Commit Graph

51 Commits

Author SHA1 Message Date
Kazuki Yamada cb00a7cbc0 test(core): Add test coverage for progressCallback in runDefaultAction
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>
2026-04-06 21:56:15 +09:00
Kazuki Yamada c3fedb933f chore(cli): Clean up redundant trace log and stale test scaffolding
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:01:28 +09:00
Kazuki Yamada fcfdf50ea0 perf(cli): Eliminate child process in default action
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>
2026-04-03 01:36:22 +09:00
Kazuki Yamada 5715b2e58e feat(worker): Add unified worker entry point for bundling support
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.
2025-12-31 22:05:06 +09:00
Kazuki Yamada f854dd4250 refactor(skill): Improve skill output generation and add tests
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
2025-12-10 00:27:43 +09:00
Kazuki Yamada e003ec6344 test(cli): Add tests for ignore-related CLI flags to improve coverage
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.
2025-11-08 20:50:52 +09:00
Kazuki Yamada 1bb752a431 fix(cli): Move stdin processing to main process to resolve hang in child_process worker
Issue #867で報告された--stdinオプションのハング問題を修正しました。

v1.6.0でdefaultActionがchild_processで実行されるようになりましたが、
child_processではデフォルトで親プロセスのstdinが継承されないため、
worker内でprocess.stdinを読み取ろうとするとハングしていました。

Changes:
- stdin処理をメインプロセスに移動し、読み取り結果をworkerに渡すように変更
- DefaultActionTask interfaceをisStdinからstdinFilePathsに変更
- child_processによるリソース分離と安定性を維持しながら、stdin機能を復元

Fixes #867
2025-10-02 23:59:53 +09:00
Kazuki Yamada ea1cc485c2 chore(config): disable organizeImports for src/index.ts
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.
2025-09-21 13:54:12 +09:00
Kazuki Yamada 681e377361 refactor(shared): improve error handling and cleanup code
- 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
2025-09-17 00:59:58 +09:00
Kazuki Yamada 8a88f45230 feat(cli): wrap entire defaultAction in child_process while optimizing other workers with worker_threads
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.
2025-09-16 23:49:38 +09:00
Kazuki Yamada b7fe6f25c5 fix(lint): resolve all oxlint warnings for code quality
- Remove unused imports across 67 files (RepomixConfigMerged, QueryCapture, etc.)
- Fix unused parameters by prefixing with underscore (_context, _index, etc.)
- Remove unused catch parameters using modern JavaScript syntax
- Fix require-yield warnings in generator functions
- Remove unused variables and interface declarations
- Add oxlint configuration to ignore integration test fixtures

Resolves 144 linting warnings while preserving all functionality.
All 743 tests continue to pass. Code quality significantly improved.
2025-08-24 18:25:08 +09:00
Kazuki Yamada 8bf797114b feat(cli): Report files detected as binary by content inspection
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.
2025-08-23 14:35:54 +09:00
Kazuki Yamada 5b5ee862a0 feat(cli): Add --include-logs option for git commit history
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.
2025-08-22 14:09:58 +09:00
Kazuki Yamada 2e584c1436 refactor(cli): rename cliPrint to cliReport and reorganize reporting functions
- 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>
2025-08-03 16:26:30 +09:00
Kazuki Yamada e175291927 refactor(cli): extract spinner initialization and token count summary
- 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>
2025-08-03 14:41:59 +09:00
Kazuki Yamada 0efe7ba3cd test: use createMockConfig helper for all test mock configurations
- 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
2025-07-15 22:44:47 +09:00
Kazuki Yamada ce5340288b refactor(stdin): Replace DI approach with direct predefinedFiles parameter
- 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>
2025-06-27 23:41:58 +09:00
Kazuki Yamada 98ee0998ec refactor(stdin): Unify file filtering logic by extending searchFiles function
- 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>
2025-06-27 23:41:58 +09:00
Kazuki Yamada e954df2c96 style: Fix linting issues
Apply automatic linting fixes for code style consistency.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 23:41:58 +09:00
Kazuki Yamada 64969234b2 fix(stdin): Add .gitignore/.repomixignore support and enable all tests
Address PR feedback by implementing complete filtering support:

