@kody-ade/kody-engine 0.4.202 → 0.4.203

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
@@ -551,7 +551,9 @@ __export(dutyMcp_exports, {
551
551
  dispatchWorkflow: () => dispatchWorkflow,
552
552
  ensureComment: () => ensureComment,
553
553
  ensureIssue: () => ensureIssue,
554
- readCheckRuns: () => readCheckRuns
554
+ parseDutyTrustMode: () => parseDutyTrustMode,
555
+ readCheckRuns: () => readCheckRuns,
556
+ readDutyTrustMode: () => readDutyTrustMode
555
557
  });
556
558
  import { createSdkMcpServer as createSdkMcpServer3, tool as tool3 } from "@anthropic-ai/claude-agent-sdk";
557
559
  import { z as z3 } from "zod";
@@ -645,6 +647,24 @@ function readLedger(label) {
645
647
  return { found: false, payload: { error: err instanceof Error ? err.message : String(err) } };
646
648
  }
647
649
  }
650
+ function parseDutyTrustMode(rawJson, dutySlug) {
651
+ try {
652
+ const parsed = JSON.parse(rawJson);
653
+ return parsed?.duties?.[dutySlug]?.mode === "auto" ? "auto" : "ask";
654
+ } catch {
655
+ return "ask";
656
+ }
657
+ }
658
+ function readDutyTrustMode(repoSlug, dutySlug) {
659
+ if (!dutySlug) return "ask";
660
+ try {
661
+ const b64 = gh(["api", `repos/${repoSlug}/contents/${TRUST_FILE_PATH}?ref=${TRUST_STATE_BRANCH}`, "--jq", ".content"]);
662
+ const json = Buffer.from(b64.trim(), "base64").toString("utf-8");
663
+ return parseDutyTrustMode(json, dutySlug);
664
+ } catch {
665
+ return "ask";
666
+ }
667
+ }
648
668
  function readCheckRuns(repoSlug, ref, ignoreNames) {
649
669
  const sha = gh(["api", `repos/${repoSlug}/commits/${ref}`, "--jq", ".sha"]).trim();
650
670
  const raw = gh([
@@ -703,6 +723,9 @@ function dispatchWorkflow(workflowFile, executable, issueNumber) {
703
723
  return { ok: false, error: err instanceof Error ? err.message : String(err) };
704
724
  }
705
725
  }
726
+ function trustRefusal(dutySlug) {
727
+ return `Not dispatched: duty \`${dutySlug ?? "?"}\` is in ASK mode (not trusted for autonomy). Do NOT retry the dispatch. Instead notify the operator (use recommend_to_operator, or rely on the tracking issue that already @-mentions them), then submit_state. To let this duty act on its own, grant it Auto on the dashboard Trust page.`;
728
+ }
706
729
  function buildDutyMcpServer(opts) {
707
730
  const workflowFile = opts.workflowFile ?? "kody.yml";
708
731
  const listTool = tool3(
@@ -728,6 +751,9 @@ function buildDutyMcpServer(opts) {
728
751
  pr: z3.number().int().positive().describe("PR number to repair.")
729
752
  },
730
753
  async (args) => {
754
+ if (readDutyTrustMode(opts.repoSlug, opts.dutySlug) !== "auto") {
755
+ return { content: [{ type: "text", text: trustRefusal(opts.dutySlug) }] };
756
+ }
731
757
  const result = dispatchVerb(workflowFile, verb, args.pr);
732
758
  const text = result.ok ? `Dispatched \`${verb}\` on PR #${args.pr}. The repair runs in its own workflow_dispatch \u2014 wait for the next tick to see the new headSha.` : `Dispatch failed for \`${verb}\` on PR #${args.pr}: ${result.error}`;
733
759
  return {
@@ -830,6 +856,9 @@ function buildDutyMcpServer(opts) {
830
856
  issueNumber: z3.number().int().positive().describe("Issue (or PR) number forwarded as issue_number.")
831
857
  },
832
858
  async (args) => {
859
+ if (readDutyTrustMode(opts.repoSlug, opts.dutySlug) !== "auto") {
860
+ return { content: [{ type: "text", text: trustRefusal(opts.dutySlug) }] };
861
+ }
833
862
  const result = dispatchWorkflow(workflowFile, args.executable, args.issueNumber);
834
863
  const text = result.ok ? `Dispatched \`${args.executable}\` on #${args.issueNumber} via workflow_dispatch.` : `Dispatch failed for \`${args.executable}\` on #${args.issueNumber}: ${result.error}`;
835
864
  return { content: [{ type: "text", text }] };
@@ -853,13 +882,15 @@ function buildDutyMcpServer(opts) {
853
882
  });
854
883
  return { server };
855
884
  }
856
- var FAIL_CONCLUSIONS, RUNNING_STATUSES, CHECK_FAIL_CONCLUSIONS, DEFAULT_IGNORE_CHECKS, trackMarker, commentMarker, DUTY_MCP_TOOL_NAMES;
885
+ var FAIL_CONCLUSIONS, RUNNING_STATUSES, TRUST_FILE_PATH, TRUST_STATE_BRANCH, CHECK_FAIL_CONCLUSIONS, DEFAULT_IGNORE_CHECKS, trackMarker, commentMarker, DUTY_MCP_TOOL_NAMES;
857
886
  var init_dutyMcp = __esm({
858
887
  "src/dutyMcp.ts"() {
859
888
  "use strict";
860
889
  init_issue();
861
890
  FAIL_CONCLUSIONS = /* @__PURE__ */ new Set(["FAILURE", "TIMED_OUT", "ACTION_REQUIRED", "STARTUP_FAILURE", "CANCELLED"]);
862
891
  RUNNING_STATUSES = /* @__PURE__ */ new Set(["IN_PROGRESS", "QUEUED", "PENDING", "WAITING", "REQUESTED"]);
892
+ TRUST_FILE_PATH = ".kody/state/trust.json";
893
+ TRUST_STATE_BRANCH = "kody-state";
863
894
  CHECK_FAIL_CONCLUSIONS = /* @__PURE__ */ new Set(["FAILURE", "TIMED_OUT", "STARTUP_FAILURE", "ACTION_REQUIRED"]);
864
895
  DEFAULT_IGNORE_CHECKS = ["run", "kody", "job-tick", "goal-tick", "worker-ask", "chat"];
865
896
  trackMarker = (key) => `<!-- kody-track:${key} -->`;
@@ -1411,7 +1442,7 @@ var init_loadCoverageRules = __esm({
1411
1442
  // package.json
1412
1443
  var package_default = {
1413
1444
  name: "@kody-ade/kody-engine",
1414
- version: "0.4.202",
1445
+ version: "0.4.203",
1415
1446
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
1416
1447
  license: "MIT",
1417
1448
  type: "module",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.202",
3
+ "version": "0.4.203",
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",
@@ -12,6 +12,25 @@
12
12
  "templates",
13
13
  "kody.config.schema.json"
14
14
  ],
15
+ "scripts": {
16
+ "kody:run": "tsx bin/kody.ts",
17
+ "serve": "tsx bin/kody.ts serve",
18
+ "serve:vscode": "tsx bin/kody.ts serve vscode",
19
+ "serve:claude": "tsx bin/kody.ts serve claude",
20
+ "build": "tsup && node scripts/copy-assets.cjs",
21
+ "check:modularity": "tsx scripts/check-script-modularity.ts",
22
+ "pretest": "pnpm check:modularity",
23
+ "test": "vitest run tests/unit tests/int --coverage",
24
+ "test:smoke": "vitest run tests/smoke --no-coverage",
25
+ "test:e2e": "vitest run tests/e2e --no-coverage",
26
+ "test:all": "vitest run tests --no-coverage",
27
+ "typecheck": "tsc --noEmit",
28
+ "lint": "biome check",
29
+ "lint:fix": "biome check --write",
30
+ "format": "biome format --write",
31
+ "brain:publish": "docker buildx build --platform linux/amd64 -f runner/Dockerfile.brain -t ghcr.io/${KODY_BRAIN_GHCR_OWNER:-aharonyaircohen}/kody-brain:latest --push runner",
32
+ "prepublishOnly": "pnpm typecheck && vitest run tests/unit tests/int --no-coverage && pnpm build"
33
+ },
15
34
  "dependencies": {
16
35
  "@actions/cache": "^6.0.0",
17
36
  "@anthropic-ai/claude-agent-sdk": "0.2.119",
@@ -34,23 +53,5 @@
34
53
  "url": "git+https://github.com/aharonyaircohen/kody-engine.git"
35
54
  },
36
55
  "homepage": "https://github.com/aharonyaircohen/kody-engine",
37
- "bugs": "https://github.com/aharonyaircohen/kody-engine/issues",
38
- "scripts": {
39
- "kody:run": "tsx bin/kody.ts",
40
- "serve": "tsx bin/kody.ts serve",
41
- "serve:vscode": "tsx bin/kody.ts serve vscode",
42
- "serve:claude": "tsx bin/kody.ts serve claude",
43
- "build": "tsup && node scripts/copy-assets.cjs",
44
- "check:modularity": "tsx scripts/check-script-modularity.ts",
45
- "pretest": "pnpm check:modularity",
46
- "test": "vitest run tests/unit tests/int --coverage",
47
- "test:smoke": "vitest run tests/smoke --no-coverage",
48
- "test:e2e": "vitest run tests/e2e --no-coverage",
49
- "test:all": "vitest run tests --no-coverage",
50
- "typecheck": "tsc --noEmit",
51
- "lint": "biome check",
52
- "lint:fix": "biome check --write",
53
- "format": "biome format --write",
54
- "brain:publish": "docker buildx build --platform linux/amd64 -f runner/Dockerfile.brain -t ghcr.io/${KODY_BRAIN_GHCR_OWNER:-aharonyaircohen}/kody-brain:latest --push runner"
55
- }
56
- }
56
+ "bugs": "https://github.com/aharonyaircohen/kody-engine/issues"
57
+ }