cursor-guard 4.9.12 → 4.9.15
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 +697 -697
- package/README.zh-CN.md +696 -696
- package/ROADMAP.md +1775 -1758
- package/SKILL.md +631 -629
- package/docs/RELEASE.md +197 -196
- package/docs/SNAPSHOT-BOOKMARK.md +47 -0
- package/package.json +2 -1
- package/references/dashboard/public/app.js +2079 -2050
- package/references/dashboard/public/style.css +1660 -1628
- package/references/lib/core/backups.js +509 -507
- package/references/lib/core/core.test.js +39 -1
- package/references/lib/core/snapshot.js +441 -416
- package/references/mcp/mcp.test.js +381 -362
- package/references/mcp/server.js +404 -347
- package/references/vscode-extension/{cursor-guard-ide-4.9.12.vsix → dist/cursor-guard-ide-4.9.15.vsix} +0 -0
- package/references/vscode-extension/dist/dashboard/public/app.js +2079 -2050
- package/references/vscode-extension/dist/dashboard/public/style.css +1660 -1628
- package/references/vscode-extension/dist/extension.js +780 -704
- package/references/vscode-extension/dist/guard-version.json +1 -1
- package/references/vscode-extension/dist/lib/auto-setup.js +201 -192
- package/references/vscode-extension/dist/lib/core/backups.js +509 -507
- package/references/vscode-extension/dist/lib/core/snapshot.js +441 -416
- package/references/vscode-extension/dist/mcp/server.js +78 -12
- package/references/vscode-extension/dist/package.json +7 -1
- package/references/vscode-extension/dist/skill/ROADMAP.md +1775 -1758
- package/references/vscode-extension/dist/skill/SKILL.md +631 -629
- package/references/vscode-extension/extension.js +780 -704
- package/references/vscode-extension/lib/auto-setup.js +201 -192
- package/references/vscode-extension/package.json +7 -1
- package/references/vscode-extension/dist/cursor-guard-ide-4.9.12.vsix +0 -0
package/README.md
CHANGED
|
@@ -1,697 +1,697 @@
|
|
|
1
|
-
# Cursor Guard
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/cursor-guard)
|
|
4
|
-
[](LICENSE)
|
|
5
|
-
|
|
6
|
-
Protects your code from accidental AI overwrite or deletion in [Cursor](https://cursor.com).
|
|
7
|
-
|
|
8
|
-
**[中文文档](README.zh-CN.md)**
|
|
9
|
-
**Release / 发版(maintainers & AI):** [docs/RELEASE.md](docs/RELEASE.md)
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## What It Does
|
|
14
|
-
|
|
15
|
-
When Cursor's AI agent edits your files, there's a risk of accidental overwrites, deletions, or loss of work. **Cursor Guard** enforces a safety protocol:
|
|
16
|
-
|
|
17
|
-
- **Mandatory pre-write snapshots** — Git commit or shadow copy before any destructive operation
|
|
18
|
-
- **Read before Write** — The agent must read a file before overwriting it
|
|
19
|
-
- **Review before apply** — Diff previews and explicit confirmation for dangerous ops
|
|
20
|
-
- **Deterministic recovery** — Clear priority-ordered recovery paths (Git → shadow copies → conversation context → editor history)
|
|
21
|
-
- **Configurable scope** — Protect only what matters via `.cursor-guard.json`
|
|
22
|
-
- **Secrets filtering** — Sensitive files (`.env`, keys, certificates) are auto-excluded from backups
|
|
23
|
-
- **Auto-backup script** — A cross-platform watcher (Node.js) that periodically snapshots to a dedicated Git branch without disturbing your working tree
|
|
24
|
-
- **MCP tool calls (optional)** —
|
|
25
|
-
- **Auto-fix diagnostics** — `doctor_fix` automatically patches missing configs, uninitialized Git repos, gitignore gaps, and stale locks
|
|
26
|
-
- **Proactive change-velocity alerts (V4)** — Auto-detects abnormal file change patterns and raises risk warnings
|
|
27
|
-
- **Pre-warning destructive edit guard (V4.9.7)** — Detects risky partial deletions before they quietly stick, with softer auto-continue review, sidebar language sync, and `popup` / `dashboard` / `silent` modes
|
|
28
|
-
- **Backup health dashboard (V4)** — One-call comprehensive view: strategy, counts, disk usage, protection scope, health status
|
|
29
|
-
- **Web dashboard (V4.2)** — Local read-only web UI at `http://127.0.0.1:3120` — see health, backups, restore points, diagnostics, protection scope at a glance. Dual-language (zh-CN / en-US), auto-refresh, multi-project support
|
|
30
|
-
- **IDE extension (V4.7)** — Full dashboard embedded in VSCode/Cursor/Windsurf as a WebView tab + status bar alert indicator + sidebar project tree. No browser needed
|
|
31
|
-
- **Event-driven watching (V4.9)** — `fs.watch` + debounce replaces blind polling. Backup latency < 500ms, zero CPU when idle. Automatic fallback to polling on unsupported platforms
|
|
32
|
-
- **Right-click context menus (V4.7.7)** — Add files/folders to `protect` or `ignore` lists via Explorer/Editor right-click menu with pattern picker
|
|
33
|
-
- **Real-time sidebar (V4.9.1)** — "Last backup Xs ago" and alert countdown tick every second in the sidebar dashboard
|
|
34
|
-
- **Smart restore for deleted files (V4.8.4)** — Restore commands auto-point to parent commit (`hash~1`) when file was deleted in the snapshot, preventing "file not found" errors
|
|
35
|
-
- **Self-contained VSIX (V4.8.1)** — MCP server bundled as a single file via esbuild, zero npm dependencies needed for IDE extension
|
|
36
|
-
- **One-click hot restart (V4.5.8)** — Dashboard detects new versions and offers in-place server restart without losing state
|
|
37
|
-
- **Shadow incremental hard links (V4.5.4)** — Unchanged files are hard-linked to save disk space and I/O
|
|
38
|
-
- **Strong protection mode (V4.5.4)** — `always_watch: true` auto-starts watcher with MCP server, ensuring zero protection gaps
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Installation
|
|
43
|
-
|
|
44
|
-
### Method 1: npm (Recommended)
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npm install cursor-guard
|
|
48
|
-
npx cursor-guard-init
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
The `init` command copies skill files to `.cursor/skills/cursor-guard/`, installs MCP dependencies, and adds `.gitignore` entries — all in one step.
|
|
52
|
-
|
|
53
|
-
Options:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npx cursor-guard-init # project-local (default)
|
|
57
|
-
npx cursor-guard-init --global # global (~/.cursor/skills/)
|
|
58
|
-
npx cursor-guard-init --path /my/project # specify project root
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
After init, the npm package in `node_modules` is no longer needed:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
npm uninstall cursor-guard
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
<details>
|
|
68
|
-
<summary>Manual installation (without init command)</summary>
|
|
69
|
-
|
|
70
|
-
If you prefer manual setup, copy files then install dependencies:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# Copy
|
|
74
|
-
cp -r node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
75
|
-
|
|
76
|
-
# Install MCP dependencies in the skill directory
|
|
77
|
-
cd .cursor/skills/cursor-guard && npm install --omit=dev && cd -
|
|
78
|
-
|
|
79
|
-
# Add to .gitignore so node_modules aren't captured by git snapshots
|
|
80
|
-
echo ".cursor/skills/**/node_modules/" >> .gitignore
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
</details>
|
|
84
|
-
|
|
85
|
-
### Method 2: Git clone
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# Global
|
|
89
|
-
git clone https://github.com/zhangqiang8vipp/cursor-guard.git ~/.cursor/skills/cursor-guard
|
|
90
|
-
|
|
91
|
-
# Per-project
|
|
92
|
-
git clone https://github.com/zhangqiang8vipp/cursor-guard.git .cursor/skills/cursor-guard
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Method 3: Manual download
|
|
96
|
-
|
|
97
|
-
Download from [GitHub Releases](https://github.com/zhangqiang8vipp/cursor-guard/releases) and extract to:
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
~/.cursor/skills/cursor-guard/ # Global
|
|
101
|
-
<project-root>/.cursor/skills/cursor-guard/ # Per-project
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Verify Installation
|
|
105
|
-
|
|
106
|
-
After installation, your directory structure should look like this:
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
.cursor/skills/cursor-guard/
|
|
110
|
-
├── SKILL.md # AI agent instructions (with MCP dual-path logic)
|
|
111
|
-
├── ROADMAP.md # Version evolution roadmap
|
|
112
|
-
├── README.md
|
|
113
|
-
├── README.zh-CN.md
|
|
114
|
-
├── LICENSE
|
|
115
|
-
├── package.json
|
|
116
|
-
└── references/
|
|
117
|
-
├── lib/
|
|
118
|
-
│ ├── auto-backup.js # Backup watcher (calls Core)
|
|
119
|
-
│ ├── guard-doctor.js # Health check CLI (calls Core)
|
|
120
|
-
│ ├── utils.js # Shared utilities
|
|
121
|
-
│ └── core/ # V3 Core layer (pure logic)
|
|
122
|
-
│ ├── doctor.js # Diagnostics (incl. MCP self-check)
|
|
123
|
-
│ ├── doctor-fix.js # Auto-fix common issues
|
|
124
|
-
│ ├── snapshot.js # Git snapshots + shadow copies
|
|
125
|
-
│ ├── backups.js # Backup listing + retention
|
|
126
|
-
│ ├── restore.js # Single file / project restore
|
|
127
|
-
│ ├── status.js # Backup system status
|
|
128
|
-
│ ├── anomaly.js # V4: Change-velocity detection
|
|
129
|
-
│ ├── pre-warning.js # V4.9.7: destructive edit risk scoring + persistence
|
|
130
|
-
│ └── dashboard.js # V4: Health dashboard aggregation
|
|
131
|
-
├── dashboard/
|
|
132
|
-
│ ├── server.js # Dashboard HTTP server + API
|
|
133
|
-
│ └── public/ # Web UI (HTML/CSS/JS)
|
|
134
|
-
│ ├── index.html
|
|
135
|
-
│ ├── style.css
|
|
136
|
-
│ └── app.js
|
|
137
|
-
├── mcp/
|
|
138
|
-
│ └── server.js # MCP Server (
|
|
139
|
-
├── vscode-extension/ # IDE Extension (V4.7)
|
|
140
|
-
│ ├── extension.js # Extension entry point
|
|
141
|
-
│ ├── package.json # Extension manifest
|
|
142
|
-
│ ├── lib/ # Modules (dashboard-manager, webview, status-bar, tree-view, poller)
|
|
143
|
-
│ └── media/ # Icons (SVG + PNG)
|
|
144
|
-
├── bin/
|
|
145
|
-
│ ├── cursor-guard-backup.js # CLI: npx cursor-guard-backup
|
|
146
|
-
│ ├── cursor-guard-doctor.js # CLI: npx cursor-guard-doctor
|
|
147
|
-
│ └── cursor-guard-mcp (server.js)# CLI: npx cursor-guard-mcp
|
|
148
|
-
├── auto-backup.ps1 / .sh # Thin wrappers
|
|
149
|
-
├── guard-doctor.ps1 / .sh
|
|
150
|
-
├── recovery.md # Recovery commands
|
|
151
|
-
├── cursor-guard.example.json # Example config
|
|
152
|
-
├── cursor-guard.schema.json # Config schema
|
|
153
|
-
├── config-reference.md # Config docs (EN)
|
|
154
|
-
└── config-reference.zh-CN.md # Config docs (CN)
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
The skill activates automatically when the AI agent detects risky operations or when you mention recovery-related terms. No extra setup needed.
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## Quick Start
|
|
162
|
-
|
|
163
|
-
1. **Install the skill** using any method above
|
|
164
|
-
|
|
165
|
-
2. **Open Cursor** and start an Agent conversation
|
|
166
|
-
|
|
167
|
-
3. **The skill works automatically** — when the AI agent tries to edit files, it will:
|
|
168
|
-
- Create a Git snapshot before writing
|
|
169
|
-
- Read files before overwriting
|
|
170
|
-
- Show diff previews for dangerous operations
|
|
171
|
-
- Report a status block after each protected operation
|
|
172
|
-
|
|
173
|
-
4. **(Optional) Add project config** to customize protection scope:
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
cp .cursor/skills/cursor-guard/references/cursor-guard.example.json .cursor-guard.json
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
5. **(Optional) Enable MCP tool calls** — add to `.cursor/mcp.json`:
|
|
180
|
-
|
|
181
|
-
```jsonc
|
|
182
|
-
{
|
|
183
|
-
"mcpServers": {
|
|
184
|
-
"cursor-guard": {
|
|
185
|
-
"command": "node",
|
|
186
|
-
"args": ["<skill-path>/references/mcp/server.js"]
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
This gives the AI agent
|
|
193
|
-
|
|
194
|
-
6. **(Optional) Run auto-backup** in a separate terminal:
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
npx cursor-guard-backup --path /my/project
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### Project Configuration
|
|
201
|
-
|
|
202
|
-
Edit `.cursor-guard.json` to define which files to protect:
|
|
203
|
-
|
|
204
|
-
```json
|
|
205
|
-
{
|
|
206
|
-
"protect": ["src/**", "lib/**", "package.json"],
|
|
207
|
-
"ignore": ["node_modules/**", "dist/**"],
|
|
208
|
-
"auto_backup_interval_seconds": 60,
|
|
209
|
-
"secrets_patterns": [".env", ".env.*", "*.key", "*.pem"],
|
|
210
|
-
"pre_restore_backup": "always",
|
|
211
|
-
"proactive_alert": true,
|
|
212
|
-
"alert_thresholds": { "files_per_window": 20, "window_seconds": 10, "cooldown_seconds": 60 },
|
|
213
|
-
"enable_pre_warning": true,
|
|
214
|
-
"pre_warning_threshold": 30,
|
|
215
|
-
"pre_warning_mode": "popup",
|
|
216
|
-
"pre_warning_exclude_patterns": ["generated/**"],
|
|
217
|
-
"retention": { "mode": "days", "days": 30 }
|
|
218
|
-
}
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
#### `pre_restore_backup` — restore behavior control
|
|
222
|
-
|
|
223
|
-
| Value | Behavior |
|
|
224
|
-
|-------|----------|
|
|
225
|
-
| `"always"` (default) | Automatically preserve current version before every restore. No prompt. |
|
|
226
|
-
| `"ask"` | Prompt you each time: "Preserve current version before restore? (Y/n)" — you decide per restore. |
|
|
227
|
-
| `"never"` | Never preserve current version before restore (not recommended). |
|
|
228
|
-
|
|
229
|
-
Regardless of config, you can always override per-request:
|
|
230
|
-
- Say "don't preserve current version" to skip even when config is `"always"`
|
|
231
|
-
- Say "preserve current first" to force even when config is `"never"`
|
|
232
|
-
|
|
233
|
-
#### `enable_pre_warning` — destructive partial-delete pre-warning
|
|
234
|
-
|
|
235
|
-
When enabled, the IDE extension evaluates edits that remove lines or whole methods/functions before they slip by unnoticed.
|
|
236
|
-
|
|
237
|
-
| Field | Default | Meaning |
|
|
238
|
-
|-------|---------|---------|
|
|
239
|
-
| `enable_pre_warning` | `false` | Turn pre-warning on without affecting existing projects |
|
|
240
|
-
| `pre_warning_threshold` | `30` | Warn when deletion risk reaches this percent |
|
|
241
|
-
| `pre_warning_mode` | `"popup"` | `popup` = interrupt with actions, `dashboard` = highlight only, `silent` = log/status only |
|
|
242
|
-
| `pre_warning_exclude_patterns` | `[]` | Skip generated files, migrations, vendored code, etc. |
|
|
243
|
-
|
|
244
|
-
Method/function removal is treated as high risk and can still trigger a warning even when the deleted-line percentage is below the threshold.
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
## Auto-Backup Script
|
|
249
|
-
|
|
250
|
-
Run in a separate terminal while working in Cursor. Cross-platform — requires Node.js >= 18.
|
|
251
|
-
|
|
252
|
-
Important:
|
|
253
|
-
|
|
254
|
-
- You can run the command from any directory
|
|
255
|
-
- But `--path` must point to the project root you want to protect
|
|
256
|
-
- If you are already in the project root, `--path .` is fine
|
|
257
|
-
- If you are not in the project root, do not use `--path .`; use the full target path instead
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
# If you are already in the project root
|
|
261
|
-
npx cursor-guard-backup --path .
|
|
262
|
-
|
|
263
|
-
# If you are not in the project root
|
|
264
|
-
npx cursor-guard-backup --path /my/project
|
|
265
|
-
npx cursor-guard-backup --path /my/project --interval 30
|
|
266
|
-
|
|
267
|
-
# Windows PowerShell
|
|
268
|
-
.\references\auto-backup.ps1 -Path "D:\MyProject"
|
|
269
|
-
|
|
270
|
-
# macOS / Linux
|
|
271
|
-
./references/auto-backup.sh /my/project
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
Wrong example:
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
# You are in some other directory
|
|
278
|
-
# In that case --path . protects the current directory, not your real project
|
|
279
|
-
npx cursor-guard-backup --path .
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
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.
|
|
283
|
-
|
|
284
|
-
### Health Check
|
|
285
|
-
|
|
286
|
-
```bash
|
|
287
|
-
npx cursor-guard-doctor --path /my/project
|
|
288
|
-
|
|
289
|
-
# Windows: .\references\guard-doctor.ps1 -Path "D:\MyProject"
|
|
290
|
-
# macOS/Linux: ./references/guard-doctor.sh /my/project
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
> **Note**: Run backup/doctor scripts in a separate terminal, NOT inside Cursor's integrated terminal.
|
|
294
|
-
|
|
295
|
-
### Web Dashboard
|
|
296
|
-
|
|
297
|
-
A local read-only web page for monitoring backup health, restore points, protection scope, and diagnostics — all in one view.
|
|
298
|
-
|
|
299
|
-
```bash
|
|
300
|
-
# Monitor a single project
|
|
301
|
-
npx cursor-guard-dashboard --path /my/project
|
|
302
|
-
|
|
303
|
-
# Monitor multiple projects
|
|
304
|
-
npx cursor-guard-dashboard --path /project-a --path /project-b
|
|
305
|
-
|
|
306
|
-
# Custom port (default: 3120)
|
|
307
|
-
npx cursor-guard-dashboard --path /my/project --port 8080
|
|
308
|
-
|
|
309
|
-
# Windows PowerShell (from skill directory)
|
|
310
|
-
node references\dashboard\server.js --path "D:\MyProject"
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
Then open `http://127.0.0.1:3120` in your browser. Or use the **IDE Extension** (see below) to embed the dashboard directly in your editor.
|
|
314
|
-
|
|
315
|
-
Features:
|
|
316
|
-
|
|
317
|
-
- **Read-only** — no write operations, safe to run anytime
|
|
318
|
-
- **Dual-language** — zh-CN / en-US, auto-detects system language, manual toggle in top-right
|
|
319
|
-
- **Auto-refresh** — pulls data every 15 seconds, plus manual refresh button
|
|
320
|
-
- **Multi-project** — pass multiple `--path` args to monitor several projects from one page
|
|
321
|
-
- **4 sections**: Overview (health + watcher + alerts + latest backups), Backups & Recovery (restore point table with type filters), Protection Scope (protect/ignore patterns), Diagnostics (doctor checks)
|
|
322
|
-
- **2 detail drawers**: Restore Point drawer (preview JSON, copy ref/hash), Doctor drawer (full check list, WARN/FAIL expanded by default)
|
|
323
|
-
- **Security** — binds to `127.0.0.1` only (not exposed to LAN), API uses project IDs instead of raw file paths, static file serving restricted to `public/` directory
|
|
324
|
-
- **Zero extra dependencies** — uses Node.js built-in `http` module + existing cursor-guard core modules
|
|
325
|
-
|
|
326
|
-
### IDE Extension (VSCode / Cursor / Windsurf)
|
|
327
|
-
|
|
328
|
-
Embed the full dashboard directly inside your IDE — no browser needed.
|
|
329
|
-
|
|
330
|
-
#### Method A: VSIX standalone (recommended, no npm needed)
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
# Build the self-contained VSIX (version = root package.json "version")
|
|
334
|
-
cd references/vscode-extension
|
|
335
|
-
node build-vsix.js
|
|
336
|
-
cd dist
|
|
337
|
-
npx --yes @vscode/vsce package --no-dependencies
|
|
338
|
-
|
|
339
|
-
# Install the generated .vsix (VERSION always matches package.json)
|
|
340
|
-
V=$(node -p "require('../../../package.json').version")
|
|
341
|
-
code --install-extension "cursor-guard-ide-${V}.vsix"
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
PowerShell (from `references\vscode-extension\dist`):
|
|
345
|
-
|
|
346
|
-
```powershell
|
|
347
|
-
$V = node -p "require('../../../package.json').version"
|
|
348
|
-
code --install-extension "cursor-guard-ide-$V.vsix"
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
Print the full release checklist from the repo root: `npm run release:checklist`.
|
|
352
|
-
|
|
353
|
-
On first activation, the extension automatically:
|
|
354
|
-
- Installs `SKILL.md` to your IDE's skills directory
|
|
355
|
-
- Registers the MCP Server in your IDE's `mcp.json`
|
|
356
|
-
- Creates a default `.cursor-guard.json` if missing
|
|
357
|
-
|
|
358
|
-
#### Method B: From source (development)
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
cd references/vscode-extension
|
|
362
|
-
code --install-extension .
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
Features:
|
|
366
|
-
|
|
367
|
-
- **WebView Dashboard** — full dashboard embedded as an editor tab, identical to the browser version
|
|
368
|
-
- **Status Bar Indicator** — shows `Guard: OK` (green) or `Guard: 22 files!` (yellow) in real-time
|
|
369
|
-
- **Sidebar TreeView** — activity bar icon with project list, watcher status, backup stats, alerts, health
|
|
370
|
-
- **Visual Sidebar** — graphical dashboard with live-ticking backup age, alert countdown, protection scope, quick stats
|
|
371
|
-
- **Pre-warning delete guard** — flags risky partial deletions, removed methods, and suspicious line drops before they quietly stick
|
|
372
|
-
- **Command Palette** — `Open Dashboard`, `Snapshot Now`, `Start/Stop Watcher`, `Quick Restore`, `Doctor`, `Refresh`
|
|
373
|
-
- **Right-click menus** — add files/folders to `protect` or `ignore` via Explorer/Editor context menu
|
|
374
|
-
- **Event-driven refresh** — `FileSystemWatcher` pushes UI updates on file changes (< 1.5s latency), 30s heartbeat fallback
|
|
375
|
-
- **Auto-setup (V4.7.5)** — auto-detects IDE type, installs Skill, registers MCP, creates config on first run
|
|
376
|
-
- **Self-contained (V4.8.1)** — MCP server bundled via esbuild, zero npm dependencies
|
|
377
|
-
- **Multi-project** — hot-loads all workspace folders with `.cursor-guard.json`
|
|
378
|
-
- **Compatible** — works with VSCode ^1.74.0, Cursor, Windsurf, Trae, and all VSCode-based IDEs
|
|
379
|
-
|
|
380
|
-
---
|
|
381
|
-
|
|
382
|
-
## Recovery
|
|
383
|
-
|
|
384
|
-
If something goes wrong, just tell the AI agent in natural language.
|
|
385
|
-
|
|
386
|
-
**Default behavior**: Before any restore, the agent automatically preserves your current version so you can undo the restore if needed. You don't need to ask for this — it happens by default. To skip, explicitly say "don't preserve current version" or "skip backup before restore".
|
|
387
|
-
|
|
388
|
-
### By time
|
|
389
|
-
|
|
390
|
-
> "restore to 5 minutes ago"
|
|
391
|
-
> "go back to yesterday's version"
|
|
392
|
-
> "restore to 3pm today"
|
|
393
|
-
|
|
394
|
-
### By version
|
|
395
|
-
|
|
396
|
-
> "undo the last change"
|
|
397
|
-
> "go back 3 versions"
|
|
398
|
-
> "restore to the previous version"
|
|
399
|
-
|
|
400
|
-
### By file
|
|
401
|
-
|
|
402
|
-
> "restore src/app.py to 10 minutes ago"
|
|
403
|
-
> "restore src/app.py to the previous version"
|
|
404
|
-
|
|
405
|
-
The agent will:
|
|
406
|
-
1. **Preserve your current version** first (unless you opt out)
|
|
407
|
-
2. Search Git history and auto-backup snapshots
|
|
408
|
-
3. Show matching versions for you to choose
|
|
409
|
-
4. Restore after your confirmation
|
|
410
|
-
5. Report both the pre-restore backup ref and the restore result
|
|
411
|
-
|
|
412
|
-
If the pre-restore backup fails, the agent will **not** proceed — it will wait for your explicit confirmation before restoring without a safety net.
|
|
413
|
-
|
|
414
|
-
### Recovery priority
|
|
415
|
-
|
|
416
|
-
1. **Git** — `git restore`, `git reset`, `git reflog`
|
|
417
|
-
2. **Auto-backup ref** — `refs/guard/auto-backup`
|
|
418
|
-
3. **Shadow copies** — `.cursor-guard-backup/<timestamp>/`
|
|
419
|
-
4. **Conversation context** — Original file content captured by agent Read calls
|
|
420
|
-
5. **Editor history** — VS Code/Cursor Timeline (auxiliary)
|
|
421
|
-
|
|
422
|
-
See [references/recovery.md](references/recovery.md) for detailed commands.
|
|
423
|
-
|
|
424
|
-
---
|
|
425
|
-
|
|
426
|
-
## Trigger Keywords
|
|
427
|
-
|
|
428
|
-
The skill activates on these signals:
|
|
429
|
-
|
|
430
|
-
- File edits, deletes, renames by the AI agent
|
|
431
|
-
- Recovery requests: "rollback", "undo", "recover", "restore"
|
|
432
|
-
- Time-based recovery: "restore to N minutes ago", "go back to yesterday"
|
|
433
|
-
- Version-based recovery: "previous version", "go back N versions"
|
|
434
|
-
- History issues: checkpoints missing, Timeline not working, save failures
|
|
435
|
-
- Health check: "guard doctor", "check guard setup", "is MCP working"
|
|
436
|
-
- Auto-fix: "guard fix", "fix config"
|
|
437
|
-
- Backup status: "guard status", "is the watcher running", "last backup time"
|
|
438
|
-
- Dashboard: "dashboard", "health overview", "backup summary"
|
|
439
|
-
- Alerts: "any alerts?", "change velocity warning", "risk status"
|
|
440
|
-
|
|
441
|
-
---
|
|
442
|
-
|
|
443
|
-
## Files
|
|
444
|
-
|
|
445
|
-
| File | Purpose |
|
|
446
|
-
|------|---------|
|
|
447
|
-
| `SKILL.md` | Main skill instructions for the AI agent (with MCP dual-path) |
|
|
448
|
-
| `ROADMAP.md` | Version evolution roadmap (V2-V7) |
|
|
449
|
-
| `references/lib/core/` | Core layer: 9 pure-logic modules (doctor / doctor-fix / snapshot / backups / restore / status / anomaly / pre-warning / dashboard) |
|
|
450
|
-
| `references/mcp/server.js` | MCP Server:
|
|
451
|
-
| `references/lib/auto-backup.js` | Auto-backup watcher (calls Core) |
|
|
452
|
-
| `references/lib/guard-doctor.js` | Health check CLI shell (calls Core) |
|
|
453
|
-
| `references/lib/utils.js` | Shared utilities (config, glob, git, manifest) |
|
|
454
|
-
| `references/bin/cursor-guard-backup.js` | CLI entry: `npx cursor-guard-backup` |
|
|
455
|
-
| `references/bin/cursor-guard-doctor.js` | CLI entry: `npx cursor-guard-doctor` |
|
|
456
|
-
| `references/dashboard/server.js` | Dashboard HTTP server + REST API |
|
|
457
|
-
| `references/dashboard/public/` | Dashboard web UI (index.html, style.css, app.js) |
|
|
458
|
-
| `references/vscode-extension/` | IDE Extension: WebView dashboard, status bar, sidebar tree, commands |
|
|
459
|
-
| `references/auto-backup.ps1` / `.sh` | Thin wrappers (Windows / macOS+Linux) |
|
|
460
|
-
| `references/guard-doctor.ps1` / `.sh` | Thin wrappers (Windows / macOS+Linux) |
|
|
461
|
-
| `references/recovery.md` | Recovery command templates |
|
|
462
|
-
| `references/cursor-guard.example.json` | Example project configuration |
|
|
463
|
-
| `references/cursor-guard.schema.json` | JSON Schema for config validation |
|
|
464
|
-
| `references/config-reference.md` | Config field docs (English) |
|
|
465
|
-
| `references/config-reference.zh-CN.md` | Config field docs (Chinese) |
|
|
466
|
-
|
|
467
|
-
---
|
|
468
|
-
|
|
469
|
-
## Changelog
|
|
470
|
-
|
|
471
|
-
### v4.9.9 — Dedicated release guide (`docs/RELEASE.md`)
|
|
472
|
-
|
|
473
|
-
- **Docs**: New bilingual **[docs/RELEASE.md](docs/RELEASE.md)** for maintainers, developers, and AI agents (full procedure, Windows `gh` + UTF-8 `--notes-file`, npm OTP)
|
|
474
|
-
- **Docs**: README / README.zh-CN link to the guide from the header and the release-checklist section; `npm run release:checklist` footer points to the same file
|
|
475
|
-
- **Packaging**: `docs/RELEASE.md` added to npm `files` so it ships with the package
|
|
476
|
-
|
|
477
|
-
### v4.9.8 — Release docs, checklist script, sidebar brand asset
|
|
478
|
-
|
|
479
|
-
- **Docs**: Bilingual **Release checklist** sections in README / README.zh-CN; steps tied to root `package.json` `version` so VSIX file name, Git tag, and npm stay consistent
|
|
480
|
-
- **Tooling**: `npm run release:checklist` (`scripts/print-release-checklist.js`) prints a ready-to-paste table; `build-vsix.js` logs the expected VSIX file name after build
|
|
481
|
-
- **IDE**: Sidebar header can show packaged brand artwork via `media/brand-placeholder.png` and `asWebviewUri` (fallback gradient if the file is absent)
|
|
482
|
-
|
|
483
|
-
### v4.9.7 — Softer Pre-Warning UX, Sidebar Locale Sync, and Watcher Singleton Guard
|
|
484
|
-
|
|
485
|
-
- **Improve**: `popup` mode now uses a softer auto-continue review flow with a 2-second timeout instead of a hard modal stop
|
|
486
|
-
- **Improve**: Pre-warning review text now follows the sidebar language toggle, keeping zh-CN / en-US messaging consistent inside the IDE
|
|
487
|
-
- **Fix**: Sidebar keeps showing watcher / health status even when delete-risk warnings are present, and popup-mode warnings no longer stick forever
|
|
488
|
-
- **Fix**: IDE watcher start/stop logic now uses the real per-project lock path and pending-process guard, preventing repeated clicks from spawning duplicate watchers
|
|
489
|
-
- **Docs**: README, roadmap, and skill notes updated for the 4.9.7 release flow and IDE behavior
|
|
490
|
-
|
|
491
|
-
### v4.9.6 — Pre-Warning for Destructive Partial Deletes
|
|
492
|
-
|
|
493
|
-
- **Feature**: Added configurable `pre_warning` support in `.cursor-guard.json` — `enable_pre_warning`, `pre_warning_threshold`, `pre_warning_mode`, `pre_warning_exclude_patterns`
|
|
494
|
-
- **Feature**: IDE extension now detects risky line/method removals and can react in `popup`, `dashboard`, or `silent` mode
|
|
495
|
-
- **Feature**: `backup_status`, `dashboard`, sidebar, status bar, and browser dashboard surface active delete-risk warnings
|
|
496
|
-
- **Improve**: New `pre-warning.js` core module centralizes deletion-risk scoring, active-warning persistence, and warning history
|
|
497
|
-
- **Docs**: README, skill guide, roadmap, and config references now document the pre-warning flow end-to-end
|
|
498
|
-
|
|
499
|
-
### v4.9.0–v4.9.1 — Event-Driven Architecture
|
|
500
|
-
|
|
501
|
-
- **Architecture**: Watcher (`auto-backup.js`) rewritten from `while+sleep` polling to `fs.watch` event-driven with 500ms debounce. Zero CPU when idle, backup latency < 500ms
|
|
502
|
-
- **Fallback**: Automatic degradation to polling mode if `fs.watch` is unavailable (e.g. older Linux kernels)
|
|
503
|
-
- **Config hot-reload**: `.cursor-guard.json` changes trigger instant config reload via `fs.watch` event (no more waiting 10 polling cycles)
|
|
504
|
-
- **IDE FileSystemWatcher**: Extension uses VSCode built-in `createFileSystemWatcher` to push UI updates on file changes (1.5s debounce)
|
|
505
|
-
- **Poller heartbeat**: Reduced from 5s fixed interval to 30s heartbeat; UI updates are now event-driven
|
|
506
|
-
- **Live sidebar counters**: "Last backup Xs ago" ticks every second in real-time (v4.9.1)
|
|
507
|
-
|
|
508
|
-
### v4.8.0–v4.8.5 — Bundling, Doctor Fixes, Restore UX
|
|
509
|
-
|
|
510
|
-
- **Fix**: MCP server bundled as single self-contained file via esbuild — eliminates all transitive dependency issues (`zod-to-json-schema`, `ajv`, etc.) (v4.8.1)
|
|
511
|
-
- **Fix**: `doctor` MCP check no longer false-warns when cursor-guard is configured in `.cursor/mcp.json` (v4.8.2)
|
|
512
|
-
- **Fix**: Skill directory `references/` now auto-creates junction link to extension runtime files on every activation (v4.8.2)
|
|
513
|
-
- **Fix**: Deleted file restore commands auto-point to parent commit (`hash~1`), preventing "file not found" errors. Button shows "Restore pre-delete" with orange styling (v4.8.4)
|
|
514
|
-
- **Fix**: Files outside `protect` scope no longer appear as phantom "deleted" in change summaries (v4.8.5)
|
|
515
|
-
- **Improve**: VSIX package reduced from 3.18 MB to 1.27 MB thanks to esbuild bundling
|
|
516
|
-
|
|
517
|
-
### v4.7.6–v4.7.9 — Sidebar Redesign, Context Menus, Protection Scope
|
|
518
|
-
|
|
519
|
-
- **Feature**: Right-click context menus — add files/folders to `protect` or `ignore` via Explorer/Editor menus with pattern picker (v4.7.7)
|
|
520
|
-
- **Feature**: Protection scope card in sidebar — shows protected/excluded file counts, actual protect/ignore patterns (v4.7.8)
|
|
521
|
-
- **Feature**: Alert countdown ticks live every second in sidebar (v4.7.8)
|
|
522
|
-
- **Fix**: Open Dashboard CORS/CSP issues — added `Access-Control-Allow-Origin`, relaxed CSP, fallback to browser on WebView failure (v4.7.8)
|
|
523
|
-
- **Fix**: `protect` patterns now use strict matching (full path only, no basename fallback) for consistency (v4.7.8)
|
|
524
|
-
- **Redesign**: Sidebar dashboard simplified — single status indicator, 2x2 action button grid, streamlined Quick Stats, removed clutter (v4.7.6)
|
|
525
|
-
|
|
526
|
-
### v4.7.5 — VSIX Self-Contained Build + Auto-Setup
|
|
527
|
-
|
|
528
|
-
- **Feature**: `build-vsix.js` packages all runtime dependencies into a self-contained VSIX — no npm installation needed
|
|
529
|
-
- **Feature**: `auto-setup.js` auto-detects IDE type (Cursor/Windsurf/Trae/VSCode), installs SKILL.md, registers MCP Server, creates default config on first activation
|
|
530
|
-
- **Fix**: `dashboard/server.js` PKG_PATH now dynamically resolved (supports skill dir, VSIX flat, `guard-version.json` fallback)
|
|
531
|
-
- **Enhancement**: Added `onStartupFinished` activation event so auto-setup runs even without `.cursor-guard.json`
|
|
532
|
-
|
|
533
|
-
### v4.7.0–v4.7.4 — IDE Extension + Bug Fixes
|
|
534
|
-
|
|
535
|
-
- **Feature**: VSCode/Cursor/Windsurf extension — full dashboard as WebView tab, status bar alert indicator, sidebar TreeView with project status, Command Palette integration
|
|
536
|
-
- **Feature**: Auto-activation on `.cursor-guard.json` detection, dashboard server runs in extension host process (zero subprocess overhead)
|
|
537
|
-
- **Feature**: Visual sidebar dashboard with charts, progress bars, status badges (v4.7.3)
|
|
538
|
-
- **Fix**: Smart path resolver (`paths.js`) for VSIX/skill/npm installation contexts (v4.7.4)
|
|
539
|
-
- **Fix**: WebView CSP, watcher infinite restart, snapshot status handling (v4.7.1–v4.7.4)
|
|
540
|
-
- **Adapt**: `fetchJson()` supports `__GUARD_BASE_URL__` for WebView; `copyText()` bridges to `vscode.env.clipboard` when in IDE
|
|
541
|
-
|
|
542
|
-
### v4.6.x — Alert UX Overhaul
|
|
543
|
-
|
|
544
|
-
- **Fix**: Alert countdown now updates every second (was only on 15s page refresh)
|
|
545
|
-
- **Fix**: Alert file details modal now shows per-file "Copy Restore Command" buttons
|
|
546
|
-
- **Fix**: Backup stale threshold changed to `max(interval*10, 300)s` (min 5 min); only checks when watcher is running
|
|
547
|
-
- **Feature**: Alert history always accessible (both active and no-alert states), persisted in `localStorage`
|
|
548
|
-
- **Feature**: Alert history as modal dialog with nested file detail drill-down
|
|
549
|
-
|
|
550
|
-
### v4.5.x — Protection Hardening
|
|
551
|
-
|
|
552
|
-
- **Fix**: Shadow hard-link ordering bug (previous snapshot was always empty directory)
|
|
553
|
-
- **Fix**: `changedFiles` now filters ignored paths from git diff output
|
|
554
|
-
- **Feature**: Alert structured file list — per-file path, action, +/- lines, sortable tables
|
|
555
|
-
- **Feature**: Shadow incremental hard links — unchanged files linked to previous snapshot, saving disk space
|
|
556
|
-
- **Feature**: `always_watch: true` config — watcher auto-starts with MCP server, zero protection gaps
|
|
557
|
-
- **Feature**: Dashboard server singleton — multiple projects share one port, hot-add new projects
|
|
558
|
-
- **Feature**: Dashboard version detection + one-click hot restart (`/api/restart` endpoint)
|
|
559
|
-
- **Feature**: File detail modal with per-file restore command copy buttons
|
|
560
|
-
- **Feature**: `cursor-guard-init` auto-creates `.cursor-guard.json`; `backup_interval_seconds` alias supported
|
|
561
|
-
- **License**: Changed to BSL 1.1
|
|
562
|
-
|
|
563
|
-
### v4.4.0 — V4 Final
|
|
564
|
-
|
|
565
|
-
- **Fix**: First snapshot now generates "Added N: file1, file2, ..." summary instead of blank — previously the very first backup had no summary because there was no parent tree to diff against
|
|
566
|
-
- **Feature**: `--dashboard` flag for watcher — `npx cursor-guard-backup --path <dir> --dashboard` starts the web dashboard alongside the watcher in a single process. Optional port: `--dashboard 4000`. Auto-increments if port is busy
|
|
567
|
-
- **Feature**: Doctor check "Git retention" — warns when git backup commits exceed 500 and `git_retention.enabled` is `false`, guiding users to enable auto-pruning before refs grow unbounded
|
|
568
|
-
- **Feature**: Doctor check "Backup integrity" — verifies that the latest auto-backup commit's tree object is reachable via `git cat-file -t`, catching silent corruption early
|
|
569
|
-
- **Improve**: `cursor-guard-init` now detects existing `.cursor-guard.json` and displays an upgrade notice instead of silently overwriting
|
|
570
|
-
- **Improve**: Dashboard server refactored to export `startDashboardServer()` for embedding into other processes
|
|
571
|
-
|
|
572
|
-
### v4.3.5
|
|
573
|
-
|
|
574
|
-
- **Fix**: Backup summary now uses incremental `diff-tree` instead of `git status --porcelain` — previously summary always showed cumulative changes since HEAD, now correctly shows changes since the last auto-backup
|
|
575
|
-
- **Improve**: Dashboard backup table "Changes" column uses stacked layout (file count + trigger / intent / detail on separate rows) for better readability
|
|
576
|
-
- **Improve**: Refined color palette — deeper background contrast, softer status colors (green `#4ade80`, amber `#f59e0b`, red `#ef4444`), deeper brand blue `#3b82f6`, wider text hierarchy gap
|
|
577
|
-
|
|
578
|
-
### v4.3.4
|
|
579
|
-
|
|
580
|
-
- **Improve**: Log rotation — `backup.log` now rotates at 1MB, keeping up to 3 old files (`backup.log.1`, `.2`, `.3`). Rotation runs on watcher startup and every 100 writes
|
|
581
|
-
- **Improve**: Watcher single-instance protection — lock file now includes startup timestamp; locks older than 24h are auto-cleaned even if PID check is unreliable on Windows
|
|
582
|
-
- **Improve**: `previewProjectRestore` output grouped — protected paths (`.cursor/`, `.gitignore`, `.cursor-guard.json`) summarized as `protectedPaths: { count: N }` instead of listing thousands of individual files, drastically reducing token cost
|
|
583
|
-
- **Improve**: SKILL.md Hard Rule #15 — agents must commit skill files after upgrade to ensure `restore_project` HEAD protection works correctly
|
|
584
|
-
|
|
585
|
-
### v4.3.3
|
|
586
|
-
|
|
587
|
-
- **Feature**: Intent context for snapshots — `snapshot_now` now accepts `intent`, `agent`, and `session` parameters, stored as Git commit trailers to form an audit trail per operation
|
|
588
|
-
- **Feature**: Dashboard displays intent badge in backup table and full intent/agent/session fields in restore-point drawer
|
|
589
|
-
- **Improve**: `parseCommitTrailers` refactored to a data-driven map, supporting all 6 trailer fields (Files-Changed, Summary, Trigger, Intent, Agent, Session)
|
|
590
|
-
- **Improve**: SKILL.md updated to guide AI agents to pass `intent` describing the operation about to happen
|
|
591
|
-
|
|
592
|
-
### v4.3.2
|
|
593
|
-
|
|
594
|
-
- **Fix**: `cursor-guard-init` now adds `node_modules/` (root-level) to `.gitignore` — prevents `git add -A` from scanning thousands of npm dependency files after `npm install cursor-guard --save-dev`
|
|
595
|
-
- **Improve**: Doctor "MCP version" mismatch warning now includes the reload keybinding (`Ctrl+Shift+P -> "Developer: Reload Window"`) for faster action
|
|
596
|
-
|
|
597
|
-
### v4.3.1
|
|
598
|
-
|
|
599
|
-
- **Fix**: `restore_project` now protects `.gitignore` — added to `GUARD_CONFIGS` so it is restored from HEAD after recovery, preventing post-restore full-tree scans (2500+ files)
|
|
600
|
-
- **Fix**: `cursor-guard-index.lock` cleanup — `createGitSnapshot` now removes stale `.lock` files on entry and in the `finally` block, preventing lock file remnants from blocking subsequent operations
|
|
601
|
-
- **Improve**: Auto-backup summary now filtered by `protect`/`ignore` patterns, excluding `.cursor/skills/` and other non-protected files
|
|
602
|
-
- **Improve**: Summary format changed from flat `M file1, A file2` to categorized `Modified 3: a.js; Added 1: b.js` with i18n support
|
|
603
|
-
- **Improve**: Manual snapshot `message` (from `snapshot_now`) now displayed in dashboard backup table and restore-point drawer
|
|
604
|
-
- **Improve**: SKILL.md adds best-practice guidance for AI agents to provide descriptive `message` when calling `snapshot_now`
|
|
605
|
-
|
|
606
|
-
### v4.3.0
|
|
607
|
-
|
|
608
|
-
- **Feature**: Backup context metadata — structured Git commit messages with `Files-Changed`, `Summary`, and `Trigger` trailers
|
|
609
|
-
- **Feature**: `listBackups` parses commit trailers and returns `filesChanged`, `summary`, `trigger` fields
|
|
610
|
-
- **Feature**: Dashboard backup table adds "Changes" column; restore-point drawer shows trigger, files changed, and summary
|
|
611
|
-
|
|
612
|
-
### v4.2.2
|
|
613
|
-
|
|
614
|
-
- **Fix**: `restore_project` now protects `.cursor-guard.json` during restore (prevents config loss)
|
|
615
|
-
- **Fix**: Post-restore HEAD recovery loop extended to restore both `.cursor/` and `.cursor-guard.json`
|
|
616
|
-
- **Improve**: `cursor-guard-init` now reminds users to `git commit` after installation in Git repos
|
|
617
|
-
|
|
618
|
-
### v4.2.1
|
|
619
|
-
|
|
620
|
-
- **Fix**: `t()` function uses `replaceAll` for i18n placeholder substitution
|
|
621
|
-
- **Fix**: Removed unused `loadActiveAlert` import from dashboard server
|
|
622
|
-
- **Fix**: Added `git-snapshot` type to dashboard filter bar
|
|
623
|
-
- **Fix**: Replaced `&&` with `;` in `detail.mcp_no_sdk` i18n string for cross-platform compatibility
|
|
624
|
-
- **Fix**: Deduplicated `sdkCandidates` in `doctor.js`
|
|
625
|
-
|
|
626
|
-
### v4.2.0
|
|
627
|
-
|
|
628
|
-
- **Feature**: Web dashboard — local read-only UI with health overview, backup table, restore-point drawers, diagnostics, protection scope
|
|
629
|
-
- **Feature**: Dual-language (zh-CN / en-US) with full i18n coverage including doctor checks, health issues, alert messages
|
|
630
|
-
- **Feature**: Multi-project support via CLI `--path` args and frontend project selector
|
|
631
|
-
|
|
632
|
-
---
|
|
633
|
-
|
|
634
|
-
## Release checklist
|
|
635
|
-
|
|
636
|
-
**Single source of truth**: the `version` field in the **repository root** `package.json`. Running `references/vscode-extension/build-vsix.js` copies that value into the extension `package.json` and `guard-version.json`, so the VSIX and npm tarball stay aligned.
|
|
637
|
-
|
|
638
|
-
**Full guide (bilingual, for humans and AI agents):** [docs/RELEASE.md](docs/RELEASE.md) — includes **Windows `gh` + UTF-8**: use `--notes-file` for GitHub Release bodies so Chinese text does not become mojibake.
|
|
639
|
-
|
|
640
|
-
### Generate a filled-in table (recommended)
|
|
641
|
-
|
|
642
|
-
From the repository root:
|
|
643
|
-
|
|
644
|
-
```bash
|
|
645
|
-
npm run release:checklist
|
|
646
|
-
```
|
|
647
|
-
|
|
648
|
-
Copy the terminal output into your own release tracker. It always reflects the current `package.json` version.
|
|
649
|
-
|
|
650
|
-
### Reference checklist
|
|
651
|
-
|
|
652
|
-
| Step | What to do |
|
|
653
|
-
|------|------------|
|
|
654
|
-
| **1. Version** | Bump root `package.json` `version`, then rebuild. Do not keep stale numbers (e.g. 4.9.5) in notes while the repo is already newer. |
|
|
655
|
-
| **2. VSIX** | `cd references/vscode-extension && node build-vsix.js && cd dist && npx --yes @vscode/vsce package --no-dependencies` |
|
|
656
|
-
| **3. Artifact** | `cursor-guard-ide-<version>.vsix` in `references/vscode-extension/dist/` (file name matches `version`). |
|
|
657
|
-
| **4. Git** | Commit and push your default branch; create and push tag `v<version>` (example: `git tag -a vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z`). Record the actual commit hash in your notes. |
|
|
658
|
-
| **5. GitHub Release** | [Create a release](https://github.com/zhangqiang8vipp/cursor-guard/releases/new), select tag `v<version>`, attach the VSIX. |
|
|
659
|
-
| **6. Release branches** | Fast-forward maintenance branches such as `release/v4.8.x` / `release/v4.7.x` to the current `master` when your branching policy requires it. |
|
|
660
|
-
| **7. npm** | From the repo root: `npm publish`. If npm asks for OTP, complete verification in the browser, then run `npm publish` again. |
|
|
661
|
-
|
|
662
|
-
Skipping the Marketplace is fine; GitHub Release + VSIX is enough for many users.
|
|
663
|
-
|
|
664
|
-
---
|
|
665
|
-
|
|
666
|
-
## Known Limitations
|
|
667
|
-
|
|
668
|
-
- **Binary files**: Git diffs and snapshots work on text files. Binary files (images, compiled assets) are stored but cannot be meaningfully diffed or partially restored.
|
|
669
|
-
- **Untracked files**: Files never committed to Git cannot be recovered from Git history. Shadow copy (`backup_strategy: "shadow"` or `"both"`) is the only safety net for untracked files.
|
|
670
|
-
- **Concurrent agents**: If multiple AI agent threads write to the same file simultaneously, snapshots cannot prevent race conditions. Avoid parallel edits to the same file.
|
|
671
|
-
- **External tools modifying the index**: Tools that alter Git's index (e.g. other Git GUIs, IDE Git integrations) while auto-backup is running may conflict. The script uses a temporary index to minimize this, but edge cases exist.
|
|
672
|
-
- **Git worktree**: The auto-backup script supports worktree layouts (`git rev-parse --git-dir`), but has not been tested with all exotic setups (e.g. `--separate-git-dir`).
|
|
673
|
-
- **Pre-warning scope**: `pre_warning` is currently an editor/extension-side "last brake", not a universal cross-process write blocker. Headless shell / MCP flows surface it through status and dashboard after detection rather than hard-blocking writes.
|
|
674
|
-
- **Cursor terminal interference**: Cursor's integrated terminal injects `--trailer` flags into `git commit` commands, which breaks plumbing commands like `commit-tree`. Always run auto-backup in a **separate terminal window**.
|
|
675
|
-
- **Large repos**: For very large repositories, `git add -A` in the backup loop may be slow. Use `protect` patterns in `.cursor-guard.json` to narrow scope.
|
|
676
|
-
|
|
677
|
-
## Requirements
|
|
678
|
-
|
|
679
|
-
- **Node.js >= 18** — core runtime for backup and health check scripts
|
|
680
|
-
- **Git** — for primary backup strategy (not needed for shadow-only mode)
|
|
681
|
-
- **Cursor IDE** — with Agent mode enabled
|
|
682
|
-
|
|
683
|
-
---
|
|
684
|
-
|
|
685
|
-
## Support / Donate
|
|
686
|
-
|
|
687
|
-
This is an independent open-source project maintained by a solo developer. If Cursor Guard has saved your code or your time, consider buying me a coffee :)
|
|
688
|
-
|
|
689
|
-
| WeChat Pay | Alipay |
|
|
690
|
-
|:---:|:---:|
|
|
691
|
-
| <img src="media/wechat-pay.png" alt="WeChat Pay" width="200"> | <img src="media/alipay.jpg" alt="Alipay" width="200"> |
|
|
692
|
-
|
|
693
|
-
---
|
|
694
|
-
|
|
695
|
-
## License
|
|
696
|
-
|
|
697
|
-
[BSL 1.1](LICENSE)
|
|
1
|
+
# Cursor Guard
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/cursor-guard)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Protects your code from accidental AI overwrite or deletion in [Cursor](https://cursor.com).
|
|
7
|
+
|
|
8
|
+
**[中文文档](README.zh-CN.md)**
|
|
9
|
+
**Release / 发版(maintainers & AI):** [docs/RELEASE.md](docs/RELEASE.md)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What It Does
|
|
14
|
+
|
|
15
|
+
When Cursor's AI agent edits your files, there's a risk of accidental overwrites, deletions, or loss of work. **Cursor Guard** enforces a safety protocol:
|
|
16
|
+
|
|
17
|
+
- **Mandatory pre-write snapshots** — Git commit or shadow copy before any destructive operation
|
|
18
|
+
- **Read before Write** — The agent must read a file before overwriting it
|
|
19
|
+
- **Review before apply** — Diff previews and explicit confirmation for dangerous ops
|
|
20
|
+
- **Deterministic recovery** — Clear priority-ordered recovery paths (Git → shadow copies → conversation context → editor history)
|
|
21
|
+
- **Configurable scope** — Protect only what matters via `.cursor-guard.json`
|
|
22
|
+
- **Secrets filtering** — Sensitive files (`.env`, keys, certificates) are auto-excluded from backups
|
|
23
|
+
- **Auto-backup script** — A cross-platform watcher (Node.js) that periodically snapshots to a dedicated Git branch without disturbing your working tree
|
|
24
|
+
- **MCP tool calls (optional)** — 10 structured tools (diagnostics, snapshot, **record_guard_event** audit bookmark, restore, status, dashboard, alerts, etc.) with JSON responses and lower token cost
|
|
25
|
+
- **Auto-fix diagnostics** — `doctor_fix` automatically patches missing configs, uninitialized Git repos, gitignore gaps, and stale locks
|
|
26
|
+
- **Proactive change-velocity alerts (V4)** — Auto-detects abnormal file change patterns and raises risk warnings
|
|
27
|
+
- **Pre-warning destructive edit guard (V4.9.7)** — Detects risky partial deletions before they quietly stick, with softer auto-continue review, sidebar language sync, and `popup` / `dashboard` / `silent` modes
|
|
28
|
+
- **Backup health dashboard (V4)** — One-call comprehensive view: strategy, counts, disk usage, protection scope, health status
|
|
29
|
+
- **Web dashboard (V4.2)** — Local read-only web UI at `http://127.0.0.1:3120` — see health, backups, restore points, diagnostics, protection scope at a glance. Dual-language (zh-CN / en-US), auto-refresh, multi-project support
|
|
30
|
+
- **IDE extension (V4.7)** — Full dashboard embedded in VSCode/Cursor/Windsurf as a WebView tab + status bar alert indicator + sidebar project tree. No browser needed
|
|
31
|
+
- **Event-driven watching (V4.9)** — `fs.watch` + debounce replaces blind polling. Backup latency < 500ms, zero CPU when idle. Automatic fallback to polling on unsupported platforms
|
|
32
|
+
- **Right-click context menus (V4.7.7)** — Add files/folders to `protect` or `ignore` lists via Explorer/Editor right-click menu with pattern picker
|
|
33
|
+
- **Real-time sidebar (V4.9.1)** — "Last backup Xs ago" and alert countdown tick every second in the sidebar dashboard
|
|
34
|
+
- **Smart restore for deleted files (V4.8.4)** — Restore commands auto-point to parent commit (`hash~1`) when file was deleted in the snapshot, preventing "file not found" errors
|
|
35
|
+
- **Self-contained VSIX (V4.8.1)** — MCP server bundled as a single file via esbuild, zero npm dependencies needed for IDE extension
|
|
36
|
+
- **One-click hot restart (V4.5.8)** — Dashboard detects new versions and offers in-place server restart without losing state
|
|
37
|
+
- **Shadow incremental hard links (V4.5.4)** — Unchanged files are hard-linked to save disk space and I/O
|
|
38
|
+
- **Strong protection mode (V4.5.4)** — `always_watch: true` auto-starts watcher with MCP server, ensuring zero protection gaps
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
### Method 1: npm (Recommended)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install cursor-guard
|
|
48
|
+
npx cursor-guard-init
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The `init` command copies skill files to `.cursor/skills/cursor-guard/`, installs MCP dependencies, and adds `.gitignore` entries — all in one step.
|
|
52
|
+
|
|
53
|
+
Options:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx cursor-guard-init # project-local (default)
|
|
57
|
+
npx cursor-guard-init --global # global (~/.cursor/skills/)
|
|
58
|
+
npx cursor-guard-init --path /my/project # specify project root
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
After init, the npm package in `node_modules` is no longer needed:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm uninstall cursor-guard
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
<details>
|
|
68
|
+
<summary>Manual installation (without init command)</summary>
|
|
69
|
+
|
|
70
|
+
If you prefer manual setup, copy files then install dependencies:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Copy
|
|
74
|
+
cp -r node_modules/cursor-guard .cursor/skills/cursor-guard
|
|
75
|
+
|
|
76
|
+
# Install MCP dependencies in the skill directory
|
|
77
|
+
cd .cursor/skills/cursor-guard && npm install --omit=dev && cd -
|
|
78
|
+
|
|
79
|
+
# Add to .gitignore so node_modules aren't captured by git snapshots
|
|
80
|
+
echo ".cursor/skills/**/node_modules/" >> .gitignore
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
### Method 2: Git clone
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Global
|
|
89
|
+
git clone https://github.com/zhangqiang8vipp/cursor-guard.git ~/.cursor/skills/cursor-guard
|
|
90
|
+
|
|
91
|
+
# Per-project
|
|
92
|
+
git clone https://github.com/zhangqiang8vipp/cursor-guard.git .cursor/skills/cursor-guard
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Method 3: Manual download
|
|
96
|
+
|
|
97
|
+
Download from [GitHub Releases](https://github.com/zhangqiang8vipp/cursor-guard/releases) and extract to:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
~/.cursor/skills/cursor-guard/ # Global
|
|
101
|
+
<project-root>/.cursor/skills/cursor-guard/ # Per-project
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Verify Installation
|
|
105
|
+
|
|
106
|
+
After installation, your directory structure should look like this:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
.cursor/skills/cursor-guard/
|
|
110
|
+
├── SKILL.md # AI agent instructions (with MCP dual-path logic)
|
|
111
|
+
├── ROADMAP.md # Version evolution roadmap
|
|
112
|
+
├── README.md
|
|
113
|
+
├── README.zh-CN.md
|
|
114
|
+
├── LICENSE
|
|
115
|
+
├── package.json
|
|
116
|
+
└── references/
|
|
117
|
+
├── lib/
|
|
118
|
+
│ ├── auto-backup.js # Backup watcher (calls Core)
|
|
119
|
+
│ ├── guard-doctor.js # Health check CLI (calls Core)
|
|
120
|
+
│ ├── utils.js # Shared utilities
|
|
121
|
+
│ └── core/ # V3 Core layer (pure logic)
|
|
122
|
+
│ ├── doctor.js # Diagnostics (incl. MCP self-check)
|
|
123
|
+
│ ├── doctor-fix.js # Auto-fix common issues
|
|
124
|
+
│ ├── snapshot.js # Git snapshots + shadow copies
|
|
125
|
+
│ ├── backups.js # Backup listing + retention
|
|
126
|
+
│ ├── restore.js # Single file / project restore
|
|
127
|
+
│ ├── status.js # Backup system status
|
|
128
|
+
│ ├── anomaly.js # V4: Change-velocity detection
|
|
129
|
+
│ ├── pre-warning.js # V4.9.7: destructive edit risk scoring + persistence
|
|
130
|
+
│ └── dashboard.js # V4: Health dashboard aggregation
|
|
131
|
+
├── dashboard/
|
|
132
|
+
│ ├── server.js # Dashboard HTTP server + API
|
|
133
|
+
│ └── public/ # Web UI (HTML/CSS/JS)
|
|
134
|
+
│ ├── index.html
|
|
135
|
+
│ ├── style.css
|
|
136
|
+
│ └── app.js
|
|
137
|
+
├── mcp/
|
|
138
|
+
│ └── server.js # MCP Server (10 tools)
|
|
139
|
+
├── vscode-extension/ # IDE Extension (V4.7)
|
|
140
|
+
│ ├── extension.js # Extension entry point
|
|
141
|
+
│ ├── package.json # Extension manifest
|
|
142
|
+
│ ├── lib/ # Modules (dashboard-manager, webview, status-bar, tree-view, poller)
|
|
143
|
+
│ └── media/ # Icons (SVG + PNG)
|
|
144
|
+
├── bin/
|
|
145
|
+
│ ├── cursor-guard-backup.js # CLI: npx cursor-guard-backup
|
|
146
|
+
│ ├── cursor-guard-doctor.js # CLI: npx cursor-guard-doctor
|
|
147
|
+
│ └── cursor-guard-mcp (server.js)# CLI: npx cursor-guard-mcp
|
|
148
|
+
├── auto-backup.ps1 / .sh # Thin wrappers
|
|
149
|
+
├── guard-doctor.ps1 / .sh
|
|
150
|
+
├── recovery.md # Recovery commands
|
|
151
|
+
├── cursor-guard.example.json # Example config
|
|
152
|
+
├── cursor-guard.schema.json # Config schema
|
|
153
|
+
├── config-reference.md # Config docs (EN)
|
|
154
|
+
└── config-reference.zh-CN.md # Config docs (CN)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The skill activates automatically when the AI agent detects risky operations or when you mention recovery-related terms. No extra setup needed.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Quick Start
|
|
162
|
+
|
|
163
|
+
1. **Install the skill** using any method above
|
|
164
|
+
|
|
165
|
+
2. **Open Cursor** and start an Agent conversation
|
|
166
|
+
|
|
167
|
+
3. **The skill works automatically** — when the AI agent tries to edit files, it will:
|
|
168
|
+
- Create a Git snapshot before writing
|
|
169
|
+
- Read files before overwriting
|
|
170
|
+
- Show diff previews for dangerous operations
|
|
171
|
+
- Report a status block after each protected operation
|
|
172
|
+
|
|
173
|
+
4. **(Optional) Add project config** to customize protection scope:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
cp .cursor/skills/cursor-guard/references/cursor-guard.example.json .cursor-guard.json
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
5. **(Optional) Enable MCP tool calls** — add to `.cursor/mcp.json`:
|
|
180
|
+
|
|
181
|
+
```jsonc
|
|
182
|
+
{
|
|
183
|
+
"mcpServers": {
|
|
184
|
+
"cursor-guard": {
|
|
185
|
+
"command": "node",
|
|
186
|
+
"args": ["<skill-path>/references/mcp/server.js"]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
This gives the AI agent 10 structured tools (diagnostics, snapshot, record_guard_event, restore, dashboard, alerts, etc.) with JSON responses — faster, more reliable, and lower token cost. Everything works without MCP too.
|
|
193
|
+
|
|
194
|
+
6. **(Optional) Run auto-backup** in a separate terminal:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npx cursor-guard-backup --path /my/project
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Project Configuration
|
|
201
|
+
|
|
202
|
+
Edit `.cursor-guard.json` to define which files to protect:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"protect": ["src/**", "lib/**", "package.json"],
|
|
207
|
+
"ignore": ["node_modules/**", "dist/**"],
|
|
208
|
+
"auto_backup_interval_seconds": 60,
|
|
209
|
+
"secrets_patterns": [".env", ".env.*", "*.key", "*.pem"],
|
|
210
|
+
"pre_restore_backup": "always",
|
|
211
|
+
"proactive_alert": true,
|
|
212
|
+
"alert_thresholds": { "files_per_window": 20, "window_seconds": 10, "cooldown_seconds": 60 },
|
|
213
|
+
"enable_pre_warning": true,
|
|
214
|
+
"pre_warning_threshold": 30,
|
|
215
|
+
"pre_warning_mode": "popup",
|
|
216
|
+
"pre_warning_exclude_patterns": ["generated/**"],
|
|
217
|
+
"retention": { "mode": "days", "days": 30 }
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### `pre_restore_backup` — restore behavior control
|
|
222
|
+
|
|
223
|
+
| Value | Behavior |
|
|
224
|
+
|-------|----------|
|
|
225
|
+
| `"always"` (default) | Automatically preserve current version before every restore. No prompt. |
|
|
226
|
+
| `"ask"` | Prompt you each time: "Preserve current version before restore? (Y/n)" — you decide per restore. |
|
|
227
|
+
| `"never"` | Never preserve current version before restore (not recommended). |
|
|
228
|
+
|
|
229
|
+
Regardless of config, you can always override per-request:
|
|
230
|
+
- Say "don't preserve current version" to skip even when config is `"always"`
|
|
231
|
+
- Say "preserve current first" to force even when config is `"never"`
|
|
232
|
+
|
|
233
|
+
#### `enable_pre_warning` — destructive partial-delete pre-warning
|
|
234
|
+
|
|
235
|
+
When enabled, the IDE extension evaluates edits that remove lines or whole methods/functions before they slip by unnoticed.
|
|
236
|
+
|
|
237
|
+
| Field | Default | Meaning |
|
|
238
|
+
|-------|---------|---------|
|
|
239
|
+
| `enable_pre_warning` | `false` | Turn pre-warning on without affecting existing projects |
|
|
240
|
+
| `pre_warning_threshold` | `30` | Warn when deletion risk reaches this percent |
|
|
241
|
+
| `pre_warning_mode` | `"popup"` | `popup` = interrupt with actions, `dashboard` = highlight only, `silent` = log/status only |
|
|
242
|
+
| `pre_warning_exclude_patterns` | `[]` | Skip generated files, migrations, vendored code, etc. |
|
|
243
|
+
|
|
244
|
+
Method/function removal is treated as high risk and can still trigger a warning even when the deleted-line percentage is below the threshold.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Auto-Backup Script
|
|
249
|
+
|
|
250
|
+
Run in a separate terminal while working in Cursor. Cross-platform — requires Node.js >= 18.
|
|
251
|
+
|
|
252
|
+
Important:
|
|
253
|
+
|
|
254
|
+
- You can run the command from any directory
|
|
255
|
+
- But `--path` must point to the project root you want to protect
|
|
256
|
+
- If you are already in the project root, `--path .` is fine
|
|
257
|
+
- If you are not in the project root, do not use `--path .`; use the full target path instead
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# If you are already in the project root
|
|
261
|
+
npx cursor-guard-backup --path .
|
|
262
|
+
|
|
263
|
+
# If you are not in the project root
|
|
264
|
+
npx cursor-guard-backup --path /my/project
|
|
265
|
+
npx cursor-guard-backup --path /my/project --interval 30
|
|
266
|
+
|
|
267
|
+
# Windows PowerShell
|
|
268
|
+
.\references\auto-backup.ps1 -Path "D:\MyProject"
|
|
269
|
+
|
|
270
|
+
# macOS / Linux
|
|
271
|
+
./references/auto-backup.sh /my/project
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Wrong example:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# You are in some other directory
|
|
278
|
+
# In that case --path . protects the current directory, not your real project
|
|
279
|
+
npx cursor-guard-backup --path .
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
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.
|
|
283
|
+
|
|
284
|
+
### Health Check
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
npx cursor-guard-doctor --path /my/project
|
|
288
|
+
|
|
289
|
+
# Windows: .\references\guard-doctor.ps1 -Path "D:\MyProject"
|
|
290
|
+
# macOS/Linux: ./references/guard-doctor.sh /my/project
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
> **Note**: Run backup/doctor scripts in a separate terminal, NOT inside Cursor's integrated terminal.
|
|
294
|
+
|
|
295
|
+
### Web Dashboard
|
|
296
|
+
|
|
297
|
+
A local read-only web page for monitoring backup health, restore points, protection scope, and diagnostics — all in one view.
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Monitor a single project
|
|
301
|
+
npx cursor-guard-dashboard --path /my/project
|
|
302
|
+
|
|
303
|
+
# Monitor multiple projects
|
|
304
|
+
npx cursor-guard-dashboard --path /project-a --path /project-b
|
|
305
|
+
|
|
306
|
+
# Custom port (default: 3120)
|
|
307
|
+
npx cursor-guard-dashboard --path /my/project --port 8080
|
|
308
|
+
|
|
309
|
+
# Windows PowerShell (from skill directory)
|
|
310
|
+
node references\dashboard\server.js --path "D:\MyProject"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Then open `http://127.0.0.1:3120` in your browser. Or use the **IDE Extension** (see below) to embed the dashboard directly in your editor.
|
|
314
|
+
|
|
315
|
+
Features:
|
|
316
|
+
|
|
317
|
+
- **Read-only** — no write operations, safe to run anytime
|
|
318
|
+
- **Dual-language** — zh-CN / en-US, auto-detects system language, manual toggle in top-right
|
|
319
|
+
- **Auto-refresh** — pulls data every 15 seconds, plus manual refresh button
|
|
320
|
+
- **Multi-project** — pass multiple `--path` args to monitor several projects from one page
|
|
321
|
+
- **4 sections**: Overview (health + watcher + alerts + latest backups), Backups & Recovery (restore point table with type filters), Protection Scope (protect/ignore patterns), Diagnostics (doctor checks)
|
|
322
|
+
- **2 detail drawers**: Restore Point drawer (preview JSON, copy ref/hash), Doctor drawer (full check list, WARN/FAIL expanded by default)
|
|
323
|
+
- **Security** — binds to `127.0.0.1` only (not exposed to LAN), API uses project IDs instead of raw file paths, static file serving restricted to `public/` directory
|
|
324
|
+
- **Zero extra dependencies** — uses Node.js built-in `http` module + existing cursor-guard core modules
|
|
325
|
+
|
|
326
|
+
### IDE Extension (VSCode / Cursor / Windsurf)
|
|
327
|
+
|
|
328
|
+
Embed the full dashboard directly inside your IDE — no browser needed.
|
|
329
|
+
|
|
330
|
+
#### Method A: VSIX standalone (recommended, no npm needed)
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# Build the self-contained VSIX (version = root package.json "version")
|
|
334
|
+
cd references/vscode-extension
|
|
335
|
+
node build-vsix.js
|
|
336
|
+
cd dist
|
|
337
|
+
npx --yes @vscode/vsce package --no-dependencies
|
|
338
|
+
|
|
339
|
+
# Install the generated .vsix (VERSION always matches package.json)
|
|
340
|
+
V=$(node -p "require('../../../package.json').version")
|
|
341
|
+
code --install-extension "cursor-guard-ide-${V}.vsix"
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
PowerShell (from `references\vscode-extension\dist`):
|
|
345
|
+
|
|
346
|
+
```powershell
|
|
347
|
+
$V = node -p "require('../../../package.json').version"
|
|
348
|
+
code --install-extension "cursor-guard-ide-$V.vsix"
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Print the full release checklist from the repo root: `npm run release:checklist`.
|
|
352
|
+
|
|
353
|
+
On first activation, the extension automatically:
|
|
354
|
+
- Installs `SKILL.md` to your IDE's skills directory
|
|
355
|
+
- Registers the MCP Server in your IDE's `mcp.json`
|
|
356
|
+
- Creates a default `.cursor-guard.json` if missing
|
|
357
|
+
|
|
358
|
+
#### Method B: From source (development)
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
cd references/vscode-extension
|
|
362
|
+
code --install-extension .
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Features:
|
|
366
|
+
|
|
367
|
+
- **WebView Dashboard** — full dashboard embedded as an editor tab, identical to the browser version
|
|
368
|
+
- **Status Bar Indicator** — shows `Guard: OK` (green) or `Guard: 22 files!` (yellow) in real-time
|
|
369
|
+
- **Sidebar TreeView** — activity bar icon with project list, watcher status, backup stats, alerts, health
|
|
370
|
+
- **Visual Sidebar** — graphical dashboard with live-ticking backup age, alert countdown, protection scope, quick stats
|
|
371
|
+
- **Pre-warning delete guard** — flags risky partial deletions, removed methods, and suspicious line drops before they quietly stick
|
|
372
|
+
- **Command Palette** — `Open Dashboard`, `Snapshot Now`, `Start/Stop Watcher`, `Quick Restore`, `Doctor`, `Refresh`
|
|
373
|
+
- **Right-click menus** — add files/folders to `protect` or `ignore` via Explorer/Editor context menu
|
|
374
|
+
- **Event-driven refresh** — `FileSystemWatcher` pushes UI updates on file changes (< 1.5s latency), 30s heartbeat fallback
|
|
375
|
+
- **Auto-setup (V4.7.5)** — auto-detects IDE type, installs Skill, registers MCP, creates config on first run
|
|
376
|
+
- **Self-contained (V4.8.1)** — MCP server bundled via esbuild, zero npm dependencies
|
|
377
|
+
- **Multi-project** — hot-loads all workspace folders with `.cursor-guard.json`
|
|
378
|
+
- **Compatible** — works with VSCode ^1.74.0, Cursor, Windsurf, Trae, and all VSCode-based IDEs
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Recovery
|
|
383
|
+
|
|
384
|
+
If something goes wrong, just tell the AI agent in natural language.
|
|
385
|
+
|
|
386
|
+
**Default behavior**: Before any restore, the agent automatically preserves your current version so you can undo the restore if needed. You don't need to ask for this — it happens by default. To skip, explicitly say "don't preserve current version" or "skip backup before restore".
|
|
387
|
+
|
|
388
|
+
### By time
|
|
389
|
+
|
|
390
|
+
> "restore to 5 minutes ago"
|
|
391
|
+
> "go back to yesterday's version"
|
|
392
|
+
> "restore to 3pm today"
|
|
393
|
+
|
|
394
|
+
### By version
|
|
395
|
+
|
|
396
|
+
> "undo the last change"
|
|
397
|
+
> "go back 3 versions"
|
|
398
|
+
> "restore to the previous version"
|
|
399
|
+
|
|
400
|
+
### By file
|
|
401
|
+
|
|
402
|
+
> "restore src/app.py to 10 minutes ago"
|
|
403
|
+
> "restore src/app.py to the previous version"
|
|
404
|
+
|
|
405
|
+
The agent will:
|
|
406
|
+
1. **Preserve your current version** first (unless you opt out)
|
|
407
|
+
2. Search Git history and auto-backup snapshots
|
|
408
|
+
3. Show matching versions for you to choose
|
|
409
|
+
4. Restore after your confirmation
|
|
410
|
+
5. Report both the pre-restore backup ref and the restore result
|
|
411
|
+
|
|
412
|
+
If the pre-restore backup fails, the agent will **not** proceed — it will wait for your explicit confirmation before restoring without a safety net.
|
|
413
|
+
|
|
414
|
+
### Recovery priority
|
|
415
|
+
|
|
416
|
+
1. **Git** — `git restore`, `git reset`, `git reflog`
|
|
417
|
+
2. **Auto-backup ref** — `refs/guard/auto-backup`
|
|
418
|
+
3. **Shadow copies** — `.cursor-guard-backup/<timestamp>/`
|
|
419
|
+
4. **Conversation context** — Original file content captured by agent Read calls
|
|
420
|
+
5. **Editor history** — VS Code/Cursor Timeline (auxiliary)
|
|
421
|
+
|
|
422
|
+
See [references/recovery.md](references/recovery.md) for detailed commands.
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## Trigger Keywords
|
|
427
|
+
|
|
428
|
+
The skill activates on these signals:
|
|
429
|
+
|
|
430
|
+
- File edits, deletes, renames by the AI agent
|
|
431
|
+
- Recovery requests: "rollback", "undo", "recover", "restore"
|
|
432
|
+
- Time-based recovery: "restore to N minutes ago", "go back to yesterday"
|
|
433
|
+
- Version-based recovery: "previous version", "go back N versions"
|
|
434
|
+
- History issues: checkpoints missing, Timeline not working, save failures
|
|
435
|
+
- Health check: "guard doctor", "check guard setup", "is MCP working"
|
|
436
|
+
- Auto-fix: "guard fix", "fix config"
|
|
437
|
+
- Backup status: "guard status", "is the watcher running", "last backup time"
|
|
438
|
+
- Dashboard: "dashboard", "health overview", "backup summary"
|
|
439
|
+
- Alerts: "any alerts?", "change velocity warning", "risk status"
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## Files
|
|
444
|
+
|
|
445
|
+
| File | Purpose |
|
|
446
|
+
|------|---------|
|
|
447
|
+
| `SKILL.md` | Main skill instructions for the AI agent (with MCP dual-path) |
|
|
448
|
+
| `ROADMAP.md` | Version evolution roadmap (V2-V7) |
|
|
449
|
+
| `references/lib/core/` | Core layer: 9 pure-logic modules (doctor / doctor-fix / snapshot / backups / restore / status / anomaly / pre-warning / dashboard) |
|
|
450
|
+
| `references/mcp/server.js` | MCP Server: 10 structured tools (optional) |
|
|
451
|
+
| `references/lib/auto-backup.js` | Auto-backup watcher (calls Core) |
|
|
452
|
+
| `references/lib/guard-doctor.js` | Health check CLI shell (calls Core) |
|
|
453
|
+
| `references/lib/utils.js` | Shared utilities (config, glob, git, manifest) |
|
|
454
|
+
| `references/bin/cursor-guard-backup.js` | CLI entry: `npx cursor-guard-backup` |
|
|
455
|
+
| `references/bin/cursor-guard-doctor.js` | CLI entry: `npx cursor-guard-doctor` |
|
|
456
|
+
| `references/dashboard/server.js` | Dashboard HTTP server + REST API |
|
|
457
|
+
| `references/dashboard/public/` | Dashboard web UI (index.html, style.css, app.js) |
|
|
458
|
+
| `references/vscode-extension/` | IDE Extension: WebView dashboard, status bar, sidebar tree, commands |
|
|
459
|
+
| `references/auto-backup.ps1` / `.sh` | Thin wrappers (Windows / macOS+Linux) |
|
|
460
|
+
| `references/guard-doctor.ps1` / `.sh` | Thin wrappers (Windows / macOS+Linux) |
|
|
461
|
+
| `references/recovery.md` | Recovery command templates |
|
|
462
|
+
| `references/cursor-guard.example.json` | Example project configuration |
|
|
463
|
+
| `references/cursor-guard.schema.json` | JSON Schema for config validation |
|
|
464
|
+
| `references/config-reference.md` | Config field docs (English) |
|
|
465
|
+
| `references/config-reference.zh-CN.md` | Config field docs (Chinese) |
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## Changelog
|
|
470
|
+
|
|
471
|
+
### v4.9.9 — Dedicated release guide (`docs/RELEASE.md`)
|
|
472
|
+
|
|
473
|
+
- **Docs**: New bilingual **[docs/RELEASE.md](docs/RELEASE.md)** for maintainers, developers, and AI agents (full procedure, Windows `gh` + UTF-8 `--notes-file`, npm OTP)
|
|
474
|
+
- **Docs**: README / README.zh-CN link to the guide from the header and the release-checklist section; `npm run release:checklist` footer points to the same file
|
|
475
|
+
- **Packaging**: `docs/RELEASE.md` added to npm `files` so it ships with the package
|
|
476
|
+
|
|
477
|
+
### v4.9.8 — Release docs, checklist script, sidebar brand asset
|
|
478
|
+
|
|
479
|
+
- **Docs**: Bilingual **Release checklist** sections in README / README.zh-CN; steps tied to root `package.json` `version` so VSIX file name, Git tag, and npm stay consistent
|
|
480
|
+
- **Tooling**: `npm run release:checklist` (`scripts/print-release-checklist.js`) prints a ready-to-paste table; `build-vsix.js` logs the expected VSIX file name after build
|
|
481
|
+
- **IDE**: Sidebar header can show packaged brand artwork via `media/brand-placeholder.png` and `asWebviewUri` (fallback gradient if the file is absent)
|
|
482
|
+
|
|
483
|
+
### v4.9.7 — Softer Pre-Warning UX, Sidebar Locale Sync, and Watcher Singleton Guard
|
|
484
|
+
|
|
485
|
+
- **Improve**: `popup` mode now uses a softer auto-continue review flow with a 2-second timeout instead of a hard modal stop
|
|
486
|
+
- **Improve**: Pre-warning review text now follows the sidebar language toggle, keeping zh-CN / en-US messaging consistent inside the IDE
|
|
487
|
+
- **Fix**: Sidebar keeps showing watcher / health status even when delete-risk warnings are present, and popup-mode warnings no longer stick forever
|
|
488
|
+
- **Fix**: IDE watcher start/stop logic now uses the real per-project lock path and pending-process guard, preventing repeated clicks from spawning duplicate watchers
|
|
489
|
+
- **Docs**: README, roadmap, and skill notes updated for the 4.9.7 release flow and IDE behavior
|
|
490
|
+
|
|
491
|
+
### v4.9.6 — Pre-Warning for Destructive Partial Deletes
|
|
492
|
+
|
|
493
|
+
- **Feature**: Added configurable `pre_warning` support in `.cursor-guard.json` — `enable_pre_warning`, `pre_warning_threshold`, `pre_warning_mode`, `pre_warning_exclude_patterns`
|
|
494
|
+
- **Feature**: IDE extension now detects risky line/method removals and can react in `popup`, `dashboard`, or `silent` mode
|
|
495
|
+
- **Feature**: `backup_status`, `dashboard`, sidebar, status bar, and browser dashboard surface active delete-risk warnings
|
|
496
|
+
- **Improve**: New `pre-warning.js` core module centralizes deletion-risk scoring, active-warning persistence, and warning history
|
|
497
|
+
- **Docs**: README, skill guide, roadmap, and config references now document the pre-warning flow end-to-end
|
|
498
|
+
|
|
499
|
+
### v4.9.0–v4.9.1 — Event-Driven Architecture
|
|
500
|
+
|
|
501
|
+
- **Architecture**: Watcher (`auto-backup.js`) rewritten from `while+sleep` polling to `fs.watch` event-driven with 500ms debounce. Zero CPU when idle, backup latency < 500ms
|
|
502
|
+
- **Fallback**: Automatic degradation to polling mode if `fs.watch` is unavailable (e.g. older Linux kernels)
|
|
503
|
+
- **Config hot-reload**: `.cursor-guard.json` changes trigger instant config reload via `fs.watch` event (no more waiting 10 polling cycles)
|
|
504
|
+
- **IDE FileSystemWatcher**: Extension uses VSCode built-in `createFileSystemWatcher` to push UI updates on file changes (1.5s debounce)
|
|
505
|
+
- **Poller heartbeat**: Reduced from 5s fixed interval to 30s heartbeat; UI updates are now event-driven
|
|
506
|
+
- **Live sidebar counters**: "Last backup Xs ago" ticks every second in real-time (v4.9.1)
|
|
507
|
+
|
|
508
|
+
### v4.8.0–v4.8.5 — Bundling, Doctor Fixes, Restore UX
|
|
509
|
+
|
|
510
|
+
- **Fix**: MCP server bundled as single self-contained file via esbuild — eliminates all transitive dependency issues (`zod-to-json-schema`, `ajv`, etc.) (v4.8.1)
|
|
511
|
+
- **Fix**: `doctor` MCP check no longer false-warns when cursor-guard is configured in `.cursor/mcp.json` (v4.8.2)
|
|
512
|
+
- **Fix**: Skill directory `references/` now auto-creates junction link to extension runtime files on every activation (v4.8.2)
|
|
513
|
+
- **Fix**: Deleted file restore commands auto-point to parent commit (`hash~1`), preventing "file not found" errors. Button shows "Restore pre-delete" with orange styling (v4.8.4)
|
|
514
|
+
- **Fix**: Files outside `protect` scope no longer appear as phantom "deleted" in change summaries (v4.8.5)
|
|
515
|
+
- **Improve**: VSIX package reduced from 3.18 MB to 1.27 MB thanks to esbuild bundling
|
|
516
|
+
|
|
517
|
+
### v4.7.6–v4.7.9 — Sidebar Redesign, Context Menus, Protection Scope
|
|
518
|
+
|
|
519
|
+
- **Feature**: Right-click context menus — add files/folders to `protect` or `ignore` via Explorer/Editor menus with pattern picker (v4.7.7)
|
|
520
|
+
- **Feature**: Protection scope card in sidebar — shows protected/excluded file counts, actual protect/ignore patterns (v4.7.8)
|
|
521
|
+
- **Feature**: Alert countdown ticks live every second in sidebar (v4.7.8)
|
|
522
|
+
- **Fix**: Open Dashboard CORS/CSP issues — added `Access-Control-Allow-Origin`, relaxed CSP, fallback to browser on WebView failure (v4.7.8)
|
|
523
|
+
- **Fix**: `protect` patterns now use strict matching (full path only, no basename fallback) for consistency (v4.7.8)
|
|
524
|
+
- **Redesign**: Sidebar dashboard simplified — single status indicator, 2x2 action button grid, streamlined Quick Stats, removed clutter (v4.7.6)
|
|
525
|
+
|
|
526
|
+
### v4.7.5 — VSIX Self-Contained Build + Auto-Setup
|
|
527
|
+
|
|
528
|
+
- **Feature**: `build-vsix.js` packages all runtime dependencies into a self-contained VSIX — no npm installation needed
|
|
529
|
+
- **Feature**: `auto-setup.js` auto-detects IDE type (Cursor/Windsurf/Trae/VSCode), installs SKILL.md, registers MCP Server, creates default config on first activation
|
|
530
|
+
- **Fix**: `dashboard/server.js` PKG_PATH now dynamically resolved (supports skill dir, VSIX flat, `guard-version.json` fallback)
|
|
531
|
+
- **Enhancement**: Added `onStartupFinished` activation event so auto-setup runs even without `.cursor-guard.json`
|
|
532
|
+
|
|
533
|
+
### v4.7.0–v4.7.4 — IDE Extension + Bug Fixes
|
|
534
|
+
|
|
535
|
+
- **Feature**: VSCode/Cursor/Windsurf extension — full dashboard as WebView tab, status bar alert indicator, sidebar TreeView with project status, Command Palette integration
|
|
536
|
+
- **Feature**: Auto-activation on `.cursor-guard.json` detection, dashboard server runs in extension host process (zero subprocess overhead)
|
|
537
|
+
- **Feature**: Visual sidebar dashboard with charts, progress bars, status badges (v4.7.3)
|
|
538
|
+
- **Fix**: Smart path resolver (`paths.js`) for VSIX/skill/npm installation contexts (v4.7.4)
|
|
539
|
+
- **Fix**: WebView CSP, watcher infinite restart, snapshot status handling (v4.7.1–v4.7.4)
|
|
540
|
+
- **Adapt**: `fetchJson()` supports `__GUARD_BASE_URL__` for WebView; `copyText()` bridges to `vscode.env.clipboard` when in IDE
|
|
541
|
+
|
|
542
|
+
### v4.6.x — Alert UX Overhaul
|
|
543
|
+
|
|
544
|
+
- **Fix**: Alert countdown now updates every second (was only on 15s page refresh)
|
|
545
|
+
- **Fix**: Alert file details modal now shows per-file "Copy Restore Command" buttons
|
|
546
|
+
- **Fix**: Backup stale threshold changed to `max(interval*10, 300)s` (min 5 min); only checks when watcher is running
|
|
547
|
+
- **Feature**: Alert history always accessible (both active and no-alert states), persisted in `localStorage`
|
|
548
|
+
- **Feature**: Alert history as modal dialog with nested file detail drill-down
|
|
549
|
+
|
|
550
|
+
### v4.5.x — Protection Hardening
|
|
551
|
+
|
|
552
|
+
- **Fix**: Shadow hard-link ordering bug (previous snapshot was always empty directory)
|
|
553
|
+
- **Fix**: `changedFiles` now filters ignored paths from git diff output
|
|
554
|
+
- **Feature**: Alert structured file list — per-file path, action, +/- lines, sortable tables
|
|
555
|
+
- **Feature**: Shadow incremental hard links — unchanged files linked to previous snapshot, saving disk space
|
|
556
|
+
- **Feature**: `always_watch: true` config — watcher auto-starts with MCP server, zero protection gaps
|
|
557
|
+
- **Feature**: Dashboard server singleton — multiple projects share one port, hot-add new projects
|
|
558
|
+
- **Feature**: Dashboard version detection + one-click hot restart (`/api/restart` endpoint)
|
|
559
|
+
- **Feature**: File detail modal with per-file restore command copy buttons
|
|
560
|
+
- **Feature**: `cursor-guard-init` auto-creates `.cursor-guard.json`; `backup_interval_seconds` alias supported
|
|
561
|
+
- **License**: Changed to BSL 1.1
|
|
562
|
+
|
|
563
|
+
### v4.4.0 — V4 Final
|
|
564
|
+
|
|
565
|
+
- **Fix**: First snapshot now generates "Added N: file1, file2, ..." summary instead of blank — previously the very first backup had no summary because there was no parent tree to diff against
|
|
566
|
+
- **Feature**: `--dashboard` flag for watcher — `npx cursor-guard-backup --path <dir> --dashboard` starts the web dashboard alongside the watcher in a single process. Optional port: `--dashboard 4000`. Auto-increments if port is busy
|
|
567
|
+
- **Feature**: Doctor check "Git retention" — warns when git backup commits exceed 500 and `git_retention.enabled` is `false`, guiding users to enable auto-pruning before refs grow unbounded
|
|
568
|
+
- **Feature**: Doctor check "Backup integrity" — verifies that the latest auto-backup commit's tree object is reachable via `git cat-file -t`, catching silent corruption early
|
|
569
|
+
- **Improve**: `cursor-guard-init` now detects existing `.cursor-guard.json` and displays an upgrade notice instead of silently overwriting
|
|
570
|
+
- **Improve**: Dashboard server refactored to export `startDashboardServer()` for embedding into other processes
|
|
571
|
+
|
|
572
|
+
### v4.3.5
|
|
573
|
+
|
|
574
|
+
- **Fix**: Backup summary now uses incremental `diff-tree` instead of `git status --porcelain` — previously summary always showed cumulative changes since HEAD, now correctly shows changes since the last auto-backup
|
|
575
|
+
- **Improve**: Dashboard backup table "Changes" column uses stacked layout (file count + trigger / intent / detail on separate rows) for better readability
|
|
576
|
+
- **Improve**: Refined color palette — deeper background contrast, softer status colors (green `#4ade80`, amber `#f59e0b`, red `#ef4444`), deeper brand blue `#3b82f6`, wider text hierarchy gap
|
|
577
|
+
|
|
578
|
+
### v4.3.4
|
|
579
|
+
|
|
580
|
+
- **Improve**: Log rotation — `backup.log` now rotates at 1MB, keeping up to 3 old files (`backup.log.1`, `.2`, `.3`). Rotation runs on watcher startup and every 100 writes
|
|
581
|
+
- **Improve**: Watcher single-instance protection — lock file now includes startup timestamp; locks older than 24h are auto-cleaned even if PID check is unreliable on Windows
|
|
582
|
+
- **Improve**: `previewProjectRestore` output grouped — protected paths (`.cursor/`, `.gitignore`, `.cursor-guard.json`) summarized as `protectedPaths: { count: N }` instead of listing thousands of individual files, drastically reducing token cost
|
|
583
|
+
- **Improve**: SKILL.md Hard Rule #15 — agents must commit skill files after upgrade to ensure `restore_project` HEAD protection works correctly
|
|
584
|
+
|
|
585
|
+
### v4.3.3
|
|
586
|
+
|
|
587
|
+
- **Feature**: Intent context for snapshots — `snapshot_now` now accepts `intent`, `agent`, and `session` parameters, stored as Git commit trailers to form an audit trail per operation
|
|
588
|
+
- **Feature**: Dashboard displays intent badge in backup table and full intent/agent/session fields in restore-point drawer
|
|
589
|
+
- **Improve**: `parseCommitTrailers` refactored to a data-driven map, supporting all 6 trailer fields (Files-Changed, Summary, Trigger, Intent, Agent, Session)
|
|
590
|
+
- **Improve**: SKILL.md updated to guide AI agents to pass `intent` describing the operation about to happen
|
|
591
|
+
|
|
592
|
+
### v4.3.2
|
|
593
|
+
|
|
594
|
+
- **Fix**: `cursor-guard-init` now adds `node_modules/` (root-level) to `.gitignore` — prevents `git add -A` from scanning thousands of npm dependency files after `npm install cursor-guard --save-dev`
|
|
595
|
+
- **Improve**: Doctor "MCP version" mismatch warning now includes the reload keybinding (`Ctrl+Shift+P -> "Developer: Reload Window"`) for faster action
|
|
596
|
+
|
|
597
|
+
### v4.3.1
|
|
598
|
+
|
|
599
|
+
- **Fix**: `restore_project` now protects `.gitignore` — added to `GUARD_CONFIGS` so it is restored from HEAD after recovery, preventing post-restore full-tree scans (2500+ files)
|
|
600
|
+
- **Fix**: `cursor-guard-index.lock` cleanup — `createGitSnapshot` now removes stale `.lock` files on entry and in the `finally` block, preventing lock file remnants from blocking subsequent operations
|
|
601
|
+
- **Improve**: Auto-backup summary now filtered by `protect`/`ignore` patterns, excluding `.cursor/skills/` and other non-protected files
|
|
602
|
+
- **Improve**: Summary format changed from flat `M file1, A file2` to categorized `Modified 3: a.js; Added 1: b.js` with i18n support
|
|
603
|
+
- **Improve**: Manual snapshot `message` (from `snapshot_now`) now displayed in dashboard backup table and restore-point drawer
|
|
604
|
+
- **Improve**: SKILL.md adds best-practice guidance for AI agents to provide descriptive `message` when calling `snapshot_now`
|
|
605
|
+
|
|
606
|
+
### v4.3.0
|
|
607
|
+
|
|
608
|
+
- **Feature**: Backup context metadata — structured Git commit messages with `Files-Changed`, `Summary`, and `Trigger` trailers
|
|
609
|
+
- **Feature**: `listBackups` parses commit trailers and returns `filesChanged`, `summary`, `trigger` fields
|
|
610
|
+
- **Feature**: Dashboard backup table adds "Changes" column; restore-point drawer shows trigger, files changed, and summary
|
|
611
|
+
|
|
612
|
+
### v4.2.2
|
|
613
|
+
|
|
614
|
+
- **Fix**: `restore_project` now protects `.cursor-guard.json` during restore (prevents config loss)
|
|
615
|
+
- **Fix**: Post-restore HEAD recovery loop extended to restore both `.cursor/` and `.cursor-guard.json`
|
|
616
|
+
- **Improve**: `cursor-guard-init` now reminds users to `git commit` after installation in Git repos
|
|
617
|
+
|
|
618
|
+
### v4.2.1
|
|
619
|
+
|
|
620
|
+
- **Fix**: `t()` function uses `replaceAll` for i18n placeholder substitution
|
|
621
|
+
- **Fix**: Removed unused `loadActiveAlert` import from dashboard server
|
|
622
|
+
- **Fix**: Added `git-snapshot` type to dashboard filter bar
|
|
623
|
+
- **Fix**: Replaced `&&` with `;` in `detail.mcp_no_sdk` i18n string for cross-platform compatibility
|
|
624
|
+
- **Fix**: Deduplicated `sdkCandidates` in `doctor.js`
|
|
625
|
+
|
|
626
|
+
### v4.2.0
|
|
627
|
+
|
|
628
|
+
- **Feature**: Web dashboard — local read-only UI with health overview, backup table, restore-point drawers, diagnostics, protection scope
|
|
629
|
+
- **Feature**: Dual-language (zh-CN / en-US) with full i18n coverage including doctor checks, health issues, alert messages
|
|
630
|
+
- **Feature**: Multi-project support via CLI `--path` args and frontend project selector
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
## Release checklist
|
|
635
|
+
|
|
636
|
+
**Single source of truth**: the `version` field in the **repository root** `package.json`. Running `references/vscode-extension/build-vsix.js` copies that value into the extension `package.json` and `guard-version.json`, so the VSIX and npm tarball stay aligned.
|
|
637
|
+
|
|
638
|
+
**Full guide (bilingual, for humans and AI agents):** [docs/RELEASE.md](docs/RELEASE.md) — includes **Windows `gh` + UTF-8**: use `--notes-file` for GitHub Release bodies so Chinese text does not become mojibake.
|
|
639
|
+
|
|
640
|
+
### Generate a filled-in table (recommended)
|
|
641
|
+
|
|
642
|
+
From the repository root:
|
|
643
|
+
|
|
644
|
+
```bash
|
|
645
|
+
npm run release:checklist
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
Copy the terminal output into your own release tracker. It always reflects the current `package.json` version.
|
|
649
|
+
|
|
650
|
+
### Reference checklist
|
|
651
|
+
|
|
652
|
+
| Step | What to do |
|
|
653
|
+
|------|------------|
|
|
654
|
+
| **1. Version** | Bump root `package.json` `version`, then rebuild. Do not keep stale numbers (e.g. 4.9.5) in notes while the repo is already newer. |
|
|
655
|
+
| **2. VSIX** | `cd references/vscode-extension && node build-vsix.js && cd dist && npx --yes @vscode/vsce package --no-dependencies` |
|
|
656
|
+
| **3. Artifact** | `cursor-guard-ide-<version>.vsix` in `references/vscode-extension/dist/` (file name matches `version`). |
|
|
657
|
+
| **4. Git** | Commit and push your default branch; create and push tag `v<version>` (example: `git tag -a vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z`). Record the actual commit hash in your notes. |
|
|
658
|
+
| **5. GitHub Release** | [Create a release](https://github.com/zhangqiang8vipp/cursor-guard/releases/new), select tag `v<version>`, attach the VSIX. |
|
|
659
|
+
| **6. Release branches** | Fast-forward maintenance branches such as `release/v4.8.x` / `release/v4.7.x` to the current `master` when your branching policy requires it. |
|
|
660
|
+
| **7. npm** | From the repo root: `npm publish`. If npm asks for OTP, complete verification in the browser, then run `npm publish` again. |
|
|
661
|
+
|
|
662
|
+
Skipping the Marketplace is fine; GitHub Release + VSIX is enough for many users.
|
|
663
|
+
|
|
664
|
+
---
|
|
665
|
+
|
|
666
|
+
## Known Limitations
|
|
667
|
+
|
|
668
|
+
- **Binary files**: Git diffs and snapshots work on text files. Binary files (images, compiled assets) are stored but cannot be meaningfully diffed or partially restored.
|
|
669
|
+
- **Untracked files**: Files never committed to Git cannot be recovered from Git history. Shadow copy (`backup_strategy: "shadow"` or `"both"`) is the only safety net for untracked files.
|
|
670
|
+
- **Concurrent agents**: If multiple AI agent threads write to the same file simultaneously, snapshots cannot prevent race conditions. Avoid parallel edits to the same file.
|
|
671
|
+
- **External tools modifying the index**: Tools that alter Git's index (e.g. other Git GUIs, IDE Git integrations) while auto-backup is running may conflict. The script uses a temporary index to minimize this, but edge cases exist.
|
|
672
|
+
- **Git worktree**: The auto-backup script supports worktree layouts (`git rev-parse --git-dir`), but has not been tested with all exotic setups (e.g. `--separate-git-dir`).
|
|
673
|
+
- **Pre-warning scope**: `pre_warning` is currently an editor/extension-side "last brake", not a universal cross-process write blocker. Headless shell / MCP flows surface it through status and dashboard after detection rather than hard-blocking writes.
|
|
674
|
+
- **Cursor terminal interference**: Cursor's integrated terminal injects `--trailer` flags into `git commit` commands, which breaks plumbing commands like `commit-tree`. Always run auto-backup in a **separate terminal window**.
|
|
675
|
+
- **Large repos**: For very large repositories, `git add -A` in the backup loop may be slow. Use `protect` patterns in `.cursor-guard.json` to narrow scope.
|
|
676
|
+
|
|
677
|
+
## Requirements
|
|
678
|
+
|
|
679
|
+
- **Node.js >= 18** — core runtime for backup and health check scripts
|
|
680
|
+
- **Git** — for primary backup strategy (not needed for shadow-only mode)
|
|
681
|
+
- **Cursor IDE** — with Agent mode enabled
|
|
682
|
+
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
## Support / Donate
|
|
686
|
+
|
|
687
|
+
This is an independent open-source project maintained by a solo developer. If Cursor Guard has saved your code or your time, consider buying me a coffee :)
|
|
688
|
+
|
|
689
|
+
| WeChat Pay | Alipay |
|
|
690
|
+
|:---:|:---:|
|
|
691
|
+
| <img src="media/wechat-pay.png" alt="WeChat Pay" width="200"> | <img src="media/alipay.jpg" alt="Alipay" width="200"> |
|
|
692
|
+
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
## License
|
|
696
|
+
|
|
697
|
+
[BSL 1.1](LICENSE)
|