@andares/pi-toolkits 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +36 -4
- package/README.zh-CN.md +23 -4
- package/package.json +8 -4
- package/src/features/permission/policy.test.ts +10 -0
- package/src/features/permission/units.test.ts +157 -0
- package/src/features/permission/units.ts +317 -15
- package/src/features/whats-new/changelog.ts +104 -0
- package/src/features/whats-new/constants.ts +35 -0
- package/src/features/whats-new/index.ts +146 -0
- package/src/features/whats-new/notice.ts +68 -0
- package/src/features/whats-new/paths.ts +29 -0
- package/src/features/whats-new/store.ts +114 -0
- package/src/features/whats-new/version.ts +43 -0
- package/src/features/whats-new/whats-new.test.ts +460 -0
- package/src/index.ts +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable, user-visible changes to `@andares/pi-toolkits`. After an upgrade, the
|
|
4
|
+
first interactive `pi` start shows the sections between the version you last ran
|
|
5
|
+
and the one just installed, once. This file keeps the full history.
|
|
6
|
+
|
|
7
|
+
Before releasing, add top-level `- ` bullets under `## Unreleased`. `pnpm release`
|
|
8
|
+
renames that heading to the version being published and refuses an empty section
|
|
9
|
+
(`--skip-changelog` bypasses the gate).
|
|
10
|
+
## Unreleased
|
|
11
|
+
|
|
12
|
+
<!-- Notes for the next release go here; `pnpm release` renames this heading. -->
|
|
13
|
+
|
|
14
|
+
## 0.14.0 — 2026-11-13
|
|
15
|
+
|
|
16
|
+
- **whats-new** — the first interactive `pi` start after an upgrade shows what changed since the version you last ran, once, without registering a slash command.
|
|
17
|
+
- **permission** — fewer false-positive prompts for quoted grep patterns, literal shell loops, `env`, `curl` data flags and read-only container inspection; multi-line commands are now split correctly.
|
|
18
|
+
|
|
19
|
+
## 0.13.0 — 2026-11-12
|
|
20
|
+
|
|
21
|
+
- `/ask-plan` — plan first, review in the browser, then implement: research the task, write a spec, annotate it paragraph by paragraph in a local page, and only get permission to code after approval.
|
|
22
|
+
- `/ask-uat` and the `record_change` tool — change records are clustered into user-facing acceptance items and ticked off on a local page, so "shipped but not verified" is visible instead of implied.
|
|
23
|
+
- `/ask-init refresh` — refresh the framework-owned files of an already-adopted project in place (idempotent, safe).
|
|
24
|
+
- Releases are published by GitHub Actions with npm trusted publishing and carry a provenance attestation.
|
|
25
|
+
|
|
26
|
+
## 0.12.3 — 2026-11-10
|
|
27
|
+
|
|
28
|
+
- quit-guard also arms on a quit event, so a signal-triggered shutdown that hangs before the TUI teardown is still forced out — with the terminal restored first.
|
|
29
|
+
- The watchdog deadline defaults to 8 s (was 10 s); `/quit-guard <ms>` still overrides it.
|
|
30
|
+
|
|
31
|
+
## 0.12.0 — 2026-11-06
|
|
32
|
+
|
|
33
|
+
- `/quit-guard` — force-exit a hung interactive shutdown and give the shell prompt back; a JSON hang report is written first when the deadline passes.
|
|
34
|
+
- Every runtime-facing string is in English.
|
|
35
|
+
|
|
36
|
+
## 0.11.0 — 2026-10-26
|
|
37
|
+
|
|
38
|
+
- `/ask-init` — install or adopt the agent memory framework (`AGENTS.md`, `specs/`, `.agents/`) with a snapshot, a coverage table, and a later drift audit.
|
|
39
|
+
|
|
40
|
+
## 0.10.0 — 2026-10-24
|
|
41
|
+
|
|
42
|
+
- permission — a capped rolling JSONL approval log records each ask, its parsed units and your answer; `pnpm approval-report` turns it into rule candidates.
|
|
43
|
+
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
[](https://github.com/earendil-works/pi)
|
|
14
14
|
[](https://github.com/andares/pi-toolkits)
|
|
15
15
|
|
|
16
|
-
In a nutshell:
|
|
16
|
+
In a nutshell: twelve ready-to-use capabilities — **read-only consult mode** `ask`, **session-scoped boundary permission** `ask-perm`, **model favorites** `favorites`, **prompt stash** `stash`, **third-party code review** `ask-review`, **dedicated compaction model** `compact-model`, **session startup automation** `autostart`, an **agent memory framework** `ask-init`, a **plan review in the browser** `ask-plan`, an **acceptance ledger with a browser page** `ask-uat`, a **quit watchdog** `quit-guard`, and **release notes on the first start after an upgrade** `whats-new` — with more to come.
|
|
17
17
|
|
|
18
18
|
**Requirements**: pi `>=0.99.0`. Every published pi release from 0.99.0 through 1.5.1 has been verified with the full gate (install → `tsc --noEmit` → full test suite → keybinding audit → hash compare of the host files this package patches), each in a sandbox with the whole `@earendil-works/*` family pinned to the version under test. Newer releases are verified as they ship and the floor moves only when the measurement says so; `pnpm check:compat` reproduces the result. Note: pi ≥ 0.99 hosts require host-provided packages to be declared in `peerDependencies` with a `"*"` range — `@earendil-works/pi-tui` and `typebox` (the `scratchpad` tool builds a TypeBox schema) are declared that way; an installed copy in `dependencies` would make pi warn.
|
|
19
19
|
|
|
@@ -58,6 +58,7 @@ After installing, verify in any pi session:
|
|
|
58
58
|
- [🚀 autostart — session startup automation](#autostart)
|
|
59
59
|
- [🧠 init — agent memory framework](#init)
|
|
60
60
|
- [🧯 quit-guard — quit watchdog](#quit-guard)
|
|
61
|
+
- [🆕 whats-new — release notes after an upgrade](#whats-new)
|
|
61
62
|
- [Development](#development)
|
|
62
63
|
- [Contributing](#contributing)
|
|
63
64
|
- [License](#license)
|
|
@@ -81,6 +82,7 @@ After installing, verify in any pi session:
|
|
|
81
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 |
|
|
82
83
|
| 🧠 **init** agent memory framework | `/ask-init` | install or adopt a fixed memory layout (`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`), migrate an existing one with a snapshot and a coverage table, and audit it later for drift, budgets and duplicated facts |
|
|
83
84
|
| 🧯 **quit-guard** quit watchdog | `/quit-guard` | force-exit when an interactive shutdown hangs, whether after the TUI teardown or before it on a signal-triggered quit; write a hang report and give the shell prompt back; TUI restarts and Ctrl+Z resume disarm it |
|
|
85
|
+
| 🆕 **whats-new** release notes after an upgrade | automatic | the first `pi` start after an upgrade shows what changed since the version you last ran, once; no slash command or other global namespace is claimed |
|
|
84
86
|
|
|
85
87
|
---
|
|
86
88
|
|
|
@@ -136,8 +138,11 @@ Repeating the argument form with the modes already in force is a **no-op**: no s
|
|
|
136
138
|
- **bash** is decomposed into simple commands — `&&`, `||`, `;`, pipes, `$(…)`, backticks, `bash -c`, `eval`, the common indirection wrappers (`sudo`, `env`, `xargs`, `find -exec`, …), heredocs — and judged per command. `cd` folds into the commands after it; the strictest result wins, so `cd /tmp && rm x` cannot ride on the first segment.
|
|
137
139
|
- **path-bearing tools** (`read` / `write` / `edit` / `grep` / `find` / `ls`) are judged by their own path; every other tool is judged by the working directory.
|
|
138
140
|
- **unresolvable input** — a non-literal `cd` or `git -C`, an unknown shell variable in a path, an unterminated heredoc or substitution — is asked about regardless of mode (fail closed), never guessed.
|
|
141
|
+
- **literal for-loops** — `for f in a b; do grep x "$f"; done` is expanded with the literal words, because that is what bash does. Ordinary assignments are not persisted across commands without control-flow analysis; an unresolved loop, a value from `$(…)`, or a reassigned/mutated loop variable stays fail-closed. Newlines separate commands (`ls⏎rm x` is two commands, not one), and a backslash-newline is a line continuation.
|
|
142
|
+
- **patterns are not paths** — the first positional operand of `grep`/`rg`/`ag` is the pattern (`grep -n '</div>\s*$' file` asks nothing), and `$` at the end of a quoted string is literal, not a variable.
|
|
139
143
|
- **`git -C <dir>`** is resolved like a local `cd`: relative path arguments (and the repository) are judged against `<dir>`, not the working directory.
|
|
140
|
-
- **device sinks and data arguments** — `/dev/null`, `/dev/stdout` and `/dev/stderr` are never boundary targets, whether written as a redirect (`cmd > /dev/null`) or an operand (`curl -o /dev/null`); the arguments of `echo` / `printf` are data, not paths.
|
|
144
|
+
- **device sinks and data arguments** — `/dev/null`, `/dev/stdout` and `/dev/stderr` are never boundary targets, whether written as a redirect (`cmd > /dev/null`) or an operand (`curl -o /dev/null`); the arguments of `echo` / `printf` are data, not paths, as are declared data flags such as `curl -w` / `-H` / `-d`. Unresolved input and output redirects both stay fail-closed.
|
|
145
|
+
- **container inspection** — `docker`/`podman` subcommands that only inspect (`ps`, `logs`, `inspect`, `images`, `compose ps/logs/config`, …) are reads; `exec`, `run`, `rm`, `build` and everything unlisted stay writes.
|
|
141
146
|
|
|
142
147
|
**Answers**: `a` allow once · `s` allow this directory for the session · `d` deny · `f` deny this directory for the session. Session grants are kept in memory as `(read|write, directory)`, matched by containment, and cleared when the mode is turned off or the session ends. A session grant outranks the destructive table — once you have allowed an operation for the session, repeating it does not ask again. A command the parser cannot resolve is granted by its exact text instead, so repeating the same opaque command does not ask again.
|
|
143
148
|
|
|
@@ -616,6 +621,31 @@ extension registration); once the TUI is gone it is the only channel left.
|
|
|
616
621
|
|
|
617
622
|
---
|
|
618
623
|
|
|
624
|
+
## 🆕 whats-new — release notes after an upgrade
|
|
625
|
+
|
|
626
|
+
<a name="whats-new"></a>
|
|
627
|
+
|
|
628
|
+
**What this does.** The first interactive `pi` start after an upgrade prints the notes for every
|
|
629
|
+
version between the one you last ran and the one you just installed — once. Later starts are
|
|
630
|
+
silent: the version is recorded in `<agent-dir>/pi-toolkits-whats-new.json`, so the notice never
|
|
631
|
+
comes back for that version. A fresh install is silent too (there is no previous version to
|
|
632
|
+
report from), and a downgrade is not an upgrade.
|
|
633
|
+
|
|
634
|
+
The notes are the bundled `CHANGELOG.md`: `pnpm release` renames its `## Unreleased` section to
|
|
635
|
+
the version being published (`--skip-changelog` bypasses that gate), so the notes always describe
|
|
636
|
+
the version that actually shipped. The startup notice is a session entry — it survives theme
|
|
637
|
+
changes and invalidations, and it stays out of the model context, so it costs no tokens. It is
|
|
638
|
+
capped at four versions and six notes per version; the file keeps everything. There is no slash
|
|
639
|
+
command: this is a plugin, and an automatic notice should not occupy the host's command namespace.
|
|
640
|
+
|
|
641
|
+
**Boundaries** — interactive TUI only: print/JSON/RPC sessions have no transcript to append to,
|
|
642
|
+
so they leave the notice for the first interactive start instead of consuming it. Notes appear
|
|
643
|
+
only when the version *increases*; reinstalling or downgrading records nothing new. If
|
|
644
|
+
`CHANGELOG.md` has no section for the running version, the notice still reports the version
|
|
645
|
+
change with an explicit "no release notes bundled" line rather than inventing content.
|
|
646
|
+
|
|
647
|
+
---
|
|
648
|
+
|
|
619
649
|
## 🛠️ Development
|
|
620
650
|
|
|
621
651
|
<a name="development"></a>
|
|
@@ -660,7 +690,9 @@ src/
|
|
|
660
690
|
│ # settings store, hang report, tests
|
|
661
691
|
├── review/ # third-party review: input/command triggers,
|
|
662
692
|
│ # review model config store, prompt, tests
|
|
663
|
-
|
|
693
|
+
├── stash/ # prompt stash: hotkey state machine + tests
|
|
694
|
+
└── whats-new/ # release notes after an upgrade: CHANGELOG parser,
|
|
695
|
+
# last-seen store, startup notice, tests
|
|
664
696
|
```
|
|
665
697
|
|
|
666
698
|
**Adding a feature**: create `src/features/<name>/` exporting `registerXxx(pi)` and call it from `src/index.ts`. Existing modules stay untouched. Each feature ships its own `*.test.ts` (vitest) — keep them deterministic (inject clocks/state, no real agent-dir writes).
|
|
@@ -677,7 +709,7 @@ pnpm release:github # create/verify the GitHub Release for the c
|
|
|
677
709
|
pnpm release:github --audit # list npm versions vs GitHub Releases vs remote tags
|
|
678
710
|
```
|
|
679
711
|
|
|
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.
|
|
712
|
+
Releasing is a **tag push**. `pnpm release` runs the gates (`typecheck`, `test`, UI checks), promotes the `## Unreleased` section of `CHANGELOG.md` to the new version (an empty section aborts the release — `--skip-changelog` opts out), bumps the version, commits, tags `vX.Y.Z`, pushes the branch and the tag — then waits for the GitHub Actions `publish` workflow. That workflow publishes with **npm trusted publishing (OIDC)**: no npm token, no interactive 2FA, and a provenance attestation on every version. The script only reports success once the version is on npm with `dist.attestations` non-empty.
|
|
681
713
|
|
|
682
714
|
`--prepare-only` is the "prepare everything, decide later" switch: it stops after commit+tag and prints the exact push command. `--no-wait` returns right after the push; `--local` is the emergency path that publishes from this machine with the old token. A failed workflow is retried on the same tag (`gh workflow run publish.yml -f tag=vX.Y.Z`); an already-published version is skipped, so the rerun is idempotent.
|
|
683
715
|
|
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`、**升级后首次启动的版本变更提示** `whats-new`,后续持续追加。
|
|
17
17
|
|
|
18
18
|
**版本要求**:pi `>=0.99.0`。0.99.0 到 1.5.1 的每一个已发布版本都用完整门禁实测过(install → `tsc --noEmit` → 全量测试 → 键位审计 → 对 patch 目标宿主文件做哈希比对),每个版本都在沙箱中把整个 `@earendil-works/*` 家族钉在同一版本。更新的版本随发布逐个验证,下限只在实测结果允许时移动;`pnpm check:compat` 可复现该结论。注:pi ≥ 0.99 的宿主要求「宿主提供的包」一律声明为 peerDependencies `"*"` —— `@earendil-works/pi-tui` 与 `typebox`(ask 的 `scratchpad` 用它构造参数 schema)都按此声明;若放进 `dependencies`,pi 会告警。
|
|
19
19
|
|
|
@@ -58,6 +58,7 @@ pi -e ./src/index.ts
|
|
|
58
58
|
- [🚀 autostart — 会话启动自动化](#autostart)
|
|
59
59
|
- [🧠 init — agent 记忆框架](#init)
|
|
60
60
|
- [🧯 quit-guard — 退出看门狗](#quit-guard)
|
|
61
|
+
- [🆕 whats-new — 升级后的版本变更提示](#whats-new)
|
|
61
62
|
- [开发](#development)
|
|
62
63
|
- [贡献](#contributing)
|
|
63
64
|
- [许可](#license)
|
|
@@ -81,6 +82,7 @@ pi -e ./src/index.ts
|
|
|
81
82
|
| 🚀 **autostart** 会话启动自动化 | `.pi/autostart.toml` | 项目内声明启动时自动执行的斜杠命令(首批用例:`/add-dir` 多仓库挂载);未信任不执行、未注册命令跳过不发给模型 |
|
|
82
83
|
| 🧠 **init** agent 记忆框架 | `/ask-init` | 安装或接管一套固定的记忆结构(`AGENTS.md` + `specs/` + `.agents/memory` + `.agents/implementations`),带快照与覆盖表迁移旧文档,之后可随时审计漂移、预算与重复事实 |
|
|
83
84
|
| 🧯 **quit-guard** 退出看门狗 | `/quit-guard` | 交互式退出卡死时,无论发生在 TUI 收尾之后、还是信号触发路径的收尾之前,超时后写诊断报告并强制退出,把命令行提示符还给你;TUI 重启与 Ctrl+Z 恢复都会解除看守 |
|
|
85
|
+
| 🆕 **whats-new** 升级后的版本变更提示 | 自动 | 升级后的首次 `pi` 启动展示「从你上次运行的版本到现在改了什么」,只展示一次;不注册斜杠命令,不占用宿主的全局命令命名空间 |
|
|
84
86
|
|
|
85
87
|
---
|
|
86
88
|
|
|
@@ -136,8 +138,11 @@ pi -e ./src/index.ts
|
|
|
136
138
|
- **bash** 先拆成简单命令 —— `&&`、`||`、`;`、管道、`$(…)`、反引号、`bash -c`、`eval`、常见间接包装(`sudo`、`env`、`xargs`、`find -exec`…)、heredoc —— 再逐条判定;`cd` 向前折叠,取最严格的结果,所以 `cd /tmp && rm x` 不会靠第一段蒙混过关
|
|
137
139
|
- **带路径的工具**(`read` / `write` / `edit` / `grep` / `find` / `ls`)按自己的路径判定;其它工具按工作目录判定
|
|
138
140
|
- **无法解析的输入** —— 非字面量 `cd` 或 `git -C`、路径里的未知 shell 变量、未闭合的 heredoc/命令替换 —— 一律询问,不看模式(fail closed),绝不猜测
|
|
141
|
+
- **字面量 for 循环** —— `for f in a b; do grep x "$f"; done` 按字面量展开(这正是 bash 的行为);普通赋值不跨命令持久化(缺少控制流分析时不能安全替换),值来自 `$(…)`、循环列表不可知、循环变量被重赋值/修改时仍按 fail-closed 处理。换行是命令分隔符(`ls⏎rm x` 是两条命令,不是一条),反斜杠+换行是续行
|
|
142
|
+
- **模式不是路径** —— `grep`/`rg`/`ag` 的第一个位置参数是模式(`grep -n '</div>\s*$' file` 不会询问);引号内的结尾 `$` 是字面字符,不是变量
|
|
139
143
|
- **`git -C <dir>`** 按局部 `cd` 处理:相对路径参数(和仓库本身)按 `<dir>` 判定,而不是工作目录
|
|
140
|
-
- **设备 sink 与数据参数** —— `/dev/null`、`/dev/stdout`、`/dev/stderr` 无论是重定向(`cmd > /dev/null`)还是普通操作数(`curl -o /dev/null`),都不算边界目标;`echo` / `printf`
|
|
144
|
+
- **设备 sink 与数据参数** —— `/dev/null`、`/dev/stdout`、`/dev/stderr` 无论是重定向(`cmd > /dev/null`)还是普通操作数(`curl -o /dev/null`),都不算边界目标;`echo` / `printf` 的参数是数据,`curl -w` / `-H` / `-d` 这类已声明的 data flag 同理。未解析的输入与输出重定向都保持 fail closed
|
|
145
|
+
- **容器只读子命令** —— `docker`/`podman` 的只读子命令(`ps`、`logs`、`inspect`、`images`、`compose ps/logs/config` 等)算读;`exec`、`run`、`rm`、`build` 以及未列出的子命令算写
|
|
141
146
|
|
|
142
147
|
**回答**:`a` 本次允许 · `s` 本会话允许该目录 · `d` 拒绝 · `f` 本会话拒绝该目录。会话授权在内存中按 `(读|写, 目录)` 保存、按包含关系匹配,关闭模式或会话结束时清空;**会话授权优先于破坏性表**——你按了 `s` 之后,重复同一操作不会再弹;解析不了完整路径的命令则按**完整命令文本**授权,重复同一条命令不会再问。
|
|
143
148
|
|
|
@@ -557,6 +562,18 @@ run = [
|
|
|
557
562
|
|
|
558
563
|
---
|
|
559
564
|
|
|
565
|
+
## 🆕 whats-new — 升级后的版本变更提示
|
|
566
|
+
|
|
567
|
+
<a name="whats-new"></a>
|
|
568
|
+
|
|
569
|
+
**做什么。** 升级后第一次进入交互式 `pi` 时,展示「你上次运行的版本 → 刚装上的版本」之间每个版本的变更要点,**只展示一次**。版本号记在 `<agent-dir>/pi-toolkits-whats-new.json`,同一版本之后再怎么进入都不会再弹;全新安装也不弹(没有「上一个版本」可对比),降级不算升级。
|
|
570
|
+
|
|
571
|
+
变更内容来自随包发布的 `CHANGELOG.md`:`pnpm release` 会把 `## Unreleased` 改名成即将发布的版本号(`--skip-changelog` 可跳过这道闸),所以提示里的内容永远对得上真正发出去的那一版。启动提示是一个会话条目 —— 主题切换/invalidate 不会冲掉它,也不进模型上下文(不花 token)。启动提示最多展示 4 个版本、每个版本 6 条;全文始终在 `CHANGELOG.md` 里。不提供斜杠命令:插件只负责自动提示,不占宿主的全局命令命名空间。
|
|
572
|
+
|
|
573
|
+
**边界** —— 只覆盖交互式 TUI:print/JSON/RPC 模式没有可追加的 transcript,会把这次提示留给下一次交互式启动,而不是白白消耗掉。只有版本**升高**时才会提示;重装或降级什么都不记。若 `CHANGELOG.md` 没有当前版本的段落,提示仍会报告版本变化,并明确写「没有内置变更记录」,不会编造内容。
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
560
577
|
## 🛠️ 开发
|
|
561
578
|
|
|
562
579
|
<a name="development"></a>
|
|
@@ -600,7 +617,9 @@ src/
|
|
|
600
617
|
│ # 配置存储、诊断报告、测试
|
|
601
618
|
├── review/ # 第三方评审:输入/指令触发、
|
|
602
619
|
│ # 评审模型配置存储、提示词、测试
|
|
603
|
-
|
|
620
|
+
├── stash/ # 提示词暂存:热键状态机 + 测试
|
|
621
|
+
└── whats-new/ # 升级后的版本变更提示:CHANGELOG 解析、
|
|
622
|
+
# 已见版本存储、启动提示、测试
|
|
604
623
|
```
|
|
605
624
|
|
|
606
625
|
**新增功能**:新建 `src/features/<name>/`,导出 `registerXxx(pi)`,在 `src/index.ts` 中调用;已有模块保持不变。每个功能自带 `*.test.ts`(vitest)——保持确定性(时钟/状态可注入,不写真实 agent-dir)。
|
|
@@ -617,7 +636,7 @@ pnpm release:github # 为当前版本创建/校验 GitHub Releas
|
|
|
617
636
|
pnpm release:github --audit # 列出 npm 版本 vs GitHub Release vs 远端 tag
|
|
618
637
|
```
|
|
619
638
|
|
|
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` 非空时才报成功。
|
|
639
|
+
**发版 = 推 tag。** `pnpm release` 跑完门禁(`typecheck`、`test`、UI 检查)、把 `CHANGELOG.md` 的 `## Unreleased` 提升为即将发布的版本号(段落为空则中止,`--skip-changelog` 可跳过)、改版本、commit、打 `vX.Y.Z` tag、推分支和 tag,然后等 GitHub Actions 的 `publish` 工作流。该工作流用 **npm trusted publishing(OIDC)** 发布:不需要 npm token、不需要交互式 2FA,每个版本自动附 provenance。脚本只在 npm 上真的出现该版本、且 `dist.attestations` 非空时才报成功。
|
|
621
640
|
|
|
622
641
|
`--prepare-only` 是「都准备好、发不发最后再说」的开关:停在 commit+tag 后,打印确切的推送命令。`--no-wait` 推完就返回;`--local` 是应急路径(本机用旧 token 发布)。工作流失败后重跑同一个 tag 即可(`gh workflow run publish.yml -f tag=vX.Y.Z`):已发布的版本会跳过,所以重跑是幂等的。
|
|
623
642
|
|
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,
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "Integrated toolkit extension for pi — ask mode (read-only Q&A), browser-reviewed planning, an acceptance ledger with a browser page, session-scoped permission checks, model favorites, prompt stash, third-party code review, session autostart, a dedicated compaction model, an agent memory framework (/ask-init), and release notes on the first start after an upgrade",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"src"
|
|
15
|
+
"src",
|
|
16
|
+
"CHANGELOG.md"
|
|
16
17
|
],
|
|
17
18
|
"keywords": [
|
|
18
19
|
"pi-package",
|
|
@@ -38,7 +39,10 @@
|
|
|
38
39
|
"uat",
|
|
39
40
|
"acceptance",
|
|
40
41
|
"acceptance-testing",
|
|
41
|
-
"change-record"
|
|
42
|
+
"change-record",
|
|
43
|
+
"whats-new",
|
|
44
|
+
"release-notes",
|
|
45
|
+
"changelog"
|
|
42
46
|
],
|
|
43
47
|
"peerDependencies": {
|
|
44
48
|
"@earendil-works/pi-coding-agent": ">=0.99.0",
|
|
@@ -215,6 +215,16 @@ describe("fail closed", () => {
|
|
|
215
215
|
const decision = decide('cd "$DIR" && rm x', ctx);
|
|
216
216
|
expect(decision.action).toBe("ask");
|
|
217
217
|
});
|
|
218
|
+
|
|
219
|
+
it("does not ignore an unresolved input redirect under strict read modes", () => {
|
|
220
|
+
const cwd = project();
|
|
221
|
+
for (const outRead of ["ask", "deny"] as const) {
|
|
222
|
+
const ctx = makeContext(cwd, { ...DEFAULT_MODES, outRead });
|
|
223
|
+
const decision = decide('cat < "$UNKNOWN"', ctx);
|
|
224
|
+
expect(decision.action).toBe("ask");
|
|
225
|
+
expect(decision.layer).toBe("opaque");
|
|
226
|
+
}
|
|
227
|
+
});
|
|
218
228
|
});
|
|
219
229
|
|
|
220
230
|
describe("decision helpers", () => {
|
|
@@ -219,3 +219,160 @@ describe("fail closed", () => {
|
|
|
219
219
|
expect(first('bash -c "$CMD"').opaque).toBe(true);
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Regressions from the 2026-10-26 → 2026-11-12 approval log (491 records,
|
|
225
|
+
* 61 asks; replaying the commands against the parser showed 52 would still
|
|
226
|
+
* ask). Each case below is one of the false-positive classes that log exposed.
|
|
227
|
+
*/
|
|
228
|
+
describe("approval-log regressions", () => {
|
|
229
|
+
it("keeps a trailing `$` inside a quoted pattern literal", () => {
|
|
230
|
+
const unit = first('grep -n "</div>\\s*$" src/a.vue');
|
|
231
|
+
expect(unit).toMatchObject({ command: "grep", effect: "read", opaque: false });
|
|
232
|
+
expect(unit.targets.map((target) => target.path)).toEqual(["/proj/src/a.vue"]);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("keeps `$` before `|` and `)` inside a quoted pattern literal", () => {
|
|
236
|
+
for (const command of [
|
|
237
|
+
'grep -E "\\.php$"',
|
|
238
|
+
'grep -cE "<STable($|[^A-Za-z])" f',
|
|
239
|
+
'grep -n "label:\\|action\\|$" f',
|
|
240
|
+
]) {
|
|
241
|
+
expect(first(command).opaque).toBe(false);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("treats a backtick inside single quotes as pattern text", () => {
|
|
246
|
+
// Shell: the backtick is literal inside '…'; the old scanner saw an
|
|
247
|
+
// unterminated command substitution and failed the whole command closed.
|
|
248
|
+
const unit = first("grep -rn ':title=\"x`' src/views");
|
|
249
|
+
expect(unit.opaque).toBe(false);
|
|
250
|
+
expect(unit.note).toBeUndefined();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("splits commands separated by a newline (missing writes were possible)", () => {
|
|
254
|
+
const units = summary("ls\nrm -rf /tmp/x");
|
|
255
|
+
expect(units.map((unit) => unit.command)).toEqual(["ls", "rm"]);
|
|
256
|
+
expect(units[1]?.targets).toEqual(["write:/tmp/x"]);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("joins a backslash-newline as a line continuation", () => {
|
|
260
|
+
const units = summary("echo a \\\nb");
|
|
261
|
+
expect(units).toHaveLength(1);
|
|
262
|
+
expect(units[0]?.command).toBe("echo");
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("gives a bare assignment no unit", () => {
|
|
266
|
+
expect(parseCommandUnits("f=2026-10-29.jsonl", CWD)).toEqual([]);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("leaves ordinary assignments unresolved without control-flow analysis", () => {
|
|
270
|
+
const units = summary('f=notes.md; grep -n x "src/$f"');
|
|
271
|
+
expect(units).toHaveLength(1);
|
|
272
|
+
expect(units[0]).toMatchObject({ command: "grep", effect: "write", opaque: true });
|
|
273
|
+
expect(units[0]?.targets).toEqual([]);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("does not substitute a non-literal assignment", () => {
|
|
277
|
+
const units = summary('f=$(date); sed -n 1p "d/$f"');
|
|
278
|
+
expect(units.find((unit) => unit.command === "sed")?.opaque).toBe(true);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it("expands a literal for-loop over real paths", () => {
|
|
282
|
+
const units = summary('for f in a b; do grep -n x "src/$f.vue"; done');
|
|
283
|
+
expect(units.map((unit) => unit.command)).toEqual(["grep", "grep"]);
|
|
284
|
+
expect(units.map((unit) => unit.targets)).toEqual([
|
|
285
|
+
["read:/proj/src/a.vue"],
|
|
286
|
+
["read:/proj/src/b.vue"],
|
|
287
|
+
]);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it("expands a literal loop for cd-like flags (`git -C`)", () => {
|
|
291
|
+
const units = summary('for d in /a /b; do git -C "$d" status; done');
|
|
292
|
+
expect(units).toHaveLength(2);
|
|
293
|
+
expect(units[0]).toMatchObject({ command: "git", base: "/a", opaque: false });
|
|
294
|
+
expect(units[1]).toMatchObject({ command: "git", base: "/b", opaque: false });
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("leaves a loop over a substitution unexpanded (fail closed)", () => {
|
|
298
|
+
const units = summary('for f in $(ls); do sed -n 1p "d/$f"; done');
|
|
299
|
+
const sed = units.find((unit) => unit.command === "sed");
|
|
300
|
+
expect(sed?.opaque).toBe(true);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("treats a plain `env` as a read, not an opaque wrapper", () => {
|
|
304
|
+
const units = summary('env | grep -i "^PI_"');
|
|
305
|
+
expect(units.map((unit) => [unit.command, unit.effect, unit.opaque])).toEqual([
|
|
306
|
+
["env", "read", false],
|
|
307
|
+
["grep", "read", false],
|
|
308
|
+
]);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("does not treat curl data flags as path operands", () => {
|
|
312
|
+
const unit = first("curl -s -o /dev/null -w '%{http_code}\\n' http://localhost:5173/");
|
|
313
|
+
expect(unit.opaque).toBe(false);
|
|
314
|
+
expect(unit.targets).toEqual([]);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it("keeps an unresolved input redirect fail-closed", () => {
|
|
318
|
+
const unit = first('wc -l < "$f"');
|
|
319
|
+
expect(unit).toMatchObject({ command: "wc", effect: "write", opaque: true });
|
|
320
|
+
expect(unit.note).toBe("unresolved redirect target");
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("still fails closed on an unresolved output redirect", () => {
|
|
324
|
+
expect(first('echo x > "$f"').opaque).toBe(true);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it("classifies container inspection subcommands as reads", () => {
|
|
328
|
+
expect(first("docker compose ps --format '{{.Name}}'").effect).toBe("read");
|
|
329
|
+
expect(first("docker ps -a").effect).toBe("read");
|
|
330
|
+
expect(first("docker compose exec worker php -l x").effect).toBe("write");
|
|
331
|
+
expect(first("docker run --rm alpine sh").effect).toBe("write");
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it("does not let a previous assignment shadow a literal loop variable", () => {
|
|
335
|
+
const units = summary('f=/proj; for f in /etc; do rm "$f/x"; done');
|
|
336
|
+
expect(units).toHaveLength(1);
|
|
337
|
+
expect(units[0]?.targets).toEqual(["write:/etc/x"]);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it("uses the inner binding for nested loops with the same variable", () => {
|
|
341
|
+
const units = summary('for f in /proj; do for f in /etc; do rm "$f/x"; done; done');
|
|
342
|
+
expect(units).toHaveLength(1);
|
|
343
|
+
expect(units[0]?.targets).toEqual(["write:/etc/x"]);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it("stops loop expansion after the variable is reassigned", () => {
|
|
347
|
+
const unit = first('for f in /proj; do f=/etc; rm "$f/x"; done');
|
|
348
|
+
expect(unit).toMatchObject({ command: "rm", opaque: true });
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("stops loop expansion after a builtin can mutate the variable", () => {
|
|
352
|
+
const unit = summary('for f in /proj; do read f; rm "$f/x"; done')
|
|
353
|
+
.find((entry) => entry.command === "rm");
|
|
354
|
+
expect(unit).toMatchObject({ command: "rm", opaque: true });
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it("does not treat a conditional assignment as having executed", () => {
|
|
358
|
+
const unit = summary('false && d=/proj; rm "$d/x"')
|
|
359
|
+
.find((entry) => entry.command === "rm");
|
|
360
|
+
expect(unit).toMatchObject({ command: "rm", opaque: true });
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it("does not reuse a literal assignment after `read` changes it", () => {
|
|
364
|
+
const unit = summary('d=/proj; read d; rm "$d/x"')
|
|
365
|
+
.find((entry) => entry.command === "rm");
|
|
366
|
+
expect(unit).toMatchObject({ command: "rm", opaque: true });
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("keeps container output options as writes", () => {
|
|
370
|
+
const unit = first("docker compose config --output /tmp/compose.yml");
|
|
371
|
+
expect(unit.effect).toBe("write");
|
|
372
|
+
expect(unit.targets).toContainEqual({
|
|
373
|
+
path: "/tmp/compose.yml",
|
|
374
|
+
effect: "write",
|
|
375
|
+
source: "operand",
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
});
|