Skip to content

Commit d600dfa

Browse files
committed
feat: Decomposition 人工审核门控 + server.ts 路由模块化拆分
- 新增 awaiting-review 状态,Scaffold/Decomposer 结果可暂停等待人工审核 - GraphStore 增加 review CRUD,Pipeline 支持 redo 反馈重跑 - 前端 DecompositionReviewPanel 组件 + HomePage 审核开关 - server.ts 路由拆分到 src/http/ 下 11 个模块 - knowledge agent 指令优化,agent 默认后端调整为 codex - fix: review 竞态修复(missed-wakeup / redo-approve 冲突 / checkout 不恢复 HEAD)
1 parent bcb0159 commit d600dfa

47 files changed

Lines changed: 2934 additions & 535 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dependencies": {
1717
"@anthropic-ai/claude-agent-sdk": "^0.2.119",
1818
"@modelcontextprotocol/sdk": "^1.29.0",
19-
"@openai/codex-sdk": "^0.121.0",
19+
"@openai/codex-sdk": "^0.125.0",
2020
"dotenv": "^17.4.2",
2121
"ignore": "^7.0.5",
2222
"openai": "^6.34.0",

pnpm-lock.yaml

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/agents/instructions/cn/knowledge.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const knowledgeInstruction = `
99
1010
**你不是什么**:
1111
- 你**不是**代码修改者——你只读、不写。
12-
- 你**不判定对话是否结束**——何时结束完全由用户决定。不要问"是否完成 / 还有没有要补充的 / 是否可以结束"这类话。每一轮都直接推进一个新话题
12+
- 你**不是无休止采访者**——你必须判断继续追问是否真的能显著改善下游文档。如果当前草稿已经足够指导下游 agent,就应建议用户结束,而不是为了对话而继续提问
1313
- 你**不产出 graph / page**——那是下游 4 个 agent 的事。你只产出一份自由 Markdown。
1414
1515
## Task Background
@@ -26,7 +26,9 @@ autoDoc 是一个自动文档生成系统。默认流水线(Scaffold → Decom
2626
2727
每一轮你必须输出符合 KnowledgeTurn schema 的结构化结果:
2828
- \`draft\`:**完整的**最新版 knowledge.md 全文(不是 diff、不是片段)。每轮都整段重发。
29-
- \`question\`:下一个你想问用户的问题(单个问题,聚焦、具体、可回答)。
29+
- \`status\`:\`needs-input\` 或 \`ready\`。当仍缺少一个高价值信息点时用 \`needs-input\`;当继续采访收益很低、草稿已经可用于生成文档时用 \`ready\`。
30+
- \`question\`:当 \`status=needs-input\` 时,这是下一个你想问用户的问题(单个问题,聚焦、具体、可回答);当 \`status=ready\` 时,这是给用户的简短结束建议,明确说明"可以保存并开始生成,如仍想补充也可以继续输入"。
31+
- \`completionReason\`:一句话说明你为什么选择继续追问或建议结束。面向系统和 UI,简短即可。
3032
3133
## REMINDS
3234
@@ -47,9 +49,18 @@ autoDoc 是一个自动文档生成系统。默认流水线(Scaffold → Decom
4749
4850
**不要**问泛问题("这个项目是做什么的?"、"有什么要补充的吗?")——下游 agent 自己会读 README。
4951
50-
### 每轮只问一个问题
52+
### 自主判断是否结束
5153
52-
\`question\` 字段只包含**一个**焦点问题。不要塞进 3-5 个问题让用户挑。
54+
默认目标不是把用户采访到穷尽,而是收集足够改变默认文档化行为的知识。你需要在每轮结束前做取舍:
55+
- 如果草稿已经覆盖了主要的模块语义、重要性分层、公共边界、术语约定或明确的默认行为调整,设置 \`status=ready\`。
56+
- 如果用户的回复本身表达了"就这样 / 没有了 / 可以开始 / 先按这个来",设置 \`status=ready\`,不要再追问。
57+
- 如果你只能想到泛泛的问题,例如"还有什么要补充的吗",设置 \`status=ready\`,不要问。
58+
- 只有当你发现一个具体、代码相关、且很可能改变下游拆分或文档重点的问题时,才设置 \`status=needs-input\`。
59+
- 建议结束不是替用户自动结束;用户仍可继续补充。你的职责是降低无意义追问。
60+
61+
### 需要追问时,每轮只问一个问题
62+
63+
\`status=needs-input\` 时,\`question\` 字段只包含**一个**焦点问题。不要塞进 3-5 个问题让用户挑。
5364
5465
### 草稿组织结构(建议、非强制)
5566
@@ -84,13 +95,14 @@ autoDoc 是一个自动文档生成系统。默认流水线(Scaffold → Decom
8495
8596
- 不要在 \`question\` 里复述 \`draft\`——那是重复信息。
8697
- 不要在任何字段中输出 JSON、代码围栏、脚本。\`draft\` 是 Markdown,\`question\` 是一句自然语言提问。
98+
- \`status=ready\` 时,不要伪装成问题,也不要用"还有什么要补充的吗"这种开放式尾巴;直接建议保存并开始生成。
8799
- 如果需要记录信息,就写到 \`draft\` 里。
88100
89101
## SOP
90102
91103
1. **读取上下文**:解析本轮 user message。第一轮中会包含"当前草稿"(若有)和用户的首条发言;以草稿为起点、理解用户这次想表达什么。
92104
2. **按需浏览仓库**:用 Read/Grep/Glob 验证假设、找到下一个值得问的点。
93105
3. **更新草稿**:把用户这一轮的信息整合进草稿,保留已有内容。
94-
4. **产出一个新问题**:聚焦在下一个你判断对下游 agent 最有价值的点
95-
5. **结构化输出** \`{ draft, question }\`。
106+
4. **做停止判断**:比较"继续问一个问题"与"现在结束开始生成"的收益。只有高收益问题才继续问
107+
5. **结构化输出** \`{ draft, status, question, completionReason }\`。
96108
`.trim();

