@downcity/plugins 1.0.52 → 1.0.57

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 (329) hide show
  1. package/bin/BuiltinPlugins.d.ts +2 -3
  2. package/bin/BuiltinPlugins.d.ts.map +1 -1
  3. package/bin/BuiltinPlugins.js +2 -6
  4. package/bin/BuiltinPlugins.js.map +1 -1
  5. package/bin/asr/Plugin.d.ts +67 -8
  6. package/bin/asr/Plugin.d.ts.map +1 -1
  7. package/bin/asr/Plugin.js +229 -461
  8. package/bin/asr/Plugin.js.map +1 -1
  9. package/bin/asr/types/AsrPlugin.d.ts +114 -0
  10. package/bin/asr/types/AsrPlugin.d.ts.map +1 -0
  11. package/bin/asr/types/AsrPlugin.js +10 -0
  12. package/bin/asr/types/AsrPlugin.js.map +1 -0
  13. package/bin/auth/Plugin.d.ts +1 -2
  14. package/bin/auth/Plugin.d.ts.map +1 -1
  15. package/bin/auth/Plugin.js +2 -2
  16. package/bin/auth/Plugin.js.map +1 -1
  17. package/bin/chat/ChatPlugin.d.ts +1 -2
  18. package/bin/chat/ChatPlugin.d.ts.map +1 -1
  19. package/bin/chat/ChatPlugin.js +3 -12
  20. package/bin/chat/ChatPlugin.js.map +1 -1
  21. package/bin/chat/PROMPT.direct.d.ts +1 -1
  22. package/bin/chat/PROMPT.direct.d.ts.map +1 -1
  23. package/bin/chat/PROMPT.direct.js +1 -1
  24. package/bin/chat/PROMPT.direct.js.map +1 -1
  25. package/bin/chat/channels/qq/PROMPT.direct.d.ts +1 -1
  26. package/bin/chat/channels/qq/PROMPT.direct.d.ts.map +1 -1
  27. package/bin/chat/channels/qq/PROMPT.direct.js +1 -1
  28. package/bin/chat/channels/qq/PROMPT.direct.js.map +1 -1
  29. package/bin/chat/channels/telegram/Bot.d.ts +6 -0
  30. package/bin/chat/channels/telegram/Bot.d.ts.map +1 -1
  31. package/bin/chat/channels/telegram/Bot.js +24 -0
  32. package/bin/chat/channels/telegram/Bot.js.map +1 -1
  33. package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts +14 -0
  34. package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
  35. package/bin/chat/channels/telegram/TelegramPlatformClient.js +39 -5
  36. package/bin/chat/channels/telegram/TelegramPlatformClient.js.map +1 -1
  37. package/bin/contact/ContactPlugin.d.ts +1 -2
  38. package/bin/contact/ContactPlugin.d.ts.map +1 -1
  39. package/bin/contact/ContactPlugin.js +2 -2
  40. package/bin/contact/ContactPlugin.js.map +1 -1
  41. package/bin/contact/PROMPT.d.ts +1 -1
  42. package/bin/contact/PROMPT.d.ts.map +1 -1
  43. package/bin/contact/PROMPT.js +1 -1
  44. package/bin/contact/PROMPT.js.map +1 -1
  45. package/bin/image/ImagePlugin.d.ts +61 -0
  46. package/bin/image/ImagePlugin.d.ts.map +1 -0
  47. package/bin/image/ImagePlugin.js +207 -0
  48. package/bin/image/ImagePlugin.js.map +1 -0
  49. package/bin/image/types/ImagePlugin.d.ts +136 -0
  50. package/bin/image/types/ImagePlugin.d.ts.map +1 -0
  51. package/bin/image/types/ImagePlugin.js +10 -0
  52. package/bin/image/types/ImagePlugin.js.map +1 -0
  53. package/bin/index.d.ts +4 -0
  54. package/bin/index.d.ts.map +1 -1
  55. package/bin/index.js +1 -0
  56. package/bin/index.js.map +1 -1
  57. package/bin/shell/ShellPlugin.d.ts +1 -2
  58. package/bin/shell/ShellPlugin.d.ts.map +1 -1
  59. package/bin/shell/ShellPlugin.js +2 -2
  60. package/bin/shell/ShellPlugin.js.map +1 -1
  61. package/bin/skill/Action.d.ts +8 -3
  62. package/bin/skill/Action.d.ts.map +1 -1
  63. package/bin/skill/Action.js +9 -11
  64. package/bin/skill/Action.js.map +1 -1
  65. package/bin/skill/Command.d.ts +1 -1
  66. package/bin/skill/Command.d.ts.map +1 -1
  67. package/bin/skill/Command.js +3 -10
  68. package/bin/skill/Command.js.map +1 -1
  69. package/bin/skill/Config.d.ts +9 -9
  70. package/bin/skill/Config.d.ts.map +1 -1
  71. package/bin/skill/Config.js +36 -24
  72. package/bin/skill/Config.js.map +1 -1
  73. package/bin/skill/PROMPT.d.ts +1 -1
  74. package/bin/skill/PROMPT.d.ts.map +1 -1
  75. package/bin/skill/PROMPT.js +1 -1
  76. package/bin/skill/PROMPT.js.map +1 -1
  77. package/bin/skill/Plugin.d.ts +2 -2
  78. package/bin/skill/Plugin.d.ts.map +1 -1
  79. package/bin/skill/Plugin.js +20 -37
  80. package/bin/skill/Plugin.js.map +1 -1
  81. package/bin/skill/runtime/Discovery.d.ts +3 -3
  82. package/bin/skill/runtime/Discovery.d.ts.map +1 -1
  83. package/bin/skill/runtime/Discovery.js +37 -14
  84. package/bin/skill/runtime/Discovery.js.map +1 -1
  85. package/bin/skill/runtime/Paths.d.ts +5 -5
  86. package/bin/skill/runtime/Paths.d.ts.map +1 -1
  87. package/bin/skill/runtime/Paths.js +23 -33
  88. package/bin/skill/runtime/Paths.js.map +1 -1
  89. package/bin/skill/runtime/Prompt.d.ts +2 -2
  90. package/bin/skill/runtime/Prompt.d.ts.map +1 -1
  91. package/bin/skill/runtime/Prompt.js +3 -8
  92. package/bin/skill/runtime/Prompt.js.map +1 -1
  93. package/bin/skill/runtime/SystemProvider.d.ts +2 -2
  94. package/bin/skill/runtime/SystemProvider.d.ts.map +1 -1
  95. package/bin/skill/runtime/SystemProvider.js +2 -2
  96. package/bin/skill/runtime/SystemProvider.js.map +1 -1
  97. package/bin/skill/types/SkillPlugin.d.ts +34 -12
  98. package/bin/skill/types/SkillPlugin.d.ts.map +1 -1
  99. package/bin/skill/types/SkillPlugin.js +2 -1
  100. package/bin/skill/types/SkillPlugin.js.map +1 -1
  101. package/bin/skill/types/SkillRoot.d.ts +1 -1
  102. package/bin/task/Action.js +2 -2
  103. package/bin/task/Action.js.map +1 -1
  104. package/bin/task/PROMPT.d.ts +1 -1
  105. package/bin/task/PROMPT.d.ts.map +1 -1
  106. package/bin/task/PROMPT.js +1 -1
  107. package/bin/task/PROMPT.js.map +1 -1
  108. package/bin/task/TaskPlugin.d.ts +1 -2
  109. package/bin/task/TaskPlugin.d.ts.map +1 -1
  110. package/bin/task/TaskPlugin.js +2 -2
  111. package/bin/task/TaskPlugin.js.map +1 -1
  112. package/bin/tts/Plugin.d.ts +53 -7
  113. package/bin/tts/Plugin.d.ts.map +1 -1
  114. package/bin/tts/Plugin.js +197 -474
  115. package/bin/tts/Plugin.js.map +1 -1
  116. package/bin/tts/types/TtsPlugin.d.ts +63 -102
  117. package/bin/tts/types/TtsPlugin.d.ts.map +1 -1
  118. package/bin/tts/types/TtsPlugin.js +4 -3
  119. package/bin/tts/types/TtsPlugin.js.map +1 -1
  120. package/bin/web/PROMPT.d.ts +1 -1
  121. package/bin/web/PROMPT.d.ts.map +1 -1
  122. package/bin/web/PROMPT.js +1 -1
  123. package/bin/web/PROMPT.js.map +1 -1
  124. package/bin/web/Plugin.d.ts +66 -6
  125. package/bin/web/Plugin.d.ts.map +1 -1
  126. package/bin/web/Plugin.js +130 -447
  127. package/bin/web/Plugin.js.map +1 -1
  128. package/bin/web/WebPromptAssets.d.ts +1 -9
  129. package/bin/web/WebPromptAssets.d.ts.map +1 -1
  130. package/bin/web/WebPromptAssets.js +1 -11
  131. package/bin/web/WebPromptAssets.js.map +1 -1
  132. package/bin/web/runtime/Install.d.ts +19 -0
  133. package/bin/web/runtime/Install.d.ts.map +1 -0
  134. package/bin/web/runtime/Install.js +178 -0
  135. package/bin/web/runtime/Install.js.map +1 -0
  136. package/bin/web/types/WebPlugin.d.ts +37 -109
  137. package/bin/web/types/WebPlugin.d.ts.map +1 -1
  138. package/bin/web/types/WebPlugin.js +5 -7
  139. package/bin/web/types/WebPlugin.js.map +1 -1
  140. package/bin/workboard/Plugin.d.ts +1 -2
  141. package/bin/workboard/Plugin.d.ts.map +1 -1
  142. package/bin/workboard/Plugin.js +2 -2
  143. package/bin/workboard/Plugin.js.map +1 -1
  144. package/package.json +2 -2
  145. package/src/BuiltinPlugins.ts +3 -10
  146. package/src/asr/Plugin.ts +264 -484
  147. package/src/asr/types/AsrPlugin.ts +118 -0
  148. package/src/auth/Plugin.ts +2 -3
  149. package/src/chat/ChatPlugin.ts +3 -14
  150. package/src/chat/PROMPT.direct.ts +1 -1
  151. package/src/chat/PROMPT.direct.ts.txt +5 -7
  152. package/src/chat/channels/qq/PROMPT.direct.ts +1 -1
  153. package/src/chat/channels/qq/PROMPT.direct.ts.txt +1 -1
  154. package/src/chat/channels/telegram/Bot.ts +22 -0
  155. package/src/chat/channels/telegram/TelegramPlatformClient.ts +42 -6
  156. package/src/contact/ContactPlugin.ts +2 -3
  157. package/src/contact/PROMPT.ts +1 -1
  158. package/src/contact/PROMPT.ts.txt +12 -12
  159. package/src/image/ImagePlugin.ts +268 -0
  160. package/src/image/types/ImagePlugin.ts +157 -0
  161. package/src/index.ts +25 -0
  162. package/src/shell/ShellPlugin.ts +2 -3
  163. package/src/skill/Action.ts +20 -9
  164. package/src/skill/Command.ts +3 -13
  165. package/src/skill/Config.ts +41 -34
  166. package/src/skill/PROMPT.ts +1 -1
  167. package/src/skill/PROMPT.ts.txt +14 -2
  168. package/src/skill/Plugin.ts +205 -214
  169. package/src/skill/runtime/Discovery.ts +43 -17
  170. package/src/skill/runtime/Paths.ts +24 -35
  171. package/src/skill/runtime/Prompt.ts +4 -10
  172. package/src/skill/runtime/SystemProvider.ts +4 -4
  173. package/src/skill/types/SkillPlugin.ts +39 -12
  174. package/src/skill/types/SkillRoot.ts +1 -1
  175. package/src/task/Action.ts +2 -2
  176. package/src/task/PROMPT.ts +1 -1
  177. package/src/task/PROMPT.ts.txt +10 -10
  178. package/src/task/TaskPlugin.ts +2 -3
  179. package/src/tts/Plugin.ts +225 -493
  180. package/src/tts/types/TtsPlugin.ts +67 -102
  181. package/src/web/PROMPT.ts +1 -1
  182. package/src/web/PROMPT.ts.txt +32 -6
  183. package/src/web/Plugin.ts +119 -454
  184. package/src/web/WebPromptAssets.ts +1 -13
  185. package/src/web/runtime/Install.ts +241 -0
  186. package/src/web/types/WebPlugin.ts +37 -113
  187. package/src/workboard/Plugin.ts +2 -3
  188. package/bin/asr/Config.d.ts +0 -43
  189. package/bin/asr/Config.d.ts.map +0 -1
  190. package/bin/asr/Config.js +0 -107
  191. package/bin/asr/Config.js.map +0 -1
  192. package/bin/asr/Dependency.d.ts +0 -77
  193. package/bin/asr/Dependency.d.ts.map +0 -1
  194. package/bin/asr/Dependency.js +0 -238
  195. package/bin/asr/Dependency.js.map +0 -1
  196. package/bin/asr/InboundAugment.d.ts +0 -17
  197. package/bin/asr/InboundAugment.d.ts.map +0 -1
  198. package/bin/asr/InboundAugment.js +0 -47
  199. package/bin/asr/InboundAugment.js.map +0 -1
  200. package/bin/asr/ModelCatalog.d.ts +0 -29
  201. package/bin/asr/ModelCatalog.d.ts.map +0 -1
  202. package/bin/asr/ModelCatalog.js +0 -25
  203. package/bin/asr/ModelCatalog.js.map +0 -1
  204. package/bin/tts/Dependency.d.ts +0 -90
  205. package/bin/tts/Dependency.d.ts.map +0 -1
  206. package/bin/tts/Dependency.js +0 -344
  207. package/bin/tts/Dependency.js.map +0 -1
  208. package/bin/tts/PluginSupport.d.ts +0 -25
  209. package/bin/tts/PluginSupport.d.ts.map +0 -1
  210. package/bin/tts/PluginSupport.js +0 -72
  211. package/bin/tts/PluginSupport.js.map +0 -1
  212. package/bin/tts/runtime/Catalog.d.ts +0 -21
  213. package/bin/tts/runtime/Catalog.d.ts.map +0 -1
  214. package/bin/tts/runtime/Catalog.js +0 -90
  215. package/bin/tts/runtime/Catalog.js.map +0 -1
  216. package/bin/tts/runtime/DependencyInstaller.d.ts +0 -143
  217. package/bin/tts/runtime/DependencyInstaller.d.ts.map +0 -1
  218. package/bin/tts/runtime/DependencyInstaller.js +0 -261
  219. package/bin/tts/runtime/DependencyInstaller.js.map +0 -1
  220. package/bin/tts/runtime/Installer.d.ts +0 -89
  221. package/bin/tts/runtime/Installer.d.ts.map +0 -1
  222. package/bin/tts/runtime/Installer.js +0 -188
  223. package/bin/tts/runtime/Installer.js.map +0 -1
  224. package/bin/tts/runtime/Paths.d.ts +0 -20
  225. package/bin/tts/runtime/Paths.d.ts.map +0 -1
  226. package/bin/tts/runtime/Paths.js +0 -32
  227. package/bin/tts/runtime/Paths.js.map +0 -1
  228. package/bin/tts/runtime/Synthesizer.d.ts +0 -44
  229. package/bin/tts/runtime/Synthesizer.d.ts.map +0 -1
  230. package/bin/tts/runtime/Synthesizer.js +0 -363
  231. package/bin/tts/runtime/Synthesizer.js.map +0 -1
  232. package/bin/tts/types/Tts.d.ts +0 -91
  233. package/bin/tts/types/Tts.d.ts.map +0 -1
  234. package/bin/tts/types/Tts.js +0 -9
  235. package/bin/tts/types/Tts.js.map +0 -1
  236. package/bin/voice/Config.d.ts +0 -43
  237. package/bin/voice/Config.d.ts.map +0 -1
  238. package/bin/voice/Config.js +0 -104
  239. package/bin/voice/Config.js.map +0 -1
  240. package/bin/voice/Dependency.d.ts +0 -77
  241. package/bin/voice/Dependency.d.ts.map +0 -1
  242. package/bin/voice/Dependency.js +0 -237
  243. package/bin/voice/Dependency.js.map +0 -1
  244. package/bin/voice/InboundAugment.d.ts +0 -17
  245. package/bin/voice/InboundAugment.d.ts.map +0 -1
  246. package/bin/voice/InboundAugment.js +0 -47
  247. package/bin/voice/InboundAugment.js.map +0 -1
  248. package/bin/voice/ModelCatalog.d.ts +0 -29
  249. package/bin/voice/ModelCatalog.d.ts.map +0 -1
  250. package/bin/voice/ModelCatalog.js +0 -25
  251. package/bin/voice/ModelCatalog.js.map +0 -1
  252. package/bin/voice/runtime/Catalog.d.ts +0 -18
  253. package/bin/voice/runtime/Catalog.d.ts.map +0 -1
  254. package/bin/voice/runtime/Catalog.js +0 -61
  255. package/bin/voice/runtime/Catalog.js.map +0 -1
  256. package/bin/voice/runtime/DependencyInstaller.d.ts +0 -145
  257. package/bin/voice/runtime/DependencyInstaller.d.ts.map +0 -1
  258. package/bin/voice/runtime/DependencyInstaller.js +0 -309
  259. package/bin/voice/runtime/DependencyInstaller.js.map +0 -1
  260. package/bin/voice/runtime/Installer.d.ts +0 -94
  261. package/bin/voice/runtime/Installer.d.ts.map +0 -1
  262. package/bin/voice/runtime/Installer.js +0 -200
  263. package/bin/voice/runtime/Installer.js.map +0 -1
  264. package/bin/voice/runtime/Paths.d.ts +0 -8
  265. package/bin/voice/runtime/Paths.d.ts.map +0 -1
  266. package/bin/voice/runtime/Paths.js +0 -26
  267. package/bin/voice/runtime/Paths.js.map +0 -1
  268. package/bin/voice/runtime/Transcriber.d.ts +0 -57
  269. package/bin/voice/runtime/Transcriber.d.ts.map +0 -1
  270. package/bin/voice/runtime/Transcriber.js +0 -329
  271. package/bin/voice/runtime/Transcriber.js.map +0 -1
  272. package/bin/voice/types/Voice.d.ts +0 -58
  273. package/bin/voice/types/Voice.d.ts.map +0 -1
  274. package/bin/voice/types/Voice.js +0 -9
  275. package/bin/voice/types/Voice.js.map +0 -1
  276. package/bin/voice/types/VoicePlugin.d.ts +0 -190
  277. package/bin/voice/types/VoicePlugin.d.ts.map +0 -1
  278. package/bin/voice/types/VoicePlugin.js +0 -9
  279. package/bin/voice/types/VoicePlugin.js.map +0 -1
  280. package/bin/web/Dependency.d.ts +0 -10
  281. package/bin/web/Dependency.d.ts.map +0 -1
  282. package/bin/web/Dependency.js +0 -10
  283. package/bin/web/Dependency.js.map +0 -1
  284. package/bin/web/PROMPT.agent-browser.d.ts +0 -7
  285. package/bin/web/PROMPT.agent-browser.d.ts.map +0 -1
  286. package/bin/web/PROMPT.agent-browser.js +0 -8
  287. package/bin/web/PROMPT.agent-browser.js.map +0 -1
  288. package/bin/web/PROMPT.web-access.d.ts +0 -7
  289. package/bin/web/PROMPT.web-access.d.ts.map +0 -1
  290. package/bin/web/PROMPT.web-access.js +0 -8
  291. package/bin/web/PROMPT.web-access.js.map +0 -1
  292. package/bin/web/runtime/Config.d.ts +0 -21
  293. package/bin/web/runtime/Config.d.ts.map +0 -1
  294. package/bin/web/runtime/Config.js +0 -79
  295. package/bin/web/runtime/Config.js.map +0 -1
  296. package/bin/web/runtime/Source.d.ts +0 -29
  297. package/bin/web/runtime/Source.d.ts.map +0 -1
  298. package/bin/web/runtime/Source.js +0 -209
  299. package/bin/web/runtime/Source.js.map +0 -1
  300. package/src/asr/Config.ts +0 -138
  301. package/src/asr/Dependency.ts +0 -336
  302. package/src/asr/InboundAugment.ts +0 -59
  303. package/src/asr/ModelCatalog.ts +0 -43
  304. package/src/tts/Dependency.ts +0 -473
  305. package/src/tts/PluginSupport.ts +0 -85
  306. package/src/tts/runtime/Catalog.ts +0 -97
  307. package/src/tts/runtime/DependencyInstaller.ts +0 -436
  308. package/src/tts/runtime/Installer.ts +0 -297
  309. package/src/tts/runtime/Paths.ts +0 -39
  310. package/src/tts/runtime/Synthesizer.ts +0 -480
  311. package/src/tts/types/Tts.ts +0 -99
  312. package/src/voice/Config.ts +0 -135
  313. package/src/voice/Dependency.ts +0 -329
  314. package/src/voice/InboundAugment.ts +0 -59
  315. package/src/voice/ModelCatalog.ts +0 -43
  316. package/src/voice/runtime/Catalog.ts +0 -68
  317. package/src/voice/runtime/DependencyInstaller.ts +0 -505
  318. package/src/voice/runtime/Installer.ts +0 -324
  319. package/src/voice/runtime/Paths.ts +0 -26
  320. package/src/voice/runtime/Transcriber.ts +0 -467
  321. package/src/voice/types/Voice.ts +0 -68
  322. package/src/voice/types/VoicePlugin.ts +0 -194
  323. package/src/web/Dependency.ts +0 -17
  324. package/src/web/PROMPT.agent-browser.ts +0 -9
  325. package/src/web/PROMPT.agent-browser.ts.txt +0 -17
  326. package/src/web/PROMPT.web-access.ts +0 -9
  327. package/src/web/PROMPT.web-access.ts.txt +0 -13
  328. package/src/web/runtime/Config.ts +0 -105
  329. package/src/web/runtime/Source.ts +0 -257
