@andares/pi-toolkits 0.14.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +101 -34
- package/README.zh-CN.md +68 -32
- package/package.json +10 -3
- package/src/features/ask/index.test.ts +15 -0
- package/src/features/ask/index.ts +18 -1
- package/src/features/init/audit.test.ts +19 -2
- package/src/features/init/audit.ts +117 -15
- package/src/features/init/index.test.ts +123 -1
- package/src/features/init/index.ts +156 -46
- package/src/features/init/parity.test.ts +176 -0
- package/src/features/init/parity.ts +229 -0
- package/src/features/init/plan.ts +25 -3
- package/src/features/init/refresh.test.ts +88 -1
- package/src/features/init/refresh.ts +43 -64
- package/src/features/init/spec.ts +11 -0
- package/src/features/init/templates/memory-readme.md +9 -2
- package/src/features/init/templates/workflow-block.md +2 -2
- package/src/features/init/test-helpers.ts +1 -0
- package/src/features/init/workflow.ts +159 -0
- package/src/features/permission/index.ts +1 -1
- package/src/features/quit-guard/constants.ts +18 -5
- package/src/features/quit-guard/index.ts +75 -29
- package/src/features/quit-guard/killer.test.ts +77 -0
- package/src/features/quit-guard/killer.ts +215 -0
- package/src/features/review/index.ts +14 -0
- package/src/features/review/review.test.ts +34 -2
- package/src/features/spec/assets/index-CdTerMvN.css +1 -0
- package/src/features/spec/assets/index-Dv52AIjX.js +1 -0
- package/src/features/{plan → spec}/assets/index.html +3 -3
- package/src/features/{plan → spec}/assets.test.ts +5 -5
- package/src/features/{plan → spec}/blocks.ts +1 -1
- package/src/features/{plan → spec}/feedback.test.ts +26 -26
- package/src/features/{plan → spec}/feedback.ts +14 -14
- package/src/features/{plan → spec}/index.test.ts +148 -63
- package/src/features/{plan → spec}/index.ts +136 -105
- package/src/features/{plan → spec}/prompt.test.ts +20 -20
- package/src/features/{plan → spec}/prompt.ts +25 -25
- package/src/features/{plan → spec}/render.test.ts +2 -2
- package/src/features/{plan → spec}/server.test.ts +21 -21
- package/src/features/{plan → spec}/server.ts +22 -22
- package/src/features/{plan → spec}/store.test.ts +77 -35
- package/src/features/{plan → spec}/store.ts +80 -52
- package/src/features/uat/index.test.ts +20 -5
- package/src/features/uat/index.ts +16 -13
- package/src/features/uat/record-tool.ts +6 -5
- package/src/features/uat/records.test.ts +5 -5
- package/src/features/uat/state.ts +13 -5
- package/src/index.ts +6 -6
- package/src/lib/ask-control.ts +2 -2
- package/src/lib/permission-control.ts +4 -4
- package/src/lib/phases.ts +50 -0
- package/src/lib/web-review.ts +1 -1
- package/src/features/plan/assets/index-C1YLIi4I.js +0 -1
- package/src/features/plan/assets/index-DMEpYC3V.css +0 -1
- /package/src/features/{plan → spec}/blocks.test.ts +0 -0
- /package/src/features/{plan → spec}/diff.test.ts +0 -0
- /package/src/features/{plan → spec}/diff.ts +0 -0
- /package/src/features/{plan → spec}/render.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,27 @@ 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.1 — 2026-11-17
|
|
15
|
+
|
|
16
|
+
- **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`.
|
|
17
|
+
- **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.
|
|
18
|
+
- **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.
|
|
19
|
+
- **ask-spec** — existing `<agent-dir>/ask-plan/` review histories are migrated to `<agent-dir>/ask-spec/` on first use.
|
|
20
|
+
|
|
21
|
+
<!-- Notes for the next release go here; `pnpm release` renames this heading. -->
|
|
22
|
+
|
|
23
|
+
## 1.0.0 — 2026-11-15
|
|
24
|
+
|
|
25
|
+
- **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).
|
|
26
|
+
- **quit-guard** — a new arm-time watchdog thread covers shutdown deadlocks that kill the main event loop *before* the fire deadline: the main loop beats a 1 Hz heartbeat, and a worker that sees it stop restores the terminal, writes a `quit-hang-*-thread.json` report and SIGKILLs; healthy quits, TUI restarts and Ctrl+Z resume are unaffected.
|
|
27
|
+
- **ask-init** — re-running it now compares the project's framework text with the installed version, repairs missing or stale framework-owned files when safe, and says explicitly when nothing needs changing; hand-edited files stay untouched.
|
|
28
|
+
- **ask-init** — the workflow marker matcher no longer mistakes inline examples or fenced snippets for the managed block; ambiguous marker pairs are reported and left untouched.
|
|
29
|
+
- **ask-init** — `refresh --adopt` takes ownership of framework files written by an older tool without a template anchor, after you review them; a normal refresh still leaves them alone.
|
|
30
|
+
- **ask** — phase guards: ask refuses to start on top of a plan review or the UAT page, a review exits ask mode and refuses while a plan is under review, and `/ask-init` refuses mutating runs while another phase owns the tree.
|
|
31
|
+
- **init** — the audit now distinguishes a stale framework file from a hand edit, reports a missing workflow block, and treats bare legacy paths as a warning once the legacy directories are gone.
|
|
32
|
+
|
|
33
|
+
<!-- Notes for the next release go here; `pnpm release` renames this heading. -->
|
|
34
|
+
|
|
14
35
|
## 0.14.0 — 2026-11-13
|
|
15
36
|
|
|
16
37
|
- **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.
|
|
@@ -41,3 +62,5 @@ renames that heading to the version being published and refuses an empty section
|
|
|
41
62
|
|
|
42
63
|
- 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
64
|
|
|
65
|
+
|
|
66
|
+
|
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
[](https://github.com/earendil-works/pi)
|
|
14
14
|
[](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 **
|
|
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.
|
|
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.
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
@@ -76,11 +76,11 @@ 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
|
-
| 🧭 **
|
|
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 |
|
|
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
|
+
| ✅ **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 |
|
|
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,
|
|
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, then audit/refresh it for drift, budgets and duplicated facts |
|
|
84
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
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 |
|
|
86
86
|
|
|
@@ -92,6 +92,8 @@ 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 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
|
+
|
|
95
97
|
**While active**:
|
|
96
98
|
|
|
97
99
|
- **Project writes stay mechanically impossible** — `write` / `edit` / `powershell` are removed from the active tool set, so pi rejects calls to inactive tools outright ("Tool not found"); the gate blocks them again as defence in depth
|
|
@@ -279,32 +281,37 @@ After a development task is done, type the `/ask-review` command to summon **a d
|
|
|
279
281
|
|
|
280
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)
|
|
281
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
|
+
- 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
|
|
282
285
|
- A grey `review` status in the footer means a review model is configured
|
|
283
286
|
|
|
284
287
|
---
|
|
285
288
|
|
|
286
|
-
## 🧭
|
|
289
|
+
## 🧭 spec — write it, review it in the browser, then implement
|
|
287
290
|
|
|
288
|
-
<a name="
|
|
291
|
+
<a name="spec"></a>
|
|
289
292
|
|
|
290
|
-
`/ask-
|
|
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.
|
|
291
294
|
|
|
292
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.
|
|
293
296
|
- **Two levels of notes.** On a block, or global. Nothing finer — no text ranges to re-anchor after an edit.
|
|
294
|
-
- **
|
|
295
|
-
- **
|
|
296
|
-
- **
|
|
297
|
-
- **
|
|
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.)
|
|
298
302
|
|
|
299
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".
|
|
300
304
|
|
|
301
305
|
```text
|
|
302
|
-
/ask-
|
|
303
|
-
/ask-
|
|
304
|
-
/ask-
|
|
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)
|
|
305
309
|
```
|
|
306
310
|
|
|
307
|
-
The spec lands in `specs/<slug>.md` — the same place `/ask-init`
|
|
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:
|
|
314
|
+
the two phases do not run on top of each other.
|
|
308
315
|
|
|
309
316
|
---
|
|
310
317
|
|
|
@@ -321,6 +328,11 @@ change record per finished round plus a one-sentence, user-facing description of
|
|
|
321
328
|
(`record_change`); the UAT side clusters many records into a few acceptance items — one
|
|
322
329
|
behaviour may need ten records, and one record may touch several behaviours.
|
|
323
330
|
|
|
331
|
+
**Requires the framework.** `/ask-uat` refuses unless the project has the framework state,
|
|
332
|
+
`AGENTS.md`, the memory contract and `.agents/implementations/`; run `/ask-init` first.
|
|
333
|
+
`record_change` is inactive in that state too. The check is feature-based, not byte-based:
|
|
334
|
+
your own edits to those files do not block the page.
|
|
335
|
+
|
|
324
336
|
```text
|
|
325
337
|
record_change (implementation) → /ask-uat (cluster) → browser (tick) → ledger
|
|
326
338
|
```
|
|
@@ -375,7 +387,7 @@ pi's `/compact` and auto-compact summarize the context **with the current sessio
|
|
|
375
387
|
| auto-compact threshold reached | summarized by the compaction model |
|
|
376
388
|
| context overflow recovery | summarized by the compaction model, retry behavior unchanged |
|
|
377
389
|
|
|
378
|
-
**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.
|
|
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.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):
|
|
379
391
|
|
|
380
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
|
|
381
393
|
- **Split behavior** — the `keepRecentTokens` retention policy, and `firstKeptEntryId` / `tokensBefore` passed back unchanged
|
|
@@ -456,7 +468,7 @@ An **identical command line** declared by both sources runs once: a duplicate is
|
|
|
456
468
|
|
|
457
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.
|
|
458
470
|
|
|
459
|
-
> **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.
|
|
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.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).
|
|
460
472
|
|
|
461
473
|
---
|
|
462
474
|
|
|
@@ -470,7 +482,7 @@ the split between three things that decay when mixed:
|
|
|
470
482
|
|
|
471
483
|
| Family | Location | Answers | Lifetime |
|
|
472
484
|
| --- | --- | --- | --- |
|
|
473
|
-
| **
|
|
485
|
+
| **spec** | `specs/` (roadmap `PLAN.md` + `<unit>.md`) | what to do, how it will be accepted | written before work, status updated at close |
|
|
474
486
|
| **memory** | `.agents/memory/` | what is known, decided, and why | long-lived; append and compact only |
|
|
475
487
|
| **evidence** | `.agents/implementations/` | what changed, when, with what proof | one record per change, never rewritten |
|
|
476
488
|
|
|
@@ -482,14 +494,33 @@ repository root stays readable: `AGENTS.md`, `specs/`, `design/`, `docs/`,
|
|
|
482
494
|
|
|
483
495
|
| Command | What it does |
|
|
484
496
|
| --- | --- |
|
|
485
|
-
| `/ask-init` | detect →
|
|
486
|
-
| `/ask-init plan [--deep]` | print the plan and write nothing (`--dry-run` is the same) |
|
|
487
|
-
| `/ask-init check` | audit the installed framework (read-only; writes only a runtime report under `.agents/framework/reports/`) |
|
|
497
|
+
| `/ask-init` | first run: detect → plan → confirm → move/scaffold/snapshot → dispatch; installed framework: refresh framework-owned text, then audit (no model turn) |
|
|
498
|
+
| `/ask-init plan [--deep]` | print the plan and write nothing (`--dry-run` is the same), including the framework-parity section |
|
|
499
|
+
| `/ask-init check` | audit the installed framework, including framework-vs-template parity (read-only; writes only a runtime report under `.agents/framework/reports/`) |
|
|
488
500
|
| `/ask-init roots` | sync the directories added with `pi-add-dir` into the framework state |
|
|
489
|
-
| `/ask-init refresh` | refresh
|
|
501
|
+
| `/ask-init refresh [--adopt]` | the refresh step on its own (also run by `/ask-init`): framework-owned files + the `AGENTS.md` workflow block; hand-edited files are left untouched. `--adopt` takes ownership of a legacy file that has no anchor, after you reviewed it |
|
|
490
502
|
| `/ask-init --yes` | skip the confirmation panel |
|
|
491
503
|
| `/ask-init --lang zh\|en` | rendering language for framework-generated files (per run; default: detected from the project's own docs) |
|
|
492
504
|
|
|
505
|
+
**Re-running is safe.** On an installed framework `/ask-init` first compares the
|
|
506
|
+
project's framework text with the version you are running: missing or behind
|
|
507
|
+
framework-owned files are refreshed, hand-edited files are left untouched, and
|
|
508
|
+
then the audit runs. If nothing drifted it says so and leaves framework files unchanged — no model
|
|
509
|
+
turn; the audit still writes its runtime report. After a package upgrade run `/ask-init` (or `/ask-init refresh`) and
|
|
510
|
+
`/reload` when the workflow block changed.
|
|
511
|
+
|
|
512
|
+
**What “installed” means for the ask loop**: `.agents/framework/state.toml`,
|
|
513
|
+
`AGENTS.md`, `.agents/memory/README.md` and `.agents/implementations/` exist. The
|
|
514
|
+
content is yours — small edits do not stop `/ask-uat` or `record_change`. Commands
|
|
515
|
+
that need the framework refuse with the missing list instead of guessing.
|
|
516
|
+
Mutating runs (including `refresh` and `roots`) refuse while `/ask`, a spec review
|
|
517
|
+
or the UAT page is active; `check` and `plan` stay available.
|
|
518
|
+
|
|
519
|
+
A project written by an older tool has no template anchor. `/ask-init` reports those
|
|
520
|
+
files as `I-FW-01` and leaves them alone because it cannot tell an old template from
|
|
521
|
+
your edit. Review one, then run `/ask-init refresh --adopt` to take ownership of the
|
|
522
|
+
current bytes; the next refresh updates them normally.
|
|
523
|
+
|
|
493
524
|
**What the mechanical half guarantees**:
|
|
494
525
|
|
|
495
526
|
1. **Snapshot first** — every path the run may write (including every file whose
|
|
@@ -520,13 +551,15 @@ unit spec verbatim. The default pass is conservative: install, fix mechanical
|
|
|
520
551
|
drift (tombstones, duplicated sections, appendix order), and record an over-budget
|
|
521
552
|
`AGENTS.md` as debt instead of rewriting prose; `--deep` opts into structural edits.
|
|
522
553
|
|
|
523
|
-
**Audit codes** (stable, so reports compare across runs):
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
`W-
|
|
527
|
-
appendix, `W-COV-01` open coverage rows, `W-
|
|
528
|
-
`W-ROOT-02` zero-byte root
|
|
529
|
-
`I-
|
|
554
|
+
**Audit codes** (stable, so reports compare across runs):
|
|
555
|
+
|
|
556
|
+
- **paths** — `E-PATH-01` bare legacy paths while a legacy directory still exists (a move would break them); `W-PATH-01` the same references once the legacy directories are gone.
|
|
557
|
+
- **structure and state** — `E-STATE-01` memory gitignored, `W-STATE-01` memory not yet committed, `E-STATE-02` state version mismatch, `E-INDEX-01` index ↔ file mismatch, `E-LINK-01` broken internal links, `E-CONTRACT-01` missing memory contract.
|
|
558
|
+
- **memory hygiene** — `W-BUDGET-01/02` `AGENTS.md` / memory file over budget, `W-DUP-01` the same section in two files, `W-ORDER-01` sections appended after the appendix, `W-COV-01` open coverage rows, `W-META-01` `FUTURE.md` entry without a trigger, `W-EVID-01` `FINISHED.md` entry without evidence, `W-PLAN-01` spec/spec-plan drift, `W-OVERRIDE-01` `AGENTS.override.md` shadowing the entry, `W-SCAFFOLD-01` unfilled `TODO(ask-init)` markers.
|
|
559
|
+
- **roots and retired dirs** — `W-ROOT-01` agent-only directory at the root, `W-ROOT-02` zero-byte root file, `W-ROOT-03` missing registered root, `W-ROOT-04` scope card too large, `W-TODO-01` retired `todos/` still present.
|
|
560
|
+
- **framework files** — `W-FW-01` managed file edited by hand, `W-FW-02` managed file missing or behind the installed template, `W-FW-03` workflow block missing/behind/malformed or hand-written without markers, `W-FW-04` required framework file missing, `I-FW-01` no template anchor (cannot tell a hand edit from older bytes; review and `refresh --adopt` if it is the framework’s own text).
|
|
561
|
+
- **acceptance** — `E-UAT-01` unparseable ledger line, `W-UAT-01` item points at a missing record, `W-UAT-02` candidate waiting too long, `W-UAT-03` item open too long, `W-REC-01` non-canonical change record, `I-UAT-01` acceptance ledger not installed.
|
|
562
|
+
- **info** — `I-AGENTS-01` `.agents/skills` present, `I-INSTALL-01` framework not installed yet.
|
|
530
563
|
|
|
531
564
|
**Multi-repository workspaces**: memory lives in the main repository only.
|
|
532
565
|
`pi-add-dir` injects each added root's `AGENTS.md` verbatim into every request, so a
|
|
@@ -570,6 +603,29 @@ Ctrl+Z suspend/resume both re-enter the TUI, and a live session must never be ki
|
|
|
570
603
|
trigger is deliberately limited to TUI mode: RPC/JSON/print stdout is machine-readable and is
|
|
571
604
|
never given terminal escape sequences.
|
|
572
605
|
|
|
606
|
+
**Two hangs, two layers.** The fire path above lives on the main event loop — which is exactly
|
|
607
|
+
what can also die: on 2026-11-13 the guard fired, wrote its report, printed "forcing exit" and
|
|
608
|
+
called `process.exit(0)` … and the process hung for 18 minutes in `futex_wait` with the pty
|
|
609
|
+
already deleted (the user had closed the terminal window to escape). Host code on the exit path
|
|
610
|
+
(`process.on("exit")` listeners, bundled graceful-fs patches, stdio flush) can deadlock
|
|
611
|
+
synchronously, and a `setTimeout` fallback cannot fire inside a dead loop. Therefore:
|
|
612
|
+
|
|
613
|
+
- **arm-time watchdog thread** — arming also starts a `worker_threads` worker that does not
|
|
614
|
+
live on the main loop. The main loop beats a 1 Hz heartbeat into shared memory; after the
|
|
615
|
+
deadline (plus a head start for the main-loop fire timer, which handles the common hangs with
|
|
616
|
+
full context: raw-mode probe, full report, terminal restore) the worker samples the heartbeat
|
|
617
|
+
twice. Still beating → the event loop is alive → it steps aside (the fire timer owns the
|
|
618
|
+
outcome, including its stray-marker protection). Stopped → the main loop can never fire → the
|
|
619
|
+
worker restores the terminal, writes a minimal `-thread.json` report and SIGKILLs. This also
|
|
620
|
+
covers the blind spot where the main thread deadlocks *before* the fire deadline — e.g.
|
|
621
|
+
synchronously inside `process.exit` right after a fast dispose — because the worker never
|
|
622
|
+
needed the main loop in the first place. Every disarm (TUI restart, Ctrl+Z resume, `/reload`)
|
|
623
|
+
cancels the worker, so a returning TUI is never killed.
|
|
624
|
+
- **fire-time hard kill** — after the report is on disk and "forcing exit" printed, fire()
|
|
625
|
+
starts a second worker that unconditionally SIGKILLs 500 ms later; `process.exit(0)` and a
|
|
626
|
+
same-loop `setTimeout` SIGKILL run before it, so the worker only matters when the main thread
|
|
627
|
+
is blocked inside the exit path (the exact 2026-11-13 shape).
|
|
628
|
+
|
|
573
629
|
### Commands
|
|
574
630
|
|
|
575
631
|
| Command | Effect |
|
|
@@ -604,7 +660,8 @@ arguments are redacted with the same rules as the approval log, so `pi --api-key
|
|
|
604
660
|
leave the key on disk.
|
|
605
661
|
|
|
606
662
|
`PI_QUIT_GUARD_DEBUG=<file>` appends one line per `arm` / `disarm` / `fire` (plus one per
|
|
607
|
-
extension registration); once the TUI is gone it is the only channel left.
|
|
663
|
+
extension registration); once the TUI is gone it is the only channel left. A thread-watchdog
|
|
664
|
+
kill appends `thread-kill heartbeat-stopped …` there.
|
|
608
665
|
|
|
609
666
|
### Boundaries
|
|
610
667
|
|
|
@@ -614,8 +671,11 @@ extension registration); once the TUI is gone it is the only channel left.
|
|
|
614
671
|
(not observed; `drainInput` is bounded at 1 s) is out of scope.
|
|
615
672
|
- When it fires, the remaining extension cleanup is skipped **by design** — that cleanup is what
|
|
616
673
|
was hanging. Session entries are appended to the session JSONL as they happen, so the
|
|
617
|
-
transcript is intact up to the last written entry. The process exits 0; if
|
|
618
|
-
itself
|
|
674
|
+
transcript is intact up to the last written entry. The process exits 0; if the exit path
|
|
675
|
+
itself deadlocks (observed for real: host `exit` listeners, stdio flush), the layered
|
|
676
|
+
fallbacks — same-loop `setTimeout` SIGKILL, then the watchdog/hard-kill worker threads — end
|
|
677
|
+
the process anyway. A worker cannot be constructed only under resource exhaustion; the guard
|
|
678
|
+
then degrades to the behavior it had before the thread layers existed.
|
|
619
679
|
- This is a workaround for a host gap. If pi ever bounds `session_shutdown`, the guard becomes
|
|
620
680
|
a no-op safety net and can be removed.
|
|
621
681
|
|
|
@@ -683,14 +743,21 @@ src/
|
|
|
683
743
|
│ # tests
|
|
684
744
|
├── favorites/ # model favorites: selector + cycle patches,
|
|
685
745
|
│ # persisted store, tests
|
|
746
|
+
├── init/ # agent memory framework: detect/plan/apply/audit,
|
|
747
|
+
│ # template parity + refresh, workflow markers,
|
|
748
|
+
│ # templates, tests
|
|
686
749
|
├── permission/ # session-scoped boundary permission: modes, panel,
|
|
687
750
|
│ # bash units, policy, session grants, prompt,
|
|
688
751
|
│ # audit payload, tests
|
|
752
|
+
├── spec/ # browser-reviewed specs: phases, block diff,
|
|
753
|
+
│ # review server, UI, tests
|
|
689
754
|
├── quit-guard/ # quit watchdog: TUI teardown + quit-event triggers,
|
|
690
755
|
│ # settings store, hang report, tests
|
|
691
|
-
├── review/ # third-party review:
|
|
756
|
+
├── review/ # third-party review: command trigger,
|
|
692
757
|
│ # review model config store, prompt, tests
|
|
693
758
|
├── stash/ # prompt stash: hotkey state machine + tests
|
|
759
|
+
├── uat/ # acceptance ledger: records/ledger, page server,
|
|
760
|
+
│ # record_change + uat_item, UI, tests
|
|
694
761
|
└── whats-new/ # release notes after an upgrade: CHANGELOG parser,
|
|
695
762
|
# last-seen store, startup notice, tests
|
|
696
763
|
```
|
package/README.zh-CN.md
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
[](https://github.com/earendil-works/pi)
|
|
14
14
|
[](https://github.com/andares/pi-toolkits)
|
|
15
15
|
|
|
16
|
-
一句话介绍:目前包含十二个开箱即用的功能——**只读咨询模式** `ask`、**会话级边界权限** `ask-perm`、**模型收藏** `favorites`、**提示词暂存** `stash`、**第三方代码评审** `ask-review`、**独立压缩模型** `compact-model`、**会话启动自动化** `autostart`、**agent 记忆框架** `ask-init
|
|
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.
|
|
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 会告警。
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
@@ -76,11 +76,11 @@ 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
|
-
| 🧭 **
|
|
80
|
-
| ✅ **uat** 验收台账 | `/ask-uat` |
|
|
79
|
+
| 🧭 **spec** 浏览器内规格评审 | `/ask-spec` | 先调研、写 spec、在浏览器里逐段评审并逐块批注,批准之后才动代码 |
|
|
80
|
+
| ✅ **uat** 验收台账 | `/ask-uat` | `/ask-init` 之后:把待归类的实施记录聚成用户视角的验收项,在页面里勾选(只追加、无提交),看清哪些已交付但还没验过 |
|
|
81
81
|
| 🗜️ **compact** 独立压缩模型 | `/compact-model` | 给 `/compact` 与 auto-compact 配一个便宜快模型做总结,主模型专注对话;未配置零开销、任何异常回落 pi 默认 |
|
|
82
82
|
| 🚀 **autostart** 会话启动自动化 | `.pi/autostart.toml` | 项目内声明启动时自动执行的斜杠命令(首批用例:`/add-dir` 多仓库挂载);未信任不执行、未注册命令跳过不发给模型 |
|
|
83
|
-
| 🧠 **init** agent 记忆框架 | `/ask-init` | 安装或接管一套固定的记忆结构(`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`)
|
|
83
|
+
| 🧠 **init** agent 记忆框架 | `/ask-init` | 安装或接管一套固定的记忆结构(`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`),带快照与覆盖表迁移旧文档,之后可随时审计/刷新漂移、预算与重复事实 |
|
|
84
84
|
| 🧯 **quit-guard** 退出看门狗 | `/quit-guard` | 交互式退出卡死时,无论发生在 TUI 收尾之后、还是信号触发路径的收尾之前,超时后写诊断报告并强制退出,把命令行提示符还给你;TUI 重启与 Ctrl+Z 恢复都会解除看守 |
|
|
85
85
|
| 🆕 **whats-new** 升级后的版本变更提示 | 自动 | 升级后的首次 `pi` 启动展示「从你上次运行的版本到现在改了什么」,只展示一次;不注册斜杠命令,不占用宿主的全局命令命名空间 |
|
|
86
86
|
|
|
@@ -92,6 +92,8 @@ pi -e ./src/index.ts
|
|
|
92
92
|
|
|
93
93
|
用 `/ask` 进入(再按一次退出)。适合只想要「问问题、读代码」的场景:模型不能改项目,但不会被剥夺思考的落点。
|
|
94
94
|
|
|
95
|
+
ask 是独立的(不需要 `/ask-init`)。规格评审或 UAT 页面开着时先退出它们——ask 不会叠在另一个相位上启动,因为那个相位的 `before_agent_start` 会把写工具重新加回来。
|
|
96
|
+
|
|
95
97
|
**进入后**:
|
|
96
98
|
|
|
97
99
|
- **项目文件写入仍然机制上不可能** —— `write` / `edit` / `powershell` 从活跃工具集中移除,pi 对未激活工具的调用直接拒绝("Tool not found");闸门还会二次拦截,防止有东西把它们重新打开
|
|
@@ -279,32 +281,36 @@ run = ["/ask-perm allow allow allow ask"]
|
|
|
279
281
|
|
|
280
282
|
- **未配置 / 配置的模型已不可用**(如在 pi 的 models.json 里删掉了该模型)→ 提示后照常弹出列表(此时无默认项)
|
|
281
283
|
- 任务仍在进行中(agent 未空闲)时触发 → 提示等待,不执行;同一时间只允许一个评审
|
|
284
|
+
- 规格评审期 → 拒绝(评审中的 spec 不能被改);ask 模式会自动退出,因为查+修需要完整工具集
|
|
282
285
|
- footer 出现灰色 `review` 状态 = 已配置评审模型
|
|
283
286
|
|
|
284
287
|
---
|
|
285
288
|
|
|
286
|
-
## 🧭
|
|
289
|
+
## 🧭 spec — 先写规格,浏览器里评审,批准后再动手
|
|
287
290
|
|
|
288
|
-
<a name="
|
|
291
|
+
<a name="spec"></a>
|
|
289
292
|
|
|
290
|
-
`/ask-
|
|
293
|
+
`/ask-spec [主题]` 进入规格评审期:模型先调研、把代码里看不出来的问题问清楚,然后写一份 spec——评审期间不改代码。写完调用 `spec_submit`,评审页在**你的浏览器**里打开,你**逐段**批注:每个空行分隔的块都可以挂批注,批注会作为下一条消息回到模型。`/ask-plan` 保留为别名。
|
|
291
294
|
|
|
292
|
-
- **块是评审单位。**
|
|
293
|
-
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
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` 是唯一会切模型的命令,那是你要求的。)
|
|
298
302
|
|
|
299
|
-
**WSL
|
|
303
|
+
**WSL 下的浏览器**:评审服务器绑 `0.0.0.0`,URL 用 WSL 的地址打印,因为 Windows 连不到 WSL 里只绑 loopback 的服务器。打开器优先用 Windows 侧启动器(`wslview`、`cmd.exe /c start`、`powershell Start-Process`),其它平台才回落到 `xdg-open`——这决定了是「打开你的浏览器」还是「在 WSL 里打开一个你看不见的浏览器」。
|
|
300
304
|
|
|
301
305
|
```text
|
|
302
|
-
/ask-
|
|
303
|
-
/ask-
|
|
304
|
-
/ask-
|
|
306
|
+
/ask-spec 做导出功能 # 进入规格评审
|
|
307
|
+
/ask-spec open # 重新打开评审页
|
|
308
|
+
/ask-spec off # 退出评审期(草稿留在原处)
|
|
305
309
|
```
|
|
306
310
|
|
|
307
|
-
spec 落在 `specs/<slug>.md
|
|
311
|
+
spec 落在 `specs/<slug>.md`——与 `/ask-init` 放 spec 的地方相同。没有 agent 框架时评审仍可用,
|
|
312
|
+
但 `record_change` 与 `/ask-uat` 不可用,直到 `/ask-init`;命令在评审开始时会说明。
|
|
313
|
+
UAT 页面开着时先退出:两个相位不叠在一起跑。
|
|
308
314
|
|
|
309
315
|
---
|
|
310
316
|
|
|
@@ -320,6 +326,10 @@ spec 落在 `specs/<slug>.md`,与 `/ask-init` 的计划同一个位置。
|
|
|
320
326
|
附一句「用户视角能做什么」;UAT 侧把多条记录聚成少数验收项——一条行为可能要十条记录,
|
|
321
327
|
一条记录也可能碰到多个行为。
|
|
322
328
|
|
|
329
|
+
**需要框架。** 项目缺少框架状态、`AGENTS.md`、记忆合同或 `.agents/implementations/` 时,
|
|
330
|
+
`/ask-uat` 直接拒绝;先跑 `/ask-init`。此时 `record_change` 也不可用。判定按特征而非字节:
|
|
331
|
+
你对这些文件的小改不会挡住页面。
|
|
332
|
+
|
|
323
333
|
```text
|
|
324
334
|
record_change(实施)→ /ask-uat(聚类)→ 浏览器(勾选)→ 台账
|
|
325
335
|
```
|
|
@@ -370,7 +380,7 @@ pi 的 `/compact` 与 auto-compact 默认**用当前会话模型**做上下文
|
|
|
370
380
|
| auto-compact 阈值触发 | 压缩模型总结 |
|
|
371
381
|
| context overflow 恢复 | 压缩模型总结,重试行为不变 |
|
|
372
382
|
|
|
373
|
-
**接管后与 pi 内建行为完全一致的部分**(逐字同步 pi 内建实现,复制自 0.87.1、在 1.2.0 → 1.5.
|
|
383
|
+
**接管后与 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 回填进摘要请求):
|
|
374
384
|
|
|
375
385
|
- **摘要格式** —— Goal / Progress / Key Decisions 结构化 checkpoint;已有摘要时用迭代更新版 prompt,信息延续不丢
|
|
376
386
|
- **切分行为** —— 保留最近 `keepRecentTokens` 的策略、`firstKeptEntryId` / `tokensBefore` 原样回传,不动
|
|
@@ -451,7 +461,7 @@ run = [
|
|
|
451
461
|
|
|
452
462
|
**关键约束:只支持扩展命令**。`/add-dir`(pi-add-dir)、`/cd`(pi-cd)等 `registerCommand` 注册的命令可以;内置命令(`/compact`、`/reload`、`/resume`…)在 TUI 层分发,扩展层触发不了;skill 命令(`/skill:name`)是展开机制而非执行机制。依赖的目标扩展(如 pi-add-dir)需要先安装。
|
|
453
463
|
|
|
454
|
-
> **实现说明**:执行用 `sendUserMessage(cmd, { expandPromptTemplates: true })` —— 该选项把 `/cmd args` 路由到命令分发而不是模型 prompt 路径(包装层默认 `false`;`_tryExecuteExtensionCommand` 在 1.2.0–1.5.
|
|
464
|
+
> **实现说明**:执行用 `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)。
|
|
455
465
|
|
|
456
466
|
---
|
|
457
467
|
|
|
@@ -475,13 +485,28 @@ run = [
|
|
|
475
485
|
|
|
476
486
|
| 命令 | 作用 |
|
|
477
487
|
| --- | --- |
|
|
478
|
-
| `/ask-init` |
|
|
479
|
-
| `/ask-init plan [--deep]` |
|
|
480
|
-
| `/ask-init check` |
|
|
488
|
+
| `/ask-init` | 首次:检测 → 出计划 → 确认 → 移动/脚手架/快照 → 派发;已安装:先刷新框架文字,再审计(不派模型) |
|
|
489
|
+
| `/ask-init plan [--deep]` | 只打印计划,不写任何盘(`--dry-run` 同义),含框架对等检查段 |
|
|
490
|
+
| `/ask-init check` | 审计已装的框架,含框架文字与模板的对等检查(只读;只在 `.agents/framework/reports/` 留下运行期报告) |
|
|
481
491
|
| `/ask-init roots` | 把 `pi-add-dir` 添加的目录同步进框架状态 |
|
|
482
|
-
| `/ask-init refresh` |
|
|
492
|
+
| `/ask-init refresh [--adopt]` | 单独执行刷新(`/ask-init` 也会跑):框架拥有文件 + `AGENTS.md` 里的工作流块;手工改过的文件一概不动。`--adopt` 在你核对过之后,把没有锚的旧文件认作框架拥有并接管 |
|
|
483
493
|
| `/ask-init --yes` | 跳过确认面板 |
|
|
484
|
-
| `/ask-init --lang zh\|en` |
|
|
494
|
+
| `/ask-init --lang zh\|en` | 框架生成文件的渲染语言(单次生效;默认按项目自身文档判定) |
|
|
495
|
+
|
|
496
|
+
**重复运行是安全的。** 已安装框架时,`/ask-init` 先对比项目里的框架文字与当前版本:
|
|
497
|
+
缺失或落后的框架拥有文件会刷新,手工改过的保持原状,然后跑审计。没有任何漂移时
|
|
498
|
+
会明确说「已是最新」,不修改框架文件——也不会派模型回合(审计仍写运行期报告)。升级包之后运行 `/ask-init`
|
|
499
|
+
(或 `/ask-init refresh`),工作流块变了再 `/reload`。
|
|
500
|
+
|
|
501
|
+
**ask 循环说的「已安装」**:`.agents/framework/state.toml`、`AGENTS.md`、
|
|
502
|
+
`.agents/memory/README.md`、`.agents/implementations/` 存在。内容是用户的——小改
|
|
503
|
+
不会让 `/ask-uat` 或 `record_change` 拒绝;需要框架的命令会把缺失项列出来。
|
|
504
|
+
mutating 运行(含 `refresh`、`roots`)在 `/ask`、规格评审或 UAT 页面开着时拒绝;
|
|
505
|
+
`check` 与 `plan` 仍可用。
|
|
506
|
+
|
|
507
|
+
旧工具写的项目没有模板锚。`/ask-init` 把这些文件报成 `I-FW-01` 并保持原状——它分不清
|
|
508
|
+
旧模板和你的手改。核对一份之后运行 `/ask-init refresh --adopt` 接管当前字节;之后的
|
|
509
|
+
refresh 就会正常更新它。
|
|
485
510
|
|
|
486
511
|
**机械那一半保证什么**:
|
|
487
512
|
|
|
@@ -504,11 +529,15 @@ run = [
|
|
|
504
529
|
装框架、修机械漂移(墓碑、重复章节、附录顺序),超预算的 `AGENTS.md` 只登记成债务;
|
|
505
530
|
`--deep` 才允许结构性改写。
|
|
506
531
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
`
|
|
510
|
-
`
|
|
511
|
-
`W-SCAFFOLD-01` 未填的 `TODO(ask-init)`
|
|
532
|
+
**审计码**(稳定,可跨次对比):
|
|
533
|
+
|
|
534
|
+
- **路径** —— `E-PATH-01` 旧目录仍存在时的裸旧路径(移动会断);`W-PATH-01` 旧目录已不存在时的同类引用。
|
|
535
|
+
- **结构与状态** —— `E-STATE-01` 记忆被 gitignore、`W-STATE-01` 记忆尚未提交、`E-STATE-02` 状态版本不符、`E-INDEX-01` 索引与实际文件不一致、`E-LINK-01` 内部链接失效、`E-CONTRACT-01` 缺记忆合同。
|
|
536
|
+
- **记忆卫生** —— `W-BUDGET-01/02` `AGENTS.md` / 记忆文件超预算、`W-DUP-01` 同一章节出现在两个文件、`W-ORDER-01` 附录之后又追加章节、`W-COV-01` 覆盖表仍有 OPEN、`W-META-01` `FUTURE.md` 条目缺触发条件、`W-EVID-01` `FINISHED.md` 条目缺证据、`W-PLAN-01` spec / 计划漂移、`W-OVERRIDE-01` `AGENTS.override.md` 顶替入口、`W-SCAFFOLD-01` 未填的 `TODO(ask-init)` 标记。
|
|
537
|
+
- **根与退役目录** —— `W-ROOT-01` 根下 agent-only 目录、`W-ROOT-02` 根下零字节文件、`W-ROOT-03` 登记的 root 缺失、`W-ROOT-04` scope card 过大、`W-TODO-01` 仍存在退役的 `todos/`。
|
|
538
|
+
- **框架文件** —— `W-FW-01` 受管文件被手工改过、`W-FW-02` 受管文件缺失或落后于当前模板、`W-FW-03` 工作流块缺失/落后/marker 不一致/手写无 marker、`W-FW-04` 必需框架文件缺失、`I-FW-01` 无模板锚(无法区分手工编辑与旧模板;核对是框架原文后跑 `refresh --adopt`)。
|
|
539
|
+
- **验收** —— `E-UAT-01` 台账行不可解析、`W-UAT-01` 项指向不存在的记录、`W-UAT-02` 候选等待过久、`W-UAT-03` 项超 30 天未勾、`W-REC-01` 近期记录首行/文件名不合规、`I-UAT-01` 验收台账未安装。
|
|
540
|
+
- **信息** —— `I-AGENTS-01` `.agents/skills` 存在、`I-INSTALL-01` 尚未安装框架。
|
|
512
541
|
|
|
513
542
|
**多仓库工作区**:记忆只住主仓。`pi-add-dir` 会把每个 added root 的 `AGENTS.md`
|
|
514
543
|
全文注入每次请求,所以根里的入口只能是 **scope card**(≤30 行:这里放什么、它的命令、
|
|
@@ -610,14 +639,21 @@ src/
|
|
|
610
639
|
│ # /compact-model、配置存储、prompt、测试
|
|
611
640
|
├── favorites/ # 模型收藏:选择器与循环 patch、
|
|
612
641
|
│ # 持久化存储、测试
|
|
642
|
+
├── init/ # agent 记忆框架:检测/计划/应用/审计、
|
|
643
|
+
│ # 模板对等检查 + refresh、工作流 marker、
|
|
644
|
+
│ # 模板、测试
|
|
613
645
|
├── permission/ # 会话级边界权限:模式、面板、bash 拆解、
|
|
614
646
|
│ # 策略、会话授权、确认对话框、
|
|
615
647
|
│ # 审计 payload、测试
|
|
648
|
+
├── spec/ # 浏览器内规格评审:相位、块级 diff、
|
|
649
|
+
│ # 评审服务器、UI、测试
|
|
616
650
|
├── quit-guard/ # 退出看门狗:TUI 收尾 + quit 事件双触发、
|
|
617
651
|
│ # 配置存储、诊断报告、测试
|
|
618
|
-
├── review/ #
|
|
652
|
+
├── review/ # 第三方评审:指令触发、
|
|
619
653
|
│ # 评审模型配置存储、提示词、测试
|
|
620
654
|
├── stash/ # 提示词暂存:热键状态机 + 测试
|
|
655
|
+
├── uat/ # 验收台账:记录/台账、页面服务器、
|
|
656
|
+
│ # record_change + uat_item、UI、测试
|
|
621
657
|
└── whats-new/ # 升级后的版本变更提示:CHANGELOG 解析、
|
|
622
658
|
# 已见版本存储、启动提示、测试
|
|
623
659
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andares/pi-toolkits",
|
|
3
|
-
"version": "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",
|
|
3
|
+
"version": "1.0.1",
|
|
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",
|
|
7
7
|
"repository": {
|
|
@@ -36,10 +36,17 @@
|
|
|
36
36
|
"memory-framework",
|
|
37
37
|
"scaffold",
|
|
38
38
|
"init",
|
|
39
|
+
"ask-init",
|
|
40
|
+
"spec",
|
|
41
|
+
"spec-review",
|
|
42
|
+
"ask-spec",
|
|
39
43
|
"uat",
|
|
44
|
+
"ask-uat",
|
|
40
45
|
"acceptance",
|
|
41
46
|
"acceptance-testing",
|
|
42
47
|
"change-record",
|
|
48
|
+
"quit-guard",
|
|
49
|
+
"watchdog",
|
|
43
50
|
"whats-new",
|
|
44
51
|
"release-notes",
|
|
45
52
|
"changelog"
|
|
@@ -76,7 +83,7 @@
|
|
|
76
83
|
"ui:dev": "pnpm --filter @andares/pi-toolkits-ui dev",
|
|
77
84
|
"ui:build": "pnpm --filter @andares/pi-toolkits-ui build",
|
|
78
85
|
"ui:typecheck": "pnpm --filter @andares/pi-toolkits-ui typecheck",
|
|
79
|
-
"ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/
|
|
86
|
+
"ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/spec/assets src/features/uat/assets)\""
|
|
80
87
|
},
|
|
81
88
|
"pi": {
|
|
82
89
|
"extensions": [
|
|
@@ -95,6 +95,9 @@ function makeHarness(options: { scratchBaseDir?: string } = {}) {
|
|
|
95
95
|
notes,
|
|
96
96
|
activeTools: () => activeTools,
|
|
97
97
|
registeredTool: () => registeredTool,
|
|
98
|
+
setActiveTools: (names: string[]) => {
|
|
99
|
+
activeTools = [...names];
|
|
100
|
+
},
|
|
98
101
|
setSessionId: (id: string) => {
|
|
99
102
|
sessionId = id;
|
|
100
103
|
},
|
|
@@ -120,6 +123,18 @@ beforeEach(() => {
|
|
|
120
123
|
});
|
|
121
124
|
|
|
122
125
|
describe("ask gate", () => {
|
|
126
|
+
it("refuses to enter while a plan or UAT phase is active", async () => {
|
|
127
|
+
const h = makeHarness({ scratchBaseDir: tempBase() });
|
|
128
|
+
h.setActiveTools(["read", "write", "edit", "bash", "spec_submit"]);
|
|
129
|
+
await h.toggle();
|
|
130
|
+
expect(h.notes.some((note) => /ask-spec/.test(note.message))).toBe(true);
|
|
131
|
+
expect(h.activeTools()).not.toContain(ASK_SCRATCH_TOOL);
|
|
132
|
+
|
|
133
|
+
h.setActiveTools(["read", "write", "edit", "bash", "uat_item"]);
|
|
134
|
+
await h.toggle();
|
|
135
|
+
expect(h.notes.some((note) => /ask-uat/.test(note.message))).toBe(true);
|
|
136
|
+
expect(h.activeTools()).not.toContain(ASK_SCRATCH_TOOL);
|
|
137
|
+
});
|
|
123
138
|
it("has no opinion while ask mode is off", async () => {
|
|
124
139
|
const h = makeHarness({ scratchBaseDir: tempBase() });
|
|
125
140
|
expect(await h.evaluate("write", { path: "x" })).toBeUndefined();
|