Skip to content

Commit fa0b03f

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/free-tokens-1m
2 parents 37affc4 + 4c729de commit fa0b03f

25 files changed

Lines changed: 1462 additions & 126 deletions

File tree

‎docs/docs/configure/agents.md‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Agents define different AI personas with specific models, prompts, permissions,
1212
| Agent | Description | Access Level |
1313
|-------|------------|-------------|
1414
| `builder` | Create and modify dbt models, SQL pipelines, and data transformations | Full read/write. SQL mutations prompt for approval. |
15-
| `analyst` | Answer questions about your data — explore it, run SELECT queries, inspect schemas, generate insights | Read-only (enforced). SQL writes denied. Safe bash commands auto-allowed. |
15+
| `analyst` | Answer questions about your data — explore it, run SELECT queries, inspect schemas, generate insights | Read-only (enforced). SQL writes, file edits, shell, memory saves and other built-in write tools denied, even if config allows them. MCP and custom tools follow your config. Training entries and session scratch tables are still allowed. |
1616
| `plan` | Plan before acting — restricted to planning files only | Minimal — no edits, no bash, no SQL |
1717

1818
### Builder
@@ -25,10 +25,11 @@ The agent for asking questions about your data. Truly read-only mode for safe da
2525

2626
- **File access**: Read, grep, glob — no prompts
2727
- **SQL**: SELECT queries execute freely. Write queries are denied (not prompted — blocked entirely)
28-
- **Bash**: Safe commands auto-allowed (`ls`, `grep`, `cat`, `head`, `tail`, `find`, `wc`). dbt read commands allowed (`dbt list`, `dbt ls`, `dbt debug`). Everything else denied.
28+
- **Bash**: Denied. Use read, grep and glob to read files
2929
- **Web**: Fetch and search allowed without prompts
3030
- **Schema/warehouse/finops**: All inspection tools available
31-
- **Workspace knowledge**: Loads workspace and project skills; reads workspace memory and views this checkout's memory audit log. Reloading memory syncs the local copy with the workspace, which can remove a local copy of a block the workspace archived. Saving memory is done with `builder`.
31+
- **Workspace knowledge**: Loads workspace and project skills; reads workspace memory and views this checkout's memory audit log. Can read files bundled with skills, including global skills stored outside the project. Reloading memory syncs the local copy with the workspace, which can remove a local copy of a block the workspace archived. Saving memory is done with `builder`.
32+
- **Config overrides**: A permission config such as `"*": "allow"` cannot turn file edits, SQL writes (including data diffs of arbitrary queries), shell, memory saves, warehouse connection or MCP config changes, training imports, sample project setup, feedback submission, batch tool calls or delegation beyond `data-explorer` back on. A global `"*": "allow"` does turn on MCP and custom tools for analyst, including ones that write (for example a SQL MCP server); to keep them from analyst, put the `"*": "allow"` under `agent.builder` instead of the global config, or deny those tools under `agent.analyst.permission`.
3233

3334
!!! tip
3435
Use `analyst` when exploring data to ensure no accidental writes. Switch to `builder` when you're ready to create or modify models.
@@ -66,8 +67,8 @@ Define custom agents in `altimate-code.json`:
6667
"write": "deny",
6768
"edit": "deny",
6869
"bash": {
69-
"dbt docs generate": "allow",
70-
"*": "deny"
70+
"*": "deny",
71+
"dbt docs generate": "allow"
7172
}
7273
}
7374
}
@@ -121,7 +122,7 @@ Each agent can have its own permission overrides:
121122
```json
122123
{
123124
"agent": {
124-
"analyst": {
125+
"builder": {
125126
"permission": {
126127
"write": "deny",
127128
"edit": "deny",
@@ -137,6 +138,8 @@ Each agent can have its own permission overrides:
137138
}
138139
```
139140

141+
`analyst` already denies its shell and built-in write tools whatever its config says, so its config is mainly useful to restrict it further (for example `"webfetch": "deny"`) or to allow MCP and custom tools.
142+
140143
!!! warning
141144
Agent-specific permissions override global permissions. A `"deny"` at the agent level cannot be overridden by a global `"allow"`.
142145

‎docs/docs/configure/permissions.md‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,25 @@ Override permissions for specific agents:
6565
```json
6666
{
6767
"agent": {
68-
"analyst": {
68+
"builder": {
6969
"permission": {
7070
"write": "deny",
7171
"edit": "deny",
7272
"bash": {
73+
"*": "deny",
7374
"SELECT *": "allow",
74-
"dbt docs *": "allow",
75-
"*": "deny"
75+
"dbt docs *": "allow"
7676
}
7777
}
7878
}
7979
}
8080
}
8181
```
8282

