cursor-guard 2.1.0 → 4.0.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 +69 -11
- package/README.zh-CN.md +351 -293
- package/ROADMAP.md +1040 -0
- package/SKILL.md +631 -557
- package/package.json +26 -6
- package/references/config-reference.md +215 -175
- package/references/config-reference.zh-CN.md +215 -175
- package/references/cursor-guard.example.json +6 -6
- package/references/cursor-guard.schema.json +30 -0
- package/references/lib/auto-backup.js +315 -530
- package/references/lib/core/anomaly.js +217 -0
- package/references/lib/core/backups.js +357 -0
- package/references/lib/core/core.test.js +1459 -0
- package/references/lib/core/dashboard.js +208 -0
- package/references/lib/core/doctor-fix.js +237 -0
- package/references/lib/core/doctor.js +248 -0
- package/references/lib/core/restore.js +360 -0
- package/references/lib/core/snapshot.js +198 -0
- package/references/lib/core/status.js +163 -0
- package/references/lib/guard-doctor.js +46 -238
- package/references/lib/utils.js +438 -371
- package/references/mcp/mcp.test.js +374 -0
- package/references/mcp/server.js +252 -0
- package/references/quickstart.zh-CN.md +364 -0
package/README.md
CHANGED
|
@@ -20,6 +20,10 @@ 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)** — 9 structured tools (diagnostics, snapshot, restore, status, dashboard, alerts, etc.) with JSON responses and lower token cost
|
|
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
|
|
23
27
|
|
|
24
28
|
---
|
|
25
29
|
|
|
@@ -84,19 +88,32 @@ After installation, your directory structure should look like this:
|
|
|
84
88
|
|
|
85
89
|
```
|
|
86
90
|
.cursor/skills/cursor-guard/
|
|
87
|
-
├── SKILL.md # AI agent instructions
|
|
91
|
+
├── SKILL.md # AI agent instructions (with MCP dual-path logic)
|
|
92
|
+
├── ROADMAP.md # Version evolution roadmap
|
|
88
93
|
├── README.md
|
|
89
94
|
├── README.zh-CN.md
|
|
90
95
|
├── LICENSE
|
|
91
96
|
├── package.json
|
|
92
97
|
└── references/
|
|
93
98
|
├── lib/
|
|
94
|
-
│ ├── auto-backup.js # Backup
|
|
95
|
-
│ ├── guard-doctor.js # Health check
|
|
96
|
-
│
|
|
99
|
+
│ ├── auto-backup.js # Backup watcher (calls Core)
|
|
100
|
+
│ ├── guard-doctor.js # Health check CLI (calls Core)
|
|
101
|
+
│ ├── utils.js # Shared utilities
|
|
102
|
+
│ └── core/ # V3 Core layer (pure logic)
|
|
103
|
+
│ ├── doctor.js # Diagnostics (incl. MCP self-check)
|
|
104
|
+
│ ├── doctor-fix.js # Auto-fix common issues
|
|
105
|
+
│ ├── snapshot.js # Git snapshots + shadow copies
|
|
106
|
+
│ ├── backups.js # Backup listing + retention
|
|
107
|
+
│ ├── restore.js # Single file / project restore
|
|
108
|
+
│ ├── status.js # Backup system status
|
|
109
|
+
│ ├── anomaly.js # V4: Change-velocity detection
|
|
110
|
+
│ └── dashboard.js # V4: Health dashboard aggregation
|
|
111
|
+
├── mcp/
|
|
112
|
+
│ └── server.js # MCP Server (9 tools)
|
|
97
113
|
├── bin/
|
|
98
|
-
│ ├── cursor-guard-backup.js # CLI
|
|
99
|
-
│
|
|
114
|
+
│ ├── cursor-guard-backup.js # CLI: npx cursor-guard-backup
|
|
115
|
+
│ ├── cursor-guard-doctor.js # CLI: npx cursor-guard-doctor
|
|
116
|
+
│ └── cursor-guard-mcp (server.js)# CLI: npx cursor-guard-mcp
|
|
100
117
|
├── auto-backup.ps1 / .sh # Thin wrappers
|
|
101
118
|
├── guard-doctor.ps1 / .sh
|
|
102
119
|
├── recovery.md # Recovery commands
|
|
@@ -128,7 +145,22 @@ The skill activates automatically when the AI agent detects risky operations or
|
|
|
128
145
|
cp .cursor/skills/cursor-guard/references/cursor-guard.example.json .cursor-guard.json
|
|
129
146
|
```
|
|
130
147
|
|
|
131
|
-
5. **(Optional)
|
|
148
|
+
5. **(Optional) Enable MCP tool calls** — add to `.cursor/mcp.json`:
|
|
149
|
+
|
|
150
|
+
```jsonc
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"cursor-guard": {
|
|
154
|
+
"command": "node",
|
|
155
|
+
"args": ["<skill-path>/references/mcp/server.js"]
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
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.
|
|
162
|
+
|
|
163
|
+
6. **(Optional) Run auto-backup** in a separate terminal:
|
|
132
164
|
|
|
133
165
|
```bash
|
|
134
166
|
npx cursor-guard-backup --path /my/project
|
|
@@ -167,8 +199,18 @@ Regardless of config, you can always override per-request:
|
|
|
167
199
|
|
|
168
200
|
Run in a separate terminal while working in Cursor. Cross-platform — requires Node.js >= 18.
|
|
169
201
|
|
|
202
|
+
Important:
|
|
203
|
+
|
|
204
|
+
- You can run the command from any directory
|
|
205
|
+
- But `--path` must point to the project root you want to protect
|
|
206
|
+
- If you are already in the project root, `--path .` is fine
|
|
207
|
+
- If you are not in the project root, do not use `--path .`; use the full target path instead
|
|
208
|
+
|
|
170
209
|
```bash
|
|
171
|
-
#
|
|
210
|
+
# If you are already in the project root
|
|
211
|
+
npx cursor-guard-backup --path .
|
|
212
|
+
|
|
213
|
+
# If you are not in the project root
|
|
172
214
|
npx cursor-guard-backup --path /my/project
|
|
173
215
|
npx cursor-guard-backup --path /my/project --interval 30
|
|
174
216
|
|
|
@@ -179,6 +221,14 @@ npx cursor-guard-backup --path /my/project --interval 30
|
|
|
179
221
|
./references/auto-backup.sh /my/project
|
|
180
222
|
```
|
|
181
223
|
|
|
224
|
+
Wrong example:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# You are in some other directory
|
|
228
|
+
# In that case --path . protects the current directory, not your real project
|
|
229
|
+
npx cursor-guard-backup --path .
|
|
230
|
+
```
|
|
231
|
+
|
|
182
232
|
The script uses Git plumbing commands to snapshot to `refs/guard/auto-backup` — it never switches branches or touches your working index. The ref lives outside `refs/heads/` so `git push --all` won't push it. Supports `shadow` mode for non-Git directories.
|
|
183
233
|
|
|
184
234
|
### Health Check
|
|
@@ -247,6 +297,11 @@ The skill activates on these signals:
|
|
|
247
297
|
- Time-based recovery: "restore to N minutes ago", "go back to yesterday"
|
|
248
298
|
- Version-based recovery: "previous version", "go back N versions"
|
|
249
299
|
- History issues: checkpoints missing, Timeline not working, save failures
|
|
300
|
+
- Health check: "guard doctor", "check guard setup", "is MCP working"
|
|
301
|
+
- Auto-fix: "guard fix", "fix config"
|
|
302
|
+
- Backup status: "guard status", "is the watcher running", "last backup time"
|
|
303
|
+
- Dashboard: "dashboard", "health overview", "backup summary"
|
|
304
|
+
- Alerts: "any alerts?", "change velocity warning", "risk status"
|
|
250
305
|
|
|
251
306
|
---
|
|
252
307
|
|
|
@@ -254,9 +309,12 @@ The skill activates on these signals:
|
|
|
254
309
|
|
|
255
310
|
| File | Purpose |
|
|
256
311
|
|------|---------|
|
|
257
|
-
| `SKILL.md` | Main skill instructions for the AI agent |
|
|
258
|
-
| `
|
|
259
|
-
| `references/lib/
|
|
312
|
+
| `SKILL.md` | Main skill instructions for the AI agent (with MCP dual-path) |
|
|
313
|
+
| `ROADMAP.md` | Version evolution roadmap (V2-V7) |
|
|
314
|
+
| `references/lib/core/` | Core layer: 8 pure-logic modules (doctor / doctor-fix / snapshot / backups / restore / status / anomaly / dashboard) |
|
|
315
|
+
| `references/mcp/server.js` | MCP Server: 9 structured tools (optional) |
|
|
316
|
+
| `references/lib/auto-backup.js` | Auto-backup watcher (calls Core) |
|
|
317
|
+
| `references/lib/guard-doctor.js` | Health check CLI shell (calls Core) |
|
|
260
318
|
| `references/lib/utils.js` | Shared utilities (config, glob, git, manifest) |
|
|
261
319
|
| `references/bin/cursor-guard-backup.js` | CLI entry: `npx cursor-guard-backup` |
|
|
262
320
|
| `references/bin/cursor-guard-doctor.js` | CLI entry: `npx cursor-guard-doctor` |
|