Skip to content

Add compile-copilot-extension-full-build task for copilot#310159

Open
insilications wants to merge 1 commit intomicrosoft:mainfrom
insilications:insilications/full-copilot-local-build
Open

Add compile-copilot-extension-full-build task for copilot#310159
insilications wants to merge 1 commit intomicrosoft:mainfrom
insilications:insilications/full-copilot-local-build

Conversation

@insilications
Copy link
Copy Markdown

@insilications insilications commented Apr 15, 2026

Summary

Adds a new compile-copilot-extension-full-build gulp task that builds the built-in copilot extension from source with correctly filtered node_modules, producing output equivalent to what CI ships from the pre-built VSIX. This also materializes native dependency shims (node-pty, ripgrep) into the extension output.

Motivation

The compile-copilot-extension-build task introduced in #309079 enables building the copilot extension from source for local (non-CI) builds. However, it produces a bloated node_modules directory containing every production dependency from extensions/copilot/package.json, even though nearly all of them are already bundled into dist/extension.js by esbuild. This is bloated for the purpose of daily driving a bleeding-edge with the latest Copilot from source via, for example, --extensionDevelopmentPath.

This happens because packageCopilotExtensionStream merges two streams:

  1. fromLocalEsbuild — runs .esbuild.ts, then calls vsce.listFiles({ packageManager: PackageManager.None }). PackageManager.None skips dependency scanning, so .vscodeignore filtering is not applied to node_modules.
  2. getProductionDependencies('extensions/copilot') — runs npm ls --all --omit=dev and blindly globs every resolved dependency path into the output.

In CI this is not a problem because packageCopilotExtensionStream is never used — CI downloads a pre-built .vsix (via downloadCopilotVsix.ts) that was packaged by vsce package with PackageManager.Npm, which respects .vscodeignore and only includes the @vscode/copilot-typescript-server-plugin and @github/copilot (SDK subtree) dependencies.

What this PR does

build/lib/extensions.ts

  • packageCopilotExtensionFullStream() — A new packaging function that:

    • Runs .esbuild.ts to compile the extension (same as existing)
    • Uses vsce.listFiles({ packageManager: PackageManager.Npm }) instead of PackageManager.None, so .vscodeignore is applied to both source files and node_modules dependencies
    • Cleans package.json (removes scripts, dependencies, devDependencies)
  • prepareCopilotExtensionNativeShims(outputDir) — Calls prepareBuiltInCopilotExtensionShims from build/lib/copilot.ts to materialize node-pty and ripgrep binaries into the copilot SDK's expected locations, using the root node_modules/ as the source. Failures are logged as warnings since the extension can create shims at runtime.

build/gulpfile.extensions.ts

  • compile-copilot-extension-full-build — A new gulp task that runs three steps in series:
    1. clean-copilot-build — removes .build/extensions/copilot/
    2. package-copilot-extension-full — runs packageCopilotExtensionFullStream and writes to .build/
    3. copilot-extension-native-shims — runs prepareCopilotExtensionNativeShims on the output

Usage

# Build the copilot extension with correct dependency filtering + native shims
npm run gulp compile-copilot-extension-full-build

# Output is at .build/extensions/copilot/

Comparison

compile-copilot-extension-build:

.build/extensions/copilot/node_modules/
├── @anthropic-ai/
├── @github/
├── @vscode/
├── isbinaryfile/
├── minimatch/
├── ... (hundreds of bundled-at-build-time dependencies)

compile-copilot-extension-full-build:

.build/extensions/copilot/node_modules/
├── @github/
│   └── copilot/
│       ├── package.json
│       ├── sdk/
│       │   ├── *.js
│       │   ├── prebuilds/linux-x64/   ← node-pty shims
│       │   ├── ripgrep/bin/linux-x64/ ← ripgrep shims
│       │   └── definitions/*.yaml
│       └── shims.txt                  ← marker file
└── @vscode/
    └── copilot-typescript-server-plugin/
        ├── package.json
        └── dist/*.js

This matches the structure of the copilot extension in released VS Code Insiders builds.

Notes

  • The existing compile-copilot-extension-build task and packageCopilotExtensionStream are left unchanged — this PR is purely additive.

Fixes #310156

cc @joaomoreno

Copilot AI review requested due to automatic review settings April 15, 2026 15:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new build pipeline for packaging the built-in Copilot extension from source in a VSIX-equivalent way (correct .vscodeignore-based dependency filtering), and optionally materializes native shims into the packaged output to match what CI ships.

Changes:

  • Add packageCopilotExtensionFullStream() to package extensions/copilot using vsce.listFiles with PackageManager.Npm (respects .vscodeignore) plus .moduleignore cleanup and package.json stripping.
  • Add prepareCopilotExtensionNativeShims(outputDir) to materialize node-pty and ripgrep shims into the packaged Copilot SDK layout (warning-only on failure for local builds).
  • Add gulp task compile-copilot-extension-full-build to clean, package, and then generate shims into .build/extensions/copilot/.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
build/lib/extensions.ts Implements VSIX-equivalent Copilot packaging stream and a helper to materialize native shims into the packaged output.
build/gulpfile.extensions.ts Introduces compile-copilot-extension-full-build task wiring (clean → package → shims) targeting .build/extensions/copilot/.

…ackaged copilot build

The existing `compile-copilot-extension-build` task (from microsoft#309079) uses
`packageCopilotExtensionStream`, which calls `fromLocalEsbuild` with
`PackageManager.None` and then merges in all production dependencies via
`getProductionDependencies`. This bypasses `.vscodeignore` filtering for
`node_modules`, resulting in hundreds of redundant dependencies that are
already bundled into `dist/extension.js` by esbuild.

In CI this is not an issue because a pre-built VSIX (packaged with
`PackageManager.Npm`, which respects `.vscodeignore`) is downloaded
instead.

Add a new `compile-copilot-extension-full-build` gulp task backed by two new functions
in `build/lib/extensions.ts`:

- `packageCopilotExtensionFullStream()`: builds the copilot extension using
  `vsce.listFiles` with `PackageManager.Npm` so `.vscodeignore` is the
  single authority on which files and dependencies are included.

- `prepareCopilotExtensionNativeShims()`: materializes node-pty and ripgrep
  binaries into the copilot SDK's expected locations via
  `prepareBuiltInCopilotExtensionShims`, so the extension does not need
  to create shims at runtime.

The output at `.build/extensions/copilot/` matches the structure of the
copilot extension in released VS Code builds.
@insilications insilications force-pushed the insilications/full-copilot-local-build branch from 79faac7 to ecf4d85 Compare April 15, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add gulp task for building a concisely packaged Copilot Extension from source

4 participants