feat(hooks): disable redundant inject hooks by default in Claude Code compatibility layer

Automatically disables these Claude Code hooks that duplicate oh-my-opencode functionality:
- inject_rules.py (replaced by rules-injector hook)
- inject_readme.py (replaced by directory-readme-injector hook)
- inject_knowledge.py (replaced by directory-agents-injector hook)
- remind*rules*.py (replaced by rules-injector hook)

Users can override via opencode-cc-plugin.json if needed.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-11 11:31:51 +09:00
parent fcdfcd3186
commit dd645994b2

View File

@@ -21,6 +21,15 @@ function getProjectConfigPath(): string {
return join(process.cwd(), ".opencode", "opencode-cc-plugin.json")
}
const DEFAULT_DISABLED_HOOKS: DisabledHooksConfig = {
PostToolUse: [
"inject_rules\\.py$",
"inject_readme\\.py$",
"inject_knowledge\\.py$",
"remind.*rules.*\\.py$",
],
}
async function loadConfigFromPath(path: string): Promise<PluginExtendedConfig | null> {
if (!existsSync(path)) {
return null
@@ -43,10 +52,10 @@ function mergeDisabledHooks(
if (!base) return override
return {
Stop: override.Stop ?? base.Stop,
PreToolUse: override.PreToolUse ?? base.PreToolUse,
PostToolUse: override.PostToolUse ?? base.PostToolUse,
UserPromptSubmit: override.UserPromptSubmit ?? base.UserPromptSubmit,
Stop: [...(base.Stop ?? []), ...(override.Stop ?? [])],
PreToolUse: [...(base.PreToolUse ?? []), ...(override.PreToolUse ?? [])],
PostToolUse: [...(base.PostToolUse ?? []), ...(override.PostToolUse ?? [])],
UserPromptSubmit: [...(base.UserPromptSubmit ?? []), ...(override.UserPromptSubmit ?? [])],
}
}
@@ -56,8 +65,11 @@ export async function loadPluginExtendedConfig(): Promise<PluginExtendedConfig>
const merged: PluginExtendedConfig = {
disabledHooks: mergeDisabledHooks(
DEFAULT_DISABLED_HOOKS,
mergeDisabledHooks(
userConfig?.disabledHooks,
projectConfig?.disabledHooks
)
),
}