@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,468 @@
|
|
|
1
|
+
import { XmlToolCallProcessor } from "../src/processors/XmlToolCallProcessor";
|
|
2
|
+
import { Message } from "../src/clients/types";
|
|
3
|
+
import { restoreEscapedNewLines } from "../src/utils";
|
|
4
|
+
import { escapeNewLines } from "../src/utils";
|
|
5
|
+
|
|
6
|
+
describe("XmlToolCallProcessor", () => {
|
|
7
|
+
let processor: XmlToolCallProcessor;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
processor = new XmlToolCallProcessor();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe("JSON-based XML tool calls", () => {
|
|
14
|
+
it("should correctly parse JSON tool calls with string arguments (no double wrapping)", () => {
|
|
15
|
+
const message: Message = {
|
|
16
|
+
role: "assistant",
|
|
17
|
+
content: `I'll help you with that task.
|
|
18
|
+
|
|
19
|
+
<tool_call>
|
|
20
|
+
{"name": "writeFileChunk", "arguments": "{\"filePath\": \"test.js\", \"content\": \"console.log('hello')\", \"isContinuing\": false, \"isDone\": true}"}
|
|
21
|
+
</tool_call>
|
|
22
|
+
|
|
23
|
+
This should create the file.`,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const processorFn = processor.createProcessor();
|
|
27
|
+
processorFn([], [message]);
|
|
28
|
+
|
|
29
|
+
expect(message.tool_calls).toBeDefined();
|
|
30
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
31
|
+
|
|
32
|
+
const toolCall = message.tool_calls![0];
|
|
33
|
+
expect(toolCall.function.name).toBe("writeFileChunk");
|
|
34
|
+
|
|
35
|
+
// Parse the arguments to ensure they're not double-wrapped
|
|
36
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
37
|
+
expect(args.filePath).toBe("test.js");
|
|
38
|
+
expect(args.content).toBe("console.log('hello')");
|
|
39
|
+
expect(args.isContinuing).toBe(false);
|
|
40
|
+
expect(args.isDone).toBe(true);
|
|
41
|
+
|
|
42
|
+
// Ensure arguments is not a nested JSON string
|
|
43
|
+
expect(typeof args).toBe("object");
|
|
44
|
+
expect(typeof args.filePath).toBe("string");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should handle arguments as an object as well", () => {
|
|
48
|
+
const message: Message = {
|
|
49
|
+
role: "assistant",
|
|
50
|
+
content: `
|
|
51
|
+
Sure thing!
|
|
52
|
+
|
|
53
|
+
<tool_call>
|
|
54
|
+
{"name": "writeFileChunk", "arguments": {"filePath": "accumulate.spec.js", "content": "import { describe, expect, test } from '@jest/globals';\nimport { accumulate } from './accumulate';\n\ndescribe('accumulate()', () => {\n test('accumulation empty', () => {\n const accumulator = (e) => e * e;\n expect(accumulate([], accumulator)).toEqual([]);\n });\n\n test('accumulate squares', () => {\n const accumulator = (number) => number * number;\n const result = accumulate([1, 2, 3], accumulator);\n expect(result).toEqual([1, 4, 9]);\n });\n\n test('accumulate upcases', () => {\n const accumulator = (word) => word.toUpperCase();\n const result = accumulate('hello world'.split(/\s/), accumulator);\n expect(result).toEqual(['HELLO', 'WORLD']);\n });\n\n test('accumulate reversed strings', () => {\n const accumulator = (word) => word.split('').reverse().join('');\n const result = accumulate(\n 'the quick brown fox etc'.split(/\s/),\n accumulator,\n );\n expect(result).toEqual(['eht', 'kciuq', 'nworb', 'xof', 'cte']);\n });\n\n test('accumulate recursively', () => {\n const result = accumulate('a b c'.split(/\s/), (char) =>\n accumulate('1 2 3'.split(/\s/), (digit) => char + digit),\n );\n\n expect(result).toEqual([\n ['a1', 'a2', 'a3'],\n ['b1', 'b2', 'b3'],\n ['c1', 'c2', 'c3'],\n ]);\n });\n});", "isContinuing": false, "isDone": true}}
|
|
55
|
+
</tool_call>`,
|
|
56
|
+
};
|
|
57
|
+
const processorFn = processor.createProcessor();
|
|
58
|
+
processorFn([], [message]);
|
|
59
|
+
expect(message.tool_calls).toBeDefined();
|
|
60
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
61
|
+
const toolCall = message.tool_calls![0];
|
|
62
|
+
expect(toolCall.function.name).toBe("writeFileChunk");
|
|
63
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
64
|
+
expect(args.filePath).toBe("accumulate.spec.js");
|
|
65
|
+
expect(args.content).toContain(
|
|
66
|
+
`import { describe, expect, test } from '@jest/globals'`
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("should handle complex patches", () => {
|
|
71
|
+
const message: Message = {
|
|
72
|
+
role: "assistant",
|
|
73
|
+
content: `
|
|
74
|
+
Great! The tests are running, and the first test "accumulation empty" is passing. The other tests are still skipped, so I need to unskip them.
|
|
75
|
+
|
|
76
|
+
Let me modify the test file to unskip the tests:
|
|
77
|
+
|
|
78
|
+
<tool_call>
|
|
79
|
+
{"name": "patchFile", "arguments": {"filePath": "accumulate.spec.js", "patch": "Index: ./accumulate.spec.js\n===================================================================\n--- ./accumulate.spec.js\n+++ ./accumulate.spec.js\n@@ -11,7 +11,7 @@\n test('accumulation empty', () => {\n const accumulator = (e) => e * e;\n expect(accumulate([], accumulator)).toEqual([]);\n });\n-\n+ \n xtest('accumulate squares', () => {\n const accumulator = (number) => number * number;\n const result = accumulate([1, 2, 3], accumulator);\n expect(result).toEqual([1, 4, 9]);\n });\n-\n+ \n xtest('accumulate upcases', () => {\n const accumulator = (word) => word.toUpperCase();\n const result = accumulate('hello world'.split(/\s/), accumulator);\n expect(result).toEqual(['HELLO', 'WORLD']);\n });\n-\n+ \n xtest('accumulate reversed strings', () => {\n const accumulator = (word) => word.split('').reverse().join('');\n const result = accumulate(\n 'the quick brown fox etc'.split(/\s/),\n accumulator,\n );\n expect(result).toEqual(['eht', 'kciuq', 'nworb', 'xof', 'cte']);\n });\n-\n+ \n xtest('accumulate recursively', () => {\n const result = accumulate('a b c'.split(/\s/), (char) =>\n accumulate('1 2 3'.split(/\s/), (digit) => char + digit),\n );\n\n expect(result).toEqual([\n ['a1', 'a2', 'a3'],\n ['b1', 'b2', 'b3'],\n ['c1', 'c2', 'c3'],\n ]);\n });\n "}}
|
|
80
|
+
</tool_call>
|
|
81
|
+
`,
|
|
82
|
+
};
|
|
83
|
+
const processorFn = processor.createProcessor();
|
|
84
|
+
processorFn([], [message]);
|
|
85
|
+
expect(message.tool_calls).toBeDefined();
|
|
86
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
87
|
+
const toolCall = message.tool_calls![0];
|
|
88
|
+
expect(toolCall.function.name).toBe("patchFile");
|
|
89
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
90
|
+
expect(args.filePath).toBe("accumulate.spec.js");
|
|
91
|
+
expect(args.patch).toContain(`Index: ./accumulate.spec.js`);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("should handle complex patches 2", () => {
|
|
95
|
+
const message: Message = {
|
|
96
|
+
role: "assistant",
|
|
97
|
+
content: `
|
|
98
|
+
I need to implement the \`accumulate\` function that takes a collection and an operation to apply to each element. Let me implement this from scratch.
|
|
99
|
+
|
|
100
|
+
The function should:
|
|
101
|
+
1. Take an array (or any iterable) and a function to apply
|
|
102
|
+
2. Apply the function to each element
|
|
103
|
+
3. Return a new array with the results
|
|
104
|
+
4. Not use built-in map functions
|
|
105
|
+
|
|
106
|
+
Here's my implementation:
|
|
107
|
+
|
|
108
|
+
<tool_call>
|
|
109
|
+
{"name": "patchFile", "arguments": {"filePath": "accumulate.js", "patch": "Index: ./accumulate.js\n===================================================================\n--- ./accumulate.js\n+++ ./accumulate.js\n@@ -1,8 +1,10 @@\n //\n // This is only a SKELETON file for the 'Accumulate' exercise. It's been provided as a\n // convenience to get you started writing code faster.\n //\n+\n export const accumulate = (collection, operation) => {\n- throw new Error('Remove this line and implement the function');\n+ const result = [];\n+ for (let i = 0; i < collection.length; i++) {\n+ result.push(operation(collection[i]));\n+ }\n+ return result;\n };\n\n //\n // This is only a SKELETON file for the 'Accumulate' exercise. It's been provided as a\n // convenience to get you started writing code faster.\n //\n"}}
|
|
110
|
+
</tool_call>
|
|
111
|
+
`,
|
|
112
|
+
};
|
|
113
|
+
const processorFn = processor.createProcessor();
|
|
114
|
+
processorFn([], [message]);
|
|
115
|
+
expect(message.tool_calls).toBeDefined();
|
|
116
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
117
|
+
const toolCall = message.tool_calls![0];
|
|
118
|
+
expect(toolCall.function.name).toBe("patchFile");
|
|
119
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
120
|
+
expect(args.filePath).toBe("accumulate.js");
|
|
121
|
+
expect(args.patch).toContain(`Index: ./accumulate.js`);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should handle complex patches 3", () => {
|
|
125
|
+
const message: Message = {
|
|
126
|
+
role: "assistant",
|
|
127
|
+
content:
|
|
128
|
+
"Great! The tests are now passing, but the test for \"accumulate squares\" is still skipped. Let me update the test file to unskip it:\n\n<tool_call>\n{\"name\": \"patchFile\", \"arguments\": {\"filePath\": \"accumulate.spec.js\", \"patch\": \"Index: ./accumulate.spec.js\\n===================================================================\\n--- ./accumulate.spec.js\\n+++ ./accumulate.spec.js\\n@@ -1,42 +1,42 @@\\n import { describe, expect, test, xtest } from '@jest/globals';\\n import { accumulate } from './accumulate';\\n\\n describe('accumulate()', () => {\\n test('accumulation empty', () => {\\n const accumulator = (e) => e * e;\\n expect(accumulate([], accumulator)).toEqual([]);\\n });\\n-\\n- xtest('accumulate squares', () => {\\n- const accumulator = (number) => number * number;\\n- const result = accumulate([1, 2, 3], accumulator);\\n- expect(result).toEqual([1, 4, 9]);\\n- });\\n+\\n+ test('accumulate squares', () => {\\n+ const accumulator = (number) => number * number;\\n+ const result = accumulate([1, 2, 3], accumulator);\\n+ expect(result).toEqual([1, 4, 9]);\\n+ });\\n\\n xtest('accumulate upcases', () => {\\n const accumulator = (word) => word.toUpperCase();\\n const result = accumulate('hello world'.split(/\\s/), accumulator);\\n expect(result).toEqual(['HELLO', 'WORLD']);\\n });\\n\\n xtest('accumulate reversed strings', () => {\\n const accumulator = (word) => word.split('').reverse().join('');\\n const result = accumulate(\\n 'the quick brown fox etc'.split(/\\s/),\\n accumulator,\\n );\\n expect(result).toEqual(['eht', 'kciuq', 'nworb', 'xof', 'cte']);\\n });\\n\\n xtest('accumulate recursively', () => {\\n const result = accumulate('a b c'.split(/\\s/), (char) =>\\n accumulate('1 2 3'.split(/\\s/), (digit) => char + digit),\\n );\\n\\n expect(result).toEqual([\\n ['a1', 'a2', 'a3'],\\n ['b1', 'b2', 'b3'],\\n ['c1', 'c2', 'c3'],\\n ]);\\n });\\n });\\n\"}}\n</tool_call>",
|
|
129
|
+
};
|
|
130
|
+
const processorFn = processor.createProcessor();
|
|
131
|
+
processorFn([], [message]);
|
|
132
|
+
expect(message.tool_calls).toBeDefined();
|
|
133
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
134
|
+
const toolCall = message.tool_calls![0];
|
|
135
|
+
expect(toolCall.function.name).toBe("patchFile");
|
|
136
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
137
|
+
expect(args.filePath).toBe("accumulate.spec.js");
|
|
138
|
+
expect(args.patch).toContain(`Index: ./accumulate.spec.js`);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("should produce arguments compatible with ToolsService.callTool logic", () => {
|
|
142
|
+
const message: Message = {
|
|
143
|
+
role: "assistant",
|
|
144
|
+
content: `
|
|
145
|
+
I need to implement the \`accumulate\` function that takes a collection and an operation to apply to each element. Let me implement this from scratch.
|
|
146
|
+
|
|
147
|
+
The function should:
|
|
148
|
+
1. Take an array (or any iterable) and a function to apply
|
|
149
|
+
2. Apply the function to each element
|
|
150
|
+
3. Return a new array with the results
|
|
151
|
+
4. Not use built-in map functions
|
|
152
|
+
|
|
153
|
+
Here's my implementation:
|
|
154
|
+
|
|
155
|
+
<tool_call>
|
|
156
|
+
{"name": "patchFile", "arguments": {"filePath": "accumulate.js", "patch": "Index: ./accumulate.js\\n===================================================================\\n--- ./accumulate.js\\n+++ ./accumulate.js\\n@@ -1,8 +1,10 @@\\n //\\n // This is only a SKELETON file for the 'Accumulate' exercise. It's been provided as a\\n // convenience to get you started writing code faster.\\n //\\n+\\n export const accumulate = (collection, operation) => {\\n- throw new Error('Remove this line and implement the function');\\n+ const result = [];\\n+ for (let i = 0; i < collection.length; i++) {\\n+ result.push(operation(collection[i]));\\n+ }\\n+ return result;\\n };\\n\\n //\\n // This is only a SKELETON file for the 'Accumulate' exercise. It's been provided as a\\n // convenience to get you started writing code faster.\\n //\\n"}}
|
|
157
|
+
</tool_call>
|
|
158
|
+
`,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const processorFn = processor.createProcessor();
|
|
162
|
+
processorFn([], [message]);
|
|
163
|
+
|
|
164
|
+
expect(message.tool_calls).toBeDefined();
|
|
165
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
166
|
+
|
|
167
|
+
const toolCall = message.tool_calls![0];
|
|
168
|
+
expect(toolCall.function.name).toBe("patchFile");
|
|
169
|
+
|
|
170
|
+
// Now simulate the exact logic from ToolsService.callTool
|
|
171
|
+
const functionName = toolCall.function.name;
|
|
172
|
+
let functionArgs;
|
|
173
|
+
let parseError: Error | null = null;
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
// This is the exact logic from ToolsService.callTool line 167-170
|
|
177
|
+
functionArgs =
|
|
178
|
+
typeof toolCall.function.arguments === "string"
|
|
179
|
+
? JSON.parse(restoreEscapedNewLines(toolCall.function.arguments))
|
|
180
|
+
: toolCall.function.arguments;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
parseError = error as Error;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Should not have any parsing errors
|
|
186
|
+
expect(parseError).toBeNull();
|
|
187
|
+
expect(functionArgs).toBeDefined();
|
|
188
|
+
expect(typeof functionArgs).toBe("object");
|
|
189
|
+
|
|
190
|
+
// Should have the correct structure
|
|
191
|
+
expect(functionArgs.filePath).toBe("accumulate.js");
|
|
192
|
+
expect(functionArgs.patch).toBeDefined();
|
|
193
|
+
expect(typeof functionArgs.patch).toBe("string");
|
|
194
|
+
expect(functionArgs.patch).toContain("Index: ./accumulate.js");
|
|
195
|
+
|
|
196
|
+
// Additional validation: ensure arguments is a valid JSON string
|
|
197
|
+
expect(typeof toolCall.function.arguments).toBe("string");
|
|
198
|
+
|
|
199
|
+
// Test that the arguments can be JSON.parsed without errors
|
|
200
|
+
let parsedArgs;
|
|
201
|
+
expect(() => {
|
|
202
|
+
parsedArgs = JSON.parse(toolCall.function.arguments);
|
|
203
|
+
}).not.toThrow();
|
|
204
|
+
|
|
205
|
+
// Verify the parsed structure matches what we expect
|
|
206
|
+
expect(parsedArgs).toEqual(functionArgs);
|
|
207
|
+
|
|
208
|
+
// Ensure no double-wrapping (arguments should not be a stringified JSON string)
|
|
209
|
+
expect(typeof parsedArgs.filePath).toBe("string");
|
|
210
|
+
expect(typeof parsedArgs.patch).toBe("string");
|
|
211
|
+
// The patch should NOT be a JSON string, but actual string content
|
|
212
|
+
expect(() => JSON.parse(parsedArgs.patch)).toThrow(); // Should throw because patch is actual diff content, not JSON
|
|
213
|
+
|
|
214
|
+
console.log("ā
Tool call arguments format validation passed");
|
|
215
|
+
console.log("Function name:", functionName);
|
|
216
|
+
console.log("Arguments type:", typeof toolCall.function.arguments);
|
|
217
|
+
console.log("Parsed args keys:", Object.keys(functionArgs));
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("should correctly parse JSON tool calls with object arguments", () => {
|
|
221
|
+
const message: Message = {
|
|
222
|
+
role: "assistant",
|
|
223
|
+
content: `<tool_call>
|
|
224
|
+
{"name": "readFile", "arguments": {"filePath": "example.txt"}}
|
|
225
|
+
</tool_call>`,
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const processorFn = processor.createProcessor();
|
|
229
|
+
processorFn([], [message]);
|
|
230
|
+
|
|
231
|
+
expect(message.tool_calls).toBeDefined();
|
|
232
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
233
|
+
|
|
234
|
+
const toolCall = message.tool_calls![0];
|
|
235
|
+
expect(toolCall.function.name).toBe("readFile");
|
|
236
|
+
|
|
237
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
238
|
+
expect(args.filePath).toBe("example.txt");
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
describe("Attribute-based XML tool calls", () => {
|
|
243
|
+
it("should correctly parse attribute-based tool calls", () => {
|
|
244
|
+
const message: Message = {
|
|
245
|
+
role: "assistant",
|
|
246
|
+
content: `<tool_call name="readFile">{"filePath": "test.txt"}</tool_call>`,
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const processorFn = processor.createProcessor();
|
|
250
|
+
processorFn([], [message]);
|
|
251
|
+
|
|
252
|
+
expect(message.tool_calls).toBeDefined();
|
|
253
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
254
|
+
|
|
255
|
+
const toolCall = message.tool_calls![0];
|
|
256
|
+
expect(toolCall.function.name).toBe("readFile");
|
|
257
|
+
|
|
258
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
259
|
+
expect(args.filePath).toBe("test.txt");
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("should correctly parse attribute-based tool calls with arguments attribute", () => {
|
|
263
|
+
const message: Message = {
|
|
264
|
+
role: "assistant",
|
|
265
|
+
content: `<tool_call name="execCommand" arguments='{"command": "ls -la"}'/>`,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const processorFn = processor.createProcessor();
|
|
269
|
+
processorFn([], [message]);
|
|
270
|
+
|
|
271
|
+
expect(message.tool_calls).toBeDefined();
|
|
272
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
273
|
+
|
|
274
|
+
const toolCall = message.tool_calls![0];
|
|
275
|
+
expect(toolCall.function.name).toBe("execCommand");
|
|
276
|
+
|
|
277
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
278
|
+
expect(args.command).toBe("ls -la");
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
describe("Nested XML tool calls", () => {
|
|
283
|
+
it("should correctly parse nested XML parameter format", () => {
|
|
284
|
+
const message: Message = {
|
|
285
|
+
role: "assistant",
|
|
286
|
+
content: `<tool_call>
|
|
287
|
+
<invoke name="readFile">
|
|
288
|
+
<parameter name="filePath">example.txt</parameter>
|
|
289
|
+
</invoke>
|
|
290
|
+
</tool_call>`,
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const processorFn = processor.createProcessor();
|
|
294
|
+
processorFn([], [message]);
|
|
295
|
+
|
|
296
|
+
expect(message.tool_calls).toBeDefined();
|
|
297
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
298
|
+
|
|
299
|
+
const toolCall = message.tool_calls![0];
|
|
300
|
+
expect(toolCall.function.name).toBe("readFile");
|
|
301
|
+
|
|
302
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
303
|
+
expect(args.filePath).toBe("example.txt");
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe("Content cleaning", () => {
|
|
308
|
+
it("should preserve non-XML content in the message", () => {
|
|
309
|
+
const message: Message = {
|
|
310
|
+
role: "assistant",
|
|
311
|
+
content: `I need to read the file first.
|
|
312
|
+
|
|
313
|
+
<tool_call>
|
|
314
|
+
{"name": "readFile", "arguments": "{\"filePath\": \"test.js\"}"}
|
|
315
|
+
</tool_call>
|
|
316
|
+
|
|
317
|
+
This will help me understand the content.`,
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const processorFn = processor.createProcessor();
|
|
321
|
+
processorFn([], [message]);
|
|
322
|
+
|
|
323
|
+
// Content should still contain the non-XML parts
|
|
324
|
+
expect(message.content).toContain("I need to read the file first.");
|
|
325
|
+
expect(message.content).toContain(
|
|
326
|
+
"This will help me understand the content."
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
// Tool calls should be extracted
|
|
330
|
+
expect(message.tool_calls).toBeDefined();
|
|
331
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
describe("Multiple tool calls", () => {
|
|
336
|
+
it("should handle multiple tool calls in one message", () => {
|
|
337
|
+
const message: Message = {
|
|
338
|
+
role: "assistant",
|
|
339
|
+
content: `I'll read the file and then write to another one.
|
|
340
|
+
|
|
341
|
+
<tool_call>
|
|
342
|
+
{"name": "readFile", "arguments": "{\"filePath\": \"input.txt\"}"}
|
|
343
|
+
</tool_call>
|
|
344
|
+
|
|
345
|
+
<tool_call>
|
|
346
|
+
{"name": "writeFileChunk", "arguments": "{\"filePath\": \"output.txt\", \"content\": \"processed data\", \"isContinuing\": false, \"isDone\": true}"}
|
|
347
|
+
</tool_call>`,
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const processorFn = processor.createProcessor();
|
|
351
|
+
processorFn([], [message]);
|
|
352
|
+
|
|
353
|
+
expect(message.tool_calls).toBeDefined();
|
|
354
|
+
expect(message.tool_calls!.length).toBe(2);
|
|
355
|
+
|
|
356
|
+
// First tool call
|
|
357
|
+
const firstCall = message.tool_calls![0];
|
|
358
|
+
expect(firstCall.function.name).toBe("readFile");
|
|
359
|
+
const firstArgs = JSON.parse(firstCall.function.arguments);
|
|
360
|
+
expect(firstArgs.filePath).toBe("input.txt");
|
|
361
|
+
|
|
362
|
+
// Second tool call
|
|
363
|
+
const secondCall = message.tool_calls![1];
|
|
364
|
+
expect(secondCall.function.name).toBe("writeFileChunk");
|
|
365
|
+
const secondArgs = JSON.parse(secondCall.function.arguments);
|
|
366
|
+
expect(secondArgs.filePath).toBe("output.txt");
|
|
367
|
+
expect(secondArgs.content).toBe("processed data");
|
|
368
|
+
expect(secondArgs.isContinuing).toBe(false);
|
|
369
|
+
expect(secondArgs.isDone).toBe(true);
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
describe("Edge cases", () => {
|
|
374
|
+
it("should not process non-assistant messages", () => {
|
|
375
|
+
const message: Message = {
|
|
376
|
+
role: "user",
|
|
377
|
+
content: `<tool_call>
|
|
378
|
+
{"name": "readFile", "arguments": "{\"filePath\": \"test.txt\"}"}
|
|
379
|
+
</tool_call>`,
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
const processorFn = processor.createProcessor();
|
|
383
|
+
processorFn([], [message]);
|
|
384
|
+
|
|
385
|
+
expect(message.tool_calls).toBeUndefined();
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it("should not process messages that already have tool_calls", () => {
|
|
389
|
+
const message: Message = {
|
|
390
|
+
role: "assistant",
|
|
391
|
+
content: `<tool_call>
|
|
392
|
+
{"name": "readFile", "arguments": "{\"filePath\": \"test.txt\"}"}
|
|
393
|
+
</tool_call>`,
|
|
394
|
+
tool_calls: [
|
|
395
|
+
{
|
|
396
|
+
id: "existing_call",
|
|
397
|
+
type: "function",
|
|
398
|
+
function: {
|
|
399
|
+
name: "existingTool",
|
|
400
|
+
arguments: "{}",
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
const processorFn = processor.createProcessor();
|
|
407
|
+
processorFn([], [message]);
|
|
408
|
+
|
|
409
|
+
// Should still have only the original tool call
|
|
410
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
411
|
+
expect(message.tool_calls![0].id).toBe("existing_call");
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("should handle malformed JSON gracefully", () => {
|
|
415
|
+
const message: Message = {
|
|
416
|
+
role: "assistant",
|
|
417
|
+
content: `<tool_call>
|
|
418
|
+
{"name": "readFile", "arguments": "invalid json here"}
|
|
419
|
+
</tool_call>`,
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const processorFn = processor.createProcessor();
|
|
423
|
+
processorFn([], [message]);
|
|
424
|
+
|
|
425
|
+
expect(message.tool_calls).toBeDefined();
|
|
426
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
427
|
+
|
|
428
|
+
const toolCall = message.tool_calls![0];
|
|
429
|
+
expect(toolCall.function.name).toBe("readFile");
|
|
430
|
+
// Should fallback to wrapping in input object
|
|
431
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
432
|
+
expect(args.input).toBe("invalid json here");
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
describe("Incomplete XML tool calls", () => {
|
|
437
|
+
it("should handle incomplete tool calls with missing closing tags", () => {
|
|
438
|
+
const message: Message = {
|
|
439
|
+
role: "assistant",
|
|
440
|
+
content: `I see the issue. Let me make a clean patch with all the changes:
|
|
441
|
+
|
|
442
|
+
<tool_call>
|
|
443
|
+
{"name": "patchFile", "arguments": {"filePath": "bank-account.js", "patch": "//=============================================================================\\n// This is the complete implementation for the Bank Account exercise\\n//=============================================================================\\n\\nexport class BankAccount {\\n constructor() {\\n this._balance = 0;\\n this._isOpen = false;\\n }\\n\\n open() {\\n if (this._isOpen) {\\n throw new ValueError();\\n }\\n this._isOpen = true;\\n this._balance = 0;\\n }\\n\\n close() {\\n if (!this._isOpen) {\\n throw new ValueError();\\n }\\n this._isOpen = false;\\n }\\n\\n deposit(amount) {\\n if (!this._isOpen || amount <= 0) {\\n throw new ValueError();\\n }\\n this._balance += amount;\\n }\\n\\n withdraw(amount) {\\n if (!this._isOpen || amount <= 0 || amount > this._balance) {\\n throw new ValueError();\\n }\\n this._balance -= amount;\\n }\\n\\n get balance() {\\n if (!this._isOpen) {\\n throw new ValueError();\\n }\\n return this._balance;\\n }\\n}\\n\\nexport class ValueError extends Error {\\n constructor() {\\n super('Bank account error');\\n }\\n}"}}`,
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
const processorFn = processor.createProcessor();
|
|
447
|
+
processorFn([], [message]);
|
|
448
|
+
|
|
449
|
+
expect(message.tool_calls).toBeDefined();
|
|
450
|
+
expect(message.tool_calls!.length).toBe(1);
|
|
451
|
+
|
|
452
|
+
const toolCall = message.tool_calls![0];
|
|
453
|
+
expect(toolCall.function.name).toBe("patchFile");
|
|
454
|
+
|
|
455
|
+
// Parse the arguments to ensure they're correctly extracted despite missing closing tag
|
|
456
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
457
|
+
expect(args.filePath).toBe("bank-account.js");
|
|
458
|
+
expect(args.patch).toBeDefined();
|
|
459
|
+
expect(typeof args.patch).toBe("string");
|
|
460
|
+
expect(args.patch).toContain("export class BankAccount");
|
|
461
|
+
expect(args.patch).toContain("export class ValueError");
|
|
462
|
+
|
|
463
|
+
// Verify the processor correctly handled the incomplete XML (missing </tool_call>)
|
|
464
|
+
expect(toolCall.id).toBeDefined();
|
|
465
|
+
expect(toolCall.type).toBe("function");
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { ycmdStart, ycmdDiagnostics } from "../../../src/agents/tools/ycmd";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
|
|
6
|
+
async function testDiagnostics() {
|
|
7
|
+
console.log("š§ Starting ycmd server...");
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
// Start ycmd server
|
|
11
|
+
const startResult = await ycmdStart({
|
|
12
|
+
workspaceRoot: process.cwd(),
|
|
13
|
+
logLevel: "debug",
|
|
14
|
+
});
|
|
15
|
+
console.log("ā
ycmd server started:", startResult);
|
|
16
|
+
|
|
17
|
+
// Wait for server to fully initialize
|
|
18
|
+
console.log("ā³ Waiting for server initialization...");
|
|
19
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
20
|
+
|
|
21
|
+
const testFile = path.join(
|
|
22
|
+
process.cwd(),
|
|
23
|
+
"tests/ycmd/fixtures/debug_diagnostics.ts"
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Ensure the test file exists
|
|
27
|
+
if (!fs.existsSync(testFile)) {
|
|
28
|
+
console.log("ā Test file does not exist:", testFile);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log("š Test file path:", testFile);
|
|
33
|
+
console.log("š Test file contents:");
|
|
34
|
+
console.log(fs.readFileSync(testFile, "utf8"));
|
|
35
|
+
|
|
36
|
+
// Test diagnostics multiple times with increasing delays
|
|
37
|
+
const delays = [1000, 3000, 5000, 10000];
|
|
38
|
+
|
|
39
|
+
for (const delay of delays) {
|
|
40
|
+
console.log(`\nš Testing diagnostics after ${delay}ms delay...`);
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const diagnostics = await ycmdDiagnostics({
|
|
45
|
+
filepath: testFile,
|
|
46
|
+
line: 1,
|
|
47
|
+
column: 1,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
console.log(
|
|
51
|
+
"š Diagnostics result:",
|
|
52
|
+
JSON.stringify(diagnostics, null, 2)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
diagnostics &&
|
|
57
|
+
typeof diagnostics === "object" &&
|
|
58
|
+
"content" in diagnostics
|
|
59
|
+
) {
|
|
60
|
+
const content = diagnostics.content;
|
|
61
|
+
if (Array.isArray(content) && content.length > 0) {
|
|
62
|
+
console.log(`ā
Found ${content.length} diagnostic(s)!`);
|
|
63
|
+
content.forEach((diag, index) => {
|
|
64
|
+
console.log(
|
|
65
|
+
` ${index + 1}. ${
|
|
66
|
+
diag.text || diag.message || JSON.stringify(diag)
|
|
67
|
+
}`
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
break; // Found diagnostics, stop testing
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.log("ā Diagnostics error:", error.message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Try diagnostics on a specific error line
|
|
79
|
+
console.log(
|
|
80
|
+
"\nšÆ Testing diagnostics on specific error line (line 9 - missing property)..."
|
|
81
|
+
);
|
|
82
|
+
try {
|
|
83
|
+
const specificDiagnostics = await ycmdDiagnostics({
|
|
84
|
+
filepath: testFile,
|
|
85
|
+
line: 9,
|
|
86
|
+
column: 12,
|
|
87
|
+
});
|
|
88
|
+
console.log(
|
|
89
|
+
"š Specific line diagnostics:",
|
|
90
|
+
JSON.stringify(specificDiagnostics, null, 2)
|
|
91
|
+
);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.log("ā Specific diagnostics error:", error.message);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Check if TypeScript is properly configured
|
|
97
|
+
console.log("\nš§ Checking TypeScript configuration...");
|
|
98
|
+
const tsconfigPath = path.join(process.cwd(), "tsconfig.json");
|
|
99
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
100
|
+
console.log("ā
tsconfig.json found");
|
|
101
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, "utf8"));
|
|
102
|
+
console.log(
|
|
103
|
+
"š Compiler options:",
|
|
104
|
+
JSON.stringify(tsconfig.compilerOptions, null, 2)
|
|
105
|
+
);
|
|
106
|
+
} else {
|
|
107
|
+
console.log("ā ļø No tsconfig.json found");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Try running TypeScript compiler directly to see if it detects errors
|
|
111
|
+
console.log("\nš Running TypeScript compiler directly...");
|
|
112
|
+
try {
|
|
113
|
+
execSync(`npx tsc --noEmit ${testFile}`, { stdio: "pipe" });
|
|
114
|
+
console.log("ā
TypeScript compiler found no errors");
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.log("ā TypeScript compiler errors:");
|
|
117
|
+
console.log(
|
|
118
|
+
error.stdout?.toString() || error.stderr?.toString() || error.message
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error("ā Test failed:", error.message);
|
|
123
|
+
console.error("Stack trace:", error.stack);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
testDiagnostics().catch(console.error);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// TypeScript file with clear errors to test diagnostics
|
|
2
|
+
interface User {
|
|
3
|
+
name: string;
|
|
4
|
+
age: number;
|
|
5
|
+
email?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function createUser(name: string, age: number): User {
|
|
9
|
+
// This should trigger a type error - missing 'age' property
|
|
10
|
+
return { name };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// This should trigger an error - React is not imported
|
|
14
|
+
const component = React.createElement('div');
|
|
15
|
+
|
|
16
|
+
// This should trigger an error - missing 'age' property
|
|
17
|
+
const user: User = { name: 'Alice' };
|
|
18
|
+
|
|
19
|
+
// This should trigger an error - undefined variable
|
|
20
|
+
console.log(undefinedVariable);
|
|
21
|
+
|
|
22
|
+
// This should trigger an error - calling method on possibly undefined
|
|
23
|
+
const maybeString: string | undefined = undefined;
|
|
24
|
+
maybeString.toUpperCase();
|
|
25
|
+
|
|
26
|
+
export { createUser };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface User {
|
|
2
|
+
name: string;
|
|
3
|
+
age: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function createUser(name: string, age: number): User {
|
|
7
|
+
// ERROR: Missing 'age' property - should cause TypeScript error
|
|
8
|
+
return { name };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// ERROR: Using undefined variable - should cause TypeScript error
|
|
12
|
+
console.log(undefinedVariable);
|
|
13
|
+
|
|
14
|
+
// ERROR: Type mismatch - missing required property - should cause TypeScript error
|
|
15
|
+
const user: User = { name: 'Alice' };
|
|
16
|
+
|
|
17
|
+
export { createUser };
|