@tduyng/pi-prewalk 0.0.3 → 0.0.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/README.md +50 -79
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,59 +1,40 @@
|
|
|
1
1
|
# @tduyng/pi-prewalk
|
|
2
2
|
|
|
3
|
-
Plan on the frontier model, execute on the cheap one, in one unbroken context. The first edit swaps the model, and the planner
|
|
3
|
+
Plan on the frontier model, execute on the cheap one, in one unbroken context. The first edit swaps the model, and the planner returns only when the executor hits a wall.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Most turns in a task are execution: applying a change the plan already describes, running the check, reading the error. Paying frontier prices for those is the largest avoidable cost in a long session.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Writing the plan down and handing it to a fresh session does not fix it. Stencil measured 1.81B tokens over about 2M tool calls and found edits are roughly 9 percent of them. Reads are the rest, so an executor reopens the files the planner already read, and the plan document saves the thinking while paying twice for the exploration.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`prewalk_plan` is 716 tokens and only while prewalk is armed in plan mode. The router is one hook on `streamSimple` and registers no schema, so an unarmed session pays nothing.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## One context, two models
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
A prompt cache belongs to one model, so a swap costs exactly one cold read of the prefix, at the cheap model's input rate, once per task. Both models then read the transcript and keep their own cache warm across their own turns.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Prompts are never rewritten and no message is edited afterwards. Rewriting one message invalidates the prefix for both.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
prewalk registers one virtual model, `prewalk/auto`, selected with `/prewalk` or from `/model`. Pi calls the router before every request, so prewalk never moves the session's model itself and no `setModel` runs mid task. Every model change in the session file is one prewalk made.
|
|
20
|
-
|
|
21
|
-
Each route returns one request's model, so planner and executor can differ inside a single task.
|
|
17
|
+
On SWE-bench this reached 92 to 97 percent of the frontier pass rate for 53 to 61 percent of its cost.
|
|
22
18
|
|
|
23
|
-
##
|
|
19
|
+
## The router
|
|
24
20
|
|
|
25
|
-
prewalk
|
|
21
|
+
prewalk registers one virtual model, `prewalk/auto`. Pi calls the router before every request, so the session's model is never moved mid-task and every model change in the session file is one prewalk made. Each route returns one request's model, so planner and executor can differ inside a single task.
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
A task boundary is the gap between one settled run and the next prompt typed after it. A task routes once and the turns inside it are never routed.
|
|
28
24
|
|
|
29
|
-
|
|
|
25
|
+
| Input | What happens |
|
|
30
26
|
| --- | --- |
|
|
31
|
-
| A prompt during the task in flight | The model stays, the prompt runs as written, no routing call
|
|
32
|
-
| A question while the executor is in play | A steer long enough to be a question moves the task back to the planner, which stays until
|
|
27
|
+
| A prompt during the task in flight | The model stays, the prompt runs as written, no routing call |
|
|
28
|
+
| A question while the executor is in play | A steer long enough to be a question moves the task back to the planner, which stays until its next edit hands it over |
|
|
29
|
+
| A one-word steer | A redirect, so the task stays where it is |
|
|
33
30
|
| A new task | The session moves to the planner before the first token |
|
|
34
|
-
| A prompt under 8 characters | Not a task
|
|
35
|
-
|
|
36
|
-
## The handoff
|
|
37
|
-
|
|
38
|
-
The planner explores, then must commit a structured plan through `prewalk_plan` before it can edit. The first edit is blocked once with a message naming the tool, and a planner that ignores the block degrades to a plain edit-only swap.
|
|
39
|
-
|
|
40
|
-
The first `edit`, `write`, `multiedit`, or `notebookedit` after the plan swaps the session to the executor, and so does a bash command that writes a file outside the temp dir (a redirect, `sed -i`, `tee`, `patch`, `git apply`, or an inline script that writes), which also demands the plan first. A third tool call after the plan still hands over, for a planner that writes in a way the check cannot see. An edit under the temp dir is scratch and swaps nothing.
|
|
41
|
-
|
|
42
|
-
The plan tool returns the handoff brief itself: the goal, the facts with file:line, each step with file, anchor, change, and verify command, the out-of-scope list, and the rules of engagement. Both roles read the same bytes, so neither cache is rewritten.
|
|
43
|
-
|
|
44
|
-
## When the executor is stuck
|
|
31
|
+
| A prompt under 8 characters | Not a task, so nothing moves |
|
|
45
32
|
|
|
46
|
-
|
|
33
|
+
Pi's own `reason: "user"` cannot carry that boundary, because it fires for a steer and a follow-up too. prewalk keeps its own flag from the `input` event, which reads `streamingBehavior` as the three cases it is: undefined when the session was idle, `steer` when the text joins the turn in flight, and `followUp` when it waits for that turn to settle and opens a task of its own.
|
|
47
34
|
|
|
48
|
-
|
|
35
|
+
## The plan is a tool call
|
|
49
36
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
The session badge reads `prewalk replan` while this happens.
|
|
53
|
-
|
|
54
|
-
## The plan tool
|
|
55
|
-
|
|
56
|
-
`prewalk_plan` is in the active set while prewalk is armed in plan mode, and the executor meets it only through tool search. Its description carries the planning brief, which is why nothing is prepended to your prompt.
|
|
37
|
+
The planner must call `prewalk_plan` before it can edit, and a guard blocks the first edit once with a message naming the tool. A planner that ignores the block degrades to a plain edit-only swap rather than stalling. The tool's result is the handoff brief, so both roles read the same bytes and neither cache is rewritten.
|
|
57
38
|
|
|
58
39
|
| Field | Meaning |
|
|
59
40
|
| --- | --- |
|
|
@@ -63,34 +44,38 @@ The session badge reads `prewalk replan` while this happens.
|
|
|
63
44
|
| `check` | Final verification command |
|
|
64
45
|
| `outOfScope` | Files the executor must not touch |
|
|
65
46
|
|
|
66
|
-
|
|
47
|
+
The first `edit`, `write`, `multiedit` or `notebookedit` after the plan swaps to the executor. So does a bash command that writes a file outside the temp dir: a redirect, `sed -i`, `tee`, `patch`, `git apply`, or an inline script that writes, and that path demands the plan first too. A third tool call after the plan still hands over, for a planner that writes in a way the check cannot see. An edit under the temp dir is scratch and swaps nothing.
|
|
67
48
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
The badge reads `prewalk route` between tasks, `prewalk plan` or `prewalk run` on the first turn of one, `prewalk exec 3/7` while the plan runs, and `prewalk done 7/7` at the end.
|
|
49
|
+
## When the executor is stuck
|
|
71
50
|
|
|
72
|
-
|
|
51
|
+
Three failed tool results in a row are a wall. One miss does not hand the task back, any success resets the count, and the third failure appends a brief naming the step. The planner takes the task back on the next request, until its next edit.
|
|
73
52
|
|
|
74
|
-
|
|
53
|
+
A task buys two upgrades, because each swap re-reads the whole prefix at the new model's input rate and a task cannot ping-pong between the models. When the executor finishes the plan or stalls after its nudge, the planner returns once per plan: it reads the edits already in the transcript, runs the final check, and fixes what is wrong. Work the plan did not cover gets a new plan, so a long task runs in phases of up to 20 steps. `"review": false` in `prewalk.json` turns that off.
|
|
75
54
|
|
|
76
|
-
|
|
55
|
+
## The step counter
|
|
77
56
|
|
|
78
|
-
|
|
57
|
+
After each edit the extension matches the path against the plan steps and advances a pointer, walking forward from the current step so batched edits and missed results catch up instead of freezing the count. The edit result gains a short footer: what was done, what comes next, the anchor, and the verify command.
|
|
79
58
|
|
|
80
|
-
|
|
59
|
+
The badge reads `prewalk route` between tasks, `prewalk plan` or `prewalk run` on the first turn of one, `prewalk exec 3/7` while the plan runs, and `prewalk done 7/7` at the end.
|
|
81
60
|
|
|
82
|
-
##
|
|
61
|
+
## Chains
|
|
83
62
|
|
|
84
|
-
|
|
63
|
+
prewalk walks each role's list until one model resolves against pi's registry and has credentials. That absorbs the two ordinary breaks: a provider with no key, and a frontier model that runs out of its usage window partway through the day.
|
|
85
64
|
|
|
86
65
|
```json
|
|
87
66
|
{
|
|
88
67
|
"planner": ["opencode-go/mimo-v2.6-pro", "anthropic/claude-opus-4-6"],
|
|
89
|
-
"executor": ["opencode-z/space-bunny-free", "z-ai/glm-5.3-flash"]
|
|
68
|
+
"executor": ["opencode-z/space-bunny-free", "z-ai/glm-5.3-flash"],
|
|
69
|
+
"mode": "plan",
|
|
70
|
+
"review": true
|
|
90
71
|
}
|
|
91
72
|
```
|
|
92
73
|
|
|
93
|
-
|
|
74
|
+
`~/.pi/agent/prewalk.json` holds the machine-wide settings, and a project's `.pi/prewalk.json` overrides `planner`, `executor` and `mode` field by field. The commands write to the project file when one exists, otherwise to the agent dir.
|
|
75
|
+
|
|
76
|
+
`/prewalk models` prints both chains, marks each entry `router`, `ready` or `unavailable` against the registry `/model` reads, with the context window and input price, sorted by price. A model named with no argument opens the model dialog, each line carrying `provider/id`, window and input price, sorted by price because the executor is the tier being paid for.
|
|
77
|
+
|
|
78
|
+
An armed prewalk owns the session model, since every task routes through the router, so it takes the router back on `model_select` and on every session start and branch switch and says which model it took. A switch away used to leave a session where nothing routed, silently. `/prewalk off` is how a physical model is kept.
|
|
94
79
|
|
|
95
80
|
## Commands
|
|
96
81
|
|
|
@@ -100,39 +85,16 @@ Each role is an ordered list, walked until one model resolves against pi's regis
|
|
|
100
85
|
| `/prewalk off` | Disarm |
|
|
101
86
|
| `/prewalk status` | Both chains, the mode, and where the task is |
|
|
102
87
|
| `/prewalk models` | Both chains, what resolves, what it costs, and the mode |
|
|
103
|
-
| `/prewalk mode off` | Nothing happens unless
|
|
88
|
+
| `/prewalk mode off` | Nothing happens unless asked |
|
|
104
89
|
| `/prewalk mode plan` | Every task plans (the default) |
|
|
105
|
-
| `/prewalk planner <model>...` | Replace the planner chain
|
|
106
|
-
| `/prewalk executor <model>...` | Replace the executor chain
|
|
90
|
+
| `/prewalk planner <model>...` | Replace the planner chain |
|
|
91
|
+
| `/prewalk executor <model>...` | Replace the executor chain |
|
|
107
92
|
| `/prewalk plan [task]` | The next task plans, decided by hand |
|
|
108
93
|
| `/prewalk run [task]` | The next task runs on the cheap model, decided by hand |
|
|
109
|
-
| `/prewalk <executor> [task]` | Set the executor
|
|
94
|
+
| `/prewalk <executor> [task]` | Set the executor |
|
|
110
95
|
| `/prewalk <planner> <executor> [task]` | Set both roles and, with a task, start it |
|
|
111
96
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
Slash commands and skill blocks are left alone, so skill expansion still works.
|
|
115
|
-
|
|
116
|
-
An armed prewalk owns the session model, because every task routes through the router. A switch away from it leaves a session where nothing routes for the rest of its life, and one press of the model cycle key used to do that silently: the `12:20` model change in one session left 130 assistant messages on a cheap model with no routing at all. prewalk now takes the router back on `model_select` and on every session start and branch switch, and says which model it took. `/prewalk off` is how a physical model is kept.
|
|
117
|
-
|
|
118
|
-
Model naming is a bare id (`deepseek-v4-flash`) or provider/id (`google/gemini-3-flash`). Resolution is exact provider/id, then exact bare id, then unique id suffix, and a bare id that several providers carry is an error rather than a guess.
|
|
119
|
-
|
|
120
|
-
## Configure
|
|
121
|
-
|
|
122
|
-
`~/.pi/agent/prewalk.json` holds the machine-wide settings. A project's `.pi/prewalk.json` overrides `planner`, `executor`, and `mode` field by field. The commands write to the project file when one exists, otherwise to the agent dir.
|
|
123
|
-
|
|
124
|
-
```json
|
|
125
|
-
{
|
|
126
|
-
"planner": ["opencode-go/mimo-v2.6-pro"],
|
|
127
|
-
"executor": ["opencode-go/mimo-v2.6-flash"],
|
|
128
|
-
"mode": "plan",
|
|
129
|
-
"review": true
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
`mode` decides how a task gets its model. `plan` is the default: every task starts on the frontier model and the executor carries the steps it was given. `off` plans nothing unless you ask, so every task runs on the executor. A file written before the score was removed, with `mode: "auto"`, reads as `plan`.
|
|
134
|
-
|
|
135
|
-
The router must be selected for any of this to run. A string is still accepted for either role, so a file written before the chains existed reads the same. A missing, unparseable, or wrongly shaped file costs its settings and not the session.
|
|
97
|
+
Model naming is a bare id (`deepseek-v4-flash`) or `provider/id`. Resolution is exact `provider/id`, then exact bare id, then unique id suffix, and a bare id that several providers carry is an error rather than a guess. Slash commands and skill blocks are left alone, so skill expansion still works.
|
|
136
98
|
|
|
137
99
|
## Install
|
|
138
100
|
|
|
@@ -141,3 +103,12 @@ pi install npm:@tduyng/pi-prewalk
|
|
|
141
103
|
```
|
|
142
104
|
|
|
143
105
|
Local checkout: `pi install /path/to/dotfiles/pi/agent/extensions/pi-prewalk`
|
|
106
|
+
|
|
107
|
+
Then select the router and write the chains above. Nothing routes until `prewalk/auto` is the session model.
|
|
108
|
+
|
|
109
|
+
## Limits
|
|
110
|
+
|
|
111
|
+
- Plan steps cap at 20, and a fourth phase needs a new plan.
|
|
112
|
+
- A prompt under 8 characters never opens a task.
|
|
113
|
+
- `"mode": "auto"` in an older file reads as `plan`.
|
|
114
|
+
- A missing, unparseable or wrongly shaped `prewalk.json` costs its settings, not the session.
|