@miniidealab/openlogos 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/dist/commands/init.d.ts +9 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +219 -8
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +9 -41
- package/dist/commands/sync.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +14 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -2
- package/skills/api-designer/SKILL.en.md +209 -0
- package/skills/api-designer/SKILL.md +209 -0
- package/skills/architecture-designer/SKILL.en.md +181 -0
- package/skills/architecture-designer/SKILL.md +181 -0
- package/skills/change-writer/SKILL.en.md +146 -0
- package/skills/change-writer/SKILL.md +146 -0
- package/skills/code-reviewer/SKILL.en.md +204 -0
- package/skills/code-reviewer/SKILL.md +204 -0
- package/skills/db-designer/SKILL.en.md +212 -0
- package/skills/db-designer/SKILL.md +212 -0
- package/skills/merge-executor/SKILL.en.md +84 -0
- package/skills/merge-executor/SKILL.md +84 -0
- package/skills/prd-writer/SKILL.en.md +171 -0
- package/skills/prd-writer/SKILL.md +171 -0
- package/skills/product-designer/SKILL.en.md +228 -0
- package/skills/product-designer/SKILL.md +228 -0
- package/skills/project-init/SKILL.en.md +163 -0
- package/skills/project-init/SKILL.md +163 -0
- package/skills/scenario-architect/SKILL.en.md +214 -0
- package/skills/scenario-architect/SKILL.md +214 -0
- package/skills/test-orchestrator/SKILL.en.md +142 -0
- package/skills/test-orchestrator/SKILL.md +142 -0
- package/skills/test-writer/SKILL.en.md +247 -0
- package/skills/test-writer/SKILL.md +247 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Skill: API Designer
|
|
2
|
+
|
|
3
|
+
> Design OpenAPI 3.0+ YAML specifications based on sequence diagrams, letting APIs emerge naturally from scenarios rather than being defined in isolation. Every endpoint is traceable to a Step number in the sequence diagrams, ensuring "no scenario, no API design."
|
|
4
|
+
|
|
5
|
+
## Trigger Conditions
|
|
6
|
+
|
|
7
|
+
- User requests API design or API documentation
|
|
8
|
+
- User mentions "Phase 3 Step 2" or "API design"
|
|
9
|
+
- Scenario sequence diagrams already exist and API specifications need to be refined
|
|
10
|
+
- User provides a specific API endpoint that needs detailed design
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
- `logos/resources/prd/3-technical-plan/2-scenario-implementation/` contains scenario sequence diagrams
|
|
15
|
+
- `logos/resources/prd/3-technical-plan/1-architecture/` contains the architecture overview (confirming frontend-backend separation approach, authentication scheme, etc.)
|
|
16
|
+
- `tech_stack` in `logos-project.yaml` is filled in
|
|
17
|
+
|
|
18
|
+
If the sequence diagram directory is empty, prompt the user to complete Phase 3 Step 1 (scenario-architect) first.
|
|
19
|
+
|
|
20
|
+
## Core Capabilities
|
|
21
|
+
|
|
22
|
+
1. Extract all cross-system-boundary API calls from sequence diagrams
|
|
23
|
+
2. Deduplicate, merge, and group by domain to form an endpoint inventory
|
|
24
|
+
3. Design OpenAPI 3.0+ YAML specifications (paths, parameters, request bodies, response structures)
|
|
25
|
+
4. Define a unified error response format and error code system
|
|
26
|
+
5. Design authentication schemes (Bearer Token / API Key / Cookie)
|
|
27
|
+
6. Design standardized parameters for pagination, sorting, and filtering
|
|
28
|
+
|
|
29
|
+
## Execution Steps
|
|
30
|
+
|
|
31
|
+
### Step 1: Read Scenario Context
|
|
32
|
+
|
|
33
|
+
Read the following files to establish complete context:
|
|
34
|
+
|
|
35
|
+
- **Scenario sequence diagrams** (`logos/resources/prd/3-technical-plan/2-scenario-implementation/`): Extract all cross-system-boundary arrows
|
|
36
|
+
- **Architecture overview** (`logos/resources/prd/3-technical-plan/1-architecture/`): Confirm authentication scheme, frontend-backend separation approach, API gateway, etc.
|
|
37
|
+
- **`logos-project.yaml`**: Read `tech_stack` to confirm backend framework and deployment approach
|
|
38
|
+
|
|
39
|
+
### Step 2: Extract Endpoint Inventory
|
|
40
|
+
|
|
41
|
+
Traverse all scenario sequence diagrams and collect every cross-system-boundary call arrow:
|
|
42
|
+
|
|
43
|
+
1. Identify "cross-system-boundary" arrows — client to server, server to external service, inter-service calls
|
|
44
|
+
2. For each arrow, extract: HTTP method, path, source scenario number, and Step number
|
|
45
|
+
3. Deduplicate and merge — the same endpoint may appear in multiple scenarios (e.g., `POST /api/auth/login` may appear in both S02 and S03)
|
|
46
|
+
4. Output an endpoint inventory summary for user confirmation:
|
|
47
|
+
|
|
48
|
+
```markdown
|
|
49
|
+
Identified N API endpoints from sequence diagrams:
|
|
50
|
+
|
|
51
|
+
| # | Method | Path | Source Scenario | Domain |
|
|
52
|
+
|---|--------|------|-----------------|--------|
|
|
53
|
+
| 1 | POST | /api/auth/register | S01 Step 2 | auth |
|
|
54
|
+
| 2 | POST | /api/auth/login | S02 Step 1 | auth |
|
|
55
|
+
| 3 | GET | /api/projects | S04 Step 1 | projects |
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Step 3: Group by Domain
|
|
59
|
+
|
|
60
|
+
Group endpoints by business domain, with each group corresponding to a YAML file:
|
|
61
|
+
|
|
62
|
+
- `auth.yaml` — Authentication-related (registration, login, logout, password reset)
|
|
63
|
+
- `projects.yaml` — CRUD for core business entities
|
|
64
|
+
- `billing.yaml` — Payment and subscriptions
|
|
65
|
+
|
|
66
|
+
Grouping principles:
|
|
67
|
+
- Operations on the same data entity go together
|
|
68
|
+
- Authentication/authorization is a separate group
|
|
69
|
+
- Third-party service callbacks (e.g., payment callbacks) go under the corresponding business domain
|
|
70
|
+
|
|
71
|
+
### Step 4: Design Unified Conventions
|
|
72
|
+
|
|
73
|
+
Before generating specific endpoints, establish global conventions:
|
|
74
|
+
|
|
75
|
+
**Authentication scheme** (read from architecture overview):
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
components:
|
|
79
|
+
securitySchemes:
|
|
80
|
+
bearerAuth:
|
|
81
|
+
type: http
|
|
82
|
+
scheme: bearer
|
|
83
|
+
bearerFormat: JWT
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Unified error response**:
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
components:
|
|
90
|
+
schemas:
|
|
91
|
+
ErrorResponse:
|
|
92
|
+
type: object
|
|
93
|
+
required: [code, message]
|
|
94
|
+
properties:
|
|
95
|
+
code:
|
|
96
|
+
type: string
|
|
97
|
+
description: Machine-readable error code (e.g., EMAIL_EXISTS)
|
|
98
|
+
message:
|
|
99
|
+
type: string
|
|
100
|
+
description: Human-readable error description
|
|
101
|
+
details:
|
|
102
|
+
type: object
|
|
103
|
+
description: Additional error information (e.g., field-level validation errors)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Pagination parameters** (applicable to list endpoints):
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
parameters:
|
|
110
|
+
- name: page
|
|
111
|
+
in: query
|
|
112
|
+
schema: { type: integer, minimum: 1, default: 1 }
|
|
113
|
+
- name: per_page
|
|
114
|
+
in: query
|
|
115
|
+
schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Step 5: Design Detailed Specification per Endpoint
|
|
119
|
+
|
|
120
|
+
Design a complete OpenAPI specification for each endpoint, **output by domain**, pausing after each domain for user review:
|
|
121
|
+
|
|
122
|
+
Each endpoint must include:
|
|
123
|
+
- `operationId`: Unique identifier for code generation
|
|
124
|
+
- `summary`: One-sentence description
|
|
125
|
+
- `description`: Annotate the source sequence diagram step (e.g., `Source: S01 Step 2 → Step 3`)
|
|
126
|
+
- `requestBody`: Schema including all fields (with required, types, validation rules such as minLength/format)
|
|
127
|
+
- `responses`: Cover the normal response + all known exceptions (extracted from EX use cases in sequence diagrams)
|
|
128
|
+
|
|
129
|
+
**Example**:
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
paths:
|
|
133
|
+
/api/auth/register:
|
|
134
|
+
post:
|
|
135
|
+
operationId: register
|
|
136
|
+
summary: User registration
|
|
137
|
+
description: "Source: S01 Step 2 → Step 3"
|
|
138
|
+
requestBody:
|
|
139
|
+
required: true
|
|
140
|
+
content:
|
|
141
|
+
application/json:
|
|
142
|
+
schema:
|
|
143
|
+
type: object
|
|
144
|
+
required: [email, password]
|
|
145
|
+
properties:
|
|
146
|
+
email: { type: string, format: email }
|
|
147
|
+
password: { type: string, minLength: 8 }
|
|
148
|
+
responses:
|
|
149
|
+
'201':
|
|
150
|
+
description: Registration successful, verification email sent
|
|
151
|
+
content:
|
|
152
|
+
application/json:
|
|
153
|
+
schema:
|
|
154
|
+
type: object
|
|
155
|
+
properties:
|
|
156
|
+
userId: { type: string, format: uuid }
|
|
157
|
+
message: { type: string }
|
|
158
|
+
'409':
|
|
159
|
+
description: "Email already registered (EX-2.1)"
|
|
160
|
+
content:
|
|
161
|
+
application/json:
|
|
162
|
+
schema:
|
|
163
|
+
$ref: '#/components/schemas/ErrorResponse'
|
|
164
|
+
'422':
|
|
165
|
+
description: Request parameter validation failed
|
|
166
|
+
content:
|
|
167
|
+
application/json:
|
|
168
|
+
schema:
|
|
169
|
+
$ref: '#/components/schemas/ErrorResponse'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Step 6: Verify Traceability Completeness
|
|
173
|
+
|
|
174
|
+
After output is complete, perform a traceability check:
|
|
175
|
+
|
|
176
|
+
1. **Forward check**: Every cross-system arrow in the sequence diagrams has a corresponding API endpoint
|
|
177
|
+
2. **Reverse check**: Every API endpoint's `description` annotates the source Step
|
|
178
|
+
3. **Exception coverage**: Every EX use case in the sequence diagrams has a corresponding HTTP error response
|
|
179
|
+
|
|
180
|
+
If gaps are found, supplement them before outputting the final version.
|
|
181
|
+
|
|
182
|
+
## Output Specification
|
|
183
|
+
|
|
184
|
+
- File format: OpenAPI 3.1 YAML
|
|
185
|
+
- Storage location: `logos/resources/api/`
|
|
186
|
+
- Split by domain: `auth.yaml`, `projects.yaml`, `billing.yaml`
|
|
187
|
+
- Each file contains complete `openapi`, `info`, `paths`, and `components` sections
|
|
188
|
+
- Error responses uniformly reference `$ref: '#/components/schemas/ErrorResponse'`
|
|
189
|
+
- Every endpoint's `description` must annotate the source sequence diagram step
|
|
190
|
+
|
|
191
|
+
## Best Practices
|
|
192
|
+
|
|
193
|
+
- **APIs emerge from sequence diagrams**: If an API cannot be traced back to a sequence diagram, it most likely should not exist. Design sequence diagrams first, then APIs — not the other way around
|
|
194
|
+
- **Path naming**: RESTful style, use plural nouns, `/api/{resource}`
|
|
195
|
+
- **Version prefix**: Do not add a version prefix initially (`/api/auth/register`); add `/api/v2/` when versioning becomes necessary
|
|
196
|
+
- **Status code semantics**: Strictly follow HTTP status code semantics — 200 success, 201 created, 400 bad request, 401 unauthorized, 403 forbidden, 404 not found, 409 conflict, 422 validation failed, 500 server error
|
|
197
|
+
- **Idempotent design**: PUT/DELETE operations must be idempotent
|
|
198
|
+
- **Sensitive data**: Do not include plaintext sensitive information such as passwords or tokens in responses
|
|
199
|
+
- **Output by domain**: Do not output all endpoints at once — output in batches by domain, letting the user review each batch before continuing
|
|
200
|
+
- **Consistent field naming**: Field names in the API should be consistent with column names in the subsequent DB design (or have explicit mapping rules) to avoid unnecessary field transformations in the code layer
|
|
201
|
+
|
|
202
|
+
## Recommended Prompts
|
|
203
|
+
|
|
204
|
+
The following prompts can be copied directly for use with the AI:
|
|
205
|
+
|
|
206
|
+
- `Help me design APIs`
|
|
207
|
+
- `Generate OpenAPI YAML based on the sequence diagrams`
|
|
208
|
+
- `Help me design the API specifications related to S01`
|
|
209
|
+
- `Help me extract all cross-system calls from the sequence diagrams into APIs`
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Skill: API Designer
|
|
2
|
+
|
|
3
|
+
> 基于时序图设计 OpenAPI 3.0+ YAML 规格,让 API 从场景中自然浮现而非凭空定义。每个端点可追溯到时序图的 Step 编号,确保"无场景不设计 API"。
|
|
4
|
+
|
|
5
|
+
## 触发条件
|
|
6
|
+
|
|
7
|
+
- 用户要求设计 API 或编写 API 文档
|
|
8
|
+
- 用户提到 "Phase 3 Step 2"、"API 设计"
|
|
9
|
+
- 已有场景时序图,需要细化 API 规格
|
|
10
|
+
- 用户提供了一个 API 端点需要详细设计
|
|
11
|
+
|
|
12
|
+
## 前置依赖
|
|
13
|
+
|
|
14
|
+
- `logos/resources/prd/3-technical-plan/2-scenario-implementation/` 中包含场景时序图
|
|
15
|
+
- `logos/resources/prd/3-technical-plan/1-architecture/` 中包含架构概要(确认前后端分离方式、认证方案等)
|
|
16
|
+
- `logos-project.yaml` 的 `tech_stack` 已填写
|
|
17
|
+
|
|
18
|
+
如果时序图目录为空,提示用户先完成 Phase 3 Step 1(scenario-architect)。
|
|
19
|
+
|
|
20
|
+
## 核心能力
|
|
21
|
+
|
|
22
|
+
1. 从时序图中提取所有跨系统边界的 API 调用
|
|
23
|
+
2. 去重、合并、按领域分组,形成端点清单
|
|
24
|
+
3. 设计 OpenAPI 3.0+ YAML 规格(路径、参数、请求体、响应结构)
|
|
25
|
+
4. 定义统一的错误响应格式和错误码体系
|
|
26
|
+
5. 设计认证方案(Bearer Token / API Key / Cookie)
|
|
27
|
+
6. 设计分页、排序、过滤的标准化参数
|
|
28
|
+
|
|
29
|
+
## 执行步骤
|
|
30
|
+
|
|
31
|
+
### Step 1: 读取场景上下文
|
|
32
|
+
|
|
33
|
+
读取以下文件建立完整上下文:
|
|
34
|
+
|
|
35
|
+
- **场景时序图**(`logos/resources/prd/3-technical-plan/2-scenario-implementation/`):提取所有跨系统边界的箭头
|
|
36
|
+
- **架构概要**(`logos/resources/prd/3-technical-plan/1-architecture/`):确认认证方案、前后端分离方式、API 网关等
|
|
37
|
+
- **`logos-project.yaml`**:读取 `tech_stack` 确认后端框架和部署方式
|
|
38
|
+
|
|
39
|
+
### Step 2: 提取端点清单
|
|
40
|
+
|
|
41
|
+
遍历所有场景时序图,收集每个跨系统边界的调用箭头:
|
|
42
|
+
|
|
43
|
+
1. 识别"跨系统边界"的箭头——客户端到服务端、服务端到外部服务、服务间调用
|
|
44
|
+
2. 为每个箭头提取:HTTP 方法、路径、所属场景编号和 Step 编号
|
|
45
|
+
3. 去重合并——同一个端点可能在多个场景中出现(如 `POST /api/auth/login` 可能在 S02 和 S03 都有)
|
|
46
|
+
4. 输出端点清单摘要供用户确认:
|
|
47
|
+
|
|
48
|
+
```markdown
|
|
49
|
+
从时序图中识别到 N 个 API 端点:
|
|
50
|
+
|
|
51
|
+
| # | 方法 | 路径 | 来源场景 | 领域 |
|
|
52
|
+
|---|------|------|---------|------|
|
|
53
|
+
| 1 | POST | /api/auth/register | S01 Step 2 | auth |
|
|
54
|
+
| 2 | POST | /api/auth/login | S02 Step 1 | auth |
|
|
55
|
+
| 3 | GET | /api/projects | S04 Step 1 | projects |
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Step 3: 按领域分组
|
|
59
|
+
|
|
60
|
+
将端点按业务领域分组,每组对应一个 YAML 文件:
|
|
61
|
+
|
|
62
|
+
- `auth.yaml` — 认证相关(注册、登录、登出、重置密码)
|
|
63
|
+
- `projects.yaml` — 核心业务对象的 CRUD
|
|
64
|
+
- `billing.yaml` — 支付和订阅
|
|
65
|
+
|
|
66
|
+
分组原则:
|
|
67
|
+
- 同一数据实体的操作放在一起
|
|
68
|
+
- 认证/授权独立分组
|
|
69
|
+
- 第三方服务回调(如支付回调)放在对应业务领域
|
|
70
|
+
|
|
71
|
+
### Step 4: 设计统一约定
|
|
72
|
+
|
|
73
|
+
在生成具体端点前,先确定全局约定:
|
|
74
|
+
|
|
75
|
+
**认证方案**(从架构概要中读取):
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
components:
|
|
79
|
+
securitySchemes:
|
|
80
|
+
bearerAuth:
|
|
81
|
+
type: http
|
|
82
|
+
scheme: bearer
|
|
83
|
+
bearerFormat: JWT
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**统一错误响应**:
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
components:
|
|
90
|
+
schemas:
|
|
91
|
+
ErrorResponse:
|
|
92
|
+
type: object
|
|
93
|
+
required: [code, message]
|
|
94
|
+
properties:
|
|
95
|
+
code:
|
|
96
|
+
type: string
|
|
97
|
+
description: 机器可读的错误码(如 EMAIL_EXISTS)
|
|
98
|
+
message:
|
|
99
|
+
type: string
|
|
100
|
+
description: 人类可读的错误描述
|
|
101
|
+
details:
|
|
102
|
+
type: object
|
|
103
|
+
description: 附加错误信息(如字段级校验错误)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**分页参数**(适用于列表端点):
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
parameters:
|
|
110
|
+
- name: page
|
|
111
|
+
in: query
|
|
112
|
+
schema: { type: integer, minimum: 1, default: 1 }
|
|
113
|
+
- name: per_page
|
|
114
|
+
in: query
|
|
115
|
+
schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Step 5: 逐端点设计详细规格
|
|
119
|
+
|
|
120
|
+
为每个端点设计完整的 OpenAPI 规格,**逐领域输出**,每完成一个领域暂停让用户 review:
|
|
121
|
+
|
|
122
|
+
每个端点必须包含:
|
|
123
|
+
- `operationId`:唯一标识符,用于代码生成
|
|
124
|
+
- `summary`:一句话描述
|
|
125
|
+
- `description`:标注来源时序图步骤(如 `来源:S01 Step 2 → Step 3`)
|
|
126
|
+
- `requestBody`:包含所有字段的 schema(含 required、类型、校验规则如 minLength/format)
|
|
127
|
+
- `responses`:覆盖正常响应 + 所有已知异常(从时序图的 EX 用例中提取)
|
|
128
|
+
|
|
129
|
+
**示例**:
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
paths:
|
|
133
|
+
/api/auth/register:
|
|
134
|
+
post:
|
|
135
|
+
operationId: register
|
|
136
|
+
summary: 用户注册
|
|
137
|
+
description: "来源:S01 Step 2 → Step 3"
|
|
138
|
+
requestBody:
|
|
139
|
+
required: true
|
|
140
|
+
content:
|
|
141
|
+
application/json:
|
|
142
|
+
schema:
|
|
143
|
+
type: object
|
|
144
|
+
required: [email, password]
|
|
145
|
+
properties:
|
|
146
|
+
email: { type: string, format: email }
|
|
147
|
+
password: { type: string, minLength: 8 }
|
|
148
|
+
responses:
|
|
149
|
+
'201':
|
|
150
|
+
description: 注册成功,发送验证邮件
|
|
151
|
+
content:
|
|
152
|
+
application/json:
|
|
153
|
+
schema:
|
|
154
|
+
type: object
|
|
155
|
+
properties:
|
|
156
|
+
userId: { type: string, format: uuid }
|
|
157
|
+
message: { type: string }
|
|
158
|
+
'409':
|
|
159
|
+
description: "邮箱已被注册(EX-2.1)"
|
|
160
|
+
content:
|
|
161
|
+
application/json:
|
|
162
|
+
schema:
|
|
163
|
+
$ref: '#/components/schemas/ErrorResponse'
|
|
164
|
+
'422':
|
|
165
|
+
description: 请求参数校验失败
|
|
166
|
+
content:
|
|
167
|
+
application/json:
|
|
168
|
+
schema:
|
|
169
|
+
$ref: '#/components/schemas/ErrorResponse'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Step 6: 验证追溯完整性
|
|
173
|
+
|
|
174
|
+
输出完成后,做一次追溯检查:
|
|
175
|
+
|
|
176
|
+
1. **正向检查**:每个时序图中的跨系统箭头都有对应的 API 端点
|
|
177
|
+
2. **反向检查**:每个 API 端点的 `description` 都标注了来源 Step
|
|
178
|
+
3. **异常覆盖**:时序图中的每个 EX 用例都有对应的 HTTP 错误响应
|
|
179
|
+
|
|
180
|
+
如果发现遗漏,补充后再输出最终版本。
|
|
181
|
+
|
|
182
|
+
## 输出规范
|
|
183
|
+
|
|
184
|
+
- 文件格式:OpenAPI 3.1 YAML
|
|
185
|
+
- 存放位置:`logos/resources/api/`
|
|
186
|
+
- 按领域分文件:`auth.yaml`、`projects.yaml`、`billing.yaml`
|
|
187
|
+
- 每个文件包含完整的 `openapi`、`info`、`paths`、`components` 段
|
|
188
|
+
- 错误响应统一引用 `$ref: '#/components/schemas/ErrorResponse'`
|
|
189
|
+
- 每个端点的 `description` 必须标注来源时序图步骤
|
|
190
|
+
|
|
191
|
+
## 实践经验
|
|
192
|
+
|
|
193
|
+
- **API 从时序图浮现**:如果一个 API 在时序图中找不到出处,它大概率不应该存在。先画时序图再设计 API,而非反过来
|
|
194
|
+
- **路径命名**:RESTful 风格,使用复数名词,`/api/{resource}`
|
|
195
|
+
- **版本前缀**:初期不加版本前缀(`/api/auth/register`),需要版本管理时再加 `/api/v2/`
|
|
196
|
+
- **状态码语义**:严格遵循 HTTP 状态码语义——200 成功、201 创建、400 参数错误、401 未认证、403 无权限、404 不存在、409 冲突、422 校验失败、500 服务错误
|
|
197
|
+
- **幂等设计**:PUT/DELETE 操作必须幂等
|
|
198
|
+
- **敏感数据**:响应中不包含密码、token 等敏感信息的明文
|
|
199
|
+
- **逐领域输出**:不要一次输出所有端点——按领域分批输出,每批让用户 review 后再继续
|
|
200
|
+
- **字段命名一致**:API 中的字段名要与后续 DB 设计中的列名保持一致(或有明确的映射规则),避免代码层出现不必要的字段转换
|
|
201
|
+
|
|
202
|
+
## 推荐提示词
|
|
203
|
+
|
|
204
|
+
以下提示词可以直接复制给 AI 使用:
|
|
205
|
+
|
|
206
|
+
- `帮我设计 API`
|
|
207
|
+
- `基于时序图帮我生成 OpenAPI YAML`
|
|
208
|
+
- `帮我设计 S01 相关的 API 规格`
|
|
209
|
+
- `帮我把所有时序图中的跨系统调用提取为 API`
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Skill: Architecture Designer
|
|
2
|
+
|
|
3
|
+
> Before diving into per-scenario technical implementation, establish the project's technical global view — system architecture, technology selection, deployment topology, and non-functional constraints. Ensure that subsequent sequence diagrams, API designs, and code generation all proceed under consistent architectural constraints.
|
|
4
|
+
|
|
5
|
+
## Trigger Conditions
|
|
6
|
+
|
|
7
|
+
- User requests designing technical architecture, making technology selections, or planning system architecture
|
|
8
|
+
- User mentions "Phase 3 Step 0", "architecture design", "technical plan"
|
|
9
|
+
- Phase 2 product design documents are complete, and Phase 3 needs to begin
|
|
10
|
+
- User wants to determine the tech stack or deployment strategy
|
|
11
|
+
|
|
12
|
+
## Core Capabilities
|
|
13
|
+
|
|
14
|
+
1. Read Phase 1 requirements documents and Phase 2 product design documents to understand the full product picture
|
|
15
|
+
2. Based on product complexity and scenario characteristics, recommend suitable system architectures
|
|
16
|
+
3. Provide selection rationale and alternative comparisons for each technology choice
|
|
17
|
+
4. Draw system architecture diagrams (Mermaid) and deployment topology diagrams
|
|
18
|
+
5. Update the `tech_stack` field in `logos-project.yaml`
|
|
19
|
+
|
|
20
|
+
## Integration with Phase 1/2
|
|
21
|
+
|
|
22
|
+
Architecture design is the bridge from Phase 2 (product design) to Phase 3 (technical implementation). Its inputs come from Phase 1/2, and its outputs influence all subsequent steps in Phase 3:
|
|
23
|
+
|
|
24
|
+
| Input (from Phase 1/2) | Output (influences subsequent Phase 3 steps) |
|
|
25
|
+
|------------------------|------------------------------|
|
|
26
|
+
| Scenario list and complexity | System boundary definition → sequence diagram participants |
|
|
27
|
+
| Non-functional requirements (performance, security) | Technology selection constraints → API design decisions |
|
|
28
|
+
| Product interaction type (Web/Mobile/API) | Frontend tech stack → prototype implementation approach |
|
|
29
|
+
| Data volume and access patterns | Database selection → DB design |
|
|
30
|
+
| Third-party service dependencies (payment, email, etc.) | Integration approach → external participants in sequence diagrams |
|
|
31
|
+
|
|
32
|
+
## Execution Steps
|
|
33
|
+
|
|
34
|
+
### Step 1: Understand the Full Product Picture
|
|
35
|
+
|
|
36
|
+
Read the following documents to build an overall understanding of the project:
|
|
37
|
+
|
|
38
|
+
- **Requirements Document** (Phase 1): Product positioning, core scenarios, constraints and boundaries
|
|
39
|
+
- **Product Design Document** (Phase 2): Information architecture, page structure, interaction complexity
|
|
40
|
+
- **Existing `logos-project.yaml`**: Whether there are initial selections in the current `tech_stack`
|
|
41
|
+
|
|
42
|
+
Key points to extract:
|
|
43
|
+
- Number and complexity of core scenarios
|
|
44
|
+
- Whether there are real-time requirements (WebSocket, SSE)
|
|
45
|
+
- Whether there are background tasks (scheduled tasks, message queues)
|
|
46
|
+
- List of third-party service dependencies
|
|
47
|
+
- Expected user scale
|
|
48
|
+
|
|
49
|
+
### Step 2: Determine System Architecture
|
|
50
|
+
|
|
51
|
+
Choose an architecture pattern based on product complexity:
|
|
52
|
+
|
|
53
|
+
**Simple Projects** (personal SaaS, utility products):
|
|
54
|
+
- Monolithic architecture + single database
|
|
55
|
+
- Architecture overview can be a paragraph of text + a simple diagram
|
|
56
|
+
|
|
57
|
+
**Medium Projects** (team SaaS, multi-role systems):
|
|
58
|
+
- Frontend-backend separation + monolithic backend + single database
|
|
59
|
+
- May need auxiliary services like object storage, caching, etc.
|
|
60
|
+
|
|
61
|
+
**Complex Projects** (multi-service, high-concurrency, multi-platform):
|
|
62
|
+
- Microservices / modular monolith
|
|
63
|
+
- Requires detailed Architecture Decision Records (ADR)
|
|
64
|
+
|
|
65
|
+
Draw system architecture diagram using Mermaid:
|
|
66
|
+
|
|
67
|
+
```mermaid
|
|
68
|
+
graph TB
|
|
69
|
+
subgraph Frontend
|
|
70
|
+
Web[Web App - Next.js]
|
|
71
|
+
end
|
|
72
|
+
subgraph Backend
|
|
73
|
+
API[API Server - Node.js]
|
|
74
|
+
Worker[Background Worker]
|
|
75
|
+
end
|
|
76
|
+
subgraph Data
|
|
77
|
+
DB[(PostgreSQL)]
|
|
78
|
+
Cache[(Redis)]
|
|
79
|
+
S3[Object Storage]
|
|
80
|
+
end
|
|
81
|
+
subgraph External
|
|
82
|
+
Auth[Supabase Auth]
|
|
83
|
+
Email[SendGrid]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Web -->|REST API| API
|
|
87
|
+
API --> DB
|
|
88
|
+
API --> Cache
|
|
89
|
+
API --> S3
|
|
90
|
+
API --> Auth
|
|
91
|
+
Worker --> DB
|
|
92
|
+
Worker --> Email
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Step 3: Technology Selection
|
|
96
|
+
|
|
97
|
+
Provide selection and rationale for each technology dimension:
|
|
98
|
+
|
|
99
|
+
```markdown
|
|
100
|
+
| Dimension | Selection | Rationale | Alternatives |
|
|
101
|
+
|-----------|-----------|-----------|-------------|
|
|
102
|
+
| Language | TypeScript | Unified frontend/backend, type safety | Go (when performance is priority) |
|
|
103
|
+
| Frontend Framework | Next.js 15 | SSR + RSC, mature ecosystem | Astro (content sites), Nuxt (Vue ecosystem) |
|
|
104
|
+
| Backend Framework | Hono | Lightweight, edge-first, native TS | Express (ecosystem), Fastify (performance) |
|
|
105
|
+
| Database | PostgreSQL | Feature-rich, JSONB, RLS | MySQL (simple scenarios) |
|
|
106
|
+
| Authentication | Supabase Auth | Out-of-the-box, RLS integration | NextAuth (self-hosted) |
|
|
107
|
+
| Deployment | Vercel + Supabase | Zero-ops, auto-scaling | AWS (full control) |
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Selection Principles**:
|
|
111
|
+
- Prefer technologies the team is already familiar with
|
|
112
|
+
- When there is no significant difference, choose the option with the larger community
|
|
113
|
+
- Selection rationale must be linked to specific product requirements or constraints
|
|
114
|
+
|
|
115
|
+
### Step 4: Non-Functional Constraints
|
|
116
|
+
|
|
117
|
+
Define key non-functional requirements:
|
|
118
|
+
|
|
119
|
+
- **Performance Targets**: Core API response time, page load time
|
|
120
|
+
- **Security Requirements**: Authentication method, data encryption, CORS policy
|
|
121
|
+
- **Scalability**: Expected user scale, data growth estimates
|
|
122
|
+
- **Observability**: Logging, monitoring, alerting strategy
|
|
123
|
+
- **Developer Experience**: Local development environment, CI/CD pipeline
|
|
124
|
+
|
|
125
|
+
### Step 5: External Dependencies and Test Strategies
|
|
126
|
+
|
|
127
|
+
Catalog all external service dependencies for the project and determine the isolation strategy for each dependency during orchestration testing. The output of this step directly impacts whether Phase 3 Step 3 (orchestration testing) can be executed smoothly.
|
|
128
|
+
|
|
129
|
+
1. Identify external dependencies from the architecture diagram and sequence diagram participants (email, SMS, verification codes, payment, OAuth, etc.)
|
|
130
|
+
2. Confirm the test strategy for each dependency with the user
|
|
131
|
+
|
|
132
|
+
Available test strategies:
|
|
133
|
+
|
|
134
|
+
| Strategy | Description | Typical Scenario |
|
|
135
|
+
|----------|-------------|-----------------|
|
|
136
|
+
| `test-api` | Test environment provides a backdoor API | Email/SMS verification codes |
|
|
137
|
+
| `fixed-value` | Specific test data uses fixed values | Fixed verification code for test phone numbers |
|
|
138
|
+
| `env-disable` | Environment variable disables the feature | CAPTCHA, slider verification |
|
|
139
|
+
| `mock-callback` | Orchestration actively calls a simulated callback | Payment callbacks, Webhooks |
|
|
140
|
+
| `mock-service` | Local mock service as replacement | OAuth Provider |
|
|
141
|
+
|
|
142
|
+
If the project has no external service dependencies (e.g., a pure CLI tool), this step can be skipped.
|
|
143
|
+
|
|
144
|
+
### Step 6: Update logos-project.yaml
|
|
145
|
+
|
|
146
|
+
Write the confirmed technology selections into the `tech_stack` field of `logos-project.yaml`, and write external dependencies and test strategies into the `external_dependencies` field, ensuring that all subsequent Skills and AI tools can read the unified tech stack and testing conventions.
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
external_dependencies:
|
|
150
|
+
- name: "Email Service"
|
|
151
|
+
provider: "SendGrid"
|
|
152
|
+
used_in: ["S01-User Registration", "S03-Forgot Password"]
|
|
153
|
+
test_strategy: "test-api"
|
|
154
|
+
test_config: "GET /api/test/latest-email?to={email}"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Output Specification
|
|
158
|
+
|
|
159
|
+
- Architecture overview document: `logos/resources/prd/3-technical-plan/1-architecture/01-architecture-overview.md`
|
|
160
|
+
- Architecture diagrams use Mermaid format
|
|
161
|
+
- Technology selections use table format, each item must include rationale
|
|
162
|
+
- Update the `tech_stack` and `external_dependencies` fields in `logos-project.yaml`
|
|
163
|
+
- Simple projects are allowed to have streamlined output (not all sections are mandatory)
|
|
164
|
+
|
|
165
|
+
## Best Practices
|
|
166
|
+
|
|
167
|
+
- **Don't over-engineer**: For a solo developer building SaaS, monolith + PostgreSQL + Vercel is sufficient — don't jump straight to microservices
|
|
168
|
+
- **Selection rationale matters more than the selection itself**: Documenting "why X was chosen" is more valuable than "X was chosen", because rationale needs to be re-evaluated as the project evolves
|
|
169
|
+
- **Architecture diagrams are prerequisites for sequence diagrams**: System components in the architecture diagram become participants in subsequent sequence diagrams — the two must be consistent
|
|
170
|
+
- **tech_stack is the AI's anchor**: Subsequent AI code generation reads `tech_stack` from `logos-project.yaml` — inaccurate selections will result in unusable generated code
|
|
171
|
+
- **Start loose with non-functional constraints, tighten later**: Don't set overly strict performance targets initially; tighten them as real data becomes available
|
|
172
|
+
- **Test strategies must be decided during the architecture phase**: If test approaches for verification codes, payments, and other external dependencies are left until orchestration testing, you'll often find that no backdoor APIs were provisioned, making fully automated orchestration tests impossible
|
|
173
|
+
|
|
174
|
+
## Recommended Prompts
|
|
175
|
+
|
|
176
|
+
The following prompts can be copied directly for use with AI:
|
|
177
|
+
|
|
178
|
+
- `Help me design the technical architecture`
|
|
179
|
+
- `Based on the product design, help me make technology selections`
|
|
180
|
+
- `Help me draw the system architecture diagram`
|
|
181
|
+
- `Help me determine the tech stack and update logos-project.yaml`
|