sdd-mcp-server 1.0.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.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +256 -0
  3. package/dist/__tests__/setup.d.ts +44 -0
  4. package/dist/__tests__/setup.js +178 -0
  5. package/dist/__tests__/setup.js.map +1 -0
  6. package/dist/__tests__/test-helpers/mock-factories.d.ts +26 -0
  7. package/dist/__tests__/test-helpers/mock-factories.js +466 -0
  8. package/dist/__tests__/test-helpers/mock-factories.js.map +1 -0
  9. package/dist/adapters/cli/SDDToolAdapter.d.ts +26 -0
  10. package/dist/adapters/cli/SDDToolAdapter.js +273 -0
  11. package/dist/adapters/cli/SDDToolAdapter.js.map +1 -0
  12. package/dist/application/services/CodebaseAnalysisService.d.ts +38 -0
  13. package/dist/application/services/CodebaseAnalysisService.js +737 -0
  14. package/dist/application/services/CodebaseAnalysisService.js.map +1 -0
  15. package/dist/application/services/LocalizationService.d.ts +184 -0
  16. package/dist/application/services/LocalizationService.js +536 -0
  17. package/dist/application/services/LocalizationService.js.map +1 -0
  18. package/dist/application/services/ProjectContextService.d.ts +61 -0
  19. package/dist/application/services/ProjectContextService.js +550 -0
  20. package/dist/application/services/ProjectContextService.js.map +1 -0
  21. package/dist/application/services/ProjectInitializationService.d.ts +57 -0
  22. package/dist/application/services/ProjectInitializationService.js +485 -0
  23. package/dist/application/services/ProjectInitializationService.js.map +1 -0
  24. package/dist/application/services/ProjectService.d.ts +19 -0
  25. package/dist/application/services/ProjectService.js +159 -0
  26. package/dist/application/services/ProjectService.js.map +1 -0
  27. package/dist/application/services/QualityGateService.d.ts +62 -0
  28. package/dist/application/services/QualityGateService.js +428 -0
  29. package/dist/application/services/QualityGateService.js.map +1 -0
  30. package/dist/application/services/QualityService.d.ts +43 -0
  31. package/dist/application/services/QualityService.js +245 -0
  32. package/dist/application/services/QualityService.js.map +1 -0
  33. package/dist/application/services/SteeringDocumentService.d.ts +62 -0
  34. package/dist/application/services/SteeringDocumentService.js +694 -0
  35. package/dist/application/services/SteeringDocumentService.js.map +1 -0
  36. package/dist/application/services/TemplateService.d.ts +47 -0
  37. package/dist/application/services/TemplateService.js +438 -0
  38. package/dist/application/services/TemplateService.js.map +1 -0
  39. package/dist/application/services/WorkflowEngineService.d.ts +56 -0
  40. package/dist/application/services/WorkflowEngineService.js +348 -0
  41. package/dist/application/services/WorkflowEngineService.js.map +1 -0
  42. package/dist/application/services/WorkflowService.d.ts +22 -0
  43. package/dist/application/services/WorkflowService.js +147 -0
  44. package/dist/application/services/WorkflowService.js.map +1 -0
  45. package/dist/application/services/WorkflowValidationService.d.ts +51 -0
  46. package/dist/application/services/WorkflowValidationService.js +665 -0
  47. package/dist/application/services/WorkflowValidationService.js.map +1 -0
  48. package/dist/domain/context/ProjectContext.d.ts +350 -0
  49. package/dist/domain/context/ProjectContext.js +138 -0
  50. package/dist/domain/context/ProjectContext.js.map +1 -0
  51. package/dist/domain/i18n/index.d.ts +286 -0
  52. package/dist/domain/i18n/index.js +97 -0
  53. package/dist/domain/i18n/index.js.map +1 -0
  54. package/dist/domain/plugins/index.d.ts +498 -0
  55. package/dist/domain/plugins/index.js +157 -0
  56. package/dist/domain/plugins/index.js.map +1 -0
  57. package/dist/domain/ports.d.ts +54 -0
  58. package/dist/domain/ports.js +3 -0
  59. package/dist/domain/ports.js.map +1 -0
  60. package/dist/domain/quality/index.d.ts +361 -0
  61. package/dist/domain/quality/index.js +113 -0
  62. package/dist/domain/quality/index.js.map +1 -0
  63. package/dist/domain/services/DomainService.d.ts +18 -0
  64. package/dist/domain/services/DomainService.js +71 -0
  65. package/dist/domain/services/DomainService.js.map +1 -0
  66. package/dist/domain/templates/index.d.ts +158 -0
  67. package/dist/domain/templates/index.js +22 -0
  68. package/dist/domain/templates/index.js.map +1 -0
  69. package/dist/domain/types.d.ts +115 -0
  70. package/dist/domain/types.js +37 -0
  71. package/dist/domain/types.js.map +1 -0
  72. package/dist/domain/workflow/WorkflowStateMachine.d.ts +62 -0
  73. package/dist/domain/workflow/WorkflowStateMachine.js +286 -0
  74. package/dist/domain/workflow/WorkflowStateMachine.js.map +1 -0
  75. package/dist/index.d.ts +19 -0
  76. package/dist/index.js +97 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/infrastructure/adapters/AjvValidationAdapter.d.ts +7 -0
  79. package/dist/infrastructure/adapters/AjvValidationAdapter.js +37 -0
  80. package/dist/infrastructure/adapters/AjvValidationAdapter.js.map +1 -0
  81. package/dist/infrastructure/adapters/ConsoleLoggerAdapter.d.ts +8 -0
  82. package/dist/infrastructure/adapters/ConsoleLoggerAdapter.js +41 -0
  83. package/dist/infrastructure/adapters/ConsoleLoggerAdapter.js.map +1 -0
  84. package/dist/infrastructure/adapters/FileBasedTaskTracker.d.ts +9 -0
  85. package/dist/infrastructure/adapters/FileBasedTaskTracker.js +41 -0
  86. package/dist/infrastructure/adapters/FileBasedTaskTracker.js.map +1 -0
  87. package/dist/infrastructure/adapters/HandlebarsTemplateEngine.d.ts +8 -0
  88. package/dist/infrastructure/adapters/HandlebarsTemplateEngine.js +38 -0
  89. package/dist/infrastructure/adapters/HandlebarsTemplateEngine.js.map +1 -0
  90. package/dist/infrastructure/adapters/JsonConfigurationAdapter.d.ts +7 -0
  91. package/dist/infrastructure/adapters/JsonConfigurationAdapter.js +24 -0
  92. package/dist/infrastructure/adapters/JsonConfigurationAdapter.js.map +1 -0
  93. package/dist/infrastructure/adapters/LinusQualityAnalyzer.d.ts +9 -0
  94. package/dist/infrastructure/adapters/LinusQualityAnalyzer.js +75 -0
  95. package/dist/infrastructure/adapters/LinusQualityAnalyzer.js.map +1 -0
  96. package/dist/infrastructure/adapters/NodeFileSystemAdapter.d.ts +12 -0
  97. package/dist/infrastructure/adapters/NodeFileSystemAdapter.js +39 -0
  98. package/dist/infrastructure/adapters/NodeFileSystemAdapter.js.map +1 -0
  99. package/dist/infrastructure/di/container.d.ts +3 -0
  100. package/dist/infrastructure/di/container.js +98 -0
  101. package/dist/infrastructure/di/container.js.map +1 -0
  102. package/dist/infrastructure/di/types.d.ts +39 -0
  103. package/dist/infrastructure/di/types.js +45 -0
  104. package/dist/infrastructure/di/types.js.map +1 -0
  105. package/dist/infrastructure/i18n/I18nextService.d.ts +27 -0
  106. package/dist/infrastructure/i18n/I18nextService.js +357 -0
  107. package/dist/infrastructure/i18n/I18nextService.js.map +1 -0
  108. package/dist/infrastructure/mcp/CapabilityNegotiator.d.ts +21 -0
  109. package/dist/infrastructure/mcp/CapabilityNegotiator.js +75 -0
  110. package/dist/infrastructure/mcp/CapabilityNegotiator.js.map +1 -0
  111. package/dist/infrastructure/mcp/ErrorHandler.d.ts +29 -0
  112. package/dist/infrastructure/mcp/ErrorHandler.js +101 -0
  113. package/dist/infrastructure/mcp/ErrorHandler.js.map +1 -0
  114. package/dist/infrastructure/mcp/MCPServer.d.ts +25 -0
  115. package/dist/infrastructure/mcp/MCPServer.js +246 -0
  116. package/dist/infrastructure/mcp/MCPServer.js.map +1 -0
  117. package/dist/infrastructure/mcp/PromptManager.d.ts +18 -0
  118. package/dist/infrastructure/mcp/PromptManager.js +373 -0
  119. package/dist/infrastructure/mcp/PromptManager.js.map +1 -0
  120. package/dist/infrastructure/mcp/ResourceManager.d.ts +15 -0
  121. package/dist/infrastructure/mcp/ResourceManager.js +229 -0
  122. package/dist/infrastructure/mcp/ResourceManager.js.map +1 -0
  123. package/dist/infrastructure/mcp/SessionManager.d.ts +64 -0
  124. package/dist/infrastructure/mcp/SessionManager.js +221 -0
  125. package/dist/infrastructure/mcp/SessionManager.js.map +1 -0
  126. package/dist/infrastructure/mcp/ToolRegistry.d.ts +48 -0
  127. package/dist/infrastructure/mcp/ToolRegistry.js +235 -0
  128. package/dist/infrastructure/mcp/ToolRegistry.js.map +1 -0
  129. package/dist/infrastructure/platform/PlatformAdapter.d.ts +46 -0
  130. package/dist/infrastructure/platform/PlatformAdapter.js +355 -0
  131. package/dist/infrastructure/platform/PlatformAdapter.js.map +1 -0
  132. package/dist/infrastructure/plugins/HookSystem.d.ts +40 -0
  133. package/dist/infrastructure/plugins/HookSystem.js +415 -0
  134. package/dist/infrastructure/plugins/HookSystem.js.map +1 -0
  135. package/dist/infrastructure/plugins/PluginManager.d.ts +51 -0
  136. package/dist/infrastructure/plugins/PluginManager.js +650 -0
  137. package/dist/infrastructure/plugins/PluginManager.js.map +1 -0
  138. package/dist/infrastructure/plugins/PluginSteeringRegistry.d.ts +63 -0
  139. package/dist/infrastructure/plugins/PluginSteeringRegistry.js +439 -0
  140. package/dist/infrastructure/plugins/PluginSteeringRegistry.js.map +1 -0
  141. package/dist/infrastructure/plugins/PluginToolRegistry.d.ts +54 -0
  142. package/dist/infrastructure/plugins/PluginToolRegistry.js +490 -0
  143. package/dist/infrastructure/plugins/PluginToolRegistry.js.map +1 -0
  144. package/dist/infrastructure/quality/ASTAnalyzer.d.ts +65 -0
  145. package/dist/infrastructure/quality/ASTAnalyzer.js +439 -0
  146. package/dist/infrastructure/quality/ASTAnalyzer.js.map +1 -0
  147. package/dist/infrastructure/quality/LinusCodeReviewer.d.ts +52 -0
  148. package/dist/infrastructure/quality/LinusCodeReviewer.js +551 -0
  149. package/dist/infrastructure/quality/LinusCodeReviewer.js.map +1 -0
  150. package/dist/infrastructure/repositories/InMemoryProjectRepository.d.ts +10 -0
  151. package/dist/infrastructure/repositories/InMemoryProjectRepository.js +35 -0
  152. package/dist/infrastructure/repositories/InMemoryProjectRepository.js.map +1 -0
  153. package/dist/infrastructure/schemas/project.schema.d.ts +192 -0
  154. package/dist/infrastructure/schemas/project.schema.js +114 -0
  155. package/dist/infrastructure/schemas/project.schema.js.map +1 -0
  156. package/dist/infrastructure/templates/FileGenerator.d.ts +15 -0
  157. package/dist/infrastructure/templates/FileGenerator.js +385 -0
  158. package/dist/infrastructure/templates/FileGenerator.js.map +1 -0
  159. package/dist/infrastructure/templates/HandlebarsRenderer.d.ts +16 -0
  160. package/dist/infrastructure/templates/HandlebarsRenderer.js +252 -0
  161. package/dist/infrastructure/templates/HandlebarsRenderer.js.map +1 -0
  162. package/dist/infrastructure/templates/TemplateManager.d.ts +36 -0
  163. package/dist/infrastructure/templates/TemplateManager.js +777 -0
  164. package/dist/infrastructure/templates/TemplateManager.js.map +1 -0
  165. package/package.json +89 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Yi Huang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,256 @@
1
+ # MCP SDD Server
2
+
3
+ A Model Context Protocol (MCP) server implementing Spec-Driven Development (SDD) workflows for AI-agent CLIs and IDEs like Claude Code, Cursor, and others.
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ ### Option 1: Install with npx (Recommended)
8
+ ```bash
9
+ # Run directly without installation
10
+ npx sdd-mcp-server
11
+
12
+ # Or install globally
13
+ npm install -g sdd-mcp-server
14
+ sdd-mcp-server
15
+ ```
16
+
17
+ ### Option 2: Clone and Run
18
+ ```bash
19
+ # Clone the repository
20
+ git clone https://github.com/yi-john-huang/sdd-mcp.git
21
+ cd sdd-mcp
22
+
23
+ # Install and start
24
+ npm install
25
+ npm run build
26
+ npm start
27
+ ```
28
+
29
+ ### Option 3: Docker
30
+ ```bash
31
+ # Run with Docker
32
+ docker run -p 3000:3000 ghcr.io/yi-john-huang/sdd-mcp:latest
33
+
34
+ # Or with Docker Compose
35
+ curl -O https://raw.githubusercontent.com/yi-john-huang/sdd-mcp/develop/docker-compose.yml
36
+ docker-compose up -d
37
+ ```
38
+
39
+ ## 🔧 Configuration for AI Clients
40
+
41
+ ### Claude Code
42
+ Add to your MCP settings:
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "sdd": {
47
+ "command": "npx",
48
+ "args": ["sdd-mcp-server"],
49
+ "env": {
50
+ "LOG_LEVEL": "info"
51
+ }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ### Cursor IDE
58
+ Add to your MCP configuration:
59
+ ```json
60
+ {
61
+ "sdd-server": {
62
+ "command": "sdd-mcp-server",
63
+ "args": [],
64
+ "env": {}
65
+ }
66
+ }
67
+ ```
68
+
69
+ ### Other MCP Clients
70
+ Any MCP-compatible client can connect using stdio transport:
71
+ ```bash
72
+ sdd-mcp-server
73
+ ```
74
+
75
+ ## 📋 Available SDD Commands
76
+
77
+ Once connected to your AI client, you can use these MCP tools:
78
+
79
+ | Tool | Description | Usage |
80
+ |------|-------------|--------|
81
+ | `sdd-init` | Initialize new SDD project | Creates .kiro directory structure |
82
+ | `sdd-requirements` | Generate requirements doc | Creates requirements.md from project analysis |
83
+ | `sdd-design` | Create design specifications | Generates design.md with architecture |
84
+ | `sdd-tasks` | Generate task breakdown | Creates tasks.md with implementation plan |
85
+ | `sdd-implement` | Implementation guidelines | Provides implementation steering |
86
+ | `sdd-status` | Check workflow progress | Shows current phase and approvals |
87
+ | `sdd-approve` | Approve workflow phases | Mark phases as approved for progression |
88
+ | `sdd-quality-check` | Code quality analysis | Linus-style 5-layer code review |
89
+ | `sdd-context-load` | Load project context | Restore project memory and state |
90
+ | `sdd-template-render` | Render templates | Generate files from templates |
91
+
92
+ ## 💡 Basic Workflow
93
+
94
+ 1. **Initialize Project**
95
+ ```
96
+ Use sdd-init to create a new SDD project
97
+ ```
98
+
99
+ 2. **Generate Requirements**
100
+ ```
101
+ Use sdd-requirements to analyze and document requirements
102
+ ```
103
+
104
+ 3. **Create Design**
105
+ ```
106
+ Use sdd-design to generate technical architecture
107
+ ```
108
+
109
+ 4. **Plan Tasks**
110
+ ```
111
+ Use sdd-tasks to break down implementation work
112
+ ```
113
+
114
+ 5. **Implement**
115
+ ```
116
+ Use sdd-implement for implementation guidance
117
+ ```
118
+
119
+ 6. **Quality Check**
120
+ ```
121
+ Use sdd-quality-check for code review and analysis
122
+ ```
123
+
124
+ ## ⚙️ Configuration
125
+
126
+ ### Environment Variables
127
+ ```bash
128
+ # Basic configuration
129
+ export LOG_LEVEL=info # debug, info, warn, error
130
+ export DEFAULT_LANG=en # en, es, fr, de, it, pt, ru, ja, zh, ko
131
+
132
+ # Advanced configuration (optional)
133
+ export PLUGIN_DIR=/path/to/plugins
134
+ export TEMPLATE_DIR=/path/to/templates
135
+ export MAX_PLUGINS=50
136
+ export HOOK_TIMEOUT=10000
137
+ ```
138
+
139
+ ### Claude Code Integration Example
140
+ ```json
141
+ {
142
+ "mcpServers": {
143
+ "sdd": {
144
+ "command": "npx",
145
+ "args": ["sdd-mcp-server"],
146
+ "env": {
147
+ "LOG_LEVEL": "info",
148
+ "DEFAULT_LANG": "en"
149
+ }
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ ## 🏗️ Key Features
156
+
157
+ - **5-Phase SDD Workflow**: INIT → REQUIREMENTS → DESIGN → TASKS → IMPLEMENTATION
158
+ - **Quality Enforcement**: Linus-style 5-layer code review system
159
+ - **Multi-Language Support**: 10 languages with cultural adaptation
160
+ - **Template Engine**: Handlebars-based file generation
161
+ - **Plugin System**: Extensible architecture for custom workflows
162
+ - **MCP Protocol**: Full compatibility with AI-agent CLIs and IDEs
163
+
164
+ ## 🔍 Example: Complete SDD Workflow
165
+
166
+ Here's how to use the MCP SDD Server in your AI client:
167
+
168
+ ```bash
169
+ # 1. Initialize a new project
170
+ "Use the sdd-init tool to create a project called 'my-web-app'"
171
+
172
+ # 2. Generate requirements
173
+ "Use sdd-requirements to analyze the project and create requirements.md"
174
+
175
+ # 3. Create technical design
176
+ "Use sdd-design to generate architecture and design specifications"
177
+
178
+ # 4. Plan implementation tasks
179
+ "Use sdd-tasks to break down the work into implementable tasks"
180
+
181
+ # 5. Get implementation guidance
182
+ "Use sdd-implement to provide implementation steering and best practices"
183
+
184
+ # 6. Review code quality
185
+ "Use sdd-quality-check to perform Linus-style code review on my components"
186
+ ```
187
+
188
+ ## 🛠️ Development & Troubleshooting
189
+
190
+ ### Local Development
191
+ ```bash
192
+ git clone https://github.com/yi-john-huang/sdd-mcp.git
193
+ cd sdd-mcp
194
+ npm install
195
+ npm run dev # Development mode with hot reload
196
+ ```
197
+
198
+ ### Testing
199
+ ```bash
200
+ npm test # Run all tests
201
+ npm run test:coverage # Run with coverage report
202
+ ```
203
+
204
+ ### Common Issues
205
+
206
+ **Issue: "Cannot find module @sdd/mcp-server"**
207
+ ```bash
208
+ # Clear npm cache and reinstall
209
+ npm cache clean --force
210
+ npm install -g @sdd/mcp-server
211
+ ```
212
+
213
+ **Issue: "MCP server not responding"**
214
+ ```bash
215
+ # Check if server is running
216
+ ps aux | grep sdd-mcp-server
217
+
218
+ # Check logs with debug level
219
+ LOG_LEVEL=debug npx sdd-mcp-server
220
+ ```
221
+
222
+ **Issue: "Permission denied"**
223
+ ```bash
224
+ # Fix permissions for global install
225
+ sudo npm install -g @sdd/mcp-server
226
+ ```
227
+
228
+ ## 📖 Advanced Documentation
229
+
230
+ For detailed documentation on:
231
+ - Plugin Development: See [DEPLOYMENT.md](DEPLOYMENT.md)
232
+ - Docker Deployment: See [Dockerfile](Dockerfile) and [docker-compose.yml](docker-compose.yml)
233
+ - Architecture Details: Explore the `/src` directory structure
234
+ - Quality Analysis: Review `.kiro/steering/linus-review.md`
235
+
236
+ ## 🐛 Support & Issues
237
+
238
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/yi-john-huang/sdd-mcp/issues)
239
+ - **Repository**: [yi-john-huang/sdd-mcp](https://github.com/yi-john-huang/sdd-mcp)
240
+ - **License**: MIT
241
+
242
+ ## 🚀 Quick Links
243
+
244
+ - [npm package](https://www.npmjs.com/package/@sdd/mcp-server)
245
+ - [Docker image](https://ghcr.io/yi-john-huang/sdd-mcp)
246
+ - [Source code](https://github.com/yi-john-huang/sdd-mcp)
247
+ - [Issues](https://github.com/yi-john-huang/sdd-mcp/issues)
248
+
249
+ ---
250
+
251
+ **Ready to get started?**
252
+ ```bash
253
+ npx sdd-mcp-server
254
+ ```
255
+
256
+ Built for the AI development community 🤖✨
@@ -0,0 +1,44 @@
1
+ import 'reflect-metadata';
2
+ declare global {
3
+ namespace jest {
4
+ interface Matchers<R> {
5
+ toBeWithinTimeThreshold(threshold?: number): R;
6
+ toHaveValidWorkflowState(): R;
7
+ toHaveValidPluginStructure(): R;
8
+ }
9
+ }
10
+ const TEST_CONFIG: {
11
+ timeout: number;
12
+ performanceThreshold: number;
13
+ tempDir: string;
14
+ };
15
+ }
16
+ export declare const TestUtils: {
17
+ createMockLogger: () => {
18
+ debug: jest.Mock<any, any, any>;
19
+ info: jest.Mock<any, any, any>;
20
+ warn: jest.Mock<any, any, any>;
21
+ error: jest.Mock<any, any, any>;
22
+ };
23
+ createMockFileSystem: () => {
24
+ readFile: jest.Mock<any, any, any>;
25
+ writeFile: jest.Mock<any, any, any>;
26
+ exists: jest.Mock<any, any, any>;
27
+ mkdir: jest.Mock<any, any, any>;
28
+ readdir: jest.Mock<any, any, any>;
29
+ stat: jest.Mock<any, any, any>;
30
+ join: jest.Mock<string, string[], any>;
31
+ basename: jest.Mock<string, [path: string], any>;
32
+ dirname: jest.Mock<string, [path: string], any>;
33
+ };
34
+ createMockValidation: () => {
35
+ validate: jest.Mock<any, any, any>;
36
+ validateSchema: jest.Mock<any, any, any>;
37
+ createValidator: jest.Mock<any, any, any>;
38
+ };
39
+ createTestWorkflowState: (overrides?: any) => any;
40
+ createTestPlugin: (overrides?: any) => any;
41
+ waitFor: (ms: number) => Promise<unknown>;
42
+ createTempDir: () => Promise<string>;
43
+ cleanupTempDir: (dir: string) => Promise<void>;
44
+ };
@@ -0,0 +1,178 @@
1
+ // Test setup and configuration for comprehensive testing framework
2
+ import 'reflect-metadata';
3
+ // Global test configuration
4
+ const TEST_TIMEOUT = 30000; // 30 seconds
5
+ const PERFORMANCE_THRESHOLD = 5000; // 5 seconds for performance tests
6
+ // Setup global test utilities
7
+ globalThis.TEST_CONFIG = {
8
+ timeout: TEST_TIMEOUT,
9
+ performanceThreshold: PERFORMANCE_THRESHOLD,
10
+ tempDir: process.env.TEST_TEMP_DIR || '/tmp/sdd-mcp-tests'
11
+ };
12
+ // Mock console methods for cleaner test output
13
+ const originalConsole = { ...console };
14
+ beforeAll(() => {
15
+ // Silence console output during tests unless TEST_VERBOSE is set
16
+ if (!process.env.TEST_VERBOSE) {
17
+ console.log = jest.fn();
18
+ console.debug = jest.fn();
19
+ console.info = jest.fn();
20
+ }
21
+ });
22
+ afterAll(() => {
23
+ // Restore console methods
24
+ if (!process.env.TEST_VERBOSE) {
25
+ Object.assign(console, originalConsole);
26
+ }
27
+ });
28
+ // Global error handling
29
+ process.on('unhandledRejection', (reason, promise) => {
30
+ console.error('Unhandled Rejection at:', promise, 'reason:', reason);
31
+ });
32
+ // Setup test matchers
33
+ expect.extend({
34
+ toBeWithinTimeThreshold(received, threshold = PERFORMANCE_THRESHOLD) {
35
+ const pass = received <= threshold;
36
+ if (pass) {
37
+ return {
38
+ message: () => `Expected ${received}ms to exceed ${threshold}ms`,
39
+ pass: true,
40
+ };
41
+ }
42
+ else {
43
+ return {
44
+ message: () => `Expected ${received}ms to be within ${threshold}ms threshold`,
45
+ pass: false,
46
+ };
47
+ }
48
+ },
49
+ toHaveValidWorkflowState(received) {
50
+ const requiredPhases = ['INIT', 'REQUIREMENTS', 'DESIGN', 'TASKS', 'IMPLEMENTATION'];
51
+ const requiredProperties = ['currentPhase', 'state', 'phases'];
52
+ const hasRequiredProperties = requiredProperties.every(prop => received && typeof received === 'object' && prop in received);
53
+ const hasAllPhases = requiredPhases.every(phase => received.phases && phase in received.phases);
54
+ const validCurrentPhase = requiredPhases.includes(received.currentPhase);
55
+ const pass = hasRequiredProperties && hasAllPhases && validCurrentPhase;
56
+ if (pass) {
57
+ return {
58
+ message: () => `Expected workflow state to be invalid`,
59
+ pass: true,
60
+ };
61
+ }
62
+ else {
63
+ return {
64
+ message: () => `Expected workflow state to have valid structure with all phases and properties`,
65
+ pass: false,
66
+ };
67
+ }
68
+ },
69
+ toHaveValidPluginStructure(received) {
70
+ const requiredProperties = ['id', 'name', 'version', 'capabilities'];
71
+ const hasRequiredProperties = requiredProperties.every(prop => received && typeof received === 'object' && prop in received);
72
+ const hasValidCapabilities = Array.isArray(received.capabilities);
73
+ const pass = hasRequiredProperties && hasValidCapabilities;
74
+ if (pass) {
75
+ return {
76
+ message: () => `Expected plugin structure to be invalid`,
77
+ pass: true,
78
+ };
79
+ }
80
+ else {
81
+ return {
82
+ message: () => `Expected plugin to have valid structure with required properties`,
83
+ pass: false,
84
+ };
85
+ }
86
+ }
87
+ });
88
+ // Test utilities
89
+ export const TestUtils = {
90
+ // Create mock logger
91
+ createMockLogger: () => ({
92
+ debug: jest.fn(),
93
+ info: jest.fn(),
94
+ warn: jest.fn(),
95
+ error: jest.fn()
96
+ }),
97
+ // Create mock file system
98
+ createMockFileSystem: () => ({
99
+ readFile: jest.fn(),
100
+ writeFile: jest.fn(),
101
+ exists: jest.fn(),
102
+ mkdir: jest.fn(),
103
+ readdir: jest.fn(),
104
+ stat: jest.fn(),
105
+ join: jest.fn((...args) => args.join('/')),
106
+ basename: jest.fn((path) => path.split('/').pop() || ''),
107
+ dirname: jest.fn((path) => path.split('/').slice(0, -1).join('/'))
108
+ }),
109
+ // Create mock validation port
110
+ createMockValidation: () => ({
111
+ validate: jest.fn(),
112
+ validateSchema: jest.fn(),
113
+ createValidator: jest.fn()
114
+ }),
115
+ // Generate test workflow state
116
+ createTestWorkflowState: (overrides = {}) => ({
117
+ currentPhase: 'INIT',
118
+ state: 'IN_PROGRESS',
119
+ phases: {
120
+ INIT: { status: 'IN_PROGRESS', startedAt: new Date() },
121
+ REQUIREMENTS: { status: 'PENDING' },
122
+ DESIGN: { status: 'PENDING' },
123
+ TASKS: { status: 'PENDING' },
124
+ IMPLEMENTATION: { status: 'PENDING' }
125
+ },
126
+ startedAt: new Date(),
127
+ ...overrides
128
+ }),
129
+ // Generate test plugin
130
+ createTestPlugin: (overrides = {}) => ({
131
+ id: 'test-plugin',
132
+ name: 'Test Plugin',
133
+ version: '1.0.0',
134
+ description: 'A test plugin',
135
+ author: 'Test Author',
136
+ license: 'MIT',
137
+ keywords: ['test'],
138
+ dependencies: [],
139
+ peerDependencies: [],
140
+ engines: [{ name: 'node', version: '>=18.0.0' }],
141
+ capabilities: [],
142
+ hooks: [],
143
+ tools: [],
144
+ steeringDocuments: [],
145
+ configuration: {
146
+ schema: {},
147
+ defaults: {},
148
+ required: [],
149
+ validation: []
150
+ },
151
+ metadata: {
152
+ createdAt: new Date(),
153
+ updatedAt: new Date(),
154
+ usageCount: 0,
155
+ ratings: [],
156
+ tags: [],
157
+ category: 'UTILITY',
158
+ maturity: 'STABLE',
159
+ supportedLanguages: ['typescript']
160
+ },
161
+ ...overrides
162
+ }),
163
+ // Wait for promises to resolve
164
+ waitFor: (ms) => new Promise(resolve => setTimeout(resolve, ms)),
165
+ // Create temporary directory for tests
166
+ createTempDir: async () => {
167
+ const { promises: fs } = await import('fs');
168
+ const os = await import('os');
169
+ const path = await import('path');
170
+ return await fs.mkdtemp(path.join(os.tmpdir(), 'sdd-mcp-test-'));
171
+ },
172
+ // Clean up temporary directory
173
+ cleanupTempDir: async (dir) => {
174
+ const { promises: fs } = await import('fs');
175
+ await fs.rm(dir, { recursive: true, force: true });
176
+ }
177
+ };
178
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,OAAO,kBAAkB,CAAC;AAE1B,4BAA4B;AAC5B,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,aAAa;AACzC,MAAM,qBAAqB,GAAG,IAAI,CAAC,CAAC,kCAAkC;AAEtE,8BAA8B;AAC7B,UAAkB,CAAC,WAAW,GAAG;IAChC,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,qBAAqB;IAC3C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,oBAAoB;CAC3D,CAAC;AAEF,+CAA+C;AAC/C,MAAM,eAAe,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;AAEvC,SAAS,CAAC,GAAG,EAAE;IACb,iEAAiE;IACjE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,GAAG,EAAE;IACZ,0BAA0B;IAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,wBAAwB;AACxB,OAAO,CAAC,EAAE,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AE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAExE,uCAAuC;IACvC,aAAa,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QAElC,OAAO,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,+BAA+B;IAC/B,cAAc,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE;QACpC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;CACF,CAAC"}
@@ -0,0 +1,26 @@
1
+ export declare class MockFactories {
2
+ static createMockHookRegistration(overrides?: any): any;
3
+ static createMockHookExecutionContext(overrides?: any): any;
4
+ static createMockHookResult(overrides?: any): any;
5
+ static createMockToolRegistration(overrides?: any): any;
6
+ static createMockToolExecutionContext(overrides?: any): any;
7
+ static createMockToolResult(overrides?: any): any;
8
+ static createMockSteeringDeclaration(overrides?: any): any;
9
+ static createMockSteeringContext(overrides?: any): any;
10
+ static createMockSteeringResult(overrides?: any): any;
11
+ static createMockPlugin(overrides?: any): any;
12
+ static createMockPluginInstance(overrides?: any): any;
13
+ static createMockPluginDescriptor(overrides?: any): any;
14
+ static createMockPluginValidationResult(overrides?: any): any;
15
+ static createMockWorkflowState(overrides?: any): any;
16
+ static createMockWorkflowMetrics(overrides?: any): any;
17
+ static createMockMCPTool(overrides?: any): any;
18
+ static createMockMCPRequest(overrides?: any): any;
19
+ static createMockMCPResponse(overrides?: any): any;
20
+ static createMockPerformanceMetrics(overrides?: any): any;
21
+ static createMockValidationError(overrides?: any): any;
22
+ static createMockSecurityIssue(overrides?: any): any;
23
+ static createMockHookRegistrations(count: number): any[];
24
+ static createMockToolRegistrations(count: number): any[];
25
+ static createMockSteeringDocuments(count: number): any[];
26
+ }