copilotPluginConverters.ts ×16

Frontier kind: Code frontier

unlabeled · c_c02cedc462cc

4 tests · 19279 LOC · 67 files · introduces 0 tests · 60 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges60 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2010 ranges19279 lines · 67 files · Browse complete extent
All tests (intent)
4 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: 60 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/copilotPluginConverters.ts 60 introduced LOC · 16 ranges

Open complete file

283 * Resolves the effective command for the current platform from a parsed hook command.
284 */
285 > function resolveEffectiveCommand(hook: IParsedHookCommand, os: OperatingSystem): string | undefined { copilotPluginConverters.ts
286 > if (os === OperatingSystem.Windows && hook.windows) {
287 return hook.windows;
288 > } else if (os === OperatingSystem.Macintosh && hook.osx) { copilotPluginConverters.ts
289 return hook.osx;
290 > } else if (os === OperatingSystem.Linux && hook.linux) { copilotPluginConverters.ts
291 return hook.linux;
292 }
293 > return hook.command; copilotPluginConverters.ts
294 > }
295
296 /**
298 * or throws on non-zero exit code or timeout.
299 */
300 > function executeHookCommand(hook: IParsedHookCommand, stdin?: string): Promise<string> { copilotPluginConverters.ts
301 > const command = resolveEffectiveCommand(hook, OS);
302 > if (!command) {
303 return Promise.resolve('');
304 }
306 > const timeout = (hook.timeout ?? 30) * 1000;
307 > const cwd = hook.cwd?.fsPath;
308 >
309 > return new Promise<string>((resolve, reject) => {
310 > const isWindows = OS === OperatingSystem.Windows;
311 > const shell = isWindows ? 'cmd.exe' : '/bin/sh';
312 > const shellArgs = isWindows ? ['/c', command] : ['-c', command];
313 >
314 > const child = spawn(shell, shellArgs, {
315 > cwd,
316 > env: { ...process.env, ...hook.env },
317 > stdio: ['pipe', 'pipe', 'pipe'],
318 > timeout,
319 > });
320 >
321 > let stdout = '';
322 > let stderr = '';
323 >
324 > child.stdout.on('data', (data: Buffer) => { stdout += data.toString(); });
325 > child.stderr.on('data', (data: Buffer) => { stderr += data.toString(); });
326 >
327 > if (stdin) {
328 > child.stdin.write(stdin);
329 > child.stdin.end();
330 > } else {
331 child.stdin.end();
332 }
334 > child.on('error', reject);
335 > child.on('close', (code) => {
336 > if (code === 0) {
337 resolve(stdout);
339 reject(new Error(`Hook command exited with code ${code}: ${stderr || stdout}`));
340 }
342 > });
343 > }
344
345 /**
349 * Command failures are swallowed — hooks are non-fatal.
350 */
351 > async function runHookCommands(commands: readonly IParsedHookCommand[] | undefined, input: unknown): Promise<object | undefined> { copilotPluginConverters.ts
352 > if (!commands) {
353 return undefined;
354 }
355 > const stdin = JSON.stringify(input); copilotPluginConverters.ts
356 > for (const cmd of commands) {
357 > try {
358 > const output = await executeHookCommand(cmd, stdin);
359 if (output.trim()) {
360 try {
405 const commandsByKey = new Map<keyof SessionHooks, IParsedHookCommand[]>();
406 for (const group of hookGroups) {
407 > const sdkKey = HOOK_TYPE_TO_SDK_KEY[group.type]; copilotPluginConverters.ts
408 > if (!sdkKey) {
409 continue;
410 }
411 > const existing = commandsByKey.get(sdkKey) ?? []; copilotPluginConverters.ts
412 > existing.push(...group.commands);
413 > commandsByKey.set(sdkKey, existing);
414 > }
415
416 const hooks: SessionHooks = {};
429 if (postToolCommands?.length || editTrackingHooks) {
430 hooks.onPostToolUse = async (input: PostToolUseHookInput) => {
431 > await editTrackingHooks?.onPostToolUse(input); copilotPluginConverters.ts
432 > return runHookCommands(postToolCommands, input);
433 > };
434 }
435