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 (default: 60)
130 #[arg(short, long, default_value = "60")]
131 interval: u64,
132 },
133 /// Set agent session ID for consistent session tracking
134 SetSession {
135 /// Agent ID to set session for
136 agent_id: String,
137 /// Session ID (optional - if not provided, clears the session)
138 session_id: Option<String>,
139 },
140}
141
142#[derive(Subcommand)]
143pub enum DbCommands {
144 /// Setup database tables (drops existing tables if they exist)
145 Setup,
146 /// Reset the entire database - drops all data and recreates fresh tables
147 Reset,
148}
149
150/// Simplified KB commands - shared knowledge base, only Luhmann IDs
151#[derive(Subcommand)]
152pub enum KbCommands {
153 /// Create a new note (auto-generates ID unless --id specified)
154 /// Usage: kb create "Title" "Content" OR kb create --id 1a "Title" "Content"
155 Create {
156 /// Optional Luhmann ID (e.g., 1a, 1a1). If not provided, auto-generates next available ID
157 #[arg(short, long)]
158 id: Option<String>,
159 /// Note title
160 title: String,
161 /// Note content
162 content: String,
163 },
164 /// Create a child note (branch) from a parent
165 /// Usage: kb branch 1 "Child Title" "Content"
166 Branch {
167 /// Parent Luhmann ID
168 parent_luhmann_id: String,
169 /// Note title
170 title: String,
171 /// Note content
172 content: String,
173 },
174 /// List all notes (sorted by Luhmann ID)
175 List,
176 /// Get a specific note by Luhmann ID
177 /// Usage: kb get 1a
178 Get {
179 /// Luhmann ID
180 luhmann_id: String,
181 },
182 /// Link two notes together
183 /// Usage: kb link 1a 1b
184 Link {
185 /// Source Luhmann ID
186 from_luhmann_id: String,
187 /// Target Luhmann ID
188 to_luhmann_id: String,
189 /// Optional context for the link
190 #[arg(short, long)]
191 context: Option<String>,
192 },
193 /// Search notes
194 /// Usage: kb search "query"
195 Search {
196 /// Search query
197 query: String,
198 },
199 /// Show notes by Luhmann ID prefix
200 /// Usage: kb tree 1a
201 Tree {
202 /// Luhmann ID prefix
203 prefix: String,
204 },
205 /// Mark that note A continues on note B (linear chain)
206 /// Usage: kb cont 1a 1b
207 Cont {
208 /// Source Luhmann ID (the note that continues)
209 from_luhmann_id: String,
210 /// Target Luhmann ID (the continuation)
211 to_luhmann_id: String,
212 },
213 /// Create an index card listing all children of a note
214 /// Usage: kb index 1a
215 Index {
216 /// Luhmann ID to create index for
217 luhmann_id: String,
218 },
219 /// Show full context of a note (parent, children, links, continuations, backlinks)
220 /// Usage: kb context 1a
221 Context {
222 /// Luhmann ID to show context for
223 luhmann_id: String,
224 },
225 /// Delete a note by Luhmann ID
226 /// Usage: kb delete 1a
227 Delete {
228 /// Luhmann ID of the note to delete
229 luhmann_id: String,
230 },
231}
232
233#[derive(Subcommand)]
234pub enum ScheduleCommands {
235 /// Create a new schedule for an agent
236 Create {
237 /// Agent ID to create schedule for
238 agent_id: String,
239 /// CRON expression (e.g., "0 9 * * *" for 9am daily, "*/5 * * * *" for every 5 minutes)
240 cron: String,
241 /// Action description - what the agent should do when schedule fires (can include markdown)
242 action: String,
243 },
244 /// List all schedules for an agent
245 List {
246 /// Agent ID to list schedules for
247 agent_id: String,
248 },
249 /// Get a specific schedule
250 Get {
251 /// Schedule ID (full UUID)
252 schedule_id: String,
253 },
254 /// Update a schedule
255 Update {
256 /// Schedule ID to update
257 schedule_id: String,
258 /// New CRON expression
259 #[arg(short, long)]
260 cron: Option<String>,
261 /// New action description
262 #[arg(short, long)]
263 action: Option<String>,
264 },
265 /// Delete a schedule
266 Delete {
267 /// Schedule ID to delete
268 schedule_id: String,
269 },
270 /// Toggle schedule on/off
271 Toggle {
272 /// Schedule ID to toggle
273 schedule_id: String,
274 },
275}