@welluable/orch 1.0.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.
package/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # orch
2
+
3
+ **The local multi-agent coding pipeline.**
4
+
5
+ A CLI that turns a task description into staged, verified, committed code —
6
+ without you babysitting a single long-lived agent session.
7
+
8
+ Long agent sessions tend to blur research, planning, and editing together in
9
+ one context, skip writing tests before implementation, and edit your working
10
+ tree directly while you watch. orch splits that into separate stages, each
11
+ run by a fresh agent process. Complex work gets its own sibling git worktree
12
+ and branch, tests or acceptance criteria are locked in before any
13
+ implementation code is written, and orch only commits once a test runner
14
+ actually passes. Small requests skip all of that ceremony and just get fixed
15
+ in place.
16
+
17
+ ```text
18
+ You: orch "add a --verbose flag that streams agent output to stderr"
19
+ orch: triage: complex — staging a worktree and test loop
20
+ orch: [test-writer 1/5] wrote 3 cases covering the new flag
21
+ orch: [code-writer 2/5] implemented the flag; tests pass
22
+ orch: commit: a1b2c3d on orch/verbose-flag-x7q2
23
+ ```
24
+
25
+ ## Why orch?
26
+
27
+ - **Triage respects small work.** A one-line typo fix doesn't get a worktree,
28
+ a test-writer, or a five-round loop — triage routes it straight to a
29
+ `quick-fix` agent editing your current tree.
30
+ - **Verify before you implement.** Tests or acceptance criteria are written
31
+ and frozen before any implementation code exists, so "done" means "passes
32
+ the check," not "the agent said so."
33
+ - **Isolated implementation.** Complex tasks run in a persistent sibling git
34
+ worktree on an `orch/<slug>` branch, so your working tree stays untouched
35
+ until you decide to merge.
36
+ - **Agent-agnostic backends.** Pick the CLI you already trust with
37
+ `--agent cursor|claude|agn` — orch owns the pipeline, the agent CLI does
38
+ the reading and writing.
39
+ - **Readable runs.** Every stage prints a one-paragraph natural-language
40
+ summary of what it did; add `-v` if you also want the raw thinking/output
41
+ deltas.
42
+ - **Escape hatches when you don't need the pipeline.** `--ask` for a
43
+ read-only question, `--quick` for a direct edit — both skip triage and
44
+ artifacts entirely.
45
+
46
+ ## Quick Start
47
+
48
+ ```bash
49
+ npm install -g @welluable/orch
50
+ ```
51
+
52
+ Make sure an agent CLI is on your `PATH` — orch defaults to `--agent cursor`
53
+ (the Cursor Agent CLI, command `agent`); `claude` and `agn` are also
54
+ supported. See [Requirements](#requirements) for details.
55
+
56
+ ```bash
57
+ orch "fix the typo in the README"
58
+ ```
59
+
60
+ That one command triages the request, and — because it's small — fixes it
61
+ directly in your current directory. For anything larger, orch will stage a
62
+ worktree and walk through the phases below automatically.
63
+
64
+ ## How it works
65
+
66
+ Every run starts at triage, which decides how much ceremony the task needs.
67
+ From there, either a short path or the full phase sequence runs.
68
+
69
+ ### Phases
70
+
71
+ | Phase | What happens |
72
+ | --- | --- |
73
+ | Triage | Classifies the task as a quick fix or complex work needing the full pipeline. |
74
+ | Quick-fix | A single agent edits the current working tree directly; no artifacts, no worktree. |
75
+ | Research | Reads the codebase and invocation-directory context, writes `research.md`. |
76
+ | Plan | Turns research into a concrete task checklist, writes `task.md`. |
77
+ | Worktree | Creates a sibling git worktree and an `orch/<slug>` branch for isolated implementation. |
78
+ | Test loop | `test-writer` ⇄ `test-critic` iterate until tests/acceptance criteria are frozen. |
79
+ | Code loop | `code-writer` ⇄ `test-runner` iterate until the runner passes. |
80
+ | Commit | Commits the passing state on the run's branch inside the worktree. |
81
+
82
+ `--ask`, `--quick`, and `--dry-run` are alternate entry paths that bypass some
83
+ or all of this table — see [Execution modes](#execution-modes).
84
+
85
+ ### Triage and short paths
86
+
87
+ Triage looks at the task text and decides whether it's a small, safe change
88
+ or something that needs the full pipeline. Small changes route to a
89
+ `quick-fix` agent that edits your current working tree directly — no
90
+ artifacts, no worktree, no fix plan. `--quick` forces this same direct-edit
91
+ path without asking triage first. `--ask` is separate again: it skips triage
92
+ entirely and every write pipeline, spawning one read-only agent that answers
93
+ your question and prints the reply.
94
+
95
+ ### Verification loops
96
+
97
+ Once a run reaches the worktree, two writer⇄critic loops gate the work in
98
+ sequence:
99
+
100
+ ```text
101
+ test-writer ──┐
102
+ ├──⇄── test-critic ──► tests frozen
103
+ (iterate up to --max-rounds)
104
+
105
+ code-writer ──┐
106
+ ├──⇄── test-runner ──► commit (on pass)
107
+ (iterate up to --max-rounds)
108
+ ```
109
+
110
+ orch owns the retries and the pass/fail gating itself — each round runs in a
111
+ fresh agent process, so no stage inherits stale context from a previous
112
+ attempt. If a loop exhausts `--max-rounds` (default 5) without passing, orch
113
+ exits non-zero and leaves the worktree and `status.md` in place so you can
114
+ inspect exactly what was tried.
115
+
116
+ ### Artifacts and worktrees
117
+
118
+ Complex tasks get one randomly named run directory under the directory where
119
+ you invoked `orch`, plus a persistent sibling git worktree and branch:
120
+
121
+ ```text
122
+ <invocation-cwd>/.orch/<slug>/
123
+ research.md
124
+ task.md
125
+ status.md
126
+
127
+ <parent-of-repo>/<repo-name>-<slug> # worktree
128
+ orch/<slug> # branch
129
+ ```
130
+
131
+ `research` and `planner` run in your invocation directory and write to the
132
+ paths above. Implementer stages (test-writer, test-critic, code-writer,
133
+ test-runner) run inside the worktree instead. The worktree is never deleted
134
+ automatically — it's left in place after the run so you can inspect,
135
+ continue, or merge the work whenever you're ready.
136
+
137
+ ## Architecture
138
+
139
+ ```text
140
+ ┌────────────┐ ┌──────────────────────┐ ┌────────────────────┐
141
+ │ orch CLI │ ──► │ stages (triage, │ ──► │ git worktree + │
142
+ │ (Commander)│ │ research, plan, │ │ orch/<slug> branch │
143
+ │ │ │ test/code loops) │ │ (implementation) │
144
+ └────────────┘ └──────────┬───────────┘ └────────────────────┘
145
+
146
+
147
+ ┌──────────────────────┐
148
+ │ agent backend adapter │
149
+ │ (cursor / claude / agn)│
150
+ └──────────────────────┘
151
+ ```
152
+
153
+ orch owns the orchestration, staging, and pass/fail gating; the selected
154
+ agent CLI does all the actual reading and writing of files.
155
+
156
+ ## Execution modes
157
+
158
+ | Mode | Behavior | Use when |
159
+ | --- | --- | --- |
160
+ | Default | Full triage → (quick-fix or research/plan/worktree/test-loop/code-loop/commit) pipeline. | You want orch to decide the right amount of ceremony. |
161
+ | `--quick` | Skips triage, runs `quick-fix` directly in the current tree; no artifacts, worktree, or commits. | You already know it's a small, direct edit. |
162
+ | `--ask` | Skips triage and all write pipelines; one read-only agent answers and orch prints the reply. | You want an answer about the codebase, not a change. |
163
+ | `--dry-run` | Checks the selected agent CLI is on `PATH` and exits without running the pipeline. | You want to sanity-check your setup before a real run. |
164
+
165
+ For `--ask`, Cursor uses `--mode ask`, Claude uses `--permission-mode plan`,
166
+ and `agn` is prompt-only best-effort (it has no dedicated read-only flag).
167
+
168
+ ## CLI Reference
169
+
170
+ ```text
171
+ Usage: orch [options] <task...>
172
+ ```
173
+
174
+ - `<task...>` — task description to use as the prompt (mention a file path
175
+ and the agent will read it with its own tools).
176
+ - `-V, --version` — outputs the version number.
177
+ - `-v, --verbose` — streams agent thinking/output deltas to stderr as the
178
+ pipeline runs.
179
+ - `--dry-run` — checks that the selected agent CLI is on `PATH` and exits
180
+ without running the pipeline.
181
+ - `--ask` — asks a read-only question about the codebase; prints the reply
182
+ and exits (skips triage and all write pipelines).
183
+ - `--quick` — skips triage, runs `quick-fix` directly in the current working
184
+ tree; creates no artifacts, worktrees, or commits.
185
+ - `--max-rounds <n>` — max writer⇄critic and writer⇄runner iterations per
186
+ implementer loop; defaults to `5`, ignored with `--ask` and `--quick`.
187
+ - `--agent <cursor|claude|agn>` — selects the backend for the whole pipeline;
188
+ defaults to `cursor`.
189
+ - `-h, --help` — displays help for the command.
190
+
191
+ Examples:
192
+
193
+ ```bash
194
+ orch "fix the typo in the README" --agent claude
195
+ orch "fix the bug described in task.md" --agent cursor -v
196
+ orch "implement the local spec" --agent agn -v
197
+ orch --ask "where is the CLI entrypoint?" --agent claude
198
+ orch --quick "fix the typo in the README" --agent claude
199
+ orch "noop" --dry-run --agent cursor
200
+ ```
201
+
202
+ ## Project structure
203
+
204
+ Complex runs create a run directory and a sibling worktree, reusing the
205
+ layout shown in [Artifacts and worktrees](#artifacts-and-worktrees):
206
+
207
+ ```text
208
+ <invocation-cwd>/.orch/<slug>/
209
+ research.md
210
+ task.md
211
+ status.md
212
+
213
+ <parent-of-repo>/<repo-name>-<slug> # worktree
214
+ orch/<slug> # branch
215
+ ```
216
+
217
+ Default quick fixes, `--quick`, and `--ask` runs create none of this — no
218
+ `.orch/` directory, no worktree, and no commits.
219
+
220
+ ## Interrupts
221
+
222
+ `SIGINT`, `SIGHUP`, and `SIGTERM` reap every detached agent process group and
223
+ exit with the usual shell statuses (130 / 129 / 143). `SIGKILL` skips signal
224
+ handlers entirely and can leave orphaned agent processes behind — clean up
225
+ manually if that happens:
226
+
227
+ ```bash
228
+ pkill -f 'agent -p' # --agent cursor
229
+ pkill -f 'claude ' # --agent claude, adjust to local argv
230
+ pkill -f 'agn ' # --agent agn
231
+ ```
232
+
233
+ ## Agent compatibility
234
+
235
+ | Backend | `--agent` value | Status | Notes |
236
+ | --- | --- | --- | --- |
237
+ | Cursor Agent CLI | `cursor` | Supported (default) | Command `agent` on `PATH`. |
238
+ | Claude Code CLI | `claude` | Supported | Command `claude` on `PATH`. |
239
+ | agn | `agn` | Supported | Requires `npm install -g @welluable/agn-cli` (`>= 0.0.12`) and `agn init`. |
240
+
241
+ ## Requirements
242
+
243
+ - A modern Node.js runtime.
244
+ - One supported agent CLI on your `PATH`: `agent` (Cursor), `claude` (Claude
245
+ Code), or `agn`.
246
+ - Git, for any run that isn't `--ask` or `--quick` (worktrees and commits
247
+ need it).
248
+
249
+ ## Development
250
+
251
+ ```bash
252
+ git clone git@github.com:Welluable/orch.git
253
+ cd orch
254
+ npm install
255
+ npm link # optional: orch on PATH from this checkout
256
+ npm test
257
+ ```
258
+
259
+ `npm run docs` re-runs orch itself in `--quick` mode to keep this README and
260
+ `orch --help` in sync with the current CLI.
261
+
262
+ ## License
263
+
264
+ ISC
package/agents/ask.js ADDED
@@ -0,0 +1,22 @@
1
+ export function askAgentArgs({ prompt, cwd }) {
2
+ return {
3
+ name: 'ask',
4
+ instructions: `
5
+ You are an Ask Agent.
6
+
7
+ * Answer the user's question about the codebase.
8
+ * This is read-only: do not edit files, write orch artifacts under .orch/,
9
+ or create worktrees.
10
+ * Put the full answer in your final message.
11
+ * Before the summary marker below, your message should only have the
12
+ answer, no other text.
13
+ * After the answer above, on a new line write the summary marker (three
14
+ '<' characters, then SUMMARY, then three '>' characters, with no
15
+ spaces), followed by one paragraph in natural, human-readable language
16
+ explaining what you did in this step and what happened — no lists, no
17
+ headers, just prose.
18
+ `,
19
+ prompt,
20
+ options: { cwd, readOnly: true },
21
+ };
22
+ }
@@ -0,0 +1,55 @@
1
+ export function codeWriterAgentArgs({
2
+ prompt,
3
+ cwd,
4
+ worktreePath,
5
+ branch,
6
+ taskPath,
7
+ statusPath,
8
+ round,
9
+ acceptedVerification,
10
+ runnerFeedback,
11
+ }) {
12
+ const feedbackBlock =
13
+ round === 1
14
+ ? `
15
+ [Accepted Verification]
16
+ ${acceptedVerification}
17
+ [/Accepted Verification]
18
+ `
19
+ : `
20
+ [Test Runner Feedback]
21
+ ${runnerFeedback}
22
+ [/Test Runner Feedback]
23
+ `;
24
+
25
+ return {
26
+ instructions: `
27
+ You are a Code Writer Agent.
28
+
29
+ * You are already running inside the git worktree for this task
30
+ (worktree: ${worktreePath}, branch: ${branch}). Do not
31
+ create, select, or switch worktrees or branches.
32
+ * Read the task checklist at the exact path: ${taskPath} and the
33
+ current status at the exact path: ${statusPath}
34
+ * Implement the steps in the task checklist against the frozen verification
35
+ from the test loop.
36
+ * Keep the exact status file at ${statusPath} updated as steps
37
+ complete.
38
+ * Do not run the test suite as a gate — that is the test-runner's job. Do not
39
+ delete or weaken tests just to force a green run.
40
+ * If only verification criteria exist, implement so those criteria are met, and
41
+ note that in the status file.
42
+ * Do not run \`git add\`, \`git commit\`, or any other git branch/commit
43
+ command. Leave changes unstaged — orch commits after the pipeline finishes.
44
+ * Once implementation is done, the task is complete.
45
+ * After your final message above, on a new line write the summary
46
+ marker (three '<' characters, then SUMMARY, then three '>'
47
+ characters, with no spaces), followed by one paragraph in natural,
48
+ human-readable language explaining what you did in this step and
49
+ what happened — no lists, no headers, just prose.
50
+ ${feedbackBlock}
51
+ `,
52
+ prompt,
53
+ options: { cwd },
54
+ };
55
+ }
@@ -0,0 +1,9 @@
1
+ export { askAgentArgs } from './ask.js';
2
+ export { triageAgentArgs } from './triage.js';
3
+ export { quickFixAgentArgs } from './quick-fix.js';
4
+ export { researchAgentArgs } from './research.js';
5
+ export { plannerAgentArgs } from './planner.js';
6
+ export { testWriterAgentArgs } from './test-writer.js';
7
+ export { testCriticAgentArgs } from './test-critic.js';
8
+ export { codeWriterAgentArgs } from './code-writer.js';
9
+ export { testRunnerAgentArgs } from './test-runner.js';
@@ -0,0 +1,26 @@
1
+ export function plannerAgentArgs({ prompt, cwd, researchPath, taskPath, researchOutput }) {
2
+ return {
3
+ name: 'planner',
4
+ instructions: `
5
+ You are a Planner Agent.
6
+
7
+ * Read the research doc at the exact path: ${researchPath}
8
+ * Plan the steps to accomplish the user's request.
9
+ * Write a checklist of the steps to accomplish the user's request only to
10
+ the exact path: ${taskPath}
11
+ * Before the summary marker below, your message must contain only the
12
+ exact path: ${taskPath}
13
+ * After the path above, on a new line write the summary marker (three
14
+ '<' characters, then SUMMARY, then three '>' characters, with no
15
+ spaces), followed by one paragraph in natural, human-readable language
16
+ explaining what you did in this step and what happened — no lists, no
17
+ headers, just prose.
18
+
19
+ [Research Agent Output]
20
+ ${researchOutput}
21
+ [/Research Agent Output]
22
+ `,
23
+ prompt,
24
+ options: { cwd },
25
+ };
26
+ }
@@ -0,0 +1,30 @@
1
+ export function quickFixAgentArgs({ prompt, cwd, fix_plan }) {
2
+ const fixPlan = fix_plan
3
+ ? `
4
+ [Triage Fix Plan]
5
+ ${fix_plan}
6
+ [/Triage Fix Plan]
7
+ `
8
+ : '';
9
+
10
+ return {
11
+ name: 'quick-fix',
12
+ instructions: `
13
+ You are a Quick Fix Agent.
14
+
15
+ * Treat the user prompt as the full task description.
16
+ * Make the smallest set of edits necessary to complete the request.
17
+ * Apply changes in the current working tree.
18
+ * Do not write research.md or task.md.
19
+ * Do not create a git worktree.
20
+ * After your final message above, on a new line write the summary
21
+ marker (three '<' characters, then SUMMARY, then three '>'
22
+ characters, with no spaces), followed by one paragraph in
23
+ natural, human-readable language explaining what you did in this
24
+ step and what happened — no lists, no headers, just prose.
25
+ ${fixPlan}
26
+ `,
27
+ prompt,
28
+ options: { cwd },
29
+ };
30
+ }
@@ -0,0 +1,23 @@
1
+ export function researchAgentArgs({ prompt, cwd, researchPath }) {
2
+ return {
3
+ name: 'research',
4
+ instructions: `
5
+ You are a Research Agent.
6
+
7
+ * Research the codebase rooted at ${cwd} for the relevant
8
+ information to accomplish the user's request.
9
+ * Don't plan just research.
10
+ * Do not write any code. After the research is complete, write your
11
+ findings only to the exact path: ${researchPath}
12
+ * Before the summary marker below, your message must contain only the
13
+ exact path: ${researchPath}
14
+ * After the path above, on a new line write the summary marker (three
15
+ '<' characters, then SUMMARY, then three '>' characters, with no
16
+ spaces), followed by one paragraph in natural, human-readable language
17
+ explaining what you did in this step and what happened — no lists, no
18
+ headers, just prose.
19
+ `,
20
+ prompt,
21
+ options: { cwd },
22
+ };
23
+ }
@@ -0,0 +1,40 @@
1
+ export function testCriticAgentArgs({
2
+ prompt,
3
+ cwd,
4
+ worktreePath,
5
+ branch,
6
+ taskPath,
7
+ statusPath,
8
+ testWriterOutput,
9
+ }) {
10
+ return {
11
+ instructions: `
12
+ You are a Test Critic Agent.
13
+
14
+ * You are already running inside the git worktree for this task
15
+ (worktree: ${worktreePath}, branch: ${branch}). Do not
16
+ create, select, or switch worktrees or branches.
17
+ * Read the task checklist at the exact path: ${taskPath} and the
18
+ status at the exact path: ${statusPath}
19
+ * Judge whether the current tests / "## Verification" section are adequate
20
+ for the task checklist intent (coverage of requirements, not merely that
21
+ files exist).
22
+ * Do not edit production code or rewrite tests. Feedback only.
23
+ * Your final message MUST include a JSON verdict:
24
+ {"passed": true|false, "summary": "short reason", "failures": ["optional"]}
25
+ * Set passed: true only when verification is adequate to freeze for implementation.
26
+ * After the JSON above, on a new line write the summary marker (three
27
+ '<' characters, then SUMMARY, then three '>' characters, with no
28
+ spaces), followed by one paragraph in natural, human-readable language
29
+ explaining what you did in this step and what happened — no lists, no
30
+ headers, just prose. The JSON itself must stay exactly as specified
31
+ above, before the summary marker.
32
+
33
+ [Test Writer Output]
34
+ ${testWriterOutput}
35
+ [/Test Writer Output]
36
+ `,
37
+ prompt,
38
+ options: { cwd },
39
+ };
40
+ }
@@ -0,0 +1,39 @@
1
+ export function testRunnerAgentArgs({
2
+ prompt,
3
+ cwd,
4
+ worktreePath,
5
+ branch,
6
+ statusPath,
7
+ codeWriterOutput,
8
+ }) {
9
+ return {
10
+ instructions: `
11
+ You are a Test Runner Agent.
12
+
13
+ * You are already running inside the git worktree for this task
14
+ (worktree: ${worktreePath}, branch: ${branch}). Do not
15
+ create, select, or switch worktrees or branches.
16
+ * Read the status at the exact path: ${statusPath} and prior stage
17
+ output for the test command(s) to run.
18
+ * If a runnable command is recorded, run it and report the outcome.
19
+ * If only a "## Verification" section exists, evaluate the current diff against
20
+ those criteria by inspection.
21
+ * Do not edit production code or tests. Report only.
22
+ * Your final message MUST include a JSON verdict:
23
+ {"passed": true|false, "summary": "short reason", "failures": ["optional"]}
24
+ * Set passed: true only when the verification gate is green.
25
+ * After the JSON above, on a new line write the summary marker (three
26
+ '<' characters, then SUMMARY, then three '>' characters, with no
27
+ spaces), followed by one paragraph in natural, human-readable language
28
+ explaining what you did in this step and what happened — no lists, no
29
+ headers, just prose. The JSON itself must stay exactly as specified
30
+ above, before the summary marker.
31
+
32
+ [Code Writer Output]
33
+ ${codeWriterOutput}
34
+ [/Code Writer Output]
35
+ `,
36
+ prompt,
37
+ options: { cwd },
38
+ };
39
+ }
@@ -0,0 +1,50 @@
1
+ export function testWriterAgentArgs({
2
+ prompt,
3
+ cwd,
4
+ worktreePath,
5
+ branch,
6
+ taskPath,
7
+ statusPath,
8
+ criticFeedback,
9
+ }) {
10
+ const criticBlock = criticFeedback
11
+ ? `
12
+ [Test Critic Feedback]
13
+ ${criticFeedback}
14
+ [/Test Critic Feedback]
15
+ `
16
+ : '';
17
+
18
+ return {
19
+ instructions: `
20
+ You are a Test Writer Agent.
21
+
22
+ * You are already running inside the git worktree for this task
23
+ (worktree: ${worktreePath}, branch: ${branch}). Do not
24
+ create, select, or switch worktrees or branches.
25
+ * Read the task checklist at the exact path: ${taskPath}
26
+ * Before making any production-code changes, decide how to verify the work:
27
+ - If automated tests are practical, write the relevant test cases/files first,
28
+ extending the existing test runner and conventions.
29
+ - If automated tests are not practical, update the exact status file at
30
+ ${statusPath} with a "## Verification" section describing what
31
+ a human or later reviewer should check in the diff. Do not invent a fake
32
+ test harness.
33
+ * Do not implement the feature/fix itself in this stage — tests and criteria only.
34
+ * Update the exact status file at: ${statusPath}
35
+ * Do not run \`git add\`, \`git commit\`, or any other git branch/commit
36
+ command. Leave changes unstaged — orch commits after the pipeline finishes.
37
+ * Your final message must include test file paths / run command, if
38
+ applicable, so it can be handed to the next stage.
39
+ * Later rounds must address critic feedback; do not write production code.
40
+ * After your final message above, on a new line write the summary
41
+ marker (three '<' characters, then SUMMARY, then three '>'
42
+ characters, with no spaces), followed by one paragraph in natural,
43
+ human-readable language explaining what you did in this step and
44
+ what happened — no lists, no headers, just prose.
45
+ ${criticBlock}
46
+ `,
47
+ prompt,
48
+ options: { cwd },
49
+ };
50
+ }
@@ -0,0 +1,31 @@
1
+ export function triageAgentArgs({ prompt, cwd }) {
2
+ return {
3
+ name: 'triage',
4
+ instructions: `
5
+ You are a Triage Agent.
6
+
7
+ Decide if the user's request is a safe minimal fix (typo, small flag tweak,
8
+ implement an already-written local spec, one-file change, etc.).
9
+
10
+ Your final message MUST be valid JSON only — no markdown, no prose outside JSON:
11
+
12
+ {
13
+ "simple": true,
14
+ "why": "short reason",
15
+ "fix_plan": "optional short plan (1-5 bullets or a paragraph)"
16
+ }
17
+
18
+ Set "simple": true only when a quick fix in the current working tree is enough.
19
+ Set "simple": false when research, planning, or a worktree is needed.
20
+
21
+ After the JSON above, on a new line write the summary marker (three
22
+ '<' characters, then SUMMARY, then three '>' characters, with no
23
+ spaces), followed by one paragraph in natural, human-readable language
24
+ explaining what you did in this step and what happened — no lists, no
25
+ headers, just prose. The JSON itself must stay exactly as specified
26
+ above, before the summary marker.
27
+ `,
28
+ prompt,
29
+ options: { cwd },
30
+ };
31
+ }
@@ -0,0 +1,57 @@
1
+ import { Agent } from './agent.js';
2
+ import { normalizeAgnToolEvent } from './tool-status.js';
3
+
4
+ export class AgentAgn extends Agent {
5
+ getSpawnConfig(promptToSend) {
6
+ return {
7
+ command: 'agn',
8
+ args: ['-p', '--output-format', 'stream-json', promptToSend],
9
+ options: {
10
+ cwd: this.cwd,
11
+ stdio: ['ignore', 'pipe', 'pipe'],
12
+ env: process.env,
13
+ },
14
+ };
15
+ }
16
+
17
+ handleStreamEvent(event, { verbose, finish }) {
18
+ switch (event.type) {
19
+ case 'system': {
20
+ if (event.subtype === 'init') {
21
+ this.setStatus('connected');
22
+ }
23
+ break;
24
+ }
25
+ case 'assistant': {
26
+ if (event.subtype === 'delta') {
27
+ if (verbose) {
28
+ process.stderr.write(event.text ?? '');
29
+ } else if (this.activeTools.size === 0) {
30
+ this.setStatus('thinking…');
31
+ }
32
+ } else if (this.activeTools.size === 0) {
33
+ this.setStatus('composing response…');
34
+ }
35
+ break;
36
+ }
37
+ case 'tool_call': {
38
+ const toolEvent = normalizeAgnToolEvent(event);
39
+ if (toolEvent) this.onToolEvent(toolEvent);
40
+ break;
41
+ }
42
+ case 'result': {
43
+ this.settleResult(
44
+ {
45
+ ...event,
46
+ result: event.result ?? event.error ?? '',
47
+ is_error: event.subtype !== 'success',
48
+ },
49
+ finish,
50
+ );
51
+ break;
52
+ }
53
+ default:
54
+ break;
55
+ }
56
+ }
57
+ }