Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/remoteCodeSearch/common/remoteCodeSearch.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
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
import { GlobIncludeOptions } from '../../../util/common/glob';
6
import { FileChunk, FileChunkAndScore } from '../../chunking/common/chunk';
7
8
export enum RemoteCodeSearchIndexStatus {
9
/** The repo index is built and ready to use */
10
Ready = 'ready',
11
12
/** The repo index is being built */
13
BuildingIndex = 'building-index',
14
15
/** The repo is not indexed but we can potentially index it */
16
NotYetIndexed = 'not-yet-indexed',
17
18
/** The repo is not indexed and we cannot trigger indexing */
19
NotIndexable = 'not-indexable',
20
}
21
22
export type RemoteCodeSearchIndexState =
23
| { readonly status: RemoteCodeSearchIndexStatus.Ready; readonly indexedCommit: string | undefined }
24
| { readonly status: RemoteCodeSearchIndexStatus.BuildingIndex | RemoteCodeSearchIndexStatus.NotYetIndexed | RemoteCodeSearchIndexStatus.NotIndexable }
25
;
26
27
export type RemoteCodeSearchError =
28
| { readonly type: 'not-authorized' }
29
| { readonly type: 'generic-error'; readonly error: Error }
30
;
31
32
interface BaseCodeSearchResult {
33
/** Tracks if the commit sha code search used differs from the one we used to compute the local diff */
34
readonly outOfSync: boolean;
35
36
/** The web URL of the remote repo, e.g. `https://github.com/microsoft/vscode` */
37
readonly remoteUrl?: string;
38
39
/** The branch name the results are from, e.g. `main` */
40
readonly refName?: string;
41
}
42
43
export interface SemanticCodeSearchResult extends BaseCodeSearchResult {
44
readonly chunks: readonly FileChunkAndScore[];
45
}
46
47
export interface LexicalCodeSearchResult extends BaseCodeSearchResult {
48
readonly chunks: readonly FileChunk[];
49
}
50
51
export interface CodeSearchOptions {
52
readonly globPatterns?: GlobIncludeOptions;
53
}
54
55