@tencent-ai/codebuddy-code 2.105.0 → 2.105.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,25 @@
1
- # Permission Rules (Permissions)
1
+ # Permission Rules
2
2
 
3
3
  > Precisely constrain what CodeBuddy Code can do with fine-grained allow / ask / deny rules, Permission Modes, and layered settings. Rules can be committed to the repository and shared with the team, or overridden locally by developers.
4
4
 
5
5
  ## Permission System Overview
6
6
 
7
- CodeBuddy Code uses a layered evaluation mechanism to balance capability and security. Before the main agent executes any tool call, it passes through the permission service (`tool-permission-service.ts::checkToolPermission`). Eight phases are evaluated in order:
7
+ CodeBuddy Code uses a layered evaluation mechanism to balance capability and security. Before each tool call, the following eight phases are evaluated in order:
8
8
 
9
9
  | Phase | Check | Behavior on match |
10
10
  | :---- | :---- | :---------------- |
11
11
  | 1 | **Deny rules** | Reject immediately, with the highest priority |
12
12
  | 2 | **Trusted Allow rules** (user / cli / flag / session / policy / project under a trusted directory / `--allowedTools`) | Allow immediately, and **can bypass command safety checks** |
13
- | 3 | **Command safety check** (`checkCommandSafety`, interactive only) | Force confirmation for high-risk / dangerous commands |
13
+ | 3 | **Command safety check** (interactive only) | Force confirmation for high-risk / dangerous commands |
14
14
  | 4 | **Ask rules** | Force confirmation |
15
15
  | 5 | **Bypass mode short-circuit** | Allow directly in `bypassPermissions` mode; downgrade to default when `disableBypassPermissionsMode` is enabled |
16
16
  | 6 | **Untrusted Allow rules** (project / local outside trusted directories, plus command / sandbox sources) | Allow, but **cannot bypass command safety checks** |
17
- | 7 | **Permission Mode strategy** (`tool-permission-strategy.ts`) | Decide whether approval is required based on the current [PermissionMode](permission-modes.md) |
17
+ | 7 | **Permission Mode strategy** | Decide whether approval is required based on the current [Permission Mode](permission-modes.md) |
18
18
  | 8 | dontAsk / async agent fallback | Convert `ask` to `deny` in print / async agent scenarios to avoid deadlock |
19
19
 
20
- > **Key point**: deny always takes precedence, and allow is split into two layers: "trusted" and "untrusted". Before the project root is listed as a trusted directory, allow rules in `.codebuddy/settings.json` **cannot bypass the command safety gate**. This differs from cc and is designed to prevent malicious repositories from bypassing local safety protections by pushing their own settings into team PRs.
20
+ > **Key point**: deny always takes precedence, and allow is split into two layers: "trusted" and "untrusted". Before the project root is listed as a trusted directory, allow rules in `.codebuddy/settings.json` **cannot bypass the command safety gate**. This is designed to prevent malicious repositories from bypassing local safety protections by pushing their own settings into team PRs.
21
21
 
22
- Read-only tools (Read / Grep / Glob, etc.) do not prompt for approval by default inside trusted directories. Editing tools and Bash always go through the full phase chain. See `tool-permission-strategy.ts::ToolPermissionDefaultStrategy` and `permission-utils.ts::isArgsInTrustedDirectories` for details.
22
+ Read-only tools (Read / Grep / Glob, etc.) do not prompt for approval by default inside trusted directories. Editing tools and Bash always go through the full phase chain.
23
23
 
24
24
  ## Three Rule Behaviors
25
25
 
@@ -43,7 +43,7 @@ The three arrays under the `permissions` object correspond to three behaviors:
43
43
 
44
44
  ### `/permissions` command
45
45
 
46
- Enter `/permissions` in a session to open the permission management panel (implemented in `permissions-command-executor.ts`). You can view all current allow / ask / deny rules, which settings layer they come from, and temporarily add or remove them (written to the user, project, or project-local scope).
46
+ Enter `/permissions` in a session to open the permission management panel. You can view all current allow / ask / deny rules, which settings layer they come from, and temporarily add or remove them (written to the user, project, or project-local scope).
47
47
 
