Skip to content

Implement remote repository support and dependency graph analysis#11

Merged
Reim-developer merged 33 commits intomasterfrom
dev
Apr 4, 2026
Merged

Implement remote repository support and dependency graph analysis#11
Reim-developer merged 33 commits intomasterfrom
dev

Conversation

@Reim-developer
Copy link
Copy Markdown
Owner

@Reim-developer Reim-developer commented Apr 4, 2026

Summary by CodeRabbit

  • New Features
    • Added graph command for dependency analysis with cycle detection, supporting JSON, Markdown, XML, and Graphviz DOT formats.
    • Added remote repository analysis via --url flag for loc, context, and graph commands.
    • Introduced --ref parameter for analyzing specific branches, tags, or commits.
    • Added --what-depends-on for reverse dependency queries and --focus/--depth for targeted analysis.

…de and add dependency graph analysis capabilities.
…tions with URL mode and associated CLI tests
…mentation for v0.5.x configuration and URL mode support
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sephera Building Building Preview Apr 4, 2026 9:33am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request introduces version 0.5.0 featuring a new graph command for dependency analysis using Tree-sitter, URL-based remote repository support for loc and context commands, and a new runtime module providing unified source resolution and context command handling for both local and remote sources.

Changes

Cohort / File(s) Summary
Version Bump
Cargo.toml, crates/sephera_core/Cargo.toml, crates/sephera_mcp/Cargo.toml
Updated workspace and crate versions from 0.4.0 to 0.5.0; added production dependencies tempfile and toml to sephera_core; added dev-dependency tempfile to sephera_mcp.
README & Documentation
README.md, docs/index.md, docs/getting-started.md, docs/src/content/docs/commands/loc.md, docs/src/content/docs/commands/context.md, docs/src/content/docs/commands/mcp.md, docs/src/content/docs/commands/graph.md, docs/src/content/docs/configuration/sephera-toml.md, docs/astro.config.mjs
Expanded README scope to highlight four commands (added graph); documented URL-mode workflows and remote ref support for loc, context, and graph; added new graph command documentation with examples and output formats; updated configuration docs for URL-mode semantics; added sidebar entry for graph command.
CLI Argument Definitions
crates/sephera_cli/src/args.rs
Added new Graph command variant with GraphArgs and GraphOutputFormat enums; transformed LocArgs and ContextArgs to support mutually-exclusive path/url plus optional git_ref (renamed --ref); expanded help text for URL-mode behavior; added comprehensive unit tests for argument parsing and validation.
Output Rendering
crates/sephera_cli/src/output.rs, crates/sephera_cli/src/output/graph.rs, crates/sephera_cli/src/output/profiles.rs
Added new graph module implementing render_graph dispatcher; implemented format-specific renderers for JSON, Markdown (with Mermaid diagrams), XML, and Graphviz DOT outputs; updated profiles.rs import path for AvailableContextProfiles.
Context Configuration
crates/sephera_cli/src/context_config.rs
Refactored from module-based structure to single-file implementation; added resolve_context_options function wrapping CLI arguments for runtime resolution; updated re-exports to use sephera_core::core::runtime types directly.
Command Execution
crates/sephera_cli/src/run.rs, crates/sephera_cli/src/lib.rs
Simplified context execution by delegating to build_context_report; added new run_graph function for graph command dispatch; removed obsolete context_diff module; integrated output progress handling for both stdout and file outputs.
Core Module Structure
crates/sephera_core/src/core.rs, crates/sephera_core/src/core/project_files.rs
Added new public modules graph and runtime; changed project_files visibility from private to pub(crate); updated collect_project_files visibility from pub(super) to pub.
Graph Analysis Module
crates/sephera_core/src/core/graph.rs, crates/sephera_core/src/core/graph/types.rs, crates/sephera_core/src/core/graph/imports.rs, crates/sephera_core/src/core/graph/resolver.rs
Created complete dependency graph analysis subsystem: types.rs defines ImportStatement, GraphReport, GraphEdge, GraphNode, and graph-related enums/metrics; imports.rs implements per-language Tree-sitter-based import extraction (Rust, Python, JS/TS, Go, Java, C/C++); resolver.rs builds dependency graphs with cycle detection, focus/depth filtering, and reverse-dependency queries.
Runtime Module
crates/sephera_core/src/core/runtime.rs, crates/sephera_core/src/core/runtime/context.rs, crates/sephera_core/src/core/runtime/source.rs, crates/sephera_core/src/core/runtime/git.rs
New runtime subsystem providing unified handling for local and remote analysis: source.rs implements SourceRequest resolution with Git URL/SCP parsing, tree URL support, and temporary checkout management; context.rs resolves context commands with config discovery, profile merging, and diff resolution; git.rs provides CLI-based git command execution helpers.
MCP Server Updates
crates/sephera_mcp/src/server.rs
Extended from two tools (loc, context) to three (loc, context, graph); refactored tool implementations to use resolve_source for URL support; added graph tool with reverse-dependency queries and JSON output; expanded context tool to route through resolve_context_command and support profiles/diffs; consolidated error handling via map_internal_error and output serialization via serialize_json.
Integration Tests
crates/sephera_cli/tests/graph_cli.rs, crates/sephera_cli/tests/url_mode.rs
Added graph_cli.rs with three tests validating --what-depends-on, --focus, and error handling for missing targets; added url_mode.rs with comprehensive tests for remote repository workflows including tag checkout, profile discovery, diff restrictions, and all three commands (loc, context, graph).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant SourceResolver
    participant GitHandler
    participant ImportExtractor
    participant GraphBuilder
    participant ReportRenderer

    Client->>SourceResolver: resolve_source(SourceRequest)
    
    alt URL mode
        SourceResolver->>GitHandler: clone & checkout repo
        GitHandler->>SourceResolver: TempDir with analysis_path
    else Local mode
        SourceResolver->>SourceResolver: validate local path
    end
    
    SourceResolver->>Client: ResolvedSource

    Client->>GraphBuilder: build_graph(analysis_path, focus, depth, query)
    
    loop For each project file
        GraphBuilder->>ImportExtractor: extract_imports(source_code, language)
        ImportExtractor->>ImportExtractor: Tree-sitter parse & walk AST
        ImportExtractor->>GraphBuilder: Vec<ImportStatement>
    end
    
    GraphBuilder->>GraphBuilder: resolve imports to internal files
    GraphBuilder->>GraphBuilder: apply focus/depth/query filters
    GraphBuilder->>GraphBuilder: detect cycles
    GraphBuilder->>Client: GraphReport

    Client->>ReportRenderer: render_graph(report, format)
    
    alt JSON
        ReportRenderer->>ReportRenderer: serde_json::to_string_pretty
    else Markdown with Mermaid
        ReportRenderer->>ReportRenderer: build text doc + graph LR diagram
    else XML
        ReportRenderer->>ReportRenderer: construct XML tree with metrics
    else DOT
        ReportRenderer->>ReportRenderer: digraph with nodes/edges
    end
    
    ReportRenderer->>Client: formatted String
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

