@mingfuyun/star-allinone 0.1.6 → 0.1.8

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.
Files changed (29) hide show
  1. package/README.md +111 -1
  2. package/dist/components/BaseModal/index.d.ts +6 -6
  3. package/dist/components/BaseModal/index.d.ts.map +1 -1
  4. package/dist/components/CustomDrawer/index.d.ts +5 -5
  5. package/dist/components/CustomDrawer/index.d.ts.map +1 -1
  6. package/dist/index.esm.js +1 -1
  7. package/dist/index.js +1 -1
  8. package/package.json +9 -2
  9. package/scripts/cli.js +179 -0
  10. package/skills/README.md +297 -0
  11. package/skills/shared/ai-review/SKILL.md +29 -0
  12. package/skills/shared/api-mock/SKILL.md +23 -0
  13. package/skills/shared/api-mock/references/mock-conventions.md +90 -0
  14. package/skills/shared/api-to-service/SKILL.md +51 -0
  15. package/skills/shared/api-to-service/references/api-artifact-generation.md +70 -0
  16. package/skills/shared/api-to-service/references/service-conventions.md +89 -0
  17. package/skills/shared/commit-current-changes/SKILL.md +63 -0
  18. package/skills/shared/design-to-page/SKILL.md +48 -0
  19. package/skills/shared/design-to-page/references/overlays.md +73 -0
  20. package/skills/shared/design-to-page/references/page-conventions.md +85 -0
  21. package/skills/shared/impact-analysis/SKILL.md +30 -0
  22. package/skills/shared/project-conventions/SKILL.md +30 -0
  23. package/skills/shared/project-conventions/references/architecture.md +43 -0
  24. package/skills/shared/project-conventions/references/quality-checklist.md +19 -0
  25. package/skills/shared/project-conventions/references/review-checklist.md +42 -0
  26. package/skills/shared/publish-test/SKILL.md +46 -0
  27. package/skills/shared/publish-test/scripts/publish-current-branch.sh +174 -0
  28. package/skills/shared/review-and-submit/SKILL.md +75 -0
  29. package/skills/shared/verify/SKILL.md +44 -0
