ironbridge-cli 2.0.1

Universal chat session manager - harvest, merge, and analyze AI chat history from VS Code, Cursor, and other editors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
// Copyright (c) 2024-2026 Nervosys LLC
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-IronBridge-Commercial
//! Agency (Agent Development Kit) command implementations

use crate::agency::{AgentRole, OrchestrationType};
use anyhow::Result;
use colored::Colorize;

/// List available agents and roles
pub fn list_agents(verbose: bool) -> Result<()> {
    println!(
        "{}",
        "+===================================================================+".cyan()
    );
    println!(
        "{}",
        "|              IRONBRIDGE Agent Development Kit (Agency)                   |".cyan()
    );
    println!(
        "{}",
        "+===================================================================+".cyan()
    );
    println!();

    println!("{}", "[*] Available Agent Roles:".bold());
    println!();

    let roles = [
        (
            "coordinator",
            "[C]",
            "Manages and delegates tasks to other agents",
        ),
        ("researcher", "[R]", "Gathers information and analyzes data"),
        ("coder", "[D]", "Writes and modifies code"),
        ("reviewer", "[V]", "Reviews code and provides feedback"),
        ("executor", "[E]", "Executes commands and tools"),
        ("writer", "[W]", "Creates documentation and content"),
        ("tester", "[T]", "Writes and runs tests"),
        ("custom", "[X]", "User-defined agent with custom behavior"),
    ];

    for (role, icon, desc) in roles {
        if verbose {
            println!(
                "  {} {} {}",
                icon,
                role.green().bold(),
                format!("- {}", desc).dimmed()
            );
        } else {
            println!("  {} {}", icon, role.green());
        }
    }

    if verbose {
        println!();
        println!("{}", "[*] Default Agents:".bold());
        println!();
        println!(
            "  {} {} - General-purpose assistant with planning",
            "[A]".dimmed(),
            "assistant".yellow()
        );
        println!(
            "  {} {} - Research specialist with web search",
            "[R]".dimmed(),
            "researcher".yellow()
        );
        println!(
            "  {} {} - Code generation and modification",
            "[D]".dimmed(),
            "coder".yellow()
        );
        println!(
            "  {} {} - Code review and quality assurance",
            "[V]".dimmed(),
            "reviewer".yellow()
        );
    }

    Ok(())
}

/// Show agent information
pub fn show_agent_info(name: &str) -> Result<()> {
    println!("{}", format!("Agent: {}", name).bold());
    println!();

    // Default agent configurations
    match name.to_lowercase().as_str() {
        "assistant" => {
            println!("  {} {}", "Role:".dimmed(), "custom".green());
            println!(
                "  {} General-purpose AI assistant with planning and reflection",
                "Description:".dimmed()
            );
            println!("  {} gemini-2.0-flash (default)", "Model:".dimmed());
            println!("  {} 0.7", "Temperature:".dimmed());
            println!(
                "  {} planning, reflection, code_execution",
                "Capabilities:".dimmed()
            );
        }
        "researcher" => {
            println!("  {} {}", "Role:".dimmed(), "researcher".green());
            println!(
                "  {} Research specialist with web search capabilities",
                "Description:".dimmed()
            );
            println!("  {} gemini-2.0-flash (default)", "Model:".dimmed());
            println!("  {} 0.5", "Temperature:".dimmed());
            println!(
                "  {} web_search, file_read, knowledge_base",
                "Tools:".dimmed()
            );
        }
        "coder" => {
            println!("  {} {}", "Role:".dimmed(), "coder".green());
            println!(
                "  {} Code generation and modification specialist",
                "Description:".dimmed()
            );
            println!("  {} gemini-2.0-flash (default)", "Model:".dimmed());
            println!("  {} 0.3", "Temperature:".dimmed());
            println!(
                "  {} file_read, file_write, terminal, code_search",
                "Tools:".dimmed()
            );
        }
        "reviewer" => {
            println!("  {} {}", "Role:".dimmed(), "reviewer".green());
            println!(
                "  {} Code review and quality assurance",
                "Description:".dimmed()
            );
            println!("  {} gemini-2.0-flash (default)", "Model:".dimmed());
            println!("  {} 0.2", "Temperature:".dimmed());
            println!("  {} file_read, code_search, lint", "Tools:".dimmed());
        }
        _ => {
            println!(
                "  {} Agent '{}' not found in defaults",
                "[!]".yellow(),
                name
            );
            println!();
            println!(
                "  Use 'ironbridge Agency create {}' to create a new agent",
                name
            );
        }
    }

    Ok(())
}

