@andares/pi-toolkits 1.0.2 → 1.2.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/CHANGELOG.md +21 -0
- package/README.md +65 -1
- package/README.zh-CN.md +58 -1
- package/package.json +7 -4
- package/src/features/keep/constants.ts +44 -0
- package/src/features/keep/format.ts +77 -0
- package/src/features/keep/index.ts +409 -0
- package/src/features/keep/keep.test.ts +955 -0
- package/src/features/keep/ledger.ts +340 -0
- package/src/features/keep/picker.ts +257 -0
- package/src/features/keep/store.ts +271 -0
- package/src/features/review-page/assets/index-CrDwcsqI.css +1 -0
- package/src/features/review-page/assets/index-DYxi32gA.js +1 -0
- package/src/features/{spec → review-page}/assets/index.html +2 -2
- package/src/features/{spec → review-page}/blocks.test.ts +17 -0
- package/src/features/{spec → review-page}/blocks.ts +9 -0
- package/src/features/review-page/headings.test.ts +44 -0
- package/src/features/review-page/headings.ts +67 -0
- package/src/features/spec/assets.test.ts +2 -2
- package/src/features/spec/diff.test.ts +1 -1
- package/src/features/spec/diff.ts +1 -1
- package/src/features/spec/feedback.test.ts +1 -1
- package/src/features/spec/feedback.ts +1 -1
- package/src/features/spec/index.test.ts +121 -0
- package/src/features/spec/index.ts +82 -23
- package/src/features/spec/server.test.ts +65 -2
- package/src/features/spec/server.ts +29 -5
- package/src/features/spec/store.ts +1 -1
- package/src/features/talk/index.test.ts +230 -0
- package/src/features/talk/index.ts +241 -0
- package/src/features/talk/message.test.ts +212 -0
- package/src/features/talk/message.ts +152 -0
- package/src/features/talk/reply.test.ts +116 -0
- package/src/features/talk/reply.ts +92 -0
- package/src/features/talk/sections.test.ts +39 -0
- package/src/features/talk/sections.ts +44 -0
- package/src/features/talk/server.test.ts +247 -0
- package/src/features/talk/server.ts +211 -0
- package/src/features/uat/ledger.ts +13 -62
- package/src/index.ts +7 -0
- package/src/lib/event-ledger.ts +112 -0
- package/src/features/spec/assets/index-CdTerMvN.css +0 -1
- package/src/features/spec/assets/index-Dv52AIjX.js +0 -1
- /package/src/features/{spec → review-page}/render.test.ts +0 -0
- /package/src/features/{spec → review-page}/render.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,25 @@ 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.2.0 — 2026-11-26
|
|
15
|
+
|
|
16
|
+
- **talk** — `/ask-talk` opens the agent's last reply in the review page: one note per block plus a composer, and `Continue` sends just the notes and your message back — the reply itself is not re-quoted.
|
|
17
|
+
- **spec** — the review page gets a contents strip at the reading column's edge: point at it to open a heading index, click a heading to jump; it follows the section you are reading.
|
|
18
|
+
- **spec** — a `Back to top` button appears once the right-hand column has scrolled out of view, and stays above the footer.
|
|
19
|
+
|
|
20
|
+
<!-- Notes for the next release go here; `pnpm release` renames this heading. -->
|
|
21
|
+
|
|
22
|
+
## 1.1.0 — 2026-11-25
|
|
23
|
+
|
|
24
|
+
<!-- Notes for the next release go here; `pnpm release` renames this heading. -->
|
|
25
|
+
|
|
26
|
+
- **spec** — running `/ask-spec` without arguments while a spec review is active now leaves the phase; `/ask-spec off` still works.
|
|
27
|
+
- **spec** — after feedback, the next submitted revision starts a new review server and opens a new window instead of printing a dead URL; reopening a closed review restarts it, and the revision history is preserved.
|
|
28
|
+
- **keep** — `/keep-quit` marks the current session unfinished and quits in one step; `/keep-load` lists that backlog, already-loaded rows dimmed but still selectable, and `/keep-drop` (or `ctrl+r` in the list) removes one.
|
|
29
|
+
- **keep** — the next interactive start reports how many kept sessions are still unloaded (`2 not loaded · /keep-load`).
|
|
30
|
+
- **keep** — a loaded session begins with the note you left at quit time, delivered as a message the model can read without triggering a turn.
|
|
31
|
+
- **keep** — the backlog is an append-only ledger: two pi processes can write at once, and a `load` left behind by a killed process is repaired on the next read.
|
|
32
|
+
|
|
14
33
|
## 1.0.2 — 2026-11-24
|
|
15
34
|
|
|
16
35
|
<!-- Notes for the next release go here; `pnpm release` renames this heading. -->
|
|
@@ -71,3 +90,5 @@ renames that heading to the version being published and refuses an empty section
|
|
|
71
90
|
|
|
72
91
|
|
|
73
92
|
|
|
93
|
+
|
|
94
|
+
|
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: fourteen 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`, **reply notes in the browser** `ask-talk`, an **acceptance ledger with a browser page** `ask-uat`, a **quit watchdog** `quit-guard`, a **session backlog for parallel work** `keep`, 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.6.0 has been verified with the full gate (install → `tsc --noEmit` → full test suite → keybinding audit → hash compare of the host files this package patches), each in a sandbox with the whole `@earendil-works/*` family pinned to the version under test. Newer releases are verified as they ship and the floor moves only when the measurement says so; `pnpm check:compat` reproduces the result. Note: pi ≥ 0.99 hosts require host-provided packages to be declared in `peerDependencies` with a `"*"` range — `@earendil-works/pi-tui` and `typebox` (the `scratchpad` tool builds a TypeBox schema) are declared that way; an installed copy in `dependencies` would make pi warn.
|
|
19
19
|
|
|
@@ -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
|
+
- [🧷 keep — session backlog](#keep)
|
|
61
62
|
- [🆕 whats-new — release notes after an upgrade](#whats-new)
|
|
62
63
|
- [Development](#development)
|
|
63
64
|
- [Contributing](#contributing)
|
|
@@ -77,11 +78,13 @@ After installing, verify in any pi session:
|
|
|
77
78
|
| 📥 **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
79
|
| 🔎 **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
|
| 🧭 **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 |
|
|
81
|
+
| 💬 **talk** reply notes | `/ask-talk` | annotate the agent's last reply in the browser — one note per block plus one message — and send it back as a single short message instead of re-quoting the answer |
|
|
80
82
|
| ✅ **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
83
|
| 🗜️ **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
84
|
| 🚀 **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
85
|
| 🧠 **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
86
|
| 🧯 **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 |
|
|
87
|
+
| 🧷 **keep** session backlog | `/keep-quit` · `/keep-load` · `/keep-drop` | mark a session unfinished as you quit, reopen the backlog next time (loaded rows dimmed but still selectable), drop what you finished; an append-only ledger, no lock and no host session listing |
|
|
85
88
|
| 🆕 **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
89
|
|
|
87
90
|
---
|
|
@@ -298,6 +301,8 @@ After a development task is done, type the `/ask-review` command to summon **a d
|
|
|
298
301
|
- **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
302
|
- **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
303
|
- **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.
|
|
304
|
+
- **Every revision gets a fresh window.** The review server closes shortly after you send a decision, so the next submitted revision starts a new server (next free port in the 20-port range) and opens a new window instead of pointing you at a dead URL. That is a restart of the page, not of the review: every revision, annotation and decision is kept, and the history drawer still lists the earlier rounds.
|
|
305
|
+
- **Contents and back to top.** A column of warm grey bars sits at the reading column's right edge; pointing at it opens a table of contents (one bar per heading, current section marked) that jumps on click, and the whole column hides in the single-column layout. Once the right column has scrolled out of view, a "Back to top" button appears above the footer. Both are shared with `/ask-talk`.
|
|
301
306
|
- **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.)
|
|
302
307
|
|
|
303
308
|
**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".
|
|
@@ -305,6 +310,7 @@ After a development task is done, type the `/ask-review` command to summon **a d
|
|
|
305
310
|
```text
|
|
306
311
|
/ask-spec build the export feature # start the review
|
|
307
312
|
/ask-spec open # re-open the review page
|
|
313
|
+
/ask-spec # while reviewing: leave the phase
|
|
308
314
|
/ask-spec off # leave the phase (the draft stays where it is)
|
|
309
315
|
```
|
|
310
316
|
|
|
@@ -315,6 +321,27 @@ the two phases do not run on top of each other.
|
|
|
315
321
|
|
|
316
322
|
---
|
|
317
323
|
|
|
324
|
+
## 💬 talk — annotate the last reply
|
|
325
|
+
|
|
326
|
+
<a name="talk"></a>
|
|
327
|
+
|
|
328
|
+
`/ask-talk` takes the agent's **last formal reply** — the final assistant message of the current turn, with thinking and tool calls excluded — and opens it in the same review page as `/ask-spec`: read it as a document, put a note on any paragraph, type a message at the bottom, press **Continue**.
|
|
329
|
+
|
|
330
|
+
No tool is registered, no tool set changes, no permission mode is touched and nothing is added to the system prompt: the command costs nothing until you type it, and it works inside `/ask` and the other phases.
|
|
331
|
+
|
|
332
|
+
- **Only the notes go back.** The message is `## Notes on your last reply` — each note with the block it quotes, clipped to 600 characters — followed by `## Operator's message`. The reply itself is not echoed: it is already in the model's context. If a compaction pushed it out, the reply is repeated once in full so the quotes still point at text the model can see.
|
|
333
|
+
- **One note per block, no verdicts.** A conversation annotation is "here is what I think about this part", not a change request to triage; clicking the note edits it.
|
|
334
|
+
- **No versions, no diff, no approval.** It is a snapshot, not a document under revision. Running `/ask-talk` again refreshes it: the same reply keeps your notes, a new reply starts empty.
|
|
335
|
+
- **Continue commits once.** It saves the notes and the composer text, sends one message and closes the port; the page then offers to be closed (a tab opened by an external launcher cannot be closed by script).
|
|
336
|
+
- **It refuses while the agent is running.** The host persists an assistant message at the end of a run, so annotating mid-run would silently show the *previous* reply.
|
|
337
|
+
|
|
338
|
+
```text
|
|
339
|
+
/ask-talk # open (or refresh) the page for the last reply
|
|
340
|
+
/ask-talk off # close it
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
318
345
|
## ✅ uat — acceptance ledger and browser page
|
|
319
346
|
|
|
320
347
|
<a name="uat"></a>
|
|
@@ -681,6 +708,43 @@ kill appends `thread-kill heartbeat-stopped …` there.
|
|
|
681
708
|
|
|
682
709
|
---
|
|
683
710
|
|
|
711
|
+
## 🧷 keep — session backlog for parallel work
|
|
712
|
+
|
|
713
|
+
<a name="keep"></a>
|
|
714
|
+
|
|
715
|
+
**What this does.** `/keep-quit` marks the current session unfinished and quits in one step, so the
|
|
716
|
+
list of open tasks is written down at the moment you walk away instead of reconstructed from memory
|
|
717
|
+
a day later. `/keep-load` lists exactly that backlog. Loading does **not** remove anything:
|
|
718
|
+
`/keep-drop` (or `ctrl+r` in the list) is the only way out.
|
|
719
|
+
|
|
720
|
+
Kept and loaded are two axes on purpose. A session is *kept* while it is unfinished and *loaded*
|
|
721
|
+
while some pi process has it open, and the second one is a record, not a lock: a hard-killed
|
|
722
|
+
process leaves a stale marker, so a loaded row stays selectable and can be loaded again. The next
|
|
723
|
+
read after that process is gone notices the dead pid and marks the session unloaded again.
|
|
724
|
+
|
|
725
|
+
State is an append-only ledger at `<agent-dir>/pi-toolkits-keep/keep.jsonl` with four events
|
|
726
|
+
(`keep`, `drop`, `load`, `unload`); everything the list shows is a pure fold over it, so two pi
|
|
727
|
+
processes can append at the same time without a lock. Nothing here calls the host's session
|
|
728
|
+
listing (576 ms for this project's 109 sessions, 9.8 s for the whole agent dir) — the backlog reads
|
|
729
|
+
only the ledger, and `rebuild` reads 16 KB per session file when you have to restore it.
|
|
730
|
+
|
|
731
|
+
| command | what it does |
|
|
732
|
+
| --- | --- |
|
|
733
|
+
| `/keep-quit [note]` | mark this session unfinished and quit; the note falls back to the session name, then to the first user message |
|
|
734
|
+
| `/keep-load` | open the backlog: `↑↓` move, enter load, `ctrl+r` drop, esc cancel; already-loaded rows are dimmed but still selectable |
|
|
735
|
+
| `/keep-load <n\|id>` | load by 1-based index or session id prefix |
|
|
736
|
+
| `/keep-load --all` | include other projects, with a project column |
|
|
737
|
+
| `/keep-load rebuild` | re-add keeps from the breadcrumb each session file carries (recovery after the ledger is lost) |
|
|
738
|
+
| `/keep-drop` | remove the current session from the backlog |
|
|
739
|
+
|
|
740
|
+
The next interactive start shows the backlog as one line — `2 not loaded · /keep-load`. Loading a
|
|
741
|
+
session injects the note you left at quit time as a message the model can see without triggering a
|
|
742
|
+
turn, so it knows where you stopped. The current session never lists itself: `/keep-quit` and
|
|
743
|
+
`/keep-drop` are its commands.
|
|
744
|
+
|
|
745
|
+
**Not a lock.** Two processes can still open the same session file; this records that they did, it
|
|
746
|
+
does not prevent it. `pi -ne` and headless runs never write `load`, so they stay invisible here.
|
|
747
|
+
|
|
684
748
|
## 🆕 whats-new — release notes after an upgrade
|
|
685
749
|
|
|
686
750
|
<a name="whats-new"></a>
|
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-spec`、**回复批注** `ask-talk`、**验收台账与浏览器页面** `ask-uat`、**退出看门狗** `quit-guard`、**并行任务的会话暂存** `keep`、**升级后首次启动的版本变更提示** `whats-new`,后续持续追加。
|
|
17
17
|
|
|
18
18
|
**版本要求**:pi `>=0.99.0`。0.99.0 到 1.6.0 的每一个已发布版本都用完整门禁实测过(install → `tsc --noEmit` → 全量测试 → 键位审计 → 对 patch 目标宿主文件做哈希比对),每个版本都在沙箱中把整个 `@earendil-works/*` 家族钉在同一版本。更新的版本随发布逐个验证,下限只在实测结果允许时移动;`pnpm check:compat` 可复现该结论。注:pi ≥ 0.99 的宿主要求「宿主提供的包」一律声明为 peerDependencies `"*"` —— `@earendil-works/pi-tui` 与 `typebox`(ask 的 `scratchpad` 用它构造参数 schema)都按此声明;若放进 `dependencies`,pi 会告警。
|
|
19
19
|
|
|
@@ -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
|
+
- [🧷 keep — 会话暂存](#keep)
|
|
61
62
|
- [🆕 whats-new — 升级后的版本变更提示](#whats-new)
|
|
62
63
|
- [开发](#development)
|
|
63
64
|
- [贡献](#contributing)
|
|
@@ -77,11 +78,13 @@ pi -e ./src/index.ts
|
|
|
77
78
|
| 📥 **stash** 提示词暂存 | `ctrl+alt+y` | 一段提示词的暂存槽,按键交换 / 连按两次暂存并清空输入框 |
|
|
78
79
|
| 🔎 **review** 第三方代码评审 | `/ask-review` | 召唤配置的评审模型,对刚完成的任务做查+修,重点检查「本轮需求实现 / 是否有遗漏 / 是否有错误」 |
|
|
79
80
|
| 🧭 **spec** 浏览器内规格评审 | `/ask-spec` | 先调研、写 spec、在浏览器里逐段评审并逐块批注,批准之后才动代码 |
|
|
81
|
+
| 💬 **talk** 回复批注 | `/ask-talk` | 把 agent 最近一条正式回复摊在浏览器里,逐块写批注、底部写一句话,合起来作为一条短消息发回,而不是把原文再贴一遍 |
|
|
80
82
|
| ✅ **uat** 验收台账 | `/ask-uat` | `/ask-init` 之后:把待归类的实施记录聚成用户视角的验收项,在页面里勾选(只追加、无提交),看清哪些已交付但还没验过 |
|
|
81
83
|
| 🗜️ **compact** 独立压缩模型 | `/compact-model` | 给 `/compact` 与 auto-compact 配一个便宜快模型做总结,主模型专注对话;未配置零开销、任何异常回落 pi 默认 |
|
|
82
84
|
| 🚀 **autostart** 会话启动自动化 | `.pi/autostart.toml` | 项目内声明启动时自动执行的斜杠命令(首批用例:`/add-dir` 多仓库挂载);未信任不执行、未注册命令跳过不发给模型 |
|
|
83
85
|
| 🧠 **init** agent 记忆框架 | `/ask-init` | 安装或接管一套固定的记忆结构(`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`),带快照与覆盖表迁移旧文档,之后可随时审计/刷新漂移、预算与重复事实 |
|
|
84
86
|
| 🧯 **quit-guard** 退出看门狗 | `/quit-guard` | 交互式退出卡死时,无论发生在 TUI 收尾之后、还是信号触发路径的收尾之前,超时后写诊断报告并强制退出,把命令行提示符还给你;TUI 重启与 Ctrl+Z 恢复都会解除看守 |
|
|
87
|
+
| 🧷 **keep** 会话暂存 | `/keep-quit` · `/keep-load` · `/keep-drop` | 退出时一条命令把当前会话标记为未完成,下次进来直接看这个待办列表(已载入的置灰但仍可选);做完的用 `/keep-drop` 或列表里的 `ctrl+r` 移出。只追加账本,没有锁,也不读宿主的会话列表 |
|
|
85
88
|
| 🆕 **whats-new** 升级后的版本变更提示 | 自动 | 升级后的首次 `pi` 启动展示「从你上次运行的版本到现在改了什么」,只展示一次;不注册斜杠命令,不占用宿主的全局命令命名空间 |
|
|
86
89
|
|
|
87
90
|
---
|
|
@@ -298,6 +301,7 @@ run = ["/ask-perm allow allow allow ask"]
|
|
|
298
301
|
- **批准和提意见都携带批注。** 它们只决定下一步:批准是「开始实施」(所有批注都带上),提意见是「改完 spec 再提交一版」。
|
|
299
302
|
- **历史留档。** 每次提交都存在 `<agent-dir>/ask-spec/<slug>/`,页头可以只读回看任意一版;旧的 `<agent-dir>/ask-plan/` 历史会在第一次使用时迁移。
|
|
300
303
|
- **评审期走边界检查。** `/ask-perm` 在评审开始时按默认值开启,结束时恢复;评审期唯一能写的是 markdown。
|
|
304
|
+
- **每一版都有自己的新窗口。** 你提交决定后评审服务很快关端口,所以下一次提交修订会重起服务(20 个端口段里取下一个空闲的)并弹新窗口,而不是把你指向一个死链接。重启的是页面,不是评审:每一版、每条批注和决定都保留,历史抽屉里前几轮仍在。
|
|
301
305
|
- **绝不切模型。** spec 评审与实施都用会话当前的模型。(`/ask-review` 是唯一会切模型的命令,那是你要求的。)
|
|
302
306
|
|
|
303
307
|
**WSL 下的浏览器**:评审服务器绑 `0.0.0.0`,URL 用 WSL 的地址打印,因为 Windows 连不到 WSL 里只绑 loopback 的服务器。打开器优先用 Windows 侧启动器(`wslview`、`cmd.exe /c start`、`powershell Start-Process`),其它平台才回落到 `xdg-open`——这决定了是「打开你的浏览器」还是「在 WSL 里打开一个你看不见的浏览器」。
|
|
@@ -305,6 +309,7 @@ run = ["/ask-perm allow allow allow ask"]
|
|
|
305
309
|
```text
|
|
306
310
|
/ask-spec 做导出功能 # 进入规格评审
|
|
307
311
|
/ask-spec open # 重新打开评审页
|
|
312
|
+
/ask-spec # 评审中再次执行:退出评审期
|
|
308
313
|
/ask-spec off # 退出评审期(草稿留在原处)
|
|
309
314
|
```
|
|
310
315
|
|
|
@@ -314,6 +319,27 @@ UAT 页面开着时先退出:两个相位不叠在一起跑。
|
|
|
314
319
|
|
|
315
320
|
---
|
|
316
321
|
|
|
322
|
+
## 💬 talk — 给最近一条回复写批注
|
|
323
|
+
|
|
324
|
+
<a name="talk"></a>
|
|
325
|
+
|
|
326
|
+
`/ask-talk` 把 agent **最近一条正式回复**(当前回合最后一条 assistant 消息的正文,不含 thinking 与工具调用)用与 `/ask-spec` 相同的评审页打开:当文档读,任意段落写一条批注,底部输入一句话,按 **继续**。
|
|
327
|
+
|
|
328
|
+
不注册工具、不改工具集、不动权限、不进系统提示:不用它时零成本,且在 `/ask` 等相位期间都能用。
|
|
329
|
+
|
|
330
|
+
- **只发批注。** 消息是 `## Notes on your last reply`(每条批注 + 它引用的块,引用裁到 600 字符)加 `## Operator's message`;回复原文不重复,因为它本来就在模型上下文里。若中途 compact 把它挤掉了,才整篇附一次。
|
|
331
|
+
- **每块一条批注、无 verdict。** 对话里的批注就是「这块我想说这句」,点开可改。
|
|
332
|
+
- **没有版本、没有 diff、没有批准。** 这是快照不是待修订的文档;再跑一次等于刷新:同一条回复保留批注,换了回复就清空。
|
|
333
|
+
- **继续只提交一次。** 保存批注与输入框、发一条消息、关掉端口;页面随后提示可以关闭(外部打开的标签页脚本关不掉)。
|
|
334
|
+
- **agent 还在跑时拒绝。** 宿主在回合结束才落盘 assistant 消息,跑到一半打开只会静默显示**上一轮**。
|
|
335
|
+
|
|
336
|
+
```text
|
|
337
|
+
/ask-talk # 打开(或刷新)最近一条回复的批注页
|
|
338
|
+
/ask-talk off # 关掉
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
317
343
|
## ✅ uat — 验收台账与浏览器页面
|
|
318
344
|
|
|
319
345
|
<a name="uat"></a>
|
|
@@ -591,6 +617,37 @@ refresh 就会正常更新它。
|
|
|
591
617
|
|
|
592
618
|
---
|
|
593
619
|
|
|
620
|
+
## 🧷 keep — 并行任务的会话暂存
|
|
621
|
+
|
|
622
|
+
<a name="keep"></a>
|
|
623
|
+
|
|
624
|
+
**做什么。** `/keep-quit` 把「退出」和「这个任务还没做完」合成一次动作:走的时候顺手记下来,不用第二天再凭记忆翻会话。
|
|
625
|
+
`/keep-load` 只列这份待办。**载入不会把会话移出待办**——出列只有 `/keep-drop` 和列表里的 `ctrl+r` 两条路。
|
|
626
|
+
|
|
627
|
+
「已入账」和「已载入」故意分成两个维度:入账表示没做完,载入表示某个 pi 进程正开着它。后者是**记账不是锁**——
|
|
628
|
+
进程被硬杀会留下脏标记,所以已载入的行仍然可以选中、可以强行重载;那个进程真的没了之后,下一次读取会发现 pid 不在了,
|
|
629
|
+
自动补一条解锁记录。
|
|
630
|
+
|
|
631
|
+
状态是 `<agent-dir>/pi-toolkits-keep/keep.jsonl` 里的只追加事件流(`keep` / `drop` / `load` / `unload`),
|
|
632
|
+
列表是它的纯函数折叠,所以两个 pi 进程可以同时追加,不需要加锁。这里**不调用宿主的会话列表**(本项目 109 个会话要 576 ms,
|
|
633
|
+
整个 agent 目录 648 个要 9.8 s)——日常只读账本,只有 `rebuild` 会在恢复时读每个会话文件的尾部 16 KB。
|
|
634
|
+
|
|
635
|
+
| 命令 | 作用 |
|
|
636
|
+
| --- | --- |
|
|
637
|
+
| `/keep-quit [note]` | 标记当前会话未完成并退出;note 省略时依次回落到会话名、首条用户消息 |
|
|
638
|
+
| `/keep-load` | 打开待办:↑↓ 移动、enter 载入、`ctrl+r` 移出、esc 取消;已载入的行置灰但仍可选中 |
|
|
639
|
+
| `/keep-load <序号\|id>` | 按 1 起序号或会话 id 前缀直接载入 |
|
|
640
|
+
| `/keep-load --all` | 含其他项目,并多一列项目名 |
|
|
641
|
+
| `/keep-load rebuild` | 从会话文件里的面包屑重建账本(账本丢了之后的兜底) |
|
|
642
|
+
| `/keep-drop` | 把当前会话移出待办 |
|
|
643
|
+
|
|
644
|
+
下次交互式启动时,待办只占一行:`2 not loaded · /keep-load`。载入会话后,当初留下的那句备注会作为一条
|
|
645
|
+
**模型能看到、但不触发回合**的消息注入,所以 agent 一上来就知道上次停在哪。列表里永远不出现当前会话本身——
|
|
646
|
+
它的命令是 `/keep-quit` 和 `/keep-drop`。
|
|
647
|
+
|
|
648
|
+
**不是锁。** 两个进程仍然可以同时打开同一个会话文件;这里只记录发生过,不阻止。`pi -ne` 与 headless 运行不写 `load`,
|
|
649
|
+
在这里是不可见的。
|
|
650
|
+
|
|
594
651
|
## 🆕 whats-new — 升级后的版本变更提示
|
|
595
652
|
|
|
596
653
|
<a name="whats-new"></a>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andares/pi-toolkits",
|
|
3
|
-
"version": "1.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), a quit watchdog, and release notes on the first start after an upgrade",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Integrated toolkit extension for pi — ask mode (read-only Q&A), browser-reviewed planning, reply notes in the browser (/ask-talk), 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 session backlog (/keep-quit, /keep-load, /keep-drop), a quit watchdog, and release notes on the first start after an upgrade",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
"spec",
|
|
41
41
|
"spec-review",
|
|
42
42
|
"ask-spec",
|
|
43
|
+
"ask-talk",
|
|
44
|
+
"reply-notes",
|
|
43
45
|
"uat",
|
|
44
46
|
"ask-uat",
|
|
45
47
|
"acceptance",
|
|
@@ -49,7 +51,8 @@
|
|
|
49
51
|
"watchdog",
|
|
50
52
|
"whats-new",
|
|
51
53
|
"release-notes",
|
|
52
|
-
"changelog"
|
|
54
|
+
"changelog",
|
|
55
|
+
"session-backlog"
|
|
53
56
|
],
|
|
54
57
|
"peerDependencies": {
|
|
55
58
|
"@earendil-works/pi-coding-agent": ">=0.99.0",
|
|
@@ -83,7 +86,7 @@
|
|
|
83
86
|
"ui:dev": "pnpm --filter @andares/pi-toolkits-ui dev",
|
|
84
87
|
"ui:build": "pnpm --filter @andares/pi-toolkits-ui build",
|
|
85
88
|
"ui:typecheck": "pnpm --filter @andares/pi-toolkits-ui typecheck",
|
|
86
|
-
"ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/
|
|
89
|
+
"ui:check": "pnpm ui:build && test -z \"$(git status --porcelain -- src/features/review-page/assets src/features/uat/assets)\""
|
|
87
90
|
},
|
|
88
91
|
"pi": {
|
|
89
92
|
"extensions": [
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* keep feature — constants shared by the ledger, the commands and the picker.
|
|
3
|
+
*
|
|
4
|
+
* Two custom entry types are written into the session file itself:
|
|
5
|
+
* - `keep:unfinished` is the breadcrumb appended by `/keep-quit` (display
|
|
6
|
+
* only, out of the model context) and the marker `rebuild` looks for in a
|
|
7
|
+
* session tail;
|
|
8
|
+
* - `keep:notice` carries the one-line startup notice, rendered through
|
|
9
|
+
* `registerEntryRenderer` so `ui.invalidate()` cannot wipe it.
|
|
10
|
+
*
|
|
11
|
+
* `keep:resume` is a `custom_message`, not an entry: it must reach the model
|
|
12
|
+
* (the note left at quit time is the whole point of coming back).
|
|
13
|
+
*/
|
|
14
|
+
import type { KeyId } from "@earendil-works/pi-tui";
|
|
15
|
+
|
|
16
|
+
/** Breadcrumb entry appended when a session is kept. */
|
|
17
|
+
export const KEEP_ENTRY = "keep:unfinished";
|
|
18
|
+
/** Startup notice entry (rendered, never sent to the model). */
|
|
19
|
+
export const KEEP_NOTICE_ENTRY = "keep:notice";
|
|
20
|
+
/** Resume note message injected into the loaded session. */
|
|
21
|
+
export const KEEP_RESUME_ENTRY = "keep:resume";
|
|
22
|
+
|
|
23
|
+
/** `<agent-dir>/pi-toolkits-keep/keep.jsonl`. */
|
|
24
|
+
export const KEEP_DIR = "pi-toolkits-keep";
|
|
25
|
+
export const KEEP_LEDGER_FILE = "keep.jsonl";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Drop the highlighted row without loading it.
|
|
29
|
+
*
|
|
30
|
+
* `ctrl+r` is free where we need it: the host binds it to
|
|
31
|
+
* `app.session.rename` inside its own session selector, and to nothing in
|
|
32
|
+
* `tui.altScreen.*` (the bindings that preempt a dialog) or in the global
|
|
33
|
+
* table. Our picker owns its own component, so it consumes the key itself.
|
|
34
|
+
* Re-audited with `pnpm check:keybindings ctrl+r` — see the feature section in
|
|
35
|
+
* AGENTS.md for the re-check obligation on host upgrades.
|
|
36
|
+
*/
|
|
37
|
+
export const KEEP_DROP_KEY: KeyId = "ctrl+r";
|
|
38
|
+
|
|
39
|
+
/** Rows shown before the list scrolls. */
|
|
40
|
+
export const KEEP_MAX_ROWS = 12;
|
|
41
|
+
/** Note length cap: a note is a reminder, not a summary. */
|
|
42
|
+
export const KEEP_NOTE_MAX = 60;
|
|
43
|
+
/** Bytes read from the end of a session file when rebuilding the ledger. */
|
|
44
|
+
export const KEEP_TAIL_BYTES = 16 * 1024;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* keep feature — text rendering.
|
|
3
|
+
*
|
|
4
|
+
* Pure string building so the rows, the startup notice and the resume note can
|
|
5
|
+
* be asserted without a terminal. Age is deliberately coarse (`12m`, `3h`,
|
|
6
|
+
* `2d`): the exact minute of a decision is in the ledger, not in the list.
|
|
7
|
+
*/
|
|
8
|
+
import { basename } from "node:path";
|
|
9
|
+
import type { KeepEntryView } from "./ledger.js";
|
|
10
|
+
|
|
11
|
+
const MINUTE = 60_000;
|
|
12
|
+
const HOUR = 60 * MINUTE;
|
|
13
|
+
const DAY = 24 * HOUR;
|
|
14
|
+
const WEEK = 7 * DAY;
|
|
15
|
+
|
|
16
|
+
/** `now` / `12m` / `3h` / `2d` / `5w`. */
|
|
17
|
+
export function formatAge(iso: string, now: Date): string {
|
|
18
|
+
const then = Date.parse(iso);
|
|
19
|
+
if (Number.isNaN(then)) return "?";
|
|
20
|
+
const diff = now.getTime() - then;
|
|
21
|
+
if (diff < MINUTE) return "now";
|
|
22
|
+
if (diff < HOUR) return `${Math.floor(diff / MINUTE)}m`;
|
|
23
|
+
if (diff < DAY) return `${Math.floor(diff / HOUR)}h`;
|
|
24
|
+
if (diff < 2 * WEEK) return `${Math.floor(diff / DAY)}d`;
|
|
25
|
+
return `${Math.floor(diff / WEEK)}w`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** `2026-11-24 15:02` in local time (no locale dependence). */
|
|
29
|
+
export function formatStamp(iso: string): string {
|
|
30
|
+
const date = new Date(iso);
|
|
31
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
32
|
+
const pad = (value: number): string => String(value).padStart(2, "0");
|
|
33
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Last path segment, used as the project column with `--all`. */
|
|
37
|
+
export function projectName(cwd: string): string {
|
|
38
|
+
const name = basename(cwd);
|
|
39
|
+
return name.length > 0 ? name : cwd;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* One list row: state glyph, age, note, then optional project and `missing`.
|
|
44
|
+
* `○` is not loaded, `●` is loaded (the row is dimmed by the picker).
|
|
45
|
+
*/
|
|
46
|
+
export function rowText(
|
|
47
|
+
entry: KeepEntryView,
|
|
48
|
+
options: { readonly now: Date; readonly showProject: boolean },
|
|
49
|
+
): string {
|
|
50
|
+
const glyph = entry.loaded ? "●" : "○";
|
|
51
|
+
const age = formatAge(entry.keptAt, options.now);
|
|
52
|
+
const parts = [entry.note.length > 0 ? entry.note : "(no note)"];
|
|
53
|
+
if (options.showProject) parts.push(projectName(entry.cwd));
|
|
54
|
+
if (entry.missing) parts.push("missing");
|
|
55
|
+
return `${glyph} ${age} ${parts.join(" · ")}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Header line above the rows. */
|
|
59
|
+
export function pickerTitle(notLoaded: number, loaded: number): string {
|
|
60
|
+
const parts = [`${notLoaded} not loaded`];
|
|
61
|
+
if (loaded > 0) parts.push(`${loaded} loaded`);
|
|
62
|
+
return `Keep backlog — ${parts.join(", ")}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Startup notice: one line, counts only, current project only. */
|
|
66
|
+
export function noticeText(count: number): string {
|
|
67
|
+
return `${count} not loaded · /keep-load`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Message injected into a loaded session. It is a `custom_message`, so the
|
|
72
|
+
* model sees it on the next turn without the note triggering a turn of its own.
|
|
73
|
+
*/
|
|
74
|
+
export function resumeText(entry: KeepEntryView): string {
|
|
75
|
+
const note = entry.note.length > 0 ? entry.note : "(no note)";
|
|
76
|
+
return `[keep] Resumed from the backlog — note left ${formatStamp(entry.keptAt)}: "${note}"`;
|
|
77
|
+
}
|