mcp-adr-analysis-server
Version:
MCP server for analyzing Architectural Decision Records and project architecture
234 lines • 8.34 kB
TypeScript
/**
* Prompt Composition Utilities for 100% Prompt-Driven Architecture
*
* This module provides standardized utilities for composing prompts and implementing
* AI delegation patterns across the MCP ADR Analysis Server.
*/
export interface PromptObject {
prompt: string;
instructions: string;
context: any;
}
export interface CombinedPrompt {
prompt: string;
instructions: string;
context: any;
metadata: {
sourcePrompts: number;
combinedAt: string;
totalLength: number;
};
}
export interface AIDelegationPrompt {
task: string;
instructions: string;
requirements: string[];
outputFormat: string;
context?: any;
}
export interface JSONSchemaSpec {
type: 'object' | 'array' | 'string' | 'number' | 'boolean';
properties?: Record<string, any>;
items?: any;
required?: string[];
description?: string;
}
export interface PromptValidationResult {
isValid: boolean;
errors: string[];
warnings: string[];
suggestions: string[];
}
/**
* Combine multiple prompt objects into a single comprehensive prompt
*/
export declare function combinePrompts(...prompts: PromptObject[]): CombinedPrompt;
/**
* Create a standardized AI delegation prompt for specific tasks
*/
export declare function createAIDelegationPrompt(task: string, requirements: string[], outputFormat: string, context?: any): AIDelegationPrompt;
/**
* Add JSON schema specification to a prompt for structured responses
*/
export declare function addJSONSchema(prompt: string, schema: JSONSchemaSpec): string;
/**
* Validate AI response against expected format and requirements
*/
export declare function validatePromptResponse(response: string, expectedFormat: 'json' | 'markdown' | 'text', requirements?: string[]): PromptValidationResult;
/**
* Create a file analysis prompt with standardized structure
*/
export declare function createFileAnalysisPrompt(filePaths: string[], analysisType: string, outputSchema?: JSONSchemaSpec): string;
/**
* Create a project structure analysis prompt
*/
export declare function createProjectStructurePrompt(projectPath: string, includePatterns?: string[], excludePatterns?: string[]): string;
/**
* Escape special characters in prompts for safe processing
*/
export declare function escapePromptContent(content: string): string;
/**
* Truncate prompt content to specified length while preserving structure
*/
export declare function truncatePrompt(prompt: string, maxLength: number): string;
/**
* Extract metadata from prompt responses
*/
export declare function extractResponseMetadata(response: string): {
wordCount: number;
lineCount: number;
hasCodeBlocks: boolean;
hasLists: boolean;
estimatedReadingTime: number;
};
/**
* Example: Combining multiple prompts for comprehensive analysis
*/
export declare function createComprehensiveAnalysisPrompt(projectPrompt: PromptObject, filePrompt: PromptObject, additionalRequirements?: string[]): CombinedPrompt;
/**
* Example: Creating a standardized ADR analysis prompt
*/
export declare function createADRAnalysisPrompt(adrDirectory: string, analysisType: 'structure' | 'content' | 'relationships' | 'compliance'): AIDelegationPrompt;
/**
* Common JSON schemas for MCP responses
*/
export declare const CommonSchemas: {
readonly adrList: {
readonly type: "object";
readonly properties: {
readonly adrs: {
readonly type: "array";
readonly items: {
readonly type: "object";
readonly properties: {
readonly id: {
readonly type: "string";
};
readonly title: {
readonly type: "string";
};
readonly status: {
readonly type: "string";
};
readonly date: {
readonly type: "string";
};
readonly filePath: {
readonly type: "string";
};
};
readonly required: readonly ["id", "title", "status", "date", "filePath"];
};
};
readonly summary: {
readonly type: "object";
readonly properties: {
readonly total: {
readonly type: "number";
};
readonly byStatus: {
readonly type: "object";
};
};
};
};
readonly required: readonly ["adrs", "summary"];
};
readonly fileAnalysis: {
readonly type: "object";
readonly properties: {
readonly files: {
readonly type: "array";
readonly items: {
readonly type: "object";
readonly properties: {
readonly path: {
readonly type: "string";
};
readonly type: {
readonly type: "string";
};
readonly size: {
readonly type: "number";
};
readonly analysis: {
readonly type: "object";
};
};
readonly required: readonly ["path", "type", "analysis"];
};
};
readonly summary: {
readonly type: "object";
readonly properties: {
readonly totalFiles: {
readonly type: "number";
};
readonly fileTypes: {
readonly type: "object";
};
readonly insights: {
readonly type: "array";
readonly items: {
readonly type: "string";
};
};
};
};
};
readonly required: readonly ["files", "summary"];
};
readonly projectStructure: {
readonly type: "object";
readonly properties: {
readonly structure: {
readonly type: "object";
readonly properties: {
readonly directories: {
readonly type: "array";
readonly items: {
readonly type: "string";
};
};
readonly files: {
readonly type: "array";
readonly items: {
readonly type: "string";
};
};
readonly totalFiles: {
readonly type: "number";
};
readonly totalDirectories: {
readonly type: "number";
};
};
};
readonly analysis: {
readonly type: "object";
readonly properties: {
readonly patterns: {
readonly type: "array";
readonly items: {
readonly type: "string";
};
};
readonly technologies: {
readonly type: "array";
readonly items: {
readonly type: "string";
};
};
readonly recommendations: {
readonly type: "array";
readonly items: {
readonly type: "string";
};
};
};
};
};
readonly required: readonly ["structure", "analysis"];
};
};
//# sourceMappingURL=prompt-composition.d.ts.map