@thincoder/core 0.11.4 → 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 +33 -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 +22 -41
- 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
|
@@ -328,11 +328,12 @@ export function sectionHasStatusLine(src, seg) {
|
|
|
328
328
|
* 模式取形(§4.16——普通模式变体**四处替换**、余行逐字同;`mode` 缺省 = "engineering"):
|
|
329
329
|
* ① 汇总行 §2/§5 标签;② `## §2` 段头;③ §2 状态占位句;④ `## §5` 段头。
|
|
330
330
|
*/
|
|
331
|
-
export function batchSkeleton({ date, topic, source, prev, baseSha, ledger = null, board = null, mode = "engineering" }) {
|
|
331
|
+
export function batchSkeleton({ date, topic, source, prev, baseSha, ledger = null, ledgerTitle = null, board = null, mode = "engineering" }) {
|
|
332
332
|
if (typeof baseSha !== "string" || baseSha.trim() === "") {
|
|
333
333
|
throw new Error("batchSkeleton: baseSha is required — pass the pre-create HEAD, or 未取到(<原因>) when git cannot supply it.")
|
|
334
334
|
}
|
|
335
335
|
const normal = mode === "normal"
|
|
336
|
+
const safeLedgerTitle = assertLedgerTitle(ledgerTitle)
|
|
336
337
|
const designerSeat = normal ? "主 agent" : "eng-designer" // ① 汇总行 §2 标签 ∥ ② §2 段头
|
|
337
338
|
const implementerSeat = normal ? "实施者:主 agent ∥ coder" : "eng-coder" // ① 汇总行 §5 标签 ∥ ④ §5 段头
|
|
338
339
|
return [
|
|
@@ -340,7 +341,7 @@ export function batchSkeleton({ date, topic, source, prev, baseSha, ledger = nul
|
|
|
340
341
|
`> 六段,一段一作者:§1 讨论(主 agent)· §2 批次任务与设计(${designerSeat})· §3 设计评审(评审子代理)· §4 用户批准(主 agent)· §5 实施记录(${implementerSeat})· §6 验证与收口(父代理)。`,
|
|
341
342
|
`> 每段只有一个作者:作者的段可 \`append\` 加内容、可就地改(\`edit\`);非作者一概拒。`,
|
|
342
343
|
`> 编制:主 agent · ${date} · 来源 = ${source}。`,
|
|
343
|
-
`> 台账 = ${ledger ?? "#<编号>"}(${board ?? (ledger ? "—" : "<板块>")} · 归批)。前情 = ${prev}。`,
|
|
344
|
+
`> 台账 = ${ledger ?? "#<编号>"}${ledger && safeLedgerTitle ? `「${safeLedgerTitle}」` : ""}(${board ?? (ledger ? "—" : "<板块>")} · 归批)。前情 = ${prev}。`,
|
|
344
345
|
"## §1 讨论(主 agent)",
|
|
345
346
|
// §1 状态行骨架写**纯「进行中」**:括注由主 agent 人工写(§4.10)。骨架不产一个没有机制会清的假占位
|
|
346
347
|
// ——`§2`/`§5` 的占位句会被 §4.12 的被动写覆盖,`§1` 的括注没有任何机制会清,留在每一本新档上就是
|
|
@@ -389,8 +390,9 @@ export function batchSkeleton({ date, topic, source, prev, baseSha, ledger = nul
|
|
|
389
390
|
/** 档头 `台账` 行识别形(行首 `>` + `台账` + `=`)——判定域 = **档头域**(档首至首个 `## §N` 段头前,
|
|
390
391
|
* 与 F11-C 的死占位扫描同域:段体里引述的同一行不是档头行)。 */
|
|
391
392
|
const LEDGER_HEADER_RE = /^>\s*台账\s*=/
|
|
392
|
-
/** 台账编号枚(`#12`
|
|
393
|
-
|
|
393
|
+
/** 台账编号枚(`#12` 形,可带标题 `#12「title」`);与模板占位 `#<编号>` 天然不同形(占位不是编号)。
|
|
394
|
+
* **捕获组 1 = 纯数字**——取号一律读 `m[1]`,不读 `m[0]`(`m[0]` 带标题,`Number()` 会得 NaN)。 */
|
|
395
|
+
const LEDGER_NO_RE = /#(\d+)(?:「[^」]*」)?/g
|
|
394
396
|
/** 档头缺行拒串(`attach` 的拒面之一——本动作只**延展**既有档头行,不造行:造行是 create 的事)。 */
|
|
395
397
|
const LEDGER_HEADER_MISSING_ERROR = "batch: the record has no `> 台账 = …` line in its header zone — attach only extends an existing header 台账 line and never creates one (creating a record, header included, is create's job). Fix the header by file edit first. Nothing was written."
|
|
396
398
|
/** 档头行无可接编号位拒串(既无 `#<编号>` 也无真编号——无处可接,不猜形)。 */
|
|
@@ -407,12 +409,38 @@ function ledgerHeaderLineOf(src) {
|
|
|
407
409
|
return { lines, idx, cr, text: cr ? lines[idx].slice(0, -1) : lines[idx] }
|
|
408
410
|
}
|
|
409
411
|
|
|
410
|
-
/**
|
|
412
|
+
/** 括注组起点(第一个**不在 `「…」` 内**的 `(`):标题里的 `(` 不构成组起点。用 `indexOf("(")` 切,
|
|
413
|
+
* 标题含 `(` 时切点落进标题内部,追加新号会插进标题中间——而号集仍解得开,没有任何门报出。 */
|
|
414
|
+
function parenStartOf(text) {
|
|
415
|
+
let inTitle = false
|
|
416
|
+
for (let i = 0; i < text.length; i++) {
|
|
417
|
+
const ch = text[i]
|
|
418
|
+
if (ch === "「") inTitle = true
|
|
419
|
+
else if (ch === "」") inTitle = false
|
|
420
|
+
else if (ch === "(" && !inTitle) return i
|
|
421
|
+
}
|
|
422
|
+
return -1
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** 号集合切分(读写共用):括注组不参与,前置列表逐枚取 `#N` 或 `#N「title」`。 */
|
|
411
426
|
function ledgerNumberMatches(text) {
|
|
412
|
-
const open = text
|
|
427
|
+
const open = parenStartOf(text)
|
|
413
428
|
return [...text.slice(0, open < 0 ? text.length : open).matchAll(LEDGER_NO_RE)]
|
|
414
429
|
}
|
|
415
430
|
|
|
431
|
+
/** 档头行标题校验(`batchSkeleton` 的 `ledgerTitle` ∥ `appendLedgerNoToHeader` 的 `title` 共用):标题原样
|
|
432
|
+
* 拼进档头行文法,含 `「` / `」` / 换行会把行写坏(`」` 让号枚正则提前收尾,追加的新号插进标题中间)。
|
|
433
|
+
* `(` / `)` **允许**——括注组起点按 `parenStartOf` 判,标题里的括号不构成组起点。
|
|
434
|
+
* fail-closed 拒,不转义:转义后读者看到的不是原标题。 */
|
|
435
|
+
export function assertLedgerTitle(title) {
|
|
436
|
+
if (title == null) return null
|
|
437
|
+
const v = String(title)
|
|
438
|
+
if (/[「」\r\n]/.test(v)) {
|
|
439
|
+
throw new Error(`batch: the ledger title cannot contain 「 」 or a newline — it is spliced verbatim into the header 台账 line and those characters break that line's grammar. Got ${JSON.stringify(v)}. Nothing was written.`)
|
|
440
|
+
}
|
|
441
|
+
return v
|
|
442
|
+
}
|
|
443
|
+
|
|
416
444
|
/**
|
|
417
445
|
* 档头 `台账` 行号集只读解析器(§2.17 `headerRows` 的单源):与 `appendLedgerNoToHeader`
|
|
418
446
|
* 共用 `ledgerHeaderLineOf` 与 `ledgerNumberMatches`,档头语法只此一份。无档头行 ⇒ 空集。
|
|
@@ -422,7 +450,7 @@ function ledgerNumberMatches(text) {
|
|
|
422
450
|
export function readLedgerHeaderNumbers(src) {
|
|
423
451
|
if (typeof src !== "string") return []
|
|
424
452
|
const header = ledgerHeaderLineOf(src)
|
|
425
|
-
return header ? ledgerNumberMatches(header.text).map((m) => Number(m[
|
|
453
|
+
return header ? ledgerNumberMatches(header.text).map((m) => Number(m[1])) : []
|
|
426
454
|
}
|
|
427
455
|
|
|
428
456
|
/**
|
|
@@ -434,10 +462,11 @@ export function readLedgerHeaderNumbers(src) {
|
|
|
434
462
|
* 档头仍带 `#<编号>` 死占位 ⇒ 占位**就地换成真编号**(这正是「把死占位换成真编号」的那条通道——F11-C 随之放行)。
|
|
435
463
|
* @param {string} src — 档全文
|
|
436
464
|
* @param {number} n — 台账行号(正整数)
|
|
465
|
+
* @param {string|null} [title] — 行标题(给了就写成 `#N「title」`——跨机时号 + 标题双认)
|
|
437
466
|
* @returns {{src:string, already:boolean, line:string}} 新全文 ∥ 是否已在列表(`already` ⇒ `src` 逐字未变)∥
|
|
438
467
|
* 改写后的档头行原文(回执用;`already` 时为现形)
|
|
439
468
|
*/
|
|
440
|
-
export function appendLedgerNoToHeader(src, n) {
|
|
469
|
+
export function appendLedgerNoToHeader(src, n, title = null) {
|
|
441
470
|
const no = Number(n)
|
|
442
471
|
if (!Number.isInteger(no) || no <= 0) {
|
|
443
472
|
throw new Error(`batch: a ledger entry number is required to extend the header 台账 line — got ${JSON.stringify(n ?? null)}. Nothing was written.`)
|
|
@@ -445,18 +474,20 @@ export function appendLedgerNoToHeader(src, n) {
|
|
|
445
474
|
const header = ledgerHeaderLineOf(src)
|
|
446
475
|
if (!header) throw new Error(LEDGER_HEADER_MISSING_ERROR)
|
|
447
476
|
const { lines, idx, cr, text } = header
|
|
448
|
-
const open = text
|
|
477
|
+
const open = parenStartOf(text)
|
|
449
478
|
const preEnd = open < 0 ? text.length : open
|
|
450
479
|
const pre = text.slice(0, preEnd)
|
|
451
480
|
const nums = ledgerNumberMatches(text)
|
|
452
|
-
if (nums.some((m) => Number(m[
|
|
481
|
+
if (nums.some((m) => Number(m[1]) === no)) return { src, already: true, line: text }
|
|
482
|
+
const safeTitle = assertLedgerTitle(title)
|
|
483
|
+
const suffix = safeTitle ? `「${safeTitle}」` : ""
|
|
453
484
|
let next
|
|
454
485
|
if (nums.length) {
|
|
455
486
|
const last = nums[nums.length - 1]
|
|
456
487
|
const after = last.index + last[0].length
|
|
457
|
-
next = `${pre.slice(0, after)} · #${no}${pre.slice(after)}${text.slice(preEnd)}`
|
|
488
|
+
next = `${pre.slice(0, after)} · #${no}${suffix}${pre.slice(after)}${text.slice(preEnd)}`
|
|
458
489
|
} else if (pre.includes("#<编号>")) {
|
|
459
|
-
next = `${pre.replace("#<编号>", `#${no}`)}${text.slice(preEnd)}`
|
|
490
|
+
next = `${pre.replace("#<编号>", `#${no}${suffix}`)}${text.slice(preEnd)}`
|
|
460
491
|
} else {
|
|
461
492
|
throw new Error(LEDGER_HEADER_NO_SLOT_ERROR)
|
|
462
493
|
}
|
package/agent-tools/consult.mjs
CHANGED
|
@@ -276,7 +276,10 @@ async function runConsultChild(ctx, session, id, m, problem, ctrl) {
|
|
|
276
276
|
// a real consult died on qwen3.8-max effort "high" (enum is xhigh/medium/low).
|
|
277
277
|
// Out-of-enum: DROP the effort entirely (the provider preset default may ALSO be
|
|
278
278
|
// out-of-enum for this override model).
|
|
279
|
-
|
|
279
|
+
// 2026-12-03 批(台账 #133):effort 不再写 provider 克隆——写**子 agent 的会话视图** `modelParams`
|
|
280
|
+
//(克隆一份——`child.modelParams` 否则会与父会话的 `config.modelParams` 同一引用)。
|
|
281
|
+
const childModelParams = { ...(agent.modelParams ?? {}) }
|
|
282
|
+
clampEffort(childModelParams, m.model, m.effort)
|
|
280
283
|
|
|
281
284
|
// Read-only consultant: filter the parent tool set down to readonly tools + main_history.
|
|
282
285
|
// B4(TOOLS.md §6.29 ①):整把只读集 ∪ action 级只读变体(与 core 派单面同一派生面、同一判据)。
|
|
@@ -298,6 +301,7 @@ async function runConsultChild(ctx, session, id, m, problem, ctrl) {
|
|
|
298
301
|
// TUI-OOM-ROOTCAUSE·AGENT-LOOP.md §9.2:子代理人读线窗口(四处创建点同置)——consult 会话跨回合驻留,
|
|
299
302
|
// 不置窗则 _fullHistory 仍无界(F-O1 覆盖 depth>0 全部创建点)
|
|
300
303
|
child._historyWindow = RECORD_WINDOW_MESSAGES
|
|
304
|
+
child.modelParams = childModelParams // 会诊池的 effort 覆盖(已钳制)住子会话视图
|
|
301
305
|
// SUBAGENT-UPSTREAM-CHANNEL 补赋(TURN-CAP-CONTINUE.md §3.1):会诊 = 后台族(consult_start
|
|
302
306
|
// 发后即返)⇒ 父在飞可答——撞帽检查点的上行 ask 与 notify_parent 同源通道。
|
|
303
307
|
child._upstream = { parent: agent, label, sync: false }
|
package/agent-tools/context.mjs
CHANGED
|
@@ -52,7 +52,7 @@ export function compactFailureNote(message, attempt) {
|
|
|
52
52
|
|
|
53
53
|
/** 轻推锚(§6.16.5):active goal 目标 ⇒ in_progress 任务标题 ⇒ 首个 pending 标题 ⇒ `(none set)`。 */
|
|
54
54
|
function nudgeAnchor(agent) {
|
|
55
|
-
if (agent?.goal?.status === "active" && agent.goal.
|
|
55
|
+
if (agent?.goal?.status === "active" && agent.goal.condition) return agent.goal.condition
|
|
56
56
|
const tasks = agent?.tasks ?? []
|
|
57
57
|
const inProgress = tasks.find((t) => t.status === "in_progress")
|
|
58
58
|
if (inProgress) return inProgress.title
|
|
@@ -86,7 +86,7 @@ function statsReport(agent) {
|
|
|
86
86
|
// 合格集与 prune 本体同一组实参(§2.3 表):`fixedOverhead` ∥ `ratio` 都当场现算,没有一处落盘。
|
|
87
87
|
const stale = collectStaleToolOutputs(
|
|
88
88
|
flat, agent?.provider, protectFrom ? flatIndexOf(agent.history, protectFrom) : flat.length,
|
|
89
|
-
usage.fixed - usage.compactionSummary, tokenRatioOf(agent),
|
|
89
|
+
usage.fixed - usage.compactionSummary, tokenRatioOf(agent), agent?.config,
|
|
90
90
|
)
|
|
91
91
|
let toolOut = 0
|
|
92
92
|
let toolCount = 0
|
|
@@ -96,7 +96,7 @@ function statsReport(agent) {
|
|
|
96
96
|
toolOut += estimateTokens([m])
|
|
97
97
|
}
|
|
98
98
|
// 预算取一次,全行共用(§7.1「从同一 contextUsage ∥ policyBudget ∥ historyReading 取数,各自具名,不混用分母」)。
|
|
99
|
-
const budget = policyBudget(agent?.provider)
|
|
99
|
+
const budget = policyBudget(agent?.provider, undefined, undefined, agent?.config)
|
|
100
100
|
// 分母 = `limit`(用户实际可填的量,§2.5 / §7.1):与状态行第 6 行同一个数,`window` 只作具名读数出现。
|
|
101
101
|
const pct = Math.round((usage.total / budget.limit) * 100)
|
|
102
102
|
const toGo = Math.max(0, usage.threshold - usage.total) // 已越阈值 ⇒ 0(自动压缩将在下一安全点接手)
|
|
@@ -121,12 +121,13 @@ function statsReport(agent) {
|
|
|
121
121
|
return [
|
|
122
122
|
`Context ≈${usage.total} tokens (${pct}% of ${budget.limit} fillable limit; window ${usage.window}, compaction line ${usage.threshold} (${toGo} to the line))`,
|
|
123
123
|
// §6.16.4 字面单源(该行为唯一字面,逐字;预算面同源 policyBudget——不自算第二套):
|
|
124
|
-
// window {window} ({modelContext|
|
|
124
|
+
// window {window} ({modelContext|list|spec|default}) · max_tokens {maxTokens|not sent} ({explicit|reported|spec|absent})
|
|
125
125
|
// · prompt {total} · to compaction line {threshold − total} · to window limit {limit − total}
|
|
126
126
|
// 两距离带符号(负 = 已越);maxTokens 未发写 not sent、来源写 absent。
|
|
127
127
|
(() => {
|
|
128
128
|
const mt = budget.maxTokens === undefined ? "not sent" : String(budget.maxTokens)
|
|
129
129
|
return `Request budget: window ${budget.window} (${budget.windowSource}) · max_tokens ${mt} (${budget.maxTokensSource})`
|
|
130
|
+
+ ` · context cap ${Math.round(budget.contextCap / 1024)}K (${budget.contextCapMode})`
|
|
130
131
|
+ ` · input limit ${budget.limit} (window − reserve ${budget.reserve})`
|
|
131
132
|
+ ` · prompt ${usage.total} · to compaction line ${usage.threshold - usage.total}`
|
|
132
133
|
+ ` · to window limit ${budget.limit - usage.total}`
|
|
@@ -84,7 +84,10 @@ function basenameOfPath(p) {
|
|
|
84
84
|
* = `batchAbsPathOfRun` 的两源定序)。`resolve` = 归一(分隔符 ∥ `.`/`..`);落盘值即此形。
|
|
85
85
|
* **归属不唯一 ⇒ 不猜**:文档集里出现**多份不同的**批档(收口消费以批为键,猜错 = 消费别批的
|
|
86
86
|
* 授权)⇒ 返回 null(归属 = 无,与「不含批档」同一降级层——§10 同段「比留下一个可解释的
|
|
87
|
-
* 滞留槽更坏」的排序)。同一档的两种写法(分隔符 / 大小写)去重,不算两份。
|
|
87
|
+
* 滞留槽更坏」的排序)。同一档的两种写法(分隔符 / 大小写)去重,不算两份。
|
|
88
|
+
* **反解回的路径是归一形**:`docSetKey` 自 2026-12-01 起经 `canonPath`(win32 折小写),所以本函数
|
|
89
|
+
* 得到的绝对路径在该平台上是小写形——只用于派生显示(末段名)与经 `batchPathKey` 的比对,
|
|
90
|
+
* 不当作原大小写可辨的身份(文件读取在 win32 上大小写不敏感,Linux 不折)。 */
|
|
88
91
|
export function batchAbsPath(docSetKey) {
|
|
89
92
|
if (typeof docSetKey !== "string") return null
|
|
90
93
|
let list = null
|
|
@@ -115,9 +118,9 @@ export function batchAbsPathOfRun(run) {
|
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
/** 批档身份键(§10「匹配」):两侧(旁列值 ∥ 收口目标 `abs`)都是 `node:path` 解析后的绝对路径;
|
|
118
|
-
* 比较前分隔符归一、`win32`
|
|
119
|
-
*
|
|
120
|
-
* `docSetKey`
|
|
121
|
+
* 比较前分隔符归一、`win32` 下不区分大小写(宿主事实)。本函数**保留自己的归一一层**——
|
|
122
|
+
* 它比的两侧来源不止 `docSetKey`(还有旁列值与 `resolve` 后的收口目标),不假定上游已归一。
|
|
123
|
+
* (2026-12-01 起 `docSetKey` 自身也经 `canonPath` 归一;本函数不因此简化。) */
|
|
121
124
|
export function batchPathKey(p) {
|
|
122
125
|
const s = resolve(String(p)).replace(/[\\/]+/g, "/")
|
|
123
126
|
return process.platform === "win32" ? s.toLowerCase() : s
|
|
@@ -232,8 +232,9 @@ export function designDocHashes(docs) {
|
|
|
232
232
|
* 「哪一份是批档」的判据不在这里新定义——`isBatchFace` 是 doc-check 那一侧同一个批档面谓词
|
|
233
233
|
* (`docRoot.batches` 一处;显式 `null` = 本面无)。项目根按每份档自己上溯(多仓评审各归各仓)。
|
|
234
234
|
* 清单来源**首选** = 受理面同一把尺解析出的受理绝对路径(`run.docAbs`,`advisor-async.mjs` 起评时落);
|
|
235
|
-
* 只有旧实例 ∥ 手建实例没有它时才退回实例键 `docSetKey`(`
|
|
236
|
-
*
|
|
235
|
+
* 只有旧实例 ∥ 手建实例没有它时才退回实例键 `docSetKey`(`canonPath` 归一形——cwd 非项目根时
|
|
236
|
+
* 与受理路径可不同)。**反解回的路径是归一形**:`docSetKey` 自 2026-12-01 起经 `canonPath`(win32
|
|
237
|
+
* 折小写);封印哈希按路径读盘、win32 下大小写不敏感,故本兜底支行为不变,只是显示形变了。 */
|
|
237
238
|
function sealDocSetOf(run) {
|
|
238
239
|
let list = null
|
|
239
240
|
if (Array.isArray(run?.docAbs)) list = run.docAbs
|