ai-dev-requirements 0.1.2 → 0.1.4

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.
@@ -1,109 +1,109 @@
1
- # Service Layer Transform
2
-
3
- ## Problem
4
-
5
- Frontend uses Mock data during development. On integration, backend fields differ in three ways:
6
-
7
- | Difference | Mock (Frontend) | Backend (Actual) |
8
- |-----------|----------------|-----------------|
9
- | Field name | `orderNo` | `order_id` |
10
- | Structure | `{ carrier: "UPS" }` | `{ carrier: { code: "UPS", name: "..." } }` |
11
- | Data format | `status: "Canceled"` | `status: 3` |
12
-
13
- ## Solution: Transform in Service Layer
14
-
15
- **No separate `adapters/` directory.** Transform functions live inside service files. Components never change.
16
-
17
- ```
18
- Component → FrontendType ← service function return type
19
-
20
- │ transform
21
-
22
- BackendType
23
- ```
24
-
25
- **Core principle:** `FrontendType` is the contract between service and component layers. Components only know the contract.
26
-
27
- ## File Structure
28
-
29
- ```
30
- src/api/{module}/
31
- ├── types.ts # FrontendType + BackendType + transform functions
32
- ├── mock.ts # Mock data (dev phase)
33
- └── {module}.ts # API functions (with .then(transform))
34
- ```
35
-
36
- ## Implementation Pattern
37
-
38
- ```typescript
39
- // ① Frontend type (component contract, never changes)
40
- export interface OrderInfo {
41
- orderId: string
42
- carrier: string
43
- amount: number
44
- status: string
45
- }
46
-
47
- // ② Backend type (added during integration)
48
- interface BackendOrderInfo {
49
- order_id: string
50
- carrier_info: { code: string; name: string }
51
- amount: string // cents as string
52
- status: number // numeric enum
53
- }
54
-
55
- // ③ Transform function
56
- const STATUS_MAP: Record<number, string> = {
57
- 1: 'Pending', 2: 'Shipped', 3: 'Canceled',
58
- }
59
-
60
- function transformOrder(raw: BackendOrderInfo): OrderInfo {
61
- return {
62
- orderId: raw.order_id, // field rename
63
- carrier: raw.carrier_info.code, // flatten structure
64
- amount: Number(raw.amount) / 100, // format conversion
65
- status: STATUS_MAP[raw.status] ?? 'Unknown', // enum mapping
66
- }
67
- }
68
-
69
- // ④ Query: backend → frontend
70
- export function getOrderList(query: PageParams) {
71
- return request<PageResponse<BackendOrderInfo>>({
72
- url: '/api/order/page',
73
- params: query,
74
- }).then(res => ({
75
- ...res,
76
- rows: res.rows.map(transformOrder),
77
- }))
78
- }
79
-
80
- // ⑤ Submit: frontend → backend
81
- function toBackendParams(form: OrderForm): BackendOrderForm {
82
- return {
83
- order_id: form.orderId,
84
- amount: String(form.amount * 100),
85
- }
86
- }
87
-
88
- export function createOrder(form: OrderForm) {
89
- return request({
90
- url: '/api/order/create',
91
- method: 'post',
92
- data: toBackendParams(form),
93
- })
94
- }
95
- ```
96
-
97
- ## Integration Flow
98
-
99
- ```
100
- Backend ready → Add BackendType → Write transform → Add .then(transform) → Components unchanged ✅
101
- ```
102
-
103
- ## When Components Must Change
104
-
105
- | Scenario | Handling |
106
- |----------|---------|
107
- | Backend adds field that UI needs to show | Extend FrontendType + component |
108
- | Business semantics change | Update transform + component logic |
109
- | Pagination structure differs (`rows` → `records`) | Handle in transform |
1
+ # Service Layer Transform
2
+
3
+ ## Problem
4
+
5
+ Frontend uses Mock data during development. On integration, backend fields differ in three ways:
6
+
7
+ | Difference | Mock (Frontend) | Backend (Actual) |
8
+ |-----------|----------------|-----------------|
9
+ | Field name | `orderNo` | `order_id` |
10
+ | Structure | `{ carrier: "UPS" }` | `{ carrier: { code: "UPS", name: "..." } }` |
11
+ | Data format | `status: "Canceled"` | `status: 3` |
12
+
13
+ ## Solution: Transform in Service Layer
14
+
15
+ **No separate `adapters/` directory.** Transform functions live inside service files. Components never change.
16
+
17
+ ```
18
+ Component → FrontendType ← service function return type
19
+
20
+ │ transform
21
+
22
+ BackendType
23
+ ```
24
+
25
+ **Core principle:** `FrontendType` is the contract between service and component layers. Components only know the contract.
26
+
27
+ ## File Structure
28
+
29
+ ```
30
+ src/api/{module}/
31
+ ├── types.ts # FrontendType + BackendType + transform functions
32
+ ├── mock.ts # Mock data (dev phase)
33
+ └── {module}.ts # API functions (with .then(transform))
34
+ ```
35
+
36
+ ## Implementation Pattern
37
+
38
+ ```typescript
39
+ // ① Frontend type (component contract, never changes)
40
+ export interface OrderInfo {
41
+ orderId: string
42
+ carrier: string
43
+ amount: number
44
+ status: string
45
+ }
46
+
47
+ // ② Backend type (added during integration)
48
+ interface BackendOrderInfo {
49
+ order_id: string
50
+ carrier_info: { code: string; name: string }
51
+ amount: string // cents as string
52
+ status: number // numeric enum
53
+ }
54
+
55
+ // ③ Transform function
56
+ const STATUS_MAP: Record<number, string> = {
57
+ 1: 'Pending', 2: 'Shipped', 3: 'Canceled',
58
+ }
59
+
60
+ function transformOrder(raw: BackendOrderInfo): OrderInfo {
61
+ return {
62
+ orderId: raw.order_id, // field rename
63
+ carrier: raw.carrier_info.code, // flatten structure
64
+ amount: Number(raw.amount) / 100, // format conversion
65
+ status: STATUS_MAP[raw.status] ?? 'Unknown', // enum mapping
66
+ }
67
+ }
68
+
69
+ // ④ Query: backend → frontend
70
+ export function getOrderList(query: PageParams) {
71
+ return request<PageResponse<BackendOrderInfo>>({
72
+ url: '/api/order/page',
73
+ params: query,
74
+ }).then(res => ({
75
+ ...res,
76
+ rows: res.rows.map(transformOrder),
77
+ }))
78
+ }
79
+
80
+ // ⑤ Submit: frontend → backend
81
+ function toBackendParams(form: OrderForm): BackendOrderForm {
82
+ return {
83
+ order_id: form.orderId,
84
+ amount: String(form.amount * 100),
85
+ }
86
+ }
87
+
88
+ export function createOrder(form: OrderForm) {
89
+ return request({
90
+ url: '/api/order/create',
91
+ method: 'post',
92
+ data: toBackendParams(form),
93
+ })
94
+ }
95
+ ```
96
+
97
+ ## Integration Flow
98
+
99
+ ```
100
+ Backend ready → Add BackendType → Write transform → Add .then(transform) → Components unchanged ✅
101
+ ```
102
+
103
+ ## When Components Must Change
104
+
105
+ | Scenario | Handling |
106
+ |----------|---------|
107
+ | Backend adds field that UI needs to show | Extend FrontendType + component |
108
+ | Business semantics change | Update transform + component logic |
109
+ | Pagination structure differs (`rows` → `records`) | Handle in transform |
@@ -1,123 +1,123 @@
1
- # Task Types & Scheduling
2
-
3
- ## Task Types
4
-
5
- | Type | ID | Strategy | Review Level | Description |
6
- |------|-----|---------|------------|------|
7
- | Code Development | `code:dev` | `isolated` | strict | Serial within module, parallel across modules |
8
- | Code Fix | `code:fix` | `isolated` | standard | Serial within file |
9
- | Code Refactor | `code:refactor` | `serial` | strict | Global serial, large impact |
10
- | Doc Writing | `doc:write` | `parallel` | light | Fully parallel |
11
- | Doc Translation | `doc:translate` | `parallel` | light | Fully parallel |
12
- | Research | `research` | `parallel` | light | Fully parallel, supports caching |
13
- | Data Processing | `data` | `isolated` | standard | Isolated by data source |
14
- | Testing | `test` | `parallel` | standard | Fully parallel |
15
-
16
- ## Scheduling Strategies
17
-
18
- - **parallel** — Fully parallel, no restrictions (bounded by parallel_limit)
19
- - **isolated** — Group by isolation key; serial within group, parallel between groups
20
- - **serial** — Global lock, one task at a time
21
-
22
- ## Max Parallelism: 5
23
-
24
- ## Task Declaration Syntax
25
-
26
- ```markdown
27
- ## TaskGroup: <group name>
28
-
29
- ### Meta
30
- - parallel_limit: 5
31
- - review_level: standard
32
- - on_failure: continue | stop
33
-
34
- ### Tasks
35
- 1. [code:dev] Implement auth module @isolated(auth/)
36
- 2. [code:dev] Implement order module @isolated(order/)
37
- 3. [doc:write] Write API docs
38
- 4. [research] Research payment gateway @cache(7d)
39
- ```
40
-
41
- | Element | Format | Description |
42
- |---------|--------|-------------|
43
- | Task type | `[type:subtype]` | Type identifier in brackets |
44
- | Isolation key | `@isolated(key)` | Grouping key for isolation |
45
- | Cache | `@cache(duration)` | Cache TTL for research tasks |
46
- | Dependency | `@depends(task_id)` | Prerequisite task dependency |
47
-
48
- ## Fullstack Parallel Strategy
49
-
50
- ```
51
- ┌─────────────┐
52
- │ API Contract │
53
- └──────┬──────┘
54
-
55
- ┌─────────┴─────────┐
56
- ↓ ↓
57
- ┌─────────┐ ┌─────────┐
58
- │ Frontend │ │ Backend │
59
- │ (Mock) │ │ (API) │
60
- └────┬────┘ └────┬────┘
61
- └────────┬──────┘
62
-
63
- ┌─────────────┐
64
- │ Integration │
65
- └─────────────┘
66
- ```
67
-
68
- ## Templates
69
-
70
- ### Code Development
71
- ```markdown
72
- ## TaskGroup: [Feature Name]
73
- ### Meta
74
- - parallel_limit: 5
75
- - review_level: strict
76
- - on_failure: continue
77
- ### Tasks
78
- 1. [code:dev] Implement [module] core logic @isolated([module]/)
79
- 2. [code:dev] Implement [module] UI components @isolated([module]/)
80
- 3. [code:dev] Implement [module] API layer @isolated([module]/api/)
81
- 4. [test] Write [module] unit tests @isolated([module]/)
82
- ```
83
-
84
- ### Code Fix
85
- ```markdown
86
- ## TaskGroup: [Bug Description]
87
- ### Meta
88
- - parallel_limit: 3
89
- - review_level: standard
90
- - on_failure: stop
91
- ### Tasks
92
- 1. [research] Root cause analysis @cache(1d)
93
- 2. [code:fix] Fix [bug] @isolated([file_path])
94
- 3. [test] Add regression tests @isolated([file_path])
95
- ```
96
-
97
- ### Code Refactor
98
- ```markdown
99
- ## TaskGroup: [Refactor Goal]
100
- ### Meta
101
- - parallel_limit: 1
102
- - review_level: strict
103
- - on_failure: stop
104
- ### Tasks
105
- 1. [research] Analyze dependencies
106
- 2. [code:refactor] Refactor core structure
107
- 3. [code:fix] Fix type errors from refactoring
108
- 4. [test] Run full test suite
109
- ```
110
-
111
- ### Research
112
- ```markdown
113
- ## TaskGroup: [Research Topic]
114
- ### Meta
115
- - parallel_limit: 5
116
- - review_level: light
117
- - on_failure: continue
118
- ### Tasks
119
- 1. [research] Research [option A] @cache(7d)
120
- 2. [research] Research [option B] @cache(7d)
121
- 3. [research] Compare A and B @depends(1,2)
122
- 4. [doc:write] Write conclusion document
123
- ```
1
+ # Task Types & Scheduling
2
+
3
+ ## Task Types
4
+
5
+ | Type | ID | Strategy | Review Level | Description |
6
+ |------|-----|---------|------------|------|
7
+ | Code Development | `code:dev` | `isolated` | strict | Serial within module, parallel across modules |
8
+ | Code Fix | `code:fix` | `isolated` | standard | Serial within file |
9
+ | Code Refactor | `code:refactor` | `serial` | strict | Global serial, large impact |
10
+ | Doc Writing | `doc:write` | `parallel` | light | Fully parallel |
11
+ | Doc Translation | `doc:translate` | `parallel` | light | Fully parallel |
12
+ | Research | `research` | `parallel` | light | Fully parallel, supports caching |
13
+ | Data Processing | `data` | `isolated` | standard | Isolated by data source |
14
+ | Testing | `test` | `parallel` | standard | Fully parallel |
15
+
16
+ ## Scheduling Strategies
17
+
18
+ - **parallel** — Fully parallel, no restrictions (bounded by parallel_limit)
19
+ - **isolated** — Group by isolation key; serial within group, parallel between groups
20
+ - **serial** — Global lock, one task at a time
21
+
22
+ ## Max Parallelism: 5
23
+
24
+ ## Task Declaration Syntax
25
+
26
+ ```markdown
27
+ ## TaskGroup: <group name>
28
+
29
+ ### Meta
30
+ - parallel_limit: 5
31
+ - review_level: standard
32
+ - on_failure: continue | stop
33
+
34
+ ### Tasks
35
+ 1. [code:dev] Implement auth module @isolated(auth/)
36
+ 2. [code:dev] Implement order module @isolated(order/)
37
+ 3. [doc:write] Write API docs
38
+ 4. [research] Research payment gateway @cache(7d)
39
+ ```
40
+
41
+ | Element | Format | Description |
42
+ |---------|--------|-------------|
43
+ | Task type | `[type:subtype]` | Type identifier in brackets |
44
+ | Isolation key | `@isolated(key)` | Grouping key for isolation |
45
+ | Cache | `@cache(duration)` | Cache TTL for research tasks |
46
+ | Dependency | `@depends(task_id)` | Prerequisite task dependency |
47
+
48
+ ## Fullstack Parallel Strategy
49
+
50
+ ```
51
+ ┌─────────────┐
52
+ │ API Contract │
53
+ └──────┬──────┘
54
+
55
+ ┌─────────┴─────────┐
56
+ ↓ ↓
57
+ ┌─────────┐ ┌─────────┐
58
+ │ Frontend │ │ Backend │
59
+ │ (Mock) │ │ (API) │
60
+ └────┬────┘ └────┬────┘
61
+ └────────┬──────┘
62
+
63
+ ┌─────────────┐
64
+ │ Integration │
65
+ └─────────────┘
66
+ ```
67
+
68
+ ## Templates
69
+
70
+ ### Code Development
71
+ ```markdown
72
+ ## TaskGroup: [Feature Name]
73
+ ### Meta
74
+ - parallel_limit: 5
75
+ - review_level: strict
76
+ - on_failure: continue
77
+ ### Tasks
78
+ 1. [code:dev] Implement [module] core logic @isolated([module]/)
79
+ 2. [code:dev] Implement [module] UI components @isolated([module]/)
80
+ 3. [code:dev] Implement [module] API layer @isolated([module]/api/)
81
+ 4. [test] Write [module] unit tests @isolated([module]/)
82
+ ```
83
+
84
+ ### Code Fix
85
+ ```markdown
86
+ ## TaskGroup: [Bug Description]
87
+ ### Meta
88
+ - parallel_limit: 3
89
+ - review_level: standard
90
+ - on_failure: stop
91
+ ### Tasks
92
+ 1. [research] Root cause analysis @cache(1d)
93
+ 2. [code:fix] Fix [bug] @isolated([file_path])
94
+ 3. [test] Add regression tests @isolated([file_path])
95
+ ```
96
+
97
+ ### Code Refactor
98
+ ```markdown
99
+ ## TaskGroup: [Refactor Goal]
100
+ ### Meta
101
+ - parallel_limit: 1
102
+ - review_level: strict
103
+ - on_failure: stop
104
+ ### Tasks
105
+ 1. [research] Analyze dependencies
106
+ 2. [code:refactor] Refactor core structure
107
+ 3. [code:fix] Fix type errors from refactoring
108
+ 4. [test] Run full test suite
109
+ ```
110
+
111
+ ### Research
112
+ ```markdown
113
+ ## TaskGroup: [Research Topic]
114
+ ### Meta
115
+ - parallel_limit: 5
116
+ - review_level: light
117
+ - on_failure: continue
118
+ ### Tasks
119
+ 1. [research] Research [option A] @cache(7d)
120
+ 2. [research] Research [option B] @cache(7d)
121
+ 3. [research] Compare A and B @depends(1,2)
122
+ 4. [doc:write] Write conclusion document
123
+ ```
@@ -1,29 +1,29 @@
1
- # 代码开发任务模板
2
-
3
- ```markdown
4
- ## TaskGroup: [功能名称]
5
-
6
- ### Meta
7
- - parallel_limit: 5
8
- - review_level: strict
9
- - on_failure: continue
10
-
11
- ### Tasks
12
- 1. [code:dev] 实现 [模块名] 核心逻辑 @isolated([module]/)
13
- 2. [code:dev] 实现 [模块名] UI 组件 @isolated([module]/)
14
- 3. [code:dev] 实现 [模块名] API 接口层 @isolated([module]/api/)
15
- 4. [test] 编写 [模块名] 单元测试 @isolated([module]/)
16
- ```
17
-
18
- ## 使用说明
19
-
20
- - **并行策略**: `isolated` — 同模块内串行执行,跨模块并行
21
- - **Review 级别**: `strict` — 新功能需严格审查
22
- - **隔离键**: 使用模块路径作为隔离键,如 `@isolated(auth/)`
23
-
24
- ## 注意事项
25
-
26
- - 同一模块的 UI 和逻辑建议串行(共享隔离键)
27
- - 不同模块可并行开发
28
- - 确保接口契约在实现前确定
29
- - 新功能必须附带测试任务
1
+ # 代码开发任务模板
2
+
3
+ ```markdown
4
+ ## TaskGroup: [功能名称]
5
+
6
+ ### Meta
7
+ - parallel_limit: 5
8
+ - review_level: strict
9
+ - on_failure: continue
10
+
11
+ ### Tasks
12
+ 1. [code:dev] 实现 [模块名] 核心逻辑 @isolated([module]/)
13
+ 2. [code:dev] 实现 [模块名] UI 组件 @isolated([module]/)
14
+ 3. [code:dev] 实现 [模块名] API 接口层 @isolated([module]/api/)
15
+ 4. [test] 编写 [模块名] 单元测试 @isolated([module]/)
16
+ ```
17
+
18
+ ## 使用说明
19
+
20
+ - **并行策略**: `isolated` — 同模块内串行执行,跨模块并行
21
+ - **Review 级别**: `strict` — 新功能需严格审查
22
+ - **隔离键**: 使用模块路径作为隔离键,如 `@isolated(auth/)`
23
+
24
+ ## 注意事项
25
+
26
+ - 同一模块的 UI 和逻辑建议串行(共享隔离键)
27
+ - 不同模块可并行开发
28
+ - 确保接口契约在实现前确定
29
+ - 新功能必须附带测试任务
@@ -1,28 +1,28 @@
1
- # 代码修复任务模板
2
-
3
- ```markdown
4
- ## TaskGroup: [Bug 描述]
5
-
6
- ### Meta
7
- - parallel_limit: 3
8
- - review_level: standard
9
- - on_failure: stop
10
-
11
- ### Tasks
12
- 1. [research] 定位 [Bug 描述] 根因 @cache(1d)
13
- 2. [code:fix] 修复 [Bug 描述] @isolated([file_path])
14
- 3. [test] 补充回归测试 @isolated([file_path])
15
- ```
16
-
17
- ## 使用说明
18
-
19
- - **并行策略**: `isolated` — 同文件串行
20
- - **Review 级别**: `standard`
21
- - **on_failure**: `stop` — 修复失败应立即停止
22
-
23
- ## 注意事项
24
-
25
- - 先调研再修复,避免盲目改代码
26
- - 修复和测试使用相同隔离键(同文件)
27
- - 修复后必须补充回归测试
28
- - 如涉及多文件,每个文件用独立隔离键
1
+ # 代码修复任务模板
2
+
3
+ ```markdown
4
+ ## TaskGroup: [Bug 描述]
5
+
6
+ ### Meta
7
+ - parallel_limit: 3
8
+ - review_level: standard
9
+ - on_failure: stop
10
+
11
+ ### Tasks
12
+ 1. [research] 定位 [Bug 描述] 根因 @cache(1d)
13
+ 2. [code:fix] 修复 [Bug 描述] @isolated([file_path])
14
+ 3. [test] 补充回归测试 @isolated([file_path])
15
+ ```
16
+
17
+ ## 使用说明
18
+
19
+ - **并行策略**: `isolated` — 同文件串行
20
+ - **Review 级别**: `standard`
21
+ - **on_failure**: `stop` — 修复失败应立即停止
22
+
23
+ ## 注意事项
24
+
25
+ - 先调研再修复,避免盲目改代码
26
+ - 修复和测试使用相同隔离键(同文件)
27
+ - 修复后必须补充回归测试
28
+ - 如涉及多文件,每个文件用独立隔离键
@@ -1,30 +1,30 @@
1
- # 代码重构任务模板
2
-
3
- ```markdown
4
- ## TaskGroup: [重构目标]
5
-
6
- ### Meta
7
- - parallel_limit: 1
8
- - review_level: strict
9
- - on_failure: stop
10
-
11
- ### Tasks
12
- 1. [research] 分析当前 [模块] 的问题和依赖关系
13
- 2. [code:refactor] 重构 [模块] 核心结构
14
- 3. [code:fix] 修复重构引入的类型错误
15
- 4. [test] 运行全量测试确认无回归
16
- ```
17
-
18
- ## 使用说明
19
-
20
- - **并行策略**: `serial` — 强制串行,影响范围大
21
- - **Review 级别**: `strict` — 重构需严格审查
22
- - **on_failure**: `stop` — 重构出错应立即停止
23
-
24
- ## 注意事项
25
-
26
- - 重构任务必须串行执行,避免冲突
27
- - 先分析依赖关系,确定影响范围
28
- - 重构后必须运行全量测试
29
- - 大范围重构建议拆分为多个小步骤
30
- - 每步重构后验证编译通过再继续
1
+ # 代码重构任务模板
2
+
3
+ ```markdown
4
+ ## TaskGroup: [重构目标]
5
+
6
+ ### Meta
7
+ - parallel_limit: 1
8
+ - review_level: strict
9
+ - on_failure: stop
10
+
11
+ ### Tasks
12
+ 1. [research] 分析当前 [模块] 的问题和依赖关系
13
+ 2. [code:refactor] 重构 [模块] 核心结构
14
+ 3. [code:fix] 修复重构引入的类型错误
15
+ 4. [test] 运行全量测试确认无回归
16
+ ```
17
+
18
+ ## 使用说明
19
+
20
+ - **并行策略**: `serial` — 强制串行,影响范围大
21
+ - **Review 级别**: `strict` — 重构需严格审查
22
+ - **on_failure**: `stop` — 重构出错应立即停止
23
+
24
+ ## 注意事项
25
+
26
+ - 重构任务必须串行执行,避免冲突
27
+ - 先分析依赖关系,确定影响范围
28
+ - 重构后必须运行全量测试
29
+ - 大范围重构建议拆分为多个小步骤
30
+ - 每步重构后验证编译通过再继续