-
Notifications
You must be signed in to change notification settings - Fork 556
feat: OpenCode v1.1.1 permission system compatibility #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ity utilities - Add opencode-version.ts: Detect installed OpenCode version and support API - Add permission-compat.ts: Compatibility layer for permission system migration - Add comprehensive tests (418 lines total) - Export new utilities from shared/index.ts 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
- Fix document-writer: change invalid 'permission: { background_task: deny }' to 'tools: { background_task: false }'
- Fix explore: split 'permission' and 'tools' config, move tool-level denials to 'tools' key
- Fix oracle: split 'permission' and 'tools' config, move tool-level denials to 'tools' key
- Align all agents with v1.1.1 permission system structure
🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
Greptile SummaryThis PR successfully adds OpenCode v1.1.1 permission system compatibility while maintaining backward compatibility with older versions. The implementation correctly addresses the breaking change where OpenCode v1.1.1 deprecated the Key Changes:
Test Coverage:
Design Quality:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Plugin as OhMyOpenCode Plugin
participant VersionUtil as opencode-version.ts
participant PermCompat as permission-compat.ts
participant Agent as Agent Config (oracle/explore/document-writer)
participant OpenCode as OpenCode SDK
Note over Plugin,OpenCode: Plugin Initialization
Plugin->>VersionUtil: getOpenCodeVersion()
VersionUtil->>VersionUtil: Check cache
alt Cache miss
VersionUtil->>OpenCode: execSync("opencode --version")
OpenCode-->>VersionUtil: "1.1.1" or "1.0.150"
VersionUtil->>VersionUtil: Parse version, cache result
end
VersionUtil-->>Plugin: version string or null
Plugin->>VersionUtil: supportsNewPermissionSystem()
VersionUtil->>VersionUtil: isVersionGte(version, "1.1.1")
VersionUtil-->>Plugin: true/false
Note over Plugin,Agent: Agent Configuration Phase
Plugin->>Agent: createAgent()
Agent->>Agent: Define restrictions
Note over Agent: OLD (pre-1.1.1): permission: { write: "deny", task: "deny" }<br/>NEW (1.1.1+): tools: { write: false, task: false }, permission: { edit: "deny" }
Agent->>PermCompat: createAgentRestrictions({ denyTools, permission })
PermCompat->>PermCompat: Build tools config (boolean)
PermCompat->>PermCompat: Build permission config (allow/deny/ask)
PermCompat-->>Agent: { tools: {...}, permission: {...} }
Agent-->>Plugin: AgentConfig with correct format
Plugin->>OpenCode: Register agent with tools + permission
Note over OpenCode: v1.1.1+: Uses permission.edit<br/>Pre-1.1.1: Uses tools.write
OpenCode-->>Plugin: Agent registered
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 8 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Summary
This PR adds compatibility with OpenCode v1.1.1's new permission system while maintaining backward compatibility with older versions.
Changes
Version Detection Utility (
opencode-version.ts)opencode --versionisVersionGte,isVersionLt,compareVersions)Permission Compatibility Layer (
permission-compat.ts)tools(boolean) andpermission(allow/deny/ask) formatscreateAgentRestrictions()helper for clean agent configurationAgent Configuration Fixes
oracle.ts: Fixed invalidpermission: { write: "deny" }→tools: { write: false }, permission: { edit: "deny" }explore.ts: Fixed invalidpermission: { write: "deny" }→tools: { write: false }, permission: { edit: "deny" }document-writer.ts: Fixed invalidpermission: { background_task: "deny" }→tools: { background_task: false }Breaking Change Context (OpenCode v1.1.1)
OpenCode v1.1.1 introduced a new permission system:
toolsconfig deprecated → merged intopermission{ "tools": { "bash": true } }→ New:{ "permission": { "bash": "allow" } }AgentConfig.permissiononly accepts specific keys:edit,bash,webfetch,doom_loop,external_directoryOur agents were incorrectly using
permissionwith invalid keys (write,task,background_task). This fix:toolsfor tool access control (disable specific tools)permissiononly for valid SDK permission keysTests
Added 37 new tests covering:
Closes #487
🤖 This PR was 100% written by Sisyphus
Generated with assistance of OhMyOpenCode
Summary by cubic
Adds OpenCode v1.1.1 permission system compatibility and fixes agent configs to use the correct tools vs permission split. Keeps older versions working via version detection and a small compat layer. Closes #487.
New Features
Bug Fixes
Written for commit 9d3c6e3. Summary will update on new commits.