27d5379215
Remove the beast-mode-system hook and all transform wiring so Copilot-specific prompt injection is fully eliminated from the runtime pipeline.
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import type { OhMyOpenCodeConfig } from "../../config"
|
|
import type { PluginContext } from "../types"
|
|
|
|
import {
|
|
createClaudeCodeHooksHook,
|
|
createKeywordDetectorHook,
|
|
createThinkingBlockValidatorHook,
|
|
} from "../../hooks"
|
|
import {
|
|
contextCollector,
|
|
createContextInjectorMessagesTransformHook,
|
|
} from "../../features/context-injector"
|
|
import { safeCreateHook } from "../../shared/safe-create-hook"
|
|
|
|
export type TransformHooks = {
|
|
claudeCodeHooks: ReturnType<typeof createClaudeCodeHooksHook> | null
|
|
keywordDetector: ReturnType<typeof createKeywordDetectorHook> | null
|
|
contextInjectorMessagesTransform: ReturnType<typeof createContextInjectorMessagesTransformHook>
|
|
thinkingBlockValidator: ReturnType<typeof createThinkingBlockValidatorHook> | null
|
|
}
|
|
|
|
export function createTransformHooks(args: {
|
|
ctx: PluginContext
|
|
pluginConfig: OhMyOpenCodeConfig
|
|
isHookEnabled: (hookName: string) => boolean
|
|
safeHookEnabled?: boolean
|
|
}): TransformHooks {
|
|
const { ctx, pluginConfig, isHookEnabled } = args
|
|
const safeHookEnabled = args.safeHookEnabled ?? true
|
|
|
|
const claudeCodeHooks = isHookEnabled("claude-code-hooks")
|
|
? safeCreateHook(
|
|
"claude-code-hooks",
|
|
() =>
|
|
createClaudeCodeHooksHook(
|
|
ctx,
|
|
{
|
|
disabledHooks: (pluginConfig.claude_code?.hooks ?? true) ? undefined : true,
|
|
keywordDetectorDisabled: !isHookEnabled("keyword-detector"),
|
|
},
|
|
contextCollector,
|
|
),
|
|
{ enabled: safeHookEnabled },
|
|
)
|
|
: null
|
|
|
|
const keywordDetector = isHookEnabled("keyword-detector")
|
|
? safeCreateHook(
|
|
"keyword-detector",
|
|
() => createKeywordDetectorHook(ctx, contextCollector),
|
|
{ enabled: safeHookEnabled },
|
|
)
|
|
: null
|
|
|
|
const contextInjectorMessagesTransform =
|
|
createContextInjectorMessagesTransformHook(contextCollector)
|
|
|
|
const thinkingBlockValidator = isHookEnabled("thinking-block-validator")
|
|
? safeCreateHook(
|
|
"thinking-block-validator",
|
|
() => createThinkingBlockValidatorHook(),
|
|
{ enabled: safeHookEnabled },
|
|
)
|
|
: null
|
|
|
|
return {
|
|
claudeCodeHooks,
|
|
keywordDetector,
|
|
contextInjectorMessagesTransform,
|
|
thinkingBlockValidator,
|
|
}
|
|
}
|