Feature: Accurate Copilot CLI Installation Reporting¶
Clear and accurate installation status reporting for GitHub Copilot CLI.
Overview¶
The amplihack copilot command now correctly reports installation success or failure with accurate messaging and appropriate exit codes. No more confusing false negatives when installation completes successfully.
What Changed¶
Before (Buggy Behavior):
$ amplihack copilot
Installing Copilot CLI...
Failed to install Copilot CLI # FALSE NEGATIVE - installation worked!
[Exit code 1]
After (Fixed):
$ amplihack copilot
Installing Copilot CLI...
Successfully installed Copilot CLI # Accurate status
[Copilot CLI launches normally]
[Exit code 0]
Benefits¶
- Clear feedback: Users know immediately if installation succeeded or failed
- Correct exit codes: CI/CD scripts can rely on exit codes (0 = success, 1 = failure)
- No confusion: No more "failed" messages when installation worked
- Reliable automation: Scripts can detect actual failures vs. false negatives
Use Cases¶
Fresh Installation¶
First-time users installing Copilot CLI:
$ which github-copilot-cli
# (no output - not installed)
$ amplihack copilot
Installing Copilot CLI...
Successfully installed Copilot CLI
Welcome to GitHub Copilot CLI...
CI/CD Integration¶
Automated environments can trust the exit code:
Troubleshooting¶
Clear messaging helps diagnose real installation failures:
# If npm install fails (network issue, permissions, etc)
$ amplihack copilot
Installing Copilot CLI...
Failed to install Copilot CLI
[Exit code 1]
# User can check npm logs for actual error
$ npm install -g github-copilot-cli
npm ERR! network request failed...
Technical Details¶
Installation Verification¶
The fix simplifies installation verification:
- Check if already installed:
shutil.which("copilot") - Install if needed:
npm install -g @github/copilot - Trust npm exit code: 0 = success, non-zero = failure
- Report status accurately: Based on installation result
Why the Bug Happened¶
The original code performed redundant verification:
# Install Copilot CLI
success = install_copilot() # npm returns success
# Redundant check (race condition)
if not shutil.which("copilot"):
# PATH hasn't propagated yet - FALSE NEGATIVE!
print("Failed to install...")
The redundant check failed due to PATH propagation timing - the binary was installed but not yet visible in the current process's PATH.
The Fix¶
Trust the installer's return value instead of re-checking:
# Install Copilot CLI
success = install_copilot() # Validates via npm exit code
# Trust the result
if not success:
print("Failed to install Copilot CLI")
sys.exit(1)
print("Successfully installed Copilot CLI")
Current runtime note¶
The current supported binary is copilot, not github-copilot-cli. The older
name remains in this document only as historical context for the original bug.
Migration¶
No migration required. The fix is backward compatible:
- Existing installations continue working (no reinstall needed)
- Fresh installations now report correctly
- Scripts relying on exit codes now get accurate signals
Testing¶
Manual Testing¶
Test on a fresh system:
# Ensure Copilot CLI not installed
npm uninstall -g github-copilot-cli
# Test installation
amplihack copilot
# Verify success message and CLI launch
# Exit code should be 0
echo $?
Automated Testing¶
Unit tests verify correct behavior:
def test_launch_copilot_installs_when_missing():
"""Installation triggers when CLI not found."""
with patch('shutil.which', return_value=None), \
patch('amplihack.launcher.install_copilot', return_value=True):
launch_copilot() # Should succeed
def test_launch_copilot_reports_install_failure():
"""Failure reported when installation fails."""
with patch('shutil.which', return_value=None), \
patch('amplihack.launcher.install_copilot', return_value=False):
with pytest.raises(SystemExit) as exc:
launch_copilot()
assert exc.value.code == 1 # Should exit with error
Troubleshooting¶
If you see installation failures:
- Check npm: Ensure npm is installed and accessible
- Check permissions: Global npm installs require write access
- Check network: npm needs to download packages
- Check logs: Run
npm install -g github-copilot-clidirectly
See Copilot Installation Troubleshooting for detailed solutions.
Related Features¶
- Copilot CLI Integration - Complete Copilot support
- Interactive Installation - Full setup wizard
Version History¶
- v0.3.2: Fixed false negative installation reporting
- v0.3.1: Initial Copilot CLI integration
Feature Added: v0.3.1 (January 2025) Bug Fixed: v0.3.2 (February 2025) Status: Production-ready