@andares/pi-toolkits 0.12.4 → 0.14.0

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 (77) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +134 -17
  3. package/README.zh-CN.md +115 -16
  4. package/package.json +24 -11
  5. package/src/features/ask/index.ts +6 -0
  6. package/src/features/init/apply.ts +32 -12
  7. package/src/features/init/audit-uat.test.ts +103 -0
  8. package/src/features/init/audit.ts +148 -0
  9. package/src/features/init/detect.ts +4 -0
  10. package/src/features/init/index.ts +47 -2
  11. package/src/features/init/plan.ts +11 -0
  12. package/src/features/init/refresh.test.ts +208 -0
  13. package/src/features/init/refresh.ts +255 -0
  14. package/src/features/init/spec.ts +20 -0
  15. package/src/features/init/templates/agents-skeleton.md +2 -0
  16. package/src/features/init/templates/uat-readme.md +53 -0
  17. package/src/features/init/templates/workflow-block.md +21 -0
  18. package/src/features/init/templates.test.ts +3 -1
  19. package/src/features/init/templates.ts +2 -0
  20. package/src/features/init/types.ts +12 -1
  21. package/src/features/permission/index.ts +32 -0
  22. package/src/features/permission/policy.test.ts +10 -0
  23. package/src/features/permission/units.test.ts +157 -0
  24. package/src/features/permission/units.ts +317 -15
  25. package/src/features/plan/assets/index-C1YLIi4I.js +1 -0
  26. package/src/features/plan/assets/index-DMEpYC3V.css +1 -0
  27. package/src/features/plan/assets/index.html +14 -0
  28. package/src/features/plan/assets.test.ts +64 -0
  29. package/src/features/plan/blocks.test.ts +77 -0
  30. package/src/features/plan/blocks.ts +153 -0
  31. package/src/features/plan/diff.test.ts +144 -0
  32. package/src/features/plan/diff.ts +193 -0
  33. package/src/features/plan/feedback.test.ts +233 -0
  34. package/src/features/plan/feedback.ts +182 -0
  35. package/src/features/plan/index.test.ts +385 -0
  36. package/src/features/plan/index.ts +433 -0
  37. package/src/features/plan/prompt.test.ts +91 -0
  38. package/src/features/plan/prompt.ts +110 -0
  39. package/src/features/plan/render.test.ts +94 -0
  40. package/src/features/plan/render.ts +131 -0
  41. package/src/features/plan/server.test.ts +374 -0
  42. package/src/features/plan/server.ts +272 -0
  43. package/src/features/plan/store.test.ts +145 -0
  44. package/src/features/plan/store.ts +244 -0
  45. package/src/features/review/index.ts +54 -28
  46. package/src/features/review/review.test.ts +46 -1
  47. package/src/features/uat/assets/index-D-W9zj0w.css +1 -0
  48. package/src/features/uat/assets/index-DCBQCsli.js +1 -0
  49. package/src/features/uat/assets/index.html +14 -0
  50. package/src/features/uat/constants.ts +23 -0
  51. package/src/features/uat/index.test.ts +404 -0
  52. package/src/features/uat/index.ts +329 -0
  53. package/src/features/uat/item-tool.ts +280 -0
  54. package/src/features/uat/ledger.test.ts +249 -0
  55. package/src/features/uat/ledger.ts +504 -0
  56. package/src/features/uat/prompt.ts +78 -0
  57. package/src/features/uat/record-tool.ts +167 -0
  58. package/src/features/uat/records.test.ts +145 -0
  59. package/src/features/uat/records.ts +268 -0
  60. package/src/features/uat/server.ts +181 -0
  61. package/src/features/uat/state.test.ts +41 -0
  62. package/src/features/uat/state.ts +67 -0
  63. package/src/features/whats-new/changelog.ts +104 -0
  64. package/src/features/whats-new/constants.ts +35 -0
  65. package/src/features/whats-new/index.ts +146 -0
  66. package/src/features/whats-new/notice.ts +68 -0
  67. package/src/features/whats-new/paths.ts +29 -0
  68. package/src/features/whats-new/store.ts +114 -0
  69. package/src/features/whats-new/version.ts +43 -0
  70. package/src/features/whats-new/whats-new.test.ts +460 -0
  71. package/src/index.ts +13 -1
  72. package/src/lib/ask-control.ts +25 -0
  73. package/src/lib/opener.test.ts +72 -0
  74. package/src/lib/opener.ts +121 -0
  75. package/src/lib/permission-control.ts +39 -0
  76. package/src/lib/startup.test.ts +1 -1
  77. package/src/lib/web-review.ts +341 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ Notable, user-visible changes to `@andares/pi-toolkits`. After an upgrade, the
4
+ first interactive `pi` start shows the sections between the version you last ran
5
+ and the one just installed, once. This file keeps the full history.
6
+
7
+ Before releasing, add top-level `- ` bullets under `## Unreleased`. `pnpm release`
8
+ renames that heading to the version being published and refuses an empty section
9
+ (`--skip-changelog` bypasses the gate).
10
+ ## Unreleased
11
+
12
+ <!-- Notes for the next release go here; `pnpm release` renames this heading. -->
13
+
14
+ ## 0.14.0 — 2026-11-13
15
+
16
+ - **whats-new** — the first interactive `pi` start after an upgrade shows what changed since the version you last ran, once, without registering a slash command.
17
+ - **permission** — fewer false-positive prompts for quoted grep patterns, literal shell loops, `env`, `curl` data flags and read-only container inspection; multi-line commands are now split correctly.
18
+
19
+ ## 0.13.0 — 2026-11-12
20
+
21
+ - `/ask-plan` — plan first, review in the browser, then implement: research the task, write a spec, annotate it paragraph by paragraph in a local page, and only get permission to code after approval.
22
+ - `/ask-uat` and the `record_change` tool — change records are clustered into user-facing acceptance items and ticked off on a local page, so "shipped but not verified" is visible instead of implied.
23
+ - `/ask-init refresh` — refresh the framework-owned files of an already-adopted project in place (idempotent, safe).
24
+ - Releases are published by GitHub Actions with npm trusted publishing and carry a provenance attestation.
25
+
26
+ ## 0.12.3 — 2026-11-10
27
+
28
+ - quit-guard also arms on a quit event, so a signal-triggered shutdown that hangs before the TUI teardown is still forced out — with the terminal restored first.
29
+ - The watchdog deadline defaults to 8 s (was 10 s); `/quit-guard <ms>` still overrides it.
30
+
31
+ ## 0.12.0 — 2026-11-06
32
+
33
+ - `/quit-guard` — force-exit a hung interactive shutdown and give the shell prompt back; a JSON hang report is written first when the deadline passes.
34
+ - Every runtime-facing string is in English.
35
+
36
+ ## 0.11.0 — 2026-10-26
37
+
38
+ - `/ask-init` — install or adopt the agent memory framework (`AGENTS.md`, `specs/`, `.agents/`) with a snapshot, a coverage table, and a later drift audit.
39
+
40
+ ## 0.10.0 — 2026-10-24
41
+
42
+ - permission — a capped rolling JSONL approval log records each ask, its parsed units and your answer; `pnpm approval-report` turns it into rule candidates.
43
+
package/README.md CHANGED
@@ -13,7 +13,7 @@
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: nine 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** `third-review`, **dedicated compaction model** `compact-model`, **session startup automation** `autostart`, an **agent memory framework** `ask-init`, and a **quit watchdog** `quit-guard` — 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 **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.
17
17
 
