@github/copilot-language-server 1.251.0 → 1.253.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/types.d.ts +96 -46
- package/dist/language-server.js +257 -256
- package/dist/language-server.js.map +3 -3
- package/native/darwin-arm64/copilot-language-server +0 -0
- package/native/darwin-x64/copilot-language-server +0 -0
- package/native/linux-x64/copilot-language-server +0 -0
- package/native/win32-x64/copilot-language-server.exe +0 -0
- package/package.json +2 -2
package/dist/api/types.d.ts
CHANGED
|
@@ -1,54 +1,62 @@
|
|
|
1
1
|
import {CancellationToken, Disposable, DocumentSelector, DocumentUri} from 'vscode-languageserver-protocol';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Code snippet extracted from a file. The URI is used for content exclusion.
|
|
22
|
-
export interface CodeSnippet extends ContextItem {
|
|
23
|
-
uri: string;
|
|
24
|
-
value: string;
|
|
25
|
-
// Additional URIs that contribute the same code snippet.
|
|
26
|
-
additionalUris?: string[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type SupportedContextItem = Trait | CodeSnippet;
|
|
30
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The ContextProvider API allows extensions to provide additional context items that
|
|
5
|
+
* Copilot can use in its prompt. This file contains type definitions for the methods
|
|
6
|
+
* and the data structures used by the API.
|
|
7
|
+
*
|
|
8
|
+
* Note: providing context is not enough to ensure that the context will be used in the prompt.
|
|
9
|
+
*
|
|
10
|
+
* The API is exposed as an export of the Copilot extension. To use it, you can cast the
|
|
11
|
+
* exported object to the ContextProviderApiV1 interface.
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
* ```
|
|
15
|
+
* const copilot = vscode.extensions.getExtension("github.copilot");
|
|
16
|
+
* const contextProviderAPI = copilot.exports.getContextProviderAPI("v1") as ContextProviderApiV1;
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
31
19
|
export interface ContextProviderApiV1 {
|
|
32
20
|
registerContextProvider<T extends SupportedContextItem>(provider: ContextProvider<T>): Disposable;
|
|
33
21
|
}
|
|
34
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Each extension can register a number of context providers, uniquely identified by their ID.
|
|
25
|
+
* In addition, each provider has to provide:
|
|
26
|
+
* - a DocumentSelector, to specify the file types for which the provider is active
|
|
27
|
+
* - a ContextResolver, a function that returns the context items for a given request
|
|
28
|
+
*
|
|
29
|
+
* Example:
|
|
30
|
+
* ```
|
|
31
|
+
* contextProviderAPI.registerContextProvider<Trait>({
|
|
32
|
+
* id: "pythonProvider",
|
|
33
|
+
* selector: [{ language: "python" }],
|
|
34
|
+
* resolver: {
|
|
35
|
+
* resolve: async (request, token) => {
|
|
36
|
+
* return [{name: 'traitName', value: 'traitValue'}];
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
35
42
|
export interface ContextProvider<T extends SupportedContextItem> {
|
|
36
43
|
id: string;
|
|
37
44
|
selector: DocumentSelector;
|
|
38
45
|
resolver: ContextResolver<T>;
|
|
39
46
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
resolve(context: CompletionContext, token: CancellationToken): Promise<T> | Promise<T[]> | AsyncIterable<T>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface DocumentContext {
|
|
46
|
-
uri: DocumentUri;
|
|
47
|
-
languageId: string;
|
|
48
|
-
version: number;
|
|
49
|
-
offset: number;
|
|
47
|
+
export interface ContextResolver<T extends SupportedContextItem> {
|
|
48
|
+
resolve(request: ResolveRequest, token: CancellationToken): Promise<T> | Promise<T[]> | AsyncIterable<T>;
|
|
50
49
|
}
|
|
51
50
|
|
|
51
|
+
/**
|
|
52
|
+
* The first argument of the resolve method is a ResolveRequest object, which informs
|
|
53
|
+
* the provider about:
|
|
54
|
+
* - the completionId, a unique identifier for the completion request
|
|
55
|
+
* - the documentContext, which contains information about the document for which the context is requested
|
|
56
|
+
* - the activeExperiments, a map of active experiments and their values
|
|
57
|
+
* - the timeBudget the provider has to provide context items
|
|
58
|
+
* - the previousUsageStatistics, which contains information about the last request to the provider
|
|
59
|
+
*/
|
|
52
60
|
export type Status = 'full' | 'partial' | 'none';
|
|
53
61
|
|
|
54
62
|
export type ContextUsageStatistics = {
|
|
@@ -56,19 +64,61 @@ export type ContextUsageStatistics = {
|
|
|
56
64
|
resolution: Status;
|
|
57
65
|
};
|
|
58
66
|
|
|
59
|
-
export interface
|
|
67
|
+
export interface DocumentContext {
|
|
68
|
+
uri: DocumentUri;
|
|
69
|
+
languageId: string;
|
|
70
|
+
version: number;
|
|
71
|
+
offset: number;
|
|
72
|
+
}
|
|
73
|
+
export interface ResolveRequest {
|
|
74
|
+
// A unique ID to correlate the request with the completion request.
|
|
75
|
+
completionId: string;
|
|
60
76
|
documentContext: DocumentContext;
|
|
61
77
|
|
|
62
78
|
activeExperiments: Map<string, string | number | boolean | string[]>;
|
|
63
79
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
/**
|
|
81
|
+
* The number of milliseconds for the context provider to provide context items.
|
|
82
|
+
* After the time budget runs out, the request will be cancelled via the CancellationToken.
|
|
83
|
+
* Providers can use this value as a hint when computing context. Providers should expect the
|
|
84
|
+
* request to be cancelled once the time budget runs out.
|
|
85
|
+
*/
|
|
69
86
|
timeBudget: number;
|
|
70
87
|
|
|
71
|
-
|
|
72
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Various statistics about the last completion request. This can be used by the context provider
|
|
90
|
+
* to make decisions about what context to provide for the current call.
|
|
91
|
+
*/
|
|
73
92
|
previousUsageStatistics?: ContextUsageStatistics;
|
|
74
93
|
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* These are the data types that can be provided by a context provider. Any non-conforming
|
|
97
|
+
* context items will be filtered out.
|
|
98
|
+
*/
|
|
99
|
+
interface ContextItem {
|
|
100
|
+
/**
|
|
101
|
+
* Specifies the relative importance with respect to items of the same type.
|
|
102
|
+
* Cross-type comparisons is currently handled by the wishlist.
|
|
103
|
+
* Accepted values are integers in the range [0, 100], where 100 is the highest importance.
|
|
104
|
+
* Items with non-conforming importance values will be filtered out.
|
|
105
|
+
* Default value is 0.
|
|
106
|
+
*/
|
|
107
|
+
importance?: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// A key-value pair used for short string snippets.
|
|
111
|
+
export interface Trait extends ContextItem {
|
|
112
|
+
name: string;
|
|
113
|
+
value: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Code snippet extracted from a file. The URI is used for content exclusion.
|
|
117
|
+
export interface CodeSnippet extends ContextItem {
|
|
118
|
+
uri: string;
|
|
119
|
+
value: string;
|
|
120
|
+
// Additional URIs that contribute the same code snippet.
|
|
121
|
+
additionalUris?: string[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type SupportedContextItem = Trait | CodeSnippet;
|