docs: sync consolidation and session starter

This commit is contained in:
Apple
2026-02-16 02:25:54 -08:00
parent 798c6f88c7
commit 7df8cd5882
18 changed files with 345 additions and 6 deletions

95
scripts/docs/docs_backup.sh Executable file
View File

@@ -0,0 +1,95 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
OUT_DIR="$ROOT_DIR/docs/backups"
RETENTION="${DOCS_BACKUP_RETENTION:-20}"
DRY_RUN=1
APPLY=0
usage() {
cat <<'USAGE'
Usage:
bash scripts/docs/docs_backup.sh [--dry-run] [--apply] [--retention N]
Behavior:
- default mode is --dry-run
- --apply creates docs backup archive and rotates old backups
USAGE
}
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run)
DRY_RUN=1
APPLY=0
shift
;;
--apply)
APPLY=1
DRY_RUN=0
shift
;;
--retention)
RETENTION="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown arg: $1" >&2
usage
exit 2
;;
esac
done
STAMP="$(date +%Y%m%d-%H%M%S)"
ARCHIVE="$OUT_DIR/docs_backup_${STAMP}.tar.gz"
LATEST_REF="$OUT_DIR/LATEST.txt"
backup_targets=(
PROJECT-MASTER-INDEX.md
NODA1-SAFE-DEPLOY.md
docs/SESSION_STARTER.md
docs/runbooks
docs/standards
docs/consolidation/README.md
docs/consolidation/SOURCES.md
docs/consolidation/docs_registry_curated.csv
docs/consolidation/INTEGRATIONS_STATUS_LATEST.md
docs/consolidation/jupyter/JUPYTER_SYNC_LATEST.md
docs/consolidation/jupyter/notebooks_index_latest.csv
docs/consolidation/pieces/PIECES_SYNC_LATEST.md
docs/consolidation/pieces/pieces_index_latest.csv
)
existing=()
for t in "${backup_targets[@]}"; do
[[ -e "$ROOT_DIR/$t" ]] && existing+=("$t")
done
if [[ "$DRY_RUN" -eq 1 ]]; then
echo "[dry-run] backup archive: $ARCHIVE"
echo "[dry-run] retention: $RETENTION"
echo "[dry-run] targets:"
printf ' - %s\n' "${existing[@]}"
exit 0
fi
mkdir -p "$OUT_DIR"
tar -czf "$ARCHIVE" -C "$ROOT_DIR" "${existing[@]}"
printf '%s\n' "$ARCHIVE" > "$LATEST_REF"
mapfile -t backups < <(ls -1t "$OUT_DIR"/docs_backup_*.tar.gz 2>/dev/null || true)
if [[ "${#backups[@]}" -gt "$RETENTION" ]]; then
for old in "${backups[@]:$RETENTION}"; do
rm -f "$old"
done
fi
echo "Wrote: $ARCHIVE"
echo "Updated: $LATEST_REF"

31
scripts/docs/docs_lint.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$ROOT_DIR"
if ! command -v npx >/dev/null 2>&1; then
echo "npx not found; install Node.js to run markdown lint" >&2
exit 2
fi
echo "Running markdown lint on tracked markdown files"
scope_file="docs/standards/lint_scope.txt"
if [[ ! -f "$scope_file" ]]; then
echo "Missing lint scope file: $scope_file" >&2
exit 2
fi
mapfile -t scope_paths < <(sed '/^\s*$/d; /^\s*#/d' "$scope_file")
files=()
for p in "${scope_paths[@]}"; do
[[ -f "$p" ]] && files+=("$p")
done
if [[ "${#files[@]}" -eq 0 ]]; then
echo "No markdown files to lint"
exit 0
fi
npx -y markdownlint-cli2 --config .markdownlint.yml "${files[@]}"

View File

@@ -105,8 +105,17 @@ doc_paths=(
docs/consolidation/jupyter/notebooks_index_latest.csv
docs/consolidation/pieces/PIECES_SYNC_LATEST.md
docs/consolidation/pieces/pieces_index_latest.csv
docs/backups/LATEST.txt
docs/standards/DOCS_STYLE_GUIDE.md
docs/standards/DOC_TEMPLATE.md
docs/standards/lint_scope.txt
PROJECT-MASTER-INDEX.md
.markdownlint.yml
.markdownlintignore
.github/workflows/docs-lint.yml
scripts/docs/session_bootstrap.sh
scripts/docs/docs_backup.sh
scripts/docs/docs_lint.sh
scripts/docs/jupyter_sync.sh
scripts/docs/pieces_sync.sh
scripts/docs/services_sync.sh

View File

@@ -14,9 +14,10 @@ Usage:
bash scripts/docs/services_sync.sh [--dry-run] [--apply] [--probe-ports 39300,39301]
Workflow:
1) integration bootstrap status
2) jupyter sync adapter
3) pieces sync adapter
1) docs backup
2) integration bootstrap status
3) jupyter sync adapter
4) pieces sync adapter
USAGE
}
@@ -49,6 +50,8 @@ while [[ $# -gt 0 ]]; do
done
if [[ "$DRY_RUN" -eq 1 ]]; then
echo "[dry-run] running: scripts/docs/docs_backup.sh --dry-run"
bash scripts/docs/docs_backup.sh --dry-run
echo "[dry-run] running: scripts/docs/session_bootstrap.sh"
bash scripts/docs/session_bootstrap.sh
echo "[dry-run] running: scripts/docs/jupyter_sync.sh --dry-run"
@@ -62,6 +65,7 @@ if [[ "$DRY_RUN" -eq 1 ]]; then
exit 0
fi
bash scripts/docs/docs_backup.sh --apply
bash scripts/docs/session_bootstrap.sh
bash scripts/docs/jupyter_sync.sh --apply
if [[ -n "$PROBE_PORTS" ]]; then