Metadata-Version: 2.4
Name: goatcode
Version: 1.0.0
Summary: Production-grade deterministic coding agent with real architecture
Home-page: https://github.com/Shivay00001/goatcode
Author: Shivay Singh
Author-email: shivay@goatcode.dev
Project-URL: Bug Reports, https://github.com/Shivay00001/goatcode/issues
Project-URL: Source, https://github.com/Shivay00001/goatcode
Keywords: ai coding agent automation llm ollama openai anthropic
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: requests>=2.28.0
Requires-Dist: openai>=1.0.0
Requires-Dist: anthropic>=0.18.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: ast-decompiler>=0.7.0
Requires-Dist: mypy>=1.0.0
Requires-Dist: pytest>=7.4.0
Requires-Dist: pytest-asyncio>=0.21.0
Requires-Dist: flake8>=6.0.0
Requires-Dist: black>=23.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: tqdm>=4.65.0
Requires-Dist: rich>=13.0.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# GOATCODE - Production-Grade Coding Agent

A **deterministic, tool-augmented, autonomous coding agent** that beats prompt-only solutions through real architecture.

## 🎯 The 80% That Matters

Unlike other AI coding assistants that rely on prompts alone, GOATCODE implements:

1. **🔍 File Indexing Engine** - AST-based semantic code search with vector embeddings
2. **🧠 Context Injection** - Automatic relevance-based retrieval with token budget management
3. **🔄 Test→Fix→Retry Loop** - Iterative validation with automatic error recovery
4. **📊 Diff-Based Patching** - AST-aware minimal surgical edits (no full rewrites)
5. **💰 Token Budget Manager** - Dynamic context window optimization
6. **🗄️ Memory System** - Resolution pattern storage and retrieval

**Prompt = 20%. Architecture = 80%**

## 🚀 Quick Start

### Prerequisites

