/** * Everything-Claude-Code (ECC) code-review bridge — adapter that * takes the ECC `code-review` agent's structured envelope * (`{ passed, violations[], gateAction }`) and renders it into the * `rd/code-review.md` markdown format that `peaks request transition` * Gate B3 already reads (`mustContain: ['## Findings', 'CRITICAL']`). * * Companion to `ocr-service.ts`: ECC is the in-skill agent option * (uses peaks-cli's own Agent tool surface), ocr is the external * subprocess option. Both produce a second-opinion code review that * the parent RD loop aggregates alongside its own inline review. * * === Why a bridge (not a direct swap) === * * `peaks-rd/references/parallel-review-fanout.md` sub-agent 1 has a * hard contract: write `rd/code-review.md` with sections * `Summary / Findings / Required Fixes / Recommended / Verdict`. * The CLI gate at `rd:qa-handoff` enforces `mustContain: ['## Findings', * 'CRITICAL']` and refuses the transition otherwise. ECC's structured * envelope does not match that shape — it returns `{ passed, violations, * gateAction }`. Hence the bridge: render the envelope into the * canonical markdown shape, so ECC and the legacy inline reviewer * share the same downstream contract. * * === Why no `peaksConfig.ecc.*` block === * * ECC is shipped via the `everything-claude-code` plugin, not as a * separate npm package. The user installs the plugin (a one-time * marketplace step); peaks-cli does not write or read any LLM * endpoint config for ECC. If a future ECC release needs user- * managed config (URL / token / model), add a `peaksConfig.ecc.*` * block then — not speculatively now. * * === Source: peaks-rd/references/parallel-review-fanout.md === * * Sub-agent 1 contract (Tier 7 v2.11.0): the parent RD loop calls * `Agent({ subagent_type: 'everything-claude-code:code-review', ... })` * with the diff + handoff in scope, receives the structured envelope, * then runs `adaptEccEnvelopeToRdCodeReview(env, { rid, generatedAt })` * and writes the resulting body to * `.peaks/_runtime//rd/code-review.md`. */ export type EccViolationKind = 'correctness' | 'type-safety' | 'error-handling' | 'mutation' | 'file-size' | 'naming' | 'dead-code' | 'regression' | 'contract-drift' | 'other'; export interface EccViolation { readonly kind: string; readonly line: number; readonly snippet: string; readonly hint: string; } export type EccGateAction = 'pass' | 'warn' | 'block'; export interface EccEnvelope { readonly passed: boolean; readonly violations: ReadonlyArray; readonly gateAction: EccGateAction; } /** * 5-state detect result — mirrors `ocr-service.ts` `OcrDetectState` * (ready / package-missing / binary-missing / config-missing / * detection-failed). ECC's analogue: * - `ready` — ECC plugin is installed and reachable * - `plugin-missing` — `everything-claude-code` not in skill list * - `agent-missing` — plugin present but `code-review` agent absent * - `dispatch-failed` — Agent tool call threw before returning envelope * - `envelope-malformed` — returned value failed `isEccEnvelope` validation * * The caller (peaks-rd's sub-agent 1 contract) inspects `state` and * either proceeds with the envelope or records a degradation note in * the request artifact body (`code-review-ecc-degraded-to-inline`). */ export type EccDetectState = 'ready' | 'plugin-missing' | 'agent-missing' | 'dispatch-failed' | 'envelope-malformed'; export interface EccDetectResult { readonly state: EccDetectState; readonly pluginInstalled: boolean; readonly agentAvailable: boolean; readonly warnings: readonly string[]; readonly nextActions: readonly string[]; } export type RdCodeReviewVerdict = 'pass' | 'warn' | 'block'; export interface RdCodeReviewDoc { /** Full markdown body, ready to write to `rd/code-review.md`. */ readonly body: string; /** Mirror of `gateAction` for the parent RD loop to log/aggregate. */ readonly verdict: RdCodeReviewVerdict; /** Counts per severity bucket — populated only when violations exist. */ readonly counts: { readonly total: number; readonly byKind: Readonly>; }; } /** * Validate a raw value as an EccEnvelope. Accepts the strict shape * only — extra fields are tolerated (forward-compat for ECC adding * new top-level keys), but missing/typed-wrong fields reject. * * Defensive on purpose: ECC is external code, and a malformed envelope * must not propagate into `rd/code-review.md` (would corrupt Gate B3). */ export declare function isEccEnvelope(value: unknown): value is EccEnvelope; /** * Render an ECC envelope to the canonical `rd/code-review.md` shape. * Verdict → sections: * - `pass` → Summary + Findings (empty) + Verdict: pass * - `warn` → Summary + Findings + Required Fixes + Recommended + Verdict: warn * - `block` → Summary + Findings + Required Fixes + Recommended + Verdict: block * + the `CRITICAL: ` marker that Gate B3's * `mustContain: ['## Findings', 'CRITICAL']` requires */ export declare function adaptEccEnvelopeToRdCodeReview(env: EccEnvelope, opts: { rid: string; generatedAt: string; }): RdCodeReviewDoc; /** * 5-state detector — mirrors `detectOcr`'s shape (state enum + warnings * + nextActions). The caller passes in the result of its own probe: * * - `pluginInstalled`: did the skill list scan find `everything-claude-code`? * - `agentAvailable`: did the Agent tool say `code-review` is registered? * - `dispatchError`: optional — the Agent tool threw before returning. * - `envelope`: optional — what came back (if anything). * * The detector never blocks: when state !== `ready`, the parent RD * loop records a `code-review-ecc-degraded-to-inline` note and falls * back to inline review. This matches `detectOcr`'s soft-fail policy. */ export declare function detectEcc(input: { readonly pluginInstalled: boolean; readonly agentAvailable: boolean; readonly dispatchError?: unknown; readonly envelope?: unknown; }): EccDetectResult; /** * Convenience: run `detectEcc` and `adaptEccEnvelopeToRdCodeReview` * in one call. The parent RD loop calls this after the Agent tool * returns. When `detectEcc` returns state !== 'ready', the caller * should NOT call `adaptEccEnvelopeToRdCodeReview` — fall back to * inline review instead. */ export declare function runEccCodeReview(input: { readonly rid: string; readonly generatedAt: string; readonly pluginInstalled: boolean; readonly agentAvailable: boolean; readonly dispatchError?: unknown; readonly envelope?: unknown; }): { detect: EccDetectResult; doc: RdCodeReviewDoc | null; };