MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / agent_hook

Method agent_hook

atomic-cli/tests/it/git_shim_opt_in_test.rs:123–150  ·  view source on GitHub ↗

Run one OpenCode agent hook dispatch the way the atomic-opencode plugin does: JSON on stdin, foreground, from the repository root.

(&self, verb: &str, session_id: &str)

Source from the content-addressed store, hash-verified

121 /// Run one OpenCode agent hook dispatch the way the atomic-opencode
122 /// plugin does: JSON on stdin, foreground, from the repository root.
123 fn agent_hook(&self, verb: &str, session_id: &str) -> Output {
124 use std::io::Write;
125 let payload = format!(
126 "{{\"session_id\":\"{session_id}\",\"cwd\":\"{}\",\"timestamp\":\"2026-10-14T10:30:00Z\"}}",
127 self.root().display()
128 );
129 let mut child = Command::new(ATOMIC_BIN)
130 .args(["agent", "hooks", "opencode", verb, "--foreground"])
131 .current_dir(self.root())
132 .env("HOME", self.home.path())
133 .env("ATOMIC_HOME", self.home.path().join(".atomic"))
134 .env("ATOMIC_NONINTERACTIVE", "1")
135 .env("NO_COLOR", "1")
136 .env("CLICOLOR", "0")
137 .env("TERM", "dumb")
138 .stdout(Stdio::piped())
139 .stderr(Stdio::piped())
140 .stdin(Stdio::piped())
141 .spawn()
142 .expect("spawn atomic agent hooks");
143 child
144 .stdin
145 .as_mut()
146 .expect("hook stdin")
147 .write_all(payload.as_bytes())
148 .expect("write hook stdin");
149 child.wait_with_output().expect("wait for agent hook")
150 }
151
152 /// A retained shadow exclude marker without shim enrollment: written by
153 /// import/push, kept on disk by `git shim disable`, and never removed by

Calls 4

spawnMethod · 0.80
rootMethod · 0.45
pathMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected