mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing professional tools, resources, and prompts for implementing AI agent best practices
133 lines • 5.07 kB
JavaScript
// Phase Management Service - Handles design phase workflow operations
import { confirmationModule } from "../confirmation-module.js";
import { coverageEnforcer } from "../coverage-enforcer.js";
import { designPhaseWorkflow } from "../design-phase-workflow.js";
import { pivotModule } from "../pivot-module.js";
class PhaseManagementServiceImpl {
async advancePhase(sessionId, content, targetPhaseId) {
const sessionState = designPhaseWorkflow.getSession(sessionId);
if (!sessionState) {
return {
success: false,
sessionId,
status: "error",
message: `Session ${sessionId} not found`,
recommendations: ["Start a new session"],
artifacts: [],
};
}
// Validate current phase if content is provided
let validationResults;
if (content) {
validationResults = await confirmationModule.confirmPhaseCompletion({
sessionState,
phaseId: sessionState.currentPhase,
content,
autoAdvance: false,
});
if (!validationResults.canProceed) {
return {
success: false,
sessionId,
currentPhase: sessionState.currentPhase,
status: "validation-failed",
message: "Current phase validation failed",
recommendations: validationResults.recommendations,
artifacts: [],
validationResults,
};
}
}
// Advance to next phase
const workflowResult = await designPhaseWorkflow.executeWorkflow({
action: "advance",
sessionId,
phaseId: targetPhaseId,
content,
});
// Check for pivot recommendation
let pivotDecision;
if (content) {
pivotDecision = await pivotModule.evaluatePivotNeed({
sessionState: workflowResult.sessionState,
currentContent: content,
});
}
return {
success: workflowResult.success,
sessionId,
currentPhase: workflowResult.currentPhase,
nextPhase: workflowResult.nextPhase,
coverage: validationResults?.coverage,
status: workflowResult.success ? "advanced" : "failed",
message: workflowResult.message,
recommendations: [
...workflowResult.recommendations,
...(pivotDecision?.triggered
? [`⚠️ ${pivotDecision.recommendation}`]
: []),
],
artifacts: workflowResult.artifacts,
validationResults,
pivotDecision,
};
}
async validatePhase(sessionId, phaseId, content) {
const sessionState = designPhaseWorkflow.getSession(sessionId);
if (!sessionState) {
return {
success: false,
sessionId,
status: "error",
message: `Session ${sessionId} not found`,
recommendations: ["Start a new session"],
artifacts: [],
};
}
// Perform comprehensive validation
const validationResults = await confirmationModule.confirmPhaseCompletion({
sessionState,
phaseId,
content,
strictMode: true,
});
const coverageResult = await coverageEnforcer.enforceCoverage({
sessionState,
content,
enforceThresholds: true,
});
const recommendations = [
...validationResults.recommendations,
...coverageResult.recommendations,
];
return {
success: validationResults.passed && coverageResult.passed,
sessionId,
currentPhase: sessionState.currentPhase,
coverage: validationResults.coverage,
status: validationResults.passed ? "validated" : "validation-failed",
message: validationResults.passed
? `Phase ${phaseId} validation successful`
: `Phase ${phaseId} validation failed`,
recommendations: [...new Set(recommendations)], // Remove duplicates
artifacts: [],
validationResults,
coverageReport: coverageResult,
};
}
async getPhaseGuidance(_sessionState, phaseId) {
return [
`Focus on ${phaseId} key criteria`,
"Engage stakeholders",
"Document decisions",
];
}
async getPhaseSequence() {
return designPhaseWorkflow.getPhaseSequence();
}
}
// Export singleton instance
export const phaseManagementService = new PhaseManagementServiceImpl();
// Module Implementation Status Sentinel
export const IMPLEMENTATION_STATUS = "IMPLEMENTED";
//# sourceMappingURL=phase-management.service.js.map