-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add initial hooks support #292699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial hooks support #292699
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Introduces initial “chat hooks” support, including a hooks.json schema + discovery, UI entry points to create/manage hook files, and a proposed API (vscode.chat.executeHook) with main-thread ↔ extension-host plumbing to execute configured hook commands.
Changes:
- Add hook configuration parsing/schema (Copilot hooks.json + Claude settings compatibility) and hook discovery via
IPromptsService.getHooks(). - Surface hook configuration in the workbench (new hook file action + “Configure Hooks” picker) and plumb collected hooks into chat agent requests.
- Implement proposed API + RPC wiring + Node extension-host execution for hook commands, with tests for parsing/compat and ext-host execution.
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.chatHooks.d.ts | Adds proposed chatHooks API typings (hook types, execution, result). |
| src/vs/workbench/contrib/chat/test/common/promptSyntax/service/mockPromptsService.ts | Updates prompts service mock to satisfy new getHooks API. |
| src/vs/workbench/contrib/chat/test/common/promptSyntax/hookSchema.test.ts | Unit tests for hook type normalization + hook command resolution. |
| src/vs/workbench/contrib/chat/test/common/promptSyntax/hookClaudeCompat.test.ts | Unit tests for Claude hook compatibility parsing/mapping. |
| src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts | Stubs IPromptsService for chat service tests after DI change. |
| src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts | Implements hook file discovery/parsing + caching via getHooks(). |
| src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts | Extends IPromptsService with getHooks(). |
| src/vs/workbench/contrib/chat/common/promptSyntax/promptTypes.ts | Adds hook docs URL + language-id mapping for hook prompt type. |
| src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.ts | Updates validator attribute sets to handle new hook prompt type. |
| src/vs/workbench/contrib/chat/common/promptSyntax/hookSchema.ts | Defines hook schema/types and helpers for command resolution/labels. |
| src/vs/workbench/contrib/chat/common/promptSyntax/hookCompatibility.ts | Adds format detection + parsing dispatch across supported formats. |
| src/vs/workbench/contrib/chat/common/promptSyntax/hookClaudeCompat.ts | Implements Claude settings.json hook parsing compatibility. |
| src/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations.ts | Adds hook file locations/types (hooks.json + .claude settings). |
| src/vs/workbench/contrib/chat/common/promptSyntax/config/config.ts | Introduces settings keys for hook file locations + enablement. |
| src/vs/workbench/contrib/chat/common/promptSyntax/chatPromptFilesContribution.ts | Extends prompt file listing command to include hooks. |
| src/vs/workbench/contrib/chat/common/participants/chatAgents.ts | Plumbs collected hooks into IChatAgentRequest. |
| src/vs/workbench/contrib/chat/common/hooksExecutionService.ts | Adds main-thread service abstraction for executing hooks via proxy. |
| src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts | Collects hooks via prompts service and attaches to chat requests. |
| src/vs/workbench/contrib/chat/browser/promptSyntax/promptFileActions.ts | Registers hook-related actions alongside other prompt actions. |
| src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.ts | Adds hook help button support in prompt pickers. |
| src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.ts | Adds hook-related picker strings + disallows copy/move for hooks. |
| src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.ts | Adds “New Hook File…” command to create/extend hooks.json. |
| src/vs/workbench/contrib/chat/browser/promptSyntax/hookUtils.ts | Adds helper to select newly-added hook command in JSON content. |
| src/vs/workbench/contrib/chat/browser/promptSyntax/hookActions.ts | Adds “Configure Hooks…” action and quick pick UI for hook entries. |
| src/vs/workbench/contrib/chat/browser/chat.contribution.ts | Registers hook JSON schema + hook-related configuration + service singleton. |
| src/vs/workbench/api/test/node/extHostHooks.test.ts | Adds tests for extension-host hook execution behavior. |
| src/vs/workbench/api/node/extHostHooksNode.ts | Implements Node extension-host hook execution via child_process. |
| src/vs/workbench/api/node/extHost.node.services.ts | Registers IExtHostHooks singleton for node extension host. |
| src/vs/workbench/api/common/extHostTypes.ts | Adds ChatHookResultKind to ext host types. |
| src/vs/workbench/api/common/extHostHooks.ts | Defines ext-host hooks service interface + RPC shape. |
| src/vs/workbench/api/common/extHostChatAgents2.ts | Stores hooks on in-flight requests + exposes getHooksForSession. |
| src/vs/workbench/api/common/extHost.protocol.ts | Adds RPC identifiers and DTO for hook execution results. |
| src/vs/workbench/api/common/extHost.api.impl.ts | Wires proposed vscode.chat.executeHook to ext-host implementation. |
| src/vs/workbench/api/browser/mainThreadHooks.ts | Main-thread customer that forwards executions to the extension host. |
| src/vs/workbench/api/browser/extensionHost.contribution.ts | Registers main-thread hooks customer. |
| src/vs/platform/extensions/common/extensionsApiProposals.ts | Registers chatHooks proposal + version. |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/promptSyntax/hookUtils.ts:69
- Related to the above: treating any '}' while bracketDepth===1 as the end of the target object can trigger on nested object closures (like the end of an
envobject), causing early termination and incorrect/undefined selections. This should be based on proper JSON structure rather than character scanning.
} else if (char === '}' && inTargetObject && bracketDepth === 1) {
// End of the target object, search for field within this object
for (let j = targetObjectStartLine; j <= i; j++) {
Initial config handling/API work for hooks support