@maxiaochao/pi-toolkit 0.9.2 → 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 +12 -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/global/AGENTS.md +24 -49
- 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,15 @@
|
|
|
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
|
+
|
|
9
|
+
## 2026-09-30 - v0.9.3
|
|
10
|
+
|
|
11
|
+
- refine global agent guidance and add repository issue, triage, and domain instructions
|
|
12
|
+
|
|
1
13
|
## 2026-09-30 - v0.9.2
|
|
2
14
|
|
|
3
15
|
- show contiguous queue positions in the todo widget while retaining stable internal task IDs
|
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/global/AGENTS.md
CHANGED
|
@@ -1,51 +1,38 @@
|
|
|
1
1
|
# AGENTS.md
|
|
2
2
|
|
|
3
|
-
Behavioral guidelines to reduce common LLM coding mistakes.
|
|
4
|
-
|
|
5
|
-
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
|
|
3
|
+
Behavioral guidelines to reduce common LLM coding mistakes. Project-specific instructions override this file when they conflict.
|
|
6
4
|
|
|
7
5
|
## 1. Think Before Coding
|
|
8
6
|
|
|
9
|
-
**
|
|
7
|
+
**Surface tradeoffs. Name confusion instead of resolving it silently.**
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
- If multiple interpretations exist, present them - don't pick silently.
|
|
9
|
+
- State your material assumptions explicitly.
|
|
10
|
+
- If multiple interpretations exist, present them rather than picking one silently.
|
|
14
11
|
- If a simpler approach exists, say so. Push back when warranted.
|
|
15
|
-
- If
|
|
16
|
-
-
|
|
12
|
+
- If requirements conflict (durability vs latency, correctness vs speed), name the conflict explicitly. Never average conflicting requirements into something that satisfies neither.
|
|
13
|
+
- When unresolved ambiguity would materially change the result, ask. When no human is reachable (headless, async, subagent), choose the interpretation you can defend, state it as an assumption, and proceed under Rule 4.
|
|
17
14
|
|
|
18
15
|
## 2. Simplicity First
|
|
19
16
|
|
|
20
|
-
**
|
|
21
|
-
|
|
22
|
-
- No features beyond what was asked.
|
|
23
|
-
- No abstractions for single-use code.
|
|
24
|
-
- No "flexibility" or "configurability" that wasn't requested.
|
|
25
|
-
- No error handling for impossible scenarios.
|
|
26
|
-
- If you write 200 lines and it could be 50, rewrite.
|
|
17
|
+
**YAGNI cuts what you don't need; KISS keeps what remains simple.**
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
- Build what was asked, for the callers that exist today.
|
|
20
|
+
- Introduce an abstraction after repeated use reveals a stable concept.
|
|
21
|
+
- For states excluded by enforced invariants, fail visibly instead of inventing fallback behavior.
|
|
22
|
+
- Each function you write does one thing. If it runs past a couple of screens or nests past three levels, review whether splitting it improves clarity.
|
|
29
23
|
|
|
30
24
|
## 3. Surgical Changes
|
|
31
25
|
|
|
32
26
|
**Touch only what you must. Clean up only your own mess.**
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
- Don't "improve" adjacent code, comments, or formatting.
|
|
36
|
-
- Don't refactor things that aren't broken.
|
|
37
|
-
- Match existing style, even if you'd do it differently.
|
|
38
|
-
- If you notice unrelated dead code, mention it - don't delete it.
|
|
39
|
-
|
|
40
|
-
When your changes create orphans:
|
|
41
|
-
- Remove imports/variables/functions that YOUR changes made unused.
|
|
42
|
-
- Don't remove pre-existing dead code unless asked.
|
|
28
|
+
The test: every changed line traces to the user's request, or to a defect that request reveals.
|
|
43
29
|
|
|
44
|
-
|
|
30
|
+
- Match existing style, even if you'd do it differently.
|
|
31
|
+
- Remove imports, variables, and functions that YOUR changes made unused. Leave pre-existing dead code in place and mention it.
|
|
45
32
|
|
|
46
33
|
When fixing a bug, fix the root cause, not the symptom. Find where the defect actually lives:
|
|
47
|
-
-
|
|
48
|
-
- If the shared function is wrong, fix it once - do not scatter per-caller guards.
|
|
34
|
+
- Find every statically discoverable caller and relevant implementation; a report names a symptom, and patching only the path the ticket mentions leaves sibling callers still broken.
|
|
35
|
+
- If the shared function is wrong, fix it once - do not scatter per-caller guards. Name the sibling callers the fix now affects.
|
|
49
36
|
- If one caller is wrong, fix that caller - do not add defensive handling to a correct shared function.
|
|
50
37
|
|
|
51
38
|
## 4. Goal-Driven Execution
|
|
@@ -56,11 +43,10 @@ Transform tasks into verifiable goals:
|
|
|
56
43
|
- "Add validation" -> "Write tests for invalid inputs, then make them pass"
|
|
57
44
|
- "Fix the bug" -> "Write a test that reproduces it, then make it pass"
|
|
58
45
|
- "Refactor X" -> "Ensure tests pass before and after"
|
|
46
|
+
- "Make X fast" -> "Write and test a simple reference implementation, then optimize against its results"
|
|
59
47
|
|
|
60
|
-
For multi-step tasks, state a brief plan:
|
|
48
|
+
For multi-step or materially ambiguous tasks, state a brief plan where every step carries its own check:
|
|
61
49
|
1. [Step] -> verify: [check]
|
|
62
|
-
2. [Step] -> verify: [check]
|
|
63
|
-
3. [Step] -> verify: [check]
|
|
64
50
|
|
|
65
51
|
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
|
|
66
52
|
|
|
@@ -68,32 +54,21 @@ Strong success criteria let you loop independently. Weak criteria ("make it work
|
|
|
68
54
|
|
|
69
55
|
**Understand adjacent code before changing it. "Looks orthogonal" is a dangerous assumption.**
|
|
70
56
|
|
|
71
|
-
Before
|
|
57
|
+
Before changing a file:
|
|
72
58
|
- Read the file's exports and public API.
|
|
73
59
|
- Read the immediate callers of the function you're modifying.
|
|
74
|
-
- Check shared utilities in the same module.
|
|
75
|
-
- If you're unsure why code is structured a certain way, ask before writing.
|
|
76
60
|
|
|
77
61
|
## 6. Fail Visibly, Not Silently
|
|
78
62
|
|
|
79
|
-
**Silent skips are failures
|
|
63
|
+
**Silent skips are failures.**
|
|
80
64
|
|
|
81
65
|
- "Completed" is wrong if anything was silently skipped.
|
|
82
|
-
- "Tests pass" is wrong if any test was skipped.
|
|
83
|
-
- Default to surfacing uncertainty. When in doubt, over-communicate what you're unsure about.
|
|
66
|
+
- "Tests pass" is wrong if any required test was skipped or not run.
|
|
84
67
|
- If a required input, file, or tool is missing (or a step is impossible under the stated constraints), do NOT fabricate it to make a check pass. Report what is missing and what you need.
|
|
85
68
|
|
|
86
69
|
## 7. Reuse Before Writing
|
|
87
70
|
|
|
88
71
|
**Before writing new code, check in order:**
|
|
89
|
-
1.
|
|
90
|
-
2.
|
|
91
|
-
3. Only then
|
|
92
|
-
|
|
93
|
-
## 8. Use Available Editing Tools
|
|
94
|
-
|
|
95
|
-
**Follow the current harness's tool surface; do not assume a shell patch helper exists.**
|
|
96
|
-
|
|
97
|
-
- Use the native file-editing tools exposed by the current environment. In pi, use `edit` for precise replacements and `write` for new files or complete rewrites.
|
|
98
|
-
- Do not run `apply_patch` as a shell command unless `command -v apply_patch` confirms that executable is available.
|
|
99
|
-
- If the harness exposes `apply_patch` as a dedicated tool rather than a command, invoke it only through that tool interface.
|
|
72
|
+
1. Reuse an existing project abstraction when it encodes project semantics. (If it is itself the bug, fix it once - see Rule 3.)
|
|
73
|
+
2. Otherwise use the standard library or a direct dependency already declared by the project.
|
|
74
|
+
3. Only then write it yourself.
|
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
|