# JIRA Project Configuration Template
# This file should be copied to .bmad-workspace/config/jira-project-{PROJECT_KEY}.yml
# and customized for your specific project

project:
  key: PROJ                                    # Your JIRA project key
  url: https://company.atlassian.net          # Your JIRA instance URL
  name: "Project Name"                        # Human-readable project name

# Custom field mappings (auto-detected or manually specified)
fields:
  epic_link: customfield_10014                # Epic link field ID
  sprint: customfield_10020                   # Sprint field ID  
  story_points: customfield_10016             # Story points field ID
  acceptance_criteria: customfield_10025      # Acceptance criteria field
  technical_notes: customfield_10030          # Technical notes field

# Repository configuration
repository:
  url: https://github.com/company/repo        # Repository URL
  type: github                                # github|gitlab|bitbucket|azure
  default_branch: main                        # Default branch name
  doc_path: docs/stories/                     # Path to BMAD stories

# Synchronization settings
sync:
  mode: light                                 # light|full
  auto_status: true                           # Auto-update status from JIRA
  create_links: true                          # Add links between JIRA and Git
  sync_comments: false                        # Sync comments (full mode only)
  conflict_strategy: jira_wins                # jira_wins|git_wins|manual

# Work tracking settings
work_tracking:
  # Upload settings
  upload:
    auto_link: true                           # Auto-link related issues
    notify_mentions: true                     # Notify @mentioned users
    preserve_formatting: true                 # Keep markdown formatting
    add_metadata: true                        # Add upload timestamp/author
  
  # Template settings
  templates:
    universal: work-documentation.md          # Single template for all documentation
    use_templates: true                       # false = pure LLM intelligence
    match_team_style: true                    # Learn from existing docs
  
  # Label conventions
  conventions:
    bug_labels: 
      - bug
      - needs-analysis
      - root-cause-analysis
    retro_labels: 
      - retrospective
      - sprint-{number}                       # {number} replaced with sprint
    decision_labels: 
      - architecture
      - decision
      - adr
    review_labels:
      - code-review
      - needs-review
      - reviewed
    planning_labels:
      - sprint-planning
      - capacity-planning
    test_labels:
      - test-report
      - test-results
      - qa-complete

# Attachment handling
attachments:
  download_path: .bmad-workspace/attachments/           # Where to store downloads
  max_size_mb: 50                             # Max attachment size to download
  auto_download: true                         # Auto-download on analysis start
  file_types:                                 # File types to auto-download
    - "*.log"
    - "*.txt"
    - "*.json"
    - "*.xml"
    - "*.csv"
    - "screenshot*"
    - "error*"

# Team settings
team:
  time_zone: "America/New_York"               # Team timezone for planning
  sprint_length: 2                            # Sprint length in weeks
  sprint_start_day: "Monday"                  # Sprint start day
  
  # Team member mappings (JIRA username → display name)
  members:
    john.doe: "John Doe"
    jane.smith: "Jane Smith"
    
  # Role assignments for mentions
  roles:
    scrum_master: john.doe
    product_owner: jane.smith
    tech_lead: john.doe

# Integration settings
integrations:
  # Confluence settings (if using for documentation)
  confluence:
    enabled: true
    space_key: PROJ                           # Confluence space key
    parent_page_id: "12345"                   # Parent page for documents
    
  # Slack notifications (optional)
  slack:
    enabled: false
    webhook_url: ""                           # Slack webhook URL
    channels:
      bugs: "#project-bugs"
      reviews: "#code-reviews"
      planning: "#sprint-planning"

# Quality gates
quality:
  # Minimum requirements for uploads
  bug_analysis:
    require_root_cause: true                  # Must identify root cause
    require_impact: true                      # Must assess impact
    require_fix_plan: true                    # Must propose fix
    
  code_review:
    require_test_check: true                  # Must verify tests
    require_security_check: true              # Must check security
    
  sprint_retro:
    require_metrics: true                     # Must include metrics
    require_actions: true                     # Must have action items

