@shakecodeslikecray/whiterose 1.0.2 → 1.0.3

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/cli/index.js CHANGED
@@ -4329,7 +4329,18 @@ function loadAccumulatedBugs(cwd) {
4329
4329
  }
4330
4330
  stored.bugs = stored.bugs.map((b) => ({ ...b, kind: b.kind || "bug" }));
4331
4331
  return stored;
4332
- } catch {
4332
+ } catch (error) {
4333
+ const backupPath = `${bugsPath}.corrupted.${Date.now()}`;
4334
+ try {
4335
+ const corruptedContent = readFileSync(bugsPath, "utf-8");
4336
+ writeFileSync(backupPath, corruptedContent);
4337
+ console.warn(`Warning: ${BUGS_FILENAME} is corrupted and could not be parsed.`);
4338
+ console.warn(`Corrupted file backed up to: ${backupPath}`);
4339
+ console.warn("Bug history has been reset. Previous bugs will appear as new.");
4340
+ } catch {
4341
+ console.warn(`Warning: ${BUGS_FILENAME} is corrupted and could not be parsed.`);
4342
+ console.warn("Bug history has been reset. Previous bugs will appear as new.");
4343
+ }
4333
4344
  return {
4334
4345
  version: STORAGE_VERSION,
4335
4346
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6323,73 +6334,111 @@ In: ${bug.file}:${bug.line}`
6323
6334
  async function runAgenticFix(bug, config, projectDir) {
6324
6335
  const providerCommand = getProviderCommand(config.provider);
6325
6336
  const prompt = buildAgenticFixPrompt(bug);
6326
- const args = [];
6327
- if (config.provider === "claude-code") {
6328
- args.push("-p", prompt, "--dangerously-skip-permissions");
6329
- } else if (config.provider === "gemini") {
6330
- args.push("-p", prompt);
6331
- } else if (config.provider === "aider") {
6332
- args.push("--message", prompt, bug.file);
6333
- } else if (config.provider === "codex") ; else {
6334
- args.push("-p", prompt);
6335
- }
6337
+ const controller = new AbortController();
6338
+ const timeoutId = setTimeout(() => controller.abort(), 3e5);
6336
6339
  let stdout = "";
6337
6340
  let stderr = "";
6338
- if (config.provider === "codex") {
6339
- const tempDir = mkdtempSync(join(tmpdir(), "whiterose-fix-"));
6340
- const outputFile = join(tempDir, "output.txt");
6341
- try {
6341
+ try {
6342
+ if (config.provider === "codex") {
6343
+ const tempDir = mkdtempSync(join(tmpdir(), "whiterose-fix-"));
6344
+ const outputFile = join(tempDir, "output.txt");
6345
+ try {
6346
+ const result = await execa(
6347
+ providerCommand,
6348
+ [
6349
+ "exec",
6350
+ "--full-auto",
6351
+ // Allow workspace writes without approval prompts
6352
+ "--skip-git-repo-check",
6353
+ "-C",
6354
+ projectDir,
6355
+ // Set working directory for codex
6356
+ "-o",
6357
+ outputFile,
6358
+ "-"
6359
+ // Read prompt from stdin
6360
+ ],
6361
+ {
6362
+ cwd: projectDir,
6363
+ input: prompt,
6364
+ // Pass prompt via stdin
6365
+ timeout: 3e5,
6366
+ env: { ...process.env, NO_COLOR: "1" },
6367
+ reject: false,
6368
+ cancelSignal: controller.signal
6369
+ }
6370
+ );
6371
+ stderr = result.stderr || "";
6372
+ if (existsSync(outputFile)) {
6373
+ try {
6374
+ stdout = readFileSync(outputFile, "utf-8");
6375
+ } catch {
6376
+ stdout = result.stdout || "";
6377
+ }
6378
+ } else {
6379
+ stdout = result.stdout || "";
6380
+ }
6381
+ } finally {
6382
+ try {
6383
+ rmSync(tempDir, { recursive: true, force: true });
6384
+ } catch {
6385
+ }
6386
+ }
6387
+ } else if (config.provider === "claude-code") {
6342
6388
  const result = await execa(
6343
6389
  providerCommand,
6344
- [
6345
- "exec",
6346
- "--full-auto",
6347
- // Allow workspace writes without approval prompts
6348
- "--skip-git-repo-check",
6349
- "-C",
6350
- projectDir,
6351
- // Set working directory for codex
6352
- "-o",
6353
- outputFile,
6354
- "-"
6355
- // Read prompt from stdin
6356
- ],
6390
+ ["--dangerously-skip-permissions", "-p"],
6357
6391
  {
6358
6392
  cwd: projectDir,
6359
6393
  input: prompt,
6360
- // Pass prompt via stdin
6394
+ // Pass prompt via stdin (Claude reads from stdin when no prompt arg provided)
6361
6395
  timeout: 3e5,
6362
6396
  env: { ...process.env, NO_COLOR: "1" },
6363
- reject: false
6397
+ reject: false,
6398
+ cancelSignal: controller.signal
6364
6399
  }
6365
6400
  );
6401
+ stdout = result.stdout || "";
6402
+ stderr = result.stderr || "";
6403
+ } else if (config.provider === "gemini") {
6404
+ const result = await execa(providerCommand, ["-p", prompt], {
6405
+ cwd: projectDir,
6406
+ timeout: 3e5,
6407
+ env: { ...process.env, NO_COLOR: "1" },
6408
+ reject: false,
6409
+ stdin: "ignore",
6410
+ // Prevent stdin hangs
6411
+ cancelSignal: controller.signal
6412
+ });
6413
+ stdout = result.stdout || "";
6414
+ stderr = result.stderr || "";
6415
+ } else if (config.provider === "aider") {
6416
+ const result = await execa(providerCommand, ["--message", prompt, bug.file], {
6417
+ cwd: projectDir,
6418
+ timeout: 3e5,
6419
+ env: { ...process.env, NO_COLOR: "1" },
6420
+ reject: false,
6421
+ stdin: "ignore",
6422
+ // Prevent stdin hangs
6423
+ cancelSignal: controller.signal
6424
+ });
6425
+ stdout = result.stdout || "";
6426
+ stderr = result.stderr || "";
6427
+ } else {
6428
+ const result = await execa(providerCommand, ["-p", prompt], {
6429
+ cwd: projectDir,
6430
+ timeout: 3e5,
6431
+ env: { ...process.env, NO_COLOR: "1" },
6432
+ reject: false,
6433
+ stdin: "ignore",
6434
+ // Prevent stdin hangs
6435
+ cancelSignal: controller.signal
6436
+ });
6437
+ stdout = result.stdout || "";
6366
6438
  stderr = result.stderr || "";
6367
- if (existsSync(outputFile)) {
6368
- try {
6369
- stdout = readFileSync(outputFile, "utf-8");
6370
- } catch {
6371
- stdout = result.stdout || "";
6372
- }
6373
- } else {
6374
- stdout = result.stdout || "";
6375
- }
6376
- } finally {
6377
- try {
6378
- rmSync(tempDir, { recursive: true, force: true });
6379
- } catch {
6380
- }
6381
6439
  }
6382
- } else {
6383
- const result = await execa(providerCommand, args, {
6384
- cwd: projectDir,
6385
- timeout: 3e5,
6386
- // 5 minute timeout for agentic operations
6387
- env: { ...process.env, NO_COLOR: "1" },
6388
- reject: false
6389
- // Don't throw on non-zero exit
6390
- });
6391
- stdout = result.stdout || "";
6392
- stderr = result.stderr || "";
6440
+ } finally {
6441
+ clearTimeout(timeoutId);
6393
6442
  }
6394
6443
  if (stderr) {
6395
6444
  const lowerStderr = stderr.toLowerCase();