@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/family-tools.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* agent/family-tools.mjs — 家族矩阵单源(`assembleFamilyTools`)。
|
|
3
3
|
*
|
|
4
4
|
* 批次 `docs/batches/2026-09-15-vsc-tool-table-dup.md` §2.3A:家族矩阵(哪个运行面得哪些
|
|
5
|
-
* 家族工具)自 CLI 侧 `agent/setup.mjs` 的 `assembleFamilyTools
|
|
5
|
+
* 家族工具)自 CLI 侧 `agent/setup.mjs` 的 `assembleFamilyTools` 整体迁出——CLI 与 VSC 同调同一份实现
|
|
6
6
|
* (消灭「同一角色矩阵两份实现」= 本批缺陷的类根因);端差(VSC 装饰链 / settings 追加 /
|
|
7
7
|
* consult 池来源)经 `decorate` 注入——**不传 = 核默认形态**(CLI = 迁出前逐字)。
|
|
8
8
|
*
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* 核内先例 = 登记册头注「Loaded from agent.mjs via dynamic import to avoid ESM circular
|
|
18
18
|
* dependencies」(本档先于 `agent/setup.mjs` 的调用点载入,同一语义)。
|
|
19
19
|
*/
|
|
20
|
+
import { knowledgeTool } from "../tools/knowledge.mjs"
|
|
21
|
+
|
|
20
22
|
export async function assembleFamilyTools({
|
|
21
23
|
depth, // number 0 = 主 agent;>0 = 子代理
|
|
22
24
|
role = null, // string 子代理角色(eng-coder / eng-designer / coder / consult / explore / …)
|
|
@@ -26,7 +28,7 @@ export async function assembleFamilyTools({
|
|
|
26
28
|
decorate = null, // object 端差面:{ subagent?, consultStart?, consultStop?, settings? }
|
|
27
29
|
} = {}) {
|
|
28
30
|
// CORE-UNIFICATION TOOLS #83:consult 家族随统一登记册自 `../agent-tools.mjs` 取用(单一来源)
|
|
29
|
-
const { planTool, subagentTool, taskTool, skillTool, goalTool, verifyTool, recentChangesTool, timerTool, advisorTool, engTool, readHistoryTool, contextTool, batchTool, manifestTool, manifestReadTool, consultStartTool, consultStopTool, parentChannelTool, docCheckTool } = await import("../agent-tools.mjs")
|
|
31
|
+
const { planTool, subagentTool, taskTool, skillTool, goalTool, verifyTool, recentChangesTool, timerTool, advisorTool, engTool, readHistoryTool, contextTool, batchTool, manifestTool, manifestReadTool, consultStartTool, consultStopTool, parentChannelTool, docCheckTool, docGraphTool, docGraphReadTool } = await import("../agent-tools.mjs")
|
|
30
32
|
// 台账统一入口(2026-10-05 统一入口批——台账 #923):全量变体 = depth-0 段 ∥ 只读变体 = 全部
|
|
31
33
|
// depth>0 段。动态 import——ledger 链静态达 node:sqlite(W8 契约②);两变体同名单对象、schema 窄化。
|
|
32
34
|
const { ledgerTool, ledgerReadTool } = await import("../ledger.mjs")
|
|
@@ -45,17 +47,21 @@ export async function assembleFamilyTools({
|
|
|
45
47
|
return { ...tool, description: tool.description + `\nCurrently configured consultants (this tool's pool): ${list}` }
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
// Role enum is mutually exclusive: normal mode has "coder", engineering mode has "eng-coder"/"eng-designer"
|
|
50
|
+
// Role enum is mutually exclusive: normal mode has "coder", engineering mode has "eng-coder"/"eng-designer";
|
|
51
|
+
// "tester" (AGENT-LOOP-SUBAGENT.md §6.59) is dispatchable in both modes — it runs verification and returns
|
|
52
|
+
// readings; its tool table (read-only set ∪ execute/bash − {verify, advisor}) holds no write tool. Run-only is the
|
|
53
|
+
// role contract, not a sandbox (§6.59.7 边界 1 — `bash` can still write, and that is by design).
|
|
54
|
+
const testerSuffix = " role='tester' runs verification and reports the readings back — it never edits code or documents."
|
|
49
55
|
const subagentRoles = (depth === 0 && engineering)
|
|
50
56
|
? {
|
|
51
|
-
enum: ["explore", "eng-designer", "eng-coder"],
|
|
57
|
+
enum: ["explore", "eng-designer", "eng-coder", "tester"],
|
|
52
58
|
description: "The sub-agent role — see the tool description for the role capability matrix. Exact spelling required.",
|
|
53
|
-
suffix: " In engineering mode, use role='eng-coder' for implementation (coder is disabled) and role='eng-designer' for writing the requirements/design documents.",
|
|
59
|
+
suffix: " In engineering mode, use role='eng-coder' for implementation (coder is disabled) and role='eng-designer' for writing the requirements/design documents." + testerSuffix,
|
|
54
60
|
}
|
|
55
61
|
: {
|
|
56
|
-
enum: ["explore", "plan", "coder"],
|
|
62
|
+
enum: ["explore", "plan", "coder", "tester"],
|
|
57
63
|
description: "The sub-agent role — see the tool description for the role capability matrix. Exact spelling required.",
|
|
58
|
-
suffix:
|
|
64
|
+
suffix: testerSuffix,
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
const filteredSubagent = depth === 0 ? {
|
|
@@ -128,6 +134,9 @@ export async function assembleFamilyTools({
|
|
|
128
134
|
? "Spawn a read-only `explore` sub-agent to SURVEY the current state for the design: it reads code / docs / existing designs and reports evidence with file:line. BLOCKING ONLY (no async) and action:'spawn' ONLY — the survey channel is read-only; escalate/status/cancel/panel/consume-design/observe/send are not available. Survey budget: ≤6 explore spawns per batch — the main agent's survey result is reference only; do your own. The spawn carries the five task-book parameters (four core: goal / knownFacts / acceptance / reportFormat + `scope`); a task-only spawn is refused."
|
|
129
135
|
: "Spawn a read-only `explore` sub-agent to AUDIT your delivery against the design: it compares the delivered code with the design for divergence — partially implemented acceptance criteria, silent simplifications, doc drift, changes outside the approved file list. BLOCKING ONLY (no async — the audit report decides your next protocol step). action:'spawn' ONLY — the audit channel is a read-only spawn; escalate/status/cancel/panel/consume-design/observe/send are not available. The audit context is appended MECHANICALLY — the batch record path (its §2 is the delivery's task book, read it before judging) plus the files you actually touched; never hand the audit a self-written file list (a self-report could omit exactly the out-of-scope file it must catch). The spawn carries the five task-book parameters (four core: goal / knownFacts / acceptance / reportFormat + `scope`); a task-only spawn is refused.",
|
|
130
136
|
parameters: { ...subagentTool.parameters, properties: props },
|
|
137
|
+
// `async` 不在本变体 schema 里(`delete props.async`)= 这条通道**没有异步选项**。`async` 必填化后
|
|
138
|
+
// 由变体自己声明固定值(同步),而不是给模型留一个缺省——缺省就是替调用方拿主意,同步才是本通道的契约。
|
|
139
|
+
execute: (args, ctx) => subagentTool.execute({ ...args, async: false }, ctx),
|
|
131
140
|
}
|
|
132
141
|
})()
|
|
133
142
|
: null
|
|
@@ -141,6 +150,12 @@ export async function assembleFamilyTools({
|
|
|
141
150
|
? [decorate?.consultStart ?? withPool(consultStartTool), decorate?.consultStop ?? consultStopTool]
|
|
142
151
|
: []
|
|
143
152
|
|
|
153
|
+
// 文档工具面(`AGENT-LOOP-SUBAGENT.md` §6.60.1 · 需求 `docs/core/requirements/DOC-GRAPH.md` §4 AC-10):
|
|
154
|
+
// **一处写、五处展开**——`doc_check` 本就只读(无写 action 可收窄)⇒ 本体直挂;`doc_graph` 挂只读变体
|
|
155
|
+
// (三动作、无 `scan`:子代理段的台账是只读变体,扫由父侧做——D-DT1)。五段各写一遍字面就是五份会各自漂的
|
|
156
|
+
// 单子(D-DT4);并成一段又会抹掉各段真实差异。depth-0 段不展开本组:那边挂的是全量 `docGraphTool` + `docCheckTool`。
|
|
157
|
+
const docTools = [docCheckTool, docGraphReadTool]
|
|
158
|
+
|
|
144
159
|
const depthOnly = depth === 0
|
|
145
160
|
? [decorate?.subagent ?? filteredSubagent, skillTool, goalTool, engTool, verifyTool, recentChangesTool, readHistoryTool, contextTool, advisorTool, batchTool(null),
|
|
146
161
|
...consultTools,
|
|
@@ -149,11 +164,15 @@ export async function assembleFamilyTools({
|
|
|
149
164
|
// 团队台账全量变体(五 action——同律:子代理段只挂读变体;登录态门在工具内)
|
|
150
165
|
teamLedgerTool,
|
|
151
166
|
// manifest 工具(`MANIFEST.md` §2.10 · 2026-10-08 · 台账 #1098):主 agent 读写出口——
|
|
152
|
-
// **两模式同挂**(需求未设模式门);全量变体仅 depth-0
|
|
167
|
+
// **两模式同挂**(需求未设模式门);全量变体仅 depth-0——子代理各角色段挂只读变体(见下 depth>0 各段)。
|
|
153
168
|
manifestTool,
|
|
154
|
-
// 文档纪律机检(`DOC-DISCIPLINE.md` §3.20 条目 S):只读报告态——depth-0 主 agent
|
|
155
|
-
//
|
|
169
|
+
// 文档纪律机检(`DOC-DISCIPLINE.md` §3.20 条目 S):只读报告态——depth-0 主 agent 段挂本体;
|
|
170
|
+
// 全部 depth>0 角色段由下方 `docTools` 展开供给(`AGENT-LOOP-SUBAGENT.md` §6.60)。
|
|
156
171
|
docCheckTool,
|
|
172
|
+
// 文档锚点图(`DOC-GRAPH.md` §2.5 · 需求 F1–F6):**两变体互斥装配**——本段(depth-0)挂全量四动作;
|
|
173
|
+
// 全部 depth>0 角色段挂只读变体(三动作、无 `scan`,契约 = `DOC-GRAPH.md` §2.5.5,装配矩阵单源 =
|
|
174
|
+
// `AGENT-LOOP-SUBAGENT.md` §6.60.2)。位置与 `docCheckTool` 同段(同一族:文档纪律面)。
|
|
175
|
+
docGraphTool,
|
|
157
176
|
// 端差(decorate.settings——VSC depth-0 主 agent 面;缺省不追加):核默认形态里
|
|
158
177
|
// settings 住**基础集**(`tools/index.mjs` `assembleBuiltinTools`),端侧自持清单
|
|
159
178
|
// 无该面 ⇒ 端以 decorate 补位(收敛通道 = 将来去 decorate 项即归核位)。
|
|
@@ -184,13 +203,13 @@ export async function assembleFamilyTools({
|
|
|
184
203
|
// 团队台账只读变体(team-ledger 批)同律。
|
|
185
204
|
// manifest 只读变体(MANIFEST.md §2.10.1 · 2026-10-22 · 台账 #1738):同名 `manifest`、action 枚举只剩 `read`;
|
|
186
205
|
// 与上两条只读先例同律挂在全部 depth>0 角色段(全量变体仅 depth-0——两变体互斥装配,同名不塌缩)。
|
|
187
|
-
: engChildRole === "eng-coder" ? [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, advisorTool, verifyTool, batchTool(batchDoc),
|
|
206
|
+
: engChildRole === "eng-coder" ? [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, advisorTool, verifyTool, batchTool(batchDoc, { role: "eng-coder" }), ...docTools,
|
|
188
207
|
...(engChildSubagent ? [engChildSubagent] : [])]
|
|
189
|
-
: engChildRole === "eng-designer" ? [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, batchTool(batchDoc),
|
|
208
|
+
: engChildRole === "eng-designer" ? [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, batchTool(batchDoc, { role: "eng-designer" }), ...docTools,
|
|
190
209
|
...(engChildSubagent ? [engChildSubagent] : [])]
|
|
191
|
-
: role === "coder" ? [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, verifyTool, advisorTool, ...(batchDoc ? [batchTool(batchDoc)] : [])]
|
|
192
|
-
: role === "consult" ? [recentChangesTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool]
|
|
193
|
-
: [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool]
|
|
210
|
+
: role === "coder" ? [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, verifyTool, advisorTool, ...docTools, ...(batchDoc ? [batchTool(batchDoc, { role: "coder" })] : [])]
|
|
211
|
+
: role === "consult" ? [recentChangesTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, ...docTools]
|
|
212
|
+
: [parentChannelTool, ledgerReadTool, teamLedgerReadTool, manifestReadTool, ...docTools]
|
|
194
213
|
|
|
195
214
|
// 固定段(装配序 = agent.tools → 固定段 → 家族段 → extraTools):timer 全模式全深度;
|
|
196
215
|
// plan 随模式位——ENG-PLAN-EXCLUSION(FR31 ① · KD8 卸载而非「注册 + 报错」· KD11 全深度两端);
|
|
@@ -200,6 +219,6 @@ export async function assembleFamilyTools({
|
|
|
200
219
|
// 判据 = 单一模式位 `engineering`(不带深度分支——子代理面随同排除,role enum
|
|
201
220
|
// `subagentRoles` + spawn 门 / task execute 门已同向)。
|
|
202
221
|
return engineering
|
|
203
|
-
? [timerTool, ...depthOnly]
|
|
204
|
-
: [taskTool, planTool, timerTool, ...depthOnly]
|
|
222
|
+
? [timerTool, knowledgeTool, ...depthOnly]
|
|
223
|
+
: [taskTool, planTool, timerTool, knowledgeTool, ...depthOnly]
|
|
205
224
|
}
|
package/agent/helpers.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* agent/helpers.mjs — Agent utility functions and constants
|
|
3
3
|
*/
|
|
4
|
-
import { configDir } from "../config.mjs"
|
|
5
4
|
import { readFileSync, readdirSync } from "node:fs"
|
|
6
5
|
import { homedir } from "node:os"
|
|
7
|
-
import { writeFile, mkdir, readdir, stat, unlink } from "node:fs/promises"
|
|
8
6
|
import { join } from "node:path"
|
|
9
7
|
import { execFile } from "node:child_process"
|
|
10
8
|
import { promisify } from "node:util"
|
|
9
|
+
// 只读变体的描述取值面(§6.29 ①「描述」行:档名 → `DESC` → `loadToolDoc`,档定义期读一次)
|
|
10
|
+
import { DESC } from "../tools/shared.mjs"
|
|
11
|
+
export { offloadToolResult, cleanupOldToolResults, TMP_RETENTION_MS } from "./offload.mjs"
|
|
11
12
|
|
|
12
13
|
/** Single source for the AUTO-mode reminder (was duplicated in agent.mjs +
|
|
13
14
|
* setup.mjs — consult P2, 2026-08-30). */
|
|
@@ -33,52 +34,6 @@ export const REPORT_CONTINUATION =
|
|
|
33
34
|
"3. How you verified (tests run, commands executed, with results)\n" +
|
|
34
35
|
"4. Anything left undone or worth follow-up"
|
|
35
36
|
|
|
36
|
-
const TOOL_RESULT_OFFLOAD_LIMIT = 64 * 1024 // 65536 chars — offload only above 64K (2026-08-24)
|
|
37
|
-
const TOOL_RESULT_PREVIEW = 64 * 1024 // total preview budget: head + middle note + tail ≤ 65536 (aligns with CLI/VS Code webview)
|
|
38
|
-
const TOOL_RESULT_PREVIEW_HEAD = 16 * 1024 // head slice preserved (2026-09-04 §5 — dual-end preview)
|
|
39
|
-
const TOOL_RESULT_PREVIEW_TAIL = 48 * 1024 // nominal tail slice (results/errors/stats live here — actual tail = budget remainder, see buildDualEndPreview)
|
|
40
|
-
|
|
41
|
-
/** UTF-16 安全截断(2026-09-02 deepseek 400 根因):slice(0, N) 按码元切会把 emoji 代理对切成孤立
|
|
42
|
-
* 高代理(如 🔴=U+D83D+DD34 只剩 D83D)——deepseek 解析器严格 UTF-16 报 400
|
|
43
|
-
* "unexpected end of hex escape"。截断点落在高代理上时向前收一个码元。
|
|
44
|
-
* 与 setup.mjs 的 safeSliceUTF16 同语义(两处独立实现——escape.mjs 的 sanitizeLoneSurrogates 是发送兜底,此处是源头)。 */
|
|
45
|
-
function safeSliceUTF16(text, max) {
|
|
46
|
-
if (text.length <= max) return text
|
|
47
|
-
const cp = text.charCodeAt(max - 1)
|
|
48
|
-
if (cp >= 0xd800 && cp <= 0xdbff) return text.slice(0, max - 1)
|
|
49
|
-
return text.slice(0, max)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** UTF-16 safe END slice (2026-09-04 §5 dual-end preview — review #5: both boundaries must not split
|
|
53
|
-
* a surrogate pair). Same rule as safeSliceUTF16, mirrored: if the slice START lands on a LOW
|
|
54
|
-
* surrogate (DC00-DFFF — the second half of a pair whose high half sits just before the boundary),
|
|
55
|
-
* advance one code unit so the slice never begins with an orphan low surrogate. */
|
|
56
|
-
function safeSliceUTF16End(text, max) {
|
|
57
|
-
if (text.length <= max) return text
|
|
58
|
-
const start = text.length - max
|
|
59
|
-
const cp = text.charCodeAt(start)
|
|
60
|
-
if (cp >= 0xdc00 && cp <= 0xdfff) return text.slice(start + 1)
|
|
61
|
-
return text.slice(start)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Dual-end preview (design §5 D-4.1): head + middle-omitted note + tail — the tail carries
|
|
65
|
-
* results/errors/stats that a pure-head truncation would cut off.
|
|
66
|
-
* Budget (round1 review #2, fixed): head + note + tail ≤ TOOL_RESULT_PREVIEW (65536) — tail is
|
|
67
|
-
* computed from constants (tail = TOOL_RESULT_PREVIEW − head − noteLen), never hardcoded.
|
|
68
|
-
* The note length depends on the omitted digit count; text.length's digit count is an upper bound
|
|
69
|
-
* for omitted (< text.length), so budgeting with it keeps the total ≤ 65536 while the printed
|
|
70
|
-
* note reports the actual omitted count. Both boundaries run surrogate-safe slices (review #5). */
|
|
71
|
-
function buildDualEndPreview(text) {
|
|
72
|
-
const head = safeSliceUTF16(text, TOOL_RESULT_PREVIEW_HEAD)
|
|
73
|
-
const noteFn = (omitted) => `\n\n… [middle omitted: ${omitted} chars] …\n\n`
|
|
74
|
-
const tailLen = Math.min(TOOL_RESULT_PREVIEW_TAIL, TOOL_RESULT_PREVIEW - TOOL_RESULT_PREVIEW_HEAD - noteFn(text.length).length)
|
|
75
|
-
const tail = safeSliceUTF16End(text, tailLen)
|
|
76
|
-
return head + noteFn(Math.max(0, text.length - head.length - tail.length)) + tail
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Offload-dir write-time self-cleanup retention window (2026-08-21): files older than 3 days are deleted on the next offload. */
|
|
80
|
-
export const TMP_RETENTION_MS = 3 * 24 * 3600 * 1000
|
|
81
|
-
|
|
82
37
|
const GIT_TIMEOUT_MS = 5000
|
|
83
38
|
const MAX_GIT_CHANGES_DISPLAY = 20
|
|
84
39
|
|
|
@@ -127,52 +82,6 @@ export function tryCanonicalize(name, args) {
|
|
|
127
82
|
try { return name + ":" + JSON.stringify(JSON.parse(args)) } catch { return name + ":" + args }
|
|
128
83
|
}
|
|
129
84
|
|
|
130
|
-
/**
|
|
131
|
-
* Best-effort write-time self-cleanup: delete files in dir whose mtime exceeds TMP_RETENTION_MS.
|
|
132
|
-
* Subdirectories are never touched; every failure is silent — cleanup must not affect offload.
|
|
133
|
-
*/
|
|
134
|
-
export async function cleanupOldToolResults(dir) {
|
|
135
|
-
const now = Date.now()
|
|
136
|
-
let entries
|
|
137
|
-
try {
|
|
138
|
-
entries = await readdir(dir, { withFileTypes: true })
|
|
139
|
-
} catch {
|
|
140
|
-
return // dir missing or unreadable → nothing to clean
|
|
141
|
-
}
|
|
142
|
-
for (const entry of entries) {
|
|
143
|
-
if (!entry.isFile()) continue // subdirectories untouched
|
|
144
|
-
try {
|
|
145
|
-
const st = await stat(join(dir, entry.name))
|
|
146
|
-
if (now - st.mtimeMs > TMP_RETENTION_MS) await unlink(join(dir, entry.name))
|
|
147
|
-
} catch {
|
|
148
|
-
/* entry vanished concurrently or I/O error — best effort, keep going */
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/** Offload a tool result / report to disk (§2.2): `force` = write regardless of size (async
|
|
154
|
-
* subagent reports must survive the parent turn). Rendering splits on the SAME constant as the old
|
|
155
|
-
* gate: ≤ TOOL_RESULT_OFFLOAD_LIMIT ⇒ body once + path (never dual-end — a short body would come
|
|
156
|
-
* out twice with `middle omitted: 0 chars`); > ⇒ dual-end preview + path. Writes self-clean first. */
|
|
157
|
-
export async function offloadToolResult(text, callId, dir = join(configDir, "tool-results"), { force = false } = {}) {
|
|
158
|
-
const overLimit = text.length > TOOL_RESULT_OFFLOAD_LIMIT
|
|
159
|
-
if (!force && !overLimit) return text
|
|
160
|
-
try {
|
|
161
|
-
await cleanupOldToolResults(dir)
|
|
162
|
-
await mkdir(dir, { recursive: true })
|
|
163
|
-
const file = join(dir, `${Date.now()}-${String(callId).replace(/[^a-zA-Z0-9_-]/g, "_")}.log`)
|
|
164
|
-
await writeFile(file, text, "utf8")
|
|
165
|
-
if (!overLimit) return `${text}\n\n[... full content saved to: ${file}\nPage through it with the read tool (offset/limit) if you need the full text later.]`
|
|
166
|
-
return buildDualEndPreview(text) + `\n\n[... output too large (${text.length} chars total), full content saved to: ${file}\n` +
|
|
167
|
-
`Page through it with the read tool (offset/limit) or sed -n 'START,ENDp' — do NOT re-run the tool blindly.]`
|
|
168
|
-
} catch {
|
|
169
|
-
// 写盘失败不吞报告:>LIMIT 走双端预览 + 原文案;≤LIMIT 正文整段在前(不谎称 truncated)
|
|
170
|
-
const body = overLimit ? buildDualEndPreview(text) : text
|
|
171
|
-
return body + (overLimit ? `\n\n[... truncated: ${text.length} chars total, offload to disk failed]`
|
|
172
|
-
: `\n\n[... full text kept inline above (${text.length} chars), offload to disk failed]`)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
85
|
// 失败冷却 v1(用户裁——GIT-ASYNC L21):真失败/超时后 30s 内跳过该 cwd 的收集——
|
|
177
86
|
// 病态 repo 周期拖慢变一次性。VSC setup-reminders.mjs 同构镜像。
|
|
178
87
|
const GIT_FAILURE_COOLDOWN_MS = 30_000
|
|
@@ -249,9 +158,13 @@ export class ContinueError extends Error {
|
|
|
249
158
|
export const INHERITED_GUARD_KEYS = [
|
|
250
159
|
"_mutatedThisRun", "_verifiedThisRun", "_verifyPassed", "_calledAdvisorThisRun",
|
|
251
160
|
"_touchedFiles", "_verifyRetries", "_advisorRound",
|
|
161
|
+
// ADVISOR-CONVERGENCE.md §6.4「状态的跨段存活」:advisor 提醒计数与到顶诚实提醒的一次性位同进清单——
|
|
162
|
+
// 不在清单里的字段不被 `restoreGuard` 回填,而自动回合收尾留下的 guard 三态照旧回填 ⇒ 计数不随、
|
|
163
|
+
// 下一次用户回合从零起,B 的周期上限形同没设。
|
|
164
|
+
"_advisorReminders", "_advisorHonestySent",
|
|
252
165
|
]
|
|
253
166
|
|
|
254
|
-
/** 写侧单点:快照
|
|
167
|
+
/** 写侧单点:快照 `INHERITED_GUARD_KEYS` 全部键 → 纯对象(载体形态由调用方决定——核 = agent 字段 / 端 = 宿主容器)。 */
|
|
255
168
|
export function snapshotGuard(agent) {
|
|
256
169
|
const snap = {}
|
|
257
170
|
for (const k of INHERITED_GUARD_KEYS) snap[k] = agent[k]
|
|
@@ -377,6 +290,121 @@ export function readonlyToolNames(tools) {
|
|
|
377
290
|
return new Set(tools.filter((t) => t.readonly).map((t) => t.name))
|
|
378
291
|
}
|
|
379
292
|
|
|
293
|
+
// ─── 只读角色的 action 级变体(TOOLS.md §6.29 ①)───────────────────────────────
|
|
294
|
+
/** 嵌套动作键闭集(§6.29「嵌套动作的配对规则」):键 → 顶层 action。schema 是平铺的,配对只在
|
|
295
|
+
* 「顶层 action + 这个键的一个值」这一对上判;表外的键不参与配对。 */
|
|
296
|
+
const NESTED_ACTION_KEYS = {
|
|
297
|
+
stash: "stashAction",
|
|
298
|
+
worktree: "worktreeAction",
|
|
299
|
+
tag: "tagAction",
|
|
300
|
+
branch: "branchAction",
|
|
301
|
+
remote: "remoteAction",
|
|
302
|
+
checkpoint: "checkpointAction",
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** 只读变体登记表(**单源**——核装配 `agent-tools/subagent-spawn.mjs` ∥ `agent-tools/consult.mjs`
|
|
306
|
+
* 与端装配 `thincoder-vscode/src/agent/tool-table.mjs` 同取本表):
|
|
307
|
+
* - `doc` = 该变体的描述档名(`tool-docs/<doc>.md`);**没有登记的工具不挂入只读角色**
|
|
308
|
+
* (§6.29「档与角色」:`browser` ∥ `ssh` 的 `isReadonlyAction` 判的是审批门,不造变体)。
|
|
309
|
+
* - `writeOnly` = 只有被剔掉的写动作才消费的参数名。没有通用派生法:参数名与注释都不说
|
|
310
|
+
* 它服务哪个 action(`git` 的 `name` 挂在 `branch` 上,而 `branch` 的只读项 `list` 并不读它),
|
|
311
|
+
* 所以这一列按工具声明,动作集仍只由运行期谓词裁决(K2:不另立第二份动作名单)。 */
|
|
312
|
+
export const READONLY_VARIANT_DOCS = {
|
|
313
|
+
git: { doc: "git-read", writeOnly: ["message", "name", "remoteUrl", "tags", "mode", "rebaseAction", "dryRun", "create", "dest"] },
|
|
314
|
+
memory: { doc: "memory-read", writeOnly: ["title", "content", "tags", "id", "confirm", "ledger", "project"] },
|
|
315
|
+
settings: { doc: "settings-read", writeOnly: [] },
|
|
316
|
+
process: { doc: "process-read", writeOnly: ["pid", "id"] },
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 只读变体构造器(§6.29 ①「共用 action 变体」):接收**工具、谓词、描述档名**三样注入,
|
|
321
|
+
* 本函数不持角色名单、也不复制任何工具的动作表。
|
|
322
|
+
*
|
|
323
|
+
* 三面同时收窄(K4):schema 的 `action.enum` 与嵌套键 `enum` ∥ 描述 ∥ execute 第二道门——
|
|
324
|
+
* 只删 enum 会留下写参数与全文诱导,只做文本过滤又会被直接 execute 绕过(provider 不保证执行 schema)。
|
|
325
|
+
*
|
|
326
|
+
* @param {object} tool — 原工具(读它的 `parameters`;执行仍回原 `execute`)
|
|
327
|
+
* @param {{docName: string, writeOnly?: string[], isReadonly: (tool: object, args: object) => boolean}} opts
|
|
328
|
+
* `isReadonly` = 运行期动作判据(调用点一律传 `readonlyActionOf` 的单参形 `readonlyActionTest`)。
|
|
329
|
+
* @returns {object} 同名只读变体(`readonly: true`)
|
|
330
|
+
*/
|
|
331
|
+
export function makeReadonlyToolVariant(tool, { docName, writeOnly = [], isReadonly }) {
|
|
332
|
+
const params = tool.parameters ?? {}
|
|
333
|
+
const props = params.properties ?? {}
|
|
334
|
+
const declared = Array.isArray(props.action?.enum) ? props.action.enum : []
|
|
335
|
+
const keptActions = []
|
|
336
|
+
const keptNested = {}
|
|
337
|
+
for (const action of declared) {
|
|
338
|
+
const nestedKey = NESTED_ACTION_KEYS[action]
|
|
339
|
+
if (nestedKey && Array.isArray(props[nestedKey]?.enum)) {
|
|
340
|
+
// 候选形 = 「顶层 action + 同 schema 里被钩子读取的嵌套键」这一对;每个枚举值各成一候选
|
|
341
|
+
const values = props[nestedKey].enum.filter((v) => isReadonly(tool, { action, [nestedKey]: v }))
|
|
342
|
+
if (values.length > 0) {
|
|
343
|
+
keptActions.push(action)
|
|
344
|
+
keptNested[nestedKey] = values
|
|
345
|
+
}
|
|
346
|
+
continue
|
|
347
|
+
}
|
|
348
|
+
if (isReadonly(tool, { action })) keptActions.push(action)
|
|
349
|
+
}
|
|
350
|
+
// 缺省空调用候选(`process` 缺省 action = list):空调用判为只读 ⇒ action 不设必填,
|
|
351
|
+
// 必填与否就由它自己决定,而不是替调用方补一个默认值。
|
|
352
|
+
const emptyCallReadonly = isReadonly(tool, {})
|
|
353
|
+
const variantProps = {}
|
|
354
|
+
for (const [key, spec] of Object.entries(props)) {
|
|
355
|
+
if (key === "action") {
|
|
356
|
+
variantProps.action = {
|
|
357
|
+
...spec,
|
|
358
|
+
enum: keptActions,
|
|
359
|
+
description: `Read-only variant: ${keptActions.join(" / ")} — the only actions this tool face carries. Every one of them only reads; write actions are not part of it.`,
|
|
360
|
+
}
|
|
361
|
+
continue
|
|
362
|
+
}
|
|
363
|
+
if (writeOnly.includes(key)) continue
|
|
364
|
+
const owningAction = Object.keys(NESTED_ACTION_KEYS).find((a) => NESTED_ACTION_KEYS[a] === key)
|
|
365
|
+
if (owningAction) {
|
|
366
|
+
// 嵌套键的 enum = 各保留顶层下只读值的并集;其顶层不在变体里 ⇒ 本键整枚不出现
|
|
367
|
+
if (keptNested[key]) variantProps[key] = { ...spec, enum: keptNested[key] }
|
|
368
|
+
continue
|
|
369
|
+
}
|
|
370
|
+
variantProps[key] = spec
|
|
371
|
+
}
|
|
372
|
+
const required = (params.required ?? []).filter((k) => !(k === "action" && emptyCallReadonly))
|
|
373
|
+
return {
|
|
374
|
+
...tool,
|
|
375
|
+
description: DESC(docName), // 档定义期取值:全量档仍服务 depth-0,两变体各一份描述
|
|
376
|
+
parameters: { ...params, properties: variantProps, required },
|
|
377
|
+
readonly: true,
|
|
378
|
+
isReadonlyAction(args) { return isReadonly(tool, args) },
|
|
379
|
+
async execute(args, ctx) {
|
|
380
|
+
const call = args && typeof args === "object" ? args : {}
|
|
381
|
+
if (!isReadonly(tool, call)) {
|
|
382
|
+
const named = call.action === undefined ? "(no action)" : JSON.stringify(call.action)
|
|
383
|
+
throw new Error(`${tool.name}: ${named} is not available to a read-only role — this tool face carries only ${keptActions.join(" / ")}; nothing was executed (zero file write, zero ledger write, zero network write).`)
|
|
384
|
+
}
|
|
385
|
+
return tool.execute(args, ctx)
|
|
386
|
+
},
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* 只读角色的工具面(§6.29 B4):整把 `readonly` 工具原样 ∪ 登记的 action 级只读变体。
|
|
392
|
+
* `isReadonly` 注入面同 `makeReadonlyToolVariant`;`tester` 面不消费本函数(它只用整把只读集,不顺扩)。
|
|
393
|
+
* @param {object[]} tools — 调用方父面工具表
|
|
394
|
+
* @param {(tool: object, args: object) => boolean} isReadonly
|
|
395
|
+
* @returns {object[]} 新数组(原表零改)
|
|
396
|
+
*/
|
|
397
|
+
export function deriveReadonlyTools(tools, isReadonly) {
|
|
398
|
+
const out = []
|
|
399
|
+
for (const t of tools ?? []) {
|
|
400
|
+
if (t?.readonly) { out.push(t); continue }
|
|
401
|
+
const reg = READONLY_VARIANT_DOCS[t?.name]
|
|
402
|
+
if (!reg) continue // 无描述档 ⇒ 不挂入只读角色(§6.29「档与角色」)
|
|
403
|
+
out.push(makeReadonlyToolVariant(t, { docName: reg.doc, writeOnly: reg.writeOnly, isReadonly }))
|
|
404
|
+
}
|
|
405
|
+
return out
|
|
406
|
+
}
|
|
407
|
+
|
|
380
408
|
/** Depth>0 tool exclusions — subagents never get the interactive main-session tools (`question`:
|
|
381
409
|
* no user to ask; `ssh`: the credential window is a user-facing event AND the session pool
|
|
382
410
|
* belongs to the main session — no UI at depth>0 and no session to hand back; the routing
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent/offload.mjs — 一次「把超长正文落到盘上、把注入体压成预览 + 路径」:门限常量 → 两端安全切片 → 预览拼装 → 落盘 → 写时自清理。
|
|
3
|
+
*/
|
|
4
|
+
import { configDir } from "../config.mjs"
|
|
5
|
+
import { writeFile, mkdir, readdir, stat, unlink } from "node:fs/promises"
|
|
6
|
+
import { join } from "node:path"
|
|
7
|
+
import { safeSliceUTF16, safeSliceUTF16Tail } from "../text-budget.mjs"
|
|
8
|
+
|
|
9
|
+
const TOOL_RESULT_OFFLOAD_LIMIT = 64 * 1024 // 65536 chars — offload only above 64K (2026-08-24)
|
|
10
|
+
const TOOL_RESULT_PREVIEW = 64 * 1024 // total preview budget: head + middle note + tail ≤ 65536 (aligns with CLI/VS Code webview)
|
|
11
|
+
|
|
12
|
+
/** Dual-end preview: head + middle-omitted note + tail — the tail carries results/errors/stats that a
|
|
13
|
+
* pure-head truncation would cut off (design §5 D-4.1; `docs/core/design/TOOL-OUTPUT-LIMITS.md` §2).
|
|
14
|
+
*
|
|
15
|
+
* `budget` is REQUIRED and has no default (`CONTEXT-COMPACTION.md` §1.2): a default would decide the
|
|
16
|
+
* caller's crop size on its behalf. head = floor(budget / 4), the note reports the ACTUAL omitted
|
|
17
|
+
* count, tail = budget remainder (never a hardcoded number).
|
|
18
|
+
* The 64K face is byte-identical to before: floor(65536 / 4) = 16384 was the old fixed head, and the
|
|
19
|
+
* old 48K tail nominal was only ever `budget − head − note` — the cap never bit.
|
|
20
|
+
*
|
|
21
|
+
* Both cut points run the surrogate-safe slices exported by `text-budget.mjs`. The deleted local END
|
|
22
|
+
* slice guarded only the slice START; `safeSliceUTF16Tail` also drops a lone high surrogate at the
|
|
23
|
+
* trailing end, so a result that itself ends in half a surrogate pair loses one more code unit.
|
|
24
|
+
* Callers only pass text LONGER than the budget (a shorter body would come out twice). */
|
|
25
|
+
export function buildDualEndPreview(text, budget) {
|
|
26
|
+
if (!(typeof budget === "number" && Number.isFinite(budget) && budget > 0)) {
|
|
27
|
+
throw new Error("buildDualEndPreview: `budget` is required (a positive character budget, no default) — pass the preview budget this caller needs")
|
|
28
|
+
}
|
|
29
|
+
const t = String(text ?? "")
|
|
30
|
+
const head = safeSliceUTF16(t, Math.floor(budget / 4))
|
|
31
|
+
const noteFn = (omitted) => `\n\n… [middle omitted: ${omitted} chars] …\n\n`
|
|
32
|
+
const tailLen = Math.max(0, budget - head.length - noteFn(t.length).length)
|
|
33
|
+
const tail = safeSliceUTF16Tail(t, tailLen)
|
|
34
|
+
return head + noteFn(Math.max(0, t.length - head.length - tail.length)) + tail
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Offload-dir write-time self-cleanup retention window (2026-08-21): files older than 3 days are deleted on the next offload. */
|
|
38
|
+
export const TMP_RETENTION_MS = 3 * 24 * 3600 * 1000
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Best-effort write-time self-cleanup: delete files in dir whose mtime exceeds TMP_RETENTION_MS.
|
|
42
|
+
* Subdirectories are never touched; every failure is silent — cleanup must not affect offload.
|
|
43
|
+
*/
|
|
44
|
+
export async function cleanupOldToolResults(dir) {
|
|
45
|
+
const now = Date.now()
|
|
46
|
+
let entries
|
|
47
|
+
try {
|
|
48
|
+
entries = await readdir(dir, { withFileTypes: true })
|
|
49
|
+
} catch {
|
|
50
|
+
return // dir missing or unreadable → nothing to clean
|
|
51
|
+
}
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
if (!entry.isFile()) continue // subdirectories untouched
|
|
54
|
+
try {
|
|
55
|
+
const st = await stat(join(dir, entry.name))
|
|
56
|
+
if (now - st.mtimeMs > TMP_RETENTION_MS) await unlink(join(dir, entry.name))
|
|
57
|
+
} catch {
|
|
58
|
+
/* entry vanished concurrently or I/O error — best effort, keep going */
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Offload a tool result / report to disk (§2.2): `force` = write regardless of size (async
|
|
64
|
+
* subagent reports must survive the parent turn). Rendering splits on the SAME constant as the old
|
|
65
|
+
* gate: ≤ TOOL_RESULT_OFFLOAD_LIMIT ⇒ body once + path (never dual-end — a short body would come
|
|
66
|
+
* out twice with `middle omitted: 0 chars`); > ⇒ dual-end preview + path. Writes self-clean first. */
|
|
67
|
+
export async function offloadToolResult(text, callId, dir = join(configDir, "tool-results"), { force = false } = {}) {
|
|
68
|
+
const overLimit = text.length > TOOL_RESULT_OFFLOAD_LIMIT
|
|
69
|
+
if (!force && !overLimit) return text
|
|
70
|
+
try {
|
|
71
|
+
await cleanupOldToolResults(dir)
|
|
72
|
+
await mkdir(dir, { recursive: true })
|
|
73
|
+
const file = join(dir, `${Date.now()}-${String(callId).replace(/[^a-zA-Z0-9_-]/g, "_")}.log`)
|
|
74
|
+
await writeFile(file, text, "utf8")
|
|
75
|
+
if (!overLimit) return `${text}\n\n[... full content saved to: ${file}\nPage through it with the read tool (offset/limit) if you need the full text later.]`
|
|
76
|
+
return buildDualEndPreview(text, TOOL_RESULT_PREVIEW) + `\n\n[... output too large (${text.length} chars total), full content saved to: ${file}\n` +
|
|
77
|
+
`Page through it with the read tool (offset/limit) or sed -n 'START,ENDp' — do NOT re-run the tool blindly.]`
|
|
78
|
+
} catch {
|
|
79
|
+
// 写盘失败不吞报告:>LIMIT 走双端预览 + 原文案;≤LIMIT 正文整段在前(不谎称 truncated)
|
|
80
|
+
const body = overLimit ? buildDualEndPreview(text, TOOL_RESULT_PREVIEW) : text
|
|
81
|
+
return body + (overLimit ? `\n\n[... truncated: ${text.length} chars total, offload to disk failed]`
|
|
82
|
+
: `\n\n[... full text kept inline above (${text.length} chars), offload to disk failed]`)
|
|
83
|
+
}
|
|
84
|
+
}
|
package/agent/post-turn.mjs
CHANGED
|
@@ -13,26 +13,34 @@ export const GOAL_BUDGET_WARN_RATIO = 0.75
|
|
|
13
13
|
// 设计轮轮数注入阈值(AGENT-LOOP.md §6.6「设计轮轮数注入」· 台账 #1661):
|
|
14
14
|
// 5 = 在 persona 判定点(过 7 轮未落盘 ⇒ 降级)之前 3 轮给出计数;8 = 与 persona 同一判定点;
|
|
15
15
|
// 15 = persona 的首版预算(注入串里的 15 一律由它插值——改常量即改注入文本,不另留字面)。
|
|
16
|
+
// 2 = 每条链的注入帽(两档各一条:5 轮计数条 + 8 轮骨架判定条)——到帽即静默;
|
|
17
|
+
// 无帽时判据只有下界,长链逐轮重发同形句(实测 600+ 轮 ⇒ 600+ 条)。
|
|
16
18
|
export const DESIGN_TURN_NOTICE_AT = 5
|
|
17
19
|
export const DESIGN_TURN_SKELETON_AT = 8
|
|
18
20
|
export const DESIGN_FIRST_VERSION_TURNS = 15
|
|
21
|
+
export const DESIGN_TURN_NOTICE_MAX = 2
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
|
-
* 设计轮轮数提醒(纯函数——注入串 | `null`;判据源 = 链内累计轮号 +
|
|
24
|
+
* 设计轮轮数提醒(纯函数——注入串 | `null`;判据源 = 链内累计轮号 + 本设计轮是否落过盘 + 本链已注入条数)。
|
|
22
25
|
* 逐字注入形 = `AGENT-LOOP.md` §6.6「注入形逐字」;角色表当前一行(`eng-designer`),
|
|
23
26
|
* `eng-coder` 零注入(其零落笔面另由零落笔看门狗兜)。
|
|
24
|
-
*
|
|
27
|
+
* **何时发(有上限、有去重)**:每条链两档各一条——`notices` 0 ⇒ 5 轮起常行;1 ⇒ 8 轮起降级行(未落盘)∥ 常行(已落盘);
|
|
28
|
+
* 到帽(`DESIGN_TURN_NOTICE_MAX`)⇒ 静默。注入的唯一作用是让模型看见「已用轮次 + 是否落过盘」,该信息只在 5 轮与 8 轮各改一次判断。
|
|
29
|
+
* @param {{role?:string|null, turn?:number, wrote?:boolean, notices?:number}} o `turn` = 链内累计轮号(1 起)· `notices` = 本链已注入条数
|
|
25
30
|
* @returns {string|null}
|
|
26
31
|
*/
|
|
27
|
-
export function designTurnReminder({ role, turn, wrote } = {}) {
|
|
32
|
+
export function designTurnReminder({ role, turn, wrote, notices } = {}) {
|
|
28
33
|
if (role !== "eng-designer") return null
|
|
29
34
|
const used = Number(turn ?? 0)
|
|
30
35
|
if (!Number.isFinite(used) || used < DESIGN_TURN_NOTICE_AT) return null
|
|
36
|
+
const sent = Number(notices ?? 0)
|
|
37
|
+
if (!Number.isFinite(sent) || sent >= DESIGN_TURN_NOTICE_MAX) return null
|
|
31
38
|
const budget = DESIGN_FIRST_VERSION_TURNS
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
const normal = `[System reminder: design round turn ${used}/${budget} — ${wrote ? "something has been written to disk" : "nothing has been written to disk yet"}. First version budget is ${budget} turns; past 7 turns with nothing landed the rule is a skeleton + unresolved list.]`
|
|
40
|
+
if (sent === 0) return normal
|
|
41
|
+
if (used < DESIGN_TURN_SKELETON_AT) return null
|
|
42
|
+
if (wrote) return normal
|
|
43
|
+
return `[System reminder: design round turn ${used}/${budget} — nothing has been written to disk yet. The 7-turn mark has passed with nothing landed: degrade the delivery NOW — write the skeleton (design doc + batch record §2) plus an unresolved list, then refine in place.]`
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
/**
|
|
@@ -92,13 +100,19 @@ export function injectPostTurn(agent, results, recentCallSigs, callbacks, turn,
|
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
// 设计轮轮数注入(AGENT-LOOP.md §6.6 · 台账 #1661):轮号取 `_currentTurn`(链内累计、续跑不重置),
|
|
95
|
-
// 写入痕迹取 `_touchedFiles
|
|
103
|
+
// 写入痕迹取 `_touchedFiles`(六件写工具)∥ `_batchWrites`(batch 成功写盘计数)——两者与注入帽计数
|
|
104
|
+
// `_designTurnNotices` 都在 resume 保留集内 ⇒ 续跑段沿用前段痕迹;段内 `turn` 形参不参与判据。
|
|
105
|
+
// 注入帽计数与注入同址自增(判据与自增一处,不写第二份)。
|
|
96
106
|
const designReminder = designTurnReminder({
|
|
97
107
|
role: agent._role,
|
|
98
108
|
turn: agent._currentTurn ?? 0,
|
|
99
|
-
wrote: (agent._touchedFiles ?? []).length > 0,
|
|
109
|
+
wrote: (agent._touchedFiles ?? []).length > 0 || (agent._batchWrites ?? 0) > 0,
|
|
110
|
+
notices: agent._designTurnNotices ?? 0,
|
|
100
111
|
})
|
|
101
|
-
if (designReminder)
|
|
112
|
+
if (designReminder) {
|
|
113
|
+
agent.history.push({ role: "user", content: designReminder })
|
|
114
|
+
agent._designTurnNotices = (agent._designTurnNotices ?? 0) + 1
|
|
115
|
+
}
|
|
102
116
|
|
|
103
117
|
callbacks.onTurnEnd?.(agent, turn)
|
|
104
118
|
}
|
package/agent/record-results.mjs
CHANGED
|
@@ -26,8 +26,6 @@
|
|
|
26
26
|
import { pushReal } from "../context.mjs"
|
|
27
27
|
import { specForModel } from "../config.mjs"
|
|
28
28
|
import { FILE_MUTATORS, toolTouchPaths } from "./helpers.mjs"
|
|
29
|
-
// F-LC6(LIGHT-CHANNEL §2.9 · 台账 #1753):无账之笔提醒叶(谓词 + 文案 + 闩单源)。
|
|
30
|
-
import { unbookedPenNotice } from "./unbooked-pen.mjs"
|
|
31
29
|
import { capHistoryImages } from "../provider/normalize.mjs"
|
|
32
30
|
import { resolve } from "node:path"
|
|
33
31
|
import { advisorRuns, stripApprovedSuffix } from "../agent-tools/advisor-async.mjs"
|
|
@@ -36,6 +34,11 @@ import { looksLikeReviewOutput, advisorIncompleteMarker } from "../advisor/run.m
|
|
|
36
34
|
import { noteReviewDelivered } from "../agent-tools/review-facts.mjs"
|
|
37
35
|
// #1178:动作级只读分类(settings get ∥ manifest read 类)不失效 verify——谓词单源 = dispatch-gates。
|
|
38
36
|
import { isReadonlyAction } from "./dispatch-gates.mjs"
|
|
37
|
+
// 跨轮投影的**账本采集点**(CONTEXT-COMPACTION.md §1.1 · 台账 #2395):每一条工具结果入史的同时记一笔
|
|
38
|
+
// 运行记账(验证命令与结果摘要);变更文件面仍走 `_touchedFiles` 既有归集(不另立第二份清单)。
|
|
39
|
+
import { noteTurnToolFacts } from "./turn-projection.mjs"
|
|
40
|
+
// 归属表(收口取材的判据一):记账的同时写下「这笔写服务哪一批」——`_touchedFiles` 形状一字不动。
|
|
41
|
+
import { recordAttribution } from "./batch-attribution.mjs"
|
|
39
42
|
|
|
40
43
|
let _reindexFile = null
|
|
41
44
|
|
|
@@ -53,6 +56,8 @@ export async function recordToolResults(agent, toolByName, results) {
|
|
|
53
56
|
|
|
54
57
|
for (const { toolCall, result, ok } of results) {
|
|
55
58
|
const tool = toolByName.get(toolCall.name)
|
|
59
|
+
// 运行记账先于三条入史分支(多模态 ∥ 普通 ∥ 非视觉提醒)——一条结果只记一次。
|
|
60
|
+
noteTurnToolFacts(agent._turnLedger, { toolCall, result, ok })
|
|
56
61
|
// Multimodal tools return JSON { text, images } — inject as multimodal user message
|
|
57
62
|
if (tool?.multimodal && ok) {
|
|
58
63
|
try {
|
|
@@ -84,10 +89,7 @@ export async function recordToolResults(agent, toolByName, results) {
|
|
|
84
89
|
}
|
|
85
90
|
} catch { /* Parse failure doesn't affect normal tool messages */ }
|
|
86
91
|
}
|
|
87
|
-
|
|
88
|
-
// (零拦截——只拼回执文本、入史时机不变;命中后本会话不再提示)。
|
|
89
|
-
const penNotice = unbookedPenNotice(agent, toolCall, ok, tool)
|
|
90
|
-
pushReal(agent, { role: "tool", tool_call_id: toolCall.id, name: toolCall.name, content: penNotice ? result + penNotice : result })
|
|
92
|
+
pushReal(agent, { role: "tool", tool_call_id: toolCall.id, name: toolCall.name, content: result })
|
|
91
93
|
if (tool && ok) {
|
|
92
94
|
if (FILE_MUTATORS.has(toolCall.name)) {
|
|
93
95
|
// Direct file edit — code was changed. The prior advisor review and
|
|
@@ -139,7 +141,13 @@ export async function recordToolResults(agent, toolByName, results) {
|
|
|
139
141
|
// (含类型不可判——run 缺失的 legacy 直调)⇒ 不置「已覆盖」(与 settle 面
|
|
140
142
|
// 逐条 parity;设计评审保持计入——无代码面)。
|
|
141
143
|
const incomplete = advisorIncompleteMarker(String(result))
|
|
142
|
-
if (!(incomplete && run?.reviewType !== "design"))
|
|
144
|
+
if (!(incomplete && run?.reviewType !== "design")) {
|
|
145
|
+
agent._calledAdvisorThisRun = true
|
|
146
|
+
// ADVISOR-CONVERGENCE.md §6.4 B 复位点 2(同步面):评审覆盖成立 ⇒ 本未评审周期结束,
|
|
147
|
+
// 下一周期起于完整预算(未完成尾不计——与覆盖标记同一判据分摊)。
|
|
148
|
+
agent._advisorReminders = 0
|
|
149
|
+
agent._advisorHonestySent = false
|
|
150
|
+
}
|
|
143
151
|
if (reviewId !== undefined) {
|
|
144
152
|
if (run) {
|
|
145
153
|
run.round++
|
|
@@ -168,10 +176,12 @@ export async function recordToolResults(agent, toolByName, results) {
|
|
|
168
176
|
try {
|
|
169
177
|
const args = JSON.parse(toolCall.arguments)
|
|
170
178
|
const paths = toolTouchPaths(tool, args)
|
|
179
|
+
const touched = []
|
|
171
180
|
for (const p of paths) {
|
|
172
181
|
if (typeof p !== "string" || !p) continue // 非字符串项不拖累合法路径(与 dispatch / VSC 消费面同口径)
|
|
173
182
|
const abs = resolve(agent.cwd, p)
|
|
174
183
|
if (!agent._touchedFiles.includes(abs)) agent._touchedFiles.push(abs)
|
|
184
|
+
touched.push(abs)
|
|
175
185
|
if (agent.memory) {
|
|
176
186
|
// Fire-and-forget: don't block the agent loop on indexing.
|
|
177
187
|
// Reuses a single cached import; errors surface as pending reminders on next turn.
|
|
@@ -184,6 +194,8 @@ export async function recordToolResults(agent, toolByName, results) {
|
|
|
184
194
|
})
|
|
185
195
|
}
|
|
186
196
|
}
|
|
197
|
+
// 归属与路径同一笔记(`agent._batchDoc` 由 spawn 绑定;未绑定 ⇒ 不入表,收口按本批判)。
|
|
198
|
+
recordAttribution(agent, touched, agent._batchDoc)
|
|
187
199
|
} catch { /* #327:畸形 args(含 null)/ 畸形路径不再裸抛——touchedFiles 尽力而为 */ }
|
|
188
200
|
}
|
|
189
201
|
}
|