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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harnex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jikku Jose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-01 00:00:00.000000000 Z
11
+ date: 2026-05-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A local PTY harness that wraps terminal AI agents (Claude, Codex) and
14
14
  adds a control plane for discovery, messaging, and coordination.
@@ -19,19 +19,28 @@ executables:
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - CHANGELOG.md
22
23
  - GUIDE.md
23
24
  - LICENSE
24
25
  - README.md
25
26
  - TECHNICAL.md
26
27
  - bin/gem-push
27
28
  - bin/harnex
29
+ - guides/01_dispatch.md
30
+ - guides/02_chain.md
31
+ - guides/03_buddy.md
32
+ - guides/04_monitoring.md
33
+ - guides/05_naming.md
28
34
  - lib/harnex.rb
29
35
  - lib/harnex/adapters.rb
30
36
  - lib/harnex/adapters/base.rb
31
37
  - lib/harnex/adapters/claude.rb
32
38
  - lib/harnex/adapters/codex.rb
39
+ - lib/harnex/adapters/codex_appserver.rb
33
40
  - lib/harnex/adapters/generic.rb
34
41
  - lib/harnex/cli.rb
42
+ - lib/harnex/commands/agents_guide.rb
43
+ - lib/harnex/commands/doctor.rb
35
44
  - lib/harnex/commands/events.rb
36
45
  - lib/harnex/commands/guide.rb
37
46
  - lib/harnex/commands/logs.rb
@@ -39,7 +48,6 @@ files:
39
48
  - lib/harnex/commands/recipes.rb
40
49
  - lib/harnex/commands/run.rb
41
50
  - lib/harnex/commands/send.rb
42
- - lib/harnex/commands/skills.rb
43
51
  - lib/harnex/commands/status.rb
44
52
  - lib/harnex/commands/stop.rb
45
53
  - lib/harnex/commands/wait.rb
@@ -59,12 +67,6 @@ files:
59
67
  - recipes/01_fire_and_watch.md
60
68
  - recipes/02_chain_implement.md
61
69
  - recipes/03_buddy.md
62
- - skills/close/SKILL.md
63
- - skills/harnex-buddy/SKILL.md
64
- - skills/harnex-chain/SKILL.md
65
- - skills/harnex-dispatch/SKILL.md
66
- - skills/harnex/SKILL.md
67
- - skills/open/SKILL.md
68
70
  homepage: https://github.com/jikkuatwork/harnex
69
71
  licenses:
70
72
  - MIT
