Skip to main content

DSL-based intent execution system with iterative refinement, featuring AI-powered suggestions via Ollama, safe simulation, and automatic health validation.

Project description

ITERUN

DSL-based intent execution system with iterative refinement, ITERUN boundary, and AI-powered assistance

Python 3.11+ License: MIT

AI Cost Tracking

PyPI Version Python License AI Cost Human Time Model

  • ๐Ÿค– LLM usage: $1.9826 (12 commits)
  • ๐Ÿ‘ค Human dev: ~$462 (4.6h @ $100/h, 30min dedup)

Generated on 2026-06-06 using openrouter/qwen/qwen3-coder-next


Overview

ITERUN is a system that allows you to:

  1. Generate intents from prompts (LiteLLM / OpenRouter / Ollama) โ†’ iterun.yaml
  2. Define intents manually in YAML DSL (sekcja INTENT:)
  3. Simulate execution with dry-run planning
  4. Deploy services in Docker with optional contract verify (TestQL + retry loop)
  5. Get AI suggestions in the interactive shell (Ollama / LiteLLM)
  6. Execute safely with the ITERUN boundary (explicit approval when enabled)

One-liner (prompt โ†’ running service):

iterun generate "Create a REST API for user management" \
  -o generated/ --execute --verify

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  CLI / Web / SDK    โ”‚  โ† User interface
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Generator (LLM)     โ”‚  โ† prompt โ†’ iterun.yaml + intract + testql
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Parser / Validator  โ”‚  โ† DSL โ†’ IR
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Planner / Simulator โ”‚  โ† Dry-run โ†’ app.py, Dockerfile
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Executor (Docker)   โ”‚  โ† Deploy service
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Contract verify       โ”‚  โ† TestQL + expectations; retry on fail
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ session.json        โ”‚  โ† Full session log in generated/
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Quick Start

Installation

# Clone repository
git clone https://github.com/softreck/iterun.git
cd iterun

# Full setup (recommended)
make setup

# Editable install (recommended)
python3 -m venv venv && source venv/bin/activate
pip install -e ".[ai]"
cp .env.example .env

Configuration (.env)

Copy .env.example to .env and adjust:

# LLM for `iterun generate` (priority: --model > LLM_MODEL > DEFAULT_MODEL)
OPENROUTER_API_KEY=sk-or-...
LLM_MODEL=openrouter/deepseek/deepseek-v4-pro

# Local Ollama (shell suggest/chat fallback)
OLLAMA_BASE_URL=http://localhost:11434
DEFAULT_MODEL=llama3.2

# Server / execution
HOST=0.0.0.0
PORT=8080
SKIP_ITERUN_CONFIRMATION=true
CONTAINER_PORT=8000

Generate from prompt

source venv/bin/activate

# YAML only
iterun generate "Create a ping API" -o generated/

# Plan + artifacts
iterun generate "..." -o generated/ --run

# Docker + contract verify + repair loop
iterun generate "..." -o generated/ --execute --verify --max-verify-iterations 5

# Full JSON session log
iterun generate "..." -o generated/ --execute --verify --json

Output directory (generated/ by default) โ€” see Session artifacts.

AI Gateway Setup (Ollama)

# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Start and pull model
make ollama-start
make ollama-pull

# Or manually
ollama serve
ollama pull llama3.2

Using Makefile

make help          # Show all commands
make setup         # Full setup
make web           # Start web server
make shell         # Interactive shell
make execute       # Execute example intent
make test          # Run all tests
make ollama-models # List available models
make clean         # Clean temp files

Shell Interface

# Start interactive shell
make shell
# Or: python -m cli.main

# Generate + execute from prompt
make execute
# Or: iterun generate "$(cat examples/01-user-api/prompt.txt)" -o examples/01-user-api/generated/ --execute --verify

Interactive Shell Commands:

intent> new my-api          # Create new intent
intent> load iterun.yaml    # Load package (generated/iterun.yaml)
intent> plan                # Run dry-run
intent> suggest             # Get AI suggestions
intent> apply               # Auto-apply AI suggestions
intent> chat                # Chat with AI
intent> iterate             # Apply manual changes
intent> iterun                # Approve execution
intent> execute             # Execute approved intent
intent> show [json]         # Show current state
intent> models              # List AI models
intent> ai-health           # Check AI Gateway status
intent> help                # Show help
intent> exit                # Exit shell

Web Interface

# Start web server
python -m web.app

# Open browser at http://localhost:8080

AI Gateway

The AI Gateway uses LiteLLM for:

  • iterun generate โ€” cloud models via OpenRouter (OPENROUTER_API_KEY, LLM_MODEL)
  • Shell suggest / chat โ€” local Ollama (OLLAMA_BASE_URL, DEFAULT_MODEL)

