krenk 0.1.13 → 0.1.14
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 +29 -104
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createRequire } from 'module'; const require = createRequire(import.met
|
|
|
5
5
|
import { program } from "commander";
|
|
6
6
|
import { readFileSync as readFileSync4 } from "fs";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
|
-
import { dirname, join as
|
|
8
|
+
import { dirname, join as join7 } from "path";
|
|
9
9
|
|
|
10
10
|
// src/commands/run.ts
|
|
11
11
|
import chalk3 from "chalk";
|
|
@@ -156,28 +156,9 @@ ${content}
|
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
// src/agents/spawner.ts
|
|
159
|
-
import { spawn
|
|
159
|
+
import { spawn } from "child_process";
|
|
160
160
|
import { EventEmitter } from "events";
|
|
161
|
-
import { writeFileSync, unlinkSync, mkdirSync as mkdirSync2 } from "fs";
|
|
162
|
-
import { tmpdir } from "os";
|
|
163
|
-
import { join as join2 } from "path";
|
|
164
161
|
var isWindows = process.platform === "win32";
|
|
165
|
-
var resolvedClaudePath = null;
|
|
166
|
-
function getClaudeBinary() {
|
|
167
|
-
if (resolvedClaudePath) return resolvedClaudePath;
|
|
168
|
-
try {
|
|
169
|
-
const cmd = isWindows ? "where claude" : "which claude";
|
|
170
|
-
const result = execFileSync(
|
|
171
|
-
isWindows ? "cmd" : "sh",
|
|
172
|
-
isWindows ? ["/c", cmd] : ["-c", cmd],
|
|
173
|
-
{ encoding: "utf-8", timeout: 5e3 }
|
|
174
|
-
).trim();
|
|
175
|
-
resolvedClaudePath = result.split("\n")[0].trim();
|
|
176
|
-
return resolvedClaudePath;
|
|
177
|
-
} catch {
|
|
178
|
-
return "claude";
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
162
|
var activeChildren = /* @__PURE__ */ new Set();
|
|
182
163
|
function killAllAgents() {
|
|
183
164
|
for (const child of activeChildren) {
|
|
@@ -244,39 +225,23 @@ function spawnClaudeAgent(opts) {
|
|
|
244
225
|
|
|
245
226
|
Your current task:
|
|
246
227
|
${opts.prompt}` : opts.prompt;
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
mkdirSync2(tempDir, { recursive: true });
|
|
251
|
-
if (isWindows) {
|
|
252
|
-
const promptFile = join2(tempDir, `prompt-${opts.role}-${Date.now()}.txt`);
|
|
253
|
-
writeFileSync(promptFile, fullPrompt, "utf-8");
|
|
254
|
-
promptArg = ["-p", `@${promptFile}`];
|
|
255
|
-
tempFiles.push(promptFile);
|
|
256
|
-
} else {
|
|
257
|
-
promptArg = ["-p", fullPrompt];
|
|
228
|
+
const args = [];
|
|
229
|
+
if (!isWindows) {
|
|
230
|
+
args.push("-p", fullPrompt);
|
|
258
231
|
}
|
|
259
|
-
|
|
260
|
-
...promptArg,
|
|
232
|
+
args.push(
|
|
261
233
|
"--output-format",
|
|
262
234
|
"stream-json",
|
|
263
235
|
"--max-turns",
|
|
264
236
|
String(opts.maxTurns || 50),
|
|
265
237
|
"--verbose",
|
|
266
238
|
"--dangerously-skip-permissions"
|
|
267
|
-
|
|
239
|
+
);
|
|
268
240
|
if (opts.model) {
|
|
269
241
|
args.push("--model", opts.model);
|
|
270
242
|
}
|
|
271
243
|
if (opts.systemPrompt) {
|
|
272
|
-
|
|
273
|
-
const sysFile = join2(tempDir, `sys-${opts.role}-${Date.now()}.txt`);
|
|
274
|
-
writeFileSync(sysFile, opts.systemPrompt, "utf-8");
|
|
275
|
-
args.push("--system-prompt", `@${sysFile}`);
|
|
276
|
-
tempFiles.push(sysFile);
|
|
277
|
-
} else {
|
|
278
|
-
args.push("--system-prompt", opts.systemPrompt);
|
|
279
|
-
}
|
|
244
|
+
args.push("--system-prompt", opts.systemPrompt);
|
|
280
245
|
}
|
|
281
246
|
if (opts.allowedTools?.length) {
|
|
282
247
|
args.push("--allowedTools", ...opts.allowedTools);
|
|
@@ -284,15 +249,19 @@ ${opts.prompt}` : opts.prompt;
|
|
|
284
249
|
if (opts.disallowedTools?.length) {
|
|
285
250
|
args.push("--disallowedTools", ...opts.disallowedTools);
|
|
286
251
|
}
|
|
287
|
-
const claudeBin = getClaudeBinary();
|
|
288
252
|
const startTime = Date.now();
|
|
289
|
-
const child = spawn(
|
|
253
|
+
const child = spawn("claude", args, {
|
|
290
254
|
env,
|
|
291
255
|
cwd: opts.cwd,
|
|
292
|
-
|
|
293
|
-
// Unix: detached
|
|
294
|
-
|
|
256
|
+
// Windows: pipe stdin for prompt, shell=true to resolve claude.cmd
|
|
257
|
+
// Unix: ignore stdin, detached for process group kills
|
|
258
|
+
stdio: [isWindows ? "pipe" : "ignore", "pipe", "pipe"],
|
|
259
|
+
...isWindows ? { shell: true } : { detached: true }
|
|
295
260
|
});
|
|
261
|
+
if (isWindows && child.stdin) {
|
|
262
|
+
child.stdin.write(fullPrompt);
|
|
263
|
+
child.stdin.end();
|
|
264
|
+
}
|
|
296
265
|
emitter.child = child;
|
|
297
266
|
activeChildren.add(child);
|
|
298
267
|
let stdout = "";
|
|
@@ -318,12 +287,6 @@ ${opts.prompt}` : opts.prompt;
|
|
|
318
287
|
});
|
|
319
288
|
child.on("close", (code) => {
|
|
320
289
|
activeChildren.delete(child);
|
|
321
|
-
for (const f of tempFiles) {
|
|
322
|
-
try {
|
|
323
|
-
unlinkSync(f);
|
|
324
|
-
} catch {
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
290
|
const duration = Math.round((Date.now() - startTime) / 1e3);
|
|
328
291
|
if (code !== 0 && stderr.trim()) {
|
|
329
292
|
emitter.emit("data", JSON.stringify({
|
|
@@ -3648,32 +3611,13 @@ import chalk11 from "chalk";
|
|
|
3648
3611
|
|
|
3649
3612
|
// src/ui/interactive.ts
|
|
3650
3613
|
import * as readline from "readline";
|
|
3651
|
-
import { spawn as spawnProcess2
|
|
3652
|
-
import { writeFileSync as writeFileSync4, unlinkSync as unlinkSync2, mkdirSync as mkdirSync5 } from "fs";
|
|
3653
|
-
import { tmpdir as tmpdir2 } from "os";
|
|
3654
|
-
import { join as join7 } from "path";
|
|
3614
|
+
import { spawn as spawnProcess2 } from "child_process";
|
|
3655
3615
|
import chalk10 from "chalk";
|
|
3656
3616
|
import gradient2 from "gradient-string";
|
|
3657
3617
|
import figlet2 from "figlet";
|
|
3658
3618
|
import boxen2 from "boxen";
|
|
3659
3619
|
import ora2 from "ora";
|
|
3660
3620
|
var isWindows3 = process.platform === "win32";
|
|
3661
|
-
var _claudeBin = null;
|
|
3662
|
-
function getClaudeBin() {
|
|
3663
|
-
if (_claudeBin) return _claudeBin;
|
|
3664
|
-
try {
|
|
3665
|
-
const cmd = isWindows3 ? "where claude" : "which claude";
|
|
3666
|
-
const result = execFileSync2(
|
|
3667
|
-
isWindows3 ? "cmd" : "sh",
|
|
3668
|
-
isWindows3 ? ["/c", cmd] : ["-c", cmd],
|
|
3669
|
-
{ encoding: "utf-8", timeout: 5e3 }
|
|
3670
|
-
).trim();
|
|
3671
|
-
_claudeBin = result.split("\n")[0].trim();
|
|
3672
|
-
return _claudeBin;
|
|
3673
|
-
} catch {
|
|
3674
|
-
return "claude";
|
|
3675
|
-
}
|
|
3676
|
-
}
|
|
3677
3621
|
var TEAM_PRESETS = [
|
|
3678
3622
|
{
|
|
3679
3623
|
label: "Full Team",
|
|
@@ -3967,32 +3911,25 @@ Rules:
|
|
|
3967
3911
|
spinner.text = phases[phaseIdx];
|
|
3968
3912
|
}
|
|
3969
3913
|
}, 3e3);
|
|
3970
|
-
const
|
|
3971
|
-
|
|
3972
|
-
if (isWindows3) {
|
|
3973
|
-
const tempDir = join7(tmpdir2(), "krenk-prompts");
|
|
3974
|
-
mkdirSync5(tempDir, { recursive: true });
|
|
3975
|
-
const pFile = join7(tempDir, `refine-${Date.now()}.txt`);
|
|
3976
|
-
writeFileSync4(pFile, refinementPrompt, "utf-8");
|
|
3977
|
-
promptArgs = ["-p", `@${pFile}`];
|
|
3978
|
-
tempFiles.push(pFile);
|
|
3979
|
-
} else {
|
|
3980
|
-
promptArgs = ["-p", refinementPrompt];
|
|
3981
|
-
}
|
|
3982
|
-
const child = spawnProcess2(getClaudeBin(), [
|
|
3983
|
-
...promptArgs,
|
|
3914
|
+
const spawnArgs = [
|
|
3915
|
+
...isWindows3 ? [] : ["-p", refinementPrompt],
|
|
3984
3916
|
"--output-format",
|
|
3985
3917
|
"stream-json",
|
|
3986
3918
|
"--verbose",
|
|
3987
3919
|
"--max-turns",
|
|
3988
3920
|
"1",
|
|
3989
3921
|
"--dangerously-skip-permissions"
|
|
3990
|
-
]
|
|
3922
|
+
];
|
|
3923
|
+
const child = spawnProcess2("claude", spawnArgs, {
|
|
3991
3924
|
env,
|
|
3992
3925
|
cwd: process.cwd(),
|
|
3993
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
3994
|
-
...isWindows3 ? {} : {}
|
|
3926
|
+
stdio: [isWindows3 ? "pipe" : "ignore", "pipe", "pipe"],
|
|
3927
|
+
...isWindows3 ? { shell: true } : {}
|
|
3995
3928
|
});
|
|
3929
|
+
if (isWindows3 && child.stdin) {
|
|
3930
|
+
child.stdin.write(refinementPrompt);
|
|
3931
|
+
child.stdin.end();
|
|
3932
|
+
}
|
|
3996
3933
|
let stdout = "";
|
|
3997
3934
|
let stderr = "";
|
|
3998
3935
|
let lineBuffer = "";
|
|
@@ -4026,12 +3963,6 @@ Rules:
|
|
|
4026
3963
|
child.on("close", (code) => {
|
|
4027
3964
|
clearInterval(phaseTimer);
|
|
4028
3965
|
clearTimeout(timeout);
|
|
4029
|
-
for (const f of tempFiles) {
|
|
4030
|
-
try {
|
|
4031
|
-
unlinkSync2(f);
|
|
4032
|
-
} catch {
|
|
4033
|
-
}
|
|
4034
|
-
}
|
|
4035
3966
|
if (code === 0 && stdout.trim()) {
|
|
4036
3967
|
resolve(stdout);
|
|
4037
3968
|
} else {
|
|
@@ -4041,12 +3972,6 @@ Rules:
|
|
|
4041
3972
|
child.on("error", (err) => {
|
|
4042
3973
|
clearInterval(phaseTimer);
|
|
4043
3974
|
clearTimeout(timeout);
|
|
4044
|
-
for (const f of tempFiles) {
|
|
4045
|
-
try {
|
|
4046
|
-
unlinkSync2(f);
|
|
4047
|
-
} catch {
|
|
4048
|
-
}
|
|
4049
|
-
}
|
|
4050
3975
|
reject(err);
|
|
4051
3976
|
});
|
|
4052
3977
|
});
|
|
@@ -4422,7 +4347,7 @@ async function resumeCommand() {
|
|
|
4422
4347
|
|
|
4423
4348
|
// src/index.ts
|
|
4424
4349
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4425
|
-
var pkg = JSON.parse(readFileSync4(
|
|
4350
|
+
var pkg = JSON.parse(readFileSync4(join7(__dirname, "..", "package.json"), "utf-8"));
|
|
4426
4351
|
program.name("krenk").description(
|
|
4427
4352
|
"Multi-agent software engineering orchestrator powered by Claude Code"
|
|
4428
4353
|
).version(pkg.version).option("--resume", "Resume a previous interrupted or failed run").action(async (opts) => {
|