@thincoder/core 0.11.2 → 0.11.3
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 +18 -0
- package/advisor/compaction.mjs +7 -5
- package/advisor/history.mjs +24 -11
- package/advisor/loop.mjs +13 -8
- package/advisor/messages.mjs +72 -8
- package/advisor/run.mjs +24 -13
- package/advisor.mjs +7 -3
- package/agent/chat-call.mjs +14 -9
- package/agent/completion.mjs +28 -40
- package/agent/continue-decision.mjs +14 -8
- package/agent/digest-account.mjs +133 -59
- package/agent/dispatch-run.mjs +1 -1
- package/agent/dispatch.mjs +2 -1
- package/agent/family-tools.mjs +12 -13
- package/agent/helpers.mjs +17 -72
- package/agent/image-heal.mjs +18 -4
- package/agent/post-turn.mjs +13 -26
- package/agent/record-results.mjs +21 -6
- package/agent/run-stages.mjs +72 -37
- package/agent/run-start.mjs +148 -113
- package/agent/setup-reminders.mjs +187 -91
- package/agent/setup.mjs +204 -138
- package/agent/spawn-child.mjs +2 -2
- package/agent/suspension.mjs +43 -15
- package/agent/timers.mjs +4 -1
- package/agent/turn-domain-text.mjs +105 -0
- package/agent/turn-loop.mjs +54 -22
- package/agent/turn-projection.mjs +127 -227
- package/agent/turn-tool-process.mjs +32 -37
- package/agent-tools/advisor-async.mjs +6 -3
- package/agent-tools/advisor-launch.mjs +5 -5
- package/agent-tools/advisor.mjs +1 -1
- package/agent-tools/async-discard.mjs +7 -2
- package/agent-tools/async-settle.mjs +18 -12
- package/agent-tools/bash-async.mjs +5 -2
- package/agent-tools/batch-closeout.mjs +12 -62
- package/agent-tools/batch-ledger-bind.mjs +19 -8
- package/agent-tools/batch-lifecycle.mjs +37 -11
- package/agent-tools/batch-read.mjs +151 -4
- package/agent-tools/batch-record-write.mjs +5 -5
- package/agent-tools/batch-segment-vocab.mjs +84 -4
- package/agent-tools/batch-skeleton.mjs +18 -14
- package/agent-tools/batch-supersede.mjs +1 -1
- package/agent-tools/batch-tier-gate.mjs +36 -119
- package/agent-tools/batch.mjs +30 -20
- package/agent-tools/browser-async.mjs +5 -2
- package/agent-tools/consult.mjs +10 -7
- package/agent-tools/context.mjs +47 -31
- package/agent-tools/digest-budget.mjs +10 -9
- package/agent-tools/eng.mjs +3 -4
- package/agent-tools/escalate-async.mjs +3 -3
- package/agent-tools/goal.mjs +5 -2
- package/agent-tools/judge-domain.mjs +347 -0
- package/agent-tools/manifest.mjs +2 -2
- package/agent-tools/parent-channel.mjs +6 -3
- package/agent-tools/plan.mjs +11 -10
- package/agent-tools/review-facts.mjs +9 -3
- package/agent-tools/skill.mjs +7 -8
- package/agent-tools/spawn-gates.mjs +5 -16
- package/agent-tools/ssh-session.mjs +6 -3
- package/agent-tools/ssh-transfer.mjs +1 -1
- package/agent-tools/subagent-actions.mjs +2 -2
- package/agent-tools/subagent-async.mjs +11 -8
- package/agent-tools/subagent-scheduler.mjs +9 -9
- package/agent-tools/subagent-spawn.mjs +2 -2
- package/agent-tools/subagent.mjs +5 -18
- package/agent-tools/task.mjs +0 -8
- package/agent.mjs +15 -15
- package/auto-think.mjs +5 -2
- package/compaction-work-state.mjs +230 -0
- package/compress-form.mjs +41 -6
- package/config-defaults.mjs +5 -2
- package/config.mjs +53 -17
- package/context-degrade.mjs +79 -48
- package/context-echo.mjs +6 -26
- package/context-push.mjs +328 -31
- package/context.mjs +203 -141
- package/conventions.mjs +1 -1
- package/declaration.mjs +95 -17
- package/escape.mjs +6 -5
- package/explore-distill.mjs +35 -8
- package/generate-title.mjs +10 -1
- package/knowledge/prompt-resources.md +5 -1
- package/ledger-tools.mjs +50 -50
- package/ledger-write-ops.mjs +43 -16
- package/memory/docs.mjs +51 -15
- package/memory/file-list.mjs +6 -0
- package/model-specs.mjs +87 -21
- package/origin-guard.mjs +190 -0
- package/package.json +1 -1
- package/prompt-files.mjs +33 -11
- package/prompt-overlays.mjs +12 -5
- package/prompts/advisor-design.md +55 -36
- package/prompts/advisor-round1.md +18 -7
- package/prompts/advisor-round2.md +18 -7
- package/prompts/advisor-round3.md +18 -7
- package/prompts/common.md +89 -51
- package/prompts/consult-base.md +2 -3
- package/prompts/discipline-engineering.md +474 -440
- package/prompts/discipline-normal.md +107 -31
- package/prompts/knowledge/business-gates.md +23 -15
- package/prompts/knowledge/decision-quality.md +16 -18
- package/prompts/knowledge/doc-lookup.md +22 -27
- package/prompts/knowledge/document-writing.md +31 -49
- package/prompts/knowledge/documentation-evaluation.md +37 -45
- package/prompts/knowledge/evidence-discipline.md +36 -55
- package/prompts/knowledge/normal-coding-workflow.md +27 -21
- package/prompts/knowledge/normal-delivery-collaboration.md +33 -17
- package/prompts/knowledge/normal-work-management.md +10 -7
- package/prompts/knowledge/product-security.md +22 -17
- package/prompts/knowledge/project-records.md +63 -52
- package/prompts/knowledge/tool-apply-patch.md +12 -13
- package/prompts/knowledge/tool-bash.md +13 -4
- package/prompts/knowledge/tool-batch-eng-coder.md +13 -6
- package/prompts/knowledge/tool-batch-eng-designer.md +14 -6
- package/prompts/knowledge/tool-batch-review.md +12 -6
- package/prompts/knowledge/tool-batch.md +76 -62
- package/prompts/knowledge/tool-browser.md +45 -34
- package/prompts/knowledge/tool-context.md +2 -2
- package/prompts/knowledge/tool-delete.md +5 -1
- package/prompts/knowledge/tool-doc-check.md +25 -24
- package/prompts/knowledge/tool-doc-graph-read.md +3 -3
- package/prompts/knowledge/tool-doc-graph.md +15 -15
- package/prompts/knowledge/tool-edit.md +26 -23
- package/prompts/knowledge/tool-execute.md +9 -4
- package/prompts/knowledge/tool-fetch.md +7 -1
- package/prompts/knowledge/tool-file-ops.md +6 -1
- package/prompts/knowledge/tool-git-read.md +3 -1
- package/prompts/knowledge/tool-git.md +1 -1
- package/prompts/knowledge/tool-glob.md +3 -1
- package/prompts/knowledge/tool-grep.md +5 -2
- package/prompts/knowledge/tool-hashline-edit.md +4 -2
- package/prompts/knowledge/tool-insert-after.md +3 -1
- package/prompts/knowledge/tool-ledger-read.md +6 -13
- package/prompts/knowledge/tool-ledger.md +14 -10
- package/prompts/knowledge/tool-ls.md +2 -0
- package/prompts/knowledge/tool-manifest.md +10 -7
- package/prompts/knowledge/tool-memory.md +15 -11
- package/prompts/knowledge/tool-operations.md +59 -71
- package/prompts/knowledge/tool-plan.md +1 -2
- package/prompts/knowledge/tool-process.md +1 -1
- package/prompts/knowledge/tool-read-history.md +6 -7
- package/prompts/knowledge/tool-read.md +1 -0
- package/prompts/knowledge/tool-settings.md +6 -7
- package/prompts/knowledge/tool-ssh.md +37 -15
- package/prompts/knowledge/tool-subagent.md +37 -39
- package/prompts/knowledge/tool-task.md +3 -1
- package/prompts/knowledge/tool-team-ledger.md +5 -1
- package/prompts/knowledge/tool-tree.md +2 -0
- package/prompts/knowledge/tool-wait-for.md +16 -16
- package/prompts/knowledge/tool-write.md +4 -1
- package/prompts/knowledge/upstream-protocol.md +39 -37
- package/prompts/persona-coder.md +1 -3
- package/prompts/persona-eng-coder.md +5 -5
- package/prompts/persona-eng-designer.md +34 -17
- package/prompts/persona-engineering.md +532 -501
- package/prompts/persona-explore.md +0 -2
- package/prompts/persona-normal.md +17 -9
- package/prompts/persona-plan.md +0 -2
- package/prompts/persona-tester.md +0 -2
- package/prompts/subagent-base.md +0 -2
- package/provider/anthropic.mjs +4 -2
- package/provider/core.mjs +5 -3
- package/provider/errors.mjs +41 -7
- package/provider/google.mjs +5 -3
- package/provider/reasoning-echo.mjs +16 -0
- package/provider/responses.mjs +4 -2
- package/provider/sse.mjs +11 -6
- package/rules.mjs +11 -10
- package/session-lifecycle.mjs +115 -81
- package/session-slot-write.mjs +1 -1
- package/session.mjs +23 -20
- package/shell-identity.mjs +129 -22
- package/skip-dirs.mjs +24 -0
- package/team-ledger.mjs +22 -22
- package/text-budget.mjs +1 -1
- package/think-off.mjs +27 -0
- package/token-ttl.mjs +1 -1
- package/token-window.mjs +278 -88
- package/tool-docs/bash.md +0 -2
- package/tool-docs/consult_start.md +2 -2
- package/tool-docs/consult_stop.md +2 -2
- package/tools/browser.mjs +8 -8
- package/tools/execute.mjs +2 -2
- package/tools/file.mjs +17 -11
- package/tools/git.mjs +12 -12
- package/tools/ops.mjs +2 -2
- package/tools/patch.mjs +1 -1
- package/tools/process-doc-mark.mjs +33 -4
- package/tools/repomap.mjs +25 -3
- package/tools/search.mjs +74 -26
- package/tools/shared.mjs +4 -3
- package/tools/ssh.mjs +5 -5
- package/tools/tree.mjs +32 -10
- package/tools/web-deepseek.mjs +1 -1
- package/tools/web.mjs +2 -2
- package/tools/write-gate-params.mjs +3 -3
- package/window-policy.mjs +118 -78
package/declaration.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { existsSync, readdirSync, statSync } from "node:fs"
|
|
9
9
|
import { basename, dirname, isAbsolute, join, parse, relative, resolve } from "node:path"
|
|
10
|
-
import { DEFAULT_MANIFEST, MANIFEST_REL, docRootPaths, manifestFilePath, onManifestInit, owningProject, readManifest } from "./manifest.mjs"
|
|
10
|
+
import { DEFAULT_MANIFEST, MANIFEST_REL, docRootBase, docRootPaths, manifestFilePath, onManifestInit, owningProject, readManifest } from "./manifest.mjs"
|
|
11
11
|
import { isSkippedRelPath } from "./memory/file-walk.mjs" // 面⑦ 子目录扫描的跳过段谓词单源(零环:file-walk 不引本档)
|
|
12
12
|
import { logEvent } from "./log.mjs"
|
|
13
13
|
|
|
@@ -79,6 +79,7 @@ function buildDeclaration(m, root = null) {
|
|
|
79
79
|
const publicRepos = normalizePathList(m?.index?.publicRepos)
|
|
80
80
|
const writableRepos = normalizePathList(m?.index?.writableRepos)
|
|
81
81
|
const batchRecords = batchSegments(m?.docRoot?.batches) // §6.14 面⑥ 声明值投影(`declared` 旗不涉——docRoot 族现状零改)
|
|
82
|
+
const docRoot = docRootTables(m?.docRoot, root) // 层投影(机制 = `docs/core/design/DOC-SYSTEM.md` §3.1「层标识」)
|
|
82
83
|
const defaults = normalizeCodePaths(DEFAULT_MANIFEST.codePaths) ?? []
|
|
83
84
|
const pathsDiffer = codePaths.length !== defaults.length || codePaths.some((p, i) => p !== defaults[i])
|
|
84
85
|
const declared = pathsDiffer || codeExtensions.length > 0 || docExtensions.length > 0 || excludePaths.length > 0 || publicRepos.length > 0
|
|
@@ -86,6 +87,7 @@ function buildDeclaration(m, root = null) {
|
|
|
86
87
|
declared,
|
|
87
88
|
codePaths: Object.freeze(codePaths),
|
|
88
89
|
batchRecords: Object.freeze(batchRecords.map((s) => Object.freeze(s))),
|
|
90
|
+
docRoot,
|
|
89
91
|
index: Object.freeze({
|
|
90
92
|
codeExtensions: Object.freeze(codeExtensions),
|
|
91
93
|
docExtensions: Object.freeze(docExtensions),
|
|
@@ -114,6 +116,29 @@ function batchSegments(v) {
|
|
|
114
116
|
return out
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
/** `docRoot` 六键 → 每键一张**根相对路径表**(`null` = 本仓没有这一层,原样保留;空表 = 声明了但展开为空)。
|
|
120
|
+
* 键序 = 模式表键序(`DEFAULT_MANIFEST.docRoot`),与声明文件里的书写序无关——层的出场序由此定。
|
|
121
|
+
* 展开单源 = `docRootPaths`(F7:归一 / 去重 / 禁 `..` 值都在那一处);本函数只把绝对形折回根相对
|
|
122
|
+
* 并剔除越根值,不另写路径运算——索引范围面与层投影吃同一张表(不各自再展开一次声明)。 */
|
|
123
|
+
function docRootTables(docRoot, root) {
|
|
124
|
+
const base = docRootBase(root ?? undefined)
|
|
125
|
+
const src = docRoot !== null && typeof docRoot === "object" && !Array.isArray(docRoot) ? docRoot : {}
|
|
126
|
+
const out = {}
|
|
127
|
+
for (const key of Object.keys(DEFAULT_MANIFEST.docRoot)) {
|
|
128
|
+
// 「本面无」是声明值(#944),不是缺键:原样保留 null,不折成空表、不补默认根。
|
|
129
|
+
if (src[key] === null) { out[key] = null; continue }
|
|
130
|
+
const rels = []
|
|
131
|
+
for (const abs of docRootPaths(src[key], root ?? undefined)) {
|
|
132
|
+
const rel = relative(base, abs).replace(/\\/g, "/")
|
|
133
|
+
const norm = rel === "" ? "." : rel
|
|
134
|
+
if (norm === ".." || norm.startsWith("../") || isAbsolute(norm)) continue // 越根值:条目子树内永不可命中
|
|
135
|
+
if (!rels.includes(norm)) rels.push(norm)
|
|
136
|
+
}
|
|
137
|
+
out[key] = Object.freeze(rels)
|
|
138
|
+
}
|
|
139
|
+
return Object.freeze(out)
|
|
140
|
+
}
|
|
141
|
+
|
|
117
142
|
/** 约定段(面⑥——`DEFAULT_MANIFEST.docRoot.batches` 单源派生;默认值改名/迁移两处同动)。 */
|
|
118
143
|
const DEFAULT_BATCH_SEGMENTS = batchSegments(DEFAULT_MANIFEST.docRoot.batches)
|
|
119
144
|
|
|
@@ -147,6 +172,62 @@ export function isExcludedRelPath(rel, decl, base = null) {
|
|
|
147
172
|
return list.some((p) => p && (s === p || s.startsWith(`${p}/`)))
|
|
148
173
|
}
|
|
149
174
|
|
|
175
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
176
|
+
// 文档层投影(机制 = `docs/core/design/DOC-SYSTEM.md` §3.1「层标识」;接口 = `docs/core/design/MANIFEST.md` §2.13):
|
|
177
|
+
// 输入 = `loadProjectDeclaration` 回执的 `docRoot` 表,本族不读 manifest、不碰盘。键名逐字即层名。
|
|
178
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
179
|
+
|
|
180
|
+
/** 层的权威属性(逐键:这层算不算权威层,仅供读者取用;层表本体由声明投影得出,不住本表)。
|
|
181
|
+
* 成员正文单源 = `docs/core/design/DOC-SYSTEM.md` §3.1「权威层 = `standards` ∪ `requirements` ∪ `design`。
|
|
182
|
+
* 其余层不享受检索注入的保底名额。」——消费者读 `docLayers` 的 `authority` 标志,不另持一份名单。 */
|
|
183
|
+
const LAYER_AUTHORITY = Object.freeze({ requirements: true, specs: false, design: true, modules: false, batches: false, standards: true })
|
|
184
|
+
|
|
185
|
+
/** 层表(有序 = `docRoot` 键序):`[{ layer, authority, roots }]`;`roots` = 根相对声明根表。
|
|
186
|
+
* `null` 或缺失的键不出行(声明了「本仓没有这一层」,不产出空层名);空表同理。
|
|
187
|
+
* @param {Readonly<object>|null} decl `loadProjectDeclaration` 回执
|
|
188
|
+
* @returns {Array<{layer: string, authority: boolean, roots: string[]}>}
|
|
189
|
+
*/
|
|
190
|
+
export function docLayers(decl) {
|
|
191
|
+
const tables = decl?.docRoot
|
|
192
|
+
if (!tables || typeof tables !== "object") return []
|
|
193
|
+
const out = []
|
|
194
|
+
for (const layer of Object.keys(tables)) {
|
|
195
|
+
const roots = tables[layer]
|
|
196
|
+
if (!Array.isArray(roots) || roots.length === 0) continue
|
|
197
|
+
out.push({ layer, authority: LAYER_AUTHORITY[layer] === true, roots: [...roots] })
|
|
198
|
+
}
|
|
199
|
+
return out
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** 出辖 / 未入任何声明根的层标识(显式一档,不是空串)。 */
|
|
203
|
+
const UNLAYERED = Object.freeze({ layer: "unlayered", authority: false })
|
|
204
|
+
|
|
205
|
+
/** 档 → 层:`absPath` 按 `decl.root` 折成根相对,再按**最长**声明根前缀判层——`modules` 根嵌在
|
|
206
|
+
* `design` 根之内,按声明序或最短前缀判会把模块档判成权威层。
|
|
207
|
+
* 出辖(`decl` 缺 ∥ 根未知 ∥ 路径在该根之外)与未落入该声明的任何声明根 ⇒ `unlayered`、非权威。
|
|
208
|
+
* `decl` = 该路径的**属辖声明**(调用面经 `declarationForTarget` 取):声明公共源里的档因此按那个仓
|
|
209
|
+
* 自己的 `docRoot` 判层,不借会话项目的根。
|
|
210
|
+
* @param {string} absPath 档的绝对路径
|
|
211
|
+
* @param {Readonly<object>|null} decl `absPath` 的属辖声明
|
|
212
|
+
* @returns {{layer: string, authority: boolean}}
|
|
213
|
+
*/
|
|
214
|
+
export function docLayerOf(absPath, decl) {
|
|
215
|
+
if (!decl || typeof decl.root !== "string" || decl.root === "") return UNLAYERED
|
|
216
|
+
let rel = relative(decl.root, resolve(String(absPath ?? ""))).replace(/\\/g, "/")
|
|
217
|
+
if (rel === "") rel = "."
|
|
218
|
+
if (rel === ".." || rel.startsWith("../") || isAbsolute(rel)) return UNLAYERED
|
|
219
|
+
let best = null
|
|
220
|
+
for (const { layer, authority, roots } of docLayers(decl)) {
|
|
221
|
+
for (const p of roots) {
|
|
222
|
+
const hit = p === "." || rel === p || rel.startsWith(`${p}/`)
|
|
223
|
+
if (!hit) continue
|
|
224
|
+
const depth = p === "." ? 0 : p.length
|
|
225
|
+
if (!best || depth > best.depth) best = { layer, authority, depth }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return best ? { layer: best.layer, authority: best.authority } : UNLAYERED
|
|
229
|
+
}
|
|
230
|
+
|
|
150
231
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
151
232
|
// §6.14 面⑦ 索引范围声明化(结构门——2026-10-13 · 台账 #1367):范围 = 锚的**管辖 manifest**
|
|
152
233
|
// 声明目录 ∪ **一级子目录**(带档者)声明目录——「未声明 ⇒ 不进」;条目集空 ⇒ 零索引
|
|
@@ -154,20 +235,15 @@ export function isExcludedRelPath(rel, decl, base = null) {
|
|
|
154
235
|
// (本规 = 新增消费点,键值语义零改)。写面(收录)∥ 读面(存量行准入)共用本谓词族。
|
|
155
236
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
156
237
|
|
|
157
|
-
/**
|
|
238
|
+
/** 文档面前缀集合(条目根相对):读 `loadProjectDeclaration` 回执的 `docRoot` 表(层投影与索引范围面
|
|
239
|
+
* 共用同一张表——本函数不再自己展开一次声明,也没有第二次读 manifest 的入口)。
|
|
158
240
|
* 值 = 根相对字面前缀(恰等 ∨ 后随 `/`——路径及子树;文件值如 `docs/RELEASE.md` ⇒ 恰该文件);
|
|
159
|
-
* `"."` =
|
|
160
|
-
|
|
161
|
-
function entryDocPaths(docRoot, root) {
|
|
241
|
+
* `"."` = 该条目根自身(整根面)。去重保序(序 = `docRoot` 键序)。 */
|
|
242
|
+
function entryDocPaths(tables) {
|
|
162
243
|
const out = []
|
|
163
|
-
if (
|
|
164
|
-
for (const key of Object.keys(
|
|
165
|
-
for (const
|
|
166
|
-
const rel = relative(root, abs).replace(/\\/g, "/")
|
|
167
|
-
if (rel === "" || rel === ".") { if (!out.includes(".")) out.push("."); continue }
|
|
168
|
-
if (rel === ".." || rel.startsWith("../") || isAbsolute(rel)) continue
|
|
169
|
-
if (!out.includes(rel)) out.push(rel)
|
|
170
|
-
}
|
|
244
|
+
if (!tables || typeof tables !== "object") return out
|
|
245
|
+
for (const key of Object.keys(tables)) {
|
|
246
|
+
for (const rel of tables[key] ?? []) if (!out.includes(rel)) out.push(rel)
|
|
171
247
|
}
|
|
172
248
|
return out
|
|
173
249
|
}
|
|
@@ -188,12 +264,10 @@ function hasSegmentRun(face, seq) {
|
|
|
188
264
|
* (坏 JSON ∥ 形态错)⇒ 两族按默认值参与 + 既有可见告警(声明链 KD-M1-32——`loadProjectDeclaration`
|
|
189
265
|
* 的降级告警单源,本档零第二实现)——不静默成零。 */
|
|
190
266
|
function scopeEntryOf(root) {
|
|
191
|
-
const decl = loadProjectDeclaration(root)
|
|
192
|
-
const r = readManifest(root)
|
|
193
|
-
const docRoot = r.ok ? r.manifest.docRoot : DEFAULT_MANIFEST.docRoot // 档在场才补默认(无档 = 无条目,不走本函数)
|
|
267
|
+
const decl = loadProjectDeclaration(root) // 声明的**一次**读取(层投影与文档面同吃回执的 `docRoot`)
|
|
194
268
|
return Object.freeze({
|
|
195
269
|
root,
|
|
196
|
-
docPaths: Object.freeze(entryDocPaths(docRoot
|
|
270
|
+
docPaths: Object.freeze(entryDocPaths(decl.docRoot)),
|
|
197
271
|
codePaths: Object.freeze([...decl.codePaths]),
|
|
198
272
|
})
|
|
199
273
|
}
|
|
@@ -349,8 +423,12 @@ function warnRetiredCarrier(root) {
|
|
|
349
423
|
* read error) → defaults + `console.warn` + a log event (visible degradation, never a throw).
|
|
350
424
|
* A retired `.thincoder/conventions.json` at the manifest's project root → one warning
|
|
351
425
|
* per cache miss (content zero-parsed, zero effect on the readings — KD-M1-34).
|
|
426
|
+
* `docRoot` = the layer projection (ONE place: the six keys → one root-relative table each;
|
|
427
|
+
* `null` = "this repository has no such layer", kept as `null`). It is the single input of
|
|
428
|
+
* `docLayers` / `docLayerOf` and of the index-scope face — neither re-expands the declaration.
|
|
352
429
|
* @param {string} cwd — project dir / anchor (root resolved by manifest.mjs)
|
|
353
430
|
* @returns {Readonly<{declared: boolean, codePaths: readonly string[], batchRecords: readonly (readonly string[])[],
|
|
431
|
+
* docRoot: Readonly<Record<string, readonly string[]|null>>,
|
|
354
432
|
* index: {codeExtensions: string[], docExtensions: string[], excludePaths: string[], publicRepos: string[],
|
|
355
433
|
* writableRepos: string[]},
|
|
356
434
|
* root: string|null}>}
|
package/escape.mjs
CHANGED
|
@@ -131,15 +131,16 @@ export function escapeMessageContent(message) {
|
|
|
131
131
|
return changed ? next : message
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
/** IKBGX4 + SESSION.md §6.9:剥离仅本地使用的整消息标记字段(transient/ts)——发送给 provider 前移除。
|
|
134
|
+
/** IKBGX4 + SESSION.md §6.9:剥离仅本地使用的整消息标记字段(transient/ts/turn/originProvider)——发送给 provider 前移除。
|
|
135
135
|
* 严格 OpenAI 兼容服务端(opencode/LiteLLM 等)会拒绝消息级未知 key
|
|
136
136
|
* ("Extra inputs are not permitted, field: 'messages[i].transient'");ts 同理
|
|
137
|
-
* (消息时间戳是本地取证字段,不进任何 provider 请求——T-S3
|
|
138
|
-
*
|
|
137
|
+
* (消息时间戳是本地取证字段,不进任何 provider 请求——T-S3);`turn` 是轮归属坐标(CONTEXT-COMPACTION
|
|
138
|
+
* §1.1),只在本地读,不上发送线;`originProvider` 是消息产出的 provider 名(AGENT-LOOP.md §5.5.3,仅本地判据)。
|
|
139
|
+
* copy-on-write:历史里的原对象不动(read_history 仍能读到 ts)。 */
|
|
139
140
|
export function stripLocalMessageFields(messages) {
|
|
140
141
|
return messages.map((m) => {
|
|
141
|
-
if (m && typeof m === "object" && ("transient" in m || "ts" in m)) {
|
|
142
|
-
const { transient, ts, ...rest } = m
|
|
142
|
+
if (m && typeof m === "object" && ("transient" in m || "ts" in m || "turn" in m || "originProvider" in m)) {
|
|
143
|
+
const { transient, ts, turn, originProvider, ...rest } = m
|
|
143
144
|
return rest
|
|
144
145
|
}
|
|
145
146
|
return m
|
package/explore-distill.mjs
CHANGED
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
import { chat } from "./provider/index.mjs"
|
|
14
14
|
import { buildCompressMessages } from "./compress-form.mjs"
|
|
15
15
|
import { estimateTokens, rebaseMeasured } from "./token-window.mjs"
|
|
16
|
+
// 压缩/蒸馏请求形的来源面(AGENT-LOOP.md §5.5.4):当下 provider 名与 spec 由本调用点显式传给构造器。
|
|
17
|
+
import { specForModel } from "./model-specs.mjs"
|
|
18
|
+
import { isThinkingRequest } from "./think-off.mjs"
|
|
19
|
+
// 拍平投影与位置换算(写面单点档):本档只读投影、写回落在在途轮的内层。
|
|
20
|
+
import { flattenHistory, flatIndexOf } from "./context-push.mjs"
|
|
16
21
|
|
|
17
22
|
/** Read-only knowledge tools counted as "exploration" (execute writes files → never exploration). */
|
|
18
23
|
export const EXPLORE_TOOLS = new Set([
|
|
@@ -90,13 +95,28 @@ async function distillExplorations(history, start, provider, signal, agent, dept
|
|
|
90
95
|
|
|
91
96
|
let summary
|
|
92
97
|
try {
|
|
98
|
+
const spec = specForModel(provider?.model)
|
|
99
|
+
const distillerProvider = { ...provider, thinking: null }
|
|
93
100
|
// Silent by design (D11): thinking:null and no onToken/onReasoning — this internal
|
|
94
101
|
// distillation must not stream to the frontend. signal propagates user cancellation.
|
|
95
102
|
// 会话续写形态(§6.15 / D-CC21):messages 由单源构造器 buildCompressMessages 产出(不设第二构造
|
|
96
103
|
// 点);tools 取与回合请求同一声明面(**不带** tool_choice——实测该参数使服务端丢弃 tools 区);
|
|
97
104
|
// 不覆盖 reasoningEffort ⇒ 与回合侧同源(v3 形态)。extras 缺省 ⇒ 退化面 1(无 system / 无 tools)。
|
|
98
|
-
|
|
99
|
-
|
|
105
|
+
// 不带上一次摘要(第五参传 `null`):摘要累积的射程是压缩(需求 §4「压缩时把上一次摘要全文并入
|
|
106
|
+
// 摘要请求的输入」),蒸馏只共用前缀、声明与 reasoningEffort(需求 §7)——不在累积之列。
|
|
107
|
+
const resp = await chat(distillerProvider, {
|
|
108
|
+
// 来源面(AGENT-LOOP.md §5.5.4):当前 provider 名与当下 spec 由本调用点显式传入,构造器不补默认。
|
|
109
|
+
messages: buildCompressMessages(
|
|
110
|
+
history,
|
|
111
|
+
cut,
|
|
112
|
+
extras?.systemPrompt,
|
|
113
|
+
EXPLORE_SUMMARY_PROMPT,
|
|
114
|
+
null,
|
|
115
|
+
provider?.name,
|
|
116
|
+
spec,
|
|
117
|
+
isThinkingRequest(distillerProvider, spec),
|
|
118
|
+
Array.isArray(extras?.tools) && extras.tools.length > 0,
|
|
119
|
+
),
|
|
100
120
|
tools: extras?.tools,
|
|
101
121
|
signal,
|
|
102
122
|
// TRACES.md §6.1 D-TR4:轨迹元数据增补——kind=distill(探索蒸馏面——agent 元数据透出;
|
|
@@ -137,16 +157,23 @@ async function distillExplorations(history, start, provider, signal, agent, dept
|
|
|
137
157
|
* ONLY after the replacement actually lands (never on no-op/failure) — callers persist the
|
|
138
158
|
* compressed session (SEND-STALL-DISTILL §2.3).
|
|
139
159
|
* `extras` = 前缀面({ systemPrompt, tools }——调用点透传、与回合请求同源 · §6.15);缺省 ⇒ 退化面 1。
|
|
160
|
+
* 射程 = 外层最后一个轮元素的内层(`CONTEXT-COMPACTION.md` §1.1)——本轮探索只在本轮自己那一截里发生;
|
|
161
|
+
* 定稿写回也是原位改那一轮的内层数组,外层元素与其它轮一条动。
|
|
140
162
|
*/
|
|
141
163
|
export async function summarizeRunExplorations(agent, callbacks, signal, depth = 0, extras) {
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const
|
|
164
|
+
const turns = Array.isArray(agent.history) ? agent.history : []
|
|
165
|
+
const last = turns.at(-1)
|
|
166
|
+
const innerLen = Array.isArray(last?.messages) ? last.messages.length : 0
|
|
167
|
+
if (innerLen === 0) return
|
|
168
|
+
const before = flattenHistory(turns)
|
|
169
|
+
const turnStart = before.length - innerLen
|
|
170
|
+
const measuredEnd = agent._usageAt ? flatIndexOf(turns, agent._usageAt) : before.length
|
|
171
|
+
const next = await distillExplorations(before, turnStart, agent.provider, signal, agent, depth, extras)
|
|
145
172
|
if (!next) return
|
|
146
|
-
|
|
173
|
+
last.messages = next.slice(turnStart)
|
|
147
174
|
// 基线按 §3.1 **重定,不归零**:蒸馏是「替换非删除」——被换掉的那些块与替换上来的那条注记各取
|
|
148
|
-
// `estimateTokens
|
|
149
|
-
// 即新的 `
|
|
175
|
+
// `estimateTokens`,差就是这一步在实测尺上的差。剪辑后仍属旧前缀的消息按身份找回,其后的第一个位置
|
|
176
|
+
// 即新的 `_usageAt`(与压缩同一条重定规则)。
|
|
150
177
|
const kept = new Set(next)
|
|
151
178
|
const dropped = before.filter((m) => !kept.has(m))
|
|
152
179
|
const note = next.find((m) => typeof m.content === "string" && m.content.startsWith("[Exploration summary]"))
|
package/generate-title.mjs
CHANGED
|
@@ -21,6 +21,11 @@ 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
|
+
// 拍平投影(回退支读机读线时用):机读线按轮嵌套。
|
|
28
|
+
import { flattenHistory } from "./context-push.mjs"
|
|
24
29
|
|
|
25
30
|
// Test seam (_-prefix, mirrors run.mjs seams): lets the proxy-branch regression
|
|
26
31
|
// test swap the proxy fetch. The branch it exercises used to carry a dynamic
|
|
@@ -39,6 +44,9 @@ export async function generateTitle(userContent, provider) {
|
|
|
39
44
|
: userContent
|
|
40
45
|
if (typeof userText !== "string" || userText.length < 10) return null
|
|
41
46
|
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
|
|
42
50
|
|
|
43
51
|
// #363③:禁思考形(三格式支共用)——off 取形与可宣称性引核单源:`thinkOffPath` 假
|
|
44
52
|
// (thinkAlwaysOn 族)或 `thinkOffShape` 为 `null`(effort 族——`null` 形是核载荷门的
|
|
@@ -135,7 +143,8 @@ export async function ensureSessionTitle(agent) {
|
|
|
135
143
|
// 内存窗口可能已滑过它(store.firstUserMessage 首扫一次并缓存);未绑定回退内存查找
|
|
136
144
|
// (谓词单源 = `isRealUserMsg`——与 VSC 端壳同判据)。
|
|
137
145
|
let firstUser = agent._recordStore?.firstUserMessage?.() ?? null
|
|
138
|
-
|
|
146
|
+
// 人读线在 ⇒ 原样;回退那一支传拍平视图(机读线按轮嵌套)。
|
|
147
|
+
if (!firstUser) firstUser = (Array.isArray(agent._fullHistory) ? agent._fullHistory : flattenHistory(agent.history)).find(isRealUserMsg)
|
|
139
148
|
if (firstUser) {
|
|
140
149
|
// #632:读源处剥离(注入形不得入标题请求——与恢复面同读一函数,零第二实现)
|
|
141
150
|
const title = await generateTitle(stripAtRefs(firstUser.content), agent.provider)
|
|
@@ -3,4 +3,8 @@ aliases: 提示词资源, 知识资源, 随包资源
|
|
|
3
3
|
|
|
4
4
|
Prompt-assembly topics live in `prompts/knowledge`. Full normal and engineering prompts inline those topics at their master anchors; tiny prompts omit the anchored bodies and allow on-demand queries.
|
|
5
5
|
|
|
6
|
-
Pure-query topics live in this directory. They are available through `knowledge` in every work mode and are never inlined into a system prompt.
|
|
6
|
+
Pure-query topics live in this directory. They are available through `knowledge` in every work mode and are never inlined into a system prompt.
|
|
7
|
+
|
|
8
|
+
Pure-query membership comes from the directory a topic sits in, not from anything inside the file. The token PURE_QUERY_ONLY_MARKER sits in this topic as a canary: because this directory is never inlined in any mode, the token appears in no assembled prompt.
|
|
9
|
+
|
|
10
|
+
Topic identifiers share one global namespace across both directories, so a duplicate identifier is an installation error rather than an order-dependent choice.
|
package/ledger-tools.mjs
CHANGED
|
@@ -183,7 +183,7 @@ const FULL_ACTIONS = ["add", "update", "close", "query", "count"]
|
|
|
183
183
|
const READ_ACTIONS = ["query", "count"]
|
|
184
184
|
|
|
185
185
|
/** cwd 参数描述(五前身声明同文——文本单点)。 */
|
|
186
|
-
const CWD_DESC = "
|
|
186
|
+
const CWD_DESC = "The action's target path. The project root is the nearest ancestor directory holding a `PROJECT-MANIFEST.json`. A ledger file on disk does not make a project. A workspace with several roots and no project directory is reported with the candidates. The search never descends into a sub-project. The ledger is stored per project root in the user data directory, outside the work tree. A relative path resolves against the session anchor; no project is attached outside that boundary. Default: the session anchor"
|
|
187
187
|
|
|
188
188
|
/** 各 action 声明条目(= 前身旧工具 `parameters` 逐字;伪工具对象守卫 + 弃用壳共用单源)。
|
|
189
189
|
* `parameters` 内的键 = 交模型 / provider 的那一份声明;**组判据两键(`oneOfRequired` / `whenPresent`)
|
|
@@ -195,14 +195,14 @@ const ACTION_SPECS = {
|
|
|
195
195
|
required: ["kind", "title"],
|
|
196
196
|
properties: {
|
|
197
197
|
cwd: { type: "string", description: CWD_DESC },
|
|
198
|
-
kind: { type: "string", enum: ["requirement", "tech_todo"], description: "
|
|
199
|
-
title: { type: "string", description: "
|
|
200
|
-
board: { type: "string", description: "
|
|
201
|
-
req_doc: { type: "string", description: "
|
|
202
|
-
task_book: { type: "string", description: "
|
|
203
|
-
evidence: { type: "string", description: "
|
|
204
|
-
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "
|
|
205
|
-
resume_when: { type: "string", description: "
|
|
198
|
+
kind: { type: "string", enum: ["requirement", "tech_todo"], description: "What kind of row to open — required on add." },
|
|
199
|
+
title: { type: "string", description: "The row's title — required on add." },
|
|
200
|
+
board: { type: "string", description: "The owning board — a requirements document name (optional)." },
|
|
201
|
+
req_doc: { type: "string", description: "Requirements-document pointer (optional)." },
|
|
202
|
+
task_book: { type: "string", description: "Task-book pointer (optional). Required while the row is 在途 or 待核销 — the ledger CHECK enforces it." },
|
|
203
|
+
evidence: { type: "string", description: "Minimal evidence line (optional)." },
|
|
204
|
+
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "Tech-todo trigger — one of the `enum` values (optional)." },
|
|
205
|
+
resume_when: { type: "string", description: "Resume condition sentence (optional): one sentence for rows whose trigger is the conditional-resume kind, plus an optional anchor `@YYYY-MM-DD` or `@<event name>`. A blank or whitespace-only value is refused." },
|
|
206
206
|
},
|
|
207
207
|
additionalProperties: false,
|
|
208
208
|
},
|
|
@@ -212,18 +212,18 @@ const ACTION_SPECS = {
|
|
|
212
212
|
type: "object",
|
|
213
213
|
properties: {
|
|
214
214
|
cwd: { type: "string", description: CWD_DESC },
|
|
215
|
-
id: { type: "number", description: "
|
|
216
|
-
batch: { type: "string", description: "
|
|
217
|
-
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "
|
|
218
|
-
title: { type: "string", description: "
|
|
219
|
-
board: { type: "string", description: "
|
|
220
|
-
req_doc: { type: "string", description: "
|
|
221
|
-
task_book: { type: "string", description: "
|
|
222
|
-
evidence: { type: "string", description: "
|
|
223
|
-
evidenceReplace: { type: "boolean", description: "
|
|
224
|
-
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "
|
|
225
|
-
resume_when: { type: "string", description: "
|
|
226
|
-
executor: { type: "string", description: "
|
|
215
|
+
id: { type: "number", description: "Row id — pass exactly one of id and batch." },
|
|
216
|
+
batch: { type: "string", description: "Batch-record pointer — pass exactly one of id and batch. Batch-level bulk: settles that batch's rows in one call. With `status`, every row is re-judged against the migration table; without it this is a plain field patch (status is not written)." },
|
|
217
|
+
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "Target state — one of the six; omitted ⇒ unchanged." },
|
|
218
|
+
title: { type: "string", description: "Title; omitted ⇒ unchanged." },
|
|
219
|
+
board: { type: "string", description: "Owning board; omitted ⇒ unchanged." },
|
|
220
|
+
req_doc: { type: "string", description: "Requirements-document pointer; omitted ⇒ unchanged." },
|
|
221
|
+
task_book: { type: "string", description: "Task-book pointer; omitted ⇒ unchanged." },
|
|
222
|
+
evidence: { type: "string", description: "Evidence line; omitted ⇒ unchanged, given ⇒ appended: a non-empty old value is joined as `旧|新` (no spaces around the bar), an empty one is replaced outright. A whitespace-only value is refused. Pass `evidenceReplace: true` to replace the whole range. Required when moving 在途 or 待核销 back to 待讨论 — it is the return reason. The receipt returns it as `reason`." },
|
|
223
|
+
evidenceReplace: { type: "boolean", description: "Replace flag: pass it with `evidence` to replace the whole range (no part of the old text survives). Omitted or false ⇒ append. Passed alone, with no new text ⇒ refused." },
|
|
224
|
+
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "Tech-todo trigger; omitted ⇒ unchanged." },
|
|
225
|
+
resume_when: { type: "string", description: "Resume condition sentence; omitted ⇒ unchanged. A blank or whitespace-only value is refused." },
|
|
226
|
+
executor: { type: "string", description: "Executor session id (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." },
|
|
227
227
|
},
|
|
228
228
|
additionalProperties: false,
|
|
229
229
|
},
|
|
@@ -235,11 +235,11 @@ const ACTION_SPECS = {
|
|
|
235
235
|
required: ["status"],
|
|
236
236
|
properties: {
|
|
237
237
|
cwd: { type: "string", description: CWD_DESC },
|
|
238
|
-
id: { type: "number", description: "
|
|
239
|
-
batch: { type: "string", description: "
|
|
240
|
-
status: { type: "string", enum: ["已核销", "已废弃"], description: "
|
|
241
|
-
evidence: { type: "string", description: "
|
|
242
|
-
evidenceReplace: { type: "boolean", description: "
|
|
238
|
+
id: { type: "number", description: "Row id — pass exactly one of id and batch." },
|
|
239
|
+
batch: { type: "string", description: "Batch-record pointer — pass exactly one of id and batch. Batch-level settlement: only rows already 待核销 are settled. Rows in 待讨论 or 待设计 are skipped and named (claim them first with update, which moves them to 在途). A 在途 row named here is skipped as well — the transition cannot jump over 待核销." },
|
|
240
|
+
status: { type: "string", enum: ["已核销", "已废弃"], description: "Target state: settle or withdraw. With `batch` it may be omitted (the settle value); given, it must be 已核销." },
|
|
241
|
+
evidence: { type: "string", description: "Minimal work-evidence line (optional); given ⇒ appended: a non-empty old value is joined as `旧|新` (no spaces around the bar), an empty one is replaced outright. A whitespace-only value is refused. Pass `evidenceReplace: true` to replace the whole range. The settle gate only asks whether the evidence is non-blank after this write — it never reads the anchoring batch's closeout or review state." },
|
|
242
|
+
evidenceReplace: { type: "boolean", description: "Replace flag: pass it with `evidence` to replace the whole range (no part of the old text survives). Omitted or false ⇒ append. Passed alone, with no new text ⇒ refused." },
|
|
243
243
|
},
|
|
244
244
|
additionalProperties: false,
|
|
245
245
|
},
|
|
@@ -251,12 +251,12 @@ const ACTION_SPECS = {
|
|
|
251
251
|
type: "object",
|
|
252
252
|
properties: {
|
|
253
253
|
cwd: { type: "string", description: CWD_DESC },
|
|
254
|
-
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "
|
|
255
|
-
kind: { type: "string", enum: ["requirement", "tech_todo"], description: "
|
|
256
|
-
board: { type: "string", description: "
|
|
257
|
-
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "
|
|
258
|
-
task_book: { type: "string", description: "
|
|
259
|
-
cursor: { type: "string", description: "
|
|
254
|
+
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "Filter by state — one of the six; omitted ⇒ no filter." },
|
|
255
|
+
kind: { type: "string", enum: ["requirement", "tech_todo"], description: "Filter by kind." },
|
|
256
|
+
board: { type: "string", description: "Filter by owning board (a requirements document name)." },
|
|
257
|
+
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." },
|
|
258
|
+
task_book: { type: "string", description: "Filter by task-book pointer (exact value — the batch→row lookup). Omitted ⇒ no filter." },
|
|
259
|
+
cursor: { type: "string", description: "Page cursor (optional): copy the previous page's tail line verbatim (form `<updated_at>|<id>`). Omitted ⇒ the first page, newest row first. A malformed cursor is refused — never silently treated as page one." },
|
|
260
260
|
},
|
|
261
261
|
additionalProperties: false,
|
|
262
262
|
},
|
|
@@ -266,7 +266,7 @@ const ACTION_SPECS = {
|
|
|
266
266
|
type: "object",
|
|
267
267
|
properties: {
|
|
268
268
|
cwd: { type: "string", description: CWD_DESC },
|
|
269
|
-
task_book: { type: "string", description: "
|
|
269
|
+
task_book: { type: "string", description: "Filter by task-book pointer (exact value)." },
|
|
270
270
|
},
|
|
271
271
|
additionalProperties: false,
|
|
272
272
|
},
|
|
@@ -280,20 +280,20 @@ const UNION_PARAMETERS = {
|
|
|
280
280
|
properties: {
|
|
281
281
|
action: { type: "string", enum: FULL_ACTIONS, description: "" }, // 变体构造时填描述
|
|
282
282
|
cwd: { type: "string", description: CWD_DESC },
|
|
283
|
-
kind: { type: "string", enum: ["requirement", "tech_todo"], description: "
|
|
284
|
-
title: { type: "string", description: "
|
|
285
|
-
board: { type: "string", description: "
|
|
286
|
-
req_doc: { type: "string", description: "
|
|
287
|
-
task_book: { type: "string", description: "
|
|
288
|
-
evidence: { type: "string", description: "
|
|
289
|
-
evidenceReplace: { type: "boolean", description: "
|
|
290
|
-
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "
|
|
291
|
-
resume_when: { type: "string", description: "
|
|
292
|
-
id: { type: "number", description: "
|
|
293
|
-
batch: { type: "string", description: "
|
|
294
|
-
status: { type: "string", enum: ["待讨论", "待设计", "在途", "待核销", "已核销", "已废弃"], description: "
|
|
295
|
-
executor: { type: "string", description: "
|
|
296
|
-
cursor: { type: "string", description: "
|
|
283
|
+
kind: { type: "string", enum: ["requirement", "tech_todo"], description: "Kind — required on add, a filter on query; omitted ⇒ no filter." },
|
|
284
|
+
title: { type: "string", description: "Row title — required on add, changeable on update. Empty or whitespace-only is refused." },
|
|
285
|
+
board: { type: "string", description: "Owning board — a requirements document name: optional on add, unchanged when omitted on update, a filter on query." },
|
|
286
|
+
req_doc: { type: "string", description: "Requirements-document pointer: optional on add, unchanged when omitted on update." },
|
|
287
|
+
task_book: { type: "string", description: "Task-book pointer: optional on add, unchanged when omitted on update. Required while the row is 在途 or 待核销 — the ledger CHECK enforces it." },
|
|
288
|
+
evidence: { type: "string", description: "Evidence line: optional on add. On update and close, given ⇒ appended: an empty old value is replaced outright, a non-empty one is joined as `旧|新` (no spaces around the bar). A whitespace-only value is refused. Pass `evidenceReplace: true` to replace the whole range. Omitted on update ⇒ unchanged; omitted on close ⇒ the row's own value is judged." },
|
|
289
|
+
evidenceReplace: { type: "boolean", description: "Replace flag: pass it with `evidence` to replace the whole range. Omitted or false ⇒ append. Passed alone, with no new text ⇒ refused (update / close)." },
|
|
290
|
+
trigger: { type: "string", enum: ["归批", "条件", "认账不排期"], description: "Tech-todo trigger — one of the `enum` values: optional on add and update, a filter on query." },
|
|
291
|
+
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
|
+
id: { type: "number", description: "Row id — on update and close, pass exactly one of id and batch." },
|
|
293
|
+
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." },
|
|
295
|
+
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
|
+
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
297
|
},
|
|
298
298
|
additionalProperties: false,
|
|
299
299
|
}
|
|
@@ -312,15 +312,15 @@ function makeLedgerTool(actions, { readonly = false, writeFace = false } = {}) {
|
|
|
312
312
|
const readProps = {}
|
|
313
313
|
if (readonly) for (const a of actions) Object.assign(readProps, ACTION_SPECS[a].parameters.properties)
|
|
314
314
|
const properties = readonly
|
|
315
|
-
? { action: { type: "string", enum: actions, description: "
|
|
315
|
+
? { action: { type: "string", enum: actions, description: "Which operation to run — read-only: `query` or `count`." }, ...readProps }
|
|
316
316
|
: {
|
|
317
317
|
...UNION_PARAMETERS.properties,
|
|
318
318
|
action: {
|
|
319
319
|
...UNION_PARAMETERS.properties.action,
|
|
320
320
|
enum: actions,
|
|
321
321
|
description: writeFace
|
|
322
|
-
? "
|
|
323
|
-
: "
|
|
322
|
+
? "Which operation to run. The three write actions are assembled for the main agent only."
|
|
323
|
+
: "Which operation to run — read-only: `query` or `count`.",
|
|
324
324
|
},
|
|
325
325
|
}
|
|
326
326
|
return {
|