@thincoder/core 0.11.3 → 0.11.5
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 +23 -0
- package/advisor/compaction.mjs +40 -17
- package/advisor/loop.mjs +14 -6
- package/advisor/notice.mjs +1 -1
- package/advisor/timeline.mjs +4 -4
- package/agent/completion.mjs +19 -0
- package/agent/dispatch-gates.mjs +2 -0
- package/agent/dispatch.mjs +2 -2
- package/agent/family-tools.mjs +13 -9
- package/agent/helpers.mjs +10 -6
- package/agent/planning-step.mjs +453 -0
- package/agent/post-turn.mjs +70 -2
- package/agent/run-stages.mjs +22 -50
- package/agent/run-start.mjs +17 -0
- package/agent/setup-reminders.mjs +71 -8
- package/agent/setup.mjs +8 -39
- package/agent/spawn-child.mjs +6 -2
- package/agent/task-lifecycle.mjs +146 -0
- package/agent/turn-loop.mjs +73 -11
- package/agent-tools/batch-closeout.mjs +21 -34
- package/agent-tools/batch-gate.mjs +7 -5
- package/agent-tools/batch-ledger-bind.mjs +21 -1
- package/agent-tools/batch-lifecycle.mjs +7 -7
- package/agent-tools/batch-record-write.mjs +237 -280
- package/agent-tools/batch-supersede.mjs +3 -3
- package/agent-tools/batch.mjs +42 -9
- package/agent-tools/context.mjs +0 -13
- package/agent-tools/escalate-async.mjs +7 -1
- package/agent-tools/parent-channel.mjs +7 -6
- package/agent-tools/plan.mjs +103 -67
- package/agent-tools/review-facts.mjs +3 -3
- package/agent-tools/settings.mjs +2 -0
- package/agent-tools/spawn-gates.mjs +37 -11
- package/agent-tools/ssh-session.mjs +68 -25
- package/agent-tools/ssh-transfer.mjs +7 -2
- package/agent-tools/ssh-transport.mjs +2 -2
- package/agent-tools/ssh-vault.mjs +2 -2
- package/agent-tools/step.mjs +462 -0
- package/agent-tools/subagent-actions.mjs +6 -1
- package/agent-tools/subagent-run.mjs +7 -0
- package/agent-tools/subagent-spawn.mjs +1 -1
- package/agent-tools/subagent.mjs +17 -11
- package/agent-tools/task.mjs +178 -26
- package/agent-tools.mjs +1 -0
- package/agent.mjs +2 -0
- package/config-defaults.mjs +17 -1
- package/config-migrate.mjs +8 -5
- package/config.mjs +7 -0
- package/context.mjs +5 -4
- package/declaration.mjs +4 -4
- package/generate-title.mjs +0 -6
- package/i18n.mjs +4 -0
- package/ledger-cmd.mjs +11 -1
- package/ledger-tools.mjs +15 -4
- package/manifest-schema.mjs +1 -0
- package/model-context.mjs +34 -11
- package/model-specs.mjs +5 -2
- package/package.json +1 -1
- package/prompt-files.mjs +48 -11
- package/prompt-overlays.mjs +79 -8
- package/prompts/advisor-design.md +253 -206
- package/prompts/advisor-round1.md +151 -145
- package/prompts/advisor-round2.md +136 -130
- package/prompts/advisor-round3.md +140 -134
- package/prompts/common.md +244 -96
- package/prompts/consult-base.md +29 -30
- package/prompts/discipline-engineering.md +73 -519
- package/prompts/discipline-normal.md +28 -136
- package/prompts/knowledge/batch-before-write.md +8 -0
- package/prompts/knowledge/batch-cycle-register.md +15 -0
- package/prompts/knowledge/batch-progress-ledger.md +29 -0
- package/prompts/knowledge/business-gates.md +24 -24
- package/prompts/knowledge/decision-quality.md +8 -19
- package/prompts/knowledge/doc-discipline-d-rules.md +63 -0
- package/prompts/knowledge/doc-lookup.md +25 -24
- package/prompts/knowledge/document-writing.md +11 -32
- package/prompts/knowledge/documentation-evaluation.md +42 -42
- package/prompts/knowledge/eng-dispatch-ops.md +34 -0
- package/prompts/knowledge/eng-ledger-ops.md +26 -0
- package/prompts/knowledge/evidence-discipline.md +10 -32
- package/prompts/knowledge/normal-batch-discipline.md +13 -0
- package/prompts/knowledge/normal-coding-workflow.md +97 -99
- package/prompts/knowledge/normal-delivery-collaboration.md +107 -112
- package/prompts/knowledge/normal-work-management.md +44 -44
- package/prompts/knowledge/product-security.md +7 -26
- package/prompts/knowledge/project-records.md +69 -64
- package/prompts/knowledge/tool-advisor.md +17 -17
- package/prompts/knowledge/tool-apply-patch.md +14 -14
- package/prompts/knowledge/tool-bash.md +32 -31
- package/prompts/knowledge/tool-batch-eng-coder.md +19 -13
- package/prompts/knowledge/tool-batch-eng-designer.md +21 -14
- package/prompts/knowledge/tool-batch-review.md +18 -12
- package/prompts/knowledge/tool-batch.md +93 -85
- package/prompts/knowledge/tool-browser.md +59 -59
- package/prompts/knowledge/tool-code-search.md +2 -2
- package/prompts/knowledge/tool-consult-start.md +6 -6
- package/prompts/knowledge/tool-consult-stop.md +3 -3
- package/prompts/knowledge/tool-context.md +4 -4
- package/prompts/knowledge/tool-delete.md +16 -16
- package/prompts/knowledge/tool-doc-check.md +39 -39
- package/prompts/knowledge/tool-doc-graph-read.md +11 -11
- package/prompts/knowledge/tool-doc-graph.md +48 -48
- package/prompts/knowledge/tool-doc-search.md +3 -3
- package/prompts/knowledge/tool-edit.md +30 -30
- package/prompts/knowledge/tool-eng.md +1 -1
- package/prompts/knowledge/tool-execute.md +16 -16
- package/prompts/knowledge/tool-fetch.md +15 -15
- package/prompts/knowledge/tool-file-ops.md +15 -15
- package/prompts/knowledge/tool-get-current-time.md +3 -3
- package/prompts/knowledge/tool-git-read.md +15 -15
- package/prompts/knowledge/tool-git.md +26 -26
- package/prompts/knowledge/tool-glob.md +14 -14
- package/prompts/knowledge/tool-goal.md +5 -5
- package/prompts/knowledge/tool-grep.md +19 -18
- package/prompts/knowledge/tool-hashline-edit.md +13 -13
- package/prompts/knowledge/tool-insert-after.md +14 -14
- package/prompts/knowledge/tool-instance-list.md +3 -3
- package/prompts/knowledge/tool-instance-send.md +5 -5
- package/prompts/knowledge/tool-knowledge.md +12 -12
- package/prompts/knowledge/tool-ledger-read.md +20 -20
- package/prompts/knowledge/tool-ledger.md +44 -44
- package/prompts/knowledge/tool-lint.md +10 -10
- package/prompts/knowledge/tool-ls.md +11 -11
- package/prompts/knowledge/tool-lsp.md +8 -8
- package/prompts/knowledge/tool-main-history.md +1 -1
- package/prompts/knowledge/tool-manifest-read.md +7 -7
- package/prompts/knowledge/tool-manifest.md +43 -32
- package/prompts/knowledge/tool-memory-read.md +12 -12
- package/prompts/knowledge/tool-memory.md +14 -14
- package/prompts/knowledge/tool-notify-parent.md +10 -10
- package/prompts/knowledge/tool-operations.md +88 -88
- package/prompts/knowledge/tool-peek.md +10 -0
- package/prompts/knowledge/tool-peer-instances.md +1 -1
- package/prompts/knowledge/tool-plan.md +6 -3
- package/prompts/knowledge/tool-process-read.md +8 -8
- package/prompts/knowledge/tool-process.md +11 -11
- package/prompts/knowledge/tool-question.md +11 -13
- package/prompts/knowledge/tool-read-history-batch.md +13 -13
- package/prompts/knowledge/tool-read-history.md +19 -19
- package/prompts/knowledge/tool-read-image.md +8 -8
- package/prompts/knowledge/tool-read.md +17 -17
- package/prompts/knowledge/tool-recent-changes.md +4 -4
- package/prompts/knowledge/tool-repo-outline.md +2 -2
- package/prompts/knowledge/tool-settings-read.md +5 -7
- package/prompts/knowledge/tool-settings.md +10 -10
- package/prompts/knowledge/tool-skill.md +4 -4
- package/prompts/knowledge/tool-ssh.md +66 -66
- package/prompts/knowledge/tool-step.md +26 -0
- package/prompts/knowledge/tool-subagent.md +52 -50
- package/prompts/knowledge/tool-task.md +14 -11
- package/prompts/knowledge/tool-team-ledger-read.md +7 -7
- package/prompts/knowledge/tool-team-ledger.md +13 -13
- package/prompts/knowledge/tool-timer.md +14 -14
- package/prompts/knowledge/tool-tree.md +11 -11
- package/prompts/knowledge/tool-verify.md +11 -11
- package/prompts/knowledge/tool-wait-for.md +20 -20
- package/prompts/knowledge/tool-websearch.md +16 -14
- package/prompts/knowledge/tool-write.md +10 -10
- package/prompts/knowledge/upstream-protocol.md +37 -38
- package/prompts/persona-coder.md +22 -22
- package/prompts/persona-eng-coder.md +87 -81
- package/prompts/persona-eng-designer.md +173 -153
- package/prompts/persona-engineering.md +53 -554
- package/prompts/persona-explore.md +18 -15
- package/prompts/persona-normal.md +62 -63
- package/prompts/persona-plan.md +36 -32
- package/prompts/persona-tester.md +39 -39
- package/prompts/planning-next-moves.md +9 -0
- package/prompts/subagent-base.md +4 -16
- package/provider/errors.mjs +0 -24
- package/provider/list-models.mjs +20 -2
- package/session-lifecycle.mjs +4 -3
- package/tool-args.mjs +25 -0
- package/tool-docs/peek.md +3 -0
- package/tool-docs/plan.md +1 -1
- package/tool-docs/question.md +1 -1
- package/tool-docs/step.md +3 -0
- package/tools/edit-diff.mjs +4 -4
- package/tools/index.mjs +3 -2
- package/tools/peek.mjs +447 -0
- package/tools/question.mjs +87 -9
- package/tools/ssh.mjs +1 -1
- package/window-policy.mjs +107 -80
package/agent-tools/task.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// F-CC4(CONTEXT-COMPACTION.md §6.16.5):task 列表变更 ⇒ 方向转换轻推(本档只调用;文案/去重单源 = agent-tools/context.mjs)
|
|
2
2
|
import { pushContextNudge } from "./context.mjs"
|
|
3
3
|
import { DESC } from "../tools/shared.mjs"
|
|
4
|
+
import { summarizeTaskList } from "../agent/task-lifecycle.mjs"
|
|
4
5
|
|
|
5
6
|
/** Common synonyms LLMs tend to use — normalize to canonical values */
|
|
6
7
|
const STATUS_ALIASES = {
|
|
@@ -25,8 +26,65 @@ function normalizeStatus(raw) {
|
|
|
25
26
|
return STATUS_ALIASES[key] ?? STATUS_ALIASES[raw] ?? null
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
function normalizeTargets(raw) {
|
|
30
|
+
if (!Array.isArray(raw)) return []
|
|
31
|
+
return raw.map((t) => String(t ?? "").trim()).filter(Boolean).slice(0, 12)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function resolveTaskMatchIndex(list, rawRef) {
|
|
35
|
+
const ref = String(rawRef ?? "").trim()
|
|
36
|
+
if (!ref) return -1
|
|
37
|
+
if (/^#?\d+$/.test(ref)) {
|
|
38
|
+
const idx = Number(ref.replace(/^#/, "")) - 1
|
|
39
|
+
return idx >= 0 && idx < list.length ? idx : -1
|
|
40
|
+
}
|
|
41
|
+
const needle = ref.toLowerCase()
|
|
42
|
+
const exact = list.findIndex((it) => String(it?.title ?? "").trim().toLowerCase() === needle)
|
|
43
|
+
if (exact !== -1) return exact
|
|
44
|
+
const openSub = list.findIndex((it) => it?.status !== "done" && String(it?.title ?? "").toLowerCase().includes(needle))
|
|
45
|
+
if (openSub !== -1) return openSub
|
|
46
|
+
return list.findIndex((it) => String(it?.title ?? "").toLowerCase().includes(needle))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function applyIncrementalUpdates(list, { complete, start, result, warnings }) {
|
|
50
|
+
const cleanResult = typeof result === "string" ? result.trim().slice(0, 240) : ""
|
|
51
|
+
if (Array.isArray(complete) && complete.length > 0) {
|
|
52
|
+
const markAll = complete.some((r) => {
|
|
53
|
+
const s = String(r ?? "").trim().toLowerCase()
|
|
54
|
+
return s === "all" || s === "*"
|
|
55
|
+
})
|
|
56
|
+
if (markAll) {
|
|
57
|
+
for (const it of list) {
|
|
58
|
+
if (it.status !== "done") {
|
|
59
|
+
it.status = "done"
|
|
60
|
+
if (cleanResult) it.result = cleanResult
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
for (const ref of complete) {
|
|
65
|
+
const idx = resolveTaskMatchIndex(list, ref)
|
|
66
|
+
if (idx === -1) {
|
|
67
|
+
warnings.push(`no task matched "${String(ref ?? "").trim()}"`)
|
|
68
|
+
continue
|
|
69
|
+
}
|
|
70
|
+
list[idx].status = "done"
|
|
71
|
+
if (cleanResult) list[idx].result = cleanResult
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (start !== undefined && start !== null && String(start).trim() !== "") {
|
|
76
|
+
const idx = resolveTaskMatchIndex(list, start)
|
|
77
|
+
if (idx === -1) {
|
|
78
|
+
warnings.push(`no task matched "${String(start).trim()}"`)
|
|
79
|
+
} else {
|
|
80
|
+
list[idx].status = "in_progress"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
28
85
|
/**
|
|
29
|
-
* task tool:
|
|
86
|
+
* task tool: micro-step planning and progress tracking (whole-list replace,
|
|
87
|
+
* incremental complete/start transitions, and explicit clear).
|
|
30
88
|
* 描述面 = `tool-docs/task.md`(DESC() 加载);仅改 agent 内部状态(readonly);ctx.agent 由 runAgent 注入。
|
|
31
89
|
*/
|
|
32
90
|
export const taskTool = {
|
|
@@ -37,48 +95,142 @@ export const taskTool = {
|
|
|
37
95
|
properties: {
|
|
38
96
|
items: {
|
|
39
97
|
type: "array",
|
|
98
|
+
description: "Full replacement list of tasks; pass [] to clear. Omit when using clear, complete, or start.",
|
|
40
99
|
items: {
|
|
41
100
|
type: "object",
|
|
42
101
|
properties: {
|
|
43
|
-
title: { type: "string" },
|
|
102
|
+
title: { type: "string", description: "Short summary of this micro-step." },
|
|
44
103
|
status: { type: "string", enum: ["pending", "in_progress", "done"] },
|
|
104
|
+
targets: {
|
|
105
|
+
type: "array",
|
|
106
|
+
items: { type: "string" },
|
|
107
|
+
description: "Optional file paths touched in this micro-step slice (ideally 1-3).",
|
|
108
|
+
},
|
|
109
|
+
evidence: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Optional verified facts or anchors read before editing this step.",
|
|
112
|
+
},
|
|
113
|
+
verify: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "Optional targeted check to run right after completing this step.",
|
|
116
|
+
},
|
|
117
|
+
result: {
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "Optional observed verification reading recorded when marking this step done.",
|
|
120
|
+
},
|
|
45
121
|
},
|
|
46
122
|
required: ["title", "status"],
|
|
47
123
|
},
|
|
48
124
|
},
|
|
125
|
+
clear: {
|
|
126
|
+
type: "boolean",
|
|
127
|
+
description: "Set true to clear the entire task list once all work is finished.",
|
|
128
|
+
},
|
|
129
|
+
complete: {
|
|
130
|
+
type: "array",
|
|
131
|
+
items: { type: "string" },
|
|
132
|
+
description: "1-based task numbers (e.g. \"1\"), title substrings, or \"all\" to mark done without resending items.",
|
|
133
|
+
},
|
|
134
|
+
start: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "1-based task number (e.g. \"2\") or title substring to mark in_progress without resending items.",
|
|
137
|
+
},
|
|
138
|
+
result: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "Optional observed verification reading attached to items completed via complete.",
|
|
141
|
+
},
|
|
49
142
|
},
|
|
50
|
-
required: ["items"],
|
|
51
143
|
},
|
|
52
144
|
readonly: true,
|
|
53
|
-
async execute(args, ctx) {
|
|
145
|
+
async execute(args = {}, ctx) {
|
|
146
|
+
const hasItems = Array.isArray(args.items)
|
|
147
|
+
const hasComplete = Array.isArray(args.complete) && args.complete.length > 0
|
|
148
|
+
const hasStart = args.start !== undefined && args.start !== null && String(args.start).trim() !== ""
|
|
149
|
+
const wantsClear = args.clear === true || (hasItems && args.items.length === 0 && !hasComplete && !hasStart)
|
|
150
|
+
|
|
151
|
+
if (!wantsClear && !hasItems && !hasComplete && !hasStart) {
|
|
152
|
+
return "Error: pass items (full list), clear: true, or complete/start to update tasks."
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (wantsClear) {
|
|
156
|
+
ctx.agent.tasks = []
|
|
157
|
+
ctx.agent._turnsSinceTaskUpdate = 0
|
|
158
|
+
ctx.agent._taskStaleNudgeSent = false
|
|
159
|
+
ctx.agent._onTaskUpdate?.([])
|
|
160
|
+
if (ctx.depth === 0) pushContextNudge(ctx.agent)
|
|
161
|
+
return "Task list cleared."
|
|
162
|
+
}
|
|
163
|
+
|
|
54
164
|
// Keep only non-done items + the 3 most recently completed (for context reference), max 20 to prevent accumulation
|
|
55
165
|
const warnings = []
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
166
|
+
let working
|
|
167
|
+
if (hasItems) {
|
|
168
|
+
working = args.items.map((it) => {
|
|
169
|
+
const normalized = normalizeStatus(it.status)
|
|
170
|
+
if (normalized && normalized !== it.status) {
|
|
171
|
+
warnings.push(`status "${it.status}" normalized to "${normalized}"`)
|
|
172
|
+
} else if (!normalized) {
|
|
173
|
+
warnings.push(`"${it.status}" is not valid (use: pending | in_progress | done)`)
|
|
174
|
+
}
|
|
175
|
+
const title = String(it.title ?? "").trim()
|
|
176
|
+
if (!title) {
|
|
177
|
+
warnings.push(`empty title skipped (item was: ${JSON.stringify(it).slice(0, 100)})`)
|
|
178
|
+
}
|
|
179
|
+
const entry = {
|
|
180
|
+
title,
|
|
181
|
+
status: normalized ?? "pending",
|
|
182
|
+
}
|
|
183
|
+
const targets = normalizeTargets(it.targets)
|
|
184
|
+
if (targets.length > 0) entry.targets = targets
|
|
185
|
+
const evidence = typeof it.evidence === "string" ? it.evidence.trim() : ""
|
|
186
|
+
if (evidence) entry.evidence = evidence.slice(0, 300)
|
|
187
|
+
const verify = typeof it.verify === "string" ? it.verify.trim() : ""
|
|
188
|
+
if (verify) entry.verify = verify.slice(0, 240)
|
|
189
|
+
const result = typeof it.result === "string" ? it.result.trim() : ""
|
|
190
|
+
if (result) entry.result = result.slice(0, 240)
|
|
191
|
+
return entry
|
|
192
|
+
}).filter((t) => t.title.length > 0)
|
|
193
|
+
} else {
|
|
194
|
+
working = (Array.isArray(ctx.agent.tasks) ? ctx.agent.tasks : []).map((it) => ({
|
|
195
|
+
...it,
|
|
196
|
+
...(Array.isArray(it?.targets) ? { targets: [...it.targets] } : {}),
|
|
197
|
+
}))
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (hasComplete || hasStart) {
|
|
201
|
+
applyIncrementalUpdates(working, {
|
|
202
|
+
complete: args.complete,
|
|
203
|
+
start: args.start,
|
|
204
|
+
result: args.result,
|
|
205
|
+
warnings,
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const pending = working.filter((t) => t.status !== "done")
|
|
210
|
+
const recentDone = working.filter((t) => t.status === "done").slice(-3)
|
|
74
211
|
const items = [...pending, ...recentDone].slice(0, 20)
|
|
75
212
|
ctx.agent.tasks = items
|
|
213
|
+
ctx.agent._turnsSinceTaskUpdate = 0
|
|
214
|
+
ctx.agent._taskStaleNudgeSent = false
|
|
76
215
|
ctx.agent._onTaskUpdate?.(items)
|
|
77
216
|
if (ctx.depth === 0) pushContextNudge(ctx.agent) // F-CC4 轻推(§6.16.5——depth-0 门:子代理拿不到 context 工具)
|
|
78
|
-
const
|
|
79
|
-
const
|
|
217
|
+
const info = summarizeTaskList(items, { maxOpen: 6 })
|
|
218
|
+
const active = items.filter((i) => i.status === "in_progress")
|
|
219
|
+
if (active.length > 1) {
|
|
220
|
+
warnings.push(`${active.length} items are in_progress — prefer 1 micro-step slice at a time`)
|
|
221
|
+
}
|
|
222
|
+
const activeLine = active.length === 1
|
|
223
|
+
? (() => {
|
|
224
|
+
const cur = active[0]
|
|
225
|
+
const parts = [`Active step: ${cur.title}`]
|
|
226
|
+
if (cur.targets?.length) parts.push(`targets: ${cur.targets.join(", ")}`)
|
|
227
|
+
if (cur.verify) parts.push(`verify: ${cur.verify}`)
|
|
228
|
+
return `\n${parts.join(" | ")}`
|
|
229
|
+
})()
|
|
230
|
+
: ""
|
|
231
|
+
const openLine = info.open > 0 ? `\nOpen: ${info.summary}` : ""
|
|
80
232
|
const warningText = warnings.length > 0 ? ` ⚠️ ${warnings.join("; ")}` : ""
|
|
81
|
-
return `Task list updated: ${done}/${items.length} done` +
|
|
82
|
-
(open > 0 ? ` — ${open} item(s) still open.` : " — all done.") + warningText
|
|
233
|
+
return `Task list updated: ${info.done}/${items.length} done` +
|
|
234
|
+
(info.open > 0 ? ` — ${info.open} item(s) still open.` : " — all done.") + warningText + activeLine + openLine
|
|
83
235
|
},
|
|
84
236
|
}
|
package/agent-tools.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { planTool } from "./agent-tools/plan.mjs"
|
|
7
7
|
export { subagentTool } from "./agent-tools/subagent.mjs"
|
|
8
|
+
export { stepTool, stepReadTool } from "./agent-tools/step.mjs"
|
|
8
9
|
export { taskTool } from "./agent-tools/task.mjs"
|
|
9
10
|
export { skillTool } from "./agent-tools/skill.mjs"
|
|
10
11
|
export { goalTool } from "./agent-tools/goal.mjs"
|
package/agent.mjs
CHANGED
|
@@ -81,6 +81,8 @@ export function createAgent({
|
|
|
81
81
|
_tok: null, _tokRatio: 1, // §6.17 估算自校准池化比({key,num,den};采样 = turn-loop,清空 = /new)
|
|
82
82
|
_compressFailures: 0,
|
|
83
83
|
_emptyRetries: 0, // empty-response retry budget (per-run; reset on a fresh user turn)
|
|
84
|
+
// §7.4 task 清单运行期追踪(AGENT-LOOP.md §6 ∥ §7.4):未更新轮数、一次性陈旧提醒位、交卷收尾推回计数。
|
|
85
|
+
_turnsSinceTaskUpdate: 0, _taskStaleNudgeSent: false, _taskClosePushbacks: 0,
|
|
84
86
|
// §7.1 `wrote` 判据与注入帽的载体(AGENT-LOOP.md §7.1 · §3 续跑沿用):
|
|
85
87
|
// `_batchWrites` = `batch` 工具成功写盘的累计数(`onWritten` 各汇聚点自增);`_designTurnNotices` = 本链已注入的设计轮提醒条数。
|
|
86
88
|
_batchWrites: 0, _designTurnNotices: 0,
|
package/config-defaults.mjs
CHANGED
|
@@ -42,7 +42,7 @@ export const DEFAULTS = {
|
|
|
42
42
|
streamRules: [], // time-traveling stream rules: [{ pattern: "regex", message: "reminder", action: "abort"|"warn", repeat: "always"|"once" }]
|
|
43
43
|
advisor: { guard: false }, // code review is always available; guard: true pushes completion back until reviewed (opt-in). Also accepts provider/model/thinking/reasoningEffort/timeoutMs overrides. Deprecated: enabled (2026-08-21)
|
|
44
44
|
autoThink: false, // auto-classify task difficulty and set reasoning effort per-turn
|
|
45
|
-
mode: "normal", //
|
|
45
|
+
mode: "normal", // config-level work-mode default: tiny | normal | engineering — a new session starts from its slot, not from this key (SESSION.md §8)
|
|
46
46
|
engineering: false, // derived runtime compatibility view only: mode === "engineering"
|
|
47
47
|
// Async pool limits (AGENT-LOOP-ASYNC-POOL.md §6.10 D-24a/R14 + R13 — POOL-CONFIG-
|
|
48
48
|
// UNIFIED 2026-09-09): { engCoder, other, advisor } — eng-coder pool / other-role
|
|
@@ -66,6 +66,22 @@ export const DEFAULTS = {
|
|
|
66
66
|
injectDocs: true,
|
|
67
67
|
injectProjectRules: true,
|
|
68
68
|
injectMemories: true,
|
|
69
|
+
// Harness 独立「Planning next moves」规划步(AGENT-LOOP.md §7.3):默认开(normal/engineering 生效,tiny/子代理自动跳过);
|
|
70
|
+
// model / reasoningEffort 为空时复用当前会话 provider 与 KV 前缀缓存,可单独配强模型或更高思考力度。
|
|
71
|
+
planningNextMoves: {
|
|
72
|
+
enabled: true,
|
|
73
|
+
onStart: true,
|
|
74
|
+
onAdvisor: true,
|
|
75
|
+
onMilestone: true,
|
|
76
|
+
intervalTurns: 2,
|
|
77
|
+
probeThreshold: 3,
|
|
78
|
+
errorThreshold: 2,
|
|
79
|
+
onCompaction: true,
|
|
80
|
+
maxPerRun: 50,
|
|
81
|
+
minCooldownTurns: 0,
|
|
82
|
+
model: null,
|
|
83
|
+
reasoningEffort: null,
|
|
84
|
+
},
|
|
69
85
|
},
|
|
70
86
|
memory: {
|
|
71
87
|
dbPath: join(configDir, "memory.db"),
|
package/config-migrate.mjs
CHANGED
|
@@ -30,17 +30,20 @@ const LEGACY_MODE_ALIASES = Object.freeze({ minimal: "tiny" })
|
|
|
30
30
|
* 给“读到旧字面要就地归一”的快照/写回面用(如 VSC 端槽写前的 mode 归一),不改变回退语义。 */
|
|
31
31
|
export const normalizeWorkMode = (mode) => (typeof mode === "string" && Object.hasOwn(LEGACY_MODE_ALIASES, mode) ? LEGACY_MODE_ALIASES[mode] : mode)
|
|
32
32
|
|
|
33
|
-
/** The only work-mode authority. A present but invalid mode falls back to normal
|
|
34
|
-
*
|
|
33
|
+
/** The only work-mode authority. A present but invalid mode falls back to normal, and so does a
|
|
34
|
+
* config with no mode key: the legacy `engineering` boolean is a derived runtime view, never a mode
|
|
35
|
+
* (SESSION.md §8, CONFIG.md §5.4 — a new session starts from its slot, not from config.json). */
|
|
35
36
|
export function resolveWorkMode(agentConfig = {}) {
|
|
36
37
|
if (agentConfig && typeof agentConfig === "object" && Object.hasOwn(agentConfig, "mode")) {
|
|
37
38
|
const mode = normalizeWorkMode(agentConfig.mode)
|
|
38
39
|
return WORK_MODES.includes(mode) ? mode : "normal"
|
|
39
40
|
}
|
|
40
|
-
return
|
|
41
|
+
return "normal"
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
/** Restore prefers a valid slot mode, then
|
|
44
|
+
/** Restore prefers a valid slot mode, then the slot's legacy boolean; a slot with neither is normal.
|
|
45
|
+
* Config `agent.mode` is not a restore authority, and `agentConfig` is accepted only for call-site
|
|
46
|
+
* compatibility (SESSION.md §8, CONFIG.md §5.4: neither side takes a config default). */
|
|
44
47
|
export function resolveSessionWorkMode(data, agentConfig = {}) {
|
|
45
48
|
if (data && typeof data === "object") {
|
|
46
49
|
const mode = normalizeWorkMode(data.mode)
|
|
@@ -49,7 +52,7 @@ export function resolveSessionWorkMode(data, agentConfig = {}) {
|
|
|
49
52
|
if (data && typeof data === "object" && data.engineering !== undefined) {
|
|
50
53
|
return data.engineering === true ? "engineering" : "normal"
|
|
51
54
|
}
|
|
52
|
-
return
|
|
55
|
+
return "normal"
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
/** Update the sole mode and derive the compatibility boolean for old runtime consumers. */
|
package/config.mjs
CHANGED
|
@@ -224,6 +224,13 @@ export function loadConfig() {
|
|
|
224
224
|
// only when mode is absent. The old boolean remains a derived runtime view, never a second authority.
|
|
225
225
|
merged.agent.mode = resolveWorkMode(config.agent)
|
|
226
226
|
merged.agent.engineering = merged.agent.mode === "engineering"
|
|
227
|
+
// 独立「Planning next moves」规划步配置归一:支持布尔 false 简写或局部字段覆写(未写字段继承 DEFAULTS)。
|
|
228
|
+
const rawPlan = config.agent?.planningNextMoves
|
|
229
|
+
merged.agent.planningNextMoves = rawPlan === false
|
|
230
|
+
? { ...DEFAULTS.agent.planningNextMoves, enabled: false }
|
|
231
|
+
: rawPlan && typeof rawPlan === "object" && !Array.isArray(rawPlan)
|
|
232
|
+
? { ...DEFAULTS.agent.planningNextMoves, ...rawPlan }
|
|
233
|
+
: { ...DEFAULTS.agent.planningNextMoves }
|
|
227
234
|
|
|
228
235
|
// 丢弃要看得见(同节「丢弃要看得见 · 数据面载体」):载体只在有丢弃时有值(无丢弃 ⇒ undefined,
|
|
229
236
|
// 与 `[]` 同义)。一条一句挂数据层;出词归消费面——本批唯一消费方 = `/model` L1 列表首行
|
package/context.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import { flattenHistory, flatIndexOf, positionOf, setInject } from "./context-pu
|
|
|
20
20
|
// 大纲正文 = `sessionOutlineOf`。压缩是本批的第二个刷新点——切走第一条真实用户消息所在轮之后重算一次,
|
|
21
21
|
// 下一次装配就贴到压缩边界后的新锚点上。
|
|
22
22
|
import { pushSessionHeadBlock, sessionOutlineOf } from "./agent/setup-reminders.mjs"
|
|
23
|
+
import { syncPlanSlot } from "./agent-tools/plan.mjs"
|
|
23
24
|
// 降级留痕(头块写入失败那一支)——核日志单一通道。
|
|
24
25
|
import { logEvent } from "./log.mjs"
|
|
25
26
|
// 压缩后回注的工作状态块(§6.1「工作状态的找回」):块怎么生成住 `compaction-work-state.mjs`;
|
|
@@ -113,9 +114,7 @@ function reinjectAfterCompaction(agent, workState) {
|
|
|
113
114
|
setInject(agent, "tasks", agent.tasks.length > 0
|
|
114
115
|
? `${TASK_REINJECT_PREFIX}\n${agent.tasks.map((t) => `- [${t.status}] ${t.title}`).join("\n")}\nContinue from where you left off.]`
|
|
115
116
|
: null)
|
|
116
|
-
|
|
117
|
-
? "[System reminder: plan mode is active. Explore the codebase read-only, design your solution, then call plan with action='exit' to present it for user approval.]"
|
|
118
|
-
: null)
|
|
117
|
+
syncPlanSlot(agent)
|
|
119
118
|
setInject(agent, "work-state", workState)
|
|
120
119
|
}
|
|
121
120
|
|
|
@@ -263,7 +262,9 @@ export async function compressIfNeeded(agent, threshold, callbacks, extras, sign
|
|
|
263
262
|
let usage = contextUsage(agent, extras)
|
|
264
263
|
if (!extras.force && usage.total <= threshold) return false
|
|
265
264
|
// ② 固定开销单独越线(#2398 · §5):history 归零后 `total` 仍等于固定开销 ⇒ 压缩无解。强压面也不放行
|
|
266
|
-
//
|
|
265
|
+
// (压一次白付一次摘要请求,压完仍抛同一个错)。判据是 `fixedFloor > limit`(有效窗口的装填上限)。
|
|
266
|
+
// `budgetOf` 把 `reserve` 封在 `window − threshold` 以下 ⇒ `limit ≥ threshold`,这道门与压缩线同源同面,
|
|
267
|
+
// 不再「先于压缩线开火」。算式的唯一实现是 `window-policy.mjs` 的 `compactLineOf`,这里不重写第二份。
|
|
267
268
|
if (usage.fixedFloor > policyBudget(agent.provider).limit) return false
|
|
268
269
|
// ③ prune 一次 → 基线按 §3.1 重定(在 prune 内部)→ 重测
|
|
269
270
|
if (pruneStaleToolOutputs(agent).pruned > 0) usage = contextUsage(agent, extras)
|
package/declaration.mjs
CHANGED
|
@@ -116,7 +116,7 @@ function batchSegments(v) {
|
|
|
116
116
|
return out
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
/** `docRoot`
|
|
119
|
+
/** `docRoot` 七键 → 每键一张**根相对路径表**(`null` = 本仓没有这一层,原样保留;空表 = 声明了但展开为空)。
|
|
120
120
|
* 键序 = 模式表键序(`DEFAULT_MANIFEST.docRoot`),与声明文件里的书写序无关——层的出场序由此定。
|
|
121
121
|
* 展开单源 = `docRootPaths`(F7:归一 / 去重 / 禁 `..` 值都在那一处);本函数只把绝对形折回根相对
|
|
122
122
|
* 并剔除越根值,不另写路径运算——索引范围面与层投影吃同一张表(不各自再展开一次声明)。 */
|
|
@@ -180,10 +180,10 @@ export function isExcludedRelPath(rel, decl, base = null) {
|
|
|
180
180
|
/** 层的权威属性(逐键:这层算不算权威层,仅供读者取用;层表本体由声明投影得出,不住本表)。
|
|
181
181
|
* 成员正文单源 = `docs/core/design/DOC-SYSTEM.md` §3.1「权威层 = `standards` ∪ `requirements` ∪ `design`。
|
|
182
182
|
* 其余层不享受检索注入的保底名额。」——消费者读 `docLayers` 的 `authority` 标志,不另持一份名单。 */
|
|
183
|
-
const LAYER_AUTHORITY = Object.freeze({ requirements: true, specs: false, design: true, modules: false, batches: false, standards: true })
|
|
183
|
+
const LAYER_AUTHORITY = Object.freeze({ requirements: true, specs: false, design: true, modules: false, batches: false, standards: true, manuals: false })
|
|
184
184
|
|
|
185
185
|
/** 层表(有序 = `docRoot` 键序):`[{ layer, authority, roots }]`;`roots` = 根相对声明根表。
|
|
186
|
-
* `null`
|
|
186
|
+
* `null` 的层不出行(声明了「本仓没有这一层」,不产出空层名);缺键不在此列:`fillDefaults` 补的是 `DEFAULT_MANIFEST` 的值,两支分开——`manuals` 缺键补成默认根 `docs/manuals` 照常出行,`standards` 缺键补成 `null` 与显式 `null` 同归不出行(`docs/core/design/MANIFEST.md` §2.3)。空表同理。
|
|
187
187
|
* @param {Readonly<object>|null} decl `loadProjectDeclaration` 回执
|
|
188
188
|
* @returns {Array<{layer: string, authority: boolean, roots: string[]}>}
|
|
189
189
|
*/
|
|
@@ -423,7 +423,7 @@ function warnRetiredCarrier(root) {
|
|
|
423
423
|
* read error) → defaults + `console.warn` + a log event (visible degradation, never a throw).
|
|
424
424
|
* A retired `.thincoder/conventions.json` at the manifest's project root → one warning
|
|
425
425
|
* per cache miss (content zero-parsed, zero effect on the readings — KD-M1-34).
|
|
426
|
-
* `docRoot` = the layer projection (ONE place: the
|
|
426
|
+
* `docRoot` = the layer projection (ONE place: the seven keys → one root-relative table each;
|
|
427
427
|
* `null` = "this repository has no such layer", kept as `null`). It is the single input of
|
|
428
428
|
* `docLayers` / `docLayerOf` and of the index-scope face — neither re-expands the declaration.
|
|
429
429
|
* @param {string} cwd — project dir / anchor (root resolved by manifest.mjs)
|
package/generate-title.mjs
CHANGED
|
@@ -21,9 +21,6 @@ import { stripAtRefs } from "./file-refs.mjs"
|
|
|
21
21
|
// (`thinkOffShape` / `thinkOffPath`——本档零副本);spec 查表同单源(`specForModel`)。
|
|
22
22
|
import { specForModel } from "./model-specs.mjs"
|
|
23
23
|
import { thinkOffShape, thinkOffPath } from "./think-off.mjs"
|
|
24
|
-
// §2.4 矛盾格:预算带 `contradiction` 时一条请求也不发(同一句「矛盾未解前该渠道一律不发请求」的第五个落点)。
|
|
25
|
-
// 取模型窗口出口 `requestBudget`:与策略出口同一次派生、不需 `workMode` ⇒ CLI ∥ 桌面 ∥ VSC 三端共用一处。
|
|
26
|
-
import { requestBudget } from "./window-policy.mjs"
|
|
27
24
|
// 拍平投影(回退支读机读线时用):机读线按轮嵌套。
|
|
28
25
|
import { flattenHistory } from "./context-push.mjs"
|
|
29
26
|
|
|
@@ -44,9 +41,6 @@ export async function generateTitle(userContent, provider) {
|
|
|
44
41
|
: userContent
|
|
45
42
|
if (typeof userText !== "string" || userText.length < 10) return null
|
|
46
43
|
if (!provider?.apiKey || !provider?.baseURL || !provider?.model) return null
|
|
47
|
-
// 配置矛盾上一条请求都不发(`CONTEXT-COMPACTION.md` §2.4):标题回退由调用方取首条真实用户消息,
|
|
48
|
-
// 本格因此只是「少一个网络往返」,不新增失败路径(下游本来就 `catch` ⇒ `null`)。
|
|
49
|
-
if (requestBudget(provider).contradiction) return null
|
|
50
44
|
|
|
51
45
|
// #363③:禁思考形(三格式支共用)——off 取形与可宣称性引核单源:`thinkOffPath` 假
|
|
52
46
|
// (thinkAlwaysOn 族)或 `thinkOffShape` 为 `null`(effort 族——`null` 形是核载荷门的
|
package/i18n.mjs
CHANGED
|
@@ -74,6 +74,9 @@ export const CORE_MESSAGES = Object.freeze({
|
|
|
74
74
|
// ── 思考 / 工具状态词 ──
|
|
75
75
|
"status.stopped": { en: "[stopped]", zh: "[已停止]" },
|
|
76
76
|
"status.thinking": { en: "Thinking", zh: "思考中" },
|
|
77
|
+
"status.planningNext": { en: "Planning next moves", zh: "规划下一步" },
|
|
78
|
+
"status.thoughtFor": { en: "Thought · ${sec}s", zh: "已思考 · ${sec}s" },
|
|
79
|
+
"status.plannedNextFor": { en: "Planned next moves · ${sec}s", zh: "已规划下一步 · ${sec}s" },
|
|
77
80
|
"status.turn": { en: "turn ${n}/${m}", zh: "轮次 ${n}/${m}" },
|
|
78
81
|
// ── 团队登录态(登录面补全批 · 2026-10-10 · 台账 #1231——TEAM.md §2.6:已失效段 ∥ 面板失效行;图形端经核字典投影直取)──
|
|
79
82
|
"status.team.invalid": { en: "Session expired — log in again", zh: "已失效——重新登录" },
|
|
@@ -84,6 +87,7 @@ export const CORE_MESSAGES = Object.freeze({
|
|
|
84
87
|
// ── SSH 会话(批 ssh-session · 台账 #1436 · TOOLS.md §6.22 ⑧——凭据窗词面单源;三端经本字典投影)──
|
|
85
88
|
"ssh.credentialTitle": { en: "SSH credential", zh: "SSH 凭据" },
|
|
86
89
|
"ssh.credentialPrompt": { en: "Enter the login credential for ${host}", zh: "输入 ${host} 的登录凭据" },
|
|
90
|
+
"ssh.credentialRetryPrompt": { en: "Authentication rejected for ${host} — check username/password and try again", zh: "${host} 认证失败——请核对用户名和密码后重试" },
|
|
87
91
|
"ssh.secretTitle": { en: "SSH secret", zh: "SSH 密文" },
|
|
88
92
|
"ssh.secretPrompt": { en: "Enter the secret for ${host}", zh: "输入 ${host} 的密文" },
|
|
89
93
|
"ssh.field.user": { en: "Username", zh: "用户名" },
|
package/ledger-cmd.mjs
CHANGED
|
@@ -98,7 +98,17 @@ export function ledgerQuery({ cwd, boundary, status = null, kind = null, board =
|
|
|
98
98
|
if (!db) return []
|
|
99
99
|
try {
|
|
100
100
|
const where = [], args = []
|
|
101
|
-
if (status) {
|
|
101
|
+
if (status) {
|
|
102
|
+
// 单值或集合:`status` 接受字符串,也接受数组(默认未决四态走这条——见 `ledger-tools.mjs`
|
|
103
|
+
// 的 `LIVE_STATUSES`)。集合用 `IN`,单值仍是等值,行为对旧调用零变。
|
|
104
|
+
const list = Array.isArray(status) ? status : [status]
|
|
105
|
+
if (list.length === 0) throw new Error("ledgerQuery:status 集合为空(要全部行就省略 status,不要传空数组)")
|
|
106
|
+
for (const v of list) {
|
|
107
|
+
if (typeof v !== "string" || v === "") throw new Error(`ledgerQuery:status 集合里有非字符串或空值:${JSON.stringify(v)}`)
|
|
108
|
+
}
|
|
109
|
+
where.push(`status IN (${list.map(() => "?").join(", ")})`)
|
|
110
|
+
args.push(...list)
|
|
111
|
+
}
|
|
102
112
|
if (kind) { where.push("kind = ?"); args.push(kind) }
|
|
103
113
|
if (board) { where.push("board = ?"); args.push(board) }
|
|
104
114
|
if (trigger) { where.push("trigger = ?"); args.push(trigger) }
|
package/ledger-tools.mjs
CHANGED
|
@@ -84,9 +84,18 @@ function parseQueryCursor(raw) {
|
|
|
84
84
|
/** 回显段(§7.2「回显段」):本页生效的过滤原样带上,形如 `, status:"在途"`;一枚没给 ⇒ 空串(`cursor`
|
|
85
85
|
* 前不留逗号)。**回显是「照抄尾行就翻同一本账」的前提**——不回显则第二页按未过滤全集取行、`<N>` 从过滤集
|
|
86
86
|
* 换成全库,且零报错。`cwd` 同一道理:换锚就换了库。 */
|
|
87
|
-
const QUERY_ECHO_KEYS = ["status", "kind", "board", "trigger", "task_book", "cwd"]
|
|
87
|
+
const QUERY_ECHO_KEYS = ["status", "kind", "board", "trigger", "task_book", "cwd", "includeArchived"]
|
|
88
88
|
const queryEchoOf = (args) => QUERY_ECHO_KEYS.filter((k) => args[k] != null).map((k) => `, ${k}:${JSON.stringify(args[k])}`).join("")
|
|
89
89
|
|
|
90
|
+
/** `query` 的状态过滤:显式 `status` 恒胜;缺席时默认只在未决四态上取。
|
|
91
|
+
* `includeArchived:true` 把归档两态放回来(此时不注入 —— 省略状态 = 全六态,与旧行为同)。
|
|
92
|
+
* 这个默认与 `ledgerCount` 同口径:`count` 一直只数未决四态(`LEDGER.md` §7.1)。 */
|
|
93
|
+
const LIVE_STATUSES = ["待讨论", "待设计", "在途", "待核销"]
|
|
94
|
+
function statusFilterOf(rest) {
|
|
95
|
+
if (rest.status != null) return rest.status
|
|
96
|
+
return rest.includeArchived === true ? null : LIVE_STATUSES
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
/** 分页切片 + 尾行(§7.2「回执逐字」四态)。`rows` = 核返回的**全量**行集(本函数不读库;排序在副本上
|
|
91
100
|
* 就地做,核的 `ORDER BY id` 零改):`<N>` = 同一行集的长度(不另跑 `count`——两数出自同一次读,不会互相
|
|
92
101
|
* 打架);`<P>` / `<A>–<B>` = 同一行集的序号;`cursor` 越过末行 ⇒ 本页空(与「候选集空」同一行)。 */
|
|
@@ -251,7 +260,8 @@ const ACTION_SPECS = {
|
|
|
251
260
|
type: "object",
|
|
252
261
|
properties: {
|
|
253
262
|
cwd: { type: "string", description: CWD_DESC },
|
|
254
|
-
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "Filter by state
|
|
263
|
+
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "Filter by one state. Omitted ⇒ the four live states only (待讨论 · 待设计 · 在途 · 待核销); archived rows (已核销 · 已废弃) are excluded unless you pass includeArchived:true or name one here. An explicit status always wins — includeArchived has no effect when this is set." },
|
|
264
|
+
includeArchived: { type: "boolean", description: "Return archived rows too (已核销 · 已废弃). Default false ⇒ the four live states only. Only meaningful when `status` is omitted; an explicit status wins." },
|
|
255
265
|
kind: { type: "string", enum: ["requirement", "tech_todo"], description: "Filter by kind." },
|
|
256
266
|
board: { type: "string", description: "Filter by owning board (a requirements document name)." },
|
|
257
267
|
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "Filter by tech-todo trigger — one of the three `enum` values. Omitted ⇒ no filter, and rows carrying no trigger (NULL) are left in." },
|
|
@@ -291,7 +301,8 @@ const UNION_PARAMETERS = {
|
|
|
291
301
|
resume_when: { type: "string", description: "Resume condition sentence: optional on add and update, for rows whose trigger is the conditional-resume kind. One sentence plus an optional anchor `@YYYY-MM-DD` or `@<event name>`. A blank or whitespace-only value is refused." },
|
|
292
302
|
id: { type: "number", description: "Row id — on update and close, pass exactly one of id and batch." },
|
|
293
303
|
batch: { type: "string", description: "Batch-record pointer — on update and close, pass exactly one of id and batch. Batch-level bulk: settles that batch's rows in one call. On update, with `status` every row is re-judged against the migration table; without it this is a plain field patch. On close only 待核销 rows are settled, and `status` may be omitted." },
|
|
294
|
-
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "Status — one of the six. Single-row close requires it and accepts `已核销` or `已废弃`. With `batch`, close may omit it; given, it must be `已核销`. update migrates the row; query filters by it." },
|
|
304
|
+
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "Status — one of the six. Single-row close requires it and accepts `已核销` or `已废弃`. With `batch`, close may omit it; given, it must be `已核销`. update migrates the row; query filters by it — and on query, omitting it returns the four live states only." },
|
|
305
|
+
includeArchived: { type: "boolean", description: "query only: return archived rows too (已核销 · 已废弃). Default false ⇒ the four live states only. Meaningless when `status` is given — an explicit status wins." },
|
|
295
306
|
executor: { type: "string", description: "Executor session id (update, optional — override the owner when taking a row over). The default follows the state transition: entering 待设计 or 在途 writes this session automatically. Leaving 在途, withdrawing or returning to 待讨论 clears it. 待核销 → 在途 always writes this session, and an explicit value does not override it." },
|
|
296
307
|
cursor: { type: "string", description: "Page cursor (query, optional): copy the previous page's tail line verbatim (form `<updated_at>|<id>`). A malformed cursor is refused — never silently treated as page one." },
|
|
297
308
|
},
|
|
@@ -374,7 +385,7 @@ function makeLedgerTool(actions, { readonly = false, writeFace = false } = {}) {
|
|
|
374
385
|
const target = startOf(ctx, anchor, rest.cwd, rest.task_book)
|
|
375
386
|
const cursor = rest.cursor == null ? null : parseQueryCursor(rest.cursor)
|
|
376
387
|
assertLedgerStart(target, anchor)
|
|
377
|
-
const rows = ledgerQuery({ cwd: target, boundary: anchor, status: rest
|
|
388
|
+
const rows = ledgerQuery({ cwd: target, boundary: anchor, status: statusFilterOf(rest), kind: rest.kind, board: rest.board, trigger: rest.trigger, task_book: rest.task_book })
|
|
378
389
|
const { page, tail } = queryPageOf(rows, cursor, queryEchoOf(rest))
|
|
379
390
|
return `${JSON.stringify(page, null, 2)}\n\n${tail}`
|
|
380
391
|
}
|
package/manifest-schema.mjs
CHANGED
|
@@ -42,6 +42,7 @@ export const DEFAULT_MANIFEST = Object.freeze({
|
|
|
42
42
|
// 默认 `null`(未声明)是三态的地基:给一条默认目录,「未声明」与「声明了但层里没档」会读出
|
|
43
43
|
// 同一路径、塌成一态。
|
|
44
44
|
standards: null,
|
|
45
|
+
manuals: "docs/manuals",
|
|
45
46
|
}),
|
|
46
47
|
// 项目声明三族(2026-09-27 声明载体唯一化批并入——键名 / 形态逐字承前;来源档已退役)。
|
|
47
48
|
// 无默认段(KD-M1-31 · 逐面对照 = `docs/core/design/MANIFEST.md` §2.4.1):默认段不是便利缺省,
|
package/model-context.mjs
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - L1 `providers[].modelContext[模型]`(人工声明,**K** 单位)→ `manualContextK`(返 K)
|
|
8
8
|
* - L3 `/models` 自报窗口(**token**)→ `listedContextTokens`(返 token)
|
|
9
|
+
* - L3 `/models` 自报输出上限(**token**)→ `listedOutputTokens`(返 token)
|
|
10
|
+
* 同一份自报里的两个量(窗口预算 / 单次输出天花板)住两张表、两条读面,一个端报窗口不代它报输出上限。
|
|
9
11
|
* 单位进函数名:乘点唯一在 `model-specs.mjs`(L1 ∥ L2 ×1024,L3 不乘)——读函数名即知单位。
|
|
10
12
|
*
|
|
11
13
|
* 缓存触发 = 既有列表拉取(写面只在 `provider/list-models.mjs` 成功返回时调 `recordListedContext`):
|
|
@@ -49,24 +51,34 @@ export function warnContextOnce(key, message) {
|
|
|
49
51
|
// 不清空上次成功值(上次自报比静态表更接近事实)。归一索引在写时建好 ⇒ 读面是一次 `Map` 查表
|
|
50
52
|
// (同键多条目 = 末段相撞,读面取列表序第一条——R29④)。
|
|
51
53
|
const listedByEndpoint = new Map()
|
|
54
|
+
// 同一份自报里的另一个量:窗口是 prompt + output 的总预算,输出上限是单次回答的天花板。
|
|
55
|
+
// **两表同生同灭**:一次成功拉取就整条替换,两条读面互不代偿。
|
|
56
|
+
const listedOutputByEndpoint = new Map()
|
|
52
57
|
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
export function recordListedContext(baseURL, entries) {
|
|
56
|
-
const base = normalizeBaseURL(baseURL)
|
|
57
|
-
if (!base) return
|
|
58
|
+
/** 条目表构建(两表共用一个函数:同形同建,两条读面的归一与撞键口径不会漂成两份)。 */
|
|
59
|
+
function indexOf(entries) {
|
|
58
60
|
const index = new Map()
|
|
59
|
-
for (const [id,
|
|
61
|
+
for (const [id, value] of entries ?? []) {
|
|
60
62
|
if (typeof id !== "string" || !id) continue
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
+
const tokens = positiveInt(value)
|
|
64
|
+
if (tokens === null) continue
|
|
63
65
|
const key = normalizeModelKey(id)
|
|
64
66
|
if (!key) continue
|
|
65
67
|
const bucket = index.get(key)
|
|
66
|
-
if (bucket) bucket.push({ id, tokens
|
|
67
|
-
else index.set(key, [{ id, tokens
|
|
68
|
+
if (bucket) bucket.push({ id, tokens })
|
|
69
|
+
else index.set(key, [{ id, tokens }])
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
return index
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** L3 写面(唯一入口):记录一个端点的列表自报表。`windows` / `outputs` 都是 `Map<id, tokens>`
|
|
75
|
+
* 或 `[id, tokens]` 可迭代(Map ∥ 数组);非法值当场丢弃(= 该模型列表未报)。空表也写入
|
|
76
|
+
* ——「这次一条都没报」是事实;传 `undefined` 与传空表同判(两表都落成空索引,读面落下一层)。 */
|
|
77
|
+
export function recordListedContext(baseURL, windows, outputs) {
|
|
78
|
+
const base = normalizeBaseURL(baseURL)
|
|
79
|
+
if (!base) return
|
|
80
|
+
listedByEndpoint.set(base, indexOf(windows))
|
|
81
|
+
listedOutputByEndpoint.set(base, indexOf(outputs))
|
|
70
82
|
}
|
|
71
83
|
|
|
72
84
|
/** L3 读面:列表自报窗口(token,不乘)。未报 ⇒ `null`(落下一层);同端点两 id 末段相撞
|
|
@@ -79,6 +91,16 @@ export function listedContextTokens(provider) {
|
|
|
79
91
|
return bucket ? positiveInt(bucket[0].tokens) : null
|
|
80
92
|
}
|
|
81
93
|
|
|
94
|
+
/** L3 读面(输出上限):列表自报的单次输出天花板(token,不乘)。未报 ⇒ `null`(落回静态表档)。
|
|
95
|
+
* 与 `listedContextTokens` 同形但**不同表**:一个端报窗口不代它报输出上限。 */
|
|
96
|
+
export function listedOutputTokens(provider) {
|
|
97
|
+
const base = normalizeBaseURL(provider?.baseURL)
|
|
98
|
+
const target = normalizeModelKey(provider?.model)
|
|
99
|
+
if (!base || !target) return null
|
|
100
|
+
const bucket = listedOutputByEndpoint.get(base)?.get(target)
|
|
101
|
+
return bucket ? positiveInt(bucket[0].tokens) : null
|
|
102
|
+
}
|
|
103
|
+
|
|
82
104
|
/** L1 读面:`providers[].modelContext[模型]` 人工声明(K 单位)。未声明 ∥ 值非法 ⇒ `null`
|
|
83
105
|
* (落下一层);两条键归一后相同 = 同一模型的两种写法 ⇒ 取对象键序第一条即用(R29④——
|
|
84
106
|
* 不排序、不比较、不告警)。值非法在装载期已告警一次(`config.mjs`),此处只判不告(热路径)。 */
|
|
@@ -94,5 +116,6 @@ export function manualContextK(provider) {
|
|
|
94
116
|
/** 测试缝:清空 L3 缓存 + 告警去重(单元档用;生产零调用)。 */
|
|
95
117
|
export function _resetModelContextForTest() {
|
|
96
118
|
listedByEndpoint.clear()
|
|
119
|
+
listedOutputByEndpoint.clear()
|
|
97
120
|
warned.clear()
|
|
98
121
|
}
|
package/model-specs.mjs
CHANGED
|
@@ -360,7 +360,10 @@ export function formatDeclaredContextK(k) {
|
|
|
360
360
|
* Returns a COPY ({ ...spec, context }) when L1 / L2 / L3 supplies the window — the shared spec
|
|
361
361
|
* object from SORTED_SPECS ∥ DEFAULT_SPEC must never be mutated, or the override would leak across
|
|
362
362
|
* providers (T-C1). No L1-L3 value ⇒ the shared spec object itself (zero-copy hot path). `maxOutput`
|
|
363
|
-
* 与其余能力位仍取静态表 ∥ DEFAULT_SPEC
|
|
363
|
+
* 与其余能力位仍取静态表 ∥ DEFAULT_SPEC:本表是 `maxOutput` 的**兜底本体**,自报值不覆盖它。
|
|
364
|
+
* **输出上限另有自报面**:`/models` 的 `max_output_tokens ∥ max_completion_tokens` 经 `listedOutputTokens`
|
|
365
|
+
* 进 `outputReserve` 的 reported 档,排在本表 `maxOutput` 之前(`PROVIDER.md` §6.15)。两条链不互相覆盖:
|
|
366
|
+
* 一条给「模型族的能力上限」,一条给「这个端能接受多少」。
|
|
364
367
|
*
|
|
365
368
|
* `source` 闭集五值(`windowSource` 的唯一来源,不并类):`modelContext` ∥ `provider-override` ∥
|
|
366
369
|
* `list` ∥ `spec` ∥ `default`。`warnUnknownModel` 只在链落到 L4/L5 时触发(L1-L3 供值时 256K 告警为假)。
|
|
@@ -444,7 +447,7 @@ export function providerSpec(provider) {
|
|
|
444
447
|
* 思考签名(PROVIDER.md §6.24):`tool_calls[].extra_content` 在场才带(缺 ⇒ 键不存在——无签名上游键集逐字不变)。
|
|
445
448
|
*
|
|
446
449
|
* 调用点:`thincoder-core/agent/turn-loop.mjs`(主循环)· `thincoder-core/advisor/loop.mjs`(评审镜像)·
|
|
447
|
-
* `bench/lib/client.mjs`(bench
|
|
450
|
+
* `bench/lib/client.mjs`(bench 客户端)——各自解析自己的 spec 面、
|
|
448
451
|
* 各自算好自己的模式;服务端 live 工具轮 = `thincoder-server/src/agent/chat-compact.mjs` 的 `assistantTurnOf`
|
|
449
452
|
* (动载后调用);VSC 转口 `thincoder-vscode/src/specs.mjs` 的 `providerSpec` ∕ `assistantEchoMessage` 再导出
|
|
450
453
|
* (本仓零调用点)。
|