@neriros/ralphy 2.16.3 → 2.16.4

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +31 -66
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -35029,8 +35029,8 @@ import { readFileSync as readFileSync2 } from "fs";
35029
35029
  import { resolve } from "path";
35030
35030
  function getVersion() {
35031
35031
  try {
35032
- if ("2.16.3")
35033
- return "2.16.3";
35032
+ if ("2.16.4")
35033
+ return "2.16.4";
35034
35034
  } catch {}
35035
35035
  const dirsToTry = [];
35036
35036
  try {
@@ -60607,57 +60607,9 @@ ${pe.stderr ?? ""}`;
60607
60607
  }
60608
60608
  }
60609
60609
  }
60610
- async function commitResidualChanges(ctx, maxAttempts) {
60611
- let hookFixAttempt = 0;
60612
- while (true) {
60613
- ctx.emit("committing", "git status");
60614
- let dirty = "";
60615
- try {
60616
- const status = await ctx.cmd.run(["git", "status", "--porcelain"], ctx.cwd);
60617
- dirty = status.stdout.trim();
60618
- } catch (err) {
60619
- ctx.log(`! git status failed for ${ctx.changeName}: ${err.message}`, "yellow");
60620
- break;
60621
- }
60622
- if (!dirty)
60623
- break;
60624
- try {
60625
- ctx.emit("committing", "git add -A");
60626
- await ctx.cmd.run(["git", "add", "-A"], ctx.cwd);
60627
- ctx.emit("committing", "git commit");
60628
- await ctx.cmd.run(["git", "commit", "-m", `chore(ralph): residual changes for ${ctx.changeName}`], ctx.cwd);
60629
- ctx.log(` committed residual changes for ${ctx.changeName}`, "gray");
60630
- break;
60631
- } catch (err) {
60632
- const e = err;
60633
- const detail = e.stderr?.trim() || e.message;
60634
- const combined = `${e.stdout ?? ""}
60635
- ${e.stderr ?? ""}`;
60636
- if (/nothing to commit/i.test(combined) || /empty git commit/i.test(combined))
60637
- break;
60638
- if (hookFixAttempt >= maxAttempts) {
60639
- ctx.log(`! commit rejected for ${ctx.changeName} after ${hookFixAttempt} hook-fix attempts (host pre-commit hook still failing) \u2014 worktree preserved at ${ctx.cwd}`, "red");
60640
- ctx.log(` detail: ${detail}`, "red");
60641
- return { gaveUp: true, hookFixAttempt };
60642
- }
60643
- hookFixAttempt += 1;
60644
- ctx.emit("commit-retry", `${hookFixAttempt}/${maxAttempts}`);
60645
- ctx.log(`! commit rejected for ${ctx.changeName} \u2014 prepending fix task and re-running loop (attempt ${hookFixAttempt}/${maxAttempts})`, "yellow");
60646
- ctx.log(` detail: ${detail}`, "yellow");
60647
- const retryCode = await runWorkerWithFixTask(ctx, "Fix host pre-commit hook rejection", `Committing residual changes was rejected by the host repo's pre-commit hook. ` + `Fix the underlying problem, then the commit will be retried.
60648
-
60649
- ` + combined.trim());
60650
- if (retryCode !== 0) {
60651
- ctx.log(`! worker re-run after commit rejection exited code ${retryCode} \u2014 giving up`, "red");
60652
- return { gaveUp: true, hookFixAttempt };
60653
- }
60654
- }
60655
- }
60656
- return { gaveUp: false, hookFixAttempt };
60657
- }
60658
- async function createPrWithRetry(ctx, issue, initialHookFixAttempt) {
60610
+ async function createPrWithRetry(ctx, issue) {
60659
60611
  const maxAttempts = ctx.cfg.maxCiFixAttempts;
60660
- let hookFixAttempt = initialHookFixAttempt;
60612
+ let hookFixAttempt = 0;
60661
60613
  let nonFfRebaseAttempted = false;
60662
60614
  let pr = null;
60663
60615
  while (true) {
@@ -60693,12 +60645,16 @@ ${re.stderr ?? ""}`;
60693
60645
  ctx.emit("rebasing", "conflicts detected \u2014 aborting + queueing fix task");
60694
60646
  try {
60695
60647
  await ctx.cmd.run(["git", "rebase", "--abort"], ctx.cwd);
60696
- } catch {}
60648
+ } catch (err2) {
60649
+ ctx.log(`! git rebase --abort failed (worktree may already be clean): ${err2.message}`, "yellow");
60650
+ }
60697
60651
  let conflictedFiles = "";
60698
60652
  try {
60699
60653
  const r = await ctx.cmd.run(["git", "diff", "--name-only", `HEAD..origin/${ctx.branch}`], ctx.cwd);
60700
60654
  conflictedFiles = r.stdout.trim();
60701
- } catch {}
60655
+ } catch (err2) {
60656
+ ctx.log(`! could not list conflicted files: ${err2.message}`, "yellow");
60657
+ }
60702
60658
  if (hookFixAttempt >= maxAttempts) {
60703
60659
  ctx.log(`! merge conflict on rebase of ${ctx.branch} after ${hookFixAttempt} attempts \u2014 worktree preserved at ${ctx.cwd}`, "red");
60704
60660
  ctx.log(` detail: ${reBlob.trim().split(`
@@ -60860,11 +60816,16 @@ async function runPostTask(input, deps) {
60860
60816
  emit,
60861
60817
  respawnWorker
60862
60818
  };
60863
- const { gaveUp: commitGaveUp, hookFixAttempt } = await commitResidualChanges(ctx, cfg.maxCiFixAttempts);
60864
- if (commitGaveUp) {
60865
- effectiveCode = PR_FAILED_EXIT;
60866
- } else {
60867
- const { pr, gaveUp: prGaveUp } = await createPrWithRetry(ctx, issue, hookFixAttempt);
60819
+ try {
60820
+ const status = await cmd.run(["git", "status", "--porcelain"], cwd2);
60821
+ if (status.stdout.trim()) {
60822
+ log2(`! ${changeName} has uncommitted changes after worker exit \u2014 the agent should commit everything before finishing. These changes will not be included in the PR.`, "yellow");
60823
+ }
60824
+ } catch (err) {
60825
+ log2(`! git status check failed for ${changeName}: ${err.message}`, "yellow");
60826
+ }
60827
+ {
60828
+ const { pr, gaveUp: prGaveUp } = await createPrWithRetry(ctx, issue);
60868
60829
  if (prGaveUp) {
60869
60830
  effectiveCode = PR_FAILED_EXIT;
60870
60831
  } else if (!pr) {
@@ -60887,7 +60848,9 @@ async function runPostTask(input, deps) {
60887
60848
  emit("teardown", cfg.teardownScript);
60888
60849
  try {
60889
60850
  await runScript("teardown", cfg.teardownScript, cwd2);
60890
- } catch {}
60851
+ } catch (err) {
60852
+ log2(`! teardown script threw: ${err.message}`, "yellow");
60853
+ }
60891
60854
  }
60892
60855
  if (useWorktree && cwd2 !== projectRoot) {
60893
60856
  emit("cleanup", "checking worktree safety");
@@ -71886,6 +71849,8 @@ function buildTaskPrompt(state, taskDir) {
71886
71849
 
71887
71850
  `;
71888
71851
  prompt += `Run \`bunx openspec validate ${state.name}\` before committing.
71852
+ `;
71853
+ prompt += `Commit all changed files yourself before finishing \u2014 stage files individually (e.g. \`git add path/to/file\`), never \`git add -A\` or \`git commit -am\`. Nothing is committed automatically after you exit.
71889
71854
  `;
71890
71855
  return prompt;
71891
71856
  }
@@ -72557,8 +72522,6 @@ function phaseColor(phase) {
72557
72522
  return "cyan";
72558
72523
  case "scaffolding":
72559
72524
  return "magenta";
72560
- case "committing":
72561
- case "commit-retry":
72562
72525
  case "pushing":
72563
72526
  case "push-retry":
72564
72527
  case "rebasing":
@@ -72583,8 +72546,6 @@ function workerBorderColor(phase) {
72583
72546
  case "working":
72584
72547
  case "scaffolding":
72585
72548
  return "cyan";
72586
- case "committing":
72587
- case "commit-retry":
72588
72549
  case "pushing":
72589
72550
  case "push-retry":
72590
72551
  case "rebasing":
@@ -72802,7 +72763,9 @@ function AgentMode({ args, projectRoot, statesDir, tasksDir }) {
72802
72763
  const json = await file.json();
72803
72764
  meta.iter = json.iteration ?? meta.iter;
72804
72765
  }
72805
- } catch {}
72766
+ } catch (err) {
72767
+ console.error(`Failed to read state file for worker '${changeName}' (may not exist yet):`, err);
72768
+ }
72806
72769
  if (meta.changeDir) {
72807
72770
  try {
72808
72771
  const tasksFile = Bun.file(join16(meta.changeDir, "tasks.md"));
@@ -72811,7 +72774,9 @@ function AgentMode({ args, projectRoot, statesDir, tasksDir }) {
72811
72774
  const match = text.match(/^- \[ \] (.+)$/m);
72812
72775
  meta.currentTask = match?.[1]?.trim() ?? null;
72813
72776
  }
72814
- } catch {}
72777
+ } catch (err) {
72778
+ console.error(`Failed to read tasks.md for worker '${changeName}' (may not exist yet):`, err);
72779
+ }
72815
72780
  }
72816
72781
  }
72817
72782
  if (!cancelled)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neriros/ralphy",
3
- "version": "2.16.3",
3
+ "version": "2.16.4",
4
4
  "description": "An iterative AI task execution framework. Orchestrates multi-phase autonomous work using Claude or Codex engines.",
5
5
  "keywords": [
6
6
  "agent",