Skip to content

fix(BUG-001): correct Copilot verification + gate on extension presence#40

Merged
mlorentedev merged 2 commits into
mainfrom
fix/bug-001-copilot-verify
May 18, 2026
Merged

fix(BUG-001): correct Copilot verification + gate on extension presence#40
mlorentedev merged 2 commits into
mainfrom
fix/bug-001-copilot-verify

Conversation

@mlorentedev
Copy link
Copy Markdown
Owner

Summary

Surfaced 2026-05-17 during AI-011-validation runtime. The setup-linux.sh output printed a contradictory pair on every run:

```
[INFO] Installing GitHub Copilot CLI extension...
❌ Error: Copilot instructions deployment failed verification
[SUCCESS] GitHub Copilot CLI configured
```

Two underlying issues, fixed together (same code block, same scope):

1. Stale verification assertion

The check grepped for the literal `"Engineering Discipline"` in the deployed `copilot-instructions.md`, but that string no longer exists — AI-013 (May 2026) refactored `ai/copilot/copilot-instructions.md` to a pointer-style ≤70-line shim that delegates to canonical `AGENTS.md` at repo root. The deploy succeeds, but the assertion fails on every run.

Replaced with the same pattern that the already-working Claude/Gemini deploys use:

```bash
grep -q 'First, read \`AGENTS.md\`' "$HOME/.copilot/copilot-instructions.md"
```

2. Gating on `gh` is the wrong signal

`gh` (GitHub CLI) is widely used for PR/issue management on machines that have zero interest in Copilot. The old logic ran the entire Copilot block any time `gh` was installed, including the `gh extension install github/gh-copilot` line — installing the extension as a side effect of running setup.

Switched to detect-and-act: deploy the Copilot config only if the `gh-copilot` extension is actually present (`gh extension list | grep github/gh-copilot`). No more auto-installs. If absent, skip the block with an info-level log that includes the install one-liner.

This keeps the project's general philosophy of "try every supported tool opportunistically and warn on missing pieces" — without making the user own a surprise extension install.

Files changed

  • `setup-linux.sh` (lines 427-450 reshape, plus header comment trim)
  • `setup-windows.ps1` (lines 793-821 mirror — gh extension list parsed in PowerShell, same assertion via `Select-String -SimpleMatch`)

Test plan

  • `bash -n setup-linux.sh` + `zsh -n setup-linux.sh` clean
  • `shellcheck setup-linux.sh` — only pre-existing INFO warnings (lines 696, 713, 724) untouched by this PR
  • `bats tests/setup-linux.bats tests/setup-windows.bats` — 90/90 green
  • Non-ASCII check on `setup-windows.ps1` — PSScriptAnalyzer `PSUseBOMForUnicodeEncodedFile` rule respected, all ASCII
  • Manual: re-run `./setup-linux.sh` post-merge → confirm `copilot-instructions.md deployed successfully (verified pointer to AGENTS.md)` line and no `❌` (extension already present on local machine — branch validated)
  • Manual (Windows): when WIN-002 runs, confirm same line and behavior

Cross-links

🤖 Generated with Claude Code

… presence

Two issues fixed together (same code block, both surfaced 2026-05-17
during AI-011-validation):

1. Verification assertion was stale. The check grepped for the literal
   "Engineering Discipline" in the deployed copilot-instructions.md, but
   that string no longer exists -- AI-013 refactored the file to a
   pointer-style ≤70-line shim that delegates to AGENTS.md. The check
   would fail on every run, printing an "❌ Error" line immediately
   followed by "[SUCCESS]". Replaced with the same pattern that
   Claude/Gemini deploys already use: grep for `First, read \`AGENTS.md\``.

2. The block was gated on `gh` being installed, which is the wrong
   signal -- gh is widely used for PR/issue management without any
   Copilot intent. On Linux specifically the user does not use Copilot;
   on Windows it is per-machine. Now gated on the gh-copilot extension
   being actually installed (detect-and-act): if the extension is present
   the config deploys and aliases are wired; if absent the block is
   skipped with an info-level log including the install one-liner.

The Linux script also no longer attempts to `gh extension install
github/gh-copilot` unconditionally -- that decision is the user's. The
detect-and-act pattern lets the script remain "try everything that is
already available, warn on missing pieces" without surprise installs.

Windows side mirrors the same logic via the gh extension list parse.
Verification string updated identically. ASCII-clean (PSScriptAnalyzer
non-ASCII gate respected).

Empirical Windows verification still pending until WIN-002 runs.
verify-setup.bats line 289 asserted `[ -d "$HOME/.copilot" ]`, encoding the
old assumption "if gh is installed, ~/.copilot is unconditionally created".
The PR-40 detect-and-act gate breaks that — the directory is now created
only when the gh-copilot extension is genuinely present. In the integration
container gh is installed (as a dev tool) but gh-copilot is not, so the
directory should NOT exist.

Inverted the assertion + renamed the test + added a comment block linking
the change to the BUG-001 fix and explaining the silent-skip contract.
@mlorentedev mlorentedev merged commit b3163e7 into main May 18, 2026
5 checks passed
@mlorentedev mlorentedev deleted the fix/bug-001-copilot-verify branch May 18, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant