@kody-ade/kody-engine 0.4.230 → 0.4.232

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 +44 -12
  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.230",
18
+ version: "0.4.232",
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",
@@ -6357,6 +6357,12 @@ var init_advanceManagedGoal = __esm({
6357
6357
  ctx.output.reason = "goal has no managed-goal contract; nothing to advance";
6358
6358
  return;
6359
6359
  }
6360
+ const previousGoalIdFact = managed.facts.goalId;
6361
+ managed.facts.goalId = goal.id;
6362
+ const restoreGoalIdFact = () => {
6363
+ if (previousGoalIdFact === void 0) delete managed.facts.goalId;
6364
+ else managed.facts.goalId = previousGoalIdFact;
6365
+ };
6360
6366
  if (isDutyCadenceGoal(managed, goal.raw.extra)) {
6361
6367
  const previousScheduleState = goal.raw.extra.scheduleState && typeof goal.raw.extra.scheduleState === "object" ? goal.raw.extra.scheduleState : void 0;
6362
6368
  const decision2 = await planGoalDutySchedule({
@@ -6365,6 +6371,7 @@ var init_advanceManagedGoal = __esm({
6365
6371
  config: ctx.config,
6366
6372
  previousScheduleState
6367
6373
  });
6374
+ restoreGoalIdFact();
6368
6375
  goal.raw = writeManagedGoalToState({ ...goal.raw, state: goal.state }, managed);
6369
6376
  goal.raw.extra.scheduleState = decision2.scheduleState;
6370
6377
  ctx.data.managedGoalDecision = decision2;
@@ -6382,6 +6389,7 @@ var init_advanceManagedGoal = __esm({
6382
6389
  applySimpleGoalTaskSummary(managed, readSimpleGoalTaskSummary(goal.id, ctx.cwd));
6383
6390
  }
6384
6391
  const decision = planManagedGoalTick(managed);
6392
+ restoreGoalIdFact();
6385
6393
  ctx.data.managedGoalDecision = decision;
6386
6394
  if (decision.kind === "done") {
6387
6395
  goal.state = "done";
@@ -9948,11 +9956,35 @@ var init_loadDutyState = __esm({
9948
9956
  });
9949
9957
 
9950
9958
  // src/scripts/loadGoalState.ts
9951
- var loadGoalState;
9959
+ function retryDelaysMs() {
9960
+ const raw = process.env.KODY_GOAL_STATE_RETRY_DELAYS_MS?.trim();
9961
+ if (!raw) return DEFAULT_RETRY_DELAYS_MS;
9962
+ return raw.split(",").map((part) => Number(part.trim())).filter((value) => Number.isFinite(value) && value >= 0);
9963
+ }
9964
+ function sleep(ms) {
9965
+ if (ms <= 0) return Promise.resolve();
9966
+ return new Promise((resolve7) => setTimeout(resolve7, ms));
9967
+ }
9968
+ async function fetchGoalStateWithRetry(owner, repo, goalId, cwd) {
9969
+ let state = fetchGoalState(owner, repo, goalId, cwd);
9970
+ if (state) return state;
9971
+ for (const delay of retryDelaysMs()) {
9972
+ await sleep(delay);
9973
+ state = fetchGoalState(owner, repo, goalId, cwd);
9974
+ if (state) {
9975
+ process.stdout.write(`[goal-manager] loaded goal state for ${goalId} after retry
9976
+ `);
9977
+ return state;
9978
+ }
9979
+ }
9980
+ return null;
9981
+ }
9982
+ var DEFAULT_RETRY_DELAYS_MS, loadGoalState;
9952
9983
  var init_loadGoalState = __esm({
9953
9984
  "src/scripts/loadGoalState.ts"() {
9954
9985
  "use strict";
9955
9986
  init_stateStore();
9987
+ DEFAULT_RETRY_DELAYS_MS = [250, 750, 1500, 2500];
9956
9988
  loadGoalState = async (ctx) => {
9957
9989
  const goalId = ctx.args.goal;
9958
9990
  if (typeof goalId !== "string" || goalId.length === 0) {
@@ -9976,7 +10008,7 @@ var init_loadGoalState = __esm({
9976
10008
  return;
9977
10009
  }
9978
10010
  try {
9979
- const state = fetchGoalState(owner, repo, goalId, ctx.cwd);
10011
+ const state = await fetchGoalStateWithRetry(owner, repo, goalId, ctx.cwd);
9980
10012
  if (!state) {
9981
10013
  process.stdout.write(`[goal-manager] no goal state for ${goalId} on ${owner}/${repo}; nothing to tick
9982
10014
  `);
@@ -13559,7 +13591,7 @@ function tryPostPr7(prNumber, body, cwd) {
13559
13591
  } catch {
13560
13592
  }
13561
13593
  }
13562
- function sleep(ms) {
13594
+ function sleep2(ms) {
13563
13595
  return new Promise((res) => setTimeout(res, ms));
13564
13596
  }
13565
13597
  var API_TIMEOUT_MS8, waitForCi;
@@ -13581,17 +13613,17 @@ var init_waitForCi = __esm({
13581
13613
  return;
13582
13614
  }
13583
13615
  const fixCiAttempts = state?.core.attempts?.["fix-ci"] ?? 0;
13584
- await sleep(initialWaitSeconds * 1e3);
13616
+ await sleep2(initialWaitSeconds * 1e3);
13585
13617
  const deadline = Date.now() + timeoutMinutes * 6e4;
13586
13618
  let lastSummary = "";
13587
13619
  while (Date.now() < deadline) {
13588
13620
  const rows = fetchChecks(prNumber, ctx.cwd);
13589
13621
  if (rows === null) {
13590
- await sleep(pollSeconds * 1e3);
13622
+ await sleep2(pollSeconds * 1e3);
13591
13623
  continue;
13592
13624
  }
13593
13625
  if (rows.length === 0) {
13594
- await sleep(pollSeconds * 1e3);
13626
+ await sleep2(pollSeconds * 1e3);
13595
13627
  continue;
13596
13628
  }
13597
13629
  const summary = summarize(rows);
@@ -13634,7 +13666,7 @@ var init_waitForCi = __esm({
13634
13666
  tryPostPr7(prNumber, `\u2705 kody waitForCi: all ${rows.length} checks green on PR #${prNumber}`, ctx.cwd);
13635
13667
  return;
13636
13668
  }
13637
- await sleep(pollSeconds * 1e3);
13669
+ await sleep2(pollSeconds * 1e3);
13638
13670
  }
13639
13671
  ctx.data.action = mkAction("CI_TIMEOUT", {
13640
13672
  reason: `CI did not complete within ${timeoutMinutes} minutes`,
@@ -17837,10 +17869,10 @@ async function waitForNextUserMessage(opts) {
17837
17869
  const remainingIdle = opts.idleTimeoutMs - (Date.now() - idleStart);
17838
17870
  const sleepMs2 = Math.max(0, Math.min(pollMs, remainingDeadline, remainingIdle));
17839
17871
  if (sleepMs2 === 0) continue;
17840
- await sleep2(sleepMs2);
17872
+ await sleep3(sleepMs2);
17841
17873
  }
17842
17874
  }
17843
- function sleep2(ms) {
17875
+ function sleep3(ms) {
17844
17876
  return new Promise((resolve7) => setTimeout(resolve7, ms));
17845
17877
  }
17846
17878
  function currentBranch(cwd) {
@@ -18455,7 +18487,7 @@ var FlyClient = class {
18455
18487
  if (res.ok) return true;
18456
18488
  } catch {
18457
18489
  }
18458
- await sleep3(intervalMs);
18490
+ await sleep4(intervalMs);
18459
18491
  }
18460
18492
  return false;
18461
18493
  }
@@ -18463,7 +18495,7 @@ var FlyClient = class {
18463
18495
  function enc(s) {
18464
18496
  return encodeURIComponent(s);
18465
18497
  }
18466
- function sleep3(ms) {
18498
+ function sleep4(ms) {
18467
18499
  return new Promise((r) => setTimeout(r, ms));
18468
18500
  }
18469
18501
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.230",
3
+ "version": "0.4.232",
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",