feat: 新增 vscode_auto_watch 开关,打开项目自动起 watch 任务

- copier.yml 加 vscode_auto_watch 问题(默认 false)+ 条件排除 .vscode/tasks.json
- template/.vscode/tasks.json.jinja:按服务生成 watch 任务,runOn folderOpen
  前端 tsc --watch、后端/agent ruff --watch,均为工具自带 watch,无新依赖
- frontend 加 typecheck:watch 脚本
- README 问卷表补该项
This commit is contained in:
baozaotumao
2026-06-01 21:46:27 -07:00
parent 4c7dbb56eb
commit f927bd4b7a
4 changed files with 58 additions and 0 deletions
+1
View File
@@ -140,6 +140,7 @@ copier copy git+https://github.com/baozaotumao2025/scaffold.git my-new-project
| `database` | choice | sqlite | `sqlite` / `postgresql` |
| `node_version` | choice | 22 | 20 / 22 |
| `llm_provider` | choice | gemini-cli | `gemini-cli` / `openai-api` / `anthropic-api` / `custom` |
| `vscode_auto_watch` | bool | false | VSCode 打开项目自动启动 watch 任务(编码即时查错) |
> `llm_provider` 仅在 `include_agent=true` 时出现。
+9
View File
@@ -35,6 +35,8 @@ _exclude:
- "{% if not (include_backend and include_agent) %}.claude/rules/data-lifecycle.md{% endif %}"
# communication-catalog: 描述服务间 WS 消息,单服务时无跨层通信
- "{% if not (include_backend or include_agent) or not (include_agent or include_frontend) %}.claude/rules/communication-catalog.md{% endif %}"
# ── VSCode 自动 watch(仅 vscode_auto_watch=true 时生成)──────────────────
- "{% if not vscode_auto_watch %}.vscode/tasks.json{% endif %}"
_tasks:
- command: git init
@@ -161,3 +163,10 @@ llm_cmd:
help: LLM CLI 命令(留空则按 provider 默认)
default: "{% if llm_provider == 'gemini-cli' %}gemini{% elif llm_provider == 'openai-api' %}openai{% else %}llm{% endif %}"
when: "{{ include_agent }}"
# ── 编辑器(VSCode)─────────────────────────────────────────────────────────
vscode_auto_watch:
type: bool
help: VSCode 打开项目时自动启动 watch 任务(类型/lint 持续后台检查,编码时即时发现问题)?
default: false
when: "{{ include_backend or include_agent or include_frontend }}"
+47
View File
@@ -0,0 +1,47 @@
// 由 scaffold 生成(vscode_auto_watch=true)。
// 打开项目即在后台启动 watch 任务,编码时持续检查、即时发现问题。
//
// ⚠ 首次使用需授权自动运行:命令面板 → "Tasks: Allow Automatic Tasks"。
// 关闭单个任务:把其 runOptions.runOn 改为 "default";全部关闭:删除本文件。
// 查看输出:终端面板的下拉里选对应 watch 任务。
{
"version": "2.0.0",
"tasks": [
{%- if include_frontend %}
{
"label": "watch: frontend typecheck",
"type": "shell",
"command": "pnpm typecheck:watch",
"options": { "cwd": "${workspaceFolder}/frontend" },
"isBackground": true,
"problemMatcher": "$tsc-watch",
"presentation": { "group": "watch", "reveal": "never", "panel": "dedicated" },
"runOptions": { "runOn": "folderOpen" }
},
{%- endif %}
{%- if include_backend %}
{
"label": "watch: backend lint",
"type": "shell",
"command": "uv run ruff check --watch src",
"options": { "cwd": "${workspaceFolder}/backend" },
"isBackground": true,
"problemMatcher": [],
"presentation": { "group": "watch", "reveal": "never", "panel": "dedicated" },
"runOptions": { "runOn": "folderOpen" }
},
{%- endif %}
{%- if include_agent %}
{
"label": "watch: agent lint",
"type": "shell",
"command": "uv run ruff check --watch src",
"options": { "cwd": "${workspaceFolder}/agent" },
"isBackground": true,
"problemMatcher": [],
"presentation": { "group": "watch", "reveal": "never", "panel": "dedicated" },
"runOptions": { "runOn": "folderOpen" }
},
{%- endif %}
]
}
+1
View File
@@ -8,6 +8,7 @@
"preview": "vite preview",
"lint": "eslint src",
"typecheck": "tsc --noEmit",
"typecheck:watch": "tsc --noEmit --watch",
"test": "vitest",
"test:run": "vitest run"
},