MCPcopy
hub / github.com/Doorman11991/smallcode / validateFileList

Function validateFileList

src/compiled/cognition/validate.js:235–266  ·  view source on GitHub ↗
(files)

Source from the content-addressed store, hash-verified

233 return { ok: false, issues: inner.issues.map(i => `${f.path}: ${i}`) };
234}
235async function validateFileList(files) {
236 if (files.length === 0) {
237 (0, metrics_1.counter)("cognition.validate.failed", { mode: "ast_compiles", kind: "empty_list" });
238 return { ok: false, issues: ["file list is empty"] };
239 }
240 const aggregated = [];
241 for (let i = 0; i < files.length; i++) {
242 const f = files[i];
243 if (!f || typeof f !== "object" || typeof f.path !== "string") {
244 aggregated.push(`file[${i}]: invalid shape; expected { path, content }`);
245 continue;
246 }
247 // Skip non-TypeScript files (markdown, json, yaml). Their content
248 // shape was already checked by validateSchemaOnly; we only run the
249 // TS compiler over .ts/.tsx files. The .kind hint is honored when
250 // present, otherwise we infer from the path extension.
251 const path = f.path;
252 const isTs = /\.(ts|tsx|cts|mts)$/i.test(path);
253 if (!isTs)
254 continue;
255 const r = await validateSingleFile({ path, content: f.content });
256 if (!r.ok)
257 aggregated.push(...r.issues);
258 }
259 if (aggregated.length > 0) {
260 (0, metrics_1.counter)("cognition.validate.failed", { mode: "ast_compiles", kind: "file_list" });
261 }
262 else {
263 (0, metrics_1.counter)("cognition.validate.passed", { mode: "ast_compiles", kind: "file_list" });
264 }
265 return { ok: aggregated.length === 0, issues: aggregated };
266}
267async function validateTypeScriptString(value) {
268 // Models often emit multi-file artifacts as one block with `// path:`
269 // headers between sections. tsc parses that as a single source file and

Callers 1

validateAstCompilesFunction · 0.70

Calls 1

validateSingleFileFunction · 0.70

Tested by

no test coverage detected