From b283911134c7bcbe83288f07fb0afeefb9f9280f Mon Sep 17 00:00:00 2001 From: Matteo Cherubini Date: Fri, 8 May 2026 21:09:42 +0200 Subject: [PATCH] feat: Add scripts for linting genomes and adding individual genomes --- scripts/add-genome.sh | 29 +++++++++++++++++++++++++++++ scripts/lint-genomes.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 scripts/add-genome.sh create mode 100644 scripts/lint-genomes.sh diff --git a/scripts/add-genome.sh b/scripts/add-genome.sh new file mode 100644 index 0000000..09e0aa1 --- /dev/null +++ b/scripts/add-genome.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# ============================================================================= +# scripts/add-genome.sh +# Helper to add a single new genome to the existing infrastructure. +# Usage: make add-genome NAME=my-new-genome DESC="Description here" +# ============================================================================= + +set -euo pipefail +source "lib/output.sh" +source "config.env" + +GENOME_NAME="${1:-}" +GENOME_DESC="${2:-}" + +if [[ -z "$GENOME_NAME" || -z "$GENOME_DESC" ]]; then + error "Missing arguments." + echo "Usage: $0 " + exit 1 +fi + +step "Adding New Genome: ${GENOME_NAME}" + +# Overwrite the GENOMES array for this session to process only the new one +export GENOMES=("${GENOME_NAME}|${GENOME_DESC}") + +# Trigger the standard genome setup logic +bash "scripts/setup-genomes.sh" + +success "Genome '${GENOME_NAME}' added and linked successfully!" diff --git a/scripts/lint-genomes.sh b/scripts/lint-genomes.sh new file mode 100644 index 0000000..1aad8f4 --- /dev/null +++ b/scripts/lint-genomes.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# ============================================================================= +# scripts/lint-genomes.sh +# Executes quality control across all registered genomes. +# ============================================================================= + +set -euo pipefail +source "lib/output.sh" +source "config.env" +source "lib/lint.sh" + +step "Starting Knowledge Genome Linting" + +TOTAL_ERRORS=0 + +# Iterate through genome submodules inside the Master repo +for genome_dir in "${WORK_DIR}/${MASTER_REPO}"/genome-*/; do + [[ -d "$genome_dir" ]] || continue + + GENOME_NAME=$(basename "$genome_dir") + info "Auditing genome: ${GENOME_NAME}..." + + # Find all .md files, excluding AGENTS.md and external references + while IFS= read -r md_file; do + # Run validations + lint_markdown_file "$md_file" "$GENOME_NAME" || TOTAL_ERRORS=$((TOTAL_ERRORS + $?)) + check_privacy_consistency "$md_file" || TOTAL_ERRORS=$((TOTAL_ERRORS + $?)) + check_broken_links "$md_file" + + done < <(find "$genome_dir" -name "*.md" ! -name "AGENTS.md" ! -path "*/core-karpathy/*") +done + +if [[ $TOTAL_ERRORS -eq 0 ]]; then + success "Linting passed: All files are consistent and secure." +else + error "Linting failed: Found ${TOTAL_ERRORS} critical issues." + exit 1 +fi