* 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)
| 60 | * current host. |
| 61 | */ |
| 62 | async 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 | |
| 94 | export async function getSessionEventsSchemaPath(): Promise<string> { |
| 95 | return resolveCopilotSchemaPath(SDK_NODE_MODULES, "session-events.schema.json"); |
no test coverage detected
searching dependent graphs…