@kody-ade/kody-engine 0.4.408 → 0.4.409

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 +37 -18
  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.408",
18
+ version: "0.4.409",
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",
@@ -2990,6 +2990,17 @@ var init_capabilityMcp = __esm({
2990
2990
  import { spawn as spawn2, spawnSync } from "child_process";
2991
2991
  import * as fs7 from "fs";
2992
2992
  import * as path8 from "path";
2993
+ function buildCloneProcess(repo, token, baseEnv = process.env) {
2994
+ const url = `https://github.com/${repo}.git`;
2995
+ const env = { ...baseEnv };
2996
+ if (!token) return { url, env };
2997
+ const parsedCount = Number.parseInt(env.GIT_CONFIG_COUNT ?? "0", 10);
2998
+ const count = Number.isInteger(parsedCount) && parsedCount >= 0 ? parsedCount : 0;
2999
+ env.GIT_CONFIG_COUNT = String(count + 1);
3000
+ env[`GIT_CONFIG_KEY_${count}`] = "http.https://github.com/.extraHeader";
3001
+ env[`GIT_CONFIG_VALUE_${count}`] = `Authorization: Basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`;
3002
+ return { url, env };
3003
+ }
2993
3004
  async function resolveAndClone(reposRoot, repo, repoToken, cloneRepo) {
2994
3005
  const name = repo?.trim();
2995
3006
  if (!name || !REPO_RE.test(name)) return null;
@@ -3020,17 +3031,19 @@ async function fetchRepo(opts) {
3020
3031
  }
3021
3032
  return dir;
3022
3033
  }
3023
- var REPO_RE, repoClones, defaultCloneRepo;
3034
+ var REPO_RE, repoClones, GIT_CREDENTIAL_HELPER, defaultCloneRepo;
3024
3035
  var init_repoWorkspace = __esm({
3025
3036
  "src/repoWorkspace.ts"() {
3026
3037
  "use strict";
3027
3038
  REPO_RE = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
3028
3039
  repoClones = /* @__PURE__ */ new Map();
3040
+ GIT_CREDENTIAL_HELPER = `!f() { if [ "$1" = get ] && [ -n "$GITHUB_TOKEN" ]; then printf '%s\\n' username=x-access-token "password=$GITHUB_TOKEN"; fi; }; f`;
3029
3041
  defaultCloneRepo = (repo, token, dir) => {
3030
3042
  fs7.mkdirSync(path8.dirname(dir), { recursive: true });
3031
- const authUrl = token ? `https://x-access-token:${token}@github.com/${repo}.git` : `https://github.com/${repo}.git`;
3043
+ const clone = buildCloneProcess(repo, token);
3032
3044
  return new Promise((resolve16, reject) => {
3033
- const child = spawn2("git", ["clone", "--depth=1", authUrl, dir], {
3045
+ const child = spawn2("git", ["clone", "--depth=1", clone.url, dir], {
3046
+ env: clone.env,
3034
3047
  stdio: "inherit"
3035
3048
  });
3036
3049
  child.on("exit", (code) => {
@@ -3043,6 +3056,9 @@ var init_repoWorkspace = __esm({
3043
3056
  const email = process.env.GIT_AUTHOR_EMAIL ?? "kody-bot@users.noreply.github.com";
3044
3057
  spawnSync("git", ["-C", dir, "config", "user.name", name]);
3045
3058
  spawnSync("git", ["-C", dir, "config", "user.email", email]);
3059
+ if (token) {
3060
+ spawnSync("git", ["-C", dir, "config", "credential.helper", GIT_CREDENTIAL_HELPER]);
3061
+ }
3046
3062
  } catch {
3047
3063
  }
3048
3064
  resolve16();
@@ -3169,24 +3185,26 @@ function stripAgentSecrets(env) {
3169
3185
  }
3170
3186
  return out;
3171
3187
  }
3172
- async function runAgent(opts) {
3173
- const ndjsonDir = opts.ndjsonDir ?? agentRunDir(opts.cwd);
3174
- fs8.mkdirSync(ndjsonDir, { recursive: true });
3175
- const ndjsonPath = path9.join(ndjsonDir, "last-run.jsonl");
3188
+ function buildAgentEnvironment(baseEnv, repoToken) {
3176
3189
  const env = stripAgentSecrets({
3177
- ...process.env,
3190
+ ...baseEnv,
3178
3191
  SKIP_HOOKS: "1",
3179
3192
  HUSKY: "0",
3180
- CI: process.env.CI ?? "1",
3181
- // MCP servers are spawned asynchronously by the SDK. With the default
3182
- // non-blocking behavior, the SDK announces its tool list at session
3183
- // init while servers are still in `pending`, so their tools never
3184
- // reach the model. Block until each MCP completes its handshake (or
3185
- // the timeout below elapses) so the tool list is complete on first
3186
- // turn.
3187
- MCP_CONNECTION_NONBLOCKING: process.env.MCP_CONNECTION_NONBLOCKING ?? "false",
3188
- MCP_TIMEOUT: process.env.MCP_TIMEOUT ?? "60000"
3193
+ CI: baseEnv.CI ?? "1",
3194
+ MCP_CONNECTION_NONBLOCKING: baseEnv.MCP_CONNECTION_NONBLOCKING ?? "false",
3195
+ MCP_TIMEOUT: baseEnv.MCP_TIMEOUT ?? "60000"
3189
3196
  });
3197
+ if (repoToken) {
3198
+ env.GITHUB_TOKEN = repoToken;
3199
+ env.GH_TOKEN = repoToken;
3200
+ }
3201
+ return env;
3202
+ }
3203
+ async function runAgent(opts) {
3204
+ const ndjsonDir = opts.ndjsonDir ?? agentRunDir(opts.cwd);
3205
+ fs8.mkdirSync(ndjsonDir, { recursive: true });
3206
+ const ndjsonPath = path9.join(ndjsonDir, "last-run.jsonl");
3207
+ const env = buildAgentEnvironment(process.env, opts.repoToken);
3190
3208
  if (opts.litellmUrl) {
3191
3209
  env.ANTHROPIC_BASE_URL = opts.litellmUrl;
3192
3210
  env.ANTHROPIC_API_KEY = getAnthropicApiKeyOrDummy();
@@ -22371,6 +22389,7 @@ async function runChatTurn(opts) {
22371
22389
  ],
22372
22390
  systemPromptAppend: systemPrompt,
22373
22391
  ...opts.reasoningEffort ? { reasoningEffort: opts.reasoningEffort } : {},
22392
+ ...opts.repoToken ? { repoToken: opts.repoToken } : {},
22374
22393
  // Cross-repo work is opt-in. Repo Brain's default path remains focused
22375
22394
  // on the selected repo even though the server stores clones under
22376
22395
  // reposRoot.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.408",
3
+ "version": "0.4.409",
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",