Skip to content

fix: require Copilot-specific markers for .github/ auto-detection#1069

Open
Giggitycountless wants to merge 4 commits intomicrosoft:mainfrom
Giggitycountless:fix/github-copilot-detection
Open

fix: require Copilot-specific markers for .github/ auto-detection#1069
Giggitycountless wants to merge 4 commits intomicrosoft:mainfrom
Giggitycountless:fix/github-copilot-detection

Conversation

@Giggitycountless
Copy link
Copy Markdown

Description

Previously, the mere existence of a .github/ directory was used to infer the project uses GitHub Copilot. This is too broad — nearly every repo has .github/ for CI workflows, CODEOWNERS, issue templates, etc. A Cursor user with standard CI would get skills installed to .github/skills/ instead of .cursor/.

Fix

.github/ is now only detected as a Copilot target when it contains Copilot-specific markers:

  • .github/copilot-instructions.md
  • .github/skills/
  • .github/agents/
  • .github/prompts/

A bare .github/ with only workflows/CODEOWNERS is no longer treated as a Copilot signal.

Changes

  • src/apm_cli/core/target_detection.py — Replace .github existence check with Copilot marker detection
  • tests/unit/core/test_target_detection.py — Update existing tests to use Copilot markers, add new test verifying bare .github/ falls through to minimal

Fixes #805

How Has This Been Tested?

  • All 91 existing tests pass
  • New test test_auto_detect_bare_github_no_copilot_markers verifies bare .github/workflows/ does NOT trigger Copilot detection

Checklist

  • I have read the Contributing Guide
  • My changes follow the established code style
  • I have added tests that prove my fix is effective

Previously, the mere existence of a .github/ directory was used to
infer the project uses GitHub Copilot. This is too broad — nearly
every repo has .github/ for CI workflows, CODEOWNERS, issue templates,
etc. A Cursor user with standard CI would get skills installed to
.github/skills/ instead of .cursor/.

Now .github/ is only detected as a Copilot target when it contains
Copilot-specific markers:
- .github/copilot-instructions.md
- .github/skills/
- .github/agents/
- .github/prompts/

Fixes microsoft#805
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Tightens APM's target auto-detection so a repo is only treated as a GitHub Copilot (VS Code) integration target when .github/ contains Copilot-specific markers, avoiding false positives for repos that only use .github/ for CI/workflows.

Changes:

  • Updated detect_target() to require specific Copilot markers under .github/ rather than treating .github/ existence alone as a Copilot signal.
  • Updated unit tests to create Copilot marker folders for .github/ detection and added a new test ensuring a bare .github/workflows/ falls through to minimal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/apm_cli/core/target_detection.py Replaces .github existence check with a Copilot marker-based check for VS Code/Copilot auto-detection.
tests/unit/core/test_target_detection.py Updates existing detection tests to use markers and adds coverage for the “bare .github” case.

Comment thread src/apm_cli/core/target_detection.py Outdated
Comment on lines +113 to +123
# For .github/, require Copilot-specific markers (not just CI workflows).
# A bare .github/ with only workflows/CODEOWNERS/etc. is NOT a Copilot signal.
github_copilot_markers = [
".github/copilot-instructions.md",
".github/skills",
".github/agents",
".github/prompts",
]
github_exists = any(
(project_root / marker).exists() for marker in github_copilot_markers
)
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detect_target() now treats .github/ as present only if one of the listed markers exists, but the marker set looks incomplete relative to the repo's own Copilot/VS Code integration surface. In particular, APM supports .github/instructions/ (and also .github/hooks/, plus legacy .github/chatmodes/) as first-class Copilot integration directories, so projects that only have modular instructions (or hooks) will now fall through to minimal and skip Copilot integration.

Consider expanding the marker list to include the other Copilot-specific subdirectories APM reads/writes (at least .github/instructions, and likely .github/hooks / .github/chatmodes) so auto-detection doesn't regress for those setups.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! ✅ Fixed: added , , and to the marker list. APM reads/writes to all of these directories for Copilot integration, so they should all trigger auto-detection.

