@andares/pi-toolkits 0.12.3 → 0.13.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.
- package/README.md +100 -15
- package/README.zh-CN.md +94 -14
- package/package.json +19 -10
- package/src/features/ask/index.ts +6 -0
- package/src/features/init/apply.ts +32 -12
- package/src/features/init/audit-uat.test.ts +103 -0
- package/src/features/init/audit.ts +148 -0
- package/src/features/init/detect.ts +4 -0
- package/src/features/init/index.ts +47 -2
- package/src/features/init/plan.ts +11 -0
- package/src/features/init/refresh.test.ts +208 -0
- package/src/features/init/refresh.ts +255 -0
- package/src/features/init/spec.ts +20 -0
- package/src/features/init/templates/agents-skeleton.md +2 -0
- package/src/features/init/templates/uat-readme.md +53 -0
- package/src/features/init/templates/workflow-block.md +21 -0
- package/src/features/init/templates.test.ts +3 -1
- package/src/features/init/templates.ts +2 -0
- package/src/features/init/types.ts +12 -1
- package/src/features/permission/index.ts +32 -0
- package/src/features/plan/assets/index-C1YLIi4I.js +1 -0
- package/src/features/plan/assets/index-DMEpYC3V.css +1 -0
- package/src/features/plan/assets/index.html +14 -0
- package/src/features/plan/assets.test.ts +64 -0
- package/src/features/plan/blocks.test.ts +77 -0
- package/src/features/plan/blocks.ts +153 -0
- package/src/features/plan/diff.test.ts +144 -0
- package/src/features/plan/diff.ts +193 -0
- package/src/features/plan/feedback.test.ts +233 -0
- package/src/features/plan/feedback.ts +182 -0
- package/src/features/plan/index.test.ts +385 -0
- package/src/features/plan/index.ts +433 -0
- package/src/features/plan/prompt.test.ts +91 -0
- package/src/features/plan/prompt.ts +110 -0
- package/src/features/plan/render.test.ts +94 -0
- package/src/features/plan/render.ts +131 -0
- package/src/features/plan/server.test.ts +374 -0
- package/src/features/plan/server.ts +272 -0
- package/src/features/plan/store.test.ts +145 -0
- package/src/features/plan/store.ts +244 -0
- package/src/features/review/index.ts +54 -28
- package/src/features/review/review.test.ts +46 -1
- package/src/features/uat/assets/index-D-W9zj0w.css +1 -0
- package/src/features/uat/assets/index-DCBQCsli.js +1 -0
- package/src/features/uat/assets/index.html +14 -0
- package/src/features/uat/constants.ts +23 -0
- package/src/features/uat/index.test.ts +404 -0
- package/src/features/uat/index.ts +329 -0
- package/src/features/uat/item-tool.ts +280 -0
- package/src/features/uat/ledger.test.ts +249 -0
- package/src/features/uat/ledger.ts +504 -0
- package/src/features/uat/prompt.ts +78 -0
- package/src/features/uat/record-tool.ts +167 -0
- package/src/features/uat/records.test.ts +145 -0
- package/src/features/uat/records.ts +268 -0
- package/src/features/uat/server.ts +181 -0
- package/src/features/uat/state.test.ts +41 -0
- package/src/features/uat/state.ts +67 -0
- package/src/index.ts +10 -1
- package/src/lib/ask-control.ts +25 -0
- package/src/lib/opener.test.ts +72 -0
- package/src/lib/opener.ts +121 -0
- package/src/lib/permission-control.ts +39 -0
- package/src/lib/startup.test.ts +1 -1
- package/src/lib/web-review.ts +341 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
[](https://github.com/earendil-works/pi)
|
|
14
14
|
[](https://github.com/andares/pi-toolkits)
|
|
15
15
|
|
|
16
|
-
In a nutshell:
|
|
16
|
+
In a nutshell: eleven 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`, and a **quit watchdog** `quit-guard` — 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 `/
|
|
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
|
---
|
|
@@ -74,7 +74,9 @@ After installing, verify in any pi session:
|
|
|
74
74
|
| 🔐 **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
75
|
| ⭐ **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
76
|
| 📥 **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 | `/
|
|
77
|
+
| 🔎 **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" |
|
|
78
|
+
| 🧭 **plan** browser-reviewed planning | `/ask-plan` | research first, write a spec, review it in your browser paragraph by paragraph, annotate block by block, then implement only after approval |
|
|
79
|
+
| ✅ **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
80
|
| 🗜️ **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
81
|
| 🚀 **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
82
|
| 🧠 **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 |
|
|
@@ -247,9 +249,9 @@ When the stash is empty, a single press means "stash + clear". The stash is **in
|
|
|
247
249
|
|
|
248
250
|
<a name="review"></a>
|
|
249
251
|
|
|
250
|
-
After a development task is done, type the `/
|
|
252
|
+
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
253
|
|
|
252
|
-
> **Command-triggered only**: only `/
|
|
254
|
+
> **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
255
|
|
|
254
256
|
**The review prompt focuses on three checks** (each gets an explicit verdict):
|
|
255
257
|
|
|
@@ -259,9 +261,9 @@ After a development task is done, type the `/third-review` command to summon **a
|
|
|
259
261
|
|
|
260
262
|
**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
263
|
|
|
262
|
-
**Choosing the review model** (every `/
|
|
264
|
+
**Choosing the review model** (every `/ask-review` opens a picker):
|
|
263
265
|
|
|
264
|
-
- `/
|
|
266
|
+
- `/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
267
|
- **Pick another model** → written back to the config immediately (**both on disk and in memory**), and **that model becomes the default next time**
|
|
266
268
|
- **Cancel** (Esc) → no review is run, the config is unchanged
|
|
267
269
|
- The config is persisted in `<agent-dir>/pi-toolkits-review.json` (defaults to `~/.pi/agent/`):
|
|
@@ -270,13 +272,92 @@ After a development task is done, type the `/third-review` command to summon **a
|
|
|
270
272
|
{ "model": "anthropic/claude-sonnet-4" }
|
|
271
273
|
```
|
|
272
274
|
|
|
273
|
-
- `/review-model` — a separate config entry point: opens the same list (without changing the session model, only updating the default config)
|
|
274
275
|
- **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
276
|
- 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
277
|
- A grey `review` status in the footer means a review model is configured
|
|
277
278
|
|
|
278
279
|
---
|
|
279
280
|
|
|
281
|
+
## 🧭 plan — plan first, review in the browser, then implement
|
|
282
|
+
|
|
283
|
+
<a name="plan"></a>
|
|
284
|
+
|
|
285
|
+
`/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.
|
|
286
|
+
|
|
287
|
+
- **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.
|
|
288
|
+
- **Two levels of notes.** On a block, or global. Nothing finer — no text ranges to re-anchor after an edit.
|
|
289
|
+
- **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".
|
|
290
|
+
- **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.
|
|
291
|
+
- **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.
|
|
292
|
+
- **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.)
|
|
293
|
+
|
|
294
|
+
**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".
|
|
295
|
+
|
|
296
|
+
```text
|
|
297
|
+
/ask-plan build the export feature # start planning
|
|
298
|
+
/ask-plan open # re-open the review page
|
|
299
|
+
/ask-plan off # leave the phase (the draft stays where it is)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
The spec lands in `specs/<slug>.md` — the same place `/ask-init` puts plans.
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## ✅ uat — acceptance ledger and browser page
|
|
307
|
+
|
|
308
|
+
<a name="uat"></a>
|
|
309
|
+
|
|
310
|
+
`/ask-uat` answers exactly one question: **what did I ship that I have not verified yet?**
|
|
311
|
+
It exists because agent-driven development produces more behaviour changes per week than
|
|
312
|
+
anyone can remember, and "I will test it later" is how acceptance debt turns into rework.
|
|
313
|
+
|
|
314
|
+
The unit of acceptance is a **behaviour**, not a commit. An implementation session writes one
|
|
315
|
+
change record per finished round plus a one-sentence, user-facing description of that behaviour
|
|
316
|
+
(`record_change`); the UAT side clusters many records into a few acceptance items — one
|
|
317
|
+
behaviour may need ten records, and one record may touch several behaviours.
|
|
318
|
+
|
|
319
|
+
```text
|
|
320
|
+
record_change (implementation) → /ask-uat (cluster) → browser (tick) → ledger
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
| Command | What it does |
|
|
324
|
+
| --- | --- |
|
|
325
|
+
| `/ask-uat` | cluster pending change records into acceptance items, then open the page |
|
|
326
|
+
| `/ask-uat open` | reopen the page without a model turn |
|
|
327
|
+
| `/ask-uat off` | stop the page server |
|
|
328
|
+
|
|
329
|
+
**The page** lists open items newest-first. Each item carries a 2-3 sentence summary and an
|
|
330
|
+
expandable test plan (steps, edge cases, what not to test). Ticking an item appends a `check`
|
|
331
|
+
event immediately — there is no submit, and closing the page cannot lose a decision. Accepted
|
|
332
|
+
items fold into a section you can expand to undo a tick; the evidence records are one click
|
|
333
|
+
away in a drawer.
|
|
334
|
+
|
|
335
|
+
**The rules that keep it honest**:
|
|
336
|
+
|
|
337
|
+
- **Append-only ledger, no submit.** `.agents/uat/ledger.jsonl` is an event stream (`candidate`,
|
|
338
|
+
`batch`, `item`, `link`, `check`, `uncheck`, `amend`, `merge`, `drop`), committed to git,
|
|
339
|
+
deduplicated by event id, and safe for two processes appending at once (no lock, no merge).
|
|
340
|
+
- **New evidence reopens an item.** If a change record lands after the tick, the item shows
|
|
341
|
+
`reopened`: "accepted" means "accepted against the current evidence set".
|
|
342
|
+
- **The ledger belongs to the main checkout.** A session running in a linked git worktree writes
|
|
343
|
+
its records and events to the main checkout, so acceptance history never splits.
|
|
344
|
+
- **The directory is the fallback index.** A change record written by hand still shows up as
|
|
345
|
+
pending; `record_change` adds the behaviour sentence and the test hint, but it is not a gate.
|
|
346
|
+
- **Nothing else.** No editing, no ordering, no comments, no assignment. If clustering is wrong,
|
|
347
|
+
ask the agent in chat — it has `uat_item` (link / amend / merge / drop) while the page is open.
|
|
348
|
+
|
|
349
|
+
**Change-record format** (what `record_change` writes):
|
|
350
|
+
|
|
351
|
+
```text
|
|
352
|
+
.agents/implementations/YYYY-MM-DD_HHMM_<slug>.md
|
|
353
|
+
# YYYY-MM-DDTHH:MM±HH:MM — title
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Older records (`YYYY-MM-DD_<slug>.md`, second-precision headers) keep working: the reader is
|
|
357
|
+
lenient, only the writer is strict. The audit reports new non-canonical records as `W-REC-01`.
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
280
361
|
## 🗜️ compact — dedicated compaction model
|
|
281
362
|
|
|
282
363
|
<a name="compact"></a>
|
|
@@ -400,6 +481,7 @@ repository root stays readable: `AGENTS.md`, `specs/`, `design/`, `docs/`,
|
|
|
400
481
|
| `/ask-init plan [--deep]` | print the plan and write nothing (`--dry-run` is the same) |
|
|
401
482
|
| `/ask-init check` | audit the installed framework (read-only; writes only a runtime report under `.agents/framework/reports/`) |
|
|
402
483
|
| `/ask-init roots` | sync the directories added with `pi-add-dir` into the framework state |
|
|
484
|
+
| `/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
485
|
| `/ask-init --yes` | skip the confirmation panel |
|
|
404
486
|
| `/ask-init --lang zh\|en` | rendering language for framework-generated files (per run; default: detected from the project's own docs) |
|
|
405
487
|
|
|
@@ -577,26 +659,29 @@ src/
|
|
|
577
659
|
├── quit-guard/ # quit watchdog: TUI teardown + quit-event triggers,
|
|
578
660
|
│ # settings store, hang report, tests
|
|
579
661
|
├── review/ # third-party review: input/command triggers,
|
|
580
|
-
│ # review
|
|
662
|
+
│ # review model config store, prompt, tests
|
|
581
663
|
└── stash/ # prompt stash: hotkey state machine + tests
|
|
582
664
|
```
|
|
583
665
|
|
|
584
666
|
**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
667
|
|
|
586
|
-
**Publishing** (
|
|
668
|
+
**Publishing** (one command; CI performs the upload):
|
|
587
669
|
|
|
588
670
|
```bash
|
|
589
671
|
pnpm release patch # 0.1.2 → 0.1.3
|
|
590
672
|
pnpm release minor # 0.1.2 → 0.2.0 (patch zeroed)
|
|
591
673
|
pnpm release major # 0.1.2 → 1.0.0 (minor + patch zeroed)
|
|
592
|
-
pnpm release patch --dry-run
|
|
593
|
-
pnpm release
|
|
594
|
-
pnpm release:github
|
|
674
|
+
pnpm release patch --dry-run # preview without changing anything
|
|
675
|
+
pnpm release patch --prepare-only # stop at the local tag, print the push command
|
|
676
|
+
pnpm release:github # create/verify the GitHub Release for the current version
|
|
677
|
+
pnpm release:github --audit # list npm versions vs GitHub Releases vs remote tags
|
|
595
678
|
```
|
|
596
679
|
|
|
597
|
-
|
|
680
|
+
Releasing is a **tag push**. `pnpm release` runs the gates (`typecheck`, `test`, UI checks), 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.
|
|
681
|
+
|
|
682
|
+
`--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
683
|
|
|
599
|
-
|
|
684
|
+
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
685
|
|
|
601
686
|
---
|
|
602
687
|
|
package/README.zh-CN.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
[](https://github.com/earendil-works/pi)
|
|
14
14
|
[](https://github.com/andares/pi-toolkits)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
一句话介绍:目前包含十一个开箱即用的功能——**只读咨询模式** `ask`、**会话级边界权限** `ask-perm`、**模型收藏** `favorites`、**提示词暂存** `stash`、**第三方代码评审** `ask-review`、**独立压缩模型** `compact-model`、**会话启动自动化** `autostart`、**agent 记忆框架** `ask-init`、**浏览器内计划评审** `ask-plan`、**验收台账与浏览器页面** `ask-uat`、**退出看门狗** `quit-guard`,后续持续追加。
|
|
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
|
-
- 完成一个开发任务后输入 `/
|
|
43
|
+
- 完成一个开发任务后输入 `/ask-review` → 切换到评审模型执行查+修
|
|
44
44
|
- `/compact-model` 选一个便宜快模型 → 之后 `/compact` 与自动压缩的总结都由它执行(footer 出现灰色 `compact` 状态)
|
|
45
45
|
|
|
46
46
|
---
|
|
@@ -74,7 +74,9 @@ pi -e ./src/index.ts
|
|
|
74
74
|
| 🔐 **permission** 会话级边界权限 | `/ask-perm` | 项目内/外 × 读/写四格模式,默认关闭且从不落盘;项目外写询问、凭据路径硬拒、破坏性命令必问;与 `/ask` 并行组合;另有滚动 JSONL 审批日志供事后挖规则 |
|
|
75
75
|
| ⭐ **favorites** 模型收藏 | `/model` 内 `ctrl+A` / `ctrl+J` | 收藏常用模型(加粗亮黄标记),`ctrl+p` 仅在收藏间循环 |
|
|
76
76
|
| 📥 **stash** 提示词暂存 | `ctrl+alt+y` | 一段提示词的暂存槽,按键交换 / 连按两次暂存并清空输入框 |
|
|
77
|
-
| 🔎 **review** 第三方代码评审 | `/
|
|
77
|
+
| 🔎 **review** 第三方代码评审 | `/ask-review` | 召唤配置的评审模型,对刚完成的任务做查+修,重点检查「本轮需求实现 / 是否有遗漏 / 是否有错误」 |
|
|
78
|
+
| 🧭 **plan** 浏览器内计划评审 | `/ask-plan` | 先调研、写 plan、在浏览器里逐段评审并逐块批注,批准之后才动代码 |
|
|
79
|
+
| ✅ **uat** 验收台账 | `/ask-uat` | 把待归类的实施记录聚成用户视角的验收项,在页面里勾选(只追加、无提交),看清哪些已交付但还没验过 |
|
|
78
80
|
| 🗜️ **compact** 独立压缩模型 | `/compact-model` | 给 `/compact` 与 auto-compact 配一个便宜快模型做总结,主模型专注对话;未配置零开销、任何异常回落 pi 默认 |
|
|
79
81
|
| 🚀 **autostart** 会话启动自动化 | `.pi/autostart.toml` | 项目内声明启动时自动执行的斜杠命令(首批用例:`/add-dir` 多仓库挂载);未信任不执行、未注册命令跳过不发给模型 |
|
|
80
82
|
| 🧠 **init** agent 记忆框架 | `/ask-init` | 安装或接管一套固定的记忆结构(`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`),带快照与覆盖表迁移旧文档,之后可随时审计漂移、预算与重复事实 |
|
|
@@ -247,9 +249,9 @@ run = ["/ask-perm allow allow allow ask"]
|
|
|
247
249
|
|
|
248
250
|
<a name="review"></a>
|
|
249
251
|
|
|
250
|
-
开发任务完成后,输入 `/
|
|
252
|
+
开发任务完成后,输入 `/ask-review` 指令召唤**另一个模型**以第三方身份,对刚完成的代码做「查 + 修」:评审模型拥有**完整工具权限**,确认的问题直接改,不是只读审计。评审回合留在当前会话记录里,评审完成后**会话保持评审模型**(不自动切回)。
|
|
251
253
|
|
|
252
|
-
> **仅指令触发**:只有 `/
|
|
254
|
+
> **仅指令触发**:只有 `/ask-review` 能发起评审。聊天中直接输入 `ask-review` 不会触发(作为普通消息发给模型),避免误发。
|
|
253
255
|
|
|
254
256
|
**评审提示词重点检查三点**(逐项给出结论):
|
|
255
257
|
|
|
@@ -259,9 +261,9 @@ run = ["/ask-perm allow allow allow ask"]
|
|
|
259
261
|
|
|
260
262
|
**范围强约束** —— 评审仅限**当前本轮修改内容**,避免扩大范围;本轮改动范围内确认的问题才直接修复,范围外的历史遗留/无关问题只记录提示、不动手改。
|
|
261
263
|
|
|
262
|
-
**评审模型选择**(每次 `/
|
|
264
|
+
**评审模型选择**(每次 `/ask-review` 都会弹出选择界面):
|
|
263
265
|
|
|
264
|
-
- `/
|
|
266
|
+
- `/ask-review` → 弹出 **`/model` 同款选择器**(限高滚动 + 模糊搜索):**默认选中当前配置的模型**(✓ 标记),直接**回车**即用它开始评审
|
|
265
267
|
- **换选其他模型** → 立即写回配置(**落盘 + 内存**),**下次默认使用该模型**
|
|
266
268
|
- **取消**(Esc)→ 不执行评审,配置不变
|
|
267
269
|
- 配置持久化于 `<agent-dir>/pi-toolkits-review.json`(默认 `~/.pi/agent/`):
|
|
@@ -270,13 +272,87 @@ run = ["/ask-perm allow allow allow ask"]
|
|
|
270
272
|
{ "model": "anthropic/claude-sonnet-4" }
|
|
271
273
|
```
|
|
272
274
|
|
|
273
|
-
- `/review-model` —— 单独的配置入口:弹出同一列表(不改会话模型,只更新默认配置)
|
|
274
275
|
- **未配置 / 配置的模型已不可用**(如在 pi 的 models.json 里删掉了该模型)→ 提示后照常弹出列表(此时无默认项)
|
|
275
276
|
- 任务仍在进行中(agent 未空闲)时触发 → 提示等待,不执行;同一时间只允许一个评审
|
|
276
277
|
- footer 出现灰色 `review` 状态 = 已配置评审模型
|
|
277
278
|
|
|
278
279
|
---
|
|
279
280
|
|
|
281
|
+
## 🧭 plan — 先出计划,浏览器里评审,批准后再动手
|
|
282
|
+
|
|
283
|
+
<a name="plan"></a>
|
|
284
|
+
|
|
285
|
+
`/ask-plan [主题]` 进入计划期:模型先调研、把代码里看不出来的问题问清楚,然后写一份 spec——评审期间不改代码。写完调用 `plan_submit`,评审页在**你的浏览器**里打开,你**逐段**批注:每个空行分隔的块都可以挂批注,批注会作为下一条消息回到模型。
|
|
286
|
+
|
|
287
|
+
- **块是评审单位。** 一段一块,带徽标标出与上一版相比的变化:`新增` / `已修改` / `位置移动` / `已删除`。未变的块默认折叠,改三行不会被读成整篇重写;围栏代码块整块保留。
|
|
288
|
+
- **只有两级批注**:块级 + 全局。不做文本选区锚,改版后不需要重新锚定。
|
|
289
|
+
- **批准和提意见都会带上批注**,它们只决定下一步:批准 = 开始实施(批注照做);提意见 = 改完再提交。
|
|
290
|
+
- **历史留档。** 每次提交都存在 `<agent-dir>/ask-plan/<slug>/`,页头可以只读回看任意一版。
|
|
291
|
+
- **计划期走边界闸门**:进入时自动开启 `/ask-perm` 默认参数,退出时恢复;计划期唯一能写的文件是 markdown。
|
|
292
|
+
- **绝不切模型。** 计划评审与实施都用会话当前的模型。(`/ask-review` 是唯一会切模型的命令,那是你要求的。)
|
|
293
|
+
|
|
294
|
+
**WSL 下的浏览器**:评审服务器绑 `0.0.0.0`,打印的 URL 用 WSL 的地址——因为在 WSL 里只绑回环,Windows 根本连不上。打开器优先用 Windows 侧的启动器(`wslview`、`cmd.exe /c start`、`powershell Start-Process`),非 WSL 才用 `xdg-open`——这决定你是"打开了浏览器"还是"在 WSL 里开了个看不见的浏览器"。
|
|
295
|
+
|
|
296
|
+
```text
|
|
297
|
+
/ask-plan 做导出功能 # 进入计划期
|
|
298
|
+
/ask-plan open # 重新打开评审页
|
|
299
|
+
/ask-plan off # 退出计划期(草稿留在原处)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
spec 落在 `specs/<slug>.md`,与 `/ask-init` 的计划同一个位置。
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## ✅ uat — 验收台账与浏览器页面
|
|
307
|
+
|
|
308
|
+
<a name="uat"></a>
|
|
309
|
+
|
|
310
|
+
`/ask-uat` 只回答一个问题:**这一批交付的东西,哪些还没验过?**
|
|
311
|
+
它存在的原因是:agent 驱动的开发一周产出的行为变更,人根本记不住;
|
|
312
|
+
「回头再测」就是验收债变成返工的方式。
|
|
313
|
+
|
|
314
|
+
验收的单位是**行为**,不是提交。实施会话每轮用 `record_change` 写一条实施记录,
|
|
315
|
+
附一句「用户视角能做什么」;UAT 侧把多条记录聚成少数验收项——一条行为可能要十条记录,
|
|
316
|
+
一条记录也可能碰到多个行为。
|
|
317
|
+
|
|
318
|
+
```text
|
|
319
|
+
record_change(实施)→ /ask-uat(聚类)→ 浏览器(勾选)→ 台账
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
| 命令 | 做什么 |
|
|
323
|
+
| --- | --- |
|
|
324
|
+
| `/ask-uat` | 把待归类的实施记录聚成验收项,然后打开页面 |
|
|
325
|
+
| `/ask-uat open` | 只重开页面,不走模型回合 |
|
|
326
|
+
| `/ask-uat off` | 关掉页面服务 |
|
|
327
|
+
|
|
328
|
+
**页面**按时间倒序列出未验收项:每条 2–3 句摘要,可展开测试方案(步骤、边界、
|
|
329
|
+
「这次不用测什么」)。勾选即写一条 `check` 事件——**没有提交**,关页不会丢决定。
|
|
330
|
+
已验收项折叠在底部,展开可反选;证据记录点一下就能看原文。
|
|
331
|
+
|
|
332
|
+
**它靠这几条站得住**:
|
|
333
|
+
|
|
334
|
+
- **只追加的台账,没有提交。** `.agents/uat/ledger.jsonl` 是事件流(`candidate`、`batch`、`item`、
|
|
335
|
+
`link`、`check`、`uncheck`、`amend`、`merge`、`drop`),进 git,按事件 id 去重,两个进程同时追加也不丢事件。
|
|
336
|
+
- **新证据会重开验收项。** 勾选之后又有新记录落到同一项,页面标 `reopened`:
|
|
337
|
+
「已验收」的含义是「按当前证据集验过」。
|
|
338
|
+
- **台账只属于主仓。** 在 git worktree 里跑的会话,实施记录与事件都写主仓,验收历史不会被分裂。
|
|
339
|
+
- **目录本身就是兜底索引。** 手写的实施记录同样会出现在待验收列表;`record_change` 只是补上
|
|
340
|
+
行为句与测试提示,不是闸门。
|
|
341
|
+
- **其他都不做。** 不编辑、不排序、不评论、不指派。聚类不合适就在对话里要求 agent
|
|
342
|
+
调整(页面开着时 `uat_item` 可用:link / amend / merge / drop)。
|
|
343
|
+
|
|
344
|
+
**实施记录格式**(`record_change` 写的就是这个):
|
|
345
|
+
|
|
346
|
+
```text
|
|
347
|
+
.agents/implementations/YYYY-MM-DD_HHMM_<slug>.md
|
|
348
|
+
# YYYY-MM-DDTHH:MM±HH:MM — 标题
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
旧记录(`YYYY-MM-DD_<slug>.md`、秒级首行)照样能读:读取端宽容,只有写入端严格。
|
|
352
|
+
新写的不合规记录由审计报 `W-REC-01`。
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
280
356
|
## 🗜️ compact — 独立压缩模型
|
|
281
357
|
|
|
282
358
|
<a name="compact"></a>
|
|
@@ -398,6 +474,7 @@ run = [
|
|
|
398
474
|
| `/ask-init plan [--deep]` | 只打印计划,不写任何盘(`--dry-run` 同义) |
|
|
399
475
|
| `/ask-init check` | 审计已装的框架(只读;只在 `.agents/framework/reports/` 留下运行期报告) |
|
|
400
476
|
| `/ask-init roots` | 把 `pi-add-dir` 添加的目录同步进框架状态 |
|
|
477
|
+
| `/ask-init refresh` | 刷新框架拥有的文件(合同、门牌、验收合同)与 `AGENTS.md` 里的工作流块;手工改过的文件一概不动 |
|
|
401
478
|
| `/ask-init --yes` | 跳过确认面板 |
|
|
402
479
|
| `/ask-init --lang zh\|en` | 框架生成文件的渲染语言(单次生效;默认按项目自身文档判定) |
|
|
403
480
|
|
|
@@ -528,20 +605,23 @@ src/
|
|
|
528
605
|
|
|
529
606
|
**新增功能**:新建 `src/features/<name>/`,导出 `registerXxx(pi)`,在 `src/index.ts` 中调用;已有模块保持不变。每个功能自带 `*.test.ts`(vitest)——保持确定性(时钟/状态可注入,不写真实 agent-dir)。
|
|
530
607
|
|
|
531
|
-
**发布**(
|
|
608
|
+
**发布**(一条命令;上传由 CI 执行):
|
|
532
609
|
|
|
533
610
|
```bash
|
|
534
611
|
pnpm release patch # 0.1.2 → 0.1.3
|
|
535
612
|
pnpm release minor # 0.1.2 → 0.2.0 (patch 清零)
|
|
536
613
|
pnpm release major # 0.1.2 → 1.0.0 (minor + patch 清零)
|
|
537
|
-
pnpm release patch --dry-run
|
|
538
|
-
pnpm release
|
|
539
|
-
pnpm release:github
|
|
614
|
+
pnpm release patch --dry-run # 预览,不做任何改动
|
|
615
|
+
pnpm release patch --prepare-only # 准备到本地 tag,打印推送命令
|
|
616
|
+
pnpm release:github # 为当前版本创建/校验 GitHub Release(幂等)
|
|
617
|
+
pnpm release:github --audit # 列出 npm 版本 vs GitHub Release vs 远端 tag
|
|
540
618
|
```
|
|
541
619
|
|
|
542
|
-
|
|
620
|
+
**发版 = 推 tag。** `pnpm release` 跑完门禁(`typecheck`、`test`、UI 检查)、改版本、commit、打 `vX.Y.Z` tag、推分支和 tag,然后等 GitHub Actions 的 `publish` 工作流。该工作流用 **npm trusted publishing(OIDC)** 发布:不需要 npm token、不需要交互式 2FA,每个版本自动附 provenance。脚本只在 npm 上真的出现该版本、且 `dist.attestations` 非空时才报成功。
|
|
621
|
+
|
|
622
|
+
`--prepare-only` 是「都准备好、发不发最后再说」的开关:停在 commit+tag 后,打印确切的推送命令。`--no-wait` 推完就返回;`--local` 是应急路径(本机用旧 token 发布)。工作流失败后重跑同一个 tag 即可(`gh workflow run publish.yml -f tag=vX.Y.Z`):已发布的版本会跳过,所以重跑是幂等的。
|
|
543
623
|
|
|
544
|
-
|
|
624
|
+
维护者一次性配置(交互式 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
625
|
|
|
546
626
|
---
|
|
547
627
|
|
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), 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.13.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, and an agent memory framework (/ask-init)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -34,7 +34,11 @@
|
|
|
34
34
|
"agent-memory",
|
|
35
35
|
"memory-framework",
|
|
36
36
|
"scaffold",
|
|
37
|
-
"init"
|
|
37
|
+
"init",
|
|
38
|
+
"uat",
|
|
39
|
+
"acceptance",
|
|
40
|
+
"acceptance-testing",
|
|
41
|
+
"change-record"
|
|
38
42
|
],
|
|
39
43
|
"peerDependencies": {
|
|
40
44
|
"@earendil-works/pi-coding-agent": ">=0.99.0",
|
|
@@ -55,11 +59,6 @@
|
|
|
55
59
|
"typescript": "^5.6.0",
|
|
56
60
|
"vitest": "^4.1.10"
|
|
57
61
|
},
|
|
58
|
-
"pi": {
|
|
59
|
-
"extensions": [
|
|
60
|
-
"./src/index.ts"
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
62
|
"scripts": {
|
|
64
63
|
"typecheck": "tsc --noEmit",
|
|
65
64
|
"test": "vitest run",
|
|
@@ -67,7 +66,17 @@
|
|
|
67
66
|
"check:compat": "node ./scripts/check-compat.mjs",
|
|
68
67
|
"approval-report": "node ./scripts/approval-report.mjs",
|
|
69
68
|
"release:github": "node ./scripts/release-github.mjs",
|
|
69
|
+
"prepublishOnly": "pnpm typecheck && pnpm ui:typecheck && pnpm test && pnpm ui:check",
|
|
70
70
|
"release": "node ./scripts/publish.mjs",
|
|
71
|
-
"tag-current": "node ./scripts/tag-current.mjs"
|
|
71
|
+
"tag-current": "node ./scripts/tag-current.mjs",
|
|
72
|
+
"ui:dev": "pnpm --filter @andares/pi-toolkits-ui dev",
|
|
73
|
+
"ui:build": "pnpm --filter @andares/pi-toolkits-ui build",
|
|
74
|
+
"ui:typecheck": "pnpm --filter @andares/pi-toolkits-ui typecheck",
|
|
75
|
+
"ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/plan/assets src/features/uat/assets)\""
|
|
76
|
+
},
|
|
77
|
+
"pi": {
|
|
78
|
+
"extensions": [
|
|
79
|
+
"./src/index.ts"
|
|
80
|
+
]
|
|
72
81
|
}
|
|
73
|
-
}
|
|
82
|
+
}
|
|
@@ -32,6 +32,7 @@ import type {
|
|
|
32
32
|
ExtensionContext,
|
|
33
33
|
} from "@earendil-works/pi-coding-agent";
|
|
34
34
|
import type { GateHub } from "../../lib/gates.js";
|
|
35
|
+
import { setAskControl } from "../../lib/ask-control.js";
|
|
35
36
|
// The jailed-tool registry lives here too: ask marks `scratchpad` while the mode
|
|
36
37
|
// is active so the boundary gate (`permission`) knows it has no path to judge.
|
|
37
38
|
import {
|
|
@@ -183,6 +184,11 @@ export function registerAsk(
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
// Planning is deliberately less restrictive than consult mode (markdown may
|
|
188
|
+
// be written and bash stays available), so `/ask-plan` exits through the
|
|
189
|
+
// owning feature rather than trying to restore its tool set itself.
|
|
190
|
+
setAskControl({ isActive: () => enabled, exit });
|
|
191
|
+
|
|
186
192
|
pi.registerCommand("ask", {
|
|
187
193
|
description: "Toggle ask mode (consult mode: no project writes, scratch notes allowed)",
|
|
188
194
|
handler: async (_args, ctx) => {
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
STATE_FILE,
|
|
43
43
|
SCAN,
|
|
44
44
|
STATE_GITIGNORE,
|
|
45
|
+
UAT_CONTRACT_FILE,
|
|
45
46
|
} from "./spec.js";
|
|
46
47
|
import { isBareRef, readDoc, walk } from "./detect.js";
|
|
47
48
|
import { renderTemplate } from "./templates.js";
|
|
@@ -81,6 +82,10 @@ function sha256File(absolute: string): string {
|
|
|
81
82
|
return createHash("sha256").update(readFileSync(absolute)).digest("hex");
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
function sha256Text(text: string): string {
|
|
86
|
+
return createHash("sha256").update(text).digest("hex");
|
|
87
|
+
}
|
|
88
|
+
|
|
84
89
|
function mkdirFor(absolute: string): void {
|
|
85
90
|
mkdirSync(dirname(absolute), { recursive: true });
|
|
86
91
|
}
|
|
@@ -397,6 +402,7 @@ export function stateToToml(state: FrameworkState): string {
|
|
|
397
402
|
path: entry.path,
|
|
398
403
|
sha256: entry.sha256,
|
|
399
404
|
template: entry.template,
|
|
405
|
+
template_sha256: entry.templateSha256,
|
|
400
406
|
})),
|
|
401
407
|
migrations: state.migrations.map((entry) =>
|
|
402
408
|
compact({ at: entry.at, to: entry.to, notes: entry.notes }),
|
|
@@ -481,6 +487,8 @@ interface ApplyContext {
|
|
|
481
487
|
readonly moved: ApplyResult["moved"];
|
|
482
488
|
readonly created: string[];
|
|
483
489
|
readonly skipped: ApplyResult["skipped"];
|
|
490
|
+
/** Hash of the bytes we rendered for each file created by this run. */
|
|
491
|
+
readonly managedHashes: Map<string, string>;
|
|
484
492
|
rewrites?: ApplyResult["rewrites"];
|
|
485
493
|
snapshot?: ApplyResult["snapshot"];
|
|
486
494
|
statePath?: string;
|
|
@@ -559,8 +567,12 @@ function applyCreateFile(ctx: ApplyContext, action: Action & { kind: "create-fil
|
|
|
559
567
|
return;
|
|
560
568
|
}
|
|
561
569
|
const body = createFile(ctx.root, action, ctx.language);
|
|
562
|
-
if (body === undefined)
|
|
563
|
-
|
|
570
|
+
if (body === undefined) {
|
|
571
|
+
ctx.skipped.push({ path: action.path, reason: "already exists" });
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
ctx.created.push(action.path);
|
|
575
|
+
ctx.managedHashes.set(action.path, sha256Text(body));
|
|
564
576
|
}
|
|
565
577
|
|
|
566
578
|
function applyWriteState(ctx: ApplyContext, action: Action & { kind: "write-state" }): void {
|
|
@@ -568,7 +580,7 @@ function applyWriteState(ctx: ApplyContext, action: Action & { kind: "write-stat
|
|
|
568
580
|
ctx.statePath = STATE_FILE;
|
|
569
581
|
return;
|
|
570
582
|
}
|
|
571
|
-
ctx.statePath = writeState(ctx.root, action.state);
|
|
583
|
+
ctx.statePath = writeState(ctx.root, action.state, ctx.managedHashes);
|
|
572
584
|
}
|
|
573
585
|
|
|
574
586
|
function runAction(ctx: ApplyContext, action: Action): void {
|
|
@@ -609,6 +621,7 @@ export function applyPlan(plan: Plan, options: ApplyOptions = {}): ApplyResult {
|
|
|
609
621
|
moved: [],
|
|
610
622
|
created: [],
|
|
611
623
|
skipped: [],
|
|
624
|
+
managedHashes: new Map(),
|
|
612
625
|
};
|
|
613
626
|
|
|
614
627
|
for (const action of plan.actions) runAction(ctx, action);
|
|
@@ -765,23 +778,30 @@ export function scrubRetiredFields(root: string, options: ScrubOptions = {}): Sc
|
|
|
765
778
|
}
|
|
766
779
|
|
|
767
780
|
/** Write state, refreshing the hashes of files this framework manages. */
|
|
768
|
-
function writeState(
|
|
769
|
-
|
|
781
|
+
function writeState(
|
|
782
|
+
root: string,
|
|
783
|
+
state: FrameworkState,
|
|
784
|
+
managedHashes: Map<string, string> = new Map(),
|
|
785
|
+
): string {
|
|
786
|
+
const managedPaths = [CONTRACT_FILE, SIGNPOST_FILE, UAT_CONTRACT_FILE, STATE_GITIGNORE];
|
|
787
|
+
const templates: Record<string, string> = {
|
|
788
|
+
[CONTRACT_FILE]: "memory-readme",
|
|
789
|
+
[SIGNPOST_FILE]: "signpost",
|
|
790
|
+
[UAT_CONTRACT_FILE]: "uat-readme",
|
|
791
|
+
[STATE_GITIGNORE]: "state-gitignore",
|
|
792
|
+
};
|
|
770
793
|
const previous = new Map(state.managed.map((entry) => [entry.path, entry]));
|
|
771
794
|
const managed: FrameworkState["managed"] = [];
|
|
772
795
|
for (const rel of managedPaths) {
|
|
773
796
|
const absolute = inside(root, rel);
|
|
774
797
|
if (!existsSync(absolute)) continue;
|
|
775
|
-
const template =
|
|
776
|
-
rel === CONTRACT_FILE
|
|
777
|
-
? "memory-readme"
|
|
778
|
-
: rel === SIGNPOST_FILE
|
|
779
|
-
? "signpost"
|
|
780
|
-
: "state-gitignore";
|
|
781
798
|
managed.push({
|
|
782
799
|
path: rel,
|
|
783
800
|
sha256: sha256File(absolute),
|
|
784
|
-
template: previous.get(rel)?.template ??
|
|
801
|
+
template: previous.get(rel)?.template ?? templates[rel] ?? "",
|
|
802
|
+
// Anchor = the bytes this tool rendered. A file we did not write this
|
|
803
|
+
// run keeps the previous anchor; without one, refresh stays hands-off.
|
|
804
|
+
templateSha256: managedHashes.get(rel) ?? previous.get(rel)?.templateSha256,
|
|
785
805
|
});
|
|
786
806
|
}
|
|
787
807
|
const absolute = inside(root, STATE_FILE);
|