lancedb-opencode-pro 0.2.0 → 0.2.2

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.
package/dist/index.js CHANGED
@@ -150,7 +150,7 @@ const plugin = async (input) => {
150
150
  memory_delete: tool({
151
151
  description: "Delete one memory entry by id",
152
152
  args: {
153
- id: tool.schema.string().min(6),
153
+ id: tool.schema.string().min(8),
154
154
  scope: tool.schema.string().optional(),
155
155
  confirm: tool.schema.boolean().default(false),
156
156
  },
@@ -237,7 +237,7 @@ const plugin = async (input) => {
237
237
  memory_feedback_wrong: tool({
238
238
  description: "Record feedback for memory that should not be stored",
239
239
  args: {
240
- id: tool.schema.string().min(6),
240
+ id: tool.schema.string().min(8),
241
241
  reason: tool.schema.string().optional(),
242
242
  scope: tool.schema.string().optional(),
243
243
  },
@@ -268,7 +268,7 @@ const plugin = async (input) => {
268
268
  memory_feedback_useful: tool({
269
269
  description: "Record whether a recalled memory was helpful",
270
270
  args: {
271
- id: tool.schema.string().min(6),
271
+ id: tool.schema.string().min(8),
272
272
  helpful: tool.schema.boolean(),
273
273
  scope: tool.schema.string().optional(),
274
274
  },
@@ -313,7 +313,7 @@ const plugin = async (input) => {
313
313
  memory_scope_promote: tool({
314
314
  description: "Promote a memory from project scope to global scope for cross-project sharing",
315
315
  args: {
316
- id: tool.schema.string().min(6),
316
+ id: tool.schema.string().min(8),
317
317
  confirm: tool.schema.boolean().default(false),
318
318
  },
319
319
  execute: async (args, context) => {
@@ -339,7 +339,7 @@ const plugin = async (input) => {
339
339
  memory_scope_demote: tool({
340
340
  description: "Demote a memory from global scope to project scope",
341
341
  args: {
342
- id: tool.schema.string().min(6),
342
+ id: tool.schema.string().min(8),
343
343
  confirm: tool.schema.boolean().default(false),
344
344
  scope: tool.schema.string().optional(),
345
345
  },
package/dist/store.d.ts CHANGED
@@ -33,6 +33,7 @@ export declare class MemoryStore {
33
33
  list(scope: string, limit: number): Promise<MemoryRecord[]>;
34
34
  pruneScope(scope: string, maxEntries: number): Promise<number>;
35
35
  countIncompatibleVectors(scopes: string[], expectedDim: number): Promise<number>;
36
+ private matchesId;
36
37
  hasMemory(id: string, scopes: string[]): Promise<boolean>;
37
38
  updateMemoryUsage(id: string, projectScope: string, scopes: string[]): Promise<void>;
38
39
  listEvents(scopes: string[], limit: number): Promise<MemoryEffectivenessEvent[]>;
@@ -49,5 +50,6 @@ export declare class MemoryStore {
49
50
  private readEventsByScopes;
50
51
  private readByScopes;
51
52
  private ensureIndexes;
53
+ private ensureMemoriesTableCompatibility;
52
54
  private ensureEventTableCompatibility;
53
55
  }
package/dist/store.js CHANGED
@@ -73,6 +73,7 @@ export class MemoryStore {
73
73
  this.eventTable = await this.connection.createTable(EVENTS_TABLE_NAME, [bootstrapEvent]);
74
74
  await this.eventTable.delete("id = '__bootstrap__'");
75
75
  }
76
+ await this.ensureMemoriesTableCompatibility();
76
77
  await this.ensureEventTableCompatibility();
77
78
  await this.ensureIndexes();
78
79
  }
@@ -165,7 +166,7 @@ export class MemoryStore {
165
166
  }
166
167
  async deleteById(id, scopes) {
167
168
  const rows = await this.readByScopes(scopes);
168
- const match = rows.find((row) => row.id === id);
169
+ const match = rows.find((row) => this.matchesId(row.id, id));
169
170
  if (!match)
170
171
  return false;
171
172
  await this.requireTable().delete(`id = '${escapeSql(match.id)}'`);
@@ -174,10 +175,10 @@ export class MemoryStore {
174
175
  }
175
176
  async updateMemoryScope(id, newScope, scopes) {
176
177
  const rows = await this.readByScopes(scopes);
177
- const match = rows.find((row) => row.id === id);
178
+ const match = rows.find((row) => this.matchesId(row.id, id));
178
179
  if (!match)
179
180
  return false;
180
- await this.requireTable().delete(`id = '${escapeSql(id)}'`);
181
+ await this.requireTable().delete(`id = '${escapeSql(match.id)}'`);
181
182
  this.invalidateScope(match.scope);
182
183
  await this.requireTable().add([{ ...match, scope: newScope }]);
183
184
  this.invalidateScope(newScope);
@@ -219,10 +220,15 @@ export class MemoryStore {
219
220
  const rows = await this.readByScopes(scopes);
220
221
  return rows.filter((row) => row.vectorDim !== expectedDim).length;
221
222
  }
223
+ matchesId(candidateId, query) {
224
+ if (query.length >= 36)
225
+ return candidateId === query;
226
+ return candidateId.startsWith(query);
227
+ }
222
228
  async hasMemory(id, scopes) {
223
229
  for (let attempt = 0; attempt < 3; attempt++) {
224
230
  const rows = await this.readByScopes(scopes);
225
- if (rows.some((row) => row.id === id)) {
231
+ if (rows.some((row) => this.matchesId(row.id, id))) {
226
232
  return true;
227
233
  }
228
234
  if (attempt < 2) {
@@ -233,7 +239,7 @@ export class MemoryStore {
233
239
  }
234
240
  async updateMemoryUsage(id, projectScope, scopes) {
235
241
  const rows = await this.readByScopes(scopes);
236
- const match = rows.find((row) => row.id === id);
242
+ const match = rows.find((row) => this.matchesId(row.id, id));
237
243
  if (!match)
238
244
  return;
239
245
  const now = Date.now();
@@ -255,7 +261,7 @@ export class MemoryStore {
255
261
  newProjectCount = projects.size;
256
262
  }
257
263
  }
258
- await this.requireTable().delete(`id = '${escapeSql(id)}'`);
264
+ await this.requireTable().delete(`id = '${escapeSql(match.id)}'`);
259
265
  this.invalidateScope(match.scope);
260
266
  await this.requireTable().add([{
261
267
  ...match,
@@ -519,6 +525,32 @@ export class MemoryStore {
519
525
  this.indexState.ftsError = error instanceof Error ? error.message : String(error);
520
526
  }
521
527
  }
528
+ async ensureMemoriesTableCompatibility() {
529
+ const table = this.requireTable();
530
+ const schema = await table.schema();
531
+ const fieldNames = new Set(schema.fields.map((field) => field.name));
532
+ const missing = [];
533
+ if (!fieldNames.has("lastRecalled")) {
534
+ missing.push({ name: "lastRecalled", valueSql: "CAST(0 AS BIGINT)" });
535
+ }
536
+ if (!fieldNames.has("recallCount")) {
537
+ missing.push({ name: "recallCount", valueSql: "CAST(0 AS INT)" });
538
+ }
539
+ if (!fieldNames.has("projectCount")) {
540
+ missing.push({ name: "projectCount", valueSql: "CAST(0 AS INT)" });
541
+ }
542
+ if (missing.length === 0) {
543
+ return;
544
+ }
545
+ try {
546
+ await table.addColumns(missing);
547
+ }
548
+ catch (error) {
549
+ const reason = error instanceof Error ? error.message : String(error);
550
+ const names = missing.map((col) => col.name).join(", ");
551
+ throw new Error(`Failed to patch ${TABLE_NAME} schema for columns [${names}]: ${reason}`);
552
+ }
553
+ }
522
554
  async ensureEventTableCompatibility() {
523
555
  const table = this.requireEventTable();
524
556
  const schema = await table.schema();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lancedb-opencode-pro",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "LanceDB-backed long-term memory provider for OpenCode",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",