A Node.js command-line tool that acts as an agentic AI code generator with intelligent planning, memory management, and MCP server integration.
- Goal-Based Code Generation: Describe what you want to build, and agentai plans and executes it
- Intelligent Planning: Breaks down high-level goals into actionable steps
- Memory Management: Maintains project state and execution history
- MCP Integration: Communicates with MCP servers for file handling, command execution, and test creation
- Structured Logging: Comprehensive logs in the
logs/directory
.
├── src/
│ ├── agentai.js # CLI entry point
│ ├── core/ # Core AI logic
│ │ ├── ai_core.js # AI reasoning and Gemini API integration
│ │ ├── chat_handler.js # Chat command orchestration
│ │ ├── memory_manager.js # Memory and state management
│ │ ├── planner.js # Goal-to-plan conversion
│ │ └── mcp_client.js # MCP server communication
│ ├── mcp_servers/ # MCP server stubs
│ │ ├── file_handling_server.js
│ │ ├── command_execution_server.js
│ │ └── test_server.js
├── .env # Environment configuration (create from .env.example)
├── .env.example # Example environment configuration
├── workspace/ # Generated project files
├── logs/ # Execution and planning logs
└── package.json # Node.js package configuration
-
Clone or navigate to the project directory
-
Install dependencies:
npm install
-
Configure the tool:
Copy the example environment file and add your configuration:
cp .env.example .env
Edit
.envand add your Google Gemini API token:GEMINI_API_TOKEN=your-actual-api-token-here
The tool reads configuration from a .env file in the project root. Create .env from .env.example:
cp .env.example .envConfiguration variables:
- GEMINI_API_TOKEN: Your Google Gemini API token (required)
- GEMINI_MODEL: Gemini model to use (default:
gemini-2.5-flash) - REQUEST_DELAY: Delay between API requests in milliseconds (default:
2000= 2 seconds). Increase if you hit rate limits - MAX_RETRIES: Maximum retry attempts for rate limit errors (default:
3) - WORKSPACE_PATH: Path where generated files are stored (default: current working directory where command is run)
- LOGS_PATH: Path where logs are stored (default:
./logsin current directory) - MCP_FILE_HANDLING_URL: MCP server endpoint for file handling (default:
http://localhost:3001) - MCP_COMMAND_EXECUTION_URL: MCP server endpoint for command execution (default:
http://localhost:3002) - MCP_TEST_SERVER_URL: MCP server endpoint for test creation (default:
http://localhost:3003) - LOG_LEVEL: Logging level (default:
info) - LOG_MAX_FILE_SIZE: Maximum log file size (default:
10MB) - LOG_MAX_FILES: Maximum number of log files to keep (default:
5)
The tool automatically handles rate limits with:
- Automatic retries: Retries up to 3 times when rate limited
- Smart delays: Extracts retry delay from API error messages
- Request throttling: Configurable delay between requests (default: 2 seconds)
If you frequently hit rate limits, increase REQUEST_DELAY in your .env:
REQUEST_DELAY=5000 # 5 seconds between requestsThe CLI only accepts the chat subcommand:
node src/agentai.js chat "your goal here"Or if installed globally:
agentai chat "create a REST API with Express.js"node src/agentai.js chat "create a simple Express.js server with a /hello endpoint"This will:
- Load configuration
- Create a plan breaking down the goal into steps
- Execute each step via MCP servers
- Update memory with results
- Log all actions to
logs/
✅ Fully Working: The system is now complete and functional!
- Google Gemini API Integration: ✅ Fully implemented and working
- MCP Servers: ✅ Fully implemented with actual file operations, command execution, and test creation
- MCP Client: ✅ Working in-process communication with MCP servers
- File Operations: ✅ Creates and modifies files in the workspace
- Code Generation: ✅ Uses AI to generate actual code
- Test Creation: ✅ Creates test files with AI-generated content
- Command Execution: ✅ Safely executes commands with validation
- Goal Analysis: The system uses Google Gemini API to analyze your goal
- Plan Generation: Creates a detailed, step-by-step plan with dependencies
- Step Reasoning: For each step, AI provides reasoning and approach
- File Creation: Creates files with AI-generated content
- Code Generation: Uses AI to write complete, working code
- File Modification: Updates existing files intelligently
- Automatically generates test files
- Uses AI to create comprehensive test cases
- Supports Jest and Mocha frameworks
- Safely executes commands like
npm install,npm init, etc. - Validates commands for safety
- Blocks dangerous operations
- Returns execution results
- Command validation before execution
- Blocks dangerous commands (rm, del, format, etc.)
- Validates file paths
- Safe error handling
- Node.js >= 18.0.0
- npm or yarn
MIT