This repository was archived by the owner on Jun 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathgenerate-cli-docs.ts
More file actions
130 lines (115 loc) · 3.18 KB
/
Copy pathgenerate-cli-docs.ts
File metadata and controls
130 lines (115 loc) · 3.18 KB
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
/**
* CLI Documentation Generator
* Parses ccw/src/tools/command-registry.ts and generates Markdown docs
*/
import fs from 'fs'
import path from 'path'
interface Command {
name: string
description: string
options: CommandOption[]
examples: string[]
}
interface CommandOption {
name: string
description: string
type: string
required: boolean
default?: string
}
function parseCommandRegistry(): Command[] {
// This would parse the actual ccw command registry
// For now, return mock data
return [
{
name: 'cli',
description: 'Execute AI-powered CLI operations',
options: [
{
name: '-p, --prompt',
description: 'Prompt text for the AI',
type: 'string',
required: true
},
{
name: '--tool',
description: 'AI tool to use (gemini, codex, qwen, claude)',
type: 'string',
required: false,
default: 'first enabled'
},
{
name: '--mode',
description: 'Execution mode (analysis, write, review)',
type: 'string',
required: true
}
],
examples: [
'ccw cli -p "Analyze codebase" --mode analysis',
'ccw cli -p "Add auth" --mode write --tool codex'
]
},
{
name: 'skill',
description: 'Manage and execute skills',
options: [
{
name: 'list',
description: 'List all available skills',
type: 'boolean',
required: false
},
{
name: 'run',
description: 'Run a specific skill',
type: 'string',
required: false
}
],
examples: [
'ccw skill list',
'ccw skill run commit'
]
}
]
}
function generateCommandMarkdown(command: Command): string {
let md = `## ${command.name}\n\n`
md += `${command.description}\n\n`
if (command.options.length > 0) {
md += `### Options\n\n`
md += `| Option | Type | Required | Default | Description |\n`
md += `|--------|------|----------|---------|-------------|\n`
for (const option of command.options) {
const required = option.required ? 'Yes' : 'No'
const defaultVal = option.default ?? '-'
md += `| \`${option.name}\` | ${option.type} | ${required} | ${defaultVal} | ${option.description} |\n`
}
md += `\n`
}
if (command.examples.length > 0) {
md += `### Examples\n\n`
for (const example of command.examples) {
md += `\`\`\`bash\n${example}\n\`\`\`\n\n`
}
}
return md
}
function generateDocs() {
const commands = parseCommandRegistry()
const outputPath = path.join(process.cwd(), 'cli/commands.generated.md')
let markdown = `# CLI Commands Reference\n\n`
markdown += `Complete reference for all CCW CLI commands.\n\n`
for (const command of commands) {
markdown += generateCommandMarkdown(command)
markdown += `---\n\n`
}
fs.writeFileSync(outputPath, markdown, 'utf-8')
console.log(`✅ Generated CLI documentation: ${outputPath}`)
}
// Run if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
generateDocs()
}
export { generateDocs, parseCommandRegistry, generateCommandMarkdown }