UNPKG

mcp-ai-agent-guidelines

Version:

A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices

219 lines 7.3 kB
/** * ADRStrategy - Architecture Decision Record output format * * Renders domain results as Architecture Decision Records (ADRs) following * the Michael Nygard format. This is the industry standard for documenting * architectural decisions with status, context, decision, and consequences. * * @module strategies/adr-strategy * @see {@link https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions Michael Nygard ADR format} * @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.3 */ import type { PromptResult } from "../domain/prompting/types.js"; import type { OutputArtifacts, OutputStrategy, RenderOptions } from "./output-strategy.js"; import { OutputApproach } from "./output-strategy.js"; /** * ADR-specific session state interface for ADR generation. * * This interface is separate from the canonical SessionState from domain/design/types.ts * because ADR generation needs ADR-specific metadata fields (decision, consequences) * that don't exist in the canonical type. The phase field is also simplified to a * string rather than PhaseId enum to support flexible ADR generation contexts. */ interface ADRSessionState { id: string; phase?: string; context?: Record<string, unknown>; config?: { goal?: string; context?: Record<string, unknown>; requirements?: unknown; }; artifacts?: Record<string, unknown>; metadata?: { title?: string; decision?: string; positiveConsequences?: string[]; negativeConsequences?: string[]; neutralConsequences?: string[]; }; } /** * ADRStrategy implements the Architecture Decision Record output format. * * Supports rendering: * - ADRSessionState: Design workflow decisions * - PromptResult: Prompt-based architectural decisions * * ADR Format (Michael Nygard): * - Status: Proposed/Accepted/Deprecated/Superseded * - Context: Background and problem statement * - Decision: The architectural decision made * - Consequences: Split into Positive, Negative, and Neutral * * @implements {OutputStrategy<ADRSessionState | PromptResult>} */ export declare class ADRStrategy implements OutputStrategy<ADRSessionState | PromptResult> { /** The output approach this strategy implements */ readonly approach = OutputApproach.ADR; /** * Render a domain result to ADR format artifacts. * * @param result - The domain result to render (ADRSessionState or PromptResult) * @param options - Optional rendering options * @returns Output artifacts with primary ADR document * @throws {Error} If result type is not supported */ render(result: ADRSessionState | PromptResult, options?: Partial<RenderOptions>): OutputArtifacts; /** * 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: string): boolean; /** * Render a ADRSessionState to ADR format. * * Extracts architectural decision information from design workflow state * and formats it according to Michael Nygard's ADR template. * * @param result - The session state to render * @param options - Optional rendering options * @returns Output artifacts with ADR document * @private */ private renderSessionState; /** * Render a PromptResult to ADR format. * * Converts prompt sections into ADR structure, mapping sections * to ADR template sections (Context, Decision, Consequences). * * @param result - The prompt result to render * @param options - Optional rendering options * @returns Output artifacts with ADR document * @private */ private renderPromptResult; /** * Generate a sequential ADR number. * * Uses timestamp-based generation to create unique ADR numbers. * Format: 4-digit number from last 4 digits of timestamp. * * @returns 4-digit ADR number as string * @private */ private generateAdrNumber; /** * Slugify a title for use in filenames. * * Converts title to lowercase, replaces non-alphanumeric characters * with hyphens, and truncates to 50 characters. * * @param title - The title to slugify * @returns Slugified title suitable for filenames * @private */ private slugify; /** * Extract title from ADRSessionState. * * Looks for title in metadata, config.goal, or uses default. * * @param result - The session state * @returns The extracted title * @private */ private extractTitle; /** * Extract title from PromptResult. * * Uses first section title or metadata if available. * * @param result - The prompt result * @returns The extracted title * @private */ private extractTitleFromPrompt; /** * Extract context from ADRSessionState. * * Builds context section from session context, config, and phase information. * * @param result - The session state * @returns Formatted context description * @private */ private extractContext; /** * Extract decision statement from ADRSessionState. * * Looks for decision in metadata or constructs from goal. * * @param result - The session state * @returns Decision statement * @private */ private extractDecision; /** * Extract positive consequences from ADRSessionState. * * Formats positive consequences as markdown list. * * @param result - The session state * @returns Formatted positive consequences list * @private */ private extractPositiveConsequences; /** * Extract negative consequences from ADRSessionState. * * Formats negative consequences as markdown list. * * @param result - The session state * @returns Formatted negative consequences list * @private */ private extractNegativeConsequences; /** * Extract neutral consequences from ADRSessionState. * * Formats neutral consequences as markdown list. * * @param result - The session state * @returns Formatted neutral consequences list * @private */ private extractNeutralConsequences; /** * Extract references from ADRSessionState. * * Builds references section from artifacts and session metadata. * * @param result - The session state * @param _options - Optional rendering options (unused) * @returns Formatted references list * @private */ private extractReferences; /** * Type guard for ADRSessionState. * * @param result - The value to check * @returns True if result is an ADRSessionState * @private */ private isSessionState; /** * Type guard for PromptResult. * * @param result - The value to check * @returns True if result is a PromptResult * @private */ private isPromptResult; } export {}; //# sourceMappingURL=adr-strategy.d.ts.map