Skip to content

Commit 234aa44

Browse files
committed
v13.0: 社区经验库+商业化基础设施(A/B/C/D全部完成)
Made-with: Cursor
1 parent 476b4e3 commit 234aa44

62 files changed

Lines changed: 6234 additions & 342 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
1-
# TestPilot AI 环境变量配置
2-
# 复制此文件为 .env 并填入实际值
1+
# ═══════════════════════════════════════════════════════
2+
# TestPilot AI — 环境变量配置
3+
# ═══════════════════════════════════════════════════════
4+
#
5+
# 使用方式:cp .env.example .env && 编辑 .env
6+
# 注意:.env 文件已在 .gitignore 中,不会被提交
7+
#
8+
# ── 数据库 ──────────────────────────────────────
9+
# 本地开发可不设置(默认使用 SQLite)
10+
# 生产部署使用 PostgreSQL:
11+
# DATABASE_URL=postgresql://testpilot:你的密码@db:5432/testpilot
12+
DB_PASSWORD=changeme_use_strong_password
313

4-
# ── 服务配置 ──
5-
TP_SERVER_HOST=127.0.0.1
6-
TP_SERVER_PORT=8900
7-
TP_SERVER_RELOAD=true
8-
TP_SERVER_LOG_LEVEL=DEBUG
9-
10-
# ── 沙箱配置 ──
11-
TP_SANDBOX_IMAGE=ghcr.io/agent-infra/sandbox:latest
12-
TP_SANDBOX_APP_PORT=3000
13-
14-
# ── 浏览器配置 ──
15-
TP_BROWSER_HEADLESS=true
16-
TP_BROWSER_VIEWPORT_WIDTH=1280
17-
TP_BROWSER_VIEWPORT_HEIGHT=720
14+
# ── 认证 ────────────────────────────────────────
15+
# JWT 签名密钥(必须设置,建议 32+ 位随机字符串)
16+
# 生成方法:python -c "import secrets; print(secrets.token_urlsafe(32))"
17+
JWT_SECRET_KEY=changeme_generate_with_secrets_module
1818

19-
# ── AI API 配置(必填) ──
20-
# 方舟平台 API 密钥(通过 OpenAI SDK 兼容接口调用
21-
TP_AI_API_KEY=你的方舟平台API密钥
19+
# ── AI 服务 ─────────────────────────────────────
20+
# 方舟平台 API 密钥(不配置则 AI 测试功能不可用
21+
TP_AI_API_KEY=
2222
TP_AI_API_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
23-
# Doubao-Seed-1.8 统一模型(文本生成 + 视觉理解 + Agent)
2423
TP_AI_MODEL=doubao-seed-1-8-251228
2524
# 思考深度:minimal / low / medium / high
2625
TP_AI_REASONING_EFFORT=medium
2726

28-
# ── 调试模式 ──
29-
DEBUG=false
27+
# ── 服务器 ──────────────────────────────────────
28+
TP_SERVER_HOST=127.0.0.1
29+
TP_SERVER_PORT=8900
30+
TP_SERVER_LOG_LEVEL=INFO
31+
32+
# ── 支付(预留) ────────────────────────────────
33+
# 支付宝/微信支付/Stripe 回调验签密钥
34+
PAYMENT_WEBHOOK_SECRET=
35+
36+
# ── 管理后台 ────────────────────────────────────
37+
# 管理员初始密码(首次部署后请立即修改)
38+
ADMIN_INITIAL_PASSWORD=changeme_admin_2026

Dockerfile

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
1-
# TestPilot AI CI Runner 镜像(v4.0)
1+
# TestPilot AI — API 服务镜像
22
#
3-
# 用途:CI/CD 环境中运行 TestPilot AI 测试
4-
#
5-
# 构建:docker build -t testpilot/runner .
6-
# 使用:docker run --rm -v ./testpilot.json:/app/blueprint.json testpilot/runner run -b /app/blueprint.json
3+
# 多阶段构建:
4+
# Stage 1: 安装 Python 依赖
5+
# Stage 2: 精简运行镜像
76
#
7+
# 构建:docker build -t testpilot/api .
8+
# 运行:docker run --env-file .env -p 8900:8900 testpilot/api
9+
10+
# ── Stage 1: 依赖安装 ────────────────────────────
11+
FROM python:3.11-slim AS builder
12+
13+
RUN pip install --no-cache-dir poetry
14+
15+
WORKDIR /build
16+
COPY pyproject.toml poetry.lock* ./
17+
18+
RUN poetry config virtualenvs.create false \
19+
&& poetry install --no-interaction --no-root --only main
820

21+
# ── Stage 2: 运行镜像 ────────────────────────────
922
FROM python:3.11-slim
1023

