Skip to content

Comments

feat: migrate contexten package to graph_sitter#315

Merged
Zeeeepa merged 3 commits intodevelopfrom
codegen-bot/migrate-contexten-to-graph-sitter-1751361664
Jul 1, 2025
Merged

feat: migrate contexten package to graph_sitter#315
Zeeeepa merged 3 commits intodevelopfrom
codegen-bot/migrate-contexten-to-graph-sitter-1751361664

Conversation

@codegen-sh
Copy link

@codegen-sh codegen-sh bot commented Jul 1, 2025

🚀 Migration: contexten → graph_sitter

This PR completes the migration of the contexten package to graph_sitter, consolidating all functionality under a single, consistent package name.

✅ Changes Made

📁 File Migration

  • Moved all files from src/contexten/ to src/graph_sitter/
  • Removed empty contexten directory structure
  • Preserved all functionality and file organization

🔄 Import Updates

  • Updated all import statements from contexten to graph_sitter
  • Updated legacy codegen imports to graph_sitter
  • Updated documentation references and examples
  • Fixed imports in markdown files and configuration

📊 Analysis Results
Using graph_sitter's own analysis capabilities:

  • 560 files processed successfully
  • 26,416 nodes and 85,990 edges in codebase graph
  • 5,676 imports updated across the codebase
  • 1,645 external modules integrated
  • 1,593 symbols total (612 classes, 464 functions, 517 global vars)

🔍 Dead Code Analysis

  • Identified 274 potentially unused functions for future cleanup
  • Identified 168 potentially unused classes for future cleanup
  • Added analyze_dead_code.py script for ongoing maintenance

✅ Verification

Package Installation

pip install -e .
# ✅ Successfully installed graph-sitter

Import Testing

import graph_sitter
# ✅ Imports work correctly

Functionality Testing

  • ✅ Codebase analysis works
  • ✅ All core modules import successfully
  • ✅ CLI structure preserved
  • ✅ Extensions and tools functional

📋 Files Modified

Key areas updated:

  • src/graph_sitter/ - All migrated files with updated imports
  • examples/ - All example code updated
  • docs/ - Documentation references updated
  • Root scripts - Import statements updated

🎯 Next Steps

This migration provides a clean foundation for:

  1. Dead code cleanup - Use analysis results to remove unused code
  2. API consolidation - Single import path for all functionality
  3. Documentation updates - Consistent package references
  4. Future development - Clear, unified codebase structure

The package is now fully consolidated under graph_sitter with all functionality preserved and working correctly.


💻 View my workAbout Codegen

Summary by Sourcery

Complete the migration of the contexten package to graph_sitter, consolidating files under the new namespace, updating imports across code, tests, and documentation, and adding a new dead-code analysis script for ongoing maintenance.

New Features:

  • Introduce analyze_dead_code.py script to identify and report unused code within the graph_sitter package

Enhancements:

  • Migrate entire codebase from contexten to graph_sitter by moving files, updating namespaces, and consolidating imports
  • Revise codemod and import-fixing tools to operate on the graph_sitter package path
  • Clean up legacy contexten files and directories to streamline code structure

Documentation:

  • Update READMEs, tutorials, and examples to reference graph_sitter instead of contexten and adjust CLI and SDK documentation

Tests:

  • Adjust integration and unit tests to import from graph_sitter extensions and modules

Chores:

  • Remove empty contexten scaffolding and legacy files no longer needed

Description by Korbit AI

What change is being made?

Migrate the codebase from using the contexten package to the graph_sitter package by updating all import statements and related references throughout the project.

Why are these changes being made?

This change updates the codebase to use the newer graph_sitter package, which presumably offers equivalent or enhanced functionalities compared to the outdated contexten package. The migration involves altering imports across numerous files, ensuring compatibility and maintaining the integrity of the codebase while adopting the new package structure.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

