Add comprehensive Codegen SDK + graph-sitter integration#80
Add comprehensive Codegen SDK + graph-sitter integration#80codegen-sh[bot] wants to merge 4 commits intomainfrom
Conversation
- Automated setup script for local Postgres exposure via Cloudflare Workers - Creates dedicated database and read-only user for Codegen - Deploys Cloudflare Worker proxy with health endpoints - Saves credentials to .env file for easy integration - Includes Windows batch and PowerShell scripts for easy setup - Comprehensive testing and status reporting - Full documentation with troubleshooting guide
- Add support for multiple authentication methods - Try common default passwords automatically - Support environment variables for admin credentials - Add interactive password prompt as fallback - Update documentation with authentication troubleshooting - Handle Windows authentication scenarios
- Switch from API token to Global API Key authentication - Add support for Cloudflare email requirement - Update environment variables and batch scripts - Create specialized script with user's credentials - Fix Cloudflare Worker creation authentication
- Created main integration class with structural analysis - Added function context analysis with dependencies and call sites - Implemented AI-powered improvement suggestions - Added advanced integration with custom AI provider - Created interactive analysis mode - Added comprehensive examples and documentation - Supports both Codegen API and OpenAI API backends
Reviewer's GuideThis PR introduces a comprehensive integration between the Codegen SDK and graph-sitter by adding a new integration class, advanced and basic usage examples, a fully rewritten README, and updated dependencies to enable AI-driven code analysis and improvement workflows. Sequence Diagram for Codebase Structural AnalysissequenceDiagram
actor User
participant CGSI as CodegenGraphSitterIntegration
participant GSCodebase as graph_sitter.Codebase
User->>CGSI: new CodegenGraphSitterIntegration(org_id, token, repo_path)
activate CGSI
CGSI->>GSCodebase: Codebase.from_repo(repo_path)
activate GSCodebase
GSCodebase-->>CGSI: codebase instance
deactivate GSCodebase
deactivate CGSI
User->>CGSI: analyze_codebase_structure()
activate CGSI
CGSI->>GSCodebase: Access functions, call_sites, dependencies etc.
activate GSCodebase
GSCodebase-->>CGSI: Structural data (details for CodebaseAnalysis)
deactivate GSCodebase
CGSI-->>User: CodebaseAnalysis object
deactivate CGSI
Sequence Diagram for AI-Powered Analysis via Codegen SDKsequenceDiagram
actor User
participant CGSI as CodegenGraphSitterIntegration
participant CodegenAgent as codegen.Agent
User->>CGSI: analyze_with_codegen_ai(prompt, context_data)
activate CGSI
CGSI->>CodegenAgent: agent.run(full_prompt)
activate CodegenAgent
CodegenAgent-->>CGSI: Task object
deactivate CodegenAgent
Note right of CGSI: CGSI polls task.refresh() until completed
CGSI->>CodegenAgent: task.refresh()
activate CodegenAgent
CodegenAgent-->>CGSI: Updated Task (status: completed)
deactivate CodegenAgent
CGSI-->>User: AI analysis result (task.result)
deactivate CGSI
Class Diagram for Advanced Integration ComponentsclassDiagram
class Agent {
<<SDK Class>>
+run(prompt: str) object
}
class Codebase {
<<SDK Class>>
+from_repo(repo_path: str) Codebase
+set_ai_provider(provider: object) (conceptual)
+ai(prompt: str, target: object, context: Dict) str
+get_function(name: str) object
+get_class(name: str) object
}
class CodegenAIProvider {
-agent: Agent
+__init__(org_id: str, token: str)
+generate(prompt: str, context: Dict): str
}
class AdvancedCodegenGraphSitter {
-org_id: str
-token: str
-repo_path: str
-ai_provider: CodegenAIProvider
-codebase: Codebase
+__init__(org_id: str, token: str, repo_path: str)
-_configure_codebase_ai()
+analyze_function_with_ai(function_name: str, analysis_type: str): str
+refactor_function_with_ai(function_name: str, refactor_goal: str): str
+generate_documentation_with_ai(target_type: str, target_name: str): str
+batch_analyze_functions(analysis_type: str): Dict
+create_improvement_plan(): str
}
AdvancedCodegenGraphSitter "1" *-- "1" CodegenAIProvider : uses
AdvancedCodegenGraphSitter "1" *-- "1" Codebase : uses
CodegenAIProvider "1" *-- "1" Agent : uses
AdvancedCodegenGraphSitter ..> CodegenAIProvider : configures Codebase with
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
🚀 Comprehensive Codegen SDK + graph-sitter Integration
This PR implements a complete integration between the Codegen SDK and graph-sitter for advanced codebase analysis and AI-powered improvements.
✨ Key Features
📁 Files Added
codegen_graph_sitter_integration.py- Main integration classexamples/basic_usage.py- Basic usage examplesexamples/advanced_integration.py- Advanced integration with custom AI providerREADME.md- Comprehensive documentationrequirements.txt- Updated dependencies🎯 Usage Examples
Basic Analysis
AI-Powered Analysis
Advanced Integration
🔧 Configuration Options
Option 1: Use Codegen API
Option 2: Use OpenAI API (alternative)
🎯 Use Cases
🧪 Testing
Run the examples to test the integration:
This implementation provides exactly what was requested - a seamless integration between Codegen SDK and graph-sitter that enables comprehensive codebase analysis with AI-powered insights!
💻 View my work • About Codegen
Summary by Sourcery
Add a full featured integration between the Codegen SDK and graph-sitter to enable advanced codebase analysis and AI-driven improvements, including a new integration module, example scripts, updated dependencies, and comprehensive documentation.
New Features:
Enhancements:
Build:
Documentation:
Chores: