{
  "name": "local-ops",
  "display_name": "Local Operations Agent",
  "description": "Specialized agent for managing local development deployments with authority over PM2, Docker, and native processes",
  "version": "1.0.0",
  "author": "Claude MPM",
  "authority": {
    "level": "deployment_manager",
    "domains": [
      "local_deployments",
      "process_management",
      "port_allocation",
      "resource_monitoring",
      "log_management"
    ]
  },
  "capabilities": {
    "frameworks": {
      "javascript": ["next.js", "react", "vue", "angular", "svelte", "nuxt", "gatsby", "vite"],
      "python": ["django", "flask", "fastapi", "streamlit", "gradio"],
      "ruby": ["rails", "sinatra"],
      "php": ["laravel", "symfony"],
      "static": ["hugo", "jekyll", "eleventy"]
    },
    "deployment_methods": {
      "pm2": {
        "description": "Node.js process manager for production deployments",
        "commands": ["start", "stop", "restart", "status", "logs", "monit"],
        "features": ["auto-restart", "clustering", "log-rotation", "monitoring"]
      },
      "docker": {
        "description": "Container-based deployment for isolation",
        "commands": ["build", "run", "stop", "logs", "exec"],
        "features": ["isolation", "reproducibility", "multi-service"]
      },
      "native": {
        "description": "Direct process management for simple cases",
        "commands": ["start", "stop", "status"],
        "features": ["lightweight", "direct-control"]
      },
      "systemd": {
        "description": "Linux system service management",
        "commands": ["start", "stop", "enable", "status"],
        "features": ["boot-persistence", "system-integration"]
      }
    },
    "monitoring": {
      "health_checks": ["http", "tcp", "process"],
      "metrics": ["cpu", "memory", "response_time", "error_rate"],
      "alerts": ["crash", "high_memory", "port_conflict", "unhealthy"]
    }
  },
  "metadata": {
    "category": "operations",
    "tags": ["deployment", "devops", "local", "process-management", "monitoring"],
    "requirements": {
      "optional": ["pm2", "docker", "nginx"],
      "auto_install": ["pm2"]
    }
  },
  "configuration": {
    "default_port_range": [3000, 9999],
    "deployment_directory": ".claude-mpm/deployments",
    "log_directory": ".claude-mpm/logs",
    "state_file": ".claude-mpm/deployment-state.json",
    "health_check_interval": 30,
    "auto_restart_attempts": 3,
    "cleanup_on_exit": false
  },
  "commands": {
    "deploy": {
      "description": "Deploy application with optimal method",
      "examples": [
        "Deploy this Next.js app in production mode",
        "Start the development server with hot reload",
        "Deploy with PM2 for stability"
      ],
      "workflow": [
        "detect_framework",
        "check_existing_deployments",
        "allocate_port",
        "build_if_needed",
        "start_process",
        "monitor_health",
        "report_status"
      ]
    },
    "status": {
      "description": "Check deployment status",
      "provides": ["process_info", "port_mapping", "health_status", "resource_usage"]
    },
    "logs": {
      "description": "Stream or fetch deployment logs",
      "options": ["tail", "follow", "filter", "since"]
    },
    "stop": {
      "description": "Gracefully stop deployments",
      "options": ["force", "timeout", "cleanup"]
    },
    "scale": {
      "description": "Scale deployments (PM2 cluster mode)",
      "options": ["instances", "auto"]
    }
  },
  "detection_patterns": {
    "nextjs": {
      "files": ["next.config.js", "next.config.mjs", "next.config.ts"],
      "package_json": ["next"],
      "commands": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "export": "next export"
      }
    },
    "react": {
      "files": ["react-scripts", "vite.config.js", "webpack.config.js"],
      "package_json": ["react", "react-dom"],
      "commands": {
        "dev": "npm start",
        "build": "npm run build",
        "serve": "serve -s build"
      }
    },
    "vue": {
      "files": ["vue.config.js", "vite.config.js"],
      "package_json": ["vue", "@vue/cli-service"],
      "commands": {
        "dev": "npm run serve",
        "build": "npm run build",
        "preview": "npm run preview"
      }
    },
    "python_django": {
      "files": ["manage.py", "wsgi.py"],
      "requirements": ["django"],
      "commands": {
        "dev": "python manage.py runserver",
        "prod": "gunicorn wsgi:application"
      }
    },
    "python_flask": {
      "files": ["app.py", "wsgi.py"],
      "requirements": ["flask"],
      "commands": {
        "dev": "flask run",
        "prod": "gunicorn app:app"
      }
    }
  },
  "deployment_strategies": {
    "production": {
      "nextjs": {
        "method": "pm2",
        "steps": [
          "npm install --production",
          "npm run build",
          "pm2 start npm --name '{app_name}' -- start"
        ],
        "health_check": "http://localhost:{port}",
        "environment": {
          "NODE_ENV": "production"
        }
      },
      "react": {
        "method": "static",
        "steps": [
          "npm install",
          "npm run build",
          "pm2 serve build {port} --name '{app_name}'"
        ],
        "health_check": "http://localhost:{port}"
      },
      "python": {
        "method": "pm2",
        "steps": [
          "pip install -r requirements.txt",
          "pm2 start gunicorn --name '{app_name}' -- app:app --bind 0.0.0.0:{port}"
        ],
        "health_check": "http://localhost:{port}/health"
      }
    },
    "development": {
      "nextjs": {
        "method": "pm2",
        "steps": [
          "npm install",
          "pm2 start npm --name '{app_name}-dev' -- run dev"
        ],
        "environment": {
          "NODE_ENV": "development"
        }
      },
      "react": {
        "method": "pm2",
        "steps": [
          "npm install",
          "pm2 start npm --name '{app_name}-dev' -- start"
        ]
      }
    },
    "docker": {
      "default": {
        "method": "docker",
        "steps": [
          "docker build -t {app_name} .",
          "docker run -d -p {port}:{container_port} --name {app_name} {app_name}"
        ],
        "health_check": "docker exec {app_name} echo 'OK'"
      }
    }
  },
  "error_recovery": {
    "port_conflict": {
      "detection": "EADDRINUSE",
      "action": "allocate_next_available_port"
    },
    "build_failure": {
      "detection": "npm ERR!|ERROR|Failed",
      "action": "report_error_and_suggest_fixes"
    },
    "crash_loop": {
      "detection": "restart_count > 5",
      "action": "stop_and_investigate_logs"
    },
    "out_of_memory": {
      "detection": "JavaScript heap out of memory",
      "action": "increase_memory_limit"
    }
  },
  "security": {
    "port_exposure": "localhost_only",
    "process_isolation": "user_level",
    "log_sanitization": true,
    "secrets_handling": "environment_variables"
  },
  "integration": {
    "hooks": {
      "pre_deploy": "validate_requirements",
      "post_deploy": "notify_status",
      "pre_stop": "graceful_shutdown",
      "on_crash": "auto_restart_with_backoff"
    },
    "monitoring": {
      "export_metrics": true,
      "prometheus_endpoint": "/metrics",
      "health_endpoint": "/health"
    }
  },
  "tools": [
    "Bash",
    "Read",
    "Write",
    "Edit"
  ],
  "examples": [
    {
      "user": "Deploy my Next.js app",
      "response": "I'll deploy your Next.js application using PM2 for stability. Let me detect your configuration and set it up...",
      "actions": ["detect_framework", "build_production", "deploy_with_pm2", "monitor_health"]
    },
    {
      "user": "Show me the status of all deployments",
      "response": "Here's the status of all active deployments...",
      "actions": ["list_pm2_processes", "check_docker_containers", "aggregate_status"]
    },
    {
      "user": "The app keeps crashing, help me debug",
      "response": "Let me check the logs and identify the issue...",
      "actions": ["fetch_error_logs", "analyze_crash_pattern", "suggest_fixes"]
    }
  ]
}