cursor-guard 2.1.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursor-guard",
3
- "version": "2.1.1",
3
+ "version": "3.0.0",
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",
@@ -24,16 +24,18 @@
24
24
  "node": ">=18"
25
25
  },
26
26
  "scripts": {
27
- "test": "node references/lib/utils.test.js"
27
+ "test": "node references/lib/utils.test.js && node references/lib/core/core.test.js && node references/mcp/mcp.test.js"
28
28
  },
29
29
  "bin": {
30
30
  "cursor-guard-backup": "references/bin/cursor-guard-backup.js",
31
- "cursor-guard-doctor": "references/bin/cursor-guard-doctor.js"
31
+ "cursor-guard-doctor": "references/bin/cursor-guard-doctor.js",
32
+ "cursor-guard-mcp": "references/mcp/server.js"
32
33
  },
33
34
  "files": [
34
35
  "SKILL.md",
35
36
  "README.md",
36
37
  "README.zh-CN.md",
38
+ "ROADMAP.md",
37
39
  "LICENSE",
38
40
  "references/auto-backup.ps1",
39
41
  "references/auto-backup.sh",
@@ -43,11 +45,18 @@
43
45
  "references/lib/auto-backup.js",
44
46
  "references/lib/guard-doctor.js",
45
47
  "references/lib/utils.js",
48
+ "references/lib/core/",
49
+ "references/mcp/",
46
50
  "references/config-reference.md",
47
51
  "references/config-reference.zh-CN.md",
48
52
  "references/cursor-guard.example.json",
49
53
  "references/cursor-guard.schema.json",
50
- "references/recovery.md"
54
+ "references/recovery.md",
55
+ "references/quickstart.zh-CN.md"
51
56
  ],
52
- "main": "SKILL.md"
57
+ "main": "SKILL.md",
58
+ "dependencies": {
59
+ "@modelcontextprotocol/sdk": "^1.27.1",
60
+ "zod": "^4.3.6"
61
+ }
53
62
  }