Supported Models (โ‰ค12B parameters)

Model Size Description
llama3.2 3B Default - Fast and efficient
llama3.2:1b 1B Ultra lightweight
llama3.1:8b 8B Balanced performance
mistral 7B Fast inference
mistral-nemo 12B Best quality under 12B
gemma2 9B Google Gemma 2
gemma2:2b 2B Lightweight
phi3 3.8B Microsoft Phi-3
qwen2.5 7B Alibaba Qwen 2.5
codellama 7B Code generation
codegemma 7B Google CodeGemma
deepseek-coder 6.7B DeepSeek Coder

Configuration

Environment variables:

export OLLAMA_BASE_URL="http://localhost:11434"
export DEFAULT_MODEL="llama3.2"
export MAX_MODEL_PARAMS="12.0"

Package file: iterun.yaml

The canonical workspace filename is iterun.yaml (not intent.yaml). Full spec: docs/INTENT_DSL_SPEC.md.

INTENT:
  name: user-api
  goal: Create a REST API for user management

ENVIRONMENT:
  runtime: docker
  base_image: python:3.12-slim
  ports:
    - 8000

IMPLEMENTATION:
  language: python
  framework: fastapi
  actions:
    - api.expose GET /ping
    - api.expose GET /users
    - api.expose POST /users
    - api.expose DELETE /users/{id}

EXECUTION:
  mode: dry-run

Supported Actions

Action Format Description
api.expose api.expose METHOD /path Expose HTTP endpoint
db.create db.create table_name Create database table
db.add_column db.add_column table column type Add column to table
shell.exec shell.exec command Execute shell command
rest.call rest.call METHOD url Call external REST API
file.create file.create path Create file

API Reference

REST Endpoints

Method Endpoint Description
GET /api/intents List all intents
POST /api/intents/parse Parse DSL and create intent
GET /api/intents/{id} Get intent by ID
DELETE /api/intents/{id} Delete intent
POST /api/intents/{id}/plan Run dry-run
POST /api/intents/{id}/iterate Apply changes
POST /api/intents/{id}/iterun Approve for execution
POST /api/intents/{id}/execute Execute approved intent
GET /api/intents/{id}/code Get generated code
GET /api/schema JSON Schema for DSL
POST /api/intents/generate LLM โ†’ YAML
POST /api/intents/generate-and-run Generate + plan (+ optional execute)
POST /api/intents/validate-yaml Validate YAML document

AI Gateway Endpoints

Method Endpoint Description
GET /api/ai/status Check AI Gateway status
GET /api/ai/models List available models
POST /api/ai/complete Generate AI completion
POST /api/ai/chat Chat with AI
POST /api/intents/{id}/ai/suggest Get AI suggestions
POST /api/intents/{id}/ai/apply Auto-apply suggestions

Python API

from generator.pipeline import run_pipeline
from parser import parse_dsl
from planner import plan_intent
from sdk import IterunClient

# Prompt โ†’ full pipeline
result = run_pipeline(
    "Create a REST API for user management",
    output_dir="generated",
    execute=True,
    verify=True,
)
print(result.yaml_path)       # generated/iterun.yaml
print(result.verification)    # testql + HTTP result

# Or SDK
client = IterunClient()
out = client.generate_and_run("Create a ping API", output_dir="generated", execute=True)

# Manual DSL
ir = parse_dsl(open("generated/iterun.yaml").read())
plan = plan_intent(ir)
print(plan.generated_code)

Examples

Script Opis
./examples/run-all.sh 01โ€“08: prompt โ†’ iterun.yaml โ†’ plan
./examples/run-e2e.sh 09โ€“12: execute + TestQL + Intract
./examples/run-resilience.sh 13โ€“16: skrajne prompty, pฤ™tla naprawcza

Szczegรณล‚y: examples/README.md.

Session artifacts

Everything from one iterun generate run lands in --output-dir (default generated/):

File Content
iterun.yaml DSL package from LLM
session.json Full session โ€” prompt, generate attempts, plan, execute, verify
intract.yaml Intract contract manifest
service.testql.toon.yaml Auto-generated TestQL scenario
plan.result.json Plan logs + IR
execution.json Execute logs, endpoints, container id
container.log Docker logs (tail)
verify.result.json Contract verify result
verify.rounds.json Repair loop history (--verify)
app.py / Dockerfile Generated service

Testing

pytest
pytest tests/e2e/test_intent_generator.py -v
pytest tests/e2e/test_shell.py -v
pytest tests/e2e/test_web.py -v
pytest tests/e2e/test_ai_gateway.py -v

Project Structure

