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
use anyhow::Result;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
mod actions;
mod agents;
mod board;
mod build;
mod ctx;
mod dev;
mod freshness;
mod icons;
mod id;
mod init;
mod links;
mod llms;
mod manifest;
mod mcp;
mod minify;
mod prompts;
mod render;
mod search;
mod theme;
mod track;
mod types;
mod validate;
mod voice;
mod wish;
mod workspace;
#[derive(Parser)]
#[command(name = "kazam", about = "Beautiful sites from simple YAML", version)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
/// Build a site from a directory of .yaml files
Build {
#[arg(default_value = ".")]
dir: PathBuf,
#[arg(short, long, default_value = "_site")]
out: PathBuf,
/// Minify HTML, CSS, and JS in the output
#[arg(short, long)]
release: bool,
/// Silence the orphan-page check (broken links still reported).
/// Useful for draft pages you haven't wired into nav yet.
#[arg(long)]
allow_orphans: bool,
/// Emit structured NDJSON instead of human-readable output
#[arg(long)]
json: bool,
/// Skip emitting site.json manifest
#[arg(long)]
no_manifest: bool,
/// Skip emitting search.json index
#[arg(long)]
no_search: bool,
},
/// Watch source, rebuild on change, serve at localhost:PORT
Dev {
#[arg(default_value = ".")]
dir: PathBuf,
#[arg(short, long, default_value = "_site")]
out: PathBuf,
#[arg(short, long, default_value_t = 3000)]
port: u16,
},
/// Scaffold a new kazam site in <NAME>/
Init { name: String },
/// Print the LLM authoring guide (full AGENTS.md to stdout)
Agents,
/// Grant a wish — populated YAML from a workspace full of your context.
Wish {
/// Name of the wish (e.g., "deck", or "list" to see all)
name: String,
#[arg(short, long)]
out: Option<PathBuf>,
#[arg(long, value_enum)]
agent: Option<wish::Agent>,
#[arg(long)]
stdout: bool,
#[arg(long)]
dry_run: bool,
#[arg(long, value_name = "TOPIC", num_args = 0..=1, default_missing_value = "")]
yolo: Option<String>,
},
/// Manage the work graph — tasks, dependencies, activity log.
Track {
#[command(subcommand)]
command: track::Command,
/// Project directory (default: current directory)
#[arg(short, long, default_value = ".", global = true)]
dir: PathBuf,
},
/// Manage context intelligence — file anatomy, learnings, bugs.
Ctx {
#[command(subcommand)]
command: ctx::Command,
/// Project directory (default: current directory)
#[arg(short, long, default_value = ".", global = true)]
dir: PathBuf,
},
/// Live dashboard — renders .kazam/ state as a visual board.
Board {
/// Project directory (default: current directory)
#[arg(default_value = ".")]
dir: PathBuf,
#[arg(short, long, default_value_t = 3001)]
port: u16,
},
/// Initialize the full agent workspace (track + ctx + hooks) in one shot.
Workspace {
#[command(subcommand)]
command: WorkspaceCommand,
/// Project directory (default: current directory)
#[arg(short, long, default_value = ".", global = true)]
dir: PathBuf,
},
/// Validate page YAML files against component schemas and structural rules.
Validate {
/// Directory of .yaml source files to validate (default: current directory)
#[arg(default_value = ".")]
dir: PathBuf,
/// Human-readable output (default is JSON)
#[arg(long)]
pretty: bool,
},
/// Run an MCP server over stdio for AI client integration
Mcp {
/// Site directory to serve
#[arg(default_value = ".")]
dir: PathBuf,
/// Allow write operations (write_page tool)
#[arg(long)]
allow_writes: bool,
/// Transport: stdio (default) or http
#[arg(long, default_value = "stdio")]
transport: String,
/// Port for HTTP transport
#[arg(long, default_value = "8080")]
port: u16,
},
/// Show freshness status for all pages in the site
Freshness {
#[command(subcommand)]
command: Option<FreshnessCommand>,
/// Site directory
#[arg(default_value = ".", global = true)]
dir: PathBuf,
},
/// Show or manage the site's voice configuration
Voice {
/// Site directory
#[arg(default_value = ".")]
dir: PathBuf,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Manage prompt templates for agent workflows
Prompt {
#[command(subcommand)]
command: prompts::Command,
/// Project directory (default: current directory)
#[arg(short, long, default_value = ".", global = true)]
dir: PathBuf,
},
/// Manage GitHub Action workflow templates
Actions {
#[command(subcommand)]
command: ActionsCommand,
/// Project directory (default: current directory)
#[arg(short, long, default_value = ".", global = true)]
dir: PathBuf,
},
}
fn main() -> Result<()> {
match Cli::parse().command {
Command::Build {
dir,
out,
release,
allow_orphans,
json,
no_manifest,
no_search,
} => build::run(
&dir,
&out,
release,
allow_orphans,
json,
no_manifest,
no_search,
),
Command::Dev { dir, out, port } => dev::run(&dir, &out, port),
Command::Init { name } => init::run(&name),
Command::Agents => agents::run(),
Command::Wish {
name,
out,
agent,
stdout,
dry_run,
yolo,
} => wish::run(&name, out, agent, stdout, dry_run, yolo),
Command::Track { command, dir } => track::run(command, &dir),
Command::Ctx { command, dir } => ctx::run(command, &dir),
Command::Board { dir, port } => board::run(&dir, port),
Command::Workspace { command, dir } => workspace::run_command(command, &dir),
Command::Validate { dir, pretty } => {
let errors = validate::validate_dir(&dir);
if pretty {
validate::print_pretty(&errors);
} else {
println!("{}", serde_json::to_string_pretty(&errors)?);
}
if !errors.is_empty() {
std::process::exit(1);
}
Ok(())
}
Command::Mcp {
dir,
allow_writes,
transport,
port,
} => match transport.as_str() {
"http" => mcp::run_http(&dir, allow_writes, port),
_ => mcp::run(&dir, allow_writes),
},
Command::Freshness { command, dir } => match command {
None | Some(FreshnessCommand::Show { .. }) => {
let (pretty, threshold) = match command {
Some(FreshnessCommand::Show { pretty, threshold }) => (pretty, threshold),
_ => (false, None),
};
freshness::run_command(&dir, pretty, threshold)
}
Some(FreshnessCommand::Review { json }) => freshness::run_review(&dir, json),
Some(FreshnessCommand::Act { path, action }) => {
freshness::run_act(&dir, &path, &action)
}
},
Command::Voice { dir, json } => voice::run(&dir, json),
Command::Prompt { command, dir } => prompts::run(command, &dir),
Command::Actions { command, dir } => match command {
ActionsCommand::List => actions::list(),
ActionsCommand::Init { name } => actions::init(&name, &dir),
},
}
}
#[derive(Subcommand)]
pub enum FreshnessCommand {
/// Show freshness status for all pages (default)
Show {
#[arg(long)]
pretty: bool,
#[arg(long)]
threshold: Option<u64>,
},
/// List stale pages for review with recommended actions
Review {
/// Output as JSON (default is human-readable)
#[arg(long)]
json: bool,
},
/// Take action on a stale page: archive, refresh, or skip
Act {
/// Path to the page YAML file (relative to site dir)
path: String,
/// Action to take
#[arg(value_enum)]
action: FreshnessAction,
},
}
#[derive(Clone, clap::ValueEnum)]
pub enum FreshnessAction {
/// Set archived: true on the page
Archive,
/// Update freshness.updated to today's date
Refresh,
}
#[derive(Subcommand)]
pub enum ActionsCommand {
/// List available action templates
List,
/// Initialize an action template in .github/workflows/
Init {
/// Template name (validate, freshness, build)
name: String,
},
}
#[derive(Subcommand)]
pub enum WorkspaceCommand {
/// Initialize track + ctx + scan + hooks in one shot
Init {
/// Agent to register hooks for
#[arg(long, default_value = "claude")]
agent: String,
/// Gitignore .kazam/ for shared repos
#[arg(long)]
skunkworks: bool,
/// Sass level for human blocker callouts (none, some, lots)
#[arg(long, default_value = "some")]
sass: String,
},
/// Show workspace status
Status,
/// Set the sass level for human blocker callouts
Sass {
/// none, some, or lots
level: String,
},
/// Toggle skunkworks mode (gitignore .kazam/)
Skunkworks {
/// enable or disable
action: String,
},
}