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

Function is_invocation

atomic-agent/src/hooks/live.rs:162–227  ·  view source on GitHub ↗
(command: &str, prefix: &str, agent: &str, event: &str)

Source from the content-addressed store, hash-verified

160}
161
162fn is_invocation(command: &str, prefix: &str, agent: &str, event: &str) -> bool {
163 if prefix.is_empty() {
164 return false;
165 }
166 let command = command.trim();
167 let guard = "test -d .atomic || test -f .atomic-sandbox && ";
168 let (command, guarded) = match command.strip_prefix(guard) {
169 Some(command) => (command, true),
170 None => (command, false),
171 };
172 let command = if guarded {
173 let Some(command) = command.strip_suffix(" || true") else {
174 return false;
175 };
176 command
177 } else {
178 command
179 };
180 let Some(rest) = command.strip_prefix(prefix) else {
181 return false;
182 };
183 if !rest.starts_with(char::is_whitespace) {
184 return false;
185 }
186 let mut args = rest.split_whitespace();
187 let Some(verb) = args.next() else {
188 return false;
189 };
190 let recognized = matches!(
191 (agent, event, verb),
192 (
193 "claude-code" | "codex" | "gemini-cli",
194 "SessionStart",
195 "session-start"
196 ) | (
197 "claude-code" | "codex" | "gemini-cli",
198 "SessionEnd",
199 "session-end"
200 ) | ("claude-code" | "codex", "Stop", "stop")
201 | (
202 "claude-code" | "codex",
203 "UserPromptSubmit",
204 "user-prompt-submit"
205 )
206 | ("claude-code", "PreToolUse", "pre-task")
207 | (
208 "claude-code",
209 "PostToolUse",
210 "post-task" | "post-todo" | "post-tool"
211 )
212 | ("codex", "PreToolUse", "pre-tool")
213 | ("codex", "PostToolUse", "post-tool")
214 | ("gemini-cli", "BeforeAgent", "before-agent")
215 | ("gemini-cli", "AfterAgent", "after-agent")
216 | ("gemini-cli", "BeforeTool", "before-tool")
217 | ("gemini-cli", "AfterTool", "after-tool")
218 );
219 if !recognized {

Callers 1

json_hooks_activeFunction · 0.85

Calls 2

is_emptyMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected