@redpanda-data/docs-extensions-and-macros 4.12.6 → 4.13.1

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 (77) hide show
  1. package/README.adoc +33 -1064
  2. package/bin/doc-tools-mcp.js +720 -0
  3. package/bin/doc-tools.js +1050 -50
  4. package/bin/mcp-tools/antora.js +153 -0
  5. package/bin/mcp-tools/cache.js +89 -0
  6. package/bin/mcp-tools/cloud-regions.js +127 -0
  7. package/bin/mcp-tools/content-review.js +196 -0
  8. package/bin/mcp-tools/crd-docs.js +153 -0
  9. package/bin/mcp-tools/frontmatter.js +138 -0
  10. package/bin/mcp-tools/generated-docs-review.js +887 -0
  11. package/bin/mcp-tools/helm-docs.js +152 -0
  12. package/bin/mcp-tools/index.js +245 -0
  13. package/bin/mcp-tools/job-queue.js +468 -0
  14. package/bin/mcp-tools/mcp-validation.js +266 -0
  15. package/bin/mcp-tools/metrics-docs.js +146 -0
  16. package/bin/mcp-tools/openapi.js +174 -0
  17. package/bin/mcp-tools/prompt-discovery.js +283 -0
  18. package/bin/mcp-tools/property-docs.js +157 -0
  19. package/bin/mcp-tools/rpcn-docs.js +113 -0
  20. package/bin/mcp-tools/rpk-docs.js +141 -0
  21. package/bin/mcp-tools/telemetry.js +211 -0
  22. package/bin/mcp-tools/utils.js +131 -0
  23. package/bin/mcp-tools/versions.js +168 -0
  24. package/cli-utils/convert-doc-links.js +1 -1
  25. package/cli-utils/github-token.js +58 -0
  26. package/cli-utils/self-managed-docs-branch.js +2 -2
  27. package/cli-utils/setup-mcp.js +313 -0
  28. package/docker-compose/25.1/transactions.md +1 -1
  29. package/docker-compose/transactions.md +1 -1
  30. package/extensions/DEVELOPMENT.adoc +464 -0
  31. package/extensions/README.adoc +124 -0
  32. package/extensions/REFERENCE.adoc +768 -0
  33. package/extensions/USER_GUIDE.adoc +339 -0
  34. package/extensions/generate-rp-connect-info.js +3 -4
  35. package/extensions/version-fetcher/get-latest-console-version.js +38 -27
  36. package/extensions/version-fetcher/get-latest-redpanda-version.js +65 -54
  37. package/extensions/version-fetcher/retry-util.js +88 -0
  38. package/extensions/version-fetcher/set-latest-version.js +6 -3
  39. package/macros/DEVELOPMENT.adoc +377 -0
  40. package/macros/README.adoc +105 -0
  41. package/macros/REFERENCE.adoc +222 -0
  42. package/macros/USER_GUIDE.adoc +220 -0
  43. package/macros/rp-connect-components.js +6 -6
  44. package/mcp/CLI_INTERFACE.adoc +384 -0
  45. package/mcp/COSTS.adoc +167 -0
  46. package/mcp/DEVELOPMENT.adoc +726 -0
  47. package/mcp/README.adoc +172 -0
  48. package/mcp/USER_GUIDE.adoc +1392 -0
  49. package/mcp/WRITER_EXTENSION_GUIDE.adoc +814 -0
  50. package/mcp/prompts/README.adoc +183 -0
  51. package/mcp/prompts/property-docs-guide.md +283 -0
  52. package/mcp/prompts/review-for-style.md +128 -0
  53. package/mcp/prompts/rpcn-connector-docs-guide.md +126 -0
  54. package/mcp/prompts/write-new-guide.md +222 -0
  55. package/mcp/team-standards/style-guide.md +321 -0
  56. package/mcp/templates/README.adoc +212 -0
  57. package/mcp/templates/prompt-review-template.md +80 -0
  58. package/mcp/templates/prompt-write-template.md +110 -0
  59. package/mcp/templates/resource-template.md +76 -0
  60. package/package.json +16 -5
  61. package/tools/bundle-openapi.js +20 -10
  62. package/tools/cloud-regions/generate-cloud-regions.js +1 -1
  63. package/tools/fetch-from-github.js +18 -4
  64. package/tools/gen-rpk-ascii.py +3 -1
  65. package/tools/generate-cli-docs.js +325 -0
  66. package/tools/get-console-version.js +4 -2
  67. package/tools/get-redpanda-version.js +4 -2
  68. package/tools/metrics/metrics.py +19 -7
  69. package/tools/property-extractor/Makefile +7 -1
  70. package/tools/property-extractor/cloud_config.py +4 -4
  71. package/tools/property-extractor/constant_resolver.py +11 -11
  72. package/tools/property-extractor/property_extractor.py +18 -16
  73. package/tools/property-extractor/topic_property_extractor.py +2 -2
  74. package/tools/property-extractor/transformers.py +7 -7
  75. package/tools/property-extractor/type_definition_extractor.py +4 -4
  76. package/tools/redpanda-connect/README.adoc +1 -1
  77. package/tools/redpanda-connect/generate-rpcn-connector-docs.js +5 -3
