Metadata-Version: 2.4
Name: anarchy-ai
Version: 1.1.1
Summary: ANARCHY - Local AI Shell with No Cloud Dependencies
Author-email: psfr4590-afk <psfr4590@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/psfr4590-afk/ANARCHY
Project-URL: Repository, https://github.com/psfr4590-afk/ANARCHY
Project-URL: Bug Tracker, https://github.com/psfr4590-afk/ANARCHY/issues
Project-URL: Package Index, https://pypi.org/project/anarchy-ai
Keywords: ai,llm,local,ollama,cli,shell
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.34.2
Requires-Dist: psutil>=5.9
Requires-Dist: rich>=13.0
Requires-Dist: cryptography>=48.0.0
Requires-Dist: numpy<3.0,>=2.2.6
Requires-Dist: llama-cpp-python<0.3.0,>=0.2.90
Requires-Dist: pyflakes
Requires-Dist: flake8
Provides-Extra: gpu
Requires-Dist: nvidia-ml-py; extra == "gpu"
Requires-Dist: GPUtil; extra == "gpu"
Provides-Extra: dev
Requires-Dist: pytest>=9.0.3; extra == "dev"
Requires-Dist: black>=26.5.1; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Dynamic: license-file

# ANARCHY — Local Windows AI Assistant

```
  ██████╗  ███╗  ██╗ █████╗ ██████╗  ██████╗ ██╗  ██╗ ██╗   ██╗
  ██╔══██╗ ████╗ ██║██╔══██╗██╔══██╗██╔════╝ ██║  ██║ ╚██╗ ██╔╝
  ███████║ ██╔██╗██║███████║██████╔╝██║      ███████║  ╚████╔╝
  ██╔══██║ ██║╚████║██╔══██║██╔══██╗██║      ██╔══██║   ╚██╔╝
  ██║  ██║ ██║ ╚███║██║  ██║██║  ██║╚██████╗ ██║  ██║    ██║
  ╚═╝  ╚═╝ ╚═╝  ╚══╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝    ╚═╝
```

**NO CLOUD. NO TELEMETRY. NO GODS. ONLY ZUL.**

ANARCHY is a fully local, offline-first AI assistant that runs entirely on your hardware. No API keys, no subscriptions, no data leaving your machine. It understands plain English — you don't use shell commands.

---

## What It Does

| Capability | Description |
|---|---|
| **Plain-language input** | Say "write a file to my desktop that says test" — no commands, no syntax |
| **Files & Code** | Read/write files, lint, explain, generate, refactor, search codebases |
| **Git & GitHub** | Status, diff, commit, push/pull, PRs, issues — all from natural language |
| **Desktop Automation** | See the screen, click, type, scroll, drag, manage windows — 5-tier permission system |
| **Windows UIA** | Element-level control of Win32/WPF/UWP apps by name/role — more reliable than pixel clicking |
| **Browser Control** | Chrome/Edge via Playwright CDP: navigate, click, fill forms, extract data |
| **System Settings** | Dark mode, brightness, Wi-Fi, power plan, volume — natural language, no menus |
| **Voice Input** | Whisper-powered push-to-talk, wake word detection (no cloud) |
| **Timers & Notifications** | "remind me in 30 minutes" — Windows toast + voice callback |
| **Task Scheduler** | Persistent Windows scheduled tasks that survive reboots |
| **AI & Memory** | Semantic RAG search, knowledge graph, multi-LLM routing, episodic memory |
| **Skills** | Reusable multi-step workflows: code review, security audit, browser tasks, dev setup |
| **MCP Server** | Exposes memory and skills to Claude Code, Cursor, and any MCP client |

---

## Install in One Command

### Windows (recommended)

Open PowerShell (`Win + R` → type `powershell` → Enter) and run:

```powershell
irm https://raw.githubusercontent.com/psfr4590-afk/ANARCHY/main/get-anarchy.ps1 | iex
```

Installs Git, Python 3.11, and Ollama automatically on a fresh machine. Nothing to pre-install.

> **GPU?** ANARCHY auto-detects NVIDIA/AMD and configures GPU acceleration.  
> **No GPU?** Runs on CPU. Works on any Windows 10/11 machine with 8 GB RAM.

### macOS / Linux

