# 🚀 SyndiCodex

**Revolutionary Autonomous Development Intelligence** by **Ethical AI Syndicate** & **MCPCodex**

A groundbreaking CLI tool that harnesses multi-agent orchestration for autonomous code generation, analysis, and project management. Built with TypeScript and designed to revolutionize your development workflow through ethical AI innovation.

[![NPM Version](https://img.shields.io/npm/v/syndicodex)](https://www.npmjs.com/package/syndicodex)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)
[![Ethical AI](https://img.shields.io/badge/Ethical-AI-green)](https://aisyndicate.io)
[![MCPCodex](https://img.shields.io/badge/MCPCodex-v2-purple)](https://mcpcodex.ca)

## ✨ Revolutionary Features

### 🤖 **Autonomous Development Intelligence**
- **Multi-Agent Orchestration**: Specialized AI agents working in harmony for complex development tasks
- **Self-Healing Code**: Autonomous error detection, correction, and optimization
- **Adaptive Learning**: Cross-project knowledge sharing and pattern recognition
- **Production Monitoring**: Real-time validation and deployment readiness assessment

### 🧠 **Advanced AI Capabilities**
- **Natural Language to Code**: Transform requirements into production-ready code
- **Intelligent Code Analysis**: Deep codebase understanding with 60+ specialized services
- **Context-Aware Generation**: Understands your entire project ecosystem
- **Quality Assurance**: Automated testing, security scanning, and performance optimization

### 🚀 **Enterprise-Grade Features**
- **Workflow Orchestration**: End-to-end autonomous development workflows
- **Interactive Chat Mode**: Conversational interface with memory and context persistence
- **Multi-Language Mastery**: TypeScript, JavaScript, Python, Go, Rust, and more
- **Plugin Ecosystem**: Extensible architecture with MCP (Model Context Protocol) integration

## 📦 Installation

### Global Installation (Recommended)

```bash
npm install -g syndicodex
```

### Local Installation

```bash
npm install syndicodex
# or
yarn add syndicodex
# or
pnpm add syndicodex
```

## 🎯 Quick Start

1. **Interactive Setup**:
   ```bash
   syndicodex onboarding
   ```

2. **Start Autonomous Workflow**:
   ```bash
   syndicodex orchestrate "build a secure user management API"
   ```

3. **Analyze & Optimize**:
   ```bash
   syndicodex analyze --production-ready
   ```

4. **Quick Code Generation**:
   ```bash
   syndicodex generate "JWT authentication middleware with rate limiting"
   ```

5. **Interactive Chat Mode**:
   ```bash
   syndicodex chat
   ```

## 📖 Commands

### 🎯 Core Commands

#### `syndicodex onboarding`
Interactive first-time setup and configuration wizard.

```bash
syndicodex onboarding
```

#### `syndicodex orchestrate <description>`
Launch autonomous development workflows with multi-agent coordination.

```bash
# Full autonomous development
syndicodex orchestrate "build a secure REST API with authentication"

# Quick task execution
syndicodex orchestrate "optimize database queries" --type quick

# Production deployment
syndicodex orchestrate "deploy microservice" --environment production
```

#### `syndicodex analyze [path]`
Analyze codebase structure and patterns.

```bash
# Analyze current directory with production readiness assessment
syndicodex analyze

# Analyze specific directory with autonomous intelligence
syndicodex analyze ./src --depth 5 --autonomous

# Production readiness validation
syndicodex analyze --production-ready --security-scan

# Output comprehensive analysis as JSON
syndicodex analyze --output json --comprehensive
```

**Options:**
- `-d, --depth <number>`: Analysis depth (default: 3)
- `-o, --output <format>`: Output format (json|text, default: text)
- `--include-tests`: Include test files in analysis
- `--exclude <patterns>`: Comma-separated patterns to exclude

#### `syndicodex generate <description>`
Autonomous code generation with multi-agent intelligence.

```bash
# Generate production-ready function
syndicodex generate "email validation with security best practices"

# Generate full-stack component with tests
syndicodex generate "user profile card" --type component --framework react --include-tests

# Interactive autonomous mode
syndicodex generate "authentication middleware" --autonomous --interactive

# Enterprise-grade generation
syndicodex generate "microservice API client with monitoring" \
  --type service \
  --language typescript \
  --style enterprise \
  --include-tests \
  --production-ready
```

**Options:**
- `-t, --type <type>`: Code type (function|class|component|test|file, default: function)
- `-l, --language <lang>`: Programming language (default: typescript)
- `-f, --framework <framework>`: Framework to use (react|express|etc)
- `-o, --output <path>`: Output file path
- `--style <style>`: Coding style (functional|oop|mixed, default: functional)
- `--no-tests`: Skip test generation
- `--no-comments`: Skip comment generation
- `-i, --interactive`: Interactive mode with prompts

#### `syndicodex chat`
Intelligent multi-agent chat with memory and context persistence.

```bash
# Advanced chat with autonomous intelligence
syndicodex chat

# Chat with full project context and memory
syndicodex chat --context ./src --memory

# Enterprise chat with specialized agents
syndicodex chat --agents security,performance,architecture --model claude-3
```

**Options:**
- `-m, --model <model>`: AI model to use (default: gpt-4)
- `--context <path>`: Include project context from path
- `--max-tokens <number>`: Maximum tokens per response (default: 2000)

### Project Management

#### `agent init`
Initialize coding agent in current project.

```bash
# Initialize with default settings
agent init

# Force reinitialize
agent init --force
```

#### `agent config`
Manage agent configuration.

```bash
# Set configuration value
agent config set openai.api_key sk-your-key-here
agent config set defaults.model gpt-4
agent config set features.autoSave true

# Get configuration value
agent config get openai.api_key

# List all configuration
agent config list

# Show sensitive values
agent config list --show-sensitive

# Delete configuration
agent config delete openai.api_key
```

#### `agent status`
Show current project context and agent status.

```bash
# Basic status
agent status

# Detailed status with project info
agent status --verbose
```

## ⚙️ Configuration

The agent stores configuration in `~/.cli-coding-agent/` by default. You can override this with the `CLI_AGENT_CONFIG_DIR` environment variable.

### Required Configuration

```bash
# OpenRouter API Key (required - provides access to multiple AI models with smart selection)
agent config set openrouter.api_key sk-or-v1-your-openrouter-api-key

# Optional: Alternative direct provider keys (if not using OpenRouter)
# agent config set openai.api_key sk-your-openai-api-key
# agent config set anthropic.api_key your-anthropic-api-key
```

### Optional Configuration

```bash
# Default AI model
agent config set defaults.model gpt-4

# Temperature for AI responses (0.0-1.0)
agent config set defaults.temperature 0.7

# Maximum tokens per response
agent config set defaults.maxTokens 2000

# Enable auto-save of generated code
agent config set features.autoSave true

# Enable context-aware generation
agent config set features.contextAware true
```

## 🛠️ Development

### Prerequisites

- Node.js 16+
- npm, yarn, or pnpm

### Setup

```bash
# Clone the repository
git clone https://github.com/your-org/cli-coding-agent.git
cd cli-coding-agent

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Run tests
npm test

# Run tests with coverage
npm run test:coverage
```

### Project Structure

```
cli-coding-agent/
├── src/
│   ├── commands/          # CLI command implementations
│   │   ├── analyze.ts     # Code analysis command
│   │   ├── generate.ts    # Code generation command
│   │   ├── chat.ts        # Interactive chat command
│   │   ├── init.ts        # Project initialization
│   │   ├── config.ts      # Configuration management
│   │   └── status.ts      # Status reporting
│   ├── services/          # Core business logic
│   │   ├── project-analyzer.ts    # Project analysis service
│   │   ├── code-generator.ts      # Code generation service
│   │   └── chat-service.ts        # Chat/AI interaction service
│   ├── utils/             # Utility functions
│   │   ├── config-manager.ts      # Configuration management
│   │   ├── logger.ts              # Logging utilities
│   │   └── file-utils.ts          # File system utilities
│   ├── types/             # TypeScript type definitions
│   └── index.ts           # Main CLI entry point
├── tests/
│   ├── unit/              # Unit tests
│   ├── integration/       # Integration tests
│   └── setup.ts           # Test configuration
├── bin/                   # Executable scripts
├── dist/                  # Compiled JavaScript output
└── docs/                  # Documentation
```

### Testing

```bash
# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run specific test files
npm test -- analyze.test.ts

# Run tests with coverage
npm run test:coverage

# Run only unit tests
npm run test:unit

# Run only integration tests
npm run test:integration
```

### Code Quality

```bash
# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Type checking
npm run type-check

# Format code
npm run format
```

## 🧪 Examples

### Basic Usage Examples

**Generate a utility function:**
```bash
agent generate "create a debounce function that delays execution"
```

**Analyze project complexity:**
```bash
agent analyze --depth 4 --include-tests
```

**Interactive chat for debugging:**
```bash
agent chat
> "Help me debug this React component that's not rendering properly"
> "Show me how to optimize this SQL query"
> "What's the best way to handle errors in this async function?"
```

### Advanced Usage Examples

**Generate a complete feature:**
```bash
agent generate "user authentication system with login, register, and password reset" \
  --type file \
  --framework express \
  --language typescript \
  --style oop
```

**Project scaffolding:**
```bash
agent generate "REST API project structure" \
  --type project \
  --framework express \
  --include-tests
```

**Context-aware generation:**
```bash
# After running 'agent analyze' to build context
agent generate "add a new endpoint to handle user preferences" \
  --context-aware
```

## 🔌 Plugin System

The agent supports plugins for extending functionality:

```bash
# Install a plugin (future feature)
agent plugin install @cli-agent/plugin-react

# List installed plugins
agent plugin list

# Enable/disable plugins
agent plugin enable react-helpers
agent plugin disable outdated-plugin
```

## 🌍 Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `CLI_AGENT_CONFIG_DIR` | Configuration directory | `~/.cli-coding-agent` |
| `CLI_AGENT_LOG_LEVEL` | Logging level (debug\|info\|warn\|error) | `info` |
| `CLI_AGENT_CACHE_DIR` | Cache directory for analysis | `~/.cli-coding-agent/cache` |
| `OPENROUTER_API_KEY` | OpenRouter API key (recommended for multi-model access) | - |
| `OPENAI_API_KEY` | OpenAI API key (alternative) | - |
| `ANTHROPIC_API_KEY` | Anthropic API key (alternative) | - |

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Make your changes with tests
4. Run the test suite: `npm test`
5. Commit your changes: `git commit -m 'Add amazing feature'`
6. Push to the branch: `git push origin feature/amazing-feature`
7. Open a Pull Request

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🆘 Support

- 📖 [Documentation](https://cli-coding-agent.dev/docs)
- 🐛 [Bug Reports](https://github.com/your-org/cli-coding-agent/issues)
- 💬 [Discussions](https://github.com/your-org/cli-coding-agent/discussions)
- 📧 [Email Support](mailto:support@cli-coding-agent.dev)

## 🎯 Roadmap

- [ ] **Plugin System**: Extensible architecture for custom functionality
- [ ] **IDE Integration**: VS Code extension for seamless integration
- [ ] **Team Collaboration**: Shared configurations and code templates
- [ ] **Advanced Analytics**: Detailed code quality metrics and trends
- [ ] **Multi-Model Support**: Support for multiple AI providers
- [ ] **Code Refactoring**: Intelligent code refactoring suggestions
- [ ] **Performance Optimization**: Code performance analysis and optimization
- [ ] **Security Analysis**: Built-in security vulnerability detection

## ⭐ Star History

[![Star History Chart](https://api.star-history.com/svg?repos=your-org/cli-coding-agent&type=Date)](https://star-history.com/#your-org/cli-coding-agent&Date)

---

**Built with ❤️ by the CLI Coding Agent Team**