@kody-ade/kody-engine 0.4.446 → 0.4.447

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 +42 -9
  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.446",
18
+ version: "0.4.447",
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",
@@ -1795,11 +1795,11 @@ function parseWorkflowTransitions(value) {
1795
1795
  const transitions = rawTransitions.map((raw) => {
1796
1796
  if (typeof raw === "string") {
1797
1797
  const to2 = raw.trim();
1798
- return isSafeStepId(to2) ? { to: to2 } : null;
1798
+ return to2 === "$end" || isSafeStepId(to2) ? { to: to2 } : null;
1799
1799
  }
1800
1800
  if (!isPlainObject(raw)) return null;
1801
1801
  const to = stringField(raw.to);
1802
- if (!to || !isSafeStepId(to)) return null;
1802
+ if (!to || to !== "$end" && !isSafeStepId(to)) return null;
1803
1803
  const maxIterations = typeof raw.maxIterations === "number" && Number.isInteger(raw.maxIterations) && raw.maxIterations > 0 ? raw.maxIterations : void 0;
1804
1804
  return {
1805
1805
  to,
@@ -1862,11 +1862,11 @@ function definitionsRoot(cwd = process.cwd()) {
1862
1862
  const override = process.env.KODY_DEFINITIONS_ROOT?.trim();
1863
1863
  const overrideCwd = process.env.KODY_DEFINITIONS_ROOT_CWD?.trim();
1864
1864
  if (override && overrideCwd && path6.resolve(cwd) === path6.resolve(overrideCwd)) {
1865
- return path6.resolve(override);
1865
+ return storeCatalogRoot(path6.resolve(override));
1866
1866
  }
1867
1867
  const hydrated = path6.join(cwd, ".kody-engine", "definitions");
1868
1868
  if (fs5.existsSync(hydrated)) return hydrated;
1869
- return override ? path6.resolve(override) : hydrated;
1869
+ return override ? storeCatalogRoot(path6.resolve(override)) : hydrated;
1870
1870
  }
1871
1871
  function hasExplicitDefinitionsRoot(cwd = process.cwd(), env = process.env) {
1872
1872
  const root = env.KODY_DEFINITIONS_ROOT?.trim();
@@ -1874,13 +1874,36 @@ function hasExplicitDefinitionsRoot(cwd = process.cwd(), env = process.env) {
1874
1874
  return Boolean(root && rootCwd && path6.resolve(cwd) === path6.resolve(rootCwd));
1875
1875
  }
1876
1876
  function capabilitiesRoot(cwd = process.cwd()) {
1877
- return path6.join(definitionsRoot(cwd), "capabilities");
1877
+ return storeAssetRoot(cwd, "capabilities") ?? path6.join(definitionsRoot(cwd), "capabilities");
1878
1878
  }
1879
1879
  function implementationsRoot(cwd = process.cwd()) {
1880
1880
  return path6.join(definitionsRoot(cwd), "implementations");
1881
1881
  }
1882
1882
  function agentsRoot(cwd = process.cwd()) {
1883
- return path6.join(definitionsRoot(cwd), "agents");
1883
+ return storeAssetRoot(cwd, "agent") ?? path6.join(definitionsRoot(cwd), "agents");
1884
+ }
1885
+ function storeCatalogRoot(root) {
1886
+ const manifest = readStoreManifest(root);
1887
+ const roots = ["capabilities", "workflows", "loops"].map((kind) => manifest?.assetRoots?.[kind]).filter((value) => typeof value === "string" && Boolean(value.trim())).map((value) => path6.dirname(value));
1888
+ return roots.length === 3 && new Set(roots).size === 1 ? path6.join(root, roots[0]) : root;
1889
+ }
1890
+ function storeAssetRoot(cwd, kind) {
1891
+ const override = process.env.KODY_DEFINITIONS_ROOT?.trim();
1892
+ if (!override) return null;
1893
+ const overrideCwd = process.env.KODY_DEFINITIONS_ROOT_CWD?.trim();
1894
+ if (overrideCwd && path6.resolve(cwd) !== path6.resolve(overrideCwd)) return null;
1895
+ const root = path6.resolve(override);
1896
+ const configured = readStoreManifest(root)?.assetRoots?.[kind];
1897
+ return typeof configured === "string" && configured.trim() ? path6.join(root, configured) : null;
1898
+ }
1899
+ function readStoreManifest(root) {
1900
+ const file = path6.join(root, "kody-store.json");
1901
+ if (!fs5.existsSync(file)) return null;
1902
+ try {
1903
+ return JSON.parse(fs5.readFileSync(file, "utf8"));
1904
+ } catch {
1905
+ return null;
1906
+ }
1884
1907
  }
1885
1908
  var init_definition_paths = __esm({
1886
1909
  "src/definition-paths.ts"() {
@@ -8959,10 +8982,13 @@ function validateWorkflow(value, options = {}) {
8959
8982
  }
8960
8983
  }
8961
8984
  const target = text(raw.to);
8962
- if (!target || !SAFE_STEP_ID.test(target)) {
8985
+ if (!target || target !== "$end" && !SAFE_STEP_ID.test(target)) {
8963
8986
  issue(issues, "invalid_transition_target", `${base}.to`, "workflow connection must name a valid target step");
8964
8987
  return;
8965
8988
  }
8989
+ if (target === "$end") {
8990
+ return;
8991
+ }
8966
8992
  if (!seen.has(target)) {
8967
8993
  issue(
8968
8994
  issues,
@@ -22687,6 +22713,13 @@ async function runGraphCapabilityWorkflow(parent, workflow, capability, base, ch
22687
22713
  const key = `${step.id}->${transition.to}`;
22688
22714
  state.transitionCounts[key] = (state.transitionCounts[key] ?? 0) + 1;
22689
22715
  }
22716
+ if (transition.to === "$end") {
22717
+ state.status = "done";
22718
+ delete state.currentStepId;
22719
+ delete state.blocker;
22720
+ await checkpoint?.(state);
22721
+ return withWorkflowBoundaryEval(capability, { ...result, workflowState: state });
22722
+ }
22690
22723
  state.currentStepId = transition.to;
22691
22724
  state.status = "running";
22692
22725
  delete state.blocker;
@@ -22862,7 +22895,7 @@ function valueMatches(actual, expected) {
22862
22895
  }
22863
22896
  function workflowStepTargetNumber(step, parent, chainData) {
22864
22897
  if (step.target === "pr") return workflowPrNumber(chainData) ?? workflowTargetFactNumber(step, chainData);
22865
- if (step.target === "issue") return workflowIssueNumber(parent);
22898
+ if (step.target === "issue") return workflowIssueNumber(parent) ?? workflowTargetFactNumber(step, chainData);
22866
22899
  return typeof parent.target === "number" ? parent.target : targetFromCliArgs(parent.cliArgs);
22867
22900
  }
22868
22901
  function workflowResumeStartIndex(steps, evidence) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.446",
3
+ "version": "0.4.447",
4
4
  "description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
5
5
  "license": "MIT",
6
6
  "type": "module",