@thincoder/core 0.11.2 → 0.11.3
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.
- package/CHANGELOG.md +18 -0
- package/advisor/compaction.mjs +7 -5
- package/advisor/history.mjs +24 -11
- package/advisor/loop.mjs +13 -8
- package/advisor/messages.mjs +72 -8
- package/advisor/run.mjs +24 -13
- package/advisor.mjs +7 -3
- package/agent/chat-call.mjs +14 -9
- package/agent/completion.mjs +28 -40
- package/agent/continue-decision.mjs +14 -8
- package/agent/digest-account.mjs +133 -59
- package/agent/dispatch-run.mjs +1 -1
- package/agent/dispatch.mjs +2 -1
- package/agent/family-tools.mjs +12 -13
- package/agent/helpers.mjs +17 -72
- package/agent/image-heal.mjs +18 -4
- package/agent/post-turn.mjs +13 -26
- package/agent/record-results.mjs +21 -6
- package/agent/run-stages.mjs +72 -37
- package/agent/run-start.mjs +148 -113
- package/agent/setup-reminders.mjs +187 -91
- package/agent/setup.mjs +204 -138
- package/agent/spawn-child.mjs +2 -2
- package/agent/suspension.mjs +43 -15
- package/agent/timers.mjs +4 -1
- package/agent/turn-domain-text.mjs +105 -0
- package/agent/turn-loop.mjs +54 -22
- package/agent/turn-projection.mjs +127 -227
- package/agent/turn-tool-process.mjs +32 -37
- package/agent-tools/advisor-async.mjs +6 -3
- package/agent-tools/advisor-launch.mjs +5 -5
- package/agent-tools/advisor.mjs +1 -1
- package/agent-tools/async-discard.mjs +7 -2
- package/agent-tools/async-settle.mjs +18 -12
- package/agent-tools/bash-async.mjs +5 -2
- package/agent-tools/batch-closeout.mjs +12 -62
- package/agent-tools/batch-ledger-bind.mjs +19 -8
- package/agent-tools/batch-lifecycle.mjs +37 -11
- package/agent-tools/batch-read.mjs +151 -4
- package/agent-tools/batch-record-write.mjs +5 -5
- package/agent-tools/batch-segment-vocab.mjs +84 -4
- package/agent-tools/batch-skeleton.mjs +18 -14
- package/agent-tools/batch-supersede.mjs +1 -1
- package/agent-tools/batch-tier-gate.mjs +36 -119
- package/agent-tools/batch.mjs +30 -20
- package/agent-tools/browser-async.mjs +5 -2
- package/agent-tools/consult.mjs +10 -7
- package/agent-tools/context.mjs +47 -31
- package/agent-tools/digest-budget.mjs +10 -9
- package/agent-tools/eng.mjs +3 -4
- package/agent-tools/escalate-async.mjs +3 -3
- package/agent-tools/goal.mjs +5 -2
- package/agent-tools/judge-domain.mjs +347 -0
- package/agent-tools/manifest.mjs +2 -2
- package/agent-tools/parent-channel.mjs +6 -3
- package/agent-tools/plan.mjs +11 -10
- package/agent-tools/review-facts.mjs +9 -3
- package/agent-tools/skill.mjs +7 -8
- package/agent-tools/spawn-gates.mjs +5 -16
- package/agent-tools/ssh-session.mjs +6 -3
- package/agent-tools/ssh-transfer.mjs +1 -1
- package/agent-tools/subagent-actions.mjs +2 -2
- package/agent-tools/subagent-async.mjs +11 -8
- package/agent-tools/subagent-scheduler.mjs +9 -9
- package/agent-tools/subagent-spawn.mjs +2 -2
- package/agent-tools/subagent.mjs +5 -18
- package/agent-tools/task.mjs +0 -8
- package/agent.mjs +15 -15
- package/auto-think.mjs +5 -2
- package/compaction-work-state.mjs +230 -0
- package/compress-form.mjs +41 -6
- package/config-defaults.mjs +5 -2
- package/config.mjs +53 -17
- package/context-degrade.mjs +79 -48
- package/context-echo.mjs +6 -26
- package/context-push.mjs +328 -31
- package/context.mjs +203 -141
- package/conventions.mjs +1 -1
- package/declaration.mjs +95 -17
- package/escape.mjs +6 -5
- package/explore-distill.mjs +35 -8
- package/generate-title.mjs +10 -1
- package/knowledge/prompt-resources.md +5 -1
- package/ledger-tools.mjs +50 -50
- package/ledger-write-ops.mjs +43 -16
- package/memory/docs.mjs +51 -15
- package/memory/file-list.mjs +6 -0
- package/model-specs.mjs +87 -21
- package/origin-guard.mjs +190 -0
- package/package.json +1 -1
- package/prompt-files.mjs +33 -11
- package/prompt-overlays.mjs +12 -5
- package/prompts/advisor-design.md +55 -36
- package/prompts/advisor-round1.md +18 -7
- package/prompts/advisor-round2.md +18 -7
- package/prompts/advisor-round3.md +18 -7
- package/prompts/common.md +89 -51
- package/prompts/consult-base.md +2 -3
- package/prompts/discipline-engineering.md +474 -440
- package/prompts/discipline-normal.md +107 -31
- package/prompts/knowledge/business-gates.md +23 -15
- package/prompts/knowledge/decision-quality.md +16 -18
- package/prompts/knowledge/doc-lookup.md +22 -27
- package/prompts/knowledge/document-writing.md +31 -49
- package/prompts/knowledge/documentation-evaluation.md +37 -45
- package/prompts/knowledge/evidence-discipline.md +36 -55
- package/prompts/knowledge/normal-coding-workflow.md +27 -21
- package/prompts/knowledge/normal-delivery-collaboration.md +33 -17
- package/prompts/knowledge/normal-work-management.md +10 -7
- package/prompts/knowledge/product-security.md +22 -17
- package/prompts/knowledge/project-records.md +63 -52
- package/prompts/knowledge/tool-apply-patch.md +12 -13
- package/prompts/knowledge/tool-bash.md +13 -4
- package/prompts/knowledge/tool-batch-eng-coder.md +13 -6
- package/prompts/knowledge/tool-batch-eng-designer.md +14 -6
- package/prompts/knowledge/tool-batch-review.md +12 -6
- package/prompts/knowledge/tool-batch.md +76 -62
- package/prompts/knowledge/tool-browser.md +45 -34
- package/prompts/knowledge/tool-context.md +2 -2
- package/prompts/knowledge/tool-delete.md +5 -1
- package/prompts/knowledge/tool-doc-check.md +25 -24
- package/prompts/knowledge/tool-doc-graph-read.md +3 -3
- package/prompts/knowledge/tool-doc-graph.md +15 -15
- package/prompts/knowledge/tool-edit.md +26 -23
- package/prompts/knowledge/tool-execute.md +9 -4
- package/prompts/knowledge/tool-fetch.md +7 -1
- package/prompts/knowledge/tool-file-ops.md +6 -1
- package/prompts/knowledge/tool-git-read.md +3 -1
- package/prompts/knowledge/tool-git.md +1 -1
- package/prompts/knowledge/tool-glob.md +3 -1
- package/prompts/knowledge/tool-grep.md +5 -2
- package/prompts/knowledge/tool-hashline-edit.md +4 -2
- package/prompts/knowledge/tool-insert-after.md +3 -1
- package/prompts/knowledge/tool-ledger-read.md +6 -13
- package/prompts/knowledge/tool-ledger.md +14 -10
- package/prompts/knowledge/tool-ls.md +2 -0
- package/prompts/knowledge/tool-manifest.md +10 -7
- package/prompts/knowledge/tool-memory.md +15 -11
- package/prompts/knowledge/tool-operations.md +59 -71
- package/prompts/knowledge/tool-plan.md +1 -2
- package/prompts/knowledge/tool-process.md +1 -1
- package/prompts/knowledge/tool-read-history.md +6 -7
- package/prompts/knowledge/tool-read.md +1 -0
- package/prompts/knowledge/tool-settings.md +6 -7
- package/prompts/knowledge/tool-ssh.md +37 -15
- package/prompts/knowledge/tool-subagent.md +37 -39
- package/prompts/knowledge/tool-task.md +3 -1
- package/prompts/knowledge/tool-team-ledger.md +5 -1
- package/prompts/knowledge/tool-tree.md +2 -0
- package/prompts/knowledge/tool-wait-for.md +16 -16
- package/prompts/knowledge/tool-write.md +4 -1
- package/prompts/knowledge/upstream-protocol.md +39 -37
- package/prompts/persona-coder.md +1 -3
- package/prompts/persona-eng-coder.md +5 -5
- package/prompts/persona-eng-designer.md +34 -17
- package/prompts/persona-engineering.md +532 -501
- package/prompts/persona-explore.md +0 -2
- package/prompts/persona-normal.md +17 -9
- package/prompts/persona-plan.md +0 -2
- package/prompts/persona-tester.md +0 -2
- package/prompts/subagent-base.md +0 -2
- package/provider/anthropic.mjs +4 -2
- package/provider/core.mjs +5 -3
- package/provider/errors.mjs +41 -7
- package/provider/google.mjs +5 -3
- package/provider/reasoning-echo.mjs +16 -0
- package/provider/responses.mjs +4 -2
- package/provider/sse.mjs +11 -6
- package/rules.mjs +11 -10
- package/session-lifecycle.mjs +115 -81
- package/session-slot-write.mjs +1 -1
- package/session.mjs +23 -20
- package/shell-identity.mjs +129 -22
- package/skip-dirs.mjs +24 -0
- package/team-ledger.mjs +22 -22
- package/text-budget.mjs +1 -1
- package/think-off.mjs +27 -0
- package/token-ttl.mjs +1 -1
- package/token-window.mjs +278 -88
- package/tool-docs/bash.md +0 -2
- package/tool-docs/consult_start.md +2 -2
- package/tool-docs/consult_stop.md +2 -2
- package/tools/browser.mjs +8 -8
- package/tools/execute.mjs +2 -2
- package/tools/file.mjs +17 -11
- package/tools/git.mjs +12 -12
- package/tools/ops.mjs +2 -2
- package/tools/patch.mjs +1 -1
- package/tools/process-doc-mark.mjs +33 -4
- package/tools/repomap.mjs +25 -3
- package/tools/search.mjs +74 -26
- package/tools/shared.mjs +4 -3
- package/tools/ssh.mjs +5 -5
- package/tools/tree.mjs +32 -10
- package/tools/web-deepseek.mjs +1 -1
- package/tools/web.mjs +2 -2
- package/tools/write-gate-params.mjs +3 -3
- package/window-policy.mjs +118 -78
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* agent-tools/batch-read.mjs — 批次档只读读面(read-data-interface 批 · 设计档
|
|
3
|
-
* `docs/cli/design/READ-DATA-INTERFACE.md` §2.5 / §3.3 · 台账 #887
|
|
3
|
+
* `docs/cli/design/READ-DATA-INTERFACE.md` §2.5 / §3.3 · 台账 #887;`read` 动作与评审侧批档简报批 ·
|
|
4
|
+
* `docs/core/design/BATCH-RECORD.md` §4.25 ∥ `docs/core/design/ADVISOR-GUARDS.md` §2.5 · 台账 #2616)。
|
|
4
5
|
*
|
|
5
6
|
* `listBatchRecords({ cwd, bases })` —— ACP `batch/list` 与变更观察器共用的**文件集 + 段状态单源**:
|
|
6
7
|
* 文件集 = 基底根(`batchDocBases`——声明面单源)下全部 `*.md`(递归;收集器 `collectMarkdownFiles`
|
|
7
8
|
* 转导出复用);路径升序稳定;单档读错跳过(尽力面)。各段状态 = `readSectionStatusWord`(段头 /
|
|
8
9
|
* 状态行正则 / 词表全消费 batch-skeleton 单源——与冻结门字面零漂移;`§4` / `§6` = 字面「无状态词」)。
|
|
10
|
+
*
|
|
11
|
+
* `read` 面(`BATCH-RECORD.md` §4.25)三件共用同一把尺——段界与状态词不各判一次:
|
|
12
|
+
* - `batchRecordIndex(src)` —— 档头区三行(编制 ∥ 台账 ∥ 批起 sha)+ 逐段一行(状态词 ∥ 正文行数)。
|
|
13
|
+
* - `batchSectionWindow(src, seg, offset)` —— 段体行集按 `READ_WINDOW` 切片(1 基、段体首行 = 1)。
|
|
14
|
+
* - `readBatchRecord({ args, pickTarget })` —— action 执行体:目标经 `pickTarget`(D-BR21 一处判据:
|
|
15
|
+
* 绑定 ∥ 在飞 ∥ depth-0 path),**零写盘、零台账事务、零 doc-check 门、零 `_batchWrites`**;
|
|
16
|
+
* 冻结档读得到(冻结是写门,读一份已收口档正是下一批学上一批的方式)。
|
|
17
|
+
* - `buildBatchBrief(batchDoc, cwd)` —— 评审消息里的 `## Batch record` 块(`ADVISOR-GUARDS.md` §2.5):
|
|
18
|
+
* 解析后的绝对路径 + 同一份索引 + 两句指令句;未绑定 ⇒ 空串(块不出现,空串是调用方算出来的结果)。
|
|
19
|
+
*
|
|
20
|
+
* 依赖单向:本档 import `batch-lifecycle.mjs`(文件集收集器 ∥ 段号谓词)与 `batch-segment-vocab.mjs`
|
|
21
|
+
* (段体行集 ∥ 状态词)——两者都不 import 本档。
|
|
9
22
|
*/
|
|
10
23
|
import { readFileSync } from "node:fs"
|
|
11
|
-
import { basename } from "node:path"
|
|
24
|
+
import { basename, resolve } from "node:path"
|
|
12
25
|
|
|
13
|
-
import { collectMarkdownFiles } from "./batch-lifecycle.mjs"
|
|
26
|
+
import { collectMarkdownFiles, segmentNumber } from "./batch-lifecycle.mjs"
|
|
14
27
|
import { batchDocBases } from "./batch-paths.mjs"
|
|
15
|
-
import { readSectionStatusWord } from "./batch-
|
|
28
|
+
import { readSectionStatusWord, sectionBodyLines } from "./batch-segment-vocab.mjs"
|
|
16
29
|
|
|
17
30
|
/** 段号表(1–6——输出映射键序固定;`readSectionStatusWord` 消费数形段号)。 */
|
|
18
31
|
const SEGMENTS = [1, 2, 3, 4, 5, 6]
|
|
19
32
|
|
|
33
|
+
/** 一次 `read` 窗口至多取回的段体行数(契约值只住 `BATCH-RECORD.md` §4.25;本档是实现面)。 */
|
|
34
|
+
export const READ_WINDOW = 200
|
|
35
|
+
|
|
20
36
|
/** 批次档列举(只读):`{ batches: [{ file, path, sections }] }`——`path` = 绝对路径(`/` 归一)、
|
|
21
37
|
* `file` = basename、`batches` 按路径升序;单档读错跳过(尽力面)。`bases` 缺省 = `batchDocBases(cwd)`。 */
|
|
22
38
|
export function listBatchRecords({ cwd, bases } = {}) {
|
|
@@ -34,3 +50,134 @@ export function listBatchRecords({ cwd, bases } = {}) {
|
|
|
34
50
|
}
|
|
35
51
|
return { batches }
|
|
36
52
|
}
|
|
53
|
+
|
|
54
|
+
/** 档头区一行的取法(行首 `> 编制` / `> 台账` / `批起 sha =` 三种结构行);取不到 ⇒ 缺行读数。
|
|
55
|
+
* 「缺行」与「无状态行」同形:索引要说的是这份档此刻有什么,不是它本该有什么。 */
|
|
56
|
+
function headerLineOf(src, re, missing) {
|
|
57
|
+
const m = re.exec(src)
|
|
58
|
+
return m ? m[0].trim().replace(/^>\s*/, "") : missing
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 段索引(纯函数 · 零 fs):档头区三行 + 逐段一行(状态词 ∥ 正文行数)。
|
|
63
|
+
* 与 `batchSectionWindow` 读同一组判据(`sectionBodyLines` ∥ `readSectionStatusWord`)——索引里的行数
|
|
64
|
+
* 就是窗口回复的「共 T 行」,两处不各数一次。
|
|
65
|
+
* @param {string} src — 档全文
|
|
66
|
+
* @returns {string} 索引正文(不含绝对路径与下一次调用的形——那两件由调用方拼)
|
|
67
|
+
*/
|
|
68
|
+
export function batchRecordIndex(src) {
|
|
69
|
+
const header = [
|
|
70
|
+
headerLineOf(src, /^>\s*编制.*$/m, "(无编制行)"),
|
|
71
|
+
headerLineOf(src, /^>\s*台账.*$/m, "(无台账行)"),
|
|
72
|
+
headerLineOf(src, /^批起 sha\s*=.*$/m, "(无批起 sha 行)"),
|
|
73
|
+
]
|
|
74
|
+
const sections = SEGMENTS.map((seg) => {
|
|
75
|
+
const word = readSectionStatusWord(src, seg)
|
|
76
|
+
const count = (sectionBodyLines(src, seg) ?? []).length
|
|
77
|
+
return `§${seg} · ${word ?? "无状态行"} · ${count} 行`
|
|
78
|
+
})
|
|
79
|
+
return [...header, "", ...sections].join("\n")
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 段体窗口(纯函数 · 零 fs):`offset` 1 基、段体首行 = 1、至多 `READ_WINDOW` 行。
|
|
84
|
+
* 两条拒面都点名被替换的参数与可判读数(**无默认值**:默认值会替调用方选起点,错的那一次静默从中间读,
|
|
85
|
+
* 而读者看不出少了半段):
|
|
86
|
+
* - 段头缺失 ⇒ 拒并点名 `segment`(不回退整档——回退之后读者以为手里是那一节,实际是六段全文);
|
|
87
|
+
* - `offset` 非 ≥1 的整数 ∥ 超过该段正文行数 ⇒ 拒并点名 `offset` 与该段总行数(空窗口读起来像
|
|
88
|
+
* 「这段读完了」,而它与「这段就到这里」是两件事)。
|
|
89
|
+
* @param {string} src — 档全文
|
|
90
|
+
* @param {number} seg — 段号(已由 `segmentNumber` 解出的数形)
|
|
91
|
+
* @param {number} offset — 段体内的 1 基起始行
|
|
92
|
+
* @returns {{start:number, end:number, total:number, lines:string[], nextOffset:number|null}}
|
|
93
|
+
*/
|
|
94
|
+
export function batchSectionWindow(src, seg, offset) {
|
|
95
|
+
const body = sectionBodyLines(src, seg)
|
|
96
|
+
if (body === null) {
|
|
97
|
+
throw new Error(`batch: read got segment "§${seg}" but this batch record has no "## §${seg}" section header — pass a section the record carries (§1–§6, e.g. "§2"). Nothing was written.`)
|
|
98
|
+
}
|
|
99
|
+
const total = body.length
|
|
100
|
+
if (!Number.isInteger(offset) || offset < 1 || offset > total) {
|
|
101
|
+
throw new Error(`batch: read got offset ${JSON.stringify(offset ?? null)} for §${seg} — offset must be an integer ≥ 1 and at most ${total} (the §${seg} body length; 1-based, the first body line is 1). Nothing was written.`)
|
|
102
|
+
}
|
|
103
|
+
const end = Math.min(total, offset + READ_WINDOW - 1)
|
|
104
|
+
return { start: offset, end, total, lines: body.slice(offset - 1, end), nextOffset: end < total ? end + 1 : null }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** 段索引回执(尾行 = 绝对路径 ∥ 下一次调用的形)。路径归一 `/`:与 `listBatchRecords` ∥ 批档简报同一形,
|
|
108
|
+
* 读它的人拿到的是可执行的路径,而不是一串可能被当成转义的 `\`。 */
|
|
109
|
+
function renderIndexReceipt(abs, src) {
|
|
110
|
+
return [
|
|
111
|
+
batchRecordIndex(src),
|
|
112
|
+
"",
|
|
113
|
+
`${abs.replace(/\\/g, "/")} · next: batch({"action":"read","segment":"§1","offset":1}) — each window carries up to ${READ_WINDOW} lines`,
|
|
114
|
+
].join("\n")
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** 段窗口回执(首行 `§N · 行 a-b / 共 T`;未完则尾行给下一 `offset`)。 */
|
|
118
|
+
function renderWindowReceipt(src, segRaw, offset) {
|
|
119
|
+
const seg = segmentNumber(segRaw)
|
|
120
|
+
if (seg === null) {
|
|
121
|
+
throw new Error(`batch: read got segment ${JSON.stringify(segRaw ?? null)} — pass the section number the record carries ("§2" and "2" are the same section, e.g. "§2"). Nothing was written.`)
|
|
122
|
+
}
|
|
123
|
+
if (offset === undefined || offset === null) {
|
|
124
|
+
throw new Error(`batch: read needs offset whenever segment is given — segment names a section, offset names where in its body to start (1-based: the first body line is 1, at most ${READ_WINDOW} lines per window). Omit segment for the whole-record index, or pass offset to open a window. Nothing was written.`)
|
|
125
|
+
}
|
|
126
|
+
const w = batchSectionWindow(src, seg, offset)
|
|
127
|
+
const lines = [`§${seg} · 行 ${w.start}-${w.end} / 共 ${w.total}`, "", ...w.lines]
|
|
128
|
+
if (w.nextOffset !== null) {
|
|
129
|
+
lines.push("", `next: offset: ${w.nextOffset} — batch({"action":"read","segment":"§${seg}","offset":${w.nextOffset}})`)
|
|
130
|
+
}
|
|
131
|
+
return lines.join("\n")
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* `read` 执行体(只读):目标经 `pickTarget`(D-BR21 一处判据——绑定 ∥ 在飞 ∥ depth-0 path,`path`
|
|
136
|
+
* 的子代理拒面也在那里),零写盘、零台账事务、零 doc-check 门、零 `_batchWrites` 计数。
|
|
137
|
+
* 两种调用形(§4.25 的表):无 `segment` ⇒ 段索引;`segment` + 必填 `offset` ⇒ 该段一个窗口。
|
|
138
|
+
* 段号与 `offset` 的两条拒面见 `renderWindowReceipt` ∥ `batchSectionWindow`。
|
|
139
|
+
* @param {{args: object, ctx: object, review: boolean, pickTarget: (raw?: string) => string}} p —
|
|
140
|
+
* `ctx` ∥ `review` 不消费(目标定位全在 `pickTarget`);形与 `checkBatchRecord` 同款,调用面只换函数名
|
|
141
|
+
* @returns {string} 回执(索引 ∥ 窗口)
|
|
142
|
+
*/
|
|
143
|
+
export function readBatchRecord({ args, ctx, review, pickTarget }) {
|
|
144
|
+
const abs = pickTarget(args?.path)
|
|
145
|
+
const src = readFileSync(abs, "utf8")
|
|
146
|
+
const segRaw = args?.segment
|
|
147
|
+
if (segRaw === undefined || segRaw === null) return renderIndexReceipt(abs, src)
|
|
148
|
+
return renderWindowReceipt(src, segRaw, args?.offset)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 评审消息的批档简报块(`ADVISOR-GUARDS.md` §2.5):块标题 + 三件(解析后的绝对路径 ∥ 档头区 ∥ 逐段一行)
|
|
153
|
+
* + 两句指令句(过程证据不是评审对象;检索面那句真话)。**只给路径与索引,不复制正文**——正文每轮重发、
|
|
154
|
+
* 随实施增长,路径加索引是常量大小,读者按需 `read`。
|
|
155
|
+
* 未绑定(`null` / `undefined` / 空串)⇒ 空串:块不出现,且这个空串是调用方算出来的结果(§2.5 参数面)。
|
|
156
|
+
* @param {string|null|undefined} batchDoc — 本笔绑定的批档(启动时点的快照值)
|
|
157
|
+
* @param {string} cwd — 解析绝对路径的基准(`buildBatchBrief` 不给默认值:基准错了,路径就是别人的档)
|
|
158
|
+
* @returns {string} 简报块(含尾空行——与对象声明块的段间空行同形)∥ 空串
|
|
159
|
+
*/
|
|
160
|
+
export function buildBatchBrief(batchDoc, cwd) {
|
|
161
|
+
if (batchDoc === undefined || batchDoc === null || batchDoc === "") return ""
|
|
162
|
+
if (typeof batchDoc !== "string") {
|
|
163
|
+
throw new TypeError("buildBatchBrief: batchDoc must be a string path, or empty/null for an unbound review — the binding value is passed through as it is, so a non-string here is a call-site defect, never a record to guess at.")
|
|
164
|
+
}
|
|
165
|
+
if (typeof cwd !== "string" || !cwd.trim()) {
|
|
166
|
+
throw new TypeError("buildBatchBrief: cwd must be a non-empty string — the brief prints the resolved absolute path, so the base it resolves against is required and is never defaulted.")
|
|
167
|
+
}
|
|
168
|
+
const abs = resolve(cwd, batchDoc).replace(/\\/g, "/")
|
|
169
|
+
let src
|
|
170
|
+
try {
|
|
171
|
+
src = readFileSync(abs, "utf8")
|
|
172
|
+
} catch (e) {
|
|
173
|
+
throw new Error(`buildBatchBrief: the bound batch record could not be read at ${abs} — ${e?.message ?? e}. The brief is built from the record itself, never from memory: fix the binding or restore the record before a review is briefed on it.`)
|
|
174
|
+
}
|
|
175
|
+
return [
|
|
176
|
+
"## Batch record",
|
|
177
|
+
`${abs} — read this file in full.`,
|
|
178
|
+
batchRecordIndex(src),
|
|
179
|
+
"",
|
|
180
|
+
"The batch record is process evidence, not a review target: §2 is the task book the work must satisfy, §1 is the ruling on it and §3 is the previous round's record — none of the three is a review basis. When you read it, the search face applies: `grep` / `glob` / `ls` / `tree` omit process documents unless you pass `includeProcessDocs: true`, and an empty default search does not mean the record is absent.",
|
|
181
|
+
"",
|
|
182
|
+
].join("\n")
|
|
183
|
+
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* (本档不 import `batch.mjs`,两条 action 的调用者只在原档的分发里)。
|
|
20
20
|
*/
|
|
21
21
|
import { readFileSync, writeFileSync } from "node:fs"
|
|
22
|
-
import { DEPTH0_SEGMENTS, ROUND_HEADING_RE, SEGMENT_BY_ROLE, SEGMENT_BY_ROLE_NORMAL, STATUS_LINE_RE, findPlaceholderResidue, firstZoneStatusLineRange, nextRoundNumber, placeholderResidueError, readBatchStatusLine, reviewWritableSegment, sectionHeaderRe, sectionThreeDesignTrackError, statusDonePlan, statusPassPlan, statusResetPlan, updateSectionStatusLine, verdictGapOf, zoneStatusCount } from "./batch-skeleton.mjs"
|
|
22
|
+
import { DEPTH0_SEGMENTS, ROUND_HEADING_RE, SEGMENT_BY_ROLE, SEGMENT_BY_ROLE_NORMAL, STATUS_LINE_RE, findPlaceholderResidue, firstZoneStatusLineRange, goAheadEndLine, goAheadReceiptLine, nextRoundNumber, placeholderResidueError, readBatchStatusLine, reviewWritableSegment, sectionHeaderRe, sectionThreeDesignTrackError, statusDonePlan, statusPassPlan, statusResetPlan, updateSectionStatusLine, verdictGapOf, zoneStatusCount } from "./batch-skeleton.mjs"
|
|
23
23
|
import { batchDocBases, resolveBatchDocPath } from "./batch-paths.mjs"
|
|
24
24
|
import { gateReceiptLine, gateRefusalMessage, runBatchGate } from "./batch-gate.mjs"
|
|
25
25
|
import { assertSectionFiveGate } from "./batch-closeout.mjs"
|
|
@@ -232,10 +232,10 @@ export function appendBatchRecord({ args, ctx, review, reviewTrack, batchDoc, on
|
|
|
232
232
|
if (gate?.state === "refused") throw new Error(gateRefusalMessage(gate, "append"))
|
|
233
233
|
writeFileSync(abs, written)
|
|
234
234
|
// #84:记账面按端注入(缺省 no-op = CLI 语义零行为变——端装配经 configureBatchSegment 覆盖,缝住 `batch.mjs`)。
|
|
235
|
-
// 本条 = `AGENT-LOOP.md` §
|
|
235
|
+
// 本条 = `AGENT-LOOP.md` §7.1 `wrote` 判据的计数面(成功写盘才增;上面各门已过)。
|
|
236
236
|
agent._batchWrites = (agent._batchWrites ?? 0) + 1
|
|
237
237
|
onWritten?.(agent, abs)
|
|
238
|
-
return `batch_segment: appended ${body.length} characters to §${n} of the batch record${roundN ? ` (### 轮次 ${roundN}(评审子代理))` : ""}.${done ? ` §${n} 状态行 = ${done.statusValue}(同笔置位——不另调 status).` : ""}${gateReceiptLine(gate)}`
|
|
238
|
+
return `batch_segment: appended ${body.length} characters to §${n} of the batch record${roundN ? ` (### 轮次 ${roundN}(评审子代理))` : ""}.${done ? ` §${n} 状态行 = ${done.statusValue}(同笔置位——不另调 status).` : ""}${n === 1 ? `${goAheadReceiptLine(written)}${goAheadEndLine(src, written)}` : ""}${gateReceiptLine(gate)}`
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
// ─── 拒串单源(append / edit 共用——两动作只差写法,不差判据)───────────────
|
|
@@ -411,7 +411,7 @@ export function editBatchRecord({ args, ctx, review, reviewTrack, batchDoc, onWr
|
|
|
411
411
|
if (gate?.state === "refused") throw new Error(gateRefusalMessage(gate, "edit"))
|
|
412
412
|
writeFileSync(abs, finalSrc)
|
|
413
413
|
// #84:记账面按端注入(与 append 同一条缝——缺省 no-op = CLI 语义零行为变)。
|
|
414
|
-
agent._batchWrites = (agent._batchWrites ?? 0) + 1 // §
|
|
414
|
+
agent._batchWrites = (agent._batchWrites ?? 0) + 1 // §7.1 `wrote` 判据:成功写盘计数(与 append 同一条面)
|
|
415
415
|
onWritten?.(agent, abs)
|
|
416
|
-
return `batch: edited §${n} of the batch record — replaced ${oldText.length} characters with ${replacement.length}.${done ? ` §${n} 状态行 = ${done.statusValue}(同笔置位——不另调 status).` : ""}${gateReceiptLine(gate)}`
|
|
416
|
+
return `batch: edited §${n} of the batch record — replaced ${oldText.length} characters with ${replacement.length}.${done ? ` §${n} 状态行 = ${done.statusValue}(同笔置位——不另调 status).` : ""}${n === 1 ? `${goAheadReceiptLine(finalSrc)}${goAheadEndLine(src, finalSrc)}` : ""}${gateReceiptLine(gate)}`
|
|
417
417
|
}
|
|
@@ -231,6 +231,84 @@ export function readBatchStatusLine(src) {
|
|
|
231
231
|
if (value.includes(STATUS_WORDS[1].open)) return "open"
|
|
232
232
|
return "unknown"
|
|
233
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* §1 **授权行**读法与被读面(`docs/core/design/BATCH-RECORD.md` §4.24;语义 = `docs/core/design/ENGINEERING-MODE-V2.md`
|
|
236
|
+
* §2.3 `E8`「授权行的双态与结束标记」):形 = `- **自动推进**:<已授权|未授权> · <余文>`,住所 = §1 **段体**
|
|
237
|
+
* (不是段头区——段头区那一族形态只有 `**状态行**:` 一条,本行刻意不进它,故不参与 `readBatchStatusLine`
|
|
238
|
+
* 的「恰一条才可读」判据)。
|
|
239
|
+
*
|
|
240
|
+
* 三条读法纪律(一个判据,所有消费面共用):
|
|
241
|
+
* - **只认行首**(`^- `):缩进行与引用行(`> ` 起头)不算——评审与批档正文里复述这一行是常态,复述不构成结论。
|
|
242
|
+
* - **取末条**:段体内最后一条该形的行是结论,此前那些是历史。
|
|
243
|
+
* - **取首词**:冒号后第一个词;不是 `已授权` ∥ `未授权` ⇒ 读不到(存量自由文本行 `范围 = …` 即此态)。
|
|
244
|
+
*/
|
|
245
|
+
const GO_AHEAD_LINE_RE = /^-\s*\*\*自动推进\*\*[::]\s*(.*)$/
|
|
246
|
+
/** 该批收口的结束原因字面(`status` ∥ `close` 两条收口通路同源落同一个词,结束语据此分岔)。 */
|
|
247
|
+
export const GO_AHEAD_REASON_CLOSE = "该批收口"
|
|
248
|
+
/** 收口时的结束语(用户 2026-11-20 14:57 原话,逐字)——只随「落了 `未授权` 行」的那一笔出现一次。 */
|
|
249
|
+
export const GO_AHEAD_END_COMPLETE = "授权任务已全部完成,自动推进授权结束"
|
|
250
|
+
|
|
251
|
+
/** 授权行解析(**内部单源**:下面四个导出面都读它一次,切词不各写一份)。
|
|
252
|
+
* `detail` = 余文首段(` · ` 分隔的第一段);`reason` = 首段形如 `结束原因 = <原因>` 时的原因本体,否则 null。
|
|
253
|
+
* @returns {{state: "granted"|"none"|"unknown", detail: string, reason: string|null}} */
|
|
254
|
+
function goAheadRecordOf(src) {
|
|
255
|
+
let last = null
|
|
256
|
+
for (const line of sectionBodyLines(src, 1) ?? []) {
|
|
257
|
+
const m = GO_AHEAD_LINE_RE.exec(line)
|
|
258
|
+
if (m) last = m[1].trim()
|
|
259
|
+
}
|
|
260
|
+
if (last === null) return { state: "unknown", detail: "", reason: null }
|
|
261
|
+
const word = /^(已授权|未授权)/.exec(last)?.[1] ?? null
|
|
262
|
+
if (!word) return { state: "unknown", detail: last, reason: null }
|
|
263
|
+
const rest = last.slice(word.length).replace(/^\s*·\s*/, "").trim()
|
|
264
|
+
const detail = rest.split(/\s+·\s+/)[0].trim()
|
|
265
|
+
const reason = /^结束原因\s*[=::]\s*(.+)$/.exec(detail)?.[1]?.trim() ?? null
|
|
266
|
+
return { state: word === "已授权" ? "granted" : "none", detail, reason }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 授权行**三值**(`granted` ∥ `none` ∥ `unknown`):`unknown` **不做二值化**——零条 ∥ 首词不是双态词同判。
|
|
271
|
+
* 「读不到」既不推出给过,也不推出没给过:授权只能从用户的话来,这一步有没有被一条授权覆盖是读者的语义判断,
|
|
272
|
+
* 工具替它判就成了第二个授权写者。
|
|
273
|
+
* @param {string} src — 批档全文
|
|
274
|
+
* @returns {"granted"|"none"|"unknown"} 该批授权态
|
|
275
|
+
*/
|
|
276
|
+
export function readGoAheadState(src) {
|
|
277
|
+
return goAheadRecordOf(src).state
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 回执行(**只报不判**——`BATCH-RECORD.md` §4.24 回执面):三形之一
|
|
282
|
+
* `授权行:已授权(<余文首段>)` ∥ `授权行:未授权(<余文首段>)` ∥ `授权行:unknown`。
|
|
283
|
+
* 括注取**余文首段原样**:建批默认行 ⇒ `本批尚无批级授权`;失效行 ⇒ `结束原因 = <原因>`(标签不剥——
|
|
284
|
+
* 读者一眼看出那是原因而不是范围)。回执不改变任何工具门的判定面,也不拦任何写入——它不是门。
|
|
285
|
+
* @param {string} src — 批档全文(写后视图:报的是这一笔之后的授权行)
|
|
286
|
+
* @returns {string} 回执段(含前导换行)——`\n[go-ahead] 授权行:…`
|
|
287
|
+
*/
|
|
288
|
+
export function goAheadReceiptLine(src) {
|
|
289
|
+
const { state, detail } = goAheadRecordOf(src)
|
|
290
|
+
if (state === "unknown") return "\n[go-ahead] 授权行:unknown"
|
|
291
|
+
const word = state === "granted" ? "已授权" : "未授权"
|
|
292
|
+
return `\n[go-ahead] 授权行:${word}(${detail || "—"})`
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 结束语(**只在这笔真落了行时出声**):末条由「非 `未授权`」变成「`未授权`」⇒ 一句结束语;其余 ⇒ 空串。
|
|
297
|
+
* 判据 = 同一文件写前写后两次读数:它只回答「这一笔是否落了行」,不回答「该不该授权」。
|
|
298
|
+
* 该批收口 ⇒ 用户原话整句;范围变化 ∥ 用户叫停 ⇒ 只报 `自动推进授权结束 · 结束原因 = <原因>`——那两种终止下
|
|
299
|
+
* 任务并没有做完,替用户宣布「任务已完成」就是假话。
|
|
300
|
+
* **只出声一次**:末条已是 `未授权` 时不重复喊(每笔都喊一遍,读者会把它当噪音跳过)。
|
|
301
|
+
* @param {string} prevSrc — 写前全文
|
|
302
|
+
* @param {string} nextSrc — 写后全文
|
|
303
|
+
* @returns {string} 结束语(含前导换行)∥ 空串
|
|
304
|
+
*/
|
|
305
|
+
export function goAheadEndLine(prevSrc, nextSrc) {
|
|
306
|
+
const next = goAheadRecordOf(nextSrc)
|
|
307
|
+
if (next.state !== "none") return ""
|
|
308
|
+
if (goAheadRecordOf(prevSrc).state === "none") return ""
|
|
309
|
+
if (next.reason === GO_AHEAD_REASON_CLOSE) return `\n${GO_AHEAD_END_COMPLETE}`
|
|
310
|
+
return `\n自动推进授权结束 · 结束原因 = ${next.reason ?? "未注明"}`
|
|
311
|
+
}
|
|
234
312
|
|
|
235
313
|
/** 机读清单的**块名**(块头两形共同的名字;**字面单源**——块头判据与收口拒文的触发判据同取它)。 */
|
|
236
314
|
export const MACHINE_LIST_HEAD_NAME = "受影响文件(机读清单)"
|
|
@@ -273,12 +351,14 @@ const cellTextOf = (s) => String(s ?? "").replace(/[`*]/g, "").trim()
|
|
|
273
351
|
/**
|
|
274
352
|
* 解析 §2 的机读清单(纯函数 · 零 fs):逐个块头(两形,判据见 `machineListHeadOf`),取它**之后的第一张表**;
|
|
275
353
|
* 找表范围止于下一个标题行 ∥ 下一个块头。看头不看行——同一份档里块头可能出现不止一次(先举例、再写真清单
|
|
276
|
-
* 是正常写法),逐行跟读会把示例当档案。读不成 2–3
|
|
277
|
-
*
|
|
278
|
-
*
|
|
354
|
+
* 是正常写法),逐行跟读会把示例当档案。读不成 2–3 格的行跳过而不抛:消费面只为「点名哪些档」与
|
|
355
|
+
* 「该档那一格写了什么方案」。
|
|
356
|
+
* **2 格 ∥ 3 格都收,加列不移位**:表形是两列(`| 档 | 分拆方案 |`);第三列是存量批档里的历史格,
|
|
357
|
+
* 无判据读它,三格旧行照旧解得开;4 格以上仍跳过(多出来的列没有判据,读了就是替写手猜)。
|
|
279
358
|
* @param {string} src 档全文
|
|
280
359
|
* @returns {{path:string, plan:string, reading:string}[]} `path` 去装饰符;`plan` = 第二列原值去首尾空白;
|
|
281
|
-
* `reading` = 第三列原值去首尾空白(**两格行 =
|
|
360
|
+
* `reading` = 第三列原值去首尾空白(**两格行 = 空串**)——一个不再被判的返回字段,留在返回形里只为让
|
|
361
|
+
* 存量三格表照旧解得开
|
|
282
362
|
*/
|
|
283
363
|
export function machineListRowsOf(src) {
|
|
284
364
|
const lines = String(src ?? "").split(/\r?\n/)
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
STATUS_LINE_RE, STATUS_WORDS, sectionHeaderRe, sectionBodyLines, readSectionStatusWord, zoneStatusCount,
|
|
27
27
|
} from "./batch-segment-vocab.mjs"
|
|
28
28
|
|
|
29
|
-
// 搬去 batch-segment-vocab.mjs
|
|
29
|
+
// 搬去 batch-segment-vocab.mjs 的导出名原样再出口(名字逐个列出,不记数——计数会随下一次新增漂移)——
|
|
30
30
|
// 既有 import 面(batch.mjs / batch-lifecycle.mjs / batch-read.mjs / batch-reopen.mjs / batch-gate.mjs /
|
|
31
31
|
// batch-closeout.mjs / design-token.mjs / advisor.mjs / batch-ledger-bind.mjs / ledger-close-proof.mjs)零改。
|
|
32
32
|
export {
|
|
@@ -36,6 +36,8 @@ export {
|
|
|
36
36
|
readBatchStatusLine, updateSectionStatusLine, readSectionStatusWord,
|
|
37
37
|
zoneStatusLines, zoneStatusCount, firstZoneStatusLineRange,
|
|
38
38
|
reviewWritableSegment, sectionThreeDesignTrackError,
|
|
39
|
+
// §1 授权行读法与回执面(§4.24 的单源;`create` ∥ `append` ∥ `edit` ∥ `status` ∥ `close` 五个消费面经本档取用)。
|
|
40
|
+
readGoAheadState, goAheadReceiptLine, goAheadEndLine, GO_AHEAD_REASON_CLOSE, GO_AHEAD_END_COMPLETE,
|
|
39
41
|
} from "./batch-segment-vocab.mjs"
|
|
40
42
|
|
|
41
43
|
/**
|
|
@@ -344,6 +346,10 @@ export function batchSkeleton({ date, topic, source, prev, baseSha, ledger = nul
|
|
|
344
346
|
// ——`§2`/`§5` 的占位句会被 §4.12 的被动写覆盖,`§1` 的括注没有任何机制会清,留在每一本新档上就是
|
|
345
347
|
// 一句陪着整批跑完的假话。
|
|
346
348
|
`**状态行**:${STATUS_WORDS[1].open}`,
|
|
349
|
+
// §1 授权行(`BATCH-RECORD.md` §4.24 · 设计 `E8`「授权行的双态与结束标记」):建批即写一条 `未授权`——
|
|
350
|
+
// 新批从「没有覆盖它的授权」这一态起读,读者不必从缺行去猜默认态。它是**段体行**,不是状态行:不参与
|
|
351
|
+
// `readBatchStatusLine` 的「段头区恰一条才可读」判据。括注之外的字面由主 agent 补(范围 / 时间 / 原话)。
|
|
352
|
+
`- **自动推进**:未授权 · 本批尚无批级授权`,
|
|
347
353
|
`批起 sha = ${baseSha}`,
|
|
348
354
|
"<§1 模板占位:本批条目 / 关键判据 / 授权口径>",
|
|
349
355
|
`## §2 批次任务与设计(${designerSeat})`,
|
|
@@ -352,27 +358,25 @@ export function batchSkeleton({ date, topic, source, prev, baseSha, ledger = nul
|
|
|
352
358
|
// ——工具建出的每一本批档都会在自己的收口门里因 §2 占位而拒。占位行各自成段;
|
|
353
359
|
// 单行自身也须留在 300 字以内(同一阈值)——往这句里加话之前先量一遍。
|
|
354
360
|
"",
|
|
361
|
+
"<§2 模板占位:目的与代价链(解决谁的什么问题 / 不做会怎样 / 为什么不选更便宜的做法)>",
|
|
362
|
+
"",
|
|
355
363
|
"<§2 模板占位:本批条目(覆盖) / 设计档落点 / 机制设计 / 受影响文件与测试覆盖 / 验收对照 / 关键决策 / 上抛项>",
|
|
356
364
|
"",
|
|
357
365
|
// 机读清单的**形单源**:写在这里、不落成真表——模板一旦落成真表,§2 在建档时就已算「有内容」,
|
|
358
366
|
// ① 链门的「§2 真跑过」那一支就对工具建出的档永久失效(改前 §2 只有状态行与占位行,两者都在排除类里)。
|
|
359
|
-
// 门 = `batch-tier-gate.mjs` 的 `assertTierPlan
|
|
360
|
-
//
|
|
361
|
-
//
|
|
362
|
-
// 一行一档、只列**代码档(源 ∥ 单测)**——`.md` 零行数义务不列(`docs/core/standards/CODE-TIER.md` §1);
|
|
367
|
+
// 门 = `batch-tier-gate.mjs` 的 `assertTierPlan`:改动面里有**在盘码档**时先判表形,再核越线档的第二列
|
|
368
|
+
// 方案(越了收口线而没有可用方案 ⇒ 拒)。**缺这一块不算拒因**——拒的是「越线档在 §2 没有可用方案」。
|
|
369
|
+
// 一行一档、只列**代码档(源 ∥ 单测)**——`.md` 不承担分拆义务,不列(`docs/core/standards/CODE-TIER.md` §1);
|
|
363
370
|
// 本批自己的单测档(收口第 ③ 臂要求删净,到档位臂已不在盘)也不列。
|
|
364
371
|
// 示例档用**在盘**的档:写一个不存在的档名,下一批照抄就必被自己的收口门拒。
|
|
365
|
-
//
|
|
366
|
-
// 「写的是 `新`,而批起快照里这一档有 N 行」);写具体数又是读数、档一改就漂——哪种档写哪一种,交给第二行说。
|
|
372
|
+
// 表只两列、示例行第二列写 `—`:第三列已无判据读它(存量批档里的三列表仍是记录,照旧解得开)。
|
|
367
373
|
// 阈值语义不在本档复述(娘家 = `docs/core/standards/CODE-TIER.md` §2 ①;落步闭集 = `batch-tier-gate.mjs` 的 `STEP_WORDS`)。
|
|
368
|
-
//
|
|
369
|
-
//
|
|
370
|
-
//
|
|
371
|
-
|
|
372
|
-
// token,所以留着也不产生 `档缺`。倒过来放示例行,夹具就留下一个真档指针。
|
|
373
|
-
"<§2 模板占位:机读清单 = 标题行「**受影响文件(机读清单)**」+ 围栏内三列表(表头 | 档 | 分拆方案 | 行数 |、分隔行 |---|---|---|、一行一档,只列代码档(源 ∥ 单测));示例行 = | thincoder-core/agent-tools/batch-tier-gate.mjs | — | <该档在批起快照上的内容行数> |>",
|
|
374
|
+
// 这一块占位**分两行、行间留一个空行**:相邻非空正文行会被段长判据并成一段,两行相连就有越过 300 字的风险
|
|
375
|
+
// (与上面占位之间的空行同一条理由)。行序不是约束——集成夹具 `CLI 7-10` 先把「本批条目」占位换成自己的 §2 正文,
|
|
376
|
+
// 再整行全剔其余「§2 模板占位」行,故哪一行排在前都不影响夹具档里是否留下真档指针。
|
|
377
|
+
"<§2 模板占位:机读清单 = 标题行「**受影响文件(机读清单)**」+ 围栏内两列表(表头 | 档 | 分拆方案 |、分隔行 |---|---|、一行一档,只列代码档(源 ∥ 单测));示例行 = | thincoder-core/agent-tools/batch-tier-gate.mjs | — |>",
|
|
374
378
|
"",
|
|
375
|
-
"<§2 模板占位:第二列两件事——越设计时线的档写处置(分拆方案,或写明不拆的理由);越过收口线的档写正向形方案(点名带目录段的档 + 本批落步 `实施轮` ∥ `§5`);两条线都不越写
|
|
379
|
+
"<§2 模板占位:第二列两件事——越设计时线的档写处置(分拆方案,或写明不拆的理由);越过收口线的档写正向形方案(点名带目录段的档 + 本批落步 `实施轮` ∥ `§5`);两条线都不越写 —。>",
|
|
376
380
|
"",
|
|
377
381
|
"## §3 设计评审(评审子代理)",
|
|
378
382
|
"## §4 用户批准(主 agent)",
|
|
@@ -222,7 +222,7 @@ export async function supersedeBatchRecord({ args, ctx, review, pickTarget, onWr
|
|
|
222
222
|
const statusWritten = updateSectionStatusLine(src, 1, `已收口 ${date}(被取代)`)
|
|
223
223
|
writeFileSync(abs, appendLineToSection(statusWritten, 1, supersedeTraceLine(date, successor.label, counts)))
|
|
224
224
|
// 记账口径同 close 径(记「落过盘」,回档不回退)——见 `batch-lifecycle.mjs` 写盘处的注释。
|
|
225
|
-
if (ctx?.agent) ctx.agent._batchWrites = (ctx.agent._batchWrites ?? 0) + 1 // §
|
|
225
|
+
if (ctx?.agent) ctx.agent._batchWrites = (ctx.agent._batchWrites ?? 0) + 1 // §7.1 `wrote` 判据(写盘成功才增)
|
|
226
226
|
onWritten?.(ctx?.agent ?? {}, abs)
|
|
227
227
|
// 写序:档先写、台账后写;台账失败 ⇒ 用写前全文回滚档并抛拒(与 close 同一单源)。
|
|
228
228
|
const reanchor = await ledgerAfterRecordWrite({
|