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:
Jesse Vincent
2025-10-10 17:14:40 -07:00
parent 6c0ab4cfec
commit a48a7e5b1b
8 changed files with 203 additions and 35 deletions
@@ -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');
}