import { readFile } from 'node:fs/promises'; import { join } from 'node:path'; import { readModuleManifest } from '../../module/import'; import type { Check } from './types'; /** * Runs the same manifest pipeline `module import` runs (zod schema + * zone + derive + hook + cross-cap + capability-name + variable-source * checks). Reports a single Check: ok if everything passes, fail with * the first error message otherwise. * * One row instead of N because a broken manifest cascades — fix the * first thing and the next run will surface the next thing. Surfacing * every individual sub-validator would just spam the report. */ export async function checkManifestSchema(modulePath: string): Promise { const result = await readModuleManifest(modulePath); if (result.success) { return { category: 'manifest_schema', name: 'manifest.yml', status: 'ok', message: 'manifest passes all schema validations', }; } return { category: 'manifest_schema', name: 'manifest.yml', status: 'fail', message: result.error, }; } /** * Reads `manifest.yml` from the given module path as raw YAML. Used by * checkers that want the manifest's claimed values without paying the * full validation cost (e.g. capability-version drift, where a malformed * manifest is already failed by checkManifestSchema). */ export async function readManifestYaml(modulePath: string): Promise { return readFile(join(modulePath, 'manifest.yml'), 'utf-8'); }