pi-pier 0.2.4 → 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 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 (separate context window). Foreground / parallel / background modes |
47
- | `list_agents` | Live state of background subagents (running / idle + panes) |
48
- | `send_message` | Follow-up work for a subagent (queued if busy, wakes if idle) |
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.4",
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,8 +2,9 @@
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), list_agents/send_message/
6
- interrupt_agent, and how the human watches everything in herdr panes.
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
@@ -35,34 +36,57 @@ rolls up to the sidebar.
35
36
 
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.
37
38
 
38
- ### Mode
39
+ The `subagent` tool has 5 operations controlled by the `action` parameter (default: `spawn`):
39
40
 
41
+ ### spawn (default action)
42
+
43
+ Create a subagent in a new pane:
40
44
  - **Foreground** (default): the call waits for a result. Use when the next step depends on it.
41
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.
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
+ - 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.
46
48
 
49
+ **Task-tab grouping** (`tab`):
47
50
  - Each delegation defaults to a **new tab named from `description`**.
48
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.
49
52
  - Keep names short (≤20 chars) and obvious; the tab bar *is* the task board.
50
53
  - 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
+ - **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.
54
55
 
56
+ **Prompt discipline**:
55
57
  - The prompt must be **self-contained**: the subagent cannot see your conversation, only this prompt.
56
58
  - State inputs (which files / facts), outputs (what to deliver), and bounds (what not to touch).
57
59
  - Share context via files / artifacts. Do not dump large blobs into the prompt.
58
60
  - Delegate only independent work; dependent steps go to the same subagent.
59
61
 
60
- ### After a background spawn
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>")`
61
82
 
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.
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>")`
66
90
 
67
91
  ## 3. Human gate
68
92
 
@@ -75,3 +99,60 @@ A subagent pane is an **interactive pi TUI** (independent session). A human can
75
99
  - Independent review for critical conclusions (a different subagent as reviewer). Do not trust a single worker blindly.
76
100
  - Homogeneous parallel workers make the same mistakes: give them different bounds and output shapes.
77
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")`