Add WASM fallbacks for tree-sitter and SQLite, fix installer

Replace native tree-sitter with web-tree-sitter + tree-sitter-wasms for
universal cross-platform support. Add node-sqlite3-wasm as a fallback
when better-sqlite3 native bindings aren't available. Move better-sqlite3
and sqlite-vss to optionalDependencies so installs never fail.

Fix installer to use npx fallback when global npm install fails, so MCP
config, hooks, and quick-start instructions all work without the bare
codegraph command in PATH.

Fix tests: update schema version expectation, fix db test paths and
method names, extract MAX_OUTPUT_LENGTH as module constant, normalize
Windows path separators in import resolver.
This commit is contained in:
Colby McHenry
2026-02-14 00:56:15 -06:00
parent 429359c25f
commit 8346440592
24 changed files with 707 additions and 781 deletions
+8 -6
View File
@@ -4,20 +4,22 @@
* Handles SQLite database initialization and connection management.
*/
import Database from 'better-sqlite3';
import { SqliteDatabase, createDatabase } from './sqlite-adapter';
import * as fs from 'fs';
import * as path from 'path';
import { SchemaVersion } from '../types';
import { runMigrations, getCurrentVersion, CURRENT_SCHEMA_VERSION } from './migrations';
export { SqliteDatabase, getActiveBackend } from './sqlite-adapter';
/**
* Database connection wrapper with lifecycle management
*/
export class DatabaseConnection {
private db: Database.Database;
private db: SqliteDatabase;
private dbPath: string;
private constructor(db: Database.Database, dbPath: string) {
private constructor(db: SqliteDatabase, dbPath: string) {
this.db = db;
this.dbPath = dbPath;
}
@@ -33,7 +35,7 @@ export class DatabaseConnection {
}
// Create and configure database
const db = new Database(dbPath);
const db = createDatabase(dbPath);
// Enable foreign keys and WAL mode for better performance
db.pragma('foreign_keys = ON');
@@ -71,7 +73,7 @@ export class DatabaseConnection {
throw new Error(`Database not found: ${dbPath}`);
}
const db = new Database(dbPath);
const db = createDatabase(dbPath);
// Enable foreign keys and WAL mode
db.pragma('foreign_keys = ON');
@@ -99,7 +101,7 @@ export class DatabaseConnection {
/**
* Get the underlying database instance
*/
getDb(): Database.Database {
getDb(): SqliteDatabase {
return this.db;
}