mme / mme/amon

Hooks: parse hook JSON in Rust instead of spawning python

Open
#77 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3
Forks
0
Avg merge
2h 20m
Merged PRs (30d)
57

Description

Problem

Every installed hook that receives structured input spawns python3 to parse the JSON, because the shell wrappers can't. The new Claude prompt hook (amon-prompt-state.sh, ADR-0020/0021) spawns python on every UserPromptSubmit — i.e. once per turn — and the vendored state hooks (amon-agent-state.sh, 12 .sh assets) do the same on their events. On a machine without python3, all of these silently no-op, so amon gets no session id or prompt at all.

This is the python-per-hook cost we want to shed: the parsing belongs in Rust.

Shape of the fix (a supersession under ADR-0021)

Add an amon hook mode that reads the raw hook JSON on stdin and parses it in Rust, rather than the current subcommands that take pre-parsed flags (--prompt, --agent-session-id, …). Then each hook script becomes a one-liner:

exec amon hook claude-prompt   # or claude-session, etc.

— no python, no JSON-in-shell, and it works with no interpreter installed.

Because this replaces vendored hook assets with amon-owned ones, it's the first real supersession per ADR-0021: keep herdr's assets vendored as the drift-watched reference (SUPERSEDED in scripts/revendor.sh), stop routing to them, and let the drift report flag upstream changes.

Scope / sequencing

  • Start with the amon-only prompt hook (amon-prompt-state.sh) — it's already amon's, so no supersession bookkeeping, just move its parsing into amon hook.
  • Then the vendored .sh/.ps1 state assets, which is where the SUPERSEDED machinery and drift report earn their keep. The PowerShell assets already call amon hook directly (PowerShell parses JSON natively), so this brings .sh up to parity.

Not doing now

Nothing blocks the current turn/activity feature — the python hooks work. This is a transport cleanup, tracked separately.

Contributor guide

No contributing guide indexed for this repository

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 with amon-prompt-state.sh and the existing amon hook entry point, then read ADR-0021 for the supersession rules. Trace the vendored .sh and .ps1 state assets and scripts/revendor.sh, including the drift report. Done means raw hook JSON is parsed in Rust, shell hooks no longer spawn Python, and superseded assets remain tracked correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, python, rust, shell
Domain
cli, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.