| 1 | # Permissions |
| 2 | |
| 3 | ## Permission types |
| 4 | |
| 5 | To make sure that users can oversee the actions of the LLM, we implement a permissions system. Every tool has one of the following permissions: |
| 6 | |
| 7 | - `allow`: The tool will be automatically called without asking |
| 8 | - `ask`: We will ask the user before calling the tool, giving them the options to accept or reject |
| 9 | - `exclude`: This tool will be completely excluded, so the model won't even know it exists |
| 10 | |
| 11 | ## Rule precedence |
| 12 | |
| 13 | There is a default set of permissions for the builtin tools in [`src/permissions/defaultPolicies.ts`](../src/permissions/defaultPolicies.ts). But these policies can be overriden by multiple layers. The order of precedence is as follows, which the earlier items taking precedence: |
| 14 | |
| 15 | 1. **Mode policies** (highest priority - see [modes.md](./modes.md)) |
| 16 | 2. Command line flags (`--allow`, `--ask`, `--exclude`) |
| 17 | 3. Permissions in `config.yaml` / configuration |
| 18 | 4. Permissions in `~/.continue/permissions.yaml` |
| 19 | 5. Default policies |
| 20 | |
| 21 | **Note:** Mode policies **completely override all other permission settings** in plan and auto modes. Available modes: |
| 22 | |
| 23 | - `normal`: No mode policies (uses existing configuration) |
| 24 | - `plan`: **Absolute override** - excludes all write tools, allows only read tools (ignores user config) |
| 25 | - `auto`: **Absolute override** - allows all tools without asking (ignores user config) |
| 26 | |
| 27 | ## Tool matching patterns |
| 28 | |
| 29 | We use a tool matching pattern to match tools to permissions. This format looks like the following: |
| 30 | |
| 31 | - `Read` matches any call to the `Read` tool |
| 32 | - `Read(*)` also matches any call to the `Read` tool |
| 33 | - `Read(**/*.ts)` matches any call to the `Read` tool where the primary parameter matches the glob pattern `**/*.ts`. |
| 34 | |
| 35 | Note that for an `exclude` policy, it doesn't make sense to have argument matching. |
| 36 | |
| 37 | ## Command line flags |
| 38 | |
| 39 | Each of the `--allow`, `--ask`, and `--exclude` flags allow you to set the permission for a tool. Usage must be a "tool matching pattern" as described above for each flag, with each providing a policy that will be added to the list of policies in order. |
| 40 | |
| 41 | ```bash |
| 42 | # Allow Read, Ask Write, and Exclude Bash |
| 43 | cn --allow Read --ask Write --exclude Bash |
| 44 | |
| 45 | # Start in plan mode (read-only tools only) |
| 46 | cn --readonly "Help me understand this codebase" |
| 47 | |
| 48 | # Use mode switching during chat |
| 49 | cn "Let me work on this feature" # Starts in normal mode |
| 50 | # Then use Shift+Tab to cycle through modes |
| 51 | ``` |
| 52 | |
| 53 | ## `config.yaml` / Configuration (implement later) |
| 54 | |
| 55 | ::: info |
| 56 | This should not be implemented yet. |
| 57 | ::: |
| 58 | |
| 59 | To let users define their permissions as a part of their custom assistant, they can do so in the permissions section of `config.yaml` or their configuration: |
| 60 | |
| 61 | ```yaml |
| 62 | permissions: |
| 63 | allow: |
| 64 | - Read(*) |
| 65 | |
| 66 | ask: |
| 67 | - Write(**/*.py) |
| 68 | |
| 69 | exclude: |
| 70 | - Write |
| 71 | ``` |
| 72 | |
| 73 | ## `~/.continue/permissions.yaml` (personal settings) |
| 74 | |
| 75 | It would be frustrating for users to have to set the same permissions across all of their assistants, so we provide them a file for personal settings. It should be basically equivalent to the `permissions` section of `config.yaml`: |
| 76 | |
| 77 | ```yaml title="~/.continue/permissions.yaml" |
| 78 | allow: |
| 79 | - Read(*) |
| 80 | |
| 81 | ask: |
| 82 | - Write(**/*.py) |
| 83 | |
| 84 | exclude: |
| 85 | - Write |
| 86 | ``` |
| 87 | |
| 88 | Except that it's important to understand that this file is _not_ intended to be edited by the user. It is only for persistence, and users should interact with their permissions by using the TUI. |
| 89 | |
| 90 | This file should be created the first time that the CLI starts. |
| 91 | |
| 92 | ## Headless mode permissions |
| 93 | |
| 94 | When running in headless mode (using the `-p` or `--print` flag), the CLI uses the same default policies as normal mode, but with different behavior for tools that require confirmation: |
| 95 | |
| 96 | - **Normal mode**: Write operations and terminal commands require confirmation (`ask`) - user is prompted |
| 97 | - **Headless mode**: Same default policies, but tools requiring confirmation (`ask`) will cause the process to exit with an error message |
| 98 | |
| 99 | To use tools that normally require confirmation in headless mode, you must explicitly allow them: |
| 100 | |
| 101 | ```bash |
| 102 | # Headless mode with explicit permissions for write operations |
| 103 | cn -p --allow write_file "Write a hello world script" |
| 104 | |
| 105 | # Headless mode with wildcard permission (allow all tools) |
| 106 | cn -p --allow "*" "Write and run a script" |
| 107 | |
| 108 | # Headless mode with specific restrictions |
| 109 | cn -p --exclude run_terminal_command "Clean up the codebase" |
| 110 | ``` |
| 111 | |
| 112 | This approach ensures that headless mode is secure by default while providing clear guidance on how to enable the needed permissions. |