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

Method hook

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

Source from the content-addressed store, hash-verified

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