@shareai-lab/kode 1.2.0 → 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 -388
- 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/{utils/autoUpdater.js → chunk-3IN27HA5.js} +38 -21
- 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 -14
- 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 -312
- 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 -32
- 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 -488
- 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 -1034
- 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 -1107
- 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 -22
- 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 -593
- 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 -308
- 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.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
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, statSync } from "fs";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import { dirname, isAbsolute, relative, resolve, sep } from "path";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
import { FileEditToolUpdatedMessage } from "../../components/FileEditToolUpdatedMessage.js";
|
|
7
|
-
import { StructuredDiff } from "../../components/StructuredDiff.js";
|
|
8
|
-
import { FallbackToolUseRejectedMessage } from "../../components/FallbackToolUseRejectedMessage.js";
|
|
9
|
-
import { logEvent } from "../../services/statsig.js";
|
|
10
|
-
import { intersperse } from "../../utils/array.js";
|
|
11
|
-
import {
|
|
12
|
-
addLineNumbers,
|
|
13
|
-
detectFileEncoding,
|
|
14
|
-
detectLineEndings,
|
|
15
|
-
findSimilarFile,
|
|
16
|
-
writeTextContent
|
|
17
|
-
} from "../../utils/file.js";
|
|
18
|
-
import { logError } from "../../utils/log.js";
|
|
19
|
-
import { getCwd } from "../../utils/state.js";
|
|
20
|
-
import { getTheme } from "../../utils/theme.js";
|
|
21
|
-
import { emitReminderEvent } from "../../services/systemReminder.js";
|
|
22
|
-
import { recordFileEdit } from "../../services/fileFreshness.js";
|
|
23
|
-
import { NotebookEditTool } from "../NotebookEditTool/NotebookEditTool.js";
|
|
24
|
-
import { DESCRIPTION } from "./prompt.js";
|
|
25
|
-
import { applyEdit } from "./utils.js";
|
|
26
|
-
import { hasWritePermission } from "../../utils/permissions/filesystem.js";
|
|
27
|
-
import { PROJECT_FILE } from "../../constants/product.js";
|
|
28
|
-
const inputSchema = z.strictObject({
|
|
29
|
-
file_path: z.string().describe("The absolute path to the file to modify"),
|
|
30
|
-
old_string: z.string().describe("The text to replace"),
|
|
31
|
-
new_string: z.string().describe("The text to replace it with")
|
|
32
|
-
});
|
|
33
|
-
const N_LINES_SNIPPET = 4;
|
|
34
|
-
const FileEditTool = {
|
|
35
|
-
name: "Edit",
|
|
36
|
-
async description() {
|
|
37
|
-
return "A tool for editing files";
|
|
38
|
-
},
|
|
39
|
-
async prompt() {
|
|
40
|
-
return DESCRIPTION;
|
|
41
|
-
},
|
|
42
|
-
inputSchema,
|
|
43
|
-
userFacingName() {
|
|
44
|
-
return "Edit";
|
|
45
|
-
},
|
|
46
|
-
async isEnabled() {
|
|
47
|
-
return true;
|
|
48
|
-
},
|
|
49
|
-
isReadOnly() {
|
|
50
|
-
return false;
|
|
51
|
-
},
|
|
52
|
-
isConcurrencySafe() {
|
|
53
|
-
return false;
|
|
54
|
-
},
|
|
55
|
-
needsPermissions({ file_path }) {
|
|
56
|
-
return !hasWritePermission(file_path);
|
|
57
|
-
},
|
|
58
|
-
renderToolUseMessage(input, { verbose }) {
|
|
59
|
-
return `file_path: ${verbose ? input.file_path : relative(getCwd(), input.file_path)}`;
|
|
60
|
-
},
|
|
61
|
-
renderToolResultMessage({ filePath, structuredPatch }) {
|
|
62
|
-
const verbose = false;
|
|
63
|
-
return /* @__PURE__ */ React.createElement(
|
|
64
|
-
FileEditToolUpdatedMessage,
|
|
65
|
-
{
|
|
66
|
-
filePath,
|
|
67
|
-
structuredPatch,
|
|
68
|
-
verbose
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
},
|
|
72
|
-
renderToolUseRejectedMessage({ file_path, old_string, new_string } = {}, { columns, verbose } = {}) {
|
|
73
|
-
try {
|
|
74
|
-
if (!file_path) {
|
|
75
|
-
return /* @__PURE__ */ React.createElement(FallbackToolUseRejectedMessage, null);
|
|
76
|
-
}
|
|
77
|
-
const { patch } = applyEdit(file_path, old_string, new_string);
|
|
78
|
-
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, " ", "\u23BF", " ", /* @__PURE__ */ React.createElement(Text, { color: getTheme().error }, "User rejected ", old_string === "" ? "write" : "update", " to", " "), /* @__PURE__ */ React.createElement(Text, { bold: true }, verbose ? file_path : relative(getCwd(), file_path))), intersperse(
|
|
79
|
-
patch.map((patch2) => /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingLeft: 5, key: patch2.newStart }, /* @__PURE__ */ React.createElement(StructuredDiff, { patch: patch2, dim: true, width: columns - 12 }))),
|
|
80
|
-
(i) => /* @__PURE__ */ React.createElement(Box, { paddingLeft: 5, key: `ellipsis-${i}` }, /* @__PURE__ */ React.createElement(Text, { color: getTheme().secondaryText }, "..."))
|
|
81
|
-
));
|
|
82
|
-
} catch (e) {
|
|
83
|
-
logError(e);
|
|
84
|
-
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, " ", "\u23BF (No changes)"));
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
async validateInput({ file_path, old_string, new_string }, { readFileTimestamps }) {
|
|
88
|
-
if (old_string === new_string) {
|
|
89
|
-
return {
|
|
90
|
-
result: false,
|
|
91
|
-
message: "No changes to make: old_string and new_string are exactly the same.",
|
|
92
|
-
meta: {
|
|
93
|
-
old_string
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const fullFilePath = isAbsolute(file_path) ? file_path : resolve(getCwd(), file_path);
|
|
98
|
-
if (existsSync(fullFilePath) && old_string === "") {
|
|
99
|
-
return {
|
|
100
|
-
result: false,
|
|
101
|
-
message: "Cannot create new file - file already exists."
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if (!existsSync(fullFilePath) && old_string === "") {
|
|
105
|
-
return {
|
|
106
|
-
result: true
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
if (!existsSync(fullFilePath)) {
|
|
110
|
-
const similarFilename = findSimilarFile(fullFilePath);
|
|
111
|
-
let message = "File does not exist.";
|
|
112
|
-
if (similarFilename) {
|
|
113
|
-
message += ` Did you mean ${similarFilename}?`;
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
result: false,
|
|
117
|
-
message
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if (fullFilePath.endsWith(".ipynb")) {
|
|
121
|
-
return {
|
|
122
|
-
result: false,
|
|
123
|
-
message: `File is a Jupyter Notebook. Use the ${NotebookEditTool.name} to edit this file.`
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
const readTimestamp = readFileTimestamps[fullFilePath];
|
|
127
|
-
if (!readTimestamp) {
|
|
128
|
-
return {
|
|
129
|
-
result: false,
|
|
130
|
-
message: "File has not been read yet. Read it first before writing to it.",
|
|
131
|
-
meta: {
|
|
132
|
-
isFilePathAbsolute: String(isAbsolute(file_path))
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
const stats = statSync(fullFilePath);
|
|
137
|
-
const lastWriteTime = stats.mtimeMs;
|
|
138
|
-
if (lastWriteTime > readTimestamp) {
|
|
139
|
-
return {
|
|
140
|
-
result: false,
|
|
141
|
-
message: "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it."
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
const enc = detectFileEncoding(fullFilePath);
|
|
145
|
-
const file = readFileSync(fullFilePath, enc);
|
|
146
|
-
if (!file.includes(old_string)) {
|
|
147
|
-
return {
|
|
148
|
-
result: false,
|
|
149
|
-
message: `String to replace not found in file.`,
|
|
150
|
-
meta: {
|
|
151
|
-
isFilePathAbsolute: String(isAbsolute(file_path))
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
const matches = file.split(old_string).length - 1;
|
|
156
|
-
if (matches > 1) {
|
|
157
|
-
return {
|
|
158
|
-
result: false,
|
|
159
|
-
message: `Found ${matches} matches of the string to replace. For safety, this tool only supports replacing exactly one occurrence at a time. Add more lines of context to your edit and try again.`,
|
|
160
|
-
meta: {
|
|
161
|
-
isFilePathAbsolute: String(isAbsolute(file_path))
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
return { result: true };
|
|
166
|
-
},
|
|
167
|
-
async *call({ file_path, old_string, new_string }, { readFileTimestamps }) {
|
|
168
|
-
const { patch, updatedFile } = applyEdit(file_path, old_string, new_string);
|
|
169
|
-
const fullFilePath = isAbsolute(file_path) ? file_path : resolve(getCwd(), file_path);
|
|
170
|
-
const dir = dirname(fullFilePath);
|
|
171
|
-
mkdirSync(dir, { recursive: true });
|
|
172
|
-
const enc = existsSync(fullFilePath) ? detectFileEncoding(fullFilePath) : "utf8";
|
|
173
|
-
const endings = existsSync(fullFilePath) ? detectLineEndings(fullFilePath) : "LF";
|
|
174
|
-
const originalFile = existsSync(fullFilePath) ? readFileSync(fullFilePath, enc) : "";
|
|
175
|
-
writeTextContent(fullFilePath, updatedFile, enc, endings);
|
|
176
|
-
recordFileEdit(fullFilePath, updatedFile);
|
|
177
|
-
readFileTimestamps[fullFilePath] = statSync(fullFilePath).mtimeMs;
|
|
178
|
-
if (fullFilePath.endsWith(`${sep}${PROJECT_FILE}`)) {
|
|
179
|
-
logEvent("tengu_write_claudemd", {});
|
|
180
|
-
}
|
|
181
|
-
emitReminderEvent("file:edited", {
|
|
182
|
-
filePath: fullFilePath,
|
|
183
|
-
oldString: old_string,
|
|
184
|
-
newString: new_string,
|
|
185
|
-
timestamp: Date.now(),
|
|
186
|
-
operation: old_string === "" ? "create" : new_string === "" ? "delete" : "update"
|
|
187
|
-
});
|
|
188
|
-
const data = {
|
|
189
|
-
filePath: file_path,
|
|
190
|
-
oldString: old_string,
|
|
191
|
-
newString: new_string,
|
|
192
|
-
originalFile,
|
|
193
|
-
structuredPatch: patch
|
|
194
|
-
};
|
|
195
|
-
yield {
|
|
196
|
-
type: "result",
|
|
197
|
-
data,
|
|
198
|
-
resultForAssistant: this.renderResultForAssistant(data)
|
|
199
|
-
};
|
|
200
|
-
},
|
|
201
|
-
renderResultForAssistant({ filePath, originalFile, oldString, newString }) {
|
|
202
|
-
const { snippet, startLine } = getSnippet(
|
|
203
|
-
originalFile || "",
|
|
204
|
-
oldString,
|
|
205
|
-
newString
|
|
206
|
-
);
|
|
207
|
-
return `The file ${filePath} has been updated. Here's the result of running \`cat -n\` on a snippet of the edited file:
|
|
208
|
-
${addLineNumbers({
|
|
209
|
-
content: snippet,
|
|
210
|
-
startLine
|
|
211
|
-
})}`;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
function getSnippet(initialText, oldStr, newStr) {
|
|
215
|
-
const before = initialText.split(oldStr)[0] ?? "";
|
|
216
|
-
const replacementLine = before.split(/\r?\n/).length - 1;
|
|
217
|
-
const newFileLines = initialText.replace(oldStr, newStr).split(/\r?\n/);
|
|
218
|
-
const startLine = Math.max(0, replacementLine - N_LINES_SNIPPET);
|
|
219
|
-
const endLine = replacementLine + N_LINES_SNIPPET + newStr.split(/\r?\n/).length;
|
|
220
|
-
const snippetLines = newFileLines.slice(startLine, endLine + 1);
|
|
221
|
-
const snippet = snippetLines.join("\n");
|
|
222
|
-
return { snippet, startLine: startLine + 1 };
|
|
223
|
-
}
|
|
224
|
-
export {
|
|
225
|
-
FileEditTool,
|
|
226
|
-
getSnippet
|
|
227
|
-
};
|
|
228
|
-
//# sourceMappingURL=FileEditTool.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/tools/FileEditTool/FileEditTool.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Hunk } from 'diff'\nimport { existsSync, mkdirSync, readFileSync, statSync } from 'fs'\nimport { Box, Text } from 'ink'\nimport { dirname, isAbsolute, relative, resolve, sep } from 'path'\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { FileEditToolUpdatedMessage } from '../../components/FileEditToolUpdatedMessage'\nimport { StructuredDiff } from '../../components/StructuredDiff'\nimport { FallbackToolUseRejectedMessage } from '../../components/FallbackToolUseRejectedMessage'\nimport { logEvent } from '../../services/statsig'\nimport { Tool, ValidationResult } from '../../Tool'\nimport { intersperse } from '../../utils/array'\nimport {\n addLineNumbers,\n detectFileEncoding,\n detectLineEndings,\n findSimilarFile,\n writeTextContent,\n} from '../../utils/file.js'\nimport { logError } from '../../utils/log'\nimport { getCwd } from '../../utils/state'\nimport { getTheme } from '../../utils/theme'\nimport { emitReminderEvent } from '../../services/systemReminder'\nimport { recordFileEdit } from '../../services/fileFreshness'\nimport { NotebookEditTool } from '../NotebookEditTool/NotebookEditTool'\nimport { DESCRIPTION } from './prompt'\nimport { applyEdit } from './utils'\nimport { hasWritePermission } from '../../utils/permissions/filesystem'\nimport { PROJECT_FILE } from '../../constants/product'\n\nconst inputSchema = z.strictObject({\n file_path: z.string().describe('The absolute path to the file to modify'),\n old_string: z.string().describe('The text to replace'),\n new_string: z.string().describe('The text to replace it with'),\n})\n\nexport type In = typeof inputSchema\n\n// Number of lines of context to include before/after the change in our result message\nconst N_LINES_SNIPPET = 4\n\nexport const FileEditTool = {\n name: 'Edit',\n async description() {\n return 'A tool for editing files'\n },\n async prompt() {\n return DESCRIPTION\n },\n inputSchema,\n userFacingName() {\n return 'Edit'\n },\n async isEnabled() {\n return true\n },\n isReadOnly() {\n return false\n },\n isConcurrencySafe() {\n return false // FileEdit modifies files, not safe for concurrent execution\n },\n needsPermissions({ file_path }) {\n return !hasWritePermission(file_path)\n },\n renderToolUseMessage(input, { verbose }) {\n return `file_path: ${verbose ? input.file_path : relative(getCwd(), input.file_path)}`\n },\n renderToolResultMessage({ filePath, structuredPatch }) {\n const verbose = false // Set default value for verbose\n return (\n <FileEditToolUpdatedMessage\n filePath={filePath}\n structuredPatch={structuredPatch}\n verbose={verbose}\n />\n )\n },\n renderToolUseRejectedMessage(\n { file_path, old_string, new_string }: any = {},\n { columns, verbose }: any = {},\n ) {\n try {\n if (!file_path) {\n return <FallbackToolUseRejectedMessage />\n }\n const { patch } = applyEdit(file_path, old_string, new_string)\n return (\n <Box flexDirection=\"column\">\n <Text>\n {' '}\u23BF{' '}\n <Text color={getTheme().error}>\n User rejected {old_string === '' ? 'write' : 'update'} to{' '}\n </Text>\n <Text bold>\n {verbose ? file_path : relative(getCwd(), file_path)}\n </Text>\n </Text>\n {intersperse(\n patch.map(patch => (\n <Box flexDirection=\"column\" paddingLeft={5} key={patch.newStart}>\n <StructuredDiff patch={patch} dim={true} width={columns - 12} />\n </Box>\n )),\n i => (\n <Box paddingLeft={5} key={`ellipsis-${i}`}>\n <Text color={getTheme().secondaryText}>...</Text>\n </Box>\n ),\n )}\n </Box>\n )\n } catch (e) {\n // Handle the case where while we were showing the diff, the user manually made the change.\n // TODO: Find a way to show the diff in this case\n logError(e)\n return (\n <Box flexDirection=\"column\">\n <Text>{' '}\u23BF (No changes)</Text>\n </Box>\n )\n }\n },\n async validateInput(\n { file_path, old_string, new_string },\n { readFileTimestamps },\n ) {\n if (old_string === new_string) {\n return {\n result: false,\n message:\n 'No changes to make: old_string and new_string are exactly the same.',\n meta: {\n old_string,\n },\n } as ValidationResult\n }\n\n const fullFilePath = isAbsolute(file_path)\n ? file_path\n : resolve(getCwd(), file_path)\n\n if (existsSync(fullFilePath) && old_string === '') {\n return {\n result: false,\n message: 'Cannot create new file - file already exists.',\n }\n }\n\n if (!existsSync(fullFilePath) && old_string === '') {\n return {\n result: true,\n }\n }\n\n if (!existsSync(fullFilePath)) {\n // Try to find a similar file with a different extension\n const similarFilename = findSimilarFile(fullFilePath)\n let message = 'File does not exist.'\n\n // If we found a similar file, suggest it to the assistant\n if (similarFilename) {\n message += ` Did you mean ${similarFilename}?`\n }\n\n return {\n result: false,\n message,\n }\n }\n\n if (fullFilePath.endsWith('.ipynb')) {\n return {\n result: false,\n message: `File is a Jupyter Notebook. Use the ${NotebookEditTool.name} to edit this file.`,\n }\n }\n\n const readTimestamp = readFileTimestamps[fullFilePath]\n if (!readTimestamp) {\n return {\n result: false,\n message:\n 'File has not been read yet. Read it first before writing to it.',\n meta: {\n isFilePathAbsolute: String(isAbsolute(file_path)),\n },\n }\n }\n\n // Check if file exists and get its last modified time\n const stats = statSync(fullFilePath)\n const lastWriteTime = stats.mtimeMs\n if (lastWriteTime > readTimestamp) {\n return {\n result: false,\n message:\n 'File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.',\n }\n }\n\n const enc = detectFileEncoding(fullFilePath)\n const file = readFileSync(fullFilePath, enc)\n if (!file.includes(old_string)) {\n return {\n result: false,\n message: `String to replace not found in file.`,\n meta: {\n isFilePathAbsolute: String(isAbsolute(file_path)),\n },\n }\n }\n\n const matches = file.split(old_string).length - 1\n if (matches > 1) {\n return {\n result: false,\n message: `Found ${matches} matches of the string to replace. For safety, this tool only supports replacing exactly one occurrence at a time. Add more lines of context to your edit and try again.`,\n meta: {\n isFilePathAbsolute: String(isAbsolute(file_path)),\n },\n }\n }\n\n return { result: true }\n },\n async *call({ file_path, old_string, new_string }, { readFileTimestamps }) {\n const { patch, updatedFile } = applyEdit(file_path, old_string, new_string)\n\n const fullFilePath = isAbsolute(file_path)\n ? file_path\n : resolve(getCwd(), file_path)\n const dir = dirname(fullFilePath)\n mkdirSync(dir, { recursive: true })\n const enc = existsSync(fullFilePath)\n ? detectFileEncoding(fullFilePath)\n : 'utf8'\n const endings = existsSync(fullFilePath)\n ? detectLineEndings(fullFilePath)\n : 'LF'\n const originalFile = existsSync(fullFilePath)\n ? readFileSync(fullFilePath, enc)\n : ''\n writeTextContent(fullFilePath, updatedFile, enc, endings)\n\n // Record Agent edit operation for file freshness tracking\n recordFileEdit(fullFilePath, updatedFile)\n\n // Update read timestamp, to invalidate stale writes\n readFileTimestamps[fullFilePath] = statSync(fullFilePath).mtimeMs\n\n // Log when editing CLAUDE.md\n if (fullFilePath.endsWith(`${sep}${PROJECT_FILE}`)) {\n logEvent('tengu_write_claudemd', {})\n }\n\n // Emit file edited event for system reminders\n emitReminderEvent('file:edited', {\n filePath: fullFilePath,\n oldString: old_string,\n newString: new_string,\n timestamp: Date.now(),\n operation:\n old_string === '' ? 'create' : new_string === '' ? 'delete' : 'update',\n })\n\n const data = {\n filePath: file_path,\n oldString: old_string,\n newString: new_string,\n originalFile,\n structuredPatch: patch,\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n },\n renderResultForAssistant({ filePath, originalFile, oldString, newString }) {\n const { snippet, startLine } = getSnippet(\n originalFile || '',\n oldString,\n newString,\n )\n return `The file ${filePath} has been updated. Here's the result of running \\`cat -n\\` on a snippet of the edited file:\n${addLineNumbers({\n content: snippet,\n startLine,\n})}`\n },\n} satisfies Tool<\n typeof inputSchema,\n {\n filePath: string\n oldString: string\n newString: string\n originalFile: string\n structuredPatch: Hunk[]\n }\n>\n\nexport function getSnippet(\n initialText: string,\n oldStr: string,\n newStr: string,\n): { snippet: string; startLine: number } {\n const before = initialText.split(oldStr)[0] ?? ''\n const replacementLine = before.split(/\\r?\\n/).length - 1\n const newFileLines = initialText.replace(oldStr, newStr).split(/\\r?\\n/)\n // Calculate the start and end line numbers for the snippet\n const startLine = Math.max(0, replacementLine - N_LINES_SNIPPET)\n const endLine =\n replacementLine + N_LINES_SNIPPET + newStr.split(/\\r?\\n/).length\n // Get snippet\n const snippetLines = newFileLines.slice(startLine, endLine + 1)\n const snippet = snippetLines.join('\\n')\n return { snippet, startLine: startLine + 1 }\n}\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["patch"]
|
|
7
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { NotebookEditTool } from "../NotebookEditTool/NotebookEditTool.js";
|
|
2
|
-
const DESCRIPTION = `This is a tool for editing files. For moving or renaming files, you should generally use the Bash tool with the 'mv' command instead. For larger edits, use the Write tool to overwrite files. For Jupyter notebooks (.ipynb files), use the ${NotebookEditTool.name} instead.
|
|
3
|
-
|
|
4
|
-
Before using this tool:
|
|
5
|
-
|
|
6
|
-
1. Use the View tool to understand the file's contents and context
|
|
7
|
-
|
|
8
|
-
2. Verify the directory path is correct (only applicable when creating new files):
|
|
9
|
-
- Use the LS tool to verify the parent directory exists and is the correct location
|
|
10
|
-
|
|
11
|
-
To make a file edit, provide the following:
|
|
12
|
-
1. file_path: The absolute path to the file to modify (must be absolute, not relative)
|
|
13
|
-
2. old_string: The text to replace (must be unique within the file, and must match the file contents exactly, including all whitespace and indentation)
|
|
14
|
-
3. new_string: The edited text to replace the old_string
|
|
15
|
-
|
|
16
|
-
The tool will replace ONE occurrence of old_string with new_string in the specified file.
|
|
17
|
-
|
|
18
|
-
CRITICAL REQUIREMENTS FOR USING THIS TOOL:
|
|
19
|
-
|
|
20
|
-
1. UNIQUENESS: The old_string MUST uniquely identify the specific instance you want to change. This means:
|
|
21
|
-
- Include AT LEAST 3-5 lines of context BEFORE the change point
|
|
22
|
-
- Include AT LEAST 3-5 lines of context AFTER the change point
|
|
23
|
-
- Include all whitespace, indentation, and surrounding code exactly as it appears in the file
|
|
24
|
-
|
|
25
|
-
2. SINGLE INSTANCE: This tool can only change ONE instance at a time. If you need to change multiple instances:
|
|
26
|
-
- Make separate calls to this tool for each instance
|
|
27
|
-
- Each call must uniquely identify its specific instance using extensive context
|
|
28
|
-
|
|
29
|
-
3. VERIFICATION: Before using this tool:
|
|
30
|
-
- Check how many instances of the target text exist in the file
|
|
31
|
-
- If multiple instances exist, gather enough context to uniquely identify each one
|
|
32
|
-
- Plan separate tool calls for each instance
|
|
33
|
-
|
|
34
|
-
WARNING: If you do not follow these requirements:
|
|
35
|
-
- The tool will fail if old_string matches multiple locations
|
|
36
|
-
- The tool will fail if old_string doesn't match exactly (including whitespace)
|
|
37
|
-
- You may change the wrong instance if you don't include enough context
|
|
38
|
-
|
|
39
|
-
When making edits:
|
|
40
|
-
- Ensure the edit results in idiomatic, correct code
|
|
41
|
-
- Do not leave the code in a broken state
|
|
42
|
-
- Always use absolute file paths (starting with /)
|
|
43
|
-
|
|
44
|
-
If you want to create a new file, use:
|
|
45
|
-
- A new file path, including dir name if needed
|
|
46
|
-
- An empty old_string
|
|
47
|
-
- The new file's contents as new_string
|
|
48
|
-
|
|
49
|
-
Remember: when making multiple file edits in a row to the same file, you should prefer to send all edits in a single message with multiple calls to this tool, rather than multiple messages with a single call each.
|
|
50
|
-
`;
|
|
51
|
-
export {
|
|
52
|
-
DESCRIPTION
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=prompt.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/tools/FileEditTool/prompt.ts"],
|
|
4
|
-
"sourcesContent": ["import { NotebookEditTool } from '../NotebookEditTool/NotebookEditTool'\n\nexport const DESCRIPTION = `This is a tool for editing files. For moving or renaming files, you should generally use the Bash tool with the 'mv' command instead. For larger edits, use the Write tool to overwrite files. For Jupyter notebooks (.ipynb files), use the ${NotebookEditTool.name} instead.\n\nBefore using this tool:\n\n1. Use the View tool to understand the file's contents and context\n\n2. Verify the directory path is correct (only applicable when creating new files):\n - Use the LS tool to verify the parent directory exists and is the correct location\n\nTo make a file edit, provide the following:\n1. file_path: The absolute path to the file to modify (must be absolute, not relative)\n2. old_string: The text to replace (must be unique within the file, and must match the file contents exactly, including all whitespace and indentation)\n3. new_string: The edited text to replace the old_string\n\nThe tool will replace ONE occurrence of old_string with new_string in the specified file.\n\nCRITICAL REQUIREMENTS FOR USING THIS TOOL:\n\n1. UNIQUENESS: The old_string MUST uniquely identify the specific instance you want to change. This means:\n - Include AT LEAST 3-5 lines of context BEFORE the change point\n - Include AT LEAST 3-5 lines of context AFTER the change point\n - Include all whitespace, indentation, and surrounding code exactly as it appears in the file\n\n2. SINGLE INSTANCE: This tool can only change ONE instance at a time. If you need to change multiple instances:\n - Make separate calls to this tool for each instance\n - Each call must uniquely identify its specific instance using extensive context\n\n3. VERIFICATION: Before using this tool:\n - Check how many instances of the target text exist in the file\n - If multiple instances exist, gather enough context to uniquely identify each one\n - Plan separate tool calls for each instance\n\nWARNING: If you do not follow these requirements:\n - The tool will fail if old_string matches multiple locations\n - The tool will fail if old_string doesn't match exactly (including whitespace)\n - You may change the wrong instance if you don't include enough context\n\nWhen making edits:\n - Ensure the edit results in idiomatic, correct code\n - Do not leave the code in a broken state\n - Always use absolute file paths (starting with /)\n\nIf you want to create a new file, use:\n - A new file path, including dir name if needed\n - An empty old_string\n - The new file's contents as new_string\n\nRemember: when making multiple file edits in a row to the same file, you should prefer to send all edits in a single message with multiple calls to this tool, rather than multiple messages with a single call each.\n`\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,wBAAwB;AAE1B,MAAM,cAAc,gPAAgP,iBAAiB,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, resolve } from "path";
|
|
2
|
-
import { getCwd } from "../../utils/state.js";
|
|
3
|
-
import { readFileSync } from "fs";
|
|
4
|
-
import { detectFileEncoding } from "../../utils/file.js";
|
|
5
|
-
import { getPatch } from "../../utils/diff.js";
|
|
6
|
-
function applyEdit(file_path, old_string, new_string) {
|
|
7
|
-
const fullFilePath = isAbsolute(file_path) ? file_path : resolve(getCwd(), file_path);
|
|
8
|
-
let originalFile;
|
|
9
|
-
let updatedFile;
|
|
10
|
-
if (old_string === "") {
|
|
11
|
-
originalFile = "";
|
|
12
|
-
updatedFile = new_string;
|
|
13
|
-
} else {
|
|
14
|
-
const enc = detectFileEncoding(fullFilePath);
|
|
15
|
-
originalFile = readFileSync(fullFilePath, enc);
|
|
16
|
-
if (new_string === "") {
|
|
17
|
-
if (!old_string.endsWith("\n") && originalFile.includes(old_string + "\n")) {
|
|
18
|
-
updatedFile = originalFile.replace(old_string + "\n", () => new_string);
|
|
19
|
-
} else {
|
|
20
|
-
updatedFile = originalFile.replace(old_string, () => new_string);
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
updatedFile = originalFile.replace(old_string, () => new_string);
|
|
24
|
-
}
|
|
25
|
-
if (updatedFile === originalFile) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
"Original and edited file match exactly. Failed to apply edit."
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const patch = getPatch({
|
|
32
|
-
filePath: file_path,
|
|
33
|
-
fileContents: originalFile,
|
|
34
|
-
oldStr: originalFile,
|
|
35
|
-
newStr: updatedFile
|
|
36
|
-
});
|
|
37
|
-
return { patch, updatedFile };
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
applyEdit
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/tools/FileEditTool/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { isAbsolute, resolve } from 'path'\nimport { getCwd } from '../../utils/state'\nimport { readFileSync } from 'fs'\nimport { detectFileEncoding } from '../../utils/file'\nimport { type Hunk } from 'diff'\nimport { getPatch } from '../../utils/diff'\n\n/**\n * Applies an edit to a file and returns the patch and updated file.\n * Does not write the file to disk.\n */\nexport function applyEdit(\n file_path: string,\n old_string: string,\n new_string: string,\n): { patch: Hunk[]; updatedFile: string } {\n const fullFilePath = isAbsolute(file_path)\n ? file_path\n : resolve(getCwd(), file_path)\n\n let originalFile\n let updatedFile\n if (old_string === '') {\n // Create new file\n originalFile = ''\n updatedFile = new_string\n } else {\n // Edit existing file\n const enc = detectFileEncoding(fullFilePath)\n originalFile = readFileSync(fullFilePath, enc)\n if (new_string === '') {\n if (\n !old_string.endsWith('\\n') &&\n originalFile.includes(old_string + '\\n')\n ) {\n updatedFile = originalFile.replace(old_string + '\\n', () => new_string)\n } else {\n updatedFile = originalFile.replace(old_string, () => new_string)\n }\n } else {\n updatedFile = originalFile.replace(old_string, () => new_string)\n }\n if (updatedFile === originalFile) {\n throw new Error(\n 'Original and edited file match exactly. Failed to apply edit.',\n )\n }\n }\n\n const patch = getPatch({\n filePath: file_path,\n fileContents: originalFile,\n oldStr: originalFile,\n newStr: updatedFile,\n })\n\n return { patch, updatedFile }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY,eAAe;AACpC,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAEnC,SAAS,gBAAgB;AAMlB,SAAS,UACd,WACA,YACA,YACwC;AACxC,QAAM,eAAe,WAAW,SAAS,IACrC,YACA,QAAQ,OAAO,GAAG,SAAS;AAE/B,MAAI;AACJ,MAAI;AACJ,MAAI,eAAe,IAAI;AAErB,mBAAe;AACf,kBAAc;AAAA,EAChB,OAAO;AAEL,UAAM,MAAM,mBAAmB,YAAY;AAC3C,mBAAe,aAAa,cAAc,GAAG;AAC7C,QAAI,eAAe,IAAI;AACrB,UACE,CAAC,WAAW,SAAS,IAAI,KACzB,aAAa,SAAS,aAAa,IAAI,GACvC;AACA,sBAAc,aAAa,QAAQ,aAAa,MAAM,MAAM,UAAU;AAAA,MACxE,OAAO;AACL,sBAAc,aAAa,QAAQ,YAAY,MAAM,UAAU;AAAA,MACjE;AAAA,IACF,OAAO;AACL,oBAAc,aAAa,QAAQ,YAAY,MAAM,UAAU;AAAA,IACjE;AACA,QAAI,gBAAgB,cAAc;AAChC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,QAAQ,SAAS;AAAA,IACrB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,SAAO,EAAE,OAAO,YAAY;AAC9B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { statSync } from "node:fs";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import { extname, relative } from "node:path";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { FallbackToolUseRejectedMessage } from "../../components/FallbackToolUseRejectedMessage.js";
|
|
8
|
-
import { HighlightedCode } from "../../components/HighlightedCode.js";
|
|
9
|
-
import { getCwd } from "../../utils/state.js";
|
|
10
|
-
import {
|
|
11
|
-
addLineNumbers,
|
|
12
|
-
findSimilarFile,
|
|
13
|
-
normalizeFilePath,
|
|
14
|
-
readTextContent
|
|
15
|
-
} from "../../utils/file.js";
|
|
16
|
-
import { logError } from "../../utils/log.js";
|
|
17
|
-
import { getTheme } from "../../utils/theme.js";
|
|
18
|
-
import { emitReminderEvent } from "../../services/systemReminder.js";
|
|
19
|
-
import {
|
|
20
|
-
recordFileRead,
|
|
21
|
-
generateFileModificationReminder
|
|
22
|
-
} from "../../services/fileFreshness.js";
|
|
23
|
-
import { DESCRIPTION, PROMPT } from "./prompt.js";
|
|
24
|
-
import { hasReadPermission } from "../../utils/permissions/filesystem.js";
|
|
25
|
-
import { secureFileService } from "../../utils/secureFile.js";
|
|
26
|
-
const MAX_LINES_TO_RENDER = 5;
|
|
27
|
-
const MAX_OUTPUT_SIZE = 0.25 * 1024 * 1024;
|
|
28
|
-
const IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
29
|
-
".png",
|
|
30
|
-
".jpg",
|
|
31
|
-
".jpeg",
|
|
32
|
-
".gif",
|
|
33
|
-
".bmp",
|
|
34
|
-
".webp"
|
|
35
|
-
]);
|
|
36
|
-
const MAX_WIDTH = 2e3;
|
|
37
|
-
const MAX_HEIGHT = 2e3;
|
|
38
|
-
const MAX_IMAGE_SIZE = 3.75 * 1024 * 1024;
|
|
39
|
-
const inputSchema = z.strictObject({
|
|
40
|
-
file_path: z.string().describe("The absolute path to the file to read"),
|
|
41
|
-
offset: z.number().optional().describe(
|
|
42
|
-
"The line number to start reading from. Only provide if the file is too large to read at once"
|
|
43
|
-
),
|
|
44
|
-
limit: z.number().optional().describe(
|
|
45
|
-
"The number of lines to read. Only provide if the file is too large to read at once."
|
|
46
|
-
)
|
|
47
|
-
});
|
|
48
|
-
const FileReadTool = {
|
|
49
|
-
name: "View",
|
|
50
|
-
async description() {
|
|
51
|
-
return DESCRIPTION;
|
|
52
|
-
},
|
|
53
|
-
async prompt() {
|
|
54
|
-
return PROMPT;
|
|
55
|
-
},
|
|
56
|
-
inputSchema,
|
|
57
|
-
isReadOnly() {
|
|
58
|
-
return true;
|
|
59
|
-
},
|
|
60
|
-
isConcurrencySafe() {
|
|
61
|
-
return true;
|
|
62
|
-
},
|
|
63
|
-
userFacingName() {
|
|
64
|
-
return "Read";
|
|
65
|
-
},
|
|
66
|
-
async isEnabled() {
|
|
67
|
-
return true;
|
|
68
|
-
},
|
|
69
|
-
needsPermissions({ file_path }) {
|
|
70
|
-
return !hasReadPermission(file_path || getCwd());
|
|
71
|
-
},
|
|
72
|
-
renderToolUseMessage(input, { verbose }) {
|
|
73
|
-
const { file_path, ...rest } = input;
|
|
74
|
-
const entries = [
|
|
75
|
-
["file_path", verbose ? file_path : relative(getCwd(), file_path)],
|
|
76
|
-
...Object.entries(rest)
|
|
77
|
-
];
|
|
78
|
-
return entries.map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(", ");
|
|
79
|
-
},
|
|
80
|
-
renderToolResultMessage(output) {
|
|
81
|
-
const verbose = false;
|
|
82
|
-
switch (output.type) {
|
|
83
|
-
case "image":
|
|
84
|
-
return /* @__PURE__ */ React.createElement(Box, { justifyContent: "space-between", overflowX: "hidden", width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React.createElement(Text, null, "Read image")));
|
|
85
|
-
case "text": {
|
|
86
|
-
const { filePath, content, numLines } = output.file;
|
|
87
|
-
const contentWithFallback = content || "(No content)";
|
|
88
|
-
return /* @__PURE__ */ React.createElement(Box, { justifyContent: "space-between", overflowX: "hidden", width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(
|
|
89
|
-
HighlightedCode,
|
|
90
|
-
{
|
|
91
|
-
code: verbose ? contentWithFallback : contentWithFallback.split("\n").slice(0, MAX_LINES_TO_RENDER).filter((_) => _.trim() !== "").join("\n"),
|
|
92
|
-
language: extname(filePath).slice(1)
|
|
93
|
-
}
|
|
94
|
-
), !verbose && numLines > MAX_LINES_TO_RENDER && /* @__PURE__ */ React.createElement(Text, { color: getTheme().secondaryText }, "... (+", numLines - MAX_LINES_TO_RENDER, " lines)"))));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
renderToolUseRejectedMessage() {
|
|
99
|
-
return /* @__PURE__ */ React.createElement(FallbackToolUseRejectedMessage, null);
|
|
100
|
-
},
|
|
101
|
-
async validateInput({ file_path, offset, limit }) {
|
|
102
|
-
const fullFilePath = normalizeFilePath(file_path);
|
|
103
|
-
const fileCheck = secureFileService.safeGetFileInfo(fullFilePath);
|
|
104
|
-
if (!fileCheck.success) {
|
|
105
|
-
const similarFilename = findSimilarFile(fullFilePath);
|
|
106
|
-
let message = "File does not exist.";
|
|
107
|
-
if (similarFilename) {
|
|
108
|
-
message += ` Did you mean ${similarFilename}?`;
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
result: false,
|
|
112
|
-
message
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
const stats = fileCheck.stats;
|
|
116
|
-
const fileSize = stats.size;
|
|
117
|
-
const ext = path.extname(fullFilePath).toLowerCase();
|
|
118
|
-
if (!IMAGE_EXTENSIONS.has(ext)) {
|
|
119
|
-
if (fileSize > MAX_OUTPUT_SIZE && !offset && !limit) {
|
|
120
|
-
return {
|
|
121
|
-
result: false,
|
|
122
|
-
message: formatFileSizeError(fileSize),
|
|
123
|
-
meta: { fileSize }
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return { result: true };
|
|
128
|
-
},
|
|
129
|
-
async *call({ file_path, offset = 1, limit = void 0 }, { readFileTimestamps }) {
|
|
130
|
-
const ext = path.extname(file_path).toLowerCase();
|
|
131
|
-
const fullFilePath = normalizeFilePath(file_path);
|
|
132
|
-
recordFileRead(fullFilePath);
|
|
133
|
-
emitReminderEvent("file:read", {
|
|
134
|
-
filePath: fullFilePath,
|
|
135
|
-
extension: ext,
|
|
136
|
-
timestamp: Date.now()
|
|
137
|
-
});
|
|
138
|
-
readFileTimestamps[fullFilePath] = Date.now();
|
|
139
|
-
const modificationReminder = generateFileModificationReminder(fullFilePath);
|
|
140
|
-
if (modificationReminder) {
|
|
141
|
-
emitReminderEvent("file:modified", {
|
|
142
|
-
filePath: fullFilePath,
|
|
143
|
-
reminder: modificationReminder,
|
|
144
|
-
timestamp: Date.now()
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (IMAGE_EXTENSIONS.has(ext)) {
|
|
148
|
-
const data2 = await readImage(fullFilePath, ext);
|
|
149
|
-
yield {
|
|
150
|
-
type: "result",
|
|
151
|
-
data: data2,
|
|
152
|
-
resultForAssistant: this.renderResultForAssistant(data2)
|
|
153
|
-
};
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const lineOffset = offset === 0 ? 0 : offset - 1;
|
|
157
|
-
const { content, lineCount, totalLines } = readTextContent(
|
|
158
|
-
fullFilePath,
|
|
159
|
-
lineOffset,
|
|
160
|
-
limit
|
|
161
|
-
);
|
|
162
|
-
if (!IMAGE_EXTENSIONS.has(ext) && content.length > MAX_OUTPUT_SIZE) {
|
|
163
|
-
throw new Error(formatFileSizeError(content.length));
|
|
164
|
-
}
|
|
165
|
-
const data = {
|
|
166
|
-
type: "text",
|
|
167
|
-
file: {
|
|
168
|
-
filePath: file_path,
|
|
169
|
-
content,
|
|
170
|
-
numLines: lineCount,
|
|
171
|
-
startLine: offset,
|
|
172
|
-
totalLines
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
yield {
|
|
176
|
-
type: "result",
|
|
177
|
-
data,
|
|
178
|
-
resultForAssistant: this.renderResultForAssistant(data)
|
|
179
|
-
};
|
|
180
|
-
},
|
|
181
|
-
renderResultForAssistant(data) {
|
|
182
|
-
switch (data.type) {
|
|
183
|
-
case "image":
|
|
184
|
-
return [
|
|
185
|
-
{
|
|
186
|
-
type: "image",
|
|
187
|
-
source: {
|
|
188
|
-
type: "base64",
|
|
189
|
-
data: data.file.base64,
|
|
190
|
-
media_type: data.file.type
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
];
|
|
194
|
-
case "text":
|
|
195
|
-
return addLineNumbers(data.file);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
const formatFileSizeError = (sizeInBytes) => `File content (${Math.round(sizeInBytes / 1024)}KB) exceeds maximum allowed size (${Math.round(MAX_OUTPUT_SIZE / 1024)}KB). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.`;
|
|
200
|
-
function createImageResponse(buffer, ext) {
|
|
201
|
-
return {
|
|
202
|
-
type: "image",
|
|
203
|
-
file: {
|
|
204
|
-
base64: buffer.toString("base64"),
|
|
205
|
-
type: `image/${ext.slice(1)}`
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
async function readImage(filePath, ext) {
|
|
210
|
-
try {
|
|
211
|
-
const stats = statSync(filePath);
|
|
212
|
-
const sharp = (await import("sharp")).default;
|
|
213
|
-
const fileReadResult = secureFileService.safeReadFile(filePath, {
|
|
214
|
-
encoding: "buffer",
|
|
215
|
-
maxFileSize: MAX_IMAGE_SIZE
|
|
216
|
-
});
|
|
217
|
-
if (!fileReadResult.success) {
|
|
218
|
-
throw new Error(`Failed to read image file: ${fileReadResult.error}`);
|
|
219
|
-
}
|
|
220
|
-
const image = sharp(fileReadResult.content);
|
|
221
|
-
const metadata = await image.metadata();
|
|
222
|
-
if (!metadata.width || !metadata.height) {
|
|
223
|
-
if (stats.size > MAX_IMAGE_SIZE) {
|
|
224
|
-
const compressedBuffer = await image.jpeg({ quality: 80 }).toBuffer();
|
|
225
|
-
return createImageResponse(compressedBuffer, "jpeg");
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
let width = metadata.width || 0;
|
|
229
|
-
let height = metadata.height || 0;
|
|
230
|
-
if (stats.size <= MAX_IMAGE_SIZE && width <= MAX_WIDTH && height <= MAX_HEIGHT) {
|
|
231
|
-
const fileReadResult2 = secureFileService.safeReadFile(filePath, {
|
|
232
|
-
encoding: "buffer",
|
|
233
|
-
maxFileSize: MAX_IMAGE_SIZE
|
|
234
|
-
});
|
|
235
|
-
if (!fileReadResult2.success) {
|
|
236
|
-
throw new Error(`Failed to read image file: ${fileReadResult2.error}`);
|
|
237
|
-
}
|
|
238
|
-
return createImageResponse(fileReadResult2.content, ext);
|
|
239
|
-
}
|
|
240
|
-
if (width > MAX_WIDTH) {
|
|
241
|
-
height = Math.round(height * MAX_WIDTH / width);
|
|
242
|
-
width = MAX_WIDTH;
|
|
243
|
-
}
|
|
244
|
-
if (height > MAX_HEIGHT) {
|
|
245
|
-
width = Math.round(width * MAX_HEIGHT / height);
|
|
246
|
-
height = MAX_HEIGHT;
|
|
247
|
-
}
|
|
248
|
-
const resizedImageBuffer = await image.resize(width, height, {
|
|
249
|
-
fit: "inside",
|
|
250
|
-
withoutEnlargement: true
|
|
251
|
-
}).toBuffer();
|
|
252
|
-
if (resizedImageBuffer.length > MAX_IMAGE_SIZE) {
|
|
253
|
-
const compressedBuffer = await image.jpeg({ quality: 80 }).toBuffer();
|
|
254
|
-
return createImageResponse(compressedBuffer, "jpeg");
|
|
255
|
-
}
|
|
256
|
-
return createImageResponse(resizedImageBuffer, ext);
|
|
257
|
-
} catch (e) {
|
|
258
|
-
logError(e);
|
|
259
|
-
const fileReadResult = secureFileService.safeReadFile(filePath, {
|
|
260
|
-
encoding: "buffer",
|
|
261
|
-
maxFileSize: MAX_IMAGE_SIZE
|
|
262
|
-
});
|
|
263
|
-
if (!fileReadResult.success) {
|
|
264
|
-
throw new Error(`Failed to read image file: ${fileReadResult.error}`);
|
|
265
|
-
}
|
|
266
|
-
return createImageResponse(fileReadResult.content, ext);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
export {
|
|
270
|
-
FileReadTool
|
|
271
|
-
};
|
|
272
|
-
//# sourceMappingURL=FileReadTool.js.map
|