/** * * When peaks-prd's request artifact transitions to `handed-off`, this helper * extracts the `businessGoal` (first non-empty bullet under `## Goals` of the * PRD body) and fires `peaks best-practice-scan --project --intent ""` * as a fire-and-forget post-step. The PRD → handed-off transition is the * canonical moment when "businessGoal transitions to complete" (the prd state * machine's terminal state). * * Failure modes (all non-fatal — the prd → handed-off transition MUST NOT * block on BPS issues): * - Empty businessGoal → status: 'skipped-empty-goal' (no spawn) * - Artifact missing → status: 'skipped-artifact-missing' * - Peaks binary missing → status: 'skipped-artifact-missing' * - Spawn 'error' event → status: 'failed' (logged, not thrown) * - Spawn event timeout (5 s) → status: 'failed' (logged, not thrown) * - Spawn 'spawn' event → status: 'triggered' (resolved; child detached) * * Karpathy §1 (Think Before Coding): extracted from the QA verdict * `prd:handed-off` transition in `src/cli/commands/request-commands.ts` * is the canonical hook point — peaks-prd's contract in * `skills/bee/peaks-prd/SKILL.md` §"Step 2.5 sub-step" mandates this firing * BEFORE peaks-rd takes over. * * Karpathy §2 (Simplicity First): single spawn, no retry, no async queue. * Karpathy §3 (Surgical Changes): one new file, no other source files * touched (the call site wiring in request-commands.ts is the only other * edit; that is the "Pattern A: inline post-step" from the dispatch spec). */ export type BestPracticeTriggerStatus = 'triggered' | 'skipped-empty-goal' | 'skipped-artifact-missing' | 'failed'; export type BestPracticeTriggerResult = { readonly status: BestPracticeTriggerStatus; readonly businessGoal?: string; readonly pid?: number; readonly reason?: string; }; /** Extract the first non-empty bullet from the `## Goals` section of a PRD * body. Falls back to the `raw input (sanitized):` line at the top when * the Goals section is missing or empty. Returns null when no goal can * be derived (caller should treat as `skipped-empty-goal`). * * Pure function — exported separately so unit tests can target the * extraction logic without spawning child processes. */ export declare function extractBusinessGoal(prdBody: string): string | null; /** Fire-and-forget: invoke `peaks best-practice-scan --project * --intent ""`. Never throws — always resolves with a * BestPracticeTriggerResult envelope. The child is detached via `unref()` * on the 'spawn' event so the parent process is not blocked waiting for * the BPS scan to finish (the scan itself sleeps ~100 ms in the v1 * Context7 stub). * * `PEAKS_BEST_PRACTICE_STDIN` is forced to empty so the BPS catch-gate * auto-accepts the recommended option — auto-trigger is non-interactive * by design (no user at the prompt when prd → handed-off fires). */ export declare function triggerBestPracticeScan(opts: { readonly projectRoot: string; readonly sessionId: string; readonly requestId: string; }): Promise;