@prdpspkt/g-coder
Version:
AI-powered CLI coding assistant supporting Ollama, OpenAI, Claude, DeepSeek and more
363 lines (260 loc) โข 8.85 kB
Markdown
# G-Coder ๐
**AI-powered CLI coding assistant with multi-provider support and intelligent automation**
[](https://www.npmjs.com/package/@prdpspkt/g-coder)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
## Why G-Coder?
โ
**Universal Provider Support** - Use ANY OpenAI-compatible API (Ollama, DeepSeek, OpenAI, Groq, Together AI, etc.)
โ
**100% Free Option** - Run locally with Ollama (no API costs)
โ
**Smart Project Memory** - Persistent conversation history per project
โ
**Auto Token Management** - Seamless continuation when limits hit
โ
**Advanced Security** - OS-aware risk detection and approval system
โ
**Highly Customizable** - Custom commands, hooks, and configurations
## ๐ฆ Installation
```bash
npm install -g @prdpspkt/g-coder
```
## ๐ Quick Start
### 1. Run G-Coder (Auto Setup)
```bash
g-coder
```
First run creates default config with Ollama (local, free). If you need API providers, interactive setup will guide you.
### 2. Manual Setup (Optional)
**For Ollama (Free, Local):**
```bash
# Install Ollama
brew install ollama # macOS
# or: https://ollama.ai/download
# Start and pull model
ollama serve
ollama pull codellama
# G-Coder default config already set for Ollama!
```
**For API Providers (DeepSeek, OpenAI, etc.):**
Edit `~/.g-coder/config.json`:
```json
{
"provider": "deepseek",
"model": "deepseek-chat",
"baseUrl": "https://api.deepseek.com/v1",
"apiKeyName": "DEEPSEEK_API_KEY"
}
```
Add API key to `~/.g-coder/.env`:
```bash
echo "DEEPSEEK_API_KEY=sk-your-key" >> ~/.g-coder/.env
```
## โ๏ธ Configuration
### Supported Providers
G-Coder works with **ANY OpenAI-compatible API**:
| Provider | baseUrl | Model Example |
|----------|---------|---------------|
| **Ollama** | `http://localhost:11434/v1` | `codellama`, `deepseek-coder` |
| **DeepSeek** | `https://api.deepseek.com/v1` | `deepseek-chat`, `deepseek-reasoner` |
| **OpenAI** | `https://api.openai.com/v1` | `gpt-4`, `gpt-3.5-turbo` |
| **Groq** | `https://api.groq.com/openai/v1` | `llama-3.1-70b-versatile` |
| **Together AI** | `https://api.together.xyz/v1` | `meta-llama/Llama-3-70b` |
| **Custom** | `https://your-api.com/v1` | Any model name |
> **Note:** Anthropic Claude uses its own API format: `https://api.anthropic.com/v1`
### Configuration Structure
`~/.g-coder/config.json`:
```json
{
"provider": "your-provider-name",
"model": "model-name",
"baseUrl": "https://api.example.com/v1",
"apiKeyName": "YOUR_API_KEY_ENV_VAR",
"temperature": 0.7,
"maxTokens": 8192,
"approval": {
"enabled": true,
"toolsRequiringApproval": {
"Bash": true,
"Write": true,
"Edit": true
}
}
}
```
`~/.g-coder/.env`:
```bash
YOUR_API_KEY_ENV_VAR=your-actual-api-key
```
**๐ See [CONFIGURATION.md](./CONFIGURATION.md) for detailed examples**
## ๐ Usage
### Start Interactive Session
```bash
g-coder # Start with default config
g-coder start # Explicit start
g-coder start -v # Verbose logging
g-coder setup # Run setup wizard
```
### In-Session Commands
**Basic:**
- `/help` - Show help
- `/clear` - Clear conversation
- `/tools` - List available tools
- `/exit` - Exit application
**Configuration:**
- `/config` - Show configuration
- `/model` - Change model
- `/approval` - Manage approval settings
**History & Sessions:**
- `/history` - View conversation history
- `/save <name>` - Save current session
- `/load <name>` - Load saved session
- `/sessions` - List all sessions
## ๐ ๏ธ Available Tools
G-Coder provides intelligent tools for coding tasks:
### File Operations
- **Read** - Read file contents
- **Write** - Create/overwrite files (approval required)
- **Edit** - Smart file editing with fuzzy matching (approval required)
- **NotebookEdit** - Edit Jupyter notebooks (approval required)
### Search
- **Glob** - Find files by pattern (`**/*.ts`)
- **Grep** - Search code with regex
### Execution
- **Bash** - Run shell commands (approval required)
- **BashOutput** - Read background process output
- **KillShell** - Stop background processes
### Git
- **GitStatus**, **GitDiff** - View changes
- **GitCommit**, **GitPush** - Create commits and push (approval required)
### Web
- **WebFetch** - Fetch web content (approval required)
## ๐ Security & Approval
### Risk-Based Approval System
Operations are categorized by risk:
- ๐ข **Safe** (no approval): Read, Glob, Grep, GitStatus, GitDiff
- ๐ก **Medium** (approval): Write, Edit, WebFetch
- ๐ **High** (approval): Bash, GitCommit
- ๐ด **Critical** (approval): GitPush, destructive operations
### OS-Aware Security
Automatically detects dangerous patterns:
**Windows:** `del /s`, `format`, registry modifications
**Linux/Mac:** `rm -rf /`, `sudo rm`, root operations
### Auto-Approve
When approving, choose "auto-approve similar" to skip future prompts for the same operation.
## ๐ง Project Intelligence
### Automatic Features
- **Project Detection** - Recognizes Node.js, Python, Go, Rust, etc.
- **Persistent History** - Last 50 interactions saved per project
- **Context Restoration** - Previous conversations loaded on startup
- **Smart Scanning** - Understands project structure automatically
### Startup Context Example
```
๐ Previous Conversation Context:
Previous session: 2025-01-15 10:30
Total interactions: 42 messages
Recent topics: Implemented auth; Fixed DB connection
Loaded 5 interactions for context
```
## โพ๏ธ Token Management
G-Coder handles token limits automatically:
**90% Warning:**
```
โ ๏ธ Approaching limit: 7200/8000 tokens (90%)
```
**100% Auto-Save:**
```
โ ๏ธ Token Limit Exceeded
Auto-saving and continuing...
โ Saved: auto-save-2025-01-15T10-30-45
Session ID: abc123
Load with: /load abc123
โ Ready to continue!
```
**No manual intervention needed!**
## ๐จ Customization
### Custom Slash Commands
Create `~/.g-coder/commands/review.md`:
```markdown
description: Review code for best practices
Review this project for:
1. Code quality
2. Potential bugs
3. Security issues
```
Usage: `/review`
### Event Hooks
Create `~/.g-coder/hooks.json`:
```json
{
"enabled": true,
"hooks": {
"session_start": ["git fetch"],
"session_end": ["git status"]
}
}
```
## ๐ G-Coder vs Claude Code
| Feature | G-Coder | Claude Code |
|---------|---------|-------------|
| **Multi-Provider** | โ
Ollama, DeepSeek, OpenAI, Groq, etc. | โ Claude only |
| **Free Option** | โ
Ollama (local, free) | โ Requires API |
| **Project History** | โ
Persistent per-project | โ Session only |
| **Auto Token Mgmt** | โ
Auto-save & continue | โ Manual |
| **OS-Aware Security** | โ
Risk detection | โ ๏ธ Basic |
| **Customization** | โ
Commands, hooks, configs | โ Limited |
**Choose G-Coder if you want:**
- ๐ Free local models
- ๐ Provider flexibility
- ๐ Project memory
- โพ๏ธ Automatic continuation
- ๐ Advanced security
- ๐จ Full customization
## ๐ Documentation
- **[CONFIGURATION.md](./CONFIGURATION.md)** - Detailed provider setup (7+ examples)
- **[config.examples.json](./config.examples.json)** - Ready-to-use configs
- **[MINIMAL_SYSTEM_PROMPT.md](./MINIMAL_SYSTEM_PROMPT.md)** - System prompt guide
- **[TOOLS_REFERENCE.md](./TOOLS_REFERENCE.md)** - Complete tool documentation
## ๐ Troubleshooting
**Ollama not connecting:**
```bash
ollama serve # Start Ollama
ollama pull codellama # Pull model
g-coder test # Test connection
```
**API key not found:**
```bash
cat ~/.g-coder/.env # Check API key
g-coder config --show # Verify config
```
**Config corrupted:**
- G-Coder auto-creates backup and fresh config
- Check `~/.g-coder/config.json.backup.*`
## ๐ค Contributing
Contributions welcome! Please submit PRs.
```bash
git clone https://github.com/prdpspkt/g-coder.git
cd g-coder
npm install
npm run build
```
## ๐ License
MIT License - see [LICENSE](LICENSE)
## ๐ฌ Support
- **Issues:** https://github.com/prdpspkt/g-coder/issues
- **NPM:** https://www.npmjs.com/package/@prdpspkt/g-coder
**Made with ๐ by developers, for developers**
เคถเฅเคฐเฅ เคเคฃเฅเคถเคพเคฏ เคจเคฎ: