Skip to content
JchinonsoPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AIOS — Pluggable AI Shell (Ollama / OpenAI / Local)

AIOS (AI Operating Shell) is a command-line automation assistant that lets you interact with AI models to ask questions, generate step-by-step plans, and safely execute system commands — all from your terminal.

It's designed for developers, sysadmins, and power users who want AI-assisted automation without sacrificing safety.
You can run it locally using Ollama models (like llama3, llama3.1), connect to OpenAI APIs (GPT-4/4o, etc.), or use a Local stub for offline development and testing.

Instead of just answering questions, AIOS can:

  • Understand your goal (e.g., "Install a Python dev box").
  • Plan safe, ordered shell commands to achieve it.
  • Show you exactly what will be run (approval gate).
  • Enforce allowlists so only approved commands execute.
  • Stream results back to your terminal in real time.
  • Automatically detect operation modes (Check, Audit, Fix, Harden).
  • Provide intelligent recovery when commands fail.
  • Support combined operations (check, audit and fix).
  • Manage advanced workflows with templates and scheduling.

This makes it ideal for:

  • Troubleshooting — "What logs should I check if apps crash?"
  • System setup — "Install PostgreSQL and configure a new database."
  • Maintenance tasks — "Upgrade all system packages."
  • Security operations — "Check and fix system vulnerabilities."
  • Cross-platform automation — works on Linux, macOS, and Windows.

Example: Security Operations

You can use AIOS to perform comprehensive security operations.
For example, to check and fix system vulnerabilities:

./target/release/aishell plan "check and fix system vulnerabilities"

This automatically:

  1. Detects operation mode: Combined (Check → Fix)
  2. Shows safety warnings: Clear about system modifications
  3. Executes in phases: Analysis first, then remediation
  4. Provides recovery: Intelligent error handling and alternatives

Example: Advanced Workflow Management

For enterprise-grade security management:

# Apply security templates
./target/release/aishell apply --template "cis_ubuntu_20.04"

# Execute saved plans
./target/release/aishell apply --plan "security_audit_2024_08_23"

# Batch operations
./target/release/aishell apply --batch "plan1,plan2,plan3"

# Scheduled execution
./target/release/aishell apply --schedule "daily" --plan "vulnerability_scan"

Example 2

./target/release/aishell --backend=ollama plan "upgrade all system packages"

{
  "goal": "upgrade all system packages",
  "steps": [
    { "cmd": "sudo apt update", "why": "Fetch latest package info" },
    { "cmd": "sudo apt upgrade -y", "why": "Apply updates" }
  ],
  "risk": "low"
}

Highlights

  • aishell: Ask / Plan / Apply / Pkg commands
  • Smart Operation Modes: Automatic detection of Check, Audit, Fix, Harden operations
  • Combined Operations: Support for "check, audit and fix" workflows
  • Intelligent Recovery: AI-powered error recovery and alternatives
  • Advanced Workflow Management: Templates, scheduling, and batch operations
  • Pluggable backends via CLI (--backend=ollama|openai|local) or env (AIOS_BACKEND)
  • System snapshot via sysctlx for richer planning prompts
  • Streaming answers for Ask (disable with --no-stream)
  • Strict JSON for Plan (extracts JSON safely)
  • Integrated execution with Plan command (no separate Apply needed)
  • Advanced Apply for workflow management (templates, scheduling, batch)
  • Cross-platform executor: bash on Linux/macOS, PowerShell on Windows
  • Safety-first design with clear operation mode warnings
  • Config via .env (URL, model, timeout, backend)

Folder Structure

    aios_scaffold/
    ├── platform/           # OS & package manager detection
    ├── sysctlx/            # System probe tool (OS, CPU, Mem info)
    ├── aishell/            # Main CLI: Ask/Plan/Apply/Pkg
    │   ├── backend/        # Backend modules: ollama.rs, openai.rs, local.rs, mod.rs
    │   ├── cli.rs          # CLI arg parsing
    │   ├── commands.rs     # Command handlers
    │   ├── sysprobe.rs     # Integration with sysctlx
    │   ├── policy.rs       # Allowlist/policy checks
    │   ├── plan.rs         # Plan save/load structs
    │   └── shell.rs        # Cross-platform shell runner
    └── policies/           # Allowlist definitions

Quickstart

1) If using the Ollama backend, install & pull a model

ollama pull llama3.1

2) Build all workspace members

cargo build --release

3) Ensure sysctlx is on PATH (so aishell can call it)

export PATH="$PWD/target/release:$PATH"

4) Try it

./target/release/sysctlx os
./target/release/aishell ask "What logs should I check if apps crash?"
./target/release/aishell plan "install a Python dev box"  # executes immediately
./target/release/aishell plan "check system vulnerabilities"  # read-only analysis
./target/release/aishell plan "audit system security"  # install tools + analyze
./target/release/aishell plan "check and fix system vulnerabilities"  # combined operation

Switching Backends

CLI flag

./target/release/aishell --backend=ollama ask "Hello!"
./target/release/aishell --backend=openai ask "Hello!"
./target/release/aishell --backend=local  ask "Hello!"

Environment variable

export AIOS_BACKEND=openai
export OPENAI_API_KEY=sk-...
./target/release/aishell ask "Hello!"

Config (.env)

Common

AIOS_MODEL=llama3 AIOS_TIMEOUT_SECS=120

Backend selection

AIOS_BACKEND=ollama

Ollama

AIOS_OLLAMA_BASE_URL=http://127.0.0.1:11434

OpenAI

OPENAI_API_KEY=sk-...

Notes

  • Plans saved to: ~/.aios/plan.json
  • Execution logs: ~/.aios/history/*.log
  • Allowlist files: policies/allowlist.*.txt (only commands whose first token is allowed will run; sudo <allowed> is OK)
  • sysprobe step: calls sysctlx to embed live OS/CPU/Mem info in planning prompts.
    If sysctlx isn't found, planning still works—just without the snapshot.

New Features

  • Operation modes: Automatically detected from command keywords (check, audit, fix, harden)
  • Safety warnings: Clear indicators for operations that modify the system
  • Integrated execution: plan command now executes immediately, apply is for advanced workflows
  • Combined operations: Support for "check, audit and fix" workflows
  • Intelligent recovery: AI-powered error recovery and alternatives

Example

./target/release/aishell --backend=ollama plan "upgrade all system packages"

{
  "goal": "upgrade all system packages",
  "steps": [
    { "cmd": "sudo apt update", "why": "Fetch latest package info" },
    { "cmd": "sudo apt upgrade -y", "why": "Apply updates" }
  ],
  "risk": "low"
}

Cross-Platform Setup

macOS

    Install Rust
    `curl https://sh.rustup.rs -sSf | sh`

    Optional: Install Ollama
    `brew install ollama`

     Build
    `cd /path/to/aios`
    `cargo build --release`
    `export PATH="$PWD/target/release:$PATH"`

Windows (PowerShell)

    Install Rust (rustup-init.exe)

    Optional: Install Ollama for Windows

    cd C:\path\to\aios
    cargo build --release
    $env:Path = "$PWD\target\release;$env:Path"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages