Repository navigation
fix(opencode): resolve absolute and ~/ {file:} prompt references on import - #3907
Merged
Merged
Conversation
…mport
OpenCode resolves a {file:...} path relative to the config file's
directory, as written when absolute, or from the home directory when it
starts with ~/. Import only handled the relative form, so absolute and
~/ references were joined onto the config directory and kept as literal
text. Resolve them like OpenCode; the project-scope containment check
still applies to the resolved path.
Refs #3619
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
… an outside file
Use the getHomeDirectory vi.mock pattern from the testing guidelines
instead of stubbing HOME_DIR, and add a regression test that an absolute
{file:} reference to a link inside the project pointing outside it is
kept literal under project-scope containment.
Refs #3619
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…w-followups # Conflicts: # src/generated/docs-content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3619
Summary
OpenCode resolves a
{file:...}path relative to the config file's directory, as written when it is absolute, or from the home directory when it starts with~/(OpenCode config docs, "Files"). Rulesync's import of inline OpenCode agents only handled the relative form: absolute and~/references were joined onto the config directory, never found, and kept as literal{file:...}text in the imported subagent body.This PR resolves those two forms the way OpenCode does (
resolveOpencodeFileTemplatePathinsrc/features/opencode-config.ts). In project scope the existing containment check still runs on the resolved path, so an absolute or~/reference that points outside the project is still refused (kept literally, with a warning). An absolute reference inside the project is now read. Global scope is still unrestricted.docs/reference/file-formats.md(and the generated docs content) now says so.This was one of the "found in review (low)" items in the latest status comment on #3619.
Status of the other remaining items in #3619
installcloning afile://source declared in a committedrulesync.jsonc: already fixed onmainby 5e9aecb (assertInstallableSourcesinsrc/mcp/install.tschecks everyfile://source the config declares).publish.ymlworkflow_rungate and the Draft Release agent's permissions (workflow edits); lock downgrade within the ref's history and whetherfetchshould adoptassertNoSymlinkBelowRoot(design decisions); the all-tools*downgrade insingle-action-collapse.ts; in-project link targets still being followed (.gitignore -> .git/config,{file:.env}), a policy question; and the warning for a{file:}refused in a config layer that a later layer overrides (cosmetic).Tests
src/features/opencode-config.test.ts: an absolute reference resolves; a~/reference resolves from the home directory; with a containment root, an absolute reference inside the project is read, and~/or absolute references outside it are kept literally.pnpm cicheck: all passed.src/utils/glob.test.tstimed out once under the full parallel run and passed when rerun on its own (a known timing flake). Content checks were rerun after committing.🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4