fix: proper OpenCode v1.1.1 permission migration (#490)

* fix: implement proper version-aware permission format for OpenCode v1.1.1

- Rewrite permission-compat.ts with runtime version detection
- createAgentToolRestrictions() returns correct format per version
- v1.1.1+ uses permission format, older uses tools format
- Add migrateToolsToPermission/migratePermissionToTools helpers
- Update test suite for new API

🤖 Generated with assistance of OhMyOpenCode
https://github.com/code-yeongyu/oh-my-opencode

* fix: update all agents to use createAgentToolRestrictions()

- Replace hardcoded tools: { X: false } format with version-aware utility
- All agents now use createAgentToolRestrictions([...])
- Ensures compatibility with both old and new OpenCode versions

🤖 Generated with assistance of OhMyOpenCode
https://github.com/code-yeongyu/oh-my-opencode

* fix: add runtime migration for user agent configs in config-handler

Migrate tools/permission format in user/project/plugin agent configs
based on detected OpenCode version at load time.

🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2026-01-05 05:28:25 +09:00
committed by GitHub
parent 09f72e2902
commit 8f2209a138
9 changed files with 232 additions and 170 deletions

View File

@@ -1,6 +1,7 @@
import type { AgentConfig } from "@opencode-ai/sdk"
import type { AgentPromptMetadata } from "./types"
import { isGptModel } from "./types"
import { createAgentToolRestrictions } from "../shared/permission-compat"
const DEFAULT_MODEL = "openai/gpt-5.2"
@@ -97,22 +98,28 @@ Organize your final answer in three tiers:
Your response goes directly to the user with no intermediate processing. Make your final message self-contained: a clear recommendation they can act on immediately, covering both what to do and why.`
export function createOracleAgent(model: string = DEFAULT_MODEL): AgentConfig {
const restrictions = createAgentToolRestrictions([
"write",
"edit",
"task",
"background_task",
])
const base = {
description:
"Expert technical advisor with deep reasoning for architecture decisions, code analysis, and engineering guidance.",
mode: "subagent" as const,
model,
temperature: 0.1,
tools: { write: false, task: false, background_task: false },
permission: { edit: "deny" as const },
...restrictions,
prompt: ORACLE_SYSTEM_PROMPT,
}
} as AgentConfig
if (isGptModel(model)) {
return { ...base, reasoningEffort: "medium", textVerbosity: "high" }
return { ...base, reasoningEffort: "medium", textVerbosity: "high" } as AgentConfig
}
return { ...base, thinking: { type: "enabled", budgetTokens: 32000 } }
return { ...base, thinking: { type: "enabled", budgetTokens: 32000 } } as AgentConfig
}
export const oracleAgent = createOracleAgent()