ai-spec-dev 0.42.0 → 0.46.0
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 +33 -17
- package/cli/commands/create.ts +232 -11
- package/cli/commands/init.ts +310 -107
- package/cli/commands/model.ts +7 -11
- package/cli/index.ts +1 -1
- package/cli/utils.ts +72 -4
- package/core/config-defaults.ts +44 -0
- package/core/constitution-generator.ts +2 -1
- package/core/dsl-extractor.ts +2 -1
- package/core/error-feedback.ts +3 -2
- package/core/openapi-exporter.ts +3 -2
- package/core/repo-store.ts +95 -0
- package/core/reviewer.ts +14 -13
- package/core/run-logger.ts +3 -4
- package/core/run-snapshot.ts +2 -3
- package/core/run-trend.ts +3 -4
- package/core/spec-generator.ts +27 -42
- package/core/token-budget.ts +3 -8
- package/core/vcr.ts +3 -1
- package/dist/cli/index.js +919 -519
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +912 -512
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +43 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/demo-backend/.ai-spec-constitution.md +0 -65
- package/demo-backend/package.json +0 -21
- package/demo-backend/prisma/schema.prisma +0 -22
- package/demo-backend/specs/feature-1-bookmark-id-uuid-title-string-required-url-str-v1.dsl.json +0 -186
- package/demo-backend/specs/feature-1-bookmark-id-uuid-title-string-required-url-str-v1.md +0 -211
- package/demo-backend/src/controllers/bookmark.controller.test.ts +0 -255
- package/demo-backend/src/controllers/bookmark.controller.ts +0 -187
- package/demo-backend/src/index.ts +0 -17
- package/demo-backend/src/routes/bookmark.routes.test.ts +0 -264
- package/demo-backend/src/routes/bookmark.routes.ts +0 -11
- package/demo-backend/src/routes/index.ts +0 -8
- package/demo-backend/src/services/bookmark.service.test.ts +0 -433
- package/demo-backend/src/services/bookmark.service.ts +0 -261
- package/demo-backend/tsconfig.json +0 -12
- package/demo-frontend/.ai-spec-constitution.md +0 -95
- package/demo-frontend/package.json +0 -23
- package/demo-frontend/src/App.tsx +0 -12
- package/demo-frontend/src/main.tsx +0 -9
- package/demo-frontend/tsconfig.json +0 -13
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# Project Constitution
|
|
2
|
-
|
|
3
|
-
## 1. 架构规则 (Architecture Rules)
|
|
4
|
-
- **组件分层架构**:页面/组件 → 自定义hooks → 服务层 → API客户端
|
|
5
|
-
- **组件组织**:页面组件位于 `src/pages/`,可复用组件位于 `src/components/`
|
|
6
|
-
- **业务逻辑分离**:所有API调用、数据转换和业务逻辑必须封装在自定义hooks或服务层中
|
|
7
|
-
- **状态管理**:使用React Context或本地状态,禁止直接修改props
|
|
8
|
-
- **类型安全**:所有组件props、API响应和状态必须明确定义TypeScript类型
|
|
9
|
-
|
|
10
|
-
## 2. 命名规范 (Naming Conventions)
|
|
11
|
-
- **文件命名**:
|
|
12
|
-
- 组件文件:PascalCase (`UserProfile.tsx`)
|
|
13
|
-
- Hook文件:camelCase,以`use`开头 (`useAuth.ts`)
|
|
14
|
-
- 工具/服务文件:camelCase (`apiService.ts`)
|
|
15
|
-
- 样式文件:与组件同名,使用CSS模块 (`UserProfile.module.css`)
|
|
16
|
-
- **变量/函数**:
|
|
17
|
-
- 变量/函数:camelCase (`userData`, `fetchUserProfile`)
|
|
18
|
-
- 接口/类型:PascalCase (`UserData`, `ApiResponse`)
|
|
19
|
-
- 常量:UPPER_SNAKE_CASE (`API_BASE_URL`)
|
|
20
|
-
- **组件命名**:PascalCase (`<UserProfile />`)
|
|
21
|
-
- **路由路径**:kebab-case (`/user-profile`, `/admin/dashboard`)
|
|
22
|
-
|
|
23
|
-
## 3. API 规范 (API Patterns)
|
|
24
|
-
- **API客户端**:使用统一的axios实例配置,位于 `src/services/apiClient.ts`
|
|
25
|
-
- **请求模式**:所有API调用必须封装在自定义hooks (`useApi`, `useFetch`) 或服务函数中
|
|
26
|
-
- **响应结构**:
|
|
27
|
-
```typescript
|
|
28
|
-
interface ApiResponse<T> {
|
|
29
|
-
success: boolean;
|
|
30
|
-
data: T;
|
|
31
|
-
message?: string;
|
|
32
|
-
error?: string;
|
|
33
|
-
code?: number;
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
- **错误处理**:统一使用try-catch包装,错误通过状态返回而非抛出异常
|
|
37
|
-
- **认证**:Token存储在localStorage,通过axios拦截器自动添加Authorization头
|
|
38
|
-
- **路由组织**:
|
|
39
|
-
- 公开路由:无需认证 (`/login`, `/register`)
|
|
40
|
-
- 受保护路由:需要认证 (`/dashboard`, `/profile`)
|
|
41
|
-
- 管理员路由:需要特定角色 (`/admin/*`)
|
|
42
|
-
|
|
43
|
-
## 4. 数据层规范 (Data Layer Rules)
|
|
44
|
-
- **状态管理**:
|
|
45
|
-
- 全局状态:React Context + useReducer
|
|
46
|
-
- 本地组件状态:useState
|
|
47
|
-
- 服务端状态:React Query或自定义缓存hooks
|
|
48
|
-
- **数据获取**:所有数据必须通过服务层获取,禁止组件直接调用fetch/axios
|
|
49
|
-
- **类型定义**:所有API请求/响应必须定义在 `src/types/` 目录下
|
|
50
|
-
- **数据转换**:在服务层进行API响应到前端模型的转换
|
|
51
|
-
|
|
52
|
-
## 5. 错误处理规范 (Error Handling Patterns)
|
|
53
|
-
- **全局错误边界**:App组件包裹ErrorBoundary
|
|
54
|
-
- **API错误**:统一在服务层处理,返回标准化错误对象
|
|
55
|
-
- **用户反馈**:通过Toast/Snackbar组件显示错误消息
|
|
56
|
-
- **错误日志**:使用console.error记录,生产环境集成错误监控
|
|
57
|
-
- **表单验证**:使用Formik或React Hook Form进行客户端验证
|
|
58
|
-
|
|
59
|
-
## 6. 禁区 (Red Lines — Never Violate)
|
|
60
|
-
- [ ] **禁止**在组件中直接进行API调用(必须通过hooks/服务层)
|
|
61
|
-
- [ ] **禁止**使用`any`类型(必须明确定义或使用`unknown`)
|
|
62
|
-
- [ ] **禁止**修改传入的props(遵循单向数据流)
|
|
63
|
-
- [ ] **禁止**在组件中编写复杂业务逻辑(必须提取到hooks/服务层)
|
|
64
|
-
- [ ] **禁止**使用内联样式(必须使用CSS模块或styled-components)
|
|
65
|
-
- [ ] **禁止**提交未定义类型的代码
|
|
66
|
-
- [ ] **禁止**直接访问process.env(必须通过配置模块)
|
|
67
|
-
|
|
68
|
-
## 7. 测试规范 (Testing Rules)
|
|
69
|
-
- **测试框架**:Vitest + React Testing Library
|
|
70
|
-
- **测试文件位置**:与源文件同目录,使用`.test.tsx`或`.spec.tsx`后缀
|
|
71
|
-
- **必须测试**:
|
|
72
|
-
- 所有自定义hooks
|
|
73
|
-
- 复杂业务逻辑函数
|
|
74
|
-
- 关键用户交互流程
|
|
75
|
-
- 组件渲染和状态变化
|
|
76
|
-
- **测试结构**:Arrange-Act-Assert模式
|
|
77
|
-
- **Mock策略**:API调用必须mock,使用MSW或手动mock
|
|
78
|
-
- **覆盖率要求**:核心业务逻辑必须>80%
|
|
79
|
-
|
|
80
|
-
## 8. 共享配置文件清单 (Shared Config Files — Append-Only)
|
|
81
|
-
|
|
82
|
-
CRITICAL: The following files are **singleton config files** that already exist in the project.
|
|
83
|
-
When any feature needs to add entries (translations, constants, routes, enums, etc.), they MUST be
|
|
84
|
-
appended/merged into these existing files. **NEVER create a new parallel file.**
|
|
85
|
-
|
|
86
|
-
- `src/constants/apiEndpoints.ts` — API端点配置 — **MODIFY ONLY, never recreate**
|
|
87
|
-
- `src/types/api.d.ts` — API类型定义 — **MODIFY ONLY, never recreate**
|
|
88
|
-
- `src/config/env.ts` — 环境变量配置 — **MODIFY ONLY, never recreate**
|
|
89
|
-
- `src/utils/errorCodes.ts` — 错误码常量 — **MODIFY ONLY, never recreate**
|
|
90
|
-
- `src/services/apiClient.ts` — Axios实例配置 — **MODIFY ONLY, never recreate**
|
|
91
|
-
- `src/routes/index.tsx` — 路由配置 — **MODIFY ONLY, never recreate**
|
|
92
|
-
- `src/hooks/index.ts` — 自定义hooks导出 — **MODIFY ONLY, never recreate**
|
|
93
|
-
- `src/context/index.ts` — Context导出 — **MODIFY ONLY, never recreate**
|
|
94
|
-
|
|
95
|
-
(No i18n/locale files detected — will be populated on first run)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "demo-frontend",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vite",
|
|
7
|
-
"build": "tsc && vite build",
|
|
8
|
-
"test": "vitest run"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"react": "^18.3.1",
|
|
12
|
-
"react-dom": "^18.3.1",
|
|
13
|
-
"axios": "^1.7.0"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"typescript": "^5.7.0",
|
|
17
|
-
"@types/react": "^18.3.0",
|
|
18
|
-
"@types/react-dom": "^18.3.0",
|
|
19
|
-
"vite": "^5.4.0",
|
|
20
|
-
"@vitejs/plugin-react": "^4.3.0",
|
|
21
|
-
"vitest": "^2.1.0"
|
|
22
|
-
}
|
|
23
|
-
}
|