```bash
curl -fsSL https://raw.githubusercontent.com/psfr4590-afk/ANARCHY/main/get-anarchy.sh | bash
```

### Manual

```bash
git clone https://github.com/psfr4590-afk/ANARCHY.git
cd ANARCHY
py install.py        # Windows
python3 install.py   # macOS / Linux
```

---

## Launch

```bash
# Windows
cd %USERPROFILE%\anarchy && py launch.py

# macOS / Linux
cd ~/anarchy && python3 launch.py
```

On launch you get:
- **System tray icon** — right-click to approve/deny actions, toggle voice, open dashboard, exit
- **Global hotkey** `Win+Alt+Z` — focuses ANARCHY from anywhere on your desktop
- **Approval overlay** — native floating card replaces CLI prompts for all state-changing actions
- **ANARCHY>** REPL — type anything in plain English

---

## Optional Windows Features

Install these for the full native experience:

```powershell
# Native approval cards + system tray
pip install pystray pillow

# Global hotkeys
pip install keyboard

# Windows toast notifications
pip install win11toast

# Element-level Windows UIA control
pip install pywinauto

# Browser automation (Playwright)
pip install playwright && python -m playwright install chromium

# Wake word detection (hands-free)
pip install openwakeword sounddevice

# Timer voice announcements
pip install pyttsx3

# Semantic routing (smarter tool matching)
pip install sentence-transformers
```

---

## Plain Language Examples

ANARCHY understands what you mean — no shell syntax required:

```
write a file to my desktop that says test
show me what's in my downloads folder
analyze C:\Users\krash\Desktop\myproject
check the GPU temperature
open Chrome and go to github.com
click the OK button in the Settings window
set my screen to dark mode
remind me in 30 minutes
schedule a daily backup every night at midnight
git commit with a message about fixing the login bug
security review core/auth.py
```

---

## Key Commands

```
help                    Full command reference
status                  System health + subsystem dashboard
hw                      Live hardware snapshot (CPU / GPU / RAM)
models                  List all Ollama and GGUF models

# Voice
voice on / off          Enable / disable push-to-talk
voice listen            Record one utterance and transcribe

# Timers
timer start lunch 45m   Start a 45-minute countdown named "lunch"
timer list              Show all running timers
timer cancel lunch      Cancel a timer

# Windows Settings
windows_settings        Adjust display, audio, power, Wi-Fi via natural language

# Scheduler
schedule list           Show all scheduled tasks
schedule add <n> <interval> <prompt>   Create a scheduled task

# RAG / Code Search
index [path]            Index a directory for semantic search
ask <query>             Search your codebase in plain English

# Git
commit [--all] [-m msg] Auto-draft commit message from staged diff
commit-push             Commit → push → PR in one step
hooks install-anarchy   Install ANARCHY pre-commit hook

# Skills
skill list              List installed skills
skill install <url>     Install a skill from GitHub URL

# Blueprints
blueprint list          List saved workflows
blueprint run <name>    Replay a saved workflow

# Code Intelligence (LSP)
diagnose <file>         Run language server diagnostics
diagnose                List installed language servers

# Planning
plan <goal>             Generate + execute a multi-tool plan
perf                    Performance dashboard
```

---

## Permission System

All tool execution flows through a non-bypassable `AuditGateway`. Every action is checked against `config/permissions.json` — the single source of truth. A safety floor prevents critical tools from ever being manifested below their minimum tier.

**7 tiers:**

| Tier | Auto-execute | Confirmation | Examples |
|---|---|---|---|
| `SAFE` | ✓ Always | None | file_read, git_status, hardware_snapshot, timer |
| `CONFIRM` | ✗ | [y/N] prompt or overlay card | file_write, git_commit, windows_settings, browser |
| `HIGH_RISK` | ✗ | Must type "yes" | shell_exec, self_modify, kill_process |
| `T0_OBSERVE` | ✓ Always | None | screenshot, list_windows, clipboard_read |
| `T1_NAVIGATE` | ✓ in auto-mode | [y/N] in user-mode | mouse_move, window_focus |
| `T2_CONTROL` | ✗ | Always confirm | mouse_click, type_text, key_press |
| `T3_ELEVATE` | ✗ | Always confirm | clipboard_write, open_url, run_command |
| `T4_OVERRIDE` | ✗ | Double-confirm | force_close_window, system_lock, run_as_admin |

