@tyvm/knowhow 0.0.89 → 0.0.91

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.
Files changed (344) hide show
  1. package/.depcheckrc +31 -0
  2. package/CONFIG.md +52 -0
  3. package/README.md +344 -29
  4. package/WORKER.md +169 -334
  5. package/autodoc/chat-guide.md +540 -0
  6. package/autodoc/cli-reference.md +765 -0
  7. package/autodoc/config-reference.md +541 -0
  8. package/autodoc/embeddings-guide.md +566 -0
  9. package/autodoc/generate-guide.md +477 -0
  10. package/autodoc/language-plugin-guide.md +443 -0
  11. package/autodoc/modules-guide.md +352 -0
  12. package/autodoc/plugins-guide.md +720 -0
  13. package/autodoc/quickstart-guide.md +129 -0
  14. package/autodoc/skills-guide.md +468 -0
  15. package/autodoc/worker-guide.md +526 -0
  16. package/bin/knowhow.js +1 -1
  17. package/package.json +4 -32
  18. package/src/agents/tools/executeScript/index.ts +5 -0
  19. package/src/agents/tools/googleSearch.ts +2 -2
  20. package/src/agents/tools/index.ts +0 -3
  21. package/src/agents/tools/list.ts +0 -147
  22. package/src/agents/tools/loadWebpage.ts +3 -113
  23. package/src/ai.ts +33 -2
  24. package/src/auth/browserLogin.ts +10 -13
  25. package/src/cli.ts +63 -3
  26. package/src/clients/gemini.ts +96 -25
  27. package/src/clients/http.ts +7 -11
  28. package/src/clients/pricing/google.ts +122 -26
  29. package/src/config.ts +28 -4
  30. package/src/conversion.ts +24 -54
  31. package/src/index.ts +30 -3
  32. package/src/login.ts +5 -6
  33. package/src/plugins/language.ts +0 -4
  34. package/src/plugins/plugins.ts +0 -14
  35. package/src/plugins/url.ts +31 -12
  36. package/src/processors/TokenCompressor.ts +2 -2
  37. package/src/processors/ToolResponseCache.ts +3 -3
  38. package/src/processors/tools/grepToolResponse.ts +9 -4
  39. package/src/processors/tools/jqToolResponse.ts +11 -6
  40. package/src/processors/tools/listStoredToolResponses.ts +1 -1
  41. package/src/processors/tools/tailToolResponse.ts +9 -4
  42. package/src/services/GitHub.ts +2 -2
  43. package/src/services/KnowhowClient.ts +34 -34
  44. package/src/{plugins/downloader/downloader.ts → services/MediaProcessorService.ts} +109 -267
  45. package/src/services/S3.ts +16 -16
  46. package/src/services/index.ts +4 -4
  47. package/src/services/modules/index.ts +10 -2
  48. package/src/services/modules/types.ts +5 -2
  49. package/src/services/script-execution/ScriptExecutor.ts +29 -10
  50. package/src/services/script-execution/ScriptPolicy.ts +6 -2
  51. package/src/types.ts +1 -0
  52. package/src/utils/http.ts +127 -0
  53. package/src/workers/auth/PasskeySetup.ts +7 -11
  54. package/tests/clients/AIClient.test.ts +24 -21
  55. package/tests/manual/file-edits/figma.test.ts +3 -70
  56. package/tests/plugins/language/languagePlugin-content-triggers.test.ts +2 -0
  57. package/tests/plugins/language/languagePlugin.test.ts +2 -0
  58. package/tests/processors/ToolResponseCache.test.ts +2 -2
  59. package/tests/test.spec.ts +0 -14
  60. package/tests/unit/modules/moduleLoading.test.ts +7 -4
  61. package/tests/unit/plugins/pluginLoading.test.ts +6 -6
  62. package/ts_build/package.json +4 -32
  63. package/ts_build/src/agents/tools/ast/astAppendNode.d.ts +1 -1
  64. package/ts_build/src/agents/tools/ast/astAppendNode.js +2 -90
  65. package/ts_build/src/agents/tools/ast/astAppendNode.js.map +1 -1
  66. package/ts_build/src/agents/tools/ast/astDeleteNode.d.ts +1 -1
  67. package/ts_build/src/agents/tools/ast/astDeleteNode.js +2 -88
  68. package/ts_build/src/agents/tools/ast/astDeleteNode.js.map +1 -1
  69. package/ts_build/src/agents/tools/ast/astEditNode.d.ts +1 -1
  70. package/ts_build/src/agents/tools/ast/astEditNode.js +2 -90
  71. package/ts_build/src/agents/tools/ast/astEditNode.js.map +1 -1
  72. package/ts_build/src/agents/tools/ast/astGetPathForLine.d.ts +1 -1
  73. package/ts_build/src/agents/tools/ast/astGetPathForLine.js +2 -72
  74. package/ts_build/src/agents/tools/ast/astGetPathForLine.js.map +1 -1
  75. package/ts_build/src/agents/tools/ast/astListPaths.d.ts +1 -1
  76. package/ts_build/src/agents/tools/ast/astListPaths.js +2 -72
  77. package/ts_build/src/agents/tools/ast/astListPaths.js.map +1 -1
  78. package/ts_build/src/agents/tools/executeScript/index.d.ts +3 -2
  79. package/ts_build/src/agents/tools/executeScript/index.js +4 -1
  80. package/ts_build/src/agents/tools/executeScript/index.js.map +1 -1
  81. package/ts_build/src/agents/tools/googleSearch.js +2 -2
  82. package/ts_build/src/agents/tools/googleSearch.js.map +1 -1
  83. package/ts_build/src/agents/tools/index.d.ts +0 -3
  84. package/ts_build/src/agents/tools/index.js +0 -3
  85. package/ts_build/src/agents/tools/index.js.map +1 -1
  86. package/ts_build/src/agents/tools/list.js +0 -138
  87. package/ts_build/src/agents/tools/list.js.map +1 -1
  88. package/ts_build/src/agents/tools/loadWebpage.js +1 -89
  89. package/ts_build/src/agents/tools/loadWebpage.js.map +1 -1
  90. package/ts_build/src/agents/tools/textSearch.d.ts +1 -1
  91. package/ts_build/src/ai.js +18 -1
  92. package/ts_build/src/ai.js.map +1 -1
  93. package/ts_build/src/auth/browserLogin.js +7 -7
  94. package/ts_build/src/auth/browserLogin.js.map +1 -1
  95. package/ts_build/src/cli.d.ts +1 -1
  96. package/ts_build/src/cli.js +47 -1
  97. package/ts_build/src/cli.js.map +1 -1
  98. package/ts_build/src/clients/gemini.d.ts +1 -73
  99. package/ts_build/src/clients/gemini.js +57 -19
  100. package/ts_build/src/clients/gemini.js.map +1 -1
  101. package/ts_build/src/clients/http.js +5 -9
  102. package/ts_build/src/clients/http.js.map +1 -1
  103. package/ts_build/src/clients/pricing/google.d.ts +17 -73
  104. package/ts_build/src/clients/pricing/google.js +47 -10
  105. package/ts_build/src/clients/pricing/google.js.map +1 -1
  106. package/ts_build/src/config.js +17 -2
  107. package/ts_build/src/config.js.map +1 -1
  108. package/ts_build/src/conversion.d.ts +1 -4
  109. package/ts_build/src/conversion.js +12 -27
  110. package/ts_build/src/conversion.js.map +1 -1
  111. package/ts_build/src/index.d.ts +4 -0
  112. package/ts_build/src/index.js +19 -3
  113. package/ts_build/src/index.js.map +1 -1
  114. package/ts_build/src/login.js +5 -4
  115. package/ts_build/src/login.js.map +1 -1
  116. package/ts_build/src/plugins/downloader/downloader.js +3 -3
  117. package/ts_build/src/plugins/downloader/downloader.js.map +1 -1
  118. package/ts_build/src/plugins/language.js.map +1 -1
  119. package/ts_build/src/plugins/plugins.js +0 -14
  120. package/ts_build/src/plugins/plugins.js.map +1 -1
  121. package/ts_build/src/plugins/tree-sitter/editor.d.ts +3 -32
  122. package/ts_build/src/plugins/tree-sitter/editor.js +6 -208
  123. package/ts_build/src/plugins/tree-sitter/editor.js.map +1 -1
  124. package/ts_build/src/plugins/tree-sitter/parser.d.ts +19 -54
  125. package/ts_build/src/plugins/tree-sitter/parser.js +19 -293
  126. package/ts_build/src/plugins/tree-sitter/parser.js.map +1 -1
  127. package/ts_build/src/plugins/tree-sitter/simple-paths.d.ts +2 -15
  128. package/ts_build/src/plugins/tree-sitter/simple-paths.js +2 -324
  129. package/ts_build/src/plugins/tree-sitter/simple-paths.js.map +1 -1
  130. package/ts_build/src/plugins/url.js +27 -8
  131. package/ts_build/src/plugins/url.js.map +1 -1
  132. package/ts_build/src/processors/TokenCompressor.js +2 -2
  133. package/ts_build/src/processors/TokenCompressor.js.map +1 -1
  134. package/ts_build/src/processors/ToolResponseCache.js +3 -3
  135. package/ts_build/src/processors/ToolResponseCache.js.map +1 -1
  136. package/ts_build/src/processors/tools/grepToolResponse.d.ts +3 -1
  137. package/ts_build/src/processors/tools/grepToolResponse.js +8 -2
  138. package/ts_build/src/processors/tools/grepToolResponse.js.map +1 -1
  139. package/ts_build/src/processors/tools/jqToolResponse.d.ts +3 -1
  140. package/ts_build/src/processors/tools/jqToolResponse.js +10 -4
  141. package/ts_build/src/processors/tools/jqToolResponse.js.map +1 -1
  142. package/ts_build/src/processors/tools/listStoredToolResponses.js +1 -1
  143. package/ts_build/src/processors/tools/listStoredToolResponses.js.map +1 -1
  144. package/ts_build/src/processors/tools/tailToolResponse.d.ts +3 -1
  145. package/ts_build/src/processors/tools/tailToolResponse.js +8 -2
  146. package/ts_build/src/processors/tools/tailToolResponse.js.map +1 -1
  147. package/ts_build/src/services/GitHub.js +2 -2
  148. package/ts_build/src/services/GitHub.js.map +1 -1
  149. package/ts_build/src/services/KnowhowClient.d.ts +29 -29
  150. package/ts_build/src/services/KnowhowClient.js +33 -33
  151. package/ts_build/src/services/KnowhowClient.js.map +1 -1
  152. package/ts_build/src/services/MediaProcessorService.d.ts +22 -0
  153. package/ts_build/src/services/MediaProcessorService.js +215 -0
  154. package/ts_build/src/services/MediaProcessorService.js.map +1 -0
  155. package/ts_build/src/services/S3.js +12 -18
  156. package/ts_build/src/services/S3.js.map +1 -1
  157. package/ts_build/src/services/index.d.ts +3 -2
  158. package/ts_build/src/services/index.js +3 -3
  159. package/ts_build/src/services/index.js.map +1 -1
  160. package/ts_build/src/services/modules/index.js +10 -2
  161. package/ts_build/src/services/modules/index.js.map +1 -1
  162. package/ts_build/src/services/modules/types.d.ts +5 -2
  163. package/ts_build/src/services/script-execution/ScriptExecutor.js +22 -7
  164. package/ts_build/src/services/script-execution/ScriptExecutor.js.map +1 -1
  165. package/ts_build/src/services/script-execution/ScriptPolicy.d.ts +1 -1
  166. package/ts_build/src/services/script-execution/ScriptPolicy.js +4 -2
  167. package/ts_build/src/services/script-execution/ScriptPolicy.js.map +1 -1
  168. package/ts_build/src/types.d.ts +1 -0
  169. package/ts_build/src/types.js +1 -0
  170. package/ts_build/src/types.js.map +1 -1
  171. package/ts_build/src/utils/http.d.ts +27 -0
  172. package/ts_build/src/utils/http.js +98 -0
  173. package/ts_build/src/utils/http.js.map +1 -0
  174. package/ts_build/src/workers/auth/PasskeySetup.js +6 -7
  175. package/ts_build/src/workers/auth/PasskeySetup.js.map +1 -1
  176. package/ts_build/tests/clients/AIClient.test.js +11 -14
  177. package/ts_build/tests/clients/AIClient.test.js.map +1 -1
  178. package/ts_build/tests/manual/file-edits/figma.test.d.ts +0 -1
  179. package/ts_build/tests/manual/file-edits/figma.test.js +1 -46
  180. package/ts_build/tests/manual/file-edits/figma.test.js.map +1 -1
  181. package/ts_build/tests/plugins/language/languagePlugin-content-triggers.test.js +2 -0
  182. package/ts_build/tests/plugins/language/languagePlugin-content-triggers.test.js.map +1 -1
  183. package/ts_build/tests/plugins/language/languagePlugin.test.js +2 -0
  184. package/ts_build/tests/plugins/language/languagePlugin.test.js.map +1 -1
  185. package/ts_build/tests/processors/ToolResponseCache.test.js +2 -2
  186. package/ts_build/tests/processors/ToolResponseCache.test.js.map +1 -1
  187. package/ts_build/tests/test.spec.js +0 -14
  188. package/ts_build/tests/test.spec.js.map +1 -1
  189. package/ts_build/tests/tree-sitter/tree-sitter.test.d.ts +0 -1
  190. package/ts_build/tests/tree-sitter/tree-sitter.test.js +2 -183
  191. package/ts_build/tests/tree-sitter/tree-sitter.test.js.map +1 -1
  192. package/ts_build/tests/unit/modules/moduleLoading.test.js +6 -4
  193. package/ts_build/tests/unit/modules/moduleLoading.test.js.map +1 -1
  194. package/ts_build/tests/unit/plugins/pluginLoading.test.js +4 -4
  195. package/ts_build/tests/unit/plugins/pluginLoading.test.js.map +1 -1
  196. package/autodoc/chat.mdx +0 -20
  197. package/autodoc/cli.mdx +0 -11
  198. package/autodoc/plugins/asana.mdx +0 -47
  199. package/autodoc/plugins/downloader/downloader.mdx +0 -38
  200. package/autodoc/plugins/downloader/plugin.mdx +0 -37
  201. package/autodoc/plugins/downloader/types.mdx +0 -42
  202. package/autodoc/plugins/embedding.mdx +0 -41
  203. package/autodoc/plugins/figma.mdx +0 -45
  204. package/autodoc/plugins/github.mdx +0 -40
  205. package/autodoc/plugins/jira.mdx +0 -46
  206. package/autodoc/plugins/language.mdx +0 -37
  207. package/autodoc/plugins/linear.mdx +0 -35
  208. package/autodoc/plugins/notion.mdx +0 -38
  209. package/autodoc/plugins/plugins.mdx +0 -59
  210. package/autodoc/plugins/types.mdx +0 -51
  211. package/autodoc/plugins/vim.mdx +0 -39
  212. package/autodoc/tools/addInternalTools.mdx +0 -1
  213. package/autodoc/tools/agentCall.mdx +0 -1
  214. package/autodoc/tools/asana/definitions.mdx +0 -10
  215. package/autodoc/tools/asana/index.mdx +0 -12
  216. package/autodoc/tools/askHuman.mdx +0 -1
  217. package/autodoc/tools/callPlugin.mdx +0 -1
  218. package/autodoc/tools/embeddingSearch.mdx +0 -1
  219. package/autodoc/tools/execCommand.mdx +0 -1
  220. package/autodoc/tools/fileSearch.mdx +0 -1
  221. package/autodoc/tools/finalAnswer.mdx +0 -1
  222. package/autodoc/tools/github/definitions.mdx +0 -6
  223. package/autodoc/tools/github/index.mdx +0 -8
  224. package/autodoc/tools/index.mdx +0 -14
  225. package/autodoc/tools/lintFile.mdx +0 -7
  226. package/autodoc/tools/list.mdx +0 -16
  227. package/autodoc/tools/modifyFile.mdx +0 -7
  228. package/autodoc/tools/patch.mdx +0 -9
  229. package/autodoc/tools/readBlocks.mdx +0 -1
  230. package/autodoc/tools/readFile.mdx +0 -1
  231. package/autodoc/tools/scanFile.mdx +0 -1
  232. package/autodoc/tools/textSearch.mdx +0 -6
  233. package/autodoc/tools/types/fileblock.mdx +0 -1
  234. package/autodoc/tools/visionTool.mdx +0 -1
  235. package/autodoc/tools/writeFile.mdx +0 -1
  236. package/benchmarks/.dockerignore +0 -7
  237. package/benchmarks/README.md +0 -166
  238. package/benchmarks/docker/Dockerfile +0 -68
  239. package/benchmarks/example-config.yml +0 -27
  240. package/benchmarks/jest.config.js +0 -13
  241. package/benchmarks/package-lock.json +0 -4297
  242. package/benchmarks/package.json +0 -39
  243. package/benchmarks/results/27b0a06/2025-09-27/xai/xai-grok-code-fast-1.json +0 -2909
  244. package/benchmarks/results/4057aed/2025-08-14/anthropic/anthropic-claude-sonnet-4-20250514.json +0 -1671
  245. package/benchmarks/results/4542435/2025-08-05/lms/lms-openai-gpt-oss-20b.json +0 -2814
  246. package/benchmarks/results/4542435/2025-08-05/lms/lms-qwen-qwen3-30b-a3b-2507.json +0 -2014
  247. package/benchmarks/results/4fb9125/2025-08-07/anthropic/anthropic-claude-sonnet-4-20250514.json +0 -3121
  248. package/benchmarks/results/5766aee/2025-08-02/lms-qwen/qwen3-coder-30b.json +0 -98
  249. package/benchmarks/results/6d73808/2025-08-07/openai/openai-gpt-5.json +0 -3256
  250. package/benchmarks/results/77bf0a6/2025-08-02/lms-qwen/qwen3-30b-a3b-2507.json +0 -4298
  251. package/benchmarks/results/8c0d445/2025-08-03/anthropic/anthropic-claude-sonnet-4-20250514.json +0 -3031
  252. package/benchmarks/results/8c0d445/2025-08-03/openai/openai-gpt-4.1-2025-04-14.json +0 -2990
  253. package/benchmarks/results/ac6b2ab/2025-08-03/anthropic/anthropic-claude-sonnet-4-20250514.json +0 -3256
  254. package/benchmarks/results/ac6b2ab/2025-08-03/lms/lms-qwen-qwen3-coder-30b.json +0 -3007
  255. package/benchmarks/results/ac6b2ab/2025-08-03/openai/openai-gpt-4.1-2025-04-14.json +0 -3256
  256. package/benchmarks/results/ac6b2ab/2025-08-03/openai/openai-gpt-4.1-mini-2025-04-14.json +0 -3036
  257. package/benchmarks/results/ac6b2ab/2025-08-03/openai/openai-gpt-4.1-nano-2025-04-14.json +0 -3280
  258. package/benchmarks/results/adff675/2025-08-04/lms/lms-qwen-qwen3-30b-a3b-2507.json +0 -1920
  259. package/benchmarks/results/adff675/2025-08-04/lms/lms-qwen-qwen3-coder-30b.json +0 -3281
  260. package/benchmarks/results/b502ed9/2025-08-03/lms-qwen/qwen3-coder-30b.json +0 -2896
  261. package/benchmarks/results/d1a8129/2025-08-03/lms/lms-qwen-qwen3-coder-30b.json +0 -3011
  262. package/benchmarks/results/e60471c/2025-08-03/lms/qwen3-30b-a3b-2507.json +0 -3003
  263. package/benchmarks/scripts/build-and-run.sh +0 -47
  264. package/benchmarks/scripts/clone-exercism.sh +0 -92
  265. package/benchmarks/scripts/validate.sh +0 -48
  266. package/benchmarks/src/__tests__/runner.test.ts +0 -27
  267. package/benchmarks/src/cli.ts +0 -90
  268. package/benchmarks/src/evaluators/EvaluatorRegistry.ts +0 -64
  269. package/benchmarks/src/evaluators/JavaScriptEvaluator.ts +0 -183
  270. package/benchmarks/src/evaluators/index.ts +0 -3
  271. package/benchmarks/src/evaluators/types.ts +0 -22
  272. package/benchmarks/src/index.ts +0 -3
  273. package/benchmarks/src/providers.ts +0 -13
  274. package/benchmarks/src/runner.ts +0 -824
  275. package/benchmarks/src/types.ts +0 -63
  276. package/benchmarks/tsconfig.json +0 -19
  277. package/leaderboard/README.md +0 -148
  278. package/leaderboard/app/api/benchmark-data/route.ts +0 -131
  279. package/leaderboard/app/api/benchmark-detail/route.ts +0 -172
  280. package/leaderboard/app/details/[model]/[provider]/[language]/page.tsx +0 -501
  281. package/leaderboard/app/exercise/[model]/[provider]/[language]/[exercise]/page.tsx +0 -375
  282. package/leaderboard/app/globals.css +0 -27
  283. package/leaderboard/app/layout.tsx +0 -21
  284. package/leaderboard/app/page.tsx +0 -170
  285. package/leaderboard/components/LeaderboardTable.tsx +0 -168
  286. package/leaderboard/components/PerformanceChart.tsx +0 -109
  287. package/leaderboard/next-env.d.ts +0 -5
  288. package/leaderboard/next.config.js +0 -4
  289. package/leaderboard/package-lock.json +0 -6363
  290. package/leaderboard/package.json +0 -28
  291. package/leaderboard/postcss.config.js +0 -6
  292. package/leaderboard/tailwind.config.js +0 -17
  293. package/leaderboard/tsconfig.json +0 -28
  294. package/leaderboard/types/benchmark.ts +0 -67
  295. package/leaderboard/utils/dataProcessor.ts +0 -33
  296. package/src/agents/tools/asana/definitions.ts +0 -199
  297. package/src/agents/tools/asana/index.ts +0 -108
  298. package/src/agents/tools/ast/astAppendNode.ts +0 -90
  299. package/src/agents/tools/ast/astDeleteNode.ts +0 -88
  300. package/src/agents/tools/ast/astEditNode.ts +0 -95
  301. package/src/agents/tools/ast/astGetPathForLine.ts +0 -73
  302. package/src/agents/tools/ast/astListPaths.ts +0 -66
  303. package/src/agents/tools/ast/index.ts +0 -7
  304. package/src/agents/tools/github/definitions.ts +0 -89
  305. package/src/agents/tools/github/index.ts +0 -67
  306. package/src/chat-old.ts +0 -446
  307. package/src/plugins/asana.ts +0 -146
  308. package/src/plugins/downloader/plugin.ts +0 -103
  309. package/src/plugins/downloader/types.ts +0 -92
  310. package/src/plugins/figma.ts +0 -158
  311. package/src/plugins/github.ts +0 -219
  312. package/src/plugins/jira.ts +0 -115
  313. package/src/plugins/linear.ts +0 -230
  314. package/src/plugins/notion.ts +0 -179
  315. package/src/plugins/tree-sitter/editor.ts +0 -369
  316. package/src/plugins/tree-sitter/lang-packs/index.ts +0 -23
  317. package/src/plugins/tree-sitter/lang-packs/java.ts +0 -59
  318. package/src/plugins/tree-sitter/lang-packs/javascript.ts +0 -57
  319. package/src/plugins/tree-sitter/lang-packs/python.ts +0 -45
  320. package/src/plugins/tree-sitter/lang-packs/types.ts +0 -79
  321. package/src/plugins/tree-sitter/lang-packs/typescript.ts +0 -49
  322. package/src/plugins/tree-sitter/parser.ts +0 -470
  323. package/src/plugins/tree-sitter/simple-paths.ts +0 -467
  324. package/test-comprehensive.ts +0 -31
  325. package/tests/tree-sitter/editor.test.ts +0 -113
  326. package/tests/tree-sitter/invalid.test.ts +0 -299
  327. package/tests/tree-sitter/paths/common-edits.test.ts +0 -564
  328. package/tests/tree-sitter/paths/debug-exact-position.test.ts +0 -44
  329. package/tests/tree-sitter/paths/debug-line-indexing.test.ts +0 -49
  330. package/tests/tree-sitter/paths/debug-paths.test.ts +0 -90
  331. package/tests/tree-sitter/paths/paths.test.ts +0 -170
  332. package/tests/tree-sitter/paths/simple-paths.test.ts +0 -367
  333. package/tests/tree-sitter/sample-after.ts +0 -48
  334. package/tests/tree-sitter/sample-before.ts +0 -25
  335. package/tests/tree-sitter/test-files/completely-broken.ts +0 -7
  336. package/tests/tree-sitter/test-files/duplicate-braces.ts +0 -39
  337. package/tests/tree-sitter/test-files/invalid-nesting.ts +0 -39
  338. package/tests/tree-sitter/test-files/malformed-signature.ts +0 -39
  339. package/tests/tree-sitter/test-files/mismatched-parens.ts +0 -39
  340. package/tests/tree-sitter/test-files/missing-semicolon.ts +0 -39
  341. package/tests/tree-sitter/test-files/partially-broken.ts +0 -20
  342. package/tests/tree-sitter/test-files/specific-errors.ts +0 -14
  343. package/tests/tree-sitter/test-files/unclosed-string.ts +0 -39
  344. package/tests/tree-sitter/tree-sitter.test.ts +0 -251
package/WORKER.md CHANGED
@@ -1,373 +1,235 @@
1
- # Knowhow Workers Guide
1
+ # `knowhow worker` — what it is
2
2
 
3
- Knowhow workers allow you to expose your local tools and development environment to the Knowhow platform, enabling remote agents to execute commands, access files, and leverage your local setup through a secure WebSocket connection.
3
+ The `knowhow worker` command starts a **Knowhow Worker process** that exposes an **MCP (Model Context Protocol) server** backed by a curated set of **tools**.
4
4
 
5
- ---
5
+ At a high level (from `src/worker.ts` + CLI wiring):
6
6
 
7
- ## Quick Start
7
+ 1. Loads `knowhow.json` via `getConfig()`.
8
+ 2. Optionally runs **passkey setup / reset** flows (browser-based), then exits.
9
+ 3. Chooses an execution mode:
10
+ - **Host mode** (default), or
11
+ - **Docker sandbox mode** (`--sandbox`)
12
+ 4. In host mode, it connects to Knowhow’s API over **WebSockets** and serves MCP tools.
13
+ 5. In sandbox mode, it verifies Docker, rebuilds the worker image, then runs the worker inside Docker and forwards logs.
8
14
 
9
- ### 1. Initial Setup
15
+ > The CLI entry point (e.g. in `src/cli.ts`) mainly defines the subcommand surface and ensures shared services are initialized; the runtime behavior and config handling are implemented in `src/worker.ts`.
10
16
 
