@mingfuyun/star-allinone 0.2.0 → 0.3.1
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 +17 -10
- package/examples/AGENTS.md +26 -0
- package/examples/projects/starlink-frontend.star-allinone.json +7 -0
- package/examples/projects/starscope-frontend.star-allinone.json +7 -0
- package/examples/skills/custom-domain-invariants/SKILL.md +16 -0
- package/package.json +5 -3
- package/scripts/cli.js +52 -13
- package/scripts/gen/fixtures/run.js +104 -0
- package/scripts/gen/fixtures/widgets.openapi.json +194 -0
- package/scripts/gen/names.js +117 -0
- package/scripts/gen/page.js +483 -0
- package/scripts/gen/project.js +154 -0
- package/scripts/gen/service.js +264 -0
- package/scripts/gen/spec.js +220 -0
- package/scripts/gen/ts.js +121 -0
- package/skills/README.md +45 -188
- package/skills/shared/api-to-service/SKILL.md +18 -10
- package/skills/shared/{api-mock/SKILL.md → api-to-service/references/mock.md} +3 -10
- package/skills/shared/design-to-page/SKILL.md +45 -6
- package/skills/shared/design-to-page/references/list-page-template.md +44 -0
- package/skills/shared/design-to-page/references/page-conventions.md +1 -1
- package/skills/shared/i-have-adhd/{SKILL.md → i-have-adhd.md} +0 -10
- package/skills/shared/project-conventions/references/architecture.md +3 -0
- package/skills/shared/publish-test/SKILL.md +4 -2
- package/skills/shared/review-and-submit/SKILL.md +8 -16
- package/skills/shared/{ai-review/SKILL.md → review-and-submit/references/ai-review.md} +4 -11
- package/skills/shared/{commit-current-changes/SKILL.md → review-and-submit/references/commit.md} +4 -12
- package/skills/shared/{impact-analysis/SKILL.md → review-and-submit/references/impact-analysis.md} +1 -10
- package/skills/shared/{verify/SKILL.md → review-and-submit/references/verify.md} +4 -11
- package/skills/shared/project-conventions/SKILL.md +0 -34
- /package/skills/shared/{api-mock → api-to-service}/references/mock-conventions.md +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const { deref, refName, pointerValue } = require('./spec');
|
|
2
|
+
|
|
3
|
+
function isNullable(schema) {
|
|
4
|
+
if (!schema) return false;
|
|
5
|
+
if (schema.nullable) return true;
|
|
6
|
+
if (Array.isArray(schema.type) && schema.type.includes('null')) return true;
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function withNull(type, schema) {
|
|
11
|
+
if (!isNullable(schema) || type.includes('| null')) return type;
|
|
12
|
+
return `${type} | null`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function collectRefs(spec, schema, bag = new Set(), seen = new Set()) {
|
|
16
|
+
if (!schema) return bag;
|
|
17
|
+
if (schema.$ref) {
|
|
18
|
+
if (seen.has(schema.$ref)) return bag;
|
|
19
|
+
seen.add(schema.$ref);
|
|
20
|
+
bag.add(schema.$ref);
|
|
21
|
+
collectRefs(spec, deref(spec, schema), bag, seen);
|
|
22
|
+
return bag;
|
|
23
|
+
}
|
|
24
|
+
const nested = [
|
|
25
|
+
schema.items,
|
|
26
|
+
...(schema.allOf || []),
|
|
27
|
+
...(schema.oneOf || []),
|
|
28
|
+
...(schema.anyOf || []),
|
|
29
|
+
...Object.values(schema.properties || {}),
|
|
30
|
+
schema.additionalProperties && typeof schema.additionalProperties === 'object'
|
|
31
|
+
? schema.additionalProperties
|
|
32
|
+
: null,
|
|
33
|
+
].filter(Boolean);
|
|
34
|
+
nested.forEach((item) => collectRefs(spec, item, bag, seen));
|
|
35
|
+
return bag;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function schemaToTs(spec, schema, namedRefs = new Map()) {
|
|
39
|
+
if (!schema) return 'unknown';
|
|
40
|
+
if (schema.$ref) {
|
|
41
|
+
if (namedRefs.has(schema.$ref)) return namedRefs.get(schema.$ref);
|
|
42
|
+
return refName(schema.$ref) || 'unknown';
|
|
43
|
+
}
|
|
44
|
+
if (schema.enum?.length) {
|
|
45
|
+
return withNull(schema.enum.map((value) => JSON.stringify(value)).join(' | '), schema);
|
|
46
|
+
}
|
|
47
|
+
if (schema.oneOf?.length) {
|
|
48
|
+
return withNull(
|
|
49
|
+
schema.oneOf.map((item) => schemaToTs(spec, item, namedRefs)).join(' | '),
|
|
50
|
+
schema,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (schema.anyOf?.length) {
|
|
54
|
+
return withNull(
|
|
55
|
+
schema.anyOf.map((item) => schemaToTs(spec, item, namedRefs)).join(' | '),
|
|
56
|
+
schema,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (schema.allOf?.length) {
|
|
60
|
+
const merged = deref(spec, schema);
|
|
61
|
+
return schemaToTs(spec, { ...merged, allOf: undefined }, namedRefs);
|
|
62
|
+
}
|
|
63
|
+
const types = Array.isArray(schema.type) ? schema.type.filter((item) => item !== 'null') : [schema.type];
|
|
64
|
+
const type = types[0];
|
|
65
|
+
if (type === 'array' || schema.items) {
|
|
66
|
+
return withNull(`${schemaToTs(spec, schema.items, namedRefs)}[]`, schema);
|
|
67
|
+
}
|
|
68
|
+
if (type === 'integer' || type === 'number') return withNull('number', schema);
|
|
69
|
+
if (type === 'boolean') return withNull('boolean', schema);
|
|
70
|
+
if (type === 'string') return withNull('string', schema);
|
|
71
|
+
if (type === 'object' || schema.properties || schema.additionalProperties) {
|
|
72
|
+
const properties = schema.properties || {};
|
|
73
|
+
const required = new Set(schema.required || []);
|
|
74
|
+
const lines = Object.entries(properties).map(([key, value]) => {
|
|
75
|
+
const optional = required.has(key) ? '' : '?';
|
|
76
|
+
return ` ${key}${optional}: ${schemaToTs(spec, value, namedRefs)};`;
|
|
77
|
+
});
|
|
78
|
+
if (!lines.length && schema.additionalProperties) {
|
|
79
|
+
const valueType =
|
|
80
|
+
schema.additionalProperties === true
|
|
81
|
+
? 'unknown'
|
|
82
|
+
: schemaToTs(spec, schema.additionalProperties, namedRefs);
|
|
83
|
+
return withNull(`Record<string, ${valueType}>`, schema);
|
|
84
|
+
}
|
|
85
|
+
if (!lines.length) return withNull('Record<string, unknown>', schema);
|
|
86
|
+
return `{\n${lines.join('\n')}\n }`;
|
|
87
|
+
}
|
|
88
|
+
return withNull('unknown', schema);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function emitNamedType(spec, name, schema, namedRefs) {
|
|
92
|
+
const resolved = schema?.$ref ? pointerValue(spec, schema.$ref) : schema;
|
|
93
|
+
if (!resolved) return ` type ${name} = unknown;`;
|
|
94
|
+
if (resolved.enum?.length) {
|
|
95
|
+
return ` type ${name} = ${schemaToTs(spec, resolved, namedRefs)};`;
|
|
96
|
+
}
|
|
97
|
+
const body = schemaToTs(spec, { ...resolved, $ref: undefined }, namedRefs);
|
|
98
|
+
return ` type ${name} = ${body};`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function emitQueryType(spec, name, params, namedRefs) {
|
|
102
|
+
if (!params.length) return null;
|
|
103
|
+
const required = new Set(params.filter((param) => param.required).map((param) => param.name));
|
|
104
|
+
const lines = params.map((param) => {
|
|
105
|
+
const optional = required.has(param.name) ? '' : '?';
|
|
106
|
+
return ` ${param.name}${optional}: ${schemaToTs(spec, param.schema, namedRefs)};`;
|
|
107
|
+
});
|
|
108
|
+
return ` type ${name} = {\n${lines.join('\n')}\n };`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function paramType(spec, param, namedRefs) {
|
|
112
|
+
return schemaToTs(spec, param.schema, namedRefs);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = {
|
|
116
|
+
collectRefs,
|
|
117
|
+
schemaToTs,
|
|
118
|
+
emitNamedType,
|
|
119
|
+
emitQueryType,
|
|
120
|
+
paramType,
|
|
121
|
+
};
|
package/skills/README.md
CHANGED
|
@@ -6,76 +6,51 @@
|
|
|
6
6
|
|
|
7
7
|
## 推荐目录
|
|
8
8
|
|
|
9
|
-
以 `starscope-frontend` 为例:
|
|
10
|
-
|
|
11
9
|
```text
|
|
12
|
-
|
|
10
|
+
business-app/
|
|
11
|
+
├── AGENTS.md
|
|
13
12
|
├── .star-allinone.json
|
|
14
13
|
└── .agents/
|
|
15
14
|
├── skills/
|
|
16
15
|
│ ├── shared-api-to-service/
|
|
17
|
-
│ ├── shared-api-mock/
|
|
18
16
|
│ ├── shared-design-to-page/
|
|
19
|
-
│ ├── shared-verify/
|
|
20
17
|
│ ├── shared-review-and-submit/
|
|
21
18
|
│ ├── shared-publish-test/
|
|
22
|
-
│
|
|
19
|
+
│ ├── shared-project-conventions/ ← 无 SKILL.md,给入口读
|
|
20
|
+
│ ├── shared-i-have-adhd/ ← 无 SKILL.md,给入口读
|
|
21
|
+
│ └── custom-* ← 仅真正的业务特例
|
|
23
22
|
└── project/
|
|
24
23
|
├── conventions.md
|
|
25
24
|
├── review-rules.md
|
|
26
25
|
└── openapi.json
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
StarLink:
|
|
30
|
-
|
|
31
|
-
```text
|
|
32
|
-
starlink-frontend/
|
|
33
|
-
└── .agents/
|
|
34
|
-
└── skills/
|
|
35
|
-
├── shared-api-to-service/
|
|
36
|
-
├── shared-api-mock/
|
|
37
|
-
├── shared-design-to-page/
|
|
38
|
-
├── shared-verify/
|
|
39
|
-
├── shared-review-and-submit/
|
|
40
|
-
├── shared-publish-test/
|
|
41
|
-
└── custom-node-management/
|
|
42
|
-
```
|
|
43
|
-
|
|
44
28
|
命名约定:
|
|
45
29
|
|
|
46
30
|
```text
|
|
47
|
-
shared-*
|
|
48
|
-
custom-*
|
|
31
|
+
shared-* 公共内容,由 star-allinone 提供,经 CLI 同步后提交到业务仓库
|
|
32
|
+
custom-* 业务定制,由业务项目维护;禁止做成第二套页面/审查/单接口生成入口
|
|
49
33
|
```
|
|
50
34
|
|
|
51
|
-
|
|
35
|
+
Cursor / Codex 的常驻说明只放仓库根 `AGENTS.md`(模板见 `examples/AGENTS.md`)。项目差异放 `.agents/project/`。不要新增 `.cursor/rules`。
|
|
52
36
|
|
|
53
37
|
## npm 包的职责
|
|
54
38
|
|
|
55
|
-
`@mingfuyun/star-allinone`
|
|
39
|
+
`@mingfuyun/star-allinone` 只发布 **4 个用户入口**。其余是入口的 `references/` 或无 `SKILL.md` 的共享文件:
|
|
56
40
|
|
|
57
41
|
```text
|
|
58
42
|
@mingfuyun/star-allinone/
|
|
59
43
|
└── skills/
|
|
60
44
|
└── shared/
|
|
61
|
-
├── api-to-service/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
│ └── api-artifact-generation.md
|
|
66
|
-
├── api-mock/
|
|
67
|
-
├── design-to-page/ # page-conventions.md + overlays.md
|
|
45
|
+
├── api-to-service/ # 单接口;mock 规则在 references/
|
|
46
|
+
├── design-to-page/ # 页面;标准列表内部跑 gen page
|
|
47
|
+
├── review-and-submit/ # 审查并提交;步骤在 references/
|
|
48
|
+
├── publish-test/ # 测发
|
|
68
49
|
├── project-conventions/ # architecture / review-checklist / quality-checklist
|
|
69
|
-
|
|
70
|
-
├── review-and-submit/
|
|
71
|
-
├── impact-analysis/
|
|
72
|
-
├── ai-review/
|
|
73
|
-
├── commit-current-changes/
|
|
74
|
-
├── i-have-adhd/ # 同步为 shared-i-have-adhd;其他 shared skill 的用户输出格式
|
|
75
|
-
└── publish-test/ # 流水线 ID 从 .star-allinone.json 读取
|
|
50
|
+
└── i-have-adhd/ # 用户输出格式
|
|
76
51
|
```
|
|
77
52
|
|
|
78
|
-
|
|
53
|
+
公共入口写死两边已对齐的硬规则,例如:页面走 `MFRequest`、DTO 放 namespace typings、`MFProTable` + `ProForm`、弹层用 `BaseModal` / `CustomDrawer` / `HocModal`、`await` 必须 try/catch、禁止无说明的 `any`。
|
|
79
54
|
|
|
80
55
|
业务项目的 `.agents/project/` 只写差异:路径、权限体系、OpenAPI 位置、领域特例。项目文件可以补充,但不能削弱公共硬规则。
|
|
81
56
|
|
|
@@ -87,13 +62,7 @@ npm 包中的 skills/shared
|
|
|
87
62
|
业务项目 .agents/skills/shared-*
|
|
88
63
|
```
|
|
89
64
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```text
|
|
93
|
-
~/.codex/skills
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
也不会管理业务项目的 `custom-*` skill。
|
|
65
|
+
不会写入 `~/.codex/skills`,也不会管理业务项目的 `custom-*`。`skills list` 只列出带 `SKILL.md` 的入口。无 `SKILL.md` 的目录仍会同步,供入口阅读。
|
|
97
66
|
|
|
98
67
|
## CLI 使用方式
|
|
99
68
|
|
|
@@ -103,40 +72,11 @@ npm 包中的 skills/shared
|
|
|
103
72
|
pnpm exec star-allinone skills sync
|
|
104
73
|
```
|
|
105
74
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```text
|
|
109
|
-
当前项目/.agents/skills/shared-*/
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
例如:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
cd /path/to/starscope-frontend
|
|
116
|
-
pnpm exec star-allinone skills sync
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
结果:
|
|
120
|
-
|
|
121
|
-
```text
|
|
122
|
-
.agents/skills/
|
|
123
|
-
├── shared-api-to-service/
|
|
124
|
-
├── shared-api-mock/
|
|
125
|
-
├── shared-review-and-submit/
|
|
126
|
-
├── shared-publish-test/
|
|
127
|
-
└── custom-*/
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
公共 skill 的更新不会影响业务定制 skill。同步会整体替换 `shared-*` 目录,并删除包中已不存在的过期 `shared-*`,但不会改动 `custom-*`。
|
|
75
|
+
同步会整体替换 `shared-*` 目录,并删除包中已不存在的过期 `shared-*`,但不会改动 `custom-*`。
|
|
131
76
|
|
|
132
77
|
## 新增或修改公共 skill
|
|
133
78
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
```text
|
|
137
|
-
修改 star-allinone/skills/shared/api-to-service/SKILL.md
|
|
138
|
-
→ 发布新版本 @mingfuyun/star-allinone
|
|
139
|
-
```
|
|
79
|
+
管理者操作:修改 `star-allinone/skills/shared/<entry>/SKILL.md` → 发布新版本。
|
|
140
80
|
|
|
141
81
|
业务项目操作:
|
|
142
82
|
|
|
@@ -147,82 +87,20 @@ git add package.json pnpm-lock.yaml .agents/skills/shared-*
|
|
|
147
87
|
git commit -m "chore(skill): 更新公共 skill"
|
|
148
88
|
```
|
|
149
89
|
|
|
150
|
-
|
|
90
|
+
团队成员只需要 `git pull` 和 `pnpm install`。不要手动修改 `shared-*`。
|
|
151
91
|
|
|
152
|
-
|
|
153
|
-
git pull
|
|
154
|
-
pnpm install
|
|
155
|
-
```
|
|
92
|
+
## 新增或修改业务定制
|
|
156
93
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
## 新增或修改业务定制 skill
|
|
160
|
-
|
|
161
|
-
业务项目直接维护:
|
|
162
|
-
|
|
163
|
-
```text
|
|
164
|
-
.agents/skills/custom-device-management/SKILL.md
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
提交即可:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
git add .agents/skills/custom-device-management
|
|
171
|
-
git commit -m "feat(skill): 增加设备管理 skill"
|
|
172
|
-
```
|
|
94
|
+
`custom-*` 只用于真正的业务特例:领域不变量、全量契约脚本、度量。审查、提交、测发、单接口、页面生成都走公共入口。
|
|
173
95
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
审查、提交、测试环境发布、Mock 和 Service 生成都走公共 skill。只有流水线 ID 放在业务项目的 `.star-allinone.json`。`custom-*` 只用于真正的业务特例,例如设备管理或节点管理。
|
|
96
|
+
全量契约重建若必须留在 custom:加上 `disable-model-invocation: true`,在 `AGENTS.md` 写清要跑的命令,不要作为用户入口。度量类 custom 不得生成代码。
|
|
177
97
|
|
|
178
98
|
## 公共部分和业务定制组合
|
|
179
99
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
```text
|
|
183
|
-
.agents/skills/custom-device-service/SKILL.md
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
内容中引用公共 skill:
|
|
187
|
-
|
|
188
|
-
```md
|
|
189
|
-
---
|
|
190
|
-
name: custom-device-service
|
|
191
|
-
description: Generate StarScope device service code.
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
本任务需要结合公共 skill `shared-api-to-service` 执行。
|
|
195
|
-
|
|
196
|
-
先读取并遵循:
|
|
197
|
-
|
|
198
|
-
`.agents/skills/shared-api-to-service/SKILL.md`
|
|
199
|
-
|
|
200
|
-
再读取当前项目的:
|
|
201
|
-
|
|
202
|
-
- OpenAPI 文件
|
|
203
|
-
- Service 约定
|
|
204
|
-
- 项目类型和权限规则
|
|
205
|
-
|
|
206
|
-
只生成符合当前项目结构的设备相关 service。
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
公共 skill 负责通用流程,业务 skill 负责具体业务规则。
|
|
100
|
+
业务定制需要复用公共流程时,在 `custom-*` 里 **读取** 对应入口的 `SKILL.md`,不要再做一个可 `$` 调用的生成入口。领域规则示例见 `examples/skills/custom-domain-invariants/`。
|
|
210
101
|
|
|
211
102
|
## 项目配置
|
|
212
103
|
|
|
213
|
-
项目差异配置放在业务项目中,例如:
|
|
214
|
-
|
|
215
|
-
```text
|
|
216
|
-
starscope-frontend/
|
|
217
|
-
├── .star-allinone.json
|
|
218
|
-
└── .agents/
|
|
219
|
-
├── skills/
|
|
220
|
-
└── project/
|
|
221
|
-
├── conventions.md
|
|
222
|
-
├── review-rules.md
|
|
223
|
-
└── openapi.json
|
|
224
|
-
```
|
|
225
|
-
|
|
226
104
|
```json
|
|
227
105
|
{
|
|
228
106
|
"project": "starscope-frontend",
|
|
@@ -233,66 +111,45 @@ starscope-frontend/
|
|
|
233
111
|
}
|
|
234
112
|
```
|
|
235
113
|
|
|
236
|
-
|
|
114
|
+
完整示例见 `examples/projects/`。可选字段 `sharedSkills` 只限制用户入口;`project-conventions` 和 `i-have-adhd` 仍会同步。
|
|
237
115
|
|
|
238
|
-
|
|
239
|
-
{
|
|
240
|
-
"project": "starlink-frontend",
|
|
241
|
-
"publicSkillPrefix": "shared-",
|
|
242
|
-
"publishPipelineId": "5245265"
|
|
243
|
-
}
|
|
244
|
-
```
|
|
116
|
+
## 用户入口
|
|
245
117
|
|
|
246
|
-
|
|
118
|
+
对话里只点这些:
|
|
247
119
|
|
|
248
|
-
|
|
120
|
+
| 入口 | 用途 |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `shared-api-to-service` | 单个 `METHOD /path/` → 类型、`MFRequest`、默认 mock |
|
|
123
|
+
| `shared-design-to-page` | 页面:标准列表内部 `gen page`,其余按设计稿实现 |
|
|
124
|
+
| `shared-review-and-submit` | 审查并提交 |
|
|
125
|
+
| `shared-publish-test` | 测发 |
|
|
249
126
|
|
|
250
127
|
## 公共规则写在哪里
|
|
251
128
|
|
|
252
|
-
|
|
|
129
|
+
| 入口 | 规则位置 | 覆盖内容 |
|
|
253
130
|
| --- | --- | --- |
|
|
254
|
-
| `shared-api-to-service` | SKILL + `references/service-conventions.md`、`api-artifact-generation.md` | 指定 operation、`MFRequest
|
|
255
|
-
| `shared-
|
|
256
|
-
| `shared-
|
|
257
|
-
| `shared-
|
|
258
|
-
|
|
|
259
|
-
|
|
|
260
|
-
| `shared-ai-review` | SKILL | Hooks、契约、权限、性能、安全的 P0–P3 审查 |
|
|
261
|
-
| `shared-commit-current-changes` | SKILL | 确认门禁、中文 Conventional Commit、禁止未确认就提交 |
|
|
262
|
-
| `shared-review-and-submit` | SKILL | impact → verify → commit review 编排 |
|
|
263
|
-
| `shared-publish-test` | SKILL + `scripts/publish-current-branch.sh` | 云效测试流水线发布;只从配置读 `publishPipelineId`;git push 后不自动跑,需单独确认「推送流水线」 |
|
|
131
|
+
| `shared-api-to-service` | SKILL + `references/service-conventions.md`、`api-artifact-generation.md`、`mock.md` | 指定 operation、`MFRequest`、namespace 类型、snake_case、mock |
|
|
132
|
+
| `shared-design-to-page` | SKILL + `page-conventions.md`、`overlays.md`、`list-page-template.md` | 页面分层、标准列表 CLI、弹层合同 |
|
|
133
|
+
| `shared-review-and-submit` | SKILL + `impact-analysis.md`、`verify.md`、`ai-review.md`、`commit.md` | 影响分析 → 验证 → 确认后提交 |
|
|
134
|
+
| `shared-publish-test` | SKILL + `scripts/publish-current-branch.sh` | 云效测发;只读 `publishPipelineId` |
|
|
135
|
+
| (非入口)`shared-project-conventions` | `architecture.md`、`review-checklist.md`、`quality-checklist.md` | 架构与质量清单 |
|
|
136
|
+
| (非入口)`shared-i-have-adhd` | `i-have-adhd.md` | 用户输出格式 |
|
|
264
137
|
|
|
265
138
|
以下内容**不**写进公共 skill 源码:
|
|
266
139
|
|
|
267
|
-
- 流水线 ID
|
|
268
|
-
- OpenAPI
|
|
269
|
-
- 真正的业务特例:权限常量名、
|
|
140
|
+
- 流水线 ID:`.star-allinone.json` 的 `publishPipelineId`
|
|
141
|
+
- OpenAPI 快照:业务仓库数据文件
|
|
142
|
+
- 真正的业务特例:权限常量名、IP 校验、设备/节点领域规则
|
|
270
143
|
|
|
271
144
|
## 最终推荐流程
|
|
272
145
|
|
|
273
|
-
公共 skill:
|
|
274
|
-
|
|
275
146
|
```text
|
|
276
|
-
star-allinone 修改
|
|
277
|
-
→ 发布 npm
|
|
278
|
-
→ 业务项目升级 npm
|
|
279
|
-
→ 执行 skills sync
|
|
280
|
-
→ 提交 .agents/skills/shared-*
|
|
147
|
+
star-allinone 修改 → 发布 npm → 业务项目升级并 skills sync → 提交 .agents/skills/shared-*
|
|
281
148
|
```
|
|
282
149
|
|
|
283
|
-
业务定制 skill:
|
|
284
|
-
|
|
285
|
-
```text
|
|
286
|
-
业务项目直接新增或修改 custom-*
|
|
287
|
-
→ 提交业务项目
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
最终结构和责任边界:
|
|
291
|
-
|
|
292
150
|
```text
|
|
151
|
+
AGENTS.md
|
|
293
152
|
.agents/skills/
|
|
294
|
-
├── shared-* ← npm
|
|
153
|
+
├── shared-* ← npm 包同步
|
|
295
154
|
└── custom-* ← 业务项目自己维护
|
|
296
155
|
```
|
|
297
|
-
|
|
298
|
-
这比全局安装更适合团队协作,也比把公共 skill 藏在 `node_modules` 中更可靠,因为公共 skill 最终会进入业务项目仓库,团队成员拉取代码后即可直接使用。
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: {{sharedSkillName}}
|
|
3
|
-
description: Generate
|
|
3
|
+
description: User-facing. Generate or update one OpenAPI/Swagger operation as TypeScript types, an MFRequest method, and optional mock JSON. Use for a named METHOD /path or operationId. Do not use for full-spec domain regen.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# API to Service
|
|
7
7
|
|
|
8
|
+
User-facing entry for **one** `METHOD /path/` or `operationId`. Do not regenerate an entire Swagger/OpenAPI domain here. Full-spec rebuilds, if the project has one, live in that project's `custom-*` and are not this skill.
|
|
9
|
+
|
|
8
10
|
This skill is fully shared. Generate only the requested `METHOD /path/` or `operationId`. Do not guess undocumented fields or change unrelated endpoints.
|
|
9
11
|
|
|
10
12
|
Read before editing:
|
|
@@ -12,7 +14,7 @@ Read before editing:
|
|
|
12
14
|
1. `.star-allinone.json`
|
|
13
15
|
2. [references/service-conventions.md](references/service-conventions.md)
|
|
14
16
|
3. [references/api-artifact-generation.md](references/api-artifact-generation.md)
|
|
15
|
-
4.
|
|
17
|
+
4. [references/mock-conventions.md](references/mock-conventions.md) before producing JSON
|
|
16
18
|
|
|
17
19
|
OpenAPI lookup order:
|
|
18
20
|
|
|
@@ -25,12 +27,18 @@ OpenAPI lookup order:
|
|
|
25
27
|
## Workflow
|
|
26
28
|
|
|
27
29
|
1. Resolve one exact operation. If a path has multiple methods and intent is unclear, ask for the method. Never infer a destructive method.
|
|
28
|
-
2.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
2. From the business project root, generate the artifacts with the CLI. Do not hand-write types or `MFRequest` methods when the spec exists:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm exec star-allinone gen service --operation "GET /api/v1/devices/"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Use `--spec <file>` when `.star-allinone.json` has no `openapi`. Use `--domain <Name>` when the folder cannot be inferred. Use `--mock-file` only when the user asked for a mock file; otherwise keep the default conversation JSON.
|
|
37
|
+
|
|
38
|
+
3. If the CLI reports reuse, keep the existing method. If it reports a conflict, stop and show the diff; do not overwrite.
|
|
39
|
+
4. Review the generated types against the spec: snake_case, optionality, `| null`, unwrapped `data`, and exact method/path.
|
|
40
|
+
5. Produce extra empty or error mocks only when requested, using [references/mock.md](references/mock.md).
|
|
41
|
+
6. Verify formatting, TypeScript, JSON parsing, exact method/path, and a focused diff.
|
|
34
42
|
|
|
35
43
|
## Hard rules
|
|
36
44
|
|
|
@@ -45,11 +53,11 @@ OpenAPI lookup order:
|
|
|
45
53
|
|
|
46
54
|
```bash
|
|
47
55
|
pnpm exec prettier --check <changed-service-and-json-files>
|
|
48
|
-
pnpm
|
|
56
|
+
pnpm typecheck
|
|
49
57
|
```
|
|
50
58
|
|
|
51
59
|
Parse changed JSON files. Search generated names, operationId, and exact API paths for omissions and collisions. Run `pnpm lint` for broad service changes. Cite the OpenAPI path, method, operationId, and schema names in the handoff.
|
|
52
60
|
|
|
53
61
|
## User-facing output
|
|
54
62
|
|
|
55
|
-
Read and apply `.agents/skills/shared-i-have-adhd/
|
|
63
|
+
Read and apply `.agents/skills/shared-i-have-adhd/i-have-adhd.md` to every response this skill sends to the user.
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: {{sharedSkillName}}
|
|
3
|
-
description: Generate deterministic API mock responses matching the active frontend project's OpenAPI contract and service types. Use when the user asks for JSON fixtures, proxy-ready mock data, empty or error scenarios, or mock files for a specified endpoint.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
1
|
# API Mock
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
`shared-api-to-service` reads this file when extra mock scenarios are needed. Generating types or `MFRequest` methods is not this file's job.
|
|
4
|
+
|
|
5
|
+
Read [mock-conventions.md](mock-conventions.md), `.star-allinone.json`, the related service types, and the OpenAPI file from `openapi` in `.star-allinone.json` (or the document provided in this conversation).
|
|
9
6
|
|
|
10
7
|
If the service contract is missing, first follow `.agents/skills/shared-api-to-service/SKILL.md`.
|
|
11
8
|
|
|
@@ -21,7 +18,3 @@ If the service contract is missing, first follow `.agents/skills/shared-api-to-s
|
|
|
21
18
|
## Handoff
|
|
22
19
|
|
|
23
20
|
For every endpoint, report HTTP method, path, scenario label, and one strict parseable JSON block. If files were written, list the paths and confirm they parse as JSON.
|
|
24
|
-
|
|
25
|
-
## User-facing output
|
|
26
|
-
|
|
27
|
-
Read and apply `.agents/skills/shared-i-have-adhd/SKILL.md` to every response this skill sends to the user.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: {{sharedSkillName}}
|
|
3
|
-
description:
|
|
3
|
+
description: User-facing. Generate or update a page. Standard table + drawer + confirm lists use star-allinone gen page inside this skill. Use for Figma, screenshots, UI specs, or CRUD list pages.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Design to Page
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
User-facing entry for **pages**. Do not send the user to another page skill.
|
|
9
|
+
|
|
10
|
+
If the request is a standard management list (table + query + drawer form + confirm), run the CLI in the standard-list path below. Dashboards, iframes, and one-off layouts stay on the design path.
|
|
9
11
|
|
|
10
12
|
Before implementation, read:
|
|
11
13
|
|
|
@@ -18,13 +20,47 @@ If `.agents/project/conventions.md` exists, use it only for extra paths.
|
|
|
18
20
|
|
|
19
21
|
Inspect the nearest existing page of the same type before proposing files.
|
|
20
22
|
|
|
21
|
-
##
|
|
23
|
+
## Standard list
|
|
24
|
+
|
|
25
|
+
When the page is table + query + drawer + confirm, collect any missing item then generate. Do not guess the file tree.
|
|
26
|
+
|
|
27
|
+
Required inputs:
|
|
28
|
+
|
|
29
|
+
- Feature folder (`src/pages/<Feature>`)
|
|
30
|
+
- Route path and menu title
|
|
31
|
+
- List operation (`METHOD /path/` or `operationId`)
|
|
32
|
+
- Optional create / update / delete operations
|
|
33
|
+
- Optional permission codes for create / edit / delete
|
|
34
|
+
|
|
35
|
+
1. Run the CLI from the business project root:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm exec star-allinone gen page \
|
|
39
|
+
--feature <Feature> \
|
|
40
|
+
--route /path \
|
|
41
|
+
--title <中文标题> \
|
|
42
|
+
--list-operation "GET /api/v1/resource/" \
|
|
43
|
+
--create-operation "POST /api/v1/resource/" \
|
|
44
|
+
--update-operation "PATCH /api/v1/resource/{id}/" \
|
|
45
|
+
--delete-operation "DELETE /api/v1/resource/{id}/"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Add `--permission-create`, `--permission-edit`, `--permission-delete` when codes are known.
|
|
49
|
+
|
|
50
|
+
2. If only services are missing, run `pnpm exec star-allinone gen service --operation "METHOD /path/"` first. Follow `.agents/skills/shared-api-to-service/SKILL.md`.
|
|
51
|
+
3. Fill generated placeholders using [references/list-page-template.md](references/list-page-template.md): columns, form fields, rowKey, permission constants, and pagination adapter (`results/count` vs `list/total`).
|
|
52
|
+
4. If `src/components/Page/Container/config.tsx` exists, register the new page as a tab after generating the standalone files. Do not invent a second page shell.
|
|
53
|
+
5. Do not overwrite existing page files. Tell the user the CLI refused, then edit in place.
|
|
54
|
+
|
|
55
|
+
## Design path
|
|
56
|
+
|
|
57
|
+
For non-standard layouts:
|
|
22
58
|
|
|
23
59
|
1. List visible states: default, loading, empty, error, disabled, overflow, permission, and narrow-screen.
|
|
24
60
|
2. Resolve ambiguities that affect APIs, route ownership, permissions, or component boundaries. For minor visual gaps, follow the closest precedent and state the assumption.
|
|
25
61
|
3. Write a short implementation contract: route, sections, query fields, columns, actions, APIs, permissions, states, and files.
|
|
26
62
|
4. Implement the smallest complete vertical slice. Keep columns and actions outside render. Keep overlay concerns in focused components.
|
|
27
|
-
5. API-backed pages include types, `MFRequest` methods, aggregate exports, and page consumption in the same change. Use `.agents/skills/shared-api-to-service/SKILL.md` for missing services. Use `.agents/skills/shared-api-mock
|
|
63
|
+
5. API-backed pages include types, `MFRequest` methods, aggregate exports, and page consumption in the same change. Use `.agents/skills/shared-api-to-service/SKILL.md` for missing services. Use `.agents/skills/shared-api-to-service/references/mock.md` for extra mock scenarios. Do not embed production fake data.
|
|
28
64
|
6. Compare desktop and narrow layouts against the design. Fix structure and spacing before decoration.
|
|
29
65
|
7. Run focused verification. Do not claim visual fidelity without inspecting the rendered page.
|
|
30
66
|
|
|
@@ -33,8 +69,11 @@ Inspect the nearest existing page of the same type before proposing files.
|
|
|
33
69
|
- React function components, TypeScript, Ant Design 5, Pro Components, Less.
|
|
34
70
|
- `ProForm` for business forms. `MFProTable` for management lists.
|
|
35
71
|
- Overlays from `@mingfuyun/star-allinone`: `CustomDrawer`, `BaseModal`, `HocModal`.
|
|
72
|
+
- Pages consume `import Service from '@/services'` only.
|
|
73
|
+
- Keep columns and toolbar builders in `const.tsx`. Empty cells render as `-`.
|
|
36
74
|
- Every `await` uses `try-catch`; loading restores in `finally`; `validateFields()` failures are logged and stop the request.
|
|
37
75
|
- Mutations guard duplicate submit, show feedback, and reload affected lists.
|
|
76
|
+
- Do not use `Modal.confirm` or feature-level Ant Design `Modal` / `Drawer` shells.
|
|
38
77
|
- Do not add a UI library, state library, or CSS-in-JS system without approval.
|
|
39
78
|
- Do not refactor unrelated code.
|
|
40
79
|
|
|
@@ -42,11 +81,11 @@ Inspect the nearest existing page of the same type before proposing files.
|
|
|
42
81
|
|
|
43
82
|
```bash
|
|
44
83
|
pnpm exec prettier --check <changed-files>
|
|
45
|
-
pnpm
|
|
84
|
+
pnpm typecheck
|
|
46
85
|
```
|
|
47
86
|
|
|
48
87
|
Run `pnpm lint` for broad or shared changes. Run the project's documented build command when routes, entry, or multiple pages change.
|
|
49
88
|
|
|
50
89
|
## User-facing output
|
|
51
90
|
|
|
52
|
-
Read and apply `.agents/skills/shared-i-have-adhd/
|
|
91
|
+
Read and apply `.agents/skills/shared-i-have-adhd/i-have-adhd.md` to every response this skill sends to the user.
|