@kody-ade/kody-engine 0.4.69 → 0.4.71

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
@@ -864,7 +864,7 @@ var init_loadPriorArt = __esm({
864
864
  // package.json
865
865
  var package_default = {
866
866
  name: "@kody-ade/kody-engine",
867
- version: "0.4.69",
867
+ version: "0.4.71",
868
868
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
869
869
  license: "MIT",
870
870
  type: "module",
@@ -878,6 +878,9 @@ var package_default = {
878
878
  ],
879
879
  scripts: {
880
880
  kody: "tsx bin/kody.ts",
881
+ serve: "tsx bin/kody.ts serve",
882
+ "serve:vscode": "tsx bin/kody.ts serve vscode",
883
+ "serve:claude": "tsx bin/kody.ts serve claude",
881
884
  build: "tsup && node scripts/copy-assets.cjs",
882
885
  "check:modularity": "tsx scripts/check-script-modularity.ts",
883
886
  pretest: "pnpm check:modularity",
@@ -2395,7 +2398,7 @@ function coerceBare(spec, value) {
2395
2398
  init_issue();
2396
2399
 
2397
2400
  // src/executor.ts
2398
- import { execFileSync as execFileSync29, spawn as spawn5 } from "child_process";
2401
+ import { execFileSync as execFileSync29, spawn as spawn6 } from "child_process";
2399
2402
  import * as fs31 from "fs";
2400
2403
  import * as path29 from "path";
2401
2404
  init_events();
@@ -3835,6 +3838,11 @@ var commitAndPush2 = async (ctx, profile) => {
3835
3838
  } catch {
3836
3839
  }
3837
3840
  }
3841
+ if (ctx.data.verifyOk === false) {
3842
+ ctx.data.commitResult = { committed: false, pushed: false, skippedReason: "verifyFailed" };
3843
+ ctx.data.hasCommitsAhead = hasCommitsAhead(branch, ctx.config.git.defaultBranch, ctx.cwd);
3844
+ return;
3845
+ }
3838
3846
  const markerMissing = ctx.data.agentMarkerMissing === true;
3839
3847
  if (ctx.data.agentDone === false && !markerMissing) {
3840
3848
  ctx.data.commitResult = { committed: false, pushed: false, skippedReason: "agentDone=false" };
@@ -8951,6 +8959,108 @@ function buildChildEnv(parent, force) {
8951
8959
  return out;
8952
8960
  }
8953
8961
 
8962
+ // src/scripts/serveFlow.ts
8963
+ import { spawn as spawn3 } from "child_process";
8964
+ function parseTarget(positional) {
8965
+ if (!Array.isArray(positional) || positional.length === 0) return "none";
8966
+ const first = String(positional[0]).toLowerCase();
8967
+ if (first === "vscode" || first === "code") return "vscode";
8968
+ if (first === "claude") return "claude";
8969
+ throw new Error(`unknown serve subcommand: "${positional[0]}" (expected: vscode, claude, or omit)`);
8970
+ }
8971
+ function buildProxyEnv(url) {
8972
+ return {
8973
+ ...process.env,
8974
+ ANTHROPIC_BASE_URL: url,
8975
+ ANTHROPIC_API_KEY: getAnthropicApiKeyOrDummy()
8976
+ };
8977
+ }
8978
+ var serveFlow = async (ctx) => {
8979
+ ctx.skipAgent = true;
8980
+ const target = parseTarget(ctx.args._);
8981
+ const model = parseProviderModel(ctx.config.agent.model);
8982
+ const usesProxy = needsLitellmProxy(model);
8983
+ let handle = null;
8984
+ if (usesProxy) {
8985
+ process.stdout.write(`[kody serve] starting LiteLLM proxy for ${model.provider}/${model.model}...
8986
+ `);
8987
+ handle = await startLitellmIfNeeded(model, ctx.cwd);
8988
+ process.stdout.write(`[kody serve] LiteLLM ready at ${handle?.url ?? LITELLM_DEFAULT_URL}
8989
+ `);
8990
+ } else {
8991
+ process.stdout.write(`[kody serve] model ${model.provider}/${model.model} routes to Anthropic directly \u2014 no proxy needed
8992
+ `);
8993
+ }
8994
+ const url = handle?.url ?? LITELLM_DEFAULT_URL;
8995
+ const editorEnv = usesProxy ? buildProxyEnv(url) : { ...process.env };
8996
+ const killProxy = () => {
8997
+ if (handle) {
8998
+ process.stdout.write(`[kody serve] stopping LiteLLM proxy...
8999
+ `);
9000
+ try {
9001
+ handle.kill();
9002
+ } catch {
9003
+ }
9004
+ }
9005
+ };
9006
+ if (target === "claude") {
9007
+ process.stdout.write(`[kody serve] launching Claude Code at ${ctx.cwd}
9008
+ `);
9009
+ if (usesProxy) process.stdout.write(` ANTHROPIC_BASE_URL=${url}
9010
+ `);
9011
+ const args = ["--dangerously-skip-permissions", "--model", model.model];
9012
+ const child = spawn3("claude", args, { stdio: "inherit", env: editorEnv, cwd: ctx.cwd });
9013
+ const exitCode = await new Promise((resolve4) => {
9014
+ child.on("exit", (code) => resolve4(code ?? 0));
9015
+ child.on("error", (err) => {
9016
+ process.stderr.write(`[kody serve] failed to launch Claude Code: ${err.message}
9017
+ `);
9018
+ process.stderr.write(` Install: https://docs.anthropic.com/claude/docs/claude-code
9019
+ `);
9020
+ resolve4(1);
9021
+ });
9022
+ });
9023
+ killProxy();
9024
+ ctx.output.exitCode = exitCode;
9025
+ return;
9026
+ }
9027
+ if (target === "vscode") {
9028
+ process.stdout.write(`[kody serve] launching VS Code at ${ctx.cwd}
9029
+ `);
9030
+ if (usesProxy) process.stdout.write(` ANTHROPIC_BASE_URL=${url}
9031
+ `);
9032
+ try {
9033
+ const code = spawn3("code", [ctx.cwd], { stdio: "inherit", env: editorEnv, detached: true });
9034
+ code.on("error", (err) => {
9035
+ process.stderr.write(`[kody serve] failed to launch VS Code: ${err.message}
9036
+ `);
9037
+ process.stderr.write(` Install the 'code' CLI: VS Code \u2192 Command Palette \u2192 "Shell Command: Install 'code' command in PATH"
9038
+ `);
9039
+ });
9040
+ code.unref();
9041
+ } catch (err) {
9042
+ const msg = err instanceof Error ? err.message : String(err);
9043
+ process.stderr.write(`[kody serve] failed to spawn VS Code: ${msg}
9044
+ `);
9045
+ }
9046
+ }
9047
+ process.stdout.write(`[kody serve] running. Press Ctrl+C to stop.
9048
+ `);
9049
+ const keepAlive = setInterval(() => {
9050
+ }, 6e4);
9051
+ const shutdown = (signal, exitCode) => {
9052
+ clearInterval(keepAlive);
9053
+ process.stdout.write(`[kody serve] received ${signal}
9054
+ `);
9055
+ killProxy();
9056
+ process.exit(exitCode);
9057
+ };
9058
+ process.on("SIGINT", () => shutdown("SIGINT", 130));
9059
+ process.on("SIGTERM", () => shutdown("SIGTERM", 143));
9060
+ await new Promise(() => {
9061
+ });
9062
+ };
9063
+
8954
9064
  // src/scripts/saveGoalState.ts
8955
9065
  var saveGoalState = async (ctx) => {
8956
9066
  const goal = ctx.data.goal;
@@ -9235,7 +9345,7 @@ var verify = async (ctx) => {
9235
9345
  };
9236
9346
 
9237
9347
  // src/scripts/verifyReproFails.ts
9238
- import { spawn as spawn3 } from "child_process";
9348
+ import { spawn as spawn4 } from "child_process";
9239
9349
  var TEST_TIMEOUT_MS = 10 * 60 * 1e3;
9240
9350
  var TAIL_CHARS2 = 8e3;
9241
9351
  var ANSI_RE2 = /\x1B\[[0-?]*[ -/]*[@-~]/g;
@@ -9304,7 +9414,7 @@ function stripAnsi2(s) {
9304
9414
  }
9305
9415
  function runCommand2(command, cwd) {
9306
9416
  return new Promise((resolve4) => {
9307
- const child = spawn3(command, {
9417
+ const child = spawn4(command, {
9308
9418
  cwd,
9309
9419
  shell: true,
9310
9420
  env: { ...process.env, HUSKY: "0", SKIP_HOOKS: "1", CI: process.env.CI ?? "1" },
@@ -9477,7 +9587,7 @@ function sleep2(ms) {
9477
9587
  }
9478
9588
 
9479
9589
  // src/scripts/warmupMcp.ts
9480
- import { spawn as spawn4 } from "child_process";
9590
+ import { spawn as spawn5 } from "child_process";
9481
9591
  var PER_SERVER_TIMEOUT_MS = 6e4;
9482
9592
  var PER_REQUEST_TIMEOUT_MS = 2e4;
9483
9593
  var warmupMcp = async (_ctx, profile) => {
@@ -9499,7 +9609,7 @@ var warmupMcp = async (_ctx, profile) => {
9499
9609
  }
9500
9610
  };
9501
9611
  async function warmupOne(command, args, env) {
9502
- const child = spawn4(command, args, {
9612
+ const child = spawn5(command, args, {
9503
9613
  stdio: ["pipe", "pipe", "pipe"],
9504
9614
  env: env ? { ...process.env, ...env } : process.env
9505
9615
  });
@@ -9751,6 +9861,7 @@ var preflightScripts = {
9751
9861
  dispatchJobTicks,
9752
9862
  dispatchJobFileTicks,
9753
9863
  runTickScript,
9864
+ serveFlow,
9754
9865
  loadGoalState,
9755
9866
  handleAbandonedGoal,
9756
9867
  deriveGoalPhase,
@@ -10167,6 +10278,9 @@ function validateInputs(specs, raw) {
10167
10278
  throw new Error(`unknown arg: --${key}`);
10168
10279
  }
10169
10280
  }
10281
+ if (Array.isArray(raw._)) {
10282
+ out._ = raw._;
10283
+ }
10170
10284
  for (const spec of specs) {
10171
10285
  const v = raw[spec.name];
10172
10286
  if (v === void 0 || v === null) continue;
@@ -10261,7 +10375,7 @@ async function runShellEntry(entry, ctx, profile) {
10261
10375
  env[`KODY_CFG_${k}`] = v;
10262
10376
  }
10263
10377
  const timeoutMs = resolveShellTimeoutMs(entry);
10264
- const child = spawn5("bash", [shellPath, ...positional], {
10378
+ const child = spawn6("bash", [shellPath, ...positional], {
10265
10379
  cwd: ctx.cwd,
10266
10380
  env,
10267
10381
  stdio: ["pipe", "pipe", "pipe"],
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "serve",
3
+ "role": "utility",
4
+ "describe": "Start a LiteLLM proxy and optionally launch an editor pointed at it. Usage: `kody serve` (proxy only), `kody serve vscode`, `kody serve claude`. Long-lived — Ctrl+C to stop.",
5
+ "inputs": [],
6
+ "claudeCode": {
7
+ "model": "inherit",
8
+ "permissionMode": "acceptEdits",
9
+ "maxTurns": null,
10
+ "systemPromptAppend": null,
11
+ "tools": [],
12
+ "hooks": [],
13
+ "skills": [],
14
+ "commands": [],
15
+ "subagents": [],
16
+ "plugins": [],
17
+ "mcpServers": []
18
+ },
19
+ "cliTools": [],
20
+ "scripts": {
21
+ "preflight": [
22
+ {
23
+ "script": "serveFlow"
24
+ }
25
+ ],
26
+ "postflight": []
27
+ }
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.69",
3
+ "version": "0.4.71",
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,20 +12,6 @@
12
12
  "templates",
13
13
  "kody.config.schema.json"
14
14
  ],
15
- "scripts": {
16
- "kody": "tsx bin/kody.ts",
17
- "build": "tsup && node scripts/copy-assets.cjs",
18
- "check:modularity": "tsx scripts/check-script-modularity.ts",
19
- "pretest": "pnpm check:modularity",
20
- "test": "vitest run tests/unit tests/int --no-coverage",
21
- "test:e2e": "vitest run tests/e2e --no-coverage",
22
- "test:all": "vitest run tests --no-coverage",
23
- "typecheck": "tsc --noEmit",
24
- "lint": "biome check",
25
- "lint:fix": "biome check --write",
26
- "format": "biome format --write",
27
- "prepublishOnly": "pnpm build"
28
- },
29
15
  "dependencies": {
30
16
  "@actions/cache": "^6.0.0",
31
17
  "@anthropic-ai/claude-agent-sdk": "0.2.119",
@@ -47,5 +33,21 @@
47
33
  "url": "git+https://github.com/aharonyaircohen/kody-engine.git"
48
34
  },
49
35
  "homepage": "https://github.com/aharonyaircohen/kody-engine",
50
- "bugs": "https://github.com/aharonyaircohen/kody-engine/issues"
51
- }
36
+ "bugs": "https://github.com/aharonyaircohen/kody-engine/issues",
37
+ "scripts": {
38
+ "kody": "tsx bin/kody.ts",
39
+ "serve": "tsx bin/kody.ts serve",
40
+ "serve:vscode": "tsx bin/kody.ts serve vscode",
41
+ "serve:claude": "tsx bin/kody.ts serve claude",
42
+ "build": "tsup && node scripts/copy-assets.cjs",
43
+ "check:modularity": "tsx scripts/check-script-modularity.ts",
44
+ "pretest": "pnpm check:modularity",
45
+ "test": "vitest run tests/unit tests/int --no-coverage",
46
+ "test:e2e": "vitest run tests/e2e --no-coverage",
47
+ "test:all": "vitest run tests --no-coverage",
48
+ "typecheck": "tsc --noEmit",
49
+ "lint": "biome check",
50
+ "lint:fix": "biome check --write",
51
+ "format": "biome format --write"
52
+ }
53
+ }