Skip to content

Commit 07d9845

Browse files
dependabot[bot]Harald Kirschner
andauthored
build(deps): bump @github/copilot-sdk from 0.1.32 to 0.2.0 in the production-dependencies group across 1 directory (#73)
* build(deps): bump @github/copilot-sdk Bumps the production-dependencies group with 1 update in the / directory: [@github/copilot-sdk](https://github.com/github/copilot-sdk). Updates `@github/copilot-sdk` from 0.1.32 to 0.2.0 - [Release notes](https://github.com/github/copilot-sdk/releases) - [Changelog](https://github.com/github/copilot-sdk/blob/main/CHANGELOG.md) - [Commits](github/copilot-sdk@v0.1.32...v0.2.0) --- updated-dependencies: - dependency-name: "@github/copilot-sdk" dependency-version: 0.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: production-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> * fix: update SDK shim for @github/copilot-sdk 0.2.0 The getBundledCliPath() function in the SDK changed its indentation and added a CJS createRequire fallback. Replace the fragile literal-string shim with a regex that matches the entire function body. Also bump the extension's SDK dependency to ^0.2.0 for consistency. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Harald Kirschner <digitarald@gmail.com>
1 parent c0a65e0 commit 07d9845

6 files changed

Lines changed: 93 additions & 90 deletions

File tree

package-lock.json

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"author": "",
3030
"license": "MIT",
3131
"dependencies": {
32-
"@github/copilot-sdk": "^0.1.32",
32+
"@github/copilot-sdk": "^0.2.0",
3333
"@inquirer/prompts": "^8.2.1",
3434
"@octokit/rest": "^22.0.1",
3535
"chalk": "^5.6.2",

tsup.config.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,34 @@ import type { Plugin } from "esbuild";
55
import { cpSync, rmSync } from "node:fs";
66

77
/**
8-
* Shim the SDK's getBundledCliPath() which calls import.meta.resolve().
9-
* In ESM bundles, import.meta.resolve("@github/copilot/sdk") throws at runtime
10-
* because the bare specifier can't be resolved from the bundle's execution
11-
* directory (e.g. stale npx cache). In CJS bundles esbuild additionally
12-
* replaces import.meta with {}. AgentRC always passes an explicit cliPath so
13-
* this function is dead code, but the SDK constructor evaluates it on load.
8+
* Shim the SDK's getBundledCliPath() which calls import.meta.resolve() and
9+
* createRequire(__filename). In ESM bundles the bare specifier can't be
10+
* resolved; in CJS bundles esbuild replaces import.meta with {}. AgentRC
11+
* always passes an explicit cliPath so this function is dead code, but the
12+
* SDK constructor evaluates it as a default value.
1413
*
1514
* Identical to the shim in vscode-extension/esbuild.mjs — update both together
1615
* if the SDK changes getBundledCliPath internals.
1716
*/
18-
const SDK_SHIM_TARGET =
19-
'const sdkUrl = import.meta.resolve("@github/copilot/sdk");\n const sdkPath = fileURLToPath(sdkUrl);\n return join(dirname(dirname(sdkPath)), "index.js");';
17+
const SDK_FN_RE = /function getBundledCliPath\(\) \{[\s\S]*?\n\}/;
2018

2119
const shimSdkImportMeta: Plugin = {
2220
name: "shim-sdk-import-meta",
2321
setup(build) {
2422
build.onLoad({ filter: /copilot-sdk[\\/]dist[\\/]client\.js$/ }, async (args) => {
25-
let contents = await readFile(args.path, "utf8");
26-
if (!contents.includes(SDK_SHIM_TARGET)) {
23+
const original = await readFile(args.path, "utf8");
24+
const contents = original.replace(
25+
SDK_FN_RE,
26+
'function getBundledCliPath() {\n return "bundled-cli-unavailable";\n}'
27+
);
28+
if (contents === original) {
2729
throw new Error(
2830
"[shim-sdk-import-meta] SDK internals changed — getBundledCliPath() " +
29-
"target string not found in " +
31+
"not found in " +
3032
args.path +
3133
". Update the shim in tsup.config.ts and vscode-extension/esbuild.mjs."
3234
);
3335
}
34-
contents = contents.replace(SDK_SHIM_TARGET, 'return "bundled-cli-unavailable";');
3536
return { contents, loader: "js" };
3637
});
3738
}

vscode-extension/esbuild.mjs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,34 @@ const watch = process.argv.includes("--watch");
77

88
/**
99
* esbuild plugin: neutralise the SDK's getBundledCliPath() which calls
10-
* import.meta.resolve("@github/copilot/sdk"). In CJS bundles esbuild replaces
11-
* import.meta with {}, making .resolve undefined and crashing at runtime.
12-
* AgentRC always passes an explicit cliPath so this function is dead code, but
13-
* the SDK constructor still evaluates it as a default value.
10+
* import.meta.resolve() and createRequire(__filename). In CJS bundles esbuild
11+
* replaces import.meta with {}, making .resolve undefined and crashing at
12+
* runtime. AgentRC always passes an explicit cliPath so this function is dead
13+
* code, but the SDK constructor still evaluates it as a default value.
1414
*
15-
* Validated against @github/copilot-sdk ^0.1.24–0.1.29.
15+
* Validated against @github/copilot-sdk 0.1.24–0.2.0.
1616
* If the SDK changes getBundledCliPath internals the build will fail with
1717
* a clear error message below.
1818
*/
19-
const SDK_SHIM_TARGET =
20-
'const sdkUrl = import.meta.resolve("@github/copilot/sdk");\n const sdkPath = fileURLToPath(sdkUrl);\n return join(dirname(dirname(sdkPath)), "index.js");';
19+
const SDK_FN_RE = /function getBundledCliPath\(\) \{[\s\S]*?\n\}/;
2120

2221
const shimSdkImportMeta = {
2322
name: "shim-sdk-import-meta",
2423
setup(build) {
2524
build.onLoad({ filter: /copilot-sdk[\\/]dist[\\/]client\.js$/ }, async (args) => {
26-
let contents = await readFile(args.path, "utf8");
27-
if (!contents.includes(SDK_SHIM_TARGET)) {
25+
const original = await readFile(args.path, "utf8");
26+
const contents = original.replace(
27+
SDK_FN_RE,
28+
'function getBundledCliPath() {\n return "bundled-cli-unavailable";\n}'
29+
);
30+
if (contents === original) {
2831
throw new Error(
2932
"[shim-sdk-import-meta] SDK internals changed — getBundledCliPath() " +
30-
"target string not found in " +
33+
"not found in " +
3134
args.path +
32-
". Update the shim to match the new SDK version."
35+
". Update the shim in tsup.config.ts and vscode-extension/esbuild.mjs."
3336
);
3437
}
35-
contents = contents.replace(SDK_SHIM_TARGET, 'return "bundled-cli-unavailable";');
3638
return { contents, loader: "js" };
3739
});
3840
}

vscode-extension/package-lock.json

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
],
313313
"devDependencies": {
314314
"@eslint/js": "^10.0.1",
315-
"@github/copilot-sdk": "^0.1.32",
315+
"@github/copilot-sdk": "^0.2.0",
316316
"@octokit/rest": "^22.0.1",
317317
"@typescript-eslint/eslint-plugin": "^8.57.1",
318318
"@typescript-eslint/parser": "^8.56.0",

0 commit comments

Comments
 (0)