mirror of
https://github.com/obra/superpowers.git
synced 2026-08-08 08:09:37 +00:00
a48a7e5b1b
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.
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
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');
|
|
}
|