Skip to content

Latest commit

 

History

History
292 lines (236 loc) · 15.4 KB

File metadata and controls

292 lines (236 loc) · 15.4 KB

SakeAI: Development Plan & Architectural Blueprint

1. Project Vision & Mission

1.1. The Problem

The open-source AI landscape is a chaotic frontier. While innovation is rapid, the user experience is fragmented and hostile. Developers and enthusiasts face significant hurdles:

  • Dependency Hell: Conflicting Python versions, CUDA drivers, and package requirements make running multiple tools a nightmare.
  • Complex Installations: READMEs are often cryptic, assuming expert-level knowledge and leading to frustrating, time-consuming setup processes.
  • Discovery Overload: Finding the right tool requires constant monitoring of social media and code repositories.
  • Configuration Sprawl: Managing API keys and settings across dozens of tools is insecure and inefficient.

1.2. Our Mission

SakeAI will be the Unified Command Center for AI. Its mission is to democratize access to powerful AI tools by abstracting away the complexities of installation, configuration, and management. We aim to make installing a complex agentic framework as simple as installing an app from an app store, empowering a new wave of creators and users.


2. Core Features & Concepts

2.1. The SakeAI Engine: Agentic Installation

This is the heart of the application. It provides two paths for installation:

  1. Manifest-Driven Installation: For maximum reliability, repositories can include a SakeAI.json file. This file provides a clear, step-by-step recipe for installation that SakeAI can execute perfectly.
  2. LLM-Powered Heuristic Engine: For any repository without a manifest, SakeAI's agentic capabilities shine. It will:
    • Clone the repository to a temporary location.
    • Scan the README, file structure, and key dependency files (requirements.txt, etc.).
    • Use a Large Language Model (LLM) to analyze this context and generate a probable SakeAI.json installation plan on the fly.
    • Present this generated plan to the user for review and approval before execution.

2.2. Flexible LLM Integration

The user is in complete control of how the Heuristic Engine "thinks." The settings panel will offer three distinct strategies:

  • Cloud API: The user provides their API key for services like OpenAI or Anthropic. SakeAI makes direct API calls.
  • Local API: For privacy and cost-savings, the user can point SakeAI to a local OpenAI-compatible server (e.g., Ollama, LM Studio).
  • Manual Web Chat: For users without API access or who prefer manual oversight, SakeAI will generate a perfectly crafted prompt. The user copies this prompt, pastes it into a web UI like ChatGPT or Claude, and then pastes the resulting JSON plan back into SakeAI to proceed.

2.3. System Intelligence & Sandboxing

To prevent system-wide conflicts and ensure successful installations, SakeAI will be intelligent about the user's environment.

  • System Scan: On first run (and via a manual "rescan" button), SakeAI will detect and save key system specs: OS, CPU, RAM, GPU (Vendor, VRAM, CUDA Version), and critical dependencies like ffmpeg.
  • Requirement Validation: Before any installation, SakeAI will compare the tool's requirements (from its SakeAI.json) against the user's system specs and warn about potential incompatibilities.
  • Isolated Environments: Every tool will be installed into its own sandboxed Conda environment. This is non-negotiable and is the core principle that guarantees zero dependency conflicts between tools.

2.4. Discovery Hub & Library

  • Discover Page: A central hub to find new tools, populated from multiple sources:
    • A curated sakeai_catalog.json file shipped with the app for vetted, high-quality tools.
    • A dynamic feed of popular tools from Hugging Face Spaces.
    • Tools added manually by the user.
  • Library Page: A clean interface to view and manage all installed applications. Users can launch, uninstall, and view the status of each tool.
  • Starring Tools: Users can "star" or "favorite" tools in their library for quick access. This will be a simple flag in the database.

2.5. App Catalogs (Kits)

This feature addresses the need for setting up complete workflows.

  • Concept: A user can install a "Kit," which is a collection of tools known to work well together (e.g., a "Voice Cloning Kit" with RVC, UVR, etc.).
  • Implementation: A Kit will be defined by a master JSON file that lists multiple GitHub URLs or SakeAI.json manifests. The installer will process these sequentially, potentially installing them into a shared, compatible Conda environment if specified by the Kit's configuration. This feature provides a powerful one-click setup for complex environments.

2.6. Universal Installation Agent (Expanded Heuristic Engine)

To truly generalize, SakeAI's agent must handle more than just Python scripts. Many powerful tools are distributed as binaries (.exe, .dmg, .appimage) via GitHub Releases. The Heuristic Engine will be expanded to become a Universal Installation Agent capable of understanding and executing these installations as well.

