@thincoder/core 0.11.5 → 0.12.1
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 +27 -0
- package/abort-provenance.mjs +23 -0
- package/advisor/citations.mjs +5 -1
- package/advisor/compaction.mjs +13 -10
- package/advisor/history.mjs +6 -1
- package/advisor/loop.mjs +35 -10
- package/advisor/messages.mjs +31 -43
- package/advisor/project-context.mjs +49 -45
- package/advisor/run.mjs +82 -26
- package/advisor.mjs +40 -11
- package/agent/assemble.mjs +5 -5
- package/agent/chat-call.mjs +21 -1
- package/agent/completion.mjs +1 -20
- package/agent/dispatch-gates.mjs +8 -3
- package/agent/dispatch-run.mjs +131 -20
- package/agent/dispatch.mjs +23 -22
- package/agent/family-tools.mjs +4 -7
- package/agent/goal-judge.mjs +99 -0
- package/agent/goal-state.mjs +96 -0
- package/agent/helpers.mjs +13 -4
- package/agent/offload.mjs +1 -1
- package/agent/planning-graph-guardrail.mjs +224 -0
- package/agent/planning-prompt.mjs +179 -0
- package/agent/planning-step.mjs +460 -173
- package/agent/post-turn.mjs +23 -33
- package/agent/record-results.mjs +8 -5
- package/agent/run-stages.mjs +18 -38
- package/agent/run-start.mjs +26 -19
- package/agent/setup-reminders.mjs +16 -14
- package/agent/setup.mjs +3 -2
- package/agent/spawn-child.mjs +17 -4
- package/agent/suspension.mjs +42 -21
- package/agent/task-lifecycle.mjs +165 -52
- package/agent/timers.mjs +9 -1
- package/agent/turn-loop.mjs +160 -69
- package/agent/turn-projection.mjs +26 -15
- package/agent/turn-task-state.mjs +4 -4
- package/agent/write-gate-ledger.mjs +1 -1
- package/agent/write-gate.mjs +14 -11
- package/agent-tools/advisor-async.mjs +2 -0
- package/agent-tools/advisor-launch.mjs +27 -13
- package/agent-tools/advisor-settle.mjs +19 -18
- package/agent-tools/advisor.mjs +90 -13
- package/agent-tools/bash-async.mjs +3 -3
- package/agent-tools/batch-ledger-bind.mjs +8 -5
- package/agent-tools/batch-read.mjs +42 -0
- package/agent-tools/batch-record-write.mjs +20 -12
- package/agent-tools/batch-segment-vocab.mjs +6 -4
- package/agent-tools/batch-skeleton.mjs +43 -12
- package/agent-tools/consult.mjs +5 -1
- package/agent-tools/context.mjs +5 -4
- package/agent-tools/design-slots.mjs +7 -4
- package/agent-tools/design-token.mjs +3 -2
- package/agent-tools/doc-graph.mjs +257 -95
- package/agent-tools/escalate-async.mjs +4 -1
- package/agent-tools/goal.mjs +28 -95
- package/agent-tools/plan.mjs +1 -1
- package/agent-tools/review-facts.mjs +56 -7
- package/agent-tools/settings.mjs +35 -1
- package/agent-tools/ssh-transport.mjs +23 -22
- package/agent-tools/step.mjs +24 -4
- package/agent-tools/subagent-actions.mjs +6 -2
- package/agent-tools/subagent-async.mjs +4 -2
- package/agent-tools/subagent.mjs +1 -1
- package/agent-tools/task.mjs +73 -65
- package/agent-tools.mjs +3 -3
- package/agent.mjs +12 -3
- package/auto-think.mjs +16 -3
- package/browser/actions.mjs +5 -1
- package/browser/cdp.mjs +1 -1
- package/browser/pool.mjs +110 -17
- package/compaction-work-state.mjs +103 -13
- package/compress-form.mjs +29 -3
- package/config-defaults.mjs +27 -3
- package/config-io.mjs +3 -14
- package/config-normalize.mjs +24 -4
- package/config-presets.mjs +40 -26
- package/config-warn.mjs +30 -0
- package/config.mjs +139 -63
- package/context-degrade.mjs +4 -4
- package/context-push.mjs +20 -9
- package/context.mjs +65 -20
- package/doc-graph/anchors.mjs +39 -40
- package/doc-graph/clusters.mjs +49 -0
- package/doc-graph/code-parsers.mjs +494 -0
- package/doc-graph/context-pack.mjs +392 -0
- package/doc-graph/dir-signals.mjs +228 -0
- package/doc-graph/edges.mjs +231 -0
- package/doc-graph/format.mjs +70 -0
- package/doc-graph/gc-cmd.mjs +104 -0
- package/doc-graph/gc.mjs +112 -0
- package/doc-graph/glob-work-graph.mjs +307 -0
- package/doc-graph/golden-set.mjs +131 -0
- package/doc-graph/ls-work-graph.mjs +534 -0
- package/doc-graph/outline.mjs +377 -0
- package/doc-graph/output-annotations.mjs +85 -0
- package/doc-graph/process-docs.mjs +68 -0
- package/doc-graph/read-work-graph.mjs +91 -0
- package/doc-graph/rebuild-cmd.mjs +75 -0
- package/doc-graph/resolvers.mjs +322 -0
- package/doc-graph/roots.mjs +86 -0
- package/doc-graph/schema.mjs +110 -0
- package/doc-graph/search-augment.mjs +418 -0
- package/doc-graph/store.mjs +231 -0
- package/doc-graph/target-resolve.mjs +352 -0
- package/doc-graph/walk.mjs +87 -0
- package/doc-graph.mjs +583 -707
- package/explore-distill.mjs +52 -17
- package/generate-title.mjs +7 -4
- package/ledger-close.mjs +6 -6
- package/ledger-cmd.mjs +3 -3
- package/ledger-consistency.mjs +8 -6
- package/ledger-db.mjs +45 -10
- package/ledger-migrate.mjs +25 -10
- package/ledger-read.mjs +1 -1
- package/ledger-write-ops.mjs +6 -6
- package/ledger.mjs +2 -2
- package/model-context.mjs +54 -18
- package/model-specs.mjs +86 -67
- package/package.json +1 -1
- package/prompt-overlays.mjs +3 -3
- package/prompts/advisor-round1.md +6 -5
- package/prompts/common.md +16 -6
- package/prompts/consult-base.md +2 -1
- package/prompts/discipline-engineering.md +1 -1
- package/prompts/discipline-normal.md +12 -8
- package/prompts/knowledge/doc-lookup.md +2 -2
- package/prompts/knowledge/normal-batch-discipline.md +2 -2
- package/prompts/knowledge/normal-delivery-collaboration.md +3 -3
- package/prompts/knowledge/tool-advisor.md +2 -2
- package/prompts/knowledge/tool-apply-patch.md +1 -1
- package/prompts/knowledge/tool-bash.md +2 -2
- package/prompts/knowledge/tool-batch.md +4 -4
- package/prompts/knowledge/tool-glob.md +9 -2
- package/prompts/knowledge/tool-goal.md +9 -6
- package/prompts/knowledge/tool-grep.md +7 -2
- package/prompts/knowledge/tool-ls.md +11 -5
- package/prompts/knowledge/tool-lsp.md +1 -1
- package/prompts/knowledge/tool-operations.md +3 -2
- package/prompts/knowledge/tool-plan.md +1 -1
- package/prompts/knowledge/tool-read.md +7 -6
- package/prompts/knowledge/tool-repo-graph-read.md +12 -0
- package/prompts/knowledge/tool-repo-graph.md +12 -0
- package/prompts/knowledge/tool-step.md +1 -1
- package/prompts/knowledge/tool-subagent.md +2 -2
- package/prompts/knowledge/tool-task.md +10 -9
- package/prompts/knowledge/tool-tree.md +7 -1
- package/prompts/persona-eng-coder.md +1 -1
- package/prompts/persona-eng-designer.md +1 -1
- package/prompts/persona-engineering.md +2 -1
- package/prompts/persona-explore.md +1 -1
- package/prompts/persona-normal.md +7 -6
- package/prompts/persona-plan.md +2 -2
- package/prompts/planning-next-moves.md +7 -8
- package/provider/anthropic.mjs +53 -51
- package/provider/core.mjs +85 -34
- package/provider/errors.mjs +33 -10
- package/provider/google.mjs +244 -37
- package/provider/list-models.mjs +28 -14
- package/provider/responses-request.mjs +15 -9
- package/provider/responses.mjs +10 -8
- package/provider/sse.mjs +3 -6
- package/proxy-transport.mjs +228 -119
- package/rules-file.mjs +79 -0
- package/rules.mjs +13 -51
- package/session-lifecycle.mjs +32 -20
- package/team-ledger.mjs +7 -7
- package/think-off.mjs +37 -18
- package/token-window.mjs +48 -31
- package/tool-args.mjs +8 -8
- package/tool-docs/bash.md +1 -1
- package/tool-docs/glob.md +3 -1
- package/tool-docs/goal.md +2 -2
- package/tool-docs/grep.md +3 -1
- package/tool-docs/ls.md +7 -1
- package/tool-docs/read.md +1 -1
- package/tool-docs/repo_graph-read.md +3 -0
- package/tool-docs/repo_graph.md +3 -0
- package/tool-docs/tree.md +1 -1
- package/tools/bash.mjs +53 -8
- package/tools/browser.mjs +4 -4
- package/tools/file.mjs +34 -7
- package/tools/glob-dialect.mjs +57 -7
- package/tools/index.mjs +3 -7
- package/tools/patch.mjs +8 -7
- package/tools/process-doc-mark.mjs +13 -0
- package/tools/search.mjs +152 -37
- package/tools/shared.mjs +6 -0
- package/tools/tree.mjs +211 -8
- package/window-policy.mjs +205 -126
- package/prompts/knowledge/tool-doc-graph-read.md +0 -20
- package/prompts/knowledge/tool-doc-graph.md +0 -49
- package/prompts/knowledge/tool-peek.md +0 -10
- package/prompts/knowledge/tool-repo-outline.md +0 -4
- package/tool-docs/doc_graph-read.md +0 -3
- package/tool-docs/doc_graph.md +0 -3
- package/tool-docs/peek.md +0 -3
- package/tool-docs/repo_outline.md +0 -3
- package/tools/peek.mjs +0 -447
package/advisor/run.mjs
CHANGED
|
@@ -4,14 +4,49 @@
|
|
|
4
4
|
* and the context/limit/tail guards in compaction.mjs(第 11 批硬帽拆分——
|
|
5
5
|
* run.mjs 原 498/500;既有 import 面经 re-export 保持不变)。
|
|
6
6
|
*/
|
|
7
|
+
import { existsSync } from "node:fs"
|
|
8
|
+
import { isAbsolute, resolve } from "node:path"
|
|
7
9
|
import { findProvider } from "../config.mjs"
|
|
8
10
|
import { prepareAdvisorMessages } from "../advisor.mjs"
|
|
9
11
|
import { buildObjectDeclarationBlock, buildDesignApprovalBlock, reviewHoldsBatchWrite } from "./messages.mjs"
|
|
10
12
|
import { appendCitationReport } from "./citations.mjs"
|
|
13
|
+
import { findProjectContextRoot } from "./project-context.mjs"
|
|
11
14
|
import { runAdvisorToolLoop } from "./loop.mjs"
|
|
12
|
-
import { estimateTokens } from "./compaction.mjs"
|
|
15
|
+
import { estimateTokens, advisorIncompleteMarker } from "./compaction.mjs"
|
|
13
16
|
import { batchDocForReview } from "../agent-tools/batch.mjs"
|
|
14
17
|
import { buildBatchBrief } from "../agent-tools/batch-read.mjs"
|
|
18
|
+
import { projectRootView } from "../manifest-discovery.mjs"
|
|
19
|
+
import { resolveProjectRootForFile } from "../doc-graph.mjs"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 多项目父工作区下对齐 advisor 工作锚:
|
|
23
|
+
* - 单项目仓(`projectRootView(anchorCwd).state !== "workspace"`)恒原样返回 `anchorCwd`;
|
|
24
|
+
* - 多项目父工作区(如 `D:\teamcode`)下,若 `boundBatchDoc` / `documents` / `paths` 全部落入同一个子仓根,
|
|
25
|
+
* 则把 `advisorCwd` 对齐到该子仓根,避免评审员用仓内相对路径 `read` 时报 `ENOENT`。
|
|
26
|
+
*/
|
|
27
|
+
export function resolveAdvisorCwd(anchorCwd, { boundBatchDoc = null, documents = null, paths = null } = {}) {
|
|
28
|
+
if (!anchorCwd) return anchorCwd
|
|
29
|
+
const absAnchor = resolve(anchorCwd)
|
|
30
|
+
try {
|
|
31
|
+
if (projectRootView(absAnchor).state !== "workspace") return anchorCwd
|
|
32
|
+
const candidates = [
|
|
33
|
+
boundBatchDoc,
|
|
34
|
+
...(Array.isArray(documents) ? documents : []),
|
|
35
|
+
...(Array.isArray(paths) ? paths : []),
|
|
36
|
+
].filter((p) => typeof p === "string" && p.trim())
|
|
37
|
+
if (candidates.length === 0) return anchorCwd
|
|
38
|
+
const roots = new Set()
|
|
39
|
+
for (const raw of candidates) {
|
|
40
|
+
const abs = isAbsolute(raw) ? resolve(raw) : resolve(absAnchor, raw)
|
|
41
|
+
if (!existsSync(abs)) continue
|
|
42
|
+
const subRoot = resolveProjectRootForFile(abs, absAnchor)
|
|
43
|
+
if (subRoot && resolve(subRoot) !== absAnchor) roots.add(resolve(subRoot))
|
|
44
|
+
}
|
|
45
|
+
return roots.size === 1 ? [...roots][0] : anchorCwd
|
|
46
|
+
} catch {
|
|
47
|
+
return anchorCwd
|
|
48
|
+
}
|
|
49
|
+
}
|
|
15
50
|
|
|
16
51
|
// 拆分后 import 面(既有导出名逐一保面——re-export;谓词为本批新增)。
|
|
17
52
|
export { ADVISOR_THINKING_PLACEHOLDER, MAX_RESULT_CHARS, renderTimeline as _renderTimeline } from "./compaction.mjs"
|
|
@@ -37,16 +72,9 @@ export function resolveAdvisorProvider(agent) {
|
|
|
37
72
|
// 模型(渠道单值模型退场)⇒ 无 cfg.model 取父运行模型 `agent.provider?.model`;两者皆无 →
|
|
38
73
|
// chat 前 `assertProviderModel` fail-fast(不静默)。
|
|
39
74
|
const result = cfg.model ? { ...provider, model: cfg.model } : { ...provider, model: agent.provider?.model }
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
// 随行则显式档支先命中、off 意图作废)。`false`(非法原值)仍归一 `undefined`(零变)。
|
|
44
|
-
if (cfg.thinking === null) {
|
|
45
|
-
result.thinking = null
|
|
46
|
-
delete result.reasoningEffort
|
|
47
|
-
} else if (cfg.thinking === false) result.thinking = undefined // invalid raw value — normalized
|
|
48
|
-
else if (cfg.thinking !== undefined) result.thinking = cfg.thinking
|
|
49
|
-
if (cfg.reasoningEffort !== undefined) result.reasoningEffort = cfg.reasoningEffort
|
|
75
|
+
// 2026-12-03 批(台账 #133):模型语义参数(thinking ∥ reasoningEffort)**不再写到本克隆上**——
|
|
76
|
+
// 它们由 `resolveAdvisorModelParams(agent)` 单独算出,逐调用经 `chat(provider, { modelParams })` 下发
|
|
77
|
+
//(用户裁定「不应该有任何 provider 级别的模型参数」)。
|
|
50
78
|
return result
|
|
51
79
|
} catch (e) {
|
|
52
80
|
// Provider not found or lookup failed — fall back to main provider, but surface the reason
|
|
@@ -55,17 +83,29 @@ export function resolveAdvisorProvider(agent) {
|
|
|
55
83
|
}
|
|
56
84
|
const provider = { ...agent.provider }
|
|
57
85
|
if (cfg?.model) provider.model = cfg.model
|
|
58
|
-
//
|
|
59
|
-
// value is invalid for providers that expect undefined or an object.
|
|
60
|
-
if (cfg?.thinking === null) {
|
|
61
|
-
provider.thinking = null
|
|
62
|
-
delete provider.reasoningEffort // 继承档(主 provider)不得随显式 off 同行
|
|
63
|
-
} else if (cfg?.thinking === false) provider.thinking = undefined
|
|
64
|
-
else if (cfg?.thinking !== undefined) provider.thinking = cfg.thinking
|
|
65
|
-
if (cfg?.reasoningEffort !== undefined) provider.reasoningEffort = cfg.reasoningEffort
|
|
86
|
+
// 2026-12-03 批(台账 #133):模型语义参数不再写在 provider 克隆上——见 `resolveAdvisorModelParams`。
|
|
66
87
|
return provider
|
|
67
88
|
}
|
|
68
89
|
|
|
90
|
+
/** Advisor 的模型语义参数(2026-12-03 批,台账 #133):住**调用方设置对象** `agent.config.advisor`
|
|
91
|
+
*(`cfg.thinking` ∥ `cfg.reasoningEffort`),逐调用经 `chat(provider, { modelParams })` 下发,**不再写到
|
|
92
|
+
* provider 克隆上**(用户裁定「不应该有任何 provider 级别的模型参数」)。
|
|
93
|
+
* 台账 #329 / `MODEL-SPECS.md §15.4-3`:off 形须**活着到达载荷层**——载荷层 off 门首款 =
|
|
94
|
+
* `modelParams.thinking === null`(`provider/core.mjs` 的 `chatImpl`);归一为 `undefined` 会让该门永不开
|
|
95
|
+
* (effort 族 advisor 关思考静默失效)。显式 off 同清**继承档**(会话 `reasoningEffort` 不得随行——随行则
|
|
96
|
+
* 显式档支先命中、off 意图作废)。`false`(非法原值)仍归一「不设」(零变)。 */
|
|
97
|
+
export function resolveAdvisorModelParams(agent) {
|
|
98
|
+
const cfg = agent?.config?.advisor
|
|
99
|
+
const out = { ...(agent?.modelParams ?? {}) }
|
|
100
|
+
if (cfg?.thinking === null) {
|
|
101
|
+
out.thinking = null
|
|
102
|
+
delete out.reasoningEffort
|
|
103
|
+
} else if (cfg?.thinking === false) delete out.thinking // invalid raw value — normalized away
|
|
104
|
+
else if (cfg?.thinking !== undefined) out.thinking = cfg.thinking
|
|
105
|
+
if (cfg?.reasoningEffort !== undefined) out.reasoningEffort = cfg.reasoningEffort
|
|
106
|
+
return out
|
|
107
|
+
}
|
|
108
|
+
|
|
69
109
|
/** Review-looking guard (async settle parity): a markdown table row or ≥200 chars of prose counts as a prior. */
|
|
70
110
|
export function looksLikeReviewOutput(text) {
|
|
71
111
|
const trimmed = String(text ?? "").trim()
|
|
@@ -105,6 +145,8 @@ function buildPinnedBrief(reviewType, documents, batchBrief, object, designToken
|
|
|
105
145
|
export async function runAdvisorReview(agent, reviewType, callbacks, designToken = null, documents = null, paths = null, object = null, designId = null) {
|
|
106
146
|
const onOutput = callbacks?.onOutput
|
|
107
147
|
const signal = callbacks?.signal
|
|
148
|
+
// 整会话 usage(docs/cli/design/TUI.md §4):带回调的调用方(同步 tool 与异步评审池)把父会话 onUsage 传进来,读数进状态行;本身不消费 usage。
|
|
149
|
+
const onUsage = callbacks?.onUsage ?? null
|
|
108
150
|
const startTime = Date.now()
|
|
109
151
|
|
|
110
152
|
// Advisor reviews are ALWAYS available (2026-08-21 semantic refactor): the
|
|
@@ -115,9 +157,6 @@ export async function runAdvisorReview(agent, reviewType, callbacks, designToken
|
|
|
115
157
|
// 拒发预检**(原 cap 内防线 + 同 doc-set 连败停止内防线整体退场;轮次仅作提示词衰减与显示)。
|
|
116
158
|
// 失败路径的出口 = 失败结论块(`advisor-settle.mjs` 结算出口,两轨共用——ADVISOR-GUARDS.md §7)。
|
|
117
159
|
const provider = resolveAdvisorProvider(agent)
|
|
118
|
-
// Advisor always works in the agent's cwd — scope is defined by paths/documents.
|
|
119
|
-
const advisorCwd = agent.cwd
|
|
120
|
-
|
|
121
160
|
// BATCH-RECORD.md §4.3 批次档写通道的绑定——**与评审轨无关**:携了可读 `batchDoc` 即绑定
|
|
122
161
|
// (判据单源 = `docs/core/design/BATCH-LEDGER-REVIEW-UNIFY.md` §2.15)。同步路径 = 调用方(advisor
|
|
123
162
|
// 工具)传入的 callbacks.batchDoc(本笔发起时点的绑定值);异步路径 = 池条目 `entry.start()` 传入的
|
|
@@ -126,12 +165,14 @@ export async function runAdvisorReview(agent, reviewType, callbacks, designToken
|
|
|
126
165
|
// `§3` 只能编或永远挂着(用户 2026-11-01 11:43 否掉的那件事)。
|
|
127
166
|
// 绑定先于消息构建算一次:用户消息与定锚简报喂的是同一个判轨值,不是各算一次。
|
|
128
167
|
const boundBatchDoc = batchDocForReview(agent, documents, callbacks)
|
|
168
|
+
// 单仓恒取 agent.cwd;多项目父工作区下若批档/评审路径落于同一子仓,自动对齐子仓根防相对路径 ENOENT。
|
|
169
|
+
const advisorCwd = resolveAdvisorCwd(agent.cwd, { boundBatchDoc, documents, paths })
|
|
129
170
|
const writesSection3 = reviewHoldsBatchWrite(agent, reviewType, boundBatchDoc)
|
|
130
171
|
// 批档简报(`ADVISOR-GUARDS.md` §2.5):**一次算、两处消费**(与 `boundBatchDoc` ∥ `writesSection3` 同款)——
|
|
131
172
|
// 用户消息与压缩定锚简报喂同一个值;未绑定 ⇒ 空串(块不出现,这是调用方算出来的结果,不是签名替他选的默认)。
|
|
132
|
-
const batchBrief = buildBatchBrief(boundBatchDoc,
|
|
173
|
+
const batchBrief = buildBatchBrief(boundBatchDoc, advisorCwd)
|
|
133
174
|
|
|
134
|
-
const messages = prepareAdvisorMessages(agent, reviewType, designToken, documents, batchBrief, paths, null, object, designId, writesSection3)
|
|
175
|
+
const messages = prepareAdvisorMessages(agent, reviewType, designToken, documents, batchBrief, paths, null, object, designId, writesSection3, advisorCwd)
|
|
135
176
|
|
|
136
177
|
// B 启动断言(fail-closed——`ADVISOR-GUARDS.md §2` #2):设计评审请求内**必须**携带与本次签发 token 精确
|
|
137
178
|
// 对应的 Approval Signal——构建面补不上就拒绝启动(不发"请回显一个不存在的 token"的请求)。
|
|
@@ -158,6 +199,12 @@ export async function runAdvisorReview(agent, reviewType, callbacks, designToken
|
|
|
158
199
|
// `onStallRound: undefined` ⇒ 环路零行为——同步径(advisor 工具)不供钩子)。
|
|
159
200
|
const result = await runAdvisorToolLoop(provider, messages, onOutput, signal, agent, advisorCwd, null, reviewType, boundBatchDoc, pinned, {
|
|
160
201
|
onStallRound: callbacks?.onStall,
|
|
202
|
+
// 模型语义参数(2026-12-03 批,台账 #133):advisor 的 thinking ∥ reasoningEffort 住 `config.advisor`,
|
|
203
|
+
// 逐调用经 `chat(provider, { modelParams })` 下发(不再写到 provider 克隆上)。
|
|
204
|
+
modelParams: resolveAdvisorModelParams(agent),
|
|
205
|
+
// 整会话 usage:评审的模型轮也计进状态行(docs/cli/design/TUI.md §4)。
|
|
206
|
+
// 调用方没传 onUsage(headless / 直调)⇒ loop 内不交,不吞读数也不造 0。
|
|
207
|
+
onUsage,
|
|
161
208
|
})
|
|
162
209
|
|
|
163
210
|
// Host-verified citations (decision d698434): mechanically check every
|
|
@@ -169,7 +216,14 @@ export async function runAdvisorReview(agent, reviewType, callbacks, designToken
|
|
|
169
216
|
// F14/`ADVISOR-GUARDS.md §3`:解析候选 = cwd + 评审对象声明范围派生根(scope = documents + paths)。
|
|
170
217
|
let final = result
|
|
171
218
|
if (!result.trimStart().startsWith("Advisor:")) {
|
|
172
|
-
|
|
219
|
+
// P2-8:引文围栏 = 被审档的归属项目根(不是 advisorCwd)——workspace 锚未对齐时,
|
|
220
|
+
// advisorCwd 是 workspace 根,围栏会放过同 workspace 另一个项目的文件。
|
|
221
|
+
const scope = [...(documents ?? []), ...(paths ?? [])]
|
|
222
|
+
const citationBase = findProjectContextRoot(advisorCwd, scope) ?? advisorCwd
|
|
223
|
+
// scope 转绝对(相对 advisorCwd)——围栏基准换成归属项目根后,派生根必须按原锚解析,
|
|
224
|
+
// 否则 `resolve(base, 相对路径)` 会双重拼接。
|
|
225
|
+
const scopeAbs = scope.map((p) => (typeof p === "string" && p.trim() ? resolve(advisorCwd, p) : p))
|
|
226
|
+
final = appendCitationReport(result, citationBase, { scope: scopeAbs })
|
|
173
227
|
// Success path: keep the FULL review output for convergence rounds —
|
|
174
228
|
// round 2+ injects this verbatim and the model understands it (decision
|
|
175
229
|
// 2026-08-08: prior-table hard parsing removed; no phrase/header matching).
|
|
@@ -177,7 +231,9 @@ export async function runAdvisorReview(agent, reviewType, callbacks, designToken
|
|
|
177
231
|
// table row (`| a | b | c |`) or substantial prose (>200 chars). An
|
|
178
232
|
// empty or tool-progress-only reply must not become the "prior review"
|
|
179
233
|
// of round 2+.
|
|
180
|
-
|
|
234
|
+
// P3:不完整报告不作 prior——含超时尾的表格输出形态上是评审,内容残缺;
|
|
235
|
+
// 下一轮从它起算会让收敛从一份不完整清单开始。
|
|
236
|
+
const looksLikeReview = looksLikeReviewOutput(final) && advisorIncompleteMarker(final) === null
|
|
181
237
|
if (looksLikeReview) {
|
|
182
238
|
agent._lastAdvisorOutput = final
|
|
183
239
|
}
|
package/advisor.mjs
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* Path classification (code / doc / temp) and the project declaration surface live in
|
|
6
6
|
* ../conventions.mjs — the single authority every gate consumes (repos.mjs included).
|
|
7
7
|
*
|
|
8
|
-
* The advisor runs as a read-only exploration sub-agent
|
|
9
|
-
*
|
|
8
|
+
* The advisor runs as a read-only exploration sub-agent — ZERO git, every round. The exact
|
|
9
|
+
* tool table lives in `advisor/loop.mjs`'s `advisorToolsFor` and is deliberately not
|
|
10
|
+
* enumerated here (an enumeration in a second place drifts). The change
|
|
10
11
|
* surface comes from the review scope (paths / _touchedFiles), never from git;
|
|
11
12
|
* verification is `read`-only with quoted-line evidence (7d49a52, d3be613).
|
|
12
13
|
*
|
|
@@ -50,6 +51,7 @@ import { buildAdvisorUserMessage, resolveScopeFiles, buildObjectDeclarationBlock
|
|
|
50
51
|
import { buildConvergenceBody } from "./advisor/convergence.mjs"
|
|
51
52
|
import { escapeLiteralEscapes } from "./escape.mjs"
|
|
52
53
|
import { applyPromptInjections, loadAdvisorPrompt } from "./prompt-files.mjs"
|
|
54
|
+
import { COMMON, filterToolRouting } from "./prompt-overlays.mjs"
|
|
53
55
|
// Re-export for run.mjs and tests (keeps their imports from "../advisor.mjs" stable)
|
|
54
56
|
export { ADVISOR_MD_PATH, extractAgentResponseTable, extractConversationBackground } from "./advisor/history.mjs"
|
|
55
57
|
export { buildAdvisorUserMessage } from "./advisor/messages.mjs"
|
|
@@ -75,6 +77,24 @@ const ADVISOR_ROUND3 = loadAdvisorPrompt("advisor-round3.md")
|
|
|
75
77
|
// and citation rules, disabling design approval entirely. loadAdvisorPrompt throws.
|
|
76
78
|
const ADVISOR_DESIGN = loadAdvisorPrompt("advisor-design.md")
|
|
77
79
|
|
|
80
|
+
// ────────────────────────────────────────
|
|
81
|
+
// 公共提示词面(`common.md`)——评审席与执行席同一条装配链
|
|
82
|
+
// ────────────────────────────────────────
|
|
83
|
+
// `common.md` 是**提示词**(产品对模型说的话,随包发布),不是项目文档:它必须装配——不装配就等于产品
|
|
84
|
+
// 对评审席失语,术语表(单元/集成测试的定义)、证据纪律、判据纪律全都不在场。项目文档(标准层)走另一条
|
|
85
|
+
// 路:按需读,见 `advisor/project-context.mjs` 的 `injectProjectStandards`。两者不可混为一谈。
|
|
86
|
+
//
|
|
87
|
+
// 三道变换缺一不可:
|
|
88
|
+
// ① `expandKnowledgeTopics`——`COMMON` 在 `prompt-overlays.mjs` 模块求值时已展开,知识锚不留字面;
|
|
89
|
+
// ② `filterToolRouting`——`## 工具路由` 列的是全套工具,评审只有十件;不裁剪就是指引它调不存在的工具。
|
|
90
|
+
// 工具名取 `advisor/loop.mjs` 的 `advisorToolsFor` 基底十件(`batch` 只在绑定批档时追加,而
|
|
91
|
+
// `filterToolRouting` 不读它,故不参与裁剪);
|
|
92
|
+
// ③ 不剥 `expand=lazy` 锚行——`common.md` 写着「需要正文时用 `knowledge get <id>` 取回」,所以评审席
|
|
93
|
+
// 必须持有 `knowledge`(`PROMPT-SYSTEM.md` §8.2:提示词要求读者做一件只有某个工具能做的事时,
|
|
94
|
+
// 读这段文字的每个读者都必须有这个工具)。锚行因此是**主题清单**,不是死文本。
|
|
95
|
+
const ADVISOR_ROUTING_TOOLS = ["read", "glob", "grep", "ls", "lsp", "code_search", "doc_check", "repo_graph", "knowledge", "manifest"]
|
|
96
|
+
const ADVISOR_COMMON = filterToolRouting(COMMON, ADVISOR_ROUTING_TOOLS)
|
|
97
|
+
|
|
78
98
|
// ────────────────────────────────────────
|
|
79
99
|
// System prompt building
|
|
80
100
|
// ────────────────────────────────────────
|
|
@@ -90,6 +110,10 @@ const ADVISOR_DESIGN = loadAdvisorPrompt("advisor-design.md")
|
|
|
90
110
|
// 锚替换缝(CORE-UNIFICATION §2.13.8——U0):本函数**每个 return 分支**都经 `applyPromptInjections`
|
|
91
111
|
// (未配置 = 恒等,现行行为零变);读取径(模块级常量缓存)不动。必须保持的不变量:每个 return
|
|
92
112
|
// 分支都经 `applyPromptInjections`,新增分支未挂即错。
|
|
113
|
+
//
|
|
114
|
+
// 每个分支都拼上 `ADVISOR_COMMON`(公共提示词面):轮次提示词在前、公共面在后——评审先读到自己的身份与
|
|
115
|
+
// 判据,再读到与执行席共用的术语、行为准则与工具边界。`common.md` 是每个 agent 场景的第二槽
|
|
116
|
+
// (`PROMPT-SYSTEM.md` §5.2),评审席此前是唯一的例外。
|
|
93
117
|
export function buildAdvisorSystemPrompt(agent, prior, reviewType) {
|
|
94
118
|
// Round decision is DETERMINISTIC (decision 2026-08-08): _advisorRound > 0
|
|
95
119
|
// with a stored review output means convergence (round 2+); 0 means round 1.
|
|
@@ -101,11 +125,11 @@ export function buildAdvisorSystemPrompt(agent, prior, reviewType) {
|
|
|
101
125
|
// complete criteria, applied to a full re-read (decision 2026-11-16). Design
|
|
102
126
|
// review has no convergence decay: the round counter drives display and audit
|
|
103
127
|
// only, never which criteria are in force.
|
|
104
|
-
if (reviewType === "design") return applyPromptInjections(ADVISOR_DESIGN)
|
|
105
|
-
if (!hasPrior) return applyPromptInjections(ADVISOR_ROUND1)
|
|
128
|
+
if (reviewType === "design") return applyPromptInjections(ADVISOR_DESIGN + "\n\n" + ADVISOR_COMMON)
|
|
129
|
+
if (!hasPrior) return applyPromptInjections(ADVISOR_ROUND1 + "\n\n" + ADVISOR_COMMON)
|
|
106
130
|
const round = (agent._advisorRound || 0) + 1
|
|
107
|
-
if (round === 2) return applyPromptInjections(ADVISOR_ROUND2)
|
|
108
|
-
return applyPromptInjections(ADVISOR_ROUND3)
|
|
131
|
+
if (round === 2) return applyPromptInjections(ADVISOR_ROUND2 + "\n\n" + ADVISOR_COMMON)
|
|
132
|
+
return applyPromptInjections(ADVISOR_ROUND3 + "\n\n" + ADVISOR_COMMON)
|
|
109
133
|
}
|
|
110
134
|
|
|
111
135
|
// ────────────────────────────────────────
|
|
@@ -194,12 +218,17 @@ export { escapeLiteralEscapes }
|
|
|
194
218
|
* @param {boolean} writesSection3 — 本评审实例是否持有 `§3` 写通道(`reviewHoldsBatchWrite` 的取值,由
|
|
195
219
|
* `advisor/run.mjs` 算一次传进来);透传给同档两处 `buildAdvisorUserMessage`。**不给默认值**。
|
|
196
220
|
*/
|
|
197
|
-
export function prepareAdvisorMessages(agent, reviewType, designToken = null, documents = null, batchBrief, paths = null, priorParam = null, object = null, designId = null, writesSection3) {
|
|
221
|
+
export function prepareAdvisorMessages(agent, reviewType, designToken = null, documents = null, batchBrief, paths = null, priorParam = null, object = null, designId = null, writesSection3, advisorCwd = null) {
|
|
198
222
|
// Deterministic convergence state (decision 2026-08-08): round 2+ requires
|
|
199
223
|
// _advisorRound > 0 AND a stored prior review output. No history parsing.
|
|
200
224
|
// priorParam (direct callers) wins over the stored output — same derivation
|
|
201
225
|
// as buildAdvisorSystemPrompt (single source of truth for round semantics).
|
|
202
226
|
const prior = (agent._advisorRound || 0) > 0 ? (priorParam ?? agent._lastAdvisorOutput) : null
|
|
227
|
+
// 多项目父工作区下,run.mjs 已把 advisorCwd 对齐到唯一子仓根;消息构造侧只读视图同步复用该 cwd,
|
|
228
|
+
// 防止项目指南注释仍打印父工作区路径误导评审员把子仓相对路径拼错;对 agent._advisorRound 等写操作仍落原 agent。
|
|
229
|
+
const msgAgent = advisorCwd && advisorCwd !== agent.cwd
|
|
230
|
+
? Object.create(agent, { cwd: { value: advisorCwd, enumerable: true } })
|
|
231
|
+
: agent
|
|
203
232
|
|
|
204
233
|
// Design review — EVERY round: the dedicated full-scope review, with the
|
|
205
234
|
// approval token re-injected (an async fix-round continuation must be able to
|
|
@@ -210,7 +239,7 @@ export function prepareAdvisorMessages(agent, reviewType, designToken = null, do
|
|
|
210
239
|
if (reviewType === "design") {
|
|
211
240
|
return [
|
|
212
241
|
{ role: "system", content: buildAdvisorSystemPrompt(agent, prior, reviewType) },
|
|
213
|
-
{ role: "user", content: escapeLiteralEscapes(buildAdvisorUserMessage(
|
|
242
|
+
{ role: "user", content: escapeLiteralEscapes(buildAdvisorUserMessage(msgAgent, prior, reviewType, designToken, documents, batchBrief, paths, object, designId, writesSection3)) },
|
|
214
243
|
]
|
|
215
244
|
}
|
|
216
245
|
|
|
@@ -236,7 +265,7 @@ export function prepareAdvisorMessages(agent, reviewType, designToken = null, do
|
|
|
236
265
|
agent._advisorRound = 0
|
|
237
266
|
}
|
|
238
267
|
// Mutations exist → KEEP the round (attempts keep advancing through retries).
|
|
239
|
-
const user = buildAdvisorUserMessage(
|
|
268
|
+
const user = buildAdvisorUserMessage(msgAgent, prior, reviewType, designToken, documents, batchBrief, paths, object, designId, writesSection3)
|
|
240
269
|
return [
|
|
241
270
|
{ role: "system", content: buildAdvisorSystemPrompt(agent, prior, reviewType) },
|
|
242
271
|
{
|
|
@@ -264,8 +293,8 @@ export function prepareAdvisorMessages(agent, reviewType, designToken = null, do
|
|
|
264
293
|
// keeps _advisorRound so the convergence prompt matches the attempt count.
|
|
265
294
|
// scopeFiles gives the fallback (agent gave no response table) a concrete
|
|
266
295
|
// review surface.
|
|
267
|
-
const scopeFiles = resolveScopeFiles(
|
|
268
|
-
const followUp = buildAdvisorFollowUp(
|
|
296
|
+
const scopeFiles = resolveScopeFiles(msgAgent, paths)
|
|
297
|
+
const followUp = buildAdvisorFollowUp(msgAgent, prior, scopeFiles, object)
|
|
269
298
|
return [
|
|
270
299
|
{ role: "system", content: buildAdvisorSystemPrompt(agent, prior, reviewType) },
|
|
271
300
|
{ role: "user", content: escapeLiteralEscapes(followUp) },
|
package/agent/assemble.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { isAbsolute, join } from "node:path"
|
|
|
15
15
|
import { createAgent } from "../agent.mjs"
|
|
16
16
|
import { configDir, loadConfig } from "../config.mjs"
|
|
17
17
|
import { createMemory, syncDir } from "../memory.mjs"
|
|
18
|
-
import { discoverRules
|
|
18
|
+
import { discoverRules } from "../rules.mjs"
|
|
19
19
|
import { assembleBuiltinTools } from "../tools/index.mjs"
|
|
20
20
|
|
|
21
21
|
/** 装配缺省面(逐项可注入 —— 断言装配调用序用假 deps;缺省 = 本档单源)。 */
|
|
@@ -62,7 +62,7 @@ export function validateProvider(agent, config) {
|
|
|
62
62
|
* (缺省 = 恒等)——位次 = 工具装配后、`createAgent` 前;核体 `await`(同步返回值与 Promise 同判)。 */
|
|
63
63
|
export async function assembleAgent({ cwd, deps = {}, toolsFinalize = null }) {
|
|
64
64
|
const D = { ...DEFAULT_DEPS, ...deps }
|
|
65
|
-
const config = D.loadConfig()
|
|
65
|
+
const config = D.loadConfig(cwd)
|
|
66
66
|
const provider = config.provider
|
|
67
67
|
const providers = config.providersList
|
|
68
68
|
// 代理注入(逐渠独立:provider.proxy ∧ `proxy.uri` 在案 ⇒ 该渠模型请求经代理——无全局闸,2026-10-08);config.provider 是 loadConfig 里的
|
|
@@ -77,9 +77,9 @@ export async function assembleAgent({ cwd, deps = {}, toolsFinalize = null }) {
|
|
|
77
77
|
const { createEmbedder } = await import("../embedding.mjs")
|
|
78
78
|
memory.embedder = createEmbedder(config.embedding)
|
|
79
79
|
}
|
|
80
|
-
// 项目级规则(.thincoder/rules/*.md)并入 config
|
|
81
|
-
//
|
|
82
|
-
|
|
80
|
+
// 项目级规则(.thincoder/rules/*.md)并入 config:已随 `loadConfig(cwd)` 在装载期完成
|
|
81
|
+
// (2026-11-30 移入核 `config.mjs`——合并属装载期归一,不是装配期动作;住在这里时只有
|
|
82
|
+
// CLI/桌面拿得到,VSC 端只能自己再合一遍,即端差)。
|
|
83
83
|
// code/doc 索引按 origin(项目根目录)隔离:检索只落本项目范围。
|
|
84
84
|
memory.codeOrigin = cwd
|
|
85
85
|
// 项目层:启动时把 `.thincoder/memory/` 目录同步进索引(有则同步、无则跳过)。
|
package/agent/chat-call.mjs
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
* 接口 = callModelTurn(agent, ctx) → response;错误走原样:AbortError-中断分支处理完照旧 `throw e`,
|
|
5
5
|
* 由 runAgent 的 catch/finally 收束。
|
|
6
6
|
*/
|
|
7
|
+
import { annotateAbort, interruptLine } from "../abort-provenance.mjs"
|
|
7
8
|
import { chat } from "../provider/index.mjs"
|
|
8
9
|
import { healImageRejection, clearImageFailStreak } from "./image-heal.mjs"
|
|
9
10
|
import { assembleRequestMessages, pushInject, pushRecord } from "../context.mjs"
|
|
11
|
+
// §2.5 发送面净判的判据面:整量测度(与压缩判定、状态行同一个数)
|
|
12
|
+
import { contextUsage } from "../token-window.mjs"
|
|
10
13
|
|
|
11
14
|
/** 流式输出门(§2.5 #78 并入——VSC 三态门,纯函数可直驱测试):depth 0 恒通;
|
|
12
15
|
* consult 子代理豁免(其输出进会诊面板);其余经 `streamOutput` 显式选择进入。 */
|
|
@@ -25,12 +28,26 @@ export async function callModelTurn(agent, {
|
|
|
25
28
|
}
|
|
26
29
|
const toolsDeclared = Array.isArray(toolSchemas) && toolSchemas.length > 0
|
|
27
30
|
// 首送与图片自愈重发共用同一请求构造形,工具声明判据也来自同一份 toolSchemas。
|
|
31
|
+
// 记录本次请求实际发出的 B 段待发队对象引用快照:工具批收尾消费时只剔除这批已送达模型的对象,
|
|
32
|
+
// 既不误清 `chat()` 返回后新写入的下轮提醒,也免疫工具执行期 `filter` 原地删旧条引起的下标偏移。
|
|
33
|
+
let sentInjectRefs = new Set(Array.isArray(agent._pendingInject) ? agent._pendingInject : [])
|
|
28
34
|
const messages = assembleRequestMessages(agent, { systemPrompt, toolsDeclared })
|
|
35
|
+
// §2.5 发送面净判的判据:整量测度 `contextUsage().total`——与压缩判定、状态行**同一个数**。每轮现算
|
|
36
|
+
// (非对话面随注入面变动),随 opts 透传到四条 transport;无 agent 的链路拿不到它,那边退回估算。
|
|
37
|
+
const measuredPrompt = contextUsage(agent, agent._ctxBasis?.overhead ?? {}).total
|
|
29
38
|
let response
|
|
30
39
|
|
|
31
40
|
// 发送选项(首送 ∥ §6.26 自愈重发共用——两送除 messages 外逐字同参)
|
|
32
41
|
const sendOpts = {
|
|
33
42
|
tools: toolSchemas,
|
|
43
|
+
// 模型语义参数(temperature ∥ thinking ∥ reasoningEffort)逐调用下发(2026-12-03 批,台账 #133):
|
|
44
|
+
// 住**设置层** `agent.modelParams`(与 `agent.provider` 同层),不再是 provider 条目属性
|
|
45
|
+
//(用户裁定「不应该有任何 provider 级别的模型参数」)。四条 transport 按它取值。
|
|
46
|
+
modelParams: agent.modelParams,
|
|
47
|
+
// 会话设置(模型窗口声明 ∥ 档位上限)随请求下发(2026-12-03 批):住设置层,不再拷到 provider 条目上。
|
|
48
|
+
settings: agent.config,
|
|
49
|
+
// §2.5:整量测度随请求送到发送面净判(守卫判它,不再判未校准的 estPrompt)
|
|
50
|
+
measuredPrompt,
|
|
34
51
|
// §2.5 #78 并入(VSC onToken 三态门):depth 0 恒通;consult 子代理豁免(其输出进
|
|
35
52
|
// 会诊面板);escalate 等经 opts.streamOutput 显式选择进入;其余子代理不流式。
|
|
36
53
|
onToken: streamOutputAllowed(depth, agent._role, streamOutput) ? callbacks.onToken : null,
|
|
@@ -62,7 +79,7 @@ export async function callModelTurn(agent, {
|
|
|
62
79
|
// User interrupt (Ctrl+I): controller.abort({ interrupt: true, message }).
|
|
63
80
|
// Inject into history; the outer loop recreates the controller and resumes.
|
|
64
81
|
if (e.name === "AbortError" && signal?.reason?.interrupt) {
|
|
65
|
-
const msg =
|
|
82
|
+
const msg = interruptLine(signal?.reason?.message)
|
|
66
83
|
// 去重:工具执行中断那一支已投过同一条时不再入队。判据读待发队尾条——
|
|
67
84
|
// 注入不在 `agent.history` 上(嵌套线上 `.content` 恒 `undefined`,读它去重恒不命中)。
|
|
68
85
|
const queue = Array.isArray(agent._pendingInject) ? agent._pendingInject : []
|
|
@@ -77,10 +94,13 @@ export async function callModelTurn(agent, {
|
|
|
77
94
|
if (!healed) throw e
|
|
78
95
|
// 重建消息(§6.26 步 4——剥除后的机读线含自愈注记):再发一次(非重试——同请求
|
|
79
96
|
// 重发对图像拒绝恒无效);再败 ⇒ 本行抛新错(不循环、不二次剥除,历史保持已剥除态)。
|
|
97
|
+
sentInjectRefs = new Set(Array.isArray(agent._pendingInject) ? agent._pendingInject : [])
|
|
80
98
|
response = await chat(agent.provider, { messages: assembleRequestMessages(agent, { systemPrompt, toolsDeclared }), ...sendOpts })
|
|
81
99
|
}
|
|
82
100
|
// §6.26 清零调用点(记账单源 = image-heal.mjs):任一次成功调用清零(含自愈重发成功)
|
|
83
101
|
clearImageFailStreak(agent)
|
|
102
|
+
// 本次已送达模型的 B 段对象引用集:供工具批收尾(post-turn)精准消费,不误清后续新入队提醒。
|
|
103
|
+
agent._sentInjectRefs = sentInjectRefs
|
|
84
104
|
|
|
85
105
|
return response
|
|
86
106
|
}
|
package/agent/completion.mjs
CHANGED
|
@@ -9,8 +9,6 @@ import { hasCodeMutations } from "../advisor/repos.mjs"
|
|
|
9
9
|
import { pushReal, pushInject } from "../context.mjs"
|
|
10
10
|
import { specForModel, assistantTextMessage, isThinkingRequest } from "../config.mjs"
|
|
11
11
|
import { advisorReviewPending, effectiveAdvisorRound } from "../agent-tools/advisor-async.mjs"
|
|
12
|
-
import { poolLive } from "./suspension.mjs"
|
|
13
|
-
import { shouldPushbackUnclosedTasks } from "./task-lifecycle.mjs"
|
|
14
12
|
|
|
15
13
|
const MAX_VERIFY_PUSHBACKS = 2
|
|
16
14
|
const MAX_VERIFY_RETRIES = 3
|
|
@@ -39,7 +37,7 @@ export function isSubstantiveResponse(response) {
|
|
|
39
37
|
*/
|
|
40
38
|
function pushAssistantText(agent, response) {
|
|
41
39
|
const spec = specForModel(agent.provider?.model)
|
|
42
|
-
pushReal(agent, assistantTextMessage(response, spec, isThinkingRequest(agent.
|
|
40
|
+
pushReal(agent, assistantTextMessage(response, spec, isThinkingRequest(agent.modelParams ?? null, spec), agent.provider ?? null))
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
/**
|
|
@@ -197,23 +195,6 @@ export function handleCompletion(agent, response, depth, turn, guardPushbacks, h
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
// --- task closeout check: bounded 1-time reminder when stale/in_progress tasks remain ---
|
|
201
|
-
// 允许刻意刚记录 `pending` 后立即交接(`inProgress === 0 && _turnsSinceTaskUpdate === 0` 不触发);
|
|
202
|
-
// 在途异步池或 `timer` 存在、工程模式、自动回合与子代理均跳过。
|
|
203
|
-
const taskCheck = shouldPushbackUnclosedTasks(agent, {
|
|
204
|
-
depth,
|
|
205
|
-
taskPushbacks: agent._taskClosePushbacks ?? 0,
|
|
206
|
-
poolActive: poolLive(agent),
|
|
207
|
-
})
|
|
208
|
-
if (taskCheck.pushback && taskCheck.reminder) {
|
|
209
|
-
agent._taskClosePushbacks = (agent._taskClosePushbacks ?? 0) + 1
|
|
210
|
-
pushAssistantText(agent, response)
|
|
211
|
-
pushInject(agent, { role: "user", content: taskCheck.reminder })
|
|
212
|
-
callbacks.onSubTurnBreak?.()
|
|
213
|
-
callbacks.onTurnEnd?.(agent, turn)
|
|
214
|
-
return { action: "continue", guardPushbacks, honestReminderInjected, advisorPushbacks }
|
|
215
|
-
}
|
|
216
|
-
|
|
217
198
|
pushAssistantText(agent, response)
|
|
218
199
|
return { action: "done", content: response.content, guardPushbacks, honestReminderInjected, advisorPushbacks }
|
|
219
200
|
}
|
package/agent/dispatch-gates.mjs
CHANGED
|
@@ -84,9 +84,14 @@ export function isReadonlyAction(toolName, args) {
|
|
|
84
84
|
const action = args?.action
|
|
85
85
|
return action === "read"
|
|
86
86
|
}
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
// batch 只读动作(`BATCH-RECORD.md` §4.25):read ∥ check 只读不写盘,planMode / readonly step 放行、免审批、不清 verify。
|
|
88
|
+
if (toolName === "batch") {
|
|
89
|
+
const action = args?.action
|
|
90
|
+
return action === "read" || action === "check"
|
|
91
|
+
}
|
|
92
|
+
// #9(TOOLS.md §6.19):process 动作分级——仅缺省或 list 为只读分类(白名单 fail-closed,planMode 放行/免审批/可批并行);
|
|
93
|
+
// kill 及任何未知动作一律走侧效审批门。
|
|
94
|
+
if (toolName === "process") return args?.action === undefined || args?.action === "list"
|
|
90
95
|
// `step` 分叉微步(`STEP-FORK.md` §3):readonly=true 为只读动作(planMode 放行 / 免审批 / 同轮并行)
|
|
91
96
|
if (toolName === "step") return args?.readonly === true
|
|
92
97
|
if (toolName !== "subagent" || !args || typeof args !== "object") return false
|