gnhf 0.1.26 → 0.1.28

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.
Files changed (3) hide show
  1. package/README.md +55 -26
  2. package/dist/cli.mjs +789 -69
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -44,10 +44,10 @@ Never wake up empty-handed.
44
44
  gnhf is a [ralph](https://ghuntley.com/ralph/), [autoresearch](https://github.com/karpathy/autoresearch)-style orchestrator that keeps your agents running while you sleep — each iteration makes one small, committed, documented change towards an objective.
45
45
  You wake up to a branch full of clean work and a log of everything that happened.
46
46
 
47
- - **Dead simple** — one command starts an autonomous loop that runs until you Ctrl+C or a configured runtime cap is reached
48
- - **Long running** — each iteration is committed on success, rolled back on failure, with sensible retries; hard agent errors back off exponentially while agent-reported failures continue immediately
47
+ - **Dead simple** — one command starts an autonomous loop that runs until you request stop or a configured runtime cap is reached
48
+ - **Long running** — each iteration is committed on success, rolled back on failure, with sensible retries; retryable hard agent errors back off exponentially while agent-reported failures continue immediately
49
49
  - **Live terminal title** — interactive runs keep your terminal title updated with live status, token totals, and commit count, then restore the previous title on exit
50
- - **Agent-agnostic** works with Claude Code, Codex, Rovo Dev, or OpenCode out of the box
50
+ - **Agent-agnostic**: works with Claude Code, Codex, Rovo Dev, OpenCode, GitHub Copilot CLI, or Pi out of the box
51
51
 
52
52
  ## Quick Start
53
53
 
@@ -129,16 +129,19 @@ npm link
129
129
  ▼ ▼ │
130
130
  ┌────────────┐ yes ┌──────────┐ │
131
131
  │ 3 consec. ├─────────►│ abort │ │
132
- │ failures? └──────────┘
132
+ │ failures └────▲─────┘
133
+ │ or perm. ├───────────────┘ │
134
+ │ error? │ │
133
135
  └─────┬──────┘ │
134
136
  no │ │
135
137
  └──────────────────────────────────────┘
136
138
  ```
137
139
 
138
140
  - **Incremental commits** — each successful iteration is a separate git commit, so you can cherry-pick or revert individual changes
139
- - **Failure handling** - all failed iterations are rolled back with `git reset --hard`; agent-reported failures proceed to the next iteration immediately, while hard agent errors use exponential backoff
140
- - **Runtime caps** - `--max-iterations` stops before the next iteration begins, `--max-tokens` can abort mid-iteration once reported usage reaches the cap, and `--stop-when` ends the loop after an iteration whose agent output reports the natural-language condition is met; uncommitted work is rolled back in either case, and in the interactive TUI the final state remains visible until you press Ctrl+C to exit
141
+ - **Failure handling** - all failed iterations are rolled back with `git reset --hard`; agent-reported failures proceed to the next iteration immediately, retryable hard agent errors use exponential backoff, and permanent agent errors such as Claude low credit balance abort immediately and print the run log path
142
+ - **Runtime caps** - `--max-iterations` stops before the next iteration begins, `--max-tokens` can abort mid-iteration once reported usage reaches the cap, and `--stop-when` ends the loop after an iteration whose agent output reports the natural-language condition is met; resumed runs reuse the saved stop condition unless you pass a new value, or `--stop-when ""` to clear it; uncommitted work is rolled back in either case, and in the interactive TUI the final state remains visible until you press Ctrl+C to exit
141
143
  - **Iteration finalization** - agents are expected to finish validation, stop any background processes they started, and only then emit the final JSON result for the iteration
144
+ - **Graceful interrupts** - in the interactive TUI, the first Ctrl+C requests a graceful stop and lets the current iteration finish (or ends backoff early), the second Ctrl+C force-stops immediately, and `SIGTERM` also force-stops immediately
142
145
  - **Shared memory** — the agent reads `notes.md` (built up from prior iterations) to communicate across iterations
143
146
  - **Local run metadata** — gnhf stores prompt, notes, and resume metadata under `.gnhf/runs/` and ignores it locally, so your branch only contains intentional work
144
147
  - **Resume support** — run `gnhf` while on an existing `gnhf/` branch to pick up where a previous run left off; if you provide a different prompt, gnhf asks whether to update the saved prompt and continue with the existing history, start a new branch, or quit
@@ -171,28 +174,30 @@ If you run `gnhf` on an existing `gnhf/` branch with a different prompt, gnhf as
171
174
 
172
175
  ### Flags
173
176
 
174
- | Flag | Description | Default |
175
- | ------------------------ | -------------------------------------------------------------------------- | ---------------------- |
176
- | `--agent <agent>` | Agent to use (`claude`, `codex`, `rovodev`, or `opencode`) | config file (`claude`) |
177
- | `--max-iterations <n>` | Abort after `n` total iterations | unlimited |
178
- | `--max-tokens <n>` | Abort after `n` total input+output tokens | unlimited |
179
- | `--stop-when <cond>` | End the loop when the agent reports this natural-language condition is met | unlimited |
180
- | `--prevent-sleep <mode>` | Prevent system sleep during the run (`on`/`off` or `true`/`false`) | config file (`on`) |
181
- | `--worktree` | Run in a separate git worktree (enables multiple agents concurrently) | `false` |
182
- | `--version` | Show version | |
177
+ | Flag | Description | Default |
178
+ | ------------------------ | --------------------------------------------------------------------------- | ---------------------- |
179
+ | `--agent <agent>` | Agent to use (`claude`, `codex`, `rovodev`, `opencode`, `copilot`, or `pi`) | config file (`claude`) |
180
+ | `--max-iterations <n>` | Abort after `n` total iterations | unlimited |
181
+ | `--max-tokens <n>` | Abort after `n` total input+output tokens | unlimited |
182
+ | `--stop-when <cond>` | End the loop when the agent reports this condition; persists across resume | unlimited |
183
+ | `--prevent-sleep <mode>` | Prevent system sleep during the run (`on`/`off` or `true`/`false`) | config file (`on`) |
184
+ | `--worktree` | Run in a separate git worktree (enables multiple agents concurrently) | `false` |
185
+ | `--version` | Show version | |
183
186
 
184
187
  ## Configuration
185
188
 
186
189
  Config lives at `~/.gnhf/config.yml`:
187
190
 
188
191
  ```yaml
189
- # Agent to use by default (claude, codex, rovodev, or opencode)
192
+ # Agent to use by default (claude, codex, rovodev, opencode, copilot, or pi)
190
193
  agent: claude
191
194
 
192
195
  # Custom paths to agent binaries (optional)
193
196
  # agentPathOverride:
194
197
  # claude: /path/to/custom-claude
195
198
  # codex: /path/to/custom-codex
199
+ # copilot: /path/to/custom-copilot
200
+ # pi: /path/to/custom-pi
196
201
 
197
202
  # Per-agent CLI arg overrides (optional)
198
203
  # agentArgsOverride:
@@ -202,6 +207,16 @@ agent: claude
202
207
  # - -c
203
208
  # - model_reasoning_effort="high"
204
209
  # - --full-auto
210
+ # copilot:
211
+ # - --model
212
+ # - gpt-5.4
213
+ # pi:
214
+ # - --provider
215
+ # - openai-codex
216
+ # - --model
217
+ # - gpt-5.5
218
+ # - --thinking
219
+ # - high
205
220
 
206
221
  # Abort after this many consecutive failures
207
222
  maxConsecutiveFailures: 3
@@ -213,13 +228,13 @@ preventSleep: true
213
228
  If the file does not exist yet, `gnhf` creates it on first run using the resolved defaults.
214
229
 
215
230
  CLI flags override config file values. `--prevent-sleep` accepts `on`/`off` as well as `true`/`false`; the config file always uses a boolean.
216
- The iteration and token caps are runtime-only flags and are not persisted in `config.yml`.
231
+ The iteration and token caps are runtime-only flags and are not persisted in `config.yml`; `--stop-when` is persisted per run for resume, but not in config.
217
232
 
218
233
  `agentArgsOverride.<name>` lets you pass through extra CLI flags for any supported agent.
219
234
 
220
235
  - Use it for agent-specific options like models, profiles, or reasoning settings without adding a dedicated `gnhf` config field for each one.
221
- - For `codex` and `claude`, `gnhf` adds its usual non-interactive permission default only when you do not provide your own permission or execution-mode flag. If you set one explicitly, `gnhf` treats that as user-managed and does not add its default on top.
222
- - Flags that `gnhf` manages itself for a given agent, such as output-shaping or local-server startup flags, are rejected during config loading so you get a clear error instead of duplicate-argument ambiguity.
236
+ - For `codex`, `claude`, and `copilot`, `gnhf` adds its usual non-interactive permission default only when you do not provide your own permission or execution-mode flag. If you set one explicitly, `gnhf` treats that as user-managed and does not add its default on top.
237
+ - Flags that `gnhf` manages itself for a given agent, such as output-shaping or local-server startup flags, are rejected during config loading so you get a clear error instead of duplicate-argument ambiguity. For `pi` specifically, `--api-key` is also blocked; configure the Pi API key via Pi's own config or the environment variable it reads, not via `agentArgsOverride`.
223
238
 
224
239
  ### Custom Agent Paths
225
240
 
@@ -229,6 +244,8 @@ Use `agentPathOverride` to point any agent at a custom binary — useful for wra
229
244
  agentPathOverride:
230
245
  claude: ~/bin/claude-code-switch
231
246
  codex: /usr/local/bin/my-codex-wrapper
247
+ copilot: ~/bin/copilot-wrapper
248
+ pi: ~/bin/pi-wrapper
232
249
  ```
233
250
 
234
251
  Paths may be absolute, bare executable names already on your `PATH`, `~`-prefixed, or relative to the config directory (`~/.gnhf/`). The override replaces only the binary name; all standard arguments are preserved, so the replacement must be CLI-compatible with the original agent. On Windows, `.cmd` and `.bat` wrappers are supported, including bare names resolved from `PATH`. For `rovodev`, the override must point to an `acli`-compatible binary since gnhf invokes it as `<bin> rovodev serve ...`.
@@ -242,14 +259,16 @@ Including a snippet of `gnhf.log` is the single most useful thing you can attach
242
259
 
243
260
  ## Agents
244
261
 
245
- `gnhf` supports four agents:
262
+ `gnhf` supports six agents:
246
263
 
247
- | Agent | Flag | Requirements | Notes |
248
- | ----------- | ------------------ | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
249
- | Claude Code | `--agent claude` | Install Anthropic's `claude` CLI and sign in first. | `gnhf` invokes `claude` directly in non-interactive mode. After Claude emits a successful structured result, `gnhf` treats that result as final and shuts down any lingering Claude process tree after a short grace period. |
250
- | Codex | `--agent codex` | Install OpenAI's `codex` CLI and sign in first. | `gnhf` invokes `codex exec` directly in non-interactive mode. |
251
- | Rovo Dev | `--agent rovodev` | Install Atlassian's `acli` and authenticate it with Rovo Dev first. | `gnhf` starts a local `acli rovodev serve --disable-session-token <port>` process automatically in the repo workspace. |
252
- | OpenCode | `--agent opencode` | Install `opencode` and configure at least one usable model provider first. | `gnhf` starts a local `opencode serve --hostname 127.0.0.1 --port <port> --print-logs` process automatically, creates a per-run session, and applies a blanket allow rule so tool calls do not block on prompts. |
264
+ | Agent | Flag | Requirements | Notes |
265
+ | ------------------ | ------------------ | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
266
+ | Claude Code | `--agent claude` | Install Anthropic's `claude` CLI and sign in first. | `gnhf` invokes `claude` directly in non-interactive mode. After Claude emits a successful structured result, `gnhf` treats that result as final and shuts down any lingering Claude process tree after a short grace period. |
267
+ | Codex | `--agent codex` | Install OpenAI's `codex` CLI and sign in first. | `gnhf` invokes `codex exec` directly in non-interactive mode. |
268
+ | GitHub Copilot CLI | `--agent copilot` | Install GitHub Copilot CLI and sign in first. | `gnhf` invokes `copilot` directly in non-interactive JSONL mode. Copilot currently exposes assistant output tokens, but not full input/cache token totals; see https://github.com/github/copilot-cli/issues/1152. |
269
+ | Pi | `--agent pi` | Install the `pi` CLI and configure a usable provider/model first. | `gnhf` invokes `pi` directly in JSON mode, appends the final output schema to the prompt, and disables Pi session persistence with `--no-session`. |
270
+ | Rovo Dev | `--agent rovodev` | Install Atlassian's `acli` and authenticate it with Rovo Dev first. | `gnhf` starts a local `acli rovodev serve --disable-session-token <port>` process automatically in the repo workspace. |
271
+ | OpenCode | `--agent opencode` | Install `opencode` and configure at least one usable model provider first. | `gnhf` starts a local `opencode serve --hostname 127.0.0.1 --port <port> --print-logs` process automatically, creates a per-run session, and applies a blanket allow rule so tool calls do not block on prompts. |
253
272
 
254
273
  ## Development
255
274
 
@@ -263,3 +282,13 @@ npm run test:e2e # Build, then run end-to-end tests against the mock openc
263
282
  npm run lint # ESLint
264
283
  npm run format # Prettier
265
284
  ```
285
+
286
+ ## Star History
287
+
288
+ <a href="https://www.star-history.com/?repos=kunchenguid%2Fgnhf&type=date&legend=top-left">
289
+ <picture>
290
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=kunchenguid/gnhf&type=date&theme=dark&legend=top-left" />
291
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=kunchenguid/gnhf&type=date&legend=top-left" />
292
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=kunchenguid/gnhf&type=date&legend=top-left" />
293
+ </picture>
294
+ </a>