fix(migration): add hook rename and removal mappings for v3.0.0 upgrade

- Add sisyphus-orchestrator → atlas hook rename mapping
- Add null mappings for removed hooks (preemptive-compaction, empty-message-sanitizer)
- Update migrateHookNames() to filter out removed hooks and return removed list
- Log warning when obsolete hooks are removed from disabled_hooks
- Add tests for new migration scenarios
This commit is contained in:
justsisyphus
2026-01-23 01:24:07 +09:00
parent 45b2782d55
commit e15677efd5
2 changed files with 74 additions and 8 deletions
+23 -5
View File
@@ -36,9 +36,15 @@ export const BUILTIN_AGENT_NAMES = new Set([
])
// Migration map: old hook names → new hook names (for backward compatibility)
export const HOOK_NAME_MAP: Record<string, string> = {
// null means the hook was removed and should be filtered out from disabled_hooks
export const HOOK_NAME_MAP: Record<string, string | null> = {
// Legacy names (backward compatibility)
"anthropic-auto-compact": "anthropic-context-window-limit-recovery",
"sisyphus-orchestrator": "atlas",
// Removed hooks (v3.0.0) - will be filtered out and user warned
"preemptive-compaction": null,
"empty-message-sanitizer": null,
}
/**
@@ -77,19 +83,28 @@ export function migrateAgentNames(agents: Record<string, unknown>): { migrated:
return { migrated, changed }
}
export function migrateHookNames(hooks: string[]): { migrated: string[]; changed: boolean } {
export function migrateHookNames(hooks: string[]): { migrated: string[]; changed: boolean; removed: string[] } {
const migrated: string[] = []
const removed: string[] = []
let changed = false
for (const hook of hooks) {
const newHook = HOOK_NAME_MAP[hook] ?? hook
const mapping = HOOK_NAME_MAP[hook]
if (mapping === null) {
removed.push(hook)
changed = true
continue
}
const newHook = mapping ?? hook
if (newHook !== hook) {
changed = true
}
migrated.push(newHook)
}
return { migrated, changed }
return { migrated, changed, removed }
}
export function migrateAgentConfigToCategory(config: Record<string, unknown>): {
@@ -167,11 +182,14 @@ export function migrateConfigFile(configPath: string, rawConfig: Record<string,
}
if (rawConfig.disabled_hooks && Array.isArray(rawConfig.disabled_hooks)) {
const { migrated, changed } = migrateHookNames(rawConfig.disabled_hooks as string[])
const { migrated, changed, removed } = migrateHookNames(rawConfig.disabled_hooks as string[])
if (changed) {
rawConfig.disabled_hooks = migrated
needsWrite = true
}
if (removed.length > 0) {
log(`Removed obsolete hooks from disabled_hooks: ${removed.join(", ")} (these hooks no longer exist in v3.0.0)`)
}
}
if (needsWrite) {