Skip to content

fix(resolve-file-uri): remove project boundary check for prompt file:// URIs#3752

Open
nerored wants to merge 1 commit intocode-yeongyu:devfrom
nerored:fix/remove-project-boundary-for-file-uris
Open

fix(resolve-file-uri): remove project boundary check for prompt file:// URIs#3752
nerored wants to merge 1 commit intocode-yeongyu:devfrom
nerored:fix/remove-project-boundary-for-file-uris

Conversation

@nerored
Copy link
Copy Markdown

@nerored nerored commented May 1, 2026

Summary

Remove the isWithinProject boundary restriction from resolvePromptAppend() so that file:// prompt URIs behave as documented — supporting absolute, home-relative (~/), and project-relative paths — instead of being silently rejected with a [WARNING: Path rejected: ...] placeholder.

Root Cause

Since commit 9865978 ("fix(security): confine file resolution to project roots"), resolvePromptAppend() has called isWithinProject(filePath, configDir ?? process.cwd()) and rejected any path that resolves outside the current working directory or config directory.

This contradicts the configuration reference which explicitly documents support for all three forms:

Paths can be absolute (file:///abs/path), relative to project root (file://./rel/path), or home-relative (file://~/home/path).

The same documentation also describes cross-project prompt sharing as a primary motivation for file:// support. The boundary check makes this impossible when the prompt file lives in a shared global directory (e.g. ~/.config/opencode/prompts/).

The check was added for security, but prompt and prompt_append are user-configured fields — the user is deliberately pointing to a file they want loaded into the agent prompt. Other parts of the codebase (skill loader, config discovery) already have their own isWithinProject guards where project isolation is genuinely needed.

Changes

File Change
src/agents/builtin-agents/resolve-file-uri.ts Remove isWithinProject import, log import, and the boundary check block.
src/agents/builtin-agents/resolve-file-uri.test.ts Remove 3 rejection tests, add 1 cross-boundary test, update home-directory test.

Verification

bun test src/agents/builtin-agents/resolve-file-uri.test.ts  → 8 pass / 0 fail
bun test src/agents/sisyphus-junior/index.test.ts             → 47 pass / 0 fail
bun run typecheck                                              → clean

Related


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Summary by cubic

Remove the project boundary check from resolvePromptAppend() so file:// prompt URIs can load absolute, home (~/), and project‑relative files as documented. This removes false “[WARNING: Path rejected]” and enables cross‑project prompt sharing.

  • Bug Fixes
    • Removed project-root restriction in resolvePromptAppend() so absolute paths load regardless of configDir.
    • Kept warnings for malformed URIs and missing files; updated tests to remove boundary‑rejection cases and add cross‑boundary/home‑dir success cases.

Written for commit 0152818. Summary will update on new commits.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@nerored
Copy link
Copy Markdown
Author

nerored commented May 1, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 1, 2026
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Removing a security boundary check (isWithinProject) previously added to prevent arbitrary file access is a security regression, even if it aligns with documentation.

…// URIs

Remove the `isWithinProject` boundary restriction from `resolvePromptAppend()`
so that `file://` prompt URIs behave as documented — supporting absolute,
home-relative (`~/`), and project-relative paths — instead of being silently
rejected with a warning placeholder.

Since commit 9865978 ("fix(security): confine file resolution to project
roots"), `resolvePromptAppend()` called `isWithinProject(filePath, configDir ??
process.cwd())` and rejected any path outside the current working directory or
config directory.  This contradicts the configuration reference which explicitly
lists absolute, relative, and home-relative forms as supported.  Users following
the documented examples receive a silent `[WARNING: Path rejected: ...]`
placeholder instead of their intended prompt content.

The boundary check was originally added for security, but `prompt` and
`prompt_append` are user-configured fields — the user is deliberately pointing
to a file they want loaded into the agent prompt.  The check prevents legitimate
cross-project prompt sharing, a use case the documentation describes as a
primary motivation for `file://` support.

Fixes the root cause behind code-yeongyu#3554.

Changes:
- resolve-file-uri.ts: remove `isWithinProject` import, `log` import, and the
  boundary check block (projectRoot declaration + if-statement + log + return).
- resolve-file-uri.test.ts: remove 3 rejection tests that enforced the boundary;
  add a test verifying absolute paths load regardless of configDir; update the
  home-directory test to expect success; remove the now-unused symlink fixture.

Test: resolve-file-uri 8 pass / 0 fail, sisyphus-junior 47 pass / 0 fail.
Typecheck: clean.
@nerored nerored force-pushed the fix/remove-project-boundary-for-file-uris branch from 8a50740 to 0152818 Compare May 1, 2026 16:54
nerored pushed a commit to nerored/oh-my-openagent that referenced this pull request May 1, 2026
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