**Approval flow for every state-changing action:**
1. Gateway classifies the action and builds `ActionMetadata` (target, expected effect, rollback hint, diff)
2. Native overlay card shown (if display available) with full context
3. CLI fallback if no display
4. Human decision (approved/denied) recorded in `logs/security.jsonl`

**Unknown tools** default to `CONFIRM` — not SAFE. ANARCHY fails closed.

---

## Built-in Skills (14)

Invoke by describing what you want in plain English:

| Skill | What it does |
|---|---|
| `security_review` | Deep audit across 7 categories: injection, auth, secrets, crypto, dependencies, error handling, input validation |
| `code_review` | 6-dimension review: comment accuracy, test gaps, silent failures, type design, maintainability, simplification |
| `audit_repo` | Full repo audit: file tree, complexity hotspots, TODO search, git status |
| `refactor_repo` | Map structure, find hotspots, apply targeted edits with confirmation |
| `generate_documentation` | Auto-generate Markdown docs for all tools, skills, and workflows |
| `backup_project` | Hash, zip, and verify a full project backup |
| `run_diagnostics` | Full system diagnostic: hardware, processes, network, LLM, tool registry |
| `summarize_directory` | Human-readable summary of every file in a directory tree |
| `open_app` | Launch, focus, or close any Windows application |
| `system_tune` | Adjust display, audio, power plan, dark mode, Wi-Fi via natural language |
| `browser_task` | Multi-step browser workflows via Playwright |
| `setup_dev_env` | Clone repo → install deps → open in VS Code |
| `daily_brief` | Morning digest: hardware, health, recent activity, scheduled tasks |
| `dockerfile_review` | Security, size, and best-practice review for Dockerfiles |

---

## Tools (73)

ANARCHY ships 73 registered tools across 10 domains:

**Files:** `file_read`, `file_write`, `delete_file`, `list_dir`, `search_files`, `copy_file`, `move_file`, `rename_file`, `create_directory`, `delete_directory`, `zip_files`, `unzip_file`, `hash_file`, `file_metadata`

**Code:** `codegen`, `lint_code`, `code_explain`, `code_run`, `code_search`, `code_refactor`, `code_test_generate`

**Git / GitHub:** `git_status`, `git_log`, `git_diff`, `git_commit`, `git_push`, `git_pull`, `git_clone`, `git_checkout`, `git_branch_list`, `git_stash`, `github_list_repos`, `github_get_repo`, `github_list_issues`, `github_create_issue`, `github_comment_issue`, `github_pull_request_info`, `github_pull_request_review`, `repo_map`, `repo_search`, `repo_analyze`, `repo_refactor_plan`

**Desktop (T0–T4):** `screen_capture`, `screen_size`, `mouse_position`, `pixel_color`, `clipboard_read`, `list_windows`, `get_active_window`, `find_on_screen`, `mouse_move`, `mouse_scroll`, `window_focus`, `window_minimize`, `window_maximize`, `window_resize`, `window_move_pos`, `mouse_click`, `mouse_double_click`, `mouse_drag`, `type_text`, `key_press`, `key_hotkey`, `clipboard_write`, `window_close`, `open_url`, `force_close_window`, `system_lock`, `system_sleep`, `run_as_admin`, `input_block`

**Windows-native:** `windows_uia`, `windows_settings`, `win_notifications`, `timer`, `task_scheduler_tool`

**Browser:** `browser` (Playwright CDP — Chrome/Edge)

**App adapters:** `vscode`, `windows_settings`

**System:** `hardware_snapshot`, `system_diagnostics`, `system_info`, `network_info`, `battery_info`, `wifi_scan`, `bluetooth_scan`, `list_processes`, `kill_process`, `launch_app`, `open_file`, `shell_exec`

**Knowledge / AI:** `multi_llm_query`, `knowledge_query`, `kg_neighbors`, `kb_info`, `discover_tools`, `analyze_path`, `self_modify`

---

## Architecture

