Relate Command
Show related nodes for an entity in the knowledge graph
Relate Command
The arc relate
command helps you explore relationships between different entities in the knowledge graph. It shows nodes that are connected to a specific entity, such as a commit, file, PR, or issue.
Usage
Subcommands
node
Show nodes related to a specific entity.
Node ID Format
The node ID follows this format: <type>:<id>
, where:
<type>
is the type of node (commit, file, pr, issue, etc.)<id>
is the identifier for that node
Examples:
commit:abc123
- A commit with hash abc123file:src/main.py
- A file at path src/main.pypr:123
- Pull request #123issue:456
- Issue #456
Options
Option | Description |
---|---|
--max-depth <depth> | Maximum depth to traverse in the knowledge graph (default: 2) |
--edge-types <types> | Comma-separated list of edge types to include |
--node-types <types> | Comma-separated list of node types to include |
--format <format> | Output format: text, json, or markdown (default: text) |
--output <file> | Write output to a file instead of stdout |
--debug | Enable debug logging |
Examples
Basic Usage
This will show all nodes directly related to commit abc123.
With Maximum Depth
This will traverse the knowledge graph up to a depth of 3 to find related information.
Filtering by Edge Types
This will only include relationships of type REFERENCES or MODIFIES.
Filtering by Node Types
This will only include related nodes of type commit or pr.
Output Format
The default output format is a text-based tree showing the related nodes:
Edge Types
Common edge types include:
Edge Type | Description |
---|---|
MODIFIES | A commit modifies a file |
MODIFIED_BY | A file is modified by a commit |
PART_OF | A commit is part of a PR |
REFERENCES | A PR references an issue |
AUTHORED_BY | A commit or PR is authored by a user |
REVIEWS | A user reviews a PR |
DEPENDS_ON | A file depends on another file |
Node Types
Common node types include:
Node Type | Description |
---|---|
commit | A Git commit |
file | A file in the repository |
pr | A pull request |
issue | An issue |
user | A user (author, reviewer, etc.) |
doc | A documentation file |
Troubleshooting
No Results Found
If no results are found, try:
- Increasing the maximum depth with
--max-depth
- Checking if the node ID is correct
- Running
arc build
to ensure the knowledge graph is up to date
Performance Issues
For large repositories, the relate
command may take some time to execute. To improve performance:
- Use a smaller maximum depth
- Filter by specific edge types or node types
- Run an incremental build first:
arc build --incremental
See Also
- Why Command - For understanding the decision trail behind a line of code
- Trace Command - For tracing the historical changes to a file or line
- Tracing History Examples - For more examples of using the
relate
command