@birdie_moblie/plugin-marketplace-cli 1.0.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +103 -6
- package/dist/adapters/agent-plugins.d.ts +11 -0
- package/dist/adapters/agent-plugins.js +66 -0
- package/dist/adapters/agent-plugins.js.map +1 -0
- package/dist/adapters/claude.d.ts +32 -1
- package/dist/adapters/claude.js +119 -14
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex.d.ts +7 -0
- package/dist/adapters/codex.js +10 -14
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/marketplace-registration.d.ts +17 -0
- package/dist/adapters/marketplace-registration.js +367 -0
- package/dist/adapters/marketplace-registration.js.map +1 -0
- package/dist/adapters/openspec.d.ts +66 -0
- package/dist/adapters/openspec.js +232 -0
- package/dist/adapters/openspec.js.map +1 -0
- package/dist/application/marketplace-registration-contract.d.ts +51 -0
- package/dist/application/marketplace-registration-contract.js +11 -0
- package/dist/application/marketplace-registration-contract.js.map +1 -0
- package/dist/application/marketplace-registration.d.ts +20 -0
- package/dist/application/marketplace-registration.js +304 -0
- package/dist/application/marketplace-registration.js.map +1 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +25 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.d.ts +1 -1
- package/dist/commands/build.js +27 -5
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/index-gen.d.ts +10 -0
- package/dist/commands/index-gen.js +81 -20
- package/dist/commands/index-gen.js.map +1 -1
- package/dist/commands/init-repo.js +11 -2
- package/dist/commands/init-repo.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +61 -9
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install-repo.d.ts +20 -0
- package/dist/commands/install-repo.js +200 -0
- package/dist/commands/install-repo.js.map +1 -0
- package/dist/commands/release-local.d.ts +1 -0
- package/dist/commands/release-local.js +310 -7
- package/dist/commands/release-local.js.map +1 -1
- package/dist/commands/validate.js +399 -16
- package/dist/commands/validate.js.map +1 -1
- package/dist/core/errors.d.ts +5 -0
- package/dist/core/errors.js +12 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/generated/skill-content.js +1 -1
- package/dist/generated/skill-content.js.map +1 -1
- package/dist/infrastructure/process-runner.d.ts +29 -0
- package/dist/infrastructure/process-runner.js +130 -0
- package/dist/infrastructure/process-runner.js.map +1 -0
- package/dist/infrastructure/vscode-user-settings.d.ts +42 -0
- package/dist/infrastructure/vscode-user-settings.js +509 -0
- package/dist/infrastructure/vscode-user-settings.js.map +1 -0
- package/dist/schema/agent-plugins.d.ts +221 -0
- package/dist/schema/agent-plugins.js +155 -0
- package/dist/schema/agent-plugins.js.map +1 -0
- package/dist/schema/plugin-yaml.d.ts +37 -3
- package/dist/schema/plugin-yaml.js +89 -4
- package/dist/schema/plugin-yaml.js.map +1 -1
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +1 -0
- package/dist/utils/helpers.js.map +1 -1
- package/dist/validation/agent-plugins.d.ts +3 -0
- package/dist/validation/agent-plugins.js +418 -0
- package/dist/validation/agent-plugins.js.map +1 -0
- package/package.json +14 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
本文件记录 `@birdie_moblie/plugin-marketplace-cli` 的对外变更。版本号遵循 semver,日期使用 ISO 8601。
|
|
4
|
+
|
|
5
|
+
## 1.3.0 - 2026-08-16
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- 为每个插件生成 Agent Plugins 1.0.0 根 `plugin.json` 与可选根 `mcp.json`,并内置官方 canonical JSON Schemas 进行离线校验。
|
|
9
|
+
- MCP 源模型新增显式 `stdio`、`streamable-http`、`sse` transport,以及 `cwd`、`url`、`headers`;既有无 `type` 声明继续按 stdio 读取。
|
|
10
|
+
- 新增 `.github/plugin/marketplace.json` 与 `.cursor-plugin/marketplace.json`,覆盖 GitHub Copilot / VS Code 与 Cursor 仓库型安装。
|
|
11
|
+
- 新增 Agent Plugins CLI 契约测试,覆盖固定 Skill 发现、MCP transport/安全语义、生成物漂移、stale 清理、Marketplace 与发布包。
|
|
12
|
+
- 新增 `install-repo <source>`:把已就绪的 marketplace 注册到 Claude Code / Codex / Copilot / VS Code / Cursor,不安装具体插件、不修改来源仓库。
|
|
13
|
+
- VS Code 注册通过原子 JSONC 更新写入用户 `settings.json` 的 `chat.plugins.enabled` 与 `chat.plugins.marketplaces`;Cursor 始终返回手工 Dashboard 导入指引。
|
|
14
|
+
- Copilot / VS Code 本地预检只接受 `.github/plugin/marketplace.json` 或 Claude 风格 `.claude-plugin/marketplace.json`,不再把本仓 Codex 根镜像 `marketplace.json` 当作有效索引。
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- `validate` 现在精确比较标准根 manifest、可选 `mcp.json`、Claude/Codex 原生 manifest、共享 `.mcp.json` 和全部客户端 Marketplace 索引;Skill 配置、目录和 frontmatter 名称必须一一对应。
|
|
18
|
+
- `build --all` 先预检全部选中插件和平台源契约,再写任何生成物,避免后置无效输入造成新旧混合状态。
|
|
19
|
+
- stdio MCP 只接受 Agent Plugins 定义的 `${PLUGIN_ROOT}` / `${PLUGIN_DATA}` 占位符,拒绝标准客户端不会展开的 ambient env 写法。
|
|
20
|
+
- Skill 校验覆盖 Agent Skills 的允许 frontmatter 字段、name/description/compatibility 长度及 metadata 字符串映射;现有 Lark/维护 Skill 元数据迁移到标准 `metadata`。
|
|
21
|
+
- 原生 `.mcp.json` 会把标准 `${PLUGIN_ROOT}` / `${PLUGIN_DATA}` 与 `./` executable/cwd 映射到 Claude 插件路径变量;标准根 `mcp.json` 保持 Agent Plugins 占位符不变。
|
|
22
|
+
- `release-local` 将标准插件根、GitHub Copilot 与 Cursor 索引纳入发布前检查、发布树和 release manifest,并排除只服务源码回归的插件顶层 `tests/`。
|
|
23
|
+
- CLI、脚手架、README、维护 Skill 与 CI 生成物清单同步 Agent Plugins 1.0 分发边界。
|
|
24
|
+
- 本仓根目录 `mp` / `ci:local` 改为验证本地 `tools/` CLI:先 `build:tools` 与 `build:all`,再 `validate` 与契约测试;远程用户仍使用已发布 `npx` CLI,无需 `npm install`。
|
|
25
|
+
|
|
26
|
+
### Compatibility
|
|
27
|
+
- Claude Code、Codex、OpenSpec、Hook 与 LSP 原生输出继续保留;Agent Plugins v1 只移植 Skills 和 MCP。
|
|
28
|
+
- Agent Plugins 1.0 不定义 Marketplace。本 CLI 只生成已有客户端明确支持的索引,不发明通用 Agent Plugins 市场格式。
|
|
29
|
+
- `install-repo` 只做 Marketplace 注册;插件安装仍使用各客户端原生命令。退出码:全部完成 `0`、部分完成 `2`、无完成或预检失败 `1`、中断 `130`。
|
|
30
|
+
|
|
31
|
+
## 1.2.0 - 2026-08-06
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- Hook 组件新增推荐字段 `matcher`、`type: command`、`script`、`interpreter`、`timeoutSeconds` 与 `statusMessage`,由 CLI 安全生成跨 Claude Code / Codex 的 `hooks/hooks.json`。
|
|
35
|
+
- `init --type hook` 改为生成读取 stdin JSON 的可执行 Python command hook 骨架。
|
|
36
|
+
- 新增 hook 契约测试,覆盖插件路径含空格、legacy timeout 毫秒转秒、生成物漂移、符号链接越界和 stale 配置清理。
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- `pattern`、`command`、`timeout` 继续作为 legacy 输入兼容;legacy `command` 按插件内脚本路径安全定位,新配置使用秒语义,生成命令以带引号的 `${CLAUDE_PLUGIN_ROOT}` 定位插件脚本。
|
|
40
|
+
- `validate` 现在检查 hook 脚本存在、可执行、真实路径不越过插件目录,并精确比较生成的 `hooks/hooks.json`。
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- 删除 hook 声明后只清理 stale `hooks/hooks.json`,保留 `hooks/` 下用户维护的脚本。
|
|
44
|
+
|
|
45
|
+
## 1.1.0 - 2026-06-29
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
- 新增 `lsp` 组件类型:`plugin.yaml` 可声明 `components.lsp`,build 阶段派生 `.lsp.json`,Claude Code 直接消费原生 LSP 配置。
|
|
49
|
+
- `init --type lsp` 生成 LSP 插件骨架,并写入面向 agent 的语义检索边界 skill 模板。
|
|
50
|
+
- marketplace 索引(`.claude-plugin/marketplace.json`、根 `marketplace.json`、`CATALOG.md`)、`release-local` 打包以及 `validate` 全面纳入 LSP 组件;Codex 输出仍然保持隔离,不暴露 LSP 字段。
|
|
51
|
+
- 新增 OpenSpec source adapter sidecar 流水线:`plugin.yaml` 中的 `openspec` overlay 由 CLI 生成 `.openspec-plugin/plugin.json` 与根 `.openspec-plugin/source-adapters.json`,不污染 Claude Code / Codex 平台原生格式。
|
|
52
|
+
- Lark 源适配抽象为通用 sheet fetch 命名,保留必需参数,多 source adapter 共存。
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
- `validate` 在 LSP 组件下校验文件存在性、extension 形式、startupTimeout / maxRestarts 非负,并比对 `.lsp.json` 是否与 `plugin.yaml` 一致,杜绝手改派生产物。
|
|
56
|
+
- 修正 LSP 派生产物中布尔/数字 `null` 字段被序列化为 JSON `null` 的问题。
|
|
57
|
+
- 清理 LSP 插件被移除时残留的 `.lsp.json`。
|
|
58
|
+
|
|
59
|
+
### Notes
|
|
60
|
+
- `.claude-plugin/plugin.json`、`.codex-plugin/plugin.json`、`.lsp.json`、`.openspec-plugin/plugin.json` 等派生文件必须通过 CLI 生成,不要手动编辑;CI 会校验它们与 `plugin.yaml` 派生结果一致。
|
|
61
|
+
|
|
62
|
+
## 1.0.1
|
|
63
|
+
|
|
64
|
+
- 修复 `init-repo` 阶段未注入维护 skill 的问题。
|
|
65
|
+
|
|
66
|
+
## 1.0.0
|
|
67
|
+
|
|
68
|
+
- 首次公开发布:`init-repo` / `init` / `validate` / `build` / `index` / `release-local`。
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @birdie_moblie/plugin-marketplace-cli
|
|
2
2
|
|
|
3
|
-
这是用于维护 Claude Code / Codex plugin marketplace 仓库的 CLI。它负责创建插件骨架、验证 `plugin.yaml
|
|
3
|
+
这是用于维护 Agent Plugins 1.0 / Claude Code / Codex / Cursor plugin marketplace 仓库的 CLI。它负责创建插件骨架、验证 `plugin.yaml`、生成标准包与平台 manifest、更新客户端 marketplace 索引,并打出本地发布包。OpenSpec source adapter metadata 通过插件内 overlay 生成 sidecar,作为兼容层存在,不改变标准或客户端原生输出格式。
|
|
4
4
|
|
|
5
5
|
## 使用公网 CLI
|
|
6
6
|
|
|
@@ -12,11 +12,12 @@ npx @birdie_moblie/plugin-marketplace-cli --help
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
npx @birdie_moblie/plugin-marketplace-cli init-repo [name] --organization "团队名" [--no-skill]
|
|
15
|
-
npx @birdie_moblie/plugin-marketplace-cli init <plugin-name> --type <skill|mcp|hook>
|
|
15
|
+
npx @birdie_moblie/plugin-marketplace-cli init <plugin-name> --type <skill|mcp|lsp|hook>
|
|
16
16
|
npx @birdie_moblie/plugin-marketplace-cli validate [plugin-name] --all
|
|
17
17
|
npx @birdie_moblie/plugin-marketplace-cli build [plugin-name] --all
|
|
18
18
|
npx @birdie_moblie/plugin-marketplace-cli index
|
|
19
19
|
npx @birdie_moblie/plugin-marketplace-cli release-local
|
|
20
|
+
npx @birdie_moblie/plugin-marketplace-cli install-repo <source> [--agent <agent>...] [--all]
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
从其他目录操作指定仓库时,使用 `--root <dir>`:
|
|
@@ -27,6 +28,20 @@ npx @birdie_moblie/plugin-marketplace-cli --root /path/to/repo validate --all
|
|
|
27
28
|
|
|
28
29
|
不传 `--root` 时,CLI 会从当前工作目录向上查找 `marketplace.yaml`。除 `init-repo` 外,找不到 `marketplace.yaml` 会直接报错并提示先初始化仓库。
|
|
29
30
|
|
|
31
|
+
`install-repo` 的 `<source>` 独立于 `--root`:它把已就绪的 marketplace 注册到所选 agent,不 build、不 validate、不安装插件。来源可以是本地目录、`owner/repo`、HTTPS Git URL 或 SSH Git URL。
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# 非交互:显式选择 agent
|
|
35
|
+
npx @birdie_moblie/plugin-marketplace-cli install-repo owner/repo --agent claude --agent codex
|
|
36
|
+
|
|
37
|
+
# 选择全部五个目标(Cursor 仍需手工 Dashboard 导入)
|
|
38
|
+
npx @birdie_moblie/plugin-marketplace-cli install-repo ./my-marketplace --all
|
|
39
|
+
|
|
40
|
+
# TTY 下省略 --agent/--all 时会先探测并交互选择
|
|
41
|
+
npx @birdie_moblie/plugin-marketplace-cli install-repo https://github.com/org/plugins.git
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
目标固定顺序:`claude` → `codex` → `copilot` → `vscode` → `cursor`。退出码:全部完成 `0`、部分完成 `2`、无完成或预检失败 `1`、中断 `130`。
|
|
30
45
|
如果已经本地或全局安装该 npm 包,也可以直接使用 `plugin-marketplace` bin 运行同一组命令。
|
|
31
46
|
|
|
32
47
|
## 插件仓库结构
|
|
@@ -37,25 +52,105 @@ npx @birdie_moblie/plugin-marketplace-cli --root /path/to/repo validate --all
|
|
|
37
52
|
├── plugins/
|
|
38
53
|
│ └── my-plugin/
|
|
39
54
|
│ ├── plugin.yaml
|
|
55
|
+
│ ├── plugin.json
|
|
56
|
+
│ ├── mcp.json
|
|
40
57
|
│ └── skills/
|
|
41
58
|
├── .agents/skills/marketplace-maintainer/SKILL.md
|
|
42
59
|
├── .claude/skills/marketplace-maintainer/SKILL.md
|
|
43
60
|
├── .claude-plugin/marketplace.json
|
|
61
|
+
├── .github/plugin/marketplace.json
|
|
44
62
|
├── .agents/plugins/marketplace.json
|
|
63
|
+
├── .cursor-plugin/marketplace.json
|
|
45
64
|
└── marketplace.json
|
|
46
65
|
```
|
|
47
66
|
|
|
48
|
-
|
|
67
|
+
每个插件的 Agent Plugins / Claude Code / Codex 平台信息以 `plugin.yaml` 为唯一来源。根 `plugin.json` 与可选根 `mcp.json` 遵循 Agent Plugins 1.0.0;CLI 离线内置 canonical schema,并校验 fixed Skill discovery 与 MCP 语义。插件也可以额外提供 `openspec-source-adapters.yaml` overlay,用于声明 OpenSpec source adapter metadata。
|
|
49
68
|
|
|
69
|
+
仓库本身要作为 marketplace 源使用时,以下生成物需要随源码一起提交:
|
|
70
|
+
|
|
71
|
+
- `plugins/**/plugin.json`
|
|
72
|
+
- `plugins/**/mcp.json`
|
|
50
73
|
- `.claude-plugin/marketplace.json`
|
|
74
|
+
- `.github/plugin/marketplace.json`
|
|
51
75
|
- `.agents/plugins/marketplace.json`
|
|
76
|
+
- `.cursor-plugin/marketplace.json`
|
|
77
|
+
- `.openspec-plugin/source-adapters.json`
|
|
52
78
|
- `plugins/**/.claude-plugin/plugin.json`
|
|
53
79
|
- `plugins/**/.codex-plugin/plugin.json`
|
|
80
|
+
- `plugins/**/.openspec-plugin/plugin.json`
|
|
54
81
|
- `plugins/**/.mcp.json`
|
|
82
|
+
- `plugins/**/.lsp.json`
|
|
55
83
|
- `plugins/**/hooks/hooks.json`
|
|
56
84
|
- `marketplace.json`
|
|
57
85
|
- `plugins/CATALOG.md`
|
|
58
86
|
|
|
87
|
+
LSP 插件在 `plugin.yaml` 的 `components.lsp` 声明 server metadata:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
components:
|
|
91
|
+
lsp:
|
|
92
|
+
- name: dart
|
|
93
|
+
command: dart
|
|
94
|
+
args: ["language-server", "--protocol=lsp"]
|
|
95
|
+
extensionToLanguage:
|
|
96
|
+
".dart": dart
|
|
97
|
+
startupTimeout: 30000
|
|
98
|
+
maxRestarts: 3
|
|
99
|
+
diagnostics: true
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
CLI 会由 `components.lsp` 生成插件根目录 `.lsp.json`,并只在 Claude Code marketplace 写入 `lspServers` 字段。Codex 当前没有原生 LSP manifest;语义能力必须通过 MCP server 暴露。
|
|
103
|
+
|
|
104
|
+
Hook 插件推荐使用声明式脚本字段:
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
components:
|
|
108
|
+
hooks:
|
|
109
|
+
- event: PreToolUse
|
|
110
|
+
matcher: Bash
|
|
111
|
+
type: command
|
|
112
|
+
script: hooks/check.py
|
|
113
|
+
interpreter: python3
|
|
114
|
+
timeoutSeconds: 10
|
|
115
|
+
statusMessage: "正在检查命令"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
CLI 会生成带引号的 `${CLAUDE_PLUGIN_ROOT}` 命令供 Claude Code 与 Codex lifecycle
|
|
119
|
+
hook 消费。`script` 必须位于插件目录内且可执行;`validate` 会检查真实路径、生成物精确
|
|
120
|
+
一致性和 stale `hooks/hooks.json`。旧 `pattern` / `command` / `timeout` 仍兼容,其中
|
|
121
|
+
legacy `command` 继续按插件内脚本路径处理并转换为带引号的插件根路径,legacy
|
|
122
|
+
`timeout` 按毫秒读取并转换为生成文件中的秒。
|
|
123
|
+
|
|
124
|
+
Agent Plugins MCP 推荐显式声明 transport:
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
components:
|
|
128
|
+
mcp:
|
|
129
|
+
- name: local-server
|
|
130
|
+
type: stdio
|
|
131
|
+
command: node
|
|
132
|
+
args: ["./mcp/server.mjs"]
|
|
133
|
+
cwd: "${PLUGIN_ROOT}"
|
|
134
|
+
- name: remote-server
|
|
135
|
+
type: streamable-http
|
|
136
|
+
url: https://example.com/mcp
|
|
137
|
+
headers:
|
|
138
|
+
X-Tenant: public
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
旧 MCP 条目省略 `type` 时继续按 `stdio` 读取。标准输出总会显式写 `type`。stdio 的 `args` / `env` / `cwd` 只允许 `${PLUGIN_ROOT}` 与 `${PLUGIN_DATA}` 两种可展开占位符;`${TOKEN}` 一类 ambient env 写法在标准客户端会保持字面量,CLI 会拒绝。`Authorization`、Cookie、API key 等凭据不能写入可见的 `env`/`headers`,由客户端认证与 secret 管理机制提供。
|
|
142
|
+
|
|
143
|
+
根 `mcp.json` 保留标准 `${PLUGIN_ROOT}` / `${PLUGIN_DATA}`。原生 `.mcp.json` 会自动转换为 `${CLAUDE_PLUGIN_ROOT}` / `${CLAUDE_PLUGIN_DATA}`,并把 `./` executable/cwd 锚定到插件根;不要手改任一派生文件。
|
|
144
|
+
|
|
145
|
+
Agent Plugins 1.0 不定义 Marketplace。CLI 生成 `.claude-plugin` / `.github/plugin`、`.agents/plugins` 与 `.cursor-plugin` 索引,是因为对应客户端明确支持这些入口;不会生成虚构的通用 Agent Plugins 市场文件。
|
|
146
|
+
|
|
147
|
+
OpenSpec sidecar 输出只来自 `openspec-source-adapters.yaml` overlay:
|
|
148
|
+
|
|
149
|
+
- `plugins/<name>/.openspec-plugin/plugin.json`
|
|
150
|
+
- `.openspec-plugin/source-adapters.json`
|
|
151
|
+
|
|
152
|
+
不要把 OpenSpec-only 字段加入 `plugin.yaml`、`.claude-plugin/plugin.json`、`.codex-plugin/plugin.json`、`.claude-plugin/marketplace.json`、`.agents/plugins/marketplace.json` 或根 `marketplace.json`。
|
|
153
|
+
|
|
59
154
|
## 推荐脚本
|
|
60
155
|
|
|
61
156
|
`plugin-marketplace init-repo` 会给新仓库写入一组 npm scripts,并默认注入 `marketplace-maintainer`
|
|
@@ -69,7 +164,7 @@ SKILL 到 `.agents/skills/` 和 `.claude/skills/`,方便维护者继续创建
|
|
|
69
164
|
"build:plugins": "npx @birdie_moblie/plugin-marketplace-cli build --all",
|
|
70
165
|
"build:index": "npx @birdie_moblie/plugin-marketplace-cli index",
|
|
71
166
|
"build:all": "npm run build:plugins && npm run build:index",
|
|
72
|
-
"ci:local": "npm run
|
|
167
|
+
"ci:local": "npm run build:all && npm run validate:plugins",
|
|
73
168
|
"release:local": "npm run ci:local && npx @birdie_moblie/plugin-marketplace-cli release-local"
|
|
74
169
|
}
|
|
75
170
|
}
|
|
@@ -89,10 +184,12 @@ npm install --save-dev @birdie_moblie/plugin-marketplace-cli
|
|
|
89
184
|
cd tools
|
|
90
185
|
npm install
|
|
91
186
|
npm run build
|
|
92
|
-
npm
|
|
187
|
+
npm test
|
|
93
188
|
npm run mp -- --root .. build --all
|
|
94
189
|
npm run mp -- --root .. index
|
|
190
|
+
npm run mp -- --root .. validate --all
|
|
191
|
+
npm run mp -- --root .. install-repo . --agent cursor
|
|
95
192
|
npm pack --dry-run
|
|
96
193
|
```
|
|
97
194
|
|
|
98
|
-
|
|
195
|
+
本仓根目录 `mp` / `ci:local` 指向本地 `tools/dist`,用于验证未发布 CLI。远程用户与 `init-repo` 生成的新仓仍使用已发布 `npx` CLI,无需先 `npm install`。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Plugins 1.0 adapter.
|
|
3
|
+
*
|
|
4
|
+
* The root plugin.json and mcp.json are portable package artifacts. Native
|
|
5
|
+
* Claude/Codex capabilities stay in their existing adapters and paths.
|
|
6
|
+
*/
|
|
7
|
+
import { type AgentMcpConfig, type AgentPluginManifest } from '../schema/agent-plugins.js';
|
|
8
|
+
import { type PluginYaml } from '../schema/plugin-yaml.js';
|
|
9
|
+
export declare function buildAgentPluginManifest(config: PluginYaml): AgentPluginManifest;
|
|
10
|
+
export declare function buildAgentMcpConfig(config: PluginYaml): AgentMcpConfig | null;
|
|
11
|
+
export declare function generateAgentPlugin(config: PluginYaml, pluginDir: string): void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Plugins 1.0 adapter.
|
|
3
|
+
*
|
|
4
|
+
* The root plugin.json and mcp.json are portable package artifacts. Native
|
|
5
|
+
* Claude/Codex capabilities stay in their existing adapters and paths.
|
|
6
|
+
*/
|
|
7
|
+
import { rmSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { AGENT_MCP_SCHEMA_URL, AGENT_PLUGIN_SCHEMA_URL, } from '../schema/agent-plugins.js';
|
|
10
|
+
import { isPluginStdioMcp } from '../schema/plugin-yaml.js';
|
|
11
|
+
export function buildAgentPluginManifest(config) {
|
|
12
|
+
return {
|
|
13
|
+
$schema: AGENT_PLUGIN_SCHEMA_URL,
|
|
14
|
+
name: config.name,
|
|
15
|
+
version: config.version,
|
|
16
|
+
description: config.description,
|
|
17
|
+
author: {
|
|
18
|
+
name: config.author.name,
|
|
19
|
+
...(config.author.email ? { email: config.author.email } : {}),
|
|
20
|
+
...(config.author.url ? { url: config.author.url } : {}),
|
|
21
|
+
},
|
|
22
|
+
...(config.homepage ? { homepage: config.homepage } : {}),
|
|
23
|
+
...(config.repository ? { repository: config.repository } : {}),
|
|
24
|
+
...(config.license ? { license: config.license } : {}),
|
|
25
|
+
...(config.tags?.length ? { keywords: config.tags } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function buildAgentMcpConfig(config) {
|
|
29
|
+
const mcps = config.components.mcp;
|
|
30
|
+
if (!mcps?.length)
|
|
31
|
+
return null;
|
|
32
|
+
const servers = {};
|
|
33
|
+
for (const mcp of mcps) {
|
|
34
|
+
if (isPluginStdioMcp(mcp)) {
|
|
35
|
+
servers[mcp.name] = {
|
|
36
|
+
type: 'stdio',
|
|
37
|
+
command: mcp.command,
|
|
38
|
+
...(mcp.args ? { args: mcp.args } : {}),
|
|
39
|
+
...(mcp.env ? { env: mcp.env } : {}),
|
|
40
|
+
...(mcp.cwd ? { cwd: mcp.cwd } : {}),
|
|
41
|
+
};
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
servers[mcp.name] = {
|
|
45
|
+
type: mcp.type,
|
|
46
|
+
url: mcp.url,
|
|
47
|
+
...(mcp.headers ? { headers: mcp.headers } : {}),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
$schema: AGENT_MCP_SCHEMA_URL,
|
|
52
|
+
mcpServers: servers,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function generateAgentPlugin(config, pluginDir) {
|
|
56
|
+
writeFileSync(join(pluginDir, 'plugin.json'), JSON.stringify(buildAgentPluginManifest(config), null, 2) + '\n');
|
|
57
|
+
const mcpConfig = buildAgentMcpConfig(config);
|
|
58
|
+
const mcpPath = join(pluginDir, 'mcp.json');
|
|
59
|
+
if (mcpConfig) {
|
|
60
|
+
writeFileSync(mcpPath, JSON.stringify(mcpConfig, null, 2) + '\n');
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
rmSync(mcpPath, { force: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=agent-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-plugins.js","sourceRoot":"","sources":["../../src/adapters/agent-plugins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GAGxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAE7E,MAAM,UAAU,wBAAwB,CAAC,MAAkB;IACzD,OAAO;QACL,OAAO,EAAE,uBAAuB;QAChC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM,EAAE;YACN,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;YACxB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,GAAG,CAAC,MAAM,CAAC,MAAM,CA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,9 @@
|
|
|
8
8
|
* - skills/<name>/SKILL.md — skill 文件(已在源码中维护,无需生成)
|
|
9
9
|
* - hooks/hooks.json — hook 配置(如果有 hooks 组件)
|
|
10
10
|
* - .mcp.json — MCP server 配置(如果有 mcp 组件)
|
|
11
|
+
* - .lsp.json — LSP server 配置(如果有 lsp 组件)
|
|
11
12
|
*/
|
|
12
|
-
import type
|
|
13
|
+
import { type PluginLspTransport, type PluginYaml } from '../schema/plugin-yaml.js';
|
|
13
14
|
export interface ClaudeManifest {
|
|
14
15
|
name: string;
|
|
15
16
|
version: string;
|
|
@@ -25,6 +26,7 @@ export interface ClaudeHooksConfig {
|
|
|
25
26
|
type: 'command';
|
|
26
27
|
command: string;
|
|
27
28
|
timeout?: number;
|
|
29
|
+
statusMessage?: string;
|
|
28
30
|
}>;
|
|
29
31
|
}>>;
|
|
30
32
|
}
|
|
@@ -33,8 +35,37 @@ export interface ClaudeMcpConfig {
|
|
|
33
35
|
command: string;
|
|
34
36
|
args?: string[];
|
|
35
37
|
env?: Record<string, string>;
|
|
38
|
+
cwd?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'http' | 'sse';
|
|
41
|
+
url: string;
|
|
42
|
+
headers?: Record<string, string>;
|
|
36
43
|
}>;
|
|
37
44
|
}
|
|
45
|
+
export type ClaudeLspConfig = Record<string, {
|
|
46
|
+
command: string;
|
|
47
|
+
args?: string[];
|
|
48
|
+
env?: Record<string, string>;
|
|
49
|
+
transport?: PluginLspTransport;
|
|
50
|
+
extensionToLanguage: Record<string, string>;
|
|
51
|
+
workspaceFolder?: string;
|
|
52
|
+
startupTimeout?: number;
|
|
53
|
+
maxRestarts?: number;
|
|
54
|
+
diagnostics?: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* 生成 Claude Code 的 .claude-plugin/plugin.json
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildClaudeManifest(config: PluginYaml): ClaudeManifest;
|
|
60
|
+
export declare function buildHooksConfig(config: PluginYaml): ClaudeHooksConfig | null;
|
|
61
|
+
/**
|
|
62
|
+
* 生成 Claude Code 的 .mcp.json(如果有 mcp 组件)
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildMcpConfig(config: PluginYaml): ClaudeMcpConfig | null;
|
|
65
|
+
/**
|
|
66
|
+
* 生成 Claude Code 的 .lsp.json(如果有 lsp 组件)
|
|
67
|
+
*/
|
|
68
|
+
export declare function buildLspConfig(config: PluginYaml): ClaudeLspConfig | null;
|
|
38
69
|
/**
|
|
39
70
|
* 将 Claude Code 兼容的文件写入插件目录
|
|
40
71
|
*/
|
package/dist/adapters/claude.js
CHANGED
|
@@ -8,13 +8,35 @@
|
|
|
8
8
|
* - skills/<name>/SKILL.md — skill 文件(已在源码中维护,无需生成)
|
|
9
9
|
* - hooks/hooks.json — hook 配置(如果有 hooks 组件)
|
|
10
10
|
* - .mcp.json — MCP server 配置(如果有 mcp 组件)
|
|
11
|
+
* - .lsp.json — LSP server 配置(如果有 lsp 组件)
|
|
11
12
|
*/
|
|
12
|
-
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
13
14
|
import { join } from 'node:path';
|
|
15
|
+
import { isPluginStdioMcp, } from '../schema/plugin-yaml.js';
|
|
16
|
+
function toClaudePluginValue(value) {
|
|
17
|
+
return value
|
|
18
|
+
.replaceAll('${PLUGIN_ROOT}', '${CLAUDE_PLUGIN_ROOT}')
|
|
19
|
+
.replaceAll('${PLUGIN_DATA}', '${CLAUDE_PLUGIN_DATA}');
|
|
20
|
+
}
|
|
21
|
+
function toClaudePluginCommand(command) {
|
|
22
|
+
if (!command.startsWith('./'))
|
|
23
|
+
return command;
|
|
24
|
+
return `\${CLAUDE_PLUGIN_ROOT}/${command.slice(2)}`;
|
|
25
|
+
}
|
|
26
|
+
function toClaudePluginCwd(cwd) {
|
|
27
|
+
if (cwd === '.')
|
|
28
|
+
return '${CLAUDE_PLUGIN_ROOT}';
|
|
29
|
+
if (cwd.startsWith('./'))
|
|
30
|
+
return `\${CLAUDE_PLUGIN_ROOT}/${cwd.slice(2)}`;
|
|
31
|
+
return toClaudePluginValue(cwd);
|
|
32
|
+
}
|
|
33
|
+
function isPresent(value) {
|
|
34
|
+
return value != null;
|
|
35
|
+
}
|
|
14
36
|
/**
|
|
15
37
|
* 生成 Claude Code 的 .claude-plugin/plugin.json
|
|
16
38
|
*/
|
|
17
|
-
function
|
|
39
|
+
export function buildClaudeManifest(config) {
|
|
18
40
|
return {
|
|
19
41
|
name: config.name,
|
|
20
42
|
version: config.version,
|
|
@@ -25,19 +47,48 @@ function buildManifest(config) {
|
|
|
25
47
|
/**
|
|
26
48
|
* 生成 Claude Code 的 hooks/hooks.json(如果有 hooks 组件)
|
|
27
49
|
*/
|
|
28
|
-
function
|
|
50
|
+
function hookCommand(hook) {
|
|
51
|
+
const hasScript = typeof hook.script === 'string' && hook.script.length > 0;
|
|
52
|
+
const hasCommand = typeof hook.command === 'string' && hook.command.length > 0;
|
|
53
|
+
if (hasScript === hasCommand) {
|
|
54
|
+
throw new Error('Hook 必须且只能配置 script 或 legacy command 之一');
|
|
55
|
+
}
|
|
56
|
+
const configuredPath = (hasCommand ? hook.command : hook.script);
|
|
57
|
+
const script = configuredPath.replace(/^\.\//, '');
|
|
58
|
+
if (!/^[A-Za-z0-9._/ -]+$/.test(script)) {
|
|
59
|
+
throw new Error(`Hook script 包含不安全的 shell 路径字符: ${configuredPath}`);
|
|
60
|
+
}
|
|
61
|
+
if (hook.interpreter && !/^[A-Za-z0-9._+-]+$/.test(hook.interpreter)) {
|
|
62
|
+
throw new Error(`Hook interpreter 不是安全的可执行名称: ${hook.interpreter}`);
|
|
63
|
+
}
|
|
64
|
+
const executable = `"\${CLAUDE_PLUGIN_ROOT}/${script}"`;
|
|
65
|
+
return hook.interpreter ? `${hook.interpreter} ${executable}` : executable;
|
|
66
|
+
}
|
|
67
|
+
function hookTimeoutSeconds(hook) {
|
|
68
|
+
if (hook.timeoutSeconds != null)
|
|
69
|
+
return hook.timeoutSeconds;
|
|
70
|
+
if (hook.timeout != null)
|
|
71
|
+
return Math.max(1, Math.ceil(hook.timeout / 1000));
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
export function buildHooksConfig(config) {
|
|
29
75
|
const hooks = config.components.hooks;
|
|
30
76
|
if (!hooks || hooks.length === 0)
|
|
31
77
|
return null;
|
|
32
78
|
const hooksMap = {};
|
|
33
79
|
for (const hook of hooks) {
|
|
80
|
+
if (!/^[A-Za-z][A-Za-z0-9]*$/.test(hook.event) || ['constructor', 'prototype'].includes(hook.event)) {
|
|
81
|
+
throw new Error(`Hook event 名称不安全: ${hook.event}`);
|
|
82
|
+
}
|
|
83
|
+
const timeout = hookTimeoutSeconds(hook);
|
|
34
84
|
const entry = {
|
|
35
|
-
matcher: hook.pattern || '*',
|
|
85
|
+
matcher: hook.matcher || hook.pattern || '*',
|
|
36
86
|
hooks: [
|
|
37
87
|
{
|
|
38
88
|
type: 'command',
|
|
39
|
-
command: hook
|
|
40
|
-
...(
|
|
89
|
+
command: hookCommand(hook),
|
|
90
|
+
...(timeout != null ? { timeout } : {}),
|
|
91
|
+
...(hook.statusMessage ? { statusMessage: hook.statusMessage } : {}),
|
|
41
92
|
},
|
|
42
93
|
],
|
|
43
94
|
};
|
|
@@ -51,20 +102,57 @@ function buildHooksConfig(config) {
|
|
|
51
102
|
/**
|
|
52
103
|
* 生成 Claude Code 的 .mcp.json(如果有 mcp 组件)
|
|
53
104
|
*/
|
|
54
|
-
function buildMcpConfig(config) {
|
|
105
|
+
export function buildMcpConfig(config) {
|
|
55
106
|
const mcps = config.components.mcp;
|
|
56
107
|
if (!mcps || mcps.length === 0)
|
|
57
108
|
return null;
|
|
58
109
|
const servers = {};
|
|
59
110
|
for (const mcp of mcps) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
111
|
+
if (isPluginStdioMcp(mcp)) {
|
|
112
|
+
servers[mcp.name] = {
|
|
113
|
+
command: toClaudePluginCommand(mcp.command),
|
|
114
|
+
...(mcp.args ? { args: mcp.args.map(toClaudePluginValue) } : {}),
|
|
115
|
+
...(mcp.env
|
|
116
|
+
? {
|
|
117
|
+
env: Object.fromEntries(Object.entries(mcp.env).map(([name, value]) => [name, toClaudePluginValue(value)])),
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
...(mcp.cwd ? { cwd: toClaudePluginCwd(mcp.cwd) } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
servers[mcp.name] = {
|
|
125
|
+
type: mcp.type === 'streamable-http' ? 'http' : 'sse',
|
|
126
|
+
url: mcp.url,
|
|
127
|
+
...(mcp.headers ? { headers: mcp.headers } : {}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
65
130
|
}
|
|
66
131
|
return { mcpServers: servers };
|
|
67
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* 生成 Claude Code 的 .lsp.json(如果有 lsp 组件)
|
|
135
|
+
*/
|
|
136
|
+
export function buildLspConfig(config) {
|
|
137
|
+
const lsps = config.components.lsp;
|
|
138
|
+
if (!lsps || lsps.length === 0)
|
|
139
|
+
return null;
|
|
140
|
+
const servers = {};
|
|
141
|
+
for (const lsp of lsps) {
|
|
142
|
+
servers[lsp.name] = {
|
|
143
|
+
command: lsp.command,
|
|
144
|
+
...(isPresent(lsp.args) ? { args: lsp.args } : {}),
|
|
145
|
+
...(isPresent(lsp.env) ? { env: lsp.env } : {}),
|
|
146
|
+
...(isPresent(lsp.transport) ? { transport: lsp.transport } : {}),
|
|
147
|
+
extensionToLanguage: lsp.extensionToLanguage,
|
|
148
|
+
...(isPresent(lsp.workspaceFolder) ? { workspaceFolder: lsp.workspaceFolder } : {}),
|
|
149
|
+
...(isPresent(lsp.startupTimeout) ? { startupTimeout: lsp.startupTimeout } : {}),
|
|
150
|
+
...(isPresent(lsp.maxRestarts) ? { maxRestarts: lsp.maxRestarts } : {}),
|
|
151
|
+
...(isPresent(lsp.diagnostics) ? { diagnostics: lsp.diagnostics } : {}),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return servers;
|
|
155
|
+
}
|
|
68
156
|
/**
|
|
69
157
|
* 将 Claude Code 兼容的文件写入插件目录
|
|
70
158
|
*/
|
|
@@ -72,18 +160,35 @@ export function generateClaude(config, pluginDir) {
|
|
|
72
160
|
// 1. .claude-plugin/plugin.json
|
|
73
161
|
const claudeDir = join(pluginDir, '.claude-plugin');
|
|
74
162
|
mkdirSync(claudeDir, { recursive: true });
|
|
75
|
-
writeFileSync(join(claudeDir, 'plugin.json'), JSON.stringify(
|
|
163
|
+
writeFileSync(join(claudeDir, 'plugin.json'), JSON.stringify(buildClaudeManifest(config), null, 2) + '\n');
|
|
76
164
|
// 2. hooks/hooks.json
|
|
77
165
|
const hooksConfig = buildHooksConfig(config);
|
|
166
|
+
const hooksPath = join(pluginDir, 'hooks', 'hooks.json');
|
|
78
167
|
if (hooksConfig) {
|
|
79
168
|
const hooksDir = join(pluginDir, 'hooks');
|
|
80
169
|
mkdirSync(hooksDir, { recursive: true });
|
|
81
|
-
writeFileSync(
|
|
170
|
+
writeFileSync(hooksPath, JSON.stringify(hooksConfig, null, 2) + '\n');
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
// 只清理生成文件,保留用户维护的 hooks/ 脚本。
|
|
174
|
+
rmSync(hooksPath, { force: true });
|
|
82
175
|
}
|
|
83
176
|
// 3. .mcp.json
|
|
84
177
|
const mcpConfig = buildMcpConfig(config);
|
|
85
178
|
if (mcpConfig) {
|
|
86
179
|
writeFileSync(join(pluginDir, '.mcp.json'), JSON.stringify(mcpConfig, null, 2) + '\n');
|
|
87
180
|
}
|
|
181
|
+
else {
|
|
182
|
+
rmSync(join(pluginDir, '.mcp.json'), { force: true });
|
|
183
|
+
}
|
|
184
|
+
// 4. .lsp.json
|
|
185
|
+
const lspConfig = buildLspConfig(config);
|
|
186
|
+
const lspPath = join(pluginDir, '.lsp.json');
|
|
187
|
+
if (lspConfig) {
|
|
188
|
+
writeFileSync(lspPath, JSON.stringify(lspConfig, null, 2) + '\n');
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
rmSync(lspPath, { force: true });
|
|
192
|
+
}
|
|
88
193
|
}
|
|
89
194
|
//# sourceMappingURL=claude.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/adapters/claude.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/adapters/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,gBAAgB,GAIjB,MAAM,0BAA0B,CAAC;AAwDlC,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK;SACT,UAAU,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;SACrD,UAAU,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAe;IAC5C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAC9C,OAAO,0BAA0B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,uBAAuB,CAAC;IAChD,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,0BAA0B,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,OAAO,mBAAmB,CAAC,GAAG,CA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IAED,eAAe;IACf,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC7C,IAAI,SAAS,EAAE,CAAC;QACd,aAAa,CACX,OAAO,EACP,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAC1C,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
package/dist/adapters/codex.d.ts
CHANGED
|
@@ -44,6 +44,13 @@ export interface CodexMarketplaceEntry {
|
|
|
44
44
|
};
|
|
45
45
|
category: string;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* 生成 Codex 的 .codex-plugin/plugin.json
|
|
49
|
+
*
|
|
50
|
+
* 如果 plugin.yaml 中没有显式指定 platform.codex.interface,
|
|
51
|
+
* 则从 name 和 description 自动推导。
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildCodexManifest(config: PluginYaml): CodexManifest;
|
|
47
54
|
/**
|
|
48
55
|
* 生成 marketplace.json 中的一个条目
|
|
49
56
|
*/
|