Run one agent hook, optionally with extra environment (failpoints).
(&self, verb: &str, env: &[(&str, &str)])
| 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, &[]) |
no test coverage detected