@tyvm/knowhow 0.0.32 → 0.0.34
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 +147 -21
- 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 +980 -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/embeddings.ts +79 -23
- package/src/login.ts +26 -9
- package/src/microphone.ts +0 -1
- package/src/plugins/downloader/downloader.ts +72 -24
- 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 +14 -1
- package/ts_build/src/agents/base/base.js +91 -17
- 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 +56 -0
- package/ts_build/src/chat/modules/AgentModule.js +705 -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/embeddings.d.ts +2 -1
- package/ts_build/src/embeddings.js +62 -17
- package/ts_build/src/embeddings.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 +4 -5
- package/ts_build/src/plugins/downloader/downloader.js +55 -26
- 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,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "leaderboard",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev -p 3333",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start",
|
|
9
|
+
"lint": "next lint"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"next": "^14.2.31",
|
|
13
|
+
"react": "^18",
|
|
14
|
+
"react-dom": "^18",
|
|
15
|
+
"recharts": "^2.8.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^20",
|
|
19
|
+
"@types/react": "^18",
|
|
20
|
+
"@types/react-dom": "^18",
|
|
21
|
+
"autoprefixer": "^10.0.1",
|
|
22
|
+
"eslint": "^8",
|
|
23
|
+
"eslint-config-next": "14.0.0",
|
|
24
|
+
"postcss": "^8",
|
|
25
|
+
"tailwindcss": "^3.3.0",
|
|
26
|
+
"typescript": "^5"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
content: [
|
|
4
|
+
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
|
|
5
|
+
'./components/**/*.{js,ts,jsx,tsx,mdx}',
|
|
6
|
+
'./app/**/*.{js,ts,jsx,tsx,mdx}',
|
|
7
|
+
],
|
|
8
|
+
theme: {
|
|
9
|
+
extend: {
|
|
10
|
+
colors: {
|
|
11
|
+
background: 'var(--background)',
|
|
12
|
+
foreground: 'var(--foreground)',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
plugins: [],
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "es6"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"baseUrl": ".",
|
|
22
|
+
"paths": {
|
|
23
|
+
"@/*": ["./*"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
27
|
+
"exclude": ["node_modules"]
|
|
28
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface BenchmarkConfig {
|
|
2
|
+
language: string;
|
|
3
|
+
maxExercises: number;
|
|
4
|
+
model: string;
|
|
5
|
+
provider: string;
|
|
6
|
+
agent?: string;
|
|
7
|
+
limits: BenchmarkLimits;
|
|
8
|
+
outputFile: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface BenchmarkLimits {
|
|
12
|
+
maxTurns: number;
|
|
13
|
+
maxTime: number;
|
|
14
|
+
maxCost: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ExerciseResult {
|
|
18
|
+
exerciseName: string;
|
|
19
|
+
status: 'success' | 'failure' | 'timeout' | 'cost_limit' | 'turn_limit';
|
|
20
|
+
testResult?: any;
|
|
21
|
+
turns: number;
|
|
22
|
+
timeElapsed: number;
|
|
23
|
+
cost: number;
|
|
24
|
+
startTime: string;
|
|
25
|
+
endTime: string;
|
|
26
|
+
errorMessage?: string;
|
|
27
|
+
finalOutput?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface BenchmarkResults {
|
|
31
|
+
config: BenchmarkConfig;
|
|
32
|
+
commitHash?: string;
|
|
33
|
+
exercises: ExerciseResult[];
|
|
34
|
+
summary: {
|
|
35
|
+
totalExercises: number;
|
|
36
|
+
testableExercises?: number;
|
|
37
|
+
testsPassedCount?: number;
|
|
38
|
+
testsFailedCount?: number;
|
|
39
|
+
testPassRate?: number;
|
|
40
|
+
agentSuccessRate?: number;
|
|
41
|
+
successCount: number;
|
|
42
|
+
failureCount: number;
|
|
43
|
+
timeoutCount: number;
|
|
44
|
+
costLimitCount: number;
|
|
45
|
+
turnLimitCount: number;
|
|
46
|
+
totalTime: number;
|
|
47
|
+
totalCost: number;
|
|
48
|
+
averageTurns: number;
|
|
49
|
+
averageTime: number;
|
|
50
|
+
successRate: number;
|
|
51
|
+
};
|
|
52
|
+
startTime: string;
|
|
53
|
+
endTime: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface LeaderboardEntry {
|
|
57
|
+
model: string;
|
|
58
|
+
provider: string;
|
|
59
|
+
language: string;
|
|
60
|
+
successRate: number;
|
|
61
|
+
totalExercises: number;
|
|
62
|
+
averageCost: number;
|
|
63
|
+
averageTime: number;
|
|
64
|
+
averageTurns: number;
|
|
65
|
+
totalRuns: number;
|
|
66
|
+
lastRun: string;
|
|
67
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LeaderboardEntry } from '@/types/benchmark';
|
|
2
|
+
|
|
3
|
+
export async function loadLeaderboardData(): Promise<LeaderboardEntry[]> {
|
|
4
|
+
try {
|
|
5
|
+
const response = await fetch('/api/benchmark-data');
|
|
6
|
+
const data = await response.json();
|
|
7
|
+
return data;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error('Error loading benchmark results:', error);
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function formatPercentage(value: number): string {
|
|
15
|
+
return `${value.toFixed(1)}%`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function formatCurrency(value: number): string {
|
|
19
|
+
return `$${value.toFixed(3)}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function formatTime(seconds: number): string {
|
|
23
|
+
if (seconds < 60) {
|
|
24
|
+
return `${seconds.toFixed(1)}s`;
|
|
25
|
+
}
|
|
26
|
+
const minutes = Math.floor(seconds / 60);
|
|
27
|
+
const remainingSeconds = seconds % 60;
|
|
28
|
+
return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function formatNumber(value: number): string {
|
|
32
|
+
return value.toFixed(1);
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tyvm/knowhow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"description": "ai cli with plugins and agents",
|
|
5
5
|
"main": "ts_build/src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"asana": "^3.0.16",
|
|
51
51
|
"axios": "^1.5.0",
|
|
52
52
|
"cheerio": "^1.0.0",
|
|
53
|
+
"commander": "^14.0.0",
|
|
53
54
|
"diff": "^5.2.0",
|
|
54
55
|
"esbuild": "^0.25.8",
|
|
55
56
|
"express": "^4.19.2",
|
package/src/agents/base/base.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface AgentContext {
|
|
|
28
28
|
Tools?: ToolsService;
|
|
29
29
|
Events?: EventService;
|
|
30
30
|
messageProcessor?: MessageProcessor;
|
|
31
|
+
Clients?: AIClient;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export abstract class BaseAgent implements IAgent {
|
|
@@ -43,6 +44,11 @@ export abstract class BaseAgent implements IAgent {
|
|
|
43
44
|
protected currentModelPreferenceIndex = 0;
|
|
44
45
|
protected easyFinalAnswer = false;
|
|
45
46
|
protected requiredToolNames = ["finalAnswer"];
|
|
47
|
+
protected maxTurns: number | null = null;
|
|
48
|
+
protected maxSpend: number | null = null;
|
|
49
|
+
protected maxRunTimeMs: number | null = null;
|
|
50
|
+
protected startTimeMs: number | null = null;
|
|
51
|
+
protected turnCount = 0;
|
|
46
52
|
protected totalCostUsd = 0;
|
|
47
53
|
protected currentThread = 0;
|
|
48
54
|
protected threads = [] as Message[][];
|
|
@@ -64,13 +70,15 @@ export abstract class BaseAgent implements IAgent {
|
|
|
64
70
|
public tools: ToolsService;
|
|
65
71
|
public events: EventService;
|
|
66
72
|
public messageProcessor: MessageProcessor;
|
|
73
|
+
public clientService: AIClient;
|
|
67
74
|
|
|
68
75
|
disabledTools = [];
|
|
69
76
|
|
|
70
77
|
constructor(context: AgentContext) {
|
|
71
78
|
this.tools = context.Tools;
|
|
72
79
|
this.events = context.Events;
|
|
73
|
-
this.messageProcessor = context.messageProcessor;
|
|
80
|
+
this.messageProcessor = context.messageProcessor || new MessageProcessor();
|
|
81
|
+
this.clientService = context.Clients || Clients;
|
|
74
82
|
|
|
75
83
|
if (!this.tools) {
|
|
76
84
|
throw new Error("ToolsService is required for BaseAgent");
|
|
@@ -79,10 +87,18 @@ export abstract class BaseAgent implements IAgent {
|
|
|
79
87
|
if (!this.events) {
|
|
80
88
|
throw new Error("EventService is required for BaseAgent");
|
|
81
89
|
}
|
|
90
|
+
}
|
|
82
91
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
setMaxTurns(maxTurns: number | null) {
|
|
93
|
+
this.maxTurns = maxTurns;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
setMaxSpend(maxSpend: number | null) {
|
|
97
|
+
this.maxSpend = maxSpend;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setMaxRunTime(maxRunTimeMs: number | null) {
|
|
101
|
+
this.maxRunTimeMs = maxRunTimeMs;
|
|
86
102
|
}
|
|
87
103
|
|
|
88
104
|
newTask() {
|
|
@@ -92,6 +108,8 @@ export abstract class BaseAgent implements IAgent {
|
|
|
92
108
|
this.summaries = [];
|
|
93
109
|
this.totalCostUsd = 0;
|
|
94
110
|
this.status = "in_progress";
|
|
111
|
+
this.turnCount = 0;
|
|
112
|
+
this.startTimeMs = Date.now();
|
|
95
113
|
}
|
|
96
114
|
|
|
97
115
|
register() {
|
|
@@ -137,7 +155,8 @@ export abstract class BaseAgent implements IAgent {
|
|
|
137
155
|
|
|
138
156
|
getClient() {
|
|
139
157
|
if (!this.client) {
|
|
140
|
-
|
|
158
|
+
console.log("Getting client for provider", this.provider);
|
|
159
|
+
this.client = this.clientService.getClient(this.provider)?.client;
|
|
141
160
|
}
|
|
142
161
|
return this.client;
|
|
143
162
|
}
|
|
@@ -174,6 +193,45 @@ export abstract class BaseAgent implements IAgent {
|
|
|
174
193
|
}
|
|
175
194
|
}
|
|
176
195
|
|
|
196
|
+
private checkLimits(): boolean {
|
|
197
|
+
// Check turn limit
|
|
198
|
+
if (this.maxTurns !== null && this.turnCount >= this.maxTurns) {
|
|
199
|
+
console.log(`Turn limit reached: ${this.turnCount}/${this.maxTurns}`);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Check spend limit
|
|
204
|
+
if (this.maxSpend !== null && this.totalCostUsd >= this.maxSpend) {
|
|
205
|
+
console.log(
|
|
206
|
+
`Spend limit reached: $${this.totalCostUsd.toFixed(
|
|
207
|
+
4
|
|
208
|
+
)}/$${this.maxSpend.toFixed(4)}`
|
|
209
|
+
);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Check runtime limit
|
|
214
|
+
if (this.maxRunTimeMs !== null && this.startTimeMs !== null) {
|
|
215
|
+
const currentRunTimeMs = Date.now() - this.startTimeMs;
|
|
216
|
+
if (currentRunTimeMs >= this.maxRunTimeMs) {
|
|
217
|
+
console.log(
|
|
218
|
+
`Runtime limit reached: ${currentRunTimeMs}ms/${this.maxRunTimeMs}ms`
|
|
219
|
+
);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private shouldTerminateFromLimits(): boolean {
|
|
228
|
+
return this.checkLimits();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
getTurnCount(): number {
|
|
232
|
+
return this.turnCount;
|
|
233
|
+
}
|
|
234
|
+
|
|
177
235
|
adjustTotalCostUsd(cost: number) {
|
|
178
236
|
if (cost) {
|
|
179
237
|
this.totalCostUsd += cost;
|
|
@@ -366,6 +424,25 @@ export abstract class BaseAgent implements IAgent {
|
|
|
366
424
|
|
|
367
425
|
await this.selectHealthyModel();
|
|
368
426
|
|
|
427
|
+
// Increment turn count and check limits (only for new calls, not recursive ones)
|
|
428
|
+
this.turnCount++;
|
|
429
|
+
if (this.shouldTerminateFromLimits()) {
|
|
430
|
+
const currentRunTimeMs = this.startTimeMs
|
|
431
|
+
? Date.now() - this.startTimeMs
|
|
432
|
+
: 0;
|
|
433
|
+
const limitMsg = `Task terminated due to limits reached. Turn: ${
|
|
434
|
+
this.turnCount
|
|
435
|
+
}/${this.maxTurns || "unlimited"}, Cost: $${this.totalCostUsd.toFixed(
|
|
436
|
+
4
|
|
437
|
+
)}/${
|
|
438
|
+
this.maxSpend ? "$" + this.maxSpend.toFixed(4) : "unlimited"
|
|
439
|
+
}, Runtime: ${currentRunTimeMs}ms/${
|
|
440
|
+
this.maxRunTimeMs ? this.maxRunTimeMs + "ms" : "unlimited"
|
|
441
|
+
}`;
|
|
442
|
+
this.agentEvents.emit(this.eventTypes.done, limitMsg);
|
|
443
|
+
return limitMsg;
|
|
444
|
+
}
|
|
445
|
+
|
|
369
446
|
try {
|
|
370
447
|
const model = this.getModel();
|
|
371
448
|
let messages = _messages || (await this.getInitialMessages(userInput));
|
|
@@ -393,7 +470,7 @@ export abstract class BaseAgent implements IAgent {
|
|
|
393
470
|
// Process messages before each AI call
|
|
394
471
|
messages = await this.messageProcessor.processMessages(
|
|
395
472
|
messages,
|
|
396
|
-
"
|
|
473
|
+
"pre_call"
|
|
397
474
|
);
|
|
398
475
|
const compressThreshold = 10000;
|
|
399
476
|
|
|
@@ -405,25 +482,36 @@ export abstract class BaseAgent implements IAgent {
|
|
|
405
482
|
});
|
|
406
483
|
|
|
407
484
|
if (response?.usd_cost === undefined) {
|
|
408
|
-
console.warn(
|
|
485
|
+
console.warn(
|
|
486
|
+
"Response cost is undefined",
|
|
487
|
+
JSON.stringify(response, null, 2)
|
|
488
|
+
);
|
|
409
489
|
}
|
|
410
490
|
|
|
411
491
|
this.adjustTotalCostUsd(response?.usd_cost);
|
|
412
|
-
this.logMessages(response.choices.map((c) => c.message));
|
|
413
|
-
|
|
414
|
-
const firstMessage = response.choices[0].message;
|
|
415
|
-
const newToolCalls = response.choices.flatMap(
|
|
416
|
-
(c) => c.message.tool_calls
|
|
417
|
-
);
|
|
418
492
|
|
|
493
|
+
// Typically, there's only one choice in the array, but you could have many
|
|
494
|
+
// If you set `n` to more than 1, you will get multiple choices
|
|
419
495
|
for (const choice of response.choices) {
|
|
420
|
-
|
|
421
|
-
console.log(responseMessage);
|
|
496
|
+
messages.push(choice.message);
|
|
422
497
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
498
|
+
messages = await this.messageProcessor.processMessages(
|
|
499
|
+
messages,
|
|
500
|
+
"post_call"
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
const lastMessage = messages[messages.length - 1];
|
|
504
|
+
|
|
505
|
+
this.logMessages([lastMessage]);
|
|
506
|
+
|
|
507
|
+
const toolCalls = lastMessage.tool_calls;
|
|
508
|
+
if (lastMessage.tool_calls) {
|
|
509
|
+
// About to call a tool, process the messages
|
|
510
|
+
// We could add all the tool calls, and do this once
|
|
511
|
+
messages = await this.messageProcessor.processMessages(
|
|
512
|
+
messages,
|
|
513
|
+
"pre_tools"
|
|
514
|
+
);
|
|
427
515
|
|
|
428
516
|
for (const toolCall of toolCalls) {
|
|
429
517
|
const toolMessages = await this.processToolMessages(toolCall);
|
|
@@ -445,15 +533,19 @@ export abstract class BaseAgent implements IAgent {
|
|
|
445
533
|
}
|
|
446
534
|
}
|
|
447
535
|
|
|
536
|
+
const newToolCalls = response.choices.flatMap(
|
|
537
|
+
(c) => c.message.tool_calls
|
|
538
|
+
);
|
|
448
539
|
// Process messages after tool execution
|
|
449
540
|
if (newToolCalls && newToolCalls.length > 0) {
|
|
450
541
|
messages = await this.messageProcessor.processMessages(
|
|
451
542
|
messages,
|
|
452
|
-
"
|
|
543
|
+
"post_tools"
|
|
453
544
|
);
|
|
454
545
|
}
|
|
455
546
|
|
|
456
547
|
// Early exit: not required to call tool
|
|
548
|
+
const firstMessage = response.choices[0].message;
|
|
457
549
|
if (
|
|
458
550
|
response.choices.length === 1 &&
|
|
459
551
|
firstMessage.content &&
|
|
@@ -501,9 +593,43 @@ export abstract class BaseAgent implements IAgent {
|
|
|
501
593
|
console.log(
|
|
502
594
|
"Agent continuing to the next iteration, reminding agent how to terminate"
|
|
503
595
|
);
|
|
596
|
+
|
|
597
|
+
const remainingTime =
|
|
598
|
+
this.maxRunTimeMs && this.startTimeMs
|
|
599
|
+
? this.maxRunTimeMs - (Date.now() - this.startTimeMs)
|
|
600
|
+
: null;
|
|
601
|
+
|
|
602
|
+
const remainingTurns = this.maxTurns
|
|
603
|
+
? this.maxTurns - this.turnCount
|
|
604
|
+
: null;
|
|
605
|
+
|
|
606
|
+
const timeRemainsingMsg = remainingTime
|
|
607
|
+
? `You have approximately ${Math.floor(
|
|
608
|
+
remainingTime / 1000
|
|
609
|
+
)} seconds remaining for this task. `
|
|
610
|
+
: "";
|
|
611
|
+
|
|
612
|
+
const turnsRemainingMsg = remainingTurns
|
|
613
|
+
? `You have ${remainingTurns} turns remaining. `
|
|
614
|
+
: "";
|
|
615
|
+
|
|
616
|
+
const remainingBudget = this.maxSpend
|
|
617
|
+
? this.maxSpend - this.totalCostUsd
|
|
618
|
+
: null;
|
|
619
|
+
const budgetRemainingMsg = remainingBudget
|
|
620
|
+
? `You have $${remainingBudget.toFixed(4)} remaining in your budget.`
|
|
621
|
+
: "";
|
|
622
|
+
|
|
623
|
+
const continuation = `<Workflow>
|
|
624
|
+
workflow continues until you call one of ${this.requiredToolNames}.\n
|
|
625
|
+
${timeRemainsingMsg}
|
|
626
|
+
${turnsRemainingMsg}
|
|
627
|
+
${budgetRemainingMsg}
|
|
628
|
+
</Workflow>`;
|
|
629
|
+
|
|
504
630
|
messages.push({
|
|
505
631
|
role: "user",
|
|
506
|
-
content:
|
|
632
|
+
content: continuation,
|
|
507
633
|
});
|
|
508
634
|
}
|
|
509
635
|
|
|
@@ -17,6 +17,34 @@ You think step by step about the blocks of code you're modifying.
|
|
|
17
17
|
You may use the execCommand tool to navigate the filesystem and to create new folders if needed.
|
|
18
18
|
You may use the execCommand tool to use git to view which changes have been made so far via git diff and git status.
|
|
19
19
|
|
|
20
|
+
# Creative Tool Usage Examples
|
|
21
|
+
|
|
22
|
+
Beyond basic file editing, consider these powerful tool combinations:
|
|
23
|
+
|
|
24
|
+
## String Replace Tool
|
|
25
|
+
- **Bulk renaming**: Use stringReplace across multiple files to rename variables, functions, or imports
|
|
26
|
+
- **Configuration updates**: Replace API endpoints, version numbers, or feature flags across the codebase
|
|
27
|
+
- **Dependency updates**: Update import paths when reorganizing code structure
|
|
28
|
+
|
|
29
|
+
## YCMD Language Server Integration
|
|
30
|
+
- **Find all references**: Use ycmdGoTo with GoToReferences to find every usage of a function before refactoring
|
|
31
|
+
- **Auto-complete exploration**: Use ycmdCompletion to discover available methods/properties on objects
|
|
32
|
+
- **Smart navigation**: Use ycmdGoTo with GoToDefinition to understand code structure before making changes
|
|
33
|
+
- **Error-driven development**: Use ycmdDiagnostics to identify compilation errors and fix them systematically
|
|
34
|
+
- **Intelligent renaming**: Use ycmdRefactor with RefactorRename for safe symbol renaming across files
|
|
35
|
+
|
|
36
|
+
## Search and Analysis Workflows
|
|
37
|
+
- **Impact analysis**: Use textSearch + ycmdGoTo to understand how changes will affect the codebase
|
|
38
|
+
- **Pattern discovery**: Use embeddingSearch to find similar code patterns when implementing new features
|
|
39
|
+
- **Code exploration**: Combine fileSearch + readFile + ycmdCompletion to understand unfamiliar codebases
|
|
40
|
+
|
|
41
|
+
## Advanced Combinations
|
|
42
|
+
- **Refactoring workflow**: ycmdDiagnostics → ycmdGoTo → stringReplace → ycmdDiagnostics (verify fixes)
|
|
43
|
+
- **Feature implementation**: embeddingSearch → ycmdCompletion → patchFile → ycmdDiagnostics
|
|
44
|
+
- **Code cleanup**: textSearch → ycmdRefactor (organize imports) → stringReplace (standardize patterns)
|
|
45
|
+
|
|
46
|
+
Think creatively about tool combinations - each tool can amplify the others' effectiveness!
|
|
47
|
+
|
|
20
48
|
# PLUGINS REMINDER:
|
|
21
49
|
|
|
22
50
|
Plugins are used to automatically expand user input with more context.
|
package/src/agents/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AgentContext } from "./base/base";
|
|
|
3
3
|
import { DeveloperAgent } from "./developer/developer";
|
|
4
4
|
import { PatchingAgent } from "./patcher/patcher";
|
|
5
5
|
import { ResearcherAgent } from "./researcher/researcher";
|
|
6
|
+
import { SetupAgent } from "./setup/setup";
|
|
6
7
|
|
|
7
8
|
export { BaseAgent } from "./base/base";
|
|
8
9
|
export { ConfigAgent } from "./configurable/ConfigAgent";
|
|
@@ -19,6 +20,7 @@ let singletons = {} as {
|
|
|
19
20
|
Developer: DeveloperAgent;
|
|
20
21
|
Patcher: PatchingAgent;
|
|
21
22
|
Researcher: ResearcherAgent;
|
|
23
|
+
Setup: SetupAgent;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export function agents(agentContext: AgentContext = services()) {
|
|
@@ -27,6 +29,7 @@ export function agents(agentContext: AgentContext = services()) {
|
|
|
27
29
|
Developer: new DeveloperAgent(agentContext),
|
|
28
30
|
Patcher: new PatchingAgent(agentContext),
|
|
29
31
|
Researcher: new ResearcherAgent(agentContext),
|
|
32
|
+
Setup: new SetupAgent(agentContext),
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
return singletons;
|
|
@@ -77,13 +77,11 @@ export class PatchingAgent extends BaseAgent {
|
|
|
77
77
|
|
|
78
78
|
constructor(context: AgentContext) {
|
|
79
79
|
super(context);
|
|
80
|
-
this.disableTool("sendVimInput");
|
|
81
|
-
this.disableTool("openFileInVim");
|
|
82
80
|
|
|
83
81
|
this.setModelPreferences([
|
|
84
82
|
{ model: Models.anthropic.Sonnet4, provider: "anthropic" },
|
|
85
83
|
{
|
|
86
|
-
model: Models.openai.
|
|
84
|
+
model: Models.openai.GPT_41_Mini,
|
|
87
85
|
provider: "openai",
|
|
88
86
|
},
|
|
89
87
|
]);
|
|
@@ -98,10 +96,14 @@ export class PatchingAgent extends BaseAgent {
|
|
|
98
96
|
${systemReminder}
|
|
99
97
|
|
|
100
98
|
Specialization: Patcher Agent, ${this.description}
|
|
99
|
+
|
|
100
|
+
# Language Server Integration:
|
|
101
|
+
Use ycmd tools (ycmdDiagnostics, ycmdCompletion, ycmdRefactor, ycmdGoTo) to get error diagnostics, code completions, refactor symbols, and navigate definitions before making changes.
|
|
102
|
+
This helps ensure accurate modifications and can suggest fixes for compilation errors.
|
|
103
|
+
|
|
101
104
|
IF you fail twice to patch a file, you may switch using writeFileChunk to rewrite the whole file.
|
|
102
105
|
`,
|
|
103
106
|
},
|
|
104
|
-
// { role: "user", content: systemReminder },
|
|
105
107
|
{ role: "user", content: userInput },
|
|
106
108
|
] as Message[];
|
|
107
109
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Message } from "../../clients/types";
|
|
2
|
+
import { AgentContext, BaseAgent } from "../base/base";
|
|
3
|
+
import { BASE_PROMPT } from "../base/prompt";
|
|
4
|
+
import configExamples from "../../prompts/KnowhowConfigExamples";
|
|
5
|
+
import { Models } from "../../ai";
|
|
6
|
+
|
|
7
|
+
export class SetupAgent extends BaseAgent {
|
|
8
|
+
name = "Setup";
|
|
9
|
+
description = `This agent is great for setting up knowhow`;
|
|
10
|
+
|
|
11
|
+
constructor(context: AgentContext) {
|
|
12
|
+
super(context);
|
|
13
|
+
|
|
14
|
+
this.setModelPreferences([
|
|
15
|
+
{ model: Models.anthropic.Sonnet4, provider: "anthropic" },
|
|
16
|
+
{
|
|
17
|
+
model: Models.openai.GPT_41_Mini,
|
|
18
|
+
provider: "openai",
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async getInitialMessages(userInput: string) {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
role: "system",
|
|
27
|
+
content: `${BASE_PROMPT}
|
|
28
|
+
|
|
29
|
+
You are the Knowhow Setup agent, you work with the user to help setup their config to get the most out of knowhow.
|
|
30
|
+
|
|
31
|
+
Here are some config examples: ${configExamples}
|
|
32
|
+
|
|
33
|
+
Use the tools to analyze the codebase and help the user setup embeddings and mcp servers or any other config features, like linters etc
|
|
34
|
+
|
|
35
|
+
If the user asks about a mcp that we don't have in the config you can google it and figure out what the configuration would look like to add it.
|
|
36
|
+
|
|
37
|
+
If the task is for how to do something, you should ask the user if they want you to do it for them by using the askHuman tool. For isntance, how coul d I hook up this agent to gmail, you would research the mcp options for gmail, and then ask them if they'd like for you to update the config with whatever options you found.
|
|
38
|
+
|
|
39
|
+
Always ask the user to approve what you're going to do to the config, that way you can get feedback via askHuman before modifying the config
|
|
40
|
+
|
|
41
|
+
When setting up the language plugin for a user you should come up with phrases they're likely to say, like frontend/backend/schema etc that will signal we should load in guides or rules for that type of task. You should put any of your rules/analses in .knowhow/docs and the language plugin should reference those.
|
|
42
|
+
|
|
43
|
+
If a user is vauge about setting up, you should give them some options of what all you could help them setup with a brief explanation of what those setups would enable.
|
|
44
|
+
|
|
45
|
+
Only suggest embeddings that include a folder path with many elements, ie src/**/*.ts, never suggest entries with one element
|
|
46
|
+
|
|
47
|
+
If a user is requesting help with setting up a coding project, you can look at their package.json to setup the lintCommands so that we get feedback on file edits, and embeddings for the source code as those two features are the highest impact
|
|
48
|
+
|
|
49
|
+
If the user just says setup fast, try to get a general idea of the project file structure and setup one source code embedding for the whole codebaseand linter commands if possible. Try not do dig too deep if they want fast, just get the highest impact features setup
|
|
50
|
+
|
|
51
|
+
`,
|
|
52
|
+
},
|
|
53
|
+
{ role: "user", content: userInput },
|
|
54
|
+
] as Message[];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -7,8 +7,12 @@ export async function agentCall(agentName: string, userInput: string) {
|
|
|
7
7
|
const toolService = this as ToolsService;
|
|
8
8
|
|
|
9
9
|
const { Events, Plugins } = toolService.getContext();
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
let fullPrompt = `${userInput}`;
|
|
12
|
+
if (config.plugins?.length) {
|
|
13
|
+
const pluginText = await Plugins.callMany(config.plugins, userInput);
|
|
14
|
+
fullPrompt += `\n ${pluginText}`;
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
Events.emit("agents:call", {
|
|
14
18
|
name: agentName,
|