diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index 0b54b901c..bf9fa5196 100755 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -1034,8 +1034,9 @@ export async function loadCliConfig( format: outputSettingsFormat, }, hooks: settings.hooks, + hooksConfig: settings.hooksConfig, enableHooks: - argv.experimentalHooks === true || settings.hooks?.enabled === true, + argv.experimentalHooks === true || settings.hooksConfig?.enabled === true, channel: argv.channel, // Precedence: explicit CLI flag > settings file > default(true). // NOTE: do NOT set a yargs default for `chat-recording`, otherwise argv will diff --git a/packages/cli/src/config/settingsSchema.ts b/packages/cli/src/config/settingsSchema.ts index 9ef11cf4f..73c47a650 100644 --- a/packages/cli/src/config/settingsSchema.ts +++ b/packages/cli/src/config/settingsSchema.ts @@ -1177,24 +1177,24 @@ const SETTINGS_SCHEMA = { showInDialog: false, }, - hooks: { + hooksConfig: { type: 'object', - label: 'Hooks', + label: 'Hooks Config', category: 'Advanced', requiresRestart: false, default: {}, description: - 'Hook configurations for extending CLI behavior at various lifecycle points.', + 'Hook configurations for intercepting and customizing agent behavior.', showInDialog: false, properties: { enabled: { type: 'boolean', label: 'Enable Hooks', category: 'Advanced', - requiresRestart: false, - default: false, + requiresRestart: true, + default: true, description: - 'Enable the hooks feature. When enabled, hooks defined in UserPromptSubmit and Stop will be executed.', + 'Canonical toggle for the hooks system. When disabled, no hooks will be executed.', showInDialog: false, }, disabled: { @@ -1204,10 +1204,23 @@ const SETTINGS_SCHEMA = { requiresRestart: false, default: [] as string[], description: - 'List of hook names to disable. Hooks in this list will not be executed.', + 'List of hook names (commands) that should be disabled. Hooks in this list will not execute even if configured.', showInDialog: false, mergeStrategy: MergeStrategy.UNION, }, + }, + }, + + hooks: { + type: 'object', + label: 'Hooks', + category: 'Advanced', + requiresRestart: false, + default: {}, + description: + 'Hook event configurations for extending CLI behavior at various lifecycle points.', + showInDialog: false, + properties: { UserPromptSubmit: { type: 'array', label: 'Before Agent Hooks', diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index bf20f1172..61ec4dfe7 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -388,6 +388,8 @@ export interface ConfigParameters { enableHooks?: boolean; /** Hooks configuration from settings */ hooks?: Record; + /** Hooks config settings (enabled, disabled list) */ + hooksConfig?: Record; /** Warnings generated during configuration resolution */ warnings?: string[]; } @@ -532,6 +534,7 @@ export class Config { private readonly defaultFileEncoding: FileEncodingType; private readonly enableHooks: boolean; private readonly hooks?: Record; + private readonly hooksConfig?: Record; private hookSystem?: HookSystem; private messageBus?: MessageBus; @@ -690,6 +693,7 @@ export class Config { }); this.enableHooks = params.enableHooks ?? false; this.hooks = params.hooks; + this.hooksConfig = params.hooksConfig; } /** @@ -1506,9 +1510,9 @@ export class Config { * This is used by the HookRegistry to filter out disabled hooks. */ getDisabledHooks(): string[] { - const hooks = this.hooks; - if (!hooks) return []; - const disabled = hooks['disabled']; + const hooksConfig = this.hooksConfig; + if (!hooksConfig) return []; + const disabled = hooksConfig['disabled']; return Array.isArray(disabled) ? (disabled as string[]) : []; }