# eliware/codescope architecture

> Architecture diagram of the GitHub repository eliware/codescope, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eliware/codescope
- Repository: https://github.com/eliware/codescope

## Overview

CodeScope is a read-only CLI for repository reviews, focused suggestions, and token/cost estimates. Users choose a profile or submit an ad hoc prompt; the CLI routes the request, gathers bounded repository evidence, frames it as untrusted input, and runs a provider-backed review or dry run before writing output. The graph preserves documented combined reviews, profiles, and pricing capabilities. Some internal links are omitted or marked unverified because their implementation was not excerpted; README-described behavior is cited where applicable.

Main entry points: [`src/cli/review-command.mjs`](https://github.com/eliware/codescope/blob/main/src/cli/review-command.mjs) (Command handlers), [`src/cli/profile-command.mjs`](https://github.com/eliware/codescope/blob/main/src/cli/profile-command.mjs) (Profile command), [`src/profiles/prompt-routing.mjs`](https://github.com/eliware/codescope/blob/main/src/profiles/prompt-routing.mjs) (Profile routing), [`src/review/run-review-pipeline.mjs`](https://github.com/eliware/codescope/blob/main/src/review/run-review-pipeline.mjs) (Review pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli["CLI entry and routing<br/>[main.mjs]"]
  node_commands["Command handlers<br/>[review-command.mjs]"]
  node_profilecmd["Profile command"]
  node_promptcmd["Prompt command<br/>[prompt-command.mjs]"]
  node_writer["Output writer<br/>[default-writer.mjs]"]
end

subgraph group_evidence["Evidence preparation"]
  node_discover["File discovery<br/>[files.mjs]"]
  node_combine["Evidence combination<br/>[all.mjs]"]
  node_verify["Verified file reads"]
  node_testspecs["Test specifications<br/>[test-specs.mjs]"]
end

subgraph group_review["Review and prompts"]
  node_profiles["Profile routing<br/>[prompt-routing.mjs]"]
  node_prompts["Review prompt sources<br/>[review.mjs]"]
  node_guidance["Review guidance"]
  node_tool["Structured review schema<br/>[review-tool.mjs]"]
  node_pipeline["Review pipeline"]
  node_attach["Evidence attachment"]
  node_result["Review result<br/>[review-result.mjs]"]
end

subgraph group_usage["Usage estimates"]
  node_pricing["Usage pricing<br/>[calculator.mjs]"]
  node_estimates["Dry-run estimates<br/>[dry-run.mjs]"]
end

node_user(("CLI user"))
node_provider{{"OpenAI service"}}

node_user -->|"submits command"| node_cli
node_cli -->|"dispatches"| node_commands
node_commands -->|"routes profiles"| node_profilecmd
node_commands -->|"routes prompts"| node_promptcmd
node_profilecmd -->|"selects prompt"| node_profiles
node_promptcmd -.->|"selects prompt"| node_profiles
node_profiles -->|"loads sources"| node_prompts
node_prompts -->|"builds schema"| node_tool
node_user -->|"supplies repository"| node_discover
node_discover -.->|"provides evidence"| node_combine
node_combine -.->|"includes test context"| node_testspecs
node_pipeline -.->|"attaches evidence"| node_attach
node_attach -->|"frames evidence"| node_guidance
node_pipeline -.->|"executes request"| node_provider
node_provider -->|"returns response"| node_result
node_result -.->|"writes result"| node_writer
node_profilecmd -->|"supports dry run"| node_estimates
node_estimates -.->|"estimates cost"| node_pricing
node_user -->|"requests estimate"| node_pricing

click node_cli "https://github.com/eliware/codescope/blob/main/src/cli/main.mjs"
click node_commands "https://github.com/eliware/codescope/blob/main/src/cli/review-command.mjs"
click node_profilecmd "https://github.com/eliware/codescope/blob/main/src/cli/profile-command.mjs"
click node_promptcmd "https://github.com/eliware/codescope/blob/main/src/cli/prompt-command.mjs"
click node_discover "https://github.com/eliware/codescope/blob/main/src/find/files.mjs"
click node_combine "https://github.com/eliware/codescope/blob/main/src/combine/all.mjs"
click node_verify "https://github.com/eliware/codescope/blob/main/src/combine/read-verified-file.mjs"
click node_testspecs "https://github.com/eliware/codescope/blob/main/src/combine/test-specs.mjs"
click node_profiles "https://github.com/eliware/codescope/blob/main/src/profiles/prompt-routing.mjs"
click node_prompts "https://github.com/eliware/codescope/blob/main/src/profiles/prompt-sources/review.mjs"
click node_guidance "https://github.com/eliware/codescope/blob/main/src/prompts/policy/review-guidance.mjs"
click node_tool "https://github.com/eliware/codescope/blob/main/src/prompts/review-tool.mjs"
click node_pipeline "https://github.com/eliware/codescope/blob/main/src/review/run-review-pipeline.mjs"
click node_attach "https://github.com/eliware/codescope/blob/main/src/review/request/attach-repository-evidence.mjs"
click node_result "https://github.com/eliware/codescope/blob/main/src/review/review-result.mjs"
click node_pricing "https://github.com/eliware/codescope/blob/main/src/pricing/calculator.mjs"
click node_estimates "https://github.com/eliware/codescope/blob/main/src/review/dry-run.mjs"
click node_writer "https://github.com/eliware/codescope/blob/main/src/cli/default-writer.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_commands,node_profilecmd,node_promptcmd,node_writer,node_user toneBlue
class node_discover,node_combine,node_verify,node_testspecs toneAmber
class node_profiles,node_prompts,node_guidance,node_tool,node_pipeline,node_attach,node_result toneMint
class node_pricing,node_estimates toneRose
class node_provider toneIndigo
```

## Components

### CLI workflow

- [CLI entry and routing](https://github.com/eliware/codescope/blob/main/src/cli/main.mjs): `src/cli/main.mjs`
- [Command handlers](https://github.com/eliware/codescope/blob/main/src/cli/review-command.mjs): `src/cli/review-command.mjs`
- [Profile command](https://github.com/eliware/codescope/blob/main/src/cli/profile-command.mjs): `src/cli/profile-command.mjs`
- [Prompt command](https://github.com/eliware/codescope/blob/main/src/cli/prompt-command.mjs): `src/cli/prompt-command.mjs`
- [Output writer](https://github.com/eliware/codescope/blob/main/src/cli/default-writer.mjs): `src/cli/default-writer.mjs`

### Evidence preparation

- [File discovery](https://github.com/eliware/codescope/blob/main/src/find/files.mjs): `src/find/files.mjs`
- [Evidence combination](https://github.com/eliware/codescope/blob/main/src/combine/all.mjs): `src/combine/all.mjs`
- [Verified file reads](https://github.com/eliware/codescope/blob/main/src/combine/read-verified-file.mjs): `src/combine/read-verified-file.mjs`
- [Test specifications](https://github.com/eliware/codescope/blob/main/src/combine/test-specs.mjs): `src/combine/test-specs.mjs`

### Review and prompts

- [Profile routing](https://github.com/eliware/codescope/blob/main/src/profiles/prompt-routing.mjs): `src/profiles/prompt-routing.mjs`
- [Review prompt sources](https://github.com/eliware/codescope/blob/main/src/profiles/prompt-sources/review.mjs): `src/profiles/prompt-sources/review.mjs`
- [Review guidance](https://github.com/eliware/codescope/blob/main/src/prompts/policy/review-guidance.mjs): `src/prompts/policy/review-guidance.mjs`
- [Structured review schema](https://github.com/eliware/codescope/blob/main/src/prompts/review-tool.mjs): `src/prompts/review-tool.mjs`
- [Review pipeline](https://github.com/eliware/codescope/blob/main/src/review/run-review-pipeline.mjs): `src/review/run-review-pipeline.mjs`
- [Evidence attachment](https://github.com/eliware/codescope/blob/main/src/review/request/attach-repository-evidence.mjs): `src/review/request/attach-repository-evidence.mjs`
- [Review result](https://github.com/eliware/codescope/blob/main/src/review/review-result.mjs): `src/review/review-result.mjs`

### Usage estimates

- [Usage pricing](https://github.com/eliware/codescope/blob/main/src/pricing/calculator.mjs): `src/pricing/calculator.mjs`
- [Dry-run estimates](https://github.com/eliware/codescope/blob/main/src/review/dry-run.mjs): `src/review/dry-run.mjs`

### Other components

- **CLI user**
- **OpenAI service**

## Connections

- CLI user → CLI entry and routing: submits command (evidence: `README.md`)
- CLI entry and routing → Command handlers: dispatches (evidence: `src/cli/main.mjs`)
- Command handlers → Profile command: routes profiles (evidence: `src/cli/review-command.mjs`)
- Command handlers → Prompt command: routes prompts (evidence: `src/cli/review-command.mjs`)
- Profile command → Profile routing: selects prompt (evidence: `src/cli/profile-command.mjs`)
- Prompt command → Profile routing: selects prompt
- Profile routing → Review prompt sources: loads sources (evidence: `src/profiles/prompt-routing.mjs`)
- Review prompt sources → Structured review schema: builds schema (evidence: `src/profiles/prompt-sources/review.mjs`)
- CLI user → File discovery: supplies repository (evidence: `README.md`)
- File discovery → Evidence combination: provides evidence
- Evidence combination → Test specifications: includes test context
- Review pipeline → Evidence attachment: attaches evidence
- Evidence attachment → Review guidance: frames evidence (evidence: `src/review/request/attach-repository-evidence.mjs`)
- Review pipeline → OpenAI service: executes request
- OpenAI service → Review result: returns response
- Review result → Output writer: writes result
- Profile command → Dry-run estimates: supports dry run (evidence: `README.md`)
- Dry-run estimates → Usage pricing: estimates cost
- CLI user → Usage pricing: requests estimate (evidence: `README.md`)