@@ -4,6 +4,6 @@
4
4
  */
5
5
 
6
6
  // Source: src/skill/PROMPT.ts.txt
7
- const TEXT_MODULE_CONTENT = "# Skill Plugin\n\nskill 是你拥有的技能。用户的提出的需求和任务,你都需要先考虑利用相关的skill来高质量的完成。\n\n\n## 使用\n\n使用技能时需要首先通过 `town skill lookup <name>` 命令载入对应的技能内容。\n\n你也可以使用 `town skill --help` 命令对skill进行其他操作。比如 `list`, `find`, `install`等等。\n";
7
+ const TEXT_MODULE_CONTENT = "# Skill Plugin\n\nskill 是你拥有的技能。用户的提出的需求和任务,你都需要先考虑利用相关的skill来高质量的完成。\n\n\n## 使用\n\n使用技能时需要首先通过 `skill` plugin 的 `lookup` action 载入对应的技能内容。\n\n如果当前工具集中存在 `plugin_call`,使用:\n\n```ts\nplugin_call({\n plugin: \"skill\",\n action: \"lookup\",\n payload: {\n name: \"<skill-name>\",\n },\n});\n```\n\n可用 action 包括 `list`、`find`、`install`、`lookup`。\n";
8
8
 
9
9
  export default TEXT_MODULE_CONTENT;
