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

Function add_hook_to_groups

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

Source from the content-addressed store, hash-verified

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