Skip to content

ali-master/cyrus

Repository files navigation

Cyrus Logo

πŸ‘‘ CYRUS

The Code Empire Analyzer

AI-Powered Code Analysis, Debugging & Language Detection CLI for Modern Developers

npm version License: MIT TypeScript AI Powered

πŸš€ Quick Start β€’ πŸ“– Documentation β€’ πŸ€– AI Providers β€’ πŸ” Language Detection β€’ βš™οΈ Configuration


✨ What Makes Cyrus Special?

Cyrus isn't just another code analysis tool, it's your AI-powered code empire command center. Built for the modern developer workflow, it combines cutting-edge language detection, multiple AI provider support, and comprehensive code analysis in one elegant CLI.

πŸ† Key Highlights

  • 🎯 High-Precision Language Detection - 95%+ accuracy with confidence scoring
  • πŸ€– Multiple AI Providers - OpenAI, Anthropic, Google, X.AI + Local AI support
  • 🌐 10+ Programming Languages - From JavaScript to Rust, we've got you covered
  • 🏠 Local AI Support - Ollama, LM Studio, and custom OpenAI-compatible APIs
  • πŸ“Š Framework Detection - React, Vue, Django, Spring, and 20+ more
  • ⚑ Lightning Fast - Built with Bun for maximum performance
  • 🎨 Beautiful CLI - Claude Code-inspired UX with progress indicators

🌟 Features

πŸ” Advanced Language Detection
  • Multi-layered Detection: File extensions + content analysis + pattern matching
  • Framework Recognition: Automatically detects React, Vue, Django, Flask, Spring, etc.
  • Build Tool Detection: npm, yarn, pnpm, bun, pip, poetry, cargo, maven, gradle
  • Test Framework Identification: Jest, pytest, JUnit, Mocha, RSpec, and more
  • Confidence Scoring: Get percentage confidence for each detection
  • Project-wide Analysis: Scan entire codebases with language distribution
# Detect languages in current project
cyrus detect .

# Analyze a specific file with detailed info
cyrus detect src/components/App.tsx --detailed

# Export project language analysis
cyrus detect . --json -o project-analysis.json
πŸ€– Multi-AI Provider Support

Cloud Providers:

  • OpenAI: GPT-4, GPT-4 Turbo, GPT-3.5 Turbo
  • Anthropic: Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku
  • Google: Gemini 1.5 Pro, Gemini 1.5 Flash
  • X.AI: Grok Beta

Local AI Providers:

  • Ollama: Auto-detection of installed models
  • LM Studio: Seamless integration with local models
  • Custom APIs: Any OpenAI-compatible local server
# Setup with local AI (no API key required!)
cyrus config init
# βœ“ Found local AI models:
#   Ollama: llama3.2, codellama, mistral
#   LM Studio: deepseek-coder, code-llama-13b

# Switch between providers easily
cyrus config set provider ollama
cyrus config set model llama3.2
πŸ“Š Comprehensive Code Analysis
  • Static Analysis: Syntax errors, code quality, complexity metrics
  • Security Scanning: OWASP vulnerability detection with severity levels
  • Performance Analysis: Bottleneck identification and optimization suggestions
  • AI-Powered Insights: Contextual explanations and improvement recommendations
  • Multiple Output Formats: Text, JSON, Markdown for any workflow
# Full analysis suite
cyrus analyze src/app.ts --security --metrics --explain

# Quick fix for critical issues
cyrus fix src/problematic-file.js

# Comprehensive code review
cyrus review src/components/UserAuth.tsx
πŸŽ“ AI-Powered Mentoring
  • Adaptive Learning: Personalized guidance based on your skill level
  • Interactive Sessions: Ask questions, get explanations, learn patterns
  • Context-Aware Teaching: Focused learning areas and customization
  • Best Practices: Industry standards and coding conventions
  • Code Walkthroughes: Line-by-line explanations with educational context
# Get personalized mentoring
cyrus mentor src/algorithm.js --interactive

# Learning mode with detailed explanations
cyrus learn src/complex-component.tsx
⚑ Smart Code Generation
  • Test Generation: Comprehensive unit tests with edge cases and mocking
  • Documentation: JSDoc, docstrings, README generation
  • Refactoring Suggestions: Before/after examples with detailed explanations
  • Project Scaffolding: Complete project structures from descriptions
  • Component Generation: Framework-specific components (React, Vue, Angular)
