Skip to content

fix(opencode): Use standard resolve function to get proper filePaths for tools#18761

Open
OpeOginni wants to merge 1 commit intoanomalyco:devfrom
OpeOginni:fix/perms-system-file-path
Open

fix(opencode): Use standard resolve function to get proper filePaths for tools#18761
OpeOginni wants to merge 1 commit intoanomalyco:devfrom
OpeOginni:fix/perms-system-file-path

Conversation

@OpeOginni
Copy link
Contributor

@OpeOginni OpeOginni commented Mar 23, 2026

Issue for this PR

Closes #18762

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When setting permissions for tools in a project that does not have git initialised, it gets the paths of files relative to its worktree, and for non-git projects the worktree is always /, this breaks permissions as the filePath is not going to be what the Permission Rule expects.

So this PR adds a check if the worktree is / then go ahead to use the Instance directory. It also moves the resolve logic to its own file, so tools can all import from it, this makes the codebase a bit cleaner since all tools use the same logic.

How did you verify your code works?

I tested with the case the user had an issue with, for both a non-git project and a git project, it works as it should.

Also added regression tests to the tools affected. The fixes makes them all pass

Screenshots / recordings

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 23, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot added needs:issue contributor and removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Mar 23, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues with Tool Permissions in Non Git Projects

1 participant