@politty/zod 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +561 -0
  3. package/bin/cli.mjs +3 -0
  4. package/dist/arg-registry-YaWTVu_x.d.ts +1025 -0
  5. package/dist/augment.d.ts +15 -0
  6. package/dist/augment.js +1 -0
  7. package/dist/cli-main-Dn88vIyn.js +84 -0
  8. package/dist/cli-run-eibUcgys.js +7 -0
  9. package/dist/cli.d.ts +1 -0
  10. package/dist/cli.js +16 -0
  11. package/dist/command-k-4yAz4J.js +42 -0
  12. package/dist/compile-cache-Ct41pWGL.js +100 -0
  13. package/dist/compile-cache.d.ts +78 -0
  14. package/dist/compile-cache.js +3 -0
  15. package/dist/completion-gtWX3mwP.js +5608 -0
  16. package/dist/completion.d.ts +242 -0
  17. package/dist/completion.js +4 -0
  18. package/dist/docs.d.ts +770 -0
  19. package/dist/docs.js +3044 -0
  20. package/dist/field-meta-DMy5BcRr.js +146 -0
  21. package/dist/index-CvhsecfS.d.ts +455 -0
  22. package/dist/index.d.ts +799 -0
  23. package/dist/index.js +17 -0
  24. package/dist/log-collector-CoUkLVJB.js +114 -0
  25. package/dist/logger-i_bb-Jhc.js +133 -0
  26. package/dist/prompt-CEIZ-7H1.js +171 -0
  27. package/dist/prompt-clack.d.ts +16 -0
  28. package/dist/prompt-clack.js +32 -0
  29. package/dist/prompt-inquirer.d.ts +16 -0
  30. package/dist/prompt-inquirer.js +47 -0
  31. package/dist/prompt.d.ts +106 -0
  32. package/dist/prompt.js +4 -0
  33. package/dist/register-Bk0K83W2.js +439 -0
  34. package/dist/runner-D72I7wvK.js +2956 -0
  35. package/dist/runner-FvUwOHyE.js +3 -0
  36. package/dist/schema-extractor-DMSozq40.js +250 -0
  37. package/dist/skill.d.ts +608 -0
  38. package/dist/skill.js +1832 -0
  39. package/dist/src-KzC0g5CS.js +191 -0
  40. package/dist/subcommand-router-Cskpofdk.js +134 -0
  41. package/package.json +103 -0
