@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
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script line parser
|
|
3
|
+
*
|
|
4
|
+
* Parses the new script syntax:
|
|
5
|
+
* - prompt("text") -> $var
|
|
6
|
+
* - prompt(<<EOF ... EOF) -> $var
|
|
7
|
+
* - command("name", ["arg1", "arg2"]) -> $var
|
|
8
|
+
*/
|
|
9
|
+
/** Get character at position, or empty string if out of bounds */
|
|
10
|
+
function charAt(input, pos) {
|
|
11
|
+
return input[pos] ?? '';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse a quoted string, handling escape sequences
|
|
15
|
+
* Returns the parsed string and the position after the closing quote
|
|
16
|
+
*/
|
|
17
|
+
export function parseQuotedString(input, startPos) {
|
|
18
|
+
if (charAt(input, startPos) !== '"') {
|
|
19
|
+
throw new Error(`Expected opening quote at position ${startPos}`);
|
|
20
|
+
}
|
|
21
|
+
let result = '';
|
|
22
|
+
let i = startPos + 1;
|
|
23
|
+
while (i < input.length) {
|
|
24
|
+
const char = charAt(input, i);
|
|
25
|
+
if (char === '\\' && i + 1 < input.length) {
|
|
26
|
+
// Escape sequence
|
|
27
|
+
const next = charAt(input, i + 1);
|
|
28
|
+
if (next === 'n') {
|
|
29
|
+
result += '\n';
|
|
30
|
+
i += 2;
|
|
31
|
+
}
|
|
32
|
+
else if (next === 't') {
|
|
33
|
+
result += '\t';
|
|
34
|
+
i += 2;
|
|
35
|
+
}
|
|
36
|
+
else if (next === '"') {
|
|
37
|
+
result += '"';
|
|
38
|
+
i += 2;
|
|
39
|
+
}
|
|
40
|
+
else if (next === '\\') {
|
|
41
|
+
result += '\\';
|
|
42
|
+
i += 2;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Unknown escape, keep as-is
|
|
46
|
+
result += char;
|
|
47
|
+
i++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (char === '"') {
|
|
51
|
+
// End of string
|
|
52
|
+
return { value: result, endPos: i + 1 };
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
result += char;
|
|
56
|
+
i++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
throw new Error('Unterminated string: missing closing quote');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parse a heredoc block
|
|
63
|
+
* Input should start at << position
|
|
64
|
+
* Returns the content and position after the closing delimiter
|
|
65
|
+
*/
|
|
66
|
+
export function parseHeredoc(input, startPos) {
|
|
67
|
+
if (input.slice(startPos, startPos + 2) !== '<<') {
|
|
68
|
+
throw new Error(`Expected << at position ${startPos}`);
|
|
69
|
+
}
|
|
70
|
+
// Find delimiter (word after <<)
|
|
71
|
+
let delimStart = startPos + 2;
|
|
72
|
+
while (delimStart < input.length && charAt(input, delimStart) === ' ') {
|
|
73
|
+
delimStart++;
|
|
74
|
+
}
|
|
75
|
+
let delimEnd = delimStart;
|
|
76
|
+
while (delimEnd < input.length && /\w/.test(charAt(input, delimEnd))) {
|
|
77
|
+
delimEnd++;
|
|
78
|
+
}
|
|
79
|
+
if (delimEnd === delimStart) {
|
|
80
|
+
throw new Error('Heredoc requires a delimiter (e.g., <<EOF)');
|
|
81
|
+
}
|
|
82
|
+
const delimiter = input.slice(delimStart, delimEnd);
|
|
83
|
+
// Find the newline after delimiter
|
|
84
|
+
let contentStart = delimEnd;
|
|
85
|
+
while (contentStart < input.length && charAt(input, contentStart) !== '\n') {
|
|
86
|
+
contentStart++;
|
|
87
|
+
}
|
|
88
|
+
contentStart++; // Skip the newline
|
|
89
|
+
// Find closing delimiter (must be on its own line)
|
|
90
|
+
const closingPattern = new RegExp(`^${delimiter}\\s*$`, 'm');
|
|
91
|
+
const remaining = input.slice(contentStart);
|
|
92
|
+
const match = closingPattern.exec(remaining);
|
|
93
|
+
if (!match) {
|
|
94
|
+
throw new Error(`Heredoc missing closing delimiter: ${delimiter}`);
|
|
95
|
+
}
|
|
96
|
+
const content = remaining.slice(0, match.index);
|
|
97
|
+
// Remove trailing newline if present
|
|
98
|
+
const trimmedContent = content.endsWith('\n')
|
|
99
|
+
? content.slice(0, -1)
|
|
100
|
+
: content;
|
|
101
|
+
const endPos = contentStart + match.index + match[0].length;
|
|
102
|
+
return { value: trimmedContent, endPos };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Parse an array of strings: ["arg1", "arg2"]
|
|
106
|
+
*/
|
|
107
|
+
export function parseStringArray(input, startPos) {
|
|
108
|
+
if (charAt(input, startPos) !== '[') {
|
|
109
|
+
throw new Error(`Expected [ at position ${startPos}`);
|
|
110
|
+
}
|
|
111
|
+
const values = [];
|
|
112
|
+
let i = startPos + 1;
|
|
113
|
+
// Skip whitespace
|
|
114
|
+
while (i < input.length && /\s/.test(charAt(input, i)))
|
|
115
|
+
i++;
|
|
116
|
+
// Empty array
|
|
117
|
+
if (charAt(input, i) === ']') {
|
|
118
|
+
return { values: [], endPos: i + 1 };
|
|
119
|
+
}
|
|
120
|
+
while (i < input.length) {
|
|
121
|
+
// Skip whitespace
|
|
122
|
+
while (i < input.length && /\s/.test(charAt(input, i)))
|
|
123
|
+
i++;
|
|
124
|
+
if (charAt(input, i) === ']') {
|
|
125
|
+
return { values, endPos: i + 1 };
|
|
126
|
+
}
|
|
127
|
+
// Parse string element
|
|
128
|
+
if (charAt(input, i) !== '"') {
|
|
129
|
+
throw new Error(`Expected string in array at position ${i}`);
|
|
130
|
+
}
|
|
131
|
+
const { value, endPos } = parseQuotedString(input, i);
|
|
132
|
+
values.push(value);
|
|
133
|
+
i = endPos;
|
|
134
|
+
// Skip whitespace
|
|
135
|
+
while (i < input.length && /\s/.test(charAt(input, i)))
|
|
136
|
+
i++;
|
|
137
|
+
// Expect comma or closing bracket
|
|
138
|
+
if (charAt(input, i) === ',') {
|
|
139
|
+
i++;
|
|
140
|
+
}
|
|
141
|
+
else if (charAt(input, i) !== ']') {
|
|
142
|
+
throw new Error(`Expected , or ] at position ${i}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
throw new Error('Unterminated array: missing ]');
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Parse capture syntax: -> $varname
|
|
149
|
+
* Returns variable name (without $) or undefined
|
|
150
|
+
*/
|
|
151
|
+
export function parseCapture(input, startPos) {
|
|
152
|
+
let i = startPos;
|
|
153
|
+
// Skip whitespace
|
|
154
|
+
while (i < input.length && /\s/.test(charAt(input, i)))
|
|
155
|
+
i++;
|
|
156
|
+
// Check for ->
|
|
157
|
+
if (input.slice(i, i + 2) !== '->') {
|
|
158
|
+
return { endPos: i };
|
|
159
|
+
}
|
|
160
|
+
i += 2;
|
|
161
|
+
// Skip whitespace
|
|
162
|
+
while (i < input.length && /\s/.test(charAt(input, i)))
|
|
163
|
+
i++;
|
|
164
|
+
// Expect $
|
|
165
|
+
if (charAt(input, i) !== '$') {
|
|
166
|
+
throw new Error(`Expected $ after -> at position ${i}`);
|
|
167
|
+
}
|
|
168
|
+
i++;
|
|
169
|
+
// Parse variable name
|
|
170
|
+
let varName = '';
|
|
171
|
+
while (i < input.length && /\w/.test(charAt(input, i))) {
|
|
172
|
+
varName += charAt(input, i);
|
|
173
|
+
i++;
|
|
174
|
+
}
|
|
175
|
+
if (!varName) {
|
|
176
|
+
throw new Error('Variable name required after $');
|
|
177
|
+
}
|
|
178
|
+
return { capture: varName, endPos: i };
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Parse a prompt line: prompt("text") or prompt(<<EOF...EOF)
|
|
182
|
+
*/
|
|
183
|
+
export function parsePromptLine(input) {
|
|
184
|
+
const trimmed = input.trim();
|
|
185
|
+
if (!trimmed.startsWith('prompt(')) {
|
|
186
|
+
throw new Error('Expected prompt(');
|
|
187
|
+
}
|
|
188
|
+
let pos = 7; // After 'prompt('
|
|
189
|
+
// Skip whitespace
|
|
190
|
+
while (pos < trimmed.length && /\s/.test(charAt(trimmed, pos)))
|
|
191
|
+
pos++;
|
|
192
|
+
let text;
|
|
193
|
+
let endPos;
|
|
194
|
+
if (charAt(trimmed, pos) === '"') {
|
|
195
|
+
// Quoted string
|
|
196
|
+
const result = parseQuotedString(trimmed, pos);
|
|
197
|
+
text = result.value;
|
|
198
|
+
endPos = result.endPos;
|
|
199
|
+
}
|
|
200
|
+
else if (trimmed.slice(pos, pos + 2) === '<<') {
|
|
201
|
+
// Heredoc
|
|
202
|
+
const result = parseHeredoc(trimmed, pos);
|
|
203
|
+
text = result.value;
|
|
204
|
+
endPos = result.endPos;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
throw new Error('Expected quoted string or heredoc after prompt(');
|
|
208
|
+
}
|
|
209
|
+
// Skip whitespace
|
|
210
|
+
while (endPos < trimmed.length && /\s/.test(charAt(trimmed, endPos)))
|
|
211
|
+
endPos++;
|
|
212
|
+
// Expect closing paren
|
|
213
|
+
if (charAt(trimmed, endPos) !== ')') {
|
|
214
|
+
throw new Error(`Expected ) at position ${endPos}`);
|
|
215
|
+
}
|
|
216
|
+
endPos++;
|
|
217
|
+
// Parse optional capture
|
|
218
|
+
const { capture } = parseCapture(trimmed, endPos);
|
|
219
|
+
const result = { type: 'prompt', text };
|
|
220
|
+
if (capture)
|
|
221
|
+
result.capture = capture;
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Parse a command line: command("name") or command("name", ["args"])
|
|
226
|
+
*/
|
|
227
|
+
export function parseCommandLine(input) {
|
|
228
|
+
const trimmed = input.trim();
|
|
229
|
+
if (!trimmed.startsWith('command(')) {
|
|
230
|
+
throw new Error('Expected command(');
|
|
231
|
+
}
|
|
232
|
+
let pos = 8; // After 'command('
|
|
233
|
+
// Skip whitespace
|
|
234
|
+
while (pos < trimmed.length && /\s/.test(charAt(trimmed, pos)))
|
|
235
|
+
pos++;
|
|
236
|
+
// Parse command name
|
|
237
|
+
if (charAt(trimmed, pos) !== '"') {
|
|
238
|
+
throw new Error('Expected quoted command name');
|
|
239
|
+
}
|
|
240
|
+
const nameResult = parseQuotedString(trimmed, pos);
|
|
241
|
+
const name = nameResult.value;
|
|
242
|
+
pos = nameResult.endPos;
|
|
243
|
+
// Skip whitespace
|
|
244
|
+
while (pos < trimmed.length && /\s/.test(charAt(trimmed, pos)))
|
|
245
|
+
pos++;
|
|
246
|
+
let args = [];
|
|
247
|
+
// Check for comma (args follow)
|
|
248
|
+
if (charAt(trimmed, pos) === ',') {
|
|
249
|
+
pos++;
|
|
250
|
+
// Skip whitespace
|
|
251
|
+
while (pos < trimmed.length && /\s/.test(charAt(trimmed, pos)))
|
|
252
|
+
pos++;
|
|
253
|
+
// Parse args array
|
|
254
|
+
const argsResult = parseStringArray(trimmed, pos);
|
|
255
|
+
args = argsResult.values;
|
|
256
|
+
pos = argsResult.endPos;
|
|
257
|
+
}
|
|
258
|
+
// Skip whitespace
|
|
259
|
+
while (pos < trimmed.length && /\s/.test(charAt(trimmed, pos)))
|
|
260
|
+
pos++;
|
|
261
|
+
// Expect closing paren
|
|
262
|
+
if (charAt(trimmed, pos) !== ')') {
|
|
263
|
+
throw new Error(`Expected ) at position ${pos}`);
|
|
264
|
+
}
|
|
265
|
+
pos++;
|
|
266
|
+
// Parse optional capture
|
|
267
|
+
const { capture } = parseCapture(trimmed, pos);
|
|
268
|
+
const result = { type: 'command', name, args };
|
|
269
|
+
if (capture)
|
|
270
|
+
result.capture = capture;
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Parse a single script line
|
|
275
|
+
*/
|
|
276
|
+
export function parseScriptLine(line) {
|
|
277
|
+
const trimmed = line.trim();
|
|
278
|
+
if (trimmed.startsWith('prompt(')) {
|
|
279
|
+
return parsePromptLine(trimmed);
|
|
280
|
+
}
|
|
281
|
+
else if (trimmed.startsWith('command(')) {
|
|
282
|
+
return parseCommandLine(trimmed);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
throw new Error(`Unknown script line type: ${trimmed.slice(0, 20)}...`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Check if a line is a comment or empty
|
|
290
|
+
*/
|
|
291
|
+
export function isCommentOrEmpty(line) {
|
|
292
|
+
const trimmed = line.trim();
|
|
293
|
+
return trimmed === '' || trimmed.startsWith('#');
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Parse script content into lines, handling multi-line heredocs
|
|
297
|
+
* Returns raw line strings (not parsed) for further processing
|
|
298
|
+
*/
|
|
299
|
+
export function extractScriptLines(content) {
|
|
300
|
+
const lines = [];
|
|
301
|
+
const contentLines = content.split('\n');
|
|
302
|
+
let i = 0;
|
|
303
|
+
while (i < contentLines.length) {
|
|
304
|
+
const line = contentLines[i] ?? '';
|
|
305
|
+
const trimmed = line.trim();
|
|
306
|
+
// Skip comments and empty lines
|
|
307
|
+
if (isCommentOrEmpty(trimmed)) {
|
|
308
|
+
i++;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
// Check for heredoc
|
|
312
|
+
if (trimmed.includes('<<')) {
|
|
313
|
+
// Find the delimiter
|
|
314
|
+
const heredocMatch = /<<(\w+)/.exec(trimmed);
|
|
315
|
+
if (heredocMatch) {
|
|
316
|
+
const delimiter = heredocMatch[1];
|
|
317
|
+
let fullLine = line;
|
|
318
|
+
i++;
|
|
319
|
+
// Collect lines until we find the closing delimiter
|
|
320
|
+
while (i < contentLines.length) {
|
|
321
|
+
const nextLine = contentLines[i] ?? '';
|
|
322
|
+
fullLine += '\n' + nextLine;
|
|
323
|
+
if (nextLine.trim() === delimiter) {
|
|
324
|
+
i++;
|
|
325
|
+
// Also capture closing paren (and optional capture) if on next line(s)
|
|
326
|
+
if (i < contentLines.length) {
|
|
327
|
+
const parenLine = contentLines[i] ?? '';
|
|
328
|
+
const parenTrimmed = parenLine.trim();
|
|
329
|
+
// Match ) or ) -> $var
|
|
330
|
+
if (parenTrimmed === ')' || parenTrimmed.startsWith(') ->')) {
|
|
331
|
+
fullLine += '\n' + parenLine;
|
|
332
|
+
i++;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
i++;
|
|
338
|
+
}
|
|
339
|
+
lines.push(fullLine);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// Regular single line
|
|
344
|
+
lines.push(line);
|
|
345
|
+
i++;
|
|
346
|
+
}
|
|
347
|
+
return lines;
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/script/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,kEAAkE;AAClE,SAAS,MAAM,CAAC,KAAa,EAAE,GAAW;IACxC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAa,EACb,QAAgB;IAEhB,IAAI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC;IAErB,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAE9B,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC1C,kBAAkB;YAClB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAClC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACjB,MAAM,IAAI,IAAI,CAAC;gBACf,CAAC,IAAI,CAAC,CAAC;YACT,CAAC;iBAAM,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACxB,MAAM,IAAI,IAAI,CAAC;gBACf,CAAC,IAAI,CAAC,CAAC;YACT,CAAC;iBAAM,IAAI,IAAI,K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CAAC;4BACxC,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;4BACtC,uBAAuB;4BACvB,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gCAC5D,QAAQ,IAAI,IAAI,GAAG,SAAS,CAAC;gCAC7B,CAAC,EAAE,CAAC;4BACN,CAAC;wBACH,CAAC;wBACD,MAAM;oBACR,CAAC;oBACD,CAAC,EAAE,CAAC;gBACN,CAAC;gBAED,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACrB,SAAS;YACX,CAAC;QACH,CAAC;QAED,sBAAsB;QACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,EAAE,CAAC;IACN,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for parsed script lines
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A prompt line: prompt("text") -> $var
|
|
6
|
+
*/
|
|
7
|
+
export interface PromptLine {
|
|
8
|
+
type: 'prompt';
|
|
9
|
+
text: string;
|
|
10
|
+
capture?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A command line: command("name", ["arg1", "arg2"]) -> $var
|
|
14
|
+
*/
|
|
15
|
+
export interface CommandLine {
|
|
16
|
+
type: 'command';
|
|
17
|
+
name: string;
|
|
18
|
+
args: string[];
|
|
19
|
+
capture?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Union of all script line types
|
|
23
|
+
*/
|
|
24
|
+
export type ScriptLine = PromptLine | CommandLine;
|
|
25
|
+
/**
|
|
26
|
+
* Result of parsing a script file
|
|
27
|
+
*/
|
|
28
|
+
export interface ParsedScript {
|
|
29
|
+
lines: ScriptLine[];
|
|
30
|
+
frontmatter: ScriptFrontmatter;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Frontmatter metadata from script files
|
|
34
|
+
*/
|
|
35
|
+
export interface ScriptFrontmatter {
|
|
36
|
+
model?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
argumentHint?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Variable store for captured outputs
|
|
42
|
+
*/
|
|
43
|
+
export interface VariableStore {
|
|
44
|
+
/** Named captures: $name -> value */
|
|
45
|
+
named: Map<string, string>;
|
|
46
|
+
/** Last output: $_ */
|
|
47
|
+
last: string;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/script/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,EAAE,iBAAiB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/script/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable store and substitution for script execution
|
|
3
|
+
*/
|
|
4
|
+
import type { VariableStore } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create an empty variable store
|
|
7
|
+
*/
|
|
8
|
+
export declare function createVariableStore(): VariableStore;
|
|
9
|
+
/**
|
|
10
|
+
* Capture output into the variable store
|
|
11
|
+
* Updates both the named variable (if provided) and $_
|
|
12
|
+
*/
|
|
13
|
+
export declare function captureOutput(store: VariableStore, output: string, varName?: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get capture log message for [RUNNER] output
|
|
16
|
+
*/
|
|
17
|
+
export declare function getCaptureLogMessage(output: string, varName?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Substitute variables in a string
|
|
20
|
+
* Handles: $_, $varname, $1, $2, etc.
|
|
21
|
+
*/
|
|
22
|
+
export declare function substituteVariables(text: string, store: VariableStore, scriptArgs?: string[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get list of variables being substituted (for logging)
|
|
25
|
+
*/
|
|
26
|
+
export declare function getSubstitutionList(text: string, store: VariableStore): string[];
|
|
27
|
+
//# sourceMappingURL=variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/script/variables.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAKnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAQN;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAM7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,EACpB,UAAU,GAAE,MAAM,EAAO,GACxB,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,MAAM,EAAE,CAgBV"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable store and substitution for script execution
|
|
3
|
+
*/
|
|
4
|
+
import { formatSize } from '../utils/formatting.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create an empty variable store
|
|
7
|
+
*/
|
|
8
|
+
export function createVariableStore() {
|
|
9
|
+
return {
|
|
10
|
+
named: new Map(),
|
|
11
|
+
last: '',
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Capture output into the variable store
|
|
16
|
+
* Updates both the named variable (if provided) and $_
|
|
17
|
+
*/
|
|
18
|
+
export function captureOutput(store, output, varName) {
|
|
19
|
+
// Always update $_
|
|
20
|
+
store.last = output;
|
|
21
|
+
// Update named variable if provided
|
|
22
|
+
if (varName) {
|
|
23
|
+
store.named.set(varName, output);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get capture log message for [RUNNER] output
|
|
28
|
+
*/
|
|
29
|
+
export function getCaptureLogMessage(output, varName) {
|
|
30
|
+
const size = formatSize(output.length);
|
|
31
|
+
if (varName) {
|
|
32
|
+
return `$${varName} captured (${size})`;
|
|
33
|
+
}
|
|
34
|
+
return `$_ captured (${size})`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Substitute variables in a string
|
|
38
|
+
* Handles: $_, $varname, $1, $2, etc.
|
|
39
|
+
*/
|
|
40
|
+
export function substituteVariables(text, store, scriptArgs = []) {
|
|
41
|
+
let result = text;
|
|
42
|
+
// Substitute $_ (last output)
|
|
43
|
+
result = result.replace(/\$_/g, store.last);
|
|
44
|
+
// Substitute $ARGUMENTS BEFORE named variables (otherwise regex catches it)
|
|
45
|
+
result = result.replace(/\$ARGUMENTS/g, scriptArgs.join(' '));
|
|
46
|
+
// Substitute positional args ($1, $2, etc.) BEFORE named variables
|
|
47
|
+
for (const [i, arg] of scriptArgs.entries()) {
|
|
48
|
+
result = result.replace(new RegExp(`\\$${i + 1}`, 'g'), arg);
|
|
49
|
+
}
|
|
50
|
+
// Remove any remaining unmatched $N placeholders
|
|
51
|
+
result = result.replace(/\$\d+/g, '');
|
|
52
|
+
// Substitute named variables ($varname) LAST
|
|
53
|
+
// Match $word but not $1, $2, etc. (already handled above)
|
|
54
|
+
result = result.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g, (_match, name) => store.named.get(name) ?? '');
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get list of variables being substituted (for logging)
|
|
59
|
+
*/
|
|
60
|
+
export function getSubstitutionList(text, store) {
|
|
61
|
+
const vars = [];
|
|
62
|
+
// Check for $_
|
|
63
|
+
if (text.includes('$_') && store.last) {
|
|
64
|
+
vars.push('$_');
|
|
65
|
+
}
|
|
66
|
+
// Check for named variables
|
|
67
|
+
for (const name of store.named.keys()) {
|
|
68
|
+
if (text.includes(`$${name}`)) {
|
|
69
|
+
vars.push(`$${name}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return vars;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../src/script/variables.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OA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AAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/D,CAAC;IAED,iDAAiD;IACjD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAEtC,6CAA6C;IAC7C,2DAA2D;IAC3D,MAAM,GAAG,MAAM,CAAC,OAAO,CACrB,6BAA6B,EAC7B,CAAC,MAAM,EAAE,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CACtD,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,KAAoB;IAEpB,MAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,eAAe;IACf,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,4BAA4B;IAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,17 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Template loading and variable substitution for commands and scripts
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
5
|
+
* Frontmatter metadata from template files
|
|
6
|
+
*/
|
|
7
|
+
export interface TemplateFrontmatter {
|
|
8
|
+
model?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
argumentHint?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Result of loading a command template
|
|
14
|
+
*/
|
|
15
|
+
export interface CommandTemplate {
|
|
16
|
+
prompt: string;
|
|
17
|
+
frontmatter: TemplateFrontmatter;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Result of loading a script template
|
|
21
|
+
*/
|
|
22
|
+
export interface ScriptTemplate {
|
|
23
|
+
lines: string[];
|
|
24
|
+
frontmatter: TemplateFrontmatter;
|
|
25
|
+
}
|
|
26
|
+
export type CommandFrontmatter = TemplateFrontmatter;
|
|
27
|
+
/**
|
|
28
|
+
* Parse YAML frontmatter from markdown content
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseFrontmatter(content: string): {
|
|
31
|
+
frontmatter: TemplateFrontmatter;
|
|
32
|
+
body: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Strip YAML frontmatter from markdown content (legacy helper)
|
|
7
36
|
*/
|
|
8
37
|
export declare function stripFrontmatter(content: string): string;
|
|
9
38
|
/**
|
|
10
|
-
* Load a command template
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
39
|
+
* Load a command template from .claude/commands/<name>.md
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadCommandTemplate(commandName: string, cmdArgs: string[]): CommandTemplate;
|
|
42
|
+
/**
|
|
43
|
+
* Load a script template and substitute arguments
|
|
15
44
|
*/
|
|
16
|
-
export declare function
|
|
45
|
+
export declare function loadScriptTemplate(scriptFile: string, scriptArgs: string[]): ScriptTemplate;
|
|
17
46
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/templates/command.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/templates/command.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAUD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAGD,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG;IACjD,WAAW,EAAE,mBAAmB,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd,CA8BA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAwCD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,GAChB,eAAe,CAgBjB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAAE,GACnB,cAAc,CAchB"}
|