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

arc relate node <node_id> [options]

Subcommands

node

Show nodes related to a specific entity.

arc relate node commit:abc123

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 abc123
  • file:src/main.py - A file at path src/main.py
  • pr:123 - Pull request #123
  • issue:456 - Issue #456

Options

OptionDescription
--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
--debugEnable debug logging

Examples

Basic Usage

arc relate node commit:abc123

This will show all nodes directly related to commit abc123.

With Maximum Depth

arc relate node file:src/main.py --max-depth 3

This will traverse the knowledge graph up to a depth of 3 to find related information.

Filtering by Edge Types

arc relate node pr:123 --edge-types REFERENCES,MODIFIES

This will only include relationships of type REFERENCES or MODIFIES.

Filtering by Node Types

arc relate node issue:456 --node-types commit,pr

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:

Related Nodes for commit:abc123
├── MODIFIES → file:src/main.py
│   └── MODIFIED_BY → commit:def456
├── PART_OF → pr:123
│   ├── REFERENCES → issue:456
│   └── AUTHORED_BY → user:jane
└── AUTHORED_BY → user:john

Edge Types

Common edge types include:

Edge TypeDescription
MODIFIESA commit modifies a file
MODIFIED_BYA file is modified by a commit
PART_OFA commit is part of a PR
REFERENCESA PR references an issue
AUTHORED_BYA commit or PR is authored by a user
REVIEWSA user reviews a PR
DEPENDS_ONA file depends on another file

Node Types

Common node types include:

Node TypeDescription
commitA Git commit
fileA file in the repository
prA pull request
issueAn issue
userA user (author, reviewer, etc.)
docA documentation file

Troubleshooting

No Results Found

If no results are found, try:

  1. Increasing the maximum depth with --max-depth
  2. Checking if the node ID is correct
  3. 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:

  1. Use a smaller maximum depth
  2. Filter by specific edge types or node types
  3. Run an incremental build first: arc build --incremental

See Also