@orquentra/codebuddy 2.9.0 → 2.15.0

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 (117) hide show
  1. package/ARCHITECTURE.md +98 -0
  2. package/CLAUDE_CODEX.md +33 -0
  3. package/README.md +114 -9
  4. package/dist/{adapters-S4HHTWJW.js → adapters-OJRSVFV3.js} +2 -2
  5. package/dist/{chunk-GXOML4UZ.js → chunk-4BSO3HST.js} +126 -18
  6. package/dist/chunk-4BSO3HST.js.map +1 -0
  7. package/dist/{chunk-CAEPHLHC.js → chunk-57642NGU.js} +2 -44
  8. package/dist/chunk-57642NGU.js.map +1 -0
  9. package/dist/{chunk-ESZXCZIN.js → chunk-6YI2D5F5.js} +33 -5
  10. package/dist/chunk-6YI2D5F5.js.map +1 -0
  11. package/dist/{chunk-GKNYMNFM.js → chunk-7IPSDDO5.js} +10 -3
  12. package/dist/chunk-7IPSDDO5.js.map +1 -0
  13. package/dist/chunk-BTTQWSDS.js +372 -0
  14. package/dist/chunk-BTTQWSDS.js.map +1 -0
  15. package/dist/{chunk-2WH2Q4TA.js → chunk-D5E7SGI5.js} +304 -77
  16. package/dist/chunk-D5E7SGI5.js.map +1 -0
  17. package/dist/chunk-EMWGLKPR.js +45 -0
  18. package/dist/chunk-EMWGLKPR.js.map +1 -0
  19. package/dist/chunk-GQKWUHMA.js +20 -0
  20. package/dist/chunk-GQKWUHMA.js.map +1 -0
  21. package/dist/chunk-ITXE27SZ.js +358 -0
  22. package/dist/chunk-ITXE27SZ.js.map +1 -0
  23. package/dist/{chunk-UK6XTS2Y.js → chunk-JJQDVGF7.js} +23 -23
  24. package/dist/chunk-JJQDVGF7.js.map +1 -0
  25. package/dist/{chunk-F4BJ3DXW.js → chunk-KQCP3ZYH.js} +1273 -331
  26. package/dist/chunk-KQCP3ZYH.js.map +1 -0
  27. package/dist/{chunk-QN76UJP7.js → chunk-KYRM3HPP.js} +89 -21
  28. package/dist/chunk-KYRM3HPP.js.map +1 -0
  29. package/dist/{chunk-KNR2P2UY.js → chunk-M75SN4D4.js} +19 -4
  30. package/dist/chunk-M75SN4D4.js.map +1 -0
  31. package/dist/{chunk-J4T6HHI4.js → chunk-RZ266NHE.js} +538 -317
  32. package/dist/chunk-RZ266NHE.js.map +1 -0
  33. package/dist/chunk-U7KDM62P.js +43 -0
  34. package/dist/chunk-U7KDM62P.js.map +1 -0
  35. package/dist/chunk-UATJCD2T.js +368 -0
  36. package/dist/chunk-UATJCD2T.js.map +1 -0
  37. package/dist/{chunk-ENKDFLOO.js → chunk-UOTKHSQ5.js} +25 -8
  38. package/dist/chunk-UOTKHSQ5.js.map +1 -0
  39. package/dist/{chunk-TLWGZVPC.js → chunk-UR3DF74I.js} +1007 -132
  40. package/dist/chunk-UR3DF74I.js.map +1 -0
  41. package/dist/chunk-UTPC66MV.js +128 -0
  42. package/dist/chunk-UTPC66MV.js.map +1 -0
  43. package/dist/{chunk-W7GAXL6C.js → chunk-V7PT6ER5.js} +6 -5
  44. package/dist/chunk-V7PT6ER5.js.map +1 -0
  45. package/dist/chunk-WHKXUXHE.js +156 -0
  46. package/dist/chunk-WHKXUXHE.js.map +1 -0
  47. package/dist/{chunk-SRA4MDVG.js → chunk-YMXFSHXT.js} +978 -950
  48. package/dist/chunk-YMXFSHXT.js.map +1 -0
  49. package/dist/cli/index.js +23 -9
  50. package/dist/cli/index.js.map +1 -1
  51. package/dist/{codebuddy-DO7ZhoWn.d.ts → codebuddy-CHqMptZB.d.ts} +35 -0
  52. package/dist/config-TXQJCCVI.js +15 -0
  53. package/dist/expand-KWYGNCKZ.js +98 -0
  54. package/dist/expand-KWYGNCKZ.js.map +1 -0
  55. package/dist/file-vectors-MKXTSGGH.js +19 -0
  56. package/dist/index-facts-4MTEHKMN.js +38 -0
  57. package/dist/index-pass-TBDUEZCB.js +14 -0
  58. package/dist/index.d.ts +6 -4
  59. package/dist/index.js +25 -23
  60. package/dist/install-E3JWINTN.js +31 -0
  61. package/dist/langgraph/index.d.ts +1 -1
  62. package/dist/lean-MLTAFS5L.js +29 -0
  63. package/dist/local-75DJECVR.js +48 -0
  64. package/dist/local-llm-MECVJTVU.js +19 -0
  65. package/dist/{main-YJKSYFPT.js → main-RLMKQZW4.js} +999 -328
  66. package/dist/main-RLMKQZW4.js.map +1 -0
  67. package/dist/{memory-TGHVTBME.js → memory-PFFVMTCH.js} +9 -6
  68. package/dist/{memory-TGHVTBME.js.map → memory-PFFVMTCH.js.map} +1 -1
  69. package/dist/{operations-OG4ISWIM.js → operations-STR7S5UO.js} +8 -7
  70. package/dist/operations-STR7S5UO.js.map +1 -0
  71. package/dist/{pretool-command-PRFOIHMW.js → pretool-command-B5GY5T6E.js} +2 -2
  72. package/dist/pretool-command-B5GY5T6E.js.map +1 -0
  73. package/dist/prompt-gate-TDTFFQW2.js +8 -0
  74. package/dist/prompt-gate-TDTFFQW2.js.map +1 -0
  75. package/dist/{rerank-IQAEWLQR.js → rerank-XXKWDI5Q.js} +7 -4
  76. package/dist/{rerank-IQAEWLQR.js.map → rerank-XXKWDI5Q.js.map} +1 -1
  77. package/dist/{runtime-GCSEIAVD.js → runtime-SWFWGTQ4.js} +18 -9
  78. package/dist/runtime-SWFWGTQ4.js.map +1 -0
  79. package/dist/summaries-QXWFFDUZ.js +31 -0
  80. package/dist/summaries-QXWFFDUZ.js.map +1 -0
  81. package/dist/{zvec-XDZNZ2OL.js → zvec-F73IBWO5.js} +13 -6
  82. package/dist/zvec-F73IBWO5.js.map +1 -0
  83. package/package.json +13 -3
  84. package/dist/chunk-2WH2Q4TA.js.map +0 -1
  85. package/dist/chunk-6NZEZJYD.js +0 -206
  86. package/dist/chunk-6NZEZJYD.js.map +0 -1
  87. package/dist/chunk-CAEPHLHC.js.map +0 -1
  88. package/dist/chunk-ENKDFLOO.js.map +0 -1
  89. package/dist/chunk-ESZXCZIN.js.map +0 -1
  90. package/dist/chunk-F4BJ3DXW.js.map +0 -1
  91. package/dist/chunk-GKNYMNFM.js.map +0 -1
  92. package/dist/chunk-GXOML4UZ.js.map +0 -1
  93. package/dist/chunk-ITQO632W.js +0 -673
  94. package/dist/chunk-ITQO632W.js.map +0 -1
  95. package/dist/chunk-J4T6HHI4.js.map +0 -1
  96. package/dist/chunk-KNR2P2UY.js.map +0 -1
  97. package/dist/chunk-QN76UJP7.js.map +0 -1
  98. package/dist/chunk-SFMIMLXR.js +0 -63
  99. package/dist/chunk-SFMIMLXR.js.map +0 -1
  100. package/dist/chunk-SRA4MDVG.js.map +0 -1
  101. package/dist/chunk-TLWGZVPC.js.map +0 -1
  102. package/dist/chunk-UK6XTS2Y.js.map +0 -1
  103. package/dist/chunk-W7GAXL6C.js.map +0 -1
  104. package/dist/config-GEZFLXK6.js +0 -12
  105. package/dist/install-BXM56QCD.js +0 -19
  106. package/dist/lean-command-7DFW32MA.js +0 -19
  107. package/dist/main-YJKSYFPT.js.map +0 -1
  108. package/dist/summaries-ML53R7EL.js +0 -21
  109. /package/dist/{adapters-S4HHTWJW.js.map → adapters-OJRSVFV3.js.map} +0 -0
  110. /package/dist/{config-GEZFLXK6.js.map → config-TXQJCCVI.js.map} +0 -0
  111. /package/dist/{install-BXM56QCD.js.map → file-vectors-MKXTSGGH.js.map} +0 -0
  112. /package/dist/{lean-command-7DFW32MA.js.map → index-facts-4MTEHKMN.js.map} +0 -0
  113. /package/dist/{operations-OG4ISWIM.js.map → index-pass-TBDUEZCB.js.map} +0 -0
  114. /package/dist/{pretool-command-PRFOIHMW.js.map → install-E3JWINTN.js.map} +0 -0
  115. /package/dist/{runtime-GCSEIAVD.js.map → lean-MLTAFS5L.js.map} +0 -0
  116. /package/dist/{summaries-ML53R7EL.js.map → local-75DJECVR.js.map} +0 -0
  117. /package/dist/{zvec-XDZNZ2OL.js.map → local-llm-MECVJTVU.js.map} +0 -0
