ai-code-agent
v1.0.0
Published
A multi-provider CLI tool for AI-powered code generation with support for OpenAI, Anthropic, DeepSeek, Grok, and Kimi
Maintainers
Readme
AI Code Agent
A powerful CLI tool for AI-powered code generation and file management. Similar to Claude Code and Codex, this tool allows you to interact with multiple AI providers to generate code and automatically create files.
Features
- Multi-Provider Support: OpenAI, Anthropic Claude, DeepSeek, Grok (xAI), Kimi (Moonshot)
- Interactive chat interface with AI
- Automatic file creation and code writing
- Persistent conversation history
- Global configuration management
- Easy provider switching
- Token/API key management
Installation
From npm (once published)
npm install -g ai-code-agentLocal Development
# Clone the repository
git clone <your-repo-url>
cd code-agents
# Install dependencies
npm install
# Link the package globally
npm linkQuick Start
1. Configure an AI Provider
Interactive setup (recommended):
ai-agent config setDirect setup:
# OpenAI
ai-agent config set-token openai sk-your-api-key
# Anthropic Claude
ai-agent config set-token anthropic sk-ant-your-api-key
# DeepSeek
ai-agent config set-token deepseek your-api-key
# Grok (xAI)
ai-agent config set-token grok your-api-key
# Kimi (Moonshot)
ai-agent config set-token kimi your-api-key2. Set Default Provider (Optional)
ai-agent config default openai3. Start Chatting
ai-agentConfiguration Commands
View All Supported Providers
ai-agent config providersList Configured Providers
ai-agent config listSet API Key with Custom Model
ai-agent config set-token openai sk-your-key --model gpt-4
ai-agent config set-token anthropic sk-ant-key --model claude-3-opus-20240229Remove Provider Configuration
ai-agent config remove openaiUse Specific Provider for a Session
ai-agent chat --provider anthropic
ai-agent --provider deepseekUsage Examples
Start Interactive Chat
ai-agentCreating a file:
You: Create a React component for a login form
AI: I'll create a React component for you...
Create file "LoginForm.jsx"? Yes
✓ File created: LoginForm.jsxGeneral questions:
You: How do I use async/await in JavaScript?
AI: Async/await is a modern way to handle asynchronous operations...Exit:
You: exitSwitch Providers Mid-Session
# Use Anthropic Claude
ai-agent --provider anthropic
# Use DeepSeek
ai-agent --provider deepseekSupported AI Providers
| Provider | ID | Models |
|----------|----|--------------------|
| OpenAI | openai | gpt-4-turbo-preview, gpt-4, gpt-3.5-turbo |
| Anthropic Claude | anthropic | claude-3-5-sonnet-20241022, claude-3-opus-20240229, claude-3-sonnet-20240229 |
| DeepSeek | deepseek | deepseek-chat, deepseek-coder |
| Grok (xAI) | grok | grok-beta |
| Kimi (Moonshot) | kimi | moonshot-v1-8k, moonshot-v1-32k, moonshot-v1-128k |
Project Structure
code-agents/
├── bin/
│ └── cli.js # CLI entry point
├── src/
│ ├── api/
│ │ ├── providers/
│ │ │ ├── openai.js # OpenAI provider
│ │ │ ├── anthropic.js # Anthropic provider
│ │ │ ├── deepseek.js # DeepSeek provider
│ │ │ ├── grok.js # Grok provider
│ │ │ └── kimi.js # Kimi provider
│ │ └── providerFactory.js # Provider factory
│ ├── commands/
│ │ └── config.js # Config commands
│ ├── utils/
│ │ ├── config.js # Configuration management
│ │ └── fileManager.js # File operations
│ └── index.js # Main application logic
├── package.json
└── README.mdConfiguration
The tool stores configuration in ~/.ai-code-agent/config.json:
{
"defaultProvider": "openai",
"providers": {
"openai": {
"apiKey": "sk-your-openai-key",
"model": "gpt-4-turbo-preview"
},
"anthropic": {
"apiKey": "sk-ant-your-anthropic-key",
"model": null
},
"deepseek": {
"apiKey": "your-deepseek-key",
"model": "deepseek-coder"
}
},
"maxTokens": 2000,
"temperature": 0.7
}Requirements
- Node.js 18 or higher
- API key for at least one supported AI provider
Development
# Install dependencies
npm install
# Run locally
npm start
# Test the CLI
node bin/cli.jsHow It Works
- Interactive Prompt: The tool opens an input prompt when you run the command
- AI Processing: Your prompt is sent to your configured AI provider
- Smart Response: The AI analyzes your request and determines if it needs to create a file
- File Creation: If code generation is needed, you'll be prompted to confirm file creation
- Automatic Writing: The code is automatically written to the specified file
Getting API Keys
- OpenAI: https://platform.openai.com/api-keys
- Anthropic: https://console.anthropic.com/
- DeepSeek: https://platform.deepseek.com/
- Grok (xAI): https://x.ai/api
- Kimi (Moonshot): https://platform.moonshot.cn/
Publishing to npm
# Login to npm
npm login
# Publish the package
npm publishLicense
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
