11---
22title : Cursor
3+ tags :
4+ - IDE
5+ - CLI
6+ - Agent
37---
48
59# Cursor
@@ -11,17 +15,54 @@ title: Cursor
1115 - https://docs.cursor.com/en/models
1216 - MCP https://cursor.com/docs/context/mcp/directory
1317
14- # Conf
18+ # 配置 {#conf}
1519
16- - ~ /.cursor
17- - $CURSOR_CONFIG_DIR
18- - $XDG_CONFIG_HOME/cursor
19- - -> Windows ` %USERPROFILE%\.cursor `
20- - ~ /.cursor/mcp.json
21- - ` .cursor/mcp.json `
22- - ` ~/.cursor/cli-config.json `
23- - ` .cursor/cli.json `
24- - 只有 permissions 生效
20+ ## 配置文件位置
21+
22+ | 类型 | 平台 | 路径 |
23+ | ------- | ----------- | --------------------------------------- |
24+ | Global | macOS/Linux | ` ~/.cursor/cli-config.json ` |
25+ | Global | Windows | ` %USERPROFILE%\.cursor\cli-config.json ` |
26+ | Project | All | ` .cursor/cli.json ` |
27+
28+ ** 环境变量覆盖:**
29+
30+ - ` CURSOR_CONFIG_DIR ` - 自定义配置目录
31+ - ` XDG_CONFIG_HOME ` (Linux/BSD) - 使用 ` $XDG_CONFIG_HOME/cursor/cli-config.json `
32+
33+ ** 其他配置文件:**
34+
35+ - ` ~/.cursor/mcp.json ` - MCP 全局配置
36+ - ` .cursor/mcp.json ` - MCP 项目配置
37+
38+ ** 注意:**
39+
40+ - Project 级别的 ` .cursor/cli.json ` 只能配置 permissions
41+ - 其他 CLI 设置必须在 Global 配置中设置
42+
43+ ## 配置字段说明
44+
45+ ### 必填字段
46+
47+ | 字段 | 类型 | 描述 |
48+ | ------------------- | -------- | -------------------------------- |
49+ | ` version ` | number | 配置 schema 版本(当前:` 1 ` ) |
50+ | ` editor.vimMode ` | boolean | 启用 Vim 键绑定(默认:` false ` ) |
51+ | ` permissions.allow ` | string[ ] | 允许的操作列表 |
52+ | ` permissions.deny ` | string[ ] | 禁止的操作列表 |
53+
54+ ### 可选字段
55+
56+ | 字段 | 类型 | 描述 |
57+ | ------------------------ | ------- | ---------------------- |
58+ | ` model ` | object | 选择的模型配置 |
59+ | ` hasChangedDefaultModel ` | boolean | CLI 管理的模型覆盖标志 |
60+
61+ ## 配置示例
62+
63+ ### 基础配置
64+
65+ ** ~ /.cursor/cli-config.json**
2566
2667``` json
2768{
@@ -30,24 +71,49 @@ title: Cursor
3071 "vimMode" : false
3172 },
3273 "permissions" : {
33- "allow" : [" " ],
34- "deny" : [" " ]
35- },
36- "model" : {},
37- "hasChangedDefaultModel" : false
74+ "allow" : [" Shell(ls)" ],
75+ "deny" : []
76+ }
3877}
3978```
4079
41- ``` json title="cli.json"
80+ ### 启用 Vim 模式
81+
82+ ``` json
4283{
84+ "version" : 1 ,
85+ "editor" : {
86+ "vimMode" : true
87+ },
4388 "permissions" : {
44- "allow" : [" Shell(ls)" , " Shell(git) " , " Read(src/**/*.ts) " , " Write(package.json) " ],
45- "deny" : [" Shell(rm) " , " Read(.env*) " , " Write(**/*.key) " ]
89+ "allow" : [" Shell(ls)" ],
90+ "deny" : []
4691 }
4792}
4893```
4994
50- > 权限语法与 Claude Code 类似
95+ ### 项目级权限配置
96+
97+ ** .cursor/cli.json**
98+
99+ ``` json
100+ {
101+ "permissions" : {
102+ "allow" : [
103+ " Shell(ls)" ,
104+ " Shell(git)" ,
105+ " Shell(npm)" ,
106+ " Shell(pnpm)" ,
107+ " Read(src/**/*.ts)" ,
108+ " Read(src/**/*.tsx)" ,
109+ " Write(src/**/*.ts)" ,
110+ " Write(src/**/*.tsx)" ,
111+ " Write(package.json)"
112+ ],
113+ "deny" : [" Shell(rm)" , " Shell(rm -rf)" , " Read(.env*)" , " Read(**/*.key)" , " Read(**/*.pem)" , " Write(**/*.key)" ]
114+ }
115+ }
116+ ```
51117
52118# FAQ
53119
0 commit comments