Skip to content

fix: skip unsupported Copilot CLI primitives at user scope#536

Closed
sergio-sisternes-epam wants to merge 2 commits intomicrosoft:mainfrom
sergio-sisternes-epam:fix/copilot-user-scope-primitives
Closed

fix: skip unsupported Copilot CLI primitives at user scope#536
sergio-sisternes-epam wants to merge 2 commits intomicrosoft:mainfrom
sergio-sisternes-epam:fix/copilot-user-scope-primitives

Conversation

@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator

Description

When running apm install --global, APM incorrectly deployed instructions to ~/.copilot/instructions/. Per the official Copilot CLI config directory reference, ~/.copilot/ only supports agents/, skills/, and hooks/.

This change adds "instructions" to the Copilot target's unsupported_user_primitives, aligning APM with the documented Copilot CLI behavior. Also fixes user-scope root_dir resolution so integrators deploy to ~/.copilot/ rather than ~/.github/.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass (3,399 unit tests)
  • Added tests for new functionality

When running apm install --global, APM incorrectly deployed instructions
to ~/.copilot/instructions/. Per the official Copilot CLI config directory
reference, ~/.copilot/ only supports agents/, skills/, and hooks/.

- Add instructions to Copilot unsupported_user_primitives
- Fix user-scope root_dir resolution for integrators
- Update tests and documentation

Ref: https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-config-dir-reference

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 10:02
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

Fixes user-scope (apm install --global) Copilot CLI behavior by aligning deployed primitives and directories with the documented Copilot CLI config layout.

Changes:

  • Mark Copilot instructions as unsupported at user scope (alongside prompts).
  • Adjust install-time user-scope target root resolution so integrators deploy into user-level target directories (e.g. ~/.copilot/).
  • Update docs and tests to reflect Copilot user-scope support and warning output.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/unit/core/test_scope.py Extends scope/target metadata assertions for Copilot user-scope unsupported primitives and warning output.
src/apm_cli/integration/targets.py Adds instructions to Copilot unsupported_user_primitives and updates reference comment/link.
src/apm_cli/commands/install.py Overrides target root_dir at user scope to deploy into user-level dirs; fixes dependency resolution root to use apm_dir.
docs/src/content/docs/guides/dependencies.md Updates the Copilot CLI user-scope support matrix to remove instructions and list it as unsupported.

Comment thread src/apm_cli/commands/install.py
Address Copilot review feedback: make user_root_dir a first-class
deploy root in validate_deploy_path, partition_managed_files, and
the uninstall engine — not just in _integrate_package_primitives.

- get_integration_prefixes(user_scope=True) includes user-scope prefixes
- validate_deploy_path accepts user-scope paths when user_scope=True
- partition_managed_files routes user-scope paths correctly
- Uninstall engine uses effective_root(user_scope) for path resolution
- Add 8 tests for user-scope integration

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

Addressed Copilot's review feedback in 7486003:

  • get_integration_prefixes(user_scope=True) now includes user-scope prefixes (.copilot/, etc.)
  • validate_deploy_path() accepts user_scope parameter
  • partition_managed_files() routes user-scope paths correctly
  • Uninstall engine uses effective_root(user_scope) for path resolution
  • 8 new tests covering user-scope integration (3,407 total passing)

sergio-sisternes-epam pushed a commit to sergio-sisternes-epam/apm that referenced this pull request Apr 2, 2026
Apply the same fix from skill_integrator to all remaining integrators:
agent, command, instruction, and prompt integrators now use
target.effective_root(user_scope) instead of target.root_dir for
deploy paths and auto_create guards.

Also threads user_scope from install.py dispatch loop and uninstall
engine to all integrator *_for_target() and sync_for_target() methods.

Related: microsoft#536 (Copilot user-scope primitives)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
danielmeppiel added a commit that referenced this pull request Apr 2, 2026
Introduce TargetProfile.for_scope() and resolve_targets() so scope
resolution happens exactly once -- no parameter threading, no caller
responsibility.  This supersedes PRs #536 and #537 and folds in #527.

Scope resolution:
- for_scope(user_scope) returns a frozen copy with root_dir resolved
  and unsupported primitives filtered out
- resolve_targets() is the single entry point combining detection,
  scope resolution, and primitive filtering
- Integrators read target.root_dir directly -- always correct
- partition_managed_files() uses longest-prefix-match routing,
  fixing .config/opencode/ multi-level root paths
- validate_deploy_path() derives prefixes from resolved targets
- Uninstall Phase 2 re-integration uses resolved targets,
  eliminating wrong-path deployment bug

