hookTypes.ts ×1

Frontier kind: Code frontier

unlabeled · c_c13743040d59

583 tests · 14124 LOC · 55 files · introduces 0 tests · 122 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
1 range122 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1090 ranges14124 lines · 55 files · Browse complete extent
All tests (intent)
583 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 122 introduced LOC across 1 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/promptSyntax/hookTypes.ts 122 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- hookTypes.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as nls from '../../../../../nls.js';
7 > import { Target } from './promptTypes.js';
8 >
9 > /**
10 > * Enum of hook types across all targets. For the set of supported hooks per target, see HOOKS_BY_TARGET.
11 > */
12 > export enum HookType {
13 > SessionStart = 'SessionStart',
14 > SessionEnd = 'SessionEnd',
15 > UserPromptSubmit = 'UserPromptSubmit',
16 > PreToolUse = 'PreToolUse',
17 > PostToolUse = 'PostToolUse',
18 > PreCompact = 'PreCompact',
19 > SubagentStart = 'SubagentStart',
20 > SubagentStop = 'SubagentStop',
21 > Stop = 'Stop',
22 > ErrorOccurred = 'ErrorOccurred',
23 > }
24 >
25 > /**
26 > * String literal type derived from HookType enum values.
27 > */
28 > export type HookTypeValue = `${HookType}`;
29 >
30 > export const HOOKS_BY_TARGET: Record<Target, Record<string, HookType>> = {
31 > // see https://code.visualstudio.com/docs/copilot/customization/hooks#_hook-lifecycle-events
32 > [Target.VSCode]: {
33 > 'SessionStart': HookType.SessionStart,
34 > 'UserPromptSubmit': HookType.UserPromptSubmit,
35 > 'PreToolUse': HookType.PreToolUse,
36 > 'PostToolUse': HookType.PostToolUse,
37 > 'PreCompact': HookType.PreCompact,
38 > 'SubagentStart': HookType.SubagentStart,
39 > 'SubagentStop': HookType.SubagentStop,
40 > 'Stop': HookType.Stop,
41 > },
42 > // see https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-hooks#types-of-hooks
43 > [Target.GitHubCopilot]: {
44 > 'sessionStart': HookType.SessionStart,
45 > 'sessionEnd': HookType.SessionEnd,
46 > 'userPromptSubmitted': HookType.UserPromptSubmit,
47 > 'preToolUse': HookType.PreToolUse,
48 > 'postToolUse': HookType.PostToolUse,
49 > 'agentStop': HookType.Stop,
50 > 'subagentStop': HookType.SubagentStop,
51 > 'errorOccurred': HookType.ErrorOccurred
52 > },
53 > // see https://docs.anthropic.com/en/docs/claude-code/hooks
54 > [Target.Claude]: {
55 > 'SessionStart': HookType.SessionStart,
56 > 'UserPromptSubmit': HookType.UserPromptSubmit,
57 > 'PreToolUse': HookType.PreToolUse,
58 > 'PostToolUse': HookType.PostToolUse,
59 > 'PreCompact': HookType.PreCompact,
60 > 'SubagentStart': HookType.SubagentStart,
61 > 'SubagentStop': HookType.SubagentStop,
62 > 'Stop': HookType.Stop,
63 > },
64 > // if no target, just list all known hook types.
65 > [Target.Undefined]: Object.fromEntries(
66 > Object.values(HookType).map(h => [h, h])
67 > ) as Record<string, HookType>
68 > };
69 >
70 > /**
71 > * Metadata for a hook type including localized label and description.
72 > */
73 > export interface IHookTypeMeta {
74 > readonly label: string;
75 > readonly description: string;
76 > }
77 >
78 > /**
79 > * Metadata for hook types including localized labels and descriptions
80 > */
81 > export const HOOK_METADATA: { [key in HookType]: IHookTypeMeta } = {
82 > [HookType.SessionStart]: {
83 > label: nls.localize('hookType.sessionStart.label', "Session Start"),
84 > description: nls.localize('hookType.sessionStart.description', "Executed when a new agent session begins.")
85 > },
86 > [HookType.UserPromptSubmit]: {
87 > label: nls.localize('hookType.userPromptSubmit.label', "User Prompt Submit"),
88 > description: nls.localize('hookType.userPromptSubmit.description', "Executed when the user submits a prompt to the agent.")
89 > },
90 > [HookType.PreToolUse]: {
91 > label: nls.localize('hookType.preToolUse.label', "Pre-Tool Use"),
92 > description: nls.localize('hookType.preToolUse.description', "Executed before the agent uses any tool.")
93 > },
94 > [HookType.PostToolUse]: {
95 > label: nls.localize('hookType.postToolUse.label', "Post-Tool Use"),
96 > description: nls.localize('hookType.postToolUse.description', "Executed after a tool completes execution successfully.")
97 > },
98 > [HookType.PreCompact]: {
99 > label: nls.localize('hookType.preCompact.label', "Pre-Compact"),
100 > description: nls.localize('hookType.preCompact.description', "Executed before the agent compacts the conversation context.")
101 > },
102 > [HookType.SubagentStart]: {
103 > label: nls.localize('hookType.subagentStart.label', "Subagent Start"),
104 > description: nls.localize('hookType.subagentStart.description', "Executed when a subagent is started.")
105 > },
106 > [HookType.SubagentStop]: {
107 > label: nls.localize('hookType.subagentStop.label', "Subagent Stop"),
108 > description: nls.localize('hookType.subagentStop.description', "Executed when a subagent stops.")
109 > },
110 > [HookType.Stop]: {
111 > label: nls.localize('hookType.stop.label', "Stop"),
112 > description: nls.localize('hookType.stop.description', "Executed when the agent stops.")
113 > },
114 > [HookType.SessionEnd]: {
115 > label: nls.localize('hookType.sessionEnd.label', "Session End"),
116 > description: nls.localize('hookType.sessionEnd.description', "Executed when an agent session ends.")
117 > },
118 > [HookType.ErrorOccurred]: {
119 > label: nls.localize('hookType.errorOccurred.label', "Error Occurred"),
120 > description: nls.localize('hookType.errorOccurred.description', "Executed when an error occurs during the agent session.")
121 > }
122 > };