mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
600 lines (517 loc) • 19.3 kB
JavaScript
/**
* TOGAFStrategy - TOGAF enterprise architecture documentation format
*
* Renders domain results as TOGAF (The Open Group Architecture Framework)
* enterprise architecture deliverables following the TOGAF ADM (Architecture
* Development Method) phases.
*
* @module strategies/togaf-strategy
* @see {@link https://www.opengroup.org/togaf TOGAF Standard}
* @see {@link https://github.com/Anselmoo/mcp-ai-agent-guidelines/blob/development/plan-v0.13.x/specs/SPEC-001-output-strategy-layer.md SPEC-001} §4.6
*/
import { OutputApproach } from "./output-strategy.js";
/**
* TOGAFStrategy implements the TOGAF enterprise architecture document format.
*
* Generates comprehensive TOGAF ADM phase deliverables:
* - Primary: Architecture Vision Document
* - Secondary: Business, Data, Application, Technology Architectures, Migration Plan
*
* Supports rendering:
* - SessionState: Design workflow to TOGAF deliverables
*
* @implements {OutputStrategy<SessionState>}
*/
export class TOGAFStrategy {
/** The output approach this strategy implements */
approach = OutputApproach.TOGAF;
/**
* Render a domain result to TOGAF format artifacts.
*
* @param result - The session state to render
* @param options - Optional rendering options
* @returns Output artifacts with primary Architecture Vision and secondary TOGAF documents
* @throws {Error} If result type is not supported
*/
render(result, options) {
if (!this.isSessionState(result)) {
throw new Error("Unsupported domain result type for TOGAFStrategy");
}
return {
primary: this.generateArchitectureVision(result, options),
secondary: [
this.generateBusinessArchitecture(result),
this.generateDataArchitecture(result),
this.generateApplicationArchitecture(result),
this.generateTechnologyArchitecture(result),
this.generateMigrationPlan(result),
],
};
}
/**
* Check if this strategy supports rendering a specific domain type.
*
* @param domainType - The domain type identifier
* @returns True if this strategy can render the domain type
*/
supports(domainType) {
return ["SessionState"].includes(domainType);
}
/**
* Generate Architecture Vision Document (TOGAF Phase A).
*
* The Architecture Vision provides executive summary, business goals,
* stakeholder map, high-level architecture, and risk assessment.
*
* @param result - The session state
* @param options - Optional rendering options
* @returns Architecture Vision document
* @private
*/
generateArchitectureVision(result, options) {
const content = `# Architecture Vision Document
## Executive Summary
${this.extractExecutiveSummary(result)}
## Request for Architecture Work
${this.extractRequestForWork(result)}
## Business Goals and Drivers
${this.extractBusinessGoals(result)}
## Architecture Principles
${this.extractPrinciples(result)}
## Stakeholder Map
${this.extractStakeholders(result)}
## High-Level Architecture
${this.extractHighLevelArchitecture(result)}
## Risk Assessment
${this.extractRisks(result)}
## Architecture Repository
${this.extractArchitectureRepository(result)}
${this.formatFooter(options)}`;
return {
name: "architecture-vision.md",
content: content.trim(),
format: "markdown",
};
}
/**
* Generate Business Architecture Document (TOGAF Phase B).
*
* Documents business processes, organizational structure, and
* business capabilities.
*
* @param result - The session state
* @returns Business Architecture document
* @private
*/
generateBusinessArchitecture(result) {
const content = `# Business Architecture
## Business Strategy
${this.extractBusinessStrategy(result)}
## Organization Structure
${this.extractOrganizationStructure(result)}
## Business Capabilities
${this.extractBusinessCapabilities(result)}
## Business Processes
${this.extractBusinessProcesses(result)}
## Business Services
${this.extractBusinessServices(result)}
## Information Concepts
${this.extractInformationConcepts(result)}
---
*TOGAF Phase B: Business Architecture*`;
return {
name: "business-architecture.md",
content: content.trim(),
format: "markdown",
};
}
/**
* Generate Data Architecture Document (TOGAF Phase C - Data).
*
* Documents data entities, data models, and data governance.
*
* @param result - The session state
* @returns Data Architecture document
* @private
*/
generateDataArchitecture(result) {
const content = `# Data Architecture
## Data Principles
${this.extractDataPrinciples(result)}
## Logical Data Model
${this.extractLogicalDataModel(result)}
## Physical Data Model
${this.extractPhysicalDataModel(result)}
## Data Entities
${this.extractDataEntities(result)}
## Data Governance
${this.extractDataGovernance(result)}
## Data Security
${this.extractDataSecurity(result)}
---
*TOGAF Phase C: Data Architecture*`;
return {
name: "data-architecture.md",
content: content.trim(),
format: "markdown",
};
}
/**
* Generate Application Architecture Document (TOGAF Phase C - Application).
*
* Documents application portfolio, application services, and integrations.
*
* @param result - The session state
* @returns Application Architecture document
* @private
*/
generateApplicationArchitecture(result) {
const content = `# Application Architecture
## Application Portfolio
${this.extractApplicationPortfolio(result)}
## Application Services
${this.extractApplicationServices(result)}
## Application Integrations
${this.extractApplicationIntegrations(result)}
## Application Interfaces
${this.extractApplicationInterfaces(result)}
## Application Deployment
${this.extractApplicationDeployment(result)}
---
*TOGAF Phase C: Application Architecture*`;
return {
name: "application-architecture.md",
content: content.trim(),
format: "markdown",
};
}
/**
* Generate Technology Architecture Document (TOGAF Phase D).
*
* Documents infrastructure, platforms, and technology standards.
*
* @param result - The session state
* @returns Technology Architecture document
* @private
*/
generateTechnologyArchitecture(result) {
const content = `# Technology Architecture
## Technology Principles
${this.extractTechnologyPrinciples(result)}
## Infrastructure Architecture
${this.extractInfrastructureArchitecture(result)}
## Platform Services
${this.extractPlatformServices(result)}
## Technology Standards
${this.extractTechnologyStandards(result)}
## Network Architecture
${this.extractNetworkArchitecture(result)}
## Security Architecture
${this.extractSecurityArchitecture(result)}
---
*TOGAF Phase D: Technology Architecture*`;
return {
name: "technology-architecture.md",
content: content.trim(),
format: "markdown",
};
}
/**
* Generate Migration Plan Document (TOGAF Phase E-F).
*
* Documents migration strategy, transition architecture, and
* implementation roadmap.
*
* @param result - The session state
* @returns Migration Plan document
* @private
*/
generateMigrationPlan(result) {
const content = `# Migration Plan
## Migration Strategy
${this.extractMigrationStrategy(result)}
## Transition Architecture
${this.extractTransitionArchitecture(result)}
## Implementation Roadmap
${this.extractImplementationRoadmap(result)}
## Work Packages
${this.extractWorkPackages(result)}
## Dependencies
${this.extractDependencies(result)}
## Risk Mitigation
${this.extractRiskMitigation(result)}
## Success Metrics
${this.extractSuccessMetrics(result)}
---
*TOGAF Phase E-F: Migration Planning*`;
return {
name: "migration-plan.md",
content: content.trim(),
format: "markdown",
};
}
// Extraction methods for Architecture Vision
extractExecutiveSummary(result) {
if (result.config?.goal) {
return `This architecture initiative focuses on: ${result.config.goal}
**Current Phase:** ${result.phase}
**Status:** ${result.status || "In Progress"}`;
}
return "Executive summary to be documented.";
}
extractRequestForWork(result) {
const parts = [];
if (result.config?.goal) {
parts.push(`**Objective:** ${result.config.goal}`);
}
if (result.config?.requirements &&
Array.isArray(result.config.requirements)) {
parts.push(`\n**Requirements:**`);
for (const req of result.config.requirements) {
parts.push(`- ${req}`);
}
}
return parts.length > 0
? parts.join("\n")
: "Request for Architecture Work to be defined.";
}
extractBusinessGoals(result) {
if (result.context && typeof result.context === "object") {
const context = result.context;
if (context.businessGoals && Array.isArray(context.businessGoals)) {
return context.businessGoals
.map((goal) => `- ${goal}`)
.join("\n");
}
if (context.goals && Array.isArray(context.goals)) {
return context.goals.map((goal) => `- ${goal}`).join("\n");
}
}
return "Business goals to be identified with stakeholders.";
}
extractPrinciples(result) {
if (result.context && typeof result.context === "object") {
const context = result.context;
if (context.principles && Array.isArray(context.principles)) {
return context.principles.map((p) => `- ${p}`).join("\n");
}
}
return `- **Principle 1:** Follow industry best practices
- **Principle 2:** Ensure scalability and maintainability
- **Principle 3:** Prioritize security and compliance`;
}
extractStakeholders(result) {
if (result.context && typeof result.context === "object") {
const context = result.context;
if (context.stakeholders && Array.isArray(context.stakeholders)) {
return context.stakeholders.map((s) => `- ${s}`).join("\n");
}
}
return `- **Business Sponsor:** TBD
- **Architecture Team:** TBD
- **Development Teams:** TBD
- **Operations Team:** TBD`;
}
extractHighLevelArchitecture(result) {
if (result.phases && typeof result.phases === "object") {
const phases = Object.entries(result.phases)
.map(([phase, data]) => `### ${phase}\n\n${this.formatPhaseData(data)}`)
.join("\n\n");
return phases || "High-level architecture to be defined.";
}
return "High-level architecture to be defined.";
}
extractRisks(result) {
if (result.context && typeof result.context === "object") {
const context = result.context;
if (context.risks && Array.isArray(context.risks)) {
return context.risks.map((r) => `- ${r}`).join("\n");
}
}
return `- **Risk:** Technical complexity
- **Mitigation:** Incremental implementation
- **Risk:** Resource constraints
- **Mitigation:** Phased approach with clear priorities`;
}
extractArchitectureRepository(result) {
if (result.artifacts && typeof result.artifacts === "object") {
const artifacts = Object.entries(result.artifacts)
.map(([name, _data]) => `- ${name}`)
.join("\n");
return artifacts || "Architecture artifacts to be stored in repository.";
}
return "Architecture artifacts to be stored in repository.";
}
// Extraction methods for Business Architecture
extractBusinessStrategy(result) {
if (result.config?.goal) {
return `The business strategy aligns with: ${result.config.goal}`;
}
return "Business strategy to be documented.";
}
extractOrganizationStructure(_result) {
return "Organization structure and team topology to be defined.";
}
extractBusinessCapabilities(result) {
if (result.context && typeof result.context === "object") {
const context = result.context;
if (context.capabilities && Array.isArray(context.capabilities)) {
return context.capabilities.map((c) => `- ${c}`).join("\n");
}
}
return "Business capabilities to be mapped.";
}
extractBusinessProcesses(_result) {
return "Key business processes to be documented.";
}
extractBusinessServices(_result) {
return "Business services and their interactions to be defined.";
}
extractInformationConcepts(_result) {
return "Core information concepts and their relationships to be identified.";
}
// Extraction methods for Data Architecture
extractDataPrinciples(_result) {
return `- Data is a strategic asset
- Data quality is paramount
- Data governance is mandatory
- Data security and privacy by design`;
}
extractLogicalDataModel(_result) {
return "Logical data model to be developed showing key entities and relationships.";
}
extractPhysicalDataModel(_result) {
return "Physical data model to be developed with implementation details.";
}
extractDataEntities(_result) {
return "Core data entities to be identified and documented.";
}
extractDataGovernance(_result) {
return `- **Data Ownership:** Define data stewards and owners
- **Data Quality:** Establish quality metrics and monitoring
- **Data Lifecycle:** Define retention and archival policies
- **Data Access:** Implement access control and auditing`;
}
extractDataSecurity(_result) {
return `- **Encryption:** At rest and in transit
- **Access Control:** Role-based access control (RBAC)
- **Auditing:** Comprehensive audit logging
- **Compliance:** GDPR, HIPAA, SOC2 as applicable`;
}
// Extraction methods for Application Architecture
extractApplicationPortfolio(_result) {
return "Application portfolio and rationalization to be documented.";
}
extractApplicationServices(_result) {
return "Application services and their capabilities to be defined.";
}
extractApplicationIntegrations(_result) {
return "Application integration patterns and interfaces to be specified.";
}
extractApplicationInterfaces(_result) {
return "Application interfaces and API contracts to be documented.";
}
extractApplicationDeployment(_result) {
return "Application deployment architecture and patterns to be defined.";
}
// Extraction methods for Technology Architecture
extractTechnologyPrinciples(_result) {
return `- Use proven, industry-standard technologies
- Prefer cloud-native and containerized solutions
- Automate infrastructure provisioning
- Implement infrastructure as code`;
}
extractInfrastructureArchitecture(_result) {
return "Infrastructure architecture including compute, storage, and network to be defined.";
}
extractPlatformServices(_result) {
return "Platform services and middleware to be specified.";
}
extractTechnologyStandards(_result) {
return "Technology standards and approved technology stack to be documented.";
}
extractNetworkArchitecture(_result) {
return "Network architecture including security zones and connectivity to be designed.";
}
extractSecurityArchitecture(_result) {
return `- **Identity & Access:** Authentication and authorization strategy
- **Network Security:** Firewalls, segmentation, DDoS protection
- **Application Security:** SAST, DAST, dependency scanning
- **Monitoring:** SIEM, security monitoring, incident response`;
}
// Extraction methods for Migration Plan
extractMigrationStrategy(result) {
return `Migration approach: Phased implementation with pilot programs and gradual rollout.
**Strategy:** ${result.status === "completed" ? "Complete" : "In Progress"}`;
}
extractTransitionArchitecture(_result) {
return "Transition architecture states from current to target architecture to be defined.";
}
extractImplementationRoadmap(result) {
if (result.phases && typeof result.phases === "object") {
const roadmap = Object.entries(result.phases)
.map(([phase, data], index) => {
return `### Phase ${index + 1}: ${phase}\n\n${this.formatPhaseData(data)}`;
})
.join("\n\n");
return roadmap || "Implementation roadmap to be developed.";
}
return "Implementation roadmap to be developed.";
}
extractWorkPackages(_result) {
return "Work packages and project organization to be defined.";
}
extractDependencies(result) {
if (result.context && typeof result.context === "object") {
const context = result.context;
if (context.dependencies && Array.isArray(context.dependencies)) {
return context.dependencies.map((d) => `- ${d}`).join("\n");
}
}
return "Dependencies and constraints to be identified.";
}
extractRiskMitigation(_result) {
return `Risk mitigation strategies:
- Regular checkpoints and course correction
- Incremental delivery with feedback loops
- Fallback and rollback procedures`;
}
extractSuccessMetrics(_result) {
return `Key performance indicators:
- **Technical:** System performance, reliability, scalability
- **Business:** Time to market, cost reduction, user satisfaction
- **Operational:** Deployment frequency, MTTR, change failure rate`;
}
// Helper methods
formatPhaseData(data) {
if (typeof data === "string") {
return data;
}
if (typeof data === "object" && data !== null) {
return JSON.stringify(data, null, 2);
}
return String(data);
}
formatFooter(options) {
if (options?.includeMetadata === true) {
return `\n\n---\n*TOGAF Architecture Vision generated: ${new Date().toISOString()}*`;
}
return "";
}
/**
* Type guard for SessionState.
*
* @param result - The value to check
* @returns True if result is a SessionState
* @private
*/
isSessionState(result) {
return (typeof result === "object" &&
result !== null &&
"id" in result &&
"phase" in result &&
"context" in result &&
"history" in result);
}
}
//# sourceMappingURL=togaf-strategy.js.map