@rcrsr/claude-code-runner 0.3.0 → 0.5.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 +131 -37
- package/dist/cli/args.d.ts +0 -3
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +74 -25
- package/dist/cli/args.js.map +1 -1
- package/dist/core/runner.d.ts +6 -2
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +31 -23
- package/dist/core/runner.js.map +1 -1
- package/dist/deaddrop/client.d.ts +23 -0
- package/dist/deaddrop/client.d.ts.map +1 -0
- package/dist/deaddrop/client.js +47 -0
- package/dist/deaddrop/client.js.map +1 -0
- package/dist/deaddrop/index.d.ts +2 -0
- package/dist/deaddrop/index.d.ts.map +1 -0
- package/dist/deaddrop/index.js +2 -0
- package/dist/deaddrop/index.js.map +1 -0
- package/dist/index.js +115 -44
- package/dist/index.js.map +1 -1
- package/dist/output/colors.d.ts +25 -5
- package/dist/output/colors.d.ts.map +1 -1
- package/dist/output/colors.js +33 -14
- package/dist/output/colors.js.map +1 -1
- package/dist/output/deaddrop-queue.d.ts +45 -0
- package/dist/output/deaddrop-queue.d.ts.map +1 -0
- package/dist/output/deaddrop-queue.js +82 -0
- package/dist/output/deaddrop-queue.js.map +1 -0
- package/dist/output/formatter.d.ts +5 -0
- package/dist/output/formatter.d.ts.map +1 -1
- package/dist/output/formatter.js +24 -22
- package/dist/output/formatter.js.map +1 -1
- package/dist/process/pty.d.ts.map +1 -1
- package/dist/process/pty.js +3 -2
- package/dist/process/pty.js.map +1 -1
- package/dist/script/index.d.ts +8 -0
- package/dist/script/index.d.ts.map +1 -0
- package/dist/script/index.js +10 -0
- package/dist/script/index.js.map +1 -0
- package/dist/script/loader.d.ts +13 -0
- package/dist/script/loader.d.ts.map +1 -0
- package/dist/script/loader.js +66 -0
- package/dist/script/loader.js.map +1 -0
- package/dist/script/parser.d.ts +63 -0
- package/dist/script/parser.d.ts.map +1 -0
- package/dist/script/parser.js +349 -0
- package/dist/script/parser.js.map +1 -0
- package/dist/script/types.d.ts +49 -0
- package/dist/script/types.d.ts.map +1 -0
- package/dist/script/types.js +5 -0
- package/dist/script/types.js.map +1 -0
- package/dist/script/variables.d.ts +27 -0
- package/dist/script/variables.d.ts.map +1 -0
- package/dist/script/variables.js +74 -0
- package/dist/script/variables.js.map +1 -0
- package/dist/templates/command.d.ts +38 -9
- package/dist/templates/command.d.ts.map +1 -1
- package/dist/templates/command.js +81 -27
- package/dist/templates/command.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/runner.d.ts +13 -0
- package/dist/types/runner.d.ts.map +1 -1
- package/dist/types/runner.js +5 -3
- package/dist/types/runner.js.map +1 -1
- package/dist/types/tools.d.ts +64 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +12 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/arguments.d.ts +19 -0
- package/dist/utils/arguments.d.ts.map +1 -0
- package/dist/utils/arguments.js +31 -0
- package/dist/utils/arguments.js.map +1 -0
- package/dist/utils/constants.d.ts +49 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +54 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/formatting.d.ts +10 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +19 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,12 +4,12 @@ Deterministic, scripted, unattended Claude Code execution.
|
|
|
4
4
|
|
|
5
5
|
## Why Use This?
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
7
|
+
- **Walk away** — Workflows run unattended in CI/CD pipelines
|
|
8
|
+
- **Chain results** — Capture output from one step, inject it into the next
|
|
9
|
+
- **Claude decides** — Signals control when to retry, escalate, or finish
|
|
10
|
+
- **No hitting context limits** — Fresh context per step keeps long workflows running
|
|
11
|
+
- **Watch live** — See tool calls stream as they execute
|
|
12
|
+
- **Replay later** — Full session logs for debugging
|
|
13
13
|
|
|
14
14
|
## Prerequisites
|
|
15
15
|
|
|
@@ -30,12 +30,6 @@ npm install -g @rcrsr/claude-code-runner
|
|
|
30
30
|
claude-code-runner prompt "Refactor the auth module to use async/await"
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
The `prompt` keyword is optional — bare strings work the same way:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
claude-code-runner "Fix the failing tests in src/utils"
|
|
37
|
-
```
|
|
38
|
-
|
|
39
33
|
### command — Run a slash command file
|
|
40
34
|
|
|
41
35
|
Store prompts as markdown files in `.claude/commands/` and invoke them by name:
|
|
@@ -58,41 +52,102 @@ Review the code in $1 for:
|
|
|
58
52
|
Output findings as a numbered list.
|
|
59
53
|
```
|
|
60
54
|
|
|
61
|
-
|
|
55
|
+
**Template variables:**
|
|
56
|
+
|
|
57
|
+
- `$1`, `$2`, `$3`... — Positional arguments
|
|
58
|
+
- `$ARGUMENTS` — All arguments joined with spaces
|
|
59
|
+
|
|
60
|
+
**Frontmatter support:**
|
|
61
|
+
|
|
62
|
+
```markdown
|
|
63
|
+
---
|
|
64
|
+
description: Review code for issues
|
|
65
|
+
argument-hint: <file> [severity]
|
|
66
|
+
model: sonnet
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
Review $1 with severity level $2...
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- `argument-hint` — Defines required `<arg>` and optional `[arg]` arguments
|
|
73
|
+
- `model` — Default model for this command (CLI `--model` takes precedence)
|
|
74
|
+
- `description` — Command description
|
|
62
75
|
|
|
63
|
-
### script — Run
|
|
76
|
+
### script — Run multi-phase workflows
|
|
64
77
|
|
|
65
|
-
|
|
78
|
+
Scripts chain commands where each phase builds on the previous. Output from one step can be captured and reused in subsequent steps via variable substitution.
|
|
66
79
|
|
|
67
80
|
```bash
|
|
68
|
-
claude-code-runner script
|
|
81
|
+
claude-code-runner script refactor-workflow.txt src/api/
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Script syntax:**
|
|
85
|
+
|
|
86
|
+
| Syntax | Description |
|
|
87
|
+
| ----------------------------------- | ----------------------------------------- |
|
|
88
|
+
| `prompt("text")` | Run a prompt (supports `\n` for newlines) |
|
|
89
|
+
| `prompt(<<EOF...EOF)` | Multi-line prompt using heredoc |
|
|
90
|
+
| `command("name")` | Run a command template |
|
|
91
|
+
| `command("name", ["arg1", "arg2"])` | Run command with arguments |
|
|
92
|
+
| `-> $varname` | Capture output into a variable |
|
|
93
|
+
| `$_` | Previous step's output (auto-captured) |
|
|
94
|
+
| `$varname` | Named captured variable |
|
|
95
|
+
| `$1`, `$2`, `$ARGUMENTS` | Script arguments |
|
|
96
|
+
| `# comment` | Comments (ignored) |
|
|
97
|
+
|
|
98
|
+
**Example: Variable capture and chaining** (`refactor-workflow.txt`):
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
---
|
|
102
|
+
argument-hint: <directory>
|
|
103
|
+
---
|
|
104
|
+
# Phase 1: Analyze - capture issues list
|
|
105
|
+
prompt("Review $1 for error handling issues. List each issue with file:line.") -> $issues
|
|
106
|
+
|
|
107
|
+
# Phase 2: Fix - use captured issues (no temp file needed)
|
|
108
|
+
prompt(<<EOF
|
|
109
|
+
Fix these issues:
|
|
110
|
+
$issues
|
|
111
|
+
|
|
112
|
+
For each fix, make minimal changes.
|
|
113
|
+
EOF
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# Phase 3: Verify - $_ contains previous output
|
|
117
|
+
prompt("Run tests. Confirm fixes are correct. Previous output: $_")
|
|
69
118
|
```
|
|
70
119
|
|
|
71
|
-
**Example
|
|
120
|
+
**Example: Command with capture** (`test-and-fix.txt`):
|
|
72
121
|
|
|
73
122
|
```text
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
123
|
+
# Run tests, capture failures
|
|
124
|
+
command("run-tests", [$1]) -> $failures
|
|
125
|
+
|
|
126
|
+
# Fix any failures
|
|
127
|
+
prompt("Fix these test failures:\n$failures")
|
|
128
|
+
|
|
129
|
+
# Verify
|
|
130
|
+
command("run-tests", [$1])
|
|
78
131
|
```
|
|
79
132
|
|
|
80
|
-
Scripts stop on `BLOCKED` or `ERROR` signals,
|
|
133
|
+
Scripts stop on `BLOCKED` or `ERROR` signals, catching issues before continuing to the next phase.
|
|
81
134
|
|
|
82
135
|
### Options
|
|
83
136
|
|
|
84
|
-
| Option
|
|
85
|
-
|
|
|
86
|
-
| `--
|
|
87
|
-
| `--
|
|
88
|
-
| `--
|
|
89
|
-
| `--
|
|
90
|
-
| `--
|
|
137
|
+
| Option | Description |
|
|
138
|
+
| ----------------- | ------------------------------------------------------ |
|
|
139
|
+
| `--version`, `-V` | Print version number |
|
|
140
|
+
| `--model`, `-m` | Specify Claude model (e.g., `sonnet`, `opus`, `haiku`) |
|
|
141
|
+
| `--quiet` | Minimal output (errors only) |
|
|
142
|
+
| `--normal` | Default output level |
|
|
143
|
+
| `--verbose` | Full output with details |
|
|
144
|
+
| `--no-log` | Disable file logging |
|
|
145
|
+
| `--deaddrop` | Enable [DeadDrop](https://deaddrop.sh) streaming |
|
|
91
146
|
|
|
92
147
|
**Example with model selection:**
|
|
93
148
|
|
|
94
149
|
```bash
|
|
95
|
-
claude-code-runner -m sonnet "Explain this codebase"
|
|
150
|
+
claude-code-runner -m sonnet prompt "Explain this codebase"
|
|
96
151
|
```
|
|
97
152
|
|
|
98
153
|
## Runner Signals
|
|
@@ -107,23 +162,62 @@ Signals give Claude a way to control execution flow. Instruct Claude to output t
|
|
|
107
162
|
|
|
108
163
|
No signal means success—the runner exits when Claude finishes without outputting a signal.
|
|
109
164
|
|
|
110
|
-
|
|
165
|
+
### Document-Driven Workflows
|
|
166
|
+
|
|
167
|
+
The real power of runner signals is **checklist-based execution**. Create a document with implementation steps, and Claude works through them one at a time across multiple invocations.
|
|
168
|
+
|
|
169
|
+
**Implementation plan** (`PLAN.md`):
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
# Feature: User Authentication
|
|
173
|
+
|
|
174
|
+
- [ ] Create `src/auth/types.ts` with User and Session interfaces
|
|
175
|
+
- [ ] Implement `src/auth/session.ts` with createSession and validateSession
|
|
176
|
+
- [ ] Add JWT signing in `src/auth/jwt.ts`
|
|
177
|
+
- [ ] Write tests in `src/auth/__tests__/session.test.ts`
|
|
178
|
+
- [ ] Update `src/index.ts` to export auth module
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Command template** (`.claude/commands/work-plan.md`):
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
Read $1 and find the first unchecked item (- [ ]).
|
|
185
|
+
|
|
186
|
+
1. Implement that single item
|
|
187
|
+
2. Mark it complete by changing `- [ ]` to `- [x]`
|
|
188
|
+
3. Check if any unchecked items remain:
|
|
189
|
+
- If YES: output :::RUNNER::REPEAT_STEP:::
|
|
190
|
+
- If NO: output "All tasks complete"
|
|
191
|
+
|
|
192
|
+
If blocked, output :::RUNNER::BLOCKED::: with what you need.
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Run it:**
|
|
111
196
|
|
|
112
197
|
```bash
|
|
113
|
-
claude-code-runner
|
|
198
|
+
claude-code-runner command work-plan PLAN.md
|
|
114
199
|
```
|
|
115
200
|
|
|
116
|
-
|
|
201
|
+
Each invocation: Claude finds the next unchecked step → implements it → marks it done → signals `REPEAT_STEP`. The loop continues until all boxes are checked. The document itself becomes persistent state across runs.
|
|
202
|
+
|
|
203
|
+
### Self-Correcting Loops
|
|
204
|
+
|
|
205
|
+
For retry-based patterns where Claude validates its own work:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
claude-code-runner "Fix all lint errors. Run the linter after each fix. Output :::RUNNER::REPEAT_STEP::: if errors remain, nothing if clean."
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Or as a template (`.claude/commands/fix-tests.md`):
|
|
117
212
|
|
|
118
213
|
```markdown
|
|
119
214
|
Run the test suite for $1.
|
|
120
215
|
|
|
121
|
-
- If tests
|
|
122
|
-
- If tests fail and
|
|
216
|
+
- If tests pass: done
|
|
217
|
+
- If tests fail and fixable: fix them, output :::RUNNER::REPEAT_STEP:::
|
|
218
|
+
- If tests fail and stuck: output :::RUNNER::BLOCKED::: with explanation
|
|
123
219
|
```
|
|
124
220
|
|
|
125
|
-
This pattern enables self-correcting loops: Claude attempts a fix, signals `REPEAT_STEP` to retry, and exits when done or stuck.
|
|
126
|
-
|
|
127
221
|
**Defaults:**
|
|
128
222
|
|
|
129
223
|
- Max 10 iterations per command (prevents runaway loops)
|
package/dist/cli/args.d.ts
CHANGED
|
@@ -9,9 +9,6 @@ import type { ParsedArgs } from '../types/index.js';
|
|
|
9
9
|
export declare function parseCommandLine(line: string): {
|
|
10
10
|
prompt: string;
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* Parse CLI arguments
|
|
14
|
-
*/
|
|
15
12
|
export declare function parseArgs(args: string[]): ParsedArgs;
|
|
16
13
|
/**
|
|
17
14
|
* Print usage information
|
package/dist/cli/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,mBAAmB,CAAC;AAkD3B;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAmBjE;AAWD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAwGpD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CA2BjC"}
|
package/dist/cli/args.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI argument parsing
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import { loadScript } from '../script/index.js';
|
|
5
6
|
import { loadCommandTemplate } from '../templates/command.js';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const pkg = require('../../package.json');
|
|
6
9
|
/**
|
|
7
10
|
* Extract options from raw args, returning positional args and config
|
|
8
11
|
*/
|
|
9
12
|
function extractOptions(args) {
|
|
13
|
+
// Handle --version early
|
|
14
|
+
if (args.includes('--version') || args.includes('-V')) {
|
|
15
|
+
console.log(pkg.version);
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
10
18
|
let verbosity = 'normal';
|
|
11
19
|
let enableLog = true;
|
|
12
20
|
let model = null;
|
|
21
|
+
let deaddrop = false;
|
|
13
22
|
const positionalArgs = [];
|
|
14
23
|
for (let i = 0; i < args.length; i++) {
|
|
15
24
|
const arg = args[i];
|
|
@@ -25,6 +34,9 @@ function extractOptions(args) {
|
|
|
25
34
|
else if (arg === '--no-log') {
|
|
26
35
|
enableLog = false;
|
|
27
36
|
}
|
|
37
|
+
else if (arg === '--deaddrop') {
|
|
38
|
+
deaddrop = true;
|
|
39
|
+
}
|
|
28
40
|
else if (arg === '--model' || arg === '-m') {
|
|
29
41
|
model = args[++i] ?? null;
|
|
30
42
|
}
|
|
@@ -35,7 +47,7 @@ function extractOptions(args) {
|
|
|
35
47
|
positionalArgs.push(arg ?? '');
|
|
36
48
|
}
|
|
37
49
|
}
|
|
38
|
-
return { positionalArgs, verbosity, enableLog, model };
|
|
50
|
+
return { positionalArgs, verbosity, enableLog, model, deaddrop };
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
53
|
* Parse a command line into a prompt
|
|
@@ -52,7 +64,8 @@ export function parseCommandLine(line) {
|
|
|
52
64
|
if (!cmdName) {
|
|
53
65
|
throw new Error('command requires a name');
|
|
54
66
|
}
|
|
55
|
-
|
|
67
|
+
const { prompt } = loadCommandTemplate(cmdName, parts.slice(2));
|
|
68
|
+
return { prompt };
|
|
56
69
|
}
|
|
57
70
|
else if (cmd === 'script') {
|
|
58
71
|
throw new Error('script cannot be nested');
|
|
@@ -65,13 +78,33 @@ export function parseCommandLine(line) {
|
|
|
65
78
|
/**
|
|
66
79
|
* Parse CLI arguments
|
|
67
80
|
*/
|
|
81
|
+
const VALID_SUBCOMMANDS = ['prompt', 'command', 'script'];
|
|
82
|
+
function isValidSubcommand(value) {
|
|
83
|
+
return VALID_SUBCOMMANDS.includes(value);
|
|
84
|
+
}
|
|
68
85
|
export function parseArgs(args) {
|
|
69
|
-
const { positionalArgs, verbosity, enableLog, model } = extractOptions(args);
|
|
70
|
-
const
|
|
86
|
+
const { positionalArgs, verbosity, enableLog, model, deaddrop } = extractOptions(args);
|
|
87
|
+
const firstArg = positionalArgs[0];
|
|
88
|
+
// Validate subcommand
|
|
89
|
+
if (!firstArg) {
|
|
90
|
+
console.error('Error: subcommand required');
|
|
91
|
+
console.error('Usage: claude-code-runner <prompt|command|script> [args...]');
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
if (!isValidSubcommand(firstArg)) {
|
|
95
|
+
console.error(`Error: unknown subcommand '${firstArg}'`);
|
|
96
|
+
console.error('Valid subcommands: prompt, command, script');
|
|
97
|
+
console.error('Usage: claude-code-runner <prompt|command|script> [args...]');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
const subcommand = firstArg;
|
|
71
101
|
let prompt = '';
|
|
72
102
|
let displayCommand = '';
|
|
73
103
|
let scriptMode = false;
|
|
74
104
|
let scriptLines = [];
|
|
105
|
+
let scriptFile = null;
|
|
106
|
+
let scriptArgs = [];
|
|
107
|
+
let frontmatterModel = null;
|
|
75
108
|
switch (subcommand) {
|
|
76
109
|
case 'command': {
|
|
77
110
|
const commandName = positionalArgs[1];
|
|
@@ -80,40 +113,53 @@ export function parseArgs(args) {
|
|
|
80
113
|
console.error('Usage: claude-code-runner command <name> [args...]');
|
|
81
114
|
process.exit(1);
|
|
82
115
|
}
|
|
83
|
-
|
|
116
|
+
const template = loadCommandTemplate(commandName, positionalArgs.slice(2));
|
|
117
|
+
prompt = template.prompt;
|
|
118
|
+
frontmatterModel = template.frontmatter.model ?? null;
|
|
84
119
|
displayCommand = positionalArgs.slice(1).join(' ');
|
|
85
120
|
break;
|
|
86
121
|
}
|
|
87
122
|
case 'script': {
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
123
|
+
const file = positionalArgs[1];
|
|
124
|
+
if (!file) {
|
|
90
125
|
console.error('Error: script file required');
|
|
91
|
-
console.error('Usage: claude-code-runner script <file>');
|
|
126
|
+
console.error('Usage: claude-code-runner script <file> [args...]');
|
|
92
127
|
process.exit(1);
|
|
93
128
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
scriptLines =
|
|
99
|
-
.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
129
|
+
scriptFile = file;
|
|
130
|
+
scriptArgs = positionalArgs.slice(2);
|
|
131
|
+
const parsed = loadScript(file, scriptArgs);
|
|
132
|
+
// Convert parsed lines to display strings for backward compat
|
|
133
|
+
scriptLines = parsed.lines.map((line) => {
|
|
134
|
+
if (line.type === 'prompt') {
|
|
135
|
+
const text = line.text.length > 50 ? line.text.slice(0, 50) + '...' : line.text;
|
|
136
|
+
return `prompt("${text}")${line.capture ? ` -> $${line.capture}` : ''}`;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return `command("${line.name}")${line.capture ? ` -> $${line.capture}` : ''}`;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
frontmatterModel = parsed.frontmatter.model ?? null;
|
|
103
143
|
scriptMode = true;
|
|
104
|
-
displayCommand =
|
|
144
|
+
displayCommand = positionalArgs.slice(1).join(' ');
|
|
105
145
|
break;
|
|
106
146
|
}
|
|
107
|
-
case 'prompt':
|
|
108
|
-
prompt =
|
|
109
|
-
|
|
147
|
+
case 'prompt': {
|
|
148
|
+
prompt = positionalArgs.slice(1).join(' ');
|
|
149
|
+
if (!prompt) {
|
|
150
|
+
console.error('Error: prompt text required');
|
|
151
|
+
console.error('Usage: claude-code-runner prompt <text>');
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
110
154
|
displayCommand = `"${prompt}"`;
|
|
111
155
|
break;
|
|
156
|
+
}
|
|
112
157
|
}
|
|
113
158
|
const config = {
|
|
114
159
|
verbosity,
|
|
115
160
|
enableLog,
|
|
116
|
-
model,
|
|
161
|
+
model: model ?? frontmatterModel,
|
|
162
|
+
deaddrop,
|
|
117
163
|
};
|
|
118
164
|
return {
|
|
119
165
|
subcommand: scriptMode ? 'script' : subcommand,
|
|
@@ -122,6 +168,8 @@ export function parseArgs(args) {
|
|
|
122
168
|
scriptLines,
|
|
123
169
|
scriptMode,
|
|
124
170
|
config,
|
|
171
|
+
scriptFile,
|
|
172
|
+
scriptArgs,
|
|
125
173
|
};
|
|
126
174
|
}
|
|
127
175
|
/**
|
|
@@ -134,12 +182,12 @@ Claude Code Runner - executes claude CLI with proper TTY handling
|
|
|
134
182
|
Usage:
|
|
135
183
|
claude-code-runner [options] prompt <prompt>
|
|
136
184
|
claude-code-runner [options] command <name> [args...]
|
|
137
|
-
claude-code-runner [options] script <file>
|
|
185
|
+
claude-code-runner [options] script <file> [args...]
|
|
138
186
|
|
|
139
187
|
Subcommands:
|
|
140
188
|
prompt <text> Run with the given prompt (supports RUNNER signals)
|
|
141
189
|
command <name> [args] Load .claude/commands/<name>.md (supports RUNNER signals)
|
|
142
|
-
script <file>
|
|
190
|
+
script <file> [args] Run commands from file, stop on ERROR/BLOCKED
|
|
143
191
|
|
|
144
192
|
Iteration Signals (control runner execution):
|
|
145
193
|
:::RUNNER::REPEAT_STEP::: Run the same step again
|
|
@@ -152,6 +200,7 @@ Options:
|
|
|
152
200
|
--verbose Full output with all details
|
|
153
201
|
--no-log Disable logging to file (enabled by default)
|
|
154
202
|
--model, -m <model> Specify Claude model (e.g., sonnet, opus, haiku)
|
|
203
|
+
--deaddrop Send messages to Deaddrop (requires DEADDROP_API_KEY env var)
|
|
155
204
|
`);
|
|
156
205
|
}
|
|
157
206
|
//# sourceMappingURL=args.js.map
|
package/dist/cli/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAwB,CAAC;AAgBjE;;GAEG;AACH,SAAS,cAAc,CAAC,IAAc;IACpC,yBAAyB;IACzB,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC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;;;CAyBb,CAAC,CAAC;AACH,CAAC"}
|
package/dist/core/runner.d.ts
CHANGED
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { FormatterState } from '../output/formatter.js';
|
|
5
5
|
import type { Logger } from '../output/logger.js';
|
|
6
|
-
import type { RunnerConfig,
|
|
6
|
+
import type { RunnerConfig, SignalRunResult } from '../types/runner.js';
|
|
7
7
|
export interface RunnerContext {
|
|
8
8
|
config: RunnerConfig;
|
|
9
9
|
logger: Logger;
|
|
10
10
|
formatterState: FormatterState;
|
|
11
11
|
cwd: string;
|
|
12
|
+
runId: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface StepContext {
|
|
15
|
+
stepNum: number;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
18
|
* Run a command with RUNNER signal support
|
|
15
19
|
* Handles iteration loop and signal detection
|
|
16
20
|
*/
|
|
17
|
-
export declare function runWithSignals(promptText: string, displayCommand: string, startTime: number, context: RunnerContext): Promise<
|
|
21
|
+
export declare function runWithSignals(promptText: string, displayCommand: string, startTime: number, context: RunnerContext, step?: StepContext): Promise<SignalRunResult>;
|
|
18
22
|
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,cAAc,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,EACtB,IAAI,GAAE,WAA4B,GACjC,OAAO,CAAC,eAAe,CAAC,CAuF1B"}
|
package/dist/core/runner.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core runner with iteration control and signal detection
|
|
3
3
|
*/
|
|
4
|
-
import { colors,
|
|
4
|
+
import { colors, formatDuration, printRunner } from '../output/colors.js';
|
|
5
5
|
import { detectRunnerSignal } from '../parsers/signals.js';
|
|
6
6
|
import { spawnClaude } from '../process/pty.js';
|
|
7
7
|
/**
|
|
8
8
|
* Run a command with RUNNER signal support
|
|
9
9
|
* Handles iteration loop and signal detection
|
|
10
10
|
*/
|
|
11
|
-
export async function runWithSignals(promptText, displayCommand, startTime, context) {
|
|
11
|
+
export async function runWithSignals(promptText, displayCommand, startTime, context, step = { stepNum: 1 }) {
|
|
12
12
|
const { config, logger, formatterState, cwd } = context;
|
|
13
13
|
const { verbosity, maxIterations, parallelThresholdMs, iterationPauseMs, model, } = config;
|
|
14
14
|
let iteration = 0;
|
|
15
|
+
let lastClaudeText = '';
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- intentional infinite loop with internal exits
|
|
16
17
|
while (true) {
|
|
17
18
|
iteration++;
|
|
18
19
|
// Check max iterations
|
|
19
20
|
if (iteration > maxIterations) {
|
|
20
|
-
const totalDuration =
|
|
21
|
-
printRunner(`${colors.red}Run stopped${colors.reset} max iterations (${maxIterations}) in ${
|
|
21
|
+
const totalDuration = Date.now() - startTime;
|
|
22
|
+
printRunner(`${colors.red}Run stopped${colors.reset} max iterations (${maxIterations}) in ${formatDuration(totalDuration)}`);
|
|
22
23
|
logger.log(`\nMAX ITERATIONS reached after ${maxIterations}`);
|
|
23
|
-
return 'error';
|
|
24
|
+
return { status: 'error', claudeText: lastClaudeText };
|
|
24
25
|
}
|
|
25
26
|
// Log iteration for subsequent iterations
|
|
26
27
|
if (iteration > 1) {
|
|
@@ -28,8 +29,12 @@ export async function runWithSignals(promptText, displayCommand, startTime, cont
|
|
|
28
29
|
}
|
|
29
30
|
// Print running message
|
|
30
31
|
if (verbosity !== 'quiet') {
|
|
31
|
-
|
|
32
|
+
const iterLabel = iteration > 1 ? ` (iter ${iteration})` : '';
|
|
33
|
+
const separator = displayCommand.startsWith('with ') ? ' ' : ': ';
|
|
34
|
+
printRunner(`Running step ${step.stepNum}${iterLabel}${separator}${displayCommand}`);
|
|
32
35
|
}
|
|
36
|
+
// Update formatter with current step
|
|
37
|
+
formatterState.currentStep = iteration;
|
|
33
38
|
// Run Claude
|
|
34
39
|
const { exitCode, claudeText } = await spawnClaude({
|
|
35
40
|
prompt: promptText,
|
|
@@ -40,29 +45,32 @@ export async function runWithSignals(promptText, displayCommand, startTime, cont
|
|
|
40
45
|
parallelThresholdMs,
|
|
41
46
|
model,
|
|
42
47
|
});
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
lastClaudeText = claudeText;
|
|
49
|
+
const signal = detectRunnerSignal(claudeText);
|
|
50
|
+
const stepDuration = Date.now() - startTime;
|
|
51
|
+
if (signal === 'blocked') {
|
|
52
|
+
printRunner(`${colors.red}Blocked${colors.reset} step ${step.stepNum} in ${formatDuration(stepDuration)}`);
|
|
53
|
+
logger.log(`\nBLOCKED at step ${step.stepNum}`);
|
|
54
|
+
return { status: 'blocked', claudeText };
|
|
49
55
|
}
|
|
50
|
-
else if (
|
|
51
|
-
printRunner(`${colors.red}
|
|
52
|
-
logger.log(`\nERROR
|
|
53
|
-
return 'error';
|
|
56
|
+
else if (signal === 'error') {
|
|
57
|
+
printRunner(`${colors.red}Failed${colors.reset} step ${step.stepNum} in ${formatDuration(stepDuration)}`);
|
|
58
|
+
logger.log(`\nERROR at step ${step.stepNum}`);
|
|
59
|
+
return { status: 'error', claudeText };
|
|
54
60
|
}
|
|
55
|
-
else if (
|
|
56
|
-
printRunner(`
|
|
57
|
-
logger.log(`Iteration ${iteration} complete,
|
|
61
|
+
else if (signal === 'repeat_step') {
|
|
62
|
+
printRunner(`Repeating step ${step.stepNum}`);
|
|
63
|
+
logger.log(`Iteration ${iteration} complete, repeating...`);
|
|
58
64
|
await sleep(iterationPauseMs);
|
|
59
65
|
}
|
|
60
66
|
else {
|
|
61
|
-
// No
|
|
67
|
+
// No signal - step completed
|
|
62
68
|
const exitStatus = exitCode === 0 ? 'ok' : 'error';
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
if (exitCode !== 0) {
|
|
70
|
+
printRunner(`${colors.red}Failed${colors.reset} step ${step.stepNum} in ${formatDuration(stepDuration)}`);
|
|
71
|
+
}
|
|
72
|
+
logger.log(`\nStep ${step.stepNum} complete, exit=${exitCode}`);
|
|
73
|
+
return { status: exitStatus, claudeText };
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
}
|
package/dist/core/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,M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: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
}
|
|
10
|
+
export type DeadDropUser = 'Runner' | 'Claude Code';
|
|
11
|
+
export interface DeadDropClient {
|
|
12
|
+
send(content: string, user: DeadDropUser): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a DeadDrop client from environment variables
|
|
16
|
+
* Returns null if DEADDROP_API_KEY is not set
|
|
17
|
+
*/
|
|
18
|
+
export declare function createDeadDropClientFromEnv(runId: string): DeadDropClient | null;
|
|
19
|
+
/**
|
|
20
|
+
* Create a DeadDrop client with the given configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare function createDeadDropClient(config: DeadDropConfig): DeadDropClient;
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/deaddrop/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAID;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,GACZ,cAAc,GAAG,IAAI,CAQvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CA4B3E"}
|