@kody-ade/kody-engine 0.4.384 → 0.4.386

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 +65 -2
  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.384",
18
+ version: "0.4.386",
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",
@@ -3869,6 +3869,29 @@ function createStateBackendFromEnv(env = process.env, client) {
3869
3869
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
3870
3870
  ...expectedUpdatedAt ? { expectedUpdatedAt } : {}
3871
3871
  });
3872
+ },
3873
+ async getRepoDoc(tenantId, kind) {
3874
+ const result = await transport.query(anyApi.repoDocs.get, {
3875
+ tenantId: requireTenant(tenantId),
3876
+ kind: requireNonEmpty(kind, "kind")
3877
+ });
3878
+ return result ?? null;
3879
+ },
3880
+ async listRepoDocs(tenantId, prefix) {
3881
+ const result = await transport.query(anyApi.repoDocs.listByPrefix, {
3882
+ tenantId: requireTenant(tenantId),
3883
+ prefix: requireNonEmpty(prefix, "prefix")
3884
+ });
3885
+ return Array.isArray(result) ? result : [];
3886
+ },
3887
+ async saveRepoDoc(tenantId, kind, doc, expectedUpdatedAt) {
3888
+ await transport.mutation(anyApi.repoDocs.save, {
3889
+ tenantId: requireTenant(tenantId),
3890
+ kind: requireNonEmpty(kind, "kind"),
3891
+ doc,
3892
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
3893
+ ...expectedUpdatedAt ? { expectedUpdatedAt } : {}
3894
+ });
3872
3895
  }
3873
3896
  };
3874
3897
  }
@@ -3908,6 +3931,9 @@ function taskArtifactStatePath(taskId, file) {
3908
3931
  }
