mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-16 08:21:52 +01:00
* Include inline completions in @vscode/chat-lib * Follow type imports, * exports without "as", and jsxImportSource pragmas for dependency extraction * update @vscode/chat-lib test configuration * update chat lib extraction with new path and add context setup for lib * initial stubs for inline completions test * round trip test for getInlineCompletions * remove unused path mappings * fix type import * send only original event names for chat-lib telemetry * fix wasm loading in chat-lib * have locateFile default to the current dir if the expected parent directory cannot be found * update to use service injection with completions in chat-lib * update citation and ExP handling for completions in chat-lib * hook up enhanced telemetry for chat-lib * add missing tsx package * update post-install script to work with pre-built and unbuilt versions of chat-lib and add missing completions dependencies * remove unneeded try/catch block * correct typo * generate package-lock from correct npm version --------- Co-authored-by: Christof Marti <chrmarti@microsoft.com>
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
async function copyStaticAssets(srcpaths: string[], dst: string): Promise<void> {
|
|
await Promise.all(srcpaths.map(async srcpath => {
|
|
const src = path.join(REPO_ROOT, srcpath);
|
|
const dest = path.join(REPO_ROOT, dst, path.basename(srcpath));
|
|
await fs.promises.mkdir(path.dirname(dest), { recursive: true });
|
|
await fs.promises.copyFile(src, dest);
|
|
}));
|
|
}
|
|
|
|
async function fileExists(filePath: string): Promise<boolean> {
|
|
try {
|
|
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
const treeSitterGrammars: string[] = [
|
|
'tree-sitter-c-sharp',
|
|
'tree-sitter-cpp',
|
|
'tree-sitter-go',
|
|
'tree-sitter-javascript', // Also includes jsx support
|
|
'tree-sitter-python',
|
|
'tree-sitter-ruby',
|
|
'tree-sitter-typescript',
|
|
'tree-sitter-tsx',
|
|
'tree-sitter-java',
|
|
'tree-sitter-rust',
|
|
'tree-sitter-php'
|
|
];
|
|
|
|
const REPO_ROOT = path.join(__dirname, '..');
|
|
|
|
async function platformDir(): Promise<string> {
|
|
const distPath = 'dist/src/_internal/platform';
|
|
const srcPath = 'src/_internal/platform';
|
|
if (await fileExists(path.join(REPO_ROOT, distPath))) {
|
|
return distPath;
|
|
} else if (await fileExists(path.join(REPO_ROOT, srcPath))) {
|
|
return srcPath;
|
|
} else {
|
|
throw new Error('Could not find the source directory for tokenizer files');
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
const platform = await platformDir();
|
|
const vendoredTiktokenFiles = [`${platform}/tokenizer/node/cl100k_base.tiktoken`, `${platform}/tokenizer/node/o200k_base.tiktoken`];
|
|
|
|
// copy static assets to dist
|
|
await copyStaticAssets([
|
|
...vendoredTiktokenFiles,
|
|
...treeSitterGrammars.map(grammar => `node_modules/@vscode/tree-sitter-wasm/wasm/${grammar}.wasm`),
|
|
'node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter.wasm',
|
|
], 'dist');
|
|
|
|
}
|
|
|
|
main();
|