sdd-mcp-server 1.3.11 → 1.4.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/README.md +53 -18
- package/dist/index.js +41 -161
- package/dist/index.js.map +1 -1
- package/dist/utils/specGenerator.d.ts +3 -0
- package/dist/utils/specGenerator.js +259 -0
- package/dist/utils/specGenerator.js.map +1 -0
- package/mcp-server.js +102 -35
- package/package.json +2 -1
- package/specGenerator.js +263 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { analyzeProject } from './documentGenerator.js';
|
|
2
|
+
export async function generateRequirementsDocument(projectPath, featureName) {
|
|
3
|
+
const analysis = await analyzeProject(projectPath);
|
|
4
|
+
const desc = analysis.description || 'Feature requirements specification';
|
|
5
|
+
const obj = generateCoreObjective(analysis);
|
|
6
|
+
const acceptance = generateAcceptanceCriteria(analysis)
|
|
7
|
+
.map((c, i) => `${i + 1}. ${c}`)
|
|
8
|
+
.join('\n');
|
|
9
|
+
return `# Requirements Document
|
|
10
|
+
|
|
11
|
+
## Introduction
|
|
12
|
+
${featureName} - Requirements derived from codebase analysis.
|
|
13
|
+
|
|
14
|
+
**Project**: ${analysis.name}
|
|
15
|
+
**Description**: ${desc}
|
|
16
|
+
|
|
17
|
+
Generated on: ${new Date().toISOString()}
|
|
18
|
+
|
|
19
|
+
## Functional Requirements
|
|
20
|
+
|
|
21
|
+
### FR-1: Core Functionality
|
|
22
|
+
**Objective:** ${obj}
|
|
23
|
+
|
|
24
|
+
#### Acceptance Criteria
|
|
25
|
+
${acceptance}
|
|
26
|
+
|
|
27
|
+
### FR-2: Technology Integration
|
|
28
|
+
**Objective:** Integrate with the detected technology stack
|
|
29
|
+
|
|
30
|
+
#### Acceptance Criteria
|
|
31
|
+
${generateTechRequirements(analysis).map((r, i) => `${i + 1}. ${r}`).join('\n')}
|
|
32
|
+
|
|
33
|
+
### FR-3: Quality Standards
|
|
34
|
+
**Objective:** Meet quality, testing, and review standards
|
|
35
|
+
|
|
36
|
+
#### Acceptance Criteria
|
|
37
|
+
${generateQualityRequirements(analysis).map((r, i) => `${i + 1}. ${r}`).join('\n')}
|
|
38
|
+
|
|
39
|
+
## Non-Functional Requirements
|
|
40
|
+
|
|
41
|
+
### NFR-1: Performance
|
|
42
|
+
- System SHALL respond within acceptable time limits
|
|
43
|
+
- Memory usage SHALL remain within reasonable bounds
|
|
44
|
+
|
|
45
|
+
### NFR-2: Reliability
|
|
46
|
+
- System SHALL handle errors gracefully
|
|
47
|
+
- System SHALL maintain data integrity
|
|
48
|
+
|
|
49
|
+
### NFR-3: Maintainability
|
|
50
|
+
- Code SHALL follow established conventions
|
|
51
|
+
- System SHALL be well-documented
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
export async function generateDesignDocument(projectPath, featureName) {
|
|
55
|
+
const analysis = await analyzeProject(projectPath);
|
|
56
|
+
const arch = describeArchitecture(analysis);
|
|
57
|
+
const components = generateComponentList(analysis).map(c => `- **${c.name}**: ${c.description}`).join('\n');
|
|
58
|
+
const dataModels = generateDataModels(analysis).map(m => `- **${m}**: Data structure definition`).join('\n');
|
|
59
|
+
const techStack = generateDetailedTechStack(analysis);
|
|
60
|
+
return `# Technical Design Document
|
|
61
|
+
|
|
62
|
+
## Project: ${featureName}
|
|
63
|
+
|
|
64
|
+
**Project Name:** ${analysis.name}
|
|
65
|
+
**Architecture:** ${analysis.architecture}
|
|
66
|
+
**Language:** ${analysis.language}
|
|
67
|
+
|
|
68
|
+
Generated on: ${new Date().toISOString()}
|
|
69
|
+
|
|
70
|
+
## Architecture Overview
|
|
71
|
+
|
|
72
|
+
### System Architecture
|
|
73
|
+
${arch}
|
|
74
|
+
|
|
75
|
+
### Key Components
|
|
76
|
+
${components}
|
|
77
|
+
|
|
78
|
+
### Data Models
|
|
79
|
+
${dataModels}
|
|
80
|
+
|
|
81
|
+
## Implementation Details
|
|
82
|
+
|
|
83
|
+
### Technology Stack
|
|
84
|
+
${techStack}
|
|
85
|
+
|
|
86
|
+
### Dependencies
|
|
87
|
+
${generateDependencySummary(analysis)}
|
|
88
|
+
|
|
89
|
+
## Interface Specifications
|
|
90
|
+
|
|
91
|
+
### Module Interfaces
|
|
92
|
+
${generateModuleInterfaces(analysis)}
|
|
93
|
+
|
|
94
|
+
## Configuration
|
|
95
|
+
|
|
96
|
+
### Environment Variables
|
|
97
|
+
${generateEnvVars(analysis)}
|
|
98
|
+
|
|
99
|
+
### Build Configuration
|
|
100
|
+
${generateBuildConfig(analysis)}
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
export async function generateTasksDocument(projectPath, featureName) {
|
|
104
|
+
const analysis = await analyzeProject(projectPath);
|
|
105
|
+
const tasks = generateImplementationTasks(analysis);
|
|
106
|
+
const section = (title, list) => list.map((task, idx) => `- [ ] ${idx + 1}. ${task.title}
|
|
107
|
+
${task.subtasks.map(s => ` - ${s}`).join('\n')}
|
|
108
|
+
- _Requirements: ${task.requirements}_`).join('\n\n');
|
|
109
|
+
return `# Implementation Plan
|
|
110
|
+
|
|
111
|
+
## Project: ${featureName}
|
|
112
|
+
|
|
113
|
+
**Project Name:** ${analysis.name}
|
|
114
|
+
**Detected Stack:** ${[analysis.language, analysis.framework || '', analysis.buildTool || ''].filter(Boolean).join(' / ')}
|
|
115
|
+
|
|
116
|
+
Generated on: ${new Date().toISOString()}
|
|
117
|
+
|
|
118
|
+
## Development Phase Tasks
|
|
119
|
+
|
|
120
|
+
${section('Development', tasks.development)}
|
|
121
|
+
|
|
122
|
+
## Integration Phase Tasks
|
|
123
|
+
|
|
124
|
+
${section('Integration', tasks.integration)}
|
|
125
|
+
|
|
126
|
+
## Quality & Testing Tasks
|
|
127
|
+
|
|
128
|
+
${section('Quality', tasks.quality)}
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
// Helpers derived from TemplateService, reduced and dependency-free
|
|
132
|
+
function generateCoreObjective(analysis) {
|
|
133
|
+
if (analysis.dependencies?.includes('@modelcontextprotocol/sdk'))
|
|
134
|
+
return 'Provide MCP tools for spec-driven development workflows';
|
|
135
|
+
if (analysis.framework === 'Express.js')
|
|
136
|
+
return 'Expose REST endpoints and middleware for business logic';
|
|
137
|
+
if (analysis.framework === 'React')
|
|
138
|
+
return 'Render interactive UI components with state management';
|
|
139
|
+
return 'Deliver feature-aligned functionality integrated with existing architecture';
|
|
140
|
+
}
|
|
141
|
+
function generateAcceptanceCriteria(analysis) {
|
|
142
|
+
const criteria = [
|
|
143
|
+
'WHEN invoked THEN it SHALL execute without runtime errors',
|
|
144
|
+
'IF input is invalid THEN it SHALL return meaningful errors',
|
|
145
|
+
'WHILE under typical load IT SHALL meet performance targets'
|
|
146
|
+
];
|
|
147
|
+
if (analysis.testFramework)
|
|
148
|
+
criteria.push('WHERE tests exist THEY SHALL pass with adequate coverage');
|
|
149
|
+
if (analysis.language === 'typescript')
|
|
150
|
+
criteria.push('WHEN type-checking THEN no TypeScript errors SHALL occur');
|
|
151
|
+
return criteria;
|
|
152
|
+
}
|
|
153
|
+
function generateTechRequirements(analysis) {
|
|
154
|
+
const out = ['Integrate with existing build and run scripts'];
|
|
155
|
+
if (analysis.dependencies?.includes('@modelcontextprotocol/sdk'))
|
|
156
|
+
out.push('Expose MCP-compliant tools over stdio');
|
|
157
|
+
if (analysis.buildTool)
|
|
158
|
+
out.push(`Provide build artifacts using ${analysis.buildTool}`);
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
function generateQualityRequirements(analysis) {
|
|
162
|
+
const out = ['Follow project coding conventions', 'Apply error handling and logging'];
|
|
163
|
+
if (analysis.testFramework)
|
|
164
|
+
out.push(`Include ${analysis.testFramework} tests for new code`);
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
function describeArchitecture(analysis) {
|
|
168
|
+
if (analysis.architecture === 'Domain-Driven Design (DDD)')
|
|
169
|
+
return 'Layered DDD: Domain, Application, Infrastructure, Presentation';
|
|
170
|
+
if (analysis.architecture.includes('API'))
|
|
171
|
+
return 'REST API with routing, middleware, services, and data access layers';
|
|
172
|
+
if (analysis.framework === 'MCP SDK')
|
|
173
|
+
return 'MCP server exposing development tools via stdio protocol';
|
|
174
|
+
return analysis.architecture || 'Modular architecture with clear separation of concerns';
|
|
175
|
+
}
|
|
176
|
+
function generateComponentList(analysis) {
|
|
177
|
+
const comps = [];
|
|
178
|
+
if (analysis.framework === 'MCP SDK') {
|
|
179
|
+
comps.push({ name: 'MCPServer', description: 'Handles stdio transport and tool registry' });
|
|
180
|
+
comps.push({ name: 'ToolHandlers', description: 'Implement SDD tools (init, requirements, design, tasks, etc.)' });
|
|
181
|
+
}
|
|
182
|
+
if (analysis.architecture.includes('API')) {
|
|
183
|
+
comps.push({ name: 'Controllers', description: 'HTTP route handlers' });
|
|
184
|
+
comps.push({ name: 'Services', description: 'Business logic orchestration' });
|
|
185
|
+
}
|
|
186
|
+
if (comps.length === 0)
|
|
187
|
+
comps.push({ name: 'CoreModule', description: 'Primary feature implementation module' });
|
|
188
|
+
return comps;
|
|
189
|
+
}
|
|
190
|
+
function generateDataModels(analysis) {
|
|
191
|
+
if (analysis.framework === 'MCP SDK')
|
|
192
|
+
return ['Tool', 'Request', 'Response'];
|
|
193
|
+
if (analysis.architecture.includes('API'))
|
|
194
|
+
return ['RequestDTO', 'ResponseDTO'];
|
|
195
|
+
return ['Entity', 'ValueObject'];
|
|
196
|
+
}
|
|
197
|
+
function generateDetailedTechStack(analysis) {
|
|
198
|
+
const parts = [];
|
|
199
|
+
parts.push(`- Runtime: ${analysis.language === 'typescript' ? 'Node.js (TypeScript)' : 'Node.js (JavaScript)'}`);
|
|
200
|
+
if (analysis.framework)
|
|
201
|
+
parts.push(`- Framework: ${analysis.framework}`);
|
|
202
|
+
if (analysis.buildTool)
|
|
203
|
+
parts.push(`- Build: ${analysis.buildTool}`);
|
|
204
|
+
if (analysis.testFramework)
|
|
205
|
+
parts.push(`- Testing: ${analysis.testFramework}`);
|
|
206
|
+
return parts.join('\n');
|
|
207
|
+
}
|
|
208
|
+
function generateDependencySummary(analysis) {
|
|
209
|
+
const deps = (analysis.dependencies || []).slice(0, 10).map((d) => `- ${d}`).join('\n');
|
|
210
|
+
const dev = (analysis.devDependencies || []).slice(0, 10).map((d) => `- ${d}`).join('\n');
|
|
211
|
+
return `#### Production\n${deps || '- (none)'}\n\n#### Development\n${dev || '- (none)'}`;
|
|
212
|
+
}
|
|
213
|
+
function generateModuleInterfaces(analysis) {
|
|
214
|
+
if (analysis.framework === 'MCP SDK') {
|
|
215
|
+
return `- registerTool(name: string, handler: (args) => Promise<unknown>)\n- connect(transport): Promise<void>`;
|
|
216
|
+
}
|
|
217
|
+
if (analysis.architecture.includes('API')) {
|
|
218
|
+
return `- handle(request): Response\n- service.process(input): Result`;
|
|
219
|
+
}
|
|
220
|
+
return `- execute(input): Output`;
|
|
221
|
+
}
|
|
222
|
+
function generateEnvVars(analysis) {
|
|
223
|
+
const envs = ['NODE_ENV', 'LOG_LEVEL'];
|
|
224
|
+
if (analysis.framework === 'MCP SDK')
|
|
225
|
+
envs.push('MCP_MODE');
|
|
226
|
+
return envs.map(e => `- ${e}`).join('\n');
|
|
227
|
+
}
|
|
228
|
+
function generateBuildConfig(analysis) {
|
|
229
|
+
if (analysis.buildTool)
|
|
230
|
+
return `Use ${analysis.buildTool} to emit production artifacts`;
|
|
231
|
+
return 'Use npm scripts (build/test/lint) defined in package.json';
|
|
232
|
+
}
|
|
233
|
+
function generateImplementationTasks(analysis) {
|
|
234
|
+
const dev = [
|
|
235
|
+
{ title: 'Set up project scaffolding', subtasks: ['Initialize directories', 'Configure scripts'], requirements: 'FR-1' },
|
|
236
|
+
{ title: 'Implement core feature logic', subtasks: ['Add modules', 'Wire integrations'], requirements: 'FR-1' }
|
|
237
|
+
];
|
|
238
|
+
const integ = [
|
|
239
|
+
{ title: 'Integrate with stack', subtasks: ['Validate build', 'Run dev server'], requirements: 'FR-2' }
|
|
240
|
+
];
|
|
241
|
+
const quality = [
|
|
242
|
+
{ title: 'Add tests and quality checks', subtasks: ['Unit tests', 'Lint/typecheck', 'Quality review'], requirements: 'FR-3' }
|
|
243
|
+
];
|
|
244
|
+
// Tailor tasks if MCP or API
|
|
245
|
+
if (analysis.framework === 'MCP SDK') {
|
|
246
|
+
dev.unshift({ title: 'Expose MCP tools', subtasks: ['Register tools', 'Handle stdio transport'], requirements: 'FR-2' });
|
|
247
|
+
}
|
|
248
|
+
if (analysis.architecture.includes('API')) {
|
|
249
|
+
dev.unshift({ title: 'Add HTTP endpoints', subtasks: ['Define routes', 'Implement handlers'], requirements: 'FR-1' });
|
|
250
|
+
}
|
|
251
|
+
if (analysis.testFramework) {
|
|
252
|
+
quality[0].subtasks.unshift(`Set up ${analysis.testFramework}`);
|
|
253
|
+
}
|
|
254
|
+
if (analysis.language === 'typescript') {
|
|
255
|
+
quality[0].subtasks.push('Ensure type safety (tsc)');
|
|
256
|
+
}
|
|
257
|
+
return { development: dev, integration: integ, quality };
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=specGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specGenerator.js","sourceRoot":"","sources":["../../src/utils/specGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,WAAmB,EAAE,WAAmB;IACzF,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,IAAI,oCAAoC,CAAC;IAC1E,MAAM,GAAG,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,0BAA0B,CAAC,QAAQ,CAAC;SACpD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;SAC/B,IAAI,CAAC,IAAI,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package/mcp-server.js
CHANGED
|
@@ -11,6 +11,26 @@ import {
|
|
|
11
11
|
generateStructureDocument
|
|
12
12
|
} from './documentGenerator.js';
|
|
13
13
|
|
|
14
|
+
// Best-effort dynamic loader for spec generators (requirements/design/tasks)
|
|
15
|
+
async function loadSpecGenerator() {
|
|
16
|
+
const tried = [];
|
|
17
|
+
const attempts = [
|
|
18
|
+
'./specGenerator.js', // root-level JS (dev/runtime)
|
|
19
|
+
'./dist/utils/specGenerator.js', // compiled TS output
|
|
20
|
+
'./utils/specGenerator.js' // TS runtime (when transpiled on-the-fly)
|
|
21
|
+
];
|
|
22
|
+
for (const p of attempts) {
|
|
23
|
+
try {
|
|
24
|
+
// eslint-disable-next-line no-await-in-loop
|
|
25
|
+
const mod = await import(p);
|
|
26
|
+
return { mod, path: p };
|
|
27
|
+
} catch (e) {
|
|
28
|
+
tried.push(`${p}: ${(e && e.message) || e}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`Unable to load specGenerator from known paths. Tried: \n- ${tried.join('\n- ')}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
14
34
|
// Resolve version dynamically from package.json when possible
|
|
15
35
|
async function resolveVersion() {
|
|
16
36
|
try {
|
|
@@ -172,39 +192,14 @@ server.registerTool("sdd-requirements", {
|
|
|
172
192
|
const specContent = await fs.readFile(specPath, 'utf8');
|
|
173
193
|
const spec = JSON.parse(specContent);
|
|
174
194
|
|
|
175
|
-
// Generate requirements
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
Please analyze the current project structure and the feature description above to generate comprehensive requirements. Consider:
|
|
185
|
-
|
|
186
|
-
1. **Project Analysis**: Examine the codebase structure, existing files, dependencies, and architecture patterns
|
|
187
|
-
2. **Feature Scope**: Based on the feature description, identify what needs to be built
|
|
188
|
-
3. **User Stories**: Create user stories that capture the value this feature provides
|
|
189
|
-
4. **Technical Requirements**: Identify technical constraints and integration points
|
|
190
|
-
5. **Acceptance Criteria**: Use EARS format (WHEN/IF/WHILE/WHERE) for testable criteria
|
|
191
|
-
|
|
192
|
-
## Requirements Generation Guidelines
|
|
193
|
-
|
|
194
|
-
Generate requirements that:
|
|
195
|
-
- Are specific to this actual project (not generic)
|
|
196
|
-
- Consider the existing codebase architecture
|
|
197
|
-
- Include functional and non-functional requirements
|
|
198
|
-
- Use EARS format for acceptance criteria
|
|
199
|
-
- Are testable and measurable
|
|
200
|
-
- Consider integration with existing features
|
|
201
|
-
|
|
202
|
-
## Current Project Information
|
|
203
|
-
- Project Path: ${process.cwd()}
|
|
204
|
-
- Feature Name: ${spec.feature_name}
|
|
205
|
-
- Initialization Date: ${spec.created_at}
|
|
206
|
-
|
|
207
|
-
**Note**: This template will be replaced by AI-generated requirements specific to your project and feature description.`;
|
|
195
|
+
// Generate requirements using specGenerator with fallback
|
|
196
|
+
let requirementsContent;
|
|
197
|
+
try {
|
|
198
|
+
const { mod } = await loadSpecGenerator();
|
|
199
|
+
requirementsContent = await mod.generateRequirementsDocument(currentPath, featureName);
|
|
200
|
+
} catch (e) {
|
|
201
|
+
requirementsContent = `# Requirements Document\n\n<!-- Warning: Analysis-backed generation failed. Using fallback template. -->\n<!-- Error: ${e && e.message ? e.message : String(e)} -->\n\n## Project Context\n**Feature**: ${spec.feature_name}\n**Description**: ${spec.description || 'Feature to be implemented'}\n`;
|
|
202
|
+
}
|
|
208
203
|
|
|
209
204
|
await fs.writeFile(path.join(featurePath, 'requirements.md'), requirementsContent);
|
|
210
205
|
|
|
@@ -266,8 +261,14 @@ server.registerTool("sdd-design", {
|
|
|
266
261
|
requirementsContext = 'Requirements document not available';
|
|
267
262
|
}
|
|
268
263
|
|
|
269
|
-
// Generate design
|
|
270
|
-
|
|
264
|
+
// Generate design using specGenerator with fallback
|
|
265
|
+
let designContent;
|
|
266
|
+
try {
|
|
267
|
+
const { mod } = await loadSpecGenerator();
|
|
268
|
+
designContent = await mod.generateDesignDocument(currentPath, featureName);
|
|
269
|
+
} catch (e) {
|
|
270
|
+
designContent = `# Technical Design Document\n\n<!-- Warning: Analysis-backed generation failed. Using fallback template. -->\n<!-- Error: ${e && e.message ? e.message : String(e)} -->\n\n## Project Context\n**Feature**: ${spec.feature_name}\n**Phase**: ${spec.phase}`;
|
|
271
|
+
}
|
|
271
272
|
|
|
272
273
|
await fs.writeFile(path.join(featurePath, 'design.md'), designContent);
|
|
273
274
|
|
|
@@ -384,6 +385,14 @@ ${designContext.substring(0, 1000)}${designContext.length > 1000 ? '...\n[Design
|
|
|
384
385
|
- Created: ${spec.created_at}
|
|
385
386
|
|
|
386
387
|
**Note**: This template will be replaced by AI-generated implementation tasks specific to your project requirements and design.`;
|
|
388
|
+
|
|
389
|
+
// Try to replace template with analysis-backed tasks
|
|
390
|
+
try {
|
|
391
|
+
const { mod } = await loadSpecGenerator();
|
|
392
|
+
tasksContent = await mod.generateTasksDocument(currentPath, featureName);
|
|
393
|
+
} catch (e) {
|
|
394
|
+
// Keep template; include debug info in file header already
|
|
395
|
+
}
|
|
387
396
|
|
|
388
397
|
await fs.writeFile(path.join(featurePath, 'tasks.md'), tasksContent);
|
|
389
398
|
|
|
@@ -1189,6 +1198,63 @@ Managed by \`/kiro:steering\` command. Updates here reflect command changes.
|
|
|
1189
1198
|
}
|
|
1190
1199
|
await fs.writeFile(agentsPath, agentsContent);
|
|
1191
1200
|
}
|
|
1201
|
+
|
|
1202
|
+
// Ensure security-check.md exists (static)
|
|
1203
|
+
const securityPath = path.join(steeringPath, 'security-check.md');
|
|
1204
|
+
const securityExists = await fs.access(securityPath).then(() => true).catch(() => false);
|
|
1205
|
+
if (!securityExists) {
|
|
1206
|
+
const securityContent = `# Security Check (OWASP Top 10 Aligned)
|
|
1207
|
+
|
|
1208
|
+
Use this checklist during code generation and review. Avoid OWASP Top 10 issues by design.
|
|
1209
|
+
|
|
1210
|
+
## A01: Broken Access Control
|
|
1211
|
+
- Enforce least privilege; validate authorization on every request/path
|
|
1212
|
+
- No client-side trust; never rely on hidden fields or disabled UI
|
|
1213
|
+
|
|
1214
|
+
## A02: Cryptographic Failures
|
|
1215
|
+
- Use HTTPS/TLS; do not roll your own crypto
|
|
1216
|
+
- Store secrets in env vars/secret stores; never commit secrets
|
|
1217
|
+
|
|
1218
|
+
## A03: Injection
|
|
1219
|
+
- Use parameterized queries/ORM and safe template APIs
|
|
1220
|
+
- Sanitize/validate untrusted input; avoid string concatenation in queries
|
|
1221
|
+
|
|
1222
|
+
## A04: Insecure Design
|
|
1223
|
+
- Threat model critical flows; add security requirements to design
|
|
1224
|
+
- Fail secure; disable features by default until explicitly enabled
|
|
1225
|
+
|
|
1226
|
+
## A05: Security Misconfiguration
|
|
1227
|
+
- Disable debug modes in prod; set secure headers (CSP, HSTS, X-Content-Type-Options)
|
|
1228
|
+
- Pin dependencies and lock versions; no default credentials
|
|
1229
|
+
|
|
1230
|
+
## A06: Vulnerable & Outdated Components
|
|
1231
|
+
- Track SBOM/dependencies; run npm audit or a scanner regularly and patch
|
|
1232
|
+
- Prefer maintained libraries; remove unused deps
|
|
1233
|
+
|
|
1234
|
+
## A07: Identification & Authentication Failures
|
|
1235
|
+
- Use vetted auth (OIDC/OAuth2); enforce MFA where applicable
|
|
1236
|
+
- Secure session handling (HttpOnly, Secure, SameSite cookies)
|
|
1237
|
+
|
|
1238
|
+
## A08: Software & Data Integrity Failures
|
|
1239
|
+
- Verify integrity of third-party artifacts; signed releases when possible
|
|
1240
|
+
- Protect CI/CD: signed commits/tags, restricted tokens, principle of least privilege
|
|
1241
|
+
|
|
1242
|
+
## A09: Security Logging & Monitoring Failures
|
|
1243
|
+
- Log authz/authn events and errors without sensitive data
|
|
1244
|
+
- Add alerts for suspicious activity; retain logs per policy
|
|
1245
|
+
|
|
1246
|
+
## A10: Server-Side Request Forgery (SSRF)
|
|
1247
|
+
- Validate/deny-list outbound destinations; no direct fetch to arbitrary URLs
|
|
1248
|
+
- Use network egress controls; fetch via vetted proxies when needed
|
|
1249
|
+
|
|
1250
|
+
## General Practices
|
|
1251
|
+
- Validate inputs (schema, length, type) and outputs (encoding)
|
|
1252
|
+
- Handle errors without leaking stack traces or secrets
|
|
1253
|
+
- Use content security best practices for templates/HTML
|
|
1254
|
+
- Add security tests where feasible (authz, input validation)
|
|
1255
|
+
`;
|
|
1256
|
+
await fs.writeFile(securityPath, securityContent);
|
|
1257
|
+
}
|
|
1192
1258
|
|
|
1193
1259
|
const mode = updateMode === 'update' ? 'Updated' : 'Created';
|
|
1194
1260
|
|
|
@@ -1207,6 +1273,7 @@ Managed by \`/kiro:steering\` command. Updates here reflect command changes.
|
|
|
1207
1273
|
- \`.kiro/steering/structure.md\` - Project organization and architectural decisions (AI analysis template)
|
|
1208
1274
|
- \`.kiro/steering/linus-review.md\` - Code review guidelines (full content)
|
|
1209
1275
|
- \`.kiro/steering/commit.md\` - Commit message standards (full content)
|
|
1276
|
+
- \`.kiro/steering/security-check.md\` - Security checklist aligned to OWASP Top 10 (full content)
|
|
1210
1277
|
- \`.kiro/steering/AGENTS.md\` - Universal AI agent workflow guidance
|
|
1211
1278
|
|
|
1212
1279
|
**AI-Driven Approach**:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdd-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "MCP server for spec-driven development workflows across AI-agent CLIs and IDEs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"dist/**/*",
|
|
13
13
|
"mcp-server.js",
|
|
14
14
|
"documentGenerator.js",
|
|
15
|
+
"specGenerator.js",
|
|
15
16
|
"README.md",
|
|
16
17
|
"LICENSE",
|
|
17
18
|
"package.json"
|