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

Function add_hook_to_groups

atomic-agent/src/hooks/codex.rs:427–453  ·  view source on GitHub ↗
(
    groups: &mut Vec<Value>,
    command: &str,
    status_message: Option<&str>,
)

Source from the content-addressed store, hash-verified

425}
426
427fn add_hook_to_groups(
428 groups: &mut Vec<Value>,
429 command: &str,
430 status_message: Option<&str>,
431) -> bool {
432 if groups.iter().any(|group| group_has_command(group, command)) {
433 return false;
434 }
435
436 let mut entry = Map::new();
437 entry.insert("type".to_string(), Value::String("command".to_string()));
438 entry.insert("command".to_string(), Value::String(command.to_string()));
439 if let Some(message) = status_message {
440 entry.insert(
441 "statusMessage".to_string(),
442 Value::String(message.to_string()),
443 );
444 }
445
446 let mut group = Map::new();
447 group.insert(
448 "hooks".to_string(),
449 Value::Array(vec![Value::Object(entry)]),
450 );
451 groups.push(Value::Object(group));
452 true
453}
454
455fn group_has_command(group: &Value, command: &str) -> bool {
456 group

Callers 2

add_hookFunction · 0.85

Calls 4

group_has_commandFunction · 0.85
iterMethod · 0.45
insertMethod · 0.45
pushMethod · 0.45

Tested by 1