Comment on lines +113 to +115
# For .github/, require Copilot-specific markers (not just CI workflows).
# A bare .github/ with only workflows/CODEOWNERS/etc. is NOT a Copilot signal.
github_copilot_markers = [
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change updates the semantics of VS Code/Copilot auto-detection (a bare .github/ should no longer trigger Copilot), but several docs pages still state that detection is based on .github/ directory existence alone (e.g. docs/src/content/docs/introduction/how-it-works.md, docs/src/content/docs/reference/cli-commands.md auto-detection table, and docs/src/content/docs/integrations/ide-tool-integration.md). Please update the docs to reflect the new "Copilot-specific markers" requirement, otherwise the documented behavior will be wrong for users.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! ✅ Updated all three docs pages:

  1. how-it-works.md: Changed 'falling back to ' to 'falling back to minimal (AGENTS.md only)' and added note about marker-based detection
  2. cli-commands.md: Updated VSCode integration description to mention Copilot-specific markers
  3. ide-tool-integration.md: Updated auto-detection callout to explain marker requirement and that bare with only CI workflows won't trigger detection


assert target == "minimal"
assert reason == REASON_NO_TARGET_FOLDER
assert "no target folder found" in reason
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In test_auto_detect_bare_github_no_copilot_markers, reason is asserted equal to REASON_NO_TARGET_FOLDER and then also asserted to contain the same literal substring. The second assertion is redundant once equality is checked, and it makes future reason-message refactors noisier. Consider keeping only the constant-equality assertion (or only the substring assertion, but prefer the exported constant).

Suggested change
assert "no target folder found" in reason

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! ✅ Removed the redundant substring assertion. The constant-equality check is sufficient and cleaner.

- Add .github/instructions, .github/hooks, .github/chatmodes to
  Copilot-specific marker list per Copilot review feedback
- Update 3 docs pages to reflect marker-based .github/ detection:
  - how-it-works.md: clarify fallback to minimal, not .github/
  - cli-commands.md: update VSCode integration detection description
  - ide-tool-integration.md: document marker requirement explicitly
- Remove redundant substring assertion in bare-github test
- Add 3 new tests for instructions/hooks/chatmodes markers

Addresses Copilot review comments on microsoft#1069
danielmeppiel and others added 2 commits May 2, 2026 16:53
- tests/unit/core/test_target_detection.py: rename unused 'reason' to
  '_reason' in test_auto_detect_neither_folder (RUF059).
- src/apm_cli/core/target_detection.py: collapse multi-line generator
  expression to satisfy 'ruff format'.

Verification:
  uv run --extra dev ruff check src/ tests/         -> All checks passed!
  uv run --extra dev ruff format --check src/ tests/ -> 623 files already formatted
  uv run --extra dev pytest tests/unit/core/test_target_detection.py
                                                    -> 101 passed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Copy link
Copy Markdown
Collaborator

DevX UX Analysis -- detection signal design

Pushed lint fix (7ad1d44) -- RUF059 unused reason + ruff format collapse. CI should be green now.

Beyond the lint, raised the maintainer's parity question with our devx-ux-expert lens. Summary of the analysis (full critique kept locally; verdict + concrete asks below).

Verdict on the marker-list approach

Ship with adjustments. The PR fixes the reported bug (#805) and is directionally correct. Two real UX issues to address before merge.

Issue 1 -- the marker list is over-broad

Six of the seven markers (skills, agents, prompts, instructions, hooks, chatmodes) are directories APM ITSELF creates. They only exist after first apm install --target copilot. So the auto-detect mostly serves the steady-state case; first-time Copilot users still need the explicit flag.

The clean parity story: .github/copilot-instructions.md is the single Copilot-native pre-APM marker (GitHub's own docs tell users to create it; many Copilot repos already have it). That gives true parity:

Tool Detection signal
Claude .claude/ (tool's namespace)
Cursor .cursor/ (tool's namespace)
OpenCode .opencode/ (tool's namespace)
Copilot .github/copilot-instructions.md (Copilot's own canonical file)

Each is a marker that the TOOL itself owns, not one APM creates.

Concrete proposal: trim the marker list to .github/copilot-instructions.md only. Keep the other directories as functional install targets, but they're not detection signals -- they're APM artifacts. (If we want a belt-and-suspenders signal, prompts/ and agents/ are also Copilot-native; skills/, instructions/, hooks/, chatmodes/ are not, drop those from detect.)

Issue 2 -- the fallback hint is now wrong

After this PR, commands/compile/cli.py:501-505 and target_detection.py:253 still say:

Create .github/, .claude/, .codex/, .opencode/ or .cursor/ folder for full integration

But after this PR, creating a bare .github/ will not trigger detection. Following that hint is a trap.

Concrete fix: when minimal is selected AND .github/ exists (bare, no markers), emit a targeted hint:

[i] .github/ detected but no Copilot markers found.
    Use --target copilot to enable Copilot integration.

Mirrors the gh CLI pattern: when there's ambiguity, name it and give the user a one-copy-paste action. Don't silently degrade; narrate the decision.

Generic hint should also change from "create .github/" to either "Create .github/copilot-instructions.md for Copilot, ..." or "Use --target copilot to enable Copilot integration".

What's good

  • Test coverage is solid; new test_auto_detect_bare_github_no_copilot_markers is exactly the regression we want.
  • Docs updated in the same PR (ide-tool-integration.md, how-it-works.md, cli-commands.md) -- thorough.
  • .gitignore-style narrowing is the right INSTINCT vs. blanket detection.

Asks before merge

  1. Trim the marker list (keep .github/copilot-instructions.md; optionally prompts, agents; drop the rest from detection). The other directories remain valid install targets, just not detection signals.
  2. Update the in-code hint strings (commands/compile/cli.py:501-505 + target_detection.py:253) so they match the new detection behavior.
  3. Add the targeted "bare .github/ -> use --target copilot" hint when minimal is chosen and .github/ exists. One log line, no new flag.

Happy to fold (1)-(3) into a follow-up commit on this branch if you'd prefer not to bounce it back -- LMK.

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.

[BUG] the .github/ directory as a signal for auto-detecting AI agent isn't ideal

3 participants