lean-ctx 3.12.10

LeanCTX | OSS: the open-source runtime for the Context Gateway for AI agents. CLI, MCP server, and supported proxy integrations.
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
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
// SPDX-License-Identifier: Apache-2.0
//! Completion spec: Setup, runtime and maintenance commands.

use super::spec::{CommandNode, DynamicKind, FlagSpec};

pub(super) const MODEL: CommandNode = CommandNode {
    name: "model",
    aliases: &[],
    description: "Install and manage local models",
    subcommands: &[
        CommandNode {
            name: "install",
            aliases: &[],
            description: "Install a model",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
        CommandNode {
            name: "status",
            aliases: &[],
            description: "Show installed models",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
        CommandNode {
            name: "remove",
            aliases: &[],
            description: "Remove a model",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
    ],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const TRIAGE: CommandNode = CommandNode {
    name: "triage",
    aliases: &[],
    description: "Inspect semantic triage shadow accuracy",
    subcommands: &[CommandNode {
        name: "accuracy",
        aliases: &[],
        description: "Show semantic-shadow agreement report",
        subcommands: &[],
        flags: &[FlagSpec {
            long: "--json",
            short: None,
            description: "JSON output",
            takes_value: false,
            value_kind: None,
        }],
        positional: None,
        hidden: false,
    }],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const SHELL: CommandNode = CommandNode {
    name: "shell",
    aliases: &[],
    description: "Activate shell integration",
    subcommands: &[],
    flags: &[
        FlagSpec {
            long: "--agent",
            short: Some('a'),
            description: "Agent name",
            takes_value: true,
            value_kind: Some(DynamicKind::Agents),
        },
        FlagSpec {
            long: "--mode",
            short: Some('m'),
            description: "Integration mode",
            takes_value: true,
            value_kind: Some(DynamicKind::Modes),
        },
    ],
    positional: Some(DynamicKind::Shells),
    hidden: false,
};

pub(super) const INIT: CommandNode = CommandNode {
    name: "init",
    aliases: &["setup", "onboard", "install", "bootstrap"],
    description: "Initialize lean-ctx for an agent",
    subcommands: &[],
    flags: &[
        FlagSpec {
            long: "--agent",
            short: Some('a'),
            description: "Agent name",
            takes_value: true,
            value_kind: Some(DynamicKind::Agents),
        },
        FlagSpec {
            long: "--mode",
            short: Some('m'),
            description: "Integration mode",
            takes_value: true,
            value_kind: Some(DynamicKind::Modes),
        },
        FlagSpec {
            long: "--prompt",
            short: None,
            description: "Add the value segment to the shell prompt (`off` removes it)",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--git-trailer",
            short: None,
            description: "Add a lean-ctx trailer to this repo's commits (`off` removes it)",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--agents",
            short: None,
            description: "setup/onboard: configure only these tools (comma-separated, or none)",
            takes_value: true,
            value_kind: Some(DynamicKind::Agents),
        },
        FlagSpec {
            long: "--dry-run",
            short: None,
            description: "Show what would be written; change nothing",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const STATUS: CommandNode = CommandNode {
    name: "status",
    aliases: &[],
    description: "Show current status",
    subcommands: &[],
    flags: &[FlagSpec {
        long: "--json",
        short: None,
        description: "JSON output",
        takes_value: false,
        value_kind: None,
    }],
    positional: None,
    hidden: false,
};

pub(super) const CONFIG: CommandNode = CommandNode {
    name: "config",
    aliases: &[],
    description: "Manage configuration",
    subcommands: &[
        CommandNode {
            name: "get",
            aliases: &[],
            description: "Get a config value",
            subcommands: &[],
            flags: &[],
            positional: Some(DynamicKind::ConfigKeys),
            hidden: false,
        },
        CommandNode {
            name: "set",
            aliases: &[],
            description: "Set a config value",
            subcommands: &[],
            flags: &[],
            positional: Some(DynamicKind::ConfigKeys),
            hidden: false,
        },
        CommandNode {
            name: "edit",
            aliases: &[],
            description: "Open config in editor",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
        CommandNode {
            name: "show",
            aliases: &[],
            description: "Show current config",
            subcommands: &[],
            flags: &[FlagSpec {
                long: "--json",
                short: None,
                description: "JSON output",
                takes_value: false,
                value_kind: None,
            }],
            positional: None,
            hidden: false,
        },
    ],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const PROXY: CommandNode = CommandNode {
    name: "proxy",
    aliases: &["serve"],
    description: "Start the proxy server",
    subcommands: &[
        CommandNode {
            name: "start",
            aliases: &[],
            description: "Start proxy",
            subcommands: &[],
            flags: &[
                FlagSpec {
                    long: "--detach",
                    short: Some('d'),
                    description: "Run in background",
                    takes_value: false,
                    value_kind: None,
                },
                FlagSpec {
                    long: "--port",
                    short: Some('p'),
                    description: "Port number",
                    takes_value: true,
                    value_kind: None,
                },
            ],
            positional: None,
            hidden: false,
        },
        CommandNode {
            name: "stop",
            aliases: &[],
            description: "Stop proxy",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
    ],
    flags: &[
        FlagSpec {
            long: "--port",
            short: Some('p'),
            description: "Port number",
            takes_value: true,
            value_kind: None,
        },
        FlagSpec {
            long: "--detach",
            short: Some('d'),
            description: "Run in background",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const COCKPIT: CommandNode = CommandNode {
    name: "cockpit",
    aliases: &["dashboard"],
    description: "Open the Cockpit (also: dashboard)",
    subcommands: &[
        CommandNode {
            name: "stop",
            aliases: &[],
            description: "Stop the background Cockpit server",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
        CommandNode {
            name: "install",
            aliases: &[],
            description: "Install the Cockpit runtime package",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
    ],
    flags: &[
        FlagSpec {
            long: "--port",
            short: Some('p'),
            description: "Port number",
            takes_value: true,
            value_kind: None,
        },
        FlagSpec {
            long: "--foreground",
            short: None,
            description: "Run the server in this terminal",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--no-open",
            short: None,
            description: "Start without opening a browser",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--export",
            short: None,
            description: "Open the report view (writes the HTML report off a terminal)",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const CACHE: CommandNode = CommandNode {
    name: "cache",
    aliases: &[],
    description: "Manage the cache",
    subcommands: &[
        CommandNode {
            name: "stats",
            aliases: &[],
            description: "Cache statistics",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
        CommandNode {
            name: "clear",
            aliases: &[],
            description: "Clear cache",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
        CommandNode {
            name: "export",
            aliases: &[],
            description: "Export cache",
            subcommands: &[],
            flags: &[],
            positional: None,
            hidden: false,
        },
    ],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const TERSE: CommandNode = CommandNode {
    name: "terse",
    aliases: &["compression"],
    description: "Set compression level",
    subcommands: &[],
    flags: &[],
    positional: Some(DynamicKind::TerseLevel),
    hidden: false,
};

pub(super) const PROFILE: CommandNode = CommandNode {
    name: "profile",
    aliases: &[],
    description: "Manage local context configuration profiles",
    subcommands: &[],
    flags: &[],
    positional: Some(DynamicKind::Profiles),
    hidden: false,
};

pub(super) const GAIN: CommandNode = CommandNode {
    name: "gain",
    aliases: &[],
    description: "Show local context-usage estimates",
    subcommands: &[],
    flags: &[
        FlagSpec {
            long: "--json",
            short: None,
            description: "JSON output",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--by-tool",
            short: None,
            description: "Per-tool local context breakdown",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--web",
            short: None,
            description: "Open the Savings view in the Cockpit",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--live",
            short: None,
            description: "Open the Calls (Ledger) view in the Cockpit",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--terminal",
            short: None,
            description: "Print the report in the terminal instead of opening the Cockpit",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const SPEND: CommandNode = CommandNode {
    name: "spend",
    aliases: &["billing", "finops", "roi"],
    description: "Show cost report",
    subcommands: &[],
    flags: &[
        FlagSpec {
            long: "--json",
            short: None,
            description: "JSON output",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--cache",
            short: None,
            description: "Cache-read share per provider and model",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const INDEX: CommandNode = CommandNode {
    name: "index",
    aliases: &[],
    description: "Build or rebuild search index",
    subcommands: &[],
    flags: &[FlagSpec {
        long: "--force",
        short: Some('f'),
        description: "Force rebuild",
        takes_value: false,
        value_kind: None,
    }],
    positional: None,
    hidden: false,
};

pub(super) const EXPLORE: CommandNode = CommandNode {
    name: "explore",
    aliases: &["repomap", "repo-map"],
    description: "Explore repository structure",
    subcommands: &[],
    flags: &[
        FlagSpec {
            long: "--depth",
            short: Some('d'),
            description: "Max depth",
            takes_value: true,
            value_kind: None,
        },
        FlagSpec {
            long: "--json",
            short: None,
            description: "JSON output",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const COMPRESS: CommandNode = CommandNode {
    name: "compress",
    aliases: &["compact"],
    description: "Compress input",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const UPDATE: CommandNode = CommandNode {
    name: "update",
    aliases: &["upgrade"],
    description: "Update lean-ctx",
    subcommands: &[],
    flags: &[
        FlagSpec {
            long: "--check",
            short: None,
            description: "Check only, don't install",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--dry-run",
            short: None,
            description: "Show the release and the setup refresh; change nothing",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--pin",
            short: None,
            description: "Persist a release version pin",
            takes_value: true,
            value_kind: None,
        },
        FlagSpec {
            long: "--unpin",
            short: None,
            description: "Clear the persistent release pin",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--status",
            short: None,
            description: "Show active and retained binary receipt",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--rollback",
            short: None,
            description: "Restore the retained verified binary",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const STOP: CommandNode = CommandNode {
    name: "stop",
    aliases: &[],
    description: "Stop all lean-ctx processes",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const RESTART: CommandNode = CommandNode {
    name: "restart",
    aliases: &[],
    description: "Restart lean-ctx",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const DEV_INSTALL: CommandNode = CommandNode {
    name: "dev-install",
    aliases: &[],
    description: "Fast development build + atomic install + restart",
    subcommands: &[],
    flags: &[
        FlagSpec {
            long: "--fast",
            short: None,
            description: "Incremental development build (default)",
            takes_value: false,
            value_kind: None,
        },
        FlagSpec {
            long: "--release",
            short: None,
            description: "Use the production release profile",
            takes_value: false,
            value_kind: None,
        },
    ],
    positional: None,
    hidden: false,
};

pub(super) const WRAP: CommandNode = CommandNode {
    name: "wrap",
    aliases: &[],
    description: "One-command setup for an agent",
    subcommands: &[],
    flags: &[],
    positional: Some(DynamicKind::Agents),
    hidden: false,
};

pub(super) const UNWRAP: CommandNode = CommandNode {
    name: "unwrap",
    aliases: &[],
    description: "Undo wrap, restore pre-wrap config",
    subcommands: &[],
    flags: &[],
    positional: Some(DynamicKind::Agents),
    hidden: false,
};

pub(super) const DOCTOR: CommandNode = CommandNode {
    name: "doctor",
    aliases: &[],
    description: "Diagnose installation issues",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const SELFTEST: CommandNode = CommandNode {
    name: "selftest",
    aliases: &["health"],
    description: "Run self-test",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const RULES: CommandNode = CommandNode {
    name: "rules",
    aliases: &[],
    description: "Manage rules",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const EXPORT_RULES: CommandNode = CommandNode {
    name: "export-rules",
    aliases: &[],
    description: "Export rules to file",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const HARDEN: CommandNode = CommandNode {
    name: "harden",
    aliases: &["security", "lockdown"],
    description: "Harden security settings",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const COMPLETIONS: CommandNode = CommandNode {
    name: "completions",
    aliases: &[],
    description: "Generate shell completion script",
    subcommands: &[],
    flags: &[],
    positional: Some(DynamicKind::Shells),
    hidden: false,
};

pub(super) const GOTCHAS: CommandNode = CommandNode {
    name: "gotchas",
    aliases: &["bugs"],
    description: "Show known gotchas",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};

pub(super) const LEARN: CommandNode = CommandNode {
    name: "learn",
    aliases: &[],
    description: "Interactive learning",
    subcommands: &[],
    flags: &[],
    positional: None,
    hidden: false,
};