@kody-ade/kody-engine 0.4.539 → 0.4.541

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 +146 -139
  2. package/package.json +1 -1
package/dist/bin/kody.js CHANGED
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@kody-ade/kody-engine",
18
- version: "0.4.539",
18
+ version: "0.4.541",
19
19
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
20
20
  license: "MIT",
21
21
  type: "module",
@@ -17869,113 +17869,6 @@ var init_runFlow = __esm({
17869
17869
  }
17870
17870
  });
17871
17871
 
17872
- // src/scripts/syncFlow.ts
17873
- import { execFileSync as execFileSync16 } from "child_process";
17874
- function restoreDone(prNumber, cwd) {
17875
- try {
17876
- setKodyLabel(prNumber, DONE2, cwd);
17877
- } catch {
17878
- }
17879
- }
17880
- function bail2(ctx, prNumber, reason) {
17881
- ctx.skipAgent = true;
17882
- ctx.output.exitCode = 1;
17883
- ctx.output.reason = reason;
17884
- const runUrl = getRunUrl();
17885
- const runSuffix = runUrl ? ` ([logs](${runUrl}))` : "";
17886
- tryPostPr3(prNumber, `\u274C kody sync could not complete${runSuffix}: ${reason}`, ctx.cwd);
17887
- }
17888
- function revParseHead(cwd) {
17889
- try {
17890
- return execFileSync16("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).toString().trim();
17891
- } catch {
17892
- return "";
17893
- }
17894
- }
17895
- function pushBranch(branch, cwd) {
17896
- const result = pushWithRetry({ cwd: cwd ?? process.cwd(), branch, setUpstream: true });
17897
- if (!result.ok) {
17898
- throw new Error(result.reason);
17899
- }
17900
- }
17901
- function tryPostPr3(prNumber, body, cwd) {
17902
- try {
17903
- postPrReviewComment(prNumber, body, cwd);
17904
- } catch {
17905
- }
17906
- }
17907
- var DONE2, syncFlow;
17908
- var init_syncFlow = __esm({
17909
- "src/scripts/syncFlow.ts"() {
17910
- "use strict";
17911
- init_branch();
17912
- init_gha();
17913
- init_issue();
17914
- init_lifecycleLabels();
17915
- init_pushWithRetry();
17916
- DONE2 = {
17917
- label: "kody:done",
17918
- color: "0e8a16",
17919
- description: "kody: PR ready for human review/merge"
17920
- };
17921
- syncFlow = async (ctx, _profile, args) => {
17922
- const announceOnSuccess = Boolean(args?.announceOnSuccess);
17923
- const prNumber = ctx.args.pr;
17924
- const pr = getPr(prNumber, ctx.cwd);
17925
- if (pr.state !== "OPEN") {
17926
- bail2(ctx, prNumber, `PR #${prNumber} is not OPEN (state: ${pr.state})`);
17927
- return;
17928
- }
17929
- ctx.data.pr = pr;
17930
- if (announceOnSuccess) {
17931
- ctx.data.commentTargetType = "pr";
17932
- ctx.data.commentTargetNumber = prNumber;
17933
- }
17934
- checkoutPrBranch(prNumber, ctx.cwd);
17935
- ctx.data.branch = getCurrentBranch(ctx.cwd);
17936
- const baseBranch = pr.baseRefName || ctx.config.git.defaultBranch;
17937
- ctx.data.baseBranch = baseBranch;
17938
- const headBefore = revParseHead(ctx.cwd);
17939
- const mergeStatus = mergeBase(baseBranch, ctx.cwd);
17940
- if (mergeStatus === "error") {
17941
- bail2(ctx, prNumber, `failed to merge origin/${baseBranch} (non-conflict error); see runner log`);
17942
- return;
17943
- }
17944
- if (mergeStatus === "conflict") {
17945
- bail2(
17946
- ctx,
17947
- prNumber,
17948
- `merge from origin/${baseBranch} produced conflicts \u2014 run \`@kody resolve\` to let kody resolve them`
17949
- );
17950
- return;
17951
- }
17952
- const headAfter = revParseHead(ctx.cwd);
17953
- if (headAfter === headBefore) {
17954
- ctx.data.syncResult = "noop";
17955
- if (announceOnSuccess) {
17956
- ctx.output.exitCode = 0;
17957
- ctx.output.reason = `already up to date with origin/${baseBranch}`;
17958
- restoreDone(prNumber, ctx.cwd);
17959
- }
17960
- return;
17961
- }
17962
- try {
17963
- pushBranch(ctx.data.branch, ctx.cwd);
17964
- } catch (err) {
17965
- const msg = err instanceof Error ? err.message : String(err);
17966
- bail2(ctx, prNumber, `merge succeeded but push failed: ${msg}`);
17967
- return;
17968
- }
17969
- ctx.data.syncResult = "merged";
17970
- if (announceOnSuccess) {
17971
- ctx.output.exitCode = 0;
17972
- ctx.output.reason = `merged origin/${baseBranch} into ${ctx.data.branch}`;
17973
- restoreDone(prNumber, ctx.cwd);
17974
- }
17975
- };
17976
- }
17977
- });
17978
-
17979
17872
  // src/scripts/prepareCapabilityDelivery.ts
17980
17873
  var prepareCapabilityDelivery;
17981
17874
  var init_prepareCapabilityDelivery = __esm({
@@ -17983,7 +17876,6 @@ var init_prepareCapabilityDelivery = __esm({
17983
17876
  "use strict";
17984
17877
  init_capabilityDelivery();
17985
17878
  init_runFlow();
17986
- init_syncFlow();
17987
17879
  prepareCapabilityDelivery = async (ctx, profile) => {
17988
17880
  const target = capabilityDeliveryTarget(ctx.data.capabilityInput);
17989
17881
  if (!target) {
@@ -17996,7 +17888,6 @@ var init_prepareCapabilityDelivery = __esm({
17996
17888
  }
17997
17889
  ctx.data.commentTargetType = "pr";
17998
17890
  ctx.data.commentTargetNumber = target.number;
17999
- await syncFlow(ctx, profile);
18000
17891
  };
18001
17892
  }
18002
17893
  });
@@ -18352,7 +18243,7 @@ var init_publishReport = __esm({
18352
18243
  });
18353
18244
 
18354
18245
  // src/scripts/recordClassification.ts
18355
- import { execFileSync as execFileSync17 } from "child_process";
18246
+ import { execFileSync as execFileSync16 } from "child_process";
18356
18247
  function parseClassification(prSummary) {
18357
18248
  if (!prSummary) return null;
18358
18249
  const classMatch = prSummary.match(/classification:\s*(feature|bug|spec|chore)\b/i);
@@ -18364,7 +18255,7 @@ function parseClassification(prSummary) {
18364
18255
  }
18365
18256
  function tryAuditComment(issueNumber, body, cwd) {
18366
18257
  try {
18367
- execFileSync17("gh", ["issue", "comment", String(issueNumber), "--body", body], {
18258
+ execFileSync16("gh", ["issue", "comment", String(issueNumber), "--body", body], {
18368
18259
  cwd,
18369
18260
  timeout: API_TIMEOUT_MS5,
18370
18261
  stdio: ["ignore", "pipe", "pipe"]
@@ -18461,7 +18352,16 @@ var init_requireDeliveryArtifacts = __esm({
18461
18352
  if (ctx.data.agentDone !== true) return;
18462
18353
  const commitResult = ctx.data.commitResult;
18463
18354
  const hasCommits = ctx.data.hasCommitsAhead === true;
18464
- if (!commitResult?.committed && !hasCommits) return;
18355
+ if (ctx.data.jobDelivery === "pull-request" && (!commitResult?.committed || !commitResult.pushed)) {
18356
+ const reason2 = "pull-request delivery produced no commit";
18357
+ ctx.data.agentFailureReason = reason2;
18358
+ ctx.output.exitCode = 4;
18359
+ ctx.output.reason = reason2;
18360
+ return;
18361
+ }
18362
+ if (!commitResult?.committed && !hasCommits) {
18363
+ return;
18364
+ }
18465
18365
  const commitMessage = String(ctx.data.commitMessage ?? "").trim();
18466
18366
  const prSummary = String(ctx.data.prSummary ?? "").trim();
18467
18367
  const missing = [];
@@ -18584,7 +18484,7 @@ var init_resolveArtifacts = __esm({
18584
18484
  });
18585
18485
 
18586
18486
  // src/scripts/resolveFlow.ts
18587
- import { execFileSync as execFileSync18 } from "child_process";
18487
+ import { execFileSync as execFileSync17 } from "child_process";
18588
18488
  function buildPreferBlock(prefer, baseBranch) {
18589
18489
  if (prefer !== "ours" && prefer !== "theirs") return "";
18590
18490
  const keepSide = prefer === "ours" ? "HEAD (this PR branch)" : `origin/${baseBranch} (base branch)`;
@@ -18604,7 +18504,7 @@ function buildPreferBlock(prefer, baseBranch) {
18604
18504
  }
18605
18505
  function getConflictedFiles(cwd) {
18606
18506
  try {
18607
- const out = execFileSync18("git", ["diff", "--name-only", "--diff-filter=U"], {
18507
+ const out = execFileSync17("git", ["diff", "--name-only", "--diff-filter=U"], {
18608
18508
  encoding: "utf-8",
18609
18509
  cwd,
18610
18510
  env: { ...process.env, HUSKY: "0" }
@@ -18619,7 +18519,7 @@ function getConflictMarkersPreview(files, cwd, maxBytes = CONFLICT_DIFF_MAX_BYTE
18619
18519
  let total = 0;
18620
18520
  for (const f of files) {
18621
18521
  try {
18622
- const content = execFileSync18("cat", [f], { encoding: "utf-8", cwd }).toString();
18522
+ const content = execFileSync17("cat", [f], { encoding: "utf-8", cwd }).toString();
18623
18523
  const snippet = `### ${f}
18624
18524
 
18625
18525
  \`\`\`
@@ -18634,7 +18534,7 @@ ${content.slice(0, 6e3)}
18634
18534
  }
18635
18535
  return chunks.join("\n");
18636
18536
  }
18637
- function tryPostPr4(prNumber, body, cwd) {
18537
+ function tryPostPr3(prNumber, body, cwd) {
18638
18538
  try {
18639
18539
  postPrReviewComment(prNumber, body, cwd);
18640
18540
  } catch {
@@ -18643,12 +18543,12 @@ function tryPostPr4(prNumber, body, cwd) {
18643
18543
  function pushEmptyCommit(branch, cwd) {
18644
18544
  const env = { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" };
18645
18545
  try {
18646
- execFileSync18(
18546
+ execFileSync17(
18647
18547
  "git",
18648
18548
  ["commit", "--allow-empty", "-m", "chore: kody resolve refresh \u2014 empty commit to recompute mergeable status"],
18649
18549
  { cwd, env, stdio: ["ignore", "pipe", "pipe"] }
18650
18550
  );
18651
- execFileSync18("git", ["push", "-u", "origin", branch], {
18551
+ execFileSync17("git", ["push", "-u", "origin", branch], {
18652
18552
  cwd,
18653
18553
  env,
18654
18554
  stdio: ["ignore", "pipe", "pipe"]
@@ -18686,14 +18586,14 @@ var init_resolveFlow = __esm({
18686
18586
  ctx.output.exitCode = 0;
18687
18587
  ctx.output.reason = `PR #${prNumber} is mergeable (no conflicts) \u2014 nothing to resolve`;
18688
18588
  ctx.skipAgent = true;
18689
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18589
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18690
18590
  return;
18691
18591
  }
18692
18592
  if (ghStatus.status === "BLOCKED") {
18693
18593
  ctx.output.exitCode = 0;
18694
18594
  ctx.output.reason = `PR #${prNumber} is mergeable but blocked by checks/reviews (mergeStateStatus=${ghStatus.mergeStateStatus}) \u2014 nothing for resolve to do`;
18695
18595
  ctx.skipAgent = true;
18696
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18596
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18697
18597
  return;
18698
18598
  }
18699
18599
  checkoutPrBranch(prNumber, ctx.cwd);
@@ -18705,20 +18605,20 @@ var init_resolveFlow = __esm({
18705
18605
  ctx.output.exitCode = 0;
18706
18606
  ctx.output.reason = pushed ? `local merge clean despite GitHub reporting CONFLICTING \u2014 pushed empty commit to force re-evaluation` : `local merge clean despite GitHub reporting CONFLICTING \u2014 couldn't refresh GitHub cache (push failed)`;
18707
18607
  ctx.skipAgent = true;
18708
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18608
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18709
18609
  return;
18710
18610
  }
18711
18611
  ctx.output.exitCode = 0;
18712
18612
  ctx.output.reason = `already up to date with origin/${baseBranch} \u2014 nothing to resolve`;
18713
18613
  ctx.skipAgent = true;
18714
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18614
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18715
18615
  return;
18716
18616
  }
18717
18617
  if (mergeStatus === "error") {
18718
18618
  ctx.output.exitCode = 99;
18719
18619
  ctx.output.reason = `failed to merge origin/${baseBranch} (non-conflict error); see runner log`;
18720
18620
  ctx.skipAgent = true;
18721
- tryPostPr4(prNumber, `\u26A0\uFE0F kody resolve FAILED: ${ctx.output.reason}`, ctx.cwd);
18621
+ tryPostPr3(prNumber, `\u26A0\uFE0F kody resolve FAILED: ${ctx.output.reason}`, ctx.cwd);
18722
18622
  return;
18723
18623
  }
18724
18624
  const conflictedFiles = getConflictedFiles(ctx.cwd);
@@ -18733,7 +18633,7 @@ var init_resolveFlow = __esm({
18733
18633
  ctx.data.preferBlock = buildPreferBlock(ctx.args.prefer, baseBranch);
18734
18634
  const runUrl = getRunUrl();
18735
18635
  const runSuffix = runUrl ? `, run ${runUrl}` : "";
18736
- tryPostPr4(
18636
+ tryPostPr3(
18737
18637
  prNumber,
18738
18638
  `\u2699\uFE0F kody resolve started on \`${ctx.data.branch}\`${runSuffix} \u2014 ${conflictedFiles.length} conflicted file(s)`,
18739
18639
  ctx.cwd
@@ -18834,10 +18734,10 @@ var init_resolvePreviewUrl = __esm({
18834
18734
  });
18835
18735
 
18836
18736
  // src/scripts/resolveQaUrl.ts
18837
- import { execFileSync as execFileSync19 } from "child_process";
18737
+ import { execFileSync as execFileSync18 } from "child_process";
18838
18738
  function ghQuery(args, cwd) {
18839
18739
  try {
18840
- const out = execFileSync19("gh", args, {
18740
+ const out = execFileSync18("gh", args, {
18841
18741
  cwd,
18842
18742
  stdio: ["ignore", "pipe", "pipe"],
18843
18743
  encoding: "utf-8",
@@ -18914,7 +18814,7 @@ var init_resolveQaUrl = __esm({
18914
18814
  });
18915
18815
 
18916
18816
  // src/scripts/revertFlow.ts
18917
- import { execFileSync as execFileSync20 } from "child_process";
18817
+ import { execFileSync as execFileSync19 } from "child_process";
18918
18818
  function buildCommitMessage(resolved) {
18919
18819
  if (resolved.length === 1) {
18920
18820
  const { full, subject } = resolved[0];
@@ -18927,7 +18827,7 @@ function buildPrSummary(resolved) {
18927
18827
  return resolved.map((r) => `- Reverted \`${r.full.slice(0, 7)}\`${r.subject ? ` \u2014 ${r.subject}` : ""}`).join("\n");
18928
18828
  }
18929
18829
  function git4(args, cwd) {
18930
- return execFileSync20("git", args, {
18830
+ return execFileSync19("git", args, {
18931
18831
  encoding: "utf-8",
18932
18832
  timeout: 3e4,
18933
18833
  cwd,
@@ -18937,7 +18837,7 @@ function git4(args, cwd) {
18937
18837
  }
18938
18838
  function isAncestorOfHead(sha, cwd) {
18939
18839
  try {
18940
- execFileSync20("git", ["merge-base", "--is-ancestor", sha, "HEAD"], {
18840
+ execFileSync19("git", ["merge-base", "--is-ancestor", sha, "HEAD"], {
18941
18841
  cwd,
18942
18842
  env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" },
18943
18843
  stdio: ["ignore", "ignore", "ignore"]
@@ -18947,7 +18847,7 @@ function isAncestorOfHead(sha, cwd) {
18947
18847
  return false;
18948
18848
  }
18949
18849
  }
18950
- function tryPostPr5(prNumber, body, cwd) {
18850
+ function tryPostPr4(prNumber, body, cwd) {
18951
18851
  try {
18952
18852
  postPrReviewComment(prNumber, body, cwd);
18953
18853
  } catch (err) {
@@ -18983,7 +18883,7 @@ var init_revertFlow = __esm({
18983
18883
  ctx.output.exitCode = 64;
18984
18884
  ctx.output.reason = "no commit SHAs provided \u2014 usage: @kody revert <sha> [<sha> \u2026]";
18985
18885
  ctx.skipAgent = true;
18986
- tryPostPr5(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
18886
+ tryPostPr4(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
18987
18887
  return;
18988
18888
  }
18989
18889
  const requested = shasArg.split(/\s+/).filter((s) => s.length > 0);
@@ -18992,7 +18892,7 @@ var init_revertFlow = __esm({
18992
18892
  ctx.output.exitCode = 64;
18993
18893
  ctx.output.reason = `not valid SHA-shaped tokens: ${bad.join(", ")}`;
18994
18894
  ctx.skipAgent = true;
18995
- tryPostPr5(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
18895
+ tryPostPr4(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
18996
18896
  return;
18997
18897
  }
18998
18898
  const resolved = [];
@@ -19020,7 +18920,7 @@ var init_revertFlow = __esm({
19020
18920
  ctx.output.exitCode = 64;
19021
18921
  ctx.output.reason = `commit(s) not found in this PR branch: ${unreachable.join(", ")}`;
19022
18922
  ctx.skipAgent = true;
19023
- tryPostPr5(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
18923
+ tryPostPr4(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
19024
18924
  return;
19025
18925
  }
19026
18926
  ctx.args.shas = resolved.map((r) => r.full).join(" ");
@@ -19030,13 +18930,13 @@ var init_revertFlow = __esm({
19030
18930
  const runUrl = getRunUrl();
19031
18931
  const runSuffix = runUrl ? `, run ${runUrl}` : "";
19032
18932
  const shaList = resolved.map((r) => `\`${r.full.slice(0, 7)}\``).join(", ");
19033
- tryPostPr5(prNumber, `\u2699\uFE0F kody revert started on \`${ctx.data.branch}\`${runSuffix} \u2014 reverting ${shaList}`, ctx.cwd);
18933
+ tryPostPr4(prNumber, `\u2699\uFE0F kody revert started on \`${ctx.data.branch}\`${runSuffix} \u2014 reverting ${shaList}`, ctx.cwd);
19034
18934
  };
19035
18935
  }
19036
18936
  });
19037
18937
 
19038
18938
  // src/scripts/reviewFlow.ts
19039
- function tryPostPr6(prNumber, body, cwd) {
18939
+ function tryPostPr5(prNumber, body, cwd) {
19040
18940
  try {
19041
18941
  postPrReviewComment(prNumber, body, cwd);
19042
18942
  } catch {
@@ -19066,7 +18966,7 @@ var init_reviewFlow = __esm({
19066
18966
  ctx.data.prDiff = getPrDiff(prNumber, ctx.cwd);
19067
18967
  const runUrl = getRunUrl();
19068
18968
  const runSuffix = runUrl ? `, run ${runUrl}` : "";
19069
- tryPostPr6(prNumber, `\u{1F440} kody review started on PR #${prNumber}${runSuffix}`, ctx.cwd);
18969
+ tryPostPr5(prNumber, `\u{1F440} kody review started on PR #${prNumber}${runSuffix}`, ctx.cwd);
19070
18970
  };
19071
18971
  }
19072
18972
  });
@@ -19922,7 +19822,7 @@ var init_skipAgent = __esm({
19922
19822
  });
19923
19823
 
19924
19824
  // src/scripts/stageMergeConflicts.ts
19925
- import { execFileSync as execFileSync21 } from "child_process";
19825
+ import { execFileSync as execFileSync20 } from "child_process";
19926
19826
  var stageMergeConflicts;
19927
19827
  var init_stageMergeConflicts = __esm({
19928
19828
  "src/scripts/stageMergeConflicts.ts"() {
@@ -19930,7 +19830,7 @@ var init_stageMergeConflicts = __esm({
19930
19830
  stageMergeConflicts = async (ctx) => {
19931
19831
  if (ctx.data.agentDone === false) return;
19932
19832
  try {
19933
- execFileSync21("git", ["add", "-A"], {
19833
+ execFileSync20("git", ["add", "-A"], {
19934
19834
  cwd: ctx.cwd,
19935
19835
  env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" },
19936
19836
  stdio: "pipe"
@@ -19983,6 +19883,113 @@ var init_startFlow = __esm({
19983
19883
  }
19984
19884
  });
19985
19885
 
19886
+ // src/scripts/syncFlow.ts
19887
+ import { execFileSync as execFileSync21 } from "child_process";
19888
+ function restoreDone(prNumber, cwd) {
19889
+ try {
19890
+ setKodyLabel(prNumber, DONE2, cwd);
19891
+ } catch {
19892
+ }
19893
+ }
19894
+ function bail2(ctx, prNumber, reason) {
19895
+ ctx.skipAgent = true;
19896
+ ctx.output.exitCode = 1;
19897
+ ctx.output.reason = reason;
19898
+ const runUrl = getRunUrl();
19899
+ const runSuffix = runUrl ? ` ([logs](${runUrl}))` : "";
19900
+ tryPostPr6(prNumber, `\u274C kody sync could not complete${runSuffix}: ${reason}`, ctx.cwd);
19901
+ }
19902
+ function revParseHead(cwd) {
19903
+ try {
19904
+ return execFileSync21("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).toString().trim();
19905
+ } catch {
19906
+ return "";
19907
+ }
19908
+ }
19909
+ function pushBranch(branch, cwd) {
19910
+ const result = pushWithRetry({ cwd: cwd ?? process.cwd(), branch, setUpstream: true });
19911
+ if (!result.ok) {
19912
+ throw new Error(result.reason);
19913
+ }
19914
+ }
19915
+ function tryPostPr6(prNumber, body, cwd) {
19916
+ try {
19917
+ postPrReviewComment(prNumber, body, cwd);
19918
+ } catch {
19919
+ }
19920
+ }
19921
+ var DONE2, syncFlow;
19922
+ var init_syncFlow = __esm({
19923
+ "src/scripts/syncFlow.ts"() {
19924
+ "use strict";
19925
+ init_branch();
19926
+ init_gha();
19927
+ init_issue();
19928
+ init_lifecycleLabels();
19929
+ init_pushWithRetry();
19930
+ DONE2 = {
19931
+ label: "kody:done",
19932
+ color: "0e8a16",
19933
+ description: "kody: PR ready for human review/merge"
19934
+ };
19935
+ syncFlow = async (ctx, _profile, args) => {
19936
+ const announceOnSuccess = Boolean(args?.announceOnSuccess);
19937
+ const prNumber = ctx.args.pr;
19938
+ const pr = getPr(prNumber, ctx.cwd);
19939
+ if (pr.state !== "OPEN") {
19940
+ bail2(ctx, prNumber, `PR #${prNumber} is not OPEN (state: ${pr.state})`);
19941
+ return;
19942
+ }
19943
+ ctx.data.pr = pr;
19944
+ if (announceOnSuccess) {
19945
+ ctx.data.commentTargetType = "pr";
19946
+ ctx.data.commentTargetNumber = prNumber;
19947
+ }
19948
+ checkoutPrBranch(prNumber, ctx.cwd);
19949
+ ctx.data.branch = getCurrentBranch(ctx.cwd);
19950
+ const baseBranch = pr.baseRefName || ctx.config.git.defaultBranch;
19951
+ ctx.data.baseBranch = baseBranch;
19952
+ const headBefore = revParseHead(ctx.cwd);
19953
+ const mergeStatus = mergeBase(baseBranch, ctx.cwd);
19954
+ if (mergeStatus === "error") {
19955
+ bail2(ctx, prNumber, `failed to merge origin/${baseBranch} (non-conflict error); see runner log`);
19956
+ return;
19957
+ }
19958
+ if (mergeStatus === "conflict") {
19959
+ bail2(
19960
+ ctx,
19961
+ prNumber,
19962
+ `merge from origin/${baseBranch} produced conflicts \u2014 run \`@kody resolve\` to let kody resolve them`
19963
+ );
19964
+ return;
19965
+ }
19966
+ const headAfter = revParseHead(ctx.cwd);
19967
+ if (headAfter === headBefore) {
19968
+ ctx.data.syncResult = "noop";
19969
+ if (announceOnSuccess) {
19970
+ ctx.output.exitCode = 0;
19971
+ ctx.output.reason = `already up to date with origin/${baseBranch}`;
19972
+ restoreDone(prNumber, ctx.cwd);
19973
+ }
19974
+ return;
19975
+ }
19976
+ try {
19977
+ pushBranch(ctx.data.branch, ctx.cwd);
19978
+ } catch (err) {
19979
+ const msg = err instanceof Error ? err.message : String(err);
19980
+ bail2(ctx, prNumber, `merge succeeded but push failed: ${msg}`);
19981
+ return;
19982
+ }
19983
+ ctx.data.syncResult = "merged";
19984
+ if (announceOnSuccess) {
19985
+ ctx.output.exitCode = 0;
19986
+ ctx.output.reason = `merged origin/${baseBranch} into ${ctx.data.branch}`;
19987
+ restoreDone(prNumber, ctx.cwd);
19988
+ }
19989
+ };
19990
+ }
19991
+ });
19992
+
19986
19993
  // src/scripts/validateAgencyModelProposal.ts
19987
19994
  import * as path46 from "path";
19988
19995
  function validateModelBundle(bundle, expectedKind, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.539",
3
+ "version": "0.4.541",
4
4
  "description": "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
5
5
  "license": "MIT",
6
6
  "type": "module",