```
launch.py               Universal entry point — boots tray, overlay, hotkey, then REPL
install.py              Dependency installer + GPU detection
get-anarchy.ps1         Windows one-liner installer
get-anarchy.sh          Unix one-liner installer
mcp_server.py           MCP server (memory + skills over stdio)

core/
  app_context.py        Dependency injection hub (56 subsystems)
  gateway.py            Non-bypassable audit gateway — single policy source, 7 tiers
  cognition.py          NLP/NLU: intent, entities, SVO, coreference, dialogue state
  nlp_payload_extractor.py  Natural language → tool payload (location aliases, content extraction)
  routing_engine.py     Semantic + lexical tool/skill routing with confidence gating
  execution.py          Tool executor, plan executor, scheduler, sub-agents
  llm.py                Ollama + GGUF backend, model router, cache, token tracker
  memory_facade.py      Unified memory (FAISS vector + SQLite episodic + JSON KV)
  wake_word.py          openwakeword background listener (shared via AudioManager)
  audio_manager.py      Shared mic session — prevents wake word / voice conflicts
  workflow_engine.py    DAG workflow execution with conditional routing + retry
  dev_tools.py          LSP client (Python/TS/Rust/Go/C/Ruby/Lua/PHP), autodoc
  handlers/             REPL command handlers split by domain (11 files)

ui/
  approval_overlay.py   Rich floating approval card — diff viewer, effect + rollback
  tray.py               System tray icon with right-click menu
  hotkey_listener.py    Global Win+Alt+Z wake hotkey

tools/
  [73 tools]            Individual Python modules, one function each
  adapters/
    browser.py          Chrome/Edge via Playwright CDP
    vscode.py           VS Code CLI + UIA adapter
    windows_settings.py PowerShell-backed system settings

skills/                 14 Markdown skill definitions
config/
  permissions.json      Per-tool permission tiers (single policy source)
  config.json           Model, context, temperature, hardware profile
  sandbox.json          Allowed/blocked filesystem paths
  tools_manifest.json   Tool registry (73 tools)
memory/                 FAISS index, SQLite episodic DB, JSON store
models/                 Local GGUF files
```

---

## MCP Server

Exposes ANARCHY's vector memory and skills to any MCP-compatible client (Claude Code, Cursor, ChatOllama):

```bash
py mcp_server.py        # Windows
python3 mcp_server.py   # macOS / Linux
```

Add to Claude Code (`~/.claude/mcp.json`):
```json
{
  "anarchy": {
    "transport": "stdio",
    "command": "python3",
    "args": ["/path/to/anarchy/mcp_server.py"]
  }
}
```

---

## Models

Default: `llama3.2:3b` (fast, ~2 GB). Switch anytime:

```bash
ollama pull phi4:14b               # strong reasoning, 8 GB VRAM
ollama pull deepseek-coder-v2:16b  # best for code, 8 GB VRAM
ollama pull llama3.1:8b            # balanced, 5 GB VRAM
ollama pull mistral:7b             # solid general purpose
ollama pull phi3:mini              # tiny — works on 4 GB RAM
```

Set in `config/config.json`:
```json
{ "ollama_model": "deepseek-coder-v2:16b" }
```

GGUF fallback: place any `.gguf` file in `models/` and ANARCHY uses it when Ollama is offline.

---

## Requirements

- Python 3.10+
- [Ollama](https://ollama.com) (auto-installed by the one-liner)
- 8 GB RAM minimum (4 GB workable with phi3:mini)
- Windows 10/11 for native UI features; macOS/Linux for core REPL

Optional language servers for `diagnose`:
```bash
pip install pyright                                      # Python
npm install -g typescript-language-server typescript     # TypeScript/JS
rustup component add rust-analyzer                       # Rust
go install golang.org/x/tools/gopls@latest              # Go
sudo apt install clangd                                  # C/C++
npm install -g intelephense                              # PHP
```

---

## Configuration

`config/config.json` — model, context length, temperature, GPU layers, threads, hardware profile

`config/permissions.json` — per-tool permission tiers (the single policy source for the gateway)

`config/sandbox.json` — allowed and blocked filesystem paths

Secrets stored encrypted in `config/secrets.vault`:
```
secret set github_token ghp_yourtoken
secret set HF_TOKEN hf_yourtoken
```

---

## License

MIT — see [LICENSE](LICENSE)

---

*Built for people who want their AI to run on their machine, answer to nobody, and work anywhere.*
