- Split 25+ index.ts files into hook.ts + extracted modules - Rename all catch-all utils.ts/helpers.ts to domain-specific names - Split src/tools/lsp/ into ~15 focused modules - Split src/tools/delegate-task/ into ~18 focused modules - Separate shared types from implementation - 155 files changed, 60+ new files created - All typecheck clean, 61 tests pass
45 lines
1.3 KiB
TypeScript
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 (!isCallerOrchestrator(input.sessionID)) {
|
|
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,
|
|
})
|
|
},
|
|
}
|
|
}
|