Skip to content

fix(opencode): use relative SDD prompt paths#1252

Open
decode2 wants to merge 1 commit into
Gentleman-Programming:mainfrom
decode2:fix/issue-723-relative-prompt-paths-v2
Open

fix(opencode): use relative SDD prompt paths#1252
decode2 wants to merge 1 commit into
Gentleman-Programming:mainfrom
decode2:fix/issue-723-relative-prompt-paths-v2

Conversation

@decode2

@decode2 decode2 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Linked Issue

Closes #723


PR Type

  • type:bug - Bug fix (non-breaking change that fixes an issue)
  • type:feature - New feature (non-breaking change that adds functionality)
  • type:docs - Documentation only
  • type:refactor - Code refactoring (no functional changes)
  • type:chore - Build, CI, or tooling changes
  • type:breaking-change - Breaking change (fix or feature that changes existing behavior)

Summary

  • Generate OpenCode SDD prompt references as portable relative paths instead of machine-specific absolute paths.
  • Keep prompt resolution deterministic across single- and multi-profile generated settings.

Changes

File / Area What Changed
internal/components/sdd Generate relative prompt paths and update profile injection coverage.
internal/components/golden_test.go Normalize golden generation expectations for relative paths.
testdata/golden/sdd-opencode-multi-settings.golden Update deterministic generated JSON output.

Test Plan

Passed:

  • go test ./internal/components/sdd/...
  • go test ./internal/components -run '^TestGoldenSDD_OpenCode_Multi$'
  • go test ./internal/components
  • git diff --check

Runtime validation: N/A. The affected output is deterministic generated JSON and is covered by focused unit and golden tests; there is no separate runtime boundary.


Automated Checks

The repository checks will run on this PR.


Contributor Checklist

  • PR is linked to an issue with status:approved
  • PR stays within 400 changed lines, or has an approved exception
  • The appropriate type:* label is applied
  • Required tests pass
  • Documentation is updated if necessary
  • Commits follow Conventional Commits
  • Commits do not include Co-Authored-By trailers

Notes for Reviewers

Size: 9 files, +128/-50 (178 changed lines), under the 400-line review budget.

Summary by CodeRabbit

  • Bug Fixes

    • Improved SDD sub-agent prompt references to use stable, portable relative {file:...} paths in generated opencode.json overlays and inline prompts.
    • Prevented machine-specific home directory paths from being embedded, improving cross-environment consistency across OpenCode and Kilocode settings layouts.
  • Tests

    • Updated golden and integration assertions to validate settings-relative prompt references.
    • Added/extended tests for shared prompt reference generation and to ensure generated outputs do not contain absolute local paths.

@decode2

decode2 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Maintainers, please add the type:bug label. The contributor account does not have permission to apply labels.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

SDD profile overlays and OpenCode prompt injection now generate settings-relative {file:...} references. A shared helper normalizes these paths, callers pass settingsPath, and tests verify generated settings do not contain temporary home directories.

Changes

Portable prompt reference generation

Layer / File(s) Summary
Shared prompt reference helper
internal/components/sdd/prompts.go, internal/components/sdd/prompts_test.go
Adds SharedPromptFileRef for normalized settings-relative prompt references and tests OpenCode/Kilocode layouts.
Overlay and injection integration
internal/components/sdd/profiles.go, internal/components/sdd/inject.go
Passes settingsPath through overlay generation and replaces absolute prompt references with shared relative references.
Integration and portability validation
internal/components/sdd/*_test.go, internal/components/golden_test.go, internal/cli/sync_test.go
Updates callers and assertions to validate relative references and unnormalized generated settings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Inject
  participant GenerateProfileOverlay
  participant SharedPromptFileRef
  participant OpenCodeSettings
  Inject->>GenerateProfileOverlay: pass settingsPath
  GenerateProfileOverlay->>SharedPromptFileRef: build phase reference
  SharedPromptFileRef-->>GenerateProfileOverlay: return relative {file:...}
  GenerateProfileOverlay->>OpenCodeSettings: write overlay
  Inject->>SharedPromptFileRef: build inlined prompt reference
  SharedPromptFileRef-->>Inject: return relative {file:...}
Loading

Possibly related PRs

Suggested labels: type:bug

Suggested reviewers: alan-thegentleman, andresnator, danielgap, alexandervazquez98, lu149

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: using relative SDD prompt paths for OpenCode settings.
Linked Issues check ✅ Passed The code now builds shared prompt refs relative to settingsPath and updates tests accordingly, matching issue #723's portability goal.
Out of Scope Changes check ✅ Passed The changes stay focused on OpenCode prompt path portability and related test updates, with no clear unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@decode2 decode2 force-pushed the fix/issue-723-relative-prompt-paths-v2 branch from ff49243 to 2242051 Compare July 13, 2026 18:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/components/sdd/profiles_test.go (1)

778-797: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert portability independently of the production helper.

The test computes expectedRef with the same SharedPromptFileRef used by GenerateProfileOverlay, so a regression that reintroduces absolute home paths can make both sides agree. Also assert that generated references are relative and contain no home path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/components/sdd/profiles_test.go` around lines 778 - 797, Update the
test around GenerateProfileOverlay and its phase loop to validate portability
independently of SharedPromptFileRef: assert each generated prompt reference is
relative and does not contain the home path before or alongside comparing
expectedRef. Keep the existing expected-reference comparison, but ensure the
assertions would fail if GenerateProfileOverlay emits an absolute home-based
path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/components/sdd/profiles_test.go`:
- Around line 778-797: Update the test around GenerateProfileOverlay and its
phase loop to validate portability independently of SharedPromptFileRef: assert
each generated prompt reference is relative and does not contain the home path
before or alongside comparing expectedRef. Keep the existing expected-reference
comparison, but ensure the assertions would fail if GenerateProfileOverlay emits
an absolute home-based path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 917aaee2-f391-4db7-843a-71f771119398

📥 Commits

Reviewing files that changed from the base of the PR and between ff49243 and 2242051.

⛔ Files ignored due to path filters (1)
  • testdata/golden/sdd-opencode-multi-settings.golden is excluded by !testdata/**
📒 Files selected for processing (9)
  • internal/cli/sync_test.go
  • internal/components/golden_test.go
  • internal/components/sdd/inject.go
  • internal/components/sdd/inject_test.go
  • internal/components/sdd/profiles.go
  • internal/components/sdd/profiles_lifecycle_test.go
  • internal/components/sdd/profiles_test.go
  • internal/components/sdd/prompts.go
  • internal/components/sdd/prompts_test.go

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.

fix(opencode): avoid absolute prompt paths in generated settings

1 participant