import * as fs from 'fs';
import * as path from 'path';
/**
 * Load a role-specific fragment file from config/roles/{role}/fragments/{fragmentName}.md.
 * Returns null if the file doesn't exist.
 *
 * @param projectRoot - Project root path (where config/ lives)
 * @param role - Agent role (e.g. 'orchestrator')
 * @param fragmentName - Fragment file name without .md extension
 * @returns Fragment content string or null
 */
export function loadRoleFragment(projectRoot, role, fragmentName) {
    try {
        const fragmentPath = path.join(projectRoot, 'config', 'roles', role, 'fragments', `${fragmentName}.md`);
        if (fs.existsSync(fragmentPath)) {
            return fs.readFileSync(fragmentPath, 'utf-8');
        }
    }
    catch {
        // Fragment not found — fall back to inline content
    }
    return null;
}
/**
 * Estimate token count from a string.
 * Uses the rough heuristic of ~4 characters per token (suitable for English/code mix).
 *
 * @param text - Text to estimate tokens for
 * @returns Estimated token count
 */
export function estimateTokens(text) {
    if (!text)
        return 0;
    // ~4 chars per token is a reasonable estimate for English + code
    return Math.ceil(text.length / 4);
}
//# sourceMappingURL=prompt-module.interface.js.map