// engine/marketplace-fetcher/evolution-log.ts — SPEC-681: Append errors to planu/evolution-log.md
// Path convention: planu/evolution-log.md (NOT .planu/) — matches ttl-refresh.ts:96 and conventions-ttl.ts:27.
import { mkdir, appendFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
function logPath(projectPath) {
    // NOTE: planu/ (not .planu/) — same convention as ttl-refresh.ts:96 and conventions-ttl.ts:27
    return join(projectPath, 'planu', 'evolution-log.md');
}
// ---------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------
/**
 * Append an error line to planu/evolution-log.md with an ISO timestamp.
 * Creates the file/directory if it does not exist.
 * Never throws — logging failures are silently swallowed.
 */
export async function appendToEvolutionLog(projectPath, message) {
    const filePath = logPath(projectPath);
    try {
        await mkdir(dirname(filePath), { recursive: true });
        const timestamp = new Date().toISOString();
        const line = `\n[${timestamp}] ${message}`;
        await appendFile(filePath, line, 'utf-8');
    }
    catch {
        // Non-critical — never block the fetch pipeline on log failures
    }
}
//# sourceMappingURL=evolution-log.js.map