Skip to content

AgentTarget Installation and Integration zh CN

JanYork edited this page Aug 14, 2026 · 2 revisions

AgentTarget 安装与集成

语言: English · 简体中文

MCP 统一了运行时通信,却没有统一每种 Agent 的 MCP 配置位置、Skills、Hooks、Instructions 或权限。LWC 因此定义统一 AgentTarget 接口,并为每种支持的 host 手写 adapter。

所有已注册 Target 都是强适配:LWC 会实现该 host 和作用域存在的每一项稳定官方文件 surface。“强”不代表在官方声明不支持、UI 管理或仅 preview 的位置发明私有格式。

支持的 Targets

LWC 注册 12 个 Target:

claude             Claude Code
cursor             Cursor
codex              Codex
opencode           OpenCode
hermes             Hermes Agent
gemini             Gemini CLI
antigravity        Antigravity
kiro               Kiro
copilot-vscode     VS Code with GitHub Copilot Chat
copilot-cli        GitHub Copilot CLI
copilot-jetbrains  JetBrains IDEs with GitHub Copilot
pi                 Pi Agent

能力矩阵

每个单元格依次表示 全局 / 当前项目

Target MCP Skill Instructions Lifecycle Hook Permissions
Claude Code installed / installed installed / installed installed / installed installed / installed installed / installed
Cursor installed / installed installed / installed user_managed / installed installed / installed not_applicable / not_applicable
Codex installed / installed installed / installed installed / installed installed / installed not_applicable / not_applicable
OpenCode installed / installed installed / installed installed / installed installed / installed not_applicable / not_applicable
Hermes Agent installed / unsupported installed / unsupported installed / installed installed / unsupported not_applicable / not_applicable
Gemini CLI installed / installed installed / installed installed / installed installed / installed not_applicable / not_applicable
Antigravity installed / installed installed / installed installed / installed installed / installed not_applicable / not_applicable
Kiro installed / installed installed / installed installed / installed configured_preview / configured_preview user_managed / user_managed
Copilot VS Code installed / installed installed / installed user_managed / installed unsupported / configured_preview user_managed / user_managed
Copilot CLI installed / installed installed / installed installed / installed installed / installed user_managed / user_managed
Copilot JetBrains installed / user_managed configured_preview / configured_preview user_managed / configured_preview unsupported / unsupported user_managed / user_managed
Pi Agent extension_bridge / extension_bridge installed / installed installed / installed installed / installed not_applicable / not_applicable

configured_preview 表示 LWC 会写入 host 官方文档规定的预览 surface,并明确报告该生命周期。user_managed 表示没有稳定官方文件可供安全自动安装;unsupported 表示所选作用域没有该 host 能力。

Pi 没有内置 MCP 配置,因此通过官方 extension bridge 提供 LWC 集成,不会假装存在 native MCP 文件。

交互式安装

lwc agent install

安装器会:

  1. 检测已经安装的 Agent;
  2. 默认选中检测结果;
  3. 允许用户编辑 Target 列表;
  4. 让用户选择 globallocal
  5. 验证 PATH 中存在兼容的全局 lwc
  6. 通过各自官方 adapter 安装;
  7. 保存 ownership receipt,用于刷新与卸载。

全局安装配置用户级 Agent;本地安装只写当前项目中该 host 官方支持的 surface。

非交互安装

--yes 表示“使用检测结果与默认值”,不表示“安装全部 Target”:

lwc agent install --yes

它选择已检测 Agent,并默认使用全局位置。安装明确集合时:

lwc agent install \
  --target codex,claude,pi \
  --location global \
  --yes

只有确实需要全部 12 项集成时才使用 --target all。安装不用的 Target 只会增加配置面,不会带来收益。

只输出配置,不写文件

lwc agent install --print-config codex --location global

--print-config 会把所选 Target 的 MCP、Hook、Skill 和 Instruction 指引输出到标准输出,不写任何文件。它适合配置审核、受管理环境,以及部分配置由 UI 管理的 host。

