@nanocollective/nanocoder 1.11.3

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 (392) hide show
  1. package/LICENSE.md +23 -0
  2. package/README.md +366 -0
  3. package/dist/app/hooks/useAppInitialization.d.ts +26 -0
  4. package/dist/app/hooks/useAppInitialization.d.ts.map +1 -0
  5. package/dist/app/hooks/useAppInitialization.js +151 -0
  6. package/dist/app/hooks/useAppInitialization.js.map +1 -0
  7. package/dist/app/hooks/useAppState.d.ts +84 -0
  8. package/dist/app/hooks/useAppState.d.ts.map +1 -0
  9. package/dist/app/hooks/useAppState.js +162 -0
  10. package/dist/app/hooks/useAppState.js.map +1 -0
  11. package/dist/app/hooks/useChatHandler.d.ts +26 -0
  12. package/dist/app/hooks/useChatHandler.d.ts.map +1 -0
  13. package/dist/app/hooks/useChatHandler.js +532 -0
  14. package/dist/app/hooks/useChatHandler.js.map +1 -0
  15. package/dist/app/hooks/useDirectoryTrust.d.ts +15 -0
  16. package/dist/app/hooks/useDirectoryTrust.d.ts.map +1 -0
  17. package/dist/app/hooks/useDirectoryTrust.js +77 -0
  18. package/dist/app/hooks/useDirectoryTrust.js.map +1 -0
  19. package/dist/app/hooks/useModeHandlers.d.ts +31 -0
  20. package/dist/app/hooks/useModeHandlers.d.ts.map +1 -0
  21. package/dist/app/hooks/useModeHandlers.js +98 -0
  22. package/dist/app/hooks/useModeHandlers.js.map +1 -0
  23. package/dist/app/hooks/useToolHandler.d.ts +32 -0
  24. package/dist/app/hooks/useToolHandler.d.ts.map +1 -0
  25. package/dist/app/hooks/useToolHandler.js +154 -0
  26. package/dist/app/hooks/useToolHandler.js.map +1 -0
  27. package/dist/app/utils/appUtils.d.ts +4 -0
  28. package/dist/app/utils/appUtils.d.ts.map +1 -0
  29. package/dist/app/utils/appUtils.js +147 -0
  30. package/dist/app/utils/appUtils.js.map +1 -0
  31. package/dist/app/utils/conversationState.d.ts +68 -0
  32. package/dist/app/utils/conversationState.d.ts.map +1 -0
  33. package/dist/app/utils/conversationState.js +199 -0
  34. package/dist/app/utils/conversationState.js.map +1 -0
  35. package/dist/app.d.ts +2 -0
  36. package/dist/app.d.ts.map +1 -0
  37. package/dist/app.js +193 -0
  38. package/dist/app.js.map +1 -0
  39. package/dist/cli.d.ts +3 -0
  40. package/dist/cli.d.ts.map +1 -0
  41. package/dist/cli.js +6 -0
  42. package/dist/cli.js.map +1 -0
  43. package/dist/client-factory.d.ts +6 -0
  44. package/dist/client-factory.d.ts.map +1 -0
  45. package/dist/client-factory.js +111 -0
  46. package/dist/client-factory.js.map +1 -0
  47. package/dist/command-parser.d.ts +5 -0
  48. package/dist/command-parser.d.ts.map +1 -0
  49. package/dist/command-parser.js +36 -0
  50. package/dist/command-parser.js.map +1 -0
  51. package/dist/commands/clear.d.ts +3 -0
  52. package/dist/commands/clear.d.ts.map +1 -0
  53. package/dist/commands/clear.js +17 -0
  54. package/dist/commands/clear.js.map +1 -0
  55. package/dist/commands/custom-commands.d.ts +3 -0
  56. package/dist/commands/custom-commands.d.ts.map +1 -0
  57. package/dist/commands/custom-commands.js +41 -0
  58. package/dist/commands/custom-commands.js.map +1 -0
  59. package/dist/commands/debug.d.ts +3 -0
  60. package/dist/commands/debug.d.ts.map +1 -0
  61. package/dist/commands/debug.js +86 -0
  62. package/dist/commands/debug.js.map +1 -0
  63. package/dist/commands/exit.d.ts +3 -0
  64. package/dist/commands/exit.d.ts.map +1 -0
  65. package/dist/commands/exit.js +17 -0
  66. package/dist/commands/exit.js.map +1 -0
  67. package/dist/commands/export.d.ts +3 -0
  68. package/dist/commands/export.d.ts.map +1 -0
  69. package/dist/commands/export.js +63 -0
  70. package/dist/commands/export.js.map +1 -0
  71. package/dist/commands/help.d.ts +3 -0
  72. package/dist/commands/help.d.ts.map +1 -0
  73. package/dist/commands/help.js +31 -0
  74. package/dist/commands/help.js.map +1 -0
  75. package/dist/commands/index.d.ts +13 -0
  76. package/dist/commands/index.d.ts.map +1 -0
  77. package/dist/commands/index.js +13 -0
  78. package/dist/commands/index.js.map +1 -0
  79. package/dist/commands/init.d.ts +3 -0
  80. package/dist/commands/init.d.ts.map +1 -0
  81. package/dist/commands/init.js +214 -0
  82. package/dist/commands/init.js.map +1 -0
  83. package/dist/commands/mcp.d.ts +9 -0
  84. package/dist/commands/mcp.d.ts.map +1 -0
  85. package/dist/commands/mcp.js +41 -0
  86. package/dist/commands/mcp.js.map +1 -0
  87. package/dist/commands/model.d.ts +3 -0
  88. package/dist/commands/model.d.ts.map +1 -0
  89. package/dist/commands/model.js +11 -0
  90. package/dist/commands/model.js.map +1 -0
  91. package/dist/commands/provider.d.ts +3 -0
  92. package/dist/commands/provider.d.ts.map +1 -0
  93. package/dist/commands/provider.js +11 -0
  94. package/dist/commands/provider.js.map +1 -0
  95. package/dist/commands/theme.d.ts +3 -0
  96. package/dist/commands/theme.d.ts.map +1 -0
  97. package/dist/commands/theme.js +11 -0
  98. package/dist/commands/theme.js.map +1 -0
  99. package/dist/commands/update.d.ts +3 -0
  100. package/dist/commands/update.d.ts.map +1 -0
  101. package/dist/commands/update.js +10 -0
  102. package/dist/commands/update.js.map +1 -0
  103. package/dist/commands.d.ts +16 -0
  104. package/dist/commands.d.ts.map +1 -0
  105. package/dist/commands.js +46 -0
  106. package/dist/commands.js.map +1 -0
  107. package/dist/components/assistant-message.d.ts +4 -0
  108. package/dist/components/assistant-message.d.ts.map +1 -0
  109. package/dist/components/assistant-message.js +43 -0
  110. package/dist/components/assistant-message.js.map +1 -0
  111. package/dist/components/bash-execution-indicator.d.ts +4 -0
  112. package/dist/components/bash-execution-indicator.d.ts.map +1 -0
  113. package/dist/components/bash-execution-indicator.js +9 -0
  114. package/dist/components/bash-execution-indicator.js.map +1 -0
  115. package/dist/components/cancelling-indicator.d.ts +3 -0
  116. package/dist/components/cancelling-indicator.d.ts.map +1 -0
  117. package/dist/components/cancelling-indicator.js +10 -0
  118. package/dist/components/cancelling-indicator.js.map +1 -0
  119. package/dist/components/chat-queue.d.ts +4 -0
  120. package/dist/components/chat-queue.d.ts.map +1 -0
  121. package/dist/components/chat-queue.js +23 -0
  122. package/dist/components/chat-queue.js.map +1 -0
  123. package/dist/components/custom-commands.d.ts +7 -0
  124. package/dist/components/custom-commands.d.ts.map +1 -0
  125. package/dist/components/custom-commands.js +27 -0
  126. package/dist/components/custom-commands.js.map +1 -0
  127. package/dist/components/error-message.d.ts +7 -0
  128. package/dist/components/error-message.d.ts.map +1 -0
  129. package/dist/components/error-message.js +12 -0
  130. package/dist/components/error-message.js.map +1 -0
  131. package/dist/components/info-message.d.ts +6 -0
  132. package/dist/components/info-message.d.ts.map +1 -0
  133. package/dist/components/info-message.js +11 -0
  134. package/dist/components/info-message.js.map +1 -0
  135. package/dist/components/model-selector.d.ts +10 -0
  136. package/dist/components/model-selector.d.ts.map +1 -0
  137. package/dist/components/model-selector.js +59 -0
  138. package/dist/components/model-selector.js.map +1 -0
  139. package/dist/components/provider-selector.d.ts +9 -0
  140. package/dist/components/provider-selector.d.ts.map +1 -0
  141. package/dist/components/provider-selector.js +36 -0
  142. package/dist/components/provider-selector.js.map +1 -0
  143. package/dist/components/security-disclaimer.d.ts +7 -0
  144. package/dist/components/security-disclaimer.d.ts.map +1 -0
  145. package/dist/components/security-disclaimer.js +36 -0
  146. package/dist/components/security-disclaimer.js.map +1 -0
  147. package/dist/components/status.d.ts +6 -0
  148. package/dist/components/status.d.ts.map +1 -0
  149. package/dist/components/status.js +35 -0
  150. package/dist/components/status.js.map +1 -0
  151. package/dist/components/success-message.d.ts +6 -0
  152. package/dist/components/success-message.d.ts.map +1 -0
  153. package/dist/components/success-message.js +11 -0
  154. package/dist/components/success-message.js.map +1 -0
  155. package/dist/components/theme-selector.d.ts +8 -0
  156. package/dist/components/theme-selector.d.ts.map +1 -0
  157. package/dist/components/theme-selector.js +40 -0
  158. package/dist/components/theme-selector.js.map +1 -0
  159. package/dist/components/thinking-indicator.d.ts +4 -0
  160. package/dist/components/thinking-indicator.d.ts.map +1 -0
  161. package/dist/components/thinking-indicator.js +32 -0
  162. package/dist/components/thinking-indicator.js.map +1 -0
  163. package/dist/components/tool-confirmation.d.ts +9 -0
  164. package/dist/components/tool-confirmation.d.ts.map +1 -0
  165. package/dist/components/tool-confirmation.js +72 -0
  166. package/dist/components/tool-confirmation.js.map +1 -0
  167. package/dist/components/tool-execution-indicator.d.ts +3 -0
  168. package/dist/components/tool-execution-indicator.d.ts.map +1 -0
  169. package/dist/components/tool-execution-indicator.js +9 -0
  170. package/dist/components/tool-execution-indicator.js.map +1 -0
  171. package/dist/components/tool-message.d.ts +10 -0
  172. package/dist/components/tool-message.d.ts.map +1 -0
  173. package/dist/components/tool-message.js +16 -0
  174. package/dist/components/tool-message.js.map +1 -0
  175. package/dist/components/update-message.d.ts +7 -0
  176. package/dist/components/update-message.d.ts.map +1 -0
  177. package/dist/components/update-message.js +93 -0
  178. package/dist/components/update-message.js.map +1 -0
  179. package/dist/components/user-input.d.ts +10 -0
  180. package/dist/components/user-input.d.ts.map +1 -0
  181. package/dist/components/user-input.js +188 -0
  182. package/dist/components/user-input.js.map +1 -0
  183. package/dist/components/user-message.d.ts +4 -0
  184. package/dist/components/user-message.d.ts.map +1 -0
  185. package/dist/components/user-message.js +15 -0
  186. package/dist/components/user-message.js.map +1 -0
  187. package/dist/components/welcome-message.d.ts +3 -0
  188. package/dist/components/welcome-message.d.ts.map +1 -0
  189. package/dist/components/welcome-message.js +21 -0
  190. package/dist/components/welcome-message.js.map +1 -0
  191. package/dist/config/index.d.ts +10 -0
  192. package/dist/config/index.d.ts.map +1 -0
  193. package/dist/config/index.js +44 -0
  194. package/dist/config/index.js.map +1 -0
  195. package/dist/config/logging.d.ts +14 -0
  196. package/dist/config/logging.d.ts.map +1 -0
  197. package/dist/config/logging.js +58 -0
  198. package/dist/config/logging.js.map +1 -0
  199. package/dist/config/preferences.d.ts +7 -0
  200. package/dist/config/preferences.d.ts.map +1 -0
  201. package/dist/config/preferences.js +46 -0
  202. package/dist/config/preferences.js.map +1 -0
  203. package/dist/config/themes.d.ts +6 -0
  204. package/dist/config/themes.d.ts.map +1 -0
  205. package/dist/config/themes.js +295 -0
  206. package/dist/config/themes.js.map +1 -0
  207. package/dist/custom-commands/executor.d.ts +12 -0
  208. package/dist/custom-commands/executor.d.ts.map +1 -0
  209. package/dist/custom-commands/executor.js +45 -0
  210. package/dist/custom-commands/executor.js.map +1 -0
  211. package/dist/custom-commands/index.d.ts +4 -0
  212. package/dist/custom-commands/index.d.ts.map +1 -0
  213. package/dist/custom-commands/index.js +4 -0
  214. package/dist/custom-commands/index.js.map +1 -0
  215. package/dist/custom-commands/loader.d.ts +41 -0
  216. package/dist/custom-commands/loader.d.ts.map +1 -0
  217. package/dist/custom-commands/loader.js +129 -0
  218. package/dist/custom-commands/loader.js.map +1 -0
  219. package/dist/custom-commands/parser.d.ts +10 -0
  220. package/dist/custom-commands/parser.d.ts.map +1 -0
  221. package/dist/custom-commands/parser.js +181 -0
  222. package/dist/custom-commands/parser.js.map +1 -0
  223. package/dist/hooks/useInputState.d.ts +14 -0
  224. package/dist/hooks/useInputState.d.ts.map +1 -0
  225. package/dist/hooks/useInputState.js +66 -0
  226. package/dist/hooks/useInputState.js.map +1 -0
  227. package/dist/hooks/useTerminalWidth.d.ts +2 -0
  228. package/dist/hooks/useTerminalWidth.d.ts.map +1 -0
  229. package/dist/hooks/useTerminalWidth.js +20 -0
  230. package/dist/hooks/useTerminalWidth.js.map +1 -0
  231. package/dist/hooks/useTheme.d.ts +9 -0
  232. package/dist/hooks/useTheme.d.ts.map +1 -0
  233. package/dist/hooks/useTheme.js +10 -0
  234. package/dist/hooks/useTheme.js.map +1 -0
  235. package/dist/hooks/useUIState.d.ts +19 -0
  236. package/dist/hooks/useUIState.d.ts.map +1 -0
  237. package/dist/hooks/useUIState.js +46 -0
  238. package/dist/hooks/useUIState.js.map +1 -0
  239. package/dist/init/agents-template-generator.d.ts +29 -0
  240. package/dist/init/agents-template-generator.d.ts.map +1 -0
  241. package/dist/init/agents-template-generator.js +340 -0
  242. package/dist/init/agents-template-generator.js.map +1 -0
  243. package/dist/init/existing-rules-extractor.d.ts +43 -0
  244. package/dist/init/existing-rules-extractor.d.ts.map +1 -0
  245. package/dist/init/existing-rules-extractor.js +226 -0
  246. package/dist/init/existing-rules-extractor.js.map +1 -0
  247. package/dist/init/file-scanner.d.ts +40 -0
  248. package/dist/init/file-scanner.d.ts.map +1 -0
  249. package/dist/init/file-scanner.js +153 -0
  250. package/dist/init/file-scanner.js.map +1 -0
  251. package/dist/init/framework-detector.d.ts +57 -0
  252. package/dist/init/framework-detector.d.ts.map +1 -0
  253. package/dist/init/framework-detector.js +277 -0
  254. package/dist/init/framework-detector.js.map +1 -0
  255. package/dist/init/language-detector.d.ts +31 -0
  256. package/dist/init/language-detector.d.ts.map +1 -0
  257. package/dist/init/language-detector.js +205 -0
  258. package/dist/init/language-detector.js.map +1 -0
  259. package/dist/init/project-analyzer.d.ts +62 -0
  260. package/dist/init/project-analyzer.d.ts.map +1 -0
  261. package/dist/init/project-analyzer.js +294 -0
  262. package/dist/init/project-analyzer.js.map +1 -0
  263. package/dist/langgraph-client.d.ts +20 -0
  264. package/dist/langgraph-client.d.ts.map +1 -0
  265. package/dist/langgraph-client.js +245 -0
  266. package/dist/langgraph-client.js.map +1 -0
  267. package/dist/mcp/mcp-client.d.ts +23 -0
  268. package/dist/mcp/mcp-client.d.ts.map +1 -0
  269. package/dist/mcp/mcp-client.js +194 -0
  270. package/dist/mcp/mcp-client.js.map +1 -0
  271. package/dist/mcp/mcp-tool-adapter.d.ts +22 -0
  272. package/dist/mcp/mcp-tool-adapter.d.ts.map +1 -0
  273. package/dist/mcp/mcp-tool-adapter.js +49 -0
  274. package/dist/mcp/mcp-tool-adapter.js.map +1 -0
  275. package/dist/message-handler.d.ts +7 -0
  276. package/dist/message-handler.d.ts.map +1 -0
  277. package/dist/message-handler.js +53 -0
  278. package/dist/message-handler.js.map +1 -0
  279. package/dist/prompt-history.d.ts +14 -0
  280. package/dist/prompt-history.d.ts.map +1 -0
  281. package/dist/prompt-history.js +88 -0
  282. package/dist/prompt-history.js.map +1 -0
  283. package/dist/tool-calling/index.d.ts +6 -0
  284. package/dist/tool-calling/index.d.ts.map +1 -0
  285. package/dist/tool-calling/index.js +5 -0
  286. package/dist/tool-calling/index.js.map +1 -0
  287. package/dist/tool-calling/json-parser.d.ts +7 -0
  288. package/dist/tool-calling/json-parser.d.ts.map +1 -0
  289. package/dist/tool-calling/json-parser.js +168 -0
  290. package/dist/tool-calling/json-parser.js.map +1 -0
  291. package/dist/tool-calling/xml-parser.d.ts +34 -0
  292. package/dist/tool-calling/xml-parser.d.ts.map +1 -0
  293. package/dist/tool-calling/xml-parser.js +113 -0
  294. package/dist/tool-calling/xml-parser.js.map +1 -0
  295. package/dist/tools/create-file.d.ts +3 -0
  296. package/dist/tools/create-file.d.ts.map +1 -0
  297. package/dist/tools/create-file.js +66 -0
  298. package/dist/tools/create-file.js.map +1 -0
  299. package/dist/tools/delete-lines.d.ts +3 -0
  300. package/dist/tools/delete-lines.d.ts.map +1 -0
  301. package/dist/tools/delete-lines.js +218 -0
  302. package/dist/tools/delete-lines.js.map +1 -0
  303. package/dist/tools/execute-bash.d.ts +3 -0
  304. package/dist/tools/execute-bash.d.ts.map +1 -0
  305. package/dist/tools/execute-bash.js +107 -0
  306. package/dist/tools/execute-bash.js.map +1 -0
  307. package/dist/tools/index.d.ts +7 -0
  308. package/dist/tools/index.d.ts.map +1 -0
  309. package/dist/tools/index.js +23 -0
  310. package/dist/tools/index.js.map +1 -0
  311. package/dist/tools/insert-lines.d.ts +3 -0
  312. package/dist/tools/insert-lines.d.ts.map +1 -0
  313. package/dist/tools/insert-lines.js +185 -0
  314. package/dist/tools/insert-lines.js.map +1 -0
  315. package/dist/tools/read-file.d.ts +3 -0
  316. package/dist/tools/read-file.d.ts.map +1 -0
  317. package/dist/tools/read-file.js +81 -0
  318. package/dist/tools/read-file.js.map +1 -0
  319. package/dist/tools/read-many-files.d.ts +3 -0
  320. package/dist/tools/read-many-files.d.ts.map +1 -0
  321. package/dist/tools/read-many-files.js +109 -0
  322. package/dist/tools/read-many-files.js.map +1 -0
  323. package/dist/tools/replace-lines.d.ts +3 -0
  324. package/dist/tools/replace-lines.d.ts.map +1 -0
  325. package/dist/tools/replace-lines.js +220 -0
  326. package/dist/tools/replace-lines.js.map +1 -0
  327. package/dist/tools/tool-manager.d.ts +54 -0
  328. package/dist/tools/tool-manager.d.ts.map +1 -0
  329. package/dist/tools/tool-manager.js +108 -0
  330. package/dist/tools/tool-manager.js.map +1 -0
  331. package/dist/types/app.d.ts +46 -0
  332. package/dist/types/app.d.ts.map +1 -0
  333. package/dist/types/app.js +2 -0
  334. package/dist/types/app.js.map +1 -0
  335. package/dist/types/commands.d.ts +36 -0
  336. package/dist/types/commands.d.ts.map +1 -0
  337. package/dist/types/commands.js +2 -0
  338. package/dist/types/commands.js.map +1 -0
  339. package/dist/types/components.d.ts +87 -0
  340. package/dist/types/components.d.ts.map +1 -0
  341. package/dist/types/components.js +2 -0
  342. package/dist/types/components.js.map +1 -0
  343. package/dist/types/config.d.ts +35 -0
  344. package/dist/types/config.d.ts.map +1 -0
  345. package/dist/types/config.js +2 -0
  346. package/dist/types/config.js.map +1 -0
  347. package/dist/types/core.d.ts +57 -0
  348. package/dist/types/core.d.ts.map +1 -0
  349. package/dist/types/core.js +2 -0
  350. package/dist/types/core.js.map +1 -0
  351. package/dist/types/hooks.d.ts +26 -0
  352. package/dist/types/hooks.d.ts.map +1 -0
  353. package/dist/types/hooks.js +2 -0
  354. package/dist/types/hooks.js.map +1 -0
  355. package/dist/types/index.d.ts +11 -0
  356. package/dist/types/index.d.ts.map +1 -0
  357. package/dist/types/index.js +12 -0
  358. package/dist/types/index.js.map +1 -0
  359. package/dist/types/mcp.d.ts +19 -0
  360. package/dist/types/mcp.d.ts.map +1 -0
  361. package/dist/types/mcp.js +2 -0
  362. package/dist/types/mcp.js.map +1 -0
  363. package/dist/types/tools.d.ts +31 -0
  364. package/dist/types/tools.d.ts.map +1 -0
  365. package/dist/types/tools.js +2 -0
  366. package/dist/types/tools.js.map +1 -0
  367. package/dist/types/ui.d.ts +22 -0
  368. package/dist/types/ui.d.ts.map +1 -0
  369. package/dist/types/ui.js +2 -0
  370. package/dist/types/ui.js.map +1 -0
  371. package/dist/types/utils.d.ts +19 -0
  372. package/dist/types/utils.d.ts.map +1 -0
  373. package/dist/types/utils.js +2 -0
  374. package/dist/types/utils.js.map +1 -0
  375. package/dist/utils/message-queue.d.ts +8 -0
  376. package/dist/utils/message-queue.d.ts.map +1 -0
  377. package/dist/utils/message-queue.js +50 -0
  378. package/dist/utils/message-queue.js.map +1 -0
  379. package/dist/utils/programming-language-helper.d.ts +2 -0
  380. package/dist/utils/programming-language-helper.d.ts.map +1 -0
  381. package/dist/utils/programming-language-helper.js +32 -0
  382. package/dist/utils/programming-language-helper.js.map +1 -0
  383. package/dist/utils/prompt-processor.d.ts +6 -0
  384. package/dist/utils/prompt-processor.d.ts.map +1 -0
  385. package/dist/utils/prompt-processor.js +103 -0
  386. package/dist/utils/prompt-processor.js.map +1 -0
  387. package/dist/utils/update-checker.d.ts +6 -0
  388. package/dist/utils/update-checker.d.ts.map +1 -0
  389. package/dist/utils/update-checker.js +120 -0
  390. package/dist/utils/update-checker.js.map +1 -0
  391. package/package.json +97 -0
  392. package/source/app/prompts/main-prompt.md +107 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history.d.ts","sourceRoot":"","sources":["../source/prompt-history.ts"],"names":[],"mappings":"AASA,cAAM,aAAa;IACjB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAc;IAE5B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB5B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IASlC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAsB/B,WAAW,IAAI,MAAM,GAAG,IAAI;IAY5B,OAAO,IAAI,MAAM,GAAG,IAAI;IAYxB,UAAU,IAAI,IAAI;IAIlB,UAAU,IAAI,MAAM,EAAE;CAGvB;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
