import { appendAutopilotLogEntry } from '../../../storage/autopilot-log-store.js';
import { hashProjectPath } from '../../../storage/base-store.js';
async function handler(ctx) {
    const { projectPath, projectId, specId } = ctx;
    if (!projectPath) {
        return;
    }
    const start = Date.now();
    try {
        const { generateSessionContext } = await import('../../session-context-generator.js');
        await generateSessionContext(projectPath, projectId);
    }
    catch (err) {
        const error = err instanceof Error ? err.message : String(err);
        void appendAutopilotLogEntry(hashProjectPath(projectPath), {
            specId,
            hookName: 'session-context',
            result: 'fail',
            error,
            timestamp: new Date().toISOString(),
            durationMs: Date.now() - start,
        });
        // Do NOT re-throw — cascade must continue with remaining hooks
    }
}
export const sessionContextHook = {
    id: 'session-context',
    triggers: [], // any status change + release_completed
    requiresProjectPath: true,
    label: 'Auto-regenerate planu/session-context.md on status transitions (SPEC-776)',
    handler,
};
//# sourceMappingURL=session-context.hook.js.map