@thincoder/core 0.10.10 → 0.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/agent/completion.mjs +4 -1
  3. package/agent/family-tools.mjs +3 -3
  4. package/agent/helpers.mjs +13 -11
  5. package/agent/light-round.mjs +1 -4
  6. package/agent/record-results.mjs +6 -1
  7. package/agent/setup-reminders.mjs +1 -1
  8. package/agent/unbooked-pen.mjs +62 -0
  9. package/agent-tools/advisor.mjs +15 -31
  10. package/agent-tools/audit-block.mjs +16 -62
  11. package/agent-tools/batch-gate.mjs +10 -18
  12. package/agent-tools/context.mjs +1 -1
  13. package/agent-tools/design-token.mjs +9 -2
  14. package/agent-tools/digest-budget.mjs +2 -0
  15. package/agent-tools/doc-check.mjs +3 -14
  16. package/agent-tools/manifest.mjs +3 -4
  17. package/agent-tools/review-facts.mjs +35 -81
  18. package/agent-tools/settings.mjs +65 -5
  19. package/agent-tools/spawn-gates.mjs +68 -31
  20. package/agent-tools/subagent-async.mjs +6 -3
  21. package/agent-tools/subagent-spawn.mjs +42 -61
  22. package/agent-tools/subagent.mjs +15 -15
  23. package/browser/launch.mjs +14 -3
  24. package/browser/queue.mjs +31 -3
  25. package/browser/session.mjs +4 -0
  26. package/config-defaults.mjs +8 -0
  27. package/config-presets.mjs +1 -1
  28. package/config.mjs +60 -11
  29. package/doc-check/anchors.mjs +10 -9
  30. package/doc-check/index.mjs +27 -23
  31. package/doc-check/paragraph.mjs +119 -0
  32. package/fts-text.mjs +4 -1
  33. package/ledger-cmd.mjs +17 -4
  34. package/ledger-db.mjs +14 -8
  35. package/ledger.mjs +1 -1
  36. package/manifest-discovery.mjs +19 -10
  37. package/manifest.mjs +17 -5
  38. package/model-context.mjs +98 -0
  39. package/model-specs.mjs +110 -37
  40. package/package.json +2 -2
  41. package/permission.mjs +3 -1
  42. package/prompts/advisor-design.md +15 -0
  43. package/prompts/common.md +1 -0
  44. package/prompts/discipline-engineering.md +27 -6
  45. package/prompts/discipline-normal.md +7 -7
  46. package/prompts/persona-eng-designer.md +16 -4
  47. package/prompts/persona-engineering.md +16 -27
  48. package/provider/anthropic.mjs +127 -4
  49. package/provider/core.mjs +16 -6
  50. package/provider/google.mjs +8 -8
  51. package/provider/list-models.mjs +37 -5
  52. package/provider/normalize.mjs +2 -2
  53. package/provider/responses.mjs +7 -7
  54. package/provider/sse.mjs +6 -5
  55. package/proxy-transport.mjs +5 -3
  56. package/proxy.mjs +2 -1
  57. package/session-guard.mjs +7 -1
  58. package/session-lifecycle.mjs +23 -8
  59. package/session-segments.mjs +1 -0
  60. package/session-slot-claims.mjs +4 -0
  61. package/session-slot-write.mjs +6 -0
  62. package/session-slots-manifest.mjs +4 -0
  63. package/token-ttl.mjs +10 -0
  64. package/tool-docs/advisor.md +24 -5
  65. package/tool-docs/doc_check.md +23 -16
  66. package/tool-docs/ledger.md +2 -2
  67. package/tool-docs/subagent.md +41 -16
  68. package/tools/web-deepseek.mjs +26 -11
  69. package/doc-check/version.mjs +0 -84
  70. package/doc-check/width.mjs +0 -87
package/CHANGELOG.md CHANGED
@@ -3,7 +3,31 @@
3
3
  All notable changes to the core package are documented here.
4
4
  Format: Keep a Changelog · 中文 · 号在发布时定(CalVer——见 `docs/RELEASE.md` §4)。
5
5
 
6
- ## [Unreleased]
6
+ ## [0.10.11] — 2026-10-25
7
+
8
+ ### Added
9
+
10
+ - **`providers[].modelContext`(按模型的人工上下文声明,单位 K)**:键 = 模型 ID(末段归一等价——`qwen/ZHIPU/GLM-5.3` ≡ `glm-5.3`),值 = 正整数 K(`128` = 128K)。
11
+ - **模型上下文五级解析链**:`modelContext` > 旧键 `providers[].context` > 渠道 `/models` 自报(`context_window` / `context_length` / `max_model_len`,取第一个合法值)> `MODEL_SPECS` 静态表 > 默认 128K;列表自报值是 token(直接采用),人工声明是 K(核内唯一乘点 ×1024)。
12
+ - **核导出 `providerSpecResolution(provider)` / `formatContextK(tokens)`**:来源五值(`modelContext` / `provider-override` / `list` / `spec` / `default`)与三端同一展示格式器。
13
+
14
+ ### Changed
15
+
16
+ - **旧键 `providers[].context` 退役为只读过渡层(A7 兼容)**:仍可读(L2,K 单位,仅未被 `modelContext` 点名的模型),但不再写入新配置——K 单位旧编辑命令退役,三端写面改用 `modelContext`(三端同批,随各端包发布);实际用到 L2 时告警一次并给出迁移形 `modelContext: { "<模型>": <K> }`(单位同为 K)。
17
+ - **`requestBudget().windowSource` 扩为五值**:读 `providerSpecResolution().source`(原二值 `provider-override` / `spec`),五个枚举值原样入 `Request budget:` 行(不并类)。
18
+ - **模型名匹配改「末段唯一」**:按 `/` 拆分后只取最后一段查表,不再先扫完整名——`glm-5.3/zzz` 由误命中 `glm-5.3`(1M 上下文)改为未命中(`DEFAULT_SPEC` + 告警);`kimi/kimi-k3` 表行退役(末段 `kimi-k3` 已有同值行,含 `/` 的键不可达)。
19
+
20
+ ## [0.10.10] — 2026-10-22
21
+
22
+ ### Added
23
+
24
+ - **子代理 `manifest` 只读面**:同名工具、`action` 枚举只剩 `read`(schema 级不可达 + execute 入口再拒一次),挂全部 depth>0 角色段;写面仍归主 agent——`init` / `write` 不在其装配,只读位也不落在全量变体上,审批门不被绕过。`readAction` 增 `canInit`:子代理侧缺档 / 无项目两态的引导行不再指向它调不到的 `init`。
25
+ - **`thincoder-core/prompts/common.md` 新增「动手前先查文档」一节**:代码只记形状,理由与后果住在文档里;一次会话只完成大任务的一步、上下文只是项目已知内容的一小部分,不先查就是拿局部当整体。
26
+
27
+ ### Changed
28
+
29
+ - **提示词面 16 档重写(一条规则一行)**:`>300` 字符行 290 → **0**(最长 1,486 → 300,为未改动原行);整句加粗 / 回查指代 / 出处括注 / 写死配置值 / 本仓路径 / 中文评审面六类残留清零。判据 = 「换个仓还成立吗」——规则只写行为,不写归属、不写配置值、不写本仓路径(配置值改教模型用 `settings` 读,路径改教用 `manifest` 取 `docRoot`)。
30
+ - **`tool-docs` 计数随动**:53 → 54 档(枚举工具 52 → 53)。
7
31
 
