@hfyjq/crannia 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +48 -45
  3. package/README.md +1 -1
  4. package/THIRD-PARTY-FRONTEND.md +5266 -5266
  5. package/THIRD-PARTY-PYTHON-linux.md +174 -0
  6. package/THIRD-PARTY-PYTHON.md +176 -162
  7. package/THIRD-PARTY.md +323 -316
  8. package/apps/desktop/quotes.txt +56 -56
  9. package/bus/core.py +677 -671
  10. package/bus/loaders/channel_loader.py +64 -64
  11. package/bus/loaders/provider_loader.py +4 -7
  12. package/bus/loaders/skill_loader.py +46 -27
  13. package/bus/loaders/skill_md.py +9 -9
  14. package/bus/mcp_disabled.py +4 -6
  15. package/bus/quarantine.py +10 -13
  16. package/bus/registry.py +2315 -2284
  17. package/bus/skill_state.py +124 -124
  18. package/channels/cli_channel/handler.py +3 -3
  19. package/channels/cli_channel/manifest.yaml +5 -5
  20. package/channels/dingtalk_channel/handler.py +32 -32
  21. package/channels/dingtalk_channel/manifest.yaml +12 -12
  22. package/channels/feishu_channel/handler.py +33 -33
  23. package/channels/feishu_channel/manifest.yaml +12 -12
  24. package/channels/qq_bot_channel/__init__.py +1 -1
  25. package/channels/qq_bot_channel/handler.py +24 -24
  26. package/channels/qq_bot_channel/manifest.yaml +4 -4
  27. package/channels/telegram_channel/__init__.py +1 -1
  28. package/channels/telegram_channel/handler.py +21 -21
  29. package/channels/telegram_channel/manifest.yaml +4 -4
  30. package/channels/telegram_channel/media.py +231 -231
  31. package/channels/textfmt.py +58 -58
  32. package/channels/wechat_channel/__init__.py +1 -1
  33. package/channels/wechat_channel/converter.py +1 -1
  34. package/channels/wechat_channel/handler.py +8 -8
  35. package/channels/wechat_channel/manifest.yaml +5 -5
  36. package/channels/wechat_channel/media.py +178 -178
  37. package/core/activity.py +753 -709
  38. package/core/agent_loop.py +7673 -7523
  39. package/core/allowlist.py +2 -3
  40. package/core/approval.py +36 -26
  41. package/core/approval_timeout.py +256 -228
  42. package/core/artifacts.py +3 -3
  43. package/core/attachment_gc.py +21 -0
  44. package/core/auto_review.py +2 -2
  45. package/core/browser/cdp.py +5 -2
  46. package/core/browser/discover.py +55 -19
  47. package/core/browser/session.py +4 -4
  48. package/core/cache_break_detector.py +97 -0
  49. package/core/cache_breakpoints.py +103 -0
  50. package/core/cache_policies.py +255 -0
  51. package/core/cancellation.py +3 -3
  52. package/core/channel_configs.py +3 -3
  53. package/core/channel_turns.py +13 -13
  54. package/core/child_approval.py +2 -3
  55. package/core/code_intel.py +11 -11
  56. package/core/command_policy.py +13 -7
  57. package/core/computer/annotate.py +231 -11
  58. package/core/computer/capture.py +140 -1
  59. package/core/computer/guard.py +7 -4
  60. package/core/computer/input.py +452 -26
  61. package/core/computer/session.py +563 -381
  62. package/core/computer/tools.py +2170 -928
  63. package/core/computer/uia.py +100 -1
  64. package/core/computer/watch.py +1 -1
  65. package/core/computer/win32.py +302 -7
  66. package/core/config_requirements.py +205 -205
  67. package/core/cron/runner.py +4 -4
  68. package/core/daily_log.py +2 -2
  69. package/core/dedup.py +2 -2
  70. package/core/egress_channels.py +326 -0
  71. package/core/egress_gate.py +96 -8
  72. package/core/egress_preapproved.py +59 -3
  73. package/core/endpoint.py +141 -141
  74. package/core/events.py +17 -8
  75. package/core/extension.py +2 -2
  76. package/core/file_history.py +15 -15
  77. package/core/file_tools.py +3 -3
  78. package/core/github_config.py +1 -1
  79. package/core/group_digest.py +3 -4
  80. package/core/group_minutes.py +5 -5
  81. package/core/group_reply.py +24 -0
  82. package/core/groups.py +5 -9
  83. package/core/hooks.py +15 -15
  84. package/core/i18n.py +2 -2
  85. package/core/ice/canary.py +3 -3
  86. package/core/ice/net_heuristics.py +2 -2
  87. package/core/im_routing.py +3 -3
  88. package/core/image_input.py +183 -43
  89. package/core/inbound.py +3 -3
  90. package/core/jobs.py +6 -6
  91. package/core/last_good.py +150 -150
  92. package/core/leaf_md.py +3 -3
  93. package/core/llm_errors.py +37 -28
  94. package/core/mail_config.py +2 -2
  95. package/core/memory/compressor.py +8 -8
  96. package/core/memory/manager.py +30 -45
  97. package/core/memory/session_memory.py +1 -2
  98. package/core/memory/short_term.py +4 -4
  99. package/core/memory_extract.py +1 -1
  100. package/core/memory_organize.py +8 -8
  101. package/core/memory_store.py +7 -9
  102. package/core/memory_transfer.py +2 -2
  103. package/core/model_capabilities.py +2 -2
  104. package/core/model_configs.py +219 -68
  105. package/core/model_profiles.py +333 -0
  106. package/core/modes.py +12 -11
  107. package/core/net_proxy.py +3 -3
  108. package/core/pipeline/scheduler.py +48 -43
  109. package/core/pipeline/stage.py +3 -0
  110. package/core/pipeline/stages/agent_loop.py +36 -15
  111. package/core/pipeline/stages/group_reply.py +22 -20
  112. package/core/pipeline/stages/post_process.py +7 -7
  113. package/core/pipeline/stages/pre_process.py +369 -77
  114. package/core/prompt_assembler.py +13 -4
  115. package/core/recycle.py +227 -16
  116. package/core/response_language.py +1 -1
  117. package/core/retention.py +2 -2
  118. package/core/rg.py +4 -3
  119. package/core/security.py +26 -8
  120. package/core/services.py +8 -8
  121. package/core/session_model.py +3 -5
  122. package/core/session_pool.py +35 -5
  123. package/core/session_recap.py +40 -3
  124. package/core/session_workspace.py +2 -3
  125. package/core/settings_baseline.py +2 -2
  126. package/core/settings_transfer.py +25 -1
  127. package/core/shell.py +52 -20
  128. package/core/side_call.py +3 -3
  129. package/core/skill_config.py +164 -0
  130. package/core/skill_factory.py +2 -2
  131. package/core/skill_guidance.py +2 -4
  132. package/core/skill_index.py +3 -4
  133. package/core/skill_settings.py +1 -1
  134. package/core/skill_sources.py +7 -7
  135. package/core/ssh_config.py +129 -0
  136. package/core/state_registry.py +67 -5
  137. package/core/subagent.py +28 -5
  138. package/core/subagent_defs.py +3 -3
  139. package/core/summarizer.py +4 -5
  140. package/core/tasks_notify.py +6 -6
  141. package/core/tiers.py +2 -2
  142. package/core/todos.py +1 -1
  143. package/core/token_calibrator.py +1 -4
  144. package/core/tool_outcome.py +108 -108
  145. package/core/touched_files.py +1 -1
  146. package/core/trace.py +12 -3
  147. package/core/unlock.py +4 -4
  148. package/core/update_tui.py +184 -158
  149. package/core/updater.py +5 -3
  150. package/core/version.py +14 -14
  151. package/core/vision_budget.py +235 -0
  152. package/core/web_cache.py +152 -152
  153. package/core/web_request.py +474 -0
  154. package/core/window_estimate.py +1 -1
  155. package/core/workspace.py +56 -26
  156. package/crannia_tray.py +278 -278
  157. package/licenses/GPL-3.0.txt +619 -619
  158. package/licenses/LGPL-2.1.txt +502 -502
  159. package/licenses/LGPL-3.0.txt +165 -165
  160. package/licenses/MIT-chat-on-wechat.txt +18 -18
  161. package/licenses/MIT-deepseek-harness.txt +21 -21
  162. package/licenses/Molio-LICENSE.txt +44 -44
  163. package/locales/en.json +1876 -1762
  164. package/main.py +154 -154
  165. package/mcpx/client.py +12 -1
  166. package/mcpx/manager.py +530 -522
  167. package/mcpx/servers/web_search.py +5 -13
  168. package/package.json +15 -23
  169. package/providers/anthropic/client.py +35 -33
  170. package/providers/base.py +13 -13
  171. package/providers/cache_policies.json +294 -0
  172. package/providers/cost_table.json +3779 -3779
  173. package/providers/lmstudio/client.py +2 -2
  174. package/providers/model_capabilities.json +6665 -6665
  175. package/providers/model_profiles.json +629 -0
  176. package/providers/ollama/client.py +2 -2
  177. package/providers/openai_compat.py +37 -16
  178. package/providers/openrouter/client.py +2 -2
  179. package/providers/qwen/__init__.py +1 -1
  180. package/providers/qwen/client.py +2 -2
  181. package/providers/qwen/manifest.yaml +16 -16
  182. package/providers/rate_limiter.py +2 -2
  183. package/providers/siliconflow/client.py +2 -2
  184. package/providers/validation.py +171 -171
  185. package/providers/vision_profiles.json +89 -0
  186. package/providers/window_table.json +8909 -8909
  187. package/requirements.txt +59 -51
  188. package/sbom-linux-x64.json +4580 -0
  189. package/sbom.json +4600 -4413
  190. package/skills/diagram/SKILL.md +47 -0
  191. package/skills/diagram/__init__.py +1 -0
  192. package/skills/diagram/handler.py +294 -0
  193. package/skills/diagram/layout.py +174 -0
  194. package/skills/diagram/manifest.yaml +106 -0
  195. package/skills/diagram/mermaid.py +170 -0
  196. package/skills/diagram/svg.py +223 -0
  197. package/skills/entertainment/SKILL.md +35 -35
  198. package/skills/entertainment/__init__.py +1 -1
  199. package/skills/entertainment/handler.py +91 -91
  200. package/skills/entertainment/manifest.yaml +26 -26
  201. package/skills/file_parser/GUIDANCE.md +10 -10
  202. package/skills/file_parser/handler.py +33 -11
  203. package/skills/github/SKILL.md +32 -32
  204. package/skills/github/__init__.py +1 -1
  205. package/skills/mail_parser/SKILL.md +68 -68
  206. package/skills/mail_parser/__init__.py +1 -1
  207. package/skills/mail_parser/handler.py +1 -1
  208. package/skills/media_gen/GUIDANCE.md +19 -19
  209. package/skills/media_gen/SKILL.md +43 -43
  210. package/skills/media_gen/__init__.py +1 -1
  211. package/skills/media_gen/handler.py +1 -1
  212. package/skills/media_gen/manifest.yaml +93 -93
  213. package/skills/netops/SKILL.md +45 -0
  214. package/skills/netops/__init__.py +1 -0
  215. package/skills/netops/handler.py +418 -0
  216. package/skills/netops/manifest.yaml +118 -0
  217. package/skills/office_parser/_excel_io.py +3 -3
  218. package/skills/office_parser/handler.py +2 -2
  219. package/skills/office_parser/ppt_tools.py +1 -1
  220. package/skills/office_parser/pptx_export/console_encoding.py +27 -27
  221. package/skills/office_parser/pptx_export/resource_paths.py +88 -88
  222. package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
  223. package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
  224. package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
  225. package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
  226. package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
  227. package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
  228. package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
  229. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
  230. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
  231. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
  232. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
  233. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/utils.py +40 -21
  234. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
  235. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
  236. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
  237. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
  238. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
  239. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
  240. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
  241. package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
  242. package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
  243. package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
  244. package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
  245. package/skills/office_parser/references/layout_library.md +816 -816
  246. package/skills/office_parser/references/ppt-master/LICENSE +21 -21
  247. package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
  248. package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
  249. package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
  250. package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
  251. package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
  252. package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
  253. package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
  254. package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
  255. package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
  256. package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
  257. package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
  258. package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
  259. package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
  260. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
  261. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
  262. package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
  263. package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
  264. package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
  265. package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
  266. package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
  267. package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
  268. package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
  269. package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
  270. package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
  271. package/skills/office_parser/references/spec_lock.md +235 -235
  272. package/skills/office_parser/soffice.py +68 -68
  273. package/skills/office_parser/word_tools.py +3 -3
  274. package/skills/ssh/SKILL.md +81 -0
  275. package/skills/ssh/__init__.py +1 -0
  276. package/skills/ssh/handler.py +609 -0
  277. package/skills/ssh/manifest.yaml +182 -0
  278. package/tui/crannia.cmd +134 -134
  279. package/tui/crannia.sh +82 -0
  280. package/tui/crannia_tui/__init__.py +1 -1
  281. package/tui/crannia_tui/app.py +240 -17
  282. package/tui/crannia_tui/app.tcss +21 -0
  283. package/tui/crannia_tui/clipboard.py +78 -10
  284. package/tui/crannia_tui/commands.py +37 -0
  285. package/tui/crannia_tui/events.py +6 -0
  286. package/tui/crannia_tui/i18n.py +164 -164
  287. package/tui/crannia_tui/locales/en.json +32 -7
  288. package/tui/crannia_tui/paths.py +4 -1
  289. package/tui/crannia_tui/profile.py +178 -169
  290. package/tui/crannia_tui/settings.py +134 -134
  291. package/tui/crannia_tui/setup.py +44 -5
  292. package/tui/crannia_tui/ui.py +156 -16
  293. package/tui/crannia_tui/update.py +393 -389
  294. package/vendor/ripgrep/COPYING.txt +3 -3
  295. package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
  296. package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
  297. package/vendor/ripgrep/README.md +30 -14
  298. package/vendor/ripgrep/UNLICENSE.txt +24 -24
  299. package/vendor/ripgrep/linux-x64/rg +0 -0
  300. package/vendor/ripgrep/package-source.json +15 -16
  301. package/web/__main__.py +12 -15
  302. package/web/server.py +8481 -8594
  303. package/web/static/img/channel-telegram.svg +1 -1
  304. package/web/static/img/channel-wechat.svg +1 -1
  305. package/web/templates/logs.html +49 -49
  306. package/web/templates/models.html +46 -46
