perf(shim): add shim-to-runtime mapping cache for O(1) lookups#99
Merged
CalvinAllen merged 1 commit intomainfrom Dec 11, 2025
Merged
perf(shim): add shim-to-runtime mapping cache for O(1) lookups#99CalvinAllen merged 1 commit intomainfrom
CalvinAllen merged 1 commit intomainfrom
Conversation
Add a persistent shim-to-runtime mapping cache that enables O(1) lookups and fixes dynamic shim resolution for globally installed packages. Changes: - Add cache directory to Paths struct (~/.dtvem/cache/) - Generate shim-map.json during reshim operations - Load cache in mapShimToRuntime() with sync.Once for efficiency - Fall back to provider-based lookup if cache is missing This fixes shims for dynamically installed packages (tsc, eslint, black, pytest, etc.) which previously failed with "runtime provider not found" because the fallback returned the shim name as the runtime name. Closes #93 🤖 Generated with [Claude Code](https://claude.com/claude-code)
d6e5aa4 to
e342482
Compare
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
~/.dtvem/cache/shim-map.json)mapShimToRuntime()using cached mapProblem
Previously,
mapShimToRuntime()only knew about core provider shims (node, npm, python, pip, etc.). Dynamically installed packages liketsc(from TypeScript) orblack(from pip) would fail with "runtime provider not found" because the fallback returned the shim name as the runtime name.Solution
During
reshim, we already scan each runtime's directories to find executables. Now we also build a mapping of shim → runtime and save it to~/.dtvem/cache/shim-map.json:{ "node": "node", "npm": "node", "tsc": "node", "python": "python", "black": "python" }The shim executable loads this cache once (using
sync.Once) for O(1) lookups.Test plan
Closes #93