@awiki/cli 0.0.1-beta.2

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.
Files changed (119) hide show
  1. package/.github/workflows/release.yml +44 -0
  2. package/.goreleaser.yml +44 -0
  3. package/AGENTS.md +60 -0
  4. package/CLAUDE.md +192 -0
  5. package/README.md +2 -0
  6. package/docs/architecture/awiki-command-v2.md +955 -0
  7. package/docs/architecture/awiki-skill-architecture.md +475 -0
  8. package/docs/architecture/awiki-v2-architecture.md +1063 -0
  9. package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/cli-init.md +1008 -0
  10. package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/output-format.md +407 -0
  11. package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/overall-init.md +741 -0
  12. package/docs/harness/review-spec.md +474 -0
  13. package/docs/installation.md +372 -0
  14. package/docs/plan/awiki-v2-implementation-plan.md +903 -0
  15. package/docs/plan/phase-0/adr-index.md +56 -0
  16. package/docs/plan/phase-0/audit-findings.md +251 -0
  17. package/docs/plan/phase-0/capability-mapping.md +108 -0
  18. package/docs/plan/phase-0/implementation-constraints.md +363 -0
  19. package/docs/publish.md +169 -0
  20. package/go.mod +29 -0
  21. package/go.sum +73 -0
  22. package/internal/anpsdk/registry.go +63 -0
  23. package/internal/authsdk/session.go +351 -0
  24. package/internal/buildinfo/buildinfo.go +34 -0
  25. package/internal/cli/app.go +136 -0
  26. package/internal/cli/app_test.go +88 -0
  27. package/internal/cli/debug.go +104 -0
  28. package/internal/cli/group.go +263 -0
  29. package/internal/cli/id.go +473 -0
  30. package/internal/cli/init.go +134 -0
  31. package/internal/cli/msg.go +228 -0
  32. package/internal/cli/page.go +267 -0
  33. package/internal/cli/root.go +499 -0
  34. package/internal/cli/runtime.go +232 -0
  35. package/internal/cli/upgrade.go +60 -0
  36. package/internal/cmdmeta/catalog.go +203 -0
  37. package/internal/cmdmeta/catalog_test.go +21 -0
  38. package/internal/config/config.go +399 -0
  39. package/internal/config/config_test.go +104 -0
  40. package/internal/config/write.go +37 -0
  41. package/internal/content/service.go +314 -0
  42. package/internal/content/service_test.go +165 -0
  43. package/internal/content/types.go +44 -0
  44. package/internal/docs/topics.go +110 -0
  45. package/internal/doctor/doctor.go +306 -0
  46. package/internal/identity/client.go +267 -0
  47. package/internal/identity/did.go +85 -0
  48. package/internal/identity/did_test.go +50 -0
  49. package/internal/identity/layout.go +206 -0
  50. package/internal/identity/legacy.go +378 -0
  51. package/internal/identity/public.go +70 -0
  52. package/internal/identity/public_test.go +73 -0
  53. package/internal/identity/readiness.go +74 -0
  54. package/internal/identity/service.go +826 -0
  55. package/internal/identity/store.go +385 -0
  56. package/internal/identity/store_test.go +180 -0
  57. package/internal/identity/types.go +204 -0
  58. package/internal/message/auth.go +167 -0
  59. package/internal/message/group_service.go +838 -0
  60. package/internal/message/group_wire.go +350 -0
  61. package/internal/message/group_wire_test.go +67 -0
  62. package/internal/message/helpers.go +61 -0
  63. package/internal/message/http_client.go +334 -0
  64. package/internal/message/proof.go +156 -0
  65. package/internal/message/proof_test.go +61 -0
  66. package/internal/message/service.go +696 -0
  67. package/internal/message/service_test.go +97 -0
  68. package/internal/message/types.go +155 -0
  69. package/internal/message/wire.go +100 -0
  70. package/internal/message/wire_test.go +49 -0
  71. package/internal/message/ws_proxy_client.go +151 -0
  72. package/internal/output/output.go +350 -0
  73. package/internal/output/output_test.go +48 -0
  74. package/internal/runtime/config.go +117 -0
  75. package/internal/runtime/config_test.go +46 -0
  76. package/internal/runtime/listener/files.go +65 -0
  77. package/internal/runtime/listener/manager.go +142 -0
  78. package/internal/runtime/listener/server.go +983 -0
  79. package/internal/runtime/listener/server_test.go +319 -0
  80. package/internal/runtime/listener/sysproc_unix.go +17 -0
  81. package/internal/runtime/listener/sysproc_windows.go +13 -0
  82. package/internal/runtime/listener/types.go +21 -0
  83. package/internal/runtime/listener/wsclient.go +299 -0
  84. package/internal/runtime/listener/wsclient_test.go +41 -0
  85. package/internal/store/dao.go +632 -0
  86. package/internal/store/dao_test.go +87 -0
  87. package/internal/store/helpers.go +197 -0
  88. package/internal/store/import.go +499 -0
  89. package/internal/store/import_test.go +103 -0
  90. package/internal/store/open.go +71 -0
  91. package/internal/store/query.go +151 -0
  92. package/internal/store/schema.go +277 -0
  93. package/internal/store/schema_test.go +56 -0
  94. package/internal/store/types.go +177 -0
  95. package/internal/update/update.go +368 -0
  96. package/package.json +17 -0
  97. package/scripts/install.js +171 -0
  98. package/scripts/release/release-prerelease.sh +86 -0
  99. package/scripts/release/tag-release.sh +66 -0
  100. package/scripts/release/withdraw-release.sh +78 -0
  101. package/scripts/run.js +69 -0
  102. package/skills/README.md +32 -0
  103. package/skills/awiki-bundle/SKILL.md +76 -0
  104. package/skills/awiki-debug/SKILL.md +80 -0
  105. package/skills/awiki-group/SKILL.md +111 -0
  106. package/skills/awiki-id/SKILL.md +123 -0
  107. package/skills/awiki-msg/SKILL.md +131 -0
  108. package/skills/awiki-page/SKILL.md +93 -0
  109. package/skills/awiki-people/SKILL.md +66 -0
  110. package/skills/awiki-runtime/SKILL.md +137 -0
  111. package/skills/awiki-shared/SKILL.md +124 -0
  112. package/skills/awiki-workflow-discovery/SKILL.md +93 -0
  113. package/skills/awiki-workflow-onboarding/SKILL.md +119 -0
  114. package/skills/manifests/skills.yaml +260 -0
  115. package/skills/templates/bundle-skill-template.md +42 -0
  116. package/skills/templates/debug-skill-template.md +44 -0
  117. package/skills/templates/domain-skill-template.md +56 -0
  118. package/skills/templates/shared-skill-template.md +46 -0
  119. package/skills/templates/workflow-skill-template.md +46 -0
