feat(coding): add durable project identity core
This commit is contained in:
@@ -178,6 +178,9 @@ export function createCodingComposition(
|
||||
.catch(() => []);
|
||||
for (const conversation of conversations) registry.forget(conversation.id);
|
||||
},
|
||||
onProjectIdentityChanging: async (project) => {
|
||||
await options.browser.close(project.path);
|
||||
},
|
||||
onProjectDeactivated: async (project, reason) => {
|
||||
const conversations = await conversationStoreForProject(project.path).read()
|
||||
.then((file) => file.conversations)
|
||||
|
||||
@@ -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 ?? '');
|
||||
|
||||
@@ -5,6 +5,8 @@ import { sendJson } from '../route-utils';
|
||||
|
||||
const FIXED_CODING_ERROR_MESSAGES: Readonly<Record<string, string>> = {
|
||||
CODING_ACTIVE_PROJECT_REQUIRED: '请先选择一个编程项目。',
|
||||
CODING_ACTIVE_PROJECT_INVALID: '当前编程项目不可用,请重新打开。',
|
||||
CODING_ACTIVE_PROJECT_PATH_MISMATCH: '当前编程项目路径已变化,请重新打开。',
|
||||
CODING_AGENT_NOT_FOUND: '当前伙伴不可用,请重新选择。',
|
||||
CODING_AGENT_ID_IMMUTABLE: '已有伙伴标识不能修改。',
|
||||
CODING_CONVERSATION_NOT_FOUND: '指定的对话不存在。',
|
||||
@@ -19,6 +21,8 @@ const FIXED_CODING_ERROR_MESSAGES: Readonly<Record<string, string>> = {
|
||||
CODING_PROJECT_ALREADY_EXISTS: '该编程项目已经存在。',
|
||||
CODING_PROJECT_CONFIG_INVALID: '项目配置无效,请检查后重试。',
|
||||
CODING_PROJECT_IDENTITY_IMMUTABLE: '项目创建标识不能修改。',
|
||||
CODING_PROJECT_IDENTITY_CONFIRMATION_REQUIRED: '设为独立副本需要明确确认。',
|
||||
CODING_PROJECT_IDENTITY_REQUIRED: '请先为该编程项目选择项目 ID。',
|
||||
CODING_PROJECT_NOT_FOUND: '指定的编程项目不存在。',
|
||||
CODING_PROJECT_REQUEST_INVALID: '项目请求无效,请检查输入。',
|
||||
CODING_PROJECT_TYPE_IMMUTABLE: '项目类型创建后不能修改。',
|
||||
|
||||
Reference in New Issue
Block a user