@kody-ade/kody-engine 0.3.19 → 0.3.21

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 (3) hide show
  1. package/README.md +67 -42
  2. package/dist/bin/kody.js +20 -19
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,73 +6,98 @@
6
6
 
7
7
  ```
8
8
  ┌─────────────────────────────────────────────┐
9
- │ Consumer repo workflow (.github/kody.yml) │ triggers on @kody comments
9
+ │ Consumer repo workflow (.github/kody.yml) │ @kody comments · schedule · release PR merge
10
10
  └─────────────────────────────────────────────┘
11
11
 
12
12
  ┌─────────────────────────────────────────────┐
13
13
  │ kody CLI (@kody-ade/kody-engine) │
14
- │ bin/kody.ts — parses argv
14
+ │ bin/kody.ts — entrypoint
15
+ │ src/dispatch.ts — profile-driven routing │
15
16
  │ src/executor.ts — runs one profile │
16
- │ src/executables/<name>/profile.json
17
- src/scripts/*.ts named hook catalog
17
+ │ src/executables/<name>/
18
+ profile.json · prompt.md · *.sh
19
+ │ src/scripts/*.ts — cross-cutting catalog │
18
20
  └─────────────────────────────────────────────┘
19
21
  ```
20
22
 
21
- Every top-level command is its own auto-discovered executable (`run`, `fix`, `fix-ci`, `resolve`, `review`, `sync`, `plan`, `plan-verify`, `orchestrator`, `release`, `watch-*`, `init`). The router has no hardcoded command switch beyond `ci`/`help`/`version` drop a new `src/executables/<name>/` directory with a `profile.json` + `prompt.md` and `kody <name>` starts working. The executor knows nothing about any specific command.
23
+ Every top-level command is its own auto-discovered executable. The router has **zero executable names hardcoded** comment dispatch resolves the first token after `@kody` through `config.aliases`, then falls back to `config.defaultExecutable` / `config.defaultPrExecutable`. Drop a new `src/executables/<name>/` directory with a `profile.json` + `prompt.md` (+ any colocated `.sh`) and `kody <name>` starts working.
22
24
 
23
- ## Install in a consumer repo
24
-
25
- 1. Copy `templates/kody.yml` to `.github/workflows/kody.yml`.
26
- 2. Add `agent.model` to `kody.config.json` (see `kody.config.schema.json`).
27
- 3. Secrets on the repo:
28
- - At least one model key (e.g. `MINIMAX_API_KEY`, `ANTHROPIC_API_KEY`)
29
- - Optional `KODY_TOKEN` PAT if you want kody's pushes to trigger downstream CI
25
+ Executable directories contain **only** three kinds of files: `profile.json` (declaration), `prompt.md` (agent instructions), and `.sh` scripts (mechanical side-effect work). Cross-cutting TypeScript lives in [src/scripts/](src/scripts/); it can't import from `src/executables/` and can't branch on `profile.name`.
30
26
 
31
- ## Commands
27
+ ## Install in a consumer repo
32
28
 
29
+ ```bash
30
+ npx -y -p @kody-ade/kody-engine@latest kody init
33
31
  ```
34
- # issue-triggered, agent writes code
35
- kody run --issue <N> # implement an issue end-to-end (branch, code, PR)
36
32
 
37
- # issue-triggered, agent read-only (no commits)
38
- kody plan --issue <N> # produce a plan artifact for run
39
- kody research --issue <N> # map repo context, surface questions/gaps
33
+ `kody init` scaffolds [kody.config.json](kody.config.schema.json), [.github/workflows/kody.yml](templates/kody.yml), per-scheduled-executable workflow files, and (if a UI is detected) `.kody/qa-guide.md` for `ui-review`. Idempotent — pass `--force` to overwrite.
40
34
 
41
- # PR-triggered, agent writes code
42
- kody fix --pr <N> [--feedback ...] # apply PR review feedback
43
- kody fix-ci --pr <N> [--run-id <ID>] # fix failing CI
44
- kody resolve --pr <N> # merge default branch in, resolve conflicts
35
+ Required repo secrets: at least one model provider key (e.g. `MINIMAX_API_KEY`, `ANTHROPIC_API_KEY`). Recommended: `KODY_TOKEN` PAT so kody's commits trigger downstream CI and can modify `.github/workflows/*`.
45
36
 
