agentHostCompletions.ts ×5

Frontier kind: Code frontier

unlabeled · c_198af2daeb5e

785 tests · 13869 LOC · 53 files · introduces 0 tests · 98 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges98 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1321 ranges13869 lines · 53 files · Browse complete extent
All tests (intent)
785 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: 98 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostCompletions.ts 98 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostCompletions.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 { CancellationToken } from '../../../base/common/cancellation.js';
7 > import { Disposable, IDisposable, toDisposable } from '../../../base/common/lifecycle.js';
8 > import { ILogService } from '../../log/common/log.js';
9 > import { createDecorator } from '../../instantiation/common/instantiation.js';
10 > import type { CompletionItem, CompletionItemKind, CompletionsParams, CompletionsResult } from '../common/state/protocol/commands.js';
11 >
12 > export const IAgentHostCompletions = createDecorator<IAgentHostCompletions>('agentHostCompletions');
13 >
14 > /**
15 > * Well-known completion trigger characters announced to clients in the
16 > * `initialize` handshake. Clients SHOULD issue a `completions` request when
17 > * the user types one of these characters in a {@link UserMessage} input.
18 > */
19 > export const enum CompletionTriggerCharacter {
20 > /** File reference, used for `@`-mentions handled by the file completion provider. */
21 > File = '@',
22 > /** File reference, used for `#`-mentions handled by the file completion provider. */
23 > Hash = '#',
24 > /** Leading slash command or skill reference. */
25 > Slash = '/',
26 > }
27 >
28 > /**
29 > * Pluggable provider that contributes {@link CompletionItem}s for one or
30 > * more {@link CompletionItemKind}s.
31 > *
32 > * Providers are registered via {@link IAgentHostCompletions.registerProvider}
33 > * and may be agent-specific (e.g. registered alongside an `IAgent`) or
34 > * generic (e.g. the built-in workspace file completion provider).
35 > */
36 > export interface IAgentHostCompletionItemProvider {
37 > /** Completion kinds this provider handles. Providers are skipped for any other kind. */
38 > readonly kinds: ReadonlySet<CompletionItemKind>;
39 >
40 > /**
41 > * Characters that, when typed by the user, should trigger a request for
42 > * this provider's completions. Aggregated across all registered providers
43 > * and announced to clients via `InitializeResult.completionTriggerCharacters`.
44 > */
45 > readonly triggerCharacters?: readonly string[];
46 >
47 > /**
48 > * Compute completion items for the given input.
49 > *
50 > * Implementations SHOULD respect `token` and return promptly.
51 > * Throwing or rejecting fails this provider only; other providers'
52 > * results are still returned by {@link IAgentHostCompletions.completions}.
53 > */
54 > provideCompletionItems(params: CompletionsParams, token: CancellationToken): Promise<readonly CompletionItem[]>;
55 > }
56 >
57 > /**
58 > * Server-side completions service. Owns a set of pluggable providers and
59 > * fans out a single `completions` request to every provider whose
60 > * {@link IAgentHostCompletionItemProvider.kinds} includes the requested kind.
61 > *
62 > * Provider results are concatenated in registration order; a single failing
63 > * provider does not prevent other providers' results from being returned.
64 > */
65 > export interface IAgentHostCompletions {
66 > readonly _serviceBrand: undefined;
67 >
68 > /**
69 > * Aggregated, deduplicated trigger characters from every registered
70 > * provider. Used to populate `InitializeResult.completionTriggerCharacters`.
71 > */
72 > readonly triggerCharacters: readonly string[];
73 >
74 > /**
75 > * Register a completion provider. The returned {@link IDisposable} unregisters
76 > * the provider when disposed.
77 > */
78 > registerProvider(provider: IAgentHostCompletionItemProvider): IDisposable;
79 >
80 > /**
81 > * Compute completion items by fanning out to all matching providers.
82 > */
83 > completions(params: CompletionsParams, token?: CancellationToken): Promise<CompletionsResult>;
84 > }
85 >
86 > export class AgentHostCompletions extends Disposable implements IAgentHostCompletions {
87 > declare readonly _serviceBrand: undefined;
88 >
89 > private readonly _providers = new Set<IAgentHostCompletionItemProvider>();
90 >
91 > constructor(
92 @ILogService private readonly _logService: ILogService,
93 ) {
94 super();
95 }
97 > get triggerCharacters(): readonly string[] {
98 const seen = new Set<string>();
99 for (const provider of this._providers) {
106 return [...seen];
107 }
109 > registerProvider(provider: IAgentHostCompletionItemProvider): IDisposable {
110 this._providers.add(provider);
111 return toDisposable(() => this._providers.delete(provider));
112 }
114 > async completions(params: CompletionsParams, token: CancellationToken = CancellationToken.None): Promise<CompletionsResult> {
115 const matching = [...this._providers].filter(p => p.kinds.has(params.kind));
116 if (matching.length === 0) {