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:
@@ -97,19 +97,29 @@ function writeJsonFile(filePath: string, data: Record<string, any>): void {
|
||||
atomicWriteFileSync(filePath, JSON.stringify(data, null, 2) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* When true, all configs use `npx @colbymchenry/codegraph` instead of the
|
||||
* bare `codegraph` command. Set by the installer when global install fails.
|
||||
*/
|
||||
let useNpxFallback = false;
|
||||
|
||||
export function setUseNpxFallback(value: boolean): void {
|
||||
useNpxFallback = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MCP server configuration for the given location
|
||||
*/
|
||||
function getMcpServerConfig(location: InstallLocation): Record<string, any> {
|
||||
if (location === 'global') {
|
||||
// Global: use 'codegraph' command directly (assumes globally installed)
|
||||
if (location === 'global' && !useNpxFallback) {
|
||||
// Global: use 'codegraph' command directly (globally installed and in PATH)
|
||||
return {
|
||||
type: 'stdio',
|
||||
command: 'codegraph',
|
||||
args: ['serve', '--mcp'],
|
||||
};
|
||||
}
|
||||
// Local: use npx to run the package
|
||||
// Local or npx fallback: use npx to run the package
|
||||
return {
|
||||
type: 'stdio',
|
||||
command: 'npx',
|
||||
@@ -212,7 +222,7 @@ export function hasPermissions(location: InstallLocation): boolean {
|
||||
* Stop → sync-if-dirty (sync, ensures fresh index before next user turn)
|
||||
*/
|
||||
function getHooksConfig(location: InstallLocation): Record<string, any> {
|
||||
const command = location === 'global' ? 'codegraph' : 'npx @colbymchenry/codegraph';
|
||||
const command = (location === 'global' && !useNpxFallback) ? 'codegraph' : 'npx @colbymchenry/codegraph';
|
||||
|
||||
return {
|
||||
PostToolUse: [
|
||||
@@ -229,6 +239,7 @@ function getHooksConfig(location: InstallLocation): Record<string, any> {
|
||||
],
|
||||
Stop: [
|
||||
{
|
||||
matcher: '.*',
|
||||
hooks: [
|
||||
{
|
||||
type: 'command',
|
||||
|
||||
Reference in New Issue
Block a user