Skip to content

[BUG] Copilot target writes userPromptSubmit; Copilot's event is userPromptSubmitted, so prompt hooks never run #3031

Description

Describe the bug
A package hook on UserPromptSubmit (or userPromptSubmit) installed for the
copilot target is written to .github/hooks/*.json under the key
"userPromptSubmit". Copilot CLI has no event by that name, so the hook never
runs and nothing is logged.

Copilot's hooks reference
(https://docs.github.com/en/copilot/reference/hooks-configuration) names the
camelCase event userPromptSubmitted. Its PascalCase UserPromptSubmit is the
VS Code-compatible variant, which switches the payload to snake_case.

Cause: _HOOK_EVENT_MAP["copilot"] in
src/apm_cli/integration/hook_integrator.py:

"UserPromptSubmit": "userPromptSubmit",
"userPromptSubmit": "userPromptSubmit",

tests/integration/test_hook_integrator_copilot_casing_e2e.py asserts the
same wrong name.

To Reproduce

  1. A package pkg with apm.yml (target: [copilot]) and .apm/hooks/x.json:
    {"hooks":{"UserPromptSubmit":[{"hooks":[{"type":"command","command":"echo hit >> hook.log"}]}]}}
  2. A project that depends on pkg, with target: [copilot]. Run apm install.
    .github/hooks/pkg-x.json holds "userPromptSubmit".
  3. Start copilot in the project and send a prompt. No hook.log is written.
  4. Change the key to "userPromptSubmitted" in the deployed file, restart
    copilot and send a prompt. hook.log contains hit.

Expected behavior
apm writes userPromptSubmitted for the copilot target, and the hook runs on
every prompt.

Environment

  • OS: Windows 11 (pwsh 7)
  • APM Version: 0.31.0. The same map is on main at 98616b9.
  • GitHub Copilot CLI 1.0.86

Additional context
Related: #2111 (hook semantics), whose comment table already lists
userPromptSubmitted for Copilot. The reverse direction is not covered here:
a Copilot-authored userPromptSubmitted package installed for claude, codex
or kiro passes through unrenamed. That can be a separate issue if wanted.

Sending fix in a PR: map the three spellings to userPromptSubmitted for
copilot target, correct the tests and add a CHANGELOG entry.

I checked two points before you post:

  • The file name in step 2 is unverified. I read the deployed file with a wildcard (.github/hooks/.json), so I never saw its actual name. pkg-x.json follows the pattern from the earlier probe, where the file was pkg-herdr-tab-label.json. Either write .github/hooks/.json in step 2, or let me rerun the install and get the real name.
  • The template's "Python Version" field is left out. apm here is the installed binary, not something I ran through a Python interpreter.

Activity

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/multi-targetMulti-target deploy spec, target directory creation, agent surface routing.status/acceptedHuman scope approval; verify the issue's approval record and review contact before work.triage/recommendedAutomated advice completed; not human scope approval.type/bugSomething does not work as documented.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions