Files
oh-my-opencode/src/hooks/sisyphus-junior-notepad/hook.ts
T
YeonGyu-Kim 068831f79e refactor: cleanup shared constants and add async SDK support for isCallerOrchestrator
- Use shared OPENCODE_STORAGE, MESSAGE_STORAGE, PART_STORAGE constants
- Make isCallerOrchestrator async with SDK fallback for beta
- Fix cache implementation using Symbol sentinel
- Update atlas hooks and sisyphus-junior-notepad to use async isCallerOrchestrator
2026-02-16 16:13:40 +09:00

45 lines
1.3 KiB
TypeScript

import type { PluginInput } from "@opencode-ai/plugin"
import { isCallerOrchestrator } from "../../shared/session-utils"
import { SYSTEM_DIRECTIVE_PREFIX } from "../../shared/system-directive"
import { log } from "../../shared/logger"
import { HOOK_NAME, NOTEPAD_DIRECTIVE } from "./constants"
export function createSisyphusJuniorNotepadHook(ctx: PluginInput) {
return {
"tool.execute.before": async (
input: { tool: string; sessionID: string; callID: string },
output: { args: Record<string, unknown>; message?: string }
): Promise<void> => {
// 1. Check if tool is task
if (input.tool !== "task") {
return
}
// 2. Check if caller is Atlas (orchestrator)
if (!(await isCallerOrchestrator(input.sessionID, ctx.client))) {
return
}
// 3. Get prompt from output.args
const prompt = output.args.prompt as string | undefined
if (!prompt) {
return
}
// 4. Check for double injection
if (prompt.includes(SYSTEM_DIRECTIVE_PREFIX)) {
return
}
// 5. Prepend directive
output.args.prompt = NOTEPAD_DIRECTIVE + prompt
// 6. Log injection
log(`[${HOOK_NAME}] Injected notepad directive to task`, {
sessionID: input.sessionID,
})
},
}
}