setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Setup Repo-Native Alignment MCP

安装配置Repo-Native Alignment (RNA) MCP

Install the RNA MCP server for aim-conditioned code intelligence.
Execute these steps in order. Do not stop between steps or ask for confirmation -- run the full sequence automatically.
安装用于目标导向型代码智能的RNA MCP服务器。
请按顺序执行以下步骤。步骤间不要停止或请求确认——自动运行完整流程。

Step 1: Check if already installed

步骤1:检查是否已安装

bash
which repo-native-alignment 2>/dev/null
If found, skip to Step 3. If not found, proceed to Step 2.
bash
which repo-native-alignment 2>/dev/null
如果已找到,跳至步骤3。如果未找到,继续步骤2。

Step 2: Download the binary

步骤2:下载二进制文件

Detect the platform and chip, then download to
~/.cargo/bin/
(already on PATH for Rust users):
bash
OS=$(uname -s)
ARCH=$(uname -m)
CHIP=$(sysctl -n machdep.cpu.brand_string 2>/dev/null || echo "")
mkdir -p ~/.cargo/bin
If macOS ARM M2+ (
Darwin
+
arm64
+ brand_string contains "M2", "M3", or "M4"):
bash
curl -L https://github.com/open-horizon-labs/repo-native-alignment/releases/latest/download/repo-native-alignment-darwin-arm64-fast.tar.gz | tar xz -C ~/.cargo/bin
If macOS ARM (M1) (
Darwin
+
arm64
):
bash
curl -L https://github.com/open-horizon-labs/repo-native-alignment/releases/latest/download/repo-native-alignment-darwin-arm64.tar.gz | tar xz -C ~/.cargo/bin
If Linux x86_64 (
Linux
+
x86_64
):
bash
curl -L https://github.com/open-horizon-labs/repo-native-alignment/releases/latest/download/repo-native-alignment-linux-x86_64.tar.gz | tar xz -C ~/.cargo/bin
If none of the above match: Tell the user their platform is not yet supported. They can build from source:
bash
cargo install --locked --git https://github.com/open-horizon-labs/repo-native-alignment
If
~/.cargo/bin
is not on PATH (no Rust toolchain installed), tell the user to add it:
export PATH="$HOME/.cargo/bin:$PATH"
检测平台和芯片,然后下载至
~/.cargo/bin/
(Rust用户的该路径已在PATH中):
bash
OS=$(uname -s)
ARCH=$(uname -m)
CHIP=$(sysctl -n machdep.cpu.brand_string 2>/dev/null || echo "")
mkdir -p ~/.cargo/bin
如果是macOS ARM M2+
Darwin
+
arm64
+ 品牌字符串包含"M2"、"M3"或"M4"):
bash
curl -L https://github.com/open-horizon-labs/repo-native-alignment/releases/latest/download/repo-native-alignment-darwin-arm64-fast.tar.gz | tar xz -C ~/.cargo/bin
如果是macOS ARM (M1)
Darwin
+
arm64
):
bash
curl -L https://github.com/open-horizon-labs/repo-native-alignment/releases/latest/download/repo-native-alignment-darwin-arm64.tar.gz | tar xz -C ~/.cargo/bin
如果是Linux x86_64
Linux
+
x86_64
):
bash
curl -L https://github.com/open-horizon-labs/repo-native-alignment/releases/latest/download/repo-native-alignment-linux-x86_64.tar.gz | tar xz -C ~/.cargo/bin
如果以上都不匹配:告知用户其平台暂不支持。他们可以从源码构建:
bash
cargo install --locked --git https://github.com/open-horizon-labs/repo-native-alignment
如果
~/.cargo/bin
不在PATH中(未安装Rust工具链),告知用户添加该路径:
export PATH="$HOME/.cargo/bin:$PATH"

Step 3: Configure the MCP server

步骤3:配置MCP服务器

