# ⚡ Quick Start Guide - AI Commit Reviewer Pro v1.1.3

**Get started in 3 minutes with super-modern code analysis!**

---

## 1️⃣ Install (30 seconds)

```bash
npm install -g ai-commit-reviewer-pro
```

**Or for development:**
```bash
cd ~/projects/ai-commit-reviewer-pro
npm install
node cli.js
```

---

## 2️⃣ Configure (1 minute)

### Option A: Use ChatGPT (Recommended)
```bash
# Set your OpenAI API key
export OPENAI_API_KEY="sk_..."

# Run
ai-review
```

### Option B: Use GitHub Copilot
```bash
# Set your GitHub token
export GITHUB_TOKEN="ghp_..."

# Run
ai-review
```

### Option C: Use Both (Automatic Fallback)
```bash
# Set both for automatic fallback
export OPENAI_API_KEY="sk_..."
export GITHUB_TOKEN="ghp_..."

# Copilot is primary, ChatGPT is fallback
ai-review
```

---

## 3️⃣ Use It! (Less than 1 minute)

### Stage your code changes:
```bash
git add src/index.js config.json theme/product.liquid
```

### Run the review:
```bash
ai-review
```

### See the magic! ✨
```
🤖 AI Commit Reviewer Pro v1.1.3

🔴 CRITICAL: Hardcoded API key detected
   File: config.json (Line 15)
   Fix: Use process.env.API_KEY
   Example: const API = process.env.STRIPE_KEY;

🟠 HIGH: Function has 8 parameters
   File: src/index.js (Line 42)
   Fix: Use options object
   Example: const fn = ({p1, p2, p3}) => { ... }

🟡 MEDIUM: console.log detected
   File: src/index.js (Line 88)
   Fix: Use logging library (winston, pino)

💡 TIP: Large code block (500+ chars)
   File: src/index.js (Line 105-245)
   Could be 20-30% smaller with modern patterns

✅ Analysis complete: 4 issues found
```

---

## 📊 What It Analyzes

### 🔴 Critical Issues (Must Fix)
- Hardcoded secrets/passwords
- eval() and code execution
- 'with' statement usage
- Empty error handlers
- Undeclared variables

### 🟠 High Priority (Should Fix)
- Hardcoded API keys
- N+1 database queries
- XSS vulnerabilities
- Functions with 6+ parameters
- Complex nested logic

### 🟡 Medium Priority (Should Address)
- console.log in production
- Promise chains (→ async/await)
- var declarations (→ const)
- Loose equality (== vs ===)
- Loop optimization

### 💡 Tips (Nice to Improve)
- Unused imports
- TODO/FIXME comments
- Code simplification opportunities
- Dependency review
- Performance tweaks

---

## 🌍 Supports 24+ Languages

```javascript
// JavaScript
// Your standard JavaScript code ✅

// TypeScript  
interface User { id: number; name: string; }

// Python
def process_data(items):
    return [x * 2 for x in items]

// Shopify Liquid
{% for product in products %}
  {{ product.title }}
{% endfor %}

// And 20+ more!
// Ruby, Go, Rust, PHP, Java, C++, C#, Swift, Kotlin, Scala, SQL, HTML, CSS, JSON, YAML...
```

---

## 🎯 Real Example

### Your Code:
```javascript
// src/auth.js
const API_KEY = "sk_live_abc123def456";
const SECRET = "secret_password_123";

async function loginUser(email, password, rememberMe, saveToken, checkEmail, validatePassword) {
  var user = null;
  
  for (let key in userDatabase) {
    if (email.indexOf(key) != -1) {
      user = userDatabase[key];
      break;
    }
  }
  
  try {
    await authenticate(user);
  } catch (e) {
    // Silently fail
  }
  
  return user ? { status: true } : { status: false };
}
```

### Plugin Output:
```
🤖 AI Commit Reviewer Pro v1.1.3

🔴 CRITICAL: Hardcoded API key detected (Line 2)
   Fix: Use process.env.STRIPE_API_KEY
   Example: const API_KEY = process.env.STRIPE_API_KEY;

🔴 CRITICAL: Hardcoded password detected (Line 3)
   Fix: Use environment variables
   Example: const SECRET = process.env.APP_SECRET;

🟠 HIGH: Function has 6 parameters (Line 5)
   Fix: Use options object
   Example: const loginUser = ({email, password, rememberMe, ...}) => { }

🟡 MEDIUM: for...in loop (Line 9)
   Fix: Use for...of instead
   Example: for (const key of Object.keys(userDatabase)) { }

🔴 CRITICAL: Loose equality check (Line 10)
   Fix: Use === instead of ==
   Example: if (email.includes(key)) {

💡 TIP: Variable 'user' declared with var (Line 7)
   Better: Use const or let
   Example: let user = null;

🔴 CRITICAL: Empty catch block (Line 15-16)
   Fix: Log or handle the error
   Example: catch (e) { logger.error('Auth failed:', e); }

✅ 7 issues found | 4 critical | 1 high
```

