{
  "report_info": {
    "version": "9.0.1",
    "generated_at": "2026-07-21T01:54:26Z",
    "binary_name": "ai-discovery"
  },
  "binary": {
    "name": "ai-discovery",
    "path": "/opt/kodachi/dashboard/hooks/ai-discovery",
    "timestamp": "2026-07-21T01:54:26Z",
    "file_info": {
      "size": 1771784,
      "sha256": "e042d9cbaf3459d31136acd16a5cd19ff1d3847a1f6e17bbe398d61435e3c7c5"
    },
    "flag_n": {
      "status": "success",
      "timestamp": "2026-07-21T01:54:26.110252153Z",
      "command": "info",
      "version": "9.8.4",
      "data": {
        "name": "ai-discovery",
        "version": "9.8.4",
        "author": "Warith Al Maawali",
        "description": "Kodachi Auto-Discovery Daemon - Monitors and indexes Rust service binaries",
        "copyright": "© 2026 Kodachi OS",
        "website": "https://www.digi77.com",
        "license": "Proprietary",
        "features": [
          "Binary file watching with inotify",
          "Automatic command extraction from -e --json",
          "Live command registry updates",
          "Daemon process management"
        ],
        "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:26.261515403Z",
      "command": "version",
      "version": "9.8.4",
      "data": {
        "name": "ai-discovery",
        "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:26.391450687Z",
      "command": "help",
      "version": "9.8.4",
      "data": {
        "name": "ai-discovery",
        "description": "Kodachi Auto-Discovery Daemon - Monitors and indexes Rust service binaries",
        "usage": "ai-discovery [OPTIONS] [COMMAND] [ARGS]",
        "commandCategories": [
          {
            "category": "Daemon Control",
            "commands": [
              {
                "name": "start",
                "description": "Start the auto-discovery daemon",
                "usage": "ai-discovery start [OPTIONS]",
                "options": [
                  {
                    "flag": "-f, --foreground",
                    "description": "Run the watch loop in this terminal instead of detaching (blocks until Ctrl+C)",
                    "default": "false (daemonize)"
                  },
                  {
                    "flag": "--json",
                    "description": "Emit status, mode, binaries_watched, commands_indexed, pid and already_running as JSON"
                  }
                ],
                "requires_sudo": true,
                "examples": [
                  "sudo ai-discovery start",
                  "sudo ai-discovery start --foreground",
                  "sudo ai-discovery start --json"
                ]
              },
              {
                "name": "status",
                "description": "Show daemon status",
                "usage": "ai-discovery status [OPTIONS]",
                "options": [
                  {
                    "flag": "--json",
                    "description": "Emit the status envelope as JSON (running, pid, binaries_watched, watch_paths)"
                  }
                ],
                "requires_sudo": false,
                "examples": [
                  "ai-discovery status",
                  "ai-discovery status --json"
                ]
              }
            ]
          },
          {
            "category": "Registry Management",
            "commands": [
              {
                "name": "reindex",
                "description": "Force reindex all binaries",
                "usage": "ai-discovery reindex [OPTIONS]",
                "options": [
                  {
                    "flag": "--service <NAME>",
                    "description": "Reindex only this service. NAME is the deployed binary filename and must match exactly",
                    "default": "all watched binaries"
                  },
                  {
                    "flag": "--json",
                    "description": "Emit status, binaries_scanned, commands_indexed and errors as JSON"
                  }
                ],
                "requires_sudo": false,
                "examples": [
                  "ai-discovery reindex",
                  "ai-discovery reindex --json",
                  "ai-discovery reindex --service health-control"
                ]
              }
            ]
          }
        ],
        "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": {
          "0": "Success",
          "3": "Permission denied",
          "1": "General error",
          "4": "Network error",
          "5": "File not found",
          "2": "Invalid arguments"
        }
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "REDACTED-BUILD-HOST",
        "user": "REDACTED-BUILD-USER"
      }
    },
    "flag_e": {
      "status": "success",
      "timestamp": "2026-07-21T01:54:26.657186435Z",
      "command": "examples",
      "version": "9.8.4",
      "data": {
        "name": "ai-discovery",
        "description": "Usage examples for ai-discovery",
        "categories": [
          {
            "id": "0_quick_start",
            "title": "Quick Start",
            "description": "The three things you will actually run: check the daemon, start it, reindex.",
            "examples": [
              {
                "command": "ai-discovery status",
                "description": "Check whether the discovery daemon is running",
                "expectedOutput": "Running or Stopped, the PID if running, the number of watched paths, and the watch path list"
              },
              {
                "command": "sudo ai-discovery start",
                "description": "Start the daemon in the background",
                "expectedOutput": "Daemon started successfully with mode, binaries watched, commands indexed and PID",
                "notes": "Needs root: the PID file and daemon log are written under the install directory."
              },
              {
                "command": "ai-discovery reindex",
                "description": "Rescan every watched binary and count its commands",
                "expectedOutput": "Reindexing completed with binaries scanned, commands indexed and error count"
              }
            ]
          },
          {
            "id": "1_daemon_control",
            "title": "Daemon Control",
            "description": "Start the auto-discovery daemon and check its state. The daemon watches the deployed Rust service binaries and re-reads their command lists when they change.",
            "examples": [
              {
                "command": "sudo ai-discovery start",
                "description": "Start the daemon detached in the background",
                "expectedOutput": "Mode: Background, plus binaries watched, commands indexed and the PID of the spawned daemon",
                "notes": "Needs root (writes the PID file and log under the install directory). If a daemon is already running its PID is reused and 'Existing daemon reused' is printed."
              },
              {
                "command": "sudo ai-discovery start --foreground",
                "description": "Run the watch loop in this terminal instead of detaching",
                "expectedOutput": "'Daemon running in foreground. Press Ctrl+C to stop.' then a line per binary create, modify or remove event",
                "notes": "Blocks until Ctrl+C. -f is the short form of --foreground."
              },
              {
                "command": "sudo ai-discovery start --json",
                "description": "Start in the background and get the result as JSON",
                "expectedOutput": "Envelope with status, mode, binaries_watched, commands_indexed, pid and already_running"
              },
              {
                "command": "ai-discovery status",
                "description": "Check daemon liveness and the watch configuration",
                "expectedOutput": "Status Running or Stopped, PID when running, the count of watched paths, and each watch path",
                "notes": "Liveness is read from the PID file plus /proc, so a stale PID file still reports Stopped."
              },
              {
                "command": "ai-discovery status --json",
                "description": "Machine-readable daemon status for scripts and the dashboard",
                "expectedOutput": "Envelope with exactly: running, pid, binaries_watched, watch_paths"
              }
            ]
          },
          {
            "id": "2_registry_management",
            "title": "Registry Management",
            "description": "Force a rescan of the watched binaries. Each binary is invoked with -e --json and its commands are extracted and deduplicated.",
            "examples": [
              {
                "command": "ai-discovery reindex",
                "description": "Reindex every watched Rust service binary",
                "expectedOutput": "'Indexed N from <path>' per binary, then a summary with binaries scanned, commands indexed and errors",
                "notes": "Per-binary progress goes to stderr so it does not pollute --json on stdout."
              },
              {
                "command": "ai-discovery reindex --json",
                "description": "Reindex everything and capture the totals as JSON",
                "expectedOutput": "Envelope with status, binaries_scanned, commands_indexed and errors"
              },
              {
                "command": "ai-discovery reindex --service health-control",
                "description": "Reindex a single service instead of the whole set",
                "expectedOutput": "One 'Indexed N from ...' line and a summary with binaries scanned: 1",
                "notes": "--service takes the deployed binary FILENAME and must match exactly. A name outside the configured indexable set is rejected before scanning."
              },
              {
                "command": "ai-discovery reindex --service ai-monitor --json",
                "description": "Targeted reindex of one service with structured output",
                "expectedOutput": "Envelope with binaries_scanned: 1 and the command count for ai-monitor"
              }
            ]
          }
        ],
        "quickReference": [
          "ai-discovery --help",
          "ai-discovery --version",
          "ai-discovery --info --json",
          "ai-discovery --examples",
          "ai-discovery status",
          "ai-discovery reindex",
          "sudo ai-discovery start"
        ]
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "REDACTED-BUILD-HOST",
        "user": "REDACTED-BUILD-USER"
      }
    }
  }
}
