@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
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/rest";
|
|
2
|
+
import { Plugin } from "./types";
|
|
3
|
+
import { parseHunks, hunksToPatch } from "../agents/tools/patch";
|
|
4
|
+
import { MinimalEmbedding } from "../types";
|
|
5
|
+
|
|
6
|
+
export class GitHubPlugin implements Plugin {
|
|
7
|
+
octokit: Octokit;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
this.octokit = new Octokit({
|
|
11
|
+
auth: process.env.GITHUB_TOKEN,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async embed(userPrompt: string): Promise<MinimalEmbedding[]> {
|
|
16
|
+
const urls = this.extractUrls(userPrompt);
|
|
17
|
+
const diffs = await this.getParsedDiffs(urls);
|
|
18
|
+
const diffsFiltered = diffs.filter((diff) => diff !== null);
|
|
19
|
+
|
|
20
|
+
return diffsFiltered.map((diff, index) => {
|
|
21
|
+
return {
|
|
22
|
+
id: urls[index],
|
|
23
|
+
text: JSON.stringify(diff),
|
|
24
|
+
metadata: {},
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
extractUrls(userPrompt: string): string[] {
|
|
30
|
+
const prUrlRegex =
|
|
31
|
+
/https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/pull\/(\d+)/g;
|
|
32
|
+
const matches = userPrompt.match(prUrlRegex);
|
|
33
|
+
return matches;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
parseUrl(url: string) {
|
|
37
|
+
const [owner, repo, _, pullNumber] = url.split("/").slice(-4);
|
|
38
|
+
return {
|
|
39
|
+
owner,
|
|
40
|
+
repo,
|
|
41
|
+
pullNumber,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async getDiff(url: string) {
|
|
46
|
+
const { owner, repo, pullNumber } = this.parseUrl(url);
|
|
47
|
+
console.log(
|
|
48
|
+
`GITHUB PLUGIN: Loading diff for ${owner}/${repo}#${pullNumber}`
|
|
49
|
+
);
|
|
50
|
+
const { data: diff } = await this.octokit.rest.pulls.get({
|
|
51
|
+
owner,
|
|
52
|
+
repo,
|
|
53
|
+
pull_number: parseInt(pullNumber, 10),
|
|
54
|
+
mediaType: {
|
|
55
|
+
format: "diff",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return diff;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getPR(url: string) {
|
|
63
|
+
const { owner, repo, pullNumber } = this.parseUrl(url);
|
|
64
|
+
return this.octokit.rest.pulls.get({
|
|
65
|
+
owner,
|
|
66
|
+
repo,
|
|
67
|
+
pull_number: parseInt(pullNumber, 10),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getLengthOfHunks(hunks: ReturnType<typeof parseHunks>) {
|
|
72
|
+
const length = hunks
|
|
73
|
+
.flatMap((hunk) => [...hunk.additions, ...hunk.subtractions])
|
|
74
|
+
.reduce((acc, line) => acc + line.length, 0);
|
|
75
|
+
console.log(`GITHUB PLUGIN: Length of hunks: ${length}`);
|
|
76
|
+
return length;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getParsedDiffs(urls: string[]) {
|
|
80
|
+
return Promise.all(
|
|
81
|
+
urls.map(async (url) => {
|
|
82
|
+
const diff = await this.getDiff(url);
|
|
83
|
+
let parsed = parseHunks(diff.toString());
|
|
84
|
+
|
|
85
|
+
console.log(`GITHUB PLUGIN: Parsed ${parsed.length} hunks`);
|
|
86
|
+
|
|
87
|
+
const averageHunkSize =
|
|
88
|
+
parsed.reduce((acc, hunk) => acc + hunk.lines.length, 0) /
|
|
89
|
+
parsed.length;
|
|
90
|
+
|
|
91
|
+
const totalCharacters = parsed
|
|
92
|
+
.flatMap((hunk) => [...hunk.additions, ...hunk.subtractions])
|
|
93
|
+
.reduce((acc, line) => acc + line.length, 0);
|
|
94
|
+
|
|
95
|
+
console.log(
|
|
96
|
+
`GITHUB PLUGIN: Average hunk size: ${averageHunkSize}, total characters: ${totalCharacters}`
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const MAX_CHARACTERS = 10000;
|
|
100
|
+
const average = MAX_CHARACTERS / averageHunkSize;
|
|
101
|
+
const PER_HUNK_LIMIT = Math.max(average, 2000);
|
|
102
|
+
|
|
103
|
+
parsed = parsed.filter((hunk) => {
|
|
104
|
+
return this.getLengthOfHunks([hunk]) <= PER_HUNK_LIMIT;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
console.log(
|
|
108
|
+
`GITHUB PLUGIN: Filtered to ${
|
|
109
|
+
parsed.length
|
|
110
|
+
} hunks. ${this.getLengthOfHunks(parsed)} characters`
|
|
111
|
+
);
|
|
112
|
+
return parsed;
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
formatDiff(diff: any) {
|
|
118
|
+
return diff;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async call(userPrompt: string): Promise<string> {
|
|
122
|
+
const urls = this.extractUrls(userPrompt);
|
|
123
|
+
|
|
124
|
+
if (urls) {
|
|
125
|
+
const prs = [];
|
|
126
|
+
for (const url of urls) {
|
|
127
|
+
const { owner, repo, pullNumber } = this.parseUrl(url);
|
|
128
|
+
const { data: pr } = await this.getPR(url);
|
|
129
|
+
const responses = await this.getParsedDiffs(urls);
|
|
130
|
+
// Format the diffs in Markdown
|
|
131
|
+
const diffStrings = responses.map(hunksToPatch);
|
|
132
|
+
|
|
133
|
+
prs.push({
|
|
134
|
+
description: pr.title,
|
|
135
|
+
url: pr.html_url,
|
|
136
|
+
body: pr.body,
|
|
137
|
+
author: pr.user.login,
|
|
138
|
+
diff: diffStrings,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const context = `GITHUB PLUGIN: These ${urls} have automatically been expanded to include the changes:\n\n${JSON.stringify(
|
|
143
|
+
prs,
|
|
144
|
+
null,
|
|
145
|
+
2
|
|
146
|
+
)}`;
|
|
147
|
+
console.log(context);
|
|
148
|
+
return context;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return "GITHUB PLUGIN: No pull request URLs detected.";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import JiraClient from "jira-client";
|
|
2
|
+
import { Plugin } from "./types";
|
|
3
|
+
import { MinimalEmbedding } from "../types";
|
|
4
|
+
|
|
5
|
+
export class JiraPlugin implements Plugin {
|
|
6
|
+
jiraClient: JiraClient;
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.jiraClient = new JiraClient({
|
|
10
|
+
protocol: "https",
|
|
11
|
+
host: process.env.JIRA_HOST,
|
|
12
|
+
username: process.env.JIRA_USER,
|
|
13
|
+
password: process.env.JIRA_PASSWORD,
|
|
14
|
+
apiVersion: "2",
|
|
15
|
+
strictSSL: true,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async embed(userPrompt: string): Promise<MinimalEmbedding[]> {
|
|
20
|
+
const urls = this.extractUrls(userPrompt);
|
|
21
|
+
const tasks = await this.getTasksFromUrls(urls);
|
|
22
|
+
const tasksFiltered = tasks.filter((task) => task !== null);
|
|
23
|
+
|
|
24
|
+
return tasksFiltered.map((task, index) => {
|
|
25
|
+
return {
|
|
26
|
+
id: urls[index],
|
|
27
|
+
text: JSON.stringify(task),
|
|
28
|
+
metadata: {},
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async getTasksFromUrls(urls: string[]) {
|
|
34
|
+
const tasks = await Promise.all(
|
|
35
|
+
urls.map(async (url) => {
|
|
36
|
+
return this.getTaskFromUrl(url);
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
return tasks;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async getTaskFromUrl(url: string) {
|
|
43
|
+
const issueId = this.extractIdFromUrl(url);
|
|
44
|
+
if (issueId) {
|
|
45
|
+
console.log(`Fetching Jira issue ${issueId}`);
|
|
46
|
+
return await this.getIssueData(issueId);
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async getIssueData(issueId: string) {
|
|
52
|
+
try {
|
|
53
|
+
const issue = await this.jiraClient.findIssue(issueId);
|
|
54
|
+
return issue;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("Error fetching Jira issue:", error);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// https://${process.env.JIRA_HOST}/browse/${issue.key}
|
|
62
|
+
extractUrls(userPrompt: string): string[] {
|
|
63
|
+
const host = process.env.JIRA_HOST;
|
|
64
|
+
const regex = new RegExp(`https://${host}/browse/[A-Z]+-\\d+`, "g");
|
|
65
|
+
const matches = userPrompt.match(regex);
|
|
66
|
+
if (!matches) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
return matches;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
extractIdFromUrl(url: string): string {
|
|
73
|
+
const host = process.env.JIRA_HOST;
|
|
74
|
+
const regex = new RegExp(`https://${host}/browse/([A-Z]+-\\d+)`, "g");
|
|
75
|
+
const matches = regex.exec(url);
|
|
76
|
+
if (matches && matches[1]) {
|
|
77
|
+
return matches[1];
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getTaskString(task: any) {
|
|
83
|
+
return `### Issue: ${task.key}\n- Summary: ${task.fields.summary}\n- URL: ${process.env.JIRA_HOST}/browse/${task.key} \n- Description: ${task.fields.description}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async call(userPrompt: string): Promise<string> {
|
|
87
|
+
const urls = this.extractUrls(userPrompt);
|
|
88
|
+
if (!urls) {
|
|
89
|
+
return "JIRA PLUGIN: No issues found";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const issuesData = await this.getTasksFromUrls(urls);
|
|
93
|
+
const issuesDataFiltered = issuesData.filter((issue) => issue !== null);
|
|
94
|
+
|
|
95
|
+
if (issuesDataFiltered.length === 0) {
|
|
96
|
+
return "JIRA PLUGIN: No issues found";
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const markdownIssues = issuesDataFiltered
|
|
100
|
+
.map((issue) => this.getTaskString(issue))
|
|
101
|
+
.join("\n\n");
|
|
102
|
+
return `JIRA PLUGIN: The following issues were loaded:\n\n${markdownIssues}`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { readFile, fileExists, fileStat } from "../utils";
|
|
2
|
+
import { Language } from "../types";
|
|
3
|
+
import { getConfig, getLanguageConfig } from "../config";
|
|
4
|
+
import { Plugin } from "./types";
|
|
5
|
+
import { GitHubPlugin } from "./github";
|
|
6
|
+
import { AsanaPlugin } from "./asana";
|
|
7
|
+
import { JiraPlugin } from "./jira";
|
|
8
|
+
import { LinearPlugin } from "./linear";
|
|
9
|
+
import { PluginService } from "./plugins";
|
|
10
|
+
|
|
11
|
+
export class LanguagePlugin implements Plugin {
|
|
12
|
+
constructor(private pluginService: PluginService) {}
|
|
13
|
+
|
|
14
|
+
async embed(userPrompt: string) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async call(userPrompt: string): Promise<string> {
|
|
19
|
+
const config = await getConfig();
|
|
20
|
+
const languageConfig = await getLanguageConfig();
|
|
21
|
+
// Extract terms from the language configuration
|
|
22
|
+
const terms = Object.keys(languageConfig);
|
|
23
|
+
|
|
24
|
+
// Find all matching terms in the userPrompt
|
|
25
|
+
const matchingTerms = terms.filter((term) =>
|
|
26
|
+
term
|
|
27
|
+
.split(",")
|
|
28
|
+
.some((w) => userPrompt.toLowerCase().includes(w.toLowerCase()))
|
|
29
|
+
);
|
|
30
|
+
if (matchingTerms.length > 0) {
|
|
31
|
+
console.log("LANGUAGE PLUGIN: Found matching terms", matchingTerms);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const sources = matchingTerms.flatMap(
|
|
35
|
+
(term) => languageConfig[term].sources
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const contexts = [];
|
|
39
|
+
|
|
40
|
+
// Load the files for the matching terms
|
|
41
|
+
const filesToLoad = sources
|
|
42
|
+
.filter((f) => f.kind === "file")
|
|
43
|
+
.map((f) => f.data)
|
|
44
|
+
.flat();
|
|
45
|
+
|
|
46
|
+
// Read the contents of the files
|
|
47
|
+
const fileContents = await Promise.all(
|
|
48
|
+
filesToLoad.map(async (filePath) => {
|
|
49
|
+
const exists = await fileExists(filePath);
|
|
50
|
+
if (!exists) {
|
|
51
|
+
return { filePath, content: `File ${filePath} does not exist` };
|
|
52
|
+
}
|
|
53
|
+
const content = (await readFile(filePath, "utf8")).toString();
|
|
54
|
+
console.log("LANGUAGE PLUGIN: Read file", filePath);
|
|
55
|
+
return { filePath, content };
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
contexts.push(...fileContents);
|
|
59
|
+
|
|
60
|
+
const textContexts = matchingTerms
|
|
61
|
+
.flatMap((term) =>
|
|
62
|
+
languageConfig[term].sources.filter((s) => s.kind === "text")
|
|
63
|
+
)
|
|
64
|
+
.map((s) => s.data);
|
|
65
|
+
contexts.push(...textContexts);
|
|
66
|
+
|
|
67
|
+
const plugins = this.pluginService.listPlugins();
|
|
68
|
+
for (const plugin of plugins) {
|
|
69
|
+
if (config.plugins.includes(plugin)) {
|
|
70
|
+
const matchingSources = sources.filter((s) => s.kind === plugin);
|
|
71
|
+
if (matchingSources.length === 0) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const data = matchingSources
|
|
76
|
+
.map((s) => s.data)
|
|
77
|
+
.flat()
|
|
78
|
+
.join("\n");
|
|
79
|
+
console.log("LANGUAGE PLUGIN: Calling plugin", plugin, data);
|
|
80
|
+
const pluginContext = await this.pluginService.call(plugin, data);
|
|
81
|
+
|
|
82
|
+
contexts.push(...pluginContext);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!matchingTerms || !matchingTerms.length) {
|
|
87
|
+
return "LANGUAGE PLUGIN: No matching terms found";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Return the file contents in a format that can be added to the prompt context
|
|
91
|
+
return `LANGUAGE PLUGIN: The user mentioned these terms triggering contextual expansions ${matchingTerms} expanded to: ${JSON.stringify(
|
|
92
|
+
contexts
|
|
93
|
+
)}
|
|
94
|
+
These terms are directly related to what the user is asking about so be sure to contextualize your response to this information.
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Since this uses other plugins, it needs to be registered
|
|
100
|
+
// Plugins.registerPlugin("language", new LanguagePlugin());
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { LinearClient } from "@linear/sdk";
|
|
2
|
+
import { Plugin } from "./types";
|
|
3
|
+
import { MinimalEmbedding } from "../types";
|
|
4
|
+
|
|
5
|
+
export class LinearPlugin implements Plugin {
|
|
6
|
+
linearClient: LinearClient;
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.linearClient = new LinearClient({
|
|
10
|
+
apiKey: process.env.LINEAR_API_KEY,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async embed(userPrompt: string): Promise<MinimalEmbedding[]> {
|
|
15
|
+
const urls = this.extractTaskUrls(userPrompt);
|
|
16
|
+
const tasksData = await this.getTasksFromUrls(urls);
|
|
17
|
+
const tasksDataFiltered = tasksData.filter((task) => task !== null);
|
|
18
|
+
|
|
19
|
+
const tasksEmbeddings = tasksDataFiltered.map((task) => {
|
|
20
|
+
return {
|
|
21
|
+
id: task.url,
|
|
22
|
+
text: this.getTaskString(task),
|
|
23
|
+
metadata: {
|
|
24
|
+
task: JSON.stringify(task),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const projectUrls = this.extractProjectUrls(userPrompt);
|
|
30
|
+
const projectTasks = await this.getTasksFromProjectUrls(projectUrls);
|
|
31
|
+
const projectTasksFiltered = projectTasks.filter((t) => t !== null);
|
|
32
|
+
|
|
33
|
+
const projectTaskEmbeddings = projectTasksFiltered
|
|
34
|
+
.map((t) => {
|
|
35
|
+
return {
|
|
36
|
+
id: t.url,
|
|
37
|
+
text: this.getTaskString(t),
|
|
38
|
+
metadata: {
|
|
39
|
+
task: JSON.stringify(t),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
})
|
|
43
|
+
.flat();
|
|
44
|
+
|
|
45
|
+
const teamUrls = this.extractTeamUrls(userPrompt);
|
|
46
|
+
const teamTasks = await this.getTasksFromTeamUrls(teamUrls);
|
|
47
|
+
const teamTasksFiltered = teamTasks.filter((t) => t !== null);
|
|
48
|
+
|
|
49
|
+
const teamTaskEmbeddings = teamTasksFiltered
|
|
50
|
+
.map((t) => {
|
|
51
|
+
return {
|
|
52
|
+
id: t.url,
|
|
53
|
+
text: this.getTaskString(t),
|
|
54
|
+
metadata: {
|
|
55
|
+
task: JSON.stringify(t),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
})
|
|
59
|
+
.flat();
|
|
60
|
+
|
|
61
|
+
return tasksEmbeddings
|
|
62
|
+
.concat(projectTaskEmbeddings)
|
|
63
|
+
.concat(teamTaskEmbeddings);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async getIssueData(issueId: string) {
|
|
67
|
+
try {
|
|
68
|
+
const issue = await this.linearClient.issue(issueId);
|
|
69
|
+
return issue;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("Error fetching Linear issue:", error);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async getTaskFromUrl(url: string) {
|
|
77
|
+
const issueId = this.getIdFromUrl(url);
|
|
78
|
+
if (issueId) {
|
|
79
|
+
console.log(`Fetching Linear issue ${issueId}`);
|
|
80
|
+
return await this.getIssueData(issueId);
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async getTasksFromUrls(urls: string[]) {
|
|
86
|
+
const tasks = await Promise.all(
|
|
87
|
+
urls.map(async (url) => {
|
|
88
|
+
return this.getTaskFromUrl(url);
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
return tasks;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
extractTeamUrls(userPrompt: string): string[] {
|
|
95
|
+
const urlRegex = /https:\/\/linear\.app\/[^\/]+\/team\/[^\/]+\/[^\/]+/g;
|
|
96
|
+
const matches = userPrompt.match(urlRegex);
|
|
97
|
+
return matches || [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getTeamIdFromUrl(url: string): string {
|
|
101
|
+
const urlRegex = /https:\/\/linear\.app\/[^\/]+\/team\/([^\/]+)\/[^\/]+/g;
|
|
102
|
+
const match = urlRegex.exec(url);
|
|
103
|
+
if (match && match[1]) {
|
|
104
|
+
return match[1];
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
extractProjectUrls(userPrompt: string): string[] {
|
|
110
|
+
const urlRegex = /https:\/\/linear\.app\/[^\/]+\/project\/[^\/]+\/[^\/]+/g;
|
|
111
|
+
const matches = userPrompt.match(urlRegex);
|
|
112
|
+
return matches || [];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getProjectIdFromUrl(url: string): string {
|
|
116
|
+
const urlRegex =
|
|
117
|
+
/https:\/\/linear\.app\/[^\/]+\/project\/([^\/]+)\/[^\/]+/g;
|
|
118
|
+
const match = urlRegex.exec(url);
|
|
119
|
+
if (match && match[1]) {
|
|
120
|
+
const parts = match[1].split("-");
|
|
121
|
+
return parts[parts.length - 1];
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async getTasksForProject(projectId: string) {
|
|
127
|
+
console.log({ projectId });
|
|
128
|
+
let tasks = await this.linearClient.issues({
|
|
129
|
+
filter: {
|
|
130
|
+
project: { slugId: { eq: projectId } },
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
let allTasks = tasks.nodes;
|
|
134
|
+
|
|
135
|
+
while (tasks.pageInfo.hasNextPage) {
|
|
136
|
+
tasks = await tasks.fetchNext();
|
|
137
|
+
allTasks = allTasks.concat(tasks.nodes);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return allTasks;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async getTasksFromProjectUrls(urls: string[]) {
|
|
144
|
+
const tasks = await Promise.all(
|
|
145
|
+
urls.map(async (url) => {
|
|
146
|
+
return this.getTasksForProject(this.getProjectIdFromUrl(url));
|
|
147
|
+
})
|
|
148
|
+
);
|
|
149
|
+
return tasks.flat();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async getTasksForTeam(teamId: string) {
|
|
153
|
+
console.log({ teamId });
|
|
154
|
+
let tasks = await this.linearClient.issues({
|
|
155
|
+
filter: {
|
|
156
|
+
team: { key: { eq: teamId } },
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
let allTasks = tasks.nodes;
|
|
161
|
+
|
|
162
|
+
while (tasks.pageInfo.hasNextPage) {
|
|
163
|
+
tasks = await tasks.fetchNext();
|
|
164
|
+
allTasks = allTasks.concat(tasks.nodes);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return allTasks;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async getTasksFromTeamUrls(urls: string[]) {
|
|
171
|
+
const tasks = await Promise.all(
|
|
172
|
+
urls.map(async (url) => {
|
|
173
|
+
return this.getTasksForTeam(this.getTeamIdFromUrl(url));
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
return tasks.flat();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
extractTaskUrls(userPrompt: string): string[] {
|
|
180
|
+
const urlRegex = /https:\/\/linear\.app\/[^\/]+\/issue\/[^\/]+\/[^\/]+/g;
|
|
181
|
+
const matches = userPrompt.match(urlRegex);
|
|
182
|
+
if (!matches) {
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
return matches;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
getIdFromUrl(url: string): string {
|
|
189
|
+
const urlRegex = /https:\/\/linear\.app\/[^\/]+\/issue\/([^\/]+)\/[^\/]+/g;
|
|
190
|
+
const match = urlRegex.exec(url);
|
|
191
|
+
if (match && match[1]) {
|
|
192
|
+
return match[1];
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
getTaskString(task: any): string {
|
|
198
|
+
return `Issue: ${task.identifier}\nTitle: ${task.title}\nURL: ${task.url} \nDescription: ${task.description}`;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async call(userPrompt: string): Promise<string> {
|
|
202
|
+
const urls = this.extractTaskUrls(userPrompt);
|
|
203
|
+
if (!urls) {
|
|
204
|
+
return "LINEAR PLUGIN: No issues found";
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const issuesData = await this.getTasksFromUrls(urls);
|
|
208
|
+
const issuesDataFiltered = issuesData.filter((issue) => issue !== null);
|
|
209
|
+
|
|
210
|
+
if (issuesDataFiltered.length === 0) {
|
|
211
|
+
return "LINEAR PLUGIN: No issues found";
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const markdownIssues = issuesDataFiltered
|
|
215
|
+
.map((issue) => this.getTaskString(issue))
|
|
216
|
+
.join("\n\n");
|
|
217
|
+
return `LINEAR PLUGIN: The following issues were loaded:\n\n${markdownIssues}`;
|
|
218
|
+
}
|
|
219
|
+
}
|