harnex 0.7.3 → 0.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -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 +38 -24
- data/guides/05_naming.md +22 -17
- 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/commands/status.rb +35 -6
- data/lib/harnex/commands/wait.rb +45 -1
- data/lib/harnex/runtime/session.rb +164 -23
- data/lib/harnex/terminal_status.rb +202 -0
- data/lib/harnex/version.rb +2 -2
- data/lib/harnex.rb +1 -0
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c6173057b1fe4fa547979d3d9803f345acb4e658dd942aefa096ef886727c33
|
|
4
|
+
data.tar.gz: da1662c9dce791ae644aa4a0ea57d2124a1698593e6db98b2ac737d9f42816f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2758cfa10fc9b221235efea20ff21be32b5558c1ab06eb4515cea5485be96e1371d663735c826d9587833caa46aed65486b5c3cedfe8ce3be04e7ac1c328f7f
|
|
7
|
+
data.tar.gz: 765cf4ef020f3a7cfa8bbd1aad517ac1b4ec8901579b3720ea618ec246b20009c07c088d4d86e354ead78194844bba771790df0271d54fccecad6f6058874d9f
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.7.5] - 2026-05-26 | 05:18 PM | IST
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `Harnex::TerminalStatus` now resolves durable terminal dispatch state from
|
|
10
|
+
summary/history rows so commands can classify inactive sessions without
|
|
11
|
+
relying on tmp done markers.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- `harnex status --json --id <id>` now returns a machine-readable row even when
|
|
16
|
+
the live session is gone, with `state` in `running|completed|failed|unknown`
|
|
17
|
+
and terminal metadata (`terminal`, `exit`, `exit_code`, `summary_out`).
|
|
18
|
+
- `harnex wait --id <id>` now falls back to terminal summary/history telemetry
|
|
19
|
+
when registry and exit-status files are missing, returning `completed` on
|
|
20
|
+
summary success and `unknown` when no durable terminal signal exists.
|
|
21
|
+
- Monitoring guides now treat `/tmp/*-done.txt` as legacy compatibility hints;
|
|
22
|
+
canonical completion is `harnex wait` / `harnex status --json` / dispatch
|
|
23
|
+
summary rows.
|
|
24
|
+
|
|
25
|
+
## [0.7.4] - 2026-05-25 | 08:45 AM | IST
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- First-class `pi` structured adapter (`Harnex::Adapters::Pi`) for
|
|
30
|
+
`pi --mode rpc` JSONL transport. `harnex run pi` now supports
|
|
31
|
+
structured completion (`agent_end` -> `task_complete`), stop/abort,
|
|
32
|
+
extension-UI dialog auto-cancel in RPC mode, streamed output/tool
|
|
33
|
+
synthesis, and Pi session-stats telemetry capture.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Structured transport handling in `Session` now supports both Codex
|
|
38
|
+
JSON-RPC (`:stdio_jsonrpc`) and Pi JSONL RPC (`:stdio_jsonl_rpc`).
|
|
39
|
+
- DISPATCH telemetry restores `actual.cost_usd` (adapter-reported
|
|
40
|
+
approximate USD when available). Pi sessions populate it from
|
|
41
|
+
`get_session_stats.cost`; adapters without reliable cost stay `null`.
|
|
42
|
+
- README, dispatch telemetry docs, and dispatch guide now document Pi RPC
|
|
43
|
+
usage and the `--` child-flag pattern.
|
|
44
|
+
|
|
5
45
|
## [0.7.3] - 2026-05-13 | 01:43 PM | IST
|
|
6
46
|
|
|
7
47
|
### 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
|
|
57
|
-
- `tmux send-keys -t "$HARNEX_SPAWNER_PANE" "
|
|
57
|
+
If `harnex status --id pi-i-42 --json` reports `state=completed` or `state=failed`, report back:
|
|
58
|
+
- `tmux send-keys -t "$HARNEX_SPAWNER_PANE" "pi-i-42 terminal state reached. Check harnex status --id pi-i-42 --json." 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,22 +17,27 @@ 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
|
-
For unattended work,
|
|
27
|
+
For unattended work, first gate on harnex terminal state, then verify the task
|
|
28
|
+
artifact and repo health:
|
|
27
29
|
|
|
28
30
|
```bash
|
|
29
|
-
|
|
30
|
-
test -
|
|
31
|
-
test "$(git
|
|
31
|
+
harnex wait --id pi-i-NN --timeout 5400 &&
|
|
32
|
+
test -f path/to/expected-artifact &&
|
|
33
|
+
test -z "$(git status --short)"
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
`harnex wait` succeeds from durable terminal telemetry (`--summary-out` /
|
|
37
|
+
`.harnex/dispatch.jsonl` / exit status), not from tmp done markers.
|
|
38
|
+
|
|
39
|
+
Adjust the artifact path to the task. The point is to avoid declaring done while
|
|
40
|
+
a worker is between edits or between commits.
|
|
36
41
|
|
|
37
42
|
## Why Pane State Alone Is Not Enough
|
|
38
43
|
|
|
@@ -51,43 +56,51 @@ where to look.
|
|
|
51
56
|
For active supervision:
|
|
52
57
|
|
|
53
58
|
```bash
|
|
54
|
-
harnex pane --id
|
|
55
|
-
harnex events --id
|
|
56
|
-
harnex logs --id
|
|
59
|
+
harnex pane --id pi-i-NN --lines 40
|
|
60
|
+
harnex events --id pi-i-NN --snapshot
|
|
61
|
+
harnex logs --id pi-i-NN --lines 80
|
|
57
62
|
```
|
|
58
63
|
|
|
59
64
|
For continuous viewing:
|
|
60
65
|
|
|
61
66
|
```bash
|
|
62
|
-
harnex pane --id
|
|
63
|
-
harnex logs --id
|
|
64
|
-
harnex events --id
|
|
67
|
+
harnex pane --id pi-i-NN --follow --interval 2
|
|
68
|
+
harnex logs --id pi-i-NN --follow
|
|
69
|
+
harnex events --id pi-i-NN
|
|
65
70
|
```
|
|
66
71
|
|
|
67
72
|
For task completion:
|
|
68
73
|
|
|
69
74
|
```bash
|
|
70
|
-
harnex wait --id
|
|
75
|
+
harnex wait --id pi-i-NN --until task_complete --timeout 900
|
|
71
76
|
```
|
|
72
77
|
|
|
73
78
|
## Background Sweeper
|
|
74
79
|
|
|
75
|
-
Consumers often run a small shell loop that checks
|
|
76
|
-
|
|
77
|
-
pipeline cannot wait forever:
|
|
80
|
+
Consumers often run a small shell loop that checks terminal state, then drops
|
|
81
|
+
to pane diagnostics only while work is still running. Keep a hard wall-clock cap
|
|
82
|
+
so an unattended pipeline cannot wait forever:
|
|
78
83
|
|
|
79
84
|
```bash
|
|
80
85
|
start=$(date +%s)
|
|
81
86
|
max_wait=5400
|
|
82
87
|
|
|
83
|
-
|
|
88
|
+
while :; do
|
|
84
89
|
if test "$(($(date +%s) - start))" -gt "$max_wait"; then
|
|
85
|
-
echo "wall-clock cap hit for
|
|
90
|
+
echo "wall-clock cap hit for pi-i-NN" >&2
|
|
86
91
|
exit 2
|
|
87
92
|
fi
|
|
88
93
|
|
|
89
|
-
harnex status --id
|
|
90
|
-
|
|
94
|
+
row=$(harnex status --id pi-i-NN --json | ruby -rjson -e 'rows=JSON.parse(STDIN.read); print JSON.generate(rows.first || {})')
|
|
95
|
+
state=$(printf '%s' "$row" | ruby -rjson -e 'print(JSON.parse(STDIN.read)["state"].to_s)')
|
|
96
|
+
|
|
97
|
+
case "$state" in
|
|
98
|
+
completed) echo "pi-i-NN completed"; break ;;
|
|
99
|
+
failed|unknown) echo "pi-i-NN terminal state: $state" >&2; exit 1 ;;
|
|
100
|
+
running) harnex pane --id pi-i-NN --lines 20 ;;
|
|
101
|
+
*) harnex pane --id pi-i-NN --lines 20 ;;
|
|
102
|
+
esac
|
|
103
|
+
|
|
91
104
|
sleep 60
|
|
92
105
|
done
|
|
93
106
|
```
|
|
@@ -106,7 +119,7 @@ Use `harnex run --watch` when one foreground process should launch the worker
|
|
|
106
119
|
and apply bounded stall recovery:
|
|
107
120
|
|
|
108
121
|
```bash
|
|
109
|
-
harnex run
|
|
122
|
+
harnex run pi --id pi-i-NN --watch --preset impl \
|
|
110
123
|
--context "Read /tmp/task-impl-NN.md"
|
|
111
124
|
```
|
|
112
125
|
|
|
@@ -124,6 +137,7 @@ interpretation.
|
|
|
124
137
|
## Anti-Patterns
|
|
125
138
|
|
|
126
139
|
- Polling `state=prompt` alone and calling it done.
|
|
140
|
+
- Blocking orchestrators on `/tmp/*-done.txt` as the only completion signal.
|
|
127
141
|
- Letting an unattended loop run with no wall-clock cap.
|
|
128
142
|
- Reading raw tmux panes instead of `harnex pane`.
|
|
129
143
|
- Using `--wait-for-idle` as acceptance proof.
|