@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.
- package/.eslintrc.js +25 -0
- package/.gitmodules +3 -0
- package/.prettierrc.json +8 -0
- package/CONTRIBUTING.md +167 -0
- package/LICENSE +21 -0
- package/README.md +280 -0
- package/README_CN.md +280 -0
- package/dist/agents.d.ts +21 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +463 -0
- package/dist/agents.js.map +1 -0
- package/dist/ai-client.d.ts +83 -0
- package/dist/ai-client.d.ts.map +1 -0
- package/dist/ai-client.js +1280 -0
- package/dist/ai-client.js.map +1 -0
- package/dist/auth.d.ts +25 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +573 -0
- package/dist/auth.js.map +1 -0
- package/dist/cancellation.d.ts +46 -0
- package/dist/cancellation.d.ts.map +1 -0
- package/dist/cancellation.js +154 -0
- package/dist/cancellation.js.map +1 -0
- package/dist/checkpoint.d.ts +28 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +186 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +364 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +49 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +205 -0
- package/dist/config.js.map +1 -0
- package/dist/context-compressor.d.ts +51 -0
- package/dist/context-compressor.d.ts.map +1 -0
- package/dist/context-compressor.js +231 -0
- package/dist/context-compressor.js.map +1 -0
- package/dist/conversation.d.ts +34 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +221 -0
- package/dist/conversation.js.map +1 -0
- package/dist/gui-subagent/action-parser/actionParser.d.ts +19 -0
- package/dist/gui-subagent/action-parser/actionParser.d.ts.map +1 -0
- package/dist/gui-subagent/action-parser/actionParser.js +203 -0
- package/dist/gui-subagent/action-parser/actionParser.js.map +1 -0
- package/dist/gui-subagent/action-parser/constants.d.ts +8 -0
- package/dist/gui-subagent/action-parser/constants.d.ts.map +1 -0
- package/dist/gui-subagent/action-parser/constants.js +12 -0
- package/dist/gui-subagent/action-parser/constants.js.map +1 -0
- package/dist/gui-subagent/action-parser/index.d.ts +3 -0
- package/dist/gui-subagent/action-parser/index.d.ts.map +1 -0
- package/dist/gui-subagent/action-parser/index.js +6 -0
- package/dist/gui-subagent/action-parser/index.js.map +1 -0
- package/dist/gui-subagent/action-parser/types.d.ts +24 -0
- package/dist/gui-subagent/action-parser/types.d.ts.map +1 -0
- package/dist/gui-subagent/action-parser/types.js +12 -0
- package/dist/gui-subagent/action-parser/types.js.map +1 -0
- package/dist/gui-subagent/agent/gui-agent.d.ts +126 -0
- package/dist/gui-subagent/agent/gui-agent.d.ts.map +1 -0
- package/dist/gui-subagent/agent/gui-agent.js +820 -0
- package/dist/gui-subagent/agent/gui-agent.js.map +1 -0
- package/dist/gui-subagent/agent/index.d.ts +5 -0
- package/dist/gui-subagent/agent/index.d.ts.map +1 -0
- package/dist/gui-subagent/agent/index.js +5 -0
- package/dist/gui-subagent/agent/index.js.map +1 -0
- package/dist/gui-subagent/index.d.ts +43 -0
- package/dist/gui-subagent/index.d.ts.map +1 -0
- package/dist/gui-subagent/index.js +96 -0
- package/dist/gui-subagent/index.js.map +1 -0
- package/dist/gui-subagent/operator/base-operator.d.ts +108 -0
- package/dist/gui-subagent/operator/base-operator.d.ts.map +1 -0
- package/dist/gui-subagent/operator/base-operator.js +172 -0
- package/dist/gui-subagent/operator/base-operator.js.map +1 -0
- package/dist/gui-subagent/operator/browser-operator.d.ts +36 -0
- package/dist/gui-subagent/operator/browser-operator.d.ts.map +1 -0
- package/dist/gui-subagent/operator/browser-operator.js +306 -0
- package/dist/gui-subagent/operator/browser-operator.js.map +1 -0
- package/dist/gui-subagent/operator/computer-operator.d.ts +31 -0
- package/dist/gui-subagent/operator/computer-operator.d.ts.map +1 -0
- package/dist/gui-subagent/operator/computer-operator.js +441 -0
- package/dist/gui-subagent/operator/computer-operator.js.map +1 -0
- package/dist/gui-subagent/operator/desktop-operator.d.ts +55 -0
- package/dist/gui-subagent/operator/desktop-operator.d.ts.map +1 -0
- package/dist/gui-subagent/operator/desktop-operator.js +527 -0
- package/dist/gui-subagent/operator/desktop-operator.js.map +1 -0
- package/dist/gui-subagent/operator/index.d.ts +7 -0
- package/dist/gui-subagent/operator/index.d.ts.map +1 -0
- package/dist/gui-subagent/operator/index.js +6 -0
- package/dist/gui-subagent/operator/index.js.map +1 -0
- package/dist/gui-subagent/types/actions.d.ts +108 -0
- package/dist/gui-subagent/types/actions.d.ts.map +1 -0
- package/dist/gui-subagent/types/actions.js +39 -0
- package/dist/gui-subagent/types/actions.js.map +1 -0
- package/dist/gui-subagent/types/index.d.ts +6 -0
- package/dist/gui-subagent/types/index.d.ts.map +1 -0
- package/dist/gui-subagent/types/index.js +6 -0
- package/dist/gui-subagent/types/index.js.map +1 -0
- package/dist/gui-subagent/types/operator.d.ts +95 -0
- package/dist/gui-subagent/types/operator.d.ts.map +1 -0
- package/dist/gui-subagent/types/operator.js +16 -0
- package/dist/gui-subagent/types/operator.js.map +1 -0
- package/dist/gui-subagent/utils.d.ts +19 -0
- package/dist/gui-subagent/utils.d.ts.map +1 -0
- package/dist/gui-subagent/utils.js +42 -0
- package/dist/gui-subagent/utils.js.map +1 -0
- package/dist/hook.d.ts +73 -0
- package/dist/hook.d.ts.map +1 -0
- package/dist/hook.js +156 -0
- package/dist/hook.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/input-history.d.ts +24 -0
- package/dist/input-history.d.ts.map +1 -0
- package/dist/input-history.js +94 -0
- package/dist/input-history.js.map +1 -0
- package/dist/input-processor.d.ts +31 -0
- package/dist/input-processor.d.ts.map +1 -0
- package/dist/input-processor.js +233 -0
- package/dist/input-processor.js.map +1 -0
- package/dist/keyboard-manager.d.ts +151 -0
- package/dist/keyboard-manager.d.ts.map +1 -0
- package/dist/keyboard-manager.js +396 -0
- package/dist/keyboard-manager.js.map +1 -0
- package/dist/logger.d.ts +75 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +339 -0
- package/dist/logger.js.map +1 -0
- package/dist/mcp.d.ts +57 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +483 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory.d.ts +25 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +250 -0
- package/dist/memory.js.map +1 -0
- package/dist/print-system-prompt.d.ts +2 -0
- package/dist/print-system-prompt.d.ts.map +1 -0
- package/dist/print-system-prompt.js +40 -0
- package/dist/print-system-prompt.js.map +1 -0
- package/dist/session-manager.d.ts +41 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +234 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/session.d.ts +77 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +1081 -0
- package/dist/session.js.map +1 -0
- package/dist/skill-invoker.d.ts +177 -0
- package/dist/skill-invoker.d.ts.map +1 -0
- package/dist/skill-invoker.js +1643 -0
- package/dist/skill-invoker.js.map +1 -0
- package/dist/skill-loader.d.ts +76 -0
- package/dist/skill-loader.d.ts.map +1 -0
- package/dist/skill-loader.js +407 -0
- package/dist/skill-loader.js.map +1 -0
- package/dist/slash-commands.d.ts +60 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/slash-commands.js +1021 -0
- package/dist/slash-commands.js.map +1 -0
- package/dist/smart-approval.d.ts +137 -0
- package/dist/smart-approval.d.ts.map +1 -0
- package/dist/smart-approval.js +512 -0
- package/dist/smart-approval.js.map +1 -0
- package/dist/system-prompt-generator.d.ts +35 -0
- package/dist/system-prompt-generator.d.ts.map +1 -0
- package/dist/system-prompt-generator.js +729 -0
- package/dist/system-prompt-generator.js.map +1 -0
- package/dist/test-boundary-conditions.d.ts.map +1 -0
- package/dist/test-boundary-conditions.js.map +1 -0
- package/dist/test-cancellation-fix.d.ts.map +1 -0
- package/dist/test-cancellation-fix.js.map +1 -0
- package/dist/test-input-history.d.ts.map +1 -0
- package/dist/test-input-history.js.map +1 -0
- package/dist/test-interaction-flow.d.ts.map +1 -0
- package/dist/test-interaction-flow.js.map +1 -0
- package/dist/test-quick.d.ts.map +1 -0
- package/dist/test-quick.js.map +1 -0
- package/dist/test-user-interaction.d.ts.map +1 -0
- package/dist/test-user-interaction.js.map +1 -0
- package/dist/theme.d.ts +353 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +383 -0
- package/dist/theme.js.map +1 -0
- package/dist/tools.d.ts +373 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +2906 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +180 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/dist/unified-session.d.ts +42 -0
- package/dist/unified-session.d.ts.map +1 -0
- package/dist/unified-session.js +271 -0
- package/dist/unified-session.js.map +1 -0
- package/dist/update.d.ts +30 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +211 -0
- package/dist/update.js.map +1 -0
- package/dist/workflow.d.ts +53 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +405 -0
- package/dist/workflow.js.map +1 -0
- package/docs/architecture/mcp-integration-guide.md +131 -0
- package/docs/architecture/overview.md +93 -0
- package/docs/architecture/tool-system-design.md +89 -0
- package/docs/cli/commands.md +189 -0
- package/docs/smart-mode.md +257 -0
- package/docs/third-party-models.md +449 -0
- package/package.json +85 -0
- package/scripts/init-skills-path.js +58 -0
- package/skills/.claude-plugin/marketplace.json +45 -0
- package/skills/README.md +94 -0
- package/skills/THIRD_PARTY_NOTICES.md +405 -0
- package/skills/skills/algorithmic-art/LICENSE.txt +202 -0
- package/skills/skills/algorithmic-art/SKILL.md +405 -0
- package/skills/skills/algorithmic-art/templates/generator_template.js +223 -0
- package/skills/skills/algorithmic-art/templates/viewer.html +599 -0
- package/skills/skills/brand-guidelines/LICENSE.txt +202 -0
- package/skills/skills/brand-guidelines/SKILL.md +73 -0
- package/skills/skills/canvas-design/LICENSE.txt +202 -0
- package/skills/skills/canvas-design/SKILL.md +130 -0
- package/skills/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -0
- package/skills/skills/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Italiana-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Jura-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/PoiretOne-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
- package/skills/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
- package/skills/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
- package/skills/skills/doc-coauthoring/SKILL.md +375 -0
- package/skills/skills/docx/LICENSE.txt +30 -0
- package/skills/skills/docx/SKILL.md +197 -0
- package/skills/skills/docx/docx-js.md +350 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/skills/docx/ooxml/scripts/pack.py +159 -0
- package/skills/skills/docx/ooxml/scripts/unpack.py +29 -0
- package/skills/skills/docx/ooxml/scripts/validate.py +69 -0
- package/skills/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/skills/docx/ooxml/scripts/validation/base.py +951 -0
- package/skills/skills/docx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/skills/docx/ooxml.md +610 -0
- package/skills/skills/docx/scripts/__init__.py +1 -0
- package/skills/skills/docx/scripts/document.py +1276 -0
- package/skills/skills/docx/scripts/templates/comments.xml +3 -0
- package/skills/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/skills/docx/scripts/templates/people.xml +3 -0
- package/skills/skills/docx/scripts/utilities.py +374 -0
- package/skills/skills/frontend-design/LICENSE.txt +177 -0
- package/skills/skills/frontend-design/SKILL.md +42 -0
- package/skills/skills/internal-comms/LICENSE.txt +202 -0
- package/skills/skills/internal-comms/SKILL.md +32 -0
- package/skills/skills/internal-comms/examples/3p-updates.md +47 -0
- package/skills/skills/internal-comms/examples/company-newsletter.md +65 -0
- package/skills/skills/internal-comms/examples/faq-answers.md +30 -0
- package/skills/skills/internal-comms/examples/general-comms.md +16 -0
- package/skills/skills/mcp-builder/LICENSE.txt +202 -0
- package/skills/skills/mcp-builder/SKILL.md +236 -0
- package/skills/skills/mcp-builder/reference/evaluation.md +602 -0
- package/skills/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/skills/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/skills/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/skills/skills/mcp-builder/scripts/connections.py +151 -0
- package/skills/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/skills/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/skills/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/skills/skills/pdf/LICENSE.txt +30 -0
- package/skills/skills/pdf/SKILL.md +294 -0
- package/skills/skills/pdf/forms.md +205 -0
- package/skills/skills/pdf/reference.md +612 -0
- package/skills/skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/skills/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/skills/skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/skills/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/skills/skills/pdf/scripts/create_validation_image.py +41 -0
- package/skills/skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/skills/skills/pdf/scripts/fill_fillable_fields.py +114 -0
- package/skills/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/skills/skills/pptx/LICENSE.txt +30 -0
- package/skills/skills/pptx/SKILL.md +484 -0
- package/skills/skills/pptx/html2pptx.md +625 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/skills/pptx/ooxml/scripts/pack.py +159 -0
- package/skills/skills/pptx/ooxml/scripts/unpack.py +29 -0
- package/skills/skills/pptx/ooxml/scripts/validate.py +69 -0
- package/skills/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/skills/pptx/ooxml/scripts/validation/base.py +951 -0
- package/skills/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/skills/pptx/ooxml.md +427 -0
- package/skills/skills/pptx/scripts/html2pptx.js +979 -0
- package/skills/skills/pptx/scripts/inventory.py +1020 -0
- package/skills/skills/pptx/scripts/rearrange.py +231 -0
- package/skills/skills/pptx/scripts/replace.py +385 -0
- package/skills/skills/pptx/scripts/thumbnail.py +450 -0
- package/skills/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skills/skill-creator/SKILL.md +356 -0
- package/skills/skills/skill-creator/references/output-patterns.md +82 -0
- package/skills/skills/skill-creator/references/workflows.md +28 -0
- package/skills/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skills/skill-creator/scripts/package_skill.py +110 -0
- package/skills/skills/skill-creator/scripts/quick_validate.py +95 -0
- package/skills/skills/slack-gif-creator/LICENSE.txt +202 -0
- package/skills/skills/slack-gif-creator/SKILL.md +254 -0
- package/skills/skills/slack-gif-creator/core/easing.py +234 -0
- package/skills/skills/slack-gif-creator/core/frame_composer.py +176 -0
- package/skills/skills/slack-gif-creator/core/gif_builder.py +269 -0
- package/skills/skills/slack-gif-creator/core/validators.py +136 -0
- package/skills/skills/slack-gif-creator/requirements.txt +4 -0
- package/skills/skills/theme-factory/LICENSE.txt +202 -0
- package/skills/skills/theme-factory/SKILL.md +59 -0
- package/skills/skills/theme-factory/theme-showcase.pdf +0 -0
- package/skills/skills/theme-factory/themes/arctic-frost.md +19 -0
- package/skills/skills/theme-factory/themes/botanical-garden.md +19 -0
- package/skills/skills/theme-factory/themes/desert-rose.md +19 -0
- package/skills/skills/theme-factory/themes/forest-canopy.md +19 -0
- package/skills/skills/theme-factory/themes/golden-hour.md +19 -0
- package/skills/skills/theme-factory/themes/midnight-galaxy.md +19 -0
- package/skills/skills/theme-factory/themes/modern-minimalist.md +19 -0
- package/skills/skills/theme-factory/themes/ocean-depths.md +19 -0
- package/skills/skills/theme-factory/themes/sunset-boulevard.md +19 -0
- package/skills/skills/theme-factory/themes/tech-innovation.md +19 -0
- package/skills/skills/web-artifacts-builder/LICENSE.txt +202 -0
- package/skills/skills/web-artifacts-builder/SKILL.md +74 -0
- package/skills/skills/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/skills/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/skills/skills/webapp-testing/LICENSE.txt +202 -0
- package/skills/skills/webapp-testing/SKILL.md +96 -0
- package/skills/skills/webapp-testing/examples/console_logging.py +35 -0
- package/skills/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/skills/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/skills/skills/webapp-testing/scripts/with_server.py +106 -0
- package/skills/skills/xlsx/LICENSE.txt +30 -0
- package/skills/skills/xlsx/SKILL.md +289 -0
- package/skills/skills/xlsx/recalc.py +178 -0
- package/skills/spec/agent-skills-spec.md +3 -0
- package/skills/template/SKILL.md +6 -0
- package/src/agents.ts +504 -0
- package/src/ai-client.ts +1456 -0
- package/src/auth.ts +648 -0
- package/src/cancellation.ts +176 -0
- package/src/checkpoint.ts +219 -0
- package/src/cli.ts +384 -0
- package/src/config.ts +248 -0
- package/src/context-compressor.ts +290 -0
- package/src/conversation.ts +288 -0
- package/src/gui-subagent/action-parser/actionParser.ts +312 -0
- package/src/gui-subagent/action-parser/constants.ts +12 -0
- package/src/gui-subagent/action-parser/index.ts +6 -0
- package/src/gui-subagent/action-parser/types.ts +31 -0
- package/src/gui-subagent/agent/gui-agent.ts +982 -0
- package/src/gui-subagent/agent/index.ts +5 -0
- package/src/gui-subagent/index.ts +139 -0
- package/src/gui-subagent/operator/base-operator.ts +246 -0
- package/src/gui-subagent/operator/computer-operator.ts +520 -0
- package/src/gui-subagent/operator/index.ts +7 -0
- package/src/gui-subagent/types/actions.ts +263 -0
- package/src/gui-subagent/types/index.ts +6 -0
- package/src/gui-subagent/types/operator.ts +106 -0
- package/src/gui-subagent/utils.ts +51 -0
- package/src/index.ts +18 -0
- package/src/input-processor.ts +282 -0
- package/src/logger.ts +438 -0
- package/src/mcp.ts +563 -0
- package/src/memory.ts +303 -0
- package/src/session-manager.ts +308 -0
- package/src/session.ts +1280 -0
- package/src/skill-invoker.ts +1888 -0
- package/src/skill-loader.ts +476 -0
- package/src/slash-commands.ts +1150 -0
- package/src/smart-approval.ts +595 -0
- package/src/system-prompt-generator.ts +786 -0
- package/src/theme.ts +455 -0
- package/src/tools.ts +3398 -0
- package/src/types.ts +198 -0
- package/src/update.ts +270 -0
- package/src/workflow.ts +508 -0
- package/tsconfig.json +22 -0
- 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
|