refactor: remove legacy tools format, use permission only

BREAKING: Requires OpenCode 1.1.1+

- Remove supportsNewPermissionSystem/usesLegacyToolsSystem checks
- Simplify permission-compat.ts to permission format only
- Unify explore/librarian deny lists: write, edit, task, sisyphus_task, call_omo_agent
- Add sisyphus_task to oracle deny list
- Update agent-tool-restrictions.ts with correct per-agent restrictions
- Clean config-handler.ts conditional version checks
- Update tests for simplified API
This commit is contained in:
justsisyphus
2026-01-16 17:11:34 +09:00
parent ede9abceb3
commit 83cbc56709
21 changed files with 505 additions and 347 deletions
+18 -52
View File
@@ -1,16 +1,14 @@
import { describe, test, expect, beforeEach, afterEach, spyOn, mock } from "bun:test"
import * as childProcess from "child_process"
import { describe, test, expect, beforeEach, afterEach } from "bun:test"
import {
parseVersion,
compareVersions,
isVersionGte,
isVersionLt,
getOpenCodeVersion,
supportsNewPermissionSystem,
usesLegacyToolsSystem,
isOpenCodeVersionAtLeast,
resetVersionCache,
setVersionCache,
PERMISSION_BREAKING_VERSION,
MINIMUM_OPENCODE_VERSION,
} from "./opencode-version"
describe("opencode-version", () => {
@@ -163,7 +161,7 @@ describe("opencode-version", () => {
})
})
describe("supportsNewPermissionSystem", () => {
describe("isOpenCodeVersionAtLeast", () => {
beforeEach(() => {
resetVersionCache()
})
@@ -172,34 +170,34 @@ describe("opencode-version", () => {
resetVersionCache()
})
test("returns true for v1.1.1", () => {
test("returns true for exact version", () => {
// #given version is 1.1.1
setVersionCache("1.1.1")
// #when checking permission system support
const result = supportsNewPermissionSystem()
// #when checking against 1.1.1
const result = isOpenCodeVersionAtLeast("1.1.1")
// #then returns true
expect(result).toBe(true)
})
test("returns true for versions above 1.1.1", () => {
// #given version is above 1.1.1
test("returns true for versions above target", () => {
// #given version is above target
setVersionCache("1.2.0")
// #when checking
const result = supportsNewPermissionSystem()
// #when checking against 1.1.1
const result = isOpenCodeVersionAtLeast("1.1.1")
// #then returns true
expect(result).toBe(true)
})
test("returns false for versions below 1.1.1", () => {
// #given version is below 1.1.1
test("returns false for versions below target", () => {
// #given version is below target
setVersionCache("1.1.0")
// #when checking
const result = supportsNewPermissionSystem()
// #when checking against 1.1.1
const result = isOpenCodeVersionAtLeast("1.1.1")
// #then returns false
expect(result).toBe(false)
@@ -210,48 +208,16 @@ describe("opencode-version", () => {
setVersionCache(null)
// #when checking
const result = supportsNewPermissionSystem()
const result = isOpenCodeVersionAtLeast("1.1.1")
// #then returns true (assume newer version)
expect(result).toBe(true)
})
})
describe("usesLegacyToolsSystem", () => {
beforeEach(() => {
resetVersionCache()
})
afterEach(() => {
resetVersionCache()
})
test("returns true for versions below 1.1.1", () => {
// #given version is below 1.1.1
setVersionCache("1.0.150")
// #when checking
const result = usesLegacyToolsSystem()
// #then returns true
expect(result).toBe(true)
})
test("returns false for v1.1.1 and above", () => {
// #given version is 1.1.1
setVersionCache("1.1.1")
// #when checking
const result = usesLegacyToolsSystem()
// #then returns false
expect(result).toBe(false)
})
})
describe("PERMISSION_BREAKING_VERSION", () => {
describe("MINIMUM_OPENCODE_VERSION", () => {
test("is set to 1.1.1", () => {
expect(PERMISSION_BREAKING_VERSION).toBe("1.1.1")
expect(MINIMUM_OPENCODE_VERSION).toBe("1.1.1")
})
})
})