11
- First, authenticate with the Knowhow platform:
17
+ ---
12
18
 
13
- ```bash
14
- knowhow login
15
- ```
19
+ ## What the worker exposes
16
20
 
17
- This will open your browser and guide you through the authentication process.
21
+ In **host mode**, the worker:
22
+ - Starts an **MCP server** (`clientName = "knowhow-worker"`, `clientVersion = "1.1.1"`).
23
+ - Registers the enabled tool set (see `worker.allowedTools` below).
24
+ - Connects to the Knowhow backend WebSocket endpoint(s) so the backend can drive tool usage.
25
+ - Reconnects continuously if the WebSocket connection drops.
18
26
 
19
- ### 2. Generate Worker Configuration
27
+ Key connection endpoints (host mode):
28
+ - Worker WS: `${API_URL}/ws/worker`
29
+ - Optional tunnel WS: `${API_URL}/ws/tunnel`
20
30
 
21
- Run the worker command to generate the initial configuration:
31
+ WebSocket headers include:
32
+ - `Authorization: Bearer <jwt>` (from `loadJwt()`)
33
+ - `User-Agent: knowhow-worker/1.1.1/<hostname>`
34
+ - `Root: <computed from WORKER_ROOT or cwd>`
35
+ - Optional share visibility:
36
+ - `Shared: "true"` with `--share`
37
+ - `Shared: "false"` with `--unshare`
38
+ - no `Shared` header if neither flag is provided
22
39
 
