-
Notifications
You must be signed in to change notification settings - Fork 175
fix: require Copilot-specific markers for .github/ auto-detection #1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4231780
da126f4
81b3ce9
7ad1d44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,7 +110,17 @@ def detect_target( # noqa: PLR0911 | |
| return "all", "apm.yml target" | ||
|
|
||
| # Priority 3: Auto-detect from existing folders | ||
| github_exists = (project_root / ".github").exists() | ||
| # 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 | ||
| ) | ||
|
||
| claude_exists = (project_root / ".claude").exists() | ||
| cursor_exists = (project_root / ".cursor").is_dir() | ||
| opencode_exists = (project_root / ".opencode").is_dir() | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |||
| from apm_cli.core.target_detection import ( | ||||
| ALL_CANONICAL_TARGETS, | ||||
| EXPERIMENTAL_TARGETS, | ||||
| REASON_NO_TARGET_FOLDER, | ||||
| VALID_TARGET_VALUES, | ||||
| TargetParamType, | ||||
| detect_target, | ||||
|
|
@@ -122,8 +123,8 @@ def test_config_target_all(self, tmp_path): | |||
| assert reason == "apm.yml target" | ||||
|
|
||||
| def test_auto_detect_github_only(self, tmp_path): | ||||
| """Auto-detect vscode when only .github/ exists.""" | ||||
| (tmp_path / ".github").mkdir() | ||||
| """Auto-detect vscode when only .github/ with Copilot markers exists.""" | ||||
| (tmp_path / ".github" / "prompts").mkdir(parents=True) | ||||
|
|
||||
| target, reason = detect_target( | ||||
| project_root=tmp_path, | ||||
|
|
@@ -149,7 +150,7 @@ def test_auto_detect_claude_only(self, tmp_path): | |||
|
|
||||
| def test_auto_detect_both_folders(self, tmp_path): | ||||
| """Auto-detect all when both folders exist.""" | ||||
| (tmp_path / ".github").mkdir() | ||||
| (tmp_path / ".github" / "prompts").mkdir(parents=True) | ||||
| (tmp_path / ".claude").mkdir() | ||||
|
|
||||
| target, reason = detect_target( | ||||
|
|
@@ -170,6 +171,22 @@ def test_auto_detect_neither_folder(self, tmp_path): | |||
| ) | ||||
|
|
||||
| assert target == "minimal" | ||||
|
|
||||
| def test_auto_detect_bare_github_no_copilot_markers(self, tmp_path): | ||||
| """Auto-detect minimal when .github/ exists but has no Copilot markers. | ||||
|
|
||||
| A bare .github/ with only workflows/CODEOWNERS is NOT a Copilot signal. | ||||
| """ | ||||
| (tmp_path / ".github" / "workflows").mkdir(parents=True) | ||||
|
|
||||
| target, reason = detect_target( | ||||
| project_root=tmp_path, | ||||
| explicit_target=None, | ||||
| config_target=None, | ||||
| ) | ||||
|
|
||||
| assert target == "minimal" | ||||
| assert reason == REASON_NO_TARGET_FOLDER | ||||
| assert "no target folder found" in reason | ||||
|
||||
| assert "no target folder found" in reason |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.mdauto-detection table, anddocs/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.There was a problem hiding this comment.
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
There was a problem hiding this comment.
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: