harnex 0.6.0 → 0.6.3

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,132 +0,0 @@
1
- ---
2
- name: harnex-chain
3
- description: End-to-end workflow from issue to shipped plans via harnex agents. Covers mapping, plan extraction, and the serial plan -> review -> implement -> review -> fix loop.
4
- ---
5
-
6
- # Chain Implement
7
-
8
- Take an issue from design through to shipped code via harnex agents. This
9
- skill defines chain semantics (phase order, quality gates, escalation), while
10
- spawn/watch/stop mechanics come from `harnex-dispatch`.
11
-
12
- For naming (`--tmux <same-as-id>`) and worktree operational rules, use
13
- `harnex-dispatch`.
14
-
15
- ## Orchestrator Role
16
-
17
- - Claude is the orchestrator only: dispatches sessions, watches progress,
18
- decides stop/resume/escalate, and enforces phase gates.
19
- - Codex performs all production work: plan writing, plan reviews,
20
- implementation, code reviews, and fixes.
21
- - The orchestrator does not implement or review directly except emergency
22
- intervention to recover a blocked chain.
23
-
24
- ## Guiding Principle
25
-
26
- Keep each agent invocation inside its safe context zone (< 40% of context
27
- window). Large issues should be split into smaller plans so each worker has a
28
- narrow, testable scope.
29
-
30
- Scale to the issue size:
31
- - Small issue: skip mapping, one plan, one serial loop.
32
- - Medium issue: one phased plan is usually enough.
33
- - Large issue: mapping plus extracted thin-layer plans.
34
-
35
- ## Workflow Overview (Serial Default)
36
-
37
- ```
38
- Issue (user + orchestrator chat)
39
-
40
- [Mapping Plan] -> [Map Review] -> [Fix Map] <- optional for large scope
41
-
42
- [Plan Extraction] -> thin-layer plans <- optional if one plan suffices
43
-
44
- Per plan (serial on main):
45
- Plan -> Plan Review -> Fix Plan
46
- -> Implement -> Code Review -> Fix Code
47
- -> Commit -> next plan
48
- ```
49
-
50
- The serial loop is the default path. For each step, use `harnex-dispatch`
51
- Fire & Watch for lifecycle operations and stop-after-commit timing.
52
-
53
- ## Phase 1: Issue
54
-
55
- User and orchestrator converge on a concrete issue document
56
- (e.g., `koder/issues/NN_label/INDEX.md`) with:
57
- - Problem and motivation
58
- - Design decisions and trade-offs
59
- - Acceptance criteria
60
- - Open questions
61
-
62
- ## Phase 2: Mapping Plan (Optional)
63
-
64
- Use when scope is broad, has sequencing constraints, or still contains
65
- user-blocking questions. Skip for small, coherent issues.
66
-
67
- Outputs:
68
- - Technical map of files/functions/seams
69
- - Sequencing constraints
70
- - Explicit user-blocking questions
71
-
72
- Gate:
73
- - If map review finds user-blocking questions, stop the chain and return to
74
- user.
75
-
76
- ## Phase 3: Plan Extraction (Optional)
77
-
78
- Use when the mapping plan should be decomposed into thin-layer plans.
79
- Each extracted plan must be one independently testable capability and ordered
80
- by dependency.
81
-
82
- ## Phase 4: Serial Plan Loop (Default)
83
-
84
- Per plan:
85
- 1. Plan (Codex)
86
- 2. Plan Review (Codex)
87
- 3. Fix Plan (Codex) when review finds issues
88
- 4. Implement (Codex)
89
- 5. Code Review (Codex)
90
- 6. Fix Code (Codex) when review finds issues
91
- 7. Commit and advance to next plan
92
-
93
- Gating rules:
94
- - Do not start implementation with unresolved P1 plan-review findings.
95
- - Do not advance to the next plan with unresolved P1 code-review findings.
96
- - Keep plan-fix and code-fix loops active until the review gate passes.
97
-
98
- ## Parallel Variant
99
-
100
- Parallelism is allowed only for planning passes. Keep implementation serial
101
- on `main` unless the user explicitly requests worktrees.
102
-
103
- Approved parallel lanes:
104
- - Parallel plan-writing sessions (one plan file per Codex session)
105
- - Parallel plan-review sessions (one review file per Codex session)
106
-
107
- Capacity rule:
108
- - Run at most 5 concurrent Codex sessions total across all active lanes
109
- (global cap, not per lane).
110
-
111
- Lifecycle rule:
112
- - Use `harnex-dispatch` Fire & Watch, including poll cadence and stop timing.
113
-
114
- Implementation rule:
115
- - Serial implementation on `main` is the default.
116
- - Parallel implementation is allowed only with explicit user request and
117
- worktree isolation (see `harnex-dispatch` worktree guidance).
118
-
119
- ## Unattended Monitoring
120
-
121
- For overnight, unattended, or >30-minute steps, use `harnex-buddy`.
122
- Buddy activation criteria, monitoring loop (poll/stall/nudge), return channel
123
- via `$HARNEX_SPAWNER_PANE`, and buddy cleanup are canonical in
124
- `harnex-buddy`.
125
-
126
- ## Failure and Escalation
127
-
128
- - User-blocking question in plan/map review: stop and ask user; do not guess.
129
- - Review returns P1: dispatch the corresponding fix step and re-review.
130
- - Implementation diverges materially from plan: stop and re-plan.
131
- - Worker is stuck or blocked by prompt/dialog: intervene, then continue with a
132
- fresh worker if needed.
@@ -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