/// List orchestration modes
pub fn list_modes() -> Result<()> {
    println!("{}", "[*] Orchestration Modes:".bold());
    println!();

    let modes = [
        ("single", "[1]", "Traditional single-agent response"),
        (
            "sequential",
            "[>]",
            "Agents execute one after another, passing results forward",
        ),
        (
            "parallel",
            "[!]",
            "Multiple agents work simultaneously on subtasks",
        ),
        ("loop", "[O]", "Agent repeats until a condition is met"),
        (
            "hierarchical",
            "[H]",
            "Lead agent delegates to specialized sub-agents",
        ),
        (
            "swarm",
            "[S]",
            "Multiple agents collaborate with a coordinator",
        ),
        ("debate", "[D]", "Agents debate to reach the best solution"),
    ];

    for (mode, icon, desc) in modes {
        println!("  {} {} - {}", icon, mode.cyan().bold(), desc.dimmed());
    }

    println!();
    println!("{}", "Usage:".dimmed());
    println!("  ironbridge Agency run --orchestration swarm \"Build a web scraper\"");

    Ok(())
}

/// Run an agent with a prompt
pub fn run_agent(
    agent_name: &str,
    prompt: &str,
    model: Option<&str>,
    orchestration: &str,
    verbose: bool,
) -> Result<()> {
    let model_name = model.unwrap_or("gemini-2.0-flash");

    println!("{}", "[*] Starting agent execution...".bold());
    println!();
    println!("  {} {}", "Agent:".dimmed(), agent_name.green());
    println!("  {} {}", "Model:".dimmed(), model_name.yellow());
    println!("  {} {}", "Mode:".dimmed(), orchestration.cyan());
    println!("  {} {}", "Prompt:".dimmed(), prompt);
    println!();

    // Parse orchestration type
    let orch_type = match orchestration.to_lowercase().as_str() {
        "single" => OrchestrationType::Sequential, // Single is just sequential with one agent
        "sequential" => OrchestrationType::Sequential,
        "parallel" => OrchestrationType::Parallel,
        "loop" => OrchestrationType::Loop,
        "hierarchical" => OrchestrationType::Hierarchical,
        "swarm" => OrchestrationType::Hierarchical, // Swarm uses hierarchical orchestration
        _ => {
            println!(
                "{} Unknown orchestration mode '{}', using single",
                "[!]".yellow(),
                orchestration
            );
            OrchestrationType::Sequential
        }
    };

    if verbose {
        println!("{}", "[*] Execution Details:".dimmed());
        println!("  Orchestration Type: {:?}", orch_type);
    }

    // For now, show that the agent would be created and run
    // Full implementation requires async runtime and API keys
    println!(
        "{}",
        "[...] Agent execution requires API keys and async runtime.".dimmed()
    );
    println!(
        "{}",
        "   Use 'ironbridge api serve' to start the backend API,".dimmed()
    );
    println!(
        "{}",
        "   then use ironbridge-web or vscode-extension for full agent execution.".dimmed()
    );
    println!();

    // Show what would happen
    println!("{}", "[*] Execution Plan:".bold());
    match orchestration.to_lowercase().as_str() {
        "single" => {
            println!("  1. {} agent receives prompt", agent_name);
            println!("  2. Agent processes and responds");
        }
        "sequential" => {
            println!("  1. First agent processes prompt");
            println!("  2. Result passed to next agent");
            println!("  3. Continue until all agents complete");
        }
        "parallel" => {
            println!("  1. Task decomposed into subtasks");
            println!("  2. Multiple agents work simultaneously");
            println!("  3. Results merged");
        }
        "swarm" | "hierarchical" => {
            println!("  1. Coordinator analyzes task");
            println!("  2. Tasks delegated to specialists");
            println!("  3. Results collected and synthesized");
        }
        "loop" => {
            println!("  1. Agent processes prompt");
            println!("  2. Check completion condition");
            println!("  3. Repeat if needed (max iterations)");
        }
        _ => {}
    }

    Ok(())
}

