A production-ready AI coding agent with interactive terminal interface, built with Vercel AI SDK and TypeScript.
- 🎨 Modern terminal interface with chalk and ora
- 💬 Interactive conversation with the agent
- 🔧 Tool execution with confirmation for dangerous operations
- 📝 Type-safe tool definitions with Zod
- 🎯 Streaming responses from LLM providers
- 🔒 Sandboxed workspace for safe file operations
- ⚙️ Configurable via environment variables
- 🧪 TypeScript with full type safety
- Node.js 20+
- OpenAI API Key or Anthropic API Key
git clone git@github.com:kikeztw/agent-coder.git
cd agent-codernpm installCreate a .env file in the project root:
OPENAI_API_KEY=your-api-key-here
# Or if using Anthropic:
# ANTHROPIC_API_KEY=your-api-key-herenpm run buildnpm linkOnce linked, you can run the agent from any directory:
coder chatcoder chat- Start interactive sessioncoder run "your message"- Run single queryexitorquit- Exit interactive session
👤 You: Create a TypeScript file that calculates Fibonacci numbers
👤 You: Explain what the main.ts file does
👤 You: Refactor the workflow function to improve readability
# Install dependencies
npm install
# Run in watch mode
npm run dev
# Type checking
npm run typecheck
# Run tests
npm testagent-coder/
├── src/
│ ├── core/ # Core agent logic
│ │ ├── state.ts # Agent state types
│ │ └── workflow.ts # ReAct workflow
│ ├── nodes/ # Workflow nodes
│ │ ├── thought.ts # LLM reasoning
│ │ ├── action.ts # Tool execution
│ │ └── review.ts # Human confirmation
│ ├── tools/ # Tool implementations
│ │ ├── registry.ts # Tool registration
│ │ ├── file-tools.ts
│ │ └── execution-tools.ts
│ ├── providers/ # LLM providers
│ │ └── llm.ts
│ ├── config/ # Configuration
│ │ └── settings.ts
│ ├── cli/ # CLI interface
│ │ └── index.ts
│ └── utils/ # Utilities
│ └── security.ts
├── tests/ # Test suite
├── workspace/ # Agent sandbox directory
├── package.json
├── tsconfig.json
└── README.md
The agent has access to the following tools:
- read_file: Read file contents
- write_file: Create or overwrite files
- delete_file: Delete files (requires confirmation)
- list_directory: List directory contents
- run_command: Execute shell commands (requires confirmation)
All tools operate within the sandboxed workspace/ directory for security.
Configuration is managed through environment variables:
- Model Configuration:
MODEL_PROVIDER,MODEL_NAME,TEMPERATURE - API Keys:
OPENAI_API_KEYorANTHROPIC_API_KEY - Security:
DANGEROUS_TOOLS,MAX_EXECUTION_TIME - Workspace:
WORKSPACE_PATH
MIT License - see LICENSE file
kikeztw - GitHub