App-templates: LLM auto-selects project template based on user requirement

- Add webapp template (FastAPI + SQLite) with INSTRUCTIONS.md and setup.sh
- select_template() scans templates, asks LLM to match; apply_template() copies to workspace
- ensure_workspace() runs setup.sh if present, otherwise falls back to default venv
- INSTRUCTIONS.md injected into planning and execution prompts
- Fix pre-existing clippy warning in kb.rs (filter_map → map)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 21:33:40 +00:00
parent 837977cd17
commit ee4a5dfc95
7 changed files with 281 additions and 18 deletions

View File

@@ -0,0 +1,31 @@
# 项目模板Web 应用 (FastAPI + SQLite)
## 技术栈
- **后端**Python FastAPI
- **数据库**SQLite通过 aiosqlite 异步访问)
- **前端**:单页 HTML + 原生 JavaScript内嵌在 Python 中或作为静态文件)
- **包管理**uv
## 项目结构约定
```
app.py # FastAPI 主应用(入口)
database.py # 数据库初始化和模型(可选,小项目可放在 app.py
static/ # 静态文件目录(可选)
```
## 关键约定
1. **入口文件**`app.py`FastAPI 应用实例命名为 `app`
2. **启动命令**`uvicorn app:app --host 0.0.0.0 --port $PORT`
3. **数据库**:使用 SQLite数据库文件放在工作区根目录`data.db`
4. **依赖安装**:使用 `uv add <包名>` 安装依赖
5. **前端**:优先使用单文件 HTML通过 FastAPI 的 `HTMLResponse` 返回或放在 `static/` 目录
6. **API 路径**:应用通过反向代理 `/api/projects/{project_id}/app/` 访问,前端 JS 中的 fetch 必须使用相对路径(如 `fetch('items')`,不要用 `fetch('/items')`
## 注意事项
- venv 已在 `.venv/` 中预先创建,直接使用即可
- 不要使用 `pip install`,使用 `uv add` 管理依赖
- SQLite 不需要额外服务,适合单机应用

View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -e
# Create venv if not exists (idempotent)
if [ ! -d ".venv" ]; then
uv venv .venv
fi

View File

@@ -0,0 +1,5 @@
{
"name": "Web 应用",
"description": "FastAPI + SQLite 的 Web 应用",
"match_hint": "需要前后端、Web 界面、HTTP API、数据库的应用类项目"
}