From ae88e8b78e5c7a41aabc2073cf9114be95a1831c Mon Sep 17 00:00:00 2001 From: Manu Lorente Date: Mon, 18 May 2026 11:00:46 -0600 Subject: [PATCH] fix(setup-windows): use AGENTS.md pointer marker for CLAUDE/GEMINI verify The post-deploy verification for CLAUDE.md and GEMINI.md was still grepping for the legacy 'CORE PRINCIPLE' string. After AI-013 refactored both files to pointer-style (delegating to AGENTS.md as canonical SSOT), that string no longer exists in either deployed file, so every setup-windows.ps1 run emitted two spurious [ERROR] lines despite the actual copy succeeding. Mirror the fix already applied to the Copilot verification in PR #40 (BUG-001): use 'First, read `AGENTS.md`' as the pointer marker, with -SimpleMatch to treat the backtick-bearing pattern as a literal string. setup-linux.sh already uses this convention for all three AI configs (lines 297/335/514) -- this closes the cross-platform parity gap. Regression guard: three new bats parity asserts in tests/setup-windows.bats locking in the marker, plus a negative assert that catches any future 'CORE PRINCIPLE' Select-String pattern from sneaking back in. Found during empirical re-run of setup-windows.ps1 on 2026-05-18 while validating the WIN-003 SessionStart hook self-heal (PR #21). --- setup-windows.ps1 | 12 ++++++------ tests/setup-windows.bats | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/setup-windows.ps1 b/setup-windows.ps1 index 4591dc4..d9f6880 100644 --- a/setup-windows.ps1 +++ b/setup-windows.ps1 @@ -139,10 +139,10 @@ if (Test-Path $claudeSource) { $claudeMdSource = "$DotfilesDir\ai\claude\CLAUDE.md" if (Test-Path $claudeMdSource) { Copy-Item $claudeMdSource "$ClaudeHome\" -Force - if (Select-String -Path "$ClaudeHome\CLAUDE.md" -Pattern "CORE PRINCIPLE" -Quiet) { - Write-Success "CLAUDE.md deployed successfully (verified)" + if (Select-String -Path "$ClaudeHome\CLAUDE.md" -Pattern 'First, read `AGENTS.md`' -SimpleMatch -Quiet) { + Write-Success "CLAUDE.md deployed successfully (verified pointer to AGENTS.md)" } else { - Write-Err "CLAUDE.md deployment failed verification" + Write-Err "CLAUDE.md deployment failed verification (expected pointer to AGENTS.md)" } } else { Write-Warn "CLAUDE.md not found at $claudeMdSource" @@ -463,10 +463,10 @@ if (Test-Path $geminiSource) { $geminiMdSource = "$DotfilesDir\ai\gemini\GEMINI.md" if (Test-Path $geminiMdSource) { Copy-Item $geminiMdSource "$GeminiHome\" -Force - if (Select-String -Path "$GeminiHome\GEMINI.md" -Pattern "CORE PRINCIPLE" -Quiet) { - Write-Success "GEMINI.md deployed successfully (verified)" + if (Select-String -Path "$GeminiHome\GEMINI.md" -Pattern 'First, read `AGENTS.md`' -SimpleMatch -Quiet) { + Write-Success "GEMINI.md deployed successfully (verified pointer to AGENTS.md)" } else { - Write-Err "GEMINI.md deployment failed verification" + Write-Err "GEMINI.md deployment failed verification (expected pointer to AGENTS.md)" } } else { Write-Warn "GEMINI.md not found at $geminiMdSource" diff --git a/tests/setup-windows.bats b/tests/setup-windows.bats index eecdfe2..7743bcb 100644 --- a/tests/setup-windows.bats +++ b/tests/setup-windows.bats @@ -222,6 +222,29 @@ setup() { grep -q 'ajeetdsouza.zoxide' "$PS1_SCRIPT" } +# --- Cross-platform parity: AI config deploy verification --- +# AI-013 refactored CLAUDE.md/GEMINI.md/copilot-instructions.md to pointer-style +# files starting with 'First, read `AGENTS.md`'. The old marker 'CORE PRINCIPLE' +# no longer exists in any deployed file. setup-linux.sh was updated; this guard +# keeps setup-windows.ps1 in lockstep (regression class: BUG-001 + BUG-002). + +@test "parity: both scripts verify CLAUDE.md deploy with AGENTS.md pointer marker" { + grep -qF "grep -q 'First, read \`AGENTS.md\`' \"\$HOME/.claude/CLAUDE.md\"" "$DOTFILES_DIR/setup-linux.sh" + grep -qF "Select-String -Path \"\$ClaudeHome\\CLAUDE.md\" -Pattern 'First, read \`AGENTS.md\`'" "$PS1_SCRIPT" +} + +@test "parity: both scripts verify GEMINI.md deploy with AGENTS.md pointer marker" { + grep -qF "grep -q 'First, read \`AGENTS.md\`' \"\$HOME/.gemini/GEMINI.md\"" "$DOTFILES_DIR/setup-linux.sh" + grep -qF "Select-String -Path \"\$GeminiHome\\GEMINI.md\" -Pattern 'First, read \`AGENTS.md\`'" "$PS1_SCRIPT" +} + +@test "setup-windows.ps1 has no stale 'CORE PRINCIPLE' verify-pattern references" { + # AGENTS.md itself may mention 'CORE PRINCIPLE' as documentation text -- that + # is fine. The bug is using it as a Select-String -Pattern, which post-AI-013 + # never matches the deployed file and emits a spurious [ERROR] every run. + ! grep -qF -- '-Pattern "CORE PRINCIPLE"' "$PS1_SCRIPT" +} + # --- PSScriptAnalyzer --- @test "setup-windows.ps1 passes PSScriptAnalyzer (if pwsh available)" {