@@ -1,4 +1,9 @@
1
1
  import {
2
+ clampBudgetForCallerModel,
3
+ countTokens
4
+ } from "./chunk-57642NGU.js";
5
+ import {
6
+ MEMORY_CONCEPT_SCORE,
2
7
  MemoryFileStore,
3
8
  auditLog,
4
9
  candidateLimit,
@@ -7,39 +12,27 @@ import {
7
12
  interactions,
8
13
  isEligibleMemory,
9
14
  lexicalTerms,
15
+ memoryConceptPatterns,
10
16
  modelCalls,
11
17
  namespaces,
12
18
  schema_exports,
13
19
  sessionSummaries,
14
20
  shares,
15
21
  validSearchVector
16
- } from "./chunk-SRA4MDVG.js";
22
+ } from "./chunk-YMXFSHXT.js";
17
23
  import {
18
- clampBudgetForCallerModel,
19
24
  computeContentHash,
20
25
  computeFactHash,
21
- countTokens,
22
26
  generateEntityId,
23
27
  generateSessionId
24
- } from "./chunk-CAEPHLHC.js";
25
- import {
26
- OpenRouterEmbeddingProvider
27
- } from "./chunk-6JCKMIQY.js";
28
- import {
29
- LocalModelProvider
30
- } from "./chunk-3QGW53GD.js";
28
+ } from "./chunk-EMWGLKPR.js";
31
29
  import {
32
30
  REDACTED,
33
31
  redactPersisted
34
32
  } from "./chunk-AL6VBTNA.js";
