fix: treat .github/-only auto-detection as ambiguous#1115
Open
Giggitycountless wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: treat .github/-only auto-detection as ambiguous#1115Giggitycountless wants to merge 1 commit intomicrosoft:mainfrom
Giggitycountless wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…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
3 tasks
Contributor
There was a problem hiding this comment.
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 returnsminimalwith an ambiguity reason instead ofvscode. - Expand unit coverage around ambiguous
.github/detection and precedence of explicit/configured targets. - Add a new tracked
.codex/config.tomlfile 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 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" |
|
|
||
| [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 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.""" |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/-onlydetection 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"withREASON_AMBIGUOUS_GITHUBinstead of"vscode"REASON_AMBIGUOUS_GITHUBconstant with guidance texttests/unit/core/test_target_detection.py:test_auto_detect_github_onlyto expect"minimal"+ ambiguous reasonTestDetectTargetAmbiguousGithubclass with 7 tests:.github/only returns minimal--target copilotstill wins over ambiguous detectiontarget: copilotstill wins over ambiguous detection.github/+.claude/still returnsall.github/+.cursor/still returnsallREASON_AMBIGUOUS_GITHUBconstant is importableDesign 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