{
  "report_info": {
    "version": "9.0.1",
    "generated_at": "2026-04-11T17:16:14Z",
    "binary_name": "ai-trainer"
  },
  "binary": {
    "name": "ai-trainer",
    "path": "/home/kodachi/k900/dashboard/hooks/ai-trainer",
    "timestamp": "2026-04-11T17:16:14Z",
    "file_info": {
      "size": 3001296,
      "sha256": "09645b66922f6e03ac1ba575907d6c132f455a1b382ab420334bb3ea903a7edb"
    },
    "flag_n": {
      "status": "success",
      "timestamp": "2026-04-11T17:16:14.291997229Z",
      "command": "info",
      "version": "9.0.1",
      "data": {
        "name": "ai-trainer",
        "version": "9.0.1",
        "author": "Warith Al Maawali <warith@digi77.com>",
        "description": "AI model training and validation for Kodachi OS command intelligence",
        "copyright": "© 2026 Linux Kodachi",
        "website": "https://www.digi77.com",
        "license": "LicenseRef-Kodachi-SAN-1.0",
        "features": [
          "TF-IDF based command embeddings",
          "Incremental model updates",
          "Model validation and accuracy testing"
        ],
        "securityFeatures": {
          "inputValidation": "All inputs are validated and sanitized",
          "rateLimiting": "Built-in rate limiting for network operations",
          "authentication": "Secure authentication with certificate pinning",
          "encryption": "TLS 1.3 for all network communications"
        },
        "systemRequirements": {
          "os": "Linux (Debian-based)",
          "privileges": "root/sudo for system operations",
          "dependencies": [
            "OpenSSL",
            "libcurl"
          ]
        }
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 1,
        "hostname": "Boardroom-System",
        "user": "kodachi"
      }
    },
    "flag_v": {
      "status": "success",
      "timestamp": "2026-04-11T17:16:14.373407520Z",
      "command": "version",
      "version": "9.0.1",
      "data": {
        "name": "ai-trainer",
        "version": "9.0.1",
        "buildDate": "2026-04-11T17:16:14.372850105Z",
        "gitCommit": "unknown",
        "rustVersion": "1.82.0"
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "Boardroom-System",
        "user": "kodachi"
      }
    },
    "flag_h": {
      "status": "success",
      "timestamp": "2026-04-11T17:16:14.450148956Z",
      "command": "help",
      "version": "9.0.1",
      "data": {
        "name": "ai-trainer",
        "description": "AI model training and validation for Kodachi OS command intelligence",
        "usage": "ai-trainer [OPTIONS] [COMMAND] [ARGS]",
        "commandCategories": [
          {
            "category": "Model Management",
            "commands": [
              {
                "name": "export",
                "description": "Export model embeddings and metadata to JSON file",
                "usage": "ai-trainer export --output <FILE> [--format <FORMAT>]",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer export --output model_export.json"
                ]
              },
              {
                "name": "snapshot",
                "description": "Save current model as versioned snapshot",
                "usage": "ai-trainer snapshot --snapshot-version <VERSION>",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer snapshot --snapshot-version 1.0.0",
                  "ai-trainer snapshot -s 1.1.0-beta"
                ]
              },
              {
                "name": "list-snapshots",
                "description": "List all saved model snapshots",
                "usage": "ai-trainer list-snapshots",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer list-snapshots"
                ]
              },
              {
                "name": "status",
                "description": "Display current model status and statistics",
                "usage": "ai-trainer status",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer status"
                ]
              },
              {
                "name": "download-model",
                "description": "Download ONNX model, tokenizer, or GGUF model for AI engine tiers",
                "usage": "ai-trainer download-model [--llm [default|small|large]] [--show-models] [--all] [--output-dir <DIR>] [--force]",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer download-model",
                  "ai-trainer download-model --llm",
                  "ai-trainer download-model --llm small",
                  "ai-trainer download-model --all",
                  "ai-trainer download-model --show-models",
                  "ai-trainer download-model --force"
                ]
              }
            ]
          },
          {
            "category": "Model Training",
            "commands": [
              {
                "name": "train",
                "description": "Train AI model from command metadata (full retraining)",
                "usage": "ai-trainer train --data <FILE> [--database <DB_PATH>]",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer train --data commands.json",
                  "ai-trainer train --data commands.json --json"
                ]
              },
              {
                "name": "incremental",
                "description": "Update model incrementally with new command data",
                "usage": "ai-trainer incremental --new-data <FILE> [--database <DB_PATH>]",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer incremental --new-data new_commands.json"
                ]
              }
            ]
          },
          {
            "category": "Validation & Testing",
            "commands": [
              {
                "name": "validate",
                "description": "Validate model accuracy against test dataset",
                "usage": "ai-trainer validate --test-data <FILE> [--threshold <THRESHOLD>]",
                "options": [],
                "requires_sudo": false,
                "examples": [
                  "ai-trainer validate --test-data test_cases.json"
                ]
              }
            ]
          }
        ],
        "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": "--json-pretty",
            "description": "Pretty-print JSON output with indentation"
          },
          {
            "flag": "--json-human",
            "description": "Enhanced JSON output with improved formatting (like jq)"
          },
          {
            "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 timeout (default: 30)"
          },
          {
            "flag": "--retry <COUNT>",
            "description": "Retry attempts (default: 3)"
          }
        ],
        "environmentVariables": [
          {
            "name": "RUST_LOG",
            "description": "Set logging level",
            "default": "info",
            "values": "error|warn|info|debug|trace"
          },
          {
            "name": "NO_COLOR",
            "description": "Disable all colored output when set",
            "default": "unset",
            "values": "1|true|yes (any value disables color)"
          }
        ],
        "exitCodes": {
          "2": "Invalid arguments",
          "5": "File not found",
          "3": "Permission denied",
          "0": "Success",
          "4": "Network error",
          "1": "General error"
        }
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "Boardroom-System",
        "user": "kodachi"
      }
    },
    "flag_e": {
      "status": "success",
      "timestamp": "2026-04-11T17:16:14.616422099Z",
      "command": "examples",
      "version": "9.0.1",
      "data": {
        "name": "ai-trainer",
        "description": "Usage examples for ai-trainer",
        "categories": [
          {
            "id": "1_model_training",
            "title": "Model Training",
            "description": "Full model training operations",
            "examples": [
              {
                "command": "sudo ai-trainer train --data commands.json",
                "description": "Train model with command data",
                "expectedOutput": "Training statistics and embeddings metrics",
                "notes": "Creates new model from scratch"
              },
              {
                "command": "sudo ai-trainer train --data commands.json --database custom.db",
                "description": "Train with custom database",
                "expectedOutput": "Training results with custom DB location",
                "notes": "Allows custom database path specification"
              },
              {
                "command": "sudo ai-trainer train --data commands.json --json",
                "description": "Train and output results as JSON",
                "expectedOutput": "JSON-formatted training metrics",
                "notes": "Structured output for automation"
              }
            ]
          },
          {
            "id": "2_incremental_training",
            "title": "Incremental Training",
            "description": "Update existing models with new data",
            "examples": [
              {
                "command": "sudo ai-trainer incremental --new-data updates.json",
                "description": "Incrementally train with new data",
                "expectedOutput": "New embeddings added to existing model",
                "notes": "Requires existing trained model"
              },
              {
                "command": "sudo ai-trainer incremental --new-data updates.json --database custom.db --json",
                "description": "Incremental training with custom DB and JSON output",
                "expectedOutput": "JSON-formatted incremental training results",
                "notes": "Combines custom DB path with structured output"
              }
            ]
          },
          {
            "id": "3_validation",
            "title": "Validation",
            "description": "Model accuracy testing and validation",
            "examples": [
              {
                "command": "sudo ai-trainer validate --test-data test_commands.json",
                "description": "Validate model with test data",
                "expectedOutput": "Validation results with accuracy metrics",
                "notes": "Tests model against known test cases"
              },
              {
                "command": "sudo ai-trainer validate --test-data test_commands.json --threshold 0.90",
                "description": "Validate with custom accuracy threshold",
                "expectedOutput": "Pass/fail validation with 90% threshold",
                "notes": "Default threshold is 0.85"
              },
              {
                "command": "sudo ai-trainer validate --test-data test_commands.json --database custom.db --json",
                "description": "Validate with custom DB and JSON output",
                "expectedOutput": "JSON-formatted validation metrics",
                "notes": "Structured validation results"
              },
              {
                "command": "sudo ai-trainer validate --test-data tests.json --threshold 0.90 --database custom.db --json",
                "description": "Validate with all parameters combined",
                "expectedOutput": "JSON validation with custom test data, 90% threshold, and custom DB",
                "notes": "Full parameter example for CI/CD pipelines"
              }
            ]
          },
          {
            "id": "4_model_export",
            "title": "Model Export",
            "description": "Export trained models and statistics",
            "examples": [
              {
                "command": "sudo ai-trainer export --output model_export.json",
                "description": "Export trained model",
                "expectedOutput": "Complete model export with embeddings",
                "notes": "Default format includes all embeddings"
              },
              {
                "command": "sudo ai-trainer export --output model_compact.json --format compact",
                "description": "Export in compact format",
                "expectedOutput": "Compact model export without full embeddings",
                "notes": "Reduces export file size"
              },
              {
                "command": "sudo ai-trainer export --output model_stats.json --format stats --json",
                "description": "Export statistics as JSON",
                "expectedOutput": "Model statistics without embeddings",
                "notes": "Lightweight statistics export"
              },
              {
                "command": "sudo ai-trainer export --output model.json --format full --json",
                "description": "Full export with JSON envelope output",
                "expectedOutput": "Complete model export with JSON status envelope",
                "notes": "Combines full embeddings export with structured output"
              }
            ]
          },
          {
            "id": "5_snapshots",
            "title": "Snapshots",
            "description": "Model versioning and snapshot management",
            "examples": [
              {
                "command": "sudo ai-trainer snapshot --snapshot-version 1.0.0",
                "description": "Create model snapshot with version",
                "expectedOutput": "Versioned snapshot created successfully",
                "notes": "Preserves model state at specific version"
              },
              {
                "command": "sudo ai-trainer list-snapshots",
                "description": "List all model snapshots",
                "expectedOutput": "List of saved model versions",
                "notes": "Shows snapshot metadata and versions"
              },
              {
                "command": "sudo ai-trainer list-snapshots --json",
                "description": "List snapshots as JSON",
                "expectedOutput": "JSON-formatted snapshot listing",
                "notes": "Structured snapshot information"
              },
              {
                "command": "sudo ai-trainer snapshot --snapshot-version 1.0.0 --json",
                "description": "Create snapshot with JSON output",
                "expectedOutput": "JSON with snapshot name, version, and embedding count",
                "notes": "Structured output for automation"
              }
            ]
          },
          {
            "id": "6_download",
            "title": "Model Download",
            "description": "Download ONNX and GGUF model files for AI engine tiers",
            "examples": [
              {
                "command": "sudo ai-trainer download-model",
                "description": "Download ONNX embeddings model to default models/ directory",
                "expectedOutput": "Model files downloaded successfully",
                "notes": "Downloads all-MiniLM-L6-v2 ONNX model and tokenizer"
              },
              {
                "command": "sudo ai-trainer download-model --llm",
                "description": "Download default GGUF model (Qwen2.5-3B-Instruct Q4_K_M, ~1.8GB)",
                "expectedOutput": "GGUF model downloaded to models/ directory",
                "notes": "Best balance of quality, speed, and size for CPU inference"
              },
              {
                "command": "sudo ai-trainer download-model --llm small",
                "description": "Download small GGUF model (Qwen2.5-1.5B, ~0.9GB)",
                "expectedOutput": "Small GGUF model downloaded",
                "notes": "For systems with <4GB available RAM"
              },
              {
                "command": "sudo ai-trainer download-model --llm large",
                "description": "Download large GGUF model (Phi-3.5-mini, ~2.3GB)",
                "expectedOutput": "Large GGUF model downloaded",
                "notes": "Better reasoning, 128K trained context"
              },
              {
                "command": "sudo ai-trainer download-model --all",
                "description": "Download both ONNX embeddings and default GGUF model",
                "expectedOutput": "All model files downloaded",
                "notes": "Complete setup for all AI tiers"
              },
              {
                "command": "sudo ai-trainer download-model --show-models",
                "description": "List downloaded and available models",
                "expectedOutput": "Model inventory with sizes and status",
                "notes": "Shows what's installed and what can be downloaded"
              },
              {
                "command": "sudo ai-trainer download-model --show-models --json",
                "description": "Model inventory as JSON",
                "expectedOutput": "JSON with downloaded and available model details"
              },
              {
                "command": "sudo ai-trainer download-model --force",
                "description": "Force re-download of ONNX model",
                "expectedOutput": "Model files re-downloaded",
                "notes": "Overwrites existing files"
              }
            ]
          },
          {
            "id": "7_status",
            "title": "Status",
            "description": "Model status and health checks",
            "examples": [
              {
                "command": "sudo ai-trainer status",
                "description": "Show training status",
                "expectedOutput": "Current model status and statistics",
                "notes": "Displays model readiness and metrics"
              },
              {
                "command": "sudo ai-trainer status --json",
                "description": "Show training status as JSON",
                "expectedOutput": "JSON-formatted status information",
                "notes": "Structured status output for automation"
              }
            ]
          },
          {
            "id": "8_ai_tiers",
            "title": "AI Tier Integration",
            "description": "Training operations related to the 6-tier AI engine (TF-IDF, ONNX, Mistral.rs, GenAI/Ollama, Legacy LLM, Claude)",
            "examples": [
              {
                "command": "sudo ai-trainer validate --test-data tests.json --json",
                "description": "Validate model against all tier responses",
                "expectedOutput": "Validation results covering all active AI tiers",
                "notes": "Tests model accuracy across available tiers"
              },
              {
                "command": "sudo ai-trainer train --data commands.json --json",
                "description": "Train model with feedback from all tiers",
                "expectedOutput": "Training metrics including multi-tier feedback data",
                "notes": "Includes feedback from mistral.rs and GenAI tier executions"
              }
            ]
          },
          {
            "id": "9_intent_classifier",
            "title": "ONNX Intent Classifier",
            "description": "Evaluate the ONNX intent classifier used for fast-path routing (12 categories, <5ms inference)",
            "examples": [
              {
                "command": "sudo ai-trainer validate --test-data intent_tests.json --json",
                "description": "Evaluate ONNX intent classifier accuracy",
                "expectedOutput": "JSON with per-intent precision, recall, and F1-score",
                "notes": "Target: 95%+ accuracy on held-out test set"
              },
              {
                "command": "sudo ai-trainer download-model --show-models --json",
                "description": "Check if intent classifier model is downloaded",
                "expectedOutput": "JSON showing classifier model status",
                "notes": "Model: kodachi-intent-classifier.onnx (~65MB)"
              }
            ]
          }
        ],
        "quickReference": [
          "sudo ai-trainer --help",
          "sudo ai-trainer --version",
          "sudo ai-trainer --info --json",
          "sudo ai-trainer --examples --json"
        ]
      },
      "errors": [],
      "warnings": [],
      "metadata": {
        "executionTime": 0,
        "hostname": "Boardroom-System",
        "user": "kodachi"
      }
    }
  }
}
