autoforge-ai 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.claude/commands/check-code.md +32 -0
  2. package/.claude/commands/checkpoint.md +40 -0
  3. package/.claude/commands/create-spec.md +613 -0
  4. package/.claude/commands/expand-project.md +234 -0
  5. package/.claude/commands/gsd-to-autoforge-spec.md +10 -0
  6. package/.claude/commands/review-pr.md +75 -0
  7. package/.claude/templates/app_spec.template.txt +331 -0
  8. package/.claude/templates/coding_prompt.template.md +265 -0
  9. package/.claude/templates/initializer_prompt.template.md +354 -0
  10. package/.claude/templates/testing_prompt.template.md +146 -0
  11. package/.env.example +64 -0
  12. package/LICENSE.md +676 -0
  13. package/README.md +423 -0
  14. package/agent.py +444 -0
  15. package/api/__init__.py +10 -0
  16. package/api/database.py +536 -0
  17. package/api/dependency_resolver.py +449 -0
  18. package/api/migration.py +156 -0
  19. package/auth.py +83 -0
  20. package/autoforge_paths.py +315 -0
  21. package/autonomous_agent_demo.py +293 -0
  22. package/bin/autoforge.js +3 -0
  23. package/client.py +607 -0
  24. package/env_constants.py +27 -0
  25. package/examples/OPTIMIZE_CONFIG.md +230 -0
  26. package/examples/README.md +531 -0
  27. package/examples/org_config.yaml +172 -0
  28. package/examples/project_allowed_commands.yaml +139 -0
  29. package/lib/cli.js +791 -0
  30. package/mcp_server/__init__.py +1 -0
  31. package/mcp_server/feature_mcp.py +988 -0
  32. package/package.json +53 -0
  33. package/parallel_orchestrator.py +1800 -0
  34. package/progress.py +247 -0
  35. package/prompts.py +427 -0
  36. package/pyproject.toml +17 -0
  37. package/rate_limit_utils.py +132 -0
  38. package/registry.py +614 -0
  39. package/requirements-prod.txt +14 -0
  40. package/security.py +959 -0
  41. package/server/__init__.py +17 -0
  42. package/server/main.py +261 -0
  43. package/server/routers/__init__.py +32 -0
  44. package/server/routers/agent.py +177 -0
  45. package/server/routers/assistant_chat.py +327 -0
  46. package/server/routers/devserver.py +309 -0
  47. package/server/routers/expand_project.py +239 -0
  48. package/server/routers/features.py +746 -0
  49. package/server/routers/filesystem.py +514 -0
  50. package/server/routers/projects.py +524 -0
  51. package/server/routers/schedules.py +356 -0
  52. package/server/routers/settings.py +127 -0
  53. package/server/routers/spec_creation.py +357 -0
  54. package/server/routers/terminal.py +453 -0
  55. package/server/schemas.py +593 -0
  56. package/server/services/__init__.py +36 -0
  57. package/server/services/assistant_chat_session.py +496 -0
  58. package/server/services/assistant_database.py +304 -0
  59. package/server/services/chat_constants.py +57 -0
  60. package/server/services/dev_server_manager.py +557 -0
  61. package/server/services/expand_chat_session.py +399 -0
  62. package/server/services/process_manager.py +657 -0
  63. package/server/services/project_config.py +475 -0
  64. package/server/services/scheduler_service.py +683 -0
  65. package/server/services/spec_chat_session.py +502 -0
  66. package/server/services/terminal_manager.py +756 -0
  67. package/server/utils/__init__.py +1 -0
  68. package/server/utils/process_utils.py +134 -0
  69. package/server/utils/project_helpers.py +32 -0
  70. package/server/utils/validation.py +54 -0
  71. package/server/websocket.py +903 -0
  72. package/start.py +456 -0
  73. package/ui/dist/assets/index-8W_wmZzz.js +168 -0
  74. package/ui/dist/assets/index-B47Ubhox.css +1 -0
  75. package/ui/dist/assets/vendor-flow-CVNK-_lx.js +7 -0
  76. package/ui/dist/assets/vendor-query-BUABzP5o.js +1 -0
  77. package/ui/dist/assets/vendor-radix-DTNNCg2d.js +45 -0
  78. package/ui/dist/assets/vendor-react-qkC6yhPU.js +1 -0
  79. package/ui/dist/assets/vendor-utils-COeKbHgx.js +2 -0
  80. package/ui/dist/assets/vendor-xterm-DP_gxef0.js +16 -0
  81. package/ui/dist/index.html +23 -0
  82. package/ui/dist/ollama.png +0 -0
  83. package/ui/dist/vite.svg +6 -0
  84. package/ui/package.json +57 -0
