@tyvm/knowhow 0.0.33 → 0.0.35
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/autodoc/plugins/downloader/downloader.mdx +2 -2
- package/benchmarks/.dockerignore +7 -0
- package/benchmarks/README.md +166 -0
- package/benchmarks/docker/Dockerfile +68 -0
- package/benchmarks/example-config.yml +27 -0
- package/benchmarks/jest.config.js +13 -0
- package/benchmarks/package-lock.json +4297 -0
- package/benchmarks/package.json +39 -0
- package/benchmarks/results/4542435/2025-08-05/lms/lms-openai-gpt-oss-20b.json +2814 -0
- package/benchmarks/results/4542435/2025-08-05/lms/lms-qwen-qwen3-30b-a3b-2507.json +2014 -0
- package/benchmarks/results/4fb9125/2025-08-07/anthropic/anthropic-claude-sonnet-4-20250514.json +3121 -0
- package/benchmarks/results/5766aee/2025-08-02/lms-qwen/qwen3-coder-30b.json +98 -0
- package/benchmarks/results/6d73808/2025-08-07/openai/openai-gpt-5.json +3256 -0
- package/benchmarks/results/77bf0a6/2025-08-02/lms-qwen/qwen3-30b-a3b-2507.json +4298 -0
- package/benchmarks/results/8c0d445/2025-08-03/anthropic/anthropic-claude-sonnet-4-20250514.json +3031 -0
- package/benchmarks/results/8c0d445/2025-08-03/openai/openai-gpt-4.1-2025-04-14.json +2990 -0
- package/benchmarks/results/ac6b2ab/2025-08-03/anthropic/anthropic-claude-sonnet-4-20250514.json +3256 -0
- package/benchmarks/results/ac6b2ab/2025-08-03/lms/lms-qwen-qwen3-coder-30b.json +3007 -0
- package/benchmarks/results/ac6b2ab/2025-08-03/openai/openai-gpt-4.1-2025-04-14.json +3256 -0
- package/benchmarks/results/ac6b2ab/2025-08-03/openai/openai-gpt-4.1-mini-2025-04-14.json +3036 -0
- package/benchmarks/results/ac6b2ab/2025-08-03/openai/openai-gpt-4.1-nano-2025-04-14.json +3280 -0
- package/benchmarks/results/adff675/2025-08-04/lms/lms-qwen-qwen3-30b-a3b-2507.json +1920 -0
- package/benchmarks/results/adff675/2025-08-04/lms/lms-qwen-qwen3-coder-30b.json +3281 -0
- package/benchmarks/results/b502ed9/2025-08-03/lms-qwen/qwen3-coder-30b.json +2896 -0
- package/benchmarks/results/d1a8129/2025-08-03/lms/lms-qwen-qwen3-coder-30b.json +3011 -0
- package/benchmarks/results/e60471c/2025-08-03/lms/qwen3-30b-a3b-2507.json +3003 -0
- package/benchmarks/scripts/build-and-run.sh +47 -0
- package/benchmarks/scripts/clone-exercism.sh +92 -0
- package/benchmarks/scripts/validate.sh +48 -0
- package/benchmarks/src/__tests__/runner.test.ts +27 -0
- package/benchmarks/src/cli.ts +90 -0
- package/benchmarks/src/evaluators/EvaluatorRegistry.ts +64 -0
- package/benchmarks/src/evaluators/JavaScriptEvaluator.ts +183 -0
- package/benchmarks/src/evaluators/index.ts +3 -0
- package/benchmarks/src/evaluators/types.ts +22 -0
- package/benchmarks/src/index.ts +3 -0
- package/benchmarks/src/providers.ts +13 -0
- package/benchmarks/src/runner.ts +824 -0
- package/benchmarks/src/types.ts +63 -0
- package/benchmarks/tsconfig.json +19 -0
- package/jest.config.js +2 -1
- package/leaderboard/README.md +148 -0
- package/leaderboard/app/api/benchmark-data/route.ts +131 -0
- package/leaderboard/app/api/benchmark-detail/route.ts +172 -0
- package/leaderboard/app/details/[model]/[provider]/[language]/page.tsx +501 -0
- package/leaderboard/app/exercise/[model]/[provider]/[language]/[exercise]/page.tsx +375 -0
- package/leaderboard/app/globals.css +27 -0
- package/leaderboard/app/layout.tsx +21 -0
- package/leaderboard/app/page.tsx +170 -0
- package/leaderboard/components/LeaderboardTable.tsx +168 -0
- package/leaderboard/components/PerformanceChart.tsx +109 -0
- package/leaderboard/next-env.d.ts +5 -0
- package/leaderboard/next.config.js +4 -0
- package/leaderboard/package-lock.json +6363 -0
- package/leaderboard/package.json +28 -0
- package/leaderboard/postcss.config.js +6 -0
- package/leaderboard/tailwind.config.js +17 -0
- package/leaderboard/tsconfig.json +28 -0
- package/leaderboard/types/benchmark.ts +67 -0
- package/leaderboard/utils/dataProcessor.ts +33 -0
- package/package.json +2 -1
- package/src/agents/base/base.ts +182 -24
- package/src/agents/base/prompt.ts +28 -0
- package/src/agents/index.ts +3 -0
- package/src/agents/patcher/patcher.ts +6 -4
- package/src/agents/setup/setup.ts +56 -0
- package/src/agents/tools/agentCall.ts +6 -2
- package/src/agents/tools/aiClient.ts +74 -8
- package/src/agents/tools/execCommand.ts +13 -14
- package/src/agents/tools/executeScript/README.md +16 -0
- package/src/agents/tools/index.ts +2 -0
- package/src/agents/tools/list.ts +73 -16
- package/src/agents/tools/startAgentTask.ts +109 -0
- package/src/agents/tools/textSearch.ts +1 -1
- package/src/agents/tools/visionTool.ts +31 -2
- package/src/agents/tools/ycmd/client.ts +608 -0
- package/src/agents/tools/ycmd/definitions.ts +294 -0
- package/src/agents/tools/ycmd/detection.ts +211 -0
- package/src/agents/tools/ycmd/index.ts +11 -0
- package/src/agents/tools/ycmd/installer.ts +251 -0
- package/src/agents/tools/ycmd/server.ts +535 -0
- package/src/agents/tools/ycmd/serverManager.ts +316 -0
- package/src/agents/tools/ycmd/tools/completion.ts +113 -0
- package/src/agents/tools/ycmd/tools/diagnostics.ts +155 -0
- package/src/agents/tools/ycmd/tools/getLocations.ts +173 -0
- package/src/agents/tools/ycmd/tools/goto.ts +169 -0
- package/src/agents/tools/ycmd/tools/refactor.ts +204 -0
- package/src/agents/tools/ycmd/tools/signature.ts +174 -0
- package/src/agents/tools/ycmd/tools/start.ts +95 -0
- package/src/agents/tools/ycmd/utils/pathUtils.ts +59 -0
- package/src/ai.ts +15 -0
- package/src/chat/CliChatService.ts +277 -0
- package/src/chat/modules/AgentModule.ts +985 -0
- package/src/chat/modules/AskModule.ts +98 -0
- package/src/chat/modules/BaseChatModule.ts +66 -0
- package/src/chat/modules/InternalChatModule.ts +174 -0
- package/src/chat/modules/SearchModule.ts +166 -0
- package/src/chat/modules/SetupModule.ts +185 -0
- package/src/chat/modules/SystemModule.ts +120 -0
- package/src/chat/modules/VoiceModule.ts +70 -0
- package/src/chat/modules/index.js +5 -0
- package/src/chat/types.ts +97 -0
- package/src/chat.ts +9 -1
- package/src/chat2.ts +62 -0
- package/src/cli.ts +264 -35
- package/src/clients/anthropic.ts +14 -7
- package/src/clients/gemini.ts +15 -7
- package/src/clients/http.ts +17 -7
- package/src/clients/index.ts +117 -4
- package/src/clients/knowhow.ts +7 -2
- package/src/clients/knowhowMcp.ts +118 -0
- package/src/clients/openai.ts +32 -8
- package/src/clients/types.ts +1 -0
- package/src/clients/xai.ts +17 -5
- package/src/config.ts +30 -5
- package/src/conversion.ts +4 -1
- package/src/login.ts +26 -9
- package/src/microphone.ts +0 -1
- package/src/plugins/downloader/downloader.ts +191 -49
- package/src/plugins/downloader/plugin.ts +3 -1
- package/src/plugins/plugins.ts +3 -0
- package/src/processors/CustomVariables.ts +425 -0
- package/src/processors/HarmonyToolProcessor.ts +264 -0
- package/src/processors/XmlToolCallProcessor.ts +533 -0
- package/src/processors/index.ts +3 -0
- package/src/prompts/KnowhowConfigExamples.ts +376 -0
- package/src/services/KnowhowClient.ts +49 -3
- package/src/services/Mcp.ts +42 -3
- package/src/services/McpServer.ts +14 -4
- package/src/services/McpWebsocketTransport.ts +21 -7
- package/src/services/MessageProcessor.ts +10 -5
- package/src/services/index.ts +5 -0
- package/src/services/script-execution/ScriptExecutor.ts +34 -1
- package/src/services/types.ts +17 -14
- package/src/types.ts +17 -0
- package/src/utils/index.ts +138 -0
- package/tests/XmlToolCallProcessor.test.ts +468 -0
- package/tests/manual/ycmd/debug_diagnostics_test.ts +127 -0
- package/tests/manual/ycmd/fixtures/debug_diagnostics.ts +26 -0
- package/tests/manual/ycmd/fixtures/file_change_test.ts +17 -0
- package/tests/manual/ycmd/minimal_advanced_test.ts +108 -0
- package/tests/manual/ycmd/simple_diagnostics_test.ts +61 -0
- package/tests/manual/ycmd/simple_test.ts +74 -0
- package/tests/manual/ycmd/test-typescript-sample.ts +34 -0
- package/tests/manual/ycmd/test_advanced_features.ts +407 -0
- package/tests/manual/ycmd/test_advanced_with_tools.ts +320 -0
- package/tests/manual/ycmd/test_comprehensive_typescript.ts +179 -0
- package/tests/manual/ycmd/test_diagnostics_file_changes.ts +249 -0
- package/tests/manual/ycmd/test_diagnostics_fix.ts +99 -0
- package/tests/manual/ycmd/test_diagnostics_simple.ts +100 -0
- package/tests/manual/ycmd/test_diagnostics_timing.ts +120 -0
- package/tests/manual/ycmd/test_discover_commands.ts +310 -0
- package/tests/manual/ycmd/test_endpoints.ts +115 -0
- package/tests/manual/ycmd/test_final_comprehensive.ts +218 -0
- package/tests/manual/ycmd/test_final_validation.ts +150 -0
- package/tests/manual/ycmd/test_implementation.js +42 -0
- package/tests/manual/ycmd/test_individual_ycmd_tool.ts +39 -0
- package/tests/manual/ycmd/test_server_manager.ts +52 -0
- package/tests/manual/ycmd/test_simple_debug.ts +86 -0
- package/tests/manual/ycmd/test_tsserver_workflow.js +83 -0
- package/tests/manual/ycmd/test_tsserver_workflow.ts +122 -0
- package/tests/manual/ycmd/test_typescript_simple.ts +48 -0
- package/tests/manual/ycmd/test_typescript_ycmd.ts +105 -0
- package/tests/manual/ycmd/test_workspace_config.ts +90 -0
- package/tests/manual/ycmd/test_ycmd_auto_start.ts +137 -0
- package/tests/manual/ycmd/test_ycmd_comprehensive.ts +73 -0
- package/tests/manual/ycmd/test_ycmd_connection.py +10 -0
- package/tests/manual/ycmd/test_ycmd_direct.ts +142 -0
- package/tests/manual/ycmd/test_ycmd_experiment.ts +48 -0
- package/tests/manual/ycmd/test_ycmd_final.ts +200 -0
- package/tests/manual/ycmd/test_ycmd_fixed.py +18 -0
- package/tests/manual/ycmd/test_ycmd_integration.ts +112 -0
- package/tests/manual/ycmd/test_ycmd_simple.ts +45 -0
- package/tests/manual/ycmd/test_ycmd_usage.py +27 -0
- package/tests/manual/ycmd/working_simple_test.ts +134 -0
- package/ts_build/src/agents/base/base.d.ts +15 -1
- package/ts_build/src/agents/base/base.js +121 -20
- package/ts_build/src/agents/base/base.js.map +1 -1
- package/ts_build/src/agents/base/prompt.d.ts +1 -1
- package/ts_build/src/agents/base/prompt.js +28 -0
- package/ts_build/src/agents/base/prompt.js.map +1 -1
- package/ts_build/src/agents/index.d.ts +2 -0
- package/ts_build/src/agents/index.js +2 -0
- package/ts_build/src/agents/index.js.map +1 -1
- package/ts_build/src/agents/patcher/patcher.js +6 -3
- package/ts_build/src/agents/patcher/patcher.js.map +1 -1
- package/ts_build/src/agents/setup/setup.d.ts +8 -0
- package/ts_build/src/agents/setup/setup.js +59 -0
- package/ts_build/src/agents/setup/setup.js.map +1 -0
- package/ts_build/src/agents/tools/agentCall.js +5 -2
- package/ts_build/src/agents/tools/agentCall.js.map +1 -1
- package/ts_build/src/agents/tools/aiClient.d.ts +6 -5
- package/ts_build/src/agents/tools/aiClient.js +37 -6
- package/ts_build/src/agents/tools/aiClient.js.map +1 -1
- package/ts_build/src/agents/tools/execCommand.d.ts +2 -2
- package/ts_build/src/agents/tools/execCommand.js +5 -6
- package/ts_build/src/agents/tools/execCommand.js.map +1 -1
- package/ts_build/src/agents/tools/executeScript/index.d.ts +1 -1
- package/ts_build/src/agents/tools/index.d.ts +2 -0
- package/ts_build/src/agents/tools/index.js +2 -0
- package/ts_build/src/agents/tools/index.js.map +1 -1
- package/ts_build/src/agents/tools/list.js +66 -16
- package/ts_build/src/agents/tools/list.js.map +1 -1
- package/ts_build/src/agents/tools/startAgentTask.d.ts +13 -0
- package/ts_build/src/agents/tools/startAgentTask.js +74 -0
- package/ts_build/src/agents/tools/startAgentTask.js.map +1 -0
- package/ts_build/src/agents/tools/startChatTask.d.ts +13 -0
- package/ts_build/src/agents/tools/startChatTask.js +73 -0
- package/ts_build/src/agents/tools/startChatTask.js.map +1 -0
- package/ts_build/src/agents/tools/textSearch.js +1 -1
- package/ts_build/src/agents/tools/textSearch.js.map +1 -1
- package/ts_build/src/agents/tools/visionTool.d.ts +1 -1
- package/ts_build/src/agents/tools/visionTool.js +23 -3
- package/ts_build/src/agents/tools/visionTool.js.map +1 -1
- package/ts_build/src/agents/tools/ycmd/client.d.ts +93 -0
- package/ts_build/src/agents/tools/ycmd/client.js +355 -0
- package/ts_build/src/agents/tools/ycmd/client.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/definitions.d.ts +345 -0
- package/ts_build/src/agents/tools/ycmd/definitions.js +298 -0
- package/ts_build/src/agents/tools/ycmd/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/detection.d.ts +11 -0
- package/ts_build/src/agents/tools/ycmd/detection.js +175 -0
- package/ts_build/src/agents/tools/ycmd/detection.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/index.d.ts +8 -0
- package/ts_build/src/agents/tools/ycmd/index.js +20 -0
- package/ts_build/src/agents/tools/ycmd/index.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/installer.d.ts +19 -0
- package/ts_build/src/agents/tools/ycmd/installer.js +196 -0
- package/ts_build/src/agents/tools/ycmd/installer.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/server.d.ts +35 -0
- package/ts_build/src/agents/tools/ycmd/server.js +363 -0
- package/ts_build/src/agents/tools/ycmd/server.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/serverManager.d.ts +39 -0
- package/ts_build/src/agents/tools/ycmd/serverManager.js +210 -0
- package/ts_build/src/agents/tools/ycmd/serverManager.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/tools/completion.d.ts +22 -0
- package/ts_build/src/agents/tools/ycmd/tools/completion.js +72 -0
- package/ts_build/src/agents/tools/ycmd/tools/completion.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/tools/diagnostics.d.ts +42 -0
- package/ts_build/src/agents/tools/ycmd/tools/diagnostics.js +88 -0
- package/ts_build/src/agents/tools/ycmd/tools/diagnostics.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/tools/getLocations.d.ts +22 -0
- package/ts_build/src/agents/tools/ycmd/tools/getLocations.js +142 -0
- package/ts_build/src/agents/tools/ycmd/tools/getLocations.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/tools/goto.d.ts +20 -0
- package/ts_build/src/agents/tools/ycmd/tools/goto.js +101 -0
- package/ts_build/src/agents/tools/ycmd/tools/goto.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/tools/refactor.d.ts +32 -0
- package/ts_build/src/agents/tools/ycmd/tools/refactor.js +123 -0
- package/ts_build/src/agents/tools/ycmd/tools/refactor.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/tools/signature.d.ts +25 -0
- package/ts_build/src/agents/tools/ycmd/tools/signature.js +110 -0
- package/ts_build/src/agents/tools/ycmd/tools/signature.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/tools/start.d.ts +17 -0
- package/ts_build/src/agents/tools/ycmd/tools/start.js +65 -0
- package/ts_build/src/agents/tools/ycmd/tools/start.js.map +1 -0
- package/ts_build/src/agents/tools/ycmd/utils/pathUtils.d.ts +4 -0
- package/ts_build/src/agents/tools/ycmd/utils/pathUtils.js +67 -0
- package/ts_build/src/agents/tools/ycmd/utils/pathUtils.js.map +1 -0
- package/ts_build/src/ai.d.ts +1 -0
- package/ts_build/src/ai.js +40 -1
- package/ts_build/src/ai.js.map +1 -1
- package/ts_build/src/chat/ChatCommandHandler.d.ts +36 -0
- package/ts_build/src/chat/ChatCommandHandler.js +268 -0
- package/ts_build/src/chat/ChatCommandHandler.js.map +1 -0
- package/ts_build/src/chat/ChatInputManager.d.ts +22 -0
- package/ts_build/src/chat/ChatInputManager.js +85 -0
- package/ts_build/src/chat/ChatInputManager.js.map +1 -0
- package/ts_build/src/chat/ChatManager.d.ts +49 -0
- package/ts_build/src/chat/ChatManager.js +271 -0
- package/ts_build/src/chat/ChatManager.js.map +1 -0
- package/ts_build/src/chat/ChatSession.d.ts +32 -0
- package/ts_build/src/chat/ChatSession.js +3 -0
- package/ts_build/src/chat/ChatSession.js.map +1 -0
- package/ts_build/src/chat/ChatSessionManager.d.ts +19 -0
- package/ts_build/src/chat/ChatSessionManager.js +188 -0
- package/ts_build/src/chat/ChatSessionManager.js.map +1 -0
- package/ts_build/src/chat/ChatStateManager.d.ts +58 -0
- package/ts_build/src/chat/ChatStateManager.js +156 -0
- package/ts_build/src/chat/ChatStateManager.js.map +1 -0
- package/ts_build/src/chat/CliChatService.d.ts +35 -0
- package/ts_build/src/chat/CliChatService.js +201 -0
- package/ts_build/src/chat/CliChatService.js.map +1 -0
- package/ts_build/src/chat/InterruptibleInput.d.ts +20 -0
- package/ts_build/src/chat/InterruptibleInput.js +109 -0
- package/ts_build/src/chat/InterruptibleInput.js.map +1 -0
- package/ts_build/src/chat/interfaces/ChatModule.d.ts +6 -0
- package/ts_build/src/chat/interfaces/ChatModule.js +3 -0
- package/ts_build/src/chat/interfaces/ChatModule.js.map +1 -0
- package/ts_build/src/chat/modules/AgentModule.d.ts +57 -0
- package/ts_build/src/chat/modules/AgentModule.js +709 -0
- package/ts_build/src/chat/modules/AgentModule.js.map +1 -0
- package/ts_build/src/chat/modules/AskModule.d.ts +10 -0
- package/ts_build/src/chat/modules/AskModule.js +63 -0
- package/ts_build/src/chat/modules/AskModule.js.map +1 -0
- package/ts_build/src/chat/modules/BaseChatModule.d.ts +14 -0
- package/ts_build/src/chat/modules/BaseChatModule.js +32 -0
- package/ts_build/src/chat/modules/BaseChatModule.js.map +1 -0
- package/ts_build/src/chat/modules/InternalChatModule.d.ts +24 -0
- package/ts_build/src/chat/modules/InternalChatModule.js +127 -0
- package/ts_build/src/chat/modules/InternalChatModule.js.map +1 -0
- package/ts_build/src/chat/modules/SearchModule.d.ts +12 -0
- package/ts_build/src/chat/modules/SearchModule.js +119 -0
- package/ts_build/src/chat/modules/SearchModule.js.map +1 -0
- package/ts_build/src/chat/modules/SetupModule.d.ts +15 -0
- package/ts_build/src/chat/modules/SetupModule.js +147 -0
- package/ts_build/src/chat/modules/SetupModule.js.map +1 -0
- package/ts_build/src/chat/modules/SystemModule.d.ts +14 -0
- package/ts_build/src/chat/modules/SystemModule.js +90 -0
- package/ts_build/src/chat/modules/SystemModule.js.map +1 -0
- package/ts_build/src/chat/modules/VoiceModule.d.ts +11 -0
- package/ts_build/src/chat/modules/VoiceModule.js +57 -0
- package/ts_build/src/chat/modules/VoiceModule.js.map +1 -0
- package/ts_build/src/chat/types.d.ts +83 -0
- package/ts_build/src/chat/types.js +3 -0
- package/ts_build/src/chat/types.js.map +1 -0
- package/ts_build/src/chat.js +7 -1
- package/ts_build/src/chat.js.map +1 -1
- package/ts_build/src/chat2.d.ts +3 -0
- package/ts_build/src/chat2.js +47 -0
- package/ts_build/src/chat2.js.map +1 -0
- package/ts_build/src/cli.js +218 -37
- package/ts_build/src/cli.js.map +1 -1
- package/ts_build/src/clients/anthropic.d.ts +5 -2
- package/ts_build/src/clients/anthropic.js +12 -7
- package/ts_build/src/clients/anthropic.js.map +1 -1
- package/ts_build/src/clients/gemini.d.ts +6 -3
- package/ts_build/src/clients/gemini.js +13 -7
- package/ts_build/src/clients/gemini.js.map +1 -1
- package/ts_build/src/clients/http.d.ts +1 -0
- package/ts_build/src/clients/http.js +12 -5
- package/ts_build/src/clients/http.js.map +1 -1
- package/ts_build/src/clients/index.d.ts +10 -0
- package/ts_build/src/clients/index.js +74 -4
- package/ts_build/src/clients/index.js.map +1 -1
- package/ts_build/src/clients/knowhow.d.ts +3 -1
- package/ts_build/src/clients/knowhow.js +8 -2
- package/ts_build/src/clients/knowhow.js.map +1 -1
- package/ts_build/src/clients/knowhowMcp.d.ts +20 -0
- package/ts_build/src/clients/knowhowMcp.js +86 -0
- package/ts_build/src/clients/knowhowMcp.js.map +1 -0
- package/ts_build/src/clients/openai.d.ts +5 -2
- package/ts_build/src/clients/openai.js +29 -8
- package/ts_build/src/clients/openai.js.map +1 -1
- package/ts_build/src/clients/types.d.ts +1 -0
- package/ts_build/src/clients/xai.d.ts +5 -2
- package/ts_build/src/clients/xai.js +15 -5
- package/ts_build/src/clients/xai.js.map +1 -1
- package/ts_build/src/config.js +24 -3
- package/ts_build/src/config.js.map +1 -1
- package/ts_build/src/conversion.js +6 -4
- package/ts_build/src/conversion.js.map +1 -1
- package/ts_build/src/login.d.ts +1 -1
- package/ts_build/src/login.js +21 -7
- package/ts_build/src/login.js.map +1 -1
- package/ts_build/src/microphone.js.map +1 -1
- package/ts_build/src/plugins/downloader/downloader.d.ts +7 -5
- package/ts_build/src/plugins/downloader/downloader.js +147 -44
- package/ts_build/src/plugins/downloader/downloader.js.map +1 -1
- package/ts_build/src/plugins/downloader/plugin.js +5 -3
- package/ts_build/src/plugins/downloader/plugin.js.map +1 -1
- package/ts_build/src/plugins/plugins.js +3 -0
- package/ts_build/src/plugins/plugins.js.map +1 -1
- package/ts_build/src/processors/CustomVariables.d.ts +32 -0
- package/ts_build/src/processors/CustomVariables.js +297 -0
- package/ts_build/src/processors/CustomVariables.js.map +1 -0
- package/ts_build/src/processors/HarmonyToolProcessor.d.ts +15 -0
- package/ts_build/src/processors/HarmonyToolProcessor.js +154 -0
- package/ts_build/src/processors/HarmonyToolProcessor.js.map +1 -0
- package/ts_build/src/processors/XmlToolCallProcessor.d.ts +14 -0
- package/ts_build/src/processors/XmlToolCallProcessor.js +357 -0
- package/ts_build/src/processors/XmlToolCallProcessor.js.map +1 -0
- package/ts_build/src/processors/index.d.ts +3 -0
- package/ts_build/src/processors/index.js +7 -1
- package/ts_build/src/processors/index.js.map +1 -1
- package/ts_build/src/prompts/KnowhowConfigExamples.d.ts +2 -0
- package/ts_build/src/prompts/KnowhowConfigExamples.js +379 -0
- package/ts_build/src/prompts/KnowhowConfigExamples.js.map +1 -0
- package/ts_build/src/services/KnowhowClient.d.ts +22 -0
- package/ts_build/src/services/KnowhowClient.js +14 -2
- package/ts_build/src/services/KnowhowClient.js.map +1 -1
- package/ts_build/src/services/Mcp.d.ts +1 -0
- package/ts_build/src/services/Mcp.js +20 -3
- package/ts_build/src/services/Mcp.js.map +1 -1
- package/ts_build/src/services/McpServer.d.ts +1 -1
- package/ts_build/src/services/McpServer.js +8 -4
- package/ts_build/src/services/McpServer.js.map +1 -1
- package/ts_build/src/services/McpWebsocketTransport.js +17 -7
- package/ts_build/src/services/McpWebsocketTransport.js.map +1 -1
- package/ts_build/src/services/MessageProcessor.d.ts +1 -1
- package/ts_build/src/services/MessageProcessor.js +4 -4
- package/ts_build/src/services/MessageProcessor.js.map +1 -1
- package/ts_build/src/services/index.d.ts +2 -0
- package/ts_build/src/services/index.js +4 -0
- package/ts_build/src/services/index.js.map +1 -1
- package/ts_build/src/services/script-execution/ScriptExecutor.d.ts +1 -0
- package/ts_build/src/services/script-execution/ScriptExecutor.js +23 -0
- package/ts_build/src/services/script-execution/ScriptExecutor.js.map +1 -1
- package/ts_build/src/services/types.d.ts +2 -6
- package/ts_build/src/services/types.js +4 -4
- package/ts_build/src/services/types.js.map +1 -1
- package/ts_build/src/types.d.ts +11 -0
- package/ts_build/src/types.js +8 -0
- package/ts_build/src/types.js.map +1 -1
- package/ts_build/src/utils/index.d.ts +2 -0
- package/ts_build/src/utils/index.js +102 -1
- package/ts_build/src/utils/index.js.map +1 -1
- package/ts_build/tests/XmlToolCallProcessor.test.d.ts +1 -0
- package/ts_build/tests/XmlToolCallProcessor.test.js +376 -0
- package/ts_build/tests/XmlToolCallProcessor.test.js.map +1 -0
- package/ts_build/tests/manual/ycmd/debug_diagnostics_test.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/debug_diagnostics_test.js +114 -0
- package/ts_build/tests/manual/ycmd/debug_diagnostics_test.js.map +1 -0
- package/ts_build/tests/manual/ycmd/minimal_advanced_test.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/minimal_advanced_test.js +104 -0
- package/ts_build/tests/manual/ycmd/minimal_advanced_test.js.map +1 -0
- package/ts_build/tests/manual/ycmd/simple_diagnostics_test.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/simple_diagnostics_test.js +74 -0
- package/ts_build/tests/manual/ycmd/simple_diagnostics_test.js.map +1 -0
- package/ts_build/tests/manual/ycmd/simple_test.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/simple_test.js +82 -0
- package/ts_build/tests/manual/ycmd/simple_test.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test-typescript-sample.d.ts +14 -0
- package/ts_build/tests/manual/ycmd/test-typescript-sample.js +20 -0
- package/ts_build/tests/manual/ycmd/test-typescript-sample.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_advanced_features.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_advanced_features.js +297 -0
- package/ts_build/tests/manual/ycmd/test_advanced_features.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_advanced_with_tools.d.ts +3 -0
- package/ts_build/tests/manual/ycmd/test_advanced_with_tools.js +262 -0
- package/ts_build/tests/manual/ycmd/test_advanced_with_tools.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_comprehensive_typescript.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_comprehensive_typescript.js +186 -0
- package/ts_build/tests/manual/ycmd/test_comprehensive_typescript.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_file_changes.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_file_changes.js +174 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_file_changes.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_fix.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_fix.js +106 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_fix.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_simple.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_simple.js +104 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_simple.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_timing.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_timing.js +119 -0
- package/ts_build/tests/manual/ycmd/test_diagnostics_timing.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_discover_commands.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_discover_commands.js +243 -0
- package/ts_build/tests/manual/ycmd/test_discover_commands.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_endpoints.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_endpoints.js +120 -0
- package/ts_build/tests/manual/ycmd/test_endpoints.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_final_comprehensive.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_final_comprehensive.js +221 -0
- package/ts_build/tests/manual/ycmd/test_final_comprehensive.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_final_validation.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_final_validation.js +160 -0
- package/ts_build/tests/manual/ycmd/test_final_validation.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_individual_ycmd_tool.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_individual_ycmd_tool.js +37 -0
- package/ts_build/tests/manual/ycmd/test_individual_ycmd_tool.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_server_manager.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_server_manager.js +38 -0
- package/ts_build/tests/manual/ycmd/test_server_manager.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_simple_debug.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_simple_debug.js +99 -0
- package/ts_build/tests/manual/ycmd/test_simple_debug.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_tsserver_workflow.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_tsserver_workflow.js +128 -0
- package/ts_build/tests/manual/ycmd/test_tsserver_workflow.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_typescript_simple.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_typescript_simple.js +66 -0
- package/ts_build/tests/manual/ycmd/test_typescript_simple.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_typescript_ycmd.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_typescript_ycmd.js +105 -0
- package/ts_build/tests/manual/ycmd/test_typescript_ycmd.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_workspace_config.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_workspace_config.js +89 -0
- package/ts_build/tests/manual/ycmd/test_workspace_config.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_auto_start.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_auto_start.js +130 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_auto_start.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_comprehensive.d.ts +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_comprehensive.js +83 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_comprehensive.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_direct.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_direct.js +149 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_direct.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_experiment.d.ts +15 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_experiment.js +58 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_experiment.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_final.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_final.js +195 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_final.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_integration.d.ts +3 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_integration.js +110 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_integration.js.map +1 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_simple.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_simple.js +36 -0
- package/ts_build/tests/manual/ycmd/test_ycmd_simple.js.map +1 -0
- package/ts_build/tests/manual/ycmd/working_simple_test.d.ts +2 -0
- package/ts_build/tests/manual/ycmd/working_simple_test.js +134 -0
- package/ts_build/tests/manual/ycmd/working_simple_test.js.map +1 -0
- package/tsconfig.json +3 -1
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
import * as crypto from "crypto";
|
|
2
|
+
import { YcmdServer, YcmdServerInfo } from "./server";
|
|
3
|
+
|
|
4
|
+
export interface YcmdRequestOptions {
|
|
5
|
+
method?: "GET" | "POST" | "PUT" | "DELETE";
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface YcmdCompletionRequest {
|
|
11
|
+
filepath: string;
|
|
12
|
+
line_num: number;
|
|
13
|
+
column_num: number;
|
|
14
|
+
file_data: Record<
|
|
15
|
+
string,
|
|
16
|
+
{
|
|
17
|
+
contents: string;
|
|
18
|
+
filetypes: string[];
|
|
19
|
+
}
|
|
20
|
+
>;
|
|
21
|
+
force_semantic?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface YcmdCompletionResponse {
|
|
25
|
+
completions: {
|
|
26
|
+
insertion_text: string;
|
|
27
|
+
menu_text?: string;
|
|
28
|
+
extra_menu_info?: string;
|
|
29
|
+
detailed_info?: string;
|
|
30
|
+
kind?: string;
|
|
31
|
+
}[];
|
|
32
|
+
completion_start_column: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface YcmdDiagnostic {
|
|
36
|
+
kind: "ERROR" | "WARNING" | "INFO";
|
|
37
|
+
text: string;
|
|
38
|
+
location: {
|
|
39
|
+
line_num: number;
|
|
40
|
+
column_num: number;
|
|
41
|
+
filepath: string;
|
|
42
|
+
};
|
|
43
|
+
location_extent: {
|
|
44
|
+
start: {
|
|
45
|
+
line_num: number;
|
|
46
|
+
column_num: number;
|
|
47
|
+
filepath: string;
|
|
48
|
+
};
|
|
49
|
+
end: {
|
|
50
|
+
line_num: number;
|
|
51
|
+
column_num: number;
|
|
52
|
+
filepath: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
ranges: {
|
|
56
|
+
start: {
|
|
57
|
+
line_num: number;
|
|
58
|
+
column_num: number;
|
|
59
|
+
filepath: string;
|
|
60
|
+
};
|
|
61
|
+
end: {
|
|
62
|
+
line_num: number;
|
|
63
|
+
column_num: number;
|
|
64
|
+
filepath: string;
|
|
65
|
+
};
|
|
66
|
+
}[];
|
|
67
|
+
fixit_available: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface YcmdGoToResponse {
|
|
71
|
+
filepath: string;
|
|
72
|
+
line_num: number;
|
|
73
|
+
column_num: number;
|
|
74
|
+
description?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* HTTP client for communicating with ycmd server using HMAC authentication
|
|
79
|
+
*/
|
|
80
|
+
export class YcmdClient {
|
|
81
|
+
private serverInfo: YcmdServerInfo;
|
|
82
|
+
private baseUrl: string;
|
|
83
|
+
|
|
84
|
+
constructor(serverInfo: YcmdServerInfo) {
|
|
85
|
+
this.serverInfo = serverInfo;
|
|
86
|
+
this.baseUrl = `http://${serverInfo.host}:${serverInfo.port}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Make an authenticated request to the ycmd server
|
|
91
|
+
*/
|
|
92
|
+
async request<T = any>(
|
|
93
|
+
endpoint: string,
|
|
94
|
+
data?: any,
|
|
95
|
+
options: YcmdRequestOptions = {}
|
|
96
|
+
): Promise<T> {
|
|
97
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
98
|
+
const method = options.method || (data ? "POST" : "GET");
|
|
99
|
+
const timeout = options.timeout || 10000;
|
|
100
|
+
|
|
101
|
+
// Prepare request body
|
|
102
|
+
const body = data ? JSON.stringify(data) : undefined;
|
|
103
|
+
|
|
104
|
+
// Generate HMAC signature
|
|
105
|
+
const hmac = this.generateHmac(method, endpoint, body || "");
|
|
106
|
+
|
|
107
|
+
// Prepare headers
|
|
108
|
+
const headers: Record<string, string> = {
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
"X-Ycm-Hmac": hmac,
|
|
111
|
+
...options.headers,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
const controller = new AbortController();
|
|
116
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
117
|
+
|
|
118
|
+
const response = await fetch(url, {
|
|
119
|
+
method,
|
|
120
|
+
headers,
|
|
121
|
+
body,
|
|
122
|
+
signal: controller.signal,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
clearTimeout(timeoutId);
|
|
126
|
+
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
const errorText = await response.text();
|
|
129
|
+
throw new Error(`ycmd server error (${response.status}): ${errorText}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const result = await response.json();
|
|
133
|
+
return result as T;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
136
|
+
throw new Error(`Request to ycmd server timed out after ${timeout}ms`);
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Generate HMAC signature for request authentication using ycmd's nested HMAC algorithm
|
|
144
|
+
* Based on the official ycmd example client implementation
|
|
145
|
+
*/
|
|
146
|
+
private generateHmac(method: string, path: string, body: string): string {
|
|
147
|
+
const secret = Buffer.from(this.serverInfo.hmacSecret, "base64");
|
|
148
|
+
|
|
149
|
+
// Create individual HMACs for method, path, and body
|
|
150
|
+
const methodHmac = crypto
|
|
151
|
+
.createHmac("sha256", secret)
|
|
152
|
+
.update(method, "utf8")
|
|
153
|
+
.digest();
|
|
154
|
+
const pathHmac = crypto
|
|
155
|
+
.createHmac("sha256", secret)
|
|
156
|
+
.update(path, "utf8")
|
|
157
|
+
.digest();
|
|
158
|
+
const bodyHmac = crypto
|
|
159
|
+
.createHmac("sha256", secret)
|
|
160
|
+
.update(body, "utf8")
|
|
161
|
+
.digest();
|
|
162
|
+
|
|
163
|
+
// Concatenate the three HMACs
|
|
164
|
+
const joinedHmacInput = Buffer.concat([methodHmac, pathHmac, bodyHmac]);
|
|
165
|
+
|
|
166
|
+
// Create final HMAC of the concatenated result
|
|
167
|
+
const finalHmac = crypto
|
|
168
|
+
.createHmac("sha256", secret)
|
|
169
|
+
.update(joinedHmacInput)
|
|
170
|
+
.digest();
|
|
171
|
+
|
|
172
|
+
// Return base64 encoded result
|
|
173
|
+
return Buffer.from(finalHmac).toString("base64");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Original simple HMAC method for fallback
|
|
178
|
+
*/
|
|
179
|
+
private generateSimpleHmac(
|
|
180
|
+
method: string,
|
|
181
|
+
path: string,
|
|
182
|
+
body: string
|
|
183
|
+
): string {
|
|
184
|
+
const hmac = crypto.createHmac(
|
|
185
|
+
"sha256",
|
|
186
|
+
Buffer.from(this.serverInfo.hmacSecret, "base64")
|
|
187
|
+
);
|
|
188
|
+
const message = `${method}&${path}&${body}`;
|
|
189
|
+
hmac.update(message);
|
|
190
|
+
return Buffer.from(hmac.digest()).toString("base64");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Check if server is ready
|
|
195
|
+
*/
|
|
196
|
+
async isReady(): Promise<boolean> {
|
|
197
|
+
try {
|
|
198
|
+
await this.request("/ready");
|
|
199
|
+
return true;
|
|
200
|
+
} catch {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Check server health
|
|
207
|
+
*/
|
|
208
|
+
async isHealthy(): Promise<boolean> {
|
|
209
|
+
try {
|
|
210
|
+
await this.request("/ready");
|
|
211
|
+
return true;
|
|
212
|
+
} catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Load extra configuration for a project
|
|
219
|
+
*/
|
|
220
|
+
async loadExtraConfFile(filepath: string): Promise<boolean> {
|
|
221
|
+
try {
|
|
222
|
+
const response = await this.request<{ found: boolean }>(
|
|
223
|
+
"/load_extra_conf_file",
|
|
224
|
+
{
|
|
225
|
+
filepath,
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
return response.found;
|
|
229
|
+
} catch {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get code completions
|
|
236
|
+
*/
|
|
237
|
+
async getCompletions(
|
|
238
|
+
request: YcmdCompletionRequest
|
|
239
|
+
): Promise<YcmdCompletionResponse> {
|
|
240
|
+
return this.request<YcmdCompletionResponse>("/completions", request);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Get detailed completion information
|
|
245
|
+
*/
|
|
246
|
+
async getCompletionDetail(request: YcmdCompletionRequest): Promise<any> {
|
|
247
|
+
return this.request("/detailed_diagnostic", request);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Get diagnostics for a file using FileReadyToParse event
|
|
252
|
+
*/
|
|
253
|
+
async getDiagnostics(
|
|
254
|
+
filepath: string,
|
|
255
|
+
contents: string,
|
|
256
|
+
filetypes: string[],
|
|
257
|
+
line_num: number = 1,
|
|
258
|
+
column_num: number = 1
|
|
259
|
+
): Promise<YcmdDiagnostic[]> {
|
|
260
|
+
const response = await this.request<YcmdDiagnostic[]>(
|
|
261
|
+
"/event_notification",
|
|
262
|
+
{
|
|
263
|
+
event_name: "FileReadyToParse",
|
|
264
|
+
filepath,
|
|
265
|
+
line_num,
|
|
266
|
+
column_num,
|
|
267
|
+
file_data: {
|
|
268
|
+
[filepath]: {
|
|
269
|
+
contents,
|
|
270
|
+
filetypes,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
return response || [];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Go to definition
|
|
281
|
+
*/
|
|
282
|
+
async goToDefinition(
|
|
283
|
+
filepath: string,
|
|
284
|
+
line: number,
|
|
285
|
+
column: number,
|
|
286
|
+
contents: string,
|
|
287
|
+
filetypes: string[]
|
|
288
|
+
): Promise<YcmdGoToResponse> {
|
|
289
|
+
return this.request<YcmdGoToResponse>("/run_completer_command", {
|
|
290
|
+
command_arguments: ["GoTo"],
|
|
291
|
+
filepath,
|
|
292
|
+
line_num: line,
|
|
293
|
+
column_num: column,
|
|
294
|
+
file_data: {
|
|
295
|
+
[filepath]: {
|
|
296
|
+
contents,
|
|
297
|
+
filetypes,
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Go to declaration
|
|
305
|
+
*/
|
|
306
|
+
async goToDeclaration(
|
|
307
|
+
filepath: string,
|
|
308
|
+
line: number,
|
|
309
|
+
column: number,
|
|
310
|
+
contents: string,
|
|
311
|
+
filetypes: string[]
|
|
312
|
+
): Promise<YcmdGoToResponse> {
|
|
313
|
+
return this.request<YcmdGoToResponse>("/run_completer_command", {
|
|
314
|
+
command_arguments: ["GoToDeclaration"],
|
|
315
|
+
filepath,
|
|
316
|
+
line_num: line,
|
|
317
|
+
column_num: column,
|
|
318
|
+
file_data: {
|
|
319
|
+
[filepath]: {
|
|
320
|
+
contents,
|
|
321
|
+
filetypes,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Go to references
|
|
329
|
+
*/
|
|
330
|
+
async goToReferences(
|
|
331
|
+
filepath: string,
|
|
332
|
+
line: number,
|
|
333
|
+
column: number,
|
|
334
|
+
contents: string,
|
|
335
|
+
filetypes: string[]
|
|
336
|
+
): Promise<YcmdGoToResponse[]> {
|
|
337
|
+
return this.request<YcmdGoToResponse[]>("/run_completer_command", {
|
|
338
|
+
command_arguments: ["GoToReferences"],
|
|
339
|
+
filepath,
|
|
340
|
+
line_num: line,
|
|
341
|
+
column_num: column,
|
|
342
|
+
file_data: {
|
|
343
|
+
[filepath]: {
|
|
344
|
+
contents,
|
|
345
|
+
filetypes,
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Get signature help
|
|
353
|
+
*/
|
|
354
|
+
async getSignatureHelp(
|
|
355
|
+
filepath: string,
|
|
356
|
+
line: number,
|
|
357
|
+
column: number,
|
|
358
|
+
contents: string,
|
|
359
|
+
filetypes: string[]
|
|
360
|
+
): Promise<any> {
|
|
361
|
+
return this.request("/run_completer_command", {
|
|
362
|
+
command_arguments: ["GetType"],
|
|
363
|
+
filepath,
|
|
364
|
+
line_num: line,
|
|
365
|
+
column_num: column,
|
|
366
|
+
file_data: {
|
|
367
|
+
[filepath]: {
|
|
368
|
+
contents,
|
|
369
|
+
filetypes,
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Get available refactoring commands
|
|
377
|
+
*/
|
|
378
|
+
async getRefactorCommands(
|
|
379
|
+
filepath: string,
|
|
380
|
+
line: number,
|
|
381
|
+
column: number,
|
|
382
|
+
contents: string,
|
|
383
|
+
filetypes: string[]
|
|
384
|
+
): Promise<any[]> {
|
|
385
|
+
return this.request<any[]>("/defined_subcommands", {
|
|
386
|
+
filepath,
|
|
387
|
+
line_num: line,
|
|
388
|
+
column_num: column,
|
|
389
|
+
file_data: {
|
|
390
|
+
[filepath]: {
|
|
391
|
+
contents,
|
|
392
|
+
filetypes,
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Refactor: Rename symbol
|
|
400
|
+
*/
|
|
401
|
+
async refactorRename(
|
|
402
|
+
filepath: string,
|
|
403
|
+
line: number,
|
|
404
|
+
column: number,
|
|
405
|
+
contents: string,
|
|
406
|
+
filetypes: string[],
|
|
407
|
+
newName: string
|
|
408
|
+
): Promise<any> {
|
|
409
|
+
return this.request("/run_completer_command", {
|
|
410
|
+
command_arguments: ["RefactorRename", newName],
|
|
411
|
+
filepath,
|
|
412
|
+
line_num: line,
|
|
413
|
+
column_num: column,
|
|
414
|
+
file_data: {
|
|
415
|
+
[filepath]: {
|
|
416
|
+
contents,
|
|
417
|
+
filetypes,
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Refactor: Extract method
|
|
425
|
+
*/
|
|
426
|
+
async refactorExtractMethod(
|
|
427
|
+
filepath: string,
|
|
428
|
+
line: number,
|
|
429
|
+
column: number,
|
|
430
|
+
contents: string,
|
|
431
|
+
filetypes: string[]
|
|
432
|
+
): Promise<any> {
|
|
433
|
+
return this.request("/run_completer_command", {
|
|
434
|
+
command_arguments: ["RefactorExtractMethod"],
|
|
435
|
+
filepath,
|
|
436
|
+
line_num: line,
|
|
437
|
+
column_num: column,
|
|
438
|
+
file_data: {
|
|
439
|
+
[filepath]: {
|
|
440
|
+
contents,
|
|
441
|
+
filetypes,
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Refactor: Organize imports
|
|
449
|
+
*/
|
|
450
|
+
async refactorOrganizeImports(
|
|
451
|
+
filepath: string,
|
|
452
|
+
line: number,
|
|
453
|
+
column: number,
|
|
454
|
+
contents: string,
|
|
455
|
+
filetypes: string[]
|
|
456
|
+
): Promise<any> {
|
|
457
|
+
return this.request("/run_completer_command", {
|
|
458
|
+
command_arguments: ["OrganizeImports"],
|
|
459
|
+
filepath,
|
|
460
|
+
line_num: line,
|
|
461
|
+
column_num: column,
|
|
462
|
+
file_data: {
|
|
463
|
+
[filepath]: {
|
|
464
|
+
contents,
|
|
465
|
+
filetypes,
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Refactor: Apply fix-it
|
|
473
|
+
*/
|
|
474
|
+
async refactorFixIt(
|
|
475
|
+
filepath: string,
|
|
476
|
+
line: number,
|
|
477
|
+
column: number,
|
|
478
|
+
contents: string,
|
|
479
|
+
filetypes: string[],
|
|
480
|
+
fixitIndex: number
|
|
481
|
+
): Promise<any> {
|
|
482
|
+
return this.request("/run_completer_command", {
|
|
483
|
+
command_arguments: ["FixIt"],
|
|
484
|
+
filepath,
|
|
485
|
+
line_num: line,
|
|
486
|
+
column_num: column,
|
|
487
|
+
file_data: {
|
|
488
|
+
[filepath]: {
|
|
489
|
+
contents,
|
|
490
|
+
filetypes,
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Execute a refactoring command
|
|
498
|
+
*/
|
|
499
|
+
async executeRefactor(command: string, args: any): Promise<any> {
|
|
500
|
+
return this.request(`/run_completer_command`, {
|
|
501
|
+
command_arguments: [command, ...Object.values(args)],
|
|
502
|
+
...args,
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Notify server of file events
|
|
508
|
+
*/
|
|
509
|
+
async notifyFileEvent(
|
|
510
|
+
event:
|
|
511
|
+
| "BufferVisit"
|
|
512
|
+
| "BufferUnload"
|
|
513
|
+
| "FileReadyToParse"
|
|
514
|
+
| "InsertLeave"
|
|
515
|
+
| "CurrentIdentifierFinished",
|
|
516
|
+
filepath: string,
|
|
517
|
+
contents?: string,
|
|
518
|
+
filetypes?: string[],
|
|
519
|
+
line_num: number = 1,
|
|
520
|
+
column_num: number = 1
|
|
521
|
+
): Promise<void> {
|
|
522
|
+
const eventData: any = {
|
|
523
|
+
event_name: event,
|
|
524
|
+
filepath,
|
|
525
|
+
line_num,
|
|
526
|
+
column_num,
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// file_data is always required by ycmd
|
|
530
|
+
eventData.file_data = {
|
|
531
|
+
[filepath]: {
|
|
532
|
+
contents: contents || "",
|
|
533
|
+
filetypes: filetypes || ["text"],
|
|
534
|
+
},
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
await this.request("/event_notification", eventData);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Shutdown the server
|
|
542
|
+
*/
|
|
543
|
+
async shutdown(): Promise<void> {
|
|
544
|
+
try {
|
|
545
|
+
await this.request("/shutdown", {}, { method: "POST" });
|
|
546
|
+
} catch {
|
|
547
|
+
// Server may have already shut down
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Utility function to determine file types from file extension
|
|
554
|
+
*/
|
|
555
|
+
export function getFileTypes(filepath: string): string[] {
|
|
556
|
+
const ext = filepath.split(".").pop()?.toLowerCase();
|
|
557
|
+
|
|
558
|
+
const typeMap: Record<string, string[]> = {
|
|
559
|
+
py: ["python"],
|
|
560
|
+
js: ["javascript"],
|
|
561
|
+
ts: ["typescript"],
|
|
562
|
+
jsx: ["javascript", "jsx"],
|
|
563
|
+
tsx: ["typescript", "tsx"],
|
|
564
|
+
cpp: ["cpp"],
|
|
565
|
+
cc: ["cpp"],
|
|
566
|
+
cxx: ["cpp"],
|
|
567
|
+
c: ["c"],
|
|
568
|
+
h: ["c"],
|
|
569
|
+
hpp: ["cpp"],
|
|
570
|
+
java: ["java"],
|
|
571
|
+
cs: ["cs"],
|
|
572
|
+
go: ["go"],
|
|
573
|
+
rs: ["rust"],
|
|
574
|
+
php: ["php"],
|
|
575
|
+
rb: ["ruby"],
|
|
576
|
+
swift: ["swift"],
|
|
577
|
+
kt: ["kotlin"],
|
|
578
|
+
scala: ["scala"],
|
|
579
|
+
sh: ["sh"],
|
|
580
|
+
bash: ["sh"],
|
|
581
|
+
zsh: ["sh"],
|
|
582
|
+
fish: ["sh"],
|
|
583
|
+
vim: ["vim"],
|
|
584
|
+
lua: ["lua"],
|
|
585
|
+
r: ["r"],
|
|
586
|
+
R: ["r"],
|
|
587
|
+
sql: ["sql"],
|
|
588
|
+
html: ["html"],
|
|
589
|
+
xml: ["xml"],
|
|
590
|
+
css: ["css"],
|
|
591
|
+
scss: ["scss"],
|
|
592
|
+
sass: ["sass"],
|
|
593
|
+
less: ["less"],
|
|
594
|
+
json: ["json"],
|
|
595
|
+
yaml: ["yaml"],
|
|
596
|
+
yml: ["yaml"],
|
|
597
|
+
toml: ["toml"],
|
|
598
|
+
ini: ["dosini"],
|
|
599
|
+
cfg: ["dosini"],
|
|
600
|
+
conf: ["conf"],
|
|
601
|
+
md: ["markdown"],
|
|
602
|
+
markdown: ["markdown"],
|
|
603
|
+
tex: ["tex"],
|
|
604
|
+
latex: ["tex"],
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
return typeMap[ext || ""] || ["text"];
|
|
608
|
+
}
|