23
- ```bash
24
- knowhow worker
25
- ```
40
+ ---
26
41
 
27
- This will:
28
- - Generate a `worker` configuration block in your `knowhow.json`
29
- - Display available tools that can be exposed
30
- - Create a secure connection to the Knowhow platform
42
+ # CLI arguments supported by `knowhow worker`
31
43
 
32
- ### 3. Configure Allowed Tools
44
+ These flags are handled by the exported worker launcher in `src/worker.ts` (and exposed by the `worker` subcommand wiring).
33
45
 
34
- Edit your `knowhow.json` to specify which tools you want to expose:
46
+ | Flag | Type | Effect |
47
+ |------|------|--------|
48
+ | `--register` | boolean | Registers the current directory as a worker path (`registerWorkerPath(process.cwd())`) and then exits. |
49
+ | `--share` | boolean | Sets `Shared: "true"` header when connecting to the API (marks worker as shared). |
50
+ | `--unshare` | boolean | Sets `Shared: "false"` header when connecting to the API (marks worker as private/unshared). |
51
+ | `--sandbox` | boolean | Runs worker in Docker sandbox mode; persists `worker.sandbox = true` into config. |
52
+ | `--no-sandbox` | boolean | Forces host mode; persists `worker.sandbox = false` into config. |
53
+ | `--passkey` | boolean | Runs browser-based passkey setup (`PasskeySetupService().setup(jwt)`) and exits. |
54
+ | `--passkey-reset` | boolean | Clears stored passkey credentials (`PasskeySetupService().reset()`) and exits. |
35
55
 
