110b1e3d2d
* refactor(keyword-detector): split constants into domain-specific modules * feat(shared): add requiresAnyModel and isAnyFallbackModelAvailable * feat(config): add hephaestus to agent schemas * feat(agents): add Hephaestus autonomous deep worker * feat(cli): update model-fallback for hephaestus support * feat(plugin): add hephaestus to config handler with ordering * test(delegate-task): update tests for hephaestus agent * docs: update AGENTS.md files for hephaestus * docs: add hephaestus to READMEs * chore: regenerate config schema * fix(delegate-task): bypass requiresModel check when user provides explicit config * docs(hephaestus): add 4-part context structure for explore/librarian prompts * docs: fix review comments from cubic (non-breaking changes) - Move Hephaestus from Primary Agents to Subagents (uses own fallback chain) - Fix Hephaestus fallback chain documentation (claude-opus-4-5 → gemini-3-pro) - Add settings.local.json to claude-code-hooks config sources - Fix delegate_task parameters in ultrawork prompt (agent→subagent_type, background→run_in_background, add load_skills) - Update line counts in AGENTS.md (index.ts: 788, manager.ts: 1440) * docs: fix additional documentation inconsistencies from oracle review - Fix delegate_task parameters in Background Agents example (docs/features.md) - Fix Hephaestus fallback chain in root AGENTS.md to match model-requirements.ts * docs: clarify Hephaestus has no fallback (requires gpt-5.2-codex only) Hephaestus uses requiresModel constraint - it only activates when gpt-5.2-codex is available. The fallback chain in code is unreachable, so documentation should not mention fallbacks. * fix(hephaestus): remove unreachable fallback chain entries Hephaestus has requiresModel: gpt-5.2-codex which means the agent only activates when that specific model is available. The fallback entries (claude-opus-4-5, gemini-3-pro) were unreachable and misleading. --------- Co-authored-by: justsisyphus <justsisyphus@users.noreply.github.com>
72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
import type { CategoryConfig, CategoriesConfig } from "../../config/schema"
|
|
import { DEFAULT_CATEGORIES, CATEGORY_PROMPT_APPENDS } from "./constants"
|
|
import { resolveModel } from "../../shared"
|
|
import { isModelAvailable } from "../../shared/model-availability"
|
|
import { CATEGORY_MODEL_REQUIREMENTS } from "../../shared/model-requirements"
|
|
import { log } from "../../shared"
|
|
|
|
export interface ResolveCategoryConfigOptions {
|
|
userCategories?: CategoriesConfig
|
|
inheritedModel?: string
|
|
systemDefaultModel?: string
|
|
availableModels?: Set<string>
|
|
}
|
|
|
|
export interface ResolveCategoryConfigResult {
|
|
config: CategoryConfig
|
|
promptAppend: string
|
|
model: string | undefined
|
|
}
|
|
|
|
/**
|
|
* Resolve the configuration for a given category name.
|
|
* Merges default and user configurations, handles model resolution.
|
|
*/
|
|
export function resolveCategoryConfig(
|
|
categoryName: string,
|
|
options: ResolveCategoryConfigOptions
|
|
): ResolveCategoryConfigResult | null {
|
|
const { userCategories, inheritedModel, systemDefaultModel, availableModels } = options
|
|
|
|
const defaultConfig = DEFAULT_CATEGORIES[categoryName]
|
|
const userConfig = userCategories?.[categoryName]
|
|
const hasExplicitUserConfig = userConfig !== undefined
|
|
|
|
// Check if category requires a specific model - bypass if user explicitly provides config
|
|
const categoryReq = CATEGORY_MODEL_REQUIREMENTS[categoryName]
|
|
if (categoryReq?.requiresModel && availableModels && !hasExplicitUserConfig) {
|
|
if (!isModelAvailable(categoryReq.requiresModel, availableModels)) {
|
|
log(`[resolveCategoryConfig] Category ${categoryName} requires ${categoryReq.requiresModel} but not available`)
|
|
return null
|
|
}
|
|
}
|
|
const defaultPromptAppend = CATEGORY_PROMPT_APPENDS[categoryName] ?? ""
|
|
|
|
if (!defaultConfig && !userConfig) {
|
|
return null
|
|
}
|
|
|
|
// Model priority for categories: user override > category default > system default
|
|
// Categories have explicit models - no inheritance from parent session
|
|
const model = resolveModel({
|
|
userModel: userConfig?.model,
|
|
inheritedModel: defaultConfig?.model, // Category's built-in model takes precedence over system default
|
|
systemDefault: systemDefaultModel,
|
|
})
|
|
const config: CategoryConfig = {
|
|
...defaultConfig,
|
|
...userConfig,
|
|
model,
|
|
variant: userConfig?.variant ?? defaultConfig?.variant,
|
|
}
|
|
|
|
let promptAppend = defaultPromptAppend
|
|
if (userConfig?.prompt_append) {
|
|
promptAppend = defaultPromptAppend
|
|
? defaultPromptAppend + "\n\n" + userConfig.prompt_append
|
|
: userConfig.prompt_append
|
|
}
|
|
|
|
return { config, promptAppend, model }
|
|
}
|