# JIRA Cleanup Rules
cleanup_rules:
  # Stale issue detection
  stale_threshold:
    days: 90                                  # Days without updates to consider stale
    exclude_statuses: [Blocked, Waiting]     # Statuses to exclude from stale detection
    exclude_labels: [keep-active, important] # Labels to exclude from cleanup
    exclude_components: []                    # Components to exclude
  
  # Orphaned issue handling  
  orphan_detection:
    require_bmad_reference: true              # Issues must have BMAD documentation
    auto_create_documentation: false         # Auto-create missing BMAD docs
    archive_legacy_items: true               # Archive pre-BMAD issues
    legacy_cutoff_date: "2024-01-01"         # Date before which issues are legacy
  
  # Duplicate detection
  duplicate_detection:
    similarity_threshold: 0.8                # Minimum similarity to flag as duplicate
    auto_merge_threshold: 0.95               # Auto-merge above this threshold
    manual_review_threshold: 0.7             # Manual review above this threshold
    check_fields: [summary, description, component] # Fields to compare
  
  # Data quality rules
  data_quality:
    required_fields: [priority, component]   # Fields that must have values
    auto_populate: true                      # Auto-populate missing values
    validation_rules: strict                 # strict|moderate|lenient
    normalize_values: true                   # Standardize field values
  
  # Sprint hygiene  
  sprint_hygiene:
    auto_close_completed: true               # Close sprints at 100% completion
    move_incomplete_to_backlog: true         # Move incomplete items to backlog
    archive_old_sprints: true                # Archive sprints older than threshold
    sprint_archive_threshold_days: 30        # Days after end to archive sprint
  
  # Attachment management
  attachment_management:
    max_attachment_age_days: 365             # Remove attachments older than this
    compress_large_files: true               # Compress attachments >10MB
    remove_duplicates: true                  # Remove duplicate attachments
    archive_resolved_attachments: true       # Archive attachments from resolved issues
  
  # Backup settings
  backup_settings:
    automatic_backup: true                   # Auto-backup before cleanup
    backup_retention_days: 30                # Keep backups for this many days
    verify_integrity: true                   # Verify backup integrity
    compress_backups: true                   # Compress backup files
    backup_location: .bmad-workspace/cleanup/backups/  # Backup storage location
  
  # Approval workflow
  approval_workflow:
    low_risk_auto_approve: true              # Auto-approve low-risk operations
    medium_risk_reviewers: [team-lead]       # Reviewers for medium-risk operations
    high_risk_reviewers: [project-manager, stakeholder] # Reviewers for high-risk
    require_confirmation: true               # Require explicit confirmation
    notification_channels: [email, jira]     # How to notify about cleanups
  
  # Safety settings
  safety:
    max_issues_per_batch: 100                # Maximum issues to process at once
    require_preview: true                    # Always preview changes first
    rollback_enabled: true                   # Enable rollback functionality
    dry_run_default: true                    # Default to dry run mode
    
  # Scheduling
  schedule:
    frequency: weekly                        # never|weekly|monthly|quarterly
    day: Sunday                              # Day of week to run
    time: "02:00"                           # Time to run (24-hour format)
    timezone: "UTC"                         # Timezone for scheduling

# Advanced settings
advanced:
  # API rate limiting
  rate_limit:
    requests_per_minute: 30                   # API request limit
    retry_after_seconds: 60                   # Retry delay
    
  # Caching
  cache:
    enabled: true                             # Cache JIRA data locally
    ttl_minutes: 15                           # Cache time-to-live
    
  # Logging
  logging:
    level: info                               # debug|info|warn|error
    file: .bmad-workspace/jira-integration.log          # Log file location
    
  # Error handling
  errors:
    retry_count: 3                            # Number of retries
    fallback_to_local: true                   # Save locally if upload fails