36
- ```json
37
- {
38
- "worker": {
39
- "allowedTools": [
40
- "readFile",
41
- "writeFileChunk",
42
- "patchFile",
43
- "execCommand",
44
- "textSearch",
45
- "fileSearch",
46
- "embeddingSearch"
47
- ]
48
- }
49
- }
50
- ```
56
+ ## Sandbox selection priority (important)
51
57
 
52
- ### 4. Start the Worker
58
+ When not already inside Docker, sandbox mode is selected by this priority:
53
59
 
54
- Run the worker again to start the connection:
60
+ 1. `--sandbox` / `--no-sandbox` CLI flags (highest priority)
61
+ 2. `knowhow.json` config: `config.worker.sandbox`
62
+ 3. Default: `false` (host mode)
55
63
 
56
- ```bash
57
- knowhow worker
58
- ```
64
+ ### Special case: already inside Docker
65
+ If `process.env.KNOWHOW_DOCKER === "true"`, the worker forces:
66
+ - `options.sandbox = false`
67
+ - `options.noSandbox = true`
59
68
 
60
- Your local tools are now available to Knowhow behaviors and agents!
69
+ This prevents nested Docker execution.
61
70
 
62
71
  ---
63
72
 
64
- ## Worker Architecture
73
+ # `knowhow.json` config options supported (as used by `src/worker.ts`)
65
74
 
