feat: preserve source-bound experience drafts and reversible adoption
This commit is contained in:
+13
-1
@@ -55,7 +55,7 @@ const research = [
|
||||
{ id: 'context', title: 'Claude Code:上下文与恢复', file: 'research/CONTEXT-RECOVERY.md', description: '压缩预算、摘要校验、会话链与未完成调用。' },
|
||||
{ id: 'tools', title: 'Claude Code:工具循环', file: 'research/TOOL-LOOP.md', description: '参数校验、队列、并发安全与权限判断。' },
|
||||
];
|
||||
const memories = new ProjectMemoryManager(store);
|
||||
const memories = new ProjectMemoryManager(store, { redact: value => provider.redact(value) });
|
||||
|
||||
function json(response, value, status = 200) {
|
||||
response.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store',
|
||||
@@ -168,6 +168,18 @@ return async (request, response) => {
|
||||
return json(response, await memories.list(projectMemoryMatch[1], { includeExpired }));
|
||||
}
|
||||
const sessionMemoryMatch = route.match(/^\/api\/sessions\/([a-f0-9-]+)\/memories$/i);
|
||||
const experienceMatch = route.match(/^\/api\/sessions\/([a-f0-9-]+)\/memories\/experiences(?:\/([a-f0-9-]+)\/(edit|adopt|withdraw|reject|counterexample|archive))?$/i);
|
||||
if (experienceMatch) {
|
||||
const session = store.session(experienceMatch[1]);
|
||||
if (method === 'GET' && !experienceMatch[2]) return json(response, memories.experiences.sources(session));
|
||||
if (method === 'POST') {
|
||||
if (workerForProject(store, session.projectId)) throw workerConflict('请从来源项目的记忆入口管理经验。');
|
||||
const input = await body(request);
|
||||
return json(response, experienceMatch[2]
|
||||
? await memories.experiences.change(session, experienceMatch[2], experienceMatch[3], input)
|
||||
: await memories.experiences.create(session, input), experienceMatch[2] ? 200 : 201);
|
||||
}
|
||||
}
|
||||
if (sessionMemoryMatch && method === 'GET') {
|
||||
const session = store.session(sessionMemoryMatch[1]);
|
||||
const includeExpired = url.searchParams.get('include_expired') !== '0';
|
||||
|
||||
Reference in New Issue
Block a user