# massdo/repomix-runner architecture

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

- Interactive diagram: https://gitdiagram.com/massdo/repomix-runner
- Repository: https://github.com/massdo/repomix-runner

## Overview

1. **Overall shape**
   - This is a **VS Code extension** written in TypeScript.
   - Its job is to orchestrate **Repomix** runs, not to implement packing itself. The extension shells out to the Repomix CLI, manages configuration, and presents results inside VS Code.

2. **Entry point and extension lifecycle**
   - `src/extension.ts` is the top-level activation module.
   - It wires together command registrations, bundle UI/data providers, file decorations, and shared services such as logging and temporary notifications.
   - The extension runs entirely in the **VS Code extension host** and depends on the `vscode` API for UI, workspace, and command integration.

3. **User-facing command layer**
   - `src/commands/*` contains one handler per command: run Repomix, run on open files, run on selected files, create/edit/delete/select bundles, open settings/output, and jump to config.
   - These command handlers form the main control surface from user action to execution.
   - Most commands delegate quickly into config, bundle, and core file/CLI utilities rather than doing heavy work themselves.

4. **Bundle subsystem**
   - `src/core/bundles/*` is the reusable-bundle model.
   - It manages bundle metadata, persistence, and presentation in the custom “REPOMIX” view.
   - `bundleManager.ts` is the central boundary for bundle lifecycle operations; `bundleDataProvider.ts` and `bundleFileDecorationProvider.ts` feed VS Code UI with bundle items and file decorations.
   - Bundles appear to be stored in the workspace under `.repomix/bundles.json`, based on the test workspace and README behavior.

5. **Configuration subsystem**
   - `src/config/*` handles extension settings and workspace config discovery.
   - `configLoader.ts` reads configuration, `configSchema.ts` defines the expected shape, `getCwd.ts` resolves the working directory, and `getOpenFiles.ts` identifies open files in the workspace.
   - The README indicates a workspace `repomix.config.json` can override extension settings, except for runner-related settings. That means configuration is a key precedence boundary between workspace defaults and extension defaults.

6. **CLI integration boundary**
   - `src/core/cli/cliFlagsBuilder.ts` translates extension state into flags for the Repomix CLI.
   - This is the most important adaptation layer between VS Code concepts like selected files, open files, bundles, and Repomix’s command-line interface.
   - The extension does not appear to call Repomix as a library; it assembles a CLI invocation and executes it externally.

7. **File/output handling**
   - `src/core/files/*` contains post-processing and user convenience operations.
   - `cleanOutputFile.ts` handles optional cleanup of generated output files.
   - `copyToClipboard.ts` supports the two copy modes described in the README: copying content or copying as a file.
   - `tempDirManager.ts` suggests temporary filesystem use during runs, likely to stage output or intermediate artifacts.

8. **Execution and shared utilities**
   - `src/shared/execPromisify.ts` is the process-execution abstraction used to run external commands asynchronously.
   - `src/shared/files.ts`, `logger.ts`, and `showTempNotification.ts` centralize cross-cutting concerns: filesystem helpers, output logging, and user feedback.
   - `src/commands/utils.ts` likely contains command-level shared logic to avoid duplication across handlers.

9. **Main data flow**
   - A user invokes a command from the command palette or the custom REPOMIX view.
   - The command handler gathers context: workspace root, selected/open files, or a chosen bundle.
   - Configuration and bundle metadata are loaded, merged, and converted into Repomix CLI flags.
   - Repomix is executed through the shell.
   - The generated output is optionally cleaned up, copied to clipboard, and shown via VS Code output/notifications.
   - Bundle/file view state is refreshed if needed.

10. **VS Code UI surfaces**
   - The extension has a custom “REPOMIX” view, an output channel, settings shortcut, and file decorations for bundle-related files.
   - These are presentation layers over the underlying config/bundle/execution subsystems, not independent business logic.
   - The architecture is therefore mostly **command-driven with lightweight UI state**.

11. **Platform and tooling constraints**
   - The README calls out that file-copy mode is platform-sensitive: supported on **macOS** and **Linux with xclip**.
   - Node.js/npm are required because the extension relies on `npx`/CLI execution.
   - The project is built/tested as a TypeScript extension, with `esbuild.js`, ESLint, Prettier, and a VS Code test setup.

12. **Testing architecture**
   - `src/test/*` mirrors the production layout, which makes subsystem boundaries explicit.
   - There are unit tests for commands, config, bundles, CLI flag building, file handling, and the extension entry point.
   - `src/test/test-workspace/*` provides an integration workspace with nested files and a sample `repomix.config.json`, showing the extension is tested against realistic workspace/file-selection scenarios.

