@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/advisor.mjs
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* The agent calls this explicitly to get an independent review.
|
|
4
4
|
* The top-level `type` is REQUIRED and must be exactly "code" or "design"
|
|
5
5
|
* (F30 fail-closed — no silent default; ADVISOR-GUARDS.md §2.4).
|
|
6
|
-
* AGENT-LOOP-ASYNC-POOL.md §6.10 (R13 — async advisor):
|
|
7
|
-
* background pool
|
|
8
|
-
*
|
|
6
|
+
* AGENT-LOOP-ASYNC-POOL.md §6.10 (R13 — async advisor): `async` is REQUIRED — `true` launches the
|
|
7
|
+
* review into the background pool at depth 0, `false` forces the blocking review (omitting it is
|
|
8
|
+
* refused: a default here would decide for the caller); depth>0 (eng-coder self-review) stays
|
|
9
|
+
* synchronous always.
|
|
9
10
|
*/
|
|
10
11
|
import { runAdvisorReview, advisorIncompleteMarker, ADVISOR_LAUNCH_REFUSAL_PREFIX } from "../advisor/run.mjs"
|
|
11
12
|
import { resolveBatchDocPath } from "./batch.mjs"
|
|
@@ -22,7 +23,10 @@ import {
|
|
|
22
23
|
} from "./advisor-async.mjs"
|
|
23
24
|
// F30/F31(2026-09-18 顾问面治理批):类型门判定 / 拒发串 / 对象标识行——单源 `advisor/notice.mjs`
|
|
24
25
|
// (文案逐字 = ADVISOR-GUARDS.md §2.4 / §2.5);零计数载体(计数护栏随撤 cap 整体退场)。
|
|
25
|
-
import { typeGateCriterion, buildTypeGateRefusal, scopeSummary, withIdentityLine } from "../advisor/notice.mjs"
|
|
26
|
+
import { typeGateCriterion, buildTypeGateRefusal, identityLine, scopeSummary, withIdentityLine } from "../advisor/notice.mjs"
|
|
27
|
+
// 账链门判据(设计单源 = `docs/core/design/ADVISOR-GUARDS.md` §2 第 7 条):批档之外还须有未决台账行指着它。
|
|
28
|
+
// 判据档零静态仓内依赖(台账链在档内动态 import——W8 契约②),故本档可静态引用。
|
|
29
|
+
import { resolveBatchLedgerLink } from "./batch-ledger-link.mjs"
|
|
26
30
|
// #15 描述外置:描述文本单点 = tool-docs/advisor.md(DESC 单解析面,缺档抛错语义不变)
|
|
27
31
|
import { DESC } from "../tools/shared.mjs"
|
|
28
32
|
|
|
@@ -31,6 +35,61 @@ import { DESC } from "../tools/shared.mjs"
|
|
|
31
35
|
// here for the tests' import surface (implementation re-exported).
|
|
32
36
|
export { validateDesignToken } from "./advisor-async.mjs"
|
|
33
37
|
|
|
38
|
+
/**
|
|
39
|
+
* `batchDoc` 缺失形态(缺失 ∥ `null` ∥ 空串 ∥ 纯空白——非字符串不在此判,留给 `resolveBatchDocPath` 的既有文案)。
|
|
40
|
+
*/
|
|
41
|
+
function missingBatchDoc(raw) {
|
|
42
|
+
return raw === undefined || raw === null || (typeof raw === "string" && raw.trim() === "")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 设计评审准入门拒文(**逐字**——单源 `docs/core/design/ADVISOR-GUARDS.md` §2 第 6 条):首行 = 稳定前缀
|
|
47
|
+
* `Advisor: launch refused` + 标识行(与类型门同族形态);其后 Why + 两个期望形 + 可执行的下一步 + 收尾句。
|
|
48
|
+
* 与类型门的唯一形态偏差 = 多一句「没有批档 ⇒ 先建档」:本门判的是「参数在不在」,用户知道怎么传不等于
|
|
49
|
+
* 知道没档时怎么办。
|
|
50
|
+
*/
|
|
51
|
+
function buildBatchDocRefusal(identity) {
|
|
52
|
+
return [
|
|
53
|
+
`Advisor: launch refused — a design review must carry \`batchDoc\`: the batch record this review belongs to. ${identity}`,
|
|
54
|
+
"Why: the token a design review issues is closed by its batch — closing that record consumes it. A review with no batch mints a token nothing can close: it rides the 7-day TTL and nothing else. Refusing the review at launch is how that token never exists.",
|
|
55
|
+
"Expected form 1 — project-root-relative: docs/batches/<batch>-<topic>.md (resolved against the session project root).",
|
|
56
|
+
"Expected form 2 — absolute: D:\\repo\\docs\\batches\\<batch>-<topic>.md (used as-is).",
|
|
57
|
+
'No batch record in flight: create one first — batch({action:"create", …}) — one command; the record is the premise of the review, not paperwork.',
|
|
58
|
+
"Nothing was sent: no review instance, no round consumed, no design token minted, no LLM call.",
|
|
59
|
+
].join("\n")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 账链门拒文(**逐字**——单源 `docs/core/design/ADVISOR-GUARDS.md` §2 第 7 条):首行 = 稳定前缀
|
|
64
|
+
* `Advisor: launch refused` + 标识行(与准入门同族形态);其后 Why + `Record:` 读数 + 三条修法 + 收尾句。
|
|
65
|
+
*
|
|
66
|
+
* 偏差(相对准入门)= 判据从「参数在不在」进到「账在不在」,因此多一行 `Record:` 读数值:让下一步可判——
|
|
67
|
+
* 是行丢了(`db: open` ∧ `unsettled: 0`),还是库根本不在盘(`db: not on disk`,Fix 1 无行可改)。
|
|
68
|
+
*/
|
|
69
|
+
function buildBatchNoLedgerRefusal({ batchDocAbs, chain, scope }) {
|
|
70
|
+
const dbText = chain.db === "open"
|
|
71
|
+
? `open at ${chain.dbFile}`
|
|
72
|
+
: chain.db === "not-on-disk"
|
|
73
|
+
? `not on disk at ${chain.dbFile}`
|
|
74
|
+
: chain.db === "unreadable"
|
|
75
|
+
? `unreadable at ${chain.dbFile}`
|
|
76
|
+
: "—" // 无项目根:没有库位可点名(`ledger base: —` 同因)
|
|
77
|
+
return [
|
|
78
|
+
`Advisor: launch refused — a design review needs its batch record to carry an unsettled ledger row. ${identityLine({
|
|
79
|
+
type: "design",
|
|
80
|
+
scope,
|
|
81
|
+
round: "—", // 判定先于实例解析——本次发起无轮次(§2 第 5 条字段行)
|
|
82
|
+
criterion: "batchdoc-no-ledger",
|
|
83
|
+
})}`,
|
|
84
|
+
`Why: the record says the work is in flight, the ledger says whose work it is — and no unsettled row points at this record (reason=${chain.reason}).`,
|
|
85
|
+
`Record: ${batchDocAbs} — ledger base: ${chain.root ?? "—"} · db: ${dbText} · rows whose task_book resolves here: ${chain.rows} (unsettled: ${chain.unsettled}).`,
|
|
86
|
+
'Fix 1 (the row was archived, still recoverable): ledger({action:"update", id:<N>, status:"在途"}) — 待核销 → 在途 是六态唯一的回退边; then ledger({action:"update", id:<N>, task_book:"<仓根相对指针>"}). Row is 已核销 / 已废弃 ⇒ that edge is gone, use Fix 2.',
|
|
87
|
+
'Fix 2 (this record is the right home, no row can come back): start a new record — batch({action:"create", …}) opens its ledger row in the same call — and launch the review under it.',
|
|
88
|
+
"Fix 3 (this record is finished): close it, and launch the review under the record that owns the work.",
|
|
89
|
+
"Nothing was sent: no review instance, no round consumed, no design token minted, no LLM call.",
|
|
90
|
+
].join("\n")
|
|
91
|
+
}
|
|
92
|
+
|
|
34
93
|
export const advisorTool = {
|
|
35
94
|
name: "advisor",
|
|
36
95
|
description: DESC("advisor"),
|
|
@@ -40,7 +99,7 @@ export const advisorTool = {
|
|
|
40
99
|
type: { type: "string", enum: ["code", "design"], description: "Review type (required): 'design' for design doc review, 'code' for code review. Omitting it is refused — there is no default." },
|
|
41
100
|
async: {
|
|
42
101
|
type: "boolean",
|
|
43
|
-
description: "Background review:
|
|
102
|
+
description: "Background review: Required — `true` = review in the background (ack now, report via digest); `false` = the blocking review; omitting it is refused. depth>0 → always sync: an explicit `async: true` there is refused.",
|
|
44
103
|
},
|
|
45
104
|
object: {
|
|
46
105
|
type: "object",
|
|
@@ -61,11 +120,11 @@ export const advisorTool = {
|
|
|
61
120
|
documents: {
|
|
62
121
|
type: "array",
|
|
63
122
|
items: { type: "string" },
|
|
64
|
-
description: "Doc paths to review (design / requirements / referenced docs). One rule: a relative path resolves against the session project root (e.g. docs
|
|
123
|
+
description: "Doc paths to review (design / requirements / referenced docs). One rule: a relative path resolves against the session project root (e.g. docs/<area>/<name>.md); an absolute path is used as-is. Accepted = an existing .md file anywhere inside a project (a repo-root doc counts); anything else is refused with the resolved path, the reason, and the two expected forms. The advisor reviews ONLY these — no git diff scan. Use for both review types to pass the task's docs list.",
|
|
65
124
|
},
|
|
66
125
|
batchDoc: {
|
|
67
126
|
type: "string",
|
|
68
|
-
description: "
|
|
127
|
+
description: "Optional: the batch record this review belongs to. Carrying it binds the review to that record on either track. On a design review the settlement writes the round's block into that record's §3 (tool stamp + a settlement header line + the review verbatim) in the same stroke that decides the token, and the reviewer gets no batch tool in engineering mode; a code review bound to a record keeps the §3 write channel (there is no settlement to write for it), and so does a reviewer in normal mode. A design review that omits it is refused at launch (a token with no batch has no closer); a path that does not resolve to a readable file is refused. Relative paths resolve against the session cwd first, then candidate project roots (project-root-relative e.g. <repo>/docs/batches/…, or absolute). A tool-face batch — delivered files are scripts / tests / CI, no design doc — runs on the code track and passes this same parameter together with `paths` = the delivered files.",
|
|
69
128
|
},
|
|
70
129
|
},
|
|
71
130
|
required: ["type"],
|
|
@@ -95,6 +154,50 @@ export const advisorTool = {
|
|
|
95
154
|
})
|
|
96
155
|
}
|
|
97
156
|
const reviewType = args.type
|
|
157
|
+
// §6.10 (R13):`async` 必填——**参数级拒判放在类型门之后、账链门之前**(缺参不该先花一次台账查;
|
|
158
|
+
// 也不该让“先补另一个参数”成为模型的下一步)。depth 不再替调用方选。
|
|
159
|
+
if (args.async !== true && args.async !== false) {
|
|
160
|
+
if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
|
|
161
|
+
return "Advisor: async is required — pass true for the background review or false for the blocking review. Nothing was sent: no review instance, no round consumed, no design token minted, no LLM call."
|
|
162
|
+
}
|
|
163
|
+
// 准入门:`type="design"` 且 `batchDoc` 缺失 / 空 ⇒ 拒发(判据与拒文 = `docs/core/design/ADVISOR-GUARDS.md`
|
|
164
|
+
// §2 第 6 条);「携了须可读」那半幅随账链门(下段)一并判——判据与文案仍单源 `resolveBatchDocPath`。
|
|
165
|
+
// 绑定落 `resolved.run`(评审实例键)。
|
|
166
|
+
// 理由:设计评审签出的 token 由关档收口,而关档只认批归属——批外签发的授权没有第二个关闭者
|
|
167
|
+
// (spawn 只校验不消费、关档消费对无归属槽不适用,只剩 7 天 TTL)⇒ 堵法是让这种授权根本发不出去。
|
|
168
|
+
// 位置 = 类型门之后、文档范围解析之前:类型诊断与「参数在不在」都先于范围诊断(真因不被次要报错掩盖),
|
|
169
|
+
// 且二者都先于实例解析 / 签发 / LLM(零实例 / 零 token / 零槽 / 零 LLM)。
|
|
170
|
+
if (reviewType === "design" && missingBatchDoc(args.batchDoc)) {
|
|
171
|
+
if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
|
|
172
|
+
return buildBatchDocRefusal(identityLine({
|
|
173
|
+
type: reviewType,
|
|
174
|
+
scope: scopeSummary(args.documents?.length ? args.documents : args.paths),
|
|
175
|
+
round: "—", // 判定先于实例解析——本次发起无轮次(§2 第 5 条字段行)
|
|
176
|
+
criterion: "batchdoc-missing",
|
|
177
|
+
}))
|
|
178
|
+
}
|
|
179
|
+
// 账链门(`docs/core/design/ADVISOR-GUARDS.md` §2 第 7 条):`type="design"` ∧ `batchDoc` 已解析为绝对路径且
|
|
180
|
+
// 可读 ⇒ 点火拍查一次账——本档还有没有 ≥1 行未决台账行(`PENDING_STATUSES` 四态)的 `task_book` 指着它;
|
|
181
|
+
// 查不出「有」⇒ 拒发(`criterion=batchdoc-no-ledger`,reason 三值),登记 `_advisorRefusals`。
|
|
182
|
+
// 理由:第 6 条只要求「参数在 + 路径可读」,账侧从头到尾不问——行被撤回 ∥ 被结 ∥ 被改挂之后,
|
|
183
|
+
// 评审照发、token 照签,收口时重锚不到任何行。
|
|
184
|
+
// 批档绝对路径在本门就要用 ⇒ `resolveBatchDocPath` 从绑定行提前到此处调一次(绑定行复用同值,不二次解析);
|
|
185
|
+
// 携了不可读 ⇒ 走其既有 throw(顺序表第 3 行:可读是账链的前提,前提坏先报前提)。
|
|
186
|
+
// 代码评审不走本门(账链门仍只判设计轨——代码轨不签 token,没有可关之物)。绑定面则与轨无关:
|
|
187
|
+
// 携 `batchDoc` 即在绑定行落 `resolved.run.batchDoc`(判据单源 = `docs/core/design/BATCH-LEDGER-REVIEW-UNIFY.md` §2.15)。
|
|
188
|
+
let designBatchDocAbs = null
|
|
189
|
+
if (reviewType === "design") {
|
|
190
|
+
designBatchDocAbs = resolveBatchDocPath(agent.cwd, args.batchDoc)
|
|
191
|
+
const chain = await resolveBatchLedgerLink({ batchDocAbs: designBatchDocAbs, anchor: agent.cwd })
|
|
192
|
+
if (!chain.ok) {
|
|
193
|
+
if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
|
|
194
|
+
return buildBatchNoLedgerRefusal({
|
|
195
|
+
batchDocAbs: designBatchDocAbs,
|
|
196
|
+
chain,
|
|
197
|
+
scope: scopeSummary(args.documents?.length ? args.documents : args.paths),
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
}
|
|
98
201
|
const documents = args.documents || null
|
|
99
202
|
// Scope fallback: the runtime mutation record (zero git) covers guard-triggered
|
|
100
203
|
// reviews where the model did not pass explicit paths.
|
|
@@ -115,14 +218,16 @@ export const advisorTool = {
|
|
|
115
218
|
const { invalid } = resolveReviewDocPaths(documents, agent.cwd)
|
|
116
219
|
if (invalid.length > 0) {
|
|
117
220
|
if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
|
|
118
|
-
// 拒发文案:既有稳定前缀逐字(行首)+ 逐文档「输入 → 解析后绝对路径 ∥ 拒因」+
|
|
119
|
-
const lines = invalid.map((v) => `- ${v.doc} → ${v.resolved ?? "(no base)"} ∥ reason=${v.reason}`)
|
|
120
|
-
if (invalid.some((v) => v.reason === "
|
|
221
|
+
// 拒发文案:既有稳定前缀逐字(行首)+ 逐文档「输入 → 解析后绝对路径 ∥ 拒因」+ 锚态(仅无唯一基根)+ 候选全列 + 期望形两句。
|
|
222
|
+
const lines = invalid.map((v) => `- ${v.doc} → ${v.resolved ?? "(no base)"} ∥ reason=${v.reason}${Array.isArray(v.sameName) && v.sameName.length > 0 ? `(盘上同名:${v.sameName.join(" ∥ ")})` : ""}`)
|
|
223
|
+
if (invalid.some((v) => v.reason === "ambiguous-path" || v.reason === "dangling-path")) {
|
|
121
224
|
const view = projectRootView(agent.cwd)
|
|
122
225
|
const where = view.state === "workspace" ? `workspace (${view.candidates.join(", ")})` : "none (no PROJECT-MANIFEST.json here or above)"
|
|
123
|
-
lines.push(`Session anchor is ${where} — no project root, so a relative path has no base to resolve against.`)
|
|
226
|
+
lines.push(`Session anchor is ${where} — no single project root, so a relative path has no base to resolve against.`)
|
|
227
|
+
const cands = [...new Set(invalid.flatMap((v) => v.candidates ?? []))]
|
|
228
|
+
if (cands.length > 0) lines.push(`Candidates: ${cands.join(" ∥ ")} — pass one explicitly (an absolute path is the surest form).`)
|
|
124
229
|
}
|
|
125
|
-
lines.push("Expected form 1 — project-root-relative: docs
|
|
230
|
+
lines.push("Expected form 1 — project-root-relative: docs/<area>/<name>.md (resolved against the session project root).", "Expected form 2 — absolute: D:\\repo\\docs\\<area>\\<name>.md (used as-is).")
|
|
126
231
|
return withIdentityLine(
|
|
127
232
|
`Advisor: design review documents must be documentation files (per the project's conventions). Invalid:\n${lines.join("\n")}`,
|
|
128
233
|
{ type: reviewType, scope: scopeSummary(documents), round: "—", criterion: "scope-not-doc" },
|
|
@@ -130,37 +235,35 @@ export const advisorTool = {
|
|
|
130
235
|
}
|
|
131
236
|
}
|
|
132
237
|
|
|
133
|
-
// §6.10 (R13 — ruling ②-3 A)
|
|
134
|
-
//
|
|
135
|
-
// an explicit async:true there is rejected, the default never flips.
|
|
136
|
-
// depth 显式校验(归一形态——判定单点:`depth` 取一次 + `asyncRequested` 显式布尔,
|
|
137
|
-
// 判定表与原逐值等价):
|
|
138
|
-
// depth 0 + 未传/true ⇒ 异步(本层默认)/ depth 0 + false ⇒ 同步;
|
|
139
|
-
// depth>0(或直调方无 depth) + 显式 true ⇒ 拒;其余 ⇒ 同步。
|
|
140
|
-
// 「无 depth」= 无 dispatch 上下文的直调方(测试/legacy)——按同步处理。
|
|
238
|
+
// §6.10 (R13 — ruling ②-3 A):depth 0 可异步、depth>0 一律同步——显式 `async:true` 在那里被拒
|
|
239
|
+
// (判据不变)。“无 depth” = 无 dispatch 上下文的直调方(测试/legacy)——按同步处理。
|
|
141
240
|
const depth = ctx?.depth ?? null
|
|
142
241
|
const asyncRequested = args.async === true
|
|
143
242
|
if (asyncRequested && depth !== 0) {
|
|
144
243
|
// 拒发登记(与 cap/池满拒同款):评审未跑——不置 called/不耗轮次(record-results
|
|
145
244
|
// 的 REFUSED 契约——advisor 评审发现 #1:拒发不得静默满足 guard)。
|
|
146
245
|
if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
|
|
147
|
-
return "Advisor: async reviews are only available at depth 0 — the top-level session owns the background pool; inside a child (eng-coder self-review) reviews run synchronously. Call advisor again
|
|
246
|
+
return "Advisor: async reviews are only available at depth 0 — the top-level session owns the background pool; inside a child (eng-coder self-review) reviews run synchronously. Call advisor again with async:false."
|
|
148
247
|
}
|
|
149
|
-
const isAsync = asyncRequested
|
|
248
|
+
const isAsync = asyncRequested
|
|
150
249
|
|
|
250
|
+
// BATCH-RECORD.md §4.2 评审侧批次档绑定(判据单源 = `docs/core/design/BATCH-LEDGER-REVIEW-UNIFY.md` §2.15):
|
|
251
|
+
// 绑定值在**发起时点取一次**,随后随 launch 载荷一路传下去(异步 = 条目 `batchDoc` 字段,同步 = callbacks)。
|
|
252
|
+
// 为什么不能在启动时读活字段:`resolved.run` 是实例级对象(代码轨续用同一实例)——发起①携 A 排队、
|
|
253
|
+
// 发起②携 B 覆盖同一字段,槽释放后①启动读到 B,评审就把裁定写进一本它没被指派的档。
|
|
254
|
+
// 不携即清:这一笔不携档(缺 / null / 空串 / 纯空白)⇒ null,不继承上一笔(静默继承比没有绑定更坏)。
|
|
255
|
+
// 位置 = 实例解析之前:路径不可读 ⇒ 在建实例与记账镜之前就炸(本档不变量「零实例 / 零 token / 零槽」)。
|
|
256
|
+
const launchBatchDoc = missingBatchDoc(args.batchDoc)
|
|
257
|
+
? null
|
|
258
|
+
// 设计评审的绝对路径由账链门那一段算好(`designBatchDocAbs`——不二次解析);代码评审仍走原解析。
|
|
259
|
+
: designBatchDocAbs ?? resolveBatchDocPath(agent.cwd, args.batchDoc)
|
|
151
260
|
// Per-review instance resolution (§6.10 ③ — ruling ②-5 A): fix rounds
|
|
152
261
|
// continue the same reviewId (design = the doc-set instance's designId —
|
|
153
262
|
// slot/spawn continuity; code = the newest OPEN instance). The resolution
|
|
154
263
|
// scopes agent._advisorRound/_lastAdvisorOutput so the message builder and
|
|
155
264
|
// the run.mjs cap read THIS instance's round/prior (multi-review isolation).
|
|
156
265
|
const resolved = resolveAdvisorLaunch(agent, reviewType, { documents })
|
|
157
|
-
|
|
158
|
-
// 口径 = **「若传则须可读」**(空/不可读 → throw;不强制必传——无批次档的在途设计评审
|
|
159
|
-
// 零回归,N5);绑定落在 resolved.run(评审实例键,与 reviewType/round/designId 同族)——
|
|
160
|
-
// 并发设计评审各绑各档,不用单值会话态(BATCH-RECORD.md §4.7 #6)。
|
|
161
|
-
if (args.batchDoc !== undefined && args.batchDoc !== null) {
|
|
162
|
-
resolved.run.batchDoc = resolveBatchDocPath(agent.cwd, args.batchDoc)
|
|
163
|
-
}
|
|
266
|
+
resolved.run.batchDoc = launchBatchDoc
|
|
164
267
|
// Design token minted for EVERY design round — the reviewer echoes it only on
|
|
165
268
|
// a clean pass; on pass it is slotted under the instance's designId at settle
|
|
166
269
|
// (sync: right here; async: the settle callback — fix #2). A NEW instance
|
|
@@ -177,6 +280,8 @@ export const advisorTool = {
|
|
|
177
280
|
const ack = launchAsyncAdvisor(agent, ctx, {
|
|
178
281
|
reviewType, documents, paths, object: reviewObject,
|
|
179
282
|
designToken, designId, run: resolved.run,
|
|
283
|
+
// 逐笔绑定快照:条目持此值,`entry.start()` 不再读活的 `run.batchDoc`(排队窗口的值会被后一笔覆盖)。
|
|
284
|
+
batchDoc: launchBatchDoc,
|
|
180
285
|
})
|
|
181
286
|
if (ack.error) {
|
|
182
287
|
// Pool-full refusal (②-6a — no queueing): the review did NOT launch — the
|
|
@@ -220,8 +325,8 @@ export const advisorTool = {
|
|
|
220
325
|
const result = await runAdvisorReview(agent, reviewType, {
|
|
221
326
|
onOutput: ctx.onOutput,
|
|
222
327
|
signal: ctx.signal,
|
|
223
|
-
//
|
|
224
|
-
batchDoc:
|
|
328
|
+
// 同步路径的绑定传递 = 同一逐笔值(异步路径走条目 `batchDoc` 字段,同值同形)。
|
|
329
|
+
batchDoc: launchBatchDoc,
|
|
225
330
|
}, designToken, documents, paths, reviewObject, designId)
|
|
226
331
|
|
|
227
332
|
// B 启动拒绝(稳定前缀):拒发登记(同池满 / cap 款——不置 called、不耗轮次),
|
|
@@ -139,7 +139,7 @@ export function parkAsyncPending(parent, entry) {
|
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* §6.31.5 升级账本写助手(消化账务批):`_unsettledDigests` 追加一行
|
|
142
|
-
* (`{ id, role,
|
|
142
|
+
* (`{ id, role, missRounds, report, at }`)。载体吸收(父字段优先 / history 借用——形态同
|
|
143
143
|
* `parkAsyncPending`);行序 = 升级序(读面 = `digest-account.mjs` `unsettledRows`)。
|
|
144
144
|
*/
|
|
145
145
|
export function appendUnsettledDigest(parent, row) {
|
|
@@ -187,7 +187,7 @@ export function releaseSettledEntry(entry) {
|
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
189
|
* §6.31.4 投递面(消化账务批 · 2026-10-05 · 台账 #930):会话态注入后**仅**释放 `childAgent`——
|
|
190
|
-
* `report` 保留至销账 /
|
|
190
|
+
* `report` 保留至销账 / 升级(升级终局披露需原文;驻留增量以报告量级 ∥ 未签收条数封顶)。fallback 面零调用
|
|
191
191
|
* (既有 `releaseSettledEntry` 逐字沿用——注入即释放)。
|
|
192
192
|
*/
|
|
193
193
|
export function releaseChildHold(entry) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* audit-block.mjs — 审计块构造器(AGENT-LOOP-SUBAGENT.md §6.26 · 台账 #23)。
|
|
3
3
|
*
|
|
4
|
-
* 自 `subagent-spawn.mjs` **逐字搬移**(D23-3 外提:spawn 档越 300
|
|
4
|
+
* 自 `subagent-spawn.mjs` **逐字搬移**(D23-3 外提:spawn 档越 300 行线 + 块构造成纯函数
|
|
5
5
|
* ⇒ 判据可直测;D23-4:块内文本零改——含块内自指词,整块搬移不改真值)。本档承载
|
|
6
6
|
* spawn 级固定机制性指令的第二块(审计模板 + 批档 §2 指向 + touched 快照):
|
|
7
7
|
* 装配侧只收集(`thincoder-core/agent-tools/subagent-spawn.mjs`),下发面 = system 固块
|
|
8
8
|
* (`child._spawnSystemBlock` → 核 `prepareRun` 拼接——`thincoder-core/agent/setup.mjs`)。
|
|
9
9
|
*
|
|
10
|
-
* 2026-10-24(§6.22 KD-SC6):任务书 =
|
|
10
|
+
* 2026-10-24(§6.22 KD-SC6):任务书 = 绑定批档,按角色切片(§8.1 现行;本块只引交付任务书 = §2);A2 拼装摘要面(按 marker 抽取
|
|
11
11
|
* 设计档 / 文件清单 / 验收三段)已随 KD-SC6 删除——审计块只注入批档路径行 + §2 指向句(路径取
|
|
12
12
|
* `ctx.agent._batchDoc`)。理由:工程角色 `_engTaskInput` 只剩一行机械文本,摘要失去来源。
|
|
13
13
|
*/
|
|
@@ -37,7 +37,7 @@ export function buildAuditBlock(ctx) {
|
|
|
37
37
|
`workspace changes not listed there are unrelated to this delivery and are NOT grounds for an out-of-list finding.\n` +
|
|
38
38
|
`Scope discipline (F-TS6 A1): read ONLY the audited files and the design-doc sections relevant to this delivery — do NOT re-read whole documents.\n` +
|
|
39
39
|
`Every deviation item MUST be fieldized: file:line + design reference (doc path + section/AC id) + severity + evidence (quoted code or doc text).\n` +
|
|
40
|
-
// §6.22 KD-SC6:任务书 =
|
|
40
|
+
// §6.22 KD-SC6:任务书 = 绑定批档,按角色切片(§8.1)——审计块注入批档路径 + 交付任务书 §2 的指向句
|
|
41
41
|
// (A2 拼装摘要面已删:工程角色 _engTaskInput = 一行机械文本,摘要无来源)。审计子代理本身是
|
|
42
42
|
// explore(任务书 = 父侧五项)——故指向句限定为「**交付**的任务书 = §2」,不冒称本 child 的唯一通道。
|
|
43
43
|
`Batch record (batchDoc): ${batchDoc}\n` +
|
|
@@ -49,9 +49,9 @@ export function buildAuditBlock(ctx) {
|
|
|
49
49
|
"Zero-git scope authority: this audit task receives NO git context — nothing is injected. " +
|
|
50
50
|
"The evidence base is the design documents, the current disk state (read/glob/grep), and the _touchedFiles list above. " +
|
|
51
51
|
"Workspace changes NOT listed in _touchedFiles are unrelated to this delivery — they are NOT grounds for an out-of-file-list finding." +
|
|
52
|
-
// §6.7.6
|
|
53
|
-
//
|
|
54
|
-
// 前导 \n
|
|
52
|
+
// §6.7.6(AGENT-LOOP-SUBAGENT.md):审计预算句——审计指令模板 + 批档指向块之后、审计报告模板之前(定序——评审 #7)。
|
|
53
|
+
// 逐字设计锚(§6.7.6 的「审计效率」行):只读该读的——10 轮机械预算——超时报 PROBLEM 下结论。
|
|
54
|
+
// 前导 \n 与审计报告模板同款块分隔约定(上一句 Zero-git 句末无换行——不触碰既有句)。
|
|
55
55
|
`\n[Audit budget — mechanical]: read ONLY the touched files listed above and the design-doc sections the parent task book names (affected-files table, acceptance criteria, status line). Do NOT read whole documents. Budget = 10 tool rounds max — if you cannot conclude within it, report PROBLEM (inconclusive) rather than continuing to explore.\n` +
|
|
56
56
|
// §6.7.6 D-TS6 A3:审计输出报告格式模板(三态——字段化行——不让模型自由发挥)。
|
|
57
57
|
`\n[Audit report format — mechanical template:]\n` +
|
|
@@ -38,6 +38,8 @@ import { cleanupOldToolResults, escapeXml } from "../agent/helpers.mjs"
|
|
|
38
38
|
import { pushReal } from "../context.mjs"
|
|
39
39
|
import { makeDecoder, sanitizeOutput } from "../tools/shared.mjs"
|
|
40
40
|
import { killProcessTree } from "../tools/process-tree.mjs"
|
|
41
|
+
// 过程档标记(TOOLS.md §6.28):后台径的结算摘要也是输出行——解析基准 = entry 记下的 spawn 局部 `cwd`。
|
|
42
|
+
import { markProcessDocLines } from "../tools/process-doc-mark.mjs"
|
|
41
43
|
import { buildBashEnv } from "../tools/bash.mjs"
|
|
42
44
|
import {
|
|
43
45
|
bindChildController, buildChildSignal, carrierField, getAsyncPool, parkAsyncPending,
|
|
@@ -119,7 +121,7 @@ export async function launchBgTask(parent, ctx, { command, timeout = null, shell
|
|
|
119
121
|
consumeSubagentToken(parent, id, "bash async launch", "bash")
|
|
120
122
|
assertPoolKeyFree(pool, id, "bash")
|
|
121
123
|
const logPath = join(dir, `${Date.now()}-bash-${id}.log`)
|
|
122
|
-
const cwd = ctx?.cwd ?? parent.cwd
|
|
124
|
+
const cwd = ctx?.cwd ?? parent.cwd
|
|
123
125
|
// UTF-8 码页前缀 = 同步径同款(win32 + 默认 shell);解码走 `makeDecoder`(同源)。
|
|
124
126
|
const effectiveCommand = process.platform === "win32" && !shell ? `chcp 65001 >nul && ${command}` : command
|
|
125
127
|
const child = spawn(effectiveCommand, [], {
|
|
@@ -132,6 +134,8 @@ export async function launchBgTask(parent, ctx, { command, timeout = null, shell
|
|
|
132
134
|
})
|
|
133
135
|
const entry = {
|
|
134
136
|
id, role: "bg", command, child, logPath,
|
|
137
|
+
// 解析基准 = 传给 spawn 的那个局部值(`ctx.cwd` 缺省时它跟着 undefined,另取就错位)
|
|
138
|
+
cwd,
|
|
135
139
|
status: "running", done: false, cancelled: false, discarded: false,
|
|
136
140
|
startedAt: Date.now(), endedAt: null, exit: null, killed: null, error: null,
|
|
137
141
|
report: null, tail: "", tailDropped: false, bytes: 0,
|
|
@@ -211,7 +215,7 @@ function finalizeBgEntry(parent, entry, { code = null, signal = null, background
|
|
|
211
215
|
wakeAsyncWaiters(parent)
|
|
212
216
|
}
|
|
213
217
|
|
|
214
|
-
/** 注入面尾截(双帽 +
|
|
218
|
+
/** 注入面尾截(双帽 + 截尾判据:行帽/字符帽/环形缓冲丢头三径合一),截帽完成后接过程档打标。 */
|
|
215
219
|
function renderTail(entry) {
|
|
216
220
|
let text = String(entry.tail ?? "")
|
|
217
221
|
let truncated = entry.tailDropped === true
|
|
@@ -224,6 +228,8 @@ function renderTail(entry) {
|
|
|
224
228
|
text = text.slice(-DIGEST_TAIL_MAX_CHARS)
|
|
225
229
|
truncated = true
|
|
226
230
|
}
|
|
231
|
+
// §6.28:两个消费点(`finalizeBgEntry` 的 `entry.report` ∥ `injectBgResult` 拼 body)同得标好的文本
|
|
232
|
+
text = markProcessDocLines(text, entry.cwd)
|
|
227
233
|
return { text, truncated }
|
|
228
234
|
}
|
|
229
235
|
|