harnex 0.12.0 → 0.29.0
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 +592 -0
- data/GUIDE.md +222 -68
- data/README.md +78 -48
- data/TECHNICAL.md +235 -98
- data/agents/gpt.md +60 -0
- data/docs/agents.md +119 -0
- data/docs/dispatch-telemetry.md +184 -50
- data/docs/events.md +20 -7
- data/docs/lanes.md +202 -0
- data/docs/mcp.md +102 -0
- data/docs/pi-rpc.md +81 -7
- data/docs/upgrading-to-0.29.md +87 -0
- data/guides/01_dispatch.md +101 -34
- data/guides/04_monitoring.md +223 -25
- data/guides/05_naming.md +0 -1
- data/guides/06_claude.md +96 -0
- data/lib/harnex/adapters/base.rb +4 -8
- data/lib/harnex/adapters/pi.rb +92 -12
- data/lib/harnex/adapters.rb +1 -16
- data/lib/harnex/artifact_report.rb +206 -12
- data/lib/harnex/cli.rb +68 -50
- data/lib/harnex/commands/ask.rb +278 -0
- data/lib/harnex/commands/delegate.rb +202 -0
- data/lib/harnex/commands/doctor.rb +34 -36
- data/lib/harnex/commands/events.rb +3 -3
- data/lib/harnex/commands/history.rb +2 -8
- data/lib/harnex/commands/land.rb +150 -0
- data/lib/harnex/commands/lanes.rb +84 -0
- data/lib/harnex/commands/logs.rb +3 -3
- data/lib/harnex/commands/mcp.rb +208 -0
- data/lib/harnex/commands/orchestration.rb +88 -9
- data/lib/harnex/commands/pane.rb +3 -3
- data/lib/harnex/commands/preflight.rb +566 -0
- data/lib/harnex/commands/reply.rb +125 -0
- data/lib/harnex/commands/result.rb +108 -0
- data/lib/harnex/commands/run.rb +248 -64
- data/lib/harnex/commands/send.rb +121 -16
- data/lib/harnex/commands/status.rb +32 -4
- data/lib/harnex/commands/stop.rb +14 -4
- data/lib/harnex/commands/telemetry.rb +19 -1
- data/lib/harnex/commands/wait.rb +421 -56
- data/lib/harnex/commands/watch.rb +134 -21
- data/lib/harnex/context_file.rb +85 -0
- data/lib/harnex/core.rb +100 -15
- data/lib/harnex/dispatch_history.rb +157 -10
- data/lib/harnex/lanes.rb +513 -0
- data/lib/harnex/mcp.rb +362 -0
- data/lib/harnex/orchestration.rb +128 -5
- data/lib/harnex/owned_process_group.rb +50 -0
- data/lib/harnex/owner_stream.rb +399 -0
- data/lib/harnex/pricing.rb +4 -9
- data/lib/harnex/runtime/activity_tracker.rb +107 -0
- data/lib/harnex/runtime/api_server.rb +11 -1
- data/lib/harnex/runtime/completion_notifier.rb +90 -11
- data/lib/harnex/runtime/inbox.rb +26 -7
- data/lib/harnex/runtime/message.rb +5 -2
- data/lib/harnex/runtime/runtime_budget.rb +96 -0
- data/lib/harnex/runtime/session.rb +684 -294
- data/lib/harnex/runtime/stop_request.rb +39 -0
- data/lib/harnex/stall.rb +46 -0
- data/lib/harnex/telemetry_reconciler.rb +42 -20
- data/lib/harnex/terminal_status.rb +5 -5
- data/lib/harnex/version.rb +2 -2
- data/lib/harnex.rb +16 -0
- data/recipes/01_fire_and_watch.md +14 -14
- data/recipes/02_chain_implement.md +35 -31
- data/recipes/03_buddy.md +1 -1
- metadata +34 -12
- data/docs/codex-appserver.md +0 -175
- data/lib/harnex/adapters/codex.rb +0 -160
- data/lib/harnex/adapters/codex_appserver.rb +0 -407
- data/lib/harnex/codex/app_server/client.rb +0 -347
data/README.md
CHANGED
|
@@ -1,43 +1,61 @@
|
|
|
1
1
|
# Harnex
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pi workers (GPT models by default) as tools for you and your coding agents.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
**Website and docs: [harnex.zyt.app](https://harnex.zyt.app)** ·
|
|
6
|
+
upgrading from an older release: [docs/upgrading-to-0.29.md](docs/upgrading-to-0.29.md)
|
|
7
|
+
|
|
8
|
+
Harnex runs Pi workers in visible tmux windows and hands their results back
|
|
9
|
+
in one call: ask another model a question, delegate a task into its own git
|
|
10
|
+
worktree and land it, run several workers in parallel, and follow up with a
|
|
11
|
+
worker that keeps its context. Claude Code and Pi get the same verbs as
|
|
12
|
+
native MCP tools. Underneath, it is a local harness for Pi, Claude Code,
|
|
13
|
+
OpenCode or any terminal CLI: launch, send, watch, inspect and stop.
|
|
8
14
|
|
|
9
15
|
```bash
|
|
10
16
|
gem install harnex
|
|
17
|
+
harnex doctor # checks Pi (structured RPC needs Pi 0.80.4+) and tmux
|
|
18
|
+
harnex mcp install # optional: native tools for Claude Code and Pi
|
|
11
19
|
```
|
|
12
20
|
|
|
13
|
-
Harnex itself requires **Ruby 3.x** and uses only the Ruby standard
|
|
14
|
-
library. Install the CLIs you want to wrap separately; Codex JSON-RPC
|
|
15
|
-
support requires Codex CLI **0.128.0 or newer**, Pi structured RPC requires
|
|
16
|
-
Pi **0.80.4 or newer**, and tmux-backed workflows require `tmux`.
|
|
21
|
+
Harnex itself requires **Ruby 3.x** and uses only the Ruby standard library.
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
## For agents (and people): lanes
|
|
19
24
|
|
|
20
25
|
```bash
|
|
21
|
-
harnex
|
|
22
|
-
harnex --help
|
|
23
|
-
harnex agents-guide
|
|
24
|
-
```
|
|
26
|
+
harnex ask "Which module writes dispatch rows, and is the lane case tested?"
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
harnex delegate --worktree word-count "Add TextKit.word_count(text) with a test; run bin/test"
|
|
29
|
+
git diff HEAD...harnex/word-count # review
|
|
30
|
+
harnex land word-count # merge, remove the worktree and branch
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
harnex
|
|
32
|
+
harnex reply word-count "Also add TextKit.char_count(text)" # same worker, same context
|
|
33
|
+
|
|
34
|
+
harnex delegate --no-wait --worktree a "Task A"
|
|
35
|
+
harnex delegate --no-wait --worktree b "Task B"
|
|
36
|
+
harnex result # each result as it lands
|
|
37
|
+
harnex lanes # what is open and what each needs
|
|
31
38
|
```
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
Every command prints the worker's reply and a `── NAME:` footer: state, time,
|
|
41
|
+
model, cost, commits and the next commands. Exit codes: 0 done, 1 failed, 124
|
|
42
|
+
still working (`harnex result NAME` keeps waiting; the default wait is 9
|
|
43
|
+
minutes, under a 10-minute agent tool cap).
|
|
44
|
+
|
|
45
|
+
- **MCP:** `harnex mcp install` registers `harnex mcp` for Claude Code (user
|
|
46
|
+
scope) and Pi, and installs a `gpt` subagent for Claude Code. The tools
|
|
47
|
+
`ask`, `delegate`, `result`, `reply`, `land`, `discard` and `lanes` then
|
|
48
|
+
appear natively. Long calls report progress; Claude Code moves them to the
|
|
49
|
+
background after two minutes.
|
|
50
|
+
- **Docs:** [lanes](docs/lanes.md), [MCP server](docs/mcp.md),
|
|
51
|
+
[coding agents](docs/agents.md); `harnex agents-guide claude` is the
|
|
52
|
+
agent-facing guide and `harnex --help` lists everything.
|
|
53
|
+
|
|
54
|
+
## Low-level control
|
|
35
55
|
|
|
36
|
-
`harnex
|
|
37
|
-
|
|
38
|
-
or project-local docs are required.
|
|
56
|
+
Before an unattended run, `harnex preflight pi --cwd ~/repo` proves the Pi
|
|
57
|
+
adapter end to end with one tiny real dispatch and prints a JSON verdict.
|
|
39
58
|
|
|
40
|
-
## What it does
|
|
41
59
|
|
|
42
60
|
```bash
|
|
43
61
|
# Start a visible one-shot worker, give it a task, and stop on completion
|
|
@@ -73,7 +91,7 @@ enclosing git root's `.harnex/dispatch.jsonl`; a non-git directory uses the
|
|
|
73
91
|
global `~/.local/state/harnex/dispatch.jsonl` fallback:
|
|
74
92
|
|
|
75
93
|
```bash
|
|
76
|
-
harnex run
|
|
94
|
+
harnex run pi --cwd /tmp/leximaze_eval_run_001 \
|
|
77
95
|
--id lm-run-001 \
|
|
78
96
|
--context "Read README.md and write RESPONSES.jsonl and OUTPUT.md" \
|
|
79
97
|
--auto-stop
|
|
@@ -111,28 +129,17 @@ an explicit working-directory/root selector for automation.
|
|
|
111
129
|
|
|
112
130
|
| Agent | Support |
|
|
113
131
|
|-------|---------|
|
|
132
|
+
| Pi (default worker) | JSONL RPC adapter (`pi --mode rpc`, Pi >= 0.80.4) with settled completion, typed failures, tool/retry events, extension-UI auto-cancel, and session stats telemetry |
|
|
114
133
|
| Claude Code | PTY adapter with prompt detection, stop sequence, workspace trust, and vim mode handling |
|
|
115
|
-
| OpenAI Codex | JSON-RPC `codex app-server` adapter by default; PTY mode remains supported for TUI/interactive use via `--legacy-pty` |
|
|
116
|
-
| Pi | JSONL RPC adapter (`pi --mode rpc`, Pi >= 0.80.4) with settled completion, typed failures, tool/retry events, extension-UI auto-cancel, and session stats telemetry |
|
|
117
134
|
| OpenCode | PTY adapter with native Ctrl+C stop handling and OpenCode-specific prompt/readiness heuristics |
|
|
118
135
|
| Any terminal CLI | Generic PTY wrapping with local API, logs, status, and best-effort prompt detection |
|
|
119
136
|
|
|
120
|
-
`harnex run codex` uses JSON-RPC by default. That path provides
|
|
121
|
-
structured task-completion events, approval mediation, and token usage
|
|
122
|
-
capture. Default JSON-RPC Codex does not accept `-m` / `--model`; pass
|
|
123
|
-
model settings as child CLI config, for example `harnex run codex -- -c model=NAME`.
|
|
124
|
-
Harnex forces Codex app-server `service_tier="flex"` unless you opt into
|
|
125
|
-
`service_tier="fast"` with `harnex run codex --fast`.
|
|
126
|
-
Use `harnex run codex --legacy-pty` when you specifically want Codex's
|
|
127
|
-
terminal UI or PTY-only Codex flags. The flag name is historical; the PTY path
|
|
128
|
-
is still supported.
|
|
129
|
-
|
|
130
137
|
`harnex run pi` launches `pi --mode rpc` and sends `--context` as a structured
|
|
131
138
|
`prompt` command (not a CLI positional argument). Harnex `--model` / `--effort`
|
|
132
139
|
flags become Pi `--model` / `--thinking` startup controls and are verified over
|
|
133
140
|
RPC before the prompt; use a deterministic `provider/model` value. Pass other
|
|
134
141
|
Pi startup flags after the separator, for example:
|
|
135
|
-
`harnex run pi --context "Implement X" -- --
|
|
142
|
+
`harnex run pi --model openai/gpt-5.1 --effort high --context "Implement X" -- --no-approve`.
|
|
136
143
|
For unattended runs, explicitly choose Pi project trust with child
|
|
137
144
|
`--approve` or `--no-approve`; Harnex never auto-trusts repository code.
|
|
138
145
|
See [docs/pi-rpc.md](docs/pi-rpc.md) for lifecycle, compatibility, and failure
|
|
@@ -162,6 +169,18 @@ harnex stop --id cl-review
|
|
|
162
169
|
For delegated work, pass the same value to `--id` and `--tmux` so
|
|
163
170
|
`harnex status`, `harnex pane`, logs, and the tmux window name all line up.
|
|
164
171
|
|
|
172
|
+
From Claude Code, a GPT-backed Pi worker can be called like a tool:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# A read-only question; stdout is the worker's answer
|
|
176
|
+
harnex ask "Which module writes dispatch rows, and is the lane case tested?"
|
|
177
|
+
|
|
178
|
+
# One delegated task, one blocking call, one JSON result (the reply is
|
|
179
|
+
# turn_result.final_message)
|
|
180
|
+
harnex run pi --id pi-i-42 --tmux pi-i-42 --context-file /tmp/task-42.md \
|
|
181
|
+
--auto-stop --wait-done --wait-timeout 9m
|
|
182
|
+
```
|
|
183
|
+
|
|
165
184
|
Harnex ships CLI-readable agent guides for this pattern:
|
|
166
185
|
|
|
167
186
|
- **[Dispatch](guides/01_dispatch.md)** — the fire-and-watch pattern:
|
|
@@ -173,6 +192,9 @@ Harnex ships CLI-readable agent guides for this pattern:
|
|
|
173
192
|
- **[Monitoring](guides/04_monitoring.md)** — completion signals and
|
|
174
193
|
poll/watch patterns
|
|
175
194
|
- **[Naming](guides/05_naming.md)** — session IDs, task files, done markers
|
|
195
|
+
- **[Claude](guides/06_claude.md)** — Claude Code sessions and subagents using
|
|
196
|
+
GPT-backed Pi workers as tools: `harnex ask`, one-call delegation, parallel
|
|
197
|
+
lanes, follow-ups
|
|
176
198
|
|
|
177
199
|
Read them from the installed CLI:
|
|
178
200
|
|
|
@@ -217,14 +239,13 @@ For file-change hooks, use `--watch-file PATH`. The older
|
|
|
217
239
|
`--watch PATH`/`--watch=PATH` form is still accepted for compatibility, while
|
|
218
240
|
bare `--watch` means babysitter mode.
|
|
219
241
|
|
|
220
|
-
For one-shot startup prompts, add `--auto-stop`. It requires `--context
|
|
221
|
-
A
|
|
222
|
-
|
|
223
|
-
|
|
242
|
+
For one-shot startup prompts, add `--auto-stop`. It requires `--context` (or
|
|
243
|
+
`--context-file`). A Pi turn is accepted when it settles. With
|
|
244
|
+
`--require-artifact-report` it must also show command/tool activity or a Git
|
|
245
|
+
delta; an acknowledgment-only turn then emits
|
|
224
246
|
`outcome.class=completed_no_activity`, makes `watch --until done` return
|
|
225
|
-
non-zero, and auto-stops with a non-zero verdict
|
|
226
|
-
|
|
227
|
-
structured activity signals.
|
|
247
|
+
non-zero, and auto-stops with a non-zero verdict. PTY adapters stop on prompt
|
|
248
|
+
return because they do not expose structured activity signals.
|
|
228
249
|
|
|
229
250
|
## Completion and waiting
|
|
230
251
|
|
|
@@ -240,7 +261,7 @@ Choose the wait/watch predicate that matches how you launched the worker:
|
|
|
240
261
|
- `harnex wait --id ID` waits for the wrapped process to exit. This is right
|
|
241
262
|
for already-exited sessions and terminal-summary recovery, but interactive
|
|
242
263
|
agents can stay open after finishing a turn.
|
|
243
|
-
- For structured Pi RPC
|
|
264
|
+
- For structured Pi RPC sessions, use
|
|
244
265
|
`harnex wait --id ID --until task_complete --timeout SECS` when you need the
|
|
245
266
|
exact successful-turn event instead of terminal-exit fallback. Use
|
|
246
267
|
`--until task_failed` to wait specifically for a failed structured turn.
|
|
@@ -420,7 +441,7 @@ EOF
|
|
|
420
441
|
|
|
421
442
|
Every spawned session gets `$HARNEX_SPAWNER_PANE` — the tmux pane ID
|
|
422
443
|
of whoever ran `harnex run`. The buddy can report back to a plain
|
|
423
|
-
Claude Code session, a
|
|
444
|
+
Claude Code session, a Pi session, or any tmux pane:
|
|
424
445
|
|
|
425
446
|
```bash
|
|
426
447
|
tmux send-keys -t "$HARNEX_SPAWNER_PANE" "worker-42 finished" Enter
|
|
@@ -432,6 +453,13 @@ See [recipes/03_buddy.md](recipes/03_buddy.md) for the full pattern.
|
|
|
432
453
|
|
|
433
454
|
| Command | What it does |
|
|
434
455
|
|---------|-------------|
|
|
456
|
+
| `harnex ask "QUESTION"` | A read-only answer from a Pi worker (`--write` lets it edit); `harnex reply ID` follows up |
|
|
457
|
+
| `harnex delegate [--worktree NAME] TASK` | A worker does the task; prints its reply and a lane footer (`--no-wait` for parallel lanes) |
|
|
458
|
+
| `harnex result [NAME...]` | Wait for lanes and print each result as it lands |
|
|
459
|
+
| `harnex reply NAME MESSAGE` | Follow-up to a lane's worker, which keeps its context |
|
|
460
|
+
| `harnex land NAME` / `harnex discard NAME` | Merge a worktree lane and clean up / drop it |
|
|
461
|
+
| `harnex lanes` | Your lanes and the next step for each |
|
|
462
|
+
| `harnex mcp [install]` | The lane verbs as MCP tools for Claude Code and Pi |
|
|
435
463
|
| `harnex run <cli>` | Start an agent (`--tmux` visible, `--detach` background, `--watch` built-in monitoring) |
|
|
436
464
|
| `harnex send --id <id>` | Send a message (queues if busy, `--wait-for-idle` to block until the turn returns idle) |
|
|
437
465
|
| `harnex stop --id <id>` | Send the agent's native exit sequence |
|
|
@@ -444,6 +472,7 @@ See [recipes/03_buddy.md](recipes/03_buddy.md) for the full pattern.
|
|
|
444
472
|
| `harnex wait --id <id>` | Block until process exit by default; use `--until done` for unattended work completion or `--until task_complete` for exact structured turn completion |
|
|
445
473
|
| `harnex artifact-report init\|validate PATH` | Validate harness-authored `harnex.artifact_report.v1` receipts; `init` remains for legacy/manual documents |
|
|
446
474
|
| `harnex doctor` | Run dependency and retention diagnostics; `--sweep` reports session drift, `--prune --dry-run` previews retention, and `--prune` applies it |
|
|
475
|
+
| `harnex preflight <cli>` | One tiny real dispatch proving boot, files, command exits, receipt, completion and stop (`--commit-check` adds a scratch-repo commit); JSON verdict, non-zero on failure |
|
|
447
476
|
| `harnex guide` | Getting started walkthrough |
|
|
448
477
|
| `harnex agents-guide` | Agent-facing dispatch, chain, buddy, monitoring, and naming guides |
|
|
449
478
|
| `harnex recipes` | List and read tested workflow patterns (`show 01`, `show buddy`) |
|
|
@@ -451,12 +480,13 @@ See [recipes/03_buddy.md](recipes/03_buddy.md) for the full pattern.
|
|
|
451
480
|
## Uninstalling
|
|
452
481
|
|
|
453
482
|
```bash
|
|
483
|
+
harnex mcp uninstall # if you ran harnex mcp install
|
|
454
484
|
gem uninstall harnex
|
|
455
485
|
```
|
|
456
486
|
|
|
457
487
|
If you installed harnex skills with an older release, those copies are no
|
|
458
|
-
longer used. Remove stale `~/.claude/skills/harnex-*`
|
|
459
|
-
|
|
488
|
+
longer used. Remove stale `~/.claude/skills/harnex-*` entries manually if you
|
|
489
|
+
want to clean them up.
|
|
460
490
|
|
|
461
491
|
## Going deeper
|
|
462
492
|
|