@tyvm/knowhow 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +14 -0
- package/CONFIG.md +336 -0
- package/README.md +49 -0
- package/autodoc/chat.mdx +20 -0
- package/autodoc/cli.mdx +11 -0
- package/autodoc/plugins/asana.mdx +47 -0
- package/autodoc/plugins/downloader/downloader.mdx +38 -0
- package/autodoc/plugins/downloader/plugin.mdx +37 -0
- package/autodoc/plugins/downloader/types.mdx +42 -0
- package/autodoc/plugins/embedding.mdx +41 -0
- package/autodoc/plugins/figma.mdx +45 -0
- package/autodoc/plugins/github.mdx +40 -0
- package/autodoc/plugins/jira.mdx +46 -0
- package/autodoc/plugins/language.mdx +37 -0
- package/autodoc/plugins/linear.mdx +35 -0
- package/autodoc/plugins/notion.mdx +38 -0
- package/autodoc/plugins/plugins.mdx +59 -0
- package/autodoc/plugins/types.mdx +51 -0
- package/autodoc/plugins/vim.mdx +39 -0
- package/autodoc/tools/addInternalTools.mdx +1 -0
- package/autodoc/tools/agentCall.mdx +1 -0
- package/autodoc/tools/asana/definitions.mdx +10 -0
- package/autodoc/tools/asana/index.mdx +12 -0
- package/autodoc/tools/askHuman.mdx +1 -0
- package/autodoc/tools/callPlugin.mdx +1 -0
- package/autodoc/tools/embeddingSearch.mdx +1 -0
- package/autodoc/tools/execCommand.mdx +1 -0
- package/autodoc/tools/fileSearch.mdx +1 -0
- package/autodoc/tools/finalAnswer.mdx +1 -0
- package/autodoc/tools/github/definitions.mdx +6 -0
- package/autodoc/tools/github/index.mdx +8 -0
- package/autodoc/tools/index.mdx +14 -0
- package/autodoc/tools/lintFile.mdx +7 -0
- package/autodoc/tools/list.mdx +16 -0
- package/autodoc/tools/modifyFile.mdx +7 -0
- package/autodoc/tools/patch.mdx +9 -0
- package/autodoc/tools/readBlocks.mdx +1 -0
- package/autodoc/tools/readFile.mdx +1 -0
- package/autodoc/tools/scanFile.mdx +1 -0
- package/autodoc/tools/textSearch.mdx +6 -0
- package/autodoc/tools/types/fileblock.mdx +1 -0
- package/autodoc/tools/visionTool.mdx +1 -0
- package/autodoc/tools/writeFile.mdx +1 -0
- package/jest.config.js +18 -0
- package/package.json +89 -0
- package/src/agents/base/base.ts +619 -0
- package/src/agents/base/prompt.ts +26 -0
- package/src/agents/configurable/ConfigAgent.ts +23 -0
- package/src/agents/developer/developer.ts +69 -0
- package/src/agents/index.ts +8 -0
- package/src/agents/interface.ts +11 -0
- package/src/agents/patcher/codebase.md +27 -0
- package/src/agents/patcher/patcher.ts +110 -0
- package/src/agents/researcher/researcher.ts +109 -0
- package/src/agents/tools/addInternalTools.ts +21 -0
- package/src/agents/tools/agentCall.ts +18 -0
- package/src/agents/tools/aiClient.ts +36 -0
- package/src/agents/tools/asana/definitions.ts +199 -0
- package/src/agents/tools/asana/index.ts +108 -0
- package/src/agents/tools/askHuman.ts +8 -0
- package/src/agents/tools/callPlugin.ts +4 -0
- package/src/agents/tools/embeddingSearch.ts +5 -0
- package/src/agents/tools/execCommand.ts +26 -0
- package/src/agents/tools/fileSearch.ts +33 -0
- package/src/agents/tools/finalAnswer.ts +4 -0
- package/src/agents/tools/github/definitions.ts +89 -0
- package/src/agents/tools/github/index.ts +67 -0
- package/src/agents/tools/googleSearch.ts +242 -0
- package/src/agents/tools/index.ts +24 -0
- package/src/agents/tools/language/definitions.ts +97 -0
- package/src/agents/tools/language/index.ts +19 -0
- package/src/agents/tools/lintFile.ts +17 -0
- package/src/agents/tools/list.ts +514 -0
- package/src/agents/tools/loadWebpage.ts +129 -0
- package/src/agents/tools/modifyFile.ts +53 -0
- package/src/agents/tools/patch.ts +672 -0
- package/src/agents/tools/readBlocks.ts +41 -0
- package/src/agents/tools/readFile.ts +39 -0
- package/src/agents/tools/scanFile.ts +16 -0
- package/src/agents/tools/textSearch.ts +21 -0
- package/src/agents/tools/types/fileblock.ts +5 -0
- package/src/agents/tools/visionTool.ts +5 -0
- package/src/agents/tools/writeFile.ts +46 -0
- package/src/agents/vim/vim.ts +153 -0
- package/src/ai.ts +167 -0
- package/src/chat.ts +412 -0
- package/src/cli.ts +85 -0
- package/src/clients/anthropic.ts +399 -0
- package/src/clients/gemini.ts +486 -0
- package/src/clients/http.ts +107 -0
- package/src/clients/index.ts +183 -0
- package/src/clients/knowhow.ts +33 -0
- package/src/clients/openai.ts +253 -0
- package/src/clients/types.ts +91 -0
- package/src/clients/xai.ts +132 -0
- package/src/config.ts +211 -0
- package/src/conversion.ts +140 -0
- package/src/dataset/diffs/README.md +12 -0
- package/src/dataset/diffs/debug-errors.ts +29 -0
- package/src/dataset/diffs/debug.ts +64 -0
- package/src/dataset/diffs/generate.ts +71 -0
- package/src/dataset/diffs/jsonl.ts +54 -0
- package/src/dataset/diffs/test.ts +193 -0
- package/src/embeddings.ts +411 -0
- package/src/hashes.ts +67 -0
- package/src/index.ts +376 -0
- package/src/login.ts +78 -0
- package/src/microphone.ts +136 -0
- package/src/modules/index.ts +37 -0
- package/src/modules/types.ts +48 -0
- package/src/plugins/asana.ts +134 -0
- package/src/plugins/downloader/downloader.ts +204 -0
- package/src/plugins/downloader/plugin.ts +85 -0
- package/src/plugins/downloader/types.ts +85 -0
- package/src/plugins/embedding.ts +42 -0
- package/src/plugins/figma.ts +137 -0
- package/src/plugins/github.ts +153 -0
- package/src/plugins/jira.ts +104 -0
- package/src/plugins/language.ts +100 -0
- package/src/plugins/linear.ts +219 -0
- package/src/plugins/notion.ts +170 -0
- package/src/plugins/plugins.ts +56 -0
- package/src/plugins/types.ts +5 -0
- package/src/plugins/url.ts +63 -0
- package/src/plugins/vim.ts +73 -0
- package/src/prompts/BasicCodeDocumenter.ts +1 -0
- package/src/prompts/BasicProjectDocumenter.ts +1 -0
- package/src/prompts/EmbeddingSeachHelper.ts +1 -0
- package/src/prompts/index.ts +9 -0
- package/src/server/index.ts +14 -0
- package/src/services/AgentService.ts +98 -0
- package/src/services/EmbeddingService.ts +410 -0
- package/src/services/EventService.ts +20 -0
- package/src/services/GitHub.ts +60 -0
- package/src/services/KnowhowClient.ts +113 -0
- package/src/services/Mcp.ts +270 -0
- package/src/services/McpServer.ts +119 -0
- package/src/services/McpWebsocketTransport.ts +64 -0
- package/src/services/S3.ts +126 -0
- package/src/services/Tools.ts +65 -0
- package/src/services/flags.ts +52 -0
- package/src/services/index.ts +8 -0
- package/src/types.ts +225 -0
- package/src/utils/index.ts +108 -0
- package/src/worker.ts +80 -0
- package/tests/integration/figma.test.ts +70 -0
- package/tests/integration/fileblocks/readwrite.test.ts +95 -0
- package/tests/integration/patching/input.txt +145 -0
- package/tests/integration/patching/output.txt +145 -0
- package/tests/integration/patching/patch.txt +15 -0
- package/tests/integration/patching/unseen.txt +80 -0
- package/tests/integration/patching.test.ts +136 -0
- package/tests/languagePlugin.test.ts +74 -0
- package/tests/patching/corrupted.test.ts +78 -0
- package/tests/patching/imports.patch.txt +11 -0
- package/tests/patching/imports.test.ts +43 -0
- package/tests/patching/imports.txt +11 -0
- package/tests/patching/interface.patch.txt +15 -0
- package/tests/patching/interface.txt +7 -0
- package/tests/test.spec.ts +132 -0
- package/ts_build/src/agents/base/base.d.ts +88 -0
- package/ts_build/src/agents/base/base.js +464 -0
- package/ts_build/src/agents/base/base.js.map +1 -0
- package/ts_build/src/agents/base/prompt.d.ts +1 -0
- package/ts_build/src/agents/base/prompt.js +30 -0
- package/ts_build/src/agents/base/prompt.js.map +1 -0
- package/ts_build/src/agents/configurable/ConfigAgent.d.ts +10 -0
- package/ts_build/src/agents/configurable/ConfigAgent.js +25 -0
- package/ts_build/src/agents/configurable/ConfigAgent.js.map +1 -0
- package/ts_build/src/agents/configurable/OpenAIAgent.d.ts +0 -0
- package/ts_build/src/agents/configurable/OpenAIAgent.js +1 -0
- package/ts_build/src/agents/configurable/OpenAIAgent.js.map +1 -0
- package/ts_build/src/agents/developer/developer.d.ts +9 -0
- package/ts_build/src/agents/developer/developer.js +69 -0
- package/ts_build/src/agents/developer/developer.js.map +1 -0
- package/ts_build/src/agents/index.d.ts +7 -0
- package/ts_build/src/agents/index.js +38 -0
- package/ts_build/src/agents/index.js.map +1 -0
- package/ts_build/src/agents/interface.d.ts +10 -0
- package/ts_build/src/agents/interface.js +3 -0
- package/ts_build/src/agents/interface.js.map +1 -0
- package/ts_build/src/agents/patcher/patcher.d.ts +9 -0
- package/ts_build/src/agents/patcher/patcher.js +106 -0
- package/ts_build/src/agents/patcher/patcher.js.map +1 -0
- package/ts_build/src/agents/researcher/researcher.d.ts +9 -0
- package/ts_build/src/agents/researcher/researcher.js +107 -0
- package/ts_build/src/agents/researcher/researcher.js.map +1 -0
- package/ts_build/src/agents/tools/addInternalTools.d.ts +5 -0
- package/ts_build/src/agents/tools/addInternalTools.js +18 -0
- package/ts_build/src/agents/tools/addInternalTools.js.map +1 -0
- package/ts_build/src/agents/tools/agentCall.d.ts +1 -0
- package/ts_build/src/agents/tools/agentCall.js +21 -0
- package/ts_build/src/agents/tools/agentCall.js.map +1 -0
- package/ts_build/src/agents/tools/aiClient.d.ts +6 -0
- package/ts_build/src/agents/tools/aiClient.js +25 -0
- package/ts_build/src/agents/tools/aiClient.js.map +1 -0
- package/ts_build/src/agents/tools/asana/definitions.d.ts +202 -0
- package/ts_build/src/agents/tools/asana/definitions.js +197 -0
- package/ts_build/src/agents/tools/asana/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/asana/index.d.ts +8 -0
- package/ts_build/src/agents/tools/asana/index.js +98 -0
- package/ts_build/src/agents/tools/asana/index.js.map +1 -0
- package/ts_build/src/agents/tools/askHuman.d.ts +1 -0
- package/ts_build/src/agents/tools/askHuman.js +15 -0
- package/ts_build/src/agents/tools/askHuman.js.map +1 -0
- package/ts_build/src/agents/tools/callPlugin.d.ts +1 -0
- package/ts_build/src/agents/tools/callPlugin.js +9 -0
- package/ts_build/src/agents/tools/callPlugin.js.map +1 -0
- package/ts_build/src/agents/tools/client.d.ts +5 -0
- package/ts_build/src/agents/tools/client.js +21 -0
- package/ts_build/src/agents/tools/client.js.map +1 -0
- package/ts_build/src/agents/tools/embeddingSearch.d.ts +1 -0
- package/ts_build/src/agents/tools/embeddingSearch.js +9 -0
- package/ts_build/src/agents/tools/embeddingSearch.js.map +1 -0
- package/ts_build/src/agents/tools/execCommand.d.ts +1 -0
- package/ts_build/src/agents/tools/execCommand.js +25 -0
- package/ts_build/src/agents/tools/execCommand.js.map +1 -0
- package/ts_build/src/agents/tools/fileSearch.d.ts +1 -0
- package/ts_build/src/agents/tools/fileSearch.js +31 -0
- package/ts_build/src/agents/tools/fileSearch.js.map +1 -0
- package/ts_build/src/agents/tools/finalAnswer.d.ts +1 -0
- package/ts_build/src/agents/tools/finalAnswer.js +8 -0
- package/ts_build/src/agents/tools/finalAnswer.js.map +1 -0
- package/ts_build/src/agents/tools/github/definitions.d.ts +47 -0
- package/ts_build/src/agents/tools/github/definitions.js +86 -0
- package/ts_build/src/agents/tools/github/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/github/index.d.ts +789 -0
- package/ts_build/src/agents/tools/github/index.js +56 -0
- package/ts_build/src/agents/tools/github/index.js.map +1 -0
- package/ts_build/src/agents/tools/googleSearch.d.ts +93 -0
- package/ts_build/src/agents/tools/googleSearch.js +117 -0
- package/ts_build/src/agents/tools/googleSearch.js.map +1 -0
- package/ts_build/src/agents/tools/googleSearchTypes.d.ts +74 -0
- package/ts_build/src/agents/tools/googleSearchTypes.js +3 -0
- package/ts_build/src/agents/tools/googleSearchTypes.js.map +1 -0
- package/ts_build/src/agents/tools/index.d.ts +24 -0
- package/ts_build/src/agents/tools/index.js +41 -0
- package/ts_build/src/agents/tools/index.js.map +1 -0
- package/ts_build/src/agents/tools/language/definitions.d.ts +89 -0
- package/ts_build/src/agents/tools/language/definitions.js +95 -0
- package/ts_build/src/agents/tools/language/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/language/index.d.ts +4 -0
- package/ts_build/src/agents/tools/language/index.js +22 -0
- package/ts_build/src/agents/tools/language/index.js.map +1 -0
- package/ts_build/src/agents/tools/lintFile.d.ts +1 -0
- package/ts_build/src/agents/tools/lintFile.js +22 -0
- package/ts_build/src/agents/tools/lintFile.js.map +1 -0
- package/ts_build/src/agents/tools/list.d.ts +2 -0
- package/ts_build/src/agents/tools/list.js +505 -0
- package/ts_build/src/agents/tools/list.js.map +1 -0
- package/ts_build/src/agents/tools/loadWebpage.d.ts +8 -0
- package/ts_build/src/agents/tools/loadWebpage.js +97 -0
- package/ts_build/src/agents/tools/loadWebpage.js.map +1 -0
- package/ts_build/src/agents/tools/modifyFile.d.ts +2 -0
- package/ts_build/src/agents/tools/modifyFile.js +74 -0
- package/ts_build/src/agents/tools/modifyFile.js.map +1 -0
- package/ts_build/src/agents/tools/patch.d.ts +21 -0
- package/ts_build/src/agents/tools/patch.js +443 -0
- package/ts_build/src/agents/tools/patch.js.map +1 -0
- package/ts_build/src/agents/tools/readBlocks.d.ts +2 -0
- package/ts_build/src/agents/tools/readBlocks.js +59 -0
- package/ts_build/src/agents/tools/readBlocks.js.map +1 -0
- package/ts_build/src/agents/tools/readFile.d.ts +1 -0
- package/ts_build/src/agents/tools/readFile.js +46 -0
- package/ts_build/src/agents/tools/readFile.js.map +1 -0
- package/ts_build/src/agents/tools/scanFile.d.ts +1 -0
- package/ts_build/src/agents/tools/scanFile.js +36 -0
- package/ts_build/src/agents/tools/scanFile.js.map +1 -0
- package/ts_build/src/agents/tools/textSearch.d.ts +1 -0
- package/ts_build/src/agents/tools/textSearch.js +22 -0
- package/ts_build/src/agents/tools/textSearch.js.map +1 -0
- package/ts_build/src/agents/tools/types/fileblock.d.ts +5 -0
- package/ts_build/src/agents/tools/types/fileblock.js +3 -0
- package/ts_build/src/agents/tools/types/fileblock.js.map +1 -0
- package/ts_build/src/agents/tools/visionTool.d.ts +1 -0
- package/ts_build/src/agents/tools/visionTool.js +9 -0
- package/ts_build/src/agents/tools/visionTool.js.map +1 -0
- package/ts_build/src/agents/tools/writeFile.d.ts +2 -0
- package/ts_build/src/agents/tools/writeFile.js +61 -0
- package/ts_build/src/agents/tools/writeFile.js.map +1 -0
- package/ts_build/src/agents/vim/vim.d.ts +14 -0
- package/ts_build/src/agents/vim/vim.js +171 -0
- package/ts_build/src/agents/vim/vim.js.map +1 -0
- package/ts_build/src/ai.d.ts +10 -0
- package/ts_build/src/ai.js +102 -0
- package/ts_build/src/ai.js.map +1 -0
- package/ts_build/src/chat.d.ts +13 -0
- package/ts_build/src/chat.js +319 -0
- package/ts_build/src/chat.js.map +1 -0
- package/ts_build/src/cli.d.ts +2 -0
- package/ts_build/src/cli.js +98 -0
- package/ts_build/src/cli.js.map +1 -0
- package/ts_build/src/clients/anthropic.d.ts +31 -0
- package/ts_build/src/clients/anthropic.js +344 -0
- package/ts_build/src/clients/anthropic.js.map +1 -0
- package/ts_build/src/clients/gemini.d.ts +20 -0
- package/ts_build/src/clients/gemini.js +347 -0
- package/ts_build/src/clients/gemini.js.map +1 -0
- package/ts_build/src/clients/http.d.ts +12 -0
- package/ts_build/src/clients/http.js +91 -0
- package/ts_build/src/clients/http.js.map +1 -0
- package/ts_build/src/clients/index.d.ts +47 -0
- package/ts_build/src/clients/index.js +143 -0
- package/ts_build/src/clients/index.js.map +1 -0
- package/ts_build/src/clients/knowhow.d.ts +10 -0
- package/ts_build/src/clients/knowhow.js +24 -0
- package/ts_build/src/clients/knowhow.js.map +1 -0
- package/ts_build/src/clients/openai.d.ts +20 -0
- package/ts_build/src/clients/openai.js +221 -0
- package/ts_build/src/clients/openai.js.map +1 -0
- package/ts_build/src/clients/types.d.ts +89 -0
- package/ts_build/src/clients/types.js +3 -0
- package/ts_build/src/clients/types.js.map +1 -0
- package/ts_build/src/clients/xai.d.ts +22 -0
- package/ts_build/src/clients/xai.js +108 -0
- package/ts_build/src/clients/xai.js.map +1 -0
- package/ts_build/src/config.d.ts +9 -0
- package/ts_build/src/config.js +216 -0
- package/ts_build/src/config.js.map +1 -0
- package/ts_build/src/conversion.d.ts +7 -0
- package/ts_build/src/conversion.js +114 -0
- package/ts_build/src/conversion.js.map +1 -0
- package/ts_build/src/dataset/diffs/debug-errors.d.ts +1 -0
- package/ts_build/src/dataset/diffs/debug-errors.js +28 -0
- package/ts_build/src/dataset/diffs/debug-errors.js.map +1 -0
- package/ts_build/src/dataset/diffs/debug.d.ts +1 -0
- package/ts_build/src/dataset/diffs/debug.js +50 -0
- package/ts_build/src/dataset/diffs/debug.js.map +1 -0
- package/ts_build/src/dataset/diffs/generate.d.ts +1 -0
- package/ts_build/src/dataset/diffs/generate.js +70 -0
- package/ts_build/src/dataset/diffs/generate.js.map +1 -0
- package/ts_build/src/dataset/diffs/jsonl.d.ts +1 -0
- package/ts_build/src/dataset/diffs/jsonl.js +47 -0
- package/ts_build/src/dataset/diffs/jsonl.js.map +1 -0
- package/ts_build/src/dataset/diffs/test.d.ts +1 -0
- package/ts_build/src/dataset/diffs/test.js +114 -0
- package/ts_build/src/dataset/diffs/test.js.map +1 -0
- package/ts_build/src/embeddings.d.ts +19 -0
- package/ts_build/src/embeddings.js +322 -0
- package/ts_build/src/embeddings.js.map +1 -0
- package/ts_build/src/hashes.d.ts +6 -0
- package/ts_build/src/hashes.js +78 -0
- package/ts_build/src/hashes.js.map +1 -0
- package/ts_build/src/index.d.ts +14 -0
- package/ts_build/src/index.js +258 -0
- package/ts_build/src/index.js.map +1 -0
- package/ts_build/src/login.d.ts +2 -0
- package/ts_build/src/login.js +63 -0
- package/ts_build/src/login.js.map +1 -0
- package/ts_build/src/microphone.d.ts +9 -0
- package/ts_build/src/microphone.js +131 -0
- package/ts_build/src/microphone.js.map +1 -0
- package/ts_build/src/modules/index.d.ts +3 -0
- package/ts_build/src/modules/index.js +34 -0
- package/ts_build/src/modules/index.js.map +1 -0
- package/ts_build/src/modules/types.d.ts +37 -0
- package/ts_build/src/modules/types.js +3 -0
- package/ts_build/src/modules/types.js.map +1 -0
- package/ts_build/src/plugins/asana.d.ts +16 -0
- package/ts_build/src/plugins/asana.js +114 -0
- package/ts_build/src/plugins/asana.js.map +1 -0
- package/ts_build/src/plugins/downloader/downloader.d.ts +12 -0
- package/ts_build/src/plugins/downloader/downloader.js +174 -0
- package/ts_build/src/plugins/downloader/downloader.js.map +1 -0
- package/ts_build/src/plugins/downloader/index.d.ts +3 -0
- package/ts_build/src/plugins/downloader/index.js +41 -0
- package/ts_build/src/plugins/downloader/index.js.map +1 -0
- package/ts_build/src/plugins/downloader/plugin.d.ts +8 -0
- package/ts_build/src/plugins/downloader/plugin.js +83 -0
- package/ts_build/src/plugins/downloader/plugin.js.map +1 -0
- package/ts_build/src/plugins/downloader/types.d.ts +82 -0
- package/ts_build/src/plugins/downloader/types.js +79 -0
- package/ts_build/src/plugins/downloader/types.js.map +1 -0
- package/ts_build/src/plugins/embedding.d.ts +5 -0
- package/ts_build/src/plugins/embedding.js +28 -0
- package/ts_build/src/plugins/embedding.js.map +1 -0
- package/ts_build/src/plugins/figma.d.ts +20 -0
- package/ts_build/src/plugins/figma.js +94 -0
- package/ts_build/src/plugins/figma.js.map +1 -0
- package/ts_build/src/plugins/github.d.ts +1223 -0
- package/ts_build/src/plugins/github.js +115 -0
- package/ts_build/src/plugins/github.js.map +1 -0
- package/ts_build/src/plugins/jira.d.ts +15 -0
- package/ts_build/src/plugins/jira.js +94 -0
- package/ts_build/src/plugins/jira.js.map +1 -0
- package/ts_build/src/plugins/language.d.ts +8 -0
- package/ts_build/src/plugins/language.js +69 -0
- package/ts_build/src/plugins/language.js.map +1 -0
- package/ts_build/src/plugins/linear.d.ts +23 -0
- package/ts_build/src/plugins/linear.js +184 -0
- package/ts_build/src/plugins/linear.js.map +1 -0
- package/ts_build/src/plugins/notion.d.ts +32 -0
- package/ts_build/src/plugins/notion.js +131 -0
- package/ts_build/src/plugins/notion.js.map +1 -0
- package/ts_build/src/plugins/plugins.d.ts +11 -0
- package/ts_build/src/plugins/plugins.js +51 -0
- package/ts_build/src/plugins/plugins.js.map +1 -0
- package/ts_build/src/plugins/types.d.ts +5 -0
- package/ts_build/src/plugins/types.js +3 -0
- package/ts_build/src/plugins/types.js.map +1 -0
- package/ts_build/src/plugins/url.d.ts +8 -0
- package/ts_build/src/plugins/url.js +50 -0
- package/ts_build/src/plugins/url.js.map +1 -0
- package/ts_build/src/plugins/vim.d.ts +11 -0
- package/ts_build/src/plugins/vim.js +63 -0
- package/ts_build/src/plugins/vim.js.map +1 -0
- package/ts_build/src/prompts/BasicCodeDocumenter.d.ts +2 -0
- package/ts_build/src/prompts/BasicCodeDocumenter.js +4 -0
- package/ts_build/src/prompts/BasicCodeDocumenter.js.map +1 -0
- package/ts_build/src/prompts/BasicProjectDocumenter.d.ts +2 -0
- package/ts_build/src/prompts/BasicProjectDocumenter.js +4 -0
- package/ts_build/src/prompts/BasicProjectDocumenter.js.map +1 -0
- package/ts_build/src/prompts/EmbeddingSeachHelper.d.ts +2 -0
- package/ts_build/src/prompts/EmbeddingSeachHelper.js +4 -0
- package/ts_build/src/prompts/EmbeddingSeachHelper.js.map +1 -0
- package/ts_build/src/prompts/index.d.ts +13 -0
- package/ts_build/src/prompts/index.js +15 -0
- package/ts_build/src/prompts/index.js.map +1 -0
- package/ts_build/src/server/index.d.ts +1 -0
- package/ts_build/src/server/index.js +17 -0
- package/ts_build/src/server/index.js.map +1 -0
- package/ts_build/src/services/AgentService.d.ts +14 -0
- package/ts_build/src/services/AgentService.js +87 -0
- package/ts_build/src/services/AgentService.js.map +1 -0
- package/ts_build/src/services/EmbeddingService.d.ts +39 -0
- package/ts_build/src/services/EmbeddingService.js +307 -0
- package/ts_build/src/services/EmbeddingService.js.map +1 -0
- package/ts_build/src/services/EventService.d.ts +9 -0
- package/ts_build/src/services/EventService.js +20 -0
- package/ts_build/src/services/EventService.js.map +1 -0
- package/ts_build/src/services/GitHub.d.ts +11 -0
- package/ts_build/src/services/GitHub.js +52 -0
- package/ts_build/src/services/GitHub.js.map +1 -0
- package/ts_build/src/services/KnowhowClient.d.ts +18 -0
- package/ts_build/src/services/KnowhowClient.js +85 -0
- package/ts_build/src/services/KnowhowClient.js.map +1 -0
- package/ts_build/src/services/Mcp.d.ts +377 -0
- package/ts_build/src/services/Mcp.js +221 -0
- package/ts_build/src/services/Mcp.js.map +1 -0
- package/ts_build/src/services/McpServer.d.ts +19 -0
- package/ts_build/src/services/McpServer.js +104 -0
- package/ts_build/src/services/McpServer.js.map +1 -0
- package/ts_build/src/services/McpWebsocketTransport.d.ts +13 -0
- package/ts_build/src/services/McpWebsocketTransport.js +59 -0
- package/ts_build/src/services/McpWebsocketTransport.js.map +1 -0
- package/ts_build/src/services/S3.d.ts +9 -0
- package/ts_build/src/services/S3.js +116 -0
- package/ts_build/src/services/S3.js.map +1 -0
- package/ts_build/src/services/Tools.d.ts +19 -0
- package/ts_build/src/services/Tools.js +51 -0
- package/ts_build/src/services/Tools.js.map +1 -0
- package/ts_build/src/services/flags.d.ts +13 -0
- package/ts_build/src/services/flags.js +48 -0
- package/ts_build/src/services/flags.js.map +1 -0
- package/ts_build/src/services/index.d.ts +8 -0
- package/ts_build/src/services/index.js +38 -0
- package/ts_build/src/services/index.js.map +1 -0
- package/ts_build/src/terminal.d.ts +1 -0
- package/ts_build/src/terminal.js +35 -0
- package/ts_build/src/terminal.js.map +1 -0
- package/ts_build/src/types.d.ts +181 -0
- package/ts_build/src/types.js +94 -0
- package/ts_build/src/types.js.map +1 -0
- package/ts_build/src/utils/index.d.ts +24 -0
- package/ts_build/src/utils/index.js +116 -0
- package/ts_build/src/utils/index.js.map +1 -0
- package/ts_build/src/worker.d.ts +1 -0
- package/ts_build/src/worker.js +68 -0
- package/ts_build/src/worker.js.map +1 -0
- package/ts_build/tests/integration/figma.test.d.ts +1 -0
- package/ts_build/tests/integration/figma.test.js +47 -0
- package/ts_build/tests/integration/figma.test.js.map +1 -0
- package/ts_build/tests/integration/fileblocks/readwrite.test.d.ts +1 -0
- package/ts_build/tests/integration/fileblocks/readwrite.test.js +95 -0
- package/ts_build/tests/integration/fileblocks/readwrite.test.js.map +1 -0
- package/ts_build/tests/integration/patching.test.d.ts +1 -0
- package/ts_build/tests/integration/patching.test.js +117 -0
- package/ts_build/tests/integration/patching.test.js.map +1 -0
- package/ts_build/tests/languagePlugin.test.d.ts +1 -0
- package/ts_build/tests/languagePlugin.test.js +78 -0
- package/ts_build/tests/languagePlugin.test.js.map +1 -0
- package/ts_build/tests/patching/corrupted.test.d.ts +1 -0
- package/ts_build/tests/patching/corrupted.test.js +53 -0
- package/ts_build/tests/patching/corrupted.test.js.map +1 -0
- package/ts_build/tests/patching/imports.test.d.ts +1 -0
- package/ts_build/tests/patching/imports.test.js +61 -0
- package/ts_build/tests/patching/imports.test.js.map +1 -0
- package/ts_build/tests/test.spec.d.ts +1 -0
- package/ts_build/tests/test.spec.js +101 -0
- package/ts_build/tests/test.spec.js.map +1 -0
- package/tsconfig.json +31 -0
- package/tslint.json +11 -0
package/src/config.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import gitignoreToGlob from "gitignore-to-glob";
|
|
5
|
+
import { Prompts } from "./prompts";
|
|
6
|
+
import { promisify } from "util";
|
|
7
|
+
import { Config, Language, AssistantConfig, Models } from "./types";
|
|
8
|
+
import { mkdir, writeFile, readFile, fileExists } from "./utils";
|
|
9
|
+
|
|
10
|
+
const defaultConfig = {
|
|
11
|
+
promptsDir: ".knowhow/prompts",
|
|
12
|
+
modules: [],
|
|
13
|
+
plugins: [
|
|
14
|
+
"embeddings",
|
|
15
|
+
"language",
|
|
16
|
+
"vim",
|
|
17
|
+
"github",
|
|
18
|
+
"asana",
|
|
19
|
+
"jira",
|
|
20
|
+
"linear",
|
|
21
|
+
"download",
|
|
22
|
+
"figma",
|
|
23
|
+
"url",
|
|
24
|
+
],
|
|
25
|
+
lintCommands: {
|
|
26
|
+
js: "eslint",
|
|
27
|
+
ts: "tslint",
|
|
28
|
+
},
|
|
29
|
+
sources: [
|
|
30
|
+
{
|
|
31
|
+
input: "src/**/*.mdx",
|
|
32
|
+
output: ".knowhow/docs/",
|
|
33
|
+
prompt: "BasicCodeDocumenter",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
input: ".knowhow/docs/**/*.mdx",
|
|
37
|
+
output: ".knowhow/docs/README.mdx",
|
|
38
|
+
prompt: "BasicProjectDocumenter",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
embedSources: [
|
|
42
|
+
{
|
|
43
|
+
input: ".knowhow/docs/**/*.mdx",
|
|
44
|
+
output: ".knowhow/embeddings/docs.json",
|
|
45
|
+
prompt: "BasicEmbeddingExplainer",
|
|
46
|
+
chunkSize: 2000,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
embeddingModel: Models.openai.EmbeddingAda2,
|
|
50
|
+
|
|
51
|
+
agents: [
|
|
52
|
+
{
|
|
53
|
+
name: "Example agent",
|
|
54
|
+
description:
|
|
55
|
+
"You can define agents in the config. They will have access to all tools.",
|
|
56
|
+
instructions: "Reply to the user saying 'Hello, world!'",
|
|
57
|
+
model: "gpt-4o-2024-08-06",
|
|
58
|
+
provider: "openai",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
mcps: [
|
|
62
|
+
{
|
|
63
|
+
name: "browser",
|
|
64
|
+
command: "npx",
|
|
65
|
+
args: ["-y", "@playwright/mcp@latest", "--browser", "chrome"],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
modelProviders: [{ url: "http://localhost:1234", provider: "lms" }],
|
|
70
|
+
} as Config;
|
|
71
|
+
|
|
72
|
+
const defaultLanguage = {
|
|
73
|
+
"knowhow config": {
|
|
74
|
+
sources: [
|
|
75
|
+
{
|
|
76
|
+
kind: "file",
|
|
77
|
+
data: [".knowhow/knowhow.json"],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
} as Language;
|
|
82
|
+
|
|
83
|
+
const globalTemplateFolders = ["prompts", "docs", "embeddings"];
|
|
84
|
+
const globalTemplateFiles = {
|
|
85
|
+
"knowhow.json": JSON.stringify(defaultConfig, null, 2),
|
|
86
|
+
"language.json": JSON.stringify(defaultLanguage, null, 2),
|
|
87
|
+
".ignore": "",
|
|
88
|
+
".hashes.json": "{}",
|
|
89
|
+
".jwt": "",
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
for (const prompt of Prompts) {
|
|
93
|
+
const promptName = Object.keys(prompt)[0];
|
|
94
|
+
const fileName = "prompts/" + promptName + ".mdx";
|
|
95
|
+
globalTemplateFiles[fileName] = prompt[promptName];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getGlobalConfigDir() {
|
|
99
|
+
return path.join(os.homedir(), ".knowhow");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function ensureGlobalConfigDir() {
|
|
103
|
+
const globalConfigDir = getGlobalConfigDir();
|
|
104
|
+
await mkdir(globalConfigDir, { recursive: true });
|
|
105
|
+
|
|
106
|
+
for (const folder of globalTemplateFolders) {
|
|
107
|
+
const folderPath = path.join(globalConfigDir, folder);
|
|
108
|
+
await mkdir(folderPath, { recursive: true });
|
|
109
|
+
fs.chmodSync(folderPath, 0o600);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
for (const file of Object.keys(globalTemplateFiles)) {
|
|
113
|
+
const filePath = path.join(globalConfigDir, file);
|
|
114
|
+
if (!fs.existsSync(filePath)) {
|
|
115
|
+
await writeFile(filePath, globalTemplateFiles[file]);
|
|
116
|
+
fs.chmodSync(filePath, 0o600);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return globalConfigDir;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export async function init() {
|
|
123
|
+
const globalConfigDir = await ensureGlobalConfigDir();
|
|
124
|
+
|
|
125
|
+
// create the folder structure
|
|
126
|
+
await mkdir(".knowhow", { recursive: true });
|
|
127
|
+
for (const folder of globalTemplateFolders) {
|
|
128
|
+
await mkdir(path.join(".knowhow", folder), { recursive: true });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Copy the template prompts
|
|
132
|
+
await copyTemplates(globalConfigDir);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function getLanguageConfig() {
|
|
136
|
+
const language = JSON.parse(await readFile(".knowhow/language.json", "utf8"));
|
|
137
|
+
return language as Language;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export async function updateLanguageConfig(language: Language) {
|
|
141
|
+
await writeFile(".knowhow/language.json", JSON.stringify(language, null, 2));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function updateConfig(config: Config) {
|
|
145
|
+
await writeFile(".knowhow/knowhow.json", JSON.stringify(config, null, 2));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function copyTemplates(globalConfigDir: string) {
|
|
149
|
+
for (const folder of globalTemplateFolders) {
|
|
150
|
+
const src = path.join(globalConfigDir, folder);
|
|
151
|
+
const dest = path.join(".knowhow", folder);
|
|
152
|
+
// Copy all the template folders, skipping files that already exist
|
|
153
|
+
await fs.promises.cp(src, dest, {
|
|
154
|
+
recursive: true,
|
|
155
|
+
filter: (source, destination) => {
|
|
156
|
+
return fs.existsSync(dest) ? false : true;
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Copy the template files, skipping files that already exist
|
|
162
|
+
for (const file of Object.keys(globalTemplateFiles)) {
|
|
163
|
+
const src = path.join(globalConfigDir, file);
|
|
164
|
+
const dest = path.join(".knowhow", file);
|
|
165
|
+
if (!fs.existsSync(dest)) {
|
|
166
|
+
await fs.promises.copyFile(src, dest);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function getConfigSync() {
|
|
172
|
+
try {
|
|
173
|
+
const config = JSON.parse(
|
|
174
|
+
fs.readFileSync(".knowhow/knowhow.json", "utf8").toString()
|
|
175
|
+
);
|
|
176
|
+
return config as Config;
|
|
177
|
+
} catch (e) {
|
|
178
|
+
return {} as Config;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export async function getConfig() {
|
|
183
|
+
const config = JSON.parse(await readFile(".knowhow/knowhow.json", "utf8"));
|
|
184
|
+
return config as Config;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export async function loadPrompt(promptName: string) {
|
|
188
|
+
const config = await getConfig();
|
|
189
|
+
if (!promptName) {
|
|
190
|
+
return "";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const prompt = await readFile(
|
|
194
|
+
path.join(config.promptsDir, `${promptName}.mdx`),
|
|
195
|
+
"utf8"
|
|
196
|
+
);
|
|
197
|
+
return prompt;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export async function getIgnorePattern() {
|
|
201
|
+
const ignoreList = new Array<string>();
|
|
202
|
+
const gitIgnore = await fileExists(".gitignore");
|
|
203
|
+
if (gitIgnore) {
|
|
204
|
+
ignoreList.push(...gitignoreToGlob(".gitignore"));
|
|
205
|
+
}
|
|
206
|
+
const knowhowIgnore = await fileExists(".knowhow/.ignore");
|
|
207
|
+
if (knowhowIgnore) {
|
|
208
|
+
ignoreList.push(...gitignoreToGlob(".knowhow/.ignore"));
|
|
209
|
+
}
|
|
210
|
+
return ignoreList.map((pattern) => pattern.replace("!", "./"));
|
|
211
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import pdf from "pdf-parse";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { readFile, fileExists } from "./utils";
|
|
5
|
+
import { Downloader } from "./plugins/downloader/downloader";
|
|
6
|
+
|
|
7
|
+
export async function processAudio(
|
|
8
|
+
filePath: string,
|
|
9
|
+
reusePreviousTranscript = true,
|
|
10
|
+
chunkTime = 30
|
|
11
|
+
): Promise<string[]> {
|
|
12
|
+
const parsed = path.parse(filePath);
|
|
13
|
+
const outputPath = `${parsed.dir}/${parsed.name}/transcript.json`;
|
|
14
|
+
|
|
15
|
+
const exists = await fileExists(outputPath);
|
|
16
|
+
if (exists && reusePreviousTranscript) {
|
|
17
|
+
console.log(`Transcription ${outputPath} already exists, skipping`);
|
|
18
|
+
const fileContent = await readFile(outputPath, "utf8");
|
|
19
|
+
return outputPath.endsWith("txt") ? fileContent : JSON.parse(fileContent);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const chunks = await Downloader.chunk(
|
|
23
|
+
filePath,
|
|
24
|
+
parsed.dir,
|
|
25
|
+
chunkTime,
|
|
26
|
+
reusePreviousTranscript
|
|
27
|
+
);
|
|
28
|
+
const transcription = await Downloader.transcribeChunks(
|
|
29
|
+
chunks,
|
|
30
|
+
outputPath,
|
|
31
|
+
reusePreviousTranscript
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return transcription;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function convertAudioToText(
|
|
38
|
+
filePath: string,
|
|
39
|
+
reusePreviousTranscript = true,
|
|
40
|
+
chunkTime = 30
|
|
41
|
+
) {
|
|
42
|
+
const audios = await processAudio(
|
|
43
|
+
filePath,
|
|
44
|
+
reusePreviousTranscript,
|
|
45
|
+
chunkTime
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
let fullString = "";
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < audios.length; i++) {
|
|
51
|
+
const audio = audios[i];
|
|
52
|
+
fullString += `[${i * chunkTime}:${(i + 1) * chunkTime}s] ${audio}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return fullString;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function processVideo(
|
|
59
|
+
filePath: string,
|
|
60
|
+
reusePreviousTranscript = true,
|
|
61
|
+
chunkTime = 30
|
|
62
|
+
) {
|
|
63
|
+
const parsed = path.parse(filePath);
|
|
64
|
+
const outputPath = `${parsed.dir}/${parsed.name}/video.json`;
|
|
65
|
+
|
|
66
|
+
console.log("Processing audio...");
|
|
67
|
+
const transcriptions = await processAudio(
|
|
68
|
+
filePath,
|
|
69
|
+
reusePreviousTranscript,
|
|
70
|
+
chunkTime
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
console.log("Extracting keyframes...");
|
|
74
|
+
const videoAnalysis = await Downloader.extractKeyframes(
|
|
75
|
+
filePath,
|
|
76
|
+
outputPath,
|
|
77
|
+
chunkTime
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return videoAnalysis.map((frame, index) => {
|
|
81
|
+
return {
|
|
82
|
+
frame,
|
|
83
|
+
transcription: transcriptions[index],
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function convertVideoToText(
|
|
89
|
+
filePath: string,
|
|
90
|
+
reusePreviousTranscript = true,
|
|
91
|
+
chunkTime = 30
|
|
92
|
+
) {
|
|
93
|
+
const processed = await processVideo(
|
|
94
|
+
filePath,
|
|
95
|
+
reusePreviousTranscript,
|
|
96
|
+
chunkTime
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
let fullString = "";
|
|
100
|
+
|
|
101
|
+
for (let i = 0; i < processed.length; i++) {
|
|
102
|
+
const chunk = processed[i];
|
|
103
|
+
fullString += `
|
|
104
|
+
Chunk: (${i + 1}/ ${processed.length}):
|
|
105
|
+
Start Timestamp: [${i * chunkTime}s]
|
|
106
|
+
Visual: ${chunk.frame.description}
|
|
107
|
+
Audio: ${chunk.transcription}
|
|
108
|
+
End Timestamp: [${i * chunkTime}s]
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return fullString;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function convertPdfToText(filePath: string) {
|
|
116
|
+
const existingPdfBytes = fs.readFileSync(filePath);
|
|
117
|
+
const data = await pdf(existingPdfBytes);
|
|
118
|
+
return data.text;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function convertToText(filePath: string) {
|
|
122
|
+
const extension = filePath.split(".").pop();
|
|
123
|
+
|
|
124
|
+
switch (extension) {
|
|
125
|
+
case "mp4":
|
|
126
|
+
case "webm":
|
|
127
|
+
case "mov":
|
|
128
|
+
case "mpeg":
|
|
129
|
+
return convertVideoToText(filePath);
|
|
130
|
+
case "mp3":
|
|
131
|
+
case "mpga":
|
|
132
|
+
case "m4a":
|
|
133
|
+
case "wav":
|
|
134
|
+
return convertAudioToText(filePath);
|
|
135
|
+
case "pdf":
|
|
136
|
+
return convertPdfToText(filePath);
|
|
137
|
+
default:
|
|
138
|
+
return readFile(filePath, "utf8");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Goal
|
|
2
|
+
The purpose of this folder is to collect examples of file modifications to fine tune GPT
|
|
3
|
+
|
|
4
|
+
The dataset should be a JSON reprensentation of a chat thread, where the user has requested some modification to a file, and then a before file and after file contents, which will be fed into the createPatchFile function of the diff tool
|
|
5
|
+
|
|
6
|
+
The function that generates this structure should be generic so that you can fine tune using examples generated from any selected files in the codebase
|
|
7
|
+
|
|
8
|
+
## Procedure for generating dataset
|
|
9
|
+
- use glob to list out files that would be in the embeddings
|
|
10
|
+
- for each file, get the commit hash via git log --pretty=oneline -- filepath
|
|
11
|
+
- for each file diff the current text against a git show commit:filepath, so that we can generate a diff of all the previous changes
|
|
12
|
+
- summarize the diff with GPT and have it construct a synthetic user message that would be requesting it to modify the file in those ways
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "source-map-support/register";
|
|
2
|
+
|
|
3
|
+
import { parsePatch, diffLines, applyPatch } from "diff";
|
|
4
|
+
import { PatchingAgent } from "../../agents/patcher/patcher";
|
|
5
|
+
import { ask, writeFile, mkdir, readFile } from "../../utils";
|
|
6
|
+
import { fixPatch, parseHunks } from "../../agents/tools/patch";
|
|
7
|
+
|
|
8
|
+
async function debugFailure() {
|
|
9
|
+
const errors = [];
|
|
10
|
+
for (const data of errors) {
|
|
11
|
+
try {
|
|
12
|
+
const { fileContent, fixedPatch, originalPatch } = data;
|
|
13
|
+
const newFixedPatch = fixPatch(fileContent, originalPatch);
|
|
14
|
+
console.log({ originalPatch, newFixedPatch });
|
|
15
|
+
const updatedContent = applyPatch(fileContent, newFixedPatch);
|
|
16
|
+
console.log("DID PATCH APPLY?", !!updatedContent);
|
|
17
|
+
|
|
18
|
+
await ask("See output? ");
|
|
19
|
+
console.log(updatedContent);
|
|
20
|
+
await ask("Continue? ");
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.log(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (require.main === module) {
|
|
28
|
+
debugFailure();
|
|
29
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import "source-map-support/register";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ChatCompletionMessageParam,
|
|
5
|
+
ChatCompletionToolMessageParam,
|
|
6
|
+
ChatCompletionMessageToolCall,
|
|
7
|
+
} from "openai/resources/chat";
|
|
8
|
+
import { parsePatch, diffLines, applyPatch } from "diff";
|
|
9
|
+
import { PatchingAgent } from "../../agents/patcher/patcher";
|
|
10
|
+
import { ask, writeFile, mkdir, readFile } from "../../utils";
|
|
11
|
+
import { fixPatch, parseHunks } from "../../agents/tools/patch";
|
|
12
|
+
import { md5Hash } from "../../hashes";
|
|
13
|
+
|
|
14
|
+
async function debugFailure() {
|
|
15
|
+
const successCount = 0;
|
|
16
|
+
const attempts = 0;
|
|
17
|
+
const testHash = "40eda1dc8f1e3052997f2930ae59fed2";
|
|
18
|
+
const dataset = [];
|
|
19
|
+
|
|
20
|
+
let patchData;
|
|
21
|
+
for (const data of dataset) {
|
|
22
|
+
if ((await md5Hash(data.patch)) === testHash) {
|
|
23
|
+
patchData = data;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (patchData) {
|
|
29
|
+
const originalContent = patchData.before;
|
|
30
|
+
const dirName = `./src/dataset/diffs/test_files/fail/${testHash}`;
|
|
31
|
+
const patch = await readFile(`${dirName}/ai-patch.diff`, "utf-8");
|
|
32
|
+
const fixedPatch = fixPatch(patchData.before, patch);
|
|
33
|
+
await writeFile(`${dirName}/ai-fixed-patch.diff`, fixedPatch);
|
|
34
|
+
|
|
35
|
+
const updatedContent = applyPatch(originalContent, fixedPatch);
|
|
36
|
+
console.log({ updatedContent });
|
|
37
|
+
const success = !!updatedContent;
|
|
38
|
+
|
|
39
|
+
if (updatedContent === patchData.after || fixedPatch === patchData.patch) {
|
|
40
|
+
console.log("SUCCESS");
|
|
41
|
+
console.log("EXACT MATCH");
|
|
42
|
+
} else {
|
|
43
|
+
console.log("AI SUGGESTED");
|
|
44
|
+
console.log(patch);
|
|
45
|
+
|
|
46
|
+
console.log("FIXED PATCH");
|
|
47
|
+
console.log(fixedPatch);
|
|
48
|
+
|
|
49
|
+
console.log("ACTUAL");
|
|
50
|
+
console.log(patchData.patch);
|
|
51
|
+
|
|
52
|
+
console.log("DID PATCH APPLY?", !!updatedContent);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const parsedAnswer = parsePatch(patchData.patch);
|
|
57
|
+
const fileName = parsedAnswer[0].oldFileName;
|
|
58
|
+
|
|
59
|
+
console.log({ successCount, attempts, total: dataset.length });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (require.main === module) {
|
|
63
|
+
debugFailure();
|
|
64
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "source-map-support/register";
|
|
2
|
+
import * as glob from "glob";
|
|
3
|
+
import { createPatch } from "diff";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import { execAsync } from "../../utils";
|
|
6
|
+
import { summarizeTexts } from "../../ai";
|
|
7
|
+
|
|
8
|
+
async function generateDataset() {
|
|
9
|
+
// Define the path pattern for files to include in the embeddings
|
|
10
|
+
const files = glob.sync("./**/*.ts", {
|
|
11
|
+
ignore: ["./node_modules/**", "./dist/**", "./.git/**"],
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const dataset = [];
|
|
15
|
+
|
|
16
|
+
for (const filePath of files) {
|
|
17
|
+
// Get the most recent commit hash for the file
|
|
18
|
+
const commandOutput = await execAsync(
|
|
19
|
+
`git log --pretty=oneline -- ${filePath}`
|
|
20
|
+
);
|
|
21
|
+
const commitHashes = commandOutput.stdout.split("\n");
|
|
22
|
+
for (const commitHash of commitHashes) {
|
|
23
|
+
const firstSpaceIndex = commitHash.indexOf(" ");
|
|
24
|
+
const hash = commitHash.slice(0, firstSpaceIndex);
|
|
25
|
+
if (hash === "") {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// Get the diff between the current file and its state at the commit
|
|
29
|
+
const { stdout: previousFileContent } = await execAsync(
|
|
30
|
+
`git show ${hash}:${filePath}`
|
|
31
|
+
);
|
|
32
|
+
const currentFileContent = fs.readFileSync(filePath, "utf-8");
|
|
33
|
+
|
|
34
|
+
// Create a patch/diff of the before and after
|
|
35
|
+
const patch = createPatch(
|
|
36
|
+
filePath,
|
|
37
|
+
previousFileContent,
|
|
38
|
+
currentFileContent
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (patch.split("\n").length < 10) {
|
|
42
|
+
console.log(`Skipping ${filePath} as the diff is too small`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(filePath);
|
|
47
|
+
console.log(patch);
|
|
48
|
+
|
|
49
|
+
dataset.push({
|
|
50
|
+
before: previousFileContent,
|
|
51
|
+
after: currentFileContent,
|
|
52
|
+
patch,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
fs.writeFileSync(
|
|
56
|
+
"./src/dataset/diffs/dataset.json",
|
|
57
|
+
JSON.stringify(dataset, null, 2)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if (dataset.length > 200) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log(`Dataset of ${dataset.length} examples generated`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (require.main === module) {
|
|
70
|
+
generateDataset();
|
|
71
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "source-map-support/register";
|
|
2
|
+
import * as glob from "glob";
|
|
3
|
+
import { createPatch } from "diff";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import { execAsync, readFile, writeFile } from "../../utils";
|
|
6
|
+
import { summarizeTexts } from "../../ai";
|
|
7
|
+
|
|
8
|
+
async function generateDataset() {
|
|
9
|
+
const datasetFile = await readFile(__dirname + "/dataset.json");
|
|
10
|
+
const dataset = JSON.parse(datasetFile.toString());
|
|
11
|
+
|
|
12
|
+
// convert to jsonl
|
|
13
|
+
function toMessage(d) {
|
|
14
|
+
const { userMessage, before, patch } = d;
|
|
15
|
+
const fileName = patch.split(" ")[1].split("\n")[0];
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
messages: [
|
|
19
|
+
{
|
|
20
|
+
role: "system",
|
|
21
|
+
content:
|
|
22
|
+
"Codebase Agent. You use the tools to read and write code, to help the developer implement features faster. Call final answer once you have finished implementing what is requested. As an agent you will receive multiple rounds of input until you call final answer. You are not able to request feedback from the user, so proceed with your plans and the developer will contact you afterwards if they need more help. After modifying files, you will read them to ensure they look correct before calling final answer. You always check your modifications for syntax errors or bugs. You always make the smallest modifications required to files, rather than outputting the entire file. You think step by step about the blocks of code you're modiyfing",
|
|
23
|
+
},
|
|
24
|
+
{ role: "user", content: userMessage },
|
|
25
|
+
{
|
|
26
|
+
role: "assistant",
|
|
27
|
+
function_call: {
|
|
28
|
+
name: "readFile",
|
|
29
|
+
arguments: JSON.stringify({
|
|
30
|
+
fileName,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
role: "assistant",
|
|
36
|
+
function_call: {
|
|
37
|
+
name: "applyPatchFile",
|
|
38
|
+
arguments: JSON.stringify({
|
|
39
|
+
fileName,
|
|
40
|
+
patch,
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const jsonl = dataset.map((d) => JSON.stringify(toMessage(d))).join("\n");
|
|
48
|
+
await writeFile(__dirname + "/dataset.jsonl", jsonl);
|
|
49
|
+
console.log(dataset);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (require.main === module) {
|
|
53
|
+
generateDataset();
|
|
54
|
+
}
|