vtcode-core 0.99.2

Core library for VT Code - a Rust-based terminal coding agent
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
//! Man page generation for VT Code CLI using roff-rs
//!
//! This module provides functionality to generate Unix man pages for VT Code
//! commands and subcommands using the roff-rs library.

use anyhow::{Context, Result, bail};
use roff::{Roff, bold, italic, roman};
use std::path::Path;
use tokio::fs;

/// Man page generator for VT Code CLI
pub struct ManPageGenerator;

impl ManPageGenerator {
    /// Get current date in YYYY-MM-DD format
    fn current_date() -> String {
        use chrono::Utc;
        Utc::now().format("%Y-%m-%d").to_string()
    }

    /// Generate man page for the main VT Code command
    pub fn generate_main_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control("TH", ["VTCODE", "1", &current_date, "VT Code", "User Commands"])
            .control("SH", ["NAME"])
            .text([roman("vtcode - Advanced coding agent with Decision Ledger")])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] ["),
                bold("COMMAND"),
                roman("] ["),
                bold("ARGS"),
                roman("]"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("VT Code is an advanced coding agent with single-agent architecture and Decision Ledger that provides"),
                roman(" intelligent code generation, analysis, and modification capabilities. It supports"),
                roman(" multiple LLM providers including Gemini, OpenAI, Anthropic, DeepSeek, Z.AI,"),
                roman(" Moonshot AI, OpenRouter, and Ollama, and includes LLM-native semantic code understanding."),
                roman(" Rust, Python, JavaScript, TypeScript, Go, and Java."),
            ])
            .control("SH", ["OPTIONS"])
            .control("TP", [])
            .text([bold("-m"), roman(", "), bold("--model"), roman(" "), italic("MODEL")])
            .text([roman("Specify the LLM model to use (default: gemini-3-flash-preview)")])
            .control("TP", [])
            .text([bold("-p"), roman(", "), bold("--provider"), roman(" "), italic("PROVIDER")])
            .text([
                roman(
                    "Specify the LLM provider (gemini, openai, anthropic, deepseek, zai, moonshot, openrouter, ollama, lmstudio)",
                ),
            ])
            .control("TP", [])
            .text([bold("--workspace"), roman(" "), italic("PATH")])
            .text([roman("Set the workspace root directory for file operations")])
            .control("TP", [])
            .text([bold("--performance-monitoring")])
            .text([roman("Enable performance monitoring and metrics")])
            .control("TP", [])
            .text([bold("--research-preview")])
            .text([roman("Enable research-preview features")])
            .control("TP", [])
            .text([bold("--debug")])
            .text([roman("Enable debug output")])
            .control("TP", [])
            .text([bold("--verbose")])
            .text([roman("Enable verbose logging")])
            .control("TP", [])
            .text([bold("-h"), roman(", "), bold("--help")])
            .text([roman("Display help information")])
            .control("TP", [])
            .text([bold("-V"), roman(", "), bold("--version")])
            .text([roman("Display version information")])
            .control("SH", ["COMMANDS"])
            .control("TP", [])
            .text([bold("chat")])
            .text([roman("Start interactive AI coding assistant")])
            .control("TP", [])
            .text([bold("ask"), roman(" "), italic("PROMPT")])
            .text([roman("Single prompt mode without tools")])
            .control("TP", [])
            .text([bold("performance")])
            .text([roman("Display performance metrics and system status")])
            .control("TP", [])
            .text([bold("benchmark")])
            .text([roman("Run SWE-bench evaluation framework")])
            .control("TP", [])
            .text([bold("create-project"), roman(" "), italic("NAME"), roman(" "), italic("FEATURES")])
            .text([roman("Create complete Rust project with features")])
            .control("TP", [])
            .text([bold("init")])
            .text([roman("Guided AGENTS.md and workspace setup")])
            .control("TP", [])
            .text([bold("man"), roman(" "), italic("COMMAND")])
            .text([roman("Generate or display man pages for commands")])
            .control("TP", [])
            .text([bold("check"), roman(" "), italic("SUBCOMMAND")])
            .text([roman("Run built-in repository checks")])
            .control("TP", [])
            .text([bold("acp")])
            .text([roman("Start Agent Client Protocol bridge for IDE integrations")])
            .control("TP", [])
            .text([bold("chat-verbose")])
            .text([roman("Verbose interactive chat with enhanced transparency")])
            .control("TP", [])
            .text([bold("performance")])
            .text([roman("Display performance metrics and system status")])
            .control("TP", [])
            .text([bold("trajectory")])
            .text([roman("Pretty-print trajectory logs and show basic analytics")])
            .control("TP", [])
            .text([bold("benchmark")])
            .text([roman("Benchmark against SWE-bench evaluation framework")])
            .control("TP", [])
            .text([bold("create-project"), roman(" "), italic("name"), roman(" "), italic("features")])
            .text([roman("Create complete Rust project with advanced features")])
            .control("TP", [])

            .control("TP", [])
            .text([bold("revert"), roman(" "), italic("turn")])
            .text([roman("Revert agent to a previous snapshot")])
            .control("TP", [])
            .text([bold("snapshots")])
            .text([roman("List all available snapshots")])
            .control("TP", [])
            .text([bold("cleanup-snapshots")])
            .text([roman("Clean up old snapshots")])
            .control("TP", [])
            .text([bold("init")])
            .text([roman("Initialize project with enhanced dot-folder structure")])
            .control("TP", [])
            .text([bold("init-project")])
            .text([roman("Initialize project with dot-folder structure")])
            .control("TP", [])
            .text([bold("config")])
            .text([roman("Generate configuration file")])
            .control("TP", [])
            .text([bold("tool-policy")])
            .text([roman("Manage tool execution policies")])
            .control("TP", [])
            .text([bold("mcp")])
            .text([roman("Manage Model Context Protocol providers")])
            .control("TP", [])
            .text([bold("models")])
            .text([roman("Manage models and providers")])
            .control("SH", ["EXAMPLES"])
            .text([roman("Start interactive chat:")])
            .text([bold("  vtcode chat")])
            .text([roman("Ask a question:")])
            .text([bold("  vtcode ask \"Explain Rust ownership\"")])
            .text([roman("Create a web project:")])
            .text([bold("  vtcode create-project myapp web,auth,db")])
            .text([roman("Generate man page:")])
            .text([bold("  vtcode man chat")])
            .text([roman("Run ast-grep checks for the current workspace:")])
            .text([bold("  vtcode check ast-grep")])
            .control("SH", ["ENVIRONMENT"])
            .control("TP", [])
            .text([bold("GEMINI_API_KEY")])
            .text([roman("API key for Google Gemini (default provider)")])
            .control("TP", [])
            .text([bold("OPENAI_API_KEY")])
            .text([roman("API key for OpenAI GPT models")])
            .control("TP", [])
            .text([bold("ANTHROPIC_API_KEY")])
            .text([roman("API key for Anthropic Claude models")])
            .control("TP", [])
            .text([bold("DEEPSEEK_API_KEY")])
            .text([roman("API key for DeepSeek models")])
            .control("TP", [])
            .text([bold("ZAI_API_KEY")])
            .text([roman("API key for Z.AI GLM models")])
            .control("TP", [])
            .text([bold("MOONSHOT_API_KEY")])
            .text([roman("API key for Moonshot AI Kimi models")])
            .control("TP", [])
            .text([bold("OPENROUTER_API_KEY")])
            .text([roman("API key for OpenRouter models")])
            .control("SH", ["FILES"])
            .control("TP", [])
            .text([bold("vtcode.toml")])
            .text([roman("Configuration file (current directory or ~/.vtcode/)")])
            .control("TP", [])
            .text([bold(".vtcode/")])
            .text([roman("Project cache and context directory")])
            .control("SH", ["SAFETY"])
            .control("TP", [])
            .text([roman(
                "apply_patch: reserve for reviewed diffs or small batches. For large refactors or critical files, stage local backups and prefer edit_file/write_file to avoid partial rewrites if a patch fails.",
            )])
            .control("TP", [])
            .text([roman(
                "Timeout governance: tune [timeouts] in vtcode.toml to clamp tool duration. VT Code warns once execution passes the configured warning threshold so you can cancel runaway commands.",
            )])
            .control("SH", ["SEE ALSO"])
            .text([roman("Full documentation: https://github.com/vinhnx/vtcode")])
            .text([roman("Related commands: cargo(1), rustc(1), git(1)")])
            .render();

        Ok(page)
    }

    /// Generate man page for a specific command
    pub fn generate_command_man_page(command: &str) -> Result<String> {
        match command {
            "chat" => Self::generate_chat_man_page(),
            "ask" => Self::generate_ask_man_page(),
            "performance" => Self::generate_performance_man_page(),
            "benchmark" => Self::generate_benchmark_man_page(),
            "check" => Self::generate_check_man_page(),
            "create-project" => Self::generate_create_project_man_page(),
            "init" => Self::generate_init_man_page(),
            "man" => Self::generate_man_man_page(),
            _ => bail!("Unknown command: {}", command),
        }
    }

    /// Generate man page for the chat command
    fn generate_chat_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control("TH", ["VTCODE-CHAT", "1", &current_date, "VT Code", "User Commands"])
            .control("SH", ["NAME"])
            .text([roman("vtcode-chat - Interactive AI coding assistant")])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("chat"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("Start an interactive AI coding assistant session."),
                roman(" The chat command provides intelligent code generation, analysis, and modification"),
                roman(" with support for multiple LLM providers and semantic code analysis."),
            ])
            .control("SH", ["OPTIONS"])
            .text([roman("All global options are supported. See "), bold("vtcode(1)"), roman(" for details.")])
            .control("SH", ["EXAMPLES"])
            .text([roman("Start basic chat session:")])
            .text([bold("  vtcode chat")])
            .text([roman("Start with specific model:")])
            .text([bold("  vtcode --model gemini-3.1-pro-preview chat")])
            .control("SH", ["SEE ALSO"])
            .text([bold("vtcode(1)"), roman(", "), bold("vtcode-ask(1)"), roman(", "), bold("vtcode-analyze(1)")])
            .render();

        Ok(page)
    }

    /// Generate man page for the ask command
    fn generate_ask_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control("TH", ["VTCODE-ASK", "1", &current_date, "VT Code", "User Commands"])
            .control("SH", ["NAME"])
            .text([roman("vtcode-ask - Single prompt mode without tools")])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("ask"),
                roman(" "),
                italic("PROMPT"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("Execute a single prompt without tool usage. This is perfect for quick questions,"),
                roman(" code explanations, and simple queries that don't require file operations or"),
                roman(" complex tool interactions."),
            ])
            .control("SH", ["EXAMPLES"])
            .text([roman("Ask about Rust ownership:")])
            .text([bold("  vtcode ask \"Explain Rust ownership\"")])
            .text([roman("Get code explanation:")])
            .text([bold("  vtcode ask \"What does this regex do: \\w+@\\w+\\.\\w+\"")])
            .control("SH", ["SEE ALSO"])
            .text([bold("vtcode(1)"), roman(", "), bold("vtcode-chat(1)")])
            .render();

        Ok(page)
    }

    /// Generate man page for the analyze command
    /// Generate man page for the performance command
    fn generate_performance_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control(
                "TH",
                [
                    "VTCODE-PERFORMANCE",
                    "1",
                    &current_date,
                    "VT Code",
                    "User Commands",
                ],
            )
            .control("SH", ["NAME"])
            .text([roman(
                "vtcode-performance - Display performance metrics and system status",
            )])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("performance"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("Display comprehensive performance metrics and system status information."),
                roman(" Shows token usage, API costs, response times, tool execution statistics,"),
                roman(" memory usage patterns, and agent performance metrics."),
            ])
            .control("SH", ["METRICS DISPLAYED"])
            .control("TP", [])
            .text([bold("Token Usage")])
            .text([roman("Input/output token counts and API costs")])
            .control("TP", [])
            .text([bold("Response Times")])
            .text([roman("API response latency and processing times")])
            .control("TP", [])
            .text([bold("Tool Execution")])
            .text([roman("Tool call statistics and execution times")])
            .control("TP", [])
            .text([bold("Memory Usage")])
            .text([roman("Memory consumption patterns")])
            .control("TP", [])
            .text([bold("Agent Performance")])
            .text([roman("Single-agent execution metrics")])
            .control("SH", ["EXAMPLES"])
            .text([roman("Show performance metrics:")])
            .text([bold("  vtcode performance")])
            .control("SH", ["SEE ALSO"])
            .text([bold("vtcode(1)"), roman(", "), bold("vtcode-benchmark(1)")])
            .render();

        Ok(page)
    }

    /// Generate man page for the benchmark command
    fn generate_benchmark_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control(
                "TH",
                [
                    "VTCODE-BENCHMARK",
                    "1",
                    &current_date,
                    "VT Code",
                    "User Commands",
                ],
            )
            .control("SH", ["NAME"])
            .text([roman(
                "vtcode-benchmark - Run SWE-bench evaluation framework",
            )])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("benchmark"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman(
                    "Run automated performance testing against the SWE-bench evaluation framework.",
                ),
                roman(" Provides comparative analysis across different models, benchmark scoring,"),
                roman(" and optimization insights for coding tasks."),
            ])
            .control("SH", ["FEATURES"])
            .control("TP", [])
            .text([bold("Automated Testing")])
            .text([roman("Run standardized coding tasks and challenges")])
            .control("TP", [])
            .text([bold("Comparative Analysis")])
            .text([roman("Compare performance across different models")])
            .control("TP", [])
            .text([bold("Benchmark Scoring")])
            .text([roman("Quantitative performance metrics and scores")])
            .control("TP", [])
            .text([bold("Optimization Insights")])
            .text([roman("Recommendations for performance improvements")])
            .control("SH", ["EXAMPLES"])
            .text([roman("Run benchmark suite:")])
            .text([bold("  vtcode benchmark")])
            .control("SH", ["SEE ALSO"])
            .text([
                bold("vtcode(1)"),
                roman(", "),
                bold("vtcode-performance(1)"),
            ])
            .render();

        Ok(page)
    }

    /// Generate man page for the create-project command
    fn generate_create_project_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control(
                "TH",
                [
                    "VTCODE-CREATE-PROJECT",
                    "1",
                    &current_date,
                    "VT Code",
                    "User Commands",
                ],
            )
            .control("SH", ["NAME"])
            .text([roman(
                "vtcode-create-project - Create complete Rust project with features",
            )])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("create-project"),
                roman(" "),
                italic("NAME"),
                roman(" "),
                italic("FEATURES"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("Create a complete Rust project with advanced features and integrations."),
                roman(" Supports web frameworks, database integration, authentication systems,"),
                roman(" testing setup, and security policies."),
            ])
            .control("SH", ["AVAILABLE FEATURES"])
            .text([roman("• web - Web framework (Axum, Rocket, Warp)")])
            .text([roman("• auth - Authentication system")])
            .text([roman("• db - Database integration")])
            .text([roman("• test - Testing setup")])
            .control("SH", ["EXAMPLES"])
            .text([roman("Create web app with auth and database:")])
            .text([bold("  vtcode create-project myapp web,auth,db")])
            .text([roman("Create basic project:")])
            .text([bold("  vtcode create-project simple_app")])
            .control("SH", ["SEE ALSO"])
            .text([bold("vtcode(1)"), roman(", "), bold("vtcode-init(1)")])
            .render();

        Ok(page)
    }

    /// Generate man page for the init command
    fn generate_init_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control(
                "TH",
                [
                    "VTCODE-INIT",
                    "1",
                    &current_date,
                    "VT Code",
                    "User Commands",
                ],
            )
            .control("SH", ["NAME"])
            .text([roman("vtcode-init - Guided AGENTS.md and workspace setup")])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("init"),
                roman(" ["),
                bold("--force"),
                roman("]"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("Bootstrap vtcode.toml, repository memory scaffolding, indexing,"),
                roman(" and a guided root AGENTS.md generated from repository signals."),
                roman(" Existing AGENTS.md files prompt for confirmation unless --force is used."),
            ])
            .control("SH", ["EXAMPLES"])
            .text([roman("Initialize current directory:")])
            .text([bold("  vtcode init")])
            .text([roman("Overwrite an existing AGENTS.md without prompting:")])
            .text([bold("  vtcode init --force")])
            .control("SH", ["SEE ALSO"])
            .text([
                bold("vtcode(1)"),
                roman(", "),
                bold("vtcode-create-project(1)"),
            ])
            .render();

        Ok(page)
    }

    /// Generate man page for the check command
    fn generate_check_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control(
                "TH",
                [
                    "VTCODE-CHECK",
                    "1",
                    &current_date,
                    "VT Code",
                    "User Commands",
                ],
            )
            .control("SH", ["NAME"])
            .text([roman("vtcode-check - Run built-in repository checks")])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("check"),
                roman(" "),
                bold("ast-grep"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("Run built-in checks against the current workspace. The "),
                bold("ast-grep"),
                roman(" subcommand runs "),
                bold("ast-grep test --config sgconfig.yml"),
                roman(" followed by "),
                bold("ast-grep scan --config sgconfig.yml"),
                roman("."),
            ])
            .control("SH", ["PREREQUISITES"])
            .text([roman("Install ast-grep with:")])
            .text([bold("  vtcode dependencies install ast-grep")])
            .text([roman("Materialize the local scaffold with:")])
            .text([bold("  vtcode init")])
            .control("SH", ["EXAMPLES"])
            .text([roman("Run ast-grep rule tests and scan:")])
            .text([bold("  vtcode check ast-grep")])
            .control("SH", ["SEE ALSO"])
            .text([
                bold("vtcode(1)"),
                roman(", "),
                bold("vtcode-init(1)"),
                roman(", "),
                bold("vtcode-man(1)"),
            ])
            .render();

        Ok(page)
    }

    /// Generate man page for the man command itself
    fn generate_man_man_page() -> Result<String> {
        let current_date = Self::current_date();
        let page = Roff::new()
            .control("TH", ["VTCODE-MAN", "1", &current_date, "VT Code", "User Commands"])
            .control("SH", ["NAME"])
            .text([roman("vtcode-man - Generate or display man pages for VT Code commands")])
            .control("SH", ["SYNOPSIS"])
            .text([
                bold("vtcode"),
                roman(" ["),
                bold("OPTIONS"),
                roman("] "),
                bold("man"),
                roman(" ["),
                italic("COMMAND"),
                roman("] ["),
                bold("--output"),
                roman(" "),
                italic("FILE"),
                roman("]"),
            ])
            .control("SH", ["DESCRIPTION"])
            .text([
                roman("Generate or display Unix man pages for VT Code commands. Man pages provide"),
                roman(" detailed documentation for all VT Code functionality including usage examples,"),
                roman(" option descriptions, and feature explanations."),
            ])
            .control("SH", ["OPTIONS"])
            .control("TP", [])
            .text([bold("--output"), roman(" "), italic("FILE")])
            .text([roman("Write man page to specified file instead of displaying")])
            .control("SH", ["AVAILABLE COMMANDS"])
            .text([roman("• chat - Interactive AI coding assistant")])
            .text([roman("• ask - Single prompt mode")])
            .text([roman("• analyze - Workspace analysis")])
            .text([roman("• performance - Performance metrics")])
            .text([roman("• trajectory - Pretty-print trajectory logs and analytics")])
            .text([roman("• benchmark - SWE-bench evaluation framework")])
            .text([roman("• create-project - Create complete Rust project with features")])

            .text([roman("• revert - Revert agent to a previous snapshot")])
            .text([roman("• snapshots - List available snapshots")])
            .text([roman("• cleanup-snapshots - Clean up old snapshots")])
            .text([roman("• init - Initialize project with enhanced structure")])
            .text([roman("• init-project - Initialize project with dot-folder structure")])
            .text([roman("• config - Generate configuration file")])
            .text([roman("• tool-policy - Manage tool execution policies")])
            .text([roman("• mcp - Manage Model Context Protocol providers")])
            .text([roman("• models - Manage models and providers")])
            .text([roman("• acp - Agent Client Protocol bridge for IDE integrations")])
            .text([roman("• chat-verbose - Verbose interactive chat with transparency")])
            .text([roman("• man - Man page generation (this command)")])
            .control("SH", ["EXAMPLES"])
            .text([roman("Display main VT Code man page:")])
            .text([bold("  vtcode man")])
            .text([roman("Display chat command man page:")])
            .text([bold("  vtcode man chat")])
            .text([roman("Save man page to file:")])
            .text([bold("  vtcode man chat --output chat.1")])
            .control("SH", ["SEE ALSO"])
            .text([bold("vtcode(1)"), roman(", "), bold("man(1)")])
            .render();

        Ok(page)
    }

    /// Save man page to file
    pub async fn save_man_page(content: &str, filename: &Path) -> Result<()> {
        fs::write(filename, content)
            .await
            .with_context(|| format!("Failed to write man page to {}", filename.display()))?;
        Ok(())
    }

    /// Get list of available commands for man page generation
    pub fn available_commands() -> Vec<&'static str> {
        vec![
            "chat",
            "ask",
            "analyze",
            "performance",
            "benchmark",
            "create-project",
            "init",
            "man",
        ]
    }
}