@mison/wecom-cleaner 1.0.0 → 1.1.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/README.md CHANGED
@@ -23,6 +23,7 @@
23
23
  - [功能总览](#功能总览)
24
24
  - [能力边界](#能力边界)
25
25
  - [安装与运行](#安装与运行)
26
+ - [Agent Skills 安装](#agent-skills-安装)
26
27
  - [常用参数](#常用参数)
27
28
  - [数据与审计文件](#数据与审计文件)
28
29
  - [开发与质量门禁](#开发与质量门禁)
@@ -63,7 +64,7 @@
63
64
  2. 文件存储目录识别
64
65
 
65
66
  - 支持默认路径、手动配置路径、自动探测路径。
66
- - 自动探测采用结构匹配(如 `*/WXWork Files/Caches`),不依赖目录名。
67
+ - 自动探测采用“结构 + 缓存特征”联合识别(如 `*/WXWork Files/Caches` + 企业微信缓存类别/月目录信号),不依赖目录名且降低误判。
67
68
  - 自动探测结果默认不预选,需用户确认后纳入处理。
68
69
 
69
70
  3. 删除与恢复链路
@@ -86,9 +87,9 @@
86
87
 
87
88
  6. 可观测性与并发安全
88
89
 
89
- - `doctor` 模式可输出人类可读报告,或通过 `--json` 输出结构化结果。
90
+ - `doctor` 模式可输出人类可读报告,或通过 `--output json` 输出结构化结果。
90
91
  - `doctor` 模式为只读体检:不会自动创建状态目录/回收区,也不会触发 Zig 自动修复下载。
91
- - 多实例并发默认加锁,检测到陈旧锁可交互清理或通过 `--force` 自动清理。
92
+ - 多实例并发默认加锁;检测到陈旧锁会优先自动恢复,异常场景可用 `--force` 兜底清理。
92
93
 
93
94
  ## 能力边界
94
95
 
@@ -128,32 +129,117 @@ npm run e2e:smoke
128
129
  - 覆盖开始菜单与关键分支:年月清理、会话分析、全量治理、回收区治理、恢复、系统自检、设置。
129
130
  - 可用 `npm run e2e:smoke -- --keep` 保留日志与测试目录。
130
131
 
132
+ ## Agent Skills 安装
133
+
134
+ 内置技能:`wecom-cleaner-agent`(用于 Codex/Agent 无交互调用)。
135
+
136
+ 推荐方式(npmjs,最稳定):
137
+
138
+ ```bash
139
+ npx --yes --package=@mison/wecom-cleaner wecom-cleaner-skill install
140
+ ```
141
+
142
+ 常用参数:
143
+
144
+ - `--target <dir>`:自定义安装目录(默认 `$CODEX_HOME/skills` 或 `~/.codex/skills`)
145
+ - `--force`:覆盖已存在技能目录
146
+ - `--dry-run`:仅预演,不落盘
147
+
148
+ 示例:
149
+
150
+ ```bash
151
+ npx --yes --package=@mison/wecom-cleaner wecom-cleaner-skill install --force
152
+ npx --yes --package=@mison/wecom-cleaner wecom-cleaner-skill install --target ~/.codex/skills
153
+ ```
154
+
155
+ GitHub 备选方式(无 npm 包依赖):
156
+
157
+ ```bash
158
+ curl -fsSL https://raw.githubusercontent.com/MisonL/wecom-cleaner/main/scripts/install-skill.sh | bash
159
+ ```
160
+
161
+ 若需安装指定版本标签(例如 `v1.1.0`):
162
+
163
+ ```bash
164
+ curl -fsSL https://raw.githubusercontent.com/MisonL/wecom-cleaner/main/scripts/install-skill.sh | bash -s -- --ref v1.1.0
165
+ ```
166
+
131
167
  ## 常用参数
132
168
 
169
+ 运行方式:
170
+
171
+ - 不带参数:进入交互菜单(TUI)。
172
+ - 带参数:进入无交互执行(默认输出 JSON,适合 AI Agent)。
173
+ - 带参数但需交互:可追加 `--interactive` 强制进入交互流程(支持配合 `--mode` 直达功能)。
174
+ - 完整契约文档:[`docs/NON_INTERACTIVE_SPEC.md`](./docs/NON_INTERACTIVE_SPEC.md)。
175
+
176
+ ### 无交互动作参数(互斥,必须且只能一个)
177
+
178
+ - `--cleanup-monthly`
179
+ - `--analysis-only`
180
+ - `--space-governance`
181
+ - `--restore-batch <batchId>`
182
+ - `--recycle-maintain`
183
+ - `--doctor`
184
+
185
+ ### 无交互安全规则
186
+
187
+ - 破坏性动作(清理/治理/恢复/回收区治理)默认 `dry-run`。
188
+ - 显式真实执行需带 `--yes`。
189
+ - 若传 `--dry-run false` 但未传 `--yes`,将直接退出(退出码 `3`)。
190
+
191
+ ### 常用无交互示例
192
+
133
193
  ```bash
134
- wecom-cleaner --root ~/Library/Containers/com.tencent.WeWorkMac/Data/Documents/Profiles
135
- wecom-cleaner --state-root ~/.wecom-cleaner-state
136
- wecom-cleaner --external-storage-root /Volumes/Data/MyWeComStorage
137
- wecom-cleaner --external-storage-auto-detect false
138
- wecom-cleaner --dry-run-default true
139
- wecom-cleaner --mode cleanup_monthly
140
- wecom-cleaner --mode space_governance
141
- wecom-cleaner --mode recycle_maintain
142
- wecom-cleaner --mode doctor
143
- wecom-cleaner --theme auto
144
- wecom-cleaner --json
145
- wecom-cleaner --force
194
+ # 年月清理(默认 dry-run)
195
+ wecom-cleaner --cleanup-monthly \
196
+ --accounts current \
197
+ --cutoff-month 2024-02 \
198
+ --categories files,images
199
+
200
+ # 年月清理(真实执行)
201
+ wecom-cleaner --cleanup-monthly \
202
+ --accounts all \
203
+ --months 2023-01,2023-02 \
204
+ --categories files \
205
+ --dry-run false \
206
+ --yes
207
+
208
+ # 全量空间治理(仅建议项,真实执行)
209
+ wecom-cleaner --space-governance \
210
+ --suggested-only true \
211
+ --tiers safe,caution \
212
+ --dry-run false \
213
+ --yes
214
+
215
+ # 回收区治理(按策略执行)
216
+ wecom-cleaner --recycle-maintain --dry-run false --yes
217
+
218
+ # 批次恢复(冲突策略:重命名)
219
+ wecom-cleaner --restore-batch 20260226-105009-ffa098 --conflict rename
220
+
221
+ # 系统自检(默认 JSON 输出)
222
+ wecom-cleaner --doctor
146
223
  ```
147
224
 
148
- ### `--mode` 可选值
225
+ ### 输出与兼容参数
226
+
227
+ - `--output json|text`:无交互输出格式,默认 `json`。
228
+ - `--json`:兼容别名,等价于 `--output json`。
229
+ - `--mode`:兼容参数,建议迁移到动作参数(如 `--cleanup-monthly`)。
230
+ - `--save-config`:将本次全局配置参数写回 `config.json`。
231
+
232
+ ### 全局参数
149
233
 
150
- - `cleanup_monthly`
151
- - `analysis_only`
152
- - `space_governance`
153
- - `recycle_maintain`
154
- - `restore`
155
- - `doctor`
156
- - `settings`
234
+ - `--root <path>`:Profile 根目录
235
+ - `--state-root <path>`:状态目录
236
+ - `--external-storage-root <path[,path...]>`:手动文件存储目录(配置层)
237
+ - `--external-storage-auto-detect <true|false>`:外部存储自动探测总开关
238
+ - `--external-roots <path[,path...]>`:本次动作临时覆盖的文件存储目录
239
+ - `--external-roots-source <preset|configured|auto|all>`:按来源筛选探测目录(默认 `preset`)
240
+ - `--theme <auto|light|dark>`:Logo 主题
241
+ - `--interactive`:即使携带参数也进入交互流程(可配合 `--mode`)
242
+ - `--force`:锁异常场景下强制清理并继续(兜底参数,通常无需)
157
243
 
158
244
  ### `--theme` 可选值
159
245
 
@@ -233,10 +319,10 @@ npm run e2e:smoke -- --keep
233
319
  npm run pack:tgz:dry-run
234
320
  ```
235
321
 
236
- 当前基线(`v1.0.0`):
322
+ 当前基线(`v1.1.0`):
237
323
 
238
- - 单元测试:`47/47` 通过。
239
- - 覆盖率:`statements 85.65%`,`branches 70.99%`,`functions 91.39%`,`lines 85.65%`。
324
+ - 单元测试:`68/68` 通过。
325
+ - 覆盖率:`statements 86.57%`,`branches 73.96%`,`functions 93.25%`,`lines 86.57%`。
240
326
  - 全菜单 smoke:通过(含恢复冲突分支与 doctor JSON 分支)。
241
327
 
242
328
  ## 发布与打包
@@ -271,14 +357,14 @@ npm run pack:tgz
271
357
 
272
358
  # 2) 推送主分支与标签
273
359
  git push origin main
274
- git tag v1.0.0
275
- git push origin v1.0.0
360
+ git tag v1.1.0
361
+ git push origin v1.1.0
276
362
 
277
363
  # 3) 发布 GitHub Release(附 tgz 包)
278
- gh release create v1.0.0 \
279
- --title "v1.0.0" \
280
- --notes-file docs/releases/v1.0.0.md \
281
- wecom-cleaner-1.0.0.tgz
364
+ gh release create v1.1.0 \
365
+ --title "v1.1.0" \
366
+ --notes-file docs/releases/v1.1.0.md \
367
+ wecom-cleaner-1.1.0.tgz
282
368
 
283
369
  # 4) 发布 npm
284
370
  npm publish --access public
@@ -122,7 +122,7 @@
122
122
  - 使用 `c8` 输出覆盖率报告。
123
123
  - 门禁阈值:`lines/statements >= 75%`,`functions >= 80%`,`branches >= 60%`。
124
124
  - 命令:`npm run test:coverage` / `npm run test:coverage:check`。
125
- - `v1.0.0` 基线:`statements 85.65%`,`branches 70.99%`,`functions 91.39%`,`lines 85.65%`。
125
+ - `v1.1.0` 基线:`statements 86.57%`,`branches 73.96%`,`functions 93.25%`,`lines 86.57%`。
126
126
 
127
127
  4. 端到端回归
128
128
 
@@ -138,21 +138,21 @@ npm run e2e:smoke -- --keep
138
138
  npm run pack:tgz:dry-run
139
139
  ```
140
140
 
141
- ## 7. 发布执行(首个正式版)
141
+ ## 7. 发布执行(当前版本)
142
142
 
143
143
  1. 版本与产物
144
144
 
145
- - `package.json` / `package-lock.json`:`1.0.0`
146
- - `native/manifest.json`:版本与 `baseUrl` 对齐 `v1.0.0`
145
+ - `package.json` / `package-lock.json`:`1.1.0`
146
+ - `native/manifest.json`:版本与 `baseUrl` 对齐 `v1.1.0`
147
147
  - 默认打包双架构核心:`darwin-x64` + `darwin-arm64`
148
148
 
149
149
  2. GitHub Release
150
150
 
151
151
  ```bash
152
152
  git push origin main
153
- git tag v1.0.0
154
- git push origin v1.0.0
155
- gh release create v1.0.0 --title "v1.0.0" --notes-file docs/releases/v1.0.0.md wecom-cleaner-1.0.0.tgz
153
+ git tag v1.1.0
154
+ git push origin v1.1.0
155
+ gh release create v1.1.0 --title "v1.1.0" --notes-file docs/releases/v1.1.0.md wecom-cleaner-1.1.0.tgz
156
156
  ```
157
157
 
158
158
  3. npm 发布
@@ -0,0 +1,115 @@
1
+ # 无交互参数规范(AI Agent)
2
+
3
+ 本文档定义 `wecom-cleaner` 的无交互 CLI 契约,供 AI Agent/脚本稳定调用。
4
+
5
+ ## 1. 运行入口
6
+
7
+ - `wecom-cleaner`(不带参数):进入交互模式(TUI)。
8
+ - `wecom-cleaner ...args`(带参数):进入无交互模式。
9
+ - `wecom-cleaner ...args --interactive`:即使带参数也强制进入交互模式(常用于本地调试/脚本回放)。
10
+
11
+ ## 2. 动作选择(必填且互斥)
12
+
13
+ 无交互模式必须且只能提供一个动作参数:
14
+
15
+ - `--cleanup-monthly`
16
+ - `--analysis-only`
17
+ - `--space-governance`
18
+ - `--restore-batch <batchId>`
19
+ - `--recycle-maintain`
20
+ - `--doctor`
21
+
22
+ 若缺少动作或动作冲突,退出码为 `2`。
23
+
24
+ ## 3. 安全确认与 dry-run
25
+
26
+ 破坏性动作:`cleanup-monthly`、`space-governance`、`restore-batch`、`recycle-maintain`。
27
+
28
+ 规则:
29
+
30
+ - 默认 `dry-run`(不执行真实删除/恢复)。
31
+ - 真实执行需显式传 `--yes`。
32
+ - 若传 `--dry-run false` 且未传 `--yes`,退出码为 `3`。
33
+
34
+ ## 4. 输出协议
35
+
36
+ 无交互默认输出 JSON,可通过 `--output text` 切换文本。
37
+
38
+ - `--output json|text`(默认 `json`)
39
+ - `--json` 为兼容别名(等价 `--output json`)
40
+
41
+ JSON 顶层字段:
42
+
43
+ - `ok`:布尔
44
+ - `action`:动作名
45
+ - `dryRun`:布尔或 `null`
46
+ - `summary`:动作摘要
47
+ - `warnings`:字符串数组
48
+ - `errors`:错误数组(`code`、`message`、可选路径字段)
49
+ - `data`:动作明细数据
50
+ - `meta`:元信息(版本、耗时、引擎、时间戳等)
51
+
52
+ ## 5. 退出码
53
+
54
+ - `0`:执行成功(含 dry-run 成功)
55
+ - `1`:执行失败(业务失败/运行失败)
56
+ - `2`:参数错误或动作契约错误
57
+ - `3`:缺少真实执行确认(`--yes`)
58
+
59
+ ## 6. 全局参数
60
+
61
+ - `--root <path>`:Profile 根目录
62
+ - `--state-root <path>`:状态目录
63
+ - `--external-storage-root <path[,path...]>`:配置层手动文件存储目录
64
+ - `--external-storage-auto-detect <true|false>`:自动探测开关
65
+ - `--external-roots <path[,path...]>`:动作层临时覆盖文件存储目录
66
+ - `--external-roots-source <preset|configured|auto|all>`:按来源筛选探测目录(默认 `preset`)
67
+ - `--theme <auto|light|dark>`
68
+ - `--interactive`:强制交互模式(与无交互动作参数互斥使用时,优先按交互模式执行)
69
+ - `--force`:锁异常场景下强制清理并继续(兜底参数)
70
+ - `--save-config`:把本次全局参数落盘到 `config.json`
71
+
72
+ ## 7. 动作参数
73
+
74
+ ### 7.1 `--cleanup-monthly`
75
+
76
+ - `--accounts <all|current|id1,id2...>`
77
+ - `--months <YYYY-MM,...>` 或 `--cutoff-month <YYYY-MM>`(二选一)
78
+ - `--categories <all|key1,key2...>`
79
+ - `--include-non-month-dirs <true|false>`
80
+ - `--dry-run <true|false>`
81
+
82
+ ### 7.2 `--analysis-only`
83
+
84
+ - `--accounts <all|current|id1,id2...>`
85
+ - `--categories <all|key1,key2...>`
86
+
87
+ ### 7.3 `--space-governance`
88
+
89
+ - `--accounts <all|current|id1,id2...>`
90
+ - `--targets <targetId1,targetId2...>`
91
+ - `--tiers <safe|caution|protected>`
92
+ - `--suggested-only <true|false>`
93
+ - `--allow-recent-active <true|false>`
94
+ - `--dry-run <true|false>`
95
+
96
+ ### 7.4 `--restore-batch <batchId>`
97
+
98
+ - `--conflict <skip|overwrite|rename>`(默认 `skip`)
99
+ - `--dry-run <true|false>`
100
+
101
+ ### 7.5 `--recycle-maintain`
102
+
103
+ - `--retention-enabled <true|false>`
104
+ - `--retention-max-age-days <int>`
105
+ - `--retention-min-keep-batches <int>`
106
+ - `--retention-size-threshold-gb <int>`
107
+ - `--dry-run <true|false>`
108
+
109
+ ### 7.6 `--doctor`
110
+
111
+ - 无动作专属参数;只读执行,返回健康报告。
112
+
113
+ ## 8. 兼容参数
114
+
115
+ - `--mode`:兼容旧调用,会映射到动作参数并附带 warning,建议迁移。
@@ -0,0 +1,36 @@
1
+ # wecom-cleaner v1.1.0
2
+
3
+ 本版本重点是:Agent 可安装技能能力正式内置、无交互调用链路更稳定、发布与验证流程完整收口。
4
+
5
+ ## 新增能力
6
+
7
+ - 内置 Agent 技能:`skills/wecom-cleaner-agent`
8
+ - 包含 `SKILL.md`、`agents/openai.yaml`、`references/commands.md`
9
+ - 新增技能安装命令:`wecom-cleaner-skill install`
10
+ - 支持 `--target`、`--force`、`--dry-run`
11
+ - 新增 GitHub 一键安装脚本:`scripts/install-skill.sh`
12
+
13
+ ## 关键改进
14
+
15
+ - 无交互协议正式化并文档化:`docs/NON_INTERACTIVE_SPEC.md`
16
+ - 启动行为统一:无参数进交互、带参数走无交互
17
+ - 无交互默认 JSON 输出,兼容 `--json`,并提示 `--mode` 迁移
18
+ - Zig 核心版本统一到 `1.1.0`,manifest 与下载基地址同步到 `v1.1.0`
19
+
20
+ ## 修复与安全
21
+
22
+ - 修复恢复 `dry-run + overwrite` 分支潜在实删问题
23
+ - 修复回收区治理异常批次路径可能越界的问题
24
+ - `scripts/install-skill.sh` 兼容 `--target` 指向不存在父目录
25
+ - 强化路径白名单 + `realpath` 边界防护与审计落盘
26
+
27
+ ## 质量与验证
28
+
29
+ - 单元测试:`68/68` 通过
30
+ - 覆盖率:`statements 86.57%`,`branches 73.96%`,`functions 93.25%`,`lines 86.57%`
31
+ - 全菜单 smoke:通过(含恢复冲突分支、doctor JSON、设置菜单)
32
+
33
+ ## 兼容性
34
+
35
+ - 当前正式支持:macOS(x64 / arm64)
36
+ - Windows 兼容仍在后续版本规划中
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "version": "1.0.0",
4
- "baseUrl": "https://raw.githubusercontent.com/MisonL/wecom-cleaner/v1.0.0/native/bin",
3
+ "version": "1.1.0",
4
+ "baseUrl": "https://raw.githubusercontent.com/MisonL/wecom-cleaner/v1.1.0/native/bin",
5
5
  "targets": {
6
6
  "darwin-x64": {
7
7
  "binaryName": "wecom-cleaner-core",
8
- "sha256": "14cfa26895101e7b71824e6bb9282f08a38f9dad72d4df2934094eb2ceefbad0"
8
+ "sha256": "d6bc4b2a7b96010889fc11502fe6d76d6f8d395e6df12c44dfc79aa58b17d53c"
9
9
  },
10
10
  "darwin-arm64": {
11
11
  "binaryName": "wecom-cleaner-core",
12
- "sha256": "fc33ce3fb44309170da8c2867d11eae552e2e9d3c95b8f0e5a8e8392bb630744"
12
+ "sha256": "f3babdfe69e83c2d0b99fe1ad525ea836e4f413c01ae2f31b569e35f2ba955f8"
13
13
  }
14
14
  }
15
15
  }
@@ -56,7 +56,7 @@ fn dirTreeSize(dir: *std.fs.Dir) !u64 {
56
56
  }
57
57
 
58
58
  fn printPing(writer: *std.Io.Writer) !void {
59
- try writer.writeAll("{\"ok\":true,\"engine\":\"zig\",\"version\":\"1.0.0\"}\n");
59
+ try writer.writeAll("{\"ok\":true,\"engine\":\"zig\",\"version\":\"1.1.0\"}\n");
60
60
  }
61
61
 
62
62
  fn runDu(args: []const []const u8, writer: *std.Io.Writer) !void {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mison/wecom-cleaner",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "企业微信本地聊天缓存清理工具(交互式 CLI/TUI)",
5
5
  "author": "MisonL",
6
6
  "license": "MIT",
@@ -14,11 +14,13 @@
14
14
  "homepage": "https://github.com/MisonL/wecom-cleaner",
15
15
  "type": "module",
16
16
  "bin": {
17
- "wecom-cleaner": "./src/cli.js"
17
+ "wecom-cleaner": "src/cli.js",
18
+ "wecom-cleaner-skill": "src/skill-cli.js"
18
19
  },
19
20
  "main": "./src/cli.js",
20
21
  "files": [
21
22
  "src",
23
+ "skills",
22
24
  "native",
23
25
  "README.md",
24
26
  "LICENSE",
@@ -43,7 +45,9 @@
43
45
  "e2e:smoke": "bash scripts/e2e-smoke.sh",
44
46
  "prepack": "npm run build:native:release && npm run check",
45
47
  "pack:tgz": "node scripts/pack-tgz.js",
46
- "pack:tgz:dry-run": "node scripts/pack-tgz.js --dry-run"
48
+ "pack:tgz:dry-run": "node scripts/pack-tgz.js --dry-run",
49
+ "skill:install": "node src/skill-cli.js install",
50
+ "skill:path": "node src/skill-cli.js path"
47
51
  },
48
52
  "keywords": [
49
53
  "wecom",
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: wecom-cleaner-agent
3
+ description: 用于执行和编排 wecom-cleaner 的无交互 Agent 技能。当任务涉及企业微信缓存盘点、年月清理、全量空间治理、批次恢复、回收区治理或系统自检,并要求 JSON 输出解析与 dry-run 安全门槛时触发。
4
+ ---
5
+
6
+ # wecom-cleaner-agent
7
+
8
+ ## 何时触发
9
+
10
+ - 用户要清理企业微信本地缓存,且希望由 Agent 自动执行。
11
+ - 用户要走无交互 CLI,返回可机读 JSON 结果。
12
+ - 用户要执行以下任一能力:盘点、年月清理、全量治理、批次恢复、回收区治理、系统自检。
13
+
14
+ ## 默认执行策略
15
+
16
+ 1. 优先无交互模式,不进入 TUI。
17
+ 2. 先执行 `--doctor --output json` 做只读体检。
18
+ 3. 每次调用必须且只能提供一个动作参数。
19
+ 4. 破坏性动作先 dry-run,再根据用户确认决定真实执行。
20
+ 5. 每次执行都使用 `--output json`,按字段解析结果并汇报。
21
+
22
+ ## 动作契约
23
+
24
+ 无交互模式只能选一个动作:
25
+
26
+ - `--cleanup-monthly`
27
+ - `--analysis-only`
28
+ - `--space-governance`
29
+ - `--restore-batch <batchId>`
30
+ - `--recycle-maintain`
31
+ - `--doctor`
32
+
33
+ 退出码约定:
34
+
35
+ - `0` 成功
36
+ - `1` 业务失败或运行失败
37
+ - `2` 参数错误或动作冲突
38
+ - `3` 请求真实执行但缺少 `--yes`
39
+
40
+ ## 安全门槛
41
+
42
+ - 未获明确授权前,不执行真实删除或真实恢复。
43
+ - `cleanup-monthly`、`space-governance`、`restore-batch`、`recycle-maintain` 默认保持 dry-run。
44
+ - 真实执行必须同时满足:
45
+ - 用户明确同意
46
+ - 命令显式携带 `--dry-run false --yes`
47
+ - 已确认处理范围(账号、月份/目标、类别、目录来源)
48
+
49
+ ## 输出解析规则
50
+
51
+ - 必须使用 `--output json`。
52
+ - 重点字段:
53
+ - `ok`:是否成功
54
+ - `action`:执行动作
55
+ - `dryRun`:是否预演
56
+ - `summary`:核心统计
57
+ - `warnings`:兼容或降级提示
58
+ - `errors`:错误详情(`code/message/path`)
59
+ - `meta`:版本、耗时、引擎
60
+ - 判定逻辑:
61
+ - `ok=true`:输出关键统计并进入下一步
62
+ - `ok=false`:先汇总 `errors`,再给出修复后重试策略
63
+ - `warnings` 包含引擎回退时:标记为非阻塞风险并继续
64
+
65
+ ## 交互模式原则
66
+
67
+ - 默认不使用 `--interactive`。
68
+ - 仅当用户明确要求交互演示或人工选择时,才进入交互模式。
69
+
70
+ ## 参考资料
71
+
72
+ - 常用命令模板:`references/commands.md`
@@ -0,0 +1,5 @@
1
+ interface:
2
+ display_name: 'WeCom Cleaner Agent'
3
+ short_description: '面向AI Agent的企业微信缓存清理与恢复无交互执行技能'
4
+ default_prompt: '请使用 $wecom-cleaner-agent 对企业微信缓存执行一次先 dry-run 再确认执行的无交互清理流程。'
5
+ brand_color: '#0EA5E9'
@@ -0,0 +1,140 @@
1
+ # wecom-cleaner 命令参考(Agent)
2
+
3
+ ## 1. 路径变量
4
+
5
+ 建议先在执行环境准备变量:
6
+
7
+ ```bash
8
+ ROOT="/Users/<name>/Library/Containers/com.tencent.WeWorkMac/Data/Documents/Profiles"
9
+ STATE="$HOME/.wecom-cleaner-state"
10
+ ```
11
+
12
+ 如需显式指定外部文件存储目录:
13
+
14
+ ```bash
15
+ EXT="/Volumes/Data/WXWork_Data"
16
+ ```
17
+
18
+ ## 2. 只读动作
19
+
20
+ 系统体检:
21
+
22
+ ```bash
23
+ wecom-cleaner --doctor --output json --root "$ROOT" --state-root "$STATE"
24
+ ```
25
+
26
+ 缓存盘点(按账号/类型):
27
+
28
+ ```bash
29
+ wecom-cleaner --analysis-only \
30
+ --accounts current \
31
+ --categories files,images,videos \
32
+ --output json \
33
+ --root "$ROOT" --state-root "$STATE"
34
+ ```
35
+
36
+ ## 3. 年月清理(先 dry-run)
37
+
38
+ ```bash
39
+ wecom-cleaner --cleanup-monthly \
40
+ --accounts all \
41
+ --cutoff-month 2024-02 \
42
+ --categories files,images \
43
+ --include-non-month-dirs false \
44
+ --output json \
45
+ --root "$ROOT" --state-root "$STATE"
46
+ ```
47
+
48
+ 真实执行(仅用户明确授权后):
49
+
50
+ ```bash
51
+ wecom-cleaner --cleanup-monthly \
52
+ --accounts all \
53
+ --months 2023-01,2023-02 \
54
+ --categories files \
55
+ --dry-run false \
56
+ --yes \
57
+ --output json \
58
+ --root "$ROOT" --state-root "$STATE"
59
+ ```
60
+
61
+ ## 4. 全量空间治理(先 dry-run)
62
+
63
+ ```bash
64
+ wecom-cleaner --space-governance \
65
+ --suggested-only true \
66
+ --tiers safe,caution \
67
+ --allow-recent-active false \
68
+ --output json \
69
+ --root "$ROOT" --state-root "$STATE"
70
+ ```
71
+
72
+ 真实执行:
73
+
74
+ ```bash
75
+ wecom-cleaner --space-governance \
76
+ --targets <target1,target2> \
77
+ --dry-run false \
78
+ --yes \
79
+ --output json \
80
+ --root "$ROOT" --state-root "$STATE"
81
+ ```
82
+
83
+ ## 5. 批次恢复
84
+
85
+ 先查可恢复批次(通过审计或先执行 `--doctor`/`--analysis-only` 获取上下文),再恢复:
86
+
87
+ ```bash
88
+ wecom-cleaner --restore-batch <batchId> \
89
+ --conflict rename \
90
+ --output json \
91
+ --root "$ROOT" --state-root "$STATE"
92
+ ```
93
+
94
+ 真实恢复:
95
+
96
+ ```bash
97
+ wecom-cleaner --restore-batch <batchId> \
98
+ --conflict overwrite \
99
+ --dry-run false \
100
+ --yes \
101
+ --output json \
102
+ --root "$ROOT" --state-root "$STATE"
103
+ ```
104
+
105
+ ## 6. 回收区治理
106
+
107
+ ```bash
108
+ wecom-cleaner --recycle-maintain \
109
+ --retention-enabled true \
110
+ --retention-max-age-days 30 \
111
+ --retention-min-keep-batches 20 \
112
+ --retention-size-threshold-gb 20 \
113
+ --output json \
114
+ --root "$ROOT" --state-root "$STATE"
115
+ ```
116
+
117
+ 真实治理:
118
+
119
+ ```bash
120
+ wecom-cleaner --recycle-maintain \
121
+ --retention-enabled true \
122
+ --dry-run false \
123
+ --yes \
124
+ --output json \
125
+ --root "$ROOT" --state-root "$STATE"
126
+ ```
127
+
128
+ ## 7. 输出解析要点
129
+
130
+ - 成功判定:`ok == true`
131
+ - 失败详情:`errors[]`
132
+ - 核心统计:`summary`(如 `successCount/skippedCount/failedCount/reclaimedBytes`)
133
+ - 执行引擎:`meta.engine`
134
+
135
+ ## 8. 常见失败与处理
136
+
137
+ - 退出码 `2`:动作参数冲突或缺失,检查是否只给了一个动作参数。
138
+ - 退出码 `3`:缺少真实执行确认,补 `--yes` 或回退到 dry-run。
139
+ - `errors.code=path_validation_failed`:路径越界/白名单不匹配,核对 `--root` 与目录范围。
140
+ - `errors.code=permission_denied`:权限不足,调整目录权限后重试。