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 with Markdown support 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    /// Search mail by subject or body content
86    Search {
87        /// Agent ID to search mail for
88        agent_id: String,
89        /// Search query string (searches in subject and body)
90        query: String,
91    },
92}
93
94#[derive(Subcommand)]
95pub enum AgentCommands {
96    /// Register a new agent
97    Register {
98        #[arg(short, long)]
99        name: String,
100    },
101    /// Unregister an agent (remove from the system)
102    Unregister {
103        /// Agent ID to remove
104        agent_id: String,
105    },
106    /// List all agents
107    List,
108    /// Get agent details
109    Get {
110        #[arg(short, long)]
111        id: String,
112    },
113    /// Set agent status (online, offline, away, etc.)
114    Status {
115        #[arg(short, long)]
116        id: String,
117        #[arg(short, long)]
118        status: String,
119    },
120    /// Run an agent in watch mode - continuously monitor for new mail and execute command when found
121    Run {
122        /// Agent ID to run
123        agent_id: String,
124        /// Bash command to execute when unread mail is found
125        bash: String,
126        /// Interval in seconds between checks
127        #[arg(short, long, default_value = "60")]
128        interval: u64,
129    },
130}
131
132#[derive(Subcommand)]
133pub enum DbCommands {
134    /// Setup database tables (drops existing tables if they exist)
135    Setup,
136    /// Reset the entire database - drops all data and recreates fresh tables
137    Reset,
138}
139
140/// Simplified KB commands - shared knowledge base, only Luhmann IDs
141#[derive(Subcommand)]
142pub enum KbCommands {
143    /// Create a new note (auto-generates ID unless --id specified)
144    /// Usage: kb create "Title" "Content"  OR  kb create --id 1a "Title" "Content"
145    Create {
146        /// Optional Luhmann ID (e.g., 1a, 1a1). If not provided, auto-generates next available ID
147        #[arg(short, long)]
148        id: Option<String>,
149        /// Note title
150        title: String,
151        /// Note content
152        content: String,
153    },
154    /// Create a child note (branch) from a parent
155    /// Usage: kb branch 1 "Child Title" "Content"
156    Branch {
157        /// Parent Luhmann ID
158        parent_luhmann_id: String,
159        /// Note title
160        title: String,
161        /// Note content
162        content: String,
163    },
164    /// List all notes (sorted by Luhmann ID)
165    List,
166    /// Get a specific note by Luhmann ID
167    /// Usage: kb get 1a
168    Get {
169        /// Luhmann ID
170        luhmann_id: String,
171    },
172    /// Link two notes together
173    /// Usage: kb link 1a 1b
174    Link {
175        /// Source Luhmann ID
176        from_luhmann_id: String,
177        /// Target Luhmann ID
178        to_luhmann_id: String,
179        /// Optional context for the link
180        #[arg(short, long)]
181        context: Option<String>,
182    },
183    /// Search notes
184    /// Usage: kb search "query"
185    Search {
186        /// Search query
187        query: String,
188    },
189    /// Show notes by Luhmann ID prefix
190    /// Usage: kb tree 1a
191    Tree {
192        /// Luhmann ID prefix
193        prefix: String,
194    },
195    /// Mark that note A continues on note B (linear chain)
196    /// Usage: kb cont 1a 1b
197    Cont {
198        /// Source Luhmann ID (the note that continues)
199        from_luhmann_id: String,
200        /// Target Luhmann ID (the continuation)
201        to_luhmann_id: String,
202    },
203    /// Create an index card listing all children of a note
204    /// Usage: kb index 1a
205    Index {
206        /// Luhmann ID to create index for
207        luhmann_id: String,
208    },
209    /// Show full context of a note (parent, children, links, continuations, backlinks)
210    /// Usage: kb context 1a
211    Context {
212        /// Luhmann ID to show context for
213        luhmann_id: String,
214    },
215    /// Delete a note by Luhmann ID
216    /// Usage: kb delete 1a
217    Delete {
218        /// Luhmann ID of the note to delete
219        luhmann_id: String,
220    },
221}