Skip to content

Commit ca2e67f

Browse files
committed
refactor: 将 paths 从 secrets.json 分离至 config.json
1 parent 9b03602 commit ca2e67f

24 files changed

Lines changed: 163 additions & 140 deletions

‎.gitignore‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.DS_Store
22

3-
# env/: only secrets.json is gitignored.
3+
# env/: secrets.json (keys/tokens/urls) and config.json (path overrides) are gitignored.
44
# env/mcp/*.json and env/platforms/*.json are committed (use ${VAR} references, no real secrets).
5-
# User only needs to create env/secrets.json from env/secrets.json.example.
5+
# User creates env/secrets.json and (optionally) env/config.json from their .example templates.
66
env/secrets.json
7+
env/config.json
78
env/backup.json
89
# 可选 MCP 启用状态(本机本地状态,不提交;脚本缺失时自动重建为 {})
910
env/optional_mcps/enabled.json

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
git clone https://github.com/i-stack/ai-coding-kit.git
2020
cd ai-coding-kit
2121

22-
# 唯一需要编辑的文件
23-
cp env/secrets.json.example env/secrets.json
22+
# 初始化本地配置(从 env/*.example 模板创建缺失文件,幂等)
23+
bash install.sh
24+
25+
# 唯一需要编辑的文件:填入真实 API Keys / Tokens
2426
$EDITOR env/secrets.json
2527

2628
# 一键同步

‎env/README.md‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
```text
88
env/
9-
├── secrets.json ← 你唯一需要填写的文件(gitignored)
9+
├── secrets.json ← 密钥配置:key/token/url(gitignored)
1010
├── secrets.json.example ← 模板(已提交)
11+
├── config.json ← 非密钥配置:安装根/路径覆盖(gitignored,可选)
12+
├── config.json.example ← 模板(已提交)
1113
│
1214
├── review.json ← auto-code-review 配置(gitignored)
1315
├── review.json.example ← review 配置模板(已提交)
@@ -26,9 +28,7 @@ env/
2628
│ ├── shell.json
2729
│ ├── xcodebuild.json
2830
│ ├── lanhu.json
29-
│ ├── moonvy.json
30-
│ ├── postgres.json
31-
│ └── sqlite.json
31+
│ └── moonvy.json
3232
│
3333
├── optional_mcps/ ← 可选 MCP 服务器(需手动启用)
3434
│ ├── enabled.json ← 启用状态记录
@@ -88,7 +88,7 @@ env/
8888

8989
**加载优先级**:`env/review.json` → `.auto-review-config.json` → `AUTO_REVIEW_*` 环境变量。
9090

91-
复制 `review.json.example` 为 `review.json` 后填写即可。仅在用户显式启动 `/auto-review` 后加载。
91+
复制 `review.json.example` 为 `review.json` 后填写即可(`bash install.sh` 会一并从模板创建,无需手动 cp)。仅在用户显式启动 `/auto-review` 后加载。
9292

9393
## backup.json
9494

@@ -111,11 +111,16 @@ env/
111111
跨会话用户画像用于让 Codex / Claude / Gemini 等 Agent 在不同会话中共享你的稳定偏好、角色和约束。
112112

113113
```bash
114-
cp env/user-profile.md.example env/user-profile.md
115-
cp env/user-profile.json.example env/user-profile.json
116-
bash sync.sh
114+
bash install.sh # 创建 user-profile.json(enabled=auto);user-profile.md 不自动创建
115+
bash sync.sh # 同步(画像文件缺失时自动跳过)
117116
```
118117

118+
> `env/user-profile.md` 是含占位符的内容模板,`install.sh` 不会自动复制它,否则会被当成真实画像同步成假的全局用户画像。需要画像时再手动:
119+
>
120+
> ```bash
121+
> cp env/user-profile.md.example env/user-profile.md # 然后填写真实信息
122+
> ```
123+
119124
`env/user-profile.json`:
120125
121126
```json
@@ -175,7 +180,7 @@ bash sync/scripts/optional_mcps.sh disable puppeteer
175180

176181
各平台的安装根目录默认是 `~/.codex`、`~/.claude`、`~/.gemini` 等固定位置。
177182
如果某工具安装在非默认路径(例如自定义前缀、便携版、或 Xcode 的 CodingAssistant 目录被移动),
178-
可以在 `secrets.json` 顶层增加 `paths` 对象来覆盖:
183+
可以在 `config.json` 顶层增加 `paths` 对象来覆盖(`bash install.sh` 会自动从 `config.json.example` 创建该文件,也可手动 `cp env/config.json.example env/config.json`):
179184

