krenk 0.1.12 → 0.1.13

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 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 join7 } from "path";
8
+ import { dirname, join as join9 } from "path";
9
9
 
10
10
  // src/commands/run.ts
11
11
  import chalk3 from "chalk";
@@ -156,9 +156,28 @@ ${content}
156
156
  };
157
157
 
158
158
  // src/agents/spawner.ts
159
- import { spawn } from "child_process";
159
+ import { spawn, execFileSync } 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";
161
164
  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
+ }
162
181
  var activeChildren = /* @__PURE__ */ new Set();
163
182
  function killAllAgents() {
164
183
  for (const child of activeChildren) {
@@ -225,9 +244,20 @@ function spawnClaudeAgent(opts) {
225
244
 
226
245
  Your current task:
227
246
  ${opts.prompt}` : opts.prompt;
247
+ const tempFiles = [];
248
+ let promptArg;
249
+ const tempDir = join2(tmpdir(), "krenk-prompts");
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];
258
+ }
228
259
  const args = [
229
- "-p",
230
- fullPrompt,
260
+ ...promptArg,
231
261
  "--output-format",
232
262
  "stream-json",
233
263
  "--max-turns",
@@ -239,7 +269,14 @@ ${opts.prompt}` : opts.prompt;
239
269
  args.push("--model", opts.model);
240
270
  }
241
271
  if (opts.systemPrompt) {
242
- args.push("--system-prompt", opts.systemPrompt);
272
+ if (isWindows) {
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
+ }
243
280
  }
244
281
  if (opts.allowedTools?.length) {
245
282
  args.push("--allowedTools", ...opts.allowedTools);
@@ -247,14 +284,14 @@ ${opts.prompt}` : opts.prompt;
247
284
  if (opts.disallowedTools?.length) {
248
285
  args.push("--disallowedTools", ...opts.disallowedTools);
249
286
  }
287
+ const claudeBin = getClaudeBinary();
250
288
  const startTime = Date.now();
251
- const child = spawn("claude", args, {
289
+ const child = spawn(claudeBin, args, {
252
290
  env,
253
291
  cwd: opts.cwd,
254
292
  stdio: ["ignore", "pipe", "pipe"],
255
- // Windows: shell=true resolves .cmd/.bat extensions (e.g. claude.cmd from npm)
256
293
  // Unix: detached=true creates process group for clean tree kills
257
- ...isWindows ? { shell: true } : { detached: true }
294
+ ...isWindows ? {} : { detached: true }
258
295
  });
259
296
  emitter.child = child;
260
297
  activeChildren.add(child);
@@ -281,6 +318,12 @@ ${opts.prompt}` : opts.prompt;
281
318
  });
282
319
  child.on("close", (code) => {
283
320
  activeChildren.delete(child);
321
+ for (const f of tempFiles) {
322
+ try {
323
+ unlinkSync(f);
324
+ } catch {
325
+ }
326
+ }
284
327
  const duration = Math.round((Date.now() - startTime) / 1e3);
285
328
  if (code !== 0 && stderr.trim()) {
286
329
  emitter.emit("data", JSON.stringify({
@@ -3605,13 +3648,32 @@ import chalk11 from "chalk";
3605
3648
 
3606
3649
  // src/ui/interactive.ts
3607
3650
  import * as readline from "readline";
3608
- import { spawn as spawnProcess2 } from "child_process";
3651
+ import { spawn as spawnProcess2, execFileSync as execFileSync2 } from "child_process";
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";
3609
3655
  import chalk10 from "chalk";
3610
3656
  import gradient2 from "gradient-string";
3611
3657
  import figlet2 from "figlet";
3612
3658
  import boxen2 from "boxen";
3613
3659
  import ora2 from "ora";
3614
3660
  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
+ }
3615
3677
  var TEAM_PRESETS = [
3616
3678
  {
3617
3679
  label: "Full Team",
@@ -3905,9 +3967,20 @@ Rules:
3905
3967
  spinner.text = phases[phaseIdx];
3906
3968
  }
3907
3969
  }, 3e3);
3908
- const child = spawnProcess2("claude", [
3909
- "-p",
3910
- refinementPrompt,
3970
+ const tempFiles = [];
3971
+ let promptArgs;
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,
3911
3984
  "--output-format",
3912
3985
  "stream-json",
3913
3986
  "--verbose",
@@ -3918,7 +3991,7 @@ Rules:
3918
3991
  env,
3919
3992
  cwd: process.cwd(),
3920
3993
  stdio: ["ignore", "pipe", "pipe"],
3921
- ...isWindows3 ? { shell: true } : {}
3994
+ ...isWindows3 ? {} : {}
3922
3995
  });
3923
3996
  let stdout = "";
3924
3997
  let stderr = "";
@@ -3953,6 +4026,12 @@ Rules:
3953
4026
  child.on("close", (code) => {
3954
4027
  clearInterval(phaseTimer);
3955
4028
  clearTimeout(timeout);
4029
+ for (const f of tempFiles) {
4030
+ try {
4031
+ unlinkSync2(f);
4032
+ } catch {
4033
+ }
4034
+ }
3956
4035
  if (code === 0 && stdout.trim()) {
3957
4036
  resolve(stdout);
3958
4037
  } else {
@@ -3962,6 +4041,12 @@ Rules:
3962
4041
  child.on("error", (err) => {
3963
4042
  clearInterval(phaseTimer);
3964
4043
  clearTimeout(timeout);
4044
+ for (const f of tempFiles) {
4045
+ try {
4046
+ unlinkSync2(f);
4047
+ } catch {
4048
+ }
4049
+ }
3965
4050
  reject(err);
3966
4051
  });
3967
4052
  });
@@ -4337,7 +4422,7 @@ async function resumeCommand() {
4337
4422
 
4338
4423
  // src/index.ts
4339
4424
  var __dirname = dirname(fileURLToPath(import.meta.url));
4340
- var pkg = JSON.parse(readFileSync4(join7(__dirname, "..", "package.json"), "utf-8"));
4425
+ var pkg = JSON.parse(readFileSync4(join9(__dirname, "..", "package.json"), "utf-8"));
4341
4426
  program.name("krenk").description(
4342
4427
  "Multi-agent software engineering orchestrator powered by Claude Code"
4343
4428
  ).version(pkg.version).option("--resume", "Resume a previous interrupted or failed run").action(async (opts) => {