scripts/check-primitives-map.mjs
scripts/check-primitives-map.mjsBrowse 6 files
539 tokens
2,152 bytes
Token encoding: o200k_base
Snapshot 8beb6cd
← Back to SKILL.md
1#!/usr/bin/env node2/**3 * Validate the primitives taxonomy:4 * - parses5 * - unique ids6 * - every code/docs path resolves on disk7 * - summaries stay single-line and short (no feature-changelog essays)8 */9import {10 checkPrimitivesMapPaths,11 defaultMapPath,12 loadPrimitivesMap,13} from './primitives-map.mjs'14 15const maxSummaryLength = 12016const map = loadPrimitivesMap()17/** @type {Array<string>} */18const errors = []19 20const primitiveIds = new Set()21for (const primitive of map.primitives) {22 if (primitiveIds.has(primitive.id)) {23 errors.push(`duplicate primitive id: ${primitive.id}`)24 }25 primitiveIds.add(primitive.id)26 if (!primitive.name?.trim()) {27 errors.push(`primitive ${primitive.id} missing name`)28 }29 if (!primitive.group?.trim()) {30 errors.push(`primitive ${primitive.id} missing group`)31 }32 if (!primitive.summary?.trim()) {33 errors.push(`primitive ${primitive.id} missing summary`)34 } else if (primitive.summary.length > maxSummaryLength) {35 errors.push(36 `primitive ${primitive.id} summary is ${primitive.summary.length} chars (max ${maxSummaryLength}); put detail in docs`,37 )38 }39 if (/\n/.test(primitive.summary ?? '')) {40 errors.push(`primitive ${primitive.id} summary must be a single line`)41 }42}43 44const invariantIds = new Set()45for (const invariant of map.invariants) {46 if (invariantIds.has(invariant.id)) {47 errors.push(`duplicate invariant id: ${invariant.id}`)48 }49 invariantIds.add(invariant.id)50 if (!invariant.summary?.trim()) {51 errors.push(`invariant ${invariant.id} missing summary`)52 } else if (invariant.summary.length > maxSummaryLength) {53 errors.push(54 `invariant ${invariant.id} summary is ${invariant.summary.length} chars (max ${maxSummaryLength}); put detail in docs`,55 )56 }57}58 59for (const issue of checkPrimitivesMapPaths(map)) {60 errors.push(`${issue.kind} ${issue.id}: ${issue.path} (${issue.reason})`)61}62 63if (errors.length > 0) {64 console.error(`primitives map check failed (${defaultMapPath}):`)65 for (const error of errors) {66 console.error(` - ${error}`)67 }68 process.exit(1)69}70 71console.log(72 `primitives map ok: ${map.primitives.length} primitives, ${map.invariants.length} invariants`,73)74