@@ -30,12 +30,24 @@
30
30
  (读不到 ≠ 0,也 ≠ "很久")。
31
31
  - 默认关:它是用户打开的功能,不是我们替他打开的。
32
32
  关着的时候本模块一行都不做(不开支、不出事件)。
33
+
34
+ ## 一次"回来"只说一遍(不只是靠 `last_turn_at` 前进)
35
+
36
+ `last_turn_at` 是「上一轮跑完了」的时刻。若那一轮在跑完之前就失败
37
+ (provider 报错、进程退出),它会停在旧值 —— 之后用户每发一句话,
38
+ `due()` 都判真,回顾就会隔一句出现一次。
39
+
40
+ 所以这里另记一格:给出回顾时把它记在 `_LAST_RECAP[session]`。
41
+ 下一条消息若仍对着同一个 `last_turn_at`(说明那之后还没有一轮真正跑完),
42
+ 直接不说话 —— 不必等到它再老一个间隔。等哪一轮跑完,`last_turn_at` 前进,
43
+ 下一个"离开够久"的窗口才重新打开。
33
44
  """
34
45
 
35
46
  from __future__ import annotations
36
47
 
37
48
  import re
38
- from typing import Optional
49
+ import time
50
+ from typing import Dict, Optional
39
51
 
40
52
  #: 设置键(`data/settings.json`)。两个键:开关 + 触发时间。
41
53
  #: 「可关闭」那一格就落在 `ENABLED_KEY` 上 ——
@@ -53,6 +65,17 @@ DEFAULT_MINUTES = 30
53
65
  MIN_MINUTES = 1
54
66
  MAX_MINUTES = 1440 # 一天;超过它等于"永远不触发",那就该关开关
55
67
 
68
+ #: 本会话上一次给出回顾的时刻。键 = session_id,进程内。
69
+ #: 判据见模块 docstring 的「一次"回来"只说一遍」—— 它防的是
70
+ #: 「那一轮没跑完 => `last_turn_at` 不前进 => 每句话都来一段回顾」。
71
+ #: 登记在 `core/state_registry.py`(`/clear` 走 `forget`)。
72
+ _LAST_RECAP: Dict[str, float] = {}
73
+
74
+
75
+ def forget(session_id: str) -> None:
76
+ """`/clear` 的清理(`state_registry` 的 purge 入口)。"""
77
+ _LAST_RECAP.pop(session_id, None)
78
+
56
79
 
57
80
  def _settings() -> dict:
58
81
  """读 `data/settings.json`。读不到 / 坏文件,空字典(读不到,默认)。"""
@@ -167,10 +190,21 @@ def recap_for(session_id: str, now: Optional[float] = None) -> Optional[str]:
167
190
 
168
191
  顺序是有讲究的:先判 `due`(纯读设置 + 一个钟),
169
192
  判过了才去读笔记文件 —— 绝大多数轮在第一道就返回了,不碰磁盘。
193
+
194
+ 另有一道「这一次回来已经说过了」:见模块 docstring。判据是
195
+ `_LAST_RECAP[session] >= last_turn_at` —— 说明给出回顾之后
196
+ 还没有任何一轮真正跑完(`last_turn_at` 没前进),此时不再重复。
170
197
  """
