> ## 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.

# 搭建你的插件生态系统

> 为整个组织或 企业 构建、托管并治理一套共享的 Devin 插件

<Note>
  插件目前处于 **封闭测试**。如需申请访问权限，请联系 [support@cognition.ai](mailto:support@cognition.ai)。其行为和配置可能会在后续版本中发生变化。
</Note>

本指南将介绍如何搭建你自己的 **插件生态系统**：由你的组织维护的插件代码仓库，通过受管清单分发给每个 Devin 会话和 CLI 用户，并通过必填、可选和禁止插件来实现治理控制。

本指南附带两个模板代码仓库：

* [**plugin-template**](https://github.com/CognitionAI/plugin-template) — 用于编写单个插件 (或少量插件) 的入门模板。
* [**team-marketplace-template**](https://github.com/CognitionAI/team-marketplace-template) — 完整的生态系统模式：一个插件 monorepo，以及一个 **元插件**，其清单定义了你的基线环境和策略。

<div id="1-author-your-plugins">
  ## 1. 编写你的插件
</div>

插件就是一个包含 `.devin-plugin/plugin.json` 清单的目录；除此之外，其他内容都是可选的：

```
my-plugin/
├── .devin-plugin/
│   └── plugin.json     # name, version, dependency + policy lists
├── AGENTS.md           # always-on rule
├── rules/              # triggered rules
├── agents/<name>.md   # 自定义子 Agent（目前仅限 CLI/Desktop）；agents/<name>/AGENT.md 同样有效
├── hooks.json          # lifecycle hooks
├── mcp_config.json     # MCP servers
└── skills/<name>/SKILL.md   # skills, exposed as /<plugin>:<skill>
```

先 Fork [plugin-template](https://github.com/CognitionAI/plugin-template) 作为起点，并参阅[CLI 插件参考](/zh/cli/extensibility/plugins/overview)了解完整格式。请保持 `AGENTS.md` 简短——因为对所有安装了该插件的人来说，它都会在每次会话中占用 context。

<div id="2-validate-and-test-locally">
  ## 2. 在本地验证和测试
</div>

这两个模板都附带了一个验证器 (`node scripts/validate-template.mjs`) 和一个 CI 工作流程，并且会在每次提交 PR 时运行该验证器。要进行实际测试，请通过 [Devin CLI](/zh/cli/index) 从本地文件夹安装：

```bash theme={null}
devin plugins install ./plugins/my-plugin   # 已链接：编辑将在下一个 session 中生效
devin plugins list
```

<div id="3-host-them-in-one-repo">
  ## 3. 将它们托管到同一个 代码仓库 中
</div>

把你所在组织的所有插件都放到同一个 代码仓库 里，作为子文件夹 (`plugins/<name>/`) ，并分别通过各自的 `git-subdir` source 引用。这个 代码仓库 可以保持为 private：云端会话会通过你的 Git 集成拉取它，而 CLI 用户则会使用自己的 git 凭据拉取 (因此他们也需要拥有该 代码仓库 的访问权限) 。

如需采用这种布局，请 fork [team-marketplace-template](https://github.com/CognitionAI/team-marketplace-template)——然后把其中元插件的 `git-subdir` URL 更新为指向你的 fork。在该模板中，元插件位于 **代码仓库 根目录**，因此该 代码仓库 本身就是可安装单元：要求 `your-org/your-marketplace` 会安装整个基线环境。

<div id="4-define-your-baseline-with-a-meta-plugin">
  ## 4. 使用元插件定义你的基线环境
</div>

**元插件**模式可将你的整个生态系统打包成一个可安装的单元。它本身几乎不包含任何内容，甚至可以完全没有内容——真正起作用的是它的清单。将它放在 代码仓库 根目录，这样 代码仓库 本身就是元插件：

```jsonc theme={null}
// .devin-plugin/plugin.json（代码仓库 根目录）
{
  "name": "team-starter-pack",
  "requiredPlugins": [
    // 自动为所有人安装，递归处理
    { "source": "git-subdir", "url": "https://github.com/acme/plugins.git", "path": "plugins/engineering-baseline" },
    { "source": "git-subdir", "url": "https://github.com/acme/plugins.git", "path": "plugins/security-guardrails" }
  ],
  "optionalPlugins": [
    // 已认可，但不自动安装；同时作为本清单禁止规则的豁免项
    { "source": "git-subdir", "url": "https://github.com/acme/plugins.git", "path": "plugins/frontend-standards" }
  ],
  "forbiddenPlugins": [
    "untrusted-vendor/*"
  ]
}
```

<div id="5-distribute-from-settings-marketplace">
  ## 5. 通过设置 → Marketplace 分发
</div>

Admin 在[Marketplace 设置页面](https://app.devin.ai/settings/marketplace)的受管清单中添加一个条目——参见[插件市场指南](/zh/product-guides/plugins)：

```json theme={null}
{
  "requiredPlugins": ["acme/plugins"]
}
```

要求安装 marketplace 代码仓库 时，会安装其根元插件，而该插件会递归拉取整个基线环境。

现在，处于该作用域内的所有人都会自动获得基线环境。请慎重选择作用域：

* **企业/account** 清单会应用到云端会话 **以及** 已登录该账户的 CLI 用户。
* **组织** 清单**仅适用于云端会话** —— CLI 没有组织上下文。

<div id="6-govern">
  ## 6. 治理
</div>

这三份列表构成了适用于各个层级 (受管清单、代码仓库 配置、插件清单) 的策略语言。优先级更高的层级生效——企业/账户高于组织，组织高于 代码仓库，代码仓库 高于 user——并且较低层级绝不能重新允许被较高层级禁止的内容，也不能禁止其强制要求的内容。

若要将账户限制为仅允许使用一组已批准的内容：

```json theme={null}
{
  "forbiddenPlugins": ["*"],
  "requiredPlugins": [
    "acme/plugins",
    { "source": "git-subdir", "url": "https://github.com/acme/plugins.git", "path": "plugins/engineering-baseline" },
    { "source": "git-subdir", "url": "https://github.com/acme/plugins.git", "path": "plugins/security-guardrails" }
  ],
  "optionalPlugins": [
    { "source": "git-subdir", "url": "https://github.com/acme/plugins.git", "path": "plugins/frontend-standards" }
  ]
}
```

清单自身的必填/可选条目不受其自身 `"*"` 禁止规则的限制；除此之外均不例外，且更低层级也不能扩大这一豁免范围。该豁免仅适用于*直接列出*的条目——必填插件的传递依赖并不享受豁免——因此在锁定模式下，请将该元插件拉入的所有内容 (此处为 `engineering-baseline` 和 `security-guardrails`) 显式列出。完整语义请参阅[治理规则](/zh/product-guides/plugins#governance-rules)。

<div id="7-evolve">
  ## 7. 演进
</div>

* 合并到你的插件代码仓库默认分支**就等于**发布：新会话会自动拉取到更新——参见[更新如何逐步推出](/zh/product-guides/plugins#how-updates-roll-out)。
* 团队通过 PR 向 marketplace 代码仓库添加插件；模板的 CI 会在每个 PR 上验证布局。
* 现有 Claude 插件可直接安装 (Devin 会回退到 `.claude-plugin/plugin.json`) ，因此你可以在 `optionalPlugins` 中采用社区插件，而无需将它们纳入仓库。

<div id="current-limitations">
  ## 当前限制
</div>

* 插件会在云端会话、[Devin CLI](/zh/cli/index) 和 Devin Desktop (使用 Devin Local 时) 中加载；不适用于经典 Cascade agent。
* **子 Agent** (`agents/<name>.md` or `agents/<name>/AGENT.md`) 仅会在本地 Devin Agent (CLI 和 Devin Desktop) 中加载，不会在云端会话中加载。
* **钩子**：云端会话会对除 `SessionStart` 和 `SessionEnd` 之外的每个[event](/zh/cli/extensibility/hooks/lifecycle-hooks)运行 `command` 钩子；`prompt` 类型的钩子仅适用于 CLI/本地环境。
* **由插件提供的 MCP** 会在会话中加载，但目前尚不会显示在 MCP 设置界面中。
* **组织级** 清单不会下发给 CLI 用户；如需对 CLI 进行强制执行，请使用企业/账户清单。

<div id="learn-more">
  ## 了解更多
</div>

* [插件市场](/zh/product-guides/plugins) — Web 应用侧：清单、作用域、上传
* [CLI 插件参考](/zh/cli/extensibility/plugins/overview) — 文件格式、编写、用户级安装
* [Skills](/zh/product-guides/skills) — 插件打包的 `SKILL.md` 步骤
