refactor(hooks): address PR feedback

- Rename getTools/setTools to getActiveTools/setActiveTools
- Add getAllTools to enumerate all configured tools
- Remove text_delta event (use turn_end/agent_end instead)
- Add shortcut conflict detection:
  - Skip shortcuts that conflict with built-in shortcuts (with warning)
  - Log warnings when hooks register same shortcut (last wins)
- Add note about prompt cache invalidation in setActiveTools
- Update plan-mode hook to use agent_end for [DONE:id] parsing
This commit is contained in:
Helmut Januschka 2026-01-03 21:30:19 +01:00 committed by Mario Zechner
parent 5b634ddf75
commit 4ecf3f9422
13 changed files with 175 additions and 153 deletions

View file

@ -447,8 +447,9 @@ export class InteractiveMode {
appendEntryHandler: (customType, data) => {
this.sessionManager.appendCustomEntry(customType, data);
},
getToolsHandler: () => this.session.getActiveToolNames(),
setToolsHandler: (toolNames) => this.session.setActiveToolsByName(toolNames),
getActiveToolsHandler: () => this.session.getActiveToolNames(),
getAllToolsHandler: () => this.session.getAllToolNames(),
setActiveToolsHandler: (toolNames) => this.session.setActiveToolsByName(toolNames),
newSessionHandler: async (options) => {
// Stop any loading animation
if (this.loadingAnimation) {

View file

@ -40,8 +40,9 @@ export async function runPrintMode(
appendEntryHandler: (customType, data) => {
session.sessionManager.appendCustomEntry(customType, data);
},
getToolsHandler: () => session.getActiveToolNames(),
setToolsHandler: (toolNames) => session.setActiveToolsByName(toolNames),
getActiveToolsHandler: () => session.getActiveToolNames(),
getAllToolsHandler: () => session.getAllToolNames(),
setActiveToolsHandler: (toolNames: string[]) => session.setActiveToolsByName(toolNames),
});
hookRunner.onError((err) => {
console.error(`Hook error (${err.hookPath}): ${err.error}`);

View file

@ -200,8 +200,9 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
appendEntryHandler: (customType, data) => {
session.sessionManager.appendCustomEntry(customType, data);
},
getToolsHandler: () => session.getActiveToolNames(),
setToolsHandler: (toolNames) => session.setActiveToolsByName(toolNames),
getActiveToolsHandler: () => session.getActiveToolNames(),
getAllToolsHandler: () => session.getAllToolNames(),
setActiveToolsHandler: (toolNames: string[]) => session.setActiveToolsByName(toolNames),
uiContext: createHookUIContext(),
hasUI: false,
});