pi-pier 0.2.2 → 0.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-pier",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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",
|
|
@@ -9,78 +9,69 @@ description: >-
|
|
|
9
9
|
license: MIT
|
|
10
10
|
---
|
|
11
11
|
|
|
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
|
-
- 子代理 pane 在 herdr 里可被人类直接进入交互;你的委派描述(pane 标签)
|
|
79
|
-
要写得人类一眼能懂。
|
|
80
|
-
|
|
81
|
-
## 4. 多 agent 纪律(工程实践映射)
|
|
82
|
-
|
|
83
|
-
- 你是仲裁者:验收每个子代理的输出,再合入你的工作;不要把仲裁权下放。
|
|
84
|
-
- 关键结论安排独立复核(换个子代理 reviewer 复核),不盲信单一子代理。
|
|
85
|
-
- 同构的并行子代理会犯同样的错:给不同子代理不同的任务边界与产出格式。
|
|
86
|
-
- 委派后继续做你自己的事,不要干等(前台调用除外)。
|
|
12
|
+
# pi-herdr workbench workflow
|
|
13
|
+
|
|
14
|
+
You run inside a herdr terminal pane. This skill is how to use `todo_write` and
|
|
15
|
+
`subagent` well. The human watches live in herdr: each pane header shows
|
|
16
|
+
`▶x ○y ■b ✓z · current task`, and semantic state (working / blocked / idle)
|
|
17
|
+
rolls up to the sidebar.
|
|
18
|
+
|
|
19
|
+
## 1. Todo discipline (full-replace semantics)
|
|
20
|
+
|
|
21
|
+
- Every `todo_write` submits the **entire list** (last-wins). There is no partial update.
|
|
22
|
+
- 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`).
|
|
23
|
+
- `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).
|
|
24
|
+
- Multi-phase plans may group with optional `phase` (≤30 chars). Single-phase: omit `phase`.
|
|
25
|
+
- Keep the list small (≤15): one item = one meaningful deliverable, not a micro-step.
|
|
26
|
+
- Mark what you are actually doing `in_progress` (multiple only when truly parallel); **mark `completed` the moment it is done**.
|
|
27
|
+
- **Never mark completed when tests fail, the implementation is incomplete, or errors remain** — stay `in_progress`, or switch to `blocked` with a blocker.
|
|
28
|
+
- **Never make `todo_write` the only tool call in a turn** — batch it with real work.
|
|
29
|
+
- If you forget an item's exact wording, copy it from the previous `todo_write` result. **Do not invent from memory** (phantom items).
|
|
30
|
+
- **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.
|
|
31
|
+
- 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.
|
|
32
|
+
- 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.
|
|
33
|
+
|
|
34
|
+
## 2. Subagent delegation
|
|
35
|
+
|
|
36
|
+
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.
|
|
37
|
+
|
|
38
|
+
### Mode
|
|
39
|
+
|
|
40
|
+
- **Foreground** (default): the call waits for a result. Use when the next step depends on it.
|
|
41
|
+
- **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.
|
|
42
|
+
- Multiple `subagent` calls in one message run in parallel (cap 4).
|
|
43
|
+
- Optional `role` (e.g. `advisor`) is a label only: v1 does not change tools or lifecycle; TTL is the same as `task`. Omit = `task`. Revive with `resume_subagent`; do not assume the pane comes back by itself.
|
|
44
|
+
|
|
45
|
+
### Task-tab grouping (`tab`)
|
|
46
|
+
|
|
47
|
+
- Each delegation defaults to a **new tab named from `description`**.
|
|
48
|
+
- 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.
|
|
49
|
+
- Keep names short (≤20 chars) and obvious; the tab bar *is* the task board.
|
|
50
|
+
- Do not cram unrelated work into one tab to "save tabs". One tab = one goal.
|
|
51
|
+
- **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, `resume_subagent(taskId)` from history — do not cite a closed pane.
|
|
52
|
+
|
|
53
|
+
### Prompt discipline
|
|
54
|
+
|
|
55
|
+
- The prompt must be **self-contained**: the subagent cannot see your conversation, only this prompt.
|
|
56
|
+
- State inputs (which files / facts), outputs (what to deliver), and bounds (what not to touch).
|
|
57
|
+
- Share context via files / artifacts. Do not dump large blobs into the prompt.
|
|
58
|
+
- Delegate only independent work; dependent steps go to the same subagent.
|
|
59
|
+
|
|
60
|
+
### After a background spawn
|
|
61
|
+
|
|
62
|
+
- `list_agents`: all background subagents and status (`running` / `idle`).
|
|
63
|
+
- `send_message(agentId, message)`: append work (FIFO; a settled subagent is woken).
|
|
64
|
+
- `interrupt_agent(agentId)`: abort the current turn (the pane stays; you can `send_message` again).
|
|
65
|
+
- After settle, if you have more work for that same `agentId`, `send_message` to wake it; do not spawn a duplicate.
|
|
66
|
+
|
|
67
|
+
## 3. Human gate
|
|
68
|
+
|
|
69
|
+
- 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.
|
|
70
|
+
- A human can enter a subagent pane directly. Write the delegation `description` (pane label) so a human understands it at a glance.
|
|
71
|
+
|
|
72
|
+
## 4. Multi-agent engineering rules
|
|
73
|
+
|
|
74
|
+
- You are the arbiter: accept each subagent's output, then merge it. Do not outsource arbitration.
|
|
75
|
+
- Independent review for critical conclusions (a different subagent as reviewer). Do not trust a single worker blindly.
|
|
76
|
+
- Homogeneous parallel workers make the same mistakes: give them different bounds and output shapes.
|
|
77
|
+
- After delegating, keep doing your own work. Do not idle-wait (except a foreground call).
|
|
@@ -122,7 +122,11 @@ export function createSessionIo(h: SessionIoHost): SessionIo {
|
|
|
122
122
|
): Promise<{ text: string | null; pendingTool: boolean; activity: boolean }> {
|
|
123
123
|
for (const file of await resolveSessionFileCandidates(paneId, cwd)) {
|
|
124
124
|
const entries = readSessionFile(file);
|
|
125
|
-
|
|
125
|
+
// readSessionFile returns null when the path is missing or unreadable.
|
|
126
|
+
// herdr often reports a .jsonl path before the worker creates the file;
|
|
127
|
+
// waitAgent(idle) then returns immediately and this path used to throw
|
|
128
|
+
// `Cannot read properties of null (reading 'length')` (session 01a055c5).
|
|
129
|
+
if (!entries?.length) continue;
|
|
126
130
|
const r = lastAssistantText(entries, { sinceTs });
|
|
127
131
|
if (r?.text) return { text: r.text, pendingTool: false, activity: true };
|
|
128
132
|
if (hasPendingToolCall(entries, sinceTs)) return { text: null, pendingTool: true, activity: true };
|