Repository navigation
feat(agent): add --json output to atomic agent hooks - #95
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
--jsonoutput toatomic agent hooks.For example:
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::hookscargo fmt --checkcargo clippy --workspace -- -D warningscargo doc --workspace --no-deps