@kody-ade/kody-engine 0.4.308 → 0.4.309

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 +189 -7
  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.308",
18
+ version: "0.4.309",
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",
@@ -7052,16 +7052,76 @@ function enrichGoalRunLogEvent(config, data, logPath, event) {
7052
7052
  const stateRepo = stateRepoContext(config, event.goalId, logPath);
7053
7053
  const trigger = event.trigger ?? triggerContext();
7054
7054
  const job = event.job ?? jobContext(data);
7055
- return pruneUndefined({
7055
+ const run = event.run ?? runContext(data);
7056
+ const links = event.links ?? linkContext(stateRepo);
7057
+ const enriched = pruneUndefined({
7056
7058
  ...event,
7057
- run: event.run ?? runContext(data),
7059
+ run,
7058
7060
  repo: event.repo ?? repoContext(config),
7059
7061
  stateRepo: event.stateRepo ?? stateRepo,
7060
7062
  trigger,
7061
7063
  job,
7062
7064
  dispatchContext: event.dispatchContext ?? dispatchContext(event, trigger, job),
7063
- links: event.links ?? linkContext(stateRepo)
7065
+ links
7066
+ });
7067
+ enriched.trace = event.trace ?? goalRunTrace(enriched);
7068
+ return enriched;
7069
+ }
7070
+ function goalRunTrace(event) {
7071
+ const run = recordValue2(event.run);
7072
+ const trigger = recordValue2(event.trigger);
7073
+ const goal = recordValue2(event.goal);
7074
+ const inspection = recordValue2(event.inspection);
7075
+ const capabilityOutput = recordValue2(inspection?.capabilityOutput);
7076
+ return pruneUndefined({
7077
+ version: 1,
7078
+ runId: stringValue2(run?.id) ?? void 0,
7079
+ workflowRunId: stringValue2(run?.githubRunId) ?? void 0,
7080
+ triggerKind: stringValue2(trigger?.kind) ?? void 0,
7081
+ source: event.source,
7082
+ event: event.event,
7083
+ goal: pruneUndefined({
7084
+ id: event.goalId,
7085
+ type: event.goalType ?? stringValue2(goal?.type) ?? void 0,
7086
+ state: event.goalState ?? stringValue2(goal?.state) ?? void 0,
7087
+ stage: event.stage ?? stringValue2(goal?.stage) ?? void 0
7088
+ }),
7089
+ evidence: goalTraceEvidence(event, goal, inspection),
7090
+ capability: event.dispatch ?? capabilityDispatchFromOutput(capabilityOutput),
7091
+ result: goalTraceResult(event, capabilityOutput),
7092
+ change: event.change,
7093
+ links: event.links
7094
+ });
7095
+ }
7096
+ function goalTraceEvidence(event, goal, inspection) {
7097
+ const expectedEvidence = recordValue2(inspection?.expectedEvidence);
7098
+ const out = pruneUndefined({
7099
+ current: event.evidence,
7100
+ required: stringArrayValue(goal?.requiredEvidence) ?? stringArrayValue(inspection?.requiredEvidence) ?? void 0,
7101
+ satisfied: stringArrayValue(goal?.satisfiedEvidence) ?? stringArrayValue(inspection?.satisfiedEvidence) ?? void 0,
7102
+ missing: stringArrayValue(goal?.missingEvidence) ?? stringArrayValue(inspection?.missingEvidence) ?? stringArrayValue(expectedEvidence?.missingBefore) ?? void 0,
7103
+ pending: stringValue2(goal?.pendingEvidence) ?? stringValue2(inspection?.pendingEvidence) ?? stringValue2(expectedEvidence?.pendingBefore) ?? void 0,
7104
+ values: event.evidenceValues
7064
7105
  });
7106
+ return Object.keys(out).length > 0 ? out : void 0;
7107
+ }
7108
+ function capabilityDispatchFromOutput(output) {
7109
+ if (!output) return void 0;
7110
+ const dispatch2 = pruneUndefined({
7111
+ capability: stringValue2(output.capability) ?? void 0,
7112
+ executable: stringValue2(output.executable) ?? void 0,
7113
+ action: stringValue2(output.action) ?? void 0
7114
+ });
7115
+ return Object.keys(dispatch2).length > 0 ? dispatch2 : void 0;
7116
+ }
7117
+ function goalTraceResult(event, capabilityOutput) {
7118
+ const result = pruneUndefined({
7119
+ status: event.status ?? stringValue2(capabilityOutput?.status) ?? void 0,
7120
+ summary: event.reason ?? stringValue2(capabilityOutput?.summary) ?? void 0,
7121
+ blockers: event.inspection ? stringArrayValue(capabilityOutput?.blockers) ?? void 0 : void 0,
7122
+ artifacts: event.artifacts
7123
+ });
7124
+ return Object.keys(result).length > 0 ? result : void 0;
7065
7125
  }
7066
7126
  function runContext(data) {
7067
7127
  const runId = process.env.GITHUB_RUN_ID?.trim();
@@ -12218,6 +12278,126 @@ var init_ensurePr = __esm({
12218
12278
  }
12219
12279
  });
12220
12280
 
12281
+ // src/agencyBoundaryEval.ts
12282
+ function evaluateAgencyBoundaries(input) {
12283
+ const findings = [];
12284
+ const results = input.results ?? [];
12285
+ findings.push(evaluateObserveBoundary(input.capabilityKind, results));
12286
+ findings.push(evaluateVerifyBoundary(input.capabilityKind, results));
12287
+ findings.push(evaluateGoalOwnershipBoundary(results));
12288
+ return {
12289
+ version: 1,
12290
+ status: findings.some((finding) => finding.status === "fail") ? "fail" : "pass",
12291
+ ...input.capability ? { capability: input.capability } : {},
12292
+ ...input.capabilityKind ? { capabilityKind: input.capabilityKind } : {},
12293
+ findings
12294
+ };
12295
+ }
12296
+ function evaluateObserveBoundary(capabilityKind, results) {
12297
+ if (capabilityKind !== "observe") {
12298
+ return pass("observe-does-not-act", "capability is not observe", { capabilityKind });
12299
+ }
12300
+ const actionResults = results.filter(resultLooksLikeAction);
12301
+ if (actionResults.length === 0) {
12302
+ return pass("observe-does-not-act", "observe capability reported facts without action output", {
12303
+ resultCount: results.length
12304
+ });
12305
+ }
12306
+ return fail2("observe-does-not-act", "observe capability returned action-shaped output", {
12307
+ resultCount: results.length,
12308
+ actionResults: actionResults.map(resultSummary)
12309
+ });
12310
+ }
12311
+ function evaluateVerifyBoundary(capabilityKind, results) {
12312
+ if (capabilityKind !== "verify") {
12313
+ return pass("verify-does-not-fix", "capability is not verify", { capabilityKind });
12314
+ }
12315
+ const actionResults = results.filter(resultLooksLikeAction);
12316
+ if (actionResults.length === 0) {
12317
+ return pass("verify-does-not-fix", "verify capability returned verdict evidence without action output", {
12318
+ resultCount: results.length
12319
+ });
12320
+ }
12321
+ return fail2("verify-does-not-fix", "verify capability returned fix/change output", {
12322
+ resultCount: results.length,
12323
+ actionResults: actionResults.map(resultSummary)
12324
+ });
12325
+ }
12326
+ function evaluateGoalOwnershipBoundary(results) {
12327
+ const targetBearing = results.filter((result) => result.target?.type === "goal");
12328
+ if (targetBearing.length === 0) {
12329
+ return pass("capability-does-not-own-goal-progress", "capability output is parent-neutral", {
12330
+ resultCount: results.length
12331
+ });
12332
+ }
12333
+ return fail2("capability-does-not-own-goal-progress", "capability output names a goal target", {
12334
+ resultCount: results.length,
12335
+ targetBearingResults: targetBearing.map(resultSummary)
12336
+ });
12337
+ }
12338
+ function resultLooksLikeAction(result) {
12339
+ if (result.status === "changed") return true;
12340
+ return Object.keys(result.facts).some((key) => ACTION_FACT_KEYS.has(key));
12341
+ }
12342
+ function resultSummary(result) {
12343
+ return {
12344
+ status: result.status,
12345
+ summary: result.summary,
12346
+ target: result.target,
12347
+ actionFactKeys: Object.keys(result.facts).filter((key) => ACTION_FACT_KEYS.has(key))
12348
+ };
12349
+ }
12350
+ function pass(rule, message, evidence) {
12351
+ return { rule, status: "pass", message, evidence };
12352
+ }
12353
+ function fail2(rule, message, evidence) {
12354
+ return { rule, status: "fail", message, evidence };
12355
+ }
12356
+ var ACTION_FACT_KEYS;
12357
+ var init_agencyBoundaryEval = __esm({
12358
+ "src/agencyBoundaryEval.ts"() {
12359
+ "use strict";
12360
+ ACTION_FACT_KEYS = /* @__PURE__ */ new Set(["changedResources", "createdResources", "actionResult"]);
12361
+ }
12362
+ });
12363
+
12364
+ // src/scripts/evaluateAgencyBoundaries.ts
12365
+ function collectResults2(raw, agentResult) {
12366
+ const out = [];
12367
+ if (Array.isArray(raw)) {
12368
+ for (const item of raw) {
12369
+ const parsed = parseCapabilityResult(item);
12370
+ if (parsed) out.push(parsed);
12371
+ }
12372
+ }
12373
+ if (agentResult?.finalText) out.push(...parseCapabilityResultsFromText(agentResult.finalText));
12374
+ return out;
12375
+ }
12376
+ var evaluateAgencyBoundariesScript;
12377
+ var init_evaluateAgencyBoundaries = __esm({
12378
+ "src/scripts/evaluateAgencyBoundaries.ts"() {
12379
+ "use strict";
12380
+ init_agencyBoundaryEval();
12381
+ init_capabilityResult();
12382
+ evaluateAgencyBoundariesScript = async (ctx, profile, agentResult) => {
12383
+ const results = collectResults2(ctx.data.capabilityResults ?? ctx.data.dutyResults, agentResult);
12384
+ const evalResult = evaluateAgencyBoundaries({
12385
+ capability: profile.name,
12386
+ capabilityKind: profile.capabilityKind,
12387
+ results
12388
+ });
12389
+ ctx.data.agencyBoundaryEval = evalResult;
12390
+ process.stdout.write(`KODY_AGENCY_BOUNDARY_EVAL=${JSON.stringify(evalResult)}
12391
+ `);
12392
+ if (evalResult.status === "fail") {
12393
+ const failed = evalResult.findings.filter((finding) => finding.status === "fail").map((finding) => finding.rule);
12394
+ ctx.output.exitCode = ctx.output.exitCode === 0 ? 99 : ctx.output.exitCode;
12395
+ ctx.output.reason = ctx.output.reason ? `${ctx.output.reason}; agency boundary eval failed: ${failed.join(", ")}` : `agency boundary eval failed: ${failed.join(", ")}`;
12396
+ }
12397
+ };
12398
+ }
12399
+ });
12400
+
12221
12401
  // src/scripts/failOnceTaskJob.ts
12222
12402
  var failOnceTaskJob;
12223
12403
  var init_failOnceTaskJob = __esm({
@@ -14088,7 +14268,7 @@ var init_markFlowSuccess = __esm({
14088
14268
  });
14089
14269
 
14090
14270
  // src/goal/operations.ts
14091
- function fail2(err) {
14271
+ function fail3(err) {
14092
14272
  if (err instanceof Error) {
14093
14273
  const lines = err.message.split("\n").filter(Boolean);
14094
14274
  return { ok: false, error: lines[0] ?? err.message };
@@ -14100,7 +14280,7 @@ function commentOnIssue(issueNumber, body, cwd) {
14100
14280
  gh(["issue", "comment", String(issueNumber), "--body", body], { cwd });
14101
14281
  return { ok: true };
14102
14282
  } catch (err) {
14103
- return fail2(err);
14283
+ return fail3(err);
14104
14284
  }
14105
14285
  }
14106
14286
  function mergePrSquash(prNumber, cwd) {
@@ -14108,7 +14288,7 @@ function mergePrSquash(prNumber, cwd) {
14108
14288
  gh(["pr", "merge", String(prNumber), "--squash", "--delete-branch"], { cwd });
14109
14289
  return { ok: true };
14110
14290
  } catch (err) {
14111
- return fail2(err);
14291
+ return fail3(err);
14112
14292
  }
14113
14293
  }
14114
14294
  var init_operations = __esm({
@@ -17988,6 +18168,7 @@ var init_scripts = __esm({
17988
18168
  init_dispatchClassified();
17989
18169
  init_dispatchNextTaskJob();
17990
18170
  init_ensurePr();
18171
+ init_evaluateAgencyBoundaries();
17991
18172
  init_failOnceTaskJob();
17992
18173
  init_finalizeTerminal();
17993
18174
  init_finishFlow();
@@ -18132,6 +18313,7 @@ var init_scripts = __esm({
18132
18313
  stageMergeConflicts,
18133
18314
  commitAndPush: commitAndPush2,
18134
18315
  ensurePr: ensurePr2,
18316
+ evaluateAgencyBoundaries: evaluateAgencyBoundariesScript,
18135
18317
  postAgentComment,
18136
18318
  postIssueComment: postIssueComment2,
18137
18319
  postPlanComment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.308",
3
+ "version": "0.4.309",
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",