Merge pull request 'docs(kyberforge): correct hooks.md on allow keys and other runtimes' (#212) from docs/kyberforge-hooks-runtimes into main
Reviewed-on: #212
This commit was merged in pull request #212.
This commit is contained in:
commit
d439bbeb05
1 file changed
+28
-26
@@ -10,7 +10,8 @@ Author hooks in `plugins/kyberforge/.apm/hooks/*.json`. `.apm/` is the only cont
|
||||
plugin root and no per-plugin `plugin.json`, so `.apm/hooks/` is both where you edit and what ships.
|
||||
|
||||
apm merges every `*.json` in that directory into a single hook definition and writes the event
|
||||
bindings into the consuming project's `.claude/settings.json`; see "Deployed shape" below. Scripts a
|
||||
bindings into each target the consuming project enables: `.claude/settings.json` for Claude Code,
|
||||
and per-target files for Copilot and Codex (see "Deployed shape" and "Other runtimes" below). Scripts a
|
||||
hook invokes live in the same directory, alongside the JSON that references them.
|
||||
|
||||
## Hook file structure
|
||||
@@ -69,9 +70,15 @@ tracked in a `.claude/apm-hooks.json` sidecar, so an uninstall removes them with
|
||||
hand-authored hooks. Both `.claude/hooks/` and the sidecar are gitignored install output.
|
||||
|
||||
Note that apm's **executable-trust gate is off** unless the consuming project's `apm.yml` has an
|
||||
`executables:` block — without one, package hooks deploy with no prompt. The allow key is
|
||||
version-pinned (`kyberforge#<version>`), so a version bump on one side alone stops the hook
|
||||
deploying; `check-executables-allow-sync` is the pre-push gate that catches it. See ADR-0019.
|
||||
`executables:` block — without one, package hooks deploy with no prompt. The grant is
|
||||
**version-blind**: apm also matches an allow key such as `kyberforge#<version>` by its bare package
|
||||
name, so a version bump on one side does not stop the hook deploying (verified against apm 0.28.0;
|
||||
the correction is recorded in ADR-0019 and `docs/spec/gates.md`). This repo still keeps each key at
|
||||
`<name>#<version>` as a record of which version was reviewed, and `check-executables-allow-sync` is
|
||||
the pre-push gate that holds every plugin shipping `.apm/hooks/` or `bin/` to that.
|
||||
|
||||
apm 0.28.0 prints "parked pending approval" for a granted package even when it deploys the hook
|
||||
(holocron#208). Check for the deployed script and settings entry, not the warning.
|
||||
|
||||
## The SessionStart hook
|
||||
|
||||
@@ -105,32 +112,27 @@ stages a genuinely outdated dependency against the **real** `apm` — a local gi
|
||||
`url.<path>.insteadOf` rewrites, so it needs no network — and replays that genuine output through the
|
||||
hook.
|
||||
|
||||
## GitHub Copilot CLI
|
||||
## Other runtimes
|
||||
|
||||
**Copilot loads no hooks from this plugin.** Two independent reasons, either one sufficient:
|
||||
An earlier version of this section said Copilot loads no hooks from an apm package, because nothing
|
||||
pointed Copilot at a hooks file and apm wrote only a Claude-shaped definition. That no longer holds:
|
||||
apm 0.28.0 shapes and deploys hooks per target itself, with no `plugin.json` pointer involved.
|
||||
Sources: `docs/research/infra-packages/enforcement-hooks.md` on the `research/enforcement-hooks`
|
||||
branch, and the [delivery guard hook](https://git.rkdr.net/Mortis/Holocron/issues/190) work.
|
||||
|
||||
- **Nothing can point Copilot at a hooks file.** Copilot types `hooks` as a `plugin.json` field of
|
||||
type "string or object" with **no default**
|
||||
(`docs/research/docs/github-copilot-plugins/configuration.md:47`), so there is no convention path
|
||||
for it to scan — it reads hooks only via an explicit pointer. Since ADR-0024 there is no
|
||||
per-plugin Copilot manifest at all, so there is nothing to carry that pointer.
|
||||
- **The two ecosystems do not share a hooks format.** Copilot reads a differently-shaped
|
||||
`hooks.json`: `version: 1` is required, each entry is `type: "command"` with separate `bash` and
|
||||
`powershell` scripts, and the lifecycle points are lowercase and differently named (`sessionStart`,
|
||||
`sessionEnd`, `userPromptSubmitted`, `preToolUse`, `postToolUse`, `errorOccurred`, `agentStop`).
|
||||
See `docs/research/docs/github-copilot-plugins/configuration.md`. apm merges `.apm/hooks/*.json`
|
||||
into one definition with no per-target shaping, and that definition is Claude-shaped.
|
||||
| Target | Where apm writes the hook | Status |
|
||||
|---|---|---|
|
||||
| `copilot` | One file per hook, `.github/hooks/<pkg>-<name>.json`, with the script under `.github/hooks/scripts/<pkg>/.apm/hooks/`. Event names are renamed to camelCase and `version: 1` is added. | **Unverified.** Entries keep Claude's nested matcher group with `command`/`timeout`. Copilot's docs accept `command`/`timeout` as aliases for `bash`/`powershell`, but don't document the nested group, so whether Copilot CLI runs the hook is untested until a Copilot account exists. |
|
||||
| `codex` | Merged into `.codex/hooks.json`, with the script under `.codex/hooks/<pkg>/.apm/hooks/`. Claude's event names and shape are kept. | apm skips the target unless `.codex/` already exists, and Codex runs project hooks only after a human trusts them. |
|
||||
|
||||
The second reason is why "just add a pointer" was rejected even while a Copilot manifest existed: a
|
||||
pointer would tell Copilot that a Claude-shaped file is Copilot-shaped, trading an incomplete
|
||||
manifest for a wrong one. ADR-0024 consequence 7 records that the question is now moot — the
|
||||
manifest it argued about is gone — but the schema mismatch it turned on is not, and it is what any
|
||||
future Copilot hooks support has to solve.
|
||||
Only enabled targets get a hook: this repo's root `apm.yml` targets `claude` alone, so nothing lands
|
||||
in `.github/hooks/` or `.codex/` here. VS Code's Copilot reads both `.github/hooks/` and
|
||||
`.claude/settings.json`, so a package installed for both `claude` and `copilot` runs each hook
|
||||
twice there.
|
||||
|
||||
**What this costs you:** a hook authored under `.apm/hooks/` reaches Claude Code and not Copilot.
|
||||
That is a real limitation, and it is the accepted one until apm emits a per-target hooks file or the
|
||||
two schemas converge. If you need a Copilot hook today, raise it — it needs an upstream change or a
|
||||
second authoring path, not a pointer.
|
||||
**The `SessionStart` hook is Claude-only in practice.** `check-apm-current.sh` answers with Claude
|
||||
Code's `reloadSkills` output and reads `${CLAUDE_PROJECT_DIR}`, so on another runtime it at most
|
||||
runs the update without reloading anything.
|
||||
|
||||
## Symlinks under `.apm/` do not survive, and nothing reports it
|
||||
|
||||
|
||||
Reference in new issue
Block a user