feat(coding): add durable project identity core

This commit is contained in:
2026-08-26 17:59:44 +08:00
parent 7e54b8fbda
commit 43f58fc72b
12 changed files with 717 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { ProjectType } from '../../../shared/project-config';
import type { ProjectIdentityChoice } from '../../../shared/coding-project-contracts';
import type { CodingProjectConfigSnapshot } from '../../coding-projects/project-service';
import type { CodingProject } from '../../coding-projects/project-store';
import type { HostApiContext } from '../context';
@@ -65,10 +66,41 @@ export async function handleCodingProjectRoutes(
parentPath?: string;
projectName?: string;
projectType?: ProjectType;
identity: ProjectIdentityChoice;
}>(req);
sendJson(res, 201, { snapshot: publicProjectSnapshot(await projects.createProject(body)) });
return true;
}
if (url.pathname === '/api/coding/projects/identity' && req.method === 'POST') {
const body = await parseJsonBody<{
localProjectId?: string;
identity: ProjectIdentityChoice;
}>(req);
sendJson(res, 200, {
snapshot: publicProjectSnapshot(
await projects.resolveProjectIdentity(
body.localProjectId ?? '',
body.identity,
),
),
});
return true;
}
if (url.pathname === '/api/coding/projects/identity/independent-copy' && req.method === 'POST') {
const body = await parseJsonBody<{
localProjectId?: string;
confirmed: unknown;
}>(req);
sendJson(res, 200, {
snapshot: publicProjectSnapshot(
await projects.makeProjectIndependentCopy(
body.localProjectId ?? '',
body.confirmed as true,
),
),
});
return true;
}
if (url.pathname === '/api/coding/projects/remove' && req.method === 'POST') {
const body = await parseJsonBody<{ projectId?: string }>(req);
await projects.removeProject(body.projectId ?? '');