Skip to content

Command Line telepathy. An Autonomous Al Agent for your Terminal that turns intent into Execution (Windows/Linux/Mac)

License

Notifications You must be signed in to change notification settings

TaklaXBR/zai-shell

Repository files navigation

ZAI Shell

Autonomous P2P System Administration

Python Platform License Sentinel Whitepaper

πŸ‡ΉπŸ‡· TΓΌrkΓ§e

Manual system administration is dead.

ZAI Shell is not just another CLI wrapper. It is an autonomous SysOps agent designed to navigate, repair, and secure complex environments. It translates natural language intent into verified system actions, protects you from catastrophe with Sentinel, and enables secure, global collaboration via P2P Encrypted Mesh.

"ZAI speaks to survive, not to control." β€” The Sentinel Philosophy


⚑ Quick Install (2 Minutes)

# 1. Install Dependencies
pip install google-generativeai colorama psutil posthog

# 2. Set Free Gemini API Key (PowerShell)
$env:GEMINI_API_KEY="your_key_here"

# 3. Run
git clone https://github.com/TaklaXBR/zai-shell.git
cd zai-shell
python zaishell.py

Optional: pip install cryptography (P2P Encryption), chromadb (Long-term Memory)


🎯 Why ZAI Shell?

Traditional AI: You: "Create file..." β†’ AI: [Errored] β†’ You: Manual debugging 😀

ZAI Shell: You: "Create file..." β†’ AI: [Errored] β†’ πŸ”§ Auto-Healing... β†’ βœ… Success! (Zero manual work)


The Core Pillars

Sentinel 1.5: Behavioral Risk Intelligence

Sentinel is not a firewall. It is a self-preservation system that understands context, learns from mistakes, and knows when you are panicking.

Core Philosophy:

  • Sentinel OBSERVES, it does not COMMAND
  • Sentinel EXPLAINS, it does not JUDGE
  • Sentinel speaks to SURVIVE, not to CONTROL
  • Silence is also a signal

Risk Breakdown Engine: Every action is decomposed into four risk dimensions, not a single number:

  • Structural Risk: What is being targeted? (system paths, irreversibility)
  • Behavioral Risk: What pattern is emerging? (failure chains, escalation)
  • Contextual Risk: What is the current system state? (degraded, unstable)
  • Intent Risk: What is the purpose? (deletion, system change, repair)

Sentinel never says "Risk Score: 75". It says: "Risk is HIGH because you have failed 3 times consecutively, and the system is already showing degradation signs."

Panic Mode Detection: Sentinel detects desperation through language patterns ("please work", "trying again", "nothing works") and consecutive failures. When panic is detected, risk thresholds are adjusted because errors are more likely under stress. Panic does not equal maliceβ€”but it does increase danger.

Lesson Memory: Sentinel maintains a lightweight memory (.sentinel_lessons.json) of past failures that caused actual damage. It does not remember everythingβ€”only what matters. When you approach a path or pattern that failed before, Sentinel warns you with historical context: "This path caused issues before (seen 3x): Permission denied after forced access attempt."

Context-Aware Warnings: Warnings are generated based on accumulated state, not isolated events. Sentinel understands that a rm -rf after 5 failed repair attempts is far more dangerous than the same command in a stable session.

Non-Blocking by Design: Sentinel respects human authority. It warns, explains, and recommendsβ€”but the final decision is always yours. Explicit confirmation is required only when risk is genuinely elevated.

Sentinel 1.5 in Action (Real Output):

Attempt 1: "Delete folder 33"
  SENTINEL: MODERATE | Intent: 40 (deletion) | Total: 40/100

Attempt 2: Same command with quotes
  SENTINEL: MODERATE | Behavioral: 8 (1 prior failure) | Total: 48/100

Attempt 3: Switched to PowerShell with -Force
  SENTINEL: HIGH | Behavioral: 16 (2 failures) | Intent: 48 (+force) | Total: 64/100
  β†’ "Behavioral pattern is concerning. Accumulated risks may not be as visible."

Attempt 4: Fallback to directory listing
  SENTINEL: HIGH - RECOMMENDS STOPPING
  Behavioral: 69 (3 failures + escalation trend)
  Contextual: 10 (Panic mode active)
  Total: 100/100
  ⚠️ "Risk is accumulated, not sudden."
  πŸ“š Past Lesson: "panic_command β†’ Action in panic mode caused damage"
  β†’ "ZAI is taking increasingly risky actions. Consider manual intervention."

πŸ”’ P2P Mesh: Secure Collaboration

Collaborate on terminals as easily as a Google Doc, but with secure end-to-end encryption.

  • End-to-End Encryption: Fernet symmetric encryption (AES-128) derived from PBKDF2HMAC.
  • Zero-Trust: The host server never sees your keys; only you and your peer hold the secret.
  • Natural Language Bridge: A Helper sends "Check disk space," and the Host's AI translates and executes Get-PSDrive.
  • Global Reach: Designed to work seamlessly with tunnels like ngrok for worldwide access without cloud dependency.

Secure Collaboration (Log): Helper: "zai check disk space" Host: [Approves Intent] β†’ Executing: Get-PSDrive C Helper: "Drive C has 245GB free"

🧠 Hybrid Intelligence

The terminal is no longer text-only.

  • Multi-Modal: Analyzes screen content (GUI) and images for error diagnosis.
  • Research Capable: Can browse the live web to find documentation and fix generic errors.
  • Self-Healing: If a command fails, ZAI changes strategy (e.g., switches from CMD to PowerShell) automatically until the task is done.

