@xagent-ai/cli 1.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 (537) hide show
  1. package/.eslintrc.js +25 -0
  2. package/.gitmodules +3 -0
  3. package/.prettierrc.json +8 -0
  4. package/CONTRIBUTING.md +167 -0
  5. package/LICENSE +21 -0
  6. package/README.md +280 -0
  7. package/README_CN.md +280 -0
  8. package/dist/agents.d.ts +21 -0
  9. package/dist/agents.d.ts.map +1 -0
  10. package/dist/agents.js +463 -0
  11. package/dist/agents.js.map +1 -0
  12. package/dist/ai-client.d.ts +83 -0
  13. package/dist/ai-client.d.ts.map +1 -0
  14. package/dist/ai-client.js +1280 -0
  15. package/dist/ai-client.js.map +1 -0
  16. package/dist/auth.d.ts +25 -0
  17. package/dist/auth.d.ts.map +1 -0
  18. package/dist/auth.js +573 -0
  19. package/dist/auth.js.map +1 -0
  20. package/dist/cancellation.d.ts +46 -0
  21. package/dist/cancellation.d.ts.map +1 -0
  22. package/dist/cancellation.js +154 -0
  23. package/dist/cancellation.js.map +1 -0
  24. package/dist/checkpoint.d.ts +28 -0
  25. package/dist/checkpoint.d.ts.map +1 -0
  26. package/dist/checkpoint.js +186 -0
  27. package/dist/checkpoint.js.map +1 -0
  28. package/dist/cli.d.ts +3 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +364 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/config.d.ts +49 -0
  33. package/dist/config.d.ts.map +1 -0
  34. package/dist/config.js +205 -0
  35. package/dist/config.js.map +1 -0
  36. package/dist/context-compressor.d.ts +51 -0
  37. package/dist/context-compressor.d.ts.map +1 -0
  38. package/dist/context-compressor.js +231 -0
  39. package/dist/context-compressor.js.map +1 -0
  40. package/dist/conversation.d.ts +34 -0
  41. package/dist/conversation.d.ts.map +1 -0
  42. package/dist/conversation.js +221 -0
  43. package/dist/conversation.js.map +1 -0
  44. package/dist/gui-subagent/action-parser/actionParser.d.ts +19 -0
  45. package/dist/gui-subagent/action-parser/actionParser.d.ts.map +1 -0
  46. package/dist/gui-subagent/action-parser/actionParser.js +203 -0
  47. package/dist/gui-subagent/action-parser/actionParser.js.map +1 -0
  48. package/dist/gui-subagent/action-parser/constants.d.ts +8 -0
  49. package/dist/gui-subagent/action-parser/constants.d.ts.map +1 -0
  50. package/dist/gui-subagent/action-parser/constants.js +12 -0
  51. package/dist/gui-subagent/action-parser/constants.js.map +1 -0
  52. package/dist/gui-subagent/action-parser/index.d.ts +3 -0
  53. package/dist/gui-subagent/action-parser/index.d.ts.map +1 -0
  54. package/dist/gui-subagent/action-parser/index.js +6 -0
  55. package/dist/gui-subagent/action-parser/index.js.map +1 -0
  56. package/dist/gui-subagent/action-parser/types.d.ts +24 -0
  57. package/dist/gui-subagent/action-parser/types.d.ts.map +1 -0
  58. package/dist/gui-subagent/action-parser/types.js +12 -0
  59. package/dist/gui-subagent/action-parser/types.js.map +1 -0
  60. package/dist/gui-subagent/agent/gui-agent.d.ts +126 -0
  61. package/dist/gui-subagent/agent/gui-agent.d.ts.map +1 -0
  62. package/dist/gui-subagent/agent/gui-agent.js +820 -0
  63. package/dist/gui-subagent/agent/gui-agent.js.map +1 -0
  64. package/dist/gui-subagent/agent/index.d.ts +5 -0
  65. package/dist/gui-subagent/agent/index.d.ts.map +1 -0
  66. package/dist/gui-subagent/agent/index.js +5 -0
  67. package/dist/gui-subagent/agent/index.js.map +1 -0
  68. package/dist/gui-subagent/index.d.ts +43 -0
  69. package/dist/gui-subagent/index.d.ts.map +1 -0
  70. package/dist/gui-subagent/index.js +96 -0
  71. package/dist/gui-subagent/index.js.map +1 -0
  72. package/dist/gui-subagent/operator/base-operator.d.ts +108 -0
  73. package/dist/gui-subagent/operator/base-operator.d.ts.map +1 -0
  74. package/dist/gui-subagent/operator/base-operator.js +172 -0
  75. package/dist/gui-subagent/operator/base-operator.js.map +1 -0
  76. package/dist/gui-subagent/operator/browser-operator.d.ts +36 -0
  77. package/dist/gui-subagent/operator/browser-operator.d.ts.map +1 -0
  78. package/dist/gui-subagent/operator/browser-operator.js +306 -0
  79. package/dist/gui-subagent/operator/browser-operator.js.map +1 -0
  80. package/dist/gui-subagent/operator/computer-operator.d.ts +31 -0
  81. package/dist/gui-subagent/operator/computer-operator.d.ts.map +1 -0
  82. package/dist/gui-subagent/operator/computer-operator.js +441 -0
  83. package/dist/gui-subagent/operator/computer-operator.js.map +1 -0
  84. package/dist/gui-subagent/operator/desktop-operator.d.ts +55 -0
  85. package/dist/gui-subagent/operator/desktop-operator.d.ts.map +1 -0
  86. package/dist/gui-subagent/operator/desktop-operator.js +527 -0
  87. package/dist/gui-subagent/operator/desktop-operator.js.map +1 -0
  88. package/dist/gui-subagent/operator/index.d.ts +7 -0
  89. package/dist/gui-subagent/operator/index.d.ts.map +1 -0
  90. package/dist/gui-subagent/operator/index.js +6 -0
  91. package/dist/gui-subagent/operator/index.js.map +1 -0
  92. package/dist/gui-subagent/types/actions.d.ts +108 -0
  93. package/dist/gui-subagent/types/actions.d.ts.map +1 -0
  94. package/dist/gui-subagent/types/actions.js +39 -0
  95. package/dist/gui-subagent/types/actions.js.map +1 -0
  96. package/dist/gui-subagent/types/index.d.ts +6 -0
  97. package/dist/gui-subagent/types/index.d.ts.map +1 -0
  98. package/dist/gui-subagent/types/index.js +6 -0
  99. package/dist/gui-subagent/types/index.js.map +1 -0
  100. package/dist/gui-subagent/types/operator.d.ts +95 -0
  101. package/dist/gui-subagent/types/operator.d.ts.map +1 -0
  102. package/dist/gui-subagent/types/operator.js +16 -0
  103. package/dist/gui-subagent/types/operator.js.map +1 -0
  104. package/dist/gui-subagent/utils.d.ts +19 -0
  105. package/dist/gui-subagent/utils.d.ts.map +1 -0
  106. package/dist/gui-subagent/utils.js +42 -0
  107. package/dist/gui-subagent/utils.js.map +1 -0
  108. package/dist/hook.d.ts +73 -0
  109. package/dist/hook.d.ts.map +1 -0
  110. package/dist/hook.js +156 -0
  111. package/dist/hook.js.map +1 -0
  112. package/dist/index.d.ts +19 -0
  113. package/dist/index.d.ts.map +1 -0
  114. package/dist/index.js +19 -0
  115. package/dist/index.js.map +1 -0
  116. package/dist/input-history.d.ts +24 -0
  117. package/dist/input-history.d.ts.map +1 -0
  118. package/dist/input-history.js +94 -0
  119. package/dist/input-history.js.map +1 -0
  120. package/dist/input-processor.d.ts +31 -0
  121. package/dist/input-processor.d.ts.map +1 -0
  122. package/dist/input-processor.js +233 -0
  123. package/dist/input-processor.js.map +1 -0
  124. package/dist/keyboard-manager.d.ts +151 -0
  125. package/dist/keyboard-manager.d.ts.map +1 -0
  126. package/dist/keyboard-manager.js +396 -0
  127. package/dist/keyboard-manager.js.map +1 -0
  128. package/dist/logger.d.ts +75 -0
  129. package/dist/logger.d.ts.map +1 -0
  130. package/dist/logger.js +339 -0
  131. package/dist/logger.js.map +1 -0
  132. package/dist/mcp.d.ts +57 -0
  133. package/dist/mcp.d.ts.map +1 -0
  134. package/dist/mcp.js +483 -0
  135. package/dist/mcp.js.map +1 -0
  136. package/dist/memory.d.ts +25 -0
  137. package/dist/memory.d.ts.map +1 -0
  138. package/dist/memory.js +250 -0
  139. package/dist/memory.js.map +1 -0
  140. package/dist/print-system-prompt.d.ts +2 -0
  141. package/dist/print-system-prompt.d.ts.map +1 -0
  142. package/dist/print-system-prompt.js +40 -0
  143. package/dist/print-system-prompt.js.map +1 -0
  144. package/dist/session-manager.d.ts +41 -0
  145. package/dist/session-manager.d.ts.map +1 -0
  146. package/dist/session-manager.js +234 -0
  147. package/dist/session-manager.js.map +1 -0
  148. package/dist/session.d.ts +77 -0
  149. package/dist/session.d.ts.map +1 -0
  150. package/dist/session.js +1081 -0
  151. package/dist/session.js.map +1 -0
  152. package/dist/skill-invoker.d.ts +177 -0
  153. package/dist/skill-invoker.d.ts.map +1 -0
  154. package/dist/skill-invoker.js +1643 -0
  155. package/dist/skill-invoker.js.map +1 -0
  156. package/dist/skill-loader.d.ts +76 -0
  157. package/dist/skill-loader.d.ts.map +1 -0
  158. package/dist/skill-loader.js +407 -0
  159. package/dist/skill-loader.js.map +1 -0
  160. package/dist/slash-commands.d.ts +60 -0
  161. package/dist/slash-commands.d.ts.map +1 -0
  162. package/dist/slash-commands.js +1021 -0
  163. package/dist/slash-commands.js.map +1 -0
  164. package/dist/smart-approval.d.ts +137 -0
  165. package/dist/smart-approval.d.ts.map +1 -0
  166. package/dist/smart-approval.js +512 -0
  167. package/dist/smart-approval.js.map +1 -0
  168. package/dist/system-prompt-generator.d.ts +35 -0
  169. package/dist/system-prompt-generator.d.ts.map +1 -0
  170. package/dist/system-prompt-generator.js +729 -0
  171. package/dist/system-prompt-generator.js.map +1 -0
  172. package/dist/test-boundary-conditions.d.ts.map +1 -0
  173. package/dist/test-boundary-conditions.js.map +1 -0
  174. package/dist/test-cancellation-fix.d.ts.map +1 -0
  175. package/dist/test-cancellation-fix.js.map +1 -0
  176. package/dist/test-input-history.d.ts.map +1 -0
  177. package/dist/test-input-history.js.map +1 -0
  178. package/dist/test-interaction-flow.d.ts.map +1 -0
  179. package/dist/test-interaction-flow.js.map +1 -0
  180. package/dist/test-quick.d.ts.map +1 -0
  181. package/dist/test-quick.js.map +1 -0
  182. package/dist/test-user-interaction.d.ts.map +1 -0
  183. package/dist/test-user-interaction.js.map +1 -0
  184. package/dist/theme.d.ts +353 -0
  185. package/dist/theme.d.ts.map +1 -0
  186. package/dist/theme.js +383 -0
  187. package/dist/theme.js.map +1 -0
  188. package/dist/tools.d.ts +373 -0
  189. package/dist/tools.d.ts.map +1 -0
  190. package/dist/tools.js +2906 -0
  191. package/dist/tools.js.map +1 -0
  192. package/dist/types.d.ts +180 -0
  193. package/dist/types.d.ts.map +1 -0
  194. package/dist/types.js +23 -0
  195. package/dist/types.js.map +1 -0
  196. package/dist/unified-session.d.ts +42 -0
  197. package/dist/unified-session.d.ts.map +1 -0
  198. package/dist/unified-session.js +271 -0
  199. package/dist/unified-session.js.map +1 -0
  200. package/dist/update.d.ts +30 -0
  201. package/dist/update.d.ts.map +1 -0
  202. package/dist/update.js +211 -0
  203. package/dist/update.js.map +1 -0
  204. package/dist/workflow.d.ts +53 -0
  205. package/dist/workflow.d.ts.map +1 -0
  206. package/dist/workflow.js +405 -0
  207. package/dist/workflow.js.map +1 -0
  208. package/docs/architecture/mcp-integration-guide.md +131 -0
  209. package/docs/architecture/overview.md +93 -0
  210. package/docs/architecture/tool-system-design.md +89 -0
  211. package/docs/cli/commands.md +189 -0
  212. package/docs/smart-mode.md +257 -0
  213. package/docs/third-party-models.md +449 -0
  214. package/package.json +85 -0
  215. package/scripts/init-skills-path.js +58 -0
  216. package/skills/.claude-plugin/marketplace.json +45 -0
  217. package/skills/README.md +94 -0
  218. package/skills/THIRD_PARTY_NOTICES.md +405 -0
  219. package/skills/skills/algorithmic-art/LICENSE.txt +202 -0
  220. package/skills/skills/algorithmic-art/SKILL.md +405 -0
  221. package/skills/skills/algorithmic-art/templates/generator_template.js +223 -0
  222. package/skills/skills/algorithmic-art/templates/viewer.html +599 -0
  223. package/skills/skills/brand-guidelines/LICENSE.txt +202 -0
  224. package/skills/skills/brand-guidelines/SKILL.md +73 -0
  225. package/skills/skills/canvas-design/LICENSE.txt +202 -0
  226. package/skills/skills/canvas-design/SKILL.md +130 -0
  227. package/skills/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -0
  228. package/skills/skills/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
  229. package/skills/skills/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
  230. package/skills/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -0
  231. package/skills/skills/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
  232. package/skills/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -0
  233. package/skills/skills/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
  234. package/skills/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  235. package/skills/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
  236. package/skills/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  237. package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
  238. package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
  239. package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -0
  240. package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
  241. package/skills/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -0
  242. package/skills/skills/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
  243. package/skills/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -0
  244. package/skills/skills/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
  245. package/skills/skills/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
  246. package/skills/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -0
  247. package/skills/skills/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
  248. package/skills/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -0
  249. package/skills/skills/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
  250. package/skills/skills/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
  251. package/skills/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
  252. package/skills/skills/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
  253. package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
  254. package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
  255. package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
  256. package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
  257. package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  258. package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  259. package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  260. package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
  261. package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  262. package/skills/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  263. package/skills/skills/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  264. package/skills/skills/canvas-design/canvas-fonts/Italiana-OFL.txt +93 -0
  265. package/skills/skills/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
  266. package/skills/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  267. package/skills/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
  268. package/skills/skills/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  269. package/skills/skills/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
  270. package/skills/skills/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
  271. package/skills/skills/canvas-design/canvas-fonts/Jura-OFL.txt +93 -0
  272. package/skills/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
  273. package/skills/skills/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
  274. package/skills/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
  275. package/skills/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  276. package/skills/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
  277. package/skills/skills/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
  278. package/skills/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
  279. package/skills/skills/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
  280. package/skills/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -0
  281. package/skills/skills/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
  282. package/skills/skills/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
  283. package/skills/skills/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  284. package/skills/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
  285. package/skills/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
  286. package/skills/skills/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
  287. package/skills/skills/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
  288. package/skills/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -0
  289. package/skills/skills/canvas-design/canvas-fonts/PoiretOne-OFL.txt +93 -0
  290. package/skills/skills/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
  291. package/skills/skills/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
  292. package/skills/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -0
  293. package/skills/skills/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
  294. package/skills/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -0
  295. package/skills/skills/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
  296. package/skills/skills/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
  297. package/skills/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -0
  298. package/skills/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
  299. package/skills/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
  300. package/skills/skills/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
  301. package/skills/skills/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
  302. package/skills/skills/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
  303. package/skills/skills/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
  304. package/skills/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -0
  305. package/skills/skills/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
  306. package/skills/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
  307. package/skills/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
  308. package/skills/skills/doc-coauthoring/SKILL.md +375 -0
  309. package/skills/skills/docx/LICENSE.txt +30 -0
  310. package/skills/skills/docx/SKILL.md +197 -0
  311. package/skills/skills/docx/docx-js.md +350 -0
  312. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  313. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  314. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  315. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  316. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  317. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  318. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  319. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  320. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  321. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  322. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  323. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  324. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  325. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  326. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  327. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  328. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  329. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  330. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  331. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  332. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  333. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  334. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  335. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  336. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  337. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  338. package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  339. package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  340. package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  341. package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  342. package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  343. package/skills/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
  344. package/skills/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  345. package/skills/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  346. package/skills/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  347. package/skills/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  348. package/skills/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  349. package/skills/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  350. package/skills/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  351. package/skills/skills/docx/ooxml/scripts/pack.py +159 -0
  352. package/skills/skills/docx/ooxml/scripts/unpack.py +29 -0
  353. package/skills/skills/docx/ooxml/scripts/validate.py +69 -0
  354. package/skills/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
  355. package/skills/skills/docx/ooxml/scripts/validation/base.py +951 -0
  356. package/skills/skills/docx/ooxml/scripts/validation/docx.py +274 -0
  357. package/skills/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
  358. package/skills/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
  359. package/skills/skills/docx/ooxml.md +610 -0
  360. package/skills/skills/docx/scripts/__init__.py +1 -0
  361. package/skills/skills/docx/scripts/document.py +1276 -0
  362. package/skills/skills/docx/scripts/templates/comments.xml +3 -0
  363. package/skills/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  364. package/skills/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  365. package/skills/skills/docx/scripts/templates/commentsIds.xml +3 -0
  366. package/skills/skills/docx/scripts/templates/people.xml +3 -0
  367. package/skills/skills/docx/scripts/utilities.py +374 -0
  368. package/skills/skills/frontend-design/LICENSE.txt +177 -0
  369. package/skills/skills/frontend-design/SKILL.md +42 -0
  370. package/skills/skills/internal-comms/LICENSE.txt +202 -0
  371. package/skills/skills/internal-comms/SKILL.md +32 -0
  372. package/skills/skills/internal-comms/examples/3p-updates.md +47 -0
  373. package/skills/skills/internal-comms/examples/company-newsletter.md +65 -0
  374. package/skills/skills/internal-comms/examples/faq-answers.md +30 -0
  375. package/skills/skills/internal-comms/examples/general-comms.md +16 -0
  376. package/skills/skills/mcp-builder/LICENSE.txt +202 -0
  377. package/skills/skills/mcp-builder/SKILL.md +236 -0
  378. package/skills/skills/mcp-builder/reference/evaluation.md +602 -0
  379. package/skills/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
  380. package/skills/skills/mcp-builder/reference/node_mcp_server.md +970 -0
  381. package/skills/skills/mcp-builder/reference/python_mcp_server.md +719 -0
  382. package/skills/skills/mcp-builder/scripts/connections.py +151 -0
  383. package/skills/skills/mcp-builder/scripts/evaluation.py +373 -0
  384. package/skills/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
  385. package/skills/skills/mcp-builder/scripts/requirements.txt +2 -0
  386. package/skills/skills/pdf/LICENSE.txt +30 -0
  387. package/skills/skills/pdf/SKILL.md +294 -0
  388. package/skills/skills/pdf/forms.md +205 -0
  389. package/skills/skills/pdf/reference.md +612 -0
  390. package/skills/skills/pdf/scripts/check_bounding_boxes.py +70 -0
  391. package/skills/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
  392. package/skills/skills/pdf/scripts/check_fillable_fields.py +12 -0
  393. package/skills/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
  394. package/skills/skills/pdf/scripts/create_validation_image.py +41 -0
  395. package/skills/skills/pdf/scripts/extract_form_field_info.py +152 -0
  396. package/skills/skills/pdf/scripts/fill_fillable_fields.py +114 -0
  397. package/skills/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
  398. package/skills/skills/pptx/LICENSE.txt +30 -0
  399. package/skills/skills/pptx/SKILL.md +484 -0
  400. package/skills/skills/pptx/html2pptx.md +625 -0
  401. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  402. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  403. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  404. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  405. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  406. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  407. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  408. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  409. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  410. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  411. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  412. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  413. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  414. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  415. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  416. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  417. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  418. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  419. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  420. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  421. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  422. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  423. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  424. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  425. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  426. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  427. package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  428. package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  429. package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  430. package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  431. package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  432. package/skills/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
  433. package/skills/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  434. package/skills/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  435. package/skills/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  436. package/skills/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  437. package/skills/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  438. package/skills/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  439. package/skills/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  440. package/skills/skills/pptx/ooxml/scripts/pack.py +159 -0
  441. package/skills/skills/pptx/ooxml/scripts/unpack.py +29 -0
  442. package/skills/skills/pptx/ooxml/scripts/validate.py +69 -0
  443. package/skills/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
  444. package/skills/skills/pptx/ooxml/scripts/validation/base.py +951 -0
  445. package/skills/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
  446. package/skills/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
  447. package/skills/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
  448. package/skills/skills/pptx/ooxml.md +427 -0
  449. package/skills/skills/pptx/scripts/html2pptx.js +979 -0
  450. package/skills/skills/pptx/scripts/inventory.py +1020 -0
  451. package/skills/skills/pptx/scripts/rearrange.py +231 -0
  452. package/skills/skills/pptx/scripts/replace.py +385 -0
  453. package/skills/skills/pptx/scripts/thumbnail.py +450 -0
  454. package/skills/skills/skill-creator/LICENSE.txt +202 -0
  455. package/skills/skills/skill-creator/SKILL.md +356 -0
  456. package/skills/skills/skill-creator/references/output-patterns.md +82 -0
  457. package/skills/skills/skill-creator/references/workflows.md +28 -0
  458. package/skills/skills/skill-creator/scripts/init_skill.py +303 -0
  459. package/skills/skills/skill-creator/scripts/package_skill.py +110 -0
  460. package/skills/skills/skill-creator/scripts/quick_validate.py +95 -0
  461. package/skills/skills/slack-gif-creator/LICENSE.txt +202 -0
  462. package/skills/skills/slack-gif-creator/SKILL.md +254 -0
  463. package/skills/skills/slack-gif-creator/core/easing.py +234 -0
  464. package/skills/skills/slack-gif-creator/core/frame_composer.py +176 -0
  465. package/skills/skills/slack-gif-creator/core/gif_builder.py +269 -0
  466. package/skills/skills/slack-gif-creator/core/validators.py +136 -0
  467. package/skills/skills/slack-gif-creator/requirements.txt +4 -0
  468. package/skills/skills/theme-factory/LICENSE.txt +202 -0
  469. package/skills/skills/theme-factory/SKILL.md +59 -0
  470. package/skills/skills/theme-factory/theme-showcase.pdf +0 -0
  471. package/skills/skills/theme-factory/themes/arctic-frost.md +19 -0
  472. package/skills/skills/theme-factory/themes/botanical-garden.md +19 -0
  473. package/skills/skills/theme-factory/themes/desert-rose.md +19 -0
  474. package/skills/skills/theme-factory/themes/forest-canopy.md +19 -0
  475. package/skills/skills/theme-factory/themes/golden-hour.md +19 -0
  476. package/skills/skills/theme-factory/themes/midnight-galaxy.md +19 -0
  477. package/skills/skills/theme-factory/themes/modern-minimalist.md +19 -0
  478. package/skills/skills/theme-factory/themes/ocean-depths.md +19 -0
  479. package/skills/skills/theme-factory/themes/sunset-boulevard.md +19 -0
  480. package/skills/skills/theme-factory/themes/tech-innovation.md +19 -0
  481. package/skills/skills/web-artifacts-builder/LICENSE.txt +202 -0
  482. package/skills/skills/web-artifacts-builder/SKILL.md +74 -0
  483. package/skills/skills/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
  484. package/skills/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -0
  485. package/skills/skills/webapp-testing/LICENSE.txt +202 -0
  486. package/skills/skills/webapp-testing/SKILL.md +96 -0
  487. package/skills/skills/webapp-testing/examples/console_logging.py +35 -0
  488. package/skills/skills/webapp-testing/examples/element_discovery.py +40 -0
  489. package/skills/skills/webapp-testing/examples/static_html_automation.py +33 -0
  490. package/skills/skills/webapp-testing/scripts/with_server.py +106 -0
  491. package/skills/skills/xlsx/LICENSE.txt +30 -0
  492. package/skills/skills/xlsx/SKILL.md +289 -0
  493. package/skills/skills/xlsx/recalc.py +178 -0
  494. package/skills/spec/agent-skills-spec.md +3 -0
  495. package/skills/template/SKILL.md +6 -0
  496. package/src/agents.ts +504 -0
  497. package/src/ai-client.ts +1456 -0
  498. package/src/auth.ts +648 -0
  499. package/src/cancellation.ts +176 -0
  500. package/src/checkpoint.ts +219 -0
  501. package/src/cli.ts +384 -0
  502. package/src/config.ts +248 -0
  503. package/src/context-compressor.ts +290 -0
  504. package/src/conversation.ts +288 -0
  505. package/src/gui-subagent/action-parser/actionParser.ts +312 -0
  506. package/src/gui-subagent/action-parser/constants.ts +12 -0
  507. package/src/gui-subagent/action-parser/index.ts +6 -0
  508. package/src/gui-subagent/action-parser/types.ts +31 -0
  509. package/src/gui-subagent/agent/gui-agent.ts +982 -0
  510. package/src/gui-subagent/agent/index.ts +5 -0
  511. package/src/gui-subagent/index.ts +139 -0
  512. package/src/gui-subagent/operator/base-operator.ts +246 -0
  513. package/src/gui-subagent/operator/computer-operator.ts +520 -0
  514. package/src/gui-subagent/operator/index.ts +7 -0
  515. package/src/gui-subagent/types/actions.ts +263 -0
  516. package/src/gui-subagent/types/index.ts +6 -0
  517. package/src/gui-subagent/types/operator.ts +106 -0
  518. package/src/gui-subagent/utils.ts +51 -0
  519. package/src/index.ts +18 -0
  520. package/src/input-processor.ts +282 -0
  521. package/src/logger.ts +438 -0
  522. package/src/mcp.ts +563 -0
  523. package/src/memory.ts +303 -0
  524. package/src/session-manager.ts +308 -0
  525. package/src/session.ts +1280 -0
  526. package/src/skill-invoker.ts +1888 -0
  527. package/src/skill-loader.ts +476 -0
  528. package/src/slash-commands.ts +1150 -0
  529. package/src/smart-approval.ts +595 -0
  530. package/src/system-prompt-generator.ts +786 -0
  531. package/src/theme.ts +455 -0
  532. package/src/tools.ts +3398 -0
  533. package/src/types.ts +198 -0
  534. package/src/update.ts +270 -0
  535. package/src/workflow.ts +508 -0
  536. package/tsconfig.json +22 -0
  537. package/vitest.config.ts +19 -0
