Skip to content

fix(cli): update Copilot SDK to fix module loading error - #190

Merged
Yohan Lasorsa (sinedied) merged 1 commit into
mainfrom
fix/copilot-sdk-esm-load
Aug 25, 2026
Merged

fix(cli): update Copilot SDK to fix module loading error#190
Yohan Lasorsa (sinedied) merged 1 commit into
mainfrom
fix/copilot-sdk-esm-load

Conversation

@sinedied

Copy link
Copy Markdown
Collaborator

Problem

Every moaw command crashes on startup with ERR_MODULE_NOT_FOUND:

$ npm i -g @moaw/cli
$ moaw s
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../node_modules/vscode-jsonrpc/node'
  imported from .../node_modules/@github/copilot-sdk/dist/session.js
Did you mean to import "vscode-jsonrpc/node.js"?

src/cli.ts statically imports translate.ts, which statically imports @github/copilot-sdk, so the SDK is loaded for every command — not just moaw translate.

Root cause

@github/copilot-sdk 0.1.31 and 0.1.32 ship dist/session.js with an extensionless import:

import { ConnectionError, ResponseError } from "vscode-jsonrpc/node";   // missing .js

vscode-jsonrpc@8.2.1 has no exports map, and Node's ESM resolver does not probe file extensions for subpath imports, so resolution fails even though node.js exists. Notably dist/client.js in the same build uses the correct vscode-jsonrpc/node.js form.

This is not Node-version specific — reproduced identically on Node 22.23.2 and 24.19.0.

Version bisect (node -e "import('@github/copilot-sdk')" per release):

SDK version Result
0.1.30 OK
0.1.31 broken
0.1.32 broken
1.0.0 – 1.0.11 OK (fixed upstream)

The previous range ^0.1.16 caps at <0.2.0, so it always resolved to the broken 0.1.32 and could never pick up the upstream fix.

Already reported and fixed upstream: github/copilot-sdk#707 (fixed by github/copilot-sdk#734), github/copilot-sdk#891, github/copilot-sdk#1651.

Changes

  • Bump @github/copilot-sdk from ^0.1.16 to ^1.0.11
  • Replace session.destroy() with session.disconnect() — the only breaking change in 1.0.x. destroy() was already deprecated in 0.1.x in favour of disconnect() with identical semantics ("Disconnects this session and releases all in-memory resources. Session data on disk is preserved.")
  • Update the corresponding debug message for consistency

All other SDK APIs used by translate.ts (CopilotClient, start, stop, createSession, getAuthStatus, session.on, sendAndWait with attachments) are unchanged in 1.0.x.

Verification

  • tsc --noEmit -p packages/cli/tsconfig.json — clean
  • npm run lint --workspace=@moaw/cli — clean (2 pre-existing TODO warnings)
  • moaw s starts successfully on both Node 22.23.2 and Node 24.19.0

Note: moaw translate itself was not exercised end-to-end here (it requires an authenticated Copilot CLI and makes real model calls), so a manual smoke test of the translate command before release would be worthwhile.

@github/copilot-sdk 0.1.31 and 0.1.32 ship dist/session.js with an
extensionless import:

    import { ConnectionError, ResponseError } from "vscode-jsonrpc/node";

vscode-jsonrpc@8.2.1 has no "exports" map, and Node's ESM resolver does
not probe file extensions, so the import fails to resolve and every moaw
command crashes on startup with ERR_MODULE_NOT_FOUND (cli.ts statically
imports translate.ts, which imports the SDK).

This affects all Node versions, not just Node 22+. Version 0.1.30 works,
0.1.31 and 0.1.32 are broken, and 1.0.x is fixed upstream. The previous
"^0.1.16" range resolves to <0.2.0, so it always picked the broken
0.1.32 and could never reach the fix.

Bump the range to ^1.0.11 and replace session.destroy() with
session.disconnect(), the only breaking change in 1.0.x. destroy() was
already deprecated in 0.1.x in favour of disconnect() with identical
semantics.

Refs: github/copilot-sdk#707

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sinedied
Yohan Lasorsa (sinedied) merged commit 9deeac0 into main Aug 25, 2026
5 checks passed
@sinedied
Yohan Lasorsa (sinedied) deleted the fix/copilot-sdk-esm-load branch August 25, 2026 13:18
Yohan Lasorsa (sinedied) pushed a commit that referenced this pull request Aug 26, 2026
# [cli-1.6.1](cli-1.6.0...cli-1.6.1) (2026-08-26)

### Bug Fixes

* **cli:** update Copilot SDK to fix module loading error ([#190](#190)) ([9deeac0](9deeac0))
@sinedied

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 1.6.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Yohan Lasorsa (sinedied) added a commit that referenced this pull request Sep 2, 2026
)

Refresh package-lock.json within the existing semver ranges.

The update had to be run with --ignore-scripts to work around an
upstream packaging bug in @rimac-technology/semantic-release-monorepo
(all versions, 1.1.6 through 1.2.10): the package uses pinst to strip
its husky postinstall hook at pack time, but npm records the packument
metadata before prepack runs. The registry therefore advertises
"postinstall": "husky" while the tarball ships "_postinstall", so a
fresh install runs husky (not a dependency of the package) and fails
with ENOENT. Lockfile-based installs read the on-disk "_postinstall"
and correctly no-op, which is why npm ci is unaffected.

Also bump pull-request.yml from Node 18 to Node 22, matching deploy.yml.
PR validation was two LTS majors behind the deploy and release
workflows, and @github/copilot-sdk (a CLI dependency since #190)
declares engines.node >= 20, so PR builds were validating against an
engine the package no longer supports.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants