@kody-ade/kody-engine 0.4.540 → 0.4.542
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/bin/kody.js +145 -144
- 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.
|
|
18
|
+
version: "0.4.542",
|
|
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,121 +17869,14 @@ 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({
|
|
17982
17875
|
"src/scripts/prepareCapabilityDelivery.ts"() {
|
|
17983
17876
|
"use strict";
|
|
17984
17877
|
init_capabilityDelivery();
|
|
17878
|
+
init_branch();
|
|
17985
17879
|
init_runFlow();
|
|
17986
|
-
init_syncFlow();
|
|
17987
17880
|
prepareCapabilityDelivery = async (ctx, profile) => {
|
|
17988
17881
|
const target = capabilityDeliveryTarget(ctx.data.capabilityInput);
|
|
17989
17882
|
if (!target) {
|
|
@@ -17994,9 +17887,9 @@ var init_prepareCapabilityDelivery = __esm({
|
|
|
17994
17887
|
await runFlow(ctx, profile);
|
|
17995
17888
|
return;
|
|
17996
17889
|
}
|
|
17890
|
+
checkoutPrBranch(target.number, ctx.cwd);
|
|
17997
17891
|
ctx.data.commentTargetType = "pr";
|
|
17998
17892
|
ctx.data.commentTargetNumber = target.number;
|
|
17999
|
-
await syncFlow(ctx, profile);
|
|
18000
17893
|
};
|
|
18001
17894
|
}
|
|
18002
17895
|
});
|
|
@@ -18352,7 +18245,7 @@ var init_publishReport = __esm({
|
|
|
18352
18245
|
});
|
|
18353
18246
|
|
|
18354
18247
|
// src/scripts/recordClassification.ts
|
|
18355
|
-
import { execFileSync as
|
|
18248
|
+
import { execFileSync as execFileSync16 } from "child_process";
|
|
18356
18249
|
function parseClassification(prSummary) {
|
|
18357
18250
|
if (!prSummary) return null;
|
|
18358
18251
|
const classMatch = prSummary.match(/classification:\s*(feature|bug|spec|chore)\b/i);
|
|
@@ -18364,7 +18257,7 @@ function parseClassification(prSummary) {
|
|
|
18364
18257
|
}
|
|
18365
18258
|
function tryAuditComment(issueNumber, body, cwd) {
|
|
18366
18259
|
try {
|
|
18367
|
-
|
|
18260
|
+
execFileSync16("gh", ["issue", "comment", String(issueNumber), "--body", body], {
|
|
18368
18261
|
cwd,
|
|
18369
18262
|
timeout: API_TIMEOUT_MS5,
|
|
18370
18263
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -18461,13 +18354,14 @@ var init_requireDeliveryArtifacts = __esm({
|
|
|
18461
18354
|
if (ctx.data.agentDone !== true) return;
|
|
18462
18355
|
const commitResult = ctx.data.commitResult;
|
|
18463
18356
|
const hasCommits = ctx.data.hasCommitsAhead === true;
|
|
18357
|
+
if (ctx.data.jobDelivery === "pull-request" && (!commitResult?.committed || !commitResult.pushed)) {
|
|
18358
|
+
const reason2 = "pull-request delivery produced no commit";
|
|
18359
|
+
ctx.data.agentFailureReason = reason2;
|
|
18360
|
+
ctx.output.exitCode = 4;
|
|
18361
|
+
ctx.output.reason = reason2;
|
|
18362
|
+
return;
|
|
18363
|
+
}
|
|
18464
18364
|
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
18365
|
return;
|
|
18472
18366
|
}
|
|
18473
18367
|
const commitMessage = String(ctx.data.commitMessage ?? "").trim();
|
|
@@ -18592,7 +18486,7 @@ var init_resolveArtifacts = __esm({
|
|
|
18592
18486
|
});
|
|
18593
18487
|
|
|
18594
18488
|
// src/scripts/resolveFlow.ts
|
|
18595
|
-
import { execFileSync as
|
|
18489
|
+
import { execFileSync as execFileSync17 } from "child_process";
|
|
18596
18490
|
function buildPreferBlock(prefer, baseBranch) {
|
|
18597
18491
|
if (prefer !== "ours" && prefer !== "theirs") return "";
|
|
18598
18492
|
const keepSide = prefer === "ours" ? "HEAD (this PR branch)" : `origin/${baseBranch} (base branch)`;
|
|
@@ -18612,7 +18506,7 @@ function buildPreferBlock(prefer, baseBranch) {
|
|
|
18612
18506
|
}
|
|
18613
18507
|
function getConflictedFiles(cwd) {
|
|
18614
18508
|
try {
|
|
18615
|
-
const out =
|
|
18509
|
+
const out = execFileSync17("git", ["diff", "--name-only", "--diff-filter=U"], {
|
|
18616
18510
|
encoding: "utf-8",
|
|
18617
18511
|
cwd,
|
|
18618
18512
|
env: { ...process.env, HUSKY: "0" }
|
|
@@ -18627,7 +18521,7 @@ function getConflictMarkersPreview(files, cwd, maxBytes = CONFLICT_DIFF_MAX_BYTE
|
|
|
18627
18521
|
let total = 0;
|
|
18628
18522
|
for (const f of files) {
|
|
18629
18523
|
try {
|
|
18630
|
-
const content =
|
|
18524
|
+
const content = execFileSync17("cat", [f], { encoding: "utf-8", cwd }).toString();
|
|
18631
18525
|
const snippet = `### ${f}
|
|
18632
18526
|
|
|
18633
18527
|
\`\`\`
|
|
@@ -18642,7 +18536,7 @@ ${content.slice(0, 6e3)}
|
|
|
18642
18536
|
}
|
|
18643
18537
|
return chunks.join("\n");
|
|
18644
18538
|
}
|
|
18645
|
-
function
|
|
18539
|
+
function tryPostPr3(prNumber, body, cwd) {
|
|
18646
18540
|
try {
|
|
18647
18541
|
postPrReviewComment(prNumber, body, cwd);
|
|
18648
18542
|
} catch {
|
|
@@ -18651,12 +18545,12 @@ function tryPostPr4(prNumber, body, cwd) {
|
|
|
18651
18545
|
function pushEmptyCommit(branch, cwd) {
|
|
18652
18546
|
const env = { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" };
|
|
18653
18547
|
try {
|
|
18654
|
-
|
|
18548
|
+
execFileSync17(
|
|
18655
18549
|
"git",
|
|
18656
18550
|
["commit", "--allow-empty", "-m", "chore: kody resolve refresh \u2014 empty commit to recompute mergeable status"],
|
|
18657
18551
|
{ cwd, env, stdio: ["ignore", "pipe", "pipe"] }
|
|
18658
18552
|
);
|
|
18659
|
-
|
|
18553
|
+
execFileSync17("git", ["push", "-u", "origin", branch], {
|
|
18660
18554
|
cwd,
|
|
18661
18555
|
env,
|
|
18662
18556
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -18694,14 +18588,14 @@ var init_resolveFlow = __esm({
|
|
|
18694
18588
|
ctx.output.exitCode = 0;
|
|
18695
18589
|
ctx.output.reason = `PR #${prNumber} is mergeable (no conflicts) \u2014 nothing to resolve`;
|
|
18696
18590
|
ctx.skipAgent = true;
|
|
18697
|
-
|
|
18591
|
+
tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
|
|
18698
18592
|
return;
|
|
18699
18593
|
}
|
|
18700
18594
|
if (ghStatus.status === "BLOCKED") {
|
|
18701
18595
|
ctx.output.exitCode = 0;
|
|
18702
18596
|
ctx.output.reason = `PR #${prNumber} is mergeable but blocked by checks/reviews (mergeStateStatus=${ghStatus.mergeStateStatus}) \u2014 nothing for resolve to do`;
|
|
18703
18597
|
ctx.skipAgent = true;
|
|
18704
|
-
|
|
18598
|
+
tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
|
|
18705
18599
|
return;
|
|
18706
18600
|
}
|
|
18707
18601
|
checkoutPrBranch(prNumber, ctx.cwd);
|
|
@@ -18713,20 +18607,20 @@ var init_resolveFlow = __esm({
|
|
|
18713
18607
|
ctx.output.exitCode = 0;
|
|
18714
18608
|
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
18609
|
ctx.skipAgent = true;
|
|
18716
|
-
|
|
18610
|
+
tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
|
|
18717
18611
|
return;
|
|
18718
18612
|
}
|
|
18719
18613
|
ctx.output.exitCode = 0;
|
|
18720
18614
|
ctx.output.reason = `already up to date with origin/${baseBranch} \u2014 nothing to resolve`;
|
|
18721
18615
|
ctx.skipAgent = true;
|
|
18722
|
-
|
|
18616
|
+
tryPostPr3(prNumber, `\u2139\uFE0F kody resolve: ${ctx.output.reason}`, ctx.cwd);
|
|
18723
18617
|
return;
|
|
18724
18618
|
}
|
|
18725
18619
|
if (mergeStatus === "error") {
|
|
18726
18620
|
ctx.output.exitCode = 99;
|
|
18727
18621
|
ctx.output.reason = `failed to merge origin/${baseBranch} (non-conflict error); see runner log`;
|
|
18728
18622
|
ctx.skipAgent = true;
|
|
18729
|
-
|
|
18623
|
+
tryPostPr3(prNumber, `\u26A0\uFE0F kody resolve FAILED: ${ctx.output.reason}`, ctx.cwd);
|
|
18730
18624
|
return;
|
|
18731
18625
|
}
|
|
18732
18626
|
const conflictedFiles = getConflictedFiles(ctx.cwd);
|
|
@@ -18741,7 +18635,7 @@ var init_resolveFlow = __esm({
|
|
|
18741
18635
|
ctx.data.preferBlock = buildPreferBlock(ctx.args.prefer, baseBranch);
|
|
18742
18636
|
const runUrl = getRunUrl();
|
|
18743
18637
|
const runSuffix = runUrl ? `, run ${runUrl}` : "";
|
|
18744
|
-
|
|
18638
|
+
tryPostPr3(
|
|
18745
18639
|
prNumber,
|
|
18746
18640
|
`\u2699\uFE0F kody resolve started on \`${ctx.data.branch}\`${runSuffix} \u2014 ${conflictedFiles.length} conflicted file(s)`,
|
|
18747
18641
|
ctx.cwd
|
|
@@ -18842,10 +18736,10 @@ var init_resolvePreviewUrl = __esm({
|
|
|
18842
18736
|
});
|
|
18843
18737
|
|
|
18844
18738
|
// src/scripts/resolveQaUrl.ts
|
|
18845
|
-
import { execFileSync as
|
|
18739
|
+
import { execFileSync as execFileSync18 } from "child_process";
|
|
18846
18740
|
function ghQuery(args, cwd) {
|
|
18847
18741
|
try {
|
|
18848
|
-
const out =
|
|
18742
|
+
const out = execFileSync18("gh", args, {
|
|
18849
18743
|
cwd,
|
|
18850
18744
|
stdio: ["ignore", "pipe", "pipe"],
|
|
18851
18745
|
encoding: "utf-8",
|
|
@@ -18922,7 +18816,7 @@ var init_resolveQaUrl = __esm({
|
|
|
18922
18816
|
});
|
|
18923
18817
|
|
|
18924
18818
|
// src/scripts/revertFlow.ts
|
|
18925
|
-
import { execFileSync as
|
|
18819
|
+
import { execFileSync as execFileSync19 } from "child_process";
|
|
18926
18820
|
function buildCommitMessage(resolved) {
|
|
18927
18821
|
if (resolved.length === 1) {
|
|
18928
18822
|
const { full, subject } = resolved[0];
|
|
@@ -18935,7 +18829,7 @@ function buildPrSummary(resolved) {
|
|
|
18935
18829
|
return resolved.map((r) => `- Reverted \`${r.full.slice(0, 7)}\`${r.subject ? ` \u2014 ${r.subject}` : ""}`).join("\n");
|
|
18936
18830
|
}
|
|
18937
18831
|
function git4(args, cwd) {
|
|
18938
|
-
return
|
|
18832
|
+
return execFileSync19("git", args, {
|
|
18939
18833
|
encoding: "utf-8",
|
|
18940
18834
|
timeout: 3e4,
|
|
18941
18835
|
cwd,
|
|
@@ -18945,7 +18839,7 @@ function git4(args, cwd) {
|
|
|
18945
18839
|
}
|
|
18946
18840
|
function isAncestorOfHead(sha, cwd) {
|
|
18947
18841
|
try {
|
|
18948
|
-
|
|
18842
|
+
execFileSync19("git", ["merge-base", "--is-ancestor", sha, "HEAD"], {
|
|
18949
18843
|
cwd,
|
|
18950
18844
|
env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" },
|
|
18951
18845
|
stdio: ["ignore", "ignore", "ignore"]
|
|
@@ -18955,7 +18849,7 @@ function isAncestorOfHead(sha, cwd) {
|
|
|
18955
18849
|
return false;
|
|
18956
18850
|
}
|
|
18957
18851
|
}
|
|
18958
|
-
function
|
|
18852
|
+
function tryPostPr4(prNumber, body, cwd) {
|
|
18959
18853
|
try {
|
|
18960
18854
|
postPrReviewComment(prNumber, body, cwd);
|
|
18961
18855
|
} catch (err) {
|
|
@@ -18991,7 +18885,7 @@ var init_revertFlow = __esm({
|
|
|
18991
18885
|
ctx.output.exitCode = 64;
|
|
18992
18886
|
ctx.output.reason = "no commit SHAs provided \u2014 usage: @kody revert <sha> [<sha> \u2026]";
|
|
18993
18887
|
ctx.skipAgent = true;
|
|
18994
|
-
|
|
18888
|
+
tryPostPr4(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
|
|
18995
18889
|
return;
|
|
18996
18890
|
}
|
|
18997
18891
|
const requested = shasArg.split(/\s+/).filter((s) => s.length > 0);
|
|
@@ -19000,7 +18894,7 @@ var init_revertFlow = __esm({
|
|
|
19000
18894
|
ctx.output.exitCode = 64;
|
|
19001
18895
|
ctx.output.reason = `not valid SHA-shaped tokens: ${bad.join(", ")}`;
|
|
19002
18896
|
ctx.skipAgent = true;
|
|
19003
|
-
|
|
18897
|
+
tryPostPr4(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
|
|
19004
18898
|
return;
|
|
19005
18899
|
}
|
|
19006
18900
|
const resolved = [];
|
|
@@ -19028,7 +18922,7 @@ var init_revertFlow = __esm({
|
|
|
19028
18922
|
ctx.output.exitCode = 64;
|
|
19029
18923
|
ctx.output.reason = `commit(s) not found in this PR branch: ${unreachable.join(", ")}`;
|
|
19030
18924
|
ctx.skipAgent = true;
|
|
19031
|
-
|
|
18925
|
+
tryPostPr4(prNumber, `\u26A0\uFE0F kody revert FAILED: ${ctx.output.reason}`, ctx.cwd);
|
|
19032
18926
|
return;
|
|
19033
18927
|
}
|
|
19034
18928
|
ctx.args.shas = resolved.map((r) => r.full).join(" ");
|
|
@@ -19038,13 +18932,13 @@ var init_revertFlow = __esm({
|
|
|
19038
18932
|
const runUrl = getRunUrl();
|
|
19039
18933
|
const runSuffix = runUrl ? `, run ${runUrl}` : "";
|
|
19040
18934
|
const shaList = resolved.map((r) => `\`${r.full.slice(0, 7)}\``).join(", ");
|
|
19041
|
-
|
|
18935
|
+
tryPostPr4(prNumber, `\u2699\uFE0F kody revert started on \`${ctx.data.branch}\`${runSuffix} \u2014 reverting ${shaList}`, ctx.cwd);
|
|
19042
18936
|
};
|
|
19043
18937
|
}
|
|
19044
18938
|
});
|
|
19045
18939
|
|
|
19046
18940
|
// src/scripts/reviewFlow.ts
|
|
19047
|
-
function
|
|
18941
|
+
function tryPostPr5(prNumber, body, cwd) {
|
|
19048
18942
|
try {
|
|
19049
18943
|
postPrReviewComment(prNumber, body, cwd);
|
|
19050
18944
|
} catch {
|
|
@@ -19074,7 +18968,7 @@ var init_reviewFlow = __esm({
|
|
|
19074
18968
|
ctx.data.prDiff = getPrDiff(prNumber, ctx.cwd);
|
|
19075
18969
|
const runUrl = getRunUrl();
|
|
19076
18970
|
const runSuffix = runUrl ? `, run ${runUrl}` : "";
|
|
19077
|
-
|
|
18971
|
+
tryPostPr5(prNumber, `\u{1F440} kody review started on PR #${prNumber}${runSuffix}`, ctx.cwd);
|
|
19078
18972
|
};
|
|
19079
18973
|
}
|
|
19080
18974
|
});
|
|
@@ -19930,7 +19824,7 @@ var init_skipAgent = __esm({
|
|
|
19930
19824
|
});
|
|
19931
19825
|
|
|
19932
19826
|
// src/scripts/stageMergeConflicts.ts
|
|
19933
|
-
import { execFileSync as
|
|
19827
|
+
import { execFileSync as execFileSync20 } from "child_process";
|
|
19934
19828
|
var stageMergeConflicts;
|
|
19935
19829
|
var init_stageMergeConflicts = __esm({
|
|
19936
19830
|
"src/scripts/stageMergeConflicts.ts"() {
|
|
@@ -19938,7 +19832,7 @@ var init_stageMergeConflicts = __esm({
|
|
|
19938
19832
|
stageMergeConflicts = async (ctx) => {
|
|
19939
19833
|
if (ctx.data.agentDone === false) return;
|
|
19940
19834
|
try {
|
|
19941
|
-
|
|
19835
|
+
execFileSync20("git", ["add", "-A"], {
|
|
19942
19836
|
cwd: ctx.cwd,
|
|
19943
19837
|
env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" },
|
|
19944
19838
|
stdio: "pipe"
|
|
@@ -19991,6 +19885,113 @@ var init_startFlow = __esm({
|
|
|
19991
19885
|
}
|
|
19992
19886
|
});
|
|
19993
19887
|
|
|
19888
|
+
// src/scripts/syncFlow.ts
|
|
19889
|
+
import { execFileSync as execFileSync21 } from "child_process";
|
|
19890
|
+
function restoreDone(prNumber, cwd) {
|
|
19891
|
+
try {
|
|
19892
|
+
setKodyLabel(prNumber, DONE2, cwd);
|
|
19893
|
+
} catch {
|
|
19894
|
+
}
|
|
19895
|
+
}
|
|
19896
|
+
function bail2(ctx, prNumber, reason) {
|
|
19897
|
+
ctx.skipAgent = true;
|
|
19898
|
+
ctx.output.exitCode = 1;
|
|
19899
|
+
ctx.output.reason = reason;
|
|
19900
|
+
const runUrl = getRunUrl();
|
|
19901
|
+
const runSuffix = runUrl ? ` ([logs](${runUrl}))` : "";
|
|
19902
|
+
tryPostPr6(prNumber, `\u274C kody sync could not complete${runSuffix}: ${reason}`, ctx.cwd);
|
|
19903
|
+
}
|
|
19904
|
+
function revParseHead(cwd) {
|
|
19905
|
+
try {
|
|
19906
|
+
return execFileSync21("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).toString().trim();
|
|
19907
|
+
} catch {
|
|
19908
|
+
return "";
|
|
19909
|
+
}
|
|
19910
|
+
}
|
|
19911
|
+
function pushBranch(branch, cwd) {
|
|
19912
|
+
const result = pushWithRetry({ cwd: cwd ?? process.cwd(), branch, setUpstream: true });
|
|
19913
|
+
if (!result.ok) {
|
|
19914
|
+
throw new Error(result.reason);
|
|
19915
|
+
}
|
|
19916
|
+
}
|
|
19917
|
+
function tryPostPr6(prNumber, body, cwd) {
|
|
19918
|
+
try {
|
|
19919
|
+
postPrReviewComment(prNumber, body, cwd);
|
|
19920
|
+
} catch {
|
|
19921
|
+
}
|
|
19922
|
+
}
|
|
19923
|
+
var DONE2, syncFlow;
|
|
19924
|
+
var init_syncFlow = __esm({
|
|
19925
|
+
"src/scripts/syncFlow.ts"() {
|
|
19926
|
+
"use strict";
|
|
19927
|
+
init_branch();
|
|
19928
|
+
init_gha();
|
|
19929
|
+
init_issue();
|
|
19930
|
+
init_lifecycleLabels();
|
|
19931
|
+
init_pushWithRetry();
|
|
19932
|
+
DONE2 = {
|
|
19933
|
+
label: "kody:done",
|
|
19934
|
+
color: "0e8a16",
|
|
19935
|
+
description: "kody: PR ready for human review/merge"
|
|
19936
|
+
};
|
|
19937
|
+
syncFlow = async (ctx, _profile, args) => {
|
|
19938
|
+
const announceOnSuccess = Boolean(args?.announceOnSuccess);
|
|
19939
|
+
const prNumber = ctx.args.pr;
|
|
19940
|
+
const pr = getPr(prNumber, ctx.cwd);
|
|
19941
|
+
if (pr.state !== "OPEN") {
|
|
19942
|
+
bail2(ctx, prNumber, `PR #${prNumber} is not OPEN (state: ${pr.state})`);
|
|
19943
|
+
return;
|
|
19944
|
+
}
|
|
19945
|
+
ctx.data.pr = pr;
|
|
19946
|
+
if (announceOnSuccess) {
|
|
19947
|
+
ctx.data.commentTargetType = "pr";
|
|
19948
|
+
ctx.data.commentTargetNumber = prNumber;
|
|
19949
|
+
}
|
|
19950
|
+
checkoutPrBranch(prNumber, ctx.cwd);
|
|
19951
|
+
ctx.data.branch = getCurrentBranch(ctx.cwd);
|
|
19952
|
+
const baseBranch = pr.baseRefName || ctx.config.git.defaultBranch;
|
|
19953
|
+
ctx.data.baseBranch = baseBranch;
|
|
19954
|
+
const headBefore = revParseHead(ctx.cwd);
|
|
19955
|
+
const mergeStatus = mergeBase(baseBranch, ctx.cwd);
|
|
19956
|
+
if (mergeStatus === "error") {
|
|
19957
|
+
bail2(ctx, prNumber, `failed to merge origin/${baseBranch} (non-conflict error); see runner log`);
|
|
19958
|
+
return;
|
|
19959
|
+
}
|
|
19960
|
+
if (mergeStatus === "conflict") {
|
|
19961
|
+
bail2(
|
|
19962
|
+
ctx,
|
|
19963
|
+
prNumber,
|
|
19964
|
+
`merge from origin/${baseBranch} produced conflicts \u2014 run \`@kody resolve\` to let kody resolve them`
|
|
19965
|
+
);
|
|
19966
|
+
return;
|
|
19967
|
+
}
|
|
19968
|
+
const headAfter = revParseHead(ctx.cwd);
|
|
19969
|
+
if (headAfter === headBefore) {
|
|
19970
|
+
ctx.data.syncResult = "noop";
|
|
19971
|
+
if (announceOnSuccess) {
|
|
19972
|
+
ctx.output.exitCode = 0;
|
|
19973
|
+
ctx.output.reason = `already up to date with origin/${baseBranch}`;
|
|
19974
|
+
restoreDone(prNumber, ctx.cwd);
|
|
19975
|
+
}
|
|
19976
|
+
return;
|
|
19977
|
+
}
|
|
19978
|
+
try {
|
|
19979
|
+
pushBranch(ctx.data.branch, ctx.cwd);
|
|
19980
|
+
} catch (err) {
|
|
19981
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
19982
|
+
bail2(ctx, prNumber, `merge succeeded but push failed: ${msg}`);
|
|
19983
|
+
return;
|
|
19984
|
+
}
|
|
19985
|
+
ctx.data.syncResult = "merged";
|
|
19986
|
+
if (announceOnSuccess) {
|
|
19987
|
+
ctx.output.exitCode = 0;
|
|
19988
|
+
ctx.output.reason = `merged origin/${baseBranch} into ${ctx.data.branch}`;
|
|
19989
|
+
restoreDone(prNumber, ctx.cwd);
|
|
19990
|
+
}
|
|
19991
|
+
};
|
|
19992
|
+
}
|
|
19993
|
+
});
|
|
19994
|
+
|
|
19994
19995
|
// src/scripts/validateAgencyModelProposal.ts
|
|
19995
19996
|
import * as path46 from "path";
|
|
19996
19997
|
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.
|
|
3
|
+
"version": "0.4.542",
|
|
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",
|