sdd-mcp-server 1.1.22 → 1.2.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.
- package/README.md +27 -13
- package/dist/adapters/cli/SDDToolAdapter.d.ts +22 -1
- package/dist/adapters/cli/SDDToolAdapter.js +399 -17
- package/dist/adapters/cli/SDDToolAdapter.js.map +1 -1
- package/dist/application/services/TemplateService.d.ts +17 -0
- package/dist/application/services/TemplateService.js +367 -24
- package/dist/application/services/TemplateService.js.map +1 -1
- package/dist/index.js +1210 -13
- package/dist/index.js.map +1 -1
- package/mcp-server.js +1501 -0
- package/package.json +3 -3
- package/simple-full-server.js +0 -379
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
A Model Context Protocol (MCP) server implementing Spec-Driven Development (SDD) workflows for AI-agent CLIs and IDEs like Claude Code, Cursor, and others.
|
|
8
8
|
|
|
9
|
-
> **✅ v1.
|
|
9
|
+
> **✅ v1.2.0 Update**: Complete kiro workflow alignment with empty project support. SDD tools now bootstrap from project descriptions without requiring existing files.
|
|
10
10
|
|
|
11
11
|
## 🚀 Quick Start
|
|
12
12
|
|
|
@@ -111,46 +111,57 @@ Once connected to your AI client, you can use these MCP tools:
|
|
|
111
111
|
| Tool | Description | Usage |
|
|
112
112
|
|------|-------------|--------|
|
|
113
113
|
| `sdd-init` | Initialize new SDD project | Creates .kiro directory structure |
|
|
114
|
-
| `sdd-requirements` | Generate requirements
|
|
115
|
-
| `sdd-design` | Create design
|
|
116
|
-
| `sdd-tasks` | Generate
|
|
114
|
+
| `sdd-requirements` | Generate context-aware requirements | Analyzes package.json and structure to create EARS-formatted requirements |
|
|
115
|
+
| `sdd-design` | Create project-specific design | Generates architecture docs based on actual tech stack and dependencies |
|
|
116
|
+
| `sdd-tasks` | Generate implementation breakdown | Creates tasks derived from real project structure and technology choices |
|
|
117
117
|
| `sdd-implement` | Implementation guidelines | Provides implementation steering |
|
|
118
118
|
| `sdd-status` | Check workflow progress | Shows current phase and approvals |
|
|
119
119
|
| `sdd-approve` | Approve workflow phases | Mark phases as approved for progression |
|
|
120
120
|
| `sdd-quality-check` | Code quality analysis | Linus-style 5-layer code review |
|
|
121
121
|
| `sdd-context-load` | Load project context | Restore project memory and state |
|
|
122
122
|
| `sdd-template-render` | Render templates | Generate files from templates |
|
|
123
|
+
| `sdd-steering` | Create/update steering docs | Analyzes project to generate product.md, tech.md, structure.md with real content |
|
|
124
|
+
| `sdd-steering-custom` | Create custom steering docs | Add specialized guidance documents |
|
|
125
|
+
| `sdd-validate-design` | Design quality validation | Interactive GO/NO-GO design review |
|
|
126
|
+
| `sdd-validate-gap` | Implementation gap analysis | Analyze requirements vs codebase |
|
|
127
|
+
| `sdd-spec-impl` | Execute tasks with TDD | Kent Beck's Red-Green-Refactor methodology |
|
|
123
128
|
|
|
124
129
|
## 💡 Basic Workflow
|
|
125
130
|
|
|
126
|
-
1. **Initialize Project**
|
|
131
|
+
1. **Initialize Project & Steering**
|
|
127
132
|
```
|
|
128
133
|
Use sdd-init to create a new SDD project
|
|
134
|
+
Use sdd-steering to generate core steering documents
|
|
129
135
|
```
|
|
130
136
|
|
|
131
137
|
2. **Generate Requirements**
|
|
132
138
|
```
|
|
133
|
-
Use sdd-requirements to analyze and
|
|
139
|
+
Use sdd-requirements to analyze package.json and create context-aware requirements
|
|
140
|
+
Use sdd-validate-gap to analyze implementation feasibility
|
|
134
141
|
```
|
|
135
142
|
|
|
136
143
|
3. **Create Design**
|
|
137
144
|
```
|
|
138
|
-
Use sdd-design to generate
|
|
145
|
+
Use sdd-design to generate architecture based on actual dependencies
|
|
146
|
+
Use sdd-validate-design for GO/NO-GO design review
|
|
139
147
|
```
|
|
140
148
|
|
|
141
149
|
4. **Plan Tasks**
|
|
142
150
|
```
|
|
143
|
-
Use sdd-tasks to
|
|
151
|
+
Use sdd-tasks to create implementation breakdown from real project structure
|
|
144
152
|
```
|
|
145
153
|
|
|
146
|
-
5. **Implement**
|
|
154
|
+
5. **Implement with TDD**
|
|
147
155
|
```
|
|
148
|
-
Use sdd-
|
|
156
|
+
Use sdd-spec-impl to execute tasks with TDD methodology
|
|
157
|
+
Use sdd-quality-check for code review and analysis
|
|
149
158
|
```
|
|
150
159
|
|
|
151
|
-
6. **
|
|
160
|
+
6. **Monitor & Manage**
|
|
152
161
|
```
|
|
153
|
-
Use sdd-
|
|
162
|
+
Use sdd-status to check workflow progress
|
|
163
|
+
Use sdd-approve to approve workflow phases
|
|
164
|
+
Use sdd-context-load to restore project memory
|
|
154
165
|
```
|
|
155
166
|
|
|
156
167
|
## ⚙️ Configuration
|
|
@@ -195,9 +206,12 @@ claude mcp add sdd "sdd-mcp-server"
|
|
|
195
206
|
## 🏗️ Key Features
|
|
196
207
|
|
|
197
208
|
- **5-Phase SDD Workflow**: INIT → REQUIREMENTS → DESIGN → TASKS → IMPLEMENTATION
|
|
209
|
+
- **Context-Aware Generation**: Analyzes package.json, dependencies, and project structure for real content
|
|
210
|
+
- **EARS-Formatted Requirements**: Generate acceptance criteria based on actual npm scripts and dependencies
|
|
211
|
+
- **Architecture Analysis**: Technology stack detection and pattern recognition from real codebase
|
|
198
212
|
- **Quality Enforcement**: Linus-style 5-layer code review system
|
|
199
213
|
- **Multi-Language Support**: 10 languages with cultural adaptation
|
|
200
|
-
- **Template Engine**: Handlebars-based file generation
|
|
214
|
+
- **Template Engine**: Handlebars-based file generation with project-specific data
|
|
201
215
|
- **Plugin System**: Extensible architecture for custom workflows
|
|
202
216
|
- **MCP Protocol**: Full compatibility with AI-agent CLIs and IDEs
|
|
203
217
|
|
|
@@ -3,6 +3,8 @@ import { ProjectService } from '../../application/services/ProjectService.js';
|
|
|
3
3
|
import { WorkflowService } from '../../application/services/WorkflowService.js';
|
|
4
4
|
import { TemplateService } from '../../application/services/TemplateService.js';
|
|
5
5
|
import { QualityService } from '../../application/services/QualityService.js';
|
|
6
|
+
import { SteeringDocumentService } from '../../application/services/SteeringDocumentService.js';
|
|
7
|
+
import { CodebaseAnalysisService } from '../../application/services/CodebaseAnalysisService.js';
|
|
6
8
|
import { LoggerPort } from '../../domain/ports.js';
|
|
7
9
|
export interface SDDToolHandler {
|
|
8
10
|
name: string;
|
|
@@ -14,8 +16,10 @@ export declare class SDDToolAdapter {
|
|
|
14
16
|
private readonly workflowService;
|
|
15
17
|
private readonly templateService;
|
|
16
18
|
private readonly qualityService;
|
|
19
|
+
private readonly steeringService;
|
|
20
|
+
private readonly codebaseAnalysisService;
|
|
17
21
|
private readonly logger;
|
|
18
|
-
constructor(projectService: ProjectService, workflowService: WorkflowService, templateService: TemplateService, qualityService: QualityService, logger: LoggerPort);
|
|
22
|
+
constructor(projectService: ProjectService, workflowService: WorkflowService, templateService: TemplateService, qualityService: QualityService, steeringService: SteeringDocumentService, codebaseAnalysisService: CodebaseAnalysisService, logger: LoggerPort);
|
|
19
23
|
getSDDTools(): SDDToolHandler[];
|
|
20
24
|
private handleProjectInit;
|
|
21
25
|
private handleProjectStatus;
|
|
@@ -23,4 +27,21 @@ export declare class SDDToolAdapter {
|
|
|
23
27
|
private handleDesign;
|
|
24
28
|
private handleTasks;
|
|
25
29
|
private handleQualityCheck;
|
|
30
|
+
private handleSteering;
|
|
31
|
+
private handleSteeringCustom;
|
|
32
|
+
private generateProductSteering;
|
|
33
|
+
private generateTechSteering;
|
|
34
|
+
private generateStructureSteering;
|
|
35
|
+
private extractFeatures;
|
|
36
|
+
private generateTargetUseCase;
|
|
37
|
+
private generateValueProposition;
|
|
38
|
+
private generateTargetUsers;
|
|
39
|
+
private generateTechStack;
|
|
40
|
+
private generateDependencyList;
|
|
41
|
+
private generateArchitecturePatterns;
|
|
42
|
+
private generateQualityStandards;
|
|
43
|
+
private generateDirectoryStructure;
|
|
44
|
+
private generateNamingConventions;
|
|
45
|
+
private generateModuleOrganization;
|
|
46
|
+
private generateWorkflow;
|
|
26
47
|
}
|
|
@@ -17,18 +17,24 @@ import { ProjectService } from '../../application/services/ProjectService.js';
|
|
|
17
17
|
import { WorkflowService } from '../../application/services/WorkflowService.js';
|
|
18
18
|
import { TemplateService } from '../../application/services/TemplateService.js';
|
|
19
19
|
import { QualityService } from '../../application/services/QualityService.js';
|
|
20
|
+
import { SteeringDocumentService } from '../../application/services/SteeringDocumentService.js';
|
|
21
|
+
import { CodebaseAnalysisService } from '../../application/services/CodebaseAnalysisService.js';
|
|
20
22
|
import { WorkflowPhase } from '../../domain/types.js';
|
|
21
23
|
let SDDToolAdapter = class SDDToolAdapter {
|
|
22
24
|
projectService;
|
|
23
25
|
workflowService;
|
|
24
26
|
templateService;
|
|
25
27
|
qualityService;
|
|
28
|
+
steeringService;
|
|
29
|
+
codebaseAnalysisService;
|
|
26
30
|
logger;
|
|
27
|
-
constructor(projectService, workflowService, templateService, qualityService, logger) {
|
|
31
|
+
constructor(projectService, workflowService, templateService, qualityService, steeringService, codebaseAnalysisService, logger) {
|
|
28
32
|
this.projectService = projectService;
|
|
29
33
|
this.workflowService = workflowService;
|
|
30
34
|
this.templateService = templateService;
|
|
31
35
|
this.qualityService = qualityService;
|
|
36
|
+
this.steeringService = steeringService;
|
|
37
|
+
this.codebaseAnalysisService = codebaseAnalysisService;
|
|
32
38
|
this.logger = logger;
|
|
33
39
|
}
|
|
34
40
|
getSDDTools() {
|
|
@@ -37,15 +43,13 @@ let SDDToolAdapter = class SDDToolAdapter {
|
|
|
37
43
|
name: 'sdd-init',
|
|
38
44
|
tool: {
|
|
39
45
|
name: 'sdd-init',
|
|
40
|
-
description: 'Initialize a new SDD project
|
|
46
|
+
description: 'Initialize a new SDD project from description',
|
|
41
47
|
inputSchema: {
|
|
42
48
|
type: 'object',
|
|
43
49
|
properties: {
|
|
44
|
-
|
|
45
|
-
path: { type: 'string', description: 'Project path' },
|
|
46
|
-
language: { type: 'string', enum: ['en', 'ja', 'zh-TW'], default: 'en' }
|
|
50
|
+
description: { type: 'string', description: 'Detailed project description' }
|
|
47
51
|
},
|
|
48
|
-
required: ['
|
|
52
|
+
required: ['description']
|
|
49
53
|
}
|
|
50
54
|
},
|
|
51
55
|
handler: this.handleProjectInit.bind(this)
|
|
@@ -69,13 +73,13 @@ let SDDToolAdapter = class SDDToolAdapter {
|
|
|
69
73
|
name: 'sdd-requirements',
|
|
70
74
|
tool: {
|
|
71
75
|
name: 'sdd-requirements',
|
|
72
|
-
description: 'Generate requirements
|
|
76
|
+
description: 'Generate requirements doc',
|
|
73
77
|
inputSchema: {
|
|
74
78
|
type: 'object',
|
|
75
79
|
properties: {
|
|
76
|
-
|
|
80
|
+
featureName: { type: 'string', description: 'Feature name' }
|
|
77
81
|
},
|
|
78
|
-
required: ['
|
|
82
|
+
required: ['featureName']
|
|
79
83
|
}
|
|
80
84
|
},
|
|
81
85
|
handler: this.handleRequirements.bind(this)
|
|
@@ -84,13 +88,13 @@ let SDDToolAdapter = class SDDToolAdapter {
|
|
|
84
88
|
name: 'sdd-design',
|
|
85
89
|
tool: {
|
|
86
90
|
name: 'sdd-design',
|
|
87
|
-
description: '
|
|
91
|
+
description: 'Create design specifications',
|
|
88
92
|
inputSchema: {
|
|
89
93
|
type: 'object',
|
|
90
94
|
properties: {
|
|
91
|
-
|
|
95
|
+
featureName: { type: 'string', description: 'Feature name' }
|
|
92
96
|
},
|
|
93
|
-
required: ['
|
|
97
|
+
required: ['featureName']
|
|
94
98
|
}
|
|
95
99
|
},
|
|
96
100
|
handler: this.handleDesign.bind(this)
|
|
@@ -99,13 +103,13 @@ let SDDToolAdapter = class SDDToolAdapter {
|
|
|
99
103
|
name: 'sdd-tasks',
|
|
100
104
|
tool: {
|
|
101
105
|
name: 'sdd-tasks',
|
|
102
|
-
description: 'Generate
|
|
106
|
+
description: 'Generate task breakdown',
|
|
103
107
|
inputSchema: {
|
|
104
108
|
type: 'object',
|
|
105
109
|
properties: {
|
|
106
|
-
|
|
110
|
+
featureName: { type: 'string', description: 'Feature name' }
|
|
107
111
|
},
|
|
108
|
-
required: ['
|
|
112
|
+
required: ['featureName']
|
|
109
113
|
}
|
|
110
114
|
},
|
|
111
115
|
handler: this.handleTasks.bind(this)
|
|
@@ -125,6 +129,38 @@ let SDDToolAdapter = class SDDToolAdapter {
|
|
|
125
129
|
}
|
|
126
130
|
},
|
|
127
131
|
handler: this.handleQualityCheck.bind(this)
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'sdd-steering',
|
|
135
|
+
tool: {
|
|
136
|
+
name: 'sdd-steering',
|
|
137
|
+
description: 'Create/update steering documents with project-specific analysis',
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {
|
|
141
|
+
updateMode: { type: 'string', enum: ['create', 'update'], description: 'Whether to create new or update existing documents' }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
handler: this.handleSteering.bind(this)
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'sdd-steering-custom',
|
|
149
|
+
tool: {
|
|
150
|
+
name: 'sdd-steering-custom',
|
|
151
|
+
description: 'Create custom steering documents for specialized contexts',
|
|
152
|
+
inputSchema: {
|
|
153
|
+
type: 'object',
|
|
154
|
+
properties: {
|
|
155
|
+
fileName: { type: 'string', description: 'Filename for the custom steering document' },
|
|
156
|
+
topic: { type: 'string', description: 'Topic/purpose of the custom steering document' },
|
|
157
|
+
inclusionMode: { type: 'string', enum: ['always', 'conditional', 'manual'], description: 'How this steering document should be included' },
|
|
158
|
+
filePattern: { type: 'string', description: 'File pattern for conditional inclusion' }
|
|
159
|
+
},
|
|
160
|
+
required: ['fileName', 'topic', 'inclusionMode']
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
handler: this.handleSteeringCustom.bind(this)
|
|
128
164
|
}
|
|
129
165
|
];
|
|
130
166
|
}
|
|
@@ -256,6 +292,348 @@ let SDDToolAdapter = class SDDToolAdapter {
|
|
|
256
292
|
});
|
|
257
293
|
return this.qualityService.formatQualityReport(report);
|
|
258
294
|
}
|
|
295
|
+
async handleSteering(args) {
|
|
296
|
+
const { updateMode = 'update' } = args;
|
|
297
|
+
const projectPath = process.cwd();
|
|
298
|
+
try {
|
|
299
|
+
// Analyze the project
|
|
300
|
+
const analysis = await this.codebaseAnalysisService.analyzeCodebase(projectPath);
|
|
301
|
+
// Generate steering documents based on project analysis
|
|
302
|
+
const productContent = await this.generateProductSteering(analysis);
|
|
303
|
+
const techContent = await this.generateTechSteering(analysis);
|
|
304
|
+
const structureContent = await this.generateStructureSteering(analysis);
|
|
305
|
+
// Create steering documents
|
|
306
|
+
await this.steeringService.createSteeringDocument(projectPath, {
|
|
307
|
+
name: 'product.md',
|
|
308
|
+
type: 'PRODUCT',
|
|
309
|
+
mode: 'ALWAYS',
|
|
310
|
+
content: productContent
|
|
311
|
+
});
|
|
312
|
+
await this.steeringService.createSteeringDocument(projectPath, {
|
|
313
|
+
name: 'tech.md',
|
|
314
|
+
type: 'TECHNICAL',
|
|
315
|
+
mode: 'ALWAYS',
|
|
316
|
+
content: techContent
|
|
317
|
+
});
|
|
318
|
+
await this.steeringService.createSteeringDocument(projectPath, {
|
|
319
|
+
name: 'structure.md',
|
|
320
|
+
type: 'STRUCTURE',
|
|
321
|
+
mode: 'ALWAYS',
|
|
322
|
+
content: structureContent
|
|
323
|
+
});
|
|
324
|
+
// Get project info from package.json
|
|
325
|
+
let packageJson = {};
|
|
326
|
+
try {
|
|
327
|
+
const fs = await import('fs');
|
|
328
|
+
const path = await import('path');
|
|
329
|
+
const packagePath = path.join(projectPath, 'package.json');
|
|
330
|
+
if (fs.existsSync(packagePath)) {
|
|
331
|
+
const packageContent = fs.readFileSync(packagePath, 'utf8');
|
|
332
|
+
packageJson = JSON.parse(packageContent);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
// Ignore errors
|
|
337
|
+
}
|
|
338
|
+
return `## Steering Documents Updated
|
|
339
|
+
|
|
340
|
+
**Project**: ${packageJson.name || 'Unknown'}
|
|
341
|
+
**Mode**: ${updateMode}
|
|
342
|
+
|
|
343
|
+
**Updated Files**:
|
|
344
|
+
- \`.kiro/steering/product.md\` - Product overview and business context
|
|
345
|
+
- \`.kiro/steering/tech.md\` - Technology stack and development environment
|
|
346
|
+
- \`.kiro/steering/structure.md\` - Project organization and architectural decisions
|
|
347
|
+
|
|
348
|
+
**Analysis**:
|
|
349
|
+
- Technology stack: ${Object.keys({ ...packageJson.dependencies, ...packageJson.devDependencies }).length} dependencies detected
|
|
350
|
+
- Project type: ${packageJson.type || 'Unknown'}
|
|
351
|
+
- Existing steering: Updated preserving customizations
|
|
352
|
+
|
|
353
|
+
These steering documents provide consistent project context for all AI interactions and spec-driven development workflows.`;
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
this.logger.error('Failed to generate steering documents', error);
|
|
357
|
+
throw new Error(`Failed to generate steering documents: ${error.message}`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
async handleSteeringCustom(args) {
|
|
361
|
+
const { fileName, topic, inclusionMode, filePattern } = args;
|
|
362
|
+
const projectPath = process.cwd();
|
|
363
|
+
if (typeof fileName !== 'string' || typeof topic !== 'string' || typeof inclusionMode !== 'string') {
|
|
364
|
+
throw new Error('Invalid arguments: fileName, topic, and inclusionMode must be strings');
|
|
365
|
+
}
|
|
366
|
+
const content = `# ${topic}
|
|
367
|
+
|
|
368
|
+
## Purpose
|
|
369
|
+
Define the purpose and scope of this steering document.
|
|
370
|
+
|
|
371
|
+
## Guidelines
|
|
372
|
+
- Guideline 1
|
|
373
|
+
- Guideline 2
|
|
374
|
+
|
|
375
|
+
## Usage
|
|
376
|
+
Describe when and how this steering document should be applied.
|
|
377
|
+
|
|
378
|
+
## Inclusion Mode
|
|
379
|
+
Mode: ${inclusionMode}${filePattern ? `
|
|
380
|
+
Pattern: ${filePattern}` : ''}
|
|
381
|
+
|
|
382
|
+
Generated on: ${new Date().toISOString()}
|
|
383
|
+
`;
|
|
384
|
+
await this.steeringService.createSteeringDocument(projectPath, {
|
|
385
|
+
name: fileName,
|
|
386
|
+
type: 'CUSTOM',
|
|
387
|
+
mode: inclusionMode.toUpperCase(),
|
|
388
|
+
patterns: filePattern ? [filePattern] : [],
|
|
389
|
+
content
|
|
390
|
+
});
|
|
391
|
+
return `Custom steering document "${fileName}" created successfully with ${inclusionMode} inclusion mode.`;
|
|
392
|
+
}
|
|
393
|
+
async generateProductSteering(analysis) {
|
|
394
|
+
// Try to read package.json for project info
|
|
395
|
+
let packageJson = {};
|
|
396
|
+
try {
|
|
397
|
+
const fs = await import('fs');
|
|
398
|
+
const path = await import('path');
|
|
399
|
+
const packagePath = path.join(process.cwd(), 'package.json');
|
|
400
|
+
if (fs.existsSync(packagePath)) {
|
|
401
|
+
const packageContent = fs.readFileSync(packagePath, 'utf8');
|
|
402
|
+
packageJson = JSON.parse(packageContent);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
// Ignore errors
|
|
407
|
+
}
|
|
408
|
+
return `# Product Overview
|
|
409
|
+
|
|
410
|
+
## Product Description
|
|
411
|
+
${packageJson.description || 'No description available'}
|
|
412
|
+
|
|
413
|
+
## Core Features
|
|
414
|
+
${this.extractFeatures(packageJson, analysis).map((feature) => `- ${feature}`).join('\n')}
|
|
415
|
+
|
|
416
|
+
## Target Use Case
|
|
417
|
+
${this.generateTargetUseCase(packageJson)}
|
|
418
|
+
|
|
419
|
+
## Key Value Proposition
|
|
420
|
+
${this.generateValueProposition(packageJson, analysis)}
|
|
421
|
+
|
|
422
|
+
## Target Users
|
|
423
|
+
${this.generateTargetUsers(packageJson)}`;
|
|
424
|
+
}
|
|
425
|
+
async generateTechSteering(analysis) {
|
|
426
|
+
// Try to read package.json for project info
|
|
427
|
+
let packageJson = {};
|
|
428
|
+
try {
|
|
429
|
+
const fs = await import('fs');
|
|
430
|
+
const path = await import('path');
|
|
431
|
+
const packagePath = path.join(process.cwd(), 'package.json');
|
|
432
|
+
if (fs.existsSync(packagePath)) {
|
|
433
|
+
const packageContent = fs.readFileSync(packagePath, 'utf8');
|
|
434
|
+
packageJson = JSON.parse(packageContent);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
// Ignore errors
|
|
439
|
+
}
|
|
440
|
+
return `# Technology Overview
|
|
441
|
+
|
|
442
|
+
## Technology Stack
|
|
443
|
+
${this.generateTechStack(packageJson, analysis)}
|
|
444
|
+
|
|
445
|
+
## Development Environment
|
|
446
|
+
- Node.js: ${packageJson.engines?.node || 'Unknown'}
|
|
447
|
+
- Package Manager: npm
|
|
448
|
+
|
|
449
|
+
## Key Dependencies
|
|
450
|
+
${this.generateDependencyList(packageJson)}
|
|
451
|
+
|
|
452
|
+
## Architecture Patterns
|
|
453
|
+
${this.generateArchitecturePatterns(analysis)}
|
|
454
|
+
|
|
455
|
+
## Quality Standards
|
|
456
|
+
${this.generateQualityStandards(packageJson)}`;
|
|
457
|
+
}
|
|
458
|
+
async generateStructureSteering(analysis) {
|
|
459
|
+
return `# Project Structure
|
|
460
|
+
|
|
461
|
+
## Directory Organization
|
|
462
|
+
${this.generateDirectoryStructure(analysis)}
|
|
463
|
+
|
|
464
|
+
## File Naming Conventions
|
|
465
|
+
${this.generateNamingConventions(analysis)}
|
|
466
|
+
|
|
467
|
+
## Module Organization
|
|
468
|
+
${this.generateModuleOrganization(analysis)}
|
|
469
|
+
|
|
470
|
+
## Development Workflow
|
|
471
|
+
${this.generateWorkflow(analysis)}`;
|
|
472
|
+
}
|
|
473
|
+
extractFeatures(packageJson, analysis) {
|
|
474
|
+
const features = [];
|
|
475
|
+
// Extract features from scripts
|
|
476
|
+
if (packageJson.scripts) {
|
|
477
|
+
if (packageJson.scripts.test)
|
|
478
|
+
features.push('Testing framework');
|
|
479
|
+
if (packageJson.scripts.build)
|
|
480
|
+
features.push('Build system');
|
|
481
|
+
if (packageJson.scripts.dev || packageJson.scripts.start)
|
|
482
|
+
features.push('Development server');
|
|
483
|
+
if (packageJson.scripts.lint)
|
|
484
|
+
features.push('Code linting');
|
|
485
|
+
if (packageJson.scripts.typecheck)
|
|
486
|
+
features.push('Type checking');
|
|
487
|
+
}
|
|
488
|
+
// Extract features from dependencies
|
|
489
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
490
|
+
if (deps?.express || deps?.fastify || deps?.koa)
|
|
491
|
+
features.push('Web server');
|
|
492
|
+
if (deps?.react || deps?.vue || deps?.angular)
|
|
493
|
+
features.push('Frontend framework');
|
|
494
|
+
if (deps?.typescript)
|
|
495
|
+
features.push('TypeScript support');
|
|
496
|
+
if (deps?.jest || deps?.mocha || deps?.vitest)
|
|
497
|
+
features.push('Unit testing');
|
|
498
|
+
if (deps?.eslint)
|
|
499
|
+
features.push('Code quality enforcement');
|
|
500
|
+
return features.length > 0 ? features : ['Core functionality to be defined'];
|
|
501
|
+
}
|
|
502
|
+
generateTargetUseCase(packageJson) {
|
|
503
|
+
if (packageJson.keywords) {
|
|
504
|
+
return `This product is designed for ${packageJson.keywords.join(', ')} use cases.`;
|
|
505
|
+
}
|
|
506
|
+
return 'Target use cases to be defined based on project requirements.';
|
|
507
|
+
}
|
|
508
|
+
generateValueProposition(packageJson, analysis) {
|
|
509
|
+
const features = this.extractFeatures(packageJson, analysis);
|
|
510
|
+
return features.map(feature => `- **${feature}**: Enhanced development experience`).join('\n');
|
|
511
|
+
}
|
|
512
|
+
generateTargetUsers(packageJson) {
|
|
513
|
+
if (packageJson.keywords?.includes('cli')) {
|
|
514
|
+
return '- Command-line tool users\n- Developers and system administrators';
|
|
515
|
+
}
|
|
516
|
+
if (packageJson.keywords?.includes('api')) {
|
|
517
|
+
return '- API consumers\n- Third-party integrators';
|
|
518
|
+
}
|
|
519
|
+
return '- Primary user persona\n- Secondary user persona';
|
|
520
|
+
}
|
|
521
|
+
generateTechStack(packageJson, analysis) {
|
|
522
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
523
|
+
const stack = [];
|
|
524
|
+
if (deps?.typescript)
|
|
525
|
+
stack.push('TypeScript');
|
|
526
|
+
if (deps?.node || packageJson.engines?.node)
|
|
527
|
+
stack.push('Node.js');
|
|
528
|
+
if (deps?.express)
|
|
529
|
+
stack.push('Express.js');
|
|
530
|
+
if (deps?.react)
|
|
531
|
+
stack.push('React');
|
|
532
|
+
if (deps?.vue)
|
|
533
|
+
stack.push('Vue.js');
|
|
534
|
+
return stack.length > 0 ? stack.join(', ') : 'Technology stack to be defined';
|
|
535
|
+
}
|
|
536
|
+
generateDependencyList(packageJson) {
|
|
537
|
+
const production = Object.keys(packageJson.dependencies || {});
|
|
538
|
+
const development = Object.keys(packageJson.devDependencies || {});
|
|
539
|
+
let list = '';
|
|
540
|
+
if (production.length > 0) {
|
|
541
|
+
list += '### Production Dependencies\n';
|
|
542
|
+
list += production.slice(0, 10).map((dep) => `- ${dep}`).join('\n');
|
|
543
|
+
}
|
|
544
|
+
if (development.length > 0) {
|
|
545
|
+
list += '\n### Development Dependencies\n';
|
|
546
|
+
list += development.slice(0, 10).map((dep) => `- ${dep}`).join('\n');
|
|
547
|
+
}
|
|
548
|
+
return list || 'Dependencies to be analyzed';
|
|
549
|
+
}
|
|
550
|
+
generateArchitecturePatterns(analysis) {
|
|
551
|
+
const patterns = [];
|
|
552
|
+
// Try to analyze directory structure from filesystem
|
|
553
|
+
try {
|
|
554
|
+
const fs = require('fs');
|
|
555
|
+
const projectPath = process.cwd();
|
|
556
|
+
const items = fs.readdirSync(projectPath, { withFileTypes: true });
|
|
557
|
+
const directories = items
|
|
558
|
+
.filter((item) => item.isDirectory())
|
|
559
|
+
.map((item) => item.name);
|
|
560
|
+
if (directories.includes('src'))
|
|
561
|
+
patterns.push('Source code organization');
|
|
562
|
+
if (directories.includes('test') || directories.includes('__tests__'))
|
|
563
|
+
patterns.push('Test-driven development');
|
|
564
|
+
if (directories.includes('dist') || directories.includes('build'))
|
|
565
|
+
patterns.push('Build artifact separation');
|
|
566
|
+
}
|
|
567
|
+
catch (error) {
|
|
568
|
+
// Ignore filesystem errors
|
|
569
|
+
}
|
|
570
|
+
return patterns.length > 0 ? patterns.map(p => `- ${p}`).join('\n') : '- Patterns to be defined';
|
|
571
|
+
}
|
|
572
|
+
generateQualityStandards(packageJson) {
|
|
573
|
+
const standards = [];
|
|
574
|
+
if (packageJson.scripts?.lint)
|
|
575
|
+
standards.push('Code linting with ESLint');
|
|
576
|
+
if (packageJson.scripts?.typecheck)
|
|
577
|
+
standards.push('Type checking with TypeScript');
|
|
578
|
+
if (packageJson.scripts?.test)
|
|
579
|
+
standards.push('Unit testing required');
|
|
580
|
+
return standards.length > 0 ? standards.map(s => `- ${s}`).join('\n') : '- Quality standards to be defined';
|
|
581
|
+
}
|
|
582
|
+
generateDirectoryStructure(analysis) {
|
|
583
|
+
// Try to get directory structure from filesystem
|
|
584
|
+
try {
|
|
585
|
+
const fs = require('fs');
|
|
586
|
+
const projectPath = process.cwd();
|
|
587
|
+
const items = fs.readdirSync(projectPath, { withFileTypes: true });
|
|
588
|
+
const directories = items
|
|
589
|
+
.filter((item) => item.isDirectory() && !item.name.startsWith('.') && item.name !== 'node_modules')
|
|
590
|
+
.map((item) => `- ${item.name}/`)
|
|
591
|
+
.join('\n');
|
|
592
|
+
return directories || 'Directory structure to be analyzed';
|
|
593
|
+
}
|
|
594
|
+
catch (error) {
|
|
595
|
+
return 'Directory structure to be analyzed';
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
generateNamingConventions(analysis) {
|
|
599
|
+
return `- Use kebab-case for file names
|
|
600
|
+
- Use PascalCase for class names
|
|
601
|
+
- Use camelCase for variable names
|
|
602
|
+
- Use UPPER_SNAKE_CASE for constants`;
|
|
603
|
+
}
|
|
604
|
+
generateModuleOrganization(analysis) {
|
|
605
|
+
return `- Group related functionality in modules
|
|
606
|
+
- Use barrel exports (index.ts files)
|
|
607
|
+
- Separate business logic from infrastructure
|
|
608
|
+
- Keep dependencies flowing inward`;
|
|
609
|
+
}
|
|
610
|
+
generateWorkflow(analysis) {
|
|
611
|
+
// Try to read package.json for scripts
|
|
612
|
+
let packageJson = {};
|
|
613
|
+
try {
|
|
614
|
+
const fs = require('fs');
|
|
615
|
+
const path = require('path');
|
|
616
|
+
const packagePath = path.join(process.cwd(), 'package.json');
|
|
617
|
+
if (fs.existsSync(packagePath)) {
|
|
618
|
+
const packageContent = fs.readFileSync(packagePath, 'utf8');
|
|
619
|
+
packageJson = JSON.parse(packageContent);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
catch (error) {
|
|
623
|
+
// Ignore errors
|
|
624
|
+
}
|
|
625
|
+
const scripts = packageJson.scripts || {};
|
|
626
|
+
let workflow = '## Development Commands\n';
|
|
627
|
+
if (scripts.dev)
|
|
628
|
+
workflow += `- \`npm run dev\` - Start development server\n`;
|
|
629
|
+
if (scripts.build)
|
|
630
|
+
workflow += `- \`npm run build\` - Build for production\n`;
|
|
631
|
+
if (scripts.test)
|
|
632
|
+
workflow += `- \`npm run test\` - Run tests\n`;
|
|
633
|
+
if (scripts.lint)
|
|
634
|
+
workflow += `- \`npm run lint\` - Check code quality\n`;
|
|
635
|
+
return workflow;
|
|
636
|
+
}
|
|
259
637
|
};
|
|
260
638
|
SDDToolAdapter = __decorate([
|
|
261
639
|
injectable(),
|
|
@@ -263,11 +641,15 @@ SDDToolAdapter = __decorate([
|
|
|
263
641
|
__param(1, inject(TYPES.WorkflowService)),
|
|
264
642
|
__param(2, inject(TYPES.TemplateService)),
|
|
265
643
|
__param(3, inject(TYPES.QualityService)),
|
|
266
|
-
__param(4, inject(TYPES.
|
|
644
|
+
__param(4, inject(TYPES.SteeringDocumentService)),
|
|
645
|
+
__param(5, inject(TYPES.CodebaseAnalysisService)),
|
|
646
|
+
__param(6, inject(TYPES.LoggerPort)),
|
|
267
647
|
__metadata("design:paramtypes", [ProjectService,
|
|
268
648
|
WorkflowService,
|
|
269
649
|
TemplateService,
|
|
270
|
-
QualityService,
|
|
650
|
+
QualityService,
|
|
651
|
+
SteeringDocumentService,
|
|
652
|
+
CodebaseAnalysisService, Object])
|
|
271
653
|
], SDDToolAdapter);
|
|
272
654
|
export { SDDToolAdapter };
|
|
273
655
|
//# sourceMappingURL=SDDToolAdapter.js.map
|