cursor-guard 4.1.0 → 4.2.1
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 +40 -0
- package/README.zh-CN.md +40 -0
- package/SKILL.md +3 -0
- package/package.json +4 -2
- package/references/bin/cursor-guard-init.js +4 -2
- package/references/dashboard/public/app.js +1069 -0
- package/references/dashboard/public/index.html +106 -0
- package/references/dashboard/public/style.css +666 -0
- package/references/dashboard/server.js +206 -0
- package/references/lib/core/doctor.js +30 -8
- package/references/lib/core/restore.js +25 -1
- package/references/lib/utils.js +7 -2
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ When Cursor's AI agent edits your files, there's a risk of accidental overwrites
|
|
|
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
26
|
- **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 every 15s, multi-project support
|
|
27
28
|
|
|
28
29
|
---
|
|
29
30
|
|
|
@@ -115,6 +116,12 @@ After installation, your directory structure should look like this:
|
|
|
115
116
|
│ ├── status.js # Backup system status
|
|
116
117
|
│ ├── anomaly.js # V4: Change-velocity detection
|
|
117
118
|
│ └── dashboard.js # V4: Health dashboard aggregation
|
|
119
|
+
├── dashboard/
|
|
120
|
+
│ ├── server.js # Dashboard HTTP server + API
|
|
121
|
+
│ └── public/ # Web UI (HTML/CSS/JS)
|
|
122
|
+
│ ├── index.html
|
|
123
|
+
│ ├── style.css
|
|
124
|
+
│ └── app.js
|
|
118
125
|
├── mcp/
|
|
119
126
|
│ └── server.js # MCP Server (9 tools)
|
|
120
127
|
├── bin/
|
|
@@ -249,6 +256,37 @@ npx cursor-guard-doctor --path /my/project
|
|
|
249
256
|
|
|
250
257
|
> **Note**: Run backup/doctor scripts in a separate terminal, NOT inside Cursor's integrated terminal.
|
|
251
258
|
|
|
259
|
+
### Web Dashboard
|
|
260
|
+
|
|
261
|
+
A local read-only web page for monitoring backup health, restore points, protection scope, and diagnostics — all in one view.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Monitor a single project
|
|
265
|
+
npx cursor-guard-dashboard --path /my/project
|
|
266
|
+
|
|
267
|
+
# Monitor multiple projects
|
|
268
|
+
npx cursor-guard-dashboard --path /project-a --path /project-b
|
|
269
|
+
|
|
270
|
+
# Custom port (default: 3120)
|
|
271
|
+
npx cursor-guard-dashboard --path /my/project --port 8080
|
|
272
|
+
|
|
273
|
+
# Windows PowerShell (from skill directory)
|
|
274
|
+
node references\dashboard\server.js --path "D:\MyProject"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Then open `http://127.0.0.1:3120` in your browser.
|
|
278
|
+
|
|
279
|
+
Features:
|
|
280
|
+
|
|
281
|
+
- **Read-only** — no write operations, safe to run anytime
|
|
282
|
+
- **Dual-language** — zh-CN / en-US, auto-detects system language, manual toggle in top-right
|
|
283
|
+
- **Auto-refresh** — pulls data every 15 seconds, plus manual refresh button
|
|
284
|
+
- **Multi-project** — pass multiple `--path` args to monitor several projects from one page
|
|
285
|
+
- **4 sections**: Overview (health + watcher + alerts + latest backups), Backups & Recovery (restore point table with type filters), Protection Scope (protect/ignore patterns), Diagnostics (doctor checks)
|
|
286
|
+
- **2 detail drawers**: Restore Point drawer (preview JSON, copy ref/hash), Doctor drawer (full check list, WARN/FAIL expanded by default)
|
|
287
|
+
- **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
|
|
288
|
+
- **Zero extra dependencies** — uses Node.js built-in `http` module + existing cursor-guard core modules
|
|
289
|
+
|
|
252
290
|
---
|
|
253
291
|
|
|
254
292
|
## Recovery
|
|
@@ -325,6 +363,8 @@ The skill activates on these signals:
|
|
|
325
363
|
| `references/lib/utils.js` | Shared utilities (config, glob, git, manifest) |
|
|
326
364
|
| `references/bin/cursor-guard-backup.js` | CLI entry: `npx cursor-guard-backup` |
|
|
327
365
|
| `references/bin/cursor-guard-doctor.js` | CLI entry: `npx cursor-guard-doctor` |
|
|
366
|
+
| `references/dashboard/server.js` | Dashboard HTTP server + REST API |
|
|
367
|
+
| `references/dashboard/public/` | Dashboard web UI (index.html, style.css, app.js) |
|
|
328
368
|
| `references/auto-backup.ps1` / `.sh` | Thin wrappers (Windows / macOS+Linux) |
|
|
329
369
|
| `references/guard-doctor.ps1` / `.sh` | Thin wrappers (Windows / macOS+Linux) |
|
|
330
370
|
| `references/recovery.md` | Recovery command templates |
|
package/README.zh-CN.md
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
- **自动诊断修复** — `doctor_fix` 一键修补缺失配置、未初始化 Git、gitignore 遗漏等常见问题
|
|
25
25
|
- **主动变更频率告警(V4)** — 自动检测异常文件变更模式并发出风险预警
|
|
26
26
|
- **备份健康看板(V4)** — 一次调用全面查看:策略、数量、磁盘占用、保护范围、健康状态
|
|
27
|
+
- **Web 仪表盘(V4.2)** — 本地只读 Web 页面 `http://127.0.0.1:3120`——健康状态、备份、恢复点、诊断、保护范围一目了然。中英双语、每 15 秒自动刷新、支持多项目监控
|
|
27
28
|
|
|
28
29
|
---
|
|
29
30
|
|
|
@@ -115,6 +116,12 @@ git clone https://github.com/zhangqiang8vipp/cursor-guard.git .cursor/skills/cur
|
|
|
115
116
|
│ ├── status.js # 备份系统状态
|
|
116
117
|
│ ├── anomaly.js # V4:变更频率检测
|
|
117
118
|
│ └── dashboard.js # V4:健康看板聚合
|
|
119
|
+
├── dashboard/
|
|
120
|
+
│ ├── server.js # 仪表盘 HTTP 服务 + API
|
|
121
|
+
│ └── public/ # Web UI(HTML/CSS/JS)
|
|
122
|
+
│ ├── index.html
|
|
123
|
+
│ ├── style.css
|
|
124
|
+
│ └── app.js
|
|
118
125
|
├── mcp/
|
|
119
126
|
│ └── server.js # MCP Server(9 个工具)
|
|
120
127
|
├── bin/
|
|
@@ -249,6 +256,37 @@ npx cursor-guard-doctor --path /my/project
|
|
|
249
256
|
|
|
250
257
|
> **注意**:请在独立终端窗口中运行备份/检查脚本,不要在 Cursor 集成终端中运行。
|
|
251
258
|
|
|
259
|
+
### Web 仪表盘
|
|
260
|
+
|
|
261
|
+
本地只读 Web 页面,一页查看备份健康状态、恢复点、保护范围和诊断结果。
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# 监控单个项目
|
|
265
|
+
npx cursor-guard-dashboard --path /my/project
|
|
266
|
+
|
|
267
|
+
# 监控多个项目
|
|
268
|
+
npx cursor-guard-dashboard --path /project-a --path /project-b
|
|
269
|
+
|
|
270
|
+
# 自定义端口(默认 3120)
|
|
271
|
+
npx cursor-guard-dashboard --path /my/project --port 8080
|
|
272
|
+
|
|
273
|
+
# Windows PowerShell(从 skill 目录运行)
|
|
274
|
+
node references\dashboard\server.js --path "D:\MyProject"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
然后在浏览器打开 `http://127.0.0.1:3120`。
|
|
278
|
+
|
|
279
|
+
特性:
|
|
280
|
+
|
|
281
|
+
- **只读** — 不执行任何写操作,随时可以安全运行
|
|
282
|
+
- **中英双语** — zh-CN / en-US,自动检测系统语言,右上角手动切换
|
|
283
|
+
- **自动刷新** — 每 15 秒拉取数据,支持手动刷新按钮
|
|
284
|
+
- **多项目** — 传多个 `--path` 参数可从一个页面监控多个项目
|
|
285
|
+
- **4 个区块**:总览(健康状态 + 守护进程 + 告警 + 最近备份)、备份与恢复(恢复点表格,按类型过滤)、保护范围(protect/ignore 规则)、诊断(doctor 检查项)
|
|
286
|
+
- **2 个详情抽屉**:恢复点抽屉(预览 JSON、复制引用/hash)、诊断抽屉(完整检查列表,WARN/FAIL 默认展开)
|
|
287
|
+
- **安全性** — 仅绑定 `127.0.0.1`(不暴露到局域网)、API 使用项目 ID 而非原始路径、静态文件服务严格限制在 `public/` 目录
|
|
288
|
+
- **零额外依赖** — 使用 Node.js 内置 `http` 模块 + cursor-guard 已有核心模块
|
|
289
|
+
|
|
252
290
|
---
|
|
253
291
|
|
|
254
292
|
## 恢复
|
|
@@ -325,6 +363,8 @@ npx cursor-guard-doctor --path /my/project
|
|
|
325
363
|
| `references/lib/utils.js` | 共享工具库(配置、glob、git、manifest) |
|
|
326
364
|
| `references/bin/cursor-guard-backup.js` | CLI 入口:`npx cursor-guard-backup` |
|
|
327
365
|
| `references/bin/cursor-guard-doctor.js` | CLI 入口:`npx cursor-guard-doctor` |
|
|
366
|
+
| `references/dashboard/server.js` | 仪表盘 HTTP 服务 + REST API |
|
|
367
|
+
| `references/dashboard/public/` | 仪表盘 Web UI(index.html、style.css、app.js) |
|
|
328
368
|
| `references/auto-backup.ps1` / `.sh` | 薄封装(Windows / macOS+Linux) |
|
|
329
369
|
| `references/guard-doctor.ps1` / `.sh` | 薄封装(Windows / macOS+Linux) |
|
|
330
370
|
| `references/recovery.md` | 恢复命令模板 |
|
package/SKILL.md
CHANGED
|
@@ -488,6 +488,7 @@ Current version preserved before restore:
|
|
|
488
488
|
> - Project preview: `restore_project { "path": "<project>", "source": "<hash>", "preview": true }` — returns the list of files that would change.
|
|
489
489
|
> - Project execute: after user confirms, `restore_project { "path": "<project>", "source": "<hash>", "preview": false, "preserve_current": true }` — creates pre-restore snapshot, then restores all files in one call. Returns `{ filesRestored, preRestoreRef, files }`.
|
|
490
490
|
> - MCP `restore_file` and `restore_project` respect `pre_restore_backup` config (§Step 4) automatically. The response includes `preRestoreRef` if a snapshot was created.
|
|
491
|
+
> - **`.cursor/` protection**: `restore_project` automatically preserves the `.cursor/` directory (including skills, MCP configs, rules) from HEAD after restoring. Preview results mark `.cursor/` files with a `warning` field. If a user explicitly wants to restore `.cursor/` contents, they must do so file-by-file via `restore_file`.
|
|
491
492
|
|
|
492
493
|
**Single file recovery:**
|
|
493
494
|
|
|
@@ -568,6 +569,7 @@ Skip the block for unrelated turns.
|
|
|
568
569
|
11. **Use `--no-verify`** on all guard snapshot commits to bypass pre-commit hooks that could fail or modify files.
|
|
569
570
|
12. **Concurrent agents**: if multiple Agent threads are active, warn the user to avoid simultaneous writes to the same file. Snapshots cannot prevent race conditions between parallel agents.
|
|
570
571
|
13. **Preservation must not pollute** — all pre-restore backups use temp index + dedicated ref (`refs/guard/pre-restore`). The user's staging area, working tree, and commit history on their branch are never modified by the preservation process.
|
|
572
|
+
14. **Do not restore `.cursor/` directory** — `.cursor/skills/`, `.cursor/rules/`, and `.cursor/mcp.json` are tool infrastructure, not project code. `restore_project` automatically protects this directory. Never include `.cursor/` in manual restore commands unless the user explicitly requests it. Restoring `.cursor/skills/cursor-guard/` would downgrade the protection tool itself.
|
|
571
573
|
|
|
572
574
|
---
|
|
573
575
|
|
|
@@ -586,6 +588,7 @@ Skip the block for unrelated turns.
|
|
|
586
588
|
- Guard doctor (Node.js core): [references/lib/guard-doctor.js](references/lib/guard-doctor.js)
|
|
587
589
|
- Core modules: [references/lib/core/](references/lib/core/) (doctor, doctor-fix, snapshot, backups, restore, status, anomaly, dashboard)
|
|
588
590
|
- MCP server: [references/mcp/server.js](references/mcp/server.js) (9 tools: doctor, doctor_fix, backup_status, list_backups, snapshot_now, restore_file, restore_project, dashboard, alert_status)
|
|
591
|
+
- Web dashboard: [references/dashboard/](references/dashboard/) (local read-only web UI — `node references/dashboard/server.js --path <project>`)
|
|
589
592
|
- Shared utilities: [references/lib/utils.js](references/lib/utils.js)
|
|
590
593
|
- Config JSON Schema: [references/cursor-guard.schema.json](references/cursor-guard.schema.json)
|
|
591
594
|
- Example config: [references/cursor-guard.example.json](references/cursor-guard.example.json)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-guard",
|
|
3
|
-
"version": "4.1
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Protects code from accidental AI overwrite or deletion in Cursor IDE — mandatory pre-write snapshots, review-before-apply, local Git safety net, and deterministic recovery. | 保护代码免受 Cursor AI 代理意外覆写或删除——强制写前快照、预览再执行、本地 Git 安全网、确定性恢复。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cursor",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"cursor-guard-init": "references/bin/cursor-guard-init.js",
|
|
31
31
|
"cursor-guard-backup": "references/bin/cursor-guard-backup.js",
|
|
32
32
|
"cursor-guard-doctor": "references/bin/cursor-guard-doctor.js",
|
|
33
|
-
"cursor-guard-mcp": "references/mcp/server.js"
|
|
33
|
+
"cursor-guard-mcp": "references/mcp/server.js",
|
|
34
|
+
"cursor-guard-dashboard": "references/dashboard/server.js"
|
|
34
35
|
},
|
|
35
36
|
"files": [
|
|
36
37
|
"SKILL.md",
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
"references/lib/utils.js",
|
|
49
50
|
"references/lib/core/",
|
|
50
51
|
"references/mcp/",
|
|
52
|
+
"references/dashboard/",
|
|
51
53
|
"references/config-reference.md",
|
|
52
54
|
"references/config-reference.zh-CN.md",
|
|
53
55
|
"references/cursor-guard.example.json",
|
|
@@ -67,10 +67,10 @@ console.log(' Done.');
|
|
|
67
67
|
// Step 2: Install MCP dependencies in skill directory
|
|
68
68
|
console.log(' [2/4] Installing MCP dependencies...');
|
|
69
69
|
try {
|
|
70
|
-
|
|
70
|
+
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
71
|
+
execFileSync(npmCmd, ['install', '--omit=dev', '--ignore-scripts'], {
|
|
71
72
|
cwd: skillTarget,
|
|
72
73
|
stdio: 'pipe',
|
|
73
|
-
shell: process.platform === 'win32',
|
|
74
74
|
});
|
|
75
75
|
console.log(' Done.');
|
|
76
76
|
} catch (e) {
|
|
@@ -110,6 +110,8 @@ console.log(` MCP server: ${serverExists ? 'OK' : 'MISSING'}`);
|
|
|
110
110
|
console.log(` MCP SDK: ${sdkExists ? 'OK' : 'MISSING — run npm install in skill dir'}`);
|
|
111
111
|
|
|
112
112
|
console.log(`\n Installation complete!\n`);
|
|
113
|
+
console.log(' ⚠ If MCP was already configured, restart Cursor (or Ctrl+Shift+P →');
|
|
114
|
+
console.log(' "Developer: Reload Window") to load the updated MCP server.\n');
|
|
113
115
|
console.log(' Next steps:');
|
|
114
116
|
console.log(' 1. The skill activates automatically in Cursor Agent conversations.');
|
|
115
117
|
console.log(' 2. (Optional) Copy example config to project root:');
|