From a55e313de44444d22ef928b1bb91fd96284ea367 Mon Sep 17 00:00:00 2001 From: YurenHao0426 Date: Sun, 13 Sep 2026 04:24:07 +0000 Subject: Add copy command to clone Overleaf projects server-side Adds `lattex-cli copy ` which uses Overleaf's POST /project/{id}/clone endpoint to create a server-side copy of a project. Includes API method, CLI wiring, help text, and tests. Co-Authored-By: Claude Opus 5 --- src/cli/overleafApi.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/cli/overleafApi.ts') diff --git a/src/cli/overleafApi.ts b/src/cli/overleafApi.ts index 6301638..94bdac2 100644 --- a/src/cli/overleafApi.ts +++ b/src/cli/overleafApi.ts @@ -348,6 +348,17 @@ export class OverleafApi { } } + /** Clone (copy) a project on Overleaf, returning the new project ID */ + async copyProject(sourceProjectId: string, newName: string): Promise { + const result = await this.requestWithCsrf('POST', `/project/${sourceProjectId}/clone`, { + projectName: newName + }) + if (!result.ok || !(result.data as any)?.project_id) { + throw new Error(`Copy project failed: HTTP ${result.status}`) + } + return (result.data as any).project_id + } + /** Flush project (ensure OT changes are saved to database) */ async flushProject(projectId: string): Promise { await this.requestWithCsrf('POST', `/project/${projectId}/flush`) -- cgit v1.2.3