Two related simplification-audit findings, bundled because they edit some of the same skill-audit files and splitting would fragment single-file diffs. Finding 10: delete 48 per-skill/reference README.md files (they restated SKILL.md in narrative form and no agent ever loads them) plus 2 scaffold templates. Drop the README criterion from skill-audit's file-structure.md and finding-criteria.md, and the README-generation step from skill-author's new-skill.sh; update new-skill.bats to match. Plugin-root READMEs are kept intentionally, out of scope. Finding 12: strip historical ADR-0020/ADR-0023 citations and changelog-style narration from model-facing skill content across kyberforge and git plugin skills. Delete skill-author's one-time retrofit.md migration guide and its references. Some ADR-0023 tags were not narration but check-rtk-prefix's required opt-out marker for intentionally-bare git commands -- those were restored, not stripped. Mirror re-synced and full pre-commit/pre-push suite verified green. Refs: SIMPLIFICATION-AUDIT.md findings 10, 12 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YR2CjVumUbEGWcMikcoXBD
210 lines
6.1 KiB
Bash
210 lines
6.1 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
setup() {
|
|
REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../../../../../../" && pwd)"
|
|
load "$REPO_ROOT/tests/test_helper/bats-support/load"
|
|
load "$REPO_ROOT/tests/test_helper/bats-assert/load"
|
|
|
|
SCRIPT="$(cd "$BATS_TEST_DIRNAME/../scripts" && pwd)/new-skill.sh"
|
|
DEST="$(mktemp -d)"
|
|
}
|
|
|
|
teardown() {
|
|
rm -rf "$DEST"
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Passing cases
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@test "--help exits 0" {
|
|
run bash "$SCRIPT" --help
|
|
assert_success
|
|
assert_output --partial "Usage:"
|
|
}
|
|
|
|
@test "creates scaffold directory at destination" {
|
|
run bash "$SCRIPT" my-tool "$DEST"
|
|
assert_success
|
|
assert [ -d "$DEST/my-tool" ]
|
|
}
|
|
|
|
@test "scaffold contains SKILL.md" {
|
|
bash "$SCRIPT" my-tool "$DEST"
|
|
assert [ -f "$DEST/my-tool/SKILL.md" ]
|
|
}
|
|
|
|
@test "scaffold contains scripts/, references/, assets/, tests/ directories" {
|
|
bash "$SCRIPT" my-tool "$DEST"
|
|
assert [ -d "$DEST/my-tool/scripts" ]
|
|
assert [ -d "$DEST/my-tool/references" ]
|
|
assert [ -d "$DEST/my-tool/assets" ]
|
|
assert [ -d "$DEST/my-tool/tests" ]
|
|
}
|
|
|
|
@test "substitutes skill name in SKILL.md" {
|
|
bash "$SCRIPT" my-tool "$DEST"
|
|
run grep "my-tool" "$DEST/my-tool/SKILL.md"
|
|
assert_success
|
|
}
|
|
|
|
@test "substitutes skill name in tests/README.md" {
|
|
bash "$SCRIPT" my-tool "$DEST"
|
|
run grep "my-tool" "$DEST/my-tool/tests/README.md"
|
|
assert_success
|
|
}
|
|
|
|
@test "skill name with numbers is valid" {
|
|
run bash "$SCRIPT" my-tool-2 "$DEST"
|
|
assert_success
|
|
assert [ -d "$DEST/my-tool-2" ]
|
|
}
|
|
|
|
@test "next-steps output references /skill-audit not validate.sh" {
|
|
run bash "$SCRIPT" my-tool "$DEST"
|
|
assert_output --partial "/skill-audit"
|
|
refute_output --partial "validate.sh"
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Failing cases
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@test "fails when no arguments given" {
|
|
run bash "$SCRIPT"
|
|
assert_failure
|
|
}
|
|
|
|
@test "fails when skill name contains uppercase" {
|
|
run bash "$SCRIPT" MyTool "$DEST"
|
|
assert_failure
|
|
}
|
|
|
|
@test "fails when skill name has consecutive hyphens" {
|
|
run bash "$SCRIPT" my--tool "$DEST"
|
|
assert_failure
|
|
}
|
|
|
|
@test "fails when skill name has a leading hyphen" {
|
|
run bash "$SCRIPT" -my-tool "$DEST"
|
|
assert_failure
|
|
}
|
|
|
|
@test "fails when skill name has a trailing hyphen" {
|
|
run bash "$SCRIPT" my-tool- "$DEST"
|
|
assert_failure
|
|
}
|
|
|
|
@test "fails when destination directory does not exist" {
|
|
run bash "$SCRIPT" my-tool "/nonexistent/path"
|
|
assert_failure
|
|
}
|
|
|
|
@test "exits 0 when target already exists (no-op)" {
|
|
mkdir -p "$DEST/my-tool"
|
|
run bash "$SCRIPT" my-tool "$DEST"
|
|
assert_success
|
|
assert_output --partial "nothing to do"
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Mode detection: package vs standalone
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@test "standalone mode is chosen when no apm.yml or .git is found above path" {
|
|
run bash "$SCRIPT" my-tool "$DEST"
|
|
assert_success
|
|
assert_output --partial "Mode: standalone"
|
|
assert [ -d "$DEST/my-tool" ]
|
|
}
|
|
|
|
@test "package mode: writes into <package-root>/.apm/skills/<name>, not under the given subdir" {
|
|
mkdir -p "$DEST/pkg/sub/deep"
|
|
cat > "$DEST/pkg/apm.yml" <<'EOF'
|
|
name: my-pkg
|
|
version: 1.0.0
|
|
type: skill
|
|
EOF
|
|
run bash "$SCRIPT" my-tool "$DEST/pkg/sub/deep"
|
|
assert_success
|
|
assert_output --partial "Mode: package"
|
|
assert [ -d "$DEST/pkg/.apm/skills/my-tool" ]
|
|
assert [ ! -d "$DEST/pkg/sub/deep/my-tool" ]
|
|
}
|
|
|
|
@test "package mode scaffold contains SKILL.md with name substituted" {
|
|
mkdir -p "$DEST/pkg"
|
|
cat > "$DEST/pkg/apm.yml" <<'EOF'
|
|
name: my-pkg
|
|
version: 1.0.0
|
|
type: hybrid
|
|
EOF
|
|
bash "$SCRIPT" my-tool "$DEST/pkg"
|
|
assert [ -f "$DEST/pkg/.apm/skills/my-tool/SKILL.md" ]
|
|
run grep "my-tool" "$DEST/pkg/.apm/skills/my-tool/SKILL.md"
|
|
assert_success
|
|
}
|
|
|
|
@test "scaffold emits a live metadata.version seeded at 0.1.0 (ADR-0022)" {
|
|
# The scaffold must clear .pre-commit-config.yaml's `skill-frontmatter` hook
|
|
# on its first commit: a commented-out metadata block ships a skill with no
|
|
# version and is blocked. Assert the field is live, not a comment.
|
|
bash "$SCRIPT" my-tool "$DEST"
|
|
run grep -E '^metadata:$' "$DEST/my-tool/SKILL.md"
|
|
assert_success
|
|
run grep -E '^ version: "[0-9]+\.[0-9]+\.[0-9]+"$' "$DEST/my-tool/SKILL.md"
|
|
assert_success
|
|
assert_output --partial '0.1.0'
|
|
}
|
|
|
|
@test "walk-up skips a type-less apm.yml (marketplace-only) and finds a real package root further up" {
|
|
mkdir -p "$DEST/mid/sub"
|
|
cat > "$DEST/apm.yml" <<'EOF'
|
|
name: root-pkg
|
|
version: 1.0.0
|
|
type: skill
|
|
EOF
|
|
cat > "$DEST/mid/apm.yml" <<'EOF'
|
|
marketplace:
|
|
owner: acme
|
|
packages: []
|
|
EOF
|
|
run bash "$SCRIPT" my-tool "$DEST/mid/sub"
|
|
assert_success
|
|
assert_output --partial "Mode: package"
|
|
assert [ -d "$DEST/.apm/skills/my-tool" ]
|
|
assert [ ! -d "$DEST/mid/.apm" ]
|
|
}
|
|
|
|
@test "walk-up stops at .git boundary and uses standalone mode at the given path" {
|
|
mkdir -p "$DEST/repo/.git"
|
|
mkdir -p "$DEST/repo/sub"
|
|
run bash "$SCRIPT" my-tool "$DEST/repo/sub"
|
|
assert_success
|
|
assert_output --partial "Mode: standalone"
|
|
assert [ -d "$DEST/repo/sub/my-tool" ]
|
|
assert [ ! -d "$DEST/repo/my-tool" ]
|
|
}
|
|
|
|
@test "package mode: matched-quote type value ('skill') is recognized" {
|
|
mkdir -p "$DEST/pkg"
|
|
printf 'name: my-pkg\ntype: "skill"\n' > "$DEST/pkg/apm.yml"
|
|
run bash "$SCRIPT" my-tool "$DEST/pkg"
|
|
assert_success
|
|
assert_output --partial "Mode: package"
|
|
}
|
|
|
|
@test "mismatched-quote type value is rejected, falls through to standalone mode" {
|
|
printf "name: my-pkg\ntype: \"skill'\n" > "$DEST/apm.yml"
|
|
run bash "$SCRIPT" my-tool "$DEST"
|
|
assert_success
|
|
assert_output --partial "Mode: standalone"
|
|
}
|
|
|
|
@test "type: line is recognized even without a trailing newline on apm.yml" {
|
|
printf 'name: my-pkg\ntype: skill' > "$DEST/apm.yml"
|
|
run bash "$SCRIPT" my-tool "$DEST"
|
|
assert_success
|
|
assert_output --partial "Mode: package"
|
|
}
|