@kody-ade/kody-engine 0.4.540 → 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 +143 -144
  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.540",
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,13 +18352,14 @@ 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;
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
+ }
18464
18362
  if (!commitResult?.committed && !hasCommits) {
18465
- if (ctx.data.jobDelivery === "pull-request") {
18466
- const reason2 = "pull-request delivery produced no commit";
18467
- ctx.data.agentFailureReason = reason2;
18468
- ctx.output.exitCode = 4;
18469
- ctx.output.reason = reason2;
18470
- }
18471
18363
  return;
18472
18364
  }
18473
18365
  const commitMessage = String(ctx.data.commitMessage ?? "").trim();
@@ -18592,7 +18484,7 @@ var init_resolveArtifacts = __esm({
18592
18484
  });
18593
18485
 
18594
18486
  // src/scripts/resolveFlow.ts
18595
- import { execFileSync as execFileSync18 } from "child_process";
18487
+ import { execFileSync as execFileSync17 } from "child_process";
18596
18488
  function buildPreferBlock(prefer, baseBranch) {
18597
18489
  if (prefer !== "ours" && prefer !== "theirs") return "";
18598
18490
  const keepSide = prefer === "ours" ? "HEAD (this PR branch)" : `origin/${baseBranch} (base branch)`;
@@ -18612,7 +18504,7 @@ function buildPreferBlock(prefer, baseBranch) {
18612
18504
  }
18613
18505
  function getConflictedFiles(cwd) {
18614
18506
  try {
18615
- const out = execFileSync18("git", ["diff", "--name-only", "--diff-filter=U"], {
18507
+ const out = execFileSync17("git", ["diff", "--name-only", "--diff-filter=U"], {
18616
18508
  encoding: "utf-8",
18617
18509
  cwd,
18618
18510
  env: { ...process.env, HUSKY: "0" }
@@ -18627,7 +18519,7 @@ function getConflictMarkersPreview(files, cwd, maxBytes = CONFLICT_DIFF_MAX_BYTE
18627
18519
  let total = 0;
18628
18520
  for (const f of files) {
18629
18521
  try {
18630
- const content = execFileSync18("cat", [f], { encoding: "utf-8", cwd }).toString();
18522
+ const content = execFileSync17("cat", [f], { encoding: "utf-8", cwd }).toString();
18631
18523
  const snippet = `### ${f}
18632
18524
 
18633
18525
  \`\`\`
@@ -18642,7 +18534,7 @@ ${content.slice(0, 6e3)}
18642
18534
  }
18643
18535
  return chunks.join("\n");
18644
18536
  }
18645
- function tryPostPr4(prNumber, body, cwd) {
18537
+ function tryPostPr3(prNumber, body, cwd) {
18646
18538
  try {
18647
18539
  postPrReviewComment(prNumber, body, cwd);
18648
18540
  } catch {
@@ -18651,12 +18543,12 @@ function tryPostPr4(prNumber, body, cwd) {
18651
18543
  function pushEmptyCommit(branch, cwd) {
18652
18544
  const env = { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" };
18653
18545
  try {
18654
- execFileSync18(
18546
+ execFileSync17(
18655
18547
  "git",
18656
18548
  ["commit", "--allow-empty", "-m", "chore: kody resolve refresh \u2014 empty commit to recompute mergeable status"],
18657
18549
  { cwd, env, stdio: ["ignore", "pipe", "pipe"] }
18658
18550
  );
18659
- execFileSync18("git", ["push", "-u", "origin", branch], {
18551
+ execFileSync17("git", ["push", "-u", "origin", branch], {
18660
18552
  cwd,
18661
18553
  env,
18662
18554
  stdio: ["ignore", "pipe", "pipe"]
@@ -18694,14 +18586,14 @@ var init_resolveFlow = __esm({
18694
18586
  ctx.output.exitCode = 0;
18695
18587
  ctx.output.reason = `PR #${prNumber} is mergeable (no conflicts) \u2014 nothing to resolve`;
18696
18588
  ctx.skipAgent = true;
18697
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18589
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18698
18590
  return;
18699
18591
  }
18700
18592
  if (ghStatus.status === "BLOCKED") {
18701
18593
  ctx.output.exitCode = 0;
18702
18594
  ctx.output.reason = `PR #${prNumber} is mergeable but blocked by checks/reviews (mergeStateStatus=${ghStatus.mergeStateStatus}) \u2014 nothing for resolve to do`;
18703
18595
  ctx.skipAgent = true;
18704
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18596
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18705
18597
  return;
18706
18598
  }
18707
18599
  checkoutPrBranch(prNumber, ctx.cwd);
@@ -18713,20 +18605,20 @@ var init_resolveFlow = __esm({
18713
18605
  ctx.output.exitCode = 0;
18714
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)`;
18715
18607
  ctx.skipAgent = true;
18716
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18608
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18717
18609
  return;
18718
18610
  }
18719
18611
  ctx.output.exitCode = 0;
18720
18612
  ctx.output.reason = `already up to date with origin/${baseBranch} \u2014 nothing to resolve`;
18721
18613
  ctx.skipAgent = true;
18722
- tryPostPr4(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18614
+ tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
18723
18615
  return;
18724
18616
  }
18725
18617
  if (mergeStatus === "error") {
18726
18618
  ctx.output.exitCode = 99;
18727
18619
  ctx.output.reason = `failed to merge origin/${baseBranch} (non-conflict error); see runner log`;
18728
18620
  ctx.skipAgent = true;
18729
- 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);
18730
18622
  return;
18731
18623
  }
18732
18624
  const conflictedFiles = getConflictedFiles(ctx.cwd);
@@ -18741,7 +18633,7 @@ var init_resolveFlow = __esm({
18741
18633
  ctx.data.preferBlock = buildPreferBlock(ctx.args.prefer, baseBranch);
18742
18634
  const runUrl = getRunUrl();
18743
18635
  const runSuffix = runUrl ? `, run ${runUrl}` : "";
18744
- tryPostPr4(
18636
+ tryPostPr3(
18745
18637
  prNumber,
18746
18638
  `\u2699\uFE0F kody resolve started on \`${ctx.data.branch}\`${runSuffix} \u2014 ${conflictedFiles.length} conflicted file(s)`,
18747
18639
  ctx.cwd
@@ -18842,10 +18734,10 @@ var init_resolvePreviewUrl = __esm({
18842
18734
  });
18843
18735
 
18844
18736
  // src/scripts/resolveQaUrl.ts
18845
- import { execFileSync as execFileSync19 } from "child_process";
18737
+ import { execFileSync as execFileSync18 } from "child_process";
18846
18738
  function ghQuery(args, cwd) {
18847
18739
  try {
18848
- const out = execFileSync19("gh", args, {
18740
+ const out = execFileSync18("gh", args, {
18849
18741
  cwd,
18850
18742
  stdio: ["ignore", "pipe", "pipe"],
18851
18743
  encoding: "utf-8",
@@ -18922,7 +18814,7 @@ var init_resolveQaUrl = __esm({
18922
18814
  });
18923
18815
 
18924
18816
  // src/scripts/revertFlow.ts
18925
- import { execFileSync as execFileSync20 } from "child_process";
18817
+ import { execFileSync as execFileSync19 } from "child_process";
18926
18818
  function buildCommitMessage(resolved) {
18927
18819
  if (resolved.length === 1) {
18928
18820
  const { full, subject } = resolved[0];
@@ -18935,7 +18827,7 @@ function buildPrSummary(resolved) {
18935
18827
  return resolved.map((r) => `- Reverted \`${r.full.slice(0, 7)}\`${r.subject ? ` \u2014 ${r.subject}` : ""}`).join("\n");
18936
18828
  }
18937
18829
  function git4(args, cwd) {
18938
- return execFileSync20("git", args, {
18830
+ return execFileSync19("git", args, {
18939
18831
  encoding: "utf-8",
18940
18832
  timeout: 3e4,
18941
18833
  cwd,
@@ -18945,7 +18837,7 @@ function git4(args, cwd) {
18945
18837
  }
18946
18838
  function isAncestorOfHead(sha, cwd) {
18947
18839
  try {
18948
- execFileSync20("git", ["merge-base", "--is-ancestor", sha, "HEAD"], {
18840
+ execFileSync19("git", ["merge-base", "--is-ancestor", sha, "HEAD"], {
18949
18841
  cwd,
18950
18842
  env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" },
18951
18843
  stdio: ["ignore", "ignore", "ignore"]
@@ -18955,7 +18847,7 @@ function isAncestorOfHead(sha, cwd) {
18955
18847
  return false;
18956
18848
  }
18957
18849
  }
18958
- function tryPostPr5(prNumber, body, cwd) {
18850
+ function tryPostPr4(prNumber, body, cwd) {
18959
18851
  try {
18960
18852
  postPrReviewComment(prNumber, body, cwd);
18961
18853
  } catch (err) {
@@ -18991,7 +18883,7 @@ var init_revertFlow = __esm({
18991
18883
  ctx.output.exitCode = 64;
18992
18884
  ctx.output.reason = "no commit SHAs provided \u2014 usage: @kody revert <sha> [<sha> \u2026]";
18993
18885
  ctx.skipAgent = true;
18994
- 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);
18995
18887
  return;
18996
18888
  }
18997
18889
  const requested = shasArg.split(/\s+/).filter((s) => s.length > 0);
@@ -19000,7 +18892,7 @@ var init_revertFlow = __esm({
19000
18892
  ctx.output.exitCode = 64;
19001
18893
  ctx.output.reason = `not valid SHA-shaped tokens: ${bad.join(", ")}`;
19002
18894
  ctx.skipAgent = true;
19003
- 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);
19004
18896
  return;
19005
18897
  }
19006
18898
  const resolved = [];
@@ -19028,7 +18920,7 @@ var init_revertFlow = __esm({
19028
18920
  ctx.output.exitCode = 64;
19029
18921
  ctx.output.reason = `commit(s) not found in this PR branch: ${unreachable.join(", ")}`;
19030
18922
  ctx.skipAgent = true;
19031
- 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);
19032
18924
  return;
19033
18925
  }
19034
18926
  ctx.args.shas = resolved.map((r) => r.full).join(" ");
@@ -19038,13 +18930,13 @@ var init_revertFlow = __esm({
19038
18930
  const runUrl = getRunUrl();
19039
18931
  const runSuffix = runUrl ? `, run ${runUrl}` : "";
19040
18932
  const shaList = resolved.map((r) => `\`${r.full.slice(0, 7)}\``).join(", ");
19041
- 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);
19042
18934
  };
19043
18935
  }
19044
18936
  });
19045
18937
 
19046
18938
  // src/scripts/reviewFlow.ts
19047
- function tryPostPr6(prNumber, body, cwd) {
18939
+ function tryPostPr5(prNumber, body, cwd) {
19048
18940
  try {
19049
18941
  postPrReviewComment(prNumber, body, cwd);
19050
18942
  } catch {
@@ -19074,7 +18966,7 @@ var init_reviewFlow = __esm({
19074
18966
  ctx.data.prDiff = getPrDiff(prNumber, ctx.cwd);
19075
18967
  const runUrl = getRunUrl();
19076
18968
  const runSuffix = runUrl ? `, run ${runUrl}` : "";
19077
- 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);
19078
18970
  };
19079
18971
  }
19080
18972
  });
@@ -19930,7 +19822,7 @@ var init_skipAgent = __esm({
19930
19822
  });
19931
19823
 
19932
19824
  // src/scripts/stageMergeConflicts.ts
19933
- import { execFileSync as execFileSync21 } from "child_process";
19825
+ import { execFileSync as execFileSync20 } from "child_process";
19934
19826
  var stageMergeConflicts;
19935
19827
  var init_stageMergeConflicts = __esm({
19936
19828
  "src/scripts/stageMergeConflicts.ts"() {
@@ -19938,7 +19830,7 @@ var init_stageMergeConflicts = __esm({
19938
19830
  stageMergeConflicts = async (ctx) => {
19939
19831
  if (ctx.data.agentDone === false) return;
19940
19832
  try {
19941
- execFileSync21("git", ["add", "-A"], {
19833
+ execFileSync20("git", ["add", "-A"], {
19942
19834
  cwd: ctx.cwd,
19943
19835
  env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" },
19944
19836
  stdio: "pipe"
@@ -19991,6 +19883,113 @@ var init_startFlow = __esm({
19991
19883
  }
19992
19884
  });
19993
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
+
19994
19993
  // src/scripts/validateAgencyModelProposal.ts
19995
19994
  import * as path46 from "path";
19996
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.540",
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",