46
- # PR-triggered, agent read-only
47
- kody review --pr <N> # structured diff review (fast, diff only)
48
- kody ui-review --pr <N> [--preview-url <URL>] # UI/UX review — browses preview via Playwright
37
+ The consumer workflow listens on three triggers: `issue_comment` (for `@kody …` dispatch), `workflow_dispatch` (manual runs, chat mode, mission wake), and `pull_request: [closed]` (auto-finalizes a merged `release/vX.Y.Z` PR).
49
38
 
50
- # no agent (deterministic)
51
- kody sync --pr <N> # merge default branch into PR branch
39
+ ## Commands
40
+
41
+ ```
42
+ # agent, writes code
43
+ kody run --issue <N> # implement an issue end-to-end
44
+ kody fix --pr <N> [--feedback ...] # apply PR review feedback
45
+ kody fix-ci --pr <N> [--run-id <ID>] # fix failing CI
46
+ kody resolve --pr <N> [--prefer ours|theirs] # merge default branch, resolve conflicts
47
+
48
+ # agent, read-only
49
+ kody plan --issue <N> # research + implementation plan
50
+ kody research --issue <N> # map repo context, surface gaps
51
+ kody review --pr <N> # structured diff review
52
+ kody ui-review --pr <N> [--preview-url <URL>] # UI review — browses preview via Playwright MCP
53
+ kody classify --issue <N> # pick a flow type (feature/bug/spec/chore)
54
+
55
+ # flow orchestrators (no agent of their own — transition tables)
56
+ kody feature --issue <N> # research → plan → run → review (→ fix)
57
+ kody bug --issue <N> # plan → run → review (→ fix)
58
+ kody spec --issue <N> # research → plan (no code, terminates at plan)
59
+ kody chore --issue <N> # run → review (→ fix)
60
+
61
+ # missions & watches (scheduled, coordinate work via issue state)
62
+ kody mission-scheduler # fans out to per-issue mission-tick
63
+ kody mission-tick --issue <N> # one tick of a kody:mission issue
64
+ kody watch-stale-prs # weekly stale-PR report
65
+
66
+ # deterministic (no agent)
67
+ kody sync --pr <N> # merge default into PR branch
52
68
  kody release --mode prepare|finalize [--bump patch|minor|major] [--dry-run]
53
- kody init [--force] # scaffold consumer repo
54
- kody orchestrate --issue <N> [--flow plan-build-review] # chain plan → run → review → fix
69
+ kody init [--force] # scaffold consumer repo
55
70
 
56
71
  # engine entrypoints
57
- kody ci --issue <N> # CI preflight + auto-dispatch from GHA event
58
- kody chat [--session <id>] # dashboard-driven chat session
72
+ kody ci # auto-dispatches from the GHA event
73
+ kody chat [--session <id>] # dashboard-driven chat session
59
74
  ```
60
75
 