# Generate comprehensive tests
cyrus generate tests src/utils/validator.js

# Create documentation
cyrus generate docs src/api/

# Get refactoring suggestions
cyrus generate refactor src/legacy-code.js --interactive

# Generate entire project
cyrus generate project "REST API with TypeScript and Prisma"
πŸ₯ Proactive Health Monitoring
  • Codebase Health Reports: Overall score with actionable insights
  • Technical Debt Tracking: Quantified debt with time estimates
  • Maintainability Index: Industry-standard metrics and trends
  • Historical Analysis: Track improvements over time
  • Team Reporting: Export reports for team reviews
# Scan entire codebase health
cyrus health

# Detailed health report with trends
cyrus health --detailed --save

# Parallel processing for large codebases
cyrus health --parallel --output health-report.json
🎯 Code Quality Scoring
  • Comprehensive Quality Score: Overall grade (A+ to F) based on multiple factors
  • Weighted Metrics: Code health, maintainability, complexity, test coverage, documentation, security
  • AI-Powered Recommendations: Specific, actionable improvement suggestions
  • File-Level Analysis: Identify files needing the most attention
  • Progress Tracking: Monitor quality improvements over time
# Calculate quality score for entire project
cyrus quality .

# Quality score for specific file
cyrus quality src/components/UserAuth.tsx

# Analyze with custom limits
cyrus quality . --max-files 100

# Export quality report
cyrus quality . --json > quality-report.json

Sample Output:

🎯 Code Quality Report
═══════════════════════════════════════════════════════════

Overall Quality Score: 87/100 (A)
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘

πŸ“Š Detailed Metrics:
  Code Health      92/100 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
  Maintainability  85/100 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œβ–‘
  Complexity       78/100 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œβ–‘β–‘
  Test Coverage    95/100 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ
  Documentation    72/100 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–β–‘β–‘
  Security         94/100 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–

πŸš€ Improvement Recommendations:
β€’ Reduce complexity in high-complexity functions (complexity.js:45-67)
β€’ Add inline documentation for public APIs
β€’ Consider extracting utility functions for better maintainability
β€’ Review security practices in authentication modules
πŸ”„ Smart Code Comparison
  • Side-by-Side Comparison: Visual diff with line-by-line and word-by-word modes
  • AI-Powered Analysis: Deep insights into similarities, differences, and improvements
  • Security & Performance Impact: Understand the implications of code changes
  • Detailed Metrics: Code size, complexity, and quality comparisons
  • Flexible Input: Compare files, code snippets, or even different versions
# Compare two code files
cyrus compare old.js new.js

# Word-by-word comparison
cyrus compare file1.py file2.py --words

# Detailed comparison with metrics
cyrus compare v1.ts v2.ts --detailed

# Include security analysis
cyrus compare auth-old.js auth-new.js --security

# Compare code snippets directly
cyrus compare "function old() { return 1; }" "const new = () => 1;"

# Export comparison report
cyrus compare src/v1/ src/v2/ --json > comparison-report.json

Sample Output:

πŸ” Code Comparison: old.js vs new.js
═══════════════════════════════════════════════════════════