171
198
  from core.memory_extract import last_turn_at
172
199
 
173
- if not due(last_turn_at(session_id), now):
200
+ anchor = last_turn_at(session_id)
201
+ if anchor is None:
202
+ return None
203
+ stamp = _LAST_RECAP.get(session_id)
204
+ if stamp is not None and stamp >= float(anchor):
205
+ return None
206
+ t = time.time() if now is None else float(now)
207
+ if not due(anchor, t):
174
208
  return None
175
209
  from core.memory.session_memory import SessionMemory
176
210
 
@@ -178,4 +212,7 @@ def recap_for(session_id: str, now: Optional[float] = None) -> Optional[str]:
178
212
  note = SessionMemory().load(session_id)
179
213
  except Exception: # noqa: BLE001 —— 回顾是**锦上添花**:拿不到就算了,
180
214
  return None # 但绝不因此弄挂这一轮(同 `context.state` 那条兜底判据)
181
- return build(note or "")
215
+ text = build(note or "")
216
+ if text:
217
+ _LAST_RECAP[session_id] = t
218
+ return text
@@ -134,8 +134,7 @@ def chosen(storage_key: str) -> str:
134
134
  # 读不到,当没选过(fail-open,同 `session_model.frozen` 那条)。
135
135
  # 方向是掐出来的:读不到就走默认工作区 —— 而"读不到"最可能的时刻
