microsoft / microsoft/apm

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

Open Beginner friendly
#3,031 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/bug
Dominant language
Python
Stars
3.8k
Forks
362
Avg merge
1d 17h
Merged PRs (30d)
132

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/apm_cli/integration/hook_integrator.py at _HOOK_EVENT_MAP["copilot"], then read tests/integration/test_hook_integrator_copilot_casing_e2e.py. Update the Copilot event mapping, adjust the assertions, and add the requested CHANGELOG entry. Done means the generated .github/hooks/*.json uses userPromptSubmitted and the Copilot casing test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, python
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.