Skip to content

fix(project): use directory root for non-git projects - #33668

Closed
lin-hongkuan wants to merge 1 commit into
anomalyco:devfrom
lin-hongkuan:nongit-project-root
Closed

lin-hongkuan wants to merge 1 commit into
anomalyco:devfrom
lin-hongkuan:nongit-project-root

Conversation

@lin-hongkuan

Copy link
Copy Markdown

Issue for this PR

Closes #24694

Type of change

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

What does this PR do?

When ProjectV2.resolve() returns no VCS, Project.fromDirectory() was using / as the global project worktree/sandbox. That makes tool permission paths relative to the filesystem root, so a project file such as src/secret.ts can be checked as a long root-relative path fragment instead of the project-relative rule users configured.

This keeps git behavior unchanged, but normalizes the opened directory once and uses it as the non-git worktree/sandbox. containsPath() keeps its / guard for legacy persisted rows so old data cannot make the filesystem root count as in-project.

Regression coverage now checks that:

  • Project.fromDirectory() returns the opened directory for non-git worktree/sandbox.
  • InstanceStore.load() exposes the opened directory as the non-git instance worktree.
  • Read permission requests in non-git projects use project-relative paths like src/secret.ts.

How did you verify your code works?

  • bun test test/project/project.test.ts
  • bun test test/project/instance.test.ts
  • bun test test/tool/read.test.ts
  • bun run typecheck
  • git diff --check

Screenshots / recordings

Not applicable, no UI change.

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@weikengchen

Copy link
Copy Markdown

I think this issue should be reopened (though I don't know how to inform the developers). I encountered this issue a lot, and this is exactly why on macOS, opencode frequently caused me to see a bunch of permission windows because the AI agent (in my case, it is Grok) would grep over the user root directory, and it is a very annoying experience.

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.

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

2 participants