3909
3932
  async function persistTaskArtifactsToState(config, cwd, artifacts) {
3910
3933
  const tenantId = config.github?.owner && config.github.repo ? `${config.github.owner}/${config.github.repo}` : process.env.GITHUB_REPOSITORY?.trim();
3934
+ if (process.env.GITHUB_ACTIONS === "true" && (!process.env.CONVEX_URL || !process.env.KODY_SERVICE_KEY || !tenantId)) {
3935
+ throw new Error("Convex artifact backend is required in GitHub Actions (CONVEX_URL, KODY_SERVICE_KEY, and repository identity)");
3936
+ }
3911
3937
  if (process.env.CONVEX_URL && process.env.KODY_SERVICE_KEY && tenantId) {
3912
3938
  const backend = createStateBackendFromEnv();
3913
3939
  for (const file of TASK_ARTIFACT_FILES) {
@@ -5639,7 +5665,11 @@ function readTaskStateLegacy(target, number, cwd, config) {
5639
5665
  }
5640
5666
  function backendScope(config) {
5641
5667
  const tenantId = config?.github?.owner && config.github.repo ? `${config.github.owner}/${config.github.repo}` : process.env.GITHUB_REPOSITORY?.trim();
5642
- if (!process.env.CONVEX_URL || !process.env.KODY_SERVICE_KEY || !tenantId) return null;
5668
+ const configured = !!process.env.CONVEX_URL && !!process.env.KODY_SERVICE_KEY && !!tenantId;
5669
+ if (!configured && process.env.GITHUB_ACTIONS === "true") {
5670
+ throw new Error("Convex task-state backend is required in GitHub Actions (CONVEX_URL, KODY_SERVICE_KEY, and repository identity)");
5671
+ }
5672
+ if (!configured) return null;
5643
5673
  return { tenantId };
5644
5674
  }
5645
5675
  async function readTaskState(target, number, cwd, config) {
@@ -5952,6 +5982,21 @@ __export(loadMemoryContext_exports, {
5952
5982
  });
5953
5983
  import * as fs21 from "fs";
5954
5984
  import * as path21 from "path";
5985
+ function formatBlockFromBackend(docs) {
5986
+ const pages = docs.flatMap((record) => {
5987
+ if (!record.doc || typeof record.doc !== "object") return [];
5988
+ const doc = record.doc;
5989
+ if (typeof doc.content !== "string") return [];
5990
+ return [{
5991
+ relPath: typeof doc.relPath === "string" ? doc.relPath : record.kind,
5992
+ title: typeof doc.title === "string" ? doc.title : record.kind,
5993
+ updated: typeof doc.updated === "string" ? doc.updated : record.updatedAt,
5994
+ content: doc.content.length > PER_PAGE_MAX_BYTES ? doc.content.slice(0, PER_PAGE_MAX_BYTES) + TRUNCATED_SUFFIX2 : doc.content,
5995
+ mtime: Date.parse(record.updatedAt) || 0
5996
+ }];
5997
+ });
5998
+ return formatBlock(sortByRecency(pages).slice(0, MAX_PAGES));
5999
+ }
5955
6000
  function collectPages(memoryAbs) {
5956
6001
  const out = [];
5957
6002
  walkMd(memoryAbs, (file) => {
@@ -6064,6 +6109,7 @@ var MEMORY_DIR_RELATIVE, MAX_PAGES, PER_PAGE_MAX_BYTES, TOTAL_MAX_BYTES2, TRUNCA
6064
6109
  var init_loadMemoryContext = __esm({
6065
6110
  "src/scripts/loadMemoryContext.ts"() {
6066
6111
  "use strict";
6112
+ init_state_backend();
6067
6113
  MEMORY_DIR_RELATIVE = ".kody/memory";
6068
6114
  MAX_PAGES = 8;
6069
6115
  PER_PAGE_MAX_BYTES = 4e3;
@@ -6071,6 +6117,17 @@ var init_loadMemoryContext = __esm({
6071
6117
  TRUNCATED_SUFFIX2 = "\n\n\u2026 (truncated)";
6072
6118
  loadMemoryContext = async (ctx) => {
6073
6119
  if (typeof ctx.data.memoryContext === "string") return;
6120
+ const tenantId = ctx.config.github?.owner && ctx.config.github.repo ? `${ctx.config.github.owner}/${ctx.config.github.repo}` : process.env.GITHUB_REPOSITORY?.trim();
6121
+ if (process.env.CONVEX_URL && process.env.KODY_SERVICE_KEY && tenantId) {
6122
+ try {
6123
+ const backend = createStateBackendFromEnv();
6124
+ const docs = await backend.listRepoDocs(tenantId, "memory:");
6125
+ ctx.data.memoryContext = formatBlockFromBackend(docs);
6126
+ } catch {
6127
+ ctx.data.memoryContext = "";
6128
+ }
6129
+ return;
6130
+ }
6074
6131
  const memoryAbs = path21.join(ctx.cwd, MEMORY_DIR_RELATIVE);
6075
6132
  if (!fs21.existsSync(memoryAbs)) {
6076
6133
  ctx.data.memoryContext = "";
@@ -22787,8 +22844,14 @@ function createSessionStore(opts) {
22787
22844
  });
22788
22845
  }
22789
22846
  if (client && !tenantId) {
22847
+ if (process.env.GITHUB_ACTIONS === "true") {
22848
+ throw new Error("Convex chat backend requires GITHUB_REPOSITORY in GitHub Actions");
22849
+ }
22790
22850
  logger.warn(`session ${opts.sessionId}: CONVEX_URL set but no tenant (GITHUB_REPOSITORY unset) \u2014 using JSONL`);
22791
22851
  } else {
22852
+ if (process.env.GITHUB_ACTIONS === "true") {
22853
+ throw new Error("Convex chat backend is required in GitHub Actions (CONVEX_URL and KODY_SERVICE_KEY)");
22854
+ }
22792
22855
  logger.info(`session ${opts.sessionId}: CONVEX_URL unset \u2014 using legacy state-repo JSONL store`);
22793
22856
  }
22794
22857
  return createJsonlStore(opts.sessionFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.384",
3
+ "version": "0.4.386",
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",