@@ -5,6 +5,18 @@ skill 是你拥有的技能。用户的提出的需求和任务,你都需要
5
5
 
6
6
  ## 使用
7
7
 
8
- 使用技能时需要首先通过 `town skill lookup <name>` 命令载入对应的技能内容。
8
+ 使用技能时需要首先通过 `skill` plugin 的 `lookup` action 载入对应的技能内容。
9
9
 
10
- 你也可以使用 `town skill --help` 命令对skill进行其他操作。比如 `list`, `find`, `install`等等。
10
+ 如果当前工具集中存在 `plugin_call`,使用:
11
+
12
+ ```ts
13
+ plugin_call({
14
+ plugin: "skill",
15
+ action: "lookup",
16
+ payload: {
17
+ name: "<skill-name>",
18
+ },
19
+ });
20
+ ```
21
+
22
+ 可用 action 包括 `list`、`find`、`install`、`lookup`。
@@ -7,21 +7,17 @@
7
7
  * - skills overview 文本通过 `plugin.system` 注入,不再依赖 plugin.system。
8
8
  */
9
9
 
10
- import type { AgentRuntime } from "@downcity/agent/internal/types/runtime/agent/AgentRuntime.js";
11
10
  import { BasePlugin } from "@downcity/agent/internal/plugin/core/BasePlugin.js";
