mirror of
https://github.com/obra/superpowers.git
synced 2026-09-03 12:15:39 +00:00
Migrate conversation search to use PERSONAL_SUPERPOWERS_DIR
Updates conversation indexing and search to use the new personal superpowers directory structure with environment variable support. Changes: - Added src/paths.ts for centralized directory resolution - Updated db.ts, indexer.ts, verify.ts to use paths.ts - Created migrate-to-config.sh for data migration from ~/.clank - Updated all documentation references from ~/.clank to ~/.config/superpowers - Database paths automatically updated during migration Migration tested with 5,017 conversations and 6,385 exchanges.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
* Get the personal superpowers directory
|
||||
*
|
||||
* Precedence:
|
||||
* 1. PERSONAL_SUPERPOWERS_DIR env var (if set)
|
||||
* 2. XDG_CONFIG_HOME/superpowers (if XDG_CONFIG_HOME is set)
|
||||
* 3. ~/.config/superpowers (default)
|
||||
*/
|
||||
export function getSuperpowersDir(): string {
|
||||
if (process.env.PERSONAL_SUPERPOWERS_DIR) {
|
||||
return process.env.PERSONAL_SUPERPOWERS_DIR;
|
||||
}
|
||||
|
||||
const xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
||||
if (xdgConfigHome) {
|
||||
return path.join(xdgConfigHome, 'superpowers');
|
||||
}
|
||||
|
||||
return path.join(os.homedir(), '.config', 'superpowers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get conversation archive directory
|
||||
*/
|
||||
export function getArchiveDir(): string {
|
||||
// Allow test override
|
||||
if (process.env.TEST_ARCHIVE_DIR) {
|
||||
return process.env.TEST_ARCHIVE_DIR;
|
||||
}
|
||||
|
||||
return path.join(getSuperpowersDir(), 'conversation-archive');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get conversation index directory
|
||||
*/
|
||||
export function getIndexDir(): string {
|
||||
return path.join(getSuperpowersDir(), 'conversation-index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get database path
|
||||
*/
|
||||
export function getDbPath(): string {
|
||||
return path.join(getIndexDir(), 'db.sqlite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exclude config path
|
||||
*/
|
||||
export function getExcludeConfigPath(): string {
|
||||
return path.join(getIndexDir(), 'exclude.txt');
|
||||
}
|
||||
Reference in New Issue
Block a user