180185
```json
181186
{
@@ -201,7 +206,7 @@ bash sync/scripts/optional_mcps.sh disable puppeteer
201206
- 设置后,该平台的所有派生路径(配置、settings、skills、MCP 文件等)都会基于覆盖值解析。
202207
- `cursor_project_roots` 是额外的 Cursor 项目根列表,用于同步项目内 `.cursor/rules/*.mdc`;也可用 `CURSOR_PROJECT_ROOTS="/path/a:/path/b"` 临时覆盖。
203208
- Codex 仍优先使用标准环境变量 `CODEX_HOME` / `CODEX_CONFIG`,其次才是此处覆盖。
204-
- `paths` 不是密钥,不会参与 `${...}` 占位符注入,仅用于路径解析。
209+
- `paths` 不是密钥,放在 `env/config.json`(gitignored 的本地配置),不会参与 `${...}` 占位符注入,仅用于路径解析。
205210

206211
## 占位符机制
207212

‎env/config.json.example‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
{
22
"_comment": "=== 非密钥的本地配置(路径/安装根覆盖)=== 复制为 env/config.json。此文件不是密钥,但含你本机路径,故也 gitignore,不提交。路径覆盖之外的非密钥配置也放这里。",
33
"paths": {
4-
"_comment": "可选:覆盖各 AI 工具的「安装根目录」。留空字符串或删除该键即使用默认路径(~/.codex、~/.claude 等)。当工具安装在非默认位置时(例如自定义前缀),在此填写绝对或 ~/ 开头的路径,所有派生路径都会基于此处解析。",
4+
"_comment": "可选:覆盖各 AI 工具的「安装根目录」。留空字符串或删除该键即使用默认路径(~/.codex、~/.claude 等)。当工具安装在非默认位置时(例如自定义前缀),在此填写绝对或 ~/ 开头的路径,所有派生路径都会基于此处解析。cursor_project_roots 留空数组 [] 表示不同步 Cursor 项目内 .cursor/rules;需要时填入如 [\"/Users/you/path/to/projA\", \"/Users/you/path/to/projB\"]。",
55
"codex": "",
66
"claude": "",
77
"gemini": "",
88
"codebuddy": "",
99
"cursor": "",
10-
"cursor_project_roots": [
11-
"/Users/you/path/to/projA",
12-
"/Users/you/path/to/projB"
13-
],
10+
"cursor_project_roots": [],
1411
"cline": "",
1512
"continue": "",
1613
"qwen": "",

‎env/mcp/postgres.json‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎env/mcp/sqlite.json‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎env/mcp/xcodebuild.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"mcp"
99
],
1010
"env": {
11-
"XCODEBUILDMCP_CWD": "${workspaceFolder}",
1211
"XCODEBUILDMCP_ENABLED_WORKFLOWS": "simulator,ui-automation,debugging,device"
1312
},
1413
"platforms": [

‎env/secrets.json.example‎

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"_comment": "=== 用户唯一需要配置的文件 === 复制为 env/secrets.json,每个平台填入你的 key/token 和 url。然后运行 bash sync.sh。",
2+
"_comment": "=== 密钥配置文件 === 复制为 env/secrets.json,每个平台填入你的 key/token 和 url(路径/安装根覆盖请放入 env/config.json)。然后运行 bash sync.sh。",
33
"github": {
44
"token": "ghp_your-github-personal-access-token"
55
},
@@ -30,30 +30,8 @@
3030
"url": "",
3131
"key": "sk-your-cline-gemini-api-key"
3232
},
33-
"postgres": {
34-
"connection_string": "postgresql://user:password@localhost:5432/your_database"
35-
},
36-
"sqlite": {
37-
"db_path": "./data/your_database.sqlite"
38-
},
3933
"qwen": {
4034
"url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
4135
"dashscopeApiKey": "sk-your-qwen-api-key"
42-
},
43-
"paths": {
44-
"_comment": "可选:覆盖各 AI 工具的「安装根目录」。留空字符串或删除该键即使用默认路径(~/.codex、~/.claude 等)。当工具安装在非默认位置时(例如自定义前缀),在此填写绝对或 ~/ 开头的路径,所有派生路径都会基于此处解析。",
45-
"codex": "",
46-
"claude": "",
47-
"gemini": "",
48-
"codebuddy": "",
49-
"cursor": "",
50-
"cursor_project_roots": [
51-
"/Users/you/path/to/projA",
52-
"/Users/you/path/to/projB"
53-
],
54-
"cline": "",
55-
"continue": "",
56-
"qwen": "",
57-
"xcode_coding_assistant": ""
5836
}
5937
}

‎install.sh‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
# ai-coding-kit 初始化脚本
44
#
55
# clone 项目后运行一次,完成本地配置初始化:
6-
# - 从 env/*.example 模板复制出缺失的本地配置文件
6+
# - 从 env/*.example 模板复制出缺失的本地配置(config/backup/review/secrets/user-profile.json)
77
# (幂等:目标已存在则跳过,绝不覆盖你已填好的真实配置)
8+
# - 不自动创建 user-profile.md:它是含占位符的「内容模板」,若自动复制会被
9+
# sync-user-profile.sh 当成真实画像同步成假的全局用户画像。需要画像时再手动
10+
# cp env/user-profile.md.example env/user-profile.md 并填写。
811
# - 提醒填写 env/secrets.json 中的真实 API Keys / Tokens
912
#
1013
# 用法:
@@ -32,6 +35,10 @@ shopt -s nullglob
3235
created=0
3336
for src in "$ENV_DIR"/*.example; do
3437
dst="${src%.example}"
38+
# user-profile.md 是含占位符的内容模板,不自动创建(避免假画像被同步)
39+
if [[ "$src" == */user-profile.md.example ]]; then
40+
continue
41+
fi
3542
if [ ! -e "$dst" ]; then
3643
cp "$src" "$dst"
3744
echo_ok "已创建 ${dst#$SCRIPT_DIR/}"

