Update Github Copilot to latest version (#2864)

* Update to latest version of Github Copilot CLI

* Use 0.0.381

* Reverts

* Update src/extension/agents/copilotcli/node/copilotcliSession.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Updates

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Don Jayamanne
2026-01-15 12:36:52 +11:00
committed by GitHub
parent cc301ab73f
commit dfaa4f6d5f
11 changed files with 190 additions and 98 deletions

View File

@@ -61,60 +61,6 @@ const treeSitterGrammars: ITreeSitterGrammar[] = [
const REPO_ROOT = path.join(__dirname, '..');
/**
* @github/copilot depends on sharp which has native dependencies that are hard to distribute.
* This function creates a shim for the sharp module that @github/copilot expects.
* The shim provides a minimal implementation of the sharp API to satisfy @github/copilot's requirements.
* Its non-functional and only intended to make the module load without errors.
*
* We create a directory @github/copilot/node_modules/sharp, so that
* the node module resolution algorithm finds our shim instead of trying to load the real sharp module. This also ensure the shims are specific to this package.
*/
async function createCopilotCliSharpShim() {
const copilotCli = path.join(REPO_ROOT, 'node_modules', '@github', 'copilot');
const sharpShim = path.join(copilotCli, 'node_modules', 'sharp');
const copilotPackageJsonFile = path.join(copilotCli, 'package.json');
const copilotPackageJson = JSON.parse(fs.readFileSync(copilotPackageJsonFile, 'utf-8'));
if (copilotPackageJson.dependencies) {
delete copilotPackageJson.dependencies.sharp;
}
await fs.promises.writeFile(copilotPackageJsonFile, JSON.stringify(copilotPackageJson, undefined, 2), 'utf-8');
await fs.promises.rm(sharpShim, { recursive: true, force: true });
await fs.promises.mkdir(path.join(sharpShim, 'lib'), { recursive: true });
await fs.promises.writeFile(path.join(sharpShim, 'package.json'), JSON.stringify({
"name": "sharp",
"type": "commonjs",
"main": "lib/index.js"
}, undefined, 2));
await fs.promises.writeFile(path.join(sharpShim, 'lib', 'index.js'), `
const Sharp = function (inputBuffer, options) {
if (arguments.length === 1 && !is.defined(input)) {
throw new Error('Invalid input');
}
if (!(this instanceof Sharp)) {
return new Sharp(input, options);
}
this.inputBuffer = inputBuffer;
return this;
};
Sharp.prototype.resize = function () {
const that = this;
const img = {
toBuffer: () => that.inputBuffer,
png: () => img,
jpeg: () => img
};
return img;
};
module.exports = Sharp;
`);
}
/**
* @github/copilot/sdk/index.js depends on @github/copilot/worker/*.js files.
* We need to copy these files into the sdk directory to ensure they are available at runtime.
@@ -123,6 +69,17 @@ async function copyCopilotCliWorkerFiles() {
const sourceDir = path.join(REPO_ROOT, 'node_modules', '@github', 'copilot', 'worker');
const targetDir = path.join(REPO_ROOT, 'node_modules', '@github', 'copilot', 'sdk', 'worker');
await copyCopilotCLIFolders(sourceDir, targetDir);
}
async function copyCopilotCliSharpFiles() {
const sourceDir = path.join(REPO_ROOT, 'node_modules', '@github', 'copilot', 'sharp');
const targetDir = path.join(REPO_ROOT, 'node_modules', '@github', 'copilot', 'sdk', 'sharp');
await copyCopilotCLIFolders(sourceDir, targetDir);
}
async function copyCopilotCLIFolders(sourceDir: string, targetDir: string) {
await fs.promises.rm(targetDir, { recursive: true, force: true });
await fs.promises.mkdir(targetDir, { recursive: true });
await fs.promises.cp(sourceDir, targetDir, { recursive: true, force: true });
@@ -144,8 +101,8 @@ async function main() {
'node_modules/@github/blackbird-external-ingest-utils/pkg/nodejs/external_ingest_utils_bg.wasm',
], 'dist');
await createCopilotCliSharpShim();
await copyCopilotCliWorkerFiles();
await copyCopilotCliSharpFiles();
// Check if the base cache file exists
const baseCachePath = path.join('test', 'simulation', 'cache', 'base.sqlite');