/** * 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, RenderOptions } from "./output-strategy.js"; import { OutputApproach } from "./output-strategy.js"; import { BaseStrategy } from "./shared/base-strategy.js"; import type { ValidationResult } from "./shared/types.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; config?: { goal?: string; context?: Record; requirements?: unknown; }; artifacts?: Record; 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 * * @extends {BaseStrategy} */ export declare class ADRStrategy extends BaseStrategy { protected readonly name = "adr"; protected readonly version = "2.0.0"; /** The output approach this strategy implements */ readonly approach = OutputApproach.ADR; /** * Validate that the input is a supported domain result type. * * @param input - Input to validate * @returns Validation result */ validate(input: ADRSessionState | PromptResult): ValidationResult; /** * Execute the ADR rendering strategy. * * @param input - The domain result to render * @returns Output artifacts with primary ADR document */ execute(input: ADRSessionState | PromptResult, options?: Partial): Promise; /** * 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