@kody-ade/kody-engine 0.4.351 → 0.4.353

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/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.351",
18
+ version: "0.4.353",
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",
@@ -1983,15 +1983,19 @@ function parseWorkflowStep(value) {
1983
1983
  if (!capability || !isSafeSlug(capability)) return null;
1984
1984
  const implementation = stringField(raw.implementation);
1985
1985
  const action = stringField(raw.action);
1986
+ const evidence = stringField(raw.evidence);
1986
1987
  const agent = stringField(raw.agent);
1987
1988
  const reason = stringField(raw.reason);
1988
1989
  const target = stringField(raw.target);
1990
+ const targetFact = stringField(raw.targetFact ?? raw.target_fact);
1989
1991
  const cliArgs = raw.cliArgs;
1990
1992
  return {
1991
1993
  capability,
1992
1994
  ...action && isSafeSlug(action) ? { action } : {},
1993
1995
  ...implementation && isSafeSlug(implementation) ? { implementation } : {},
1996
+ ...evidence ? { evidence } : {},
1994
1997
  ...target === "issue" || target === "pr" ? { target } : {},
1998
+ ...targetFact ? { targetFact } : {},
1995
1999
  ...agent && isSafeSlug(agent) ? { agent } : {},
1996
2000
  ...reason ? { reason } : {},
1997
2001
  ...cliArgs && typeof cliArgs === "object" && !Array.isArray(cliArgs) ? { cliArgs } : {},
@@ -9324,6 +9328,13 @@ var init_goalCapabilityScheduling = __esm({
9324
9328
  });
9325
9329
 
9326
9330
  // src/scripts/advanceManagedGoal.ts
9331
+ function scalarFacts(facts) {
9332
+ return Object.fromEntries(
9333
+ Object.entries(facts).filter(
9334
+ ([key, value]) => key !== "pendingEvidence" && (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
9335
+ )
9336
+ );
9337
+ }
9327
9338
  function autonomyBlockReason(ctx, goalId, goal, dispatch2) {
9328
9339
  if (ctx.data.jobForce === true) return null;
9329
9340
  if (goal.runWithoutApproval !== true) {
@@ -9788,6 +9799,8 @@ var init_advanceManagedGoal = __esm({
9788
9799
  ctx.output.nextDispatch = {
9789
9800
  workflow: decision.workflow,
9790
9801
  cliArgs: decision.cliArgs,
9802
+ workflowFacts: scalarFacts(managed.facts),
9803
+ evidence: decision.evidence,
9791
9804
  ...decision.saveReport === true ? { saveReport: true } : {},
9792
9805
  resultTarget: { type: "goal", id: goal.id }
9793
9806
  };
@@ -9797,9 +9810,10 @@ var init_advanceManagedGoal = __esm({
9797
9810
  ctx.output.nextDispatch = {
9798
9811
  capability: decision.capability,
9799
9812
  cliArgs: decision.cliArgs,
9813
+ evidence: decision.evidence,
9800
9814
  ...decision.implementation ? { implementation: decision.implementation } : {},
9801
9815
  ...decision.saveReport === true ? { saveReport: true } : {},
9802
- resultTarget: { type: "goal", id: goal.id, evidence: decision.evidence }
9816
+ resultTarget: { type: "goal", id: goal.id }
9803
9817
  };
9804
9818
  ctx.output.reason = `dispatch ${decision.capability} for ${decision.evidence}`;
9805
9819
  };
@@ -10938,6 +10952,12 @@ function parseResultTarget(raw) {
10938
10952
  ...evidence ? { evidence } : {}
10939
10953
  };
10940
10954
  }
10955
+ function parseEvidenceContext(raw) {
10956
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
10957
+ const context = raw;
10958
+ const evidence = typeof context.evidence === "string" && context.evidence.trim().length > 0 ? context.evidence.trim() : void 0;
10959
+ return evidence ? { evidence } : null;
10960
+ }
10941
10961
  function collectGoalCapabilityEvidence(reports, results, fallbackGoalId, explicitEvidence) {
10942
10962
  const items = [];
10943
10963
  for (const report of reports) {
@@ -11042,8 +11062,9 @@ var init_applyCapabilityReports = __esm({
11042
11062
  const reports = collectReports(ctx.data.capabilityReports, agentResult);
11043
11063
  const results = collectResults2(ctx.data.capabilityResults, agentResult);
11044
11064
  const resultTarget = parseResultTarget(ctx.data.capabilityResultTarget);
11065
+ const evidenceContext = parseEvidenceContext(ctx.data.capabilityEvidence);
11045
11066
  const resultGoalId = resultTarget?.id ?? (typeof ctx.args.goal === "string" && ctx.args.goal.length > 0 ? ctx.args.goal : null);
11046
- const explicitEvidence = resultTarget?.evidence ?? (typeof ctx.args.evidence === "string" && ctx.args.evidence.length > 0 ? ctx.args.evidence : void 0);
11067
+ const explicitEvidence = evidenceContext?.evidence ?? resultTarget?.evidence ?? (typeof ctx.args.evidence === "string" && ctx.args.evidence.length > 0 ? ctx.args.evidence : void 0);
11047
11068
  const evidenceItems = collectGoalCapabilityEvidence(reports, results, resultGoalId, explicitEvidence);
11048
11069
  if (evidenceItems.length === 0) return;
11049
11070
  const evidenceByGoal = groupGoalEvidence(evidenceItems);
@@ -20470,6 +20491,8 @@ function handoffToJob(handoff) {
20470
20491
  workflow: handoff.workflow,
20471
20492
  implementation: handoff.implementation,
20472
20493
  cliArgs: handoff.cliArgs,
20494
+ workflowFacts: handoff.workflowFacts,
20495
+ evidence: handoff.evidence,
20473
20496
  flavor: "instant",
20474
20497
  saveReport: handoff.saveReport === true,
20475
20498
  resultTarget: handoff.resultTarget
@@ -20814,6 +20837,8 @@ function validateJob(input) {
20814
20837
  schedule: typeof j.schedule === "string" ? j.schedule : void 0,
20815
20838
  target: typeof j.target === "number" ? j.target : void 0,
20816
20839
  cliArgs: j.cliArgs ?? {},
20840
+ workflowFacts: j.workflowFacts && typeof j.workflowFacts === "object" && !Array.isArray(j.workflowFacts) ? j.workflowFacts : void 0,
20841
+ evidence: parseJobEvidence(j),
20817
20842
  flavor: j.flavor,
20818
20843
  force: j.force === true,
20819
20844
  saveReport: j.saveReport === true,
@@ -20825,13 +20850,18 @@ function parseCapabilityResultTarget(raw) {
20825
20850
  const target = raw;
20826
20851
  if (target.type !== "goal") return void 0;
20827
20852
  if (typeof target.id !== "string" || target.id.trim().length === 0) return void 0;
20828
- const evidence = typeof target.evidence === "string" && target.evidence.trim().length > 0 ? target.evidence.trim() : void 0;
20829
20853
  return {
20830
20854
  type: "goal",
20831
- id: target.id.trim(),
20832
- ...evidence ? { evidence } : {}
20855
+ id: target.id.trim()
20833
20856
  };
20834
20857
  }
20858
+ function parseJobEvidence(job) {
20859
+ if (typeof job.evidence === "string" && job.evidence.trim().length > 0) return job.evidence.trim();
20860
+ const target = job.resultTarget;
20861
+ if (!target || typeof target !== "object" || Array.isArray(target)) return void 0;
20862
+ const evidence = target.evidence;
20863
+ return typeof evidence === "string" && evidence.trim().length > 0 ? evidence.trim() : void 0;
20864
+ }
20835
20865
  async function runJob(job, base) {
20836
20866
  const valid = validateJob(job);
20837
20867
  const action = valid.action ?? valid.capability;
@@ -20891,6 +20921,7 @@ async function runCapabilityImplementationStep(valid, profileName, capabilityIde
20891
20921
  if (valid.schedule !== void 0 && valid.schedule.length > 0) preloadedData.jobSchedule = valid.schedule;
20892
20922
  if (valid.saveReport === true) preloadedData.jobSaveReport = true;
20893
20923
  if (valid.force === true) preloadedData.jobForce = true;
20924
+ if (valid.evidence) preloadedData.capabilityEvidence = { evidence: valid.evidence };
20894
20925
  if (valid.resultTarget) preloadedData.capabilityResultTarget = valid.resultTarget;
20895
20926
  if (capabilityContext) {
20896
20927
  preloadedData.capabilitySlug = capabilityContext.slug;
@@ -20943,13 +20974,15 @@ async function runCapabilityWorkflow(parent, workflow, capability, base) {
20943
20974
  workflowTitle: capability.title,
20944
20975
  workflowStepCount: workflow.steps.length,
20945
20976
  workflowIssueNumber: workflowIssueNumber(parent),
20977
+ workflowFacts: parent.workflowFacts ?? {},
20946
20978
  workflowStack: [
20947
20979
  ...Array.isArray(base.preloadedData?.workflowStack) ? base.preloadedData.workflowStack.filter((entry) => typeof entry === "string") : [],
20948
20980
  capability.slug
20949
20981
  ]
20950
20982
  };
20951
20983
  let result = { exitCode: 0 };
20952
- for (let index = 0; index < workflow.steps.length; index++) {
20984
+ const startIndex = workflowResumeStartIndex(workflow.steps, parent.evidence);
20985
+ for (let index = startIndex; index < workflow.steps.length; index++) {
20953
20986
  const step = workflow.steps[index];
20954
20987
  const label = step.action ?? step.capability;
20955
20988
  if (!shouldRunWorkflowStep(step, chainData)) {
@@ -21038,9 +21071,11 @@ function workflowStepToJob(step, parent, chainData) {
21038
21071
  ...parent.schedule ? { schedule: parent.schedule } : {},
21039
21072
  ...typeof target === "number" ? { target } : {},
21040
21073
  cliArgs,
21074
+ ...step.evidence ? { evidence: step.evidence } : parent.evidence ? { evidence: parent.evidence } : {},
21041
21075
  flavor: parent.flavor,
21042
21076
  force: parent.force,
21043
- saveReport: step.saveReport === true || parent.saveReport === true
21077
+ saveReport: step.saveReport === true || parent.saveReport === true,
21078
+ ...parent.resultTarget ? { resultTarget: parent.resultTarget } : {}
21044
21079
  };
21045
21080
  }
21046
21081
  function shouldRunWorkflowStep(step, data) {
@@ -21081,10 +21116,23 @@ function valueMatches(actual, expected) {
21081
21116
  return actual === expected;
21082
21117
  }
21083
21118
  function workflowStepTargetNumber(step, parent, chainData) {
21084
- if (step.target === "pr") return workflowPrNumber(chainData) ?? targetFromCliArgs(step.cliArgs ?? {});
21119
+ if (step.target === "pr")
21120
+ return workflowPrNumber(chainData) ?? workflowTargetFactNumber(step, chainData) ?? targetFromCliArgs(step.cliArgs ?? {});
21085
21121
  if (step.target === "issue") return workflowIssueNumber(parent);
21086
21122
  return typeof parent.target === "number" ? parent.target : targetFromCliArgs({ ...parent.cliArgs, ...step.cliArgs ?? {} });
21087
21123
  }
21124
+ function workflowResumeStartIndex(steps, evidence) {
21125
+ if (!evidence) return 0;
21126
+ const index = steps.findIndex((step) => step.evidence === evidence);
21127
+ return index >= 0 ? index : 0;
21128
+ }
21129
+ function workflowTargetFactNumber(step, data) {
21130
+ if (!step.targetFact) return void 0;
21131
+ const facts = data.workflowFacts;
21132
+ if (!facts || typeof facts !== "object" || Array.isArray(facts)) return void 0;
21133
+ const value = facts[step.targetFact];
21134
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
21135
+ }
21088
21136
  function workflowIssueNumber(parent) {
21089
21137
  return typeof parent.target === "number" ? parent.target : targetFromCliArgs(parent.cliArgs);
21090
21138
  }
@@ -401,7 +401,6 @@ export interface OutputContract {
401
401
  export interface CapabilityResultTarget {
402
402
  type: "goal"
403
403
  id: string
404
- evidence?: string
405
404
  }
406
405
 
407
406
  // ────────────────────────────────────────────────────────────────────────────
@@ -438,6 +437,8 @@ export interface Context {
438
437
  workflow?: string
439
438
  implementation?: string
440
439
  cliArgs: Record<string, unknown>
440
+ workflowFacts?: Record<string, unknown>
441
+ evidence?: string
441
442
  saveReport?: boolean
442
443
  resultTarget?: CapabilityResultTarget
443
444
  }
@@ -450,6 +451,8 @@ export interface Context {
450
451
  workflow?: string
451
452
  implementation?: string
452
453
  cliArgs: Record<string, unknown>
454
+ workflowFacts?: Record<string, unknown>
455
+ evidence?: string
453
456
  saveReport?: boolean
454
457
  resultTarget?: CapabilityResultTarget
455
458
  }
@@ -517,6 +520,10 @@ export interface Job {
517
520
  target?: number
518
521
  /** Args passed through to the implementation (mirrors DispatchResult.cliArgs). */
519
522
  cliArgs: Record<string, unknown>
523
+ /** Internal workflow resume context. Not passed to capability CLI args. */
524
+ workflowFacts?: Record<string, unknown>
525
+ /** Evidence this capability run is expected to report, independent of who consumes it. */
526
+ evidence?: string
520
527
  /** Run once now ("instant") or on the schedule ("scheduled"). */
521
528
  flavor: JobFlavor
522
529
  /** Manual force-run (bypass cadence) for a scheduled job. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.351",
3
+ "version": "0.4.353",
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",