πŸ“‹ Line-by-line Comparison:
────────────────────────────────────────────────────────────
-   1 β”‚ function calculateTotal(items) {
+   1 β”‚ const calculateTotal = (items) => {
    2 β”‚   let total = 0;
-   3 β”‚   for (let i = 0; i < items.length; i++) {
-   4 β”‚     total += items[i].price;
+   3 β”‚   return items.reduce((sum, item) => sum + item.price, 0);
-   5 β”‚   }
-   6 β”‚   return total;
    7 β”‚ }

πŸ€– AI-Powered Comparison Analysis

πŸ”— Key Similarities
β€’ Both functions calculate the total price of items
β€’ Same input parameter structure and expected output
β€’ Both handle array iteration for summation

πŸ”„ Key Differences  
β€’ Modern ES6 arrow function syntax vs traditional function declaration
β€’ Functional programming approach (reduce) vs imperative loop
β€’ More concise implementation reduces code by 60%
β€’ Better immutability practices in the new version

πŸš€ Improvements & Recommendations
β€’ New version is more functional and concise
β€’ Arrow function with reduce is more expressive
β€’ Better performance with native reduce method
β€’ Consider adding TypeScript for better type safety

πŸ”’ Security Implications
β€’ No security implications identified in this change
β€’ Both versions handle input validation equally

⚑ Performance Notes
β€’ New version likely faster due to native reduce optimization
β€’ Reduced memory allocation with functional approach
β€’ Less prone to off-by-one errors

πŸ’‘ Expert Recommendations
β€’ The new version represents a clear improvement
β€’ Consider adding input validation for both versions
β€’ Document the function purpose and expected input format
πŸŽ“ Interactive Learning Assistant
  • Personalized Learning Paths: AI-generated curricula tailored to your skill level and goals
  • Interactive Tutorials: Step-by-step guided learning with hands-on practice
  • Coding Challenges: Progressive difficulty challenges with instant AI feedback
  • Skill Assessment: Comprehensive evaluation of your programming abilities
  • Progress Tracking: Monitor your learning journey with detailed analytics
  • Achievement System: Gamified learning with badges and milestones
  • Adaptive Difficulty: AI automatically adjusts challenge difficulty based on performance
# Start interactive learning session
cyrus learn

# Take skill assessment
cyrus learn --assessment

# Start coding challenge
cyrus learn --challenge medium

# Begin personalized tutorial
cyrus learn --tutorial

# View learning progress
cyrus learn --progress

Sample Learning Session:

πŸŽ“ Welcome to Cyrus Learning Assistant!
══════════════════════════════════════════════════════════

πŸš€ Let's create your learning profile!
? What's your programming skill level? Intermediate - Have some experience
? Which programming languages are you interested in? JavaScript, TypeScript, Python
? What's your preferred learning style? Hands-on - Learn by doing and practicing
? What topics interest you most? Algorithms & Data Structures, Web Development

βœ… Profile created successfully!

? What would you like to do today?
❯ πŸ“š Start Interactive Tutorial
  πŸ† Take Coding Challenge  
  πŸ“Š Skill Assessment
  🎯 Personalized Learning Path
  πŸ“ˆ View Progress & Achievements

πŸ“š Starting Tutorial: JavaScript Functions and Closures
────────────────────────────────────────────────────────

## 🎯 Learning Objectives
By the end of this tutorial, you'll understand:
β€’ Function declarations vs expressions
β€’ Scope and closures in JavaScript
β€’ Practical use cases for closures
β€’ Common closure patterns and pitfalls

## πŸ“– Functions Fundamentals
Functions are the building blocks of JavaScript...

πŸ€” Ready for some practice?
? Would you like to try some practice exercises? Yes

πŸ‹οΈ Practice Session
────────────────────────────────────────────────────────

πŸ“ Exercise: Create a Counter Function
Write a function that returns another function which increments a counter each time it's called.

πŸ’‘ Starting code:
function createCounter() {
    // Your code here
}

πŸ” Analyzing your solution...
βœ… Analysis complete!

## ✨ Excellent Solution!

### 🎯 Correctness Assessment
Your solution correctly implements a closure-based counter! The inner function properly captures and modifies the outer variable.

### πŸ’ͺ Code Quality Feedback
β€’ Clean and readable implementation
β€’ Proper use of closure concepts
β€’ Good variable naming

### πŸš€ Learning Points
β€’ You've mastered the concept of closures
β€’ Your understanding of function scope is solid
β€’ Ready for more advanced closure patterns

πŸ† Achievement Unlocked: Closure Master!
πŸ“ˆ Progress: Functions & Closures topic completed (8/10 points)

πŸš€ Quick Start

Installation

# Using npm
npm install -g @usex/cyrus

# Using bun (recommended)
bun install -g @usex/cyrus

# Using yarn
yarn global add @usex/cyrus

# Using pnpm
pnpm add -g @usex/cyrus

# Verify installation
cyrus --version

Setup

# Interactive setup with local AI detection
cyrus config init

# βœ“ Found local AI models:
#   Ollama: llama3.2, codellama, mistral
# βœ“ Configuration saved successfully!

Your First Analysis

# Detect project languages and frameworks
cyrus detect .

# Analyze a file for issues
cyrus analyze src/app.ts

# Get AI mentoring
cyrus mentor src/complex-logic.js --interactive

# Generate tests for your code
cyrus generate tests src/utils.js

πŸ“– Documentation

Core Commands

Command Description Example
cyrus detect <path> Language & framework detection cyrus detect . --detailed
cyrus analyze <file> Code analysis & debugging cyrus analyze src/app.js --security
cyrus mentor <file> AI-powered code mentoring cyrus mentor src/algo.py --interactive
cyrus generate <type> Code generation utilities cyrus generate tests src/utils.js
cyrus quality <target> Comprehensive quality scoring cyrus quality . --max-files 50
cyrus health Codebase health analysis cyrus health --detailed --save
cyrus compare <first> <second> AI-powered code comparison cyrus compare old.js new.js -d
cyrus learn Interactive learning assistant cyrus learn --challenge medium
cyrus config Configuration management cyrus config init

Quick Commands

Command Description
cyrus fix <file> Quick fix critical issues
cyrus review <file> Comprehensive code review
cyrus study <file> Study mode with detailed explanations

Global Options

Option Description
--json Output in JSON format
--quiet, -q Suppress banner output
--help, -h Show help information
--version, -V Show version number

πŸ” Language Detection

Cyrus features industry-leading language detection with 95%+ accuracy:

Supported Languages

Language Extensions Frameworks Detected
JavaScript .js, .mjs, .cjs React, Vue, Express, Next.js
TypeScript .ts, .tsx React, Angular, NestJS, Next.js
Python .py, .pyw, .pyi Django, Flask, FastAPI, pytest
Java .java Spring, Spring Boot, JUnit
Go .go Gin, Echo, built-in testing
Rust .rs Actix, Rocket, cargo test
C# .cs .NET, ASP.NET, xUnit
PHP .php Laravel, Symfony, PHPUnit
Ruby .rb, .rake Rails, RSpec, Minitest

Detection Features

# Project-wide language analysis
cyrus detect .
# πŸ“Š Project Analysis
# ─────────────────────────────
# Total Files: 247
# Primary Language: TypeScript
#
# Language Distribution:
# TypeScript        β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  156 files (63.2%)
# JavaScript        β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘   78 files (31.6%)
# JSON              β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘   13 files (5.3%)
#
# 🎯 Detected Frameworks:
# β€’ React + TypeScript
# β€’ Next.js
# β€’ Tailwind CSS
# β€’ Jest (testing)
#
# πŸ“¦ Package Managers:
# β€’ bun
# β€’ npm (fallback)

# File-specific analysis with confidence
cyrus detect src/components/UserAuth.tsx --detailed
# πŸ“„ File Analysis
# ─────────────────────────────
# File: UserAuth.tsx
# Language: TypeScript
# Confidence: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 98.7%
# Frameworks: React, TypeScript
# Test Frameworks: Jest, Testing Library
#
# Language Features:
# Extensions: .tsx
# Static Analysis: βœ“
# Security Rules: βœ“
# Test Frameworks: Jest, Testing Library

πŸ€– AI Providers

Cloud Providers

OpenAI

OpenAI
GPT-4, GPT-4 Turbo
Anthropic

Anthropic
Claude 3.5 Sonnet, Opus
Google Gemini
Google
Gemini 1.5 Pro, Flash
X.AI Grok

X.AI

Local AI Support 🏠

Why Local AI?

  • βœ… No API costs - Run unlimited analysis
  • βœ… Privacy-first - Your code never leaves your machine
  • βœ… Offline capable - Work without internet
  • βœ… Custom models - Use specialized coding models

Supported Platforms:

Platform Auto-Detection Models
Ollama βœ… llama3.2, codellama, deepseek-coder, starcoder
LM Studio βœ… Any GGUF model from HuggingFace
Custom API βš™οΈ Any OpenAI-compatible server
# Setup with Ollama (example)
# 1. Install Ollama: https://ollama.ai
# 2. Pull a coding model
ollama pull codellama

# 3. Initialize Cyrus (auto-detects Ollama)
cyrus config init
# βœ“ Found local AI models:
#   Ollama: codellama, llama3.2, deepseek-coder

# 4. Start analyzing with local AI!
cyrus analyze src/app.py
# πŸ€– Using Ollama (codellama) - No API key required!

βš™οΈ Configuration

Flexible Configuration with Cosmiconfig

Cyrus uses cosmiconfig for flexible configuration management:

Supported Configuration Files:

  • package.json (in cyrus field)
  • .cyrusrc (JSON or YAML)
  • .cyrusrc.json
  • .cyrusrc.yaml / .cyrusrc.yml
  • .cyrusrc.js / .cyrusrc.cjs / .cyrusrc.mjs
  • .cyrusrc.ts
  • cyrus.config.js / cyrus.config.cjs / cyrus.config.mjs
  • cyrus.config.ts

Configuration Examples

Cloud Provider Setup (.cyrusrc.json)
{
  "$schema": "https://cyrus.dev/schema.json",
  "aiProvider": {
    "name": "openai",
    "model": "gpt-4-turbo-preview",
    "apiKey": "sk-...",
    "temperature": 0.7,
    "maxTokens": 4096
  },
  "features": {
    "securityScan": true,
    "performanceAnalysis": true,
    "codeGeneration": true,
    "refactorSuggestions": true,
    "mentorMode": true
  },
  "languages": ["javascript", "typescript", "python"],
  "outputFormat": "text",
  "detectLanguage": {
    "enabled": true,
    "confidence": 0.7
  }
}
Local AI Setup (.cyrusrc.json)
{
  "$schema": "https://cyrus.dev/schema.json",
  "aiProvider": {
    "name": "ollama",
    "model": "codellama",
    "baseURL": "http://localhost:11434/v1"
  },
  "features": {
    "securityScan": true,
    "performanceAnalysis": true,
    "codeGeneration": true,
    "refactorSuggestions": true,
    "mentorMode": true
  },
  "localModels": {
    "ollama": {
      "models": ["codellama", "llama3.2", "deepseek-coder"],
      "defaultModel": "codellama"
    }
  }
}
TypeScript Configuration (cyrus.config.ts)
import type { Config } from '@usex/cyrus';

const config: Config = {
  aiProvider: {
    name: 'anthropic',
    model: 'claude-3-5-sonnet-20241022',
    apiKey: process.env.ANTHROPIC_API_KEY!,
    temperature: 0.3,
  },
  features: {
    securityScan: true,
    performanceAnalysis: true,
    codeGeneration: true,
    refactorSuggestions: true,
    mentorMode: true,
  },
  languages: ['typescript', 'javascript', 'python', 'rust'],
  outputFormat: 'json',
  detectLanguage: {
    enabled: true,
    confidence: 0.8,
  },
};

export default config;

Environment Variables

# API Keys
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GOOGLE_API_KEY="AIza..."
export XAI_API_KEY="xai-..."

# Default Settings
export CYRUS_PROVIDER="openai"
export CYRUS_MODEL="gpt-4-turbo-preview"
export CYRUS_OUTPUT_FORMAT="text"

Configuration Commands

# Interactive setup
cyrus config init

# View current configuration
cyrus config show

# Set individual values
cyrus config set provider anthropic
cyrus config set model claude-3-5-sonnet-20241022
cyrus config set apikey sk-ant-...
cyrus config set baseurl http://localhost:11434/v1  # For local AI

# Get specific values
cyrus config get provider
cyrus config get model

# Reset configuration
cyrus config delete

🎬 Examples & Use Cases

Real-World Scenarios

πŸ” Project Onboarding
# You've just cloned a new repository
git clone https://github.com/company/mystery-project
cd mystery-project

# Understand the project structure instantly
cyrus detect .
# πŸ“Š Project Analysis
# ─────────────────────────────
# Primary Language: TypeScript (React)
# Frameworks: Next.js, Tailwind CSS, Prisma
# Package Manager: pnpm
# Test Framework: Jest + Testing Library
# Total Files: 247

# Get a health overview
cyrus health
# πŸ₯ Codebase Health: 8.7/10
# βœ… Strong type safety
# ⚠️  Some duplicate code detected
# πŸ“ˆ Excellent test coverage (94%)
πŸ› Debugging Session
# Found a problematic file
cyrus analyze src/utils/dateParser.js --explain --security
# πŸ” Analysis Results
# ─────────────────────────────
# Issues Found:
# 1. Line 15: Potential null pointer exception
# 2. Line 23: Inefficient regex pattern
# 3. Line 31: Missing input validation (Security Risk)
#
# πŸ€– AI Explanation:
# The function doesn't handle edge cases where...
# [Detailed explanation with fix suggestions]

# Get mentoring on the complex parts
cyrus mentor src/utils/dateParser.js --interactive
# πŸŽ“ Mentoring Session
# Let's walk through this code together...
# [Interactive Q&A session]
⚑ Test Generation
# Generate comprehensive tests
cyrus generate tests src/api/userController.js
# πŸ§ͺ Generated 47 test cases covering:
# βœ… Happy path scenarios (12 tests)
# βœ… Edge cases (18 tests)  
# βœ… Error conditions (12 tests)
# βœ… Security scenarios (5 tests)
#
# Tests saved to: src/api/__tests__/userController.test.js

# Generate tests for the entire module
cyrus generate tests src/utils/ --recursive
πŸ“š Documentation Generation
# Generate comprehensive documentation
cyrus generate docs src/api/
# πŸ“– Generated documentation:
# β€’ API.md - Complete API documentation
# β€’ src/api/README.md - Module overview
# β€’ Inline JSDoc comments added
# β€’ Type definitions documented

# Generate project documentation
cyrus generate docs . --type=project
# Creates: README.md, CONTRIBUTING.md, API.md
πŸ”„ Refactoring Assistance
# Get refactoring suggestions
cyrus generate refactor src/legacy/oldCode.js --interactive
# πŸ”§ Refactoring Suggestions (5 found)
# ─────────────────────────────
# 1. Extract utility function (Line 45-67)
#    Impact: High | Confidence: 94%
#    Before: [long complex function]
#    After:  [clean, modular code]
#
# Apply this suggestion? (y/N) y
# βœ… Refactoring applied successfully!

Integration Examples

πŸ”„ CI/CD Integration
# .github/workflows/code-analysis.yml
name: Code Analysis with Cyrus

on: [push, pull_request]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v1
      
      - name: Install Cyrus
        run: bun install -g @usex/cyrus
        
      - name: Setup Cyrus
        run: |
          cyrus config set provider openai
          cyrus config set model gpt-3.5-turbo
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          
      - name: Analyze Code Health
        run: cyrus health --json > health-report.json
        
      - name: Upload Health Report
        uses: actions/upload-artifact@v4
        with:
          name: health-report
          path: health-report.json
πŸ“ Pre-commit Hook
# .husky/pre-commit
#!/usr/bin/env sh

# Get staged files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|ts|jsx|tsx|py|java|go|rs)$')

if [ ${#STAGED_FILES[@]} -gt 0 ]; then
  echo "πŸ” Running Cyrus analysis on staged files..."
  
  for FILE in $STAGED_FILES; do
    echo "Analyzing $FILE..."
    cyrus analyze "$FILE" --security --quiet
    
    if [ $? -ne 0 ]; then
      echo "❌ Analysis failed for $FILE"
      exit 1
    fi
  done
  
  echo "βœ… All files passed analysis!"
fi

πŸ› οΈ Advanced Usage

Custom Workflows

πŸ“Š Team Health Dashboard
# Generate team health report
cyrus health --detailed --trends --save
# Creates comprehensive report with:
# β€’ Overall health metrics
# β€’ Language distribution changes
# β€’ Technical debt trends
# β€’ Security vulnerability tracking
# β€’ Test coverage evolution

# Export for team dashboard
cyrus health --json | jq '.summary' > team-dashboard.json
πŸ—οΈ Project Scaffolding
# Generate complete project from description
cyrus generate project "REST API with TypeScript, Prisma, and Redis"
# πŸ—οΈ  Generating project structure...
# βœ… Created TypeScript configuration
# βœ… Set up Prisma with PostgreSQL
# βœ… Configured Redis connection
# βœ… Added Express.js server
# βœ… Generated API routes
# βœ… Created test suite
# βœ… Added Docker configuration
# βœ… Generated documentation

# Generate component with tests
cyrus generate component UserProfileCard --framework=react --tests

Power User Tips

⚑ Performance Optimization
# Parallel processing for large codebases
cyrus health --parallel --workers=8

# Use local AI for unlimited analysis
cyrus config set provider ollama
cyrus analyze src/ --recursive  # No API costs!

# Cache analysis results
export CYRUS_CACHE_TTL=3600  # 1 hour cache
cyrus analyze src/  # Subsequent runs use cache
🎯 Targeted Analysis
# Language-specific analysis
cyrus analyze src/ --language=typescript --framework=react

# Security-focused scanning
cyrus analyze src/ --security --owasp --severity=high

# Performance-focused analysis
cyrus analyze src/ --performance --metrics --bottlenecks

🀝 Contributing

We love contributions! Cyrus is built by developers, for developers.

Quick Contribution Guide

  1. Fork & Clone

    git clone https://github.com/ali-master/cyrus.git
    cd cyrus
  2. Setup Development Environment

    bun install
    bun run start:cli:dev
  3. Make Your Changes

  4. Submit Pull Request

    git checkout -b feature/amazing-feature
    git commit -m 'Add amazing feature'
    git push origin feature/amazing-feature

Development Commands

# Development
bun run start:dev           # Run main in dev mode
bun run start:cli:dev       # Run CLI in dev mode

# Building
bun run build              # Build for production
bun run test:types         # Type checking

# Quality
bun run format             # Format code with Prettier
bun run lint               # Lint with ESLint
bun run lint:fix           # Auto-fix linting issues

Areas We Need Help

  • 🌍 Language Support: Add more programming languages
  • πŸ€– AI Providers: Integrate additional AI services
  • πŸ§ͺ Test Coverage: Expand our test suite
  • πŸ“– Documentation: Improve guides and examples
  • 🎨 UI/UX: Enhance the CLI experience
  • πŸ”Œ Integrations: VS Code extension, GitHub Actions

See open issues β†’


πŸ“ˆ Roadmap

🎯 v1.1 - Enhanced Detection

  • Language Support: C++, Kotlin, Swift, Dart
  • Framework Detection: Flutter, Laravel, Ruby on Rails
  • IDE Integration: VS Code extension
  • Package Ecosystem: Detect package vulnerabilities

🎯 v1.2 - Team Features

  • Team Dashboard: Web interface for team analytics
  • Historical Tracking: Code health trends over time
  • Integration APIs: Slack, Discord, Microsoft Teams
  • Custom Rules: Team-specific analysis rules

🎯 v1.3 - Advanced AI

  • Code Similarity: Duplicate code detection across repos
  • Smart Refactoring: AI-powered code transformation
  • Learning Mode: Personalized improvement suggestions
  • Code Review: AI-powered PR reviews

🎯 v2.0 - Enterprise Ready

  • Self-hosted: On-premise deployment options
  • RBAC: Role-based access control
  • Audit Logs: Compliance and security tracking
  • Custom Models: Fine-tuned AI models for specific domains

View full roadmap β†’


πŸ› Troubleshooting

❓ Common Issues

No API key found

# Check your configuration
cyrus config show

# Set your API key
cyrus config set apikey sk-your-key-here

# Or use environment variables
export OPENAI_API_KEY="sk-your-key-here"

Local AI not detected

# Ensure Ollama is running
ollama serve

# Check if models are installed
ollama list

# Re-run configuration
cyrus config init

Analysis fails

# Use verbose mode for debugging
cyrus analyze src/app.js --verbose

# Check file permissions
ls -la src/app.js

# Try with a different AI provider
cyrus config set provider anthropic

Performance issues

# Use parallel processing
cyrus health --parallel

# Increase timeout
export CYRUS_TIMEOUT=60000

# Use local AI to avoid rate limits
cyrus config set provider ollama
πŸ”§ Advanced Debugging
# Enable debug logging
export DEBUG=cyrus:*
cyrus analyze src/app.js

# Check configuration resolution
cyrus config show --debug

# Validate file detection
cyrus detect src/app.js --verbose

# Test AI connectivity
cyrus config test-connection

πŸ“„ License

MIT Β© Ali Torki

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

Cyrus stands on the shoulders of giants. Special thanks to:

AI Provider Partners

OpenAI Anthropic Google X.AI Ollama
OpenAI Anthropic Google X.AI Ollama

🌟 Star us on GitHub!

If Cyrus has helped you build better code, please give us a star. It helps us understand that we're building something valuable for the developer community.

GitHub stars

Built with ❀️ by Ali Torki for developers who demand excellence

πŸš€ Get Started β€’ πŸ“– Documentation β€’ 🐦 Linkedin

About

The Code Empire Analyzer AI-Powered Debugging & Analysis CLI for Modern Developers

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published