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

Method hook_output_with

atomic-cli/tests/it/agent_git_commit_absorb_test.rs:109–131  ·  view source on GitHub ↗

Run one agent hook, optionally with extra environment (failpoints).

(&self, verb: &str, env: &[(&str, &str)])

Source from the content-addressed store, hash-verified

107
108 /// Run one agent hook, optionally with extra environment (failpoints).
109 fn hook_output_with(&self, verb: &str, env: &[(&str, &str)]) -> Output {
110 let payload = serde_json::json!({"session_id": SESSION, "cwd": self.root(),
111 "prompt": "Fix the tracked file and commit it", "model": "test", "provider": "test",
112 "response": "Committed the fix", "turn_duration_ms": 10});
113 let mut command = self.with_env(Command::new(env!("CARGO_BIN_EXE_atomic")));
114 for (name, value) in env {
115 command.env(name, value);
116 }
117 let mut child = command
118 .args(["agent", "hooks", "opencode", verb, "--foreground", "--json"])
119 .stdin(Stdio::piped())
120 .stdout(Stdio::piped())
121 .stderr(Stdio::piped())
122 .spawn()
123 .unwrap();
124 child
125 .stdin
126 .take()
127 .unwrap()
128 .write_all(payload.to_string().as_bytes())
129 .unwrap();
130 child.wait_with_output().unwrap()
131 }
132
133 fn hook_output(&self, verb: &str) -> Output {
134 self.hook_output_with(verb, &[])

Callers 3

hook_outputMethod · 0.80
interrupt_adoptionFunction · 0.80
interrupt_after_recordFunction · 0.80

Calls 4

with_envMethod · 0.80
spawnMethod · 0.80
unwrapMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected