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

Function registerStore

test/core/references.test.ts:51–79  ·  view source on GitHub ↗
(
    id: string,
    options: { healthyRoot?: boolean; metadataId?: string | null } = {}
  )

Source from the content-addressed store, hash-verified

49 }
50
51 async function registerStore(
52 id: string,
53 options: { healthyRoot?: boolean; metadataId?: string | null } = {}
54 ): Promise<string> {
55 const storeRoot = mkdir(`stores/${id}`);
56 if (options.healthyRoot !== false) {
57 createOpenSpecRoot(storeRoot);
58 }
59 if (options.metadataId !== null) {
60 await writeStoreMetadataState(storeRoot, {
61 version: 1,
62 id: options.metadataId ?? id,
63 });
64 }
65
66 const existing = await readStoreRegistryState({ globalDataDir }).catch(() => null);
67 await writeStoreRegistryState(
68 {
69 version: 1,
70 stores: {
71 ...(existing?.stores ?? {}),
72 [id]: { backend: { type: 'git', local_path: storeRoot } },
73 },
74 },
75 { globalDataDir }
76 );
77
78 return storeRoot;
79 }
80
81 function appRoot(): ResolvedOpenSpecRoot {
82 const rootDir = mkdir('app-repo');

Calls 5

writeStoreMetadataStateFunction · 0.85
readStoreRegistryStateFunction · 0.85
writeStoreRegistryStateFunction · 0.85
mkdirFunction · 0.70
createOpenSpecRootFunction · 0.70

Tested by

no test coverage detected