@xuxiao-dev/ai-dev-kit 0.1.3 → 0.2.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/README.md +46 -193
- package/bin/ai-dev-kit.js +54 -54
- package/codex/index.html +205 -0
- package/codex/skills/content-blog-optimize/SKILL.md +206 -0
- package/codex/skills/content-blog-optimize/agents/openai.yaml +4 -0
- package/codex/skills/document-project-docs/SKILL.md +42 -0
- package/codex/skills/document-project-docs/agents/openai.yaml +4 -0
- package/codex/skills/{generate-project-readme → document-project-readme}/SKILL.md +1 -1
- package/codex/skills/{generate-project-readme → document-project-readme}/agents/openai.yaml +1 -1
- package/codex/skills/engineering-bug-review/SKILL.md +40 -0
- package/codex/skills/engineering-bug-review/agents/openai.yaml +4 -0
- package/codex/skills/{commit-staged-changes → git-commit-staged}/SKILL.md +1 -1
- package/codex/skills/{commit-staged-changes → git-commit-staged}/agents/openai.yaml +1 -1
- package/codex/skills/vue-component-config/SKILL.md +339 -0
- package/codex/skills/vue-component-config/agents/openai.yaml +4 -0
- package/package.json +1 -1
- package/codex/rules/ai-task-workflow-rule.md +0 -29
package/README.md
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://typorabucket0308.oss-cn-beijing.aliyuncs.com/images/20260603103934962.jpg" alt="
|
|
2
|
+
<img src="https://typorabucket0308.oss-cn-beijing.aliyuncs.com/images/20260603103934962.jpg" alt="ai-dev-kit 项目封面" width="800" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">ai-dev-kit</h1>
|
|
6
|
-
<p align="center">
|
|
7
|
-
用于把 AI 开发辅助资源安装到项目中的 TypeScript CLI 工具。<br />
|
|
8
|
-
在目标项目根目录执行:<code>npx @xuxiao-dev/ai-dev-kit cursor add --all</code> 或 <code>npx @xuxiao-dev/ai-dev-kit codex add --all</code>
|
|
9
|
-
</p>
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
<p align="center">将内置的 Cursor 与 Codex 开发协作资源安装到目标项目的命令行工具。</p>
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
## 项目简介
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
`@xuxiao-dev/ai-dev-kit` 是一个 npm CLI 包,用于将包内维护的 Cursor rules / commands,以及 Codex skills / rules 复制或合并到当前工作目录的项目中。
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
CLI 命令为 `ai-dev-kit`,运行环境要求 Node.js `>=18`。
|
|
18
14
|
|
|
19
15
|
## 功能特性
|
|
20
16
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
- 将 Codex Rules 以受管理区块合并到 `AGENTS.md`,保留已有项目约定
|
|
27
|
-
- 默认跳过已存在文件,避免覆盖当前项目已有配置
|
|
28
|
-
- 支持通过 `--force` 覆盖已存在文件
|
|
17
|
+
- 列出包内可用的 Cursor 和 Codex 资源。
|
|
18
|
+
- 安装单个或全部 Cursor rule 与 command 到 `.cursor/`。
|
|
19
|
+
- 安装单个或全部 Codex skill 到 `.agents/skills/`。
|
|
20
|
+
- 将 Codex skills 安装到 `.agents/skills/`,并在 `AGENTS.md` 中维护简短索引。
|
|
21
|
+
- 默认跳过目标中已存在的资源;使用 `--force` 可覆盖已安装的 Skill 或更新受管理的 `AGENTS.md` 索引区块。
|
|
29
22
|
|
|
30
23
|
## 技术栈
|
|
31
24
|
|
|
@@ -35,72 +28,28 @@
|
|
|
35
28
|
- fs-extra
|
|
36
29
|
- picocolors
|
|
37
30
|
- tsup
|
|
38
|
-
- tsx
|
|
39
31
|
- pnpm
|
|
40
32
|
|
|
41
|
-
##
|
|
33
|
+
## 核心目录结构
|
|
42
34
|
|
|
43
35
|
```text
|
|
44
36
|
ai-dev-kit/
|
|
37
|
+
├── bin/ # 构建后的 CLI
|
|
38
|
+
├── codex/
|
|
39
|
+
│ ├── rules/
|
|
40
|
+
│ └── skills/
|
|
45
41
|
├── cursor/
|
|
46
42
|
│ ├── commands/
|
|
47
43
|
│ └── rules/
|
|
48
|
-
├── codex/
|
|
49
|
-
│ ├── skills/
|
|
50
|
-
│ └── rules/
|
|
51
44
|
├── src/
|
|
52
|
-
│ ├── commands/
|
|
45
|
+
│ ├── commands/ # Cursor / Codex 子命令
|
|
53
46
|
│ ├── utils/
|
|
54
|
-
│ └── cli.ts
|
|
47
|
+
│ └── cli.ts # CLI 入口
|
|
55
48
|
├── package.json
|
|
56
|
-
├── pnpm-lock.yaml
|
|
57
|
-
├── tsconfig.json
|
|
58
49
|
├── tsup.config.ts
|
|
59
50
|
└── README.md
|
|
60
51
|
```
|
|
61
52
|
|
|
62
|
-
## 内置资源
|
|
63
|
-
|
|
64
|
-
Cursor Rules:
|
|
65
|
-
|
|
66
|
-
- `ai-task-workflow-rule`
|
|
67
|
-
|
|
68
|
-
Cursor Commands:
|
|
69
|
-
|
|
70
|
-
- `readme-command`
|
|
71
|
-
- `create-plan-from-brief`
|
|
72
|
-
- `commit`
|
|
73
|
-
|
|
74
|
-
安装到业务项目后,资源会写入:
|
|
75
|
-
|
|
76
|
-
```text
|
|
77
|
-
.cursor/
|
|
78
|
-
├── commands/
|
|
79
|
-
│ └── xxx.md
|
|
80
|
-
└── rules/
|
|
81
|
-
└── xxx.mdc
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Codex Skills:
|
|
85
|
-
|
|
86
|
-
- `commit-staged-changes`:根据暂存区变更生成中文 Conventional Commit 并安全提交
|
|
87
|
-
- `generate-project-readme`:根据真实代码和配置生成或更新 README
|
|
88
|
-
|
|
89
|
-
Codex Rules:
|
|
90
|
-
|
|
91
|
-
- `ai-task-workflow-rule`
|
|
92
|
-
|
|
93
|
-
安装到业务项目后,资源会写入:
|
|
94
|
-
|
|
95
|
-
```text
|
|
96
|
-
.agents/
|
|
97
|
-
└── skills/
|
|
98
|
-
└── xxx/
|
|
99
|
-
└── SKILL.md
|
|
100
|
-
|
|
101
|
-
AGENTS.md
|
|
102
|
-
```
|
|
103
|
-
|
|
104
53
|
## 本地运行
|
|
105
54
|
|
|
106
55
|
安装依赖:
|
|
@@ -109,53 +58,32 @@ AGENTS.md
|
|
|
109
58
|
pnpm install
|
|
110
59
|
```
|
|
111
60
|
|
|
112
|
-
|
|
61
|
+
以源码方式运行 CLI:
|
|
113
62
|
|
|
114
63
|
```bash
|
|
115
64
|
pnpm dev
|
|
116
65
|
```
|
|
117
66
|
|
|
118
|
-
|
|
67
|
+
构建:
|
|
119
68
|
|
|
120
69
|
```bash
|
|
121
70
|
pnpm build
|
|
122
71
|
```
|
|
123
72
|
|
|
124
|
-
|
|
73
|
+
构建完成后,可执行:
|
|
125
74
|
|
|
126
75
|
```bash
|
|
127
76
|
node bin/ai-dev-kit.js cursor list
|
|
128
77
|
node bin/ai-dev-kit.js codex list
|
|
129
78
|
```
|
|
130
79
|
|
|
131
|
-
## 快速开始
|
|
132
|
-
|
|
133
|
-
在目标项目根目录执行,一次性安装全部内置 Cursor 资源:
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
npx @xuxiao-dev/ai-dev-kit cursor add --all
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
安装 Codex 资源:
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npx @xuxiao-dev/ai-dev-kit codex add --all
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Cursor 资源会复制到当前项目的 `.cursor/rules` 和 `.cursor/commands`。Codex skills 会复制到 `.agents/skills`,rules 会追加到 `AGENTS.md` 的受管理区块。默认跳过已存在资源;如需覆盖,加 `--force`。
|
|
146
|
-
|
|
147
80
|
## 使用方式
|
|
148
81
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
npx @xuxiao-dev/ai-dev-kit <子命令>
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
查看内置资源:
|
|
82
|
+
在目标项目根目录中,通过 `npx` 运行已发布的包:
|
|
156
83
|
|
|
157
84
|
```bash
|
|
158
85
|
npx @xuxiao-dev/ai-dev-kit cursor list
|
|
86
|
+
npx @xuxiao-dev/ai-dev-kit codex list
|
|
159
87
|
```
|
|
160
88
|
|
|
161
89
|
安装全部 Cursor 资源:
|
|
@@ -164,145 +92,70 @@ npx @xuxiao-dev/ai-dev-kit cursor list
|
|
|
164
92
|
npx @xuxiao-dev/ai-dev-kit cursor add --all
|
|
165
93
|
```
|
|
166
94
|
|
|
167
|
-
安装单个 Cursor
|
|
95
|
+
安装单个 Cursor 资源:
|
|
168
96
|
|
|
169
97
|
```bash
|
|
170
98
|
npx @xuxiao-dev/ai-dev-kit cursor add rule ai-task-workflow-rule
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
安装单个 Cursor Command:
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
99
|
npx @xuxiao-dev/ai-dev-kit cursor add command readme-command
|
|
177
100
|
```
|
|
178
101
|
|
|
179
|
-
|
|
102
|
+
安装全部 Codex 资源:
|
|
180
103
|
|
|
181
104
|
```bash
|
|
182
|
-
npx @xuxiao-dev/ai-dev-kit codex add
|
|
105
|
+
npx @xuxiao-dev/ai-dev-kit codex add --all
|
|
183
106
|
```
|
|
184
107
|
|
|
185
|
-
|
|
108
|
+
也可以只安装某一类 Codex 资源:
|
|
186
109
|
|
|
187
110
|
```bash
|
|
188
111
|
npx @xuxiao-dev/ai-dev-kit codex add skill --all
|
|
112
|
+
npx @xuxiao-dev/ai-dev-kit codex add rule --all
|
|
189
113
|
```
|
|
190
114
|
|
|
191
|
-
安装单个 Codex
|
|
115
|
+
安装单个 Codex skill:
|
|
192
116
|
|
|
193
117
|
```bash
|
|
194
|
-
npx @xuxiao-dev/ai-dev-kit codex add
|
|
118
|
+
npx @xuxiao-dev/ai-dev-kit codex add skill document-project-readme
|
|
119
|
+
npx @xuxiao-dev/ai-dev-kit codex add skill vue-component-config
|
|
195
120
|
```
|
|
196
121
|
|
|
197
|
-
|
|
122
|
+
默认不会覆盖目标项目内已有资源。如需覆盖,请增加 `--force`:
|
|
198
123
|
|
|
199
124
|
```bash
|
|
200
|
-
npx @xuxiao-dev/ai-dev-kit cursor add rule ai-task-workflow-rule --force
|
|
201
125
|
npx @xuxiao-dev/ai-dev-kit cursor add --all --force
|
|
202
126
|
npx @xuxiao-dev/ai-dev-kit codex add --all --force
|
|
203
127
|
```
|
|
204
128
|
|
|
205
|
-
|
|
129
|
+
## 内置资源
|
|
206
130
|
|
|
207
|
-
|
|
131
|
+
当前包内包含以下资源:
|
|
208
132
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
133
|
+
| 类型 | 资源 |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| Cursor Rule | `ai-task-workflow-rule` |
|
|
136
|
+
| Cursor Command | `commit`、`create-plan-from-brief`、`readme-command` |
|
|
137
|
+
| Codex Skill | `content-blog-optimize`、`document-project-docs`、`document-project-readme`、`engineering-bug-review`、`git-commit-staged`、`vue-component-config` |
|
|
213
138
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
npx @xuxiao-dev/ai-dev-kit cursor add --all
|
|
218
|
-
```
|
|
139
|
+
安装后,Cursor 资源会写入 `.cursor/rules/` 或 `.cursor/commands/`;Codex skills 会写入 `.agents/skills/`,并在目标项目的 `AGENTS.md` 中追加由 ai-dev-kit 管理的 Skill 索引区块。完整 Skill 内容不会写入 `AGENTS.md`。
|
|
219
140
|
|
|
220
141
|
## 环境变量
|
|
221
142
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
## 构建与发布
|
|
225
|
-
|
|
226
|
-
项目使用 `tsup` 构建,构建入口为 `src/cli.ts`,产物输出到 `bin/` 目录,并带有 Node.js CLI 所需的 shebang。
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
pnpm build
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
发布前会执行:
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
pnpm prepublishOnly
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### 首次发布
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
# 安装依赖
|
|
242
|
-
pnpm install
|
|
243
|
-
|
|
244
|
-
# 构建产物
|
|
245
|
-
pnpm build
|
|
143
|
+
当前代码未读取运行时环境变量,仓库中也未提供 `.env.example`,无需额外配置。
|
|
246
144
|
|
|
247
|
-
|
|
248
|
-
npm publish
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
首次发布前需要确认:
|
|
252
|
-
|
|
253
|
-
- npm 包名未被占用,或当前账号拥有该包的发布权限
|
|
254
|
-
- `package.json` 中的 `name`、`version`、`bin`、`files` 配置正确
|
|
255
|
-
- 已登录正确的 npm 账号
|
|
145
|
+
## 部署说明
|
|
256
146
|
|
|
257
|
-
|
|
147
|
+
本项目构建产物位于 `bin/`,并通过 `package.json` 的 `bin` 字段暴露为 `ai-dev-kit` 命令。发布前会自动执行 `pnpm build`(`prepublishOnly`)。
|
|
258
148
|
|
|
259
|
-
npm
|
|
149
|
+
发布到 npm 前,请根据实际发布权限确认包名、版本号和 npm 登录状态:
|
|
260
150
|
|
|
261
151
|
```bash
|
|
262
|
-
# 查看当前改动
|
|
263
|
-
git status
|
|
264
|
-
|
|
265
|
-
# 提交本次变更
|
|
266
|
-
git add .
|
|
267
|
-
git commit -m "type(scope): 本次更新说明"
|
|
268
|
-
|
|
269
|
-
# 确认工作区干净
|
|
270
|
-
git status --short
|
|
271
|
-
|
|
272
|
-
# 升级版本号
|
|
273
|
-
pnpm version patch
|
|
274
|
-
|
|
275
|
-
# 构建并发布
|
|
276
152
|
pnpm build
|
|
277
153
|
npm publish
|
|
278
154
|
```
|
|
279
155
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
- `pnpm version patch`:文档修复、小问题修复
|
|
283
|
-
- `pnpm version minor`:新增能力且保持兼容
|
|
284
|
-
- `pnpm version major`:包含破坏性变更
|
|
285
|
-
|
|
286
|
-
注意事项:
|
|
287
|
-
|
|
288
|
-
- 执行 `pnpm version patch/minor/major` 前,Git 工作区必须是干净的,否则会报 `Git working directory not clean`
|
|
289
|
-
- 发布失败并提示 `You cannot publish over the previously published versions` 时,说明该版本已经发布过,需要升级版本号后重新发布
|
|
290
|
-
- `pnpm version` 会自动修改版本号并创建对应的 Git commit / tag
|
|
291
|
-
- 发布前建议确认已登录正确的 npm 账号,并且账号有当前包的发布权限
|
|
292
|
-
|
|
293
|
-
## 部署说明
|
|
294
|
-
|
|
295
|
-
这是一个 npm CLI 工具,不需要像 Web 项目一样部署到服务器。常见交付方式是构建后发布到 npm,再通过 `npx` 或项目内 devDependencies 使用。
|
|
296
|
-
|
|
297
|
-
npm 包名、发布账号和访问权限请根据实际情况确认。
|
|
156
|
+
更多发布前的暂存与检查步骤可参考 [docs/npm-staged-publish.md](docs/npm-staged-publish.md)。
|
|
298
157
|
|
|
299
158
|
## 后续计划
|
|
300
159
|
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
- 根据实际使用情况扩展更多 Cursor Rules 和 Commands
|
|
304
|
-
- 增加资源名称与 README 内置资源列表的同步检查
|
|
305
|
-
|
|
306
|
-
## License
|
|
307
|
-
|
|
308
|
-
待补充
|
|
160
|
+
- 根据实际使用反馈补充或调整内置资源。
|
|
161
|
+
- 为 CLI 行为补充自动化测试与使用示例。
|
package/bin/ai-dev-kit.js
CHANGED
|
@@ -172,17 +172,24 @@ import path3 from "path";
|
|
|
172
172
|
import fs2 from "fs-extra";
|
|
173
173
|
import { Command as Command2 } from "commander";
|
|
174
174
|
import pc2 from "picocolors";
|
|
175
|
-
var
|
|
175
|
+
var SKILL_INDEX_START = "<!-- ai-dev-kit:codex-skills:start -->";
|
|
176
|
+
var SKILL_INDEX_END = "<!-- ai-dev-kit:codex-skills:end -->";
|
|
177
|
+
var SKILL_DESCRIPTIONS = {
|
|
178
|
+
"content-blog-optimize": "\u4E2D\u6587\u6280\u672F\u535A\u5BA2\u4F18\u5316",
|
|
179
|
+
"document-project-docs": "\u9879\u76EE\u6587\u6863\u7EC4\u7EC7\u4E0E\u7EF4\u62A4",
|
|
180
|
+
"document-project-readme": "\u9879\u76EE README \u751F\u6210\u4E0E\u7EF4\u62A4",
|
|
181
|
+
"engineering-bug-review": "\u5DE5\u7A0B\u95EE\u9898\u590D\u76D8",
|
|
182
|
+
"git-commit-staged": "Git \u6682\u5B58\u533A\u63D0\u4EA4",
|
|
183
|
+
"vue-component-config": "Vue \u7EC4\u4EF6\u914D\u7F6E\u89C4\u8303"
|
|
184
|
+
};
|
|
176
185
|
function createCodexCommand(context) {
|
|
177
|
-
const codex = new Command2("codex").description("Manage Codex skills
|
|
178
|
-
codex.command("list").description("List built-in Codex
|
|
179
|
-
const
|
|
186
|
+
const codex = new Command2("codex").description("Manage Codex skills for the current project.");
|
|
187
|
+
codex.command("list").description("List built-in Codex skills.").action(async () => {
|
|
188
|
+
const skills = await getCodexSkills(context.packageRoot);
|
|
180
189
|
console.log(pc2.bold("Codex Skills:"));
|
|
181
|
-
printResourceList2(
|
|
182
|
-
console.log(pc2.bold("Codex Rules:"));
|
|
183
|
-
printResourceList2(resources.rule);
|
|
190
|
+
printResourceList2(skills);
|
|
184
191
|
});
|
|
185
|
-
codex.command("add").description("Install Codex
|
|
192
|
+
codex.command("add").description("Install Codex skills into the current project.").argument("[type]", "Resource type: skill").argument("[name]", "Skill name to install").option("--all", "Install all Codex skills").option("--force", "Overwrite an existing skill or replace the managed AGENTS.md index").action(async (type, name, options) => {
|
|
186
193
|
await handleAdd2(context.packageRoot, type, name, options);
|
|
187
194
|
});
|
|
188
195
|
return codex;
|
|
@@ -191,26 +198,20 @@ async function handleAdd2(packageRoot2, rawType, name, options) {
|
|
|
191
198
|
const mode = options.force ? "overwrite" : "skip";
|
|
192
199
|
const projectRoot = process.cwd();
|
|
193
200
|
if (options.all) {
|
|
194
|
-
if (name) throw new Error('Do not provide a
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
for (const skill of resources2.skill) await installSkill(packageRoot2, projectRoot, skill, mode);
|
|
199
|
-
}
|
|
200
|
-
if (!type2 || type2 === "rule") {
|
|
201
|
-
for (const rule of resources2.rule) await installRule(packageRoot2, projectRoot, rule, mode);
|
|
202
|
-
}
|
|
201
|
+
if (name) throw new Error('Do not provide a skill name with --all. Use "codex add --all" or "codex add skill --all".');
|
|
202
|
+
normalizeResourceType2(rawType);
|
|
203
|
+
const skills2 = await getCodexSkills(packageRoot2);
|
|
204
|
+
for (const skill of skills2) await installSkill(packageRoot2, projectRoot, skill, mode);
|
|
203
205
|
return;
|
|
204
206
|
}
|
|
205
207
|
const type = normalizeResourceType2(rawType);
|
|
206
|
-
if (!type || !name) throw new Error("Missing arguments. Usage: ai-dev-kit codex add
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
209
|
-
throw new Error(`Unknown Codex
|
|
210
|
-
Available
|
|
208
|
+
if (!type || !name) throw new Error("Missing arguments. Usage: ai-dev-kit codex add skill <name>, ai-dev-kit codex add skill --all, or ai-dev-kit codex add --all");
|
|
209
|
+
const skills = await getCodexSkills(packageRoot2);
|
|
210
|
+
if (!skills.includes(name)) {
|
|
211
|
+
throw new Error(`Unknown Codex skill: ${name}
|
|
212
|
+
Available skills: ${formatAvailable2(skills)}`);
|
|
211
213
|
}
|
|
212
|
-
|
|
213
|
-
else await installRule(packageRoot2, projectRoot, name, mode);
|
|
214
|
+
await installSkill(packageRoot2, projectRoot, name, mode);
|
|
214
215
|
}
|
|
215
216
|
async function installSkill(packageRoot2, projectRoot, name, mode) {
|
|
216
217
|
const targetPath = path3.join(".agents", "skills", name);
|
|
@@ -220,29 +221,34 @@ async function installSkill(packageRoot2, projectRoot, name, mode) {
|
|
|
220
221
|
mode
|
|
221
222
|
);
|
|
222
223
|
printCopyResult(targetPath, result);
|
|
224
|
+
await updateSkillIndex(projectRoot, name);
|
|
223
225
|
}
|
|
224
|
-
async function
|
|
225
|
-
const source = path3.join(packageRoot2, "codex", "rules", `${name}.md`);
|
|
226
|
-
const rule = await fs2.readFile(source, "utf8");
|
|
226
|
+
async function updateSkillIndex(projectRoot, name) {
|
|
227
227
|
const target = path3.join(projectRoot, "AGENTS.md");
|
|
228
|
-
const start = `${RULE_START}${name}:start -->`;
|
|
229
|
-
const end = `<!-- ai-dev-kit:codex-rule:${name}:end -->`;
|
|
230
|
-
const block = `${start}
|
|
231
|
-
|
|
232
|
-
${rule.trim()}
|
|
233
|
-
|
|
234
|
-
${end}`;
|
|
235
228
|
const existing = await fs2.pathExists(target) ? await fs2.readFile(target, "utf8") : "";
|
|
236
|
-
const startIndex = existing.indexOf(
|
|
229
|
+
const startIndex = existing.indexOf(SKILL_INDEX_START);
|
|
230
|
+
const names = /* @__PURE__ */ new Set();
|
|
237
231
|
if (startIndex >= 0) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
232
|
+
const endIndex = existing.indexOf(SKILL_INDEX_END, startIndex);
|
|
233
|
+
if (endIndex < 0) throw new Error("Cannot update AGENTS.md: its managed Codex skill index is incomplete.");
|
|
234
|
+
const managedBlock = existing.slice(startIndex, endIndex);
|
|
235
|
+
for (const match of managedBlock.matchAll(/\.agents\/skills\/([a-z0-9-]+)\/SKILL\.md/g)) names.add(match[1]);
|
|
236
|
+
}
|
|
237
|
+
names.add(name);
|
|
238
|
+
const block = [
|
|
239
|
+
SKILL_INDEX_START,
|
|
240
|
+
"",
|
|
241
|
+
"## \u53EF\u7528\u9879\u76EE Skills",
|
|
242
|
+
"",
|
|
243
|
+
"\u6D89\u53CA\u5BF9\u5E94\u4EFB\u52A1\u65F6\uFF0C\u5148\u9605\u8BFB\u76F8\u5173 Skill\uFF1A",
|
|
244
|
+
"",
|
|
245
|
+
...[...names].sort((a, b) => a.localeCompare(b)).map((skill) => `- ${SKILL_DESCRIPTIONS[skill] ?? skill}\uFF1A.agents/skills/${skill}/SKILL.md`),
|
|
246
|
+
"",
|
|
247
|
+
SKILL_INDEX_END
|
|
248
|
+
].join("\n");
|
|
249
|
+
if (startIndex >= 0) {
|
|
250
|
+
const endIndex = existing.indexOf(SKILL_INDEX_END, startIndex);
|
|
251
|
+
await fs2.writeFile(target, `${existing.slice(0, startIndex)}${block}${existing.slice(endIndex + SKILL_INDEX_END.length)}`);
|
|
246
252
|
return;
|
|
247
253
|
}
|
|
248
254
|
await fs2.writeFile(target, existing.trimEnd() ? `${existing.trimEnd()}
|
|
@@ -250,19 +256,13 @@ ${end}`;
|
|
|
250
256
|
${block}
|
|
251
257
|
` : `${block}
|
|
252
258
|
`);
|
|
253
|
-
console.log(pc2.green(`Installed rule: AGENTS.md (${name})`));
|
|
254
259
|
}
|
|
255
|
-
async function
|
|
256
|
-
|
|
257
|
-
listDirectoryNames(path3.join(packageRoot2, "codex", "skills"), "SKILL.md"),
|
|
258
|
-
listResourceNames(path3.join(packageRoot2, "codex", "rules"), ".md")
|
|
259
|
-
]);
|
|
260
|
-
return { skill: skills, rule: rules };
|
|
260
|
+
async function getCodexSkills(packageRoot2) {
|
|
261
|
+
return listDirectoryNames(path3.join(packageRoot2, "codex", "skills"), "SKILL.md");
|
|
261
262
|
}
|
|
262
263
|
function normalizeResourceType2(type) {
|
|
263
|
-
if (type ===
|
|
264
|
-
|
|
265
|
-
return void 0;
|
|
264
|
+
if (type === void 0 || type === "skill") return "skill";
|
|
265
|
+
throw new Error('Invalid resource type. Use "skill".');
|
|
266
266
|
}
|
|
267
267
|
function printCopyResult(targetPath, result) {
|
|
268
268
|
const label = result === "installed" ? "Installed" : result === "overwritten" ? "Overwritten" : "Skipped existing file";
|
|
@@ -288,7 +288,7 @@ function getPackageRoot(cliImportMetaUrl) {
|
|
|
288
288
|
// src/cli.ts
|
|
289
289
|
var program = new Command3();
|
|
290
290
|
var packageRoot = getPackageRoot(import.meta.url);
|
|
291
|
-
program.name("ai-dev-kit").description("Install AI development helper resources into your project.").version("0.
|
|
291
|
+
program.name("ai-dev-kit").description("Install AI development helper resources into your project.").version("0.2.0").showHelpAfterError().showSuggestionAfterError();
|
|
292
292
|
program.addCommand(createCursorCommand({ packageRoot }));
|
|
293
293
|
program.addCommand(createCodexCommand({ packageRoot }));
|
|
294
294
|
program.exitOverride();
|