cursor-guard 3.4.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -23
- package/README.zh-CN.md +36 -23
- package/ROADMAP.md +309 -103
- package/SKILL.md +20 -6
- package/package.json +2 -1
- package/references/bin/cursor-guard-init.js +120 -0
- package/references/config-reference.md +40 -0
- package/references/config-reference.zh-CN.md +40 -0
- package/references/cursor-guard.example.json +6 -0
- package/references/cursor-guard.schema.json +30 -0
- package/references/lib/auto-backup.js +66 -8
- package/references/lib/core/anomaly.js +217 -0
- package/references/lib/core/backups.js +9 -9
- package/references/lib/core/core.test.js +600 -0
- package/references/lib/core/dashboard.js +208 -0
- package/references/lib/core/doctor-fix.js +1 -1
- package/references/lib/core/doctor.js +26 -8
- package/references/lib/core/restore.js +78 -23
- package/references/lib/core/snapshot.js +45 -19
- package/references/lib/core/status.js +4 -4
- package/references/lib/utils.js +72 -5
- package/references/mcp/mcp.test.js +98 -3
- package/references/mcp/server.js +74 -12
- package/references/quickstart.zh-CN.md +23 -1
package/README.md
CHANGED
|
@@ -20,47 +20,56 @@ When Cursor's AI agent edits your files, there's a risk of accidental overwrites
|
|
|
20
20
|
- **Configurable scope** — Protect only what matters via `.cursor-guard.json`
|
|
21
21
|
- **Secrets filtering** — Sensitive files (`.env`, keys, certificates) are auto-excluded from backups
|
|
22
22
|
- **Auto-backup script** — A cross-platform watcher (Node.js) that periodically snapshots to a dedicated Git branch without disturbing your working tree
|
|
23
|
-
- **MCP tool calls (optional)** —
|
|
23
|
+
- **MCP tool calls (optional)** — 9 structured tools (diagnostics, snapshot, restore, status, dashboard, alerts, etc.) with JSON responses and lower token cost
|
|
24
24
|
- **Auto-fix diagnostics** — `doctor_fix` automatically patches missing configs, uninitialized Git repos, gitignore gaps, and stale locks
|
|
25
|
+
- **Proactive change-velocity alerts (V4)** — Auto-detects abnormal file change patterns and raises risk warnings
|
|
26
|
+
- **Backup health dashboard (V4)** — One-call comprehensive view: strategy, counts, disk usage, protection scope, health status
|
|
25
27
|
|
|
26
28
|
---
|
|
27
29
|
|
|
28
30
|
## Installation
|
|
29
31
|
|
|
30
|
-
### Method 1: npm
|
|
32
|
+
### Method 1: npm (Recommended)
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
35
|
npm install cursor-guard
|
|
36
|
+
npx cursor-guard-init
|
|
34
37
|
```
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
The `init` command copies skill files to `.cursor/skills/cursor-guard/`, installs MCP dependencies, and adds `.gitignore` entries — all in one step.
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
Options:
|
|
39
42
|
|
|
40
|
-
```
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# Per-project (current project only)
|
|
45
|
-
Copy-Item -Recurse node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
43
|
+
```bash
|
|
44
|
+
npx cursor-guard-init # project-local (default)
|
|
45
|
+
npx cursor-guard-init --global # global (~/.cursor/skills/)
|
|
46
|
+
npx cursor-guard-init --path /my/project # specify project root
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
After init, the npm package in `node_modules` is no longer needed:
|
|
49
50
|
|
|
50
51
|
```bash
|
|
51
|
-
|
|
52
|
-
cp -r node_modules/cursor-guard ~/.cursor/skills/cursor-guard
|
|
53
|
-
|
|
54
|
-
# Per-project
|
|
55
|
-
cp -r node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
52
|
+
npm uninstall cursor-guard
|
|
56
53
|
```
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
<details>
|
|
56
|
+
<summary>Manual installation (without init command)</summary>
|
|
57
|
+
|
|
58
|
+
If you prefer manual setup, copy files then install dependencies:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
|
|
61
|
+
# Copy
|
|
62
|
+
cp -r node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
63
|
+
|
|
64
|
+
# Install MCP dependencies in the skill directory
|
|
65
|
+
cd .cursor/skills/cursor-guard && npm install --omit=dev && cd -
|
|
66
|
+
|
|
67
|
+
# Add to .gitignore so node_modules aren't captured by git snapshots
|
|
68
|
+
echo ".cursor/skills/**/node_modules/" >> .gitignore
|
|
62
69
|
```
|
|
63
70
|
|
|
71
|
+
</details>
|
|
72
|
+
|
|
64
73
|
### Method 2: Git clone
|
|
65
74
|
|
|
66
75
|
```bash
|
|
@@ -103,9 +112,11 @@ After installation, your directory structure should look like this:
|
|
|
103
112
|
│ ├── snapshot.js # Git snapshots + shadow copies
|
|
104
113
|
│ ├── backups.js # Backup listing + retention
|
|
105
114
|
│ ├── restore.js # Single file / project restore
|
|
106
|
-
│
|
|
115
|
+
│ ├── status.js # Backup system status
|
|
116
|
+
│ ├── anomaly.js # V4: Change-velocity detection
|
|
117
|
+
│ └── dashboard.js # V4: Health dashboard aggregation
|
|
107
118
|
├── mcp/
|
|
108
|
-
│ └── server.js # MCP Server (
|
|
119
|
+
│ └── server.js # MCP Server (9 tools)
|
|
109
120
|
├── bin/
|
|
110
121
|
│ ├── cursor-guard-backup.js # CLI: npx cursor-guard-backup
|
|
111
122
|
│ ├── cursor-guard-doctor.js # CLI: npx cursor-guard-doctor
|
|
@@ -154,7 +165,7 @@ cp .cursor/skills/cursor-guard/references/cursor-guard.example.json .cursor-guar
|
|
|
154
165
|
}
|
|
155
166
|
```
|
|
156
167
|
|
|
157
|
-
This gives the AI agent
|
|
168
|
+
This gives the AI agent 9 structured tools (diagnostics, snapshot, restore, dashboard, alerts, etc.) with JSON responses — faster, more reliable, and lower token cost. Everything works without MCP too.
|
|
158
169
|
|
|
159
170
|
6. **(Optional) Run auto-backup** in a separate terminal:
|
|
160
171
|
|
|
@@ -296,6 +307,8 @@ The skill activates on these signals:
|
|
|
296
307
|
- Health check: "guard doctor", "check guard setup", "is MCP working"
|
|
297
308
|
- Auto-fix: "guard fix", "fix config"
|
|
298
309
|
- Backup status: "guard status", "is the watcher running", "last backup time"
|
|
310
|
+
- Dashboard: "dashboard", "health overview", "backup summary"
|
|
311
|
+
- Alerts: "any alerts?", "change velocity warning", "risk status"
|
|
299
312
|
|
|
300
313
|
---
|
|
301
314
|
|
|
@@ -305,8 +318,8 @@ The skill activates on these signals:
|
|
|
305
318
|
|------|---------|
|
|
306
319
|
| `SKILL.md` | Main skill instructions for the AI agent (with MCP dual-path) |
|
|
307
320
|
| `ROADMAP.md` | Version evolution roadmap (V2-V7) |
|
|
308
|
-
| `references/lib/core/` | Core layer:
|
|
309
|
-
| `references/mcp/server.js` | MCP Server:
|
|
321
|
+
| `references/lib/core/` | Core layer: 8 pure-logic modules (doctor / doctor-fix / snapshot / backups / restore / status / anomaly / dashboard) |
|
|
322
|
+
| `references/mcp/server.js` | MCP Server: 9 structured tools (optional) |
|
|
310
323
|
| `references/lib/auto-backup.js` | Auto-backup watcher (calls Core) |
|
|
311
324
|
| `references/lib/guard-doctor.js` | Health check CLI shell (calls Core) |
|
|
312
325
|
| `references/lib/utils.js` | Shared utilities (config, glob, git, manifest) |
|
package/README.zh-CN.md
CHANGED
|
@@ -20,47 +20,56 @@
|
|
|
20
20
|
- **可配置保护范围** — 通过 `.cursor-guard.json` 配置文件只保护你关心的文件
|
|
21
21
|
- **敏感文件过滤** — `.env`、密钥、证书等敏感文件自动排除备份
|
|
22
22
|
- **自动备份脚本** — 跨平台 (Node.js) 定期快照到独立 Git 分支,不干扰工作区
|
|
23
|
-
- **MCP 工具调用(可选)** —
|
|
23
|
+
- **MCP 工具调用(可选)** — 9 个标准化工具(诊断、快照、恢复、状态、看板、告警等),结构化 JSON 返回,低 token 消耗
|
|
24
24
|
- **自动诊断修复** — `doctor_fix` 一键修补缺失配置、未初始化 Git、gitignore 遗漏等常见问题
|
|
25
|
+
- **主动变更频率告警(V4)** — 自动检测异常文件变更模式并发出风险预警
|
|
26
|
+
- **备份健康看板(V4)** — 一次调用全面查看:策略、数量、磁盘占用、保护范围、健康状态
|
|
25
27
|
|
|
26
28
|
---
|
|
27
29
|
|
|
28
30
|
## 安装
|
|
29
31
|
|
|
30
|
-
### 方式一:npm
|
|
32
|
+
### 方式一:npm 安装(推荐)
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
35
|
npm install cursor-guard
|
|
36
|
+
npx cursor-guard-init
|
|
34
37
|
```
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
`init` 命令一键完成:复制技能文件到 `.cursor/skills/cursor-guard/`、安装 MCP 依赖、添加 `.gitignore` 条目。
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
可选参数:
|
|
39
42
|
|
|
40
|
-
```
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# 项目级安装(仅当前项目生效)
|
|
45
|
-
Copy-Item -Recurse node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
43
|
+
```bash
|
|
44
|
+
npx cursor-guard-init # 项目级安装(默认)
|
|
45
|
+
npx cursor-guard-init --global # 全局安装(~/.cursor/skills/)
|
|
46
|
+
npx cursor-guard-init --path /my/project # 指定项目根目录
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
初始化完成后,`node_modules` 中的 npm 包已不再需要:
|
|
49
50
|
|
|
50
51
|
```bash
|
|
51
|
-
|
|
52
|
-
cp -r node_modules/cursor-guard ~/.cursor/skills/cursor-guard
|
|
53
|
-
|
|
54
|
-
# 项目级安装
|
|
55
|
-
cp -r node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
52
|
+
npm uninstall cursor-guard
|
|
56
53
|
```
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
<details>
|
|
56
|
+
<summary>手动安装(不使用 init 命令)</summary>
|
|
57
|
+
|
|
58
|
+
如果你更喜欢手动操作,复制文件后需要手动安装依赖:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
|
|
61
|
+
# 复制
|
|
62
|
+
cp -r node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
63
|
+
|
|
64
|
+
# 在 skill 目录中安装 MCP 依赖
|
|
65
|
+
cd .cursor/skills/cursor-guard && npm install --omit=dev && cd -
|
|
66
|
+
|
|
67
|
+
# 添加到 .gitignore,防止 node_modules 被 git 快照捕获
|
|
68
|
+
echo ".cursor/skills/**/node_modules/" >> .gitignore
|
|
62
69
|
```
|
|
63
70
|
|
|
71
|
+
</details>
|
|
72
|
+
|
|
64
73
|
### 方式二:Git 克隆
|
|
65
74
|
|
|
66
75
|
```bash
|
|
@@ -103,9 +112,11 @@ git clone https://github.com/zhangqiang8vipp/cursor-guard.git .cursor/skills/cur
|
|
|
103
112
|
│ ├── snapshot.js # Git 快照 + 影子拷贝
|
|
104
113
|
│ ├── backups.js # 备份列表 + 留存清理
|
|
105
114
|
│ ├── restore.js # 单文件/全项目恢复
|
|
106
|
-
│
|
|
115
|
+
│ ├── status.js # 备份系统状态
|
|
116
|
+
│ ├── anomaly.js # V4:变更频率检测
|
|
117
|
+
│ └── dashboard.js # V4:健康看板聚合
|
|
107
118
|
├── mcp/
|
|
108
|
-
│ └── server.js # MCP Server(
|
|
119
|
+
│ └── server.js # MCP Server(9 个工具)
|
|
109
120
|
├── bin/
|
|
110
121
|
│ ├── cursor-guard-backup.js # CLI:npx cursor-guard-backup
|
|
111
122
|
│ ├── cursor-guard-doctor.js # CLI:npx cursor-guard-doctor
|
|
@@ -154,7 +165,7 @@ cp .cursor/skills/cursor-guard/references/cursor-guard.example.json .cursor-guar
|
|
|
154
165
|
}
|
|
155
166
|
```
|
|
156
167
|
|
|
157
|
-
启用后 AI 代理可直接调用
|
|
168
|
+
启用后 AI 代理可直接调用 9 个结构化工具(诊断、快照、恢复、看板、告警等),无需拼接 shell 命令,更快更省 token。不启用也完全不影响使用。
|
|
158
169
|
|
|
159
170
|
6. **(可选)运行自动备份** — 在独立终端运行:
|
|
160
171
|
|
|
@@ -296,6 +307,8 @@ npx cursor-guard-doctor --path /my/project
|
|
|
296
307
|
- 健康检查:"guard doctor"、"自检"、"诊断guard"、"MCP 能用吗"
|
|
297
308
|
- 自动修复:"guard fix"、"修复配置"、"自动修复"
|
|
298
309
|
- 备份状态:"备份状态"、"guard status"、"watcher 在跑吗"
|
|
310
|
+
- 健康看板:"看板"、"dashboard"、"备份总览"、"健康状态"
|
|
311
|
+
- 告警检查:"有告警吗"、"变更异常"、"风险提示"
|
|
299
312
|
|
|
300
313
|
---
|
|
301
314
|
|
|
@@ -305,8 +318,8 @@ npx cursor-guard-doctor --path /my/project
|
|
|
305
318
|
|------|------|
|
|
306
319
|
| `SKILL.md` | AI 代理的主要技能指令(含 MCP 双路径逻辑) |
|
|
307
320
|
| `ROADMAP.md` | 版本演进规划书(V2-V7) |
|
|
308
|
-
| `references/lib/core/` | Core 层:
|
|
309
|
-
| `references/mcp/server.js` | MCP Server:
|
|
321
|
+
| `references/lib/core/` | Core 层:8 个纯逻辑模块(doctor / doctor-fix / snapshot / backups / restore / status / anomaly / dashboard) |
|
|
322
|
+
| `references/mcp/server.js` | MCP Server:9 个标准化工具(可选) |
|
|
310
323
|
| `references/lib/auto-backup.js` | 自动备份 watcher(调用 Core) |
|
|
311
324
|
| `references/lib/guard-doctor.js` | 健康检查 CLI 壳(调用 Core) |
|
|
312
325
|
| `references/lib/utils.js` | 共享工具库(配置、glob、git、manifest) |
|