@kody-ade/kody-engine 0.4.296 → 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 +59 -5
  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.296",
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",
@@ -11913,11 +11913,18 @@ function computeFailureReason(ctx) {
11913
11913
  if (expectedTests.length > 0) return `missing tests: ${expectedTests.join(", ")}`;
11914
11914
  const agentDone = Boolean(ctx.data.agentDone);
11915
11915
  if (!agentDone) {
11916
- 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";
11917
11917
  }
11918
11918
  if (ctx.data.verifyOk === false) return ctx.data.verifyReason || "verify failed";
11919
11919
  return "";
11920
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
+ }
11921
11928
  function collectExpectedTests(raw) {
11922
11929
  if (!Array.isArray(raw) || raw.length === 0) return [];
11923
11930
  const out = [];
@@ -14382,8 +14389,46 @@ function extractFailureSignatureBlock(text) {
14382
14389
  const stopIdx = afterMarker.search(stopRe);
14383
14390
  let block = stopIdx === -1 ? afterMarker : afterMarker.slice(0, stopIdx);
14384
14391
  block = block.trim();
14385
- block = block.replace(/^```(?:json)?\s*/i, "").replace(/```\s*$/i, "");
14386
- 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 "";
14387
14432
  }
14388
14433
  function stripMarkdownEmphasis2(s) {
14389
14434
  return s.trim().replace(/^[*_`~]+|[*_`~]+$/g, "").trim();
@@ -14397,6 +14442,7 @@ function downgrade(ctx, reason) {
14397
14442
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
14398
14443
  };
14399
14444
  }
14445
+ ctx.data.agentFailureReason = reason;
14400
14446
  ctx.data.agentDone = false;
14401
14447
  }
14402
14448
  var parseReproOutput;
@@ -14703,11 +14749,18 @@ function computeFailureReason2(ctx) {
14703
14749
  if (misses.length > 0) return `missing tests: ${misses.map((m) => m.expectedTest).join(", ")}`;
14704
14750
  const agentDone = Boolean(ctx.data.agentDone);
14705
14751
  if (!agentDone) {
14706
- 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";
14707
14753
  }
14708
14754
  if (ctx.data.verifyOk === false) return ctx.data.verifyReason || "verify failed";
14709
14755
  return "";
14710
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
+ }
14711
14764
  function postWith(type, n, body, cwd) {
14712
14765
  try {
14713
14766
  if (type === "issue") postIssueComment(n, body, cwd);
@@ -16899,6 +16952,7 @@ function downgrade2(ctx, reason) {
16899
16952
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
16900
16953
  };
16901
16954
  }
16955
+ ctx.data.agentFailureReason = reason;
16902
16956
  ctx.data.agentDone = false;
16903
16957
  }
16904
16958
  var TEST_TIMEOUT_MS, TAIL_CHARS2, ANSI_RE2, verifyReproFails;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.296",
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",