feat(categories): add disable field to CategoryConfigSchema

Allow individual categories to be disabled via `disable: true` in
config. Introduce shared `mergeCategories()` utility to centralize
category merging and disabled filtering across all 7 consumption sites.
This commit is contained in:
YeonGyu-Kim
2026-02-11 13:52:06 +09:00
parent 67b4665c28
commit bfe1730e9f
11 changed files with 131 additions and 29 deletions
+84
View File
@@ -0,0 +1,84 @@
import { describe, it, expect } from "bun:test"
import { mergeCategories } from "./merge-categories"
import { DEFAULT_CATEGORIES } from "../tools/delegate-task/constants"
describe("mergeCategories", () => {
it("returns all default categories when no user config provided", () => {
//#given
const userCategories = undefined
//#when
const result = mergeCategories(userCategories)
//#then
expect(Object.keys(result)).toEqual(Object.keys(DEFAULT_CATEGORIES))
})
it("filters out categories with disable: true", () => {
//#given
const userCategories = {
"quick": { disable: true },
}
//#when
const result = mergeCategories(userCategories)
//#then
expect(result["quick"]).toBeUndefined()
expect(Object.keys(result).length).toBe(Object.keys(DEFAULT_CATEGORIES).length - 1)
})
it("keeps categories with disable: false", () => {
//#given
const userCategories = {
"quick": { disable: false },
}
//#when
const result = mergeCategories(userCategories)
//#then
expect(result["quick"]).toBeDefined()
})
it("allows user to add custom categories", () => {
//#given
const userCategories = {
"my-custom": { model: "openai/gpt-5.2", description: "Custom category" },
}
//#when
const result = mergeCategories(userCategories)
//#then
expect(result["my-custom"]).toBeDefined()
expect(result["my-custom"].model).toBe("openai/gpt-5.2")
})
it("allows user to disable custom categories", () => {
//#given
const userCategories = {
"my-custom": { model: "openai/gpt-5.2", disable: true },
}
//#when
const result = mergeCategories(userCategories)
//#then
expect(result["my-custom"]).toBeUndefined()
})
it("user overrides merge with defaults", () => {
//#given
const userCategories = {
"ultrabrain": { model: "anthropic/claude-opus-4-6" },
}
//#when
const result = mergeCategories(userCategories)
//#then
expect(result["ultrabrain"]).toBeDefined()
expect(result["ultrabrain"].model).toBe("anthropic/claude-opus-4-6")
})
})
+18
View File
@@ -0,0 +1,18 @@
import type { CategoriesConfig, CategoryConfig } from "../config/schema"
import { DEFAULT_CATEGORIES } from "../tools/delegate-task/constants"
/**
* Merge default and user categories, filtering out disabled ones.
* Single source of truth for category merging across the codebase.
*/
export function mergeCategories(
userCategories?: CategoriesConfig,
): Record<string, CategoryConfig> {
const merged = userCategories
? { ...DEFAULT_CATEGORIES, ...userCategories }
: { ...DEFAULT_CATEGORIES }
return Object.fromEntries(
Object.entries(merged).filter(([, config]) => !config.disable),
)
}