docs(style): enforce clickable links for Markdown references

- Add COMMON/docs-style.md with linking rule
- Convert plain Markdown file references to relative links across docs
This commit is contained in:
2025-09-10 17:43:37 -05:00
parent 59e104a57c
commit 2a7d270062
12 changed files with 31 additions and 98 deletions

83
scripts/prompts Normal file → Executable file
View File

@@ -22,88 +22,18 @@ ci_run() {
# Use compose to run with current uid:gid to avoid file ownership issues
docker compose -f "$root/docker/ci.compose.yml" run --rm \
--user "$(id -u):$(id -g)" \
-e IN_CI_CONTAINER=1 ci bash -lc "$1" </dev/null
-e IN_CI_CONTAINER=1 ci bash -lc "cd /workspace && $1" </dev/null
}
build_manifest() {
local manifest=$1 out=$2 root
root="$(repo_root)"
mkdir -p "$root/dist/prompts"
local cmd
cmd=$(cat <<'PY'
python3 - << 'EOF'
import os, sys, yaml
manifest_path = sys.argv[1]
out_path = sys.argv[2]
seen = []
def load_manifest(path):
with open(path, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
def collect(mod, acc):
if mod not in acc:
acc.append(mod)
def resolve(path):
m = load_manifest(path)
includes = m.get('include', []) or []
modules = m.get('modules', []) or []
for inc in includes:
for x in resolve(inc):
collect(x, seen)
for mod in modules:
collect(mod, seen)
return seen
mods = resolve(manifest_path)
if not mods:
print(f"No modules resolved from {manifest_path}", file=sys.stderr)
sys.exit(1)
os.makedirs(os.path.dirname(out_path), exist_ok=True)
def read(p):
with open(p, 'r', encoding='utf-8') as f:
return f.read().strip() + "\n\n"
with open(out_path, 'w', encoding='utf-8') as out:
out.write("Generated Prompt Pack\n\n")
for m in mods:
out.write(f"--- {m} ---\n")
out.write(read(m))
# Budgets (approximate by word count)
def words(s):
return len(s.split())
with open(out_path, 'r', encoding='utf-8') as f:
content = f.read()
total_words = words(content)
BASE_BUDGET = 1200
if total_words > BASE_BUDGET:
print(f"ERROR: Pack exceeds budget: {total_words} > {BASE_BUDGET}", file=sys.stderr)
sys.exit(3)
# Per-module budget check
ERRORS = 0
MOD_BUDGET = 400
for m in mods:
with open(m, 'r', encoding='utf-8') as f:
wc = words(f.read())
if wc > MOD_BUDGET:
print(f"ERROR: Module {m} exceeds budget: {wc} > {MOD_BUDGET}", file=sys.stderr)
ERRORS += 1
if ERRORS:
sys.exit(4)
print(f"Built {out_path} with {total_words} words across {len(mods)} modules.")
EOF
PY
)
ci_run "$cmd" <<<"$manifest $out"
# Write on host to avoid ownership issues; container prints to stdout.
TMP_OUT=$(mktemp)
trap '[[ -n "${TMP_OUT:-}" ]] && rm -f "$TMP_OUT"' EXIT
ci_run "python3 scripts/prompt_build.py '$manifest' -" >"$TMP_OUT"
mv "$TMP_OUT" "$out"
}
cmd=${1:-}
@@ -127,4 +57,3 @@ case "$cmd" in
"$0" all ;;
*) usage ;;
esac