66
- ### WebSocket Connection
75
+ The worker primarily reads/writes under `config.worker.*`.
67
76
 
68
- Workers establish a secure WebSocket connection to the Knowhow platform:
77
+ ## 1) `worker.sandbox` (boolean)
78
+ Controls which mode runs **when no CLI sandbox flags are provided**.
69
79
 
70
- - **Authentication**: Uses your login credentials for secure access
71
- - **Real-time Communication**: Enables instant tool execution requests
72
- - **Automatic Reconnection**: Handles network interruptions gracefully
73
- - **Tool Allowlisting**: Only exposed tools can be executed remotely
80
+ - Updated by:
81
+ - `--sandbox` `worker.sandbox = true`
82
+ - `--no-sandbox` `worker.sandbox = false`
83
+
84
+ ---
74
85
 
75
- ### MCP Integration
86
+ ## 2) `worker.allowedTools` (string[])
87
+ Controls which tools are exposed to the MCP server.
76
88
 
77
- Workers leverage the Model Context Protocol (MCP) to expose tools:
89
+ Behavior:
90
+ - If missing, the worker:
91
+ 1. populates it with `Tools.getToolNames()`
92
+ 2. saves it back to `knowhow.json`
93
+ 3. then exits early (so you can edit/curate the allowlist)
78
94
 
79
- - **Tool Registration**: Local tools are registered as MCP resources
80
- - **Parameter Validation**: Ensures proper argument types and requirements
81
- - **Error Handling**: Provides detailed error messages for debugging
82
- - **Response Formatting**: Standardizes tool outputs for agent consumption
95
+ So: first run creates an allowlist; subsequent runs enforce it.
83
96
 
84
97
  ---
85
98
 
86
- ## Configuration
99
+ ## 3) Passkey auth: `worker.auth.passkey`
100
+ If configured, the worker starts in a **locked** state and wraps tool execution so tools fail unless unlocked.
87
101
 
88
- ### Basic Worker Configuration
102
+ The code implies an expected shape like:
89
103
 
