Summary
CopilotClient's getBundledCliPath() resolves the CLI entry to a path one directory too high when the @github/copilot package is installed and the running Node has import.meta.resolve. It returns .../node_modules/@github/index.js instead of .../node_modules/@github/copilot/index.js, so startup throws:
Copilot CLI not found at C:\...\node_modules\@github\index.js. Ensure @github/copilot is installed.
even though @github/copilot is correctly installed.
Root cause
In the import.meta.resolve branch, the path is derived as:
const sdkPath = fileURLToPath(import.meta.resolve("@github/copilot/sdk"));
return join(dirname(dirname(sdkPath)), "index.js");
dirname(dirname(sdkPath)) strips two segments. For a resolved sdk entry living under @github/copilot/..., two dirname calls land on @github/ (the scope dir), so the joined result is @github/index.js — the wrong package level. The non-import.meta.resolve fallback branch (require.resolve.paths loop) correctly targets @github/copilot/index.js, which is why the bug only reproduces on newer Node where import.meta.resolve is present.
Impact
Any host on a recent Node (observed on Node v24.x / v25.x) where the package is present fails to launch the bundled CLI. On older Node (no import.meta.resolve) or where the package is absent (falls back to PATH), it works — which masks the bug.
Workaround
Set COPILOT_CLI_PATH to a launch-verified entry (e.g. .../@github/copilot/index.js or npm-loader.js); the client honors it before getBundledCliPath().
Suggested fix
Use a single dirname (or resolve the package root via require.resolve('@github/copilot/package.json')) so both branches agree on @github/copilot/index.js.
Environment
Windows, Node v24/v25, @github/copilot CLI 1.0.61–1.0.66, embedded CopilotClient SDK.
(AI-assisted report, filed via an automated agent.)
Summary
CopilotClient'sgetBundledCliPath()resolves the CLI entry to a path one directory too high when the@github/copilotpackage is installed and the running Node hasimport.meta.resolve. It returns.../node_modules/@github/index.jsinstead of.../node_modules/@github/copilot/index.js, so startup throws:even though
@github/copilotis correctly installed.Root cause
In the
import.meta.resolvebranch, the path is derived as:dirname(dirname(sdkPath))strips two segments. For a resolvedsdkentry living under@github/copilot/..., twodirnamecalls land on@github/(the scope dir), so the joined result is@github/index.js— the wrong package level. The non-import.meta.resolvefallback branch (require.resolve.pathsloop) correctly targets@github/copilot/index.js, which is why the bug only reproduces on newer Node whereimport.meta.resolveis present.Impact
Any host on a recent Node (observed on Node v24.x / v25.x) where the package is present fails to launch the bundled CLI. On older Node (no
import.meta.resolve) or where the package is absent (falls back toPATH), it works — which masks the bug.Workaround
Set
COPILOT_CLI_PATHto a launch-verified entry (e.g..../@github/copilot/index.jsornpm-loader.js); the client honors it beforegetBundledCliPath().Suggested fix
Use a single
dirname(or resolve the package root viarequire.resolve('@github/copilot/package.json')) so both branches agree on@github/copilot/index.js.Environment
Windows, Node v24/v25,
@github/copilotCLI 1.0.61–1.0.66, embeddedCopilotClientSDK.(AI-assisted report, filed via an automated agent.)