fix: use platform-aware local defaults
- Route app DB and sqlite-vec defaults through shared platform helpers - Mirror platform DB defaults in the standalone MCP package - Fix Windows setup npm spawning and remove macOS-only env defaults
This commit is contained in:
@@ -24,7 +24,7 @@ Start with product orientation and goal discovery first.
|
||||
Only bring up setup details if the user actually needs them:
|
||||
|
||||
1. If they are on local/BYO-key mode, point them to Settings → API Keys.
|
||||
2. If they ask about the database location, tell them the default macOS path is `~/Library/Application Support/RA-H/db/rah.sqlite`.
|
||||
2. If they ask about the database location, tell them RA-H uses the platform default: macOS `~/Library/Application Support/RA-H/db/rah.sqlite`, Windows `%APPDATA%/RA-H/db/rah.sqlite`, Linux `~/.local/share/RA-H/db/rah.sqlite`.
|
||||
3. If API keys are relevant, explain them plainly:
|
||||
- **OpenAI** — powers embeddings, semantic retrieval, and extraction-related AI work.
|
||||
- **Anthropic** — mainly relevant for compatible runtime paths and local/dev setups.
|
||||
|
||||
@@ -2,6 +2,7 @@ import Database from 'better-sqlite3';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { DatabaseError } from '@/types/database';
|
||||
import { getDatabasePath, getVecExtensionPath } from '@/services/database/sqlite-runtime';
|
||||
|
||||
export interface SQLiteConfig {
|
||||
dbPath: string;
|
||||
@@ -115,17 +116,9 @@ class SQLiteClient {
|
||||
}
|
||||
|
||||
private getSQLiteConfig(): SQLiteConfig {
|
||||
const dbPath = process.env.SQLITE_DB_PATH || path.join(
|
||||
process.env.HOME || '~',
|
||||
'Library/Application Support/RA-H/db/rah.sqlite'
|
||||
);
|
||||
|
||||
const vecExtensionPath = process.env.SQLITE_VEC_EXTENSION_PATH ||
|
||||
'./vendor/sqlite-extensions/vec0.dylib';
|
||||
|
||||
return {
|
||||
dbPath,
|
||||
vecExtensionPath
|
||||
dbPath: getDatabasePath(),
|
||||
vecExtensionPath: getVecExtensionPath()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
*/
|
||||
|
||||
import Database from 'better-sqlite3';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import { getDbVectorCapability as getVectorCapability } from '@/services/database/sqlite-runtime';
|
||||
import {
|
||||
getDatabasePath as getRuntimeDatabasePath,
|
||||
getDbVectorCapability as getVectorCapability,
|
||||
getVecExtensionPath as getRuntimeVecExtensionPath
|
||||
} from '@/services/database/sqlite-runtime';
|
||||
|
||||
/**
|
||||
* Serialize a float array to binary format for vec0 storage
|
||||
@@ -35,27 +37,14 @@ export function deserializeFloat32Vector(blob: Buffer): number[] {
|
||||
* Get SQLite database path from environment or default location
|
||||
*/
|
||||
export function getDatabasePath(): string {
|
||||
const envPath = process.env.SQLITE_DB_PATH;
|
||||
if (envPath) {
|
||||
return envPath;
|
||||
}
|
||||
|
||||
// Default path: ~/Library/Application Support/RA-H/db/rah.sqlite
|
||||
const homeDir = os.homedir();
|
||||
return path.join(homeDir, 'Library', 'Application Support', 'RA-H', 'db', 'rah.sqlite');
|
||||
return getRuntimeDatabasePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vec extension path from environment or default location
|
||||
*/
|
||||
export function getVecExtensionPath(): string {
|
||||
const envPath = process.env.SQLITE_VEC_EXTENSION_PATH;
|
||||
if (envPath) {
|
||||
return envPath;
|
||||
}
|
||||
|
||||
// Default path relative to project root
|
||||
return path.join(process.cwd(), 'vendor', 'sqlite-extensions', 'vec0.dylib');
|
||||
return getRuntimeVecExtensionPath();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,18 +2,10 @@ import { tool } from 'ai';
|
||||
import { z } from 'zod';
|
||||
import { exec } from 'child_process';
|
||||
import { promisify } from 'util';
|
||||
import path from 'path';
|
||||
import { getDatabasePath } from '@/services/database/sqlite-runtime';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
// Get database path (same logic as sqlite-client.ts)
|
||||
function getDatabasePath(): string {
|
||||
return process.env.SQLITE_DB_PATH || path.join(
|
||||
process.env.HOME || '~',
|
||||
'Library/Application Support/RA-H/db/rah.sqlite'
|
||||
);
|
||||
}
|
||||
|
||||
// Security: Only allow SELECT statements
|
||||
function isReadOnlyQuery(sql: string): boolean {
|
||||
const normalized = sql.trim().toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user