@kody-ade/kody-engine 0.4.295 → 0.4.297

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 +85 -14
  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.295",
18
+ version: "0.4.297",
19
19
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
20
20
  license: "MIT",
21
21
  type: "module",
@@ -2208,15 +2208,19 @@ function listExecutables(roots = getExecutableRoots()) {
2208
2208
  return out.sort((a, b) => a.name.localeCompare(b.name));
2209
2209
  }
2210
2210
  function resolveExecutable(name, roots = getExecutableRoots()) {
2211
- if (!isSafeName(name)) return null;
2211
+ return resolveExecutableCandidates(name, roots)[0] ?? null;
2212
+ }
2213
+ function resolveExecutableCandidates(name, roots = getExecutableRoots()) {
2214
+ if (!isSafeName(name)) return [];
2212
2215
  const rootList = typeof roots === "string" ? [roots] : roots;
2216
+ const out = [];
2213
2217
  for (const root of rootList) {
2214
2218
  const profilePath = path8.join(root, name, "profile.json");
2215
2219
  if (fs6.existsSync(profilePath) && fs6.statSync(profilePath).isFile() && isImplementationProfile(profilePath, isCapabilityRoot(root))) {
2216
- return profilePath;
2220
+ out.push(profilePath);
2217
2221
  }
2218
2222
  }
2219
- return null;
2223
+ return out;
2220
2224
  }
2221
2225
  function listCapabilityActions(projectCapabilitiesRoot = getProjectCapabilitiesRoot()) {
2222
2226
  const seen = /* @__PURE__ */ new Set();
@@ -11909,11 +11913,18 @@ function computeFailureReason(ctx) {
11909
11913
  if (expectedTests.length > 0) return `missing tests: ${expectedTests.join(", ")}`;
11910
11914
  const agentDone = Boolean(ctx.data.agentDone);
11911
11915
  if (!agentDone) {
11912
- return ctx.data.agentFailureReason || ctx.data.agentError || ctx.data.commitCrash || "agent did not emit DONE";
11916
+ return ctx.data.agentFailureReason || ctx.data.agentError || ctx.data.commitCrash || actionFailureReason(ctx.data.action) || "agent did not emit DONE";
11913
11917
  }
11914
11918
  if (ctx.data.verifyOk === false) return ctx.data.verifyReason || "verify failed";
11915
11919
  return "";
11916
11920
  }
11921
+ function actionFailureReason(action) {
11922
+ if (!action || typeof action !== "object" || Array.isArray(action)) return "";
11923
+ const payload = action.payload;
11924
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) return "";
11925
+ const reason = payload.reason;
11926
+ return typeof reason === "string" ? reason : "";
11927
+ }
11917
11928
  function collectExpectedTests(raw) {
11918
11929
  if (!Array.isArray(raw) || raw.length === 0) return [];
11919
11930
  const out = [];
@@ -14378,8 +14389,46 @@ function extractFailureSignatureBlock(text) {
14378
14389
  const stopIdx = afterMarker.search(stopRe);
14379
14390
  let block = stopIdx === -1 ? afterMarker : afterMarker.slice(0, stopIdx);
14380
14391
  block = block.trim();
14381
- block = block.replace(/^```(?:json)?\s*/i, "").replace(/```\s*$/i, "");
14382
- return block.trim();
14392
+ return normalizeFailureSignatureBlock(block);
14393
+ }
14394
+ function normalizeFailureSignatureBlock(block) {
14395
+ let s = block.trim();
14396
+ while (/^```(?:json)?\s*/i.test(s) && /```\s*$/i.test(s)) {
14397
+ const next = s.replace(/^```(?:json)?\s*/i, "").replace(/```\s*$/i, "").trim();
14398
+ if (next === s) break;
14399
+ s = next;
14400
+ }
14401
+ const jsonObject = extractFirstJsonObject(s);
14402
+ return jsonObject || s;
14403
+ }
14404
+ function extractFirstJsonObject(text) {
14405
+ const start = text.indexOf("{");
14406
+ if (start === -1) return "";
14407
+ let depth = 0;
14408
+ let inString = false;
14409
+ let escaped = false;
14410
+ for (let i = start; i < text.length; i++) {
14411
+ const ch = text[i];
14412
+ if (inString) {
14413
+ if (escaped) {
14414
+ escaped = false;
14415
+ } else if (ch === "\\") {
14416
+ escaped = true;
14417
+ } else if (ch === '"') {
14418
+ inString = false;
14419
+ }
14420
+ continue;
14421
+ }
14422
+ if (ch === '"') {
14423
+ inString = true;
14424
+ } else if (ch === "{") {
14425
+ depth++;
14426
+ } else if (ch === "}") {
14427
+ depth--;
14428
+ if (depth === 0) return text.slice(start, i + 1).trim();
14429
+ }
14430
+ }
14431
+ return "";
14383
14432
  }
14384
14433
  function stripMarkdownEmphasis2(s) {
14385
14434
  return s.trim().replace(/^[*_`~]+|[*_`~]+$/g, "").trim();
@@ -14393,6 +14442,7 @@ function downgrade(ctx, reason) {
14393
14442
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
14394
14443
  };
14395
14444
  }
14445
+ ctx.data.agentFailureReason = reason;
14396
14446
  ctx.data.agentDone = false;
14397
14447
  }
