Files
2026-06-06 10:40:48 +08:00

213 lines
6.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Software Generator
> 需求文本 → 可发布软件。一条命令,370ms。
7 个 Agent 组成的端到端软件生成管线,从自然语言需求到可发布的桌面应用。
## 快速开始
```bash
# 生成完整项目(以 PetCare 为例)
node scripts/project-intake-agent.mjs --input "做一个宠物护理管理平台" --output /tmp/petcare/prd.json
node scripts/architecture-agent.mjs --input /tmp/petcare/prd.json --output /tmp/petcare/arch.json
node scripts/frontend-builder-agent.mjs --prd /tmp/petcare/prd.json --arch /tmp/petcare/arch.json --output /tmp/petcare/frontend
node scripts/backend-builder-agent.mjs --prd /tmp/petcare/prd.json --arch /tmp/petcare/arch.json --output /tmp/petcare/backend
node scripts/fullstack-composer-agent.mjs --prd /tmp/petcare/prd.json --arch /tmp/petcare/arch.json --output /tmp/petcare/fullstack
node scripts/electron-builder-agent.mjs --input /tmp/petcare/fullstack --output /tmp/petcare/electron --prd /tmp/petcare/prd.json
node scripts/release-builder-agent.mjs --input /tmp/petcare/fullstack --output /tmp/petcare/release
```
## 架构
```
需求文本
↓ SF-01 project-intake-agent
PRD JSON
↓ SF-02 architecture-agent
Architecture JSON
↓ SF-03 frontend-builder-agent
Web Frontend (Next.js)
↓ SF-04 backend-builder-agent
API Backend (Express + SQLite)
↓ SF-05 fullstack-composer-agent
Fullstack Monorepo
↓ SF-06 electron-builder-agent
Desktop App (Electron)
↓ SF-07 release-builder-agent
Release Package
```
## 7 个 Agent
| Agent | 文件 | 职责 |
|-------|------|------|
| SF-01 | `scripts/project-intake-agent.mjs` | 需求分析 → PRD JSON |
| SF-02 | `scripts/architecture-agent.mjs` | PRD → 架构设计 |
| SF-03 | `scripts/frontend-builder-agent.mjs` | PRD + 架构 → Next.js 前端 |
| SF-04 | `scripts/backend-builder-agent.mjs` | PRD + 架构 → Express 后端 |
| SF-05 | `scripts/fullstack-composer-agent.mjs` | 前端 + 后端 → Monorepo |
| SF-06 | `scripts/electron-builder-agent.mjs` | 全栈项目 → Electron 桌面应用 |
| SF-07 | `scripts/release-builder-agent.mjs` | 桌面应用 → Release 包 |
## 各 Agent 用法
### SF-01 — 需求分析
```bash
node scripts/project-intake-agent.mjs --input "需求描述" --output prd.json
node scripts/project-intake-agent.mjs --input prd.md --output prd.json # 从文件读取
```
输出: `prd.json` — 包含 projectName, domain, features, pages, apiRequirements, personas, userStories
### SF-02 — 架构设计
```bash
node scripts/architecture-agent.mjs --input prd.json --output arch.json
```
输出: `arch.json` — 包含 modules, dataFlows, directoryStructure, databaseSchema, apiDesign
### SF-03 — 前端生成
```bash
node scripts/frontend-builder-agent.mjs --prd prd.json --arch arch.json --output frontend/
```
输出: Next.js 项目 — app/, components/, hooks/, services/, types/
### SF-04 — 后端生成
```bash
node scripts/backend-builder-agent.mjs --prd prd.json --arch arch.json --output backend/
```
输出: Express + SQLite 项目 — src/routes/, src/services/, src/db/, src/middleware/
### SF-05 — 全栈组装
```bash
node scripts/fullstack-composer-agent.mjs --prd prd.json --arch arch.json --output fullstack/
```
输出: Monorepo — apps/web/, apps/api/, packages/shared-types/, packages/shared-config/
### SF-06 — 桌面封装
```bash
node scripts/electron-builder-agent.mjs --input fullstack/ --output electron/ --prd prd.json
```
输出: Electron 项目 — electron/main.ts, preload.ts, ipc.ts, tray.ts, updater.ts
### SF-07 — 发布打包
```bash
node scripts/release-builder-agent.mjs --input fullstack/ --output release/
```
输出: Release 包 — version.json, manifest.json, checksums.txt, release-notes.md, build-info.json, windows/, macos/, linux/
## 输出结构
### Fullstack Monorepo
```
fullstack/
├── apps/
│ ├── web/ # Next.js 前端
│ │ ├── app/ # 页面路由
│ │ ├── components/
│ │ ├── hooks/
│ │ ├── services/
│ │ └── types/
│ └── api/ # Express 后端
│ └── src/
│ ├── routes/
│ ├── services/
│ ├── db/
│ └── middleware/
├── packages/
│ ├── shared-types/
│ └── shared-config/
└── package.json
```
### Release Package
```
release/
├── version.json # 版本元数据
├── build-info.json # 构建环境信息
├── README.md
├── manifests/
│ └── manifest.json # 文件列表 + SHA256
├── checksums/
│ └── checksums.txt # SHA256 校验
├── release-notes/
│ └── release-notes.md # 发布说明
├── windows/ # Windows 安装器占位
├── macos/ # macOS DMG 占位
└── linux/ # Linux AppImage 占位
```
## 测试
```bash
# 单元测试(各 Agent
node --test test/project-intake-agent.test.mjs
node --test test/architecture-agent.test.mjs
node --test test/frontend-builder-agent.test.mjs
node --test test/backend-builder-agent.test.mjs
node --test test/fullstack-composer-agent.test.mjs
node --test test/electron-builder-agent.test.mjs
node --test test/release-builder-agent.test.mjs
# E2E 回归测试(10 领域 × 7 阶段 = 170 检查)
node --test test/e2e-regression.test.mjs
```
## Benchmark
```bash
# E2E Benchmark10 领域全量)
node scripts/e2e-benchmark-v1.mjs
# 单领域 Benchmark
node scripts/domain-benchmark.mjs --domain petcare
# Release Benchmark
node scripts/release-benchmark.mjs
```
## 技术栈
| 层 | 技术 |
|---|------|
| 前端 | Next.js 15 + React 19 + Tailwind CSS 4 |
| 后端 | Express + better-sqlite3 + JWT |
| 桌面 | Electron 35 + electron-builder |
| 测试 | Node.js built-in test runner |
## 已验证领域
| 领域 | 特性 | 页面 | API | 文件 |
|------|------|------|-----|------|
| PetCare | 7 | 6 | 5 | 162 |
| CRM | 5 | 4 | 5 | 144 |
| Inventory | 6 | 5 | 6 | 164 |
| Ticket | 7 | 5 | 6 | 162 |
| Blog CMS | 5 | 3 | 3 | 136 |
| Project Mgmt | 5 | 4 | 5 | 126 |
| HR | 7 | 5 | 6 | 162 |
| Asset | 5 | 4 | 5 | 126 |
| Course | 6 | 5 | 6 | 158 |
| Appointment | 5 | 4 | 5 | 126 |
## 里程碑
- **v1.0.0-mvp** — Software Generator MVP v1 (2026-06-05)
- 7 Agents, 7,941 LoC
- 10/10 领域 E2E PASS
- 170/170 回归测试 PASS