src/tools/builder/
Overview
The software builder provides:- LLM-driven development: Uses an agent loop similar to Codex for iterative development
- Multiple software types: WASM tools, CLI apps, libraries, scripts
- Build loop: Analyze → Scaffold → Implement → Build → Fix → Test → Validate → Package
- Language support: Rust, Python, JavaScript/TypeScript, Bash
- WASM tool specialization: Automatic WIT interface compliance and capability generation
Architecture
src/tools/builder/mod.rs:11-24
Build Tool
build_software
Location:src/tools/builder/core.rs
Create software using LLM-driven iterative development.
Domain: Container
Approval: Always
Rate Limit: 5/min, 20/hour
Software Types
Location:src/tools/builder/core.rs:28-45
WASM Tool
Sandboxed tool that compiles to WebAssembly. Features:- Automatic WIT interface implementation
- Capability file generation
- Host function usage (log, http, workspace_read)
- Integration with tool registry
src/tools/builder/templates.rs:WasmToolTemplate
CLI App
Standalone command-line application. Features:- Argument parsing (clap for Rust, argparse for Python)
- Error handling
- Help documentation
- Exit codes
Library
Reusable library with public API. Features:- Module structure
- Public API design
- Documentation
- Example usage
Script
Single-file executable script. Features:- Shebang line
- Inline dependencies (Rust scripts use
cargo-script) - Simple execution model
Languages
Location:src/tools/builder/core.rs:47-60
Rust
Build system: CargoWASM target:
wasm32-wasip2Package manager: crates.io Example Cargo.toml:
Python
Package manager: pipVirtual env: venv
Testing: pytest Example requirements.txt:
JavaScript/TypeScript
Runtime: Node.jsPackage manager: npm
Build tool: esbuild, tsc Example package.json:
Bash
Interpreter: bashTesting: bats-core Example script:
Build Phases
Location:src/tools/builder/core.rs:62-85
BuildLog entry with details and outputs.
Templates
Location:src/tools/builder/templates.rs
Template Engine
WASM Tool Template
Files generated:Cargo.toml- Rust project configsrc/lib.rs- Tool implementation with WIT bindings<name>.capabilities.json- Capability declarationsREADME.md- Documentation.gitignore- Git ignore patterns
Testing Framework
Location:src/tools/builder/testing.rs
Validation
Location:src/tools/builder/validation.rs
WASM Validator
- WASM binary is valid
- Exports required functions (name, description, parameters_schema, execute)
- Parameters schema is valid JSON Schema
- Tool can be instantiated
- Test execution doesn’t trap
Builder Configuration
Location:src/tools/builder/core.rs:87-110
LLM Software Builder
Location:src/tools/builder/core.rs:112-200
Usage Examples
Build WASM Tool
Build CLI App
Build with Agent Tool
Error Recovery
The builder automatically recovers from common errors:Compilation Errors
Dependency Errors
Test Failures
Best Practices
- Provide clear requirements: Detailed descriptions lead to better results
- Include test cases: Tests guide the implementation and catch errors
- Set appropriate timeouts: Complex builds may need longer timeouts
- Review generated code: Always review before deploying to production
- Iterate on requirements: Refine the description if initial results are off
- Use context: Provide relevant context (API docs, examples, constraints)
- Monitor iterations: If max_iterations is reached, simplify the requirement
Limitations
- LLM quality dependent: Results depend on the underlying LLM’s capabilities
- Complex projects: Very large or complex projects may exceed context limits
- External dependencies: May struggle with undocumented or obscure APIs
- Architecture decisions: May not make optimal architectural choices
- Security: Generated code should be reviewed for security issues
Next Steps
WASM Tools
Learn about the WASM tool system
Built-in Tools
Explore built-in tool reference