@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,153 @@
1
+ /**
2
+ * MCP Tools - Kubernetes CRD Documentation Generation
3
+ *
4
+ * OPTIMIZATION: This tool calls CLI, doesn't use LLM directly.
5
+ * - No model recommendation (CLI tool)
6
+ * - Cost comes from doc-tools CLI execution
7
+ */
8
+
9
+ const { spawnSync } = require('child_process');
10
+ const { findRepoRoot, getDocToolsCommand, MAX_EXEC_BUFFER_SIZE, normalizeVersion, DEFAULT_COMMAND_TIMEOUT } = require('./utils');
11
+ const { getAntoraStructure } = require('./antora');
12
+
13
+ /**
14
+ * Generate Kubernetes CRD documentation
15
+ *
16
+ * Use tags for released content (GA or beta), branches for in-progress content.
17
+ *
18
+ * @param {Object} args - Arguments
19
+ * @param {string} [args.tag] - Operator release tag for GA/beta content (for example, operator/v2.2.6-25.3.1 or v25.1.2). Auto-prepends "operator/" if not present.
20
+ * @param {string} [args.branch] - Branch name for in-progress content (for example, release/v2.2.x, main, dev)
21
+ * @param {string} [args.source_path] - CRD Go types dir or GitHub URL
22
+ * @param {number} [args.depth] - How many levels deep to generate
23
+ * @param {string} [args.templates_dir] - Asciidoctor templates directory
24
+ * @param {string} [args.output] - Where to write the generated AsciiDoc file
25
+ * @returns {Object} Generation results
26
+ */
27
+ function generateCrdDocs(args) {
28
+ const repoRoot = findRepoRoot();
29
+ const structure = getAntoraStructure(repoRoot);
30
+
31
+ if (!structure.hasDocTools) {
32
+ return {
33
+ success: false,
34
+ error: 'doc-tools not found in this repository',
35
+ suggestion: 'Navigate to the docs-extensions-and-macros repository'
36
+ };
37
+ }
38
+
39
+ // Validate that either tag or branch is provided (but not both)
40
+ if (!args.tag && !args.branch) {
41
+ return {
42
+ success: false,
43
+ error: 'Either tag or branch is required',
44
+ suggestion: 'Provide --tag "operator/v25.1.2" or --branch "main"'
45
+ };
46
+ }
47
+
48
+ if (args.tag && args.branch) {
49
+ return {
50
+ success: false,
51
+ error: 'Cannot specify both tag and branch',
52
+ suggestion: 'Use either --tag or --branch, not both'
53
+ };
54
+ }
55
+
56
+ try {
57
+ // Get the appropriate doc-tools command (local or installed)
58
+ const docTools = getDocToolsCommand(repoRoot);
59
+
60
+ // Build command arguments array (no shell interpolation)
61
+ const cmdArgs = ['generate', 'crd-spec'];
62
+
63
+ // Add tag or branch flag
64
+ if (args.tag) {
65
+ cmdArgs.push('--tag');
66
+ cmdArgs.push(args.tag);
67
+ } else {
68
+ cmdArgs.push('--branch');
69
+ cmdArgs.push(args.branch);
70
+ }
71
+
72
+ if (args.source_path) {
73
+ cmdArgs.push('--source-path');
74
+ cmdArgs.push(args.source_path);
75
+ }
76
+
77
+ if (args.depth) {
78
+ cmdArgs.push('--depth');
79
+ cmdArgs.push(String(args.depth));
80
+ }
81
+
82
+ if (args.templates_dir) {
83
+ cmdArgs.push('--templates-dir');
84
+ cmdArgs.push(args.templates_dir);
85
+ }
86
+
87
+ if (args.output) {
88
+ cmdArgs.push('--output');
89
+ cmdArgs.push(args.output);
90
+ }
91
+
92
+ const result = spawnSync(docTools.program, docTools.getArgs(cmdArgs), {
93
+ cwd: repoRoot.root,
94
+ encoding: 'utf8',
95
+ stdio: 'pipe',
96
+ maxBuffer: MAX_EXEC_BUFFER_SIZE,
97
+ timeout: DEFAULT_COMMAND_TIMEOUT
98
+ });
99
+
100
+ // Check for spawn errors
101
+ if (result.error) {
102
+ const err = new Error(`Failed to execute command: ${result.error.message}`);
103
+ err.stdout = result.stdout || '';
104
+ err.stderr = result.stderr || '';
105
+ err.status = result.status;
106
+ throw err;
107
+ }
108
+
109
+ // Check for non-zero exit codes
110
+ if (result.status !== 0) {
111
+ const errorMsg = result.stderr || `Command failed with exit code ${result.status}`;
112
+ const err = new Error(errorMsg);
113
+ err.stdout = result.stdout || '';
114
+ err.stderr = result.stderr || '';
115
+ err.status = result.status;
116
+ throw err;
117
+ }
118
+
119
+ const output = result.stdout;
120
+
121
+ const ref = args.tag || args.branch;
122
+ const refType = args.tag ? 'tag' : 'branch';
123
+
124
+ return {
125
+ success: true,
126
+ [refType]: ref,
127
+ files_generated: [args.output || 'modules/reference/pages/k-crd.adoc'],
128
+ output: output.trim(),
129
+ summary: `Generated CRD documentation for operator ${refType} ${ref}`
130
+ };
131
+ } catch (err) {
132
+ // Check if the error is due to --branch not being supported (old doc-tools version)
133
+ const isOldVersionError = err.stderr &&
134
+ err.stderr.includes('required option') &&
135
+ err.stderr.includes('--tag') &&
136
+ args.branch;
137
+
138
+ return {
139
+ success: false,
140
+ error: err.message,
141
+ stdout: err.stdout || '',
142
+ stderr: err.stderr || '',
143
+ exitCode: err.status,
144
+ suggestion: isOldVersionError
145
+ ? 'Your doc-tools version doesn\'t support --branch. Update with: npm install (in docs-extensions-and-macros repo)'
146
+ : 'Check that the operator tag exists in the repository'
147
+ };
148
+ }
149
+ }
150
+
151
+ module.exports = {
152
+ generateCrdDocs
153
+ };
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Frontmatter Parser for MCP Prompts
3
+ *
4
+ * Parses YAML frontmatter from markdown files to extract metadata.
5
+ * Supports validation against JSON schemas.
6
+ */
7
+
8
+ const yaml = require('js-yaml');
9
+
10
+ /**
11
+ * Parse frontmatter from markdown content
12
+ * @param {string} content - Markdown content with optional frontmatter
13
+ * @returns {{ metadata: Object, content: string }} Parsed frontmatter and remaining content
14
+ */
15
+ function parseFrontmatter(content) {
16
+ const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
17
+ const match = content.match(frontmatterRegex);
18
+
19
+ if (!match) {
20
+ // No frontmatter found - return empty metadata and full content
21
+ return {
22
+ metadata: {},
23
+ content: content
24
+ };
25
+ }
26
+
27
+ try {
28
+ const metadata = yaml.load(match[1]) || {};
29
+ const remainingContent = match[2];
30
+
31
+ return {
32
+ metadata,
33
+ content: remainingContent
34
+ };
35
+ } catch (err) {
36
+ throw new Error(`Failed to parse YAML frontmatter: ${err.message}`);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * JSON Schema for prompt frontmatter
42
+ */
43
+ const promptFrontmatterSchema = {
44
+ type: 'object',
45
+ properties: {
46
+ description: {
47
+ type: 'string',
48
+ minLength: 10,
49
+ description: 'Description of what this prompt does'
50
+ },
51
+ version: {
52
+ type: 'string',
53
+ pattern: '^\\d+\\.\\d+\\.\\d+$',
54
+ description: 'Semantic version (for example, 1.0.0)'
55
+ },
56
+ arguments: {
57
+ type: 'array',
58
+ description: 'Arguments this prompt accepts',
59
+ items: {
60
+ type: 'object',
61
+ required: ['name', 'description', 'required'],
62
+ properties: {
63
+ name: {
64
+ type: 'string',
65
+ pattern: '^[a-z_][a-z0-9_]*$',
66
+ description: 'Argument name (lowercase, underscores allowed)'
67
+ },
68
+ description: {
69
+ type: 'string',
70
+ minLength: 5,
71
+ description: 'What this argument is for'
72
+ },
73
+ required: {
74
+ type: 'boolean',
75
+ description: 'Whether this argument is required'
76
+ }
77
+ },
78
+ additionalProperties: false
79
+ }
80
+ },
81
+ argumentFormat: {
82
+ type: 'string',
83
+ enum: ['content-append', 'structured'],
84
+ description: 'How to format arguments when building the prompt'
85
+ }
86
+ },
87
+ additionalProperties: false
88
+ };
89
+
90
+ /**
91
+ * Validate frontmatter against schema
92
+ * @param {Object} metadata - Parsed frontmatter metadata
93
+ * @param {string} filename - File name (for error messages)
94
+ * @param {Object} schema - JSON schema to validate against
95
+ * @throws {Error} If validation fails
96
+ */
97
+ function validateFrontmatter(metadata, filename, schema = promptFrontmatterSchema) {
98
+ const Ajv = require('ajv');
99
+ const ajv = new Ajv({ allErrors: true });
100
+
101
+ const valid = ajv.validate(schema, metadata);
102
+
103
+ if (!valid) {
104
+ const errors = ajv.errors.map(err => {
105
+ const path = err.instancePath || 'root';
106
+ return ` - ${path}: ${err.message}`;
107
+ }).join('\n');
108
+
109
+ throw new Error(`Invalid frontmatter in ${filename}:\n${errors}`);
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Parse and validate prompt file
115
+ * @param {string} content - File content
116
+ * @param {string} filename - File name
117
+ * @returns {{ metadata: Object, content: string }} Validated metadata and content
118
+ */
119
+ function parsePromptFile(content, filename) {
120
+ const { metadata, content: promptContent } = parseFrontmatter(content);
121
+
122
+ // If metadata exists, validate it
123
+ if (Object.keys(metadata).length > 0) {
124
+ validateFrontmatter(metadata, filename);
125
+ }
126
+
127
+ return {
128
+ metadata,
129
+ content: promptContent
130
+ };
131
+ }
132
+
133
+ module.exports = {
134
+ parseFrontmatter,
135
+ parsePromptFile,
136
+ validateFrontmatter,
137
+ promptFrontmatterSchema
138
+ };