Files
raea/tools/skills-sections.sh
shinyobjectz 5d7afd0493 #269's gates on main as it is now: crates and files under their limits by real splits, the copies folded, no "void"
- raea-cli 2139 -> about 1800 lines: raea goal's verbs (the loop's runner, its usage, the render moment, and raea
  make's asset tools regrouped) are raea-cli-goal (engine/cli/goal), and what a refused render changed is
  raea-cli-refused (engine/cli/refused); verbs.rs and usage.rs re-export them, so no call site moved
- engine/native node.rs 515 -> 495: spawnSync's deadline wait is deadline.rs (its pipes drained on threads of their
  own)
- a CommonJS file's names are exported by alias (`export { __cjs_0 as delete }`), so a reserved word is a name too and
  cjs.rs needs no list of them (the list named "void", which tools/no-void.sh can't tell from the product); the node
  test imports one (`delete as del`)
- raea-runtime-export back to main's: #269's own fix for a .png with no --frame (#261) is gone, main fixed it in the
  stills path (8627ba7a), and both had landed as two paths for one case
- tools/skills.sh 504 -> 459: the sections, their co-change warning (SK4) and `stale` are tools/skills-sections.sh,
  sourced as skills-app.sh is
- dupes back to 293/57: cjs.rs's quote and identifier tests one helper each, its resolve without format!, and the new
  lines that matched others by shape written plainly (js.rs's importing folder, check-make's broke lines, apps/make's
  goals, lod-plan's objects)

layers, names, legacy names, size, one-version, no-void, dupes, cargo shear and rask check pass on this tree;
raea-native's (cjs and node, with the reserved-word import and the spawnSync timeout), raea-cli-refused's and
raea-runtime-lod-plan's tests pass.
2026-11-29 17:18:31 -08:00

51 lines
3.1 KiB
Bash
Executable File

# Sourced by tools/skills.sh (its sections, split out to keep it under 500 lines): the hand-written sections of the
# skill and the craft guides that name their sources (`<!-- sources: PATH ... -->`), cochange()'s SK4 warning when a
# change touches a section's sources and leaves the section alone (check runs it), and stale(), every such section by
# how many commits to its sources it has missed (`tools/skills.sh stale`). Reads SK and texts() from skills.sh.
# each hand-written section that names its sources: file, its first and last line, heading, sources
sections() {
texts | while IFS= read -r f; do
awk -v f="$f" '
function flush() { if (head != "" && src != "") printf "%s\t%d\t%d\t%s\t%s\n", f, start, NR - 1, head, src }
/^## / { flush(); head = substr($0, 4); start = NR; src = "" }
/^<!-- sources: / { s = $0; sub(/^<!-- sources: /, "", s); sub(/ *-->.*$/, "", s); src = s }
END { NR++; flush() }' "$f"
done
}
# a change to a section's sources that leaves the section alone (SK4): a warning, answered in the landing message
cochange() {
local changed
if [ -n "${SKILLS_CHANGED:-}" ]; then changed=$SKILLS_CHANGED
else changed=$(git diff --name-only "$(git merge-base HEAD origin/main 2>/dev/null || echo HEAD)" 2>/dev/null; git diff --name-only HEAD 2>/dev/null); fi
[ -n "$changed" ] || return 0
sections | while IFS=$'\t' read -r f a b head src; do
local hit="" s
for s in $src; do grep -qE "^${s//./\\.}(/|$)" <<< "$changed" && hit="$hit $s"; done
[ -n "$hit" ] || continue
# the section counts as touched when its file changed within its lines (or, with no history here, at all)
# (a skill in raea-skills counts as touched when the pointer moved: raea's history doesn't see inside it)
case $f in "$SK"/*) grep -qx skills <<< "$changed" && continue ;; esac
if grep -qx "$f" <<< "$changed"; then
[ -n "${SKILLS_CHANGED:-}" ] && continue
git diff -U0 "$(git merge-base HEAD origin/main 2>/dev/null || echo HEAD)" -- "$f" | grep -E '^@@' | sed -E 's/^@@ [^+]*\+([0-9]+)(,([0-9]+))?.*/\1 \3/' |
awk -v a="$a" -v b="$b" '{ n = ($2 == "" ? 1 : $2); if ($1 <= b && $1 + n - 1 >= a) t = 1 } END { exit !t }' && continue
fi
echo "skills: warning $f:$a: \"$head\" names$hit, which changed while it didn't; say in the landing message whether it still holds (\"checked, still true\") or edit it"
done
}
# every section with sources, by how many commits to them it has missed since its own lines last changed
stale() {
sections | while IFS=$'\t' read -r f a b head src; do
local t n bl
case $f in "$SK"/*) bl=(git -C skills blame -L "$a,$b" --porcelain -- "${f#skills/}") ;; *) bl=(git blame -L "$a,$b" --porcelain -- "$f") ;; esac
t=$("${bl[@]}" 2>/dev/null | awk '/^committer-time / { if ($2 > m) m = $2 } END { print m + 0 }')
[ "$t" -gt 0 ] || t=$(date +%s)
# shellcheck disable=SC2086
n=$(git rev-list --count --since="$t" HEAD -- $src 2>/dev/null || echo 0)
printf '%s\t%s:%s\t%s\n' "$n" "$f" "$a" "$head"
done | sort -rn -k1,1 | awk -F'\t' 'BEGIN { print "missed section" } { printf "%6d %s %s\n", $1, $2, $3 }'
}