@kody-ade/kody-engine 0.4.87 → 0.4.88

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/bin/kody.js +50 -1
  2. package/package.json +1 -1
package/dist/bin/kody.js CHANGED
@@ -877,7 +877,7 @@ var init_loadPriorArt = __esm({
877
877
  // package.json
878
878
  var package_default = {
879
879
  name: "@kody-ade/kody-engine",
880
- version: "0.4.87",
880
+ version: "0.4.88",
881
881
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
882
882
  license: "MIT",
883
883
  type: "module",
@@ -5321,6 +5321,23 @@ function editPrBase(prNumber, baseBranch, cwd) {
5321
5321
  return fail(err);
5322
5322
  }
5323
5323
  }
5324
+ function branchContains(leafHead, candidateHead, cwd) {
5325
+ if (leafHead === candidateHead) return { ok: true, value: true };
5326
+ try {
5327
+ const out = gh(
5328
+ [
5329
+ "api",
5330
+ `repos/{owner}/{repo}/compare/${encodeURIComponent(leafHead)}...${encodeURIComponent(candidateHead)}`,
5331
+ "--jq",
5332
+ ".ahead_by"
5333
+ ],
5334
+ { cwd }
5335
+ );
5336
+ return { ok: true, value: Number.parseInt(out.trim(), 10) === 0 };
5337
+ } catch (err) {
5338
+ return fail(err);
5339
+ }
5340
+ }
5324
5341
  function markPrReady(prNumber, cwd) {
5325
5342
  try {
5326
5343
  gh(["pr", "ready", String(prNumber)], { cwd });
@@ -6928,6 +6945,15 @@ function collectExpectedTests(raw) {
6928
6945
  }
6929
6946
 
6930
6947
  // src/scripts/finalizeGoal.ts
6948
+ function prIssueNumbers(pr) {
6949
+ const nums = new Set(extractClosesIssues(pr.body));
6950
+ const headMatch = pr.headRefName.match(/^(\d+)-/);
6951
+ if (headMatch) {
6952
+ const n = Number.parseInt(headMatch[1], 10);
6953
+ if (Number.isFinite(n)) nums.add(n);
6954
+ }
6955
+ return [...nums];
6956
+ }
6931
6957
  var finalizeGoal = async (ctx) => {
6932
6958
  const goal = ctx.data.goal;
6933
6959
  if (!goal) return;
@@ -6966,8 +6992,24 @@ var finalizeGoal = async (ctx) => {
6966
6992
  `[goal-tick] leaf PR #${leaf.number} is the deliverable (cumulative goal diff vs ${goal.defaultBranch}) \u2014 left open for human merge
6967
6993
  `
6968
6994
  );
6995
+ const uncarriedIssues = /* @__PURE__ */ new Set();
6969
6996
  const others = (goal.openTaskPrs ?? []).filter((p) => p.number !== leaf.number);
6970
6997
  for (const pr of others) {
6998
+ const contained = branchContains(leaf.headRefName, pr.headRefName, ctx.cwd);
6999
+ if (!contained.ok || contained.value !== true) {
7000
+ const why = contained.ok ? `commits on \`${pr.headRefName}\` are NOT reachable from the deliverable leaf \`${leaf.headRefName}\`` : `could not verify containment (${contained.error})`;
7001
+ process.stderr.write(
7002
+ `[goal-tick] finalizeGoal: NOT closing PR #${pr.number} \u2014 ${why}; leaving it open (broken stack)
7003
+ `
7004
+ );
7005
+ for (const n of prIssueNumbers(pr)) uncarriedIssues.add(n);
7006
+ commentOnIssue(
7007
+ pr.number,
7008
+ `\u26A0\uFE0F _Stacked-PR finalize: this PR's commits are **not** carried by the goal's deliverable PR #${leaf.number} (the stack chain was broken). Leaving this PR open so its work isn't lost \u2014 review and land it manually._`,
7009
+ ctx.cwd
7010
+ );
7011
+ continue;
7012
+ }
6971
7013
  process.stdout.write(`[goal-tick] closing intermediate stacked PR #${pr.number} (carried by deliverable leaf)
6972
7014
  `);
6973
7015
  const closed = closePr(
@@ -6982,6 +7024,13 @@ var finalizeGoal = async (ctx) => {
6982
7024
  }
6983
7025
  const openIssues = (goal.childTasks ?? []).filter((t) => t.state === "OPEN");
6984
7026
  for (const t of openIssues) {
7027
+ if (uncarriedIssues.has(t.number)) {
7028
+ process.stderr.write(
7029
+ `[goal-tick] finalizeGoal: NOT closing task issue #${t.number} \u2014 its PR's work is not carried by the deliverable (broken stack)
7030
+ `
7031
+ );
7032
+ continue;
7033
+ }
6985
7034
  process.stdout.write(`[goal-tick] closing task issue #${t.number} (goal finalized \u2014 carried by PR #${leaf.number})
6986
7035
  `);
6987
7036
  const closed = closeIssue(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.87",
3
+ "version": "0.4.88",
4
4
  "description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
5
5
  "license": "MIT",
6
6
  "type": "module",