UNPKG

sf-agent-framework

Version:

AI Agent Orchestration Framework for Salesforce Development - Two-phase architecture with 70% context reduction

387 lines (270 loc) 8.1 kB
# Create Document Task v2.0 - Enhanced Template Processing ## Purpose Process enhanced templates with embedded LLM instructions to generate comprehensive documentation. ## Task Configuration ```yaml task: id: create-doc-v2 name: Create Document with Enhanced Templates type: document-generation phase: any agents: all template_version: 2.0 ``` ## How It Works This task orchestrates the creation of documents using the enhanced template system with: - Embedded LLM instructions - Variable substitution - Conditional logic - Section repetition - Automatic validation ## Usage Modes ### 1. Interactive Mode (Default) Agent works with user to gather variables and process template section by section. ```yaml mode: interactive benefits: - User can review and refine each section - Variables can be adjusted during generation - LLM instructions can be modified on the fly ``` ### 2. Rapid Mode Agent processes entire template automatically with provided variables. ```yaml mode: rapid benefits: - Fast document generation - Consistent output - Batch processing capable ``` ## Process Flow ### Step 1: Template Selection ``` Agent: Which template would you like to use? 1. sf-requirements-enhanced - Requirements Document 2. sf-architecture-enhanced - Architecture Document 3. sf-test-plan-enhanced - Test Plan 4. [Browse more templates...] User: 1 ``` ### Step 2: Variable Collection ``` Agent: Let's gather the required variables for this template: Required Variables: - project_name: [Enter project name] - project_type: [enhancement/greenfield/integration/migration] - business_context: [Describe business problem] - stakeholders: [List stakeholders] - target_clouds: [Which Salesforce clouds?] Optional Variables (press Enter to skip): - complexity: [simple/medium/complex] (default: medium) - timeline: [Project timeline] ``` ### Step 3: Template Processing #### Interactive Mode ``` Agent: Processing template section by section... ## Section 1: Executive Summary [LLM Instruction Detected] Generating executive summary based on business context... [Generated Content] The Customer Portal Enhancement project addresses the critical need for improved self-service capabilities... Review this section: 1. Accept and continue 2. Regenerate with modifications 3. Edit manually 4. Skip this section User: 1 ``` #### Rapid Mode ``` Agent: Processing entire template... [======================>] 100% Complete Document generated successfully: - Output: docs/requirements/CustomerPortal-requirements-v1.0.md - Sections: 12/12 processed - LLM Instructions: 18 executed - Validation: Passed ``` ## Template Features ### Variable Substitution ```yaml # In template title: "{{project_name}} Requirements" # With variable project_name: "Customer Portal" # Result title: "Customer Portal Requirements" ``` ### LLM Instructions ```yaml # In template instruction: | [[LLM: Generate 5 user stories based on: - Context: {{business_context}} - Users: {{stakeholders}} Format as: As a [user], I want [feature], so that [benefit]]] # Result The LLM generates contextual user stories based on provided variables ``` ### Conditional Sections ```yaml # In template - id: integration_section condition: "project_type == 'integration'" # Only included when project_type is 'integration' ``` ### Repeatable Sections ```yaml # In template repeatable: true repeat_for: components loop_var: component # With variable components: ['Auth Service', 'Data Service', 'UI Layer'] # Generates section for each component ``` ## Advanced Usage ### Custom Variables ```bash # Provide variables via JSON file /sf-product-manager *create-doc --template requirements --var-file project-vars.json ``` ### Template Validation ```bash # Validate template before processing *validate-template sf-requirements-enhanced Output: Template structure valid All required sections present LLM instructions properly formatted ⚠️ Optional section 'appendices' may need variables ``` ### Batch Processing ```bash # Process multiple documents *batch-create --templates "requirements,architecture,test-plan" --vars project.json ``` ## Template Library ### Planning Phase Templates 1. **sf-requirements-enhanced.yaml** - Comprehensive requirements 2. **sf-architecture-enhanced.yaml** - Solution architecture 3. **sf-design-enhanced.yaml** - Technical design 4. **sf-user-stories-enhanced.yaml** - User story generation ### Development Phase Templates 1. **sf-story-context-enhanced.yaml** - Implementation stories 2. **sf-test-plan-enhanced.yaml** - Test planning 3. **sf-code-review-enhanced.yaml** - Code review checklist ### Deployment Phase Templates 1. **sf-deployment-guide-enhanced.yaml** - Deployment instructions 2. **sf-release-notes-enhanced.yaml** - Release documentation 3. **sf-rollback-plan-enhanced.yaml** - Rollback procedures ## Best Practices ### DO: - Review template requirements before starting - Gather all variables upfront for rapid mode - Validate generated content against requirements - Use interactive mode for complex documents - Save variables for reuse ### DON'T: - Skip variable validation - Ignore LLM instruction errors - Process without reviewing output - Use rapid mode without complete context ## Error Handling ### Missing Required Variable ``` Error: Required variable 'project_name' not provided Solution: Provide the variable or mark it with a default value ``` ### Invalid LLM Instruction ``` Error: Malformed LLM instruction in section 'requirements' Solution: Check instruction syntax - must be [[LLM: ... ]] ``` ### Condition Evaluation Failed ``` Error: Cannot evaluate condition 'complexity == complex' Solution: Ensure variable 'complexity' is defined ``` ## Integration with Agents ### Product Manager Usage ``` /sf-product-manager *create-doc > Select: requirements-enhanced > Mode: interactive > Collaborate on business context and requirements ``` ### Architect Usage ``` /sf-architect *create-doc > Select: architecture-enhanced > Mode: rapid > Provide technical context and generate architecture ``` ### Developer Usage ``` /sf-developer-lean *create-doc > Select: story-context-enhanced > Mode: rapid > Generate implementation story from sharded docs ``` ## Output Examples ### Generated Requirements Document ```markdown # Customer Portal Requirements Document **Version:** 1.0 **Date:** 2024-01-15 **Status:** Draft ## Executive Summary [LLM-generated executive summary based on context] ## Business Requirements [Detailed business requirements with objectives] ## Functional Requirements ### User Stories [Generated user stories with acceptance criteria] ## Technical Requirements [Platform, integration, and security requirements] ## Success Metrics [Measurable KPIs and targets] ``` ### Generated Architecture Document ```markdown # Customer Portal Architecture Document ## Solution Architecture [Component descriptions with diagrams] ## Data Architecture [Data model and flow descriptions] ## Integration Architecture [API specifications and patterns] ## Security Architecture [Authentication, authorization, encryption] ``` ## Metrics Well-processed templates result in: - **80% reduction** in document creation time - **95% consistency** across similar documents - **100% coverage** of required sections - **Zero missing** critical information ## Command Reference ```bash # Process template interactively *create-doc # Process with specific template *create-doc --template sf-requirements-enhanced # Rapid mode with variables *create-doc --rapid --vars '{"project_name":"Portal"}' # Validate template *validate-template [template-name] # List available templates *list-templates # Process batch *batch-create --templates [list] --vars [file] ``` ## Conclusion The enhanced template system with create-doc-v2 provides intelligent, context-aware document generation that dramatically improves productivity while ensuring comprehensive, consistent documentation across all Salesforce projects.