harnex 0.7.3 → 0.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +55 -36
- data/guides/01_dispatch.md +24 -23
- data/guides/02_chain.md +6 -3
- data/guides/03_buddy.md +12 -11
- data/guides/04_monitoring.md +17 -16
- data/guides/05_naming.md +16 -15
- data/lib/harnex/adapters/base.rb +3 -2
- data/lib/harnex/adapters/pi.rb +512 -0
- data/lib/harnex/adapters.rb +3 -1
- data/lib/harnex/cli.rb +1 -1
- data/lib/harnex/commands/run.rb +3 -3
- data/lib/harnex/runtime/session.rb +164 -23
- data/lib/harnex/version.rb +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e99b85fa8112b666665da16757d871098867e0b05c9521c3507fc2092616f825
|
|
4
|
+
data.tar.gz: 78a5190335ee968c77d75531d23998c34272d24a3b6a8d6a53d5e9a8922c87da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c32673867f2b86ee84fa1768ee4fee82a3ddb0fb69abd5c369349d59fe9feef3cc468ee71776115da19ca2997b1f647678b413f8c93d02538f56c17daf316d4
|
|
7
|
+
data.tar.gz: bf049097af8736c25991af1894dd15b6cc8159393f99eb215a0dc7ddd67f9716b1864589664fdd08671edc6859899c9cb84c46852b940323b8f11f42d5f8ee29
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.7.4] - 2026-05-25 | 08:45 AM | IST
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- First-class `pi` structured adapter (`Harnex::Adapters::Pi`) for
|
|
10
|
+
`pi --mode rpc` JSONL transport. `harnex run pi` now supports
|
|
11
|
+
structured completion (`agent_end` -> `task_complete`), stop/abort,
|
|
12
|
+
extension-UI dialog auto-cancel in RPC mode, streamed output/tool
|
|
13
|
+
synthesis, and Pi session-stats telemetry capture.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Structured transport handling in `Session` now supports both Codex
|
|
18
|
+
JSON-RPC (`:stdio_jsonrpc`) and Pi JSONL RPC (`:stdio_jsonl_rpc`).
|
|
19
|
+
- DISPATCH telemetry restores `actual.cost_usd` (adapter-reported
|
|
20
|
+
approximate USD when available). Pi sessions populate it from
|
|
21
|
+
`get_session_stats.cost`; adapters without reliable cost stay `null`.
|
|
22
|
+
- README, dispatch telemetry docs, and dispatch guide now document Pi RPC
|
|
23
|
+
usage and the `--` child-flag pattern.
|
|
24
|
+
|
|
5
25
|
## [0.7.3] - 2026-05-13 | 01:43 PM | IST
|
|
6
26
|
|
|
7
27
|
### Added
|
data/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Run multiple AI coding agents from your terminal and coordinate them.
|
|
4
4
|
|
|
5
|
-
Harnex wraps Claude Code, OpenAI Codex, or any terminal CLI in a
|
|
6
|
-
harness so you can launch agents, send them tasks,
|
|
7
|
-
transcripts, and stop them cleanly
|
|
5
|
+
Harnex wraps Claude Code, OpenAI Codex, Pi, OpenCode, or any terminal CLI in a
|
|
6
|
+
local harness so you can launch agents, send them tasks, inspect panes,
|
|
7
|
+
transcripts, and events, and stop them cleanly -- all from the command line.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
gem install harnex
|
|
@@ -34,7 +34,7 @@ or project-local docs are required.
|
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
# Start an agent in tmux
|
|
37
|
-
harnex run
|
|
37
|
+
harnex run pi --id planner --tmux planner
|
|
38
38
|
|
|
39
39
|
# Send it a task and wait for it to finish
|
|
40
40
|
harnex send --id planner --message "Write a plan to /tmp/plan.md" --wait-for-idle
|
|
@@ -52,12 +52,12 @@ job, watch it work, stop it when done.
|
|
|
52
52
|
## Why use this
|
|
53
53
|
|
|
54
54
|
- **You want agents to plan, implement, review, and fix — in sequence.**
|
|
55
|
-
|
|
55
|
+
Pi writes code. Claude reviews it. Pi (or another adapter) fixes the review
|
|
56
56
|
findings. Each step is a fresh agent with clean context.
|
|
57
57
|
|
|
58
|
-
- **You want to see what agents are doing.** `harnex pane`
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
- **You want to see what agents are doing.** `harnex pane` captures a
|
|
59
|
+
tmux-backed terminal, `harnex logs` tails the persisted transcript, and
|
|
60
|
+
`harnex events` streams structured JSONL lifecycle events.
|
|
61
61
|
|
|
62
62
|
- **You don't want to babysit.** Send a task with `--wait-for-idle`,
|
|
63
63
|
walk away, check back when it's done.
|
|
@@ -76,7 +76,8 @@ job, watch it work, stop it when done.
|
|
|
76
76
|
| Agent | Support |
|
|
77
77
|
|-------|---------|
|
|
78
78
|
| Claude Code | PTY adapter with prompt detection, stop sequence, workspace trust, and vim mode handling |
|
|
79
|
-
| OpenAI Codex | JSON-RPC `codex app-server` adapter by default;
|
|
79
|
+
| OpenAI Codex | JSON-RPC `codex app-server` adapter by default; PTY mode remains supported for TUI/interactive use via `--legacy-pty` |
|
|
80
|
+
| Pi | JSONL RPC adapter (`pi --mode rpc`) with structured completion, tool events, extension-UI auto-cancel, and session stats telemetry |
|
|
80
81
|
| OpenCode | PTY adapter with native Ctrl+C stop handling and OpenCode-specific prompt/readiness heuristics |
|
|
81
82
|
| Any terminal CLI | Generic PTY wrapping with local API, logs, status, and best-effort prompt detection |
|
|
82
83
|
|
|
@@ -87,22 +88,28 @@ model settings as child CLI config, for example `harnex run codex -- -c model=NA
|
|
|
87
88
|
Harnex forces Codex app-server `service_tier="flex"` unless you opt into
|
|
88
89
|
`service_tier="fast"` with `harnex run codex --fast`.
|
|
89
90
|
Use `harnex run codex --legacy-pty` when you specifically want Codex's
|
|
90
|
-
terminal UI or
|
|
91
|
+
terminal UI or PTY-only Codex flags. The flag name is historical; the PTY path
|
|
92
|
+
is still supported.
|
|
93
|
+
|
|
94
|
+
`harnex run pi` launches `pi --mode rpc` and sends `--context` as a structured
|
|
95
|
+
`prompt` command (not a CLI positional argument). Pass Pi child flags after the
|
|
96
|
+
separator, for example:
|
|
97
|
+
`harnex run pi --context "Implement X" -- --model anthropic/claude-sonnet-4-5 --thinking high`.
|
|
91
98
|
|
|
92
99
|
## Multi-agent workflows
|
|
93
100
|
|
|
94
101
|
The real power is chaining agents together:
|
|
95
102
|
|
|
96
103
|
```bash
|
|
97
|
-
# 1.
|
|
98
|
-
harnex run
|
|
99
|
-
harnex send --id
|
|
100
|
-
harnex stop --id
|
|
104
|
+
# 1. Pi writes a plan
|
|
105
|
+
harnex run pi --id pi-plan --tmux pi-plan
|
|
106
|
+
harnex send --id pi-plan --message "Plan the auth module, write to /tmp/plan.md" --wait-for-idle
|
|
107
|
+
harnex stop --id pi-plan
|
|
101
108
|
|
|
102
|
-
# 2. Fresh
|
|
103
|
-
harnex run
|
|
104
|
-
harnex send --id
|
|
105
|
-
harnex stop --id
|
|
109
|
+
# 2. Fresh Pi implements the plan
|
|
110
|
+
harnex run pi --id pi-impl --tmux pi-impl
|
|
111
|
+
harnex send --id pi-impl --message "Implement /tmp/plan.md, run tests" --wait-for-idle
|
|
112
|
+
harnex stop --id pi-impl
|
|
106
113
|
|
|
107
114
|
# 3. Claude reviews the implementation
|
|
108
115
|
harnex run claude --id cl-review --tmux cl-review
|
|
@@ -137,13 +144,15 @@ harnex agents-guide monitoring
|
|
|
137
144
|
For unattended dispatches, use `--watch` instead of writing a bash poll loop:
|
|
138
145
|
|
|
139
146
|
```bash
|
|
140
|
-
harnex run
|
|
147
|
+
harnex run pi --id pi-impl-42 --watch --preset impl \
|
|
141
148
|
--context "Implement koder/plans/42_plan.md. Run tests and commit when done."
|
|
142
149
|
```
|
|
143
150
|
|
|
144
151
|
`--watch` runs a foreground babysitter that checks session activity every 60s,
|
|
145
152
|
force-resumes on stall up to a cap, and exits when the target session exits or
|
|
146
|
-
the resume cap is reached.
|
|
153
|
+
the resume cap is reached. It is foreground-only; use `--tmux` or `--detach`
|
|
154
|
+
for visible/background sessions, and `--watch` when the current command should
|
|
155
|
+
block as the monitor.
|
|
147
156
|
|
|
148
157
|
Presets map to stall policy defaults:
|
|
149
158
|
|
|
@@ -153,13 +162,17 @@ Presets map to stall policy defaults:
|
|
|
153
162
|
|
|
154
163
|
Explicit `--stall-after` and `--max-resumes` flags override preset defaults.
|
|
155
164
|
|
|
165
|
+
For file-change hooks, use `--watch-file PATH`. The older
|
|
166
|
+
`--watch PATH`/`--watch=PATH` form is still accepted for compatibility, while
|
|
167
|
+
bare `--watch` means babysitter mode.
|
|
168
|
+
|
|
156
169
|
For one-shot startup prompts, add `--auto-stop`. It requires `--context`
|
|
157
170
|
and stops the session after the first task completion or PTY prompt return.
|
|
158
171
|
|
|
159
172
|
For structured subscriptions, stream JSONL events:
|
|
160
173
|
|
|
161
174
|
```bash
|
|
162
|
-
harnex events --id
|
|
175
|
+
harnex events --id pi-impl-42
|
|
163
176
|
```
|
|
164
177
|
|
|
165
178
|
Schema details and compatibility policy are documented in
|
|
@@ -167,10 +180,10 @@ Schema details and compatibility policy are documented in
|
|
|
167
180
|
|
|
168
181
|
## Dispatch history
|
|
169
182
|
|
|
170
|
-
Every finished `harnex run`
|
|
171
|
-
`<repo>/.harnex/dispatch.jsonl
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
Every finished `harnex run` writes dispatch records. In a git repo, the
|
|
184
|
+
default path is `<repo>/.harnex/dispatch.jsonl`; outside a git repo, the
|
|
185
|
+
compact history record falls back to `~/.local/state/harnex/dispatch.jsonl`.
|
|
186
|
+
`harnex history` reads the compact records from that location.
|
|
174
187
|
|
|
175
188
|
Use `harnex history` to inspect it:
|
|
176
189
|
|
|
@@ -182,18 +195,24 @@ harnex history --json | jq .
|
|
|
182
195
|
Dispatch briefs can declare soft budget metadata through `--meta`:
|
|
183
196
|
|
|
184
197
|
```bash
|
|
185
|
-
harnex run
|
|
198
|
+
harnex run pi --meta '{"read_budget_lines":2000,"output_ceiling_lines":800}' ...
|
|
186
199
|
```
|
|
187
200
|
|
|
188
201
|
Those declared values are copied into summary `meta`. Terminal summary
|
|
189
|
-
`actual`
|
|
190
|
-
|
|
191
|
-
|
|
202
|
+
`actual` records timing, exit classification, token usage when the adapter can
|
|
203
|
+
capture it, adapter-reported `cost_usd` when reliably available, git deltas,
|
|
204
|
+
task-completion state, operational counters (`stalls`, `force_resumes`,
|
|
205
|
+
`disconnections`, `tool_calls`, `commands_executed`), output/event log paths,
|
|
206
|
+
and rough volume measurements such as `lines_changed`, `output_lines`,
|
|
207
|
+
`output_bytes`, and `event_records`.
|
|
208
|
+
Harnex records the data only; consumers decide whether to fail closed. See
|
|
209
|
+
[docs/dispatch-telemetry.md](docs/dispatch-telemetry.md) for the field
|
|
210
|
+
contract.
|
|
192
211
|
|
|
193
212
|
## Long-running and overnight work
|
|
194
213
|
|
|
195
214
|
For plain "force-resume on stall" recovery, use
|
|
196
|
-
`harnex run
|
|
215
|
+
`harnex run pi --watch --preset impl --context "Read /tmp/task.md"`.
|
|
197
216
|
|
|
198
217
|
A **buddy** is for richer reasoning: doc drift checks, semantic sanity checks,
|
|
199
218
|
and multi-session correlation. It's still just another harnex session.
|
|
@@ -203,8 +222,8 @@ and multi-session correlation. It's still just another harnex session.
|
|
|
203
222
|
Spawn a buddy alongside a long-running implementation worker:
|
|
204
223
|
|
|
205
224
|
```bash
|
|
206
|
-
harnex run
|
|
207
|
-
harnex run
|
|
225
|
+
harnex run pi --id worker-42 --tmux worker-42
|
|
226
|
+
harnex run pi --id buddy-42 --tmux buddy-42
|
|
208
227
|
harnex send --id buddy-42 --message "$(cat <<'EOF'
|
|
209
228
|
Watch harnex session worker-42.
|
|
210
229
|
Every 5 minutes: run `harnex pane --id worker-42 --lines 30`.
|
|
@@ -222,8 +241,8 @@ A buddy that checks whether a worker's code changes have left
|
|
|
222
241
|
docs out of date:
|
|
223
242
|
|
|
224
243
|
```bash
|
|
225
|
-
harnex run
|
|
226
|
-
harnex run
|
|
244
|
+
harnex run pi --id worker-99 --tmux worker-99
|
|
245
|
+
harnex run pi --id buddy-99 --tmux buddy-99
|
|
227
246
|
harnex send --id buddy-99 --message "$(cat <<'EOF'
|
|
228
247
|
Watch harnex session worker-99.
|
|
229
248
|
Every 5 minutes: run `harnex pane --id worker-99 --lines 30`.
|
|
@@ -258,7 +277,7 @@ See [recipes/03_buddy.md](recipes/03_buddy.md) for the full pattern.
|
|
|
258
277
|
| `harnex send --id <id>` | Send a message (queues if busy, `--wait-for-idle` to block until done) |
|
|
259
278
|
| `harnex stop --id <id>` | Send the agent's native exit sequence |
|
|
260
279
|
| `harnex status` | List running sessions (`--json` for full payloads) |
|
|
261
|
-
| `harnex pane --id <id>` | Capture
|
|
280
|
+
| `harnex pane --id <id>` | Capture a tmux-backed session's screen (`--follow` for live) |
|
|
262
281
|
| `harnex logs --id <id>` | Read session transcript (`--follow` to tail) |
|
|
263
282
|
| `harnex events --id <id>` | Stream structured session events (`--snapshot` for non-blocking dump) |
|
|
264
283
|
| `harnex history` | List completed dispatches from `.harnex/dispatch.jsonl` |
|
|
@@ -266,7 +285,7 @@ See [recipes/03_buddy.md](recipes/03_buddy.md) for the full pattern.
|
|
|
266
285
|
| `harnex doctor` | Run adapter dependency preflight checks; add `--sweep` for read-only session drift diagnostics |
|
|
267
286
|
| `harnex guide` | Getting started walkthrough |
|
|
268
287
|
| `harnex agents-guide` | Agent-facing dispatch, chain, buddy, monitoring, and naming guides |
|
|
269
|
-
| `harnex recipes` |
|
|
288
|
+
| `harnex recipes` | List and read tested workflow patterns (`show 01`, `show buddy`) |
|
|
270
289
|
|
|
271
290
|
## Uninstalling
|
|
272
291
|
|
data/guides/01_dispatch.md
CHANGED
|
@@ -17,7 +17,7 @@ Inside a harnex-managed session, these environment variables are available:
|
|
|
17
17
|
|
|
18
18
|
| Variable | Meaning |
|
|
19
19
|
| --- | --- |
|
|
20
|
-
| `HARNEX_SESSION_CLI` | Wrapped CLI name, such as `codex
|
|
20
|
+
| `HARNEX_SESSION_CLI` | Wrapped CLI name, such as `pi`, `codex`, or `claude` |
|
|
21
21
|
| `HARNEX_ID` | Current harnex session ID |
|
|
22
22
|
| `HARNEX_SESSION_REPO_ROOT` | Repo root for the session |
|
|
23
23
|
| `HARNEX_SESSION_ID` | Internal harnex instance ID |
|
|
@@ -34,13 +34,13 @@ Decide how results come back before you delegate work.
|
|
|
34
34
|
Inside harnex, instruct the peer to reply to your own session:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
harnex send --id
|
|
37
|
+
harnex send --id pi-i-NN --message "Read /tmp/task-impl-NN.md. When done, send one summary line back to harnex id $HARNEX_ID."
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
Outside harnex, require a file or another explicit return path:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
harnex send --id
|
|
43
|
+
harnex send --id pi-i-NN --message "Read /tmp/task-impl-NN.md. Write final status to /tmp/pi-i-NN-done.txt."
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Do not delegate work without an explicit completion contract.
|
|
@@ -48,18 +48,18 @@ Do not delegate work without an explicit completion contract.
|
|
|
48
48
|
## Spawn
|
|
49
49
|
|
|
50
50
|
Launch worker sessions in tmux when a user or orchestrator may need to inspect
|
|
51
|
-
them live:
|
|
51
|
+
them live. Default to Pi unless a task explicitly requires another adapter:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
harnex run
|
|
54
|
+
harnex run pi --id pi-i-NN --tmux pi-i-NN \
|
|
55
55
|
--context "Implement the project plan in /tmp/task-impl-NN.md. Run tests when done."
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
For long prompts, write the details into a file and reference it.
|
|
59
|
-
reliable with short injected messages.
|
|
58
|
+
For long prompts, write the details into a file and reference it. Structured
|
|
59
|
+
sends are more reliable with short injected messages.
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
|
-
harnex run
|
|
62
|
+
harnex run pi --id pi-i-NN --tmux pi-i-NN \
|
|
63
63
|
--context "Read and execute /tmp/task-impl-NN.md"
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -70,7 +70,7 @@ parallel orchestration compact:
|
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
72
|
for i in 1 2 3; do
|
|
73
|
-
harnex run
|
|
73
|
+
harnex run pi --id w-$i --tmux w-$i --detach \
|
|
74
74
|
--context "Read and execute /tmp/task-$i.md" --auto-stop &
|
|
75
75
|
done
|
|
76
76
|
for i in 1 2 3; do harnex wait --id w-$i & done
|
|
@@ -81,27 +81,28 @@ Rule: when you use `--tmux`, pass the same name as `--id`. If you pass only
|
|
|
81
81
|
`--tmux NAME`, harnex creates a random session ID and the pane name no longer
|
|
82
82
|
matches `harnex status` or `harnex pane --id`.
|
|
83
83
|
|
|
84
|
+
Pi runs use structured RPC (`pi --mode rpc`). Pass Pi child flags after `--`
|
|
85
|
+
(e.g. `harnex run pi --context "..." -- --model anthropic/claude-sonnet-4-5 --thinking high`).
|
|
86
|
+
|
|
84
87
|
Codex flag forms differ between transports. The default JSON-RPC adapter
|
|
85
88
|
(`codex app-server`) does not accept `-m`/`--model`; pass the model as
|
|
86
89
|
`-c model="<name>"` instead. The legacy PTY adapter (`harnex run codex
|
|
87
|
-
--legacy-pty`) still accepts `-m`.
|
|
88
|
-
|
|
89
|
-
Codex app-server runs also default to `service_tier="flex"`; add
|
|
90
|
-
`--fast` to use `service_tier="fast"`.
|
|
90
|
+
--legacy-pty`) still accepts `-m`. Codex app-server runs also default to
|
|
91
|
+
`service_tier="flex"`; add `--fast` to use `service_tier="fast"`.
|
|
91
92
|
|
|
92
93
|
## Send
|
|
93
94
|
|
|
94
95
|
Use `--message` for short instructions and file references:
|
|
95
96
|
|
|
96
97
|
```bash
|
|
97
|
-
harnex send --id
|
|
98
|
+
harnex send --id pi-i-NN --message "Continue with /tmp/task-impl-NN.md. Report final status to $HARNEX_ID."
|
|
98
99
|
```
|
|
99
100
|
|
|
100
101
|
Use `--wait-for-idle` only as a turn fence. It proves that one send returned to
|
|
101
102
|
an idle state; it is not a full work-completion signal.
|
|
102
103
|
|
|
103
104
|
```bash
|
|
104
|
-
harnex send --id
|
|
105
|
+
harnex send --id pi-i-NN --message "Run the acceptance test." --wait-for-idle --timeout 900
|
|
105
106
|
```
|
|
106
107
|
|
|
107
108
|
Messages sent from one harnex session to another include a relay header:
|
|
@@ -120,16 +121,16 @@ Use the lightest primitive that gives the signal you need:
|
|
|
120
121
|
|
|
121
122
|
| Need | Command |
|
|
122
123
|
| --- | --- |
|
|
123
|
-
| Current live screen | `harnex pane --id
|
|
124
|
-
| Continuous pane view | `harnex pane --id
|
|
125
|
-
| Transcript tail | `harnex logs --id
|
|
126
|
-
| Structured events | `harnex events --id
|
|
127
|
-
| Native turn completion | `harnex wait --id
|
|
124
|
+
| Current live screen | `harnex pane --id pi-i-NN --lines 40` |
|
|
125
|
+
| Continuous pane view | `harnex pane --id pi-i-NN --follow` |
|
|
126
|
+
| Transcript tail | `harnex logs --id pi-i-NN --lines 80` |
|
|
127
|
+
| Structured events | `harnex events --id pi-i-NN --snapshot` |
|
|
128
|
+
| Native turn completion | `harnex wait --id pi-i-NN --until task_complete` |
|
|
128
129
|
|
|
129
130
|
For unattended policy-only stall recovery, use built-in watch mode:
|
|
130
131
|
|
|
131
132
|
```bash
|
|
132
|
-
harnex run
|
|
133
|
+
harnex run pi --id pi-i-NN --watch --preset impl --context "Read /tmp/task-impl-NN.md"
|
|
133
134
|
```
|
|
134
135
|
|
|
135
136
|
`--watch` is foreground-blocking. Use it when a single process should launch
|
|
@@ -142,10 +143,10 @@ Before stopping a worker, verify the expected artifact, test result, commit,
|
|
|
142
143
|
or review output exists:
|
|
143
144
|
|
|
144
145
|
```bash
|
|
145
|
-
harnex pane --id
|
|
146
|
+
harnex pane --id pi-i-NN --lines 60
|
|
146
147
|
git status --short
|
|
147
148
|
git log --oneline -5
|
|
148
|
-
harnex stop --id
|
|
149
|
+
harnex stop --id pi-i-NN
|
|
149
150
|
```
|
|
150
151
|
|
|
151
152
|
Stop completed sessions promptly. Fresh workers are easier to reason about
|
data/guides/02_chain.md
CHANGED
|
@@ -39,6 +39,9 @@ Issue or request
|
|
|
39
39
|
Each arrow is a fresh harnex worker when delegated. Pass state through files:
|
|
40
40
|
the issue, plan, review file, fix summary, test log, or done marker.
|
|
41
41
|
|
|
42
|
+
Default adapter choice for autonomous chain steps is Pi (`harnex run pi ...`).
|
|
43
|
+
Use another adapter only when the task explicitly requires it.
|
|
44
|
+
|
|
42
45
|
## Per-Plan Loop
|
|
43
46
|
|
|
44
47
|
For each independently testable plan:
|
|
@@ -72,8 +75,8 @@ Recommended limits:
|
|
|
72
75
|
| Code review/fix | Serial per implementation |
|
|
73
76
|
|
|
74
77
|
When parallelizing, cap the number of active workers to what the machine and
|
|
75
|
-
CLI provider can handle. A practical upper bound is five
|
|
76
|
-
all
|
|
78
|
+
CLI provider can handle. A practical upper bound is five active sessions across
|
|
79
|
+
all lanes unless the user requested more.
|
|
77
80
|
|
|
78
81
|
## Worktrees
|
|
79
82
|
|
|
@@ -84,7 +87,7 @@ untracked files do not carry over.
|
|
|
84
87
|
```bash
|
|
85
88
|
git worktree add ../project-plan-NN -b plan/NN main
|
|
86
89
|
cd ../project-plan-NN
|
|
87
|
-
harnex run
|
|
90
|
+
harnex run pi --id pi-i-NN --tmux pi-i-NN \
|
|
88
91
|
--context "Read the project plan and implement this isolated lane."
|
|
89
92
|
```
|
|
90
93
|
|
data/guides/03_buddy.md
CHANGED
|
@@ -7,7 +7,7 @@ needs interpretation that simple stall policy cannot provide.
|
|
|
7
7
|
For simple inactivity recovery, prefer built-in watch mode:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
harnex run
|
|
10
|
+
harnex run pi --id pi-i-NN --watch --preset impl --context "Read /tmp/task-impl-NN.md"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Use a buddy when you need reasoning over pane contents, semantic checks, or
|
|
@@ -28,14 +28,15 @@ Use a buddy for:
|
|
|
28
28
|
Spawn the worker first, then spawn the buddy:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
harnex run
|
|
31
|
+
harnex run pi --id pi-i-42 --tmux pi-i-42 \
|
|
32
32
|
--context "Read and execute /tmp/task-impl-42.md"
|
|
33
33
|
|
|
34
|
-
harnex run
|
|
34
|
+
harnex run pi --id buddy-42 --tmux buddy-42
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
The buddy is just another harnex session. Inspect it, stop it, and read its
|
|
38
|
-
logs with the same commands as any worker.
|
|
38
|
+
logs with the same commands as any worker. Use Pi by default; swap to another
|
|
39
|
+
adapter if your environment or policy requires it.
|
|
39
40
|
|
|
40
41
|
## Buddy Prompt
|
|
41
42
|
|
|
@@ -43,18 +44,18 @@ Give the buddy an explicit polling loop, stall threshold, nudge rule, return
|
|
|
43
44
|
channel, and cleanup rule:
|
|
44
45
|
|
|
45
46
|
```text
|
|
46
|
-
You are an accountability partner for harnex session `
|
|
47
|
+
You are an accountability partner for harnex session `pi-i-42`.
|
|
47
48
|
|
|
48
49
|
Every 5 minutes:
|
|
49
|
-
- Run `harnex pane --id
|
|
50
|
-
- Run `harnex status --id
|
|
50
|
+
- Run `harnex pane --id pi-i-42 --lines 30`.
|
|
51
|
+
- Run `harnex status --id pi-i-42 --json`.
|
|
51
52
|
|
|
52
53
|
If the worker appears stuck at a prompt or permission dialog for more than
|
|
53
54
|
10 minutes with no progress, nudge it:
|
|
54
|
-
- `harnex send --id
|
|
55
|
+
- `harnex send --id pi-i-42 --message "You appear to have stalled. Continue with your current task."`
|
|
55
56
|
|
|
56
|
-
If the worker exits or writes `/tmp/
|
|
57
|
-
- `tmux send-keys -t "$HARNEX_SPAWNER_PANE" "
|
|
57
|
+
If the worker exits or writes `/tmp/pi-i-42-done.txt`, report back:
|
|
58
|
+
- `tmux send-keys -t "$HARNEX_SPAWNER_PANE" "pi-i-42 finished. Check /tmp/pi-i-42-done.txt." Enter`
|
|
58
59
|
|
|
59
60
|
Do not interfere with active work. Stop yourself after reporting completion.
|
|
60
61
|
```
|
|
@@ -73,7 +74,7 @@ harnex session:
|
|
|
73
74
|
|
|
74
75
|
```bash
|
|
75
76
|
tmux capture-pane -t "$HARNEX_SPAWNER_PANE" -p
|
|
76
|
-
tmux send-keys -t "$HARNEX_SPAWNER_PANE" "
|
|
77
|
+
tmux send-keys -t "$HARNEX_SPAWNER_PANE" "pi-i-42 finished" Enter
|
|
77
78
|
```
|
|
78
79
|
|
|
79
80
|
If no tmux return pane is available, require the buddy to write a file and tell
|
data/guides/04_monitoring.md
CHANGED
|
@@ -17,16 +17,17 @@ Prefer signals in this order:
|
|
|
17
17
|
| `harnex pane` | Live UI interpretation and prompt/error diagnosis |
|
|
18
18
|
| `harnex status` | Session liveness and coarse state |
|
|
19
19
|
|
|
20
|
-
For
|
|
21
|
-
turn-level fence. It still
|
|
22
|
-
expected artifact or tests
|
|
20
|
+
For structured sessions (Pi RPC and Codex app-server),
|
|
21
|
+
`harnex wait --until task_complete` is a strong turn-level fence. It still
|
|
22
|
+
does not know your acceptance criteria; verify the expected artifact or tests
|
|
23
|
+
afterward.
|
|
23
24
|
|
|
24
25
|
## Completion Test
|
|
25
26
|
|
|
26
27
|
For unattended work, declare done with a conjunction of work-level facts:
|
|
27
28
|
|
|
28
29
|
```bash
|
|
29
|
-
test -f /tmp/
|
|
30
|
+
test -f /tmp/pi-i-NN-done.txt &&
|
|
30
31
|
test -z "$(git status --short)" &&
|
|
31
32
|
test "$(git log -1 --format=%ct)" -lt "$(($(date +%s) - 600))"
|
|
32
33
|
```
|
|
@@ -51,23 +52,23 @@ where to look.
|
|
|
51
52
|
For active supervision:
|
|
52
53
|
|
|
53
54
|
```bash
|
|
54
|
-
harnex pane --id
|
|
55
|
-
harnex events --id
|
|
56
|
-
harnex logs --id
|
|
55
|
+
harnex pane --id pi-i-NN --lines 40
|
|
56
|
+
harnex events --id pi-i-NN --snapshot
|
|
57
|
+
harnex logs --id pi-i-NN --lines 80
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
For continuous viewing:
|
|
60
61
|
|
|
61
62
|
```bash
|
|
62
|
-
harnex pane --id
|
|
63
|
-
harnex logs --id
|
|
64
|
-
harnex events --id
|
|
63
|
+
harnex pane --id pi-i-NN --follow --interval 2
|
|
64
|
+
harnex logs --id pi-i-NN --follow
|
|
65
|
+
harnex events --id pi-i-NN
|
|
65
66
|
```
|
|
66
67
|
|
|
67
68
|
For task completion:
|
|
68
69
|
|
|
69
70
|
```bash
|
|
70
|
-
harnex wait --id
|
|
71
|
+
harnex wait --id pi-i-NN --until task_complete --timeout 900
|
|
71
72
|
```
|
|
72
73
|
|
|
73
74
|
## Background Sweeper
|
|
@@ -80,14 +81,14 @@ pipeline cannot wait forever:
|
|
|
80
81
|
start=$(date +%s)
|
|
81
82
|
max_wait=5400
|
|
82
83
|
|
|
83
|
-
until test -f /tmp/
|
|
84
|
+
until test -f /tmp/pi-i-NN-done.txt; do
|
|
84
85
|
if test "$(($(date +%s) - start))" -gt "$max_wait"; then
|
|
85
|
-
echo "wall-clock cap hit for
|
|
86
|
+
echo "wall-clock cap hit for pi-i-NN" >&2
|
|
86
87
|
exit 2
|
|
87
88
|
fi
|
|
88
89
|
|
|
89
|
-
harnex status --id
|
|
90
|
-
harnex pane --id
|
|
90
|
+
harnex status --id pi-i-NN --json
|
|
91
|
+
harnex pane --id pi-i-NN --lines 20
|
|
91
92
|
sleep 60
|
|
92
93
|
done
|
|
93
94
|
```
|
|
@@ -106,7 +107,7 @@ Use `harnex run --watch` when one foreground process should launch the worker
|
|
|
106
107
|
and apply bounded stall recovery:
|
|
107
108
|
|
|
108
109
|
```bash
|
|
109
|
-
harnex run
|
|
110
|
+
harnex run pi --id pi-i-NN --watch --preset impl \
|
|
110
111
|
--context "Read /tmp/task-impl-NN.md"
|
|
111
112
|
```
|
|
112
113
|
|
data/guides/05_naming.md
CHANGED
|
@@ -15,6 +15,7 @@ Common prefixes:
|
|
|
15
15
|
|
|
16
16
|
| Prefix | Meaning |
|
|
17
17
|
| --- | --- |
|
|
18
|
+
| `pi` | Pi worker (default) |
|
|
18
19
|
| `cx` | Codex worker |
|
|
19
20
|
| `cl` | Claude worker |
|
|
20
21
|
| `buddy` | Buddy monitor |
|
|
@@ -34,13 +35,13 @@ Common phases:
|
|
|
34
35
|
Examples:
|
|
35
36
|
|
|
36
37
|
```text
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
pi-m-42 Pi maps task 42
|
|
39
|
+
pi-p-42 Pi writes plan 42
|
|
40
|
+
pi-r-42 Pi reviews plan 42
|
|
41
|
+
pi-f-42 Pi fixes plan 42
|
|
42
|
+
pi-i-42 Pi implements plan 42
|
|
43
|
+
pi-cr-42 Pi reviews implementation 42
|
|
44
|
+
pi-cf-42 Pi fixes implementation 42
|
|
44
45
|
buddy-42 Buddy monitors task 42
|
|
45
46
|
```
|
|
46
47
|
|
|
@@ -52,13 +53,13 @@ short, and present in every artifact.
|
|
|
52
53
|
Always pass both and keep them identical:
|
|
53
54
|
|
|
54
55
|
```bash
|
|
55
|
-
harnex run
|
|
56
|
+
harnex run pi --id pi-i-42 --tmux pi-i-42
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
Avoid this:
|
|
59
60
|
|
|
60
61
|
```bash
|
|
61
|
-
harnex run
|
|
62
|
+
harnex run pi --tmux pi-i-42
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
If `--id` is missing, harnex generates a random session ID. The tmux window may
|
|
@@ -70,9 +71,9 @@ ID.
|
|
|
70
71
|
If a session fails and you dispatch a fresh attempt, append a suffix:
|
|
71
72
|
|
|
72
73
|
```text
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
pi-i-42 first attempt
|
|
75
|
+
pi-i-42b second attempt
|
|
76
|
+
pi-i-42c third attempt
|
|
76
77
|
```
|
|
77
78
|
|
|
78
79
|
Keep the old session's logs. They are useful for diagnosis.
|
|
@@ -97,9 +98,9 @@ session ID.
|
|
|
97
98
|
Derive done markers from the session ID:
|
|
98
99
|
|
|
99
100
|
```text
|
|
100
|
-
/tmp/
|
|
101
|
-
/tmp/
|
|
102
|
-
/tmp/
|
|
101
|
+
/tmp/pi-p-42-done.txt
|
|
102
|
+
/tmp/pi-i-42-done.txt
|
|
103
|
+
/tmp/pi-cr-42-done.txt
|
|
103
104
|
```
|
|
104
105
|
|
|
105
106
|
When a brief asks for a completion marker, make it one line and include the
|
data/lib/harnex/adapters/base.rb
CHANGED
|
@@ -24,8 +24,9 @@ module Harnex
|
|
|
24
24
|
@extra_args = extra_args.dup
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
# Default transport.
|
|
28
|
-
# :
|
|
27
|
+
# Default transport. Structured adapters override to :stdio_jsonrpc
|
|
28
|
+
# (Codex app-server) or :stdio_jsonl_rpc (Pi RPC); Session#run uses
|
|
29
|
+
# this to pick the I/O path.
|
|
29
30
|
def transport
|
|
30
31
|
:pty
|
|
31
32
|
end
|