50 lines
1.6 KiB
Bash
50 lines
1.6 KiB
Bash
#!/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-setup/lib \
|
|
# scoped-lint.sh <genome_name> 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-setup/lib)}"
|
|
|
|
# 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 <genome> <file...>}"
|
|
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 ]]
|