Skip to content

fix: fail loudly when Copilot agent files are not created#3

Open
Lucas-Frazao wants to merge 1 commit into
mainfrom
fix/copilot-setup-validation
Open

fix: fail loudly when Copilot agent files are not created#3
Lucas-Frazao wants to merge 1 commit into
mainfrom
fix/copilot-setup-validation

Conversation

@Lucas-Frazao
Copy link
Copy Markdown
Owner

Problem

hsdd init could complete successfully while the .github/agents/ directory was never created. This happened because CopilotIntegration.setup() silently returned an empty list when it couldn't locate command templates (e.g. due to install path resolution differences between dev/wheel installs, Windows path quirks, or venv isolation).

The result: users run hsdd init, see success, open VS Code, type /hsdd.constitution — and nothing shows up.

Root Cause

_locate_commands_dir() checks two hardcoded paths:

  1. core_pack/commands/ (wheel install)
  2. ../../templates/commands/ relative to __file__ (dev install)

If neither resolves — which can happen with editable installs, symlinked venvs, or certain Windows configurations — list_command_templates() returns [], and setup() returns [] without any warning.

Changes

CopilotIntegration.setup()

  • Raises FileNotFoundError when no command templates are found, with diagnostic info showing which paths were searched.

hsdd init

  • Catches FileNotFoundError from the integration, shows a clear error with remediation steps (hsdd integrate copilot), and exits non-zero.
  • Post-validates that .agent.md files actually exist on disk after setup() returns (defense in depth).

hsdd integrate

  • Same error handling as init.

hsdd check

  • Now reads init-options.json to determine the configured AI assistant.
  • If ai_assistant is copilot but .github/agents/ is missing, flags it as an error (not a skip) with a remediation message.

Tests

  • 9 new tests covering the Copilot integration setup:
    • Agent files created
    • Prompt files created
    • copilot-instructions.md created
    • Correct file extensions
    • Prompt files reference correct agent names
    • Raises on missing templates (the key regression test)
    • Idempotency
    • Constitution agent specifically exists
    • All 10 expected commands present

All 55 tests pass.

Previously, CopilotIntegration.setup() silently returned an empty list
when command templates could not be located (e.g. due to install path
resolution issues). This meant 'hsdd init' could report success while
.github/agents/ was never created, leaving /hsdd.* commands invisible
in Copilot Chat.

Changes:
- CopilotIntegration.setup() now raises FileNotFoundError when no
  command templates are found, with diagnostic paths in the message.
- 'hsdd init' catches the error, reports it clearly, and exits non-zero.
- 'hsdd init' also post-validates that .agent.md files actually exist
  on disk after setup() returns.
- 'hsdd integrate' gets the same error handling.
- 'hsdd check' now reads init-options.json and flags missing agents as
  an error (not a skip) when ai_assistant is 'copilot'.
- Adds 9 tests covering the Copilot integration setup path.

Fixes: silent Copilot integration failure during init
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