feat(impact): add optional doc_refs field for DocRel integration#6
Closed
seek-hope wants to merge 1 commit into
Closed
feat(impact): add optional doc_refs field for DocRel integration#6seek-hope wants to merge 1 commit into
seek-hope wants to merge 1 commit into
Conversation
When a project uses the DocRel code-documentation sync system, a .docrel/mappings.json file exists in the project root. This change: 1. Adds a DocRef struct with doc_file, doc_anchor, relationship, and symbol_name fields. 2. Adds an optional doc_refs: Option<Vec<DocRef>> field to ImpactResult. 3. In analyze_impact(), reads .docrel/mappings.json if present and attaches matching doc references for affected symbols. 4. Passes the workspace folder as project_root to enable the lookup. The feature is zero-cost when DocRel is not in use — if the .docrel/mappings.json file doesn't exist, no doc_refs are returned. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds optional DocRel documentation references (doc_refs) to the codegraph_analyze_impact tool response so downstream agents can see which docs may need updates when impacted symbols change.
Changes:
- Introduce
DocRefand adddoc_refs: Option<Vec<DocRef>>to the impact analysis result (skipping serialization when absent). - Read
.docrel/mappings.json(when present) and attach matching doc references for affected symbols. - Thread a
project_rootargument intoanalyze_impact()(MCP passes the first workspace folder; LSP passesNone).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/codegraph-server/src/domain/impact.rs | Adds DocRel types/field and reads .docrel/mappings.json to populate doc_refs. |
| crates/codegraph-server/src/mcp/server.rs | Passes workspace folder as project_root into analyze_impact() for DocRel lookup. |
| crates/codegraph-server/src/handlers/custom.rs | Updates the LSP handler call to match the new analyze_impact() signature (passes None for project_root). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // entries so agents see which docs need updating when a symbol changes. | ||
| let doc_refs: Option<Vec<DocRef>> = project_root.and_then(|root| { | ||
| let mappings_path = root.join(".docrel").join("mappings.json"); | ||
| let content = std::fs::read_to_string(&mappings_path).ok()?; |
Comment on lines
+331
to
+335
| relationship: m | ||
| .get("rel_type") | ||
| .and_then(|v| v.as_str()) | ||
| .unwrap_or("describes") | ||
| .to_string(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an optional
doc_refsfield to thecodegraph_analyze_impacttool response, enabling integration with the DocRel code-documentation sync system.Design
When a project uses DocRel, a
.docrel/mappings.jsonfile exists in the project root with symbol→document references. This PR:DocRefstruct —doc_file,doc_anchor,relationship,symbol_namedoc_refs: Option<Vec<DocRef>>toImpactResult— skips serialization when absent.docrel/mappings.jsoninanalyze_impact()— matches affected symbol names against mappingsproject_root— fromworkspace_folders.first()Behavior
.docrel/mappings.jsondoesn't exist,doc_refsisNoneNoneContext
This is the lightweight CodeGraph side of the DocRel design spec — CodeGraph provides read-only doc hints; DocRel manages mappings and sync logic.
🤖 Generated with Claude Code