cursor-guard 4.9.1 → 4.9.8
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 +130 -10
- package/README.zh-CN.md +130 -10
- package/ROADMAP.md +65 -8
- package/SKILL.md +32 -22
- package/package.json +3 -2
- package/references/config-reference.md +68 -7
- package/references/config-reference.zh-CN.md +68 -7
- package/references/cursor-guard.example.json +11 -7
- package/references/cursor-guard.schema.json +30 -7
- package/references/dashboard/public/app.js +73 -27
- package/references/dashboard/public/index.html +8 -7
- package/references/lib/auto-backup.js +40 -2
- package/references/lib/core/backups.js +46 -16
- package/references/lib/core/core.test.js +101 -22
- package/references/lib/core/dashboard.js +37 -23
- package/references/lib/core/doctor.js +19 -13
- package/references/lib/core/pre-warning.js +296 -0
- package/references/lib/core/snapshot.js +24 -2
- package/references/lib/core/status.js +15 -7
- package/references/lib/utils.js +46 -20
- package/references/mcp/mcp.test.js +60 -12
- package/references/mcp/server.js +72 -60
- package/references/quickstart.zh-CN.md +46 -21
- package/references/vscode-extension/build-vsix.js +4 -1
- package/references/vscode-extension/dist/LICENSE +65 -0
- package/references/vscode-extension/dist/{cursor-guard-ide-4.9.1.vsix → cursor-guard-ide-4.9.8.vsix} +0 -0
- package/references/vscode-extension/dist/dashboard/public/app.js +73 -27
- package/references/vscode-extension/dist/dashboard/public/index.html +8 -7
- package/references/vscode-extension/dist/extension.js +406 -5
- package/references/vscode-extension/dist/guard-version.json +1 -1
- package/references/vscode-extension/dist/lib/auto-backup.js +40 -2
- package/references/vscode-extension/dist/lib/core/backups.js +46 -16
- package/references/vscode-extension/dist/lib/core/dashboard.js +37 -23
- package/references/vscode-extension/dist/lib/core/doctor.js +19 -13
- package/references/vscode-extension/dist/lib/core/pre-warning.js +296 -0
- package/references/vscode-extension/dist/lib/core/snapshot.js +24 -2
- package/references/vscode-extension/dist/lib/core/status.js +15 -7
- package/references/vscode-extension/dist/lib/dashboard-manager.js +102 -52
- package/references/vscode-extension/dist/lib/locale.js +36 -0
- package/references/vscode-extension/dist/lib/sidebar-webview.js +1027 -281
- package/references/vscode-extension/dist/lib/status-bar.js +95 -68
- package/references/vscode-extension/dist/lib/tree-view.js +174 -114
- package/references/vscode-extension/dist/lib/utils.js +46 -20
- package/references/vscode-extension/dist/mcp/server.js +395 -31
- package/references/vscode-extension/dist/media/brand-placeholder.png +0 -0
- package/references/vscode-extension/dist/package.json +1 -1
- package/references/vscode-extension/dist/skill/ROADMAP.md +65 -8
- package/references/vscode-extension/dist/skill/SKILL.md +32 -22
- package/references/vscode-extension/dist/skill/config-reference.md +68 -7
- package/references/vscode-extension/dist/skill/config-reference.zh-CN.md +68 -7
- package/references/vscode-extension/dist/skill/cursor-guard.example.json +11 -7
- package/references/vscode-extension/dist/skill/cursor-guard.schema.json +30 -7
- package/references/vscode-extension/extension.js +406 -5
- package/references/vscode-extension/lib/dashboard-manager.js +102 -52
- package/references/vscode-extension/lib/locale.js +36 -0
- package/references/vscode-extension/lib/sidebar-webview.js +1027 -281
- package/references/vscode-extension/lib/status-bar.js +95 -68
- package/references/vscode-extension/lib/tree-view.js +174 -114
- package/references/vscode-extension/media/brand-placeholder.png +0 -0
- package/references/vscode-extension/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,9 +23,15 @@ When Cursor's AI agent edits your files, there's a risk of accidental overwrites
|
|
|
23
23
|
- **MCP tool calls (optional)** — 9 structured tools (diagnostics, snapshot, restore, status, dashboard, alerts, etc.) with JSON responses and lower token cost
|
|
24
24
|
- **Auto-fix diagnostics** — `doctor_fix` automatically patches missing configs, uninitialized Git repos, gitignore gaps, and stale locks
|
|
25
25
|
- **Proactive change-velocity alerts (V4)** — Auto-detects abnormal file change patterns and raises risk warnings
|
|
26
|
+
- **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
|
|
26
27
|
- **Backup health dashboard (V4)** — One-call comprehensive view: strategy, counts, disk usage, protection scope, health status
|
|
27
|
-
- **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
|
|
28
|
+
- **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
|
|
28
29
|
- **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
|
|
30
|
+
- **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
|
|
31
|
+
- **Right-click context menus (V4.7.7)** — Add files/folders to `protect` or `ignore` lists via Explorer/Editor right-click menu with pattern picker
|
|
32
|
+
- **Real-time sidebar (V4.9.1)** — "Last backup Xs ago" and alert countdown tick every second in the sidebar dashboard
|
|
33
|
+
- **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
|
|
34
|
+
- **Self-contained VSIX (V4.8.1)** — MCP server bundled as a single file via esbuild, zero npm dependencies needed for IDE extension
|
|
29
35
|
- **One-click hot restart (V4.5.8)** — Dashboard detects new versions and offers in-place server restart without losing state
|
|
30
36
|
- **Shadow incremental hard links (V4.5.4)** — Unchanged files are hard-linked to save disk space and I/O
|
|
31
37
|
- **Strong protection mode (V4.5.4)** — `always_watch: true` auto-starts watcher with MCP server, ensuring zero protection gaps
|
|
@@ -119,6 +125,7 @@ After installation, your directory structure should look like this:
|
|
|
119
125
|
│ ├── restore.js # Single file / project restore
|
|
120
126
|
│ ├── status.js # Backup system status
|
|
121
127
|
│ ├── anomaly.js # V4: Change-velocity detection
|
|
128
|
+
│ ├── pre-warning.js # V4.9.7: destructive edit risk scoring + persistence
|
|
122
129
|
│ └── dashboard.js # V4: Health dashboard aggregation
|
|
123
130
|
├── dashboard/
|
|
124
131
|
│ ├── server.js # Dashboard HTTP server + API
|
|
@@ -200,6 +207,12 @@ Edit `.cursor-guard.json` to define which files to protect:
|
|
|
200
207
|
"auto_backup_interval_seconds": 60,
|
|
201
208
|
"secrets_patterns": [".env", ".env.*", "*.key", "*.pem"],
|
|
202
209
|
"pre_restore_backup": "always",
|
|
210
|
+
"proactive_alert": true,
|
|
211
|
+
"alert_thresholds": { "files_per_window": 20, "window_seconds": 10, "cooldown_seconds": 60 },
|
|
212
|
+
"enable_pre_warning": true,
|
|
213
|
+
"pre_warning_threshold": 30,
|
|
214
|
+
"pre_warning_mode": "popup",
|
|
215
|
+
"pre_warning_exclude_patterns": ["generated/**"],
|
|
203
216
|
"retention": { "mode": "days", "days": 30 }
|
|
204
217
|
}
|
|
205
218
|
```
|
|
@@ -216,6 +229,19 @@ Regardless of config, you can always override per-request:
|
|
|
216
229
|
- Say "don't preserve current version" to skip even when config is `"always"`
|
|
217
230
|
- Say "preserve current first" to force even when config is `"never"`
|
|
218
231
|
|
|
232
|
+
#### `enable_pre_warning` — destructive partial-delete pre-warning
|
|
233
|
+
|
|
234
|
+
When enabled, the IDE extension evaluates edits that remove lines or whole methods/functions before they slip by unnoticed.
|
|
235
|
+
|
|
236
|
+
| Field | Default | Meaning |
|
|
237
|
+
|-------|---------|---------|
|
|
238
|
+
| `enable_pre_warning` | `false` | Turn pre-warning on without affecting existing projects |
|
|
239
|
+
| `pre_warning_threshold` | `30` | Warn when deletion risk reaches this percent |
|
|
240
|
+
| `pre_warning_mode` | `"popup"` | `popup` = interrupt with actions, `dashboard` = highlight only, `silent` = log/status only |
|
|
241
|
+
| `pre_warning_exclude_patterns` | `[]` | Skip generated files, migrations, vendored code, etc. |
|
|
242
|
+
|
|
243
|
+
Method/function removal is treated as high risk and can still trigger a warning even when the deleted-line percentage is below the threshold.
|
|
244
|
+
|
|
219
245
|
---
|
|
220
246
|
|
|
221
247
|
## Auto-Backup Script
|
|
@@ -303,16 +329,26 @@ Embed the full dashboard directly inside your IDE — no browser needed.
|
|
|
303
329
|
#### Method A: VSIX standalone (recommended, no npm needed)
|
|
304
330
|
|
|
305
331
|
```bash
|
|
306
|
-
# Build the self-contained VSIX package
|
|
332
|
+
# Build the self-contained VSIX (version = root package.json "version")
|
|
307
333
|
cd references/vscode-extension
|
|
308
334
|
node build-vsix.js
|
|
309
335
|
cd dist
|
|
310
|
-
npx vsce package
|
|
336
|
+
npx --yes @vscode/vsce package --no-dependencies
|
|
311
337
|
|
|
312
|
-
# Install the generated .vsix
|
|
313
|
-
|
|
338
|
+
# Install the generated .vsix (VERSION always matches package.json)
|
|
339
|
+
V=$(node -p "require('../../../package.json').version")
|
|
340
|
+
code --install-extension "cursor-guard-ide-${V}.vsix"
|
|
314
341
|
```
|
|
315
342
|
|
|
343
|
+
PowerShell (from `references\vscode-extension\dist`):
|
|
344
|
+
|
|
345
|
+
```powershell
|
|
346
|
+
$V = node -p "require('../../../package.json').version"
|
|
347
|
+
code --install-extension "cursor-guard-ide-$V.vsix"
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Print the full release checklist from the repo root: `npm run release:checklist`.
|
|
351
|
+
|
|
316
352
|
On first activation, the extension automatically:
|
|
317
353
|
- Installs `SKILL.md` to your IDE's skills directory
|
|
318
354
|
- Registers the MCP Server in your IDE's `mcp.json`
|
|
@@ -330,9 +366,13 @@ Features:
|
|
|
330
366
|
- **WebView Dashboard** — full dashboard embedded as an editor tab, identical to the browser version
|
|
331
367
|
- **Status Bar Indicator** — shows `Guard: OK` (green) or `Guard: 22 files!` (yellow) in real-time
|
|
332
368
|
- **Sidebar TreeView** — activity bar icon with project list, watcher status, backup stats, alerts, health
|
|
333
|
-
- **Visual Sidebar** — graphical dashboard with
|
|
334
|
-
- **
|
|
369
|
+
- **Visual Sidebar** — graphical dashboard with live-ticking backup age, alert countdown, protection scope, quick stats
|
|
370
|
+
- **Pre-warning delete guard** — flags risky partial deletions, removed methods, and suspicious line drops before they quietly stick
|
|
371
|
+
- **Command Palette** — `Open Dashboard`, `Snapshot Now`, `Start/Stop Watcher`, `Quick Restore`, `Doctor`, `Refresh`
|
|
372
|
+
- **Right-click menus** — add files/folders to `protect` or `ignore` via Explorer/Editor context menu
|
|
373
|
+
- **Event-driven refresh** — `FileSystemWatcher` pushes UI updates on file changes (< 1.5s latency), 30s heartbeat fallback
|
|
335
374
|
- **Auto-setup (V4.7.5)** — auto-detects IDE type, installs Skill, registers MCP, creates config on first run
|
|
375
|
+
- **Self-contained (V4.8.1)** — MCP server bundled via esbuild, zero npm dependencies
|
|
336
376
|
- **Multi-project** — hot-loads all workspace folders with `.cursor-guard.json`
|
|
337
377
|
- **Compatible** — works with VSCode ^1.74.0, Cursor, Windsurf, Trae, and all VSCode-based IDEs
|
|
338
378
|
|
|
@@ -405,7 +445,7 @@ The skill activates on these signals:
|
|
|
405
445
|
|------|---------|
|
|
406
446
|
| `SKILL.md` | Main skill instructions for the AI agent (with MCP dual-path) |
|
|
407
447
|
| `ROADMAP.md` | Version evolution roadmap (V2-V7) |
|
|
408
|
-
| `references/lib/core/` | Core layer:
|
|
448
|
+
| `references/lib/core/` | Core layer: 9 pure-logic modules (doctor / doctor-fix / snapshot / backups / restore / status / anomaly / pre-warning / dashboard) |
|
|
409
449
|
| `references/mcp/server.js` | MCP Server: 9 structured tools (optional) |
|
|
410
450
|
| `references/lib/auto-backup.js` | Auto-backup watcher (calls Core) |
|
|
411
451
|
| `references/lib/guard-doctor.js` | Health check CLI shell (calls Core) |
|
|
@@ -427,6 +467,55 @@ The skill activates on these signals:
|
|
|
427
467
|
|
|
428
468
|
## Changelog
|
|
429
469
|
|
|
470
|
+
### v4.9.8 — Release docs, checklist script, sidebar brand asset
|
|
471
|
+
|
|
472
|
+
- **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
|
|
473
|
+
- **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
|
|
474
|
+
- **IDE**: Sidebar header can show packaged brand artwork via `media/brand-placeholder.png` and `asWebviewUri` (fallback gradient if the file is absent)
|
|
475
|
+
|
|
476
|
+
### v4.9.7 — Softer Pre-Warning UX, Sidebar Locale Sync, and Watcher Singleton Guard
|
|
477
|
+
|
|
478
|
+
- **Improve**: `popup` mode now uses a softer auto-continue review flow with a 2-second timeout instead of a hard modal stop
|
|
479
|
+
- **Improve**: Pre-warning review text now follows the sidebar language toggle, keeping zh-CN / en-US messaging consistent inside the IDE
|
|
480
|
+
- **Fix**: Sidebar keeps showing watcher / health status even when delete-risk warnings are present, and popup-mode warnings no longer stick forever
|
|
481
|
+
- **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
|
|
482
|
+
- **Docs**: README, roadmap, and skill notes updated for the 4.9.7 release flow and IDE behavior
|
|
483
|
+
|
|
484
|
+
### v4.9.6 — Pre-Warning for Destructive Partial Deletes
|
|
485
|
+
|
|
486
|
+
- **Feature**: Added configurable `pre_warning` support in `.cursor-guard.json` — `enable_pre_warning`, `pre_warning_threshold`, `pre_warning_mode`, `pre_warning_exclude_patterns`
|
|
487
|
+
- **Feature**: IDE extension now detects risky line/method removals and can react in `popup`, `dashboard`, or `silent` mode
|
|
488
|
+
- **Feature**: `backup_status`, `dashboard`, sidebar, status bar, and browser dashboard surface active delete-risk warnings
|
|
489
|
+
- **Improve**: New `pre-warning.js` core module centralizes deletion-risk scoring, active-warning persistence, and warning history
|
|
490
|
+
- **Docs**: README, skill guide, roadmap, and config references now document the pre-warning flow end-to-end
|
|
491
|
+
|
|
492
|
+
### v4.9.0–v4.9.1 — Event-Driven Architecture
|
|
493
|
+
|
|
494
|
+
- **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
|
|
495
|
+
- **Fallback**: Automatic degradation to polling mode if `fs.watch` is unavailable (e.g. older Linux kernels)
|
|
496
|
+
- **Config hot-reload**: `.cursor-guard.json` changes trigger instant config reload via `fs.watch` event (no more waiting 10 polling cycles)
|
|
497
|
+
- **IDE FileSystemWatcher**: Extension uses VSCode built-in `createFileSystemWatcher` to push UI updates on file changes (1.5s debounce)
|
|
498
|
+
- **Poller heartbeat**: Reduced from 5s fixed interval to 30s heartbeat; UI updates are now event-driven
|
|
499
|
+
- **Live sidebar counters**: "Last backup Xs ago" ticks every second in real-time (v4.9.1)
|
|
500
|
+
|
|
501
|
+
### v4.8.0–v4.8.5 — Bundling, Doctor Fixes, Restore UX
|
|
502
|
+
|
|
503
|
+
- **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)
|
|
504
|
+
- **Fix**: `doctor` MCP check no longer false-warns when cursor-guard is configured in `.cursor/mcp.json` (v4.8.2)
|
|
505
|
+
- **Fix**: Skill directory `references/` now auto-creates junction link to extension runtime files on every activation (v4.8.2)
|
|
506
|
+
- **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)
|
|
507
|
+
- **Fix**: Files outside `protect` scope no longer appear as phantom "deleted" in change summaries (v4.8.5)
|
|
508
|
+
- **Improve**: VSIX package reduced from 3.18 MB to 1.27 MB thanks to esbuild bundling
|
|
509
|
+
|
|
510
|
+
### v4.7.6–v4.7.9 — Sidebar Redesign, Context Menus, Protection Scope
|
|
511
|
+
|
|
512
|
+
- **Feature**: Right-click context menus — add files/folders to `protect` or `ignore` via Explorer/Editor menus with pattern picker (v4.7.7)
|
|
513
|
+
- **Feature**: Protection scope card in sidebar — shows protected/excluded file counts, actual protect/ignore patterns (v4.7.8)
|
|
514
|
+
- **Feature**: Alert countdown ticks live every second in sidebar (v4.7.8)
|
|
515
|
+
- **Fix**: Open Dashboard CORS/CSP issues — added `Access-Control-Allow-Origin`, relaxed CSP, fallback to browser on WebView failure (v4.7.8)
|
|
516
|
+
- **Fix**: `protect` patterns now use strict matching (full path only, no basename fallback) for consistency (v4.7.8)
|
|
517
|
+
- **Redesign**: Sidebar dashboard simplified — single status indicator, 2x2 action button grid, streamlined Quick Stats, removed clutter (v4.7.6)
|
|
518
|
+
|
|
430
519
|
### v4.7.5 — VSIX Self-Contained Build + Auto-Setup
|
|
431
520
|
|
|
432
521
|
- **Feature**: `build-vsix.js` packages all runtime dependencies into a self-contained VSIX — no npm installation needed
|
|
@@ -462,7 +551,7 @@ The skill activates on these signals:
|
|
|
462
551
|
- **Feature**: Dashboard version detection + one-click hot restart (`/api/restart` endpoint)
|
|
463
552
|
- **Feature**: File detail modal with per-file restore command copy buttons
|
|
464
553
|
- **Feature**: `cursor-guard-init` auto-creates `.cursor-guard.json`; `backup_interval_seconds` alias supported
|
|
465
|
-
- **License**: Changed
|
|
554
|
+
- **License**: Changed to BSL 1.1
|
|
466
555
|
|
|
467
556
|
### v4.4.0 — V4 Final
|
|
468
557
|
|
|
@@ -535,6 +624,36 @@ The skill activates on these signals:
|
|
|
535
624
|
|
|
536
625
|
---
|
|
537
626
|
|
|
627
|
+
## Release checklist
|
|
628
|
+
|
|
629
|
+
**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.
|
|
630
|
+
|
|
631
|
+
### Generate a filled-in table (recommended)
|
|
632
|
+
|
|
633
|
+
From the repository root:
|
|
634
|
+
|
|
635
|
+
```bash
|
|
636
|
+
npm run release:checklist
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
Copy the terminal output into your own release tracker. It always reflects the current `package.json` version.
|
|
640
|
+
|
|
641
|
+
### Reference checklist
|
|
642
|
+
|
|
643
|
+
| Step | What to do |
|
|
644
|
+
|------|------------|
|
|
645
|
+
| **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. |
|
|
646
|
+
| **2. VSIX** | `cd references/vscode-extension && node build-vsix.js && cd dist && npx --yes @vscode/vsce package --no-dependencies` |
|
|
647
|
+
| **3. Artifact** | `cursor-guard-ide-<version>.vsix` in `references/vscode-extension/dist/` (file name matches `version`). |
|
|
648
|
+
| **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. |
|
|
649
|
+
| **5. GitHub Release** | [Create a release](https://github.com/zhangqiang8vipp/cursor-guard/releases/new), select tag `v<version>`, attach the VSIX. |
|
|
650
|
+
| **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. |
|
|
651
|
+
| **7. npm** | From the repo root: `npm publish`. If npm asks for OTP, complete verification in the browser, then run `npm publish` again. |
|
|
652
|
+
|
|
653
|
+
Skipping the Marketplace is fine; GitHub Release + VSIX is enough for many users.
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
538
657
|
## Known Limitations
|
|
539
658
|
|
|
540
659
|
- **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.
|
|
@@ -542,6 +661,7 @@ The skill activates on these signals:
|
|
|
542
661
|
- **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.
|
|
543
662
|
- **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.
|
|
544
663
|
- **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`).
|
|
664
|
+
- **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.
|
|
545
665
|
- **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**.
|
|
546
666
|
- **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.
|
|
547
667
|
|
|
@@ -565,4 +685,4 @@ This is an independent open-source project maintained by a solo developer. If Cu
|
|
|
565
685
|
|
|
566
686
|
## License
|
|
567
687
|
|
|
568
|
-
[BSL 1.1
|
|
688
|
+
[BSL 1.1](LICENSE)
|
package/README.zh-CN.md
CHANGED
|
@@ -23,9 +23,15 @@
|
|
|
23
23
|
- **MCP 工具调用(可选)** — 9 个标准化工具(诊断、快照、恢复、状态、看板、告警等),结构化 JSON 返回,低 token 消耗
|
|
24
24
|
- **自动诊断修复** — `doctor_fix` 一键修补缺失配置、未初始化 Git、gitignore 遗漏等常见问题
|
|
25
25
|
- **主动变更频率告警(V4)** — 自动检测异常文件变更模式并发出风险预警
|
|
26
|
+
- **事先预警删除风险(V4.9.7)** — 在危险的局部删除真正“悄悄生效”前先提醒你,支持更柔和的自动继续提示、侧边栏语言同步,以及 `popup` / `dashboard` / `silent` 三种模式
|
|
26
27
|
- **备份健康看板(V4)** — 一次调用全面查看:策略、数量、磁盘占用、保护范围、健康状态
|
|
27
|
-
- **Web 仪表盘(V4.2)** — 本地只读 Web 页面 `http://127.0.0.1:3120
|
|
28
|
+
- **Web 仪表盘(V4.2)** — 本地只读 Web 页面 `http://127.0.0.1:3120`——健康状态、备份、恢复点、诊断、保护范围一目了然。中英双语、自动刷新、支持多项目监控
|
|
28
29
|
- **IDE 扩展(V4.7)** — 完整仪表盘嵌入 VSCode/Cursor/Windsurf,WebView 标签页 + 状态栏告警指示器 + 侧边栏项目树。无需打开浏览器
|
|
30
|
+
- **事件驱动监听(V4.9)** — `fs.watch` + 防抖替代盲轮询。备份延迟 < 500ms,空闲时零 CPU。不支持的平台自动降级为轮询
|
|
31
|
+
- **右键上下文菜单(V4.7.7)** — 在资源管理器/编辑器右键菜单中将文件或文件夹添加到 `protect` 或 `ignore` 列表
|
|
32
|
+
- **实时侧边栏(V4.9.1)** — "上次备份 Xs 前"和告警倒计时每秒跳动更新
|
|
33
|
+
- **删除文件智能恢复(V4.8.4)** — 恢复命令自动指向父提交(`hash~1`),避免"文件不存在"错误
|
|
34
|
+
- **自包含 VSIX(V4.8.1)** — MCP server 通过 esbuild 打包为单文件,IDE 扩展零 npm 依赖
|
|
29
35
|
- **一键热重启(V4.5.8)** — 仪表盘检测到新版本时可原地重启服务,不丢失状态
|
|
30
36
|
- **Shadow 增量硬链接(V4.5.4)** — 未变更文件硬链接到上次快照,节省磁盘空间和 I/O
|
|
31
37
|
- **强保护模式(V4.5.4)** — `always_watch: true` 让 watcher 随 MCP server 自动启动,确保零保护缺口
|
|
@@ -119,6 +125,7 @@ git clone https://github.com/zhangqiang8vipp/cursor-guard.git .cursor/skills/cur
|
|
|
119
125
|
│ ├── restore.js # 单文件/全项目恢复
|
|
120
126
|
│ ├── status.js # 备份系统状态
|
|
121
127
|
│ ├── anomaly.js # V4:变更频率检测
|
|
128
|
+
│ ├── pre-warning.js # V4.9.7:删除风险评分 + 持久化
|
|
122
129
|
│ └── dashboard.js # V4:健康看板聚合
|
|
123
130
|
├── dashboard/
|
|
124
131
|
│ ├── server.js # 仪表盘 HTTP 服务 + API
|
|
@@ -200,6 +207,12 @@ npx cursor-guard-backup --path /my/project
|
|
|
200
207
|
"auto_backup_interval_seconds": 60,
|
|
201
208
|
"secrets_patterns": [".env", ".env.*", "*.key", "*.pem"],
|
|
202
209
|
"pre_restore_backup": "always",
|
|
210
|
+
"proactive_alert": true,
|
|
211
|
+
"alert_thresholds": { "files_per_window": 20, "window_seconds": 10, "cooldown_seconds": 60 },
|
|
212
|
+
"enable_pre_warning": true,
|
|
213
|
+
"pre_warning_threshold": 30,
|
|
214
|
+
"pre_warning_mode": "popup",
|
|
215
|
+
"pre_warning_exclude_patterns": ["generated/**"],
|
|
203
216
|
"retention": { "mode": "days", "days": 30 }
|
|
204
217
|
}
|
|
205
218
|
```
|
|
@@ -216,6 +229,19 @@ npx cursor-guard-backup --path /my/project
|
|
|
216
229
|
- 说"不保留当前版本"可跳过保留(即使配置为 `"always"`)
|
|
217
230
|
- 说"先保留当前版本"可强制保留(即使配置为 `"never"`)
|
|
218
231
|
|
|
232
|
+
#### `enable_pre_warning` — 局部破坏性删除的事先预警
|
|
233
|
+
|
|
234
|
+
开启后,IDE 扩展会在“删行很多”或“直接删掉方法/函数”这类高风险编辑发生时,先给出最后一道提醒。
|
|
235
|
+
|
|
236
|
+
| 字段 | 默认值 | 说明 |
|
|
237
|
+
|------|--------|------|
|
|
238
|
+
| `enable_pre_warning` | `false` | 默认关闭,兼容旧项目 |
|
|
239
|
+
| `pre_warning_threshold` | `30` | 删除风险达到这个百分比时触发预警 |
|
|
240
|
+
| `pre_warning_mode` | `"popup"` | `popup` 弹窗拦一下,`dashboard` 仅高亮看板,`silent` 只记日志/状态 |
|
|
241
|
+
| `pre_warning_exclude_patterns` | `[]` | 跳过生成文件、迁移脚本、第三方代码等 |
|
|
242
|
+
|
|
243
|
+
如果检测到方法/函数被移除,即使删行比例没到阈值,也会按高风险处理并触发提醒。
|
|
244
|
+
|
|
219
245
|
---
|
|
220
246
|
|
|
221
247
|
## 自动备份脚本
|
|
@@ -303,16 +329,26 @@ node references\dashboard\server.js --path "D:\MyProject"
|
|
|
303
329
|
#### 方式 A:VSIX 独立安装(推荐,无需 npm)
|
|
304
330
|
|
|
305
331
|
```bash
|
|
306
|
-
# 构建独立 VSIX
|
|
332
|
+
# 构建独立 VSIX 包(版本号 = 仓库根目录 package.json 的 version)
|
|
307
333
|
cd references/vscode-extension
|
|
308
334
|
node build-vsix.js
|
|
309
335
|
cd dist
|
|
310
|
-
npx vsce package
|
|
336
|
+
npx --yes @vscode/vsce package --no-dependencies
|
|
311
337
|
|
|
312
|
-
# 安装生成的 .vsix
|
|
313
|
-
|
|
338
|
+
# 安装生成的 .vsix(VERSION 与 package.json 一致;勿手写旧版本号)
|
|
339
|
+
V=$(node -p "require('../../../package.json').version")
|
|
340
|
+
code --install-extension "cursor-guard-ide-${V}.vsix"
|
|
314
341
|
```
|
|
315
342
|
|
|
343
|
+
PowerShell(在 `references\vscode-extension\dist` 下):
|
|
344
|
+
|
|
345
|
+
```powershell
|
|
346
|
+
$V = node -p "require('../../../package.json').version"
|
|
347
|
+
code --install-extension "cursor-guard-ide-$V.vsix"
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
发版前打印完整检查清单:`npm run release:checklist`(在仓库根目录)。
|
|
351
|
+
|
|
316
352
|
首次激活时,扩展自动:
|
|
317
353
|
- 将 `SKILL.md` 安装到 IDE 的 skills 目录
|
|
318
354
|
- 将 MCP Server 注册到 IDE 的 `mcp.json`
|
|
@@ -330,9 +366,13 @@ code --install-extension .
|
|
|
330
366
|
- **WebView 仪表盘** — 完整仪表盘作为编辑器标签页嵌入,与浏览器版本完全一致
|
|
331
367
|
- **状态栏指示器** — 实时显示 `Guard: OK`(绿色)或 `Guard: 22 files!`(黄色告警)
|
|
332
368
|
- **侧边栏 TreeView** — Activity Bar 图标,树形展示项目列表、Watcher 状态、备份统计、告警、健康评估
|
|
333
|
-
- **可视化图表侧边栏** —
|
|
334
|
-
-
|
|
369
|
+
- **可视化图表侧边栏** — 备份时间实时跳动、告警倒计时、保护范围、Quick Stats
|
|
370
|
+
- **事先预警删除保护** — 在局部删代码、删方法、可疑大段删行时提前亮警报
|
|
371
|
+
- **命令面板** — `Open Dashboard`、`Snapshot Now`、`Start/Stop Watcher`、`Quick Restore`、`Doctor`、`Refresh`
|
|
372
|
+
- **右键菜单** — 在资源管理器/编辑器右键菜单中将文件或文件夹添加到 `protect` 或 `ignore`
|
|
373
|
+
- **事件驱动刷新** — `FileSystemWatcher` 监听文件变化推送 UI 更新(< 1.5s 延迟),30s 心跳兜底
|
|
335
374
|
- **自动配置(V4.7.5)** — 首次运行自动检测 IDE 类型、安装 Skill、注册 MCP、创建配置
|
|
375
|
+
- **自包含(V4.8.1)** — MCP server 通过 esbuild 打包,零 npm 依赖
|
|
336
376
|
- **多项目** — 热加载所有包含 `.cursor-guard.json` 的工作区文件夹
|
|
337
377
|
- **兼容性** — 支持 VSCode ^1.74.0、Cursor、Windsurf、Trae 及所有基于 VSCode 的 IDE
|
|
338
378
|
|
|
@@ -405,7 +445,7 @@ code --install-extension .
|
|
|
405
445
|
|------|------|
|
|
406
446
|
| `SKILL.md` | AI 代理的主要技能指令(含 MCP 双路径逻辑) |
|
|
407
447
|
| `ROADMAP.md` | 版本演进规划书(V2-V7) |
|
|
408
|
-
| `references/lib/core/` | Core 层:
|
|
448
|
+
| `references/lib/core/` | Core 层:9 个纯逻辑模块(doctor / doctor-fix / snapshot / backups / restore / status / anomaly / pre-warning / dashboard) |
|
|
409
449
|
| `references/mcp/server.js` | MCP Server:9 个标准化工具(可选) |
|
|
410
450
|
| `references/lib/auto-backup.js` | 自动备份 watcher(调用 Core) |
|
|
411
451
|
| `references/lib/guard-doctor.js` | 健康检查 CLI 壳(调用 Core) |
|
|
@@ -427,6 +467,55 @@ code --install-extension .
|
|
|
427
467
|
|
|
428
468
|
## 更新日志
|
|
429
469
|
|
|
470
|
+
### v4.9.8 — 发版文档、清单脚本、侧边栏品牌资源
|
|
471
|
+
|
|
472
|
+
- **文档**:在 README / README.zh-CN 增加双语**发版检查清单**,步骤与根目录 `package.json` 的 `version` 绑定,避免 VSIX 名、Git 标签、npm 版本各写各的
|
|
473
|
+
- **工具**:`npm run release:checklist`(`scripts/print-release-checklist.js`)一键输出可粘贴的表格;`build-vsix.js` 构建结束后提示对应 VSIX 文件名
|
|
474
|
+
- **IDE**:侧边栏顶栏可通过扩展内 `media/brand-placeholder.png` + webview `asWebviewUri` 展示品牌图(无文件时仍用渐变占位)
|
|
475
|
+
|
|
476
|
+
### v4.9.7 — 更柔和的事先预警、侧边栏语言同步与 Watcher 单例保护
|
|
477
|
+
|
|
478
|
+
- **改进**:`popup` 模式改为 2 秒自动继续的柔性提示,不再用硬阻塞弹窗打断连续编辑
|
|
479
|
+
- **改进**:事先预警提示文案会跟随侧边栏语言切换,IDE 内中英文保持一致
|
|
480
|
+
- **修复**:即使存在删除风险提示,侧边栏也会持续展示 watcher / health 状态;`popup` 模式的预警不会一直挂住不消失
|
|
481
|
+
- **修复**:IDE 启停 watcher 时改为读取真实项目锁路径,并增加启动中的单例保护,避免重复点击拉起多个 watcher
|
|
482
|
+
- **文档**:README、ROADMAP、SKILL 一并更新到 4.9.7 发版说明
|
|
483
|
+
|
|
484
|
+
### v4.9.6 — 事先预警局部破坏性删除
|
|
485
|
+
|
|
486
|
+
- **新功能**:`.cursor-guard.json` 新增 `enable_pre_warning`、`pre_warning_threshold`、`pre_warning_mode`、`pre_warning_exclude_patterns`
|
|
487
|
+
- **新功能**:IDE 扩展现在会检测高风险删行 / 删方法,并支持 `popup`、`dashboard`、`silent` 三种预警模式
|
|
488
|
+
- **新功能**:`backup_status`、`dashboard`、侧边栏、状态栏、浏览器仪表盘都会展示活跃的删除风险预警
|
|
489
|
+
- **增强**:新增 `pre-warning.js` Core 模块,统一负责删除风险评分、活跃预警持久化和历史记录
|
|
490
|
+
- **文档**:README、SKILL、ROADMAP 与配置说明已补齐预警功能说明
|
|
491
|
+
|
|
492
|
+
### v4.9.0–v4.9.1 — 事件驱动架构
|
|
493
|
+
|
|
494
|
+
- **架构重构**:Watcher(`auto-backup.js`)从 `while+sleep` 轮询重写为 `fs.watch` 事件驱动 + 500ms 防抖。空闲时零 CPU,备份延迟 < 500ms
|
|
495
|
+
- **自动降级**:`fs.watch` 不可用时自动回退到轮询模式
|
|
496
|
+
- **配置即时响应**:`.cursor-guard.json` 变化通过 `fs.watch` 事件直接触发热加载(不再等待 10 个轮询周期)
|
|
497
|
+
- **IDE FileSystemWatcher**:扩展使用 VSCode 内置 `createFileSystemWatcher` 推送文件变化事件(1.5s 防抖)
|
|
498
|
+
- **Poller 心跳**:从 5s 固定轮询改为 30s 心跳;UI 更新由事件驱动
|
|
499
|
+
- **实时侧边栏计时**:"上次备份 Xs 前"每秒跳动更新(v4.9.1)
|
|
500
|
+
|
|
501
|
+
### v4.8.0–v4.8.5 — 打包修复、Doctor 优化、恢复 UX
|
|
502
|
+
|
|
503
|
+
- **修复**:MCP server 通过 esbuild 打包为单个自包含文件——彻底解决传递依赖缺失问题(`zod-to-json-schema`、`ajv` 等)(v4.8.1)
|
|
504
|
+
- **修复**:`doctor` MCP 检查不再在 `.cursor/mcp.json` 已配置 cursor-guard 时误报 WARN(v4.8.2)
|
|
505
|
+
- **修复**:Skill 目录 `references/` 每次激活时自动创建 junction 链接到扩展运行时文件(v4.8.2)
|
|
506
|
+
- **修复**:删除文件的恢复命令自动指向父提交(`hash~1`),避免"文件不存在"错误。按钮显示"恢复删除前"橙色样式(v4.8.4)
|
|
507
|
+
- **修复**:`protect` 范围外的文件不再在变更摘要中被误标为"删除"(v4.8.5)
|
|
508
|
+
- **优化**:VSIX 包从 3.18 MB 缩减至 1.27 MB
|
|
509
|
+
|
|
510
|
+
### v4.7.6–v4.7.9 — 侧边栏重设计、右键菜单、保护范围
|
|
511
|
+
|
|
512
|
+
- **新功能**:右键上下文菜单——在资源管理器/编辑器右键添加文件到 `protect` 或 `ignore`,含模式选择器(v4.7.7)
|
|
513
|
+
- **新功能**:侧边栏保护范围卡片——显示受保护/排除文件数、protect/ignore 模式列表(v4.7.8)
|
|
514
|
+
- **新功能**:告警倒计时每秒实时跳动(v4.7.8)
|
|
515
|
+
- **修复**:Open Dashboard CORS/CSP 问题——添加 CORS 头、放宽 CSP、WebView 失败时回退到浏览器(v4.7.8)
|
|
516
|
+
- **修复**:`protect` 模式改为严格匹配(仅完整路径,不回退到 basename)(v4.7.8)
|
|
517
|
+
- **重设计**:侧边栏仪表盘简化——单一状态指示器、2×2 操作按钮网格、精简 Quick Stats(v4.7.6)
|
|
518
|
+
|
|
430
519
|
### v4.7.5 — VSIX 独立打包 + 自动配置
|
|
431
520
|
|
|
432
521
|
- **功能**:`build-vsix.js` 将所有运行时依赖打包为独立 VSIX —— 无需 npm 安装
|
|
@@ -461,7 +550,7 @@ code --install-extension .
|
|
|
461
550
|
- **功能**:Dashboard 版本检测 + 一键热重启(`/api/restart` 端点)
|
|
462
551
|
- **功能**:文件详情弹窗 + 每文件恢复命令复制按钮
|
|
463
552
|
- **功能**:`cursor-guard-init` 自动创建 `.cursor-guard.json`;支持 `backup_interval_seconds` 别名
|
|
464
|
-
-
|
|
553
|
+
- **许可证**:变更为 BSL 1.1
|
|
465
554
|
|
|
466
555
|
### v4.4.0 — V4 收官版
|
|
467
556
|
|
|
@@ -534,6 +623,36 @@ code --install-extension .
|
|
|
534
623
|
|
|
535
624
|
---
|
|
536
625
|
|
|
626
|
+
## 发版检查清单
|
|
627
|
+
|
|
628
|
+
**唯一版本源**:仓库**根目录** `package.json` 里的 **`version`**。执行 `references/vscode-extension/build-vsix.js` 时,会把同一版本写入扩展内的 `package.json` 与 `guard-version.json`,因此 VSIX 与 npm 包版本一致。
|
|
629
|
+
|
|
630
|
+
### 生成已填好版本号的表格(推荐)
|
|
631
|
+
|
|
632
|
+
在仓库根目录执行:
|
|
633
|
+
|
|
634
|
+
```bash
|
|
635
|
+
npm run release:checklist
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
将终端完整输出复制到你的发版记录即可;其中版本号始终与当前 `package.json` 一致。
|
|
639
|
+
|
|
640
|
+
### 步骤对照表
|
|
641
|
+
|
|
642
|
+
| 步骤 | 内容 |
|
|
643
|
+
|------|------|
|
|
644
|
+
| **1. 版本号** | 先修改根目录 `package.json` 的 `version`,再执行构建。记录表里不要写已过期的版本号(例如仓库已是 4.9.8 却仍写 4.9.5)。 |
|
|
645
|
+
| **2. VSIX** | `cd references/vscode-extension && node build-vsix.js && cd dist && npx --yes @vscode/vsce package --no-dependencies` |
|
|
646
|
+
| **3. 产物** | `references/vscode-extension/dist/cursor-guard-ide-<version>.vsix`(文件名与 `version` 一致) |
|
|
647
|
+
| **4. Git** | 提交并推送默认分支;打标签 **`v<version>`** 并推送(示例:`git tag -a vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z`)。提交 hash 以实际为准记入你的表格。 |
|
|
648
|
+
| **5. GitHub Release** | 在 [Releases](https://github.com/zhangqiang8vipp/cursor-guard/releases/new) 新建 Release,选择对应 **`v<version>`** 标签,上传上述 VSIX。 |
|
|
649
|
+
| **6. release 分支** | 按分支策略将 **`release/v4.8.x`**、**`release/v4.7.x`** 等维护分支快进到当前 **`master`**(如需)。 |
|
|
650
|
+
| **7. npm** | 在仓库根目录执行 **`npm publish`**;若提示 OTP,先在浏览器完成 npm 的二次验证,再重新执行一次 **`npm publish`**。 |
|
|
651
|
+
|
|
652
|
+
暂不发布 VS Code Marketplace 也可以;仅靠 GitHub Release + VSIX 已能满足很多安装场景。
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
537
656
|
## 已知限制
|
|
538
657
|
|
|
539
658
|
- **二进制文件**:Git 快照可以存储二进制文件(图片、编译产物),但无法进行有意义的 diff 或部分恢复。
|
|
@@ -541,6 +660,7 @@ code --install-extension .
|
|
|
541
660
|
- **并发 Agent**:如果多个 AI 代理线程同时写入同一文件,快照无法防止竞态条件。请避免并行编辑同一文件。
|
|
542
661
|
- **外部工具修改索引**:在自动备份运行期间,其他修改 Git 索引的工具(如 Git GUI、IDE Git 集成)可能冲突。脚本使用临时索引来最小化风险,但边缘情况仍存在。
|
|
543
662
|
- **Git worktree**:自动备份脚本支持 worktree 布局(`git rev-parse --git-dir`),但未在所有特殊配置下测试(如 `--separate-git-dir`)。
|
|
663
|
+
- **预警边界**:`pre_warning` 目前属于编辑器/扩展侧的“最后一道刹车”,还不是跨进程、全场景的硬拦截。纯 shell / 纯 MCP 无界面场景下,主要通过状态和看板暴露风险。
|
|
544
664
|
- **Cursor 终端干扰**:Cursor 集成终端会向 `git commit` 命令注入 `--trailer` 标志,导致 `commit-tree` 等底层命令异常。请始终在**独立的终端窗口**中运行自动备份脚本。
|
|
545
665
|
- **大型仓库**:对于非常大的仓库,备份循环中的 `git add -A` 可能较慢。使用 `.cursor-guard.json` 中的 `protect` 模式缩小范围。
|
|
546
666
|
|
|
@@ -564,4 +684,4 @@ code --install-extension .
|
|
|
564
684
|
|
|
565
685
|
## 许可证
|
|
566
686
|
|
|
567
|
-
[BSL 1.1
|
|
687
|
+
[BSL 1.1](LICENSE)
|
package/ROADMAP.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
> 本文档描述 cursor-guard 从 V2 到 V7 的长期演进方向。
|
|
4
4
|
> 每一代向下兼容,低版本功能永远不废弃。
|
|
5
5
|
>
|
|
6
|
-
> **当前版本**:`V4.9.
|
|
7
|
-
> **文档状态**:`V2` ~ `V4.9.
|
|
6
|
+
> **当前版本**:`V4.9.8`
|
|
7
|
+
> **文档状态**:`V2` ~ `V4.9.8` 已完成交付(含 V5 intent/audit 基础),`V5` 主体规划中
|
|
8
8
|
|
|
9
9
|
## 阅读导航
|
|
10
10
|
|
|
@@ -193,7 +193,7 @@ cursor-guard 的安全,不靠“模型自己小心一点”,而是靠**规
|
|
|
193
193
|
|
|
194
194
|
---
|
|
195
195
|
|
|
196
|
-
## V2 — Skill + Script
|
|
196
|
+
## V2 — Skill + Script(基础能力起点)
|
|
197
197
|
|
|
198
198
|
| 项目 | 内容 |
|
|
199
199
|
|---|---|
|
|
@@ -560,7 +560,7 @@ V4 经过 4 轮系统性代码审查,修复了以下关键问题:
|
|
|
560
560
|
|
|
561
561
|
| 层 | 改动 | 说明 |
|
|
562
562
|
|----|------|------|
|
|
563
|
-
| Core | `backups.js` 新增 `getBackupFiles(projectDir, commitHash)` | 对指定 commit 运行 `diff
|
|
563
|
+
| Core | `backups.js` 新增 `getBackupFiles(projectDir, commitHash)` | 对指定 commit 运行 `git diff --numstat` + `git diff --name-status`(与终端一致;V4.9.3+)。无 parent 时对 Git 空树 `4b825dc…`。返回 `[{path, action, added, deleted}]`,按变化量降序;`R`/`C` 前缀解析 rename/copy |
|
|
564
564
|
| Server | `GET /api/backup-files?id=<project>&hash=<commit>` | 懒加载端点,不在 `list_backups` 中批量计算(50 条备份×`diff-tree` 会很慢)。400 校验 `hash` 必填 |
|
|
565
565
|
| Dashboard | `parseSummaryToFiles(summary)` | 解析 summary 文本格式 `"Modified 3: a.js (+2 -1), b.js (+0 -5), ...; Added 2: c.js (+10 -0)"` → `[{path, action, added, deleted}]`。正则匹配 `(Modified|Added|Deleted|Renamed) N:` 段头,逐文件解析 `filename (+N -M)`,自动跳过 `...` 截断标记 |
|
|
566
566
|
| Dashboard | `fetchBackupFiles(hash)` | 调用 `/api/backup-files` 端点,返回完整文件数组。网络失败静默降级(返回空数组) |
|
|
@@ -734,6 +734,55 @@ V4 经过 4 轮系统性代码审查,修复了以下关键问题:
|
|
|
734
734
|
}
|
|
735
735
|
```
|
|
736
736
|
|
|
737
|
+
### V4.9.8:发版流程文档化 + 侧边栏品牌占位 ✅
|
|
738
|
+
| 能力 | 说明 |
|
|
739
|
+
|------|------|
|
|
740
|
+
| **发版清单** | 根目录 `npm run release:checklist` 输出带当前 `package.json` 版本的步骤表;README / README.zh-CN 双语「发版检查清单」与之一致,避免 VSIX 名、tag、npm 版本手写漂移 |
|
|
741
|
+
| **构建提示** | `build-vsix.js` 结束行打印预期 `cursor-guard-ide-<version>.vsix` 文件名 |
|
|
742
|
+
| **侧边栏品牌** | 扩展包内 `media/brand-placeholder.png`,webview 通过 `asWebviewUri` 加载;缺失时回退渐变占位 |
|
|
743
|
+
|
|
744
|
+
### V4.9.7:预警体验打磨、语言同步与 Watcher 单例保护 ✅
|
|
745
|
+
| 能力 | 说明 |
|
|
746
|
+
|------|------|
|
|
747
|
+
| **柔性预警** | `popup` 模式改为 2 秒自动继续的软提示,保留 `Undo Change`、`View Diff`、`Keep Changes`,但不再把连续 AI 编辑卡死在硬模态弹窗里 |
|
|
748
|
+
| **语言同步** | 侧边栏语言切换会同步到预警提示,zh-CN / en-US 的按钮、摘要、倒计时文案保持一致 |
|
|
749
|
+
| **侧边栏状态恢复** | `popup` 模式的预警不再长期占据侧边栏主卡片;Watcher / Health 状态重新固定可见,系统是否正常运行能持续看到 |
|
|
750
|
+
| **Watcher 单例** | IDE 侧统一读取真实 watcher 锁文件路径,并增加 pending-process 保护;同一个项目重复点 `Start Watcher` 不会再拉起多个 watcher |
|
|
751
|
+
| **发布目标** | 这是对 V4.9.6 MVP 的 UX/稳定性收口版,让预警真正适合长时间挂在 Agent 模式下使用 |
|
|
752
|
+
|
|
753
|
+
### V4.9.6:新增可开关的 `pre_warning` 事先预警 MVP ✅
|
|
754
|
+
|
|
755
|
+
| 能力 | 说明 |
|
|
756
|
+
|------|------|
|
|
757
|
+
| **配置开关** | `.cursor-guard.json` 新增 `enable_pre_warning`、`pre_warning_threshold`、`pre_warning_mode`、`pre_warning_exclude_patterns`,默认关闭,兼容旧项目 |
|
|
758
|
+
| **风险模型** | 基于删行比例 + 方法/函数移除检测进行评分;删方法/函数即使未达到删行阈值,也会按高风险处理 |
|
|
759
|
+
| **IDE 交互** | VSCode / Cursor / Windsurf 扩展支持 `popup` / `dashboard` / `silent` 三种模式;`popup` 提供 `Undo Change` 与 `View Diff` 作为最后一道刹车 |
|
|
760
|
+
| **状态面整合** | `backup_status`、`dashboard`、状态栏、侧边栏、浏览器仪表盘统一展示活跃 pre-warning;风险摘要进入 health issues |
|
|
761
|
+
| **架构定位** | 这是 V5「变更控制层」前的一步 MVP:先做编辑器侧的“最后一道提醒”,不是跨进程硬拦截;后续仍由 V5 的 `begin_edit` / embedded watcher 承接更强的事前控制 |
|
|
762
|
+
|
|
763
|
+
### V4.9.5 / V4.9.4:修复事件驱动 Watcher 因 `.git` 写入导致的疯狂自触发备份 ✅
|
|
764
|
+
|
|
765
|
+
| 修复 | 说明 |
|
|
766
|
+
|------|------|
|
|
767
|
+
| **根因** | v4.9.0 起 `fs.watch(recursive)` 监听整个仓库。每次快照会写 `.git/objects`、`refs/guard/…` 等,触发 watch → debounce 后又跑备份。Windows 下 `filename` 常为 `HEAD`、`objects/…` 等**不带** `.git/` 前缀 → **反馈环路** |
|
|
768
|
+
| **完全避免(不靠延时)** | `shouldIgnoreFsWatchEvent`:凡可判定为「落在 Git 目录内」的事件一律不触发备份。**不用**快照后冷却计时;路径语义正确即可从根上断开环路 |
|
|
769
|
+
| **真实 Git 目录** | 传入 `git rev-parse --git-dir` 解析后的路径(worktree / 子模块等下 `.git` 可能是文件),避免误用 `项目/.git` 字符串 |
|
|
770
|
+
| **路径规则** | `.git/` 前缀、`.cursor-guard-backup`、多段路径在 `git-dir` 下存在、`path.relative(gitDir, resolve(项目,filename))` 落在仓库内 → 忽略 |
|
|
771
|
+
| **V4.9.5** | 移除曾加入的 **3.5s 冷却**(用户要求:应全量避免,而非靠时间窗口兜底) |
|
|
772
|
+
|
|
773
|
+
### V4.9.3:备份文件 +/- 与终端 `git diff` 完全一致 ✅
|
|
774
|
+
|
|
775
|
+
| 变更 | 说明 |
|
|
776
|
+
|------|------|
|
|
777
|
+
| **唯一数据源** | `getBackupFiles` 只使用 `git diff --numstat <parent> <commit>` + `git diff --name-status <parent> <commit>`,与你在终端执行的 diff 统计一致(含 rename 检测、CRLF、二进制 `- -` 等) |
|
|
778
|
+
| **根/orphan 提交** | 无父提交时 `parent` 使用 Git 标准空树 `4b825dc642cb6eb9a060e54bf8d69288fbee4904`,不再用 `ls-tree` + 手工行数 |
|
|
779
|
+
| **移除** | 去掉 `diff-tree --numstat`、`--text` 及 `git show` 行数回退,避免与 CLI 语义分叉 |
|
|
780
|
+
| **拷贝** | `git diff --name-status` 的 `C`(copy)映射为 `action: copied` |
|
|
781
|
+
|
|
782
|
+
### V4.9.2:(已由 V4.9.3 替代)备份详情行数修复尝试
|
|
783
|
+
|
|
784
|
+
> V4.9.2 的 `--text` + `git show` 回退已废弃;以 V4.9.3「纯 git diff」为准。
|
|
785
|
+
|
|
737
786
|
### V4.9.1:侧边栏"Last backup"实时计时 ✅
|
|
738
787
|
|
|
739
788
|
| 优化 | 说明 |
|
|
@@ -1381,7 +1430,7 @@ PR Review 中展示 AI 编辑报告
|
|
|
1381
1430
|
|
|
1382
1431
|
### V6 不做的事
|
|
1383
1432
|
|
|
1384
|
-
-
|
|
1433
|
+
- **不做平台化** —— cursor-guard 专注代码安全工具
|
|
1385
1434
|
- **不做强依赖云端的服务** —— 核心能力永远是本地优先
|
|
1386
1435
|
- **不做 IDE 本体** —— 只做安全层,不越界
|
|
1387
1436
|
- **不做通用工程观测平台** —— 只围绕 AI 代码变更安全
|
|
@@ -1568,7 +1617,15 @@ V4.3.2 ───── ✅ init 自动添加 node_modules/ 到 .gitignore + doc
|
|
|
1568
1617
|
V4.3.3 ───── ✅ Intent 上下文(intent / agent / session trailer + 仪表盘展示)
|
|
1569
1618
|
V4.3.4 ───── ✅ 运维加固(日志轮转 / 锁文件时间戳 / preview 分组 / SKILL 规则)
|
|
1570
1619
|
V4.3.5 ───── ✅ Summary 增量 diff-tree 修复 + 变更列堆叠布局 + 配色优化
|
|
1571
|
-
V4.4.0 ───── ✅ V4 收官:首次快照 summary + doctor 完整性/retention 检查 + init 升级检测
|
|
1620
|
+
V4.4.0 ───── ✅ V4 收官:首次快照 summary + doctor 完整性/retention 检查 + init 升级检测
|
|
1621
|
+
V4.9.0 ───── ✅ 事件驱动 watcher + 实时侧边栏计时
|
|
1622
|
+
V4.9.5 ───── ✅ 修复 `.git` 写入导致的疯狂自触发备份
|
|
1623
|
+
V4.9.8 ───── ✅ 发版清单(README 双语 + checklist 脚本)+ 侧边栏品牌图 ← 当前版本
|
|
1624
|
+
V4.9.7 ───── ✅ 预警体验打磨 + 语言同步 + watcher 单例保护
|
|
1625
|
+
│
|
|
1626
|
+
│ 前提:MVP 已跑通,需要把提示从“能用”打磨到“适合常开”
|
|
1627
|
+
▼
|
|
1628
|
+
V4.9.6 ───── ✅ `pre_warning` 事先预警 MVP(局部删代码风险提示)
|
|
1572
1629
|
│
|
|
1573
1630
|
│ 前提:AI 编辑需要更强的追溯 / 恢复 / 查询闭环
|
|
1574
1631
|
│ 前提:多 Agent / 多工具协作成为真实场景
|
|
@@ -1647,10 +1704,10 @@ V7 的"可验证治理"是这条产品线的逻辑终点——该保护的都保
|
|
|
1647
1704
|
| 取代 Git | cursor-guard 是 Git 的增强,不是替代 |
|
|
1648
1705
|
| AI 行为限制 | cursor-guard 是安全网,不是笼子 |
|
|
1649
1706
|
| 多 IDE 全面适配 | 聚焦 Cursor,其他 IDE 由社区或 V6 协议解决 |
|
|
1650
|
-
|
|
|
1707
|
+
| 封闭化 | 保持开源,协议保持开放 |
|
|
1651
1708
|
| 中心化认证服务 | 签名和验证基于本地,不引入外部依赖 |
|
|
1652
1709
|
|
|
1653
1710
|
---
|
|
1654
1711
|
|
|
1655
1712
|
*最后更新:2026-03-22*
|
|
1656
|
-
*版本:v1.
|
|
1713
|
+
*版本:v1.8(V4.9.8,在 V4.9.7 基础上增加发版流程文档与侧边栏品牌资源;历史能力含事件驱动 watcher、自触发备份反馈环修复、`pre_warning` 事先预警 MVP)*
|