/** * PR miner (Part 2 idea #4 — PR/review-comment capture). * * Mines merged GitHub pull requests — title, description, and crucially the * REVIEW COMMENTS (where humans say "don't do X here", "we always Y", "this * broke prod last time") — into memory proposals via the same LLM extraction * contract as `dim mine --llm` and `dim harvest`. * * Uses the `gh` CLI (already authenticated on the developer's machine), so no * token handling here. Cursor-tracked by merge time; every proposal is * anchored to the PR's merge commit (COMMIT_REF) so verification can re-check * it, and carries the reviewer's verbatim words in the rationale. * * Proposals land in the review queue (source `pr-miner`) — never directly in * memory. */ import type { Proposal } from "../types.js"; import type { MemoryStore } from "../db/store.js"; export interface MinedPr { number: number; title: string; body: string; mergedAt: string; mergeCommitSha: string | null; headRefName: string; files: string[]; /** review comments + top-level reviews, oldest first */ comments: Array<{ author: string; path: string | null; body: string; }>; } export interface PrMineResult { scanned: number; proposed: Proposal[]; skippedDuplicates: number; provider: string | null; } /** True if the `gh` CLI is installed and authenticated for this repo's host. */ export declare function ghAvailable(repoRoot: string): boolean; /** List merged PRs (newest first), stopping at the cursor. */ export declare function listMergedPrs(repoRoot: string, sinceMergedAt: string | null, limit?: number): MinedPr[]; /** Fetch review comments (inline, with file paths) + review bodies for one PR. */ export declare function fetchPrComments(repoRoot: string, prNumber: number): MinedPr["comments"]; export declare const PR_EXTRACT_INSTRUCTIONS = "You are mining a merged GitHub pull request \u2014 its description and especially its REVIEW COMMENTS \u2014 for durable, project-specific knowledge worth remembering across AI coding sessions.\n\nReview comments are where senior engineers state the unwritten rules: \"we never call the DB from controllers\", \"this exact retry pattern caused the March outage\", \"always use the factory here\". Those are the claims to extract.\n\nRules:\n1. Most PRs contain NOTHING durable \u2014 routine reviews (\"nit\", \"LGTM\", style back-and-forth). Return zero claims for those. Do NOT invent.\n2. SYNTHESIZE falsifiable claims about the codebase \u2014 do not parrot the comment. Include the WHY when a reviewer gives one.\n3. Prefer claims grounded in review comments over the PR description; keep the reviewer's key phrase in the rationale.\n4. kinds: DECISION, CONVENTION, GOTCHA, FAILED_APPROACH, ARCHITECTURE, INVARIANT, GUARDRAIL (guardrail_level never|ask-first|always), SKILL, TODO_CONTEXT.\n5. Scope with the commented file paths; add \"static_check\" (cheap shell command, exit 0 iff true) when an honest one exists.\n6. 0\u20133 claims per PR. Zero is the common case.\n\nRespond with ONLY: {\"claims\":[{\"kind\":\"CONVENTION\",\"claim\":\"...\",\"paths\":[\"src/x\"],\"symbols\":[],\"guardrail_level\":null,\"rationale\":\"...\",\"static_check\":null}]}"; export declare function buildPrPrompt(pr: MinedPr): string; /** * Mine merged PRs since the cursor. Requires the `gh` CLI and an LLM * provider; returns provider:null when no provider is available (the CLI * explains how to get one — there is no regex fallback here because review * threads need synthesis, and `dim mine` already covers merge-commit bodies). */ export declare function minePrs(store: MemoryStore, repoRoot: string, opts?: { max?: number; all?: boolean; }): Promise;