{"id":29729565,"url":"https://github.com/jackccrawford/pr-2-graph","last_synced_at":"2025-07-25T04:13:39.748Z","repository":{"id":305821527,"uuid":"1024041631","full_name":"jackccrawford/pr-2-graph","owner":"jackccrawford","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-22T06:59:26.000Z","size":139,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-22T07:39:40.139Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jackccrawford.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-22T05:25:40.000Z","updated_at":"2025-07-22T06:47:33.000Z","dependencies_parsed_at":"2025-07-22T07:39:42.929Z","dependency_job_id":"8c7abc8c-5842-4ba3-b1d4-99eb97e2483e","html_url":"https://github.com/jackccrawford/pr-2-graph","commit_stats":null,"previous_names":["jackccrawford/pr-2-graph"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/jackccrawford/pr-2-graph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackccrawford%2Fpr-2-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackccrawford%2Fpr-2-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackccrawford%2Fpr-2-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackccrawford%2Fpr-2-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackccrawford","download_url":"https://codeload.github.com/jackccrawford/pr-2-graph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackccrawford%2Fpr-2-graph/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266952936,"owners_count":24011513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-25T04:13:33.934Z","updated_at":"2025-07-25T04:13:39.739Z","avatar_url":"https://github.com/jackccrawford.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pr-2-graph\n## GitHub PR Conversation Analysis and Knowledge Graph Generation\n\n[![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE)\n[![Python](https://img.shields.io/badge/Python-3.12+-3776AB?style=for-the-badge\u0026logo=python\u0026logoColor=white)](https://www.python.org/downloads/)\n[![Poetry](https://img.shields.io/badge/Poetry-2.1.3-60A5FA?style=for-the-badge\u0026logo=poetry\u0026logoColor=white)](https://python-poetry.org/)\n[![FastAPI](https://img.shields.io/badge/FastAPI-0.116.1-009688?style=for-the-badge\u0026logo=fastapi\u0026logoColor=white)](https://fastapi.tiangolo.com/)\n[![Pydantic](https://img.shields.io/badge/Pydantic-2.11.7-E92063?style=for-the-badge\u0026logo=pydantic\u0026logoColor=white)](https://docs.pydantic.dev/)\n[![D3.js](https://img.shields.io/badge/D3.js-Interactive_Graphs-F9A03C?style=for-the-badge\u0026logo=d3.js\u0026logoColor=white)](https://d3js.org/)\n[![Ollama](https://img.shields.io/badge/Ollama-LLM_Integration-4285F4?style=for-the-badge)](https://ollama.ai/)\n[![Status](https://img.shields.io/badge/Status-Active_Development-EAB308?style=for-the-badge)]()\n[![Architecture](https://img.shields.io/badge/Architecture-Plugin_Based-9ca3af?style=for-the-badge)]()\n[![Analysis](https://img.shields.io/badge/Analysis-Multi--Agent-ff69b4?style=for-the-badge)]()\n[![Visualization](https://img.shields.io/badge/Visualization-Interactive-22C55E?style=for-the-badge)]()\n\n\u003e **Note**: This project is currently under active development. APIs are stable with comprehensive documentation.\n\n## Overview\n\npr-2-graph is an open-source tool that analyzes GitHub Pull Request conversations and transforms them into interactive knowledge graphs. Originally developed as part of Devin AI's plugin system, it has been generalized to help development teams understand collaboration patterns, identify breakthrough moments, and visualize problem-solving flows.\n\n## Architecture: Multi-Model LLM Analysis Pipeline\n\npr-2-graph uses a sophisticated three-stage LLM pipeline with custom Ollama models, each specialized for specific aspects of PR conversation analysis:\n\n```\n┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐\n│   pr-analyzer   │───▶│   pr-critic      │───▶│  pr-formatter   │\n│   (Primary)     │    │   (Quality)      │    │  (Structure)    │\n│ gemma3n:e2b base│    │ qwen3:1.7b base  │    │ phi4-mini base  │\n└─────────────────┘    └──────────────────┘    └─────────────────┘\n        ▲                        ▲                        ▲\n        │                        │                        │\n   Modelfile with           Modelfile with          Modelfile with\n   PR analysis              critique focus          JSON formatting\n   instructions             instructions            instructions\n```\n\n### Model Specialization\n\n1. **pr-analyzer** (Primary Analysis)\n   - **Base Model**: gemma3n:e2b (5.6GB)\n   - **Purpose**: Extract semantic relationships, identify collaboration patterns, detect breakthrough moments\n   - **Specialization**: GitHub PR conversation analysis with focus on multi-agent workflows\n\n2. **pr-critic** (Quality Review)\n   - **Base Model**: qwen3:1.7b (1.4GB)\n   - **Purpose**: Validate analysis accuracy, identify missing elements, suggest improvements\n   - **Specialization**: Quality assurance for PR analysis with focus on completeness and consistency\n\n3. **pr-formatter** (Structured Output)\n   - **Base Model**: phi4-mini:3.8b (2.5GB)\n   - **Purpose**: Extract and format analysis into structured JSON, ensure data consistency\n   - **Specialization**: JSON formatting and data structure validation\n\n### Pipeline Benefits\n- **Memory Efficient**: Models loaded/unloaded dynamically based on system resources\n- **Quality Assured**: Multi-stage validation ensures accurate and complete analysis\n- **Specialized Performance**: Each model optimized for its specific task\n- **Fallback Support**: Graceful degradation when models are unavailable\n\n## Key Features\n\n### Semantic Analysis\n- Extract relationships, roles, and collaboration patterns from PR conversations\n- Identify participant contributions and expertise domains\n- Map technical decision points and their outcomes\n- Support for complex multi-participant discussions\n\n### Breakthrough Detection\n- Identify key problem-solving moments and insights\n- Track resolution patterns and solution emergence\n- Analyze collaboration effectiveness and team dynamics\n- Detect innovation and creative problem-solving instances\n\n### Multi-Agent Support\n- Specialized analysis for human-AI collaboration patterns\n- Recognition of different agent types and their contributions\n- Analysis of coordination patterns in mixed teams\n- Support for complex multi-agent workflows\n\n### Interactive Visualization\n- D3.js-powered knowledge graphs with physics simulation\n- Real-time interaction with hover details and drag functionality\n- Customizable node and edge styling based on relationship types\n- Export capabilities for presentations and documentation\n\n### Extensible Architecture\n- Plugin system for custom analysis types\n- Configurable LLM models and analysis parameters\n- Environment-driven configuration management\n- Professional deployment patterns with health monitoring\n\n## Installation\n\n### Prerequisites\n\n- Python 3.12+\n- Poetry for dependency management\n- [Ollama](https://ollama.ai/) for local LLM inference\n- Git for version control\n\n### Local Development\n\n```bash\n# Clone repository\ngit clone https://github.com/your-username/pr-2-graph.git\ncd pr-2-graph\n\n# Install dependencies\npoetry install\n\n# Set up custom Ollama models\ncd ollama-models\n./setup_pr_models.sh\n\n# Configure environment\ncp .env .env.local\n# Edit .env.local with your settings\n\n# Start server with custom models\n./run_server.sh\n```\n\n### Custom Model Setup\n\nThe system uses three specialized Ollama models. Run the setup script to create them:\n\n```bash\ncd ollama-models\n./setup_pr_models.sh\n```\n\nThis creates:\n- `pr-analyzer:latest` - Primary PR conversation analysis\n- `pr-critic:latest` - Quality review and validation\n- `pr-formatter:latest` - JSON formatting and structure\n\nUpdate your `.env.local` to use these models:\n```bash\nPRIMARY_MODEL=pr-analyzer:latest\nCRITIC_MODEL=pr-critic:latest\nFORMATTER_MODEL=pr-formatter:latest\n```\n\n### Testing\n\n```bash\n# Health check\ncurl -X GET http://localhost:7700/health\n\n# Model manager status\ncurl -X GET http://localhost:7700/api/models/status\n\n# Test with TIN Sidekick PR data\ncurl -X POST http://localhost:7700/api/models/test-tin-analysis\n\n# Test with TIN Docs PR data\ncurl -X POST http://localhost:7700/api/models/test-tin-docs-analysis\n\n# Test with HuggingFace PR data\ncurl -X POST http://localhost:7700/api/models/test-huggingface-analysis\n\n# Direct LLM analysis\ncurl -X POST http://localhost:7700/api/models/analyze \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"conversation\": \"Your PR conversation text here\"}'\n\n# Interactive API documentation\n# Open in browser: http://localhost:7700/docs\n```\n\n## Test Results\n\n### Multi-Model Pipeline Performance\n\nOur custom Ollama models demonstrate significant improvements over generic prompts:\n\n| **Test Case** | **Confidence** | **Participants** | **Relationships** | **Breakthrough Moments** |\n|---------------|----------------|------------------|-------------------|-------------------------|\n| TIN Sidekick PR | 0.7 | 2 | 2 | 1 (\"CODE IS TRUTH\") |\n| TIN Docs PR | 0.7 | 1 | 3 | 0 |\n| HuggingFace PR | **0.85** | **5** | **5** | **2** |\n\n### Real-World Analysis Examples\n\n#### HuggingFace Transformers PR #39561\n**Collaboration Pattern**: maintainer_coordination_with_automation\n- **Human Contributors**: vasqu (issue identifier), molbap \u0026 ArthurZucker (maintainers)\n- **Automation**: github-actions (testing), HuggingFaceDocBuilderDev (docs)\n- **Key Insight**: Post-merge conflict resolution with Ernie 4.5 model updates\n- **Breakthrough Moments**: Issue identification and automated documentation preview\n\n#### TIN Sidekick PR Analysis\n**Collaboration Pattern**: human_ai_debugging_workflow\n\n- **30 Comments** from 3 participants\n- **90 Knowledge Graph Triplets** extracted\n- **Participants Identified**:\n  - Devin (AI Flutter Specialist) - 12 comments\n  - Jack/Cascade (AI Backend Specialist) - 18 comments\n- **Issues Detected**: Authentication Flow, Message Format, API Parsing, Duplication, Debug Execution\n- **Solutions Identified**: Message Format Fix, API Parsing Fix, Authentication Fix, Duplication Fix\n- **Relationship Types**: ANALYZES, IMPLEMENTS, PROVIDES, REPLIES_TO, RESOLVES\n\n### LLM-Enhanced Analysis\n\nWith the new LLM-powered backend:\n\n- **Asymmetric Relationship Types**: DIAGNOSES_ROOT_CAUSE, CONFIRMS_THROUGH_TESTING, VALIDATES_SYSTEMATICALLY, PROVIDES_BREAKTHROUGH\n- **Breakthrough Moment Detection**: Identifies novel insights that changed conversation direction\n- **Confidence Scoring**: Based on insight novelty and impact rather than keyword presence\n- **Participant Role Analysis**: Strategic analyst vs implementation specialist vs coordinator\n- **Interactive Visualization**: D3.js physics-based graph with hover details and drag functionality\n\n### Sample Knowledge Graph Output\n\n```json\n{\n  \"nodes\": [\n    {\n      \"id\": \"devin-ai-integration[bot]\",\n      \"label\": \"Devin (AI Flutter Specialist)\",\n      \"type\": \"participant\",\n      \"properties\": {\"role\": \"ai_flutter_specialist\", \"comment_count\": 12}\n    },\n    {\n      \"id\": \"authentication_issue\",\n      \"label\": \"Authentication Flow\",\n      \"type\": \"issue\",\n      \"properties\": {\"keywords\": [\"403\", \"401\", \"authentication\", \"auth\", \"token\"]}\n    }\n  ],\n  \"edges\": [\n    {\n      \"id\": \"devin-ai-integration[bot]-ANALYZES-authentication_issue\",\n      \"source\": \"devin-ai-integration[bot]\",\n      \"target\": \"authentication_issue\",\n      \"relationship\": \"ANALYZES\"\n    }\n  ],\n  \"triplets\": [\n    {\n      \"subject\": \"devin-ai-integration[bot]\",\n      \"predicate\": \"ANALYZES\",\n      \"object\": \"authentication_issue\",\n      \"confidence\": 0.8\n    }\n  ]\n}\n```\n\n## Future Plugin Ideas\n\nThe extensible architecture supports additional plugins such as:\n\n- **Code Analysis Plugin** - Analyze code changes and patterns\n- **Performance Metrics Plugin** - Extract performance-related insights\n- **Collaboration Patterns Plugin** - Identify team collaboration patterns\n- **Issue Resolution Plugin** - Track issue resolution workflows\n\n## Contributing\n\nTo add a new plugin:\n\n1. Create a new file in `app/plugins/`\n2. Implement the `BasePlugin` interface\n3. Register the plugin in `app/main.py`\n4. Add appropriate tests\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Author\n\n**Jack C Crawford** - *Initial work*","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackccrawford%2Fpr-2-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackccrawford%2Fpr-2-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackccrawford%2Fpr-2-graph/lists"}