Add bundle update awareness: outdated, update commands and async check#48
Open
shwetank-dev wants to merge 5 commits intomainfrom
Open
Add bundle update awareness: outdated, update commands and async check#48shwetank-dev wants to merge 5 commits intomainfrom
shwetank-dev wants to merge 5 commits intomainfrom
Conversation
Move getCacheDir, getCacheMetadata, writeCacheMetadata, and CacheMetadata interface from run.ts into a shared utils/cache.ts module. This prepares for the new `outdated` and `update` commands (#37) which need the same cache utilities. No behavior change — run.ts imports from the new location and all existing tests pass with updated imports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After spawning the MCP server, fire a non-blocking background check against the registry. If the cached version differs from latest, print an update notice to stderr. Uses a 1-hour TTL (lastCheckedAt field in .mpak-meta.json) to avoid hitting the registry on every run. Errors are silently swallowed. Local bundles skip the check entirely. The exit handler waits up to 3s for the check to complete before calling process.exit(), so the notice and metadata write aren't lost. Refs #37 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds two new CLI commands for bundle update awareness: - `mpak outdated` / `mpak bundle outdated`: scans ~/.mpak/cache/, checks each cached registry bundle against the registry, and prints a table of bundles with newer versions available. Supports --json. - `mpak update [@scope/name]` / `mpak bundle update [@scope/name]`: with a name, downloads the latest version and replaces the cache. Without args, runs the outdated check first and updates all stale bundles sequentially. New shared helpers in cache.ts: - listCachedBundles(): scans cache dir, skips _local/, reads manifest.json + .mpak-meta.json from each entry - downloadAndExtract(): reusable download+extract+write-metadata flow with zip bomb protection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- cache.test.ts (10 tests): listCachedBundles() using real temp dirs. Covers empty/missing cache, multiple bundles, _local/ skipping, missing or corrupt manifest/meta files, non-directory entries, and verifying name is read from manifest not directory name. - outdated.test.ts (6 tests): getOutdatedBundles() with mocked SDK client. Covers empty cache, all-up-to-date, identifying outdated bundles with correct versions, alphabetical sorting, skipping bundles deleted from registry, and parallel checking. - update.test.ts (8 tests): handleUpdate() with mocked downloadAndExtract and getOutdatedBundles. Covers single-bundle update, update-all, JSON output for both modes, continuation on partial failure, and not calling getOutdatedBundles in single mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mgoldsborough
requested changes
Mar 16, 2026
| return results.sort((a, b) => a.name.localeCompare(b.name)); | ||
| } | ||
|
|
||
| export async function handleOutdated(options: OutdatedOptions = {}): Promise<void> { |
Contributor
There was a problem hiding this comment.
handleOutdated calls listCachedBundles twice — outdated.ts:51 calls listCachedBundles() to check if empty, then getOutdatedBundles() at line 54 calls it again internally. could pass the list in, or just let getOutdatedBundles return empty.
Split downloadAndExtract into resolveBundle + downloadAndExtract so run.ts can check the resolved version against cache before downloading. Extract shared extractZip helper (with zip bomb protection) used by both registry and local bundle paths, eliminating duplicate security-critical code from run.ts. Remove redundant listCachedBundles call in outdated.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mgoldsborough
approved these changes
Mar 17, 2026
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
Closes #37
utils/cache.ts— movesgetCacheDir,getCacheMetadata,writeCacheMetadataout ofrun.tsinto a shared module for reuse across commandsmpak run— fire-and-forget background check against the registry after spawning the MCP server. Throttled to once per hour vialastCheckedAtin cache metadata. Prints a notice to stderr if a newer version existsmpak outdated/mpak bundle outdated— scans~/.mpak/cache/, checks each cached registry bundle against the registry in parallel, prints a table of bundles with newer versions available. Supports--jsonmpak update/mpak bundle update— with a package name, downloads the latest version and replaces the cache. Without args, runs the outdated check first and updates all stale bundles sequentially. Continues on partial failure. Supports--jsoncache.ts:listCachedBundles()(scans cache, skips_local/, reads manifest + meta),downloadAndExtract()(download + zip bomb check + extract + write metadata)listCachedBundles(10 tests with real temp dirs),getOutdatedBundles(6 tests with mocked SDK), andhandleUpdate(8 tests with mocked dependencies)Test plan
pnpm typecheckpassespnpm lintpassespnpm testpasses (132 tests, 10 test files)mpak outdatedworks against real cache (3 cached bundles, all up to date)mpak outdated --jsonoutputs valid JSONmpak updateworks (reports all up to date)mpak update --jsonoutputs valid JSONmpak bundle outdatedandmpak bundle updatealiases work🤖 Generated with Claude Code