MCPcopy Index your code
hub / github.com/Fission-AI/OpenSpec / registerStore

Function registerStore

test/core/root-selection.test.ts:55–89  ·  view source on GitHub ↗
(
    id: string,
    options: { healthyRoot?: boolean; metadataId?: string | null } = {}
  )

Source from the content-addressed store, hash-verified

53 }
54
55 async function registerStore(
56 id: string,
57 options: { healthyRoot?: boolean; metadataId?: string | null } = {}
58 ): Promise<string> {
59 const storeRoot = mkdir(`stores/${id}`);
60 if (options.healthyRoot !== false) {
61 createOpenSpecRoot(storeRoot);
62 }
63 if (options.metadataId !== null) {
64 await writeStoreMetadataState(storeRoot, {
65 version: 1,
66 id: options.metadataId ?? id,
67 });
68 }
69
70 const existing = fs.existsSync(path.join(globalDataDir, 'stores', 'registry.yaml'));
71 const registryStores = existing
72 ? (await import('../../src/core/store/foundation.js').then((m) =>
73 m.readStoreRegistryState({ globalDataDir })
74 ))?.stores ?? {}
75 : {};
76
77 await writeStoreRegistryState(
78 {
79 version: 1,
80 stores: {
81 ...registryStores,
82 [id]: { backend: { type: 'git', local_path: storeRoot } },
83 },
84 },
85 { globalDataDir }
86 );
87
88 return storeRoot;
89 }
90
91 async function expectRootSelectionError(
92 promise: Promise<unknown>,

Callers 1

Calls 4

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

Tested by

no test coverage detected