A comprehensive code analysis tool that combines multiple scanning engines (SemGrep, Trivy, AI) with automated fixing capabilities using LangGraph orchestration.
Before installing Codetective, ensure you have the following tools installed:
pip install semgrep
ollama pull codellama
ollama start
# Clone the repository git clone https://github.com/codetective/codetective.git cd codetective # Install the package pip install -e . # OR make install # Or install from PyPI pip install codetective
ollama start
codetective info
This will show you which tools are available and their versions.
# Scan current directory with all agents codetective scan . # Scan specific paths with selected agents codetective scan /path/to/code --agents semgrep,trivy --timeout 600 # Custom output file codetective scan . --output my_scan_results.json
# Apply automatic fixes codetective fix codetective_scan_results.json
# Add explanatory comments instead codetective fix codetective_scan_results.json --agent comment
# Launch NiceGUI interface (default) codetective gui # Custom host and port codetective gui --host 0.0.0.0 --port 7891
Then open your browser to http://localhost:7891
(NiceGUI)
codetective info
Check system compatibility and tool availability.
codetective scan [paths]
Execute multi-agent code scanning.
Options:
-a, --agents
: Comma-separated agents (semgrep,trivy,ai_review)-t, --timeout
: Timeout in seconds (default: 900)-o, --output
: Output JSON file (default: codetective_scan_results.json)Examples:
codetective scan . codetective scan src/ tests/ --agents semgrep,trivy --timeout 600 codetective scan . --output security_scan.json
codetective fix <json_file>
Apply automated fixes to identified issues.
Options:
-a, --agent
: Fix agent (comment,edit) (default: edit)--keep-backup
: Keep backup files after fix completion--selected-issues
: Comma-separated list of issue IDs to fixExamples:
codetective fix scan_results.json codetective fix scan_results.json --agent comment
Codetective offers a modern web interface:
A modern, responsive web interface with better state management and real-time updates.
Codetective always outputs results in a standardized JSON format:
{ "timestamp": "2024-01-01T12:00:00", "scan_path": "/path/to/project", "semgrep_results": [ { "id": "semgrep-rule-file-line", "title": "Issue title", "description": "Detailed description", "severity": "high", "file_path": "/path/to/file.py", "line_number": 42, "rule_id": "rule.id", "fix_suggestion": "Suggested fix", "status": "detected" } ], "trivy_results": [...], "ai_review_results": [...], "total_issues": 15, "scan_duration": 45.2 }
Codetective uses a multi-agent architecture orchestrated by LangGraph:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β CLI/GUI β β Orchestrator β β Config β
β Interface βββββΆβ (LangGraph) ββββββ Management β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββΌββββββββββββββββ
β β β
βββββββββΌβββββββ ββββββββΌβββββββ ββββββββΌββββββββ
β Scan Agents β βOutput Agentsβ β Utils β
β β β β β β
β β’ SemGrep β β β’ Comment β β β’ File I/O β
β β’ Trivy β β β’ Edit β β β’ Validation β
β β’ AI Review β β β β β’ System β
ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
Contributions to the Codetective are welcome. Follow the CONTRIBUTING.md for contribution guidelines.
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This application is open-source and is released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. See the LICENSE file for details.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.