@thincoder/core 0.10.13 → 0.11.2
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 +74 -1
- package/advisor/convergence.mjs +34 -3
- package/advisor/loop.mjs +42 -10
- package/advisor/messages.mjs +46 -27
- package/advisor/notice.mjs +1 -1
- package/advisor/project-context.mjs +253 -14
- package/advisor/run.mjs +7 -4
- package/advisor.mjs +29 -43
- package/agent/batch-attribution.mjs +87 -0
- package/agent/batch-changed-surface.mjs +129 -0
- package/agent/completion.mjs +57 -4
- package/agent/digest-account.mjs +73 -46
- package/agent/dispatch-gates.mjs +6 -0
- package/agent/dispatch-run.mjs +1 -1
- package/agent/dispatch.mjs +35 -22
- package/agent/family-tools.mjs +36 -17
- package/agent/helpers.mjs +123 -95
- package/agent/offload.mjs +84 -0
- package/agent/post-turn.mjs +24 -10
- package/agent/record-results.mjs +19 -7
- package/agent/run-stages.mjs +127 -61
- package/agent/run-start.mjs +45 -8
- package/agent/setup-reminders.mjs +9 -2
- package/agent/setup.mjs +27 -22
- package/agent/spawn-child.mjs +38 -1
- package/agent/suspension.mjs +1 -1
- package/agent/timers.mjs +5 -3
- package/agent/turn-loop.mjs +60 -6
- package/agent/turn-projection.mjs +386 -0
- package/agent/turn-task-state.mjs +274 -0
- package/agent/turn-tool-process.mjs +168 -0
- package/agent/write-face.mjs +99 -0
- package/agent/write-gate-ledger.mjs +569 -0
- package/agent/write-gate.mjs +39 -13
- package/agent-tools/advisor-async.mjs +29 -169
- package/agent-tools/advisor-launch.mjs +178 -0
- package/agent-tools/advisor-settle.mjs +28 -1
- package/agent-tools/advisor.mjs +136 -31
- package/agent-tools/async-settle.mjs +2 -2
- package/agent-tools/audit-block.mjs +6 -6
- package/agent-tools/bash-async.mjs +8 -2
- package/agent-tools/batch-closeout.mjs +444 -0
- package/agent-tools/batch-gate.mjs +152 -138
- package/agent-tools/batch-ledger-bind.mjs +392 -0
- package/agent-tools/batch-ledger-link.mjs +73 -0
- package/agent-tools/batch-ledger-view.mjs +109 -0
- package/agent-tools/batch-lifecycle.mjs +245 -376
- package/agent-tools/batch-paths.mjs +73 -47
- package/agent-tools/batch-read.mjs +1 -1
- package/agent-tools/batch-record-write.mjs +417 -0
- package/agent-tools/batch-regions.mjs +215 -0
- package/agent-tools/batch-reopen.mjs +154 -0
- package/agent-tools/batch-segment-vocab.mjs +379 -0
- package/agent-tools/batch-skeleton.mjs +344 -196
- package/agent-tools/batch-supersede.mjs +232 -0
- package/agent-tools/batch-tier-gate.mjs +297 -0
- package/agent-tools/batch.mjs +189 -253
- package/agent-tools/consult.mjs +7 -4
- package/agent-tools/context.mjs +47 -17
- package/agent-tools/design-review-record.mjs +225 -0
- package/agent-tools/design-slots.mjs +24 -24
- package/agent-tools/design-token.mjs +318 -39
- package/agent-tools/doc-check.mjs +55 -29
- package/agent-tools/doc-graph.mjs +140 -0
- package/agent-tools/eng.mjs +10 -9
- package/agent-tools/escalate-async.mjs +5 -5
- package/agent-tools/manifest.mjs +34 -15
- package/agent-tools/read-history.mjs +115 -14
- package/agent-tools/review-facts.mjs +40 -15
- package/agent-tools/settings.mjs +23 -2
- package/agent-tools/spawn-gates.mjs +19 -22
- package/agent-tools/ssh-session.mjs +120 -111
- package/agent-tools/ssh-text.mjs +155 -0
- package/agent-tools/ssh-transfer.mjs +210 -0
- package/agent-tools/ssh-transport.mjs +183 -81
- package/agent-tools/subagent-actions-query.mjs +11 -7
- package/agent-tools/subagent-actions.mjs +1 -1
- package/agent-tools/subagent-async.mjs +11 -11
- package/agent-tools/subagent-brief.mjs +76 -0
- package/agent-tools/subagent-design-token.mjs +168 -0
- package/agent-tools/subagent-run.mjs +1 -1
- package/agent-tools/subagent-scheduler.mjs +45 -11
- package/agent-tools/subagent-spawn.mjs +143 -104
- package/agent-tools/subagent.mjs +26 -23
- package/agent-tools/taskbook-block.mjs +94 -0
- package/agent-tools/timer.mjs +12 -8
- package/agent-tools/verify.mjs +13 -4
- package/agent-tools.mjs +7 -3
- package/agent.mjs +20 -1
- package/attachments.mjs +3 -3
- package/browser/actions.mjs +9 -3
- package/browser/cdp.mjs +45 -17
- package/browser/launch.mjs +25 -43
- package/browser/pool.mjs +299 -0
- package/browser/queue.mjs +2 -0
- package/browser/session-state.mjs +450 -0
- package/browser/session.mjs +127 -151
- package/browser/snapshot.mjs +89 -0
- package/client-identity.mjs +22 -6
- package/config-defaults.mjs +2 -1
- package/config-migrate.mjs +40 -0
- package/config-normalize.mjs +28 -2
- package/config-presets.mjs +5 -3
- package/config-reload.mjs +59 -0
- package/config.mjs +62 -98
- package/context-degrade.mjs +38 -10
- package/context-echo.mjs +11 -0
- package/context.mjs +165 -68
- package/conventions.mjs +11 -9
- package/declaration.mjs +33 -7
- package/declared-repos.mjs +94 -0
- package/doc-check/doc-names.mjs +73 -0
- package/doc-check/doc-tokens.mjs +110 -0
- package/doc-check/existence.mjs +160 -0
- package/doc-check/index.mjs +312 -163
- package/doc-check/line-refs.mjs +38 -0
- package/doc-check/paragraph.mjs +220 -91
- package/doc-graph/anchors.mjs +474 -0
- package/doc-graph/doc-batch-face.mjs +59 -0
- package/doc-graph/doc-suffix.mjs +27 -0
- package/doc-graph/graph-tokens.mjs +160 -0
- package/doc-graph.mjs +778 -0
- package/explore-distill.mjs +12 -6
- package/i18n.mjs +2 -2
- package/index-discover.mjs +4 -1
- package/instance-inbox-watch.mjs +272 -0
- package/instance-inbox.mjs +218 -0
- package/instance-registry.mjs +179 -0
- package/knowledge/README.md +3 -0
- package/knowledge/prompt-resources.md +6 -0
- package/ledger-close-proof.mjs +95 -62
- package/ledger-close.mjs +188 -0
- package/ledger-cmd.mjs +76 -244
- package/ledger-consistency.mjs +113 -0
- package/ledger-db.mjs +70 -37
- package/ledger-executors.mjs +1 -1
- package/ledger-migrate.mjs +4 -4
- package/ledger-read.mjs +10 -8
- package/ledger-surface.mjs +1 -1
- package/ledger-tools.mjs +83 -24
- package/ledger-variant-notice.mjs +1 -1
- package/ledger-write-ops.mjs +462 -0
- package/ledger.mjs +2 -2
- package/manifest-discovery.mjs +5 -3
- package/manifest-schema.mjs +28 -2
- package/memory/memory-tool.mjs +5 -2
- package/memory/schema.mjs +6 -27
- package/package.json +3 -1
- package/path-resolve.mjs +498 -0
- package/permission.mjs +4 -0
- package/prompt-files.mjs +91 -1
- package/prompt-overlays.mjs +14 -6
- package/prompts/advisor-design.md +66 -22
- package/prompts/advisor-round1.md +37 -3
- package/prompts/advisor-round2.md +44 -10
- package/prompts/advisor-round3.md +43 -9
- package/prompts/common.md +15 -375
- package/prompts/consult-base.md +6 -1
- package/prompts/discipline-engineering.md +251 -95
- package/prompts/discipline-normal.md +4 -250
- package/prompts/knowledge/business-gates.md +22 -0
- package/prompts/knowledge/decision-quality.md +23 -0
- package/prompts/knowledge/doc-lookup.md +35 -0
- package/prompts/knowledge/document-writing.md +51 -0
- package/prompts/knowledge/documentation-evaluation.md +56 -0
- package/prompts/knowledge/evidence-discipline.md +57 -0
- package/prompts/knowledge/normal-coding-workflow.md +104 -0
- package/prompts/knowledge/normal-delivery-collaboration.md +108 -0
- package/prompts/knowledge/normal-work-management.md +57 -0
- package/prompts/knowledge/product-security.md +23 -0
- package/prompts/knowledge/project-records.md +62 -0
- package/prompts/knowledge/tool-advisor.md +29 -0
- package/prompts/knowledge/tool-apply-patch.md +18 -0
- package/prompts/knowledge/tool-bash.md +39 -0
- package/prompts/knowledge/tool-batch-eng-coder.md +12 -0
- package/prompts/knowledge/tool-batch-eng-designer.md +12 -0
- package/prompts/knowledge/tool-batch-review.md +12 -0
- package/prompts/knowledge/tool-batch.md +80 -0
- package/prompts/knowledge/tool-browser.md +57 -0
- package/prompts/knowledge/tool-code-search.md +4 -0
- package/prompts/knowledge/tool-consult-start.md +12 -0
- package/prompts/knowledge/tool-consult-stop.md +6 -0
- package/prompts/knowledge/tool-context.md +6 -0
- package/prompts/knowledge/tool-delete.md +17 -0
- package/prompts/knowledge/tool-doc-check.md +70 -0
- package/prompts/knowledge/tool-doc-graph-read.md +20 -0
- package/prompts/knowledge/tool-doc-graph.md +49 -0
- package/prompts/knowledge/tool-doc-search.md +6 -0
- package/prompts/knowledge/tool-edit.md +38 -0
- package/prompts/knowledge/tool-eng.md +2 -0
- package/prompts/knowledge/tool-execute.md +16 -0
- package/prompts/knowledge/tool-fetch.md +12 -0
- package/prompts/knowledge/tool-file-ops.md +16 -0
- package/prompts/knowledge/tool-get-current-time.md +7 -0
- package/prompts/knowledge/tool-git-read.md +19 -0
- package/prompts/knowledge/tool-git.md +29 -0
- package/prompts/knowledge/tool-glob.md +15 -0
- package/prompts/knowledge/tool-goal.md +8 -0
- package/prompts/knowledge/tool-grep.md +18 -0
- package/prompts/knowledge/tool-hashline-edit.md +14 -0
- package/prompts/knowledge/tool-insert-after.md +15 -0
- package/prompts/knowledge/tool-instance-list.md +6 -0
- package/prompts/knowledge/tool-instance-send.md +10 -0
- package/prompts/knowledge/tool-knowledge.md +18 -0
- package/prompts/knowledge/tool-ledger-read.md +35 -0
- package/prompts/knowledge/tool-ledger.md +42 -0
- package/prompts/knowledge/tool-lint.md +16 -0
- package/prompts/knowledge/tool-ls.md +13 -0
- package/prompts/knowledge/tool-lsp.md +11 -0
- package/prompts/knowledge/tool-main-history.md +2 -0
- package/prompts/knowledge/tool-manifest-read.md +14 -0
- package/prompts/knowledge/tool-manifest.md +31 -0
- package/prompts/knowledge/tool-memory-read.md +20 -0
- package/prompts/knowledge/tool-memory.md +15 -0
- package/prompts/knowledge/tool-notify-parent.md +12 -0
- package/prompts/knowledge/tool-operations.md +114 -0
- package/prompts/knowledge/tool-peer-instances.md +2 -0
- package/prompts/knowledge/tool-plan.md +6 -0
- package/prompts/knowledge/tool-process-read.md +13 -0
- package/prompts/knowledge/tool-process.md +15 -0
- package/prompts/knowledge/tool-question.md +16 -0
- package/prompts/knowledge/tool-read-history-batch.md +22 -0
- package/prompts/knowledge/tool-read-history.md +36 -0
- package/prompts/knowledge/tool-read-image.md +11 -0
- package/prompts/knowledge/tool-read.md +21 -0
- package/prompts/knowledge/tool-recent-changes.md +6 -0
- package/prompts/knowledge/tool-repo-outline.md +4 -0
- package/prompts/knowledge/tool-settings-read.md +12 -0
- package/prompts/knowledge/tool-settings.md +18 -0
- package/prompts/knowledge/tool-skill.md +6 -0
- package/prompts/knowledge/tool-ssh.md +52 -0
- package/prompts/knowledge/tool-subagent.md +59 -0
- package/prompts/knowledge/tool-task.md +12 -0
- package/prompts/knowledge/tool-team-ledger-read.md +11 -0
- package/prompts/knowledge/tool-team-ledger.md +11 -0
- package/prompts/knowledge/tool-timer.md +23 -0
- package/prompts/knowledge/tool-tree.md +14 -0
- package/prompts/knowledge/tool-verify.md +19 -0
- package/prompts/knowledge/tool-wait-for.md +25 -0
- package/prompts/knowledge/tool-websearch.md +19 -0
- package/prompts/knowledge/tool-write.md +9 -0
- package/prompts/knowledge/upstream-protocol.md +43 -0
- package/prompts/persona-eng-coder.md +29 -3
- package/prompts/persona-eng-designer.md +131 -159
- package/prompts/persona-engineering.md +202 -131
- package/prompts/persona-explore.md +1 -1
- package/prompts/persona-plan.md +6 -1
- package/prompts/persona-tester.md +55 -0
- package/prompts/subagent-base.md +2 -0
- package/provider/anthropic.mjs +6 -4
- package/provider/core.mjs +5 -4
- package/provider/errors.mjs +29 -4
- package/provider/google.mjs +39 -12
- package/provider/rate.mjs +11 -3
- package/provider/responses.mjs +3 -1
- package/provider/sse.mjs +15 -4
- package/provider-flows.mjs +2 -2
- package/session-identity.mjs +21 -0
- package/session-index-build.mjs +1 -1
- package/session-index-pass.mjs +1 -1
- package/session-index-query.mjs +1 -1
- package/session-index.mjs +1 -1
- package/session-lifecycle.mjs +79 -19
- package/session-slot-write.mjs +37 -5
- package/session-slots.mjs +9 -14
- package/session.mjs +29 -8
- package/skip-dirs.mjs +48 -0
- package/team-ledger.mjs +17 -13
- package/text-budget.mjs +4 -0
- package/token-ttl.mjs +73 -4
- package/token-window.mjs +244 -34
- package/tool-docs/advisor.md +2 -27
- package/tool-docs/apply_patch.md +1 -13
- package/tool-docs/bash.md +2 -37
- package/tool-docs/batch-eng-coder.md +3 -0
- package/tool-docs/batch-eng-designer.md +3 -0
- package/tool-docs/batch-review.md +3 -0
- package/tool-docs/batch.md +3 -1
- package/tool-docs/browser.md +2 -47
- package/tool-docs/code_search.md +3 -1
- package/tool-docs/consult_start.md +2 -4
- package/tool-docs/consult_stop.md +2 -2
- package/tool-docs/context.md +1 -5
- package/tool-docs/delete.md +2 -14
- package/tool-docs/doc_check.md +2 -72
- package/tool-docs/doc_graph-read.md +3 -0
- package/tool-docs/doc_graph.md +3 -0
- package/tool-docs/doc_search.md +3 -1
- package/tool-docs/edit.md +2 -18
- package/tool-docs/eng.md +3 -1
- package/tool-docs/execute.md +2 -12
- package/tool-docs/fetch.md +2 -12
- package/tool-docs/file_ops.md +2 -16
- package/tool-docs/get_current_time.md +1 -6
- package/tool-docs/git-read.md +3 -0
- package/tool-docs/git.md +2 -27
- package/tool-docs/glob.md +2 -10
- package/tool-docs/goal.md +2 -5
- package/tool-docs/grep.md +2 -18
- package/tool-docs/hashline_edit.md +2 -13
- package/tool-docs/insert_after.md +2 -14
- package/tool-docs/instance_list.md +3 -0
- package/tool-docs/instance_send.md +3 -0
- package/tool-docs/knowledge.md +3 -0
- package/tool-docs/ledger-read.md +3 -0
- package/tool-docs/ledger.md +3 -8
- package/tool-docs/lint.md +2 -9
- package/tool-docs/ls.md +2 -11
- package/tool-docs/lsp.md +2 -9
- package/tool-docs/main_history.md +3 -1
- package/tool-docs/manifest-read.md +2 -7
- package/tool-docs/manifest.md +2 -28
- package/tool-docs/memory-read.md +3 -0
- package/tool-docs/memory.md +3 -11
- package/tool-docs/notify_parent.md +2 -13
- package/tool-docs/peer_instances.md +3 -1
- package/tool-docs/plan.md +2 -4
- package/tool-docs/process-read.md +3 -0
- package/tool-docs/process.md +2 -13
- package/tool-docs/question.md +3 -17
- package/tool-docs/read.md +2 -19
- package/tool-docs/read_history-batch.md +3 -0
- package/tool-docs/read_history.md +2 -6
- package/tool-docs/read_image.md +2 -7
- package/tool-docs/recent_changes.md +3 -1
- package/tool-docs/repo_outline.md +3 -1
- package/tool-docs/settings-read.md +3 -0
- package/tool-docs/settings.md +2 -5
- package/tool-docs/skill.md +3 -5
- package/tool-docs/ssh.md +2 -50
- package/tool-docs/subagent.md +2 -63
- package/tool-docs/task.md +2 -6
- package/tool-docs/team_ledger-read.md +3 -0
- package/tool-docs/team_ledger.md +3 -9
- package/tool-docs/timer.md +3 -13
- package/tool-docs/tree.md +2 -13
- package/tool-docs/verify.md +3 -1
- package/tool-docs/wait_for.md +2 -32
- package/tool-docs/websearch.md +2 -17
- package/tool-docs/write.md +2 -10
- package/tools/bash.mjs +12 -2
- package/tools/browser.mjs +52 -7
- package/tools/doc-write-gate.mjs +73 -0
- package/tools/edit-batch.mjs +176 -91
- package/tools/edit-diff.mjs +129 -45
- package/tools/edit-receipt.mjs +39 -0
- package/tools/execute.mjs +11 -5
- package/tools/file.mjs +32 -34
- package/tools/git.mjs +43 -2
- package/tools/index.mjs +6 -0
- package/tools/knowledge.mjs +143 -0
- package/tools/linter.mjs +3 -3
- package/tools/ops.mjs +4 -1
- package/tools/patch.mjs +127 -38
- package/tools/process-doc-mark.mjs +139 -0
- package/tools/search.mjs +15 -6
- package/tools/shared.mjs +31 -7
- package/tools/ssh.mjs +48 -7
- package/tools/tree.mjs +4 -1
- package/tools/write-gate-params.mjs +31 -0
- package/tools/write-path.mjs +79 -6
- package/traces/trace-store.mjs +4 -3
- package/window-policy.mjs +203 -0
- package/agent/light-round.mjs +0 -63
- package/agent/unbooked-pen.mjs +0 -62
- package/doc-check/anchors.mjs +0 -135
package/agent-tools/batch.mjs
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* agent-tools/batch.mjs — 批次档生命周期工具(KD-4
|
|
3
|
-
*
|
|
2
|
+
* agent-tools/batch.mjs — 批次档生命周期工具(KD-4 拆分主档:**action 分发 + schema + 路径解析面 +
|
|
3
|
+
* 评审实例绑定 + #84 记账缝**)。
|
|
4
4
|
*
|
|
5
|
-
* 单工具 `batch`,action = create(建档,§4.11)/ append
|
|
6
|
-
*
|
|
5
|
+
* 单工具 `batch`,action = create(建档,§4.11)/ attach(给现役档补挂台账行,§4.21.3)/ append(段写入)/ edit
|
|
6
|
+
* (段内就地改,§4.19)/ status(段属主状态行流转,§4.12)/ close(收口冻结,§4.13)/ supersede
|
|
7
|
+
* (被取代的收口,§4.18-D——对象已消失、永不实施、且能点名取代者的批档)。写入面**按段分权、不按段分处置**:
|
|
8
|
+
* 六段各自只有一个作者,作者对本段可 append 加内容 ∥ edit 就地改既有行(§4.19);状态行只有一个写者(status)。
|
|
7
9
|
* 权威规格 = `docs/core/design/BATCH-RECORD.md` §4(契约/挂载/用例 §4.8/骨架 §4.10/
|
|
8
|
-
* 参数面 §4.11–§4.13
|
|
9
|
-
*
|
|
10
|
+
* 参数面 §4.11–§4.13 · §4.21)。
|
|
11
|
+
*
|
|
12
|
+
* 2026-11-05 拆档族把**段写入执行面**(append ∥ edit 的执行体、共用助手与八条拒串)搬进
|
|
13
|
+
* `batch-record-write.mjs`——本档只留模型可见的 schema 与分发(改 schema 不该翻过 300 行执行体)。
|
|
14
|
+
* 其余依赖单向:`batch-segment-vocab ← batch-skeleton ← …(gate ∥ closeout ∥ reopen ∥ lifecycle ∥
|
|
15
|
+
* record-write)← 本档`。
|
|
10
16
|
*
|
|
11
17
|
* 身份判据(D-BR17/D-BR18/D-BR21):主 agent 调用 ctx 带 `depth === 0`(dispatch 装配);
|
|
12
18
|
* eng 子代理 `depth > 0`(`agent._role` 定段);评审实例 ctx 无 depth 但工具以 `review: true`
|
|
13
|
-
* 绑定。create/close 仅 depth-0 放行;depth-0 的 append/status/close 可选 `path`(D-BR21:
|
|
19
|
+
* 绑定。create/close/attach 仅 depth-0 放行;depth-0 的 append/status/close/attach 可选 `path`(D-BR21:
|
|
14
20
|
* 缺省 = findInFlightBatch 取唯一在飞批,0/复数 ⇒ throw);子代理/评审传 path ⇒ 拒(目标 =
|
|
15
21
|
* spawn/实例注入,语法上写不到别处——运行期门拒)。append 段白名单(**模式感知**——§4.16):
|
|
16
|
-
* depth-0 → 工程 §1/§4/§6 ∥ 普通 §1/§2/§4/§5/§6 · eng-designer → §2 · 评审 → §3
|
|
22
|
+
* depth-0 → 工程 §1/§4/§6 ∥ 普通 §1/§2/§4/§5/§6 · eng-designer → §2 · 评审 → §3(**工程设计轨除外**——那一路的
|
|
23
|
+
* `§3` 只由结算写,§4.4)· eng-coder → §5 ·
|
|
17
24
|
* coder(普通模式分支增表——SEGMENT_BY_ROLE_NORMAL)→ §5;status 写域 = 调用者自己段(模式感知
|
|
18
|
-
* ——见 batch-lifecycle.mjs
|
|
19
|
-
*
|
|
25
|
+
* ——见 batch-lifecycle.mjs)。**edit 的段域 = 同模式 append 白名单**(§4.19「段域」行——一张表两
|
|
26
|
+
* 个动作,不另立第二张):能 append 哪段就 edit 哪段,两动作只差写法(段尾加内容 ∥ 段内改既有字)。
|
|
27
|
+
* append 迁移面错误串**逐字保持
|
|
28
|
+
* "batch_segment:" 前缀**(§4.1 全表锚断言);"batch:" 前缀 = 新增错误面(create/close/status/
|
|
29
|
+
* edit 锚判据/findInFlight/path 门/dispatch)。
|
|
20
30
|
*
|
|
21
|
-
*
|
|
22
|
-
* `configureBatchSegment` / `resetBatchSegment`(#84
|
|
23
|
-
* `MAX_TEXT_CHARS`
|
|
31
|
+
* 导出面(名与形逐字不变——2026-11-05 拆档族后仍由本档出):`batchTool`(主名)· `resolveBatchDocPath` ·
|
|
32
|
+
* `batchDocBases` · `batchDocForReview` · `configureBatchSegment` / `resetBatchSegment`(#84 记账缝——
|
|
33
|
+
* 契约名不变,AC-11 零改)· `MAX_TEXT_CHARS`(经 `batch-record-write.mjs` re-export)· `SEGMENT_BY_ROLE`。
|
|
24
34
|
*
|
|
25
35
|
* #84 记账面(CORE-UNIFICATION §2.13.4):写入成功后的记账**按端注入**——核内缺省 no-op = CLI
|
|
26
36
|
* 语义零行为变;端装配经 `configureBatchSegment({ onWrite })` 覆盖(VSC 侧现形 = `_touchedFiles`
|
|
27
|
-
* 记账)。核内零端名分支(契约 5——只认 `onWrite`
|
|
37
|
+
* 记账)。核内零端名分支(契约 5——只认 `onWrite` 函数名)。**缝住本档**:它唯一的读者是下面
|
|
38
|
+
* `batchTool.execute`(取值后经 `onWritten` 形参递给五条 action)——缝与读者同档,执行体侧只收形参。
|
|
28
39
|
*/
|
|
29
|
-
import { readFileSync, writeFileSync } from "node:fs"
|
|
30
|
-
|
|
31
40
|
// 描述面 = `tool-docs/batch.md`(#15 描述外置统一——工厂形描述经 DESC 单一解析面,工厂调用期取值)
|
|
32
41
|
import { DESC } from "../tools/shared.mjs"
|
|
33
|
-
import { SEGMENT_BY_ROLE
|
|
42
|
+
import { SEGMENT_BY_ROLE } from "./batch-skeleton.mjs"
|
|
34
43
|
import { batchDocBases, resolveBatchDocPath } from "./batch-paths.mjs"
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
44
|
+
import { createBatchRecord, attachBatchRecord } from "./batch-ledger-bind.mjs"
|
|
45
|
+
import { checkBatchRecord, closeBatchRecord, findInFlightBatch, statusBatchRecord } from "./batch-lifecycle.mjs"
|
|
46
|
+
import { supersedeBatchRecord } from "./batch-supersede.mjs"
|
|
47
|
+
import { appendBatchRecord, editBatchRecord } from "./batch-record-write.mjs"
|
|
37
48
|
|
|
38
49
|
export { SEGMENT_BY_ROLE, batchDocBases, resolveBatchDocPath }
|
|
39
|
-
|
|
40
|
-
/** text 单次上限(BATCH-RECORD.md §4.1——超出引导分段追加,不承诺"不新盖戳")。append 迁移域私有区常量
|
|
41
|
-
* (随执行体自 batch-segment.mjs 迁入——骨架档只住骨架/状态行单源,lifecycle 档头枚举口径)。 */
|
|
42
|
-
export const MAX_TEXT_CHARS = 20000
|
|
43
|
-
/** 工具写入的轮次节标题形态(N 计数口径 = 该形态行;`### 轮次与发现(…)` 骨架行不匹配)。 */
|
|
44
|
-
const ROUND_HEADING_RE = /^### 轮次 \d+(评审子代理)/
|
|
45
|
-
/** 凭证形态(`BATCH-RECORD.md` §4.1——三形):`[DESIGN-TOKEN:…]` 闭括号形 ∥ `designId: …` 键形 ∥ 无标两段
|
|
46
|
-
* token 值形 `⟨uuid⟩:⟨epoch⟩`(与单源 `design-token.mjs` 判据对表);裸 uuid 非凭证不剥(KD-7)。两字面勿
|
|
47
|
-
* 合并:`CRED_RE` 走 `.replace()` 须 `/g` ∥ `CRED_TEST_RE` 逐行 `.test()` 须非 `/g`(lastIndex 有状态会漏剥)。 */
|
|
48
|
-
const CRED_RE = /\[DESIGN-TOKEN:[^\]]*\]|designId\s*:\s*\S+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:\d{10,16}/g
|
|
49
|
-
const CRED_TEST_RE = /\[DESIGN-TOKEN:[^\]]*\]|designId\s*:\s*\S+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:\d{10,16}/
|
|
50
|
+
export { MAX_TEXT_CHARS } from "./batch-record-write.mjs"
|
|
50
51
|
|
|
51
52
|
// ─── #84 记账面注入缝(「记账面按端注入」,形态参 §2.13.5 注入缝)───────────────
|
|
52
53
|
/**
|
|
@@ -70,247 +71,174 @@ export function resetBatchSegment() { injectedOnWrite = null }
|
|
|
70
71
|
*/
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* 评审侧批次档绑定解析(BATCH-RECORD.md §4.2/§4.3——评审实例的唯一路径来源):
|
|
75
|
+
* 单源 = 调用方把**本笔**绑定显式放进 callbacks(**带 batchDoc 键**,未绑定即 null)——
|
|
76
|
+
* 同步路径来自 advisor 工具,异步路径来自池条目的 `entry.start()`(条目持发起时点的快照)。
|
|
77
|
+
* 缺键 ⇒ null(fail-closed)。
|
|
78
|
+
* 池扫兜底已退役:按文档集去池里认条目是同一判据的第二份、且更弱的表述(只认设计轨);
|
|
79
|
+
* 代码轨 `documents` 为 null ⇒ `[]` 会匹配到无 documents 的条目,等于另开一个错档入口。
|
|
80
|
+
* `agent` / `documents` 形参保留为签名兼容(调用方按位置传参),本函数不再消费。
|
|
77
81
|
*/
|
|
78
82
|
export function batchDocForReview(agent, documents, callbacks = null) {
|
|
79
83
|
if (callbacks && "batchDoc" in callbacks) return callbacks.batchDoc ?? null
|
|
80
|
-
const key = JSON.stringify([...(documents ?? [])].sort())
|
|
81
|
-
for (const e of agent?._asyncAdvisors?.values?.() ?? []) {
|
|
82
|
-
if (e.status === "running" && e.reviewType === "design" && JSON.stringify([...(e.documents ?? [])].sort()) === key) {
|
|
83
|
-
return e.run?.batchDoc ?? null
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
84
|
return null
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
// ─── append 迁移面(原 batch-segment.mjs :129-184 私有区——逐字迁移,错误串逐字保序)───
|
|
90
|
-
|
|
91
|
-
/** 段号解析:`§2` / `2` / `§2 批次任务` 均可;无法解析 → null。 */
|
|
92
|
-
function segmentNumber(raw) {
|
|
93
|
-
const m = /^§?\s*(\d+)/.exec(String(raw ?? "").trim())
|
|
94
|
-
return m ? Number(m[1]) : null
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** 身份 → 可写段号;无写权身份 → null。评审实例绑定优先(评审者的身份即"设计评审"。)
|
|
98
|
-
* depth-0 的段白名单(append——模式感知,§4.16)由 appendBatchRecord 分支,不经本表;
|
|
99
|
-
* 普通模式分支额外合并 coder 增表(`SEGMENT_BY_ROLE_NORMAL`——**合并查只在普通模式分支**)。 */
|
|
100
|
-
function allowedSegment(agent, review, engineering) {
|
|
101
|
-
if (review) return 3
|
|
102
|
-
const role = agent?._role
|
|
103
|
-
return SEGMENT_BY_ROLE[role] ?? (engineering ? null : SEGMENT_BY_ROLE_NORMAL[role]) ?? null
|
|
104
|
-
}
|
|
105
|
-
|
|
106
87
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* `
|
|
110
|
-
* 工具生成才是唯一来源戳(否则伪造戳会污染 N 计数)。
|
|
88
|
+
* 身份 profile(TOOLS.md §6.29 ②):depth-0 = 全量六动作;子代理与评审 = 自己那一段的
|
|
89
|
+
* append / edit / status(段域仍由既有身份白名单裁决,本档只裁**动作面与参数面**)。
|
|
90
|
+
* 描述取各自一份档——全量档 `batch.md` 通篇讲六个动作,子代理读到它就是读到做不到的事(B6)。
|
|
111
91
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
function roundCount(src, headerMatch, endIdx) {
|
|
125
|
-
const body = src.slice(headerMatch.index + headerMatch[0].length, endIdx)
|
|
126
|
-
return body.split("\n").filter((l) => ROUND_HEADING_RE.test(l)).length
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** 段尾定位 + 插入(append-only:只在段尾插入,既有字节不变;返回新全文 + 本轮 N)。 */
|
|
130
|
-
function insertIntoSection(src, seg, text) {
|
|
131
|
-
const hdr = sectionHeaderRe(seg).exec(src)
|
|
132
|
-
if (!hdr) {
|
|
133
|
-
throw new Error(`batch_segment: the bound batch record has no "## §${seg}" section header — the six-section skeleton is written by the record's creator before any segment write. Fix: ask the parent/creator to add the "## §${seg} …" heading (with the template's sub-headings) first, then call batch_segment again. Nothing was written.`)
|
|
92
|
+
const PROFILE_ACTIONS = ["append", "edit", "status"]
|
|
93
|
+
const PROFILE_SEGMENTS = { "eng-designer": 2, "eng-coder": 5, coder: 5, review: 3 }
|
|
94
|
+
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
|
+
const PROFILE_PROPS = ["segment", "text", "oldText", "newText", "value", "note"]
|
|
97
|
+
/** profile 面的 `segment` 参数(只点名自己那段——全量档那句把六个身份的白名单一起列出来,
|
|
98
|
+
* 子代理读到的是别的身份的写域)。 */
|
|
99
|
+
function profileSegmentProp(profileKey) {
|
|
100
|
+
const seg = PROFILE_SEGMENTS[profileKey]
|
|
101
|
+
return {
|
|
102
|
+
type: "string",
|
|
103
|
+
description: `append/edit/status only — the batch-record section you are writing: §${seg} is your pen on this record (e.g. "§${seg}"). Declares the section number only; the identity bound to this spawn decides what is actually writable.`,
|
|
134
104
|
}
|
|
135
|
-
const nextRe = /^## §\d/gm
|
|
136
|
-
nextRe.lastIndex = hdr.index + hdr[0].length
|
|
137
|
-
const next = nextRe.exec(src)
|
|
138
|
-
const endIdx = next ? next.index : src.length
|
|
139
|
-
// 来源戳(仅 §3):工具生成标题 + N——调用方写不进自己的标题(sanitize 已丢弃同名行)。
|
|
140
|
-
const roundN = seg === 3 ? roundCount(src, hdr, endIdx) + 1 : 0
|
|
141
|
-
const payload = (seg === 3 ? `### 轮次 ${roundN}(评审子代理)\n\n` : "") + text
|
|
142
|
-
const before = src.slice(0, endIdx)
|
|
143
|
-
const after = src.slice(endIdx)
|
|
144
|
-
const eol = src.includes("\r\n") ? "\r\n" : "\n"
|
|
145
|
-
const lead = before === "" ? "" : before.endsWith(eol + eol) ? "" : before.endsWith(eol) ? eol : eol + eol
|
|
146
|
-
// 尾随 eol 恒加(块自成行);后面还有段标题时再补一个空行(保持模板的空行分隔)。
|
|
147
|
-
const written = before + lead + payload.replaceAll("\n", eol) + eol + (after === "" ? "" : eol) + after
|
|
148
|
-
return { written, roundN }
|
|
149
105
|
}
|
|
150
106
|
|
|
151
|
-
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
107
|
+
/** 全量参数面(depth-0 六动作):schema 单源——profile 面从它取所需格,见 `PROFILE_PROPS`。 */
|
|
108
|
+
function fullParameters() {
|
|
109
|
+
return {
|
|
110
|
+
type: "object",
|
|
111
|
+
properties: {
|
|
112
|
+
action: {
|
|
113
|
+
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 条件 (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).",
|
|
116
|
+
},
|
|
117
|
+
path: {
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "depth-0 only (D-BR21) — the batch record to operate on (若传则须可读). 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
|
+
},
|
|
121
|
+
segment: {
|
|
122
|
+
type: "string",
|
|
123
|
+
description: "append/edit/status only — the batch-record section you are writing (e.g. \"§4\"). Declares the section number only; 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.",
|
|
124
|
+
},
|
|
125
|
+
text: {
|
|
126
|
+
type: "string",
|
|
127
|
+
description: "append only — the markdown to append (for a design review §3: the round's conclusion table — one row per finding, its evidence a pointer — plus the VERDICT line and the counts; the report's own text stays out). Limit 20000 characters per call; longer content is refused — split it into multiple calls (each call becomes its own section, N continues). A line that STARTS with the status-line form (`**状态行**:…`) is refused — that line has one writer (`status`); quote it with a leading `> ` instead, or write it as prose.",
|
|
128
|
+
},
|
|
129
|
+
oldText: {
|
|
130
|
+
type: "string",
|
|
131
|
+
description: "edit only — oldText must match exactly once, byte for byte (line endings included), inside the section body; newText replaces that range, and an empty newText deletes it. Refused with nothing written: a blank oldText, zero hits, two or more hits (the matching lines are named), an anchor crossing the section boundary, an anchor touching the section's PROTECTED status line (the first `**状态行**:` line of its header zone — one writer: `status`; deleting a status line elsewhere, e.g. a surplus copy, is allowed), any replacement that introduces a `**状态行**:` line, and any edit that would leave MORE status lines in the header zone than before.",
|
|
132
|
+
},
|
|
133
|
+
newText: {
|
|
134
|
+
type: "string",
|
|
135
|
+
description: "edit only — the replacement text for the anchored range; an empty string deletes the range. Limit 20000 characters per call (same cap as append); longer is refused — split it into several edits of one anchored range each. Credentials are stripped mechanically (same as append); a `## §N` heading line is refused (skeleton protection), and on §3 a `### 轮次 N(评审子代理)` line is dropped (the round stamp is tool-generated only).",
|
|
136
|
+
},
|
|
137
|
+
value: {
|
|
138
|
+
type: "string",
|
|
139
|
+
description: "status only — the new status-line value (single line; exactly one legal keyword of your section's STATUS_WORDS entry: §1 进行中/已收口 · §2 设计完成 · §3 评审通过 · §5 实施完成 — plus decoration only: surrounding symbols / a trailing ISO date / whitespace; prose goes to `note`).",
|
|
140
|
+
},
|
|
141
|
+
note: {
|
|
142
|
+
type: "string",
|
|
143
|
+
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
|
+
},
|
|
145
|
+
completed: {
|
|
146
|
+
type: "array",
|
|
147
|
+
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 条件 (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
|
+
},
|
|
150
|
+
supersededBy: {
|
|
151
|
+
type: "string",
|
|
152
|
+
description: "supersede only — REQUIRED: who replaced this record. Three forms, each machine-checked: a batch record path (docs/batches/<x>.md, must be on disk) / a document plus a section (docs/<area>/<name>.md §<N>, the section number must hit a heading line) / a commit (40 hex, must be reachable in the version store). A planned or never-done successor does not resolve and is refused — the machine never invents this fact. It lands verbatim in the §1 supersede record line and in the receipt.",
|
|
153
|
+
},
|
|
154
|
+
closeEvidence: {
|
|
155
|
+
type: "string",
|
|
156
|
+
description: "close / supersede / status writing §1 已收口 — REQUIRED on all three: one line of work evidence for this closeout (what this batch actually did). It is written into every settled row's evidence with a `收口 <YYYY-MM-DD>:` prefix, so human evidence and the closeout evidence stay distinguishable on the row. Blank (missing / empty / whitespace) is refused before anything is written — the machine never invents this line, because a machine-written sentence turns the close-proof gate into decoration.",
|
|
157
|
+
},
|
|
158
|
+
topic: {
|
|
159
|
+
type: "string",
|
|
160
|
+
description: "create only — the batch subject word shared by the record header (keep the file name aligned with it).",
|
|
161
|
+
},
|
|
162
|
+
source: {
|
|
163
|
+
type: "string",
|
|
164
|
+
description: "create only — REQUIRED: the record's origin line (来源 = …; single line). It fills the header's 编制 line; without it the skeleton's placeholder would block the record's first append/status (topic-style fail-closed). Nothing is written when it is missing.",
|
|
165
|
+
},
|
|
166
|
+
ledger: {
|
|
167
|
+
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 归批; 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
|
+
},
|
|
170
|
+
newDebt: {
|
|
171
|
+
type: "string",
|
|
172
|
+
description: "create / attach — optional: one line saying why this is a NEW debt rather than one of the unsettled rows already on the same face (board). Required only when you omit ledger while that face has unsettled rows; the reason lands in the new row's evidence and is quoted in this record's closeout receipt. Omit both ledger and newDebt while unsettled rows exist ⇒ refused with the candidate list.",
|
|
173
|
+
},
|
|
174
|
+
board: {
|
|
175
|
+
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 括注 (未给 ⇒ 「—」); attach never rewrites the parenthesis group — it only appends to the number list.",
|
|
177
|
+
},
|
|
178
|
+
title: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "attach only — REQUIRED when attach opens a new ledger row (not needed when you take one over with ledger): the row's own subject, i.e. what this new piece of work is. It is the same thing as the ledger row's title (one concept, one name); do not reuse the batch's original subject — a reopened record taking on a new debt is not a second copy of the old one.",
|
|
181
|
+
},
|
|
182
|
+
date: {
|
|
183
|
+
type: "string",
|
|
184
|
+
description: "create only — the record date (YYYY-MM-DD); defaults to today.",
|
|
185
|
+
},
|
|
186
|
+
prev: {
|
|
187
|
+
type: "string",
|
|
188
|
+
description: "create only — the predecessor pointer line (前情); a leading `前情 = ` prefix is stripped automatically (idempotent — repeated prefixes included); defaults to 无(独立批).",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
required: ["action"],
|
|
228
192
|
}
|
|
229
|
-
// F11-C(挂点:gate / text 校验后 · insertIntoSection 前):档头结构行死占位残留 ⇒ 拒
|
|
230
|
-
// (段体引用豁免——判据可辨性收正,`TOOLS.md` §6.20;骨架枚举单源 = skeleton 档 TEMPLATE_PLACEHOLDERS)。
|
|
231
|
-
const residues = findPlaceholderResidue(src)
|
|
232
|
-
if (residues.length) throw new Error(placeholderResidueError(residues))
|
|
233
|
-
// 文档机检门(§3.20「结构兜底」①——门位 = 既有拒因全部之后、insertIntoSection / 写盘之前):
|
|
234
|
-
// 只挂子代理写 §2 / §5(depth-0 与评审不检);REFUSED ⇒ throw;PASS ⇒ 照写;ERROR / 门自身异常 ⇒ 写 + 回执明示。
|
|
235
|
-
const gate = !depth0 && !review && (n === 2 || n === 5)
|
|
236
|
-
? runBatchGate({ abs, cwd, agent, scope: "writer" })
|
|
237
|
-
: null
|
|
238
|
-
if (gate?.state === "refused") throw new Error(gateRefusalMessage(gate, "append"))
|
|
239
|
-
const { written, roundN } = insertIntoSection(src, n, body)
|
|
240
|
-
writeFileSync(abs, written)
|
|
241
|
-
// #84:记账面按端注入(缺省 no-op = CLI 语义零行为变——端装配经 configureBatchSegment 覆盖)。
|
|
242
|
-
onWritten?.(agent, abs)
|
|
243
|
-
return `batch_segment: appended ${body.length} characters to §${n} of the batch record${roundN ? ` (### 轮次 ${roundN}(评审子代理))` : ""}.${gateReceiptLine(gate)}`
|
|
244
193
|
}
|
|
245
194
|
|
|
246
195
|
/**
|
|
247
|
-
* 批次档生命周期工具工厂(主名 `batch
|
|
196
|
+
* 批次档生命周期工具工厂(主名 `batch`——**七 action**(+ `check` 只读面):create / attach / append / edit /
|
|
197
|
+
* status / close / supersede)。
|
|
248
198
|
* @param {string|null} batchDoc — 绑定的目标档(spawn:`child._batchDoc`;评审:实例键;
|
|
249
199
|
* depth-0 主 agent 挂载时 = null——目标走 D-BR21 可选 path / 在飞扫描)
|
|
250
|
-
* @param {{review?: boolean}} [opts] —
|
|
200
|
+
* @param {{review?: boolean, role?: string|null, reviewType?: string|null}} [opts] —
|
|
201
|
+
* `review=true` 表示评审实例形态(写 `§3` + 工具盖戳);`role` = 装配面的角色身份
|
|
202
|
+
* (`family-tools.mjs` 传;缺省 = depth-0 全量面);`reviewType` = 本评审实例的**评审轨**
|
|
203
|
+
* (`"design"` ∥ `"code"`)——与模式位一起决定 `§3` 写不写得进去(`BATCH-RECORD.md` §4.3 ∥ §4.4:
|
|
204
|
+
* 工程设计轨收回,代码轨与普通模式保留)。两项缺一即判不出,故这里不给默认值。
|
|
251
205
|
*/
|
|
252
|
-
export function batchTool(batchDoc = null, { review = false } = {}) {
|
|
206
|
+
export function batchTool(batchDoc = null, { review = false, role = null, reviewType } = {}) {
|
|
207
|
+
const profileKey = review ? "review" : (role && PROFILE_DOCS[role] ? role : null)
|
|
208
|
+
const full = fullParameters()
|
|
209
|
+
const profileParameters = profileKey
|
|
210
|
+
? {
|
|
211
|
+
type: "object",
|
|
212
|
+
required: ["action"],
|
|
213
|
+
properties: {
|
|
214
|
+
action: {
|
|
215
|
+
type: "string",
|
|
216
|
+
enum: PROFILE_ACTIONS,
|
|
217
|
+
description: `Which step this face carries: ${PROFILE_ACTIONS.join(" / ")} — append (add text to the END of your section) / edit (replace one anchored range inside it) / status (your section's status line).`,
|
|
218
|
+
},
|
|
219
|
+
...Object.fromEntries(PROFILE_PROPS.map((k) => [k, k === "segment" ? profileSegmentProp(profileKey) : full.properties[k]])),
|
|
220
|
+
},
|
|
221
|
+
}
|
|
222
|
+
: full
|
|
253
223
|
return {
|
|
254
224
|
name: "batch",
|
|
255
|
-
description: DESC("batch"), // 模型可见文本 = tool-docs/batch
|
|
256
|
-
parameters:
|
|
257
|
-
type: "object",
|
|
258
|
-
properties: {
|
|
259
|
-
action: {
|
|
260
|
-
type: "string",
|
|
261
|
-
enum: ["create", "append", "status", "close"],
|
|
262
|
-
description: "Which lifecycle step to run: create (new record) / append (your section) / status (your section's status line) / close (freeze the record).",
|
|
263
|
-
},
|
|
264
|
-
path: {
|
|
265
|
-
type: "string",
|
|
266
|
-
description: "depth-0 only (D-BR21) — the batch record to operate on (若传则须可读). 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.",
|
|
267
|
-
},
|
|
268
|
-
segment: {
|
|
269
|
-
type: "string",
|
|
270
|
-
description: "append/status only — the batch-record section you are writing (e.g. \"§4\"). Declares the section number only; your identity decides what is actually writable (main agent: append §1/§4/§6 · status §1 (engineering) / append §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).",
|
|
271
|
-
},
|
|
272
|
-
text: {
|
|
273
|
-
type: "string",
|
|
274
|
-
description: "append only — the markdown to append (verbatim — findings table + VERDICT + counts for a design review §3). Limit 20000 characters per call; longer content is refused — split it into multiple calls (each call becomes its own section, N continues).",
|
|
275
|
-
},
|
|
276
|
-
value: {
|
|
277
|
-
type: "string",
|
|
278
|
-
description: "status only — the new status-line value (single line; exactly one legal keyword of your section's STATUS_WORDS entry: §1 进行中/已收口 · §2 设计完成 · §3 评审完成 · §5 实施完成 — plus decoration only: surrounding symbols / a trailing ISO date / whitespace; prose goes to `note`).",
|
|
279
|
-
},
|
|
280
|
-
note: {
|
|
281
|
-
type: "string",
|
|
282
|
-
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).",
|
|
283
|
-
},
|
|
284
|
-
topic: {
|
|
285
|
-
type: "string",
|
|
286
|
-
description: "create only — the batch subject word shared by the record header (keep the file name aligned with it).",
|
|
287
|
-
},
|
|
288
|
-
source: {
|
|
289
|
-
type: "string",
|
|
290
|
-
description: "create only — REQUIRED: the record's origin line (来源 = …; single line). It fills the header's 编制 line; without it the skeleton's placeholder would block the record's first append/status (topic-style fail-closed). Nothing is written when it is missing.",
|
|
291
|
-
},
|
|
292
|
-
ledger: {
|
|
293
|
-
type: "string",
|
|
294
|
-
description: "create only — optional: the ledger entry number for the header's 台账 line (e.g. \"#938\"; a leading # is added if missing). Passed together with board, it fills the header at creation; when omitted, the placeholder stays and must be filled by file edit before the record's first append/status.",
|
|
295
|
-
},
|
|
296
|
-
board: {
|
|
297
|
-
type: "string",
|
|
298
|
-
description: "create only — optional: the owning board for the header's 台账 line (e.g. \"core\"). See ledger — both fill the header at creation.",
|
|
299
|
-
},
|
|
300
|
-
date: {
|
|
301
|
-
type: "string",
|
|
302
|
-
description: "create only — the record date (YYYY-MM-DD); defaults to today.",
|
|
303
|
-
},
|
|
304
|
-
prev: {
|
|
305
|
-
type: "string",
|
|
306
|
-
description: "create only — the predecessor pointer line (前情); a leading `前情 = ` prefix is stripped automatically (idempotent — repeated prefixes included); defaults to 无(独立批).",
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
required: ["action"],
|
|
310
|
-
},
|
|
225
|
+
description: profileKey ? DESC(PROFILE_DOCS[profileKey]) : DESC("batch"), // 模型可见文本 = tool-docs/batch*.md
|
|
226
|
+
parameters: profileParameters,
|
|
311
227
|
async execute(args, ctx) {
|
|
228
|
+
// 第二道门(§6.29 ② · B6):schema 的 enum 只是提示,provider 不保证执行它——profile 面
|
|
229
|
+
// 收到本身份执行不了的动作,必须在任何写盘 / 台账事务之前拒,并点名动作与可用集。
|
|
230
|
+
if (profileKey && !PROFILE_ACTIONS.includes(args?.action)) {
|
|
231
|
+
throw new Error(`batch: action ${JSON.stringify(args?.action ?? null)} is not available to this caller — this face carries ${PROFILE_ACTIONS.join(" / ")} only (its own section of the record). Nothing was written.`)
|
|
232
|
+
}
|
|
233
|
+
const closingCall = args?.action === "close" || args?.action === "supersede" || (args?.action === "status" && typeof args?.value === "string" && args.value.includes("已收口"))
|
|
234
|
+
if (args?.completed !== undefined && !closingCall) {
|
|
235
|
+
throw new Error("batch: completed is accepted only by close, by supersede, or by status writing §1 已收口. Nothing was written.")
|
|
236
|
+
}
|
|
237
|
+
if (args?.closeEvidence !== undefined && !closingCall) {
|
|
238
|
+
throw new Error("batch: closeEvidence is accepted only by close, by supersede, or by status writing §1 已收口. Nothing was written.")
|
|
239
|
+
}
|
|
312
240
|
const agent = ctx?.agent ?? {}
|
|
313
|
-
const cwd = agent.cwd
|
|
241
|
+
const cwd = agent.cwd
|
|
314
242
|
const bases = batchDocBases(cwd) // 歧义锚 ⇒ 候选项目基底并集(#828——create / 在飞 / 写门基底集同源)
|
|
315
243
|
const onWritten = injectedOnWrite
|
|
316
244
|
/** depth-0 目标定位(D-BR21):path 传 ⇒ 可读性门;缺省 ⇒ 唯一在飞批(depth-0)/
|
|
@@ -330,15 +258,23 @@ export function batchTool(batchDoc = null, { review = false } = {}) {
|
|
|
330
258
|
switch (args?.action) {
|
|
331
259
|
case "create":
|
|
332
260
|
return createBatchRecord({ args, ctx, review, cwd, bases, onWritten })
|
|
261
|
+
case "attach":
|
|
262
|
+
return attachBatchRecord({ args, ctx, review, cwd, pickTarget, onWritten })
|
|
333
263
|
case "append":
|
|
334
|
-
return appendBatchRecord({ args, ctx, review, batchDoc, onWritten })
|
|
264
|
+
return appendBatchRecord({ args, ctx, review, reviewTrack: reviewType, batchDoc, onWritten })
|
|
265
|
+
case "edit":
|
|
266
|
+
return editBatchRecord({ args, ctx, review, reviewTrack: reviewType, batchDoc, onWritten })
|
|
335
267
|
case "status":
|
|
336
|
-
return statusBatchRecord({ args, ctx, review, pickTarget, onWritten })
|
|
268
|
+
return statusBatchRecord({ args, ctx, review, reviewTrack: reviewType, pickTarget, onWritten })
|
|
337
269
|
case "close":
|
|
338
270
|
return closeBatchRecord({ args, ctx, review, pickTarget, onWritten })
|
|
271
|
+
case "supersede":
|
|
272
|
+
return supersedeBatchRecord({ args, ctx, review, pickTarget, onWritten })
|
|
273
|
+
case "check":
|
|
274
|
+
return checkBatchRecord({ args, ctx, review, pickTarget })
|
|
339
275
|
default:
|
|
340
|
-
throw new Error(`batch: unknown action ${JSON.stringify(args?.action ?? null)} — pass one of create / append / status / close.`)
|
|
276
|
+
throw new Error(`batch: unknown action ${JSON.stringify(args?.action ?? null)} — pass one of create / attach / append / edit / status / close / supersede / check.`)
|
|
341
277
|
}
|
|
342
278
|
},
|
|
343
279
|
}
|
|
344
|
-
}
|
|
280
|
+
}
|
package/agent-tools/consult.mjs
CHANGED
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
* 同族收齐批 · #748; a cancelled session's children emit ⟦ev⟧stopped — R17: the old
|
|
24
24
|
* in-turn check consumption is gone; consumed blocks archive at the consumption window).
|
|
25
25
|
*/
|
|
26
|
-
import { createAgent, runAgent,
|
|
26
|
+
import { createAgent, runAgent, excludeSubagentTools } from "../agent.mjs"
|
|
27
|
+
// B4(TOOLS.md §6.29 ①):会诊席与派单面同一只读派生面(构造器 ∥ 判据各一处单源)。
|
|
28
|
+
import { deriveReadonlyTools } from "../agent/helpers.mjs"
|
|
29
|
+
import { readonlyActionTest } from "../agent/dispatch-gates.mjs"
|
|
27
30
|
import { resolveChildProvider } from "./subagent.mjs"
|
|
28
31
|
import { pushReal } from "../context.mjs"
|
|
29
32
|
import { offloadToolResult, escapeXml } from "../agent/helpers.mjs"
|
|
@@ -273,9 +276,9 @@ async function runConsultChild(ctx, session, id, m, problem, ctrl) {
|
|
|
273
276
|
clampEffort(provider, m.model, m.effort)
|
|
274
277
|
|
|
275
278
|
// Read-only consultant: filter the parent tool set down to readonly tools + main_history.
|
|
276
|
-
|
|
279
|
+
// B4(TOOLS.md §6.29 ①):整把只读集 ∪ action 级只读变体(与 core 派单面同一派生面、同一判据)。
|
|
277
280
|
const tools = [
|
|
278
|
-
...excludeSubagentTools((agent.tools ?? []
|
|
281
|
+
...excludeSubagentTools(deriveReadonlyTools(agent.tools ?? [], readonlyActionTest)), // TOOLS.md §6.16:继承面过谓词
|
|
279
282
|
makeMainHistoryTool(agent),
|
|
280
283
|
]
|
|
281
284
|
|
|
@@ -404,7 +407,7 @@ export const consultStartTool = {
|
|
|
404
407
|
type: "object",
|
|
405
408
|
properties: {
|
|
406
409
|
problem: { type: "string", description: "Problem brief (symptom + failure trail + entry files)" },
|
|
407
|
-
models: { type: "array", items: { type: "string" }, description: 'Optional subset
|
|
410
|
+
models: { type: "array", items: { type: "string" }, description: 'Optional subset to narrow the pool — omit to run the whole pool. Each entry is "provider:model", a bare provider, or a bare model name (case-insensitive).' },
|
|
408
411
|
},
|
|
409
412
|
required: ["problem"],
|
|
410
413
|
},
|