‎skills-engineering/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ SYNC_CLAUDE=0 SYNC_CODEX=0 SYNC_CURSOR=0 SYNC_XCODE_CODEX=0 SYNC_XCODE_CLAUDE=1
213213
CURSOR_PROJECT_ROOTS="/path/to/appA:/path/to/appB" ./scripts/sync-agent-preamble.sh
214214
```
215215

216-
也可以把外部 Cursor 项目根写进 `env/secrets.json` 的 `paths.cursor_project_roots`。命令行传入的 `CURSOR_PROJECT_ROOTS` 仍然优先,适合一次性覆盖。
216+
也可以把外部 Cursor 项目根写进 `env/config.json` 的 `paths.cursor_project_roots`。命令行传入的 `CURSOR_PROJECT_ROOTS` 仍然优先,适合一次性覆盖。
217217

218-
Claude / Codex 两端同样遵循 `SYNC_CLAUDE` / `SYNC_CODEX` 门控语义(`1 / 0 / 留空自动探测`);Cursor 项目规则由 `env/secrets.json` 的 `paths.cursor_project_roots` 或临时 `CURSOR_PROJECT_ROOTS` 决定,不复用 `SYNC_CURSOR`。
218+
Claude / Codex 两端同样遵循 `SYNC_CLAUDE` / `SYNC_CODEX` 门控语义(`1 / 0 / 留空自动探测`);Cursor 项目规则由 `env/config.json` 的 `paths.cursor_project_roots` 或临时 `CURSOR_PROJECT_ROOTS` 决定,不复用 `SYNC_CURSOR`。
219219
Xcode Codex / Claude 侧分别遵循 `SYNC_XCODE_CODEX` / `SYNC_XCODE_CLAUDE` 门控语义(`1 / 0 / 留空自动探测`),默认写入 `codex/AGENTS.md` 与 `ClaudeAgentConfig/CLAUDE.md`。
220220

221221
脚本只重写 `<!-- managed-block:agent-preamble:begin ... :end -->` 托管块(并兼容迁移旧的 `ios-engineer` 托管块标记),保留文件中的其他内容。
@@ -252,7 +252,7 @@ curl -fsSL https://raw.githubusercontent.com/i-stack/ai-coding-kit/main/skills-e
252252
- `SKIP_PREAMBLE=true`:跳过 `sync-agent-preamble.sh`
253253
- `SKIP_USER_PROFILE=true`:跳过 `sync-user-profile.sh`(跨会话用户画像)
254254
- `SKIP_MEMORY=true`:跳过 `sync-memory.sh`(跨会话事件记忆)
255-
- `CURSOR_PROJECT_ROOTS`:临时覆盖 `env/secrets.json` 的 `paths.cursor_project_roots`,透传给 `sync-agent-preamble.sh`
255+
- `CURSOR_PROJECT_ROOTS`:临时覆盖 `env/config.json` 的 `paths.cursor_project_roots`,透传给 `sync-agent-preamble.sh`
256256

257257
### 5. 跨会话记忆(用户画像 + 事件记忆)
258258

0 commit comments

Comments
 (0)