@@ -0,0 +1,1008 @@
1
+ > **文档状态说明(已过时)**
2
+ > 本文档属于早期 CLI 初始化草案,已被最终方案取代。当前请以 `docs/architecture/awiki-v2-architecture.md`(总体架构)、`docs/architecture/awiki-command-v2.md`(最终命令与初始化方案)和 `docs/architecture/output-format.md`(输出契约)为准;若本文与最终方案存在冲突,以最终方案为准。保留本文仅用于回溯设计演进。
3
+
4
+ 我先给结论:
5
+
6
+ **awiki v2 应该学飞书的“结构”,不要学飞书的“体量”。**
7
+ 最新的 larksuite 官方栈已经很清晰:`lark-cli` 是统一执行入口,`lark-shared` 负责共享规则,按业务域拆 skill;同时官方还把 OpenClaw 插件和 OpenAPI MCP 分成了独立仓库。这说明他们在走一条分层路线:**CLI 负责执行、skill 负责模型理解、插件负责渠道交互、MCP 负责通用工具接入**。`lark-cli` 目前公开 README 写的是 12 个业务域、200+ 命令、20 个 AI Agent Skills,采用“三层架构”:Shortcuts → API Commands → Raw API;v1.0.3 还新增了 `--jq`、更多 shortcut,并继续强化认证、多用户、诊断、测试与私有部署能力。([GitHub][1])
8
+
9
+ 而 awiki 现在的公开仓库还是典型的 Python skill 仓:目录以 `scripts/`、`references/`、`service/`、`tests/` 为中心,README 的使用方式主要还是逐个运行 Python 脚本,`pyproject.toml` 也还是一个很轻的 Python 包定义。换句话说,awiki 当前最大的瓶颈不是性能,也不是跨平台二进制,而是**CLI 入口、skill 分层、输出协议和分发方式还没产品化**。([GitHub][2])
10
+
11
+ 所以我的建议是:
12
+
13
+ 1. **CLI 语言现在继续用 Python,不要重写 Go。**
14
+ 2. **引入统一的 `awiki` CLI,而不是继续暴露脚本名。**
15
+ 3. **增加类似飞书的 shortcut 思想,但不要把 `+` 前缀当主语法。**
16
+ 4. **把 skill 拆成 `shared + domain`。**
17
+ 5. **先把 `schema / doctor / --dry-run / --jq / structured output` 做好。**
18
+
19
+ 飞书的 `+` shortcut 是建立在“三层调用架构”上的:因为它同时暴露了 shortcut、平台同步 API 命令和 raw API,所以才需要一个显式 shortcut 层。awiki 的核心域比飞书窄得多,主命令树本身就应该是“任务层”;如果再引入一整套平行的 `+` 语法,收益没有飞书那么大,反而会制造第二套文档和第二套路由。飞书值得借的是**shortcut 这个产品思想**,不是必须照搬 `+` 这个符号。([GitHub][1])
20
+
21
+ 下面是我起草的 **awiki v2 CLI 规范草案**。
22
+
23
+ ---
24
+
25
+ # awiki v2 CLI 规范草案
26
+
27
+ ## 1. 设计目标
28
+
29
+ v2 的目标不是“把所有旧脚本包一层”,而是建立一个**可让 AI 稳定路由的任务模型**。
30
+
31
+ v2 必须满足这 6 条:
32
+
33
+ * **按用户意图组织,不按脚本实现组织**
34
+ * **命令默认非交互**
35
+ * **有副作用的命令必须支持 `--dry-run`**
36
+ * **所有命令必须支持结构化输出**
37
+ * **必须提供可机器读取的 `schema`**
38
+ * **skill 必须拆成 shared + domain**
39
+
40
+ ---
41
+
42
+ ## 2. awiki v2 顶层命令树
43
+
44
+ ### 2.1 核心顶层命令
45
+
46
+ ```bash
47
+ awiki status
48
+ awiki schema [COMMAND]
49
+ awiki doctor
50
+ awiki version
51
+
52
+ awiki id ...
53
+ awiki msg ...
54
+ awiki runtime ...
55
+ ```
56
+
57
+ ### 2.2 扩展顶层命令
58
+
59
+ ```bash
60
+ awiki people ...
61
+ awiki page ...
62
+ awiki discovery ...
63
+ awiki debug ...
64
+ ```
65
+
66
+ ### 2.3 顶层命令职责
67
+
68
+ `status`
69
+ 快速总览:identity、listener、runtime mode、未读、待处理 secure 状态。
70
+
71
+ `schema`
72
+ 命令与返回结构自省,给 AI 和调试工具看。
73
+
74
+ `doctor`
75
+ 比 `status` 更深的诊断:环境、配置、凭证、数据库迁移、listener、服务可达性。
76
+
77
+ `id`
78
+ 身份生命周期:DID、Handle、绑定、恢复、profile、多身份切换。
79
+
80
+ `msg`
81
+ 消息生命周期:私聊、群聊、收件箱、历史、E2EE。
82
+
83
+ `runtime`
84
+ 运行时机制:mode、listener、heartbeat、setup。
85
+
86
+ `people`
87
+ 搜索、follow、contacts。
88
+
89
+ `page`
90
+ 内容页发布。
91
+
92
+ `discovery`
93
+ 群组发现工作流。**不要再混在 msg 主路径里。**
94
+
95
+ `debug`
96
+ 原始调试、DB、schema cache、兼容层。
97
+
98
+ ---
99
+
100
+ ## 3. 统一消息模型
101
+
102
+ v2 主文档里建议直接写死下面这段:
103
+
104
+ ```text
105
+ Message =
106
+ Target(scope: direct | group)
107
+ × Security(plain | e2ee)
108
+ × ReceiveMode(pull | realtime)
109
+ ```
110
+
111
+ 其中:
112
+
113
+ * AI 需要主动选择的只有 `scope` 和 `security`
114
+ * `ReceiveMode` 属于 runtime,不属于消息路由
115
+
116
+ 当前支持矩阵建议明确成:
117
+
118
+ ```text
119
+ direct + plain = supported
120
+ direct + e2ee = supported
121
+ group + plain = supported
122
+ group + e2ee = not supported yet
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 4. 详细命令树
128
+
129
+ ## 4.1 status / schema / doctor
130
+
131
+ ```bash
132
+ awiki status [--identity NAME] [--output human|json]
133
+ awiki schema [COMMAND] [--output human|json]
134
+ awiki doctor [--identity NAME] [--output human|json]
135
+ awiki version
136
+ ```
137
+
138
+ ### 语义
139
+
140
+ `status` 是轻量 dashboard。
141
+ `doctor` 是深度诊断。
142
+ `schema` 是元数据入口,不执行真实业务。
143
+
144
+ ---
145
+
146
+ ## 4.2 id
147
+
148
+ ```bash
149
+ awiki id status [--identity NAME]
150
+
151
+ awiki id create \
152
+ --name "Alice" \
153
+ [--identity alice]
154
+
155
+ awiki id register \
156
+ --handle alice \
157
+ (--phone +8613800138000 [--otp 123456] [--invite-code ABC123] \
158
+ | --email user@example.com [--wait]) \
159
+ [--identity alice]
160
+
161
+ awiki id bind \
162
+ (--phone +8613800138000 [--otp 123456] \
163
+ | --email user@example.com [--wait]) \
164
+ [--identity alice]
165
+
166
+ awiki id resolve (--handle alice | --did did:wba:...)
167
+
168
+ awiki id recover \
169
+ --handle alice \
170
+ --phone +8613800138000 \
171
+ --otp 123456 \
172
+ [--identity alice]
173
+
174
+ awiki id list
175
+ awiki id current
176
+ awiki id use alice
177
+
178
+ awiki id profile get \
179
+ [--self | --handle alice | --did did:wba:...]
180
+
181
+ awiki id profile set \
182
+ [--display-name "Alice"] \
183
+ [--bio "..." ] \
184
+ [--tags "ai,did,agent"] \
185
+ [--markdown "# About Me"] \
186
+ [--markdown-file ./profile.md]
187
+ ```
188
+
189
+ ### 规范
190
+
191
+ * `id create` 只做 DID-only
192
+ * `id register` 只做 Handle 注册
193
+ * `id bind` 只做联系方式补充
194
+ * `id use` 切换默认 identity
195
+ * `profile` 一律归到 `id` 下
196
+ * 所有注册/绑定流程默认非交互,`--wait` 只允许轮询,不允许 CLI 内部 prompt
197
+
198
+ ---
199
+
200
+ ## 4.3 msg
201
+
202
+ ### 4.3.1 发送、收件箱、历史
203
+
204
+ ```bash
205
+ awiki msg send \
206
+ (--to TARGET | --group GROUP_ID) \
207
+ [--text "Hello"] \
208
+ [--text-file ./message.txt] \
209
+ [--type text|event] \
210
+ [--secure off|on] \
211
+ [--identity alice]
212
+
213
+ awiki msg inbox \
214
+ [--scope all|direct|group] \
215
+ [--with TARGET] \
216
+ [--group GROUP_ID] \
217
+ [--unread] \
218
+ [--limit 20] \
219
+ [--mark-read] \
220
+ [--identity alice]
221
+
222
+ awiki msg history \
223
+ --with TARGET \
224
+ [--limit 50] \
225
+ [--cursor CURSOR] \
226
+ [--identity alice]
227
+
228
+ awiki msg mark-read MSG_ID...
229
+ ```
230
+
231
+ ### 4.3.2 群组
232
+
233
+ ```bash
234
+ awiki msg group create \
235
+ --name "Agent War Room" \
236
+ [--slug agent-war-room] \
237
+ [--description "..."] \
238
+ [--goal "..."] \
239
+ [--rules "..."] \
240
+ [--message-prompt "..."] \
241
+ [--member-max-messages 10] \
242
+ [--member-max-total-chars 2000] \
243
+ [--identity alice]
244
+
245
+ awiki msg group join \
246
+ --code 314159 \
247
+ [--identity alice]
248
+
249
+ awiki msg group list [--identity alice]
250
+
251
+ awiki msg group info \
252
+ --group GROUP_ID \
253
+ [--identity alice]
254
+
255
+ awiki msg group members \
256
+ --group GROUP_ID \
257
+ [--limit 100] \
258
+ [--identity alice]
259
+
260
+ awiki msg group messages \
261
+ --group GROUP_ID \
262
+ [--limit 50] \
263
+ [--cursor CURSOR] \
264
+ [--identity alice]
265
+
266
+ awiki msg group update \
267
+ --group GROUP_ID \
268
+ [--name "..."] \
269
+ [--description "..."] \
270
+ [--goal "..."] \
271
+ [--rules "..."] \
272
+ [--message-prompt "..."] \
273
+ [--member-max-messages 10] \
274
+ [--member-max-total-chars 2000] \
275
+ [--identity alice]
276
+
277
+ awiki msg group leave \
278
+ --group GROUP_ID \
279
+ [--identity alice]
280
+
281
+ awiki msg group kick \
282
+ --group GROUP_ID \
283
+ --member did:wba:... \
284
+ [--identity alice]
285
+
286
+ awiki msg group code get \
287
+ --group GROUP_ID \
288
+ [--identity alice]
289
+
290
+ awiki msg group code refresh \
291
+ --group GROUP_ID \
292
+ [--identity alice]
293
+
294
+ awiki msg group code enable \
295
+ --group GROUP_ID \
296
+ --enabled true|false \
297
+ [--identity alice]
298
+ ```
299
+
300
+ ### 4.3.3 Secure / E2EE
301
+
302
+ ```bash
303
+ awiki msg secure status \
304
+ [--with TARGET] \
305
+ [--identity alice]
306
+
307
+ awiki msg secure init \
308
+ --with TARGET \
309
+ [--identity alice]
310
+
311
+ awiki msg secure repair \
312
+ --with TARGET \
313
+ [--identity alice]
314
+
315
+ awiki msg secure failed \
316
+ [--identity alice]
317
+
318
+ awiki msg secure retry \
319
+ OUTBOX_ID \
320
+ [--identity alice]
321
+
322
+ awiki msg secure drop \
323
+ OUTBOX_ID \
324
+ [--identity alice]
325
+ ```
326
+
327
+ ### msg 设计原则
328
+
329
+ 最关键的一条:
330
+
331
+ **所有发送动作统一进 `awiki msg send`。**
332
+
333
+ 也就是:
334
+
335
+ ```bash
336
+ awiki msg send --to alice --text "hello"
337
+ awiki msg send --to alice --text "secret" --secure on
338
+ awiki msg send --group GID --text "hello everyone"
339
+ ```
340
+
341
+ 这样 AI 永远先匹配“发消息”这个动作,再判断:
342
+
343
+ * `--to` 还是 `--group`
344
+ * `--secure off` 还是 `--secure on`
345
+
346
+ 而不会再去猜旧脚本名。
347
+
348
+ ---
349
+
350
+ ## 4.4 runtime
351
+
352
+ ```bash
353
+ awiki runtime status [--identity NAME]
354
+
355
+ awiki runtime setup \
356
+ [--mode http|websocket] \
357
+ [--identity NAME]
358
+
359
+ awiki runtime mode get
360
+ awiki runtime mode set http|websocket
361
+
362
+ awiki runtime listener status
363
+ awiki runtime listener install
364
+ awiki runtime listener start
365
+ awiki runtime listener stop
366
+ awiki runtime listener restart
367
+ awiki runtime listener uninstall
368
+
369
+ awiki runtime heartbeat status
370
+ awiki runtime heartbeat install [--every 15m]
371
+ awiki runtime heartbeat run-once
372
+ ```
373
+
374
+ ### 设计原则
375
+
376
+ * transport 只在 `runtime` 出现
377
+ * 消息命令不再感知 HTTP / WSS
378
+ * `setup` 是编排器:migration + runtime config + listener bootstrap
379
+ * `listener` 负责实时接收基础设施
380
+ * `heartbeat` 负责平台级周期检查,不再散落到主 skill 的行为说明里
381
+
382
+ ---
383
+
384
+ ## 4.5 扩展命令
385
+
386
+ ### people
387
+
388
+ ```bash
389
+ awiki people search "AI agent"
390
+ awiki people follow TARGET
391
+ awiki people unfollow TARGET
392
+ awiki people status TARGET
393
+ awiki people followers
394
+ awiki people following
395
+ awiki people contacts list
396
+ awiki people contacts save --did DID --handle HANDLE --reason "..."
397
+ ```
398
+
399
+ ### page
400
+
401
+ ```bash
402
+ awiki page create --slug jd --title "Hiring" --markdown-file ./jd.md
403
+ awiki page list
404
+ awiki page get --slug jd
405
+ awiki page update --slug jd [--title "..."] [--markdown "..."] [--markdown-file ./x.md]
406
+ awiki page rename --slug jd --to hiring
407
+ awiki page delete --slug hiring
408
+ ```
409
+
410
+ ### discovery
411
+
412
+ ```bash
413
+ awiki discovery scan --group GROUP_ID
414
+ awiki discovery recommend --group GROUP_ID
415
+ awiki discovery draft-intro --group GROUP_ID
416
+ awiki discovery draft-dm --group GROUP_ID --member DID
417
+ ```
418
+
419
+ ### debug
420
+
421
+ ```bash
422
+ awiki debug db query "SELECT ..."
423
+ awiki debug raw rpc ...
424
+ awiki debug schema-cache
425
+ awiki debug logs [--follow]
426
+ ```
427
+
428
+ ---
429
+
430
+ # 5. 参数命名规范
431
+
432
+ v2 建议统一成下面这套。
433
+
434
+ ## 5.1 通用参数
435
+
436
+ ```bash
437
+ --identity <name> # canonical
438
+ --credential <name> # legacy alias
439
+
440
+ --output human|json|ndjson
441
+ --json # alias of --output json
442
+ --jq '<expr>' # apply jq-style filter to JSON output
443
+ --dry-run
444
+ --verbose
445
+ ```
446
+
447
+ 飞书 CLI 在 v1.0.3 刚加入了 `--jq`,这是一个非常值得直接借鉴的点:对 AI 和调试都很有价值。([GitHub][3])
448
+
449
+ ## 5.2 身份和目标
450
+
451
+ ```bash
452
+ --to <handle|did> # direct message target
453
+ --group <group-id> # group target
454
+ --did <did> # explicit DID input
455
+ --handle <handle> # explicit handle input
456
+ --with <target> # history / secure peer
457
+ ```
458
+
459
+ 规范:
460
+
461
+ * 消息发送一律用 `--to` 或 `--group`
462
+ * 需要显式解析时才用 `--did` / `--handle`
463
+ * 不再继续扩散 `--peer`、`--target-did` 这种协议味很重的名字
464
+
465
+ ## 5.3 文本和文件
466
+
467
+ ```bash
468
+ --text "..."
469
+ --text-file ./message.txt
470
+
471
+ --markdown "..."
472
+ --markdown-file ./doc.md
473
+ ```
474
+
475
+ 规范:
476
+
477
+ * 消息统一用 `--text`
478
+ * Markdown 内容统一用 `--markdown`
479
+ * 不再混用 `--content` / `--body` / `--profile-md`
480
+
481
+ ## 5.4 控制参数
482
+
483
+ ```bash
484
+ --secure off|on
485
+ --mode http|websocket
486
+ --wait
487
+ --limit 50
488
+ --cursor CURSOR
489
+ --force
490
+ ```
491
+
492
+ 规范:
493
+
494
+ * `--secure` 先只支持 `off|on`
495
+ * 不建议上来就做会降级到明文的 `auto`
496
+ * `--force` 只给不可逆动作用
497
+
498
+ ---
499
+
500
+ # 6. 输出协议
501
+
502
+ ## 6.1 总原则
503
+
504
+ * 默认 human 输出面向人读
505
+ * `--json` 输出必须稳定、机器可解析
506
+ * `ndjson` 用于事件流或大型列表
507
+ * human 输出默认缩写 DID、隐藏敏感值、本地化时间
508
+ * JSON 输出也不应暴露私钥/JWT/原始敏感材料
509
+
510
+ ## 6.2 JSON 输出统一信封
511
+
512
+ 成功:
513
+
514
+ ```json
515
+ {
516
+ "ok": true,
517
+ "command": "awiki msg send",
518
+ "data": {},
519
+ "warnings": [],
520
+ "notice": {},
521
+ "meta": {
522
+ "version": "2.0.0",
523
+ "identity": {
524
+ "name": "alice",
525
+ "did": "did:wba:awiki.ai:user:abc...xyz"
526
+ },
527
+ "dry_run": false,
528
+ "output": "json"
529
+ }
530
+ }
531
+ ```
532
+
533
+ 失败:
534
+
535
+ ```json
536
+ {
537
+ "ok": false,
538
+ "error": {
539
+ "code": "permission_denied",
540
+ "message": "Missing required permission",
541
+ "hint": "Run awiki id use alice or refresh identity",
542
+ "retryable": false,
543
+ "details": {}
544
+ },
545
+ "meta": {
546
+ "version": "2.0.0",
547
+ "dry_run": false,
548
+ "output": "json"
549
+ }
550
+ }
551
+ ```
552
+
553
+ ## 6.3 建议的错误码集合
554
+
555
+ ```text
556
+ invalid_argument
557
+ identity_required
558
+ auth_required
559
+ permission_denied
560
+ not_found
561
+ conflict
562
+ network_error
563
+ transport_unavailable
564
+ secure_session_required
565
+ unsupported_mode
566
+ partial_failure
567
+ internal_error
568
+ ```
569
+
570
+ ## 6.4 notice 字段
571
+
572
+ 建议统一保留:
573
+
574
+ ```json
575
+ "notice": {
576
+ "update": {
577
+ "current": "2.0.0",
578
+ "latest": "2.1.0",
579
+ "command": "uv tool upgrade awiki-cli"
580
+ }
581
+ }
582
+ ```
583
+
584
+ 飞书的 `lark-shared` 明确要求 agent 不要静默忽略更新提示,这个思路值得借。([GitHub][4])
585
+
586
+ ---
587
+
588
+ # 7. `--dry-run` 设计
589
+
590
+ ## 7.1 适用范围
591
+
592
+ 所有有副作用的命令 **MUST** 支持 `--dry-run`,包括:
593
+
594
+ * `id register`
595
+ * `id bind`
596
+ * `msg send`
597
+ * `msg group create/join/update/leave/kick`
598
+ * `msg secure retry/drop`
599
+ * `people follow/unfollow`
600
+ * `page create/update/delete`
601
+ * `runtime setup/listener install`
602
+
603
+ 飞书官方 shortcut 也把 dry-run 作为有副作用动作的标准预览能力,这个点非常应该对齐。([GitHub][5])
604
+
605
+ ## 7.2 dry-run 行为
606
+
607
+ `--dry-run` 时:
608
+
609
+ * **允许**参数校验
610
+ * **允许**本地只读检查
611
+ * **允许**安全的 GET 预检
612
+ * **禁止**发送 OTP / 邮件 / 消息
613
+ * **禁止**创建或修改远端资源
614
+ * **禁止**写入本地持久状态
615
+
616
+ ## 7.3 dry-run 输出应包含 plan
617
+
618
+ 示例:
619
+
620
+ ```json
621
+ {
622
+ "ok": true,
623
+ "command": "awiki msg send",
624
+ "data": {
625
+ "plan": {
626
+ "action": "send_message",
627
+ "target": {
628
+ "kind": "direct",
629
+ "input": "alice",
630
+ "resolved_handle": "alice.awiki.ai",
631
+ "resolved_did": "did:wba:awiki.ai:user:abc...xyz"
632
+ },
633
+ "security": {
634
+ "requested": "on",
635
+ "mode": "e2ee",
636
+ "session": "missing",
637
+ "will_init": true
638
+ },
639
+ "transport": {
640
+ "send": "http",
641
+ "receive": "websocket"
642
+ },
643
+ "mutations": [
644
+ "remote:e2ee_init",
645
+ "remote:e2ee_msg"
646
+ ]
647
+ }
648
+ },
649
+ "meta": {
650
+ "dry_run": true
651
+ }
652
+ }
653
+ ```
654
+
655
+ ---
656
+
657
+ # 8. `schema` 设计
658
+
659
+ 飞书把 `schema` 做成了一等入口,这对 AI 极其重要;而且最新 README 已经把它列为主命令,用来查看参数、请求体、响应结构、支持 identity 和 scopes。awiki v2 也应该直接照这个方向做。([GitHub][5])
660
+
661
+ ## 8.1 CLI
662
+
663
+ ```bash
664
+ awiki schema
665
+ awiki schema msg.send
666
+ awiki schema id.register
667
+ awiki schema runtime.listener.install
668
+ awiki schema --skills
669
+ ```
670
+
671
+ ## 8.2 schema 返回内容
672
+
673
+ 每个命令 schema 至少包含:
674
+
675
+ ```json
676
+ {
677
+ "name": "awiki msg send",
678
+ "summary": "Send a direct or group message",
679
+ "aliases": ["awiki dm"],
680
+ "side_effect": true,
681
+ "confirm_required": true,
682
+ "dry_run_supported": true,
683
+ "identity_required": true,
684
+ "supports_output": ["human", "json", "ndjson"],
685
+ "capabilities": {
686
+ "direct_plain": true,
687
+ "direct_e2ee": true,
688
+ "group_plain": true,
689
+ "group_e2ee": false
690
+ },
691
+ "args": [],
692
+ "returns": {},
693
+ "errors": [],
694
+ "examples": [],
695
+ "legacy_maps_to": [
696
+ "scripts/send_message.py",
697
+ "scripts/e2ee_messaging.py --send",
698
+ "scripts/manage_group.py --post-message"
699
+ ]
700
+ }
701
+ ```
702
+
703
+ ## 8.3 存储位置
704
+
705
+ 建议在 repo 里落一份生成后的命令 schema:
706
+
707
+ ```text
708
+ schemas/
709
+ cli.json
710
+ commands/
711
+ awiki.status.json
712
+ awiki.id.register.json
713
+ awiki.msg.send.json
714
+ awiki.msg.group.join.json
715
+ awiki.runtime.setup.json
716
+ ```
717
+
718
+ 并且:
719
+
720
+ * CLI help 从 schema 生成
721
+ * `CLI_REFERENCE.md` 从 schema 生成
722
+ * skill 文档中的命令引用由 CI 检查是否存在
723
+
724
+ 飞书 changelog 里已经出现了 skill format check 和更完整的 CI/发布流程,这个方向非常值得借。([GitHub][3])
725
+
726
+ ---
727
+
728
+ # 9. 是否要加 shortcut
729
+
730
+ 我的建议是:
731
+
732
+ ## 9.1 要加,但不要把 `+` 当主语法
733
+
734
+ ### 原因
735
+
736
+ 飞书之所以需要 `+` shortcut,是因为它同时面向:
737
+
738
+ * shortcut 层
739
+ * 平台同步 API command 层
740
+ * raw API 层
741
+
742
+ 所以 `+` 是在一个“大而全平台 CLI”里区分“高层任务入口”的手段。awiki 不打算把 1:1 API 和 raw API 暴露成主路径,因此**canonical 命令本身就应该足够短**。([GitHub][1])
743
+
744
+ ## 9.2 awiki 的 shortcut 设计
745
+
746
+ 我建议用**别名命令**,不是 `+` 前缀:
747
+
748
+ ```bash
749
+ awiki setup # = awiki runtime setup
750
+ awiki register ... # = awiki id register ...
751
+ awiki inbox # = awiki msg inbox
752
+ awiki dm alice "hello" # = awiki msg send --to alice --text "hello"
753
+ awiki secure alice "secret" # = awiki msg send --to alice --text "secret" --secure on
754
+ awiki join 314159 # = awiki msg group join --code 314159
755
+ awiki history alice # = awiki msg history --with alice
756
+ ```
757
+
758
+ ## 9.3 shortcut 规则
759
+
760
+ * shortcut **只能**是 canonical command 的别名
761
+ * shortcut **不能**有独占语义
762
+ * shortcut 数量控制在 6–8 个以内
763
+ * 文档必须先讲 canonical command,再讲 shortcut
764
+ * 以后如果你真的想兼容飞书风格,可以在 parser 里偷偷支持 `+dm`、`+inbox` 这样的 alias,但**不要在主文档里把它当第一层语法**
765
+
766
+ 一句话:
767
+
768
+ **awiki 应该引入“shortcut 这个思想”,但不应该复制“符号化的第二套语法”。**
769
+
770
+ ---
771
+
772
+ # 10. skill 拆分目录
773
+
774
+ 我建议最终目录这样拆:
775
+
776
+ ```text
777
+ skills/
778
+ awiki-bundle/
779
+ SKILL.md
780
+
781
+ awiki-shared/
782
+ SKILL.md
783
+
784
+ awiki-id/
785
+ SKILL.md
786
+
787
+ awiki-msg/
788
+ SKILL.md
789
+
790
+ awiki-runtime/
791
+ SKILL.md
792
+
793
+ awiki-people/
794
+ SKILL.md
795
+
796
+ awiki-discovery/
797
+ SKILL.md
798
+
799
+ awiki-page/
800
+ SKILL.md
801
+
802
+ awiki-debug/
803
+ SKILL.md
804
+ ```
805
+
806
+ ## 10.1 每个 skill 的职责
807
+
808
+ `awiki-bundle`
809
+ 薄入口。只做导航,不承载大段细节。告诉 AI 先用哪个 skill。
810
+
811
+ `awiki-shared`
812
+ 安装检查、安全规则、环境变量、多身份规则、输出协议、`--dry-run`、`schema`、更新提示、何时必须确认。
813
+ 这层很像飞书的 `lark-shared`,后者已经把配置初始化、认证、身份切换、权限错误处理、更新提示和安全规则集中到一个共享 skill 里。([GitHub][4])
814
+
815
+ `awiki-id`
816
+ DID、Handle、bind、recover、profile。
817
+
818
+ `awiki-msg`
819
+ direct/group messaging、inbox/history、secure session。
820
+
821
+ `awiki-runtime`
822
+ mode、listener、heartbeat、setup。
823
+
824
+ `awiki-people`
825
+ search / follow / contacts。
826
+
827
+ `awiki-discovery`
828
+ 群组发现工作流、推荐、DM 草稿模板。
829
+ **不再混到 msg 的默认行为里。**
830
+
831
+ `awiki-page`
832
+ 内容页发布。
833
+
834
+ `awiki-debug`
835
+ DB / raw rpc / schema cache / troubleshooting。
836
+
837
+ ---
838
+
839
+ # 11. 文档目录
840
+
841
+ 建议文档也同步拆:
842
+
843
+ ```text
844
+ references/
845
+ SECURITY.md
846
+ CLI_REFERENCE.md
847
+ IDENTITY.md
848
+ MESSAGING.md
849
+ RUNTIME.md
850
+ PEOPLE.md
851
+ DISCOVERY.md
852
+ PAGE.md
853
+ DEBUG.md
854
+ UPGRADE.md
855
+ WHY_AWIKI.md
856
+ ```
857
+
858
+ 原则是:
859
+
860
+ * 一个主题只有一个权威文档
861
+ * `SKILL.md` 只讲路由与默认行为
862
+ * CLI 细节全部下沉到 `CLI_REFERENCE.md`
863
+ * discovery 独立,不再挤占核心 skill
864
+
865
+ ---
866
+
867
+ # 12. 代码与包分发建议
868
+
869
+ ## 12.1 语言
870
+
871
+ **现在继续用 Python。**
872
+
873
+ 具体建议:
874
+
875
+ * CLI:**Typer**
876
+ * 数据模型/输出协议:**Pydantic**
877
+ * 代码组织:
878
+
879
+ * `awiki_sdk`:身份、消息、group、secure、runtime、storage
880
+ * `awiki_cli`:命令树和输出
881
+ * legacy `scripts/` 先保留一到两个大版本
882
+
883
+ 为什么不建议现在就学飞书重写 Go:
884
+
885
+ * 飞书 CLI 现在已经是 12 个域、200+ 命令、20 个 skill,并且底层是 Go、分发走 npm wrapper + postinstall + 跨平台二进制;这是一套成熟平台工具链的复杂度。([GitHub][1])
886
+ * awiki 目前还是 Python 工程,公开 repo 结构和 `pyproject.toml` 都说明它离“需要原生二进制重构”的阶段还很远。([GitHub][2])
887
+
888
+ ## 12.2 包结构
889
+
890
+ ```text
891
+ src/
892
+ awiki_sdk/
893
+ awiki_cli/
894
+
895
+ skills/
896
+ schemas/
897
+ references/
898
+ legacy/
899
+ scripts/
900
+ ```
901
+
902
+ `pyproject.toml`:
903
+
904
+ ```toml
905
+ [project]
906
+ name = "awiki-cli"
907
+ version = "2.0.0"
908
+
909
+ [project.scripts]
910
+ awiki = "awiki_cli.app:main"
911
+ ```
912
+
913
+ ## 12.3 分发
914
+
915
+ ### 第一优先级
916
+
917
+ ```bash
918
+ uv tool install awiki-cli
919
+ # or
920
+ pipx install awiki-cli
921
+ ```
922
+
923
+ ### 第二优先级
924
+
925
+ GitHub Releases 发布:
926
+
927
+ * wheel
928
+ * sdist
929
+ * checksums
930
+ * source zip
931
+ * skills bundle zip
932
+
933
+ ### 第三优先级
934
+
935
+ 如果以后确实出现跨平台零 Python 依赖的强需求,再做:
936
+
937
+ * standalone binary
938
+ * 国内镜像安装
939
+ * 可选 wrapper
940
+
941
+ ## 12.4 为什么不建议现在上 npm wrapper
942
+
943
+ 飞书的 npm 分发成立,是因为它的包本质上是 Go CLI 的包装层:`package.json` 里把 `lark-cli` 指到 `scripts/run.js`,安装时执行 `scripts/install.js`,而且近期 changelog 还专门修了“用 curl 下载二进制、支持代理、加 npmmirror fallback”。这是一套“原生二进制 + npm 分发层”的体系。对 awiki 现在来说,这套复杂度太高。([GitHub][6])
944
+
945
+ 而且飞书社区最近已经有人提 issue,希望支持 Bun,原因就是当前 Node 运行时包装层本身也会带来额外环境摩擦。对 awiki 这种还在打磨产品模型的项目来说,没必要先背这层负担。([GitHub][7])
946
+
947
+ ---
948
+
949
+ # 13. 兼容迁移建议
950
+
951
+ 建议保留旧脚本一个过渡周期,但统一输出 deprecation hint。
952
+
953
+ 示例映射:
954
+
955
+ ```text
956
+ scripts/check_status.py -> awiki status
957
+ scripts/setup_identity.py -> awiki id create / id list / id use
958
+ scripts/send_verification_code.py -> awiki id register / id bind
959
+ scripts/register_handle.py -> awiki id register
960
+ scripts/bind_contact.py -> awiki id bind
961
+ scripts/resolve_handle.py -> awiki id resolve
962
+ scripts/recover_handle.py -> awiki id recover
963
+ scripts/get_profile.py -> awiki id profile get
964
+ scripts/update_profile.py -> awiki id profile set
965
+ scripts/send_message.py -> awiki msg send --secure off
966
+ scripts/e2ee_messaging.py --send -> awiki msg send --secure on
967
+ scripts/check_inbox.py -> awiki msg inbox / msg history / msg mark-read
968
+ scripts/manage_group.py -> awiki msg group ...
969
+ scripts/manage_group.py --post-message -> awiki msg send --group ...
970
+ scripts/setup_realtime.py -> awiki runtime setup
971
+ scripts/ws_listener.py -> awiki runtime listener ...
972
+ scripts/query_db.py -> awiki debug db query
973
+ ```
974
+
975
+ ---
976
+
977
+ # 14. 最终建议
978
+
979
+ 如果只保留最关键的 7 条,我建议你直接这样定:
980
+
981
+ 1. **canonical CLI 固定为**
982
+ `awiki status / schema / doctor / id / msg / runtime`
983
+
984
+ 2. **消息统一成一个入口**
985
+ `awiki msg send`
986
+
987
+ 3. **transport 只留在 runtime**
988
+ 不再让消息命令感知 HTTP/WSS
989
+
990
+ 4. **引入 `schema`、`--dry-run`、`--jq`、统一 JSON envelope**
991
+
992
+ 5. **skill 拆成**
993
+ `awiki-shared / awiki-id / awiki-msg / awiki-runtime / awiki-people / awiki-discovery / awiki-page / awiki-debug`
994
+
995
+ 6. **shortcut 要加,但只做 alias,不要复制飞书的 `+` 作为主语法**
996
+
997
+ 7. **语言继续用 Python + Typer,先走 PyPI/uv/pipx,暂不上 Go/npm wrapper**
998
+
999
+ 如果你愿意,我下一步直接给你写两份可落地文本:
1000
+ 一份是 **新版根 `SKILL.md`**,另一份是 **`CLI_REFERENCE.md` 初稿**。
1001
+
1002
+ [1]: https://github.com/larksuite/cli "GitHub - larksuite/cli: The official Lark/Feishu CLI tool, maintained by the larksuite team — built for humans and AI Agents. Covers core business domains including Messenger, Docs, Base, Sheets, Calendar, Mail, Tasks, Meetings, and more, with 200+ commands and 19 AI Agent Skills. · GitHub"
1003
+ [2]: https://github.com/AgentConnect/awiki-agent-id-message "GitHub - AgentConnect/awiki-agent-id-message: Provide a skill that offers identity, public profile, and end-to-end messaging services for agents. · GitHub"
1004
+ [3]: https://github.com/larksuite/cli/blob/main/CHANGELOG.md "cli/CHANGELOG.md at main · larksuite/cli · GitHub"
1005
+ [4]: https://github.com/larksuite/cli/blob/main/skills/lark-shared/SKILL.md "cli/skills/lark-shared/SKILL.md at main · larksuite/cli · GitHub"
1006
+ [5]: https://github.com/larksuite/cli?utm_source=chatgpt.com "larksuite/cli: The official Lark/Feishu ..."
1007
+ [6]: https://github.com/larksuite/cli/blob/main/package.json?utm_source=chatgpt.com "cli/package.json at main · larksuite/cli"
1008
+ [7]: https://github.com/larksuite/cli/issues/196?utm_source=chatgpt.com "建议官方支持Bun 作为Node.js 替代方案,提升开发体验#196"