Embed tracker templates to fix bundled environment path resolution#267
Embed tracker templates to fix bundled environment path resolution#267
Conversation
The bun bundler compiles all modules into a single output file, causing import.meta.url to resolve to the bundle location (dist/) rather than the original module's nested path. This made template.hbs files unreadable from bundled distributions. Solution: Embed templates as string constants in a shared module, eliminating the file I/O dependency. Template.hbs files are kept as reference documentation for users creating custom templates. Fixes #248 https://claude.ai/code/session_01UqFimD7QDEz9LCzxGQtCNA
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
WalkthroughThis PR migrates tracker templates from runtime file-based loading to static embedded constants. It removes filesystem I/O dependencies from four tracker plugins (beads, beads-bv, beads-rust, json), wires BEADS_RUST_TEMPLATE into the template resolution engine, and updates template.hbs files to document their reference-only status. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Remove redundant src/plugins/trackers/builtin/templates.ts - Update all trackers to import from src/templates/builtin.ts - Add BEADS_RUST_TEMPLATE to the existing builtin templates - Update template engine types and functions to support beads-rust - Fix beads-bv test to match actual template content (no bd sync) https://claude.ai/code/session_01UqFimD7QDEz9LCzxGQtCNA
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #267 +/- ##
==========================================
+ Coverage 43.69% 43.70% +0.01%
==========================================
Files 94 94
Lines 29040 28978 -62
==========================================
- Hits 12688 12665 -23
+ Misses 16352 16313 -39
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/templates/engine.ts (1)
642-647:⚠️ Potential issue | 🟡 MinorAdd beads-rust to installBuiltinTemplates output.
Line 642-647 currently omit the new beads-rust template, soinstallBuiltinTemplateswon’t createbeads-rust.hbs. Please include it for parity with the other built-ins.Proposed fix
const templates: Record<string, string> = { 'default': DEFAULT_TEMPLATE, 'beads': BEADS_TEMPLATE, + 'beads-rust': BEADS_RUST_TEMPLATE, 'beads-bv': BEADS_BV_TEMPLATE, 'json': JSON_TEMPLATE, };
…Xul1u Embed tracker templates to fix bundled environment path resolution
Summary
Resolves path resolution issues in bundled environments by embedding tracker prompt templates as string constants instead of reading them from the filesystem at runtime.
Problem
When the application is bundled,
__dirnameresolves to the bundle root rather than the original module's directory, causing template file reads to fail. This affects all tracker plugins (beads, beads-rust, beads-bv, and json).Solution
src/plugins/trackers/builtin/templates.tswith embedded template constants for all tracker typesreadFileSync,__dirname,dirname,fileURLToPath) from all tracker plugin filesgetTemplate()methods to return embedded constants instead of reading files.hbsfiles to clarify they are reference copies only, with notes about customization locationsKey Changes
src/plugins/trackers/builtin/templates.ts- ContainsBEADS_TEMPLATE,BEADS_RUST_TEMPLATE,BEADS_BV_TEMPLATE,JSON_TEMPLATE, andFALLBACK_TEMPLATEconstantssrc/plugins/trackers/builtin/beads/index.ts- Removed file I/O, imports embedded templatesrc/plugins/trackers/builtin/beads-rust/index.ts- Removed file I/O, imports embedded templatesrc/plugins/trackers/builtin/beads-bv/index.ts- Removed file I/O, imports embedded templatesrc/plugins/trackers/builtin/json/index.ts- Removed file I/O, imports embedded template.hbstemplate files - Added reference-only notices and customization instructionsImplementation Details
readFileSync,dirname,fileURLToPath,join(where applicable).ralph-tui/templates/{tracker}.hbsor~/.config/ralph-tui/templates/{tracker}.hbshttps://claude.ai/code/session_01UqFimD7QDEz9LCzxGQtCNA
Summary by CodeRabbit
Release Notes
New Features
Documentation