* Reads the resolved root's config once, assembles the referenced-store * index when references are declared, and resolves the config path for * fix text. Shared by both instruction surfaces.
(root: ResolvedOpenSpecRoot)
| 72 | * fix text. Shared by both instruction surfaces. |
| 73 | */ |
| 74 | async function loadRootConfigContext(root: ResolvedOpenSpecRoot): Promise<{ |
| 75 | projectConfig: ProjectConfig | null; |
| 76 | references: ReferenceIndexEntry[] | undefined; |
| 77 | }> { |
| 78 | // readProjectConfig never throws: missing/unparseable configs are null. |
| 79 | const projectConfig = readProjectConfig(root.path); |
| 80 | |
| 81 | // One registry read serves every relationship consumer in this |
| 82 | // output so it never carries a torn snapshot. |
| 83 | const snapshot = await readRegistrySnapshot(); |
| 84 | const registryEntries = snapshot.entries; |
| 85 | |
| 86 | const declared = projectConfig?.references ?? []; |
| 87 | const index = |
| 88 | declared.length > 0 |
| 89 | ? await assembleReferenceIndex({ references: declared, resolvedRoot: root, registryEntries }) |
| 90 | : []; |
| 91 | |
| 92 | // Omitted, not empty: an index emptied by self-reference omission must |
| 93 | // look identical to an undeclared one in JSON. |
| 94 | return { |
| 95 | projectConfig, |
| 96 | references: index.length > 0 ? index : undefined, |
| 97 | }; |
| 98 | } |
| 99 | |
| 100 | export async function instructionsCommand( |
| 101 | artifactId: string | undefined, |
no test coverage detected