18
18
  **Requirements**: pi `>=0.99.0`. Every published pi release from 0.99.0 through 1.5.1 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
 
@@ -40,7 +40,7 @@ After installing, verify in any pi session:
40
40
  - `/ask` → a grey `ask` status appears in the footer, `write`/`edit` are hard-disabled, and a `scratchpad` tool appears for throwaway notes
41
41
  - `/model` (or `ctrl+l`) → a favorites hint line appears at the top of the selector; `ctrl+A` on the selected model → it turns bold bright yellow and the favorites counter goes up (this step is also the real-machine keypress check — see Keybindings)
42
42
  - press `ctrl+alt+y` in the input box → the current prompt is stashed and the input box is cleared
43
- - after finishing a development task, type `/third-review` → switches to the review model and runs check + fix
43
+ - after finishing a development task, type `/ask-review` → switches to the review model and runs check + fix
44
44
  - `/compact-model`, pick a cheap fast model → from then on both `/compact` and auto-compaction summarize with it (a grey `compact` status appears in the footer)
45
45
 
46
46
  ---
@@ -58,6 +58,7 @@ After installing, verify in any pi session:
58
58
  - [🚀 autostart — session startup automation](#autostart)
59
59
  - [🧠 init — agent memory framework](#init)
60
60
  - [🧯 quit-guard — quit watchdog](#quit-guard)
61
+ - [🆕 whats-new — release notes after an upgrade](#whats-new)
61
62
  - [Development](#development)
62
63
  - [Contributing](#contributing)
63
64
  - [License](#license)
@@ -74,11 +75,14 @@ After installing, verify in any pi session:
74
75
  | 🔐 **permission** session-scoped boundary checks | `/ask-perm` | four in/out × read/write modes, off by default and never persisted; outside writes ask, credentials are denied, destructive commands always ask; composes with `/ask`; a capped JSONL approval log feeds later rule mining |
75
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 |
76
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 |
77
- | 🔎 **review** third-party code review | `/third-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" |
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 |
80
+ | ✅ **uat** acceptance ledger | `/ask-uat` | 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 |
78
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 |
79
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 |
80
83
  | 🧠 **init** agent memory framework | `/ask-init` | install or adopt a fixed memory layout (`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`), migrate an existing one with a snapshot and a coverage table, and audit it later for drift, budgets and duplicated facts |
81
84
  | 🧯 **quit-guard** quit watchdog | `/quit-guard` | force-exit when an interactive shutdown hangs, whether after the TUI teardown or before it on a signal-triggered quit; write a hang report and give the shell prompt back; TUI restarts and Ctrl+Z resume disarm it |
85
+ | 🆕 **whats-new** release notes after an upgrade | automatic | the first `pi` start after an upgrade shows what changed since the version you last ran, once; no slash command or other global namespace is claimed |
82
86
 
83
87
  ---
84
88
 
@@ -134,8 +138,11 @@ Repeating the argument form with the modes already in force is a **no-op**: no s
134
138
  - **bash** is decomposed into simple commands — `&&`, `||`, `;`, pipes, `$(…)`, backticks, `bash -c`, `eval`, the common indirection wrappers (`sudo`, `env`, `xargs`, `find -exec`, …), heredocs — and judged per command. `cd` folds into the commands after it; the strictest result wins, so `cd /tmp && rm x` cannot ride on the first segment.
135
139
  - **path-bearing tools** (`read` / `write` / `edit` / `grep` / `find` / `ls`) are judged by their own path; every other tool is judged by the working directory.
136
140
  - **unresolvable input** — a non-literal `cd` or `git -C`, an unknown shell variable in a path, an unterminated heredoc or substitution — is asked about regardless of mode (fail closed), never guessed.
141
+ - **literal for-loops** — `for f in a b; do grep x "$f"; done` is expanded with the literal words, because that is what bash does. Ordinary assignments are not persisted across commands without control-flow analysis; an unresolved loop, a value from `$(…)`, or a reassigned/mutated loop variable stays fail-closed. Newlines separate commands (`ls⏎rm x` is two commands, not one), and a backslash-newline is a line continuation.
142
+ - **patterns are not paths** — the first positional operand of `grep`/`rg`/`ag` is the pattern (`grep -n '</div>\s*$' file` asks nothing), and `$` at the end of a quoted string is literal, not a variable.
137
143
  - **`git -C <dir>`** is resolved like a local `cd`: relative path arguments (and the repository) are judged against `<dir>`, not the working directory.
138
- - **device sinks and data arguments** — `/dev/null`, `/dev/stdout` and `/dev/stderr` are never boundary targets, whether written as a redirect (`cmd > /dev/null`) or an operand (`curl -o /dev/null`); the arguments of `echo` / `printf` are data, not paths.
144
+ - **device sinks and data arguments** — `/dev/null`, `/dev/stdout` and `/dev/stderr` are never boundary targets, whether written as a redirect (`cmd > /dev/null`) or an operand (`curl -o /dev/null`); the arguments of `echo` / `printf` are data, not paths, as are declared data flags such as `curl -w` / `-H` / `-d`. Unresolved input and output redirects both stay fail-closed.
145
+ - **container inspection** — `docker`/`podman` subcommands that only inspect (`ps`, `logs`, `inspect`, `images`, `compose ps/logs/config`, …) are reads; `exec`, `run`, `rm`, `build` and everything unlisted stay writes.
139
146
 
140
147
  **Answers**: `a` allow once · `s` allow this directory for the session · `d` deny · `f` deny this directory for the session. Session grants are kept in memory as `(read|write, directory)`, matched by containment, and cleared when the mode is turned off or the session ends. A session grant outranks the destructive table — once you have allowed an operation for the session, repeating it does not ask again. A command the parser cannot resolve is granted by its exact text instead, so repeating the same opaque command does not ask again.
141
148
 
@@ -247,9 +254,9 @@ When the stash is empty, a single press means "stash + clear". The stash is **in
247
254
 
248
255
  <a name="review"></a>
249
256
 
250
- After a development task is done, type the `/third-review` command to summon **a different model** as a third party to "check + fix" the code just written: the review model has **full tool permissions**, and confirmed problems are edited in place — this is not a read-only audit. The review turn stays in the current session transcript, and after the review **the session keeps the review model** (it does not switch back automatically).
257
+ After a development task is done, type the `/ask-review` command to summon **a different model** as a third party to "check + fix" the code just written: the review model has **full tool permissions**, and confirmed problems are edited in place — this is not a read-only audit. The review turn stays in the current session transcript, and after the review **the session keeps the review model** (it does not switch back automatically).
251
258
 
252
- > **Command-triggered only**: only `/third-review` starts a review. Typing `third-review` as chat text does not trigger it (that is sent to the model as an ordinary message), which avoids accidental launches.
259
+ > **Command-triggered only**: only `/ask-review` starts a review. Typing `ask-review` as chat text does not trigger it (that is sent to the model as an ordinary message), which avoids accidental launches.
253
260
 
254
261
  **The review prompt focuses on three checks** (each gets an explicit verdict):
255
262
 
@@ -259,9 +266,9 @@ After a development task is done, type the `/third-review` command to summon **a
259
266
 
260
267
  **Strict scope constraint** — the review is limited to **the changes made in the current round**, to avoid scope creep; only problems confirmed inside this round's changes are fixed directly, while pre-existing or unrelated issues outside that range are only recorded as notes and left untouched.
261
268
 
262
- **Choosing the review model** (every `/third-review` opens a picker):
269
+ **Choosing the review model** (every `/ask-review` opens a picker):
263
270
 
264
- - `/third-review` → opens the **same selector as `/model`** (height-limited scrolling + fuzzy search): **the currently configured model is selected by default** (✓ marker), so pressing **Enter** starts the review with it
271
+ - `/ask-review` → opens the **same selector as `/model`** (height-limited scrolling + fuzzy search): **the currently configured model is selected by default** (✓ marker), so pressing **Enter** starts the review with it
265
272
  - **Pick another model** → written back to the config immediately (**both on disk and in memory**), and **that model becomes the default next time**
266
273
  - **Cancel** (Esc) → no review is run, the config is unchanged
267
274
  - The config is persisted in `<agent-dir>/pi-toolkits-review.json` (defaults to `~/.pi/agent/`):
@@ -270,13 +277,92 @@ After a development task is done, type the `/third-review` command to summon **a
270
277
  { "model": "anthropic/claude-sonnet-4" }
271
278
  ```
272
279
 
273
- - `/review-model` — a separate config entry point: opens the same list (without changing the session model, only updating the default config)
274
280
  - **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)
275
281
  - 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
276
282
  - A grey `review` status in the footer means a review model is configured
277
283
 
278
284
  ---
279
285
 
286
+ ## 🧭 plan — plan first, review in the browser, then implement
287
+
288
+ <a name="plan"></a>
289
+
290
+ `/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.
291
+
292
+ - **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.
293
+ - **Two levels of notes.** On a block, or global. Nothing finer — no text ranges to re-anchor after an edit.
294
+ - **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".
295
+ - **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.
296
+ - **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.
297
+ - **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.)
298
+
299
+ **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".
300
+
301
+ ```text
302
+ /ask-plan build the export feature # start planning
303
+ /ask-plan open # re-open the review page
304
+ /ask-plan off # leave the phase (the draft stays where it is)
305
+ ```
306
+
307
+ The spec lands in `specs/<slug>.md` — the same place `/ask-init` puts plans.
308
+
309
+ ---
310
+
311
+ ## ✅ uat — acceptance ledger and browser page
312
+
313
+ <a name="uat"></a>
314
+
315
+ `/ask-uat` answers exactly one question: **what did I ship that I have not verified yet?**
316
+ It exists because agent-driven development produces more behaviour changes per week than
317
+ anyone can remember, and "I will test it later" is how acceptance debt turns into rework.
318
+
319
+ The unit of acceptance is a **behaviour**, not a commit. An implementation session writes one
320
+ change record per finished round plus a one-sentence, user-facing description of that behaviour
321
+ (`record_change`); the UAT side clusters many records into a few acceptance items — one
322
+ behaviour may need ten records, and one record may touch several behaviours.
323
+
324
+ ```text
325
+ record_change (implementation) → /ask-uat (cluster) → browser (tick) → ledger
326
+ ```
327
+
328
+ | Command | What it does |
329
+ | --- | --- |
330
+ | `/ask-uat` | cluster pending change records into acceptance items, then open the page |
331
+ | `/ask-uat open` | reopen the page without a model turn |
332
+ | `/ask-uat off` | stop the page server |
333
+
334
+ **The page** lists open items newest-first. Each item carries a 2-3 sentence summary and an
335
+ expandable test plan (steps, edge cases, what not to test). Ticking an item appends a `check`
336
+ event immediately — there is no submit, and closing the page cannot lose a decision. Accepted
337
+ items fold into a section you can expand to undo a tick; the evidence records are one click
338
+ away in a drawer.
339
+
340
+ **The rules that keep it honest**:
341
+
342
+ - **Append-only ledger, no submit.** `.agents/uat/ledger.jsonl` is an event stream (`candidate`,
343
+ `batch`, `item`, `link`, `check`, `uncheck`, `amend`, `merge`, `drop`), committed to git,
344
+ deduplicated by event id, and safe for two processes appending at once (no lock, no merge).
345
+ - **New evidence reopens an item.** If a change record lands after the tick, the item shows
346
+ `reopened`: "accepted" means "accepted against the current evidence set".
347
+ - **The ledger belongs to the main checkout.** A session running in a linked git worktree writes
348
+ its records and events to the main checkout, so acceptance history never splits.
349
+ - **The directory is the fallback index.** A change record written by hand still shows up as
350
+ pending; `record_change` adds the behaviour sentence and the test hint, but it is not a gate.
351
+ - **Nothing else.** No editing, no ordering, no comments, no assignment. If clustering is wrong,
352
+ ask the agent in chat — it has `uat_item` (link / amend / merge / drop) while the page is open.
353
+
354
+ **Change-record format** (what `record_change` writes):
355
+
356
+ ```text
357
+ .agents/implementations/YYYY-MM-DD_HHMM_<slug>.md
358
+ # YYYY-MM-DDTHH:MM±HH:MM — title
359
+ ```
360
+
361
+ Older records (`YYYY-MM-DD_<slug>.md`, second-precision headers) keep working: the reader is
362
+ lenient, only the writer is strict. The audit reports new non-canonical records as `W-REC-01`.
363
+
364
+ ---
365
+
280
366
  ## 🗜️ compact — dedicated compaction model
281
367
 
282
368
  <a name="compact"></a>
@@ -400,6 +486,7 @@ repository root stays readable: `AGENTS.md`, `specs/`, `design/`, `docs/`,
400
486
  | `/ask-init plan [--deep]` | print the plan and write nothing (`--dry-run` is the same) |
401
487
  | `/ask-init check` | audit the installed framework (read-only; writes only a runtime report under `.agents/framework/reports/`) |
402
488
  | `/ask-init roots` | sync the directories added with `pi-add-dir` into the framework state |
489
+ | `/ask-init refresh` | refresh framework-owned files (contract, signpost, acceptance contract) and the workflow block in `AGENTS.md`; files you edited by hand are left untouched |
403
490
  | `/ask-init --yes` | skip the confirmation panel |
404
491
  | `/ask-init --lang zh\|en` | rendering language for framework-generated files (per run; default: detected from the project's own docs) |
405
492
 
@@ -534,6 +621,31 @@ extension registration); once the TUI is gone it is the only channel left.
534
621
 
535
622
  ---
536
623
 
624
+ ## 🆕 whats-new — release notes after an upgrade
625
+
626
+ <a name="whats-new"></a>
627
+
628
+ **What this does.** The first interactive `pi` start after an upgrade prints the notes for every
629
+ version between the one you last ran and the one you just installed — once. Later starts are
630
+ silent: the version is recorded in `<agent-dir>/pi-toolkits-whats-new.json`, so the notice never
631
+ comes back for that version. A fresh install is silent too (there is no previous version to
632
+ report from), and a downgrade is not an upgrade.
633
+
634
+ The notes are the bundled `CHANGELOG.md`: `pnpm release` renames its `## Unreleased` section to
635
+ the version being published (`--skip-changelog` bypasses that gate), so the notes always describe
636
+ the version that actually shipped. The startup notice is a session entry — it survives theme
637
+ changes and invalidations, and it stays out of the model context, so it costs no tokens. It is
638
+ capped at four versions and six notes per version; the file keeps everything. There is no slash
639
+ command: this is a plugin, and an automatic notice should not occupy the host's command namespace.
640
+
641
+ **Boundaries** — interactive TUI only: print/JSON/RPC sessions have no transcript to append to,
642
+ so they leave the notice for the first interactive start instead of consuming it. Notes appear
643
+ only when the version *increases*; reinstalling or downgrading records nothing new. If
644
+ `CHANGELOG.md` has no section for the running version, the notice still reports the version
645
+ change with an explicit "no release notes bundled" line rather than inventing content.
646
+
647
+ ---
648
+
537
649
  ## 🛠️ Development
538
650
 
539
651
  <a name="development"></a>
@@ -577,26 +689,31 @@ src/
577
689
  ├── quit-guard/ # quit watchdog: TUI teardown + quit-event triggers,
578
690
  │ # settings store, hang report, tests
579
691
  ├── review/ # third-party review: input/command triggers,
580
- │ # review-model config store, prompt, tests
581
- └── stash/ # prompt stash: hotkey state machine + tests
692
+ │ # review model config store, prompt, tests
693
+ ├── stash/ # prompt stash: hotkey state machine + tests
694
+ └── whats-new/ # release notes after an upgrade: CHANGELOG parser,
695
+ # last-seen store, startup notice, tests
582
696
  ```
583
697
 
584
698
  **Adding a feature**: create `src/features/<name>/` exporting `registerXxx(pi)` and call it from `src/index.ts`. Existing modules stay untouched. Each feature ships its own `*.test.ts` (vitest) — keep them deterministic (inject clocks/state, no real agent-dir writes).
585
699
 
586
- **Publishing** (pnpm-only, one command):
700
+ **Publishing** (one command; CI performs the upload):
587
701
 
588
702
  ```bash
589
703
  pnpm release patch # 0.1.2 → 0.1.3
590
704
  pnpm release minor # 0.1.2 → 0.2.0 (patch zeroed)
591
705
  pnpm release major # 0.1.2 → 1.0.0 (minor + patch zeroed)
592
- pnpm release patch --dry-run # preview without changing anything
593
- pnpm release:github # create/verify the GitHub Release for the current version
594
- pnpm release:github --audit # list npm versions vs GitHub Releases vs remote tags
706
+ pnpm release patch --dry-run # preview without changing anything
707
+ pnpm release patch --prepare-only # stop at the local tag, print the push command
708
+ pnpm release:github # create/verify the GitHub Release for the current version
709
+ pnpm release:github --audit # list npm versions vs GitHub Releases vs remote tags
595
710
  ```
596
711
 
597
- `release` requires exactly one of `major | minor | patch`; incrementing a higher level zeroes the lower ones. The chain is: **the working tree must be clean (any uncommitted change aborts before anything happens, guaranteeing tag content == published content)** → `typecheck + test` gate → version bump → git commit + `vX.Y.Z` tag (self-check that tag == HEAD and the tree is clean) → `pnpm publish` (with `prepublishOnly` as a second gate) → push the current branch → push the tag if the remote lacks it, verify the remote tag hash (with bounded retries, because GitHub's ref view lags right after a push) and create the GitHub Release.
712
+ Releasing is a **tag push**. `pnpm release` runs the gates (`typecheck`, `test`, UI checks), promotes the `## Unreleased` section of `CHANGELOG.md` to the new version (an empty section aborts the release — `--skip-changelog` opts out), bumps the version, commits, tags `vX.Y.Z`, pushes the branch and the tag — then waits for the GitHub Actions `publish` workflow. That workflow publishes with **npm trusted publishing (OIDC)**: no npm token, no interactive 2FA, and a provenance attestation on every version. The script only reports success once the version is on npm with `dist.attestations` non-empty.
713
+
714
+ `--prepare-only` is the "prepare everything, decide later" switch: it stops after commit+tag and prints the exact push command. `--no-wait` returns right after the push; `--local` is the emergency path that publishes from this machine with the old token. A failed workflow is retried on the same tag (`gh workflow run publish.yml -f tag=vX.Y.Z`); an already-published version is skipped, so the rerun is idempotent.
598
715
 
599
- If that last step is skipped (no `GITHUB_TOKEN`, a failed push, an HTTP error), the version would otherwise stay Release-less forever: the next release's auto-generated notes diff against the previous *published* Release, so the missing version's commits get folded into the next one and GitHub drifts away from npm. `pnpm release:github` is the resume path — it never bumps the version and never touches npm; `--audit` is the drift detector (`--allow-gaps` downgrades a historical gap to a warning).
716
+ One-time setup by the maintainer (interactive 2FA): `npm trust github @andares/pi-toolkits --repo andares/pi-toolkits --file publish.yml --env npm --allow-publish`. The GitHub Release remains best-effort (`GITHUB_TOKEN`); `pnpm release:github` backfills it without touching npm.
600
717
 
601
718
  ---
602
719
 
package/README.zh-CN.md CHANGED
@@ -13,7 +13,7 @@
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`、**第三方代码评审** `third-review`、**独立压缩模型** `compact-model`、**会话启动自动化** `autostart`、**agent 记忆框架** `ask-init`、**退出看门狗** `quit-guard`,后续持续追加。
16
+ 一句话介绍:目前包含十二个开箱即用的功能——**只读咨询模式** `ask`、**会话级边界权限** `ask-perm`、**模型收藏** `favorites`、**提示词暂存** `stash`、**第三方代码评审** `ask-review`、**独立压缩模型** `compact-model`、**会话启动自动化** `autostart`、**agent 记忆框架** `ask-init`、**浏览器内计划评审** `ask-plan`、**验收台账与浏览器页面** `ask-uat`、**退出看门狗** `quit-guard`、**升级后首次启动的版本变更提示** `whats-new`,后续持续追加。
17
17
 
18
18
  **版本要求**:pi `>=0.99.0`。0.99.0 到 1.5.1 的每一个已发布版本都用完整门禁实测过(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
 
@@ -40,7 +40,7 @@ pi -e ./src/index.ts
40
40
  - `/ask` → footer 出现灰色 `ask` 状态,`write`/`edit` 被硬禁用,同时出现 `scratchpad` 工具用于草稿笔记
41
41
  - `/model`(或 `ctrl+l`)→ 选择器顶部出现收藏提示行;对选中模型按 `ctrl+A` → 文字变**加粗亮黄**、收藏计数 +1(这一步同时就是真机按键检查,见「键位」约定)
42
42
  - 输入框内按 `ctrl+alt+y` → 当前提示词被暂存并清空输入框
43
- - 完成一个开发任务后输入 `/third-review` → 切换到评审模型执行查+修
43
+ - 完成一个开发任务后输入 `/ask-review` → 切换到评审模型执行查+修
44
44
  - `/compact-model` 选一个便宜快模型 → 之后 `/compact` 与自动压缩的总结都由它执行(footer 出现灰色 `compact` 状态)
45
45
 
46
46
  ---
@@ -58,6 +58,7 @@ pi -e ./src/index.ts
58
58
  - [🚀 autostart — 会话启动自动化](#autostart)
59
59
  - [🧠 init — agent 记忆框架](#init)
60
60
  - [🧯 quit-guard — 退出看门狗](#quit-guard)
61
+ - [🆕 whats-new — 升级后的版本变更提示](#whats-new)
61
62
  - [开发](#development)
62
63
  - [贡献](#contributing)
63
64
  - [许可](#license)
@@ -74,11 +75,14 @@ pi -e ./src/index.ts
74
75
  | 🔐 **permission** 会话级边界权限 | `/ask-perm` | 项目内/外 × 读/写四格模式,默认关闭且从不落盘;项目外写询问、凭据路径硬拒、破坏性命令必问;与 `/ask` 并行组合;另有滚动 JSONL 审批日志供事后挖规则 |
75
76
  | ⭐ **favorites** 模型收藏 | `/model` 内 `ctrl+A` / `ctrl+J` | 收藏常用模型(加粗亮黄标记),`ctrl+p` 仅在收藏间循环 |
76
77
  | 📥 **stash** 提示词暂存 | `ctrl+alt+y` | 一段提示词的暂存槽,按键交换 / 连按两次暂存并清空输入框 |
77
- | 🔎 **review** 第三方代码评审 | `/third-review` | 召唤配置的评审模型,对刚完成的任务做查+修,重点检查「本轮需求实现 / 是否有遗漏 / 是否有错误」 |
78
+ | 🔎 **review** 第三方代码评审 | `/ask-review` | 召唤配置的评审模型,对刚完成的任务做查+修,重点检查「本轮需求实现 / 是否有遗漏 / 是否有错误」 |
79
+ | 🧭 **plan** 浏览器内计划评审 | `/ask-plan` | 先调研、写 plan、在浏览器里逐段评审并逐块批注,批准之后才动代码 |
80
+ | ✅ **uat** 验收台账 | `/ask-uat` | 把待归类的实施记录聚成用户视角的验收项,在页面里勾选(只追加、无提交),看清哪些已交付但还没验过 |
78
81
  | 🗜️ **compact** 独立压缩模型 | `/compact-model` | 给 `/compact` 与 auto-compact 配一个便宜快模型做总结,主模型专注对话;未配置零开销、任何异常回落 pi 默认 |
79
82
  | 🚀 **autostart** 会话启动自动化 | `.pi/autostart.toml` | 项目内声明启动时自动执行的斜杠命令(首批用例:`/add-dir` 多仓库挂载);未信任不执行、未注册命令跳过不发给模型 |
80
83
  | 🧠 **init** agent 记忆框架 | `/ask-init` | 安装或接管一套固定的记忆结构(`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`),带快照与覆盖表迁移旧文档,之后可随时审计漂移、预算与重复事实 |
81
84
  | 🧯 **quit-guard** 退出看门狗 | `/quit-guard` | 交互式退出卡死时,无论发生在 TUI 收尾之后、还是信号触发路径的收尾之前,超时后写诊断报告并强制退出,把命令行提示符还给你;TUI 重启与 Ctrl+Z 恢复都会解除看守 |
85
+ | 🆕 **whats-new** 升级后的版本变更提示 | 自动 | 升级后的首次 `pi` 启动展示「从你上次运行的版本到现在改了什么」,只展示一次;不注册斜杠命令,不占用宿主的全局命令命名空间 |
82
86
 
83
87
  ---
84
88
 
@@ -134,8 +138,11 @@ pi -e ./src/index.ts
134
138
  - **bash** 先拆成简单命令 —— `&&`、`||`、`;`、管道、`$(…)`、反引号、`bash -c`、`eval`、常见间接包装(`sudo`、`env`、`xargs`、`find -exec`…)、heredoc —— 再逐条判定;`cd` 向前折叠,取最严格的结果,所以 `cd /tmp && rm x` 不会靠第一段蒙混过关
135
139
  - **带路径的工具**(`read` / `write` / `edit` / `grep` / `find` / `ls`)按自己的路径判定;其它工具按工作目录判定
136
140
  - **无法解析的输入** —— 非字面量 `cd` 或 `git -C`、路径里的未知 shell 变量、未闭合的 heredoc/命令替换 —— 一律询问,不看模式(fail closed),绝不猜测
141
+ - **字面量 for 循环** —— `for f in a b; do grep x "$f"; done` 按字面量展开(这正是 bash 的行为);普通赋值不跨命令持久化(缺少控制流分析时不能安全替换),值来自 `$(…)`、循环列表不可知、循环变量被重赋值/修改时仍按 fail-closed 处理。换行是命令分隔符(`ls⏎rm x` 是两条命令,不是一条),反斜杠+换行是续行
142
+ - **模式不是路径** —— `grep`/`rg`/`ag` 的第一个位置参数是模式(`grep -n '</div>\s*$' file` 不会询问);引号内的结尾 `$` 是字面字符,不是变量
137
143
  - **`git -C <dir>`** 按局部 `cd` 处理:相对路径参数(和仓库本身)按 `<dir>` 判定,而不是工作目录
138
- - **设备 sink 与数据参数** —— `/dev/null`、`/dev/stdout`、`/dev/stderr` 无论是重定向(`cmd > /dev/null`)还是普通操作数(`curl -o /dev/null`),都不算边界目标;`echo` / `printf` 的参数是数据,不按路径处理
144
+ - **设备 sink 与数据参数** —— `/dev/null`、`/dev/stdout`、`/dev/stderr` 无论是重定向(`cmd > /dev/null`)还是普通操作数(`curl -o /dev/null`),都不算边界目标;`echo` / `printf` 的参数是数据,`curl -w` / `-H` / `-d` 这类已声明的 data flag 同理。未解析的输入与输出重定向都保持 fail closed
145
+ - **容器只读子命令** —— `docker`/`podman` 的只读子命令(`ps`、`logs`、`inspect`、`images`、`compose ps/logs/config` 等)算读;`exec`、`run`、`rm`、`build` 以及未列出的子命令算写
139
146
 
140
147
  **回答**:`a` 本次允许 · `s` 本会话允许该目录 · `d` 拒绝 · `f` 本会话拒绝该目录。会话授权在内存中按 `(读|写, 目录)` 保存、按包含关系匹配,关闭模式或会话结束时清空;**会话授权优先于破坏性表**——你按了 `s` 之后,重复同一操作不会再弹;解析不了完整路径的命令则按**完整命令文本**授权,重复同一条命令不会再问。
141
148
 
@@ -247,9 +254,9 @@ run = ["/ask-perm allow allow allow ask"]
247
254
 
248
255
  <a name="review"></a>
249
256
 
250
- 开发任务完成后,输入 `/third-review` 指令召唤**另一个模型**以第三方身份,对刚完成的代码做「查 + 修」:评审模型拥有**完整工具权限**,确认的问题直接改,不是只读审计。评审回合留在当前会话记录里,评审完成后**会话保持评审模型**(不自动切回)。
257
+ 开发任务完成后,输入 `/ask-review` 指令召唤**另一个模型**以第三方身份,对刚完成的代码做「查 + 修」:评审模型拥有**完整工具权限**,确认的问题直接改,不是只读审计。评审回合留在当前会话记录里,评审完成后**会话保持评审模型**(不自动切回)。
251
258
 
252
- > **仅指令触发**:只有 `/third-review` 能发起评审。聊天中直接输入 `third-review` 不会触发(作为普通消息发给模型),避免误发。
259
+ > **仅指令触发**:只有 `/ask-review` 能发起评审。聊天中直接输入 `ask-review` 不会触发(作为普通消息发给模型),避免误发。
253
260
 
254
261
  **评审提示词重点检查三点**(逐项给出结论):
255
262
 
@@ -259,9 +266,9 @@ run = ["/ask-perm allow allow allow ask"]
259
266
 
260
267
  **范围强约束** —— 评审仅限**当前本轮修改内容**,避免扩大范围;本轮改动范围内确认的问题才直接修复,范围外的历史遗留/无关问题只记录提示、不动手改。
261
268
 
262
- **评审模型选择**(每次 `/third-review` 都会弹出选择界面):
269
+ **评审模型选择**(每次 `/ask-review` 都会弹出选择界面):
263
270
 
264
- - `/third-review` → 弹出 **`/model` 同款选择器**(限高滚动 + 模糊搜索):**默认选中当前配置的模型**(✓ 标记),直接**回车**即用它开始评审
271
+ - `/ask-review` → 弹出 **`/model` 同款选择器**(限高滚动 + 模糊搜索):**默认选中当前配置的模型**(✓ 标记),直接**回车**即用它开始评审
265
272
  - **换选其他模型** → 立即写回配置(**落盘 + 内存**),**下次默认使用该模型**
266
273
  - **取消**(Esc)→ 不执行评审,配置不变
267
274
  - 配置持久化于 `<agent-dir>/pi-toolkits-review.json`(默认 `~/.pi/agent/`):
@@ -270,13 +277,87 @@ run = ["/ask-perm allow allow allow ask"]
270
277
  { "model": "anthropic/claude-sonnet-4" }
271
278
  ```
272
279
 
273
- - `/review-model` —— 单独的配置入口:弹出同一列表(不改会话模型,只更新默认配置)
274
280
  - **未配置 / 配置的模型已不可用**(如在 pi 的 models.json 里删掉了该模型)→ 提示后照常弹出列表(此时无默认项)
275
281
  - 任务仍在进行中(agent 未空闲)时触发 → 提示等待,不执行;同一时间只允许一个评审
276
282
  - footer 出现灰色 `review` 状态 = 已配置评审模型
277
283
 
278
284
  ---
279
285
 
286
+ ## 🧭 plan — 先出计划,浏览器里评审,批准后再动手
287
+
288
+ <a name="plan"></a>
289
+
290
+ `/ask-plan [主题]` 进入计划期:模型先调研、把代码里看不出来的问题问清楚,然后写一份 spec——评审期间不改代码。写完调用 `plan_submit`,评审页在**你的浏览器**里打开,你**逐段**批注:每个空行分隔的块都可以挂批注,批注会作为下一条消息回到模型。
291
+
292
+ - **块是评审单位。** 一段一块,带徽标标出与上一版相比的变化:`新增` / `已修改` / `位置移动` / `已删除`。未变的块默认折叠,改三行不会被读成整篇重写;围栏代码块整块保留。
293
+ - **只有两级批注**:块级 + 全局。不做文本选区锚,改版后不需要重新锚定。
294
+ - **批准和提意见都会带上批注**,它们只决定下一步:批准 = 开始实施(批注照做);提意见 = 改完再提交。
295
+ - **历史留档。** 每次提交都存在 `<agent-dir>/ask-plan/<slug>/`,页头可以只读回看任意一版。
296
+ - **计划期走边界闸门**:进入时自动开启 `/ask-perm` 默认参数,退出时恢复;计划期唯一能写的文件是 markdown。
297
+ - **绝不切模型。** 计划评审与实施都用会话当前的模型。(`/ask-review` 是唯一会切模型的命令,那是你要求的。)
298
+
299
+ **WSL 下的浏览器**:评审服务器绑 `0.0.0.0`,打印的 URL 用 WSL 的地址——因为在 WSL 里只绑回环,Windows 根本连不上。打开器优先用 Windows 侧的启动器(`wslview`、`cmd.exe /c start`、`powershell Start-Process`),非 WSL 才用 `xdg-open`——这决定你是"打开了浏览器"还是"在 WSL 里开了个看不见的浏览器"。
300
+
301
+ ```text
302
+ /ask-plan 做导出功能 # 进入计划期
303
+ /ask-plan open # 重新打开评审页
304
+ /ask-plan off # 退出计划期(草稿留在原处)
305
+ ```
306
+
307
+ spec 落在 `specs/<slug>.md`,与 `/ask-init` 的计划同一个位置。
308
+
309
+ ---
310
+
311
+ ## ✅ uat — 验收台账与浏览器页面
312
+
313
+ <a name="uat"></a>
314
+
315
+ `/ask-uat` 只回答一个问题:**这一批交付的东西,哪些还没验过?**
316
+ 它存在的原因是:agent 驱动的开发一周产出的行为变更,人根本记不住;
317
+ 「回头再测」就是验收债变成返工的方式。
318
+
319
+ 验收的单位是**行为**,不是提交。实施会话每轮用 `record_change` 写一条实施记录,
320
+ 附一句「用户视角能做什么」;UAT 侧把多条记录聚成少数验收项——一条行为可能要十条记录,
321
+ 一条记录也可能碰到多个行为。
322
+
323
+ ```text
324
+ record_change(实施)→ /ask-uat(聚类)→ 浏览器(勾选)→ 台账
325
+ ```
326
+
327
+ | 命令 | 做什么 |
328
+ | --- | --- |
329
+ | `/ask-uat` | 把待归类的实施记录聚成验收项,然后打开页面 |
330
+ | `/ask-uat open` | 只重开页面,不走模型回合 |
331
+ | `/ask-uat off` | 关掉页面服务 |
332
+
333
+ **页面**按时间倒序列出未验收项:每条 2–3 句摘要,可展开测试方案(步骤、边界、
334
+ 「这次不用测什么」)。勾选即写一条 `check` 事件——**没有提交**,关页不会丢决定。
335
+ 已验收项折叠在底部,展开可反选;证据记录点一下就能看原文。
336
+
337
+ **它靠这几条站得住**:
338
+
339
+ - **只追加的台账,没有提交。** `.agents/uat/ledger.jsonl` 是事件流(`candidate`、`batch`、`item`、
340
+ `link`、`check`、`uncheck`、`amend`、`merge`、`drop`),进 git,按事件 id 去重,两个进程同时追加也不丢事件。
341
+ - **新证据会重开验收项。** 勾选之后又有新记录落到同一项,页面标 `reopened`:
342
+ 「已验收」的含义是「按当前证据集验过」。
343
+ - **台账只属于主仓。** 在 git worktree 里跑的会话,实施记录与事件都写主仓,验收历史不会被分裂。
344
+ - **目录本身就是兜底索引。** 手写的实施记录同样会出现在待验收列表;`record_change` 只是补上
345
+ 行为句与测试提示,不是闸门。
346
+ - **其他都不做。** 不编辑、不排序、不评论、不指派。聚类不合适就在对话里要求 agent
347
+ 调整(页面开着时 `uat_item` 可用:link / amend / merge / drop)。
348
+
349
+ **实施记录格式**(`record_change` 写的就是这个):
350
+
351
+ ```text
352
+ .agents/implementations/YYYY-MM-DD_HHMM_<slug>.md
353
+ # YYYY-MM-DDTHH:MM±HH:MM — 标题
354
+ ```
355
+
356
+ 旧记录(`YYYY-MM-DD_<slug>.md`、秒级首行)照样能读:读取端宽容,只有写入端严格。
357
+ 新写的不合规记录由审计报 `W-REC-01`。
358
+
359
+ ---
360
+
280
361
  ## 🗜️ compact — 独立压缩模型
281
362
 
282
363
  <a name="compact"></a>
@@ -398,6 +479,7 @@ run = [
398
479
  | `/ask-init plan [--deep]` | 只打印计划,不写任何盘(`--dry-run` 同义) |
399
480
  | `/ask-init check` | 审计已装的框架(只读;只在 `.agents/framework/reports/` 留下运行期报告) |
400
481
  | `/ask-init roots` | 把 `pi-add-dir` 添加的目录同步进框架状态 |
482
+ | `/ask-init refresh` | 刷新框架拥有的文件(合同、门牌、验收合同)与 `AGENTS.md` 里的工作流块;手工改过的文件一概不动 |
401
483
  | `/ask-init --yes` | 跳过确认面板 |
402
484
  | `/ask-init --lang zh\|en` | 框架生成文件的渲染语言(单次生效;默认按项目自身文档判定) |
403
485
 
@@ -480,6 +562,18 @@ run = [
480
562
 
481
563
  ---
482
564
 
565
+ ## 🆕 whats-new — 升级后的版本变更提示
566
+
567
+ <a name="whats-new"></a>
568
+
569
+ **做什么。** 升级后第一次进入交互式 `pi` 时,展示「你上次运行的版本 → 刚装上的版本」之间每个版本的变更要点,**只展示一次**。版本号记在 `<agent-dir>/pi-toolkits-whats-new.json`,同一版本之后再怎么进入都不会再弹;全新安装也不弹(没有「上一个版本」可对比),降级不算升级。
570
+
571
+ 变更内容来自随包发布的 `CHANGELOG.md`:`pnpm release` 会把 `## Unreleased` 改名成即将发布的版本号(`--skip-changelog` 可跳过这道闸),所以提示里的内容永远对得上真正发出去的那一版。启动提示是一个会话条目 —— 主题切换/invalidate 不会冲掉它,也不进模型上下文(不花 token)。启动提示最多展示 4 个版本、每个版本 6 条;全文始终在 `CHANGELOG.md` 里。不提供斜杠命令:插件只负责自动提示,不占宿主的全局命令命名空间。
572
+
573
+ **边界** —— 只覆盖交互式 TUI:print/JSON/RPC 模式没有可追加的 transcript,会把这次提示留给下一次交互式启动,而不是白白消耗掉。只有版本**升高**时才会提示;重装或降级什么都不记。若 `CHANGELOG.md` 没有当前版本的段落,提示仍会报告版本变化,并明确写「没有内置变更记录」,不会编造内容。
574
+
575
+ ---
576
+
483
577
  ## 🛠️ 开发
484
578
 
485
579
  <a name="development"></a>
@@ -523,25 +617,30 @@ src/
523
617
  │ # 配置存储、诊断报告、测试
524
618
  ├── review/ # 第三方评审:输入/指令触发、
525
619
  │ # 评审模型配置存储、提示词、测试
526
- └── stash/ # 提示词暂存:热键状态机 + 测试
620
+ ├── stash/ # 提示词暂存:热键状态机 + 测试
621
+ └── whats-new/ # 升级后的版本变更提示:CHANGELOG 解析、
622
+ # 已见版本存储、启动提示、测试
527
623
  ```
528
624
 
529
625
  **新增功能**:新建 `src/features/<name>/`,导出 `registerXxx(pi)`,在 `src/index.ts` 中调用;已有模块保持不变。每个功能自带 `*.test.ts`(vitest)——保持确定性(时钟/状态可注入,不写真实 agent-dir)。
530
626
 
531
- **发布**(仅 pnpm 一条命令):
627
+ **发布**(一条命令;上传由 CI 执行):
532
628
 
533
629
  ```bash
534
630
  pnpm release patch # 0.1.2 → 0.1.3
535
631
  pnpm release minor # 0.1.2 → 0.2.0 (patch 清零)
536
632
  pnpm release major # 0.1.2 → 1.0.0 (minor + patch 清零)
537
- pnpm release patch --dry-run # 预览,不做任何改动
538
- pnpm release:github # 为当前版本创建/校验 GitHub Release(幂等)
539
- pnpm release:github --audit # 列出 npm 版本 vs GitHub Release vs 远端 tag
633
+ pnpm release patch --dry-run # 预览,不做任何改动
634
+ pnpm release patch --prepare-only # 准备到本地 tag,打印推送命令
635
+ pnpm release:github # 为当前版本创建/校验 GitHub Release(幂等)
636
+ pnpm release:github --audit # 列出 npm 版本 vs GitHub Release vs 远端 tag
540
637
  ```
541
638
 
542
- `release` 要求且仅要求 `major | minor | patch` 之一;上级递增清零下级。执行链:**工作区必须干净(有未提交变更直接中止,保证 tag 内容 == 发布内容)** → `typecheck + test` 门禁 → 改版本 → git commit + `vX.Y.Z` tag(自检 tag==HEAD 且工作区干净) → `pnpm publish`(`prepublishOnly` 二次门禁) → 推当前分支 → tag 远端没有就推、有就校验哈希一致(带有限次重试——刚推完 GitHub 的 ref 可见性可能滞后)→ 创建 GitHub Release。
639
+ **发版 = 推 tag。** `pnpm release` 跑完门禁(`typecheck`、`test`、UI 检查)、把 `CHANGELOG.md` 的 `## Unreleased` 提升为即将发布的版本号(段落为空则中止,`--skip-changelog` 可跳过)、改版本、commit、打 `vX.Y.Z` tag、推分支和 tag,然后等 GitHub Actions 的 `publish` 工作流。该工作流用 **npm trusted publishing(OIDC)** 发布:不需要 npm token、不需要交互式 2FA,每个版本自动附 provenance。脚本只在 npm 上真的出现该版本、且 `dist.attestations` 非空时才报成功。
640
+
641
+ `--prepare-only` 是「都准备好、发不发最后再说」的开关:停在 commit+tag 后,打印确切的推送命令。`--no-wait` 推完就返回;`--local` 是应急路径(本机用旧 token 发布)。工作流失败后重跑同一个 tag 即可(`gh workflow run publish.yml -f tag=vX.Y.Z`):已发布的版本会跳过,所以重跑是幂等的。
543
642
 
544
- 若最后一步被跳过(无 `GITHUB_TOKEN`、push 失败、HTTP 报错),该版本会永远没有 Release:下一版自动生成的 release notes 是**对着上一个已发布的 Release** 算 diff 的,于是缺的那版提交被吞进下一版,GitHub 的版本线就与 npm 对不上。`pnpm release:github` 就是补建/续跑入口——不动版本号、不碰 npm;`--audit` 是差集探测器(`--allow-gaps` 把历史缺口降级为警告)。
643
+ 维护者一次性配置(交互式 2FA):`npm trust github @andares/pi-toolkits --repo andares/pi-toolkits --file publish.yml --env npm --allow-publish`。GitHub Release 仍是 best-effort(需要 `GITHUB_TOKEN`);`pnpm release:github` 可以不动 npm 补建。
545
644
 
546
645
  ---
547
646
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@andares/pi-toolkits",
3
- "version": "0.12.4",
4
- "description": "Integrated toolkit extension for pi — ask mode (read-only Q&A), session-scoped permission checks, model favorites, prompt stash, third-party code review, session autostart, a dedicated compaction model, and an agent memory framework (/ask-init)",
3
+ "version": "0.14.0",
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), and release notes on the first start after an upgrade",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -12,7 +12,8 @@
12
12
  "access": "public"
13
13
  },
14
14
  "files": [
15
- "src"
15
+ "src",
16
+ "CHANGELOG.md"
16
17
  ],
17
18
  "keywords": [
18
19
  "pi-package",
@@ -34,7 +35,14 @@
34
35
  "agent-memory",
35
36
  "memory-framework",
36
37
  "scaffold",
37
- "init"
38
+ "init",
39
+ "uat",
40
+ "acceptance",
41
+ "acceptance-testing",
42
+ "change-record",
43
+ "whats-new",
44
+ "release-notes",
45
+ "changelog"
38
46
  ],
39
47
  "peerDependencies": {
40
48
  "@earendil-works/pi-coding-agent": ">=0.99.0",
@@ -55,11 +63,6 @@
55
63
  "typescript": "^5.6.0",
56
64
  "vitest": "^4.1.10"
57
65
  },
58
- "pi": {
59
- "extensions": [
60
- "./src/index.ts"
61
- ]
62
- },
63
66
  "scripts": {
64
67
  "typecheck": "tsc --noEmit",
65
68
  "test": "vitest run",
@@ -67,7 +70,17 @@
67
70
  "check:compat": "node ./scripts/check-compat.mjs",
68
71
  "approval-report": "node ./scripts/approval-report.mjs",
69
72
  "release:github": "node ./scripts/release-github.mjs",
73
+ "prepublishOnly": "pnpm typecheck && pnpm ui:typecheck && pnpm test && pnpm ui:check",
70
74
  "release": "node ./scripts/publish.mjs",
71
- "tag-current": "node ./scripts/tag-current.mjs"
75
+ "tag-current": "node ./scripts/tag-current.mjs",
76
+ "ui:dev": "pnpm --filter @andares/pi-toolkits-ui dev",
77
+ "ui:build": "pnpm --filter @andares/pi-toolkits-ui build",
78
+ "ui:typecheck": "pnpm --filter @andares/pi-toolkits-ui typecheck",
79
+ "ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/plan/assets src/features/uat/assets)\""
80
+ },
81
+ "pi": {
82
+ "extensions": [
83
+ "./src/index.ts"
84
+ ]
72
85
  }
73
- }
86
+ }