* chore(deps): upgrade @opencode-ai/plugin and sdk to 1.1.19 * docs(prometheus): add Question tool usage reminder * fix(migration): remove auto model-to-category conversion - Remove migrateAgentConfigToCategory call from migrateConfigFile - User's explicit model/category settings are now preserved as-is - No more unwanted deletion of agent configs (e.g., multimodal-looker) - Add BUILTIN_AGENT_NAMES constant for future reference - Update tests to reflect new behavior * ci(sisyphus): add mandatory 'new branch + PR' todos for implementation tasks --------- Co-authored-by: justsisyphus <justsisyphus@users.noreply.github.com>
166 lines
4.6 KiB
TypeScript
166 lines
4.6 KiB
TypeScript
import * as fs from "fs"
|
|
import { log } from "./logger"
|
|
|
|
// Migration map: old keys → new keys (for backward compatibility)
|
|
export const AGENT_NAME_MAP: Record<string, string> = {
|
|
omo: "Sisyphus",
|
|
"OmO": "Sisyphus",
|
|
sisyphus: "Sisyphus",
|
|
"OmO-Plan": "Prometheus (Planner)",
|
|
"omo-plan": "Prometheus (Planner)",
|
|
"Planner-Sisyphus": "Prometheus (Planner)",
|
|
"planner-sisyphus": "Prometheus (Planner)",
|
|
prometheus: "Prometheus (Planner)",
|
|
"plan-consultant": "Metis (Plan Consultant)",
|
|
metis: "Metis (Plan Consultant)",
|
|
build: "build",
|
|
oracle: "oracle",
|
|
librarian: "librarian",
|
|
explore: "explore",
|
|
"frontend-ui-ux-engineer": "frontend-ui-ux-engineer",
|
|
"document-writer": "document-writer",
|
|
"multimodal-looker": "multimodal-looker",
|
|
}
|
|
|
|
export const BUILTIN_AGENT_NAMES = new Set([
|
|
"Sisyphus",
|
|
"oracle",
|
|
"librarian",
|
|
"explore",
|
|
"frontend-ui-ux-engineer",
|
|
"document-writer",
|
|
"multimodal-looker",
|
|
"Metis (Plan Consultant)",
|
|
"Momus (Plan Reviewer)",
|
|
"Prometheus (Planner)",
|
|
"orchestrator-sisyphus",
|
|
"build",
|
|
])
|
|
|
|
// Migration map: old hook names → new hook names (for backward compatibility)
|
|
export const HOOK_NAME_MAP: Record<string, string> = {
|
|
// Legacy names (backward compatibility)
|
|
"anthropic-auto-compact": "anthropic-context-window-limit-recovery",
|
|
}
|
|
|
|
// Model to category mapping for auto-migration
|
|
export const MODEL_TO_CATEGORY_MAP: Record<string, string> = {
|
|
"google/gemini-3-pro-preview": "visual-engineering",
|
|
"openai/gpt-5.2": "ultrabrain",
|
|
"anthropic/claude-haiku-4-5": "quick",
|
|
"anthropic/claude-opus-4-5": "most-capable",
|
|
"anthropic/claude-sonnet-4-5": "general",
|
|
}
|
|
|
|
export function migrateAgentNames(agents: Record<string, unknown>): { migrated: Record<string, unknown>; changed: boolean } {
|
|
const migrated: Record<string, unknown> = {}
|
|
let changed = false
|
|
|
|
for (const [key, value] of Object.entries(agents)) {
|
|
const newKey = AGENT_NAME_MAP[key.toLowerCase()] ?? AGENT_NAME_MAP[key] ?? key
|
|
if (newKey !== key) {
|
|
changed = true
|
|
}
|
|
migrated[newKey] = value
|
|
}
|
|
|
|
return { migrated, changed }
|
|
}
|
|
|
|
export function migrateHookNames(hooks: string[]): { migrated: string[]; changed: boolean } {
|
|
const migrated: string[] = []
|
|
let changed = false
|
|
|
|
for (const hook of hooks) {
|
|
const newHook = HOOK_NAME_MAP[hook] ?? hook
|
|
if (newHook !== hook) {
|
|
changed = true
|
|
}
|
|
migrated.push(newHook)
|
|
}
|
|
|
|
return { migrated, changed }
|
|
}
|
|
|
|
export function migrateAgentConfigToCategory(config: Record<string, unknown>): {
|
|
migrated: Record<string, unknown>
|
|
changed: boolean
|
|
} {
|
|
const { model, ...rest } = config
|
|
if (typeof model !== "string") {
|
|
return { migrated: config, changed: false }
|
|
}
|
|
|
|
const category = MODEL_TO_CATEGORY_MAP[model]
|
|
if (!category) {
|
|
return { migrated: config, changed: false }
|
|
}
|
|
|
|
return {
|
|
migrated: { category, ...rest },
|
|
changed: true,
|
|
}
|
|
}
|
|
|
|
export function shouldDeleteAgentConfig(
|
|
config: Record<string, unknown>,
|
|
category: string
|
|
): boolean {
|
|
const { DEFAULT_CATEGORIES } = require("../tools/sisyphus-task/constants")
|
|
const defaults = DEFAULT_CATEGORIES[category]
|
|
if (!defaults) return false
|
|
|
|
const keys = Object.keys(config).filter((k) => k !== "category")
|
|
if (keys.length === 0) return true
|
|
|
|
for (const key of keys) {
|
|
if (config[key] !== (defaults as Record<string, unknown>)[key]) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
export function migrateConfigFile(configPath: string, rawConfig: Record<string, unknown>): boolean {
|
|
let needsWrite = false
|
|
|
|
if (rawConfig.agents && typeof rawConfig.agents === "object") {
|
|
const { migrated, changed } = migrateAgentNames(rawConfig.agents as Record<string, unknown>)
|
|
if (changed) {
|
|
rawConfig.agents = migrated
|
|
needsWrite = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (rawConfig.omo_agent) {
|
|
rawConfig.sisyphus_agent = rawConfig.omo_agent
|
|
delete rawConfig.omo_agent
|
|
needsWrite = true
|
|
}
|
|
|
|
if (rawConfig.disabled_hooks && Array.isArray(rawConfig.disabled_hooks)) {
|
|
const { migrated, changed } = migrateHookNames(rawConfig.disabled_hooks as string[])
|
|
if (changed) {
|
|
rawConfig.disabled_hooks = migrated
|
|
needsWrite = true
|
|
}
|
|
}
|
|
|
|
if (needsWrite) {
|
|
try {
|
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-")
|
|
const backupPath = `${configPath}.bak.${timestamp}`
|
|
fs.copyFileSync(configPath, backupPath)
|
|
|
|
fs.writeFileSync(configPath, JSON.stringify(rawConfig, null, 2) + "\n", "utf-8")
|
|
log(`Migrated config file: ${configPath} (backup: ${backupPath})`)
|
|
} catch (err) {
|
|
log(`Failed to write migrated config to ${configPath}:`, err)
|
|
}
|
|
}
|
|
|
|
return needsWrite
|
|
}
|