@@ -0,0 +1,220 @@
1
+ = AsciiDoc Macros User Guide
2
+ :toc:
3
+ :toclevels: 3
4
+
5
+ Complete guide to using AsciiDoc macros in your documentation.
6
+
7
+ == Getting started
8
+
9
+ === Installation
10
+
11
+ Install the package:
12
+
13
+ [,bash]
14
+ ----
15
+ npm i @redpanda-data/docs-extensions-and-macros
16
+ ----
17
+
18
+ === Configuration
19
+
20
+ Register macros in your Antora playbook under `asciidoc.extensions`:
21
+
22
+ [,yaml]
23
+ ----
24
+ asciidoc:
25
+ extensions:
26
+ - '@redpanda-data/docs-extensions-and-macros/macros/glossary'
27
+ - '@redpanda-data/docs-extensions-and-macros/macros/config-ref'
28
+ - '@redpanda-data/docs-extensions-and-macros/macros/helm-ref'
29
+ ----
30
+
31
+ IMPORTANT: Use `asciidoc.extensions` for macros, not `antora.extensions`.
32
+
33
+ == Using macros
34
+
35
+ === glossterm - Glossary terms
36
+
37
+ Reference glossary terms with tooltips:
38
+
39
+ [,asciidoc]
40
+ ----
41
+ The glossterm:partition[partition] stores data.
42
+ glossterm:broker[broker,A server that handles requests]
43
+ ----
44
+
45
+ *Syntax:* `glossterm:term[definition]`
46
+
47
+ * `term` - The term to reference (required)
48
+ * `definition` - Custom definition (optional, uses global glossary by default)
49
+
50
+ === config_ref - Configuration references
51
+
52
+ Link to configuration properties:
53
+
54
+ [,asciidoc]
55
+ ----
56
+ config_ref:log.retention.ms,true,tunable-properties[]
57
+ config_ref:cleanup.policy,false[]
58
+ ----
59
+
60
+ *Syntax:* `config_ref:property,isLink,path[]`
61
+
62
+ * `property` - Configuration property name (required)
63
+ * `isLink` - Whether to create a link (true/false, required)
64
+ * `path` - Document path for link (required if isLink is true)
65
+
66
+ === helm_ref - Helm value references
67
+
68
+ Link to Helm chart values:
69
+
70
+ [,asciidoc]
71
+ ----
72
+ helm_ref:storage.tieredConfig.cloud_storage_enabled[]
73
+ helm_ref:[]
74
+ ----
75
+
76
+ *Syntax:* `helm_ref:value[]`
77
+
78
+ * `value` - Helm value path (optional, links to values.yaml overview if omitted)
79
+
80
+ === components_by_category - Component display
81
+
82
+ Display Redpanda Connect components by category:
83
+
84
+ [,asciidoc]
85
+ ----
86
+ components_by_category::inputs[]
87
+ components_by_category::outputs[]
88
+ components_by_category::processors[]
89
+ ----
90
+
91
+ *Syntax:* `components_by_category::[type]`
92
+
93
+ * `type` - Component type (inputs, outputs, processors, etc.)
94
+
95
+ === component_table - Component table
96
+
97
+ Generate searchable component table:
98
+
99
+ [,asciidoc]
100
+ ----
101
+ component_table::[]
102
+ ----
103
+
104
+ Generates a searchable table of all components with filters.
105
+
106
+ === component_type_dropdown - Type switcher
107
+
108
+ Create dropdown for switching between component types:
109
+
110
+ [,asciidoc]
111
+ ----
112
+ component_type_dropdown::[]
113
+ ----
114
+
115
+ Generates a dropdown to switch between different implementations of the same component.
116
+
117
+ == Configuration options
118
+
119
+ === Glossary configuration
120
+
121
+ Configure glossary behavior in playbook:
122
+
123
+ [,yaml]
124
+ ----
125
+ asciidoc:
126
+ attributes:
127
+ glossary-tooltip: data-tooltip # Enable tooltips
128
+ glossary-page: glossary.adoc # Link target
129
+ glossary-links: true # Enable links
130
+ extensions:
131
+ - '@redpanda-data/docs-extensions-and-macros/macros/glossary'
132
+ ----
133
+
134
+ *Options:*
135
+
136
+ * `glossary-tooltip` - Tooltip implementation (title, true, or data-attribute-name)
137
+ * `glossary-page` - Page to link glossary terms to
138
+ * `glossary-links` - Enable/disable links (default: true)
139
+ * `glossary-term-role` - CSS role for terms (default: glossary-term)
140
+
141
+ == Troubleshooting
142
+
143
+ === Macro not rendering
144
+
145
+ *Problem:* Macro appears as plain text
146
+
147
+ *Solutions:*
148
+
149
+ * Verify macro is registered under `asciidoc.extensions`
150
+ * Check macro syntax is correct
151
+ * Ensure package is installed
152
+ * Try rebuilding: `npx antora playbook.yml`
153
+
154
+ === Glossary terms not found
155
+
156
+ *Problem:* Glossary definitions missing
157
+
158
+ *Solutions:*
159
+
160
+ * Define terms in shared component or local `antora.yml`
161
+ * Check term spelling matches exactly
162
+ * Provide inline definition as fallback
163
+
164
+ === Links not working
165
+
166
+ *Problem:* config_ref or helm_ref links broken
167
+
168
+ *Solutions:*
169
+
170
+ * Verify target page exists
171
+ * Check path is relative to reference module
172
+ * Ensure property/value name is correct
173
+
174
+ === Component macros empty
175
+
176
+ *Problem:* components_by_category shows no components
177
+
178
+ *Solutions:*
179
+
180
+ * Ensure component aggregator extension is enabled
181
+ * Check component data is generated
182
+ * Verify component type is correct
183
+
184
+ == Best practices
185
+
186
+ === Use glossary terms consistently
187
+
188
+ [,asciidoc]
189
+ ----
190
+ ✓ Good: glossterm:partition[]
191
+ ✗ Bad: partition (without macro)
192
+ ----
193
+
194
+ === Provide fallback definitions
195
+
196
+ [,asciidoc]
197
+ ----
198
+ glossterm:custom-term[A definition in case term isn't in glossary]
199
+ ----
200
+
201
+ === Link to configuration when relevant
202
+
203
+ [,asciidoc]
204
+ ----
205
+ To configure retention, set config_ref:log.retention.ms,true,tunable-properties[].
206
+ ----
207
+
208
+ === Keep macro usage readable
209
+
210
+ [,asciidoc]
211
+ ----
212
+ ✓ Good: Configure config_ref:retention.ms,true,topic-properties[].
213
+ ✗ Bad: config_ref:retention.ms,true,topic-properties[]config_ref:cleanup.policy,true,topic-properties[].
214
+ ----
215
+
216
+ == Related documentation
217
+
218
+ * link:REFERENCE.adoc[Macros reference] - Complete macro documentation
219
+ * link:DEVELOPMENT.adoc[Development guide] - How to create new macros
220
+ * https://docs.asciidoctor.org/asciidoc/latest/macros/[AsciiDoc Macro Syntax]
@@ -273,10 +273,10 @@ module.exports.register = function (registry, context) {
273
273
  *
274
274
  * @returns {Object} - An object with two properties:
275
275
  * - `certified`: An array of SQL drivers with 'certified' support level. Each driver contains:
276
- * - `commercialName`: The trimmed commercial name of the driver (e.g., 'PostgreSQL').
276
+ * - `commercialName`: The trimmed commercial name of the driver (for example, 'PostgreSQL').
277
277
  * - `isCloudSupported`: A boolean indicating whether the driver supports cloud.
278
278
  * - `community`: An array of SQL drivers with 'community' support level. Each driver contains:
279
- * - `commercialName`: The trimmed commercial name of the driver (e.g., 'Trino').
279
+ * - `commercialName`: The trimmed commercial name of the driver (for example, 'Trino').
280
280
  * - `isCloudSupported`: A boolean indicating whether the driver supports cloud.
281
281
  *
282
282
  * Example return structure:
@@ -330,7 +330,7 @@ module.exports.register = function (registry, context) {
330
330
  * @param {Object} connectors - An object containing the connector data, where each key is a connector name and
331
331
  * each value contains details about its types, licensing, and cloud support.
332
332
  * {
333
- * types: Map - A map of connector types (e.g., Input, Output, Processor), with associated commercial names.
333
+ * types: Map - A map of connector types (for example, Input, Output, Processor), with associated commercial names.
334
334
  * isLicensed: 'Yes' or 'No' - Indicates if the connector requires an enterprise license.
335
335
  * isCloudConnectorSupported: true or false - Indicates if any type for this connector supports Redpanda Cloud.
336
336
  * }
@@ -340,7 +340,7 @@ module.exports.register = function (registry, context) {
340
340
  * community: Array<{ commercialName: string, isCloudSupported: boolean }>
341
341
  * }
342
342
  * @param {boolean} isCloud - A flag indicating whether to filter by cloud support. If true, only cloud-supported connectors are shown.
343
- * @param {boolean} showAllInfo - A flag indicating whether to show all information or limit the data displayed (e.g., for cloud-only views).
343
+ * @param {boolean} showAllInfo - A flag indicating whether to show all information or limit the data displayed (for example, for cloud-only views).
344
344
  *
345
345
  * @returns {string} - A string containing the generated HTML for the connectors table rows.
346
346
  * The output is a string of HTML rows with the following columns:
@@ -831,7 +831,7 @@ module.exports.register = function (registry, context) {
831
831
  // Generic fallback for words ending in 's Selected'
832
832
  return pluralText.replace(/s Selected$/, ' Selected');
833
833
  } else if (pluralText.endsWith('ies Selected')) {
834
- // Handle words ending in 'ies' (e.g., "Categories Selected" -> "Category Selected")
834
+ // Handle words ending in 'ies' (for example, "Categories Selected" -> "Category Selected")
835
835
  return pluralText.replace(/ies Selected$/, 'y Selected');
836
836
  } else {
837
837
  // If no pattern matches, return as-is
@@ -984,7 +984,7 @@ module.exports.register = function (registry, context) {
984
984
  self.named('component_type_dropdown');
985
985
  self.process((parent, target, attrs) => {
986
986
  const attributes = parent.getDocument().getAttributes();
987
- const component = attributes['page-component-title']; // Current component (e.g., 'Redpanda Cloud' or 'Redpanda Connect')
987
+ const component = attributes['page-component-title']; // Current component (for example, 'Redpanda Cloud' or 'Redpanda Connect')
988
988
  const name = attributes['doctitle'];
989
989
  const type = attributes['type'];
990
990
  if (!name || !type) {
@@ -0,0 +1,384 @@
1
+ = CLI Interface Contract
2
+ :toc:
3
+ :toclevels: 3
4
+
5
+ This document describes the CLI interface contract that the MCP server depends on. These contracts are verified by the CLI contract tests to ensure the MCP server continues to work as expected when the CLI changes.
6
+
7
+ The MCP server wraps the `npx doc-tools` CLI to provide a natural language interface to Claude Code. The CLI must maintain specific commands, flags, and output formats for the MCP server to function correctly.
8
+
9
+ == Command structure
10
+
11
+ All commands follow the pattern:
12
+
13
+ [,bash]
14
+ ----
15
+ npx doc-tools <command> [subcommand] [flags]
16
+ ----
17
+
18
+ == Top-level commands
19
+
20
+ === generate
21
+
22
+ Generate various types of documentation.
23
+
24
+ [,bash]
25
+ ----
26
+ npx doc-tools generate <subcommand> [flags]
27
+ ----
28
+
29
+ Subcommands are documented in the <<Generate subcommands>> section.
30
+
31
+ === get-redpanda-version
32
+
33
+ Get the latest Redpanda version information.
34
+
35
+ [,bash]
36
+ ----
37
+ npx doc-tools get-redpanda-version [--beta]
38
+ ----
39
+
40
+ *Output format:*
41
+
42
+ [,bash]
43
+ ----
44
+ REDPANDA_VERSION=v25.3.1
45
+ REDPANDA_DOCKER_TAG=docker.redpanda.com/redpandadata/redpanda:v25.3.1
46
+ REDPANDA_RELEASE_NOTES=https://github.com/redpanda-data/redpanda/releases/tag/v25.3.1
47
+ ----
48
+
49
+ *Flags:*
50
+
51
+ --beta:: Get the latest beta/RC version instead of stable (optional)
52
+
53
+ === get-console-version
54
+
55
+ Get the latest Redpanda Console version information.
56
+
57
+ [,bash]
58
+ ----
59
+ npx doc-tools get-console-version
60
+ ----
61
+
62
+ *Output format:*
63
+
64
+ [,bash]
65
+ ----
66
+ CONSOLE_VERSION=v2.7.2
67
+ CONSOLE_DOCKER_TAG=docker.redpanda.com/redpandadata/console:v2.7.2
68
+ CONSOLE_RELEASE_NOTES=https://github.com/redpanda-data/console/releases/tag/v2.7.2
69
+ ----
70
+
71
+ === --version
72
+
73
+ Display the doc-tools version.
74
+
75
+ [,bash]
76
+ ----
77
+ npx doc-tools --version
78
+ ----
79
+
80
+ *Output format:*
81
+
82
+ [,bash]
83
+ ----
84
+ <major>.<minor>.<patch>
85
+ ----
86
+
87
+ Example: `1.2.3`
88
+
89
+ == Generate subcommands
90
+
91
+ === property-docs
92
+
93
+ Generate Redpanda configuration property documentation.
94
+
95
+ [,bash]
96
+ ----
97
+ npx doc-tools generate property-docs --tag <version> [options]
98
+ ----
99
+
100
+ *Required flags:*
101
+
102
+ --tag:: Redpanda version to generate docs for (for example, `v25.3.1`, `25.3.1`, or `latest`)
103
+
104
+ *Optional flags:*
105
+
106
+ --generate-partials:: Generate AsciiDoc partials in addition to JSON
107
+ --cloud-support:: Include cloud support information
108
+ --overrides:: Path to property overrides JSON file
109
+
110
+ *Output:*
111
+
112
+ Creates one or more of:
113
+
114
+ * `modules/reference/partials/properties.json`
115
+ * `modules/reference/partials/cluster-properties.adoc` (with `--generate-partials`)
116
+ * `modules/reference/partials/broker-properties.adoc` (with `--generate-partials`)
117
+ * `modules/reference/partials/tunable-properties.adoc` (with `--generate-partials`)
118
+ * `modules/reference/partials/topic-properties.adoc` (with `--generate-partials`)
119
+
120
+ === metrics-docs
121
+
122
+ Generate Redpanda metrics documentation.
123
+
124
+ [,bash]
125
+ ----
126
+ npx doc-tools generate metrics-docs --tag <version>
127
+ ----
128
+
129
+ *Required flags:*
130
+
131
+ --tag:: Redpanda version to generate docs for
132
+
133
+ *Output:*
134
+
135
+ Creates `modules/reference/pages/public-metrics-reference.adoc`
136
+
137
+ === rpk-docs
138
+
139
+ Generate RPK command-line documentation.
140
+
141
+ [,bash]
142
+ ----
143
+ npx doc-tools generate rpk-docs --tag <version>
144
+ ----
145
+
146
+ *Required flags:*
147
+
148
+ --tag:: Redpanda version to generate docs for
149
+
150
+ *Output:*
151
+
152
+ Creates AsciiDoc files in `autogenerated/v<version>/rpk/`
153
+
154
+ === rpcn-connector-docs
155
+
156
+ Generate Redpanda Connect connector documentation.
157
+
158
+ [,bash]
159
+ ----
160
+ npx doc-tools generate rpcn-connector-docs [options]
161
+ ----
162
+
163
+ *Optional flags:*
164
+
165
+ --fetch-connectors:: Fetch connector definitions from Redpanda Connect repository
166
+ --draft-missing:: Create draft pages for missing connectors
167
+ --update-whats-new:: Update the what's new page
168
+ --include-bloblang:: Include Bloblang documentation
169
+ --data-dir:: Directory containing connector data
170
+ --old-data:: Path to previous connector data for comparison
171
+ --csv:: Export connector data as CSV
172
+ --overrides:: Path to overrides JSON file
173
+
174
+ *Output:*
175
+
176
+ Creates component documentation files in `modules/reference/pages/redpanda-connect/components/`
177
+
178
+ === helm-spec
179
+
180
+ Generate Helm chart specification documentation.
181
+
182
+ [,bash]
183
+ ----
184
+ npx doc-tools generate helm-spec [options]
185
+ ----
186
+
187
+ *Optional flags:*
188
+
189
+ --chart-dir:: Path to Helm chart directory
190
+ --tag:: Helm chart version
191
+ --readme:: Include README content
192
+ --output-dir:: Output directory for generated files
193
+ --output-suffix:: Suffix for output files
194
+
195
+ === cloud-regions
196
+
197
+ Generate cloud regions documentation.
198
+
199
+ [,bash]
200
+ ----
201
+ npx doc-tools generate cloud-regions [options]
202
+ ----
203
+
204
+ *Optional flags:*
205
+
206
+ --output:: Output file path
207
+ --format:: Output format (json, yaml, adoc)
208
+ --owner:: GitHub repository owner
209
+ --repo:: GitHub repository name
210
+ --path:: Path to regions file in repository
211
+ --ref:: Git reference (branch, tag, commit)
212
+ --template:: AsciiDoc template file
213
+ --dry-run:: Show what would be generated without writing files
214
+
215
+ === crd-spec
216
+
217
+ Generate Custom Resource Definition (CRD) specification documentation.
218
+
219
+ [,bash]
220
+ ----
221
+ npx doc-tools generate crd-spec --tag <version> [options]
222
+ npx doc-tools generate crd-spec --branch <branch> [options]
223
+ ----
224
+
225
+ *Required flags (one of):*
226
+
227
+ --tag:: Redpanda Operator version tag (for released content)
228
+ --branch:: Branch name (for in-progress content)
229
+
230
+ *Optional flags:*
231
+
232
+ --source-path:: Path to CRD source files
233
+ --depth:: Maximum depth for nested properties
234
+ --templates-dir:: Directory containing documentation templates
235
+ --output:: Output directory
236
+
237
+ === bundle-openapi
238
+
239
+ Bundle OpenAPI specifications.
240
+
241
+ [,bash]
242
+ ----
243
+ npx doc-tools generate bundle-openapi --tag <version> [options]
244
+ ----
245
+
246
+ *Required flags:*
247
+
248
+ --tag:: Redpanda version for API specifications
249
+
250
+ *Optional flags:*
251
+
252
+ --repo:: Repository to fetch from
253
+ --surface:: API surface to bundle (admin, connect, or both)
254
+ --out-admin:: Output path for admin API bundle
255
+ --out-connect:: Output path for connect API bundle
256
+ --admin-major:: Major version for admin API
257
+ --use-admin-major-version:: Use major version in admin API bundle
258
+ --quiet:: Suppress output messages
259
+
260
+ == Output format contracts
261
+
262
+ === Version commands
263
+
264
+ Version commands (`get-redpanda-version`, `get-console-version`) must output key-value pairs in the format:
265
+
266
+ [,bash]
267
+ ----
268
+ KEY=value
269
+ ----
270
+
271
+ Lines starting with `#` are treated as comments and ignored by the MCP server.
272
+
273
+ === Generate commands
274
+
275
+ Generate commands should:
276
+
277
+ * Write to stdout for informational messages
278
+ * Write to stderr for errors
279
+ * Exit with code 0 on success
280
+ * Exit with non-zero code on failure
281
+
282
+ The MCP server parses stdout to extract:
283
+
284
+ * File counts (for example, "Generated 342 properties")
285
+ * File paths created
286
+ * Success/failure status
287
+
288
+ == Error handling contracts
289
+
290
+ === Missing required parameters
291
+
292
+ Commands must exit with non-zero status when required parameters are missing.
293
+
294
+ Example:
295
+
296
+ [,bash]
297
+ ----
298
+ $ npx doc-tools generate property-docs
299
+ Error: Required flag --tag is missing
300
+ $ echo $?
301
+ 1
302
+ ----
303
+
304
+ === Invalid flags
305
+
306
+ Commands must exit with non-zero status when invalid flags are provided.
307
+
308
+ Example:
309
+
310
+ [,bash]
311
+ ----
312
+ $ npx doc-tools generate property-docs --invalid-flag-xyz
313
+ Error: Unknown flag: --invalid-flag-xyz
314
+ $ echo $?
315
+ 1
316
+ ----
317
+
318
+ === Nonexistent commands
319
+
320
+ The CLI must exit with non-zero status when nonexistent commands are called.
321
+
322
+ Example:
323
+
324
+ [,bash]
325
+ ----
326
+ $ npx doc-tools generate nonexistent-command
327
+ Error: Unknown command: nonexistent-command
328
+ $ echo $?
329
+ 1
330
+ ----
331
+
332
+ === Network errors
333
+
334
+ Network errors (for example, GitHub API failures) are acceptable for version commands, but:
335
+
336
+ * Must write error message to stderr
337
+ * Must exit with non-zero status
338
+ * Error message should indicate the network issue
339
+
340
+ == Version compatibility
341
+
342
+ The CLI must support the `--version` flag to output the current version.
343
+
344
+ Format: `<major>.<minor>.<patch>`
345
+
346
+ This allows the MCP server to verify compatibility and provide helpful error messages if the CLI version is incompatible.
347
+
348
+ == Stability guarantees
349
+
350
+ The MCP server depends on these CLI contracts remaining stable:
351
+
352
+ *Command names and subcommands* must not change without a major version bump.
353
+
354
+ *Required flags* must not be removed or renamed without a major version bump.
355
+
356
+ *Output formats* for version commands must remain parseable.
357
+
358
+ *Exit codes* must follow Unix conventions (0 = success, non-zero = failure).
359
+
360
+ *Optional flags* may be added without breaking the MCP server.
361
+
362
+ *New subcommands* may be added without breaking the MCP server.
363
+
364
+ == Testing
365
+
366
+ The `cli-contract.test.js` test suite verifies these contracts automatically. All tests must pass before releasing a new version of doc-tools that could affect the MCP server.
367
+
368
+ Test categories:
369
+
370
+ * Command structure - Verifies commands and subcommands exist
371
+ * Flag support - Verifies required and optional flags are present
372
+ * Output format - Verifies output can be parsed correctly
373
+ * Error handling - Verifies proper exit codes and error messages
374
+ * Version compatibility - Verifies version information is available
375
+
376
+ == Breaking changes
377
+
378
+ If a breaking change to the CLI is necessary:
379
+
380
+ . Update the CLI with the breaking change
381
+ . Increment the major version in package.json
382
+ . Update the MCP server to handle both old and new interfaces (if possible)
383
+ . Update the CLI contract tests to verify the new interface
384
+ . Update this document with the new contract