@xuxiao-dev/ai-dev-kit 0.1.1 → 0.1.2
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 +132 -23
- package/bin/ai-dev-kit.js +126 -7
- package/codex/rules/ai-task-workflow-rule.md +29 -0
- package/codex/skills/commit-staged-changes/SKILL.md +17 -0
- package/codex/skills/commit-staged-changes/agents/openai.yaml +4 -0
- package/codex/skills/generate-project-readme/SKILL.md +14 -0
- package/codex/skills/generate-project-readme/agents/openai.yaml +4 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">ai-dev-kit</h1>
|
|
6
6
|
<p align="center">
|
|
7
|
-
用于把 AI 开发辅助资源安装到项目中的 TypeScript CLI
|
|
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>
|
|
8
9
|
</p>
|
|
9
10
|
|
|
10
11
|
## 项目简介
|
|
11
12
|
|
|
12
|
-
`@xuxiao-dev/ai-dev-kit` 是一个面向项目开发流程的 npm CLI
|
|
13
|
+
`@xuxiao-dev/ai-dev-kit` 是一个面向项目开发流程的 npm CLI 工具包,用于管理和安装 Cursor 与 Codex 相关资源。
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
在任意项目根目录执行对应的 `add --all` 命令,即可安装内置资源:Cursor 资源会复制到 `.cursor/`,Codex skills 会复制到 `.codex/skills/`,Codex rules 会安全合并到 `AGENTS.md`。适合在多个项目中复用统一的 AI 协作规范、README 生成和提交工作流。
|
|
15
16
|
|
|
16
17
|
当前项目类型为工具库 / npm 包,入口命令为 `ai-dev-kit`,运行环境要求 Node.js `>=18`。
|
|
17
18
|
|
|
@@ -21,6 +22,8 @@
|
|
|
21
22
|
- 按名称安装单个 Cursor Rule 到 `.cursor/rules`
|
|
22
23
|
- 按名称安装单个 Cursor Command 到 `.cursor/commands`
|
|
23
24
|
- 支持一次性安装全部内置 Cursor 资源
|
|
25
|
+
- 查看和安装内置 Codex Skills 与项目 Rules
|
|
26
|
+
- 将 Codex Rules 以受管理区块合并到 `AGENTS.md`,保留已有项目约定
|
|
24
27
|
- 默认跳过已存在文件,避免覆盖当前项目已有配置
|
|
25
28
|
- 支持通过 `--force` 覆盖已存在文件
|
|
26
29
|
|
|
@@ -42,6 +45,9 @@ ai-dev-kit/
|
|
|
42
45
|
├── cursor/
|
|
43
46
|
│ ├── commands/
|
|
44
47
|
│ └── rules/
|
|
48
|
+
├── codex/
|
|
49
|
+
│ ├── skills/
|
|
50
|
+
│ └── rules/
|
|
45
51
|
├── src/
|
|
46
52
|
│ ├── commands/
|
|
47
53
|
│ ├── utils/
|
|
@@ -71,10 +77,30 @@ Cursor Commands:
|
|
|
71
77
|
.cursor/
|
|
72
78
|
├── commands/
|
|
73
79
|
│ └── xxx.md
|
|
74
|
-
└── rules/
|
|
80
|
+
└── rules/
|
|
75
81
|
└── xxx.mdc
|
|
76
82
|
```
|
|
77
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
|
+
.codex/
|
|
97
|
+
└── skills/
|
|
98
|
+
└── xxx/
|
|
99
|
+
└── SKILL.md
|
|
100
|
+
|
|
101
|
+
AGENTS.md
|
|
102
|
+
```
|
|
103
|
+
|
|
78
104
|
## 本地运行
|
|
79
105
|
|
|
80
106
|
安装依赖:
|
|
@@ -99,52 +125,90 @@ pnpm build
|
|
|
99
125
|
|
|
100
126
|
```bash
|
|
101
127
|
node bin/ai-dev-kit.js cursor list
|
|
128
|
+
node bin/ai-dev-kit.js codex list
|
|
102
129
|
```
|
|
103
130
|
|
|
104
|
-
##
|
|
131
|
+
## 快速开始
|
|
105
132
|
|
|
106
|
-
|
|
133
|
+
在目标项目根目录执行,一次性安装全部内置 Cursor 资源:
|
|
107
134
|
|
|
108
135
|
```bash
|
|
109
|
-
npx @xuxiao-dev/ai-dev-kit cursor
|
|
136
|
+
npx @xuxiao-dev/ai-dev-kit cursor add --all
|
|
110
137
|
```
|
|
111
138
|
|
|
112
|
-
|
|
139
|
+
安装 Codex 资源:
|
|
113
140
|
|
|
114
141
|
```bash
|
|
115
|
-
|
|
116
|
-
|
|
142
|
+
npx @xuxiao-dev/ai-dev-kit codex add --all
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Cursor 资源会复制到当前项目的 `.cursor/rules` 和 `.cursor/commands`。Codex skills 会复制到 `.codex/skills`,rules 会追加到 `AGENTS.md` 的受管理区块。默认跳过已存在资源;如需覆盖,加 `--force`。
|
|
146
|
+
|
|
147
|
+
## 使用方式
|
|
148
|
+
|
|
149
|
+
推荐通过 `npx` 直接运行,无需提前安装:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx @xuxiao-dev/ai-dev-kit <子命令>
|
|
117
153
|
```
|
|
118
154
|
|
|
119
155
|
查看内置资源:
|
|
120
156
|
|
|
121
157
|
```bash
|
|
122
|
-
ai-dev-kit cursor list
|
|
158
|
+
npx @xuxiao-dev/ai-dev-kit cursor list
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
安装全部 Cursor 资源:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npx @xuxiao-dev/ai-dev-kit cursor add --all
|
|
123
165
|
```
|
|
124
166
|
|
|
125
167
|
安装单个 Cursor Rule:
|
|
126
168
|
|
|
127
169
|
```bash
|
|
128
|
-
ai-dev-kit cursor add rule ai-task-workflow-rule
|
|
170
|
+
npx @xuxiao-dev/ai-dev-kit cursor add rule ai-task-workflow-rule
|
|
129
171
|
```
|
|
130
172
|
|
|
131
173
|
安装单个 Cursor Command:
|
|
132
174
|
|
|
133
175
|
```bash
|
|
134
|
-
ai-dev-kit cursor add command readme-command
|
|
176
|
+
npx @xuxiao-dev/ai-dev-kit cursor add command readme-command
|
|
135
177
|
```
|
|
136
178
|
|
|
137
|
-
|
|
179
|
+
安装单个 Codex Skill:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npx @xuxiao-dev/ai-dev-kit codex add skill generate-project-readme
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
安装单个 Codex Rule:
|
|
138
186
|
|
|
139
187
|
```bash
|
|
140
|
-
ai-dev-kit
|
|
188
|
+
npx @xuxiao-dev/ai-dev-kit codex add rule ai-task-workflow-rule
|
|
141
189
|
```
|
|
142
190
|
|
|
143
191
|
覆盖已存在文件:
|
|
144
192
|
|
|
145
193
|
```bash
|
|
146
|
-
ai-dev-kit cursor add rule ai-task-workflow-rule --force
|
|
147
|
-
ai-dev-kit cursor add --all --force
|
|
194
|
+
npx @xuxiao-dev/ai-dev-kit cursor add rule ai-task-workflow-rule --force
|
|
195
|
+
npx @xuxiao-dev/ai-dev-kit cursor add --all --force
|
|
196
|
+
npx @xuxiao-dev/ai-dev-kit codex add --all --force
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 安装到项目后使用
|
|
200
|
+
|
|
201
|
+
若已作为开发依赖安装,可省略 `npx` 前缀:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pnpm add -D @xuxiao-dev/ai-dev-kit
|
|
205
|
+
pnpm ai-dev-kit cursor add --all
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
等价于:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npx @xuxiao-dev/ai-dev-kit cursor add --all
|
|
148
212
|
```
|
|
149
213
|
|
|
150
214
|
## 环境变量
|
|
@@ -165,21 +229,66 @@ pnpm build
|
|
|
165
229
|
pnpm prepublishOnly
|
|
166
230
|
```
|
|
167
231
|
|
|
168
|
-
|
|
232
|
+
### 首次发布
|
|
169
233
|
|
|
170
|
-
|
|
234
|
+
```bash
|
|
235
|
+
# 安装依赖
|
|
236
|
+
pnpm install
|
|
171
237
|
|
|
172
|
-
|
|
238
|
+
# 构建产物
|
|
239
|
+
pnpm build
|
|
240
|
+
|
|
241
|
+
# 发布到 npm
|
|
242
|
+
npm publish
|
|
243
|
+
```
|
|
173
244
|
|
|
174
|
-
|
|
245
|
+
首次发布前需要确认:
|
|
246
|
+
|
|
247
|
+
- npm 包名未被占用,或当前账号拥有该包的发布权限
|
|
248
|
+
- `package.json` 中的 `name`、`version`、`bin`、`files` 配置正确
|
|
249
|
+
- 已登录正确的 npm 账号
|
|
250
|
+
|
|
251
|
+
### 更新发布
|
|
252
|
+
|
|
253
|
+
npm 不允许重复发布同一个包版本。每次更新后,都需要先提交代码,再升级版本号,最后重新构建并发布。
|
|
175
254
|
|
|
176
255
|
```bash
|
|
177
|
-
|
|
256
|
+
# 查看当前改动
|
|
257
|
+
git status
|
|
258
|
+
|
|
259
|
+
# 提交本次变更
|
|
260
|
+
git add .
|
|
261
|
+
git commit -m "type(scope): 本次更新说明"
|
|
262
|
+
|
|
263
|
+
# 确认工作区干净
|
|
264
|
+
git status --short
|
|
265
|
+
|
|
266
|
+
# 升级版本号
|
|
267
|
+
pnpm version patch
|
|
268
|
+
|
|
269
|
+
# 构建并发布
|
|
178
270
|
pnpm build
|
|
179
271
|
npm publish
|
|
180
272
|
```
|
|
181
273
|
|
|
182
|
-
|
|
274
|
+
版本号选择建议:
|
|
275
|
+
|
|
276
|
+
- `pnpm version patch`:文档修复、小问题修复
|
|
277
|
+
- `pnpm version minor`:新增能力且保持兼容
|
|
278
|
+
- `pnpm version major`:包含破坏性变更
|
|
279
|
+
|
|
280
|
+
注意事项:
|
|
281
|
+
|
|
282
|
+
- 执行 `pnpm version patch/minor/major` 前,Git 工作区必须是干净的,否则会报 `Git working directory not clean`
|
|
283
|
+
- 发布失败并提示 `You cannot publish over the previously published versions` 时,说明该版本已经发布过,需要升级版本号后重新发布
|
|
284
|
+
- `pnpm version` 会自动修改版本号并创建对应的 Git commit / tag
|
|
285
|
+
- 发布前建议确认已登录正确的 npm 账号,并且账号有当前包的发布权限
|
|
286
|
+
|
|
287
|
+
## 部署说明
|
|
288
|
+
|
|
289
|
+
这是一个 npm CLI 工具,不需要像 Web 项目一样部署到服务器。常见交付方式是构建后发布到 npm,再通过 `npx` 或项目内 devDependencies 使用。
|
|
290
|
+
|
|
291
|
+
npm 包名、发布账号和访问权限请根据实际情况确认。
|
|
183
292
|
|
|
184
293
|
## 后续计划
|
|
185
294
|
|
package/bin/ai-dev-kit.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { Command as
|
|
5
|
-
import
|
|
4
|
+
import { Command as Command3 } from "commander";
|
|
5
|
+
import pc3 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// src/commands/cursor.ts
|
|
8
8
|
import path2 from "path";
|
|
@@ -31,6 +31,19 @@ async function copyFileWithMode(source, target, mode) {
|
|
|
31
31
|
});
|
|
32
32
|
return exists ? "overwritten" : "installed";
|
|
33
33
|
}
|
|
34
|
+
async function copyPathWithMode(source, target, mode) {
|
|
35
|
+
await fs.ensureDir(path.dirname(target));
|
|
36
|
+
const exists = await fs.pathExists(target);
|
|
37
|
+
if (exists && mode === "skip") return "skipped";
|
|
38
|
+
await fs.copy(source, target, { overwrite: true, errorOnExist: false });
|
|
39
|
+
return exists ? "overwritten" : "installed";
|
|
40
|
+
}
|
|
41
|
+
async function listDirectoryNames(directory, requiredFile) {
|
|
42
|
+
if (!await fs.pathExists(directory)) return [];
|
|
43
|
+
const entries = await fs.readdir(directory, { withFileTypes: true });
|
|
44
|
+
const names = await Promise.all(entries.filter((entry) => entry.isDirectory()).map(async (entry) => await fs.pathExists(path.join(directory, entry.name, requiredFile)) ? entry.name : void 0));
|
|
45
|
+
return names.filter((name) => Boolean(name)).sort((a, b) => a.localeCompare(b));
|
|
46
|
+
}
|
|
34
47
|
|
|
35
48
|
// src/commands/cursor.ts
|
|
36
49
|
var RESOURCE_CONFIG = {
|
|
@@ -154,25 +167,131 @@ function sortByPreferredOrder(names, preferredOrder) {
|
|
|
154
167
|
];
|
|
155
168
|
}
|
|
156
169
|
|
|
157
|
-
// src/
|
|
170
|
+
// src/commands/codex.ts
|
|
158
171
|
import path3 from "path";
|
|
172
|
+
import fs2 from "fs-extra";
|
|
173
|
+
import { Command as Command2 } from "commander";
|
|
174
|
+
import pc2 from "picocolors";
|
|
175
|
+
var RULE_START = "<!-- ai-dev-kit:codex-rule:";
|
|
176
|
+
function createCodexCommand(context) {
|
|
177
|
+
const codex = new Command2("codex").description("Manage Codex skills and project rules.");
|
|
178
|
+
codex.command("list").description("List built-in Codex resources.").action(async () => {
|
|
179
|
+
const resources = await getCodexResources(context.packageRoot);
|
|
180
|
+
console.log(pc2.bold("Codex Skills:"));
|
|
181
|
+
printResourceList2(resources.skill);
|
|
182
|
+
console.log(pc2.bold("Codex Rules:"));
|
|
183
|
+
printResourceList2(resources.rule);
|
|
184
|
+
});
|
|
185
|
+
codex.command("add").description("Install Codex resources into the current project.").argument("[type]", "Resource type: skill or rule").argument("[name]", "Resource name to install").option("--all", "Install all Codex skills and rules").option("--force", "Overwrite an existing skill or replace an installed rule block").action(async (type, name, options) => {
|
|
186
|
+
await handleAdd2(context.packageRoot, type, name, options);
|
|
187
|
+
});
|
|
188
|
+
return codex;
|
|
189
|
+
}
|
|
190
|
+
async function handleAdd2(packageRoot2, rawType, name, options) {
|
|
191
|
+
const mode = options.force ? "overwrite" : "skip";
|
|
192
|
+
const projectRoot = process.cwd();
|
|
193
|
+
if (options.all) {
|
|
194
|
+
if (rawType || name) throw new Error('Use either "codex add --all" or "codex add <skill|rule> <name>", not both.');
|
|
195
|
+
const resources2 = await getCodexResources(packageRoot2);
|
|
196
|
+
for (const skill of resources2.skill) await installSkill(packageRoot2, projectRoot, skill, mode);
|
|
197
|
+
for (const rule of resources2.rule) await installRule(packageRoot2, projectRoot, rule, mode);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const type = normalizeResourceType2(rawType);
|
|
201
|
+
if (!type || !name) throw new Error("Missing arguments. Usage: ai-dev-kit codex add <skill|rule> <name> or ai-dev-kit codex add --all");
|
|
202
|
+
const resources = await getCodexResources(packageRoot2);
|
|
203
|
+
if (!resources[type].includes(name)) {
|
|
204
|
+
throw new Error(`Unknown Codex ${type}: ${name}
|
|
205
|
+
Available ${type}s: ${formatAvailable2(resources[type])}`);
|
|
206
|
+
}
|
|
207
|
+
if (type === "skill") await installSkill(packageRoot2, projectRoot, name, mode);
|
|
208
|
+
else await installRule(packageRoot2, projectRoot, name, mode);
|
|
209
|
+
}
|
|
210
|
+
async function installSkill(packageRoot2, projectRoot, name, mode) {
|
|
211
|
+
const targetPath = path3.join(".codex", "skills", name);
|
|
212
|
+
const result = await copyPathWithMode(
|
|
213
|
+
path3.join(packageRoot2, "codex", "skills", name),
|
|
214
|
+
path3.join(projectRoot, targetPath),
|
|
215
|
+
mode
|
|
216
|
+
);
|
|
217
|
+
printCopyResult(targetPath, result);
|
|
218
|
+
}
|
|
219
|
+
async function installRule(packageRoot2, projectRoot, name, mode) {
|
|
220
|
+
const source = path3.join(packageRoot2, "codex", "rules", `${name}.md`);
|
|
221
|
+
const rule = await fs2.readFile(source, "utf8");
|
|
222
|
+
const target = path3.join(projectRoot, "AGENTS.md");
|
|
223
|
+
const start = `${RULE_START}${name}:start -->`;
|
|
224
|
+
const end = `<!-- ai-dev-kit:codex-rule:${name}:end -->`;
|
|
225
|
+
const block = `${start}
|
|
226
|
+
|
|
227
|
+
${rule.trim()}
|
|
228
|
+
|
|
229
|
+
${end}`;
|
|
230
|
+
const existing = await fs2.pathExists(target) ? await fs2.readFile(target, "utf8") : "";
|
|
231
|
+
const startIndex = existing.indexOf(start);
|
|
232
|
+
if (startIndex >= 0) {
|
|
233
|
+
if (mode === "skip") {
|
|
234
|
+
console.log(pc2.yellow(`Skipped existing rule: AGENTS.md (${name})`));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const endIndex = existing.indexOf(end, startIndex);
|
|
238
|
+
if (endIndex < 0) throw new Error(`Cannot replace ${name}: its managed block in AGENTS.md is incomplete.`);
|
|
239
|
+
await fs2.writeFile(target, `${existing.slice(0, startIndex)}${block}${existing.slice(endIndex + end.length)}`);
|
|
240
|
+
console.log(pc2.green(`Overwritten rule: AGENTS.md (${name})`));
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
await fs2.writeFile(target, existing.trimEnd() ? `${existing.trimEnd()}
|
|
244
|
+
|
|
245
|
+
${block}
|
|
246
|
+
` : `${block}
|
|
247
|
+
`);
|
|
248
|
+
console.log(pc2.green(`Installed rule: AGENTS.md (${name})`));
|
|
249
|
+
}
|
|
250
|
+
async function getCodexResources(packageRoot2) {
|
|
251
|
+
const [skills, rules] = await Promise.all([
|
|
252
|
+
listDirectoryNames(path3.join(packageRoot2, "codex", "skills"), "SKILL.md"),
|
|
253
|
+
listResourceNames(path3.join(packageRoot2, "codex", "rules"), ".md")
|
|
254
|
+
]);
|
|
255
|
+
return { skill: skills, rule: rules };
|
|
256
|
+
}
|
|
257
|
+
function normalizeResourceType2(type) {
|
|
258
|
+
if (type === "skill" || type === "rule") return type;
|
|
259
|
+
if (type) throw new Error('Invalid resource type. Use "skill" or "rule".');
|
|
260
|
+
return void 0;
|
|
261
|
+
}
|
|
262
|
+
function printCopyResult(targetPath, result) {
|
|
263
|
+
const label = result === "installed" ? "Installed" : result === "overwritten" ? "Overwritten" : "Skipped existing file";
|
|
264
|
+
const color = result === "skipped" ? pc2.yellow : pc2.green;
|
|
265
|
+
console.log(color(`${label}: ${targetPath}`));
|
|
266
|
+
}
|
|
267
|
+
function printResourceList2(names) {
|
|
268
|
+
if (names.length === 0) console.log(pc2.dim("- none"));
|
|
269
|
+
else names.forEach((name) => console.log(`- ${name}`));
|
|
270
|
+
}
|
|
271
|
+
function formatAvailable2(names) {
|
|
272
|
+
return names.length ? names.join(", ") : "none";
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// src/utils/path.ts
|
|
276
|
+
import path4 from "path";
|
|
159
277
|
import { fileURLToPath } from "url";
|
|
160
278
|
function getPackageRoot(cliImportMetaUrl) {
|
|
161
279
|
const cliFile = fileURLToPath(cliImportMetaUrl);
|
|
162
|
-
return
|
|
280
|
+
return path4.resolve(path4.dirname(cliFile), "..");
|
|
163
281
|
}
|
|
164
282
|
|
|
165
283
|
// src/cli.ts
|
|
166
|
-
var program = new
|
|
284
|
+
var program = new Command3();
|
|
167
285
|
var packageRoot = getPackageRoot(import.meta.url);
|
|
168
|
-
program.name("ai-dev-kit").description("Install AI development helper resources into your project.").version("0.1.
|
|
286
|
+
program.name("ai-dev-kit").description("Install AI development helper resources into your project.").version("0.1.1").showHelpAfterError().showSuggestionAfterError();
|
|
169
287
|
program.addCommand(createCursorCommand({ packageRoot }));
|
|
288
|
+
program.addCommand(createCodexCommand({ packageRoot }));
|
|
170
289
|
program.exitOverride();
|
|
171
290
|
try {
|
|
172
291
|
await program.parseAsync(process.argv);
|
|
173
292
|
} catch (error) {
|
|
174
293
|
if (error instanceof Error) {
|
|
175
|
-
console.error(
|
|
294
|
+
console.error(pc3.red(error.message));
|
|
176
295
|
}
|
|
177
296
|
process.exit(1);
|
|
178
297
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# AI Task Workflow
|
|
2
|
+
|
|
3
|
+
当用户提供 `local-docs/ai-tasks/briefs/*.brief.md`,进入以下工作流:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
Brief → Plan → Checkpoint 执行 → 用户验收 → Final Report
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
所有协作文档放在 `local-docs/ai-tasks/{briefs,plans,reports}/`,命名统一为 `YYYY-MM-DD_task-name`;这些本地协作文档默认不提交 Git。
|
|
10
|
+
|
|
11
|
+
## Plan
|
|
12
|
+
|
|
13
|
+
收到“基于 brief 生成 plan”后:读取 brief 和关联项目代码,不修改业务代码或样式,不安装依赖;在 `plans/` 中创建同名 `.plan.md`,然后停下等待确认。
|
|
14
|
+
|
|
15
|
+
Plan 必须说明:文件对应关系、需求理解、项目现状、涉及文件(含只读参考)、实现思路、2–5 个 checkpoint、风险、待确认问题、验收标准和建议先执行的 checkpoint。
|
|
16
|
+
|
|
17
|
+
## Checkpoint
|
|
18
|
+
|
|
19
|
+
只有用户明确确认 plan 并指定 checkpoint 后才能修改。默认每次只执行一个 checkpoint;执行前说明本次目标、修改范围和不处理的内容。
|
|
20
|
+
|
|
21
|
+
执行时只改当前 checkpoint 的内容,不做计划外优化、不删已有逻辑、不引入未确认依赖。发现计划不合理、不确定点或跨页面风险时暂停并说明。
|
|
22
|
+
|
|
23
|
+
每个 checkpoint 后停止并汇报:已完成内容、修改文件、验证结果、用户需要验收的重点和下一步建议。未获明确验收不得继续下一个 checkpoint。
|
|
24
|
+
|
|
25
|
+
## Final report
|
|
26
|
+
|
|
27
|
+
所有 checkpoint 完成且用户确认结束后,必须在 `reports/` 中创建同名 `.report.md`。报告包含:文件对应关系、目标回顾、完成内容、checkpoint 执行和验收记录、最终修改文件、验证结果、遗留问题与提交建议。
|
|
28
|
+
|
|
29
|
+
不要在未生成计划或未确认计划时改代码;不要在 checkpoint 后自动推进;不要只在聊天中输出 report;不要伪造验证结果或忽略 brief 中的“不要做”。
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commit-staged-changes
|
|
3
|
+
description: Generate a Chinese Conventional Commit message from Git staged changes and execute exactly one safe commit. Use when the user explicitly asks Codex to commit the current staged changes, says “提交暂存区”, “帮我 commit”, or invokes this skill; do not use for merely explaining Git or reviewing changes without authorization to commit.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 提交暂存区变更
|
|
7
|
+
|
|
8
|
+
1. 只读取暂存区:先运行 `git diff --cached`,必要时读取 `git diff --cached --stat`。不要把未暂存变更纳入判断。
|
|
9
|
+
2. 暂存区为空时,停止并输出:`当前暂存区没有变更,请先执行 git add 后再生成 commit message。`
|
|
10
|
+
3. 生成一条中文 Conventional Commit:优先 `<type>(<scope>): <subject>`;scope 不明确时省略。subject 用简短动宾结构,不超过 50 个中文字符,不以句号结尾。
|
|
11
|
+
4. 选择最核心的 type:`feat`、`fix`、`docs`、`style`、`refactor`、`perf`、`test`、`build`、`ci`、`chore` 或 `revert`。scope 使用受影响模块或路径的英文小写名称;无法确定则不编造。
|
|
12
|
+
5. 变更多且单行说不清时,补充简短 body,列出真实变更点。
|
|
13
|
+
6. 向用户展示推荐 message 和一句选择理由后,直接执行一次 `git commit`。不要 `git push`、`--no-verify`、`--amend`、rebase 或其他历史改写操作。
|
|
14
|
+
7. 提交成功后,运行 `git show -s --format=%B HEAD` 自检。提交信息不得包含任何共同作者标记(大小写不敏感的 `Co-authored-by:`)。若发现,报告异常并停止;不要自行 amend。
|
|
15
|
+
8. 提交失败时,只输出关键失败原因和 1–2 条下一步建议;不要重复尝试。
|
|
16
|
+
|
|
17
|
+
不要输出完整 diff、多个无关候选,或暂存区之外的推断。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generate-project-readme
|
|
3
|
+
description: Create or update a GitHub-ready README.md by inspecting the real project structure, dependencies, scripts, and implemented features. Use when the user asks to generate, rewrite, improve, or document a project's README; never invent unverified features or configuration.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 生成项目 README
|
|
7
|
+
|
|
8
|
+
1. 先检查 `package.json`、锁文件、构建和 TypeScript 配置、现有 README、入口文件及核心源码目录;根据项目类型补充检查路由、组件、服务、环境变量示例和部署配置。
|
|
9
|
+
2. 仅从实际代码与配置中总结项目名称、用途、功能、技术栈、目录结构、运行命令、环境变量和部署方式。不能确认的信息写“待补充”。不要暴露 `.env` 的具体值。
|
|
10
|
+
3. README 顶部默认放置封面图,再放居中标题和一句简介。封面地址优先级:本次请求明确提供的 OSS/GIF 地址;`docs/images/readme-cover.gif`;`docs/images/readme-cover.png`;否则使用 `https://typorabucket0308.oss-cn-beijing.aliyuncs.com/images/20260603103934962.jpg`。
|
|
11
|
+
4. README 至少包含:项目简介、功能特性、技术栈、核心目录结构、本地运行、环境变量、部署说明和后续计划。目录结构只列核心文件。
|
|
12
|
+
5. 从实际锁文件选择包管理器:`pnpm-lock.yaml` 用 pnpm,`yarn.lock` 用 yarn,`package-lock.json` 用 npm。只写已存在的 scripts;缺失命令标记“待补充”。
|
|
13
|
+
6. 可以将无法确认的部署方式写成“参考”,但不要把它描述为项目既有能力。roadmap 保持保守且贴合当前项目状态。
|
|
14
|
+
7. 修改 `README.md` 后,简要说明依据和文件路径。不要凭空添加图片、敏感信息、账号、接口地址或版权风险说明。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xuxiao-dev/ai-dev-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A CLI toolkit for installing AI development resources into projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin",
|
|
11
|
+
"codex",
|
|
11
12
|
"cursor",
|
|
12
13
|
"README.md"
|
|
13
14
|
],
|