136
136
  # 正是库刚建、或换了一台机器;那时"用默认"就是对的答案。
137
- print(f"[session_workspace] 读会话工作目录失败(按未选择处理):"
138
- f"{type(exc).__name__}: {exc}")
137
+ print(f"[session_workspace] read session workspace failed (treating as unset): {type(exc).__name__}: {exc}")
139
138
  return ""
140
139
 
141
140
 
@@ -188,7 +187,7 @@ def use_default(storage_key: str) -> bool:
188
187
  st.clear_session_workspace(key)
189
188
  return existed
190
189
  except Exception as exc: # noqa: BLE001
191
- print(f"[session_workspace] 退回默认工作区失败({type(exc).__name__}: {exc})")
190
+ print(f"[session_workspace] revert to default workspace failed ({type(exc).__name__}: {exc})")
192
191
  return False
193
192
 
194
193
 
@@ -92,12 +92,12 @@ def baseline(path: Optional[Path] = None) -> dict:
92
92
  except FileNotFoundError:
93
93
  if not _warned:
94
94
  _warned = True
95
- print(f"[settings] 出厂基准读不到({p})—— 「恢复默认」会变成空操作")
95
+ print(f"[settings] factory baseline unreadable ({p}) - restore defaults will become a no-op")
96
96
  return {}
97
97
  except (OSError, ValueError) as exc:
98
98
  if not _warned:
99
99
  _warned = True
100
- print(f"[settings] 出厂基准坏了({p}):{type(exc).__name__}: {exc}")
100
+ print(f"[settings] factory baseline broken ({p}): {type(exc).__name__}: {exc}")
101
101
  return {}
102
102
  if not isinstance(raw, dict):
103
103
  return {}
@@ -75,7 +75,9 @@ CRED_FILES: tuple = (
75
75
  ("data/wechat_credentials.json", "wechat_credentials"),
76
76
  ("data/media_gen_credentials.json", "media_gen_credentials"),
77
77
  ("data/media_gen_key.txt", "media_gen_key"),
78
- ("data/runtime/provider_credentials.json", "provider_credentials"),
78
+ #: 模型配置的密钥不在这里 —— 它与账本同一份文件,
79
+ #: 整份搬会把非密字段也塞进加密段、导入时还会覆盖账本。
80
+ #: 走 `collect_credentials` 里那条 `model_config_api`(按 id 取明文)。
79
81
  # MCP 服务器的 `env` / `headers` 里通常就是令牌,归凭据,绝不进默认包。
80
82
  ("data/mcp_servers.json", "mcp_servers"),
81
83
  )
@@ -152,6 +154,19 @@ def collect_credentials(settings: Optional[dict] = None) -> dict:
152
154
  text = _read_text(path)
153
155
  if text:
154
156
  out[name] = text
157
+ #: 模型配置的密钥(单文件存储之后与账本同一份文件)——
158
+ #: 按 id 逐条取明文,不整份搬:整份会把非密字段也加密,
159
+ #: 导入时还会覆盖账本(账本那段走 `merge_ledger`,与这条分开)。
160
+ try:
161
+ from core import model_configs as _MC
162
+ apis = {cid: _MC.api_for(cid)
163
+ for cid in (_MC.all_entries().get("configs") or {})}
164
+ apis = {k: v for k, v in apis.items() if v}
165
+ if apis:
166
+ out["model_config_api"] = apis
167
+ except Exception as exc: # noqa: BLE001
168
+ # 收不起来就不带这一段(明确不出声地少一块 = 用户以为包里全了)。
169
+ print(f"[settings_transfer] model config secrets not collected ({type(exc).__name__}: {exc})")
155
170
  for k in CRED_SETTINGS:
156
171
  if isinstance(settings, dict) and k in settings:
157
172
  out[k] = settings[k]
