import { ProcessTemplate } from '../types.js';

export const softwareEngineerDailyTemplate: ProcessTemplate = {
  id: 'software-engineer-daily',
  name: 'Daily Engineering Routine',
  description: 'Automated daily workflow for software engineers including CI/CD checks, PR reviews, and standup preparation',
  persona: 'software-engineer',
  category: 'daily-routine',
  
  variables: [
    {
      name: 'slackChannel',
      type: 'string',
      defaultValue: '#engineering',
      description: 'Slack channel for notifications'
    },
    {
      name: 'includeTestReport',
      type: 'boolean',
      defaultValue: true,
      description: 'Include test coverage in daily report'
    }
  ],
  
  suggestedTriggers: [
    {
      type: 'schedule',
      name: 'Morning Routine',
      defaultConfig: {
        cron: '0 9 * * 1-5',
        timezone: 'local'
      },
      applicableWhen: 'Run every weekday morning before standup'
    },
    {
      type: 'manual',
      name: 'On Demand',
      defaultConfig: {},
      applicableWhen: 'Run manually when needed'
    }
  ],
  
  activities: [
    {
      id: 'check-ci-status',
      type: 'tool',
      name: 'Check CI/CD Pipeline Status',
      config: {
        toolName: 'check_deployment_health',
        toolArgs: {
          environment: 'all'
        }
      },
      outputs: ['ciStatus']
    },
    {
      id: 'get-pr-list',
      type: 'tool',
      name: 'Get Pending Pull Requests',
      config: {
        toolName: 'list_pull_requests',
        toolArgs: {
          status: 'open',
          assignedToMe: true
        }
      },
      outputs: ['pendingPRs']
    },
    {
      id: 'check-test-coverage',
      type: 'tool',
      name: 'Check Test Coverage',
      condition: '${includeTestReport}',
      config: {
        toolName: 'analyze_test_coverage',
        toolArgs: {}
      },
      outputs: ['testCoverage']
    },
    {
      id: 'check-sprint-status',
      type: 'tool',
      name: 'Get Sprint Status',
      config: {
        toolName: 'get_sprint_status',
        toolArgs: {}
      },
      outputs: ['sprintStatus']
    },
    {
      id: 'generate-standup-notes',
      type: 'agent',
      name: 'Generate Standup Notes',
      config: {
        agentType: 'report-generator',
        agentTask: 'Create standup notes from collected data',
        agentConfig: {
          inputs: ['ciStatus', 'pendingPRs', 'testCoverage', 'sprintStatus']
        }
      },
      outputs: ['standupNotes']
    },
    {
      id: 'review-notes',
      type: 'human',
      name: 'Review Standup Notes',
      config: {
        prompt: 'Please review and edit your standup notes before sharing',
        formFields: [
          {
            name: 'notes',
            type: 'text',
            label: 'Standup Notes',
            defaultValue: '${standupNotes}',
            required: true
          },
          {
            name: 'blockers',
            type: 'text',
            label: 'Any blockers?',
            required: false
          }
        ],
        timeout: 300000 // 5 minutes
      },
      outputs: ['finalNotes', 'blockers']
    },
    {
      id: 'notify-team',
      type: 'external',
      name: 'Post to Slack',
      config: {
        url: 'https://slack.com/api/chat.postMessage',
        method: 'POST',
        body: {
          channel: '${slackChannel}',
          text: '${finalNotes}',
          blocks: [
            {
              type: 'section',
              text: {
                type: 'mrkdwn',
                text: '*Daily Standup Notes*\n${finalNotes}'
              }
            }
          ]
        },
        authentication: {
          type: 'bearer',
          credentials: {
            token: '${SLACK_TOKEN}'
          }
        }
      }
    }
  ],
  
  estimatedDuration: '5-10 minutes',
  requiredIntegrations: ['git', 'slack']
};