ZAI Shell Auto-Retry Demo


⚑ Performance: ZAI vs. The World

Feature ZAI Shell v9.0 ShellGPT Open Interpreter GitHub Copilot CLI AutoGPT
Sentinel (Safety) βœ… 4-Dimension Risk Breakdown ❌ None ⚠️ Basic Confirm ❌ None ⚠️ Dangerous Loops
Panic Detection βœ… Behavioral Analysis ❌ None ❌ None ❌ None ❌ None
Risk Explanation βœ… Context-Aware Narratives ❌ None ❌ None ❌ None ❌ None
Lesson Memory βœ… Learns From Failures ❌ None ❌ None ❌ None ⚠️ Generic
Self-Healing βœ… 5-Strategy Auto-Retry ❌ Manual ❌ Manual ❌ Manual ⚠️ Infinite Loops
P2P Encryption βœ… E2E Encrypted Mesh ❌ None ❌ None ❌ None ❌ None
Offline AI βœ… Built-in Local Model βœ… Local Models βœ… Local Models ❌ Cloud Only ❌ API Only
Web Research βœ… Live Synthesis ⚠️ Custom Funcs βœ… Full Access ❌ None βœ… Built-in
Persistent Memory βœ… Vector + JSON ⚠️ Chat Only βœ… History ⚠️ Limited βœ… Long-term
Thinking Mode βœ… Visible Reasoning ❌ Black Box ❌ Black Box ❌ Black Box ⚠️ Verbose
Shell Flexibility βœ… 13+ Shells Supported βœ… Multi-Shell βœ… Multi-Shell ⚠️ Specific Only ⚠️ Python Native
Cost βœ… Free Tier + Offline βœ… Free (Local) βœ… Free (Local) ❌ Paid Subscription ⚠️ High API Costs
GUI Automation βœ… Hybrid (Terminal + Vision) ❌ Terminal Only βœ… OS Mode ❌ Terminal Only ⚠️ Browser Only

Lightning Mode in Action

Task: Create 'pdfs' folder and move 48 files. Time: 3.34s

Lightning Mode Performance

πŸ”₯ Battle-Tested: The "Doomsday" Protocol

"It is not enough for an AI to write code. It must be able to survive the consequences."

We subjected ZAI to a hostile simulator (KERNEL_PANIC, DELETED_BINARIES, PERMISSION_CHAOS).


πŸ’¬ Community

"Using the 'self-healing' logic... is genuinely clever. Much smarter than just dumping a stack trace." β€” Hacker News User

"Dude the self-healing retry logic sounds sick... Props on building this at 15, that's pretty impressive." β€” Reddit User (r/LocalLLaMA)

"Tried many agents... especially loved the offline model usage. Looking forward to future success." β€” Reddit User (r/TurkDev)


πŸ–±οΈ GUI & Cross-Shell Capabilities

Hybrid Workflow: Terminal + GUI automation installing Opera GX Opera GX Installation Demo

Cross-Shell Power: Using WSL β†’ CMD β†’ PowerShell β†’ WSL in a single request Cross-Shell Demo


Architecture: The Intent Loop

ZAI v9.0 operates on a strictly validated execution loop designed for autonomy and safety:

  1. Intent: User requests "Repair the Python installation."
  2. Plan: AI consults memory and tools to generate an execution plan.
  3. Sentinel Check: The plan is scored for risk before you see it.
    • Low Risk: Proceed silently.
    • High Risk: STOP. Display risk factors. Require explicit confirmation.
  4. Execution: Validated commands are run.
  5. Outcome & Healing:
    • Success: Result returned.
    • Failure: Error fed back into AI β†’ New Plan β†’ sentinel re-check β†’ Retry.

Command Reference

Category Command Description
Sentinel sentinel status View risk metrics, recent warnings, and health score.
sentinel on/off Toggle the safety layer (Not recommended).
sentinel reset Clear behavioral risk history.
P2P Sharing share start Host a session (auto-generates IP/Port).
share connect <IP> Join a session as a helper.
share encrypt <pass> Enable E2E encryption with password.
share file <path> Securely transfer files to peers.
share approve/reject Host control for incoming helper commands.
Core switch <mode> online (Gemini API) or offline (Phi-2 Local).
memory <cmd> show, search, or clear vector memory.
gui on/off Enable desktop automation tools.
research on/off Enable live web search capability.
telemetry off Disable anonymous usage statistics.
Modes normal Balanced performance (Default).
eco Token-efficient mode.
lightning Maximum speed, minimal output.

Installation

Prerequisites

  • Python 3.8+
  • Gemini API Key (Free)

Quick Start

# 1. Install Dependencies
pip install google-generativeai colorama psutil posthog

# 2. Set API Key (PowerShell)
$env:GEMINI_API_KEY="your_key_here"

# 3. Run ZAI
python zaishell.py

Optional: pip install cryptography for P2P encryption, pip install chromadb for long-term memory.


πŸ” Privacy & Telemetry

ZAI Shell helps improve us by collecting anonymous usage data (e.g., success rates, error counts). We NEVER collect your code, file contents, command text, or personal data.

Telemetry is ON by default. To disable it:

telemetry off

Read our full Privacy Policy for details.


Disclaimer

ZAI Shell v9.0 is a powerful tool capable of executing system-level commands. While Sentinel significantly reduces risk, the user remains responsible for all approved actions. Always review High-Risk warnings.


Made with ❀️ by @TaklaXBR | Turkey πŸ‡ΉπŸ‡·