@rcrsr/claude-code-runner 0.4.0 → 0.6.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 +104 -31
- package/dist/cli/args.d.ts +0 -3
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +51 -20
- package/dist/cli/args.js.map +1 -1
- package/dist/core/runner.d.ts +5 -2
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +27 -24
- package/dist/core/runner.js.map +1 -1
- package/dist/index.js +85 -42
- package/dist/index.js.map +1 -1
- package/dist/output/colors.d.ts +16 -12
- package/dist/output/colors.d.ts.map +1 -1
- package/dist/output/colors.js +27 -65
- 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 +23 -0
- package/dist/output/formatter.d.ts.map +1 -1
- package/dist/output/formatter.js +83 -42
- package/dist/output/formatter.js.map +1 -1
- package/dist/output/index.d.ts +1 -0
- package/dist/output/index.d.ts.map +1 -1
- package/dist/output/index.js +1 -0
- package/dist/output/index.js.map +1 -1
- package/dist/output/logger.js +2 -2
- package/dist/output/logger.js.map +1 -1
- package/dist/output/stats.d.ts +73 -0
- package/dist/output/stats.d.ts.map +1 -0
- package/dist/output/stats.js +154 -0
- package/dist/output/stats.js.map +1 -0
- 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 +18 -20
- package/dist/templates/command.d.ts.map +1 -1
- package/dist/templates/command.js +40 -61
- package/dist/templates/command.js.map +1 -1
- package/dist/types/claude.d.ts +12 -0
- package/dist/types/claude.d.ts.map +1 -1
- package/dist/types/claude.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 +12 -0
- package/dist/types/runner.d.ts.map +1 -1
- package/dist/types/runner.js +4 -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 +51 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +56 -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/dist/index.js
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* Shows intermediate tool calls and responses in real-time
|
|
5
5
|
*/
|
|
6
6
|
import { randomBytes } from 'crypto';
|
|
7
|
-
import { parseArgs
|
|
8
|
-
import { runWithSignals } from './core/runner.js';
|
|
7
|
+
import { parseArgs } from './cli/args.js';
|
|
8
|
+
import { runWithSignals, } from './core/runner.js';
|
|
9
9
|
import { createDeadDropClientFromEnv } from './deaddrop/index.js';
|
|
10
|
-
import {
|
|
11
|
-
import { createFormatterState } from './output/formatter.js';
|
|
10
|
+
import { configureDeadDrop, flushDeadDrop, printRunner, printRunnerInfo, } from './output/colors.js';
|
|
11
|
+
import { createFormatterState, finalizeStepStats, getRunStatsSummary, resetFormatterState, } from './output/formatter.js';
|
|
12
12
|
import { createLogger } from './output/logger.js';
|
|
13
|
+
import { captureOutput, createVariableStore, getSubstitutionList, loadScript, substituteVariables, } from './script/index.js';
|
|
14
|
+
import { loadCommandTemplate } from './templates/command.js';
|
|
13
15
|
import { DEFAULT_CONFIG } from './types/runner.js';
|
|
14
16
|
/**
|
|
15
17
|
* Generate a short unique run ID (8 chars, uppercase)
|
|
@@ -17,6 +19,16 @@ import { DEFAULT_CONFIG } from './types/runner.js';
|
|
|
17
19
|
function generateRunId() {
|
|
18
20
|
return randomBytes(4).toString('hex').toUpperCase();
|
|
19
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Format variables used for "with X" clause
|
|
24
|
+
*/
|
|
25
|
+
function formatVarsUsed(vars) {
|
|
26
|
+
if (vars.length === 0)
|
|
27
|
+
return '';
|
|
28
|
+
// Convert $_ to "last result", keep others as-is
|
|
29
|
+
const labels = vars.map((v) => (v === '$_' ? 'last result' : v));
|
|
30
|
+
return `with ${labels.join(', ')}: `;
|
|
31
|
+
}
|
|
20
32
|
async function main() {
|
|
21
33
|
const totalStart = Date.now();
|
|
22
34
|
const args = process.argv.slice(2);
|
|
@@ -68,58 +80,89 @@ async function main() {
|
|
|
68
80
|
printRunnerInfo(`Log: ${logger.filePath}`);
|
|
69
81
|
}
|
|
70
82
|
logger.log(`Started: ${new Date().toISOString()}`);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
// Build script lines - single prompt/command becomes a 1-step script
|
|
84
|
+
let lines;
|
|
85
|
+
let scriptArgs = [];
|
|
86
|
+
if (parsed.scriptMode && parsed.scriptFile) {
|
|
87
|
+
const script = loadScript(parsed.scriptFile, parsed.scriptArgs);
|
|
88
|
+
lines = script.lines;
|
|
89
|
+
scriptArgs = parsed.scriptArgs;
|
|
74
90
|
}
|
|
75
91
|
else {
|
|
76
|
-
// Single command
|
|
77
|
-
|
|
92
|
+
// Single prompt or command becomes a 1-step script
|
|
93
|
+
lines = [{ type: 'prompt', text: parsed.prompt }];
|
|
78
94
|
}
|
|
95
|
+
// Run the script
|
|
96
|
+
const success = await runScript(lines, scriptArgs, context, totalStart);
|
|
97
|
+
context.logger.close();
|
|
98
|
+
await flushDeadDrop();
|
|
99
|
+
process.exit(success ? 0 : 1);
|
|
79
100
|
}
|
|
80
101
|
/**
|
|
81
|
-
*
|
|
102
|
+
* Build display string for a script line
|
|
82
103
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
function getDisplayLine(line) {
|
|
105
|
+
if (line.type === 'prompt') {
|
|
106
|
+
// Replace newlines with spaces for single-line display
|
|
107
|
+
const cleaned = line.text.replace(/[\r\n]+/g, ' ').trim();
|
|
108
|
+
const preview = cleaned.length > 50 ? cleaned.slice(0, 50) + '...' : cleaned;
|
|
109
|
+
return `"${preview}"`;
|
|
110
|
+
}
|
|
111
|
+
return `command("${line.name}")`;
|
|
89
112
|
}
|
|
90
113
|
/**
|
|
91
|
-
* Run
|
|
114
|
+
* Run a script (unified execution for single prompts and multi-step scripts)
|
|
92
115
|
*/
|
|
93
|
-
async function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
async function runScript(lines, scriptArgs, context, startTime) {
|
|
117
|
+
const store = createVariableStore();
|
|
118
|
+
for (const [i, line] of lines.entries()) {
|
|
119
|
+
const stepNum = i + 1;
|
|
120
|
+
const displayLine = getDisplayLine(line);
|
|
121
|
+
context.logger.log(`\n=== Step ${stepNum}: ${displayLine} ===\n`);
|
|
122
|
+
// Get the prompt text
|
|
123
|
+
let promptText;
|
|
124
|
+
if (line.type === 'prompt') {
|
|
125
|
+
promptText = line.text;
|
|
102
126
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
127
|
+
else {
|
|
128
|
+
const template = loadCommandTemplate(line.name, line.args);
|
|
129
|
+
promptText = template.prompt;
|
|
106
130
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
131
|
+
// Substitute variables
|
|
132
|
+
const varsUsed = getSubstitutionList(promptText, store);
|
|
133
|
+
const finalPrompt = substituteVariables(promptText, store, scriptArgs);
|
|
134
|
+
// Build display: show substituted prompt and what variables were used
|
|
135
|
+
const substitutedDisplay = getDisplayLine({
|
|
136
|
+
type: 'prompt',
|
|
137
|
+
text: finalPrompt,
|
|
138
|
+
});
|
|
139
|
+
const withClause = formatVarsUsed(varsUsed);
|
|
140
|
+
// Set step number and start time for formatter output
|
|
141
|
+
context.formatterState.currentStep = stepNum;
|
|
142
|
+
context.formatterState.stepStartTime = Date.now();
|
|
143
|
+
// Run via runWithSignals (handles iterations, signals, output)
|
|
144
|
+
const stepContext = { stepNum };
|
|
145
|
+
const result = await runWithSignals(finalPrompt, `${withClause}${substitutedDisplay}`, startTime, context, stepContext);
|
|
146
|
+
// Capture output for variable store
|
|
147
|
+
captureOutput(store, result.claudeText, line.capture);
|
|
148
|
+
// Finalize step stats and print completion
|
|
149
|
+
const stepDurationMs = context.formatterState.stepStartTime
|
|
150
|
+
? Date.now() - context.formatterState.stepStartTime
|
|
151
|
+
: (context.formatterState.lastStepDurationMs ?? 0);
|
|
152
|
+
const stepSummary = finalizeStepStats(context.formatterState, stepDurationMs);
|
|
153
|
+
printRunner(`Step ${stepNum} complete: ${stepSummary}`);
|
|
154
|
+
// Handle failure (runWithSignals already printed the error)
|
|
155
|
+
if (result.status !== 'ok') {
|
|
156
|
+
return false;
|
|
114
157
|
}
|
|
158
|
+
// Reset step stats for next step (preserves runStats)
|
|
159
|
+
resetFormatterState(context.formatterState);
|
|
115
160
|
}
|
|
116
|
-
//
|
|
161
|
+
// Print run completion with overall stats
|
|
117
162
|
const totalDuration = Date.now() - startTime;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
await flushDeadDrop();
|
|
122
|
-
process.exit(0);
|
|
163
|
+
const runSummary = getRunStatsSummary(context.formatterState, totalDuration);
|
|
164
|
+
printRunner(`Run ${context.runId} complete: ${runSummary}`);
|
|
165
|
+
return true;
|
|
123
166
|
}
|
|
124
167
|
// Run main
|
|
125
168
|
main().catch((err) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAEL,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACj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CAAC,KAAK,cAAc,UAAU,EAAE,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,WAAW;AACX,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/output/colors.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ANSI color codes for terminal output
|
|
3
3
|
*/
|
|
4
|
+
import { configureDeadDrop, flushDeadDrop } from './deaddrop-queue.js';
|
|
5
|
+
export { configureDeadDrop, flushDeadDrop };
|
|
4
6
|
export declare const colors: {
|
|
5
7
|
readonly reset: "\u001B[0m";
|
|
6
8
|
readonly dim: "\u001B[2m";
|
|
@@ -14,6 +16,16 @@ export declare const colors: {
|
|
|
14
16
|
};
|
|
15
17
|
export type ColorName = keyof typeof colors;
|
|
16
18
|
export declare function stripAnsi(str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Strip carriage returns for cleaner terminal display
|
|
21
|
+
* Tool outputs sometimes contain CRs that cause display issues
|
|
22
|
+
*/
|
|
23
|
+
export declare function stripCR(str: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Log to terminal with CR stripping for clean display
|
|
26
|
+
* Use this for all terminal output in the formatter
|
|
27
|
+
*/
|
|
28
|
+
export declare function terminalLog(line: string): void;
|
|
17
29
|
/**
|
|
18
30
|
* Apply color to a string
|
|
19
31
|
*/
|
|
@@ -24,7 +36,7 @@ export declare function colorize(text: string, color: ColorName): string;
|
|
|
24
36
|
export declare function truncate(str: string, len: number): string;
|
|
25
37
|
/**
|
|
26
38
|
* Format duration in human-readable form
|
|
27
|
-
* Examples: 450ms, 2.5s,
|
|
39
|
+
* Examples: 450ms, 2.5s, 1m 30s, 1h 2m 3s
|
|
28
40
|
*/
|
|
29
41
|
export declare function formatDuration(ms: number): string;
|
|
30
42
|
/**
|
|
@@ -47,16 +59,6 @@ export type DeadDropUser = 'Runner' | 'Claude Code';
|
|
|
47
59
|
* Deaddrop send function type (to avoid circular imports)
|
|
48
60
|
*/
|
|
49
61
|
export type DeadDropSender = (content: string, user: DeadDropUser) => Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Configure the deaddrop sender for all output functions
|
|
52
|
-
* Call once at startup when --deaddrop is enabled
|
|
53
|
-
*/
|
|
54
|
-
export declare function configureDeadDrop(sender: DeadDropSender | null): void;
|
|
55
|
-
/**
|
|
56
|
-
* Flush all pending deaddrop sends
|
|
57
|
-
* Call before process.exit to ensure all messages are sent
|
|
58
|
-
*/
|
|
59
|
-
export declare function flushDeadDrop(): Promise<void>;
|
|
60
62
|
/**
|
|
61
63
|
* Print a [RUNNER] operational message with timestamp
|
|
62
64
|
* Automatically sends to Deaddrop if configured (without prefix)
|
|
@@ -70,6 +72,8 @@ export declare function printRunnerInfo(message: string): void;
|
|
|
70
72
|
/**
|
|
71
73
|
* Print a [CLAUDE] message with timestamp
|
|
72
74
|
* Automatically sends to Deaddrop if configured (without prefix)
|
|
75
|
+
* @param message - Display message (may be truncated/formatted for console)
|
|
76
|
+
* @param rawForDeaddrop - Original unmodified text to send to deaddrop (preserves newlines)
|
|
73
77
|
*/
|
|
74
|
-
export declare function printClaude(message: string): void;
|
|
78
|
+
export declare function printClaude(message: string, rawForDeaddrop?: string): void;
|
|
75
79
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/output/colors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,MAAM;;;;;;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MAAM,GAAG,MAAM,CAE3C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAE/D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAejD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAE,IAAiB,GAAG,MAAM,CAM/D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,YAAY,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAKjD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAK1E"}
|
package/dist/output/colors.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ANSI color codes for terminal output
|
|
3
3
|
*/
|
|
4
|
+
import { configureDeadDrop, flushDeadDrop, sendToDeadDrop, } from './deaddrop-queue.js';
|
|
5
|
+
// Re-export deaddrop functions for backward compatibility
|
|
6
|
+
export { configureDeadDrop, flushDeadDrop };
|
|
4
7
|
export const colors = {
|
|
5
8
|
reset: '\x1b[0m',
|
|
6
9
|
dim: '\x1b[2m',
|
|
@@ -20,6 +23,20 @@ const ANSI_REGEX = /\x1b\[[0-9;]*[a-zA-Z]/g;
|
|
|
20
23
|
export function stripAnsi(str) {
|
|
21
24
|
return str.replace(ANSI_REGEX, '');
|
|
22
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Strip carriage returns for cleaner terminal display
|
|
28
|
+
* Tool outputs sometimes contain CRs that cause display issues
|
|
29
|
+
*/
|
|
30
|
+
export function stripCR(str) {
|
|
31
|
+
return str.replace(/\r/g, '');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Log to terminal with CR stripping for clean display
|
|
35
|
+
* Use this for all terminal output in the formatter
|
|
36
|
+
*/
|
|
37
|
+
export function terminalLog(line) {
|
|
38
|
+
console.log(stripCR(line));
|
|
39
|
+
}
|
|
23
40
|
/**
|
|
24
41
|
* Apply color to a string
|
|
25
42
|
*/
|
|
@@ -37,7 +54,7 @@ export function truncate(str, len) {
|
|
|
37
54
|
}
|
|
38
55
|
/**
|
|
39
56
|
* Format duration in human-readable form
|
|
40
|
-
* Examples: 450ms, 2.5s,
|
|
57
|
+
* Examples: 450ms, 2.5s, 1m 30s, 1h 2m 3s
|
|
41
58
|
*/
|
|
42
59
|
export function formatDuration(ms) {
|
|
43
60
|
if (ms < 1000) {
|
|
@@ -51,9 +68,9 @@ export function formatDuration(ms) {
|
|
|
51
68
|
const mins = Math.floor((totalSeconds % 3600) / 60);
|
|
52
69
|
const secs = Math.round(totalSeconds % 60);
|
|
53
70
|
if (hours > 0) {
|
|
54
|
-
return `${hours}h${mins}m${secs}s`;
|
|
71
|
+
return `${hours}h ${mins}m ${secs}s`;
|
|
55
72
|
}
|
|
56
|
-
return `${mins}m${secs}s`;
|
|
73
|
+
return `${mins}m ${secs}s`;
|
|
57
74
|
}
|
|
58
75
|
/**
|
|
59
76
|
* Shorten file paths by removing common prefixes
|
|
@@ -82,69 +99,12 @@ export function formatTimestamp(date = new Date()) {
|
|
|
82
99
|
export function timestampPrefix() {
|
|
83
100
|
return `${colors.dim}${formatTimestamp()}${colors.reset} `;
|
|
84
101
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Module-level deaddrop sender, configured once at startup
|
|
87
|
-
*/
|
|
88
|
-
let deadDropSender = null;
|
|
89
|
-
const messageQueue = [];
|
|
90
|
-
let isProcessing = false;
|
|
91
|
-
let flushResolve = null;
|
|
92
|
-
/**
|
|
93
|
-
* Configure the deaddrop sender for all output functions
|
|
94
|
-
* Call once at startup when --deaddrop is enabled
|
|
95
|
-
*/
|
|
96
|
-
export function configureDeadDrop(sender) {
|
|
97
|
-
deadDropSender = sender;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Process queued messages one at a time
|
|
101
|
-
*/
|
|
102
|
-
async function processQueue() {
|
|
103
|
-
if (isProcessing || !deadDropSender)
|
|
104
|
-
return;
|
|
105
|
-
isProcessing = true;
|
|
106
|
-
let msg = messageQueue.shift();
|
|
107
|
-
while (msg) {
|
|
108
|
-
await deadDropSender(msg.content, msg.user);
|
|
109
|
-
msg = messageQueue.shift();
|
|
110
|
-
}
|
|
111
|
-
isProcessing = false;
|
|
112
|
-
// Resolve flush promise if waiting
|
|
113
|
-
if (flushResolve && messageQueue.length === 0) {
|
|
114
|
-
flushResolve();
|
|
115
|
-
flushResolve = null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Flush all pending deaddrop sends
|
|
120
|
-
* Call before process.exit to ensure all messages are sent
|
|
121
|
-
*/
|
|
122
|
-
export async function flushDeadDrop() {
|
|
123
|
-
if (messageQueue.length === 0 && !isProcessing)
|
|
124
|
-
return;
|
|
125
|
-
return new Promise((resolve) => {
|
|
126
|
-
flushResolve = resolve;
|
|
127
|
-
// If not already processing, start
|
|
128
|
-
if (!isProcessing) {
|
|
129
|
-
void processQueue();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Send a message to deaddrop if configured
|
|
135
|
-
*/
|
|
136
|
-
function sendToDeadDrop(message, user) {
|
|
137
|
-
if (deadDropSender) {
|
|
138
|
-
messageQueue.push({ content: message, user });
|
|
139
|
-
void processQueue();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
102
|
/**
|
|
143
103
|
* Print a [RUNNER] operational message with timestamp
|
|
144
104
|
* Automatically sends to Deaddrop if configured (without prefix)
|
|
145
105
|
*/
|
|
146
106
|
export function printRunner(message) {
|
|
147
|
-
|
|
107
|
+
terminalLog(`${timestampPrefix()}${colors.magenta}[RUNNER]${colors.reset} ${message}`);
|
|
148
108
|
sendToDeadDrop(stripAnsi(message), 'Runner');
|
|
149
109
|
}
|
|
150
110
|
/**
|
|
@@ -152,14 +112,16 @@ export function printRunner(message) {
|
|
|
152
112
|
* Does NOT send to Deaddrop (used for startup config, debug info)
|
|
153
113
|
*/
|
|
154
114
|
export function printRunnerInfo(message) {
|
|
155
|
-
|
|
115
|
+
terminalLog(`${timestampPrefix()}${colors.magenta}[RUNNER]${colors.reset} ${message}`);
|
|
156
116
|
}
|
|
157
117
|
/**
|
|
158
118
|
* Print a [CLAUDE] message with timestamp
|
|
159
119
|
* Automatically sends to Deaddrop if configured (without prefix)
|
|
120
|
+
* @param message - Display message (may be truncated/formatted for console)
|
|
121
|
+
* @param rawForDeaddrop - Original unmodified text to send to deaddrop (preserves newlines)
|
|
160
122
|
*/
|
|
161
|
-
export function printClaude(message) {
|
|
162
|
-
|
|
163
|
-
sendToDeadDrop(stripAnsi(message), 'Claude Code');
|
|
123
|
+
export function printClaude(message, rawForDeaddrop) {
|
|
124
|
+
terminalLog(`${timestampPrefix()}${colors.green}[CLAUDE]${colors.reset} ${message}`);
|
|
125
|
+
sendToDeadDrop(stripAnsi(rawForDeaddrop ?? message), 'Claude Code');
|
|
164
126
|
}
|
|
165
127
|
//# sourceMappingURL=colors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/output/colors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;IACf,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;CACR,CAAC;AAIX;;GAEG;AACH,4FAA4F;AAC5F,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAE5C,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAgB;IACrD,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,GAAW;IAC/C,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACd,OAAO,GAAG,EAAE,IAAI,CAAC;IACnB,CAAC;IACD,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC;IAC/B,IAAI,YAAY,GAAG,EAAE,EAAE,CAAC;QACtB,OA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Ac,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,WAAW,CACT,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC,KAAK,IAAI,OAAO,EAAE,CAC1E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,cAAuB;IAClE,WAAW,CACT,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,KAAK,WAAW,MAAM,CAAC,KAAK,IAAI,OAAO,EAAE,CACxE,CAAC;IACF,cAAc,CAAC,SAAS,CAAC,cAAc,IAAI,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serial message queue for deaddrop communication
|
|
3
|
+
* Encapsulates module-level state into a testable class
|
|
4
|
+
*/
|
|
5
|
+
import type { DeadDropSender, DeadDropUser } from './colors.js';
|
|
6
|
+
/**
|
|
7
|
+
* Serial message queue for deaddrop communication
|
|
8
|
+
* Ensures messages are sent one at a time in order
|
|
9
|
+
*/
|
|
10
|
+
export declare class DeadDropQueue {
|
|
11
|
+
private sender;
|
|
12
|
+
private messageQueue;
|
|
13
|
+
private isProcessing;
|
|
14
|
+
private flushResolve;
|
|
15
|
+
/**
|
|
16
|
+
* Configure the sender function
|
|
17
|
+
* Call once at startup when --deaddrop is enabled
|
|
18
|
+
*/
|
|
19
|
+
configure(sender: DeadDropSender | null): void;
|
|
20
|
+
/**
|
|
21
|
+
* Enqueue a message for sending
|
|
22
|
+
*/
|
|
23
|
+
send(message: string, user: DeadDropUser): void;
|
|
24
|
+
/**
|
|
25
|
+
* Wait for all pending messages to be sent
|
|
26
|
+
* Call before process.exit to ensure delivery
|
|
27
|
+
*/
|
|
28
|
+
flush(): Promise<void>;
|
|
29
|
+
private processQueue;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Configure the deaddrop sender for all output functions
|
|
33
|
+
* Call once at startup when --deaddrop is enabled
|
|
34
|
+
*/
|
|
35
|
+
export declare function configureDeadDrop(sender: DeadDropSender | null): void;
|
|
36
|
+
/**
|
|
37
|
+
* Send a message to deaddrop if configured
|
|
38
|
+
*/
|
|
39
|
+
export declare function sendToDeadDrop(message: string, user: DeadDropUser): void;
|
|
40
|
+
/**
|
|
41
|
+
* Flush all pending deaddrop sends
|
|
42
|
+
* Call before process.exit to ensure all messages are sent
|
|
43
|
+
*/
|
|
44
|
+
export declare function flushDeadDrop(): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=deaddrop-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deaddrop-queue.d.ts","sourceRoot":"","sources":["../../src/output/deaddrop-queue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOhE;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,YAAY,CAA6B;IAEjD;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI;IAI9C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;IAO/C;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAWd,YAAY;CAiB3B;AAKD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAExE;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serial message queue for deaddrop communication
|
|
3
|
+
* Encapsulates module-level state into a testable class
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Serial message queue for deaddrop communication
|
|
7
|
+
* Ensures messages are sent one at a time in order
|
|
8
|
+
*/
|
|
9
|
+
export class DeadDropQueue {
|
|
10
|
+
sender = null;
|
|
11
|
+
messageQueue = [];
|
|
12
|
+
isProcessing = false;
|
|
13
|
+
flushResolve = null;
|
|
14
|
+
/**
|
|
15
|
+
* Configure the sender function
|
|
16
|
+
* Call once at startup when --deaddrop is enabled
|
|
17
|
+
*/
|
|
18
|
+
configure(sender) {
|
|
19
|
+
this.sender = sender;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Enqueue a message for sending
|
|
23
|
+
*/
|
|
24
|
+
send(message, user) {
|
|
25
|
+
if (this.sender) {
|
|
26
|
+
this.messageQueue.push({ content: message, user });
|
|
27
|
+
void this.processQueue();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Wait for all pending messages to be sent
|
|
32
|
+
* Call before process.exit to ensure delivery
|
|
33
|
+
*/
|
|
34
|
+
async flush() {
|
|
35
|
+
if (this.messageQueue.length === 0 && !this.isProcessing)
|
|
36
|
+
return;
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
this.flushResolve = resolve;
|
|
39
|
+
if (!this.isProcessing) {
|
|
40
|
+
void this.processQueue();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async processQueue() {
|
|
45
|
+
if (this.isProcessing || !this.sender)
|
|
46
|
+
return;
|
|
47
|
+
this.isProcessing = true;
|
|
48
|
+
let msg = this.messageQueue.shift();
|
|
49
|
+
while (msg) {
|
|
50
|
+
await this.sender(msg.content, msg.user);
|
|
51
|
+
msg = this.messageQueue.shift();
|
|
52
|
+
}
|
|
53
|
+
this.isProcessing = false;
|
|
54
|
+
if (this.flushResolve && this.messageQueue.length === 0) {
|
|
55
|
+
this.flushResolve();
|
|
56
|
+
this.flushResolve = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Singleton instance (maintains backward compatibility)
|
|
61
|
+
const defaultQueue = new DeadDropQueue();
|
|
62
|
+
/**
|
|
63
|
+
* Configure the deaddrop sender for all output functions
|
|
64
|
+
* Call once at startup when --deaddrop is enabled
|
|
65
|
+
*/
|
|
66
|
+
export function configureDeadDrop(sender) {
|
|
67
|
+
defaultQueue.configure(sender);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Send a message to deaddrop if configured
|
|
71
|
+
*/
|
|
72
|
+
export function sendToDeadDrop(message, user) {
|
|
73
|
+
defaultQueue.send(message, user);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Flush all pending deaddrop sends
|
|
77
|
+
* Call before process.exit to ensure all messages are sent
|
|
78
|
+
*/
|
|
79
|
+
export async function flushDeadDrop() {
|
|
80
|
+
return defaultQueue.flush();
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=deaddrop-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deaddrop-queue.js","sourceRoot":"","sources":["../../src/output/deaddrop-queue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;GAGG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,GAA0B,IAAI,CAAC;IACrC,YAAY,GAAoB,EAAE,CAAC;IACnC,YAAY,GAAG,KAAK,CAAC;IACrB,YAAY,GAAwB,IAAI,CAAC;IAEjD;;;OAGG;IACH,SAAS,CAAC,MAA6B;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,E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wD;AACxD,MAAM,YAAY,GAAG,IAAI,aAAa,EAAE,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA6B;IAC7D,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,IAAkB;IAChE,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { type ClaudeMessage } from '../types/claude.js';
|
|
5
5
|
import { type ActiveTask, type PendingTool, type Verbosity } from '../types/runner.js';
|
|
6
6
|
import type { Logger } from './logger.js';
|
|
7
|
+
import { type RunStats } from './stats.js';
|
|
7
8
|
/**
|
|
8
9
|
* State for tracking parallel tool calls and active tasks
|
|
9
10
|
*/
|
|
@@ -13,9 +14,31 @@ export interface FormatterState {
|
|
|
13
14
|
activeTask: ActiveTask | null;
|
|
14
15
|
toolStartTimes: Map<string, number>;
|
|
15
16
|
currentStep: number;
|
|
17
|
+
/** When true, step completion is not printed (caller handles it) */
|
|
18
|
+
suppressStepCompletion: boolean;
|
|
19
|
+
/** Duration from last result message (for caller to use) */
|
|
20
|
+
lastStepDurationMs: number | null;
|
|
21
|
+
/** Run statistics for current step */
|
|
22
|
+
stats: RunStats;
|
|
23
|
+
/** Overall run statistics (accumulated across steps) */
|
|
24
|
+
runStats: RunStats;
|
|
25
|
+
/** Step start time */
|
|
26
|
+
stepStartTime: number | null;
|
|
27
|
+
/** Task statistics (for nested task tracking) */
|
|
28
|
+
taskStats: RunStats | null;
|
|
29
|
+
/** Task start time */
|
|
30
|
+
taskStartTime: number | null;
|
|
16
31
|
}
|
|
17
32
|
export declare function createFormatterState(): FormatterState;
|
|
18
33
|
export declare function resetFormatterState(state: FormatterState): void;
|
|
34
|
+
/**
|
|
35
|
+
* Finalize step stats: merge into runStats and return step summary
|
|
36
|
+
*/
|
|
37
|
+
export declare function finalizeStepStats(state: FormatterState, stepDurationMs: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get the overall run stats summary
|
|
40
|
+
*/
|
|
41
|
+
export declare function getRunStatsSummary(state: FormatterState, runDurationMs: number): string;
|
|
19
42
|
/**
|
|
20
43
|
* Flush pending tools, grouping parallel calls
|
|
21
44
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,aAAa,EASnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,aAAa,EASnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAuB5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAQL,KAAK,QAAQ,EAEd,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,sBAAsB,EAAE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