Skip to content

fix: treat .github/-only auto-detection as ambiguous#1115

Open
Giggitycountless wants to merge 1 commit intomicrosoft:mainfrom
Giggitycountless:fix/ambiguous-github-auto-detect
Open

fix: treat .github/-only auto-detection as ambiguous#1115
Giggitycountless wants to merge 1 commit intomicrosoft:mainfrom
Giggitycountless:fix/ambiguous-github-auto-detect

Conversation

@Giggitycountless
Copy link
Copy Markdown

Description

Previously, detect_target() returned "vscode" when only .github/ existed, assuming the project uses GitHub Copilot. This is unreliable — nearly every repo has .github/ for CI workflows, issue templates, CODEOWNERS, etc. A Cursor or Codex user with standard CI would be misdetected as Copilot.

This PR changes .github/-only detection to return "minimal" with an actionable reason that guides users to set their target explicitly.

Changes

  • src/apm_cli/core/target_detection.py:
    • .github/ only → returns "minimal" with REASON_AMBIGUOUS_GITHUB instead of "vscode"
    • Added REASON_AMBIGUOUS_GITHUB constant with guidance text
    • Updated module docstring to reflect new behavior
  • tests/unit/core/test_target_detection.py:
    • Updated test_auto_detect_github_only to expect "minimal" + ambiguous reason
    • Added TestDetectTargetAmbiguousGithub class with 7 tests:
      • .github/ only returns minimal
      • Reason message guides user to set target
      • Explicit --target copilot still wins over ambiguous detection
      • Config target: copilot still wins over ambiguous detection
      • .github/ + .claude/ still returns all
      • .github/ + .cursor/ still returns all
      • REASON_AMBIGUOUS_GITHUB constant is importable

Design rationale

The maintainer feedback on #1069 was clear: instead of improving the "guess" logic, guide users to declare their target explicitly via apm.yml (target: copilot) or --target copilot. This change implements that guidance by treating .github/ alone as ambiguous and surfacing a helpful message.

Fixes #805

…opilot

Previously, auto-detection returned 'vscode' when only .github/ existed.
This is unreliable — nearly every repo has .github/ for CI workflows,
issue templates, and CODEOWNERS, leading to Copilot being inferred for
Cursor, Codex, and other non-Copilot users.

Now returns 'minimal' with a reason that guides users to declare their
target explicitly via apm.yml or --target flag.

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

This PR updates target auto-detection so a repo with only .github/ is treated as ambiguous instead of implicitly assuming GitHub Copilot. That fits the CLI's detection layer by making fallback behavior safer and pushing users toward an explicit target: or --target when .github/ alone is not a reliable signal.

Changes:

  • Change detect_target() so .github/ alone returns minimal with an ambiguity reason instead of vscode.
  • Expand unit coverage around ambiguous .github/ detection and precedence of explicit/configured targets.
  • Add a new tracked .codex/config.toml file with MCP server configuration.

Reviewed changes

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

File Description
src/apm_cli/core/target_detection.py Changes .github/-only auto-detection and adds a new exported reason constant.
tests/unit/core/test_target_detection.py Updates existing expectations and adds focused tests for ambiguous .github/ handling.
.codex/config.toml Adds project-scoped Codex MCP configuration entries to the repository.

Comment thread .codex/config.toml
Comment on lines +16 to +22
[mcp_servers.github-mcp-server.env]
GITHUB_PERSONAL_ACCESS_TOKEN = "ghp_token_123"
GITHUB_TOOLSETS = "context"
GITHUB_DYNAMIC_TOOLSETS = "1"

[mcp_servers.notion-mcp-server.env]
NOTION_TOKEN = "secret_notion_token_67890"
Comment thread .codex/config.toml

[mcp_servers.notion-mcp-server]
command = "npx"
args = [ "-y", "@notionhq/notion-mcp-server@1.8.1", "--transport", "stdio", "--port", "3000", "secret_notion_token_67890",]
Comment thread .codex/config.toml
Comment on lines +1 to +25
[mcp_servers.github-mcp-server]
command = "docker"
args = [ "run", "-i", "--rm", "-e", "GITHUB_DYNAMIC_TOOLSETS", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "-e", "GITHUB_TOOLSETS", "ghcr.io/github/github-mcp-server",]
id = "ab12cd34-5678-90ef-1234-567890abcdef"

[mcp_servers.notion-mcp-server]
command = "npx"
args = [ "-y", "@notionhq/notion-mcp-server@1.8.1", "--transport", "stdio", "--port", "3000", "secret_notion_token_67890",]
id = "8b9c1d20-2345-6789-abcd-ef0123456789"

[mcp_servers.test-docker-server]
command = "docker"
args = [ "run", "-i", "--rm", "example/test-server", "--verbose", "--config", "-e", "TEST_TOKEN", "/app/config.json",]
id = "test-docker-with-pkg-args"

[mcp_servers.github-mcp-server.env]
GITHUB_PERSONAL_ACCESS_TOKEN = "ghp_token_123"
GITHUB_TOOLSETS = "context"
GITHUB_DYNAMIC_TOOLSETS = "1"

[mcp_servers.notion-mcp-server.env]
NOTION_TOKEN = "secret_notion_token_67890"

[mcp_servers.test-docker-server.env]
TEST_TOKEN = "test_token_value"
Comment on lines +11 to +12
- .github/ only -> minimal (ambiguous; .github/ is too common for CI
to reliably infer Copilot — user should set target explicitly)
Comment on lines +199 to +202
# .github/ alone is too ambiguous to infer Copilot — most repos have
# it for CI workflows, issue templates, CODEOWNERS, etc. Return
# minimal so the user is prompted to set target explicitly.
return "minimal", REASON_AMBIGUOUS_GITHUB
# no explicit or config target is set. .github/ is too common (CI workflows,
# issue templates, CODEOWNERS) to reliably infer Copilot usage — treat it as
# ambiguous and ask the user to declare their target explicitly.
REASON_AMBIGUOUS_GITHUB = "ambiguous .github/ — set target in apm.yml or use --target"
"""Tests for .github/-only auto-detection returning minimal (ambiguous)."""

def test_github_only_returns_minimal(self, tmp_path):
"""Only .github/ present — too ambiguous to assume Copilot."""
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

2 participants