Skip to content

fix(opencode): resolve absolute and ~/ {file:} prompt references on import - #3907

Merged
dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3619-low-followups
Nov 20, 2026
Merged

dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3619-low-followups

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

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 (resolveOpencodeFileTemplatePath in src/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

  • MCP install cloning a file:// source declared in a committed rulesync.jsonc: already fixed on main by 5e9aecb (assertInstallableSources in src/mcp/install.ts checks every file:// source the config declares).
  • Still open, for the maintainer: the publish.yml workflow_run gate and the Draft Release agent's permissions (workflow edits); lock downgrade within the ref's history and whether fetch should adopt assertNoSymlinkBelowRoot (design decisions); the all-tools * downgrade in single-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

  • New unit tests in 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.ts timed 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

dyoshikawa and others added 3 commits November 20, 2026 08:50
…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
@dyoshikawa
dyoshikawa merged commit ea93aa6 into main Nov 20, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3619-low-followups branch November 20, 2026 00:32
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.

1 participant