Add three test cases for handleProgress:
- Callback is invoked with progress messages from pack()
- Async callback rejection is isolated (pack completes, error logged)
- Spinner still updates when callback throws synchronously
Also restore the outer try-catch for sync errors — Promise.resolve()
only catches async rejections, not synchronous throws from the
callback invocation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Run pack() directly in the main process instead of spawning a child
process via initTaskRunner. The child process startup cost (~250ms for
Node.js init + module re-loading) was pure overhead since the spinner
and pack ran in the same child process anyway.
This removes the defaultActionWorker indirection, the Bun-specific
ping/retry handshake, and the processConcurrency dependency from
defaultAction entirely.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract duplicated DefaultActionRunnerResult mock into
createMockDefaultActionResult() helper function
- Add missing REPOMIX_REMOTE_TRUST_CONFIG env var mention in ko, pt-br,
ru library usage docs for consistency with other languages
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the intermediate isRemote flag that inverted remoteTrustConfig
only to be re-inverted back to skipLocalConfig in defaultAction. Now
remoteAction computes skipLocalConfig directly, reducing the internal
flag chain from 3 concepts to 2 (remoteTrustConfig → skipLocalConfig).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move absolute path validation for --config to before repository
download/clone, avoiding wasted I/O on invalid input
- Consolidate duplicate findConfigFile calls in skipLocalConfig branch
into a single search with conditional handling
- Add test for relative --config rejection even with --remote-trust-config
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Relative --config paths in remote mode would resolve against the cloned
temp directory, potentially loading and executing malicious config files
(e.g., repomix.config.ts) from untrusted repositories.
Now rejects relative paths with a clear error message guiding users to
use absolute paths instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When using `repomix --remote <url>` or the MCP `pack_remote_repository` tool,
config files (repomix.config.ts/js) from the cloned repository were executed
via jiti, allowing a malicious repository to achieve arbitrary code execution
on the user's machine.
This commit skips all local config file loading when processing remote
repositories. The `isRemote` flag is propagated from remoteAction through
defaultAction to loadFileConfig, which skips local config auto-detection
and --config flag resolution. Global config and CLI options continue to
work normally.
Users who need to trust remote configs can do so in a future release via
an explicit opt-in flag (e.g., --trust-remote-config).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Vitest v4 changed how vi.fn() and vi.mock() work with class constructors.
Arrow functions in mockImplementation no longer work as constructors
when called with 'new' keyword.
Changes:
- Use regular function syntax instead of arrow functions for constructor mocks
- Use vi.hoisted() to define class mocks that can be used in vi.mock() factories
- Replace vi.fn().mockReturnValue() with vi.fn().mockImplementation() for class mocks
- Update mock instance retrieval to use vi.mocked().mock.results[0].value
Add a unified worker entry point that enables full bundling support by
allowing bundled files to spawn workers using themselves. This is a
prerequisite for bundling the website server to improve Cloud Run cold
start times.
Changes:
- Add src/shared/unifiedWorker.ts as single entry point for all workers
- Support both worker_threads and child_process runtimes
- Add REPOMIX_WORKER_TYPE env var for child_process worker type detection
- Add REPOMIX_WORKER_PATH env var for bundled environment worker path
- Add REPOMIX_WASM_DIR env var for WASM file location override
- Update processConcurrency.ts to use unified worker path
- Add debug logging (REPOMIX_DEBUG_WORKER=1) for worker troubleshooting
- Export unified worker handler from main index.ts
Note: This is work in progress. There's a known issue with child_process
runtime where nested worker pools (created inside a worker) may receive
incorrect REPOMIX_WORKER_TYPE environment variable, causing task routing
issues. Investigation ongoing.
The copySkillOutputToCurrentDirectory function was never actually used
because skills are written directly to their final destination via the
skillDir absolute path, not to the temp directory.
- Remove copySkillOutputToCurrentDirectory function
- Remove related tests
- Simplify the copy logic in runRemoteAction
- Remove unused skillLocation variable and imports
Adds a size-based output splitter via --split-output (kb/mb) and writes numbered parts without splitting within a top-level folder.
Also updates metrics aggregation for multi-part output and adds unit tests.
Add unit tests for the copySkillOutputToCurrentDirectory function:
- Copy .claude/skills directory when it exists
- Skip copy when directory does not exist
- Handle EPERM and EACCES permission errors
- Handle generic errors
Instead of creating separate variables and passing them through the task,
directly update cliOptions.skillName and cliOptions.skillDir. This simplifies
the code flow and removes redundant fields from DefaultActionTask interface.
When Personal Skills location is selected, the summary was showing
a relative path (.claude/skills/) instead of the actual path
(~/.claude/skills/). Now passes the computed skillDir to reportResults.
Add @clack/prompts-based selection for skill output location:
- Personal Skills (~/.claude/skills/) - default, available across all projects
- Project Skills (.claude/skills/) - shared with team via git
Features:
- Interactive prompt to choose skill location
- Overwrite confirmation when skill directory already exists
- Works with both local and remote repositories
Refactor and improve the skill generation feature based on code review:
- Split generateSkillOutput into generateSkillReferences and
generateSkillMdFromReferences to avoid double generation
- Add try-catch error handling to writeSkillOutput with proper
permission error messages
- Add unit tests for skillSectionGenerators (12 tests)
- Add validation tests for --skill-generate flag combinations
- Update createMockConfig to support skillGenerate and remoteUrl
Added unit tests for buildCliConfig function to cover --no-gitignore,
--no-dot-ignore, and --no-default-patterns flags. These tests ensure
proper handling of ignore configuration options and improve test coverage
to meet the 80% threshold.
This addresses the Codecov coverage gap where src/cli/actions/defaultAction.ts
lines 131-132 were not covered by tests.
Updated documentation for all supported languages to include:
- ignore.useDotIgnore configuration option
- --no-dot-ignore CLI flag
- .ignore file explanation and priority order
- Benefits of using .ignore file with ripgrep and ag tools
Also updated test files to include useDotIgnore in mock configs
to satisfy TypeScript type checking after adding the new
configuration option.
Languages updated:
- zh-cn (Simplified Chinese)
- zh-tw (Traditional Chinese)
- ko (Korean)
- vi (Vietnamese)
- id (Indonesian)
- hi (Hindi)
- fr (French)
- de (German)
- es (Spanish)
- pt-br (Brazilian Portuguese)
Implemented mandatory and recommended fixes from code review:
1. Fix timer cleanup in cliSpinner.test.ts
- Added vi.useRealTimers() to afterEach hook
- Prevents fake timers from bleeding into other test files
2. Fix isCancel mock in initAction.test.ts (3 locations)
- Changed from mockReturnValue(true) to mockImplementation
- Now properly tests only the actual cancel symbol
- More accurate test behavior for cancellation scenarios
3. Add DI pattern explanation comment in configLoad.ts
- Clarifies why dependency injection is used for jitiImport
- Documents the double instrumentation issue
- Helps future maintainers understand the design decision
When copying output files fails due to permission errors (EPERM/EACCES),
provide clear and actionable error messages that explain the issue and
offer specific solutions.
This commonly occurs when users run repomix from protected directories
like C:\Windows\System32 on Windows.
Fixes#868
When using the remote repository feature with an absolute path specified
for the output file, the previous implementation attempted to copy the file
even though source and target resolved to the same path. This resulted in
an error when trying to copy a file to itself.
This commit fixes the issue by:
- Checking if source and target paths are identical before copying
- Skipping the copy operation when they are the same
- This handles absolute paths and any other edge cases where paths resolve to the same location
The fix is implemented in copyOutputToCurrentDirectory function itself,
making it more robust and self-contained.
Fixes#873
Added override configuration to disable Biome's organizeImports feature
specifically for src/index.ts to allow manual import order management
while keeping automatic import organization enabled for other files.
- Remove unnecessary config parameter from PingTask interface for better performance
- Improve error serialization using util.inspect with safety limits
- Update function signatures to match simplified ping interface
- Add comprehensive error details formatting with depth and length limits
These changes address PR review comments and improve worker efficiency.
- Fix stdin processing tests to expect raw cwd path instead of resolved path
- Aligns test expectations with actual implementation where stdin uses [cwd] directly
- Resolves Windows CI failures where path.resolve() was incorrectly applied to stdin cases
- Maintains correct expectations for directory processing vs stdin processing paths
This fixes the remaining Windows CI test failures while preserving test accuracy.
- Import path module and use path.resolve() for all path assertions
- Fix failing tests on Windows CI by handling platform-specific path separators
- Ensure tests work correctly on both Unix and Windows systems
- Maintain test functionality while improving cross-platform compatibility
This resolves CI failures on Windows builds while preserving test coverage.
- Add tests for defaultActionWorker.ts covering ping, directory processing, stdin handling, error cases, and path resolution
- Add tests for calculateGitDiffMetrics.ts covering config validation, diff processing, error handling, and encoding
- Add tests for calculateGitLogMetrics.ts covering log processing, error scenarios, and edge cases
- All test files follow project conventions with proper mocking and type safety
- Total of 46 new tests ensuring robust coverage of worker functionality
These tests improve code coverage and provide safety net for future changes
to the metrics calculation and worker system components.
- Use class names for RepomixError type checking instead of hardcoded strings
- Remove unused RepomixError import from fileProcess.ts
- Simplify comments in errorHandle.ts and fileProcess.ts
- Clean up constructor-based error checking logic
Implemented a comprehensive worker process architecture that balances performance and isolation:
- Created defaultActionWorker.ts that runs entire CLI processing pipeline in child_process for better resource isolation
- Migrated all other worker implementations (fileProcess, security, metrics, etc.) from child_process to worker_threads for improved performance
- Enhanced logger.ts to support both worker_threads (via workerData) and child_process (via environment variables)
- Added color support for child_process workers by passing FORCE_COLOR and TERM environment variables
- Moved Spinner from main process to defaultActionWorker for direct stdout control
This hybrid approach provides the best of both worlds: the main CLI operation runs in isolated child_process for stability, while intensive parallel tasks use faster worker_threads for optimal performance.
Add new "Binary Files Detected" section to CLI output that shows files which were
skipped due to binary content detection (not extension-based). This addresses issue #752
where users were not informed about files being silently excluded.
Changes:
- Update fileRead.ts to return detailed skip reasons (binary-extension, binary-content, size-limit, encoding-error)
- Modify file collection pipeline to track and propagate skipped files
- Add reportSkippedFiles function to display binary-content detected files
- Show files with relative paths and helpful exclusion messages
- Only display section when binary-content files are found
- Add comprehensive test coverage for new functionality
The implementation follows existing security check reporting patterns and provides
users clear visibility into why files were excluded from output.
This feature allows users to include git log information in the output to help AI understand development patterns and file change relationships.
Key changes:
- Added --include-logs and --include-logs-count CLI options
- Default to 50 commits, configurable via CLI and config file
- Includes commit date, message, and changed file paths (excludes commit hashes)
- Added security checks and metrics calculation for git logs
- Updated output templates to include git logs section
- Comprehensive test coverage and TypeScript fixes
Resolves user request for including git commit history to provide development context for AI analysis.
- Move string-to-number parsing from defaultAction to Commander.js option parser
- Update CLI types to reflect Commander.js parsed values (boolean | number)
- Simplify buildCliConfig by removing redundant parsing logic
- Update tests to match new type expectations
This approach follows the same pattern as --top-files-len and centralizes
input validation at the CLI parsing level where it belongs.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
CLI options use string type for numeric values as they come from commander.js parsing.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add explicit radix 10 to Number.parseInt() for consistent parsing
- Add validation to throw error for non-numeric string inputs
- Export TreeNode interface to eliminate code duplication
- Remove unused rootDirs parameter from test helper
- Remove unused isLast parameter from displayNode function
- Simplify token count threshold handling in reporter
These changes address review feedback to improve robustness and maintainability.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Rename cliPrint.ts to cliReport.ts with all functions changed from print* to report*
- Move printResults from defaultAction to cliReport as reportResults for better organization
- Move reportTokenCountTree to cli/reporters/tokenCountTreeReporter.ts for cleaner separation
- Move test-only functions (buildTokenCountStructure, convertToOutput) from core module to test files
- Update all imports and test files to reflect new naming conventions
- Maintain all functionality while improving code organization and module cohesion
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Major restructuring of CLI options and tokenCountTree functionality:
CLI Options:
- Reorganized options into logical groups: "CLI Input/Output Options", "Repomix Output Options", and "File Selection Options"
- Moved --verbose, --quiet, --stdout, --stdin, --copy, --token-count-tree, --top-files-len to CLI I/O group
- Renamed --summarize-token-counts to --token-count-tree for clarity
- Updated README.md documentation to reflect new option organization
TokenCountTree Refactoring:
- Moved tokenCountTree functionality from saveTokenCounts.ts to cliPrint.ts as printTokenCountTree
- Deleted saveTokenCounts.ts (no longer needed)
- Removed handleTokenCountTree function from defaultAction.ts
- Integrated printTokenCountTree into printResults workflow for consistency
- Updated threshold calculation to be handled within printTokenCountTree
Configuration:
- Added tokenCountTree option to config schema with default value false
- Changed schema from z.union([z.boolean(), z.string()]) to z.union([z.boolean(), z.number()])
- CLI now converts string thresholds to numbers during buildCliConfig
Optimizations:
- Modified calculateMetrics to calculate all file tokens when tokenCountTree is enabled
- Prevents double token calculation for better performance
Display:
- Changed emoji from 📊 to 🔢 for Token Count Tree
- Updated title from "Token Count Summary" to "Token Count Tree"
Tests:
- Renamed and updated test files to match new structure
- Updated tests to work with new printTokenCountTree function signature
- All tests pass with new implementation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Move spinner initialization to runDefaultAction for shared usage across all operations
- Extract handleTokenCountSummary method from inline code for better modularity
- Remove unused cliOptions parameters from handleStdinProcessing and handleDirectoryProcessing
- Update test signatures to match new function parameters
- Enable spinner reuse in summarizeTokenCounts functionality
This refactoring improves code organization by centralizing spinner management
and separating token count summary logic into a dedicated method.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace manual config objects with createMockConfig() in test files
- Ensures consistency and automatic handling of new config properties
- Fixes truncateBase64 property linter errors
- Improves maintainability for future config schema changes
- Add optional predefinedFiles parameter to pack function for cleaner API
- Remove complex dependency injection override in defaultAction.ts
- Pass stdin file paths directly to pack function instead of using searchFiles override
- Update tests to match new function signatures and parameter expectations
- Simplify stdin processing workflow by eliminating intermediate filtering step
This approach is more explicit, maintainable, and easier to understand than
the previous dependency injection pattern for handling predefined file lists.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add predefinedFiles parameter to searchFiles function for stdin file processing
- Remove duplicate filterFileList function and consolidate logic
- Update defaultAction to use unified searchFiles instead of filterFileList
- Skip directory validation when using predefined files from stdin
- Update tests to reflect consolidated file filtering architecture
- Improve code maintainability by eliminating duplicate filtering logic
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>