Skip to content

Embed tracker templates to fix bundled environment path resolution#267

Merged
subsy merged 3 commits intomainfrom
claude/investigate-issue-248-Xul1u
Feb 3, 2026
Merged

Embed tracker templates to fix bundled environment path resolution#267
subsy merged 3 commits intomainfrom
claude/investigate-issue-248-Xul1u

Conversation

@subsy
Copy link
Copy Markdown
Owner

@subsy subsy commented Feb 3, 2026

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, __dirname resolves 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

  • Created new src/plugins/trackers/builtin/templates.ts with embedded template constants for all tracker types
  • Removed filesystem-based template loading (readFileSync, __dirname, dirname, fileURLToPath) from all tracker plugin files
  • Updated getTemplate() methods to return embedded constants instead of reading files
  • Updated template .hbs files to clarify they are reference copies only, with notes about customization locations

Key Changes

  • New file: src/plugins/trackers/builtin/templates.ts - Contains BEADS_TEMPLATE, BEADS_RUST_TEMPLATE, BEADS_BV_TEMPLATE, JSON_TEMPLATE, and FALLBACK_TEMPLATE constants
  • Modified: src/plugins/trackers/builtin/beads/index.ts - Removed file I/O, imports embedded template
  • Modified: src/plugins/trackers/builtin/beads-rust/index.ts - Removed file I/O, imports embedded template
  • Modified: src/plugins/trackers/builtin/beads-bv/index.ts - Removed file I/O, imports embedded template
  • Modified: src/plugins/trackers/builtin/json/index.ts - Removed file I/O, imports embedded template
  • Updated: All .hbs template files - Added reference-only notices and customization instructions

Implementation Details

  • Templates are now embedded as multi-line string constants, preserving all original formatting and handlebars syntax
  • Removed template caching logic (no longer needed with embedded constants)
  • Removed unused imports: readFileSync, dirname, fileURLToPath, join (where applicable)
  • Users can still customize templates by placing files at .ralph-tui/templates/{tracker}.hbs or ~/.config/ralph-tui/templates/{tracker}.hbs
  • Fixes issue: Bug: Beads tracker template.hbs path resolution fails in bundled dist #248

https://claude.ai/code/session_01UqFimD7QDEz9LCzxGQtCNA

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for Beads-Rust tracker plugin.
  • Documentation

    • Updated template reference files to clarify customisation locations for project and global configurations.

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
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ralph-tui Ignored Ignored Preview Feb 3, 2026 9:49pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 3, 2026

Walkthrough

This 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

Cohort / File(s) Summary
Beads tracker plugin
src/plugins/trackers/builtin/beads/index.ts, src/plugins/trackers/builtin/beads/template.hbs
Replaced file-based template loading with embedded BEADS_TEMPLATE constant; removed __dirname, filesystem reads, and caching logic. Updated template header to mark as reference copy with customization guidance.
Beads-bv tracker plugin
src/plugins/trackers/builtin/beads-bv/index.ts, src/plugins/trackers/builtin/beads-bv/template.hbs
Replaced file-based template loading with embedded BEADS_BV_TEMPLATE constant; removed path resolution and caching. Updated template header to indicate reference-only status and embedded runtime version.
Beads-rust tracker plugin
src/plugins/trackers/builtin/beads-rust/index.ts, src/plugins/trackers/builtin/beads-rust/template.hbs
Replaced file-based template loading with embedded BEADS_RUST_TEMPLATE constant; removed filesystem dependencies. Updated template header and added customization location guidance.
JSON tracker plugin
src/plugins/trackers/builtin/json/index.ts, src/plugins/trackers/builtin/json/template.hbs
Replaced file-based template loading with embedded JSON_TEMPLATE constant; removed fallback logic and error handling for missing files. Updated template header to document reference-only and embedded runtime status.
Template engine system
src/templates/builtin.ts, src/templates/engine.ts, src/templates/types.ts
Added BEADS_RUST_TEMPLATE export (with duplicate declaration in builtin.ts); extended BuiltinTemplateType to include 'beads-rust'; wired beads-rust support into getBuiltinTemplate and getTemplateTypeFromPlugin resolution logic.
Tracker test updates
src/plugins/trackers/builtin/beads-bv/index.test.ts
Removed mocked fs.readFileSync from test setup; updated test expectation to remove 'bd sync' assertion with explanatory comment distinguishing beads-bv (no sync) from beads-rust (with sync).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #179: Directly modifies template/engine plumbing to wire beads-rust built-in template support through the same mechanisms (getBuiltinTemplate, BuiltinTemplateType).
  • PR #128: Related changes to tracker template provisioning and how getTemplate implementations are structured across tracker plugins.
  • PR #232: Adds explicit beads-rust tracker recognition in detection, runner, and wizard logic alongside this PR's wiring of BEADS_RUST_TEMPLATE.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarises the primary objective: embedding tracker templates to resolve path issues in bundled environments. It is concise, clear, and directly reflects the main change across the entire changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/investigate-issue-248-Xul1u

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- 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
Copy link
Copy Markdown

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.70%. Comparing base (106f026) to head (dd87c83).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/templates/engine.ts 40.00% 3 Missing ⚠️
src/plugins/trackers/builtin/json/index.ts 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
src/plugins/trackers/builtin/beads-bv/index.ts 10.78% <100.00%> (-1.79%) ⬇️
src/plugins/trackers/builtin/beads-rust/index.ts 70.20% <100.00%> (-0.43%) ⬇️
src/plugins/trackers/builtin/beads/index.ts 61.82% <100.00%> (+1.86%) ⬆️
src/templates/builtin.ts 100.00% <100.00%> (ø)
src/plugins/trackers/builtin/json/index.ts 60.98% <66.66%> (+1.57%) ⬆️
src/templates/engine.ts 71.42% <40.00%> (-0.39%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Add beads-rust to installBuiltinTemplates output.
Line 642-647 currently omit the new beads-rust template, so installBuiltinTemplates won’t create beads-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,
   };

@subsy subsy merged commit e94bdd8 into main Feb 3, 2026
9 checks passed
@subsy subsy deleted the claude/investigate-issue-248-Xul1u branch February 3, 2026 21:56
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
…Xul1u

Embed tracker templates to fix bundled environment path resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants