fix: deny todo tools for prometheus and sisyphus-junior when task_system enabled
Amp-Thread-ID: https://ampcode.com/threads/T-019c848f-b2a8-7037-9eb5-a258df14b683 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
parent
6245e46885
commit
35ab9b19c8
83
src/plugin-handlers/tool-config-handler.test.ts
Normal file
83
src/plugin-handlers/tool-config-handler.test.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import { describe, it, expect } from "bun:test"
|
||||||
|
import { applyToolConfig } from "./tool-config-handler"
|
||||||
|
import type { OhMyOpenCodeConfig } from "../config"
|
||||||
|
|
||||||
|
function createParams(overrides: {
|
||||||
|
taskSystem?: boolean
|
||||||
|
agents?: string[]
|
||||||
|
}) {
|
||||||
|
const agentResult: Record<string, { permission?: Record<string, unknown> }> = {}
|
||||||
|
for (const agent of overrides.agents ?? []) {
|
||||||
|
agentResult[agent] = { permission: {} }
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
config: { tools: {}, permission: {} } as Record<string, unknown>,
|
||||||
|
pluginConfig: {
|
||||||
|
experimental: { task_system: overrides.taskSystem ?? false },
|
||||||
|
} as OhMyOpenCodeConfig,
|
||||||
|
agentResult: agentResult as Record<string, unknown>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("applyToolConfig", () => {
|
||||||
|
describe("#given task_system is enabled", () => {
|
||||||
|
describe("#when applying tool config", () => {
|
||||||
|
it("#then should deny todowrite and todoread globally", () => {
|
||||||
|
const params = createParams({ taskSystem: true })
|
||||||
|
|
||||||
|
applyToolConfig(params)
|
||||||
|
|
||||||
|
const tools = params.config.tools as Record<string, unknown>
|
||||||
|
expect(tools.todowrite).toBe(false)
|
||||||
|
expect(tools.todoread).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
"atlas",
|
||||||
|
"sisyphus",
|
||||||
|
"hephaestus",
|
||||||
|
"prometheus",
|
||||||
|
"sisyphus-junior",
|
||||||
|
])("#then should deny todo tools for %s agent", (agentName) => {
|
||||||
|
const params = createParams({
|
||||||
|
taskSystem: true,
|
||||||
|
agents: [agentName],
|
||||||
|
})
|
||||||
|
|
||||||
|
applyToolConfig(params)
|
||||||
|
|
||||||
|
const agent = params.agentResult[agentName] as {
|
||||||
|
permission: Record<string, unknown>
|
||||||
|
}
|
||||||
|
expect(agent.permission.todowrite).toBe("deny")
|
||||||
|
expect(agent.permission.todoread).toBe("deny")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("#given task_system is disabled", () => {
|
||||||
|
describe("#when applying tool config", () => {
|
||||||
|
it.each([
|
||||||
|
"atlas",
|
||||||
|
"sisyphus",
|
||||||
|
"hephaestus",
|
||||||
|
"prometheus",
|
||||||
|
"sisyphus-junior",
|
||||||
|
])("#then should NOT deny todo tools for %s agent", (agentName) => {
|
||||||
|
const params = createParams({
|
||||||
|
taskSystem: false,
|
||||||
|
agents: [agentName],
|
||||||
|
})
|
||||||
|
|
||||||
|
applyToolConfig(params)
|
||||||
|
|
||||||
|
const agent = params.agentResult[agentName] as {
|
||||||
|
permission: Record<string, unknown>
|
||||||
|
}
|
||||||
|
expect(agent.permission.todowrite).toBeUndefined()
|
||||||
|
expect(agent.permission.todoread).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -84,6 +84,7 @@ export function applyToolConfig(params: {
|
|||||||
question: questionPermission,
|
question: questionPermission,
|
||||||
"task_*": "allow",
|
"task_*": "allow",
|
||||||
teammate: "allow",
|
teammate: "allow",
|
||||||
|
...denyTodoTools,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const junior = agentByKey(params.agentResult, "sisyphus-junior");
|
const junior = agentByKey(params.agentResult, "sisyphus-junior");
|
||||||
@ -93,6 +94,7 @@ export function applyToolConfig(params: {
|
|||||||
task: "allow",
|
task: "allow",
|
||||||
"task_*": "allow",
|
"task_*": "allow",
|
||||||
teammate: "allow",
|
teammate: "allow",
|
||||||
|
...denyTodoTools,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user