wezard 2.8.8 → 3.0.1

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 (414) hide show
  1. package/.claude-plugin/plugin.json +0 -6
  2. package/CLAUDE.md +36 -16
  3. package/README.md +41 -54
  4. package/cli/wezard.sh +3 -0
  5. package/config.example.jsonc +6 -8
  6. package/dist/cli/codex-hook.js +20 -4
  7. package/dist/cli/codex-hook.js.map +1 -1
  8. package/dist/cli/init.js +45 -8
  9. package/dist/cli/init.js.map +1 -1
  10. package/dist/cli/skills.js +113 -0
  11. package/dist/cli/skills.js.map +1 -0
  12. package/dist/cli/sync.js +32 -112
  13. package/dist/cli/sync.js.map +1 -1
  14. package/dist/daemon/apprentice.js +75 -0
  15. package/dist/daemon/apprentice.js.map +1 -0
  16. package/dist/daemon/approval.js +78 -20
  17. package/dist/daemon/approval.js.map +1 -1
  18. package/dist/daemon/channel-context.js +69 -0
  19. package/dist/daemon/channel-context.js.map +1 -0
  20. package/dist/daemon/channel-posts.js +53 -0
  21. package/dist/daemon/channel-posts.js.map +1 -0
  22. package/dist/daemon/channel-store.js +96 -0
  23. package/dist/daemon/channel-store.js.map +1 -0
  24. package/dist/daemon/channel.js +805 -0
  25. package/dist/daemon/channel.js.map +1 -0
  26. package/dist/daemon/chat-name.js +24 -161
  27. package/dist/daemon/chat-name.js.map +1 -1
  28. package/dist/daemon/classes.js +418 -0
  29. package/dist/daemon/classes.js.map +1 -0
  30. package/dist/daemon/config-api.js +11 -3
  31. package/dist/daemon/config-api.js.map +1 -1
  32. package/dist/daemon/danger.js +24 -205
  33. package/dist/daemon/danger.js.map +1 -1
  34. package/dist/daemon/detail.js +14 -8
  35. package/dist/daemon/detail.js.map +1 -1
  36. package/dist/daemon/handoff.js +266 -50
  37. package/dist/daemon/handoff.js.map +1 -1
  38. package/dist/daemon/http.js +25 -18
  39. package/dist/daemon/http.js.map +1 -1
  40. package/dist/daemon/idle-reap.js +30 -0
  41. package/dist/daemon/idle-reap.js.map +1 -0
  42. package/dist/daemon/inbound.js +366 -143
  43. package/dist/daemon/inbound.js.map +1 -1
  44. package/dist/daemon/index.js +2232 -2616
  45. package/dist/daemon/index.js.map +1 -1
  46. package/dist/daemon/last-response.js +44 -9
  47. package/dist/daemon/last-response.js.map +1 -1
  48. package/dist/daemon/memory-steward.js +1 -1
  49. package/dist/daemon/memory-steward.js.map +1 -1
  50. package/dist/daemon/message-format.js +10 -2
  51. package/dist/daemon/message-format.js.map +1 -1
  52. package/dist/daemon/mirror-bridge.js +714 -485
  53. package/dist/daemon/mirror-bridge.js.map +1 -1
  54. package/dist/daemon/mirror-store.js +24 -0
  55. package/dist/daemon/mirror-store.js.map +1 -1
  56. package/dist/daemon/notices.js +2 -2
  57. package/dist/daemon/notices.js.map +1 -1
  58. package/dist/daemon/onboarding.js +384 -0
  59. package/dist/daemon/onboarding.js.map +1 -0
  60. package/dist/daemon/outbound.js +21 -11
  61. package/dist/daemon/outbound.js.map +1 -1
  62. package/dist/daemon/peers.js +38 -230
  63. package/dist/daemon/peers.js.map +1 -1
  64. package/dist/daemon/pending.js +7 -5
  65. package/dist/daemon/pending.js.map +1 -1
  66. package/dist/daemon/picker-policy.js +27 -12
  67. package/dist/daemon/picker-policy.js.map +1 -1
  68. package/dist/daemon/plans.js.map +1 -1
  69. package/dist/daemon/room-auto-adhoc.js +18 -0
  70. package/dist/daemon/room-auto-adhoc.js.map +1 -0
  71. package/dist/daemon/room-facts.js +35 -0
  72. package/dist/daemon/room-facts.js.map +1 -0
  73. package/dist/daemon/room-hub.js +430 -0
  74. package/dist/daemon/room-hub.js.map +1 -0
  75. package/dist/daemon/room-overdue.js +98 -0
  76. package/dist/daemon/room-overdue.js.map +1 -0
  77. package/dist/daemon/room-prune.js +74 -0
  78. package/dist/daemon/room-prune.js.map +1 -0
  79. package/dist/daemon/room-spawn.js +20 -0
  80. package/dist/daemon/room-spawn.js.map +1 -0
  81. package/dist/daemon/room-watchdog.js +153 -0
  82. package/dist/daemon/room-watchdog.js.map +1 -0
  83. package/dist/daemon/rooms.js +107 -0
  84. package/dist/daemon/rooms.js.map +1 -0
  85. package/dist/daemon/route.js +7 -18
  86. package/dist/daemon/route.js.map +1 -1
  87. package/dist/daemon/spawn-tmux.js +171 -55
  88. package/dist/daemon/spawn-tmux.js.map +1 -1
  89. package/dist/daemon/steward-guard.js +2 -2
  90. package/dist/daemon/steward.js +132 -0
  91. package/dist/daemon/steward.js.map +1 -0
  92. package/dist/daemon/tasks.js +4 -14
  93. package/dist/daemon/tasks.js.map +1 -1
  94. package/dist/daemon/turn-opening.js +25 -0
  95. package/dist/daemon/turn-opening.js.map +1 -0
  96. package/dist/daemon/wake-tail.js +55 -0
  97. package/dist/daemon/wake-tail.js.map +1 -0
  98. package/dist/daemon/weixin-cmd.js +10 -14
  99. package/dist/daemon/weixin-cmd.js.map +1 -1
  100. package/dist/daemon/wezard-session.js +7 -2
  101. package/dist/daemon/wezard-session.js.map +1 -1
  102. package/dist/daemon/wizard-names.js +0 -22
  103. package/dist/daemon/wizard-names.js.map +1 -1
  104. package/dist/daemon/wizard.js +589 -145
  105. package/dist/daemon/wizard.js.map +1 -1
  106. package/dist/mcp/output.js +6 -5
  107. package/dist/mcp/output.js.map +1 -1
  108. package/dist/mcp/tools.js +258 -236
  109. package/dist/mcp/tools.js.map +1 -1
  110. package/dist/shared/allow-rules.js +32 -8
  111. package/dist/shared/allow-rules.js.map +1 -1
  112. package/dist/shared/charter-rearm.js +179 -0
  113. package/dist/shared/charter-rearm.js.map +1 -0
  114. package/dist/shared/chat-http.js +374 -459
  115. package/dist/shared/chat-http.js.map +1 -1
  116. package/dist/shared/chat-record.js +55 -0
  117. package/dist/shared/chat-record.js.map +1 -0
  118. package/dist/shared/chat-render.js +7 -4
  119. package/dist/shared/chat-render.js.map +1 -1
  120. package/dist/shared/chat-view.js +2 -41
  121. package/dist/shared/chat-view.js.map +1 -1
  122. package/dist/shared/cli-backends.js +27 -5
  123. package/dist/shared/cli-backends.js.map +1 -1
  124. package/dist/shared/config.js +122 -38
  125. package/dist/shared/config.js.map +1 -1
  126. package/dist/shared/detail-render.js +104 -21
  127. package/dist/shared/detail-render.js.map +1 -1
  128. package/dist/shared/detail-store.js.map +1 -1
  129. package/dist/shared/group-members.js +35 -0
  130. package/dist/shared/group-members.js.map +1 -0
  131. package/dist/shared/inject-view.js +105 -0
  132. package/dist/shared/inject-view.js.map +1 -0
  133. package/dist/shared/json-map-store.js +23 -6
  134. package/dist/shared/json-map-store.js.map +1 -1
  135. package/dist/shared/legacy-routes.js +199 -0
  136. package/dist/shared/legacy-routes.js.map +1 -0
  137. package/dist/shared/mem-guard.js +32 -0
  138. package/dist/shared/mem-guard.js.map +1 -0
  139. package/dist/shared/message-footer.js +4 -3
  140. package/dist/shared/message-footer.js.map +1 -1
  141. package/dist/shared/pricing.js +5 -0
  142. package/dist/shared/pricing.js.map +1 -1
  143. package/dist/shared/reminder.js +30 -38
  144. package/dist/shared/reminder.js.map +1 -1
  145. package/dist/shared/repl-script.js +114 -26
  146. package/dist/shared/repl-script.js.map +1 -1
  147. package/dist/shared/role-render.js +209 -210
  148. package/dist/shared/role-render.js.map +1 -1
  149. package/dist/shared/role-view.js +61 -299
  150. package/dist/shared/role-view.js.map +1 -1
  151. package/dist/shared/room-label.js +13 -0
  152. package/dist/shared/room-label.js.map +1 -0
  153. package/dist/shared/room-migrate.js +404 -0
  154. package/dist/shared/room-migrate.js.map +1 -0
  155. package/dist/shared/room-overdue.js +81 -0
  156. package/dist/shared/room-overdue.js.map +1 -0
  157. package/dist/shared/room-search.js +102 -0
  158. package/dist/shared/room-search.js.map +1 -0
  159. package/dist/shared/room-view.js +261 -0
  160. package/dist/shared/room-view.js.map +1 -0
  161. package/dist/shared/room.js +610 -0
  162. package/dist/shared/room.js.map +1 -0
  163. package/dist/shared/session-hooks.js +58 -0
  164. package/dist/shared/session-hooks.js.map +1 -0
  165. package/dist/shared/session-label.js +80 -60
  166. package/dist/shared/session-label.js.map +1 -1
  167. package/dist/shared/session-mcp.js +77 -0
  168. package/dist/shared/session-mcp.js.map +1 -0
  169. package/dist/shared/session-skills.js +63 -0
  170. package/dist/shared/session-skills.js.map +1 -0
  171. package/dist/shared/skill-sync.js +229 -0
  172. package/dist/shared/skill-sync.js.map +1 -0
  173. package/dist/shared/smarts.js +39 -0
  174. package/dist/shared/smarts.js.map +1 -0
  175. package/dist/shared/stream-page.js +22 -0
  176. package/dist/shared/stream-page.js.map +1 -0
  177. package/dist/shared/task-file.js +0 -5
  178. package/dist/shared/task-file.js.map +1 -1
  179. package/dist/shared/task-template.js +1 -1
  180. package/dist/shared/task-template.js.map +1 -1
  181. package/dist/shared/tool-hints.js +76 -17
  182. package/dist/shared/tool-hints.js.map +1 -1
  183. package/dist/shared/workspace-trust.js +8 -0
  184. package/dist/shared/workspace-trust.js.map +1 -1
  185. package/dist/shared/world.js +101 -166
  186. package/dist/shared/world.js.map +1 -1
  187. package/dist/svr/facts-store.js +26 -0
  188. package/dist/svr/facts-store.js.map +1 -0
  189. package/dist/svr/index.js +62 -6
  190. package/dist/svr/index.js.map +1 -1
  191. package/hooks/pre-tool-use.sh +18 -0
  192. package/hooks/stop.sh +26 -0
  193. package/package.json +7 -3
  194. package/scripts/install.sh +11 -0
  195. package/skills/LICENSE.wecom-unified.txt +21 -0
  196. package/skills/wecom-unified/SKILL.md +151 -0
  197. package/skills/wecom-unified/assets/templates/broadside/DESIGN.preset.md +172 -0
  198. package/skills/wecom-unified/assets/templates/broadside/shell/content.jsx +31 -0
  199. package/skills/wecom-unified/assets/templates/broadside/slides/01_cover.slide +48 -0
  200. package/skills/wecom-unified/assets/templates/broadside/slides/02_section.slide +58 -0
  201. package/skills/wecom-unified/assets/templates/broadside/slides/03_cards.slide +53 -0
  202. package/skills/wecom-unified/assets/templates/broadside/slides/04_image.slide +64 -0
  203. package/skills/wecom-unified/assets/templates/cartesian/DESIGN.preset.md +139 -0
  204. package/skills/wecom-unified/assets/templates/cartesian/shell/content.jsx +28 -0
  205. package/skills/wecom-unified/assets/templates/cartesian/slides/01_cover.slide +44 -0
  206. package/skills/wecom-unified/assets/templates/cartesian/slides/02_compare.slide +79 -0
  207. package/skills/wecom-unified/assets/templates/cartesian/slides/03_table.slide +79 -0
  208. package/skills/wecom-unified/assets/templates/cobalt-grid/DESIGN.preset.md +118 -0
  209. package/skills/wecom-unified/assets/templates/cobalt-grid/shell/content.jsx +24 -0
  210. package/skills/wecom-unified/assets/templates/cobalt-grid/slides/01_cover.slide +61 -0
  211. package/skills/wecom-unified/assets/templates/cobalt-grid/slides/02_structure.slide +85 -0
  212. package/skills/wecom-unified/assets/templates/cobalt-grid/slides/03_data.slide +60 -0
  213. package/skills/wecom-unified/assets/templates/editorial-forest/DESIGN.preset.md +135 -0
  214. package/skills/wecom-unified/assets/templates/editorial-forest/shell/content.jsx +19 -0
  215. package/skills/wecom-unified/assets/templates/editorial-forest/slides/01_cover.slide +29 -0
  216. package/skills/wecom-unified/assets/templates/editorial-forest/slides/02_cards.slide +60 -0
  217. package/skills/wecom-unified/assets/templates/editorial-forest/slides/03_data.slide +49 -0
  218. package/skills/wecom-unified/assets/templates/editorial-forest/slides/04_image.slide +46 -0
  219. package/skills/wecom-unified/assets/templates/emerald-editorial/DESIGN.preset.md +119 -0
  220. package/skills/wecom-unified/assets/templates/emerald-editorial/shell/content.jsx +18 -0
  221. package/skills/wecom-unified/assets/templates/emerald-editorial/slides/01_cover.slide +36 -0
  222. package/skills/wecom-unified/assets/templates/emerald-editorial/slides/02_section.slide +39 -0
  223. package/skills/wecom-unified/assets/templates/emerald-editorial/slides/03_data.slide +79 -0
  224. package/skills/wecom-unified/assets/templates/emerald-editorial/slides/04_steps.slide +53 -0
  225. package/skills/wecom-unified/assets/templates/grove/DESIGN.preset.md +159 -0
  226. package/skills/wecom-unified/assets/templates/grove/shell/content.jsx +18 -0
  227. package/skills/wecom-unified/assets/templates/grove/shell/content_light.jsx +18 -0
  228. package/skills/wecom-unified/assets/templates/grove/slides/01_cover.slide +26 -0
  229. package/skills/wecom-unified/assets/templates/grove/slides/02_compare.slide +92 -0
  230. package/skills/wecom-unified/assets/templates/grove/slides/03_table.slide +68 -0
  231. package/skills/wecom-unified/assets/templates/index.json +280 -0
  232. package/skills/wecom-unified/assets/templates/long-table/DESIGN.preset.md +135 -0
  233. package/skills/wecom-unified/assets/templates/long-table/shell/content.jsx +36 -0
  234. package/skills/wecom-unified/assets/templates/long-table/slides/01_cover.slide +71 -0
  235. package/skills/wecom-unified/assets/templates/long-table/slides/02_cards.slide +72 -0
  236. package/skills/wecom-unified/assets/templates/long-table/slides/03_timeline.slide +81 -0
  237. package/skills/wecom-unified/assets/templates/long-table/slides/04_image.slide +60 -0
  238. package/skills/wecom-unified/assets/templates/sakura-chroma/DESIGN.preset.md +121 -0
  239. package/skills/wecom-unified/assets/templates/sakura-chroma/shell/content.jsx +13 -0
  240. package/skills/wecom-unified/assets/templates/sakura-chroma/slides/01_cover.slide +54 -0
  241. package/skills/wecom-unified/assets/templates/sakura-chroma/slides/02_products.slide +134 -0
  242. package/skills/wecom-unified/assets/templates/sakura-chroma/slides/03_section.slide +30 -0
  243. package/skills/wecom-unified/assets/templates/sakura-chroma/slides/04_schedule.slide +65 -0
  244. package/skills/wecom-unified/assets/templates/signal/DESIGN.preset.md +121 -0
  245. package/skills/wecom-unified/assets/templates/signal/shell/content.jsx +18 -0
  246. package/skills/wecom-unified/assets/templates/signal/shell/content_dark.jsx +23 -0
  247. package/skills/wecom-unified/assets/templates/signal/slides/01_cover.slide +48 -0
  248. package/skills/wecom-unified/assets/templates/signal/slides/02_cards.slide +67 -0
  249. package/skills/wecom-unified/assets/templates/signal/slides/03_data.slide +68 -0
  250. package/skills/wecom-unified/references/wecomcli-calendar-agenda.md +227 -0
  251. package/skills/wecom-unified/references/wecomcli-calendar-cancel.md +108 -0
  252. package/skills/wecom-unified/references/wecomcli-calendar-create.md +238 -0
  253. package/skills/wecom-unified/references/wecomcli-calendar-freebusy.md +207 -0
  254. package/skills/wecom-unified/references/wecomcli-calendar-meeting-room.md +170 -0
  255. package/skills/wecom-unified/references/wecomcli-calendar-search.md +209 -0
  256. package/skills/wecom-unified/references/wecomcli-calendar-update.md +272 -0
  257. package/skills/wecom-unified/references/wecomcli-calendar.md +296 -0
  258. package/skills/wecom-unified/references/wecomcli-contact.md +48 -0
  259. package/skills/wecom-unified/references/wecomcli-disk.md +380 -0
  260. package/skills/wecom-unified/references/wecomcli-doc-contents-append.md +20 -0
  261. package/skills/wecom-unified/references/wecomcli-doc-contents-overwrite.md +27 -0
  262. package/skills/wecom-unified/references/wecomcli-doc-create.md +162 -0
  263. package/skills/wecom-unified/references/wecomcli-doc-manage-doc-members-update.md +24 -0
  264. package/skills/wecom-unified/references/wecomcli-doc-manage-doc-names-update.md +20 -0
  265. package/skills/wecom-unified/references/wecomcli-doc-manage-doc-rules-update.md +22 -0
  266. package/skills/wecom-unified/references/wecomcli-doc-manage.md +127 -0
  267. package/skills/wecom-unified/references/wecomcli-doc.md +135 -0
  268. package/skills/wecom-unified/references/wecomcli-email-forward-mail.md +131 -0
  269. package/skills/wecom-unified/references/wecomcli-email-get-mail.md +187 -0
  270. package/skills/wecom-unified/references/wecomcli-email-reply-mail.md +138 -0
  271. package/skills/wecom-unified/references/wecomcli-email-search-mail.md +114 -0
  272. package/skills/wecom-unified/references/wecomcli-email-security.md +52 -0
  273. package/skills/wecom-unified/references/wecomcli-email-send-mail.md +186 -0
  274. package/skills/wecom-unified/references/wecomcli-email-send-schedule.md +83 -0
  275. package/skills/wecom-unified/references/wecomcli-email.md +206 -0
  276. package/skills/wecom-unified/references/wecomcli-media.md +89 -0
  277. package/skills/wecom-unified/references/wecomcli-meeting-cancel.md +113 -0
  278. package/skills/wecom-unified/references/wecomcli-meeting-create.md +167 -0
  279. package/skills/wecom-unified/references/wecomcli-meeting-list.md +228 -0
  280. package/skills/wecom-unified/references/wecomcli-meeting-original-get.md +101 -0
  281. package/skills/wecom-unified/references/wecomcli-meeting-search.md +176 -0
  282. package/skills/wecom-unified/references/wecomcli-meeting-update.md +217 -0
  283. package/skills/wecom-unified/references/wecomcli-meeting.md +366 -0
  284. package/skills/wecom-unified/references/wecomcli-message.md +190 -0
  285. package/skills/wecom-unified/references/wecomcli-pptx-component-animation.md +62 -0
  286. package/skills/wecom-unified/references/wecomcli-pptx-component-box.md +102 -0
  287. package/skills/wecom-unified/references/wecomcli-pptx-component-chart.md +261 -0
  288. package/skills/wecom-unified/references/wecomcli-pptx-component-codeblock.md +70 -0
  289. package/skills/wecom-unified/references/wecomcli-pptx-component-diagram.md +54 -0
  290. package/skills/wecom-unified/references/wecomcli-pptx-component-faicon.md +71 -0
  291. package/skills/wecom-unified/references/wecomcli-pptx-component-hyperlink.md +55 -0
  292. package/skills/wecom-unified/references/wecomcli-pptx-component-image.md +107 -0
  293. package/skills/wecom-unified/references/wecomcli-pptx-component-math.md +65 -0
  294. package/skills/wecom-unified/references/wecomcli-pptx-component-qrcode.md +22 -0
  295. package/skills/wecom-unified/references/wecomcli-pptx-component-slide.md +74 -0
  296. package/skills/wecom-unified/references/wecomcli-pptx-component-svg.md +95 -0
  297. package/skills/wecom-unified/references/wecomcli-pptx-component-table.md +72 -0
  298. package/skills/wecom-unified/references/wecomcli-pptx-component-text.md +96 -0
  299. package/skills/wecom-unified/references/wecomcli-pptx-content-contract.md +73 -0
  300. package/skills/wecom-unified/references/wecomcli-pptx-create-from-material.md +67 -0
  301. package/skills/wecom-unified/references/wecomcli-pptx-create-from-scratch.md +178 -0
  302. package/skills/wecom-unified/references/wecomcli-pptx-create-from-template.md +123 -0
  303. package/skills/wecom-unified/references/wecomcli-pptx-design-principle.md +65 -0
  304. package/skills/wecom-unified/references/wecomcli-pptx-government-contract.md +40 -0
  305. package/skills/wecom-unified/references/wecomcli-pptx-human-alignment.md +140 -0
  306. package/skills/wecom-unified/references/wecomcli-pptx-pptx-api.md +161 -0
  307. package/skills/wecom-unified/references/wecomcli-pptx-pptx-edit.md +37 -0
  308. package/skills/wecom-unified/references/wecomcli-pptx-story-principle.md +184 -0
  309. package/skills/wecom-unified/references/wecomcli-pptx-templates-README.md +165 -0
  310. package/skills/wecom-unified/references/wecomcli-pptx-templates-anti-ai-slop.md +52 -0
  311. package/skills/wecom-unified/references/wecomcli-pptx.md +158 -0
  312. package/skills/wecom-unified/references/wecomcli-sheet-conditional-formatting.md +203 -0
  313. package/skills/wecom-unified/references/wecomcli-sheet-filter.md +179 -0
  314. package/skills/wecom-unified/references/wecomcli-sheet-float-image.md +235 -0
  315. package/skills/wecom-unified/references/wecomcli-sheet-formulas.md +71 -0
  316. package/skills/wecom-unified/references/wecomcli-sheet-history.md +118 -0
  317. package/skills/wecom-unified/references/wecomcli-sheet-protection.md +170 -0
  318. package/skills/wecom-unified/references/wecomcli-sheet-range-operations.md +306 -0
  319. package/skills/wecom-unified/references/wecomcli-sheet-read-data.md +151 -0
  320. package/skills/wecom-unified/references/wecomcli-sheet-search-replace.md +121 -0
  321. package/skills/wecom-unified/references/wecomcli-sheet-structure-operations.md +394 -0
  322. package/skills/wecom-unified/references/wecomcli-sheet-style.md +246 -0
  323. package/skills/wecom-unified/references/wecomcli-sheet-table-style.md +199 -0
  324. package/skills/wecom-unified/references/wecomcli-sheet-validation.md +217 -0
  325. package/skills/wecom-unified/references/wecomcli-sheet-visual-standards.md +166 -0
  326. package/skills/wecom-unified/references/wecomcli-sheet-workbook.md +264 -0
  327. package/skills/wecom-unified/references/wecomcli-sheet-write-cells.md +320 -0
  328. package/skills/wecom-unified/references/wecomcli-sheet-xlsx-process.md +324 -0
  329. package/skills/wecom-unified/references/wecomcli-sheet.md +96 -0
  330. package/skills/wecom-unified/references/wecomcli-smartpage-data-driven-pages.md +50 -0
  331. package/skills/wecom-unified/references/wecomcli-smartpage-edit.md +526 -0
  332. package/skills/wecom-unified/references/wecomcli-smartpage-formula-arraylist.md +369 -0
  333. package/skills/wecom-unified/references/wecomcli-smartpage-formula-datetime.md +283 -0
  334. package/skills/wecom-unified/references/wecomcli-smartpage-formula-logic.md +247 -0
  335. package/skills/wecom-unified/references/wecomcli-smartpage-formula-math.md +362 -0
  336. package/skills/wecom-unified/references/wecomcli-smartpage-formula-operators.md +246 -0
  337. package/skills/wecom-unified/references/wecomcli-smartpage-formula-pageblock.md +76 -0
  338. package/skills/wecom-unified/references/wecomcli-smartpage-formula-reference.md +192 -0
  339. package/skills/wecom-unified/references/wecomcli-smartpage-formula-templates.md +410 -0
  340. package/skills/wecom-unified/references/wecomcli-smartpage-formula-text.md +377 -0
  341. package/skills/wecom-unified/references/wecomcli-smartpage-formula-user.md +22 -0
  342. package/skills/wecom-unified/references/wecomcli-smartpage-mdx-syntax.md +739 -0
  343. package/skills/wecom-unified/references/wecomcli-smartpage.md +179 -0
  344. package/skills/wecom-unified/references/wecomcli-smartsheet-chart-types.md +95 -0
  345. package/skills/wecom-unified/references/wecomcli-smartsheet-common.md +160 -0
  346. package/skills/wecom-unified/references/wecomcli-smartsheet-edit.md +609 -0
  347. package/skills/wecom-unified/references/wecomcli-smartsheet-field-types.md +438 -0
  348. package/skills/wecom-unified/references/wecomcli-smartsheet-formula.md +845 -0
  349. package/skills/wecom-unified/references/wecomcli-smartsheet-read.md +411 -0
  350. package/skills/wecom-unified/references/wecomcli-smartsheet-record-values.md +218 -0
  351. package/skills/wecom-unified/references/wecomcli-smartsheet-template-ai_efficiency.md +709 -0
  352. package/skills/wecom-unified/references/wecomcli-smartsheet-template-connect_to_app.md +380 -0
  353. package/skills/wecom-unified/references/wecomcli-smartsheet-template-financial_accounting.md +369 -0
  354. package/skills/wecom-unified/references/wecomcli-smartsheet-template-hr_and_administration.md +475 -0
  355. package/skills/wecom-unified/references/wecomcli-smartsheet-template-ledger_records.md +156 -0
  356. package/skills/wecom-unified/references/wecomcli-smartsheet-template-manufacturing.md +395 -0
  357. package/skills/wecom-unified/references/wecomcli-smartsheet-template-marketing.md +186 -0
  358. package/skills/wecom-unified/references/wecomcli-smartsheet-template-office_essentials.md +299 -0
  359. package/skills/wecom-unified/references/wecomcli-smartsheet-template-personal_efficiency.md +70 -0
  360. package/skills/wecom-unified/references/wecomcli-smartsheet-template-procurement_logistics.md +325 -0
  361. package/skills/wecom-unified/references/wecomcli-smartsheet-template-project_management.md +564 -0
  362. package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_customer.md +222 -0
  363. package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_ops.md +105 -0
  364. package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_project.md +109 -0
  365. package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_research.md +92 -0
  366. package/skills/wecom-unified/references/wecomcli-smartsheet-template-sales_and_operations.md +446 -0
  367. package/skills/wecom-unified/references/wecomcli-smartsheet-template-store_management.md +431 -0
  368. package/skills/wecom-unified/references/wecomcli-smartsheet-template-team_tasks.md +274 -0
  369. package/skills/wecom-unified/references/wecomcli-smartsheet-template-wechat_customer.md +384 -0
  370. package/skills/wecom-unified/references/wecomcli-smartsheet-template-work_report.md +100 -0
  371. package/skills/wecom-unified/references/wecomcli-smartsheet-templates.md +53 -0
  372. package/skills/wecom-unified/references/wecomcli-smartsheet-view-types.md +373 -0
  373. package/skills/wecom-unified/references/wecomcli-smartsheet-webhook-examples.md +176 -0
  374. package/skills/wecom-unified/references/wecomcli-smartsheet-webhook.md +186 -0
  375. package/skills/wecom-unified/references/wecomcli-smartsheet.md +147 -0
  376. package/skills/wecom-unified/references/wecomcli-todo-create.md +137 -0
  377. package/skills/wecom-unified/references/wecomcli-todo-delete.md +63 -0
  378. package/skills/wecom-unified/references/wecomcli-todo-finish.md +72 -0
  379. package/skills/wecom-unified/references/wecomcli-todo-get.md +69 -0
  380. package/skills/wecom-unified/references/wecomcli-todo-list.md +136 -0
  381. package/skills/wecom-unified/references/wecomcli-todo-update.md +112 -0
  382. package/skills/wecom-unified/references/wecomcli-todo.md +68 -0
  383. package/skills/wecom-unified/scripts/build_docx.py +1274 -0
  384. package/skills/wecom-unified/scripts/build_page.py +2449 -0
  385. package/skills/wecom-unified/scripts/collect.py +868 -0
  386. package/skills/wecom-unified/scripts/doc_image_extractor.py +498 -0
  387. package/skills/wecom-unified/scripts/pptx2image.py +268 -0
  388. package/skills/wecom-unified/scripts/recalc.py +403 -0
  389. package/systemd/wezard.service.template +6 -0
  390. package/web/chat.css +70 -273
  391. package/web/chat.js +2228 -2190
  392. package/dist/daemon/chat-log.js +0 -130
  393. package/dist/daemon/chat-log.js.map +0 -1
  394. package/dist/daemon/dispatch.js +0 -6
  395. package/dist/daemon/dispatch.js.map +0 -1
  396. package/dist/daemon/idle-nudge.js +0 -69
  397. package/dist/daemon/idle-nudge.js.map +0 -1
  398. package/dist/daemon/message-events.js +0 -1083
  399. package/dist/daemon/message-events.js.map +0 -1
  400. package/dist/daemon/pending-items.js +0 -160
  401. package/dist/daemon/pending-items.js.map +0 -1
  402. package/dist/daemon/router.js +0 -742
  403. package/dist/daemon/router.js.map +0 -1
  404. package/dist/daemon/tips.js +0 -25
  405. package/dist/daemon/tips.js.map +0 -1
  406. package/dist/daemon/wedoc.js +0 -210
  407. package/dist/daemon/wedoc.js.map +0 -1
  408. package/dist/shared/role-search.js +0 -100
  409. package/dist/shared/role-search.js.map +0 -1
  410. package/dist/shared/startup-notice.js +0 -21
  411. package/dist/shared/startup-notice.js.map +0 -1
  412. package/dist/shared/turn-state.js +0 -27
  413. package/dist/shared/turn-state.js.map +0 -1
  414. package/hooks/hooks.json +0 -16
