4 Commits

Author SHA1 Message Date
8f523da270 Merge pull request 'feat(lint): wire Vale as deterministic prefilter for skill-audit/agent-audit' (#85) from feat/84-vale-audit-prefilter into main
Reviewed-on: https://git.dev.rkdr.net/Defame1297/holocron/pulls/85
Reviewed-by: Defame1297 <gitea@rkdr.net>
2026-08-10 16:46:59 +00:00
cf5de2bd87 fix(lint): fail loudly on a nonexistent REPO_ROOT in check-vale-style-sync.sh
A bad or stale REPO_ROOT argument fell through to the "neither copy
present" no-op guard and exited 0 — the exact "clean result can mean
nothing was checked" anti-pattern this PR spent multiple review rounds
eliminating elsewhere. That guard exists for a repo that legitimately has
no kyberforge plugin installed, not for a typo'd path.

Only the documented manual-invocation mode was affected: the shipped
pre-push hook always calls this script with zero args, which resolves via
`git rev-parse --show-toplevel` and is always valid inside a repo.

Added a regression test asserting a nonexistent REPO_ROOT exits non-zero.

Refs: #85
2026-08-10 07:45:58 +00:00
76e0df6f5b chore(plugins): patch-bump gitea for shipped content changes
gitea 1.3.2 -> 1.3.3. The round-1 Vale corpus fix (3324a73) changed
shipped skill content (gitea-issues, gitea-prs, gitea-releases SKILL.md)
without touching this plugin's manifests, so installed copies would keep
serving the old content from cache. Every other plugin whose content
changed in this PR got this bump (bin, kyberforge, lint, four times
total) — gitea was missed each time.

Marketplace entries carry no per-plugin version, so both marketplace.json
files are untouched, matching prior version-bump commits in this PR.

Refs: #85
2026-08-10 07:38:09 +00:00
389a4f0f7a fix(lint): avoid bash 4 associative arrays in check-vale-style-sync.sh
check-vale-style-sync.sh used `declare -A` for a per-skill regex cache.
Associative arrays are bash 4.0+; this script runs as an always-run
pre-push hook with `language: system`, so it inherits whatever bash is
first on the invoking user's PATH. On macOS's stock bash 3.2, `declare -A`
at top level aborts immediately under `set -euo pipefail` — every push
would hard-fail before the sync check ran anything.

Replaced with two parallel indexed arrays (HOOK_REGEX_CACHE_KEYS/_VALS),
linear-scanned by index — same caching behavior (avoids re-parsing both
pre-commit manifests when agent-audit is probed twice), but only ever
uses ${#arr[@]} and index access, never a bare ${arr[@]} expansion.

Extended test-vale-wrap.sh's existing bash-3.2 hazard sweep to scan this
file too, and added a check for `declare -A` itself — it previously only
caught unguarded ${arr[@]} expansions and mapfile/readarray, so this
exact regression had no test that would have caught it.

Refs: #85
2026-08-10 07:37:55 +00:00
5 changed files with 59 additions and 22 deletions

View File

@@ -15,5 +15,5 @@
],
"license": "MIT",
"name": "gitea",
"version": "1.3.2"
"version": "1.3.3"
}

View File

@@ -20,5 +20,5 @@
"skills": [
"skills/"
],
"version": "1.3.2"
"version": "1.3.3"
}

View File