76
+ ### Flow orchestrators
77
+
78
+ Each flow (`feature`, `bug`, `spec`, `chore`) is a declarative transition table: postflight entries dispatch the next executable based on `data.taskState.core.lastOutcome.type` via `runWhen`. No engine changes to add a new flow — drop a new `src/executables/<flow-name>/` with a different table. `classify` picks the flow for an unlabeled issue.
79
+
80
+ ### Missions
81
+
82
+ A **mission** is a stateful, bounded goal expressed as a labeled GitHub issue (`kody:mission`). A **watch** is a stateless repeating loop. A **manager** is a mission whose job happens to be overseeing other missions. All three run on the same scheduled-executable substrate.
83
+
84
+ `mission-scheduler` wakes on cron (default `*/5 * * * *`) or empty `workflow_dispatch`, finds every open `kody:mission` issue, and calls `mission-tick` once per issue. The tick agent reads the issue body (human-owned prose) and a dedicated state comment (bot-owned JSON), decides the next step, and emits a fenced `kody-mission-next-state` block the postflight persists. Children are spawned via `gh workflow run kody.yml` (not `@kody` comments — the default `GITHUB_TOKEN` can dispatch workflows but can't post auto-triggering comments).
85
+
61
86
  ### `ui-review`
62
87
 
63
- `ui-review` adds UI/UX verification to the review surface. It runs the usual diff-based review AND drives the running preview deployment via the Playwright CLI writing a throwaway spec under `.kody/ui-review/`, running it, capturing screenshots, and folding the observed behavior into the review verdict.
88
+ Drives the running preview deployment via the Playwright MCP server alongside the usual diff review.
89
+
90
+ - Preview URL: `--preview-url` → `$PREVIEW_URL` → `http://localhost:3000`. Unreachable → falls back to diff-only.
91
+ - Credentials: `.kody/qa-guide.md` (committed, scaffolded by `kody init` with `CHANGE_ME` placeholders).
92
+ - Auto-discovery: routes, roles, login/admin paths, Payload CMS collections, API routes, env vars — fed to the agent as context.
64
93
 
65
- - Preview URL resolution: `--preview-url` flag → `$PREVIEW_URL` → `http://localhost:3000`.
66
- - Credentials: committed in `.kody/qa-guide.md` (scaffolded by `kody init` when a UI is detected, with `CHANGE_ME` placeholders). The agent reads the guide and uses any credentials it finds.
67
- - Auto-discovery: routes, roles, login page, admin path, Payload CMS collections, API routes, env vars — fed to the agent so it knows *what* to browse without you spelling it out.
68
- - Falls back to a diff-only review when the preview URL is unreachable.
94
+ ### `release`
69
95
 
70
- `kody chat` reads `.kody/sessions/<id>.jsonl`, runs one agent turn, appends
71
- the reply, and writes `chat.message` + `chat.done` events to
72
- `.kody/events/<id>.jsonl` (plus optional HTTP push to a dashboard ingest URL).
73
- Inputs can come from flags or env (`SESSION_ID`, `INIT_MESSAGE`, `MODEL`,
74
- `DASHBOARD_URL`) — the yaml template passes the latter.
96
+ - `--mode prepare` — bumps `package.json`, updates `CHANGELOG.md`, opens a `release/vX.Y.Z` PR. `--bump patch|minor|major` (default `patch`).
97
+ - `--mode finalize` — tags, pushes, runs `prepublishOnly` + `npm publish`, creates a GH release. Runs **automatically** when a `release/vX.Y.Z` PR is merged (via `pull_request: [closed]` in the consumer workflow); manual trigger still works.
75
98
 
76
99
  ## Profiles
77
100
 
78
- A profile is declarative JSON + an adjacent `prompt.md`. See any directory under `src/executables/` for examples. Adding a new command = new directory + profile + prompt + registering any new scripts under `src/scripts/`. No executor, entry, or dispatch changes.
101
+ A profile is declarative JSON + an adjacent `prompt.md`. See any directory under [src/executables/](src/executables/) for examples. Adding a new command = new directory + profile + prompt + any `.sh` scripts + registering any new shared TS utilities under [src/scripts/](src/scripts/). No executor, entry, or dispatch changes.
102
+
103
+ See [AGENTS.md](AGENTS.md) for the full architectural contract.
package/dist/bin/kody.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@kody-ade/kody-engine",
6
- version: "0.3.19",
6
+ version: "0.3.21",
7
7
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
8
8
  license: "MIT",
9
9
  type: "module",
@@ -2671,6 +2671,12 @@ function truncate2(s, maxBytes) {
2671
2671
  if (s.length <= maxBytes) return s;
2672
2672
  return `${s.slice(0, maxBytes)}\u2026 (+${s.length - maxBytes} chars)`;
2673
2673
  }
2674
+ function parsePrNumber(url) {
2675
+ const m = url.match(/\/pull\/(\d+)(?:[/?#]|$)/);
2676
+ if (!m) return null;
2677
+ const n = parseInt(m[1], 10);
2678
+ return Number.isFinite(n) ? n : null;
2679
+ }
2674
2680
  function getPr(prNumber, cwd) {
2675
2681
  const output = gh2(["pr", "view", String(prNumber), "--json", "number,title,body,headRefName,baseRefName,state"], {
2676
2682
  cwd
@@ -3138,15 +3144,16 @@ var finishFlow = async (ctx, _profile, _agentResult, args) => {
3138
3144
  if (!issueNumber) return;
3139
3145
  const label = typeof args?.label === "string" ? args.label : void 0;
3140
3146
  if (label && label.startsWith(KODY_NAMESPACE)) {
3141
- setKodyLabel(
3142
- issueNumber,
3143
- {
3144
- label,
3145
- color: typeof args?.color === "string" ? args.color : void 0,
3146
- description: typeof args?.description === "string" ? args.description : void 0
3147
- },
3148
- ctx.cwd
3149
- );
3147
+ const spec = {
3148
+ label,
3149
+ color: typeof args?.color === "string" ? args.color : void 0,
3150
+ description: typeof args?.description === "string" ? args.description : void 0
3151
+ };
3152
+ setKodyLabel(issueNumber, spec, ctx.cwd);
3153
+ const prNumber = state?.core.prUrl ? parsePrNumber(state.core.prUrl) : null;
3154
+ if (prNumber && prNumber !== issueNumber) {
3155
+ setKodyLabel(prNumber, spec, ctx.cwd);
3156
+ }
3150
3157
  }
3151
3158
  const icon = STATUS_ICON[reason] ?? "\u2139\uFE0F";
3152
3159
  const prSuffix = state?.core.prUrl ? `
@@ -4044,7 +4051,7 @@ var mirrorStateToPr = async (ctx) => {
4044
4051
  if (!issueNumber || issueTarget !== "issue") return;
4045
4052
  const prUrl = ctx.output.prUrl ?? ctx.data.prResult?.url;
4046
4053
  if (!prUrl) return;
4047
- const prNumber = parsePrNumber(prUrl);
4054
+ const prNumber = parsePrNumber2(prUrl);
4048
4055
  if (!prNumber) return;
4049
4056
  let state;
4050
4057
  try {
@@ -4062,7 +4069,7 @@ var mirrorStateToPr = async (ctx) => {
4062
4069
  );
4063
4070
  }
4064
4071
  };
4065
- function parsePrNumber(prUrl) {
4072
+ function parsePrNumber2(prUrl) {
4066
4073
  const m = prUrl.match(/\/pull\/(\d+)(?:[/?#]|$)/);
4067
4074
  if (!m) return null;
4068
4075
  const n = parseInt(m[1], 10);
@@ -5210,7 +5217,7 @@ var startFlow = async (ctx, profile, _agentResult, args) => {
5210
5217
  postKodyComment(target, issueNumber, state, entry, ctx.cwd);
5211
5218
  };
5212
5219
  function postKodyComment(target, issueNumber, state, next, cwd) {
5213
- const targetNumber = target === "pr" && state?.core.prUrl ? parsePr2(state.core.prUrl) ?? issueNumber : issueNumber;
5220
+ const targetNumber = target === "pr" && state?.core.prUrl ? parsePrNumber(state.core.prUrl) ?? issueNumber : issueNumber;
5214
5221
  const sub = target === "pr" && state?.core.prUrl ? "pr" : "issue";
5215
5222
  const body = `@kody ${next}`;
5216
5223
  try {
@@ -5226,12 +5233,6 @@ function postKodyComment(target, issueNumber, state, next, cwd) {
5226
5233
  );
5227
5234
  }
5228
5235
  }
5229
- function parsePr2(url) {
5230
- const m = url.match(/\/pull\/(\d+)(?:[/?#]|$)/);
5231
- if (!m) return null;
5232
- const n = parseInt(m[1], 10);
5233
- return Number.isFinite(n) ? n : null;
5234
- }
5235
5236
 
5236
5237
  // src/scripts/syncFlow.ts
5237
5238
  import { execFileSync as execFileSync19 } from "child_process";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.3.19",
3
+ "version": "0.3.21",
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",