Skip to content

Toolkit for detecting, analyzing, and debugging AI-generated code. Inspired by research in AI-assisted debugging, this toolkit helps developers identify and fix common issues in AI-generated code.

Notifications You must be signed in to change notification settings

t1m41n4/AICodeAnalyzer

Repository files navigation

AI Code Detective Toolkit

A powerful toolkit for detecting, analyzing, and debugging AI-generated code. Inspired by research in AI-assisted debugging, this toolkit helps developers identify and fix common issues in AI-generated code.

⚠️ Project Status: Beta

This project is under active development. While core features are functional, you may encounter bugs or incomplete features.

Current Status

✅ Working Features

  • Basic AI code detection and probability scoring
  • Security vulnerability scanning (eval, innerHTML, etc.)
  • Error handling pattern detection
  • VS Code extension with:
    • Real-time code analysis
    • Quick fixes for common issues
    • Workspace scanning
    • Status bar integration

🚧 In Progress

  • Advanced pattern recognition improvements
  • Machine learning model analysis features
  • Performance optimizations for large codebases
  • Enhanced test coverage

Key Features

  • AI Code Detection: Identify code likely generated by AI tools
  • Bug Pattern Recognition: Detect common issues in AI-generated code
  • Automated Fix Suggestions: Get intelligent suggestions for fixing identified issues
  • Complexity Analysis: Analyze code complexity and potential maintenance issues
  • Security Scanning: Identify potential security vulnerabilities in AI-generated code

Installation

pip install ai-toolkit

Quick Start

from ai_toolkit import code_analyzer

# Initialize the analyzer
analyzer = code_analyzer.AICodeAnalyzer()

# Analyze a file
results = analyzer.analyze_file('path/to/your/file.py')

# View results
print(f"AI Generated Probability: {results['ai_probability']}")
print("\nPotential Bugs:")
for bug in results['potential_bugs']:
    print(f"- {bug['description']}")

Features in Detail

1. AI Code Detection

  • Pattern recognition for AI-generated code
  • Confidence scoring for AI attribution
  • Style analysis and comparison

2. Bug Detection

  • Common AI coding pattern issues
  • Error handling problems
  • API misuse detection
  • Security vulnerability scanning

3. Fix Suggestions

  • Automated fix recommendations
  • Best practice suggestions
  • Code improvement hints

VSCode Extension Features

Installation

  1. Install from VS Code Marketplace:
    • Search for "AI Code Detective"
    • Click Install

Features

  • Real-time AI code detection
  • Dedicated sidebar for analysis results
  • Status bar integration
  • Auto-scan on file save
  • Custom highlighting for AI-generated code
  • Quick fixes and suggestions

Using the Fix All Issues Feature

The Fix All Issues button appears in two places:

  1. In the editor title area when viewing a supported file (.py, .js, .ts, etc.)
  2. At the top of the "Potential Issues" section in the AI Code Detective sidebar

To use this feature:

  1. Open a file you want to analyze
  2. Run the "AI Detective: Analyze File" command
  3. If issues are found, click the "Fix All Issues" button
  4. The extension will automatically fix all fixable issues in the file

Note: You must have an active editor open with the file you want to fix when clicking the Fix All Issues button.

Inline Highlights & Quick‑Fixes

  • Inline Decorations: Lines flagged (e.g. eval usages) are highlighted in the editor.
  • Quick Fix: Hover on a warning gutter, select "Replace with ast.literal_eval" to apply safe parsing.

New Commands

  • AI Detective: Scan Workspace scans all files in the workspace.

Configuration

Access settings through:

  1. Command Palette (Ctrl+Shift+P)
  2. Search "AI Code Detective"
  3. Customize:
    • Auto-scan behavior
    • Highlighting options
    • Analysis sensitivity

Configuration

  • probabilityThreshold: 0.5
  • complexityThreshold: 10

CLI Usage

ai-toolkit path/to/your_file.py

Outputs JSON with fields:

  • ai_probability
  • potential_bugs
  • complexity_score
  • suggested_fixes

Development & Testing

Install in editable mode:

pip install -e .

Run Python tests:

pytest

Run VS Code extension tests:

npm install
npm run compile
npm run test

Use Cases

  • Code review automation
  • Quality assurance for AI-generated code
  • Security auditing
  • Technical debt assessment

Contributing

We welcome contributions! See our Contributing Guide for details.

License

MIT License - see LICENSE file for details.

About

Toolkit for detecting, analyzing, and debugging AI-generated code. Inspired by research in AI-assisted debugging, this toolkit helps developers identify and fix common issues in AI-generated code.

Resources

Stars

Watchers

Forks