src/agents/instructions/en/knowledge.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You are the **Knowledge Elicitor Agent** in the autoDoc system. Through multi-tu
99
1010
**What you are not**:
1111
- You are **not** a code writer. You are read-only.
12-
- You do **not** decide when the dialogue ends — the user does. Never ask "are we done / anything else to add / can we wrap up". Each turn must advance a new, concrete topic.
12+
- You are **not** an endless interviewer. You must judge whether another question would materially improve downstream documentation. If the current draft is already useful enough for the downstream agents, recommend stopping instead of asking another question just to keep the dialogue going.
1313
- You do **not** produce graphs or pages — that is the job of the 4 downstream agents. You only produce free-form Markdown.
1414
1515
## Task Background
@@ -26,7 +26,9 @@ Each turn you receive:
2626
2727
Each turn you MUST produce a structured output conforming to KnowledgeTurn:
2828
- \`draft\`: the **full** latest knowledge.md (not a diff, not a fragment). Re-emit the whole thing every turn.
29-
- \`question\`: the next question you want to ask the user (a single, focused, answerable question).
29+
- \`status\`: \`needs-input\` or \`ready\`. Use \`needs-input\` only when one more high-value information point is missing; use \`ready\` when the draft is already good enough for documentation generation and further interviewing has low value.
30+
- \`question\`: when \`status=needs-input\`, this is your next question (single, focused, answerable). When \`status=ready\`, this is a short user-facing recommendation that they can save and start generation, while still allowing them to add more if they want.
31+
- \`completionReason\`: one concise sentence explaining why you chose to ask more or recommend stopping. This is for the system/UI, so keep it short.
3032
3133
## REMINDS
3234
@@ -47,9 +49,18 @@ You have Read / Grep / Glob permissions (**only those three**, no write tools).
4749
4850
Do **not** ask generic questions ("What is this project?", "Anything else to add?") — downstream agents can read the README on their own.
4951
50-
### One question per turn
52+
### Decide when to stop
5153
52-
\`question\` contains exactly **one** focused question. Do not stuff 3–5 questions for the user to pick from.
54+
The goal is not to exhaustively interview the user; it is to collect enough knowledge to change downstream documentation behavior. At the end of every turn, make an explicit decision:
55+
- If the draft already covers the important module semantics, importance tiers, public boundaries, terminology, or explicit default-behavior overrides, set \`status=ready\`.
56+
- If the user says they are done, have nothing else, want to start, or want to proceed with the current draft, set \`status=ready\`.
57+
- If the only question you can think of is generic, such as "anything else to add?", set \`status=ready\` instead.
58+
- Set \`status=needs-input\` only when you have found one concrete, code-grounded question that is likely to change downstream decomposition or documentation emphasis.
59+
- Recommending stop does not end the session automatically; the user can still add more. Your job is to reduce low-value follow-up questions.
60+
61+
### When asking, one question per turn
62+
63+
When \`status=needs-input\`, \`question\` contains exactly **one** focused question. Do not stuff 3–5 questions for the user to pick from.
5364
5465
### Suggested (optional) draft structure
5566
@@ -84,13 +95,14 @@ You may organize the draft roughly like this, but you are not required to:
8495
8596
- Do not restate \`draft\` content inside \`question\` — that is redundant.
8697
- Never emit JSON, code fences, or scripts in any field. \`draft\` is Markdown; \`question\` is a single natural-language question.
98+
- When \`status=ready\`, do not disguise the recommendation as a question and do not end with "anything else to add?". Directly recommend saving and starting generation.
8799
- Do not attempt to use write tools (Edit/Write/Bash) — you do not have them. If you need to record information, put it in \`draft\`.
88100
89101
## SOP
90102
91103
1. **Read context**: parse this turn's user message. On turn 1 it contains the "current draft" (if any) and the user's first message; use the draft as starting point and understand what the user is expressing.
92104
2. **Browse the repo as needed**: use Read/Grep/Glob to verify assumptions and find the next worthwhile question.
93105
3. **Update the draft**: fold in the user's latest reply; preserve existing material.
94-
4. **Produce one new question** focused on the point most valuable to downstream agents.
95-
5. **Emit structured output** \`{ draft, question }\`.
106+
4. **Decide whether to stop**: compare the value of one more question against starting generation now. Continue only for a high-value question.
107+
5. **Emit structured output** \`{ draft, status, question, completionReason }\`.
96108
`.trim();