The changes span multiple interconnected domains: a new substantial feature (graph command with multi-language Tree-sitter support), significant runtime refactoring introducing three new modules (source, context, git) with complex logic for URL parsing and remote checkout handling, and heterogeneous modifications across CLI, core library, and MCP server. While individual file changes follow consistent patterns, the density of new code, diverse interaction patterns, and integration points across local/remote paths demand careful sequential reasoning across cohorts.

Poem

🐰 A graph of dependencies, drawn with care,
Tree-sitter whispers imports from everywhere,
Markdown, JSON, XML, or DOT so fine,
Local paths or GitHub URLs align,
Cycles detected, profiles applied with grace,
Version point-five hops into place! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 78.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the two main changes: implementing remote repository support and adding dependency graph analysis, which are the primary features across the entire changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #12

coderabbitai bot added a commit that referenced this pull request Apr 4, 2026
Docstrings generation was requested by @Reim-developer.

* #11 (comment)

The following files were modified:

* `crates/sephera_cli/src/context_config.rs`
* `crates/sephera_cli/src/output/graph.rs`
* `crates/sephera_cli/src/output/profiles.rs`
* `crates/sephera_cli/src/run.rs`
* `crates/sephera_cli/tests/graph_cli.rs`
* `crates/sephera_cli/tests/url_mode.rs`
* `crates/sephera_core/src/core/graph/imports.rs`
* `crates/sephera_core/src/core/graph/resolver.rs`
* `crates/sephera_core/src/core/project_files.rs`
* `crates/sephera_core/src/core/runtime/context.rs`
* `crates/sephera_core/src/core/runtime/git.rs`
* `crates/sephera_core/src/core/runtime/source.rs`
* `crates/sephera_mcp/src/server.rs`
@coderabbitai coderabbitai bot mentioned this pull request Apr 4, 2026
@Reim-developer Reim-developer merged commit b463ba6 into master Apr 4, 2026
24 of 25 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