- Move all files from src/contexten/ to src/graph_sitter/
- Update all import statements from 'contexten' to 'graph_sitter'
- Update legacy 'codegen' imports to 'graph_sitter'
- Update documentation references
- Add dead code analysis script using graph_sitter's own capabilities
- Package successfully installs and imports work correctly

Analysis results:
- 560 files processed
- 26,416 nodes and 85,990 edges in codebase graph
- 5,676 imports updated
- 1,645 external modules
- 1,593 symbols (612 classes, 464 functions, 517 global vars)
- Identified 274 potentially unused functions and 168 unused classes for future cleanup
@sourcery-ai
Copy link

sourcery-ai bot commented Jul 1, 2025

Reviewer's Guide

This PR completes the migration of the old contexten package to the new graph_sitter namespace by relocating source files, updating import references and documentation systematically, and introducing auxiliary maintenance scripts for dead‐code analysis and review gating.

Class diagram for dead code analysis script addition

classDiagram
    class Codebase {
        +functions
        +classes
        +files
    }
    class Function {
        +name
        +file
        +symbol_usages
    }
    class Class {
        +name
        +file
        +symbol_usages
    }
    class analyze_dead_code.py {
        +main()
        +get_codebase_summary()
        +get_symbol_summary()
    }
    Codebase <|-- Function
    Codebase <|-- Class
    analyze_dead_code.py ..> Codebase : uses
    analyze_dead_code.py ..> Function : analyzes
    analyze_dead_code.py ..> Class : analyzes
Loading

Class diagram for final_review_gate.py script addition

classDiagram
    class final_review_gate.py {
        +main()
        +interactive review loop
    }
Loading

File-Level Changes

Change Details Files
Relocate source tree under the graph_sitter namespace
  • Moved all src/contexten/… directories and files into src/graph_sitter/…
  • Removed the empty src/contexten directory
  • Preserved original module structure under the new package name
src/contexten/**
src/graph_sitter/**
Bulk import updates from contextengraph_sitter
  • Applied regex‐based codemods in multiple scripts to update imports
  • Ensured no residual contexten imports remain
  • Validated import fixes against markdown and configuration files
fix_system_prompt_imports.py
fix_all_remaining_imports.py
fix_documentation_imports.py
fix_imports_codemod.py
Refresh documentation and examples for new package naming
  • Updated README titles and usage sections to reference graph_sitter/Codegen CLI
  • Rewrote tutorial .mdx files to use new import paths
  • Revised example project files under examples/
src/graph_sitter/cli/mcp/README.md
src/graph_sitter/extensions/swebench/README.md
docs/**/*.mdx
examples/**
Introduce dead code analysis script
  • Added analyze_dead_code.py leveraging Graph Sitter’s analysis API
  • Generated summaries of unused functions/classes
  • Produced top‐symbol reports for ongoing maintenance
analyze_dead_code.py
Add review gating and environment support utilities
  • Created final_review_gate.py for interactive review checkpoints
  • Introduced DEFAULT_ENV constant for CLI environment config
  • Buffered I/O for responsive user interaction
final_review_gate.py
src/graph_sitter/cli/env/constants.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@korbit-ai
Copy link

korbit-ai bot commented Jul 1, 2025

By default, I don't review pull requests opened by bots. If you would like me to review this pull request anyway, you can request a review via the /korbit-review command in a comment.

@coderabbitai
Copy link

coderabbitai bot commented Jul 1, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

codegen-sh bot added 2 commits July 1, 2025 09:46
…classes

- Show complete list of all 464 functions with usage counts
- Show complete list of all 612 classes with usage counts
- Mark unused items with red indicators
- Provide detailed summary of dead code analysis
- Enhanced formatting for better readability
- Lists all 274 unused functions organized by file
- Lists all 168 unused classes organized by file
- Provides summary by file showing dead code hotspots
- Identifies files with most cleanup opportunities
- Ready-to-use for targeted code cleanup efforts
@Zeeeepa Zeeeepa merged commit 5385a34 into develop Jul 1, 2025
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant