Skip to content

aarushg888/magic-code

Repository files navigation

⚡ Magic Code

AI Coding Agent for FTC / FRC / VEX Robotics Software Development

Python 3.9+ License: MIT FTC SDK Pedro Pathing PRs Welcome


   __  __           _       ____          _
  |  \/  |         (_)     / ___|___   __| | ___
  | \  / | ___  ___ _  ___| |   / _ \ / _` |/ _ \
  | |\/| |/ _ \/ __| |/ __| |__| (_) | (_| |  __/
  |_|  |_|\___/\___|_|\___|\____\___/ \__,_|\___|

The only AI coding agent built specifically for robotics — FTC, FRC, and VEX.

Generate robot code, design autonomous routines, tune PID, and deploy — all from your terminal.


🚀 Quick Start

# Install
pip install magic-code

# Run the interactive setup (pick provider, model, enter API key)
magic-code setup

# Start coding
magic-code "create an FTC teleop with mecanum drive using NextFTC"
magic-code "generate an FRC swerve drive with PathPlanner"
magic-code "write a VEX PROS autonomous routine"

🎯 Features

🤖 Platform Support

Platform Frameworks Path Planning Vision
FTC NextFTC, FTCLib Pedro Pathing, Pure Pursuit AprilTag, TFOD, Limelight
FRC WPILib, Command-Based PathPlanner, Choreo PhotonVision, Limelight
VEX PROS (C/C++) VEX Pathing Vision Sensor

🧠 Multi-Provider AI

Pick your AI model like Hermes Agent, OpenCode, Cursor:

 Anthropic (Claude)     → sonnet, opus, haiku
 OpenAI (GPT)           → gpt-5, gpt-4o, o1
 Google (Gemini)        → gemini-2.5-pro, gemini-2.5-flash
 xAI (Grok)             → grok-3, grok-3-mini
 Cohere (Command R)     → command-r-plus
 Ollama (Local)         → llama3.1, qwen2.5, codellama
 NVIDIA (NIM)           → nemotron-3-ultra
 OpenRouter             → 300+ models unified
 DeepSeek               → deepseek-chat, deepseek-coder

Quick model switching:

# CLI flags
magic-code --provider openai   --model gpt-5 "make an FTC auto"
magic-code --provider google   --model gemini-2.5-pro "tune PID"
magic-code --provider ollama   --model llama3.1 "build chassis"
magic-code --provider nvidia   --model nemotron-3-ultra "swerve drive"

📊 Terminal Visualizer

Visualise robots, fields, and paths — no GUI needed:

magic-code "show the FTC DECODE field"
magic-code "place my robot at (36, 36, 90) on the FTC field"
magic-code "show a path from (0,0) to (72,72)"
magic-code "visualise my Pedro Pathing code on the field"
┌────── FTC DECODE FIELD ──────┐
│                              │
│  🔵     ⚪     🔴            │
│   ╲     │     ╱             │
│    ╲    │    ╱              │
│     ─── ┴ ───               │
│         R 🟦                │
│     ─── ┬ ───               │
│    ╱    │    ╲              │
│   ╱     │     ╲             │
│  🟦     ⚪     🔴            │
│                              │
└──────────────────────────────┘

🔧 21 Built-In Tools

Category Tools
File System read, write, edit, list, search, create, delete, copy
Terminal run command, run async, wait, gradle, adb
Deploy deploy-ftc, deploy-frc, run-simulation
Visualizer show-field, show-pose, show-path, show-pedro-path, show-dashboard

📚 13 Robotics Skills

  • FTC: Command-Based, Pedro Pathing, Pure Pursuit, AprilTag, Dashboard
  • FRC: Command-Based, PathPlanner, Choreo, PhotonVision
  • Common: PID Tuning, Git→Deploy→Test Loop, VEX PROS

🔧 Setup Wizard

Pick your provider interactively:

magic-code setup
=== Magic Code Setup Wizard ===

Step 1: Pick your AI Provider
  #  Provider              Models              Description
  1  Anthropic (Claude)    sonnet, opus, haiku Best for complex reasoning
  2  OpenAI (GPT)          gpt-5, gpt-4o, o1  Fast, coding-optimized
  3  Google (Gemini)       gemini-2.5-pro     Large context, fast
  4  xAI (Grok)            grok-3, grok-3-mini Unfiltered
  5  Cohere (Command R)    command-r-plus     RAG, enterprise
  6  Ollama (Local)        llama3.1, qwen2.5  Run locally
  7  NVIDIA (NIM)          nemotron-3-ultra   NVIDIA NIM
  8  OpenRouter            300+ models        Unified API
  9  DeepSeek              deepseek-chat      Reasoning

Enter number or provider name [1]:

API keys are saved securely to ~/.config/magic-code/.env (chmod 600).


💡 Example Workflows

FTC: Build a Competition Robot

magic-code "create FTC teleop with mecanum drive, intake subsystem, and arm"
# → Generates TeleOp.kt, DriveSubsystem.kt, IntakeSubsystem.kt, ArmSubsystem.kt

magic-code "add Pedro Pathing autonomous that scores 2 samples in high chamber"
# → Generates AutoRed.kt with Pedro Pathing path chain

magic-code "show my path on the field"
# → Terminal field visualisation with robot pose and path overlay

FRC: Full Swerve Drive

magic-code "create FRC swerve subsystem with PathPlanner integration for team 1234"
# → Generates SwerveSubsystem.java, PathPlanner integration, RobotContainer.java

PID Tuning

magic-code "create FTC PID tuning routine for arm with FTC Dashboard @Config"
# → Generates ArmPIDTuner OpMode with configurable constants

🔌 Supported Providers

Provider API Key Env Models Cool Factor
Anthropic ANTHROPIC_API_KEY sonnet, opus, haiku Best reasoning
OpenAI OPENAI_API_KEY gpt-5, gpt-4o, o1 Fast coding
Google GOOGLE_API_KEY gemini-2.5-pro 1M context
xAI XAI_API_KEY grok-3 Unfiltered
Cohere COHERE_API_KEY command-r-plus RAG
Ollama (none) llama3.1 Local/Private
NVIDIA NVIDIA_API_KEY nemotron-3-ultra GPU optimized
OpenRouter OPENROUTER_API_KEY 300+ models One API
DeepSeek DEEPSEEK_API_KEY deepseek-chat Budget

📂 Project Structure

magic-code/
├── magic_code/              # Core agent package
│   ├── agent.py             # Main agent with LLM integration
│   ├── cli.py               # CLI entry + setup wizard (9 providers)
│   ├── config/              # Configuration management
│   ├── llm_provider.py      # 6 LLM providers + model aliases
│   ├── tools/               # 21 tools (file, terminal, visualizer)
│   └── visualizer/          # Terminal field visualiser (FTC/FRC/VEX)
├── skills/                  # 13 robotics-specific skills
└── AGENTS.md                # AI agent instructions

🧪 Verification

magic-code doctor

Checks:

  • Python version
  • Configured provider + model
  • All 9 API key statuses
  • Installed dependencies

🏆 FTC DECODE 2025-2026 Knowledge

Built-in season knowledge:

  • Full field layout (144" x 144")
  • Sample/Specimen/Ascent scoring
  • AprilTag ID map (1-24)
  • Optimal autonomous strategies
  • Chamber and Observation Zone coordinates

📖 Documentation

  • magic-code --help — CLI reference
  • magic-code doctor — System health check
  • magic-code setup — Interactive provider setup
  • AGENTS.md — Agent behavior guidelines

🤝 Contributing

PRs welcome! See CONTRIBUTING.md for guidelines.


📜 License

MIT — use it, fork it, build robots with it.


Made with ⚡ for FIRST Robotics and VEX teams everywhere.

About

A opensource coding agent for robotics teams

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages