MCPcopy Index your code
hub / github.com/github/copilot-sdk / resolveCopilotSchemaPath

Function resolveCopilotSchemaPath

java/scripts/codegen/java.ts:163–198  ·  view source on GitHub ↗

* Resolve a JSON schema shipped by the `@github/copilot` CLI package. * * The CLI package layout changed in 1.0.64-1: the umbrella `@github/copilot` * package became a thin loader and its bundled assets (including the JSON * schemas) moved into the platform-specific packages installed as optiona

(fileName: string)

Source from the content-addressed store, hash-verified

161 * first (older versions) and then whichever platform package is present.
162 */
163async function resolveCopilotSchemaPath(fileName: string): Promise<string> {
164 const nodeModulesDirs = [
165 path.join(REPO_ROOT, "scripts/codegen/node_modules"),
166 path.join(REPO_ROOT, "nodejs/node_modules"),
167 ];
168
169 const candidates: string[] = [];
170 for (const nodeModulesDir of nodeModulesDirs) {
171 candidates.push(path.join(nodeModulesDir, "@github/copilot/schemas", fileName));
172 const githubScopeDir = path.join(nodeModulesDir, "@github");
173 try {
174 for (const entry of await fs.readdir(githubScopeDir)) {
175 if (entry.startsWith("copilot-")) {
176 candidates.push(path.join(githubScopeDir, entry, "schemas", fileName));
177 }
178 }
179 } catch (err) {
180 const code = (err as NodeJS.ErrnoException).code;
181 if (code !== "ENOENT" && code !== "ENOTDIR") {
182 throw err;
183 }
184 // @github scope directory may not exist; try the next location.
185 }
186 }
187
188 for (const candidate of candidates) {
189 try {
190 await fs.access(candidate);
191 return candidate;
192 } catch {
193 // Try the next candidate.
194 }
195 }
196
197 throw new Error(`${fileName} not found. Run 'npm ci' in java/scripts/codegen or java/nodejs first.`);
198}
199
200async function getSessionEventsSchemaPath(): Promise<string> {
201 return resolveCopilotSchemaPath("session-events.schema.json");

Callers 2

getApiSchemaPathFunction · 0.70

Calls 3

joinMethod · 0.80
readdirMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…