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

Function resolveCopilotSchemaPath

scripts/codegen/utils.ts:62–92  ·  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

(nodeModulesDir: string, fileName: string)

Source from the content-addressed store, hash-verified

60 * current host.
61 */
62async function resolveCopilotSchemaPath(nodeModulesDir: string, fileName: string): Promise<string> {
63 const candidates = [path.join(nodeModulesDir, "@github/copilot/schemas", fileName)];
64
65 const githubScopeDir = path.join(nodeModulesDir, "@github");
66 try {
67 for (const entry of await fs.readdir(githubScopeDir)) {
68 if (entry.startsWith("copilot-")) {
69 candidates.push(path.join(githubScopeDir, entry, "schemas", fileName));
70 }
71 }
72 } catch (err) {
73 const code = (err as NodeJS.ErrnoException).code;
74 if (code !== "ENOENT" && code !== "ENOTDIR") {
75 throw err;
76 }
77 // @github scope directory may not exist yet; fall through to the error below.
78 }
79
80 for (const candidate of candidates) {
81 try {
82 await fs.access(candidate);
83 return candidate;
84 } catch {
85 // Try the next candidate.
86 }
87 }
88
89 throw new Error(
90 `${fileName} not found under ${githubScopeDir}. Run 'npm ci' in nodejs/ first.`
91 );
92}
93
94export async function getSessionEventsSchemaPath(): Promise<string> {
95 return resolveCopilotSchemaPath(SDK_NODE_MODULES, "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…