Fix codegen schema resolution for new @github/copilot package layout#1738
Conversation
The @github/copilot CLI package became a thin loader in 1.0.64-1 and moved its bundled JSON schemas into platform-specific packages (e.g. @github/copilot-win32-x64). The codegen scripts hardcoded the umbrella package's schemas/ path, which no longer exists, breaking the Update @github/copilot Dependency workflow. Resolve schemas by checking the umbrella package first (older versions), then falling back to whichever @github/copilot-* platform package is installed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the schema path resolution logic used by the repo’s code generation scripts to support the new @github/copilot npm package layout introduced in 1.0.64-1, where JSON schemas moved from the umbrella package into platform-specific @github/copilot-* optional dependency packages.
Changes:
- Add a shared resolver in
scripts/codegen/utils.tsthat first tries the legacy umbrella path and then scansnode_modules/@githubforcopilot-*platform packages containing the schema. - Apply the same fallback strategy to the Java codegen resolver in
java/scripts/codegen/java.tswhile preserving its existing preference order betweenscripts/codegen/node_modulesandnodejs/node_modules.
Show a summary per file
| File | Description |
|---|---|
| scripts/codegen/utils.ts | Introduces a host-agnostic schema resolver that falls back to platform-specific @github/copilot-* packages. |
| java/scripts/codegen/java.ts | Updates Java’s schema path resolution to support the new @github/copilot platform-package schema location across both node_modules locations it checks. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 3
This comment has been minimized.
This comment has been minimized.
…gen resolvers Only swallow ENOENT/ENOTDIR when probing the @github scope directory so permission/I/O failures are no longer misreported as 'schema not found'. Also correct the java codegen not-found message to name both install locations the resolver searches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cross-SDK Consistency Review ✅This PR modifies two codegen infrastructure scripts, not SDK client code:
Both scripts receive an equivalent fix (umbrella-package-first lookup, then platform-specific package fallback), covering all six SDK language generators in a single PR. No public SDK APIs are added, removed, or changed. No cross-SDK consistency issues found. All language generators are updated uniformly.
|
Why
The "Update @github/copilot Dependency" workflow started failing at the codegen step when bumping to
1.0.64-1:In
1.0.64-1the@github/copilotCLI package was restructured: the umbrella package became a thin loader (npm-loader.js), and its bundled assets, includingapi.schema.jsonandsession-events.schema.json, moved into the platform-specific optional-dependency packages (@github/copilot-linux-x64,@github/copilot-win32-x64, etc.). Our codegen scripts hardcoded the old@github/copilot/schemas/...path, which no longer exists.Approach
Both schema resolvers now check the umbrella package first (older versions), then fall back to scanning the
@githubscope for any installed@github/copilot-*platform package and readingschemas/<file>from it. This is host-agnostic, so it works on Linux CI and on Windows.scripts/codegen/utils.ts- resolver for the TS/C#/Python/Go/Rust generatorsjava/scripts/codegen/java.ts- resolver for the Java generator (preserves its existing two-location search order)The Java codegen would have hit the same failure at its later (skipped) step, so it gets the same fix.
Notes
@github/copilotdoes not match thecopilot-prefix, and any non-platform match simply fails thefs.accesscheck and falls through. Since all platform packages of a given version ship identical schemas,readdirordering does not affect correctness.Validation
Reproduced the real
1.0.64-1install layout locally and ran both generators end to end. The previously-failingtsx typescript.tsstep and the Java generator both resolved schemas from the platform package and succeeded.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com