Core Logic:

  1. Comprehensive Analysis: When analyzing a repository, the agent will not only scan for requirements.txt but also:

    • Parse the README for instructions related to binary downloads and setup procedures (e.g., "Download the latest release," "Run the setup.exe," "Drag the .app to your Applications folder").
    • Query the GitHub API to inspect the "Releases" tab. It will look for assets that match the user's operating system.
  2. LLM-Powered Plan Generation: The LLM prompt will be enhanced to generate installation plans for these new scenarios. It will be instructed to identify:

    • The correct asset to download from the latest release.
    • Silent installation flags (e.g., /S, --silent) from the documentation to attempt an automated setup.
    • Standard installation procedures for different OSes (e.g., mounting a DMG on macOS).
  3. Human-in-the-Loop Interaction: The agent will recognize when it's uncertain. If an installer requires graphical interaction or presents an unknown prompt, the installation plan will include a step to pause and ask the user for help.

Expanded SakeAI.json Specification

To support this, the install_steps in the manifest will be expanded with new types.

Example: SakeAI.json for a hypothetical .exe installer

{
  "spec_version": "1.1",
  "source_type": "github",
  "source_url": "https://github.com/some-dev/ImageOptimizer",
  "name": "Image Optimizer Pro",
  "description": "A standalone tool for optimizing images.",
  "tags": ["image", "utility", "windows"],

  "system_requirements": {
    "os": ["windows"]
  },

  "install_steps": [
    {
      "type": "download_release",
      "version": "latest",
      "asset_name_pattern": "*.exe"
    },
    {
      "type": "user_prompt",
      "message": "The installer may ask for an installation directory. Please complete the graphical setup. Click 'Continue' in SakeAI when you are finished.",
      "expected_input": "confirmation"
    },
    {
      "type": "execute_binary",
      "file_pattern": "ImageOptimizer-*.exe",
      "args": ["/S"]
    }
  ],

  "launch": {
    "command": "C:\\Program Files\\ImageOptimizerPro\\ImageOptimizer.exe"
  }
}

New install_steps Types:

  • download_release: Downloads a specific file from a GitHub Release.
    • version: Can be "latest" or a specific tag like "v2.1.0".
    • asset_name_pattern: A glob pattern to find the correct file (e.g., *x64-installer.exe, *.AppImage).
  • execute_binary: Runs an executable file.
    • file_pattern: A glob pattern to find the downloaded executable.
    • args: An array of command-line arguments for silent installation. If omitted, the binary is run normally.
  • mount_dmg (macOS): Mounts a .dmg file to make its contents accessible.
  • copy_app (macOS): Copies a .app bundle from a mounted volume to the /Applications directory.
  • user_prompt: Pauses the installation and displays a dialog to the user. This is the core of the human-in-the-loop system.
    • message: The text to display to the user (e.g., "Please enter the license key," or "Please complete the setup wizard and click OK.").
    • expected_input: Defines what the agent needs. Can be "text", "path", or "confirmation".

3. Features Deferred (Post-V1)

To ensure a focused and achievable initial release, the following features are considered out of scope for V1. They are excellent candidates for future updates.

  • Library Organization (Folders/Bins): Adds significant UI complexity. A flat list is sufficient for V1.
  • Multi-App Tabbing: Launching tools is the V1 goal. Managing their processes and embedding their GUIs into tabs is a major undertaking.
  • Linking LLM Sites as Apps: A powerful concept that blends the line between a downloader and a browser. This requires QWebEngineView integration and is a distinct feature set from the core installation agent.

4. The SakeAI.json Manifest Specification

This file is the ground truth for installation. The LLM's goal is to generate a file that adheres to this spec.

Example: SakeAI.json for RVC-WebUI

{
  "spec_version": "1.0",
  "source_type": "github",
  "source_url": "https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI",
  "name": "RVC-WebUI",
  "description": "A web UI for Retrieval-based Voice Conversion, a popular open-source voice cloning tool.",
  "tags": ["audio", "voice-cloning", "tts", "rvc"],

  "system_requirements": {
    "os": ["windows", "linux"],
    "gpu": {
      "vendor": "nvidia",
      "vram_gb": 6,
      "cuda_version": "11.8"
    },
    "ram_gb": 16,
    "system_dependencies": ["ffmpeg"]
  },

  "install_steps": [
    { "type": "conda_create", "python_version": "3.10" },
    { "type": "pip_install", "file": "requirements.txt" },
    {
      "type": "download",
      "url": "https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt",
      "dest": "./"
    },
    { "type": "run_script", "file": "download_models.py" }
  ],

  "configuration": {
    "config_file": ".env",
    "format": "key_value",
    "keys": [{ "name": "OPENAI_API_KEY", "source": "vault_openai_api_key" }]
  },

  "launch": {
    "command": "python infer-web.py",
    "working_directory": "./"
  }
}