package/README.md ADDED
@@ -0,0 +1,423 @@
1
+ # AutoForge
2
+
3
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=flat&logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/leonvanzyl)
4
+
5
+ A long-running autonomous coding agent powered by the Claude Agent SDK. This tool can build complete applications over multiple sessions using a two-agent pattern (initializer + coding agent). Includes a React-based UI for monitoring progress in real-time.
6
+
7
+ ## Video Tutorial
8
+
9
+ [![Watch the tutorial](https://img.youtube.com/vi/lGWFlpffWk4/hqdefault.jpg)](https://youtu.be/lGWFlpffWk4)
10
+
11
+ > **[Watch the setup and usage guide →](https://youtu.be/lGWFlpffWk4)**
12
+
13
+ ---
14
+
15
+ ## Prerequisites
16
+
17
+ - **Node.js 20+** - Required for the CLI
18
+ - **Python 3.11+** - Auto-detected on first run ([download](https://www.python.org/downloads/))
19
+ - **Claude Code CLI** - Install and authenticate (see below)
20
+
21
+ ### Claude Code CLI (Required)
22
+
23
+ **macOS / Linux:**
24
+ ```bash
25
+ curl -fsSL https://claude.ai/install.sh | bash
26
+ ```
27
+
28
+ **Windows (PowerShell):**
29
+ ```powershell
30
+ irm https://claude.ai/install.ps1 | iex
31
+ ```
32
+
33
+ ### Authentication
34
+
35
+ You need one of the following:
36
+
37
+ - **Claude Pro/Max Subscription** - Use `claude login` to authenticate (recommended)
38
+ - **Anthropic API Key** - Pay-per-use from https://console.anthropic.com/
39
+
40
+ ---
41
+
42
+ ## Quick Start
43
+
44
+ ### Option 1: npm Install (Recommended)
45
+
46
+ ```bash
47
+ npm install -g autoforge-ai
48
+ autoforge
49
+ ```
50
+
51
+ On first run, AutoForge automatically:
52
+ 1. Checks for Python 3.11+
53
+ 2. Creates a virtual environment at `~/.autoforge/venv/`
54
+ 3. Installs Python dependencies
55
+ 4. Copies a default config file to `~/.autoforge/.env`
56
+ 5. Starts the server and opens your browser
57
+
58
+ ### CLI Commands
59
+
60
+ ```
61
+ autoforge Start the server (default)
62
+ autoforge config Open ~/.autoforge/.env in $EDITOR
63
+ autoforge config --path Print config file path
64
+ autoforge config --show Show active configuration values
65
+ autoforge --port PORT Custom port (default: auto from 8888)
66
+ autoforge --host HOST Custom host (default: 127.0.0.1)
67
+ autoforge --no-browser Don't auto-open browser
68
+ autoforge --repair Delete and recreate virtual environment
69
+ autoforge --version Print version
70
+ autoforge --help Show help
71
+ ```
72
+
73
+ ### Option 2: From Source (Development)
74
+
75
+ Clone the repository and use the start scripts directly. This is the recommended path if you want to contribute or modify AutoForge itself.
76
+
77
+ ```bash
78
+ git clone https://github.com/leonvanzyl/autoforge.git
79
+ cd autoforge
80
+ ```
81
+
82
+ **Web UI:**
83
+
84
+ | Platform | Command |
85
+ |---|---|
86
+ | Windows | `start_ui.bat` |
87
+ | macOS / Linux | `./start_ui.sh` |
88
+
89
+ This launches the React-based web UI at `http://localhost:5173` with:
90
+ - Project selection and creation
91
+ - Kanban board view of features
92
+ - Real-time agent output streaming
93
+ - Start/pause/stop controls
94
+
95
+ **CLI Mode:**
96
+
97
+ | Platform | Command |
98
+ |---|---|
99
+ | Windows | `start.bat` |
100
+ | macOS / Linux | `./start.sh` |
101
+
102
+ The start script will:
103
+ 1. Check if Claude CLI is installed
104
+ 2. Check if you're authenticated (prompt to run `claude login` if not)
105
+ 3. Create a Python virtual environment
106
+ 4. Install dependencies
107
+ 5. Launch the main menu
108
+
109
+ ### Creating or Continuing a Project
110
+
111
+ You'll see options to:
112
+ - **Create new project** - Start a fresh project with AI-assisted spec generation
113
+ - **Continue existing project** - Resume work on a previous project
114
+
115
+ For new projects, you can use the built-in `/create-spec` command to interactively create your app specification with Claude's help.
116
+
117
+ ---
118
+
119
+ ## How It Works
120
+
121
+ ### Two-Agent Pattern
122
+
123
+ 1. **Initializer Agent (First Session):** Reads your app specification, creates features in a SQLite database (`features.db`), sets up the project structure, and initializes git.
124
+
125
+ 2. **Coding Agent (Subsequent Sessions):** Picks up where the previous session left off, implements features one by one, and marks them as passing in the database.
126
+
127
+ ### Feature Management
128
+
129
+ Features are stored in SQLite via SQLAlchemy and managed through an MCP server that exposes tools to the agent:
130
+ - `feature_get_stats` - Progress statistics
131
+ - `feature_get_next` - Get highest-priority pending feature
132
+ - `feature_get_for_regression` - Random passing features for regression testing
133
+ - `feature_mark_passing` - Mark feature complete
134
+ - `feature_skip` - Move feature to end of queue
135
+ - `feature_create_bulk` - Initialize all features (used by initializer)
136
+
137
+ ### Session Management
138
+
139
+ - Each session runs with a fresh context window
140
+ - Progress is persisted via SQLite database and git commits
141
+ - The agent auto-continues between sessions (3 second delay)
142
+ - Press `Ctrl+C` to pause; run the start script again to resume
143
+
144
+ ---
145
+
146
+ ## Important Timing Expectations
147
+
148
+ > **Note: Building complete applications takes time!**
149
+
150
+ - **First session (initialization):** The agent generates feature test cases. This takes several minutes and may appear to hang - this is normal.
151
+
152
+ - **Subsequent sessions:** Each coding iteration can take **5-15 minutes** depending on complexity.
153
+
154
+ - **Full app:** Building all features typically requires **many hours** of total runtime across multiple sessions.
155
+
156
+ **Tip:** The feature count in the prompts determines scope. For faster demos, you can modify your app spec to target fewer features (e.g., 20-50 features for a quick demo).
157
+
158
+ ---
159
+
160
+ ## Project Structure
161
+
162
+ ```
163
+ autoforge/
164
+ ├── bin/ # npm CLI entry point
165
+ ├── lib/ # CLI bootstrap and setup logic
166
+ ├── start.py # CLI menu and project management
167
+ ├── start_ui.py # Web UI backend (FastAPI server launcher)
168
+ ├── autonomous_agent_demo.py # Agent entry point
169
+ ├── agent.py # Agent session logic
170
+ ├── client.py # Claude SDK client configuration
171
+ ├── security.py # Bash command allowlist and validation
172
+ ├── progress.py # Progress tracking utilities
173
+ ├── prompts.py # Prompt loading utilities
174
+ ├── api/
175
+ │ └── database.py # SQLAlchemy models (Feature table)
176
+ ├── mcp_server/
177
+ │ └── feature_mcp.py # MCP server for feature management tools
178
+ ├── server/
179
+ │ ├── main.py # FastAPI REST API server
180
+ │ ├── websocket.py # WebSocket handler for real-time updates
181
+ │ ├── schemas.py # Pydantic schemas
182
+ │ ├── routers/ # API route handlers
183
+ │ └── services/ # Business logic services
184
+ ├── ui/ # React frontend
185
+ │ ├── src/
186
+ │ │ ├── App.tsx # Main app component
187
+ │ │ ├── hooks/ # React Query and WebSocket hooks
188
+ │ │ └── lib/ # API client and types
189
+ │ ├── package.json
190
+ │ └── vite.config.ts
191
+ ├── .claude/
192
+ │ ├── commands/
193
+ │ │ └── create-spec.md # /create-spec slash command
194
+ │ ├── skills/ # Claude Code skills
195
+ │ └── templates/ # Prompt templates
196
+ ├── requirements.txt # Python dependencies (development)
197
+ ├── requirements-prod.txt # Python dependencies (npm install)
198
+ ├── package.json # npm package definition
199
+ └── .env # Optional configuration
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Generated Project Structure
205
+
206
+ After the agent runs, your project directory will contain:
207
+
208
+ ```
209
+ generations/my_project/
210
+ ├── features.db # SQLite database (feature test cases)
211
+ ├── prompts/
212
+ │ ├── app_spec.txt # Your app specification
213
+ │ ├── initializer_prompt.md # First session prompt
214
+ │ └── coding_prompt.md # Continuation session prompt
215
+ ├── init.sh # Environment setup script
216
+ ├── claude-progress.txt # Session progress notes
217
+ └── [application files] # Generated application code
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Running the Generated Application
223
+
224
+ After the agent completes (or pauses), you can run the generated application:
225
+
226
+ ```bash
227
+ cd generations/my_project
228
+
229
+ # Run the setup script created by the agent
230
+ ./init.sh
231
+
232
+ # Or manually (typical for Node.js apps):
233
+ npm install
234
+ npm run dev
235
+ ```
236
+
237
+ The application will typically be available at `http://localhost:3000` or similar.
238
+
239
+ ---
240
+
241
+ ## Security Model
242
+
243
+ This project uses a defense-in-depth security approach (see `security.py` and `client.py`):
244
+
245
+ 1. **OS-level Sandbox:** Bash commands run in an isolated environment
246
+ 2. **Filesystem Restrictions:** File operations restricted to the project directory only
247
+ 3. **Bash Allowlist:** Only specific commands are permitted:
248
+ - File inspection: `ls`, `cat`, `head`, `tail`, `wc`, `grep`
249
+ - Node.js: `npm`, `node`
250
+ - Version control: `git`
251
+ - Process management: `ps`, `lsof`, `sleep`, `pkill` (dev processes only)
252
+
253
+ Commands not in the allowlist are blocked by the security hook.
254
+
255
+ ---
256
+
257
+ ## Web UI Development
258
+
259
+ The React UI is located in the `ui/` directory.
260
+
261
+ ### Development Mode
262
+
263
+ ```bash
264
+ cd ui
265
+ npm install
266
+ npm run dev # Development server with hot reload
267
+ ```
268
+
269
+ ### Building for Production
270
+
271
+ ```bash
272
+ cd ui
273
+ npm run build # Builds to ui/dist/
274
+ ```
275
+
276
+ **Note:** The `start_ui.bat`/`start_ui.sh` scripts serve the pre-built UI from `ui/dist/`. After making UI changes, run `npm run build` to see them when using the start scripts.
277
+
278
+ ### Tech Stack
279
+
280
+ - React 18 with TypeScript
281
+ - TanStack Query for data fetching
282
+ - Tailwind CSS v4 with neobrutalism design
283
+ - Radix UI components
284
+ - WebSocket for real-time updates
285
+
286
+ ### Real-time Updates
287
+
288
+ The UI receives live updates via WebSocket (`/ws/projects/{project_name}`):
289
+ - `progress` - Test pass counts
290
+ - `agent_status` - Running/paused/stopped/crashed
291
+ - `log` - Agent output lines (streamed from subprocess stdout)
292
+ - `feature_update` - Feature status changes
293
+
294
+ ---
295
+
296
+ ## Configuration
297
+
298
+ AutoForge reads configuration from a `.env` file. The file location depends on how you installed AutoForge:
299
+
300
+ | Install method | Config file location | Edit command |
301
+ |---|---|---|
302
+ | npm (global) | `~/.autoforge/.env` | `autoforge config` |
303
+ | From source | `.env` in the project root | Edit directly |
304
+
305
+ A default config file is created automatically on first run. Use `autoforge config` to open it in your editor, or `autoforge config --show` to print the active values.
306
+
307
+ ### N8N Webhook Integration
308
+
309
+ Add to your `.env` to send progress notifications to an N8N webhook:
310
+
311
+ ```bash
312
+ # Optional: N8N webhook for progress notifications
313
+ PROGRESS_N8N_WEBHOOK_URL=https://your-n8n-instance.com/webhook/your-webhook-id
314
+ ```
315
+
316
+ When test progress increases, the agent sends:
317
+
318
+ ```json
319
+ {
320
+ "event": "test_progress",
321
+ "passing": 45,
322
+ "total": 200,
323
+ "percentage": 22.5,
324
+ "project": "my_project",
325
+ "timestamp": "2025-01-15T14:30:00.000Z"
326
+ }
327
+ ```
328
+
329
+ ### Using GLM Models (Alternative to Claude)
330
+
331
+ Add these variables to your `.env` file to use Zhipu AI's GLM models:
332
+
333
+ ```bash
334
+ ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
335
+ ANTHROPIC_AUTH_TOKEN=your-zhipu-api-key
336
+ API_TIMEOUT_MS=3000000
337
+ ANTHROPIC_DEFAULT_SONNET_MODEL=glm-4.7
338
+ ANTHROPIC_DEFAULT_OPUS_MODEL=glm-4.7
339
+ ANTHROPIC_DEFAULT_HAIKU_MODEL=glm-4.5-air
340
+ ```
341
+
342
+ This routes AutoForge's API requests through Zhipu's Claude-compatible API, allowing you to use GLM-4.7 and other models. **This only affects AutoForge** - your global Claude Code settings remain unchanged.
343
+
344
+ Get an API key at: https://z.ai/subscribe
345
+
346
+ ### Using Ollama Local Models
347
+
348
+ Add these variables to your `.env` file to run agents with local models via Ollama v0.14.0+:
349
+
350
+ ```bash
351
+ ANTHROPIC_BASE_URL=http://localhost:11434
352
+ ANTHROPIC_AUTH_TOKEN=ollama
353
+ API_TIMEOUT_MS=3000000
354
+ ANTHROPIC_DEFAULT_SONNET_MODEL=qwen3-coder
355
+ ANTHROPIC_DEFAULT_OPUS_MODEL=qwen3-coder
356
+ ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3-coder
357
+ ```
358
+
359
+ See the [CLAUDE.md](CLAUDE.md) for recommended models and known limitations.
360
+
361
+ ### Using Vertex AI
362
+
363
+ Add these variables to your `.env` file to run agents via Google Cloud Vertex AI:
364
+
365
+ ```bash
366
+ CLAUDE_CODE_USE_VERTEX=1
367
+ CLOUD_ML_REGION=us-east5
368
+ ANTHROPIC_VERTEX_PROJECT_ID=your-gcp-project-id
369
+ ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-5@20251101
370
+ ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-5@20250929
371
+ ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-3-5-haiku@20241022
372
+ ```
373
+
374
+ Requires `gcloud auth application-default login` first. Note the `@` separator (not `-`) in Vertex AI model names.
375
+
376
+ ---
377
+
378
+ ## Customization
379
+
380
+ ### Changing the Application
381
+
382
+ Use the `/create-spec` command when creating a new project, or manually edit the files in your project's `prompts/` directory:
383
+ - `app_spec.txt` - Your application specification
384
+ - `initializer_prompt.md` - Controls feature generation
385
+
386
+ ### Modifying Allowed Commands
387
+
388
+ Edit `security.py` to add or remove commands from `ALLOWED_COMMANDS`.
389
+
390
+ ---
391
+
392
+ ## Troubleshooting
393
+
394
+ **"Claude CLI not found"**
395
+ Install the Claude Code CLI using the instructions in the Prerequisites section.
396
+
397
+ **"Not authenticated with Claude"**
398
+ Run `claude login` to authenticate. The start script will prompt you to do this automatically.
399
+
400
+ **"Appears to hang on first run"**
401
+ This is normal. The initializer agent is generating detailed test cases, which takes significant time. Watch for `[Tool: ...]` output to confirm the agent is working.
402
+
403
+ **"Command blocked by security hook"**
404
+ The agent tried to run a command not in the allowlist. This is the security system working as intended. If needed, add the command to `ALLOWED_COMMANDS` in `security.py`.
405
+
406
+ **"Python 3.11+ required but not found"**
407
+ Install Python 3.11 or later from [python.org](https://www.python.org/downloads/). Make sure `python3` (or `python` on Windows) is on your PATH.
408
+
409
+ **"Python venv module not available"**
410
+ On Debian/Ubuntu, the venv module is packaged separately. Install it with `sudo apt install python3.XX-venv` (replace `XX` with your Python minor version, e.g., `python3.12-venv`).
411
+
412
+ **"AutoForge is already running"**
413
+ A server instance is already active. Use the browser URL shown in the terminal, or stop the existing instance with Ctrl+C first.
414
+
415
+ **Virtual environment issues after a Python upgrade**
416
+ Run `autoforge --repair` to delete and recreate the virtual environment from scratch.
417
+
418
+ ---
419
+
420
+ ## License
421
+
422
+ This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details.
423
+ Copyright (C) 2026 Leon van Zyl (https://leonvanzyl.com)