@thoughtflow/codebase 0.2.0

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 (278) hide show
  1. package/dist/contexts/context-decomposer.d.ts +13 -0
  2. package/dist/contexts/context-decomposer.d.ts.map +1 -0
  3. package/dist/contexts/context-decomposer.js +97 -0
  4. package/dist/contexts/context-decomposer.js.map +1 -0
  5. package/dist/contexts/context-document-manager.d.ts +21 -0
  6. package/dist/contexts/context-document-manager.d.ts.map +1 -0
  7. package/dist/contexts/context-document-manager.js +69 -0
  8. package/dist/contexts/context-document-manager.js.map +1 -0
  9. package/dist/contexts/context-router.d.ts +13 -0
  10. package/dist/contexts/context-router.d.ts.map +1 -0
  11. package/dist/contexts/context-router.js +94 -0
  12. package/dist/contexts/context-router.js.map +1 -0
  13. package/dist/index.d.ts +53 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +76 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/libs/codebase/deep-analyzer.d.ts +58 -0
  18. package/dist/libs/codebase/deep-analyzer.d.ts.map +1 -0
  19. package/dist/libs/codebase/deep-analyzer.js +239 -0
  20. package/dist/libs/codebase/deep-analyzer.js.map +1 -0
  21. package/dist/libs/codebase/graph/dependency-extractor.d.ts +20 -0
  22. package/dist/libs/codebase/graph/dependency-extractor.d.ts.map +1 -0
  23. package/dist/libs/codebase/graph/dependency-extractor.js +174 -0
  24. package/dist/libs/codebase/graph/dependency-extractor.js.map +1 -0
  25. package/dist/libs/codebase/graph/graph-analysis.d.ts +42 -0
  26. package/dist/libs/codebase/graph/graph-analysis.d.ts.map +1 -0
  27. package/dist/libs/codebase/graph/graph-analysis.js +222 -0
  28. package/dist/libs/codebase/graph/graph-analysis.js.map +1 -0
  29. package/dist/libs/codebase/graph/graph-visualizer.d.ts +12 -0
  30. package/dist/libs/codebase/graph/graph-visualizer.d.ts.map +1 -0
  31. package/dist/libs/codebase/graph/graph-visualizer.js +99 -0
  32. package/dist/libs/codebase/graph/graph-visualizer.js.map +1 -0
  33. package/dist/libs/codebase/indexer/batch-processor.d.ts +18 -0
  34. package/dist/libs/codebase/indexer/batch-processor.d.ts.map +1 -0
  35. package/dist/libs/codebase/indexer/batch-processor.js +39 -0
  36. package/dist/libs/codebase/indexer/batch-processor.js.map +1 -0
  37. package/dist/libs/codebase/indexer/chunker-markdown.d.ts +19 -0
  38. package/dist/libs/codebase/indexer/chunker-markdown.d.ts.map +1 -0
  39. package/dist/libs/codebase/indexer/chunker-markdown.js +138 -0
  40. package/dist/libs/codebase/indexer/chunker-markdown.js.map +1 -0
  41. package/dist/libs/codebase/indexer/chunker.d.ts +21 -0
  42. package/dist/libs/codebase/indexer/chunker.d.ts.map +1 -0
  43. package/dist/libs/codebase/indexer/chunker.js +133 -0
  44. package/dist/libs/codebase/indexer/chunker.js.map +1 -0
  45. package/dist/libs/codebase/indexer/explorer.d.ts +29 -0
  46. package/dist/libs/codebase/indexer/explorer.d.ts.map +1 -0
  47. package/dist/libs/codebase/indexer/explorer.js +278 -0
  48. package/dist/libs/codebase/indexer/explorer.js.map +1 -0
  49. package/dist/libs/codebase/indexer/indexer.d.ts +35 -0
  50. package/dist/libs/codebase/indexer/indexer.d.ts.map +1 -0
  51. package/dist/libs/codebase/indexer/indexer.js +172 -0
  52. package/dist/libs/codebase/indexer/indexer.js.map +1 -0
  53. package/dist/libs/codebase/knowledge/cross-referencer.d.ts +32 -0
  54. package/dist/libs/codebase/knowledge/cross-referencer.d.ts.map +1 -0
  55. package/dist/libs/codebase/knowledge/cross-referencer.js +132 -0
  56. package/dist/libs/codebase/knowledge/cross-referencer.js.map +1 -0
  57. package/dist/libs/codebase/knowledge/markdown-extractor.d.ts +34 -0
  58. package/dist/libs/codebase/knowledge/markdown-extractor.d.ts.map +1 -0
  59. package/dist/libs/codebase/knowledge/markdown-extractor.js +273 -0
  60. package/dist/libs/codebase/knowledge/markdown-extractor.js.map +1 -0
  61. package/dist/libs/codebase/knowledge/summarizer.d.ts +25 -0
  62. package/dist/libs/codebase/knowledge/summarizer.d.ts.map +1 -0
  63. package/dist/libs/codebase/knowledge/summarizer.js +61 -0
  64. package/dist/libs/codebase/knowledge/summarizer.js.map +1 -0
  65. package/dist/libs/codebase/search/bm25.d.ts +23 -0
  66. package/dist/libs/codebase/search/bm25.d.ts.map +1 -0
  67. package/dist/libs/codebase/search/bm25.js +93 -0
  68. package/dist/libs/codebase/search/bm25.js.map +1 -0
  69. package/dist/libs/codebase/search/hybrid-search.d.ts +22 -0
  70. package/dist/libs/codebase/search/hybrid-search.d.ts.map +1 -0
  71. package/dist/libs/codebase/search/hybrid-search.js +80 -0
  72. package/dist/libs/codebase/search/hybrid-search.js.map +1 -0
  73. package/dist/libs/codebase-index.class.d.ts +66 -0
  74. package/dist/libs/codebase-index.class.d.ts.map +1 -0
  75. package/dist/libs/codebase-index.class.js +595 -0
  76. package/dist/libs/codebase-index.class.js.map +1 -0
  77. package/dist/tools/codebase/codebase-analyze.tool.d.ts +8 -0
  78. package/dist/tools/codebase/codebase-analyze.tool.d.ts.map +1 -0
  79. package/dist/tools/codebase/codebase-analyze.tool.js +20 -0
  80. package/dist/tools/codebase/codebase-analyze.tool.js.map +1 -0
  81. package/dist/tools/codebase/codebase-crossref.tool.d.ts +8 -0
  82. package/dist/tools/codebase/codebase-crossref.tool.d.ts.map +1 -0
  83. package/dist/tools/codebase/codebase-crossref.tool.js +20 -0
  84. package/dist/tools/codebase/codebase-crossref.tool.js.map +1 -0
  85. package/dist/tools/codebase/codebase-flow.tool.d.ts +8 -0
  86. package/dist/tools/codebase/codebase-flow.tool.d.ts.map +1 -0
  87. package/dist/tools/codebase/codebase-flow.tool.js +20 -0
  88. package/dist/tools/codebase/codebase-flow.tool.js.map +1 -0
  89. package/dist/tools/codebase/codebase-graph-circular.tool.d.ts +8 -0
  90. package/dist/tools/codebase/codebase-graph-circular.tool.d.ts.map +1 -0
  91. package/dist/tools/codebase/codebase-graph-circular.tool.js +17 -0
  92. package/dist/tools/codebase/codebase-graph-circular.tool.js.map +1 -0
  93. package/dist/tools/codebase/codebase-graph-query.tool.d.ts +8 -0
  94. package/dist/tools/codebase/codebase-graph-query.tool.d.ts.map +1 -0
  95. package/dist/tools/codebase/codebase-graph-query.tool.js +21 -0
  96. package/dist/tools/codebase/codebase-graph-query.tool.js.map +1 -0
  97. package/dist/tools/codebase/codebase-graph-stats.tool.d.ts +8 -0
  98. package/dist/tools/codebase/codebase-graph-stats.tool.d.ts.map +1 -0
  99. package/dist/tools/codebase/codebase-graph-stats.tool.js +17 -0
  100. package/dist/tools/codebase/codebase-graph-stats.tool.js.map +1 -0
  101. package/dist/tools/codebase/codebase-graph-visualize.tool.d.ts +8 -0
  102. package/dist/tools/codebase/codebase-graph-visualize.tool.d.ts.map +1 -0
  103. package/dist/tools/codebase/codebase-graph-visualize.tool.js +21 -0
  104. package/dist/tools/codebase/codebase-graph-visualize.tool.js.map +1 -0
  105. package/dist/tools/codebase/codebase-impact.tool.d.ts +8 -0
  106. package/dist/tools/codebase/codebase-impact.tool.d.ts.map +1 -0
  107. package/dist/tools/codebase/codebase-impact.tool.js +21 -0
  108. package/dist/tools/codebase/codebase-impact.tool.js.map +1 -0
  109. package/dist/tools/codebase/codebase-index.tool.d.ts +8 -0
  110. package/dist/tools/codebase/codebase-index.tool.d.ts.map +1 -0
  111. package/dist/tools/codebase/codebase-index.tool.js +21 -0
  112. package/dist/tools/codebase/codebase-index.tool.js.map +1 -0
  113. package/dist/tools/codebase/codebase-knowledge.tool.d.ts +8 -0
  114. package/dist/tools/codebase/codebase-knowledge.tool.d.ts.map +1 -0
  115. package/dist/tools/codebase/codebase-knowledge.tool.js +22 -0
  116. package/dist/tools/codebase/codebase-knowledge.tool.js.map +1 -0
  117. package/dist/tools/codebase/codebase-search.tool.d.ts +8 -0
  118. package/dist/tools/codebase/codebase-search.tool.d.ts.map +1 -0
  119. package/dist/tools/codebase/codebase-search.tool.js +24 -0
  120. package/dist/tools/codebase/codebase-search.tool.js.map +1 -0
  121. package/dist/tools/codebase/codebase-status.tool.d.ts +8 -0
  122. package/dist/tools/codebase/codebase-status.tool.d.ts.map +1 -0
  123. package/dist/tools/codebase/codebase-status.tool.js +19 -0
  124. package/dist/tools/codebase/codebase-status.tool.js.map +1 -0
  125. package/dist/tools/neural/comparative-analysis.tool.d.ts +37 -0
  126. package/dist/tools/neural/comparative-analysis.tool.d.ts.map +1 -0
  127. package/dist/tools/neural/comparative-analysis.tool.js +241 -0
  128. package/dist/tools/neural/comparative-analysis.tool.js.map +1 -0
  129. package/dist/tools/neural/index.d.ts +12 -0
  130. package/dist/tools/neural/index.d.ts.map +1 -0
  131. package/dist/tools/neural/index.js +28 -0
  132. package/dist/tools/neural/index.js.map +1 -0
  133. package/dist/tools/neural/neural-deadcode.tool.d.ts +10 -0
  134. package/dist/tools/neural/neural-deadcode.tool.d.ts.map +1 -0
  135. package/dist/tools/neural/neural-deadcode.tool.js +133 -0
  136. package/dist/tools/neural/neural-deadcode.tool.js.map +1 -0
  137. package/dist/tools/neural/neural-debug.tool.d.ts +11 -0
  138. package/dist/tools/neural/neural-debug.tool.d.ts.map +1 -0
  139. package/dist/tools/neural/neural-debug.tool.js +205 -0
  140. package/dist/tools/neural/neural-debug.tool.js.map +1 -0
  141. package/dist/tools/neural/neural-explain.tool.d.ts +9 -0
  142. package/dist/tools/neural/neural-explain.tool.d.ts.map +1 -0
  143. package/dist/tools/neural/neural-explain.tool.js +100 -0
  144. package/dist/tools/neural/neural-explain.tool.js.map +1 -0
  145. package/dist/tools/neural/neural-optimize.tool.d.ts +9 -0
  146. package/dist/tools/neural/neural-optimize.tool.d.ts.map +1 -0
  147. package/dist/tools/neural/neural-optimize.tool.js +117 -0
  148. package/dist/tools/neural/neural-optimize.tool.js.map +1 -0
  149. package/dist/tools/neural/neural-pattern.tool.d.ts +10 -0
  150. package/dist/tools/neural/neural-pattern.tool.d.ts.map +1 -0
  151. package/dist/tools/neural/neural-pattern.tool.js +169 -0
  152. package/dist/tools/neural/neural-pattern.tool.js.map +1 -0
  153. package/dist/tools/neural/neural-review.tool.d.ts +11 -0
  154. package/dist/tools/neural/neural-review.tool.d.ts.map +1 -0
  155. package/dist/tools/neural/neural-review.tool.js +152 -0
  156. package/dist/tools/neural/neural-review.tool.js.map +1 -0
  157. package/dist/tools/neural/neural-security.tool.d.ts +16 -0
  158. package/dist/tools/neural/neural-security.tool.d.ts.map +1 -0
  159. package/dist/tools/neural/neural-security.tool.js +256 -0
  160. package/dist/tools/neural/neural-security.tool.js.map +1 -0
  161. package/dist/tools/neural/neural-similar.tool.d.ts +9 -0
  162. package/dist/tools/neural/neural-similar.tool.d.ts.map +1 -0
  163. package/dist/tools/neural/neural-similar.tool.js +139 -0
  164. package/dist/tools/neural/neural-similar.tool.js.map +1 -0
  165. package/dist/tools/neural/neural-smells.tool.d.ts +9 -0
  166. package/dist/tools/neural/neural-smells.tool.d.ts.map +1 -0
  167. package/dist/tools/neural/neural-smells.tool.js +123 -0
  168. package/dist/tools/neural/neural-smells.tool.js.map +1 -0
  169. package/dist/tools/neural/neural-suggest.tool.d.ts +9 -0
  170. package/dist/tools/neural/neural-suggest.tool.d.ts.map +1 -0
  171. package/dist/tools/neural/neural-suggest.tool.js +64 -0
  172. package/dist/tools/neural/neural-suggest.tool.js.map +1 -0
  173. package/dist/tools/quality/index.d.ts +8 -0
  174. package/dist/tools/quality/index.d.ts.map +1 -0
  175. package/dist/tools/quality/index.js +24 -0
  176. package/dist/tools/quality/index.js.map +1 -0
  177. package/dist/tools/quality/quality-complexity.tool.d.ts +11 -0
  178. package/dist/tools/quality/quality-complexity.tool.d.ts.map +1 -0
  179. package/dist/tools/quality/quality-complexity.tool.js +152 -0
  180. package/dist/tools/quality/quality-complexity.tool.js.map +1 -0
  181. package/dist/tools/quality/quality-coupling.tool.d.ts +9 -0
  182. package/dist/tools/quality/quality-coupling.tool.d.ts.map +1 -0
  183. package/dist/tools/quality/quality-coupling.tool.js +51 -0
  184. package/dist/tools/quality/quality-coupling.tool.js.map +1 -0
  185. package/dist/tools/quality/quality-coverage.tool.d.ts +9 -0
  186. package/dist/tools/quality/quality-coverage.tool.d.ts.map +1 -0
  187. package/dist/tools/quality/quality-coverage.tool.js +104 -0
  188. package/dist/tools/quality/quality-coverage.tool.js.map +1 -0
  189. package/dist/tools/quality/quality-deps.tool.d.ts +11 -0
  190. package/dist/tools/quality/quality-deps.tool.d.ts.map +1 -0
  191. package/dist/tools/quality/quality-deps.tool.js +119 -0
  192. package/dist/tools/quality/quality-deps.tool.js.map +1 -0
  193. package/dist/tools/quality/quality-duplication.tool.d.ts +9 -0
  194. package/dist/tools/quality/quality-duplication.tool.d.ts.map +1 -0
  195. package/dist/tools/quality/quality-duplication.tool.js +100 -0
  196. package/dist/tools/quality/quality-duplication.tool.js.map +1 -0
  197. package/dist/tools/quality/quality-size.tool.d.ts +9 -0
  198. package/dist/tools/quality/quality-size.tool.d.ts.map +1 -0
  199. package/dist/tools/quality/quality-size.tool.js +94 -0
  200. package/dist/tools/quality/quality-size.tool.js.map +1 -0
  201. package/dist/tools/quality/quality-types.tool.d.ts +9 -0
  202. package/dist/tools/quality/quality-types.tool.d.ts.map +1 -0
  203. package/dist/tools/quality/quality-types.tool.js +95 -0
  204. package/dist/tools/quality/quality-types.tool.js.map +1 -0
  205. package/dist/tools/workspace/analyze-project.tool.d.ts +36 -0
  206. package/dist/tools/workspace/analyze-project.tool.d.ts.map +1 -0
  207. package/dist/tools/workspace/analyze-project.tool.js +454 -0
  208. package/dist/tools/workspace/analyze-project.tool.js.map +1 -0
  209. package/dist/tools/workspace/codebase-research.tool.d.ts +10 -0
  210. package/dist/tools/workspace/codebase-research.tool.d.ts.map +1 -0
  211. package/dist/tools/workspace/codebase-research.tool.js +89 -0
  212. package/dist/tools/workspace/codebase-research.tool.js.map +1 -0
  213. package/dist/tools/workspace/project-scanner.tool.d.ts +55 -0
  214. package/dist/tools/workspace/project-scanner.tool.d.ts.map +1 -0
  215. package/dist/tools/workspace/project-scanner.tool.js +978 -0
  216. package/dist/tools/workspace/project-scanner.tool.js.map +1 -0
  217. package/dist/tools/workspace/search-code.tool.d.ts +14 -0
  218. package/dist/tools/workspace/search-code.tool.d.ts.map +1 -0
  219. package/dist/tools/workspace/search-code.tool.js +286 -0
  220. package/dist/tools/workspace/search-code.tool.js.map +1 -0
  221. package/package.json +17 -0
  222. package/src/contexts/context-decomposer.ts +113 -0
  223. package/src/contexts/context-document-manager.ts +70 -0
  224. package/src/contexts/context-router.ts +121 -0
  225. package/src/index.ts +65 -0
  226. package/src/libs/codebase/deep-analyzer.ts +287 -0
  227. package/src/libs/codebase/graph/dependency-extractor.ts +165 -0
  228. package/src/libs/codebase/graph/graph-analysis.ts +231 -0
  229. package/src/libs/codebase/graph/graph-visualizer.ts +124 -0
  230. package/src/libs/codebase/indexer/batch-processor.ts +47 -0
  231. package/src/libs/codebase/indexer/chunker-markdown.ts +175 -0
  232. package/src/libs/codebase/indexer/chunker.ts +126 -0
  233. package/src/libs/codebase/indexer/explorer.ts +269 -0
  234. package/src/libs/codebase/indexer/indexer.ts +174 -0
  235. package/src/libs/codebase/knowledge/cross-referencer.ts +182 -0
  236. package/src/libs/codebase/knowledge/markdown-extractor.ts +270 -0
  237. package/src/libs/codebase/knowledge/summarizer.ts +85 -0
  238. package/src/libs/codebase/search/bm25.ts +109 -0
  239. package/src/libs/codebase/search/hybrid-search.ts +109 -0
  240. package/src/libs/codebase-index.class.ts +715 -0
  241. package/src/tools/codebase/codebase-analyze.tool.ts +18 -0
  242. package/src/tools/codebase/codebase-crossref.tool.ts +18 -0
  243. package/src/tools/codebase/codebase-flow.tool.ts +18 -0
  244. package/src/tools/codebase/codebase-graph-circular.tool.ts +15 -0
  245. package/src/tools/codebase/codebase-graph-query.tool.ts +19 -0
  246. package/src/tools/codebase/codebase-graph-stats.tool.ts +15 -0
  247. package/src/tools/codebase/codebase-graph-visualize.tool.ts +19 -0
  248. package/src/tools/codebase/codebase-impact.tool.ts +19 -0
  249. package/src/tools/codebase/codebase-index.tool.ts +19 -0
  250. package/src/tools/codebase/codebase-knowledge.tool.ts +20 -0
  251. package/src/tools/codebase/codebase-search.tool.ts +22 -0
  252. package/src/tools/codebase/codebase-status.tool.ts +17 -0
  253. package/src/tools/neural/comparative-analysis.tool.ts +309 -0
  254. package/src/tools/neural/index.ts +11 -0
  255. package/src/tools/neural/neural-deadcode.tool.ts +105 -0
  256. package/src/tools/neural/neural-debug.tool.ts +199 -0
  257. package/src/tools/neural/neural-explain.tool.ts +67 -0
  258. package/src/tools/neural/neural-optimize.tool.ts +93 -0
  259. package/src/tools/neural/neural-pattern.tool.ts +141 -0
  260. package/src/tools/neural/neural-review.tool.ts +145 -0
  261. package/src/tools/neural/neural-security.tool.ts +226 -0
  262. package/src/tools/neural/neural-similar.tool.ts +113 -0
  263. package/src/tools/neural/neural-smells.tool.ts +98 -0
  264. package/src/tools/neural/neural-suggest.tool.ts +65 -0
  265. package/src/tools/quality/index.ts +7 -0
  266. package/src/tools/quality/quality-complexity.tool.ts +132 -0
  267. package/src/tools/quality/quality-coupling.tool.ts +57 -0
  268. package/src/tools/quality/quality-coverage.tool.ts +78 -0
  269. package/src/tools/quality/quality-deps.tool.ts +89 -0
  270. package/src/tools/quality/quality-duplication.tool.ts +71 -0
  271. package/src/tools/quality/quality-size.tool.ts +66 -0
  272. package/src/tools/quality/quality-types.tool.ts +66 -0
  273. package/src/tools/workspace/analyze-project.tool.ts +429 -0
  274. package/src/tools/workspace/codebase-research.tool.ts +100 -0
  275. package/src/tools/workspace/project-scanner.tool.ts +1058 -0
  276. package/src/tools/workspace/search-code.tool.ts +344 -0
  277. package/tsconfig.build.json +12 -0
  278. package/tsconfig.json +9 -0
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NeuralDebugTool = void 0;
37
+ const zod_1 = require("zod");
38
+ const core_1 = require("@thoughtflow/core");
39
+ const dependency_extractor_1 = require("../../libs/codebase/graph/dependency-extractor");
40
+ const explorer_1 = require("../../libs/codebase/indexer/explorer");
41
+ const fs = __importStar(require("node:fs"));
42
+ const path = __importStar(require("node:path"));
43
+ const DebugResultSchema = zod_1.z.object({
44
+ errorType: zod_1.z.string(),
45
+ rootCause: zod_1.z.string(),
46
+ suggestedFix: zod_1.z.string(),
47
+ codeFixExample: zod_1.z.string().optional(),
48
+ affectedFiles: zod_1.z.array(zod_1.z.string()),
49
+ confidence: zod_1.z.enum(["high", "medium", "low"]),
50
+ });
51
+ class NeuralDebugTool extends core_1.ToolBase {
52
+ name = "neuralDebug";
53
+ description = "Analyze a stack trace or error against the codebase to suggest a fix. Parses stack frames, finds relevant source files, extracts context, and uses LLM to propose solutions.";
54
+ readonly = true;
55
+ constructor() {
56
+ super(zod_1.z.object({
57
+ error: zod_1.z.string().describe("Stack trace or error message"),
58
+ projectPath: zod_1.z.string().optional(),
59
+ maxFrames: zod_1.z.number().optional().describe("Max stack frames to analyze"),
60
+ }));
61
+ }
62
+ async run(input, ctx) {
63
+ const { error, maxFrames } = input;
64
+ const rootPath = input.projectPath ?? process.cwd();
65
+ const max = maxFrames ?? 5;
66
+ const frames = this.parseStackTrace(error, rootPath);
67
+ const relevantFrames = frames.slice(0, max);
68
+ const analysis = [];
69
+ for (const frame of relevantFrames) {
70
+ const absolutePath = path.join(rootPath, frame.file);
71
+ if (!fs.existsSync(absolutePath))
72
+ continue;
73
+ const content = fs.readFileSync(absolutePath, "utf8");
74
+ const lines = content.split("\n");
75
+ const start = Math.max(0, frame.line - 10);
76
+ const end = Math.min(lines.length, frame.line + 10);
77
+ const context = lines.slice(start, end)
78
+ .map((l, i) => `${start + i + 1}: ${l}`)
79
+ .join("\n");
80
+ const suggestions = this.staticAnalyzeContext(lines, frame.line, frame.message);
81
+ analysis.push({ file: frame.file, line: frame.line, column: frame.column, context, suggestions });
82
+ }
83
+ const explorer = new explorer_1.CodebaseExplorer();
84
+ const files = explorer.explore({ rootPath });
85
+ const codeFiles = files.filter((f) => f.classification === "source-code")
86
+ .map((f) => ({ relativePath: f.relativePath, absolutePath: f.absolutePath }));
87
+ const depExtractor = new dependency_extractor_1.DependencyExtractor();
88
+ const graph = await depExtractor.buildGraph(codeFiles, rootPath);
89
+ const affectedFiles = new Set();
90
+ for (const frame of relevantFrames) {
91
+ affectedFiles.add(frame.file);
92
+ const dependents = graph.edges.filter((e) => e.to === frame.file);
93
+ for (const dep of dependents.slice(0, 5)) {
94
+ affectedFiles.add(dep.from);
95
+ }
96
+ }
97
+ const callStructured = ctx.conversation?.callStructured;
98
+ if (!callStructured) {
99
+ return {
100
+ success: true,
101
+ output: JSON.stringify({
102
+ error: error.split("\n")[0],
103
+ framesAnalyzed: analysis.length,
104
+ totalFrames: frames.length,
105
+ affectedFiles: Array.from(affectedFiles).slice(0, 15),
106
+ analysis,
107
+ llmUsed: false,
108
+ }),
109
+ };
110
+ }
111
+ const codeContext = analysis
112
+ .map((a) => `=== ${a.file}:${a.line} ===\n${a.context}`)
113
+ .join("\n\n")
114
+ .slice(0, 8000);
115
+ const prompt = `You are an expert software debugger. Analyze the stack trace and source code context, then provide a structured root cause analysis, a concrete suggested fix with code example, and list of affected files.
116
+
117
+ ERROR:
118
+ ${error}
119
+
120
+ RELEVANT SOURCE CODE:
121
+ ${codeContext}
122
+
123
+ STATIC ANALYSIS HINTS:
124
+ ${analysis.map((a) => `- ${a.file}:${a.line}: ${a.suggestions.join("; ")}`).join("\n")}`;
125
+ try {
126
+ const result = await callStructured(prompt, DebugResultSchema);
127
+ return {
128
+ success: true,
129
+ output: JSON.stringify({
130
+ ...result,
131
+ stackFrames: frames.length,
132
+ relevantFiles: relevantFrames.map((f) => f.file),
133
+ affectedFiles: Array.from(affectedFiles).slice(0, 15),
134
+ filesAnalyzed: analysis.length,
135
+ llmUsed: true,
136
+ }),
137
+ };
138
+ }
139
+ catch {
140
+ return {
141
+ success: true,
142
+ output: JSON.stringify({
143
+ error: error.split("\n")[0],
144
+ stackFrames: frames.length,
145
+ relevantFiles: relevantFrames.map((f) => f.file),
146
+ affectedFiles: Array.from(affectedFiles).slice(0, 15),
147
+ analysis,
148
+ llmUsed: false,
149
+ }),
150
+ };
151
+ }
152
+ }
153
+ parseStackTrace(error, rootPath) {
154
+ const frames = [];
155
+ const lines = error.split("\n");
156
+ const message = lines[0];
157
+ const patterns = [
158
+ /at\s+(?:async\s+)?(?:\S+\s+)?\(?(.+?):(\d+):(\d+)\)?/g,
159
+ /at\s+(.+?):(\d+):(\d+)/g,
160
+ ];
161
+ for (const line of lines) {
162
+ for (const pattern of patterns) {
163
+ pattern.lastIndex = 0;
164
+ let match;
165
+ while ((match = pattern.exec(line)) !== null) {
166
+ const file = match[1].replace(/^file:\/\//, "");
167
+ const lineNum = parseInt(match[2], 10);
168
+ const col = match[3] ? parseInt(match[3], 10) : undefined;
169
+ if (file.includes("node_modules") || file.includes("node:"))
170
+ continue;
171
+ const relative = file.startsWith(rootPath)
172
+ ? path.relative(rootPath, file)
173
+ : file;
174
+ frames.push({ file: relative, line: lineNum, column: col, message });
175
+ }
176
+ }
177
+ }
178
+ return frames;
179
+ }
180
+ staticAnalyzeContext(lines, lineNum, errorMsg) {
181
+ const suggestions = [];
182
+ const targetLine = lines[lineNum - 1] ?? "";
183
+ if (targetLine.trim().startsWith("//") || targetLine.trim().startsWith("/*")) {
184
+ suggestions.push("Error on a comment line — check preceding/succeeding code");
185
+ }
186
+ if (targetLine.includes("undefined") || targetLine.includes("null")) {
187
+ suggestions.push("Possible null/undefined access — add null check or optional chaining");
188
+ }
189
+ if (targetLine.includes(".map(") || targetLine.includes(".filter(") || targetLine.includes(".find(")) {
190
+ suggestions.push("Array method may be called on undefined — ensure array is initialized");
191
+ }
192
+ if (targetLine.includes("await")) {
193
+ suggestions.push("Async operation — verify error handling with try/catch or .catch()");
194
+ }
195
+ if (targetLine.includes("import")) {
196
+ suggestions.push("Import resolution error — check file path, extension, and module existence");
197
+ }
198
+ if (suggestions.length === 0) {
199
+ suggestions.push("Review the surrounding context for variable initialization and error handling");
200
+ }
201
+ return suggestions;
202
+ }
203
+ }
204
+ exports.NeuralDebugTool = NeuralDebugTool;
205
+ //# sourceMappingURL=neural-debug.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-debug.tool.js","sourceRoot":"","sources":["../../../src/tools/neural/neural-debug.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAwB;AACxB,4CAA+E;AAC/E,yFAAqF;AACrF,mEAAwE;AACxE,4CAA8B;AAC9B,gDAAkC;AAElC,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;I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AQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrG,WAAW,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAC;QAC5F,CAAC;QAED,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,WAAW,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;QACzF,CAAC;QAED,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,WAAW,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;QACjG,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,WAAW,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QACpG,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AApLD,0CAoLC"}
@@ -0,0 +1,9 @@
1
+ import { ToolBase, ToolContext, ToolExecutionResult } from "@thoughtflow/core";
2
+ export declare class NeuralExplainTool extends ToolBase {
3
+ readonly name = "neuralExplain";
4
+ readonly description = "Explain any code snippet, function, or file in natural language. Uses LLM to provide clear, educational explanations of what the code does, its purpose, and how it works.";
5
+ readonly readonly = true;
6
+ constructor();
7
+ run(input: Record<string, unknown>, ctx: ToolContext): Promise<ToolExecutionResult>;
8
+ }
9
+ //# sourceMappingURL=neural-explain.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-explain.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/neural/neural-explain.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI/E,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,IAAI,mBAAmB;IAChC,QAAQ,CAAC,WAAW,gLAAgL;IACpM,SAAkB,QAAQ,QAAQ;;IAU5B,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAgD1F"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NeuralExplainTool = void 0;
37
+ const zod_1 = require("zod");
38
+ const core_1 = require("@thoughtflow/core");
39
+ const fs = __importStar(require("node:fs"));
40
+ const path = __importStar(require("node:path"));
41
+ class NeuralExplainTool extends core_1.ToolBase {
42
+ name = "neuralExplain";
43
+ description = "Explain any code snippet, function, or file in natural language. Uses LLM to provide clear, educational explanations of what the code does, its purpose, and how it works.";
44
+ readonly = true;
45
+ constructor() {
46
+ super(zod_1.z.object({
47
+ target: zod_1.z.string().describe("File path, function name, or code snippet to explain"),
48
+ detail: zod_1.z.enum(["brief", "detailed", "tutorial"]).optional().describe("Level of detail (default: detailed)"),
49
+ projectPath: zod_1.z.string().optional(),
50
+ }));
51
+ }
52
+ async run(input, ctx) {
53
+ const { target, detail } = input;
54
+ const rootPath = input.projectPath ?? process.cwd();
55
+ const level = detail ?? "detailed";
56
+ let codeToExplain = target;
57
+ const fullPath = path.join(rootPath, target);
58
+ try {
59
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
60
+ codeToExplain = fs.readFileSync(fullPath, "utf8").slice(0, 8000);
61
+ }
62
+ }
63
+ catch {
64
+ /* use target as-is */
65
+ }
66
+ const callStructured = ctx.conversation?.callStructured;
67
+ if (!callStructured) {
68
+ return {
69
+ success: true,
70
+ output: JSON.stringify({
71
+ explanation: "LLM not available — raw code provided for manual review",
72
+ code: codeToExplain.slice(0, 500),
73
+ level,
74
+ }),
75
+ };
76
+ }
77
+ const prompt = level === "brief"
78
+ ? `Explain this code in 1-2 sentences:\n\n\`\`\`\n${codeToExplain}\n\`\`\``
79
+ : level === "tutorial"
80
+ ? `Explain this code as a step-by-step tutorial for beginners. Cover what it does, why each part exists, and how each piece works together:\n\n\`\`\`\n${codeToExplain}\n\`\`\``
81
+ : `Explain this code in detail — what it does, its purpose, key design decisions, and how it fits into the larger system. Cover the logic flow, data transformations, and any notable patterns:\n\n\`\`\`\n${codeToExplain}\n\`\`\``;
82
+ try {
83
+ const result = await callStructured(prompt, zod_1.z.object({ explanation: zod_1.z.string() }));
84
+ const data = result;
85
+ return { success: true, output: data.explanation ?? "No explanation generated" };
86
+ }
87
+ catch (err) {
88
+ return {
89
+ success: true,
90
+ output: JSON.stringify({
91
+ explanation: `Failed to generate explanation: ${err instanceof Error ? err.message : "Unknown error"}`,
92
+ code: codeToExplain.slice(0, 500),
93
+ level,
94
+ }),
95
+ };
96
+ }
97
+ }
98
+ }
99
+ exports.NeuralExplainTool = NeuralExplainTool;
100
+ //# sourceMappingURL=neural-explain.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-explain.tool.js","sourceRoot":"","sources":["../../../src/tools/neural/neural-explain.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAwB;AACxB,4CAA+E;AAC/E,4CAA8B;AAC9B,gDAAkC;AAElC,MAAa,iBAAkB,SAAQ,eAAQ;IACpC,IAAI,GAAG,eAAe,CAAC;IACvB,WAAW,GAAG,4KAA4K,CAAC;IAClL,QAAQ,GAAG,IAAI,CAAC;IAElC;QACE,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC;YACb,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;YACnF,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;YAC5G,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACnC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAA8B,EAAE,GAAgB;QACxD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAA4C,CAAC;QACxE,MAAM,QAAQ,GAAI,KAAK,CAAC,WAAsB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChE,MAAM,KAAK,GAAG,MAAM,IAAI,UAAU,CAAC;QAEnC,IAAI,aAAa,GAAG,MAAM,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC;YACH,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,M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,CAAC,CAAC,eAAe,EAAE;oBACtG,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;oBACjC,KAAK;iBACN,CAAC;aACH,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA7DD,8CA6DC"}
@@ -0,0 +1,9 @@
1
+ import { ToolBase, ToolContext, ToolExecutionResult } from "@thoughtflow/core";
2
+ export declare class NeuralOptimizeTool extends ToolBase {
3
+ readonly name = "neuralOptimize";
4
+ readonly description = "AI-powered performance optimization. Combines static pattern detection (N+1 queries, sync-in-async, missing memoization) with LLM semantic analysis of hot-path inefficiencies. Provides concrete fix suggestions with estimated impact.";
5
+ readonly readonly = true;
6
+ constructor();
7
+ run(input: Record<string, unknown>, ctx: ToolContext): Promise<ToolExecutionResult>;
8
+ }
9
+ //# sourceMappingURL=neural-optimize.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-optimize.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/neural/neural-optimize.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAa/E,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,WAAW,8OAA8O;IAClQ,SAAkB,QAAQ,QAAQ;;IAS5B,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAkE1F"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NeuralOptimizeTool = void 0;
37
+ const zod_1 = require("zod");
38
+ const core_1 = require("@thoughtflow/core");
39
+ const explorer_1 = require("../../libs/codebase/indexer/explorer");
40
+ const fs = __importStar(require("node:fs"));
41
+ const OptimizeSuggestionSchema = zod_1.z.object({
42
+ category: zod_1.z.string(),
43
+ severity: zod_1.z.enum(["high", "medium", "low"]),
44
+ message: zod_1.z.string(),
45
+ fix: zod_1.z.string(),
46
+ estimatedImpact: zod_1.z.string(),
47
+ });
48
+ class NeuralOptimizeTool extends core_1.ToolBase {
49
+ name = "neuralOptimize";
50
+ description = "AI-powered performance optimization. Combines static pattern detection (N+1 queries, sync-in-async, missing memoization) with LLM semantic analysis of hot-path inefficiencies. Provides concrete fix suggestions with estimated impact.";
51
+ readonly = true;
52
+ constructor() {
53
+ super(zod_1.z.object({
54
+ target: zod_1.z.string().optional().describe("File path or leave empty for worst offenders"),
55
+ projectPath: zod_1.z.string().optional(),
56
+ }));
57
+ }
58
+ async run(input, ctx) {
59
+ const rootPath = input.projectPath ?? process.cwd();
60
+ const target = input.target || undefined;
61
+ const explorer = new explorer_1.CodebaseExplorer();
62
+ const files = explorer.explore({ rootPath });
63
+ const scanFiles = target
64
+ ? files.filter((f) => f.relativePath.includes(target)).slice(0, 5)
65
+ : files.filter((f) => f.classification === "source-code").slice(0, 20);
66
+ const staticIssues = [];
67
+ for (const file of scanFiles) {
68
+ const content = fs.readFileSync(file.absolutePath, "utf8");
69
+ const lines = content.split("\n");
70
+ for (let i = 0; i < lines.length; i++) {
71
+ const surrounding = lines.slice(Math.max(0, i - 3), i + 3).join("\n");
72
+ if (lines[i].match(/\.findMany|\.findFirst|\.findUnique|\.query|\.execute/) && surrounding.match(/for\s*\(|forEach|\.map\s*\(/)) {
73
+ staticIssues.push({ category: "n+1", severity: "high", file: file.relativePath, line: i + 1, message: "Database query inside loop — potential N+1 problem", fix: "Use batch query, eager loading (include), or DataLoader", estimatedImpact: "Can reduce DB calls from N to 1" });
74
+ }
75
+ if (lines[i].includes("await") && surrounding.match(/for\s*\(.*of/) && lines[i].match(/await\s+\w+/)) {
76
+ staticIssues.push({ category: "sequential-async", severity: "medium", file: file.relativePath, line: i + 1, message: "Sequential awaits in loop — can parallelize", fix: "Use Promise.all() for independent async operations", estimatedImpact: "Can reduce total time by factor of N" });
77
+ }
78
+ }
79
+ if (content.match(/\.filter|\.sort|\.reduce/) && !content.includes("useMemo") && !content.includes("useCallback") && (file.relativePath.endsWith(".tsx") || file.relativePath.endsWith(".jsx"))) {
80
+ staticIssues.push({ category: "missing-memo", severity: "medium", file: file.relativePath, message: "Expensive computation in render without memoization", fix: "Wrap in useMemo/useCallback", estimatedImpact: "Can prevent unnecessary re-renders" });
81
+ }
82
+ }
83
+ const cs = ctx.conversation?.callStructured;
84
+ if (!cs) {
85
+ return { success: true, output: JSON.stringify({ filesScanned: scanFiles.length, issuesFound: staticIssues.length, issues: staticIssues }) };
86
+ }
87
+ const codeSnippets = scanFiles.filter((f) => {
88
+ const c = fs.readFileSync(f.absolutePath, "utf8");
89
+ return c.includes("await") || c.includes(".find") || c.includes(".map") || c.includes("for");
90
+ }).slice(0, 3).map((f) => {
91
+ const c = fs.readFileSync(f.absolutePath, "utf8").slice(0, 3000);
92
+ return `--- ${f.relativePath} ---\n${c}`;
93
+ }).join("\n\n");
94
+ if (!codeSnippets) {
95
+ return { success: true, output: JSON.stringify({ filesScanned: scanFiles.length, issuesFound: staticIssues.length, issues: staticIssues }) };
96
+ }
97
+ const prompt = `Analyze this code for performance optimization opportunities: N+1 queries, missing caching/memoization, unnecessary re-renders, expensive operations in hot paths, sync operations in async contexts, large dependency imports, unnecessary closures, unbatched state updates, premature materialization of large collections, missing lazy evaluation.\n\n${codeSnippets}\n\nReturn structured suggestions with severity and estimated impact.`;
98
+ try {
99
+ const result = await cs(prompt, zod_1.z.object({ suggestions: zod_1.z.array(OptimizeSuggestionSchema) }));
100
+ const llmIssues = (result.suggestions ?? []).map((s) => ({
101
+ category: s.category,
102
+ severity: s.severity,
103
+ file: target ?? "",
104
+ message: s.message,
105
+ fix: s.fix,
106
+ estimatedImpact: s.estimatedImpact,
107
+ }));
108
+ const allIssues = [...staticIssues, ...llmIssues];
109
+ return { success: true, output: JSON.stringify({ filesScanned: scanFiles.length, issuesFound: allIssues.length, issues: allIssues.slice(0, 20) }) };
110
+ }
111
+ catch {
112
+ return { success: true, output: JSON.stringify({ filesScanned: scanFiles.length, issuesFound: staticIssues.length, issues: staticIssues }) };
113
+ }
114
+ }
115
+ }
116
+ exports.NeuralOptimizeTool = NeuralOptimizeTool;
117
+ //# sourceMappingURL=neural-optimize.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-optimize.tool.js","sourceRoot":"","sources":["../../../src/tools/neural/neural-optimize.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAwB;AACxB,4CAA+E;AA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,EAAE,CAAC,CAAC,QAAQ;gBACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,IAAI,EAAE,MAAM,IAAI,EAAE;gBAClB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,GAAG,EAAE,CAAC,CAAC,GAAG;gBACV,eAAe,EAAE,CAAC,CAAC,eAAe;aACnC,CAAC,CAAC,CAAC;YACJ,MAAM,SAAS,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,CAAC,CAAC;YAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACtJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;QAC/I,CAAC;IACH,CAAC;CACF;AA9ED,gDA8EC"}
@@ -0,0 +1,10 @@
1
+ import { ToolBase, ToolContext, ToolExecutionResult } from "@thoughtflow/core";
2
+ export declare class NeuralPatternTool extends ToolBase {
3
+ readonly name = "neuralPattern";
4
+ readonly description = "Recognize design patterns used in the codebase using static analysis and LLM verification. Detects Singleton, Factory, Observer, Strategy, Decorator, Repository, Adapter, Builder, Command, Mediator, Chain of Responsibility, and more.";
5
+ readonly readonly = true;
6
+ constructor();
7
+ run(input: Record<string, unknown>, ctx: ToolContext): Promise<ToolExecutionResult>;
8
+ private detectPatterns;
9
+ }
10
+ //# sourceMappingURL=neural-pattern.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-pattern.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/neural/neural-pattern.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI/E,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,IAAI,mBAAmB;IAChC,QAAQ,CAAC,WAAW,+OAA+O;IACnQ,SAAkB,QAAQ,QAAQ;;IAU5B,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAyEzF,OAAO,CAAC,cAAc;CAiDvB"}