refactor(athena): rename session_handoff to switch_agent to avoid confusion with /handoff command

Rename across all layers to eliminate naming ambiguity:
- Tool: session_handoff → switch_agent
- Hook: agent-handoff → agent-switch
- Feature: agent-handoff/ → agent-switch/
- Types: SessionHandoffArgs → SwitchAgentArgs, PendingHandoff → PendingSwitch
- Functions: setPendingHandoff → setPendingSwitch, consumePendingHandoff → consumePendingSwitch

/handoff = inter-session context summary (existing command)
switch_agent = intra-session active agent change (our new tool)
This commit is contained in:
ismeth
2026-02-13 13:18:07 +01:00
committed by YeonGyu-Kim
parent 7db0f110ee
commit 84185490f9
22 changed files with 139 additions and 139 deletions
+37
View File
@@ -0,0 +1,37 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { consumePendingSwitch } from "../../features/agent-switch"
import { log } from "../../shared/logger"
const HOOK_NAME = "agent-switch" as const
export function createAgentSwitchHook(ctx: PluginInput) {
return {
event: async (input: { event: { type: string; properties?: Record<string, unknown> } }): Promise<void> => {
if (input.event.type !== "session.idle") return
const props = input.event.properties as Record<string, unknown> | undefined
const sessionID = props?.sessionID as string | undefined
if (!sessionID) return
const pending = consumePendingSwitch(sessionID)
if (!pending) return
log(`[${HOOK_NAME}] Switching to ${pending.agent}`, { sessionID })
try {
await ctx.client.session.promptAsync({
path: { id: sessionID },
body: {
agent: pending.agent,
parts: [{ type: "text", text: pending.context }],
},
query: { directory: ctx.directory },
})
log(`[${HOOK_NAME}] Switch to ${pending.agent} complete`, { sessionID })
} catch (err) {
log(`[${HOOK_NAME}] Switch failed`, { sessionID, error: String(err) })
}
},
}
}
+1
View File
@@ -0,0 +1 @@
export { createAgentSwitchHook } from "./hook"