Commit Graph

23 Commits

Author SHA1 Message Date
Kazuki Yamada
0aef80b7e3 feat(shared): Support decimal values in size parsing
Allow decimal size values like '2.5mb' or '1.5kb' in parseHumanSizeToBytes.
This enables more flexible size configuration for split output.
2025-12-21 18:53:05 +09:00
Kazuki Yamada
282eeffc99 fix(cli): Address additional PR review comments
- Add test for sizeParse overflow case
- Use RepomixProgressCallback type in outputSplit.ts for consistency
- Improve configuration.md description for splitOutput option
2025-12-21 14:25:41 +09:00
Dango233
a34215ef35 feat(cli): Add --split-output option
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.
2025-12-18 02:15:24 -05: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
09b31e3e7a refactor(core): Prioritize safety with conservative worker runtime selection
Adjust worker runtime configuration to use child_process for all potentially risky operations, prioritizing stability and isolation over performance.

- Change token-related workers to child_process for better memory isolation:
  - calculateGitDiffMetrics: child_process (was worker_threads)
  - calculateGitLogMetrics: child_process (was worker_threads)
  - calculateOutputMetrics: child_process (was worker_threads)
  - calculateSelectiveFileMetrics: child_process (was worker_threads)
- Keep file collection and globby operations as worker_threads (lower risk)
- Remove redundant memory leak risk comments for cleaner code
- Fix test cases to include required runtime parameter and teardown property
- Reorder imports in languageParser.ts for consistency

This conservative approach ensures maximum stability by isolating all token counting operations in separate processes, preventing potential memory leaks from affecting the main process.
2025-09-01 22:39:24 +09:00
Kazuki Yamada
25d65dfe7c refactor(core): Consolidate worker pool arguments into WorkerOptions interface
- Add WorkerOptions interface to combine numOfTasks, workerPath, and optional runtime
- Update createWorkerPool and initTaskRunner functions to accept WorkerOptions object
- Refactor all usage sites across file processing, metrics, and security modules
- Update corresponding test cases to use new interface

This improves type safety and makes the API more maintainable by avoiding parameter order mistakes.
2025-08-31 16:24:38 +09:00
Kazuki Yamada
8f07b63a61 feat(core): Add runtime selection support for worker pools
Add WorkerRuntime type and configurable runtime parameter to createWorkerPool and initTaskRunner functions. This allows choosing between 'worker_threads' and 'child_process' runtimes based on performance requirements.

- Add WorkerRuntime type definition for type safety
- Add optional runtime parameter to createWorkerPool with child_process default
- Add optional runtime parameter to initTaskRunner with child_process default
- Configure fileCollectWorker to use worker_threads for better performance
- Update all test files to use WorkerRuntime type
- Add comprehensive tests for runtime parameter functionality
- Maintain backward compatibility with existing code

The fileCollectWorker now benefits from worker_threads faster startup and shared memory, while other workers continue using child_process for stability.
2025-08-31 16:18:12 +09:00
Kazuki Yamada
7cfe658dca feat(metrics): Create dedicated git diff worker for improved memory efficiency
- Extract git diff token calculation into separate worker and dedicated module
- Parallelize git diff metrics calculation with other metrics computations using Promise.all
- Isolate TokenCounter usage for git diffs within child process worker to prevent memory leaks
- Add comprehensive worker cleanup with exit handler for proper resource management
- Update tests to reflect new worker-based architecture and remove direct TokenCounter mocking

Memory improvements:
- Git diff token calculation now runs in isolated child process
- Enables parallel execution of all three metrics calculations (files, output, git diff)
- Further reduces main process memory footprint by isolating heavy TokenCounter operations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-27 23:53:06 +09:00
Kazuki Yamada
748ce7cead refactor(shared): Consolidate initTaskRunner implementations
Add generic initTaskRunner function to processConcurrency.ts to eliminate
duplicate initialization logic across multiple modules. This reduces code
duplication and provides consistent worker pool management with proper
type safety through generic parameters.

- Add TaskRunner<T, R> interface and initTaskRunner function
- Remove duplicate createTaskRunner wrappers from 5 modules
- Update all deps parameters to use shared initTaskRunner directly
- Maintain type safety with explicit generic type parameters
- Update corresponding test mocks to match new signature

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 23:47:07 +09:00
Kazuki Yamada
6eb8f27fd5 refactor(core): Replace environment variable with workerData for worker log level
Replace the environment variable approach for passing log levels to workers with Tinypool's workerData mechanism, which is more idiomatic for worker thread configuration.

Changes:
- Add setLogLevelByWorkerData() method to handle workerData-based log level setting
- Update Tinypool configuration to use workerData instead of env variables
- Update all 5 worker files to use setLogLevelByWorkerData()
- Remove unused setLogLevelByEnv function and related test mocks
- Update tests to reflect new workerData configuration

This provides better isolation and follows Node.js worker thread best practices.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 00:05:52 +09:00
Kazuki Yamada
ae68e51a05 fix(core): optimize worker thread allocation
- Set TASKS_PER_THREAD to 100 for better balance between performance and resource usage
- Add comment explaining that worker initialization is expensive
- Update tests to match new thread allocation logic

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 00:05:51 +09:00
Kazuki Yamada
c1edfff082 Rename initTinypool to initWorker for better semantic clarity
Updated all references throughout the codebase:
- Import statements in 5 core modules
- Function calls in file processing, metrics, and security modules
- Test mocks and descriptions
- Maintained backward compatibility and functionality

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-05 00:27:34 +09:00
Kazuki Yamada
a2c5a15838 feat: migrate from Piscina to Tinypool for worker thread management
Replace Piscina with Tinypool to significantly reduce bundle size (800KB → 38KB) while maintaining full API compatibility and performance. This migration affects all worker thread pools used in file processing, security checks, and metrics calculations.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-05 00:23:56 +09:00
Devin AI
59b1bfe70d Remove unnecessary unknown type casting in processConcurrency.test.ts
Co-Authored-By: Kazuki Yamada <koukun0120@gmail.com>
2025-05-12 14:32:02 +00:00
Kazuki Yamada
2f2035eab3 test(core): fix tests for logger loglevel sync in worker processes 2025-04-20 15:01:20 +09:00
pranshugupta01
ed13f1f0ff lint fix 2025-04-07 02:12:15 +05:30
pranshugupta01
6d7e4edc38 test(patternUtils): add unit tests for splitPatterns function 2025-04-07 01:52:47 +05:30
yamadashy
3f8dff6694 test: Increase coverage of some tests 2025-03-02 21:45:12 +09:00
Yamada Dev
0b84b97675 feat(cli): Add quiet mode option 2025-02-11 18:02:03 +09:00
Yamada Dev
c04554e59f feat(cli): Control verbose as a log level 2025-02-11 17:48:52 +09:00
Kazuki Yamada
6c9a149eb5 feat(pack): Simplify various processes 2025-01-25 13:55:19 +09:00
Kazuki Yamada
c51435e24a refact: Migrate from ESLint and Prettier to Biome 2024-08-26 23:54:23 +09:00
Kazuki Yamada
88dd0c8eb2 refact: Refactor logging and improve test coverage 2024-08-12 16:41:37 +09:00