Skip to content

feat(agent): add --json output to atomic agent hooks - #95

Merged
geekgonecrazy merged 4 commits into
devfrom
feat/agent-hooks-json
Jul 1, 2026
Merged

geekgonecrazy merged 4 commits into
devfrom
feat/agent-hooks-json

Conversation

@vinceblock99

@vinceblock99 vinceblock99 commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds --json output to atomic agent hooks.

For example:

atomic agent hooks sherpa turn-end --json

can now return:

{
  "session_id": "...",
  "recorded": true,
  "change_hash": "...",
  "view": "...",
  "files": ["..."]
}

Why

Sherpa/noname runs ACP agents through the Atomic hook CLI.

After the ACP turn finishes, Sherpa needs to know which Atomic change was recorded so it can link the result back to the Graph, and later to Intent or Memory artifacts.

Without this JSON output, Sherpa can get the agent answer, but cannot reliably know the recorded change_hash, view, or changed files.

Testing

  • cargo test -p atomic-cli agent::hooks
  • cargo fmt --check
  • cargo clippy --workspace -- -D warnings
  • cargo doc --workspace --no-deps

Adds an opt-in `--json` flag to `atomic agent hooks <agent> <verb>` that
prints a machine-readable result on stdout describing what the hook
recorded: session id, whether a change was recorded, the change hash, and
the files in that change.

Why: a coordinator driving an agent turn through the hook surface (e.g. the
Sherpa UI bridging an ACP run into Atomic) needs the recorded change hash to
link the turn to its Atomic change. The hook surface previously kept stdout
quiet by design, so there was no way to get the hash back without linking the
engine crate directly.

The flag is off by default, so existing integrations are unaffected (Claude
Code reads its own JSON response from stdout; the OpenCode plugin treats
stdout as TUI noise). Only callers that pass `--json` get the extra line.
`atomic agent hooks codex stop` detaches into a background recorder whose
stdout is null, so a `--json` caller could never receive the recorded change
hash. Skip the handoff and run in-process when `--json` is requested, so the
caller gets the JSON result synchronously. Default (non-json) codex stop still
hands off as before.
The agent records each turn onto the session's own (haikunator-named) view, not
the default/shared view, so a caller that has only the change hash can't locate
it with a plain `log` on the default view. Expose the view as the source of
truth from the hook itself.

DispatchResult gains a `view` field, set from the session's view_name on
turn-end; `atomic agent hooks … turn-end --json` now emits `view` alongside
session_id / recorded / change_hash / files (omitted when unknown).

Surfaced by a local integration rehearsal: a recorded ACP run's change was on
the session view and invisible to a default-view `log`, while `diff --change`
(global) still worked.
@geekgonecrazy
geekgonecrazy merged commit 3f1adb0 into dev Jul 1, 2026
8 checks passed
@geekgonecrazy
geekgonecrazy deleted the feat/agent-hooks-json branch July 1, 2026 05:31
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.

2 participants