Repository navigation
copilot: install chat-lib with the Copilot workspace - #346069
Merged
Ladislau Szomoru (lszomoru) merged 1 commit intoNov 4, 2026
Merged
Conversation
`extensions/copilot/chat-lib` was a separate pnpm install root, with its own `pnpm-workspace.yaml` and `pnpm-lock.yaml`. It becomes a member of the `extensions/copilot` workspace: one `pnpm install` in `extensions/copilot` installs both, and Copilot's `pnpm-lock.yaml` records them. The extraction already sets chat-lib's dependencies to Copilot's versions, so the committed chat-lib `package.json` now has those versions too (`@anthropic-ai/sdk`, `@types/node`, `typescript`). In Copilot's lockfile chat-lib's project uses Copilot's entries for all its dependencies: the lockfile gains the project and no packages, and Copilot's own project doesn't change. - `chat-lib/script/postinstall.ts`: every Copilot install runs it now, also before `extract-chat-lib` created the sources; it skips instead of failing. Packages installed from npm (with `dist/`) are unaffected. - `chat-lib/package.json`: `compile` runs `tsc6`, the compiler of the `typescript` that chat-lib declares (TypeScript 6). In its own install root, `tsc` came from the same package by accident of hoisting; in Copilot's workspace it is Copilot's `@typescript/native`. - `extractChatLib.ts` / `chatLibLockfile.ts`: after the extraction changes chat-lib's dependencies, `lockChatLibDependencies` locks them to Copilot's versions in the shared lockfile and drops the entries no project uses, still without resolving anything. The extraction then also updates `node_modules`, so that its TypeScript check doesn't use chat-lib's previous versions. - `pnpm-workspace.yaml`: `hoistWorkspacePackages: false`. Otherwise pnpm links chat-lib into `node_modules/@vscode/chat-lib`, and `vsce package` fails: its `npm list --production` reports the link as extraneous. - CI (`test-chat-lib` action, chat-lib npm package pipelines): chat-lib's dependencies are installed in `extensions/copilot` after the extraction, then chat-lib's postinstall runs (pnpm skips it when the workspace is up to date). - `build/npm/dirs.ts`: chat-lib is a member of `extensions/copilot`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the chat-lib workspace consolidation.
No open issues 🎉
1 file not reviewed
extensions/copilot/pnpm-lock.yaml: Generated file
What changed in this PR
This PR moves @vscode/chat-lib into the Copilot pnpm workspace, continuing the install-root consolidation and reducing the repository from eight install roots to seven.
Changes:
- Consolidates chat-lib’s dependencies into Copilot’s lockfile and aligns its declared versions and compiler command.
- Updates extraction to synchronize the shared lockfile and installed dependencies, while allowing postinstall to skip before sources exist.
- Adjusts CI and build tooling for workspace installation and explicit post-extraction asset copying.
No actionable findings remain. Linux/Windows chat-lib jobs and the Azure npm package pipeline remain validation gaps noted in the PR description.
| File | Description |
|---|---|
extensions/copilot/script/test/chatLibLockfile.spec.ts |
Rewrites dependency-locking tests for the shared workspace. |
extensions/copilot/script/build/extractChatLib.ts |
Updates the shared lockfile and refreshes installed dependencies. |
extensions/copilot/script/build/chatLibLockfile.ts |
Locks chat-lib dependencies to Copilot’s versions and prunes unused entries. |
extensions/copilot/pnpm-workspace.yaml |
Adds chat-lib and disables workspace-package hoisting for packaging compatibility. |
extensions/copilot/pnpm-lock.yaml |
Adds chat-lib’s project using existing package entries. |
extensions/copilot/chat-lib/script/postinstall.ts |
Skips asset copying when extracted sources are absent. |
extensions/copilot/chat-lib/pnpm-workspace.yaml |
Removes the standalone workspace configuration. |
extensions/copilot/chat-lib/pnpm-lock.yaml |
Removes the standalone lockfile. |
extensions/copilot/chat-lib/package.json |
Aligns dependency versions and switches compilation to tsc6. |
extensions/copilot/build/steps/test-chat-lib.yml |
Uses workspace installation and explicitly runs chat-lib postinstall. |
extensions/copilot/build/steps/build-chat-lib.yml |
Adapts package builds to the shared installation. |
extensions/copilot/build/npm-package-next.yml |
Adapts next-package publishing preparation to the shared installation. |
build/npm/pnpm/workspaceConfig.ts |
Recognizes hoistWorkspacePackages as a supported setting. |
build/npm/dirs.ts |
Registers chat-lib as a Copilot workspace member. |
build/lib/test/pnpmLock.test.ts |
Tests chat-lib’s shared lockfile location. |
.github/actions/test-chat-lib/action.yml |
Preserves Copilot dependencies and copies assets after extraction. |
Review effort: Balanced
Ladislau Szomoru (lszomoru)
marked this pull request as ready for review
November 4, 2026 19:49
Ladislau Szomoru (lszomoru)
enabled auto-merge (squash)
November 4, 2026 19:49
Federico Brancasi (federicobrancasi)
approved these changes
Nov 4, 2026
Ladislau Szomoru (lszomoru)
deleted the
lszomoru/merge-chat-lib-into-copilot
branch
November 4, 2026 19:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
extensions/copilot/chat-lib(the@vscode/chat-libnpm package, extracted from the Copilot extension's sources) was a separate pnpm install root, with its ownpnpm-workspace.yamlandpnpm-lock.yaml. It becomes a member of theextensions/copilotworkspace: onepnpm installinextensions/copilotinstalls both, and Copilot'spnpm-lock.yamlrecords them. That takes the repository from 8 pnpm install roots to 7 (after #345794, #345795, #345797 and #345827).What changed
extract-chat-lib) already syncs chat-lib's dependencies to Copilot's versions in every pipeline. The committed chat-libpackage.jsonnow has those versions too:@anthropic-ai/sdk^0.82.0,@types/node24.x,typescript= Copilot's@typescript/typescript6alias.chat-lib/script/postinstall.ts: every Copilot install now runs it, also before the extraction has created chat-lib's sources. It skipped nothing before and failed ("Could not find the source directory for tokenizer files"); now it skips with a message. In a package installed from npm (dist/present) it copies the same files as before.chat-lib/package.jsoncompile:tsc→tsc6, the binary of thetypescriptthat chat-lib declares (TypeScript 6). In its own install root,tsccame from@typescript/old(the same TypeScript 6.0.3) only because pnpm hoisted it. In Copilot's workspace,tscis Copilot's@typescript/native(TypeScript 7), whose declaration emit fails on chat-lib (TS5088/TS7056).extractChatLib.ts/chatLibLockfile.ts:copyLockedDependencies(which copied entries into chat-lib's own lockfile) becomeslockChatLibDependencies. It locks each changed dependency to the version Copilot's project locks in the shared lockfile, drops the entries no project uses anymore, and still resolves nothing.pnpm install --frozen-lockfile --ignore-scripts. Otherwise its own TypeScript check would use chat-lib's previous versions, which pnpm nests inchat-lib/node_modules.extensions/copilot/pnpm-workspace.yaml:packages: [chat-lib];hoistWorkspacePackages: false. Without it, pnpm links chat-lib intonode_modules/@vscode/chat-lib, andvsce package(pnpm exec vsce packagein the Copilot pipeline) fails: itsnpm list --productionreports the link and chat-lib's nested packages as extraneous (ELSPROBLEMS)..github/actions/test-chat-lib;extensions/copilot/build/steps/{build,test}-chat-lib.ymlandnpm-package-next.ymlfor the npm package pipelines):node_modules;extensions/copilotafter the extraction;pnpm --dir chat-lib run postinstallruns, because pnpm skips lifecycle scripts when the workspace is already up to date. It copies the wasm and tokenizer files next to the extracted sources.build/npm/dirs.ts: chat-lib is a member ofextensions/copilot(separateRootMembers).hoistWorkspacePackagesis added to the known settings (workspaceConfig.ts).For reviewers
test-chat-libaction used to delete everynode_modulesabove chat-lib, so chat-lib built and tested against only its own dependencies. Now its dependencies are in Copilot'snode_modules, so a chat-lib import of a package that only Copilot declares would no longer fail in CI. Today it doesn't happen: the packed package installs and loads in a clean project (below). A follow-up could add that consumer check to thetest-chat-libaction.overrides(zod,string_decoder,yauzl) now also apply to chat-lib's tests. The packages that ship are unaffected: npm consumers resolve chat-lib's dependencies themselves.@vscode/chat-lib(e.g. 0.73.0) runstsx script/postinstall.jsaspostinstall, buttsxis a dev dependency, sonpm install @vscode/chat-libfails unlesstsxis available or scripts are ignored.How to test (macOS arm64; compared with
mainatb48b93587a9, same steps on both)pnpm install --frozen-lockfileat the root: passes, and chat-lib's postinstall skips.cd extensions/copilot && pnpm install --lockfile-onlyleaves the lockfile unchanged.pnpm run build, thenpnpm exec vsce package -o copilot-chat.vsix --allow-package-secrets sendgrid(as inproduct-copilot.yml): 82 files, byte-identical tomain's VSIX (bundles included).npm list --production(what vsce reads) gives the same 280 paths as onmain. WithouthoistWorkspacePackages: false,vsce packagefailed.getProductionDependenciesfor'',remote,remote/web,extensionsandextensions/copilot(233 / 142 / 26 / 1 / 279): name, version and location identical tomain.pnpm run build,pnpm test: 19/19 tests pass;pnpm pack: the same 2143 files asmain's package. All compiled.js/.d.tsfiles are byte-identical; onlypackage.json(compile) andscript/postinstall.tsdiffer.test-chat-libaction steps: same result.@anthropic-ai/sdkback on ^0.91.1 in the lockfile): the extraction updates 1 dependency, relocks it to Copilot's version, removes the stale nested copy, and the build and the 19 tests pass.npm install --ignore-scripts <tgz>into a clean project,require('@vscode/chat-lib')(11 exports), andtscon a consumer file: same results asmain's package. The package'spostinstall(run withtsx) copies the same 12 wasm and 2 tokenizer files.cd extensions/copilot && pnpm run typecheck: passes.pnpm exec vitest --run script/test/chatLibLockfile.spec.ts: 5 passed.cd build && pnpm run typecheck: passes.node --test lib/test/pnpmLock.test.ts lib/test/installWithoutSaving.test.ts lib/test/cloudSandbox.test.ts lib/test/dependencies.test.ts lib/test/listNodeModules.test.ts lib/test/detectChanges.test.ts lib/test/detectMissingCaches.test.ts npm/pnpm/test/workspaceConfig.test.ts: 76 passed.npm-package.yml, publishing off by default).