The function now always calculates metrics for all files, so the
"Selective" prefix no longer reflects its behavior.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The output parameter was typed as `string | string[] | Promise<...>` but
callers can always wrap sync values in Promise.resolve(). Simplifying to
`Promise<string | string[]>` makes the interface cleaner.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace tiktoken (WASM-based) with gpt-tokenizer (pure JS) for token
counting, eliminating ~200ms WASM initialization overhead while keeping
the existing worker pool infrastructure for parallel processing.
Changes:
- Swap tiktoken dependency for gpt-tokenizer in package.json
- Rewrite TokenCounter to use gpt-tokenizer's async dynamic import
with lazy-loaded encoding modules cached at module level
- Add TOKEN_ENCODINGS constant with Zod enum validation in config
schema, replacing unsafe type assertion
- Use { disallowedSpecial: new Set() } to match tiktoken's
encode(content, [], []) behavior (treat all text as plain text)
- Add p50k_edit encoding for backward compatibility
- Update worker to handle async getTokenCounter initialization
- Rewrite tests to use real gpt-tokenizer with exact token counts
The worker pool, parallel chunk processing, and pre-warming
infrastructure are preserved — only the underlying tokenizer changes.
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
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.
Replaced worker file imports with direct function calls in tests to improve coverage
and remove CI build requirements. Key changes:
- Extracted calculateUnifiedMetrics function from unifiedMetricsWorker for direct testing
- Added taskRunner dependency injection to calculateMetrics function
- Updated all metric tests to use mocked taskRunner instead of actual worker files
- Removed build steps from CI test jobs (test, test-bun, test-coverage)
This approach provides better test coverage since worker logic runs directly
in the test process rather than being executed in separate worker threads.
Tests now run faster without requiring TypeScript compilation.
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.
Remove calculateAllFileMetrics function that was only used in tests and rename calculateAllFileMetrics.ts to calculateSelectiveFileMetrics.ts to match the remaining function. This simplifies the metrics calculation API by keeping only the selective file metrics functionality that is actually used in production code.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 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>
- 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 character-based pre-filtering to reduce token calculation overhead
- Implement calculateSelectiveFileMetrics for targeted token counting
- Only calculate tokens for top candidates (5x display count) instead of all files
- Maintain accurate token-based ranking while improving performance for large codebases
- Update tests to cover new selective calculation functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Updated CLI options to use `--include-diffs` instead of `--diffs`.
- Refactored `printSummary` to accept a `PackResult` object for better data handling.
- Introduced `getStagedDiff` function to retrieve staged changes from git.
- Created `getGitDiffs` function to encapsulate logic for fetching both worktree and staged diffs.
- Modified output generation functions to include git diffs in various formats (markdown, XML, plain text).
- Updated tests to reflect changes in CLI options and output generation logic, ensuring proper handling of git diffs.
- Removed deprecated `diffContent` from config schema and adjusted related logic.