@kody-ade/kody-engine 0.2.19 → 0.2.20
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/kody2.js +102 -10
- package/dist/executables/sync/profile.json +35 -0
- package/package.json +1 -1
package/dist/bin/kody2.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// package.json
|
|
4
4
|
var package_default = {
|
|
5
5
|
name: "@kody-ade/kody-engine",
|
|
6
|
-
version: "0.2.
|
|
6
|
+
version: "0.2.20",
|
|
7
7
|
description: "kody2 \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
|
|
8
8
|
license: "MIT",
|
|
9
9
|
type: "module",
|
|
@@ -2912,6 +2912,94 @@ function synthesizeAction(ctx) {
|
|
|
2912
2912
|
};
|
|
2913
2913
|
}
|
|
2914
2914
|
|
|
2915
|
+
// src/scripts/syncFlow.ts
|
|
2916
|
+
import { execFileSync as execFileSync13 } from "child_process";
|
|
2917
|
+
var syncFlow = async (ctx) => {
|
|
2918
|
+
ctx.skipAgent = true;
|
|
2919
|
+
const prNumber = ctx.args.pr;
|
|
2920
|
+
const pr = getPr(prNumber, ctx.cwd);
|
|
2921
|
+
if (pr.state !== "OPEN") {
|
|
2922
|
+
bail2(ctx, prNumber, `PR #${prNumber} is not OPEN (state: ${pr.state})`);
|
|
2923
|
+
return;
|
|
2924
|
+
}
|
|
2925
|
+
ctx.data.pr = pr;
|
|
2926
|
+
ctx.data.commentTargetType = "pr";
|
|
2927
|
+
ctx.data.commentTargetNumber = prNumber;
|
|
2928
|
+
checkoutPrBranch(prNumber, ctx.cwd);
|
|
2929
|
+
ctx.data.branch = getCurrentBranch(ctx.cwd);
|
|
2930
|
+
const baseBranch = pr.baseRefName || ctx.config.git.defaultBranch;
|
|
2931
|
+
ctx.data.baseBranch = baseBranch;
|
|
2932
|
+
const headBefore = revParseHead(ctx.cwd);
|
|
2933
|
+
const mergeStatus = mergeBase(baseBranch, ctx.cwd);
|
|
2934
|
+
if (mergeStatus === "error") {
|
|
2935
|
+
bail2(ctx, prNumber, `failed to merge origin/${baseBranch} (non-conflict error); see runner log`);
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2938
|
+
if (mergeStatus === "conflict") {
|
|
2939
|
+
bail2(
|
|
2940
|
+
ctx,
|
|
2941
|
+
prNumber,
|
|
2942
|
+
`merge from origin/${baseBranch} produced conflicts \u2014 run \`@kody2 resolve\` to let kody2 resolve them`
|
|
2943
|
+
);
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2946
|
+
const headAfter = revParseHead(ctx.cwd);
|
|
2947
|
+
if (headAfter === headBefore) {
|
|
2948
|
+
ctx.output.exitCode = 0;
|
|
2949
|
+
ctx.output.reason = `already up to date with origin/${baseBranch}`;
|
|
2950
|
+
tryPostPr5(prNumber, `\u2139\uFE0F kody2 sync: already up to date with origin/${baseBranch}`, ctx.cwd);
|
|
2951
|
+
return;
|
|
2952
|
+
}
|
|
2953
|
+
try {
|
|
2954
|
+
pushBranch(ctx.data.branch, ctx.cwd);
|
|
2955
|
+
} catch (err) {
|
|
2956
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2957
|
+
bail2(ctx, prNumber, `merge succeeded but push failed: ${msg}`);
|
|
2958
|
+
return;
|
|
2959
|
+
}
|
|
2960
|
+
ctx.output.exitCode = 0;
|
|
2961
|
+
ctx.output.reason = `merged origin/${baseBranch} into ${ctx.data.branch}`;
|
|
2962
|
+
const runUrl = getRunUrl();
|
|
2963
|
+
const runSuffix = runUrl ? ` ([logs](${runUrl}))` : "";
|
|
2964
|
+
tryPostPr5(
|
|
2965
|
+
prNumber,
|
|
2966
|
+
`\u2705 kody2 sync: merged \`origin/${baseBranch}\` into \`${ctx.data.branch}\`${runSuffix}`,
|
|
2967
|
+
ctx.cwd
|
|
2968
|
+
);
|
|
2969
|
+
};
|
|
2970
|
+
function bail2(ctx, prNumber, reason) {
|
|
2971
|
+
ctx.output.exitCode = 1;
|
|
2972
|
+
ctx.output.reason = reason;
|
|
2973
|
+
const runUrl = getRunUrl();
|
|
2974
|
+
const runSuffix = runUrl ? ` ([logs](${runUrl}))` : "";
|
|
2975
|
+
tryPostPr5(prNumber, `\u274C kody2 sync could not complete${runSuffix}: ${reason}`, ctx.cwd);
|
|
2976
|
+
}
|
|
2977
|
+
function revParseHead(cwd) {
|
|
2978
|
+
try {
|
|
2979
|
+
return execFileSync13("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).toString().trim();
|
|
2980
|
+
} catch {
|
|
2981
|
+
return "";
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
function pushBranch(branch, cwd) {
|
|
2985
|
+
const env = { ...process.env, HUSKY: "0", SKIP_HOOKS: "1" };
|
|
2986
|
+
try {
|
|
2987
|
+
execFileSync13("git", ["push", "-u", "origin", branch], { cwd, env, stdio: ["ignore", "pipe", "pipe"] });
|
|
2988
|
+
} catch {
|
|
2989
|
+
execFileSync13("git", ["push", "--force-with-lease", "-u", "origin", branch], {
|
|
2990
|
+
cwd,
|
|
2991
|
+
env,
|
|
2992
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
function tryPostPr5(prNumber, body, cwd) {
|
|
2997
|
+
try {
|
|
2998
|
+
postPrReviewComment(prNumber, body, cwd);
|
|
2999
|
+
} catch {
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
|
|
2915
3003
|
// src/verify.ts
|
|
2916
3004
|
import { spawn as spawn2 } from "child_process";
|
|
2917
3005
|
var TAIL_CHARS = 4e3;
|
|
@@ -3111,6 +3199,7 @@ var preflightScripts = {
|
|
|
3111
3199
|
fixCiFlow,
|
|
3112
3200
|
resolveFlow,
|
|
3113
3201
|
reviewFlow,
|
|
3202
|
+
syncFlow,
|
|
3114
3203
|
initFlow,
|
|
3115
3204
|
releaseFlow,
|
|
3116
3205
|
watchStalePrsFlow,
|
|
@@ -3138,7 +3227,7 @@ var allScriptNames = /* @__PURE__ */ new Set([
|
|
|
3138
3227
|
]);
|
|
3139
3228
|
|
|
3140
3229
|
// src/tools.ts
|
|
3141
|
-
import { execFileSync as
|
|
3230
|
+
import { execFileSync as execFileSync14 } from "child_process";
|
|
3142
3231
|
function verifyCliTools(tools, cwd) {
|
|
3143
3232
|
const out = [];
|
|
3144
3233
|
for (const t of tools) out.push(verifyOne(t, cwd));
|
|
@@ -3171,7 +3260,7 @@ function verifyOne(tool, cwd) {
|
|
|
3171
3260
|
}
|
|
3172
3261
|
function runShell2(cmd, cwd, timeoutMs = 3e4) {
|
|
3173
3262
|
try {
|
|
3174
|
-
|
|
3263
|
+
execFileSync14("sh", ["-c", cmd], { cwd, stdio: "pipe", timeout: timeoutMs });
|
|
3175
3264
|
return true;
|
|
3176
3265
|
} catch {
|
|
3177
3266
|
return false;
|
|
@@ -3409,7 +3498,7 @@ function finish(out) {
|
|
|
3409
3498
|
}
|
|
3410
3499
|
|
|
3411
3500
|
// src/kody2-cli.ts
|
|
3412
|
-
import { execFileSync as
|
|
3501
|
+
import { execFileSync as execFileSync15 } from "child_process";
|
|
3413
3502
|
import * as fs16 from "fs";
|
|
3414
3503
|
import * as path13 from "path";
|
|
3415
3504
|
|
|
@@ -3456,6 +3545,9 @@ function autoDispatch(opts) {
|
|
|
3456
3545
|
if (/\breview\b/.test(afterTag)) {
|
|
3457
3546
|
return { executable: "review", cliArgs: { pr: targetNum }, target: targetNum };
|
|
3458
3547
|
}
|
|
3548
|
+
if (/\bsync\b/.test(afterTag)) {
|
|
3549
|
+
return { executable: "sync", cliArgs: { pr: targetNum }, target: targetNum };
|
|
3550
|
+
}
|
|
3459
3551
|
const feedback = extractFeedback(afterTag);
|
|
3460
3552
|
return {
|
|
3461
3553
|
executable: "fix",
|
|
@@ -3586,7 +3678,7 @@ function detectPackageManager2(cwd) {
|
|
|
3586
3678
|
}
|
|
3587
3679
|
function shellOut(cmd, args, cwd, stream = true) {
|
|
3588
3680
|
try {
|
|
3589
|
-
|
|
3681
|
+
execFileSync15(cmd, args, {
|
|
3590
3682
|
cwd,
|
|
3591
3683
|
stdio: stream ? "inherit" : "pipe",
|
|
3592
3684
|
env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1", CI: process.env.CI ?? "1" }
|
|
@@ -3599,7 +3691,7 @@ function shellOut(cmd, args, cwd, stream = true) {
|
|
|
3599
3691
|
}
|
|
3600
3692
|
function isOnPath(bin) {
|
|
3601
3693
|
try {
|
|
3602
|
-
|
|
3694
|
+
execFileSync15("which", [bin], { stdio: "pipe" });
|
|
3603
3695
|
return true;
|
|
3604
3696
|
} catch {
|
|
3605
3697
|
return false;
|
|
@@ -3633,7 +3725,7 @@ function installLitellmIfNeeded(cwd) {
|
|
|
3633
3725
|
} catch {
|
|
3634
3726
|
}
|
|
3635
3727
|
try {
|
|
3636
|
-
|
|
3728
|
+
execFileSync15("python3", ["-c", "import litellm"], { stdio: "pipe" });
|
|
3637
3729
|
process.stdout.write("\u2192 kody2: litellm already installed\n");
|
|
3638
3730
|
return 0;
|
|
3639
3731
|
} catch {
|
|
@@ -3643,16 +3735,16 @@ function installLitellmIfNeeded(cwd) {
|
|
|
3643
3735
|
}
|
|
3644
3736
|
function configureGitIdentity(cwd) {
|
|
3645
3737
|
try {
|
|
3646
|
-
const name =
|
|
3738
|
+
const name = execFileSync15("git", ["config", "user.name"], { cwd, stdio: "pipe", encoding: "utf-8" }).trim();
|
|
3647
3739
|
if (name) return;
|
|
3648
3740
|
} catch {
|
|
3649
3741
|
}
|
|
3650
3742
|
try {
|
|
3651
|
-
|
|
3743
|
+
execFileSync15("git", ["config", "user.name", "github-actions[bot]"], { cwd, stdio: "pipe" });
|
|
3652
3744
|
} catch {
|
|
3653
3745
|
}
|
|
3654
3746
|
try {
|
|
3655
|
-
|
|
3747
|
+
execFileSync15("git", ["config", "user.email", "41898282+github-actions[bot]@users.noreply.github.com"], {
|
|
3656
3748
|
cwd,
|
|
3657
3749
|
stdio: "pipe"
|
|
3658
3750
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sync",
|
|
3
|
+
"describe": "Merge the default (base) branch into a PR branch and push. No agent.",
|
|
4
|
+
"inputs": [
|
|
5
|
+
{
|
|
6
|
+
"name": "pr",
|
|
7
|
+
"flag": "--pr",
|
|
8
|
+
"type": "int",
|
|
9
|
+
"required": true,
|
|
10
|
+
"describe": "GitHub PR number to update from its base branch."
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"claudeCode": {
|
|
14
|
+
"model": "inherit",
|
|
15
|
+
"permissionMode": "acceptEdits",
|
|
16
|
+
"maxTurns": null,
|
|
17
|
+
"systemPromptAppend": null,
|
|
18
|
+
"tools": [],
|
|
19
|
+
"hooks": [],
|
|
20
|
+
"skills": [],
|
|
21
|
+
"commands": [],
|
|
22
|
+
"subagents": [],
|
|
23
|
+
"plugins": [],
|
|
24
|
+
"mcpServers": []
|
|
25
|
+
},
|
|
26
|
+
"cliTools": [],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"preflight": [
|
|
29
|
+
{
|
|
30
|
+
"script": "syncFlow"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"postflight": []
|
|
34
|
+
}
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kody-ade/kody-engine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20",
|
|
4
4
|
"description": "kody2 — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|