harnex 0.5.0 → 0.6.2

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.
@@ -1,294 +0,0 @@
1
- ---
2
- name: harnex-dispatch
3
- description: Fire & Watch — the standard pattern for launching and monitoring harnex agent sessions. Use when dispatching implementation, review, or fix agents.
4
- allowed-tools: Bash(harnex *)
5
- ---
6
-
7
- # Dispatch — Fire & Watch
8
-
9
- Every harnex agent dispatch follows three phases: **spawn**, **watch**, **stop**.
10
- Before spawn, always decide the return channel and message contract.
11
-
12
- `harnex-dispatch` is the canonical home for lifecycle mechanics only.
13
- For orchestrator role boundaries, phase gates, and chain-level parallel policy,
14
- see `harnex-chain`.
15
-
16
- ## Detect your context
17
-
18
- Check env vars first to know whether you are inside a harnex-managed session:
19
-
20
- | Variable | Meaning |
21
- |----------|---------|
22
- | `HARNEX_SESSION_CLI` | Which CLI this session is (`claude` or `codex`) |
23
- | `HARNEX_ID` | Your session ID |
24
- | `HARNEX_SESSION_REPO_ROOT` | Repo root the session is scoped to |
25
- | `HARNEX_SESSION_ID` | Internal harnex instance ID |
26
- | `HARNEX_SPAWNER_PANE` | tmux pane ID (`%N`) of the invoker |
27
-
28
- If these are present, you can coordinate peers directly with `harnex send`,
29
- `harnex status`, and `harnex wait`. `HARNEX_SPAWNER_PANE` is the fallback
30
- return channel to the invoker via `tmux send-keys`.
31
-
32
- ## Return Channel First
33
-
34
- Define how results come back before delegating work.
35
-
36
- - Inside harnex: require peers to send final results back to your own
37
- `HARNEX_ID` via `harnex send --id "$HARNEX_ID" ...`
38
- - Outside harnex: require a concrete return path (for example a specific file
39
- in the repo or an explicit tmux pane message)
40
-
41
- Do not delegate work without an explicit completion contract.
42
-
43
- ## Send Hygiene
44
-
45
- ### Keep prompts short; reference files for long instructions
46
-
47
- ```bash
48
- cat > /tmp/task-impl-NN.md <<'EOF'
49
- Detailed instructions here...
50
- EOF
51
-
52
- harnex send --id cx-impl-NN --message "Read /tmp/task-impl-NN.md. Reply with final status to harnex id $HARNEX_ID."
53
- ```
54
-
55
- Long inline messages are brittle in PTYs. Use plan/issue files or temp files.
56
-
57
- ### Require explicit reply instruction in every delegated task
58
-
59
- ```bash
60
- harnex send --id cl-rev-NN --message "Review koder/plans/NN_name.md. When done send findings to harnex id $HARNEX_ID."
61
- ```
62
-
63
- ## Relay Headers
64
-
65
- Messages sent from one harnex session to another are auto-wrapped:
66
-
67
- ```
68
- [harnex relay from=<cli> id=<sender_id> at=<timestamp>]
69
- <message body>
70
- ```
71
-
72
- When you receive a relay header, treat it as an actionable prompt from the
73
- peer. Respond using `harnex send --id <sender_id> ...` unless instructed
74
- otherwise.
75
-
76
- ## Practical Reply/Delegate Patterns
77
-
78
- Reply to a peer:
79
-
80
- ```bash
81
- harnex send --id <TARGET_ID> --message "<result>"
82
- ```
83
-
84
- Delegate and force a return path:
85
-
86
- ```bash
87
- harnex send --id cx-impl-NN --message "$(cat <<EOF
88
- Implement koder/plans/NN_name.md.
89
- Run tests before finishing.
90
- When done, send one summary line back to harnex id $HARNEX_ID.
91
- EOF
92
- )"
93
- ```
94
-
95
- ## 1. Spawn
96
-
97
- Launch the agent in a tmux window so the user can observe it live:
98
-
99
- ```bash
100
- harnex run codex --id cx-impl-NN --tmux cx-impl-NN \
101
- --context "Implement koder/plans/NN_name.md. Run tests when done. Commit after each phase."
102
- ```
103
-
104
- For reviews (Claude):
105
-
106
- ```bash
107
- harnex run claude --id cl-rev-NN --tmux cl-rev-NN \
108
- --context "Review the implementation of plan NN against the spec in koder/plans/NN_name.md. Write findings to koder/reviews/NN_name.md"
109
- ```
110
-
111
- For complex task prompts, write to a temp file and reference it:
112
-
113
- ```bash
114
- cat > /tmp/task-impl-NN.md <<'EOF'
115
- Detailed instructions here...
116
- EOF
117
-
118
- harnex run codex --id cx-impl-NN --tmux cx-impl-NN \
119
- --context "Read and execute /tmp/task-impl-NN.md"
120
- ```
121
-
122
- ### Built-in monitoring (`--watch`)
123
-
124
- For unattended implementation runs where you only need stall policy (not
125
- Claude-side reasoning), bundle dispatch and monitoring in one command:
126
-
127
- ```bash
128
- harnex run codex --id cx-impl-42 --tmux cx-impl-42 --watch --preset impl
129
- ```
130
-
131
- `--preset impl` applies the standard 8m stall threshold with one forced resume.
132
- Trade-off: `--watch` is foreground-blocking and policy-only (`stall-after` +
133
- `max-resumes`). Use pane polling (and buddy when needed) for richer reasoning.
134
-
135
- ## 2. Watch
136
-
137
- Poll the agent's screen with `harnex pane`. Checking is cheap — a 20-line
138
- tail is a few hundred bytes.
139
-
140
- For structured orchestration, prefer `harnex events --id <id>` over pane-text
141
- scraping.
142
-
143
- **Default: poll every 30 seconds.** This is fine for most work. The check
144
- itself costs almost nothing and catches completion quickly.
145
-
146
- **Progressive intervals** when you expect longer work:
147
-
148
- | Elapsed | Interval | Rationale |
149
- |---------|----------|-----------|
150
- | 0–2 min | 30s | Catch fast completions and early errors |
151
- | 2–10 min | 60s | Steady state for typical implementations |
152
- | 10+ min | 120s | Long-running work, reduce noise |
153
-
154
- ```bash
155
- # Quick check — last 20 lines is enough to see if done or stuck
156
- harnex pane --id cx-impl-NN --lines 20
157
-
158
- # JSON metadata (includes capture timestamp)
159
- harnex pane --id cx-impl-NN --lines 20 --json
160
- ```
161
-
162
- When checking, look for:
163
- - **At prompt** → agent finished, read last output for results
164
- - **Still working** → agent is reading files, running tests, editing code
165
- - **Error/stuck** → agent hit a blocker, may need intervention
166
- - **Permission prompt** → agent waiting for user approval, intervene
167
-
168
- ### Background poll from Claude Code
169
-
170
- ```bash
171
- # Run as a background task, check result when notified
172
- harnex pane --id cx-impl-NN --lines 20
173
- ```
174
-
175
- Or use `--follow` for continuous monitoring:
176
-
177
- ```bash
178
- harnex pane --id cx-impl-NN --lines 20 --follow
179
- ```
180
-
181
- ## 3. Stop
182
-
183
- When the agent is done (at prompt, work committed):
184
-
185
- Stop each completed session as soon as its commit lands.
186
-
187
- ```bash
188
- harnex stop --id cx-impl-NN
189
- ```
190
-
191
- Always verify the agent's work landed before stopping:
192
-
193
- ```bash
194
- # Quick sanity check
195
- harnex pane --id cx-impl-NN --lines 20
196
- # Confirm commits exist
197
- git log --oneline -5
198
- # Then stop
199
- harnex stop --id cx-impl-NN
200
- ```
201
-
202
- ## Naming Conventions
203
-
204
- | Step | ID pattern | tmux window | Example |
205
- |------|-----------|-------------|---------|
206
- | Mapping | `cx-map-NN` | `cx-map-NN` | `cx-map-42` |
207
- | Map review | `cx-rev-map-NN` | `cx-rev-map-NN` | `cx-rev-map-42` |
208
- | Map fix | `cx-fix-map-NN` | `cx-fix-map-NN` | `cx-fix-map-42` |
209
- | Implement | `cx-impl-NN` | `cx-impl-NN` | `cx-impl-42` |
210
- | Review | `cl-rev-NN` | `cl-rev-NN` | `cl-rev-42` |
211
- | Fix | `cx-fix-NN` | `cx-fix-NN` | `cx-fix-42` |
212
- | Plan write | `cx-plan-NN` | `cx-plan-NN` | `cx-plan-42` |
213
- | Plan review | `cx-rev-plan-NN` | `cx-rev-plan-NN` | `cx-rev-plan-42` |
214
- | Plan fix | `cx-fix-plan-NN` | `cx-fix-plan-NN` | `cx-fix-plan-42` |
215
- | Buddy | `buddy-NN` | `buddy-NN` | `buddy-42` |
216
-
217
- **Rule**: Always use `--tmux <same-as-id>` so the tmux window name matches
218
- the session ID. Never use a different tmux name.
219
-
220
- ## Full Dispatch Lifecycle
221
-
222
- ```
223
- 1. Mark plan IN_PROGRESS, commit
224
- 2. harnex run codex --id cx-impl-NN --tmux cx-impl-NN
225
- 3. Poll with harnex pane --lines 20 every 30s
226
- 4. When done: verify commits, harnex stop
227
- 5. harnex run claude --id cl-rev-NN --tmux cl-rev-NN (review)
228
- 6. Poll with harnex pane --lines 20 every 30s
229
- 7. When done: harnex stop, read review
230
- 8. If NEEDS FIXES: harnex run codex --id cx-fix-NN (fix pass)
231
- 9. If PASS: done
232
- ```
233
-
234
- ## Worktree Option
235
-
236
- Use worktrees only when you need **parallel isolation** — e.g., implementing
237
- one plan while another is being reviewed, or when the user explicitly asks.
238
- Do not default to worktrees for serial work.
239
-
240
- ### Worktree Setup
241
-
242
- ```bash
243
- # Commit all files the agent will need BEFORE creating the worktree
244
- # (untracked files don't carry over)
245
- git add koder/plans/NN_name.md
246
- git commit -m "docs(plan-NN): add plan"
247
-
248
- # Create worktree
249
- WORKTREE="$(pwd)/../$(basename $(pwd))-plan-NN"
250
- git worktree add ${WORKTREE} -b plan/NN_name main
251
-
252
- # Launch from worktree
253
- cd ${WORKTREE}
254
- harnex run codex --id cx-impl-NN --tmux cx-impl-NN \
255
- --context "Implement koder/plans/NN_name.md. Run tests when done."
256
- ```
257
-
258
- ### Worktree Caveats
259
-
260
- - **cd first**: launch and manage sessions from the worktree directory
261
- - **Merge conflicts**: `koder/` state files may diverge — on merge, keep
262
- master's versions of session-state files
263
- - **Cleanup**: `git worktree remove <path>` then `git branch -d plan/<branch>`
264
-
265
- ## Checking Status
266
-
267
- ```bash
268
- harnex status # current repo sessions
269
- harnex status --all # all repos
270
- ```
271
-
272
- ## Buddy for Long-Running Dispatches
273
-
274
- If the dispatched work is expected to take a long time (overnight, multi-hour)
275
- or the user asks for unattended execution, spawn a buddy alongside the worker.
276
- Dispatch mechanics stay here; buddy monitoring mechanics live in
277
- `harnex-buddy`.
278
-
279
- ```bash
280
- harnex run claude --id buddy-NN --tmux buddy-NN
281
- harnex send --id buddy-NN --message "Watch session cx-impl-NN. Follow skills/harnex-buddy/SKILL.md and report completion to \$HARNEX_SPAWNER_PANE."
282
- ```
283
-
284
- For activation conditions, poll/stall/nudge loop, return channel details, and
285
- buddy cleanup, use `harnex-buddy`.
286
-
287
- ## What NOT to Do
288
-
289
- - **Never** launch agents with raw `tmux send-keys` or `tmux new-window`
290
- - **Never** use `--tmux NAME` where NAME differs from `--id`
291
- - **Never** pass `-- --cd <path>` to Claude sessions (unsupported flag)
292
- - **Never** poll with raw `tmux capture-pane` — use `harnex pane`
293
- - **Never** rely on `--wait-for-idle` alone — always use Fire & Watch
294
- - **Never** use `c-zai-dangerous` or direct CLI spawning outside harnex
data/skills/open/SKILL.md DELETED
@@ -1,32 +0,0 @@
1
- ---
2
- name: open
3
- description: Open a work session in this repo — read koder/STATE.md first, inspect the current worktree, align on the active issue or plan, and establish the starting point before editing. Use when the user says "open session", "start work", "initialize", "orient yourself", or invokes "/open".
4
- ---
5
-
6
- # Open Session Workflow
7
-
8
- When the user asks to initialize or open the session, run this sequence:
9
-
10
- ## 1. Read the handoff
11
-
12
- - Read `koder/STATE.md` first
13
- - Note the `Current snapshot`, open issues and plans, and `Next step`
14
- - Open only the issue or plan files relevant to the current task
15
-
16
- ## 2. Inspect the repo state
17
-
18
- - Run `git status --short`
19
- - Notice modified or untracked files before editing
20
- - Do not revert unrelated changes you did not make
21
-
22
- ## 3. Establish the starting point
23
-
24
- - Summarize the important context for this session: relevant issue or plan, repo state, and the immediate next step
25
- - If the user already asked for implementation, continue into the work instead of stopping at orientation
26
- - Update `koder/STATE.md` during open only if it is clearly stale enough to mislead the session
27
-
28
- ## Notes
29
-
30
- - Treat `koder/STATE.md` as the handoff document between sessions
31
- - Prefer updating existing issue or plan docs over creating new tracking files
32
- - Do NOT create issue docs unless the user explicitly asks