feat(cli): add convenience filter flags --ext, --max-depth, --min-size, --max-size#101
Merged
gregpriday merged 1 commit intoFeb 26, 2026
Merged
Conversation
…e, --max-size - Add --ext flag to filter by file extensions (comma-separated, e.g. .js,.ts) - Add --max-depth flag to limit directory traversal depth (0 = root only) - Add --min-size / --max-size flags for human-readable size filtering (1KB, 10MB) - Implement depth tracking in ignoreWalker.js (recursive) and parallelWalker.js (BFS) - Apply extension and size filters in FileDiscoveryStage after discovery - parseExtensions() validates non-empty input, throws CommandError on degenerate input - parseSizeOption() reuses existing parseSize() from helpers with friendly error messages - All four flags work in combination (AND logic) with existing --filter patterns - Force-included files (--always / .copytreeinclude) bypass ext/size filters by design - Add 18 unit tests for filter combinations in FileDiscoveryStage.filters.test.js - Add 4 maxDepth tests to ignoreWalker.test.js - Add 5 maxDepth tests to parallelWalker.test.js including sequential/parallel parity check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds four convenience CLI flags that make common file-filtering tasks fast and intuitive, without requiring glob patterns or profile edits.
Closes #28
Changes Made
New CLI flags (
bin/copytree.js)--ext <extensions>— filter by file extensions, comma-separated (e.g..js,.ts,.tsxorjs,ts)--max-depth <n>— limit traversal depth (0 = root files only, 1 = one level deep, etc.)--min-size <size>— exclude files smaller than a human-readable threshold (e.g.1KB,500B)--max-size <size>— exclude files larger than a human-readable threshold (e.g.10MB,1GB)Wiring (
src/commands/copy.js)parseExtensions()— normalises comma-separated extensions to lowercase with leading dots; throwsCommandErrorfor empty/degenerate input (e.g.',,,)parseSizeOption()— wraps existingparseSize()fromhelpers.jswith a user-friendlyCommandErrorbuildProfileFromCliOptions()— converts the four new flags intoprofile.optionsfieldssetupPipelineStages()— forwards the new options toFileDiscoveryStageFiltering logic (
src/pipeline/stages/FileDiscoveryStage.js)extFilter,maxDepth,minSizeBytes,maxSizeBytesmaxDepthis passed to both walkers viawalkOptions--filterpatterns--always/.copytreeinclude) bypass ext/size filters by design (separate fast-glob path)Depth limiting (
src/utils/ignoreWalker.js,src/utils/parallelWalker.js)walkWithIgnore—walk()now accepts adepthparameter (default0); recursion is skipped whendepth >= maxDepthwalkParallel— BFS queue entries carrydepth; subdirectories are only enqueued whendepth < maxDepthTests
tests/unit/pipeline/stages/FileDiscoveryStage.filters.test.js— 18 tests covering all four filters and their combinationstests/unit/utils/ignoreWalker.test.js— 4maxDepthcases (0, 1, 2, unlimited)tests/unit/utils/parallelWalker.test.js— 5maxDepthcases including sequential/parallel parity checkUsage Examples