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 /// Manage scheduled tasks for agents
24 #[command(subcommand)]
25 Schedule(ScheduleCommands),
26 /// Human-only tools (not for AI agents)
27 #[command(subcommand)]
28 Human(HumanCommands),
29 /// A warm welcome and guide for new AI agents
30 HowWeWork,
31}
32
33/// Commands intended for human use only - these are tools for manual interaction
34/// and should not be invoked by AI agents
35#[derive(Subcommand)]
36pub enum HumanCommands {
37 #[command(subcommand)]
38 Db(DbCommands),
39 /// Start web interface
40 Web {
41 /// Host to bind to
42 #[arg(short = 'H', long, default_value = "127.0.0.1")]
43 host: String,
44 /// Port to listen on
45 #[arg(short, long, default_value = "8080")]
46 port: u16,
47 },
48}
49
50#[derive(Subcommand)]
51pub enum MailCommands {
52 /// View recent mail for an agent (last 24 hours)
53 Recent {
54 /// Agent ID to view mail for
55 agent_id: String,
56 },
57 /// Send mail from one agent to another (SIMPLE - uses agent names only!)
58 Send {
59 #[arg(short, long)]
60 from: String,
61 #[arg(short, long)]
62 to: String,
63 #[arg(short, long)]
64 subject: String,
65 #[arg(short, long)]
66 body: String,
67 },
68 /// View inbox of an agent
69 Inbox {
70 /// Agent ID to view inbox for
71 agent_id: String,
72 },
73 /// View outbox (sent items) of an agent
74 Outbox {
75 /// Agent ID to view outbox for
76 agent_id: String,
77 },
78 /// Mark mail as read by short ID (first 8 chars of UUID)
79 Read {
80 /// Short mail ID (first 8 characters of UUID)
81 mail_id: String,
82 },
83 /// Check if agent should look at their mail (has unread messages)
84 ShouldLook {
85 /// Agent ID to check
86 agent_id: String,
87 },
88 /// Search mail by subject or body content
89 Search {
90 /// Agent ID to search mail for
91 agent_id: String,
92 /// Search query string (searches in subject and body)
93 query: String,
94 },
95}
96
97#[derive(Subcommand)]
98pub enum AgentCommands {
99 /// Register a new agent
100 Register {
101 #[arg(short, long)]
102 name: String,
103 },
104 /// Unregister an agent (remove from the system)
105 Unregister {
106 /// Agent ID to remove
107 agent_id: String,
108 },
109 /// List all agents
110 List,
111 /// Get agent details
112 Get {
113 #[arg(short, long)]
114 id: String,
115 },
116 /// Set agent status (online, offline, away, etc.)
117 Status {
118 #[arg(short, long)]
119 id: String,
120 #[arg(short, long)]
121 status: String,
122 },
123 /// Run an agent in watch mode - continuously monitor for new mail and execute command when found
124 Run {
125 /// Agent ID to run
126 agent_id: String,
127 /// Bash command to execute when unread mail is found
128 bash: String,
129 /// Interval in seconds between checks
130 #[arg(short, long, default_value = "60")]
131 interval: u64,
132 },
133}
134
135#[derive(Subcommand)]
136pub enum DbCommands {
137 /// Setup database tables (drops existing tables if they exist)
138 Setup,
139 /// Reset the entire database - drops all data and recreates fresh tables
140 Reset,
141}
142
143/// Simplified KB commands - shared knowledge base, only Luhmann IDs
144#[derive(Subcommand)]
145pub enum KbCommands {
146 /// Create a new note (auto-generates ID unless --id specified)
147 /// Usage: kb create "Title" "Content" OR kb create --id 1a "Title" "Content"
148 Create {
149 /// Optional Luhmann ID (e.g., 1a, 1a1). If not provided, auto-generates next available ID
150 #[arg(short, long)]
151 id: Option<String>,
152 /// Note title
153 title: String,
154 /// Note content
155 content: String,
156 },
157 /// Create a child note (branch) from a parent
158 /// Usage: kb branch 1 "Child Title" "Content"
159 Branch {
160 /// Parent Luhmann ID
161 parent_luhmann_id: String,
162 /// Note title
163 title: String,
164 /// Note content
165 content: String,
166 },
167 /// List all notes (sorted by Luhmann ID)
168 List,
169 /// Get a specific note by Luhmann ID
170 /// Usage: kb get 1a
171 Get {
172 /// Luhmann ID
173 luhmann_id: String,
174 },
175 /// Link two notes together
176 /// Usage: kb link 1a 1b
177 Link {
178 /// Source Luhmann ID
179 from_luhmann_id: String,
180 /// Target Luhmann ID
181 to_luhmann_id: String,
182 /// Optional context for the link
183 #[arg(short, long)]
184 context: Option<String>,
185 },
186 /// Search notes
187 /// Usage: kb search "query"
188 Search {
189 /// Search query
190 query: String,
191 },
192 /// Show notes by Luhmann ID prefix
193 /// Usage: kb tree 1a
194 Tree {
195 /// Luhmann ID prefix
196 prefix: String,
197 },
198 /// Mark that note A continues on note B (linear chain)
199 /// Usage: kb cont 1a 1b
200 Cont {
201 /// Source Luhmann ID (the note that continues)
202 from_luhmann_id: String,
203 /// Target Luhmann ID (the continuation)
204 to_luhmann_id: String,
205 },
206 /// Create an index card listing all children of a note
207 /// Usage: kb index 1a
208 Index {
209 /// Luhmann ID to create index for
210 luhmann_id: String,
211 },
212 /// Show full context of a note (parent, children, links, continuations, backlinks)
213 /// Usage: kb context 1a
214 Context {
215 /// Luhmann ID to show context for
216 luhmann_id: String,
217 },
218 /// Delete a note by Luhmann ID
219 /// Usage: kb delete 1a
220 Delete {
221 /// Luhmann ID of the note to delete
222 luhmann_id: String,
223 },
224}
225
226#[derive(Subcommand)]
227pub enum ScheduleCommands {
228 /// Create a new schedule for an agent
229 Create {
230 /// Agent ID to create schedule for
231 agent_id: String,
232 /// CRON expression (e.g., "0 9 * * *" for 9am daily, "*/5 * * * *" for every 5 minutes)
233 cron: String,
234 /// Action description - what the agent should do when schedule fires (can include markdown)
235 action: String,
236 },
237 /// List all schedules for an agent
238 List {
239 /// Agent ID to list schedules for
240 agent_id: String,
241 },
242 /// Get a specific schedule
243 Get {
244 /// Schedule ID (full UUID)
245 schedule_id: String,
246 },
247 /// Update a schedule
248 Update {
249 /// Schedule ID to update
250 schedule_id: String,
251 /// New CRON expression
252 #[arg(short, long)]
253 cron: Option<String>,
254 /// New action description
255 #[arg(short, long)]
256 action: Option<String>,
257 },
258 /// Delete a schedule
259 Delete {
260 /// Schedule ID to delete
261 schedule_id: String,
262 },
263 /// Toggle schedule on/off
264 Toggle {
265 /// Schedule ID to toggle
266 schedule_id: String,
267 },
268}