@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,29 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* agent-tools/batch-tier-gate.mjs — 收口面的第 ⑤ 臂:**档位臂**(单源叶档)。
|
|
3
3
|
*
|
|
4
|
-
* 权威规格(语义单源)= `docs/core/standards/CODE-TIER.md` §2.2:收口面判的是 **§2
|
|
5
|
-
*
|
|
6
|
-
* `docs/core/design/DOC-CHECK.md` §8;量法的定义单源 = 同档 §
|
|
4
|
+
* 权威规格(语义单源)= `docs/core/standards/CODE-TIER.md` §2.2:收口面判的是 **§2 的记录缺件**——
|
|
5
|
+
* 本批收口时越过收口线的码档,§2 的「受影响文件(机读清单)」里有没有它的分拆方案。判法、触发物与
|
|
6
|
+
* 拒文措辞 = `docs/core/design/DOC-CHECK.md` §8;量法的定义单源 = 同档 §8.2。位次与跳过集 =
|
|
7
7
|
* `batch-closeout.mjs` 的 `assertCloseoutGates` 第 ⑤ 臂。本档只实现,不重述口径(D2)。
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* 不逐档报缺行——「表形不对」与「漏写行」的下一步动作不同(口径 = `docs/core/design/DOC-CHECK.md` §8.4)。
|
|
15
|
-
* ② **越线方案支**(触发物 = 收口时盘上的实测越过收口线):越线档须带正向形分拆方案。
|
|
9
|
+
* 一支判据,触发物 = 收口时盘上的实测越过收口线:
|
|
10
|
+
* - 逐档量**收口那一刻盘上**的内容行数(`countContentLines`,量法见 §8.2):不读批档里记过的数,也不读 git;
|
|
11
|
+
* - 只对越过收口线的档,去 §2 机读清单找它那一行,判第二列(方案格);
|
|
12
|
+
* - 清单解析零行而档全文出现块名 ⇒ 先出一条表形拒文(`tierListUnreadableError`),不逐档报缺行——
|
|
13
|
+
* 「表形不对」与「漏写行」的下一步动作不同(口径 = `docs/core/design/DOC-CHECK.md` §8.4)。
|
|
16
14
|
*
|
|
17
|
-
*
|
|
18
|
-
* **「§2 缺块」仍不是拒因**:块缺时拒的是「每个在盘码档都缺它那一行读数」,不是「格式没写对」。
|
|
19
|
-
* 而「档里有它的名字、清单零行」不是缺行——那是表形不对,另出一条拒文(见 ①)。
|
|
15
|
+
* **「§2 缺块」不是拒因**:块缺时拒的是「越线档在 §2 没有可用方案」,不是「格式没写对」。
|
|
20
16
|
*
|
|
21
|
-
* 入参 `(src, root, changed
|
|
17
|
+
* 入参 `(src, root, changed)`:`src` = 调用方已读的**写盘前全文**;
|
|
22
18
|
* `root` = 仓根(清单第一列是仓根相对路径);`changed` = 本批改动面——**调用方交的现成两面**
|
|
23
|
-
* (写工具触达账 ∪ 提交 diff
|
|
24
|
-
* 三值三判:串 = 该档在快照里的内容 ∥ `null` = 快照里没有这一档 ∥ `undefined` = 基线不可判(整批一条拒)。
|
|
25
|
-
* **本档不读 git**:基线内容由调用方交进来,缺了按入参缺件拒——判据才保持「一段 §2 文本 + 一个仓根 +
|
|
26
|
-
* 一份改动面 + 一个取值函数」的可直取形,单测不必装一个 git 仓。
|
|
19
|
+
* (写工具触达账 ∪ 提交 diff,绝对路径)。判域只由改动面与盘上长度决定,本档不读 git。
|
|
27
20
|
*
|
|
28
21
|
* 依赖:只取段词表叶档的 §2 机读清单解析(`batch-segment-vocab.mjs`——**形单源**,与文档门的计划件判据同一份);
|
|
29
22
|
* 它零 import,无环;本档不 import 任何批次判序档(`batch-closeout.mjs` 单向调本档,本档不回头)。
|
|
@@ -36,7 +29,7 @@ import { MACHINE_LIST_HEAD_NAME, machineListRowsOf } from "./batch-segment-vocab
|
|
|
36
29
|
/** 收口线(> 即越线):语义与时点的单源 = `docs/core/standards/CODE-TIER.md` §2.2。 */
|
|
37
30
|
const FILE_CLOSE_MAX = 800
|
|
38
31
|
|
|
39
|
-
/**
|
|
32
|
+
/** 内容行数(末行换行不计)——量法单源 = 本函数;消费面 = 档位臂的越线支 + 夹具的越线前提断言(集成与单测各一处),改它要连那几处一起看。 */
|
|
40
33
|
export function countContentLines(text) {
|
|
41
34
|
const parts = String(text).split("\n")
|
|
42
35
|
if (parts.length && parts[parts.length - 1] === "") parts.pop()
|
|
@@ -46,12 +39,6 @@ export function countContentLines(text) {
|
|
|
46
39
|
/** 源码 / 单测档后缀闭集。 */
|
|
47
40
|
const CODE_EXTS = Object.freeze([".mjs", ".cjs", ".js"])
|
|
48
41
|
|
|
49
|
-
/** 读数格的值形之一:纯十进制整数(剥装饰符与首尾空白后)。 */
|
|
50
|
-
const READING_NUM_RE = /^\d+$/
|
|
51
|
-
|
|
52
|
-
/** 读数格的另一个值形:快照里没有这一档。写 0 会被读成「量过、是空的」;写别的数就是编。 */
|
|
53
|
-
const NEW_TOKEN = "新"
|
|
54
|
-
|
|
55
42
|
/** 正向形 ①:目标档 token 须**带目录段**(至少一个 `/`)与档后缀——只点名一个光秃名字不算点名目标。 */
|
|
56
43
|
const TARGET_TOKEN_RE = /[A-Za-z0-9_.@-]+\/[A-Za-z0-9_.@/-]*\.[A-Za-z0-9]{1,8}/
|
|
57
44
|
|
|
@@ -76,51 +63,22 @@ const TIER_PLAN_DISPOSAL =
|
|
|
76
63
|
"要写什么:在本批 §2 的「受影响文件(机读清单)」为每个越线档补一行——第二列写正向形方案" +
|
|
77
64
|
"(点名目标档,带目录段;并写出本批落步 `实施轮` ∥ `§5`);未越线的档不受此约束。本门只拒、不代改。Nothing was written."
|
|
78
65
|
|
|
79
|
-
/**
|
|
80
|
-
* 「本节「快照怎么取」」,而运行时串里没有「本档 ∥ 本节」可指,所以把两个家的路径写全;逐档发现句 ∥ 首句 ∥
|
|
81
|
-
* `Nothing was written.` 三处与设计档同字面)。 */
|
|
82
|
-
const TIER_READING_DISPOSAL =
|
|
83
|
-
"要写什么:在 §2「受影响文件(机读清单)」的第三列写该档的原始行数——量法 = `countContentLines`" +
|
|
84
|
-
"(定义单源 = `docs/core/design/DOC-CHECK.md` §1);取数 = 该档在**批起快照**上的内容" +
|
|
85
|
-
"(快照怎么取 = 同档 §8);快照里没有这一档就写 `新`。只报这一个数:不写增量 ∥ 百分比 ∥ 超了多少行。" +
|
|
86
|
-
"本门只拒、不代改。Nothing was written."
|
|
87
|
-
|
|
88
|
-
/** 拒文(门自身入参缺件):改动面与基线取值都是判据的输入,缺省由调用方决定,不由本档猜。 */
|
|
66
|
+
/** 拒文(门自身入参缺件):改动面是判据的输入,缺省由调用方决定,不由本档猜。 */
|
|
89
67
|
function tierInputMissingError(what) {
|
|
90
68
|
return "batch: tier-plan gate is missing its input(收口前置门 · tier-plan gate)— close refuses: " +
|
|
91
|
-
`${what}.
|
|
69
|
+
`${what}. 触发物是本批改动面里在盘码档的实测长度——不知道改了哪几档,就没有可判的东西;` +
|
|
92
70
|
"猜一个等于替调用方决定。Nothing was written."
|
|
93
71
|
}
|
|
94
72
|
|
|
95
|
-
/**
|
|
96
|
-
function tierReadingHeader() {
|
|
97
|
-
return "batch: 码档缺原始行数 ∥ 读数与基线不符(收口前置门 · tier-reading gate)— close refuses: " +
|
|
98
|
-
"a code file this batch changed carries no usable line reading in §2's 受影响文件(机读清单)" +
|
|
99
|
-
"(判的是记录缺件,不是代码长短):"
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** 越线方案那一半的节首句(`tier-plan gate` 是 A2 认的那一句)。 */
|
|
73
|
+
/** 越线方案那一支的节首句(`tier-plan gate` 是 A2 认的那一句)。 */
|
|
103
74
|
function tierPlanHeader() {
|
|
104
75
|
return "batch: 越了收口线却没有分拆方案(收口前置门 · tier-plan gate)— close refuses: a source/test file this batch changed " +
|
|
105
76
|
`crosses the closeout line (> ${FILE_CLOSE_MAX}) and §2 carries no usable split plan for it(判的是记录缺件:§2 有没有可用方案):`
|
|
106
77
|
}
|
|
107
78
|
|
|
108
|
-
/**
|
|
109
|
-
function
|
|
110
|
-
return
|
|
111
|
-
"§1 has no usable `批起 sha`(缺记入行 ∥ 该对象读不到),读数的比对基准不存在,这一半无从核起:\n" +
|
|
112
|
-
"要写什么:在 §1 记入行写 `批起 sha = <批起快照 sha>`(快照怎么取 = `docs/core/design/DOC-CHECK.md` §8)。" +
|
|
113
|
-
"本门只拒、不代改。Nothing was written."
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** 一条拒文装两节(KD-5):两节各带自己的「要写什么」,设计席一次改完再收口。 */
|
|
117
|
-
function tierRefusalError(readingFindings, planFindings) {
|
|
118
|
-
const blocks = []
|
|
119
|
-
if (readingFindings.length) blocks.push([tierReadingHeader(), ...readingFindings, TIER_READING_DISPOSAL].join("\n"))
|
|
120
|
-
if (planFindings.length) {
|
|
121
|
-
blocks.push([tierPlanHeader(), ...planFindings, TIER_PLAN_DISPOSAL].join("\n"))
|
|
122
|
-
}
|
|
123
|
-
return blocks.join("\n")
|
|
79
|
+
/** 一条拒文(一次收口只抛一次):设计席一次改完再收口。 */
|
|
80
|
+
function tierRefusalError(planFindings) {
|
|
81
|
+
return [tierPlanHeader(), ...planFindings, TIER_PLAN_DISPOSAL].join("\n")
|
|
124
82
|
}
|
|
125
83
|
|
|
126
84
|
/**
|
|
@@ -162,7 +120,7 @@ function displayPath(p, root) {
|
|
|
162
120
|
}
|
|
163
121
|
|
|
164
122
|
/**
|
|
165
|
-
*
|
|
123
|
+
* 逐档实测内容行数(**量法 = `countContentLines`**,收口面自己量盘上那一刻的长度——不采信任何抄来的数)。
|
|
166
124
|
* 量不到 ⇒ `null`:本批删掉 / 搬走的档在盘上没有长度可量,跳过(不是「干净的档」,是**没有这一档**)。
|
|
167
125
|
* @param {string} changedPath — 改动面条目(绝对路径 ∥ 仓根相对路径)
|
|
168
126
|
* @param {string} root — 仓根
|
|
@@ -180,7 +138,7 @@ function contentLinesOf(changedPath, root) {
|
|
|
180
138
|
|
|
181
139
|
/**
|
|
182
140
|
* 判域 = 本批改动面里**在盘**的码档(同一档去重后只量一次——触达账与提交清单会重叠)。
|
|
183
|
-
* @returns {{abs:string, len:number}[]} 绝对路径 + 盘上内容行数(`len`
|
|
141
|
+
* @returns {{abs:string, len:number}[]} 绝对路径 + 盘上内容行数(`len` 就是越线那一支的触发物)
|
|
184
142
|
*/
|
|
185
143
|
function codeFilesOf(changed, root) {
|
|
186
144
|
const out = []
|
|
@@ -198,50 +156,12 @@ function codeFilesOf(changed, root) {
|
|
|
198
156
|
return out
|
|
199
157
|
}
|
|
200
158
|
|
|
201
|
-
/** 一个码档那一格缺什么:`null` = 读数成立 ∥ 一句「哪一格不对、写的是什么、基线是什么」。 */
|
|
202
|
-
function readingGapOf(row, baseLines) {
|
|
203
|
-
const cell = cellText(row?.reading)
|
|
204
|
-
if (baseLines === null) {
|
|
205
|
-
if (cell === NEW_TOKEN) return null
|
|
206
|
-
if (READING_NUM_RE.test(cell)) return `写的是 ${Number(cell)},而批起快照里没有这一档;本批期间建的档写 \`新\``
|
|
207
|
-
return "该列没有数(空 ∥ `—`);批起快照里也没有这一档,该格写 `新`"
|
|
208
|
-
}
|
|
209
|
-
if (cell === NEW_TOKEN) return `写的是 \`新\`,而批起快照里这一档有 ${baseLines} 行`
|
|
210
|
-
if (!READING_NUM_RE.test(cell)) return `该列没有数(空 ∥ \`—\`);基线是 ${baseLines}`
|
|
211
|
-
const n = Number(cell)
|
|
212
|
-
return n === baseLines ? null : `写的是 ${n},基线是 ${baseLines}`
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* 读数支(在盘的每个码档逐档核):三值分流全部在这里,`undefined` ⇒ 抛整批一条「批起基线不可判」
|
|
217
|
-
* (放行等于没核,静默退回头更坏)。
|
|
218
|
-
* @returns {string[]} 逐档发现(空 = 这一半成立)
|
|
219
|
-
*/
|
|
220
|
-
function readingFindingsOf(files, rows, root, baseTextOf) {
|
|
221
|
-
const findings = []
|
|
222
|
-
for (const f of files) {
|
|
223
|
-
const rel = displayPath(f.abs, root)
|
|
224
|
-
const base = baseTextOf(rel)
|
|
225
|
-
if (base === undefined || (base !== null && typeof base !== "string")) throw new Error(tierBaselineError())
|
|
226
|
-
const baseLines = base === null ? null : countContentLines(base)
|
|
227
|
-
const row = rowFor(f.abs, rows)
|
|
228
|
-
const gap = row === null
|
|
229
|
-
? baseLines === null
|
|
230
|
-
? "§2 清单里没有这一档的行;批起快照里也没有这一档,该格写 `新`"
|
|
231
|
-
: `§2 清单里没有这一档的行;基线是 ${baseLines}`
|
|
232
|
-
: readingGapOf(row, baseLines)
|
|
233
|
-
if (gap === null) continue
|
|
234
|
-
findings.push(` ${rel} — ${gap}`)
|
|
235
|
-
}
|
|
236
|
-
return findings
|
|
237
|
-
}
|
|
238
|
-
|
|
239
159
|
/** 拒文(清单读不出行):档里明明写着块名,解析面却一行都没有——那是表形不对,不是漏写行。
|
|
240
160
|
* 形单源 = `docs/core/design/DOC-CHECK.md` §8.4;块名取解析器那一份字面(`MACHINE_LIST_HEAD_NAME`)。 */
|
|
241
161
|
function tierListUnreadableError(files, root) {
|
|
242
162
|
// 逐个一行、与逐档发现同形(` <仓根相对> — <gap>`):这一份的 gap 对每档相同——清单读不出行,就没有它的行可读
|
|
243
163
|
const list = files.map((f) => ` ${displayPath(f.abs, root)} — 清单读不出行,无行可读`).join("\n")
|
|
244
|
-
return "batch: §2 的机读清单读不出行(收口前置门 · tier-
|
|
164
|
+
return "batch: §2 的机读清单读不出行(收口前置门 · tier-plan gate)— close refuses: " +
|
|
245
165
|
"the batch record carries the block name in its text, yet §2's machine-readable list parses to zero rows — " +
|
|
246
166
|
`档里有它的名字,清单却解析出零行,本批每个在盘码档就没有行可读:` +
|
|
247
167
|
`\n${list}\n` +
|
|
@@ -249,49 +169,46 @@ function tierListUnreadableError(files, root) {
|
|
|
249
169
|
"`**受影响文件(机读清单)**`,或同名标题行(`#{1,6}` 起头、标题文字以这个名字结尾,如 " +
|
|
250
170
|
"`### 受影响文件(机读清单)` ∥ `### 3. 受影响文件(机读清单)`);" +
|
|
251
171
|
"`### 受影响文件(机读清单)的写法` 这类「在提它」的标题不在两形之内。" +
|
|
252
|
-
"②
|
|
172
|
+
"② 表行的格数不在 2–3 格(少于 2 格 ∥ 4 格以上的行跳过)。" +
|
|
253
173
|
"③ 表行不连续——中间夹一个空行即截断,其后的行读不到;只剩表头行或全是 `<…>` 占位行同样是零行。" +
|
|
254
|
-
"
|
|
174
|
+
"要写什么:把块头改成两形之一,其下紧跟一张连续的两列表(`| 档 | 分拆方案 |`),一行一档。" +
|
|
255
175
|
"本门只拒、不代改。Nothing was written."
|
|
256
176
|
}
|
|
257
177
|
|
|
258
178
|
/**
|
|
259
|
-
* 收口前置门(第 ⑤ 臂 ·
|
|
260
|
-
*
|
|
179
|
+
* 收口前置门(第 ⑤ 臂 · 档位臂):只判「越线档在 §2 有没有可用方案」,一次收口一条拒文。
|
|
180
|
+
* 判序:先判表形(清单零行而档里有块名 ⇒ 表形拒文),再逐档判方案格——整份读不出行时,每一条逐档比对
|
|
181
|
+
* 都只是同一个原因的回声。
|
|
261
182
|
* 放行零回执(与其余收口前置同形:不写回执段、不改回执字面)。
|
|
262
183
|
* @param {string} src — 写盘前的档全文
|
|
263
184
|
* @param {string} root — 仓根(**必填**:清单第一列与改动面条目都按它落盘,缺省由调用方决定而不是本档猜)
|
|
264
185
|
* @param {string[]} changed — 本批改动面(触达账 ∪ 提交 diff;**必填**——它就是触发物的取材)
|
|
265
|
-
* @
|
|
266
|
-
* @throws 入参缺件 ∥ 基线不可判 ∥ 读数缺件 ∥ 越线而缺方案
|
|
186
|
+
* @throws 入参缺件 ∥ 清单读不出行 ∥ 越线而缺方案
|
|
267
187
|
*/
|
|
268
|
-
export function assertTierPlan(src, root, changed
|
|
188
|
+
export function assertTierPlan(src, root, changed) {
|
|
269
189
|
if (typeof root !== "string" || root.trim() === "") {
|
|
270
190
|
throw new Error(tierInputMissingError("the repo root was not given — the affected-file list's first column is repo-root-relative, and a guessed base measures the wrong files"))
|
|
271
191
|
}
|
|
272
192
|
if (!Array.isArray(changed)) {
|
|
273
193
|
throw new Error(tierInputMissingError("the changed-file list was not given — the trigger is the measured length of this batch's own changed files, so the gate cannot guess it"))
|
|
274
194
|
}
|
|
275
|
-
if (typeof baseTextOf !== "function") {
|
|
276
|
-
throw new Error(tierInputMissingError("the baseline reader (`baseTextOf`) was not given as a function — the reading column is compared against each file's content in the batch-start snapshot, and this gate does not read git itself; a guessed baseline measures the wrong thing"))
|
|
277
|
-
}
|
|
278
195
|
const files = codeFilesOf(changed, root)
|
|
279
|
-
//
|
|
280
|
-
|
|
281
|
-
|
|
196
|
+
// 没有在盘码档 ⇒ 本门不启动(连 §2 都不解析)。
|
|
197
|
+
if (files.length === 0) return
|
|
198
|
+
const rows = machineListRowsOf(src)
|
|
199
|
+
// 表形自诊断:先判表形再判方案——整份读不出行时,每一条逐档比对都只是同一个原因的回声。
|
|
282
200
|
// 三条件全从既有入参算得(码档非空 ∥ 清单零行 ∥ 档全文出现块名),不新增参数、不设开关。
|
|
283
|
-
if (
|
|
201
|
+
if (rows.length === 0 && String(src ?? "").includes(MACHINE_LIST_HEAD_NAME)) {
|
|
284
202
|
throw new Error(tierListUnreadableError(files, root))
|
|
285
203
|
}
|
|
286
|
-
|
|
287
|
-
// ② 越线方案支:只在收口时的实测越过收口线时才查(`§2 缺块本身不是拒因` 照旧成立)。
|
|
204
|
+
// 越线方案支:只在收口时的实测越过收口线时才查(`§2 缺块本身不是拒因` 照旧成立)。
|
|
288
205
|
const planFindings = []
|
|
289
206
|
for (const f of files) {
|
|
290
207
|
if (f.len <= FILE_CLOSE_MAX) continue
|
|
291
208
|
const row = rowFor(f.abs, rows)
|
|
292
|
-
const gap = row === null ? "§2
|
|
209
|
+
const gap = row === null ? "§2 清单里没有这一档的行" : planGapOf(row.plan)
|
|
293
210
|
if (gap === null) continue
|
|
294
211
|
planFindings.push(` ${displayPath(f.abs, root)} — ${f.len} > ${FILE_CLOSE_MAX};${gap}`)
|
|
295
212
|
}
|
|
296
|
-
if (
|
|
213
|
+
if (planFindings.length) throw new Error(tierRefusalError(planFindings))
|
|
297
214
|
}
|
package/agent-tools/batch.mjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* 单工具 `batch`,action = create(建档,§4.11)/ attach(给现役档补挂台账行,§4.21.3)/ append(段写入)/ edit
|
|
6
6
|
* (段内就地改,§4.19)/ status(段属主状态行流转,§4.12)/ close(收口冻结,§4.13)/ supersede
|
|
7
|
-
* (被取代的收口,§4.18-D
|
|
7
|
+
* (被取代的收口,§4.18-D——对象已消失、永不实施、且能点名取代者的批档)/ read(只读:段索引 ∥ 段窗口,§4.25)。
|
|
8
|
+
* 写入面**按段分权、不按段分处置**:
|
|
8
9
|
* 六段各自只有一个作者,作者对本段可 append 加内容 ∥ edit 就地改既有行(§4.19);状态行只有一个写者(status)。
|
|
9
10
|
* 权威规格 = `docs/core/design/BATCH-RECORD.md` §4(契约/挂载/用例 §4.8/骨架 §4.10/
|
|
10
11
|
* 参数面 §4.11–§4.13 · §4.21)。
|
|
@@ -43,6 +44,7 @@ import { SEGMENT_BY_ROLE } from "./batch-skeleton.mjs"
|
|
|
43
44
|
import { batchDocBases, resolveBatchDocPath } from "./batch-paths.mjs"
|
|
44
45
|
import { createBatchRecord, attachBatchRecord } from "./batch-ledger-bind.mjs"
|
|
45
46
|
import { checkBatchRecord, closeBatchRecord, findInFlightBatch, statusBatchRecord } from "./batch-lifecycle.mjs"
|
|
47
|
+
import { readBatchRecord } from "./batch-read.mjs"
|
|
46
48
|
import { supersedeBatchRecord } from "./batch-supersede.mjs"
|
|
47
49
|
import { appendBatchRecord, editBatchRecord } from "./batch-record-write.mjs"
|
|
48
50
|
|
|
@@ -85,42 +87,48 @@ export function batchDocForReview(agent, documents, callbacks = null) {
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
/**
|
|
88
|
-
* 身份 profile(TOOLS.md §6.29 ②):depth-0 =
|
|
89
|
-
* append / edit / status
|
|
90
|
-
*
|
|
90
|
+
* 身份 profile(TOOLS.md §6.29 ②):depth-0 = 全量动作面;子代理与评审 = 自己那一段的
|
|
91
|
+
* append / edit / status,加上**只读**的 `read`(读域 = 整档,不受段写权约束——§4.25;段域仍由既有
|
|
92
|
+
* 身份白名单裁决,本档只裁**动作面与参数面**)。
|
|
93
|
+
* 描述取各自一份档——全量档 `batch.md` 通篇讲全量动作,子代理读到它就是读到做不到的事(B6)。
|
|
91
94
|
*/
|
|
92
|
-
const PROFILE_ACTIONS = ["append", "edit", "status"]
|
|
95
|
+
const PROFILE_ACTIONS = ["append", "edit", "status", "read"]
|
|
93
96
|
const PROFILE_SEGMENTS = { "eng-designer": 2, "eng-coder": 5, coder: 5, review: 3 }
|
|
94
97
|
const PROFILE_DOCS = { "eng-designer": "batch-eng-designer", "eng-coder": "batch-eng-coder", coder: "batch-eng-coder", review: "batch-review" }
|
|
95
|
-
/** profile 面保留的参数(其余参数只服务 create / attach / close / path,profile 执行不到 ⇒ 不出现)。
|
|
96
|
-
|
|
98
|
+
/** profile 面保留的参数(其余参数只服务 create / attach / close / path,profile 执行不到 ⇒ 不出现)。
|
|
99
|
+
* `offset` 只服务 `read` 的窗口形——profile 面同样要能取它。 */
|
|
100
|
+
const PROFILE_PROPS = ["segment", "text", "oldText", "newText", "value", "note", "offset"]
|
|
97
101
|
/** profile 面的 `segment` 参数(只点名自己那段——全量档那句把六个身份的白名单一起列出来,
|
|
98
102
|
* 子代理读到的是别的身份的写域)。 */
|
|
99
103
|
function profileSegmentProp(profileKey) {
|
|
100
104
|
const seg = PROFILE_SEGMENTS[profileKey]
|
|
101
105
|
return {
|
|
102
106
|
type: "string",
|
|
103
|
-
description: `append/edit/status only — the batch-record section
|
|
107
|
+
description: `append/edit/status/read only — the batch-record section: §${seg} is your pen on this record (e.g. "§${seg}"), and \`read\` may open a window of any section the record carries. Declares the section number only; the identity bound to this spawn decides what is actually writable.`,
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
/** 全量参数面(depth-0
|
|
111
|
+
/** 全量参数面(depth-0 动作面):schema 单源——profile 面从它取所需格,见 `PROFILE_PROPS`。 */
|
|
108
112
|
function fullParameters() {
|
|
109
113
|
return {
|
|
110
114
|
type: "object",
|
|
111
115
|
properties: {
|
|
112
116
|
action: {
|
|
113
117
|
type: "string",
|
|
114
|
-
enum: ["create", "attach", "append", "edit", "status", "close", "supersede", "check"],
|
|
115
|
-
description: "Which lifecycle step to run: create (new record) / attach — hang a ledger row on an ALREADY EXISTING in-flight record (depth-0 only: a reopened record taking on a new piece of work; opens a new row, or takes over an unsettled one with ledger:\"#<id>\", and writes its number into the header 台账 line) / append (add text to the END of your section) / edit — replace one anchored range inside YOUR OWN section (§1–§6 alike; your identity decides which section) / status (your section's status line) / close (freeze the record — this settles the batch's ledger rows in the same action) / supersede — freeze a record whose object is gone and will never be implemented, naming what replaced it (supersededBy); it never writes §3/§4/§6, settles the 待核销 rows and returns the unnamed 在途 rows to 待讨论 with trigger
|
|
118
|
+
enum: ["create", "attach", "append", "edit", "status", "close", "supersede", "check", "read"],
|
|
119
|
+
description: "Which lifecycle step to run: create (new record) / attach — hang a ledger row on an ALREADY EXISTING in-flight record (depth-0 only: a reopened record taking on a new piece of work; opens a new row, or takes over an unsettled one with ledger:\"#<id>\", and writes its number into the header 台账 line) / append (add text to the END of your section) / edit — replace one anchored range inside YOUR OWN section (§1–§6 alike; your identity decides which section) / status (your section's status line) / close (freeze the record — this settles the batch's ledger rows in the same action) / supersede — freeze a record whose object is gone and will never be implemented, naming what replaced it (supersededBy); it never writes §3/§4/§6, settles the 待核销 rows and returns the unnamed 在途 rows to 待讨论 with the conditional-resume trigger (depth-0 only) / check (depth-0 only, read-only: print this record's half-state readings — §1 open|closed, its ledger rows, and every record↔ledger inconsistency with the way out) / read (read-only, every seat that holds this tool: no `segment` ⇒ the record's section index — the header rows plus one line per section with its status word and body line count; `segment` + REQUIRED `offset` ⇒ one window of that section's body, 1-based, at most 200 lines, the receipt naming the next `offset`. A closed record reads the same — freezing is a write gate. The read domain is the whole record, not your pen: §1 carries the rulings, §3 the previous round, §5 the implementation record.)",
|
|
116
120
|
},
|
|
117
121
|
path: {
|
|
118
122
|
type: "string",
|
|
119
|
-
description: "depth-0 only (D-BR21) — the batch record to operate on (
|
|
123
|
+
description: "depth-0 only (D-BR21) — the batch record to operate on (must be readable when given). Omit it to target the unique in-flight record (0 or ≥2 in flight ⇒ refuse). Sub-agents and design reviews: do NOT pass path — your target record arrives via the spawn binding / the review instance key.",
|
|
120
124
|
},
|
|
121
125
|
segment: {
|
|
122
126
|
type: "string",
|
|
123
|
-
description: "append/edit/status only — the batch-record section you
|
|
127
|
+
description: "append/edit/status/read only — the batch-record section you write, or the one `read` opens a window of (e.g. \"§4\"). Declares the section number only; for the write actions your identity decides what is actually writable (main agent: append/edit §1/§4/§6 · status §1 (engineering) / append/edit §1/§2/§4/§5/§6 · status §1/§2/§5 (normal); eng-designer §2; eng-coder §5; normal-mode coder with a batchDoc binding §5; design review §3). edit reads the same whitelist as append — one table, two actions: the section you may append is the section you may rewrite in place. `read` is not bound by that whitelist: it reads any section the record carries, and given `segment` it also needs `offset`.",
|
|
128
|
+
},
|
|
129
|
+
offset: {
|
|
130
|
+
type: "number",
|
|
131
|
+
description: "read only, REQUIRED once `segment` is given — the 1-based line inside that section's body to start the window at (the first body line is 1); a window carries at most 200 lines and the receipt names the next offset while lines remain. Omit it together with `segment` to get the record's section index instead — a section with no offset is refused rather than started at line 1 for you.",
|
|
124
132
|
},
|
|
125
133
|
text: {
|
|
126
134
|
type: "string",
|
|
@@ -140,12 +148,12 @@ function fullParameters() {
|
|
|
140
148
|
},
|
|
141
149
|
note: {
|
|
142
150
|
type: "string",
|
|
143
|
-
description: "status only — prose that lands as a parenthetical on the status line (
|
|
151
|
+
description: "status only — prose that lands as a parenthetical on the status line (`**状态行**:进行中(note)`). Single line; must carry no STATUS_WORDS keyword (those go in `value`) and no skeleton placeholders. Omit for a plain value. On the reopen path (a frozen record, §1 → 进行中) `note` is REQUIRED and lands verbatim in the §1 reopen record instead of the status-line parenthetical (it may name the frozen keyword there).",
|
|
144
152
|
},
|
|
145
153
|
completed: {
|
|
146
154
|
type: "array",
|
|
147
155
|
items: { type: "number" },
|
|
148
|
-
description: "close / status writing §1 已收口 / supersede — REQUIRED for close and status: the ledger ids completed by this batch. Every id must be unique, belong to this record, and currently be 在途; every 在途 row must be listed. [] is valid only when the batch has no 在途 rows. On supersede the list is optional: an unnamed 在途 row goes back to 待讨论 with trigger
|
|
156
|
+
description: "close / status writing §1 已收口 / supersede — REQUIRED for close and status: the ledger ids completed by this batch. Every id must be unique, belong to this record, and currently be 在途; every 在途 row must be listed. [] is valid only when the batch has no 在途 rows. On supersede the list is optional: an unnamed 在途 row goes back to 待讨论 with the conditional-resume trigger (the work was not done — that is what this closeout says), so [] or omitting it is the main path there. Other actions do not accept this parameter. Invalid or omitted ids are refused before tokens or the record are written; return unfinished rows to 待讨论 first. Those rows are settled to 已核销 in the same transaction, and this batch's existing 待核销 rows are settled with them — closing leaves zero 在途 and zero 待核销 behind.",
|
|
149
157
|
},
|
|
150
158
|
supersededBy: {
|
|
151
159
|
type: "string",
|
|
@@ -165,7 +173,7 @@ function fullParameters() {
|
|
|
165
173
|
},
|
|
166
174
|
ledger: {
|
|
167
175
|
type: "string",
|
|
168
|
-
description: "create / attach — optional: an existing ledger entry number to take over (e.g. \"#1830\"; a leading # is optional) — on attach that is how a reopened record takes over an unsettled row. Omit it and the call opens a NEW ledger row in the same call (status 在途 · task_book = this record · trigger
|
|
176
|
+
description: "create / attach — optional: an existing ledger entry number to take over (e.g. \"#1830\"; a leading # is optional) — on attach that is how a reopened record takes over an unsettled row. Omit it and the call opens a NEW ledger row in the same call (status 在途 · task_book = this record · trigger = the batch-attributed value; attach needs title for that) — but only when no unsettled row exists on the same face (board); otherwise it is refused and lists the candidates, and you pass either ledger:\"#<id>\" to take one over or newDebt:\"<why this is not one of them>\". Pass an archived / settled / foreign-owned row and it is refused. The row and the record are one action — there is no separate registration step.",
|
|
169
177
|
},
|
|
170
178
|
newDebt: {
|
|
171
179
|
type: "string",
|
|
@@ -173,7 +181,7 @@ function fullParameters() {
|
|
|
173
181
|
},
|
|
174
182
|
board: {
|
|
175
183
|
type: "string",
|
|
176
|
-
description: "create / attach — optional: the owning board for the header's 台账 line (e.g. \"core\"). Given, the opened/taken-over row is a requirement and carries this board; omitted, the row is a tech_todo. create writes it into the header
|
|
184
|
+
description: "create / attach — optional: the owning board for the header's 台账 line (e.g. \"core\"). Given, the opened/taken-over row is a requirement and carries this board; omitted, the row is a tech_todo. create writes it into the header's parenthetical (omitted ⇒ `—`); attach never rewrites the parenthesis group — it only appends to the number list.",
|
|
177
185
|
},
|
|
178
186
|
title: {
|
|
179
187
|
type: "string",
|
|
@@ -193,7 +201,7 @@ function fullParameters() {
|
|
|
193
201
|
}
|
|
194
202
|
|
|
195
203
|
/**
|
|
196
|
-
* 批次档生命周期工具工厂(主名 `batch`——**七 action**(+ `check` 只读面):create / attach / append / edit /
|
|
204
|
+
* 批次档生命周期工具工厂(主名 `batch`——**七 action**(+ `check` ∥ `read` 只读面):create / attach / append / edit /
|
|
197
205
|
* status / close / supersede)。
|
|
198
206
|
* @param {string|null} batchDoc — 绑定的目标档(spawn:`child._batchDoc`;评审:实例键;
|
|
199
207
|
* depth-0 主 agent 挂载时 = null——目标走 D-BR21 可选 path / 在飞扫描)
|
|
@@ -214,7 +222,7 @@ export function batchTool(batchDoc = null, { review = false, role = null, review
|
|
|
214
222
|
action: {
|
|
215
223
|
type: "string",
|
|
216
224
|
enum: PROFILE_ACTIONS,
|
|
217
|
-
|
|
225
|
+
description: `Which step this face carries, inside your own section: add text to its END / replace one anchored range inside it / write its status line / read the record without writing anything (no \`segment\` ⇒ its section index; \`segment\` + \`offset\` ⇒ one window of that section).`,
|
|
218
226
|
},
|
|
219
227
|
...Object.fromEntries(PROFILE_PROPS.map((k) => [k, k === "segment" ? profileSegmentProp(profileKey) : full.properties[k]])),
|
|
220
228
|
},
|
|
@@ -272,8 +280,10 @@ export function batchTool(batchDoc = null, { review = false, role = null, review
|
|
|
272
280
|
return supersedeBatchRecord({ args, ctx, review, pickTarget, onWritten })
|
|
273
281
|
case "check":
|
|
274
282
|
return checkBatchRecord({ args, ctx, review, pickTarget })
|
|
283
|
+
case "read":
|
|
284
|
+
return readBatchRecord({ args, ctx, review, pickTarget })
|
|
275
285
|
default:
|
|
276
|
-
throw new Error(`batch: unknown action ${JSON.stringify(args?.action ?? null)} — pass one of create / attach / append / edit / status / close / supersede / check.`)
|
|
286
|
+
throw new Error(`batch: unknown action ${JSON.stringify(args?.action ?? null)} — pass one of create / attach / append / edit / status / close / supersede / check / read.`)
|
|
277
287
|
}
|
|
278
288
|
},
|
|
279
289
|
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* agent/helpers.mjs(escapeXml)· context.mjs(pushReal)——叶子向、无环。
|
|
23
23
|
*/
|
|
24
24
|
import { escapeXml } from "../agent/helpers.mjs"
|
|
25
|
-
import {
|
|
25
|
+
import { pushInject, pushRecord } from "../context.mjs"
|
|
26
26
|
import { runAction } from "../browser/session.mjs"
|
|
27
27
|
import {
|
|
28
28
|
bindChildController, buildChildSignal, carrierField, getAsyncPool, parkAsyncPending,
|
|
@@ -167,7 +167,10 @@ export async function injectBrowserResult(parent, entry) {
|
|
|
167
167
|
: "ok"
|
|
168
168
|
const head = `[System reminder: background browser#${entry.id} finished — ${label} (${status}, ${seconds}s)]`
|
|
169
169
|
const body = escapeXml(String(entry.receipt ?? entry.error ?? "(no result)"))
|
|
170
|
-
|
|
170
|
+
const msg = { role: "user", content: `${head}\n${body}` }
|
|
171
|
+
// B 段:一次性投递走待发队,持久写入只落人读线(机读线零触)。
|
|
172
|
+
pushInject(parent, msg)
|
|
173
|
+
pushRecord(parent, msg)
|
|
171
174
|
writeTombstone(parent, entry.id, entry.error != null || entry.failed != null ? "failed" : "consumed", "browser")
|
|
172
175
|
}
|
|
173
176
|
|
package/agent-tools/consult.mjs
CHANGED
|
@@ -28,18 +28,18 @@ import { createAgent, runAgent, excludeSubagentTools } from "../agent.mjs"
|
|
|
28
28
|
import { deriveReadonlyTools } from "../agent/helpers.mjs"
|
|
29
29
|
import { readonlyActionTest } from "../agent/dispatch-gates.mjs"
|
|
30
30
|
import { resolveChildProvider } from "./subagent.mjs"
|
|
31
|
-
import {
|
|
31
|
+
import { pushInject, pushRecord } from "../context.mjs"
|
|
32
32
|
import { offloadToolResult, escapeXml } from "../agent/helpers.mjs"
|
|
33
33
|
import { logEvent, errText } from "../log.mjs"
|
|
34
34
|
import { deathLine } from "../abort-provenance.mjs"
|
|
35
35
|
import { makeRelay, wrapChildCallbacks, runWithContinue, ensureChildApiKey, clampEffort } from "../agent/spawn-child.mjs"
|
|
36
|
-
// TUI-OOM-ROOTCAUSE·AGENT-LOOP.md §
|
|
36
|
+
// TUI-OOM-ROOTCAUSE·AGENT-LOOP.md §9.2:子代理人读线窗口常量(单源——store 零依赖)。
|
|
37
37
|
import { RECORD_WINDOW_MESSAGES } from "../session-store.mjs"
|
|
38
38
|
// ASYNC-RESULT-CONTAINER.md D2/D3/D6:pending 单容器停靠 + settle 公共收尾 + child signal 单点
|
|
39
39
|
import { bindChildController, buildChildSignal, settleAsyncEntry } from "./async-settle.mjs"
|
|
40
40
|
import { registerTurnCapCheckpoint } from "./checkpoint.mjs"
|
|
41
41
|
import { drainInjectedQueue } from "./subagent-run.mjs"
|
|
42
|
-
import { digestBudgetOver, persistOverflowReport } from "./digest-budget.mjs" // B5(群 B 批 AGENT-LOOP.md §
|
|
42
|
+
import { digestBudgetOver, persistOverflowReport } from "./digest-budget.mjs" // B5(群 B 批 AGENT-LOOP.md §9 D-DG2):digest 注入预算单源
|
|
43
43
|
// #15 描述外置:描述文本单点 = tool-docs/{consult_start,consult_stop,main_history}.md(DESC 单解析面,缺档抛错语义不变)
|
|
44
44
|
import { DESC } from "../tools/shared.mjs"
|
|
45
45
|
|
|
@@ -188,7 +188,7 @@ export function composeConsultDigest(session) {
|
|
|
188
188
|
*/
|
|
189
189
|
export async function injectConsultResult(agent, entry) {
|
|
190
190
|
const full = String(entry?.report ?? "(no consultation result)")
|
|
191
|
-
// §
|
|
191
|
+
// §9 D-DG3(群 B 批 B5):计入预算的 raw = 报告正文(标签行不计)——首行标签拆出;超限
|
|
192
192
|
// 路径保留族标签行(与 VSC 镜像同形);落盘内容 = raw(与其余三族同口径)。
|
|
193
193
|
const at = full.indexOf("\n")
|
|
194
194
|
const label = at === -1 ? "" : full.slice(0, at + 1)
|
|
@@ -196,10 +196,13 @@ export async function injectConsultResult(agent, entry) {
|
|
|
196
196
|
const over = digestBudgetOver(agent, raw.length)
|
|
197
197
|
const saved = over ? await persistOverflowReport(raw, { tag: `consult-${entry?.id ?? "session"}` }) : null
|
|
198
198
|
const preview = saved ? `${label}${saved}` : await offloadToolResult(full, `consult-${entry?.id ?? "session"}`)
|
|
199
|
-
|
|
199
|
+
const msg = {
|
|
200
200
|
role: "user",
|
|
201
201
|
content: escapeXml(preview),
|
|
202
|
-
}
|
|
202
|
+
}
|
|
203
|
+
// B 段:一次性投递走待发队,持久写入只落人读线(机读线零触)。
|
|
204
|
+
pushInject(agent, msg)
|
|
205
|
+
pushRecord(agent, msg)
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
/** Per-child settle 路由(consult 同族收齐批 · 2026-09-30 · 台账 #748):settle 一律发
|
|
@@ -292,7 +295,7 @@ async function runConsultChild(ctx, session, id, m, problem, ctrl) {
|
|
|
292
295
|
// role "consult" (overlay + base would concatenate it twice).
|
|
293
296
|
role: "consult",
|
|
294
297
|
})
|
|
295
|
-
// TUI-OOM-ROOTCAUSE·AGENT-LOOP.md §
|
|
298
|
+
// TUI-OOM-ROOTCAUSE·AGENT-LOOP.md §9.2:子代理人读线窗口(四处创建点同置)——consult 会话跨回合驻留,
|
|
296
299
|
// 不置窗则 _fullHistory 仍无界(F-O1 覆盖 depth>0 全部创建点)
|
|
297
300
|
child._historyWindow = RECORD_WINDOW_MESSAGES
|
|
298
301
|
// SUBAGENT-UPSTREAM-CHANNEL 补赋(TURN-CAP-CONTINUE.md §3.1):会诊 = 后台族(consult_start
|