8
32
  ## [0.10.9] — 2026-10-19
9
33
 
@@ -191,7 +215,9 @@ Format: Keep a Changelog · 中文 · 号在发布时定(CalVer——见 `docs
191
215
 
192
216
  ### Added
193
217
 
194
- - **规格表覆盖扩面(新名专行)**:`qwen-flash` / `qwen-vl-max`(实测输出上限 32_768——服务端直报 `[1, 32768]`;前者思考默认可开、后者不支持)、`claude-fable-5.1`(1_000_000 / 128_000)、`gemini-3.1-pro`(1_048_576 / 65_536)、`stepfun/step-3.7-flash`(262_144);kimi-code 平台三行(`kimi-for-coding` / `kimi-for-coding-highspeed` / `k3-256k`——含 effort 枚举与默认档)——掉兜底名不再退默认。
218
+ - **规格表覆盖扩面(新名专行)**:`qwen-flash` / `qwen-vl-max`(实测输出上限 32_768——服务端直报 `[1, 32768]`;前者思考默认可开、后者不支持)、
219
+ `claude-fable-5.1`(1_000_000 / 128_000)、`gemini-3.1-pro`(1_048_576 / 65_536)、`stepfun/step-3.7-flash`(262_144);
220
+ kimi-code 平台三行(`kimi-for-coding` / `kimi-for-coding-highspeed` / `k3-256k`——含 effort 枚举与默认档)——掉兜底名不再退默认。
195
221
  - **bench 受测 10 档规格行**:此前经泛前缀/兜底解析的受测模型补独立行 + 视觉声明分态登记。
196
222
  - **跨实例意图认领层(P1)**:`peers/{sessionId}.json` 增 claims 意图域(TTL 30 分钟租约 · 进程死亡即失效);写前命中他实例活认领 ⇒ 软提示(不阻写;与写后足迹登记分开存)。
197
223
 
@@ -8,6 +8,7 @@
8
8
  import { hasCodeMutations } from "../advisor/repos.mjs"
9
9
  import { pushReal } from "../context.mjs"
10
10
  import { advisorReviewPending, effectiveAdvisorRound } from "../agent-tools/advisor-async.mjs"
11
+ import { poolLive } from "./suspension.mjs"
11
12
 
12
13
  const MAX_VERIFY_PUSHBACKS = 2
13
14
  const MAX_VERIFY_RETRIES = 3
@@ -59,7 +60,9 @@ export function handleCompletion(agent, response, depth, turn, guardPushbacks, h
59
60
  // list state earns one fresh reminder.
60
61
  // F10(催更门连带):工程模式下 task 工具机械停用(装配摘除 + execute 拒)⇒ 不再发指向被拒
61
62
  // 工具的提醒(死胡同提醒防线);列表本体与 `_taskPushbacks` 预算语义零改。
62
- if (depth === 0 && !agent.config?.agent?.engineering && agent.tasks.some((t) => t.status === "pending") && (agent._taskPushbacks ?? 0) < 1) {
63
+ // TIMEOUT-DIGEST.md §2.3(#29):后台池 live 时不推回——池在飞时回合本就还会被 settle 唤醒,
64
+ // 此时催 task 只会拖回合;判据复用 `poolLive`(与挂起尾巴同一口径,不立第二处)。
65
+ if (depth === 0 && !agent.config?.agent?.engineering && !poolLive(agent) && agent.tasks.some((t) => t.status === "pending") && (agent._taskPushbacks ?? 0) < 1) {
63
66
  agent._taskPushbacks = (agent._taskPushbacks ?? 0) + 1
64
67
  const pending = agent.tasks.filter((t) => t.status === "pending").map((t) => t.title).join(", ")
65
68
  pushReal(agent, { role: "assistant", content: response.content })
@@ -95,8 +95,8 @@ export async function assembleFamilyTools({
95
95
  // async, the check/status params (id/n), the eng-coder token params
96
96
  // (designToken/designId are meaningless for a read-only spawn; the parent
97
97
  // spawn already carried the token) and batchDoc (an audit child derives no
98
- // batch parameter — its task book rides the mechanical summary of the
99
- // parent's _engTaskInput instead). Schema noise would invite the
98
+ // batch parameter — its task book rides the parent's batch record §2 instead
99
+ // (the audit block carries the batchDoc path)). Schema noise would invite the
100
100
  // model to pass irrelevant args.
101
101
  delete props.async // sync only — the parent blocks on the child's report
102
102
  delete props.id
@@ -126,7 +126,7 @@ export async function assembleFamilyTools({
126
126
  name: "subagent",
127
127
  description: designer
128
128
  ? "Spawn a read-only `explore` sub-agent to SURVEY the current state for the design: it reads code / docs / existing designs and reports evidence with file:line. BLOCKING ONLY (no async) and action:'spawn' ONLY — the survey channel is read-only; escalate/status/cancel/panel/consume-design/observe/send are not available. Survey budget: ≤6 explore spawns per batch — the main agent's survey result is reference only; do your own. The spawn carries the five task-book parameters (four core: goal / knownFacts / acceptance / reportFormat + `scope`); a task-only spawn is refused."
129
- : "Spawn a read-only `explore` sub-agent to AUDIT your delivery against the design: it compares the delivered code with the design for divergence — partially implemented acceptance criteria, silent simplifications, doc drift, changes outside the approved file list. BLOCKING ONLY (no async — the audit report decides your next protocol step). action:'spawn' ONLY — the audit channel is a read-only spawn; escalate/status/cancel/panel/consume-design/observe/send are not available. The audit task book is appended MECHANICALLY — your own spawn task (docs involved / acceptance criteria / file list) plus the files you actually touched; never hand the audit a self-written file list (a self-report could omit exactly the out-of-scope file it must catch). The spawn carries the five task-book parameters (four core: goal / knownFacts / acceptance / reportFormat + `scope`); a task-only spawn is refused.",
129
+ : "Spawn a read-only `explore` sub-agent to AUDIT your delivery against the design: it compares the delivered code with the design for divergence — partially implemented acceptance criteria, silent simplifications, doc drift, changes outside the approved file list. BLOCKING ONLY (no async — the audit report decides your next protocol step). action:'spawn' ONLY — the audit channel is a read-only spawn; escalate/status/cancel/panel/consume-design/observe/send are not available. The audit context is appended MECHANICALLY — the batch record path (its §2 is the delivery's task book, read it before judging) plus the files you actually touched; never hand the audit a self-written file list (a self-report could omit exactly the out-of-scope file it must catch). The spawn carries the five task-book parameters (four core: goal / knownFacts / acceptance / reportFormat + `scope`); a task-only spawn is refused.",
130
130
  parameters: { ...subagentTool.parameters, properties: props },
131
131
  }
132
132
  })()
package/agent/helpers.mjs CHANGED
@@ -150,24 +150,26 @@ export async function cleanupOldToolResults(dir) {
150
150
  }
151
151
  }
152
152
 
153
- /** Offload oversized tool results (>64K chars) to disk, returning a head+tail preview + file path
154
- * (2026-09-04 §5 — dual-end preview; the failed-offload fallback uses the same dual-end slice).
155
- * Writes trigger write-time self-cleanup of the offload dir first (dir param overridable for tests). */
156
- export async function offloadToolResult(text, callId, dir = join(configDir, "tool-results")) {
157
- if (text.length <= TOOL_RESULT_OFFLOAD_LIMIT) return text
153
+ /** Offload a tool result / report to disk (§2.2): `force` = write regardless of size (async
154
+ * subagent reports must survive the parent turn). Rendering splits on the SAME constant as the old
155
+ * gate: ≤ TOOL_RESULT_OFFLOAD_LIMIT ⇒ body once + path (never dual-end — a short body would come
156
+ * out twice with `middle omitted: 0 chars`); > ⇒ dual-end preview + path. Writes self-clean first. */
157
+ export async function offloadToolResult(text, callId, dir = join(configDir, "tool-results"), { force = false } = {}) {
158
+ const overLimit = text.length > TOOL_RESULT_OFFLOAD_LIMIT
159
+ if (!force && !overLimit) return text
158
160
  try {
159
161
  await cleanupOldToolResults(dir)
160
162
  await mkdir(dir, { recursive: true })
161
163
  const file = join(dir, `${Date.now()}-${String(callId).replace(/[^a-zA-Z0-9_-]/g, "_")}.log`)
162
164
  await writeFile(file, text, "utf8")
163
- return (
164
- buildDualEndPreview(text) +
165
- `\n\n[... output too large (${text.length} chars total), full content saved to: ${file}\n` +
165
+ if (!overLimit) return `${text}\n\n[... full content saved to: ${file}\nPage through it with the read tool (offset/limit) if you need the full text later.]`
166
+ return buildDualEndPreview(text) + `\n\n[... output too large (${text.length} chars total), full content saved to: ${file}\n` +
166
167
  `Page through it with the read tool (offset/limit) or sed -n 'START,ENDp' — do NOT re-run the tool blindly.]`
167
- )
168
168
  } catch {
169
- // review #3: fallback uses the same dual-end slice (head + omitted note + tail, no path hint)
170
- return buildDualEndPreview(text) + `\n\n[... truncated: ${text.length} chars total, offload to disk failed]`
169
+ // 写盘失败不吞报告:>LIMIT 走双端预览 + 原文案;≤LIMIT 正文整段在前(不谎称 truncated)
170
+ const body = overLimit ? buildDualEndPreview(text) : text
171
+ return body + (overLimit ? `\n\n[... truncated: ${text.length} chars total, offload to disk failed]`
172
+ : `\n\n[... full text kept inline above (${text.length} chars), offload to disk failed]`)
171
173
  }
172
174
  }
173
175
 
@@ -21,9 +21,6 @@ import { projectRootView, resolveProjectRoot } from "../manifest.mjs"
21
21
  import { resolveDeclaredRef } from "../declaration.mjs"
22
22
  import { readBatchStatusLine } from "../agent-tools/batch-skeleton.mjs"
23
23
 
24
- /** 轮型标记(§2.3 开轮形升格为闸凭据;全链批行无此标记 ⇒ 不构成信号)。 */
25
- const ROUND_MARKER = "收尾链待跑"
26
-
27
24
  /** 轻通道轮在盘谓词(异步 · 只读 · fail-closed)。契约见头注。
28
25
  * @param {object} agent — 会话 agent(读 `cwd`)
29
26
  * @returns {Promise<boolean>} true = 放行(在盘轮次);读错 ∥ 不可判 ⇒ false(照拦)
@@ -33,7 +30,7 @@ export async function lightRoundOpen(agent) {
33
30
  const cwd = agent?.cwd
34
31
  if (typeof cwd !== "string" || cwd.trim() === "") return false
35
32
  // W8 契约②:node:sqlite 链只经动态 import 进入(勿升静态)——候选枚举与逐候选查行同取本档公共面。
36
- const { ledgerChildren, ledgerQuery } = await import("../ledger.mjs")
33
+ const { ledgerChildren, ledgerQuery, ROUND_MARKER } = await import("../ledger.mjs")
37
34
  const anchor = resolve(cwd)
38
35
  // 候选面 = 锚自身 + 直接子目录一层(纯向下;子项枚举单源 = `ledgerChildren`)。
39
36
  const candidates = [anchor, ...ledgerChildren(anchor).map((p) => p.root)]
@@ -26,6 +26,8 @@
26
26
  import { pushReal } from "../context.mjs"
27
27
  import { specForModel } from "../config.mjs"
28
28
  import { FILE_MUTATORS, toolTouchPaths } from "./helpers.mjs"
29
+ // F-LC6(LIGHT-CHANNEL §2.9 · 台账 #1753):无账之笔提醒叶(谓词 + 文案 + 闩单源)。
30
+ import { unbookedPenNotice } from "./unbooked-pen.mjs"
29
31
  import { capHistoryImages } from "../provider/normalize.mjs"
30
32
  import { resolve } from "node:path"
31
33
  import { advisorRuns, stripApprovedSuffix } from "../agent-tools/advisor-async.mjs"
@@ -82,7 +84,10 @@ export async function recordToolResults(agent, toolByName, results) {
82
84
  }
83
85
  } catch { /* Parse failure doesn't affect normal tool messages */ }
84
86
  }
85
- pushReal(agent, { role: "tool", tool_call_id: toolCall.id, name: toolCall.name, content: result })
87
+ // F-LC6(LIGHT-CHANNEL §2.9):主 agent 会话首笔产品源文件笔 ⇒ 回执末尾追加一行通道提醒
88
+ // (零拦截——只拼回执文本、入史时机不变;命中后本会话不再提示)。
89
+ const penNotice = unbookedPenNotice(agent, toolCall, ok, tool)
90
+ pushReal(agent, { role: "tool", tool_call_id: toolCall.id, name: toolCall.name, content: penNotice ? result + penNotice : result })
86
91
  if (tool && ok) {
87
92
  if (FILE_MUTATORS.has(toolCall.name)) {
88
93
  // Direct file edit — code was changed. The prior advisor review and
@@ -88,7 +88,7 @@ export function manifestStateLine({ phase }) {
88
88
  */
89
89
  export function manifestReportLine({ state, cwd, root, path, candidates, errors, matched } = {}) {
90
90
  if (state === "no-project") {
91
- return `${MANIFEST_LINE_PREFIX}none — no project at ${cwd} (no manifest on the ancestor chain, none below). ` +
91
+ return `${MANIFEST_LINE_PREFIX}none — no project at ${cwd} (no manifest at this directory, none in the direct children). ` +
92
92
  `Parameters fall back to defaults. Create PROJECT-MANIFEST.json here to land a project (git optional).]`
93
93
  }
94
94
  if (state === "workspace") {
@@ -0,0 +1,62 @@
1
+ /**
2
+ * unbooked-pen.mjs — 无账之笔提醒叶(批 unbooked-pen · 台账 #1753)。
3
+ * 设计权威 = `docs/core/design/LIGHT-CHANNEL.md` §2.9(F-LC6);需求 = `docs/core/requirements/LIGHT-CHANNEL.md` §2.6。
4
+ *
5
+ * 机制:每会话**首次**由主 agent 落下**产品源文件**笔时,在工具回执末尾追加一行通道确认提醒。
6
+ * 只提示——不拦、不放行、不改任何判据;文案为条件句(轻通道笔须先挂轮,全链笔交 eng-coder)。
7
+ * 承载形对齐先例 `agent-tools/zero-write-watch.mjs`(谓词叶 + 文案函数 + 闩 + 非阻塞)。
8
+ * 零环:只 import 既有单源(`FILE_MUTATORS` ∥ `toolTouchPaths` ∥ `isCodePath` ∥ `declarationForTarget`),
9
+ * 只被 `agent/record-results.mjs` import(不反向引)。
10
+ */
11
+ import { resolve } from "node:path"
12
+ import { FILE_MUTATORS, toolTouchPaths } from "./helpers.mjs"
13
+ import { declarationForTarget } from "../declaration.mjs"
14
+ import { isCodePath } from "../conventions.mjs"
15
+
16
+ /** 笔集(§2.9 ②):`FILE_MUTATORS` **减** `delete`——减式派生,不另抄第二份工具名清单
17
+ * (`FILE_MUTATORS` 增删成员时本集自动跟上)。`delete` 不入集:删产品源文件须 `force`、
18
+ * 是显式动作,本批无场景(K20)。 */
19
+ export const PEN_TOOLS = new Set([...FILE_MUTATORS].filter((name) => name !== "delete"))
20
+
21
+ /** 文案单源(§2.9 文案块逐字——条件句 + 后果句;改文案只改这一处)。 */
22
+ export function unbookedPenText() {
23
+ return "[pen check] first product-source write this session — confirm the channel before it lands: a light-channel pen needs its round booked first (batch record + an in-flight ledger row pointing at the record); a full-chain pen goes to eng-coder. A pen with no account is invisible at closeout, so the ledger settlement misses it."
24
+ }
25
+
26
+ /**
27
+ * 四合取 + 一闩判定(§2.9 触发面)——命中:置闩并返回回执后缀(`\n` + 文案行);未中:空串。
28
+ * ① 身份 = 主 agent(`_role == null`——主会话装配不传 role,子代理 spawn 面统一传角色)
29
+ * ② 工具 ∈ `PEN_TOOLS` ③ `ok === true` ④ 任一目标分类为产品源文件
30
+ * (逐目标 `resolve(cwd, p)` → `declarationForTarget(abs)` → `isCodePath(abs, conv)`——与父侧门
31
+ * `agent/dispatch.mjs:111-118` 同式;出辖目标不判,任一命中即触发)
32
+ * 闩 = `agent._unbookedPenNotified`(每会话一次——不按轮、不按文件)。
33
+ * @param {object} agent 主 agent(读 `cwd` ∥ `_role` ∥ 闩位)
34
+ * @param {{name: string, arguments?: string}} toolCall
35
+ * @param {boolean} ok 工具结果成功位(被拒的笔没有落盘,提醒无对象)
36
+ * @param {object} [tool] 工具对象——只用于 `toolTouchPaths` 的可选钩子 `touchedPaths`
37
+ * (`apply_patch` ∥ 多目标 `edit` 的目标解析靠它;缺省按单参 `path`)
38
+ * @returns {string} 命中 = 回执后缀;未中 = ""
39
+ */
40
+ export function unbookedPenNotice(agent, toolCall, ok, tool) {
41
+ if (!agent || agent._role != null) return ""
42
+ if (!tool) return ""
43
+ if (ok !== true) return ""
44
+ if (agent._unbookedPenNotified) return ""
45
+ if (!PEN_TOOLS.has(toolCall?.name)) return ""
46
+ try {
47
+ const args = JSON.parse(toolCall.arguments || "{}")
48
+ const hit = toolTouchPaths(tool, args).some((p) => {
49
+ if (typeof p !== "string" || !p.trim()) return false
50
+ const abs = resolve(agent.cwd, p)
51
+ const conv = declarationForTarget(abs)
52
+ return !!conv && isCodePath(abs, conv)
53
+ })
54
+ if (!hit) return ""
55
+ } catch {
56
+ // 恒零抛(先例 zero-write-watch.mjs 同款):提醒是兜底面——判定失败不得中断回执提交
57
+ // (畸形 args ∥ 非标准装配的 cwd)。退回空串 = 本笔不提示,判据面零变。
58
+ return ""
59
+ }
60
+ agent._unbookedPenNotified = true
61
+ return `\n${unbookedPenText()}`
62
+ }
@@ -9,10 +9,9 @@
9
9
  */
10
10
  import { runAdvisorReview, advisorIncompleteMarker, ADVISOR_LAUNCH_REFUSAL_PREFIX } from "../advisor/run.mjs"
11
11
  import { resolveBatchDocPath } from "./batch.mjs"
12
- // M6(模块设计 §2.1 F3):评审对象来源读 manifest docRoot(声明面)——单一权威源 =
13
- // review-facts.mjs 的 resolveReviewDocPaths(2026-10-04 · #921 · KD-2——分类四分支 + B 文案
14
- // 诊断数据单源;write-gate 同名再出口保 normAbs 面)。不 import dispatch.mjs(簇间回边,环风险)。
15
- import { normAbs } from "../agent/write-gate.mjs"
12
+ // 设计评审的文档受理面单源 = review-facts.mjs 的 resolveReviewDocPaths(判据正文 =
13
+ // docs/core/design/ADVISOR-GUARDS.md §12:相对形按会话项目根 / 绝对形照用 / 受理 = 项目内现存 `.md`)。
14
+ import { projectRootView } from "../manifest-discovery.mjs"
16
15
  import { resolveReviewDocPaths } from "./review-facts.mjs"
17
16
  import {
18
17
  generateDesignToken,
@@ -62,7 +61,7 @@ export const advisorTool = {
62
61
  documents: {
63
62
  type: "array",
64
63
  items: { type: "string" },
65
- description: "Doc paths to review (design / requirements / referenced docs). Relative paths resolve against the session cwd first, then candidate project roots (project-root-relative e.g. <repo>/docs/…, or absolute). The advisor reviews ONLY these — no git diff scan. Use for both review types to pass the task's docs list.",
64
+ description: "Doc paths to review (design / requirements / referenced docs). One rule: a relative path resolves against the session project root (e.g. docs/core/design/ADVISOR-GUARDS.md); an absolute path is used as-is. Accepted = an existing .md file anywhere inside a project (a repo-root doc such as METHODOLOGY.md counts); anything else is refused with the resolved path, the reason, and the two expected forms. The advisor reviews ONLY these — no git diff scan. Use for both review types to pass the task's docs list.",
66
65
  },
67
66
  batchDoc: {
68
67
  type: "string",
@@ -111,36 +110,21 @@ export const advisorTool = {
111
110
  )
112
111
  }
113
112
 
114
- // Design review: the review scope must be documentation files. Classification =
115
- // resolveReviewDocPaths (2026-10-04 · #921 · the four-leg single authority in
116
- // review-facts.mjs): legs ① session-root set / ② owning-project root set keep the
117
- // legacy behavior verbatim; leg ③ probes candidate project roots for bare
118
- // project-root-relative forms; leg ④ disambiguates by readable-file uniqueness
119
- // (fail-closed — criterion=scope-doc-ambiguous when ≥2 candidates are readable).
113
+ // 设计评审:受理面 = 项目内现存 `.md`——相对形按会话项目根解析(越根 ⇒ 拒)· 绝对形照用 · 解析不出 ⇒ 拒并说清期望形;零试探、零歧义归一。
120
114
  if (reviewType === "design" && documents) {
121
- const { resolved, invalid, ambiguous, candidates } = resolveReviewDocPaths(documents, agent.cwd)
122
- if (invalid.length > 0 || ambiguous) {
115
+ const { invalid } = resolveReviewDocPaths(documents, agent.cwd)
116
+ if (invalid.length > 0) {
123
117
  if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
124
- if (ambiguous) {
125
- // 歧义拒(KD-4 独立判据——不混入 not-doc;列全部可读命中——fail-closed 不静默挑一)。
126
- return withIdentityLine(
127
- `Advisor: design review document "${ambiguous.doc}" matches several projects: ${ambiguous.hits.join(", ")}. Pass an absolute path to select one.`,
128
- { type: reviewType, scope: scopeSummary(documents), round: "—", criterion: "scope-doc-ambiguous" },
129
- )
118
+ // 拒发文案:既有稳定前缀逐字(行首)+ 逐文档「输入 → 解析后绝对路径 ∥ 拒因」+ 锚态(仅无项目根)+ 期望形两句。
119
+ const lines = invalid.map((v) => `- ${v.doc} → ${v.resolved ?? "(no base)"} ∥ reason=${v.reason}`)
120
+ if (invalid.some((v) => v.reason === "no-project-root")) {
121
+ const view = projectRootView(agent.cwd)
122
+ const where = view.state === "workspace" ? `workspace (${view.candidates.join(", ")})` : "none (no PROJECT-MANIFEST.json here or above)"
123
+ lines.push(`Session anchor is ${where} — no project root, so a relative path has no base to resolve against.`)
130
124
  }
131
- // not-doc 拒:既有稳定前缀逐字(行首)+ 解析诊断尾(B 面根治——逐文档「解析后绝对
132
- // 路径 ← 基面 = 会话 cwd」+ 候选项目根提示 cap 5 + 重试指引——纠正「误报因」缺陷)。
133
- const invalidList = invalid.map((v) => v.doc).join(", ")
134
- const attemptedList = invalid
135
- .map((v) => `${v.doc} → ${v.attempted.length > 0 ? v.attempted.join(" | ") : normAbs(v.doc, agent.cwd)}`)
136
- .join("; ")
137
- const shown = candidates.slice(0, 5)
138
- const more = candidates.length - shown.length
139
- const candidateNote = shown.length > 0
140
- ? `(candidates: ${shown.join(", ")}${more > 0 ? ` +${more} more` : ""}) — pass project-root-relative (e.g. ${shown[0]}/docs/…) or absolute paths`
141
- : "— pass project-root-relative or absolute paths"
125
+ lines.push("Expected form 1 — project-root-relative: docs/core/design/ADVISOR-GUARDS.md (resolved against the session project root).", "Expected form 2 — absolute: D:\\repo\\docs\\core\\design\\ADVISOR-GUARDS.md (used as-is).")
142
126
  return withIdentityLine(
143
- `Advisor: design review documents must be documentation files (per the project's conventions). Invalid: ${invalidList}\nDiagnosis: resolved against session cwd ${agent.cwd} → ${attemptedList}; no candidate project docRoot contains it ${candidateNote}.`,
127
+ `Advisor: design review documents must be documentation files (per the project's conventions). Invalid:\n${lines.join("\n")}`,
144
128
  { type: reviewType, scope: scopeSummary(documents), round: "—", criterion: "scope-not-doc" },
145
129
  )
146
130
  }
