[PROTOTYPE/RFC] URL-based pattern loading with automatic dependency resolution #1987
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.
This is a prototype/proof-of-concept implementation to demonstrate URL-based pattern loading. This PR is for discussion and feedback only, not ready to merge.
Problem Statement
Patterns in the
recipesrepo need to reference patterns in thelabsrepo, but currently this requires:Proposed Solution
Enable patterns to be loaded directly from URLs (e.g., GitHub raw URLs) with automatic resolution of relative imports.
What This Prototype Demonstrates
✅ Core Functionality Working
Direct URL Loading
Automatic Relative Import Resolution
./counter-handlers.tshttps://.../counter-handlers.tsCross-Repository References
🧪 Tests Passing
All tests pass successfully:
packages/charm/test/url-loading.test.ts(5/5 passing)test-url-integration.ts(all scenarios working)aside.tsx,counter.tsxwith dependenciesTechnical Implementation
Files Modified (7 core files)
packages/js-runtime/program.ts- HTTP program resolver with cache bustingpackages/js-runtime/typescript/resolver.ts- URL-based relative resolutionpackages/js-runtime/typescript/compiler.ts- URL-aware module resolutionpackages/js-runtime/typescript/diagnostics/checker.ts- Filter URL module errorspackages/js-runtime/typescript/bundler/bundle.ts- Preserve URLs in AMD outputpackages/runner/src/harness/pretransform.ts- Skip hash prefix for URLspackages/charm/src/commands.ts- NewaddRecipeFromUrl()APIKey Technical Challenges Solved
path.normalize()) corrupt URLs (https://→https:/)URLclass insteadQuestions for Discussion
🤔 Architecture & Design
🤔 API Design
addRecipeFromUrl()clear enough? Alternative names?🤔 Integration & Deployment
🤔 User Experience
Benefits of This Approach
✅ No Symlinks: Eliminates brittle cross-repo symlink management
✅ No Copying: No need to duplicate pattern files
✅ Versioning: Can pin to specific commits via URL
✅ Distribution: Share patterns via simple URLs
✅ Works Today: Functional prototype with passing tests
Known Limitations & TODOs
📋 Would Need Before Landing:
Documentation
docs/URL_PATTERN_LOADING.mdURL_PATTERN_LOADING_SUMMARY.mddocs/FINDINGS_URL_PATTERN_LOADING.mdHow to Test
Request for Feedback
Please review and provide feedback on:
Again: This is a prototype for discussion. Not ready to merge.
Please feel free to experiment with it, break it, and provide honest feedback!
🤖 Generated with Claude Code
Summary by cubic
Prototype adds URL-based pattern loading with automatic resolution of relative imports so patterns can be loaded directly from URLs (e.g., GitHub raw). This enables cross-repo references without symlinks or file copying and includes tests and docs.
Written for commit 893890e. Summary will update automatically on new commits.