35
33
  import {
36
- DEFAULT_CLOUD_EMBEDDING_MODELS,
37
- DEFAULT_EMBEDDING_MODELS,
38
- DEFAULT_LLM_MODELS,
39
- EMBEDDING_DIMENSIONS,
40
- assertCompatibleEmbeddingModels,
41
- getModelDefinition
42
- } from "./chunk-HPOR6YXA.js";
34
+ OpenRouterEmbeddingProvider
35
+ } from "./chunk-6JCKMIQY.js";
43
36
  import {
44
37
  MISSING_DATABASE_URL,
45
38
  checkConfigPermissions,
@@ -49,7 +42,18 @@ import {
49
42
  migrateLegacyNamespace,
50
43
  readConfigFile,
51
44
  redactSecrets
52
- } from "./chunk-KNR2P2UY.js";
45
+ } from "./chunk-M75SN4D4.js";
46
+ import {
47
+ LocalModelProvider
48
+ } from "./chunk-3QGW53GD.js";
49
+ import {
50
+ DEFAULT_CLOUD_EMBEDDING_MODELS,
51
+ DEFAULT_EMBEDDING_MODELS,
52
+ DEFAULT_LLM_MODELS,
53
+ EMBEDDING_DIMENSIONS,
54
+ assertCompatibleEmbeddingModels,
55
+ getModelDefinition
56
+ } from "./chunk-HPOR6YXA.js";
53
57
 
