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:
@@ -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(
|
||||
userConfig?.disabledHooks,
|
||||
projectConfig?.disabledHooks
|
||||
DEFAULT_DISABLED_HOOKS,
|
||||
mergeDisabledHooks(
|
||||
userConfig?.disabledHooks,
|
||||
projectConfig?.disabledHooks
|
||||
)
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user