@zabaca/lattice 1.0.22 → 1.0.23

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/main.js +28 -15
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -873,8 +873,7 @@ class GraphService {
873
873
  const allResults = [];
874
874
  const conn = await this.ensureConnected();
875
875
  const vectorStr = `[${queryVector.join(", ")}]`;
876
- try {
877
- const reader = await conn.runAndReadAll(`
876
+ const sql = `
878
877
  SELECT
879
878
  name,
880
879
  label,
@@ -883,10 +882,11 @@ class GraphService {
883
882
  array_cosine_similarity(embedding, ${vectorStr}::FLOAT[${this.embeddingDimensions}]) as similarity
884
883
  FROM nodes
885
884
  WHERE embedding IS NOT NULL
886
- ORDER BY similarity DESC
887
- LIMIT ${k}
888
- `);
889
- for (const row of reader.getRows()) {
885
+ `;
886
+ try {
887
+ const reader = await conn.runAndReadAll(sql);
888
+ const rows = reader.getRows();
889
+ for (const row of rows) {
890
890
  const [name, label, title, description, similarity] = row;
891
891
  allResults.push({
892
892
  name,
@@ -3373,26 +3373,36 @@ GraphValidatorService = __legacyDecorateClassTS([
3373
3373
  // src/commands/sync.command.ts
3374
3374
  class SyncCommand extends CommandRunner7 {
3375
3375
  syncService;
3376
+ graphService;
3376
3377
  _graphValidator;
3377
3378
  watcher = null;
3378
3379
  isShuttingDown = false;
3379
- constructor(syncService, _graphValidator) {
3380
+ constructor(syncService, graphService, _graphValidator) {
3380
3381
  super();
3381
3382
  this.syncService = syncService;
3383
+ this.graphService = graphService;
3382
3384
  this._graphValidator = _graphValidator;
3383
3385
  }
3386
+ async safeExit(code) {
3387
+ try {
3388
+ await this.graphService.checkpoint();
3389
+ } catch (error) {
3390
+ console.error("Warning: checkpoint failed during exit");
3391
+ }
3392
+ process.exit(code);
3393
+ }
3384
3394
  async run(paths, options) {
3385
3395
  if (options.watch && options.dryRun) {
3386
3396
  console.log(`
3387
3397
  \u26A0\uFE0F Watch mode is not compatible with --dry-run mode
3388
3398
  `);
3389
- process.exit(1);
3399
+ await this.safeExit(1);
3390
3400
  }
3391
3401
  if (options.watch && options.force) {
3392
3402
  console.log(`
3393
3403
  \u26A0\uFE0F Watch mode is not compatible with --force mode (for safety)
3394
3404
  `);
3395
- process.exit(1);
3405
+ await this.safeExit(1);
3396
3406
  }
3397
3407
  if (options.force && paths.length === 0) {
3398
3408
  console.log(`
@@ -3400,7 +3410,7 @@ class SyncCommand extends CommandRunner7 {
3400
3410
  `);
3401
3411
  console.log(` Usage: lattice sync --force <path1> [path2] ...
3402
3412
  `);
3403
- process.exit(1);
3413
+ await this.safeExit(1);
3404
3414
  }
3405
3415
  const syncOptions = {
3406
3416
  force: options.force,
@@ -3447,12 +3457,12 @@ class SyncCommand extends CommandRunner7 {
3447
3457
  if (options.watch) {
3448
3458
  await this.enterWatchMode(syncOptions);
3449
3459
  } else {
3450
- process.exit(initialResult.errors.length > 0 ? 1 : 0);
3460
+ await this.safeExit(initialResult.errors.length > 0 ? 1 : 0);
3451
3461
  }
3452
3462
  } catch (error) {
3453
3463
  console.error(`
3454
3464
  \u274C Sync failed:`, error instanceof Error ? error.message : String(error));
3455
- process.exit(1);
3465
+ await this.safeExit(1);
3456
3466
  }
3457
3467
  }
3458
3468
  async enterWatchMode(syncOptions) {
@@ -3509,10 +3519,12 @@ class SyncCommand extends CommandRunner7 {
3509
3519
  debouncedSync();
3510
3520
  }
3511
3521
  });
3512
- process.on("SIGINT", () => this.shutdown());
3522
+ process.on("SIGINT", () => {
3523
+ this.shutdown().catch(console.error);
3524
+ });
3513
3525
  await new Promise(() => {});
3514
3526
  }
3515
- shutdown() {
3527
+ async shutdown() {
3516
3528
  if (this.isShuttingDown)
3517
3529
  return;
3518
3530
  this.isShuttingDown = true;
@@ -3522,7 +3534,7 @@ class SyncCommand extends CommandRunner7 {
3522
3534
  if (this.watcher) {
3523
3535
  this.watcher.close();
3524
3536
  }
3525
- process.exit(0);
3537
+ await this.safeExit(0);
3526
3538
  }
3527
3539
  printSyncResults(result, isWatchMode = false) {
3528
3540
  console.log(`
@@ -3712,6 +3724,7 @@ SyncCommand = __legacyDecorateClassTS([
3712
3724
  }),
3713
3725
  __legacyMetadataTS("design:paramtypes", [
3714
3726
  typeof SyncService === "undefined" ? Object : SyncService,
3727
+ typeof GraphService === "undefined" ? Object : GraphService,
3715
3728
  typeof GraphValidatorService === "undefined" ? Object : GraphValidatorService
3716
3729
  ])
3717
3730
  ], SyncCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zabaca/lattice",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "Human-initiated, AI-powered knowledge graph for markdown documentation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@anthropic-ai/claude-agent-sdk": "^0.1.67",
47
- "@duckdb/node-api": "1.3.1-alpha.23",
47
+ "@duckdb/node-api": "1.4.3-r.1",
48
48
  "@nestjs/common": "^10.0.0",
49
49
  "@nestjs/config": "^3.0.0",
50
50
  "@nestjs/core": "^10.0.0",