RNA is a per-project MCP server (it indexes the repo it's pointed at).
Check if
.mcp.json
exists in the project root and already contains an
rna-mcp
entry. If it does, skip this step.
If the agent supports
claude mcp add
(Claude Code):
bash
claude mcp add rna-mcp --scope project -- repo-native-alignment --repo .
Otherwise, create or update
.mcp.json
in the project root with:
json
{
  "mcpServers": {
    "rna-mcp": {
      "command": "repo-native-alignment",
      "args": ["--repo", "."]
    }
  }
}
If
.mcp.json
already exists with other servers, merge the
rna-mcp
entry into the existing
mcpServers
object -- do not overwrite the file.
RNA是一个基于项目的MCP服务器(它会为指向的代码仓库建立索引)。
检查项目根目录下是否存在
.mcp.json
且已包含
rna-mcp
条目。如果存在,跳过此步骤。
如果Agent支持
claude mcp add
(Claude Code):
bash
claude mcp add rna-mcp --scope project -- repo-native-alignment --repo .
否则,在项目根目录下创建或更新
.mcp.json
,内容如下:
json
{
  "mcpServers": {
    "rna-mcp": {
      "command": "repo-native-alignment",
      "args": ["--repo", "."]
    }
  }
}
如果
.mcp.json
已存在且包含其他服务器条目,请将
rna-mcp
条目合并到现有的
mcpServers
对象中——不要覆盖整个文件。

Step 4: Pre-warm the code index

步骤4:预加载代码索引

Run a full scan to build the code index before the MCP server starts. This avoids cold-start latency on the first tool call:
bash
repo-native-alignment scan --repo . --full
This builds the full pipeline (scan, extract, embed, LSP enrich, graph) and caches results in
.oh/.cache/lance/
. The MCP server reuses this cache on startup -- if no files changed, graph loads in seconds with zero re-extraction. Subsequent scans are incremental.
Without this step, the MCP server pre-warms the graph automatically at startup, but the first tool call may need to wait for that to complete. Pre-building ensures instant readiness.
在MCP服务器启动前运行完整扫描以构建代码索引。这样可以避免首次工具调用时的冷启动延迟:
bash
repo-native-alignment scan --repo . --full
此命令会构建完整流程(扫描、提取、嵌入、LSP增强、图谱)并将结果缓存到
.oh/.cache/lance/
中。MCP服务器启动时会复用该缓存——如果文件未发生变化,图谱可在数秒内加载完成,无需重新提取。后续扫描为增量式。
如果跳过此步骤,MCP服务器会在启动时自动预加载图谱,但首次工具调用可能需要等待该过程完成。提前构建可确保立即就绪。

Step 5: Update AGENTS.md with tool guidance

步骤5:更新AGENTS.md添加工具使用指南

If AGENTS.md exists in the project root, check if it already contains
<!-- RNA MCP tool guidance -->
. If it already has this marker, skip this step.
If AGENTS.md exists but lacks the marker, append this block:
markdown
<!-- RNA MCP tool guidance -->
如果项目根目录下存在AGENTS.md,检查其是否已包含
<!-- RNA MCP tool guidance -->
标记。如果已包含,跳过此步骤。
如果AGENTS.md存在但缺少该标记,追加以下内容块:
markdown
<!-- RNA MCP tool guidance -->

Code Exploration (use RNA MCP tools, not grep/Read)

代码探索(使用RNA MCP工具,而非grep/Read)

Instead of...Use this MCP tool
Grep
for symbol names
search_symbols(query, kind, language, file)
Read
to trace function calls
graph_query(node_id, mode: "neighbors")
Grep
for "who calls X"
graph_query(node_id, mode: "impact")
Read
to find .oh/ artifacts
oh_search_context(query)
Bash
with
grep -rn
search_symbols
or
oh_search_context
Recording learnings/signalsWrite to
.oh/metis/
,
.oh/signals/
,
.oh/guardrails/
(YAML frontmatter + markdown)
Searching git history
oh_search_context(query)
-- returns hash; use
git show <hash>
via Bash for diffs
<!-- end RNA MCP tool guidance -->

If AGENTS.md does not exist, create it with the tool guidance block as the initial content.
替代...使用此MCP工具
Grep
查找符号名称
search_symbols(query, kind, language, file)
Read
追踪函数调用
graph_query(node_id, mode: "neighbors")
Grep
查找"谁调用了X"
graph_query(node_id, mode: "impact")
Read
查找.oh/ 产物
oh_search_context(query)
Bash
搭配
grep -rn
search_symbols
oh_search_context
记录学习成果/信号写入
.oh/metis/
,
.oh/signals/
,
.oh/guardrails/
(YAML前置元数据 + markdown)
搜索Git历史
oh_search_context(query)
-- 返回哈希值;通过Bash使用
git show <hash>
查看差异
<!-- end RNA MCP tool guidance -->

如果AGENTS.md不存在,创建该文件并将上述工具指南块作为初始内容。

Step 6: Inform the user

步骤6:告知用户

Tell the user:
  1. Setup is complete
  2. They may need to restart their agent/IDE for the MCP server to load
  3. After restart, RNA MCP tools will be available:
    • oh_get_context
      - Business context in one call
    • oh_search_context
      - Semantic search over outcomes, code, commits
    • search_symbols
      - Multi-language symbol search with graph edges
    • graph_query
      - Impact analysis, neighbor traversal, reachability
    • outcome_progress
      - Structural outcome-to-code joins
    • list_roots
      - Workspace root management
告知用户:
  1. 安装配置已完成
  2. 他们可能需要重启Agent/IDE以加载MCP服务器
  3. 重启后,RNA MCP工具将可用:
    • oh_get_context
      - 一键获取业务上下文
    • oh_search_context
      - 对产出物、代码、提交记录进行语义搜索
    • search_symbols
      - 带图谱关联的多语言符号搜索
    • graph_query
      - 影响分析、关联节点遍历、可达性分析
    • outcome_progress
      - 结构化产出物与代码关联
    • list_roots
      - 工作区根目录管理