Skip to main content

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.

PyPI License: MIT Python 3.10+

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 (30 Seconds)

1. Install

pip install darkzloop

2. Configure (No API Keys Needed!)

Tell Darkzloop which tool to drive:

# If you have Claude Pro/Enterprise
darkzloop config native claude

# If you have GitHub Copilot
darkzloop config native gh-copilot

# If you want 100% local/offline (Llama 3, DeepSeek)
darkzloop config native ollama

3. Verify

Ensure your tools are reachable:

darkzloop doctor
# โœ“ Executor: SHELL
# โœ“ Command: claude
# โœ“ Authenticated: user@example.com

4. Fix Code

Run the "Fast Lane" command to fix bugs without ceremony:

darkzloop fix "Add a retry mechanism to the payment webhook"

๐Ÿ›ก๏ธ 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

๐Ÿ› ๏ธ Full Workflow

Initialize a Project

cd my-rust-project
darkzloop init
# โœ“ Detected: Rust (Cargo.toml)
# โœ“ Created: darkzloop.json
# โœ“ Created: DARKZLOOP_SPEC.md

Darkzloop auto-detects your stack and configures appropriate quality gates:

  • Rust: cargo check, cargo test, cargo clippy
  • Python: pytest, ruff, black
  • Node: npm test, eslint
  • Go: go build, go test, golangci-lint

Plan a Feature

darkzloop plan --task "Add rate limiting to the API endpoints"
# Semantic expansion: rate โ†’ [throttle, limit, 429, quota, bucket]
# Found relevant files: src/middleware/auth.rs, src/api/handlers.rs

Execute with Oversight

darkzloop run --attended
# FSM State: PLANNING โ†’ EXECUTING โ†’ TESTING โ†’ DONE
# โœ“ All gates passed
# โœ“ Created commit: "feat: Add rate limiting middleware"

One-Shot Fixes (Fast Lane)

darkzloop fix "Login button not responding on mobile"
# โ†’ Searches codebase semantically
# โ†’ Generates temporary spec
# โ†’ Executes fix
# โ†’ Runs tests
# โ†’ Done in one command

๐Ÿ“ฆ 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

Global Config (~/.darkzloop/config.json)

{
  "agent": {
    "mode": "shell",
    "command": "claude",
    "args": ["--print"]
  },
  "default_attended": true,
  "default_auto_commit": true
}

Project Config (./darkzloop.json)

{
  "project": { "name": "my-api", "type": "rust" },
  "gates": {
    "tier1": { "commands": ["cargo check", "cargo test"] },
    "tier2": { "commands": ["cargo clippy"], "auto_fix_commands": ["cargo fmt"] }
  },
  "loop": {
    "max_iterations": 100,
    "max_consecutive_failures": 3,
    "max_task_retries": 3
  }
}

๐Ÿ“Š Commands

Command Description
darkzloop init Initialize project with auto-detected stack
darkzloop plan Generate execution plan from spec or task
darkzloop run Execute plan with FSM control
darkzloop fix "..." One-shot fix without manual spec
darkzloop status Show current loop state
darkzloop graph Visualize task DAG
darkzloop config native <tool> Configure native CLI backend
darkzloop config api <provider> Configure direct API backend
darkzloop doctor Verify environment and configuration

๐Ÿšจ Safety Features

Darkzloop is designed to never lose your work:

  1. Git Clean Check: Warns before running with uncommitted changes
  2. Backup Branches: Creates darkzloop-backup-YYYYMMDD-HHMMSS before execution
  3. Dry Run Mode: --dry-run shows what would happen without executing
  4. Attended Mode: Requires approval at each major step
  5. Read-Before-Write: Cannot modify files not explicitly loaded into context
  6. 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:

  1. Spec: Define what you want (the "Pin")
  2. Plan: Break it into tasks with dependencies (DAG)
  3. Execute: Let the agent work within strict boundaries
  4. Verify: Run tests before accepting any change
  5. 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 config native claude && darkzloop fix "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

darkzloop-0.6.0.tar.gz (97.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

darkzloop-0.6.0-py3-none-any.whl (99.6 kB view details)

Uploaded Python 3

File details

Details for the file darkzloop-0.6.0.tar.gz.

File metadata

  • Download URL: darkzloop-0.6.0.tar.gz
  • Upload date:
  • Size: 97.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for darkzloop-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f912c83bed959d3f24d2503f5289757b20ac7724da52b0c2a0212d75d27cf2ed
MD5 c3d107828be7894c4ed8c1596825be69
BLAKE2b-256 34b266a5f1705793cbac8fec2d3e57cae04e5e837d23e5e33ce4c30d31ea578c

See more details on using hashes here.

Provenance

The following attestation bundles were made for darkzloop-0.6.0.tar.gz:

Publisher: publish.yml on darkzOGx/darkzloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file darkzloop-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: darkzloop-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 99.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for darkzloop-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a752ef3e766f52d5f8d739398e1aa83e978e7dfe177f7a1ddc28c17340cf60f
MD5 f34bd009d40ed6703659381885119c60
BLAKE2b-256 91239ff0ecd79e6dd5bb7ab4718530a6eb2f963f06d75ea44461850a040d33ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for darkzloop-0.6.0-py3-none-any.whl:

Publisher: publish.yml on darkzOGx/darkzloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page