48
48
  When **"Yes, don't ask again"** is selected in the dialog, CodeBuddy writes the most stable prefix for the current command into the `allow` array of the corresponding scope's settings.
49
49
 
@@ -56,8 +56,6 @@ When **"Yes, don't ask again"** is selected in the dialog, CodeBuddy writes the
56
56
  | `--add-dir <path>` | Add an extra directory to the trusted directory scope (affects whether Read requires confirmation) |
57
57
  | `-y` / `--dangerously-skip-permissions` | Equivalent to `--permission-mode bypassPermissions` |
58
58
 
59
- Definitions are in `cli-provider.ts:40-55`.
60
-
61
59
  ### Configuration Files
62
60
 
63
61
  See [Settings Configuration](settings.md) for details. CodeBuddy merges these four scopes:
@@ -69,8 +67,6 @@ See [Settings Configuration](settings.md) for details. CodeBuddy merges these fo
69
67
  | project-local | `<repo>/.codebuddy/settings.local.json` (not committed to git, local override) |
70
68
  | cliArg / flagSettings / session / policySettings | Process state, not persisted to disk |
71
69
 
72
- See `tool-permission-service.ts:647-741` for the merge implementation.
73
-
74
70
  ## Rule Syntax
75
71
 
76
72
  Rule form: `Tool` or `Tool(specifier)`.
@@ -86,7 +82,7 @@ Remove the parentheses to match all calls to a tool:
86
82
  | `Read` | All file reads |
87
83
  | `Edit` | All file edits |
88
84
 
89
- `*` can also be used as a standalone rule (`permission-utils.ts:194` treats it as a full-match wildcard).
85
+ `*` can also be used as a standalone rule, equivalent to a full-match wildcard.
90
86
 
91
87
  ### Add a Specifier for Fine-Grained Matching
92
88
 
@@ -108,22 +104,22 @@ Write arguments inside the parentheses:
108
104
 
109
105
  ### Bash
110
106
 
111
- Bash rules support three syntax forms (implemented in `permission-utils.ts::matchSingleCommandAgainstPattern`, lines `414-450`):
107
+ Bash rules support three syntax forms:
112
108
 
113
109
  | Syntax | Meaning | Example |
114
110
  | :----- | :------ | :------ |
115
111
  | Exact match | The pattern is exactly equal to the command | `Bash(npm run build)` only matches `npm run build` |
116
112
  | `:*` prefix | The pattern ends with `:*` → matches the first word / multi-word prefix of the command | `Bash(git:*)` matches `git status` / `git push origin main` |
117
- | Wildcard | When the pattern contains `*`, use picomatch bash mode (**`*` can cross `/`**) | `Bash(npm run *)` matches `npm run build`; `Bash(ls *)` matches `ls -al /tmp/x` |
113
+ | Wildcard | When the pattern contains `*`, matches as a bash glob pattern (**`*` can cross `/`**) | `Bash(npm run *)` matches `npm run build`; `Bash(ls *)` matches `ls -al /tmp/x` |
118
114
 
119
- > Unlike minimatch, cbc deliberately enables `bash: true` for Bash wildcard mode so that `*` can cross `/`. Otherwise, `ls *` could not match `ls -al /xxx`, which is one of the most common pitfalls for users (see the comments in `permission-utils.ts:441-446`).
115
+ > The wildcard mode deliberately lets `*` cross `/`. Otherwise, `ls *` could not match `ls -al /xxx`, which is one of the most common pitfalls for users.
120
116
 
121
117
  #### Compound Commands
122
118
 
123
- CodeBuddy uses `CommandParserService` (priority: tree-sitter > shell-quote > regex fallback; see `permission-utils.ts:357-378`) to parse shell operators `&&` / `||` / `;` / `|`, and evaluates each subcommand independently:
119
+ CodeBuddy parses shell operators `&&` / `||` / `;` / `|` and evaluates each subcommand independently:
124
120
 
125
- - **deny / ask rules**: trigger if any subcommand matches (`matchCommandRule`, lines `305-334`)
126
- - **allow rules**: require **all subcommands to match** before allowing (`isCommandAllowed`, lines `478-500`). This is a different trade-off from cc: a compound command with one matching and one non-matching subcommand will still ask for approval, preventing attackers from hiding dangerous commands next to allowed ones
121
+ - **deny / ask rules**: trigger if any subcommand matches
122
+ - **allow rules**: require **all subcommands to match** before allowing a compound command with one matching and one non-matching subcommand will still ask for approval, preventing attackers from hiding dangerous commands next to allowed ones
127
123
 
