@maxiaochao/pi-toolkit 0.9.3 → 0.9.4
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 +8 -0
- package/README.md +40 -90
- package/extensions/{btw.ts → btw/index.ts} +1 -1
- package/extensions/{tests/btw-history.mjs → btw/tests/history.mjs} +1 -1
- package/package.json +19 -10
- package/packages/cache-export/CHANGELOG.md +5 -0
- package/packages/cache-export/README.md +70 -0
- package/packages/cache-export/TESTING.md +17 -0
- package/packages/cache-export/docs/demo.gif +0 -0
- package/packages/cache-export/docs/screenshot.png +0 -0
- package/{extensions/cache-export/index.ts → packages/cache-export/extensions/cache-export.ts} +1 -1
- package/packages/cache-export/package.json +22 -0
- package/{extensions/cache-export → packages/cache-export/src}/render.ts +1 -1
- package/{extensions → packages}/cache-export/tests/e2e-browser.mjs +2 -2
- package/{extensions → packages}/cache-export/tests/run-tests.mjs +2 -2
- package/packages/codex-edit/CHANGELOG.md +32 -0
- package/packages/codex-edit/README.md +123 -0
- package/packages/codex-edit/TESTING.md +20 -0
- package/{extensions → packages}/codex-edit/codex-edit-explainer.html +41 -20
- package/packages/codex-edit/docs/demo.gif +0 -0
- package/packages/codex-edit/docs/screenshot.png +0 -0
- package/{extensions/codex-edit/index.ts → packages/codex-edit/extensions/codex-edit.ts} +3 -3
- package/packages/codex-edit/package.json +48 -0
- package/{extensions/codex-edit → packages/codex-edit/src}/parser.ts +1 -2
- package/{extensions → packages}/codex-edit/summary.md +1 -1
- package/{extensions → packages}/codex-edit/tests/package.test.mjs +12 -7
- package/{extensions → packages}/codex-edit/tests/parser.test.mjs +100 -3
- package/packages/tiny-subagent/CHANGELOG.md +12 -0
- package/packages/tiny-subagent/README.md +128 -0
- package/packages/tiny-subagent/TESTING.md +20 -0
- package/packages/tiny-subagent/agents/worker.md +9 -0
- package/packages/tiny-subagent/docs/demo.gif +0 -0
- package/packages/tiny-subagent/docs/screenshot.png +0 -0
- package/packages/tiny-subagent/extensions/tiny-subagent.ts +228 -0
- package/packages/tiny-subagent/package.json +44 -0
- package/packages/tiny-subagent/src/personas.ts +110 -0
- package/packages/tiny-subagent/src/runner.ts +319 -0
- package/packages/tiny-subagent/tests/run-tests.mjs +111 -0
- package/packages/todo/CHANGELOG.md +5 -0
- package/packages/todo/README.md +63 -0
- package/packages/todo/TESTING.md +20 -0
- package/packages/todo/docs/demo.gif +0 -0
- package/packages/todo/docs/screenshot.png +0 -0
- package/{extensions → packages/todo/extensions}/todo.ts +1 -1
- package/packages/todo/package.json +25 -0
- package/{extensions → packages/todo}/tests/todo-state.mjs +1 -1
- package/packages/worktree/CHANGELOG.md +5 -0
- package/packages/worktree/README.md +60 -0
- package/packages/worktree/TESTING.md +21 -0
- package/packages/worktree/docs/demo.gif +0 -0
- package/packages/worktree/docs/screenshot.png +0 -0
- package/packages/worktree/package.json +20 -0
- package/packages/worktree/scripts/install.mjs +26 -0
- package/packages/worktree/tests/install.test.mjs +25 -0
- package/packages/worktree/tests/run-tests.sh +46 -0
- package/scripts/install-agents.mjs +8 -18
- package/extensions/codex-edit/README.md +0 -53
- /package/extensions/{btw-scroll.ts → btw/scroll.ts} +0 -0
- /package/{extensions/cache-export → packages/cache-export/src}/tau-assets.ts +0 -0
- /package/{extensions → packages}/codex-edit/config.json +0 -0
- /package/{extensions/codex-edit → packages/codex-edit/src}/model-routing.ts +0 -0
- /package/{extensions → packages/todo/src}/todo-state.ts +0 -0
- /package/{bin → packages/worktree/bin}/pi-worktree +0 -0
- /package/{bin → packages/worktree/bin}/pi-worktree-completion.bash +0 -0
- /package/{skills → packages/worktree/skills}/pi-worktree/SKILL.md +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 2026-09-30 - v0.9.4
|
|
2
|
+
|
|
3
|
+
- retain Codex Edit in the root toolkit while restoring `@maxiaochao/pi-codex-edit` as an independently installable child package; both distributions share the implementation under `packages/codex-edit`
|
|
4
|
+
- align repeated-region hunk matching with Codex by selecting the first match at or after the current cursor
|
|
5
|
+
- reorganize the repository as an npm workspace: todo, cache-export, codex-edit, tiny-subagent, and worktree own their source, docs, tests, versions, and child-package releases while the root manifest loads their entrypoints directly; BTW remains root-only
|
|
6
|
+
- expand every child README with motivation or upstream alignment, usage examples, screenshots and animated demos captured from the real implementation; document Cache Export's alignment with Hugging Face Tau
|
|
7
|
+
- coordinate child and toolkit releases from one commit with two version updates, two tags, and one atomic push so standalone and bundled users cannot receive mismatched source revisions
|
|
8
|
+
|
|
1
9
|
## 2026-09-30 - v0.9.3
|
|
2
10
|
|
|
3
11
|
- refine global agent guidance and add repository issue, triage, and domain instructions
|
package/README.md
CHANGED
|
@@ -1,125 +1,75 @@
|
|
|
1
1
|
# pi-toolkit
|
|
2
2
|
|
|
3
|
-
Personal Pi
|
|
3
|
+
Personal Pi distribution that bundles focused extensions, agent skills, the Night Owl theme, global instructions, and the `pi-worktree` CLI.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
Install the
|
|
7
|
+
Install the complete toolkit:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pi install npm:@maxiaochao/pi-toolkit
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
The package postinstall hook synchronizes the bundled global instructions to:
|
|
16
|
-
|
|
17
|
-
```text
|
|
18
|
-
~/.pi/agent/AGENTS.md
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
It also selects `nightowl` as the default theme only when `~/.pi/agent/settings.json` does not already contain a theme. To switch manually, use `/settings` or:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
pi --use-theme nightowl
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
An installed package can expose a theme through `pi.themes`, but Pi has no package-manifest field for a default theme, so the guarded postinstall step is used for the npm install case.
|
|
28
|
-
|
|
29
|
-
When `global/AGENTS.md` changes, publish a new `@maxiaochao/pi-toolkit` version and update installed copies:
|
|
13
|
+
Update it:
|
|
30
14
|
|
|
31
15
|
```bash
|
|
32
16
|
pi update npm:@maxiaochao/pi-toolkit
|
|
33
17
|
```
|
|
34
18
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
bash scripts/install.sh
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The `todo` tool maintains a session checklist for explicit plans and multi-step work. It automatically keeps one task active and advances the next queued task; `replace` starts a clean plan after a change of direction, while `cancelled` records obsolete work honestly. The persistent widget numbers active work by queue position; `/todos` shows active and closed tasks with their stable internal IDs.
|
|
42
|
-
|
|
43
|
-
The `/btw` side chat is a separate agent session. It can inspect the main conversation and repository, and its thread stays out of the main context until you close it and choose to inject a summary. Use `/btw` to open it or `/btw <question>` to ask directly. While the BTW overlay has focus, use `Up` / `Down` to scroll its transcript one line at a time and `PageUp` / `PageDown` to move by one transcript page.
|
|
44
|
-
|
|
45
|
-
Use `/cache_export [path]` to write an interactive per-request cache dashboard. It defaults to the latest Context segment for current-state diagnosis, and the View selector can show any earlier segment or all session history. Compaction and model changes both break context charts into segments; cache-hit accumulation also resets at model changes, while TTL and other inferred interruptions remain diagnostic events rather than segment boundaries.
|
|
46
|
-
|
|
47
|
-
The bundled `nightowl` theme is available to Pi through the package manifest and is selected automatically on npm installation only when no theme is already configured.
|
|
48
|
-
|
|
49
|
-
## pi-worktree CLI
|
|
50
|
-
|
|
51
|
-
The package also ships a standalone shell command, `pi-worktree`, that wraps Git worktree creation and Pi launch into one step. On installation (Unix-like systems) the postinstall hook copies it to `~/.local/bin/pi-worktree` and installs bash completion to `~/.local/share/bash-completion/completions/pi-worktree` (no `.bashrc` edits needed).
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
pi-worktree start feat-ui # create/reuse .worktrees/feat-ui, branch feat-ui, launch pi inside
|
|
55
|
-
pi-worktree list # list worktrees (main checkout marked "main checkout")
|
|
56
|
-
pi-worktree info feat-ui # base commit, ahead/behind main, unique commits
|
|
57
|
-
pi-worktree out # open a shell in the main checkout (for merging)
|
|
58
|
-
pi-worktree remove feat-ui # remove the worktree (refuses unmerged branches)
|
|
59
|
-
pi-worktree prune # drop stale registrations for manually deleted dirs
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Typical loop: `pi-worktree start <name>` to start (Tab completes existing worktree names), commit inside Pi, `pi-worktree out` + `git merge <name>` to land the work, `pi-worktree remove <name>` to clean up. New branches are created from the branch you're currently on (or `HEAD` when detached), and the base commit is recorded in `branch.<name>.base` config so `info` can always tell you where the branch came from. Bash completion covers subcommands and existing worktree names (`pi-worktree feat<Tab>`).
|
|
63
|
-
|
|
64
|
-
The bundled `pi-worktree` skill documents the CLI for agents: the `start`/`list`/`info`/`out`/`remove`/`prune` commands, the isolation loop from creating a worktree to landing the merge, and which of those commands need an interactive terminal (so an agent uses `start <name> -p "<task>"` for a headless nested run).
|
|
19
|
+
The root package embeds the child-package source snapshots listed below. Install the complete toolkit or selected standalone children, not both.
|
|
65
20
|
|
|
66
|
-
|
|
21
|
+
## Child packages
|
|
67
22
|
|
|
68
|
-
|
|
23
|
+
| Package | Capability | Install | Update |
|
|
24
|
+
|---|---|---|---|
|
|
25
|
+
| [pi-todo](packages/todo/README.md) | Session plans, automatic task advancement, `/todos` | `pi install npm:@maxiaochao/pi-todo` | `pi update npm:@maxiaochao/pi-todo` |
|
|
26
|
+
| [pi-cache-export](packages/cache-export/README.md) | Tau-aligned interactive cache dashboard for Pi sessions | `pi install npm:@maxiaochao/pi-cache-export` | `pi update npm:@maxiaochao/pi-cache-export` |
|
|
27
|
+
| [pi-codex-edit](packages/codex-edit/README.md) | Codex-harness `apply_patch` routing for selected GPT models | `pi install npm:@maxiaochao/pi-codex-edit` | `pi update npm:@maxiaochao/pi-codex-edit` |
|
|
28
|
+
| [pi-tiny-subagent](packages/tiny-subagent/README.md) | One focused task in a fresh child Pi context | `pi install npm:@maxiaochao/pi-tiny-subagent` | `pi update npm:@maxiaochao/pi-tiny-subagent` |
|
|
29
|
+
| [pi-worktree](packages/worktree/README.md) | Worktree CLI, completion, installer, and agent skill | `pi install npm:@maxiaochao/pi-worktree` | `pi update npm:@maxiaochao/pi-worktree` |
|
|
69
30
|
|
|
70
|
-
|
|
71
|
-
node skills/web-browser/scripts/start.js --headless
|
|
72
|
-
node skills/web-browser/scripts/nav.js https://example.com
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
The bundled `chrome-cdp` skill (derived from [pasky/chrome-cdp-skill](https://github.com/pasky/chrome-cdp-skill), MIT) complements `web-browser`: instead of launching an isolated browser, it attaches to a Chrome session that already runs with remote debugging (port pre-allocated at launch, or the `chrome://inspect/#remote-debugging` toggle). It is a zero-dependency CLI (`scripts/cdp.mjs`, Node 22+) with per-tab daemons so Chrome's "Allow debugging" modal fires once:
|
|
31
|
+
Each child README owns its feature description, motivation or upstream alignment, examples, screenshots/demos, configuration, and test documentation.
|
|
76
32
|
|
|
77
|
-
|
|
78
|
-
export CDP_PORT_FILE="/mnt/c/Users/<you>/AppData/Local/Google/Chrome/CDP-Profile/DevToolsActivePort"
|
|
79
|
-
node skills/chrome-cdp/scripts/cdp.mjs list # list open tabs → target prefix
|
|
80
|
-
node skills/chrome-cdp/scripts/cdp.mjs snap <target> # accessibility tree
|
|
81
|
-
node skills/chrome-cdp/scripts/cdp.mjs eval <target> 'document.title'
|
|
82
|
-
```
|
|
33
|
+
Multiple standalone children may be installed together. Do not install a child alongside the complete toolkit because that exposes the same resource twice.
|
|
83
34
|
|
|
84
|
-
|
|
35
|
+
Root and child versions remain independent, but repository release tooling publishes a modified child and a new toolkit snapshot from the same commit. Run `pi update --extensions` to update all installed packages. Explicit version sources such as `npm:@maxiaochao/pi-toolkit@0.9.3` remain pinned.
|
|
85
36
|
|
|
86
|
-
|
|
37
|
+
## Toolkit-only features
|
|
87
38
|
|
|
88
|
-
|
|
39
|
+
### `/btw`
|
|
89
40
|
|
|
90
|
-
|
|
41
|
+
`/btw` opens a separate side-chat session that can inspect the main conversation and repository without entering the main context. Closing it can optionally inject a summary. Use `Up` / `Down` for line scrolling and `PageUp` / `PageDown` for page scrolling.
|
|
91
42
|
|
|
92
|
-
|
|
43
|
+
### Global instructions and theme
|
|
93
44
|
|
|
94
|
-
The
|
|
45
|
+
The postinstall hook:
|
|
95
46
|
|
|
96
|
-
|
|
47
|
+
- synchronizes `global/AGENTS.md` to `~/.pi/agent/AGENTS.md`;
|
|
48
|
+
- selects `nightowl` only when no theme is configured;
|
|
49
|
+
- installs the bundled worktree CLI and bash completion.
|
|
97
50
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
The tiny subagent is a separate npm package. Install it independently when you want the `tiny_subagents` tool:
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
pi install npm:@maxiaochao/pi-tiny-subagent
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
It is not included in the root package's `pi.extensions` list. The two packages have independent versions, release tags, and update commands:
|
|
51
|
+
Existing theme choices are preserved. To sync only the global instructions from a checkout:
|
|
107
52
|
|
|
108
53
|
```bash
|
|
109
|
-
|
|
110
|
-
pi update npm:@maxiaochao/pi-tiny-subagent
|
|
54
|
+
bash scripts/install.sh
|
|
111
55
|
```
|
|
112
56
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
## Codex Edit (apply_patch)
|
|
116
|
-
|
|
117
|
-
The `apply_patch` extension ships with the toolkit as part of `pi.extensions`. It activates Codex's freeform `apply_patch` protocol for GPT/Codex models while other models keep Pi's native `edit` tool. Routing is by model ID (`gpt-5.6-*`) plus API (`openai-responses` or `openai-codex-responses`); provider does not matter. For every other model the extension only re-syncs an already-active editor tool, so it is a no-op.
|
|
57
|
+
## Bundled skills
|
|
118
58
|
|
|
119
|
-
|
|
59
|
+
| Skill | Purpose |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `web-browser` | Launch and automate an isolated Chrome/Chromium session through CDP |
|
|
62
|
+
| `chrome-cdp` | Attach to an existing Chrome debugging session |
|
|
63
|
+
| `show-me` | Explain the current topic with the smallest useful visual |
|
|
64
|
+
| `html-artifact` | Build self-contained HTML explainers and diagrams |
|
|
65
|
+
| `pdlog` | Decompress and inspect Pudu `.pdlog` files |
|
|
66
|
+
| `herdr` | Control Herdr workspaces, tabs, panes, and agents |
|
|
67
|
+
| `agent-team` | Run cross-vendor adversarial review through Herdr |
|
|
68
|
+
| `tapd` | Use the TAPD CLI for requirements, defects, tasks, and wikis |
|
|
69
|
+
| `calldiff` | Diff call stacks across commits |
|
|
120
70
|
|
|
121
|
-
|
|
71
|
+
Package-specific skills, such as `pi-worktree`, are documented by their child package.
|
|
122
72
|
|
|
123
|
-
##
|
|
73
|
+
## Repository
|
|
124
74
|
|
|
125
|
-
|
|
75
|
+
This repository is an npm workspace. Child implementations live under `packages/*`; `extensions/` contains only the toolkit-only BTW module. Development, testing, media generation, and release rules are documented in [AGENTS.md](AGENTS.md).
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
type OverlayHandle,
|
|
25
25
|
type TUI,
|
|
26
26
|
} from "@earendil-works/pi-tui";
|
|
27
|
-
import { clampBtwScrollTop, getBtwPageScrollSize } from "./
|
|
27
|
+
import { clampBtwScrollTop, getBtwPageScrollSize } from "./scroll.ts";
|
|
28
28
|
|
|
29
29
|
const BTW_ENTRY_TYPE = "btw-thread-entry";
|
|
30
30
|
const BTW_RESET_TYPE = "btw-thread-reset";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import { clampBtwScrollTop, getBtwPageScrollSize } from "../
|
|
2
|
+
import { clampBtwScrollTop, getBtwPageScrollSize } from "../scroll.ts";
|
|
3
3
|
|
|
4
4
|
assert.equal(getBtwPageScrollSize(18), 18, "page scrolling uses the transcript viewport height");
|
|
5
5
|
assert.equal(getBtwPageScrollSize(8.9), 8, "page scrolling uses a whole number of lines");
|
package/package.json
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxiaochao/pi-toolkit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "Personal pi coding agent toolkit: /todos, /btw, /cache_export and apply_patch extensions, browser automation, and bundled theme/skills.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"workspaces": [
|
|
7
|
+
"packages/*"
|
|
8
|
+
],
|
|
6
9
|
"keywords": [
|
|
7
10
|
"pi-package",
|
|
8
11
|
"pi-extension"
|
|
9
12
|
],
|
|
10
13
|
"files": [
|
|
11
14
|
"extensions",
|
|
15
|
+
"packages/todo",
|
|
16
|
+
"packages/cache-export",
|
|
17
|
+
"packages/codex-edit",
|
|
18
|
+
"packages/tiny-subagent",
|
|
19
|
+
"packages/worktree",
|
|
12
20
|
"themes",
|
|
13
|
-
"bin",
|
|
14
21
|
"README.md",
|
|
15
22
|
"CHANGELOG.md",
|
|
16
23
|
"global/AGENTS.md",
|
|
@@ -23,20 +30,22 @@
|
|
|
23
30
|
},
|
|
24
31
|
"pi": {
|
|
25
32
|
"extensions": [
|
|
26
|
-
"./extensions/todo.ts",
|
|
27
|
-
"./extensions/cache-export
|
|
28
|
-
"./extensions/btw.ts",
|
|
29
|
-
"./extensions/codex-edit
|
|
33
|
+
"./packages/todo/extensions/todo.ts",
|
|
34
|
+
"./packages/cache-export/extensions/cache-export.ts",
|
|
35
|
+
"./extensions/btw/index.ts",
|
|
36
|
+
"./packages/codex-edit/extensions/codex-edit.ts",
|
|
37
|
+
"./packages/tiny-subagent/extensions/tiny-subagent.ts"
|
|
30
38
|
],
|
|
31
39
|
"skills": [
|
|
32
|
-
"./skills"
|
|
40
|
+
"./skills",
|
|
41
|
+
"./packages/worktree/skills"
|
|
33
42
|
],
|
|
34
43
|
"themes": [
|
|
35
44
|
"./themes"
|
|
36
45
|
]
|
|
37
46
|
},
|
|
38
47
|
"bin": {
|
|
39
|
-
"pi-worktree": "bin/pi-worktree"
|
|
48
|
+
"pi-worktree": "packages/worktree/bin/pi-worktree"
|
|
40
49
|
},
|
|
41
50
|
"peerDependencies": {
|
|
42
51
|
"@earendil-works/pi-ai": "*",
|
|
@@ -48,8 +57,8 @@
|
|
|
48
57
|
"ws": "^8.19.0"
|
|
49
58
|
},
|
|
50
59
|
"scripts": {
|
|
51
|
-
"test": "
|
|
52
|
-
"load-test": "pi -ne -e ./extensions/todo.ts && pi -ne -e ./extensions/cache-export
|
|
60
|
+
"test": "node tests/package-layout.mjs && npm --prefix packages/todo test && npm --prefix packages/cache-export test && npm --prefix packages/codex-edit test && npm --prefix packages/tiny-subagent test && npm --prefix packages/worktree test && node --experimental-strip-types extensions/btw/tests/history.mjs",
|
|
61
|
+
"load-test": "pi -ne -e ./packages/todo/extensions/todo.ts && pi -ne -e ./packages/cache-export/extensions/cache-export.ts && pi -ne -e ./extensions/btw/index.ts && pi -ne -e ./packages/codex-edit/extensions/codex-edit.ts && pi -ne -e ./packages/tiny-subagent/extensions/tiny-subagent.ts",
|
|
53
62
|
"eval:agents": "node evaluations/agents-md/run.mjs",
|
|
54
63
|
"eval:agents:test": "node evaluations/agents-md/tests/run-tests.mjs",
|
|
55
64
|
"postinstall": "node scripts/install-agents.mjs"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @maxiaochao/pi-cache-export
|
|
2
|
+
|
|
3
|
+
Pi 的 `/cache_export [path]` 扩展,把当前会话写成可交互的缓存诊断 HTML。
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## 为什么有这个包
|
|
8
|
+
|
|
9
|
+
这个功能对齐 [Hugging Face Tau](https://github.com/huggingface/tau) coding agent 的 session usage / cache dashboard。`src/tau-assets.ts` 与仪表盘基础逻辑来自 Tau 的 `tau_coding/session_usage.py`,本包把它适配到 Pi session,并增加:
|
|
10
|
+
|
|
11
|
+
- Pi 消息、tool result、模型切换和 compaction 解析。
|
|
12
|
+
- 按 Context segment 查看最新上下文、历史 segment 或全部历史。
|
|
13
|
+
- cache miss、TTL expiry、cache rebuild 和低命中 streak 诊断。
|
|
14
|
+
- 跨图表断点的 tooltip,以及 segment 内的全局请求编号。
|
|
15
|
+
|
|
16
|
+
Tau 资产保持上游一致;上述 Pi 语义和诊断规则由本包维护。
|
|
17
|
+
|
|
18
|
+
## 演示
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
/cache_export
|
|
24
|
+
/cache_export ./reports/cache.html
|
|
25
|
+
/cache_export --open
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
命令读取当前 session,生成自包含 HTML;`--open` 在支持的桌面环境中同时打开浏览器。
|
|
29
|
+
|
|
30
|
+
## 安装
|
|
31
|
+
|
|
32
|
+
完整工具包已经包含本扩展:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pi install npm:@maxiaochao/pi-toolkit
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
只需要缓存仪表盘时单独安装:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pi install npm:@maxiaochao/pi-cache-export
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
两种方式二选一,避免重复注册。
|
|
45
|
+
|
|
46
|
+
## 更新
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pi update npm:@maxiaochao/pi-toolkit # 更新主包内置版本
|
|
50
|
+
pi update npm:@maxiaochao/pi-cache-export # 更新独立子包
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
两个 npm 包版本独立。Cache Export 源码变更需要分别发布主包和子包,才能覆盖两类用户。
|
|
54
|
+
|
|
55
|
+
## 功能
|
|
56
|
+
|
|
57
|
+
- 默认展示最新 Context segment,也可切换历史 segment 或全部历史。
|
|
58
|
+
- 模型切换和 compaction 切分 segment。
|
|
59
|
+
- 诊断 cache miss、TTL、cache rebuild 和低命中 streak。
|
|
60
|
+
- 导出的 HTML 自包含,可离线查看。
|
|
61
|
+
|
|
62
|
+
## 开发与测试
|
|
63
|
+
|
|
64
|
+
权威源码位于 `extensions/` 和 `src/`。`src/tau-assets.ts` 必须由上游资产重生成,禁止手改。测试流程、数据用例和结果见 [TESTING.md](TESTING.md)。
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm --prefix packages/cache-export test
|
|
68
|
+
npm --prefix packages/cache-export run load-test
|
|
69
|
+
npm pack ./packages/cache-export --dry-run
|
|
70
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Cache Export 测试方案
|
|
2
|
+
|
|
3
|
+
## 流程
|
|
4
|
+
|
|
5
|
+
1. `npm --prefix packages/cache-export test`:先运行确定性逻辑测试,再运行真实 Chromium E2E。
|
|
6
|
+
2. `npm --prefix packages/cache-export run load-test`:加载扩展入口。
|
|
7
|
+
3. `npm pack ./packages/cache-export --dry-run`:检查 tarball。
|
|
8
|
+
4. 确认 Tau 来源说明、功能示例、真实浏览器截图 `docs/screenshot.png` 和 `docs/demo.gif` 随包发布。
|
|
9
|
+
|
|
10
|
+
## 用例数据
|
|
11
|
+
|
|
12
|
+
- 47 个确定性断言:命中率阈值、TTL、cache rebuild、模型切换、compaction、segment 和退化输入。
|
|
13
|
+
- 18 个浏览器断言:三张图的 tooltip、断点两侧、全历史视图、segment 全局请求号和浏览器异常。
|
|
14
|
+
|
|
15
|
+
## 最近验证结果
|
|
16
|
+
|
|
17
|
+
迁移前基线为 `47 passed, 0 failed` 和 `18 passed, 0 failed, 0 skipped`。找不到 Chrome 时 E2E 会明确报告 skip;发布验收要求可用 Chrome 的环境中 0 skip。
|
|
Binary file
|
|
Binary file
|
package/{extensions/cache-export/index.ts → packages/cache-export/extensions/cache-export.ts}
RENAMED
|
@@ -9,7 +9,7 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { basename, dirname, join, resolve } from "node:path";
|
|
11
11
|
import { spawnSync } from "node:child_process";
|
|
12
|
-
import { parseEntries, buildCacheExportHtml } from "
|
|
12
|
+
import { parseEntries, buildCacheExportHtml } from "../src/render.ts";
|
|
13
13
|
|
|
14
14
|
const DEFAULT_DIR = join(homedir(), ".cache", "pi-cache-dashboard");
|
|
15
15
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maxiaochao/pi-cache-export",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Interactive cache usage dashboard export for Pi sessions.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": ["pi-package", "pi-extension", "cache", "dashboard"],
|
|
7
|
+
"files": ["extensions", "src", "docs", "README.md", "TESTING.md", "CHANGELOG.md"],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/chaochaoxiaochao/pi-toolkit.git",
|
|
11
|
+
"directory": "packages/cache-export"
|
|
12
|
+
},
|
|
13
|
+
"pi": { "extensions": ["./extensions/cache-export.ts"] },
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "node --experimental-strip-types tests/run-tests.mjs && node tests/e2e-browser.mjs",
|
|
19
|
+
"load-test": "pi -ne -e ./extensions/cache-export.ts"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": { "access": "public" }
|
|
22
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tau-style usage/cache dashboard renderer.
|
|
2
2
|
// Logic ported from huggingface/tau src/tau_coding/session_usage.py (render_usage_dashboard),
|
|
3
|
-
// interactivity/styles auto-extracted into ./tau-assets.
|
|
3
|
+
// interactivity/styles auto-extracted into ./tau-assets.ts.
|
|
4
4
|
|
|
5
5
|
import { USAGE_STYLES, USAGE_SCRIPT } from "./tau-assets.ts";
|
|
6
6
|
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
// test prints SKIP and exits 0 so CI without Chrome still passes; if a
|
|
9
9
|
// browser IS found, failing assertions exit 1.
|
|
10
10
|
//
|
|
11
|
-
// Run: node tests/e2e-browser.mjs (from
|
|
11
|
+
// Run: node tests/e2e-browser.mjs (from packages/cache-export)
|
|
12
12
|
|
|
13
13
|
import { spawn, execFileSync } from "node:child_process";
|
|
14
14
|
import { existsSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
|
|
15
15
|
import net from "node:net";
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
17
|
import { join } from "node:path";
|
|
18
|
-
import { parseEntries, buildCacheExportHtml } from "../render.ts";
|
|
18
|
+
import { parseEntries, buildCacheExportHtml } from "../src/render.ts";
|
|
19
19
|
|
|
20
20
|
let pass = 0, fail = 0, skipped = 0;
|
|
21
21
|
function check(name, cond, detail = "") {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
|
-
import registerCacheExport from "../
|
|
7
|
-
import { parseEntries, analyzeStreaks, analyzeMisses, buildContextSegments, lineChartForTest, renderDashboard, chartEvents } from "../render.ts";
|
|
6
|
+
import registerCacheExport from "../extensions/cache-export.ts";
|
|
7
|
+
import { parseEntries, analyzeStreaks, analyzeMisses, buildContextSegments, lineChartForTest, renderDashboard, chartEvents } from "../src/render.ts";
|
|
8
8
|
|
|
9
9
|
let pass = 0, fail = 0;
|
|
10
10
|
function check(name, cond, detail = "") {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
## 2026-09-30 - v0.1.7
|
|
2
|
+
|
|
3
|
+
- match Codex `apply_patch` semantics by selecting the first matching region at or after the current hunk cursor
|
|
4
|
+
- add standalone package testing documentation and real parser-generated screenshot/demo media
|
|
5
|
+
|
|
6
|
+
## 2026-09-30 - v0.1.6
|
|
7
|
+
|
|
8
|
+
- route apply_patch by API plus model-ID glob instead of requiring grammar-tool support
|
|
9
|
+
|
|
10
|
+
## 2026-09-08 - v0.1.5
|
|
11
|
+
|
|
12
|
+
- route gpt-5.6-* models to apply_patch by model glob
|
|
13
|
+
|
|
14
|
+
## 2026-09-04 - v0.1.4
|
|
15
|
+
|
|
16
|
+
- update Luna High rerun statistics and paired timing methodology
|
|
17
|
+
|
|
18
|
+
## 2026-09-04 - v0.1.3
|
|
19
|
+
|
|
20
|
+
- correct Luna timing analysis to count only completed correct runs
|
|
21
|
+
|
|
22
|
+
## 2026-09-04 - v0.1.2
|
|
23
|
+
|
|
24
|
+
- default to validated Sol routing and document Luna High benchmark variance
|
|
25
|
+
|
|
26
|
+
## 2026-09-04 - v0.1.1
|
|
27
|
+
|
|
28
|
+
- fix package config discovery so GPT/Codex model routing activates apply_patch
|
|
29
|
+
|
|
30
|
+
## 2026-09-04 - v0.1.0
|
|
31
|
+
|
|
32
|
+
- initial release of the Codex-style apply_patch Pi extension and docs
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Codex Edit (apply_patch)
|
|
2
|
+
|
|
3
|
+
A Pi extension that gives selected GPT models the same `apply_patch` editing protocol used by the Codex harness, while every model outside the routing rules keeps Pi's native `edit` tool.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Why this package exists
|
|
8
|
+
|
|
9
|
+
GPT models used through the Codex harness are trained to edit with OpenAI's `apply_patch` protocol, while Pi's native editor uses a different `oldText/newText` contract. This package exposes the Codex-harness editing interface inside Pi for explicitly allowed models. Models that do not match the rules continue to see Pi's native `edit`; the extension never replaces the editor universally.
|
|
10
|
+
|
|
11
|
+
The implementation follows Codex's ordered hunk matching semantics and supports the same Add/Delete/Update/Move patch shape, then adds workspace, symlink, overwrite, preflight, and mutation-queue safeguards required by Pi.
|
|
12
|
+
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
*** Begin Patch
|
|
19
|
+
*** Update File: src/app.ts
|
|
20
|
+
@@
|
|
21
|
+
-const enabled = false;
|
|
22
|
+
+const enabled = true;
|
|
23
|
+
*** End Patch
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The complete patch is parsed and preflighted before any file is mutated; the result reports per-file diffs and committed paths.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
Install it as a separate package:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pi install npm:@maxiaochao/pi-codex-edit
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This is the standalone child package of `@maxiaochao/pi-toolkit`. The full toolkit already bundles the same implementation, so install this package only when you do not want the rest of the toolkit. Installing both is unnecessary and may register `apply_patch` twice.
|
|
37
|
+
|
|
38
|
+
Update whichever distribution you installed:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pi update npm:@maxiaochao/pi-toolkit # full toolkit, including bundled Codex Edit
|
|
42
|
+
pi update npm:@maxiaochao/pi-codex-edit # standalone child package
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The two npm packages have independent versions. An implementation or configuration change reaches toolkit users only after a new `@maxiaochao/pi-toolkit` version is published, and reaches standalone users only after a new `@maxiaochao/pi-codex-edit` version is published.
|
|
46
|
+
|
|
47
|
+
The extension registers `apply_patch` and selects the editing tool from the resolved model configuration:
|
|
48
|
+
|
|
49
|
+
- Allowed model ID on a supported Responses API: Codex-harness-compatible `apply_patch`
|
|
50
|
+
- Model ID outside the allowlist: Pi's native `edit`
|
|
51
|
+
- Model on another API, even if its ID matches: Pi's native `edit`
|
|
52
|
+
|
|
53
|
+
The default allowlist enables all `gpt-5.6-*` models regardless of provider. Other model families can be added after separate validation by editing `config.json`.
|
|
54
|
+
|
|
55
|
+
The extension does not add a permanent AGENTS rule telling models not to use `apply_patch`. Only the selected editor tool is active, so the model receives one editing protocol.
|
|
56
|
+
|
|
57
|
+
## What `apply_patch` does
|
|
58
|
+
|
|
59
|
+
The tool accepts raw Codex patch text between `*** Begin Patch` and `*** End Patch`. It supports:
|
|
60
|
+
|
|
61
|
+
- `Add File`
|
|
62
|
+
- `Delete File`
|
|
63
|
+
- `Update File`
|
|
64
|
+
- `Move to`
|
|
65
|
+
- multiple update hunks with `@@` context
|
|
66
|
+
- EOF-oriented insertions
|
|
67
|
+
|
|
68
|
+
Before writing, it parses the complete patch, resolves paths, rejects workspace escapes and unsafe symlink/parent paths, reads all source files, and computes every update in memory. Only after preflight succeeds does it mutate files. It returns per-file diff details and reports committed paths if a later filesystem operation fails.
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
The extension defaults to a model-ID allowlist in `config.json`: `"gpt-5.6-*"`. Provider does not affect routing. Each entry is a `*` glob, so this matches every `gpt-5.6-` variant. The route additionally requires:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
model.api = openai-responses or openai-codex-responses
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The effective routing rule is:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
settings.enabled
|
|
82
|
+
and model.api in ["openai-responses", "openai-codex-responses"]
|
|
83
|
+
and model.id matches at least one settings.models pattern
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Patterns are case-sensitive, match the complete model ID, and support `*` as the wildcard. Provider name is intentionally ignored.
|
|
87
|
+
|
|
88
|
+
### Add model rules
|
|
89
|
+
|
|
90
|
+
Edit `config.json` and add validated model-ID patterns:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"enabled": true,
|
|
95
|
+
"models": [
|
|
96
|
+
"gpt-5.6-*",
|
|
97
|
+
"gpt-5.7-*",
|
|
98
|
+
"my-codex-model"
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Examples:
|
|
104
|
+
|
|
105
|
+
| Pattern | Matches | Does not match |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| `gpt-5.6-*` | `gpt-5.6-sol`, `gpt-5.6-terra` | `gpt-5.7-sol` |
|
|
108
|
+
| `gpt-*-codex` | `gpt-5.6-codex` | `gpt-5.6-codex-mini` |
|
|
109
|
+
| `my-codex-model` | exactly `my-codex-model` | `my-codex-model-v2` |
|
|
110
|
+
|
|
111
|
+
Adding a pattern only changes routing; it does not prove that a model handles the Codex protocol correctly. Validate the model before adding it to the default allowlist. A matching model on `anthropic-messages`, `openai-completions`, or another unsupported API still uses Pi's native `edit`.
|
|
112
|
+
|
|
113
|
+
Grammar support is not part of the route. When a provider does not emit Lark grammar tools, Pi falls back to a normal function tool, so `apply_patch` still runs there — only the grammar-enforced output shape is lost.
|
|
114
|
+
|
|
115
|
+
Edit `config.json` in the standalone installed package, or `packages/codex-edit/config.json` inside an installed full toolkit, only if you need to change the default allowlist. Package updates can replace local edits. Set `"enabled": false` to disable all `apply_patch` routing. The implementation keeps both tools registered for session replay and changes only the active tool set on `session_start` and `model_select`.
|
|
116
|
+
|
|
117
|
+
## Documentation
|
|
118
|
+
|
|
119
|
+
- `summary.md`: benchmark summary and decision record.
|
|
120
|
+
- `codex-edit-explainer.html`: self-contained interactive architecture and configuration explainer.
|
|
121
|
+
- `TESTING.md`: deterministic test flow, regression fixtures, and latest baseline.
|
|
122
|
+
|
|
123
|
+
The benchmark found equal final correctness in the fair 20-case comparison, with first editor-call success improving from 85% to 95%. Overall tool-call count and cache-inclusive token use were effectively unchanged, so the route stays limited to the GPT/Codex allowlist rather than replacing `edit` universally.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Codex Edit 测试方案
|
|
2
|
+
|
|
3
|
+
## 流程
|
|
4
|
+
|
|
5
|
+
1. `npm --prefix packages/codex-edit test`:运行 parser、matcher、路由和包结构测试。
|
|
6
|
+
2. `pi -ne -e ./packages/codex-edit/extensions/codex-edit.ts`:加载权威入口;独立子包与根包 manifest 都指向该实现。
|
|
7
|
+
3. `npm pack ./packages/codex-edit --dry-run`:检查独立 tarball。
|
|
8
|
+
4. 确认 README 的协议示例、真实 parser 运行输出 `docs/screenshot.png` 和 `docs/demo.gif` 随包发布。
|
|
9
|
+
|
|
10
|
+
## 用例数据
|
|
11
|
+
|
|
12
|
+
- Add/Delete/Update/Move、多 hunk、BOM、CRLF、EOF 和 workspace escape。
|
|
13
|
+
- 与 Codex 一致的 cursor 顺序匹配:重复 HTML section 与 Markdown `---`。
|
|
14
|
+
- 多文件结构重构 patch 的解析,以及重复目标拒绝。
|
|
15
|
+
- `gpt-5.6-*` glob、Responses API 路由和 disabled 配置。
|
|
16
|
+
- 自定义精确规则与 `*` glob;相同 model ID 在不支持的 API 上必须回退到 Pi `edit`。
|
|
17
|
+
|
|
18
|
+
## 最近验证结果
|
|
19
|
+
|
|
20
|
+
当前基线为 12 个确定性测试全部通过;真实触发过 `Ambiguous ... regions found` 的重复 HTML/Markdown 形态已经加入回归集。发布前必须验证子包 tarball 和根包 tarball 都包含该入口。
|