Skip to content

[codex] feat(cli): agentkeys wire hooks for Hermes#142

Closed
hanwencheng wants to merge 1 commit into
mainfrom
codex/issue-103-wire-hooks
Closed

[codex] feat(cli): agentkeys wire hooks for Hermes#142
hanwencheng wants to merge 1 commit into
mainfrom
codex/issue-103-wire-hooks

Conversation

@hanwencheng
Copy link
Copy Markdown
Member

Summary

Implements the current #103 direction from the latest issue comment: hooks-first agentkeys wire for Hermes, with AgentKeys MCP tools turned into runtime lifecycle IAM guarantees.

  • Adds agentkeys hook check|audit|memory-inject as host-invoked MCP JSON-RPC helpers.
  • Adds agentkeys wire hermes with a RuntimeAdapter seam, idempotent hook script writes, sentinel-managed ~/.hermes/config.yaml merging, --check-only drift reporting, and hermes hooks doctor verification.
  • Adds the operator runbook for the 7-step fresh-user flow and three-act demo.
  • Fixes the test-hygiene issue from feat(cli): agentkeys wire + hook — IAM-guarantee hooks for Hermes #141 by avoiding global HOME mutation in the wire unit test.

Context

The latest #103 comment says #140 has merged the docs/strategy reset and #141 is the active implementation shape. This PR applies that implementation on top of the merged #140 main, keeps the #141 semantics, and includes the local CI fix so the harness can get past formatting and parallel test isolation.

Fixes #103.
References #140 and #141.

Validation

  • cargo fmt --all -- --check
  • cargo test -p agentkeys-cli
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace -- --test-threads=1

Phase 1.a of the fresh-user wire-onboarding plan. Turns the shipped MCP
tools (#107) into IAM guarantees the LLM cannot bypass, via Task-Host
lifecycle hooks (issue #133 track). Companion docs (strategy/arch/wiki/
plan) land in PR #140.

- `agentkeys hook check|audit|memory-inject` (src/hook.rs): thin MCP
  JSON-RPC clients invoked by the wire-generated hook scripts. Read the
  host stdin payload, call an AgentKeys MCP tool, emit host-shaped stdout
  JSON. `check` fails CLOSED; audit + memory-inject never block.
- `agentkeys wire <runtime>` (src/wire.rs): RuntimeAdapter trait +
  HermesAdapter. Detects Hermes, writes hook scripts to
  ~/.hermes/agent-hooks/, merges a sentinel-managed `hooks:` block into
  ~/.hermes/config.yaml (preserves other keys, refuses to clobber a
  foreign hooks:), sets hooks_auto_accept: true, verifies via
  `hermes hooks doctor`. Idempotent (ok/skip/fail per step); --check-only
  reports drift without writing.
- CLI wiring: Commands::Wire + Commands::Hook + HookAction in main.rs;
  pub mod hook/wire in lib.rs.
- Operator runbook (docs/operator-runbook-wire.md): the 7-step fresh-user
  flow + three-act demo verification — moved here from the docs PR since
  it documents these exact commands.

13 unit tests (6 hook + 7 wire). Smoke-tested end-to-end against the
in-memory MCP backend: Act 1 memory injection, Act 2 over-cap denial,
auto-audit, and the full wire apply->idempotent-rerun->check-only cycle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Demo: aiosandbox + Hermes + AgentKeys on ESP32 hardware

1 participant