// src/engine/skill-adapter/command-rewriter.ts — SPEC-682: Regex-based command rewrites
// Pure functions — no I/O, no side effects.
/** Rewrite package manager commands in content.
 * Only rewrites word-boundary occurrences of 'npm' (default generic manager).
 * E.g. 'npm install' → 'pnpm install' when packageManager is 'pnpm'.
 */
export function rewritePackageManagerCommands(content, packageManager) {
    if (!packageManager || packageManager === 'npm') {
        return content;
    }
    // Replace 'npm' at word boundaries — avoids 'npmrc', 'snpm', etc.
    // We replace 'npm' only when it's used as a command (followed by space or end of line)
    return content.replace(/\bnpm\b/g, packageManager);
}
/** Rewrite test runner commands (jest → vitest, etc.).
 * Uses word-boundary regex to avoid corrupting identifiers like 'jestConfig'.
 * Only replaces jest when it appears as a standalone command reference.
 */
export function rewriteTestRunnerCommands(content, testCommand) {
    if (!testCommand) {
        return content;
    }
    // Detect if this project uses vitest
    const usesVitest = testCommand.includes('vitest');
    if (usesVitest) {
        // Replace word-boundary 'jest' occurrences (not inside identifiers like jestConfig)
        return content.replace(/\bjest\b/g, 'vitest');
    }
    return content;
}
//# sourceMappingURL=command-rewriter.js.map