feat(core): gate tool use with hooks - #1155
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
# Conflicts: # src/core/task/__tests__/Task.persistence.spec.ts # webview-ui/src/components/settings/__tests__/HooksSettings.spec.tsx
Stack
This is 4 of 4 in the Zoo Code hooks MVP stack. Review and merge from the bottom upward. Do not merge this PR until #1156 is merged.
mainfm/zoo-hooks-contractsfm/zoo-hooks-settingssessionStartintegrationfm/zoo-hooks-session-startpreToolUse, E2E, and documentationSummary
Complete the hooks MVP by applying fail-closed
preToolUsegates at every supported static, custom, and native MCP execution boundary, then document and exercise the full workflow in a real VS Code host.Scope
preToolUsehooks after tool and argument validation but before approval, checkpointing, or execution.docs/hooks.md.Tool Gate
flowchart TD A[Model requests tool] --> B[Resolve tool and validate arguments] B -->|invalid or disallowed| C[Existing validation result] B -->|valid| D[Find exact preToolUse hooks] D --> E[Run hooks sequentially] E -->|all allow| F[Approval and checkpoint flow] F --> G[Execute static, custom, or MCP tool] E -->|block, error, timeout, cancel| H[Skip approval and execution] H --> I[Emit exactly one real tool result] G --> ITests
src/core/assistant-message/__tests__/presentAssistantMessage-custom-tool.spec.tssrc/core/assistant-message/__tests__/presentAssistantMessage-images.spec.tssrc/core/task/__tests__/Task.persistence.spec.tssrc/core/tools/__tests__/useMcpToolTool.spec.tssrc/core/webview/__tests__/webviewMessageHandler.spec.tswebview-ui/src/components/settings/__tests__/HooksSettings.spec.tsxpackages/types/src/__tests__/hooks.test.tsapps/vscode-e2e/src/suite/hooks.test.tspnpm testpassed (437 files, 7,356 tests; 39 skipped).pnpm check-types,pnpm lint, andpnpm buildpassed.USE_MOCK=true TEST_FILE=hooks.test pnpm --filter @roo-code/vscode-e2e test:runpassed.Risks
Review Notes
fm/zoo-hooks-session-start, notmain.da0d545b6carries the intermediate-branch CI fixes forward without rewriting published history.e484eeae8carries the Windows runner portability fix from#1156into this top branch.72fb1097fcarries the explicit Windows system-binary path fix forward.dffdf7390carries deterministic Windows-path coverage forward.2e98360d6carries the final taskkill fallback cleanup forward.#1153->#1154->#1156->#1155.