Skip to content

Non-git projects use "/" as worktree, breaking permission path resolution #24694

Description

@d7pow

Description

Problem

When running in a non-git directory, Project.fromDirectory sets:

worktree: "/"
sandbox: "/"

This causes permission path resolution to break.

Example:

path.relative("/", "/home/.../artifacts/dry_run/file.md")
→ "home/.../artifacts/dry_run/file.md"

This does not match patterns like:

artifacts/dry_run/*

Impact

Even with a typical ruleset like:

edit:
"": "deny"
"artifacts/dry_run/
": "allow"

the allow rule never matches, because the evaluated path becomes:

home/.../artifacts/dry_run/...

So the final result is a deny, even though the config is correct.

Expected behavior

Non-git directories should treat the current directory as the project root:

worktree: directory
sandbox: directory

Plugins

None

OpenCode version

1.14.28

Steps to reproduce

Steps to reproduce

  1. Create a non-git directory (no .git folder)

  2. Create an opencode config with path-scoped permissions, for example:

edit:
"": "deny"
"artifacts/dry_run/
": "allow"

  1. Start opencode in that directory

  2. Attempt to create a file:

Create artifacts/dry_run/test.md

  1. Observe that the operation is denied

What happens

The evaluated path becomes:

home/.../artifacts/dry_run/test.md

instead of:

artifacts/dry_run/test.md

So the allow rule does not match and the deny rule applies.

Expected

The file should be created successfully because it matches the allow rule.

Screenshot and/or share link

No response

Operating System

Debian GNU/Linux 13 (trixie)

Terminal

Konsole Version 25.04.2

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions