sdd-mcp-server 1.6.2 → 1.8.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 +48 -33
- package/dist/adapters/cli/SDDToolAdapter.js +23 -22
- package/dist/adapters/cli/SDDToolAdapter.js.map +1 -1
- package/dist/application/services/staticSteering.js +22 -19
- package/dist/application/services/staticSteering.js.map +1 -1
- package/dist/index.js +92 -57
- package/dist/index.js.map +1 -1
- package/dist/utils/moduleLoader.d.ts +9 -12
- package/dist/utils/moduleLoader.js +55 -52
- package/dist/utils/moduleLoader.js.map +1 -1
- package/dist/utils/specGenerator.js +228 -160
- package/dist/utils/specGenerator.js.map +1 -1
- package/package.json +2 -2
- package/dist/__tests__/legacy/setup.d.ts +0 -44
- package/dist/__tests__/legacy/setup.js +0 -178
- package/dist/__tests__/legacy/setup.js.map +0 -1
- package/dist/__tests__/legacy/test-helpers/mock-factories.d.ts +0 -26
- package/dist/__tests__/legacy/test-helpers/mock-factories.js +0 -466
- package/dist/__tests__/legacy/test-helpers/mock-factories.js.map +0 -1
- package/dist/__tests__/setup.d.ts +0 -44
- package/dist/__tests__/setup.js +0 -178
- package/dist/__tests__/setup.js.map +0 -1
- package/dist/__tests__/test-helpers/mock-factories.d.ts +0 -26
- package/dist/__tests__/test-helpers/mock-factories.js +0 -466
- package/dist/__tests__/test-helpers/mock-factories.js.map +0 -1
package/dist/__tests__/setup.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;CA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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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
// Mock factories for consistent test data generation
|
|
2
|
-
import { HookType, HookPhase, ToolCategory, PermissionType, SteeringMode, PluginState, ValidationSeverity, SecuritySeverity } from '../../domain/plugins/index.js';
|
|
3
|
-
import { WorkflowPhase, WorkflowState } from '../../domain/types.js';
|
|
4
|
-
import { SteeringDocumentType } from '../../domain/context/ProjectContext.js';
|
|
5
|
-
export class MockFactories {
|
|
6
|
-
// Hook System Mocks
|
|
7
|
-
static createMockHookRegistration(overrides = {}) {
|
|
8
|
-
return {
|
|
9
|
-
pluginId: 'test-plugin',
|
|
10
|
-
name: 'test-hook',
|
|
11
|
-
type: HookType.FILTER,
|
|
12
|
-
phase: HookPhase.PRE_INIT,
|
|
13
|
-
priority: 100,
|
|
14
|
-
handler: jest.fn().mockResolvedValue({ success: true, data: {} }),
|
|
15
|
-
conditions: [],
|
|
16
|
-
...overrides
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
static createMockHookExecutionContext(overrides = {}) {
|
|
20
|
-
return {
|
|
21
|
-
hookName: 'test-hook',
|
|
22
|
-
phase: HookPhase.PRE_INIT,
|
|
23
|
-
data: { test: true },
|
|
24
|
-
metadata: {},
|
|
25
|
-
cancellationToken: {
|
|
26
|
-
isCancelled: false,
|
|
27
|
-
cancel: jest.fn(),
|
|
28
|
-
onCancelled: jest.fn()
|
|
29
|
-
},
|
|
30
|
-
...overrides
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
static createMockHookResult(overrides = {}) {
|
|
34
|
-
return {
|
|
35
|
-
success: true,
|
|
36
|
-
data: { processed: true },
|
|
37
|
-
metadata: {
|
|
38
|
-
executionTime: 100,
|
|
39
|
-
hooksExecuted: 1,
|
|
40
|
-
errorCount: 0
|
|
41
|
-
},
|
|
42
|
-
...overrides
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
// Tool Registry Mocks
|
|
46
|
-
static createMockToolRegistration(overrides = {}) {
|
|
47
|
-
return {
|
|
48
|
-
pluginId: 'test-plugin',
|
|
49
|
-
name: 'test-tool',
|
|
50
|
-
description: 'A test tool',
|
|
51
|
-
category: ToolCategory.UTILITY,
|
|
52
|
-
handler: jest.fn().mockResolvedValue({ success: true, data: {} }),
|
|
53
|
-
inputSchema: {
|
|
54
|
-
type: 'object',
|
|
55
|
-
properties: {
|
|
56
|
-
input: { type: 'string' }
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
outputSchema: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: {
|
|
62
|
-
result: { type: 'string' }
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
permissions: [],
|
|
66
|
-
...overrides
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
static createMockToolExecutionContext(overrides = {}) {
|
|
70
|
-
return {
|
|
71
|
-
toolName: 'test-tool',
|
|
72
|
-
pluginId: 'test-plugin',
|
|
73
|
-
user: 'test-user',
|
|
74
|
-
session: 'test-session',
|
|
75
|
-
metadata: {},
|
|
76
|
-
...overrides
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
static createMockToolResult(overrides = {}) {
|
|
80
|
-
return {
|
|
81
|
-
success: true,
|
|
82
|
-
data: { result: 'success' },
|
|
83
|
-
metadata: {
|
|
84
|
-
executionTime: 150,
|
|
85
|
-
inputValidated: true,
|
|
86
|
-
outputValidated: true
|
|
87
|
-
},
|
|
88
|
-
...overrides
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
// Steering Document Mocks
|
|
92
|
-
static createMockSteeringDeclaration(overrides = {}) {
|
|
93
|
-
return {
|
|
94
|
-
name: 'test-steering',
|
|
95
|
-
type: SteeringDocumentType.CUSTOM,
|
|
96
|
-
mode: SteeringMode.ALWAYS,
|
|
97
|
-
priority: 100,
|
|
98
|
-
patterns: [],
|
|
99
|
-
template: 'Test steering content: {{variable}}',
|
|
100
|
-
variables: [
|
|
101
|
-
{
|
|
102
|
-
name: 'variable',
|
|
103
|
-
type: 'string',
|
|
104
|
-
description: 'Test variable',
|
|
105
|
-
required: false,
|
|
106
|
-
defaultValue: 'default'
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
...overrides
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
static createMockSteeringContext(overrides = {}) {
|
|
113
|
-
return {
|
|
114
|
-
currentFile: 'test.ts',
|
|
115
|
-
projectPath: '/test/project',
|
|
116
|
-
workingDirectory: '/test/project',
|
|
117
|
-
variables: { variable: 'test-value' },
|
|
118
|
-
metadata: { timestamp: new Date().toISOString() },
|
|
119
|
-
...overrides
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
static createMockSteeringResult(overrides = {}) {
|
|
123
|
-
return {
|
|
124
|
-
applicable: true,
|
|
125
|
-
content: 'Test steering content: test-value',
|
|
126
|
-
variables: { variable: 'test-value' },
|
|
127
|
-
priority: 100,
|
|
128
|
-
conflictsWith: [],
|
|
129
|
-
...overrides
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
// Plugin Mocks
|
|
133
|
-
static createMockPlugin(overrides = {}) {
|
|
134
|
-
return {
|
|
135
|
-
id: 'test-plugin',
|
|
136
|
-
name: 'Test Plugin',
|
|
137
|
-
version: '1.0.0',
|
|
138
|
-
description: 'A comprehensive test plugin',
|
|
139
|
-
author: 'Test Developer',
|
|
140
|
-
homepage: 'https://example.com',
|
|
141
|
-
repository: 'https://github.com/test/plugin',
|
|
142
|
-
license: 'MIT',
|
|
143
|
-
keywords: ['test', 'sdd', 'plugin'],
|
|
144
|
-
dependencies: [],
|
|
145
|
-
peerDependencies: [],
|
|
146
|
-
engines: [
|
|
147
|
-
{ name: 'node', version: '>=18.0.0' },
|
|
148
|
-
{ name: 'sdd-mcp', version: '>=1.0.0' }
|
|
149
|
-
],
|
|
150
|
-
capabilities: [
|
|
151
|
-
{
|
|
152
|
-
type: 'hook',
|
|
153
|
-
name: 'workflow-enhancement',
|
|
154
|
-
description: 'Enhances workflow execution',
|
|
155
|
-
required: false,
|
|
156
|
-
configuration: {}
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
|
-
hooks: [
|
|
160
|
-
{
|
|
161
|
-
name: 'enhance-requirements',
|
|
162
|
-
type: HookType.FILTER,
|
|
163
|
-
phase: HookPhase.PRE_REQUIREMENTS,
|
|
164
|
-
priority: 200,
|
|
165
|
-
description: 'Enhances requirements with additional context',
|
|
166
|
-
parameters: [
|
|
167
|
-
{
|
|
168
|
-
name: 'context',
|
|
169
|
-
type: 'object',
|
|
170
|
-
required: true,
|
|
171
|
-
description: 'Execution context'
|
|
172
|
-
}
|
|
173
|
-
],
|
|
174
|
-
returnType: 'HookResult'
|
|
175
|
-
}
|
|
176
|
-
],
|
|
177
|
-
tools: [
|
|
178
|
-
{
|
|
179
|
-
name: 'analyze-complexity',
|
|
180
|
-
description: 'Analyzes code complexity',
|
|
181
|
-
category: ToolCategory.QUALITY,
|
|
182
|
-
inputSchema: {
|
|
183
|
-
type: 'object',
|
|
184
|
-
properties: {
|
|
185
|
-
filePath: { type: 'string' }
|
|
186
|
-
},
|
|
187
|
-
required: ['filePath']
|
|
188
|
-
},
|
|
189
|
-
outputSchema: {
|
|
190
|
-
type: 'object',
|
|
191
|
-
properties: {
|
|
192
|
-
complexity: { type: 'number' },
|
|
193
|
-
suggestions: { type: 'array' }
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
examples: [
|
|
197
|
-
{
|
|
198
|
-
name: 'Analyze TypeScript file',
|
|
199
|
-
description: 'Analyze complexity of a TypeScript file',
|
|
200
|
-
input: { filePath: 'src/component.ts' },
|
|
201
|
-
expectedOutput: { complexity: 15, suggestions: ['Extract helper function'] }
|
|
202
|
-
}
|
|
203
|
-
],
|
|
204
|
-
permissions: [
|
|
205
|
-
{
|
|
206
|
-
type: PermissionType.FILE_READ,
|
|
207
|
-
resource: 'src/**/*.ts',
|
|
208
|
-
actions: ['read']
|
|
209
|
-
}
|
|
210
|
-
]
|
|
211
|
-
}
|
|
212
|
-
],
|
|
213
|
-
steeringDocuments: [
|
|
214
|
-
{
|
|
215
|
-
name: 'coding-standards',
|
|
216
|
-
type: SteeringDocumentType.TECHNICAL,
|
|
217
|
-
mode: SteeringMode.ALWAYS,
|
|
218
|
-
priority: 150,
|
|
219
|
-
patterns: [],
|
|
220
|
-
template: '# Coding Standards\n\nFollow {{standard}} guidelines.',
|
|
221
|
-
variables: [
|
|
222
|
-
{
|
|
223
|
-
name: 'standard',
|
|
224
|
-
type: 'string',
|
|
225
|
-
description: 'Coding standard to follow',
|
|
226
|
-
required: true,
|
|
227
|
-
defaultValue: 'TypeScript'
|
|
228
|
-
}
|
|
229
|
-
]
|
|
230
|
-
}
|
|
231
|
-
],
|
|
232
|
-
configuration: {
|
|
233
|
-
schema: {
|
|
234
|
-
type: 'object',
|
|
235
|
-
properties: {
|
|
236
|
-
enableEnhancements: { type: 'boolean' },
|
|
237
|
-
complexityThreshold: { type: 'number', minimum: 0, maximum: 100 }
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
defaults: {
|
|
241
|
-
enableEnhancements: true,
|
|
242
|
-
complexityThreshold: 10
|
|
243
|
-
},
|
|
244
|
-
required: ['enableEnhancements'],
|
|
245
|
-
validation: [
|
|
246
|
-
{
|
|
247
|
-
field: 'complexityThreshold',
|
|
248
|
-
type: 'range',
|
|
249
|
-
rules: [
|
|
250
|
-
{
|
|
251
|
-
type: 'min',
|
|
252
|
-
value: 1,
|
|
253
|
-
message: 'Complexity threshold must be at least 1'
|
|
254
|
-
}
|
|
255
|
-
],
|
|
256
|
-
message: 'Invalid complexity threshold'
|
|
257
|
-
}
|
|
258
|
-
]
|
|
259
|
-
},
|
|
260
|
-
metadata: {
|
|
261
|
-
createdAt: new Date('2024-01-01'),
|
|
262
|
-
updatedAt: new Date('2024-01-15'),
|
|
263
|
-
installedAt: new Date('2024-01-20'),
|
|
264
|
-
lastUsed: new Date('2024-01-22'),
|
|
265
|
-
usageCount: 50,
|
|
266
|
-
ratings: [
|
|
267
|
-
{
|
|
268
|
-
userId: 'user1',
|
|
269
|
-
rating: 5,
|
|
270
|
-
comment: 'Excellent plugin!',
|
|
271
|
-
createdAt: new Date('2024-01-21')
|
|
272
|
-
}
|
|
273
|
-
],
|
|
274
|
-
tags: ['workflow', 'quality', 'analysis'],
|
|
275
|
-
category: 'QUALITY',
|
|
276
|
-
maturity: 'STABLE',
|
|
277
|
-
supportedLanguages: ['typescript', 'javascript']
|
|
278
|
-
},
|
|
279
|
-
...overrides
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
static createMockPluginInstance(overrides = {}) {
|
|
283
|
-
const plugin = this.createMockPlugin();
|
|
284
|
-
return {
|
|
285
|
-
plugin,
|
|
286
|
-
instance: {
|
|
287
|
-
initialize: jest.fn(),
|
|
288
|
-
activate: jest.fn(),
|
|
289
|
-
deactivate: jest.fn(),
|
|
290
|
-
dispose: jest.fn(),
|
|
291
|
-
getConfiguration: jest.fn().mockReturnValue({}),
|
|
292
|
-
setConfiguration: jest.fn(),
|
|
293
|
-
executeHook: jest.fn().mockResolvedValue({ success: true }),
|
|
294
|
-
executeTool: jest.fn().mockResolvedValue({ success: true })
|
|
295
|
-
},
|
|
296
|
-
state: PluginState.ACTIVE,
|
|
297
|
-
loadedAt: new Date(),
|
|
298
|
-
configuration: plugin.configuration.defaults,
|
|
299
|
-
hooks: [],
|
|
300
|
-
tools: [],
|
|
301
|
-
...overrides
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
static createMockPluginDescriptor(overrides = {}) {
|
|
305
|
-
return {
|
|
306
|
-
path: '/plugins/test-plugin',
|
|
307
|
-
manifest: this.createMockPlugin(),
|
|
308
|
-
valid: true,
|
|
309
|
-
errors: [],
|
|
310
|
-
warnings: [],
|
|
311
|
-
...overrides
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
static createMockPluginValidationResult(overrides = {}) {
|
|
315
|
-
return {
|
|
316
|
-
valid: true,
|
|
317
|
-
errors: [],
|
|
318
|
-
warnings: [],
|
|
319
|
-
securityIssues: [],
|
|
320
|
-
compatibilityIssues: [],
|
|
321
|
-
...overrides
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
// Workflow Mocks
|
|
325
|
-
static createMockWorkflowState(overrides = {}) {
|
|
326
|
-
return {
|
|
327
|
-
currentPhase: WorkflowPhase.INIT,
|
|
328
|
-
state: WorkflowState.IN_PROGRESS,
|
|
329
|
-
phases: {
|
|
330
|
-
[WorkflowPhase.INIT]: {
|
|
331
|
-
status: WorkflowState.IN_PROGRESS,
|
|
332
|
-
startedAt: new Date(),
|
|
333
|
-
duration: 0
|
|
334
|
-
},
|
|
335
|
-
[WorkflowPhase.REQUIREMENTS]: {
|
|
336
|
-
status: WorkflowState.PENDING,
|
|
337
|
-
duration: 0
|
|
338
|
-
},
|
|
339
|
-
[WorkflowPhase.DESIGN]: {
|
|
340
|
-
status: WorkflowState.PENDING,
|
|
341
|
-
duration: 0
|
|
342
|
-
},
|
|
343
|
-
[WorkflowPhase.TASKS]: {
|
|
344
|
-
status: WorkflowState.PENDING,
|
|
345
|
-
duration: 0
|
|
346
|
-
},
|
|
347
|
-
[WorkflowPhase.IMPLEMENTATION]: {
|
|
348
|
-
status: WorkflowState.PENDING,
|
|
349
|
-
duration: 0
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
startedAt: new Date(),
|
|
353
|
-
projectPath: '/test/project',
|
|
354
|
-
...overrides
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
static createMockWorkflowMetrics(overrides = {}) {
|
|
358
|
-
return {
|
|
359
|
-
totalDuration: 3600000, // 1 hour
|
|
360
|
-
phasesCompleted: 2,
|
|
361
|
-
phasesRemaining: 3,
|
|
362
|
-
completionPercentage: 40,
|
|
363
|
-
averagePhaseTime: 1800000, // 30 minutes
|
|
364
|
-
estimatedTimeRemaining: 5400000, // 1.5 hours
|
|
365
|
-
currentPhaseElapsedTime: 300000, // 5 minutes
|
|
366
|
-
...overrides
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
// MCP Protocol Mocks
|
|
370
|
-
static createMockMCPTool(overrides = {}) {
|
|
371
|
-
return {
|
|
372
|
-
name: 'sdd-init',
|
|
373
|
-
description: 'Initialize a new SDD project',
|
|
374
|
-
inputSchema: {
|
|
375
|
-
type: 'object',
|
|
376
|
-
properties: {
|
|
377
|
-
projectPath: { type: 'string' },
|
|
378
|
-
projectName: { type: 'string' },
|
|
379
|
-
description: { type: 'string' }
|
|
380
|
-
},
|
|
381
|
-
required: ['projectPath', 'projectName']
|
|
382
|
-
},
|
|
383
|
-
...overrides
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
static createMockMCPRequest(overrides = {}) {
|
|
387
|
-
return {
|
|
388
|
-
method: 'tools/call',
|
|
389
|
-
params: {
|
|
390
|
-
name: 'sdd-init',
|
|
391
|
-
arguments: {
|
|
392
|
-
projectPath: '/test/project',
|
|
393
|
-
projectName: 'Test Project'
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
...overrides
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
static createMockMCPResponse(overrides = {}) {
|
|
400
|
-
return {
|
|
401
|
-
content: [
|
|
402
|
-
{
|
|
403
|
-
type: 'text',
|
|
404
|
-
text: 'Operation completed successfully'
|
|
405
|
-
}
|
|
406
|
-
],
|
|
407
|
-
isError: false,
|
|
408
|
-
...overrides
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
// Performance Testing Mocks
|
|
412
|
-
static createMockPerformanceMetrics(overrides = {}) {
|
|
413
|
-
return {
|
|
414
|
-
executionTime: 150,
|
|
415
|
-
memoryUsage: 1024 * 1024, // 1MB
|
|
416
|
-
cpuUsage: 15.5,
|
|
417
|
-
operationsPerSecond: 1000,
|
|
418
|
-
errorRate: 0.01,
|
|
419
|
-
successRate: 0.99,
|
|
420
|
-
...overrides
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
// Error and Validation Mocks
|
|
424
|
-
static createMockValidationError(overrides = {}) {
|
|
425
|
-
return {
|
|
426
|
-
type: 'validation-error',
|
|
427
|
-
message: 'Validation failed',
|
|
428
|
-
field: 'testField',
|
|
429
|
-
severity: ValidationSeverity.HIGH,
|
|
430
|
-
...overrides
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
static createMockSecurityIssue(overrides = {}) {
|
|
434
|
-
return {
|
|
435
|
-
type: 'code-injection',
|
|
436
|
-
severity: SecuritySeverity.HIGH,
|
|
437
|
-
message: 'Potential code injection vulnerability detected',
|
|
438
|
-
recommendation: 'Sanitize user input before processing',
|
|
439
|
-
cve: 'CVE-2024-0001',
|
|
440
|
-
...overrides
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
// Utility methods for batch creation
|
|
444
|
-
static createMockHookRegistrations(count) {
|
|
445
|
-
return Array.from({ length: count }, (_, i) => this.createMockHookRegistration({
|
|
446
|
-
name: `hook-${i}`,
|
|
447
|
-
priority: 100 - i,
|
|
448
|
-
pluginId: `plugin-${i}`
|
|
449
|
-
}));
|
|
450
|
-
}
|
|
451
|
-
static createMockToolRegistrations(count) {
|
|
452
|
-
return Array.from({ length: count }, (_, i) => this.createMockToolRegistration({
|
|
453
|
-
name: `tool-${i}`,
|
|
454
|
-
pluginId: `plugin-${i}`,
|
|
455
|
-
category: Object.values(ToolCategory)[i % Object.values(ToolCategory).length]
|
|
456
|
-
}));
|
|
457
|
-
}
|
|
458
|
-
static createMockSteeringDocuments(count) {
|
|
459
|
-
return Array.from({ length: count }, (_, i) => this.createMockSteeringDeclaration({
|
|
460
|
-
name: `steering-${i}`,
|
|
461
|
-
priority: 200 - i,
|
|
462
|
-
mode: Object.values(SteeringMode)[i % Object.values(SteeringMode).length]
|
|
463
|
-
}));
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
//# sourceMappingURL=mock-factories.js.map
|