90
- ```json
91
- {
92
- "worker": {
93
- "allowedTools": [
94
- "readFile",
95
- "writeFileChunk",
96
- "patchFile",
97
- "lintFile",
98
- "execCommand",
99
- "textSearch",
100
- "fileSearch",
101
- "embeddingSearch"
102
- ]
103
- }
104
- }
104
+ ```ts
105
+ config.worker.auth.passkey.publicKey
106
+ config.worker.auth.passkey.credentialId
107
+ config.worker.auth.sessionDurationHours // optional; defaults to ~3
105
108
  ```
106
109
 
107
- ### Advanced Configuration
110
+ Effects when enabled:
111
+ - `WorkerPasskeyAuthService` is created.
112
+ - Tool functions are wrapped:
113
+ - When locked: return an error object like `WORKER_LOCKED` / “unlock first”.
114
+ - When unlocked: execute the original tool function.
115
+ - The worker registers additional auth tools:
116
+ - `unlock` (`makeUnlockTool`)
117
+ - `lock` (`makeLockTool`)
108
118
 
109
- ```json
110
- {
111
- "worker": {
112
- "allowedTools": [
113
- "readFile",
114
- "writeFileChunk",
115
- "patchFile",
116
- "lintFile",
117
- "execCommand",
118
- "textSearch",
119
- "fileSearch",
120
- "embeddingSearch",
121
- "createAiCompletion",
122
- "listAllModels",
123
- "callPlugin"
124
- ]
125
- }
126
- }
127
- ```
119
+ > Exact error message/response format depends on the auth service implementation, but the lock/unlock gating is explicit.
128
120
 
129
121
  ---
130
122
 
131
- ## Available Tools
132
-
133
- ### File Operations
123
+ ## 4) Tunnel configuration: `worker.tunnel.*`
124
+ If enabled, the worker also opens a second WebSocket (`/ws/tunnel`) so the backend can reach allowed local services.
134
125
 
135
- #### Core File Tools
136
- - **`readFile`** - Read complete file contents
137
- - **`writeFileChunk`** - Write content to files (supports chunking for large files)
138
- - **`patchFile`** - Apply unified diff patches to files
139
- - **`readBlocks`** - Read specific blocks from files
126
+ ### `worker.tunnel.enabled` (boolean)
127
+ - `true` tunnel WS created
128
+ - `false` / missing tunneling disabled
140
129
 
141
- #### Search Tools
142
- - **`textSearch`** - Search for exact text matches across files
143
- - **`fileSearch`** - Search for files by path patterns
144
- - **`embeddingSearch`** - Semantic search using embeddings
130
+ ### `worker.tunnel.allowedPorts` (number[])
131
+ - Restricts which ports can be used through the tunnel.
132
+ - If tunnel is enabled but this list is empty, the worker logs a warning.
145
133
 
146
- ### Development Tools
134
+ ### `worker.tunnel.localHost` (string, optional)
135
+ Hostname for reaching local services.
147
136
 
148
- #### Code Quality
149
- - **`lintFile`** - Run linters on files based on extension
150
- - **`execCommand`** - Execute shell commands with timeout support
137
+ - If not set:
138
+ - inside Docker (`KNOWHOW_DOCKER === "true"`): `host.docker.internal`
139
+ - otherwise: `127.0.0.1`
151
140
 
152
- #### AI Integration
153
- - **`createAiCompletion`** - Create AI completions using configured models
154
- - **`listAllModels`** - List available AI models
155
- - **`listAllProviders`** - List available AI providers
141
+ ### `worker.tunnel.portMapping` (object/map)
142
+ The code treats it as a mapping:
156
143
 
157
- ### Plugin System
158
- - **`callPlugin`** - Execute plugin functions
159
- - **`addLanguageTerm`** - Add language terms for context loading
160
- - **`getAllLanguageTerms`** - Retrieve all configured language terms
161
- - **`lookupLanguageTerm`** - Look up specific language terms
144
+ - `config.worker.tunnel.portMapping[containerPort] = hostPort`
162
145
 
163
- ### Integration Tools
146
+ It logs these mappings and passes them to the tunnel handler.
164
147
 
165
- #### Version Control
166
- - **`getPullRequest`** - Fetch GitHub pull request information
167
- - **`getPullRequestBuildStatuses`** - Get build status for PRs
168
- - **`getRunLogs`** - Retrieve GitHub Actions run logs
169
- - **`getPullRequestBuildFailureLogs`** - Get failure logs from PR builds
148
+ ### `worker.tunnel.maxConcurrentStreams` (number, optional)
149
+ - Passed to tunnel config
150
+ - Default used in `src/worker.ts`: `50`
170
151
 
171
- ### MCP Server Tools
172
-
173
- When MCP servers are configured, their tools become available with prefixed names:
174
-
175
- ```json
176
- {
177
- "mcps": [
178
- {
179
- "name": "browser",
180
- "command": "npx",
181
- "args": ["-y", "@modelcontextprotocol/server-puppeteer"]
182
- }
183
- ],
184
- "worker": {
185
- "allowedTools": [
186
- "mcp_0_browser_navigate",
187
- "mcp_0_browser_screenshot",
188
- "mcp_0_browser_click",
189
- "mcp_0_browser_fill",
190
- "mcp_0_browser_select"
191
- ]
192
- }
193
- }
194
- ```
152
+ ### `worker.tunnel.enableUrlRewriting` (boolean, optional)
153
+ - Passed to tunnel config as:
154
+ - `config.worker.tunnel.enableUrlRewriting !== false`
155
+ - So URL rewriting defaults to **enabled** unless explicitly set to `false`.
195
156
 
196
157
  ---
197
158
 
198
- ## Security Considerations
199
-
200
- ### Tool Allowlisting
159
+ # Execution modes (host vs Docker sandbox)
160
+
161
+ ## Host mode (default)
162
+ Key responsibilities:
163
+ - Connect to `${API_URL}/ws/worker` using the JWT and headers (including optional `Shared`).
164
+ - Optionally connect to `${API_URL}/ws/tunnel`.
165
+ - Serve MCP tools via `mcpServer.createServer(...).withTools(toolsToUse)`.
166
+ - If the worker WS reconnects:
167
+ - it resets MCP server state and re-registers the tool set.
168
+
169
+ ## Docker sandbox mode (`--sandbox`)
170
+ When sandbox mode is selected:
171
+ 1. Check Docker availability.
172
+ 2. Build the worker Docker image.
173
+ 3. Load JWT.
174
+ 4. Run the worker in Docker (`Docker.runWorkerContainer(...)`) with:
175
+ - `workspaceDir: process.cwd()`
176
+ - `jwt`
177
+ - `apiUrl: API_URL`
178
+ - `config` passed into container
179
+ - `share` / `unshare` options
180
+ 5. Forward container logs and stop the container on exit.
201
181
 
202
- Only tools explicitly listed in `allowedTools` can be executed remotely:
182
+ ---
203
183
 
204
- ```json
205
- {
206
- "worker": {
207
- "allowedTools": [
208
- "readFile", // Allowed
209
- "writeFileChunk", // Allowed
210
- // "execCommand" // ❌ Not allowed - commented out
211
- ]
212
- }
213
- }
184
+ # Summary checklist
185
+
186
+ - **Use `knowhow worker` to**: run a Knowhow Worker that exposes an MCP server and a filtered tool allowlist.
187
+ - **Common CLI flags**:
188
+ - `--register`, `--share`, `--unshare`
189
+ - `--sandbox` / `--no-sandbox`
190
+ - `--passkey` / `--passkey-reset`
191
+ - **Key config fields**:
192
+ - `worker.sandbox`
193
+ - `worker.allowedTools` (auto-populated on first run if missing)
194
+ - `worker.auth.passkey.*` (enables lock/unlock tool gating)
195
+ - `worker.tunnel.enabled`, `worker.tunnel.allowedPorts`, `worker.tunnel.localHost`, `worker.tunnel.portMapping`, `worker.tunnel.maxConcurrentStreams`, `worker.tunnel.enableUrlRewriting`
214
196
  ```
215
197
 
216
- ### File System Access
217
-
218
- Workers respect the project directory boundaries:
219
- - **Limited Scope**: Only files within the project directory are accessible
220
- - **Path Validation**: Prevents directory traversal attacks
221
- - **Permission Checks**: Respects file system permissions
222
-
223
- ### Command Execution
224
-
225
- When `execCommand` is enabled:
226
- - **Timeout Protection**: Commands have configurable timeouts
227
- - **Process Isolation**: Commands run in separate processes
228
- - **Error Handling**: Captures both stdout and stderr
229
- - **Security Warning**: Be cautious with command execution in untrusted environments
230
-
231
- ### Network Security
198
+ If you paste `src/worker.ts` (or the exact relevant portions) and `src/cli.ts`, I can tighten any remaining ambiguities (e.g., exact auth config field names and the precise tool/error response shapes).
199
+ # Knowhow Workers Guide
232
200
 
233
- - **Encrypted Connection**: All communication uses WebSocket Secure (WSS)
234
- - **Authentication Required**: Valid Knowhow credentials required
235
- - **Session Management**: Automatic session expiration and renewal
201
+ Knowhow workers allow you to expose your local tools and development environment to the Knowhow platform, enabling remote agents to execute commands, access files, and leverage your local setup through a secure WebSocket connection.
236
202
 
237
203
  ---
238
204
 
239
- ## Integration with Knowhow Behaviors
240
-
241
- ### Creating Worker-Enabled Behaviors
242
-
243
- Behaviors can leverage worker tools through the Knowhow platform:
244
-
245
- ```json
246
- {
247
- "name": "Code Reviewer",
248
- "description": "Reviews code changes and provides feedback",
249
- "instructions": "Use readFile to examine code, textSearch to find patterns, and writeFileChunk to create review comments",
250
- "tools": ["worker_0_readFile", "worker_0_textSearch", "worker_0_writeFileChunk"],
251
- "workers": ["worker_connection_id"]
252
- }
253
- ```
254
-
255
- ### Tool Usage in Agents
256
-
257
- Agents can call worker tools directly:
258
-
259
- ```javascript
260
- // Agent can read local files
261
- const fileContent = await callTool('readFile', {
262
- filePath: './src/components/Header.tsx'
263
- });
264
-
265
- // Search for patterns in codebase
266
- const searchResults = await callTool('textSearch', {
267
- searchTerm: 'useState'
268
- });
269
-
270
- // Apply code changes
271
- await callTool('patchFile', {
272
- filePath: './src/utils/helpers.ts',
273
- patch: `--- a/src/utils/helpers.ts
274
- +++ b/src/utils/helpers.ts
275
- @@ -10,6 +10,7 @@
276
- export function formatDate(date: Date): string {
277
- + if (!date) return '';
278
- return date.toISOString().split('T')[0];
279
- }`
280
- });
281
- ```
282
-
283
- ---
205
+ ## Quick Start
284
206
 
285
- ## Command Line Usage
207
+ ### 1. Initial Setup
286
208
 
287
- ### Basic Commands
209
+ First, authenticate with the Knowhow platform:
288
210
 
289
211
  ```bash
