Refactor path management: Migrate path discovery logic to shared paths module

- Removed `path-discovery.ts` service and replaced its usage with a new `paths.ts` module.
- Updated all commands and services to utilize the new path constants and helper functions.
- Ensured all necessary directories are created using the new utility functions.
- Improved code readability and maintainability by centralizing path configurations.
This commit is contained in:
Alex Newman
2025-10-16 14:46:47 -04:00
parent 2ba840aaac
commit f2551ac366
18 changed files with 327 additions and 233 deletions
+3 -7
View File
@@ -1,7 +1,5 @@
import { Database as BunDatabase } from 'bun:sqlite';
import path from 'path';
import fs from 'fs';
import { PathDiscovery } from '../path-discovery.js';
import { DATA_DIR, DB_PATH, ensureDir } from '../../shared/paths.js';
// Type alias for better-sqlite3 compatibility
type Database = BunDatabase;
@@ -47,11 +45,9 @@ export class DatabaseManager {
}
// Ensure the data directory exists
const dataDir = PathDiscovery.getInstance().getDataDirectory();
fs.mkdirSync(dataDir, { recursive: true });
ensureDir(DATA_DIR);
const dbPath = path.join(dataDir, 'claude-mem.db');
this.db = new BunDatabase(dbPath, { create: true, readwrite: true });
this.db = new BunDatabase(DB_PATH, { create: true, readwrite: true });
// Apply optimized SQLite settings
this.db.run('PRAGMA journal_mode = WAL');