@@ -0,0 +1,88 @@
1
+ import fs from "fs/promises";
2
+ import path from "path";
3
+ import os from "os";
4
+ import { logError } from './utils/message-queue.js';
5
+ const HISTORY_FILE = path.join(os.homedir(), ".nano-coder-history");
6
+ const MAX_HISTORY_SIZE = 100;
7
+ const ENTRY_SEPARATOR = '\n---ENTRY_SEPARATOR---\n';
8
+ class PromptHistory {
9
+ history = [];
10
+ currentIndex = -1;
11
+ async loadHistory() {
12
+ try {
13
+ const content = await fs.readFile(HISTORY_FILE, "utf8");
14
+ if (content.includes(ENTRY_SEPARATOR)) {
15
+ // New format with separator
16
+ this.history = content.split(ENTRY_SEPARATOR).filter(entry => entry.trim() !== "");
17
+ }
18
+ else {
19
+ // Legacy format - assume single lines only
20
+ this.history = content.split("\n").filter(line => line.trim() !== "");
21
+ }
22
+ this.currentIndex = -1;
23
+ }
24
+ catch {
25
+ // File doesn't exist yet, start with empty history
26
+ this.history = [];
27
+ this.currentIndex = -1;
28
+ }
29
+ }
30
+ async saveHistory() {
31
+ try {
32
+ await fs.writeFile(HISTORY_FILE, this.history.join(ENTRY_SEPARATOR), "utf8");
33
+ }
34
+ catch (error) {
35
+ // Silently fail to avoid disrupting the user experience
36
+ logError(`Failed to save prompt history: ${error}`);
37
+ }
38
+ }
39
+ addPrompt(prompt) {
40
+ const trimmed = prompt.trim();
41
+ if (!trimmed)
42
+ return;
43
+ // Remove duplicate if it exists
44
+ const existingIndex = this.history.indexOf(trimmed);
45
+ if (existingIndex !== -1) {
46
+ this.history.splice(existingIndex, 1);
47
+ }
48
+ // Add to the end
49
+ this.history.push(trimmed);
50
+ // Keep only the last MAX_HISTORY_SIZE entries
51
+ if (this.history.length > MAX_HISTORY_SIZE) {
52
+ this.history = this.history.slice(-MAX_HISTORY_SIZE);
53
+ }
54
+ this.currentIndex = -1;
55
+ this.saveHistory(); // Fire and forget
56
+ }
57
+ getPrevious() {
58
+ if (this.history.length === 0)
59
+ return null;
60
+ if (this.currentIndex === -1) {
61
+ this.currentIndex = this.history.length - 1;
62
+ }
63
+ else if (this.currentIndex > 0) {
64
+ this.currentIndex--;
65
+ }
66
+ return this.history[this.currentIndex] ?? null;
67
+ }
68
+ getNext() {
69
+ if (this.history.length === 0 || this.currentIndex === -1)
70
+ return null;
71
+ if (this.currentIndex < this.history.length - 1) {
72
+ this.currentIndex++;
73
+ return this.history[this.currentIndex] ?? null;
74
+ }
75
+ else {
76
+ this.currentIndex = -1;
77
+ return "";
78
+ }
79
+ }
80
+ resetIndex() {
81
+ this.currentIndex = -1;
82
+ }
83
+ getHistory() {
84
+ return [...this.history];
85
+ }
86
+ }
87
+ export const promptHistory = new PromptHistory();
88
+ //# sourceMappingURL=prompt-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history.js","sourceRoot":"","sources":["../source/prompt-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAElD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,qBAAqB,CAAC,CAAC;AACpE,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAEpD,MAAM,aAAa;IACT,OAAO,GAAa,EAAE,CAAC;IACvB,YAAY,GAAW,CAAC,CAAC,CAAC;IAElC,KAAK,CAAC,WAAW;QACf,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YACxD,IAAI,OAAO,CAAC,QAAQ,C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B,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,UAAU;QACR,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,UAAU;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Tool calling utilities - main exports
3
+ */
4
+ export { parseToolCallsFromContent, cleanContentFromToolCalls, } from './json-parser.js';
5
+ export type { ToolExecutionResult } from '../types/index.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tool-calling/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,yBAAyB,EACzB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tool calling utilities - main exports
3
+ */
4
+ export { parseToolCallsFromContent, cleanContentFromToolCalls, } from './json-parser.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/tool-calling/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,yBAAyB,EACzB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ToolCall } from '../types/index.js';
2
+ export declare function parseToolCallsFromContent(content: string): ToolCall[];
3
+ /**
4
+ * Cleans content by removing tool call JSON blocks
5
+ */
6
+ export declare function cleanContentFromToolCalls(content: string, toolCalls: ToolCall[]): string;
7
+ //# sourceMappingURL=json-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-parser.d.ts","sourceRoot":"","sources":["../../source/tool-calling/json-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAMhD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,CAgHrE;AAsBD;;GAEG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,QAAQ,EAAE,GACnB,MAAM,CAwDR"}
@@ -0,0 +1,168 @@
1
+ import { logError } from '../utils/message-queue.js';
2
+ import { XMLToolCallParser } from './xml-parser.js';
3
+ // XML validation functions removed - XMLToolCallParser handles XML parsing
4
+ export function parseToolCallsFromContent(content) {
5
+ const extractedCalls = [];
6
+ let trimmedContent = content.trim();
7
+ // First, try the new XML parser for cleaner XML tool call parsing
8
+ if (XMLToolCallParser.hasToolCalls(content)) {
9
+ const parsedCalls = XMLToolCallParser.parseToolCalls(content);
10
+ const convertedCalls = XMLToolCallParser.convertToToolCalls(parsedCalls);
11
+ extractedCalls.push(...convertedCalls);
12
+ // If XML parser found tool calls, return them (don't continue with legacy parsers)
13
+ if (convertedCalls.length > 0) {
14
+ const uniqueCalls = deduplicateToolCalls(extractedCalls);
15
+ return uniqueCalls;
16
+ }
17
+ }
18
+ // Handle markdown code blocks
19
+ const codeBlockMatch = trimmedContent.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/);
20
+ if (codeBlockMatch && codeBlockMatch[1]) {
21
+ trimmedContent = codeBlockMatch[1].trim();
22
+ }
23
+ // Try to parse entire content as single JSON tool call
24
+ if (trimmedContent.startsWith('{') && trimmedContent.endsWith('}')) {
25
+ // Skip empty or nearly empty JSON objects
26
+ if (trimmedContent === '{}' || trimmedContent.replace(/\s/g, '') === '{}') {
27
+ return extractedCalls;
28
+ }
29
+ try {
30
+ const parsed = JSON.parse(trimmedContent);
31
+ if (parsed.name && parsed.arguments !== undefined) {
32
+ const toolCall = {
33
+ id: `call_${Date.now()}`,
34
+ function: {
35
+ name: parsed.name || '',
36
+ arguments: parsed.arguments || {},
37
+ },
38
+ };
39
+ extractedCalls.push(toolCall);
40
+ return extractedCalls;
41
+ }
42
+ }
43
+ catch (e) {
44
+ logError('Tool call failed to parse from JSON code block.');
45
+ }
46
+ }
47
+ // Look for standalone JSON blocks in the content (multiline without code blocks)
48
+ const jsonBlockRegex = /\{\s*\n\s*"name":\s*"([^"]+)",\s*\n\s*"arguments":\s*\{[\s\S]*?\}\s*\n\s*\}/g;
49
+ let jsonMatch;
50
+ while ((jsonMatch = jsonBlockRegex.exec(content)) !== null) {
51
+ try {
52
+ const parsed = JSON.parse(jsonMatch[0]);
53
+ if (parsed.name && parsed.arguments !== undefined) {
54
+ const toolCall = {
55
+ id: `call_${Date.now()}_${extractedCalls.length}`,
56
+ function: {
57
+ name: parsed.name || '',
58
+ arguments: parsed.arguments || {},
59
+ },
60
+ };
61
+ extractedCalls.push(toolCall);
62
+ }
63
+ }
64
+ catch (e) {
65
+ logError('Tool call failed to parse from JSON block.');
66
+ }
67
+ }
68
+ // XML parsing is now handled by XMLToolCallParser
69
+ // All XML parsing is now handled by XMLToolCallParser
70
+ // Look for embedded tool calls using regex patterns
71
+ const toolCallPatterns = [
72
+ /\{"name":\s*"([^"]+)",\s*"arguments":\s*(\{[^}]*\})\}/g,
73
+ /\{"name":\s*"([^"]+)",\s*"arguments":\s*(\{[^}]+\})\}/g,
74
+ /\{"name":\s*"([^"]+)",\s*"arguments":\s*"([^"]+)"\}/g,
75
+ ];
76
+ for (const pattern of toolCallPatterns) {
77
+ let match;
78
+ while ((match = pattern.exec(content)) !== null) {
79
+ const [, name, argsStr] = match;
80
+ try {
81
+ let args;
82
+ if (argsStr && argsStr.startsWith('{')) {
83
+ args = JSON.parse(argsStr || '{}');
84
+ }
85
+ else {
86
+ args = argsStr || '';
87
+ }
88
+ extractedCalls.push({
89
+ id: `call_${Date.now()}_${extractedCalls.length}`,
90
+ function: {
91
+ name: name || '',
92
+ arguments: args,
93
+ },
94
+ });
95
+ }
96
+ catch (e) {
97
+ logError('Tool call failed to parse from content.');
98
+ }
99
+ }
100
+ }
101
+ // Deduplicate identical tool calls
102
+ const uniqueCalls = deduplicateToolCalls(extractedCalls);
103
+ return uniqueCalls;
104
+ }
105
+ function deduplicateToolCalls(toolCalls) {
106
+ const seen = new Set();
107
+ const unique = [];
108
+ for (const call of toolCalls) {
109
+ // Create a hash of the function name and arguments for comparison
110
+ const hash = `${call.function.name}:${JSON.stringify(call.function.arguments)}`;
111
+ if (!seen.has(hash)) {
112
+ seen.add(hash);
113
+ unique.push(call);
114
+ }
115
+ else {
116
+ }
117
+ }
118
+ return unique;
119
+ }
120
+ /**
121
+ * Cleans content by removing tool call JSON blocks
122
+ */
123
+ export function cleanContentFromToolCalls(content, toolCalls) {
124
+ if (toolCalls.length === 0)
125
+ return content;
126
+ let cleanedContent = content;
127
+ // Use the new XML parser to clean XML tool calls
128
+ if (XMLToolCallParser.hasToolCalls(cleanedContent)) {
129
+ cleanedContent = XMLToolCallParser.removeToolCallsFromContent(cleanedContent);
130
+ }
131
+ // XML cleaning is handled by XMLToolCallParser.removeToolCallsFromContent above
132
+ // Handle markdown code blocks that contain only tool calls
133
+ const codeBlockRegex = /```(?:json)?\s*\n?([\s\S]*?)\n?```/g;
134
+ cleanedContent = cleanedContent.replace(codeBlockRegex, (match, blockContent) => {
135
+ const trimmedBlock = blockContent.trim();
136
+ // Check if this block contains a tool call that we parsed
137
+ try {
138
+ const parsed = JSON.parse(trimmedBlock);
139
+ if (parsed.name && parsed.arguments !== undefined) {
140
+ // This code block contains only a tool call, remove the entire block
141
+ return '';
142
+ }
143
+ }
144
+ catch (e) {
145
+ // Not valid JSON, keep the code block
146
+ }
147
+ // Keep the code block as-is if it doesn't contain a tool call
148
+ return match;
149
+ });
150
+ // XML tool call cleaning is handled by XMLToolCallParser above
151
+ // Remove JSON blocks that were parsed as tool calls (for non-code-block cases)
152
+ const toolCallPatterns = [
153
+ /\{\s*\n\s*"name":\s*"([^"]+)",\s*\n\s*"arguments":\s*\{[\s\S]*?\}\s*\n\s*\}/g, // Multiline JSON blocks
154
+ /\{"name":\s*"([^"]+)",\s*"arguments":\s*(\{[^}]*\})\}/g,
155
+ /\{"name":\s*"([^"]+)",\s*"arguments":\s*(\{[^}]+\})\}/g,
156
+ /\{"name":\s*"([^"]+)",\s*"arguments":\s*"([^"]+)"\}/g,
157
+ ];
158
+ for (const pattern of toolCallPatterns) {
159
+ cleanedContent = cleanedContent.replace(pattern, '').trim();
160
+ }
161
+ // Clean up extra whitespace and newlines
162
+ cleanedContent = cleanedContent
163
+ .replace(/\n\s*\n\s*\n/g, '\n\n') // Reduce multiple newlines to double
164
+ .replace(/^\s*\n+|\n+\s*$/g, '') // Remove leading/trailing newlines
165
+ .trim();
166
+ return cleanedContent;
167
+ }
168
+ //# sourceMappingURL=json-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-parser.js","sourceRoot":"","sources":["../../source/tool-calling/json-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAElD,2EAA2E;AAE3E,MAAM,UAAU,yBAAyB,CAAC,OAAe;IACxD,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,IAAI,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAEpC,kEAAkE;IAClE,IAAI,iBAAiB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAG,iBAAiB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC9D,MAAM,cAAc,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACzE,cAAc,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;QAEvC,mFAAmF;QACnF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,WAAW,GAAG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ET,OAAO,cAAc,CAAC;AACvB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { ToolCall } from '../types/index.js';
2
+ export interface ParsedToolCall {
3
+ toolName: string;
4
+ parameters: Record<string, any>;
5
+ }
6
+ /**
7
+ * Parses XML-formatted tool calls from non-function-calling models
8
+ * Expected format: <tool_name><param1>value1</param1><param2>value2</param2></tool_name>
9
+ */
10
+ export declare class XMLToolCallParser {
11
+ private static readonly TOOL_CALL_REGEX;
12
+ private static readonly PARAMETER_REGEX;
13
+ /**
14
+ * Extracts tool calls from text content containing XML-formatted tool calls
15
+ */
16
+ static parseToolCalls(content: string): ParsedToolCall[];
17
+ /**
18
+ * Parses parameters from inner XML content
19
+ */
20
+ private static parseParameters;
21
+ /**
22
+ * Converts parsed tool calls to the standard ToolCall format
23
+ */
24
+ static convertToToolCalls(parsedCalls: ParsedToolCall[]): ToolCall[];
25
+ /**
26
+ * Removes XML tool call blocks from content, leaving only the text
27
+ */
28
+ static removeToolCallsFromContent(content: string): string;
29
+ /**
30
+ * Checks if content contains XML-formatted tool calls
31
+ */
32
+ static hasToolCalls(content: string): boolean;
33
+ }
34
+ //# sourceMappingURL=xml-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-parser.d.ts","sourceRoot":"","sources":["../../source/tool-calling/xml-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAA0B;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAyB;IAEhE;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE;IAmCxD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAsB9B;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,QAAQ,EAAE;IAUpE;;OAEG;IACH,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAiC1D;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAa7C"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Parses XML-formatted tool calls from non-function-calling models
3
+ * Expected format: <tool_name><param1>value1</param1><param2>value2</param2></tool_name>
4
+ */
5
+ export class XMLToolCallParser {
6
+ static TOOL_CALL_REGEX = /<(\w+)>(.*?)<\/\1>/gs;
7
+ static PARAMETER_REGEX = /<(\w+)>(.*?)<\/\1>/g;
8
+ /**
9
+ * Extracts tool calls from text content containing XML-formatted tool calls
10
+ */
11
+ static parseToolCalls(content) {
12
+ const toolCalls = [];
13
+ let match;
14
+ // Handle content that might be wrapped in markdown code blocks
15
+ let processedContent = content;
16
+ const codeBlockMatch = content.match(/```(?:\w+)?\s*\n?([\s\S]*?)\n?```/);
17
+ if (codeBlockMatch && codeBlockMatch[1]) {
18
+ processedContent = codeBlockMatch[1].trim();
19
+ }
20
+ // Remove <tool_call> wrapper tags if present
21
+ processedContent = processedContent.replace(/<\/?tool_call>/g, '').trim();
22
+ // Find all tool call blocks
23
+ this.TOOL_CALL_REGEX.lastIndex = 0; // Reset regex state
24
+ while ((match = this.TOOL_CALL_REGEX.exec(processedContent)) !== null) {
25
+ const [, toolName, innerXml] = match;
26
+ // Skip if this is a generic "tool_call" tag that slipped through
27
+ if (toolName === 'tool_call') {
28
+ continue;
29
+ }
30
+ const parameters = this.parseParameters(innerXml);
31
+ toolCalls.push({
32
+ toolName,
33
+ parameters,
34
+ });
35
+ }
36
+ return toolCalls;
37
+ }
38
+ /**
39
+ * Parses parameters from inner XML content
40
+ */
41
+ static parseParameters(innerXml) {
42
+ const parameters = {};
43
+ let match;
44
+ // Reset regex state
45
+ this.PARAMETER_REGEX.lastIndex = 0;
46
+ while ((match = this.PARAMETER_REGEX.exec(innerXml)) !== null) {
47
+ const [, paramName, paramValue] = match;
48
+ // Try to parse as JSON for complex objects/arrays
49
+ try {
50
+ parameters[paramName] = JSON.parse(paramValue);
51
+ }
52
+ catch {
53
+ // If not valid JSON, use as string
54
+ parameters[paramName] = paramValue;
55
+ }
56
+ }
57
+ return parameters;
58
+ }
59
+ /**
60
+ * Converts parsed tool calls to the standard ToolCall format
61
+ */
62
+ static convertToToolCalls(parsedCalls) {
63
+ return parsedCalls.map((call, index) => ({
64
+ id: `xml_call_${index}`,
65
+ function: {
66
+ name: call.toolName,
67
+ arguments: call.parameters,
68
+ },
69
+ }));
70
+ }
71
+ /**
72
+ * Removes XML tool call blocks from content, leaving only the text
73
+ */
74
+ static removeToolCallsFromContent(content) {
75
+ let cleanedContent = content;
76
+ // Remove all markdown code blocks that contain XML tool calls (using global flag)
77
+ cleanedContent = cleanedContent.replace(/```(?:\w+)?\s*\n?([\s\S]*?)\n?```/g, (match, blockContent) => {
78
+ if (blockContent) {
79
+ // Reset regex and check if this block contains XML tool calls
80
+ this.TOOL_CALL_REGEX.lastIndex = 0;
81
+ if (this.TOOL_CALL_REGEX.test(blockContent)) {
82
+ // This code block contains XML tool calls, remove it entirely
83
+ return '';
84
+ }
85
+ }
86
+ // Keep blocks that don't contain XML tool calls
87
+ return match;
88
+ });
89
+ // Remove XML tool calls that aren't in code blocks
90
+ this.TOOL_CALL_REGEX.lastIndex = 0;
91
+ cleanedContent = cleanedContent.replace(this.TOOL_CALL_REGEX, '').trim();
92
+ // Remove any <tool_call> wrapper tags that may be left behind
93
+ cleanedContent = cleanedContent.replace(/<\/?tool_call>/g, '').trim();
94
+ // Clean up extra whitespace and empty lines
95
+ cleanedContent = cleanedContent.replace(/\n\s*\n\s*\n/g, '\n\n').trim();
96
+ return cleanedContent;
97
+ }
98
+ /**
99
+ * Checks if content contains XML-formatted tool calls
100
+ */
101
+ static hasToolCalls(content) {
102
+ // Handle content that might be wrapped in markdown code blocks
103
+ let processedContent = content;
104
+ const codeBlockMatch = content.match(/```(?:\w+)?\s*\n?([\s\S]*?)\n?```/);
105
+ if (codeBlockMatch && codeBlockMatch[1]) {
106
+ processedContent = codeBlockMatch[1].trim();
107
+ }
108
+ this.TOOL_CALL_REGEX.lastIndex = 0;
109
+ const result = this.TOOL_CALL_REGEX.test(processedContent);
110
+ return result;
111
+ }
112
+ }
113
+ //# sourceMappingURL=xml-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-parser.js","sourceRoot":"","sources":["../../source/tool-calling/xml-parser.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACrB,MAAM,CAAU,eAAe,GAAG,sBAAsB,CAAC;IACzD,MAAM,CAAU,eAAe,GAAG,qBAAqB,CAAC;IAEhE;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAe;QACpC,MAAM,SAAS,GAAqB,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC;QAEV,+DAA+D;QAC/D,IAAI,gBAAgB,GAAG,OAAO,CAAC;QAC/B,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAC1E,IAAI,cAAc,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,gBAAgB,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7C,CAAC;QAED,6CAA6C;QAC7C,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAE1E,4BAA4B;QAC5B,IAAI,CAAC,eAAe,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,oBAAoB;QACxD,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,eAA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AC,EAAE,CAAC;YACzC,gBAAgB,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,SAAS,GAAG,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE3D,OAAO,MAAM,CAAC;IACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ToolDefinition } from '../types/index.js';
2
+ export declare const createFileTool: ToolDefinition;
3
+ //# sourceMappingURL=create-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-file.d.ts","sourceRoot":"","sources":["../../source/tools/create-file.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAiFnE,eAAO,MAAM,cAAc,EAAE,cAyB5B,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { resolve } from 'node:path';
3
+ import { writeFile } from 'node:fs/promises';
4
+ import { highlight } from 'cli-highlight';
5
+ import React from 'react';
6
+ import { Text, Box } from 'ink';
7
+ import { ThemeContext } from '../hooks/useTheme.js';
8
+ import { getLanguageFromExtension } from '../utils/programming-language-helper.js';
9
+ import ToolMessage from '../components/tool-message.js';
10
+ const handler = async (args) => {
11
+ const absPath = resolve(args.path);
12
+ await writeFile(absPath, args.content, 'utf-8');
13
+ return 'File written successfully';
14
+ };
15
+ // Create a component that will re-render when theme changes
16
+ const CreateFileFormatter = React.memo(({ args }) => {
17
+ const { colors } = React.useContext(ThemeContext);
18
+ const path = args.path || args.file_path || 'unknown';
19
+ const newContent = args.content || '';
20
+ const lineCount = newContent.split('\n').length;
21
+ const charCount = newContent.length;
22
+ // Estimate tokens (rough approximation: ~4 characters per token)
23
+ const estimatedTokens = Math.ceil(charCount / 4);
24
+ const messageContent = (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: colors.tool, children: "\u2692 create_file" }), _jsxs(Box, { children: [_jsx(Text, { color: colors.secondary, children: "Path: " }), _jsx(Text, { color: colors.white, children: path })] }), _jsxs(Box, { children: [_jsx(Text, { color: colors.secondary, children: "Size: " }), _jsxs(Text, { color: colors.white, children: [lineCount, " lines, ", charCount, " characters (~", estimatedTokens, " tokens)"] })] }), newContent.length > 0 ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { color: colors.white, children: "File content:" }), newContent.split('\n').map((line, i) => {
25
+ const lineNumStr = String(i + 1).padStart(4, ' ');
26
+ const ext = path.split('.').pop()?.toLowerCase();
27
+ const language = getLanguageFromExtension(ext);
28
+ try {
29
+ const highlighted = highlight(line, { language, theme: 'default' });
30
+ return (_jsxs(Box, { children: [_jsxs(Text, { color: colors.secondary, children: [lineNumStr, " "] }), _jsx(Text, { wrap: "wrap", children: highlighted })] }, i));
31
+ }
32
+ catch {
33
+ return (_jsxs(Box, { children: [_jsxs(Text, { color: colors.secondary, children: [lineNumStr, " "] }), _jsx(Text, { wrap: "wrap", children: line })] }, i));
34
+ }
35
+ })] })) : (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: colors.secondary, children: "File will be empty" }) }))] }));
36
+ return _jsx(ToolMessage, { message: messageContent, hideBox: true });
37
+ });
38
+ const formatter = async (args) => {
39
+ return _jsx(CreateFileFormatter, { args: args });
40
+ };
41
+ export const createFileTool = {
42
+ handler,
43
+ formatter,
44
+ config: {
45
+ type: 'function',
46
+ function: {
47
+ name: 'create_file',
48
+ description: 'Create a new file with the specified content (overwrites if file exists)',
49
+ parameters: {
50
+ type: 'object',
51
+ properties: {
52
+ path: {
53
+ type: 'string',
54
+ description: 'The path to the file to write.',
55
+ },
56
+ content: {
57
+ type: 'string',
58
+ description: 'The content to write to the file.',
59
+ },
60
+ },
61
+ required: ['path', 'content'],
62
+ },
63
+ },
64
+ },
65
+ };
66
+ //# sourceMappingURL=create-file.js.map
@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EAAE,SAAS,CAAC;aAC7B;SACD;KACD;CACD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ToolDefinition } from '../types/index.js';
2
+ export declare const deleteLinesTool: ToolDefinition;
3
+ //# sourceMappingURL=delete-lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-lines.d.ts","sourceRoot":"","sources":["../../source/tools/delete-lines.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,cAAc,EAAC,MAAM,mBAAmB,CAAC;AA4UnE,eAAO,MAAM,eAAe,EAAE,cA4B7B,CAAC"}