@sunub/obsidian-mcp-server 0.3.19 → 0.3.20
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/build/cli/App.d.ts +1 -0
- package/build/cli/App.js +247 -0
- package/build/cli/App.js.map +1 -0
- package/build/cli/AppContainer.d.ts +1 -0
- package/build/cli/AppContainer.js +19 -0
- package/build/cli/AppContainer.js.map +1 -0
- package/build/cli/colors.d.ts +15 -0
- package/build/cli/colors.js +15 -0
- package/build/cli/colors.js.map +1 -0
- package/build/cli/commands/types.d.ts +19 -0
- package/build/cli/commands/types.js +11 -0
- package/build/cli/commands/types.js.map +1 -0
- package/build/cli/config/SettingContext.d.ts +1 -0
- package/build/cli/config/SettingContext.js +2 -0
- package/build/cli/config/SettingContext.js.map +1 -0
- package/build/cli/config/mcpServersConfig.d.ts +30 -0
- package/build/cli/config/mcpServersConfig.js +123 -0
- package/build/cli/config/mcpServersConfig.js.map +1 -0
- package/build/cli/config/settingSchema.d.ts +180 -0
- package/build/cli/config/settingSchema.js +128 -0
- package/build/cli/config/settingSchema.js.map +1 -0
- package/build/cli/constants.d.ts +47 -0
- package/build/cli/constants.js +101 -0
- package/build/cli/constants.js.map +1 -0
- package/build/cli/context/InputContext.d.ts +12 -0
- package/build/cli/context/InputContext.js +10 -0
- package/build/cli/context/InputContext.js.map +1 -0
- package/build/cli/context/KeypressContext.d.ts +30 -0
- package/build/cli/context/KeypressContext.js +200 -0
- package/build/cli/context/KeypressContext.js.map +1 -0
- package/build/cli/context/KeypressContext.util.d.ts +7 -0
- package/build/cli/context/KeypressContext.util.js +476 -0
- package/build/cli/context/KeypressContext.util.js.map +1 -0
- package/build/cli/errors/index.d.ts +3 -0
- package/build/cli/errors/index.js +7 -0
- package/build/cli/errors/index.js.map +1 -0
- package/build/cli/hooks/useAtCompletion.d.ts +12 -0
- package/build/cli/hooks/useAtCompletion.js +5 -0
- package/build/cli/hooks/useAtCompletion.js.map +1 -0
- package/build/cli/hooks/useCommandCompletion.d.ts +59 -0
- package/build/cli/hooks/useCommandCompletion.js +344 -0
- package/build/cli/hooks/useCommandCompletion.js.map +1 -0
- package/build/cli/hooks/useCompletion.d.ts +22 -0
- package/build/cli/hooks/useCompletion.js +84 -0
- package/build/cli/hooks/useCompletion.js.map +1 -0
- package/build/cli/hooks/useDispatcher.d.ts +6 -0
- package/build/cli/hooks/useDispatcher.js +286 -0
- package/build/cli/hooks/useDispatcher.js.map +1 -0
- package/build/cli/hooks/useFocus.d.ts +2 -0
- package/build/cli/hooks/useFocus.js +3 -0
- package/build/cli/hooks/useFocus.js.map +1 -0
- package/build/cli/hooks/useHistoryManager.d.ts +32 -0
- package/build/cli/hooks/useHistoryManager.js +78 -0
- package/build/cli/hooks/useHistoryManager.js.map +1 -0
- package/build/cli/hooks/useInputHistory.d.ts +24 -0
- package/build/cli/hooks/useInputHistory.js +159 -0
- package/build/cli/hooks/useInputHistory.js.map +1 -0
- package/build/cli/hooks/useKeyMatchers.d.ts +17 -0
- package/build/cli/hooks/useKeyMatchers.js +18 -0
- package/build/cli/hooks/useKeyMatchers.js.map +1 -0
- package/build/cli/hooks/useKeypress.d.ts +19 -0
- package/build/cli/hooks/useKeypress.js +28 -0
- package/build/cli/hooks/useKeypress.js.map +1 -0
- package/build/cli/hooks/useLlmStream/constants.d.ts +4 -0
- package/build/cli/hooks/useLlmStream/constants.js +5 -0
- package/build/cli/hooks/useLlmStream/constants.js.map +1 -0
- package/build/cli/hooks/useLlmStream/index.d.ts +2 -0
- package/build/cli/hooks/useLlmStream/index.js +2 -0
- package/build/cli/hooks/useLlmStream/index.js.map +1 -0
- package/build/cli/hooks/useLlmStream/llmService.d.ts +2 -0
- package/build/cli/hooks/useLlmStream/llmService.js +111 -0
- package/build/cli/hooks/useLlmStream/llmService.js.map +1 -0
- package/build/cli/hooks/useLlmStream/types.d.ts +38 -0
- package/build/cli/hooks/useLlmStream/types.js.map +1 -0
- package/build/cli/hooks/useLlmStream/useLlmStream.d.ts +12 -0
- package/build/cli/hooks/useLlmStream/useLlmStream.js +175 -0
- package/build/cli/hooks/useLlmStream/useLlmStream.js.map +1 -0
- package/build/cli/hooks/useLlmStream/utils.d.ts +17 -0
- package/build/cli/hooks/useLlmStream/utils.js +142 -0
- package/build/cli/hooks/useLlmStream/utils.js.map +1 -0
- package/build/cli/hooks/useMcpClient.d.ts +10 -0
- package/build/cli/hooks/useMcpClient.js +102 -0
- package/build/cli/hooks/useMcpClient.js.map +1 -0
- package/build/cli/hooks/useMcpManager.d.ts +26 -0
- package/build/cli/hooks/useMcpManager.js +89 -0
- package/build/cli/hooks/useMcpManager.js.map +1 -0
- package/build/cli/hooks/usePromptCompletion.d.ts +19 -0
- package/build/cli/hooks/usePromptCompletion.js +13 -0
- package/build/cli/hooks/usePromptCompletion.js.map +1 -0
- package/build/cli/hooks/useRagContext.d.ts +6 -0
- package/build/cli/hooks/useRagContext.js +84 -0
- package/build/cli/hooks/useRagContext.js.map +1 -0
- package/build/cli/hooks/useShellCompletion.d.ts +18 -0
- package/build/cli/hooks/useShellCompletion.js +10 -0
- package/build/cli/hooks/useShellCompletion.js.map +1 -0
- package/build/cli/hooks/useSlashCompletion.d.ts +21 -0
- package/build/cli/hooks/useSlashCompletion.js +11 -0
- package/build/cli/hooks/useSlashCompletion.js.map +1 -0
- package/build/cli/hooks/useTerminalSize.d.ts +4 -0
- package/build/cli/hooks/useTerminalSize.js +21 -0
- package/build/cli/hooks/useTerminalSize.js.map +1 -0
- package/build/cli/index.d.ts +1 -0
- package/build/cli/index.js +26 -0
- package/build/cli/index.js.map +1 -0
- package/build/cli/key/input.d.ts +5 -0
- package/build/cli/key/input.js +9 -0
- package/build/cli/key/input.js.map +1 -0
- package/build/cli/key/keyBindings.d.ts +152 -0
- package/build/cli/key/keyBindings.js +630 -0
- package/build/cli/key/keyBindings.js.map +1 -0
- package/build/cli/key/keyMatchers.d.ts +19 -0
- package/build/cli/key/keyMatchers.js +25 -0
- package/build/cli/key/keyMatchers.js.map +1 -0
- package/build/cli/key/mouse.d.ts +23 -0
- package/build/cli/key/mouse.js +155 -0
- package/build/cli/key/mouse.js.map +1 -0
- package/build/cli/key/text-buffer.d.ts +156 -0
- package/build/cli/key/text-buffer.js +937 -0
- package/build/cli/key/text-buffer.js.map +1 -0
- package/build/cli/main.d.ts +1 -0
- package/build/cli/main.js +20 -0
- package/build/cli/main.js.map +1 -0
- package/build/cli/services/McpClientService.d.ts +32 -0
- package/build/cli/services/McpClientService.js +123 -0
- package/build/cli/services/McpClientService.js.map +1 -0
- package/build/cli/services/McpManager.d.ts +28 -0
- package/build/cli/services/McpManager.js +146 -0
- package/build/cli/services/McpManager.js.map +1 -0
- package/build/cli/theme/builtin/default-dark.d.ts +7 -0
- package/build/cli/theme/builtin/default-dark.js +143 -0
- package/build/cli/theme/builtin/default-dark.js.map +1 -0
- package/build/cli/theme/builtin/no-color.d.ts +7 -0
- package/build/cli/theme/builtin/no-color.js +125 -0
- package/build/cli/theme/builtin/no-color.js.map +1 -0
- package/build/cli/theme/builtin/tokyonight-dark.d.ts +7 -0
- package/build/cli/theme/builtin/tokyonight-dark.js +146 -0
- package/build/cli/theme/builtin/tokyonight-dark.js.map +1 -0
- package/build/cli/theme/semantic-colors.d.ts +2 -0
- package/build/cli/theme/semantic-colors.js +19 -0
- package/build/cli/theme/semantic-colors.js.map +1 -0
- package/build/cli/theme/semantic-tokens.d.ts +42 -0
- package/build/cli/theme/semantic-tokens.js +77 -0
- package/build/cli/theme/semantic-tokens.js.map +1 -0
- package/build/cli/theme/theme-manager.d.ts +32 -0
- package/build/cli/theme/theme-manager.js +150 -0
- package/build/cli/theme/theme-manager.js.map +1 -0
- package/build/cli/theme/theme.d.ts +107 -0
- package/build/cli/theme/theme.js +333 -0
- package/build/cli/theme/theme.js.map +1 -0
- package/build/cli/tmp.d.ts +1 -0
- package/build/cli/tmp.js +27 -0
- package/build/cli/tmp.js.map +1 -0
- package/build/cli/types.d.ts +97 -0
- package/build/cli/types.js +2 -0
- package/build/cli/types.js.map +1 -0
- package/build/cli/ui/ConnectionStatus.d.ts +13 -0
- package/build/cli/ui/ConnectionStatus.js +19 -0
- package/build/cli/ui/ConnectionStatus.js.map +1 -0
- package/build/cli/ui/HalfPaddingBox.d.ts +13 -0
- package/build/cli/ui/HalfPaddingBox.js +11 -0
- package/build/cli/ui/HalfPaddingBox.js.map +1 -0
- package/build/cli/ui/HelpCommands.d.ts +5 -0
- package/build/cli/ui/HelpCommands.js +11 -0
- package/build/cli/ui/HelpCommands.js.map +1 -0
- package/build/cli/ui/HistoryItemDisplay.d.ts +9 -0
- package/build/cli/ui/HistoryItemDisplay.js +34 -0
- package/build/cli/ui/HistoryItemDisplay.js.map +1 -0
- package/build/cli/ui/InputPrompt.d.ts +13 -0
- package/build/cli/ui/InputPrompt.js +138 -0
- package/build/cli/ui/InputPrompt.js.map +1 -0
- package/build/cli/ui/LLMErrorComponent.d.ts +6 -0
- package/build/cli/ui/LLMErrorComponent.js +18 -0
- package/build/cli/ui/LLMErrorComponent.js.map +1 -0
- package/build/cli/ui/LLMHealthChecker.d.ts +8 -0
- package/build/cli/ui/LLMHealthChecker.js +22 -0
- package/build/cli/ui/LLMHealthChecker.js.map +1 -0
- package/build/cli/ui/MCPServers.d.ts +11 -0
- package/build/cli/ui/MCPServers.js +15 -0
- package/build/cli/ui/MCPServers.js.map +1 -0
- package/build/cli/ui/MainContent.d.ts +12 -0
- package/build/cli/ui/MainContent.js +28 -0
- package/build/cli/ui/MainContent.js.map +1 -0
- package/build/cli/ui/MarkdownDisplay.d.ts +8 -0
- package/build/cli/ui/MarkdownDisplay.js +6 -0
- package/build/cli/ui/MarkdownDisplay.js.map +1 -0
- package/build/cli/ui/MouseContext.d.ts +1 -0
- package/build/cli/ui/MouseContext.js +2 -0
- package/build/cli/ui/MouseContext.js.map +1 -0
- package/build/cli/ui/SuggestionsDisplay.d.ts +25 -0
- package/build/cli/ui/SuggestionsDisplay.js +45 -0
- package/build/cli/ui/SuggestionsDisplay.js.map +1 -0
- package/build/cli/ui/SystemInfoSummaryBox.d.ts +6 -0
- package/build/cli/ui/SystemInfoSummaryBox.js +6 -0
- package/build/cli/ui/SystemInfoSummaryBox.js.map +1 -0
- package/build/cli/ui/ThinkingIndicator.d.ts +2 -0
- package/build/cli/ui/ThinkingIndicator.js +16 -0
- package/build/cli/ui/ThinkingIndicator.js.map +1 -0
- package/build/cli/ui/layout/DefaultAppLayout.d.ts +2 -0
- package/build/cli/ui/layout/DefaultAppLayout.js +6 -0
- package/build/cli/ui/layout/DefaultAppLayout.js.map +1 -0
- package/build/cli/ui/shared/ExpandableText.d.ts +14 -0
- package/build/cli/ui/shared/ExpandableText.js +19 -0
- package/build/cli/ui/shared/ExpandableText.js.map +1 -0
- package/build/cli/utils/cache.d.ts +21 -0
- package/build/cli/utils/cache.js +56 -0
- package/build/cli/utils/cache.js.map +1 -0
- package/build/cli/utils/cleanup.d.ts +1 -0
- package/build/cli/utils/cleanup.js +5 -0
- package/build/cli/utils/cleanup.js.map +1 -0
- package/build/cli/utils/commandUtils.d.ts +11 -0
- package/build/cli/utils/commandUtils.js +16 -0
- package/build/cli/utils/commandUtils.js.map +1 -0
- package/build/cli/utils/historyStorage.d.ts +13 -0
- package/build/cli/utils/historyStorage.js +64 -0
- package/build/cli/utils/historyStorage.js.map +1 -0
- package/build/cli/utils/stdio.d.ts +18 -0
- package/build/cli/utils/stdio.js +58 -0
- package/build/cli/utils/stdio.js.map +1 -0
- package/build/cli/utils/textUtil.d.ts +63 -0
- package/build/cli/utils/textUtil.js +231 -0
- package/build/cli/utils/textUtil.js.map +1 -0
- package/build/config.d.ts +31 -0
- package/{dist/src → build}/config.js +31 -2
- package/build/config.js.map +1 -0
- package/build/db.d.ts +1 -0
- package/{dist/src → build}/db.js +0 -3
- package/build/db.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/{dist/src → build}/index.js +0 -3
- package/build/index.js.map +1 -0
- package/{dist/src → build}/server.d.ts +0 -1
- package/{dist/src → build}/server.js +1 -1
- package/build/server.js.map +1 -0
- package/{dist/src → build}/setup.d.ts +0 -2
- package/{dist/src → build}/setup.js +2 -4
- package/build/setup.js.map +1 -0
- package/build/shared/configSchema.d.ts +27 -0
- package/build/shared/configSchema.js +31 -0
- package/build/shared/configSchema.js.map +1 -0
- package/build/shared/index.d.ts +3 -0
- package/build/shared/index.js +4 -0
- package/build/shared/index.js.map +1 -0
- package/build/shared/types.d.ts +20 -0
- package/build/shared/types.js +2 -0
- package/build/shared/types.js.map +1 -0
- package/build/shared/utils/debugLogger.d.ts +12 -0
- package/build/shared/utils/debugLogger.js +54 -0
- package/build/shared/utils/debugLogger.js.map +1 -0
- package/{dist/src → build}/tools/create_document_with_properties/index.d.ts +22 -5
- package/{dist/src → build}/tools/create_document_with_properties/index.js +2 -2
- package/build/tools/create_document_with_properties/index.js.map +1 -0
- package/build/tools/create_document_with_properties/params.d.ts +66 -0
- package/{dist/src → build}/tools/create_document_with_properties/params.js +1 -1
- package/build/tools/create_document_with_properties/params.js.map +1 -0
- package/{dist/src → build}/tools/generate_property/index.d.ts +1 -2
- package/{dist/src → build}/tools/generate_property/index.js +1 -1
- package/build/tools/generate_property/index.js.map +1 -0
- package/{dist/src → build}/tools/generate_property/params.d.ts +30 -7
- package/build/tools/generate_property/params.js.map +1 -0
- package/{dist/src → build}/tools/index.d.ts +51 -36
- package/build/tools/index.js +13 -0
- package/build/tools/index.js.map +1 -0
- package/{dist/src → build}/tools/organize_attachments/index.d.ts +1 -2
- package/{dist/src → build}/tools/organize_attachments/index.js +2 -2
- package/build/tools/organize_attachments/index.js.map +1 -0
- package/build/tools/organize_attachments/params.d.ts +122 -0
- package/{dist/src → build}/tools/organize_attachments/params.js +3 -3
- package/build/tools/organize_attachments/params.js.map +1 -0
- package/{dist/src → build}/tools/organize_attachments/utils.d.ts +0 -1
- package/build/tools/organize_attachments/utils.js.map +1 -0
- package/{dist/src → build}/tools/vault/index.d.ts +5 -26
- package/{dist/src → build}/tools/vault/index.js +3 -3
- package/build/tools/vault/index.js.map +1 -0
- package/{dist/src → build}/tools/vault/metrics.d.ts +0 -1
- package/build/tools/vault/metrics.js.map +1 -0
- package/build/tools/vault/params.d.ts +115 -0
- package/{dist/src → build}/tools/vault/params.js +0 -1
- package/build/tools/vault/params.js.map +1 -0
- package/build/tools/vault/types/collect_context.d.ts +1340 -0
- package/{dist/src → build}/tools/vault/types/collect_context.js +1 -1
- package/build/tools/vault/types/collect_context.js.map +1 -0
- package/build/tools/vault/types/list_all.d.ts +387 -0
- package/{dist/src → build}/tools/vault/types/list_all.js +4 -9
- package/build/tools/vault/types/list_all.js.map +1 -0
- package/build/tools/vault/types/read_specific.d.ts +297 -0
- package/{dist/src → build}/tools/vault/types/read_specific.js +1 -3
- package/build/tools/vault/types/read_specific.js.map +1 -0
- package/build/tools/vault/types/search.d.ts +598 -0
- package/{dist/src → build}/tools/vault/types/search.js +8 -16
- package/build/tools/vault/types/search.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/actions/collect_context.d.ts +1 -2
- package/{dist/src → build}/tools/vault/utils/actions/collect_context.js +4 -4
- package/build/tools/vault/utils/actions/collect_context.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/actions/index_rag.d.ts +0 -1
- package/build/tools/vault/utils/actions/index_rag.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/actions/list_all.d.ts +1 -2
- package/{dist/src → build}/tools/vault/utils/actions/list_all.js +1 -1
- package/build/tools/vault/utils/actions/list_all.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/actions/load_memory.d.ts +1 -2
- package/{dist/src → build}/tools/vault/utils/actions/load_memory.js +3 -3
- package/build/tools/vault/utils/actions/load_memory.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/actions/read.d.ts +1 -2
- package/{dist/src → build}/tools/vault/utils/actions/read.js +1 -1
- package/build/tools/vault/utils/actions/read.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/actions/search.d.ts +1 -2
- package/{dist/src → build}/tools/vault/utils/actions/search.js +2 -2
- package/build/tools/vault/utils/actions/search.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/actions/stats.d.ts +0 -1
- package/build/tools/vault/utils/actions/stats.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/constants.d.ts +0 -1
- package/build/tools/vault/utils/constants.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/document.d.ts +0 -6
- package/{dist/src → build}/tools/vault/utils/document.js +0 -1
- package/build/tools/vault/utils/document.js.map +1 -0
- package/{dist/src → build}/tools/vault/utils/shared.d.ts +1 -2
- package/build/tools/vault/utils/shared.js.map +1 -0
- package/build/tools/vault/utils.d.ts +7 -0
- package/build/tools/vault/utils.js +8 -0
- package/build/tools/vault/utils.js.map +1 -0
- package/{dist/src → build}/tools/write_property/index.d.ts +22 -5
- package/{dist/src → build}/tools/write_property/index.js +1 -1
- package/build/tools/write_property/index.js.map +1 -0
- package/build/tools/write_property/params.d.ts +60 -0
- package/build/tools/write_property/params.js.map +1 -0
- package/{dist/src → build}/utils/DirectoryWalker.d.ts +1 -2
- package/build/utils/DirectoryWalker.js.map +1 -0
- package/{dist/src → build}/utils/Embedder.d.ts +0 -1
- package/{dist/src → build}/utils/Embedder.js +1 -1
- package/build/utils/Embedder.js.map +1 -0
- package/{dist/src → build}/utils/Indexer.d.ts +2 -3
- package/{dist/src → build}/utils/Indexer.js +2 -2
- package/build/utils/Indexer.js.map +1 -0
- package/{dist/src → build}/utils/LLMClient.d.ts +0 -1
- package/{dist/src → build}/utils/LLMClient.js +0 -16
- package/build/utils/LLMClient.js.map +1 -0
- package/{dist/src → build}/utils/LocalReranker.d.ts +0 -1
- package/{dist/src → build}/utils/LocalReranker.js +1 -1
- package/build/utils/LocalReranker.js.map +1 -0
- package/{dist/src → build}/utils/RAGIndexer.d.ts +1 -2
- package/{dist/src → build}/utils/RAGIndexer.js +6 -6
- package/build/utils/RAGIndexer.js.map +1 -0
- package/build/utils/RerankerClient.d.ts +61 -0
- package/{dist/src → build}/utils/RerankerClient.js +1 -20
- package/build/utils/RerankerClient.js.map +1 -0
- package/{dist/src → build}/utils/VaultManger/VaultManager.d.ts +3 -4
- package/{dist/src → build}/utils/VaultManger/VaultManager.js +9 -9
- package/build/utils/VaultManger/VaultManager.js.map +1 -0
- package/{dist/src → build}/utils/VaultManger/VaultPathError.d.ts +0 -1
- package/build/utils/VaultManger/VaultPathError.js.map +1 -0
- package/build/utils/VaultManger/index.d.ts +3 -0
- package/build/utils/VaultManger/index.js +3 -0
- package/build/utils/VaultManger/index.js.map +1 -0
- package/{dist/src → build}/utils/VaultManger/types.d.ts +1 -2
- package/build/utils/VaultManger/types.js +2 -0
- package/build/utils/VaultManger/types.js.map +1 -0
- package/{dist/src → build}/utils/VaultWatcher.d.ts +0 -1
- package/{dist/src → build}/utils/VaultWatcher.js +1 -1
- package/build/utils/VaultWatcher.js.map +1 -0
- package/{dist/src → build}/utils/VectorDB.d.ts +0 -1
- package/build/utils/VectorDB.js +243 -0
- package/build/utils/VectorDB.js.map +1 -0
- package/{dist/src → build}/utils/constants.d.ts +0 -1
- package/build/utils/constants.js.map +1 -0
- package/{dist/src → build}/utils/createToolError.d.ts +0 -1
- package/build/utils/createToolError.js.map +1 -0
- package/build/utils/getVaultManager.d.ts +2 -0
- package/{dist/src → build}/utils/getVaultManager.js +1 -7
- package/build/utils/getVaultManager.js.map +1 -0
- package/{dist/src → build}/utils/processor/LinkExtractor.d.ts +0 -1
- package/build/utils/processor/LinkExtractor.js.map +1 -0
- package/build/utils/processor/MatterParser.d.ts +2 -0
- package/build/utils/processor/MatterParser.js +28 -0
- package/build/utils/processor/MatterParser.js.map +1 -0
- package/build/utils/processor/types.d.ts +104 -0
- package/{dist/src → build}/utils/processor/types.js +2 -10
- package/build/utils/processor/types.js.map +1 -0
- package/{dist/src → build}/utils/semaphore.d.ts +0 -1
- package/build/utils/semaphore.js.map +1 -0
- package/package.json +84 -72
- package/dist/package.json +0 -74
- package/dist/src/config.d.ts +0 -6
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js.map +0 -1
- package/dist/src/db.d.ts +0 -2
- package/dist/src/db.d.ts.map +0 -1
- package/dist/src/db.js.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/server.d.ts.map +0 -1
- package/dist/src/server.js.map +0 -1
- package/dist/src/setup.d.ts.map +0 -1
- package/dist/src/setup.js.map +0 -1
- package/dist/src/tools/create_document_with_properties/index.d.ts.map +0 -1
- package/dist/src/tools/create_document_with_properties/index.js.map +0 -1
- package/dist/src/tools/create_document_with_properties/params.d.ts +0 -19
- package/dist/src/tools/create_document_with_properties/params.d.ts.map +0 -1
- package/dist/src/tools/create_document_with_properties/params.js.map +0 -1
- package/dist/src/tools/generate_property/index.d.ts.map +0 -1
- package/dist/src/tools/generate_property/index.js.map +0 -1
- package/dist/src/tools/generate_property/params.d.ts.map +0 -1
- package/dist/src/tools/generate_property/params.js.map +0 -1
- package/dist/src/tools/index.d.ts.map +0 -1
- package/dist/src/tools/index.js +0 -13
- package/dist/src/tools/index.js.map +0 -1
- package/dist/src/tools/organize_attachments/index.d.ts.map +0 -1
- package/dist/src/tools/organize_attachments/index.js.map +0 -1
- package/dist/src/tools/organize_attachments/params.d.ts +0 -47
- package/dist/src/tools/organize_attachments/params.d.ts.map +0 -1
- package/dist/src/tools/organize_attachments/params.js.map +0 -1
- package/dist/src/tools/organize_attachments/utils.d.ts.map +0 -1
- package/dist/src/tools/organize_attachments/utils.js.map +0 -1
- package/dist/src/tools/vault/index.d.ts.map +0 -1
- package/dist/src/tools/vault/index.js.map +0 -1
- package/dist/src/tools/vault/metrics.d.ts.map +0 -1
- package/dist/src/tools/vault/metrics.js.map +0 -1
- package/dist/src/tools/vault/params.d.ts +0 -100
- package/dist/src/tools/vault/params.d.ts.map +0 -1
- package/dist/src/tools/vault/params.js.map +0 -1
- package/dist/src/tools/vault/types/collect_context.d.ts +0 -388
- package/dist/src/tools/vault/types/collect_context.d.ts.map +0 -1
- package/dist/src/tools/vault/types/collect_context.js.map +0 -1
- package/dist/src/tools/vault/types/list_all.d.ts +0 -89
- package/dist/src/tools/vault/types/list_all.d.ts.map +0 -1
- package/dist/src/tools/vault/types/list_all.js.map +0 -1
- package/dist/src/tools/vault/types/read_specific.d.ts +0 -68
- package/dist/src/tools/vault/types/read_specific.d.ts.map +0 -1
- package/dist/src/tools/vault/types/read_specific.js.map +0 -1
- package/dist/src/tools/vault/types/search.d.ts +0 -151
- package/dist/src/tools/vault/types/search.d.ts.map +0 -1
- package/dist/src/tools/vault/types/search.js.map +0 -1
- package/dist/src/tools/vault/utils/actions/collect_context.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/actions/collect_context.js.map +0 -1
- package/dist/src/tools/vault/utils/actions/index_rag.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/actions/index_rag.js.map +0 -1
- package/dist/src/tools/vault/utils/actions/list_all.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/actions/list_all.js.map +0 -1
- package/dist/src/tools/vault/utils/actions/load_memory.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/actions/load_memory.js.map +0 -1
- package/dist/src/tools/vault/utils/actions/read.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/actions/read.js.map +0 -1
- package/dist/src/tools/vault/utils/actions/search.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/actions/search.js.map +0 -1
- package/dist/src/tools/vault/utils/actions/stats.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/actions/stats.js.map +0 -1
- package/dist/src/tools/vault/utils/constants.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/constants.js.map +0 -1
- package/dist/src/tools/vault/utils/document.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/document.js.map +0 -1
- package/dist/src/tools/vault/utils/shared.d.ts.map +0 -1
- package/dist/src/tools/vault/utils/shared.js.map +0 -1
- package/dist/src/tools/vault/utils.d.ts +0 -8
- package/dist/src/tools/vault/utils.d.ts.map +0 -1
- package/dist/src/tools/vault/utils.js +0 -8
- package/dist/src/tools/vault/utils.js.map +0 -1
- package/dist/src/tools/write_property/index.d.ts.map +0 -1
- package/dist/src/tools/write_property/index.js.map +0 -1
- package/dist/src/tools/write_property/params.d.ts +0 -17
- package/dist/src/tools/write_property/params.d.ts.map +0 -1
- package/dist/src/tools/write_property/params.js.map +0 -1
- package/dist/src/utils/DirectoryWalker.d.ts.map +0 -1
- package/dist/src/utils/DirectoryWalker.js.map +0 -1
- package/dist/src/utils/Embedder.d.ts.map +0 -1
- package/dist/src/utils/Embedder.js.map +0 -1
- package/dist/src/utils/Indexer.d.ts.map +0 -1
- package/dist/src/utils/Indexer.js.map +0 -1
- package/dist/src/utils/LLMClient.d.ts.map +0 -1
- package/dist/src/utils/LLMClient.js.map +0 -1
- package/dist/src/utils/LocalReranker.d.ts.map +0 -1
- package/dist/src/utils/LocalReranker.js.map +0 -1
- package/dist/src/utils/RAGIndexer.d.ts.map +0 -1
- package/dist/src/utils/RAGIndexer.js.map +0 -1
- package/dist/src/utils/RerankerClient.d.ts +0 -28
- package/dist/src/utils/RerankerClient.d.ts.map +0 -1
- package/dist/src/utils/RerankerClient.js.map +0 -1
- package/dist/src/utils/VaultManger/VaultManager.d.ts.map +0 -1
- package/dist/src/utils/VaultManger/VaultManager.js.map +0 -1
- package/dist/src/utils/VaultManger/VaultPathError.d.ts.map +0 -1
- package/dist/src/utils/VaultManger/VaultPathError.js.map +0 -1
- package/dist/src/utils/VaultManger/index.d.ts +0 -4
- package/dist/src/utils/VaultManger/index.d.ts.map +0 -1
- package/dist/src/utils/VaultManger/index.js +0 -3
- package/dist/src/utils/VaultManger/index.js.map +0 -1
- package/dist/src/utils/VaultManger/types.d.ts.map +0 -1
- package/dist/src/utils/VaultManger/types.js.map +0 -1
- package/dist/src/utils/VaultWatcher.d.ts.map +0 -1
- package/dist/src/utils/VaultWatcher.js.map +0 -1
- package/dist/src/utils/VectorDB.d.ts.map +0 -1
- package/dist/src/utils/VectorDB.js +0 -305
- package/dist/src/utils/VectorDB.js.map +0 -1
- package/dist/src/utils/constants.d.ts.map +0 -1
- package/dist/src/utils/constants.js.map +0 -1
- package/dist/src/utils/createToolError.d.ts.map +0 -1
- package/dist/src/utils/createToolError.js.map +0 -1
- package/dist/src/utils/getVaultManager.d.ts +0 -7
- package/dist/src/utils/getVaultManager.d.ts.map +0 -1
- package/dist/src/utils/getVaultManager.js.map +0 -1
- package/dist/src/utils/processor/LinkExtractor.d.ts.map +0 -1
- package/dist/src/utils/processor/LinkExtractor.js.map +0 -1
- package/dist/src/utils/processor/MatterParser.d.ts +0 -3
- package/dist/src/utils/processor/MatterParser.d.ts.map +0 -1
- package/dist/src/utils/processor/MatterParser.js +0 -27
- package/dist/src/utils/processor/MatterParser.js.map +0 -1
- package/dist/src/utils/processor/types.d.ts +0 -53
- package/dist/src/utils/processor/types.d.ts.map +0 -1
- package/dist/src/utils/processor/types.js.map +0 -1
- package/dist/src/utils/semaphore.d.ts.map +0 -1
- package/dist/src/utils/semaphore.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- /package/{dist/src/utils/VaultManger → build/cli/hooks/useLlmStream}/types.js +0 -0
- /package/{dist/src → build}/tools/generate_property/params.js +0 -0
- /package/{dist/src → build}/tools/organize_attachments/utils.js +0 -0
- /package/{dist/src → build}/tools/vault/metrics.js +0 -0
- /package/{dist/src → build}/tools/vault/utils/actions/index_rag.js +0 -0
- /package/{dist/src → build}/tools/vault/utils/actions/stats.js +0 -0
- /package/{dist/src → build}/tools/vault/utils/constants.js +0 -0
- /package/{dist/src → build}/tools/vault/utils/shared.js +0 -0
- /package/{dist/src → build}/tools/write_property/params.js +0 -0
- /package/{dist/src → build}/utils/DirectoryWalker.js +0 -0
- /package/{dist/src → build}/utils/VaultManger/VaultPathError.js +0 -0
- /package/{dist/src → build}/utils/constants.js +0 -0
- /package/{dist/src → build}/utils/createToolError.js +0 -0
- /package/{dist/src → build}/utils/processor/LinkExtractor.js +0 -0
- /package/{dist/src → build}/utils/semaphore.js +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
export const MAX_WIDTH = 120;
|
|
4
|
+
/**
|
|
5
|
+
* Renders a suggestion label, highlighting the matched portion if provided.
|
|
6
|
+
*/
|
|
7
|
+
export function ExpandableText({ label, matchedIndex, userInput, textColor, isExpanded: _isExpanded, }) {
|
|
8
|
+
if (matchedIndex !== undefined &&
|
|
9
|
+
matchedIndex >= 0 &&
|
|
10
|
+
userInput &&
|
|
11
|
+
userInput.length > 0) {
|
|
12
|
+
const before = label.slice(0, matchedIndex);
|
|
13
|
+
const match = label.slice(matchedIndex, matchedIndex + userInput.length);
|
|
14
|
+
const after = label.slice(matchedIndex + userInput.length);
|
|
15
|
+
return (_jsxs(Text, { color: textColor, children: [before, _jsx(Text, { bold: true, children: match }), after] }));
|
|
16
|
+
}
|
|
17
|
+
return _jsx(Text, { color: textColor, children: label });
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ExpandableText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandableText.js","sourceRoot":"","sources":["../../../../src/cli/ui/shared/ExpandableText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAU7B;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,EAC9B,KAAK,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,UAAU,EAAE,WAAW,GACF;IACrB,IACC,YAAY,KAAK,SAAS;QAC1B,YAAY,IAAI,CAAC;QACjB,SAAS;QACT,SAAS,CAAC,MAAM,GAAG,CAAC,EACnB,CAAC;QACF,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3D,OAAO,CACN,MAAC,IAAI,IAAC,KAAK,EAAE,SAAS,aACpB,MAAM,EACP,KAAC,IAAI,IAAC,IAAI,kBAAE,KAAK,GAAQ,EACxB,KAAK,IACA,CACP,CAAC;IACH,CAAC;IACD,OAAO,KAAC,IAAI,IAAC,KAAK,EAAE,SAAS,YAAG,KAAK,GAAQ,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CacheEntry<V> {
|
|
2
|
+
value: V;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
ttl?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CacheOptions {
|
|
7
|
+
defaultTTL?: number;
|
|
8
|
+
deleteOnPromiseFailure?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class CacheService<K extends object | string | undefined, V> {
|
|
11
|
+
private readonly storage;
|
|
12
|
+
private readonly defaultTTL?;
|
|
13
|
+
private readonly deleteOnPromiseFailure;
|
|
14
|
+
constructor(options?: CacheOptions);
|
|
15
|
+
get(key: K): V | undefined;
|
|
16
|
+
set(key: K, value: V, ttl?: number): void;
|
|
17
|
+
getOrCreate(key: K, creator: () => V, ttl?: number): V;
|
|
18
|
+
delete(key: K): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function createCache<K extends string | undefined, V>(options: CacheOptions): CacheService<K, V>;
|
|
21
|
+
export declare function createCache<K extends object, V>(options?: CacheOptions): CacheService<K, V>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export class CacheService {
|
|
2
|
+
storage;
|
|
3
|
+
defaultTTL;
|
|
4
|
+
deleteOnPromiseFailure;
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.storage = new Map();
|
|
7
|
+
this.defaultTTL = options.defaultTTL;
|
|
8
|
+
this.deleteOnPromiseFailure = options.deleteOnPromiseFailure ?? false;
|
|
9
|
+
}
|
|
10
|
+
get(key) {
|
|
11
|
+
const entry = this.storage.get(key);
|
|
12
|
+
if (!entry) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const ttl = entry.ttl ?? this.defaultTTL;
|
|
16
|
+
if (ttl !== undefined && Date.now() - entry.timestamp > ttl) {
|
|
17
|
+
this.delete(key);
|
|
18
|
+
}
|
|
19
|
+
return entry.value;
|
|
20
|
+
}
|
|
21
|
+
set(key, value, ttl) {
|
|
22
|
+
const entry = {
|
|
23
|
+
value,
|
|
24
|
+
timestamp: Date.now(),
|
|
25
|
+
ttl,
|
|
26
|
+
};
|
|
27
|
+
this.storage.set(key, entry);
|
|
28
|
+
if (this.deleteOnPromiseFailure && value instanceof Promise) {
|
|
29
|
+
value.catch(() => {
|
|
30
|
+
if (this.storage.get(key) === entry) {
|
|
31
|
+
this.delete(key);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
getOrCreate(key, creator, ttl) {
|
|
37
|
+
let value = this.get(key);
|
|
38
|
+
if (value === undefined) {
|
|
39
|
+
value = creator();
|
|
40
|
+
this.set(key, value, ttl);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
delete(key) {
|
|
45
|
+
if (this.storage instanceof Map) {
|
|
46
|
+
this.storage.delete(key);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.storage.delete(key);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function createCache(options = {}) {
|
|
54
|
+
return new CacheService(options);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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,EAAE,CAAC;oBACrC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAED,WAAW,CAAC,GAAM,EAAE,OAAgB,EAAE,GAAY;QACjD,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,KAAK,GAAG,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,CAAC,GAAM;QACZ,IAAI,IAAI,CAAC,OAAO,YAAY,GAAG,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAA2C,CAAC,MAAM,CAAC,GAAc,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC;CACD;AAQD,MAAM,UAAU,WAAW,CAC1B,UAAwB,EAAE;IAE1B,OAAO,IAAI,YAAY,CAAO,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerSyncCleanup(fn: () => void): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../../src/cli/utils/cleanup.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAsB,EAAE,CAAC;AAEnD,MAAM,UAAU,mBAAmB,CAAC,EAAc;IACjD,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for command parsing.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Returns true if the trimmed text begins with '/', indicating a slash command.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isSlashCommand(text: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if the trimmed text begins with '@', indicating an at-command.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isAtCommand(text: string): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for command parsing.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Returns true if the trimmed text begins with '/', indicating a slash command.
|
|
6
|
+
*/
|
|
7
|
+
export function isSlashCommand(text) {
|
|
8
|
+
return text.trimStart().startsWith("/");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if the trimmed text begins with '@', indicating an at-command.
|
|
12
|
+
*/
|
|
13
|
+
export function isAtCommand(text) {
|
|
14
|
+
return text.trimStart().startsWith("@");
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=commandUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandUtils.js","sourceRoot":"","sources":["../../../src/cli/utils/commandUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface HistoryItem {
|
|
2
|
+
text: string;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class HistoryStorage {
|
|
6
|
+
private filePath;
|
|
7
|
+
constructor(filePath?: string);
|
|
8
|
+
getPreviousUserMessages(): Promise<string[]>;
|
|
9
|
+
appendMessage(text: string): Promise<void>;
|
|
10
|
+
private getRawItems;
|
|
11
|
+
private saveItems;
|
|
12
|
+
}
|
|
13
|
+
export declare const historyStorage: HistoryStorage;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { debugLogger } from "../../shared/index.js";
|
|
5
|
+
const HISTORY_FILE_PATH = path.join(os.homedir(), ".obsidian-mcp-agent-history.json");
|
|
6
|
+
const EXPIRY_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
7
|
+
export class HistoryStorage {
|
|
8
|
+
filePath;
|
|
9
|
+
constructor(filePath = HISTORY_FILE_PATH) {
|
|
10
|
+
this.filePath = filePath;
|
|
11
|
+
}
|
|
12
|
+
async getPreviousUserMessages() {
|
|
13
|
+
try {
|
|
14
|
+
const data = await fs.readFile(this.filePath, "utf-8");
|
|
15
|
+
const parsed = JSON.parse(data);
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
const validItems = parsed.filter((item) => now - item.timestamp <= EXPIRY_MS);
|
|
18
|
+
// If items were pruned, save back to file to save disk space
|
|
19
|
+
if (validItems.length < parsed.length) {
|
|
20
|
+
await this.saveItems(validItems);
|
|
21
|
+
}
|
|
22
|
+
// Return just the text values
|
|
23
|
+
return validItems.map((item) => item.text);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error.code !== "ENOENT") {
|
|
27
|
+
debugLogger.warn("Failed to read history storage", error);
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async appendMessage(text) {
|
|
33
|
+
try {
|
|
34
|
+
const currentMessages = await this.getRawItems();
|
|
35
|
+
const now = Date.now();
|
|
36
|
+
// Prune old items first
|
|
37
|
+
const validItems = currentMessages.filter((item) => now - item.timestamp <= EXPIRY_MS);
|
|
38
|
+
validItems.push({ text, timestamp: now });
|
|
39
|
+
await this.saveItems(validItems);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
debugLogger.warn("Failed to append message to history storage", error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async getRawItems() {
|
|
46
|
+
try {
|
|
47
|
+
const data = await fs.readFile(this.filePath, "utf-8");
|
|
48
|
+
return JSON.parse(data);
|
|
49
|
+
}
|
|
50
|
+
catch (_error) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async saveItems(items) {
|
|
55
|
+
try {
|
|
56
|
+
await fs.writeFile(this.filePath, JSON.stringify(items, null, 2), "utf-8");
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
debugLogger.warn("Failed to save items to history storage", error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export const historyStorage = new HistoryStorage();
|
|
64
|
+
//# sourceMappingURL=historyStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historyStorage.js","sourceRoot":"","sources":["../../../src/cli/utils/historyStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAClC,EAAE,CAAC,OAAO,EAAE,EACZ,kCAAkC,CAClC,CAAC;AACF,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW;AAOlD,MAAM,OAAO,cAAc;IAClB,QAAQ,CAAS;IAEzB,YAAY,WAAmB,iBAAiB;QAC/C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC5B,IAAI,CAAC;YAC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AAC;YAE1C,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,WAAW,CAAC,IAAI,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;QACxE,CAAC;IACF,CAAC;IAEO,KAAK,CAAC,WAAW;QACxB,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YACjB,OAAO,EAAE,CAAC;QACX,CAAC;IACF,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,KAAoB;QAC3C,IAAI,CAAC;YACJ,MAAM,EAAE,CAAC,SAAS,CACjB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAC9B,OAAO,CACP,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,WAAW,CAAC,IAAI,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;QACpE,CAAC;IACF,CAAC;CACD;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 몽키패칭에서 사용이 필요한 경우, 원래의 stdout과 stderr에 직접 쓰기 위해 이 함수를 사용합니다. stdio가 패치된 이후에도 원래의 출력 스트림에 접근할 수 있도록 합니다.
|
|
3
|
+
*/
|
|
4
|
+
export declare function writeToStdout(...args: Parameters<typeof process.stdout.write>): boolean;
|
|
5
|
+
export declare function writeToStderr(...args: Parameters<typeof process.stderr.write>): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Creates proxies for process.stdout and process.stderr that use the real write methods
|
|
8
|
+
* (writeToStdout and writeToStderr) bypassing any monkey patching.
|
|
9
|
+
* This is used to write to the real output even when stdio is patched.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createWorkingStdio(): {
|
|
12
|
+
stdout: NodeJS.WriteStream & {
|
|
13
|
+
fd: 1;
|
|
14
|
+
};
|
|
15
|
+
stderr: NodeJS.WriteStream & {
|
|
16
|
+
fd: 2;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 몽키 패칭을 수행하기 이전에 원래의 stdout과 stderr의 write 메서드를 저장합니다. 이렇게 하면 stdio가 패치된 이후에도 원래의 출력 스트림에 접근할 수 있습니다.
|
|
3
|
+
*/
|
|
4
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
5
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
6
|
+
/**
|
|
7
|
+
* 몽키패칭에서 사용이 필요한 경우, 원래의 stdout과 stderr에 직접 쓰기 위해 이 함수를 사용합니다. stdio가 패치된 이후에도 원래의 출력 스트림에 접근할 수 있도록 합니다.
|
|
8
|
+
*/
|
|
9
|
+
export function writeToStdout(...args) {
|
|
10
|
+
return originalStdoutWrite(...args);
|
|
11
|
+
}
|
|
12
|
+
export function writeToStderr(...args) {
|
|
13
|
+
return originalStderrWrite(...args);
|
|
14
|
+
}
|
|
15
|
+
function isKey(key, obj) {
|
|
16
|
+
return key in obj;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates proxies for process.stdout and process.stderr that use the real write methods
|
|
20
|
+
* (writeToStdout and writeToStderr) bypassing any monkey patching.
|
|
21
|
+
* This is used to write to the real output even when stdio is patched.
|
|
22
|
+
*/
|
|
23
|
+
export function createWorkingStdio() {
|
|
24
|
+
const stdoutHandler = {
|
|
25
|
+
get(target, prop) {
|
|
26
|
+
if (prop === "write") {
|
|
27
|
+
return writeToStdout;
|
|
28
|
+
}
|
|
29
|
+
if (isKey(prop, target)) {
|
|
30
|
+
const value = target[prop];
|
|
31
|
+
if (typeof value === "function") {
|
|
32
|
+
return value.bind(target);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const inkStdout = new Proxy(process.stdout, stdoutHandler);
|
|
40
|
+
const stderrHandler = {
|
|
41
|
+
get(target, prop) {
|
|
42
|
+
if (prop === "write") {
|
|
43
|
+
return writeToStderr;
|
|
44
|
+
}
|
|
45
|
+
if (isKey(prop, target)) {
|
|
46
|
+
const value = target[prop];
|
|
47
|
+
if (typeof value === "function") {
|
|
48
|
+
return value.bind(target);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const inkStderr = new Proxy(process.stderr, stderrHandler);
|
|
56
|
+
return { stdout: inkStdout, stderr: inkStderr };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../../src/cli/utils/stdio.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACtE,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,UAAU,aAAa,CAC5B,GAAG,IAA6C;IAEhD,OAAO,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,aAAa,CAC5B,GAAG,IAA6C;IAEhD,OAAO,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,KA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,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the maximum width of a multi-line ASCII art string.
|
|
3
|
+
* @param asciiArt The ASCII art string.
|
|
4
|
+
* @returns The length of the longest line in the ASCII art.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getAsciiArtWidth: (asciiArt: string) => number;
|
|
7
|
+
/**
|
|
8
|
+
* Checks if a string contains only ASCII characters (0-127).
|
|
9
|
+
*/
|
|
10
|
+
export declare function isAscii(str: string): boolean;
|
|
11
|
+
export declare function toCodePoints(str: string): string[];
|
|
12
|
+
export declare function cpLen(str: string): number;
|
|
13
|
+
/**
|
|
14
|
+
* Converts a code point index to a UTF-16 code unit offset.
|
|
15
|
+
*/
|
|
16
|
+
export declare function cpIndexToOffset(str: string, cpIndex: number): number;
|
|
17
|
+
export declare function cpSlice(str: string, start: number, end?: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Strip characters that can break terminal rendering.
|
|
20
|
+
*
|
|
21
|
+
* This is a strict sanitization function intended for general display
|
|
22
|
+
* contexts. It strips all C1 control characters (0x80-0x9F) and VT
|
|
23
|
+
* control sequences. For list display contexts where a more lenient
|
|
24
|
+
* approach is needed (preserving C1 characters and only stripping ANSI
|
|
25
|
+
* codes and newlines/tabs), use a separate function instead.
|
|
26
|
+
*
|
|
27
|
+
* Processing order:
|
|
28
|
+
* 1. stripAnsi removes ANSI escape sequences (including 8-bit CSI 0x9B)
|
|
29
|
+
* 2. Regex strips C0, C1, BiDi, and zero-width control characters
|
|
30
|
+
* 3. stripVTControlCharacters removes any remaining VT sequences
|
|
31
|
+
*
|
|
32
|
+
* Characters stripped:
|
|
33
|
+
* - ANSI escape sequences (via strip-ansi)
|
|
34
|
+
* - VT control sequences (via Node.js util.stripVTControlCharacters)
|
|
35
|
+
* - C0 control chars (0x00-0x1F) except TAB(0x09), LF(0x0A), CR(0x0D)
|
|
36
|
+
* - C1 control chars (0x80-0x9F) that can cause display issues
|
|
37
|
+
* - BiDi control chars (U+200E, U+200F, U+202A-U+202E, U+2066-U+2069)
|
|
38
|
+
* - Zero-width chars (U+200B, U+FEFF)
|
|
39
|
+
*
|
|
40
|
+
* Characters preserved:
|
|
41
|
+
* - All printable Unicode including emojis
|
|
42
|
+
* - ZWJ (U+200D) - needed for complex emoji sequences
|
|
43
|
+
* - ZWNJ (U+200C) - preserve zero-width non-joiner
|
|
44
|
+
* - DEL (0x7F) - handled functionally by applyOperations, not a display issue
|
|
45
|
+
* - CR/LF (0x0D/0x0A) - needed for line breaks
|
|
46
|
+
* - TAB (0x09) - preserve tabs
|
|
47
|
+
*/
|
|
48
|
+
export declare function stripUnsafeCharacters(str: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Sanitize a string for display in inline UI components (e.g. Help, Suggestions).
|
|
51
|
+
* Removes ANSI codes, dangerous control characters, collapses whitespace
|
|
52
|
+
* characters into a single space, and optionally truncates.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sanitizeForDisplay(str: string, maxLength?: number): string;
|
|
55
|
+
/**
|
|
56
|
+
* Normalizes escaped newline characters (e.g., "\\n") into actual newline characters.
|
|
57
|
+
*/
|
|
58
|
+
export declare function normalizeEscapedNewlines(value: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Cached version of stringWidth function for better performance
|
|
61
|
+
*/
|
|
62
|
+
export declare const getCachedStringWidth: (str: string) => number;
|
|
63
|
+
export declare function escapeAnsiCtrlCodes<T>(obj: T): T;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { stripVTControlCharacters } from "node:util";
|
|
2
|
+
import { LRU_BUFFER_PERF_CACHE_LIMIT } from "../constants.js";
|
|
3
|
+
import ansiRegex from "ansi-regex";
|
|
4
|
+
import { LRUCache } from "mnemonist";
|
|
5
|
+
import stringWidth from "string-width";
|
|
6
|
+
import stripAnsi from "strip-ansi";
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the maximum width of a multi-line ASCII art string.
|
|
9
|
+
* @param asciiArt The ASCII art string.
|
|
10
|
+
* @returns The length of the longest line in the ASCII art.
|
|
11
|
+
*/
|
|
12
|
+
export const getAsciiArtWidth = (asciiArt) => {
|
|
13
|
+
if (!asciiArt) {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
const lines = asciiArt.split("\n");
|
|
17
|
+
return Math.max(...lines.map((line) => line.length));
|
|
18
|
+
};
|
|
19
|
+
/*
|
|
20
|
+
* -------------------------------------------------------------------------
|
|
21
|
+
* Unicode‑aware helpers (work at the code‑point level rather than UTF‑16
|
|
22
|
+
* code units so that surrogate‑pair emoji count as one "column".)
|
|
23
|
+
* ---------------------------------------------------------------------- */
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a string contains only ASCII characters (0-127).
|
|
26
|
+
*/
|
|
27
|
+
export function isAscii(str) {
|
|
28
|
+
for (let i = 0; i < str.length; i++) {
|
|
29
|
+
if (str.charCodeAt(i) > 127) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
// Cache for code points
|
|
36
|
+
const MAX_STRING_LENGTH_TO_CACHE = 1000;
|
|
37
|
+
const codePointsCache = new LRUCache(LRU_BUFFER_PERF_CACHE_LIMIT);
|
|
38
|
+
export function toCodePoints(str) {
|
|
39
|
+
// ASCII fast path
|
|
40
|
+
if (isAscii(str)) {
|
|
41
|
+
return str.split("");
|
|
42
|
+
}
|
|
43
|
+
// Cache short strings
|
|
44
|
+
if (str.length <= MAX_STRING_LENGTH_TO_CACHE) {
|
|
45
|
+
const cached = codePointsCache.get(str);
|
|
46
|
+
if (cached !== undefined) {
|
|
47
|
+
return cached;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const result = Array.from(str);
|
|
51
|
+
// Cache result
|
|
52
|
+
if (str.length <= MAX_STRING_LENGTH_TO_CACHE) {
|
|
53
|
+
codePointsCache.set(str, result);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
export function cpLen(str) {
|
|
58
|
+
if (isAscii(str)) {
|
|
59
|
+
return str.length;
|
|
60
|
+
}
|
|
61
|
+
return toCodePoints(str).length;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Converts a code point index to a UTF-16 code unit offset.
|
|
65
|
+
*/
|
|
66
|
+
export function cpIndexToOffset(str, cpIndex) {
|
|
67
|
+
return cpSlice(str, 0, cpIndex).length;
|
|
68
|
+
}
|
|
69
|
+
export function cpSlice(str, start, end) {
|
|
70
|
+
if (isAscii(str)) {
|
|
71
|
+
return str.slice(start, end);
|
|
72
|
+
}
|
|
73
|
+
// Slice by code‑point indices and re‑join.
|
|
74
|
+
const arr = toCodePoints(str).slice(start, end);
|
|
75
|
+
return arr.join("");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Strip characters that can break terminal rendering.
|
|
79
|
+
*
|
|
80
|
+
* This is a strict sanitization function intended for general display
|
|
81
|
+
* contexts. It strips all C1 control characters (0x80-0x9F) and VT
|
|
82
|
+
* control sequences. For list display contexts where a more lenient
|
|
83
|
+
* approach is needed (preserving C1 characters and only stripping ANSI
|
|
84
|
+
* codes and newlines/tabs), use a separate function instead.
|
|
85
|
+
*
|
|
86
|
+
* Processing order:
|
|
87
|
+
* 1. stripAnsi removes ANSI escape sequences (including 8-bit CSI 0x9B)
|
|
88
|
+
* 2. Regex strips C0, C1, BiDi, and zero-width control characters
|
|
89
|
+
* 3. stripVTControlCharacters removes any remaining VT sequences
|
|
90
|
+
*
|
|
91
|
+
* Characters stripped:
|
|
92
|
+
* - ANSI escape sequences (via strip-ansi)
|
|
93
|
+
* - VT control sequences (via Node.js util.stripVTControlCharacters)
|
|
94
|
+
* - C0 control chars (0x00-0x1F) except TAB(0x09), LF(0x0A), CR(0x0D)
|
|
95
|
+
* - C1 control chars (0x80-0x9F) that can cause display issues
|
|
96
|
+
* - BiDi control chars (U+200E, U+200F, U+202A-U+202E, U+2066-U+2069)
|
|
97
|
+
* - Zero-width chars (U+200B, U+FEFF)
|
|
98
|
+
*
|
|
99
|
+
* Characters preserved:
|
|
100
|
+
* - All printable Unicode including emojis
|
|
101
|
+
* - ZWJ (U+200D) - needed for complex emoji sequences
|
|
102
|
+
* - ZWNJ (U+200C) - preserve zero-width non-joiner
|
|
103
|
+
* - DEL (0x7F) - handled functionally by applyOperations, not a display issue
|
|
104
|
+
* - CR/LF (0x0D/0x0A) - needed for line breaks
|
|
105
|
+
* - TAB (0x09) - preserve tabs
|
|
106
|
+
*/
|
|
107
|
+
export function stripUnsafeCharacters(str) {
|
|
108
|
+
const strippedAnsi = stripAnsi(str);
|
|
109
|
+
// Strip C0, C1, and other unsafe characters via regex first.
|
|
110
|
+
// This is more efficient than multiple replaces and crucially removes C1
|
|
111
|
+
// characters (e.g., 0x90 DCS) before they can be misinterpreted by
|
|
112
|
+
// stripVTControlCharacters, which could otherwise cause data loss.
|
|
113
|
+
const strippedWithRegex = strippedAnsi.replace(
|
|
114
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex:터미널 입력을 파싱하기 위한 정규식입니다.
|
|
115
|
+
/[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\x9F\u200E\u200F\u202A-\u202E\u2066-\u2069\u200B\uFEFF]/g, "");
|
|
116
|
+
// Finally, use stripVTControlCharacters for any remaining VT sequences
|
|
117
|
+
// that the regex might not cover.
|
|
118
|
+
return stripVTControlCharacters(strippedWithRegex);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Sanitize a string for display in inline UI components (e.g. Help, Suggestions).
|
|
122
|
+
* Removes ANSI codes, dangerous control characters, collapses whitespace
|
|
123
|
+
* characters into a single space, and optionally truncates.
|
|
124
|
+
*/
|
|
125
|
+
export function sanitizeForDisplay(str, maxLength) {
|
|
126
|
+
if (!str) {
|
|
127
|
+
return "";
|
|
128
|
+
}
|
|
129
|
+
let sanitized = stripUnsafeCharacters(str).replace(/\s+/g, " ");
|
|
130
|
+
if (maxLength && sanitized.length > maxLength) {
|
|
131
|
+
sanitized = `${sanitized.substring(0, maxLength - 3)}...`;
|
|
132
|
+
}
|
|
133
|
+
return sanitized;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Normalizes escaped newline characters (e.g., "\\n") into actual newline characters.
|
|
137
|
+
*/
|
|
138
|
+
export function normalizeEscapedNewlines(value) {
|
|
139
|
+
return value.replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n");
|
|
140
|
+
}
|
|
141
|
+
const stringWidthCache = new LRUCache(LRU_BUFFER_PERF_CACHE_LIMIT);
|
|
142
|
+
/**
|
|
143
|
+
* Cached version of stringWidth function for better performance
|
|
144
|
+
*/
|
|
145
|
+
export const getCachedStringWidth = (str) => {
|
|
146
|
+
// ASCII printable chars (32-126) have width 1.
|
|
147
|
+
// This is a very frequent path, so we use a fast numeric check.
|
|
148
|
+
if (str.length === 1) {
|
|
149
|
+
const code = str.charCodeAt(0);
|
|
150
|
+
if (code >= 0x20 && code <= 0x7e) {
|
|
151
|
+
return 1;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const cached = stringWidthCache.get(str);
|
|
155
|
+
if (cached !== undefined) {
|
|
156
|
+
return cached;
|
|
157
|
+
}
|
|
158
|
+
let width;
|
|
159
|
+
try {
|
|
160
|
+
width = stringWidth(str);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
// Fallback for characters that cause string-width to crash (e.g. U+0602)
|
|
164
|
+
// See: https://github.com/google-gemini/gemini-cli/issues/16418
|
|
165
|
+
width = toCodePoints(stripAnsi(str)).length;
|
|
166
|
+
}
|
|
167
|
+
stringWidthCache.set(str, width);
|
|
168
|
+
return width;
|
|
169
|
+
};
|
|
170
|
+
const regex = ansiRegex();
|
|
171
|
+
/* Recursively traverses a JSON-like structure (objects, arrays, primitives)
|
|
172
|
+
* and escapes all ANSI control characters found in any string values.
|
|
173
|
+
*
|
|
174
|
+
* This function is designed to be robust, handling deeply nested objects and
|
|
175
|
+
* arrays. It applies a regex-based replacement to all string values to
|
|
176
|
+
* safely escape control characters.
|
|
177
|
+
*
|
|
178
|
+
* To optimize performance, this function uses a "copy-on-write" strategy.
|
|
179
|
+
* It avoids allocating new objects or arrays if no nested string values
|
|
180
|
+
* required escaping, returning the original object reference in such cases.
|
|
181
|
+
*
|
|
182
|
+
* @param obj The JSON-like value (object, array, string, etc.) to traverse.
|
|
183
|
+
* @returns A new value with all nested string fields escaped, or the
|
|
184
|
+
* original `obj` reference if no changes were necessary.
|
|
185
|
+
*/
|
|
186
|
+
export function escapeAnsiCtrlCodes(obj) {
|
|
187
|
+
if (typeof obj === "string") {
|
|
188
|
+
if (obj.search(regex) === -1) {
|
|
189
|
+
return obj; // No changes return original string
|
|
190
|
+
}
|
|
191
|
+
regex.lastIndex = 0; // needed for global regex
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
193
|
+
return obj.replace(regex, (match) => JSON.stringify(match).slice(1, -1));
|
|
194
|
+
}
|
|
195
|
+
if (obj === null || typeof obj !== "object") {
|
|
196
|
+
return obj;
|
|
197
|
+
}
|
|
198
|
+
if (Array.isArray(obj)) {
|
|
199
|
+
let newArr = null;
|
|
200
|
+
for (let i = 0; i < obj.length; i++) {
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
202
|
+
const value = obj[i];
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
204
|
+
const escapedValue = escapeAnsiCtrlCodes(value);
|
|
205
|
+
if (escapedValue !== value) {
|
|
206
|
+
if (newArr === null) {
|
|
207
|
+
newArr = [...obj];
|
|
208
|
+
}
|
|
209
|
+
newArr[i] = escapedValue;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
213
|
+
return (newArr !== null ? newArr : obj);
|
|
214
|
+
}
|
|
215
|
+
let newObj = null;
|
|
216
|
+
const keys = Object.keys(obj);
|
|
217
|
+
for (const key of keys) {
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
219
|
+
const value = obj[key];
|
|
220
|
+
const escapedValue = escapeAnsiCtrlCodes(value);
|
|
221
|
+
if (escapedValue !== value) {
|
|
222
|
+
if (newObj === null) {
|
|
223
|
+
newObj = { ...obj };
|
|
224
|
+
}
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
226
|
+
newObj[key] = escapedValue;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return newObj !== null ? newObj : obj;
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=textUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textUtil.js","sourceRoot":"","sources":["../../../src/cli/utils/textUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC5D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,OAAO,CAAC,CAAC;IACV,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF;;;;4EAI4E;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