-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
107 lines (89 loc) · 3.97 KB
/
main.py
File metadata and controls
107 lines (89 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
AutoDev AI — Self-Building Software Engineer Agent
===================================================
Usage
─────
python main.py "Build a URL shortener with analytics"
python main.py "REST API for a blog" --max-iter 8
python main.py "Chat app" --demo
python main.py "Todo app" --github --github-token ghp_xxx
python main.py --interactive
Agents
──────
🧠 Planner — adaptive-thinking architecture + JSON plan
🛠 Builder — writes all source files via tool calls
🔍 Critic — static code review BEFORE execution
📋 TestWriter — generates test spec early (test-driven debugging)
⚡ Executor — pip install → setup → run
🐛 Debugger — memory-augmented root-cause analysis + smarter escalation
🧪 Tester — runs the early test spec
🚀 Deployer — Dockerfile, README, .env.example
📦 GitAgent — git init + optional GitHub push
Flags
─────
--demo Cinematic mode: shows thinking blocks, dramatic pacing
--github Enable auto-push after deploy
--github-token GitHub personal access token (or set GITHUB_TOKEN env)
--max-iter N Max build→debug cycles (default 6)
--interactive Prompt for the idea
"""
from __future__ import annotations
import argparse
import os
import sys
def _check_api_key() -> None:
if not os.environ.get("ANTHROPIC_API_KEY", "").strip():
print(
"Error: ANTHROPIC_API_KEY not set.\n"
" export ANTHROPIC_API_KEY=sk-ant-...",
file=sys.stderr,
)
sys.exit(1)
def main() -> None:
parser = argparse.ArgumentParser(
description="AutoDev AI — give it an idea, get a working app.",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=__doc__,
)
parser.add_argument("idea", nargs="?", help="App idea (quoted string)")
parser.add_argument("--max-iter", type=int, default=6, metavar="N")
parser.add_argument("--demo", action="store_true", help="Cinematic demo mode")
parser.add_argument("--github", action="store_true", help="Push to GitHub after deploy")
parser.add_argument("--github-token", default="", metavar="TOKEN")
parser.add_argument("--interactive", action="store_true", help="Prompt for idea")
args = parser.parse_args()
_check_api_key()
# GitHub token: CLI arg → env var
github_token = (
args.github_token
or os.environ.get("GITHUB_TOKEN", "")
).strip()
import config as cfg
cfg.GITHUB_TOKEN = github_token
# ── Resolve idea ─────────────────────────────────────────────────────
if args.interactive or not args.idea:
from rich.console import Console
from rich.prompt import Prompt
c = Console()
c.print("\n[bold blue]🚀 AutoDev AI[/bold blue] — Self-Building Software Engineer\n")
idea = Prompt.ask("[bold]What would you like me to build?[/bold]").strip()
if not idea:
c.print("[red]No idea provided. Exiting.[/red]")
sys.exit(1)
else:
idea = args.idea.strip()
# ── Print graph map in demo mode ─────────────────────────────────────
if args.demo:
from ui.terminal import print_graph_map
print_graph_map()
# ── Run pipeline ──────────────────────────────────────────────────────
from core.orchestrator import run
final_state = run(
idea = idea,
max_iterations = args.max_iter,
use_github = args.github and bool(github_token),
demo_mode = args.demo,
)
sys.exit(0 if final_state.get("phase") == "complete" else 1)
if __name__ == "__main__":
main()