iterun/
โ”œโ”€โ”€ generator/          # LLM generate, pipeline, testql, intract, verify loop
โ”‚   โ”œโ”€โ”€ intent_generator.py
โ”‚   โ”œโ”€โ”€ pipeline.py
โ”‚   โ”œโ”€โ”€ contract_verify.py
โ”‚   โ””โ”€โ”€ session.py
โ”œโ”€โ”€ dsl/                # Pydantic schema for LLM validation
โ”œโ”€โ”€ ir/                 # Intermediate Representation
โ”œโ”€โ”€ parser/             # DSL parser
โ”œโ”€โ”€ planner/            # Dry-run simulator
โ”œโ”€โ”€ executor/           # Docker execution + HTTP validation
โ”œโ”€โ”€ ai_gateway/         # LiteLLM (Ollama + OpenRouter)
โ”œโ”€โ”€ cli/                # `iterun` CLI
โ”œโ”€โ”€ web/                # FastAPI web UI
โ”œโ”€โ”€ sdk/                # Python SDK client
โ”œโ”€โ”€ mcp/                # MCP server (optional)
โ”œโ”€โ”€ examples/           # prompt.txt + run.sh โ†’ generated/
โ”œโ”€โ”€ docs/               # DSL spec, docs index
โ”œโ”€โ”€ tests/e2e/
โ”œโ”€โ”€ config.py           # PACKAGE_FILENAME = "iterun.yaml"
โ””โ”€โ”€ README.md

Workflow

Prompt-first (recommended)

  1. Prompt โ†’ iterun generate "..." -o generated/
  2. Contracts โ†’ auto intract.yaml + service.testql.toon.yaml
  3. Plan โ†’ app.py, Dockerfile, plan.result.json
  4. Execute โ†’ Docker container
  5. Verify โ†’ TestQL + HTTP (--verify); retry with error context on failure
  6. Session โ†’ session.json aggregates all steps

Manual / interactive

  1. Edit iterun.yaml or use shell new / load
  2. Plan โ†’ dry-run
  3. Suggest / iterate โ†’ AI or manual refinement
  4. ITERUN โ†’ approve (unless SKIP_ITERUN_CONFIRMATION)
  5. Execute โ†’ deploy + endpoint validation

Documentation: docs/README.md ยท docs/INTENT_DSL_SPEC.md

Validation & Auto-Fix

After container deployment, the system automatically:

  1. Waits for container startup (configurable STARTUP_WAIT)
  2. Validates all exposed endpoints with HTTP requests
  3. Detects issues like connection refused, timeouts, HTTP errors
  4. Auto-fixes common problems:
    • Missing __main__ block
    • Wrong port configuration
    • Missing dependencies
  5. Restarts container with fixes
  6. Re-validates until success or max iterations reached

Configuration

# In .env
VALIDATE_AFTER_EXECUTE=true
AUTO_FIX_ENABLED=true
MAX_FIX_ITERATIONS=3
STARTUP_WAIT=2
VALIDATION_TIMEOUT=10

Example Output

Execution Logs:
  [12:38:55] Container started: 8f35e0a2fb27
  [12:38:55] Waiting 2s for container startup...
  [12:38:57] โœ“ http://localhost:8002 โ†’ 200
  [12:38:57] โœ“ http://localhost:8002/ping โ†’ 200
  [12:38:57] โœ“ http://localhost:8002/health โ†’ 200
  [12:38:57] โœ“ All endpoints validated successfully
โœ“ Execution completed in 2.56s

Validation:
  โœ“ All endpoints validated

API Endpoints

Method Endpoint Description
POST /api/intents/{id}/validate Validate running container
GET /api/containers/{id}/logs Get container logs

License

Licensed under Apache-2.0.

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

iterun-0.1.8.tar.gz (59.1 kB view details)

Uploaded Source

Built Distribution

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

iterun-0.1.8-py3-none-any.whl (63.0 kB view details)

Uploaded Python 3

File details

Details for the file iterun-0.1.8.tar.gz.

File metadata

  • Download URL: iterun-0.1.8.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for iterun-0.1.8.tar.gz
Algorithm Hash digest
SHA256 184931aa3ae00881f688b922cb9bcf26f7852dabe4b032ec17f86453af9a6018
MD5 fc978bddcc49486ff6d8ac37d8fca2c7
BLAKE2b-256 d436b403e5adfcd895e192bfd7e2eb17b01b67d82652ec2af89631b936bd148e

See more details on using hashes here.

File details

Details for the file iterun-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: iterun-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 63.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for iterun-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6310a6f06c6a66706aac83aeac8c1de272928259fa4dbc387966a7125f9fc467
MD5 40322d6e63e5d54168175fa326205fa1
BLAKE2b-256 d7aec2460ee42db6cad7c18b0fd4ac24fa6b5b44f87a8c17ed905cd52f3e1fb5

See more details on using hashes here.

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