Skip to content

Commit 46d7800

Browse files
serghei-devsergeyklay
authored andcommitted
fix(examples): scope OpenCode sample permissions
1 parent 3de98a0 commit 46d7800

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

cmd/sortie/sample_workflow_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"path/filepath"
5+
"slices"
56
"strings"
67
"testing"
78

@@ -342,6 +343,22 @@ func TestSampleWorkflowOpenCodeExtension(t *testing.T) {
342343
if v, _ := opencodeCfg["disable_autocompact"].(bool); !v {
343344
t.Error("opencode extension 'disable_autocompact' must be true")
344345
}
346+
allowedTools, ok := opencodeCfg["allowed_tools"].([]any)
347+
if !ok {
348+
t.Fatal("opencode extension missing 'allowed_tools' list")
349+
}
350+
gotAllowedTools := make([]string, 0, len(allowedTools))
351+
for _, tool := range allowedTools {
352+
name, ok := tool.(string)
353+
if !ok {
354+
t.Fatalf("allowed tool type = %T, want string", tool)
355+
}
356+
gotAllowedTools = append(gotAllowedTools, name)
357+
}
358+
wantAllowedTools := []string{"read", "glob", "grep", "edit", "bash"}
359+
if !slices.Equal(gotAllowedTools, wantAllowedTools) {
360+
t.Errorf("opencode extension allowed_tools = %v, want %v", gotAllowedTools, wantAllowedTools)
361+
}
345362

346363
agent, ok := wf.Config["agent"].(map[string]any)
347364
if !ok {

examples/WORKFLOW.opencode.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ opencode:
4949
model: anthropic/claude-sonnet-4-5
5050
dangerously_skip_permissions: true
5151
disable_autocompact: true
52+
allowed_tools:
53+
- read
54+
- glob
55+
- grep
56+
- edit
57+
- bash
5258

5359
server:
5460
port: 8642
@@ -60,6 +66,9 @@ server:
6066
turn. Session IDs are preserved across turns, so continuation uses
6167
the existing session instead of starting over.
6268

69+
This sample also pins an explicit tool allowlist so OpenCode does
70+
not fall back to its permissive default tool policy.
71+
6372
Required env vars:
6473
SORTIE_JIRA_ENDPOINT — Jira Cloud base URL (e.g. https://mycompany.atlassian.net)
6574
SORTIE_JIRA_API_KEY — Jira API token

0 commit comments

Comments
 (0)