moonlight-cli 0.1.2

Compare command behavior against one or two reference commands.
Documentation
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
use uuid::Uuid;

#[derive(Debug, Parser)]
#[command(
    name = "moonlight",
    bin_name = "moonlight",
    version,
    about = "Compare command behavior with Moonlight's shared comparison engine"
)]
pub(crate) struct Cli {
    #[command(flatten)]
    pub(crate) config: ConfigArgs,

    #[command(subcommand)]
    pub(crate) command: CliCommand,
}

#[derive(Debug, Args)]
pub(crate) struct ConfigArgs {
    #[arg(
        long,
        global = true,
        value_name = "PATH",
        help_heading = "Config",
        conflicts_with = "no_config",
        help = "TOML config file to read instead of ./moonlight.conf"
    )]
    pub(crate) config: Option<PathBuf>,

    #[arg(
        long,
        global = true,
        help_heading = "Config",
        help = "Do not read ./moonlight.conf"
    )]
    pub(crate) no_config: bool,
}

#[derive(Debug, Subcommand)]
pub(crate) enum CliCommand {
    #[command(
        about = "Run one primary/candidate comparison",
        after_help = "Examples:\n  moonlight run --primary 'printf \"{\\\"value\\\":42}\\n\"' --candidate 'printf \"{\\\"value\\\":43}\\n\"'\n  moonlight run --primary-argv '[\"printf\",\"%s\\n\",\"{\\\"value\\\":42}\"]' --candidate-argv '[\"printf\",\"%s\\n\",\"{\\\"value\\\":42}\"]' --compact"
    )]
    Run(RunArgs),
    #[command(
        about = "Run many JSONL comparison cases in one process",
        after_help = "Examples:\n  moonlight batch --input cases.jsonl --jobs 8\n  moonlight batch --input cases.jsonl --emit-runs"
    )]
    Batch(BatchArgs),
    #[command(
        alias = "ls",
        about = "List stored comparison runs newest first",
        after_help = "Examples:\n  moonlight list --limit 20\n  moonlight ls --limit 20 --offset 20 --compact"
    )]
    List(ListArgs),
    #[command(
        about = "Summarize stored comparison runs",
        after_help = "Examples:\n  moonlight stats\n  moonlight stats --compact"
    )]
    Stats(ReadArgs),
    #[command(
        about = "Show a full stored comparison run",
        after_help = "Examples:\n  moonlight show 00000000-0000-0000-0000-000000000000\n  moonlight show 00000000-0000-0000-0000-000000000000 --compact"
    )]
    Show(ShowArgs),
    #[command(
        about = "Render a shareable report for a stored comparison run",
        after_help = "Examples:\n  moonlight report 00000000-0000-0000-0000-000000000000\n  moonlight report 00000000-0000-0000-0000-000000000000 --format json"
    )]
    Report(ReportArgs),
    #[command(
        about = "Set review state for a stored comparison run",
        after_help = "Examples:\n  moonlight review 00000000-0000-0000-0000-000000000000 --status ignored --note 'Known rollout delta'"
    )]
    Review(ReviewArgs),
    #[command(
        about = "List stored run review states",
        after_help = "Examples:\n  moonlight reviews\n  moonlight reviews --status new"
    )]
    Reviews(ReviewsArgs),
    #[command(about = "Evaluate coding-agent patches against existing projects")]
    #[command(subcommand)]
    Eval(EvalCommand),
}

#[derive(Debug, Subcommand)]
pub(crate) enum EvalCommand {
    #[command(
        about = "Run project checks against baseline and candidate worktrees",
        after_help = "Examples:\n  moonlight eval run --project moonlight.eval.toml --candidate-patch agent.patch\n  moonlight eval run --project moonlight.eval.toml --candidate-ref agent/output-branch"
    )]
    Run(EvalRunArgs),
    #[command(
        about = "Render a stored project eval summary",
        after_help = "Examples:\n  moonlight eval report 00000000-0000-0000-0000-000000000000 --format markdown"
    )]
    Report(EvalReportArgs),
}

#[derive(Debug, Args)]
pub(crate) struct StorageArgs {
    #[arg(
        long,
        value_name = "PATH",
        help_heading = "Storage",
        help = "JSONL storage file"
    )]
    pub(crate) storage_path: Option<PathBuf>,
}

#[derive(Debug, Args)]
pub(crate) struct EvalRunArgs {
    #[command(flatten)]
    pub(crate) storage: StorageArgs,

