pi-pier 0.2.3 → 0.2.5
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 +3 -4
- package/package.json +1 -1
- package/skills/pi-herdr-workflow/SKILL.md +149 -77
- package/src/core/subagent.ts +245 -261
- package/src/core/terminal.ts +200 -232
- package/src/core/todo.ts +10 -75
- package/src/index.ts +49 -22
- package/src/notice-buffer.ts +2 -2
- package/src/roles/master.json +4 -4
- package/src/roles/worker-default.json +3 -12
- package/src/slim-frame.ts +120 -11
- package/src/subagent-core.ts +3 -3
- package/src/subagent-poll-loop.ts +1 -1
- package/src/subagent-session-io.ts +5 -1
- package/src/terminal-core.ts +3 -3
- package/src/todo-window.ts +82 -0
package/README.md
CHANGED
|
@@ -43,10 +43,9 @@ The installer also verifies node / pi / herdr versions, probes local paths, and
|
|
|
43
43
|
| Tool | Purpose |
|
|
44
44
|
|---|---|
|
|
45
45
|
| `todo_write` | Full-replacement todo list. Session JSONL is the single source of truth; correct rollback on branch switches. Projected live onto the pane title (`▶i ○p ■b ✓c (N/M) · current task`). `/todos` command to view/edit/unblock |
|
|
46
|
-
| `subagent` | Delegate self-contained subtasks to an isolated pi session in its own herdr pane
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `interrupt_agent` | Stop a subagent's current turn; it stays alive for more messages |
|
|
46
|
+
| `subagent` | Delegate self-contained subtasks to an isolated pi session in its own herdr pane. Actions: `spawn` (default; foreground / parallel / background), `list`, `send`, `interrupt`, `resume` |
|
|
47
|
+
| `terminal` | Persistent interactive shells in dedicated herdr panes. Actions: `open`, `send`, `read`, `signal`, `close`, `list` |
|
|
48
|
+
| `ask_user_question` | Human gate: pane shows blocked in herdr while waiting |
|
|
50
49
|
|
|
51
50
|
### Behaviors
|
|
52
51
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-pier",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "pier: pi extension that fuses pi agent sessions with the herdr pane/tab orchestrator — todo_write loop closure + interactive subagents in isolated panes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -2,85 +2,157 @@
|
|
|
2
2
|
name: pi-herdr-workflow
|
|
3
3
|
description: >-
|
|
4
4
|
How to use the pi-herdr workbench fusion: todo_write discipline, subagent
|
|
5
|
-
delegation (foreground/parallel/background
|
|
6
|
-
|
|
5
|
+
delegation (foreground/parallel/background via action spawn/list/send/
|
|
6
|
+
interrupt/resume), terminal persistent shells, and how the human watches
|
|
7
|
+
everything in herdr panes.
|
|
7
8
|
Load when the user asks about multi-step plans, delegating subtasks,
|
|
8
9
|
background work, or checking on running subagents.
|
|
9
10
|
license: MIT
|
|
10
11
|
---
|
|
11
12
|
|
|
12
|
-
# pi-herdr
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`subagent`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-
|
|
13
|
+
# pi-herdr workbench workflow
|
|
14
|
+
|
|
15
|
+
You run inside a herdr terminal pane. This skill is how to use `todo_write` and
|
|
16
|
+
`subagent` well. The human watches live in herdr: each pane header shows
|
|
17
|
+
`▶x ○y ■b ✓z · current task`, and semantic state (working / blocked / idle)
|
|
18
|
+
rolls up to the sidebar.
|
|
19
|
+
|
|
20
|
+
## 1. Todo discipline (full-replace semantics)
|
|
21
|
+
|
|
22
|
+
- Every `todo_write` submits the **entire list** (last-wins). There is no partial update.
|
|
23
|
+
- An item is `content` (non-empty, unique, 5–10 word imperative phrase: *what*, not *how*, **no numeric prefix**) + `status` (`pending` | `in_progress` | `completed` | `blocked` | `abandoned`).
|
|
24
|
+
- `blocked` = waiting on an external condition (info, a person, another system) and **must** include `blocker` saying what is missing; `abandoned` = explicit drop (keep the row; do not delete the plan trail).
|
|
25
|
+
- Multi-phase plans may group with optional `phase` (≤30 chars). Single-phase: omit `phase`.
|
|
26
|
+
- Keep the list small (≤15): one item = one meaningful deliverable, not a micro-step.
|
|
27
|
+
- Mark what you are actually doing `in_progress` (multiple only when truly parallel); **mark `completed` the moment it is done**.
|
|
28
|
+
- **Never mark completed when tests fail, the implementation is incomplete, or errors remain** — stay `in_progress`, or switch to `blocked` with a blocker.
|
|
29
|
+
- **Never make `todo_write` the only tool call in a turn** — batch it with real work.
|
|
30
|
+
- If you forget an item's exact wording, copy it from the previous `todo_write` result. **Do not invent from memory** (phantom items).
|
|
31
|
+
- **Do not** put work you already delegated to a subagent on *your* todo list — that is the subagent's job. Your list tracks *your* work. Accept and archive after the result comes back.
|
|
32
|
+
- When several subagents collaborate, put **file ownership** in `content` (e.g. "refactor auth (only src/auth/)") so two agents do not fight over the same file.
|
|
33
|
+
- When **you** are a delegated worker pane (`PI_HERDR_SUBAGENT=1`), this plugin enforces strict mode: **at most one `in_progress`** at a time (extras are normalized), and finishing the current item auto-promotes the next `pending`. The master pane keeps parallel semantics; this section is the discipline.
|
|
34
|
+
|
|
35
|
+
## 2. Subagent delegation
|
|
36
|
+
|
|
37
|
+
A subagent pane is an **interactive pi TUI** (independent session). A human can enter that pane and talk to it at any time. Your delegation prompt appears as a message in its conversation.
|
|
38
|
+
|
|
39
|
+
The `subagent` tool has 5 operations controlled by the `action` parameter (default: `spawn`):
|
|
40
|
+
|
|
41
|
+
### spawn (default action)
|
|
42
|
+
|
|
43
|
+
Create a subagent in a new pane:
|
|
44
|
+
- **Foreground** (default): the call waits for a result. Use when the next step depends on it.
|
|
45
|
+
- **Background** (`run_in_background: true`): returns `agentId` immediately; the subagent keeps running in its own pane. Use for long / parallel work. It **persists** (own session). On settle you get a "Background subagent <id> finished..." notice.
|
|
46
|
+
- Multiple `subagent` calls (with `action: "spawn"`) in one message run in parallel (cap 4).
|
|
47
|
+
- Optional `role` (e.g. `advisor`) matches a profile when found; unknown names are labels only.
|
|
48
|
+
|
|
49
|
+
**Task-tab grouping** (`tab`):
|
|
50
|
+
- Each delegation defaults to a **new tab named from `description`**.
|
|
51
|
+
- Related subtasks share one `tab` name (e.g. web research + status probe both `tab: "research"`) so the human sees every related pane in one herdr tab.
|
|
52
|
+
- Keep names short (≤20 chars) and obvious; the tab bar *is* the task board.
|
|
53
|
+
- Do not cram unrelated work into one tab to "save tabs". One tab = one goal.
|
|
54
|
+
- **Task tabs are temporary**: after every subagent in the tab has settled (default grace ~10 minutes) the tab closes. Do not assume those panes last. To review or continue, use `action: "resume"` from history — do not cite a closed pane.
|
|
55
|
+
|
|
56
|
+
**Prompt discipline**:
|
|
57
|
+
- The prompt must be **self-contained**: the subagent cannot see your conversation, only this prompt.
|
|
58
|
+
- State inputs (which files / facts), outputs (what to deliver), and bounds (what not to touch).
|
|
59
|
+
- Share context via files / artifacts. Do not dump large blobs into the prompt.
|
|
60
|
+
- Delegate only independent work; dependent steps go to the same subagent.
|
|
61
|
+
|
|
62
|
+
### list
|
|
63
|
+
|
|
64
|
+
Show all background subagents with status (`running` / `idle` / `blocked`), `agentId`, and last activity.
|
|
65
|
+
|
|
66
|
+
Call: `subagent(action: "list")`
|
|
67
|
+
|
|
68
|
+
### send
|
|
69
|
+
|
|
70
|
+
Append follow-up message to background subagent:
|
|
71
|
+
- If working: delivered at next tool-gap (steering, seconds).
|
|
72
|
+
- If idle: wakes for new turn.
|
|
73
|
+
- After settle, `send` to wake it; do not spawn duplicate.
|
|
74
|
+
|
|
75
|
+
Call: `subagent(action: "send", agentId: "<id>", message: "...")`
|
|
76
|
+
|
|
77
|
+
### interrupt
|
|
78
|
+
|
|
79
|
+
Abort subagent's current turn (fire-and-return). Pane stays; can `send` again.
|
|
80
|
+
|
|
81
|
+
Call: `subagent(action: "interrupt", agentId: "<id>")`
|
|
82
|
+
|
|
83
|
+
### resume
|
|
84
|
+
|
|
85
|
+
Revive finished subagent from ledger by `taskId`. Opens saved conversation in new pane; then `send` work.
|
|
86
|
+
|
|
87
|
+
The ledger is an append-only JSONL file at `~/.pi/agent/herdr-pi/history/<flattened-cwd>/history.jsonl`, one row per status change. Use `list` for live panes from this session; for tasks from earlier sessions or closed panes, read/grep the ledger for the `taskId`.
|
|
88
|
+
|
|
89
|
+
Call: `subagent(action: "resume", taskId: "<uuid>")`
|
|
90
|
+
|
|
91
|
+
## 3. Human gate
|
|
92
|
+
|
|
93
|
+
- For a human decision (approval, tradeoff, direction), use `ask_user_question` (this plugin). While waiting, your pane is **blocked** in herdr so the human can see and intervene. The answer comes back as the tool result, then you continue.
|
|
94
|
+
- A human can enter a subagent pane directly. Write the delegation `description` (pane label) so a human understands it at a glance.
|
|
95
|
+
|
|
96
|
+
## 4. Multi-agent engineering rules
|
|
97
|
+
|
|
98
|
+
- You are the arbiter: accept each subagent's output, then merge it. Do not outsource arbitration.
|
|
99
|
+
- Independent review for critical conclusions (a different subagent as reviewer). Do not trust a single worker blindly.
|
|
100
|
+
- Homogeneous parallel workers make the same mistakes: give them different bounds and output shapes.
|
|
101
|
+
- After delegating, keep doing your own work. Do not idle-wait (except a foreground call).
|
|
102
|
+
|
|
103
|
+
## 5. Terminal management (master only)
|
|
104
|
+
|
|
105
|
+
The `terminal` tool has 6 operations for persistent shell sessions (dev servers, REPLs, stateful work):
|
|
106
|
+
|
|
107
|
+
### open
|
|
108
|
+
|
|
109
|
+
Create a persistent interactive terminal (resident shell in its own herdr pane) and return its `terminal_id`.
|
|
110
|
+
|
|
111
|
+
The shell keeps its cwd, environment variables, and background processes across `terminal` calls — use it for dev servers, REPLs, or multi-step shell work instead of one-shot bash calls.
|
|
112
|
+
|
|
113
|
+
Call: `terminal(action: "open", cwd: "<path>")`
|
|
114
|
+
Returns: `terminal_id` and readiness status (prompt detected or busy).
|
|
115
|
+
|
|
116
|
+
### send
|
|
117
|
+
|
|
118
|
+
Send a text command (plain text only, no ANSI escapes) to a persistent terminal; Enter is appended automatically.
|
|
119
|
+
|
|
120
|
+
Returns after the keystrokes are delivered — poll with `action: "read"` for output (long-running commands keep producing output across reads).
|
|
121
|
+
|
|
122
|
+
Call: `terminal(action: "send", terminal_id: "<id>", text: "npm run dev")`
|
|
123
|
+
|
|
124
|
+
### read
|
|
125
|
+
|
|
126
|
+
Read new output from a persistent terminal since your last read (cursor-based increment; the first read returns the recent buffer).
|
|
127
|
+
|
|
128
|
+
Parameters:
|
|
129
|
+
- `terminal_id`: your terminal from `open`. Alternatively `pane_id`: a pane in this session's own tab (narrow scope by design).
|
|
130
|
+
- `max_chars`: output cap for this read.
|
|
131
|
+
|
|
132
|
+
Output is ANSI-stripped and bounded; if the buffer scrolled past your last read you get a reset marker plus the current tail. Detecting a fullscreen TUI program (vim/less/top) returns an error with suggestions instead of garbage.
|
|
133
|
+
|
|
134
|
+
Call: `terminal(action: "read", terminal_id: "<id>")`
|
|
135
|
+
|
|
136
|
+
### signal
|
|
137
|
+
|
|
138
|
+
Send a control key to a persistent terminal: ctrl+c (interrupt), ctrl+d (EOF), ctrl+z (suspend), esc, enter.
|
|
139
|
+
|
|
140
|
+
Use ctrl+c to stop a running command; anything beyond this whitelist is outside the terminal seam.
|
|
141
|
+
|
|
142
|
+
Call: `terminal(action: "signal", terminal_id: "<id>", key: "ctrl+c")`
|
|
143
|
+
|
|
144
|
+
### close
|
|
145
|
+
|
|
146
|
+
Close a persistent terminal (kills its shell process tree and removes the pane).
|
|
147
|
+
|
|
148
|
+
Terminal state does not survive close — persist anything you need to files first.
|
|
149
|
+
|
|
150
|
+
Call: `terminal(action: "close", terminal_id: "<id>")`
|
|
151
|
+
|
|
152
|
+
### list
|
|
153
|
+
|
|
154
|
+
List this session's persistent terminals with open/closed and pane-liveness status.
|
|
155
|
+
|
|
156
|
+
Entries whose pane is gone (human closed it, restart) are marked closed — terminal sessions do not survive pane closure or restarts; persist state to files instead of relying on terminal reuse.
|
|
157
|
+
|
|
158
|
+
Call: `terminal(action: "list")`
|