@@ -1,9 +1,7 @@
1
1
  import { attachmentLine, inboxName, saveToInbox } from "./media.js";
2
2
  import { PRIMARY_BOT } from "../shared/config.js";
3
- import { messageId } from "./message-events.js";
4
- import { tailTurnsWithTools, peerMentionPart, renderHumanEnvelope, renderStewardHint } from "./peers.js";
5
- import { noticeSuffixFor } from "./notices.js";
6
- import { renderTail } from "../shared/reminder.js";
3
+ import { resolveCliBackend } from "../shared/cli-backends.js";
4
+ import { lastModel, tailTurnsWithTools } from "./peers.js";
7
5
  import { expandHome, sanitizeId } from "../shared/paths.js";
8
6
  import { parseWxCommand, wxCommandHandler } from "./weixin-cmd.js";
9
7
  import { tryConsumeClaim, persistClaim, ackClaim, shouldAutoClaim, ackAutoClaim, shouldBotAutoClaim, persistBotClaim, ackBotClaim } from "./claim.js";
@@ -13,10 +11,17 @@ import { computeUsage, renderUsageReport } from "./usage.js";
13
11
  import { computeAuditReport } from "./audit.js";
14
12
  import { syncProjectConfig, renderSyncReport } from "./cfg-sync.js";