11-
# 安装系统依赖(Playwright 需要)
1224
RUN apt-get update && apt-get install -y --no-install-recommends \
1325
curl \
1426
&& rm -rf /var/lib/apt/lists/*
1527

16-
# 安装 Poetry
17-
RUN pip install --no-cache-dir poetry
28+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
29+
COPY --from=builder /usr/local/bin /usr/local/bin
1830

1931
WORKDIR /app
32+
COPY src/ ./src/
33+
COPY alembic/ ./alembic/
34+
COPY alembic.ini cli.py main.py pyproject.toml ./
2035

21-
# 复制依赖文件
22-
COPY pyproject.toml poetry.lock* ./
36+
RUN mkdir -p /app/data
2337

24-
# 安装 Python 依赖
25-
RUN poetry config virtualenvs.create false \
26-
&& poetry install --no-interaction --no-root
38+
ENV PYTHONUNBUFFERED=1
39+
ENV TP_SERVER_HOST=0.0.0.0
40+
ENV TP_SERVER_PORT=8900
2741

28-
# 安装 Playwright 浏览器
29-
RUN playwright install chromium \
30-
&& playwright install-deps chromium
31-
32-
# 复制项目文件
33-
COPY . .
34-
35-
# 暴露引擎端口
3642
EXPOSE 8900
3743

38-
# 默认命令:启动引擎
39-
ENTRYPOINT ["python", "cli.py"]
40-
CMD ["serve", "--host", "0.0.0.0"]
44+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
45+
CMD curl -f http://localhost:8900/api/v1/health || exit 1
46+
47+
CMD ["python", "-m", "uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8900"]

PROGRESS.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TestPilot AI — 进度备忘录
22

3-
> 最后更新:2026-03-13
3+
> 最后更新:2026-03-15(v13.0 社区经验库+商业化 开始)
44
55
---
66

@@ -38,30 +38,40 @@
3838

3939
---
4040

41-
## 📋 下次继续(待办)
42-
43-
### 高优先
44-
- [ ] **Phase 2: AI自动评估分享价值 + 弹窗推荐**
45-
- 测试完成后,如果发现Bug+Fix记录,AI自动算分享价值(已有calc_share_score)
46-
- 超过阈值(如≥5分)弹窗询问用户是否分享到经验库
47-
- 文件:`src/community/anonymizer.py` + 插件弹窗逻辑
48-
49-
- [ ] **桌面测试state隔离**
50-
- 每次测试前通过`app_exe`参数重启被测应用,确保状态干净
51-
- MCP工具`run_desktop_test`需要支持`app_exe`参数
52-
53-
### 中优先
54-
- [ ] **插件自动闭环开关**
55-
- 测试→发现Bug→AI自动修复→重测→直到Bug=0
56-
- 需要`auto_repair`开关 + 循环测试逻辑
57-
58-
- [ ] **OCR进一步优化(可选)**
59-
- 坐标分析时同时顺带返回页面文字(一次API调用返回坐标+文字)
60-
- 需要改prompt格式,解析逻辑要处理混合输出
61-
62-
### 低优先
63-
- [ ] **桌面应用打包**`cargo tauri build`(Rust已配置在D:\DevEnv)
64-
- [ ] **Web测试截图优化** — 类似桌面hash缓存机制
41+
## 📋 当前重点(v13.0 社区经验库+商业化)
42+
43+
### 🔴 最高优先(v13.0-A/B 在Windows上做)
44+
- [ ] **Step 1-3: 社区数据模型+Alembic+PG驱动**
45+
- 新建 `src/community/models.py`(6张表)
46+
- 添加 alembic + psycopg2-binary 依赖
47+
- 生成第一个迁移脚本
48+
- [ ] **Step 4-6: 社区服务层+API路由+测试**
49+
- 新建 `src/community/service.py`(20+函数)
50+
- 新建 `src/community/routes.py`(15个端点)
51+
- 新建 `tests/test_community.py`(≥30个用例)
52+
- [ ] **Step 7-15: Web门户**
53+
- 新建 `web/` React项目(8个页面)
54+
- 重点页面:用户主页(勋章墙+贡献统计+经验列表+平台雷达图)
55+
- FastAPI集成 或 Nginx独立部署
56+
57+
### 🔴 高优先(v13.0-C/D)
58+
- [ ] **Step 16-18: 插件社区对接**
59+
- 后端API已有→插件自动生效
60+
- 测试后分享推荐弹窗
61+
- 勋章展示+社区搜索
62+
- [ ] **Step 19-24: 部署+积分**
63+
- Docker Compose(PG+API+Web)
64+
- 积分系统(余额/消费/充值)
65+
- 支付接口预留
66+
67+
### 🍎 并行(Mac上做)
68+
- [ ] **v13.0-E: Mac/iOS平台控制器**(不在Windows上改动)
69+
70+
### 保留待办(优先级降低)
71+
- [ ] 桌面测试state隔离
72+
- [ ] 插件自动闭环开关
73+
- [ ] OCR进一步优化
74+
- [ ] 桌面应用打包
6575

6676
---
6777

alembic.ini

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts.
5+
# this is typically a path given in POSIX (e.g. forward slashes)
6+
# format, relative to the token %(here)s which refers to the location of this
7+
# ini file
8+
script_location = %(here)s/alembic
9+
10+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
11+
# Uncomment the line below if you want the files to be prepended with date and time
12+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
13+
# for all available tokens
14+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
15+
# Or organize into date-based subdirectories (requires recursive_version_locations = true)
16+
# file_template = %%(year)d/%%(month).2d/%%(day).2d_%%(hour).2d%%(minute).2d_%%(second).2d_%%(rev)s_%%(slug)s
17+
18+
# sys.path path, will be prepended to sys.path if present.
19+
# defaults to the current working directory. for multiple paths, the path separator
20+
# is defined by "path_separator" below.
21+
prepend_sys_path = .
22+
23+
24+
# timezone to use when rendering the date within the migration file
25+
# as well as the filename.
26+
# If specified, requires the tzdata library which can be installed by adding
27+
# `alembic[tz]` to the pip requirements.
28+
# string value is passed to ZoneInfo()
29+
# leave blank for localtime
30+
# timezone =
31+
32+
# max length of characters to apply to the "slug" field
33+
# truncate_slug_length = 40
34+
35+
# set to 'true' to run the environment during
36+
# the 'revision' command, regardless of autogenerate
37+
# revision_environment = false
38+
39+
# set to 'true' to allow .pyc and .pyo files without
40+
# a source .py file to be detected as revisions in the
41+
# versions/ directory
42+
# sourceless = false
43+
44+
# version location specification; This defaults
45+
# to <script_location>/versions. When using multiple version
46+
# directories, initial revisions must be specified with --version-path.
47+
# The path separator used here should be the separator specified by "path_separator"
48+
# below.
49+
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
50+
51+
# path_separator; This indicates what character is used to split lists of file
52+
# paths, including version_locations and prepend_sys_path within configparser
53+
# files such as alembic.ini.
54+
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
55+
# to provide os-dependent path splitting.
56+
#
57+
# Note that in order to support legacy alembic.ini files, this default does NOT
58+
# take place if path_separator is not present in alembic.ini. If this
59+
# option is omitted entirely, fallback logic is as follows:
60+
#
61+
# 1. Parsing of the version_locations option falls back to using the legacy
62+
# "version_path_separator" key, which if absent then falls back to the legacy
63+
# behavior of splitting on spaces and/or commas.
64+
# 2. Parsing of the prepend_sys_path option falls back to the legacy
65+
# behavior of splitting on spaces, commas, or colons.
66+
#
67+
# Valid values for path_separator are:
68+
#
69+
# path_separator = :
70+
# path_separator = ;
71+
# path_separator = space
72+
# path_separator = newline
73+
#
74+
# Use os.pathsep. Default configuration used for new projects.
75+
path_separator = os
76+
77+
# set to 'true' to search source files recursively
78+
# in each "version_locations" directory
79+
# new in Alembic version 1.10
80+
# recursive_version_locations = false
81+
82+
# the output encoding used when revision files
83+
# are written from script.py.mako
84+
# output_encoding = utf-8
85+
86+
# database URL. This is consumed by the user-maintained env.py script only.
87+
# other means of configuring database URLs may be customized within the env.py
88+
# file.
89+
sqlalchemy.url = driver://user:pass@localhost/dbname
90+
91+
92+
[post_write_hooks]
93+
# post_write_hooks defines scripts or Python functions that are run
94+
# on newly generated revision scripts. See the documentation for further
95+
# detail and examples
96+
97+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
98+
# hooks = black
99+
# black.type = console_scripts
100+
# black.entrypoint = black
101+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
102+
103+
# lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
104+
# hooks = ruff
105+
# ruff.type = module
106+
# ruff.module = ruff
107+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
108+
109+
# Alternatively, use the exec runner to execute a binary found on your PATH
110+
# hooks = ruff
111+
# ruff.type = exec
112+
# ruff.executable = ruff
113+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
114+
115+
# Logging configuration. This is also consumed by the user-maintained
116+
# env.py script only.
117+
[loggers]
118+
keys = root,sqlalchemy,alembic
119+
120+
[handlers]
121+
keys = console
122+
123+
[formatters]
124+
keys = generic
125+
126+
[logger_root]
127+
level = WARNING
128+
handlers = console
129+
qualname =
130+
131+
[logger_sqlalchemy]
132+
level = WARNING
133+
handlers =
134+
qualname = sqlalchemy.engine
135+
136+
[logger_alembic]
137+
level = INFO
138+
handlers =
139+
qualname = alembic
140+
141+
[handler_console]
142+
class = StreamHandler
143+
args = (sys.stderr,)
144+
level = NOTSET
145+
formatter = generic
146+
147+
[formatter_generic]
148+
format = %(levelname)-5.5s [%(name)s] %(message)s
149+
datefmt = %H:%M:%S

alembic/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic single-database configuration.

0 commit comments

Comments
 (0)