@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,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComparativeAnalysisTool = void 0;
4
+ const zod_1 = require("zod");
5
+ const core_1 = require("@thoughtflow/core");
6
+ const ComparativeResultSchema = zod_1.z.object({
7
+ overallCompliance: zod_1.z.number().min(0).max(1),
8
+ sections: zod_1.z.array(zod_1.z.object({
9
+ section: zod_1.z.string(),
10
+ status: zod_1.z.enum(["compliant", "partial", "non_compliant", "not_applicable"]),
11
+ details: zod_1.z.string(),
12
+ evidenceRefs: zod_1.z.array(zod_1.z.string()).optional(),
13
+ })),
14
+ discrepancies: zod_1.z.array(zod_1.z.object({
15
+ section: zod_1.z.string(),
16
+ expected: zod_1.z.string(),
17
+ actual: zod_1.z.string(),
18
+ severity: zod_1.z.enum(["low", "medium", "high", "critical"]),
19
+ fix: zod_1.z.string(),
20
+ })),
21
+ additionalWarnings: zod_1.z.array(zod_1.z.object({
22
+ title: zod_1.z.string(),
23
+ description: zod_1.z.string(),
24
+ severity: zod_1.z.enum(["low", "medium", "high"]),
25
+ relatedRule: zod_1.z.string().optional(),
26
+ suggestion: zod_1.z.string(),
27
+ })),
28
+ additionalCritical: zod_1.z.array(zod_1.z.object({
29
+ title: zod_1.z.string(),
30
+ description: zod_1.z.string(),
31
+ impact: zod_1.z.string(),
32
+ blocking: zod_1.z.boolean(),
33
+ relatedRule: zod_1.z.string().optional(),
34
+ suggestedFix: zod_1.z.string(),
35
+ })),
36
+ summary: zod_1.z.string(),
37
+ });
38
+ class ComparativeAnalysisTool extends core_1.ToolBase {
39
+ config;
40
+ name = "comparativeAnalysis";
41
+ description = "Compare actual state (code, files, screenshots) against expected state (design specs, rules, guidelines). " +
42
+ "Detects discrepancies, compliance issues, and suggests fixes. " +
43
+ "Returns structured output with: target (what was checked), additionalWarnings (non-critical issues), " +
44
+ "additionalCritical (blocking issues), designCompliance (per-section status), diffDesign (expected vs actual). " +
45
+ "Use this when you need to verify implementation against design specifications or coding rules.";
46
+ readonly = true;
47
+ namespace = "neural";
48
+ tags = ["analysis", "compare", "verify"];
49
+ constructor(config = {}) {
50
+ super(zod_1.z.object({
51
+ actualState: zod_1.z.string().describe("What currently exists — file content, code snippet, or description of current state"),
52
+ expectedState: zod_1.z.string().describe("What should exist — design spec, rules, acceptance criteria, or expected behavior"),
53
+ context: zod_1.z.array(zod_1.z.string()).optional().describe("Additional context documents (architecture docs, related files, etc.)"),
54
+ checkSections: zod_1.z.array(zod_1.z.string()).optional().describe("Specific sections/aspects to compare (e.g. ['colors', 'spacing', 'routing', 'auth'])"),
55
+ strictMode: zod_1.z.boolean().optional().default(false).describe("If true, flags even minor deviations as warnings"),
56
+ }));
57
+ this.config = config;
58
+ }
59
+ async run(input, ctx) {
60
+ const actualState = input["actualState"];
61
+ const expectedState = input["expectedState"];
62
+ const context = input["context"];
63
+ const checkSections = input["checkSections"];
64
+ const strictMode = input["strictMode"] ?? false;
65
+ ctx.emitProgress?.("Starting comparative analysis...");
66
+ const callStructured = ctx.conversation?.callStructured;
67
+ if (callStructured) {
68
+ try {
69
+ ctx.emitProgress?.("Running LLM-powered comparison...");
70
+ const result = await callStructured(this.buildLLMPrompt(actualState, expectedState, context, checkSections, strictMode), ComparativeResultSchema);
71
+ ctx.emitProgress?.("Comparison complete", {
72
+ compliance: result.overallCompliance,
73
+ discrepancies: result.discrepancies.length,
74
+ warnings: result.additionalWarnings.length,
75
+ criticals: result.additionalCritical.length,
76
+ });
77
+ return {
78
+ success: true,
79
+ output: JSON.stringify(this.formatOutput(result), null, 2),
80
+ data: { result },
81
+ };
82
+ }
83
+ catch (err) {
84
+ ctx.emitProgress?.(`LLM comparison failed: ${String(err)}`);
85
+ }
86
+ }
87
+ // Fallback: keyword-based comparison
88
+ ctx.emitProgress?.("Running heuristic comparison...");
89
+ const heuristic = this.heuristicCompare(actualState, expectedState, checkSections, strictMode);
90
+ return {
91
+ success: true,
92
+ output: JSON.stringify(heuristic, null, 2),
93
+ data: { result: heuristic },
94
+ };
95
+ }
96
+ buildLLMPrompt(actual, expected, context, sections, strictMode) {
97
+ const t = this.config.truncation ?? {};
98
+ const actualChars = t.actualMaxChars ?? 3000;
99
+ const expectedChars = t.expectedMaxChars ?? 3000;
100
+ const ctxChars = t.contextMaxChars ?? 2000;
101
+ const parts = [];
102
+ parts.push(this.config.personaPrompt ??
103
+ "You are a design compliance auditor. Compare the ACTUAL implementation against the EXPECTED specification.");
104
+ parts.push(`\n## ACTUAL State (what currently exists)\n${actual.slice(0, actualChars)}`);
105
+ parts.push(`\n## EXPECTED State (what should exist)\n${expected.slice(0, expectedChars)}`);
106
+ if (context && context.length > 0) {
107
+ parts.push(`\n## Additional Context\n${context.join("\n\n").slice(0, ctxChars)}`);
108
+ }
109
+ parts.push("\n## Instructions");
110
+ if (sections && sections.length > 0) {
111
+ parts.push(`Check these specific sections: ${sections.join(", ")}`);
112
+ }
113
+ parts.push(strictMode
114
+ ? "STRICT MODE: Flag every deviation, even minor spacing/color differences."
115
+ : "Balanced mode: Focus on functional and design-breaking issues. Minor style deviations are warnings.");
116
+ parts.push(``);
117
+ parts.push("Return structured JSON with:");
118
+ parts.push("- overallCompliance (0-1, where 1 = perfect match)");
119
+ parts.push("- sections: per-section compliance status");
120
+ parts.push("- discrepancies: expected vs actual with severity and suggested fix");
121
+ parts.push("- additionalWarnings: non-critical issues found beyond the immediate scope");
122
+ parts.push("- additionalCritical: blocking or severe issues");
123
+ parts.push("- summary: concise human-readable verdict");
124
+ return parts.join("\n");
125
+ }
126
+ heuristicCompare(actual, expected, sections, strictMode) {
127
+ const discrepancies = [];
128
+ const warnings = [];
129
+ const criticals = [];
130
+ const sectionResults = [];
131
+ const checkList = sections ?? ["overall"];
132
+ const actualLower = actual.toLowerCase();
133
+ const expectedLower = expected.toLowerCase();
134
+ // Check for common issues
135
+ for (const section of checkList) {
136
+ const sectionLower = section.toLowerCase();
137
+ // Color-related checks
138
+ if (sectionLower.includes("color") || sectionLower.includes("style") || sectionLower.includes("css")) {
139
+ const expectedColors = expectedLower.match(/#[0-9a-f]{3,6}|rgb\([^)]+\)|red|blue|green|white|black/g);
140
+ const actualColors = actualLower.match(/#[0-9a-f]{3,6}|rgb\([^)]+\)|red|blue|green|white|black/g);
141
+ if (expectedColors && actualColors) {
142
+ for (const ec of expectedColors) {
143
+ if (!actualColors.includes(ec)) {
144
+ discrepancies.push({
145
+ section,
146
+ expected: `Color should include ${ec}`,
147
+ actual: `Color ${ec} not found in implementation`,
148
+ severity: strictMode ? "medium" : "low",
149
+ fix: `Add color ${ec} as specified`,
150
+ });
151
+ }
152
+ }
153
+ }
154
+ sectionResults.push({ section, status: discrepancies.length === 0 ? "compliant" : "partial", details: `${discrepancies.length} color mismatches`, evidenceRefs: [] });
155
+ }
156
+ // Navigation/routing checks
157
+ if (sectionLower.includes("nav") || sectionLower.includes("rout") || sectionLower.includes("link")) {
158
+ const hasNavActual = /<nav|navigation|navigate|route|link/i.test(actual);
159
+ if (!hasNavActual) {
160
+ discrepancies.push({
161
+ section,
162
+ expected: `Navigation structure should be present`,
163
+ actual: "No navigation pattern detected",
164
+ severity: "high",
165
+ fix: "Implement navigation as specified",
166
+ });
167
+ }
168
+ sectionResults.push({ section, status: hasNavActual ? "compliant" : "non_compliant", details: "Navigation check", evidenceRefs: [] });
169
+ }
170
+ // Default section
171
+ // Always run default comparison for sections that aren't specifically handled
172
+ {
173
+ // Basic content comparison
174
+ const expectedKeywords = expectedLower.split(/\s+/).filter((w) => w.length > 3).slice(0, 10);
175
+ const missingKeywords = expectedKeywords.filter((kw) => !actualLower.includes(kw));
176
+ if (missingKeywords.length > 3) {
177
+ discrepancies.push({
178
+ section,
179
+ expected: `Should contain: ${missingKeywords.join(", ")}`,
180
+ actual: "Keywords not found in implementation",
181
+ severity: "medium",
182
+ fix: "Ensure implementation includes expected content",
183
+ });
184
+ }
185
+ sectionResults.push({
186
+ section,
187
+ status: missingKeywords.length === 0 ? "compliant" : missingKeywords.length <= 3 ? "partial" : "non_compliant",
188
+ details: `${missingKeywords.length}/${expectedKeywords.length} keywords missing`,
189
+ evidenceRefs: [],
190
+ });
191
+ }
192
+ }
193
+ // Always check for common cross-cutting concerns
194
+ const crossChecks = this.config.crossCuttingChecks ?? [
195
+ { keyword: "test", severity: "medium", title: "Testing not detected in implementation", suggestion: "Add unit and integration tests" },
196
+ { keyword: "error", severity: "medium", title: "Error handling may be missing", suggestion: "Add error handling and user feedback" },
197
+ ];
198
+ for (const check of crossChecks) {
199
+ if (!actualLower.includes(check.keyword) && expectedLower.includes(check.keyword)) {
200
+ warnings.push({
201
+ sourceNodeId: "",
202
+ title: check.title,
203
+ description: `Expected specification mentions ${check.keyword}, not detected in implementation`,
204
+ severity: check.severity,
205
+ suggestion: check.suggestion,
206
+ });
207
+ }
208
+ }
209
+ const penalty = this.config.scoringWeights?.penaltyPerDiscrepancy ?? 0.15;
210
+ return {
211
+ overallCompliance: discrepancies.length === 0 ? 1 : Math.max(0, 1 - discrepancies.length * penalty),
212
+ sections: sectionResults,
213
+ discrepancies,
214
+ additionalWarnings: warnings,
215
+ additionalCritical: criticals,
216
+ summary: discrepancies.length === 0
217
+ ? "Implementation appears compliant with specification"
218
+ : `${discrepancies.length} discrepancy(s) found, ${warnings.length} warning(s)`,
219
+ };
220
+ }
221
+ formatOutput(result) {
222
+ return {
223
+ target: "Comparative analysis between expected and actual state",
224
+ designCompliance: {
225
+ overallScore: result.overallCompliance,
226
+ sections: result.sections,
227
+ discrepancies: result.discrepancies,
228
+ },
229
+ additionalWarnings: result.additionalWarnings,
230
+ additionalCritical: result.additionalCritical,
231
+ diffDesign: result.discrepancies.map((d) => ({
232
+ section: d.section,
233
+ diff: `Expected: ${d.expected}\nActual: ${d.actual}\nFix: ${d.fix}`,
234
+ severity: d.severity,
235
+ })),
236
+ summary: result.summary,
237
+ };
238
+ }
239
+ }
240
+ exports.ComparativeAnalysisTool = ComparativeAnalysisTool;
241
+ //# sourceMappingURL=comparative-analysis.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparative-analysis.tool.js","sourceRoot":"","sources":["../../../src/tools/neural/comparative-analysis.tool.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAA+E;AA0B/E,MAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC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IACJ,CAAC;CACF;AAxPD,0DAwPC"}
@@ -0,0 +1,12 @@
1
+ export * from "./neural-explain.tool";
2
+ export * from "./neural-suggest.tool";
3
+ export * from "./neural-review.tool";
4
+ export * from "./neural-debug.tool";
5
+ export * from "./neural-security.tool";
6
+ export * from "./neural-smells.tool";
7
+ export * from "./neural-deadcode.tool";
8
+ export * from "./neural-similar.tool";
9
+ export * from "./neural-pattern.tool";
10
+ export * from "./neural-optimize.tool";
11
+ export * from "./comparative-analysis.tool";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/neural/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,28 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./neural-explain.tool"), exports);
18
+ __exportStar(require("./neural-suggest.tool"), exports);
19
+ __exportStar(require("./neural-review.tool"), exports);
20
+ __exportStar(require("./neural-debug.tool"), exports);
21
+ __exportStar(require("./neural-security.tool"), exports);
22
+ __exportStar(require("./neural-smells.tool"), exports);
23
+ __exportStar(require("./neural-deadcode.tool"), exports);
24
+ __exportStar(require("./neural-similar.tool"), exports);
25
+ __exportStar(require("./neural-pattern.tool"), exports);
26
+ __exportStar(require("./neural-optimize.tool"), exports);
27
+ __exportStar(require("./comparative-analysis.tool"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/neural/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,wDAAsC;AACtC,uDAAqC;AACrC,sDAAoC;AACpC,yDAAuC;AACvC,uDAAqC;AACrC,yDAAuC;AACvC,wDAAsC;AACtC,wDAAsC;AACtC,yDAAuC;AACvC,8DAA4C"}
@@ -0,0 +1,10 @@
1
+ import { ToolBase, ToolContext, ToolExecutionResult } from "@thoughtflow/core";
2
+ export declare class NeuralDeadcodeTool extends ToolBase {
3
+ readonly name = "neuralDeadcode";
4
+ readonly description = "Detect dead code: unused exports, unreachable functions, unused variables, and orphaned files using dependency graph analysis with LLM-guided false-positive filtering for uncertain cases.";
5
+ readonly readonly = true;
6
+ constructor();
7
+ run(input: Record<string, unknown>, ctx: ToolContext): Promise<ToolExecutionResult>;
8
+ private extractExports;
9
+ }
10
+ //# sourceMappingURL=neural-deadcode.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-deadcode.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/neural/neural-deadcode.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAK/E,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,WAAW,iMAAiM;IACrN,SAAkB,QAAQ,QAAQ;;IAU5B,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuEzF,OAAO,CAAC,cAAc;CAcvB"}
@@ -0,0 +1,133 @@
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.NeuralDeadcodeTool = 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
+ class NeuralDeadcodeTool extends core_1.ToolBase {
43
+ name = "neuralDeadcode";
44
+ description = "Detect dead code: unused exports, unreachable functions, unused variables, and orphaned files using dependency graph analysis with LLM-guided false-positive filtering for uncertain cases.";
45
+ readonly = true;
46
+ constructor() {
47
+ super(zod_1.z.object({
48
+ projectPath: zod_1.z.string().optional(),
49
+ threshold: zod_1.z.number().optional().describe("Min lines of dead code to report a file"),
50
+ llmVerify: zod_1.z.boolean().optional().describe("Use LLM to verify uncertain cases"),
51
+ }));
52
+ }
53
+ async run(input, ctx) {
54
+ const rootPath = input.projectPath ?? process.cwd();
55
+ const threshold = input.threshold ?? 3;
56
+ const llmVerify = input.llmVerify ?? false;
57
+ const explorer = new explorer_1.CodebaseExplorer();
58
+ const files = explorer.explore({ rootPath });
59
+ const codeFiles = files.filter((f) => f.classification === "source-code")
60
+ .map((f) => ({ relativePath: f.relativePath, absolutePath: f.absolutePath }));
61
+ const depExtractor = new dependency_extractor_1.DependencyExtractor();
62
+ const graph = await depExtractor.buildGraph(codeFiles, rootPath);
63
+ const usedFiles = new Set();
64
+ for (const edge of graph.edges) {
65
+ usedFiles.add(edge.to);
66
+ }
67
+ const deadExports = [];
68
+ const unreachableFiles = [];
69
+ for (const file of codeFiles) {
70
+ const content = fs.readFileSync(file.absolutePath, "utf8");
71
+ const exports = this.extractExports(content, file.relativePath);
72
+ const hasIncoming = graph.edges.some((e) => e.to === file.relativePath);
73
+ const isEntry = file.relativePath.match(/(index|main|app|server|cli)\.ts$/);
74
+ if (!hasIncoming && !isEntry && file.relativePath.includes("/")) {
75
+ unreachableFiles.push(file.relativePath);
76
+ }
77
+ for (const exp of exports) {
78
+ let used = false;
79
+ for (const edge of graph.edges) {
80
+ if (edge.symbols?.includes(exp.symbol)) {
81
+ used = true;
82
+ break;
83
+ }
84
+ }
85
+ if (!used && !exp.symbol.startsWith("_") && !exp.symbol.startsWith("I")) {
86
+ deadExports.push({ ...exp, confidence: "high" });
87
+ }
88
+ }
89
+ }
90
+ if (llmVerify && unreachableFiles.length > 0 && ctx.conversation) {
91
+ const prompt = `These files appear to have no imports from other project files. Are any of them entry points, referenced dynamically (e.g., loaded by string path, used in config files, routing tables, or build scripts), or otherwise used indirectly?\n\n${unreachableFiles.slice(0, 10).join("\n")}\n\nReturn: { falsePositives: string[] } listing only files that are genuinely in use.`;
92
+ try {
93
+ const result = await ctx.conversation.callStructured(prompt, zod_1.z.object({ falsePositives: zod_1.z.array(zod_1.z.string()) }));
94
+ const fps = new Set(result.falsePositives ?? []);
95
+ const filtered = unreachableFiles.filter((f) => !fps.has(f));
96
+ return {
97
+ success: true,
98
+ output: JSON.stringify({
99
+ summary: { totalFiles: codeFiles.length, deadExports: deadExports.length, unreachableFiles: filtered.length, falsePositivesRemoved: fps.size },
100
+ deadExports: deadExports.slice(0, 50),
101
+ unreachableFiles: filtered,
102
+ }),
103
+ };
104
+ }
105
+ catch {
106
+ }
107
+ }
108
+ return {
109
+ success: true,
110
+ output: JSON.stringify({
111
+ summary: { totalFiles: codeFiles.length, deadExports: deadExports.length, unreachableFiles: unreachableFiles.length },
112
+ deadExports: deadExports.slice(0, 50),
113
+ unreachableFiles: unreachableFiles.slice(0, 20),
114
+ }),
115
+ };
116
+ }
117
+ extractExports(content, filePath) {
118
+ const exports = [];
119
+ const lines = content.split("\n");
120
+ for (let i = 0; i < lines.length; i++) {
121
+ const match = lines[i].match(/(?:export\s+(?:async\s+)?(?:function|class|const|let|var|interface|type|enum)\s+(\w+))|(?:export\s*\{\s*([^}]+)\s*\})/);
122
+ if (match) {
123
+ const name = match[1] || match[2];
124
+ if (name) {
125
+ exports.push({ file: filePath, symbol: name, type: "export", line: i + 1 });
126
+ }
127
+ }
128
+ }
129
+ return exports;
130
+ }
131
+ }
132
+ exports.NeuralDeadcodeTool = NeuralDeadcodeTool;
133
+ //# sourceMappingURL=neural-deadcode.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-deadcode.tool.js","sourceRoot":"","sources":["../../../src/tools/neural/neural-deadcode.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAwB;AACxB,4CAA+E;AAC/E,yFAAqF;AACrF,mEAAwE;AACxE,4CAA8B;AAE9B,MAAa,kBAAmB,SAAQ,eAAQ;IACrC,IAAI,GAAG,gBAAgB,CAAC;IACxB,WAAW,GAAG,6LAA6L,CAAC;IACnM,QAAQ,GAAG,IAAI,CAAC;IAElC;QACE,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC;YACb,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAClC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;YACpF,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;SAChF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAA8B,EAAE,GAAgB;QACxD,MAAM,QAAQ,GAAI,KAAK,CAAC,WAAsB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChE,MAAM,SAAS,GAAI,KAAK,CAAC,SAAoB,IAAI,CAAC,CAAC;QACnD,MAAM,SAAS,GAAI,KAAK,CAAC,SAAqB,IAAI,KAAK,CAAC;QAExD,MAAM,QAAQ,GAAG,IAAI,2BAAgB,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC7C,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,aAAa,CAAC;aACtE,GAAG,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ClC,IAAI,IAAI,EAAE,CAAC;oBACT,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC9E,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAlGD,gDAkGC"}
@@ -0,0 +1,11 @@
1
+ import { ToolBase, ToolContext, ToolExecutionResult } from "@thoughtflow/core";
2
+ export declare class NeuralDebugTool extends ToolBase {
3
+ readonly name = "neuralDebug";
4
+ readonly 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.";
5
+ readonly readonly = true;
6
+ constructor();
7
+ run(input: Record<string, unknown>, ctx: ToolContext): Promise<ToolExecutionResult>;
8
+ private parseStackTrace;
9
+ private staticAnalyzeContext;
10
+ }
11
+ //# sourceMappingURL=neural-debug.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neural-debug.tool.d.ts","sourceRoot":"","sources":["../../../src/tools/neural/neural-debug.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAiB/E,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,kLAAkL;IACtM,SAAkB,QAAQ,QAAQ;;IAU5B,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwGzF,OAAO,CAAC,eAAe;IAiCvB,OAAO,CAAC,oBAAoB;CA8B7B"}