15
13
  import { captureQuota, renderQuotaReport } from "./quota.js";
16
- import { tagOfKey, baseOfKey, keyOf, withTagHeader, parseTagHeader, nameTokenRe, allNames, unlinkTags, uniqueTag, displayName, tagLink, withBot, sameBot } from "../shared/session-label.js";
14
+ import { tagOfKey, baseOfKey, keyOf, withTagHeader, parseTagHeader, nameTokenRe, unlinkTags, uniqueTag, displayName, tagLink, withBot, sameBot, stripSigil } from "../shared/session-label.js";
17
15
  import { botTagOf } from "./bot-mux.js";
18
- import { chatNameOf, clearChatName, setChatName, stewardTierOf } from "./chat-name.js";
19
- import { evictStaleName, reclaimChatName, wizardStore } from "./wizard.js";
16
+ import { chatNameOf } from "./chat-name.js";
17
+ import { anchorOf, identityFieldsOf, identityOf, identityWorkspaceOf, manifestationOf, openInstance, settleName, wizardStore } from "./wizard.js";
18
+ import { stewardIdentityOf, stewardRoute as resolveSteward } from "./steward.js";
19
+ import { parseInstanceName } from "./classes.js";
20
+ import { noteNativeChannelFrame } from "./channel.js";
21
+ import { awaitChannelOfPost, channelOf, channelOfPost, postsOfChannel } from "./channel-posts.js";
22
+ import { settleChannelSteward } from "./onboarding.js";
23
+ import { applyOnboarding, bindSteward, classifyOnboardingInput, GUIDE_DESC, guideOf, guideTargetOf, judgeOnboarding, loadOnboardingStore, needsOnboarding, renderGuideOpening, renderGuideRetry, renderOnboardingDone } from "./onboarding.js";
24
+ import { isApprentice } from "./apprentice.js";
20
25
  import { truncate } from "../shared/std.js";
