MCPcopy Index your code
hub / github.com/BuilderIO/skills / assertSkillCurrent

Function assertSkillCurrent

scripts/sync-agent-native-plan-skills.mjs:123–149  ·  view source on GitHub ↗
(name, sourceDir)

Source from the content-addressed store, hash-verified

121}
122
123async function assertSkillCurrent(name, sourceDir) {
124 const destination = path.join(destinationRoot, name);
125 if (!existsSync(destination)) {
126 throw new Error(`${name} is missing at ${destination}`);
127 }
128
129 const sourceFiles = (await listFiles(sourceDir)).filter(
130 (rel) => !publicDocOverlays.has(rel),
131 );
132 const destinationFiles = (await listFiles(destination)).filter(
133 (rel) => !publicDocOverlays.has(rel),
134 );
135 if (sourceFiles.join("\n") !== destinationFiles.join("\n")) {
136 throw new Error(`${name} file list is out of sync`);
137 }
138
139 for (const rel of sourceFiles) {
140 const [sourceBody, destinationBody] = await Promise.all([
141 readFile(path.join(sourceDir, rel), "utf8"),
142 readFile(path.join(destination, rel), "utf8"),
143 ]);
144 if (sourceBody !== destinationBody) {
145 throw new Error(`${name}/${rel} is out of sync`);
146 }
147 }
148 console.log(`${name} is current`);
149}
150
151try {
152 const sources = resolveSources(requestedSource);

Calls 1

listFilesFunction · 0.85

Tested by

no test coverage detected