Claude Code instructions (#527):
- Deploy .instructions.md to .claude/rules/*.md with applyTo: to
  paths: frontmatter conversion
- Legacy glob disabled for .claude/rules/ to protect user .md files
- 22 new tests for conversion, integration, sync, and partition

Copilot CLI user-scope fix (#536):
- Add instructions to unsupported_user_primitives (per official docs)
- Fix resolve_dependencies to use apm_dir at user scope

Fixes #530

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

Superseded by #542 which implements a cleaner architecture: TargetProfile.for_scope() resolves scope once on the data object, eliminating the need for parameter threading or ad-hoc dataclasses.replace() at dispatch sites. Your unsupported_user_primitives addition and resolve_dependencies(apm_dir) fix are cherry-picked into #542. Thank you for the contribution!

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Closing in favor of #542 (scope-resolved target profiles architecture).

danielmeppiel added a commit that referenced this pull request Apr 2, 2026
Introduce TargetProfile.for_scope() and resolve_targets() so scope
resolution happens exactly once -- no parameter threading, no caller
responsibility.  This supersedes PRs #536 and #537 and folds in #527.

Scope resolution:
- for_scope(user_scope) returns a frozen copy with root_dir resolved
  and unsupported primitives filtered out
- resolve_targets() is the single entry point combining detection,
  scope resolution, and primitive filtering
- Integrators read target.root_dir directly -- always correct
- partition_managed_files() uses longest-prefix-match routing,
  fixing .config/opencode/ multi-level root paths
- validate_deploy_path() derives prefixes from resolved targets
- Uninstall Phase 2 re-integration uses resolved targets,
  eliminating wrong-path deployment bug

Claude Code instructions (#527):
- Deploy .instructions.md to .claude/rules/*.md with applyTo: to
  paths: frontmatter conversion
- Legacy glob disabled for .claude/rules/ to protect user .md files
- 22 new tests for conversion, integration, sync, and partition

Copilot CLI user-scope fix (#536):
- Add instructions to unsupported_user_primitives (per official docs)
- Fix resolve_dependencies to use apm_dir at user scope

Fixes #530

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
danielmeppiel added a commit that referenced this pull request Apr 2, 2026
* fix: scope-resolved target profiles + Claude Code instructions

Introduce TargetProfile.for_scope() and resolve_targets() so scope
resolution happens exactly once -- no parameter threading, no caller
responsibility.  This supersedes PRs #536 and #537 and folds in #527.

Scope resolution:
- for_scope(user_scope) returns a frozen copy with root_dir resolved
  and unsupported primitives filtered out
- resolve_targets() is the single entry point combining detection,
  scope resolution, and primitive filtering
- Integrators read target.root_dir directly -- always correct
- partition_managed_files() uses longest-prefix-match routing,
  fixing .config/opencode/ multi-level root paths
- validate_deploy_path() derives prefixes from resolved targets
- Uninstall Phase 2 re-integration uses resolved targets,
  eliminating wrong-path deployment bug

Claude Code instructions (#527):
- Deploy .instructions.md to .claude/rules/*.md with applyTo: to
  paths: frontmatter conversion
- Legacy glob disabled for .claude/rules/ to protect user .md files
- 22 new tests for conversion, integration, sync, and partition

Copilot CLI user-scope fix (#536):
- Add instructions to unsupported_user_primitives (per official docs)
- Fix resolve_dependencies to use apm_dir at user scope

Fixes #530

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: address PR review -- trie routing, legacy prefix cleanup, CHANGELOG refs

- Replace O(M*P) sorted-prefix scan with O(depth) trie lookup in
  partition_managed_files (reviewer comment 1)
- Use default KNOWN_TARGETS for uninstall partition so legacy
  deployed_files from buggy user-scope installs are still bucketed
  and cleaned up (reviewer comment 2)
- Remove targets= from orphan validate_deploy_path so legacy
  .github/ paths from old user-scope installs can be cleaned up
  (reviewer comment 3)
- Fix CHANGELOG PR references to use #542 (reviewer comment 4)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: dynamic skill sync prefixes + uninstall Phase 2 targets

Fix #538: pass resolved targets to skill_integrator.integrate_package_skill()
in uninstall Phase 2 so user-scope re-integration deploys to .copilot/skills/
not .github/skills/. Add auto_create guard to copy_skill_to_target().

Fix #539: refactor sync_integration() to derive skill prefixes dynamically
from targets instead of hardcoded .github/skills/, .claude/skills/, etc.
User-scope paths like .copilot/skills/ and .config/opencode/skills/ are
now handled correctly. Pass resolved targets from uninstall engine.

9 new tests covering resolved-target routing, auto_create guards,
user-scope manifest removal, legacy cleanup, and cross-tool guards.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergio-sisternes-epam sergio-sisternes-epam deleted the fix/copilot-user-scope-primitives branch April 3, 2026 18:16
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.

3 participants