Skip to content

convert --to json does not set metadata.sourcePrd field #160

@sclaar

Description

@sclaar

When using ralph-tui convert --to json to convert a PRD markdown file to JSON format, the generated prd.json does not include the metadata.sourcePrd field.

However, the codebase already has logic to read this field and inject the full PRD content into the agent prompt via {{prdContent}}:

// cli.js:37926-37942
async getSourcePrdContent() {
  if (!this.filePath) {
    return "";
  }
  try {
    const prd = await this.readPrd();
    const sourcePrdPath = prd.metadata?.sourcePrd;  // <-- looks for this field
    if (!sourcePrdPath) {
      return "";  // <-- returns empty if missing
    }
    const prdDir = resolve(this.filePath, "..");
    const fullPath = sourcePrdPath.startsWith("/") ? sourcePrdPath : resolve(prdDir, sourcePrdPath);
    const content = await readFile(fullPath, "utf-8");
    return content;
  } catch {
    return "";
  }
}

But the convertToPrdJson() function does not populate this field:

// cli.js:94097-94116
function convertToPrdJson(prd) {
  return {
    name: prd.name,
    description: prd.description,
    branchName: prd.branchName,
    userStories: prd.userStories.map((story) => ({ ... })),
    metadata: {
      createdAt: prd.createdAt,
      version: "1.0.0"
      // sourcePrd is missing here!
    }
  };
}

Impact
Without sourcePrd, the agent only receives the user story title and acceptance criteria from the JSON. It misses important context from the full PRD such as:

Goals and Non-Goals
Technical Considerations
Functional Requirements
Quality Gates
Success Metrics
This limits the agent's ability to make informed implementation decisions.

Expected Behavior
When running:

ralph-tui convert --to json ./tasks/my-feature.md -o ./tasks/prd.json
The generated JSON should include:

{
  "metadata": {
    "createdAt": "2026-01-19T23:35:50.609Z",
    "version": "1.0.0",
    "sourcePrd": "./my-feature.md"
  }
}

The path should be relative to the output JSON file location.

Workaround
Manually add the sourcePrd field to the generated JSON:

"metadata": {
  "sourcePrd": "./my-feature.md"
}

Version
ralph-tui 0.2.1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions