feat(config): add configurable agent ordering
This commit is contained in:
@@ -38,3 +38,58 @@ describe("OhMyOpenCodeConfigSchema team_mode", () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe("OhMyOpenCodeConfigSchema agent_order", () => {
|
||||
it("accepts string agent ordering when provided", () => {
|
||||
// given
|
||||
const rawConfig = {
|
||||
agent_order: ["hephaestus", "sisyphus", "prometheus", "atlas"],
|
||||
}
|
||||
|
||||
// when
|
||||
const result = OhMyOpenCodeConfigSchema.safeParse(rawConfig)
|
||||
|
||||
// then
|
||||
expect(result.success).toBe(true)
|
||||
if (result.success) {
|
||||
expect(result.data.agent_order).toEqual([
|
||||
"hephaestus",
|
||||
"sisyphus",
|
||||
"prometheus",
|
||||
"atlas",
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
it("allows agent_order omission", () => {
|
||||
// given
|
||||
const rawConfig = {}
|
||||
|
||||
// when
|
||||
const result = OhMyOpenCodeConfigSchema.safeParse(rawConfig)
|
||||
|
||||
// then
|
||||
expect(result.success).toBe(true)
|
||||
if (result.success) {
|
||||
expect(result.data.agent_order).toBeUndefined()
|
||||
}
|
||||
})
|
||||
|
||||
it("rejects abusive agent_order string length and item count", () => {
|
||||
// given
|
||||
const tooLongName = "x".repeat(129)
|
||||
const tooManyNames = Array.from({ length: 65 }, (_, index) => `agent-${index}`)
|
||||
|
||||
// when
|
||||
const tooLongResult = OhMyOpenCodeConfigSchema.safeParse({
|
||||
agent_order: [tooLongName],
|
||||
})
|
||||
const tooManyResult = OhMyOpenCodeConfigSchema.safeParse({
|
||||
agent_order: tooManyNames,
|
||||
})
|
||||
|
||||
// then
|
||||
expect(tooLongResult.success).toBe(false)
|
||||
expect(tooManyResult.success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -32,6 +32,8 @@ export const OhMyOpenCodeConfigSchema = z.object({
|
||||
new_task_system_enabled: z.boolean().optional(),
|
||||
/** Default agent name for `oh-my-opencode run` (env: OPENCODE_DEFAULT_AGENT) */
|
||||
default_run_agent: z.string().optional(),
|
||||
/** Preferred display order for known agents. Invalid names are ignored with a toast warning. */
|
||||
agent_order: z.array(z.string().max(128)).max(64).optional(),
|
||||
/** Paths to external agent definition files (.md or .json) */
|
||||
agent_definitions: AgentDefinitionsConfigSchema,
|
||||
disabled_mcps: z.array(AnyMcpNameSchema).optional(),
|
||||
|
||||
Reference in New Issue
Block a user