@kody-ade/kody-engine 0.4.529 → 0.4.531

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 +66 -10
  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.529",
18
+ version: "0.4.531",
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",
@@ -7509,8 +7509,19 @@ var init_litellm = __esm({
7509
7509
  async function upsertRunIndexRowBestEffortAsync(config, _cwd, row) {
7510
7510
  if (!row) return;
7511
7511
  const tenantId2 = tenantIdForRun(config);
7512
- if (!tenantId2) throw new Error("Repository identity is required for the run index");
7513
- await createStateBackendFromEnv().saveAgencyRun(tenantId2, row.id, row.subjectType, row.subjectId, row, row.updatedAt);
7512
+ if (!tenantId2) return;
7513
+ try {
7514
+ await createStateBackendFromEnv().saveAgencyRun(
7515
+ tenantId2,
7516
+ row.id,
7517
+ row.subjectType,
7518
+ row.subjectId,
7519
+ row,
7520
+ row.updatedAt
7521
+ );
7522
+ } catch {
7523
+ process.stderr.write("\u2192 kody: run index persistence unavailable; continuing\n");
7524
+ }
7514
7525
  }
7515
7526
  function stageRunIndexFinalization(data, row) {
7516
7527
  if (!row) return;
@@ -23020,7 +23031,9 @@ function capabilityStepInput(input, target, targetNumber) {
23020
23031
  if (!target || targetNumber === void 0) return input;
23021
23032
  const routing = { [target]: targetNumber };
23022
23033
  if (input && typeof input === "object" && !Array.isArray(input)) {
23023
- return { ...input, ...routing };
23034
+ const context = { ...input };
23035
+ delete context[target === "pr" ? "issue" : "pr"];
23036
+ return { ...context, ...routing };
23024
23037
  }
23025
23038
  return input === void 0 ? routing : { request: input, ...routing };
23026
23039
  }
@@ -23871,6 +23884,28 @@ var CHAT_SYSTEM_PROMPT = [
23871
23884
  "Do not invent file paths, commit SHAs, line numbers, or command output. If you",
23872
23885
  "cite something concrete, you must have just read or run it in this session."
23873
23886
  ].join("\n");
23887
+ var HOST_CHAT_SYSTEM_PROMPT = [
23888
+ "You are Kody, a general-purpose assistant running on the machine hosting Brain.",
23889
+ "Reply to the user's latest message using the full conversation as context.",
23890
+ "Keep replies short and simple, and use plain terms rather than jargon.",
23891
+ "",
23892
+ "# Your environment and capabilities",
23893
+ "You can work across the host environment available to this process. You are not",
23894
+ "limited to a repository or an opened project. Start from the current working",
23895
+ "directory, and use `pwd`, `uname`, and other real commands before describing",
23896
+ "the machine. Read, Edit, Write, Glob, Grep, and Bash can inspect and change",
23897
+ "files or run programs with the same permissions as the Brain host user.",
23898
+ "",
23899
+ "Do not assume a repository exists. When a task concerns a project, first locate",
23900
+ "the relevant directory from the user's words and the machine's actual filesystem.",
23901
+ "Never print secrets or credential values. Be careful with destructive operations",
23902
+ "and explain their effect before running them.",
23903
+ "",
23904
+ "# Ground answers in the machine",
23905
+ "Use the real filesystem, process state, and command output before making claims",
23906
+ "about this host. If the request is ambiguous and choosing a target could modify",
23907
+ "the wrong data, ask a direct clarification before acting."
23908
+ ].join("\n");
23874
23909
  var OPENAI_CHAT_SYSTEM_PROMPT = [
23875
23910
  "You are Kody, an AI assistant for the Kody Operations Dashboard. Reply to the",
23876
23911
  "user's latest message using the full conversation below as context. Keep replies",
@@ -23931,8 +23966,14 @@ function buildImplementationCatalog() {
23931
23966
  function shouldWriteTaskArtifacts(driver) {
23932
23967
  return driver !== "codex-app-server";
23933
23968
  }
23969
+ function resolveChatSystemPrompt(input) {
23970
+ return input.systemPrompt ?? readSystemPromptOverride(input.cwd) ?? (input.workspaceKind === "host" ? HOST_CHAT_SYSTEM_PROMPT : input.protocol === "openai" ? OPENAI_CHAT_SYSTEM_PROMPT : CHAT_SYSTEM_PROMPT);
23971
+ }
23934
23972
  async function runChatTurn(opts) {
23935
- const store = opts.store ?? createSessionStore({ sessionId: opts.sessionId, sessionFile: opts.sessionFile });
23973
+ const store = opts.store ?? createSessionStore({
23974
+ sessionId: opts.sessionId,
23975
+ sessionFile: opts.sessionFile
23976
+ });
23936
23977
  const turns = await store.readTurns();
23937
23978
  if (turns.length === 0) {
23938
23979
  const error = "session file is empty \u2014 nothing to reply to";
@@ -23946,7 +23987,12 @@ async function runChatTurn(opts) {
23946
23987
  return { exitCode: 64, error };
23947
23988
  }
23948
23989
  const { turns: promptTurns, imagePaths } = prepareAttachments(turns, opts.cwd, opts.sessionId);
23949
- const basePrompt = opts.systemPrompt ?? readSystemPromptOverride(opts.cwd) ?? (opts.model.protocol === "openai" ? OPENAI_CHAT_SYSTEM_PROMPT : CHAT_SYSTEM_PROMPT);
23990
+ const basePrompt = resolveChatSystemPrompt({
23991
+ cwd: opts.cwd,
23992
+ protocol: opts.model.protocol,
23993
+ workspaceKind: opts.workspaceKind,
23994
+ systemPrompt: opts.systemPrompt
23995
+ });
23950
23996
  const activeAgent = await store.readActiveAgent();
23951
23997
  const agentIdentityBlock = readAgentIdentityBlock(opts.cwd, opts.agentIdentity ?? { slug: activeAgent.slug });
23952
23998
  const catalog = buildImplementationCatalog();
@@ -23954,7 +24000,10 @@ async function runChatTurn(opts) {
23954
24000
  ...prepareTaskArtifactsDir(opts.cwd, opts.sessionId),
23955
24001
  taskKey: `sessions/${opts.sessionId}`
23956
24002
  };
23957
- initializeTaskArtifacts(taskArtifactsPaths, { taskType: "chat", target: opts.sessionId });
24003
+ initializeTaskArtifacts(taskArtifactsPaths, {
24004
+ taskType: "chat",
24005
+ target: opts.sessionId
24006
+ });
23958
24007
  const artifactAddendum = shouldWriteTaskArtifacts(opts.driver) ? taskArtifactsPromptAddendum({
23959
24008
  taskId: taskArtifactsPaths.taskId,
23960
24009
  taskType: "chat",
@@ -24089,7 +24138,9 @@ async function runChatTurn(opts) {
24089
24138
  content: reply,
24090
24139
  timestamp: now
24091
24140
  });
24092
- await emit(opts.sink, "chat.done", opts.sessionId, "done", { sessionId: opts.sessionId });
24141
+ await emit(opts.sink, "chat.done", opts.sessionId, "done", {
24142
+ sessionId: opts.sessionId
24143
+ });
24093
24144
  try {
24094
24145
  const missing = verifyTaskArtifacts(taskArtifactsPaths.absDir);
24095
24146
  if (missing.length > 0) {
@@ -24158,7 +24209,9 @@ async function runOpenAIChatTurn(args) {
24158
24209
  content: reply,
24159
24210
  timestamp: now
24160
24211
  });
24161
- await emit(opts.sink, "chat.done", opts.sessionId, "done", { sessionId: opts.sessionId });
24212
+ await emit(opts.sink, "chat.done", opts.sessionId, "done", {
24213
+ sessionId: opts.sessionId
24214
+ });
24162
24215
  return { exitCode: 0, reply };
24163
24216
  } catch (err) {
24164
24217
  const error = err instanceof Error ? err.message : String(err);
@@ -26294,7 +26347,9 @@ async function handleChatTurn(req, res, chatId, opts) {
26294
26347
  try {
26295
26348
  turnDriver = resolveBrainDriver(runtime);
26296
26349
  } catch (err) {
26297
- sendJson(res, 400, { error: err instanceof Error ? err.message : String(err) });
26350
+ sendJson(res, 400, {
26351
+ error: err instanceof Error ? err.message : String(err)
26352
+ });
26298
26353
  return;
26299
26354
  }
26300
26355
  }
@@ -26357,6 +26412,7 @@ async function handleChatTurn(req, res, chatId, opts) {
26357
26412
  sessionId: chatId,
26358
26413
  sessionFile,
26359
26414
  cwd: agentCwd,
26415
+ workspaceKind: repo ? "repository" : "host",
26360
26416
  model: opts.model,
26361
26417
  litellmUrl: opts.litellmUrl,
26362
26418
  sink,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.529",
3
+ "version": "0.4.531",
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",