test(kyberforge): run the instructions-author bats suite on the pinned apm

need_apm now runs apm through scripts/lib/apm.sh, so the suite exercises
the repo-pinned 0.39.3 and never a PATH apm. In this repo a missing uv or
an apm below 0.39.2 fails rather than skips, so run-tests.sh --strict
cannot pass without running these tests. Outside the repo it still falls
back to PATH apm and skips without one.

Three assertions pinned 0.28.0 behaviour and are updated to 0.39.3's:
compile --target claude writes a CLAUDE.md that imports AGENTS.md, an
unquoted applyTo fails install closed and deploys nothing, and compile
warns when applyTo matches no file. The skill's own text still describes
the 0.28.0 behaviour; that is left for a skill update.

Refs: #271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-12-02 08:47:35 +00:00
1 parent 7291b46271
commit 5842be70cc
1 file changed
+31 -9
@@ -28,7 +28,21 @@ fill() {
"$1"
}
# In this repo apm is the one pinned in pyproject.toml/uv.lock, run through
# scripts/lib/apm.sh as `uv run --project <repo root> --frozen apm` (ADR-0034),
# so these tests exercise 0.39.3 and never whatever apm is on PATH. The pin is
# a declared dependency here, so a missing uv or an apm below the helper's
# minimum FAILS rather than skips: a skip would let `run-tests.sh --strict` go
# green without running these tests. Outside this repo (no helper) the PATH
# apm is used, and its absence still skips.
need_apm() {
if [[ -f "$REPO_ROOT/scripts/lib/apm.sh" ]]; then
# shellcheck source=/dev/null
source "$REPO_ROOT/scripts/lib/apm.sh"
require_apm_version || fail "the repo-pinned apm is unavailable; run 'uv sync --frozen' at $REPO_ROOT"
apm() { run_apm "$@"; }
return 0
fi
command -v apm >/dev/null 2>&1 || skip "apm CLI not installed"
}
@@ -173,10 +187,14 @@ need_apm() {
}
# ---------------------------------------------------------------------------
# apm behaviour the skill's gotchas rest on (verified against apm 0.28.0)
# apm behaviour the skill's gotchas rest on. Verified against apm 0.28.0, then
# re-pinned to the repo's 0.39.3 (#271), where three behaviours changed: compile
# --target claude writes a CLAUDE.md that imports AGENTS.md, an unquoted applyTo
# fails install closed, and compile warns when applyTo matches no file. The
# skill's own text still describes 0.28.0 in places; see #271's report.
# ---------------------------------------------------------------------------
@test "filled scaffold compiles for the Claude target into CLAUDE.md without the description" {
@test "filled scaffold compiles for the Claude target: CLAUDE.md imports AGENTS.md, which drops the description" {
need_apm
make_package
bash "$SCRIPT" my-rule "$ROOT"
@@ -185,9 +203,11 @@ need_apm() {
run apm compile --target claude
assert_success
assert [ -f "$ROOT/CLAUDE.md" ]
run grep -F 'Use type hints.' "$ROOT/CLAUDE.md"
run grep -Fx '@AGENTS.md' "$ROOT/CLAUDE.md"
assert_success
run grep -F 'Python style rules' "$ROOT/CLAUDE.md"
run grep -F 'Use type hints.' "$ROOT/AGENTS.md"
assert_success
run grep -F 'Python style rules' "$ROOT/AGENTS.md"
assert_failure
}
@@ -221,17 +241,16 @@ need_apm() {
assert [ ! -f "$ROOT/CLAUDE.md" ]
}
@test "an unquoted applyTo still installs, as a rule with no paths:" {
@test "an unquoted applyTo fails install closed and deploys no rule" {
need_apm
make_package
mkdir -p "$ROOT/.apm/instructions"
printf -- '---\ndescription: x\napplyTo: **/*.py\n---\n# T\n\n- a\n' > "$ROOT/.apm/instructions/bad.instructions.md"
cd "$ROOT"
run apm install
assert_success
assert [ -f "$ROOT/.claude/rules/bad.md" ]
run grep -F 'paths:' "$ROOT/.claude/rules/bad.md"
assert_failure
assert_output --partial "Rejected frontmatter in bad.instructions.md"
assert [ ! -f "$ROOT/.claude/rules/bad.md" ]
}
@test "compile --validate exits 0 and hides the warnings a real compile prints" {
@@ -259,5 +278,8 @@ need_apm() {
assert_success
assert_output --partial "dry-run"
refute_output --partial "Failed to parse"
refute_output --partial "Warning"
# 0.39 warns when applyTo matches no file, which an empty package always
# does; any other warning is a parse or validation finding.
run grep -F "Warning" <<< "$(grep -vF "matched no files" <<< "$output")"
assert_failure
}