import path from 'node:path'; /** * Sovereign Path Utility * Ensures all paths are resolved relative to the environment-root, * preventing hardcoded absolute path failures. */ const PROJECT_ROOT = process.cwd(); export function resolvePath(...segments: string[]): string { // If the first segment is already an absolute path based on the root, we don't double resolve if (segments[0] && (segments[0].startsWith('/') || segments[0].match(/^[a-zA-Z]:\\/))) { return path.normalize(segments[0]); } return path.resolve(PROJECT_ROOT, ...segments); } export function getRelativePath(absolutePath: string): string { return path.relative(PROJECT_ROOT, absolutePath); } export function isCrossPlatformPath(p: string): boolean { return !p.includes('\\') || path.sep === '\\'; } export const Paths = { root: PROJECT_ROOT, tools: resolvePath('Tools'), wrench: resolvePath('Tools', 'Wrench'), utils: resolvePath('Tools', 'utils'), config: resolvePath('Tools', 'config'), storage: resolvePath('Tools', 'storage'), // Dedicated storage dir };