128
124
  Example:
129
125
 
@@ -137,11 +133,11 @@ git status; rm * → ask (same as above)
137
133
 
138
134
  #### Redirection
139
135
 
140
- Commands containing `>` / `<` / `>>` / `<<` / `&>` require an **exact match** under allow rules (`permission-utils.ts:482-485`); wildcard rules do not apply.
136
+ Commands containing `>` / `<` / `>>` / `<<` / `&>` require an **exact match** under allow rules; wildcard rules do not apply.
141
137
 
142
138
  ### Read / Edit / Write
143
139
 
144
- File rules use `minimatch` for glob matching and perform three layers of path normalization (`permission-utils.ts::matchFileRule` and `normalizePath`, lines `241-268`):
140
+ File rules use glob matching and perform three layers of path normalization:
145
141
 
146
142
  | pattern | Explanation | Example |
147
143
  | :------ | :---------- | :------ |
@@ -150,12 +146,12 @@ File rules use `minimatch` for glob matching and perform three layers of path no
150
146
  | `/path` | Starting from the project root | `Edit(/src/**/*.ts)` |
151
147
  | `path` or `./path` | Starting from the current working directory | `Read(.env)` |
152
148
 
153
- Matching options: `dot: true` (allow dotfiles), `nocase: true` (case-insensitive), `matchBase: true` (bare filenames can match at any depth).
149
+ Matching options: dotfiles allowed, case-insensitive, bare filenames can match at any depth.
154
150
 
155
151
  Notes:
156
152
 
157
153
  - deny rules such as `Edit(.git/**)` block all attempts through Edit / Write / NotebookEdit, but **do not block** indirect paths through Bash such as `python -c 'open(".git/config", "w")...'`. OS-level protection depends on [Bash sandboxing](bash-sandboxing.md)
158
- - Read rules are also intercepted and parsed for some Bash file-read commands (`cat`, `head`, `tail`, etc.; see the special handling for these commands inside `command-utils.ts::checkCommandSafety`)
154
+ - Read rules are also intercepted and parsed for some Bash file-read commands (`cat`, `head`, `tail`, etc.)
159
155
 
160
156
  ### WebFetch
161
157
 
@@ -164,7 +160,7 @@ WebFetch # any URL
164
160
  WebFetch(domain:example.com) # only example.com and its subdomains
165
161
  ```
166
162
 
167
- The matching implementation is in `permission-utils.ts::matchURLRule` (line `515`) and supports the `domain:` prefix for hostname matching.
163
+ Supports the `domain:` prefix for hostname matching (including subdomains).
168
164
 
169
165
  ### MCP Tools
170
166
 
@@ -176,7 +172,7 @@ MCP tools are named in the format `mcp__<server>__<tool>`. Rules support three g
176
172
  | `mcp__puppeteer__*` | Same as above (wildcard form) |
177
173
  | `mcp__puppeteer__navigate` | Only the navigate tool |
178
174
 
179
- Starting from `tool-permission-service.ts:152`, the code checks `tool.name.startsWith('mcp__')` and enters the MCP-specific branch.
175
+ Tool names starting with `mcp__` are matched as MCP rules.
180
176
 
181
177
  ### Agent (Subagent)
182
178
 
@@ -206,7 +202,7 @@ After being denied, that `subagent_type` will be rejected when the main agent in
206
202
  }
207
203
  ```
208
204
 
209
- Skill rules **must** be exact matches (`permission-utils.ts::matchSkillRule`, lines `458-464`); wildcards are not supported.
205
+ Skill rules **must** be exact matches; wildcards are not supported.
210
206
 
211
207
  ## Trusted Directories
212
208
 
@@ -221,22 +217,22 @@ Several ways to expand the trusted scope:
221
217
  | `permissions.additionalDirectories` setting | Persistent |
222
218
  | `permissions.trustedDirectories` setting | Persistent |
223
219
 