12
11
  import type { Plugin } from "@downcity/agent/internal/plugin/types/Plugin.js";
13
12
  import type { JsonObject, JsonValue } from "@downcity/agent/internal/types/common/Json.js";
14
- import { isPluginEnabled } from "@downcity/agent/internal/plugin/core/Activation.js";
15
13
  import type {
16
14
  SkillPluginFindPayload,
17
15
  SkillPluginInstallPayload,
18
16
  SkillPluginLookupPayload,
17
+ SkillPluginOptions,
19
18
  } from "@/skill/types/SkillPlugin.js";
20
19
  import { SKILL_PLUGIN_ACTIONS } from "@/skill/types/SkillPlugin.js";
21
- import {
22
- DEFAULT_SKILL_PLUGIN_CONFIG,
23
- readSkillPluginConfig,
24
- } from "@/skill/Config.js";
20
+ import { resolveSkillPluginOptions } from "@/skill/Config.js";
25
21
  import { skillFindCommand, skillInstallCommand } from "@/skill/Command.js";
26
22
  import {
27
23
  findLearnedSkillExact,
@@ -92,245 +88,239 @@ function inferSkillQueryFromSpec(spec: string): string {
92
88
  return "";
93
89
  }
94
90
 
95
- function createSkillPluginDefinition(plugin: Plugin): Plugin {
91
+ function createSkillPluginDefinition(options: SkillPluginOptions): Plugin {
96
92
  return {
97
93
  name: "skill",
98
- title: "Skill Catalog And Loader",
99
- description:
100
- "Finds, installs, lists, and reads local skills, and injects the current skill overview into system prompts so the agent knows what capabilities are available.",
101
- config: {
102
- plugin: "skill",
103
- scope: "project",
104
- defaultValue: {
105
- ...DEFAULT_SKILL_PLUGIN_CONFIG,
94
+ title: "Skill Catalog And Loader",
95
+ description:
96
+ "Finds, installs, lists, and reads local skills, and injects the current skill overview into system prompts so the agent knows what capabilities are available.",
97
+ async system(context) {
98
+ const dynamicText = String(
99
+ await buildSkillsSystemText({
100
+ rootPath: context.rootPath,
101
+ options,
102
+ }),
103
+ ).trim();
104
+ return [SKILL_PLUGIN_PROMPT, dynamicText].filter(Boolean).join("\n\n");
106
105
  },
107
- },
108
- availability(context) {
109
- if (!isPluginEnabled({ plugin, context })) {
110
- return {
111
- enabled: false,
112
- available: false,
113
- reasons: ["skill plugin disabled in project config"],
114
- };
115
- }
116
- return {
117
- enabled: true,
118
- available: true,
119
- reasons: [],
120
- };
121
- },
122
- async system(context) {
123
- const dynamicText = String(await buildSkillsSystemText(context)).trim();
124
- return [SKILL_PLUGIN_PROMPT, dynamicText].filter(Boolean).join("\n\n");
125
- },
126
- actions: {
127
- [SKILL_PLUGIN_ACTIONS.find]: {
128
- command: {
129
- description: "查找 `list` 中不存在的未学会 skills(缺失时再 install)",
130
- configure(command) {
131
- command.argument("<query>");
132
- },
133
- mapInput({ args }): SkillPluginFindPayload {
134
- const query = String(args[0] || "").trim();
135
- if (!query) throw new Error("Missing query");
136
- return { query };
106
+ actions: {
107
+ [SKILL_PLUGIN_ACTIONS.find]: {
108
+ command: {
109
+ description: "查找 `list` 中不存在的未学会 skills(缺失时再 install)",
110
+ configure(command) {
111
+ command.argument("<query>");
112
+ },
113
+ mapInput({ args }): SkillPluginFindPayload {
114
+ const query = String(args[0] || "").trim();
115
+ if (!query) throw new Error("Missing query");
116
+ return { query };
117
+ },
137
118
  },
138
- },
139
- async execute(params) {
140
- const payload = params.payload as SkillPluginFindPayload;
141
- const rootPath = params.context.rootPath;
142
- const exactLearned = findLearnedSkillExact(rootPath, payload.query);
143
- if (exactLearned) {
119
+ async execute(params) {
120
+ const payload = params.payload as SkillPluginFindPayload;
121
+ const rootPath = params.context.rootPath;
122
+ const exactLearned = findLearnedSkillExact(
123
+ rootPath,
124
+ payload.query,
125
+ options,
126
+ );
127
+ if (exactLearned) {
128
+ return {
129
+ success: true,
130
+ data: {
131
+ query: payload.query,
132
+ message: "该技能已在 list 中,无需 install。使用前请先执行 lookup。",
133
+ workflow: ["list", "lookup"],
134
+ nextAction: "lookup",
135
+ learnedSkill: exactLearned,
136
+ learnedHints: [],
137
+ },
138
+ };
139
+ }
140
+
141
+ const learnedHints = searchLearnedSkills(
142
+ rootPath,
143
+ payload.query,
144
+ 5,
145
+ options,
146
+ );
147
+ await skillFindCommand(payload.query);
144
148
  return {
145
149
  success: true,
146
150
  data: {
147
151
  query: payload.query,
148
- message: "该技能已在 list 中,无需 install。使用前请先执行 lookup。",
149
- workflow: ["list", "lookup"],
150
- nextAction: "lookup",
151
- learnedSkill: exactLearned,
152
- learnedHints: [],
152
+ message: "已执行缺失技能检索;若目标不在 list 中,可 install 后再 lookup。",
153
+ workflow: ["find", "install", "lookup"],
154
+ nextAction: "install",
155
+ learnedSkill: null,
156
+ learnedHints,
153
157
  },
154
158
  };
155
- }
156
-
157
- const learnedHints = searchLearnedSkills(rootPath, payload.query, 5);
158
- await skillFindCommand(payload.query);
159
- return {
160
- success: true,
161
- data: {
162
- query: payload.query,
163
- message: "已执行缺失技能检索;若目标不在 list 中,可 install 后再 lookup。",
164
- workflow: ["find", "install", "lookup"],
165
- nextAction: "install",
166
- learnedSkill: null,
167
- learnedHints,
168
- },
169
- };
170
- },
171
- },
172
- [SKILL_PLUGIN_ACTIONS.install]: {
173
- command: {
174
- description: "安装 `list` 中不存在的 skill(完成后请先 lookup)",
175
- configure(command) {
176
- command
177
- .argument("<spec>")
178
- .option("-g, --global", "全局安装(默认 true)", true)
179
- .option("-y, --yes", "跳过确认(默认 true)", true)
180
- .option("--agent <agent>", "指定 agent", "claude-code");
181
- },
182
- mapInput({ args, opts }): SkillPluginInstallPayload {
183
- const spec = String(args[0] || "").trim();
184
- if (!spec) throw new Error("Missing spec");
185
- return {
186
- spec,
187
- global: getBooleanOpt(opts, "global"),
188
- yes: getBooleanOpt(opts, "yes"),
189
- agent: getStringOpt(opts, "agent"),
190
- };
191
159
  },
192
160
  },
193
- async execute(params) {
194
- const payload = params.payload as SkillPluginInstallPayload;
195
- const rootPath = params.context.rootPath;
196
- const queryFromSpec = inferSkillQueryFromSpec(payload.spec);
197
- const beforeList = listSkills(rootPath).skills;
198
- const beforeIds = new Set(beforeList.map((item) => item.id));
161
+ [SKILL_PLUGIN_ACTIONS.install]: {
162
+ command: {
163
+ description: "安装 `list` 中不存在的 skill(完成后请先 lookup)",
164
+ configure(command) {
165
+ command
166
+ .argument("<spec>")
167
+ .option("-g, --global", "全局安装(默认 true)", true)
168
+ .option("-y, --yes", "跳过确认(默认 true)", true)
169
+ .option("--agent <agent>", "指定 agent", "claude-code");
170
+ },
171
+ mapInput({ args, opts }): SkillPluginInstallPayload {
172
+ const spec = String(args[0] || "").trim();
173
+ if (!spec) throw new Error("Missing spec");
174
+ return {
175
+ spec,
176
+ global: getBooleanOpt(opts, "global"),
177
+ yes: getBooleanOpt(opts, "yes"),
178
+ agent: getStringOpt(opts, "agent"),
179
+ };
180
+ },
181
+ },
182
+ async execute(params) {
183
+ const payload = params.payload as SkillPluginInstallPayload;
184
+ const rootPath = params.context.rootPath;
185
+ const queryFromSpec = inferSkillQueryFromSpec(payload.spec);
186
+ const beforeList = listSkills(rootPath, options).skills;
187
+ const beforeIds = new Set(beforeList.map((item) => item.id));
188
+
189
+ const learnedBefore =
190
+ findLearnedSkillExact(rootPath, queryFromSpec, options) ||
191
+ findLearnedSkillExact(rootPath, payload.spec, options);
192
+ if (learnedBefore) {
193
+ return {
194
+ success: true,
195
+ data: {
196
+ spec: payload.spec,
197
+ skipped: true,
198
+ message: "技能已在 list 中,无需 install。使用前请先执行 lookup。",
199
+ workflow: ["list", "lookup"],
200
+ nextAction: "lookup",
201
+ queryFromSpec,
202
+ addedSkills: [],
203
+ learnedSkill: learnedBefore,
204
+ },
205
+ };
206
+ }
207
+
208
+ await skillInstallCommand(payload.spec, {
209
+ global: payload.global,
210
+ yes: payload.yes,
211
+ agent: payload.agent,
212
+ });
213
+ const afterList = listSkills(rootPath, options).skills;
214
+ const addedSkills = afterList.filter((item) => !beforeIds.has(item.id));
215
+ const learnedAfter =
216
+ findLearnedSkillExact(rootPath, queryFromSpec, options) ||
217
+ findLearnedSkillExact(rootPath, payload.spec, options) ||
218
+ (addedSkills.length === 1 ? addedSkills[0] : undefined);
199
219
 
200
- const learnedBefore =
201
- findLearnedSkillExact(rootPath, queryFromSpec) ||
202
- findLearnedSkillExact(rootPath, payload.spec);
203
- if (learnedBefore) {
204
220
  return {
205
221
  success: true,
206
222
  data: {
207
223
  spec: payload.spec,
208
- skipped: true,
209
- message: "技能已在 list 中,无需 install。使用前请先执行 lookup",
210
- workflow: ["list", "lookup"],
224
+ message: "技能学习完成。使用技能前请先执行 lookup 读取该技能的 SKILL.md 内容。",
225
+ workflow: ["find", "install", "lookup"],
211
226
  nextAction: "lookup",
227
+ skipped: false,
212
228
  queryFromSpec,
213
- addedSkills: [],
214
- learnedSkill: learnedBefore,
229
+ addedSkills,
230
+ learnedSkill: learnedAfter || null,
215
231
  },
216
232
  };
217
- }
218
-
219
- await skillInstallCommand(payload.spec, {
220
- global: payload.global,
221
- yes: payload.yes,
222
- agent: payload.agent,
223
- });
224
- const afterList = listSkills(rootPath).skills;
225
- const addedSkills = afterList.filter((item) => !beforeIds.has(item.id));
226
- const learnedAfter =
227
- findLearnedSkillExact(rootPath, queryFromSpec) ||
228
- findLearnedSkillExact(rootPath, payload.spec) ||
229
- (addedSkills.length === 1 ? addedSkills[0] : undefined);
230
-
231
- return {
232
- success: true,
233
- data: {
234
- spec: payload.spec,
235
- message: "技能学习完成。使用技能前请先执行 lookup 读取该技能的 SKILL.md 内容。",
236
- workflow: ["find", "install", "lookup"],
237
- nextAction: "lookup",
238
- skipped: false,
239
- queryFromSpec,
240
- addedSkills,
241
- learnedSkill: learnedAfter || null,
242
- },
243
- };
244
- },
245
- },
246
- [SKILL_PLUGIN_ACTIONS.list]: {
247
- command: {
248
- description: "列出当前已学会(本地可发现)的 skills",
249
- mapInput() {
250
- return {};
251
233
  },
252
234
  },
253
- api: {
254
- method: "GET",
255
- },
256
- execute(params) {
257
- return {
258
- success: true,
259
- data: listSkills(params.context.rootPath),
260
- };
261
- },
262
- },
263
- [SKILL_PLUGIN_ACTIONS.lookup]: {
264
- command: {
265
- description: "读取已学会 skill 内容(SKILL.md)",
266
- configure(command) {
267
- command.argument("<name>");
235
+ [SKILL_PLUGIN_ACTIONS.list]: {
236
+ command: {
237
+ description: "列出当前已学会(本地可发现)的 skills",
238
+ mapInput() {
239
+ return {};
240
+ },
268
241
  },
269
- mapInput({ args }): SkillPluginLookupPayload {
270
- const name = String(args[0] || "").trim();
271
- if (!name) throw new Error("Missing name");
272
- return { name };
242
+ api: {
243
+ method: "GET",
273
244
  },
274
- },
275
- api: {
276
- method: "POST",
277
- async mapInput(c): Promise<SkillPluginLookupPayload> {
278
- const body = readJsonObject(await c.req.json());
279
- const name = String(body.name || "").trim();
280
- if (!name) throw new Error("Missing name");
281
- return { name };
245
+ execute(params) {
246
+ return {
247
+ success: true,
248
+ data: listSkills(params.context.rootPath, options),
249
+ };
282
250
  },
283
251
  },
284
- async execute(params) {
285
- const payload = params.payload as SkillPluginLookupPayload;
286
- const result = await lookupSkill({
287
- projectRoot: params.context.rootPath,
288
- request: {
289
- name: payload.name,
252
+ [SKILL_PLUGIN_ACTIONS.lookup]: {
253
+ command: {
254
+ description: "读取已学会 skill 内容(SKILL.md)",
255
+ configure(command) {
256
+ command.argument("<name>");
290
257
  },
291
- });
292
- if (!result.success) {
293
- return {
294
- success: false,
295
- error: result.error || "skill lookup failed",
296
- };
297
- }
258
+ mapInput({ args }): SkillPluginLookupPayload {
259
+ const name = String(args[0] || "").trim();
260
+ if (!name) throw new Error("Missing name");
261
+ return { name };
262
+ },
263
+ },
264
+ api: {
265
+ method: "POST",
266
+ async mapInput(c): Promise<SkillPluginLookupPayload> {
267
+ const body = readJsonObject(await c.req.json());
268
+ const name = String(body.name || "").trim();
269
+ if (!name) throw new Error("Missing name");
270
+ return { name };
271
+ },
272
+ },
273
+ async execute(params) {
274
+ const payload = params.payload as SkillPluginLookupPayload;
275
+ const result = await lookupSkill({
276
+ projectRoot: params.context.rootPath,
277
+ request: {
278
+ name: payload.name,
279
+ },
280
+ options,
281
+ });
282
+ if (!result.success) {
283
+ return {
284
+ success: false,
285
+ error: result.error || "skill lookup failed",
286
+ };
287
+ }
298
288
 
299
- const skillName = String(result.skill?.name || result.skill?.id || "").trim();
300
- const openingTag = skillName
301
- ? `<skill name="${sanitizeXmlAttr(skillName)}">`
302
- : "<skill>";
303
- const skillUserMessage = [
304
- openingTag,
305
- String(result.content || "").trim(),
306
- "</skill>",
307
- ]
308
- .filter(Boolean)
309
- .join("\n")
310
- .trim();
289
+ const skillName = String(result.skill?.name || result.skill?.id || "").trim();
290
+ const openingTag = skillName
291
+ ? `<skill name="${sanitizeXmlAttr(skillName)}">`
292
+ : "<skill>";
293
+ const skillUserMessage = [
294
+ openingTag,
295
+ String(result.content || "").trim(),
296
+ "</skill>",
297
+ ]
298
+ .filter(Boolean)
299
+ .join("\n")
300
+ .trim();
311
301
 
312
- return {
313
- success: true,
314
- data: {
302
+ return {
315
303
  success: true,
316
- ...(result.skill ? { skill: result.skill } : {}),
317
- message: "技能内容已准备,下一步将以 `<skill>...</skill>` user message 注入。",
318
- __ship: {
319
- injectUserMessages: [
320
- {
321
- text: skillUserMessage,
322
- note: "skill_lookup",
323
- },
324
- ],
325
- suppressToolOutput: true,
326
- toolOutputMessage:
327
- "skill lookup success; content injected as <skill> user message.",
304
+ data: {
305
+ success: true,
306
+ ...(result.skill ? { skill: result.skill } : {}),
307
+ message: "技能内容已准备,下一步将以 `<skill>...</skill>` user message 注入。",
308
+ __ship: {
309
+ injectUserMessages: [
310
+ {
311
+ text: skillUserMessage,
312
+ note: "skill_lookup",
313
+ },
314
+ ],
315
+ suppressToolOutput: true,
316
+ toolOutputMessage:
317
+ "skill lookup success; content injected as <skill> user message.",
318
+ },
328
319
  },
329
- },
330
- };
320
+ };
321
+ },
331
322
  },
332
323
  },
333
- },
334
324
  };
335
325
  }
336
326
 
@@ -340,8 +330,9 @@ function createSkillPluginDefinition(plugin: Plugin): Plugin {
340
330
  export class SkillPlugin extends BasePlugin {
341
331
  readonly name = "skill";
342
332
 
343
- constructor(agent: AgentRuntime | null = null) {
344
- super(agent);
345
- Object.assign(this, createSkillPluginDefinition(this));
333
+ constructor(options: SkillPluginOptions = {}) {
334
+ super();
335
+ const resolvedOptions = resolveSkillPluginOptions(options);
336
+ Object.assign(this, createSkillPluginDefinition(resolvedOptions));
346
337
  }
347
338
  }
@@ -2,7 +2,7 @@
2
2
  * Skills discovery:扫描可用 skills 并生成索引。
3
3
  *
4
4
  * 关键点(中文)
5
- * - 扫描范围由 `paths.ts` 决定(项目、用户目录、可选外部目录)。
5
+ * - 扫描范围由 `paths.ts` 决定(项目、用户目录、构造参数路径)。
6
6
  * - 同名 skill 按根目录优先级“先到先得”。
7
7
  */
8
8
 
@@ -10,14 +10,46 @@ import fs from "fs-extra";
10
10
  import yaml from "js-yaml";
11
11
  import path from "path";
12
12
  import type { Dirent, Stats } from "node:fs";
13
- import type { DowncityConfig } from "@downcity/agent/internal/config/Config.js";
14
- import { readSkillPluginConfig } from "../Config.js";
13
+ import { resolveSkillPluginOptions } from "../Config.js";
15
14
  import { parseFrontMatter } from "./Frontmatter.js";
16
15
  import { getClaudeSkillSearchRoots } from "./Paths.js";
17
- import { isSubpath } from "./Utils.js";
18
16
  import type { ClaudeSkill } from "@/skill/types/ClaudeSkill.js";
17
+ import type {
18
+ SkillPluginIgnoreRule,
19
+ SkillPluginOptions,
20
+ } from "@/skill/types/SkillPlugin.js";
19
21
  import type { JsonObject, JsonValue } from "@downcity/agent/internal/types/common/Json.js";
20
22
 
23
+ function matchesIgnoreRule(skill: ClaudeSkill, rule: SkillPluginIgnoreRule): boolean {
24
+ if (typeof rule === "string") {
25
+ const value = rule.trim().toLowerCase();
26
+ if (!value) return false;
27
+ return skill.id.toLowerCase() === value || skill.name.toLowerCase() === value;
28
+ }
29
+ if (rule instanceof RegExp) {
30
+ rule.lastIndex = 0;
31
+ const matchesId = rule.test(skill.id);
32
+ rule.lastIndex = 0;
33
+ const matchesName = rule.test(skill.name);
34
+ rule.lastIndex = 0;
35
+ return matchesId || matchesName;
36
+ }
37
+ if (typeof rule === "function") {
38
+ return rule(skill);
39
+ }
40
+ return false;
41
+ }
42
+
43
+ function shouldIgnoreSkill(
44
+ skill: ClaudeSkill,
45
+ rules: SkillPluginIgnoreRule[],
46
+ ): boolean {
47
+ for (const rule of rules) {
48
+ if (matchesIgnoreRule(skill, rule)) return true;
49
+ }
50
+ return false;
51
+ }
52
+
21
53
  /**
22
54
  * 扫描并发现 Claude Code-compatible skills。
23
55
  *
@@ -34,26 +66,18 @@ import type { JsonObject, JsonValue } from "@downcity/agent/internal/types/commo
34
66
  */
35
67
  export function discoverClaudeSkillsSync(
36
68
  projectRoot: string,
37
- config: DowncityConfig,
69
+ options?: SkillPluginOptions | null,
38
70
  ): ClaudeSkill[] {
39
71
  const root = String(projectRoot || "").trim();
40
72
  if (!root) return [];
41
- const allowExternal = readSkillPluginConfig(config).allowExternalPaths;
42
- const roots = getClaudeSkillSearchRoots(root, config);
73
+ const resolvedOptions = resolveSkillPluginOptions(options);
74
+ const roots = getClaudeSkillSearchRoots(root, resolvedOptions);
43
75
 
44
76
  const outById = new Map<string, ClaudeSkill>();
45
77
 
46
78
  for (const r of roots) {
47
79
  const sourceRoot = r.resolved;
48
80
 
49
- // allowExternalPaths 只影响 config 外部路径;home 默认可扫描
50
- if (
51
- r.source === "config" &&
52
- !allowExternal &&
53
- !isSubpath(root, sourceRoot)
54
- ) {
55
- continue;
56
- }
57
81
  if (!fs.existsSync(sourceRoot)) continue;
58
82
  let stat: Stats;
59
83
  try {
@@ -122,7 +146,7 @@ export function discoverClaudeSkillsSync(
122
146
  const allowedTools =
123
147
  meta?.["allowed-tools"] ?? meta?.allowedTools ?? meta?.allowed_tools;
124
148
 
125
- outById.set(id, {
149
+ const skill: ClaudeSkill = {
126
150
  id,
127
151
  name,
128
152
  description,
@@ -131,7 +155,9 @@ export function discoverClaudeSkillsSync(
131
155
  directoryPath,
132
156
  skillMdPath,
133
157
  allowedTools,
134
- });
158
+ };
159
+ if (shouldIgnoreSkill(skill, resolvedOptions.ignore)) continue;
160
+ outById.set(id, skill);
135
161
  }
136
162
  }
137
163