290
- # Authenticate with Knowhow
291
212
  knowhow login
292
-
293
- # Generate worker configuration
294
- knowhow worker
295
-
296
- # Start worker with default config
297
- knowhow worker
298
- ```
299
-
300
- ### Environment Variables
301
-
302
- ---
303
-
304
- ## Troubleshooting
305
-
306
- ### Common Issues
307
-
308
- #### Connection Problems
309
-
310
- **Issue**: Worker fails to connect
311
- ```
312
- Error: WebSocket connection failed
313
213
  ```
314
214
 
315
- **Solutions**:
316
- 1. Check internet connection
317
- 2. Verify authentication: `knowhow login`
318
- 3. Check firewall settings for WebSocket connections
319
-
320
- #### Authentication Errors
321
-
322
- **Issue**: Authentication failed
323
- ```
324
- Error: Invalid credentials
325
- ```
215
+ This will open your browser and guide you through the authentication process.
326
216
 
327
- **Solutions**:
328
- 1. Re-authenticate: `knowhow login`
329
- 2. Check token expiration
330
- 3. Verify organization permissions
217
+ ### 2. Generate Worker Configuration
331
218
 
332
- #### Tool Execution Failures
219
+ Run the worker command to generate the initial configuration:
333
220
 
334
- **Issue**: Tool not found or not allowed
335
- ```
336
- Error: Function readFile not enabled
221
+ ```bash
222
+ knowhow worker
337
223
  ```
338
224
 
339
- **Solutions**:
340
- 1. Add tool to `allowedTools` in `knowhow.json`
341
- 2. Restart worker after configuration changes
342
- 3. Verify tool name spelling
343
-
344
- ## Best Practices
345
-
346
- ### Security
347
-
348
- 1. **Principle of Least Privilege**: Only expose necessary tools
349
- 2. **Regular Audits**: Review `allowedTools` periodically
350
- 3. **Environment Separation**: Use different configurations for dev/prod
351
- 4. **Command Restrictions**: Be cautious with `execCommand` permissions
352
-
353
- ### Development Workflow
354
-
355
- 1. **Version Control**: Include `knowhow.json` in version control
356
- 2. **Team Coordination**: Document tool requirements for team members
357
- 3. **Testing**: Test worker configuration before deploying behaviors
358
- 4. **Documentation**: Document custom tools and their usage
359
-
360
- ### Maintenance
361
- 1. **Regular Updates**: Keep Knowhow CLI updated
362
- 2. **Log Monitoring**: Review worker logs for issues
363
- 3. **Configuration Backup**: Backup working configurations
364
- 4. **Health Checks**: Implement monitoring for worker connectivity
365
-
366
- ---
225
+ This will:
226
+ - Generate a `worker` configuration block in your `knowhow.json`
227
+ - Display available tools that can be exposed
228
+ - Create a secure connection to the Knowhow platform
367
229
 
368
- ## Examples
230
+ ### 3. Configure Allowed Tools
369
231
 
370
- ### Development Environment Setup
232
+ Edit your `knowhow.json` to specify which tools you want to expose:
371
233
 
372
234
  ```json
373
235
  {
@@ -376,30 +238,7 @@ Error: Function readFile not enabled
376
238
  "readFile",
377
239
  "writeFileChunk",
378
240
  "patchFile",
379
- "textSearch",
380
- "fileSearch",
381
- "embeddingSearch",
382
241
  "execCommand",
383
- "lintFile"
384
- ]
385
- },
386
- "mcps": [
387
- {
388
- "name": "browser",
389
- "command": "npx",
390
- "args": ["-y", "@modelcontextprotocol/server-puppeteer"]
391
- }
392
- ]
393
- }
394
- ```
395
-
396
- ### Production Environment (Restricted)
397
-
398
- ```json
399
- {
400
- "worker": {
401
- "allowedTools": [
402
- "readFile",
403
242
  "textSearch",
404
243
  "fileSearch",
405
244
  "embeddingSearch"
@@ -408,18 +247,14 @@ Error: Function readFile not enabled
408
247
  }
409
248
  ```
410
249
 
411
- ### Code Review Workflow
250
+ ### 4. Start the Worker
412
251
 
413
- ```json
414
- {
415
- "worker": {
416
- "allowedTools": [
417
- "readFile",
418
- "textSearch",
419
- "getPullRequest",
420
- "getPullRequestBuildStatuses",
421
- "lintFile"
422
- ]
423
- }
424
- }
252
+ Run the worker again to start the connection:
253
+
254
+ ```bash
255
+ knowhow worker
425
256
  ```
257
+
258
+ Your local tools are now available to Knowhow behaviors and agents!
259
+
260
+