Skip to main content

agent_office/cli/
mod.rs

1use clap::{Parser, Subcommand};
2
3#[derive(Parser)]
4#[command(name = "agent-office")]
5#[command(about = "A pleasant set of tools for refined AI agents to get work done")]
6#[command(version = "0.1.0")]
7pub struct Cli {
8    #[command(subcommand)]
9    pub command: Commands,
10}
11
12#[derive(Subcommand)]
13pub enum Commands {
14    /// A simple mailbox to communicate with your coworkers
15    #[command(subcommand)]
16    Mail(MailCommands),
17    /// Find your coworkers, let your coworkers know your status, and register yourself as a coworker
18    #[command(subcommand)]
19    Agent(AgentCommands),
20    /// A Zettelkasten knowledge base for all coworkers to share
21    #[command(subcommand)]
22    Kb(KbCommands),
23    /// Human-only tools (not for AI agents)
24    #[command(subcommand)]
25    Human(HumanCommands),
26    /// A warm welcome and guide for new AI agents
27    HowWeWork,
28}
29
30/// Commands intended for human use only - these are tools for manual interaction
31/// and should not be invoked by AI agents
32#[derive(Subcommand)]
33pub enum HumanCommands {
34    #[command(subcommand)]
35    Db(DbCommands),
36    /// Start web interface
37    Web {
38        /// Host to bind to
39        #[arg(short = 'H', long, default_value = "127.0.0.1")]
40        host: String,
41        /// Port to listen on
42        #[arg(short, long, default_value = "8080")]
43        port: u16,
44    },
45}
46
47#[derive(Subcommand)]
48pub enum MailCommands {
49    /// View recent mail for an agent (last 24 hours)
50    Recent {
51        /// Agent ID to view mail for
52        agent_id: String,
53    },
54    /// Send mail from one agent to another (SIMPLE - uses agent names only!)
55    Send {
56        #[arg(short, long)]
57        from: String,
58        #[arg(short, long)]
59        to: String,
60        #[arg(short, long)]
61        subject: String,
62        #[arg(short, long)]
63        body: String,
64    },
65    /// View inbox of an agent
66    Inbox {
67        /// Agent ID to view inbox for
68        agent_id: String,
69    },
70    /// View outbox (sent items) of an agent
71    Outbox {
72        /// Agent ID to view outbox for
73        agent_id: String,
74    },
75    /// Mark mail as read by short ID (first 8 chars of UUID)
76    Read {
77        /// Short mail ID (first 8 characters of UUID)
78        mail_id: String,
79    },
80    /// Check if agent should look at their mail (has unread messages)
81    ShouldLook {
82        /// Agent ID to check
83        agent_id: String,
84    },
85    /// Watch for new mail and execute command when unread mail arrives
86    Watch {
87        /// Agent ID to watch
88        agent_id: String,
89        /// Interval in seconds between checks
90        #[arg(short, long, default_value = "60")]
91        interval: u64,
92        /// Bash command to execute when unread mail is found
93        #[arg(short, long)]
94        bash: String,
95    },
96    /// Search mail by subject or body content
97    Search {
98        /// Agent ID to search mail for
99        agent_id: String,
100        /// Search query string (searches in subject and body)
101        query: String,
102    },
103}
104
105#[derive(Subcommand)]
106pub enum AgentCommands {
107    /// Register a new agent
108    Register {
109        #[arg(short, long)]
110        name: String,
111    },
112    /// Unregister an agent (remove from the system)
113    Unregister {
114        /// Agent ID to remove
115        agent_id: String,
116    },
117    /// List all agents
118    List,
119    /// Get agent details
120    Get {
121        #[arg(short, long)]
122        id: String,
123    },
124    /// Set agent status (online, offline, away, etc.)
125    Status {
126        #[arg(short, long)]
127        id: String,
128        #[arg(short, long)]
129        status: String,
130    },
131}
132
133#[derive(Subcommand)]
134pub enum DbCommands {
135    /// Setup database tables (drops existing tables if they exist)
136    Setup,
137    /// Reset the entire database - drops all data and recreates fresh tables
138    Reset,
139}
140
141/// Simplified KB commands - shared knowledge base, only Luhmann IDs
142#[derive(Subcommand)]
143pub enum KbCommands {
144    /// Create a new note (auto-generates ID unless --id specified)
145    /// Usage: kb create "Title" "Content"  OR  kb create --id 1a "Title" "Content"
146    Create {
147        /// Optional Luhmann ID (e.g., 1a, 1a1). If not provided, auto-generates next available ID
148        #[arg(short, long)]
149        id: Option<String>,
150        /// Note title
151        title: String,
152        /// Note content
153        content: String,
154    },
155    /// Create a child note (branch) from a parent
156    /// Usage: kb branch 1 "Child Title" "Content"
157    Branch {
158        /// Parent Luhmann ID
159        parent_luhmann_id: String,
160        /// Note title
161        title: String,
162        /// Note content
163        content: String,
164    },
165    /// List all notes (sorted by Luhmann ID)
166    List,
167    /// Get a specific note by Luhmann ID
168    /// Usage: kb get 1a
169    Get {
170        /// Luhmann ID
171        luhmann_id: String,
172    },
173    /// Link two notes together
174    /// Usage: kb link 1a 1b
175    Link {
176        /// Source Luhmann ID
177        from_luhmann_id: String,
178        /// Target Luhmann ID
179        to_luhmann_id: String,
180        /// Optional context for the link
181        #[arg(short, long)]
182        context: Option<String>,
183    },
184    /// Search notes
185    /// Usage: kb search "query"
186    Search {
187        /// Search query
188        query: String,
189    },
190    /// Show notes by Luhmann ID prefix
191    /// Usage: kb tree 1a
192    Tree {
193        /// Luhmann ID prefix
194        prefix: String,
195    },
196    /// Mark that note A continues on note B (linear chain)
197    /// Usage: kb cont 1a 1b
198    Cont {
199        /// Source Luhmann ID (the note that continues)
200        from_luhmann_id: String,
201        /// Target Luhmann ID (the continuation)
202        to_luhmann_id: String,
203    },
204    /// Create an index card listing all children of a note
205    /// Usage: kb index 1a
206    Index {
207        /// Luhmann ID to create index for
208        luhmann_id: String,
209    },
210    /// Show full context of a note (parent, children, links, continuations, backlinks)
211    /// Usage: kb context 1a
212    Context {
213        /// Luhmann ID to show context for
214        luhmann_id: String,
215    },
216}