21
26
  import { hookModePath, readHookMode, writeHookMode } from "../shared/hook-mode.js";
22
27
  /** 判定"引用内容是否已在目标会话上下文里"时回看的轮数 —— 引用的通常是最近几轮
@@ -27,13 +32,13 @@ const QUOTE_TAIL_TURNS = 12;
27
32
  // 副机器人收到的聊天挂 `~<bot>` (bot-mux 在转发时给 body 记了是谁收的): 同一个人私聊两个机器人、
28
33
  // 同一个群里两个机器人, 是两个聊天、两套 wizard。授权不走这里 (authPrincipals 不带后缀)。
29
34
  const chatPrincipal = (msg) => withBot(msg.chattype === "group" && msg.chatid ? `chat:${msg.chatid}` : `user:${msg.from.userid}`, botTagOf(msg));
30
- // 寻址靠 wizard 的**全局名字** `.name` —— 它可能住在任何一个聊天里。
35
+ // 寻址靠 wizard 的**全局名字** —— 人点名单写作 `.name` (`🧙‍♂️ name` 同样认, 双态), 它可能住在任何一个聊天里。
31
36
  // Must be space-delimited or edge-of-string so paths / extensions like `a.ts`
32
37
  // survive. 一条消息只认**一个**路由名字, 且**只做前缀匹配**: 清洗之后 (链接标记
33
38
  // 还原成裸 `.name`、@ 已由 stripAt 剥掉、去掉开头的空白与不可见字符) 落在**消息
34
39
  // 开头**的那个 `.x` 才是目标 —— 认不认识都算 (不认识 = 叫一个新 wizard 出来)。
35
40
  // 正文里的 `.fix` / `.gitignore` 一律只是提及, 哪怕名册里真有这个名字。
36
- // 选中的那个 token 从正文里摘掉, 其余 `.foo` 原样留着 (见 peerMentions)。
41
+ // 选中的那个 token 从正文里摘掉, 其余 `.foo` 原样留着 (见 wake-tail.ts peerMentionsOf)。
37
42
  // Token 规则收在 session-label(nameTokenRe / allNames),路由与标注共用同一把尺子。
38
43
  const NAME_RE = nameTokenRe();
39
44
  const LEAD_NOISE_RE = /^[\s​-‍⁠]+/u;
@@ -45,16 +50,19 @@ const parseTag = (text) => {
45
50
  return { tag: m[2] ?? "", cleaned: lead.slice(m[0].length).replace(/[ \t]+/g, " ").trim() };
46
51
  };
47
52
  const tagOf = tagOfKey;
48
- /** 名字 → 投递目标。名册 (全局) > 在本聊天新开一个 slot。
53
+ /** 名字 → 投递目标。名册 (全局, 按身份解析到本聊天的化身) > 在本聊天新开一个 slot。
49
54
  * 新 wizard 的名字由 spawn 时 settleName 按 slot 落定。
50
55
  * 名册里那个名字归别的机器人 → 当作不认识 (落到「本聊天新开」; 名字全局唯一, settleName 会挂 `-N`)。
51
56
  * 引用气泡的 srcTag 也走这里, 同一把尺子。 */