224
- Implementation: `permission-utils.ts:561-583`. Trusted directory list = `workspace root + settings.trustedDirectories + session.options.addDir`.
220
+ The effective trusted directory list = workspace root + `settings.trustedDirectories` + directories added at startup with `--add-dir` or in-session with `/add-dir`.
225
221
 
226
- > Both `--add-dir` and `permissions.additionalDirectories` only grant **file access**. They **do not** make CodeBuddy load `.codebuddy/` configuration from those directories (agents / hooks / settings, etc. still use the startup directory). This matches cc behavior.
222
+ > Both `--add-dir` and `permissions.additionalDirectories` only grant **file access**. They **do not** make CodeBuddy load `.codebuddy/` configuration from those directories (agents / hooks / settings, etc. still use the startup directory).
227
223
 
228
224
  ### Project Directory Trust Switch
229
225
 
230
- Whether you have "explicitly trusted" a repository directory also affects the trust level of allow rules (`tool-permission-service.ts:182`). When the directory is **not trusted**:
226
+ Whether you have "explicitly trusted" a repository directory also affects the trust level of allow rules. When the directory is **not trusted**:
231
227
 
232
228
  - `allow` rules in `<repo>/.codebuddy/settings.json` and `.codebuddy/settings.local.json` are classified into the **untrusted** layer (Phase 6), and **cannot** bypass command safety checks
233
- - After the user confirms trust in the interactive UI (`directoryTrustService.isTrustDirectory`), project-level rules are promoted to the Phase 2 trusted layer
229
+ - After the user confirms trust in the interactive UI, project-level rules are promoted to the Phase 2 trusted layer
234
230
 
235
- This is a cbc-specific security model designed to reduce lateral risk that can arise immediately after cloning and running a repository.
231
+ This is designed to reduce lateral risk that can arise immediately after cloning and running a repository.
236
232
 
237
233
  ## Protected Files / Paths
238
234
 
