thincoder 0.12.79 → 0.12.81
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 +17 -0
- package/README.md +88 -37
- package/package.json +2 -2
- package/src/acp/bridge.mjs +75 -23
- package/src/acp/read-data.mjs +4 -4
- package/src/acp/resource-link.mjs +1 -1
- package/src/cli/make-agent.mjs +1 -1
- package/src/command-interactive.mjs +3 -1
- package/src/command-table.mjs +5 -0
- package/src/tui/agent-turn.mjs +8 -2
- package/src/tui/cmd-eng.mjs +1 -1
- package/src/tui/cmd-mcp.mjs +1 -1
- package/src/tui/lifecycle-records.mjs +12 -1
- package/src/tui/render-loop.mjs +24 -4
- package/src/tui/status-line.mjs +4 -5
- package/src/tui/tui-state.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [0.12.81] — 2026-11-04
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **撞帽卡给出「本段 + 累计」两个数**:删掉印错的 `(limit)`。
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **升级核到 `0.11.1`**:承载「`ssh` 文件传输 `put` / `get`」「写门射程含 `ssh`(只 `get` 要号)」「派单动作表四列(加原因)」「SSE 首 chunk 与流中途分窗」「`x-opencode-session` 每会话一个」「台账契约五面同口径」。
|
|
10
|
+
- **`ledger/count` 的界改用调用方 `cwd`**:跨项目读面,不再按进程根。
|
|
11
|
+
|
|
12
|
+
## [0.12.80] — 2026-10-26
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **升级核到 `0.10.13`**:承载「模型请求带产品身份头」。CLI 在 `src/command-table.mjs` 顶部声明自己的端与版本(每个命令都过的分发点——不是 `tui/startup.mjs`,那条会漏 headless ∥ ACP ∥ distill ∥ embedding 四条模型路径)。
|
|
17
|
+
|
|
1
18
|
## [0.12.79] — 2026-10-26
|
|
2
19
|
|
|
3
20
|
### Changed
|
package/README.md
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
**A "thin" AI coding agent: pure `.mjs`, no build step, zero third-party dependencies, native Node.js.**
|
|
6
6
|
|
|
7
|
-
The "Thin" in ThinCoder doesn't mean "feature-poor"
|
|
8
|
-
While every AI agent races to be "all-powerful", ThinCoder plays the opposite card: **restraint, precision, no filler**.
|
|
9
|
-
Its persona is a geek engineer of few words who cuts to the bone: give it a complex requirement, get back a clean implementation.
|
|
7
|
+
The "Thin" in ThinCoder doesn't mean "feature-poor". It means **sharp thinking, straight to the point** — like a blade.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
While every AI agent races to be "all-powerful", ThinCoder plays the opposite card: **restraint, precision, no filler**. Its persona is a geek engineer of few words who cuts to the bone — give it a complex requirement, get back a clean implementation.
|
|
10
|
+
|
|
11
|
+
Design philosophy (the entire meaning of the name): if the Node standard library can do it, no third-party dependency is allowed.
|
|
12
|
+
|
|
13
|
+
So `node_modules` holds no third-party packages — only the first-party `@thincoder/core` shared core, a local link in development and resolved from the npm registry for releases.
|
|
13
14
|
|
|
14
15
|
## Features
|
|
15
16
|
|
|
@@ -17,18 +18,26 @@ resolved from the npm registry for releases).
|
|
|
17
18
|
- **Checkpoint system**: auto-snapshot before every user task, `list`/`create`/`rewind` tools for the model, single-file restore — rewinding itself is reversible (pre-rewind state auto-saved)
|
|
18
19
|
- **Codebase understanding** ⭐0.5.0: `repo_outline` (dependency outline, auto-injected at startup), `code_search` (source FTS5 + vectors + JSDoc extraction), `doc_search` (docs chunked by ## headings) — background indexing, auto-incremental updates on file writes, three tools
|
|
19
20
|
guided by "structure → intent → details"
|
|
20
|
-
- **Model adaptation** ⭐: top-tier only, latest only. Built-in flagship models from twenty-five providers — DeepSeek / Kimi / Kimi For Coding / GLM / GLM Coding Plan (智谱 Coding) / Qwen / Qwen Token Plan / MiMo (小米) / MiMo Token Plan (小米套餐) / MiniMax / OpenAI / Claude / Gemini / Gemini (OpenAI-compatible — same key)
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
- **Model adaptation** ⭐: top-tier only, latest only. Built-in flagship models from twenty-five providers — DeepSeek / Kimi / Kimi For Coding / GLM / GLM Coding Plan (智谱 Coding) / Qwen / Qwen Token Plan / MiMo (小米) / MiMo Token Plan (小米套餐) / MiniMax / OpenAI / Claude / Gemini / Gemini (OpenAI-compatible — same key).
|
|
22
|
+
|
|
23
|
+
Further presets: Grok / Mistral / Volcengine Ark (豆包) / Hunyuan (腾讯混元) / Tencent TokenHub (腾讯混元网关) / Huawei Cloud MaaS (华为云 MaaS) / SiliconFlow (硅基流动) / OpenRouter / Groq / OpenCode Go (same key for both protocol sides: OpenAI-compatible + Anthropic Messages).
|
|
24
|
+
|
|
25
|
+
No legacy model compatibility. Context windows are auto-matched.
|
|
26
|
+
|
|
27
|
+
The same deep adaptation covers truncation-resume protocols (prefix/partial), thinking-mode APIs (thinking.type / reasoning_effort), reasoning_content echo strategies (reasoningEcho), output limits and temperature range clamping.
|
|
23
28
|
- **Toolset**: `read` / `write` / `edit` / `bash` / `glob` (supports `**`) / `grep` / `websearch` / `ls` / `fetch` + `read_image` (image/video paste) + three retrieval tools + MCP — all zero-dependency, file tools confined to the working directory
|
|
24
29
|
- **Memory system**: three layers (personal/project/team), FTS5 + vector RRF hybrid retrieval, git-friendly markdown format
|
|
25
30
|
- **Two-phase tool scheduling**: permission prompts serialized, read-only tools parallelized, side-effect tools serialized
|
|
26
31
|
- **Session persistence** ⭐0.5.0: unlimited archive slots, `/session` to switch anytime, tool results visible after restore. Process-level isolation — multiple instances in the same directory each get their own session slot
|
|
27
32
|
- **Concurrent subagents**: five roles — `explore`/`plan`/`coder`/`eng-coder`/`eng-designer` — dispatched in parallel, streaming output visible, reports land in the conversation; per-subagent model override (`subagent` tool `model` arg or `agent.subagentModel` config — e.g.
|
|
28
33
|
discuss with `glm-5.2`, let `deepseek-v4-flash` implement)
|
|
29
|
-
- **Multi-model consultation 会诊 + 飞刀 (escalate)** ⭐0.12.30: `consult_start`/`consult_stop` run several configured models in parallel as independent read-only consultants (each with its own TUI activity card, `main_history` access to the failure trail); when every model settles
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
- **Multi-model consultation 会诊 + 飞刀 (escalate)** ⭐0.12.30: `consult_start`/`consult_stop` run several configured models in parallel as independent read-only consultants (each with its own TUI activity card, `main_history` access to the failure trail); when every model settles.
|
|
35
|
+
|
|
36
|
+
The full verdict digest is then delivered automatically (R17 — consult_check retired).
|
|
37
|
+
|
|
38
|
+
`escalate` flies in a stronger model for a single expert implementation run with full write access. It is default-async since R17, so the post-op report arrives automatically with its mutations merged.
|
|
39
|
+
|
|
40
|
+
Candidate pool = `agent.consultModels` ([{ provider, model, effort? }], up to 5); budgets via `agent.consultTurns` / `agent.consultTimeoutMs`.
|
|
32
41
|
- **Plan Mode**: read-only exploration + design, implement after user approval
|
|
33
42
|
- **AUTO mode**: `/auto` full authorization, no confirmations on long tasks
|
|
34
43
|
- **Task tracking**: `task` tool breaks down multi-step work, status bar ✓n/m live progress, auto-filters completed items
|
|
@@ -77,10 +86,15 @@ npm install -g thincoder
|
|
|
77
86
|
thincoder
|
|
78
87
|
```
|
|
79
88
|
|
|
80
|
-
First launch walks you through a setup wizard: arrow keys to pick a provider (built-in presets or a custom endpoint) → enter API key → optionally enter an embedding key (SiliconFlow, enables vector memory search, skippable) → arrow keys to pick a model
|
|
81
|
-
files. Adjust anytime with `/model` (add/remove providers, set keys, custom endpoints) or `/config embedkey`. `chat`/`distill` also offer in-place interactive setup when no key is configured in a terminal (in pipes/CI they exit with an error and instructions).
|
|
89
|
+
First launch walks you through a setup wizard: arrow keys to pick a provider (built-in presets or a custom endpoint) → enter API key → optionally enter an embedding key (SiliconFlow, enables vector memory search, skippable) → arrow keys to pick a model.
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
Nothing is hand-edited in config files. Adjust any of it later with `/model` (add/remove providers, set keys, custom endpoints) or `/config embedkey`.
|
|
92
|
+
|
|
93
|
+
`chat`/`distill` also offer in-place interactive setup when no key is configured in a terminal; in pipes/CI they exit with an error and instructions.
|
|
94
|
+
|
|
95
|
+
Any OpenAI-compatible endpoint works without a built-in preset: pick **add provider → custom** in `/model` (name + baseURL + model), or hand-write the entry in `providers[]`.
|
|
96
|
+
|
|
97
|
+
Regional endpoint variants work the same way — Huawei Cloud MaaS, for example, is `https://api-ap-southeast-1.modelarts-maas.com/openai/v1`.
|
|
84
98
|
|
|
85
99
|
You can also hand-write `~/.thincoder/config.json` (see "Configuration" below), then:
|
|
86
100
|
|
|
@@ -107,14 +121,23 @@ thincoder upgrade
|
|
|
107
121
|
|
|
108
122
|
Running from source: replace `thincoder` above with `node bin/thincoder.mjs`.
|
|
109
123
|
|
|
110
|
-
Slash commands in the TUI
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
Slash commands in the TUI cover the whole loop. `/help` prints help, and `/model` opens a two-level picker (provider first, then model) that also adds or removes providers, sets keys and edits custom endpoints; `/model <provider>:<name>` switches directly.
|
|
125
|
+
|
|
126
|
+
Subagents get the same treatment. `/submodel` picks their models per type, from global plus the explore/plan/coder/eng-coder/eng-designer slots, or takes `/submodel <type> <provider:model>` directly.
|
|
127
|
+
|
|
128
|
+
`/shell` opens a platform-aware picker over the available shells — pick Git Bash/pwsh, or pass `/shell "C:\Program Files\Git\bin\bash.exe"`, or `/shell reset`. It also fixes win11 cmd encoding/command issues.
|
|
129
|
+
|
|
130
|
+
`/think` toggles thinking mode and reasoning effort. `/config` views configuration, and with no argument opens the interactive menu (default model, embedding key, proxy), while `/config embedkey` sets the embedding key directly.
|
|
131
|
+
|
|
132
|
+
`/session` lists and switches archived sessions; `/reindex` rebuilds the index; `/extract` pulls knowledge from the current session; `/restore` restores a checkpoint; `/clear` and `/exit` do what they say.
|
|
133
|
+
|
|
134
|
+
High-frequency commands support abbreviations: `/h` `/x` `/m` `/p` `/t` `/c` `/n`. Typing `/` shows live matching hints in the status bar, and the model picker supports search/filter — type to narrow down results.
|
|
115
135
|
|
|
116
|
-
Configuration comes exclusively from `~/.thincoder/config.json` — the single source of truth.
|
|
117
|
-
|
|
136
|
+
Configuration comes exclusively from `~/.thincoder/config.json` — the single source of truth.
|
|
137
|
+
|
|
138
|
+
Sensitive value fields — a provider's `apiKey` or `websearch.apiKey`, for instance — may hold a `${env:VAR}` reference, resolved at use time, when the value is taken from the environment variable.
|
|
139
|
+
|
|
140
|
+
There is no environment-variable-only configuration channel and no env-only override.
|
|
118
141
|
|
|
119
142
|
> **Kimi note**: Kimi has **two separate platforms with non-interchangeable API keys** — Moonshot (`https://api.moonshot.cn/v1`, keys `sk-...`, platform.moonshot.cn) and **Kimi For Coding** (`https://api.kimi.com/coding/v1`, keys `sk-kimi-...`, platform.kimi.com, model ID `k3`).
|
|
120
143
|
> Use the `kimi` preset for Moonshot and `kimi-code` for Kimi For Coding — putting one platform's key on the other's endpoint fails with 401 (a hint is appended when the key/baseURL look mismatched).
|
|
@@ -233,6 +256,26 @@ Code conventions: pure `.mjs`, no semicolons, no third-party npm dependencies al
|
|
|
233
256
|
|
|
234
257
|
## Changelog
|
|
235
258
|
|
|
259
|
+
### 0.12.81 (2026-11)
|
|
260
|
+
- **Core `^0.11.1`** — ssh file transfer (`put` / `get`, single file, classic SCP by default); the write gate now reaches `ssh` (`get` only); task-book action tables carry a reason column; SSE first-chunk / mid-stream split; ledger contract unified on one sentence.
|
|
261
|
+
- `ledger/count`: the boundary follows the caller `cwd` (cross-project read face).
|
|
262
|
+
- Turn-cap card reports both the segment and the cumulative count; the stale `(limit)` line is gone.
|
|
263
|
+
|
|
264
|
+
### 0.12.80 (2026-10)
|
|
265
|
+
- **Core `^0.10.13`** — model requests carry a product identity header (`ThinCoder/<surface>/<version>`).
|
|
266
|
+
|
|
267
|
+
### 0.12.79 (2026-10)
|
|
268
|
+
- **Core `^0.10.12`** — ledger root errors are surfaced instead of silently returning an empty set; batch creation names the project under multi-root workspaces.
|
|
269
|
+
|
|
270
|
+
### 0.12.78 (2026-10)
|
|
271
|
+
- `modelContext` duplicate keys no longer error — two spellings that normalise to the same model are treated as one entry.
|
|
272
|
+
|
|
273
|
+
### 0.12.77 (2026-10)
|
|
274
|
+
- **Core `^0.10.10`** — prompt face rewritten (one rule per line), new "check the docs before acting" section; subagents gain the read-only `manifest` face.
|
|
275
|
+
|
|
276
|
+
### 0.12.76 (2026-10)
|
|
277
|
+
- Network tools reuse the DeepSeek key from `providers[]` (`websearch` / `fetch`), zero new config.
|
|
278
|
+
|
|
236
279
|
### 0.12.75 (2026-10)
|
|
237
280
|
- **Core `^0.10.8`** — builtin `doc_check` (document-discipline machine check as a product tool: anchors + line width, report-only) and ledger root derivation (single read/write criterion) ride in with the core.
|
|
238
281
|
- Prompt-face corrections: Chinese = design docs / English = code split landed; runtime face doc-reference removal; online-verification guidance; S1/S2 tuning.
|
|
@@ -324,10 +367,10 @@ Chinese output on win11.
|
|
|
324
367
|
|
|
325
368
|
### 0.12.9 (2026-08)
|
|
326
369
|
- **Prompt-system quality pass (both CLI and VS Code extension, byte-identical sync):**
|
|
327
|
-
- **Advisor-after-code rule moved from system
|
|
328
|
-
-
|
|
370
|
+
- **Advisor-after-code rule moved from the `system` prompt to the `discipline` prompt** — engineering mode no longer receives the conflicting "call advisor after changing code" instruction (its review-timing rules say do not call unprompted). Standard mode behavior unchanged.
|
|
371
|
+
- **`engineering` prompt delivery-review semantics unified** — the mandatory-flow step and the state table now both say: eng-coder self-reviews inside the subagent; the architect verifies against acceptance criteria and re-reviews only when asked or when the delivery looks wrong.
|
|
329
372
|
(Previously the step forced a parent-side advisor code review that the hard rules contradicted.)
|
|
330
|
-
- **checkpoint description aligned with actual auto-snapshot triggers
|
|
373
|
+
- **checkpoint description aligned with actual auto-snapshot triggers**.
|
|
331
374
|
- **advisor round budget wording fixed** — prompts advertise a 30-round budget; the mechanical hard cap is 100 rounds (loop guard). Both layers are now named explicitly.
|
|
332
375
|
|
|
333
376
|
### 0.12.8 (2026-08)
|
|
@@ -340,9 +383,11 @@ only; expanded blocks are exempt from the consecutive-dim folding so nothing fol
|
|
|
340
383
|
- **Fix: wide tables misaligned in narrow terminals** — a many-column table that still exceeded the terminal width after column shrinking (e.g. 8 columns at 40 cols) wrapped at the terminal and misaligned. Table rows are now clipped with an ellipsis instead of ever exceeding the width.
|
|
341
384
|
|
|
342
385
|
### 0.12.6 (2026-08)
|
|
343
|
-
- **Checkpoint v2 — full-file-copy snapshots** — snapshots now store complete copies of changed files (tracked + untracked) instead of a git diff patch: rollback works even after commits happened post-snapshot. New `versions` checkpoint action lists a file's historical copies
|
|
344
|
-
|
|
345
|
-
|
|
386
|
+
- **Checkpoint v2 — full-file-copy snapshots** — snapshots now store complete copies of changed files (tracked + untracked) instead of a git diff patch: rollback works even after commits happened post-snapshot. New `versions` checkpoint action lists a file's historical copies.
|
|
387
|
+
|
|
388
|
+
That listing spans snapshots by time, size or content hash, and a specific version can be restored from it.
|
|
389
|
+
|
|
390
|
+
**Full rollback is disabled** — as dangerous as a working-tree reset, since it silently discards post-snapshot work. Oversized files (>5MB) are skipped with an explicit notice, and files created after a snapshot are never deleted by a restore.
|
|
346
391
|
- **Git destructive-command protection** — `checkout --` / `restore` / `reset --hard` / `clean -f` (including bypass variants like `checkout HEAD -- .`) auto-snapshot every uncommitted file **before** running, then execute without blocking — a model rollback can no longer destroy
|
|
347
392
|
uncommitted work. Snapshot triggers slimmed to: destructive-git guard, pre-restore, manual.
|
|
348
393
|
- **Fix: bash no longer hangs on background processes** — `start /b`, `&`, `nohup` children that hold the output pipe no longer stall the tool until timeout (resolves after a short grace with a notice).
|
|
@@ -354,9 +399,13 @@ with click-to-expand — folding now has real objects in everyday sessions.
|
|
|
354
399
|
- **Fix: inline code styling** — markdown code spans now render with underline instead of reverse video (less harsh on the eyes)
|
|
355
400
|
|
|
356
401
|
### 0.12.4 (2026-08)
|
|
357
|
-
- **Context compaction unified spec** — CLI/VS Code now share one compaction semantics (`docs/design/CONTEXT-COMPACTION.md`): window-adaptive tail size (`max(10, ctx/100K×30)`, ≤40% of history), measured prompt-token baseline preferred, pure-estimation path includes system+tools
|
|
358
|
-
|
|
359
|
-
|
|
402
|
+
- **Context compaction unified spec** — CLI/VS Code now share one compaction semantics (`docs/core/design/CONTEXT-COMPACTION.md`): window-adaptive tail size (`max(10, ctx/100K×30)`, ≤40% of history), measured prompt-token baseline preferred, pure-estimation path includes system+tools overhead.
|
|
403
|
+
|
|
404
|
+
Head/tail tool-call pairing is protected on both sides, and the fallback runs in 3 tiers: LLM summary → deterministic truncation after 3 failures → per-message shrink.
|
|
405
|
+
|
|
406
|
+
Compaction summaries stay silent to the frontend — nothing streams into the conversation — and task re-injection is deduplicated.
|
|
407
|
+
|
|
408
|
+
Unknown model names now warn once instead of silently degrading to the 128K default.
|
|
360
409
|
- **Kimi For Coding support** — new `kimi-code` preset (`api.kimi.com/coding/v1`, model `k3`, platform.kimi.com, `sk-kimi-` keys — NOT interchangeable with Moonshot); `MODEL_SPECS` gains the `k3` alias (1M context / multimodal / partialMode / reasoningEcho); 401 errors hint at
|
|
361
410
|
the two-platform key mismatch; README documents the split
|
|
362
411
|
- **Ctrl+C double-confirm** — idle-state first Ctrl+C only warns (3s window), second press exits; picker-cancel and in-flight abort semantics unchanged
|
|
@@ -403,7 +452,7 @@ limits output to 50KB, enforces 30s timeout, and blocks private IPs in fetch. Sc
|
|
|
403
452
|
- **Lifecycle Hooks** — `PreToolUse` / `PostToolUse` / `PostToolUseFailure` / `Stop` events. User-defined shell commands in config, with per-tool regex matching, timeout control, and `block`/`allow`/`notify` actions. Implemented in `thincoder-core/hooks.mjs`, integrated into tool dispatch.
|
|
404
453
|
- **Built-in Skills (5)** — `pdf-create`, `xlsx-create`, `frontend-design`, `code-review`, `api-design` ship with the installation. Each is a standalone markdown instruction file using zero-dependency approaches (Chrome headless for PDF, PowerShell for Excel, etc.).
|
|
405
454
|
- **Conversation message folding** — Long tool result blocks (>8 consecutive dim lines) auto-collapse to first 2 lines + "… N more lines — Enter to expand". `/fold on|off` toggles globally.
|
|
406
|
-
- **Tree-shaped tasks** — `checklist` tool now supports hierarchical task IDs (`T1`, `T1.1`, `T1.2.1`) with auto-assigned numbering. `add` accepts `parent` parameter for subtree positioning. Indentation-based persistence in
|
|
455
|
+
- **Tree-shaped tasks** — `checklist` tool now supports hierarchical task IDs (`T1`, `T1.1`, `T1.2.1`) with auto-assigned numbering. `add` accepts `parent` parameter for subtree positioning. Indentation-based persistence in the checklist file.
|
|
407
456
|
- **AI-native MCP config** — `/mcp add` picker now includes "Describe with AI" option. Describe a server in natural language → model generates config JSON → preview + confirm → save and connect.
|
|
408
457
|
- **Goal judge model** — `goal complete` now runs an independent LLM check: goal criteria + recent agent activity → judge model verifies YES/NO. Prevents false completion claims during autonomous work.
|
|
409
458
|
- **`/undo` command** — Tracks up to 50 write/edit/delete operations in `agent._undoStack`. `/undo` opens a picker showing each operation's file and original content size. Select to revert.
|
|
@@ -437,17 +486,19 @@ extensions, Office add-ins, Program Files)
|
|
|
437
486
|
- **Refactor: `embed-config.mjs`** — simplified to only read API key via `resolveEmbedKey()`, base URL and model are fixed constants; VSCode SecretStorage dependency removed
|
|
438
487
|
|
|
439
488
|
### 0.8.11 (2026-07)
|
|
440
|
-
- **Feat**: `checklist` tool — persistent project task tracking in `.thincoder
|
|
489
|
+
- **Feat**: `checklist` tool — persistent project task tracking in a checklist file under `.thincoder/`. Add/mark/list items, auto-archive done items to a separate done file. Injected at session start (pending + in_progress only)
|
|
441
490
|
- **Feat**: updated prompts — four-step workflow (requirements→design→development→testing), three-step debugging strategy (logs→docs→binary search), working checklist discipline
|
|
442
|
-
- **Feat**: methodology docs — `docs/
|
|
491
|
+
- **Feat**: methodology docs — `docs/core/requirements/METHODOLOGY.md` rebuilt, `docs/core/requirements/PHILOSOPHY.md` expanded with worldview #6 (official docs over guessing)
|
|
443
492
|
- **Bugfix**: vision guard — `read_image` now refuses non-vision models before reading the file, the agent loop injects a system reminder instead of image parts for text-only models, and `stripImagesForTextModel` sanitizes image parts at send time (history untouched, restored
|
|
444
493
|
when switching back to a vision model). Previously a single image in history made text-only APIs (e.g. DeepSeek) reject EVERY subsequent request with 400, bricking the conversation
|
|
445
494
|
- **Improvement**: silent `catch {}` blocks now log to stderr (checkpoint file copies, MCP notify/close, session incremental save, clipboard paste, provider picker, team-memory rebase abort, tool dispatch) — failures are visible for debugging instead of disappearing
|
|
446
495
|
|
|
447
496
|
### 0.8.10 (2026-07)
|
|
448
|
-
- **Bugfix**: pasted text now lands in the active TUI text target — the API key prompt when adding a provider via `/model` (and any free-text `askQuestion`) now accepts paste correctly. Previously, bracketed-paste injection in the terminal was always written to the main input
|
|
449
|
-
|
|
450
|
-
|
|
497
|
+
- **Bugfix**: pasted text now lands in the active TUI text target — the API key prompt when adding a provider via `/model` (and any free-text `askQuestion`) now accepts paste correctly. Previously, bracketed-paste injection in the terminal was always written to the main input box.
|
|
498
|
+
|
|
499
|
+
Pasting into a question prompt therefore appeared as "nothing happened", and the text was orphaned into the input box after the question closed.
|
|
500
|
+
|
|
501
|
+
Both bracketed-paste (Windows Terminal / most modern terminals) and Ctrl+V-as-key-event (legacy conhost) now route through a single `insertPastedText` helper. It targets the question answer, the options-list (ignored), or the main input box as appropriate.
|
|
451
502
|
|
|
452
503
|
### 0.8.9 (2026-07)
|
|
453
504
|
- **Bugfix**: `wizardProviderItems` was defined inside `createWizard()` but not included in the return statement, causing key-handler to crash with `TypeError` during provider selection on first launch (/ new config)
|
|
@@ -458,7 +509,7 @@ box, so pasting into a question prompt appeared as "nothing happened" and orphan
|
|
|
458
509
|
- **Feat**: auto update check on startup + `/upgrade` command
|
|
459
510
|
|
|
460
511
|
### 0.8.3 (2026-07)
|
|
461
|
-
- **Output panels**: tools with `outputPanel` flag stream to scrolled panel, auto-collapse to summary on completion (bash, long tool results)(机制已于 2026-08-30 废除——D6 清理,见 AGENT-LOOP.md)
|
|
512
|
+
- **Output panels**: tools with `outputPanel` flag stream to scrolled panel, auto-collapse to summary on completion (bash, long tool results)(机制已于 2026-08-30 废除——D6 清理,见 docs/core/design/AGENT-LOOP.md)
|
|
462
513
|
- **Checkpoint enhancements**: `cat` for file preview from snapshots, per-file rewind, auto-recover on apply failure, escape-hatch hints on errors
|
|
463
514
|
- **Bash safety**: `checkpoint-before-destructive` discipline rule; bash guard guides checkpoint instead of just commit/stash
|
|
464
515
|
- **Code review fixes**: output friendliness, readability, English-only strings, TUI polish
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thincoder",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.81",
|
|
4
4
|
"description": "Thin coding agent - zero third-party dependencies, no build step, Node.js native. Sharp code, zero bloat.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": ">=24"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@thincoder/core": "^0.
|
|
23
|
+
"@thincoder/core": "^0.11.1"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"bin/",
|
package/src/acp/bridge.mjs
CHANGED
|
@@ -23,8 +23,11 @@
|
|
|
23
23
|
* End-of-turn is NOT a notification: `session/prompt` resolves with
|
|
24
24
|
* `{ stopReason: "end_turn" }` (kimi session.ts parity).
|
|
25
25
|
*/
|
|
26
|
-
import { detectDanger, normalizeEOL, joinWithEol } from "@thincoder/core/tools/shared.mjs"
|
|
27
|
-
import { computeEditEntry, validateEditEntry, assertEditArgsExclusive, assertEditsContainer, assertEditEntries, hasLineParams,
|
|
26
|
+
import { detectDanger, normalizeEOL, joinWithEol, resolveInCwd } from "@thincoder/core/tools/shared.mjs"
|
|
27
|
+
import { computeEditEntry, validateEditEntry, assertEditArgsExclusive, assertEditsContainer, assertEditEntries, hasLineParams, planEditEntries, applyPlannedEntries, deleteTarget, EDIT_ENTRY_NO_PATH, editEntryLabel } from "@thincoder/core/tools/edit-diff.mjs"
|
|
28
|
+
// 行号锚护栏(EDIT-HELPERS §7):桥不经 writeThroughPath ⇒ 判据与记账都得在桥面接(§7.4)。
|
|
29
|
+
// 判据 / 拒文 = 核单源;记账 = 写缓冲成功后桥自 recordWrite,键 = resolveInCwd 后的绝对路径。
|
|
30
|
+
import { recordWrite, lineAnchorVerdict, lineAnchorRefusal } from "@thincoder/core/tools/write-path.mjs"
|
|
28
31
|
// 第 27 批 §12.3①/③:relay 前缀文法单一权威(模块直连——不自持正则副本)。
|
|
29
32
|
import { parseRelayPath } from "@thincoder/core/agent/relay-prefix.mjs"
|
|
30
33
|
// 批 1 CORE-DEFECT-FIXES B3:onWait 相位值域 + 文案单源(本面仅日志——PROVIDER.md §6.20)
|
|
@@ -154,23 +157,42 @@ export function buildAcpCallbacks({ sessionId, agent, notify, request, log = ()
|
|
|
154
157
|
throw new Error(`fs/write_text_file failed: ${e.message}`)
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
|
-
/**
|
|
158
|
-
*
|
|
159
|
-
|
|
160
|
+
/** 记账键(§7.4):与核同一键 = `resolveInCwd` 后的绝对路径——键不一致则核与桥各记一条、
|
|
161
|
+
* 互相看不见,护栏对另一条通道等于零。 */
|
|
162
|
+
const absOf = (p) => resolveInCwd({ cwd: agent?.cwd ?? process.cwd() }, p)
|
|
163
|
+
/** 单形态:读 IDE 缓冲 → 行号锚护栏判定 → computeEditEntry(rich——无 abortPrefix——同本地
|
|
164
|
+
* runSingleEdit)→ 写回 → 记账。EOL 权威(F1):判定/应用在 normalizeEOL 后的 LF 域;写回
|
|
165
|
+
* joinWithEol 按原文首换行恢复(LF 域判定——CRLF 域写回——与本地 edit 工具同判同恢复)。 */
|
|
160
166
|
const editSingle = async (p, args) => {
|
|
161
167
|
const raw = await readBuffer(p)
|
|
162
168
|
const content = normalizeEOL(raw)
|
|
163
|
-
const
|
|
169
|
+
const abs = absOf(p)
|
|
170
|
+
// 行号锚护栏(§7.4):行号形才需判——内容形态是位置无关寻址,没有可漂移的锚。
|
|
171
|
+
// 形态校验先于护栏(与核 runSingleEdit 同序):缺 endLine / 与 old_string 互斥报自己的句。
|
|
172
|
+
if (hasLineParams(args)) {
|
|
173
|
+
validateEditEntry(args, { rich: true })
|
|
174
|
+
const startLine = args.line ?? args.startLine
|
|
175
|
+
const endLine = args.line ?? args.endLine
|
|
176
|
+
if (lineAnchorVerdict(abs, startLine, endLine)) throw new Error(lineAnchorRefusal(abs, startLine, endLine))
|
|
177
|
+
}
|
|
178
|
+
const out = computeEditEntry(content, args, { path: p, absPath: abs })
|
|
164
179
|
await writeBuffer(p, joinWithEol(normalizeEOL(out.updated).split("\n"), raw))
|
|
180
|
+
// 缓冲写回**成功之后**记账(快照对同一坐标系有效——缓冲与盘面可能不同步,行号语义跟的是缓冲)
|
|
181
|
+
recordWrite(abs, { type: "edit", startLine: out.editStartLine, shift: out.lineShift })
|
|
182
|
+
// 逐条回执(§7.4「单形态删行不经桥」):单形态经桥恒为确认形——路由门要求单形态的
|
|
183
|
+
// `new_string` 是字符串,而删行只在**省略**它时成立 ⇒ 单形态删行走不到这里(落本地通道,
|
|
184
|
+
// 回执 = 核面 `Deleted line N of <path>`),桥面的删行回执只来自 `edits` 数组形态(editBatch)。
|
|
185
|
+
// 不留删行分支:为没出现过的输入加分支 = 加一条没人走的路,且它会让下一个读这里的人
|
|
186
|
+
// 以为单形态删行走 IDE 缓冲(实测不走);放宽路由门是行为变更,没人要求过。
|
|
165
187
|
return `OK: edited ${p} via IDE (${out.occurrences} occurrence(s))${out.note ? ` — ${out.note}` : ""}`
|
|
166
188
|
}
|
|
167
189
|
/** 数组形态(D15.7):守卫与文案单源 = 本地 edit-diff(assertEditsContainer / assertEditEntries /
|
|
168
190
|
* validateEditEntry——EDIT.md §8 D-7:核 edit-batch 与桥同调用、桥零字面副本)→
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
191
|
+
* 读全部涉及文件缓冲(按绝对路径去重——一次读)→ 用批前快照判一次 → **帧调同一对纯函数**
|
|
192
|
+
* (planEditEntries / applyPlannedEntries,R1–R4;不另写组循环)→ 全部通过 → 逐文件写回
|
|
193
|
+
* 一次并同记账(判失败 → 零写;写失败 → 同本地 edit-batch 既有原子语义)。 */
|
|
172
194
|
/** ACP batch-edit 通道——与 EDIT.md:#796 汇总行体系**无关**。
|
|
173
|
-
* 桥面 `
|
|
195
|
+
* 桥面 `prepared.map(...).join("\\n")` 自持逐条文字行,不经 `applyEditBatch`/`diffLines`/offload;
|
|
174
196
|
* 距 64K offload 阈值远 + 不含 diff 结构 ⇒ 不在 offload 盲区范围。**判定:非 #796 射程(#908)**。
|
|
175
197
|
*/
|
|
176
198
|
const editBatch = async (args) => {
|
|
@@ -178,36 +200,63 @@ export function buildAcpCallbacks({ sessionId, agent, notify, request, log = ()
|
|
|
178
200
|
assertEditsContainer(edits)
|
|
179
201
|
assertEditArgsExclusive(args)
|
|
180
202
|
assertEditEntries(edits)
|
|
181
|
-
const groups = new Map() //
|
|
182
|
-
for (
|
|
203
|
+
const groups = new Map() // abs → { abs, path, raw, content, edits, origIdx }
|
|
204
|
+
for (let i = 0; i < edits.length; i++) {
|
|
205
|
+
const e = edits[i]
|
|
183
206
|
// 2026-09-05 用户裁定(CLI parity——本地 edit-batch 同句):条目自带 path 优先;
|
|
184
207
|
// 缺省回退顶层 path(pathOf——path/filePath 别名同单形态)
|
|
185
|
-
const p = e.path
|
|
208
|
+
const p = e.path || pathOf(args) // 同核 edit-batch 的兜底判(`||` 而非 `??`——空串也回落顶层)
|
|
186
209
|
if (!p) throw new Error(EDIT_ENTRY_NO_PATH)
|
|
187
210
|
validateEditEntry(e, { label: editEntryLabel(p), rich: false })
|
|
188
|
-
|
|
211
|
+
const abs = absOf(p)
|
|
212
|
+
let g = groups.get(abs)
|
|
189
213
|
if (!g) {
|
|
190
|
-
g = { path: p, raw: "", content: "", edits: [] }
|
|
191
|
-
groups.set(
|
|
214
|
+
g = { abs, path: p, raw: "", content: "", edits: [], origIdx: [] }
|
|
215
|
+
groups.set(abs, g)
|
|
192
216
|
}
|
|
193
217
|
g.edits.push(e)
|
|
218
|
+
g.origIdx.push(i) // 条目在 `edits` 数组里的原始下标——回显按它回位(§7.3)
|
|
194
219
|
}
|
|
195
220
|
for (const g of groups.values()) {
|
|
196
221
|
g.raw = await readBuffer(g.path)
|
|
197
222
|
g.content = normalizeEOL(g.raw)
|
|
198
223
|
}
|
|
199
|
-
|
|
224
|
+
// 判定点(§7.3 同核):组循环之前用**批前快照**判一次——命中即抛、零写
|
|
200
225
|
for (const g of groups.values()) {
|
|
201
226
|
for (const e of g.edits) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
227
|
+
if (!hasLineParams(e)) continue
|
|
228
|
+
const startLine = e.line ?? e.startLine
|
|
229
|
+
const endLine = e.line ?? e.endLine
|
|
230
|
+
if (lineAnchorVerdict(g.abs, startLine, endLine)) throw new Error(lineAnchorRefusal(g.abs, startLine, endLine))
|
|
205
231
|
}
|
|
206
232
|
}
|
|
233
|
+
// 帧单源:调 §7.3 的同一对零 IO 纯函数——桥只做「读缓冲 → 应用计划 → 写缓冲」。
|
|
234
|
+
// 回显按调用序 = 按条目的**原始下标**回填(§7.3):跨文件交错的批若按文件分组去排会排成
|
|
235
|
+
// A、A、B——模型按位置对号入座,顺序一变它会把结果贴到错的那一笔上。
|
|
236
|
+
const prepared = new Array(edits.length)
|
|
237
|
+
for (const g of groups.values()) {
|
|
238
|
+
const plan = planEditEntries(g.edits, g.path)
|
|
239
|
+
if (plan.rejection) throw new Error(plan.rejection)
|
|
240
|
+
const applied = applyPlannedEntries(g.content, g.edits, plan.order, { path: g.path })
|
|
241
|
+
g.content = applied.content
|
|
242
|
+
g.netShift = applied.results.reduce((n, r) => n + r.lineShift, 0)
|
|
243
|
+
// results 按组内调用序;g.origIdx 给出它在这一组里的下标对应的原始下标
|
|
244
|
+
applied.results.forEach((r, k) => { prepared[g.origIdx[k]] = { g, ...r } })
|
|
245
|
+
}
|
|
207
246
|
for (const g of groups.values()) {
|
|
208
247
|
await writeBuffer(g.path, joinWithEol(normalizeEOL(g.content).split("\n"), g.raw))
|
|
248
|
+
// 写缓冲成功后记账:合并快照 startLine = 组内最小、shift = 组内净漂移(同核批量语义)
|
|
249
|
+
const startLine = Math.min(...prepared.filter((p) => p.g === g).map((p) => p.editStartLine))
|
|
250
|
+
recordWrite(g.abs, { type: "edit", startLine, shift: g.netShift })
|
|
209
251
|
}
|
|
210
|
-
|
|
252
|
+
// 逐条回执同单形态(§7.4):删行条目写 `Deleted <line N|lines N-M> of <path> via IDE`,
|
|
253
|
+
// 行号段取同一 `deleteTarget`;替换条目保持确认形。核面的 diff / `context (L…-L…)` /
|
|
254
|
+
// 批末汇总行桥面不写(那三样读盘面内容或起外部进程,缓冲与盘面可能不同步)。
|
|
255
|
+
return prepared
|
|
256
|
+
.map((o) => (o.deleted
|
|
257
|
+
? `Deleted ${deleteTarget(o)} of ${o.g.path} via IDE`
|
|
258
|
+
: `OK: edited ${o.g.path} via IDE (${o.occurrences} occurrence(s))${o.note ? ` — ${o.note}` : ""}`))
|
|
259
|
+
.join("\n")
|
|
211
260
|
}
|
|
212
261
|
|
|
213
262
|
const callbacks = {
|
|
@@ -334,8 +383,8 @@ export function buildAcpCallbacks({ sessionId, agent, notify, request, log = ()
|
|
|
334
383
|
/**
|
|
335
384
|
* fs reverse-RPC router (dispatch.mjs toolRouter, M2) — 能力位 + 工具形态双判(§11.4):
|
|
336
385
|
* - write → fs/write_text_file (full content, no read-back) — 需 clientCaps.fs.writeTextFile
|
|
337
|
-
* - edit → fs/read_text_file → computeEditEntry(本地权威——单/数组形态)→ fs/write_text_file
|
|
338
|
-
* (§15.1 D15.7
|
|
386
|
+
* - edit → fs/read_text_file → 行号锚护栏 → computeEditEntry(本地权威——单/数组形态)→ fs/write_text_file
|
|
387
|
+
* (§15.1 D15.7 委派——双通道同语义;数组=原子批量——帧 R1–R4 同核,写回成功后同记账)
|
|
339
388
|
* — 需 readTextFile ∧ writeTextFile(读回是 edit 桥的必要前提)
|
|
340
389
|
* - apply_patch → local (unified-diff application is not routed in M2)
|
|
341
390
|
* - delete, reads → local
|
|
@@ -351,6 +400,9 @@ export function buildAcpCallbacks({ sessionId, agent, notify, request, log = ()
|
|
|
351
400
|
const content = args.content
|
|
352
401
|
try {
|
|
353
402
|
await request("fs/write_text_file", { sessionId, path, content }, { timeoutMs: 30000 })
|
|
403
|
+
// 全文重写也是「我们写的」——与核 writeTool 同型记账(§7.1 第 3 行:之后任何行号形拒)。
|
|
404
|
+
// 不记这一格,同一份漂移就成了「本地拒、IDE 缓冲放」。
|
|
405
|
+
recordWrite(absOf(path), { type: "write", startLine: 1, shift: 0 })
|
|
354
406
|
return { handled: true, result: `OK: wrote ${path} via IDE` }
|
|
355
407
|
} catch (e) {
|
|
356
408
|
return { handled: true, result: `Error: fs/write_text_file failed: ${e.message}` }
|
package/src/acp/read-data.mjs
CHANGED
|
@@ -73,8 +73,8 @@ export function createReadDataHandlers(ctx, { intervalMs = WATCH_INTERVAL_MS } =
|
|
|
73
73
|
const c = resolveCwd(params, ctx)
|
|
74
74
|
if (c.error) return c.error
|
|
75
75
|
const { ledgerCmd } = await core()
|
|
76
|
-
// `ledgerCount` 出参 = 对象形 `{ count, overdue,
|
|
77
|
-
try { return ledgerCmd.ledgerCount({ cwd: c.cwd }) } catch (e) { return badParams(e?.message ?? String(e)) }
|
|
76
|
+
// `ledgerCount` 出参 = 对象形 `{ count, overdue, evidenceTooLong }`(设计档 §7.1)——直传核对象,零包装
|
|
77
|
+
try { return ledgerCmd.ledgerCount({ cwd: c.cwd, boundary: c.cwd }) } catch (e) { return badParams(e?.message ?? String(e)) } // 界 = 调用方指名的 cwd(同 :66;见 docs/core/design/LEDGER.md §3.8「三面三界」)
|
|
78
78
|
},
|
|
79
79
|
|
|
80
80
|
"batch/list": async (params) => {
|
|
@@ -101,8 +101,8 @@ export function createReadDataHandlers(ctx, { intervalMs = WATCH_INTERVAL_MS } =
|
|
|
101
101
|
const { ledgerDb, batchRead } = await core()
|
|
102
102
|
// 观察域根 = 判据单源 `resolveLedgerRoot`(与写入面同源):根 ⇒ 其键控库指纹;无根 ⇒ 该域无台账库、
|
|
103
103
|
// 指纹恒 "0"(观察域照常上报——键控库在盘 / 变动即报 `ledger/changed`)。
|
|
104
|
-
const root = ledgerDb.resolveLedgerRoot(cwd)?.root
|
|
105
|
-
const ledgerSig = root ? fileSig(ledgerDb.ledgerDbPath(root)) : "0"
|
|
104
|
+
const root = ledgerDb.resolveLedgerRoot(cwd, cwd)?.root
|
|
105
|
+
const ledgerSig = root ? fileSig(ledgerDb.ledgerDbPath(root, root)) : "0"
|
|
106
106
|
const batchSig = batchRead.listBatchRecords({ cwd }).batches.map((b) => `${b.path}:${fileSig(b.path)}`).join("|")
|
|
107
107
|
if (!last || last.cwd !== cwd) { last = { cwd, ledgerSig, batchSig }; return [] } // 首查 / 观察域切换 ⇒ 立基线(静默)
|
|
108
108
|
const fired = []
|
|
@@ -60,7 +60,7 @@ export async function resolveResourceLink(block, { cwd } = {}) {
|
|
|
60
60
|
} else {
|
|
61
61
|
try { path = decodeURIComponent(raw) } catch { return marker(raw, "invalid percent-encoding") }
|
|
62
62
|
}
|
|
63
|
-
path = resolvePath(cwd
|
|
63
|
+
path = resolvePath(cwd, path) // 相对路径按 cwd;已在盘面形则归一平台原生分隔符
|
|
64
64
|
|
|
65
65
|
// ③ 选区解析(仅 url.hash;非选区哈希 = 锚点 ⇒ 整文)
|
|
66
66
|
let sel = null
|
package/src/cli/make-agent.mjs
CHANGED
|
@@ -124,7 +124,7 @@ async function finalizeTools(baseTools, { cwd, config, excludeTools, warnings })
|
|
|
124
124
|
* @param {{cwd?: string, slotData?: object|null}} [opts]
|
|
125
125
|
* @returns {object|null} 附着后的 manifest / 非 ok 态与普通会话 null
|
|
126
126
|
*/
|
|
127
|
-
export function attachManifest(agent, { cwd =
|
|
127
|
+
export function attachManifest(agent, { cwd = agent.cwd, slotData } = {}) {
|
|
128
128
|
const slotEng = slotData?.engineering
|
|
129
129
|
const engineering = slotEng !== undefined ? slotEng === true : agent.config?.agent?.engineering === true
|
|
130
130
|
if (!engineering) {
|
|
@@ -108,7 +108,9 @@ export async function chatCommand(args, ctx) {
|
|
|
108
108
|
} catch (error) {
|
|
109
109
|
// 用 name 判断而非 instanceof:不依赖"与 runAgent 同一个模块实例"这一隐式约定
|
|
110
110
|
if (error.name === "ContinueError") {
|
|
111
|
-
|
|
111
|
+
// 两个数(TURN-CAP-CONTINUE.md §6.1 / §6.3 · D-TC10):本段轮数 + 链内累计(直读 `agent._turnSeq`,
|
|
112
|
+
// 不加兜底——缺值印 0 会把「未跟踪」读作「零消耗」);上限不印(§6.2 撞帽点两个上限均 ≡ 已示轮数)。
|
|
113
|
+
console.error(`\n[paused] Agent stopped after ${error.turn} turns — ${agent._turnSeq} turns total. Run in TUI to continue.`)
|
|
112
114
|
exitSoon(0)
|
|
113
115
|
} else {
|
|
114
116
|
console.error(`\n[error] ${error.message}`)
|
package/src/command-table.mjs
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { readFileSync } from "node:fs"
|
|
9
9
|
import { isAbsolute, join } from "node:path"
|
|
10
10
|
import { loadConfig } from "@thincoder/core/config.mjs"
|
|
11
|
+
import { setClientIdentity } from "@thincoder/core/client-identity.mjs"
|
|
11
12
|
import { createMemory, syncDir } from "@thincoder/core/memory.mjs"
|
|
12
13
|
import { teamConfig } from "./cli/make-agent.mjs"
|
|
13
14
|
import { memoryCommand } from "./cli/memory-command.mjs"
|
|
@@ -15,6 +16,10 @@ import { distillCommand } from "./cli/distill-command.mjs"
|
|
|
15
16
|
import { chatCommand, tuiCommand, acpCommand } from "./command-interactive.mjs"
|
|
16
17
|
import { teamCommand } from "./cli/team-command.mjs"
|
|
17
18
|
|
|
19
|
+
// 客户端标识声明(PROVIDER.md §6.17):本端进程启动期一次——落点 = 每个命令都过的分发点(headless ∥ ACP ∥ distill ∥ embedding 四条模型路径都不经 `tui/startup.mjs`)。
|
|
20
|
+
const CLI_VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version
|
|
21
|
+
setClientIdentity({ surface: "cli", version: CLI_VERSION })
|
|
22
|
+
|
|
18
23
|
/** 命令分发(原 `bin/thincoder.mjs` 顶层 switch 骨架逐字搬移——命令行为零改)。 */
|
|
19
24
|
export async function runCommandTable(command, args, ctx) {
|
|
20
25
|
const { usage, version, exitSoon } = ctx
|
package/src/tui/agent-turn.mjs
CHANGED
|
@@ -238,8 +238,14 @@ async function runAgentTurnBody(ctx, text, opts) {
|
|
|
238
238
|
break
|
|
239
239
|
}
|
|
240
240
|
if (decision === "ask") {
|
|
241
|
+
// TURN-CAP-CONTINUE.md §6.1 ∕ §6.4(D-TC10):撞帽提示给两个数——
|
|
242
|
+
// seg = 本段轮数(`ContinueError.turn`,撞帽点 ≡ 本段预算)、total = 链内累计(`_turnSeq` 计数器本身)。
|
|
243
|
+
// 直读 `agent._turnSeq`,不加 `?? 0`:缺值印 0 会把「未跟踪」读作「零消耗」(§6.1)。
|
|
244
|
+
// 上限不印(§6.2):撞帽点本段上限 ≡ 本段轮数、累计上限 ≡ 累计轮数,印出来只有重复。
|
|
245
|
+
const seg = error.turn
|
|
246
|
+
const total = agent._turnSeq
|
|
241
247
|
pushLabel(`❯ Continue`, ansi.bold + C.warn)
|
|
242
|
-
pushLine(`Ran ${
|
|
248
|
+
pushLine(`Ran ${seg} turns — ${total} turns total. Continue?`, C.warn)
|
|
243
249
|
// Pause to ask: reuse permission mechanism
|
|
244
250
|
const willContinue = await new Promise((resolve) => {
|
|
245
251
|
state.permission = {
|
|
@@ -247,7 +253,7 @@ async function runAgentTurnBody(ctx, text, opts) {
|
|
|
247
253
|
args: { turns: error.turn },
|
|
248
254
|
resolve,
|
|
249
255
|
}
|
|
250
|
-
state.status = `Continue after ${
|
|
256
|
+
state.status = `Continue after ${seg} turns (${total} total)?`
|
|
251
257
|
render()
|
|
252
258
|
})
|
|
253
259
|
state.permission = null
|
package/src/tui/cmd-eng.mjs
CHANGED
|
@@ -42,7 +42,7 @@ export async function handleEngCommand(ctx) {
|
|
|
42
42
|
// (模式未翻 / token 未清 / `_advisorRuns` 未重置 / 提醒未入列 / 槽未写)。
|
|
43
43
|
// 准 ⇒ 缺档格就地建档(writer:'main')+ `agent.manifest` ← 结果(相位行当回合起活)。
|
|
44
44
|
if (!agent.config.agent.engineering) {
|
|
45
|
-
const r = resolveEngineeringManifest(agent.cwd
|
|
45
|
+
const r = resolveEngineeringManifest(agent.cwd, { writer: "main" })
|
|
46
46
|
if (!r.ok && r.code !== "workspace") {
|
|
47
47
|
pushLine(`Engineering mode not enabled — ${r.message} (mode unchanged)`, C.warn)
|
|
48
48
|
return
|
package/src/tui/cmd-mcp.mjs
CHANGED
|
@@ -187,7 +187,7 @@ Return ONLY the JSON object:`,
|
|
|
187
187
|
logCtx: {
|
|
188
188
|
stage: "mcp", kind: "mcp",
|
|
189
189
|
role: agent?._role ?? null,
|
|
190
|
-
session: agent?._sessionStart ?? null, cwd: agent?.cwd
|
|
190
|
+
session: agent?._sessionStart ?? null, cwd: agent?.cwd,
|
|
191
191
|
traces: agent?.config?.traces?.enabled !== false,
|
|
192
192
|
},
|
|
193
193
|
})
|
|
@@ -140,7 +140,18 @@ export function digestTraceLines(rec, startN = null) {
|
|
|
140
140
|
export function synthSubTask(rec) {
|
|
141
141
|
const meta = rec?.meta ?? {}
|
|
142
142
|
const rows = Array.isArray(rec?.rows) ? rec.rows : []
|
|
143
|
-
|
|
143
|
+
// 行首子标(跨端恢复——承接细则 = `docs/cli/design/TUI-SESSION-VIEW.md` §6「行首子标」条):
|
|
144
|
+
// 条目带 `sub` ⇒ 行文 = `<sub> · <正文>`(与 VSC ∥ 桌面 `span.advisor-sub` 同一串:同字面 ∥ 同位置 ∥ 同分隔符);
|
|
145
|
+
// 不带 ⇒ 原样(存量记录的子标烙在 `text` 内,逐字不变)。子标在此合成——本端渲染面逐字消费 `b.text`,零改。
|
|
146
|
+
// 空正文行 = 两端同判丢弃:跳过判据 = `text` 为空,与 `sub` 在场无关(与 VSC 派生面 `rowsOf` 同一谓词)。
|
|
147
|
+
const blocks = []
|
|
148
|
+
for (const r of rows) {
|
|
149
|
+
const text = String(r?.text ?? "")
|
|
150
|
+
if (text === "") continue
|
|
151
|
+
const kind = typeof r?.kind === "string" ? r.kind : "text"
|
|
152
|
+
const sub = typeof r?.sub === "string" && r.sub ? r.sub : null
|
|
153
|
+
blocks.push({ kind, text: sub === null ? text : `${sub} · ${text}` })
|
|
154
|
+
}
|
|
144
155
|
const doneAt = Number.isFinite(meta.doneAt) ? meta.doneAt : null
|
|
145
156
|
const started = Number.isFinite(meta.startedAt) ? meta.startedAt : (doneAt ?? 0)
|
|
146
157
|
return {
|
package/src/tui/render-loop.mjs
CHANGED
|
@@ -14,12 +14,34 @@
|
|
|
14
14
|
* so recomputing the frame each paint is cheap.
|
|
15
15
|
*/
|
|
16
16
|
import { countConvLines, renderRows } from "./render-frame.mjs"
|
|
17
|
-
import {
|
|
17
|
+
import { historyReading, tokenRatioOf } from "@thincoder/core/token-window.mjs"
|
|
18
|
+
import { providerSpec } from "@thincoder/core/config.mjs"
|
|
18
19
|
import { ansi, C } from "./ansi.mjs"
|
|
19
20
|
import { isTuiActive } from "./tui-lifecycle.mjs" // F-2 渲染抑制守卫(RESIZE-MOUSE-LEAK-FIX)
|
|
20
21
|
|
|
21
22
|
const MIN_RENDER_INTERVAL_MS = 16
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* 上下文读数缓存(CONTEXT-COMPACTION.md §6.16.4 单源):值全部来自核 `historyReading`,本档零自算式。
|
|
26
|
+
* 失效键三项 = `history.length` · `ratio` · 解析后的窗口——只按长度会留陈旧读数:校准比可在长度不变时变
|
|
27
|
+
* (槽样本恢复 / 口径版本切换),窗口可在切模型 ∥ 改人工声明时变。三项全等 ⇒ **原引用**(零重算);
|
|
28
|
+
* 否则重取核读数。为何不每帧调核:`estimateTokens` 是全史线性扫描,每帧跑一次是渲染热路径的净开销。
|
|
29
|
+
* **三项覆盖不到的一类变化(登记)**:内容变而长度不变——`pruneStaleToolOutputs` 原位换掉 tool 内容
|
|
30
|
+
* (`thincoder-core/context-degrade.mjs:30`-35:数组长度不变、估算骤降)与 `applySession` 整体换机读线
|
|
31
|
+
* (`thincoder-core/session-lifecycle.mjs:119`:长度可与前一会话巧合相等)。这两时刻状态行沿用变化前的
|
|
32
|
+
* 百分比,直到下一次追回消息使 `len` 变;闭这项需要第四个内容版本键(机制变更,不自取)。
|
|
33
|
+
* 首帧:`state.ctxCache` 初值 `{ len: -1, tokens: 0 }`(`tui-state.mjs`)长度恒不等 ⇒ 必落重算支,
|
|
34
|
+
* 由此补齐 `ratio` / `window` / `pct`;未补齐前 `pct` = `undefined` ⇒ 状态行显示门(`ctxPct > 0`)为假,该段不显。
|
|
35
|
+
*/
|
|
36
|
+
export function ctxCacheOf(agent, prev) {
|
|
37
|
+
const history = agent?.history ?? []
|
|
38
|
+
const ratio = tokenRatioOf(agent)
|
|
39
|
+
const window = providerSpec(agent?.provider).context
|
|
40
|
+
if (prev && prev.len === history.length && prev.ratio === ratio && prev.window === window) return prev
|
|
41
|
+
const { tokens, pct } = historyReading(history, agent?.provider, ratio)
|
|
42
|
+
return { len: history.length, ratio, window, tokens, pct }
|
|
43
|
+
}
|
|
44
|
+
|
|
23
45
|
/**
|
|
24
46
|
* Create the render loop closure. Returns { render, scheduleRender }.
|
|
25
47
|
*
|
|
@@ -86,9 +108,7 @@ export function createRenderLoop(state, agent, ctx, pushLine, write = (s) => pro
|
|
|
86
108
|
// Clamp scroll (bookkeeping for the status-bar hint; renderConversation clamps internally too)
|
|
87
109
|
state.scroll = Math.min(state.scroll, Math.max(0, countConvLines(state, dims.cols, dims.rows) - layout.panels.conversation.h))
|
|
88
110
|
|
|
89
|
-
|
|
90
|
-
state.ctxCache = { len: agent.history.length, tokens: estimateTokens(agent.history) }
|
|
91
|
-
}
|
|
111
|
+
state.ctxCache = ctxCacheOf(agent, state.ctxCache)
|
|
92
112
|
|
|
93
113
|
// Deferred upgrade notice — pop when no overlay is active
|
|
94
114
|
if (ctx.pendingNoticeReady(state)) {
|
package/src/tui/status-line.mjs
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { ansi, C } from "./ansi.mjs"
|
|
12
12
|
import { sliceByWidth, stringWidth } from "./render.mjs"
|
|
13
|
-
import { providerSpec } from "@thincoder/core/config.mjs"
|
|
14
13
|
import { t } from "@thincoder/core/i18n.mjs" // 停滞轻显形(TUI.md §7.7):句式键 status.quiet——词面单源(CLI 直取)
|
|
15
14
|
import { isRealUserMsg } from "@thincoder/core/history-window.mjs" // B6 回退链:首条真实 user 消息谓词(纯件单源)
|
|
16
15
|
import { isYesNoModal } from "./interaction.mjs" // X8 跟进①:y/n-only 族判据单源
|
|
@@ -141,10 +140,10 @@ function buildStatusLine(state, agent, { cols, slashCommands }) {
|
|
|
141
140
|
? ` ${t("status.quiet", { s: Math.floor((Date.now() - lastOut) / 1000) })}`
|
|
142
141
|
: ""
|
|
143
142
|
const statusText = state.processing ? `${state.status}${toolHint}${elapsed}${quietHint}` : state.status
|
|
144
|
-
// 2026-09-02 Q1(SESSION.md §6.8):provider 可为 null —— providerSpec(null) 保守 128K
|
|
145
|
-
// 2026-09-02 §15
|
|
146
|
-
|
|
147
|
-
const ctxPct =
|
|
143
|
+
// 2026-09-02 Q1(SESSION.md §6.8):provider 可为 null —— 核 `providerSpec(null)` 保守 128K 不抛错。
|
|
144
|
+
// 2026-09-02 §15 ∥ context-percent-parity:窗口 / 校准比 / 两值全在核 `historyReading` 内解析(`ctxCacheOf` 缓出)——
|
|
145
|
+
// 本段零自算式,只格式化核读数的两个返回值;零值不显示门 `ctxPct > 0` 留在端侧(空历史口径已登记)。
|
|
146
|
+
const ctxPct = state.ctxCache.pct
|
|
148
147
|
const ctxTokensHint = state.ctxCache.tokens > 0 ? ` ${fmtK(state.ctxCache.tokens)}` : ""
|
|
149
148
|
const ctxHint = ctxPct > 0
|
|
150
149
|
? ctxPct >= 80 ? ` │ ${ansi.reset}${C.warn}context ${ctxPct}%${ctxTokensHint}${ansi.reset}${ansi.dim}` : ` │ context ${ctxPct}%${ctxTokensHint}` : ""
|
package/src/tui/tui-state.mjs
CHANGED
|
@@ -36,7 +36,7 @@ export function createTuiState({ cols, rows, agent }) {
|
|
|
36
36
|
tasks: agent.tasks ?? [], // task list from task tool (progress shown in status bar); carried over on session restore, auto-collapsed when all done
|
|
37
37
|
dims: makeDimsState({ cols: startupCols, rows: startupRows }), // terminal dims single source (Windows ConPTY instability, 2026-08-30) — seeded pre-raw-mode, re-sampled by event hooks only (startup retry / resize / idle watchdog)
|
|
38
38
|
tokens: { prompt: 0, completion: 0, cacheHit: 0, cacheMiss: 0, reasoningTokens: 0 }, // cumulative token usage (shown in status bar)
|
|
39
|
-
ctxCache: { len: -1, tokens: 0 }, // context
|
|
39
|
+
ctxCache: { len: -1, tokens: 0 }, // context reading cache (core `historyReading`; estimateTokens is O(n)). Invalidation keys = len · ratio · window (`ctxCacheOf`, render-loop.mjs); `len: -1` never matches ⇒ the first frame fills ratio / window / pct
|
|
40
40
|
reasoning: "", // thinking stream buffer (dimmed display)
|
|
41
41
|
completion: null, // Tab completion state { candidates, index }
|
|
42
42
|
|