Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/apm_cli/core/target_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Comment on lines +122 to +124
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

".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.

claude_exists = (project_root / ".claude").exists()
cursor_exists = (project_root / ".cursor").is_dir()
opencode_exists = (project_root / ".opencode").is_dir()
Expand Down
31 changes: 24 additions & 7 deletions tests/unit/core/test_target_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -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
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.



Expand Down Expand Up @@ -318,8 +335,8 @@ def test_auto_detect_cursor_only(self, tmp_path):
assert ".cursor/" in reason

def test_auto_detect_cursor_plus_github(self, tmp_path):
"""Auto-detect all when .cursor/ and .github/ exist."""
(tmp_path / ".github").mkdir()
"""Auto-detect all when .cursor/ and .github/ with Copilot markers exist."""
(tmp_path / ".github" / "prompts").mkdir(parents=True)
(tmp_path / ".cursor").mkdir()
target, _ = detect_target(
project_root=tmp_path,
Expand Down Expand Up @@ -357,8 +374,8 @@ def test_auto_detect_opencode_only(self, tmp_path):
assert ".opencode/" in reason

def test_auto_detect_opencode_plus_github(self, tmp_path):
"""Auto-detect all when .opencode/ and .github/ exist."""
(tmp_path / ".github").mkdir()
"""Auto-detect all when .opencode/ and .github/ with Copilot markers exist."""
(tmp_path / ".github" / "prompts").mkdir(parents=True)
(tmp_path / ".opencode").mkdir()
target, _ = detect_target(
project_root=tmp_path,
Expand Down
Loading