54
58
  // src/db/bootstrap.ts
55
59
  async function enablePgvector(sql2) {
@@ -89,6 +93,7 @@ import postgres from "postgres";
89
93
  function createDatabaseClient(config) {
90
94
  const sql2 = postgres(config.postgresUrl, {
91
95
  max: config.maxConnections ?? 10,
96
+ ...config.applicationName ? { connection: { application_name: config.applicationName } } : {},
92
97
  ...config.connectTimeoutSeconds !== void 0 ? { connect_timeout: config.connectTimeoutSeconds } : {},
93
98
  // postgres.js logs NOTICE messages (e.g. "extension already exists,
94
99
  // skipping") to stdout by default. Over the MCP stdio transport stdout
@@ -834,17 +839,21 @@ var PostgresMemoryRepository = class {
834
839
  }
835
840
  async searchFactsLexically(namespaceId, query, limit) {
836
841
  const terms = lexicalTerms(query);
842
+ const patterns = memoryConceptPatterns(query);
837
843
  if (!terms.length) return { candidates: [], matchedFacts: 0 };
838
844
  const rows = await this.db.execute(sql`
839
845
  with scored as materialized (
840
846
  select id, content, subject, predicate, object, proposition_key, confidence,
841
847
  created_by_agent, created_at,
842
- (select coalesce(sum(
848
+ greatest((select coalesce(sum(
843
849
  (case when strpos(' ' || regexp_replace(lower(subject || ' ' || object), '[^[:alnum:]_]+', ' ', 'g') || ' ', ' ' || term || ' ') > 0 then 2 else 0 end) +
844
850
  (case when strpos(' ' || regexp_replace(lower(content), '[^[:alnum:]_]+', ' ', 'g') || ' ', ' ' || term || ' ') > 0 then 1 else 0 end)
845
851
  ), 0)::float / ${3 * terms.length} from
846
852
  jsonb_array_elements_text(${JSON.stringify(terms)}::jsonb) term
847
- ) as score
853
+ ), case when exists (
854
+ select 1 from jsonb_array_elements_text(${JSON.stringify(patterns)}::jsonb) pattern
855
+ where lower(subject || ' ' || object || ' ' || content) ~ pattern
856
+ ) then ${MEMORY_CONCEPT_SCORE}::double precision else 0::double precision end) as score
848
857
  from facts
849
858
  where not source_deleted and superseded_by is null
850
859
  and (
@@ -1177,6 +1186,38 @@ var PostgresMemoryRepository = class {
1177
1186
  };
1178
1187
  });
1179
1188
  }
1189
+ async storageStatus(namespaceId) {
1190
+ const [factRows, statusRows, pendingRows, spaceRows] = await Promise.all([
1191
+ this.client.sql`
1192
+ select id, file_backed from facts where namespace_id = ${namespaceId}`,
1193
+ this.client.sql`
1194
+ select status::text as status, count(*)::text as count from embeddings
1195
+ where namespace_id = ${namespaceId} group by status`,
1196
+ this.client.sql`
1197
+ select min(created_at) as oldest from embeddings
1198
+ where namespace_id = ${namespaceId} and status = 'pending'`,
1199
+ this.client.sql`
1200
+ select embedding_space as space, embedding_model as model, count(*)::text as count
1201
+ from embeddings where namespace_id = ${namespaceId} and status = 'ready'
1202
+ group by embedding_space, embedding_model order by count(*) desc`
1203
+ ]);
1204
+ const embeddings2 = { pending: 0, processing: 0, failed: 0, ready: 0 };
1205
+ for (const row of statusRows) {
1206
+ if (row.status in embeddings2)
1207
+ embeddings2[row.status] = Number(row.count);
1208
+ }
1209
+ const oldest = pendingRows[0]?.oldest;
1210
+ return {
1211
+ facts: factRows.map((row) => ({ id: row.id, fileBacked: row.file_backed })),
1212
+ embeddings: embeddings2,
1213
+ oldestPendingAt: oldest ? new Date(oldest).toISOString() : null,
1214
+ spaces: spaceRows.map((row) => ({
1215
+ space: row.space,
1216
+ model: row.model,
1217
+ count: Number(row.count)
1218
+ }))
1219
+ };
1220
+ }
1180
1221
  async getVectorIndexHealth(namespaceId) {
1181
1222
  const countRows = namespaceId ? await this.client.sql`select count(*)::text as count from embeddings where namespace_id = ${namespaceId}` : await this.client.sql`select count(*)::text as count from embeddings`;
1182
1223
  const indexRows = await this.client.sql`
@@ -2678,6 +2719,33 @@ var CodeBuddy = class {
2678
2719
  * file is applied independently: malformed or conflicting files are reported
2679
2720
  * in `failures` and never abort healthy imports (nor count as deletions).
2680
2721
  */
2722
+ /**
2723
+ * Where Markdown and the database disagree (queue Q7). `markdownOnly`: an
2724
+ * eligible fact file with no row (reindex imports it). `dbOnly`: a row with no
2725
+ * eligible file; `unbacked` are those never imported from a file, i.e. not
2726
+ * covered by the Markdown backup. Read-only.
2727
+ */
2728
+ async storageReport() {
2729
+ const namespaceId = this.requireNamespaceId();
2730
+ const status = await this.repo.storageStatus(namespaceId);
2731
+ const scan = this.memoryFileStore ? await this.memoryFileStore.scanFacts() : null;
2732
+ const files = new Set(
2733
+ (scan?.facts ?? []).filter((file) => isEligibleMemory(file, { namespace: this.config.namespace })).map((file) => file.id)
2734
+ );
2735
+ const rows = new Map(status.facts.map((fact) => [fact.id, fact.fileBacked]));
2736
+ const dbOnly = [...rows.keys()].filter((id) => !files.has(id));
2737
+ return {
2738
+ markdownFacts: files.size,
2739
+ invalidFiles: scan?.invalid.length ?? 0,
2740
+ databaseFacts: rows.size,
2741
+ markdownOnly: [...files].filter((id) => !rows.has(id)),
2742
+ dbOnly,
2743
+ unbacked: dbOnly.filter((id) => rows.get(id) === false),
2744
+ embeddings: status.embeddings,
2745
+ oldestPendingAt: status.oldestPendingAt,
2746
+ spaces: status.spaces
2747
+ };
2748
+ }
2681
2749
  async reindexMemory(options = {}) {
2682
2750
  const namespaceId = this.requireNamespaceId();
2683
2751
  const store = this.memoryFileStore;
@@ -3320,4 +3388,4 @@ export {
3320
3388
  inspectNamespace,
3321
3389
  runDoctor
3322
3390
  };
3323
- //# sourceMappingURL=chunk-QN76UJP7.js.map
3391
+ //# sourceMappingURL=chunk-KYRM3HPP.js.map