Open Code Review (OCR) — Scan agent

docs / modules / scan

← all docs

Open Code Review (OCR) — Scan agent

flowchart LR IN["Input\nscan.Args (repo dir, optional --path, ScanTemplate)"] --> ACT["Scan agent\nRuns ocr scan: review whole files (no git diff needed) — for auditing unfamiliar code or directories without a meaningful diff."] ACT --> OUT["Output\n[]model.LlmComment for whole files + an optional project-level Markdown summary"]

Runs ocr scan: review whole files (no git diff needed) — for auditing unfamiliar code or directories without a meaningful diff. Package: internal/scan/.

What flows through it

flowchart LR IN["scan.Args (repo dir, optional --path, ScanTemplate)"] --> MOD["Scan agent"] MOD --> OUT["[]model.LlmComment for whole files + an optional project-level Markdown summary"]

Technical details

Package: internal/scan/ Depends on: config_rules, llmloop, tool, session, llm, agent Depended on by: CLI

What actually happens here

scan.Agent enumerates files under RepoDir or --path into []model.ScanItem (whole file content, not a diff), then reuses the exact same llmloop.Runner the review agent uses (toLoopTemplate maps ScanTemplate onto the loop's template.Template fields). Adds two phases review mode doesn't have: an optional per-batch DEDUP_TASK and a post-run PROJECT_SUMMARY_TASK, both individually disableable via --no-dedup/--no-summary.

How the LLM / model version is chosen

Same Args.Model/Provider pattern as review — one model for the whole run, set by the CLI from the resolved endpoint.

Deterministic (non-LLM) work in this module

File enumeration and size filtering (MaxFileSizeBytes, default 2 MiB), toLoopTemplate's field mapping, and dispatch/budget gating mirror agent's — AI involvement is the plan phase, main loop, dedup task and project-summary task, each individually toggleable.


Part of the module docs index. Full interactive version, with every module side by side: architecture.html §7. Cross-cutting mechanisms this module participates in (retry, compression, manifest, resume, hashing): LLD.