小优化,产品愿景,视觉规范,交互和导航大版本
This commit is contained in:
47
.cursor/rules/project/local-env-check.mdc
Normal file
47
.cursor/rules/project/local-env-check.mdc
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
description: 检查本地环境配置文件 .cursor/local-env.json 是否存在,不存在时自动探测并生成
|
||||
globs:
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
## 本地环境配置自动初始化
|
||||
|
||||
每次会话处理用户第一个任务前,检查 `.cursor/local-env.json` 是否存在:
|
||||
|
||||
### 文件存在时
|
||||
|
||||
读取并验证 JSON 格式正确、包含 `nodejs_path` 和 `shell` 两个字段。
|
||||
字段缺失时补充探测(见下方流程),不覆盖已有字段。
|
||||
|
||||
### 文件不存在时
|
||||
|
||||
执行自动探测流程,生成 `.cursor/local-env.json`:
|
||||
|
||||
```
|
||||
1. 探测 shell 类型:
|
||||
- Windows($env:OS 包含 "Windows")→ "powershell"
|
||||
- macOS/Linux → 读取 $SHELL 环境变量末段(bash/zsh/fish 等)
|
||||
|
||||
2. 探测 Node.js 路径:
|
||||
- Windows:运行 `where.exe node`,排除 Cursor 内置的 node
|
||||
(路径含 "cursor" 的不算),取第一个有效结果的父目录
|
||||
- macOS/Linux:运行 `which node`,取父目录
|
||||
- 找不到 → 设为 null
|
||||
|
||||
3. 写入 .cursor/local-env.json:
|
||||
{
|
||||
"nodejs_path": "<探测到的路径或 null>",
|
||||
"shell": "<探测到的 shell>"
|
||||
}
|
||||
|
||||
4. 简要告知用户:
|
||||
> 已自动生成本地环境配置 `.cursor/local-env.json`,
|
||||
> 检测到 Node.js 路径为 xxx,shell 为 xxx。如需调整请手动编辑该文件。
|
||||
```
|
||||
|
||||
### 注意事项
|
||||
|
||||
- `local-env.json` 已在 `.gitignore` 中,不会进入版本控制
|
||||
- 该文件存储**设备绑定**的配置,与 `.env`(存储密钥/API key)互补
|
||||
- 只在文件不存在或字段缺失时触发探测,不会每次会话都重新探测
|
||||
- 探测结果不一定准确(如多个 Node.js 版本并存),用户可随时手动修改
|
||||
Reference in New Issue
Block a user