musubi-sdd 3.10.0 → 5.1.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 +24 -19
- package/package.json +1 -1
- package/src/agents/agent-loop.js +532 -0
- package/src/agents/agentic/code-generator.js +767 -0
- package/src/agents/agentic/code-reviewer.js +698 -0
- package/src/agents/agentic/index.js +43 -0
- package/src/agents/function-tool.js +432 -0
- package/src/agents/index.js +45 -0
- package/src/agents/schema-generator.js +514 -0
- package/src/analyzers/ast-extractor.js +870 -0
- package/src/analyzers/context-optimizer.js +681 -0
- package/src/analyzers/repository-map.js +692 -0
- package/src/integrations/index.js +7 -1
- package/src/integrations/mcp/index.js +175 -0
- package/src/integrations/mcp/mcp-context-provider.js +472 -0
- package/src/integrations/mcp/mcp-discovery.js +436 -0
- package/src/integrations/mcp/mcp-tool-registry.js +467 -0
- package/src/integrations/mcp-connector.js +818 -0
- package/src/integrations/tool-discovery.js +589 -0
- package/src/managers/index.js +7 -0
- package/src/managers/skill-tools.js +565 -0
- package/src/monitoring/cost-tracker.js +7 -0
- package/src/monitoring/incident-manager.js +10 -0
- package/src/monitoring/observability.js +10 -0
- package/src/monitoring/quality-dashboard.js +491 -0
- package/src/monitoring/release-manager.js +10 -0
- package/src/orchestration/agent-skill-binding.js +655 -0
- package/src/orchestration/error-handler.js +827 -0
- package/src/orchestration/index.js +235 -1
- package/src/orchestration/mcp-tool-adapters.js +896 -0
- package/src/orchestration/reasoning/index.js +58 -0
- package/src/orchestration/reasoning/planning-engine.js +831 -0
- package/src/orchestration/reasoning/reasoning-engine.js +710 -0
- package/src/orchestration/reasoning/self-correction.js +751 -0
- package/src/orchestration/skill-executor.js +665 -0
- package/src/orchestration/skill-registry.js +650 -0
- package/src/orchestration/workflow-examples.js +1072 -0
- package/src/orchestration/workflow-executor.js +779 -0
- package/src/phase4-integration.js +248 -0
- package/src/phase5-integration.js +402 -0
- package/src/steering/steering-auto-update.js +572 -0
- package/src/steering/steering-validator.js +547 -0
- package/src/templates/template-constraints.js +646 -0
- package/src/validators/advanced-validation.js +580 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Phase 4 Advanced Integrations - Index
|
|
3
|
+
* @description Export all Phase 4 advanced integration modules
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
// Sprint 4.1: MCP Integration Enhancement
|
|
10
|
+
const mcpIntegration = require('./integrations/mcp');
|
|
11
|
+
|
|
12
|
+
// Sprint 4.2: Codebase Intelligence
|
|
13
|
+
const { RepositoryMap, createRepositoryMap, generateRepositoryMap } = require('./analyzers/repository-map');
|
|
14
|
+
const { ASTExtractor, createASTExtractor } = require('./analyzers/ast-extractor');
|
|
15
|
+
const { ContextOptimizer, createContextOptimizer, optimizeContext } = require('./analyzers/context-optimizer');
|
|
16
|
+
|
|
17
|
+
// Sprint 4.3: Agentic Reasoning
|
|
18
|
+
const {
|
|
19
|
+
ReasoningEngine,
|
|
20
|
+
PlanningEngine,
|
|
21
|
+
SelfCorrection,
|
|
22
|
+
createReasoningEngine,
|
|
23
|
+
createPlanningEngine,
|
|
24
|
+
createSelfCorrection,
|
|
25
|
+
STRATEGY,
|
|
26
|
+
STEP_TYPE,
|
|
27
|
+
TASK_STATUS,
|
|
28
|
+
PLAN_STATUS,
|
|
29
|
+
PRIORITY
|
|
30
|
+
} = require('./orchestration/reasoning');
|
|
31
|
+
|
|
32
|
+
// Sprint 4.4: Agentic Features
|
|
33
|
+
const {
|
|
34
|
+
CodeGenerator,
|
|
35
|
+
CodeReviewer,
|
|
36
|
+
createCodeGenerator,
|
|
37
|
+
createCodeReviewer,
|
|
38
|
+
generateCode,
|
|
39
|
+
reviewCode,
|
|
40
|
+
GEN_MODE,
|
|
41
|
+
LANGUAGE,
|
|
42
|
+
TEMPLATES,
|
|
43
|
+
SEVERITY,
|
|
44
|
+
CATEGORY,
|
|
45
|
+
DEFAULT_RULES
|
|
46
|
+
} = require('./agents/agentic');
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Phase 4 Advanced Integrations
|
|
50
|
+
* Complete integration of all advanced features
|
|
51
|
+
*/
|
|
52
|
+
const phase4 = {
|
|
53
|
+
// Version
|
|
54
|
+
version: '4.0.0',
|
|
55
|
+
phase: 4,
|
|
56
|
+
|
|
57
|
+
// Sprint 4.1: MCP Integration
|
|
58
|
+
mcp: mcpIntegration,
|
|
59
|
+
|
|
60
|
+
// Sprint 4.2: Codebase Intelligence
|
|
61
|
+
codebase: {
|
|
62
|
+
RepositoryMap,
|
|
63
|
+
createRepositoryMap,
|
|
64
|
+
generateRepositoryMap,
|
|
65
|
+
ASTExtractor,
|
|
66
|
+
createASTExtractor,
|
|
67
|
+
ContextOptimizer,
|
|
68
|
+
createContextOptimizer,
|
|
69
|
+
optimizeContext
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
// Sprint 4.3: Agentic Reasoning
|
|
73
|
+
reasoning: {
|
|
74
|
+
ReasoningEngine,
|
|
75
|
+
PlanningEngine,
|
|
76
|
+
SelfCorrection,
|
|
77
|
+
createReasoningEngine,
|
|
78
|
+
createPlanningEngine,
|
|
79
|
+
createSelfCorrection,
|
|
80
|
+
STRATEGY,
|
|
81
|
+
STEP_TYPE,
|
|
82
|
+
TASK_STATUS,
|
|
83
|
+
PLAN_STATUS,
|
|
84
|
+
PRIORITY
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
// Sprint 4.4: Agentic Features
|
|
88
|
+
agentic: {
|
|
89
|
+
CodeGenerator,
|
|
90
|
+
CodeReviewer,
|
|
91
|
+
createCodeGenerator,
|
|
92
|
+
createCodeReviewer,
|
|
93
|
+
generateCode,
|
|
94
|
+
reviewCode,
|
|
95
|
+
GEN_MODE,
|
|
96
|
+
LANGUAGE,
|
|
97
|
+
TEMPLATES,
|
|
98
|
+
SEVERITY,
|
|
99
|
+
CATEGORY,
|
|
100
|
+
DEFAULT_RULES
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create integrated agent with all Phase 4 capabilities
|
|
106
|
+
* @param {Object} options - Agent options
|
|
107
|
+
* @returns {Object} Integrated agent
|
|
108
|
+
*/
|
|
109
|
+
function createIntegratedAgent(options = {}) {
|
|
110
|
+
return {
|
|
111
|
+
// Codebase Intelligence
|
|
112
|
+
repositoryMap: createRepositoryMap(options.repositoryMap),
|
|
113
|
+
astExtractor: createASTExtractor(options.astExtractor),
|
|
114
|
+
contextOptimizer: createContextOptimizer(options.contextOptimizer),
|
|
115
|
+
|
|
116
|
+
// Agentic Reasoning
|
|
117
|
+
reasoningEngine: createReasoningEngine(options.reasoning),
|
|
118
|
+
planningEngine: createPlanningEngine(options.planning),
|
|
119
|
+
selfCorrection: createSelfCorrection(options.selfCorrection),
|
|
120
|
+
|
|
121
|
+
// Agentic Features
|
|
122
|
+
codeGenerator: createCodeGenerator(options.codeGenerator),
|
|
123
|
+
codeReviewer: createCodeReviewer(options.codeReviewer),
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Analyze repository and generate context
|
|
127
|
+
* @param {string} rootPath - Repository root path
|
|
128
|
+
* @returns {Promise<Object>} Analysis result
|
|
129
|
+
*/
|
|
130
|
+
async analyzeRepository(rootPath) {
|
|
131
|
+
const map = await this.repositoryMap.generate(rootPath);
|
|
132
|
+
return {
|
|
133
|
+
map,
|
|
134
|
+
stats: this.repositoryMap.getStats()
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Generate code with reasoning
|
|
140
|
+
* @param {string} description - What to generate
|
|
141
|
+
* @param {Object} options - Generation options
|
|
142
|
+
* @returns {Promise<Object>} Generated code with reasoning
|
|
143
|
+
*/
|
|
144
|
+
async generateWithReasoning(description, options = {}) {
|
|
145
|
+
// Plan the generation
|
|
146
|
+
const plan = this.planningEngine.createPlan(`Generate: ${description}`, {
|
|
147
|
+
strategy: 'incremental'
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Reason about the implementation
|
|
151
|
+
const reasoning = this.reasoningEngine.reason(
|
|
152
|
+
`How to implement: ${description}`,
|
|
153
|
+
{ type: 'decomposition' }
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// Generate the code
|
|
157
|
+
const generated = await this.codeGenerator.generate({
|
|
158
|
+
description,
|
|
159
|
+
...options
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Review the generated code
|
|
163
|
+
const review = this.codeReviewer.review(generated.code, options);
|
|
164
|
+
|
|
165
|
+
// Self-correct if needed
|
|
166
|
+
if (review.score < 70) {
|
|
167
|
+
const correction = this.selfCorrection.analyzeError({
|
|
168
|
+
error: new Error('Code quality below threshold'),
|
|
169
|
+
context: { review, generated }
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
generated,
|
|
174
|
+
review,
|
|
175
|
+
correction,
|
|
176
|
+
reasoning: reasoning.result,
|
|
177
|
+
plan: plan.id,
|
|
178
|
+
needsImprovement: true
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
generated,
|
|
184
|
+
review,
|
|
185
|
+
reasoning: reasoning.result,
|
|
186
|
+
plan: plan.id,
|
|
187
|
+
needsImprovement: false
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Get agent statistics
|
|
193
|
+
* @returns {Object} Agent statistics
|
|
194
|
+
*/
|
|
195
|
+
getStats() {
|
|
196
|
+
return {
|
|
197
|
+
repositoryMap: this.repositoryMap.getStats(),
|
|
198
|
+
reasoning: this.reasoningEngine.getStats(),
|
|
199
|
+
planning: this.planningEngine.getStats(),
|
|
200
|
+
codeGenerator: this.codeGenerator.getStats(),
|
|
201
|
+
codeReviewer: this.codeReviewer.getStats()
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
module.exports = {
|
|
208
|
+
...phase4,
|
|
209
|
+
phase4,
|
|
210
|
+
createIntegratedAgent,
|
|
211
|
+
|
|
212
|
+
// Direct exports for convenience
|
|
213
|
+
RepositoryMap,
|
|
214
|
+
ASTExtractor,
|
|
215
|
+
ContextOptimizer,
|
|
216
|
+
ReasoningEngine,
|
|
217
|
+
PlanningEngine,
|
|
218
|
+
SelfCorrection,
|
|
219
|
+
CodeGenerator,
|
|
220
|
+
CodeReviewer,
|
|
221
|
+
|
|
222
|
+
// Factory functions
|
|
223
|
+
createRepositoryMap,
|
|
224
|
+
createASTExtractor,
|
|
225
|
+
createContextOptimizer,
|
|
226
|
+
createReasoningEngine,
|
|
227
|
+
createPlanningEngine,
|
|
228
|
+
createSelfCorrection,
|
|
229
|
+
createCodeGenerator,
|
|
230
|
+
createCodeReviewer,
|
|
231
|
+
|
|
232
|
+
// Helper functions
|
|
233
|
+
generateRepositoryMap,
|
|
234
|
+
optimizeContext,
|
|
235
|
+
generateCode,
|
|
236
|
+
reviewCode,
|
|
237
|
+
|
|
238
|
+
// Enums
|
|
239
|
+
STRATEGY,
|
|
240
|
+
STEP_TYPE,
|
|
241
|
+
TASK_STATUS,
|
|
242
|
+
PLAN_STATUS,
|
|
243
|
+
PRIORITY,
|
|
244
|
+
GEN_MODE,
|
|
245
|
+
LANGUAGE,
|
|
246
|
+
SEVERITY,
|
|
247
|
+
CATEGORY
|
|
248
|
+
};
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5 Integration Module
|
|
3
|
+
* Advanced Features統合エンジン
|
|
4
|
+
*
|
|
5
|
+
* @module phase5-integration
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const EventEmitter = require('events');
|
|
9
|
+
|
|
10
|
+
// Phase 5 modules
|
|
11
|
+
const { SteeringAutoUpdate, createSteeringAutoUpdate, TRIGGER, STEERING_TYPE } = require('./steering/steering-auto-update');
|
|
12
|
+
const { SteeringValidator, createSteeringValidator, SEVERITY, RULE_TYPE } = require('./steering/steering-validator');
|
|
13
|
+
const { TemplateConstraints, ThinkingChecklist, createTemplateConstraints, createThinkingChecklist, CONSTRAINT_TYPE, UNCERTAINTY, MARKER_TYPE } = require('./templates/template-constraints');
|
|
14
|
+
const { QualityDashboard, createQualityDashboard, METRIC_CATEGORY, HEALTH_STATUS, CONSTITUTIONAL_ARTICLES } = require('./monitoring/quality-dashboard');
|
|
15
|
+
const { AdvancedValidation, createAdvancedValidation, VALIDATION_TYPE, ARTIFACT_TYPE, GAP_SEVERITY } = require('./validators/advanced-validation');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Phase 5 integration status
|
|
19
|
+
*/
|
|
20
|
+
const INTEGRATION_STATUS = {
|
|
21
|
+
INITIALIZED: 'initialized',
|
|
22
|
+
READY: 'ready',
|
|
23
|
+
RUNNING: 'running',
|
|
24
|
+
STOPPED: 'stopped',
|
|
25
|
+
ERROR: 'error'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Phase 5 Integration Engine
|
|
30
|
+
* Combines all advanced features for comprehensive project management
|
|
31
|
+
*/
|
|
32
|
+
class Phase5Integration extends EventEmitter {
|
|
33
|
+
/**
|
|
34
|
+
* @param {Object} options
|
|
35
|
+
* @param {Object} options.steering - Steering auto-update options
|
|
36
|
+
* @param {Object} options.validator - Steering validator options
|
|
37
|
+
* @param {Object} options.templates - Template constraints options
|
|
38
|
+
* @param {Object} options.dashboard - Quality dashboard options
|
|
39
|
+
* @param {Object} options.validation - Advanced validation options
|
|
40
|
+
*/
|
|
41
|
+
constructor(options = {}) {
|
|
42
|
+
super();
|
|
43
|
+
|
|
44
|
+
this.status = INTEGRATION_STATUS.INITIALIZED;
|
|
45
|
+
this.options = options;
|
|
46
|
+
|
|
47
|
+
// Initialize components
|
|
48
|
+
this.steeringAutoUpdate = createSteeringAutoUpdate(options.steering || {});
|
|
49
|
+
this.steeringValidator = createSteeringValidator(options.validator || {});
|
|
50
|
+
this.templateConstraints = createTemplateConstraints(options.templates || {});
|
|
51
|
+
this.qualityDashboard = createQualityDashboard(options.dashboard || {});
|
|
52
|
+
this.advancedValidation = createAdvancedValidation(options.validation || {});
|
|
53
|
+
|
|
54
|
+
// Thinking checklist
|
|
55
|
+
this.thinkingChecklist = createThinkingChecklist();
|
|
56
|
+
|
|
57
|
+
// Wire up event handlers
|
|
58
|
+
this.setupEventHandlers();
|
|
59
|
+
|
|
60
|
+
this.status = INTEGRATION_STATUS.READY;
|
|
61
|
+
this.emit('ready');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Setup cross-component event handlers
|
|
66
|
+
*/
|
|
67
|
+
setupEventHandlers() {
|
|
68
|
+
// When steering is updated, validate it
|
|
69
|
+
this.steeringAutoUpdate.on('update-applied', (update) => {
|
|
70
|
+
this.emit('steering-updated', update);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// When quality is collected, check thresholds
|
|
74
|
+
this.qualityDashboard.on('collected', (snapshot) => {
|
|
75
|
+
const health = this.qualityDashboard.getHealthSummary();
|
|
76
|
+
if (health.status === HEALTH_STATUS.CRITICAL || health.status === HEALTH_STATUS.FAILING) {
|
|
77
|
+
this.emit('health-alert', { status: health.status, snapshot });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// When validation finds issues, emit alerts
|
|
82
|
+
this.advancedValidation.on('validated', (result) => {
|
|
83
|
+
if (!result.valid) {
|
|
84
|
+
this.emit('validation-alert', result);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// When gaps are detected, emit alerts
|
|
89
|
+
this.advancedValidation.on('gaps-detected', (result) => {
|
|
90
|
+
if (result.criticalGaps > 0) {
|
|
91
|
+
this.emit('gap-alert', result);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get component by name
|
|
98
|
+
* @param {string} name
|
|
99
|
+
* @returns {Object|null}
|
|
100
|
+
*/
|
|
101
|
+
getComponent(name) {
|
|
102
|
+
const components = {
|
|
103
|
+
steeringAutoUpdate: this.steeringAutoUpdate,
|
|
104
|
+
steeringValidator: this.steeringValidator,
|
|
105
|
+
templateConstraints: this.templateConstraints,
|
|
106
|
+
qualityDashboard: this.qualityDashboard,
|
|
107
|
+
advancedValidation: this.advancedValidation,
|
|
108
|
+
thinkingChecklist: this.thinkingChecklist
|
|
109
|
+
};
|
|
110
|
+
return components[name] || null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Run comprehensive project analysis
|
|
115
|
+
* @param {Object} context - Project context
|
|
116
|
+
* @returns {Object}
|
|
117
|
+
*/
|
|
118
|
+
async analyzeProject(context = {}) {
|
|
119
|
+
const timestamp = new Date().toISOString();
|
|
120
|
+
this.status = INTEGRATION_STATUS.RUNNING;
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
// Collect quality metrics
|
|
124
|
+
const metrics = await this.qualityDashboard.collect(context);
|
|
125
|
+
|
|
126
|
+
// Run advanced validations
|
|
127
|
+
const validation = this.advancedValidation.runAllValidations();
|
|
128
|
+
|
|
129
|
+
// Get health summary
|
|
130
|
+
const health = this.qualityDashboard.getHealthSummary();
|
|
131
|
+
|
|
132
|
+
// Calculate overall score
|
|
133
|
+
const overallScore = this.calculateOverallScore(metrics, validation);
|
|
134
|
+
|
|
135
|
+
const result = {
|
|
136
|
+
timestamp,
|
|
137
|
+
status: this.status,
|
|
138
|
+
health,
|
|
139
|
+
metrics,
|
|
140
|
+
validation,
|
|
141
|
+
overallScore,
|
|
142
|
+
recommendations: this.generateRecommendations(health, validation)
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
this.status = INTEGRATION_STATUS.READY;
|
|
146
|
+
this.emit('analysis-complete', result);
|
|
147
|
+
|
|
148
|
+
return result;
|
|
149
|
+
} catch (error) {
|
|
150
|
+
this.status = INTEGRATION_STATUS.ERROR;
|
|
151
|
+
this.emit('error', error);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Calculate overall project score
|
|
158
|
+
*/
|
|
159
|
+
calculateOverallScore(metrics, validation) {
|
|
160
|
+
const healthScore = metrics.health?.overall ?? 0;
|
|
161
|
+
const validationScore = validation.valid ? 100 :
|
|
162
|
+
Math.max(0, 100 - (validation.criticalIssues * 20) - (validation.totalIssues * 5));
|
|
163
|
+
|
|
164
|
+
return Math.round((healthScore + validationScore) / 2);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Generate recommendations based on analysis
|
|
169
|
+
*/
|
|
170
|
+
generateRecommendations(health, validation) {
|
|
171
|
+
const recommendations = [];
|
|
172
|
+
|
|
173
|
+
// Health-based recommendations
|
|
174
|
+
if (health.breakdown.coverage.status !== HEALTH_STATUS.HEALTHY) {
|
|
175
|
+
recommendations.push({
|
|
176
|
+
type: 'coverage',
|
|
177
|
+
priority: 'high',
|
|
178
|
+
message: 'Increase test coverage to improve project health',
|
|
179
|
+
currentScore: health.breakdown.coverage.score
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (health.breakdown.constitutional.status !== HEALTH_STATUS.HEALTHY) {
|
|
184
|
+
recommendations.push({
|
|
185
|
+
type: 'constitutional',
|
|
186
|
+
priority: 'high',
|
|
187
|
+
message: 'Review constitutional compliance for all articles',
|
|
188
|
+
currentScore: health.breakdown.constitutional.score
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Validation-based recommendations
|
|
193
|
+
if (validation.gaps.gapCount > 0) {
|
|
194
|
+
recommendations.push({
|
|
195
|
+
type: 'gaps',
|
|
196
|
+
priority: validation.gaps.criticalGaps > 0 ? 'critical' : 'medium',
|
|
197
|
+
message: `Address ${validation.gaps.gapCount} specification gaps`,
|
|
198
|
+
details: validation.gaps.gaps.slice(0, 5)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (validation.traceability.coverage < 80) {
|
|
203
|
+
recommendations.push({
|
|
204
|
+
type: 'traceability',
|
|
205
|
+
priority: 'medium',
|
|
206
|
+
message: 'Improve traceability coverage between artifacts',
|
|
207
|
+
currentCoverage: validation.traceability.coverage
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return recommendations;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Validate steering files
|
|
216
|
+
* @param {Object} files - Map of file name to content
|
|
217
|
+
* @returns {Object}
|
|
218
|
+
*/
|
|
219
|
+
validateSteering(files) {
|
|
220
|
+
const results = {};
|
|
221
|
+
|
|
222
|
+
for (const [name, content] of Object.entries(files)) {
|
|
223
|
+
results[name] = this.steeringValidator.validateFile(content, name);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const overallValid = Object.values(results).every(r => r.valid);
|
|
227
|
+
const avgScore = Object.values(results).reduce((sum, r) => sum + r.score, 0) / Object.keys(results).length;
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
valid: overallValid,
|
|
231
|
+
files: results,
|
|
232
|
+
avgScore: Math.round(avgScore),
|
|
233
|
+
timestamp: new Date().toISOString()
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Validate template content
|
|
239
|
+
* @param {string} content
|
|
240
|
+
* @param {string} templateId
|
|
241
|
+
* @returns {Object}
|
|
242
|
+
*/
|
|
243
|
+
validateTemplate(content, templateId) {
|
|
244
|
+
return this.templateConstraints.validate(content, templateId);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Get comprehensive status
|
|
249
|
+
* @returns {Object}
|
|
250
|
+
*/
|
|
251
|
+
getStatus() {
|
|
252
|
+
return {
|
|
253
|
+
status: this.status,
|
|
254
|
+
components: {
|
|
255
|
+
steeringAutoUpdate: {
|
|
256
|
+
rules: this.steeringAutoUpdate.rules?.length ?? 0,
|
|
257
|
+
history: this.steeringAutoUpdate.updateHistory?.length ?? 0
|
|
258
|
+
},
|
|
259
|
+
steeringValidator: {
|
|
260
|
+
rules: this.steeringValidator.rules?.size ?? 0,
|
|
261
|
+
history: this.steeringValidator.history?.length ?? 0
|
|
262
|
+
},
|
|
263
|
+
templateConstraints: {
|
|
264
|
+
templates: Object.keys(this.templateConstraints.templates).length,
|
|
265
|
+
history: this.templateConstraints.validationHistory?.length ?? 0
|
|
266
|
+
},
|
|
267
|
+
qualityDashboard: {
|
|
268
|
+
metrics: this.qualityDashboard.metrics?.size ?? 0,
|
|
269
|
+
history: this.qualityDashboard.history?.length ?? 0
|
|
270
|
+
},
|
|
271
|
+
advancedValidation: {
|
|
272
|
+
artifacts: this.advancedValidation.artifacts?.size ?? 0,
|
|
273
|
+
links: this.advancedValidation.countLinks?.() ?? 0
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
timestamp: new Date().toISOString()
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Generate comprehensive report
|
|
282
|
+
* @returns {string}
|
|
283
|
+
*/
|
|
284
|
+
generateReport() {
|
|
285
|
+
const status = this.getStatus();
|
|
286
|
+
const health = this.qualityDashboard.getHealthSummary();
|
|
287
|
+
|
|
288
|
+
let report = `# Phase 5 Integration Report\n\n`;
|
|
289
|
+
report += `Generated: ${new Date().toISOString()}\n\n`;
|
|
290
|
+
|
|
291
|
+
// Status
|
|
292
|
+
report += `## Status\n\n`;
|
|
293
|
+
report += `Integration Status: **${status.status}**\n\n`;
|
|
294
|
+
|
|
295
|
+
// Health Summary
|
|
296
|
+
report += `## Project Health\n\n`;
|
|
297
|
+
report += `| Metric | Score | Status |\n`;
|
|
298
|
+
report += `|--------|-------|--------|\n`;
|
|
299
|
+
report += `| Overall | ${health.overall.toFixed(1)}% | ${health.status} |\n`;
|
|
300
|
+
report += `| Coverage | ${health.breakdown.coverage.score.toFixed(1)}% | ${health.breakdown.coverage.status} |\n`;
|
|
301
|
+
report += `| Constitutional | ${health.breakdown.constitutional.score.toFixed(1)}% | ${health.breakdown.constitutional.status} |\n`;
|
|
302
|
+
report += `| Quality | ${health.breakdown.quality.score.toFixed(1)}% | ${health.breakdown.quality.status} |\n\n`;
|
|
303
|
+
|
|
304
|
+
// Component Summary
|
|
305
|
+
report += `## Components\n\n`;
|
|
306
|
+
report += `| Component | Metric | Value |\n`;
|
|
307
|
+
report += `|-----------|--------|-------|\n`;
|
|
308
|
+
report += `| Steering Auto-Update | Rules | ${status.components.steeringAutoUpdate.rules} |\n`;
|
|
309
|
+
report += `| Steering Validator | Rules | ${status.components.steeringValidator.rules} |\n`;
|
|
310
|
+
report += `| Template Constraints | Templates | ${status.components.templateConstraints.templates} |\n`;
|
|
311
|
+
report += `| Quality Dashboard | Metrics | ${status.components.qualityDashboard.metrics} |\n`;
|
|
312
|
+
report += `| Advanced Validation | Artifacts | ${status.components.advancedValidation.artifacts} |\n\n`;
|
|
313
|
+
|
|
314
|
+
// Traceability
|
|
315
|
+
const traceReport = this.advancedValidation.exportMatrix();
|
|
316
|
+
report += traceReport;
|
|
317
|
+
|
|
318
|
+
return report;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Reset all components
|
|
323
|
+
*/
|
|
324
|
+
reset() {
|
|
325
|
+
this.steeringAutoUpdate.clearHistory?.();
|
|
326
|
+
this.steeringValidator.history = [];
|
|
327
|
+
this.templateConstraints.clearHistory();
|
|
328
|
+
this.qualityDashboard.clear();
|
|
329
|
+
this.advancedValidation.clear();
|
|
330
|
+
this.thinkingChecklist.reset();
|
|
331
|
+
|
|
332
|
+
this.status = INTEGRATION_STATUS.READY;
|
|
333
|
+
this.emit('reset');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Start monitoring
|
|
338
|
+
*/
|
|
339
|
+
start() {
|
|
340
|
+
this.qualityDashboard.startAutoCollection();
|
|
341
|
+
this.status = INTEGRATION_STATUS.RUNNING;
|
|
342
|
+
this.emit('started');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Stop monitoring
|
|
347
|
+
*/
|
|
348
|
+
stop() {
|
|
349
|
+
this.qualityDashboard.stopAutoCollection();
|
|
350
|
+
this.status = INTEGRATION_STATUS.STOPPED;
|
|
351
|
+
this.emit('stopped');
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Factory function
|
|
357
|
+
*/
|
|
358
|
+
function createPhase5Integration(options = {}) {
|
|
359
|
+
return new Phase5Integration(options);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
module.exports = {
|
|
363
|
+
// Main integration
|
|
364
|
+
Phase5Integration,
|
|
365
|
+
createPhase5Integration,
|
|
366
|
+
INTEGRATION_STATUS,
|
|
367
|
+
|
|
368
|
+
// Re-export Sprint 5.1
|
|
369
|
+
SteeringAutoUpdate,
|
|
370
|
+
createSteeringAutoUpdate,
|
|
371
|
+
TRIGGER,
|
|
372
|
+
STEERING_TYPE,
|
|
373
|
+
|
|
374
|
+
// Re-export Sprint 5.1 validator
|
|
375
|
+
SteeringValidator,
|
|
376
|
+
createSteeringValidator,
|
|
377
|
+
SEVERITY,
|
|
378
|
+
RULE_TYPE,
|
|
379
|
+
|
|
380
|
+
// Re-export Sprint 5.2
|
|
381
|
+
TemplateConstraints,
|
|
382
|
+
ThinkingChecklist,
|
|
383
|
+
createTemplateConstraints,
|
|
384
|
+
createThinkingChecklist,
|
|
385
|
+
CONSTRAINT_TYPE,
|
|
386
|
+
UNCERTAINTY,
|
|
387
|
+
MARKER_TYPE,
|
|
388
|
+
|
|
389
|
+
// Re-export Sprint 5.3
|
|
390
|
+
QualityDashboard,
|
|
391
|
+
createQualityDashboard,
|
|
392
|
+
METRIC_CATEGORY,
|
|
393
|
+
HEALTH_STATUS,
|
|
394
|
+
CONSTITUTIONAL_ARTICLES,
|
|
395
|
+
|
|
396
|
+
// Re-export Sprint 5.4
|
|
397
|
+
AdvancedValidation,
|
|
398
|
+
createAdvancedValidation,
|
|
399
|
+
VALIDATION_TYPE,
|
|
400
|
+
ARTIFACT_TYPE,
|
|
401
|
+
GAP_SEVERITY
|
|
402
|
+
};
|