Elffuss BraidHub

kikocis/continue public

main · 4.3 KiBRenderedRawPermalink
1# Permissions
2
3## Permission types
4
5To 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
13There 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
151. **Mode policies** (highest priority - see [modes.md](./modes.md))
162. Command line flags (`--allow`, `--ask`, `--exclude`)
173. Permissions in `config.yaml` / configuration
184. Permissions in `~/.continue/permissions.yaml`
195. 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
29We 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
35Note that for an `exclude` policy, it doesn't make sense to have argument matching.
36
37## Command line flags
38
39Each 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
43cn --allow Read --ask Write --exclude Bash
44
45# Start in plan mode (read-only tools only)
46cn --readonly "Help me understand this codebase"
47
48# Use mode switching during chat
49cn "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
56This should not be implemented yet.
57:::
58
59To 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
62permissions:
63 allow:
64 - Read(*)
65
66 ask:
67 - Write(**/*.py)
68
69 exclude:
70 - Write
71```
72
73## `~/.continue/permissions.yaml` (personal settings)
74
75It 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"
78allow:
79 - Read(*)
80
81ask:
82 - Write(**/*.py)
83
84exclude:
85 - Write
86```
87
88Except 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
90This file should be created the first time that the CLI starts.
91
92## Headless mode permissions
93
94When 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
99To 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
103cn -p --allow write_file "Write a hello world script"
104
105# Headless mode with wildcard permission (allow all tools)
106cn -p --allow "*" "Write and run a script"
107
108# Headless mode with specific restrictions
109cn -p --exclude run_terminal_command "Clean up the codebase"
110```
111
112This approach ensures that headless mode is secure by default while providing clear guidance on how to enable the needed permissions.