@groupchatai/claude-runner 0.1.0 → 0.2.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/dist/index.js +24 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -120,13 +120,26 @@ Due: ${new Date(detail.task.dueDate).toLocaleDateString()}`);
|
|
|
120
120
|
);
|
|
121
121
|
return parts.join("\n");
|
|
122
122
|
}
|
|
123
|
+
var C = {
|
|
124
|
+
reset: "\x1B[0m",
|
|
125
|
+
dim: "\x1B[2m",
|
|
126
|
+
white: "\x1B[97m",
|
|
127
|
+
grey: "\x1B[90m",
|
|
128
|
+
green: "\x1B[32m",
|
|
129
|
+
red: "\x1B[31m",
|
|
130
|
+
pid: "\x1B[38;2;193;95;60m"
|
|
131
|
+
};
|
|
132
|
+
function pidTag(pid) {
|
|
133
|
+
return ` ${C.pid}[pid ${pid}]${C.reset}`;
|
|
134
|
+
}
|
|
123
135
|
function formatStreamEvent(event, pid) {
|
|
124
|
-
const
|
|
136
|
+
const tag = pidTag(pid);
|
|
125
137
|
switch (event.type) {
|
|
126
138
|
case "system":
|
|
127
139
|
if (event.subtype === "init") {
|
|
128
|
-
let line = `${
|
|
140
|
+
let line = `${tag} ${C.dim}session started`;
|
|
129
141
|
if (event.session_id) line += ` (${event.session_id})`;
|
|
142
|
+
line += C.reset;
|
|
130
143
|
return line;
|
|
131
144
|
}
|
|
132
145
|
return null;
|
|
@@ -137,20 +150,20 @@ function formatStreamEvent(event, pid) {
|
|
|
137
150
|
for (const block of blocks) {
|
|
138
151
|
if (block.type === "text" && block.text) {
|
|
139
152
|
for (const line of block.text.split("\n")) {
|
|
140
|
-
if (line.trim()) parts.push(`${
|
|
153
|
+
if (line.trim()) parts.push(`${tag} ${C.white}${line}${C.reset}`);
|
|
141
154
|
}
|
|
142
155
|
} else if (block.type === "tool_use" && block.name) {
|
|
143
156
|
let detail = block.name;
|
|
144
157
|
const input = block.input;
|
|
145
158
|
if (input) {
|
|
146
159
|
if (typeof input.file_path === "string") {
|
|
147
|
-
detail += ` \u2192 ${input.file_path}`;
|
|
160
|
+
detail += ` ${C.dim}\u2192${C.grey} ${input.file_path}`;
|
|
148
161
|
} else if (typeof input.command === "string") {
|
|
149
162
|
const cmd = input.command.length > 80 ? input.command.slice(0, 77) + "\u2026" : input.command;
|
|
150
|
-
detail += ` \u2192 ${cmd}`;
|
|
163
|
+
detail += ` ${C.dim}\u2192${C.grey} ${cmd}`;
|
|
151
164
|
}
|
|
152
165
|
}
|
|
153
|
-
parts.push(`${
|
|
166
|
+
parts.push(`${tag} ${C.grey}${detail}${C.reset}`);
|
|
154
167
|
}
|
|
155
168
|
}
|
|
156
169
|
return parts.length > 0 ? parts.join("\n") : null;
|
|
@@ -161,11 +174,11 @@ function formatStreamEvent(event, pid) {
|
|
|
161
174
|
const lines = [];
|
|
162
175
|
if (event.cost_usd !== void 0 || event.total_cost_usd !== void 0) {
|
|
163
176
|
const cost = event.cost_usd ?? event.total_cost_usd;
|
|
164
|
-
lines.push(`${
|
|
177
|
+
lines.push(`${tag} ${C.dim}cost: $${cost?.toFixed(4)}${C.reset}`);
|
|
165
178
|
}
|
|
166
179
|
if (event.result) {
|
|
167
180
|
const preview = event.result.length > 120 ? event.result.slice(0, 117) + "\u2026" : event.result;
|
|
168
|
-
lines.push(`${
|
|
181
|
+
lines.push(`${tag} ${C.green}\u2713${C.reset} ${C.white}${preview}${C.reset}`);
|
|
169
182
|
}
|
|
170
183
|
return lines.length > 0 ? lines.join("\n") : null;
|
|
171
184
|
}
|
|
@@ -257,7 +270,7 @@ function spawnClaudeCode(prompt, config, runOptions) {
|
|
|
257
270
|
const formatted = formatStreamEvent(event, pid);
|
|
258
271
|
if (formatted) console.log(formatted);
|
|
259
272
|
} catch {
|
|
260
|
-
console.log(
|
|
273
|
+
console.log(`${pidTag(pid)} ${C.dim}${trimmed}${C.reset}`);
|
|
261
274
|
}
|
|
262
275
|
}
|
|
263
276
|
});
|
|
@@ -265,7 +278,7 @@ function spawnClaudeCode(prompt, config, runOptions) {
|
|
|
265
278
|
errChunks.push(data);
|
|
266
279
|
if (config.verbose) {
|
|
267
280
|
const text = data.toString("utf-8").trimEnd();
|
|
268
|
-
if (text) console.error(
|
|
281
|
+
if (text) console.error(`${pidTag(pid)} ${C.dim}${text}${C.reset}`);
|
|
269
282
|
}
|
|
270
283
|
});
|
|
271
284
|
child.on("error", (err) => reject(new Error(`Failed to spawn claude: ${err.message}`)));
|
|
@@ -277,7 +290,7 @@ function spawnClaudeCode(prompt, config, runOptions) {
|
|
|
277
290
|
const formatted = formatStreamEvent(event, pid);
|
|
278
291
|
if (formatted) console.log(formatted);
|
|
279
292
|
} catch {
|
|
280
|
-
console.log(
|
|
293
|
+
console.log(`${pidTag(pid)} ${C.dim}${lineBuf.trim()}${C.reset}`);
|
|
281
294
|
}
|
|
282
295
|
}
|
|
283
296
|
const rawOutput = Buffer.concat(chunks).toString("utf-8");
|