@@ -1,226 +0,0 @@
1
- require "fileutils"
2
-
3
- module Harnex
4
- class Skills
5
- SKILLS_ROOT = File.expand_path("../../../../skills", __FILE__)
6
- INSTALL_SKILLS = %w[harnex-dispatch harnex-chain harnex-buddy].freeze
7
- DEPRECATED_SKILLS = %w[harnex dispatch chain-implement].freeze
8
- SKILL_ALIASES = {
9
- "harnex" => "harnex-dispatch",
10
- "dispatch" => "harnex-dispatch",
11
- "chain-implement" => "harnex-chain"
12
- }.freeze
13
-
14
- def self.usage
15
- <<~TEXT
16
- Usage: harnex skills <subcommand> [SKILL...] [--local]
17
-
18
- Subcommands:
19
- install Install bundled skills (globally by default; optional skill names)
20
- uninstall Remove installed skills (globally by default)
21
-
22
- Options:
23
- --local Target the current repo instead of global ~/.claude/
24
-
25
- Installs: #{INSTALL_SKILLS.join(', ')}
26
- Aliases: harnex|dispatch -> harnex-dispatch, chain-implement -> harnex-chain
27
-
28
- By default, copies each skill to ~/.claude/skills/<skill>/
29
- and symlinks ~/.codex/skills/<skill> to it.
30
-
31
- With --local, copies each skill to .claude/skills/<skill>/
32
- in the current repo and symlinks .codex/skills/<skill> to it.
33
- TEXT
34
- end
35
-
36
- def initialize(argv)
37
- @argv = argv.dup
38
- end
39
-
40
- def run
41
- subcommand = @argv.shift
42
- case subcommand
43
- when "install"
44
- local, help, requested_skills = parse_args(@argv, allow_positional: true)
45
- return (puts self.class.usage; 0) if help
46
-
47
- remove_deprecated(local)
48
- install_skills = requested_skills.empty? ? INSTALL_SKILLS : canonical_skill_names(requested_skills)
49
-
50
- install_skills.each do |skill_name|
51
- skill_source = resolve_skill_source(skill_name)
52
- unless skill_source
53
- return missing_skill(skill_name)
54
- end
55
-
56
- result = local ? install_local(skill_name, skill_source) : install_global(skill_name, skill_source)
57
- return result unless result == 0
58
- end
59
- 0
60
- when "uninstall"
61
- local, help, = parse_args(@argv)
62
- return (puts self.class.usage; 0) if help
63
-
64
- (INSTALL_SKILLS + DEPRECATED_SKILLS).each do |skill_name|
65
- local ? uninstall_local(skill_name) : uninstall_global(skill_name)
66
- end
67
- 0
68
- when "-h", "--help", nil
69
- puts self.class.usage
70
- 0
71
- else
72
- warn("harnex skills: unknown subcommand #{subcommand.inspect}")
73
- puts self.class.usage
74
- 1
75
- end
76
- end
77
-
78
- private
79
-
80
- def parse_args(args, allow_positional: false)
81
- local = false
82
- help = false
83
- positional = []
84
-
85
- args.each do |arg|
86
- case arg
87
- when "--local"
88
- local = true
89
- when "-h", "--help"
90
- help = true
91
- when /\A-/
92
- raise "harnex skills: unknown option #{arg.inspect}"
93
- else
94
- if allow_positional
95
- positional << arg
96
- else
97
- warn("harnex skills: unexpected argument #{arg.inspect}")
98
- raise "harnex skills takes no positional arguments"
99
- end
100
- end
101
- end
102
-
103
- [local, help, positional]
104
- end
105
-
106
- def resolve_skill_source(skill_name)
107
- path = File.join(SKILLS_ROOT, skill_name)
108
- File.directory?(path) ? path : nil
109
- end
110
-
111
- def missing_skill(skill_name)
112
- warn("harnex skills: bundled skill #{skill_name.inspect} not found at #{SKILLS_ROOT}")
113
- 1
114
- end
115
-
116
- def remove_deprecated(local)
117
- DEPRECATED_SKILLS.each do |skill_name|
118
- local ? uninstall_local(skill_name) : uninstall_global(skill_name)
119
- end
120
- end
121
-
122
- def canonical_skill_names(skill_names)
123
- skill_names.map { |name| canonical_skill_name(name) }.uniq
124
- end
125
-
126
- def canonical_skill_name(skill_name)
127
- SKILL_ALIASES.fetch(skill_name, skill_name)
128
- end
129
-
130
- def install_local(skill_name, skill_source)
131
- repo_root = Harnex.resolve_repo_root(Dir.pwd)
132
- claude_dir = File.join(repo_root, ".claude", "skills", skill_name)
133
- codex_dir = File.join(repo_root, ".codex", "skills", skill_name)
134
-
135
- # Copy skill to .claude/skills/<skill>/
136
- if Dir.exist?(claude_dir)
137
- warn("harnex skills: #{claude_dir} already exists, overwriting")
138
- FileUtils.rm_rf(claude_dir)
139
- end
140
- FileUtils.mkdir_p(File.dirname(claude_dir))
141
- FileUtils.cp_r(skill_source, claude_dir)
142
- puts "installed #{claude_dir}"
143
-
144
- # Symlink .codex/skills/<skill> -> .claude/skills/<skill>
145
- codex_parent = File.dirname(codex_dir)
146
- FileUtils.mkdir_p(codex_parent)
147
- FileUtils.rm_rf(codex_dir) if File.exist?(codex_dir) || File.symlink?(codex_dir)
148
-
149
- # Relative symlink so it works if the repo moves
150
- relative = relative_path(from: codex_parent, to: claude_dir)
151
- File.symlink(relative, codex_dir)
152
- puts "symlinked #{codex_dir} -> #{relative}"
153
-
154
- 0
155
- end
156
-
157
- def install_global(skill_name, skill_source)
158
- claude_dir = File.expand_path("~/.claude/skills/#{skill_name}")
159
- codex_dir = File.expand_path("~/.codex/skills/#{skill_name}")
160
-
161
- # Copy skill to ~/.claude/skills/<skill>/
162
- if Dir.exist?(claude_dir)
163
- warn("harnex skills: #{claude_dir} already exists, overwriting")
164
- FileUtils.rm_rf(claude_dir)
165
- end
166
- FileUtils.mkdir_p(File.dirname(claude_dir))
167
- FileUtils.cp_r(skill_source, claude_dir)
168
- puts "installed #{claude_dir}"
169
-
170
- # Symlink ~/.codex/skills/<skill> -> ~/.claude/skills/<skill>
171
- codex_parent = File.dirname(codex_dir)
172
- FileUtils.mkdir_p(codex_parent)
173
- FileUtils.rm_rf(codex_dir) if File.exist?(codex_dir) || File.symlink?(codex_dir)
174
- File.symlink(claude_dir, codex_dir)
175
- puts "symlinked #{codex_dir} -> #{claude_dir}"
176
-
177
- 0
178
- end
179
-
180
- def uninstall_local(skill_name)
181
- repo_root = Harnex.resolve_repo_root(Dir.pwd)
182
- claude_dir = File.join(repo_root, ".claude", "skills", skill_name)
183
- codex_dir = File.join(repo_root, ".codex", "skills", skill_name)
184
-
185
- removed = false
186
- if File.exist?(codex_dir) || File.symlink?(codex_dir)
187
- FileUtils.rm_rf(codex_dir)
188
- removed = true
189
- end
190
- if File.exist?(claude_dir) || File.symlink?(claude_dir)
191
- FileUtils.rm_rf(claude_dir)
192
- removed = true
193
- end
194
- puts "removed #{skill_name}" if removed
195
- end
196
-
197
- def uninstall_global(skill_name)
198
- claude_dir = File.expand_path("~/.claude/skills/#{skill_name}")
199
- codex_dir = File.expand_path("~/.codex/skills/#{skill_name}")
200
-
201
- removed = false
202
- if File.exist?(codex_dir) || File.symlink?(codex_dir)
203
- FileUtils.rm_rf(codex_dir)
204
- removed = true
205
- end
206
- if File.exist?(claude_dir) || File.symlink?(claude_dir)
207
- FileUtils.rm_rf(claude_dir)
208
- removed = true
209
- end
210
- puts "removed #{skill_name}" if removed
211
- end
212
-
213
- def relative_path(from:, to:)
214
- from_parts = File.expand_path(from).split("/")
215
- to_parts = File.expand_path(to).split("/")
216
-
217
- # Drop common prefix
218
- while from_parts.first == to_parts.first && !from_parts.empty?
219
- from_parts.shift
220
- to_parts.shift
221
- end
222
-
223
- ([".."] * from_parts.length + to_parts).join("/")
224
- end
225
- end
226
- end
@@ -1,47 +0,0 @@
1
- ---
2
- name: close
3
- description: Close a work session in this repo — update koder/STATE.md with what changed and the next step, clean up accidental or temporary repo artifacts, and leave a clear handoff. Use when the user says "close session", "wrap up", "end session", "handoff", or invokes "/close".
4
- ---
5
-
6
- # Close Session Workflow
7
-
8
- When the user asks to wrap up or close the current session, run this sequence:
9
-
10
- ## 1. Review the session changes
11
-
12
- - Check `git status --short` and `git diff --stat`
13
- - Separate the work from this session from unrelated user changes
14
- - Do not revert unrelated changes you did not make
15
-
16
- ## 2. Update `koder/STATE.md`
17
-
18
- - Update the `Updated:` date
19
- - Add or adjust concise lines in `Current snapshot` for completed work
20
- - Update test count if it changed
21
- - Update issue or plan statuses only when work was actually completed or a new blocker was clearly discovered
22
- - Rewrite `Next step` so the next agent can resume without reconstructing context
23
-
24
- ## 3. Clean up repo artifacts
25
-
26
- - Remove temporary files, scratch notes, or mistaken tracking docs created during the session
27
- - Keep durable artifacts that are part of the intended result
28
- - If cleanup would discard ambiguous work, ask the user instead of guessing
29
-
30
- ## 4. Commit and clean the repo
31
-
32
- - Stage all session changes (code, docs, STATE.md updates) and commit with a clear message summarizing the session's work
33
- - Do NOT stage files that look like secrets, credentials, or large binaries — flag them to the user
34
- - After committing, run `git status --short` to confirm a clean working tree
35
- - If unrelated uncommitted changes remain, leave them alone — do not revert or commit work you did not produce
36
-
37
- ## 5. Verify the handoff
38
-
39
- - Run the relevant tests or verification commands if code or docs changed
40
- - Give the user a concise summary of what changed, the commit, and any remaining follow-up
41
- - The goal: the next `/open` should see a clean repo and an accurate `koder/STATE.md`
42
-
43
- ## Notes
44
-
45
- - Do NOT create or close issue docs unless the user explicitly asks
46
- - Do NOT build, install, or publish anything unless the user explicitly asks
47
- - If `koder/STATE.md` is already accurate, keep the update minimal rather than churning it
@@ -1,20 +0,0 @@
1
- ---
2
- name: harnex
3
- description: Deprecated alias for harnex-dispatch. Use harnex-dispatch for active harnex collaboration guidance.
4
- ---
5
-
6
- # Deprecated Skill Alias
7
-
8
- `harnex` is deprecated.
9
-
10
- Use `harnex-dispatch` as the canonical skill for harnex collaboration,
11
- Fire & Watch dispatching, relay handling, and return-channel discipline.
12
-
13
- If you are installing skills, use:
14
-
15
- ```bash
16
- harnex skills install harnex-dispatch
17
- ```
18
-
19
- Compatibility note: `harnex skills install harnex` remains supported and
20
- installs `harnex-dispatch`.
@@ -1,104 +0,0 @@
1
- ---
2
- name: harnex-buddy
3
- description: Spawn an accountability partner for long-running harnex sessions. Use when the user asks to run something overnight, unattended, or for any work expected to take more than 30 minutes without supervision.
4
- ---
5
-
6
- # Buddy — Accountability Partner for Long-Running Work
7
-
8
- For any long-running or unattended work, spawn a **buddy** — a second harnex
9
- agent that watches the worker and nudges it if it stalls.
10
-
11
- For plain stall recovery (force-resume on inactivity), prefer
12
- `harnex run --watch --preset impl`. Use a buddy when you need reasoning that
13
- policy checks cannot provide (doc drift, semantic checks, multi-session
14
- correlation).
15
-
16
- The buddy is an LLM, so it has intelligence for free. It reads the worker's
17
- screen, reasons about whether it's stuck, and composes a meaningful nudge.
18
-
19
- Dispatch workers via `harnex-dispatch` first. This skill owns only buddy
20
- behavior after the worker is already running.
21
-
22
- ## When to activate
23
-
24
- - User says "do this overnight" or "run this while I'm away"
25
- - Task is expected to take more than 30 minutes unattended
26
- - User explicitly asks for a buddy, accountability partner, or monitoring
27
- - User asks to "keep an eye on" a dispatched worker
28
-
29
- ## Spawn the buddy
30
-
31
- After dispatching the worker with `harnex-dispatch`, spawn a buddy alongside
32
- it. Keep ID/tmux naming consistent with `harnex-dispatch` (`--tmux` matches
33
- `--id`):
34
-
35
- ```bash
36
- # Spawn its buddy
37
- harnex run claude --id buddy-42 --tmux buddy-42
38
- ```
39
-
40
- ## Write the buddy prompt
41
-
42
- Write a task file with the watching instructions, then send it:
43
-
44
- ```bash
45
- cat > /tmp/buddy-42.md <<'EOF'
46
- You are an accountability partner for harnex session `cx-impl-42`.
47
-
48
- Your job:
49
- 1. Every 5 minutes, check on the worker:
50
- - `harnex pane --id cx-impl-42 --lines 20`
51
- - `harnex status --id cx-impl-42 --json`
52
- 2. If the worker appears stuck at a prompt for more than 10 minutes
53
- with no progress, nudge it:
54
- - `harnex send --id cx-impl-42 --message "You appear to have stalled. Continue with your current task."`
55
- 3. If the worker has exited, report back to the invoker:
56
- - `tmux send-keys -t "$HARNEX_SPAWNER_PANE" "cx-impl-42 has exited. Check results." Enter`
57
- 4. Keep watching until the worker finishes or is stopped.
58
-
59
- Do not interfere with work in progress. Only nudge when clearly stalled.
60
- EOF
61
-
62
- harnex send --id buddy-42 --message "Read and execute /tmp/buddy-42.md"
63
- ```
64
-
65
- Adjust the polling interval (5 min), stall threshold (10 min), and nudge
66
- message to match the workload.
67
-
68
- ## Return channel
69
-
70
- The buddy can reach back to the invoker (your raw Claude session) via
71
- `$HARNEX_SPAWNER_PANE` — the stable tmux pane ID set automatically by
72
- harnex at spawn time:
73
-
74
- ```bash
75
- # Read the invoker's screen
76
- tmux capture-pane -t "$HARNEX_SPAWNER_PANE" -p
77
-
78
- # Type into the invoker
79
- tmux send-keys -t "$HARNEX_SPAWNER_PANE" "worker-42 finished" Enter
80
- ```
81
-
82
- The invoker does NOT need to be a harnex session. It just needs to be in tmux.
83
-
84
- ## Naming convention
85
-
86
- Use naming from `harnex-dispatch`: set `--tmux <same-as-id>` for every
87
- session and keep the buddy ID paired with the worker step ID.
88
-
89
- ## Cleanup
90
-
91
- Stop the buddy after the worker finishes:
92
-
93
- ```bash
94
- harnex stop --id buddy-42
95
- ```
96
-
97
- ## Notes
98
-
99
- - For chain orchestration, phase gates, and the 5-concurrent parallel planning
100
- cap, see `harnex-chain`.
101
- - One buddy per worker, or one buddy watching multiple sessions
102
- - The buddy is a regular harnex session — stop, inspect, log it like any other
103
- - Tune polling and thresholds in the buddy's prompt, not in harnex config
104
- - See `recipes/03_buddy.md` for the full recipe
@@ -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.