    #[arg(
        long,
        value_name = "PATH",
        default_value = "moonlight.eval.toml",
        help_heading = "Project",
        help = "Project eval TOML config"
    )]
    pub(crate) project: PathBuf,

    #[arg(
        long,
        value_name = "PATH",
        help_heading = "Project",
        help = "Repository path override"
    )]
    pub(crate) repo: Option<PathBuf>,

    #[arg(
        long,
        value_name = "REF",
        help_heading = "Project",
        help = "Baseline ref override"
    )]
    pub(crate) baseline_ref: Option<String>,

    #[arg(
        long,
        value_name = "REF",
        conflicts_with = "candidate_patch",
        help_heading = "Candidate",
        help = "Candidate branch or commit"
    )]
    pub(crate) candidate_ref: Option<String>,

    #[arg(
        long,
        value_name = "PATH",
        conflicts_with = "candidate_ref",
        help_heading = "Candidate",
        help = "Patch to apply on top of the baseline ref"
    )]
    pub(crate) candidate_patch: Option<PathBuf>,

    #[arg(
        long,
        value_name = "FORMAT",
        default_value = "text",
        value_parser = ["text", "json", "markdown"],
        help_heading = "Output",
        help = "Summary output format"
    )]
    pub(crate) format: String,

    #[arg(
        long,
        value_name = "MODE",
        value_parser = ["never", "failed", "always"],
        help_heading = "Execution",
        help = "Override when eval worktrees are kept"
    )]
    pub(crate) keep_worktrees: Option<String>,

    #[arg(
        long,
        value_name = "N",
        help_heading = "Execution",
        help = "Maximum number of checks to run concurrently"
    )]
    pub(crate) jobs: Option<usize>,

    #[arg(long, help_heading = "Output", help = "Suppress summary output")]
    pub(crate) quiet: bool,
}

#[derive(Debug, Args)]
pub(crate) struct EvalReportArgs {
    pub(crate) eval_id: Uuid,

    #[command(flatten)]
    pub(crate) storage: StorageArgs,

    #[arg(
        long,
        value_name = "FORMAT",
        default_value = "markdown",
        value_parser = ["text", "json", "markdown"],
        help_heading = "Output",
        help = "Summary output format"
    )]
    pub(crate) format: String,
}

#[derive(Debug, Args)]
pub(crate) struct ReadArgs {
    #[command(flatten)]
    pub(crate) storage: StorageArgs,

    #[arg(long, help_heading = "Output", help = "Print compact JSON")]
    pub(crate) compact: bool,
}

#[derive(Debug, Args)]
pub(crate) struct ListArgs {
    #[command(flatten)]
    pub(crate) output: ReadArgs,

    #[arg(
        long,
        help_heading = "Output",
        help = "Maximum number of newest runs to print"
    )]
    pub(crate) limit: Option<usize>,

    #[arg(
        long,
        default_value_t = 0,
        help_heading = "Output",
        help = "Number of newest runs to skip"
    )]
    pub(crate) offset: usize,

    #[arg(
        long,
        value_name = "CLASSIFICATION",
        value_parser = ["match", "suspicious_difference", "reference_noise", "suspicious_with_noise", "target_error"],
        help_heading = "Filters",
        help = "Only list runs with this classification"
    )]
    pub(crate) classification: Option<String>,

    #[arg(
        long,
        value_name = "ADAPTER",
        value_parser = ["http", "cli", "project"],
        help_heading = "Filters",
        help = "Only list runs from this adapter"
    )]
    pub(crate) adapter: Option<String>,

    #[arg(
        long = "query",
        alias = "q",
        value_name = "TEXT",
        help_heading = "Filters",
        help = "Search run input text"
    )]
    pub(crate) query: Option<String>,

    #[arg(
        long,
        value_name = "STATUS",
        help_heading = "Filters",
        help = "Only list runs where any target has this status"
    )]
    pub(crate) status: Option<u16>,
}

#[derive(Debug, Args)]
pub(crate) struct ShowArgs {
    pub(crate) id: Uuid,

    #[command(flatten)]
    pub(crate) output: ReadArgs,
}

#[derive(Debug, Args)]
pub(crate) struct ReportArgs {
    pub(crate) id: Uuid,

    #[command(flatten)]
    pub(crate) storage: StorageArgs,

    #[arg(
        long,
        value_name = "FORMAT",
        default_value = "markdown",
        value_parser = ["markdown", "json"],
        help_heading = "Output",
        help = "Report output format"
    )]
    pub(crate) format: String,
}

#[derive(Debug, Args)]
pub(crate) struct ReviewArgs {
    pub(crate) id: Uuid,

    #[arg(
        long,
        value_name = "STATUS",
        value_parser = ["new", "accepted", "ignored", "fixed"],
        help = "Review status to store"
    )]
    pub(crate) status: String,

    #[arg(long, value_name = "TEXT", help = "Optional review note")]
    pub(crate) note: Option<String>,

    #[arg(
        long = "tag",
        value_name = "TAG",
        help = "Review tag; repeat to add multiple tags"
    )]
    pub(crate) tags: Vec<String>,
}