13. **What to draw in an architecture diagram**
   - Center the diagram on the **VS Code extension host**.
   - Show separate boxes for **commands**, **configuration**, **bundle management**, **CLI flag building**, **external Repomix execution**, and **output/clipboard/file cleanup**.
   - Draw the strongest boundary between the extension and the **external Repomix CLI process**, since that is the main runtime dependency outside VS Code.

Main entry points: [`src/commands`](https://github.com/massdo/repomix-runner/tree/main/src/commands) (Commands), [`src/extension.ts`](https://github.com/massdo/repomix-runner/blob/main/src/extension.ts) (Extension entry), [`src/test/core`](https://github.com/massdo/repomix-runner/tree/main/src/test/core) (Core tests), [`src/config/configLoader.ts`](https://github.com/massdo/repomix-runner/blob/main/src/config/configLoader.ts) (Config loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["VS Code host"]
  node_n1["Extension entry<br/>activation<br/>[extension.ts]"]
  node_n2["Commands<br/>handlers"]
  node_n3["Bundle view<br/>tree provider"]
  node_n4["Decorations"]
  node_n17(("Temporary notice<br/>ui feedback"))
end

subgraph group_g2["Core subsystems"]
  node_n5["Config loader<br/>workspace config<br/>[configLoader.ts]"]
  node_n6["Config schema<br/>settings schema<br/>[configSchema.ts]"]
  node_n7["Cwd resolver<br/>workspace path<br/>[getCwd.ts]"]
  node_n8["Open files<br/>workspace selection<br/>[getOpenFiles.ts]"]
  node_n9[("Bundle manager<br/>bundle lifecycle<br/>[bundleManager.ts]")]
  node_n10["CLI flags<br/>adapter<br/>[cliFlagsBuilder.ts]"]
  node_n11["Exec runner<br/>process exec<br/>[execPromisify.ts]"]
  node_n12["File helpers<br/>filesystem utils<br/>[files.ts]"]
  node_n13["Logger<br/>logging<br/>[logger.ts]"]
  node_n14[("Temp files<br/>scratch space<br/>[tempDirManager.ts]")]
  node_n15["Cleanup<br/>post-process<br/>[cleanOutputFile.ts]"]
  node_n16["Clipboard copy<br/>output copy<br/>[copyToClipboard.ts]"]
end

subgraph group_g3["Test layout"]
  node_n19["Commands tests<br/>unit tests"]
  node_n20["Core tests<br/>unit tests"]
  node_n21[("Workspace fixture<br/>integration workspace")]
  node_n22["Extension tests<br/>integration tests<br/>[extension.test.ts]"]
end

node_n18{{"Repomix CLI<br/>external process"}}

node_n1 -->|"registers"| node_n2
node_n1 -->|"creates"| node_n3
node_n1 -->|"creates"| node_n4
node_n1 -->|"uses"| node_n13
node_n1 -->|"uses"| node_n17
node_n2 -->|"reads"| node_n5
node_n2 -->|"resolves"| node_n7
node_n2 -->|"collects"| node_n8
node_n2 -->|"mutates"| node_n9
node_n2 -->|"builds"| node_n10
node_n2 -->|"executes"| node_n11
node_n2 -->|"cleans"| node_n15
node_n2 -->|"copies"| node_n16
node_n3 -->|"reads"| node_n9
node_n4 -->|"reflects"| node_n9
node_n5 -->|"validates"| node_n6
node_n5 -->|"uses"| node_n8
node_n9 -->|"persists"| node_n12
node_n10 -->|"targets"| node_n18
node_n11 -->|"spawns"| node_n18
node_n14 -->|"depends on"| node_n12
node_n15 -->|"uses"| node_n12
node_n16 -->|"uses"| node_n12
node_n19 -.->|"covers"| node_n2
node_n20 -.->|"covers"| node_n5
node_n20 -.->|"covers"| node_n9
node_n20 -.->|"covers"| node_n10
node_n20 -.->|"covers"| node_n15
node_n20 -.->|"covers"| node_n16
node_n21 -.->|"exercises"| node_n8
node_n21 -.->|"exercises"| node_n5
node_n22 -.->|"covers"| node_n1

click node_n1 "https://github.com/massdo/repomix-runner/blob/main/src/extension.ts"
click node_n2 "https://github.com/massdo/repomix-runner/tree/main/src/commands"
click node_n3 "https://github.com/massdo/repomix-runner/blob/main/src/core/bundles/bundleDataProvider.ts"
click node_n4 "https://github.com/massdo/repomix-runner/blob/main/src/core/bundles/bundleFileDecorationProvider.ts"
click node_n5 "https://github.com/massdo/repomix-runner/blob/main/src/config/configLoader.ts"
click node_n6 "https://github.com/massdo/repomix-runner/blob/main/src/config/configSchema.ts"
click node_n7 "https://github.com/massdo/repomix-runner/blob/main/src/config/getCwd.ts"
click node_n8 "https://github.com/massdo/repomix-runner/blob/main/src/config/getOpenFiles.ts"
click node_n9 "https://github.com/massdo/repomix-runner/blob/main/src/core/bundles/bundleManager.ts"
click node_n10 "https://github.com/massdo/repomix-runner/blob/main/src/core/cli/cliFlagsBuilder.ts"
click node_n11 "https://github.com/massdo/repomix-runner/blob/main/src/shared/execPromisify.ts"
click node_n12 "https://github.com/massdo/repomix-runner/blob/main/src/shared/files.ts"
click node_n13 "https://github.com/massdo/repomix-runner/blob/main/src/shared/logger.ts"
click node_n14 "https://github.com/massdo/repomix-runner/blob/main/src/core/files/tempDirManager.ts"
click node_n15 "https://github.com/massdo/repomix-runner/blob/main/src/core/files/cleanOutputFile.ts"
click node_n16 "https://github.com/massdo/repomix-runner/blob/main/src/core/files/copyToClipboard.ts"
click node_n17 "https://github.com/massdo/repomix-runner/blob/main/src/shared/showTempNotification.ts"
click node_n19 "https://github.com/massdo/repomix-runner/tree/main/src/test/commands"
click node_n20 "https://github.com/massdo/repomix-runner/tree/main/src/test/core"
click node_n21 "https://github.com/massdo/repomix-runner/tree/main/src/test/test-workspace"
click node_n22 "https://github.com/massdo/repomix-runner/blob/main/src/test/extension.test.ts"

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_n1,node_n2,node_n3,node_n4,node_n17 toneBlue
class node_n5,node_n6,node_n7,node_n8,node_n9,node_n10,node_n11,node_n12,node_n13,node_n14,node_n15,node_n16 toneAmber
class node_n19,node_n20,node_n21,node_n22 toneMint
class node_n18 toneNeutral
```

## Components

### VS Code host

Extension runtime and UI integration inside the VS Code extension host.

- [Extension entry](https://github.com/massdo/repomix-runner/blob/main/src/extension.ts): activation · Top-level extension activation and wiring of commands, UI, logging, and notifications. · `src/extension.ts`
- [Commands](https://github.com/massdo/repomix-runner/tree/main/src/commands): handlers · User-facing command handlers for running Repomix, bundle operations, and navigation. · `src/commands`
- [Bundle view](https://github.com/massdo/repomix-runner/blob/main/src/core/bundles/bundleDataProvider.ts): tree provider · Custom REPOMIX view data and bundle presentation in VS Code. · `src/core/bundles/bundleDataProvider.ts`
- [Decorations](https://github.com/massdo/repomix-runner/blob/main/src/core/bundles/bundleFileDecorationProvider.ts): file decorations · File decoration provider for bundle-related workspace files. · `src/core/bundles/bundleFileDecorationProvider.ts`
- [Temporary notice](https://github.com/massdo/repomix-runner/blob/main/src/shared/showTempNotification.ts): ui feedback · Short-lived user notifications for command status and results. · `src/shared/showTempNotification.ts`

### Core subsystems

Configuration, bundles, CLI adaptation, and file handling.

- [Config loader](https://github.com/massdo/repomix-runner/blob/main/src/config/configLoader.ts): workspace config · Loads extension and workspace configuration, including precedence boundaries. · `src/config/configLoader.ts`
- [Config schema](https://github.com/massdo/repomix-runner/blob/main/src/config/configSchema.ts): settings schema · Defines the configuration shape consumed by the extension. · `src/config/configSchema.ts`
- [Cwd resolver](https://github.com/massdo/repomix-runner/blob/main/src/config/getCwd.ts): workspace path · Resolves the effective working directory for runs. · `src/config/getCwd.ts`
- [Open files](https://github.com/massdo/repomix-runner/blob/main/src/config/getOpenFiles.ts): workspace selection · Collects open workspace files used by run commands. · `src/config/getOpenFiles.ts`
- [Bundle manager](https://github.com/massdo/repomix-runner/blob/main/src/core/bundles/bundleManager.ts): bundle lifecycle · Central boundary for bundle metadata, persistence, and selection state. · `src/core/bundles/bundleManager.ts`
- [CLI flags](https://github.com/massdo/repomix-runner/blob/main/src/core/cli/cliFlagsBuilder.ts): adapter · Translates extension state into Repomix CLI arguments and flags. · `src/core/cli/cliFlagsBuilder.ts`
- [Exec runner](https://github.com/massdo/repomix-runner/blob/main/src/shared/execPromisify.ts): process exec · Asynchronous execution wrapper for external commands. · `src/shared/execPromisify.ts`
- [File helpers](https://github.com/massdo/repomix-runner/blob/main/src/shared/files.ts): filesystem utils · Shared filesystem helpers used across commands and core flows. · `src/shared/files.ts`
- [Logger](https://github.com/massdo/repomix-runner/blob/main/src/shared/logger.ts): logging · Centralized output and diagnostic logging support. · `src/shared/logger.ts`
- [Temp files](https://github.com/massdo/repomix-runner/blob/main/src/core/files/tempDirManager.ts): scratch space · Manages temporary directories for run-time artifacts and staging. · `src/core/files/tempDirManager.ts`
- [Cleanup](https://github.com/massdo/repomix-runner/blob/main/src/core/files/cleanOutputFile.ts): post-process · Optional cleanup for generated output files. · `src/core/files/cleanOutputFile.ts`
- [Clipboard copy](https://github.com/massdo/repomix-runner/blob/main/src/core/files/copyToClipboard.ts): output copy · Supports copying generated output as text or as a file. · `src/core/files/copyToClipboard.ts`

### Test layout

Mirrors the production subsystems for unit and integration coverage.

- [Commands tests](https://github.com/massdo/repomix-runner/tree/main/src/test/commands): unit tests · Command-level tests covering success and failure paths. · `src/test/commands`
- [Core tests](https://github.com/massdo/repomix-runner/tree/main/src/test/core): unit tests · Tests for config, bundles, CLI flags, and file handling. · `src/test/core`
- [Workspace fixture](https://github.com/massdo/repomix-runner/tree/main/src/test/test-workspace): integration workspace · Realistic test workspace used for integration-style command and selection scenarios. · `src/test/test-workspace`
- [Extension tests](https://github.com/massdo/repomix-runner/blob/main/src/test/extension.test.ts): integration tests · Extension entry-point tests and end-to-end wiring checks. · `src/test/extension.test.ts`

### Other components

- **Repomix CLI**: external process · External Repomix command-line tool executed by the extension.

## Connections

- Extension entry → Commands: registers · Activation wires the command surface.
- Extension entry → Bundle view: creates · Activation sets up the custom bundle view.
- Extension entry → Decorations: creates · Activation installs file decorations.
- Extension entry → Logger: uses · Activation shares the logger across subsystems.
- Extension entry → Temporary notice: uses · Activation and commands surface temporary notifications.
- Commands → Config loader: reads · Commands load configuration before running.
- Commands → Cwd resolver: resolves · Commands determine the effective workspace root.
- Commands → Open files: collects · Open-file commands gather the active file set.
- Commands → Bundle manager: mutates · Bundle commands create, edit, delete, and select bundles.
- Commands → CLI flags: builds · Run commands convert context into CLI flags.
- Commands → Exec runner: executes · Commands launch the external process through the exec wrapper.
- Commands → Cleanup: cleans · Run flows may post-process generated files.
- Commands → Clipboard copy: copies · Run flows support clipboard output modes.
- Bundle view → Bundle manager: reads · The bundle view reflects bundle state from the manager.
- Decorations → Bundle manager: reflects · Decorations are derived from bundle metadata.
- Config loader → Config schema: validates · Configuration loading relies on the schema.
- Config loader → Open files: uses · Config loading can incorporate open-file context.
- Bundle manager → File helpers: persists · Bundle lifecycle relies on filesystem helpers for storage.
- CLI flags → Repomix CLI: targets · Flag assembly prepares the external CLI invocation.
- Exec runner → Repomix CLI: spawns · The extension runs Repomix as an external process.
- Temp files → File helpers: depends on · Temporary directory handling uses filesystem helpers.
- Cleanup → File helpers: uses · Output cleanup operates on generated files.
- Clipboard copy → File helpers: uses · Clipboard/file copy behavior depends on filesystem helpers.
- Commands tests → Commands: covers · Tests exercise command handlers.
- Core tests → Config loader: covers · Tests exercise configuration loading.
- Core tests → Bundle manager: covers · Tests exercise bundle lifecycle behavior.
- Core tests → CLI flags: covers · Tests exercise CLI flag generation.
- Core tests → Cleanup: covers · Tests exercise file cleanup behavior.
- Core tests → Clipboard copy: covers · Tests exercise clipboard copy behavior.
- Workspace fixture → Open files: exercises · The fixture workspace supports open-file and selection scenarios.
- Workspace fixture → Config loader: exercises · The fixture includes workspace configuration.
- Extension tests → Extension entry: covers · Extension tests validate top-level wiring.