14398
14448
  var parseReproOutput;
@@ -14699,11 +14749,18 @@ function computeFailureReason2(ctx) {
14699
14749
  if (misses.length > 0) return `missing tests: ${misses.map((m) => m.expectedTest).join(", ")}`;
14700
14750
  const agentDone = Boolean(ctx.data.agentDone);
14701
14751
  if (!agentDone) {
14702
- return ctx.data.agentFailureReason || ctx.data.agentError || "agent did not emit DONE";
14752
+ return ctx.data.agentFailureReason || ctx.data.agentError || actionFailureReason2(ctx.data.action) || "agent did not emit DONE";
14703
14753
  }
14704
14754
  if (ctx.data.verifyOk === false) return ctx.data.verifyReason || "verify failed";
14705
14755
  return "";
14706
14756
  }
14757
+ function actionFailureReason2(action) {
14758
+ if (!action || typeof action !== "object" || Array.isArray(action)) return "";
14759
+ const payload = action.payload;
14760
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) return "";
14761
+ const reason = payload.reason;
14762
+ return typeof reason === "string" ? reason : "";
14763
+ }
14707
14764
  function postWith(type, n, body, cwd) {
14708
14765
  try {
14709
14766
  if (type === "issue") postIssueComment(n, body, cwd);
@@ -16895,6 +16952,7 @@ function downgrade2(ctx, reason) {
16895
16952
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
16896
16953
  };
16897
16954
  }
16955
+ ctx.data.agentFailureReason = reason;
16898
16956
  ctx.data.agentDone = false;
16899
16957
  }
16900
16958
  var TEST_TIMEOUT_MS, TAIL_CHARS2, ANSI_RE2, verifyReproFails;
@@ -17654,9 +17712,6 @@ var init_scripts = __esm({
17654
17712
  postReviewResult,
17655
17713
  persistArtifacts,
17656
17714
  writeAgentRunSummary,
17657
- // Deprecated profile compatibility. Older external capability profiles used
17658
- // this name before the summary writer was made agent-result specific.
17659
- writeRunSummary: writeAgentRunSummary,
17660
17715
  saveTaskState,
17661
17716
  mirrorStateToPr,
17662
17717
  startFlow,
@@ -17970,9 +18025,8 @@ async function runExecutable(profileName, input) {
17970
18025
  `);
17971
18026
  return out;
17972
18027
  };
17973
- const profilePath = resolveProfilePath(profileName);
17974
- const profile = loadProfile(profilePath);
17975
- const missing = validateScriptReferences(profile, allScriptNames);
18028
+ const resolved = loadRunnableProfile(profileName);
18029
+ const { profilePath, profile, missing } = resolved;
17976
18030
  if (missing.length > 0) {
17977
18031
  return finishAndEnd({
17978
18032
  exitCode: 99,
@@ -18465,6 +18519,23 @@ function resolveProfilePath(profileName) {
18465
18519
  }
18466
18520
  return candidates[0];
18467
18521
  }
18522
+ function loadRunnableProfile(profileName) {
18523
+ const candidates = resolveExecutableCandidates(profileName);
18524
+ const skipped = [];
18525
+ for (const profilePath2 of candidates) {
18526
+ const profile2 = loadProfile(profilePath2);
18527
+ const missing = validateScriptReferences(profile2, allScriptNames);
18528
+ if (missing.length === 0) return { profilePath: profilePath2, profile: profile2, missing };
18529
+ skipped.push(`${profilePath2}: ${missing.join(", ")}`);
18530
+ }
18531
+ if (skipped.length > 0) {
18532
+ process.stderr.write(`[kody] skipping invalid profile override(s): ${skipped.join("; ")}
18533
+ `);
18534
+ }
18535
+ const profilePath = resolveProfilePath(profileName);
18536
+ const profile = loadProfile(profilePath);
18537
+ return { profilePath, profile, missing: validateScriptReferences(profile, allScriptNames) };
18538
+ }
18468
18539
  function validateInputs(specs, raw) {
18469
18540
  const out = {};
18470
18541
  const allowedKeys = /* @__PURE__ */ new Set(["_", "cwd", "verbose", "quiet"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.295",
3
+ "version": "0.4.297",
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",