83+
The `analyst` agent's shell and built-in write tools (file edits, SQL writes, memory saves and the other built-in tools that change state) stay denied even if its permission config allows them. Training entries remain available through `training_save` and `training_remove`, and analyst can create session scratch tables. MCP and custom tools follow your config, so a global `"*": "allow"` turns them on for analyst too, including ones that write. Config can still restrict analyst further.
84+
85+
Rules are evaluated in order and the last matching rule wins, so put a `"*"` rule before the more specific patterns it should not override.
86+
8387
## All Permissioned Tools
8488

8589
| Tool | Supports Patterns | Description |
@@ -209,15 +213,8 @@ Give each agent only the permissions it needs:
209213
"agent": {
210214
"analyst": {
211215
"permission": {
212-
"write": "deny",
213-
"edit": "deny",
214-
"sql_execute_write": "deny",
215-
"bash": {
216-
"*": "deny",
217-
"ls *": "allow",
218-
"cat *": "allow",
219-
"dbt list *": "allow"
220-
}
216+
"webfetch": "deny",
217+
"websearch": "deny"
221218
}
222219
},
223220
"builder": {

‎docs/docs/configure/tools.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Control which tools agents can use via the [permission system](permissions.md):
3838
{
3939
"permission": {
4040
"bash": {
41+
"*": "ask",
4142
"dbt *": "allow",
42-
"rm *": "deny",
43-
"*": "ask"
43+
"rm *": "deny"
4444
},
4545
"write": "ask",
4646
"read": "allow"
@@ -58,22 +58,22 @@ Disable a tool for a specific agent by setting its permission to `"deny"`:
5858
```json
5959
{
6060
"agent": {
61-
"analyst": {
61+
"builder": {
6262
"permission": {
6363
"write": "deny",
6464
"edit": "deny",
6565
"bash": {
66-
"dbt run *": "deny",
67-
"*": "ask"
66+
"*": "ask",
67+
"dbt run *": "deny"
6868
}
6969
}
7070
}
7171
}
7272
}
7373
```
7474

75-
!!! example "Read-only analyst"
76-
The configuration above creates an analyst agent that cannot modify files. It can only read and explore the codebase, and must ask before running shell commands (except `dbt run`, which is blocked entirely).
75+
!!! example "Builder with file edit tools denied"
76+
The configuration above denies the builder agent's `write` and `edit` tools. The builder can read and explore the codebase. It must ask before running other shell commands, and `dbt run` is blocked entirely. An approved shell command can still modify files. The `analyst` agent's shell and built-in write tools are already denied whatever its permission config says. It can still save training entries and create session scratch tables for analysis, and MCP or custom tools follow your config.
7777

7878
## Tool Behavior
7979

@@ -85,11 +85,11 @@ The `bash` tool executes shell commands in the project directory. Commands run i
8585
{
8686
"permission": {
8787
"bash": {
88+
"*": "ask",
8889
"dbt *": "allow",
8990
"git *": "allow",
9091
"python *": "allow",
91-
"rm -rf *": "deny",
92-
"*": "ask"
92+
"rm -rf *": "deny"
9393
}
9494
}
9595
}

‎docs/docs/data-engineering/agent-modes.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ Analyst mode enforces strict guardrails:
8888

8989
- **SELECT only.** INSERT, UPDATE, DELETE, DROP are denied (not prompted, blocked entirely)
9090
- **No file writes.** Cannot modify your codebase
91-
- **Safe bash only.** `ls`, `grep`, `cat`, `head`, `tail`, `find`, `wc` auto-allowed. dbt read commands allowed (`dbt list`, `dbt ls`, `dbt debug`, `dbt deps`). Everything else denied.
91+
- **No shell.** Bash is denied. Files are read with the read, grep and glob tools
92+
- **No memory saves.** Workspace memory blocks can be read, but not saved, extracted or deleted (use builder). Training entries can still be saved and removed
93+
- **Config cannot lift these.** A permission config such as `"*": "allow"` does not turn file edits, SQL writes (including data diffs of arbitrary queries), shell, memory saves, warehouse connection or MCP config changes, training imports, sample project setup, feedback submission, batch tool calls or delegation beyond `data-explorer` back on for analyst. MCP and custom tools are not covered: a global `"*": "allow"` turns them on for analyst too, including ones that write.
94+
- **Skill files readable.** Files bundled with a skill, including global skills stored outside the project, can be read
9295
- **Full web access.** Fetch and search allowed without prompts
9396
- **All inspection tools.** Schema, warehouse, finops, lineage, and core analysis tools available
9497

‎docs/docs/getting-started/quickstart.md‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ Verify your connection:
147147

148148
altimate ships with specialized agent modes, each with its own tool permissions:
149149

150-
| Mode | Access | Use when you want to... |
151-
| ----------- | ---------- | ------------------------------------------------------------------------------ |
152-
| **Builder** | Read/Write | Create and modify SQL, dbt models, pipelines. SQL writes prompt for approval. |
153-
| **Analyst** | Read-only | Ask questions about your data, explore production data safely, run cost analysis. SQL writes denied entirely. |
154-
| **Plan** | Minimal | Plan an approach before switching to builder to execute it |
150+
| Mode | Access | Use when you want to... |
151+
| ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
152+
| **Builder** | Read/Write | Create and modify SQL, dbt models, pipelines. SQL writes prompt for approval. |
153+
| **Analyst** | Read-only | Ask questions about your data, explore production data safely, run cost analysis. Production SQL writes are denied; session scratch tables are allowed. |
154+
| **Plan** | Minimal | Plan an approach before switching to builder to execute it |
155155

156156
Switch modes in the TUI:
157157

@@ -234,12 +234,7 @@ Set tool permissions for each agent mode in `altimate-code.json`:
234234
"agent": {
235235
"analyst": {
236236
"permission": {
237-
"write": "deny",
238-
"edit": "deny",
239-
"bash": {
240-
"dbt docs generate": "allow",
241-
"*": "deny"
242-
}
237+
"webfetch": "deny"
243238
}
244239
},
245240
"builder": {
@@ -256,6 +251,8 @@ Set tool permissions for each agent mode in `altimate-code.json`:
256251
}
257252
```
258253

254+
Analyst's shell and built-in write tools are always denied, so config cannot turn them on. It can still save training entries and create session scratch tables, and MCP or custom tools follow your config.
255+
259256
### Project rules with AGENTS.md
260257

261258
Define project-wide conventions in an `AGENTS.md` file at your project root. These rules are automatically loaded into every agent's system prompt:
@@ -271,11 +268,11 @@ Define project-wide conventions in an `AGENTS.md` file at your project root. The
271268

272269
### Default permissions by agent mode
273270

274-
| Agent | File writes | SQL writes | Bash | Training |
275-
| ------- | ----------- | -------------------------- | --------------------------------- | -------- |
276-
| Builder | allow | ask (prompts for approval) | ask | allow |
277-
| Analyst | deny | deny (blocked entirely) | deny (safe commands auto-allowed) | allow |
278-
| Plan | deny | deny | deny | deny |
271+
| Agent | File writes | SQL writes | Bash | Training |
272+
| ------- | ----------- | --------------------------- | ---- | -------- |
273+
| Builder | allow | ask (prompts for approval) | ask | allow |
274+
| Analyst | deny | deny, except scratch tables | deny | allow |
275+
| Plan | deny | deny | deny | deny |
279276

280277
---
281278

‎docs/docs/reference/security-faq.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ Yes. Use pattern-based permissions to deny destructive SQL:
9696
}
9797
```
9898

99-
You can also configure per-agent permissions. For example, restrict the `analyst` agent to read-only:
99+
You can also configure per-agent permissions. For example, keep the `builder` agent from editing files and allow only `SELECT` shell commands. The `analyst` agent's shell and built-in write tools are already denied whatever its config says. It can still save training entries and create session scratch tables, and MCP or custom tools follow your config.
100100

101101
```json
102102
{
103103
"agent": {
104-
"analyst": {
104+
"builder": {
105105
"permission": {
106106
"write": "deny",
107107
"edit": "deny",
108108
"bash": {
109-
"SELECT *": "allow",
110-
"*": "deny"
109+
"*": "deny",
110+
"SELECT *": "allow"
111111
}
112112
}
113113
}
@@ -300,8 +300,8 @@ For additional safety:
300300

301301
Altimate Code includes several layers of protection to keep the agent within your project:
302302

303-
- **Project boundary enforcement.** File operations check that paths stay within your project directory (or git worktree for monorepos). Attempts to read or write outside the project trigger an `external_directory` permission prompt.
304-
- **Symlink-aware path resolution.** Symlinks inside the project that point outside are detected and blocked. This prevents an agent from reading or writing outside your project through symlinks.
303+
- **Project boundary enforcement.** File operations check that paths stay within your project directory (or git worktree for monorepos). Attempts to read or write outside the project trigger an `external_directory` permission prompt. A path that goes through a symlink is also checked against the directory it resolves to, so a symlink inside an allowed directory cannot be used to reach a directory outside it that is not allowed.
304+
- **Symlink-aware path resolution.** Symlinks inside the project that point outside are resolved, so following one triggers the same `external_directory` permission check as any other path outside the project. Whether it is allowed depends on that permission.
305305
- **Path traversal blocking.** Paths containing `../` sequences that would escape the project are rejected with an "Access denied" error.
306306
- **Sensitive file protection.** Writing to credential files (`.env`, `.ssh/`, `.aws/`, private keys) triggers a confirmation prompt, even inside the project. See [below](#why-am-i-being-prompted-to-edit-env-files) for details.
307307
- **Bash command analysis.** The bash tool parses commands with tree-sitter to detect file operations (`rm`, `cp`, `mv`, etc.) targeting paths outside your project, and prompts for permission.

‎packages/core/src/util/wildcard.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
export * as Wildcard from "./wildcard"
22

3+
// altimate_change start — preserve POSIX backslashes when matching filesystem paths
34
export function match(input: string, pattern: string) {
4-
const normalized = input.replaceAll("\\", "/")
5+
return matchNormalized(input.replaceAll("\\", "/"), pattern.replaceAll("\\", "/"))
6+
}
7+
8+
export function matchPath(input: string, pattern: string) {
9+
if (process.platform === "win32") return match(input, pattern)
10+
return matchNormalized(input, pattern)
11+
}
12+
13+
function matchNormalized(input: string, pattern: string) {
514
let escaped = pattern
6-
.replaceAll("\\", "/")
715
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
816
.replace(/\*/g, ".*")
917
.replace(/\?/g, ".")
1018

1119
if (escaped.endsWith(" .*")) escaped = escaped.slice(0, -3) + "( .*)?"
1220

13-
return new RegExp("^" + escaped + "$", process.platform === "win32" ? "si" : "s").test(normalized)
21+
return new RegExp("^" + escaped + "$", process.platform === "win32" ? "si" : "s").test(input)
1422
}
23+
// altimate_change end

‎packages/opencode/src/agent/agent.ts‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ export const layer = Layer.effect(
334334
question: "allow",
335335
// Skills return instruction text only (no side effects), so they are safe for a read-only agent.
336336
skill: "allow",
337+
// "*": "deny" above also overrides the default allow for skill directories; add it back
338+
// so files bundled with a global skill (stored outside the project) stay readable.
339+
external_directory: Object.fromEntries(skillDirs.map((dir) => [path.join(dir, "*"), "allow"])),
337340
// Workspace memory: read, reload and view the audit log. Reloading syncs like the
338341
// load every session runs (it can drop a local copy of a block the workspace has
339342
// archived), but cannot create or edit memory. Saving and deleting stay denied, so a
@@ -633,12 +636,48 @@ export const layer = Layer.effect(
633636
// Ensure Truncate.GLOB is allowed unless explicitly configured
634637
for (const name in agents) {
635638
const agent = agents[name]
636-
// altimate_change start — keep the analyst shell disabled after config and safety rules
639+
// altimate_change start — keep analyst's shell and write tools disabled after config and safety rules
637640
// Permission.disabled requires the final bash rule to deny "*". Without
638641
// it, narrower safety rules leave the tool exposed to commands that emit
639642
// no permission patterns (e.g. `>out.txt`). data-explorer is capped above.
643+
// The built-in tools that change files, memory, config, connections or external
644+
// systems are denied again too: last-match-wins would otherwise let a config grant
645+
// such as "*": "allow" turn them back on for the read-only agent. Most of them never
646+
// call ctx.ask, so removing them from the tool list is their only gate. batch is
647+
// denied because it runs other tools without that tool-list filter.
640648
if (name === "analyst") {
641-
agent.permission = Permission.merge(agent.permission, Permission.fromConfig({ bash: "deny" }))
649+
// Keep what config resolved for data-explorer (it may deny or ask), but nothing broader.
650+
const dataExplorerAction = Permission.evaluate("task", "data-explorer", agent.permission).action
651+
agent.permission = Permission.merge(
652+
agent.permission,
653+
Permission.fromConfig({
654+
...Object.fromEntries(
655+
[
656+
"bash",
657+
"sql_execute_write",
658+
"edit",
659+
"write",
660+
"apply_patch",
661+
"altimate_memory_write",
662+
"altimate_memory_delete",
663+
"altimate_memory_extract",
664+
"training_import",
665+
"warehouse_add",
666+
"warehouse_remove",
667+
"warehouse_install_driver",
668+
"mcp_discover",
669+
"datamate_manager",
670+
"sample_setup",
671+
"feedback_submit",
672+
// Runs caller-supplied SQL without the write classification sql_execute applies.
673+
"data_diff",
674+
"batch",
675+
].map((tool) => [tool, "deny" as const]),
676+
),
677+
// A trailing "*" deny is what removes task from the tool list when nothing is allowed.
678+
task: dataExplorerAction === "deny" ? "deny" : { "*": "deny", "data-explorer": dataExplorerAction },
679+
}),
680+
)
642681
}
643682
// altimate_change end
644683
const explicit = agent.permission.some((r) => {

0 commit comments

Comments
 (0)