MCPcopy
hub / github.com/Fission-AI/OpenSpec / loadRootConfigContext

Function loadRootConfigContext

src/commands/workflow/instructions.ts:74–98  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

72 * fix text. Shared by both instruction surfaces.
73 */
74async 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
100export async function instructionsCommand(
101 artifactId: string | undefined,

Callers 2

instructionsCommandFunction · 0.85
applyInstructionsCommandFunction · 0.85

Calls 3

readProjectConfigFunction · 0.85
readRegistrySnapshotFunction · 0.85
assembleReferenceIndexFunction · 0.85

Tested by

no test coverage detected