安装内容

根据不同 adapter,安装过程可能写入:

  • 一项运行 lwc serve --mcplwc MCP entry;
  • 完整 using-lwc Skill bundle;
  • 官方 instruction 文件中的一段 marker-bounded 指导;
  • native lifecycle Hook 配置;
  • OpenCode、Antigravity 或 Pi 使用的官方 plugin/extension bridge;
  • Claude Code 官方权限模型支持的 MCP permissions。

安装器还会迁移 LWC 拥有的旧版独立 CodeGraph entry。CodeGraph 继续通过 lwc_explore 使用,不会留下重复 MCP 服务。

状态模型

lwc agent status --target auto --location global

状态会分别报告 Target 检测结果与集成状态。常见值包括:

  • installed:receipt 版本与全部已跟踪安装后 hash 一致;
  • modified:某个已跟踪文件在安装后发生变化;
  • not_installed:不存在当前 LWC receipt;
  • unsupported:Target 或位置没有官方集成作用域。

响应还会报告 MCP、Skills、Instructions、Hook、permissions、配置路径,以及 host 是否被检测到或已经配置。

不能把 modified 当作覆盖用户变更的授权。Drift 可能是有意修改,刷新前应检查 Target 路径。

幂等刷新

lwc agent refresh --target codex,claude,pi --location global

Refresh 会重新运行相同 adapter,替换 owned Skill 文件与 marker block,并去重 owned MCP 和 Hook entry。没有 drift 时,刷新前后保持逐字节一致。

Claude prompt Hook 的选择会从安装 receipt 保留;刷新不会静默推翻先前的 --no-prompt-hook 决定。

精确卸载

lwc agent uninstall \
  --target codex,claude,pi \
  --location global \
  --yes

Receipt 会保存原始内容、权限模式、安装后 hash、owned MCP 元数据和创建目录。卸载只会删除或恢复仍与 LWC-owned 状态匹配的文件与片段,保留外部 entry 和后续用户修改。

多个 Target receipt 共用文件时,只在 ownership 允许后恢复。目录也只有为空时才会删除。

不依赖维护者本机环境

Agent 集成只要求:

  • PATH 中存在兼容的全局 lwc
  • Agent 官方用户目录或项目目录;
  • 在当前目录正常工作时不需要导出 LWC_PROJECT_ROOT
  • 不需要 LWC=/private/path/to/lwc 别名;
  • 不需要安装 AMC;
  • 不从维护者 HOME 复制任何文件。

只有明确操作另一个已授权项目根时,才需要显式 LWC_PROJECT_ROOT

首次使用 Readiness

安装 Agent 集成不会启用项目图。下一次受支持边界触发 Hook 时会报告 readiness。实质任务需要缺失图能力时,Agent 使用可移植四选一文本只询问一次,并且只初始化获批能力。

文档图 Work 与 CodeGraph 项目索引需要独立验收。Agent 集成成功不能隐藏图初始化失败,图已经就绪也不代表 Agent 配置成功。

完成证据

AgentTarget 安装只有满足以下条件才算完成:

  • 明确了目标 Target 和 global/local 位置;
  • status 报告 adaptation=strong 以及准确的各 surface 模式;
  • MCP entry 名为 lwc,且没有重复 CodeGraph server;
  • Skill、Instructions 和 Hook 通过 host 官方机制加载;
  • 没有用户 drift 时,重复 refresh 逐字节幂等;
  • 卸载恢复安装前状态,且没有删除外部内容;
  • 不需要维护者本机路径或私有工具。

LWC Wiki

English · 简体中文


Start here · 开始使用

Core capabilities · 核心能力

Practical guides · 实战指南

Capability configuration · 能力配置

Technical design · 技术设计

Operations · 运行与维护

Reference · 参考资料

Contributing · 参与贡献


Repository · Releases

Clone this wiki locally