@thincoder/core 0.11.1 → 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 +64 -2
- package/advisor/compaction.mjs +7 -5
- package/advisor/convergence.mjs +34 -3
- package/advisor/history.mjs +24 -11
- package/advisor/loop.mjs +49 -12
- package/advisor/messages.mjs +114 -33
- package/advisor/project-context.mjs +171 -42
- package/advisor/run.mjs +24 -10
- package/advisor.mjs +36 -46
- package/agent/batch-attribution.mjs +87 -0
- package/agent/batch-changed-surface.mjs +129 -0
- package/agent/chat-call.mjs +14 -9
- package/agent/completion.mjs +70 -41
- package/agent/continue-decision.mjs +14 -8
- package/agent/digest-account.mjs +133 -59
- package/agent/dispatch-gates.mjs +6 -0
- package/agent/dispatch-run.mjs +1 -1
- package/agent/dispatch.mjs +10 -4
- package/agent/family-tools.mjs +37 -23
- package/agent/helpers.mjs +139 -73
- package/agent/image-heal.mjs +18 -4
- package/agent/offload.mjs +25 -29
- package/agent/post-turn.mjs +36 -35
- package/agent/record-results.mjs +39 -7
- package/agent/run-stages.mjs +132 -52
- package/agent/run-start.mjs +150 -78
- package/agent/setup-reminders.mjs +194 -91
- package/agent/setup.mjs +219 -140
- package/agent/spawn-child.mjs +40 -3
- package/agent/suspension.mjs +43 -15
- package/agent/timers.mjs +9 -4
- package/agent/turn-domain-text.mjs +105 -0
- package/agent/turn-loop.mjs +84 -27
- package/agent/turn-projection.mjs +286 -0
- package/agent/turn-task-state.mjs +274 -0
- package/agent/turn-tool-process.mjs +163 -0
- package/agent/write-gate-ledger.mjs +569 -0
- package/agent/write-gate.mjs +29 -352
- package/agent-tools/advisor-async.mjs +35 -172
- package/agent-tools/advisor-launch.mjs +178 -0
- package/agent-tools/advisor-settle.mjs +28 -1
- package/agent-tools/advisor.mjs +37 -48
- package/agent-tools/async-discard.mjs +7 -2
- package/agent-tools/async-settle.mjs +18 -12
- package/agent-tools/audit-block.mjs +6 -6
- package/agent-tools/bash-async.mjs +5 -2
- package/agent-tools/batch-closeout.mjs +223 -35
- package/agent-tools/batch-gate.mjs +142 -342
- package/agent-tools/batch-ledger-bind.mjs +240 -20
- package/agent-tools/batch-ledger-view.mjs +109 -0
- package/agent-tools/batch-lifecycle.mjs +197 -48
- package/agent-tools/batch-paths.mjs +29 -8
- package/agent-tools/batch-read.mjs +151 -4
- package/agent-tools/batch-record-write.mjs +417 -0
- package/agent-tools/batch-regions.mjs +215 -0
- package/agent-tools/batch-reopen.mjs +23 -11
- package/agent-tools/batch-segment-vocab.mjs +459 -0
- package/agent-tools/batch-skeleton.mjs +196 -239
- package/agent-tools/batch-supersede.mjs +232 -0
- package/agent-tools/batch-tier-gate.mjs +214 -0
- package/agent-tools/batch.mjs +192 -439
- package/agent-tools/browser-async.mjs +5 -2
- package/agent-tools/consult.mjs +17 -11
- package/agent-tools/context.mjs +76 -33
- package/agent-tools/design-review-record.mjs +225 -0
- package/agent-tools/design-slots.mjs +1 -1
- package/agent-tools/design-token.mjs +279 -81
- package/agent-tools/digest-budget.mjs +10 -9
- package/agent-tools/doc-check.mjs +43 -33
- package/agent-tools/doc-graph.mjs +140 -0
- package/agent-tools/eng.mjs +12 -12
- package/agent-tools/escalate-async.mjs +5 -5
- package/agent-tools/goal.mjs +5 -2
- package/agent-tools/judge-domain.mjs +347 -0
- package/agent-tools/manifest.mjs +34 -18
- package/agent-tools/parent-channel.mjs +6 -3
- package/agent-tools/plan.mjs +11 -10
- package/agent-tools/read-history.mjs +112 -11
- package/agent-tools/review-facts.mjs +19 -6
- package/agent-tools/settings.mjs +23 -2
- package/agent-tools/skill.mjs +7 -8
- package/agent-tools/spawn-gates.mjs +14 -24
- package/agent-tools/ssh-session.mjs +8 -5
- package/agent-tools/ssh-text.mjs +155 -0
- package/agent-tools/ssh-transfer.mjs +1 -1
- package/agent-tools/ssh-transport.mjs +19 -148
- package/agent-tools/subagent-actions-query.mjs +10 -6
- package/agent-tools/subagent-actions.mjs +2 -2
- package/agent-tools/subagent-async.mjs +19 -17
- package/agent-tools/subagent-brief.mjs +76 -0
- package/agent-tools/subagent-design-token.mjs +168 -0
- package/agent-tools/subagent-run.mjs +1 -1
- package/agent-tools/subagent-scheduler.mjs +13 -13
- package/agent-tools/subagent-spawn.mjs +92 -112
- package/agent-tools/subagent.mjs +16 -28
- package/agent-tools/task.mjs +0 -8
- package/agent-tools/taskbook-block.mjs +94 -0
- package/agent-tools/timer.mjs +12 -8
- package/agent-tools/verify.mjs +13 -4
- package/agent-tools.mjs +7 -3
- package/agent.mjs +26 -7
- package/attachments.mjs +3 -3
- package/auto-think.mjs +5 -2
- package/browser/actions.mjs +9 -3
- package/browser/cdp.mjs +45 -17
- package/browser/launch.mjs +25 -43
- package/browser/pool.mjs +299 -0
- package/browser/queue.mjs +2 -0
- package/browser/session-state.mjs +450 -0
- package/browser/session.mjs +127 -151
- package/browser/snapshot.mjs +89 -0
- package/client-identity.mjs +1 -1
- package/compaction-work-state.mjs +230 -0
- package/compress-form.mjs +41 -6
- package/config-defaults.mjs +7 -3
- package/config-migrate.mjs +40 -0
- package/config-normalize.mjs +28 -2
- package/config-reload.mjs +59 -0
- package/config.mjs +110 -110
- package/context-degrade.mjs +93 -34
- package/context-echo.mjs +6 -15
- package/context-push.mjs +328 -31
- package/context.mjs +298 -170
- package/conventions.mjs +11 -9
- package/declaration.mjs +126 -22
- package/declared-repos.mjs +94 -0
- package/doc-check/doc-names.mjs +73 -0
- package/doc-check/doc-tokens.mjs +110 -0
- package/doc-check/existence.mjs +160 -0
- package/doc-check/index.mjs +309 -213
- package/doc-check/line-refs.mjs +27 -101
- package/doc-check/paragraph.mjs +218 -102
- package/doc-graph/anchors.mjs +474 -0
- package/doc-graph/doc-batch-face.mjs +59 -0
- package/doc-graph/doc-suffix.mjs +27 -0
- package/doc-graph/graph-tokens.mjs +160 -0
- package/doc-graph.mjs +778 -0
- package/escape.mjs +6 -5
- package/explore-distill.mjs +41 -8
- package/generate-title.mjs +10 -1
- package/i18n.mjs +1 -1
- package/instance-inbox-watch.mjs +272 -0
- package/instance-inbox.mjs +218 -0
- package/instance-registry.mjs +179 -0
- package/knowledge/README.md +3 -0
- package/knowledge/prompt-resources.md +10 -0
- package/ledger-close-proof.mjs +100 -49
- package/ledger-close.mjs +188 -0
- package/ledger-cmd.mjs +47 -91
- package/ledger-consistency.mjs +113 -0
- package/ledger-db.mjs +47 -15
- package/ledger-executors.mjs +1 -1
- package/ledger-tools.mjs +121 -62
- package/ledger-write-ops.mjs +162 -46
- package/ledger.mjs +1 -1
- package/manifest-discovery.mjs +3 -1
- package/manifest-schema.mjs +27 -5
- package/memory/docs.mjs +51 -15
- package/memory/file-list.mjs +6 -0
- package/memory/schema.mjs +2 -2
- package/model-specs.mjs +87 -21
- package/origin-guard.mjs +190 -0
- package/package.json +3 -1
- package/path-resolve.mjs +338 -57
- package/prompt-files.mjs +114 -2
- package/prompt-overlays.mjs +21 -11
- package/prompts/advisor-design.md +96 -36
- package/prompts/advisor-round1.md +48 -4
- package/prompts/advisor-round2.md +54 -10
- package/prompts/advisor-round3.md +53 -9
- package/prompts/common.md +99 -434
- package/prompts/consult-base.md +7 -4
- package/prompts/discipline-engineering.md +504 -295
- package/prompts/discipline-normal.md +106 -281
- package/prompts/knowledge/business-gates.md +30 -0
- package/prompts/knowledge/decision-quality.md +21 -0
- package/prompts/knowledge/doc-lookup.md +30 -0
- package/prompts/knowledge/document-writing.md +33 -0
- package/prompts/knowledge/documentation-evaluation.md +48 -0
- package/prompts/knowledge/evidence-discipline.md +38 -0
- package/prompts/knowledge/normal-coding-workflow.md +110 -0
- package/prompts/knowledge/normal-delivery-collaboration.md +124 -0
- package/prompts/knowledge/normal-work-management.md +60 -0
- package/prompts/knowledge/product-security.md +28 -0
- package/prompts/knowledge/project-records.md +73 -0
- package/prompts/knowledge/tool-advisor.md +29 -0
- package/prompts/knowledge/tool-apply-patch.md +17 -0
- package/prompts/knowledge/tool-bash.md +48 -0
- package/prompts/knowledge/tool-batch-eng-coder.md +19 -0
- package/prompts/knowledge/tool-batch-eng-designer.md +20 -0
- package/prompts/knowledge/tool-batch-review.md +18 -0
- package/prompts/knowledge/tool-batch.md +94 -0
- package/prompts/knowledge/tool-browser.md +68 -0
- package/prompts/knowledge/tool-code-search.md +4 -0
- package/prompts/knowledge/tool-consult-start.md +12 -0
- package/prompts/knowledge/tool-consult-stop.md +6 -0
- package/prompts/knowledge/tool-context.md +6 -0
- package/prompts/knowledge/tool-delete.md +21 -0
- package/prompts/knowledge/tool-doc-check.md +71 -0
- package/prompts/knowledge/tool-doc-graph-read.md +20 -0
- package/prompts/knowledge/tool-doc-graph.md +49 -0
- package/prompts/knowledge/tool-doc-search.md +6 -0
- package/prompts/knowledge/tool-edit.md +41 -0
- package/prompts/knowledge/tool-eng.md +2 -0
- package/prompts/knowledge/tool-execute.md +21 -0
- package/prompts/knowledge/tool-fetch.md +18 -0
- package/prompts/knowledge/tool-file-ops.md +21 -0
- package/prompts/knowledge/tool-get-current-time.md +7 -0
- package/prompts/knowledge/tool-git-read.md +21 -0
- package/prompts/knowledge/tool-git.md +29 -0
- package/prompts/knowledge/tool-glob.md +17 -0
- package/prompts/knowledge/tool-goal.md +8 -0
- package/prompts/knowledge/tool-grep.md +21 -0
- package/prompts/knowledge/tool-hashline-edit.md +16 -0
- package/prompts/knowledge/tool-insert-after.md +17 -0
- package/prompts/knowledge/tool-instance-list.md +6 -0
- package/prompts/knowledge/tool-instance-send.md +10 -0
- package/prompts/knowledge/tool-knowledge.md +18 -0
- package/prompts/knowledge/tool-ledger-read.md +28 -0
- package/prompts/knowledge/tool-ledger.md +46 -0
- package/prompts/knowledge/tool-lint.md +16 -0
- package/prompts/knowledge/tool-ls.md +15 -0
- package/prompts/knowledge/tool-lsp.md +11 -0
- package/prompts/knowledge/tool-main-history.md +2 -0
- package/prompts/knowledge/tool-manifest-read.md +14 -0
- package/prompts/knowledge/tool-manifest.md +34 -0
- package/prompts/knowledge/tool-memory-read.md +20 -0
- package/prompts/knowledge/tool-memory.md +19 -0
- package/prompts/knowledge/tool-notify-parent.md +12 -0
- package/prompts/knowledge/tool-operations.md +102 -0
- package/prompts/knowledge/tool-peer-instances.md +2 -0
- package/prompts/knowledge/tool-plan.md +5 -0
- package/prompts/knowledge/tool-process-read.md +13 -0
- package/prompts/knowledge/tool-process.md +15 -0
- package/prompts/knowledge/tool-question.md +16 -0
- package/prompts/knowledge/tool-read-history-batch.md +22 -0
- package/prompts/knowledge/tool-read-history.md +35 -0
- package/prompts/knowledge/tool-read-image.md +11 -0
- package/prompts/knowledge/tool-read.md +22 -0
- package/prompts/knowledge/tool-recent-changes.md +6 -0
- package/prompts/knowledge/tool-repo-outline.md +4 -0
- package/prompts/knowledge/tool-settings-read.md +12 -0
- package/prompts/knowledge/tool-settings.md +17 -0
- package/prompts/knowledge/tool-skill.md +6 -0
- package/prompts/knowledge/tool-ssh.md +74 -0
- package/prompts/knowledge/tool-subagent.md +57 -0
- package/prompts/knowledge/tool-task.md +14 -0
- package/prompts/knowledge/tool-team-ledger-read.md +11 -0
- package/prompts/knowledge/tool-team-ledger.md +15 -0
- package/prompts/knowledge/tool-timer.md +23 -0
- package/prompts/knowledge/tool-tree.md +16 -0
- package/prompts/knowledge/tool-verify.md +19 -0
- package/prompts/knowledge/tool-wait-for.md +25 -0
- package/prompts/knowledge/tool-websearch.md +19 -0
- package/prompts/knowledge/tool-write.md +12 -0
- package/prompts/knowledge/upstream-protocol.md +45 -0
- package/prompts/persona-coder.md +1 -3
- package/prompts/persona-eng-coder.md +24 -6
- package/prompts/persona-eng-designer.md +150 -171
- package/prompts/persona-engineering.md +531 -442
- package/prompts/persona-explore.md +1 -3
- package/prompts/persona-normal.md +17 -9
- package/prompts/persona-plan.md +5 -3
- package/prompts/persona-tester.md +0 -2
- package/prompts/subagent-base.md +2 -2
- package/provider/anthropic.mjs +10 -6
- package/provider/core.mjs +8 -5
- package/provider/errors.mjs +63 -4
- package/provider/google.mjs +29 -10
- package/provider/reasoning-echo.mjs +16 -0
- package/provider/responses.mjs +7 -3
- package/provider/sse.mjs +11 -6
- package/provider-flows.mjs +2 -2
- package/rules.mjs +11 -10
- package/session-index-build.mjs +1 -1
- package/session-index-pass.mjs +1 -1
- package/session-index-query.mjs +1 -1
- package/session-index.mjs +1 -1
- package/session-lifecycle.mjs +131 -42
- package/session-slot-write.mjs +38 -6
- package/session.mjs +30 -11
- package/shell-identity.mjs +129 -22
- package/skip-dirs.mjs +26 -2
- package/team-ledger.mjs +34 -30
- package/text-budget.mjs +1 -1
- package/think-off.mjs +27 -0
- package/token-ttl.mjs +74 -5
- package/token-window.mjs +371 -47
- package/tool-docs/advisor.md +2 -27
- package/tool-docs/apply_patch.md +1 -15
- package/tool-docs/bash.md +2 -43
- package/tool-docs/batch-eng-coder.md +3 -0
- package/tool-docs/batch-eng-designer.md +3 -0
- package/tool-docs/batch-review.md +3 -0
- package/tool-docs/batch.md +2 -84
- package/tool-docs/browser.md +2 -49
- package/tool-docs/code_search.md +2 -2
- package/tool-docs/consult_start.md +2 -8
- package/tool-docs/consult_stop.md +2 -4
- package/tool-docs/context.md +1 -5
- package/tool-docs/delete.md +2 -17
- package/tool-docs/doc_check.md +2 -107
- package/tool-docs/doc_graph-read.md +3 -0
- package/tool-docs/doc_graph.md +3 -0
- package/tool-docs/doc_search.md +2 -4
- package/tool-docs/edit.md +1 -38
- package/tool-docs/eng.md +3 -1
- package/tool-docs/execute.md +2 -18
- package/tool-docs/fetch.md +2 -14
- package/tool-docs/file_ops.md +2 -18
- package/tool-docs/get_current_time.md +1 -6
- package/tool-docs/git-read.md +3 -0
- package/tool-docs/git.md +2 -35
- package/tool-docs/glob.md +2 -10
- package/tool-docs/goal.md +1 -6
- package/tool-docs/grep.md +2 -18
- package/tool-docs/hashline_edit.md +2 -15
- package/tool-docs/insert_after.md +2 -16
- package/tool-docs/instance_list.md +3 -0
- package/tool-docs/instance_send.md +3 -0
- package/tool-docs/knowledge.md +3 -0
- package/tool-docs/ledger-read.md +3 -0
- package/tool-docs/ledger.md +3 -8
- package/tool-docs/lint.md +2 -10
- package/tool-docs/ls.md +2 -11
- package/tool-docs/lsp.md +2 -9
- package/tool-docs/main_history.md +3 -1
- package/tool-docs/manifest-read.md +2 -8
- package/tool-docs/manifest.md +2 -35
- package/tool-docs/memory-read.md +3 -0
- package/tool-docs/memory.md +2 -20
- package/tool-docs/notify_parent.md +2 -13
- package/tool-docs/peer_instances.md +3 -1
- package/tool-docs/plan.md +1 -5
- package/tool-docs/process-read.md +3 -0
- package/tool-docs/process.md +2 -13
- package/tool-docs/question.md +3 -17
- package/tool-docs/read.md +2 -19
- package/tool-docs/read_history-batch.md +3 -0
- package/tool-docs/read_history.md +2 -18
- package/tool-docs/read_image.md +2 -9
- package/tool-docs/recent_changes.md +2 -2
- package/tool-docs/repo_outline.md +2 -2
- package/tool-docs/settings-read.md +3 -0
- package/tool-docs/settings.md +1 -12
- package/tool-docs/skill.md +2 -6
- package/tool-docs/ssh.md +1 -62
- package/tool-docs/subagent.md +2 -100
- package/tool-docs/task.md +1 -7
- package/tool-docs/team_ledger-read.md +3 -0
- package/tool-docs/team_ledger.md +3 -9
- package/tool-docs/timer.md +2 -19
- package/tool-docs/tree.md +2 -13
- package/tool-docs/verify.md +2 -12
- package/tool-docs/wait_for.md +2 -32
- package/tool-docs/websearch.md +2 -19
- package/tool-docs/write.md +2 -12
- package/tools/browser.mjs +54 -9
- package/tools/doc-write-gate.mjs +73 -0
- package/tools/edit-batch.mjs +170 -92
- package/tools/edit-diff.mjs +78 -62
- package/tools/edit-receipt.mjs +39 -0
- package/tools/execute.mjs +3 -3
- package/tools/file.mjs +28 -14
- package/tools/git.mjs +36 -21
- package/tools/index.mjs +6 -0
- package/tools/knowledge.mjs +143 -0
- package/tools/linter.mjs +3 -3
- package/tools/ops.mjs +5 -3
- package/tools/patch.mjs +124 -44
- package/tools/process-doc-mark.mjs +33 -4
- package/tools/repomap.mjs +25 -3
- package/tools/search.mjs +74 -26
- package/tools/shared.mjs +29 -27
- 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 +31 -0
- package/tools/write-path.mjs +16 -4
- package/window-policy.mjs +243 -0
- package/doc-check/anchors.mjs +0 -235
package/shell-identity.mjs
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* shell-identity.mjs — bash
|
|
3
|
-
* 设计权威 = `docs/core/design/BASH-EXECUTOR-FACE.md` §2
|
|
2
|
+
* shell-identity.mjs — bash 工具**执行器身份与版本**探测单源(bash-executor-face 批 · 台账 #922——
|
|
3
|
+
* 设计权威 = `docs/core/design/BASH-EXECUTOR-FACE.md` §2「接口契约」)。
|
|
4
4
|
*
|
|
5
5
|
* 探测源 = **spawn 同链镜像**(`tools/bash.mjs` spawn 的 `shell` 参数计算式):
|
|
6
6
|
* config.shell(trim 后非空即用)→ win32 %COMSPEC% → 兜底字面 `cmd.exe`;
|
|
7
7
|
* 非 win32 = `process.env.SHELL` → 兜底 `/bin/sh`(Node `shell:true` 兜底的事实陈述,非平台推断)。
|
|
8
|
-
* 探测值 =
|
|
9
|
-
*
|
|
8
|
+
* 探测值 = 实际执行器(不是环境快照);识别表未命中知名字 ⇒ `kind: "unknown"`(fail-open 零猜测——
|
|
9
|
+
* 用户 2026-10-04 22:48 裁定③);**零静态平台默认**(裁定①)。
|
|
10
|
+
*
|
|
11
|
+
* 版本 = **执行器自报**(`probeShellVersion` 起子进程问它),不从可执行文件名推断;探不到只写名字
|
|
12
|
+
* (`shellVersionLine`),不回落任何版本号。身份写进会话头块那一行,工具描述不再带执行器声明。
|
|
10
13
|
*
|
|
11
14
|
* memo(进程生命周期 + 按配置值键控)先例 = `shell-candidates.mjs`(「shell 路径不热变化」同判据);
|
|
12
15
|
* 配置值变化 ⇒ memo 未命中重探(K2 配置变更刷新 ∥ 裁定①零静态同时成立)。
|
|
13
16
|
* 测试缝 `_setComSpecForTest` 先例 = `shell-candidates.mjs` `_setShellDetectForTest`。
|
|
14
17
|
*/
|
|
18
|
+
import { execFile } from "node:child_process"
|
|
15
19
|
|
|
16
20
|
// 识别表(raw 尾段词 → 显示名 + 语法族)。匹配大小写不敏感,尾段词先剥 `.exe` 后缀(U3——
|
|
17
21
|
// `bash.exe` ∥ `cmd.exe` ∥ `pwsh.exe` 均须命中);序 = 最特异优先:
|
|
@@ -76,32 +80,135 @@ export function resolveShellIdentity(configShell) {
|
|
|
76
80
|
/** memo(进程生命周期 ∕ 按配置值键控——本档单点持有)。 */
|
|
77
81
|
const _memo = { key: undefined, value: null }
|
|
78
82
|
|
|
79
|
-
/**
|
|
83
|
+
/** 版本探测的时间预算(ms):`probeShellVersion` 的硬上限。装配点原值传入,本常量只说预算。 */
|
|
84
|
+
export const SHELL_VERSION_TIMEOUT_MS = 1200
|
|
85
|
+
|
|
86
|
+
/** 版本串文法:首个 `<数字>(.<数字>)+`——`5.1.22621.6133` ∥ `v24.19.0` ∥ `10.0.22631.6199` 都取这一段。 */
|
|
87
|
+
const VERSION_TOKEN_RE = /\d+(?:\.\d+)+/
|
|
88
|
+
|
|
89
|
+
/** 版本串上限(设计档 §2「版本串收窄」:首个版本 token、去空白换行、上限 32 字符)。 */
|
|
90
|
+
const VERSION_MAX_CHARS = 32
|
|
91
|
+
|
|
92
|
+
/** 单个探测命令的输出上限。超出时 Node 以 `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` 结束子进程 ⇒ 本次按失败处理。 */
|
|
93
|
+
const VERSION_MAX_BUFFER = 64 * 1024
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* kind ⇒ 探测命令的**参数**(可执行文件 = `identity.raw` 本身,不经 shell 拼串)。
|
|
97
|
+
* `cmd` 那一行取 `ver` 报的 Windows 版本号:cmd.exe 没有另一条自报版本的面(设计档 §2 探测表)。
|
|
98
|
+
* `unknown` 不在表内 ⇒ 不探测。
|
|
99
|
+
*/
|
|
100
|
+
const PROBE_ARGS = Object.freeze({
|
|
101
|
+
powershell: Object.freeze(["-NoProfile", "-NonInteractive", "-Command", "$PSVersionTable.PSVersion.ToString()"]),
|
|
102
|
+
posix: Object.freeze(["--version"]),
|
|
103
|
+
cmd: Object.freeze(["/d", "/c", "ver"]),
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 版本单槽缓存:`raw` 记这份版本属于哪个执行器(`null` = 还没探过),`version` = 探测值
|
|
108
|
+
* (探测失败同样缓存为 `null`——不为一条探不到的事实每回合重付一次代价)。
|
|
109
|
+
*/
|
|
110
|
+
const _versionCache = { raw: null, version: null }
|
|
111
|
+
|
|
112
|
+
/** 测试缝注入的版本(`null` = 没注入)。注入值优先于缓存与子进程。 */
|
|
113
|
+
let _versionForTest = null
|
|
114
|
+
|
|
115
|
+
/** 测试缝:注入 %COMSPEC% 读数(undefined = 复位真实环境读数);注入即清两份缓存。 */
|
|
80
116
|
let _comSpecOverride = null
|
|
81
117
|
export function _setComSpecForTest(value) {
|
|
82
118
|
_comSpecOverride = value === undefined ? null : value
|
|
83
119
|
_memo.key = undefined
|
|
84
120
|
_memo.value = null
|
|
121
|
+
// 同一条身份链上的事实:身份重探了,版本缓存也跟着失效(两者同源)。
|
|
122
|
+
_versionCache.raw = null
|
|
123
|
+
_versionCache.version = null
|
|
85
124
|
}
|
|
86
125
|
|
|
87
126
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
127
|
+
* 探测执行器**自报**的版本(设计档 §2 探测表)。
|
|
128
|
+
*
|
|
129
|
+
* 硬上限 = `timeoutMs`:超时由 `execFile` 杀掉子进程、回调收到错误 ⇒ `null`。执行器启动失败、非零退出、
|
|
130
|
+
* 输出里没有版本串、`kind: "unknown"`(识别表未命中,不探测)⇒ 同样 `null`。**永不抛、永不拒绝**——
|
|
131
|
+
* 探测失败不该拦住一次 run;唯一抛出的情形是缺 `timeoutMs`(那是调用方的编码错误,不是探测失败)。
|
|
132
|
+
*
|
|
133
|
+
* 结果按 `identity.raw` 单槽缓存:同一个 raw 第二次调用零子进程。raw 变了 ⇒ 重探。
|
|
134
|
+
* @param {{ raw: string, name: string, kind: string, known: boolean }} identity `resolveShellIdentity` 出参
|
|
135
|
+
* @param {{ timeoutMs: number }} opts `timeoutMs` 必填、无默认(缺参即抛并点名该参数)
|
|
136
|
+
* @returns {Promise<string|null>} 版本串 / `null`(探不到)
|
|
92
137
|
*/
|
|
93
|
-
export function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
case "cmd":
|
|
97
|
-
return "- Executor: the bash tool runs commands through Windows cmd.exe (%COMSPEC%). Use cmd syntax: && works; NUL not /dev/null; %VAR% not $VAR; no single-quote grouping. For complex logic prefer the execute tool (node)."
|
|
98
|
-
case "powershell":
|
|
99
|
-
return /pwsh/i.test(lastWord(raw))
|
|
100
|
-
? `- Executor: the bash tool runs commands through PowerShell (pwsh; ${raw}). && and || work; %VAR% does not expand (use $VAR); cmdlets differ (Remove-Item, Copy-Item). For complex logic prefer the execute tool (node).`
|
|
101
|
-
: `- Executor: the bash tool runs commands through Windows PowerShell (${raw}). PS 5.1 has NO &&/|| (use ; or separate calls); redirection differs (2>/dev/null is invalid); cmdlets differ (Remove-Item, Copy-Item). For complex logic prefer the execute tool (node).`
|
|
102
|
-
case "posix":
|
|
103
|
-
return `- Executor: the bash tool runs commands through a POSIX shell (${raw}). Standard POSIX syntax applies ($(...), $VAR, ;, >/dev/null).`
|
|
104
|
-
default:
|
|
105
|
-
return `- Executor: the bash tool shell could not be identified (raw: ${raw}) — write portable commands and trust the command's own error output.`
|
|
138
|
+
export async function probeShellVersion(identity, { timeoutMs } = {}) {
|
|
139
|
+
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
140
|
+
throw new Error(`probeShellVersion: \`timeoutMs\` is required (a positive number, no default) — pass SHELL_VERSION_TIMEOUT_MS; got ${JSON.stringify(timeoutMs)}`)
|
|
106
141
|
}
|
|
142
|
+
if (_versionForTest !== null) return _versionForTest
|
|
143
|
+
const raw = rawOf(identity)
|
|
144
|
+
if (_versionCache.raw === raw) return _versionCache.version
|
|
145
|
+
const args = PROBE_ARGS[identity?.kind]
|
|
146
|
+
const version = args ? await runProbe(raw, args, timeoutMs) : null
|
|
147
|
+
_versionCache.raw = raw
|
|
148
|
+
_versionCache.version = version
|
|
149
|
+
return version
|
|
107
150
|
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 会话头那一行里 `Shell:` 的值(设计档 §2):`<name>` 或 `<name> <version>`。
|
|
154
|
+
* 同步、**只读缓存**(绝不起子进程——压缩后的头块重建走这里)。未探测 / 探测失败 /
|
|
155
|
+
* `kind: "unknown"` ⇒ 只有 `<name>`;`unknown` 的 name 就是 raw 本身,认不出的执行器照样写进会话头。
|
|
156
|
+
* @param {{ raw: string, name: string, kind: string, known: boolean }} identity `resolveShellIdentity` 出参
|
|
157
|
+
* @returns {string}
|
|
158
|
+
*/
|
|
159
|
+
export function shellVersionLine(identity) {
|
|
160
|
+
const name = identity?.name == null ? rawOf(identity) : String(identity.name)
|
|
161
|
+
const version = cachedVersionFor(identity)
|
|
162
|
+
return version ? `${name} ${version}` : name
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 测试缝:注入版本值(批旁单测用——不起子进程就能判 `shellVersionLine` 的两种形)。
|
|
167
|
+
* 传 `null`(或 `undefined`)即清,与 `_setComSpecForTest(undefined)` 同形;注入即清缓存。
|
|
168
|
+
*/
|
|
169
|
+
export function _setShellVersionForTest(value) {
|
|
170
|
+
_versionForTest = value == null ? null : String(value)
|
|
171
|
+
_versionCache.raw = null
|
|
172
|
+
_versionCache.version = null
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** 身份里的 raw 原值(恒为字符串:`resolveShellIdentity` 的出参面)。 */
|
|
176
|
+
function rawOf(identity) {
|
|
177
|
+
return identity?.raw == null ? "" : String(identity.raw)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** 缓存里属于这份身份的值(`raw` 相同才算同一个执行器);没探过就是 `null`。 */
|
|
181
|
+
function cachedVersionFor(identity) {
|
|
182
|
+
if (_versionForTest !== null) return _versionForTest
|
|
183
|
+
return _versionCache.raw === rawOf(identity) ? _versionCache.version : null
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 执行一次探测命令并取版本串。`execFile` 不经 shell(`raw` 带空格的路径免引号);超时、非零退出、
|
|
188
|
+
* 输出超限都由回调收到错误 ⇒ `null`。`execFile` 对不可执行的目标还会**同步抛**(Windows 上
|
|
189
|
+
* `.cmd` 即 spawn `EINVAL`)⇒ 同一处置。本函数从不拒绝。
|
|
190
|
+
*/
|
|
191
|
+
function runProbe(file, args, timeoutMs) {
|
|
192
|
+
return new Promise((resolve) => {
|
|
193
|
+
let settled = false
|
|
194
|
+
const finish = (value) => {
|
|
195
|
+
if (settled) return
|
|
196
|
+
settled = true
|
|
197
|
+
resolve(value)
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
execFile(file, args, { timeout: timeoutMs, maxBuffer: VERSION_MAX_BUFFER, windowsHide: true }, (err, stdout) => {
|
|
201
|
+
finish(err ? null : firstVersionToken(stdout))
|
|
202
|
+
})
|
|
203
|
+
} catch {
|
|
204
|
+
finish(null)
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** 首个版本 token(设计档 §2「版本串收窄」);无匹配 ⇒ `null`。 */
|
|
210
|
+
function firstVersionToken(output) {
|
|
211
|
+
const hit = VERSION_TOKEN_RE.exec(String(output ?? ""))
|
|
212
|
+
if (!hit) return null
|
|
213
|
+
return hit[0].trim().slice(0, VERSION_MAX_CHARS) || null
|
|
214
|
+
}
|
package/skip-dirs.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* skip-dirs.mjs — 目录排除名单**零依赖叶档**(本批 E12:四份名单合一份)。
|
|
3
3
|
*
|
|
4
|
-
* 四份并存曾是漂移源:`index-discover.mjs
|
|
5
|
-
* `tools/tree.mjs
|
|
4
|
+
* 四份并存曾是漂移源:`index-discover.mjs`(8 项)· `tools/shared.mjs`(6 项,名 `IGNORED_DIRS`)·
|
|
5
|
+
* `tools/tree.mjs`(13 项)· `memory/schema.mjs`(39 项 + 折叠集 + 前缀族)。同一个问题
|
|
6
6
|
* (「哪些目录不是人要读的东西」)四个答案;索引面与检索面各剪各的,同一批文件在两个面上一进一出。
|
|
7
7
|
* 单源 = 本档,四个消费面只 import 名单,不各自持有副本。
|
|
8
8
|
*
|
|
9
9
|
* **名单只此一份**:`SKIP_DIRS`(42 项)答「索引 / 遍历 / 搜索时跳过什么」——剪掉的是噪音。
|
|
10
10
|
* 面判不读任何排除名单:面只有两值(文档面放行 ∥ 其余产品面拦),「什么算产物」不参与面判定。
|
|
11
|
+
* `BUILD_ARTIFACT_*` 三份与它**并列不同面**:读索引行、只在大纲编撰面生效,不改索引准入
|
|
12
|
+
* (见下方该族头注)。
|
|
11
13
|
*
|
|
12
14
|
* 三条处置(理由写在项旁,防后人「顺手补回去」):
|
|
13
15
|
* - `bin` **不列**:`thincoder-cli/bin/` 有 2 个 `.mjs` 是 CLI 入口、产品代码;列进名单会把入口
|
|
@@ -46,3 +48,25 @@ export const SKIP_DIRS_FOLD = new Set([
|
|
|
46
48
|
|
|
47
49
|
/** 目录名前缀族(`bazel-<workspace>` 无法枚举——workspace 名任意)。 */
|
|
48
50
|
export const SKIP_DIR_PREFIXES = ["bazel-"]
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 构建产物目录族——**只在大纲编撰面生效**,不进 `SKIP_DIRS`、不改索引准入:
|
|
54
|
+
* 库里的行照留(由维护面按 `ENOENT` 判死),只是不进大纲三段
|
|
55
|
+
* (机制 = `docs/core/design/MEMORY.md` §4「文件发现与范围」)。
|
|
56
|
+
*
|
|
57
|
+
* 取景 = 记忆库里 `path` 的段序列(相对 origin 根,`/` 分隔):
|
|
58
|
+
* - 段命中 `BUILD_ARTIFACT_DIRS`——浏览器缓存目录(`bin/Debug/…/EBWebView/…` 一族);
|
|
59
|
+
* - 相邻段对命中 `BUILD_ARTIFACT_DIR_PAIRS`——`bin` → `Debug` = 构建输出树;
|
|
60
|
+
* - 段前缀命中 `BUILD_ARTIFACT_DIR_PREFIXES`——带后缀的产物目录(`dist-*`)。
|
|
61
|
+
*
|
|
62
|
+
* **`bin` 单独不列**:`thincoder-cli/bin/` 是产品入口,列入会把入口漏出大纲;
|
|
63
|
+
* 只认 `bin` 后紧跟 `Debug` 的那一对。
|
|
64
|
+
*/
|
|
65
|
+
export const BUILD_ARTIFACT_DIRS = new Set(["EBWebView", "WidevineCdm"])
|
|
66
|
+
|
|
67
|
+
/** 相邻段对(`bin` → `Debug`):两个段连着出现才算构建输出树,单独任一段不算。 */
|
|
68
|
+
export const BUILD_ARTIFACT_DIR_PAIRS = [["bin", "Debug"]]
|
|
69
|
+
|
|
70
|
+
/** 段前缀族(`dist-*`:`dist-linux` ∥ `dist-win` 一类,名自带后缀)。**只判目录段**:
|
|
71
|
+
* 文件名以 `dist-` 开头的是产品代码(如 `scripts/dist-resource-face.mjs`),照旧进大纲。 */
|
|
72
|
+
export const BUILD_ARTIFACT_DIR_PREFIXES = ["dist-"]
|
package/team-ledger.mjs
CHANGED
|
@@ -138,14 +138,14 @@ function assertArgs(name, decl, args) {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
/** 各 action 声明条目(= 参数并集按 action 收窄的单源;schema 与守卫同源)。 */
|
|
141
|
-
const SCOPE_DESC = `"repo"
|
|
141
|
+
const SCOPE_DESC = `"repo" (default — this repo, derived automatically) or "team" (every repo in the team)`
|
|
142
142
|
const ACTION_SPECS = {
|
|
143
143
|
query: {
|
|
144
144
|
type: "object",
|
|
145
145
|
properties: {
|
|
146
146
|
scope: { type: "string", enum: ["repo", "team"], description: SCOPE_DESC },
|
|
147
|
-
status: { type: "string", enum: STATUSES, description: "
|
|
148
|
-
owner: { type: "string", description: "
|
|
147
|
+
status: { type: "string", enum: STATUSES, description: "Filter by state — one of the six; omitted ⇒ no filter." },
|
|
148
|
+
owner: { type: "string", description: "Filter by owner (exact username)." },
|
|
149
149
|
},
|
|
150
150
|
additionalProperties: false,
|
|
151
151
|
},
|
|
@@ -153,8 +153,8 @@ const ACTION_SPECS = {
|
|
|
153
153
|
type: "object",
|
|
154
154
|
properties: {
|
|
155
155
|
scope: { type: "string", enum: ["repo", "team"], description: SCOPE_DESC },
|
|
156
|
-
status: { type: "string", enum: STATUSES, description: "
|
|
157
|
-
owner: { type: "string", description: "
|
|
156
|
+
status: { type: "string", enum: STATUSES, description: "Filter by state — one of the six; omitted ⇒ no filter." },
|
|
157
|
+
owner: { type: "string", description: "Filter by owner (exact username)." },
|
|
158
158
|
},
|
|
159
159
|
additionalProperties: false,
|
|
160
160
|
},
|
|
@@ -162,9 +162,9 @@ const ACTION_SPECS = {
|
|
|
162
162
|
type: "object",
|
|
163
163
|
required: ["title"],
|
|
164
164
|
properties: {
|
|
165
|
-
title: { type: "string", description: "
|
|
166
|
-
detail: { type: "string", description: "
|
|
167
|
-
owner: { type: "string", description: "
|
|
165
|
+
title: { type: "string", description: "Title — required; trimmed non-empty and at most 200 characters." },
|
|
166
|
+
detail: { type: "string", description: "Body — optional, at most 4000 characters." },
|
|
167
|
+
owner: { type: "string", description: "Owner; omitted ⇒ you." },
|
|
168
168
|
},
|
|
169
169
|
additionalProperties: false,
|
|
170
170
|
},
|
|
@@ -172,11 +172,11 @@ const ACTION_SPECS = {
|
|
|
172
172
|
type: "object",
|
|
173
173
|
required: ["id"],
|
|
174
174
|
properties: {
|
|
175
|
-
id: { type: "number", description: "
|
|
176
|
-
title: { type: "string", description: "
|
|
177
|
-
detail: { type: "string", description: "
|
|
178
|
-
owner: { type: "string", description: "
|
|
179
|
-
status: { type: "string", enum: STATUSES, description: "
|
|
175
|
+
id: { type: "number", description: "Row number (global)." },
|
|
176
|
+
title: { type: "string", description: "Title; omitted ⇒ unchanged." },
|
|
177
|
+
detail: { type: "string", description: "Body; omitted ⇒ unchanged." },
|
|
178
|
+
owner: { type: "string", description: "Owner — set it to hand the row over; omitted ⇒ unchanged." },
|
|
179
|
+
status: { type: "string", enum: STATUSES, description: "Target state — must be a legal successor in the migration table; anything else is refused by the server with 400." },
|
|
180
180
|
},
|
|
181
181
|
additionalProperties: false,
|
|
182
182
|
},
|
|
@@ -184,8 +184,8 @@ const ACTION_SPECS = {
|
|
|
184
184
|
type: "object",
|
|
185
185
|
required: ["id", "status"],
|
|
186
186
|
properties: {
|
|
187
|
-
id: { type: "number", description: "
|
|
188
|
-
status: { type: "string", enum: ["已核销", "已废弃"], description: "
|
|
187
|
+
id: { type: "number", description: "Row number (global)." },
|
|
188
|
+
status: { type: "string", enum: ["已核销", "已废弃"], description: "Target state: settle or withdraw." },
|
|
189
189
|
},
|
|
190
190
|
additionalProperties: false,
|
|
191
191
|
},
|
|
@@ -198,31 +198,35 @@ const UNION_PARAMETERS = {
|
|
|
198
198
|
properties: {
|
|
199
199
|
action: { type: "string", enum: FULL_ACTIONS, description: "" }, // 变体构造时填描述
|
|
200
200
|
scope: { type: "string", enum: ["repo", "team"], description: SCOPE_DESC },
|
|
201
|
-
status: { type: "string", enum: STATUSES, description: "
|
|
202
|
-
owner: { type: "string", description: "
|
|
203
|
-
title: { type: "string", description: "
|
|
204
|
-
detail: { type: "string", description: "
|
|
205
|
-
id: { type: "number", description: "
|
|
201
|
+
status: { type: "string", enum: STATUSES, description: "Status — one of the six. On query and count it filters; on update it is the target state and must be a legal successor in the migration table. On close it is `已核销` or `已废弃`." },
|
|
202
|
+
owner: { type: "string", description: "Owner: on query and count it filters (exact username); on add and update it sets the value." },
|
|
203
|
+
title: { type: "string", description: "Title: required on add, changeable on update — trimmed non-empty and at most 200 characters." },
|
|
204
|
+
detail: { type: "string", description: "Body: on add and update, optional, at most 4000 characters." },
|
|
205
|
+
id: { type: "number", description: "Row number: required on update and close; the numbering is global." },
|
|
206
206
|
},
|
|
207
207
|
additionalProperties: false,
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
/** 变体构造(同名单对象、schema 窄化、两形永不同装配——先例 = `ledger` 工具 depth 面变体)。
|
|
210
|
+
/** 变体构造(同名单对象、schema 窄化、两形永不同装配——先例 = `ledger` 工具 depth 面变体)。
|
|
211
|
+
* 只读变体的参数面 = 本变体各 action 的 `ACTION_SPECS` 并集(B6:它拿不到 `title` / `detail` 这类只有
|
|
212
|
+
* 写动作消费的参数与说明),描述取自己的档 `team_ledger-read.md`。 */
|
|
211
213
|
function makeTeamLedgerTool(actions, { readonly = false, writeFace = false } = {}) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
properties: {
|
|
214
|
+
const readProps = {}
|
|
215
|
+
if (readonly) for (const a of actions) Object.assign(readProps, ACTION_SPECS[a].properties)
|
|
216
|
+
const properties = readonly
|
|
217
|
+
? { action: { type: "string", enum: actions, description: "Which operation to run — read-only: `query` or `count`." }, ...readProps }
|
|
218
|
+
: {
|
|
218
219
|
...UNION_PARAMETERS.properties,
|
|
219
220
|
action: {
|
|
220
221
|
...UNION_PARAMETERS.properties.action,
|
|
221
222
|
enum: actions,
|
|
222
|
-
description: writeFace ? "
|
|
223
|
+
description: writeFace ? "Which operation to run. The three write actions are assembled for the main agent only." : "Which operation to run — read-only: `query` or `count`.",
|
|
223
224
|
},
|
|
224
|
-
}
|
|
225
|
-
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
name: "team_ledger",
|
|
228
|
+
description: readonly ? DESC("team_ledger-read") : DESC("team_ledger"), // 文本单点 = tool-docs/{team_ledger,team_ledger-read}.md
|
|
229
|
+
parameters: { type: "object", required: ["action"], properties, additionalProperties: false },
|
|
226
230
|
readonly,
|
|
227
231
|
isReadonlyAction(args) { return READ_ACTIONS.includes(args?.action) },
|
|
228
232
|
async execute(args, ctx) {
|
package/text-budget.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* text-budget.mjs — 文本额度纯函数(零依赖——TUI-OOM-ROOTCAUSE 批,
|
|
2
|
+
* text-budget.mjs — 文本额度纯函数(零依赖——TUI-OOM-ROOTCAUSE 批,TOOL-OUTPUT-LIMITS.md §2 头尾预览 / TUI-SESSION-VIEW.md §5.2)。
|
|
3
3
|
*
|
|
4
4
|
* 单一来源(D2):agent 侧捕获截断(spawn-child.mjs——子代理 `_capturedOutput`)与 TUI 面
|
|
5
5
|
* 载体额度(tui/display-budget.mjs)共用本体的 `capText` / `appendCappedText`——两处各自
|
package/think-off.mjs
CHANGED
|
@@ -25,6 +25,33 @@ export function thinkOffPath(spec) {
|
|
|
25
25
|
return true
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** 有效思考模式(判据本体 = `docs/core/design/AGENT-LOOP.md` §5.4 的判定次序):
|
|
29
|
+
* 这一轮请求会不会真的带思考 —— 判据是「服务端的有效模式」,不是「UI 显成什么」。
|
|
30
|
+
* 输入 `provider` = 该渠道的描述子(`thinking` ∥ `reasoningEffort` 两键的实际值)、`spec` = 核规格(可为 `null`)。
|
|
31
|
+
* 次序(自上而下,先命中先返回):
|
|
32
|
+
* ① `thinkAlwaysOn === true` 或非空且非 `"none"` 的 `reasoningEffort` ⇒ `true`(显式要思考 / 服务端强制);
|
|
33
|
+
* ② `reasoningEffort === "none"` ∥ `thinking.type === "disabled"` ⇒ `false`(两枚显式 off 形);
|
|
34
|
+
* ③ `thinking === null` 且该族的 off 形本来就是 `null`(`spec.thinkApi === "effort"`)且 `thinkOffPath(spec)` 为真
|
|
35
|
+
* ⇒ `false`——只有 effort 族有资格把 `null` 读成关闭:它的 off 形 = 置 `null` + 删 effort,且枚举含 `"none"`
|
|
36
|
+
* 时载荷层才补发 `reasoning_effort:"none"`(`provider/core.mjs` 的支),此时它才是有效关闭;
|
|
37
|
+
* ④ 其余 ⇒ `true`:没有任何 off 证据就不按「已关思考」静默省键(kimi 式 `thinking:null` 而枚举无 `none`、
|
|
38
|
+
* 以及 type 族的 `thinking:null`——`null` 不是它的 off 形,载荷层的 `if (provider.thinking)` 会跳过它、
|
|
39
|
+
* 服务端默认照旧思考——两处都落这一支)。
|
|
40
|
+
* 边界:两个参数都必须显式传入;`null` 是合法实参(没有渠道 ∥ 未声明族),`undefined` 点名报错,不补默认。 */
|
|
41
|
+
export function isThinkingRequest(provider, spec) {
|
|
42
|
+
if (provider === undefined) throw new Error("isThinkingRequest: provider is required — 传该渠道的描述子(没有渠道时传 null),本函数不替调用方补默认")
|
|
43
|
+
if (spec === undefined) throw new Error("isThinkingRequest: spec is required — 传该族的规格(未声明的族传 null),本函数不替调用方补默认")
|
|
44
|
+
const effort = provider?.reasoningEffort
|
|
45
|
+
if (spec?.thinkAlwaysOn === true) return true
|
|
46
|
+
if (typeof effort === "string" && effort.trim() !== "" && effort !== "none") return true
|
|
47
|
+
if (effort === "none") return false
|
|
48
|
+
if (provider?.thinking?.type === "disabled") return false
|
|
49
|
+
// `null` 只有 effort 族读得成关闭(它的 off 形就是 null + 删 effort);type 族的 off 形是 {type:"disabled"},
|
|
50
|
+
// 收到 null 只表示「没配」——载荷层 `if (provider.thinking)` 会跳过它、服务端照旧思考,不能据此判合规省键。
|
|
51
|
+
if (provider?.thinking === null && spec?.thinkApi === "effort" && thinkOffPath(spec)) return false
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
|
|
28
55
|
/** advisor 推理档写面三态(**写语义单源** —— 由 VSC `settings-panel-write.mjs` 的 `applyAdvisorEffort` 上提;B10 S11:
|
|
29
56
|
* 桌面主侧 ∕ VSC 写面两端同引,零副本):`advisor` 对象原地作用于 `{ thinking, reasoningEffort }` 两键 ——
|
|
30
57
|
* ① `"none"`(关思考)⇒ `thinking = thinkOffShape(spec)`(族别 off 形)+ 删 `reasoningEffort`;
|
package/token-ttl.mjs
CHANGED
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
* slot 残留 engDesignToken → 迁入 Map,此后不写不读镜像)。
|
|
23
23
|
* - **§10(2026-10-26)**:批次归属旁列 `engDesignTokenBatches`(designId → 批档绝对路径)与
|
|
24
24
|
* 槽多槽表**同点序列化 / 同拍恢复 / 同处落盘**;轻读面 = `readEngTokenBatchesFromSlot`。
|
|
25
|
-
*
|
|
25
|
+
* - **§10.2(2026-11-12)**:评审封印旁列 `engDesignTokenSeals`(designId → `{ hash, docs, docHashes }`)同点序列化 /
|
|
26
|
+
* 同拍恢复 / 同处落盘;轻读面 = `readEngTokenSealsFromSlot`(与批归属同形兄弟、同一两形读法)。
|
|
27
|
+
* token 值形零改(仍 `<uuid>:<expiryMs>`)——两条旁列只承载归属与版本,不承载授权。
|
|
26
28
|
*
|
|
27
29
|
* 依赖方向:本模块只 import 底层槽 I/O(session-slots.mjs 原语 + session-guard.mjs 轮转
|
|
28
30
|
* 守卫)——session.mjs 同时 import 本模块(engTokenSlotFields/restoreEngTokens),形成
|
|
@@ -112,8 +114,9 @@ export function purgeExpiredDesignTokens(agent) {
|
|
|
112
114
|
* NO field,不从上次 save 复活槽。
|
|
113
115
|
* DESIGN-TOKEN-SETTLEMENT D3(2026-09-08):单值镜像 `engDesignToken` 退役——
|
|
114
116
|
* saveSession 不再写镜像字段(AC3 零写);只产多槽表 engDesignTokens。
|
|
115
|
-
* 批次归属旁列 `engDesignTokenBatches`(DESIGN-TOKEN-SETTLEMENT §10
|
|
116
|
-
*
|
|
117
|
+
* 批次归属旁列 `engDesignTokenBatches`(DESIGN-TOKEN-SETTLEMENT §10)与评审封印旁列
|
|
118
|
+
* `engDesignTokenSeals`(§10.2)同处序列化——与槽表并列、同空态语义(空表 ⇒ undefined ⇒
|
|
119
|
+
* 字段不落盘);承载归属与版本,不承载恢复。 */
|
|
117
120
|
export function engTokenSlotFields(agent) {
|
|
118
121
|
return {
|
|
119
122
|
engDesignTokens: agent._engDesignTokens instanceof Map && agent._engDesignTokens.size > 0
|
|
@@ -122,6 +125,10 @@ export function engTokenSlotFields(agent) {
|
|
|
122
125
|
engDesignTokenBatches: agent._engDesignTokenBatches instanceof Map && agent._engDesignTokenBatches.size > 0
|
|
123
126
|
? Object.fromEntries(agent._engDesignTokenBatches)
|
|
124
127
|
: undefined,
|
|
128
|
+
// 评审封印旁列(§10.2)同处序列化——与槽表、批归属并列为第三个槽字段,空表 ⇒ undefined ⇒ 字段不落盘。
|
|
129
|
+
engDesignTokenSeals: agent._engDesignTokenSeals instanceof Map && agent._engDesignTokenSeals.size > 0
|
|
130
|
+
? Object.fromEntries(agent._engDesignTokenSeals)
|
|
131
|
+
: undefined,
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
134
|
|
|
@@ -169,6 +176,26 @@ export function restoreEngTokens(agent, data) {
|
|
|
169
176
|
}
|
|
170
177
|
if (batches.size > 0) agent._engDesignTokenBatches = batches
|
|
171
178
|
else delete agent._engDesignTokenBatches
|
|
179
|
+
// 评审封印旁列同拍读入(§10.2):值 = `{ hash, docs, docHashes }`(被审档绝对路径清单 + 组合 sha256 +
|
|
180
|
+
// 逐档 `[{ path, hash }]`——逐档列只服务拒文点名,旧行没有它时保留缺席,不补不猜)。
|
|
181
|
+
// 只收形状完整的行——缺 `hash` ∥ `docs` 不是清单 ⇒ 闸面按「无封印值」判(旧槽同层降级)。
|
|
182
|
+
const seals = new Map()
|
|
183
|
+
if (data.engDesignTokenSeals && typeof data.engDesignTokenSeals === "object" && !Array.isArray(data.engDesignTokenSeals)) {
|
|
184
|
+
for (const [id, s] of Object.entries(data.engDesignTokenSeals)) {
|
|
185
|
+
if (s && typeof s === "object" && !Array.isArray(s) && typeof s.hash === "string"
|
|
186
|
+
&& Array.isArray(s.docs) && s.docs.every((p) => typeof p === "string")) {
|
|
187
|
+
const row = { hash: s.hash, docs: [...s.docs] }
|
|
188
|
+
// `docHashes` 不是成形判据(闸面 `hasSeal` 零改):形状不全 ⇒ 整列按「没有」处理,行照旧读入。
|
|
189
|
+
const docHashes = Array.isArray(s.docHashes)
|
|
190
|
+
? s.docHashes.filter((d) => d && typeof d === "object" && typeof d.path === "string" && typeof d.hash === "string").map((d) => ({ path: d.path, hash: d.hash }))
|
|
191
|
+
: null
|
|
192
|
+
if (docHashes) row.docHashes = docHashes
|
|
193
|
+
seals.set(id, row)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (seals.size > 0) agent._engDesignTokenSeals = seals
|
|
198
|
+
else delete agent._engDesignTokenSeals
|
|
172
199
|
let droppedDesignTokens = 0
|
|
173
200
|
for (const id of before) if (!map.has(id)) droppedDesignTokens++
|
|
174
201
|
return { droppedDesignTokens }
|
|
@@ -246,6 +273,41 @@ export function readEngTokenBatchesFromSlot(agent, { strict = false } = {}) {
|
|
|
246
273
|
}
|
|
247
274
|
}
|
|
248
275
|
|
|
276
|
+
/** 读当前会话槽文件的**评审封印**旁列(DESIGN-TOKEN-SETTLEMENT §10.2——不做 TTL 过滤、不改盘)。
|
|
277
|
+
* 与 `readEngTokenBatchesFromSlot` 同形兄弟(同一轻读形、同一两形读法)——两者不能合成一个函数:
|
|
278
|
+
* 字段名硬编码是既有读者的形状,合并就得让每个读者自己再筛字段。
|
|
279
|
+
* **两形**:`strict:false`(缺省)读不到 ⇒ `null`;`strict:true`(闸面)读不到 ⇒ **抛**——派单侧
|
|
280
|
+
* 不能在「封印读不到」时落进「无封印值 ⇒ 不拦」。
|
|
281
|
+
* 判据 = **「没有」与「读不到」分清**:无槽号 ∥ 文件不存在(`ENOENT`)∥ 无该字段 ⇒ 空集(合法缺省,
|
|
282
|
+
* 两形同);其余 I/O 错 ∥ `JSON.parse` 失败 ⇒ 宽容形 `null` / 严格形抛。
|
|
283
|
+
* 槽号解析在 `try` 之外:manifest 层的「读不到」自带 manifest 坐标,不被重包成封印读失败。
|
|
284
|
+
* 返回 {designId: {hash, docs}} 对象或 null。 */
|
|
285
|
+
export function readEngTokenSealsFromSlot(agent, { strict = false } = {}) {
|
|
286
|
+
const slot = currentSlotNoReadOnly(agent, { strict })
|
|
287
|
+
if (slot == null) return null
|
|
288
|
+
let p = "(unresolved slot path)"
|
|
289
|
+
try {
|
|
290
|
+
p = slotPath(agent.cwd, slot)
|
|
291
|
+
let raw
|
|
292
|
+
try {
|
|
293
|
+
raw = readFileSync(p, "utf8")
|
|
294
|
+
} catch (e) {
|
|
295
|
+
if (e?.code === "ENOENT") return null // 「没有」:文件不存在——合法缺省
|
|
296
|
+
throw e // 「读不到」:其余 I/O 错交外层按读形处置
|
|
297
|
+
}
|
|
298
|
+
const data = JSON.parse(raw)
|
|
299
|
+
return (data && typeof data === "object" && !Array.isArray(data.engDesignTokenSeals)
|
|
300
|
+
&& data.engDesignTokenSeals && typeof data.engDesignTokenSeals === "object")
|
|
301
|
+
? data.engDesignTokenSeals
|
|
302
|
+
: null
|
|
303
|
+
} catch (e) {
|
|
304
|
+
if (strict) {
|
|
305
|
+
throw new Error(`readEngTokenSealsFromSlot: the session slot file's review-seal side column could NOT be read (${p}: ${e?.message ?? e}) — the eng-coder spawn cannot tell which version of the reviewed documents passed, so the spawn is refused with nothing written; fix the slot file or its permissions and retry.`)
|
|
306
|
+
}
|
|
307
|
+
return null
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
249
311
|
/** 内存 miss 时从权威槽 reconcile(D2 spawn 门 + D3 dispatch 写门同源):把槽文件中
|
|
250
312
|
* **未过期**项并进内存 Map(TTL 过滤保留——expired 不并入,fail-closed;格式/畸形串
|
|
251
313
|
* 与 restoreEngTokens 同语义读回——门禁格式拒);槽无活项 → 内存原样。返回判定用 Map。
|
|
@@ -326,25 +388,32 @@ export function persistEngTokens(agent) {
|
|
|
326
388
|
tasks: agent.tasks ?? [],
|
|
327
389
|
planMode: agent.planMode ?? false,
|
|
328
390
|
autoApprove: agent.autoApprove ?? false,
|
|
329
|
-
|
|
391
|
+
mode: agent.config?.agent?.mode ?? (agent.config?.agent?.engineering === true ? "engineering" : "normal"),
|
|
330
392
|
goal: agent.goal ?? null,
|
|
331
393
|
advisor: agent.config?.advisor ?? null,
|
|
332
394
|
// 会话级档位(#441③ 键齐——与 `newSlotData` 规范结构 / `saveSession` 携带面同源:
|
|
333
395
|
// 实况有值携带、无则 `null`;老槽禁回填不适用——本分支只产全新槽)。
|
|
334
396
|
effort: agent._slotEffort ?? null,
|
|
335
|
-
|
|
397
|
+
pendingInject: agent._pendingInject ?? [],
|
|
336
398
|
sessionStart: agent._sessionStart ?? null,
|
|
337
399
|
// 创建端(SLOT-END-PARAM 批 §6.20 判据句 4 写面——全新分支):取值链已由守卫(上方
|
|
338
400
|
// `guardForeignSlotFile`)解析入 `agent._slotCreatedBy`(文件不在盘 ⇒ 进程端名)。
|
|
339
401
|
createdBy: agent._slotCreatedBy ?? sessionEnd(),
|
|
340
402
|
}
|
|
341
403
|
}
|
|
404
|
+
// Migrate legacy slots at the same write: removing the old boolean without mode would lose
|
|
405
|
+
// the session's engineering state if the process stops before the next full saveSession.
|
|
406
|
+
data.mode = agent.config?.agent?.mode ?? (agent.config?.agent?.engineering === true ? "engineering" : "normal")
|
|
407
|
+
delete data.engineering
|
|
342
408
|
const fields = engTokenSlotFields(agent)
|
|
343
409
|
if (fields.engDesignTokens !== undefined) data.engDesignTokens = fields.engDesignTokens
|
|
344
410
|
else delete data.engDesignTokens
|
|
345
411
|
// 批次归属旁列逐字段复制同处(§10「保存 / 合并路径」第二处):空表 ⇒ 字段删(不从上次落盘复活)。
|
|
346
412
|
if (fields.engDesignTokenBatches !== undefined) data.engDesignTokenBatches = fields.engDesignTokenBatches
|
|
347
413
|
else delete data.engDesignTokenBatches
|
|
414
|
+
// 评审封印旁列同处落盘(§10.2 落点表「落盘」行):同一空态语义(空表 ⇒ 字段删)。
|
|
415
|
+
if (fields.engDesignTokenSeals !== undefined) data.engDesignTokenSeals = fields.engDesignTokenSeals
|
|
416
|
+
else delete data.engDesignTokenSeals
|
|
348
417
|
// 单值镜像字段永不复写(D3 零写)——残留 engDesignToken 随本次写一并清(更快退役,
|
|
349
418
|
// 杜绝 stale 镜像 + 空 Map 组合在下次 restore 二次迁移复活死 token 的边角)。
|
|
350
419
|
delete data.engDesignToken
|