@@ -0,0 +1,1643 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ import { getSkillLoader } from './skill-loader.js';
5
+ import { ExecutionMode } from './types.js';
6
+ import { getConfigManager } from './config.js';
7
+ /**
8
+ * Track skill execution history for tracking failures
9
+ */
10
+ export class SkillExecutionHistory {
11
+ history = new Map();
12
+ /**
13
+ * Get failure count for a task
14
+ */
15
+ getFailureCount(taskKey) {
16
+ return this.history.get(taskKey) || 0;
17
+ }
18
+ /**
19
+ * Increment failure count for a task
20
+ */
21
+ incrementFailure(taskKey) {
22
+ const count = this.getFailureCount(taskKey) + 1;
23
+ this.history.set(taskKey, count);
24
+ return count;
25
+ }
26
+ /**
27
+ * Reset failure count for a task (e.g., after success)
28
+ */
29
+ reset(taskKey) {
30
+ this.history.delete(taskKey);
31
+ }
32
+ /**
33
+ * Check if threshold reached
34
+ */
35
+ shouldUseFallback(taskKey, threshold = 2) {
36
+ return this.getFailureCount(taskKey) >= threshold;
37
+ }
38
+ }
39
+ // Singleton execution history
40
+ const executionHistory = new SkillExecutionHistory();
41
+ export function getExecutionHistory() {
42
+ return executionHistory;
43
+ }
44
+ // ============================================================
45
+ // Workspace Utility Functions
46
+ // ============================================================
47
+ /**
48
+ * Get workspace directory path
49
+ * @param taskId Task ID for creating unique workspace directory
50
+ * @returns Absolute path to workspace directory
51
+ */
52
+ export function getWorkspaceDir(taskId) {
53
+ // Try to get from config first
54
+ try {
55
+ const configManager = getConfigManager();
56
+ const config = configManager.getSettings?.();
57
+ if (config?.workspacePath) {
58
+ return path.join(config.workspacePath, taskId);
59
+ }
60
+ }
61
+ catch {
62
+ // Config not available, use default
63
+ }
64
+ // Default to ~/.xagent/workspace
65
+ return path.join(os.homedir(), '.xagent', 'workspace', taskId);
66
+ }
67
+ /**
68
+ * Get base workspace directory (without task-id)
69
+ */
70
+ export function getBaseWorkspaceDir() {
71
+ try {
72
+ const configManager = getConfigManager();
73
+ const config = configManager.getSettings?.();
74
+ if (config?.workspacePath) {
75
+ return config.workspacePath;
76
+ }
77
+ }
78
+ catch {
79
+ // Config not available, use default
80
+ }
81
+ return path.join(os.homedir(), '.xagent', 'workspace');
82
+ }
83
+ /**
84
+ * Get workspace directory description for AI
85
+ * Returns the actual workspace path from config, or default path
86
+ */
87
+ export function getWorkspaceDescription() {
88
+ try {
89
+ const configManager = getConfigManager();
90
+ const config = configManager.getSettings?.();
91
+ if (config?.workspacePath) {
92
+ return config.workspacePath;
93
+ }
94
+ }
95
+ catch {
96
+ // Config not available, use default
97
+ }
98
+ return path.join(os.homedir(), '.xagent', 'workspace');
99
+ }
100
+ /**
101
+ * Ensure workspace directory exists
102
+ * @param workspaceDir Workspace directory path
103
+ */
104
+ export async function ensureWorkspaceDir(workspaceDir) {
105
+ await fs.mkdir(workspaceDir, { recursive: true });
106
+ }
107
+ /**
108
+ * Clean up workspace directory
109
+ * @param workspaceDir Workspace directory path
110
+ * @param preserveFiles Files to preserve (relative paths)
111
+ */
112
+ export async function cleanupWorkspace(workspaceDir, preserveFiles = []) {
113
+ try {
114
+ const entries = await fs.readdir(workspaceDir, { withFileTypes: true });
115
+ for (const entry of entries) {
116
+ const fullPath = path.join(workspaceDir, entry.name);
117
+ // Skip files to preserve
118
+ if (preserveFiles.includes(entry.name)) {
119
+ continue;
120
+ }
121
+ if (entry.isDirectory()) {
122
+ // Recursively delete subdirectories
123
+ await fs.rm(fullPath, { recursive: true, force: true });
124
+ }
125
+ else {
126
+ // Delete files
127
+ await fs.unlink(fullPath);
128
+ }
129
+ }
130
+ }
131
+ catch (error) {
132
+ if (error.code !== 'ENOENT') {
133
+ console.warn(`Workspace cleanup failed: ${error.message}`);
134
+ }
135
+ }
136
+ }
137
+ /**
138
+ * Determine if workspace should be auto-cleaned based on ExecutionMode
139
+ * @param executionMode Execution mode
140
+ * @returns Whether auto-cleanup should happen
141
+ */
142
+ export function shouldAutoCleanup(executionMode) {
143
+ // YOLO mode: fully automatic, clean up directly
144
+ if (executionMode === ExecutionMode.YOLO) {
145
+ return true;
146
+ }
147
+ // Other modes require user confirmation
148
+ return false;
149
+ }
150
+ /**
151
+ * Generate cleanup prompt message
152
+ * @param workspaceDir Workspace directory path
153
+ */
154
+ export async function getCleanupInfo(workspaceDir) {
155
+ try {
156
+ const entries = await fs.readdir(workspaceDir, { withFileTypes: true });
157
+ const files = [];
158
+ for (const entry of entries) {
159
+ files.push(entry.name);
160
+ }
161
+ // Calculate total size
162
+ let totalSize = 0;
163
+ for (const entry of entries) {
164
+ if (entry.isFile()) {
165
+ const stats = await fs.stat(path.join(workspaceDir, entry.name));
166
+ totalSize += stats.size;
167
+ }
168
+ }
169
+ const formatSize = (bytes) => {
170
+ if (bytes < 1024)
171
+ return `${bytes} B`;
172
+ if (bytes < 1024 * 1024)
173
+ return `${(bytes / 1024).toFixed(2)} KB`;
174
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
175
+ };
176
+ return { files, totalSize: formatSize(totalSize) };
177
+ }
178
+ catch {
179
+ return { files: [], totalSize: '0 B' };
180
+ }
181
+ }
182
+ // ============================================================
183
+ // Shared Content Extraction Utilities
184
+ // ============================================================
185
+ /**
186
+ * Remove Markdown formatting (bold, italic, etc.)
187
+ */
188
+ export function stripMarkdown(text) {
189
+ return text
190
+ .replace(/\*\*(.+?)\*\*/g, '$1') // Remove bold **
191
+ .replace(/\*(.+?)\*/g, '$1') // Remove italic *
192
+ .replace(/`(.+?)`/g, '$1') // Remove inline code `
193
+ .trim();
194
+ }
195
+ /**
196
+ * Extract content related to keywords (for SKILL.md content matching)
197
+ * @param content SKILL.md full content
198
+ * @param keywords Keyword list
199
+ * @param maxLength Maximum return length
200
+ * @returns Extracted relevant content
201
+ */
202
+ export function extractContent(content, keywords, maxLength = 5000) {
203
+ const lines = content.split('\n');
204
+ const relevantLines = [];
205
+ let inRelevantSection = false;
206
+ let sectionDepth = 0;
207
+ let found = false;
208
+ for (let i = 0; i < lines.length; i++) {
209
+ const line = lines[i];
210
+ // Detect headings
211
+ if (line.match(/^#{1,6}\s/)) {
212
+ const strippedLine = stripMarkdown(line);
213
+ const lowerLine = strippedLine.toLowerCase();
214
+ // Check if contains keywords
215
+ const hasKeyword = keywords.some(kw => lowerLine.includes(kw.toLowerCase()));
216
+ if (hasKeyword) {
217
+ inRelevantSection = true;
218
+ found = true;
219
+ sectionDepth = line.match(/^(#+)/)?.[1].length || 1;
220
+ }
221
+ else if (inRelevantSection) {
222
+ // Check if same level or higher heading (end current section)
223
+ const currentDepth = line.match(/^(#+)/)?.[1].length || 1;
224
+ if (currentDepth <= sectionDepth) {
225
+ inRelevantSection = false;
226
+ }
227
+ }
228
+ }
229
+ if (inRelevantSection || found) {
230
+ relevantLines.push(line);
231
+ }
232
+ // Limit content length
233
+ if (relevantLines.join('\n').length > maxLength) {
234
+ relevantLines.push('\n...(content truncated for brevity)...');
235
+ break;
236
+ }
237
+ }
238
+ if (relevantLines.length > 0) {
239
+ return relevantLines.join('\n').trim();
240
+ }
241
+ // If still not found, return first 100 lines
242
+ return lines.slice(0, 100).join('\n').trim() + '\n\n...(See SKILL.md for full instructions)';
243
+ }
244
+ /**
245
+ * Read SKILL.md and extract relevant content based on task
246
+ */
247
+ export async function readSkillContent(skillPath, keywords, maxLength = 5000) {
248
+ const skillMdPath = path.join(skillPath, 'SKILL.md');
249
+ const content = await fs.readFile(skillMdPath, 'utf-8');
250
+ return extractContent(content, keywords, maxLength);
251
+ }
252
+ // ============================================================
253
+ // SKILL Trigger Keywords Mapping
254
+ // ============================================================
255
+ const SKILL_TRIGGERS = {
256
+ docx: {
257
+ skillId: 'docx',
258
+ keywords: [
259
+ 'word document', 'docx', 'microsoft word', 'create word', 'edit word',
260
+ 'create .docx', '.docx file', 'word file', 'document creation',
261
+ 'word editing', 'tracked changes', 'comments'
262
+ ],
263
+ category: 'Document Processing'
264
+ },
265
+ pdf: {
266
+ skillId: 'pdf',
267
+ keywords: [
268
+ 'pdf', 'create pdf', 'edit pdf', 'pdf document', 'pdf file',
269
+ 'extract pdf', 'merge pdf', 'split pdf', 'pdf form', 'manipulate pdf'
270
+ ],
271
+ category: 'Document Processing'
272
+ },
273
+ pptx: {
274
+ skillId: 'pptx',
275
+ keywords: [
276
+ 'powerpoint', 'ppt', 'pptx', 'presentation', 'slide',
277
+ 'create presentation', 'edit powerpoint', 'create slides',
278
+ 'powerpoint file', 'presentation file'
279
+ ],
280
+ category: 'Document Processing'
281
+ },
282
+ xlsx: {
283
+ skillId: 'xlsx',
284
+ keywords: [
285
+ 'excel', 'spreadsheet', 'xlsx', 'create excel', 'edit spreadsheet',
286
+ 'excel file', 'spreadsheet file', 'formulas', 'data analysis'
287
+ ],
288
+ category: 'Spreadsheet & Data'
289
+ },
290
+ frontend_design: {
291
+ skillId: 'frontend-design',
292
+ keywords: [
293
+ 'web page', 'website', 'web app', 'frontend', 'ui', 'user interface',
294
+ 'create website', 'build website', 'web component', 'html css',
295
+ 'landing page', 'dashboard', 'react', 'vue', 'web interface'
296
+ ],
297
+ category: 'Frontend & Web Development'
298
+ },
299
+ web_artifacts_builder: {
300
+ skillId: 'web-artifacts-builder',
301
+ keywords: [
302
+ 'complex react', 'react artifact', 'stateful artifact', 'routing',
303
+ 'web artifact', 'interactive artifact', 'web-based tool'
304
+ ],
305
+ category: 'Frontend & Web Development'
306
+ },
307
+ webapp_testing: {
308
+ skillId: 'webapp-testing',
309
+ keywords: [
310
+ 'test web', 'web testing', 'browser test', 'playwright', 'e2e test',
311
+ 'frontend test', 'capture screenshot', 'verify web'
312
+ ],
313
+ category: 'Frontend & Web Development'
314
+ },
315
+ canvas_design: {
316
+ skillId: 'canvas-design',
317
+ keywords: [
318
+ 'poster', 'artwork', 'visual art', 'canvas', 'design art',
319
+ 'create poster', 'create artwork', 'visual design', 'graphic art'
320
+ ],
321
+ category: 'Visual & Creative Design'
322
+ },
323
+ algorithmic_art: {
324
+ skillId: 'algorithmic-art',
325
+ keywords: [
326
+ 'generative art', 'algorithmic art', 'p5.js', 'particle system',
327
+ 'flow field', 'creative coding', 'code art'
328
+ ],
329
+ category: 'Visual & Creative Design'
330
+ },
331
+ theme_factory: {
332
+ skillId: 'theme-factory',
333
+ keywords: [
334
+ 'theme', 'color scheme', 'font theme', 'styling theme',
335
+ 'consistent theme', 'apply theme', 'theme colors'
336
+ ],
337
+ category: 'Visual & Creative Design'
338
+ },
339
+ brand_guidelines: {
340
+ skillId: 'brand-guidelines',
341
+ keywords: [
342
+ 'brand colors', 'brand guidelines', 'anthropic brand',
343
+ 'official brand', 'brand styling'
344
+ ],
345
+ category: 'Visual & Creative Design'
346
+ },
347
+ slack_gif_creator: {
348
+ skillId: 'slack-gif-creator',
349
+ keywords: [
350
+ 'slack gif', 'animated gif', 'gif for slack', 'slack animation'
351
+ ],
352
+ category: 'Visual & Creative Design'
353
+ },
354
+ mcp_builder: {
355
+ skillId: 'mcp-builder',
356
+ keywords: [
357
+ 'mcp server', 'model context protocol', 'create mcp',
358
+ 'mcp integration', 'external api integration'
359
+ ],
360
+ category: 'Development & Integration'
361
+ },
362
+ skill_creator: {
363
+ skillId: 'skill-creator',
364
+ keywords: [
365
+ 'create skill', 'new skill', 'skill development',
366
+ 'extend capabilities', 'custom skill'
367
+ ],
368
+ category: 'Development & Integration'
369
+ },
370
+ doc_coauthoring: {
371
+ skillId: 'doc-coauthoring',
372
+ keywords: [
373
+ 'documentation', 'technical docs', 'write documentation',
374
+ 'coauthor', 'doc writing', 'technical writing'
375
+ ],
376
+ category: 'Communication & Documentation'
377
+ },
378
+ internal_comms: {
379
+ skillId: 'internal-comms',
380
+ keywords: [
381
+ 'internal communication', 'status report', 'newsletter',
382
+ 'internal update', 'team communication', 'announcement'
383
+ ],
384
+ category: 'Communication & Documentation'
385
+ }
386
+ };
387
+ // ============================================================
388
+ // SkillInvoker Main Class
389
+ // ============================================================
390
+ export class SkillInvoker {
391
+ skillLoader;
392
+ initialized = false;
393
+ skillCache = new Map();
394
+ constructor(skillLoader) {
395
+ this.skillLoader = skillLoader || getSkillLoader();
396
+ }
397
+ async initialize() {
398
+ if (this.initialized)
399
+ return;
400
+ const skills = await this.skillLoader.loadAllSkills();
401
+ for (const skill of skills) {
402
+ this.skillCache.set(skill.id, skill);
403
+ }
404
+ this.initialized = true;
405
+ }
406
+ /**
407
+ * Get list of all available skills
408
+ */
409
+ async listAvailableSkills() {
410
+ await this.initialize();
411
+ return this.skillLoader.listSkills();
412
+ }
413
+ /**
414
+ * Match the most relevant skill based on user input
415
+ */
416
+ async matchSkill(userInput) {
417
+ await this.initialize();
418
+ const lowerInput = userInput.toLowerCase();
419
+ let bestMatch = null;
420
+ // First check predefined trigger keywords
421
+ for (const trigger of Object.values(SKILL_TRIGGERS)) {
422
+ const matchedKeywords = trigger.keywords.filter(kw => lowerInput.includes(kw.toLowerCase()));
423
+ if (matchedKeywords.length > 0) {
424
+ const confidence = matchedKeywords.length / trigger.keywords.length;
425
+ const skill = this.skillCache.get(trigger.skillId);
426
+ if (skill) {
427
+ const result = {
428
+ skill,
429
+ confidence,
430
+ matchedKeywords,
431
+ category: trigger.category
432
+ };
433
+ if (!bestMatch || confidence > bestMatch.confidence) {
434
+ bestMatch = result;
435
+ }
436
+ }
437
+ }
438
+ }
439
+ return bestMatch;
440
+ }
441
+ /**
442
+ * Get skill details
443
+ */
444
+ async getSkillDetails(skillId) {
445
+ await this.initialize();
446
+ return this.skillLoader.getSkill(skillId) || null;
447
+ }
448
+ /**
449
+ * Execute skill
450
+ */
451
+ async executeSkill(params) {
452
+ const skill = this.skillCache.get(params.skillId);
453
+ if (!skill) {
454
+ return {
455
+ success: false,
456
+ error: `Skill not found: ${params.skillId}`
457
+ };
458
+ }
459
+ // Generate task ID (if not provided)
460
+ const taskId = params.taskId || `${params.skillId}-${Date.now()}`;
461
+ try {
462
+ // Execute based on skillId
463
+ const executor = this.getSkillExecutor(skill.id);
464
+ const result = await executor.execute(skill, { ...params, taskId });
465
+ // Add workspaceDir to result
466
+ if (result.success && result.nextSteps && result.nextSteps.length > 0) {
467
+ result.workspaceDir = getWorkspaceDir(taskId);
468
+ await ensureWorkspaceDir(result.workspaceDir);
469
+ }
470
+ return result;
471
+ }
472
+ catch (error) {
473
+ return {
474
+ success: false,
475
+ error: error.message
476
+ };
477
+ }
478
+ }
479
+ /**
480
+ * Clean up workspace based on execution result
481
+ * @param result Skill execution result
482
+ * @param executionMode Execution mode
483
+ * @returns Whether cleanup was performed
484
+ */
485
+ async cleanupAfterExecution(result, executionMode) {
486
+ if (!result.workspaceDir) {
487
+ return false;
488
+ }
489
+ // YOLO mode: auto cleanup
490
+ if (executionMode === ExecutionMode.YOLO) {
491
+ await cleanupWorkspace(result.workspaceDir, result.preserveFiles || []);
492
+ return true;
493
+ }
494
+ // Other modes: don't auto cleanup, let user decide
495
+ return false;
496
+ }
497
+ /**
498
+ * Get cleanup prompt (for asking user)
499
+ */
500
+ async getCleanupPrompt(result) {
501
+ if (!result.workspaceDir) {
502
+ return null;
503
+ }
504
+ const info = await getCleanupInfo(result.workspaceDir);
505
+ if (info.files.length === 0) {
506
+ return null;
507
+ }
508
+ return `Task completed! Workspace directory contains the following files:\n` +
509
+ `📁 ${result.workspaceDir}\n` +
510
+ `Files: ${info.files.join(', ')}\n` +
511
+ `Size: ${info.totalSize}\n\n` +
512
+ `Do you want to clean up these temporary files?`;
513
+ }
514
+ /**
515
+ * Get executor for skill
516
+ * Determine which executor to use based on skill.id
517
+ */
518
+ getSkillExecutor(skillId) {
519
+ const docProcessingSkills = ['docx', 'pdf', 'pptx', 'xlsx'];
520
+ const frontendSkills = ['frontend-design', 'web-artifacts-builder', 'webapp-testing'];
521
+ const visualDesignSkills = ['canvas-design', 'algorithmic-art', 'theme-factory', 'brand-guidelines', 'slack-gif-creator'];
522
+ const docSkills = ['doc-coauthoring', 'internal-comms'];
523
+ if (docProcessingSkills.includes(skillId)) {
524
+ return new DocumentSkillExecutor();
525
+ }
526
+ if (frontendSkills.includes(skillId)) {
527
+ return new FrontendSkillExecutor();
528
+ }
529
+ if (visualDesignSkills.includes(skillId)) {
530
+ return new VisualDesignSkillExecutor();
531
+ }
532
+ if (docSkills.includes(skillId)) {
533
+ return new DocumentationSkillExecutor();
534
+ }
535
+ return new DefaultSkillExecutor();
536
+ }
537
+ /**
538
+ * Generate skill invocation instructions (for system prompt)
539
+ */
540
+ generateSkillInstructions() {
541
+ const categories = new Map();
542
+ for (const trigger of Object.values(SKILL_TRIGGERS)) {
543
+ const skill = this.skillCache.get(trigger.skillId);
544
+ if (skill) {
545
+ const existing = categories.get(trigger.category) || [];
546
+ existing.push({
547
+ skillId: trigger.skillId,
548
+ name: skill.name,
549
+ description: skill.description
550
+ });
551
+ categories.set(trigger.category, existing);
552
+ }
553
+ }
554
+ let instructions = '\n## Available Skills\n\n';
555
+ instructions += 'When users request tasks matching these domains, invoke the "InvokeSkill" tool:\n\n';
556
+ for (const [category, skills] of categories) {
557
+ instructions += `### ${category}\n`;
558
+ for (const skill of skills) {
559
+ instructions += `**${skill.name}** (${skill.skillId}): ${skill.description}\n`;
560
+ instructions += ` �?Use: InvokeSkill(skillId="${skill.skillId}", taskDescription="...")\n`;
561
+ }
562
+ instructions += '\n';
563
+ }
564
+ return instructions;
565
+ }
566
+ }
567
+ /**
568
+ * Document Processing Skill Executor
569
+ */
570
+ class DocumentSkillExecutor {
571
+ async execute(skill, params) {
572
+ const outputMessages = [];
573
+ const files = [];
574
+ const nextSteps = [];
575
+ outputMessages.push(`## 🧠 ${skill.name} Skill - Autonomous Mode\n`);
576
+ outputMessages.push(`**Task**: ${params.taskDescription}\n`);
577
+ try {
578
+ // Generate task ID
579
+ const taskId = params.taskId || `${skill.id}-${Date.now()}`;
580
+ // Read complete skill documentation
581
+ const skillPath = skill.skillsPath;
582
+ const skillMdPath = path.join(skillPath, 'SKILL.md');
583
+ files.push(skillMdPath);
584
+ // Read SKILL.md content
585
+ const skillContent = await fs.readFile(skillMdPath, 'utf-8');
586
+ // Extract relevant content based on task type and generate execution steps
587
+ const taskContent = await this.extractRelevantContent(skill, params, skillContent, nextSteps, taskId);
588
+ outputMessages.push(taskContent);
589
+ // Add input/output files to list if they exist
590
+ if (params.inputFile)
591
+ files.push(params.inputFile);
592
+ if (params.outputFile)
593
+ files.push(params.outputFile);
594
+ return {
595
+ success: true,
596
+ output: outputMessages.join('\n'),
597
+ files: files,
598
+ nextSteps: nextSteps,
599
+ requiresManualExecution: true
600
+ };
601
+ }
602
+ catch (error) {
603
+ return {
604
+ success: false,
605
+ error: error.message
606
+ };
607
+ }
608
+ }
609
+ /**
610
+ * Extract relevant skill content based on task type
611
+ */
612
+ async extractRelevantContent(skill, params, fullContent, nextSteps, taskId) {
613
+ const taskLower = params.taskDescription.toLowerCase();
614
+ const workspaceBase = getWorkspaceDescription();
615
+ const taskWorkspace = `${workspaceBase}/${taskId}`;
616
+ // Determine required files based on skill type
617
+ let requiredFiles = [];
618
+ switch (skill.id) {
619
+ case 'pptx':
620
+ requiredFiles = ['skills/pptx/SKILL.md', 'skills/pptx/html2pptx.md', 'skills/pptx/scripts/html2pptx.js'];
621
+ break;
622
+ case 'docx':
623
+ requiredFiles = ['skills/docx/SKILL.md', 'skills/docx/docx-js.md', 'skills/docx/ooxml.md'];
624
+ break;
625
+ case 'pdf':
626
+ requiredFiles = ['skills/pdf/SKILL.md', 'skills/pdf/reference.md', 'skills/pdf/forms.md'];
627
+ break;
628
+ case 'xlsx':
629
+ requiredFiles = ['skills/xlsx/SKILL.md', 'skills/xlsx/recalc.py'];
630
+ break;
631
+ case 'frontend-design':
632
+ requiredFiles = ['skills/frontend-design/SKILL.md'];
633
+ break;
634
+ case 'web-artifacts-builder':
635
+ requiredFiles = ['skills/web-artifacts-builder/SKILL.md'];
636
+ break;
637
+ case 'webapp-testing':
638
+ requiredFiles = ['skills/webapp-testing/SKILL.md', 'skills/webapp-testing/examples/'];
639
+ break;
640
+ case 'canvas-design':
641
+ requiredFiles = ['skills/canvas-design/SKILL.md'];
642
+ break;
643
+ case 'algorithmic-art':
644
+ requiredFiles = ['skills/algorithmic-art/SKILL.md', 'skills/algorithmic-art/templates/generator_template.js'];
645
+ break;
646
+ case 'theme-factory':
647
+ requiredFiles = ['skills/theme-factory/SKILL.md', 'skills/theme-factory/themes/'];
648
+ break;
649
+ case 'brand-guidelines':
650
+ requiredFiles = ['skills/brand-guidelines/SKILL.md'];
651
+ break;
652
+ case 'internal-comms':
653
+ requiredFiles = ['skills/internal-comms/SKILL.md', 'skills/internal-comms/examples/'];
654
+ break;
655
+ case 'doc-coauthoring':
656
+ requiredFiles = ['skills/doc-coauthoring/SKILL.md'];
657
+ break;
658
+ case 'mcp-builder':
659
+ requiredFiles = ['skills/mcp-builder/SKILL.md', 'skills/mcp-builder/reference/'];
660
+ break;
661
+ case 'skill-creator':
662
+ requiredFiles = ['skills/skill-creator/SKILL.md'];
663
+ break;
664
+ case 'slack-gif-creator':
665
+ requiredFiles = ['skills/slack-gif-creator/SKILL.md', 'skills/slack-gif-creator/core/'];
666
+ break;
667
+ default:
668
+ requiredFiles = [`skills/${skill.id}/SKILL.md`];
669
+ }
670
+ nextSteps.push({
671
+ step: 1,
672
+ action: 'Read skill documentation',
673
+ description: `Read: ${requiredFiles.join(', ')}`,
674
+ reason: 'Understand the skill workflow and best practices'
675
+ });
676
+ nextSteps.push({
677
+ step: 2,
678
+ action: 'Analyze documentation and design approach',
679
+ description: `Based on SKILL.md, determine the best approach for: ${taskWorkspace}`,
680
+ reason: 'Plan your execution based on the documentation'
681
+ });
682
+ nextSteps.push({
683
+ step: 3,
684
+ action: 'Execute your plan',
685
+ description: 'Create workspace, write code, run scripts, verify output',
686
+ reason: 'Execute the task using your own understanding'
687
+ });
688
+ return `### Skill Execution\n\n` +
689
+ `**Your task**: ${params.taskDescription}\n\n` +
690
+ `**Read these files first**:\n` +
691
+ requiredFiles.map(f => `- ${f}`).join('\n') + '\n\n' +
692
+ `Then analyze the documentation and create your own execution plan.\n\n` +
693
+ `**Workspace**: \`${taskWorkspace}\`\n\n` +
694
+ `**⚠️ Windows Path Execution**: Use absolute paths, NOT \`cd && command\`:\n` +
695
+ ` - ✅ Correct: \`node "${taskWorkspace}/script.js"\`\n` +
696
+ ` - ❌ Wrong: \`cd "${taskWorkspace}" && node script.js\` (fails in PowerShell 5.1)\n` +
697
+ ` - ✅ Correct: \`python "${taskWorkspace}/script.py"\`\n\n` +
698
+ `**📦 Dependency Reuse**: Check existing libraries before downloading:\n` +
699
+ ` - Node.js: pptxgenjs, playwright, sharp, docx are globally available\n` +
700
+ ` - Python: pypdf, openpyxl, python-pptx, fitz are available\n` +
701
+ ` - Use \`require("pptxgenjs")\` NOT \`npm install pptxgenjs\`\n` +
702
+ ` - Use \`from openpyxl import Workbook\` NOT \`pip install openpyxl\`\n\n` +
703
+ `**🧹 Cleanup**: Delete all intermediate/temporary files when task completes:\n` +
704
+ ` - Remove: all files generated during the task\n` +
705
+ ` - Keep: Only the final output file (output.pptx/docx/xlsx/pdf)\n\n` +
706
+ `**Instructions**: read_file the documentation, understand the API, and create your own execution plan.\n` +
707
+ `**If you encounter issues**: Explain what went wrong and suggest a different approach.\n`;
708
+ }
709
+ /**
710
+ * Extract PPTX-related content and generate steps
711
+ */
712
+ extractPptxContent(taskLower, fullContent, nextSteps, skillPath, taskWorkspace) {
713
+ const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
714
+ const html2pptxPath = `${skillPath}/scripts/html2pptx.js`;
715
+ const scriptsPath = `${skillPath}/scripts`;
716
+ // Check if using template
717
+ const useTemplate = taskLower.includes('template') || taskLower.includes('template');
718
+ if (useTemplate) {
719
+ // Add template usage steps
720
+ nextSteps.push({
721
+ step: 1,
722
+ action: 'Read documentation and script',
723
+ description: `Read pptx/html2pptx.md and ${html2pptxPath} - CRITICAL: Read the USAGE section at the top of html2pptx.js to understand the correct API: const { slide, placeholders } = await html2pptx('slide.html', pptx);`,
724
+ file: html2pptxPath,
725
+ reason: 'Understand html2pptx API - MUST read the usage example in the file header'
726
+ });
727
+ nextSteps.push({
728
+ step: 2,
729
+ action: 'Create workspace directory',
730
+ description: `Create directory: ${taskWorkspace}`,
731
+ reason: 'Create workspace directory for this task'
732
+ });
733
+ nextSteps.push({
734
+ step: 3,
735
+ action: 'Create HTML slide file in workspace',
736
+ description: `Create slide.html inside ${taskWorkspace}/ (720pt × 405pt for 16:9)`,
737
+ reason: 'Create slide HTML file in workspace to avoid polluting target directory'
738
+ });
739
+ nextSteps.push({
740
+ step: 4,
741
+ action: 'Create PPTX conversion script in workspace',
742
+ description: `Create convert.js inside ${taskWorkspace}/ using CommonJS: const { slide, placeholders } = await html2pptx('slide.html', pptx); // slide is already added, use slide.addChart()/addText() for content`,
743
+ reason: 'Write Node.js script - MUST use destructured { slide, placeholders } from html2pptx()'
744
+ });
745
+ nextSteps.push({
746
+ step: 5,
747
+ action: 'Run the script',
748
+ description: `node "${taskWorkspace.replace(/\\/g, '/')}/convert.js"`,
749
+ reason: 'Generate PPTX file using html2pptx (use absolute path for Windows compatibility)'
750
+ });
751
+ nextSteps.push({
752
+ step: 6,
753
+ action: 'Generate thumbnail grid for visual validation',
754
+ description: `Run: python "${scriptsPath}/thumbnail.py" ${taskWorkspace}/output.pptx ${taskWorkspace}/thumbnails --cols 4`,
755
+ reason: 'Create thumbnail grid to verify slide layout and visual quality'
756
+ });
757
+ nextSteps.push({
758
+ step: 7,
759
+ action: 'Copy output to target directory',
760
+ description: `Copy ${taskWorkspace}/output.pptx to target directory`,
761
+ reason: 'Only save final file to specified path, keep workspace clean'
762
+ });
763
+ const patterns = [
764
+ /##\s*Creating\s*a\s*new\s*PowerPoint\s*presentation\s*\*\*using\s*a\s*template\*\*[\s\S]*?(?=##\s+)/i,
765
+ /##\s*Using\s*a\s*template[\s\S]*?(?=##\s+)/i
766
+ ];
767
+ for (const pattern of patterns) {
768
+ const match = content.match(pattern);
769
+ if (match) {
770
+ return `### Using a Template\n\n${match[0].trim()}`;
771
+ }
772
+ }
773
+ }
774
+ // Not using template
775
+ nextSteps.push({
776
+ step: 1,
777
+ action: 'Read documentation and script',
778
+ description: `Read pptx/html2pptx.md and ${html2pptxPath} - CRITICAL: Read the USAGE section at the top of html2pptx.js to understand the correct API: const { slide, placeholders } = await html2pptx('slide.html', pptx);`,
779
+ file: html2pptxPath,
780
+ reason: 'Understand html2pptx API - MUST read the usage example in the file header'
781
+ });
782
+ nextSteps.push({
783
+ step: 2,
784
+ action: 'Create workspace directory',
785
+ description: `Create directory: ${taskWorkspace}`,
786
+ reason: 'Create workspace directory for this task'
787
+ });
788
+ nextSteps.push({
789
+ step: 3,
790
+ action: 'Create HTML slide file in workspace',
791
+ description: `Create slide.html inside ${taskWorkspace}/ (720pt × 405pt for 16:9)`,
792
+ reason: 'Create slide HTML file in workspace to avoid polluting target directory'
793
+ });
794
+ nextSteps.push({
795
+ step: 4,
796
+ action: 'Create PPTX conversion script in workspace',
797
+ description: `Create convert.js inside ${taskWorkspace}/ using CommonJS: const { slide, placeholders } = await html2pptx('slide.html', pptx); // slide is already added, use slide.addChart()/addText() for content`,
798
+ reason: 'Write Node.js script - MUST use destructured { slide, placeholders } from html2pptx()'
799
+ });
800
+ nextSteps.push({
801
+ step: 5,
802
+ action: 'Run the script',
803
+ description: `node "${taskWorkspace.replace(/\\/g, '/')}/convert.js"`,
804
+ reason: 'Generate PPTX file using html2pptx (use absolute path for Windows compatibility)'
805
+ });
806
+ nextSteps.push({
807
+ step: 6,
808
+ action: 'Generate thumbnail grid for visual validation',
809
+ description: `Run: python "${scriptsPath}/thumbnail.py" ${taskWorkspace}/output.pptx ${taskWorkspace}/thumbnails --cols 4`,
810
+ reason: 'Create thumbnail grid to verify slide layout and visual quality'
811
+ });
812
+ nextSteps.push({
813
+ step: 7,
814
+ action: 'Copy output to target directory',
815
+ description: `Copy ${taskWorkspace}/output.pptx to target directory`,
816
+ reason: 'Only save final file to specified path, keep workspace clean'
817
+ });
818
+ const patterns = [
819
+ /##\s*Creating\s*a\s*new\s*PowerPoint[\s\S]*?(?=##\s+)/i,
820
+ /###\s*Workflow[\s\S]*?(?=###\s+|$)/i
821
+ ];
822
+ for (const pattern of patterns) {
823
+ const match = content.match(pattern);
824
+ if (match) {
825
+ return `### Creating New Presentation\n\n${match[0].trim()}`;
826
+ }
827
+ }
828
+ return extractContent(content, ['html2pptx', 'Creating', 'Workflow']);
829
+ }
830
+ /**
831
+ * Extract DOCX-related content and generate steps
832
+ */
833
+ extractDocxContent(taskLower, fullContent, nextSteps, params, skillPath, taskWorkspace) {
834
+ const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
835
+ const unpackScript = `${skillPath}/ooxml/scripts/unpack.py`;
836
+ const packScript = `${skillPath}/ooxml/scripts/pack.py`;
837
+ const scriptsPath = `${skillPath}/scripts`;
838
+ const isNew = taskLower.includes('create') || taskLower.includes('new');
839
+ const isEditing = taskLower.includes('edit') || taskLower.includes('modify') || taskLower.includes('modify');
840
+ if (isNew) {
841
+ // Create new document
842
+ nextSteps.push({
843
+ step: 1,
844
+ action: 'Read documentation',
845
+ description: 'Read docx-js.md for API reference',
846
+ file: `${skillPath}/docx-js.md`,
847
+ reason: 'Understand how to use docx-js library to create Word documents'
848
+ });
849
+ nextSteps.push({
850
+ step: 2,
851
+ action: 'Create script in workspace',
852
+ description: `Create create_doc.js in ${taskWorkspace}: const { Document, Paragraph, TextRun, Packer } = await import("docx");`,
853
+ reason: 'Create Word document code using docx library with dynamic import'
854
+ });
855
+ nextSteps.push({
856
+ step: 3,
857
+ action: 'Run the script',
858
+ description: `node "${taskWorkspace.replace(/\\/g, '/')}/create_doc.js"`,
859
+ reason: 'Generate DOCX file in workspace (use absolute path for Windows compatibility)'
860
+ });
861
+ nextSteps.push({ step: 4,
862
+ action: 'Copy output to target directory',
863
+ description: `Copy ${taskWorkspace}/output.docx to target directory`,
864
+ reason: 'Only save final file to specified path, keep workspace clean'
865
+ });
866
+ return extractContent(content, ['Creating', 'docx-js', 'Workflow']);
867
+ }
868
+ if (isEditing) {
869
+ // Edit existing document - use existing scripts
870
+ nextSteps.push({
871
+ step: 1,
872
+ action: 'Read documentation',
873
+ description: 'Read ooxml.md for editing API',
874
+ file: `${skillPath}/ooxml.md`,
875
+ reason: 'Understand how to edit existing Word documents'
876
+ });
877
+ nextSteps.push({
878
+ step: 2,
879
+ action: 'Create workspace directory',
880
+ description: `Create workspace directory: ${taskWorkspace}/`,
881
+ reason: 'Create workspace directory for intermediate files'
882
+ });
883
+ if (params.inputFile) {
884
+ nextSteps.push({
885
+ step: 3,
886
+ action: 'Unpack document in workspace',
887
+ description: `Run: python "${unpackScript}" "${params.inputFile}" ${taskWorkspace}/docx_input`,
888
+ reason: 'Unpack DOCX file using existing unpack.py script'
889
+ });
890
+ }
891
+ nextSteps.push({
892
+ step: 4,
893
+ action: 'Create editing script in workspace',
894
+ description: `Create edit_doc.py in ${taskWorkspace}: from scripts.document import Document; doc = Document("${taskWorkspace}/docx_input");`,
895
+ reason: 'Create Python editing script using existing Document library'
896
+ });
897
+ if (params.inputFile || params.outputFile) {
898
+ nextSteps.push({
899
+ step: 5,
900
+ action: 'Pack document',
901
+ description: `Run: python "${packScript}" ${taskWorkspace}/docx_input ${taskWorkspace}/output.docx`,
902
+ reason: 'Repack DOCX using existing pack.py script'
903
+ });
904
+ }
905
+ nextSteps.push({
906
+ step: 6,
907
+ action: 'Copy output to target directory',
908
+ description: `Copy ${taskWorkspace}/output.docx to target directory`,
909
+ reason: 'Only save final file to specified path'
910
+ });
911
+ return extractContent(content, ['Editing', 'redlining', 'ooxml']);
912
+ }
913
+ // Default case
914
+ nextSteps.push({
915
+ step: 1,
916
+ action: 'Read documentation',
917
+ description: 'Read ooxml.md or docx-js.md',
918
+ reason: 'Understand document processing methods'
919
+ });
920
+ nextSteps.push({
921
+ step: 2,
922
+ action: 'Create or edit document',
923
+ description: 'Write code using appropriate library',
924
+ reason: 'Perform document operations'
925
+ });
926
+ return extractContent(content, ['Creating', 'Editing', 'document', 'docx']);
927
+ }
928
+ /**
929
+ * Extract PDF-related content and generate steps
930
+ */
931
+ extractPdfContent(taskLower, fullContent, nextSteps, params, skillPath, taskWorkspace) {
932
+ const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
933
+ const scriptsPath = `${skillPath}/scripts`;
934
+ const isForm = taskLower.includes('form') || taskLower.includes('form');
935
+ const isExtract = taskLower.includes('extract') || taskLower.includes('extract');
936
+ const isMerge = taskLower.includes('merge') || taskLower.includes('merge');
937
+ const isConvert = taskLower.includes('convert') || taskLower.includes('image');
938
+ nextSteps.push({
939
+ step: 1,
940
+ action: 'Read documentation',
941
+ description: 'Read reference.md for PDF operations',
942
+ file: `${skillPath}/reference.md`,
943
+ reason: 'Understand PDF operation methods'
944
+ });
945
+ nextSteps.push({
946
+ step: 2,
947
+ action: 'Create workspace directory',
948
+ description: `Create workspace directory: ${taskWorkspace}/`,
949
+ reason: 'Create workspace directory for intermediate files'
950
+ });
951
+ if (isForm) {
952
+ // Check for fillable fields first
953
+ nextSteps.push({
954
+ step: 3,
955
+ action: 'Check form fields',
956
+ description: `Run: python "${scriptsPath}/check_fillable_fields.py" <input_pdf>`,
957
+ reason: 'Check if PDF has fillable form fields'
958
+ });
959
+ nextSteps.push({
960
+ step: 4,
961
+ action: 'Create PDF form script in workspace',
962
+ description: `Create form_script.py in ${taskWorkspace}: use "${scriptsPath}/fill_fillable_fields.py" or "${scriptsPath}/fill_pdf_form_with_annotations.py"`,
963
+ reason: 'Create PDF form processing script using existing scripts'
964
+ });
965
+ }
966
+ else if (isExtract) {
967
+ nextSteps.push({
968
+ step: 3,
969
+ action: 'Create extraction script in workspace',
970
+ description: `Create extract_script.py in ${taskWorkspace}: use pypdf or pdfplumber for text extraction`,
971
+ reason: 'Create PDF content extraction script'
972
+ });
973
+ }
974
+ else if (isMerge) {
975
+ nextSteps.push({
976
+ step: 3,
977
+ action: 'Create merge script in workspace',
978
+ description: `Create merge_script.py in ${taskWorkspace}: use pypdf to combine PDF files`,
979
+ reason: 'Create PDF merge script'
980
+ });
981
+ }
982
+ else if (isConvert) {
983
+ nextSteps.push({
984
+ step: 3,
985
+ action: 'Convert PDF to images',
986
+ description: `Run: python "${scriptsPath}/convert_pdf_to_images.py" <input_pdf> ${taskWorkspace}/images`,
987
+ reason: 'Convert PDF to images using existing script'
988
+ });
989
+ }
990
+ else {
991
+ nextSteps.push({
992
+ step: 3,
993
+ action: 'Create PDF processing script in workspace',
994
+ description: `Create pdf_script.py in ${taskWorkspace}: use pypdf for desired operations`,
995
+ reason: 'Create PDF processing script'
996
+ });
997
+ }
998
+ nextSteps.push({
999
+ step: 5,
1000
+ action: 'Run the script',
1001
+ description: `python "${taskWorkspace.replace(/\\/g, '/')}/pdf_script.py"`,
1002
+ reason: 'Execute PDF operation script in workspace (use absolute path for Windows compatibility)'
1003
+ });
1004
+ nextSteps.push({
1005
+ step: 6,
1006
+ action: 'Copy output to target directory',
1007
+ description: `Copy ${taskWorkspace}/output.pdf to target directory`,
1008
+ reason: 'Only save final file to specified path'
1009
+ });
1010
+ return extractContent(content, ['Creating', 'pdf', 'PDF']);
1011
+ }
1012
+ /**
1013
+ * Extract XLSX relevant content and generate steps
1014
+ */
1015
+ extractXlsxContent(taskLower, fullContent, nextSteps, skillPath, taskWorkspace) {
1016
+ const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
1017
+ const hasFormulas = taskLower.includes('formula') || taskLower.includes('公式');
1018
+ const hasData = taskLower.includes('data') || taskLower.includes('数据分析');
1019
+ nextSteps.push({
1020
+ step: 1,
1021
+ action: 'Read documentation',
1022
+ description: 'Read SKILL.md for Excel operations',
1023
+ file: `${skillPath}/SKILL.md`,
1024
+ reason: 'Understand Excel operation methods'
1025
+ });
1026
+ nextSteps.push({
1027
+ step: 2,
1028
+ action: 'Create workspace directory',
1029
+ description: `Create workspace directory: ${taskWorkspace}/`,
1030
+ reason: 'Create workspace directory for intermediate files'
1031
+ });
1032
+ if (hasFormulas || hasData) {
1033
+ nextSteps.push({
1034
+ step: 3,
1035
+ action: 'Create spreadsheet script in workspace',
1036
+ description: `Create create_xlsx.py in ${taskWorkspace}: use openpyxl to create workbook with formulas`,
1037
+ reason: 'Create spreadsheet script with formulas in workspace'
1038
+ });
1039
+ }
1040
+ else {
1041
+ nextSteps.push({
1042
+ step: 3,
1043
+ action: 'Create spreadsheet script in workspace',
1044
+ description: `Create create_xlsx.py in ${taskWorkspace}: use openpyxl to create workbook`,
1045
+ reason: 'Create spreadsheet script in workspace'
1046
+ });
1047
+ }
1048
+ nextSteps.push({
1049
+ step: 4,
1050
+ action: 'Run the script',
1051
+ description: `python "${taskWorkspace.replace(/\\/g, '/')}/create_xlsx.py"`,
1052
+ reason: 'Generate XLSX file in workspace (use absolute path for Windows compatibility)'
1053
+ });
1054
+ if (hasFormulas) {
1055
+ nextSteps.push({
1056
+ step: 5,
1057
+ action: 'Recalculate formulas',
1058
+ description: `Run: python "${skillPath}/recalc.py" ${taskWorkspace}/output.xlsx to recalculate all formulas and check for errors`,
1059
+ reason: 'Recalculate formulas and verify no formula errors (#REF!, #DIV/0!, etc.)'
1060
+ });
1061
+ nextSteps.push({
1062
+ step: 6,
1063
+ action: 'Fix formula errors if any',
1064
+ description: `Check recalc.py output JSON for error locations and fix formula errors in ${taskWorkspace}`,
1065
+ reason: 'Ensure ZERO formula errors before final output'
1066
+ });
1067
+ nextSteps.push({
1068
+ step: 7,
1069
+ action: 'Copy output to target directory',
1070
+ description: `Copy ${taskWorkspace}/output.xlsx to target directory`,
1071
+ reason: 'Only save final file to specified path'
1072
+ });
1073
+ }
1074
+ else {
1075
+ nextSteps.push({
1076
+ step: 5,
1077
+ action: 'Copy output to target directory',
1078
+ description: `Copy ${taskWorkspace}/output.xlsx to target directory`,
1079
+ reason: 'Only save final file to specified path'
1080
+ });
1081
+ }
1082
+ return extractContent(content, ['Excel', 'xlsx', 'spreadsheet']);
1083
+ }
1084
+ /**
1085
+ * Extract default content
1086
+ */
1087
+ extractDefaultContent(skill, fullContent, nextSteps) {
1088
+ const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
1089
+ const firstLines = content.split('\n').slice(0, 100).join('\n');
1090
+ nextSteps.push({
1091
+ step: 1,
1092
+ action: 'Read SKILL.md',
1093
+ description: `Read ${skill.id}/SKILL.md for full instructions`,
1094
+ file: `${skill.skillsPath}/SKILL.md`,
1095
+ reason: 'Understand complete execution workflow'
1096
+ });
1097
+ return `### ${skill.name}\n\n${firstLines}\n\n(See ${skill.skillsPath}/SKILL.md for full instructions)`;
1098
+ }
1099
+ }
1100
+ /**
1101
+ * Frontend Development Skill Executor
1102
+ */
1103
+ class FrontendSkillExecutor {
1104
+ async execute(skill, params) {
1105
+ const outputMessages = [];
1106
+ const files = [];
1107
+ const nextSteps = [];
1108
+ outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
1109
+ outputMessages.push(`**Task**: ${params.taskDescription}\n`);
1110
+ // Get or generate task ID
1111
+ const taskId = params.taskId || `${skill.id}-${Date.now()}`;
1112
+ try {
1113
+ // Read SKILL.md content
1114
+ const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
1115
+ files.push(skillMdPath);
1116
+ const skillContent = await fs.readFile(skillMdPath, 'utf-8');
1117
+ // Generate execution steps
1118
+ const taskContent = await this.extractFrontendContent(skill, params, skillContent, nextSteps, taskId);
1119
+ outputMessages.push(taskContent);
1120
+ // Add input/output files to list if they exist
1121
+ if (params.inputFile)
1122
+ files.push(params.inputFile);
1123
+ if (params.outputFile)
1124
+ files.push(params.outputFile);
1125
+ return {
1126
+ success: true,
1127
+ output: outputMessages.join('\n'),
1128
+ files: files,
1129
+ nextSteps: nextSteps,
1130
+ requiresManualExecution: true
1131
+ };
1132
+ }
1133
+ catch (error) {
1134
+ return {
1135
+ success: false,
1136
+ error: error.message
1137
+ };
1138
+ }
1139
+ }
1140
+ /**
1141
+ * Extract relevant content based on frontend skill type and generate steps
1142
+ */
1143
+ async extractFrontendContent(skill, params, fullContent, nextSteps, taskId) {
1144
+ const taskLower = params.taskDescription.toLowerCase();
1145
+ const workspaceBase = getWorkspaceDescription();
1146
+ const taskWorkspace = `${workspaceBase}/${taskId}`;
1147
+ // Add common steps
1148
+ nextSteps.push({
1149
+ step: 1,
1150
+ action: 'Design Thinking',
1151
+ description: 'Understand requirements, define aesthetic direction',
1152
+ reason: 'Clarify design direction and goals'
1153
+ });
1154
+ nextSteps.push({
1155
+ step: 2,
1156
+ action: 'Create implementation',
1157
+ description: 'Write production-grade HTML/CSS/JS or React code',
1158
+ reason: 'Implement frontend interface'
1159
+ });
1160
+ switch (skill.id) {
1161
+ case 'frontend-design':
1162
+ nextSteps.push({
1163
+ step: 3,
1164
+ action: 'Create workspace directory',
1165
+ description: `Create workspace directory: ${taskWorkspace}/`,
1166
+ reason: 'Create workspace directory for frontend files'
1167
+ });
1168
+ nextSteps.push({
1169
+ step: 4,
1170
+ action: 'Create frontend files in workspace',
1171
+ description: `Create index.html, styles.css, app.js in ${taskWorkspace}`,
1172
+ reason: 'Create frontend files in workspace'
1173
+ });
1174
+ if (taskLower.includes('landing')) {
1175
+ nextSteps.push({
1176
+ step: 5,
1177
+ action: 'Focus areas',
1178
+ description: 'Hero section, features, pricing, testimonials, footer',
1179
+ reason: 'Implement landing page sections'
1180
+ });
1181
+ }
1182
+ else if (taskLower.includes('dashboard')) {
1183
+ nextSteps.push({
1184
+ step: 5,
1185
+ action: 'Focus areas',
1186
+ description: 'Charts, data visualization, navigation panels',
1187
+ reason: 'Implement dashboard functionality'
1188
+ });
1189
+ }
1190
+ nextSteps.push({
1191
+ step: 6,
1192
+ action: 'Verify in browser',
1193
+ description: `Open files in ${taskWorkspace} to verify`,
1194
+ reason: 'Verify in browser'
1195
+ });
1196
+ nextSteps.push({
1197
+ step: 7,
1198
+ action: 'Copy files to target directory',
1199
+ description: `Copy frontend files from ${taskWorkspace} to target directory`,
1200
+ reason: 'Only save final files to specified path'
1201
+ });
1202
+ return extractContent(fullContent, ['frontend', 'design', 'web', 'interface']);
1203
+ case 'web-artifacts-builder':
1204
+ nextSteps.push({
1205
+ step: 3,
1206
+ action: 'Create workspace directory',
1207
+ description: `Create workspace directory: ${taskWorkspace}/`,
1208
+ reason: 'Create workspace directory for component files'
1209
+ });
1210
+ nextSteps.push({
1211
+ step: 4,
1212
+ action: 'Build React artifact in workspace',
1213
+ description: `Create React component files in ${taskWorkspace} using shadcn/ui`,
1214
+ reason: 'Build React component in workspace'
1215
+ });
1216
+ nextSteps.push({
1217
+ step: 5,
1218
+ action: 'Test artifact',
1219
+ description: `Test the artifact in ${taskWorkspace}`,
1220
+ reason: 'Test component functionality'
1221
+ });
1222
+ nextSteps.push({
1223
+ step: 6,
1224
+ action: 'Copy artifact to target directory',
1225
+ description: `Copy component files from ${taskWorkspace} to target directory`,
1226
+ reason: 'Only save final files to specified path'
1227
+ });
1228
+ return extractContent(fullContent, ['Web Artifacts Builder', 'React', 'Quick Start']);
1229
+ case 'webapp-testing':
1230
+ const scriptsPath = `${skill.skillsPath}/scripts`;
1231
+ nextSteps.push({
1232
+ step: 3,
1233
+ action: 'Read documentation and helper script',
1234
+ description: 'Read SKILL.md and scripts/with_server.py',
1235
+ file: `${scriptsPath}/with_server.py`,
1236
+ reason: 'Understand webapp testing workflow and with_server.py usage'
1237
+ });
1238
+ nextSteps.push({
1239
+ step: 4,
1240
+ action: 'Create workspace directory',
1241
+ description: `Create workspace directory: ${taskWorkspace}/`,
1242
+ reason: 'Create workspace directory for test files'
1243
+ });
1244
+ nextSteps.push({
1245
+ step: 5,
1246
+ action: 'Write Playwright tests in workspace',
1247
+ description: `Create test.py in ${taskWorkspace} for web application testing`,
1248
+ reason: 'Write test scripts in workspace'
1249
+ });
1250
+ nextSteps.push({
1251
+ step: 6,
1252
+ action: 'Run tests with server',
1253
+ description: `Run: python "${scriptsPath}/with_server.py" --server "<start_command>" --port <port> -- python ${taskWorkspace}/test.py`,
1254
+ reason: 'Run tests with server using existing with_server.py helper'
1255
+ });
1256
+ nextSteps.push({
1257
+ step: 7,
1258
+ action: 'Copy test reports to target directory',
1259
+ description: `Copy test reports from ${taskWorkspace} to target directory`,
1260
+ reason: 'Only save test reports to specified path'
1261
+ });
1262
+ return extractContent(fullContent, ['test', 'web', 'playwright', 'testing']);
1263
+ default:
1264
+ return extractContent(fullContent, ['frontend', 'design', 'web']);
1265
+ }
1266
+ }
1267
+ }
1268
+ /**
1269
+ * Visual Design Skill Executor
1270
+ */
1271
+ class VisualDesignSkillExecutor {
1272
+ async execute(skill, params) {
1273
+ const outputMessages = [];
1274
+ const files = [];
1275
+ const nextSteps = [];
1276
+ outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
1277
+ outputMessages.push(`**Task**: ${params.taskDescription}\n`);
1278
+ // Get or generate task ID
1279
+ const taskId = params.taskId || `${skill.id}-${Date.now()}`;
1280
+ try {
1281
+ // Read SKILL.md content
1282
+ const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
1283
+ files.push(skillMdPath);
1284
+ const skillContent = await fs.readFile(skillMdPath, 'utf-8');
1285
+ // Generate execution steps
1286
+ const taskContent = await this.extractVisualContent(skill, params, skillContent, nextSteps, taskId);
1287
+ outputMessages.push(taskContent);
1288
+ // Add input/output files to list if they exist
1289
+ if (params.inputFile)
1290
+ files.push(params.inputFile);
1291
+ if (params.outputFile)
1292
+ files.push(params.outputFile);
1293
+ return {
1294
+ success: true,
1295
+ output: outputMessages.join('\n'),
1296
+ files: files,
1297
+ nextSteps: nextSteps,
1298
+ requiresManualExecution: true
1299
+ };
1300
+ }
1301
+ catch (error) {
1302
+ return {
1303
+ success: false,
1304
+ error: error.message
1305
+ };
1306
+ }
1307
+ }
1308
+ /**
1309
+ * Extract relevant content based on visual design skill type and generate steps
1310
+ */
1311
+ async extractVisualContent(skill, params, fullContent, nextSteps, taskId) {
1312
+ const taskLower = params.taskDescription.toLowerCase();
1313
+ const workspaceBase = getWorkspaceDescription();
1314
+ const taskWorkspace = `${workspaceBase}/${taskId}`;
1315
+ switch (skill.id) {
1316
+ case 'canvas-design':
1317
+ // Canvas Design: Two-step process
1318
+ nextSteps.push({
1319
+ step: 1,
1320
+ action: 'Create workspace directory',
1321
+ description: `Create workspace directory: ${taskWorkspace}/`,
1322
+ reason: 'Create workspace directory for design files'
1323
+ });
1324
+ nextSteps.push({
1325
+ step: 2,
1326
+ action: 'Design Philosophy Creation',
1327
+ description: `Create manifesto/md file in ${taskWorkspace} defining aesthetic movement`,
1328
+ reason: 'Create design philosophy document in workspace'
1329
+ });
1330
+ nextSteps.push({
1331
+ step: 3,
1332
+ action: 'Canvas Creation',
1333
+ description: `Express philosophy visually using PDF/PNG output in ${taskWorkspace}`,
1334
+ reason: 'Express philosophy visually on canvas in workspace'
1335
+ });
1336
+ nextSteps.push({
1337
+ step: 4,
1338
+ action: 'Copy output to target directory',
1339
+ description: `Copy output files from ${taskWorkspace} to target directory`,
1340
+ reason: 'Only save final files to specified path'
1341
+ });
1342
+ return extractContent(fullContent, ['design', 'art', 'visual', 'philosophy']);
1343
+ case 'algorithmic-art':
1344
+ // Algorithmic Art
1345
+ nextSteps.push({
1346
+ step: 1,
1347
+ action: 'Create workspace directory',
1348
+ description: `Create workspace directory: ${taskWorkspace}/`,
1349
+ reason: 'Create workspace directory for generative art files'
1350
+ });
1351
+ nextSteps.push({
1352
+ step: 2,
1353
+ action: 'Algorithmic Philosophy',
1354
+ description: `Define generative art philosophy in ${taskWorkspace}`,
1355
+ reason: 'Create generative art philosophy in workspace'
1356
+ });
1357
+ nextSteps.push({
1358
+ step: 3,
1359
+ action: 'P5.js Implementation',
1360
+ description: `Write p5.js code in ${taskWorkspace} for generative art`,
1361
+ reason: 'Implement generative art code in workspace'
1362
+ });
1363
+ nextSteps.push({
1364
+ step: 4,
1365
+ action: 'Generate artwork',
1366
+ description: `Run p5.js code in ${taskWorkspace} to generate artwork`,
1367
+ reason: 'Run generative art code'
1368
+ });
1369
+ nextSteps.push({
1370
+ step: 5,
1371
+ action: 'Copy output to target directory',
1372
+ description: `Copy output files from ${taskWorkspace} to target directory`,
1373
+ reason: 'Only save final files to specified path'
1374
+ });
1375
+ return extractContent(fullContent, ['generative', 'algorithmic', 'art']);
1376
+ case 'theme-factory':
1377
+ // Theme Factory
1378
+ nextSteps.push({
1379
+ step: 1,
1380
+ action: 'Create workspace directory',
1381
+ description: `Create workspace directory: ${taskWorkspace}/`,
1382
+ reason: 'Create workspace directory for theme files'
1383
+ });
1384
+ nextSteps.push({
1385
+ step: 2,
1386
+ action: 'Select theme',
1387
+ description: `Choose from available themes or create custom in ${taskWorkspace}`,
1388
+ reason: 'Select or create theme in workspace'
1389
+ });
1390
+ nextSteps.push({
1391
+ step: 3,
1392
+ action: 'Apply theme',
1393
+ description: `Apply colors, fonts to design in ${taskWorkspace}`,
1394
+ reason: 'Apply theme to design in workspace'
1395
+ });
1396
+ nextSteps.push({
1397
+ step: 4,
1398
+ action: 'Copy output to target directory',
1399
+ description: `Copy theme files from ${taskWorkspace} to target directory`,
1400
+ reason: 'Only save final files to specified path'
1401
+ });
1402
+ return extractContent(fullContent, ['Theme Factory', 'Themes', 'apply']);
1403
+ case 'brand-guidelines':
1404
+ // Brand Guidelines
1405
+ nextSteps.push({
1406
+ step: 1,
1407
+ action: 'Create workspace directory',
1408
+ description: `Create workspace directory: ${taskWorkspace}/`,
1409
+ reason: 'Create workspace directory for brand files'
1410
+ });
1411
+ nextSteps.push({
1412
+ step: 2,
1413
+ action: 'Apply brand colors',
1414
+ description: `Use Anthropic brand colors and typography in ${taskWorkspace}`,
1415
+ reason: 'Apply brand colors in workspace'
1416
+ });
1417
+ nextSteps.push({
1418
+ step: 3,
1419
+ action: 'Follow guidelines',
1420
+ description: `Apply brand styling consistently in ${taskWorkspace}`,
1421
+ reason: 'Follow brand guidelines in workspace'
1422
+ });
1423
+ nextSteps.push({
1424
+ step: 4,
1425
+ action: 'Copy output to target directory',
1426
+ description: `Copy brand files from ${taskWorkspace} to target directory`,
1427
+ reason: 'Only save final files to specified path'
1428
+ });
1429
+ return extractContent(fullContent, ['Brand Guidelines', 'Colors', 'Typography']);
1430
+ default:
1431
+ nextSteps.push({
1432
+ step: 1,
1433
+ action: 'Create workspace directory',
1434
+ description: `Create workspace directory: ${taskWorkspace}/`,
1435
+ reason: 'Create workspace directory for design files'
1436
+ });
1437
+ nextSteps.push({
1438
+ step: 2,
1439
+ action: 'Create visual design',
1440
+ description: `Write design code or use canvas in ${taskWorkspace}`,
1441
+ reason: 'Create visual design in workspace'
1442
+ });
1443
+ nextSteps.push({
1444
+ step: 3,
1445
+ action: 'Copy output to target directory',
1446
+ description: `Copy output files from ${taskWorkspace} to target directory`,
1447
+ reason: 'Only save final files to specified path'
1448
+ });
1449
+ return extractContent(fullContent, ['design', 'art', 'visual']);
1450
+ }
1451
+ }
1452
+ }
1453
+ /**
1454
+ * Documentation Skill Executor
1455
+ */
1456
+ class DocumentationSkillExecutor {
1457
+ async execute(skill, params) {
1458
+ const outputMessages = [];
1459
+ const files = [];
1460
+ const nextSteps = [];
1461
+ outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
1462
+ outputMessages.push(`**Task**: ${params.taskDescription}\n`);
1463
+ // Get or generate task ID
1464
+ const taskId = params.taskId || `${skill.id}-${Date.now()}`;
1465
+ try {
1466
+ // Read SKILL.md content
1467
+ const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
1468
+ files.push(skillMdPath);
1469
+ const skillContent = await fs.readFile(skillMdPath, 'utf-8');
1470
+ // Generate execution steps
1471
+ const taskContent = await this.extractDocContent(skill, params, skillContent, nextSteps, taskId);
1472
+ outputMessages.push(taskContent);
1473
+ // Add input/output files to list if they exist
1474
+ if (params.inputFile)
1475
+ files.push(params.inputFile);
1476
+ if (params.outputFile)
1477
+ files.push(params.outputFile);
1478
+ return {
1479
+ success: true,
1480
+ output: outputMessages.join('\n'),
1481
+ files: files,
1482
+ nextSteps: nextSteps,
1483
+ requiresManualExecution: true
1484
+ };
1485
+ }
1486
+ catch (error) {
1487
+ return {
1488
+ success: false,
1489
+ error: error.message
1490
+ };
1491
+ }
1492
+ }
1493
+ /**
1494
+ * Extract relevant content based on documentation skill type and generate steps
1495
+ */
1496
+ async extractDocContent(skill, params, fullContent, nextSteps, taskId) {
1497
+ const taskLower = params.taskDescription.toLowerCase();
1498
+ const workspaceBase = getWorkspaceDescription();
1499
+ const taskWorkspace = `${workspaceBase}/${taskId}`;
1500
+ switch (skill.id) {
1501
+ case 'internal-comms':
1502
+ // Internal Comms
1503
+ if (taskLower.includes('status') || taskLower.includes('report')) {
1504
+ nextSteps.push({
1505
+ step: 1,
1506
+ action: 'Gather information',
1507
+ description: 'Collect progress, plans, problems',
1508
+ reason: 'Gather status information'
1509
+ });
1510
+ nextSteps.push({
1511
+ step: 2,
1512
+ action: 'Write update',
1513
+ description: 'Draft 3P update format',
1514
+ reason: 'Write status update'
1515
+ });
1516
+ }
1517
+ else if (taskLower.includes('newsletter')) {
1518
+ nextSteps.push({
1519
+ step: 1,
1520
+ action: 'Create newsletter',
1521
+ description: 'Write company newsletter content',
1522
+ reason: 'Create company newsletter'
1523
+ });
1524
+ }
1525
+ return extractContent(fullContent, ['documentation', 'writing', 'internal']);
1526
+ case 'doc-coauthoring':
1527
+ // Doc Co-Authoring: Three-stage process
1528
+ nextSteps.push({
1529
+ step: 1,
1530
+ action: 'Create workspace directory',
1531
+ description: `Create workspace directory: ${taskWorkspace}/`,
1532
+ reason: 'Create workspace directory for document drafts'
1533
+ });
1534
+ nextSteps.push({
1535
+ step: 2,
1536
+ action: 'Stage 1: Context Gathering',
1537
+ description: 'Gather requirements and initial questions',
1538
+ reason: 'Gather document background and requirements'
1539
+ });
1540
+ nextSteps.push({
1541
+ step: 3,
1542
+ action: 'Stage 2: Refinement',
1543
+ description: `Structure and draft content in ${taskWorkspace}`,
1544
+ reason: 'Structure and draft document in workspace'
1545
+ });
1546
+ nextSteps.push({
1547
+ step: 4,
1548
+ action: 'Stage 3: Reader Testing',
1549
+ description: `Test with fresh Claude and refine in ${taskWorkspace}`,
1550
+ reason: 'Test and refine document in workspace'
1551
+ });
1552
+ nextSteps.push({
1553
+ step: 5,
1554
+ action: 'Copy final document to target directory',
1555
+ description: `Copy final document from ${taskWorkspace} to target directory`,
1556
+ reason: 'Only save final document to specified path'
1557
+ });
1558
+ return extractContent(fullContent, ['documentation', 'coauthor', 'workflow']);
1559
+ default:
1560
+ return extractContent(fullContent, ['documentation', 'writing', 'guide']);
1561
+ }
1562
+ }
1563
+ }
1564
+ /**
1565
+ * Default Skill Executor
1566
+ */
1567
+ class DefaultSkillExecutor {
1568
+ async execute(skill, params) {
1569
+ const outputMessages = [];
1570
+ const files = [];
1571
+ const nextSteps = [];
1572
+ outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
1573
+ outputMessages.push(`**Task**: ${params.taskDescription}\n`);
1574
+ try {
1575
+ // Read SKILL.md content
1576
+ const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
1577
+ files.push(skillMdPath);
1578
+ const skillContent = await fs.readFile(skillMdPath, 'utf-8');
1579
+ // Generate execution steps
1580
+ const taskContent = this.extractDefaultContent(skill, skillContent, nextSteps);
1581
+ outputMessages.push(taskContent);
1582
+ // Add input/output files to list if they exist
1583
+ if (params.inputFile)
1584
+ files.push(params.inputFile);
1585
+ if (params.outputFile)
1586
+ files.push(params.outputFile);
1587
+ return {
1588
+ success: true,
1589
+ output: outputMessages.join('\n'),
1590
+ files: files,
1591
+ nextSteps: nextSteps,
1592
+ requiresManualExecution: true
1593
+ };
1594
+ }
1595
+ catch (error) {
1596
+ return {
1597
+ success: false,
1598
+ error: error.message
1599
+ };
1600
+ }
1601
+ }
1602
+ /**
1603
+ * Extract default skill content and generate steps
1604
+ */
1605
+ extractDefaultContent(skill, fullContent, nextSteps) {
1606
+ nextSteps.push({
1607
+ step: 1,
1608
+ action: 'Read SKILL.md',
1609
+ description: `Read ${skill.skillsPath}/SKILL.md for full instructions`,
1610
+ reason: 'Understand complete execution workflow'
1611
+ });
1612
+ nextSteps.push({
1613
+ step: 2,
1614
+ action: 'Follow workflow',
1615
+ description: 'Execute according to SKILL.md instructions',
1616
+ reason: 'Follow SKILL.md guidance for execution'
1617
+ });
1618
+ return extractContent(fullContent, ['skill', 'guide', 'how to', skill.name]);
1619
+ }
1620
+ }
1621
+ // ============================================================
1622
+ // ============================================================
1623
+ /**
1624
+ * Execute skill - LLM analyzes SKILL.md and generates its own steps
1625
+ * @param skill Skill to execute
1626
+ * @param params Execution parameters
1627
+ * @returns Execution result with guidance
1628
+ */
1629
+ export async function executeSkill(skill, params) {
1630
+ const executor = new DocumentSkillExecutor();
1631
+ return executor.execute(skill, params);
1632
+ }
1633
+ // ============================================================
1634
+ // Singleton Instance and Exports
1635
+ // ============================================================
1636
+ let skillInvokerInstance = null;
1637
+ export function getSkillInvoker() {
1638
+ if (!skillInvokerInstance) {
1639
+ skillInvokerInstance = new SkillInvoker();
1640
+ }
1641
+ return skillInvokerInstance;
1642
+ }
1643
+ //# sourceMappingURL=skill-invoker.js.map