{
  "report_info": {
    "version": "9.0.1",
    "generated_at": "2026-07-21T01:54:20Z",
    "binary_name": "ai-monitor"
  },
  "binary": {
    "name": "ai-monitor",
    "path": "/opt/kodachi/dashboard/hooks/ai-monitor",
    "timestamp": "2026-07-21T01:54:20Z",
    "file_info": {
      "size": 4205584,
      "sha256": "89d6c242af57bbbf89c73c17f30037146123a7b6ae2cd989d9de6e77232e8f78"
    },
    "flag_n": {
      "status": "success",
      "timestamp": "2026-07-21T01:54:20.529179317Z",
      "command": "info",
      "version": "9.8.4",
      "data": {
        "name": "ai-monitor",
        "version": "9.8.4",
        "author": "Warith Al Maawali",
        "description": "Proactive system monitoring daemon with anomaly detection and suggestions",
        "copyright": "© 2026 Kodachi OS",
        "website": "https://www.digi77.com",
        "license": "Proprietary",
        "features": [],
        "securityFeatures": {
          "inputValidation": "Argument parsing via clap; per-command validation is the consumer's responsibility",
          "rateLimiting": "Not provided by cli-core",
          "authentication": "Not provided by cli-core (see online-auth)",
          "encryption": "Not provided by cli-core"
        },
        "systemRequirements": {
          "os": "Linux (Debian-based)",
          "privileges": "root/sudo for system operations",
          "dependencies": [
            "OpenSSL",
            "libcurl"
          ]
        }
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "REDACTED-BUILD-HOST",
        "user": "REDACTED-BUILD-USER"
      }
    },
    "flag_v": {
      "status": "success",
      "timestamp": "2026-07-21T01:54:20.762566404Z",
      "command": "version",
      "version": "9.8.4",
      "data": {
        "name": "ai-monitor",
        "version": "9.8.4",
        "buildDate": "REDACTED-BUILD-TIME",
        "gitCommit": "unknown",
        "rustVersion": "1.82.0"
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "REDACTED-BUILD-HOST",
        "user": "REDACTED-BUILD-USER"
      }
    },
    "flag_h": {
      "status": "success",
      "timestamp": "2026-07-21T01:54:20.942076359Z",
      "command": "help",
      "version": "9.8.4",
      "data": {
        "name": "ai-monitor",
        "description": "Proactive system monitoring daemon with anomaly detection and suggestions",
        "usage": "ai-monitor [OPTIONS] [COMMAND] [ARGS]",
        "commandCategories": [
          {
            "category": "Monitoring",
            "commands": [
              {
                "name": "start",
                "description": "Start the system monitoring daemon",
                "usage": "ai-monitor start [OPTIONS]",
                "options": [
                  {
                    "flag": "-i, --interval <SECONDS>",
                    "description": "How often the monitor re-checks the system, in seconds",
                    "default": "30"
                  },
                  {
                    "flag": "-s, --threshold <SCORE>",
                    "description": "Security score (1 to 100) below which the monitor raises an alert",
                    "default": "70"
                  },
                  {
                    "flag": "-d, --daemon",
                    "description": "Install the systemd unit if missing and run under systemd instead of in this shell. Requires root"
                  },
                  {
                    "flag": "--json",
                    "description": "Emit the start result as a JSON envelope"
                  }
                ],
                "requires_sudo": false,
                "examples": [
                  "ai-monitor start",
                  "ai-monitor start --interval 60",
                  "ai-monitor start --interval 60 --threshold 80",
                  "sudo ai-monitor start --daemon"
                ]
              },
              {
                "name": "status",
                "description": "Show current monitor status and statistics",
                "usage": "ai-monitor status [--verbose] [--json]",
                "options": [
                  {
                    "flag": "--verbose",
                    "description": "Also report database statistics and which monitors (VPN, Tor, DNS, security) are enabled"
                  },
                  {
                    "flag": "--json",
                    "description": "Emit status, message, is_running, active_suggestions, last_check and config as a JSON envelope"
                  }
                ],
                "requires_sudo": false,
                "examples": [
                  "ai-monitor status",
                  "ai-monitor status --verbose",
                  "ai-monitor status --json"
                ]
              }
            ]
          },
          {
            "category": "Service Management",
            "commands": [
              {
                "name": "service",
                "description": "Manage the ai-monitor systemd service lifecycle",
                "usage": "ai-monitor service <ACTION>",
                "options": [
                  {
                    "flag": "<ACTION>",
                    "description": "install (write the unit file), uninstall (stop, disable and remove it), enable (start at boot), disable (do not start at boot), status (read-only). Everything except status requires root",
                    "required": true
                  },
                  {
                    "flag": "--force",
                    "description": "With 'install': overwrite a unit file that is not recognized as ai-monitor's own output (e.g. an administrator-customized unit). Ignored by other actions",
                    "default": "false"
                  },
                  {
                    "flag": "--json",
                    "description": "Emit the action result as a JSON envelope"
                  }
                ],
                "requires_sudo": false,
                "examples": [
                  "sudo ai-monitor service install",
                  "sudo ai-monitor service install --force",
                  "sudo ai-monitor service enable",
                  "ai-monitor service status",
                  "sudo ai-monitor service disable",
                  "sudo ai-monitor service uninstall"
                ]
              }
            ]
          },
          {
            "category": "Suggestions",
            "commands": [
              {
                "name": "suggestions",
                "description": "List and manage proactive suggestions",
                "usage": "ai-monitor suggestions [OPTIONS]",
                "options": [
                  {
                    "flag": "-c, --category <CATEGORY>",
                    "description": "Show only one category: security, network, recovery or optimization",
                    "default": "all categories"
                  },
                  {
                    "flag": "-r, --resolve <ID>",
                    "description": "Mark the suggestion with this ID as resolved. Write operation, needs a prior online-auth login"
                  },
                  {
                    "flag": "-d, --dismiss <ID>",
                    "description": "Mark the suggestion with this ID as dismissed. Write operation, needs a prior online-auth login"
                  },
                  {
                    "flag": "--cleanup",
                    "description": "Delete old inactive suggestions from the database. Write operation, needs a prior online-auth login"
                  },
                  {
                    "flag": "--json",
                    "description": "Emit the suggestion list or the write result as a JSON envelope"
                  }
                ],
                "requires_sudo": false,
                "examples": [
                  "ai-monitor suggestions",
                  "ai-monitor suggestions --json",
                  "ai-monitor suggestions --category security",
                  "ai-monitor suggestions --resolve 1",
                  "ai-monitor suggestions --dismiss 2",
                  "ai-monitor suggestions --cleanup"
                ]
              }
            ]
          }
        ],
        "globalOptions": [
          {
            "flag": "-h, --help",
            "description": "Print help information"
          },
          {
            "flag": "-v, --version",
            "description": "Print version information"
          },
          {
            "flag": "-n, --info",
            "description": "Display detailed information"
          },
          {
            "flag": "-e, --examples",
            "description": "Show usage examples"
          },
          {
            "flag": "--json",
            "description": "Output in JSON format"
          },
          {
            "flag": "-o, --output-format <FORMAT>",
            "description": "Force output format (text|json)"
          },
          {
            "flag": "--json-pretty",
            "description": "Pretty-print JSON output with indentation"
          },
          {
            "flag": "--json-human",
            "description": "Enhanced JSON output with improved formatting (like jq)"
          },
          {
            "flag": "--json-filter <FIELD1,FIELD2>",
            "description": "Return only specified JSON fields (comma-separated)"
          },
          {
            "flag": "--fields <FIELD_LIST>",
            "description": "Select specific fields to include in output (comma-separated)"
          },
          {
            "flag": "--limit <NUMBER>",
            "description": "Limit number of results returned"
          },
          {
            "flag": "--offset <NUMBER>",
            "description": "Skip first N results (for pagination)"
          },
          {
            "flag": "-d, --work-dir <PATH>",
            "description": "Working directory (defaults to auto-detected base directory)"
          },
          {
            "flag": "--port <PORT>",
            "description": "Set custom port number (1024-65535)"
          },
          {
            "flag": "--log-level <LEVEL>",
            "description": "Set log level (error|warn|info|debug)"
          },
          {
            "flag": "--verbose",
            "description": "Enable verbose output"
          },
          {
            "flag": "--quiet",
            "description": "Suppress non-essential output"
          },
          {
            "flag": "--no-color",
            "description": "Disable colored output"
          },
          {
            "flag": "--config <FILE>",
            "description": "Use custom configuration file"
          },
          {
            "flag": "--timeout <SECS>",
            "description": "Set operation timeout in seconds (optional; no default applied)"
          }
        ],
        "environmentVariables": [
          {
            "name": "NO_COLOR",
            "description": "Disable all colored output when set",
            "default": "unset",
            "values": "1|true|yes (any value disables color)"
          }
        ],
        "exitCodes": {
          "2": "Invalid arguments",
          "1": "General error",
          "3": "Permission denied",
          "0": "Success",
          "5": "File not found",
          "4": "Network error"
        }
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "REDACTED-BUILD-HOST",
        "user": "REDACTED-BUILD-USER"
      }
    },
    "flag_e": {
      "status": "success",
      "timestamp": "2026-07-21T01:54:21.328242510Z",
      "command": "examples",
      "version": "9.8.4",
      "data": {
        "name": "ai-monitor",
        "description": "Usage examples for ai-monitor",
        "categories": [
          {
            "id": "1_basic",
            "title": "Basic Usage",
            "description": "Look at what the monitor currently knows: is it running, and what has it suggested.",
            "examples": [
              {
                "command": "ai-monitor status",
                "description": "Show whether the monitor is running and how many suggestions are open",
                "expectedOutput": "'Monitor Status: running' or 'stopped', then active suggestions, last check, check interval and security threshold"
              },
              {
                "command": "ai-monitor status --json",
                "description": "Same status as a JSON envelope for the dashboard or a script",
                "expectedOutput": "Envelope with status, message, is_running, active_suggestions, last_check and config{check_interval_seconds, security_threshold}"
              },
              {
                "command": "ai-monitor status --verbose",
                "description": "Add the SQLite database stats and which monitors are enabled",
                "expectedOutput": "The plain status block plus a Database section (total size, pages) and a Monitoring section (VPN, Tor, DNS, Security enabled or disabled)",
                "notes": "--verbose adds database{page_count, page_size, freelist_count, total_size_bytes, unused_bytes} and monitoring{vpn_enabled, tor_enabled, dns_enabled, security_enabled} to the JSON form."
              },
              {
                "command": "ai-monitor suggestions",
                "description": "List every open proactive suggestion",
                "expectedOutput": "One line per active suggestion with its ID, category and message, or a note that there are none"
              },
              {
                "command": "ai-monitor suggestions --json",
                "description": "List open suggestions as JSON",
                "expectedOutput": "Envelope with the suggestion array and its metadata"
              },
              {
                "command": "ai-monitor start",
                "description": "Run the monitoring loop in this terminal (not as a service)",
                "expectedOutput": "The monitor starts with a 30 second interval and a security threshold of 70, then keeps checking until you stop it",
                "notes": "Foreground run. Use `service` or `start --daemon` if you want it to survive the shell."
              }
            ]
          },
          {
            "id": "2_advanced",
            "title": "Tuning the Monitor",
            "description": "Change how often the monitor checks the system and how low the security score has to drop before it raises an alert.",
            "examples": [
              {
                "command": "ai-monitor start --interval 60 --threshold 80",
                "description": "Check every 60 seconds and alert below a security score of 80",
                "expectedOutput": "The monitor starts and reports the interval and threshold it is using",
                "notes": "--interval is in seconds (default 30). --threshold is a security score of 1 to 100 (default 70). Short forms are -i and -s."
              },
              {
                "command": "ai-monitor start --interval 60 --threshold 80 --json",
                "description": "Start a tuned foreground monitor and capture the config as JSON",
                "expectedOutput": "Envelope echoing the interval and security threshold actually applied"
              },
              {
                "command": "ai-monitor suggestions --category security",
                "description": "Only look at security suggestions",
                "expectedOutput": "The active suggestions whose category is security",
                "notes": "--category accepts exactly: security, network, recovery, optimization. Anything else is rejected by clap."
              },
              {
                "command": "ai-monitor suggestions --category network",
                "description": "Only look at network suggestions",
                "expectedOutput": "The active suggestions whose category is network"
              },
              {
                "command": "ai-monitor suggestions --category security --json",
                "description": "Filtered suggestions as JSON for automation",
                "expectedOutput": "Envelope with only the security-category suggestions"
              }
            ]
          },
          {
            "id": "3_service",
            "title": "Service Management",
            "description": "Run the monitor as a systemd unit so it survives logout and reboot. The unit file is generated at install time with the real binary path.",
            "examples": [
              {
                "command": "sudo ai-monitor start --daemon",
                "description": "Install the unit if needed and start the monitor under systemd",
                "expectedOutput": "The service is installed (first run only), started, and confirmed active",
                "notes": "Needs root: it writes the unit file and calls systemctl. Without sudo it fails with 'This operation requires root privileges.'"
              },
              {
                "command": "sudo ai-monitor service install",
                "description": "Only write the systemd unit file, do not start it",
                "expectedOutput": "Service installed successfully",
                "notes": "Needs root."
              },
              {
                "command": "sudo ai-monitor service enable",
                "description": "Start the monitor automatically on every boot",
                "expectedOutput": "Service enabled successfully",
                "notes": "Needs root. Install the service first, enable only creates the boot link."
              },
              {
                "command": "sudo ai-monitor service disable",
                "description": "Stop the monitor from starting at boot, leave it installed",
                "expectedOutput": "Service disabled successfully",
                "notes": "Needs root. A currently running instance keeps running until it is stopped."
              },
              {
                "command": "ai-monitor service status",
                "description": "Check whether the service is installed, active and enabled",
                "expectedOutput": "installed true or false, plus the systemd active and enabled state and MainPID, ActiveEnterTimestamp, MemoryCurrent",
                "notes": "The only service action that does not need root."
              },
              {
                "command": "ai-monitor service status --json",
                "description": "Service state as JSON for the dashboard",
                "expectedOutput": "Envelope with installed, active, enabled and a properties map"
              },
              {
                "command": "sudo ai-monitor service uninstall",
                "description": "Stop, disable and delete the systemd unit",
                "expectedOutput": "Service uninstalled successfully",
                "notes": "Needs root. Destructive: the unit file is removed and the monitor stops running at boot. Collected suggestions in the database are not touched."
              }
            ]
          },
          {
            "id": "4_maintenance",
            "title": "Suggestion Maintenance",
            "description": "Act on suggestions: resolve one you have fixed, dismiss one you do not care about, or prune the old inactive ones.",
            "examples": [
              {
                "command": "ai-monitor suggestions --resolve 1",
                "description": "Mark suggestion 1 as resolved because you acted on it",
                "expectedOutput": "Suggestion 1 is marked resolved and drops out of the active list",
                "notes": "Write operation: requires a prior `online-auth` login, otherwise it exits with 'Authentication required. Please authenticate using online-auth first'. The ID comes from `ai-monitor suggestions`."
              },
              {
                "command": "ai-monitor suggestions --dismiss 2",
                "description": "Dismiss suggestion 2 without claiming you fixed anything",
                "expectedOutput": "Suggestion 2 is marked dismissed and drops out of the active list",
                "notes": "Write operation: requires a prior `online-auth` login."
              },
              {
                "command": "ai-monitor suggestions --cleanup",
                "description": "Delete old inactive suggestions from the database",
                "expectedOutput": "The number of cleaned up suggestions",
                "notes": "Write operation: requires a prior `online-auth` login. Irreversible: the pruned rows are deleted from the local database."
              },
              {
                "command": "ai-monitor suggestions --category optimization",
                "description": "Review the optimization suggestions before acting on them",
                "expectedOutput": "The active suggestions whose category is optimization"
              },
              {
                "command": "ai-monitor suggestions --category recovery",
                "description": "Review the recovery suggestions",
                "expectedOutput": "The active suggestions whose category is recovery"
              }
            ]
          }
        ],
        "quickReference": [
          "ai-monitor --help",
          "ai-monitor --version",
          "ai-monitor --info --json",
          "ai-monitor --examples",
          "ai-monitor status",
          "ai-monitor suggestions",
          "ai-monitor service status",
          "sudo ai-monitor start --daemon"
        ]
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "REDACTED-BUILD-HOST",
        "user": "REDACTED-BUILD-USER"
      }
    }
  }
}
