No description
Find a file
2026-02-03 18:12:21 +08:00
.codebuddy/plan/aicc-text-to-elf Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
examples Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
src Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
.gitignore Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
Cargo.lock Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
Cargo.toml Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
CHANGELOG.md Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
example-config.toml Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
PROJECT_SUMMARY.md Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
QUICKSTART.md Init aicc with first vibe release 2026-02-03 18:08:45 +08:00
README.md Init aicc with first vibe release 2026-02-03 18:08:45 +08:00

AICC - AI Compiler Collection

Transform text descriptions into executable ELF binaries using AI.

Overview

AICC is a Rust-based tool that uses AI language models to generate C code from natural language descriptions, then compiles it into executable ELF binaries. It provides a complete pipeline from text to binary.

Features

  • 📝 Text to Code: Convert natural language descriptions to C code using AI
  • 🔧 Automatic Compilation: Compile generated code to ELF binaries
  • 🎯 Multi-Architecture: Support for x86_64, aarch64, and more
  • ELF Validation: Automatic validation of generated binaries
  • 🔄 Retry Logic: Robust error handling with automatic retries
  • ⚙️ Configurable: Flexible configuration system
  • 🚀 Fast: Efficient pipeline with progress indicators

Installation

Prerequisites

  • Rust 1.70 or later
  • A C compiler (gcc or clang)
  • An OpenAI API key (or compatible AI service)

Build from Source

git clone <repository-url>
cd aicc/aicc
cargo build --release

The binary will be available at target/release/aicc.

Configuration

Generate a default configuration file:

./target/release/aicc config --output config.toml

Configure API Key

Method 1: Environment Variable (Recommended)

export AICC_API_KEY="your-api-key-here"

Method 2: Configuration File

Edit the configuration file to set your AI API key and preferences:

[ai]
provider = "openai"
api_endpoint = "https://api.openai.com/v1/chat/completions"
api_key = "your-api-key-here"
model = "gpt-4"
temperature = 0.2

[compiler]
preferred = "gcc"
optimization_level = "2"

[target]
architecture = "x86_64"

Note: Environment variable AICC_API_KEY takes precedence over config file.

For detailed API key configuration and troubleshooting, see API_KEY_GUIDE.md.

Alternatively, set the API key via environment variable:

export AICC_API_KEY="your-api-key-here"

Usage

Basic Usage

./target/release/aicc compile input.txt

This will:

  1. Read the text description from input.txt
  2. Generate C code using AI
  3. Compile it to an ELF binary
  4. Save the output to ./output/<filename>.elf

Specify Output Path

./target/release/aicc compile input.txt --output my_program

Target Different Architecture

./target/release/aicc compile input.txt --arch aarch64

Use Specific Compiler

./target/release/aicc compile input.txt --compiler clang

Verbose Output

./target/release/aicc compile input.txt --verbose

View Configuration

Show current configuration:

./target/release/aicc show

Show configuration with validation:

./target/release/aicc show --validate

Show configuration field descriptions:

./target/release/aicc show --help

Use a specific config file:

./target/release/aicc --config /path/to/config.toml show

Examples

Example 1: Hello World

Create a file hello.txt:

Write a simple C program that prints "Hello, AICC!" to the console and exits successfully.

Run AICC:

./target/release/aicc compile examples/hello.txt

Example 2: Fibonacci Calculator

Create a file fibonacci.txt:

Write a C program that calculates and prints the first 10 Fibonacci numbers.
The program should use an iterative approach for efficiency.

Run AICC:

./target/release/aicc compile fibonacci.txt --output fib_calc

Project Structure

aicc/
├── src/
│   ├── main.rs           # Entry point
│   ├── lib.rs            # Library exports
│   ├── ai_client.rs      # AI API integration
│   ├── compiler.rs       # Compiler wrapper
│   ├── elf_validator.rs  # ELF validation
│   ├── file_input.rs     # File input handling
│   ├── pipeline.rs       # Main orchestration
│   ├── config.rs         # Configuration management
│   ├── error.rs          # Error types
│   ├── logging.rs        # Logging setup
│   └── cli.rs            # CLI interface
├── examples/             # Example input files
├── output/               # Default output directory
└── Cargo.toml           # Dependencies

Configuration Options

General Settings

  • max_file_size_mb: Maximum input file size (default: 10 MB)
  • output_dir: Default output directory (default: "./output")
  • max_retries: Maximum retry attempts for AI requests (default: 3)

AI Settings

  • provider: AI service provider (default: "openai")
  • api_endpoint: API endpoint URL
  • api_key: API authentication key
  • model: Model name (default: "gpt-4")
  • timeout_secs: Request timeout (default: 60)
  • temperature: Generation temperature (default: 0.2)

Compiler Settings

  • preferred: Preferred compiler (default: "gcc")
  • optimization_level: Optimization level 0-3, s, z (default: "2")
  • extra_flags: Additional compiler flags
  • timeout_secs: Compilation timeout (default: 300)

Target Settings

  • architecture: Target architecture (default: "x86_64")
  • toolchain_path: Custom toolchain path (optional)

Troubleshooting

Quick Diagnostics

# Check your configuration
./target/release/aicc show --validate

Common Issues

1. API Key Errors (401 Unauthorized)

Problem: Environment variable overriding valid config file key.

Solution:

# Remove environment variable to use config file
unset AICC_API_KEY

# Or set correct key
export AICC_API_KEY="your-valid-key"

2. Compiler Not Found

Make sure gcc or clang is installed:

# On macOS
xcode-select --install

# On Ubuntu/Debian
sudo apt-get install build-essential

# On Fedora/RHEL
sudo dnf install gcc

3. Compilation Errors

If the generated code fails to compile:

  1. Check the error messages in the output
  2. Try adjusting the AI temperature in config
  3. Make your input description more specific
  4. Use --verbose flag for detailed logs

For detailed troubleshooting, see TROUBLESHOOTING.md

Development

Running Tests

cargo test

Building Documentation

cargo doc --open

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Acknowledgments

  • Built with Rust
  • Uses OpenAI API for code generation
  • Leverages goblin for ELF parsing