src/installer/ · targets/registry.ts · 手刻 TOML serializer安裝器是 codegraph install(與裸 codegraph / npx @colbymchenry/codegraph)的入口。架構刻意做成可擴充:targets/registry.ts 列所有 agent;targets/types.ts 定義 AgentTarget interface——加第 5 個 agent = targets/ 一個新檔 + registry 一個 entry。每個 target 自己負責它的 config 檔位置與 MCP-server JSON/TOML/JSONC 寫法。
目前的 targets:claude.ts、cursor.ts、codex.ts、opencode.ts,加上 Hermes / Gemini CLI / Antigravity / Kiro / Copilot 三 surface。每個 target 實現偵測(agent 是否安裝)、config 路徑、MCP server 設定寫入與移除。codegraph install 的「問哪些 agent」就是列 registry 自動偵測。
Codex 用 TOML。為了不破壞使用者原本的設定,這個 serializer 只處理 [mcp_servers.codegraph],sibling tables 與 [[array_of_tables]] 原樣保留。不引入新 dependency。
opencode 預設讀 opencode.jsonc:偏好既有 .jsonc、fallback .json、greenfield 建 .jsonc。編輯用 jsonc-parser 精準改——使用者的註解與排版在 install / re-install / uninstall round-trip 後存活。這是「絕不亂開實驗性 flag、不啟用 plugin、不信任第三方指令」原則的體現。
主 agent 收到 MCP initialize 的指引,但 sub-agent 與非 MCP harness 收不到——所以安裝器在每個 agent 的 instructions 檔寫入短 marker-fenced 段落,指向 codegraph explore CLI 對等指令。`codegraph uninstall` 可乾淨移除。Copilot target 目前不寫 instructions(MCP 指引已足夠)。
本站是 opencode 使用情境——安裝 codegraph 時,opencode target 就是寫入 opencode.jsonc 的 mcp_servers.codegraph 區塊。你也可以用 codegraph install --print-config opencode 只印設定不寫檔。