Skip to content

Conversation

@Mishkun
Copy link

@Mishkun Mishkun commented Oct 30, 2025

I've vibed a solution for my issue (#3218). I thought it might be cool to have a more granular control, so added bash-like complex permission for external files.

Claude overview:

Changes

Tool Updates

  • Read Tool: Added permission check for files outside working directory
  • Write Tool: Added permission check before file creation/modification
  • Edit Tool: Added permission check for external file edits
  • Patch Tool: Added permission check for all file operations in patches

Configuration Examples

Simple Permission

{
  "permission": {
    "external_files": "ask"
  }
}

Pattern-Based (Monorepo)

{
  "permission": {
    "external_files": {
      "*/docs/*": "allow",
      "*/packages/*/README.md": "allow",
      "*/node_modules/*": "deny",
      "*": "ask"
    }
  }
}

Per-Agent Configuration

{
  "agent": {
    "build": {
      "permission": {
        "external_files": "allow"
      }
    }
  }
}

Closes #3218

- Add external_files permission to config schema (top-level and per-agent)
- Update agent permission schema with external_files support
- Implement permission checks in read, write, edit, and patch tools
- Add pattern-based permission matching using Wildcard.all()
- Default to 'ask' for security, support 'allow' and 'deny'
- Add TUI display support for external_files permission prompts
- Create comprehensive tests for all file tools
- Maintain backward compatibility with bypassCwdCheck

Closes sst#3218
@Mishkun
Copy link
Author

Mishkun commented Oct 30, 2025

Oops, PR was meant to be a draft here. Need to check all of the functionality by hand

@Mishkun Mishkun marked this pull request as draft October 30, 2025 22:01
…terns

- Add expandPermissionPatterns utility to handle path expansion
- Support tilde (~) expansion to home directory
- Support relative paths (../, ./) resolved from Instance.directory
- Preserve wildcards in patterns while expanding base paths
- Update all file tools (read, write, edit, patch) to use path expansion
- Add comprehensive tests for path expansion utility

This fixes the issue where permission patterns like '~/projects/*' and '../docs/*'
were not matching because they weren't expanded before wildcard comparison.
@Mishkun
Copy link
Author

Mishkun commented Nov 2, 2025

I'll provide new pr compatible with opentui migration

@Mishkun Mishkun closed this Nov 2, 2025
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.

Feature request: ability to disable "File X is not in the current working directory" error

1 participant