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

Method hook

atomic-cli/tests/it/intent_turn_binding_test.rs:59–79  ·  view source on GitHub ↗
(&self, session: &str, verb: &str)

Source from the content-addressed store, hash-verified

57 }
58
59 fn hook(&self, session: &str, verb: &str) -> serde_json::Value {
60 let mut child = self
61 .command()
62 .args(["agent", "hooks", "opencode", verb, "--foreground", "--json"])
63 .stdin(Stdio::piped())
64 .stdout(Stdio::piped())
65 .stderr(Stdio::piped())
66 .spawn()
67 .unwrap();
68 let payload = serde_json::json!({"session_id": session, "cwd": self.root(),
69 "prompt": "Implement a greeting", "model": "test", "provider": "test",
70 "response": "Implemented and tested a greeting"});
71 child
72 .stdin
73 .take()
74 .unwrap()
75 .write_all(payload.to_string().as_bytes())
76 .unwrap();
77 let text = success(child.wait_with_output().unwrap());
78 serde_json::from_str(text.lines().last().unwrap()).unwrap()
79 }
80
81 fn new_intent(&self) -> (String, String) {
82 let output = self.run(&["intent", "new", "Implement a greeting"]);

Calls 7

spawnMethod · 0.80
lastMethod · 0.80
successFunction · 0.70
unwrapMethod · 0.45
commandMethod · 0.45
as_bytesMethod · 0.45
linesMethod · 0.45

Tested by

no test coverage detected