- Python 3.9+
- For local models: [Ollama](https://ollama.com)
- For SaaS: API key (OpenAI, Anthropic)

### Installation

```bash
# Clone repository
git clone https://github.com/yourusername/goatcode.git
cd goatcode

# Install dependencies
pip install -r requirements.txt

# If using Ollama, pull a model
ollama pull llama2
ollama pull codellama
```

### Usage

#### Interactive Mode (Recommended)

```bash
# With local Ollama
python -m goatcode --provider ollama --model llama2

# With OpenAI
python -m goatcode --provider openai --model gpt-4 --api-key $OPENAI_API_KEY

# With Anthropic
python -m goatcode --provider anthropic --model claude-3-opus
```

#### Batch Mode

```bash
python -m goatcode --provider ollama \
  -p "Create a Python function to parse JSON with error handling" \
  -o result.json
```

### Example Session

```
🐐 GOATCODE - Production-Grade Coding Agent

Interactive Mode - Type your coding requests
Commands: /help, /exit, /status, /models
------------------------------------------------------------

📝 > Create a REST API endpoint for user authentication with JWT

🚀 Starting execution...

============================================================
Status: SUCCESS
============================================================

📊 Analysis Summary:
Creating a secure REST API endpoint for user authentication 
using JWT tokens. Will include login, registration, and 
protected route middleware.

📋 Implementation Plan:
  1. Create auth module with JWT utilities
  2. Implement login endpoint with password hashing
  3. Implement registration endpoint with validation
  4. Create authentication middleware
  5. Add comprehensive error handling

📝 Files Modified:
  [CREATE] src/auth/jwt_utils.py
  [CREATE] src/auth/endpoints.py
  [CREATE] src/auth/middleware.py
  [UPDATE] requirements.txt

✅ Validation Report:
  ✓ All validations passed
  ✓ Type checking clean
  ✓ Tests passing (12/12)

🎯 Confidence Score: 95%

============================================================
```

## 🏗️ Architecture

```
goatcode/
├── core/
│   └── agent.py              # Main orchestrator
├── llm/
│   └── interface.py          # Multi-provider LLM support
├── tools/
│   └── registry.py           # Tool system
├── context/
│   └── manager.py            # Context pruning & injection
├── memory/
│   └── system.py             # Pattern storage & retrieval
├── validation/
│   └── engine.py             # Test→Fix→Retry loop
└── cli/
    └── main.py               # CLI entry point
```

### Execution Pipeline

```
User Request
    ↓
1. Intent Analysis (What to build?)
    ↓
2. Project Context (File structure, dependencies)
    ↓
3. Risk Analysis (Security, edge cases)
    ↓
4. Memory Lookup (Similar past solutions)
    ↓
5. Implementation Plan (Files, functions, steps)
    ↓
6. Code Generation (Complete, correct code)
    ↓
7. Validation Loop (Test → Fix → Retry)
    ↓
8. Diff Patching (Minimal surgical changes)
    ↓
Success / Report
```

## 🛠️ Available Tools

- **read_file** - Read file contents
- **write_file** - Write or overwrite files
- **list_directory** - List project structure
- **search_project** - Text-based code search
- **semantic_search** - Vector-based code search
- **run_tests** - Execute test suites
- **run_linter** - Code linting
- **run_typecheck** - Type checking
- **git_diff** - Show git changes
- **memory_lookup** - Search past solutions
- **memory_store** - Store resolution patterns

## 🤖 Supported LLM Providers

### Local (Free)
- **Ollama** - Run models locally
  - llama2, codellama, mistral, mixtral
  - No API costs, complete privacy

### SaaS (API Key Required)
- **OpenAI** - GPT-4, GPT-3.5-turbo
- **Anthropic** - Claude 3 (Opus, Sonnet, Haiku)
- **Google** - Gemini Pro (coming soon)

### Multi-Provider with Fallback

```python
from goatcode.llm.interface import create_multi_provider_router

router = create_multi_provider_router([
    {'provider': 'ollama', 'model': 'llama2'},
    {'provider': 'openai', 'model': 'gpt-3.5-turbo'}
])
```

## 📊 Performance Comparison

| Feature | GOATCODE | Cursor | Copilot | ChatGPT |
|---------|----------|---------|---------|---------|
| File Indexing | ✅ | ❌ | ❌ | ❌ |
| Context Injection | ✅ | ⚠️ | ❌ | ❌ |
| Test→Fix Loop | ✅ | ❌ | ❌ | ❌ |
| Diff Patching | ✅ | ❌ | ❌ | ❌ |
| Memory System | ✅ | ❌ | ❌ | ❌ |
| Token Budget | ✅ | ❌ | ❌ | ❌ |
| Local Models | ✅ | ❌ | ❌ | ❌ |

## 🎯 Why This Wins

### vs. Cursor/Copilot
- ❌ They hide the architecture → ✅ GOATCODE shows the engineering
- ❌ Prompt-only solutions → ✅ Real tool orchestration
- ❌ No verification loop → ✅ Test→Fix→Retry cycle
- ❌ No context management → ✅ Smart context injection
- ❌ Cloud-only → ✅ Local Ollama support

### vs. ChatGPT
- ❌ No project context → ✅ Full project analysis
- ❌ No file operations → ✅ Complete tool system
- ❌ No validation → ✅ Automated testing
- ❌ No memory → ✅ Pattern learning

## 🔒 Security Features

- ✅ No hardcoded secrets
- ✅ No unsafe eval/exec
- ✅ Input validation
- ✅ Least-privilege design
- ✅ Automatic dependency checking

## 🧪 Development

```bash
# Install dev dependencies
pip install -r requirements-dev.txt

# Run tests
pytest tests/

# Run linter
flake8 goatcode/

# Type checking
mypy goatcode/
```

## 📈 Roadmap

- [x] Core agent architecture
- [x] Multi-provider LLM support
- [x] Tool system
- [ ] FAISS vector search
- [ ] AST-aware diff patching
- [ ] Web interface
- [ ] VSCode extension
- [ ] CI/CD integration
- [ ] Team collaboration features

## 🤝 Contributing

This is a production-grade reference implementation. Contributions welcome:

1. Fork the repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open Pull Request

## 📝 License

MIT License - See LICENSE file

## 🙏 Acknowledgments

- Inspired by the need for deterministic, verifiable AI coding
- Built on top of excellent open-source tools
- Community-driven development

---

**Built with Python 🐍 | Powered by Determinism ⚡ | Designed for Production 🚀**

*Prompt is 20%. This is the 80%.*
