-
Notifications
You must be signed in to change notification settings - Fork 1
Restore models and models-macro workflow #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #6
This commit restores the Bun macro functionality in models.ts by adding
the `with { type: "macro" }` directive to the import statement.
Key changes:
- Added macro directive to models-macro import in src/provider/models.ts
- Created comprehensive documentation in docs/MACRO_SUPPORT.md
How it works:
- Macros work in development mode (running from source)
- Macros gracefully fallback when running from node_modules
- Runtime fetching is used when macros are unavailable
Limitations:
Due to Bun's security model, macros cannot execute from node_modules.
This means macros only work when running from source, not when
installed globally via `bun install -g`. The code handles this
gracefully with automatic fallback to runtime fetching.
Alternative approaches considered:
1. Pre-bundling: Async macros caused bundler to hang
2. Bundled JSON: Would add ~600KB to package size
The current solution provides the best balance:
- Development performance optimization through macros
- Reliable production behavior through runtime fetching
- No user configuration required
Related: #6
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit 99daa5a.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart 1/3Detected uncommitted changes from previous run. Starting new session to review and commit them. Uncommitted files: Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback. |
This commit adds development tooling to demonstrate and verify the macro functionality works as expected: 1. experiments/test-macro.ts - Verifies the macro imports and executes correctly in development mode, fetching ~596KB JSON from models.dev 2. experiments/test-agent-simple.sh - Tests that the agent runs correctly with macro support enabled 3. scripts/build.ts - Experimental build script that attempts to bundle the application with macros evaluated at build time (investigation showed async macros with network fetching cause bundler to hang) These scripts provide evidence that the macro restoration works in development mode and document the pre-bundling investigation. Related: #6 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Summary
This PR restores Bun macro support for the models.dev data fetching functionality, as requested in issue #6. The implementation adds the macro directive while maintaining backward compatibility through automatic fallback.
Key Changes
Restored macro directive in
src/provider/models.ts:Added comprehensive documentation in
docs/MACRO_SUPPORT.mdexplaining:How It Works
Limitations
Due to Bun's security model, macros cannot execute from
node_modules. This is a fundamental restriction documented in the official Bun macro documentation:This means:
bun install -g)Testing
The macro has been tested and verified to work in development mode:
The existing test suite continues to pass, confirming backward compatibility.
Alternative Approaches Investigated
Pre-bundling with
bun build:Bundling cached JSON:
Conclusion
This implementation provides the best of both worlds:
While macros cannot work in globally-installed packages due to Bun's security model, restoring the macro directive enables development-time optimizations and keeps the door open for future improvements if Bun adds support for pre-compiled/bundled packages.
Fixes #6
🤖 Generated with Claude Code