@kody-ade/kody-engine 0.4.484 → 0.4.487

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.484",
18
+ version: "0.4.487",
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",
@@ -4315,6 +4315,17 @@ function validateCapabilityContractValue(boundary, schema, value) {
4315
4315
  throw new CapabilityContractValidationError(boundary, validate.errors ?? []);
4316
4316
  }
4317
4317
  }
4318
+ function capabilityContractInput(inputs, args) {
4319
+ const isGenericRunnerInput = inputs.some((input) => input.name === "capability") && inputs.some((input) => input.name === "input");
4320
+ if (!isGenericRunnerInput) return args;
4321
+ const value = args.input;
4322
+ if (typeof value !== "string") return value;
4323
+ try {
4324
+ return JSON.parse(value);
4325
+ } catch {
4326
+ return value;
4327
+ }
4328
+ }
4318
4329
  var validator, CapabilityContractValidationError;
4319
4330
  var init_capability_contract_validation = __esm({
4320
4331
  "src/agency/capability-contract-validation.ts"() {
@@ -15464,6 +15475,18 @@ async function resolveRuntimeSecret(name, ctx, opts = {}) {
15464
15475
  }
15465
15476
  return envSecret(name, env);
15466
15477
  }
15478
+ async function resolveRuntimeSecrets(names, ctx, opts = {}) {
15479
+ const declared = Array.isArray(names) ? [...new Set(names.filter((name) => typeof name === "string" && /^[A-Z][A-Z0-9_]*$/.test(name)))] : [];
15480
+ const resolved = await Promise.all(
15481
+ declared.map(async (name) => ({ name, result: await resolveRuntimeSecret(name, ctx, opts) }))
15482
+ );
15483
+ return {
15484
+ environment: Object.fromEntries(
15485
+ resolved.flatMap(({ name, result }) => result.value ? [[name, result.value]] : [])
15486
+ ),
15487
+ warnings: resolved.flatMap(({ result }) => result.warning ? [result.warning] : [])
15488
+ };
15489
+ }
15467
15490
  var init_runtimeSecrets = __esm({
15468
15491
  "src/scripts/runtimeSecrets.ts"() {
15469
15492
  "use strict";
@@ -19139,16 +19162,6 @@ import * as fs47 from "fs";
19139
19162
  function formatDuration2(timeoutMs) {
19140
19163
  return timeoutMs % 6e4 === 0 ? `${timeoutMs / 6e4} minutes` : `${timeoutMs}ms`;
19141
19164
  }
19142
- function declaredSecrets(names, parent) {
19143
- if (!Array.isArray(names)) return {};
19144
- const secrets = {};
19145
- for (const name of names) {
19146
- if (typeof name !== "string" || !/^[A-Z][A-Z0-9_]*$/.test(name)) continue;
19147
- const value = parent[name];
19148
- if (value !== void 0) secrets[name] = value;
19149
- }
19150
- return secrets;
19151
- }
19152
19165
  function isRegularFile2(filePath) {
19153
19166
  try {
19154
19167
  const stat = fs47.lstatSync(filePath);
@@ -19165,6 +19178,7 @@ var init_runSimpleCapabilityScript = __esm({
19165
19178
  "src/scripts/runSimpleCapabilityScript.ts"() {
19166
19179
  "use strict";
19167
19180
  init_capabilityResult();
19181
+ init_runtimeSecrets();
19168
19182
  init_tickShellRunner();
19169
19183
  DEFAULT_SCRIPT_TIMEOUT_MS = 5 * 60 * 1e3;
19170
19184
  SCRIPT_MAX_OUTPUT_BYTES = 1024 * 1024;
@@ -19177,13 +19191,17 @@ var init_runSimpleCapabilityScript = __esm({
19177
19191
  return;
19178
19192
  }
19179
19193
  const capabilityEnvironment = isStringRecord(ctx.data.capabilityEnvironment) ? ctx.data.capabilityEnvironment : {};
19180
- const capabilitySecrets = declaredSecrets(ctx.data.capabilitySecretNames, process.env);
19194
+ const capabilitySecrets = await resolveRuntimeSecrets(ctx.data.capabilitySecretNames, ctx);
19195
+ for (const warning of capabilitySecrets.warnings) {
19196
+ process.stderr.write(`\u2192 kody: WARNING ${warning}
19197
+ `);
19198
+ }
19181
19199
  const timeoutMs = typeof ctx.data.capabilityScriptTimeoutMs === "number" ? ctx.data.capabilityScriptTimeoutMs : DEFAULT_SCRIPT_TIMEOUT_MS;
19182
19200
  const result = spawnSync3("bash", [scriptPath], {
19183
19201
  cwd: ctx.cwd,
19184
19202
  env: {
19185
19203
  ...buildTickChildEnv(process.env, false),
19186
- ...capabilitySecrets,
19204
+ ...capabilitySecrets.environment,
19187
19205
  ...capabilityEnvironment
19188
19206
  },
19189
19207
  stdio: ["ignore", "pipe", "pipe"],
@@ -20943,7 +20961,11 @@ async function runImplementation(profileName, input) {
20943
20961
  try {
20944
20962
  args = validateInputs(profile.inputs, input.cliArgs);
20945
20963
  if (profile.canonicalContract) {
20946
- validateCapabilityContractValue("input", profile.canonicalContract.inputSchema, args);
20964
+ validateCapabilityContractValue(
20965
+ "input",
20966
+ profile.canonicalContract.inputSchema,
20967
+ capabilityContractInput(profile.inputs, args)
20968
+ );
20947
20969
  }
20948
20970
  } catch (err) {
20949
20971
  return finishAndEnd({ exitCode: 64, reason: err instanceof Error ? err.message : String(err) });
@@ -24218,14 +24240,14 @@ function primaryNumericInputName(implementation) {
24218
24240
  const intInput = inputs.find((i) => i.type === "int" && i.required);
24219
24241
  return intInput?.name ?? null;
24220
24242
  }
24221
- function resolveOperatorAction(action) {
24222
- return resolveCapabilityAction(action);
24243
+ function resolveOperatorAction(action, projectCapabilitiesRoot) {
24244
+ return resolveCapabilityAction(action, projectCapabilitiesRoot);
24223
24245
  }
24224
- function resolveConfiguredAction(action) {
24225
- return resolveCapabilityAction(action);
24246
+ function resolveConfiguredAction(action, projectCapabilitiesRoot) {
24247
+ return resolveCapabilityAction(action, projectCapabilitiesRoot);
24226
24248
  }
24227
- function requiredRoute(action) {
24228
- const route = resolveConfiguredAction(action);
24249
+ function requiredRoute(action, projectCapabilitiesRoot) {
24250
+ const route = resolveConfiguredAction(action, projectCapabilitiesRoot);
24229
24251
  if (!route) throw new Error(`required capability action not found: ${action}`);
24230
24252
  return route;
24231
24253
  }
@@ -24241,9 +24263,14 @@ function routeResult(route, cliArgs, target, why) {
24241
24263
  return result;
24242
24264
  }
24243
24265
  function autoDispatch(opts) {
24266
+ const projectCapabilitiesRoot = opts?.projectCapabilitiesRoot;
24244
24267
  const explicit = opts?.explicit;
24245
24268
  if (explicit?.issueNumber && explicit.issueNumber > 0) {
24246
- return routeResult(requiredRoute("run"), { issue: explicit.issueNumber }, explicit.issueNumber);
24269
+ return routeResult(
24270
+ requiredRoute("run", projectCapabilitiesRoot),
24271
+ { issue: explicit.issueNumber },
24272
+ explicit.issueNumber
24273
+ );
24247
24274
  }
24248
24275
  const eventName = process.env.GITHUB_EVENT_NAME;
24249
24276
  const eventPath = process.env.GITHUB_EVENT_PATH;
@@ -24259,7 +24286,7 @@ function autoDispatch(opts) {
24259
24286
  const n = parseInt(String(inputs2?.issue_number ?? ""), 10);
24260
24287
  if (!Number.isNaN(n) && n > 0) {
24261
24288
  const actionName = String(inputs2?.capability ?? "").trim() || "run";
24262
- const route2 = resolveConfiguredAction(actionName);
24289
+ const route2 = resolveConfiguredAction(actionName, projectCapabilitiesRoot);
24263
24290
  if (!route2) return null;
24264
24291
  const base = String(inputs2?.base ?? "").trim();
24265
24292
  const profileInputs = getProfileInputs(route2.implementation);
@@ -24281,7 +24308,7 @@ function autoDispatch(opts) {
24281
24308
  if (actionName && (action === "opened" || action === "synchronize" || action === "reopened")) {
24282
24309
  const pullRequest = objectValue(event.pull_request);
24283
24310
  if (isReleasePullRequest(pullRequest, opts?.config)) return null;
24284
- const route2 = resolveConfiguredAction(actionName);
24311
+ const route2 = resolveConfiguredAction(actionName, projectCapabilitiesRoot);
24285
24312
  if (!route2) return null;
24286
24313
  const prNum = Number(pullRequest?.number ?? event.number ?? 0);
24287
24314
  if (prNum > 0) {
@@ -24320,7 +24347,7 @@ function autoDispatch(opts) {
24320
24347
  let route = null;
24321
24348
  let consumedFirstToken = false;
24322
24349
  if (aliased) {
24323
- route = resolveOperatorAction(aliased);
24350
+ route = resolveOperatorAction(aliased, projectCapabilitiesRoot);
24324
24351
  if (route) {
24325
24352
  consumedFirstToken = true;
24326
24353
  } else if (firstToken && aliases[firstToken] && aliases[firstToken] === aliased) {
@@ -24332,7 +24359,7 @@ function autoDispatch(opts) {
24332
24359
  }
24333
24360
  if (!route && !firstToken) {
24334
24361
  const defaultAction = isPr ? opts?.config?.defaultPrImplementation ?? null : opts?.config?.defaultImplementation ?? null;
24335
- route = defaultAction ? resolveConfiguredAction(defaultAction) : null;
24362
+ route = defaultAction ? resolveConfiguredAction(defaultAction, projectCapabilitiesRoot) : null;
24336
24363
  }
24337
24364
  if (isBotAuthor && !consumedFirstToken) {
24338
24365
  process.stderr.write(
@@ -24343,14 +24370,14 @@ function autoDispatch(opts) {
24343
24370
  }
24344
24371
  if (!route) {
24345
24372
  if (!firstToken) return null;
24346
- const profileMissing = aliased ? resolveOperatorAction(aliased) === null : true;
24373
+ const profileMissing = aliased ? resolveOperatorAction(aliased, projectCapabilitiesRoot) === null : true;
24347
24374
  process.stderr.write(
24348
24375
  `[kody] dispatch: no capability action resolved for issue_comment (firstToken=${firstToken ?? "<none>"}, aliased=${aliased ?? "<none>"}, actionFound=${!profileMissing}, defaultImplementation=${opts?.config?.defaultImplementation ?? "<unset>"}, defaultPrImplementation=${opts?.config?.defaultPrImplementation ?? "<unset>"})
24349
24376
  `
24350
24377
  );
24351
24378
  return null;
24352
24379
  }
24353
- const inputs = getProfileInputs(route.implementation);
24380
+ const inputs = getCapabilityActionInputs(route.action, projectCapabilitiesRoot);
24354
24381
  const effectiveInputs = inputs ?? [];
24355
24382
  const unknownProfile = inputs === null;
24356
24383
  const rest = extractCommentRest(afterTag, consumedFirstToken ? firstToken : null);
@@ -24425,7 +24452,7 @@ function autoDispatchTyped(opts) {
24425
24452
  reason: tokenRaw ? `polite-word lead-in '${tokenRaw}', no default capability action configured` : "no subcommand token, no default capability action configured"
24426
24453
  };
24427
24454
  }
24428
- const available = listCapabilityActions().map((e) => e.action).filter((n) => !n.startsWith("goal-") && !n.startsWith("job-")).sort();
24455
+ const available = listCapabilityActions(opts?.projectCapabilitiesRoot).map((e) => e.action).filter((n) => !n.startsWith("goal-") && !n.startsWith("job-")).sort();
24429
24456
  return { kind: "unrecognized", token: tokenRaw, target: targetNum, isPr, available };
24430
24457
  }
24431
24458
  function dispatchScheduledWatches(opts) {
@@ -24636,7 +24663,7 @@ Options:
24636
24663
  --package-manager Override package-manager auto-detect
24637
24664
 
24638
24665
  Environment:
24639
- ALL_SECRETS JSON blob of all GitHub secrets (auto-populated in CI)
24666
+ ALL_SECRETS Legacy JSON secret blob (supported, never generated by current templates)
24640
24667
  KODY_TOKEN|GH_TOKEN|GITHUB_TOKEN|GH_PAT auth token for gh/git operations
24641
24668
 
24642
24669
  Exit codes (inherited from kody run):
@@ -24953,7 +24980,8 @@ async function runCi(argv) {
24953
24980
  } catch (err) {
24954
24981
  earlyConfigError = err instanceof Error ? err : new Error(String(err));
24955
24982
  }
24956
- const autoFallback = !args.issueNumber ? autoDispatch({ config: earlyConfig }) : null;
24983
+ const dispatchCapabilitiesRoot = capabilitiesRoot(cwd);
24984
+ const autoFallback = !args.issueNumber ? autoDispatch({ config: earlyConfig, projectCapabilitiesRoot: dispatchCapabilitiesRoot }) : null;
24957
24985
  const eventName = process.env.GITHUB_EVENT_NAME;
24958
24986
  const scheduledActionsWake = isScheduledActionsWake();
24959
24987
  const dispatchEventPath = process.env.GITHUB_EVENT_PATH;
@@ -25135,7 +25163,10 @@ async function runCi(argv) {
25135
25163
  return runScheduledFanOut(cwd, args, { force: manualWorkflowDispatch });
25136
25164
  }
25137
25165
  if (!args.issueNumber && !autoFallback && process.env.GITHUB_EVENT_NAME) {
25138
- const outcome = autoDispatchTyped({ config: earlyConfig });
25166
+ const outcome = autoDispatchTyped({
25167
+ config: earlyConfig,
25168
+ projectCapabilitiesRoot: dispatchCapabilitiesRoot
25169
+ });
25139
25170
  if (outcome.kind === "rejected") {
25140
25171
  try {
25141
25172
  unpackAllSecrets();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.484",
3
+ "version": "0.4.487",
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",
@@ -75,7 +75,10 @@ jobs:
75
75
  node-version: 22
76
76
 
77
77
  - env:
78
- ALL_SECRETS: ${{ toJSON(secrets) }}
78
+ GH_PAT: ${{ secrets.GH_PAT }}
79
+ KODY_TOKEN: ${{ secrets.KODY_TOKEN }}
80
+ KODY_APP_ID: ${{ secrets.KODY_APP_ID }}
81
+ KODY_APP_PRIVATE_KEY: ${{ secrets.KODY_APP_PRIVATE_KEY }}
79
82
  SESSION_ID: ${{ inputs.sessionId }}
80
83
  INIT_MESSAGE: ${{ inputs.message }}
81
84
  MODEL: ${{ inputs.model }}