### Modern Version:
```javascript
// src/auth.js - FIXED
const API_KEY = process.env.STRIPE_API_KEY;
const SECRET = process.env.APP_SECRET;

const loginUser = async (options) => {
  const { email, password, rememberMe, saveToken, checkEmail, validatePassword } = options;
  
  const user = Object.values(userDatabase)
    .find(u => email.includes(u.email));
  
  try {
    await authenticate(user);
  } catch (error) {
    logger.error('Authentication failed:', error);
    throw error;
  }
  
  return { status: Boolean(user) };
};
```

---

## 🚀 Features by Category

### Security (8 patterns)
✅ Find hardcoded secrets  
✅ Detect API key leaks  
✅ Identify injection risks  
✅ Find XSS vulnerabilities  
✅ Detect innerHTML usage  
✅ Spot template injections  
✅ Warn about HTTP connections  
✅ Find eval() usage  

### Performance (7 patterns)
✅ Find N+1 queries  
✅ Suggest loop optimization  
✅ Recommend array consolidation  
✅ Identify DOM selector caching  
✅ Suggest async/await  
✅ Flag console.log  
✅ Verify setTimeout usage  

### Modern Code (8 patterns)
✅ var → const/let  
✅ == → ===  
✅ indexOf → includes()  
✅ Promises → async/await  
✅ Functions → arrow functions  
✅ Object.keys().map → Object.entries()  
✅ Empty try-catch  
✅ Optional chaining & nullish coalescing  

### More Categories
✅ Code Refactoring (4 patterns)  
✅ Liquid Templates (3 patterns)  
✅ Error Detection (6 patterns)  
✅ Code Quality (3 patterns)  
✅ Unused Code (3 patterns)  
✅ Architecture (3 patterns)  
✅ Python Patterns (2 patterns)  
✅ Low-Code (2 patterns)  

---

## 🎓 Tips & Tricks

### See Everything in Detail
```bash
# Run in debug mode
DEBUG=* ai-review
```

### Focus on One File
```bash
# Add a specific file
git add src/important.js
ai-review
```

### Skip Review (When Needed)
```bash
# Push without review
git commit -m "Quick fix" --no-verify
```

### Check Documentation
```bash
# Read the comprehensive guide
cat MODERN_FEATURES.md
```

---

## ❓ Common Questions

**Q: Does it upload my code?**  
A: No! Analysis happens locally. Only optional AI suggestions need internet.

**Q: What if I don't have an API key?**  
A: Local pattern matching still works. No internet required.

**Q: Can I use both ChatGPT and Copilot?**  
A: Yes! Set both and it automatically falls back if one fails.

**Q: Does it block commits?**  
A: No! Suggestions are informational only. Commits always proceed.

**Q: How many languages are supported?**  
A: 24+ languages including Shopify Liquid.

**Q: How is this different from ESLint?**  
A: Covers all languages, AI-powered suggestions, finds security issues, simplification opportunities.

---

## 📚 Learn More

- 📖 **Full Guide:** [MODERN_FEATURES.md](./MODERN_FEATURES.md)
- 📋 **Release Notes:** [RELEASE_NOTES_v1.1.3.md](./RELEASE_NOTES_v1.1.3.md)
- ✅ **Validation:** [VALIDATION_REPORT_v1.1.3.md](./VALIDATION_REPORT_v1.1.3.md)
- 🎯 **Feature Showcase:** [FEATURE_SHOWCASE.md](./FEATURE_SHOWCASE.md)

---

## 🆘 Troubleshooting

### "Command not found: ai-review"
```bash
# Install globally
npm install -g ai-commit-reviewer-pro

# Or use directly
npx ai-commit-reviewer-pro
```

### "No staged changes found"
```bash
# Stage some code first
git add src/file.js

# Then run review
ai-review
```

### "API key error"
```bash
# Check your key is set
echo $OPENAI_API_KEY
echo $GITHUB_TOKEN

# Or set it again
export OPENAI_API_KEY="sk_..."
ai-review
```

---

## 🎉 You're Ready!

```bash
# One more time:
git add your-changes
ai-review

# Watch the magic! ✨
```

---

**Questions?** Check [MODERN_FEATURES.md](./MODERN_FEATURES.md)  
**Want details?** Read [RELEASE_NOTES_v1.1.3.md](./RELEASE_NOTES_v1.1.3.md)  
**Need help?** Visit [GitHub Issues](https://github.com/snbroy/ai-commit-reviewer-pro/issues)  

---

**Happy coding! 🚀**