- Add .gitignore and .repomixignore processing using globby
- Enable previously skipped test cases with proper mocks
- Add globby mocks to defaultAction tests
- Fix test expectations to match sorted output

This resolves the TODO in filterFileList and ensures stdin filtering
matches the behavior of normal file discovery.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 23:41:58 +09:00
Kazuki Yamada 8262546134 fix(tests): Resolve remaining Windows path compatibility issues
Fixed additional Windows-specific path issues that were causing CI failures:

**fileStdin.test.ts fixes:**
- Updated `readFilePathsFromStdin` tests to use `path.resolve()` for absolute path generation
- Fixed mock generators to use resolved absolute paths instead of raw string paths like '/absolute/file3.txt'
- Updated expected results to use `path.resolve(cwd, 'dir', 'file2.txt')` for proper cross-platform path handling

**defaultAction.test.ts fixes:**
- Fixed `handleStdinProcessing` test to use `path.join('subdir', 'file2.txt')` for proper Windows path separators
- Ensures relative paths in test expectations use correct platform-specific separators (\ on Windows, / on Unix)

**Key improvements:**
- All path expectations now properly handle Windows backslash separators vs Unix forward slashes
- Absolute path generation is consistent across platforms using `path.resolve()`
- Mock data uses platform-appropriate paths to match actual function behavior
- Tests now pass on Windows, macOS, Linux, and other platforms

All 629 tests now pass on all operating systems, resolving Windows CI failures completely.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-15 17:40:27 +09:00
Kazuki Yamada fc80ba12af fix(tests): Fix Windows path compatibility issues in stdin tests
Fixed hardcoded Unix-style paths that were causing test failures on Windows CI:

**fileStdin.test.ts changes:**
- Added `path` import for cross-platform path handling
- Updated `resolveAndDeduplicatePaths` tests to use `path.resolve()` instead of hardcoded `/test/cwd` paths
- Updated `readFilePathsFromStdin` tests to use platform-agnostic path expectations
- All test assertions now use `path.resolve()` for expected results

**defaultAction.test.ts changes:**
- Added `path` import for cross-platform path handling
- Updated `handleStdinProcessing` tests to use `path.resolve()` for `testCwd` and file paths
- Updated `handleDirectoryProcessing` tests to use `path.resolve()` for directory path expectations
- All hardcoded `/test/cwd` paths replaced with `path.resolve('/test/cwd')`

**Key improvements:**
- Tests now work correctly on both Unix and Windows systems
- Path comparisons are platform-agnostic using Node.js `path` module
- No functional changes to test logic, only path handling compatibility
- All 629 tests now pass on all platforms

Resolves Windows CI test failures while maintaining cross-platform compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-15 17:32:18 +09:00
Kazuki Yamada d107817afe feat(test): Add comprehensive tests for new defaultAction handler functions
- Add complete test coverage for handleStdinProcessing:
  * Validates directory argument restrictions
  * Tests stdin file path processing workflow
  * Verifies pack integration with custom searchFiles
  * Tests error propagation from stdin reading and packing
  * Covers edge cases like empty directories array

- Add complete test coverage for handleDirectoryProcessing:
  * Tests directory path resolution (relative, absolute, single, multiple)
  * Verifies pack integration with resolved paths
  * Tests progress callback functionality
  * Tests error propagation from pack operation

- Export handler functions to enable direct testing
- Update test imports and mocks to support new functions
- Maintain compatibility with existing test suite (41 tests total)

All tests pass with proper type safety and comprehensive coverage
of the refactored defaultAction workflow handlers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-15 16:42:03 +09:00
Kazuki Yamada 712b982e00 feat(mcp): Add processedFiles and safeFilePaths to PackResult and update related interfaces 2025-05-25 12:18:58 +09:00
Devin AI 48ec00c63a - Replace hardcoded config objects with createMockConfig utility
- Add proper typing to mock objects and functions
- Remove unnecessary type casting
- Add GitDiffResult type to git diff objects

