From e02b6cfed298308802aa5e4e0cbd5cb57d66124e Mon Sep 17 00:00:00 2001 From: Julian lechner Date: Wed, 16 Sep 2026 16:04:35 +0200 Subject: [PATCH] test: cover embedded general.md dedup and split-rule reference files Co-Authored-By: Claude Sonnet 5 --- scripts/test-platform-packages.ps1 | 10 ++++++++++ scripts/test-platform-packages.sh | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/scripts/test-platform-packages.ps1 b/scripts/test-platform-packages.ps1 index 543ec5e..e5e2186 100644 --- a/scripts/test-platform-packages.ps1 +++ b/scripts/test-platform-packages.ps1 @@ -5,6 +5,8 @@ $bashHook = Get-Content -LiteralPath (Join-Path $root 'shared/hooks/flashbang.sh if ($powerShellHook -notmatch '\$HoldMs\s*=\s*250' -or $powerShellHook -notmatch '\$FadeMs\s*=\s*250' -or ([regex]::Matches($bashHook, 'default=250').Count -lt 2)) { throw 'Flashbang defaults must total 500 milliseconds on Windows and Linux.' } $statusInput = '{"model":{"display_name":"Test Model"},"effort":{"level":"high"},"workspace":{"current_dir":"' + $root.Replace('\','\\') + '","repo":{"name":"TestRepo"}},"context_window":{"context_window_size":200000,"used_percentage":8.5,"total_input_tokens":15500,"total_output_tokens":1200}}' $branch = & git -C $root branch --show-current +$buildSummaryOutput = & (Join-Path $root 'scripts/build.ps1') -Summary +if (@($buildSummaryOutput | Where-Object { $_ -eq 'PASS build: codex-windows, claude-windows, codex-linux, claude-linux' }).Count -ne 1) { throw "build.ps1 -Summary must still print the PASS line: $($buildSummaryOutput -join '; ')" } $statusOutput = ($statusInput | & (Join-Path $root 'shared/statusline/statusline.ps1')) -join "`n" $plainStatusOutput = [regex]::Replace($statusOutput, [char]27 + '\[[0-9;]*m', '') $expectedStatusOutput = "Test Model $([char]0x00B7) high`nTestRepo on $branch $([char]0x00B7) 9% ctx (16.7k tok)" @@ -36,6 +38,14 @@ foreach ($platform in @('windows','linux')) { } elseif (-not (Test-Path -LiteralPath (Join-Path $package "statusline/statusline.$(if ($platform -eq 'windows') { 'ps1' } else { 'sh' })")) -or $settings.statusLine.command -notmatch "statusline\.$(if ($platform -eq 'windows') { 'ps1' } else { 'sh' })") { throw "Claude status line is incorrect in $package" } + $docFile = if ($client -eq 'codex') { 'AGENTS.md' } else { 'CLAUDE.md' } + $docContent = Get-Content -LiteralPath (Join-Path $package $docFile) -Raw + if (([regex]::Matches($docContent, [regex]::Escape('Apply instructions in this order'))).Count -ne 1) { throw "$client-$platform must embed the priority rule exactly once" } + if ($client -eq 'codex' -and $docContent -match 'Always load and apply `rules/general\.md`') { throw "$package must not still instruct loading general.md by path" } + foreach ($splitRule in @('angular','wpf','ui-ux')) { + $referencesDir = if ($client -eq 'codex') { Join-Path $package "rules/$splitRule/references" } else { Join-Path $package "skills/rules/rules-$splitRule/references" } + if (-not (Test-Path $referencesDir) -or (Get-ChildItem $referencesDir -Filter '*.md').Count -eq 0) { throw "$package is missing reference files for $splitRule" } + } } } foreach ($platformSelection in @('1','2')) { diff --git a/scripts/test-platform-packages.sh b/scripts/test-platform-packages.sh index c510bc3..295fa24 100755 --- a/scripts/test-platform-packages.sh +++ b/scripts/test-platform-packages.sh @@ -5,6 +5,11 @@ grep -Eq '\$HoldMs[[:space:]]*=[[:space:]]*250' "$root/shared/hooks/flashbang.ps grep -Eq '\$FadeMs[[:space:]]*=[[:space:]]*250' "$root/shared/hooks/flashbang.ps1" [ "$(grep -c 'default=250' "$root/shared/hooks/flashbang.sh")" -ge 2 ] branch=$(git -C "$root" branch --show-current) +build_summary_output=$(bash "$root/scripts/build.sh" --summary) +if ! printf '%s\n' "$build_summary_output" | grep -qx 'PASS build: codex-windows, claude-windows, codex-linux, claude-linux'; then + printf 'build.sh --summary must still print the PASS line: %s\n' "$build_summary_output" >&2 + exit 1 +fi status_output=$(printf '{"model":{"display_name":"Test Model"},"effort":{"level":"high"},"workspace":{"current_dir":"%s","repo":{"name":"TestRepo"}},"context_window":{"context_window_size":200000,"used_percentage":8.5,"total_input_tokens":15500,"total_output_tokens":1200}}' "$root" | bash "$root/shared/statusline/statusline.sh") plain_status_output=$(printf '%s' "$status_output" | sed -E $'s/\x1b\\[[0-9;]*m//g') expected_status_output=$'Test Model \xc2\xb7 high\nTestRepo on '"$branch"$' \xc2\xb7 9% ctx (16.7k tok)' @@ -45,6 +50,26 @@ for platform in windows linux; do grep -q "statusline.$statusline_extension" "$package/$file" fi if grep -Eq '__HOOK_|__WINDOWS_HOOK_' "$package/$file"; then exit 1; fi + doc_file=AGENTS.md + [ "$client" != claude ] || doc_file=CLAUDE.md + doc_content=$(cat "$package/$doc_file") + occurrences=$(printf '%s' "$doc_content" | grep -o 'Apply instructions in this order' | wc -l) + [ "$occurrences" -eq 1 ] || { printf '%s-%s must embed the priority rule exactly once\n' "$client" "$platform" >&2; exit 1; } + if [ "$client" = codex ] && printf '%s' "$doc_content" | grep -q 'Always load and apply `rules/general\.md`'; then + printf '%s must not still instruct loading general.md by path\n' "$package" >&2 + exit 1 + fi + for split_rule in angular wpf ui-ux; do + if [ "$client" = codex ]; then + references_dir="$package/rules/$split_rule/references" + else + references_dir="$package/skills/rules/rules-$split_rule/references" + fi + if [ ! -d "$references_dir" ] || [ -z "$(find "$references_dir" -maxdepth 1 -name '*.md' -print -quit)" ]; then + printf '%s is missing reference files for %s\n' "$package" "$split_rule" >&2 + exit 1 + fi + done done done for platform_selection in 1 2; do