- Update register_agent callers added on main after Phase 3 diverged (live_socket_check + claim_task tests), pass None for host - Prefix unused host param with underscore (WIP — wiring in next slice) - Allow dead_code on MIGRATIONS constant (schema not yet wired) Rebase conflict resolution only — no behavioral changes.
92 lines
3.2 KiB
Bash
Executable file
92 lines
3.2 KiB
Bash
Executable file
#!/bin/sh
|
|
# stage-wiki-for-starlight — copy colibri wiki pages into a Starlight docs
|
|
# content tree with injected frontmatter and route-fixed links.
|
|
#
|
|
# Usage:
|
|
# ./scripts/stage-wiki-for-starlight.sh [COLIBRI_REPO] [STARLIGHT_CONTENT]
|
|
#
|
|
# Defaults:
|
|
# COLIBRI_REPO = /home/clawdie/ai/colibri
|
|
# STARLIGHT_CONTENT = /usr/home/clawdie/clawdie-docs/src/content/docs
|
|
#
|
|
# What it does:
|
|
# 1. Copies docs/wiki/*.md into <STARLIGHT_CONTENT>/wiki/
|
|
# 2. Injects Starlight frontmatter (title from H1, description from first
|
|
# non-link paragraph)
|
|
# 3. Rewrites intra-wiki ./page.md links to Starlight /wiki/page/ routes
|
|
# 4. Rewrites source-code links (../../crates/..., ../DOC.md) to Forgejo
|
|
# permanent URLs pinned at the build-time HEAD commit
|
|
# 5. Drops the backlink line (Starlight provides breadcrumbs)
|
|
#
|
|
# Idempotent — safe to re-run before every docs build.
|
|
set -eu
|
|
|
|
COLIBRI_REPO="${1:-/home/clawdie/ai/colibri}"
|
|
STARLIGHT_CONTENT="${2:-/usr/home/clawdie/clawdie-docs/src/content/docs}"
|
|
WIKI_SRC="${COLIBRI_REPO}/docs/wiki"
|
|
WIKI_DST="${STARLIGHT_CONTENT}/wiki"
|
|
|
|
if [ ! -d "${WIKI_SRC}" ]; then
|
|
echo "ERROR: wiki source not found at ${WIKI_SRC}" >&2
|
|
exit 1
|
|
fi
|
|
if [ ! -d "${STARLIGHT_CONTENT}" ]; then
|
|
echo "ERROR: Starlight content dir not found at ${STARLIGHT_CONTENT}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Pin the colibri commit for source-code permalinks.
|
|
COLIBRI_COMMIT=$(git -C "${COLIBRI_REPO}" rev-parse HEAD 2>/dev/null || echo "main")
|
|
FORGEJO_BASE="https://code.smilepowered.org/clawdie/colibri/src/commit/${COLIBRI_COMMIT}"
|
|
|
|
echo "Staging wiki from ${WIKI_SRC} -> ${WIKI_DST} (colibri ${COLIBRI_COMMIT})"
|
|
|
|
rm -rf "${WIKI_DST}"
|
|
mkdir -p "${WIKI_DST}"
|
|
|
|
for src in "${WIKI_SRC}"/*.md; do
|
|
base="$(basename "${src}")"
|
|
dst="${WIKI_DST}/${base}"
|
|
|
|
# Extract title from H1 (first line starting with "# ")
|
|
title=$(head -1 "${src}" | sed 's/^# //')
|
|
|
|
# Extract description from first substantial non-link paragraph.
|
|
desc=$(awk '
|
|
NR <= 1 { next }
|
|
/^$/ { next }
|
|
/^[←\[#>`]/ { next }
|
|
/^```/ { in_code = !in_code; next }
|
|
in_code { next }
|
|
/^[A-Za-z]/ { print; exit }
|
|
' "${src}")
|
|
|
|
# Fallback
|
|
[ -z "${desc}" ] && desc="${title}"
|
|
|
|
# Escape double quotes for YAML
|
|
title_yaml=$(printf '%s' "${title}" | sed 's/"/\\"/g')
|
|
desc_yaml=$(printf '%s' "${desc}" | sed 's/"/\\"/g')
|
|
|
|
# Write frontmatter
|
|
{
|
|
printf '%s\n' '---'
|
|
printf 'title: "%s"\n' "${title_yaml}"
|
|
printf 'description: "%s"\n' "${desc_yaml}"
|
|
printf '%s\n' '---'
|
|
printf '\n'
|
|
} > "${dst}"
|
|
|
|
# Body with link rewrites.
|
|
# FreeBSD sed: use -E for extended regex, avoid GNU-isms.
|
|
awk 'NR==1 { next } 1' "${src}" \
|
|
| grep -v '^← \[index\]' \
|
|
| sed -E 's|\(\./([a-z0-9-]+)\.md\)|(/wiki/\1/)|g' \
|
|
| sed -E "s|\(\.\./([A-Za-z0-9_.-]+\.md)\)|(${FORGEJO_BASE}/docs/\1)|g" \
|
|
| sed -E "s|\(\.\./\.\./(crates/[^)]+)\)|(${FORGEJO_BASE}/\1)|g" \
|
|
| sed -E "s|\(\.\./\.\./(packaging/[^)]+)\)|(${FORGEJO_BASE}/\1)|g" \
|
|
| sed -E "s|\(\.\./\.\./(scripts/[^)]+)\)|(${FORGEJO_BASE}/\1)|g" \
|
|
>> "${dst}"
|
|
done
|
|
|
|
echo "Wiki staged: $(ls "${WIKI_DST}" | wc -l | tr -d ' ') pages"
|