#!/usr/bin/env bash
# Regenerates the combined KB file from the per-module KB files.
# Do not edit the output by hand. Edit the module files under docs/kb/, then run this script.
set -euo pipefail
KB_DIR="${1:-docs/kb}"                       # folder holding 00-...md to 10-...md
OUT="${2:-docs/kb/BUSINESS_KNOWLEDGE_BASE.md}"
{
  echo "<!-- GENERATED by scripts/build-kb.sh from ${KB_DIR}/ — DO NOT EDIT BY HAND -->"
  echo
  echo "# Dinex — Business Knowledge Base (combined)"
  echo
  echo "> Generated from the per-module files listed in ${KB_DIR}/README.md. Edit those files, not this one."
  for f in "${KB_DIR}"/[0-9][0-9]-*.md; do
    echo; echo "---"; echo
    cat "$f"
  done
} > "$OUT"
echo "Wrote $OUT"