@@ -489,6 +504,15 @@ def apply_import(bundle, plan: dict, current: Optional[dict] = None, *,
489
504
  new_settings[k] = payload[k]
490
505
  written.append(k)
491
506
  n += 1
507
+ #: 模型配置的密钥按 id 并回账本(只认已有 id)。
508
+ apis = payload.get("model_config_api")
509
+ if isinstance(apis, dict) and apis:
510
+ try:
511
+ from core import model_configs as _MC
512
+ n += _MC.import_apis(apis)
513
+ except Exception as exc: # noqa: BLE001
514
+ applied["model_config_api_error"] = "%s: %s" % (
515
+ type(exc).__name__, exc)
492
516
  applied["credentials"] = n
493
517
  except ValueError as exc:
494
518
  applied["credentials_error"] = str(exc)
package/core/shell.py CHANGED
@@ -68,6 +68,7 @@ import os
68
68
  import re
69
69
  import shlex
70
70
  import shutil
71
+ import signal
71
72
  import subprocess
72
73
  import sys
73
74
  import threading
@@ -148,7 +149,7 @@ _BASH_CANDIDATES: tuple[str, ...] = (
148
149
  ENV_WHITELIST: tuple[str, ...] = (
149
150
  # ① 进程能起来所必需(缺了 bash 或子进程会直接跑不动)
150
151
  "path", "pathext", "systemroot", "windir", "systemdrive",
151
- "comspec", "temp", "tmp",
152
+ "comspec", "temp", "tmp", "tmpdir",
152
153
  # ② `~` 与用户目录(bash 靠 HOME/USERPROFILE 展开 `~`)
153
154
  "home", "homedrive", "homepath", "userprofile",
154
155
  "appdata", "localappdata", "programdata",
@@ -248,9 +249,9 @@ def bash_path() -> str:
248
249
  _bash_cache = found
249
250
  _bash_probed = True # 最后写 —— 见 docstring 那段
250
251
  if not _bash_cache:
251
- print("[shell] 找不到 bash —— 命令执行工具将不可用。"
252
- f"已试过:{', '.join(_BASH_CANDIDATES)} 与 PATH。"
253
- f"装了 Git for Windows 之后重启框架即可。")
252
+ print("[shell] bash not found - command execution tool will be unavailable. "
253
+ f"Tried: {', '.join(_BASH_CANDIDATES)} and PATH. "
254
+ f"Install Git for Windows and restart the framework.")
254
255
  return _bash_cache
255
256
 
256
257
 
@@ -444,8 +445,8 @@ def ensure_snapshot() -> str:
444
445
  dest = _SNAPSHOT_DEST.resolve()
445
446
  ok, why = _write_snapshot(bash, dest)
446
447
  if not ok:
447
- print("[shell] 没生成 shell 快照(%s)—— 命令照常跑,只是没有 profile "
448
- "里的函数与别名。" % why)
448
+ print("[shell] shell snapshot not created (%s) - commands still run, "
449
+ "but without profile functions and aliases." % why)
449
450
  return ""
450
451
  _snapshot_file = str(dest)
451
452
  _snapshot_cache = str(dest)
@@ -536,6 +537,10 @@ _CWD_MARK = "\x01CRANNIA_CWD\x01"
536
537
  #: (`subprocess.run` 的 timeout 只杀直接子进程,孙进程会活下来)。
537
538
  _CREATE_NEW_PROCESS_GROUP = getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0)
538
539
 
540
+ #: POSIX 的对应物:子进程自成会话(新进程组),`/stop` 才能 killpg 整棵树。
541
+ #: Windows 上传 True 会被 `subprocess` 拒,所以这一格在 Windows 上必须是 False。
542
+ _START_NEW_SESSION = os.name != "nt"
543
+
539
544
 
540
545
  def _wrap(command: str, snapshot: str = "") -> str:
541
546
  """给命令拼上"回报 cwd + 保留退出码"的尾巴(见模块 docstring 第三节)。
@@ -671,7 +676,8 @@ def _kill_tree(proc: subprocess.Popen) -> None:
671
676
  """杀掉整棵进程树(best-effort)。
672
677
 
673
678
  Windows 上 `proc.kill()` 只结束直接子进程;`taskkill /T` 才带子进程。
674
- 拿不到 `taskkill` 就退回 `kill()` —— 降级要出声。
679
+ POSIX 上子进程由 `start_new_session=True` 自成一组,`killpg` 才带子进程。
680
+ 拿不到对应的工具就退回 `kill()` —— 降级要出声。
675
681
  """
676
682
  if sys.platform == "win32":
677
683
  taskkill = shutil.which("taskkill")
@@ -681,14 +687,38 @@ def _kill_tree(proc: subprocess.Popen) -> None:
681
687
  capture_output=True, timeout=10)
682
688
  return
683
689
  except Exception as exc:
684
- print(f"[shell] taskkill 失败({type(exc).__name__}: {exc})"
685
- f" —— 退回单进程 kill,孙进程可能残留")
690
+ print(f"[shell] taskkill failed ({type(exc).__name__}: {exc}) - falling back to single-process kill, grandchildren may survive")
691
+ else:
692
+ print("[shell] taskkill not found - falling back to single-process kill, grandchildren may survive")
693
+ try:
694
+ proc.kill()
695
+ except Exception as exc:
696
+ print(f"[shell] kill also failed ({type(exc).__name__}: {exc})")
697
+ return
698
+
699
+ # POSIX:先确认它真的自成一组,再杀组 —— 杀错组的代价是把框架自己带走。
700
+ try:
701
+ pgid = os.getpgid(proc.pid)
702
+ except ProcessLookupError:
703
+ return
704
+ except Exception as exc:
705
+ pgid = None
706
+ print(f"[shell] process group lookup failed ({type(exc).__name__}: {exc}) - falling back to single-process kill, grandchildren may survive")
707
+ if pgid is not None:
708
+ if pgid == proc.pid:
709
+ try:
710
+ os.killpg(pgid, signal.SIGKILL)
711
+ return
712
+ except ProcessLookupError:
713
+ return
714
+ except Exception as exc:
715
+ print(f"[shell] killpg failed ({type(exc).__name__}: {exc}) - falling back to single-process kill, grandchildren may survive")
686
716
  else:
687
- print("[shell] 找不到 taskkill —— 退回单进程 kill,孙进程可能残留")
717
+ print("[shell] child process not in its own process group - killing only itself, grandchildren may survive")
688
718
  try:
689
719
  proc.kill()
690
720
  except Exception as exc:
691
- print(f"[shell] kill 也失败了({type(exc).__name__}: {exc})")
721
+ print(f"[shell] kill also failed ({type(exc).__name__}: {exc})")
692
722
 
693
723
 
694
724
  def _spill(payload: str) -> str:
@@ -990,10 +1020,13 @@ def _run(command: str, work_dir: Path, timeout_ms: int, *,
990
1020
  argv = [powershell_path(), "-NoProfile", "-NoLogo",
991
1021
  "-NonInteractive", "-Command", _wrap_ps(command)]
992
1022
  else:
1023
+ route = ("Windows 上装 Git for Windows,或确认系统自带的 powershell.exe 在。"
1024
+ if os.name == "nt"
1025
+ else "装一个 bash(Debian / Ubuntu:`apt install bash`)。")
993
1026
  return {
994
1027
  "success": False,
995
1028
  "error": ("找不到可用的 shell(bash 与 PowerShell 都没有),命令没有执行。"
996
- "Windows 上装 Git for Windows,或确认系统自带的 powershell.exe 在。"),
1029
+ + route),
997
1030
  }
998
1031
 
999
1032
  ms = int(timeout_ms or 0) or DEFAULT_TIMEOUT_MS
@@ -1009,6 +1042,7 @@ def _run(command: str, work_dir: Path, timeout_ms: int, *,
1009
1042
  stdout=subprocess.PIPE,
1010
1043
  stderr=subprocess.PIPE,
1011
1044
  creationflags=_CREATE_NEW_PROCESS_GROUP,
1045
+ start_new_session=_START_NEW_SESSION,
1012
1046
  )
1013
1047
  except OSError as exc:
1014
1048
  return {"success": False,
@@ -1072,8 +1106,7 @@ def _run(command: str, work_dir: Path, timeout_ms: int, *,
1072
1106
  )
1073
1107
  why = ("用户转后台" if by_user else
1074
1108
  ("超时转后台" if timed_out_ else "按请求直接转后台"))
1075
- print(f"[shell] {why}:{job.id}(上限 "
1076
- f"{jobs.JOB_MAX_LIFETIME_MS // 60000} 分钟)")
1109
+ print(f"[shell] {why}: {job.id} (limit {jobs.JOB_MAX_LIFETIME_MS // 60000} min)")
1077
1110
  # 产生后台任务的这一刻,把 `task` 工具挂进这个会话(按需发现;
1078
1111
  # 只追加、不改前缀,`K5`)。回执里点名它,模型不用猜。
1079
1112
  if _cancel_key:
@@ -1275,7 +1308,7 @@ def _note_command_touches(command: str, cwd, wm) -> None:
1275
1308
  break
1276
1309
  except Exception as exc: # noqa: BLE001
1277
1310
  # 记账失败绝不许拦住一条要跑的命令(同 `touched_files.note` 的规矩)。
1278
- print("[touched] 命令行改动记账失败(不影响执行):%s: %s"
1311
+ print("[touched] command-line change recording failed (does not affect execution): %s: %s"
1279
1312
  % (type(exc).__name__, exc))
1280
1313
 
1281
1314
 
@@ -1422,7 +1455,7 @@ def run_command(command: str = "", cwd: str = "", timeout_ms: int = 0,
1422
1455
  _snap = request_snapshot.get_current()
1423
1456
  spec = current_spec(_snap.session_id if _snap is not None else "")
1424
1457
  if not offers_command(spec):
1425
- print(f"[tier] 拒绝 run_command:档 {spec.level}({spec.name})不给执行命令")
1458
+ print(f"[tier] run_command refused: tier {spec.level} ({spec.name}) does not allow command execution")
1426
1459
  return {
1427
1460
  "success": False,
1428
1461
  "denied": True,
@@ -1465,7 +1498,7 @@ def run_command(command: str = "", cwd: str = "", timeout_ms: int = 0,
1465
1498
  except Exception: # noqa: BLE001
1466
1499
  _unlocked = False
1467
1500
  if _unlocked:
1468
- print("[unlock] deny 档命令放行:%s" % raw[:120])
1501
+ print("[unlock] deny-tier command allowed: %s" % raw[:120])
1469
1502
  tier = TIER_ALLOW
1470
1503
  else:
1471
1504
  return {
@@ -1592,7 +1625,7 @@ def run_command(command: str = "", cwd: str = "", timeout_ms: int = 0,
1592
1625
  # 这里只 `print`(进运行日志)。界面上一行是它的自然后继 ——
1593
1626
  # 要动事件流(前端加一种事件 = 三处),不顺手做。
1594
1627
  if _no_ask:
1595
- print(f"[command] 免问集命中,未询问:{subject[:120]} —— {_no_ask}")
1628
+ print(f"[command] allowlist hit, not asking: {subject[:120]} - {_no_ask}")
1596
1629
 
1597
1630
  # 命令里点名的、工作区内的文件先记一笔(列表要它,留档也要它)。
1598
1631
  # 放在这里 = 审批过了、真的要跑了 —— 没跑的命令不该出现在"本轮改过"里。
@@ -1635,8 +1668,7 @@ def run_command(command: str = "", cwd: str = "", timeout_ms: int = 0,
1635
1668
  ("ok" if result.get("success") else "fail"))
1636
1669
  except Exception as exc:
1637
1670
  # 审计失败不能吞掉:它是这条路径上唯一的留痕。
1638
- print(f"[audit] run_command 审计写入失败({type(exc).__name__}: {exc})"
1639
- f" —— 这条命令执行过但没有记录")
1671
+ print(f"[audit] run_command audit write failed ({type(exc).__name__}: {exc}) - command ran but was not recorded")
1640
1672
 
1641
1673
  # 输出裁剪(保尾 + spill)。在工具里做,不在 agent_loop 里 ——
1642
1674
  # 那边那把刀保的是头部,方向正好相反(见 `_OUT_BUDGET` 的注释)。
package/core/side_call.py CHANGED
@@ -114,17 +114,17 @@ def run(provider, messages, *, session_id: str, directive: str, header: str,
114
114
  resp = provider.chat(payload, tools, system=system,
115
115
  thinking=thinking_for(session_id))
116
116
  except Exception as exc: # noqa: BLE001 —— 不吞错:原样报
117
- print(f"[{tag}] 失败:{type(exc).__name__}: {exc}")
117
+ print(f"[{tag}] failed: {type(exc).__name__}: {exc}")
118
118
  return f"#{tag}-回复异常"
119
119
 
120
120
  text = (getattr(resp, "content", "") or "").strip()
121
121
  if not text:
122
122
  # 静默返回"没有回应"的原形就是这个分支 ——
123
123
  # 用户看不出是模型没说话还是框架坏了。
124
- print(f"[{tag}] 空回答(模型只回了工具调用或空白)")
124
+ print(f"[{tag}] empty reply (model returned only tool calls or blank)")
125
125
  return f"#{tag}-模型没有给出回复,可在主对话重试"
126
126
 
127
127
  if len(text) > MAX_CHARS:
128
128
  text = text[:MAX_CHARS].rstrip() + " …(截断)"
129
- print(f"[{tag}] 回了 {len(text)} 字符")
129
+ print(f"[{tag}] replied {len(text)} chars")
130
130
  return f"{header}\n{text}"
@@ -0,0 +1,164 @@
1
+ # -*- coding: utf-8 -*-
2
+ """`skill_config_write` —— 给模型一个受控的"写技能配置"入口(P3)。
3
+
4
+ ## 为什么需要它
5
+
6
+ `ssh` 这类技能的配置里既有普通字段(默认用户名),也有秘密
7
+ (口令 / 密码 / sudo 密码)。用户把私钥路径或密码打在对话里时,
8
+ 模型能帮填 —— 但用户不该被迫手改 `data/settings.json`。
9
+ 这条入口把"帮填"变成一次有审批的动作。
10
+
11
+ ## 四条硬规矩
12
+
13
+ 1. 审批:它是 `destructive=True` 且没有自己的审批发射点 ——
14
+ 兜底闸在派发前问一次(subject = 工具名)。
15
+ 2. 秘密只写不回显:口令 / 密码类字段写进去,回执与审计只出现字段名;
16
+ 读回接口里它们仍然是 `x-secret`(设置页那一层负责打码)。
17
+ 3. 空值不覆盖:给空串等于"不改这一格" —— 静默把口令清掉是最坏的一种
18
+ "帮了倒忙"。
19
+ 4. 字段白名单:每个技能只认它 manifest 里声明过的键。写一个不存在的键
20
+ 就是一次拼错,拒掉并列出可写的键。
21
+
22
+ ## 它不做什么
23
+
24
+ 不改模型/安全档位(那些只能由用户在设置页改),也不删条目。
25
+ """
26
+
27
+ from __future__ import annotations
28
+
29
+ import json
30
+ import os
31
+ from pathlib import Path
32
+
33
+ __all__ = ["TOOL_NAME", "SCHEMA", "skill_config_write", "register"]
34
+
35
+ TOOL_NAME = "skill_config_write"
36
+
37
+ _SETTINGS = Path("data/settings.json")
38
+
39
+ #: 技能 -> 可写字段。秘密字段单独一张表(回执只记名字)。
40
+ _FIELDS: dict[str, tuple[str, ...]] = {
41
+ "ssh": ("key_path", "passphrase", "user", "password", "sudo_password"),
42
+ }
43
+ _SECRET_FIELDS: frozenset[str] = frozenset({"passphrase", "password", "sudo_password"})
44
+
45
+ SCHEMA = {
46
+ "description": (
47
+ "写入一个技能的配置条目(目前只支持 ssh)。秘密字段(口令/密码)"
48
+ "只写不回显,回执里只出现字段名;空值表示不修改该字段。"
49
+ "这是改动持久安全配置的动作,会先经过一次审批。"
50
+ ),
51
+ "inputSchema": {
52
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
53
+ "type": "object",
54
+ "properties": {
55
+ "skill": {"type": "string", "enum": sorted(_FIELDS)},
56
+ "entry": {"type": "string",
57
+ "description": "条目名(设置页里那一行;新建会直接用这个名字)"},
58
+ "fields": {"type": "object",
59
+ "description": "要写的字段(键 -> 值);空串表示不修改"},
60
+ "active": {"type": "boolean", "default": False,
61
+ "description": "是否把这个条目设为当前使用的那一条"},
62
+ },
63
+ "required": ["skill", "entry", "fields"],
64
+ },
65
+ }
66
+
67
+
68
+ def _err(msg: str) -> dict:
69
+ return {"success": False, "tool": TOOL_NAME, "data": {}, "error": msg}
70
+
71
+
72
+ def _load_settings() -> dict:
73
+ try:
74
+ raw = json.loads(_SETTINGS.read_text(encoding="utf-8"))
75
+ except (OSError, ValueError, TypeError):
76
+ return {}
77
+ return raw if isinstance(raw, dict) else {}
78
+
79
+
80
+ def _save_settings(data: dict) -> None:
81
+ _SETTINGS.parent.mkdir(parents=True, exist_ok=True)
82
+ tmp = _SETTINGS.with_suffix(".json.tmp")
83
+ tmp.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
84
+ os.replace(tmp, _SETTINGS)
85
+
86
+
87
+ def skill_config_write(skill: str, entry: str, fields: dict,
88
+ active: bool = False) -> dict:
89
+ sk = str(skill or "").strip()
90
+ name = str(entry or "").strip()
91
+ if sk not in _FIELDS:
92
+ return _err("这个技能没有配置写入口:%s(可写:%s)"
93
+ % (sk or "(空)", " / ".join(sorted(_FIELDS))))
94
+ if not name:
95
+ return _err("entry 不能为空(它是设置页里那一行的名字)。")
96
+ if not isinstance(fields, dict) or not fields:
97
+ return _err("fields 必须是非空对象(键 -> 值)。")
98
+
99
+ allowed = _FIELDS[sk]
100
+ bad = sorted(k for k in fields if k not in allowed)
101
+ if bad:
102
+ return _err("不认识的字段:%s(这个技能可写:%s)"
103
+ % ("、".join(bad), "、".join(allowed)))
104
+
105
+ data = _load_settings()
106
+ block = data.get("skill_configs")
107
+ if not isinstance(block, dict):
108
+ block = {}
109
+ data["skill_configs"] = block
110
+ section = block.get(sk)
111
+ if not isinstance(section, dict):
112
+ section = {}
113
+ block[sk] = section
114
+ entries = section.get("entries")
115
+ if not isinstance(entries, dict):
116
+ entries = {}
117
+ section["entries"] = entries
118
+ row = entries.get(name)
119
+ if not isinstance(row, dict):
120
+ row = {}
121
+ entries[name] = row
122
+
123
+ written: list[str] = []
124
+ skipped: list[str] = []
125
+ for k in allowed:
126
+ if k not in fields:
127
+ continue
128
+ v = fields.get(k)
129
+ s = str(v if v is not None else "").strip()
130
+ if not s:
131
+ # 空值不覆盖:静默清掉口令是最坏的一种"帮了倒忙"。
132
+ skipped.append(k)
133
+ continue
134
+ row[k] = s
135
+ written.append(k)
136
+
137
+ if not written and not skipped:
138
+ return _err("没有可写的字段。")
139
+ if not written:
140
+ return _err("所有字段都是空值(空值表示不修改);什么都没写。")
141
+
142
+ if active:
143
+ section["active"] = name
144
+ _save_settings(data)
145
+
146
+ return {
147
+ "success": True,
148
+ "tool": TOOL_NAME,
149
+ "data": {
150
+ "skill": sk,
151
+ "entry": name,
152
+ "written": written,
153
+ #: 秘密只记名字,不记值。
154
+ "secret_fields": [k for k in written if k in _SECRET_FIELDS],
155
+ "unchanged_empty": skipped,
156
+ "active": bool(active),
157
+ },
158
+ "error": "",
159
+ }
160
+
161
+
162
+ def register() -> None:
163
+ from bus.registry import register_tool
164
+ register_tool(TOOL_NAME, skill_config_write, SCHEMA)
@@ -338,8 +338,8 @@ def create_skill(name: str = "", manifest_yaml=None, handler_py=None,
338
338
  if tmp_dir.exists():
339
339
  shutil.rmtree(tmp_dir, ignore_errors=True)
340
340
 
341
- print("[skill] create_skill 造了草稿 %s(%d 个工具)%s"
342
- % (name, len(tools), (",已强制 " + ";".join(forced)) if forced else ""))
341
+ print("[skill] create_skill created draft %s (%d tools)%s"
342
+ % (name, len(tools), (", forced " + "; ".join(forced)) if forced else ""))
343
343
 
344
344
  return {
345
345
  "success": True,
@@ -230,12 +230,10 @@ def _read_domain(skill: str) -> str:
230
230
  return ""
231
231
  text = path.read_text(encoding="utf-8").strip()
232
232
  except Exception as exc: # 判据 4:不静默,但也不阻断对话
233
- print(f"[skill_guidance] 读不动 {path}({type(exc).__name__}: {exc})"
234
- f" —— 这个 skill 本轮不带领域片段")
233
+ print(f"[skill_guidance] cannot read {path} ({type(exc).__name__}: {exc}) - this skill gets no domain guidance this turn")
235
234
  return ""
236
235
  if len(text) > _MAX_DOMAIN_CHARS:
237
- print(f"[skill_guidance] {path} 有 {len(text)} 字符,超过 "
238
- f"{_MAX_DOMAIN_CHARS} —— 已截断(它是按条计费的,请写短些)")
236
+ print(f"[skill_guidance] {path} has {len(text)} chars, exceeds {_MAX_DOMAIN_CHARS} - truncated (billed per request, please write shorter)")
239
237
  text = text[:_MAX_DOMAIN_CHARS].rstrip() + "..."
240
238
  return text
241
239
 
@@ -108,16 +108,15 @@ def fit_listing(lines: List[str], budget: int) -> List[str]:
108
108
  heads = [split_line(x)[0] for x in lines]
109
109
  names_only = sum(len(h) for h in heads)
110
110
  if budget <= names_only:
111
- print("[skill_listing] 超预算(%d 行 %d 字符 > %d)—— **只列名字**"
111
+ print("[skill_listing] over budget (%d lines %d chars > %d) - names only"
112
112
  % (len(lines), total, budget))
113
113
  return heads
114
114
 
115
115
  per = max(1, (budget - names_only) // max(1, len(lines)))
116
116
  per = min(per, SKILL_LISTING_DESC_CAP) # 每个 skill 的描述上限
117
117
  out = [h + _cut(x[len(h):], per) for x, h in zip(lines, heads)]
118
- print("[skill_listing] 超预算:%d 行 %d 字符 > %d —— **描述被砍短**"
119
- "(要更宽:设置 `skillListingBudgetFraction` / 环境变量 "
120
- "`SLASH_COMMAND_TOOL_CHAR_BUDGET`)" % (len(lines), total, budget))
118
+ print("[skill_listing] over budget: %d lines %d chars > %d - descriptions truncated"
119
+ % (len(lines), total, budget))
121
120
  return out
122
121
 
123
122
 
@@ -106,7 +106,7 @@ def load(skill_name: str) -> dict:
106
106
  try:
107
107
  data = json.loads(p.read_text(encoding="utf-8"))
108
108
  except Exception as exc: # noqa: BLE001
109
- print("[skill-settings] %s 读不出来:%s: %s" % (p, type(exc).__name__, exc))
109
+ print("[skill-settings] %s unreadable: %s: %s" % (p, type(exc).__name__, exc))
110
110
  return {}
111
111
  return data if isinstance(data, dict) else {}
112
112
 
@@ -65,9 +65,9 @@ _REPO_SKILLS_ABS = Path(__file__).resolve().parent.parent / "skills"
65
65
  #: · `~/.agents/skills` 跨 agent 的共享约定,几个 agent 工具都往这里放
66
66
  #: · 项目级 `.agents/skills/` 同族,跟着项目走
67
67
  #: · `~/.claude/skills/` 别人的目录;我们只读,不写
68
- #: · `~/.codex/skills/.system` 另一家的内置技能(点开头是根的一部分,
68
+ #: · `~/.codex/skills/.system` 该工具的内置技能目录(点开头是根的一部分,
69
69
  #: 所以不经过"跳过点开头条目"那条规则)
70
- #: · `~/.workbuddy/plugins/cache` 另一家的已安装插件
70
+ #: · `~/.workbuddy/plugins/cache` 该工具的已安装插件目录
71
71
  #: (深度 5:`<市场>/<插件>/<版本>/SKILL.md` 与
72
72
  #: `<市场>/<插件>/<版本>/skills/<技能>/SKILL.md` 两种布局都在里面)
73
73
  #:
@@ -120,13 +120,13 @@ def _workspace_plugins_ok() -> bool:
120
120
  from core.plugin_packages import workspace_plugins_allowed
121
121
  ok = workspace_plugins_allowed()
122
122
  except Exception as exc: # noqa: BLE001
123
- print("[skills] 读工作区插件开关失败(按关处理):%s: %s"
123
+ print("[skills] reading workspace plugin switch failed (treating as off): %s: %s"
124
124
  % (type(exc).__name__, exc))
125
125
  return False
126
126
  if not ok and not _WS_PLUGIN_NOTE_SHOWN:
127
127
  _WS_PLUGIN_NOTE_SHOWN = True
128
- print("[skills] 工作区插件包里的技能没有加载:要先在"
129
- "「设置 → 安全设置 → 工作区插件」里打开(与钩子、MCP 服务器同一个开关)。")
128
+ print("[skills] skills from workspace plugin packages were not loaded: enable "
129
+ "Settings -> Security -> Workspace Plugins first (same switch as hooks and MCP servers).")
130
130
  return ok
131
131
 
132
132
 
@@ -143,8 +143,8 @@ def _workspace_plugins_ok() -> bool:
143
143
  #: 只列随框架发布的那些。测试夹具(draft、从不装载、不进安装包)不在这张表里 ——
144
144
  #: 登记一个包里没有的名字,会让用户自己装的同名技能被标成"内置"而藏起来。
145
145
  BUILTIN_SKILLS: frozenset[str] = frozenset({
146
- "entertainment", "file_parser", "github", "mail_parser", "media_gen",
147
- "office_parser", "ppt-master",
146
+ "diagram", "entertainment", "file_parser", "github", "mail_parser",
147
+ "media_gen", "netops", "office_parser", "ppt-master", "ssh",
148
148
  })
149
149
 
150
150