/// Create a new agent configuration
pub fn create_agent(
    name: &str,
    role: &str,
    instruction: Option<&str>,
    model: Option<&str>,
) -> Result<()> {
    let role_enum = match role.to_lowercase().as_str() {
        "coordinator" => AgentRole::Coordinator,
        "researcher" => AgentRole::Researcher,
        "coder" => AgentRole::Coder,
        "reviewer" => AgentRole::Reviewer,
        "executor" => AgentRole::Executor,
        "writer" => AgentRole::Writer,
        "analyst" => AgentRole::Analyst,
        "assistant" => AgentRole::Assistant,
        "household" => AgentRole::Household,
        "business" => AgentRole::Business,
        "tester" => AgentRole::Tester,
        _ => AgentRole::Custom,
    };

    let default_instruction = match role_enum {
        AgentRole::Coordinator => "You are a coordinator agent that manages and delegates tasks.",
        AgentRole::Researcher => "You are a research specialist that gathers and analyzes information.",
        AgentRole::Coder => "You are a coding specialist that writes and modifies code.",
        AgentRole::Reviewer => "You are a code reviewer that provides quality feedback.",
        AgentRole::Executor => "You are an executor that runs commands and tools.",
        AgentRole::Writer => "You are a writer that creates documentation and content.",
        AgentRole::Analyst => "You are an analyst that examines data and provides insights.",
        AgentRole::Assistant => "You are a helpful AI assistant.",
        AgentRole::Household => "You are a proactive Household Agent that monitors and solves home problems with user permission. Track bills, maintenance, supplies, smart home devices, and daily household tasks.",
        AgentRole::Business => "You are a proactive Business Agent that monitors and solves work problems with user permission. Optimize calendars, triage emails, prepare for meetings, track deadlines, and coordinate projects.",
        AgentRole::Tester => "You are a testing specialist that creates and runs tests.",
        AgentRole::Custom => "You are a helpful AI assistant.",
    };

    let instruction = instruction.unwrap_or(default_instruction);
    let model = model.unwrap_or("gemini-2.0-flash");

    println!("{}", "[+] Agent Configuration Created:".bold().green());
    println!();
    println!("  {} {}", "Name:".dimmed(), name.cyan().bold());
    println!("  {} {:?}", "Role:".dimmed(), role_enum);
    println!("  {} {}", "Model:".dimmed(), model.yellow());
    println!("  {} {}", "Instruction:".dimmed(), instruction);
    println!();
    println!("{}", "[*] To use this agent:".dimmed());
    println!(
        "   ironbridge Agency run --agent {} \"Your prompt here\"",
        name
    );

    Ok(())
}

/// List available tools
pub fn list_tools() -> Result<()> {
    println!("{}", "[*] Available Tools:".bold());
    println!();

    let tools = [
        ("file_read", "[F]", "Read file contents"),
        ("file_write", "[W]", "Write or modify files"),
        ("terminal", "[T]", "Execute shell commands"),
        ("web_search", "[?]", "Search the web for information"),
        ("code_search", "[?]", "Search codebase for symbols"),
        ("knowledge_base", "[K]", "Query knowledge base"),
        ("calculator", "[#]", "Perform calculations"),
        ("http_request", "[H]", "Make HTTP requests"),
    ];

    for (tool, icon, desc) in tools {
        println!("  {} {} - {}", icon, tool.green().bold(), desc.dimmed());
    }

    Ok(())
}

/// Show swarm templates
pub fn list_templates() -> Result<()> {
    println!("{}", "[S] Swarm Templates:".bold());
    println!();

    let templates = [
        (
            "code_review",
            "Code Review Team",
            vec!["coder", "reviewer", "tester"],
        ),
        (
            "research",
            "Research Team",
            vec!["coordinator", "researcher", "writer"],
        ),
        (
            "full_stack",
            "Full Stack Team",
            vec!["coordinator", "coder", "reviewer", "tester"],
        ),
        (
            "content",
            "Content Team",
            vec!["researcher", "writer", "reviewer"],
        ),
    ];

    for (id, name, agents) in templates {
        println!("  {} {}", "[*]".dimmed(), name.cyan().bold());
        println!("     {} {}", "ID:".dimmed(), id.yellow());
        println!("     {} {}", "Agents:".dimmed(), agents.join(", ").green());
        println!();
    }

    println!("{}", "Usage:".dimmed());
    println!("  Select a template in ironbridge-web or vscode-extension to create a swarm.");

    Ok(())
}