52
- const resolveName = (base, name) => {
57
+ export const resolveName = (base, name) => {
53
58
  if (!name)
54
59
  return base;
55
60
  const rec = wizardStore()?.byName(name);
61
+ // 名字属于身份 (§2): 投递落「身份在本聊天的化身」—— 有就用本群的, 没有回落锚点化身
62
+ // (共享锚点上下文), 不自动新建。按群隔离会话是管家专用 (resolve → stewardReception);
63
+ // worker 跨群点名沿用同一会话, 不每群新开 pane (人 2026-11-17, 测试 steward-reception 钉住)。
56
64
  if (rec && sameBot(base, rec.target))
57
- return rec.target;
65
+ return manifestationOf(wizardStore(), name, base) ?? rec.target;
58
66
  const slot = name;
59
67
  // 这个 slot 已被一个改了名的 (冷) wizard 占着 → 挪到 `slot-N`, 别唤醒别人。
60
68
  const taken = new Set((wizardStore()?.all() ?? []).filter((w) => baseOfKey(w.target) === base).map((w) => tagOfKey(w.target)));
@@ -100,11 +108,22 @@ const parseUseCommand = (text) => {
100
108
  return "show";
101
109
  return arg === "cli" || arg === "wecom" ? arg : "invalid";
102
110
  };
111
+ // `/notice` 看 · `/notice clear` 清 · `/notice <文字>` 设 —— 本群 room 的公告 (账本 notice 行)。
112
+ // 保留原文 (含大小写): 公告是人写给 wizard 的话。
113
+ export const parseNoticeCommand = (text) => {
114
+ const m = /^\/notice(?:\s+([\s\S]*))?$/iu.exec(text.trim());
115
+ if (!m)
116
+ return undefined;
117
+ const arg = (m[1] ?? "").trim();
118
+ if (!arg)
119
+ return { op: "show" };
120
+ return /^(?:clear|清除|清空)$/iu.test(arg) ? { op: "clear" } : { op: "set", text: arg };
121
+ };
103
122
  // `/audit` or `/audit <name>`. A supplied name resolves only through the global wizard registry;
104
123
  // without one, the caller's own mirror binding is used.
105
124
  const parseAuditCommand = (text) => {
106
125
  const m = /^\/audit(?:\s+(.+))?$/u.exec(text.trim());
107
- return m ? { name: (m[1] ?? "").trim().replace(/^\./, "") } : undefined;
126
+ return m ? { name: stripSigil(m[1] ?? "") } : undefined;
108
127
  };
109
128
  const resolveAuditMirror = (mirrors, name, who, chatWho) => {
110
129
  if (name) {
@@ -143,20 +162,22 @@ const parseCfgSyncCommand = (text) => {
143
162
  const m = CFGSYNC_RE.exec(text.trim());
144
163
  return m ? { apply: Boolean(m[1]) } : undefined;
145
164
  };
146
- // `/name` 读, `/name x` 写, `/name -` 摘掉。名字是 chat 级的 —— 带不带 `.name`
147
- // 路由过来都命名同一个聊天, 所以这里不看路由目标。
148
- const NAME_RE_CMD = /^\/name(?:\s+(\S+))?$/i;
149
- const parseNameCommand = (text) => {
150
- const m = NAME_RE_CMD.exec(text.trim());
151
- return m ? { arg: m[1] ?? "" } : undefined;
152
- };
153
- // `/chats` — 跨聊天目录: 谁有名字、谁没有、各自跑着哪些会话。
154
- const isChatsCommand = (text) => /^\/chats?$/i.test(text.trim());
155
165
  const isUsageCommand = (text) => text.trim() === "/usage";
156
166
  const isStopCommand = (text) => /^(?:\/stop|stop)$/i.test(text.trim());
157
167
  const isKillCommand = (text) => text.trim() === "/kill";
158
168
  const isEnterCommand = (text) => text.trim() === "/n";
159
169
  const isRevealCommand = (text) => text.trim() === "/reveal";
170
+ const isModelCommand = (text) => /^\/model(?:\s|$)/i.test(text.trim());
171
+ /** `/model` 的回话: 有会话 = 转录里最近一轮真正用的模型 (绑定里的只是启动参数), 无会话 = 明说并给默认后端。 */
172
+ const renderModelReply = (text, who, info, defaultCli = "") => {
173
+ const name = displayName(who) || tagOf(who) || who;
174
+ const hasArg = text.trim().split(/\s+/).length > 1;
175
+ const tip = hasArg ? " · /model 不切换, 换模型请让 wizard 用 set_model 或改 config" : "";
176
+ if (!info)
177
+ return `[wezard] .${name} 当前无活会话${defaultCli ? `, 新会话用 ${defaultCli} 默认模型 (config 的 tiers 可按档固定)` : ""}${tip}`;
178
+ const model = (info.jsonlPath ? lastModel(info.jsonlPath) : "") || info.model || "CLI 默认 (本会话还没发过言)";
179
+ return `[wezard] .${name} 当前模型: ${model} · effort ${info.effort || "默认"} · cli ${info.cli}${tip}`;
180
+ };
160
181
  const isHelpCommand = (text) => /^\/(?:help|\?|h)$/i.test(text.trim());
161
182
  // Static command reference. Grouped: session control, usage/info. Anything
162
183
  // not matching a command is a
@@ -172,6 +193,7 @@ const renderHelp = () => [
172
193
  "`/sessions` 列出本机所有 live 会话 · `/sessions <emoji|id>` 把本聊天改接到某一个",
173
194
  "`/stop` 打断当前生成 (Esc)",
174
195
  "`/kill` 结束本会话并移除 tmux pane (下条消息自动让新的 wizard 就位)",
196
+ "`/model` 查看本会话当前模型 / effort (只读; 换模型让 wizard 用 set_model)",
175
197
  "`/n` 向 CLI 输入回车 (Enter)",
176
198
  "`/reveal` 把终端的 tmux 窗口切到本会话",
177
199
  "`/wx` 微信 ClawBot: 列出 / `bind` 扫码绑定 (每个微信号 = 一个群聊) / `unbind` (仅审批人)",
@@ -181,30 +203,30 @@ const renderHelp = () => [
181
203
  "位置参数可叠:`.docs /new opus 先读一遍 README` = 名字 + 模型 + 首句;新 pane 后端由配置决定。",
182
204
  "",
183
205
  "▎wizard",
184
- "每个 wizard 有一个**全局唯一**的名字,写作 `.name`;聊天的默认 wizard 名字就是聊天名。",
206
+ "每个 wizard 有一个**全局唯一**的名字;你点名写作 `.name`。类名是一个人的设定 (`X`), 实例地址是 `X-1`、`X-2`… (新群由引导落定)。",
185
207
  "消息里带 `.name`(如 `.docs 帮我改 README`)就是找那一个 —— 它可以住在任何一个聊天里,",
186
208
  "回复会回到你说话的这个群;不带 = 本聊天默认那个。开头写一个还不存在的 `.x` = 在这里叫出一个新的 x。",
187
- "它们的回复以 `emoji .name` 打头。`/clear .x`、`/pwd .x`、`/stop .x` 同理按名字走。",
209
+ "它们的回复以 `🧙‍♂️ name` 打头。`/clear .x`、`/pwd .x`、`/stop .x` 同理按名字走 (`🧙‍♂️ x` 写法同样认)。",
188
210
  "wizard 知道自己是谁、在哪个目录、还有谁在,也能给自己改名、写职责、记长期记忆、上下文满了自己交接重开。",
189
- "wizard 之间默认**私聊**,只有需要你知道的才发进群。",
211
+ "wizard 之间在 room 里说话: 两人私聊 / 三人以上的临时 room 只在 rolepage 看得到,说进本群的才进企微。",
190
212
  "",
191
213
  "▎分身(clone)",
192
214
  "对 AI 说「分个身去干 X」「开三个分身分头处理」即可。分身默认**继承它此刻的上下文** ——",
193
215
  "先把公共材料读进来、再分身,材料只读一遍却进了 N 份上下文;要白纸一张就说明白。",
194
- "分身有自己的 `.name`、自己的终端,也能再生分身。活干完对 AI 说「收掉它们」。",
216
+ "分身有自己的名字、自己的终端,也能再生分身。活干完对 AI 说「收掉它们」。",
195
217
  "",
196
- "▎跨聊天",
197
- "`/name <名字>` 给本聊天起名 · `/name` 查看 · `/name -` 取消",
198
- "`/chats` 列出所有已知聊天及其 wizard",
199
- "名字 1-32 位字母/数字/`_`/`-`,全机唯一;它同时就是这里默认 wizard 的名字 (撞名会自动加后缀)。",
218
+ "▎命名",
219
+ "名字由 wizard 自己起 (`wizard_identity`); 改别人用 `wizard_identity({to})` —— 直属 parent 或管家实例可改",
220
+ "类改名会同步它的全部实例 (`X-1..X-N`) 与指向它的管家绑定; 实例名 (形如 `X-3`) 不能当类名",
221
+ "名字 1-32 位字母/数字/`_`/`-`,全机唯一,跟着管家身份走 (同一管家进多个群共用一个名字)。",
200
222
  "对 AI 说「让 .fix 看一眼」「在 daily 里开个 .ingest 跑这个目录」即可。",
201
223
  "",
202
224
  "▎协作",
203
225
  "`/peers`(或 `/wizards`) 列出本聊天的 wizard:名字、职责、忙闲、谁是谁的分身",
204
226
  "同一聊天里的 wizard 互相看得见也驱动得动,直接说人话:",
205
- "「看下 `.fix` 的进展,推动它直到结束」— AI 会读它最近的对话、派活、收它的回执直到跑完。",
206
- "「让 `.fix` 和 `.review` 互相迭代到 review 说 LGTM」— AI 会把它们串成一条循环流水线。",
207
- "它们之间的往来默认只进各自的 rolepage;需要你知道的 (公开讨论、结论) 才发进群;工单的派活与回执不进群。",
227
+ "「看下 `.fix` 的进展,推动它直到结束」— AI 会看它卡在哪、追问它,等它交代做完为止。",
228
+ "「让 `.fix` 和 `.review` 互相迭代到 review 说 LGTM」— AI 会开一个跟进 room 让两边来回返修,直到通过。",
229
+ "派活、追问与交代走它们之间的 room,只在 rolepage 看得到;结论由你叫的那个 wizard 在群里交代。",
208
230
  "",
209
231
  "▎信息 (免授权)",
210
232
  "`/id` 查看会话/权限 id",
@@ -218,6 +240,9 @@ const renderHelp = () => [
218
240
  "▎审批",
219
241
  "`/use cli` 审批交给你本地 CLI 的权限框 (企微卡停用) · `/use wecom` 交回企微 · `/use` 看当前",
220
242
  "",
243
+ "▎群公告",
244
+ "`/notice <文字>` 设本群公告 (最多 500 字, 群里的 wizard 都会知道) · `/notice` 看当前 · `/notice clear` 清除",
245
+ "",
221
246
  "▎引用 (quote)",
222
247
  "引用消息 + 新文字:被引用内容作为上下文前缀附在你的话前。",
223
248
  "纯引用不加字:把被引用内容当正文重发 —— 微信会去重相同文本,",
@@ -304,20 +329,6 @@ const renderPeers = (peers, chatName) => {
304
329
  ].join("\n");
305
330
  };
306
331
  // /chats — 跨聊天目录: 每个聊天里住着哪些 wizard (`.name`, 全局可达)。
307
- const renderChats = (roster) => {
308
- if (roster.length === 0)
309
- return "[wezard] 还没有任何聊天在跑会话。";
310
- const rows = roster.flatMap((c) => {
311
- const sessions = c.targets.map((t) => tagLink(t, `.${displayName(t) || "?"}`)).join(" · ") || "(无)";
312
- const head = c.name ? `\`${c.name}\`` : `_(未命名)_ \`${c.base}\``;
313
- return [`**${head}**${c.self ? " ⬅️ 本聊天" : ""} · ${c.targets.length} 个会话`, ` ${sessions}`, ""];
314
- });
315
- return [
316
- `[wezard] 已知的聊天 · ${roster.length} 个`,
317
- "",
318
- ...rows,
319
- ].join("\n");
320
- };
321
332
  // Match a switch arg against a scanned session: animal emoji label, full
322
333
  // sessionId, or a ≥6 char sessionId prefix. Returns the session or undefined.
323
334
  const matchSession = (sessions, arg) => sessions.find((s) => s.label === arg) ??
@@ -351,6 +362,10 @@ const stripName = (text, name) => text
351
362
  // DMs can't @ a bot — any "@" the user types is content (e.g. "@src/foo.ts"),
352
363
  // so name detection is group-only. 配置里写死的名字 (`wrc.botNames`) 则任何
353
364
  // 场景都剥: 单聊里手打 "@wezard /usage" 同样不该漏进 prompt。
365
+ /** 下面各有 message.<type> 监听的 msgtype —— 与 SDK handleMessageCallback 的 switch 对齐。 */
366
+ const ROUTED_MSGTYPES = new Set(["text", "image", "mixed", "voice", "file", "video"]);
367
+ /** 不是人发的一句话, 不回「暂不支持」(stream 是流式刷新回调, event 正常走事件通道)。 */
368
+ const NO_REPLY_MSGTYPES = new Set(["stream", "event"]);
354
369
  const isGroup = (msg) => msg.chattype === "group" && !!msg.chatid;
355
370
  const BUILTIN_BOT_NAMES = ["wezard"];
356
371
  const maybeStripMentions = (names, msg, text) => {
@@ -423,11 +438,11 @@ const canonContains = (haystack, needle) => {
423
438
  const isLastResponseQuote = (target, quoted) => canonContains(getLastResponse(target) ?? "", quoted);
424
439
  // ── 引用即路由 ─────────────────────────────────────────────────────────
425
440
  // 群里要跟 `.fix` 说话,手打名字太慢 —— 直接引用它的气泡即可。每条出站气泡都
426
- // 带 `emoji .name` 头 (withTagHeader),所以引用文本自带路由信息;用户自己发的
441
+ // 带 `🧙‍♂️ name:` 头 (withTagHeader; 旧气泡是 `.name:`, 双态都认),所以引用文本自带路由信息;用户自己发的
427
442
  // 行首 `.fix 干活` 同样算数(限行首,否则正文里随手写的 .gitignore 会误判)。
428
443
  // `body` 是剥掉头/tag 后的净引用内容,用于跟目标 context 比对。
429
444
  // `tag` = 路由目标(引用继承的投递 tag)。
430
- // `srcTag` = 引用气泡真正出自哪个会话 —— 仅 bot 气泡可知(反解 `emoji .name` 头)。
445
+ // `srcTag` = 引用气泡真正出自哪个会话 —— 仅 bot 气泡可知(反解 `🧙‍♂️ name:` / `.name:` 头)。
431
446
  // 去重要比对的是「内容在不在源会话」,而非路由目标: 带着引用新建 /
432
447
  // 改投到别的 tag 时,目标会话是空的,只有源会话里才有那段原文。
433
448
  // `srcTag===undefined` 表示源未知(用户自己打的引用),回退到按目标查。
@@ -509,7 +524,7 @@ const downloadToInbox = async (deps, url, aesKey, msgid, index, attempt = 0) =>
509
524
  return attempt < 1 ? downloadToInbox(deps, url, aesKey, msgid, index, attempt + 1) : undefined;
510
525
  }
511
526
  };
512
- export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guardCharter) => {
527
+ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guardCharter, opts = {}) => {
513
528
  const inboxDir = expandHome(cfg.wrc.mirror.inboxDir);
514
529
  // 已知的机器人名只随配置变; 下面所有入站路径共用这一个剥离器。
515
530
  const botNames = [...BUILTIN_BOT_NAMES, ...cfg.wrc.botNames.filter(Boolean)];
@@ -524,8 +539,8 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
524
539
  // `.docs` → window `docs`, not the principal slug).
525
540
  // On success there is NO reply: newSession already pushed the single
526
541
  // "created + cwd" bubble. Only failures produce user-facing text.
527
- const spawnSession = async (who, silent, model) => {
528
- const r = await bridge.newSession(who, displayName(who) || tagOf(who) || who, { silent, model });
542
+ const spawnSession = async (who, silent, model, cwd) => {
543
+ const r = await bridge.newSession(who, displayName(who) || tagOf(who) || who, { silent, model, ...(cwd ? { cwd } : {}) });
529
544
  return r.ok ? {} : { err: `[wezard] /new failed: ${r.reason ?? "unknown"}` };
530
545
  };
531
546
  // 同一 wizard 的两条消息会并发落进 gate,双双判定「未附着」→ 双 spawn,后者
@@ -541,36 +556,28 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
541
556
  return next;
542
557
  };
543
558
  // 显式 /new:排队但仍强制重开(用户就是要换一个)。
544
- // 默认会话先把名字换回聊天名, 再 spawn —— charter 在 spawn 时按名字渲染。
545
- // 聊天名若被一个静默超过一天的 wizard 占着, 先顶掉它 —— 否则默认会话只能退避成 `-N`。
546
- const staleDeps = {
547
- lastActivity: (t) => bridge.lastActivity(t),
548
- retire: (t) => bridge.killPane(t),
549
- };
550
559
  // 新开的 slot 先按人写的名字落名: slot 只是内部 id, 被一个改过名的冷 wizard 占着
551
560
  // 时会挪成 `foo-N` —— 名字不该跟着它退避。已有名字的 wizard 不受影响 (claim 不改)。
561
+ // 聊天名已冻结为显示标签 (2026-11-16): 名字不再跟着聊天名走 —— 名册有就用名册的,
562
+ // 没有留给新群引导 / wizard_identity 去起。
552
563
  const claimAsked = (who, asked) => {
553
564
  if (asked)
554
565
  wizardStore()?.claim(who, asked);
555
566
  };
556
567
  const autoSpawnAndAttach = (who, asked, model) => serializeSpawn(who, async () => {
557
568
  claimAsked(who, asked);
558
- const chat = chatNameOf(cfg, who);
559
- if (chat && !tagOf(who)) {
560
- const gone = await evictStaleName(wizardStore(), chat, [who], staleDeps);
561
- if (gone)
562
- log.info({ target: gone.target, name: gone.name }, "stale name evicted by /new");
563
- }
564
- reclaimChatName(wizardStore(), chat, who);
565
- return spawnSession(who, false, model);
569
+ settleName(wizardStore(), chatNameOf(cfg, who), who);
570
+ // 管家化身 (/new 或裸消息首条) 落在身份的工作区 (引导落的身份级 workspace,
571
+ // 或锚点会话的 live cwd), 不落兜底目录。
572
+ return spawnSession(who, false, model, freshSteward.get(who) || identityWorkspaceOf(wizardStore(), who) || undefined);
566
573
  });
567
574
  // 隐式建会话(新 `.name` 的第一条消息):轮到自己时若前一条已经把会话建好,直接
568
575
  // 复用,不再 respawn —— 否则先到的消息会被注入进一个刚被杀掉的 pane。
569
- const ensureSession = (who, asked) => serializeSpawn(who, async () => {
576
+ const ensureSession = (who, asked, cwd) => serializeSpawn(who, async () => {
570
577
  if (bridge.hasMirrorTarget(who))
571
578
  return {};
572
579
  claimAsked(who, asked);
573
- return spawnSession(who, true);
580
+ return spawnSession(who, true, undefined, cwd);
574
581
  });
575
582
  // Prefix user-visible daemon replies with `<emoji> .name`, so a chat hosting
576
583
  // several wizards stays visually disambiguated. Emoji is derived from the
@@ -582,6 +589,16 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
582
589
  }
583
590
  catch { /* ignore */ }
584
591
  };
592
+ // daemon 自己的系统行 (会话边界确认 / 失败回执): 不署名头, 以 `[wezard]` 起头。
593
+ // 那个前缀不是装饰 —— 严格群的出站门 (mirror-bridge 的 sendStandalone) 只放行
594
+ // `[wezard]`/`[mirror]` 系统提示, 所以这条既是给人看的来源记号, 也是「这不是
595
+ // 模型发言」的判据。直发 replyStream, 与 /help /pwd 同一条不经门的口子。
596
+ const replySystem = async (frame, msg, text) => {
597
+ try {
598
+ await client.replyStream(frame, msg.msgid, text, true);
599
+ }
600
+ catch { /* ignore */ }
601
+ };
585
602
  // Common gating: claim bootstrap + allowFrom check. Returns true if the
586
603
  // caller should stop (claim consumed or message rejected).
587
604
  const gate = async (frame, msg, text, who, asked = "") => {
@@ -706,6 +723,26 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
706
723
  catch { /* ignore */ }
707
724
  return { stop: true };
708
725
  }
726
+ // Authorized `/notice [clear|<文字>]` — 本群 room 的公告; 人在绑定 room 里改的就是这个 room 的。
727
+ const notice = parseNoticeCommand(text);
728
+ if (notice) {
729
+ const base = baseOfKey(who);
730
+ if (notice.op === "show") {
731
+ const cur = opts.getNotice?.(base);
732
+ await replyText(frame, msg, who, cur ? `📌 群公告: ${cur}` : "📌 本群还没有公告 · `/notice <文字>` 设置");
733
+ return { stop: true };
734
+ }
735
+ const r = opts.setNotice
736
+ ? opts.setNotice(base, notice.op === "clear" ? "" : notice.text, { kind: "human", id: String(msg.from.userid) })
737
+ : { ok: false, reason: "room 接线还没就绪, 稍后再试" };
738
+ log.info({ who, op: notice.op, ok: r.ok }, "/notice");
739
+ // 成功时群里已有 daemon 的系统行 (📌 群公告…), 不再另回; 没变化 / 失败才答一句。
740
+ if (!r.ok)
741
+ await replyText(frame, msg, who, `[wezard] /notice 没生效: ${r.reason}`);
742
+ else if (!r.changed)
743
+ await replyText(frame, msg, who, notice.op === "clear" ? "📌 本群本来就没有公告" : "📌 公告没变");
744
+ return { stop: true };
745
+ }
709
746
  // Authorized `/use [cli|wecom]` — 审批 hook 的裁决权在企微卡片与本地 CLI 之间
710
747
  // 切换。写一个状态文件, 不改 hook 注册, 对已在跑的会话即刻生效。
711
748
  const use = parseUseCommand(text);
@@ -764,11 +801,24 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
764
801
  // picks which wizard (re)spawns; the name is also the tmux window name.
765
802
  const nu = parseNewCommand(text);
766
803
  if (nu) {
804
+ // 学徒 (§7) 是连续身份、唯一会话: /new 不换会话, 改为「整理记忆 + 原会话继续」。
805
+ if (isApprentice(wizardStore(), who)) {
806
+ const { err } = await ensureSession(who, asked, cfg.wrc.apprentice.workspace);
807
+ if (err) {
808
+ await replyText(frame, msg, who, err);
809
+ return { stop: true };
810
+ }
811
+ await send(frame, msg, who, "[系统] /new 已拦: 学徒是连续身份、唯一会话, 不换会话。请整理记忆 (值得跨会话留下的用 wizard_remember 记下) 后在原会话继续; 上下文紧张用 handoff 压简报, 会话与身份不变。");
812
+ return { stop: true };
813
+ }
767
814
  const { err } = await autoSpawnAndAttach(who, asked, nu.model);
768
815
  if (err) {
769
816
  await replyText(frame, msg, who, err);
770
817
  return { stop: true };
771
818
  }
819
+ // room 口径 (fix-task §8.3): /new 的会话边界确认只有一种形态, 由 mirror 的
820
+ // pushProjectInfo 发 (createdAck, 不带系统前缀); daemon 这里不再补发 —— 出站门
821
+ // 已废, 老的「严格群被静音要补一条」的前提不存在了。
772
822
  // 带正文的 `/new`: 这段就是新会话的第一句。走和「隐式建会话后 fall through」
773
823
  // 完全相同的 dispatch 路径 —— freshSpawn 的冷时序、peer 提示都在那里。
774
824
  if (nu.prompt)
@@ -797,10 +847,22 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
797
847
  // and drop the binding (no `--resume` resurrection). Routed by `.name` like
798
848
  // /stop, so `/kill #docs` only takes down that sibling.
799
849
  if (isKillCommand(text)) {
850
+ // 学徒 (§7) 不可退役: /kill 会去掉绑定且不复活, 对学徒是身份谋杀。
851
+ if (isApprentice(wizardStore(), who)) {
852
+ await replyText(frame, msg, who, "学徒是连续身份, 不可 /kill —— pane 死了会带着记忆同身份重生; 要停它这一轮用 /stop。");
853
+ return { stop: true };
854
+ }
800
855
  const r = await bridge.killPane(who);
801
856
  await replyText(frame, msg, who, r.ok ? "🗑️ 会话已结束,pane 已移除" : `[wezard] /kill failed: ${r.reason ?? "unknown"}`);
802
857
  return { stop: true };
803
858
  }
859
+ // `/model`: 原样注入 pane 会让 TUI 弹出交互式模型选择器, 把 pane 卡死 —— 所以绝不注入。
860
+ // 由 daemon 自己查「接待 wizard」(who = 这条消息会路由到的会话) 此刻真正在跑的模型回一行;
861
+ // 带参数不切换, 换模型走 MCP set_model / config (内部能力不变)。
862
+ if (isModelCommand(text)) {
863
+ await replyText(frame, msg, who, renderModelReply(text, who, bridge.sessionInfo(who), resolveCliBackend(cfg.wrc).name));
864
+ return { stop: true };
865
+ }
804
866
  // Authorized `/n` — send a bare Enter to the live pane. Confirms a prompt /
805
867
  // dismisses a "press enter to continue", or submits whatever's already in
806
868
  // the input box. Bails cleanly when no attachment.
@@ -834,42 +896,6 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
834
896
  await replyText(frame, msg, who, body);
835
897
  return { stop: true };
836
898
  }
837
- // /name [x|-] — 给本聊天起名,作为跨聊天操作使用的可读聊天名。
838
- // 名字写进 config.jsonc 而不是运行时 state; 改名即覆盖,一个聊天只留一个名字,
839
- // 一个名字只归一个聊天。
840
- const nc = parseNameCommand(text);
841
- if (nc) {
842
- const cur = chatNameOf(cfg, who);
843
- if (!nc.arg) {
844
- await replyText(frame, msg, who, cur
845
- ? `[wezard] 本聊天名为 \`${cur}\``
846
- : "[wezard] 本聊天还没起名。");
847
- return { stop: true };
848
- }
849
- // 聊天名进宪章 (home 群、管家那节的 config_set 路径): 过宪章守卫, 受影响的 wizard 被提醒 handoff。
850
- if (nc.arg === "-") {
851
- const { r: gone } = guardCharter(() => clearChatName(cfg, sourcePath, who), (g) => g ? { what: `人 \`/name -\` 取消了聊天名 \`${g}\``, byHuman: true } : undefined);
852
- await replyText(frame, msg, who, gone ? `[wezard] 已取消命名 \`${gone}\`` : "[wezard] 本聊天本来就没起名。");
853
- return { stop: true };
854
- }
855
- // 聊天名就是默认 wizard 的名字: 人起名即改名 (撞名照 pickName 挂 `-N`), tmux 窗口跟着换。
856
- const home = baseOfKey(who);
857
- const { r: [r, wiz] } = guardCharter(() => {
858
- const r = setChatName(cfg, sourcePath, who, nc.arg);
859
- return [r, r.ok ? wizardStore()?.rename(home, r.name) : undefined];
860
- }, ([r]) => r.ok && r.name !== cur ? { what: `人 \`/name ${r.name}\` 把聊天${cur ? ` \`${cur}\`` : ""}改名为 \`${r.name}\``, byHuman: true } : undefined);
861
- if (wiz)
862
- void bridge.retitlePane(home);
863
- await replyText(frame, msg, who, r.ok
864
- ? `[wezard] ✅ 本聊天更名为 \`${r.name}\`${cur && cur !== r.name ? `(原 \`${cur}\`)` : ""}${wiz && wiz !== r.name ? `; 默认 wizard 名 \`.${wiz}\` (\`.${r.name}\` 已被占)` : ""}`
865
- : `[wezard] /name failed: ${r.reason}`);
866
- return { stop: true };
867
- }
868
- // /chats — 跨聊天目录:谁有名字、各自跑着哪些会话。Read-only。
869
- if (isChatsCommand(text)) {
870
- await replyText(frame, msg, who, renderChats(bridge.chatRoster(who).filter((c) => sameBot(who, c.base))));
871
- return { stop: true };
872
- }
873
899
  // /peers — this chat's own wizard roster (default + siblings), with
874
900
  // live busy state. Read-only.
875
901
  if (isPeersCommand(text)) {
@@ -923,8 +949,14 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
923
949
  // sender is already in allowFrom, we treat that authorization as license
924
950
  // to auto-spawn: this inbound becomes both the binding signal and the
925
951
  // first prompt — attach, then fall through to dispatch.
926
- if (text.trimStart().startsWith("/") && !bridge.hasMirrorTarget(who)) {
927
- const { err } = await ensureSession(who, asked);
952
+ // v3 §3: 管家接待的新化身与 slash 命令同权 —— 裸消息也是该聊天的第一条消息,
953
+ // 直接在身份的工作区里起 pane, 不再回「还没有会话 — 发 /new」。其余 named slot
954
+ // 照旧 (点一个名字 ≠ 创建它, 创建走 spawn 的 409-clash 路径)。
955
+ // 学徒的首触同样在这里起 pane (工作区 = wrc.apprentice.workspace) —— 之后 pane 死亡由
956
+ // dispatch 的 --resume 自动同身份重生 (§7), 不再走这条。
957
+ const apprenticeHere = isApprentice(wizardStore(), who);
958
+ if (!bridge.hasMirrorTarget(who) && (text.trimStart().startsWith("/") || freshSteward.has(who) || apprenticeHere)) {
959
+ const { err } = await ensureSession(who, asked, freshSteward.get(who) || identityWorkspaceOf(wizardStore(), who) || (apprenticeHere ? cfg.wrc.apprentice.workspace : undefined));
928
960
  if (err) {
929
961
  await replyText(frame, msg, who, err);
930
962
  return { stop: true };
@@ -959,51 +991,213 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
959
991
  log.info({ target, jsonl, tailLen: tail.length, quotedLen: quoted.length, hit }, "quoteInContext: tail check");
960
992
  return hit;
961
993
  };
962
- // 路由用掉的那个 `.name` 已被 parseTag 摘走,正文里剩下的每个 `.x` 都可能是
963
- // 用户在指另一个 wizard。解析走 bridge 自己的 resolvePeerTag —— peer 工具用的
964
- // 同一套(全局名册),所以标注出来的地址一定是 peek_peer/send_peer 打得中的;
965
- // 解析不到的 `.foo` 与自指静默略过。
966
- const peerMentions = (who, text) => {
967
- const mb = bridge;
968
- const seen = new Set();
969
- return allNames(text).flatMap((name) => {
970
- const r = mb.resolvePeerTag(who, name);
971
- if (!r.ok || r.target === who || seen.has(r.target))
972
- return [];
973
- seen.add(r.target);
974
- const { runningCwd, defaultCwd } = mb.getCwd(r.target);
975
- return [{
976
- tag: name,
977
- target: r.target,
978
- chat: chatNameOf(cfg, r.target),
979
- foreign: r.foreign,
980
- job: wizardStore()?.get(r.target)?.description ?? "",
981
- cwd: runningCwd || defaultCwd,
982
- }];
983
- });
984
- };
985
994
  // 名字 → 它指向谁。哪个 `.x` 是路由不在这里定: parseTag 只认消息开头那一个。
986
- const resolve = (base, name) => resolveName(base, name);
995
+ // 裸消息 (name = "") 走管家接待 (§3): 绑定的管家身份在本群的化身; 解析要新开化身时先落记录
996
+ // (名字/身份/种类来自身份锚点), 会话由 gate 的 ensureSession 在身份的工作区里起。
997
+ const freshSteward = new Map(); // target → 新化身的工作区 (identity workspace)
998
+ /** 在 base 新开一条身份化身 —— 管家接待与「点类名」走同一条路 (人 2026-11-18):
999
+ * 身份有类 → 领一个序号 (allocOrdinal, 永不复用), 名字 `<类名>-<N>`, target 用实例名
1000
+ * (uniqueTag 防撞), 记录带 identity=类 id / ordinal, 并继承类的字段;
1001
+ * 没有类 → 旧行为 (锚点的名字 + 身份级字段)。返回落定的 target。 */
1002
+ const openManifestation = (base, fresh, wantTarget) => {
1003
+ const store = wizardStore();
1004
+ if (!store)
1005
+ return wantTarget;
1006
+ const cls = fresh.classId ? store.classes?.get(fresh.classId) : undefined;
1007
+ if (cls) {
1008
+ // 领号 / 落名 / 继承类字段都在 wizard.openInstance 里 (同一把尺子给「点类名」复用)。
1009
+ const target = openInstance(store, base, cls.id, fresh.kind ?? "steward");
1010
+ if (target) {
1011
+ freshSteward.set(target, cls.workspace);
1012
+ log.info({ base, target, classId: cls.id }, "class: new instance registered");
1013
+ return target;
1014
+ }
1015
+ }
1016
+ // 身份级字段 (职责 / 专长 / 记忆 / 角色) 从锚点带过来: 新化身是同一个身份在不同群的
1017
+ // 又一条记录, 不是一张白纸。
1018
+ const inherited = identityFieldsOf(anchorOf(store, fresh.identity));
1019
+ store.upsert(wantTarget, { ...inherited, identity: fresh.identity, name: fresh.name, ...(fresh.kind ? { kind: fresh.kind } : {}) });
1020
+ freshSteward.set(wantTarget, fresh.workspace ?? "");
1021
+ log.info({ base, target: wantTarget, identity: fresh.identity }, "steward reception: new manifestation registered");
1022
+ return wantTarget;
1023
+ };
1024
+ const stewardReception = (base) => {
1025
+ const r = resolveSteward(cfg, wizardStore(), base, (t) => ((c) => c.runningCwd || c.defaultCwd)(bridge.getCwd(t)));
1026
+ if (r.fresh && !freshSteward.has(r.target))
1027
+ return openManifestation(base, r.fresh, r.target);
1028
+ return r.target;
1029
+ };
1030
+ // 点名: 已绑定的群里点本群管家 → 仍走接待 (落本群化身, 没有就新开), 不回落锚点 ——
1031
+ // 否则点名会与别的群共享那条会话, 而它明确是指「本群的管家」。这是「按群隔离会话」
1032
+ // 的唯一入口: 其余点名 (worker、别群的管家) 都走 resolveName, 跨群共享同一会话。
1033
+ const resolve = (base, name) => {
1034
+ if (!name)
1035
+ return stewardReception(base);
1036
+ const store = wizardStore();
1037
+ const rec = store?.byName(name);
1038
+ if (store && rec && sameBot(base, rec.target)) {
1039
+ const id = identityOf(rec);
1040
+ // 实例名 (`<类名>-<N>`) 是精确地址: 那一条就是那一条 (跨群也直接投它, 回复回本群)。
1041
+ if (rec.ordinal !== undefined && parseInstanceName(name))
1042
+ return rec.target;
1043
+ if (id === stewardIdentityOf(cfg, store, base))
1044
+ return stewardReception(base);
1045
+ // 类名: 本群有该类的实例就用它; 没有就在本群新建一个 (与管家接待同一路径)。
1046
+ const cls = store.classes?.get(id);
1047
+ if (cls) {
1048
+ const hit = store.all().find((w) => identityOf(w) === id && baseOfKey(w.target) === base);
1049
+ if (hit)
1050
+ return hit.target;
1051
+ const kind = anchorOf(store, id)?.kind;
1052
+ return openManifestation(base, {
1053
+ identity: id, name: cls.name, classId: cls.id, workspace: cls.workspace, ...(kind ? { kind } : {}),
1054
+ }, keyOf(base, cls.name));
1055
+ }
1056
+ }
1057
+ return resolveName(base, name);
1058
+ };
987
1059
  const route = (msg, raw) => {
988
1060
  const c = composeInbound(msg, raw, quoteInContext, stripAt, resolve);
989
1061
  return { ...c, who: resolve(chatPrincipal(msg), c.tag) };
990
1062
  };
1063
+ // ── 新群引导 (onboarding.ts) ──────────────────────────────────────
1064
+ // 人 2026-11-17 改口径: 引导要一个**真实的引导会话** (对话式比系统行友好), 且「工作区
1065
+ // 设置以后就等同于绑定了管家, 就该退出引导」。daemon 是状态机主人 —— 判定/校验/落盘/
1066
+ // 强制全在这里 (模型跳不了步、落不了错盘); 引导化身 (base#guide, 不占 untagged —— 那是
1067
+ // 管家锚点的保留位) 只把 daemon 的指令转成人话回群, 没有工具面 (见 guideRefusal)。
1068
+ // 绑定即收: 目录 / 已有管家名一落定, 完成确认走 daemon 系统行, 引导化身当场 kill + drop
1069
+ // —— 不再留告别窗口与定时器 (reload 丢定时器 = 群里残留一个「等指令」的会话)。兜底:
1070
+ // 绑定已在 (人手改 config、上个进程死在半路) 而引导化身还挂着, 下一条群消息进门时收尸。
1071
+ const onboarding = opts.onboarding ?? loadOnboardingStore(cfg);
1072
+ /** 频道原生帧等 topic_at_bot 配对的上限 (实测事件先到 0.3–0.8s; 只有没配过的帖子会等)。 */
1073
+ const CHANNEL_PAIR_WAIT_MS = 2000;
1074
+ const reapGuide = async (base, why) => {
1075
+ const guide = guideOf(wizardStore(), base);
1076
+ if (!guide)
1077
+ return;
1078
+ const r = await bridge.killPane(guide);
1079
+ wizardStore()?.drop(guide);
1080
+ log.info({ base, guide, why, killed: r.ok, reason: r.reason }, "onboarding: guide reaped");
1081
+ };
1082
+ // 频道 (人 2026-11-17 拍板: 整个频道一个管家, 每个帖子复用): 原生帧的 base 是帖子群, 先等它与
1083
+ // 同句 topic_at_bot 配上对拿到频道键 (原生帧可能先到), 再把散落的帖子级绑定收口成频道一条。
1084
+ const sourceOf = (msg) => msg.compat_info?.source ?? "";
1085
+ const settleChannelPost = async (base) => {
1086
+ const topicId = channelOfPost(cfg, base) || await awaitChannelOfPost(cfg, base, CHANNEL_PAIR_WAIT_MS);
1087
+ if (!topicId) {
1088
+ log.info({ base }, "channel post: 未配上频道 (没有同句 topic_at_bot), 按普通群判");
1089
+ return;
1090
+ }
1091
+ const { r } = guardCharter(() => settleChannelSteward(cfg, wizardStore(), sourcePath, base), (s) => (s ? { what: "频道 " + s.topicId + " 的管家收口为 " + s.name + " (清掉帖子级绑定 " + s.cleared.join(", ") + ")", byHuman: false } : undefined));
1092
+ if (r)
1093
+ log.info({ base, ...r }, "channel post: steward settled at channel level");
1094
+ };
1095
+ // 频道级绑定落定: 同频道其余帖子的在途引导一并收掉 —— 它们从此复用这个管家。
1096
+ const reapChannelSiblings = async (base) => {
1097
+ const topicId = channelOf(cfg, base);
1098
+ if (!topicId)
1099
+ return;
1100
+ for (const b of postsOfChannel(cfg, topicId).filter((p) => p !== base)) {
1101
+ onboarding.finish(b);
1102
+ await reapGuide(b, "channel bound");
1103
+ }
1104
+ };
1105
+ const guideGate = async (frame, msg, raw) => {
1106
+ if (!isGroup(msg))
1107
+ return false;
1108
+ const base = chatPrincipal(msg);
1109
+ if (sourceOf(msg) === "channel")
1110
+ await settleChannelPost(base);
1111
+ const store = wizardStore();
1112
+ if (!needsOnboarding(cfg, store, base)) {
1113
+ // 绑定已在 (含同频道别的帖子绑的): 在途引导状态 (出站豁免) 与引导化身一并收掉。
1114
+ onboarding.finish(base);
1115
+ if (guideOf(store, base))
1116
+ await reapGuide(base, "already bound");
1117
+ return false;
1118
+ }
1119
+ // 与 gate 同一把 allowFrom 尺子: 陌生人交给老路 (gate 回未授权), 引导不搭理。
1120
+ const allow = [...cfg.wrc.allowFrom, ...(cfg.bots.find((b) => b.id === botTagOf(msg))?.allowFrom ?? [])];
1121
+ if (!isAllowed(allow, authPrincipals(msg)))
1122
+ return false;
1123
+ const text = raw.trim();
1124
+ // 引导期每条消息落一行: 「人说了但没反应」时要先分清是没进 daemon 还是判定没走通 —— 这条
1125
+ // 路径原本一个日志都没有, 空正文那条回复也只走 replySystem (不落日志)。
1126
+ log.info({ base, len: text.length, guide: guideOf(store, base) }, "onboarding: guideGate");
1127
+ if (!text) {
1128
+ await replySystem(frame, msg, "[wezard] 本群还在初始化引导中 — 请发文字: 管家的工作目录 (绝对路径), 或已有管家的名字。");
1129
+ return true;
1130
+ }
1131
+ // 点名 .x / 🧙 x 的消息不拦: 人在明确找某个 wizard (或叫一个新的), 与本群初始化无关。
1132
+ if (parseTag(text).tag)
1133
+ return false;
1134
+ // 免授权的发现面 (/id /help) 引导期照样给 —— 直接答, 不走 route (那会顺手注册管家化身)。
1135
+ if (isIdCommand(text)) {
1136
+ await replySystem(frame, msg, renderIds(msg, allow));
1137
+ return true;
1138
+ }
1139
+ if (isHelpCommand(text)) {
1140
+ await replySystem(frame, msg, renderHelp());
1141
+ return true;
1142
+ }
1143
+ const input = classifyOnboardingInput(text);
1144
+ if (input.kind === "command") {
1145
+ await replySystem(frame, msg, "[wezard] 本群还没完成初始化 — 先回复管家的工作目录 (绝对路径) 或已有管家的名字, 命令引导完成后可用。");
1146
+ return true;
1147
+ }
1148
+ const first = !onboarding.get(base);
1149
+ onboarding.begin(base);
1150
+ // ① 快路径 (2026-11-20 收窄): **整句**就是一个路径 / 一个名字才一步绑定。含路径但还有别的
1151
+ // 话、相对路径、认不出的 —— 全部下面交给引导化身, 不再从长句里抽第一个路径 (实录: 「在
1152
+ // ~/develop/Tencent 下建 dhtpm 并绑定」被绑成父目录, 人真正要的事全丢)。
1153
+ let retryReason = "";
1154
+ if (input.kind !== "sentence") {
1155
+ const verdict = judgeOnboarding(store, base, input, (t) => bridge.sessionInfo(t)?.cwd ?? "");
1156
+ if (verdict.kind !== "retry") {
1157
+ const bound = applyOnboarding(store, onboarding, base, verdict, (name) => guardCharter(() => bindSteward(cfg, sourcePath, base, name), () => ({ what: verdict.kind === "bind-new" ? "新群引导新建管家 " + name + " (工作区 " + verdict.workspace + ") 并绑到 " + base : "新群引导把 " + name + " 绑为 " + base + " 的管家", byHuman: true })), (t) => identityWorkspaceOf(store, t) || ((c) => c.runningCwd || c.defaultCwd)(bridge.getCwd(t)));
1158
+ log.info({ base, ...bound }, "onboarding: steward bound (fast path)");
1159
+ // 引导化身在 room 里 (上一句已经交给它了): 管家接进 room、duty 连原话一起转过去,
1160
+ // 完成确认由 room 的系统行发; 否则照旧回一条 daemon 系统行。
1161
+ if (!(opts.guideSettle?.(base, bound) ?? false))
1162
+ await replySystem(frame, msg, renderOnboardingDone(bound));
1163
+ await reapGuide(base, "bound");
1164
+ await reapChannelSiblings(base);
1165
+ return true;
1166
+ }
1167
+ retryReason = verdict.reason;
1168
+ }
1169
+ // ② 别的都是引导化身的事: 起/续引导会话, 把这轮的话术挂到它下一次注入上 (它就是引导的宪章),
1170
+ // 人这句由 inbound 端口落进本群 room (guide 作 founder) 并唤醒它 —— 绑定后 duty 连原话交给管家。
1171
+ // 引导化身自己的工作区 = 全局默认 (cfg.wrc.cwd) —— 要绑的 workspace 是管家的。
1172
+ const guide = guideTargetOf(store, base);
1173
+ if (!bridge.hasMirrorTarget(guide)) {
1174
+ store?.upsert(guide, { identity: guide, kind: "worker", description: GUIDE_DESC, workspace: expandHome(cfg.wrc.cwd) });
1175
+ log.info({ base, guide }, "onboarding: guide session spawned");
1176
+ }
1177
+ const { err } = await ensureSession(guide, "guide", expandHome(cfg.wrc.cwd));
1178
+ if (err) {
1179
+ await replySystem(frame, msg, "[wezard] 引导会话起不来: " + err + " — 稍后再发一句试试。");
1180
+ return true;
1181
+ }
1182
+ bridge.armCharter(guide, first ? renderGuideOpening() : renderGuideRetry(retryReason));
1183
+ const sent = opts.guideInbound
1184
+ ? await opts.guideInbound({ base, guide, text, from: msg.from.userid, streamId: msg.msgid, frame })
1185
+ : { ok: false, reason: "room 接线还没就绪" };
1186
+ if (sent.ok)
1187
+ return true;
1188
+ log.warn({ base, guide, reason: sent.reason }, "onboarding: 人这句没能进 room");
1189
+ await replySystem(frame, msg, "[wezard] 引导没接上 (" + (sent.reason ?? "未知原因") + ") — 稍后再发一句。");
1190
+ return true;
1191
+ };
991
1192
  const send = async (frame, msg, who, text, images = []) => {
992
- // 斜杠命令按行解析,尾巴上多挂一段会让它不再被识别成命令 —— 只标注普通消息。
993
- const slash = text.trimStart().startsWith("/");
994
- const hint = slash ? [] : [peerMentionPart(peerMentions(who, text), ((c) => c.runningCwd || c.defaultCwd)(bridge.getCwd(who)))];
995
- // 谁、在哪个群说的 —— transcript 里只有这一段记着它 (read_chat 从那里读回来)。
996
- // 私信也带真实 userid 与稳定 chat key, 不能从 wizard home/defaultChat 猜。
1193
+ // 账本行只存人的原话: 信封已删 (谁说的 = 行作者, 哪个群 = 行所在 room), 管家自查 / 点名提示 /
1194
+ // 名册增量这些提醒尾巴也不在这里拼 —— 它们在唤醒渲染那一刻才挂 (wake-tail.ts / room-hub)。
997
1195
  const channel = chatPrincipal(msg);
998
- const chat = chatNameOf(cfg, channel);
999
- const envelope = slash ? "" : renderHumanEnvelope(msg.from.userid, chat || channel, channel);
1000
- const steward = slash || !stewardTierOf(cfg, who) ? "" : renderStewardHint();
1001
- // 同一条边界上再挂: 点名提示, 以及这个 wizard 不在场时群里发生的成员变动 (见 notices.ts,
1002
- // 近几次注入里给过的不再重复)。
1003
- const notice = noticeSuffixFor(who, text, { human: { channel } }, hint);
1196
+ // P7-S1 只记录不动行为: 人话 dispatch 前落一行 human (同步内存记账, 落盘在后台)。
1197
+ // room 模型: 人话行的去重键 = 企微 msgid (账本行 ext), 事件表已退役。
1004
1198
  try {
1005
1199
  // 回复回到发话的这个群 —— `who` 可能住在别的聊天 (名字全局可达)。
1006
- await bridge.dispatch({ eventId: slash ? undefined : messageId(botTagOf(msg), channel, msg.msgid), identity: JSON.stringify(msg), originalAt: msg.create_time ? (msg.create_time < 1e12 ? msg.create_time * 1000 : msg.create_time) : Date.now(), principal: who, text: text + renderTail(envelope, steward, notice), images, frame, streamId: msg.msgid, channel, speaker: `user:${msg.from.userid}` });
1200
+ await bridge.dispatch({ eventId: undefined, identity: JSON.stringify(msg), originalAt: msg.create_time ? (msg.create_time < 1e12 ? msg.create_time * 1000 : msg.create_time) : Date.now(), principal: who, text, rawText: text, images, frame, streamId: msg.msgid, channel, speaker: `user:${msg.from.userid}`, quoted: parseQuote(msg.quote)?.body });
1007
1201
  }
1008
1202
  catch (e) {
1009
1203
  log.error({ err: e.message }, "bridge dispatch failed");
@@ -1013,12 +1207,37 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
1013
1207
  catch { /* ignore */ }
1014
1208
  }
1015
1209
  };
1210
+ // 入站最外层: SDK 对每条消息回调先 emit "message" 再按 msgtype 分发 —— 在这里落一行, 「人说了
1211
+ // 没反应」才分得清是帧没到 daemon (企微没推), 还是到了被后面的门吃掉 (guideGate 的日志在拿到
1212
+ // text 之后才落, 证明不了「没到」)。SDK 不认的 msgtype 只 logger.debug 一句就丢, daemon 是 info
1213
+ // 级永远看不见: 这里落 warn 带原帧, 并明确回一句 —— 人的话不能静默消失。
1214
+ client.on("message", (frame) => {
1215
+ const msg = frame.body;
1216
+ if (!msg)
1217
+ return;
1218
+ const source = msg.compat_info?.source;
1219
+ log.info({ msgid: msg.msgid, msgtype: msg.msgtype, chattype: msg.chattype, chat: chatPrincipal(msg), from: msg.from?.userid, hasQuote: !!msg.quote, ...(source ? { source } : {}) }, "rx frame");
1220
+ // 频道里 @ 机器人的原生帧 (chatid = 帖子群): 记一笔, 同一句的 topic_at_bot 桥接就不再重投 (channel.ts)。
1221
+ if (source === "channel")
1222
+ noteNativeChannelFrame(msg.from?.userid ?? "", chatPrincipal(msg));
1223
+ if (ROUTED_MSGTYPES.has(msg.msgtype) || NO_REPLY_MSGTYPES.has(msg.msgtype))
1224
+ return;
1225
+ log.warn({ body: msg }, "rx frame — unhandled msgtype, not routed to any wizard");
1226
+ void replySystem(frame, msg, "[wezard] 收到一条暂不支持的消息 (类型 " + msg.msgtype + "), 没有转给任何 wizard — 请改发文字。");
1227
+ });
1016
1228
  client.on("message.text", async (frame) => {
1017
1229
  const msg = frame.body;
1018
1230
  if (!msg)
1019
1231
  return;
1232
+ if (await guideGate(frame, msg, stripAt(msg, msg.text?.content ?? "")))
1233
+ return;
1020
1234
  const { text, tag, promoted, who } = route(msg, stripAt(msg, msg.text?.content ?? ""));
1021
- log.info({ msgid: msg.msgid, len: text.length, tag, hasQuote: !!msg.quote, promoted }, "rx text");
1235
+ const known = bridge.hasMirrorTarget(who);
1236
+ log.info({ msgid: msg.msgid, len: text.length, tag, hasQuote: !!msg.quote, promoted, chat: chatPrincipal(msg), who, known }, "rx text");
1237
+ // 落到一个没有任何会话的聊天时, 把原始回调也记一笔: 频道 / 群 / 单聊的 chatid
1238
+ // 形状不同, 认错了就会像 /reveal 那样 "no tmux pane bound"。
1239
+ if (!known)
1240
+ log.info({ body: msg }, "rx text — unknown chat (raw)");
1022
1241
  const { stop } = await gate(frame, msg, text, who, tag);
1023
1242
  if (stop)
1024
1243
  return;
@@ -1029,6 +1248,8 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
1029
1248
  if (!msg)
1030
1249
  return;
1031
1250
  log.info({ msgid: msg.msgid, hasQuote: !!msg.quote }, "rx image");
1251
+ if (await guideGate(frame, msg, ""))
1252
+ return;
1032
1253
  // Images carry no text of their own — the quote (if any) is the only
1033
1254
  // routing signal; without it they land on the chat's default session.
1034
1255
  const { text, tag, who } = route(msg, "");
@@ -1060,6 +1281,8 @@ export const installInboundRouter = (client, cfg, log, bridge, sourcePath, guard
1060
1281
  .filter((it) => it.msgtype === "text")
1061
1282
  .map((it) => it.text?.content ?? "")
1062
1283
  .join("\n");
1284
+ if (await guideGate(frame, msg, stripAt(msg, rawText)))
1285
+ return;
1063
1286
  const { tag, who } = route(msg, stripAt(msg, rawText));
1064
1287
  const { stop } = await gate(frame, msg, "", who, tag);
1065
1288
  if (stop)