@@ -3,74 +3,26 @@
3
3
  *
4
4
  * 自 `subagent-spawn.mjs` **逐字搬移**(D23-3 外提:spawn 档越 300 软线 + 块构造成纯函数
5
5
  * ⇒ 判据可直测;D23-4:块内文本零改——含块内自指词,整块搬移不改真值)。本档承载
6
- * spawn 级固定机制性指令的第二块(审计模板 + A2 任务书摘要 + touched 快照):
6
+ * spawn 级固定机制性指令的第二块(审计模板 + 批档 §2 指向 + touched 快照):
7
7
  * 装配侧只收集(`thincoder-core/agent-tools/subagent-spawn.mjs`),下发面 = system 固块
8
8
  * (`child._spawnSystemBlock` → 核 `prepareRun` 拼接——`thincoder-core/agent/setup.mjs`)。
9
+ *
10
+ * 2026-10-24(§6.22 KD-SC6):任务书 = 批次档 §2(子代理自读);A2 拼装摘要面(按 marker 抽取
11
+ * 设计档 / 文件清单 / 验收三段)已随 KD-SC6 删除——审计块只注入批档路径行 + §2 指向句(路径取
12
+ * `ctx.agent._batchDoc`)。理由:工程角色 `_engTaskInput` 只剩一行机械文本,摘要失去来源。
9
13
  */
