How massdo/repomix-runner works
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: commands Commands · extension.ts Extension entry · core Core tests · configLoader.ts Config loader
Components 22
VS Code host
Extension runtime and UI integration inside the VS Code extension host.
- Extension entry · Top-level extension activation and wiring of commands, UI, logging, and notifications.
src/extension.ts - Commands · User-facing command handlers for running Repomix, bundle operations, and navigation.
src/commands - Bundle view · Custom REPOMIX view data and bundle presentation in VS Code.
src/core/bundles/bundleDataProvider.ts - Decorations · File decoration provider for bundle-related workspace files.
src/core/bundles/bundleFileDecorationProvider.ts - Temporary notice · Short-lived user notifications for command status and results.
src/shared/showTempNotification.ts
Core subsystems
Configuration, bundles, CLI adaptation, and file handling.
- Config loader · Loads extension and workspace configuration, including precedence boundaries.
src/config/configLoader.ts - Config schema · Defines the configuration shape consumed by the extension.
src/config/configSchema.ts - Cwd resolver · Resolves the effective working directory for runs.
src/config/getCwd.ts - Open files · Collects open workspace files used by run commands.
src/config/getOpenFiles.ts - Bundle manager · Central boundary for bundle metadata, persistence, and selection state.
src/core/bundles/bundleManager.ts - CLI flags · Translates extension state into Repomix CLI arguments and flags.
src/core/cli/cliFlagsBuilder.ts - Exec runner · Asynchronous execution wrapper for external commands.
src/shared/execPromisify.ts - File helpers · Shared filesystem helpers used across commands and core flows.
src/shared/files.ts - Logger · Centralized output and diagnostic logging support.
src/shared/logger.ts - Temp files · Manages temporary directories for run-time artifacts and staging.
src/core/files/tempDirManager.ts - Cleanup · Optional cleanup for generated output files.
src/core/files/cleanOutputFile.ts - Clipboard 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 · Command-level tests covering success and failure paths.
src/test/commands - Core tests · Tests for config, bundles, CLI flags, and file handling.
src/test/core - Workspace fixture · Realistic test workspace used for integration-style command and selection scenarios.
src/test/test-workspace - Extension tests · Extension entry-point tests and end-to-end wiring checks.
src/test/extension.test.ts
Other components
- Repomix CLI · External Repomix command-line tool executed by the extension.
Connections 32
- 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.