package/dist/docs.d.ts ADDED
@@ -0,0 +1,770 @@
1
+ import { T as Example, U as SubCommandValue, X as ResolvedFieldMeta, Y as ExtractedFields, b as ArgsSchema, tt as SchemaLike, v as AnyCommand } from "./arg-registry-YaWTVu_x.js";
2
+ import * as fs from "node:fs";
3
+ //#region ../core/src/executor/subcommand-router.d.ts
4
+ /**
5
+ * Resolve a lazy-loaded command (sync or async)
6
+ *
7
+ * @param cmd - The command or lazy loader function
8
+ * @returns The resolved command
9
+ */
10
+ declare function resolveLazyCommand(cmd: SubCommandValue): Promise<AnyCommand>;
11
+ //#endregion
12
+ //#region ../core/src/docs/option-rows.d.ts
13
+ /**
14
+ * Column identifiers for the options markdown table, in their canonical order.
15
+ */
16
+ type ColumnId = "option" | "alias" | "description" | "required" | "default" | "env";
17
+ //#endregion
18
+ //#region ../core/src/docs/render-args.d.ts
19
+ /**
20
+ * Args shape type (Record of string keys to field schemas of the CLI's
21
+ * schema library). This matches the typical structure of `commonArgs`,
22
+ * `workspaceArgs`, etc.
23
+ */
24
+ type ArgsShape = Record<string, SchemaLike>;
25
+ /**
26
+ * Options for rendering args table
27
+ */
28
+ type ArgsTableOptions = {
29
+ /** Columns to include in the table (default: all columns) */
30
+ columns?: ColumnId[];
31
+ };
32
+ /**
33
+ * Render args definition as a markdown options table
34
+ *
35
+ * This function takes raw args definitions (like `commonArgs`) and
36
+ * renders them as a markdown table suitable for documentation.
37
+ *
38
+ * @example
39
+ * import { renderArgsTable } from "politty/docs";
40
+ * import { commonArgs, workspaceArgs } from "./args";
41
+ *
42
+ * const table = renderArgsTable({
43
+ * ...commonArgs,
44
+ * ...workspaceArgs,
45
+ * });
46
+ * // | Option | Alias | Description | Default |
47
+ * // |--------|-------|-------------|---------|
48
+ * // | `--env-file <ENV_FILE>` | `-e` | Path to environment file | - |
49
+ * // ...
50
+ *
51
+ * @param args - Args shape (record of field names to the CLI's schema-library schemas, with arg() metadata)
52
+ * @param options - Rendering options
53
+ * @returns Rendered markdown table string
54
+ */
55
+ declare function renderArgsTable(args: ArgsShape, options?: ArgsTableOptions): string;
56
+ //#endregion
57
+ //#region ../core/src/docs/types.d.ts
58
+ /** Heading level for markdown headings (1-6) */
59
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
60
+ /**
61
+ * Options for rendering command index
62
+ */
63
+ type CommandIndexOptions = {
64
+ /** Base heading level (default: 3, which renders as ###) */
65
+ headingLevel?: HeadingLevel;
66
+ /** Only include leaf commands (commands without subcommands). Default: true */
67
+ leafOnly?: boolean;
68
+ };
69
+ /**
70
+ * Command information for rendering
71
+ */
72
+ interface CommandInfo {
73
+ /** Command name */
74
+ name: string;
75
+ /** Command description */
76
+ description?: string | undefined;
77
+ /** Alternative names (aliases) for this command */
78
+ aliases?: string[] | undefined;
79
+ /** Full command path (e.g., "my-cli config get") */
80
+ fullCommandPath: string;
81
+ /** Command path relative to root (e.g., "" for root, "config" for subcommand) */
82
+ commandPath: string;
83
+ /** Command depth (1 for root commands, 2 for subcommands, etc.) */
84
+ depth: number;
85
+ /** Positional arguments */
86
+ positionalArgs: ResolvedFieldMeta[];
87
+ /** Options (non-positional arguments) */
88
+ options: ResolvedFieldMeta[];
89
+ /** Subcommand information */
90
+ subCommands: SubCommandInfo[];
91
+ /** Extracted field information from schema */
92
+ extracted: ExtractedFields | null;
93
+ /** Original command object */
94
+ command: AnyCommand;
95
+ /** Additional notes */
96
+ notes?: string | undefined;
97
+ /** File path where this command is rendered (for cross-file links) */
98
+ filePath?: string | undefined;
99
+ /** Map of command path to file path (for cross-file links) */
100
+ fileMap?: Record<string, string> | undefined;
101
+ /** Example definitions from command */
102
+ examples?: Example[] | undefined;
103
+ /** Example execution results (populated when examples are executed) */
104
+ exampleResults?: ExampleExecutionResult[] | undefined;
105
+ /** Path to root document file (for global options link generation) */
106
+ rootDocPath?: string | undefined;
107
+ /** Whether global options exist (for global options link generation) */
108
+ hasGlobalOptions?: boolean;
109
+ }
110
+ /**
111
+ * Subcommand information
112
+ */
113
+ interface SubCommandInfo {
114
+ /** Subcommand name */
115
+ name: string;
116
+ /** Subcommand description */
117
+ description?: string | undefined;
118
+ /** Alternative names (aliases) for this subcommand */
119
+ aliases?: string[] | undefined;
120
+ /** Full command path */
121
+ fullPath: string[];
122
+ }
123
+ /**
124
+ * Example execution result
125
+ */
126
+ interface ExampleExecutionResult {
127
+ /** Command arguments that were executed */
128
+ cmd: string;
129
+ /** Description of the example */
130
+ desc: string;
131
+ /** Expected output (if defined in example) */
132
+ expectedOutput?: string | undefined;
133
+ /** Captured stdout */
134
+ stdout: string;
135
+ /** Captured stderr */
136
+ stderr: string;
137
+ /** Whether execution was successful */
138
+ success: boolean;
139
+ }
140
+ /**
141
+ * Example execution config for a specific command path
142
+ * If a command path is specified in ExampleConfig, its examples will be executed
143
+ */
144
+ interface ExampleCommandConfig {
145
+ /** Mock setup before running examples */
146
+ mock?: () => void | Promise<void>;
147
+ /** Mock cleanup after running examples */
148
+ cleanup?: () => void | Promise<void>;
149
+ }
150
+ /**
151
+ * Example execution configuration
152
+ * Key is command path (e.g., "", "config", "config get")
153
+ * All specified command paths will have their examples executed
154
+ *
155
+ * @example
156
+ * // With mock setup
157
+ * { "": { mock: () => mockFs(), cleanup: () => restoreFs() } }
158
+ *
159
+ * // Without mock (just execute)
160
+ * { "user": true }
161
+ */
162
+ type ExampleConfig = Record<string, ExampleCommandConfig | true>;
163
+ /**
164
+ * Render function type for custom markdown generation
165
+ */
166
+ type RenderFunction = (info: CommandInfo) => string;
167
+ /**
168
+ * Section render function type (legacy)
169
+ * @param defaultContent - The default rendered content for this section
170
+ * @param info - Command information
171
+ * @returns The final content to render (return empty string to hide section)
172
+ * @deprecated Use context-based render functions instead
173
+ */
174
+ type SectionRenderFunction = (defaultContent: string, info: CommandInfo) => string;
175
+ /**
176
+ * Render options for options/arguments
177
+ */
178
+ interface RenderContentOptions {
179
+ /** Style for rendering */
180
+ style?: "table" | "list";
181
+ /** Include heading (default: true) */
182
+ withHeading?: boolean;
183
+ }
184
+ /**
185
+ * Options render context
186
+ */
187
+ interface OptionsRenderContext {
188
+ /** Options to render */
189
+ options: ResolvedFieldMeta[];
190
+ /** Render function that accepts options and optional rendering options */
191
+ render: (options: ResolvedFieldMeta[], opts?: RenderContentOptions) => string;
192
+ /** Heading prefix (e.g., "###") */
193
+ heading: string;
194
+ /** Command information */
195
+ info: CommandInfo;
196
+ }
197
+ type OptionsRenderFunction = (context: OptionsRenderContext) => string;
198
+ /**
199
+ * Arguments render context
200
+ */
201
+ interface ArgumentsRenderContext {
202
+ /** Arguments to render */
203
+ args: ResolvedFieldMeta[];
204
+ /** Render function that accepts arguments and optional rendering options */
205
+ render: (args: ResolvedFieldMeta[], opts?: RenderContentOptions) => string;
206
+ /** Heading prefix (e.g., "###") */
207
+ heading: string;
208
+ /** Command information */
209
+ info: CommandInfo;
210
+ }
211
+ type ArgumentsRenderFunction = (context: ArgumentsRenderContext) => string;
212
+ /**
213
+ * Subcommands render options
214
+ */
215
+ interface SubcommandsRenderOptions {
216
+ /** Generate anchor links */
217
+ generateAnchors?: boolean;
218
+ /** Include heading (default: true) */
219
+ withHeading?: boolean;
220
+ }
221
+ /**
222
+ * Subcommands render context
223
+ */
224
+ interface SubcommandsRenderContext {
225
+ /** Subcommands to render */
226
+ subcommands: SubCommandInfo[];
227
+ /** Render function that accepts subcommands and optional rendering options */
228
+ render: (subcommands: SubCommandInfo[], opts?: SubcommandsRenderOptions) => string;
229
+ /** Heading prefix (e.g., "###") */
230
+ heading: string;
231
+ /** Command information */
232
+ info: CommandInfo;
233
+ }
234
+ type SubcommandsRenderFunction = (context: SubcommandsRenderContext) => string;
235
+ /**
236
+ * Examples render options
237
+ */
238
+ interface ExamplesRenderOptions {
239
+ /** Include heading (default: true) */
240
+ withHeading?: boolean;
241
+ /** Show execution output (default: true when results available) */
242
+ showOutput?: boolean;
243
+ /** Command prefix to prepend to example commands (e.g., "my-cli config get") */
244
+ commandPrefix?: string;
245
+ }
246
+ /**
247
+ * Examples render context
248
+ */
249
+ interface ExamplesRenderContext {
250
+ /** Examples to render */
251
+ examples: Example[];
252
+ /** Execution results (if examples were executed) */
253
+ results?: ExampleExecutionResult[] | undefined;
254
+ /** Render function that accepts examples, results, and optional rendering options */
255
+ render: (examples: Example[], results?: ExampleExecutionResult[], opts?: ExamplesRenderOptions) => string;
256
+ /** Heading prefix (e.g., "###") */
257
+ heading: string;
258
+ /** Command information */
259
+ info: CommandInfo;
260
+ }
261
+ type ExamplesRenderFunction = (context: ExamplesRenderContext) => string;
262
+ /**
263
+ * Simple section render context (for description, usage, notes, footer)
264
+ */
265
+ interface SimpleRenderContext {
266
+ /** Default content */
267
+ content: string;
268
+ /** Heading prefix (e.g., "###") */
269
+ heading: string;
270
+ /** Command information */
271
+ info: CommandInfo;
272
+ }
273
+ type SimpleRenderFunction = (context: SimpleRenderContext) => string;
274
+ /**
275
+ * Default renderer customization options
276
+ */
277
+ interface DefaultRendererOptions {
278
+ /** Heading level (default: 1) */
279
+ headingLevel?: HeadingLevel;
280
+ /** Option display style */
281
+ optionStyle?: "table" | "list";
282
+ /** Generate anchor links to subcommands */
283
+ generateAnchors?: boolean;
284
+ /** Include subcommand details */
285
+ includeSubcommandDetails?: boolean;
286
+ /**
287
+ * Omit the `<!-- politty:...:start/end -->` section markers from the rendered
288
+ * output. Used by marker-free `files` generation. When markers are omitted the
289
+ * output can only be regenerated wholesale (sections can no longer be located
290
+ * and updated in place), which is exactly how marker-free `files` mode works.
291
+ */
292
+ markerless?: boolean;
293
+ /** Custom renderer for description section */
294
+ renderDescription?: SimpleRenderFunction;
295
+ /** Custom renderer for usage section */
296
+ renderUsage?: SimpleRenderFunction;
297
+ /** Custom renderer for arguments section */
298
+ renderArguments?: ArgumentsRenderFunction;
299
+ /** Custom renderer for options section */
300
+ renderOptions?: OptionsRenderFunction;
301
+ /** Custom renderer for subcommands section */
302
+ renderSubcommands?: SubcommandsRenderFunction;
303
+ /** Custom renderer for notes section */
304
+ renderNotes?: SimpleRenderFunction;
305
+ /** Custom renderer for footer (default content is empty) */
306
+ renderFooter?: SimpleRenderFunction;
307
+ /** Custom renderer for examples section */
308
+ renderExamples?: ExamplesRenderFunction;
309
+ }
310
+ /**
311
+ * Root document configuration
312
+ * The root document contains global options tables and command index sections.
313
+ */
314
+ interface RootDocConfig {
315
+ /** Output file path */
316
+ path: string;
317
+ /**
318
+ * Global options configuration.
319
+ * ArgsShape directly, or { args, options } for render options.
320
+ */
321
+ globalOptions?: ArgsShape | {
322
+ args: ArgsShape;
323
+ options?: ArgsTableOptions;
324
+ };
325
+ /** Heading level for the file header (default: 1) */
326
+ headingLevel?: HeadingLevel;
327
+ /** Index section rendering options */
328
+ index?: CommandIndexOptions;
329
+ }
330
+ /**
331
+ * Root command customization for the root document.
332
+ * Controls the root document's title, description, header, and footer.
333
+ */
334
+ interface RootCommandInfo {
335
+ /** Title (defaults to command.name) */
336
+ title?: string;
337
+ /** Description (defaults to command.description) */
338
+ description?: string;
339
+ /** Markdown placed after title/description */
340
+ header?: string;
341
+ /** Markdown placed at end of document */
342
+ footer?: string;
343
+ }
344
+ /**
345
+ * Path configuration for documentation output.
346
+ * Simpler alternative to FileMapping for common patterns.
347
+ *
348
+ * @example
349
+ * // All commands in one file
350
+ * path: "docs/CLI.md"
351
+ *
352
+ * // Split files: root + specific commands in separate files
353
+ * path: { root: "docs/CLI.md", commands: { "build": "docs/build.md" } }
354
+ */
355
+ type PathConfig = string | {
356
+ root: string;
357
+ commands?: Record<string, string>;
358
+ };
359
+ /**
360
+ * Per-file configuration with custom renderer
361
+ */
362
+ interface FileConfig {
363
+ /** Command paths to include in this file (e.g., ["", "user", "config get"]) */
364
+ commands: string[];
365
+ /** Custom renderer for this file (optional) */
366
+ render?: RenderFunction;
367
+ /** File title (prepended to the file content) */
368
+ title?: string;
369
+ /** File description (added after title) */
370
+ description?: string;
371
+ /** Skip subcommand expansion (commands are used as-is). @internal */
372
+ noExpand?: boolean;
373
+ }
374
+ /**
375
+ * File mapping configuration
376
+ * Key: output file path (e.g., "docs/cli.md")
377
+ * Value: command paths array or FileConfig object
378
+ *
379
+ * @example
380
+ * // Simple: single file with multiple commands
381
+ * { "docs/cli.md": ["", "user", "config"] }
382
+ *
383
+ * // With custom renderer
384
+ * { "docs/cli.md": { commands: [""], render: customRenderer } }
385
+ */
386
+ type FileMapping = Record<string, string[] | FileConfig>;
387
+ /**
388
+ * generateDoc configuration
389
+ */
390
+ interface GenerateDocConfig {
391
+ /** Command to generate documentation for */
392
+ command: AnyCommand;
393
+ /**
394
+ * Root document configuration.
395
+ * The root document contains global options tables and command index sections.
396
+ * Title and description are derived from `command.name` and `command.description`.
397
+ */
398
+ rootDoc?: RootDocConfig;
399
+ /**
400
+ * Path configuration (simpler alternative to files).
401
+ * Mutually exclusive with `files`.
402
+ */
403
+ path?: PathConfig;
404
+ /** File output configuration (command path -> file mapping) */
405
+ files?: FileMapping;
406
+ /** Root command customization (title, description, header, footer) */
407
+ rootInfo?: RootCommandInfo;
408
+ /** Command paths to ignore (including their subcommands) */
409
+ ignores?: string[];
410
+ /** Default renderer options (used when render is not specified per file) */
411
+ format?: DefaultRendererOptions;
412
+ /** Formatter function to apply to generated content before comparison */
413
+ formatter?: FormatterFunction;
414
+ /** Example execution configuration (per command path) */
415
+ examples?: ExampleConfig;
416
+ /**
417
+ * Target command paths to validate (e.g., ["read", "config get"])
418
+ * When specified, only these commands' sections are validated.
419
+ * The full document structure is used to maintain cross-file links.
420
+ */
421
+ targetCommands?: string[];
422
+ /**
423
+ * Global args schema (runtime schema alternative).
424
+ * When provided, automatically derives `rootDoc.globalOptions` from this schema.
425
+ */
426
+ globalArgs?: ArgsSchema;
427
+ /**
428
+ * Template-based generation: output file path -> template file path.
429
+ * The template mixes handwritten markdown with {{politty:...}} placeholders.
430
+ * The output file is fully generated from the template and contains no
431
+ * politty markers. Can be combined with `files` or `path`.
432
+ */
433
+ templates?: Record<string, string>;
434
+ /**
435
+ * Declare that you will hand-customize the `files` output.
436
+ *
437
+ * Default `false`: the output is fully generated and regenerated wholesale on
438
+ * every run (with `targetCommands`, only files containing a target command are
439
+ * regenerated, but each such file is rebuilt in full). The output carries no
440
+ * `<!-- politty:...:start/end -->` markers — do not hand-edit it.
441
+ *
442
+ * Set to `true` when you want to hand-edit the output and have politty preserve
443
+ * your edits: generated sections are wrapped in markers and updated in place
444
+ * (with `targetCommands`), and handwritten content between them is kept. When a
445
+ * command in the generated output gains a section the file does not yet have,
446
+ * it is reported as a non-fatal warning (run with `POLITTY_DOCS_DOCTOR=true
447
+ * POLITTY_DOCS_UPDATE=true` to insert it, or leave it removed to opt that
448
+ * section out).
449
+ *
450
+ * This flag does not affect `path`/`rootDoc` output, which always uses markers
451
+ * to inject generated sections into a handwritten file, nor `templates`, which
452
+ * are always fully generated.
453
+ */
454
+ customizable?: boolean;
455
+ }
456
+ /**
457
+ * generateDoc result
458
+ */
459
+ interface GenerateDocResult {
460
+ /** Whether all files matched or were updated successfully */
461
+ success: boolean;
462
+ /** File processing results */
463
+ files: Array<{
464
+ /** File path */
465
+ path: string;
466
+ /** Status of this file */
467
+ status: "match" | "created" | "updated" | "diff";
468
+ /** Diff content (only when status is "diff") */
469
+ diff?: string | undefined;
470
+ }>;
471
+ /** Error message (when success is false) */
472
+ error?: string | undefined;
473
+ }
474
+ /**
475
+ * Formatter function type
476
+ * Formats generated content before comparison
477
+ */
478
+ type FormatterFunction = (content: string) => string | Promise<string>;
479
+ /**
480
+ * Environment variable name for update mode
481
+ */
482
+ declare const UPDATE_GOLDEN_ENV = "POLITTY_DOCS_UPDATE";
483
+ /**
484
+ * Environment variable name for doctor mode.
485
+ * When enabled alone, detects and reports missing section markers (read-only).
486
+ * When combined with POLITTY_DOCS_UPDATE=true, auto-inserts missing markers.
487
+ */
488
+ declare const DOCTOR_ENV = "POLITTY_DOCS_DOCTOR";
489
+ /**
490
+ * All section types in rendering order
491
+ */
492
+ declare const SECTION_TYPES: readonly ["heading", "description", "usage", "arguments", "options", "global-options-link", "subcommands", "examples", "notes"];
493
+ /**
494
+ * Section types for command documentation markers
495
+ */
496
+ type SectionType = (typeof SECTION_TYPES)[number];
497
+ /**
498
+ * Marker prefix for command section markers in generated documentation
499
+ * Format: <!-- politty:command:<scope>:<type>:start --> ... <!-- politty:command:<scope>:<type>:end -->
500
+ */
501
+ declare const SECTION_MARKER_PREFIX = "politty:command";
502
+ /**
503
+ * Generate start marker for a command section
504
+ */
505
+ declare function sectionStartMarker(type: SectionType, scope: string): string;
506
+ /**
507
+ * Generate end marker for a command section
508
+ */
509
+ declare function sectionEndMarker(type: SectionType, scope: string): string;
510
+ /**
511
+ * Marker prefix for global options sections in generated documentation
512
+ * Format: <!-- politty:global-options:start --> ... <!-- politty:global-options:end -->
513
+ */
514
+ declare const GLOBAL_OPTIONS_MARKER_PREFIX = "politty:global-options";
515
+ /**
516
+ * Generate start marker for a global options section
517
+ */
518
+ declare function globalOptionsStartMarker(): string;
519
+ /**
520
+ * Generate end marker for a global options section
521
+ */
522
+ declare function globalOptionsEndMarker(): string;
523
+ /**
524
+ * Marker prefix for root header sections in generated documentation
525
+ */
526
+ declare const ROOT_HEADER_MARKER_PREFIX = "politty:root-header";
527
+ declare function rootHeaderStartMarker(): string;
528
+ declare function rootHeaderEndMarker(): string;
529
+ /**
530
+ * Marker prefix for root footer sections in generated documentation
531
+ */
532
+ declare const ROOT_FOOTER_MARKER_PREFIX = "politty:root-footer";
533
+ declare function rootFooterStartMarker(): string;
534
+ declare function rootFooterEndMarker(): string;
535
+ /**
536
+ * Marker prefix for index sections in generated documentation
537
+ * Format: <!-- politty:index:<scope>:start --> ... <!-- politty:index:<scope>:end -->
538
+ */
539
+ declare const INDEX_MARKER_PREFIX = "politty:index";
540
+ /**
541
+ * Generate start marker for an index section
542
+ */
543
+ declare function indexStartMarker(scope: string): string;
544
+ /**
545
+ * Generate end marker for an index section
546
+ */
547
+ declare function indexEndMarker(scope: string): string;
548
+ //#endregion
549
+ //#region ../core/src/docs/default-renderers.d.ts
550
+ /**
551
+ * Render usage line
552
+ */
553
+ declare function renderUsage(info: CommandInfo): string;
554
+ /**
555
+ * Render arguments as table
556
+ */
557
+ declare function renderArgumentsTable(info: CommandInfo): string;
558
+ /**
559
+ * Render arguments as list
560
+ */
561
+ declare function renderArgumentsList(info: CommandInfo): string;
562
+ /**
563
+ * Render options as markdown table
564
+ *
565
+ * Features:
566
+ * - Uses kebab-case (cliName) for option names (e.g., `--dry-run` instead of `--dryRun`)
567
+ * - Automatically adds Env column when any option has env configured
568
+ * - Displays multiple env vars as comma-separated list
569
+ *
570
+ * @example
571
+ * | Option | Alias | Description | Required | Default | Env |
572
+ * |--------|-------|-------------|----------|---------|-----|
573
+ * | `--dry-run` | `-d` | Dry run mode | No | `false` | - |
574
+ * | `--port <PORT>` | - | Server port | Yes | - | `PORT`, `SERVER_PORT` |
575
+ */
576
+ declare function renderOptionsTable(info: CommandInfo): string;
577
+ /**
578
+ * Render options as markdown list
579
+ *
580
+ * Features:
581
+ * - Uses kebab-case (cliName) for option names (e.g., `--dry-run` instead of `--dryRun`)
582
+ * - Appends env info at the end of each option (e.g., `[env: PORT, SERVER_PORT]`)
583
+ *
584
+ * @example
585
+ * - `-d`, `--dry-run` - Dry run mode (default: false)
586
+ * - `--port <PORT>` - Server port (required) [env: PORT, SERVER_PORT]
587
+ */
588
+ declare function renderOptionsList(info: CommandInfo): string;
589
+ /**
590
+ * Render subcommands as table
591
+ */
592
+ declare function renderSubcommandsTable(info: CommandInfo, generateAnchors?: boolean): string;
593
+ /**
594
+ * Render options from array as table
595
+ */
596
+ declare function renderOptionsTableFromArray(options: ResolvedFieldMeta[]): string;
597
+ /**
598
+ * Render options from array as list
599
+ */
600
+ declare function renderOptionsListFromArray(options: ResolvedFieldMeta[]): string;
601
+ /**
602
+ * Render arguments from array as table
603
+ */
604
+ declare function renderArgumentsTableFromArray(args: ResolvedFieldMeta[]): string;
605
+ /**
606
+ * Render arguments from array as list
607
+ */
608
+ declare function renderArgumentsListFromArray(args: ResolvedFieldMeta[]): string;
609
+ /**
610
+ * Render subcommands from array as table
611
+ */
612
+ declare function renderSubcommandsTableFromArray(subcommands: SubCommandInfo[], info: CommandInfo, generateAnchors?: boolean): string;
613
+ /**
614
+ * Render examples as markdown
615
+ *
616
+ * @example
617
+ * **Basic usage**
618
+ *
619
+ * ```bash
620
+ * $ greet World
621
+ * ```
622
+ *
623
+ * Output:
624
+ * ```
625
+ * Hello, World!
626
+ * ```
627
+ */
628
+ declare function renderExamplesDefault(examples: Example[], results?: ExampleExecutionResult[], opts?: ExamplesRenderOptions): string;
629
+ declare function createCommandRenderer(options?: DefaultRendererOptions): RenderFunction;
630
+ /**
631
+ * Default renderers presets
632
+ */
633
+ declare const defaultRenderers: {
634
+ /** Standard command documentation */
635
+ command: (options?: DefaultRendererOptions) => RenderFunction;
636
+ /** Table style options (default) */
637
+ tableStyle: RenderFunction;
638
+ /** List style options */
639
+ listStyle: RenderFunction;
640
+ };
641
+ //#endregion
642
+ //#region ../core/src/docs/doc-comparator.d.ts
643
+ /**
644
+ * Comparison result
645
+ */
646
+ interface CompareResult {
647
+ /** Whether the content matches */
648
+ match: boolean;
649
+ /** Diff content (only when match is false) */
650
+ diff?: string;
651
+ /** Whether the file exists */
652
+ fileExists: boolean;
653
+ }
654
+ /**
655
+ * Compare generated content with existing file
656
+ */
657
+ declare function compareWithExisting(generatedContent: string, filePath: string): CompareResult;
658
+ /**
659
+ * Format diff between two strings in unified diff format
660
+ */
661
+ declare function formatDiff(expected: string, actual: string): string;
662
+ /**
663
+ * Write content to file, creating directories if needed
664
+ */
665
+ declare function writeFile(filePath: string, content: string): void;
666
+ /**
667
+ * Minimal fs interface for deleteFile
668
+ */
669
+ interface DeleteFileFs {
670
+ existsSync: typeof fs.existsSync;
671
+ unlinkSync: typeof fs.unlinkSync;
672
+ }
673
+ //#endregion
674
+ //#region ../core/src/docs/doc-generator.d.ts
675
+ /**
676
+ * Build CommandInfo from a command
677
+ */
678
+ declare function buildCommandInfo(command: AnyCommand, rootName: string, commandPath?: string[]): Promise<CommandInfo>;
679
+ /**
680
+ * Collect all commands with their paths
681
+ * Returns a map of command path -> CommandInfo
682
+ */
683
+ declare function collectAllCommands(command: AnyCommand, rootName?: string): Promise<Map<string, CommandInfo>>;
684
+ //#endregion
685
+ //#region ../core/src/docs/example-executor.d.ts
686
+ /**
687
+ * Execute examples for a command and capture output
688
+ *
689
+ * @param examples - Examples to execute
690
+ * @param config - Execution configuration (mock setup/cleanup)
691
+ * @param rootCommand - Root command to execute against
692
+ * @param commandPath - Command path for subcommands (e.g., ["config", "get"])
693
+ * @returns Array of execution results with captured stdout/stderr
694
+ */
695
+ declare function executeExamples(examples: Example[], config: ExampleCommandConfig, rootCommand: AnyCommand, commandPath?: string[]): Promise<ExampleExecutionResult[]>;
696
+ //#endregion
697
+ //#region ../core/src/docs/golden-test.d.ts
698
+ /**
699
+ * Generate documentation from command definition
700
+ */
701
+ declare function generateDoc(config: GenerateDocConfig): Promise<GenerateDocResult>;
702
+ /**
703
+ * Assert that documentation matches golden files
704
+ * Throws an error if there are differences and update mode is not enabled
705
+ */
706
+ declare function assertDocMatch(config: GenerateDocConfig): Promise<void>;
707
+ /**
708
+ * Initialize documentation files by deleting them
709
+ * Only deletes when update mode is enabled (POLITTY_DOCS_UPDATE=true)
710
+ * Use this in beforeAll to ensure skipped tests don't leave stale sections
711
+ * @param config - Config containing files to initialize, or a single file path
712
+ * @param fileSystem - Optional fs implementation (useful when fs is mocked)
713
+ */
714
+ declare function initDocFile(config: Pick<GenerateDocConfig, "files" | "templates" | "rootDoc"> | string, fileSystem?: DeleteFileFs): void;
715
+ //#endregion
716
+ //#region ../core/src/docs/render-index.d.ts
717
+ /**
718
+ * Configuration for a command category
719
+ */
720
+ type CommandCategory = {
721
+ /** Category title (e.g., "Application Commands") */
722
+ title: string;
723
+ /** Category description */
724
+ description: string;
725
+ /** Command paths to include (parent commands will auto-expand to leaf commands) */
726
+ commands: string[];
727
+ /** Optional post-expansion allowlist, used when a caller has already applied ignores */
728
+ allowedCommands?: string[];
729
+ /** Path to documentation file for links (e.g., "./cli/application.md") */
730
+ docPath: string;
731
+ /**
732
+ * When true, `commands` are used verbatim as index rows without expanding
733
+ * parent commands to their leaf subcommands. Used for template-derived
734
+ * categories where only explicitly rendered scopes have headings.
735
+ */
736
+ noExpand?: boolean;
737
+ };
738
+ /**
739
+ * Render command index from categories
740
+ *
741
+ * Generates a category-based index of commands with links to documentation.
742
+ *
743
+ * @example
744
+ * const categories: CommandCategory[] = [
745
+ * {
746
+ * title: "Application Commands",
747
+ * description: "Commands for managing applications.",
748
+ * commands: ["init", "generate", "apply"],
749
+ * docPath: "./cli/application.md",
750
+ * },
751
+ * ];
752
+ *
753
+ * const index = await renderCommandIndex(mainCommand, categories);
754
+ * // ### [Application Commands](./cli/application.md)
755
+ * //
756
+ * // Commands for managing applications.
757
+ * //
758
+ * // | Command | Description |
759
+ * // |---------|-------------|
760
+ * // | [init](./cli/application.md#init) | Initialize a project |
761
+ * // ...
762
+ *
763
+ * @param command - Root command to extract command information from
764
+ * @param categories - Category definitions for grouping commands
765
+ * @param options - Rendering options
766
+ * @returns Rendered markdown string
767
+ */
768
+ declare function renderCommandIndex(command: AnyCommand, categories: CommandCategory[], options?: CommandIndexOptions): Promise<string>;
769
+ //#endregion
770
+ export { type ArgsShape, type ArgsTableOptions, type ArgumentsRenderContext, type ArgumentsRenderFunction, type CommandCategory, type CommandIndexOptions, type CommandInfo, DOCTOR_ENV, type DefaultRendererOptions, type DeleteFileFs, type ExampleCommandConfig, type ExampleConfig, type ExampleExecutionResult, type ExamplesRenderContext, type ExamplesRenderFunction, type ExamplesRenderOptions, type FileConfig, type FileMapping, type FormatterFunction, GLOBAL_OPTIONS_MARKER_PREFIX, type GenerateDocConfig, type GenerateDocResult, type HeadingLevel, INDEX_MARKER_PREFIX, type OptionsRenderContext, type OptionsRenderFunction, type PathConfig, ROOT_FOOTER_MARKER_PREFIX, ROOT_HEADER_MARKER_PREFIX, type RenderContentOptions, type RenderFunction, type RootCommandInfo, type RootDocConfig, SECTION_MARKER_PREFIX, SECTION_TYPES, type SectionRenderFunction, type SectionType, type SimpleRenderContext, type SimpleRenderFunction, type SubCommandInfo, type SubcommandsRenderContext, type SubcommandsRenderFunction, type SubcommandsRenderOptions, UPDATE_GOLDEN_ENV, assertDocMatch, buildCommandInfo, collectAllCommands, compareWithExisting, createCommandRenderer, defaultRenderers, executeExamples, formatDiff, generateDoc, globalOptionsEndMarker, globalOptionsStartMarker, indexEndMarker, indexStartMarker, initDocFile, renderArgsTable, renderArgumentsList, renderArgumentsListFromArray, renderArgumentsTable, renderArgumentsTableFromArray, renderCommandIndex, renderExamplesDefault, renderOptionsList, renderOptionsListFromArray, renderOptionsTable, renderOptionsTableFromArray, renderSubcommandsTable, renderSubcommandsTableFromArray, renderUsage, resolveLazyCommand, rootFooterEndMarker, rootFooterStartMarker, rootHeaderEndMarker, rootHeaderStartMarker, sectionEndMarker, sectionStartMarker, writeFile };