@andares/pi-toolkits 1.0.0 → 1.0.2

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +26 -25
  3. package/README.zh-CN.md +28 -27
  4. package/package.json +8 -7
  5. package/src/features/ask/index.test.ts +2 -2
  6. package/src/features/ask/index.ts +1 -1
  7. package/src/features/autostart/autostart.ts +1 -1
  8. package/src/features/autostart/index.ts +3 -2
  9. package/src/features/compact/index.ts +1 -1
  10. package/src/features/compact/prompt.ts +3 -3
  11. package/src/features/favorites/patch-selector.ts +5 -1
  12. package/src/features/init/index.test.ts +2 -2
  13. package/src/features/init/templates/workflow-block.md +2 -2
  14. package/src/features/permission/index.ts +1 -1
  15. package/src/features/permission/panel.ts +3 -1
  16. package/src/features/quit-guard/index.ts +4 -3
  17. package/src/features/review/index.ts +3 -3
  18. package/src/features/review/review.test.ts +2 -2
  19. package/src/features/spec/assets/index-CdTerMvN.css +1 -0
  20. package/src/features/spec/assets/index-Dv52AIjX.js +1 -0
  21. package/src/features/{plan → spec}/assets/index.html +3 -3
  22. package/src/features/{plan → spec}/assets.test.ts +5 -5
  23. package/src/features/{plan → spec}/blocks.ts +1 -1
  24. package/src/features/{plan → spec}/feedback.test.ts +26 -26
  25. package/src/features/{plan → spec}/feedback.ts +14 -14
  26. package/src/features/{plan → spec}/index.test.ts +100 -66
  27. package/src/features/{plan → spec}/index.ts +117 -106
  28. package/src/features/{plan → spec}/prompt.test.ts +20 -20
  29. package/src/features/{plan → spec}/prompt.ts +25 -25
  30. package/src/features/{plan → spec}/render.test.ts +2 -2
  31. package/src/features/{plan → spec}/server.test.ts +21 -21
  32. package/src/features/{plan → spec}/server.ts +22 -22
  33. package/src/features/{plan → spec}/store.test.ts +77 -35
  34. package/src/features/{plan → spec}/store.ts +80 -52
  35. package/src/features/uat/index.test.ts +5 -5
  36. package/src/features/uat/index.ts +8 -8
  37. package/src/features/uat/record-tool.ts +3 -3
  38. package/src/features/uat/records.test.ts +5 -5
  39. package/src/index.ts +6 -6
  40. package/src/lib/ask-control.ts +2 -2
  41. package/src/lib/permission-control.ts +4 -4
  42. package/src/lib/phases.ts +20 -7
  43. package/src/lib/web-review.ts +1 -1
  44. package/src/features/plan/assets/index-C1YLIi4I.js +0 -1
  45. package/src/features/plan/assets/index-DMEpYC3V.css +0 -1
  46. /package/src/features/{plan → spec}/blocks.test.ts +0 -0
  47. /package/src/features/{plan → spec}/diff.test.ts +0 -0
  48. /package/src/features/{plan → spec}/diff.ts +0 -0
  49. /package/src/features/{plan → spec}/render.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -11,6 +11,21 @@ renames that heading to the version being published and refuses an empty section
11
11
 
12
12
  <!-- Notes for the next release go here; `pnpm release` renames this heading. -->
13
13
 
14
+ ## 1.0.2 — 2026-11-24
15
+
16
+ <!-- Notes for the next release go here; `pnpm release` renames this heading. -->
17
+
18
+ - **host compatibility** — verified against every published pi release from 0.99.0 through 1.6.0 (window 1.3–1.6); the declared range stays `pi >= 0.99.0` with no upper bound, and the package loads cleanly on 1.6.0.
19
+
20
+ ## 1.0.1 — 2026-11-17
21
+
22
+ - **ask-spec** — the browser review command is now `/ask-spec` (`/ask-plan` still works as an alias), the submit tool is `spec_submit`, and an untitled review defaults to `specs/spec.md` instead of `specs/plan.md`.
23
+ - **spec review page** — a new two-column page: warm paper/rose palette, the spec on the left, revision stats and a clickable annotation index on the right; global notes stay visible above the blocks.
24
+ - **spec review page** — the decision bar now carries *Only changed* and *Global notes* on the left and the total note count in the middle, with the explanatory footer text removed.
25
+ - **ask-spec** — existing `<agent-dir>/ask-plan/` review histories are migrated to `<agent-dir>/ask-spec/` on first use.
26
+
27
+ <!-- Notes for the next release go here; `pnpm release` renames this heading. -->
28
+
14
29
  ## 1.0.0 — 2026-11-15
15
30
 
16
31
  - **quit-guard** — a forced exit can no longer be defeated by a deadlock inside `process.exit` itself: after the report is written, a same-loop SIGKILL timer and then an independent worker thread guarantee the process ends (real hang observed 2026-11-13, process stuck 18 min with the pty already deleted).
@@ -54,3 +69,5 @@ renames that heading to the version being published and refuses an empty section
54
69
  - permission — a capped rolling JSONL approval log records each ask, its parsed units and your answer; `pnpm approval-report` turns it into rule candidates.
55
70
 
56
71
 
