#!/usr/bin/env bash # ============================================================================= # skills/ingest/scripts/scoped-lint.sh # Run the framework's validation on ONLY the files touched this session. # Reuses lib/lint.sh + lib/output.sh — same checks as `make lint`, scoped. # # KG_LIB_DIR=/opt/knowledge-genome-orchestrator/lib \ # scoped-lint.sh wiki/sources/x.md wiki/entities/y.md # # Exits non-zero if any hard error is found, so the agent notices. # Findings are printed (stderr from the lint functions + a summary on stdout). # ============================================================================= set -euo pipefail : "${KG_LIB_DIR:?set KG_LIB_DIR to the framework lib/ dir (e.g. /opt/knowledge-genome-orchestrator/lib)}" # Fail clearly if the lib files are missing, rather than a raw `source: No such file`. for _f in output.sh lint.sh; do [[ -f "${KG_LIB_DIR}/${_f}" ]] || { echo "scoped-lint: missing ${KG_LIB_DIR}/${_f}" >&2; exit 1; } done # shellcheck source=/dev/null source "${KG_LIB_DIR}/output.sh" # shellcheck source=/dev/null source "${KG_LIB_DIR}/lint.sh" genome="${1:?usage: scoped-lint.sh }" shift [[ $# -gt 0 ]] || { echo "scoped-lint: no files given" >&2; exit 1; } errors=0 stale=0 count=$# for f in "$@"; do if [[ ! -f "$f" ]]; then warn "scoped-lint: missing file (skipped): $f" continue fi lint_markdown_file "$f" "$genome" && fe=0 || fe=$? check_privacy_consistency "$f" && pce=0 || pce=$? check_page_size "$f" && pse=0 || pse=$? errors=$(( errors + fe + pce + pse )) check_knowledge_decay "$f" && st=0 || st=$? stale=$(( stale + st )) check_broken_links "$f" || true # warnings only done echo "" echo "scoped-lint: ${errors} error(s), ${stale} stale across ${count} file(s)" [[ $errors -eq 0 ]]