Title
Implement Enhanced System Prompt Management with Multi-Component Architecture and
Runtime Customization
Summary
Replace the current monolithic system prompt with a flexible, multi-component
architecture that allows users to define custom prompt components, manage
priorities, and customize system behavior while preserving the existing prompt as
immutable defaults.
Background
Current State
- Simple Architecture: Single systemPrompt string in cipher.yml (2,608 characters)
- Limited Customization: No way to modify specific prompt sections without affecting
entire prompt
- Static Configuration: Requires restart to change system prompt
- Monolithic Structure: All prompt logic in one block
Current System Prompt Flow
- memAgent/cipher.yml → systemPrompt field
- loadAgentConfig() → YAML parsing + environment expansion
- AgentConfigSchema → String validation
- createAgentServices() → PromptManager.load()
- ContextManager.getSystemPrompt() → Single prompt string
Problems with Current Approach
- Users cannot customize domain-specific instructions without losing core
functionality
- No separation of concerns (memory instructions, personality, domain knowledge)
- Difficult to version and maintain different prompt variations
- No runtime management capabilities
- Cannot enable/disable specific prompt features
Proposed Solution
Multi-Component Architecture
Transform the current monolithic prompt into a structured, priority-based component
system:
interface PromptComponent {
name: string; // Unique identifier
priority: number; // 0-1000 (higher = more important)
content: string; // Prompt content
enabled: boolean; // Runtime toggle
metadata?: {
category?: 'system' | 'memory' | 'user' | 'domain';
immutable?: boolean; // Cannot be modified
version?: string;
description?: string;
};
}
Enhanced Configuration Schema
Support both backward-compatible string format and new structured format:
Option 1: Simple string (backward compatibility)
systemPrompt: "You are an AI programming assistant..."
Option 2: Advanced multi-component structure
systemPrompt:
prompts:
- name: "core_system"
priority: 1000
content: |
You are an AI programming assistant with advanced memory capabilities.
enabled: true
metadata:
category: "system"
immutable: true
- name: "user_personality"
priority: 500
content: |
Be helpful, concise, and focus on practical solutions.
Always explain your reasoning for complex problems.
enabled: true
metadata:
category: "user"
customizable: true
- name: "domain_specific"
priority: 300
content: |
For this TypeScript project, prioritize type safety and performance.
Suggest efficient implementation patterns.
enabled: false
metadata:
category: "domain"
settings:
merge_strategy: "priority_order"
separator: "\n\n"
max_length: 8000
truncate_strategy: "lowest_priority"
Key Features
- Backward Compatibility
- Existing cipher.yml configurations work unchanged
- Automatic migration from string to structured format
- Graceful degradation when new features fail
- Zero-downtime deployment
- Immutable System Components
- Core system prompt preserved as default components
- Components marked as immutable: true cannot be modified
- Automatic restoration of corrupted immutable components
- Version tracking for system components
- Flexible User Customization
- Add domain-specific prompt components
- Enable/disable components based on context
- Adjust priorities for component ordering
- Session-specific customization
- Runtime Management
- Modify components without system restart
- Real-time validation and preview
- Component library and preset management
- Import/export configurations
- Performance Optimization
- Intelligent prompt composition caching
- Lazy evaluation of component changes
- Memory-efficient component storage
- Fast validation and error handling
- Comprehensive Validation
- Schema validation for all configurations
- Runtime validation for component operations
- Clear error messages and warnings
- Conflict detection and resolution
Title
Implement Enhanced System Prompt Management with Multi-Component Architecture and
Runtime Customization
Summary
Replace the current monolithic system prompt with a flexible, multi-component
architecture that allows users to define custom prompt components, manage
priorities, and customize system behavior while preserving the existing prompt as
immutable defaults.
Background
Current State
entire prompt
Current System Prompt Flow
Problems with Current Approach
functionality
Proposed Solution
Multi-Component Architecture
Transform the current monolithic prompt into a structured, priority-based component
system:
interface PromptComponent {
name: string; // Unique identifier
priority: number; // 0-1000 (higher = more important)
content: string; // Prompt content
enabled: boolean; // Runtime toggle
metadata?: {
category?: 'system' | 'memory' | 'user' | 'domain';
immutable?: boolean; // Cannot be modified
version?: string;
description?: string;
};
}
Enhanced Configuration Schema
Support both backward-compatible string format and new structured format:
Option 1: Simple string (backward compatibility)
systemPrompt: "You are an AI programming assistant..."
Option 2: Advanced multi-component structure
systemPrompt:
prompts:
- name: "core_system"
priority: 1000
content: |
You are an AI programming assistant with advanced memory capabilities.
enabled: true
metadata:
category: "system"
immutable: true
Key Features