@@ -1,175 +1,175 @@
1
- # Configuration Reference
2
-
3
- This document explains every field in `.cursor-guard.json`.
4
-
5
- > Example file: [cursor-guard.example.json](cursor-guard.example.json)
6
- >
7
- > JSON Schema: [cursor-guard.schema.json](cursor-guard.schema.json)
8
-
9
- ---
10
-
11
- ## `protect`
12
-
13
- - **Type**: `string[]` (glob patterns)
14
- - **Default**: not set (all files protected)
15
-
16
- Whitelist glob patterns relative to workspace root. Only matching files get backup protection. If empty or missing, all files are protected.
17
-
18
- ```json
19
- "protect": ["src/**", "lib/**", "package.json"]
20
- ```
21
-
22
- ---
23
-
24
- ## `ignore`
25
-
26
- - **Type**: `string[]` (glob patterns)
27
- - **Default**: not set
28
-
29
- Blacklist glob patterns. Matching files are excluded from protection even if they match `protect`. Applied on top of `.gitignore`.
30
-
31
- **Resolution rules**:
32
-
33
- | Scenario | Behavior |
34
- |----------|----------|
35
- | Both `protect` and `ignore` set | File must match `protect` AND not match `ignore` |
36
- | Only `protect` set | Only matching files are protected |
37
- | Only `ignore` set | Everything protected except matches |
38
- | Neither set | Protect everything |
39
-
40
- ```json
41
- "ignore": ["node_modules/**", "dist/**", "*.log"]
42
- ```
43
-
44
- ---
45
-
46
- ## `backup_strategy`
47
-
48
- - **Type**: `string`
49
- - **Allowed**: `"git"` | `"shadow"` | `"both"`
50
- - **Default**: `"git"`
51
-
52
- | Value | Description |
53
- |-------|-------------|
54
- | `"git"` | Local commits to dedicated ref `refs/guard/auto-backup` |
55
- | `"shadow"` | File copies to `.cursor-guard-backup/<timestamp>/` |
56
- | `"both"` | Git branch snapshot + shadow copies |
57
-
58
- ```json
59
- "backup_strategy": "git"
60
- ```
61
-
62
- ---
63
-
64
- ## `auto_backup_interval_seconds`
65
-
66
- - **Type**: `integer`
67
- - **Minimum**: `5`
68
- - **Default**: `60`
69
-
70
- Interval in seconds for the auto-backup script to check for changes and create snapshots.
71
-
72
- ```json
73
- "auto_backup_interval_seconds": 60
74
- ```
75
-
76
- ---
77
-
78
- ## `secrets_patterns`
79
-
80
- - **Type**: `string[]` (glob patterns)
81
- - **Default**: built-in list (see below)
82
-
83
- Glob patterns for sensitive files. Matching files are **auto-excluded** from backup, even if within `protect` scope. Built-in defaults: `.env`, `.env.*`, `*.key`, `*.pem`, `*.p12`, `*.pfx`, `credentials*`.
84
-
85
- **Setting this field replaces the built-in defaults entirely.** If you only need to add patterns, use `secrets_patterns_extra` instead.
86
-
87
- ```json
88
- "secrets_patterns": [".env", ".env.*", "*.key", "*.pem"]
89
- ```
90
-
91
- ---
92
-
93
- ## `secrets_patterns_extra`
94
-
95
- - **Type**: `string[]` (glob patterns)
96
- - **Default**: not set
97
-
98
- Additional glob patterns **appended** to the current `secrets_patterns` (including defaults). Use this to add custom patterns without losing the built-in protection for `.p12`, `.pfx`, `credentials*`, etc.
99
-
100
- ```json
101
- "secrets_patterns_extra": ["*.secret", "tokens.*"]
102
- ```
103
-
104
- ---
105
-
106
- ## `pre_restore_backup`
107
-
108
- - **Type**: `string`
109
- - **Allowed**: `"always"` | `"ask"` | `"never"`
110
- - **Default**: `"always"`
111
-
112
- | Value | Description |
113
- |-------|-------------|
114
- | `"always"` | Auto-preserve current version before every restore. No prompt. |
115
- | `"ask"` | Prompt user each time: "Preserve current version?" |
116
- | `"never"` | Skip preservation entirely (not recommended). |
117
-
118
- Regardless of this config, the user's explicit instruction in the current message always takes priority. Say "don't preserve" to skip, or "preserve first" to force.
119
-
120
- ```json
121
- "pre_restore_backup": "always"
122
- ```
123
-
124
- ---
125
-
126
- ## `retention`
127
-
128
- - **Type**: `object`
129
- - **Default**: `{ "mode": "days", "days": 30 }`
130
-
131
- Retention policy for **shadow copies** only. Git branch snapshots are not auto-cleaned — manage them manually. Controls automatic cleanup of old `.cursor-guard-backup/` directories.
132
-
133
- ### Sub-fields
134
-
135
- | Field | Type | Default | Description |
136
- |-------|------|---------|-------------|
137
- | `mode` | `"days"` \| `"count"` \| `"size"` | `"days"` | Cleanup strategy |
138
- | `days` | `integer` | `30` | Keep snapshots from last N days (when mode=days) |
139
- | `max_count` | `integer` | `100` | Keep N newest snapshots (when mode=count) |
140
- | `max_size_mb` | `integer` | `500` | Keep total size under N MB (when mode=size) |
141
-
142
- ```json
143
- "retention": {
144
- "mode": "days",
145
- "days": 30,
146
- "max_count": 100,
147
- "max_size_mb": 500
148
- }
149
- ```
150
-
151
- ---
152
-
153
- ## `git_retention`
154
-
155
- - **Type**: `object`
156
- - **Default**: `{ "enabled": false, "mode": "count", "max_count": 200 }`
157
-
158
- Retention policy for the **`refs/guard/auto-backup` Git ref**. By default, auto-backup commits accumulate indefinitely. Enable this to automatically prune old commits.
159
-
160
- ### Sub-fields
161
-
162
- | Field | Type | Default | Description |
163
- |-------|------|---------|-------------|
164
- | `enabled` | `boolean` | `false` | Enable automatic pruning. When false, branch grows without limit. |
165
- | `mode` | `"days"` \| `"count"` | `"count"` | Pruning strategy |
166
- | `days` | `integer` | `30` | Keep commits from last N days (when mode=days) |
167
- | `max_count` | `integer` | `200` | Keep N newest commits (when mode=count, minimum 10) |
168
-
169
- ```json
170
- "git_retention": {
171
- "enabled": true,
172
- "mode": "count",
173
- "max_count": 200
174
- }
175
- ```
1
+ # Configuration Reference
2
+
3
+ This document explains every field in `.cursor-guard.json`.
4
+
5
+ > Example file: [cursor-guard.example.json](cursor-guard.example.json)
6
+ >
7
+ > JSON Schema: [cursor-guard.schema.json](cursor-guard.schema.json)
8
+
9
+ ---
10
+
11
+ ## `protect`
12
+
13
+ - **Type**: `string[]` (glob patterns)
14
+ - **Default**: not set (all files protected)
15
+
16
+ Whitelist glob patterns relative to workspace root. Only matching files get backup protection. If empty or missing, all files are protected.
17
+
18
+ ```json
19
+ "protect": ["src/**", "lib/**", "package.json"]
20
+ ```
21
+
22
+ ---
23
+
24
+ ## `ignore`
25
+
26
+ - **Type**: `string[]` (glob patterns)
27
+ - **Default**: not set
28
+
29
+ Blacklist glob patterns. Matching files are excluded from protection even if they match `protect`. Applied on top of `.gitignore`.
30
+
31
+ **Resolution rules**:
32
+
33
+ | Scenario | Behavior |
34
+ |----------|----------|
35
+ | Both `protect` and `ignore` set | File must match `protect` AND not match `ignore` |
36
+ | Only `protect` set | Only matching files are protected |
37
+ | Only `ignore` set | Everything protected except matches |
38
+ | Neither set | Protect everything |
39
+
40
+ ```json
41
+ "ignore": ["node_modules/**", "dist/**", "*.log"]
42
+ ```
43
+
44
+ ---
45
+
46
+ ## `backup_strategy`
47
+
48
+ - **Type**: `string`
49
+ - **Allowed**: `"git"` | `"shadow"` | `"both"`
50
+ - **Default**: `"git"`
51
+
52
+ | Value | Description |
53
+ |-------|-------------|
54
+ | `"git"` | Local commits to dedicated ref `refs/guard/auto-backup` |
55
+ | `"shadow"` | File copies to `.cursor-guard-backup/<timestamp>/` |
56
+ | `"both"` | Git branch snapshot + shadow copies |
57
+
58
+ ```json
59
+ "backup_strategy": "git"
60
+ ```
61
+
62
+ ---
63
+
64
+ ## `auto_backup_interval_seconds`
65
+
66
+ - **Type**: `integer`
67
+ - **Minimum**: `5`
68
+ - **Default**: `60`
69
+
70
+ Interval in seconds for the auto-backup script to check for changes and create snapshots.
71
+
72
+ ```json
73
+ "auto_backup_interval_seconds": 60
74
+ ```
75
+
76
+ ---
77
+
78
+ ## `secrets_patterns`
79
+
80
+ - **Type**: `string[]` (glob patterns)
81
+ - **Default**: built-in list (see below)
82
+
83
+ Glob patterns for sensitive files. Matching files are **auto-excluded** from backup, even if within `protect` scope. Built-in defaults: `.env`, `.env.*`, `*.key`, `*.pem`, `*.p12`, `*.pfx`, `credentials*`.
84
+
85
+ **Setting this field replaces the built-in defaults entirely.** If you only need to add patterns, use `secrets_patterns_extra` instead.
86
+
87
+ ```json
88
+ "secrets_patterns": [".env", ".env.*", "*.key", "*.pem"]
89
+ ```
90
+
91
+ ---
92
+
93
+ ## `secrets_patterns_extra`
94
+
95
+ - **Type**: `string[]` (glob patterns)
96
+ - **Default**: not set
97
+
98
+ Additional glob patterns **appended** to the current `secrets_patterns` (including defaults). Use this to add custom patterns without losing the built-in protection for `.p12`, `.pfx`, `credentials*`, etc.
99
+
100
+ ```json
101
+ "secrets_patterns_extra": ["*.secret", "tokens.*"]
102
+ ```
103
+
104
+ ---
105
+
106
+ ## `pre_restore_backup`
107
+
108
+ - **Type**: `string`
109
+ - **Allowed**: `"always"` | `"ask"` | `"never"`
110
+ - **Default**: `"always"`
111
+
112
+ | Value | Description |
113
+ |-------|-------------|
114
+ | `"always"` | Auto-preserve current version before every restore. No prompt. |
115
+ | `"ask"` | Prompt user each time: "Preserve current version?" |
116
+ | `"never"` | Skip preservation entirely (not recommended). |
117
+
118
+ Regardless of this config, the user's explicit instruction in the current message always takes priority. Say "don't preserve" to skip, or "preserve first" to force.
119
+
120
+ ```json
121
+ "pre_restore_backup": "always"
122
+ ```
123
+
124
+ ---
125
+
126
+ ## `retention`
127
+
128
+ - **Type**: `object`
129
+ - **Default**: `{ "mode": "days", "days": 30 }`
130
+
131
+ Retention policy for **shadow copies** only. Git branch snapshots are not auto-cleaned — manage them manually. Controls automatic cleanup of old `.cursor-guard-backup/` directories.
132
+
133
+ ### Sub-fields
134
+
135
+ | Field | Type | Default | Description |
136
+ |-------|------|---------|-------------|
137
+ | `mode` | `"days"` \| `"count"` \| `"size"` | `"days"` | Cleanup strategy |
138
+ | `days` | `integer` | `30` | Keep snapshots from last N days (when mode=days) |
139
+ | `max_count` | `integer` | `100` | Keep N newest snapshots (when mode=count) |
140
+ | `max_size_mb` | `integer` | `500` | Keep total size under N MB (when mode=size) |
141
+
142
+ ```json
143
+ "retention": {
144
+ "mode": "days",
145
+ "days": 30,
146
+ "max_count": 100,
147
+ "max_size_mb": 500
148
+ }
149
+ ```
150
+
151
+ ---
152
+
153
+ ## `git_retention`
154
+
155
+ - **Type**: `object`
156
+ - **Default**: `{ "enabled": false, "mode": "count", "max_count": 200 }`
157
+
158
+ Retention policy for the **`refs/guard/auto-backup` Git ref**. By default, auto-backup commits accumulate indefinitely. Enable this to automatically prune old commits.
159
+
160
+ ### Sub-fields
161
+
162
+ | Field | Type | Default | Description |
163
+ |-------|------|---------|-------------|
164
+ | `enabled` | `boolean` | `false` | Enable automatic pruning. When false, branch grows without limit. |
165
+ | `mode` | `"days"` \| `"count"` | `"count"` | Pruning strategy |
166
+ | `days` | `integer` | `30` | Keep commits from last N days (when mode=days) |
167
+ | `max_count` | `integer` | `200` | Keep N newest commits (when mode=count, minimum 10) |
168
+
169
+ ```json
170
+ "git_retention": {
171
+ "enabled": true,
172
+ "mode": "count",
173
+ "max_count": 200
174
+ }
175
+ ```