@@ -0,0 +1,297 @@
1
+ # Skills
2
+
3
+ 公共 skill 和业务定制 skill 都保存在业务项目仓库中,但通过目录命名和来源规则明确区分。
4
+
5
+ 不使用 Codex 全局目录 `~/.codex/skills`,也不要求团队成员拥有 `star-allinone` 源码。
6
+
7
+ ## 推荐目录
8
+
9
+ 以 `starscope-frontend` 为例:
10
+
11
+ ```text
12
+ starscope-frontend/
13
+ ├── .star-allinone.json
14
+ └── .agents/
15
+ ├── skills/
16
+ │ ├── shared-api-to-service/
17
+ │ ├── shared-api-mock/
18
+ │ ├── shared-design-to-page/
19
+ │ ├── shared-verify/
20
+ │ ├── shared-review-and-submit/
21
+ │ ├── shared-publish-test/
22
+ │ └── custom-device-management/
23
+ └── project/
24
+ ├── conventions.md
25
+ ├── review-rules.md
26
+ └── openapi.json
27
+ ```
28
+
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
+ 命名约定:
45
+
46
+ ```text
47
+ shared-* 公共 skill,由 star-allinone 提供,经 CLI 同步后提交到业务仓库
48
+ custom-* 业务定制 skill,由业务项目维护
49
+ ```
50
+
51
+ 这样所有 skill 都在业务项目中,Codex 可以直接发现;同时通过名称可以清楚区分来源。
52
+
53
+ ## npm 包的职责
54
+
55
+ `@mingfuyun/star-allinone` 包中保存公共 skill 源文件。每个 skill 包含可执行规则,细节放在同目录 `references/`:
56
+
57
+ ```text
58
+ @mingfuyun/star-allinone/
59
+ └── skills/
60
+ └── shared/
61
+ ├── api-to-service/
62
+ │ ├── SKILL.md
63
+ │ └── references/
64
+ │ ├── service-conventions.md
65
+ │ └── api-artifact-generation.md
66
+ ├── api-mock/
67
+ ├── design-to-page/ # page-conventions.md + overlays.md
68
+ ├── project-conventions/ # architecture / review-checklist / quality-checklist
69
+ ├── verify/
70
+ ├── review-and-submit/
71
+ ├── impact-analysis/
72
+ ├── ai-review/
73
+ ├── commit-current-changes/
74
+ └── publish-test/ # 流水线 ID 从 .star-allinone.json 读取
75
+ ```
76
+
77
+ 公共 skill 写死两边已对齐的硬规则,例如:页面走 `MFRequest`、DTO 放 namespace typings、`MFProTable` + `ProForm`、弹层用 `BaseModal` / `CustomDrawer` / `HocModal`、`await` 必须 try/catch、禁止无说明的 `any`。
78
+
79
+ 业务项目的 `.agents/project/` 只写差异:路径、权限体系、OpenAPI 位置、领域特例。项目文件可以补充,但不能削弱公共硬规则。
80
+
81
+ CLI 只做同步:
82
+
83
+ ```text
84
+ npm 包中的 skills/shared
85
+ ↓
86
+ 业务项目 .agents/skills/shared-*
87
+ ```
88
+
89
+ 不会写入:
90
+
91
+ ```text
92
+ ~/.codex/skills
93
+ ```
94
+
95
+ 也不会管理业务项目的 `custom-*` skill。
96
+
97
+ ## CLI 使用方式
98
+
99
+ 在业务项目目录执行:
100
+
101
+ ```bash
102
+ pnpm exec star-allinone skills sync
103
+ ```
104
+
105
+ CLI 根据当前业务项目的 `.star-allinone.json`,直接将公共 skill 写入当前项目:
106
+
107
+ ```text
108
+ 当前项目/.agents/skills/shared-*/
109
+ ```
110
+
111
+ 例如:
112
+
113
+ ```bash
114
+ cd /path/to/starscope-frontend
115
+ pnpm exec star-allinone skills sync
116
+ ```
117
+
118
+ 结果:
119
+
120
+ ```text
121
+ .agents/skills/
122
+ ├── shared-api-to-service/
123
+ ├── shared-api-mock/
124
+ ├── shared-review-and-submit/
125
+ ├── shared-publish-test/
126
+ └── custom-*/
127
+ ```
128
+
129
+ 公共 skill 的更新不会影响业务定制 skill。同步会整体替换 `shared-*` 目录,并删除包中已不存在的过期 `shared-*`,但不会改动 `custom-*`。
130
+
131
+ ## 新增或修改公共 skill
132
+
133
+ 管理者操作:
134
+
135
+ ```text
136
+ 修改 star-allinone/skills/shared/api-to-service/SKILL.md
137
+ → 发布新版本 @mingfuyun/star-allinone
138
+ ```
139
+
140
+ 业务项目操作:
141
+
142
+ ```bash
143
+ pnpm update @mingfuyun/star-allinone
144
+ pnpm exec star-allinone skills sync
145
+ git add package.json pnpm-lock.yaml .agents/skills/shared-*
146
+ git commit -m "chore(skill): 更新公共 skill"
147
+ ```
148
+
149
+ 团队成员只需要:
150
+
151
+ ```bash
152
+ git pull
153
+ pnpm install
154
+ ```
155
+
156
+ 由于公共 skill 已经提交到业务仓库,所以团队成员不需要手动安装全局 skill,也不需要拥有 `star-allinone` 源码。
157
+
158
+ ## 新增或修改业务定制 skill
159
+
160
+ 业务项目直接维护:
161
+
162
+ ```text
163
+ .agents/skills/custom-device-management/SKILL.md
164
+ ```
165
+
166
+ 提交即可:
167
+
168
+ ```bash
169
+ git add .agents/skills/custom-device-management
170
+ git commit -m "feat(skill): 增加设备管理 skill"
171
+ ```
172
+
173
+ 不需要修改 `star-allinone`,也不需要重新发布 npm。
174
+
175
+ 审查、提交、测试环境发布、Mock 和 Service 生成都走公共 skill。只有流水线 ID 放在业务项目的 `.star-allinone.json`。`custom-*` 只用于真正的业务特例,例如设备管理或节点管理。
176
+
177
+ ## 公共部分和业务定制组合
178
+
179
+ 例如业务定制 skill 需要复用公共 API 生成流程:
180
+
181
+ ```text
182
+ .agents/skills/custom-device-service/SKILL.md
183
+ ```
184
+
185
+ 内容中引用公共 skill:
186
+
187
+ ```md
188
+ ---
189
+ name: custom-device-service
190
+ description: Generate StarScope device service code.
191
+ ---
192
+
193
+ 本任务需要结合公共 skill `shared-api-to-service` 执行。
194
+
195
+ 先读取并遵循:
196
+
197
+ `.agents/skills/shared-api-to-service/SKILL.md`
198
+
199
+ 再读取当前项目的:
200
+
201
+ - OpenAPI 文件
202
+ - Service 约定
203
+ - 项目类型和权限规则
204
+
205
+ 只生成符合当前项目结构的设备相关 service。
206
+ ```
207
+
208
+ 公共 skill 负责通用流程,业务 skill 负责具体业务规则。
209
+
210
+ ## 项目配置
211
+
212
+ 项目差异配置放在业务项目中,例如:
213
+
214
+ ```text
215
+ starscope-frontend/
216
+ ├── .star-allinone.json
217
+ └── .agents/
218
+ ├── skills/
219
+ └── project/
220
+ ├── conventions.md
221
+ ├── review-rules.md
222
+ └── openapi.json
223
+ ```
224
+
225
+ ```json
226
+ {
227
+ "project": "starscope-frontend",
228
+ "publicSkillPrefix": "shared-",
229
+ "serviceDir": "src/services",
230
+ "openapi": ".agents/project/openapi.json",
231
+ "publishPipelineId": "5108336"
232
+ }
233
+ ```
234
+
235
+ StarLink 使用:
236
+
237
+ ```json
238
+ {
239
+ "project": "starlink-frontend",
240
+ "publicSkillPrefix": "shared-",
241
+ "publishPipelineId": "5245265"
242
+ }
243
+ ```
244
+
245
+ 完整示例见 `examples/projects/`。
246
+
247
+ 可选字段 `sharedSkills` 用于只同步部分公共 skill;省略时同步 `skills/shared` 下的全部公共 skill。
248
+
249
+ ## 公共规则写在哪里
250
+
251
+ | Skill | 规则位置 | 覆盖内容 |
252
+ | --- | --- | --- |
253
+ | `shared-api-to-service` | SKILL + `references/service-conventions.md`、`api-artifact-generation.md` | 指定 operation、`MFRequest` 映射、namespace 类型、snake_case、schema 闭包、禁止改 transport |
254
+ | `shared-api-mock` | SKILL + `references/mock-conventions.md` | 对话 JSON 默认、完整响应信封、分页/空列表/错误场景、禁止 handler 和随机数 |
255
+ | `shared-design-to-page` | SKILL + `references/page-conventions.md`、`overlays.md` | 页面分层、`MFProTable`、`ProForm`、权限、异步、`HocModal` 弹层合同 |
256
+ | `shared-project-conventions` | SKILL + `references/architecture.md`、`review-checklist.md`、`quality-checklist.md` | 架构边界、质量禁令、审查清单;其他 skill 会引用这些文件 |
257
+ | `shared-verify` | SKILL | 成套产物检查、await/loading/弹层、验证命令和报告格式 |
258
+ | `shared-impact-analysis` | SKILL | 只读影响分类和回归路径 |
259
+ | `shared-ai-review` | SKILL | Hooks、契约、权限、性能、安全的 P0–P3 审查 |
260
+ | `shared-commit-current-changes` | SKILL | 确认门禁、中文 Conventional Commit、禁止未确认就提交 |
261
+ | `shared-review-and-submit` | SKILL | impact → verify → commit review 编排 |
262
+ | `shared-publish-test` | SKILL + `scripts/publish-current-branch.sh` | 云效测试流水线发布;只从 `.star-allinone.json` 读取 `publishPipelineId` |
263
+
264
+ 以下内容**不**写进公共 skill 源码:
265
+
266
+ - 流水线 ID:放在业务项目 `.star-allinone.json` 的 `publishPipelineId`
267
+ - OpenAPI 快照:业务仓库数据文件,路径由 `.star-allinone.json` 的 `openapi` 指向
268
+ - 真正的业务特例:权限常量名、Clear Cache 登记、IP 校验、设备/节点领域规则,放 `custom-*`
269
+
270
+ ## 最终推荐流程
271
+
272
+ 公共 skill:
273
+
274
+ ```text
275
+ star-allinone 修改
276
+ → 发布 npm
277
+ → 业务项目升级 npm
278
+ → 执行 skills sync
279
+ → 提交 .agents/skills/shared-*
280
+ ```
281
+
282
+ 业务定制 skill:
283
+
284
+ ```text
285
+ 业务项目直接新增或修改 custom-*
286
+ → 提交业务项目
287
+ ```
288
+
289
+ 最终结构和责任边界:
290
+
291
+ ```text
292
+ .agents/skills/
293
+ ├── shared-* ← npm 包同步,不能在业务项目直接维护
294
+ └── custom-* ← 业务项目自己维护
295
+ ```
296
+
297
+ 这比全局安装更适合团队协作,也比把公共 skill 藏在 `node_modules` 中更可靠,因为公共 skill 最终会进入业务项目仓库,团队成员拉取代码后即可直接使用。
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: {{sharedSkillName}}
3
+ description: Review frontend changes for correctness, API and permission contracts, React lifecycle, performance, maintainability, security, accessibility, and test gaps. Use for a standalone review without commit. Do not modify files.
4
+ ---
5
+
6
+ # AI Code Review
7
+
8
+ This skill is fully shared. Review the current diff plus relevant callers and types. Before reviewing, read:
9
+
10
+ 1. `.agents/skills/shared-project-conventions/references/review-checklist.md`
11
+ 2. `.agents/skills/shared-project-conventions/references/quality-checklist.md`
12
+
13
+ Do not require a project-local review-rules file. If `.agents/project/review-rules.md` exists, apply extra domain checks only; do not weaken shared hard rules.
14
+
15
+ ## Required checks
16
+
17
+ 1. React Hooks: stale closures, incomplete dependencies, request races, updates after unmount, unnecessary rerenders.
18
+ 2. API contracts: method/path/params, response unwrapping, pagination, nullability, enum drift, error handling, DTO mismatch.
19
+ 3. Permissions: route access, button visibility, mutation authorization, client-only enforcement.
20
+ 4. Forms/tables: validation, reset, duplicate submit, refresh after mutation, column-state, long text, empty/error.
21
+ 5. Performance: eager `xlsx`/editor imports, duplicate libraries, large lists without virtualization, unstable columns/handlers, avoidable requests.
22
+ 6. Security/privacy: tokens, user data, URLs, unsafe HTML, sensitive logs, environment config.
23
+ 7. Tests and accessibility: critical paths, failure states, keyboard labels, disabled/loading semantics.
24
+
25
+ ## Output
26
+
27
+ Lead with findings ordered `[P0]`–`[P3]`, with file and line. Separate blocking issues from recommendations. Do not report style preferences as bugs.
28
+
29
+ If none, write `No issues found.` Always include validation performed and gaps. Do not modify files unless the user explicitly asks for fixes.
@@ -0,0 +1,23 @@
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
+ # API Mock
7
+
8
+ This skill is fully shared. Read [references/mock-conventions.md](references/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
+
10
+ If the service contract is missing, first follow `.agents/skills/shared-api-to-service/SKILL.md`.
11
+
12
+ ## Hard rules
13
+
14
+ - OpenAPI and existing namespace types are authoritative. Do not invent undocumented fields.
15
+ - Default output is labeled conversation JSON. Write `mock/<api-path>/<method>.json` only when the user explicitly asks for files.
16
+ - Keep the complete backend envelope. Service callers see unwrapped `data`; mocks must not drop `code` / `message` / `data`.
17
+ - Preserve snake_case, required fields, enums, nullability, and pagination totals.
18
+ - Never add runtime handlers, `defineMock`, Faker, current timestamps, or unseeded randomness without an explicit request.
19
+ - Cover requested scenarios only. Success is the default; empty, overflow, zero, validation, and permission cases need an explicit ask or a documented contract.
20
+
21
+ ## Handoff
22
+
23
+ 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.
@@ -0,0 +1,90 @@
1
+ # Mock Conventions
2
+
3
+ Default output is conversation JSON. Do not create files, Umi routes, JavaScript, TypeScript, handlers, or server configuration unless the user explicitly asks for files.
4
+
5
+ ## Conversation output
6
+
7
+ Label each response with HTTP method, API path, and scenario, then provide one strict JSON code block.
8
+
9
+ ```text
10
+ GET /api/v1/devices/ — success
11
+ ```
12
+
13
+ Rules:
14
+
15
+ - Return the default success scenario unless the user requests another scenario.
16
+ - Use separate labeled JSON blocks for success, empty, validation error, or permission error responses.
17
+ - Preserve OpenAPI placeholders such as `{id}` in the label while using realistic concrete IDs in response data.
18
+ - Do not mention an output filename unless writing a file was requested.
19
+
20
+ When files are requested, write pure JSON at `mock/<api-path>/<method>.json`. Never generate `defineMock`, Umi imports, handlers, Faker, current timestamps, or unseeded randomness.
21
+
22
+ ## Response shapes
23
+
24
+ Use the actual OpenAPI response schema even when it differs from these common envelopes.
25
+
26
+ Ordinary success:
27
+
28
+ ```json
29
+ {
30
+ "code": 0,
31
+ "message": "success",
32
+ "data": {
33
+ "id": "device-001",
34
+ "hostname": "edge-shanghai-001"
35
+ }
36
+ }
37
+ ```
38
+
39
+ Paginated list. Follow the nearest domain; common shapes are `{ results, count }` or `{ list, total }`:
40
+
41
+ ```json
42
+ {
43
+ "code": 0,
44
+ "message": "success",
45
+ "data": {
46
+ "results": [
47
+ {
48
+ "id": "device-001",
49
+ "hostname": "edge-shanghai-001"
50
+ }
51
+ ],
52
+ "count": 1
53
+ }
54
+ }
55
+ ```
56
+
57
+ Business error:
58
+
59
+ ```json
60
+ {
61
+ "code": 400,
62
+ "message": "参数校验失败",
63
+ "data": {
64
+ "hostname": ["该字段不能为空"]
65
+ }
66
+ }
67
+ ```
68
+
69
+ `MFRequest` unwraps `data` for service callers. Mock JSON must keep the complete backend envelope.
70
+
71
+ ## Scenario coverage
72
+
73
+ - Default successful detail or operation response.
74
+ - Normal list containing representative status and enum variants.
75
+ - Empty list when requested: empty collection and matching total/count `0`.
76
+ - Very long names and remarks for overflow testing.
77
+ - Zero numeric values so UI code does not confuse zero with missing data.
78
+ - Nullable and optional fields only where the contract permits them.
79
+ - Validation and permission errors only when requested or documented.
80
+
81
+ Static JSON cannot implement pagination, filtering, mutation continuity, or upload parsing. Represent those as separate labeled responses.
82
+
83
+ ## Contract checks
84
+
85
+ 1. Copy the exact path and method from OpenAPI and the service module.
86
+ 2. Resolve every `$ref` used by the selected response schema.
87
+ 3. Include every required property and preserve snake_case.
88
+ 4. Keep enum values, nullability, number/string types, and nested arrays consistent.
89
+ 5. Keep pagination totals consistent with the represented collection unless the fixture intentionally shows another page.
90
+ 6. Ensure every fenced JSON block is strict, parseable JSON: double-quoted keys and strings, no comments, no trailing commas.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: {{sharedSkillName}}
3
+ description: Generate frontend TypeScript API types, MFRequest service methods, aggregate exports, and contract-aligned mock artifacts for an explicitly selected API operation. Use when the user names an endpoint or operationId and asks to generate or update service, types, or mock data.
4
+ ---
5
+
6
+ # API to Service
7
+
8
+ This skill is fully shared. Generate only the requested `METHOD /path/` or `operationId`. Do not guess undocumented fields or change unrelated endpoints.
9
+
10
+ Read before editing:
11
+
12
+ 1. `.star-allinone.json`
13
+ 2. [references/service-conventions.md](references/service-conventions.md)
14
+ 3. [references/api-artifact-generation.md](references/api-artifact-generation.md)
15
+ 4. `.agents/skills/shared-api-mock/references/mock-conventions.md` before producing JSON
16
+
17
+ OpenAPI lookup order:
18
+
19
+ 1. `openapi` in `.star-allinone.json`
20
+ 2. A Swagger/OpenAPI file the user provided in this conversation
21
+ 3. Nearest existing domain `typings.d.ts` plus the live endpoint, reported as incomplete if no schema exists
22
+
23
+ `serviceDir` defaults to `src/services` unless `.star-allinone.json` sets it.
24
+
25
+ ## Workflow
26
+
27
+ 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. Recursively resolve parameters, request body, responses, and local `$ref`s. Neighboring methods that share a path are out of scope.
29
+ 3. Build the target matrix in `api-artifact-generation.md`. Compare existing types, methods, exports, and mocks. Classify create / update / reuse / conflict.
30
+ 4. Report contract conflicts before overwriting deployed behavior.
31
+ 5. Update `src/services/<Domain>/typings.d.ts`, the thin `MFRequest` method, and `src/services/index.ts` when the domain export is missing.
32
+ 6. Produce the default successful JSON mock. Add empty or error variants only when requested.
33
+ 7. Verify formatting, TypeScript, JSON parsing, exact method/path, and a focused diff.
34
+
35
+ ## Hard rules
36
+
37
+ - Preserve backend snake_case, documented optionality, and `| null` nullability.
38
+ - Type callers against unwrapped `data`. Do not model the transport envelope inside `T`.
39
+ - Prefer named types. Do not use `Record<string, any>` or unexplained `any`.
40
+ - Do not modify `src/services/request.tsx` for one endpoint without explicit approval.
41
+ - Do not generate pages, hooks, or extra mock scenarios unless requested.
42
+ - Never refresh a checked-in OpenAPI snapshot with `cp` or full-file replacement.
43
+
44
+ ## Verification
45
+
46
+ ```bash
47
+ pnpm exec prettier --check <changed-service-and-json-files>
48
+ pnpm exec tsc --noEmit
49
+ ```
50
+
51
+ 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.
@@ -0,0 +1,70 @@
1
+ # Specified API Artifact Generation
2
+
3
+ ## Accepted selectors
4
+
5
+ Resolve a request using one of these forms:
6
+
7
+ ```text
8
+ GET /api/v1/devices/
9
+ PATCH /api/v1/devices/{id}/
10
+ operationId: api_v1_devices_list
11
+ ```
12
+
13
+ Preserve the documented path, including placeholders and trailing slash. Never infer a destructive method.
14
+
15
+ If a path has multiple methods and intent does not identify one, stop and request the method.
16
+
17
+ ## Target matrix
18
+
19
+ Before editing, establish this matrix for every requested operation:
20
+
21
+ | Field | Value |
22
+ | ---------------- | -------------------------------------------------- |
23
+ | Method and path | Exact OpenAPI operation |
24
+ | operationId | Documented identifier |
25
+ | Domain | Existing service domain or tag-derived domain |
26
+ | Parameters | Path, query, header, and cookie schemas |
27
+ | Request body | Content type and resolved schema |
28
+ | Success response | Selected status, content type, and resolved schema |
29
+ | Error responses | Only those needed by the requested artifacts |
30
+ | Service method | Existing or proposed public method name |
31
+ | Types | Existing types to reuse and new types to create |
32
+ | Mock output | Conversation JSON, or `mock/<api-path>/<method>.json` when files are requested |
33
+
34
+ ## Default artifacts
35
+
36
+ Unless the user narrows the scope, generating `GET /api/v1/devices/` means:
37
+
38
+ - Request, query, and path-parameter types.
39
+ - Response, item, detail, pagination, enum, and nested object types required by that operation.
40
+ - One thin `MFRequest` method.
41
+ - Domain aggregate export when missing.
42
+ - One deterministic successful JSON response.
43
+
44
+ Do not generate a page, hook, model, component, test server, or extra mock scenario unless requested.
45
+
46
+ ## Schema closure
47
+
48
+ Starting from parameters, request bodies, and selected responses:
49
+
50
+ 1. Collect every local `$ref`.
51
+ 2. Read the referenced component schema.
52
+ 3. Repeat for nested properties, items, `allOf`, `oneOf`, and `anyOf`.
53
+ 4. Stop only when all leaves are primitive, inline, or unsupported external references that are explicitly reported.
54
+
55
+ Generate types only for schemas used by the selected operation. Reuse an existing project type only after verifying required fields, optionality, nullability, enums, and formats.
56
+
57
+ ## Existing artifact decisions
58
+
59
+ - **Create:** no matching service, type, or mock exists.
60
+ - **Update:** the artifact represents the selected operation but differs from the current contract.
61
+ - **Reuse:** the existing artifact matches semantically; do not rewrite it for formatting or naming.
62
+ - **Conflict:** deployed behavior intentionally differs or sources contradict; report before destructive changes.
63
+
64
+ Never regenerate an entire service namespace because one endpoint changed.
65
+
66
+ ## OpenAPI snapshot
67
+
68
+ Treat the project's OpenAPI/Swagger file as authoritative. Lookup order: `openapi` in `.star-allinone.json`, then a document provided in the conversation.
69
+
70
+ Never refresh a checked-in snapshot with `cp`, full-file replacement, or unconditional formatter output. Report the delta and wait for confirmation before rewriting the snapshot.
@@ -0,0 +1,89 @@
1
+ # Service Conventions
2
+
3
+ Read `.star-allinone.json` first. `serviceDir` defaults to `src/services`. Overlay extra domain paths only when `.agents/project/conventions.md` exists.
4
+
5
+ ## Layout
6
+
7
+ ```text
8
+ src/services/<Domain>/
9
+ ├── <domain>.ts
10
+ └── typings.d.ts
11
+ ```
12
+
13
+ Import the domain default export in `src/services/index.ts` and spread it into the aggregate object. Update an existing domain instead of creating a duplicate.
14
+
15
+ Pages must not call axios or `src/services/request.tsx` directly. Consume methods through `import Service from '@/services'`.
16
+
17
+ ## Request mapping
18
+
19
+ Inspect the project's `MFRequest` helper before generating. The common mapping is:
20
+
21
+ | Contract | Call |
22
+ | --------------------- | ------------------------------- |
23
+ | GET query | `MFRequest.get(url, params)` |
24
+ | POST JSON | `MFRequest.post(url, body)` |
25
+ | PATCH JSON | `MFRequest.patch(url, body)` |
26
+ | PUT JSON | `MFRequest.put(url, body)` |
27
+ | DELETE query | `MFRequest.delete(url, params)` |
28
+ | GET blob export | `MFRequest.export(url, params)` |
29
+ | POST multipart import | `MFRequest.import(url, params)` |
30
+
31
+ Do not modify the shared request module for a single endpoint unless the transport capability is missing and the user approves the cross-cutting change.
32
+
33
+ ## Types
34
+
35
+ - Put DTOs in `src/services/<Domain>/typings.d.ts` using the project's `declare namespace DOMAIN_API` pattern.
36
+ - Pages must not redefine service DTOs.
37
+ - Preserve backend snake_case.
38
+ - Mark a field optional only when the contract may omit it. Use `| null` when it is present but nullable.
39
+ - Prefer named types over `Record<string, any>` when the contract is known.
40
+ - Use `Partial<T>` only for genuinely partial update or filter contracts.
41
+ - Path parameters are explicit function arguments, not fields on the query type.
42
+ - Service callers are typed against the unwrapped `data` payload. `MFRequest` resolves the outer envelope; do not duplicate `code`, `message`/`msg`, or `data` inside `T`.
43
+ - Add concise Chinese JSDoc matching nearby services.
44
+
45
+ ```ts
46
+ import MFRequest from '../request';
47
+
48
+ /**
49
+ * 获取设备列表
50
+ */
51
+ const getDevicesList = (params: DEVICES_API.IDevicesListForm) => {
52
+ return MFRequest.get('/api/v1/devices/', params);
53
+ };
54
+
55
+ export default { getDevicesList };
56
+ ```
57
+
58
+ ```ts
59
+ declare namespace DEVICES_API {
60
+ type IDevicesListForm = {
61
+ page: number;
62
+ page_size: number;
63
+ keyword?: string;
64
+ };
65
+
66
+ type IDevicesListResponse = {
67
+ results: IDevicesListItem[];
68
+ count: number;
69
+ };
70
+ }
71
+ ```
72
+
73
+ If the nearest domain uses `{ list, total }` instead of `{ results, count }`, follow that domain. Do not invent a third pagination shape.
74
+
75
+ ## Endpoint checklist
76
+
77
+ - Exact HTTP method and trailing slash.
78
+ - Path variables and their types.
79
+ - Query versus JSON body versus multipart.
80
+ - Required, optional, and nullable fields.
81
+ - Enum values and display fields.
82
+ - Date/time and numeric units.
83
+ - List pagination and sorting fields.
84
+ - Download filename/content behavior.
85
+ - Empty response semantics for create/update/delete.
86
+
87
+ ## MFRequest side effects
88
+
89
+ Ordinary requests typically strip `undefined`, `null`, and empty strings. PATCH may convert `undefined` to `null`. Confirm the local wrapper before using `undefined` to mean “unchanged.”