#!/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)/validate-provenance.sh" TMPDIR="$(mktemp -d)" # Helper: create a plugin root with plugin.json and an agents/ directory make_plugin() { local root="$1" mkdir -p "$root/agents" echo '{"name":"test-plugin","version":"0.1.0"}' > "$root/plugin.json" } # Helper: create a clean agent pair (no source_keys) make_clean_pair() { local root="$1" local name="${2:-my-agent}" cat > "$root/agents/${name}.md" < "$root/agents/${name}.agent.md" < "$root/agents/${name}.md" < "$root/agents/${name}.agent.md" < "$root/agents/${name}.agent.md" < "$root/sources.md" < "$dir/agents/my-agent.md" < "$root/sources.md" <> "$root/sources.md" run bash "$SCRIPT" "$root/agents/my-agent.md" assert_success } # --------------------------------------------------------------------------- # Check 2: source_keys slug missing from sources.md → FAIL # --------------------------------------------------------------------------- @test "FAIL: source_keys slug in CC file not present as H2 in sources.md" { local root="$TMPDIR/plugin" make_plugin "$root" make_cc_with_source_keys "$root" "my-agent" "my-source" make_copilot_clean "$root" make_sources_md "$root" "different-source" "(none)" "(none)" run bash "$SCRIPT" "$root/agents/my-agent.md" assert_failure assert_output --partial "FAIL" } @test "FAIL: source_keys slug in Copilot file not present as H2 in sources.md" { local root="$TMPDIR/plugin" make_plugin "$root" make_clean_pair "$root" make_copilot_with_source_keys "$root" "my-agent" "my-source" make_sources_md "$root" "different-source" "(none)" "(none)" run bash "$SCRIPT" "$root/agents/my-agent.agent.md" assert_failure assert_output --partial "FAIL" } # --------------------------------------------------------------------------- # Check 4: Contributing file path doesn't exist → FAIL # --------------------------------------------------------------------------- @test "FAIL: Contributing file listed in sources.md does not exist" { local root="$TMPDIR/plugin" make_plugin "$root" make_cc_with_source_keys "$root" make_copilot_with_source_keys "$root" make_sources_md "$root" "my-source" "agents/nonexistent.md" run bash "$SCRIPT" "$root/agents/my-agent.md" assert_failure assert_output --partial "FAIL" } @test "pass: (none) in Contributing files is skipped" { local root="$TMPDIR/plugin" make_plugin "$root" make_cc_with_source_keys "$root" make_copilot_with_source_keys "$root" make_sources_md "$root" "my-source" "(none — not used directly)" run bash "$SCRIPT" "$root/agents/my-agent.md" assert_success } # --------------------------------------------------------------------------- # Check 6: Research doc field missing or placeholder → FAIL # --------------------------------------------------------------------------- @test "FAIL: Research doc field missing from sources.md entry" { local root="$TMPDIR/plugin" make_plugin "$root" make_cc_with_source_keys "$root" make_copilot_with_source_keys "$root" cat > "$root/sources.md" < "$root/sources.md" < "$root/agents/my-agent.md" < "$root/sources.md" <