239
- In any mode, CodeBuddy adds extra protection for a set of critical paths (overlapping with the [PermissionMode documentation](permission-modes.md#protected-critical-files)):
235
+ In any mode, CodeBuddy adds extra protection for a set of critical paths (matching [Permission Modes](permission-modes.md#protected-critical-files)):
240
236
 
241
237
  - The repository itself: `.git`, `.gitconfig`, `.gitmodules`
242
238
  - Shell configuration: `.bashrc` / `.zshrc` / `.envrc`, etc.
@@ -245,7 +241,7 @@ In any mode, CodeBuddy adds extra protection for a set of critical paths (overla
245
241
  - CodeBuddy itself: `.codebuddy` (except `.codebuddy/worktrees`)
246
242
  - MCP / configuration: `.mcp.json` / `.codebuddy.json`
247
243
 
248
- `bypassPermissions` mode still allows most of these through, but "catastrophic commands" such as `rm -rf /` / `rm -rf ~` are forced to ask through the `isDangerousCommand` fallback (`tool-permission-service.ts:244`).
244
+ `bypassPermissions` mode still allows most of these through, but "catastrophic commands" such as `rm -rf /` / `rm -rf ~` are forced to ask.
249
245
 
250
246
  ## Extending Permissions with Hooks
251
247
 
@@ -274,7 +270,7 @@ Hook exit code semantics:
274
270
 
275
271
  Notes:
276
272
 
277
- - **deny / ask rules always take effect before hooks**. A hook returning `"allow"` cannot bypass deny in settings. This matches cc behavior
273
+ - **deny / ask rules always take effect before hooks**. A hook returning `"allow"` cannot bypass deny in settings
278
274
  - However, **blocking hooks** (exit code 2) can short-circuit allow rules before Phase 1, so you can "allow all Bash first, but use hooks to separately block a few specific commands"
279
275
 
280
276
  ## Working with Sandboxing
@@ -301,9 +297,9 @@ projectSettings > localSettings > command/sandbox sources
301
297
 
302
298
  However, the **evaluation order** is more important than settings priority:
303
299
 
304
- - `deny` arrays are merged from all scopes (`PermissionUtils.mergeRulesFromAllSources`), and **a deny in any scope rejects**
305
- - `allow` arrays are merged twice by "trusted / untrusted": user/cli/flag/session/policy are always included in the trusted merge; project/local are considered trusted only when the directory is trusted
306
- - `disableBypassPermissionsMode` takes effect when it is `"disable"` in any of the four layers: `user / project / local / cliArg` (see `tool-permission-service.ts:670-673`) — this adds a project-level hard-disable channel compared with cc
300
+ - `deny` arrays are merged from all scopes, and **a deny in any scope rejects**
301
+ - `allow` arrays are merged twice by "trusted / untrusted": user / cli / flag / session / policy are always included in the trusted merge; project / local are considered trusted only when the directory is trusted
302
+ - `disableBypassPermissionsMode` takes effect when it is `"disable"` in any of the four layers: user / project / local / CLI startup flag
307
303
 
308
304
  ## Example Configurations
309
305
 
@@ -22,11 +22,14 @@ CodeBuddy Code includes a set of built-in tools to help understand and modify yo
22
22
  | `ImageEdit` | Edits or modifies existing images based on text instructions | Yes |
23
23
  | `ImageGen` | Generates images from text descriptions | Yes |
24
24
  | `LeaveWorktree` | Exits the worktree session and returns to the original directory | Yes |
25
+ | `ListMcpResources` | Lists all resources/templates exposed by connected [MCP servers](mcp.md); optionally filtered by server name | No |
25
26
  | `LSP` | Provides code intelligence via Language Server. Automatically reports type errors and warnings after file edits. Also supports navigation operations such as go-to-definition, find references, get type info, list symbols, find implementations, and trace call hierarchies. Requires a [Code Intelligence Plugin](plugins.md) and its language server binary | No |
26
27
  | `MultiEdit` | Performs multiple edits on the same file in a single atomic operation | Yes |
27
28
  | `NotebookEdit` | Modifies Jupyter notebook cell contents | Yes |
29
+ | `NotebookRead` | Reads Jupyter notebook cell contents; specify `cell_id` to read a single cell | No |
28
30
  | `PowerShell` | Executes PowerShell commands on Windows. Only available on Windows, see [PowerShell Tool Behavior](#powershell-tool-behavior) | Yes |
29
31
  | `Read` | Reads file contents, supporting images, PDFs, and Jupyter notebooks | No |
32
+ | `ReadMcpResource` | Reads the content of a specific MCP resource by server + URI; pairs with `ListMcpResources` | Yes |
30
33
  | `SendMessage` | Sends messages to teammates in an [Agent Team](agent-teams.md) | No |
31
34
  | `Skill` | Executes a [Skill](skills.md) in the main conversation | No |
32
35
  | `SlashCommand` | Executes a custom [slash command](slash-commands.md) | Yes |
@@ -40,8 +43,10 @@ CodeBuddy Code includes a set of built-in tools to help understand and modify yo
40
43
  | `TeamCreate` | Creates an [Agent Team](agent-teams.md) for coordinating multiple agents | No |
41
44
  | `TeamDelete` | Deletes an Agent Team and its task directory | No |
42
45
  | `ToolSearch` | Searches and loads deferred tools, supporting both built-in tools and [MCP tools](mcp.md#deferred-loading-defer_loading) | No |
46
+ | `WaitForMcpServers` | Waits for the specified MCP servers to finish connecting (defaults to all pending servers), with a 5-second timeout | No |
43
47
  | `WebFetch` | Fetches content from a specified URL and performs AI analysis | Yes |
44
48
  | `WebSearch` | Performs a web search | Yes |
49
+ | `Workflow` | Launches a [Dynamic Workflow](workflows.md) asynchronously, returns a runId immediately, and runs in the background; pull results via `TaskOutput` | Yes |
45
50
  | `Write` | Creates or overwrites files | Yes |
46
51
 
47
52
  Permission rules can be configured via the `/permissions` command or in [permission settings](settings.md#permission-settings). See also [Tool-Specific Permission Rules](iam.md#tool-specific-permission-rules).
@@ -104,18 +109,6 @@ The PowerShell tool includes a built-in security checker covering dangerous patt
104
109
 
105
110
  Some tools (such as those provided via [MCP servers](mcp.md)) use deferred loading. These tools do not appear in the initial tool list and must be discovered and activated via `ToolSearch`. Once activated, tools remain available for the rest of the session.
106
111
 
107
- Tools can be configured as deferred via product configuration:
108
-
109
- ```json
110
- {
111
- "tools": {
112
- "ToolName": {
113
- "deferLoading": true
114
- }
115
- }
116
- }
117
- ```
118
-
119
112
  ## See Also
120
113
 
121
114
  * [Identity and Access Management](iam.md): Permission system, rule syntax, and tool-specific rules
@@ -1,9 +1,9 @@
1
- # Dynamic Workflows: Orchestrating Large-Scale Subagents with Scripts
1
+ # Dynamic Workflows
2
2
 
3
3
  > Dynamic Workflows let CodeBuddy write a JavaScript orchestration script that the runtime executes in the background to coordinate dozens or even hundreds of subagents on a task. The script itself is readable, editable, and rerunnable, making it suitable for codebase audits, large migrations, and research tasks that require cross-validation.
4
4
 
5
5
  <Note>
6
- Dynamic Workflows are currently a research preview and require CodeBuddy Code v2.1.154 or later. Enable them with the "Dynamic workflows" toggle in `/config`.
6
+ Dynamic Workflows are currently a research preview and require CodeBuddy Code v2.105.0 or later. They are enabled by default; to turn them off, toggle "Dynamic workflows" in `/config`.
7
7
  </Note>
8
8
 
9
9
  A Dynamic Workflow is a JavaScript script that CodeBuddy writes on the spot for your task. The runtime executes it in the background while your session stays responsive. The script contains one or more [`agent()`](#script-api) calls; each call dispatches an independent subagent to work. After the script receives intermediate results, it can branch, run work in parallel, or dispatch the next batch of subagents.
@@ -81,7 +81,7 @@ CodeBuddy Code includes the following Workflow:
81
81
 
82
82
  | Command | Purpose |
83
83
  | :---------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
84
- | `/deep-research <question>` | Searches, fetches, and cross-validates sources from multiple angles in parallel, votes on each claim, removes parts that fail validation, and outputs a cited report. Requires the [WebSearch tool](tools-reference.md#websearch-tool-behavior). |
84
+ | `/deep-research <question>` | Searches, fetches, and cross-validates sources from multiple angles in parallel, votes on each claim, removes parts that fail validation, and outputs a cited report. Requires the [WebSearch tool](tools-reference.md). |
85
85
 
86
86
  [Workflows you save yourself](#saving-a-workflow-for-reuse) are registered as commands in the same way and appear together with built-in Workflows in `/` autocomplete.
87
87
 
@@ -235,8 +235,6 @@ The script is a self-contained JavaScript module and can use the following globa
235
235
  | `args` | Arguments passed by the caller (see [Passing Arguments to a Saved Workflow](#passing-arguments-to-a-saved-workflow)) |
236
236
  | `workflow(name, args?)` | Calls a **saved** Workflow as a nested Workflow (only exposed to the parent; child Workflows do not expose this hook again, and deep nesting is forbidden) |
237
237
 
238
- For more patterns, see [`build/patches/cli-saas/templates/workflow-tool-description.tpl`](../../../build/patches/cli-saas/templates/workflow-tool-description.tpl) and [`workflow-subagent-system-preamble.tpl`](../../../build/patches/cli-saas/templates/workflow-subagent-system-preamble.tpl).
239
-
240
238
  ## Run Management
241
239
 
242
240
  After a run starts, manage it from the `/workflows` view. You can also expand the progress row in the task panel below the input box.
@@ -268,7 +266,7 @@ Disable it only for yourself:
268
266
  - Set `"disableWorkflows": true` in `~/.codebuddy/settings.json`. This persists
269
267
  - Set the environment variable `CODEBUDDY_DISABLE_WORKFLOWS=1`. It is read at startup and takes effect wherever it is set
270
268
 
271
- Disable it for the whole organization: set `"disableWorkflows": true` in [managed settings](settings.md#enterprise-managed-policy-settings).
269
+ Disable it for the whole organization: set `"disableWorkflows": true` in [managed settings](settings.md).
272
270
 
273
271
  After disabling, built-in Workflow commands are unavailable, the keyword `ultracode` no longer triggers Workflow, and the `/effort` menu no longer shows the ultracode option.
274
272