Initial commit: 1人+2AI协作框架 - 完整目录结构和AI宪法

This commit is contained in:
tupingr
2026-05-22 15:27:36 +08:00
commit 837d067928
30 changed files with 1498 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
# P01_errlens_app - 环境准备指南
## 依赖要求
- Node.js >= 20.x
- npm >= 10.x
- 数据库: PostgreSQL 15+
## 安装步骤
```bash
# 安装依赖
npm install
# 配置环境变量
cp .env.example .env
# 初始化数据库
npm run db:migrate
```
## 环境变量
| 变量名 | 说明 | 默认值 |
|--------|------|--------|
| PORT | 服务端口 | 3000 |
| DATABASE_URL | 数据库连接 | postgresql://localhost:5432/errlens |
| NODE_ENV | 运行环境 | development |
## 运行命令
```bash
# 开发模式
npm run dev
# 生产构建
npm run build
# 运行测试
npm test
```
@@ -0,0 +1,21 @@
# P01_errlens_app - 需求概要
## 项目概述
ErrLens 是一个 AI 辅助编程工具,旨在帮助开发者快速定位和修复代码错误。
## 核心功能
1. **错误检测** - 实时分析代码中的潜在问题
2. **智能修复** - 自动生成修复建议
3. **代码审查** - 提供代码质量评估
4. **学习建议** - 根据错误类型提供学习资源
## 用户角色
- 初级开发者:学习编程时获得实时反馈
- 中级开发者:提高代码质量和效率
- 团队负责人:监控团队代码质量
## 技术栈
- 前端:React + TypeScript
- 后端:Node.js + Express
- 数据库:PostgreSQL
- AI 服务:自定义模型 + OpenAI API
@@ -0,0 +1,59 @@
# P01_errlens_app - 架构设计
## 系统架构
采用微服务架构,前后端分离。
### 架构图
```
┌─────────────────────────────────────────────────────┐
│ 前端层 │
│ React + TypeScript + Tailwind CSS │
└──────────────────────┬──────────────────────────────┘
│ HTTP/WebSocket
┌─────────────────────────────────────────────────────┐
│ API网关 │
│ Express + Middleware │
└──────────────────────┬──────────────────────────────┘
┌─────────────────┼─────────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ 代码分析 │ │ AI服务 │ │ 用户管理 │
│ Service │ │ Service │ │ Service │
└──────────┘ └──────────┘ └──────────┘
│ │ │
└─────────────────┼─────────────────┘
┌──────────────┐
│ PostgreSQL │
└──────────────┘
```
## 核心模块
### 1. 代码分析模块
- 解析源代码
- 静态分析检测
- 错误分类与评级
### 2. AI 服务模块
- 调用 AI 模型
- 生成修复建议
- 优化提示词
### 3. 用户管理模块
- 用户认证授权
- 使用统计
- 个性化配置
## 目录结构
```
src/
├── api/ # REST API 路由
├── controllers/ # 业务逻辑
├── services/ # 核心服务
├── models/ # 数据模型
├── middleware/ # 中间件
└── utils/ # 工具函数
```
@@ -0,0 +1,95 @@
# P01_errlens_app - 接口定义
## API 基础路径
`/api/v1`
## 认证方式
JWT Token,放在 Authorization 头:
```
Authorization: Bearer <token>
```
## 接口列表
### 1. 代码分析
#### POST /api/v1/analyze
分析代码中的错误
**请求体:**
```json
{
"code": "string",
"language": "string",
"options": {
"strict": true
}
}
```
**响应:**
```json
{
"success": true,
"errors": [
{
"line": 10,
"column": 5,
"type": "error",
"message": "变量未定义",
"suggestion": "建议在使用前定义变量"
}
]
}
```
### 2. 用户管理
#### POST /api/v1/users/login
用户登录
**请求体:**
```json
{
"email": "string",
"password": "string"
}
```
**响应:**
```json
{
"success": true,
"token": "string",
"user": {
"id": "string",
"email": "string",
"name": "string"
}
}
```
### 3. 修复建议
#### POST /api/v1/fix
获取修复建议
**请求体:**
```json
{
"code": "string",
"error": {
"type": "string",
"message": "string"
}
}
```
**响应:**
```json
{
"success": true,
"fixedCode": "string",
"explanation": "string"
}
```