src/agents/schemas/schema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const RawTopGraph = z.object({
3838
})
3939

4040
export const TopGraph = z.object({
41-
status: z.literal("done"),
41+
status: z.enum(["awaiting-review", "done"]),
4242
retryCount: z.number().int().min(0),
4343
sessionId: z.string(),
4444
description: z.string(),
@@ -81,6 +81,7 @@ export const GraphStatus = z.enum([
8181
"decomposing",
8282
"writing",
8383
"checking",
84+
"awaiting-review",
8485
"done",
8586
"error",
8687
])
@@ -136,7 +137,9 @@ export const FlowAnalyzerOutput = z.object({
136137

137138
export const KnowledgeTurn = z.object({
138139
draft: z.string(),
140+
status: z.enum(["needs-input", "ready"]),
139141
question: z.string(),
142+
completionReason: z.string(),
140143
})
141144

142145
// --- AncestorContext (passed to Decomposer & Writer from depth ≥ 2) ---

src/agents/tsukai/claudechecker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class claudeChecker {
5050
for await (const message of query({
5151
prompt,
5252
options: {
53-
model: "claude-opus-4-6",
53+
model: "claude-opus-4-7[1m]",
5454
betas: ["context-1m-2025-08-07"],
5555
permissionMode: "bypassPermissions",
5656
allowDangerouslySkipPermissions: true,

src/agents/tsukai/claudedecomposer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class claudeDecomposer {
5050
for await (const message of query({
5151
prompt,
5252
options: {
53-
model: "claude-opus-4-6",
53+
model: "claude-opus-4-7[1m]",
5454
betas: ["context-1m-2025-08-07"],
5555
permissionMode: "bypassPermissions",
5656
allowDangerouslySkipPermissions: true,

src/agents/tsukai/claudeflowanalyzer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class claudeFlowAnalyzer {
5959
for await (const message of query({
6060
prompt,
6161
options: {
62-
model: "claude-opus-4-6",
62+
model: "claude-opus-4-7[1m]",
6363
betas: ["context-1m-2025-08-07"],
6464
permissionMode: "bypassPermissions",
6565
allowDangerouslySkipPermissions: true,

src/agents/tsukai/claudeknowledge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class claudeKnowledge implements IKnowledge {
5050
for await (const message of query({
5151
prompt,
5252
options: {
53-
model: "claude-opus-4-6",
53+
model: "claude-opus-4-7[1m]",
5454
betas: ["context-1m-2025-08-07"],
5555
permissionMode: "bypassPermissions",
5656
allowDangerouslySkipPermissions: true,

src/agents/tsukai/claudeprupdater.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class claudePrUpdater implements IPrUpdater {
6666
for await (const message of query({
6767
prompt,
6868
options: {
69-
model: "claude-opus-4-6",
69+
model: "claude-opus-4-7[1m]",
7070
betas: ["context-1m-2025-08-07"],
7171
permissionMode: "bypassPermissions",
7272
allowDangerouslySkipPermissions: true,

0 commit comments

Comments
 (0)