72
+
73
+
package/README.md CHANGED
@@ -13,9 +13,9 @@
13
13
  [![pi >= 0.99](https://img.shields.io/badge/pi-%3E%3D0.99.0-blueviolet)](https://github.com/earendil-works/pi)
14
14
  [![GitHub](https://img.shields.io/badge/github-andares%2Fpi--toolkits-181717?logo=github)](https://github.com/andares/pi-toolkits)
15
15
 
16
- In a nutshell: twelve ready-to-use capabilities — **read-only consult mode** `ask`, **session-scoped boundary permission** `ask-perm`, **model favorites** `favorites`, **prompt stash** `stash`, **third-party code review** `ask-review`, **dedicated compaction model** `compact-model`, **session startup automation** `autostart`, an **agent memory framework** `ask-init`, a **plan review in the browser** `ask-plan`, an **acceptance ledger with a browser page** `ask-uat`, a **quit watchdog** `quit-guard`, and **release notes on the first start after an upgrade** `whats-new` — with more to come.
16
+ In a nutshell: twelve ready-to-use capabilities — **read-only consult mode** `ask`, **session-scoped boundary permission** `ask-perm`, **model favorites** `favorites`, **prompt stash** `stash`, **third-party code review** `ask-review`, **dedicated compaction model** `compact-model`, **session startup automation** `autostart`, an **agent memory framework** `ask-init`, a **spec review in the browser** `ask-spec`, an **acceptance ledger with a browser page** `ask-uat`, a **quit watchdog** `quit-guard`, and **release notes on the first start after an upgrade** `whats-new` — with more to come.
17
17
 
18
- **Requirements**: pi `>=0.99.0`. Every published pi release from 0.99.0 through 1.5.2 has been verified with the full gate (install → `tsc --noEmit` → full test suite → keybinding audit → hash compare of the host files this package patches), each in a sandbox with the whole `@earendil-works/*` family pinned to the version under test. Newer releases are verified as they ship and the floor moves only when the measurement says so; `pnpm check:compat` reproduces the result. Note: pi ≥ 0.99 hosts require host-provided packages to be declared in `peerDependencies` with a `"*"` range — `@earendil-works/pi-tui` and `typebox` (the `scratchpad` tool builds a TypeBox schema) are declared that way; an installed copy in `dependencies` would make pi warn.
18
+ **Requirements**: pi `>=0.99.0`. Every published pi release from 0.99.0 through 1.6.0 has been verified with the full gate (install → `tsc --noEmit` → full test suite → keybinding audit → hash compare of the host files this package patches), each in a sandbox with the whole `@earendil-works/*` family pinned to the version under test. Newer releases are verified as they ship and the floor moves only when the measurement says so; `pnpm check:compat` reproduces the result. Note: pi ≥ 0.99 hosts require host-provided packages to be declared in `peerDependencies` with a `"*"` range — `@earendil-works/pi-tui` and `typebox` (the `scratchpad` tool builds a TypeBox schema) are declared that way; an installed copy in `dependencies` would make pi warn.
19
19
 
20
20
  ---
21
21
 
@@ -76,7 +76,7 @@ After installing, verify in any pi session:
76
76
  | ⭐ **favorites** model favorites | `ctrl+A` / `ctrl+J` inside `/model` | favorite the models you use most (marked in bold bright yellow), `ctrl+p` cycles only among favorites |
77
77
  | 📥 **stash** prompt stash | `ctrl+alt+y` | a stash slot for one prompt: press to swap, press twice to stash and clear the input box |
78
78
  | 🔎 **review** third-party code review | `/ask-review` | summon the configured review model to check + fix the task just finished, focusing on "is this round's requirement implemented / is anything missing / is anything wrong" |
79
- | 🧭 **plan** browser-reviewed planning | `/ask-plan` | research first, write a spec, review it in your browser paragraph by paragraph, annotate block by block, then implement only after approval |
79
+ | 🧭 **spec** browser-reviewed specs | `/ask-spec` | research first, write a spec, review it in your browser paragraph by paragraph, annotate block by block, then implement only after approval |
80
80
  | ✅ **uat** acceptance ledger | `/ask-uat` | after `/ask-init`: cluster pending change records into user-facing acceptance items, tick them off on a page (append-only ledger, no submit), and see what shipped without being verified |
81
81
  | 🗜️ **compact** dedicated compaction model | `/compact-model` | give `/compact` and auto-compact a cheap fast model to summarize with, leaving the main model free to focus on the conversation; zero overhead when unconfigured, falls back to pi's default on any failure |
82
82
  | 🚀 **autostart** session startup automation | `.pi/autostart.toml` | declare slash commands to run automatically at session start, per project (first use case: mounting multi-repo directories with `/add-dir`); never runs in untrusted directories, unregistered commands are skipped instead of being sent to the model |
@@ -92,7 +92,7 @@ After installing, verify in any pi session:
92
92
 
93
93
  Enter with `/ask` (press it again to exit). Meant for the case where you only want to "ask questions and read code": the model may not change the project, but it is not starved of a place to think.
94
94
 
95
- Ask is standalone (no `/ask-init` needed). If a plan review or the UAT page is active, leave it first — ask refuses to start on top of another phase rather than promise a read-only surface another feature will re-open.
95
+ Ask is standalone (no `/ask-init` needed). If a spec review or the UAT page is active, leave it first — ask refuses to start on top of another phase rather than promise a read-only surface another feature will re-open.
96
96
 
97
97
  **While active**:
98
98
 
@@ -281,35 +281,36 @@ After a development task is done, type the `/ask-review` command to summon **a d
281
281
 
282
282
  - **Unconfigured / the configured model is no longer available** (e.g. it was deleted from pi's models.json) → a notice is shown and the list opens as usual (with no default entry in that case)
283
283
  - Triggered while a task is still in progress (the agent is not idle) → you are told to wait and nothing runs; only one review may be active at a time
284
- - Planning phase → refused (a plan under review must not be edited); ask mode is exited automatically because check + fix needs the full tool set
284
+ - Spec-review phase → refused (a spec under review must not be edited); ask mode is exited automatically because check + fix needs the full tool set
285
285
  - A grey `review` status in the footer means a review model is configured
286
286
 
287
287
  ---
288
288
 
289
- ## 🧭 plan — plan first, review in the browser, then implement
289
+ ## 🧭 spec — write it, review it in the browser, then implement
290
290
 
291
- <a name="plan"></a>
291
+ <a name="spec"></a>
292
292
 
293
- `/ask-plan [topic]` opens a planning phase: the agent explores the code, asks what it cannot infer, and writes a spec — no code changes while the plan is under review. Then it calls `plan_submit`, the review opens in **your browser**, and you annotate it **paragraph by paragraph**: every blank-line-separated block can carry notes, and every note comes back to the agent as its next message.
293
+ `/ask-spec [topic]` opens a spec-review phase: the agent explores the code, asks what it cannot infer, and writes a spec — no code changes while the spec is under review. Then it calls `spec_submit`, the review opens in **your browser**, and you annotate it **paragraph by paragraph**: every blank-line-separated block can carry notes, and every note comes back to the agent as its next message. `/ask-plan` is kept as an alias.
294
294
 
295
295
  - **Blocks are the unit of review.** Each paragraph is one block, with a badge telling you what changed since the previous round: `new`, `modified`, `moved`, `removed`. Unchanged blocks collapse, so a three-line edit does not look like a rewrite. Fenced code blocks stay whole.
296
296
  - **Two levels of notes.** On a block, or global. Nothing finer — no text ranges to re-anchor after an edit.
297
- - **Approve and deny both carry your notes.** They only choose the next step: approve means "start implementing" (with every note applied on the way), deny means "revise the plan and submit again".
298
- - **History is kept.** Every submitted revision is stored under `<agent-dir>/ask-plan/<slug>/` and the header lets you reopen any of them read-only.
299
- - **The planning phase uses the boundary checks.** `/ask-perm` is switched on with its defaults when planning starts and restored when it ends; the only file the plan phase may write is markdown.
300
- - **No model switching, ever.** The plan is reviewed and implemented with whatever model the session is on. (`/ask-review` is the one command that does switch, because you asked it to.)
297
+ - **The page keeps the review in view.** A two-column layout: the spec on the left; the revision stats and a clickable annotation index on the right. Global notes stay visible above the blocks even when the editor is closed.
298
+ - **Approve and deny both carry your notes.** They only choose the next step: approve means "start implementing" (with every note applied on the way), deny means "revise the spec and submit again".
299
+ - **History is kept.** Every submitted revision is stored under `<agent-dir>/ask-spec/<slug>/` and the header lets you reopen any of them read-only. Existing `<agent-dir>/ask-plan/` histories are migrated on first use.
300
+ - **The review phase uses the boundary checks.** `/ask-perm` is switched on with its defaults when the review starts and restored when it ends; the only file the review phase may write is markdown.
301
+ - **No model switching, ever.** The spec is reviewed and implemented with whatever model the session is on. (`/ask-review` is the one command that does switch, because you asked it to.)
301
302
 
302
303
  **Browser on WSL**: the review server binds `0.0.0.0` and the URL is printed with the WSL address, because Windows cannot reach a loopback-only server inside WSL. The opener prefers a Windows-side launcher (`wslview`, `cmd.exe /c start`, `powershell Start-Process`) and only falls back to `xdg-open` elsewhere — that is the difference between "opens your browser" and "opens a browser inside WSL that you cannot see".
303
304
 
304
305
  ```text
305
- /ask-plan build the export feature # start planning
306
- /ask-plan open # re-open the review page
307
- /ask-plan off # leave the phase (the draft stays where it is)
306
+ /ask-spec build the export feature # start the review
307
+ /ask-spec open # re-open the review page
308
+ /ask-spec off # leave the phase (the draft stays where it is)
308
309
  ```
309
310
 
310
- The spec lands in `specs/<slug>.md` — the same place `/ask-init` puts plans. Without an
311
- agent framework the plan still works, but `record_change` and `/ask-uat` stay unavailable
312
- until `/ask-init`; the command says so when planning starts. Leave an open UAT page first:
311
+ The spec lands in `specs/<slug>.md` — the same place `/ask-init` keeps specs. Without an
312
+ agent framework the review still works, but `record_change` and `/ask-uat` stay unavailable
313
+ until `/ask-init`; the command says so when the review starts. Leave an open UAT page first:
313
314
  the two phases do not run on top of each other.
314
315
 
315
316
  ---
@@ -386,7 +387,7 @@ pi's `/compact` and auto-compact summarize the context **with the current sessio
386
387
  | auto-compact threshold reached | summarized by the compaction model |
387
388
  | context overflow recovery | summarized by the compaction model, retry behavior unchanged |
388
389
 
389
- **Parts that are identical to pi's built-in behavior after takeover** (the built-in implementation is mirrored verbatim — copied from 0.87.1, byte-identical across 1.2.0 → 1.5.2 apart from the two 1.4.0 fixes adopted here: summaries request the model's output limit instead of a fixed fraction of `reserveTokens`, and `/compact <instructions>` also reaches the split-turn prefix, plus the 1.5.0 `cost.totalFromProvider` merge rule in the usage accounting — and only the executing model changes; the conversation serializer itself is imported from the host, so it follows whatever the running host does, e.g. 1.2.0 stops feeding assistant thinking back into the summarization request):
390
+ **Parts that are identical to pi's built-in behavior after takeover** (the built-in implementation is mirrored verbatim — copied from 0.87.1, byte-identical across 1.2.0 → 1.6.0 apart from the two 1.4.0 fixes adopted here: summaries request the model's output limit instead of a fixed fraction of `reserveTokens`, and `/compact <instructions>` also reaches the split-turn prefix, plus the 1.5.0 `cost.totalFromProvider` merge rule in the usage accounting — and only the executing model changes; the conversation serializer itself is imported from the host, so it follows whatever the running host does, e.g. 1.2.0 stops feeding assistant thinking back into the summarization request):
390
391
 
391
392
  - **Summary format** — the structured Goal / Progress / Key Decisions checkpoint; when a summary already exists, the iterative-update prompt is used so information carries over instead of being lost
392
393
  - **Split behavior** — the `keepRecentTokens` retention policy, and `firstKeptEntryId` / `tokensBefore` passed back unchanged
@@ -467,7 +468,7 @@ An **identical command line** declared by both sources runs once: a duplicate is
467
468
 
468
469
  **Key constraint: extension commands only**. Commands registered via `registerCommand` such as `/add-dir` (pi-add-dir) and `/cd` (pi-cd) work; built-in commands (`/compact`, `/reload`, `/resume`, …) are dispatched in the TUI layer and cannot be triggered from the extension layer; skill commands (`/skill:name`) are an expansion mechanism rather than an execution mechanism. The target extension you depend on (e.g. pi-add-dir) must be installed first.
469
470
 
470
- > **Implementation notes**: execution uses `sendUserMessage(cmd, { expandPromptTemplates: true })` — that option routes `/cmd args` into command dispatch instead of the model prompt path (the wrapper defaults to `false`; `_tryExecuteExtensionCommand` is byte-identical across 1.2.0–1.5.2, and although 1.5.1 moved the rest of `sendUserMessage` into `_preparePrompt`, the extension-command branch is still its first early exit — see the host-compatibility discipline in AGENTS.md). Pre-validation uses `pi.getCommands()` (accepting only `source: "extension"`). Depends on `smol-toml` (zero-dependency, ~10KB, TOML 1.0).
471
+ > **Implementation notes**: execution uses `sendUserMessage(cmd, { expandPromptTemplates: true })` — that option routes `/cmd args` into command dispatch instead of the model prompt path (the wrapper defaults to `false`; `_tryExecuteExtensionCommand` is byte-identical across 1.2.0–1.6.0, and although 1.5.1 moved the rest of `sendUserMessage` into `_preparePrompt`, the extension-command branch is still its first early exit — see the host-compatibility discipline in AGENTS.md). Pre-validation uses `pi.getCommands()` (accepting only `source: "extension"`). Depends on `smol-toml` (zero-dependency, ~10KB, TOML 1.0).
471
472
 
472
473
  ---
473
474
 
@@ -481,7 +482,7 @@ the split between three things that decay when mixed:
481
482
 
482
483
  | Family | Location | Answers | Lifetime |
483
484
  | --- | --- | --- | --- |
484
- | **plan** | `specs/` (`PLAN.md` + `<unit>.md`) | what to do, how it will be accepted | written before work, status updated at close |
485
+ | **spec** | `specs/` (roadmap `PLAN.md` + `<unit>.md`) | what to do, how it will be accepted | written before work, status updated at close |
485
486
  | **memory** | `.agents/memory/` | what is known, decided, and why | long-lived; append and compact only |
486
487
  | **evidence** | `.agents/implementations/` | what changed, when, with what proof | one record per change, never rewritten |
487
488
 
@@ -512,7 +513,7 @@ turn; the audit still writes its runtime report. After a package upgrade run `/a
512
513
  `AGENTS.md`, `.agents/memory/README.md` and `.agents/implementations/` exist. The
513
514
  content is yours — small edits do not stop `/ask-uat` or `record_change`. Commands
514
515
  that need the framework refuse with the missing list instead of guessing.
515
- Mutating runs (including `refresh` and `roots`) refuse while `/ask`, a plan review
516
+ Mutating runs (including `refresh` and `roots`) refuse while `/ask`, a spec review
516
517
  or the UAT page is active; `check` and `plan` stay available.
517
518
 
518
519
  A project written by an older tool has no template anchor. `/ask-init` reports those
@@ -717,7 +718,7 @@ pnpm typecheck # tsc --noEmit
717
718
  pnpm test # vitest (all feature unit tests)
718
719
 
719
720
  pnpm check:keybindings # audit this plugin's keys against the host's own dispatch table
720
- pnpm check:compat # mandatory 4-line window + backward probe (4 more lines) → public floor
721
+ pnpm check:compat # re-measure the declared pi range against real hosts (fails if it drifted)
721
722
  pnpm approval-report # summarize the local approval log (answer mix, targets, rule candidates)
722
723
  ```
723
724
 
@@ -748,7 +749,7 @@ src/
748
749
  ├── permission/ # session-scoped boundary permission: modes, panel,
749
750
  │ # bash units, policy, session grants, prompt,
750
751
  │ # audit payload, tests
751
- ├── plan/ # browser-reviewed planning: phases, block diff,
752
+ ├── spec/ # browser-reviewed specs: phases, block diff,
752
753
  │ # review server, UI, tests
753
754
  ├── quit-guard/ # quit watchdog: TUI teardown + quit-event triggers,
754
755
  │ # settings store, hang report, tests
@@ -795,7 +796,7 @@ PRs and issues welcome. A few conventions:
795
796
  - **Built-in patches** (favorites) must stay **version-guarded and idempotent** — verify the target prototype members exist before patching, guard against double-apply, degrade with a `console.warn` instead of breaking the extension
796
797
  - **Built-in prompt sync** (compact) — the summarization prompts in `src/features/compact/prompt.ts` are copied verbatim from pi's built-in compaction; when upgrading the pi dependency, diff `dist/core/compaction/compaction.js` (and `utils.js`) and update the strings + assembly helpers to match, keeping takeover output byte-compatible with stock
797
798
  - **Keybindings** — before picking a new shortcut, check pi defaults + reserved keys, terminal control chars, and OS/terminal-emulator grabs; prefer `ctrl+alt+<letter>` for cross-platform safety. Do not stop at "it works on my machine in the main screen": in `fullscreen` mode (pi's default since 1.0) the alt-screen layer consumes `tui.altScreen.*` **before** dialogs see the key, and on Windows/WSL several of those bindings differ from the Linux defaults. Run `pnpm check:keybindings [candidate...]` (and `pnpm check:keybindings --all` after a pi upgrade) — it probes the installed host's resolved keybinding table with the host's own `matchesKey`. A key free in the host table can still be taken at the machine layer: Windows Terminal binds `ctrl+v` (paste) and `ctrl+shift+f` (find), and third-party Windows tools commonly grab `ctrl+alt+<letter>` (a screenshot tool once took `ctrl+alt+f`) — so try the key for real on the target machine before shipping it.
798
- - **Host compatibility** — the peer range is a measured statement, not a wish, and it only points backwards: the four most recently released pi minor lines are a mandatory window (fix our code, never raise the floor), below it we probe up to four older lines to find where compatibility actually ends, and the single number users see is the resulting floor (`pi >= <floor>`, no upper bound). Re-run `pnpm check:compat` whenever the host dependency moves and read its verdict block (it fails if the declared floor drifts from the measured one). See the pi 宿主兼容 section of AGENTS.md; keybinding collisions found during an upgrade are reported to the maintainer for a decision, never re-keyed silently.
799
+ - **Host compatibility** — the peer range is a measured statement, not a wish: `pi >= <floor>` with no upper bound, where the floor is the oldest release that still passes the full gate and every published version from the floor up to the newest verified one has been tested. Move the host dependency only together with a green `pnpm check:compat` run — it re-measures the declared range against real hosts and fails if the declared floor drifts from the measured one. See the pi 宿主兼容 section of AGENTS.md; keybinding collisions found during an upgrade are reported to the maintainer for a decision, never re-keyed silently.
799
800
  - **Quality gate** — `pnpm typecheck && pnpm test` must pass before submitting
800
801
 
801
802
  ---
package/README.zh-CN.md CHANGED
@@ -13,9 +13,9 @@
13
13
  [![pi >= 0.99](https://img.shields.io/badge/pi-%3E%3D0.99.0-blueviolet)](https://github.com/earendil-works/pi)
14
14
  [![GitHub](https://img.shields.io/badge/github-andares%2Fpi--toolkits-181717?logo=github)](https://github.com/andares/pi-toolkits)
15
15
 
16
- 一句话介绍:目前包含十二个开箱即用的功能——**只读咨询模式** `ask`、**会话级边界权限** `ask-perm`、**模型收藏** `favorites`、**提示词暂存** `stash`、**第三方代码评审** `ask-review`、**独立压缩模型** `compact-model`、**会话启动自动化** `autostart`、**agent 记忆框架** `ask-init`、**浏览器内计划评审** `ask-plan`、**验收台账与浏览器页面** `ask-uat`、**退出看门狗** `quit-guard`、**升级后首次启动的版本变更提示** `whats-new`,后续持续追加。
16
+ 一句话介绍:目前包含十二个开箱即用的功能——**只读咨询模式** `ask`、**会话级边界权限** `ask-perm`、**模型收藏** `favorites`、**提示词暂存** `stash`、**第三方代码评审** `ask-review`、**独立压缩模型** `compact-model`、**会话启动自动化** `autostart`、**agent 记忆框架** `ask-init`、**浏览器内规格评审** `ask-spec`、**验收台账与浏览器页面** `ask-uat`、**退出看门狗** `quit-guard`、**升级后首次启动的版本变更提示** `whats-new`,后续持续追加。
17
17
 
18
- **版本要求**:pi `>=0.99.0`。0.99.0 到 1.5.2 的每一个已发布版本都用完整门禁实测过(install → `tsc --noEmit` → 全量测试 → 键位审计 → 对 patch 目标宿主文件做哈希比对),每个版本都在沙箱中把整个 `@earendil-works/*` 家族钉在同一版本。更新的版本随发布逐个验证,下限只在实测结果允许时移动;`pnpm check:compat` 可复现该结论。注:pi ≥ 0.99 的宿主要求「宿主提供的包」一律声明为 peerDependencies `"*"` —— `@earendil-works/pi-tui` 与 `typebox`(ask 的 `scratchpad` 用它构造参数 schema)都按此声明;若放进 `dependencies`,pi 会告警。
18
+ **版本要求**:pi `>=0.99.0`。0.99.0 到 1.6.0 的每一个已发布版本都用完整门禁实测过(install → `tsc --noEmit` → 全量测试 → 键位审计 → 对 patch 目标宿主文件做哈希比对),每个版本都在沙箱中把整个 `@earendil-works/*` 家族钉在同一版本。更新的版本随发布逐个验证,下限只在实测结果允许时移动;`pnpm check:compat` 可复现该结论。注:pi ≥ 0.99 的宿主要求「宿主提供的包」一律声明为 peerDependencies `"*"` —— `@earendil-works/pi-tui` 与 `typebox`(ask 的 `scratchpad` 用它构造参数 schema)都按此声明;若放进 `dependencies`,pi 会告警。
19
19
 
20
20
  ---
21
21
 
@@ -76,7 +76,7 @@ pi -e ./src/index.ts
76
76
  | ⭐ **favorites** 模型收藏 | `/model` 内 `ctrl+A` / `ctrl+J` | 收藏常用模型(加粗亮黄标记),`ctrl+p` 仅在收藏间循环 |
77
77
  | 📥 **stash** 提示词暂存 | `ctrl+alt+y` | 一段提示词的暂存槽,按键交换 / 连按两次暂存并清空输入框 |
78
78
  | 🔎 **review** 第三方代码评审 | `/ask-review` | 召唤配置的评审模型,对刚完成的任务做查+修,重点检查「本轮需求实现 / 是否有遗漏 / 是否有错误」 |
79
- | 🧭 **plan** 浏览器内计划评审 | `/ask-plan` | 先调研、写 plan、在浏览器里逐段评审并逐块批注,批准之后才动代码 |
79
+ | 🧭 **spec** 浏览器内规格评审 | `/ask-spec` | 先调研、写 spec、在浏览器里逐段评审并逐块批注,批准之后才动代码 |
80
80
  | ✅ **uat** 验收台账 | `/ask-uat` | `/ask-init` 之后:把待归类的实施记录聚成用户视角的验收项,在页面里勾选(只追加、无提交),看清哪些已交付但还没验过 |
81
81
  | 🗜️ **compact** 独立压缩模型 | `/compact-model` | 给 `/compact` 与 auto-compact 配一个便宜快模型做总结,主模型专注对话;未配置零开销、任何异常回落 pi 默认 |
82
82
  | 🚀 **autostart** 会话启动自动化 | `.pi/autostart.toml` | 项目内声明启动时自动执行的斜杠命令(首批用例:`/add-dir` 多仓库挂载);未信任不执行、未注册命令跳过不发给模型 |
@@ -92,7 +92,7 @@ pi -e ./src/index.ts
92
92
 
93
93
  用 `/ask` 进入(再按一次退出)。适合只想要「问问题、读代码」的场景:模型不能改项目,但不会被剥夺思考的落点。
94
94
 
95
- ask 是独立的(不需要 `/ask-init`)。计划评审或 UAT 页面开着时先退出它们——ask 不会叠在另一个相位上启动,因为那个相位的 `before_agent_start` 会把写工具重新加回来。
95
+ ask 是独立的(不需要 `/ask-init`)。规格评审或 UAT 页面开着时先退出它们——ask 不会叠在另一个相位上启动,因为那个相位的 `before_agent_start` 会把写工具重新加回来。
96
96
 
97
97
  **进入后**:
98
98
 
@@ -281,35 +281,36 @@ run = ["/ask-perm allow allow allow ask"]
281
281
 
282
282
  - **未配置 / 配置的模型已不可用**(如在 pi 的 models.json 里删掉了该模型)→ 提示后照常弹出列表(此时无默认项)
283
283
  - 任务仍在进行中(agent 未空闲)时触发 → 提示等待,不执行;同一时间只允许一个评审
284
- - 计划期 → 拒绝(评审中的计划不能被改);ask 模式会自动退出,因为查+修需要完整工具集
284
+ - 规格评审期 → 拒绝(评审中的 spec 不能被改);ask 模式会自动退出,因为查+修需要完整工具集
285
285
  - footer 出现灰色 `review` 状态 = 已配置评审模型
286
286
 
287
287
  ---
288
288
 
289
- ## 🧭 plan — 先出计划,浏览器里评审,批准后再动手
289
+ ## 🧭 spec — 先写规格,浏览器里评审,批准后再动手
290
290
 
291
- <a name="plan"></a>
291
+ <a name="spec"></a>
292
292
 
293
- `/ask-plan [主题]` 进入计划期:模型先调研、把代码里看不出来的问题问清楚,然后写一份 spec——评审期间不改代码。写完调用 `plan_submit`,评审页在**你的浏览器**里打开,你**逐段**批注:每个空行分隔的块都可以挂批注,批注会作为下一条消息回到模型。
293
+ `/ask-spec [主题]` 进入规格评审期:模型先调研、把代码里看不出来的问题问清楚,然后写一份 spec——评审期间不改代码。写完调用 `spec_submit`,评审页在**你的浏览器**里打开,你**逐段**批注:每个空行分隔的块都可以挂批注,批注会作为下一条消息回到模型。`/ask-plan` 保留为别名。
294
294
 
295
- - **块是评审单位。** 一段一块,带徽标标出与上一版相比的变化:`新增` / `已修改` / `位置移动` / `已删除`。未变的块默认折叠,改三行不会被读成整篇重写;围栏代码块整块保留。
296
- - **只有两级批注**:块级 + 全局。不做文本选区锚,改版后不需要重新锚定。
297
- - **批准和提意见都会带上批注**,它们只决定下一步:批准 = 开始实施(批注照做);提意见 = 改完再提交。
298
- - **历史留档。** 每次提交都存在 `<agent-dir>/ask-plan/<slug>/`,页头可以只读回看任意一版。
299
- - **计划期走边界闸门**:进入时自动开启 `/ask-perm` 默认参数,退出时恢复;计划期唯一能写的文件是 markdown。
300
- - **绝不切模型。** 计划评审与实施都用会话当前的模型。(`/ask-review` 是唯一会切模型的命令,那是你要求的。)
295
+ - **块是评审单位。** 每个空行分隔的段落是一块,徽标告诉你相对上一版改了什么:`new`、`modified`、`moved`、`removed`。未变的块会折叠,三行小改不会看起来像整篇重写;围栏代码块保持完整。
296
+ - **两级批注。** 段落级,或全局;没有更细的文本范围批注,改完不需要重新锚定。
297
+ - **评审页一直看得见。** 双栏布局:左边是 spec,右边是本版统计和可点击的批注索引;全局批注即使编辑框关着也常显在正文上方。
298
+ - **批准和提意见都携带批注。** 它们只决定下一步:批准是「开始实施」(所有批注都带上),提意见是「改完 spec 再提交一版」。
299
+ - **历史留档。** 每次提交都存在 `<agent-dir>/ask-spec/<slug>/`,页头可以只读回看任意一版;旧的 `<agent-dir>/ask-plan/` 历史会在第一次使用时迁移。
300
+ - **评审期走边界检查。** `/ask-perm` 在评审开始时按默认值开启,结束时恢复;评审期唯一能写的是 markdown。
301
+ - **绝不切模型。** spec 评审与实施都用会话当前的模型。(`/ask-review` 是唯一会切模型的命令,那是你要求的。)
301
302
 
302
- **WSL 下的浏览器**:评审服务器绑 `0.0.0.0`,打印的 URL 用 WSL 的地址——因为在 WSL 里只绑回环,Windows 根本连不上。打开器优先用 Windows 侧的启动器(`wslview`、`cmd.exe /c start`、`powershell Start-Process`),非 WSL 才用 `xdg-open`——这决定你是"打开了浏览器"还是"在 WSL 里开了个看不见的浏览器"。
303
+ **WSL 下的浏览器**:评审服务器绑 `0.0.0.0`,URL 用 WSL 的地址打印,因为 Windows 连不到 WSL 里只绑 loopback 的服务器。打开器优先用 Windows 侧启动器(`wslview`、`cmd.exe /c start`、`powershell Start-Process`),其它平台才回落到 `xdg-open`——这决定了是「打开你的浏览器」还是「在 WSL 里打开一个你看不见的浏览器」。
303
304
 
304
305
  ```text
305
- /ask-plan 做导出功能 # 进入计划期
306
- /ask-plan open # 重新打开评审页
307
- /ask-plan off # 退出计划期(草稿留在原处)
306
+ /ask-spec 做导出功能 # 进入规格评审
307
+ /ask-spec open # 重新打开评审页
308
+ /ask-spec off # 退出评审期(草稿留在原处)
308
309
  ```
309
310
 
310
- spec 落在 `specs/<slug>.md`,与 `/ask-init` 的计划同一个位置。没有 agent 框架时计划仍能用,
311
- 但 `record_change` 与 `/ask-uat` 要等 `/ask-init` 之后才可用;进入计划期时会提示。
312
- UAT 页面开着时先 `/ask-uat off`——两个相位不会叠着跑。
311
+ spec 落在 `specs/<slug>.md`——与 `/ask-init` 放 spec 的地方相同。没有 agent 框架时评审仍可用,
312
+ 但 `record_change` 与 `/ask-uat` 不可用,直到 `/ask-init`;命令在评审开始时会说明。
313
+ UAT 页面开着时先退出:两个相位不叠在一起跑。
313
314
 
314
315
  ---
315
316
 
@@ -379,7 +380,7 @@ pi 的 `/compact` 与 auto-compact 默认**用当前会话模型**做上下文
379
380
  | auto-compact 阈值触发 | 压缩模型总结 |
380
381
  | context overflow 恢复 | 压缩模型总结,重试行为不变 |
381
382
 
382
- **接管后与 pi 内建行为完全一致的部分**(逐字同步 pi 内建实现,复制自 0.87.1、在 1.2.0 → 1.5.2 内字节级不变 —— 除了此处采纳的两项 1.4.0 修正:摘要请求使用模型自身的输出上限而非 `reserveTokens` 的固定比例,以及 `/compact <instructions>` 也会进入 split-turn 前缀,外加 1.5.0 的 `cost.totalFromProvider` 合并规则(用量统计);只换执行模型;对话序列化函数(`serializeConversation`)是直接从宿主导入的,因此跟随宿主行为 —— 例如 1.2.0 起不再把 assistant thinking 回填进摘要请求):
383
+ **接管后与 pi 内建行为完全一致的部分**(逐字同步 pi 内建实现,复制自 0.87.1、在 1.2.0 → 1.6.0 内字节级不变 —— 除了此处采纳的两项 1.4.0 修正:摘要请求使用模型自身的输出上限而非 `reserveTokens` 的固定比例,以及 `/compact <instructions>` 也会进入 split-turn 前缀,外加 1.5.0 的 `cost.totalFromProvider` 合并规则(用量统计);只换执行模型;对话序列化函数(`serializeConversation`)是直接从宿主导入的,因此跟随宿主行为 —— 例如 1.2.0 起不再把 assistant thinking 回填进摘要请求):
383
384
 
384
385
  - **摘要格式** —— Goal / Progress / Key Decisions 结构化 checkpoint;已有摘要时用迭代更新版 prompt,信息延续不丢
385
386
  - **切分行为** —— 保留最近 `keepRecentTokens` 的策略、`firstKeptEntryId` / `tokensBefore` 原样回传,不动
@@ -460,7 +461,7 @@ run = [
460
461
 
461
462
  **关键约束:只支持扩展命令**。`/add-dir`(pi-add-dir)、`/cd`(pi-cd)等 `registerCommand` 注册的命令可以;内置命令(`/compact`、`/reload`、`/resume`…)在 TUI 层分发,扩展层触发不了;skill 命令(`/skill:name`)是展开机制而非执行机制。依赖的目标扩展(如 pi-add-dir)需要先安装。
462
463
 
463
- > **实现说明**:执行用 `sendUserMessage(cmd, { expandPromptTemplates: true })` —— 该选项把 `/cmd args` 路由到命令分发而不是模型 prompt 路径(包装层默认 `false`;`_tryExecuteExtensionCommand` 在 1.2.0–1.5.2 全区间字节级一致,1.5.1 虽把 `sendUserMessage` 其余部分重构进 `_preparePrompt`,扩展命令分支仍是它最前面的早退路径,见 AGENTS.md 宿主兼容纪律)。预校验用 `pi.getCommands()`(只认 `source: "extension"`)。依赖 `smol-toml`(零依赖、~10KB、TOML 1.0)。
464
+ > **实现说明**:执行用 `sendUserMessage(cmd, { expandPromptTemplates: true })` —— 该选项把 `/cmd args` 路由到命令分发而不是模型 prompt 路径(包装层默认 `false`;`_tryExecuteExtensionCommand` 在 1.2.0–1.6.0 全区间字节级一致,1.5.1 虽把 `sendUserMessage` 其余部分重构进 `_preparePrompt`,扩展命令分支仍是它最前面的早退路径,见 AGENTS.md 宿主兼容纪律)。预校验用 `pi.getCommands()`(只认 `source: "extension"`)。依赖 `smol-toml`(零依赖、~10KB、TOML 1.0)。
464
465
 
465
466
  ---
466
467
 
@@ -500,7 +501,7 @@ run = [
500
501
  **ask 循环说的「已安装」**:`.agents/framework/state.toml`、`AGENTS.md`、
501
502
  `.agents/memory/README.md`、`.agents/implementations/` 存在。内容是用户的——小改
502
503
  不会让 `/ask-uat` 或 `record_change` 拒绝;需要框架的命令会把缺失项列出来。
503
- mutating 运行(含 `refresh`、`roots`)在 `/ask`、计划评审或 UAT 页面开着时拒绝;
504
+ mutating 运行(含 `refresh`、`roots`)在 `/ask`、规格评审或 UAT 页面开着时拒绝;
504
505
  `check` 与 `plan` 仍可用。
505
506
 
506
507
  旧工具写的项目没有模板锚。`/ask-init` 把这些文件报成 `I-FW-01` 并保持原状——它分不清
@@ -614,7 +615,7 @@ pnpm typecheck # tsc --noEmit
614
615
  pnpm test # vitest(全部功能单元测试)
615
616
 
616
617
  pnpm check:keybindings # 用宿主自己的分发表审计本插件的按键
617
- pnpm check:compat # 校验声明的 pi 下限:强制 4 条线窗口 + 向后 4 条线探针 → public floor
618
+ pnpm check:compat # 用真实宿主实测声明的 pi 区间(与声明不符即判失败)
618
619
  pnpm approval-report # 汇总本地审批日志(答复分布、目标目录、候选规则)
619
620
  ```
620
621
 
@@ -644,7 +645,7 @@ src/
644
645
  ├── permission/ # 会话级边界权限:模式、面板、bash 拆解、
645
646
  │ # 策略、会话授权、确认对话框、
646
647
  │ # 审计 payload、测试
647
- ├── plan/ # 浏览器内计划评审:相位、块级 diff、
648
+ ├── spec/ # 浏览器内规格评审:相位、块级 diff、
648
649
  │ # 评审服务器、UI、测试
649
650
  ├── quit-guard/ # 退出看门狗:TUI 收尾 + quit 事件双触发、
650
651
  │ # 配置存储、诊断报告、测试
@@ -691,7 +692,7 @@ pnpm release:github --audit # 列出 npm 版本 vs GitHub Release vs 远
691
692
  - **内建 patch**(favorites)必须保持**版本守卫 + 幂等** —— 打 patch 前先确认目标原型成员存在,防止重复应用,失败时用 `console.warn` 降级而不是把扩展搞挂
692
693
  - **内建提示词同步**(compact) —— `src/features/compact/prompt.ts` 里的总结 prompt 逐字抄自 pi 内建压缩;升级 pi 依赖时 diff `dist/core/compaction/compaction.js`(及 `utils.js`),同步字符串与组装辅助函数,保持接管输出与内建字节级一致
693
694
  - **键位** —— 定新快捷键前先查 pi 默认键位 + 保留键、终端控制字符、OS/终端模拟器占用;跨平台安全优先选 `ctrl+alt+<字母>`。**不得只验证「主屏下我这台机器能用」**:自 pi 1.0 起默认 `fullscreen`,alt-screen 层在对话框看到按键**之前**就消费 `tui.altScreen.*`,且 Windows/WSL 上多个绑定与 Linux 默认值不同。用 `pnpm check:keybindings [候选键...]` 核查(pi 升级后跑 `pnpm check:keybindings --all`),它用宿主自己的 `matchesKey` 探测已安装宿主的**已解析**键位表。**宿主表空闲 ≠ 机器层空闲**:Windows Terminal 默认占 `ctrl+v`(粘贴)与 `ctrl+shift+f`(查找),第三方 Windows 工具常绑 `ctrl+alt+<字母>`(截图工具占过 `ctrl+alt+f`)——定键后必须在真机试按,确认按键真的到得了应用。
694
- - **宿主兼容** —— peer 区间是实测结论而非愿望,而且只往回指:最近 4 个已发布中版本线是**强制窗口**(不兼容就改我们的代码,绝不抬下限),窗口之下再向后探最多 4 条线找出兼容实际停在哪里,对使用者只展示一个数:由此得到的**下限**(`pi >= <floor>`,无上界)。宿主依赖一动就重跑 `pnpm check:compat`,读它的 verdict 段(声明下限与实测不一致会直接判失败)。详见 AGENTS.md「pi 宿主兼容」;升级中发现的键位冲突**上报崔总决策**,不得顺手换键。
695
+ - **宿主兼容** —— peer 区间是实测结论而非愿望:`pi >= <floor>`,无上界;下限是仍能通过完整门禁的最老版本,下限到「已验证的最新版本」之间的每一个已发布版本都实测过。宿主依赖只在 `pnpm check:compat` 全绿时一起升——它用真实宿主重测声明区间,声明与实测不一致会直接判失败。详见 AGENTS.md「pi 宿主兼容」;升级中发现的键位冲突**上报崔总决策**,不得顺手换键。
695
696
  - **质量门禁** —— 提交前必须通过 `pnpm typecheck && pnpm test`
696
697
 
697
698
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andares/pi-toolkits",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Integrated toolkit extension for pi — ask mode (read-only Q&A), browser-reviewed planning, an acceptance ledger with a browser page, session-scoped permission checks, model favorites, prompt stash, third-party code review, session autostart, a dedicated compaction model, an agent memory framework (/ask-init), a quit watchdog, and release notes on the first start after an upgrade",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,8 +37,9 @@
37
37
  "scaffold",
38
38
  "init",
39
39
  "ask-init",
40
- "plan",
41
- "ask-plan",
40
+ "spec",
41
+ "spec-review",
42
+ "ask-spec",
42
43
  "uat",
43
44
  "ask-uat",
44
45
  "acceptance",
@@ -61,9 +62,9 @@
61
62
  "smol-toml": "^1.9.0"
62
63
  },
63
64
  "devDependencies": {
64
- "@earendil-works/pi-ai": "^1.5.1",
65
- "@earendil-works/pi-coding-agent": "^1.5.1",
66
- "@earendil-works/pi-tui": "^1.5.1",
65
+ "@earendil-works/pi-ai": "^1.6.0",
66
+ "@earendil-works/pi-coding-agent": "^1.6.0",
67
+ "@earendil-works/pi-tui": "^1.6.0",
67
68
  "@types/node": "^26.6.2",
68
69
  "typebox": "^1.3.27",
69
70
  "typescript": "^5.6.0",
@@ -82,7 +83,7 @@
82
83
  "ui:dev": "pnpm --filter @andares/pi-toolkits-ui dev",
83
84
  "ui:build": "pnpm --filter @andares/pi-toolkits-ui build",
84
85
  "ui:typecheck": "pnpm --filter @andares/pi-toolkits-ui typecheck",
85
- "ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/plan/assets src/features/uat/assets)\""
86
+ "ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/spec/assets src/features/uat/assets)\""
86
87
  },
87
88
  "pi": {
88
89
  "extensions": [
@@ -125,9 +125,9 @@ beforeEach(() => {
125
125
  describe("ask gate", () => {
126
126
  it("refuses to enter while a plan or UAT phase is active", async () => {
127
127
  const h = makeHarness({ scratchBaseDir: tempBase() });
128
- h.setActiveTools(["read", "write", "edit", "bash", "plan_submit"]);
128
+ h.setActiveTools(["read", "write", "edit", "bash", "spec_submit"]);
129
129
  await h.toggle();
130
- expect(h.notes.some((note) => /ask-plan/.test(note.message))).toBe(true);
130
+ expect(h.notes.some((note) => /ask-spec/.test(note.message))).toBe(true);
131
131
  expect(h.activeTools()).not.toContain(ASK_SCRATCH_TOOL);
132
132
 
133
133
  h.setActiveTools(["read", "write", "edit", "bash", "uat_item"]);
@@ -186,7 +186,7 @@ export function registerAsk(
186
186
  }
187
187
 
188
188
  // Planning is deliberately less restrictive than consult mode (markdown may
189
- // be written and bash stays available), so `/ask-plan` exits through the
189
+ // be written and bash stays available), so `/ask-spec` exits through the
190
190
  // owning feature rather than trying to restore its tool set itself.
191
191
  setAskControl({ isActive: () => enabled, exit });
192
192
 
@@ -48,7 +48,7 @@ export const RUNNABLE_REASONS: ReadonlySet<string> = new Set([
48
48
  * `-r` (`--resume`), `--session <path>` and `--fork <path>` all open an
49
49
  * existing session *before* the first runtime exists, and that runtime is
50
50
  * created without an explicit session_start event, so extensions see pi's
51
- * default reason — `startup` — not `resume` (verified on pi 1.2.0–1.5.1:
51
+ * default reason — `startup` — not `resume` (verified on pi 1.2.0–1.6.0:
52
52
  * `main.js` builds the initial session manager from those flags and calls
53
53
  * `createAgentSessionRuntime` with no `sessionStartEvent`;
54
54
  * `agent-session.js` defaults it to `{ reason: "startup" }`). `resume` is only
@@ -27,11 +27,12 @@
27
27
  * that flag is what routes "/cmd args" through _tryExecuteExtensionCommand
28
28
  * instead of the model prompt path. The wrapper defaults it to false in this
29
29
  * package. `_tryExecuteExtensionCommand` is byte-identical across every
30
- * published version of the supported window (1.2.0 → 1.5.1); `sendUserMessage`
30
+ * published version of the supported window (1.3.0 → 1.6.0); `sendUserMessage`
31
31
  * itself was refactored in 1.5.1 (the rest of the body moved into
32
32
  * `_preparePrompt`, #9154), but the extension-command branch is still the
33
33
  * first early exit of the wrapper, so `/cmd args` never reaches the model
34
- * prompt path. See AGENTS.md host-compat discipline for the version matrix.
34
+ * prompt path (1.6.0 left `sendUserMessage` and `_preparePrompt`
35
+ * byte-identical). See AGENTS.md host-compat discipline for the version matrix.
35
36
  *
36
37
  * Only extension commands can run this way. Built-in commands (/compact,
37
38
  * /reload, /resume, …) are dispatched at the TUI layer and cannot be
@@ -13,7 +13,7 @@
13
13
  * the summary file-list tail are verbatim pi built-in behavior (copied
14
14
  * from 0.87.1; `core/compaction/compaction.js` stayed byte-identical
15
15
  * 1.0.0 → 1.3.0, 1.4.0 changed only the summary output budget and
16
- * the split-turn focus handling mirrored below, and 1.5.0 / 1.5.1 left it
16
+ * the split-turn focus handling mirrored below, and 1.5.0 → 1.6.0 left it
17
17
  * untouched; the only mirrored helper that moved after that span is
18
18
  * `combineUsage`, see prompt.ts) — only the executing
19
19
  * model differs. The one exception is `serializeConversation`, which is
@@ -6,16 +6,16 @@
6
6
  * summaries produced by the configured compact model are formatted exactly
7
7
  * like pi's own compaction output. Only the executing model differs.
8
8
  * Verified byte-identical against every published version of the supported
9
- * window (1.2.0 → 1.5.1): the only utils.js changes (1.2.0 dropping assistant
9
+ * window (1.3.0 → 1.6.0): the only utils.js changes (1.2.0 dropping assistant
10
10
  * thinking from serializeConversation; 1.5.1 routing `truncateText` through
11
11
  * `sliceHead` so a truncation never splits a surrogate pair) do not touch the
12
12
  * strings mirrored here — that serializer is imported from the host, not
13
13
  * mirrored — compaction.js last changed in 1.4.0, in the output budget and
14
14
  * the split-turn focus handling (both adopted here, see
15
- * buildTurnPrefixPromptText) and is untouched in 1.5.1, and
15
+ * buildTurnPrefixPromptText) and is untouched in 1.5.1, 1.5.2 and 1.6.0, and
16
16
  * core/usage-totals.js changed once past that point, in 1.5.0, which only
17
17
  * added the `cost.totalFromProvider` merge rule mirrored below (the numeric
18
- * fields are untouched; 1.5.1 left it alone). 0.87.0 shipped a
18
+ * fields are untouched; 1.5.1 → 1.6.0 left it alone). 0.87.0 shipped a
19
19
  * different split-turn prefix prompt; the text mirrored here is 0.87.1's
20
20
  * fix, and the mirror is the only variant any supported host gets
21
21
  * — intentional.
@@ -22,13 +22,17 @@
22
22
  * keeps loading and ctrl+p falls back to stock behavior. The prototype
23
23
  * shape touched here (handleInput/updateList/filterModels and the instance
24
24
  * fields below) is unchanged across the mandatory window
25
- * pi 1.2.0 → 1.5.1 (and exercised by the 0.99.0 → 1.1.0 backward probes).
25
+ * pi 1.3.0 → 1.6.0 (and exercised by the 0.99.0 → 1.2.0 backward probes).
26
26
  * updateList gained one layout change in 1.5.0 — the disambiguating model
27
27
  * name after the id — mirrored here; see distinctModelName below.
28
28
  * filterModels gained a second `preferredModel` argument in 1.5.1 (keep the
29
29
  * selection when a background catalog refresh lands, #9109). The override
30
30
  * forwards it as-is: hosts before 1.5.1 ignore the extra argument, hosts from
31
31
  * 1.5.1 keep the highlighted row instead of jumping back to the top.
32
+ * 1.6.0 changed the *call site* only: the stock handleInput re-filters just
33
+ * when the query text actually changed (cursor keys no longer move the
34
+ * selection). Our override is on filterModels, which that path still calls,
35
+ * and the favorites keys are intercepted before the original handleInput runs.
32
36
  */
33
37
  import {
34
38
  ModelSelectorComponent,
@@ -317,11 +317,11 @@ describe("/ask-init", () => {
317
317
  const root = installedProject();
318
318
  try {
319
319
  const plan = harness(root);
320
- plan.tools.push("plan_submit");
320
+ plan.tools.push("spec_submit");
321
321
  registerInit(plan.pi, { now: NOW, toolVersion: "test" });
322
322
  await plan.run("--yes");
323
323
  expect(plan.sent).toHaveLength(0);
324
- expect(plan.messages.some((item) => /ask-plan/.test(item.message))).toBe(true);
324
+ expect(plan.messages.some((item) => /ask-spec/.test(item.message))).toBe(true);
325
325
 
326
326
  const uat = harness(root);
327
327
  uat.tools.push("uat_item");
@@ -6,7 +6,7 @@ This project uses the `@andares/pi-toolkits` ask workflow. The steps run in this
6
6
  | step | entry | what it does |
7
7
  | --- | --- | --- |
8
8
  | discuss | `/ask` | read-only consult; `scratchpad` is the only write channel |
9
- | plan | `/ask-plan <topic>` | research, ask questions, write `specs/<slug>.md`, review it block by block in the browser, implement only after approval |
9
+ | spec | `/ask-spec <topic>` | research, ask questions, write `specs/<slug>.md`, review it block by block in the browser, implement only after approval |
10
10
  | record | `record_change` | after the work: write the change record and one user-visible behaviour sentence |
11
11
  | review | `/ask-review` | optional third-party model cross-check (check + fix); it leaves no state behind |
12
12
  | accept | `/ask-uat` | cluster pending change records into acceptance items, verify them on the page, tick them off |
@@ -16,6 +16,6 @@ Rules that are easy to break:
16
16
  - Change records live in `.agents/implementations/`; new ones carry the minute in the name (`YYYY-MM-DD_HHMM_slug.md`) and repeat it in the first line (`# YYYY-MM-DDTHH:MM±HH:MM — title`).
17
17
  - The acceptance ledger is `.agents/uat/ledger.jsonl`, append-only, committed to git, and belongs to the main checkout. Never edit it by hand: the tools and the page write it.
18
18
  - Acceptance items are created by clustering on the UAT side, never by an implementation session.
19
- - Plans go in `specs/`, memory in `.agents/memory/`, evidence in `.agents/implementations/`.
19
+ - Specs go in `specs`, memory in `.agents/memory/`, evidence in `.agents/implementations/`.
20
20
 
21
21
  <!-- ask-init:end workflow -->
@@ -406,7 +406,7 @@ export function registerPermission(
406
406
  });
407
407
 
408
408
  // ── Control surface for other features ─────────────────────────────────
409
- // `/ask-plan` needs to switch the checks on for the planning phase and put
409
+ // `/ask-spec` needs to switch the checks on for the spec-review phase and put
410
410
  // them back afterwards. It gets a handle, not a copy of the state: the
411
411
  // session's own `/ask-perm` command stays authoritative, so an operator who
412
412
  // changes the mode mid-plan wins over whatever we restore later.
@@ -41,7 +41,9 @@ class ApplyOnEnter implements Component {
41
41
  }
42
42
 
43
43
  render(width: number): string[] {
44
- return this.list.render(width);
44
+ // pi 1.6.0 widened `Component.render` to `readonly string[]`; copy so the
45
+ // mutable local signature stays valid on both sides of that change.
46
+ return [...this.list.render(width)];
45
47
  }
46
48
 
47
49
  invalidate(): void {
@@ -4,9 +4,10 @@
4
4
  * Problem this solves: pi's interactive `/quit` stops the TUI, then awaits
5
5
  * `runtimeHost.dispose()` — every extension's `session_shutdown` handler,
6
6
  * one after another, with no timeout (upstream issue #9997; still unbounded
7
- * in 1.5.1 and on main — 1.5.1 added `await session.abort()` before the
8
- * handler loop and `await settleCredentialWrites()` after it, i.e. more awaits
9
- * in the same untimed chain, which makes the failure mode more likely, not
7
+ * in 1.6.0 and on main — 1.5.1 added `await session.abort()` before the
8
+ * handler loop and `await settleCredentialWrites()` after it, 1.6.0 added
9
+ * `await flushStdout()` further down, i.e. more awaits in the same untimed
10
+ * chain, which makes the failure mode more likely, not
10
11
  * less). One handler that never settles leaves the process
11
12
  * alive at 0% CPU, the terminal already restored and the final frame
12
13
  * reprinted: the screen looks like a frozen "exit screen" and the shell
@@ -33,7 +33,7 @@ import type {
33
33
  Theme,
34
34
  } from "@earendil-works/pi-coding-agent";
35
35
  import { getAskControl } from "../../lib/ask-control.js";
36
- import { PLAN_PHASE_TOOL } from "../../lib/phases.js";
36
+ import { specPhaseActive } from "../../lib/phases.js";
37
37
  import {
38
38
  modelKey,
39
39
  resolveConfiguredModel,
@@ -140,9 +140,9 @@ export function createReviewRunner(
140
140
  );
141
141
  return;
142
142
  }
143
- if (pi.getActiveTools?.().includes(PLAN_PHASE_TOOL)) {
143
+ if (specPhaseActive(pi)) {
144
144
  ctx.ui.notify(
145
- `${REVIEW_COMMAND}: ask-plan is active — approve or /ask-plan off first; a review needs write access.`,
145
+ `${REVIEW_COMMAND}: ask-spec is active — approve or /ask-spec off first; a review needs write access.`,
146
146
  "warning",
147
147
  );
148
148
  return;
@@ -417,13 +417,13 @@ describe("createReviewRunner", () => {
417
417
 
418
418
  it("refuses to review while a plan is under review", async () => {
419
419
  getReviewStore().setModel("anthropic/claude-sonnet-4");
420
- const { pi, sendUserMessage } = fakePi(true, ["read", "plan_submit"]);
420
+ const { pi, sendUserMessage } = fakePi(true, ["read", "spec_submit"]);
421
421
  const { ctx, notify, custom } = fakeCtx({ customResult: MODELS[0] });
422
422
  await createReviewRunner(pi)(ctx);
423
423
  expect(custom).not.toHaveBeenCalled();
424
424
  expect(sendUserMessage).not.toHaveBeenCalled();
425
425
  expect(notify).toHaveBeenCalledWith(
426
- expect.stringContaining("ask-plan"),
426
+ expect.stringContaining("ask-spec"),
427
427
  "warning",
428
428
  );
429
429
  });