Skip to content

[unic-pr-review] Pre-PR mode skeleton + code-reviewer aspect agent #145

@orioltf

Description

@orioltf

Parent

docs/issues/unic-pr-review/PRD.md

What to build

The first end-to-end review path: /unic-pr-review:review-pr invoked without a URL detects Pre-PR mode, computes the local diff against the resolved base branch, fans out to a single review-aspect sub-agent (code-reviewer), and renders Findings to the terminal grouped by Severity. No writes anywhere.

This slice also lands the load-bearing pure-function library used by every later slice — signature.mjs (footer renderer only — the parser comes in #re-review-detection), severity-bucketer.mjs, mode-detector.mjs, changed-file-analyser.mjs (minimal: always spawn code-reviewer), review-summary-renderer.mjs, inline-comment-renderer.mjs, notices.mjs.

Motto: get out of the models' way. The aspect agent is trusted to read the diff and emit structured Findings with no rule-table assistance. Renderers own template consistency.

Acceptance criteria

  • commands/review-pr.md exists. No URL argument → Pre-PR mode. With a URL, exits with "ADO mode not yet supported" (filled in by later slices).
  • Base-branch resolution chain (git symbolic-ref refs/remotes/origin/HEADdevelopmainmaster → hard error) is implemented and unit-tested.
  • agents/code-reviewer.md exists with a distinctive name + colour, embeds the Confidence-Score rubric (90-100 Critical, 80-89 Important, 60-79 Minor, <60 dropped), and emits Findings as JSON { severity, confidence, filePath, startLine, endLine, title, body, suggestion? } — no Bot Signature footer.
  • scripts/lib/signature.mjs exports a footer renderer that produces exactly 🤖 Reviewed by Claude Code — Iteration N (with trailing newlines per the PRD schema). The parser entry point is stubbed for now.
  • scripts/lib/severity-bucketer.mjs maps confidence 0–100 to one of critical / important / minor / dropped per the thresholds.
  • scripts/lib/mode-detector.mjs returns pre-pr / first-review / re-review / first-review-fallback from { hasUrl, hasPriorSignature, revisionsAvailable }. Table-driven.
  • scripts/lib/changed-file-analyser.mjs returns at minimum ['code-reviewer'] for any non-empty changed-files list.
  • scripts/lib/review-summary-renderer.mjs builds the exact Review Summary template from the PRD (Notices → Intent Check → 🔴 Critical → 🟠 Important → 🟡 Minor → ✅ What's good → footer via signature.mjs).
  • scripts/lib/inline-comment-renderer.mjs builds the Inline Comment template (severity emoji + title + prose + optional ```suggestion block + footer via signature.mjs).
  • Neither renderer inlines the literal footer string; both import the footer from scripts/lib/signature.mjs. The PRD schemas use the {BOT_SIGNATURE_FOOTER} placeholder to make this contract explicit — a renderer test asserts the footer in rendered output is byte-identical to signature.mjs's output.
  • Default run writes nothing — only prints the rendered preview to the terminal and exits 0.
  • Per-module unit tests cover signature, severity-bucketer, mode-detector, changed-file-analyser (single case), review-summary-renderer (with and without Intent Check / Notices), inline-comment-renderer.
  • Cross-platform CI is green.

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew capabilityfeature/unic-pr-reviewIssues from the unic-pr-review featureready-for-agentFully specified, ready for an AFK agent

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions