@kody-ade/kody-engine 0.4.384 → 0.4.385

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 +51 -1
  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.385",
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
  }
@@ -5952,6 +5975,21 @@ __export(loadMemoryContext_exports, {
5952
5975
  });
5953
5976
  import * as fs21 from "fs";
5954
5977
  import * as path21 from "path";
5978
+ function formatBlockFromBackend(docs) {
5979
+ const pages = docs.flatMap((record) => {
5980
+ if (!record.doc || typeof record.doc !== "object") return [];
5981
+ const doc = record.doc;
5982
+ if (typeof doc.content !== "string") return [];
5983
+ return [{
5984
+ relPath: typeof doc.relPath === "string" ? doc.relPath : record.kind,
5985
+ title: typeof doc.title === "string" ? doc.title : record.kind,
5986
+ updated: typeof doc.updated === "string" ? doc.updated : record.updatedAt,
5987
+ content: doc.content.length > PER_PAGE_MAX_BYTES ? doc.content.slice(0, PER_PAGE_MAX_BYTES) + TRUNCATED_SUFFIX2 : doc.content,
5988
+ mtime: Date.parse(record.updatedAt) || 0
5989
+ }];
5990
+ });
5991
+ return formatBlock(sortByRecency(pages).slice(0, MAX_PAGES));
5992
+ }
5955
5993
  function collectPages(memoryAbs) {
5956
5994
  const out = [];
5957
5995
  walkMd(memoryAbs, (file) => {
@@ -6064,6 +6102,7 @@ var MEMORY_DIR_RELATIVE, MAX_PAGES, PER_PAGE_MAX_BYTES, TOTAL_MAX_BYTES2, TRUNCA
6064
6102
  var init_loadMemoryContext = __esm({
6065
6103
  "src/scripts/loadMemoryContext.ts"() {
6066
6104
  "use strict";
6105
+ init_state_backend();
6067
6106
  MEMORY_DIR_RELATIVE = ".kody/memory";
6068
6107
  MAX_PAGES = 8;
6069
6108
  PER_PAGE_MAX_BYTES = 4e3;
@@ -6071,6 +6110,17 @@ var init_loadMemoryContext = __esm({
6071
6110
  TRUNCATED_SUFFIX2 = "\n\n\u2026 (truncated)";
6072
6111
  loadMemoryContext = async (ctx) => {
6073
6112
  if (typeof ctx.data.memoryContext === "string") return;
6113
+ const tenantId = ctx.config.github?.owner && ctx.config.github.repo ? `${ctx.config.github.owner}/${ctx.config.github.repo}` : process.env.GITHUB_REPOSITORY?.trim();
6114
+ if (process.env.CONVEX_URL && process.env.KODY_SERVICE_KEY && tenantId) {
6115
+ try {
6116
+ const backend = createStateBackendFromEnv();
6117
+ const docs = await backend.listRepoDocs(tenantId, "memory:");
6118
+ ctx.data.memoryContext = formatBlockFromBackend(docs);
6119
+ } catch {
6120
+ ctx.data.memoryContext = "";
6121
+ }
6122
+ return;
6123
+ }
6074
6124
  const memoryAbs = path21.join(ctx.cwd, MEMORY_DIR_RELATIVE);
6075
6125
  if (!fs21.existsSync(memoryAbs)) {
6076
6126
  ctx.data.memoryContext = "";
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.385",
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",