Commit Graph

47 Commits

Author SHA1 Message Date
Kazuki Yamada db647834f5 test(core): Restore '# Directory Structure' assertion in markdown case
Earlier push commit (03b8e70b) accidentally dropped the
`expect(actualOutput).toContain('# Directory Structure')` assertion
inside the markdown branch of the integration test's case-style switch.
That line still exists on disk and was present pre-change; restoring it
to keep the markdown-style coverage symmetric with the plain-style
case below it.
2026-05-09 02:38:14 +09:00
Kazuki Yamada 03b8e70b9c test(core): Wire createSecurityTaskRunner mock into remaining packager tests
Final commit of the perf(core) Pre-warm security worker pool change —
extends the unit packager test and the integration packager test:

- tests/core/packager.test.ts: adds `createSecurityTaskRunner` mock to
  the orchestration test's `mockDeps` and to the `parallel error
  handling` `baseDeps()` shared fixture, updates the
  `validateFileSafety.toHaveBeenCalledWith` assertion to expect the new
  6th-argument deps object (`{ taskRunner: <Object> }`), and adds
  positive/negative gate assertions —
  `expect(deps.createSecurityTaskRunner).toHaveBeenCalled()` for the
  default unscoped path, `.not.toHaveBeenCalled()` for the
  `--include 'src'` and `explicitFiles` (--stdin) paths.

- tests/integration-tests/packager.test.ts: adds the
  `createSecurityTaskRunner` stub so the default-scope path no longer
  attempts to spawn a real worker pool (the previous unhandled-rejection
  noise from a missing worker file URL is gone with this change).

(See PR description / first source commit for the full perf change
rationale, benchmark numbers, and correctness notes.)
2026-05-09 02:35:18 +09:00
Kazuki Yamada cfbab618c5 refactor(metrics): Encapsulate warmup logic in createMetricsTaskRunner
Move worker thread warmup from packager into createMetricsTaskRunner,
which now returns both a taskRunner and warmupPromise. This keeps the
packager clean — it no longer needs to know warmup implementation details.

Also:
- Skip metrics worker pool creation on skill-generation path where
  it is unused
- Await warmupPromise in finally block before cleanup to prevent
  tearing down workers during initialization

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 14:56:49 +09:00
Claude 4d2bbcf6cc perf(core): Pre-initialize metrics worker pool to overlap tiktoken WASM loading
Pipeline-level optimizations that produce measurable end-to-end improvement:

- Pre-initialize metrics worker pool during file collection phase so tiktoken
  WASM loading overlaps with security checks and file processing. First token
  count task dropped from 381ms to 22ms (worker already warmed).
- Lazy-load Jiti via dynamic import — only loaded when TS/JS config files are
  detected, saving startup time for the common JSON/default config path.
- Fix O(n²) file path re-grouping in packager by using Map + Set for O(1)
  membership checks instead of .find() + .includes().
- Move binary extension check before fs.stat in fileRead to skip unnecessary
  stat syscalls for binary files.
- Parallelize split output file writes with Promise.all instead of sequential
  for-loop.

Benchmark (15 runs each, median ± IQR, packing repomix repo ~1000 files):

  main branch: 3515ms (P25: 3443, P75: 3581)
  perf branch: 3318ms (P25: 3215, P75: 3383)
  Improvement: -197ms (-5.6%)

Pipeline stage breakdown (instrumented):
  - Metrics first-file init: 381ms → 22ms (worker pre-warmed)
  - Total metrics stage: 793ms → ~450ms

All 1096 tests pass. Lint clean.

https://claude.ai/code/session_01JoNjFe7S2roMfHfNcw6bso
2026-03-28 01:15:43 +09:00
Kazuki Yamada e97691dd36 perf(core): Replace worker threads with promise pool for file collection
After the UTF-8 fast path optimization eliminated the CPU-heavy jschardet
bottleneck, file collection became I/O-bound. Worker threads now add pure
overhead (Tinypool init, structured clone, IPC) without benefit.

Benchmark (954 files, M2 Pro 10-core):
- Worker Threads: ~108ms → Promise Pool (c=50): ~37ms (2.9x faster)

Changes:
- Replace Tinypool worker dispatch with a simple promise pool (c=50)
- Inject readRawFile via deps for testability
- Remove unused concurrentTasksPerWorker from WorkerOptions
- Simplify tests to use readRawFile mock instead of 5+ module mocks
2026-02-17 23:09:18 +09:00
Kazuki Yamada 375da204b1 refactor(core): Extract inner functions from generateSplitOutputParts
- Move makeChunkConfig and renderGroups to module level for better readability
- Add GenerateOutputFn type alias using typeof generateOutput
- Add comment explaining O(N²) complexity and why it's acceptable
- Fix test mock property names to match actual GitDiffResult/GitLogResult types
- Update integration tests to use produceOutput instead of individual functions
2025-12-21 21:56:39 +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 f87e00dbdf chore(lint): upgrade biome to v2.2.4 and fix all lint errors
Updated biome from v1.9.4 to v2.2.4 to take advantage of latest linting improvements.

- Upgraded @biomejs/biome from ^1.9.4 to ^2.2.4
- Updated biome.json configuration for v2 compatibility:
  - Changed schema to 2.2.4
  - Updated file includes/ignores syntax
  - Added Vue file overrides to disable noUnusedVariables/noUnusedImports
- Fixed all lint errors:
  - Added radix parameter to parseInt calls
  - Prefixed unused parameters with underscore
  - Removed unused imports
  - Fixed biome suppression comments
  - Removed !important from CSS
  - Added type ignores for Vue component definitions

All 325 files now pass lint with 0 warnings and 0 errors.
2025-09-21 13:39:43 +09:00
Kazuki Yamada 78b25b86e7 feat(core): use direct globby import instead of worker isolation
Replace executeGlobbyInWorker with direct globby calls since worker isolation
is no longer necessary for globby execution.

- Remove src/core/file/globbyExecute.ts wrapper
- Remove src/core/file/workers/globbyWorker.ts
- Update fileSearch.ts to import and use globby directly
- Update tests to mock globby instead of executeGlobbyInWorker
- Simplify integration tests by removing worker mocks
2025-09-18 23:53:27 +09:00
Kazuki Yamada 2de51c9c3a docs(readme): reorganize JSON output documentation and format order
- Reorder output formats from xml, markdown, plain, json to xml, markdown, json, plain throughout README.md, CLI help, and schema
- Move JSON Format section before Plain Text Format in documentation
- Enhance jq command examples with comprehensive JSON manipulation patterns
- Change jq examples to use `cat | jq` pipeline format for consistency
- Update all references to maintain xml, markdown, json, plain order in:
  - CLI options help text
  - Configuration schema enum
  - GitHub Actions examples
  - Documentation tables
- Fix linting issue with switch case block scoping in integration tests

This improves the logical flow by placing JSON (programmatic format) before Plain (simple format) and maintains consistent ordering across all documentation and code.
2025-09-14 14:50:38 +09:00
Kazuki Yamada 313e978e11 feat(core): add JSON output style support
Add comprehensive JSON output style with camelCase naming convention:
- JSON output generates machine-readable format using JSON.stringify()
- Always uses parsable style for valid JSON structure
- Parameter names follow camelCase convention (fileSummary, userProvidedHeader, etc.)
- Includes CLI option, config schema, and interactive prompt support
- Comprehensive test coverage for unit and integration tests
- Error handling with clear unsupported style messages

This enables easier programmatic consumption of Repomix output for AI systems and automated tools.
2025-09-14 14:50:38 +09:00
Kazuki Yamada ddd2814f84 fix(tests): Update test mocks to use new WorkerOptions interface 2025-08-31 16:32:49 +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 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 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 dac1210474 feat(core): Isolate globby usage in workers to prevent memory leaks
- Create globbyWorker.ts for isolated globby execution
- Add globbyExecute.ts to manage worker-based globby calls
- Update fileSearch.ts to use worker isolation for all globby operations
- Remove redundant cleanup calls in worker-using functions
- Fix processConcurrency.ts Bun detection logic
- Update tests to mock worker functionality for test environment

This change isolates globby memory usage in child processes, preventing
memory accumulation in the main process when processing large codebases.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 00:59:58 +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 97d4171176 fix(core): Fix TokenCounter memory leak in worker threads
TokenCounter instances were not being properly freed when worker threads
were terminated by Tinypool's idle timeout. This caused memory leaks
when using runCli as a library.

Changes:
- Add SIGTERM/SIGINT handlers to fileMetricsWorker and outputMetricsWorker
- Add freeTokenCounters function with proper cleanup and debug logging
- Convert all worker usage to consistent taskRunner pattern with cleanup
- Add cleanupWorkerPool function for explicit worker pool termination
- Update all related tests to match new taskRunner interface

The fix ensures TokenCounter resources are properly freed when workers
terminate, preventing memory accumulation during library usage.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 23:25:23 +09:00
Kazuki Yamada 002bea3d61 refactor(core): Rename handleOutput to writeOutputToDisk for clarity
Update dependency injection parameter names to be more descriptive of the actual functionality.

🤖 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 fecebc2ca6 refactor(core): Update GitDiffResult imports and restructure git handling modules 2025-05-24 14:14:26 +09:00
Kazuki Yamada b13a21aebd refactor(core): Migrate GitDiffResult and related functions to gitHandle module 2025-05-24 13:59:32 +09:00
Kazuki Yamada 9538395cdf refactor(core): Move Git-related modules to dedicated core/git directory 2025-05-19 14:53:28 +00:00
Kazuki Yamada ce3d025e23 fix(output): Update numbering for multiple file entries in output formats 2025-05-17 16:44:10 +09:00
Kazuki Yamada 5e8ff25335 feat(output): Ensure consistent order of sections (Summary, UserProvidedHeader, Directory Structure) across all output styles 2025-05-17 16:22:22 +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 265845a9c0 fix(gitDiff): Fix syntax and tests 2025-05-10 11:26:05 +09:00
Riqwan Thamir 2c4e026df3 feat(core): Make it easier to pick & override pack's deps + core export 2025-04-21 15:58:26 +02:00
Kazuki Yamada 29bd646ddc feat: allow setting max file size 2025-04-20 14:42:03 +09:00
Kazuki Yamada f1993c62c4 Fix tests for metadata-only output mode 2025-04-19 17:58:44 +09:00
Kazuki Yamada 8911966daa feat(git): Sort files by git commit frequency 2025-03-16 01:38:13 +09:00
Yamada Dev ed5b2541d1 feat(output): Keep "by Repomix" attribution for long-term LLM benefits 2025-02-11 21:14:36 +09:00
paperboardofficial 3a46cca5b3 removed-generatedby-line 2025-02-11 21:14:36 +09:00
Rakesh Chatrath 8f542124c0 Allow for passing in multiple directories 2025-02-08 16:27:22 +09:00
Yamada Dev 5ffef1f96e feat: Add accurate codebase scope description to output header 2025-02-01 18:45:23 +09:00
gitkenan fff304b02b feat: Adding "End of Codebase" to the end of codebase 2025-01-29 17:20:30 +01:00
Kazuki Yamada ebacdd967c feat(pack): Simplify the process and make it testable with DI 2025-01-25 12:43:38 +09:00
Kazuki Yamada 86ad26fefb feat(output): remove repository URL from output files 2025-01-05 22:36:16 +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 d28f34ded2 feat(config): Implement Zod for robust configuration validation 2024-11-10 22:35:45 +09:00
Kazuki Yamada 398047b1a6 feat(rename): Rename to repomix
# Conflicts:
#	src/core/packager.ts
#	src/core/security/securityCheck.ts
#	src/shared/processConcurrency.ts

# Conflicts:
#	package-lock.json
#	package.json
2024-11-02 15:26:32 +09:00
Kazuki Yamada 487287c22c refactor: refine directory structure and files 2024-10-08 01:17:05 +09:00
Kazuki Yamada 68b4c86f00 feat(config): Add support for project instruction file 2024-09-07 23:34:42 +09:00
Kazuki Yamada 2a000fa675 fix(ignore): Fix default ignore patterns for sub directories 2024-09-02 23:24:10 +09:00
Kazuki Yamada c51435e24a refact: Migrate from ESLint and Prettier to Biome 2024-08-26 23:54:23 +09:00
Kazuki Yamada bc1cf3ab6f feat(action): Add remote repository processing feature 2024-08-26 22:57:41 +09:00
Kazuki Yamada 5ae3f921d7 chore(lint): Update ESLint configuration and dependencies 2024-08-10 15:29:39 +09:00
Kazuki Yamada 0d8016e7a4 refactor(structure): Reorganize project file structure for improved modularity 2024-08-10 14:39:05 +09:00