specweave 0.21.0 → 0.21.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.
- package/.claude-plugin/marketplace.json +44 -0
- package/dist/locales/de/.gitkeep +0 -0
- package/dist/locales/de/cli.json +108 -0
- package/dist/locales/en/cli.json +287 -0
- package/dist/locales/en/errors.json +7 -0
- package/dist/locales/en/templates.json +6 -0
- package/dist/locales/es/.gitkeep +0 -0
- package/dist/locales/es/cli.json +41 -0
- package/dist/locales/fr/.gitkeep +0 -0
- package/dist/locales/fr/cli.json +108 -0
- package/dist/locales/ja/.gitkeep +0 -0
- package/dist/locales/ja/cli.json +108 -0
- package/dist/locales/ko/.gitkeep +0 -0
- package/dist/locales/ko/cli.json +108 -0
- package/dist/locales/pt/.gitkeep +0 -0
- package/dist/locales/pt/cli.json +108 -0
- package/dist/locales/ru/.gitkeep +0 -0
- package/dist/locales/ru/cli.json +269 -0
- package/dist/locales/zh/.gitkeep +0 -0
- package/dist/locales/zh/cli.json +108 -0
- package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.d.ts +25 -0
- package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.d.ts.map +1 -0
- package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.js +191 -0
- package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.js.map +1 -0
- package/dist/plugins/specweave-kafka/lib/cli/kcat-wrapper.d.ts +57 -0
- package/dist/plugins/specweave-kafka/lib/cli/kcat-wrapper.d.ts.map +1 -0
- package/dist/plugins/specweave-kafka/lib/cli/kcat-wrapper.js +248 -0
- package/dist/plugins/specweave-kafka/lib/cli/kcat-wrapper.js.map +1 -0
- package/dist/plugins/specweave-kafka/lib/cli/types.d.ts +82 -0
- package/dist/plugins/specweave-kafka/lib/cli/types.d.ts.map +1 -0
- package/dist/plugins/specweave-kafka/lib/cli/types.js +13 -0
- package/dist/plugins/specweave-kafka/lib/cli/types.js.map +1 -0
- package/dist/plugins/specweave-kafka/lib/mcp/detector.d.ts +49 -0
- package/dist/plugins/specweave-kafka/lib/mcp/detector.d.ts.map +1 -0
- package/dist/plugins/specweave-kafka/lib/mcp/detector.js +316 -0
- package/dist/plugins/specweave-kafka/lib/mcp/detector.js.map +1 -0
- package/dist/plugins/specweave-kafka/lib/mcp/types.d.ts +70 -0
- package/dist/plugins/specweave-kafka/lib/mcp/types.d.ts.map +1 -0
- package/dist/plugins/specweave-kafka/lib/mcp/types.js +23 -0
- package/dist/plugins/specweave-kafka/lib/mcp/types.js.map +1 -0
- package/dist/plugins/specweave-kafka/lib/utils/partitioning.d.ts +85 -0
- package/dist/plugins/specweave-kafka/lib/utils/partitioning.d.ts.map +1 -0
- package/dist/plugins/specweave-kafka/lib/utils/partitioning.js +281 -0
- package/dist/plugins/specweave-kafka/lib/utils/partitioning.js.map +1 -0
- package/dist/plugins/specweave-kafka/lib/utils/sizing.d.ts +75 -0
- package/dist/plugins/specweave-kafka/lib/utils/sizing.d.ts.map +1 -0
- package/dist/plugins/specweave-kafka/lib/utils/sizing.js +238 -0
- package/dist/plugins/specweave-kafka/lib/utils/sizing.js.map +1 -0
- package/dist/spec-parser.js +629 -0
- package/dist/src/core/increment/conflict-resolver.d.ts.map +1 -1
- package/dist/src/core/increment/conflict-resolver.js +4 -1
- package/dist/src/core/increment/conflict-resolver.js.map +1 -1
- package/dist/src/core/increment/duplicate-detector.d.ts +3 -0
- package/dist/src/core/increment/duplicate-detector.d.ts.map +1 -1
- package/dist/src/core/increment/duplicate-detector.js +22 -4
- package/dist/src/core/increment/duplicate-detector.js.map +1 -1
- package/dist/src/core/sync/spec-content-sync.d.ts +88 -0
- package/dist/src/core/sync/spec-content-sync.d.ts.map +1 -0
- package/dist/src/core/sync/spec-content-sync.js +5 -0
- package/dist/src/core/sync/spec-content-sync.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/plugins/specweave-ado/lib/enhanced-ado-sync.js +170 -0
- package/src/templates/AGENTS.md.template +41 -6
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"init": {
|
|
3
|
+
"welcome": "🚀 SpecWeave Initialization",
|
|
4
|
+
"projectName": "Project name:",
|
|
5
|
+
"projectNamePrompt": "Project name (for templates):",
|
|
6
|
+
"projectNameDefault": "my-saas",
|
|
7
|
+
"detectingTool": "Detecting AI tool...",
|
|
8
|
+
"foundClaude": "✅ Found Claude Code",
|
|
9
|
+
"foundCursor": "✅ Found Cursor",
|
|
10
|
+
"foundCopilot": "✅ Found GitHub Copilot",
|
|
11
|
+
"noToolDetected": "No AI tool detected, using Generic adapter",
|
|
12
|
+
"complete": "✨ Initialization complete!",
|
|
13
|
+
"claudeNativeComplete": "✨ Claude Code native installation complete!",
|
|
14
|
+
"claudeNativeBenefits": "✅ Native skills, agents, hooks work out of the box",
|
|
15
|
+
"projectSuccess": "SpecWeave project created successfully!",
|
|
16
|
+
"readyToBuild": "🚀 Ready to build with SpecWeave!",
|
|
17
|
+
"errors": {
|
|
18
|
+
"invalidName": "Project name must contain only lowercase letters, numbers, and hyphens",
|
|
19
|
+
"alreadyExists": ".specweave directory already exists",
|
|
20
|
+
"cancelled": "❌ Initialization cancelled",
|
|
21
|
+
"invalidLanguage": "❌ Invalid language: {{language}}",
|
|
22
|
+
"supportedLanguages": "Supported languages: {{languages}}",
|
|
23
|
+
"nestedNotSupported": "❌ Nested .specweave/ folders are NOT supported!",
|
|
24
|
+
"parentFound": "Found parent .specweave/ at:",
|
|
25
|
+
"projectCreationFailed": "Failed to create project",
|
|
26
|
+
"commandsCopyFailed": "❌ Commands copy failed: {{error}}",
|
|
27
|
+
"agentsCopyFailed": "❌ Agents copy failed: {{error}}",
|
|
28
|
+
"skillsCopyFailed": "❌ Skills copy failed: {{error}}",
|
|
29
|
+
"hooksCopyFailed": "❌ Hooks copy failed: {{error}}"
|
|
30
|
+
},
|
|
31
|
+
"warnings": {
|
|
32
|
+
"invalidDirName": "⚠️ Current directory name '{{dirName}}' contains invalid characters.",
|
|
33
|
+
"directoryNotEmpty": "⚠️ Current directory contains {{count}} file{{plural}}.",
|
|
34
|
+
"skillsIndexWarning": "⚠️ Warning: Could not generate skills index: {{error}}",
|
|
35
|
+
"skillsIndexNote": "Skills will still work, but manual indexing may be needed."
|
|
36
|
+
},
|
|
37
|
+
"prompts": {
|
|
38
|
+
"confirmInitInCurrent": "Initialize SpecWeave in current directory?",
|
|
39
|
+
"overwriteSpecweave": ".specweave directory already exists. Overwrite?",
|
|
40
|
+
"overwriteDirectory": "Directory {{projectName}} already exists. Overwrite?",
|
|
41
|
+
"enablePlugins": "Enable suggested plugins now?"
|
|
42
|
+
},
|
|
43
|
+
"info": {
|
|
44
|
+
"nestedEnforcement": "SpecWeave enforces a single source of truth:",
|
|
45
|
+
"nestedBullet1": "• Use the parent folder for all increments",
|
|
46
|
+
"nestedBullet2": "• Increments can span multiple subdirectories",
|
|
47
|
+
"nestedBullet3": "• See CLAUDE.md section \"Root-Level .specweave/ Folder\"",
|
|
48
|
+
"nestedToFix": "To fix:",
|
|
49
|
+
"suggestedPlugins": "💡 Suggested Plugins:",
|
|
50
|
+
"copiedFiles": "✓ Copied {{count}} command files",
|
|
51
|
+
"copiedAgents": "✓ Copied {{count}} agent directories",
|
|
52
|
+
"copiedSkills": "✓ Copied {{count}} skill directories",
|
|
53
|
+
"copiedHooks": "✓ Copied {{count}} hook files"
|
|
54
|
+
},
|
|
55
|
+
"progress": {
|
|
56
|
+
"creatingProject": "Creating SpecWeave project...",
|
|
57
|
+
"detected": "Detected {{tool}}...",
|
|
58
|
+
"usingTool": "Using {{tool}}...",
|
|
59
|
+
"directoryCreated": "Directory structure created...",
|
|
60
|
+
"templatesCopied": "Base templates copied...",
|
|
61
|
+
"installingComponents": "Installing Claude Code components...",
|
|
62
|
+
"commandsInstalled": "Slash commands installed...",
|
|
63
|
+
"agentsInstalled": "Agents installed...",
|
|
64
|
+
"skillsInstalled": "Skills installed...",
|
|
65
|
+
"hooksInstalled": "Hooks installed...",
|
|
66
|
+
"generatingIndex": "Generating skills index...",
|
|
67
|
+
"indexGenerated": "Skills index generated...",
|
|
68
|
+
"installingAdapter": "Installing {{tool}} adapter...",
|
|
69
|
+
"projectSuccess": "SpecWeave project created successfully!",
|
|
70
|
+
"detectingPlugins": "Detecting plugins...",
|
|
71
|
+
"detectedPlugins": "Detected {{count}} suggested plugins",
|
|
72
|
+
"enablingPlugins": "Enabling plugins...",
|
|
73
|
+
"enabledPlugin": "Enabled {{plugin}}",
|
|
74
|
+
"pluginsEnabled": "Plugins enabled"
|
|
75
|
+
},
|
|
76
|
+
"nextSteps": {
|
|
77
|
+
"header": "🎯 Next steps:",
|
|
78
|
+
"cd": "cd {{projectName}}",
|
|
79
|
+
"footer": "🚀 Ready to build with SpecWeave!",
|
|
80
|
+
"docsLink": "Documentation: https://spec-weave.com",
|
|
81
|
+
"githubLink": "GitHub: https://github.com/anton-abyzov/specweave"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"increment": {
|
|
85
|
+
"creating": "📝 Creating increment: {name}",
|
|
86
|
+
"created": "✅ Increment {id} created successfully!",
|
|
87
|
+
"nextStepDo": "Next: Run /specweave.do to start implementation",
|
|
88
|
+
"errors": {
|
|
89
|
+
"incompleteFound": "Cannot create new increment! Previous increments incomplete"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"progress": {
|
|
93
|
+
"currentIncrement": "Current Increment: {id}",
|
|
94
|
+
"status": "Status: {status}",
|
|
95
|
+
"completion": "Completion: {percent}%"
|
|
96
|
+
},
|
|
97
|
+
"translate": {
|
|
98
|
+
"translating": "🌐 Translating content to {language}...",
|
|
99
|
+
"complete": "✅ Translation complete!"
|
|
100
|
+
},
|
|
101
|
+
"version": {
|
|
102
|
+
"current": "SpecWeave version: {version}"
|
|
103
|
+
},
|
|
104
|
+
"errors": {
|
|
105
|
+
"fileNotFound": "❌ File not found: {path}",
|
|
106
|
+
"invalidConfig": "❌ Invalid configuration: {error}"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Azure DevOps Spec Content Sync
|
|
3
|
+
*
|
|
4
|
+
* Uses EnhancedContentBuilder and SpecIncrementMapper for rich feature descriptions.
|
|
5
|
+
*/
|
|
6
|
+
export interface EnhancedAdoSyncOptions {
|
|
7
|
+
specPath: string;
|
|
8
|
+
organization?: string;
|
|
9
|
+
project?: string;
|
|
10
|
+
dryRun?: boolean;
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface EnhancedAdoSyncResult {
|
|
14
|
+
success: boolean;
|
|
15
|
+
action: 'created' | 'updated' | 'no-change' | 'error';
|
|
16
|
+
featureId?: number;
|
|
17
|
+
featureUrl?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
tasksLinked?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Enhanced sync with rich content including task mappings
|
|
23
|
+
*/
|
|
24
|
+
export declare function syncSpecToAdoWithEnhancedContent(options: EnhancedAdoSyncOptions): Promise<EnhancedAdoSyncResult>;
|
|
25
|
+
//# sourceMappingURL=enhanced-ado-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-ado-sync.d.ts","sourceRoot":"","sources":["../../../../plugins/specweave-ado/lib/enhanced-ado-sync.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAgIhC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Azure DevOps Spec Content Sync
|
|
3
|
+
*
|
|
4
|
+
* Uses EnhancedContentBuilder and SpecIncrementMapper for rich feature descriptions.
|
|
5
|
+
*/
|
|
6
|
+
import { AdoClientV2 } from './ado-client-v2.js';
|
|
7
|
+
import { EnhancedContentBuilder } from '../../../src/core/sync/enhanced-content-builder.js';
|
|
8
|
+
import { SpecIncrementMapper } from '../../../src/core/sync/spec-increment-mapper.js';
|
|
9
|
+
import { parseSpecContent } from '../../../src/core/spec-content-sync.js';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import fs from 'fs/promises';
|
|
12
|
+
/**
|
|
13
|
+
* Enhanced sync with rich content including task mappings
|
|
14
|
+
*/
|
|
15
|
+
export async function syncSpecToAdoWithEnhancedContent(options) {
|
|
16
|
+
const { specPath, organization, project, dryRun = false, verbose = false } = options;
|
|
17
|
+
try {
|
|
18
|
+
// 1. Parse spec content
|
|
19
|
+
const baseSpec = await parseSpecContent(specPath);
|
|
20
|
+
if (!baseSpec) {
|
|
21
|
+
return {
|
|
22
|
+
success: false,
|
|
23
|
+
action: 'error',
|
|
24
|
+
error: 'Failed to parse spec content',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (verbose) {
|
|
28
|
+
console.log(`📄 Parsed spec: ${baseSpec.identifier.compact}`);
|
|
29
|
+
}
|
|
30
|
+
// 2. Build enhanced spec with task mappings
|
|
31
|
+
const specId = baseSpec.identifier.full || baseSpec.identifier.compact;
|
|
32
|
+
const rootDir = await findSpecWeaveRoot(specPath);
|
|
33
|
+
const mapper = new SpecIncrementMapper(rootDir);
|
|
34
|
+
const mapping = await mapper.mapSpecToIncrements(specId);
|
|
35
|
+
if (verbose) {
|
|
36
|
+
console.log(`🔗 Found ${mapping.increments.length} related increments`);
|
|
37
|
+
}
|
|
38
|
+
// 3. Build enhanced spec content
|
|
39
|
+
const taskMapping = buildTaskMapping(mapping.increments, organization, project);
|
|
40
|
+
const architectureDocs = await findArchitectureDocs(rootDir, specId);
|
|
41
|
+
const enhancedSpec = {
|
|
42
|
+
...baseSpec,
|
|
43
|
+
summary: baseSpec.description,
|
|
44
|
+
taskMapping,
|
|
45
|
+
architectureDocs
|
|
46
|
+
};
|
|
47
|
+
// 4. Build external description
|
|
48
|
+
const builder = new EnhancedContentBuilder();
|
|
49
|
+
const description = builder.buildExternalDescription(enhancedSpec);
|
|
50
|
+
if (verbose) {
|
|
51
|
+
console.log(`📝 Generated description: ${description.length} characters`);
|
|
52
|
+
}
|
|
53
|
+
if (dryRun) {
|
|
54
|
+
console.log('🔍 DRY RUN - Would create/update feature with:');
|
|
55
|
+
console.log(` Title: ${baseSpec.title}`);
|
|
56
|
+
console.log(` Description length: ${description.length}`);
|
|
57
|
+
return {
|
|
58
|
+
success: true,
|
|
59
|
+
action: 'no-change',
|
|
60
|
+
tasksLinked: taskMapping?.tasks.length || 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// 5. Create or update ADO feature
|
|
64
|
+
if (!organization || !project) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
action: 'error',
|
|
68
|
+
error: 'Azure DevOps organization/project not specified',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Create a sync profile for the ADO client
|
|
72
|
+
const profile = {
|
|
73
|
+
provider: 'ado',
|
|
74
|
+
displayName: `${organization}/${project}`,
|
|
75
|
+
config: {
|
|
76
|
+
organization,
|
|
77
|
+
project
|
|
78
|
+
},
|
|
79
|
+
timeRange: { default: '1M', max: '6M' }
|
|
80
|
+
};
|
|
81
|
+
const pat = process.env.AZURE_DEVOPS_PAT || '';
|
|
82
|
+
const client = new AdoClientV2(profile, pat);
|
|
83
|
+
// Check if feature already exists
|
|
84
|
+
const existingFeature = await findExistingFeature(client, baseSpec.identifier.compact);
|
|
85
|
+
let result;
|
|
86
|
+
if (existingFeature) {
|
|
87
|
+
// Update existing feature
|
|
88
|
+
await client.updateWorkItem(existingFeature.id, {
|
|
89
|
+
title: `[${baseSpec.identifier.compact}] ${baseSpec.title}`,
|
|
90
|
+
description
|
|
91
|
+
});
|
|
92
|
+
result = {
|
|
93
|
+
success: true,
|
|
94
|
+
action: 'updated',
|
|
95
|
+
featureId: existingFeature.id,
|
|
96
|
+
featureUrl: `https://dev.azure.com/${organization}/${project}/_workitems/edit/${existingFeature.id}`,
|
|
97
|
+
tasksLinked: taskMapping?.tasks.length || 0
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Create new feature (using createEpic which creates Feature work item type)
|
|
102
|
+
const feature = await client.createEpic({
|
|
103
|
+
title: `[${baseSpec.identifier.compact}] ${baseSpec.title}`,
|
|
104
|
+
description,
|
|
105
|
+
tags: ['spec', 'external-tool-sync']
|
|
106
|
+
});
|
|
107
|
+
result = {
|
|
108
|
+
success: true,
|
|
109
|
+
action: 'created',
|
|
110
|
+
featureId: feature.id,
|
|
111
|
+
featureUrl: `https://dev.azure.com/${organization}/${project}/_workitems/edit/${feature.id}`,
|
|
112
|
+
tasksLinked: taskMapping?.tasks.length || 0
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (verbose) {
|
|
116
|
+
console.log(`✅ ${result.action === 'created' ? 'Created' : 'Updated'} feature #${result.featureId}`);
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return {
|
|
122
|
+
success: false,
|
|
123
|
+
action: 'error',
|
|
124
|
+
error: error.message
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Helper functions
|
|
129
|
+
async function findSpecWeaveRoot(specPath) {
|
|
130
|
+
let currentDir = path.dirname(specPath);
|
|
131
|
+
while (true) {
|
|
132
|
+
const specweaveDir = path.join(currentDir, '.specweave');
|
|
133
|
+
try {
|
|
134
|
+
await fs.access(specweaveDir);
|
|
135
|
+
return currentDir;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
const parentDir = path.dirname(currentDir);
|
|
139
|
+
if (parentDir === currentDir) {
|
|
140
|
+
throw new Error('.specweave directory not found');
|
|
141
|
+
}
|
|
142
|
+
currentDir = parentDir;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function buildTaskMapping(increments, organization, project) {
|
|
147
|
+
if (increments.length === 0)
|
|
148
|
+
return undefined;
|
|
149
|
+
const firstIncrement = increments[0];
|
|
150
|
+
const tasks = firstIncrement.tasks.map((task) => ({
|
|
151
|
+
id: task.id,
|
|
152
|
+
title: task.title,
|
|
153
|
+
userStories: task.userStories
|
|
154
|
+
}));
|
|
155
|
+
return {
|
|
156
|
+
incrementId: firstIncrement.id,
|
|
157
|
+
tasks,
|
|
158
|
+
tasksUrl: `https://dev.azure.com/${organization}/${project}/_git/repo?path=/.specweave/increments/${firstIncrement.id}/tasks.md`
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
async function findArchitectureDocs(rootDir, specId) {
|
|
162
|
+
const docs = [];
|
|
163
|
+
const archDir = path.join(rootDir, '.specweave/docs/internal/architecture');
|
|
164
|
+
try {
|
|
165
|
+
const adrDir = path.join(archDir, 'adr');
|
|
166
|
+
try {
|
|
167
|
+
const adrs = await fs.readdir(adrDir);
|
|
168
|
+
const relatedAdrs = adrs.filter(file => file.includes(specId.replace('spec-', '')));
|
|
169
|
+
for (const adr of relatedAdrs) {
|
|
170
|
+
docs.push({
|
|
171
|
+
type: 'adr',
|
|
172
|
+
path: path.join(adrDir, adr),
|
|
173
|
+
title: adr.replace('.md', '').replace(/-/g, ' ')
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch { }
|
|
178
|
+
}
|
|
179
|
+
catch { }
|
|
180
|
+
return docs;
|
|
181
|
+
}
|
|
182
|
+
async function findExistingFeature(client, specId) {
|
|
183
|
+
try {
|
|
184
|
+
const features = await client.queryWorkItems(`[System.Title] Contains '[${specId}]' AND [System.WorkItemType] = 'Feature'`);
|
|
185
|
+
return features[0] || null;
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=enhanced-ado-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-ado-sync.js","sourceRoot":"","sources":["../../../../plugins/specweave-ado/lib/enhanced-ado-sync.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAuB,MAAM,oDAAoD,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAY,MAAM,iDAAiD,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAmB7B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,OAA+B;IAE/B,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAErF,IAAI,CAAC;QACH,wBAAwB;QACxB,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO;gBACL,OAAO,EAAE,K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+
* kcat CLI Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Type-safe TypeScript wrapper for kcat (kafkacat) CLI tool.
|
|
5
|
+
* Provides produce, consume, metadata, and query operations.
|
|
6
|
+
*/
|
|
7
|
+
import { KcatProduceOptions, KcatConsumeOptions, KcatMetadataOptions, KcatQueryOptions, ClusterMetadata, ConsumerMessage, CLIExecutionResult } from './types';
|
|
8
|
+
export declare class KcatWrapper {
|
|
9
|
+
/**
|
|
10
|
+
* Produce a message to Kafka topic
|
|
11
|
+
*/
|
|
12
|
+
produce(message: string, options: KcatProduceOptions): Promise<CLIExecutionResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Consume messages from Kafka topic
|
|
15
|
+
*/
|
|
16
|
+
consume(options: KcatConsumeOptions): Promise<ConsumerMessage[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Get cluster metadata
|
|
19
|
+
*/
|
|
20
|
+
getMetadata(options: KcatMetadataOptions): Promise<ClusterMetadata>;
|
|
21
|
+
/**
|
|
22
|
+
* Query topic offsets
|
|
23
|
+
*/
|
|
24
|
+
queryOffsets(options: KcatQueryOptions): Promise<Record<number, {
|
|
25
|
+
earliest: number;
|
|
26
|
+
latest: number;
|
|
27
|
+
}>>;
|
|
28
|
+
/**
|
|
29
|
+
* Execute kcat command
|
|
30
|
+
*/
|
|
31
|
+
private execute;
|
|
32
|
+
/**
|
|
33
|
+
* Parse consume output into messages
|
|
34
|
+
*/
|
|
35
|
+
private parseConsumeOutput;
|
|
36
|
+
/**
|
|
37
|
+
* Parse metadata JSON output
|
|
38
|
+
*/
|
|
39
|
+
private parseMetadataOutput;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate replication factor from partitions
|
|
42
|
+
*/
|
|
43
|
+
private calculateReplicationFactor;
|
|
44
|
+
/**
|
|
45
|
+
* Parse query offset output
|
|
46
|
+
*/
|
|
47
|
+
private parseQueryOutput;
|
|
48
|
+
/**
|
|
49
|
+
* Check if kcat is installed
|
|
50
|
+
*/
|
|
51
|
+
static isInstalled(): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Get kcat version
|
|
54
|
+
*/
|
|
55
|
+
static getVersion(): Promise<string>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=kcat-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kcat-wrapper.d.ts","sourceRoot":"","sources":["../../../../../plugins/specweave-kafka/lib/cli/kcat-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,kBAAkB,EAGnB,MAAM,SAAS,CAAC;AAIjB,qBAAa,WAAW;IACtB;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+BxF;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAmCtE;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAsBzE;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAsB5G;;OAEG;YACW,OAAO;IAsCrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAKlC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;OAEG;WACU,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAS5C;;OAEG;WACU,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;CAS3C"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kcat CLI Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Type-safe TypeScript wrapper for kcat (kafkacat) CLI tool.
|
|
5
|
+
* Provides produce, consume, metadata, and query operations.
|
|
6
|
+
*/
|
|
7
|
+
import { exec } from 'child_process';
|
|
8
|
+
import { promisify } from 'util';
|
|
9
|
+
const execAsync = promisify(exec);
|
|
10
|
+
export class KcatWrapper {
|
|
11
|
+
/**
|
|
12
|
+
* Produce a message to Kafka topic
|
|
13
|
+
*/
|
|
14
|
+
async produce(message, options) {
|
|
15
|
+
const args = [
|
|
16
|
+
'kcat',
|
|
17
|
+
'-P', // Producer mode
|
|
18
|
+
'-b', options.brokers,
|
|
19
|
+
'-t', options.topic
|
|
20
|
+
];
|
|
21
|
+
if (options.key) {
|
|
22
|
+
args.push('-K', ':'); // Key delimiter
|
|
23
|
+
}
|
|
24
|
+
if (options.partition !== undefined) {
|
|
25
|
+
args.push('-p', options.partition.toString());
|
|
26
|
+
}
|
|
27
|
+
if (options.compression) {
|
|
28
|
+
args.push('-z', options.compression);
|
|
29
|
+
}
|
|
30
|
+
if (options.acks !== undefined) {
|
|
31
|
+
const acksValue = options.acks === 'all' ? '-1' : options.acks.toString();
|
|
32
|
+
args.push('-X', `acks=${acksValue}`);
|
|
33
|
+
}
|
|
34
|
+
const command = args.join(' ');
|
|
35
|
+
const input = options.key ? `${options.key}:${message}` : message;
|
|
36
|
+
return this.execute(command, input);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Consume messages from Kafka topic
|
|
40
|
+
*/
|
|
41
|
+
async consume(options) {
|
|
42
|
+
const args = [
|
|
43
|
+
'kcat',
|
|
44
|
+
'-C', // Consumer mode
|
|
45
|
+
'-b', options.brokers,
|
|
46
|
+
'-t', options.topic,
|
|
47
|
+
'-f', '%t:%p:%o:%k:%s\\n' // Format: topic:partition:offset:key:value
|
|
48
|
+
];
|
|
49
|
+
if (options.offset) {
|
|
50
|
+
args.push('-o', options.offset.toString());
|
|
51
|
+
}
|
|
52
|
+
if (options.partition !== undefined) {
|
|
53
|
+
args.push('-p', options.partition.toString());
|
|
54
|
+
}
|
|
55
|
+
if (options.count) {
|
|
56
|
+
args.push('-c', options.count.toString());
|
|
57
|
+
}
|
|
58
|
+
if (options.groupId) {
|
|
59
|
+
args.push('-G', options.groupId);
|
|
60
|
+
}
|
|
61
|
+
const command = args.join(' ');
|
|
62
|
+
const result = await this.execute(command);
|
|
63
|
+
if (!result.success) {
|
|
64
|
+
throw new Error(`kcat consume failed: ${result.error}`);
|
|
65
|
+
}
|
|
66
|
+
return this.parseConsumeOutput(result.output);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get cluster metadata
|
|
70
|
+
*/
|
|
71
|
+
async getMetadata(options) {
|
|
72
|
+
const args = [
|
|
73
|
+
'kcat',
|
|
74
|
+
'-L', // Metadata mode
|
|
75
|
+
'-b', options.brokers,
|
|
76
|
+
'-J' // JSON output
|
|
77
|
+
];
|
|
78
|
+
if (options.topic) {
|
|
79
|
+
args.push('-t', options.topic);
|
|
80
|
+
}
|
|
81
|
+
const command = args.join(' ');
|
|
82
|
+
const result = await this.execute(command);
|
|
83
|
+
if (!result.success) {
|
|
84
|
+
throw new Error(`kcat metadata failed: ${result.error}`);
|
|
85
|
+
}
|
|
86
|
+
return this.parseMetadataOutput(result.output);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Query topic offsets
|
|
90
|
+
*/
|
|
91
|
+
async queryOffsets(options) {
|
|
92
|
+
const args = [
|
|
93
|
+
'kcat',
|
|
94
|
+
'-Q', // Query mode
|
|
95
|
+
'-b', options.brokers,
|
|
96
|
+
'-t', options.topic
|
|
97
|
+
];
|
|
98
|
+
if (options.partition !== undefined) {
|
|
99
|
+
args.push('-p', options.partition.toString());
|
|
100
|
+
}
|
|
101
|
+
const command = args.join(' ');
|
|
102
|
+
const result = await this.execute(command);
|
|
103
|
+
if (!result.success) {
|
|
104
|
+
throw new Error(`kcat query failed: ${result.error}`);
|
|
105
|
+
}
|
|
106
|
+
return this.parseQueryOutput(result.output);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Execute kcat command
|
|
110
|
+
*/
|
|
111
|
+
async execute(command, input) {
|
|
112
|
+
const startTime = Date.now();
|
|
113
|
+
try {
|
|
114
|
+
const execOptions = {
|
|
115
|
+
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
|
116
|
+
timeout: 30000 // 30 second timeout
|
|
117
|
+
};
|
|
118
|
+
if (input) {
|
|
119
|
+
execOptions.input = input;
|
|
120
|
+
}
|
|
121
|
+
const { stdout, stderr } = await execAsync(command, execOptions);
|
|
122
|
+
const duration = Date.now() - startTime;
|
|
123
|
+
return {
|
|
124
|
+
success: true,
|
|
125
|
+
output: stdout,
|
|
126
|
+
error: stderr || undefined,
|
|
127
|
+
exitCode: 0,
|
|
128
|
+
command,
|
|
129
|
+
duration
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
const duration = Date.now() - startTime;
|
|
134
|
+
return {
|
|
135
|
+
success: false,
|
|
136
|
+
output: error.stdout || '',
|
|
137
|
+
error: error.stderr || error.message,
|
|
138
|
+
exitCode: error.code || 1,
|
|
139
|
+
command,
|
|
140
|
+
duration
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Parse consume output into messages
|
|
146
|
+
*/
|
|
147
|
+
parseConsumeOutput(output) {
|
|
148
|
+
const lines = output.trim().split('\n').filter(line => line.length > 0);
|
|
149
|
+
const messages = [];
|
|
150
|
+
for (const line of lines) {
|
|
151
|
+
// Format: topic:partition:offset:key:value
|
|
152
|
+
const parts = line.split(':');
|
|
153
|
+
if (parts.length >= 5) {
|
|
154
|
+
messages.push({
|
|
155
|
+
topic: parts[0],
|
|
156
|
+
partition: parseInt(parts[1]),
|
|
157
|
+
offset: parseInt(parts[2]),
|
|
158
|
+
key: parts[3] || undefined,
|
|
159
|
+
value: parts.slice(4).join(':'), // Rejoin in case value contains ':'
|
|
160
|
+
timestamp: Date.now() // kcat doesn't provide timestamp in this format
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return messages;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Parse metadata JSON output
|
|
168
|
+
*/
|
|
169
|
+
parseMetadataOutput(output) {
|
|
170
|
+
const metadata = JSON.parse(output);
|
|
171
|
+
return {
|
|
172
|
+
clusterId: metadata.originatingBroker?.cluster || 'unknown',
|
|
173
|
+
controllerId: metadata.controllerId || -1,
|
|
174
|
+
brokers: (metadata.brokers || []).map((b) => ({
|
|
175
|
+
id: b.id,
|
|
176
|
+
host: b.host,
|
|
177
|
+
port: b.port,
|
|
178
|
+
rack: b.rack
|
|
179
|
+
})),
|
|
180
|
+
topics: (metadata.topics || []).map((t) => ({
|
|
181
|
+
name: t.topic,
|
|
182
|
+
replicationFactor: this.calculateReplicationFactor(t.partitions),
|
|
183
|
+
configs: {},
|
|
184
|
+
partitions: (t.partitions || []).map((p) => ({
|
|
185
|
+
id: p.partition,
|
|
186
|
+
leader: p.leader,
|
|
187
|
+
replicas: p.replicas || [],
|
|
188
|
+
isr: p.isrs || [],
|
|
189
|
+
earliestOffset: 0, // Not provided in metadata
|
|
190
|
+
latestOffset: 0 // Not provided in metadata
|
|
191
|
+
}))
|
|
192
|
+
}))
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Calculate replication factor from partitions
|
|
197
|
+
*/
|
|
198
|
+
calculateReplicationFactor(partitions) {
|
|
199
|
+
if (!partitions || partitions.length === 0)
|
|
200
|
+
return 0;
|
|
201
|
+
return partitions[0].replicas?.length || 0;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Parse query offset output
|
|
205
|
+
*/
|
|
206
|
+
parseQueryOutput(output) {
|
|
207
|
+
const lines = output.trim().split('\n');
|
|
208
|
+
const offsets = {};
|
|
209
|
+
for (const line of lines) {
|
|
210
|
+
// Format: topic partition [earliest] [latest]
|
|
211
|
+
const match = line.match(/(\d+)\s+\[(\d+)\]\s+\[(\d+)\]/);
|
|
212
|
+
if (match) {
|
|
213
|
+
const partition = parseInt(match[1]);
|
|
214
|
+
offsets[partition] = {
|
|
215
|
+
earliest: parseInt(match[2]),
|
|
216
|
+
latest: parseInt(match[3])
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return offsets;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Check if kcat is installed
|
|
224
|
+
*/
|
|
225
|
+
static async isInstalled() {
|
|
226
|
+
try {
|
|
227
|
+
const { stdout } = await execAsync('which kcat 2>/dev/null || which kafkacat 2>/dev/null');
|
|
228
|
+
return !!stdout.trim();
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get kcat version
|
|
236
|
+
*/
|
|
237
|
+
static async getVersion() {
|
|
238
|
+
try {
|
|
239
|
+
const { stdout } = await execAsync('kcat -V 2>&1 || kafkacat -V 2>&1');
|
|
240
|
+
const match = stdout.match(/kafkacat - Apache Kafka producer and consumer tool\s+(\S+)/);
|
|
241
|
+
return match ? match[1] : 'unknown';
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
return 'unknown';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=kcat-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kcat-wrapper.js","sourceRoot":"","sources":["../../../../../plugins/specweave-kafka/lib/cli/kcat-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EA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