Key Explanations:

  • system_requirements: Used by SakeAI to validate user's system before installation.
  • install_steps: An ordered array of actions. Supported types: conda_create, pip_install (from file or package name), download, run_script.
  • configuration: (Future-proofing) Defines how to inject user's API keys into the tool's config files.
  • launch: The command to execute to start the application.

5. Technical Architecture & Project Structure

The project will follow a standard, professional structure separating backend logic from the user interface.

/
├── README.md                 # High-level project overview
├── requirements.txt          # Python dependencies for SakeAI itself
├── SakeAI.json               # Example manifest file for reference
└── sakedownloader/
    ├── README.md             # Detailed breakdown of the source structure
    ├── __init__.py
    ├── main.py               # Application entry point
    ├── core/
    │   ├── __init__.py
    │   ├── database.py       # Manages SQLite (library) and JSON (catalog)
    │   ├── discovery.py      # Fetches tools from Hugging Face, etc.
    │   ├── heuristic_engine.py # Clones repos and uses LLM to build install plans
    │   ├── installer.py      # Executes install plans (conda, pip, download)
    │   ├── llm_handler.py    # Interfaces with Cloud/Local/Manual LLMs
    │   ├── prompts.py        # Helper to load prompts from prompts.json
    │   ├── prompts.json      # Stores all prompts for the LLM
    │   └── system_info.py    # Gathers local hardware/software specs
    └── ui/
        ├── __init__.py
        ├── main_window.py    # The main PyQt6 application window and all pages
        └── style.qss         # A dark theme stylesheet for the application

5.1. Core Components (sakedownloader/core/)

  • database.py: Uses Python's sqlite3 for the tool library and json for the user-curated catalog. It will handle adding tools, updating their status (installing, installed, failed), and retrieving them.
  • system_info.py: Uses psutil for RAM/CPU, platform for OS, and subprocess to call nvidia-smi for GPU/CUDA details.
  • installer.py: The workhorse. It takes a SakeAI.json plan and uses subprocess to execute commands like conda create, conda run -n <env> pip install, etc. It is responsible for logging all output to the UI.
  • llm_handler.py: A class that takes user preferences and a context string. It contains the logic for all three LLM strategies, using requests for API calls.
  • heuristic_engine.py: The "agent." It uses GitPython to clone a repo into a temporary directory, reads the key files to build a context string, and then passes this to the LLMHandler to get an installation plan.

5.2. User Interface (sakedownloader/ui/)

  • main_window.py: A single, comprehensive file containing the QMainWindow and all QWidget pages. This simplifies state management for V1.
    • A primary QStackedWidget will switch between the main pages (Discover, Library, Add Tool, Settings).
    • A secondary QStackedWidget will manage the view, allowing the UI to switch from a main page (like Discover) to a DetailPage for a specific tool.
  • Responsiveness: All long-running operations (fetching data, analyzing repos, installing tools) must be run in a QThread to prevent the UI from freezing. Signals and slots (pyqtSignal) will be used to communicate results and progress back to the main UI thread.

6. User Flow for Heuristic Installation

This diagram illustrates the core agentic workflow when a user adds a GitHub URL that lacks a SakeAI.json manifest. Also shows how the agent can pause and request user input when it encounters an installation step it cannot automate, making the system far more robust.

graph TD
    subgraph "SakeAI Agent"
        A[User provides GitHub URL] --> H{Heuristic Engine Analysis};
        H --> I[Scan Repo & Releases];
        I --> J{Query LLM to generate install plan};
        J --> K[LLM generates plan (JSON)];
    end

    subgraph "User Interaction"
        K --> O{Present Plan for Approval};
        O -- Approve --> P[User clicks 'Install'];
        O -- Deny --> Q[Cancel];
    end

    subgraph "SakeAI Installer"
        P --> R{Start executing plan steps};
        R --> S{Next Step is 'user_prompt'?};
        S -- No --> T[Execute step automatically (download, pip, etc.)];
        T --> U{More steps?};
        U -- Yes --> R;
        S -- Yes --> V[Pause & Show Dialog to User];
    end

    subgraph "User Interaction"
        V --> W[User reads prompt & interacts with external installer];
        W --> X[User provides input/confirmation back to SakeAI];
    end

    subgraph "SakeAI Installer"
        X --> Y[Installer resumes with user input];
        Y --> U;
        U -- No --> Z[Installation Complete];
    end
Loading

7. Dependencies

The requirements.txt file will contain:

PyQt6
psutil
requests
huggingface-hub
markdown
Pygments
GitPython