10
14
 
11
- /**
12
- * AGENT-LOOP-SUBAGENT.md §6.7.6 D-TS5 (A2): mechanically summarize the parent spawn task book for the
13
- * audit spawn — the three audit-relevant elements VERBATIM (design doc paths /
14
- * affected-file list / acceptance criteria); verbose context/background is
15
- * dropped (the auditor can read the design docs themselves — they stay
16
- * available outside this input). Independence preserved: the input is
17
- * _engTaskInput (mechanically kept by the parent spawn) — never the
18
- * eng-coder's self-report. Sections are located by header marker, prioritizing
19
- * header lines (structured task books: "## 文件清单 …") and falling back to
20
- * inline markers (flat one-line task books); a section runs to the next header
21
- * of the SAME OR HIGHER level ("## 文件清单" survives a "### 修改" sub-header).
22
- * Marker not found → the section is reported as missing (never fabricate).
23
- */
24
- export function summarizeEngTaskBook(taskInput) {
25
- if (!taskInput) return "(unavailable)"
26
- // 五项拼装形下,`designPoints` 一段同时承载「设计档落点」与「受影响文件清单」——
27
- // 前两段同取该块是有意的(语义都在其中);代价 = 摘要里该块出现两次,不是抽取失败。
28
- const SECTIONS = [
29
- { name: "Design docs involved", markers: [/Docs? involved/i, /涉及文档/, /^Design points/i] },
30
- { name: "Affected-file list", markers: [/Files? (?:list|to (?:modify|change)|modified)/i, /受影响文件/, /文件清单/, /涉及文件/, /^Design points/i] },
31
- { name: "Acceptance criteria", markers: [/Acceptance(?: criteria)?/i, /验收标准/] },
32
- ]
33
- const lines = taskInput.split("\n")
34
- const headerLevel = (l) => {
35
- const m = l.match(/^\s*(#{1,6})\s/)
36
- return m ? m[1].length : 0
37
- }
38
- const headerIdx = lines.map((l, i) => (headerLevel(l) > 0 ? i : -1)).filter((i) => i >= 0)
39
- const boundsFor = (from, level) => {
40
- for (const j of headerIdx) {
41
- if (j > from && (level === 0 || headerLevel(lines[j]) <= level)) return j
42
- }
43
- return lines.length
44
- }
45
- const out = []
46
- for (const { name, markers } of SECTIONS) {
47
- let from = -1
48
- let level = 0
49
- for (const i of headerIdx) {
50
- if (markers.some((m) => m.test(lines[i]))) { from = i; level = headerLevel(lines[i]); break }
51
- }
52
- if (from === -1) {
53
- for (let i = 0; i < lines.length; i++) {
54
- if (markers.some((m) => m.test(lines[i]))) { from = i; level = 0; break }
55
- }
56
- }
57
- if (from === -1) { out.push(`${name}: (not found in the parent task book)`); continue }
58
- const body = lines.slice(from, boundsFor(from, level)).join("\n").trim()
59
- out.push(body || `${name}: (empty section)`)
60
- }
61
- return out.join("\n\n")
62
- }
63
-
64
15
  /**
65
16
  * 审计块(spawn 级固定 ⇒ system 固块——§6.26 分类裁定表「审计块」行):纯函数——touched 快照
66
- * (`ctx.agent._touchedFiles`——机制面证据,非 eng-coder 自述)+ A2 任务书摘要
67
- * (`summarizeEngTaskBook(ctx.agent._engTaskInput)`)+ 指令 / 范围 / 零 git 权威 / 预算 /
68
- * 报告格式五段模板**逐字**。零副作用(只读 ctx);块内文本与搬移前逐字节一致。
69
- * @param {{ agent?: { _touchedFiles?: string[], _engTaskInput?: string } }} ctx
17
+ * (`ctx.agent._touchedFiles`——机制面证据,非 eng-coder 自述)+ 批档路径行与 §2 指向句
18
+ * (`ctx.agent._batchDoc`——任务书由审计子代理自读 §2)+ 指令 / 范围 / 零 git 权威 / 预算 /
19
+ * 报告格式五段模板**逐字**。零副作用(只读 ctx)。
20
+ * @param {{ agent?: { _touchedFiles?: string[], _batchDoc?: string } }} ctx
70
21
  * @returns {string} 块文本(不含与其它块之间的分隔符——分隔由装配侧 `join("\n\n")` 施加)
71
22
  */
72
23
  export function buildAuditBlock(ctx) {
73
24
  const touched = (ctx.agent._touchedFiles ?? []).map((f) => `- ${f}`).join("\n") || "- (none yet)"
25
+ const batchDoc = typeof ctx.agent?._batchDoc === "string" ? ctx.agent._batchDoc : "(unavailable)"
74
26
  return `[Audit scope — mechanical context, independent of the eng-coder's self-report:]\n` +
75
27
  // §6.7.6 D-TS4 A1:审计指令模板(四类偏差 + 范围限制 + 校验清单格式)——审计语义
76
28
  // 不再靠模型自悟;范围限制是 §6.7.4 D-AG3 声明(下方 Zero-git scope authority)
@@ -85,9 +37,11 @@ export function buildAuditBlock(ctx) {
85
37
  `workspace changes not listed there are unrelated to this delivery and are NOT grounds for an out-of-list finding.\n` +
86
38
  `Scope discipline (F-TS6 A1): read ONLY the audited files and the design-doc sections relevant to this delivery — do NOT re-read whole documents.\n` +
87
39
  `Every deviation item MUST be fieldized: file:line + design reference (doc path + section/AC id) + severity + evidence (quoted code or doc text).\n` +
88
- // §6.7.6 D-TS5 A2:任务书从全量 verbatim 改机械摘要块(三要素逐字——排除冗长上下文)。
89
- `[Parent spawn task book — mechanical summary: design docs + affected-file list + acceptance criteria verbatim; verbose context/background dropped — the design docs are still available for reading outside this input:]\n` +
90
- `${summarizeEngTaskBook(ctx.agent._engTaskInput)}\n` +
40
+ // §6.22 KD-SC6:任务书 = 批次档 §2(审计子代理自读)——审计块注入批档路径 + §2 指向句
41
+ // (A2 拼装摘要面已删:工程角色 _engTaskInput = 一行机械文本,摘要无来源)。审计子代理本身是
42
+ // explore(任务书 = 父侧五项)——故指向句限定为「**交付**的任务书 = §2」,不冒称本 child 的唯一通道。
43
+ `Batch record (batchDoc): ${batchDoc}\n` +
44
+ `Delivery task book: §2 of the batch record at ${batchDoc} — read it before judging the delivery; it is the criterion source for this audit.\n` +
91
45
  `Files actually touched by the eng-coder (mechanical union — audit these against the file list):\n${touched}\n` +
92
46
  // §18.5 D-AG3(2026-09-04):审计零 git 范围权威声明——本审计任务零 git(不注入
93
47
  // git 上下文——§6.7.4 全角色零 git);_touchedFiles 为审计范围;工作区未列于
@@ -95,7 +49,7 @@ export function buildAuditBlock(ctx) {
95
49
  "Zero-git scope authority: this audit task receives NO git context — nothing is injected. " +
96
50
  "The evidence base is the design documents, the current disk state (read/glob/grep), and the _touchedFiles list above. " +
97
51
  "Workspace changes NOT listed in _touchedFiles are unrelated to this delivery — they are NOT grounds for an out-of-file-list finding." +
98
- // §6.7.6 D-A1.2:审计预算句——A1 指令模板 + A2 摘要块之后、A3 报告模板之前(定序——评审 #7)。
52
+ // §6.7.6 D-A1.2:审计预算句——A1 指令模板 + 批档指向块之后、A3 报告模板之前(定序——评审 #7)。
99
53
  // 逐字设计锚(D-A1.2 代码块):只读该读的——10 轮机械预算——超时报 PROBLEM 下结论。
100
54
  // 前导 \n 与 A3 同款块分隔约定(上一句 Zero-git 句末无换行——不触碰既有句)。
101
55
  `\n[Audit budget — mechanical]: read ONLY the touched files listed above and the design-doc sections the parent task book names (affected-files table, acceptance criteria, status line). Do NOT read whole documents. Budget = 10 tool rounds max — if you cannot conclude within it, report PROBLEM (inconclusive) rather than continuing to explore.\n` +
@@ -14,9 +14,9 @@
14
14
  * `REFUSED`(K ≥ 1)∥ `ERROR` ⇒ 调用面 throw(fail-closed);命中 ⊆ 他批在途集 ⇒ 不阻收口 + 固定行逐档列出。
15
15
  *
16
16
  * 判据零变:本档不新增判据——只决定「判谁」与「何时强制」;判据与裁定串由产品引擎
17
- * `doc-check/index.mjs` 产出(判据源唯一)。引擎版本前置同源 = `doc-check/version.mjs`。
17
+ * `doc-check/index.mjs` 产出(判据源唯一)。
18
18
  *
19
- * 两条边界(设计与实测同口径):① **批档自身不入范围**(载体不是判据对象——判它只会把载体的行宽记成本批欠账);
19
+ * 两条边界(设计与实测同口径):① **批档自身不入范围**(载体不是判据对象——判它只会把载体的超段记成本批欠账);
20
20
  * ② **本轮提交面不在工具面**——`<批起 sha>` 只有父侧掌握,
21
21
  * ② 的写入集只认触达账 + 回执明示「基 sha 未定」,提交面由父侧协议清单兜(不静默)。
22
22
  */
@@ -25,7 +25,6 @@ import { relative, resolve } from "node:path"
25
25
 
26
26
  import { owningProject, readManifest } from "../manifest.mjs"
27
27
  import { runDocCheck } from "../doc-check/index.mjs"
28
- import { firstVerdictLine, gateEngineError, staleEngineFiles } from "../doc-check/version.mjs"
29
28
  import { batchProjectRoot } from "./batch-paths.mjs"
30
29
 
31
30
  /** 平台路径键(win32 大小写不敏感——只作集比对,非判据面)。 */
@@ -61,7 +60,7 @@ function gitSurface(root) {
61
60
  * (报面单源不重写);行数与命中数不等(引擎报面行序变动)⇒ `aligned: false` + 自造行,由调用面回执明示。 */
62
61
  function hitEntries(res, root) {
63
62
  const lines = res.report.split("\n").filter((l) => l.startsWith("✗ "))
64
- const hits = [...res.anchorHits, ...res.widthHits]
63
+ const hits = [...res.anchorHits, ...res.paragraphHits]
65
64
  const aligned = lines.length === hits.length
66
65
  const entries = hits.map((h, i) => ({
67
66
  file: h.file,
@@ -93,20 +92,20 @@ const emptyRange = (basis) => ({ count: 0, k: 0, foreign: 0, basis })
93
92
  const errorState = (first, range = emptyRange("none")) => ({ state: "error", first, report: first, hitLines: [], noteLines: [], range })
94
93
 
95
94
  /**
96
- * 跑一次门(**非抛错**:三因之外的门自身异常收为 `error` 态,由调用面按 `scope` 消费)。
97
- * @param {{abs:string, cwd?:string, agent?:object, scope?:'writer'|'close', clock?:object}} o
98
- * `abs` = 目标批次档绝对路径(根解析用);`agent._touchedFiles` = 触达记账;`clock` = 版本判定的测试注入缝。
95
+ * 跑一次门(**非抛错**:两因之外的门自身异常收为 `error` 态,由调用面按 `scope` 消费)。
96
+ * @param {{abs:string, cwd?:string, agent?:object, scope?:'writer'|'close'}} o
97
+ * `abs` = 目标批次档绝对路径(根解析用);`agent._touchedFiles` = 触达记账。
99
98
  * @returns {{state:'pass'|'refused'|'error'|'not-applicable', first:string|null, report:string,
100
99
  * hitLines:string[], noteLines:string[], range:{count:number, k:number, foreign:number, basis:string}}}
101
100
  * `first` = 唯一机判串(首行 `DOC-CHECK GATE:`);`not-applicable` ⇒ `first = null` + 固定回执行。
102
101
  */
103
- export function runBatchGate({ abs, cwd, agent = {}, scope = "writer", clock } = {}) {
102
+ export function runBatchGate({ abs, cwd, agent = {}, scope = "writer" } = {}) {
104
103
  // `scope` 两取值、无第三值(设计「`scope` 语义」)——未知值不静默降级(降级即 ② 变 fail-open)
105
104
  if (scope !== "writer" && scope !== "close") {
106
105
  return errorState(`DOC-CHECK GATE: ERROR(未知 scope:${JSON.stringify(scope)}——取值只有 "writer" ∥ "close")`)
107
106
  }
108
107
  try {
109
- return evaluate({ abs, cwd, agent, scope, clock })
108
+ return evaluate({ abs, cwd, agent, scope })
110
109
  } catch (e) {
111
110
  const first = `DOC-CHECK GATE: ERROR(门自身异常:${e?.message ?? String(e)})`
112
111
  return errorState(first)
@@ -114,7 +113,7 @@ export function runBatchGate({ abs, cwd, agent = {}, scope = "writer", clock } =
114
113
  }
115
114
 
116
115
  /** 门体(正常路径——异常由上抛给 `runBatchGate` 收口)。 */
117
- function evaluate({ abs, cwd, agent, scope, clock }) {
116
+ function evaluate({ abs, cwd, agent, scope }) {
118
117
  const base = resolve(cwd ?? process.cwd())
119
118
  const root = owningProject(resolve(abs)) ?? batchProjectRoot(base)
120
119
  const close = scope === "close"
@@ -127,15 +126,8 @@ function evaluate({ abs, cwd, agent, scope, clock }) {
127
126
  if (!read.ok && read.reason === "missing") {
128
127
  return { state: "not-applicable", first: null, report: "[doc-check gate] 未跑(本项目无声明面)", hitLines: [], noteLines: [], range: emptyRange("none") }
129
128
  }
130
- // 引擎版本前置(fail-closed):stale ⇒ 直接 ERROR 串,不进引擎(不产 PASS)。
131
- const version = staleEngineFiles(clock ?? {})
132
- if (version.stale.length) {
133
- const report = gateEngineError(version)
134
- return { state: "error", first: firstVerdictLine(report), report, hitLines: [], noteLines: [], range: emptyRange("none") }
135
- }
136
-
137
129
  // 范围(判谁):writer = 写者触达账;close = 本批笔域集(触达账)∪ git 面。
138
- // 批档自身不入范围(载体不是判据对象——判它只会把载体的行宽记成本批欠账)。
130
+ // 批档自身不入范围(载体不是判据对象——判它只会把载体的超段记成本批欠账)。
139
131
  const selfKey = pathKey(resolve(abs))
140
132
  const touched = docPaths(agent?._touchedFiles, base).filter((p) => pathKey(p) !== selfKey)
141
133
  const git = close ? gitSurface(root) : { ok: false, base: root, files: [] }
@@ -92,7 +92,7 @@ function statsReport(agent) {
92
92
  return [
93
93
  `Context ≈${usage.total} tokens (${pct}% of ${usage.window} window); compaction line ${usage.threshold} (${toGo} to the line)`,
94
94
  // §6.16.4 字面单源(该行为唯一字面,逐字;预算面同源 requestBudget——不自算第二套):
95
- // window {window} ({spec|provider-override}) · max_tokens {maxTokens|not sent} ({explicit|spec|absent})
95
+ // window {window} ({modelContext|provider-override|list|spec|default}) · max_tokens {maxTokens|not sent} ({explicit|spec|absent})
96
96
  // · prompt {total} · to compaction line {threshold − total} · to window limit {limit − total}
97
97
  // 两距离带符号(负 = 已越);maxTokens 未发写 not sent、来源写 absent(该档守卫不覆盖——§6.17 射程)。
98
98
  (() => {
@@ -97,8 +97,15 @@ const TRUNCATED_ECHO_MARK = "注:回显被截断(uuid 之后缺失或不符
97
97
 
98
98
  /** §5.2 verdict gate (#940): the echo alone is NOT the verdict — the receipt must
99
99
  * carry a `VERDICT: pass` line and no `VERDICT: changes-required` line (fail-closed). */
100
- const VERDICT_PASS_LINE = /^[ \t]*[*_`]*[ \t]*VERDICT:[ \t]*pass[ \t]*[*_`]*[ \t]*$/m
101
- const VERDICT_CHANGES_LINE = /^[ \t]*[*_`]*[ \t]*VERDICT:[ \t]*changes-required[ \t]*[*_`]*[ \t]*$/m
100
+ // 裁定行接受本地化等价形(GitHub #32 / #14):评审席用中文回执很常见,
101
+ // 只认英文会让 pass 落成 no-pass-line、凭证永不签发;判据仍只认整行逐字面,
102
+ // 不做「句中含『通过』」这类模糊匹配——那样会把「未通过」也放过。
103
+ const _V_PRE = "^[ \\t]*[*_`]*[ \\t]*"
104
+ const _V_SUF = "[ \\t]*[*_`]*[ \\t]*$"
105
+ const VERDICT_PASS_LINE = new RegExp(
106
+ _V_PRE + "(?:VERDICT:[ \\t]*(?:pass|通过|通过。)|结论[::][ \\t]*(?:通过|pass))" + _V_SUF, "mi")
107
+ const VERDICT_CHANGES_LINE = new RegExp(
108
+ _V_PRE + "(?:VERDICT:[ \\t]*(?:changes-required|不通过|需修改)|结论[::][ \\t]*(?:不通过|需修改|changes-required))" + _V_SUF, "mi")
102
109
  export function verdictGateFailure(rawResult) {
103
110
  if (typeof rawResult !== "string") return "no-pass-line"
104
111
  if (VERDICT_CHANGES_LINE.test(rawResult)) return "changes-required"
@@ -58,6 +58,8 @@ export function digestBudgetOver(agent, size) {
58
58
  /** Test seam: 落盘目录重定向(单元测试沙箱——生产从不调用)。 */
59
59
  let _digestOffloadDirOverride = null
60
60
  export function _setDigestOffloadDirForTest(dir) { _digestOffloadDirOverride = dir }
61
+ /** 缝的读取面(无参):生产恒 undefined ⇒ 消费方取各自默认目录。一条缝覆盖本档与 `offloadToolResult` 两族(TIMEOUT-DIGEST.md §2.2)。 */
62
+ export function _digestOffloadDirForTest() { return _digestOffloadDirOverride ?? undefined }
61
63
 
62
64
  /** 超限条目全量落盘(返回清单行文本;失败 null——调用方回退 inline——结果零丢失)。
63
65
  * tag 入文件名(溯源:写入族 + 条目 id)。 */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * agent-tools/doc-check.mjs — `doc_check` 工具:文档纪律机检(产品内建 · 两种问法)。
3
3
  *
4
- * 设计 = `docs/core/design/DOC-DISCIPLINE.md` §3.20 条目 S(判据 = 锚 ∥ 行宽 · 参数内置常量)。
4
+ * 设计 = `docs/core/design/DOC-DISCIPLINE.md` §3.20 条目 S(判据 = 锚 ∥ 段判据 · 参数内置常量)。
5
5
  * 工具形:**无动作枚举**——`mode` = 同一条判据的两种问法(`report` = 报告态 ∥ `gate` = 交付时点的裁定);
6
6
  * **只读**(零副作用 · 免审批 · 可并行);参数 `target` / `mode` / `docs`
7
7
  * (`target` 指向多项目工作区 ⇒ 报明候选并要求指名,同 `manifest` 工具面)。
@@ -10,21 +10,14 @@
10
10
  * `gate` 面缺省 = 本会话触达记账里的 `.md`(交付面按轮次收窄的唯一来源)。
11
11
  * `report` 非门禁(硬):输出不得被读作拒执行的理由(用户令 > 机检——§2 总则族);
12
12
  * `gate` 的强制面住交付协议 + 批次档 §6 前置,工具本体同样不阻断任何动作。
13
- * gate 前置(fail-closed)= 引擎版本一致:本会话进程持启动时加载的 ESM 引擎,引擎档晚于启动 ⇒ ERROR
14
- * (判据单源 = `doc-check/version.mjs`——与 `batch-gate.mjs` 共用一份清单,不各持一份)。
15
13
  * 描述外置:模型可见文本单点 = `tool-docs/doc_check.md`(`DESC` 单一解析面)。
16
14
  * 装配段 = `agent/family-tools.mjs` 三处(depth-0 / eng-coder / eng-designer)——写文档 / 设计档的角色面。
17
15
  */
18
16
  import { resolve } from "node:path"
19
17
  import { projectRootView } from "../manifest.mjs"
20
18
  import { runDocCheck } from "../doc-check/index.mjs"
21
- import { staleEngineFiles, gateEngineError, withEngineNote } from "../doc-check/version.mjs"
22
19
  import { DESC } from "../tools/shared.mjs"
23
20
 
24
- // 版本函数单源 = `doc-check/version.mjs`(两消费面:本档 gate 分支 ∥ `batch-gate.mjs` 两机械点)——
25
- // 本档只转口,导出面不变(原五档清单已随之六档:`version.mjs` 自身入清单)。
26
- export { staleEngineFiles, gateEngineError }
27
-
28
21
  export const docCheckTool = {
29
22
  name: "doc_check",
30
23
  description: DESC("doc_check"),
@@ -63,18 +56,14 @@ export const docCheckTool = {
63
56
  }
64
57
  const root = view.state === "ok" ? view.root : target
65
58
  if (mode === "gate") {
66
- // 引擎版本校验先于引擎(A-DD30 ①):stale 非空 ⇒ 直接 ERROR 串,不进引擎
67
- const version = staleEngineFiles()
68
- if (version.stale.length) return gateEngineError(version)
69
- // 会话候选先取 `.md`(触达记账含代码档——代码档不是文档,不该进范围行);可判集归引擎单源
70
59
  const docs = explicit ?? (Array.isArray(ctx?.agent?._touchedFiles) ? ctx.agent._touchedFiles : [])
71
60
  .filter((p) => typeof p === "string" && p.toLowerCase().endsWith(".md"))
72
61
  return runDocCheck(root, { mode: "gate", docs, docsSource: explicit ? "explicit" : "session" }).report
73
62
  }
74
- // 报告态:清单是唯一范围来源——不给就是拒绝(不是「全域」)。引擎陈旧 ⇒ 首行前一行注记(A-DD30 ①)。
63
+ // 报告态:清单是唯一范围来源——不给就是拒绝(不是「全域」)。
75
64
  if (explicit === null) {
76
65
  return "doc_check: `docs` is required in report mode — pass the explicit list of documents to judge (e.g. docs: [\"docs/design/X.md\"]). There is no default range: nothing is scanned unless you name it."
77
66
  }
78
- return withEngineNote(runDocCheck(root, { docs: explicit, docsSource: "explicit" }).report, staleEngineFiles())
67
+ return runDocCheck(root, { docs: explicit, docsSource: "explicit" }).report
79
68
  },
80
69
  }