cursor-guard 2.1.1 → 3.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 +63 -11
- package/README.zh-CN.md +345 -293
- package/ROADMAP.md +834 -0
- package/SKILL.md +617 -557
- package/package.json +14 -5
- package/references/config-reference.md +175 -175
- package/references/config-reference.zh-CN.md +175 -175
- package/references/cursor-guard.example.json +0 -6
- package/references/lib/auto-backup.js +257 -530
- package/references/lib/core/backups.js +357 -0
- package/references/lib/core/core.test.js +859 -0
- package/references/lib/core/doctor-fix.js +237 -0
- package/references/lib/core/doctor.js +248 -0
- package/references/lib/core/restore.js +305 -0
- package/references/lib/core/snapshot.js +173 -0
- package/references/lib/core/status.js +163 -0
- package/references/lib/guard-doctor.js +46 -238
- package/references/lib/utils.js +371 -371
- package/references/mcp/mcp.test.js +279 -0
- package/references/mcp/server.js +198 -0
- package/references/quickstart.zh-CN.md +342 -0
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ 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)** — 7 structured tools (diagnostics, snapshot, restore, status, 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
|
|
23
25
|
|
|
24
26
|
---
|
|
25
27
|
|
|
@@ -84,19 +86,30 @@ After installation, your directory structure should look like this:
|
|
|
84
86
|
|
|
85
87
|
```
|
|
86
88
|
.cursor/skills/cursor-guard/
|
|
87
|
-
├── SKILL.md # AI agent instructions
|
|
89
|
+
├── SKILL.md # AI agent instructions (with MCP dual-path logic)
|
|
90
|
+
├── ROADMAP.md # Version evolution roadmap
|
|
88
91
|
├── README.md
|
|
89
92
|
├── README.zh-CN.md
|
|
90
93
|
├── LICENSE
|
|
91
94
|
├── package.json
|
|
92
95
|
└── references/
|
|
93
96
|
├── lib/
|
|
94
|
-
│ ├── auto-backup.js # Backup
|
|
95
|
-
│ ├── guard-doctor.js # Health check
|
|
96
|
-
│
|
|
97
|
+
│ ├── auto-backup.js # Backup watcher (calls Core)
|
|
98
|
+
│ ├── guard-doctor.js # Health check CLI (calls Core)
|
|
99
|
+
│ ├── utils.js # Shared utilities
|
|
100
|
+
│ └── core/ # V3 Core layer (pure logic)
|
|
101
|
+
│ ├── doctor.js # Diagnostics (incl. MCP self-check)
|
|
102
|
+
│ ├── doctor-fix.js # Auto-fix common issues
|
|
103
|
+
│ ├── snapshot.js # Git snapshots + shadow copies
|
|
104
|
+
│ ├── backups.js # Backup listing + retention
|
|
105
|
+
│ ├── restore.js # Single file / project restore
|
|
106
|
+
│ └── status.js # Backup system status
|
|
107
|
+
├── mcp/
|
|
108
|
+
│ └── server.js # MCP Server (7 tools)
|
|
97
109
|
├── bin/
|
|
98
|
-
│ ├── cursor-guard-backup.js # CLI
|
|
99
|
-
│
|
|
110
|
+
│ ├── cursor-guard-backup.js # CLI: npx cursor-guard-backup
|
|
111
|
+
│ ├── cursor-guard-doctor.js # CLI: npx cursor-guard-doctor
|
|
112
|
+
│ └── cursor-guard-mcp (server.js)# CLI: npx cursor-guard-mcp
|
|
100
113
|
├── auto-backup.ps1 / .sh # Thin wrappers
|
|
101
114
|
├── guard-doctor.ps1 / .sh
|
|
102
115
|
├── recovery.md # Recovery commands
|
|
@@ -128,7 +141,22 @@ The skill activates automatically when the AI agent detects risky operations or
|
|
|
128
141
|
cp .cursor/skills/cursor-guard/references/cursor-guard.example.json .cursor-guard.json
|
|
129
142
|
```
|
|
130
143
|
|
|
131
|
-
5. **(Optional)
|
|
144
|
+
5. **(Optional) Enable MCP tool calls** — add to `.cursor/mcp.json`:
|
|
145
|
+
|
|
146
|
+
```jsonc
|
|
147
|
+
{
|
|
148
|
+
"mcpServers": {
|
|
149
|
+
"cursor-guard": {
|
|
150
|
+
"command": "node",
|
|
151
|
+
"args": ["<skill-path>/references/mcp/server.js"]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
This gives the AI agent 7 structured tools (diagnostics, snapshot, restore, etc.) with JSON responses — faster, more reliable, and lower token cost. Everything works without MCP too.
|
|
158
|
+
|
|
159
|
+
6. **(Optional) Run auto-backup** in a separate terminal:
|
|
132
160
|
|
|
133
161
|
```bash
|
|
134
162
|
npx cursor-guard-backup --path /my/project
|
|
@@ -167,8 +195,18 @@ Regardless of config, you can always override per-request:
|
|
|
167
195
|
|
|
168
196
|
Run in a separate terminal while working in Cursor. Cross-platform — requires Node.js >= 18.
|
|
169
197
|
|
|
198
|
+
Important:
|
|
199
|
+
|
|
200
|
+
- You can run the command from any directory
|
|
201
|
+
- But `--path` must point to the project root you want to protect
|
|
202
|
+
- If you are already in the project root, `--path .` is fine
|
|
203
|
+
- If you are not in the project root, do not use `--path .`; use the full target path instead
|
|
204
|
+
|
|
170
205
|
```bash
|
|
171
|
-
#
|
|
206
|
+
# If you are already in the project root
|
|
207
|
+
npx cursor-guard-backup --path .
|
|
208
|
+
|
|
209
|
+
# If you are not in the project root
|
|
172
210
|
npx cursor-guard-backup --path /my/project
|
|
173
211
|
npx cursor-guard-backup --path /my/project --interval 30
|
|
174
212
|
|
|
@@ -179,6 +217,14 @@ npx cursor-guard-backup --path /my/project --interval 30
|
|
|
179
217
|
./references/auto-backup.sh /my/project
|
|
180
218
|
```
|
|
181
219
|
|
|
220
|
+
Wrong example:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# You are in some other directory
|
|
224
|
+
# In that case --path . protects the current directory, not your real project
|
|
225
|
+
npx cursor-guard-backup --path .
|
|
226
|
+
```
|
|
227
|
+
|
|
182
228
|
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
229
|
|
|
184
230
|
### Health Check
|
|
@@ -247,6 +293,9 @@ The skill activates on these signals:
|
|
|
247
293
|
- Time-based recovery: "restore to N minutes ago", "go back to yesterday"
|
|
248
294
|
- Version-based recovery: "previous version", "go back N versions"
|
|
249
295
|
- History issues: checkpoints missing, Timeline not working, save failures
|
|
296
|
+
- Health check: "guard doctor", "check guard setup", "is MCP working"
|
|
297
|
+
- Auto-fix: "guard fix", "fix config"
|
|
298
|
+
- Backup status: "guard status", "is the watcher running", "last backup time"
|
|
250
299
|
|
|
251
300
|
---
|
|
252
301
|
|
|
@@ -254,9 +303,12 @@ The skill activates on these signals:
|
|
|
254
303
|
|
|
255
304
|
| File | Purpose |
|
|
256
305
|
|------|---------|
|
|
257
|
-
| `SKILL.md` | Main skill instructions for the AI agent |
|
|
258
|
-
| `
|
|
259
|
-
| `references/lib/
|
|
306
|
+
| `SKILL.md` | Main skill instructions for the AI agent (with MCP dual-path) |
|
|
307
|
+
| `ROADMAP.md` | Version evolution roadmap (V2-V7) |
|
|
308
|
+
| `references/lib/core/` | Core layer: 6 pure-logic modules (doctor / doctor-fix / snapshot / backups / restore / status) |
|
|
309
|
+
| `references/mcp/server.js` | MCP Server: 7 structured tools (optional) |
|
|
310
|
+
| `references/lib/auto-backup.js` | Auto-backup watcher (calls Core) |
|
|
311
|
+
| `references/lib/guard-doctor.js` | Health check CLI shell (calls Core) |
|
|
260
312
|
| `references/lib/utils.js` | Shared utilities (config, glob, git, manifest) |
|
|
261
313
|
| `references/bin/cursor-guard-backup.js` | CLI entry: `npx cursor-guard-backup` |
|
|
262
314
|
| `references/bin/cursor-guard-doctor.js` | CLI entry: `npx cursor-guard-doctor` |
|