feat(cli): add cache list/clear command#232
Merged
Merged
Conversation
Adds listArchiveCacheEntries, clearArchiveCacheRoot, and clearArchiveCacheEntry (each a pure function taking cacheRoot/cacheDir as a parameter, never resolving the real OS temp cache themselves) plus the shared ArchiveCacheEntry type and a pathExists helper. Also exports getArchiveCacheRoot, computeArchiveCacheKey, and resolveArchiveCacheDir, which were previously internal-only, so the upcoming CLI cache command can use them.
…cheRoot Replaces the hardcoded os.tmpdir()/nitpicker/cache/table path with getTableCacheRoot(), defined as a child of crawler's getArchiveCacheRoot(). Default behaviour is unchanged; NITPICKER_TAR_CACHE_DIR now also redirects the analyze table cache, matching the tar-extraction cache it already redirects.
Adds a `cache` sub-command with two operations: `list` (human-readable text by default, `--json` for machine output) and `clear` (wipes the entire cache root, or just one archive's tar-cache entry when a `.nitpicker` path is given). No confirmation prompt, matching the existing "manual rm -rf is safe" design for the tar cache. Adds formatBytes and formatCacheList as separate testable formatting helpers.
cache.spec.ts mocks @nitpicker/crawler entirely to unit-test the command's own branching, proving nothing about whether the real getArchiveCacheRoot/listArchiveCacheEntries/clearArchiveCache* functions agree with what Archive.openCached actually writes to disk. Spawns the built CLI binary (same pattern as viewer-read-model-build.e2e.ts) with NITPICKER_TAR_CACHE_DIR pinned to a throwaway directory, so the suite never touches a real developer machine's cache. Registers the new file in the e2e shard manifest.
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
nitpicker cache list [--json]andnitpicker cache clear [archive]to list/clear the on-disk tar-extraction cache (and the siblinganalyzetablecache) that viewer/MCP/query CLI populate undergetArchiveCacheRoot(). Previously the only way to clear this was a manualrm -rf.cache clearwith no archive wipes the whole cache root; with a.nitpickerpath it removes only that archive's tar-cache entry (content-addressed lookup — a stale entry from a since-changed archive won't be found this way,cache list+cache clearwith no argument is the fallback). No confirmation prompt, matching the existing "manualrm -rfis safe" design for the tar cache.@nitpicker/core's hardcoded analyzetablecache path intogetTableCacheRoot(), defined as a child of crawler'sgetArchiveCacheRoot(). Default behaviour is unchanged;NITPICKER_TAR_CACHE_DIRnow also redirects the table cache, matching the tar cache it already redirects.listArchiveCacheEntries,clearArchiveCacheRoot,clearArchiveCacheEntry) are pure — they takecacheRoot/cacheDiras a parameter rather than resolving the real OS temp cache themselves, so their unit tests exercise a throwaway directory and never touch a real developer machine's cache.cache listreports it →cache clearremoves it), since the command-level unit test mocks@nitpicker/crawlerentirely.Test plan
yarn build(worktree,NX_WORKSPACE_ROOT_PATHset)yarn lintyarn test— 494 files / 3484 tests passedyarn vitest run --config vitest.e2e.config.ts packages/test-server/src/__tests__/e2e/cache-cli.e2e.ts— 3 tests passedgit diff origin/dev...HEADfor stray domains / sample-value convention🤖 Generated with Claude Code