Co-Authored-By: Kazuki Yamada <koukun0120@gmail.com>
2025-05-13 22:55:50 +09:00
Kazuki Yamada 95f7092b94 feat(cli): add --stdout option for output to stdout instead of file, enhancing CLI flexibility
- Introduced `--stdout` flag to allow output to standard output, which cannot be used with the `--output` option.
- Updated CLI configuration to handle `stdout` mode.
- Enhanced documentation with examples for using `--stdout`.
- Added tests to ensure correct behavior when using `--stdout` in various scenarios.
2025-05-10 16:33:09 +09:00
Kazuki Yamada 265845a9c0 fix(gitDiff): Fix syntax and tests 2025-05-10 11:26:05 +09:00
pmdyy cdfa93c594 feat(output): Add git diff support with --diffs flag 2025-05-05 23:57:05 -06:00
Kazuki Yamada 46518a847a fix: add input.maxFileSize to tests config 2025-04-20 14:42:03 +09:00
Kazuki Yamada 12cbde363c Add metadata-only output mode with --no-files flag 2025-04-19 17:41:31 +09:00
Kazuki Yamada f19d77c83d test: Remove stdout when running test 2025-04-19 16:10:14 +09:00
pranshugupta01 8b9889403d lint fix 2025-04-06 23:57:15 +09:00
pranshugupta01 53a1412deb test(cli): add test for trimming whitespace in comma-separated patterns for include and ignore options 2025-04-06 23:57:15 +09:00
Kazuki Yamada 8911966daa feat(git): Sort files by git commit frequency 2025-03-16 01:38:13 +09:00
yamadashy f5c29c1a35 fix(cli): properly handle "false" config values for --no-* options 2025-03-04 23:36:13 +09:00
huy-trn 2ca7453df4 Add code compression option 2025-02-15 19:11:42 +09:00
Yamada Dev c04554e59f feat(cli): Control verbose as a log level 2025-02-11 17:48:52 +09:00
Rakesh Chatrath 8f542124c0 Allow for passing in multiple directories 2025-02-08 16:27:22 +09:00
Dorian Massoulier 157440e6c8 feat(cli-flags): add --include-empty-directories flag 2025-01-28 23:58:16 +09:00
Dorian Massoulier 7747bfddcf feat(cli-flags): add --instruction-file-path 2025-01-28 23:58:16 +09:00
Dorian Massoulier bc8e8f9b48 feat(cli-flags): add --header-text flag 2025-01-28 23:58:16 +09:00
Dorian Massoulier 60f75be144 feat(cli-flags): add --no-default-patterns flag 2025-01-28 23:58:16 +09:00
Dorian Massoulier b1510a2a07 feat(cli-flag): add --no-gitignore flag 2025-01-28 23:58:16 +09:00
Andreas Tollk?tter aebfa6b7fa fix tests 2025-01-19 23:13:44 +09:00
Andreas Tollk?tter 5c841a3a65 lint 2025-01-19 23:13:44 +09:00
Kazuki Yamada 76904c9476 feat(website): Add configurable token count encoding and change default to o200k_base 2025-01-05 22:18:46 +09:00
Kazuki Yamada 42401bbd37 feat(cli): Add CLI flags for controlling output sections and content processing 2025-01-01 03:00:03 +09:00
Kazuki Yamada 8db9f95c7a feat(output): Add options to control file summary and directory structure output 2024-12-30 00:13:03 +09:00
Kazuki Yamada 82775c1ea9 feat(cli): Add --no-security-check command line option
# Conflicts:
#	README.md
#	src/cli/cliRun.ts
2024-12-11 13:44:55 +09:00
Jason Son 699e1f0f3b test: add missing copyToClipboard property to test config 2024-11-04 12:16:45 -08:00