#[derive(Debug, Args)]
pub(crate) struct ReviewsArgs {
    #[arg(
        long,
        value_name = "STATUS",
        value_parser = ["new", "accepted", "ignored", "fixed"],
        help = "Only list reviews with this status"
    )]
    pub(crate) status: Option<String>,

    #[arg(long, help_heading = "Output", help = "Print compact JSON")]
    pub(crate) compact: bool,
}

#[derive(Debug, Args)]
pub(crate) struct RunArgs {
    #[command(flatten)]
    pub(crate) storage: StorageArgs,

    #[arg(
        long,
        help_heading = "Target Commands",
        help = "Primary reference shell command run through sh -lc"
    )]
    pub(crate) primary: Option<String>,

    #[arg(
        long,
        value_name = "JSON",
        help_heading = "Target Commands",
        help = "Primary reference argv as a JSON string array, bypassing sh -lc"
    )]
    pub(crate) primary_argv: Option<String>,

    #[arg(
        long,
        help_heading = "Target Commands",
        help = "Candidate shell command run through sh -lc"
    )]
    pub(crate) candidate: Option<String>,

    #[arg(
        long,
        value_name = "JSON",
        help_heading = "Target Commands",
        help = "Candidate argv as a JSON string array, bypassing sh -lc"
    )]
    pub(crate) candidate_argv: Option<String>,

    #[arg(
        long,
        help_heading = "Target Commands",
        help = "Optional secondary reference shell command run through sh -lc"
    )]
    pub(crate) secondary: Option<String>,

    #[arg(
        long,
        value_name = "JSON",
        help_heading = "Target Commands",
        help = "Optional secondary reference argv as a JSON string array"
    )]
    pub(crate) secondary_argv: Option<String>,

    #[arg(
        long,
        value_name = "BYTES",
        help_heading = "Comparison",
        help = "Maximum stdout/stderr body bytes to store"
    )]
    pub(crate) max_body_capture_bytes: Option<usize>,

    #[arg(
        long = "ignore-json-path",
        value_name = "PATH",
        help_heading = "Comparison",
        help = "Exact JSON diff path to ignore"
    )]
    pub(crate) ignore_json_paths: Vec<String>,

    #[arg(
        long = "ignore-json-path-pattern",
        value_name = "PATTERN",
        help_heading = "Comparison",
        help = "JSON diff path pattern to ignore; supports * and [*]"
    )]
    pub(crate) ignore_json_path_patterns: Vec<String>,

    #[arg(
        long = "redact-json-path",
        value_name = "PATH",
        help_heading = "Redaction",
        help = "Exact JSON body path to redact from stored previews and diffs"
    )]
    pub(crate) redact_json_paths: Vec<String>,

    #[arg(
        long = "redact-json-path-pattern",
        value_name = "PATTERN",
        help_heading = "Redaction",
        help = "JSON body path pattern to redact from stored previews and diffs; supports * and [*]"
    )]
    pub(crate) redact_json_path_patterns: Vec<String>,

    #[arg(
        long = "ignore-header",
        value_name = "HEADER",
        help_heading = "Comparison",
        help = "Header name to ignore during comparison"
    )]
    pub(crate) ignore_headers: Vec<String>,

    #[arg(long, help_heading = "Comparison", help = "Ignore stderr differences")]
    pub(crate) ignore_stderr: bool,

    #[arg(
        long,
        value_name = "MS",
        help_heading = "Execution",
        help = "Per-target timeout in milliseconds; 0 uses the default"
    )]
    pub(crate) target_timeout_ms: Option<u64>,

    #[arg(
        long,
        help_heading = "Execution",
        help = "Run primary, candidate, and secondary targets sequentially"
    )]
    pub(crate) serial_targets: bool,

    #[arg(long, help_heading = "Output", help = "Print no run JSON to stdout")]
    pub(crate) quiet: bool,

    #[arg(
        long,
        help_heading = "Output",
        help = "Print one-line JSON instead of pretty JSON"
    )]
    pub(crate) compact: bool,
}

#[derive(Debug, Args)]
pub(crate) struct BatchArgs {
    #[command(flatten)]
    pub(crate) storage: StorageArgs,

    #[arg(
        long,
        value_name = "PATH",
        help_heading = "Input",
        help = "JSONL batch input path, or - for stdin"
    )]
    pub(crate) input: Option<PathBuf>,

    #[arg(
        long,
        value_name = "N",
        help_heading = "Execution",
        help = "Maximum number of cases to run concurrently"
    )]
    pub(crate) jobs: Option<usize>,

    #[arg(
        long,
        help_heading = "Output",
        help = "Suppress the final batch summary"
    )]
    pub(crate) quiet: bool,

    #[arg(
        long,
        help_heading = "Output",
        help = "Print compact run JSONL records as cases complete"
    )]
    pub(crate) emit_runs: bool,

    #[arg(
        long,
        help_heading = "Execution",
        help = "Run primary, candidate, and secondary targets sequentially per case"
    )]
    pub(crate) serial_targets: bool,
}