Artificial Lifeform Intelligent Entity โ terminal-native AI agent orchestrator
Project description
๐ค ALFIE CLI
Artificial Lifeform Intelligent Entity
A terminal-native AI agent orchestrator that plans, executes, monitors, and self-heals shell-level tasks using LLM reasoning.
What is ALFIE?
ALFIE bridges the gap between AI that talks and AI that works. Instead of just generating code or giving advice, ALFIE takes control of your terminal โ planning multi-step shell workflows as directed acyclic graphs (DAGs), executing them with real process management, monitoring output in real time, and recovering from failures automatically.
Give it an intent in plain English โ it breaks it into tasks, orders them by dependencies, runs them in parallel where possible, and reports back.
Key Features
- Natural Language โ Execution Plans โ Describe what you want; ALFIE's LLM planner generates a fully structured DAG of shell commands
- DAG Scheduler โ Topological sorting, dependency tracking, parallel execution across a pane pool
- Multi-Model Support โ Works with OpenAI, Anthropic, and Google models via the Vercel AI Gateway
- Interactive Chat โ Multi-turn REPL with conversation memory and auto-execution of detected plans
- Watcher Engine โ Real-time pane monitoring with state classification (idle / running / error / stuck / interactive)
- Safety Guard โ Command blocklist, confirmation prompts for destructive operations, configurable safety policies
- OS-Aware โ Detects Windows/Linux/macOS and generates platform-appropriate commands (PowerShell on Windows, bash on *nix)
- Session Memory โ Persistent conversation history with per-session storage, trimming, and recall
- Dry Run Mode โ Validate and safety-check plans without executing anything
- Rich Terminal UI โ Beautiful tables, panels, spinners, and live-updating displays via Rich
Installation
pip install alfie-cli
Or install from source:
git clone https://github.com/p-typed/alfie-cli.git
cd alfie-cli
pip install -e ".[dev]"
Requirements
- Python 3.11+
- An API key for the Vercel AI Gateway (supports OpenAI, Anthropic, Google models)
Configuration
Set your API key as an environment variable:
# PowerShell (Windows)
$env:AI_GATEWAY_API_KEY = "your-api-key"
# Bash / Zsh (Linux / macOS)
export AI_GATEWAY_API_KEY="your-api-key"
Or create a .env file in your project root:
AI_GATEWAY_API_KEY=your-api-key
Quick Start
# Check ALFIE is installed
alfie version
# Verify system requirements
alfie doctor
# Run a task from natural language
alfie run "create a hello.txt file that says hello world"
# Run a multi-step task
alfie run "find all python files, count lines of code, and write a summary to report.txt"
# Use a specific model
alfie run "list system info" --model anthropic/claude-sonnet-4-20250514
# Dry-run to validate without executing
alfie run "delete temp files" --dry-run
Commands
alfie run
Execute a task from natural language or a JSON plan file.
# Natural language intent
alfie run "install dependencies and run tests"
# From a saved plan file
alfie run "deploy" --plan ./my-plan.json
# Dry-run mode โ validate safety without executing
alfie run "rm -rf /tmp/old" --dry-run
# Specify a model
alfie run "gather system specs" --model google/gemini-2.5-flash
How it works:
- Your intent is sent to the LLM planner
- The planner returns a structured DAG of tasks with dependencies
- The DAG scheduler topologically sorts tasks and executes them layer by layer
- Results are displayed in a rich summary table
alfie chat
Interactive multi-turn conversation with auto-execution of plans.
# Start a new chat session
alfie chat
# Resume a previous session
alfie chat --session abc123
# Use a different model
alfie chat --model anthropic/claude-sonnet-4-20250514
Chat commands:
| Command | Description |
|---|---|
/clear |
Clear conversation history |
/info |
Show session info |
/exit |
Quit (or press Ctrl+C) |
When you ask ALFIE to do something in chat, it automatically generates and executes a plan โ no extra confirmation needed.
alfie memory
Manage conversation memory across sessions.
# List all saved sessions
alfie memory list
# Show a specific session
alfie memory show <session-id>
# Delete a session
alfie memory delete <session-id>
# Clear all sessions
alfie memory clear
alfie watch
Monitor a running tmux session in real time.
# Watch a tmux session
alfie watch my-session
# Custom poll interval and timeout
alfie watch my-session --poll 5 --timeout 600
alfie doctor
Check system requirements and configuration.
alfie doctor
Shows status of Python version, tmux availability, API key configuration, and more.
alfie config
Display the current configuration as JSON.
alfie config
Other Commands
| Command | Description |
|---|---|
alfie version |
Show ALFIE version |
alfie status |
Check status of current session |
alfie kill |
Emergency stop โ kill all running tasks |
alfie history |
Show past sessions |
alfie logs |
Tail audit log |
Supported Models
ALFIE works with any model available through the Vercel AI Gateway. Tested models include:
| Provider | Model | Flag |
|---|---|---|
| OpenAI | GPT-4o Mini (default) | --model gpt-4o-mini |
| OpenAI | GPT-4o | --model gpt-4o |
| Anthropic | Claude Sonnet 4 | --model anthropic/claude-sonnet-4-20250514 |
| Gemini 2.5 Pro | --model google/gemini-2.5-pro |
|
| Gemini 2.5 Flash | --model google/gemini-2.5-flash |
|
| Gemini 2.0 Flash | --model google/gemini-2.0-flash |
Python API
ALFIE can be used as a library in your own Python code:
from alfie.planner import Planner
from alfie.scheduler.dag import TaskScheduler, PanePool, topological_sort
from alfie.models import Plan
# Generate a plan from natural language
planner = Planner(model="gpt-4o-mini")
plan = planner.generate("install numpy and run a quick benchmark")
# Inspect the plan
for task in plan.tasks:
print(f"{task.id}: {task.cmd} (depends on: {task.depends_on})")
# Use the DAG scheduler
layers = topological_sort(plan.tasks)
print(f"Execution will proceed in {len(layers)} layers")
Async Support
import asyncio
from alfie.planner import Planner
async def main():
planner = Planner(model="gpt-4o-mini")
plan = await planner.agenerate("check disk usage and memory stats")
for task in plan.tasks:
print(f"{task.id}: {task.cmd}")
asyncio.run(main())
Memory Store
from alfie.memory.store import MemoryStore
# Create or resume a session
mem = MemoryStore(session_id="my-session")
mem.add("user", "Hello ALFIE")
mem.add("assistant", "Hello! How can I help?")
# Get messages for LLM context
messages = mem.get_context_messages(system_prompt="You are ALFIE.")
# List all sessions
for session in mem.list_sessions():
print(session)
Architecture
alfie/
โโโ cli.py # Typer CLI โ all user-facing commands
โโโ config.py # Pydantic configuration (TOML-backed)
โโโ models.py # Domain models โ Task, Plan, Session, etc.
โโโ planner/
โ โโโ base.py # System prompt + JSON schema for structured output
โ โโโ client.py # OpenAI SDK wrapper โ Vercel AI Gateway
โ โโโ planner.py # LLM planning engine with retry + DAG validation
โโโ scheduler/
โ โโโ dag.py # Topological sort, PanePool, TaskScheduler
โโโ watcher/
โ โโโ engine.py # Real-time pane monitoring + state classification
โโโ memory/
โ โโโ store.py # JSON-backed conversation persistence
โ โโโ prompts.py # Chat system prompt (OS-aware)
โโโ events/
โ โโโ bus.py # Pub/sub event bus
โโโ safety/
โ โโโ guard.py # Command validation + blocklist
โโโ tmux/
โโโ session.py # tmux session/pane wrappers
Execution Flow
User Intent (natural language)
โ
โผ
โโโโโโโโโโโโโโโ
โ LLM Planner โ โ Vercel AI Gateway (OpenAI / Anthropic / Google)
โโโโโโโโฌโโโโโโโ
โ structured JSON plan (DAG)
โผ
โโโโโโโโโโโโโโโ
โ Safety Guard โ โ blocklist check, confirmation prompts
โโโโโโโโฌโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โ DAG Scheduler โ โ topological sort โ layer-by-layer execution
โโโโโโโโฌโโโโโโโโ
โ parallel task dispatch
โผ
โโโโโโโโโโโโโโโโ
โ Executor โ โ subprocess (PowerShell on Windows, bash on *nix)
โโโโโโโโฌโโโโโโโโ
โ stdout/stderr
โผ
โโโโโโโโโโโโโโโโ
โ Watcher โ โ state classification, timeout detection, recovery
โโโโโโโโโโโโโโโโ
Development
# Clone the repo
git clone https://github.com/p-typed/alfie-cli.git
cd alfie-cli
# Create a virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/macOS
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check src/ tests/
Running Tests
# Run all 172 tests
pytest
# Run with verbose output
pytest -v
# Run a specific test file
pytest tests/test_scheduler.py
# Run a specific test
pytest tests/test_planner.py -k "test_generate_simple"
Roadmap
- Phase 0 โ Foundation (CLI, config, models, events, safety)
- Phase 1 โ Watcher Engine (real-time pane monitoring)
- Phase 2 โ DAG Scheduler (topological sort, parallel execution)
- Phase 3 โ LLM Planner (Vercel AI Gateway integration)
- Memory & Chat โ Persistent conversations + interactive REPL
- Phase 4 โ Real tmux executor (full process management)
- Phase 5 โ Persistent storage (aiosqlite session history)
- Phase 6 โ Re-planning (automatic failure recovery via LLM)
- Phase 7 โ Polish (documentation, packaging, CI/CD)
License
MIT โ see LICENSE.
Built by P-Typed Research Labs
ALFIE doesn't just plan โ it executes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alfie_cli-0.0.1.tar.gz.
File metadata
- Download URL: alfie_cli-0.0.1.tar.gz
- Upload date:
- Size: 57.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2502be6f2898bd6c5fe601b9626af595d2eae39e305c583aea0b6d4ae952da55
|
|
| MD5 |
184c856e521670ded2a0dbcae49dc720
|
|
| BLAKE2b-256 |
e789b86c66f5bb22467575d71f66e98782628b3e9ac556f69c1e1e93e888c03f
|
File details
Details for the file alfie_cli-0.0.1-py3-none-any.whl.
File metadata
- Download URL: alfie_cli-0.0.1-py3-none-any.whl
- Upload date:
- Size: 41.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00833bc43ea3d5716213d6eaa88bcb4e140744275420c464fe2b4ada3791d4c4
|
|
| MD5 |
4354405b375240faed3ab3f0c073aa70
|
|
| BLAKE2b-256 |
6ead69878b336ae3f529cb415d6cdad03596b9dd07e6024ae6ad5253ac297094
|