@shareai-lab/kode 1.1.23 → 2.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/README.md +25 -404
- package/cli-acp.js +82 -0
- package/cli.js +89 -79
- package/dist/REPL-CW7AYLVL.js +42 -0
- package/dist/acp-VEPJ74LT.js +1357 -0
- package/dist/acp-VEPJ74LT.js.map +7 -0
- package/dist/agentsValidate-7LH4HTNR.js +373 -0
- package/dist/agentsValidate-7LH4HTNR.js.map +7 -0
- package/dist/ask-3NHFFUQG.js +125 -0
- package/dist/ask-3NHFFUQG.js.map +7 -0
- package/dist/autoUpdater-ITPIHCOI.js +17 -0
- package/dist/chunk-3IN27HA5.js +128 -0
- package/dist/chunk-3IN27HA5.js.map +7 -0
- package/dist/chunk-3RUXVV4S.js +23 -0
- package/dist/chunk-3RUXVV4S.js.map +7 -0
- package/dist/chunk-4FX3IVPT.js +164 -0
- package/dist/chunk-4FX3IVPT.js.map +7 -0
- package/dist/chunk-4RTX4AG4.js +249 -0
- package/dist/chunk-4RTX4AG4.js.map +7 -0
- package/dist/chunk-5PDP7R6N.js +515 -0
- package/dist/chunk-5PDP7R6N.js.map +7 -0
- package/dist/chunk-73WGVYLQ.js +735 -0
- package/dist/chunk-73WGVYLQ.js.map +7 -0
- package/dist/{services/systemReminder.js → chunk-7M2YN6TU.js} +221 -59
- package/dist/chunk-7M2YN6TU.js.map +7 -0
- package/dist/{utils/theme.js → chunk-7U7L4NMD.js} +28 -6
- package/dist/chunk-7U7L4NMD.js.map +7 -0
- package/dist/chunk-ABLVTESJ.js +19 -0
- package/dist/chunk-ABLVTESJ.js.map +7 -0
- package/dist/chunk-AFFSCMYS.js +191 -0
- package/dist/chunk-AFFSCMYS.js.map +7 -0
- package/dist/chunk-ARZSBOAO.js +1256 -0
- package/dist/chunk-ARZSBOAO.js.map +7 -0
- package/dist/chunk-CIG63V4E.js +72 -0
- package/dist/chunk-CIG63V4E.js.map +7 -0
- package/dist/chunk-CM3EGTG6.js +1609 -0
- package/dist/chunk-CM3EGTG6.js.map +7 -0
- package/dist/{services/openai.js → chunk-DZE5YA7L.js} +168 -234
- package/dist/chunk-DZE5YA7L.js.map +7 -0
- package/dist/chunk-E6YNABER.js +24 -0
- package/dist/chunk-E6YNABER.js.map +7 -0
- package/dist/{cost-tracker.js → chunk-EZXMVTDU.js} +51 -32
- package/dist/chunk-EZXMVTDU.js.map +7 -0
- package/dist/chunk-F2SJXUDI.js +148 -0
- package/dist/chunk-F2SJXUDI.js.map +7 -0
- package/dist/chunk-FC5ZCKBI.js +30167 -0
- package/dist/chunk-FC5ZCKBI.js.map +7 -0
- package/dist/chunk-HCBELH4J.js +145 -0
- package/dist/chunk-HCBELH4J.js.map +7 -0
- package/dist/chunk-HN4E4UUQ.js +96 -0
- package/dist/chunk-HN4E4UUQ.js.map +7 -0
- package/dist/{utils/model.js → chunk-IZVMU4S2.js} +194 -227
- package/dist/chunk-IZVMU4S2.js.map +7 -0
- package/dist/chunk-JC6NCUG5.js +11 -0
- package/dist/chunk-K2CWOTI2.js +196 -0
- package/dist/chunk-K2CWOTI2.js.map +7 -0
- package/dist/chunk-KAA5BGMQ.js +12 -0
- package/dist/chunk-KAA5BGMQ.js.map +7 -0
- package/dist/{utils/config.js → chunk-LC4TVOCZ.js} +351 -171
- package/dist/chunk-LC4TVOCZ.js.map +7 -0
- package/dist/chunk-MIW7N2MY.js +2613 -0
- package/dist/chunk-MIW7N2MY.js.map +7 -0
- package/dist/chunk-MWRSY4X6.js +240 -0
- package/dist/chunk-MWRSY4X6.js.map +7 -0
- package/dist/chunk-ND3XWFO6.js +34 -0
- package/dist/chunk-ND3XWFO6.js.map +7 -0
- package/dist/chunk-NPFOMITO.js +21 -0
- package/dist/chunk-NPFOMITO.js.map +7 -0
- package/dist/chunk-QVLYOPO5.js +1097 -0
- package/dist/chunk-QVLYOPO5.js.map +7 -0
- package/dist/chunk-RZWOUA25.js +490 -0
- package/dist/chunk-RZWOUA25.js.map +7 -0
- package/dist/chunk-S3J2TLV6.js +16 -0
- package/dist/chunk-S3J2TLV6.js.map +7 -0
- package/dist/chunk-S6HRABTA.js +95 -0
- package/dist/chunk-S6HRABTA.js.map +7 -0
- package/dist/{utils/debugLogger.js → chunk-STSX7GIX.js} +107 -204
- package/dist/chunk-STSX7GIX.js.map +7 -0
- package/dist/chunk-UHYRLID6.js +472 -0
- package/dist/chunk-UHYRLID6.js.map +7 -0
- package/dist/chunk-UKHTVRJM.js +47 -0
- package/dist/chunk-UKHTVRJM.js.map +7 -0
- package/dist/chunk-UYXEDKOZ.js +24 -0
- package/dist/chunk-UYXEDKOZ.js.map +7 -0
- package/dist/chunk-W7GRKO7Q.js +766 -0
- package/dist/chunk-W7GRKO7Q.js.map +7 -0
- package/dist/chunk-WVHORZQ5.js +17 -0
- package/dist/chunk-WVHORZQ5.js.map +7 -0
- package/dist/chunk-WWUWDNWW.js +49 -0
- package/dist/chunk-WWUWDNWW.js.map +7 -0
- package/dist/chunk-YC6LJCDE.js +511 -0
- package/dist/chunk-YC6LJCDE.js.map +7 -0
- package/dist/chunk-YXYYDIMI.js +2931 -0
- package/dist/chunk-YXYYDIMI.js.map +7 -0
- package/dist/chunk-ZVDRDPII.js +138 -0
- package/dist/chunk-ZVDRDPII.js.map +7 -0
- package/dist/cli-DOPVY2CW.js +3917 -0
- package/dist/cli-DOPVY2CW.js.map +7 -0
- package/dist/commands-2BF2CJ3A.js +46 -0
- package/dist/config-RUSD6G5Y.js +81 -0
- package/dist/context-6FXPETYH.js +30 -0
- package/dist/costTracker-6SL26FDB.js +19 -0
- package/dist/customCommands-TOIJFZAL.js +25 -0
- package/dist/customCommands-TOIJFZAL.js.map +7 -0
- package/dist/env-XGKBLU3D.js +22 -0
- package/dist/env-XGKBLU3D.js.map +7 -0
- package/dist/index.js +34 -5
- package/dist/index.js.map +4 -4
- package/dist/kodeAgentSessionId-X6XWQW7B.js +13 -0
- package/dist/kodeAgentSessionId-X6XWQW7B.js.map +7 -0
- package/dist/kodeAgentSessionLoad-MITZADPB.js +18 -0
- package/dist/kodeAgentSessionLoad-MITZADPB.js.map +7 -0
- package/dist/kodeAgentSessionResume-GVRWB4WO.js +16 -0
- package/dist/kodeAgentSessionResume-GVRWB4WO.js.map +7 -0
- package/dist/kodeAgentStreamJson-NXFN7TXH.js +13 -0
- package/dist/kodeAgentStreamJson-NXFN7TXH.js.map +7 -0
- package/dist/kodeAgentStreamJsonSession-UGEZJJEB.js +131 -0
- package/dist/kodeAgentStreamJsonSession-UGEZJJEB.js.map +7 -0
- package/dist/kodeAgentStructuredStdio-HGWJT7CU.js +10 -0
- package/dist/kodeAgentStructuredStdio-HGWJT7CU.js.map +7 -0
- package/dist/kodeHooks-QWM36A3D.js +36 -0
- package/dist/kodeHooks-QWM36A3D.js.map +7 -0
- package/dist/llm-ZUQC4WYM.js +3118 -0
- package/dist/llm-ZUQC4WYM.js.map +7 -0
- package/dist/llmLazy-54QQHA54.js +15 -0
- package/dist/llmLazy-54QQHA54.js.map +7 -0
- package/dist/loader-FYHJQES5.js +28 -0
- package/dist/loader-FYHJQES5.js.map +7 -0
- package/dist/mcp-J332IKT3.js +49 -0
- package/dist/mcp-J332IKT3.js.map +7 -0
- package/dist/{services/mentionProcessor.js → mentionProcessor-EE3XFHCJ.js} +61 -50
- package/dist/mentionProcessor-EE3XFHCJ.js.map +7 -0
- package/dist/messages-EOYQKPGM.js +63 -0
- package/dist/messages-EOYQKPGM.js.map +7 -0
- package/dist/model-FV3JDJKH.js +30 -0
- package/dist/model-FV3JDJKH.js.map +7 -0
- package/dist/openai-RRCWW33N.js +29 -0
- package/dist/openai-RRCWW33N.js.map +7 -0
- package/dist/outputStyles-62Q3VH2J.js +28 -0
- package/dist/outputStyles-62Q3VH2J.js.map +7 -0
- package/dist/package.json +1 -1
- package/dist/pluginRuntime-6ETCZ2LL.js +218 -0
- package/dist/pluginRuntime-6ETCZ2LL.js.map +7 -0
- package/dist/pluginValidation-I4YKUWGS.js +17 -0
- package/dist/pluginValidation-I4YKUWGS.js.map +7 -0
- package/dist/prompts-ZLEKDD77.js +48 -0
- package/dist/prompts-ZLEKDD77.js.map +7 -0
- package/dist/query-VFRJPBGD.js +50 -0
- package/dist/query-VFRJPBGD.js.map +7 -0
- package/dist/responsesStreaming-AW344PQO.js +10 -0
- package/dist/responsesStreaming-AW344PQO.js.map +7 -0
- package/dist/ripgrep-3NTIKQYW.js +17 -0
- package/dist/ripgrep-3NTIKQYW.js.map +7 -0
- package/dist/skillMarketplace-3RXQBVOL.js +37 -0
- package/dist/skillMarketplace-3RXQBVOL.js.map +7 -0
- package/dist/state-P5G6CO5V.js +16 -0
- package/dist/state-P5G6CO5V.js.map +7 -0
- package/dist/theme-3LWP3BG7.js +14 -0
- package/dist/theme-3LWP3BG7.js.map +7 -0
- package/dist/toolPermissionContext-65L65VEZ.js +17 -0
- package/dist/toolPermissionContext-65L65VEZ.js.map +7 -0
- package/dist/toolPermissionSettings-3ROBVTUK.js +18 -0
- package/dist/toolPermissionSettings-3ROBVTUK.js.map +7 -0
- package/dist/tools-RO7HSSE5.js +47 -0
- package/dist/tools-RO7HSSE5.js.map +7 -0
- package/dist/userInput-JSBJRFSK.js +311 -0
- package/dist/userInput-JSBJRFSK.js.map +7 -0
- package/dist/uuid-QN2CNKKN.js +9 -0
- package/dist/uuid-QN2CNKKN.js.map +7 -0
- package/package.json +43 -15
- package/scripts/binary-utils.cjs +62 -0
- package/scripts/cli-acp-wrapper.cjs +82 -0
- package/scripts/cli-wrapper.cjs +105 -0
- package/scripts/postinstall.js +135 -9
- package/LICENSE +0 -201
- package/README.zh-CN.md +0 -326
- package/dist/ProjectOnboarding.js +0 -99
- package/dist/ProjectOnboarding.js.map +0 -7
- package/dist/Tool.js +0 -1
- package/dist/commands/agents.js +0 -2087
- package/dist/commands/agents.js.map +0 -7
- package/dist/commands/approvedTools.js +0 -36
- package/dist/commands/approvedTools.js.map +0 -7
- package/dist/commands/bug.js +0 -21
- package/dist/commands/bug.js.map +0 -7
- package/dist/commands/clear.js +0 -37
- package/dist/commands/clear.js.map +0 -7
- package/dist/commands/compact.js +0 -104
- package/dist/commands/compact.js.map +0 -7
- package/dist/commands/config.js +0 -20
- package/dist/commands/config.js.map +0 -7
- package/dist/commands/cost.js +0 -19
- package/dist/commands/cost.js.map +0 -7
- package/dist/commands/ctx_viz.js +0 -152
- package/dist/commands/ctx_viz.js.map +0 -7
- package/dist/commands/doctor.js +0 -25
- package/dist/commands/doctor.js.map +0 -7
- package/dist/commands/help.js +0 -20
- package/dist/commands/help.js.map +0 -7
- package/dist/commands/init.js +0 -38
- package/dist/commands/init.js.map +0 -7
- package/dist/commands/listen.js +0 -37
- package/dist/commands/listen.js.map +0 -7
- package/dist/commands/login.js +0 -37
- package/dist/commands/login.js.map +0 -7
- package/dist/commands/logout.js +0 -33
- package/dist/commands/logout.js.map +0 -7
- package/dist/commands/mcp.js +0 -34
- package/dist/commands/mcp.js.map +0 -7
- package/dist/commands/model.js +0 -41
- package/dist/commands/model.js.map +0 -7
- package/dist/commands/modelstatus.js +0 -21
- package/dist/commands/modelstatus.js.map +0 -7
- package/dist/commands/onboarding.js +0 -36
- package/dist/commands/onboarding.js.map +0 -7
- package/dist/commands/pr_comments.js +0 -61
- package/dist/commands/pr_comments.js.map +0 -7
- package/dist/commands/refreshCommands.js +0 -37
- package/dist/commands/refreshCommands.js.map +0 -7
- package/dist/commands/release-notes.js +0 -30
- package/dist/commands/release-notes.js.map +0 -7
- package/dist/commands/resume.js +0 -35
- package/dist/commands/resume.js.map +0 -7
- package/dist/commands/review.js +0 -51
- package/dist/commands/review.js.map +0 -7
- package/dist/commands/terminalSetup.js +0 -163
- package/dist/commands/terminalSetup.js.map +0 -7
- package/dist/commands.js +0 -84
- package/dist/commands.js.map +0 -7
- package/dist/components/ApproveApiKey.js +0 -74
- package/dist/components/ApproveApiKey.js.map +0 -7
- package/dist/components/AsciiLogo.js +0 -12
- package/dist/components/AsciiLogo.js.map +0 -7
- package/dist/components/AutoUpdater.js +0 -74
- package/dist/components/AutoUpdater.js.map +0 -7
- package/dist/components/Bug.js +0 -147
- package/dist/components/Bug.js.map +0 -7
- package/dist/components/Config.js +0 -166
- package/dist/components/Config.js.map +0 -7
- package/dist/components/ConsoleOAuthFlow.js +0 -188
- package/dist/components/ConsoleOAuthFlow.js.map +0 -7
- package/dist/components/Cost.js +0 -13
- package/dist/components/Cost.js.map +0 -7
- package/dist/components/CostThresholdDialog.js +0 -38
- package/dist/components/CostThresholdDialog.js.map +0 -7
- package/dist/components/CustomSelect/option-map.js +0 -32
- package/dist/components/CustomSelect/option-map.js.map +0 -7
- package/dist/components/CustomSelect/select-option.js +0 -34
- package/dist/components/CustomSelect/select-option.js.map +0 -7
- package/dist/components/CustomSelect/select.js +0 -64
- package/dist/components/CustomSelect/select.js.map +0 -7
- package/dist/components/CustomSelect/theme.js +0 -1
- package/dist/components/CustomSelect/use-select-state.js +0 -220
- package/dist/components/CustomSelect/use-select-state.js.map +0 -7
- package/dist/components/CustomSelect/use-select.js +0 -21
- package/dist/components/CustomSelect/use-select.js.map +0 -7
- package/dist/components/FallbackToolUseRejectedMessage.js +0 -11
- package/dist/components/FallbackToolUseRejectedMessage.js.map +0 -7
- package/dist/components/FileEditToolUpdatedMessage.js +0 -31
- package/dist/components/FileEditToolUpdatedMessage.js.map +0 -7
- package/dist/components/Help.js +0 -41
- package/dist/components/Help.js.map +0 -7
- package/dist/components/HighlightedCode.js +0 -30
- package/dist/components/HighlightedCode.js.map +0 -7
- package/dist/components/InvalidConfigDialog.js +0 -83
- package/dist/components/InvalidConfigDialog.js.map +0 -7
- package/dist/components/Link.js +0 -18
- package/dist/components/Link.js.map +0 -7
- package/dist/components/LogSelector.js +0 -50
- package/dist/components/LogSelector.js.map +0 -7
- package/dist/components/Logo.js +0 -94
- package/dist/components/Logo.js.map +0 -7
- package/dist/components/MCPServerApprovalDialog.js +0 -79
- package/dist/components/MCPServerApprovalDialog.js.map +0 -7
- package/dist/components/MCPServerDialogCopy.js +0 -11
- package/dist/components/MCPServerDialogCopy.js.map +0 -7
- package/dist/components/MCPServerMultiselectDialog.js +0 -80
- package/dist/components/MCPServerMultiselectDialog.js.map +0 -7
- package/dist/components/Message.js +0 -146
- package/dist/components/Message.js.map +0 -7
- package/dist/components/MessageResponse.js +0 -9
- package/dist/components/MessageResponse.js.map +0 -7
- package/dist/components/MessageSelector.js +0 -133
- package/dist/components/MessageSelector.js.map +0 -7
- package/dist/components/ModeIndicator.js +0 -38
- package/dist/components/ModeIndicator.js.map +0 -7
- package/dist/components/ModelConfig.js +0 -208
- package/dist/components/ModelConfig.js.map +0 -7
- package/dist/components/ModelListManager.js +0 -140
- package/dist/components/ModelListManager.js.map +0 -7
- package/dist/components/ModelSelector.js +0 -1985
- package/dist/components/ModelSelector.js.map +0 -7
- package/dist/components/ModelStatusDisplay.js +0 -87
- package/dist/components/ModelStatusDisplay.js.map +0 -7
- package/dist/components/Onboarding.js +0 -153
- package/dist/components/Onboarding.js.map +0 -7
- package/dist/components/PressEnterToContinue.js +0 -10
- package/dist/components/PressEnterToContinue.js.map +0 -7
- package/dist/components/PromptInput.js +0 -501
- package/dist/components/PromptInput.js.map +0 -7
- package/dist/components/SentryErrorBoundary.js +0 -27
- package/dist/components/SentryErrorBoundary.js.map +0 -7
- package/dist/components/Spinner.js +0 -101
- package/dist/components/Spinner.js.map +0 -7
- package/dist/components/StickerRequestForm.js +0 -7
- package/dist/components/StickerRequestForm.js.map +0 -7
- package/dist/components/StructuredDiff.js +0 -148
- package/dist/components/StructuredDiff.js.map +0 -7
- package/dist/components/TextInput.js +0 -100
- package/dist/components/TextInput.js.map +0 -7
- package/dist/components/TodoItem.js +0 -35
- package/dist/components/TodoItem.js.map +0 -7
- package/dist/components/TokenWarning.js +0 -19
- package/dist/components/TokenWarning.js.map +0 -7
- package/dist/components/ToolUseLoader.js +0 -24
- package/dist/components/ToolUseLoader.js.map +0 -7
- package/dist/components/TrustDialog.js +0 -76
- package/dist/components/TrustDialog.js.map +0 -7
- package/dist/components/binary-feedback/BinaryFeedback.js +0 -50
- package/dist/components/binary-feedback/BinaryFeedback.js.map +0 -7
- package/dist/components/binary-feedback/BinaryFeedbackOption.js +0 -94
- package/dist/components/binary-feedback/BinaryFeedbackOption.js.map +0 -7
- package/dist/components/binary-feedback/BinaryFeedbackView.js +0 -139
- package/dist/components/binary-feedback/BinaryFeedbackView.js.map +0 -7
- package/dist/components/binary-feedback/utils.js +0 -161
- package/dist/components/binary-feedback/utils.js.map +0 -7
- package/dist/components/messages/AssistantBashOutputMessage.js +0 -23
- package/dist/components/messages/AssistantBashOutputMessage.js.map +0 -7
- package/dist/components/messages/AssistantLocalCommandOutputMessage.js +0 -36
- package/dist/components/messages/AssistantLocalCommandOutputMessage.js.map +0 -7
- package/dist/components/messages/AssistantRedactedThinkingMessage.js +0 -12
- package/dist/components/messages/AssistantRedactedThinkingMessage.js.map +0 -7
- package/dist/components/messages/AssistantTextMessage.js +0 -78
- package/dist/components/messages/AssistantTextMessage.js.map +0 -7
- package/dist/components/messages/AssistantThinkingMessage.js +0 -27
- package/dist/components/messages/AssistantThinkingMessage.js.map +0 -7
- package/dist/components/messages/AssistantToolUseMessage.js +0 -91
- package/dist/components/messages/AssistantToolUseMessage.js.map +0 -7
- package/dist/components/messages/TaskProgressMessage.js +0 -11
- package/dist/components/messages/TaskProgressMessage.js.map +0 -7
- package/dist/components/messages/TaskToolMessage.js +0 -39
- package/dist/components/messages/TaskToolMessage.js.map +0 -7
- package/dist/components/messages/UserBashInputMessage.js +0 -18
- package/dist/components/messages/UserBashInputMessage.js.map +0 -7
- package/dist/components/messages/UserCommandMessage.js +0 -20
- package/dist/components/messages/UserCommandMessage.js.map +0 -7
- package/dist/components/messages/UserKodingInputMessage.js +0 -18
- package/dist/components/messages/UserKodingInputMessage.js.map +0 -7
- package/dist/components/messages/UserPromptMessage.js +0 -20
- package/dist/components/messages/UserPromptMessage.js.map +0 -7
- package/dist/components/messages/UserTextMessage.js +0 -25
- package/dist/components/messages/UserTextMessage.js.map +0 -7
- package/dist/components/messages/UserToolResultMessage/UserToolCanceledMessage.js +0 -10
- package/dist/components/messages/UserToolResultMessage/UserToolCanceledMessage.js.map +0 -7
- package/dist/components/messages/UserToolResultMessage/UserToolErrorMessage.js +0 -15
- package/dist/components/messages/UserToolResultMessage/UserToolErrorMessage.js.map +0 -7
- package/dist/components/messages/UserToolResultMessage/UserToolRejectMessage.js +0 -25
- package/dist/components/messages/UserToolResultMessage/UserToolRejectMessage.js.map +0 -7
- package/dist/components/messages/UserToolResultMessage/UserToolResultMessage.js +0 -47
- package/dist/components/messages/UserToolResultMessage/UserToolResultMessage.js.map +0 -7
- package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js +0 -23
- package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js.map +0 -7
- package/dist/components/messages/UserToolResultMessage/utils.js +0 -42
- package/dist/components/messages/UserToolResultMessage/utils.js.map +0 -7
- package/dist/components/permissions/BashPermissionRequest/BashPermissionRequest.js +0 -112
- package/dist/components/permissions/BashPermissionRequest/BashPermissionRequest.js.map +0 -7
- package/dist/components/permissions/FallbackPermissionRequest.js +0 -131
- package/dist/components/permissions/FallbackPermissionRequest.js.map +0 -7
- package/dist/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +0 -159
- package/dist/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js.map +0 -7
- package/dist/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js +0 -58
- package/dist/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js.map +0 -7
- package/dist/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +0 -153
- package/dist/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js.map +0 -7
- package/dist/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js +0 -70
- package/dist/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js.map +0 -7
- package/dist/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +0 -212
- package/dist/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js.map +0 -7
- package/dist/components/permissions/PermissionRequest.js +0 -70
- package/dist/components/permissions/PermissionRequest.js.map +0 -7
- package/dist/components/permissions/PermissionRequestTitle.js +0 -52
- package/dist/components/permissions/PermissionRequestTitle.js.map +0 -7
- package/dist/components/permissions/hooks.js +0 -28
- package/dist/components/permissions/hooks.js.map +0 -7
- package/dist/components/permissions/toolUseOptions.js +0 -46
- package/dist/components/permissions/toolUseOptions.js.map +0 -7
- package/dist/components/permissions/utils.js +0 -21
- package/dist/components/permissions/utils.js.map +0 -7
- package/dist/constants/betas.js +0 -11
- package/dist/constants/betas.js.map +0 -7
- package/dist/constants/claude-asterisk-ascii-art.js +0 -242
- package/dist/constants/claude-asterisk-ascii-art.js.map +0 -7
- package/dist/constants/figures.js +0 -6
- package/dist/constants/figures.js.map +0 -7
- package/dist/constants/keys.js +0 -7
- package/dist/constants/keys.js.map +0 -7
- package/dist/constants/macros.js +0 -13
- package/dist/constants/macros.js.map +0 -7
- package/dist/constants/modelCapabilities.js +0 -154
- package/dist/constants/modelCapabilities.js.map +0 -7
- package/dist/constants/models.js +0 -1029
- package/dist/constants/models.js.map +0 -7
- package/dist/constants/oauth.js +0 -18
- package/dist/constants/oauth.js.map +0 -7
- package/dist/constants/product.js +0 -26
- package/dist/constants/product.js.map +0 -7
- package/dist/constants/prompts.js +0 -168
- package/dist/constants/prompts.js.map +0 -7
- package/dist/constants/releaseNotes.js +0 -9
- package/dist/constants/releaseNotes.js.map +0 -7
- package/dist/context/PermissionContext.js +0 -111
- package/dist/context/PermissionContext.js.map +0 -7
- package/dist/context.js +0 -259
- package/dist/context.js.map +0 -7
- package/dist/cost-tracker.js.map +0 -7
- package/dist/entrypoints/cli.js +0 -1122
- package/dist/entrypoints/cli.js.map +0 -7
- package/dist/entrypoints/mcp.js +0 -150
- package/dist/entrypoints/mcp.js.map +0 -7
- package/dist/history.js +0 -25
- package/dist/history.js.map +0 -7
- package/dist/hooks/useApiKeyVerification.js +0 -12
- package/dist/hooks/useApiKeyVerification.js.map +0 -7
- package/dist/hooks/useArrowKeyHistory.js +0 -50
- package/dist/hooks/useArrowKeyHistory.js.map +0 -7
- package/dist/hooks/useCanUseTool.js +0 -112
- package/dist/hooks/useCanUseTool.js.map +0 -7
- package/dist/hooks/useCancelRequest.js +0 -30
- package/dist/hooks/useCancelRequest.js.map +0 -7
- package/dist/hooks/useDoublePress.js +0 -31
- package/dist/hooks/useDoublePress.js.map +0 -7
- package/dist/hooks/useExitOnCtrlCD.js +0 -26
- package/dist/hooks/useExitOnCtrlCD.js.map +0 -7
- package/dist/hooks/useInterval.js +0 -18
- package/dist/hooks/useInterval.js.map +0 -7
- package/dist/hooks/useLogMessages.js +0 -14
- package/dist/hooks/useLogMessages.js.map +0 -7
- package/dist/hooks/useLogStartupTime.js +0 -15
- package/dist/hooks/useLogStartupTime.js.map +0 -7
- package/dist/hooks/useNotifyAfterTimeout.js +0 -42
- package/dist/hooks/useNotifyAfterTimeout.js.map +0 -7
- package/dist/hooks/usePermissionRequestLogging.js +0 -28
- package/dist/hooks/usePermissionRequestLogging.js.map +0 -7
- package/dist/hooks/useTerminalSize.js +0 -38
- package/dist/hooks/useTerminalSize.js.map +0 -7
- package/dist/hooks/useTextInput.js +0 -250
- package/dist/hooks/useTextInput.js.map +0 -7
- package/dist/hooks/useUnifiedCompletion.js +0 -929
- package/dist/hooks/useUnifiedCompletion.js.map +0 -7
- package/dist/messages.js +0 -33
- package/dist/messages.js.map +0 -7
- package/dist/permissions.js +0 -194
- package/dist/permissions.js.map +0 -7
- package/dist/query.js +0 -492
- package/dist/query.js.map +0 -7
- package/dist/screens/ConfigureNpmPrefix.js +0 -128
- package/dist/screens/ConfigureNpmPrefix.js.map +0 -7
- package/dist/screens/Doctor.js +0 -143
- package/dist/screens/Doctor.js.map +0 -7
- package/dist/screens/LogList.js +0 -55
- package/dist/screens/LogList.js.map +0 -7
- package/dist/screens/REPL.js +0 -596
- package/dist/screens/REPL.js.map +0 -7
- package/dist/screens/ResumeConversation.js +0 -56
- package/dist/screens/ResumeConversation.js.map +0 -7
- package/dist/services/adapters/base.js +0 -29
- package/dist/services/adapters/base.js.map +0 -7
- package/dist/services/adapters/chatCompletions.js +0 -69
- package/dist/services/adapters/chatCompletions.js.map +0 -7
- package/dist/services/adapters/responsesAPI.js +0 -126
- package/dist/services/adapters/responsesAPI.js.map +0 -7
- package/dist/services/browserMocks.js +0 -48
- package/dist/services/browserMocks.js.map +0 -7
- package/dist/services/claude.js +0 -1605
- package/dist/services/claude.js.map +0 -7
- package/dist/services/customCommands.js +0 -359
- package/dist/services/customCommands.js.map +0 -7
- package/dist/services/fileFreshness.js +0 -280
- package/dist/services/fileFreshness.js.map +0 -7
- package/dist/services/gpt5ConnectionTest.js +0 -248
- package/dist/services/gpt5ConnectionTest.js.map +0 -7
- package/dist/services/mcpClient.js +0 -435
- package/dist/services/mcpClient.js.map +0 -7
- package/dist/services/mcpServerApproval.js +0 -55
- package/dist/services/mcpServerApproval.js.map +0 -7
- package/dist/services/mentionProcessor.js.map +0 -7
- package/dist/services/modelAdapterFactory.js +0 -47
- package/dist/services/modelAdapterFactory.js.map +0 -7
- package/dist/services/notifier.js +0 -35
- package/dist/services/notifier.js.map +0 -7
- package/dist/services/oauth.js +0 -259
- package/dist/services/oauth.js.map +0 -7
- package/dist/services/openai.js.map +0 -7
- package/dist/services/responseStateManager.js +0 -68
- package/dist/services/responseStateManager.js.map +0 -7
- package/dist/services/sentry.js +0 -9
- package/dist/services/sentry.js.map +0 -7
- package/dist/services/statsig.js +0 -112
- package/dist/services/statsig.js.map +0 -7
- package/dist/services/statsigStorage.js +0 -75
- package/dist/services/statsigStorage.js.map +0 -7
- package/dist/services/systemReminder.js.map +0 -7
- package/dist/services/vcr.js +0 -133
- package/dist/services/vcr.js.map +0 -7
- package/dist/tools/ArchitectTool/ArchitectTool.js +0 -119
- package/dist/tools/ArchitectTool/ArchitectTool.js.map +0 -7
- package/dist/tools/ArchitectTool/prompt.js +0 -18
- package/dist/tools/ArchitectTool/prompt.js.map +0 -7
- package/dist/tools/AskExpertModelTool/AskExpertModelTool.js +0 -423
- package/dist/tools/AskExpertModelTool/AskExpertModelTool.js.map +0 -7
- package/dist/tools/BashTool/BashTool.js +0 -188
- package/dist/tools/BashTool/BashTool.js.map +0 -7
- package/dist/tools/BashTool/BashToolResultMessage.js +0 -21
- package/dist/tools/BashTool/BashToolResultMessage.js.map +0 -7
- package/dist/tools/BashTool/OutputLine.js +0 -30
- package/dist/tools/BashTool/OutputLine.js.map +0 -7
- package/dist/tools/BashTool/prompt.js +0 -179
- package/dist/tools/BashTool/prompt.js.map +0 -7
- package/dist/tools/BashTool/utils.js +0 -51
- package/dist/tools/BashTool/utils.js.map +0 -7
- package/dist/tools/FileEditTool/FileEditTool.js +0 -228
- package/dist/tools/FileEditTool/FileEditTool.js.map +0 -7
- package/dist/tools/FileEditTool/prompt.js +0 -54
- package/dist/tools/FileEditTool/prompt.js.map +0 -7
- package/dist/tools/FileEditTool/utils.js +0 -42
- package/dist/tools/FileEditTool/utils.js.map +0 -7
- package/dist/tools/FileReadTool/FileReadTool.js +0 -272
- package/dist/tools/FileReadTool/FileReadTool.js.map +0 -7
- package/dist/tools/FileReadTool/prompt.js +0 -10
- package/dist/tools/FileReadTool/prompt.js.map +0 -7
- package/dist/tools/FileWriteTool/FileWriteTool.js +0 -204
- package/dist/tools/FileWriteTool/FileWriteTool.js.map +0 -7
- package/dist/tools/FileWriteTool/prompt.js +0 -14
- package/dist/tools/FileWriteTool/prompt.js.map +0 -7
- package/dist/tools/GlobTool/GlobTool.js +0 -88
- package/dist/tools/GlobTool/GlobTool.js.map +0 -7
- package/dist/tools/GlobTool/prompt.js +0 -12
- package/dist/tools/GlobTool/prompt.js.map +0 -7
- package/dist/tools/GrepTool/GrepTool.js +0 -107
- package/dist/tools/GrepTool/GrepTool.js.map +0 -7
- package/dist/tools/GrepTool/prompt.js +0 -15
- package/dist/tools/GrepTool/prompt.js.map +0 -7
- package/dist/tools/MCPTool/MCPTool.js +0 -90
- package/dist/tools/MCPTool/MCPTool.js.map +0 -7
- package/dist/tools/MCPTool/prompt.js +0 -7
- package/dist/tools/MCPTool/prompt.js.map +0 -7
- package/dist/tools/MemoryReadTool/MemoryReadTool.js +0 -103
- package/dist/tools/MemoryReadTool/MemoryReadTool.js.map +0 -7
- package/dist/tools/MemoryReadTool/prompt.js +0 -7
- package/dist/tools/MemoryReadTool/prompt.js.map +0 -7
- package/dist/tools/MemoryWriteTool/MemoryWriteTool.js +0 -77
- package/dist/tools/MemoryWriteTool/MemoryWriteTool.js.map +0 -7
- package/dist/tools/MemoryWriteTool/prompt.js +0 -7
- package/dist/tools/MemoryWriteTool/prompt.js.map +0 -7
- package/dist/tools/MultiEditTool/MultiEditTool.js +0 -293
- package/dist/tools/MultiEditTool/MultiEditTool.js.map +0 -7
- package/dist/tools/MultiEditTool/prompt.js +0 -48
- package/dist/tools/MultiEditTool/prompt.js.map +0 -7
- package/dist/tools/NotebookEditTool/NotebookEditTool.js +0 -238
- package/dist/tools/NotebookEditTool/NotebookEditTool.js.map +0 -7
- package/dist/tools/NotebookEditTool/prompt.js +0 -7
- package/dist/tools/NotebookEditTool/prompt.js.map +0 -7
- package/dist/tools/NotebookReadTool/NotebookReadTool.js +0 -212
- package/dist/tools/NotebookReadTool/NotebookReadTool.js.map +0 -7
- package/dist/tools/NotebookReadTool/prompt.js +0 -7
- package/dist/tools/NotebookReadTool/prompt.js.map +0 -7
- package/dist/tools/StickerRequestTool/StickerRequestTool.js +0 -86
- package/dist/tools/StickerRequestTool/StickerRequestTool.js.map +0 -7
- package/dist/tools/StickerRequestTool/prompt.js +0 -23
- package/dist/tools/StickerRequestTool/prompt.js.map +0 -7
- package/dist/tools/TaskTool/TaskTool.js +0 -351
- package/dist/tools/TaskTool/TaskTool.js.map +0 -7
- package/dist/tools/TaskTool/constants.js +0 -5
- package/dist/tools/TaskTool/constants.js.map +0 -7
- package/dist/tools/TaskTool/prompt.js +0 -82
- package/dist/tools/TaskTool/prompt.js.map +0 -7
- package/dist/tools/ThinkTool/ThinkTool.js +0 -48
- package/dist/tools/ThinkTool/ThinkTool.js.map +0 -7
- package/dist/tools/ThinkTool/prompt.js +0 -16
- package/dist/tools/ThinkTool/prompt.js.map +0 -7
- package/dist/tools/TodoWriteTool/TodoWriteTool.js +0 -216
- package/dist/tools/TodoWriteTool/TodoWriteTool.js.map +0 -7
- package/dist/tools/TodoWriteTool/prompt.js +0 -66
- package/dist/tools/TodoWriteTool/prompt.js.map +0 -7
- package/dist/tools/URLFetcherTool/URLFetcherTool.js +0 -137
- package/dist/tools/URLFetcherTool/URLFetcherTool.js.map +0 -7
- package/dist/tools/URLFetcherTool/cache.js +0 -45
- package/dist/tools/URLFetcherTool/cache.js.map +0 -7
- package/dist/tools/URLFetcherTool/htmlToMarkdown.js +0 -42
- package/dist/tools/URLFetcherTool/htmlToMarkdown.js.map +0 -7
- package/dist/tools/URLFetcherTool/prompt.js +0 -22
- package/dist/tools/URLFetcherTool/prompt.js.map +0 -7
- package/dist/tools/WebSearchTool/WebSearchTool.js +0 -86
- package/dist/tools/WebSearchTool/WebSearchTool.js.map +0 -7
- package/dist/tools/WebSearchTool/prompt.js +0 -17
- package/dist/tools/WebSearchTool/prompt.js.map +0 -7
- package/dist/tools/WebSearchTool/searchProviders.js +0 -48
- package/dist/tools/WebSearchTool/searchProviders.js.map +0 -7
- package/dist/tools/lsTool/lsTool.js +0 -201
- package/dist/tools/lsTool/lsTool.js.map +0 -7
- package/dist/tools/lsTool/prompt.js +0 -5
- package/dist/tools/lsTool/prompt.js.map +0 -7
- package/dist/tools.js +0 -64
- package/dist/tools.js.map +0 -7
- package/dist/types/PermissionMode.js +0 -82
- package/dist/types/PermissionMode.js.map +0 -7
- package/dist/types/RequestContext.js +0 -47
- package/dist/types/RequestContext.js.map +0 -7
- package/dist/types/common.d.js +0 -1
- package/dist/types/conversation.js +0 -1
- package/dist/types/logs.js +0 -1
- package/dist/types/modelCapabilities.js +0 -1
- package/dist/types/notebook.js +0 -1
- package/dist/utils/Cursor.js +0 -313
- package/dist/utils/Cursor.js.map +0 -7
- package/dist/utils/PersistentShell.js +0 -382
- package/dist/utils/PersistentShell.js.map +0 -7
- package/dist/utils/advancedFuzzyMatcher.js +0 -206
- package/dist/utils/advancedFuzzyMatcher.js.map +0 -7
- package/dist/utils/agentLoader.js +0 -199
- package/dist/utils/agentLoader.js.map +0 -7
- package/dist/utils/agentStorage.js +0 -59
- package/dist/utils/agentStorage.js.map +0 -7
- package/dist/utils/array.js +0 -7
- package/dist/utils/array.js.map +0 -7
- package/dist/utils/ask.js +0 -77
- package/dist/utils/ask.js.map +0 -7
- package/dist/utils/auth.js +0 -11
- package/dist/utils/auth.js.map +0 -7
- package/dist/utils/autoCompactCore.js +0 -149
- package/dist/utils/autoCompactCore.js.map +0 -7
- package/dist/utils/autoUpdater.js +0 -360
- package/dist/utils/autoUpdater.js.map +0 -7
- package/dist/utils/betas.js +0 -21
- package/dist/utils/betas.js.map +0 -7
- package/dist/utils/browser.js +0 -15
- package/dist/utils/browser.js.map +0 -7
- package/dist/utils/cleanup.js +0 -54
- package/dist/utils/cleanup.js.map +0 -7
- package/dist/utils/commands.js +0 -207
- package/dist/utils/commands.js.map +0 -7
- package/dist/utils/commonUnixCommands.js +0 -687
- package/dist/utils/commonUnixCommands.js.map +0 -7
- package/dist/utils/config.js.map +0 -7
- package/dist/utils/conversationRecovery.js +0 -35
- package/dist/utils/conversationRecovery.js.map +0 -7
- package/dist/utils/debugLogger.js.map +0 -7
- package/dist/utils/diff.js +0 -32
- package/dist/utils/diff.js.map +0 -7
- package/dist/utils/env.js +0 -44
- package/dist/utils/env.js.map +0 -7
- package/dist/utils/errors.js +0 -23
- package/dist/utils/errors.js.map +0 -7
- package/dist/utils/exampleCommands.js +0 -80
- package/dist/utils/exampleCommands.js.map +0 -7
- package/dist/utils/execFileNoThrow.js +0 -44
- package/dist/utils/execFileNoThrow.js.map +0 -7
- package/dist/utils/expertChatStorage.js +0 -78
- package/dist/utils/expertChatStorage.js.map +0 -7
- package/dist/utils/file.js +0 -282
- package/dist/utils/file.js.map +0 -7
- package/dist/utils/fileRecoveryCore.js +0 -41
- package/dist/utils/fileRecoveryCore.js.map +0 -7
- package/dist/utils/format.js +0 -41
- package/dist/utils/format.js.map +0 -7
- package/dist/utils/fuzzyMatcher.js +0 -252
- package/dist/utils/fuzzyMatcher.js.map +0 -7
- package/dist/utils/generators.js +0 -46
- package/dist/utils/generators.js.map +0 -7
- package/dist/utils/git.js +0 -83
- package/dist/utils/git.js.map +0 -7
- package/dist/utils/globalLogger.js +0 -54
- package/dist/utils/globalLogger.js.map +0 -7
- package/dist/utils/http.js +0 -7
- package/dist/utils/http.js.map +0 -7
- package/dist/utils/imagePaste.js +0 -29
- package/dist/utils/imagePaste.js.map +0 -7
- package/dist/utils/json.js +0 -16
- package/dist/utils/json.js.map +0 -7
- package/dist/utils/log.js +0 -298
- package/dist/utils/log.js.map +0 -7
- package/dist/utils/markdown.js +0 -187
- package/dist/utils/markdown.js.map +0 -7
- package/dist/utils/messageContextManager.js +0 -195
- package/dist/utils/messageContextManager.js.map +0 -7
- package/dist/utils/messages.js +0 -633
- package/dist/utils/messages.js.map +0 -7
- package/dist/utils/model.js.map +0 -7
- package/dist/utils/permissions/filesystem.js +0 -80
- package/dist/utils/permissions/filesystem.js.map +0 -7
- package/dist/utils/responseState.js +0 -20
- package/dist/utils/responseState.js.map +0 -7
- package/dist/utils/ripgrep.js +0 -131
- package/dist/utils/ripgrep.js.map +0 -7
- package/dist/utils/secureFile.js +0 -483
- package/dist/utils/secureFile.js.map +0 -7
- package/dist/utils/sessionState.js +0 -31
- package/dist/utils/sessionState.js.map +0 -7
- package/dist/utils/state.js +0 -24
- package/dist/utils/state.js.map +0 -7
- package/dist/utils/style.js +0 -31
- package/dist/utils/style.js.map +0 -7
- package/dist/utils/terminal.js +0 -43
- package/dist/utils/terminal.js.map +0 -7
- package/dist/utils/theme.js.map +0 -7
- package/dist/utils/thinking.js +0 -103
- package/dist/utils/thinking.js.map +0 -7
- package/dist/utils/todoStorage.js +0 -291
- package/dist/utils/todoStorage.js.map +0 -7
- package/dist/utils/tokens.js +0 -30
- package/dist/utils/tokens.js.map +0 -7
- package/dist/utils/toolExecutionController.js +0 -109
- package/dist/utils/toolExecutionController.js.map +0 -7
- package/dist/utils/unaryLogging.js +0 -14
- package/dist/utils/unaryLogging.js.map +0 -7
- package/dist/utils/user.js +0 -40
- package/dist/utils/user.js.map +0 -7
- package/dist/utils/validate.js +0 -132
- package/dist/utils/validate.js.map +0 -7
- /package/dist/{Tool.js.map → REPL-CW7AYLVL.js.map} +0 -0
- /package/dist/{components/CustomSelect/theme.js.map → autoUpdater-ITPIHCOI.js.map} +0 -0
- /package/dist/{types/common.d.js.map → chunk-JC6NCUG5.js.map} +0 -0
- /package/dist/{types/conversation.js.map → commands-2BF2CJ3A.js.map} +0 -0
- /package/dist/{types/logs.js.map → config-RUSD6G5Y.js.map} +0 -0
- /package/dist/{types/modelCapabilities.js.map → context-6FXPETYH.js.map} +0 -0
- /package/dist/{types/notebook.js.map → costTracker-6SL26FDB.js.map} +0 -0
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
+
const require = __kodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CONFIG_BASE_DIR,
|
|
5
|
+
getCwd,
|
|
6
|
+
getKodeBaseDir
|
|
7
|
+
} from "./chunk-YXYYDIMI.js";
|
|
8
|
+
|
|
9
|
+
// src/services/plugins/skillMarketplace.ts
|
|
10
|
+
import {
|
|
11
|
+
copyFileSync,
|
|
12
|
+
existsSync,
|
|
13
|
+
lstatSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
readFileSync,
|
|
16
|
+
readdirSync,
|
|
17
|
+
renameSync,
|
|
18
|
+
rmSync,
|
|
19
|
+
writeFileSync
|
|
20
|
+
} from "node:fs";
|
|
21
|
+
import { randomUUID } from "node:crypto";
|
|
22
|
+
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
23
|
+
import { unzipSync } from "fflate";
|
|
24
|
+
import { z } from "zod";
|
|
25
|
+
var KNOWN_MARKETPLACES_FILE = "known_marketplaces.json";
|
|
26
|
+
var MARKETPLACES_CACHE_DIR = "marketplaces";
|
|
27
|
+
var INSTALLED_SKILL_PLUGINS_FILE = "installed-skill-plugins.json";
|
|
28
|
+
var MarketplaceSourceSchema = z.discriminatedUnion("source", [
|
|
29
|
+
z.strictObject({
|
|
30
|
+
source: z.literal("github"),
|
|
31
|
+
repo: z.string().min(3),
|
|
32
|
+
ref: z.string().optional(),
|
|
33
|
+
path: z.string().optional()
|
|
34
|
+
}),
|
|
35
|
+
z.strictObject({
|
|
36
|
+
source: z.literal("git"),
|
|
37
|
+
url: z.string().min(3),
|
|
38
|
+
ref: z.string().optional(),
|
|
39
|
+
path: z.string().optional()
|
|
40
|
+
}),
|
|
41
|
+
z.strictObject({
|
|
42
|
+
source: z.literal("url"),
|
|
43
|
+
url: z.string().url(),
|
|
44
|
+
headers: z.record(z.string(), z.string()).optional()
|
|
45
|
+
}),
|
|
46
|
+
z.strictObject({
|
|
47
|
+
source: z.literal("npm"),
|
|
48
|
+
package: z.string().min(1)
|
|
49
|
+
}),
|
|
50
|
+
z.strictObject({
|
|
51
|
+
source: z.literal("file"),
|
|
52
|
+
path: z.string().min(1)
|
|
53
|
+
}),
|
|
54
|
+
z.strictObject({
|
|
55
|
+
source: z.literal("directory"),
|
|
56
|
+
path: z.string().min(1)
|
|
57
|
+
})
|
|
58
|
+
]);
|
|
59
|
+
var MarketplacePathListSchema = z.preprocess((value) => {
|
|
60
|
+
if (typeof value === "string") return [value];
|
|
61
|
+
return value;
|
|
62
|
+
}, z.array(z.string()));
|
|
63
|
+
var MarketplacePluginSchema = z.object({
|
|
64
|
+
name: z.string().min(1),
|
|
65
|
+
description: z.string().optional(),
|
|
66
|
+
source: z.string().optional().default("./"),
|
|
67
|
+
strict: z.boolean().optional(),
|
|
68
|
+
skills: MarketplacePathListSchema.optional(),
|
|
69
|
+
commands: MarketplacePathListSchema.optional()
|
|
70
|
+
}).passthrough();
|
|
71
|
+
var MarketplaceManifestSchema = z.object({
|
|
72
|
+
$schema: z.string().optional(),
|
|
73
|
+
description: z.string().optional(),
|
|
74
|
+
name: z.string().min(1),
|
|
75
|
+
owner: z.object({
|
|
76
|
+
name: z.string().optional(),
|
|
77
|
+
email: z.string().optional()
|
|
78
|
+
}).passthrough().optional(),
|
|
79
|
+
metadata: z.record(z.string(), z.unknown()).optional().default({}),
|
|
80
|
+
plugins: z.array(MarketplacePluginSchema).default([])
|
|
81
|
+
}).passthrough();
|
|
82
|
+
var KnownMarketplacesSchema = z.record(
|
|
83
|
+
z.string(),
|
|
84
|
+
z.strictObject({
|
|
85
|
+
source: MarketplaceSourceSchema,
|
|
86
|
+
installLocation: z.string().min(1),
|
|
87
|
+
lastUpdated: z.string().min(1),
|
|
88
|
+
autoUpdate: z.boolean().optional()
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
function userKodeDir() {
|
|
92
|
+
return getKodeBaseDir();
|
|
93
|
+
}
|
|
94
|
+
function normalizePluginScope(options) {
|
|
95
|
+
if (options?.scope === "user" || options?.scope === "project" || options?.scope === "local") {
|
|
96
|
+
return options.scope;
|
|
97
|
+
}
|
|
98
|
+
if (options?.project === true) return "project";
|
|
99
|
+
return "user";
|
|
100
|
+
}
|
|
101
|
+
function scopeBaseDir(scope) {
|
|
102
|
+
if (scope === "user") return userKodeDir();
|
|
103
|
+
return join(getCwd(), CONFIG_BASE_DIR);
|
|
104
|
+
}
|
|
105
|
+
function scopeSkillsDir(scope) {
|
|
106
|
+
return join(scopeBaseDir(scope), "skills");
|
|
107
|
+
}
|
|
108
|
+
function scopeCommandsDir(scope) {
|
|
109
|
+
return join(scopeBaseDir(scope), "commands");
|
|
110
|
+
}
|
|
111
|
+
function scopeInstalledPluginsDir(scope) {
|
|
112
|
+
return join(scopeBaseDir(scope), "plugins", "installed");
|
|
113
|
+
}
|
|
114
|
+
function scopeInstalledPluginRoot(scope, plugin, marketplace) {
|
|
115
|
+
return join(scopeInstalledPluginsDir(scope), plugin, marketplace);
|
|
116
|
+
}
|
|
117
|
+
function pluginsDir() {
|
|
118
|
+
return join(userKodeDir(), "plugins");
|
|
119
|
+
}
|
|
120
|
+
function knownMarketplacesConfigPath() {
|
|
121
|
+
return join(pluginsDir(), KNOWN_MARKETPLACES_FILE);
|
|
122
|
+
}
|
|
123
|
+
function marketplaceCacheBaseDir() {
|
|
124
|
+
return join(pluginsDir(), MARKETPLACES_CACHE_DIR);
|
|
125
|
+
}
|
|
126
|
+
function installedSkillPluginsPath() {
|
|
127
|
+
return join(userKodeDir(), INSTALLED_SKILL_PLUGINS_FILE);
|
|
128
|
+
}
|
|
129
|
+
function ensureDir(path) {
|
|
130
|
+
mkdirSync(path, { recursive: true });
|
|
131
|
+
}
|
|
132
|
+
function readJsonFile(path, fallback) {
|
|
133
|
+
try {
|
|
134
|
+
if (!existsSync(path)) return fallback;
|
|
135
|
+
const raw = readFileSync(path, "utf8");
|
|
136
|
+
return JSON.parse(raw);
|
|
137
|
+
} catch {
|
|
138
|
+
return fallback;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function writeJsonFile(path, value) {
|
|
142
|
+
ensureDir(dirname(path));
|
|
143
|
+
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
144
|
+
`, "utf8");
|
|
145
|
+
}
|
|
146
|
+
function normalizeMarketplaceSubPath(path) {
|
|
147
|
+
if (!path) return null;
|
|
148
|
+
const trimmed = path.trim().replace(/^\.?\//, "").replace(/^\/+/, "");
|
|
149
|
+
if (!trimmed) return null;
|
|
150
|
+
if (trimmed.includes("..")) {
|
|
151
|
+
throw new Error(`Marketplace path contains '..': ${path}`);
|
|
152
|
+
}
|
|
153
|
+
return trimmed.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
154
|
+
}
|
|
155
|
+
function safeJoinWithin(baseDir, relativePath) {
|
|
156
|
+
const normalized = relativePath.replace(/\\/g, "/");
|
|
157
|
+
if (!normalized || normalized.startsWith("/") || normalized.includes("..")) {
|
|
158
|
+
throw new Error(`Unsafe path in archive: ${relativePath}`);
|
|
159
|
+
}
|
|
160
|
+
const joined = resolve(baseDir, normalized.split("/").join(sep));
|
|
161
|
+
const resolvedBase = resolve(baseDir);
|
|
162
|
+
if (!joined.startsWith(resolvedBase + sep) && joined !== resolvedBase) {
|
|
163
|
+
throw new Error(`Path traversal detected: ${relativePath}`);
|
|
164
|
+
}
|
|
165
|
+
return joined;
|
|
166
|
+
}
|
|
167
|
+
function ensureEmptyDir(path) {
|
|
168
|
+
if (existsSync(path)) rmSync(path, { recursive: true, force: true });
|
|
169
|
+
ensureDir(path);
|
|
170
|
+
}
|
|
171
|
+
function safeCopyDirectory(srcDir, destDir) {
|
|
172
|
+
ensureDir(destDir);
|
|
173
|
+
const entries = readdirSync(srcDir, { withFileTypes: true });
|
|
174
|
+
for (const entry of entries) {
|
|
175
|
+
const srcPath = join(srcDir, entry.name);
|
|
176
|
+
const destPath = join(destDir, entry.name);
|
|
177
|
+
if (entry.isDirectory()) {
|
|
178
|
+
safeCopyDirectory(srcPath, destPath);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (entry.isFile()) {
|
|
182
|
+
ensureDir(dirname(destPath));
|
|
183
|
+
copyFileSync(srcPath, destPath);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function readMarketplaceFromDirectory(rootDir) {
|
|
189
|
+
const primaryMarketplaceFile = resolve(
|
|
190
|
+
rootDir,
|
|
191
|
+
".kode-plugin",
|
|
192
|
+
"marketplace.json"
|
|
193
|
+
);
|
|
194
|
+
const legacyMarketplaceFile = resolve(
|
|
195
|
+
rootDir,
|
|
196
|
+
".claude-plugin",
|
|
197
|
+
"marketplace.json"
|
|
198
|
+
);
|
|
199
|
+
const marketplaceFile = existsSync(primaryMarketplaceFile) ? primaryMarketplaceFile : legacyMarketplaceFile;
|
|
200
|
+
if (!existsSync(marketplaceFile)) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`Marketplace file not found (expected .kode-plugin/marketplace.json or .claude-plugin/marketplace.json)`
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const raw = readFileSync(marketplaceFile, "utf8");
|
|
206
|
+
const parsed = MarketplaceManifestSchema.safeParse(JSON.parse(raw));
|
|
207
|
+
if (!parsed.success) {
|
|
208
|
+
throw new Error(
|
|
209
|
+
`Invalid marketplace.json: ${parsed.error.issues.map((i) => i.message).join("; ")}`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return parsed.data;
|
|
213
|
+
}
|
|
214
|
+
function parsePluginSpec(spec) {
|
|
215
|
+
const trimmed = spec.trim();
|
|
216
|
+
const parts = trimmed.split("@");
|
|
217
|
+
if (parts.length !== 2) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Invalid plugin spec: ${spec}. Expected format: <plugin>@<marketplace>`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
const plugin = parts[0].trim();
|
|
223
|
+
const marketplace = parts[1].trim();
|
|
224
|
+
if (!plugin || !marketplace) {
|
|
225
|
+
throw new Error(
|
|
226
|
+
`Invalid plugin spec: ${spec}. Expected format: <plugin>@<marketplace>`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
return { plugin, marketplace };
|
|
230
|
+
}
|
|
231
|
+
function resolvePluginForInstall(pluginInput) {
|
|
232
|
+
const trimmed = pluginInput.trim();
|
|
233
|
+
if (!trimmed) throw new Error("Plugin is required");
|
|
234
|
+
if (trimmed.includes("@")) {
|
|
235
|
+
const resolved = parsePluginSpec(trimmed);
|
|
236
|
+
return {
|
|
237
|
+
...resolved,
|
|
238
|
+
pluginSpec: `${resolved.plugin}@${resolved.marketplace}`
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const config = loadKnownMarketplaces();
|
|
242
|
+
const matches = [];
|
|
243
|
+
for (const [marketplace, entry] of Object.entries(config)) {
|
|
244
|
+
try {
|
|
245
|
+
const manifest = readMarketplaceFromDirectory(entry.installLocation);
|
|
246
|
+
const found = manifest.plugins.find((p) => p.name === trimmed);
|
|
247
|
+
if (found) matches.push({ marketplace, entry: found });
|
|
248
|
+
} catch {
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (matches.length === 0) {
|
|
252
|
+
const availableMarketplaces = Object.keys(config).sort().join(", ");
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Plugin '${trimmed}' not found in any marketplace. Available marketplaces: ${availableMarketplaces || "(none)"}`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
if (matches.length > 1) {
|
|
258
|
+
const options = matches.map((m) => `${trimmed}@${m.marketplace}`).sort().join(", ");
|
|
259
|
+
throw new Error(
|
|
260
|
+
`Plugin '${trimmed}' is available in multiple marketplaces. Use an explicit spec: ${options}`
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
plugin: trimmed,
|
|
265
|
+
marketplace: matches[0].marketplace,
|
|
266
|
+
pluginSpec: `${trimmed}@${matches[0].marketplace}`
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function resolveInstalledPluginSpec(pluginInput, state) {
|
|
270
|
+
const trimmed = pluginInput.trim();
|
|
271
|
+
if (!trimmed) throw new Error("Plugin is required");
|
|
272
|
+
if (trimmed.includes("@")) {
|
|
273
|
+
parsePluginSpec(trimmed);
|
|
274
|
+
return trimmed;
|
|
275
|
+
}
|
|
276
|
+
const matches = Object.entries(state).filter(
|
|
277
|
+
([, record]) => record?.plugin === trimmed
|
|
278
|
+
);
|
|
279
|
+
if (matches.length === 0) {
|
|
280
|
+
throw new Error(`Plugin '${trimmed}' is not installed`);
|
|
281
|
+
}
|
|
282
|
+
if (matches.length > 1) {
|
|
283
|
+
const options = matches.map(([spec]) => spec).sort().join(", ");
|
|
284
|
+
throw new Error(
|
|
285
|
+
`Plugin '${trimmed}' is installed from multiple marketplaces. Use an explicit spec: ${options}`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
return matches[0][0];
|
|
289
|
+
}
|
|
290
|
+
function baseDirForInstallRecord(record) {
|
|
291
|
+
if (record.scope === "user") return userKodeDir();
|
|
292
|
+
const projectPath = typeof record.projectPath === "string" ? record.projectPath.trim() : "";
|
|
293
|
+
if (!projectPath) {
|
|
294
|
+
throw new Error(
|
|
295
|
+
`Installed plugin '${record.plugin}@${record.marketplace}' is missing projectPath for scope=${record.scope}`
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
return join(projectPath, CONFIG_BASE_DIR);
|
|
299
|
+
}
|
|
300
|
+
function githubRepoFromUrl(input) {
|
|
301
|
+
const ssh = input.match(/^git@github\.com:([^/]+\/[^/]+?)(?:\.git)?$/);
|
|
302
|
+
if (ssh?.[1]) return ssh[1];
|
|
303
|
+
const https = input.match(
|
|
304
|
+
/^https?:\/\/github\.com\/([^/]+\/[^/]+?)(?:\.git)?$/
|
|
305
|
+
);
|
|
306
|
+
if (https?.[1]) return https[1];
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
function parseRefAndPath(input) {
|
|
310
|
+
const [beforeHash, hashPart] = input.split("#", 2);
|
|
311
|
+
const [base, refPart] = beforeHash.split("@", 2);
|
|
312
|
+
return {
|
|
313
|
+
base,
|
|
314
|
+
ref: refPart?.trim() || void 0,
|
|
315
|
+
path: hashPart?.trim() || void 0
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function parseMarketplaceSourceInput(sourceInput) {
|
|
319
|
+
const raw = sourceInput.trim();
|
|
320
|
+
if (!raw) throw new Error("Marketplace source is required");
|
|
321
|
+
for (const prefix of [
|
|
322
|
+
"github:",
|
|
323
|
+
"git:",
|
|
324
|
+
"url:",
|
|
325
|
+
"npm:",
|
|
326
|
+
"file:",
|
|
327
|
+
"dir:"
|
|
328
|
+
]) {
|
|
329
|
+
if (raw.startsWith(prefix)) {
|
|
330
|
+
const rest = raw.slice(prefix.length).trim();
|
|
331
|
+
const parsed2 = parseRefAndPath(rest);
|
|
332
|
+
if (prefix === "github:") {
|
|
333
|
+
return {
|
|
334
|
+
source: "github",
|
|
335
|
+
repo: parsed2.base.trim(),
|
|
336
|
+
...parsed2.ref ? { ref: parsed2.ref } : {},
|
|
337
|
+
...parsed2.path ? { path: parsed2.path } : {}
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
if (prefix === "git:") {
|
|
341
|
+
const repo2 = githubRepoFromUrl(parsed2.base.trim());
|
|
342
|
+
if (repo2) {
|
|
343
|
+
return {
|
|
344
|
+
source: "github",
|
|
345
|
+
repo: repo2,
|
|
346
|
+
...parsed2.ref ? { ref: parsed2.ref } : {},
|
|
347
|
+
...parsed2.path ? { path: parsed2.path } : {}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
source: "git",
|
|
352
|
+
url: parsed2.base.trim(),
|
|
353
|
+
...parsed2.ref ? { ref: parsed2.ref } : {},
|
|
354
|
+
...parsed2.path ? { path: parsed2.path } : {}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
if (prefix === "url:") {
|
|
358
|
+
return { source: "url", url: rest };
|
|
359
|
+
}
|
|
360
|
+
if (prefix === "npm:") {
|
|
361
|
+
return { source: "npm", package: rest };
|
|
362
|
+
}
|
|
363
|
+
if (prefix === "file:") {
|
|
364
|
+
return { source: "file", path: rest };
|
|
365
|
+
}
|
|
366
|
+
if (prefix === "dir:") {
|
|
367
|
+
return { source: "directory", path: rest };
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const resolved = resolve(raw);
|
|
372
|
+
if (existsSync(resolved)) {
|
|
373
|
+
const stat = lstatSync(resolved);
|
|
374
|
+
if (stat.isDirectory()) return { source: "directory", path: resolved };
|
|
375
|
+
if (stat.isFile()) return { source: "file", path: resolved };
|
|
376
|
+
throw new Error(`Marketplace source must be a directory or file: ${raw}`);
|
|
377
|
+
}
|
|
378
|
+
const parsed = parseRefAndPath(raw);
|
|
379
|
+
if (/^[^/\s]+\/[^/\s]+$/.test(parsed.base)) {
|
|
380
|
+
return {
|
|
381
|
+
source: "github",
|
|
382
|
+
repo: parsed.base,
|
|
383
|
+
...parsed.ref ? { ref: parsed.ref } : {},
|
|
384
|
+
...parsed.path ? { path: parsed.path } : {}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
const repo = githubRepoFromUrl(parsed.base);
|
|
388
|
+
if (repo) {
|
|
389
|
+
return {
|
|
390
|
+
source: "github",
|
|
391
|
+
repo,
|
|
392
|
+
...parsed.ref ? { ref: parsed.ref } : {},
|
|
393
|
+
...parsed.path ? { path: parsed.path } : {}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
if (/^https?:\/\//.test(raw)) {
|
|
397
|
+
return { source: "url", url: raw };
|
|
398
|
+
}
|
|
399
|
+
throw new Error(
|
|
400
|
+
`Unsupported marketplace source: ${sourceInput}. Use a local path, "owner/repo", or prefixes like github:, git:, url:, file:, dir:.`
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
async function fetchBinary(url) {
|
|
404
|
+
const resp = await fetch(url, { method: "GET" });
|
|
405
|
+
if (!resp.ok) {
|
|
406
|
+
throw new Error(
|
|
407
|
+
`Failed to download ${url}: ${resp.status} ${resp.statusText}`
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
const buf = await resp.arrayBuffer();
|
|
411
|
+
return new Uint8Array(buf);
|
|
412
|
+
}
|
|
413
|
+
async function tryDownloadGithubZip(repo, ref) {
|
|
414
|
+
const [owner, name] = repo.split("/", 2);
|
|
415
|
+
if (!owner || !name) throw new Error(`Invalid GitHub repo: ${repo}`);
|
|
416
|
+
const candidates = ref.startsWith("refs/") ? [ref] : [`refs/heads/${ref}`, `refs/tags/${ref}`];
|
|
417
|
+
let lastError = null;
|
|
418
|
+
for (const candidate of candidates) {
|
|
419
|
+
const url = `https://codeload.github.com/${owner}/${name}/zip/${candidate}`;
|
|
420
|
+
try {
|
|
421
|
+
return await fetchBinary(url);
|
|
422
|
+
} catch (err) {
|
|
423
|
+
lastError = err instanceof Error ? err : Error(String(err));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
throw lastError ?? new Error(`Failed to download GitHub repo ${repo}@${ref}`);
|
|
427
|
+
}
|
|
428
|
+
async function cacheMarketplaceToTempDir(source, tempDir) {
|
|
429
|
+
ensureEmptyDir(tempDir);
|
|
430
|
+
if (source.source === "directory") {
|
|
431
|
+
const root = resolve(source.path);
|
|
432
|
+
if (!existsSync(root) || !lstatSync(root).isDirectory()) {
|
|
433
|
+
throw new Error(`Directory not found: ${source.path}`);
|
|
434
|
+
}
|
|
435
|
+
safeCopyDirectory(root, tempDir);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (source.source === "file") {
|
|
439
|
+
const file = resolve(source.path);
|
|
440
|
+
if (!existsSync(file) || !lstatSync(file).isFile()) {
|
|
441
|
+
throw new Error(`File not found: ${source.path}`);
|
|
442
|
+
}
|
|
443
|
+
const out = join(tempDir, ".kode-plugin");
|
|
444
|
+
ensureDir(out);
|
|
445
|
+
copyFileSync(file, join(out, "marketplace.json"));
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (source.source === "github") {
|
|
449
|
+
const pathWithin = normalizeMarketplaceSubPath(source.path);
|
|
450
|
+
const preferredRef = source.ref?.trim() || "";
|
|
451
|
+
const refsToTry = preferredRef ? [preferredRef] : ["main", "master"];
|
|
452
|
+
let zip = null;
|
|
453
|
+
let usedRef = preferredRef || "main";
|
|
454
|
+
let lastError = null;
|
|
455
|
+
for (const ref of refsToTry) {
|
|
456
|
+
try {
|
|
457
|
+
zip = await tryDownloadGithubZip(source.repo, ref);
|
|
458
|
+
usedRef = ref;
|
|
459
|
+
break;
|
|
460
|
+
} catch (err) {
|
|
461
|
+
lastError = err instanceof Error ? err : Error(String(err));
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (!zip)
|
|
465
|
+
throw lastError ?? new Error(`Failed to download GitHub repo ${source.repo}`);
|
|
466
|
+
const files = unzipSync(zip);
|
|
467
|
+
const names = Object.keys(files).filter(Boolean);
|
|
468
|
+
const topDir = names.length > 0 ? names[0].split("/")[0] : "";
|
|
469
|
+
const includePrefix = pathWithin ? `${topDir}/${pathWithin.replace(/\/+$/, "")}/` : `${topDir}/`;
|
|
470
|
+
let extractedCount = 0;
|
|
471
|
+
for (const [name, data] of Object.entries(files)) {
|
|
472
|
+
if (!name.startsWith(includePrefix)) continue;
|
|
473
|
+
const rel = name.slice(includePrefix.length);
|
|
474
|
+
if (!rel) continue;
|
|
475
|
+
if (rel.endsWith("/")) {
|
|
476
|
+
ensureDir(safeJoinWithin(tempDir, rel));
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
const dest = safeJoinWithin(tempDir, rel);
|
|
480
|
+
ensureDir(dirname(dest));
|
|
481
|
+
writeFileSync(dest, data);
|
|
482
|
+
extractedCount++;
|
|
483
|
+
}
|
|
484
|
+
if (extractedCount === 0) {
|
|
485
|
+
throw new Error(
|
|
486
|
+
`No files extracted from ${source.repo}@${usedRef}${pathWithin ? `#${pathWithin}` : ""}`
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (source.source === "url") {
|
|
492
|
+
const url = source.url;
|
|
493
|
+
if (url.toLowerCase().endsWith(".json")) {
|
|
494
|
+
const data = await fetchBinary(url);
|
|
495
|
+
const out = join(tempDir, ".kode-plugin");
|
|
496
|
+
ensureDir(out);
|
|
497
|
+
writeFileSync(join(out, "marketplace.json"), Buffer.from(data));
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
if (url.toLowerCase().endsWith(".zip")) {
|
|
501
|
+
const zip = await fetchBinary(url);
|
|
502
|
+
const files = unzipSync(zip);
|
|
503
|
+
for (const [name, data] of Object.entries(files)) {
|
|
504
|
+
if (!name || name.endsWith("/")) continue;
|
|
505
|
+
const dest = safeJoinWithin(tempDir, name);
|
|
506
|
+
ensureDir(dirname(dest));
|
|
507
|
+
writeFileSync(dest, data);
|
|
508
|
+
}
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
throw new Error(
|
|
512
|
+
`Unsupported url marketplace source. Provide a .json or .zip URL: ${url}`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
if (source.source === "git") {
|
|
516
|
+
const repo = githubRepoFromUrl(source.url);
|
|
517
|
+
if (repo) {
|
|
518
|
+
await cacheMarketplaceToTempDir(
|
|
519
|
+
{
|
|
520
|
+
source: "github",
|
|
521
|
+
repo,
|
|
522
|
+
...source.ref ? { ref: source.ref } : {},
|
|
523
|
+
...source.path ? { path: source.path } : {}
|
|
524
|
+
},
|
|
525
|
+
tempDir
|
|
526
|
+
);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
throw new Error(
|
|
530
|
+
`git sources are not supported without GitHub conversion (url=${source.url})`
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
if (source.source === "npm") {
|
|
534
|
+
throw new Error(
|
|
535
|
+
`npm marketplace sources are not supported yet (package=${source.package}). Install the package and add it as a local dir instead.`
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
function loadKnownMarketplaces() {
|
|
540
|
+
const raw = readJsonFile(knownMarketplacesConfigPath(), {});
|
|
541
|
+
const parsed = KnownMarketplacesSchema.safeParse(raw);
|
|
542
|
+
if (!parsed.success) {
|
|
543
|
+
throw new Error(
|
|
544
|
+
`Marketplace configuration is corrupted: ${parsed.error.issues.map((i) => i.message).join("; ")}`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
return parsed.data;
|
|
548
|
+
}
|
|
549
|
+
function saveKnownMarketplaces(config) {
|
|
550
|
+
const parsed = KnownMarketplacesSchema.safeParse(config);
|
|
551
|
+
if (!parsed.success) {
|
|
552
|
+
throw new Error(`Invalid marketplace config: ${parsed.error.message}`);
|
|
553
|
+
}
|
|
554
|
+
writeJsonFile(knownMarketplacesConfigPath(), parsed.data);
|
|
555
|
+
}
|
|
556
|
+
function listMarketplaces() {
|
|
557
|
+
return loadKnownMarketplaces();
|
|
558
|
+
}
|
|
559
|
+
async function addMarketplace(sourceInput) {
|
|
560
|
+
const source = parseMarketplaceSourceInput(sourceInput);
|
|
561
|
+
const validatedSource = MarketplaceSourceSchema.safeParse(source);
|
|
562
|
+
if (!validatedSource.success) {
|
|
563
|
+
throw new Error(
|
|
564
|
+
`Invalid marketplace source: ${validatedSource.error.issues.map((i) => i.message).join("; ")}`
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
const config = loadKnownMarketplaces();
|
|
568
|
+
const cacheBase = marketplaceCacheBaseDir();
|
|
569
|
+
ensureDir(cacheBase);
|
|
570
|
+
const tempDir = join(cacheBase, `tmp-${randomUUID()}`);
|
|
571
|
+
try {
|
|
572
|
+
await cacheMarketplaceToTempDir(validatedSource.data, tempDir);
|
|
573
|
+
const manifest = readMarketplaceFromDirectory(tempDir);
|
|
574
|
+
const marketplaceName = manifest.name;
|
|
575
|
+
if (config[marketplaceName]) {
|
|
576
|
+
throw new Error(
|
|
577
|
+
`Marketplace '${marketplaceName}' is already installed. Remove it first to re-add.`
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
const installLocation = join(cacheBase, marketplaceName);
|
|
581
|
+
if (existsSync(installLocation)) {
|
|
582
|
+
throw new Error(
|
|
583
|
+
`Marketplace cache directory already exists: ${installLocation}`
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
renameSync(tempDir, installLocation);
|
|
587
|
+
config[marketplaceName] = {
|
|
588
|
+
source: validatedSource.data,
|
|
589
|
+
installLocation,
|
|
590
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
591
|
+
};
|
|
592
|
+
saveKnownMarketplaces(config);
|
|
593
|
+
return { name: marketplaceName };
|
|
594
|
+
} catch (error) {
|
|
595
|
+
if (existsSync(tempDir)) rmSync(tempDir, { recursive: true, force: true });
|
|
596
|
+
throw error;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function removeMarketplace(name) {
|
|
600
|
+
const trimmed = name.trim();
|
|
601
|
+
if (!trimmed) throw new Error("Marketplace name is required");
|
|
602
|
+
const config = loadKnownMarketplaces();
|
|
603
|
+
const entry = config[trimmed];
|
|
604
|
+
if (!entry) throw new Error(`Marketplace '${trimmed}' not found`);
|
|
605
|
+
delete config[trimmed];
|
|
606
|
+
saveKnownMarketplaces(config);
|
|
607
|
+
try {
|
|
608
|
+
if (existsSync(entry.installLocation)) {
|
|
609
|
+
rmSync(entry.installLocation, { recursive: true, force: true });
|
|
610
|
+
}
|
|
611
|
+
} catch {
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
async function refreshMarketplaceAsync(name) {
|
|
615
|
+
const trimmed = name.trim();
|
|
616
|
+
if (!trimmed) throw new Error("Marketplace name is required");
|
|
617
|
+
const config = loadKnownMarketplaces();
|
|
618
|
+
const entry = config[trimmed];
|
|
619
|
+
if (!entry) throw new Error(`Marketplace '${trimmed}' not found`);
|
|
620
|
+
const cacheBase = marketplaceCacheBaseDir();
|
|
621
|
+
ensureDir(cacheBase);
|
|
622
|
+
const tempDir = join(cacheBase, `tmp-${randomUUID()}`);
|
|
623
|
+
try {
|
|
624
|
+
await cacheMarketplaceToTempDir(entry.source, tempDir);
|
|
625
|
+
const manifest = readMarketplaceFromDirectory(tempDir);
|
|
626
|
+
if (manifest.name !== trimmed) {
|
|
627
|
+
throw new Error(
|
|
628
|
+
`Marketplace name mismatch on refresh: expected ${trimmed}, got ${manifest.name}`
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
if (existsSync(entry.installLocation)) {
|
|
632
|
+
rmSync(entry.installLocation, { recursive: true, force: true });
|
|
633
|
+
}
|
|
634
|
+
renameSync(tempDir, entry.installLocation);
|
|
635
|
+
config[trimmed] = {
|
|
636
|
+
...entry,
|
|
637
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
638
|
+
};
|
|
639
|
+
saveKnownMarketplaces(config);
|
|
640
|
+
} catch (error) {
|
|
641
|
+
if (existsSync(tempDir)) rmSync(tempDir, { recursive: true, force: true });
|
|
642
|
+
throw error;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
async function refreshAllMarketplacesAsync(onProgress) {
|
|
646
|
+
const config = loadKnownMarketplaces();
|
|
647
|
+
const names = Object.keys(config).sort();
|
|
648
|
+
const refreshed = [];
|
|
649
|
+
const failed = [];
|
|
650
|
+
for (const name of names) {
|
|
651
|
+
try {
|
|
652
|
+
onProgress?.(`Updating marketplace: ${name}...`);
|
|
653
|
+
await refreshMarketplaceAsync(name);
|
|
654
|
+
refreshed.push(name);
|
|
655
|
+
} catch (error) {
|
|
656
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
657
|
+
failed.push({ name, error: message });
|
|
658
|
+
onProgress?.(`Failed to refresh marketplace ${name}: ${message}`);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return { refreshed, failed };
|
|
662
|
+
}
|
|
663
|
+
function getMarketplaceManifest(marketplaceName) {
|
|
664
|
+
const config = loadKnownMarketplaces();
|
|
665
|
+
const entry = config[marketplaceName];
|
|
666
|
+
if (!entry) {
|
|
667
|
+
const available = Object.keys(config).sort().join(", ");
|
|
668
|
+
throw new Error(
|
|
669
|
+
`Marketplace '${marketplaceName}' not found. Available marketplaces: ${available || "(none)"}`
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
const manifest = readMarketplaceFromDirectory(entry.installLocation);
|
|
673
|
+
return { manifest, rootDir: entry.installLocation, source: entry.source };
|
|
674
|
+
}
|
|
675
|
+
function ensurePluginInstallState() {
|
|
676
|
+
ensureDir(userKodeDir());
|
|
677
|
+
const state = readJsonFile(
|
|
678
|
+
installedSkillPluginsPath(),
|
|
679
|
+
{}
|
|
680
|
+
);
|
|
681
|
+
for (const record of Object.values(state)) {
|
|
682
|
+
if (!record || typeof record !== "object") continue;
|
|
683
|
+
if (record.scope !== "user" && record.scope !== "project" && record.scope !== "local") {
|
|
684
|
+
record.scope = "user";
|
|
685
|
+
}
|
|
686
|
+
if (record.kind !== "skill-pack" && record.kind !== "plugin-pack") {
|
|
687
|
+
record.kind = typeof record.pluginRoot === "string" ? "plugin-pack" : "skill-pack";
|
|
688
|
+
}
|
|
689
|
+
if (record.isEnabled === void 0) record.isEnabled = true;
|
|
690
|
+
}
|
|
691
|
+
return state;
|
|
692
|
+
}
|
|
693
|
+
function savePluginInstallState(state) {
|
|
694
|
+
writeJsonFile(installedSkillPluginsPath(), state);
|
|
695
|
+
}
|
|
696
|
+
function installSkillPlugin(pluginInput, options) {
|
|
697
|
+
const scope = normalizePluginScope(options);
|
|
698
|
+
const { plugin, marketplace, pluginSpec } = resolvePluginForInstall(pluginInput);
|
|
699
|
+
const { manifest, rootDir, source } = getMarketplaceManifest(marketplace);
|
|
700
|
+
const entry = manifest.plugins.find((p) => p.name === plugin);
|
|
701
|
+
if (!entry) {
|
|
702
|
+
const available = manifest.plugins.map((p) => p.name).sort().join(", ");
|
|
703
|
+
throw new Error(
|
|
704
|
+
`Plugin '${plugin}' not found in marketplace '${marketplace}'. Available plugins: ${available || "(none)"}`
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
const installState = ensurePluginInstallState();
|
|
708
|
+
const existing = installState[pluginSpec];
|
|
709
|
+
if (existing && existing.scope !== scope && options?.force !== true) {
|
|
710
|
+
throw new Error(
|
|
711
|
+
`Plugin '${pluginSpec}' is already installed with scope=${existing.scope}. Uninstall it first to install with scope=${scope}.`
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
if (existing && options?.force !== true) {
|
|
715
|
+
throw new Error(
|
|
716
|
+
`Plugin '${pluginSpec}' is already installed. Re-run with --force to reinstall.`
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
const entrySourceBase = resolve(rootDir, entry.source ?? "./");
|
|
720
|
+
const primaryManifestPath = join(
|
|
721
|
+
entrySourceBase,
|
|
722
|
+
".kode-plugin",
|
|
723
|
+
"plugin.json"
|
|
724
|
+
);
|
|
725
|
+
const legacyManifestPath = join(
|
|
726
|
+
entrySourceBase,
|
|
727
|
+
".claude-plugin",
|
|
728
|
+
"plugin.json"
|
|
729
|
+
);
|
|
730
|
+
const pluginManifestPath = existsSync(primaryManifestPath) ? primaryManifestPath : legacyManifestPath;
|
|
731
|
+
if (existsSync(pluginManifestPath) && lstatSync(pluginManifestPath).isFile()) {
|
|
732
|
+
const pluginRoot = scopeInstalledPluginRoot(scope, plugin, marketplace);
|
|
733
|
+
if (existsSync(pluginRoot) && options?.force !== true) {
|
|
734
|
+
throw new Error(`Destination already exists: ${pluginRoot}`);
|
|
735
|
+
}
|
|
736
|
+
ensureEmptyDir(pluginRoot);
|
|
737
|
+
safeCopyDirectory(entrySourceBase, pluginRoot);
|
|
738
|
+
installState[pluginSpec] = {
|
|
739
|
+
plugin,
|
|
740
|
+
marketplace,
|
|
741
|
+
scope,
|
|
742
|
+
kind: "plugin-pack",
|
|
743
|
+
pluginRoot,
|
|
744
|
+
isEnabled: true,
|
|
745
|
+
projectPath: scope === "user" ? void 0 : getCwd(),
|
|
746
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
747
|
+
skills: [],
|
|
748
|
+
commands: [],
|
|
749
|
+
sourceMarketplacePath: source.source === "file" || source.source === "directory" ? source.path : source.source === "github" ? `github:${source.repo}` : source.source === "url" ? source.url : source.source === "git" ? source.url : `npm:${source.package}`
|
|
750
|
+
};
|
|
751
|
+
savePluginInstallState(installState);
|
|
752
|
+
return { pluginSpec, installedSkills: [], installedCommands: [] };
|
|
753
|
+
}
|
|
754
|
+
const skillsDestBase = scopeSkillsDir(scope);
|
|
755
|
+
const commandsDestBase = join(scopeCommandsDir(scope), plugin, marketplace);
|
|
756
|
+
ensureDir(skillsDestBase);
|
|
757
|
+
ensureDir(commandsDestBase);
|
|
758
|
+
const installedSkills = [];
|
|
759
|
+
const installedCommands = [];
|
|
760
|
+
const skillPaths = entry.skills ?? [];
|
|
761
|
+
for (const rel of skillPaths) {
|
|
762
|
+
const src = safeJoinWithin(entrySourceBase, rel);
|
|
763
|
+
if (!existsSync(src) || !lstatSync(src).isDirectory()) {
|
|
764
|
+
throw new Error(`Skill path not found or not a directory: ${src}`);
|
|
765
|
+
}
|
|
766
|
+
const skillName = basename(src);
|
|
767
|
+
const dest = join(skillsDestBase, skillName);
|
|
768
|
+
if (existsSync(dest) && options?.force !== true) {
|
|
769
|
+
throw new Error(`Destination already exists: ${dest}`);
|
|
770
|
+
}
|
|
771
|
+
ensureEmptyDir(dest);
|
|
772
|
+
safeCopyDirectory(src, dest);
|
|
773
|
+
installedSkills.push(skillName);
|
|
774
|
+
}
|
|
775
|
+
const commandPaths = entry.commands ?? [];
|
|
776
|
+
for (const rel of commandPaths) {
|
|
777
|
+
const src = safeJoinWithin(entrySourceBase, rel);
|
|
778
|
+
if (!existsSync(src)) {
|
|
779
|
+
throw new Error(`Command path not found: ${src}`);
|
|
780
|
+
}
|
|
781
|
+
const stat = lstatSync(src);
|
|
782
|
+
if (stat.isDirectory()) {
|
|
783
|
+
const dest = join(commandsDestBase, basename(src));
|
|
784
|
+
if (existsSync(dest) && options?.force !== true) {
|
|
785
|
+
throw new Error(`Destination already exists: ${dest}`);
|
|
786
|
+
}
|
|
787
|
+
ensureEmptyDir(dest);
|
|
788
|
+
safeCopyDirectory(src, dest);
|
|
789
|
+
installedCommands.push(dest);
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
if (stat.isFile()) {
|
|
793
|
+
const dest = join(commandsDestBase, basename(src));
|
|
794
|
+
ensureDir(dirname(dest));
|
|
795
|
+
if (existsSync(dest) && options?.force !== true) {
|
|
796
|
+
throw new Error(`Destination already exists: ${dest}`);
|
|
797
|
+
}
|
|
798
|
+
copyFileSync(src, dest);
|
|
799
|
+
installedCommands.push(dest);
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
installState[pluginSpec] = {
|
|
804
|
+
plugin,
|
|
805
|
+
marketplace,
|
|
806
|
+
scope,
|
|
807
|
+
kind: "skill-pack",
|
|
808
|
+
isEnabled: true,
|
|
809
|
+
projectPath: scope === "user" ? void 0 : getCwd(),
|
|
810
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
811
|
+
skills: installedSkills,
|
|
812
|
+
commands: installedCommands,
|
|
813
|
+
sourceMarketplacePath: source.source === "file" || source.source === "directory" ? source.path : source.source === "github" ? `github:${source.repo}` : source.source === "url" ? source.url : source.source === "git" ? source.url : `npm:${source.package}`
|
|
814
|
+
};
|
|
815
|
+
savePluginInstallState(installState);
|
|
816
|
+
return { pluginSpec, installedSkills, installedCommands };
|
|
817
|
+
}
|
|
818
|
+
function uninstallSkillPlugin(pluginInput, options) {
|
|
819
|
+
const requestedScope = normalizePluginScope(options);
|
|
820
|
+
const state = ensurePluginInstallState();
|
|
821
|
+
const pluginSpec = resolveInstalledPluginSpec(pluginInput, state);
|
|
822
|
+
const record = state[pluginSpec];
|
|
823
|
+
if (!record) {
|
|
824
|
+
throw new Error(`Plugin '${pluginSpec}' is not installed`);
|
|
825
|
+
}
|
|
826
|
+
if (record.scope !== requestedScope) {
|
|
827
|
+
throw new Error(
|
|
828
|
+
`Plugin '${pluginSpec}' is installed with scope=${record.scope}. Re-run with --scope ${record.scope}.`
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
if (record.scope !== "user") {
|
|
832
|
+
const projectPath = record.projectPath?.trim() || "";
|
|
833
|
+
const cwd = getCwd();
|
|
834
|
+
if (!projectPath || projectPath !== cwd) {
|
|
835
|
+
throw new Error(
|
|
836
|
+
`Plugin '${pluginSpec}' is installed for a different directory. Expected cwd=${projectPath || "(missing)"}, got cwd=${cwd}`
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if (record.kind === "plugin-pack") {
|
|
841
|
+
const baseDir2 = baseDirForInstallRecord(record);
|
|
842
|
+
const pluginRoot = typeof record.pluginRoot === "string" && record.pluginRoot.trim() ? record.pluginRoot : join(
|
|
843
|
+
baseDir2,
|
|
844
|
+
"plugins",
|
|
845
|
+
"installed",
|
|
846
|
+
record.plugin,
|
|
847
|
+
record.marketplace
|
|
848
|
+
);
|
|
849
|
+
const removedCommands2 = [];
|
|
850
|
+
if (existsSync(pluginRoot)) {
|
|
851
|
+
rmSync(pluginRoot, { recursive: true, force: true });
|
|
852
|
+
removedCommands2.push(pluginRoot);
|
|
853
|
+
}
|
|
854
|
+
delete state[pluginSpec];
|
|
855
|
+
savePluginInstallState(state);
|
|
856
|
+
return { pluginSpec, removedSkills: [], removedCommands: removedCommands2 };
|
|
857
|
+
}
|
|
858
|
+
const baseDir = baseDirForInstallRecord(record);
|
|
859
|
+
const skillsDestBase = join(baseDir, "skills");
|
|
860
|
+
const commandsDestBase = join(
|
|
861
|
+
baseDir,
|
|
862
|
+
"commands",
|
|
863
|
+
record.plugin,
|
|
864
|
+
record.marketplace
|
|
865
|
+
);
|
|
866
|
+
const disabledSkillsBase = join(
|
|
867
|
+
baseDir,
|
|
868
|
+
"skills.disabled",
|
|
869
|
+
record.plugin,
|
|
870
|
+
record.marketplace
|
|
871
|
+
);
|
|
872
|
+
const disabledCommandsBase = join(
|
|
873
|
+
baseDir,
|
|
874
|
+
"commands.disabled",
|
|
875
|
+
record.plugin,
|
|
876
|
+
record.marketplace
|
|
877
|
+
);
|
|
878
|
+
const removedSkills = [];
|
|
879
|
+
for (const skillName of record.skills) {
|
|
880
|
+
const dest = join(skillsDestBase, skillName);
|
|
881
|
+
if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });
|
|
882
|
+
const disabledDest = join(disabledSkillsBase, skillName);
|
|
883
|
+
if (existsSync(disabledDest))
|
|
884
|
+
rmSync(disabledDest, { recursive: true, force: true });
|
|
885
|
+
removedSkills.push(skillName);
|
|
886
|
+
}
|
|
887
|
+
const removedCommands = [];
|
|
888
|
+
if (existsSync(commandsDestBase)) {
|
|
889
|
+
rmSync(commandsDestBase, { recursive: true, force: true });
|
|
890
|
+
removedCommands.push(commandsDestBase);
|
|
891
|
+
}
|
|
892
|
+
if (existsSync(disabledCommandsBase)) {
|
|
893
|
+
rmSync(disabledCommandsBase, { recursive: true, force: true });
|
|
894
|
+
removedCommands.push(disabledCommandsBase);
|
|
895
|
+
}
|
|
896
|
+
delete state[pluginSpec];
|
|
897
|
+
savePluginInstallState(state);
|
|
898
|
+
return { pluginSpec, removedSkills, removedCommands };
|
|
899
|
+
}
|
|
900
|
+
function disableSkillPlugin(pluginInput, options) {
|
|
901
|
+
const requestedScope = normalizePluginScope(options);
|
|
902
|
+
const state = ensurePluginInstallState();
|
|
903
|
+
const pluginSpec = resolveInstalledPluginSpec(pluginInput, state);
|
|
904
|
+
const record = state[pluginSpec];
|
|
905
|
+
if (!record) throw new Error(`Plugin '${pluginSpec}' is not installed`);
|
|
906
|
+
if (record.scope !== requestedScope) {
|
|
907
|
+
throw new Error(
|
|
908
|
+
`Plugin '${pluginSpec}' is installed with scope=${record.scope}. Re-run with --scope ${record.scope}.`
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
if (record.scope !== "user") {
|
|
912
|
+
const projectPath = record.projectPath?.trim() || "";
|
|
913
|
+
const cwd = getCwd();
|
|
914
|
+
if (!projectPath || projectPath !== cwd) {
|
|
915
|
+
throw new Error(
|
|
916
|
+
`Plugin '${pluginSpec}' is installed for a different directory. Expected cwd=${projectPath || "(missing)"}, got cwd=${cwd}`
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
if (record.isEnabled === false) {
|
|
921
|
+
return { pluginSpec, disabledSkills: [], disabledCommands: [] };
|
|
922
|
+
}
|
|
923
|
+
if (record.kind === "plugin-pack") {
|
|
924
|
+
record.isEnabled = false;
|
|
925
|
+
state[pluginSpec] = record;
|
|
926
|
+
savePluginInstallState(state);
|
|
927
|
+
return { pluginSpec, disabledSkills: [], disabledCommands: [] };
|
|
928
|
+
}
|
|
929
|
+
const baseDir = baseDirForInstallRecord(record);
|
|
930
|
+
const skillsDir = join(baseDir, "skills");
|
|
931
|
+
const commandsDir = join(
|
|
932
|
+
baseDir,
|
|
933
|
+
"commands",
|
|
934
|
+
record.plugin,
|
|
935
|
+
record.marketplace
|
|
936
|
+
);
|
|
937
|
+
const disabledSkillsBase = join(
|
|
938
|
+
baseDir,
|
|
939
|
+
"skills.disabled",
|
|
940
|
+
record.plugin,
|
|
941
|
+
record.marketplace
|
|
942
|
+
);
|
|
943
|
+
const disabledCommandsDir = join(
|
|
944
|
+
baseDir,
|
|
945
|
+
"commands.disabled",
|
|
946
|
+
record.plugin,
|
|
947
|
+
record.marketplace
|
|
948
|
+
);
|
|
949
|
+
const disabledSkills = [];
|
|
950
|
+
for (const skillName of record.skills) {
|
|
951
|
+
const src = join(skillsDir, skillName);
|
|
952
|
+
if (!existsSync(src)) continue;
|
|
953
|
+
const dest = join(disabledSkillsBase, skillName);
|
|
954
|
+
ensureDir(dirname(dest));
|
|
955
|
+
if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });
|
|
956
|
+
renameSync(src, dest);
|
|
957
|
+
disabledSkills.push(skillName);
|
|
958
|
+
}
|
|
959
|
+
const disabledCommands = [];
|
|
960
|
+
if (existsSync(commandsDir)) {
|
|
961
|
+
ensureDir(dirname(disabledCommandsDir));
|
|
962
|
+
if (existsSync(disabledCommandsDir)) {
|
|
963
|
+
rmSync(disabledCommandsDir, { recursive: true, force: true });
|
|
964
|
+
}
|
|
965
|
+
renameSync(commandsDir, disabledCommandsDir);
|
|
966
|
+
disabledCommands.push(disabledCommandsDir);
|
|
967
|
+
}
|
|
968
|
+
record.isEnabled = false;
|
|
969
|
+
state[pluginSpec] = record;
|
|
970
|
+
savePluginInstallState(state);
|
|
971
|
+
return { pluginSpec, disabledSkills, disabledCommands };
|
|
972
|
+
}
|
|
973
|
+
function enableSkillPlugin(pluginInput, options) {
|
|
974
|
+
const requestedScope = normalizePluginScope(options);
|
|
975
|
+
const state = ensurePluginInstallState();
|
|
976
|
+
const pluginSpec = resolveInstalledPluginSpec(pluginInput, state);
|
|
977
|
+
const record = state[pluginSpec];
|
|
978
|
+
if (!record) throw new Error(`Plugin '${pluginSpec}' is not installed`);
|
|
979
|
+
if (record.scope !== requestedScope) {
|
|
980
|
+
throw new Error(
|
|
981
|
+
`Plugin '${pluginSpec}' is installed with scope=${record.scope}. Re-run with --scope ${record.scope}.`
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
if (record.scope !== "user") {
|
|
985
|
+
const projectPath = record.projectPath?.trim() || "";
|
|
986
|
+
const cwd = getCwd();
|
|
987
|
+
if (!projectPath || projectPath !== cwd) {
|
|
988
|
+
throw new Error(
|
|
989
|
+
`Plugin '${pluginSpec}' is installed for a different directory. Expected cwd=${projectPath || "(missing)"}, got cwd=${cwd}`
|
|
990
|
+
);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
if (record.isEnabled !== false) {
|
|
994
|
+
return { pluginSpec, enabledSkills: [], enabledCommands: [] };
|
|
995
|
+
}
|
|
996
|
+
if (record.kind === "plugin-pack") {
|
|
997
|
+
record.isEnabled = true;
|
|
998
|
+
state[pluginSpec] = record;
|
|
999
|
+
savePluginInstallState(state);
|
|
1000
|
+
return { pluginSpec, enabledSkills: [], enabledCommands: [] };
|
|
1001
|
+
}
|
|
1002
|
+
const baseDir = baseDirForInstallRecord(record);
|
|
1003
|
+
const skillsDir = join(baseDir, "skills");
|
|
1004
|
+
const commandsDir = join(
|
|
1005
|
+
baseDir,
|
|
1006
|
+
"commands",
|
|
1007
|
+
record.plugin,
|
|
1008
|
+
record.marketplace
|
|
1009
|
+
);
|
|
1010
|
+
const disabledSkillsBase = join(
|
|
1011
|
+
baseDir,
|
|
1012
|
+
"skills.disabled",
|
|
1013
|
+
record.plugin,
|
|
1014
|
+
record.marketplace
|
|
1015
|
+
);
|
|
1016
|
+
const disabledCommandsDir = join(
|
|
1017
|
+
baseDir,
|
|
1018
|
+
"commands.disabled",
|
|
1019
|
+
record.plugin,
|
|
1020
|
+
record.marketplace
|
|
1021
|
+
);
|
|
1022
|
+
const enabledSkills = [];
|
|
1023
|
+
for (const skillName of record.skills) {
|
|
1024
|
+
const src = join(disabledSkillsBase, skillName);
|
|
1025
|
+
if (!existsSync(src)) continue;
|
|
1026
|
+
const dest = join(skillsDir, skillName);
|
|
1027
|
+
ensureDir(dirname(dest));
|
|
1028
|
+
if (existsSync(dest)) {
|
|
1029
|
+
throw new Error(`Destination already exists: ${dest}`);
|
|
1030
|
+
}
|
|
1031
|
+
renameSync(src, dest);
|
|
1032
|
+
enabledSkills.push(skillName);
|
|
1033
|
+
}
|
|
1034
|
+
const enabledCommands = [];
|
|
1035
|
+
if (existsSync(disabledCommandsDir)) {
|
|
1036
|
+
ensureDir(dirname(commandsDir));
|
|
1037
|
+
if (existsSync(commandsDir)) {
|
|
1038
|
+
throw new Error(`Destination already exists: ${commandsDir}`);
|
|
1039
|
+
}
|
|
1040
|
+
renameSync(disabledCommandsDir, commandsDir);
|
|
1041
|
+
enabledCommands.push(commandsDir);
|
|
1042
|
+
}
|
|
1043
|
+
record.isEnabled = true;
|
|
1044
|
+
state[pluginSpec] = record;
|
|
1045
|
+
savePluginInstallState(state);
|
|
1046
|
+
return { pluginSpec, enabledSkills, enabledCommands };
|
|
1047
|
+
}
|
|
1048
|
+
function listInstalledSkillPlugins() {
|
|
1049
|
+
return ensurePluginInstallState();
|
|
1050
|
+
}
|
|
1051
|
+
function listEnabledInstalledPluginPackRoots() {
|
|
1052
|
+
const state = ensurePluginInstallState();
|
|
1053
|
+
const cwd = getCwd();
|
|
1054
|
+
const roots = [];
|
|
1055
|
+
for (const spec of Object.keys(state).sort()) {
|
|
1056
|
+
const record = state[spec];
|
|
1057
|
+
if (!record || record.kind !== "plugin-pack") continue;
|
|
1058
|
+
if (record.isEnabled === false) continue;
|
|
1059
|
+
if (record.scope !== "user") {
|
|
1060
|
+
const projectPath = record.projectPath?.trim() || "";
|
|
1061
|
+
if (!projectPath || projectPath !== cwd) continue;
|
|
1062
|
+
}
|
|
1063
|
+
const baseDir = baseDirForInstallRecord(record);
|
|
1064
|
+
const pluginRoot = typeof record.pluginRoot === "string" && record.pluginRoot.trim() ? record.pluginRoot : join(
|
|
1065
|
+
baseDir,
|
|
1066
|
+
"plugins",
|
|
1067
|
+
"installed",
|
|
1068
|
+
record.plugin,
|
|
1069
|
+
record.marketplace
|
|
1070
|
+
);
|
|
1071
|
+
try {
|
|
1072
|
+
if (!existsSync(pluginRoot) || !lstatSync(pluginRoot).isDirectory())
|
|
1073
|
+
continue;
|
|
1074
|
+
roots.push(pluginRoot);
|
|
1075
|
+
} catch {
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
return roots;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
export {
|
|
1083
|
+
MarketplaceManifestSchema,
|
|
1084
|
+
parsePluginSpec,
|
|
1085
|
+
listMarketplaces,
|
|
1086
|
+
addMarketplace,
|
|
1087
|
+
removeMarketplace,
|
|
1088
|
+
refreshMarketplaceAsync,
|
|
1089
|
+
refreshAllMarketplacesAsync,
|
|
1090
|
+
getMarketplaceManifest,
|
|
1091
|
+
installSkillPlugin,
|
|
1092
|
+
uninstallSkillPlugin,
|
|
1093
|
+
disableSkillPlugin,
|
|
1094
|
+
enableSkillPlugin,
|
|
1095
|
+
listInstalledSkillPlugins,
|
|
1096
|
+
listEnabledInstalledPluginPackRoots
|
|
1097
|
+
};
|