feat: add PRD context support to beads and JSON trackers#168
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
WalkthroughConversion flows now propagate an optional PRD source path: JSON output gains metadata.sourcePrd, beads creation can attach Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as Convert Command
participant Path as Path Resolver
participant Json as PRD Generator
participant Beads as Beads Executor
participant Tracker as BeadsTrackerPlugin
participant FS as File System
User->>CLI: convert --to json input.md -o out/prd.json
CLI->>Path: resolve input & output dirs
Path->>CLI: return resolved paths
CLI->>Path: compute relative sourcePrd (out -> input.md)
Path->>CLI: return "../input.md"
CLI->>Json: convertToPrdJson(prd, sourcePrd="../input.md")
Json->>FS: write prd.json with metadata.sourcePrd
FS->>User: prd.json created
User->>CLI: convert --to beads input.md
CLI->>Beads: executeBeadsConversion(..., prdPath="input.md")
Beads->>Beads: create epic with --external-ref prd:input.md
Beads->>Beads: create stories with --external-ref prd:input.md
Tracker->>Beads: bd show <epicId> (reads external_ref)
Beads->>Tracker: external_ref "prd:./input.md"
Tracker->>FS: resolve path and read PRD content
FS->>Tracker: return PRD content
Tracker->>Tracker: compute completedCount / totalCount and return PRD context
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #168 +/- ##
==========================================
+ Coverage 40.87% 40.95% +0.07%
==========================================
Files 72 72
Lines 19912 19994 +82
==========================================
+ Hits 8140 8188 +48
- Misses 11772 11806 +34
🚀 New features to boost your workflow:
|
Beads tracker: - Add `external_ref` field to BeadJson interface - Implement `getPrdContext()` method to read PRD content from epic's external_ref field (format: prd:./path/to/file.md) - Return PRD content with completion stats for template rendering JSON tracker (fixes #160): - Add `sourcePrd` parameter to `convertToPrdJson()` - Populate `metadata.sourcePrd` field during conversion - Compute relative path from JSON output to PRD input Convert command: - Pass PRD path through conversion chain for both formats - Add `--external-ref prd:<path>` to epic AND child task creation - Use relative paths for portability across machines This enables agents to access full PRD context (goals, technical considerations, quality gates) during task execution, not just the user story title and acceptance criteria.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/plugins/trackers/builtin/beads/index.ts`:
- Around line 724-770: The code parses epicResult.stdout as a single BeadJson
object which causes epic.external_ref, title, and description to be undefined;
instead parse JSON.parse(epicResult.stdout) as an array, extract the first
element (e.g., const [epic] = ...), validate that the array has at least one
element (return null if empty), then use epic.external_ref, epic.title, and
epic.description for the PRD lookup and return payload; update any subsequent
references in this function (the epicResult parsing block around execBd, the
externalRef/ prdPath resolution, and the final return object) to use the
extracted epic element.
- Add tests for BeadsTrackerPlugin.getPrdContext(): - Returns null when no epicId set - Returns null when epic has no external_ref - Returns null when external_ref doesn't start with prd: - Returns PRD content with completion stats for valid prd: ref - Handles file read failures gracefully - Handles bd show failures gracefully - Supports absolute paths - Add tests for convertToPrdJson(): - Generates valid prd.json without sourcePrd - Includes sourcePrd in metadata when provided - Handles relative and absolute paths - Does not include sourcePrd for empty string - Fix getPrdContext() to parse bd show output as array (bd show --json returns an array with one element)
843f358 to
c474c4e
Compare
feat: add PRD context support to beads and JSON trackers
Summary
getPrdContext()method to read PRD content from epic'sexternal_reffieldmetadata.sourcePrdduring conversion (fixes convert --to json does not set metadata.sourcePrd field #160)--external-refto all created tasksChanges
Beads Tracker (
src/plugins/trackers/builtin/beads/index.ts)external_ref?: stringtoBeadJsoninterfacegetPrdContext()method that:external_reffield (format:prd:./path/to/file.md)BeadsBvTrackerPlugininherits this automaticallyJSON Tracker (
src/prd/generator.ts)sourcePrdparameter toconvertToPrdJson()sourcePrdin metadata when providedConvert Command (
src/commands/convert.ts)--external-ref prd:<path>to both epic and child task creationconvertToPrdJson()Why This Matters
Previously, agents only received user story title and acceptance criteria from the tracker. With this change, agents can access the full PRD content including:
This enables more informed implementation decisions.
Test plan
ralph-tui convert --to beads ./tasks/test.mdand verify epic + tasks haveExternal: prd:./tasks/test.mdralph-tui convert --to json ./tasks/test.md -o ./tasks/prd.jsonand verifymetadata.sourcePrdis setgetPrdContext()returns content when epic has external_refgetPrdContext()returns null gracefully when no external_refSummary by CodeRabbit
New Features
Bug Fixes / Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.