Reliable. Autonomous. Model-Agnostic. Turn any LLM into a disciplined software engineer.
Project description
โพ๏ธ Darkzloop
Reliable. Autonomous. Model-Agnostic.
Stop hand-carrying cargo. Operate the locomotive.
Darkzloop is a terminal-based agent runner that turns any LLM into a rigorous software engineer. Unlike flaky chat agents, Darkzloop uses a Finite State Machine, Circuit Breakers, and Manifest Protocols to prevent hallucinations and infinite loops.
๐ฅ The Killer Feature: Bring Your Own Auth (BYOA)
Darkzloop doesn't need your API keys. It pipes context directly to the tools you're already logged into:
Claude CLI โข GitHub Copilot โข Ollama โข llm CLI โข Aider
โก Quick Start
1. Install
pip install darkzloop
2. Run
Navigate to your project and describe the task. Darkzloop auto-detects your stack.
darkzloop "Fix the retry logic in the webhook handler"
That's it. Darkzloop will:
- ๐ Detect your project type (Rust/Python/Node/Go)
- ๐ก๏ธ Create a safety backup branch
- ๐ Plan, Execute, and Test the fix using your project's own test suite
Optional: Verify Setup
darkzloop doctor
# โ Backend: claude
# โ Project: Python
# Tier 1: ['ruff check .']
# Tier 2: ['pytest -x']
๐ก๏ธ Why Darkzloop?
Most AI agents are just "loops in a while(true) block." They drift, hallucinate, and overwrite good code. Darkzloop is different:
| Feature | The Problem | The Darkzloop Solution |
|---|---|---|
| Manifest Protocol | Agent edits files blindly | Read-Before-Write: Writes blocked unless file is in context |
| Circuit Breakers | Agent tries the same wrong fix 10ร | Task Limits: Hard stop after 3 failed attempts per task |
| Tiered Gates | Agent breaks the build | Quality Control: Tests must pass before loop completes |
| Semantic Expansion | "Fix billing" misses src/invoice.rs |
Synonyms: Auto-expands intent to find relevant files |
| Git Safety | Agent overwrites uncommitted work | Backup Branches: Auto-creates restore points before execution |
๐ง Supported Backends
Darkzloop works with any tool that accepts text via stdin.
| Backend | Best For | Setup |
|---|---|---|
| Claude CLI | Complex refactors, high reasoning | darkzloop config native claude |
| Ollama | Privacy, offline, free | darkzloop config native ollama |
| GitHub Copilot | Quick fixes with Enterprise license | darkzloop config native gh-copilot |
| llm CLI | Universal adapter (50+ providers) | darkzloop config native llm |
| Direct API | Full control, streaming | darkzloop config api anthropic |
๐ ๏ธ Usage Examples
Quick Fix
darkzloop "Login button not responding on mobile"
With Backend Override
darkzloop "Add rate limiting" --backend ollama
Skip Safety Prompts (CI/CD)
darkzloop "Fix lint errors" --unattended
Check Environment
darkzloop doctor
Auto-detected quality gates by stack:
- Rust:
cargo checkโcargo test - Python:
ruff check .โpytest -x - Node:
npm run lintโnpm test - Go:
go build ./...โgo test ./...
๐ฆ Architecture
Darkzloop implements the Ralph Loop methodology with industrial-grade hardening:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DARKZLOOP CONTROL PLANE โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ FSM โโโโโถโ Manifest โโโโโถโ Gates โ โ
โ โ Engine โ โ Protocol โ โ (Tests) โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ โ โ โ
โ โผ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Semantic Expansion Layer โ โ
โ โ (Synonyms, Learning Glossary, Search) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Executor Layer โ
โ (Model-Agnostic) โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ
โ Claude โ โ Ollama โ โ API โ
โ CLI โ โ (Local) โ โ (SDK) โ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ
Finite State Machine
The FSM enforces strict state transitionsโno "hallucinated" jumps:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โ
โโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโ
โ IDLE โโโโโถโ PLANNING โโโโโถโ EXECUTING โโโโโถโ TESTING โโ
โโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโฌโโโโโโ
โ โ
โโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โโโโโโโโโโโค REMEDIATING โโโโโโโโ โ
โ โ โ (tests โ
โ โโโโโโโโโโโโโโโ failed) โ
โ โ โ
โ โ (fix applied) โ
โ โโโโโโโโโโโโโโโโโโโโโโ
โ
โ (max retries exceeded)
โผ
โโโโโโโโโโโ โโโโโโโโ
โ BLOCKED โ โ DONE โโโโ (tests passed)
โโโโโโโโโโโ โโโโโโโโ
| State | Description | Exit Condition |
|---|---|---|
| IDLE | Waiting for task | Plan approved |
| PLANNING | Agent generates plan | Plan validated |
| EXECUTING | Agent works on current task | Task complete |
| TESTING | Running tiered gates | Pass โ DONE, Fail โ REMEDIATING |
| REMEDIATING | Self-healing after test failure (max 3 retries per task) | Fix applied โ TESTING |
| BLOCKED | Circuit breaker tripped | Human intervention required |
| DONE | All tasks complete, all gates passed | โ |
Key Components
- FSM Engine: 7-state machine with strict transitionsโno skipping states
- Manifest Protocol: Tracks every file read/write, enforces read-before-write, user must approve sensitive file additions
- Circuit Breakers: Max iterations (100), consecutive failures (3), per-task retries (3)
- Semantic Layer: Expands search terms using local synonym matching + learning glossary (no external API calls, no data leaves your machine)
- Executor Interface: Pluggable backends via stdin/stdout protocol
The Manifest Protocol (Read-Before-Write)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MANIFEST RULES โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ Agent wants to READ src/api/users.rs โ
โ โ Allowed (adds to manifest automatically) โ
โ โ
โ โ Agent wants to WRITE src/api/users.rs (not in manifest) โ
โ โ BLOCKED: "Must read file before modifying" โ
โ โ
โ โ Agent wants to READ config/secrets.json โ
โ โ PROMPT: "Add sensitive file to manifest? [y/N]" โ
โ โ
โ โ Agent wants to WRITE src/api/users.rs (in manifest) โ
โ โ Allowed (file was previously read) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
This prevents the #1 agent failure mode: blindly overwriting files it hasn't seen.
Semantic Expansion
When you say darkzloop fix "billing issue", the semantic layer expands your intent:
Input: "billing"
โ
Synonyms: ["invoice", "payment", "charge", "subscription", "price"]
โ
Learned: ["stripe", "checkout"] (from project glossary)
โ
Search: Finds src/billing.rs, src/invoice.rs, src/stripe/webhook.rs
Implementation: Local dictionary + project-specific learning glossary stored in .darkzloop/glossary.json. No embeddings, no external callsโfast and private.
๐ง Configuration
Zero config by default. Darkzloop auto-detects everything.
Optional overrides via environment:
DARKZLOOP_BACKEND=ollama # Use Ollama instead of Claude
DARKZLOOP_MAX_ITER=5 # Limit iterations
๐ Commands
| Command | Description |
|---|---|
darkzloop "task" |
Run a fix or feature (main usage) |
darkzloop "task" --backend ollama |
Override LLM backend |
darkzloop "task" --unattended |
Skip safety prompts (for CI) |
darkzloop doctor |
Verify environment and configuration |
๐จ Safety Features
Darkzloop is designed to never lose your work:
- Git Clean Check: Warns before running with uncommitted changes
- Backup Branches: Creates
darkzloop-backup-YYYYMMDD-HHMMSSbefore execution - Dry Run Mode:
--dry-runshows what would happen without executing - Attended Mode: Requires approval at each major step
- Read-Before-Write: Cannot modify files not explicitly loaded into context
- Sensitive File Prompts: Asks permission before reading config/secrets
๐ฏ Philosophy
"The goal is not to build a smarter agent. It's to build a more disciplined one."
Darkzloop is based on the Ralph Loop methodology:
- Spec: Define what you want (the "Pin")
- Plan: Break it into tasks with dependencies (DAG)
- Execute: Let the agent work within strict boundaries
- Verify: Run tests before accepting any change
- Learn: Build project-specific vocabulary over time
The agent is powerful. The system keeps it honest.
๐ค Contributing
See CONTRIBUTING.md for guidelines.
git clone https://github.com/yourusername/darkzloop
cd darkzloop
pip install -e ".[dev]"
pytest
๐ License
MIT ยฉ 2025
Stop debugging your debugger. Start shipping.
pip install darkzloop && darkzloop "your bug here"
Project details
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 darkzloop-0.7.1.tar.gz.
File metadata
- Download URL: darkzloop-0.7.1.tar.gz
- Upload date:
- Size: 99.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d68ae91e86fdfee62c1dd305e4de0b0d47f1e7876f70afab9af04dd852931517
|
|
| MD5 |
1dfc1653f164da36b6b4855e9a5205b7
|
|
| BLAKE2b-256 |
a266323fe6c31b9084b0f95196fd7a1f8409cc7ab6ccb5b4ffcb0562d229cc05
|
File details
Details for the file darkzloop-0.7.1-py3-none-any.whl.
File metadata
- Download URL: darkzloop-0.7.1-py3-none-any.whl
- Upload date:
- Size: 102.8 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 |
d6ad3877e908c5cfb4c8fe310b4875aab8c89c830e30018a280b317cc41bc673
|
|
| MD5 |
b0bea3f3711cb4ee05496c9ad3c1d09d
|
|
| BLAKE2b-256 |
7a6559dc66aea8088564d2f9aab9b00d1e490468a0d48b3f8277213afa6b7d7a
|