> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devinenterprise.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 插件

> 从代码仓库、git URL 或本地文件夹安装并共享技能包。

<Note>
  插件目前处于 **beta** 阶段。其行为和配置可能会在后续版本中发生变化。
</Note>

**插件**是一组可复用的[技能](/zh/cli/extensibility/skills/overview)，你可以从 GitHub 代码仓库、git URL 或本地文件夹安装，并在多个项目之间复用。安装插件后，其中的技能会以 `/<plugin>:<skill>` 斜杠命令的形式提供，并且还会自动拉取其依赖的其他插件。

插件本质上只是一个包含以下内容的来源：

```
my-plugin/
├── .devin-plugin/
│   └── plugin.json     # 插件清单
└── skills/
    └── review/
        └── SKILL.md    # 普通技能
```

`skills/` 目录用于存放常规技能——插件不会引入新的技能
格式。有关 `SKILL.md` 的格式，请参阅[创建技能](/zh/cli/extensibility/skills/creating-skills)。

***

<div id="installing-a-plugin">
  ## 安装插件
</div>

插件来源可以是 GitHub `owner/repo`、git URL 或本地路径：

```bash theme={null}
# 从 GitHub 安装
devin plugins install acme/review-tools

# 从任意 git 托管平台安装
devin plugins install https://gitlab.com/acme/review-tools.git

# 从本地文件夹安装（非常适合本地开发调试）
devin plugins install ./my-plugin
```

安装前，Devin 会显示该插件将添加的内容——它提供的技能、
将自动安装的所有必需插件，以及它引入的任何策略
(例如，是否禁止其他插件) 。传入 `-y` / `--yes` 可跳过
提示。

插件以 **user** 级别安装，并可在你的所有
项目中使用。

***

<div id="managing-plugins">
  ## 管理插件
</div>

```bash theme={null}
# 列出已安装的插件、其版本以及是否有插件被策略阻止
devin plugins list

# 显示插件的 技能 及其必需/可选/禁止列表
devin plugins info review-tools

# 重新拉取某个插件（或所有插件）的最新版本
devin plugins update review-tools
devin plugins update

# 移除插件（自动安装的必需插件将保留原位）
devin plugins remove review-tools
```

本地插件会直接链接到源文件夹，因此编辑会立即生效：
`devin plugins install ./my-plugin` → 编辑 `skills/<name>/SKILL.md` → 所做更改
会在下一次会话中生效，无需执行 `update`。

***

<div id="the-manifest">
  ## 清单
</div>

`.devin-plugin/plugin.json` 用于描述插件。只有 `name` 是必填项，
并且它在已安装插件中必须唯一 (即 `/<name>:…` 命名空间) 。

```jsonc theme={null}
{
  "name": "review-tools",
  "version": "1.0.0",
  "description": "Code-review skills for our team",
  "requiredPlugins": [
    "acme/secure-base",
    { "source": "github", "repo": "acme/audit-logging" }
  ],
  "optionalPlugins": [
    "acme/deploy-tools",
    { "source": "url", "url": "https://gitlab.com/acme/extra.git" }
  ],
  "forbiddenPlugins": ["sketchy-org/bad-plugin", "acme/*", "*"]
}
```

支持的元数据字段：`name`、`version`、`description`、`author`
(`{ name, email }`) 、`homepage`、`repository`、`license` 和 `keywords`。

依赖项条目表示一个**来源**——可以是字符串简写，也可以是对象：

* `"owner/repo"` → GitHub
* `"https://…"`, `"git@…"`, `"ssh://…"` → git URL
* `{ "source": "github", "repo": "owner/repo" }`
* `{ "source": "url", "url": "https://gitlab.com/team/plugin.git" }`

同一代码仓库的所有 GitHub 表示形式 (`owner/repo`、HTTPS URL、`.git`
URL、SSH 形式) 都对应同一个插件标识。

***

<div id="dependencies-and-governance">
  ## 依赖与治理
</div>

插件可以声明三个列表，使单个插件能够作为由其他插件构成的精选、受管控的集合。

<div id="requiredplugins">
  ### `requiredPlugins`
</div>

安装插件时会自动 (递归) 安装这些插件。如果某个必需插件被策略阻止，整个安装都会失败——不支持部分安装。

<div id="optionalplugins">
  ### `optionalPlugins`
</div>

该插件认可的插件**允许列表**。这些插件**不会**自动安装；此列表仅用于将某个被禁用的条目设为例外
(见下文) 。

<div id="forbiddenplugins">
  ### `forbiddenPlugins`
</div>

一个**禁止列表**。每个条目可以是以下之一：

* 一个精确的插件标识，可写为 `owner/repo`、git URL 或本地路径。
* 一个 **glob 模式** —— 任何包含 `*` 的条目。`*` 可匹配任意长度的
  字符序列，包括 `/`。模式会先规范化到标准标识空间，因此 `acme/*` 会变成 `https://github.com/acme/*` (`acme` 的所有
  GitHub 代码仓库) ，`*/secrets` 会匹配任意 owner 下名为 `secrets` 的代码仓库，而
  `https://gitlab.com/acme/*` 会匹配该路径下的任意代码仓库。
* 单独的 `"*"`，它会匹配所有其他插件 (不可绕过的完全锁定) 。

策略规则如下：

* **禁止优先。** 如果任一已安装插件禁止某个插件 (通过其
  精确标识、匹配的 glob 或 `"*"`) ，该插件就会被阻止。
* **自身覆盖。** 插件自身的 `requiredPlugins`、`optionalPlugins` 以及它
  本身，不受其**自身**禁止列表的限制。因此，
  `forbiddenPlugins: ["*"]` 与 `optionalPlugins: [B, C]` 一起使用时表示“允许
  我自己、B 和 C；禁止其他所有内容。”
* **不允许跨插件重新放行。** 一个插件的允许列表不能重新放行
  **另一个**插件所禁止的内容。带有
  `forbiddenPlugins: ["*"]` 的已安装插件会形成不可绕过的完全锁定。
* **默认开放。** 如果没有任何已安装插件禁止任何内容，就不会有任何插件被阻止。

策略会在两个时间点执行：

* **安装时** —— 如果要安装的插件已被阻止 (或其必需插件
  无法满足，或其名称与已安装插件冲突) ，则会
  拒绝安装。
* **加载时** —— 如果插件在安装后变为被阻止 (例如，某个实施禁止的插件稍后才安装) ，它会继续保留在磁盘上，但其技能会在会话开始时被跳过，并显示一条警告，指出是哪个插件禁止了它。