@@ -10,11 +10,17 @@ set -euo pipefail
# only one of the two. Run from repo root or pass REPO_ROOT as arg.
REPO_ROOT="${1:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
# A nonexistent REPO_ROOT must fail loudly, not fall through to the "neither
# copy present" no-op below — that guard exists for a repo that legitimately
# has no kyberforge plugin installed, not for a typo'd or stale path, and a
# clean exit 0 here would read as "checked, in sync" when nothing ran at all.
if [[ ! -d "$REPO_ROOT" ]]; then
echo "Vale style sync check failed: REPO_ROOT '$REPO_ROOT' is not a directory." >&2
exit 1
fi
# Absolutized because the glob probe below `cd`s into a scratch tree, where a
# relative --config path would stop resolving.
if [[ -d "$REPO_ROOT" ]]; then
REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
fi
REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
FAIL=0
err() { echo " FAIL: $1" >&2; FAIL=$((FAIL + 1)); }
@@ -81,21 +87,26 @@ done
# $1's vale-wrap.sh. Records are delimited by their `- id:` line, so the check
# does not depend on `entry:` preceding `files:` within a record.
#
# Cached per skill (in HOOK_REGEX_CACHE, populated lazily) because the final
# validation loop below probes agent-audit twice — once for its CC agent-file
# shape, once for its Copilot .agent.md shape — and both probes need the same
# regex set. Without the cache, that pair of calls would each re-parse both
# manifest files from scratch for no new information. HOOK_REGEX_CACHE_SEEN is
# a separate array so a skill with no matching hooks (empty result) is still
# recognized as already computed, rather than re-parsed every call.
declare -A HOOK_REGEX_CACHE=()
declare -A HOOK_REGEX_CACHE_SEEN=()
# Cached per skill (parallel HOOK_REGEX_CACHE_KEYS/_VALS arrays, populated
# lazily) because the final validation loop below probes agent-audit twice —
# once for its CC agent-file shape, once for its Copilot .agent.md shape — and
# both probes need the same regex set. Without the cache, that pair of calls
# would each re-parse both manifest files from scratch for no new information.
# Plain indexed arrays, not `declare -A`: associative arrays are bash 4.0+ and
# this script must run on macOS's stock bash 3.2. Only ${#arr[@]} (always safe
# on an empty/unset array under `set -u`) and index access are used below —
# never a bare `${arr[@]}` expansion, which aborts on bash < 4.4 under nounset.
HOOK_REGEX_CACHE_KEYS=()
HOOK_REGEX_CACHE_VALS=()
hook_file_regexes() {
local skill="$1" manifest raw result
if [[ -n "${HOOK_REGEX_CACHE_SEEN[$skill]:-}" ]]; then
printf '%s' "${HOOK_REGEX_CACHE[$skill]}"
local skill="$1" manifest raw result idx=0
while [[ $idx -lt ${#HOOK_REGEX_CACHE_KEYS[@]} ]]; do
if [[ "${HOOK_REGEX_CACHE_KEYS[$idx]}" == "$skill" ]]; then
printf '%s' "${HOOK_REGEX_CACHE_VALS[$idx]}"
return
fi
idx=$((idx + 1))
done
result="$(
for manifest in "$REPO_ROOT/.pre-commit-hooks.yaml" "$REPO_ROOT/.pre-commit-config.yaml"; do
[[ -f "$manifest" ]] || continue
@@ -116,8 +127,8 @@ hook_file_regexes() {
printf '%s\n' "$raw"
done
)"
HOOK_REGEX_CACHE[$skill]="$result"
HOOK_REGEX_CACHE_SEEN[$skill]=1
HOOK_REGEX_CACHE_KEYS[${#HOOK_REGEX_CACHE_KEYS[@]}]="$skill"
HOOK_REGEX_CACHE_VALS[${#HOOK_REGEX_CACHE_VALS[@]}]="$result"
printf '%s' "$result"
}

View File

@@ -123,6 +123,19 @@ else
fail "exited non-zero when skill-audit/agent-audit are simply absent"
fi
# --- 5b. Exits 1 when REPO_ROOT does not exist ---
# A nonexistent path used to fall through to the "neither copy present" no-op
# (test 5 above) and exit 0 — indistinguishable from a real, verified in-sync
# result. That guard is for a repo legitimately missing kyberforge, not a
# typo'd or stale path.
echo ""
echo "--- exits 1 when REPO_ROOT does not exist ---"
if bash "$SCRIPT" "/nonexistent/path/$(date +%s)-$$" > /dev/null 2>&1; then
fail "exited 0 for a nonexistent REPO_ROOT — expected exit 1"
else
pass "exits non-zero for a nonexistent REPO_ROOT"
fi
# --- 6. Exits 1 when only one of the two copies is present ---
# The no-op guard used `||`, so a single missing copy also exited 0 — a deleted
# or renamed copy passed the sync check silently.

View File

@@ -447,7 +447,10 @@ fi
# scripts, and the test runner AGENTS.md tells contributors to run by hand.
# `mapfile` is checked alongside, because it is bash 4.0+ and the expansion scan
# cannot see it — run-tests.sh carried one until it was replaced with a
# `while read` loop, and nothing would have caught its return.
# `while read` loop, and nothing would have caught its return. `declare -A`
# (bash 4.0+ associative arrays) is checked for the same reason — the
# expansion scan cannot see it, and check-vale-style-sync.sh carried a pair of
# them until they were replaced with index-scanned plain arrays.
echo ""
echo "--- no unguarded array expansion remains in the macOS-facing scripts ---"
unguarded_expansions() {
@@ -474,6 +477,7 @@ for BASH32_SCRIPT in \
"$SCRIPT" \
"$REPO_ROOT/scripts/skill-size-check.sh" \
"$REPO_ROOT/scripts/check-release-needed.sh" \
"$REPO_ROOT/scripts/check-vale-style-sync.sh" \
"$REPO_ROOT/tests/run-tests.sh"; do
FOUND16="$(unguarded_expansions "$BASH32_SCRIPT")"
if [[ -n "$FOUND16" ]]; then
@@ -486,6 +490,15 @@ for BASH32_SCRIPT in \
if [[ -n "$FOUND16B" ]]; then
HAZARDS16+="${BASH32_SCRIPT##*/}:$FOUND16B "
fi
# `declare -A` (associative arrays) is bash 4.0+ with no 3.2 fallback. The
# flag cluster can carry other letters in any order (-Ag, -rA, ...); what
# matters is a literal uppercase A appearing in it, so match on that rather
# than the exact string "-A".
FOUND16C="$(awk '{ if ($0 ~ /^[[:space:]]*#/) print ""; else print }' "$BASH32_SCRIPT" \
| grep -nE '(^|[^[:alnum:]_])declare[[:space:]]+-[a-zA-Z]*A[a-zA-Z]*([[:space:]]|$)' || true)"
if [[ -n "$FOUND16C" ]]; then
HAZARDS16+="${BASH32_SCRIPT##*/}:$FOUND16C "
fi
done
if [[ -n "$HAZARDS16" ]]; then
fail "unguarded array expansion(s) abort on bash < 4.4 under set -u: $(echo "$HAZARDS16" | tr '\n' ' ')"