Skip to content

ghostwriternr/codeflare

Repository files navigation

🔥 Codeflare

AI coding agent running on Cloudflare workers

✨ Overview

Codeflare is a coding agent designed to run on Cloudflare's Durable Objects and their upcoming Containers platform. It offers a very minimal UI to interact with the agent and display its working.

At this point, this project is only a quick prototype to showcase the simplicity of building coding agents and the ease of deploying them on Cloudflare. That being said, it is still quite capable, thanks to Claude Sonnet 3.7.

🚀 Quick Start

Prerequisites

  • Node.js ≥ 18, npm ≥ 8
  • Anthropic API Key
  • In order to deploy to Cloudflare as-is, you will need a Cloudflare account with early access to their upcoming Containers platform.
    • You could also modify the code to have the agent connect with containers running on other platforms too.

Setup

# Clone the repository
git clone https://github.com/cloudflare/codeflare.git
cd codeflare

# Install dependencies
npm install

# Set up environment variables (remember to replace the placeholders!)
echo "ANTHROPIC_API_KEY=your_key_here" > apps/agent/.dev.vars
echo "REPOSITORY_PATH=absolute_path_to_a_local_repo" >> apps/agent/.dev.vars

💻 Development

# Start development servers
npm run dev

This launches:

🏗️ Architecture

The React frontend is running on Cloudflare Workers, and the core agent loop atop Durable Objects (made easier with the Agent SDK). Because we need access to a unix-like environment to access the filesystem and run commands, containers are spun up on demand with a Hono server that exposes actions that the agent needs to perform as tools via a simple REST API.

The monorepo is managed with Turborepo, containing:

apps/
  ├── agent/      # Core agent loop and chat UI
  └── container/  # Hono server for tool endpoints
packages/
  ├── common/     # Shared types and utilities
  ├── eslint/     # ESLint configuration
  └── typescript/ # TypeScript configuration

🛠️ Known issues and limitations

  • There is no way to stop a running agent currently.
  • No validations or error handling, so sometimes the agent fails silently.
  • Only one session can be active at a time.
  • Only Anthropic models are supported.
  • Tool calls in progress are not yet rendered on the UI.

I'd welcome contributions to fix these or any other issues you might find!

🌟 Contributing

Contributions are welcome! To get started:

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

📄 License

MIT. Clean and simple.

🙌 Credits

A good chunk of the prompts & tool implementation on this codebase are borrowed from dnakov/anon-kode, which is a CLI coding agent. Much of the heavy lifting of working with the Cloudflare Workers platform and running the agentic loop is done by the Agent SDK and interacting with LLMs using the AI SDK.

About

Coding agent running on Cloudflare

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages