@pasosdejesus/m 0.15.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 (324) hide show
  1. package/dist/blockchain/deployments.d.ts +40 -0
  2. package/dist/blockchain/deployments.d.ts.map +1 -0
  3. package/dist/blockchain/deployments.js +64 -0
  4. package/dist/debug/DebugConsole.d.ts +22 -0
  5. package/dist/debug/DebugConsole.d.ts.map +1 -0
  6. package/dist/debug/DebugConsole.js +79 -0
  7. package/dist/debug/Logger.d.ts +38 -0
  8. package/dist/debug/Logger.d.ts.map +1 -0
  9. package/dist/debug/Logger.js +94 -0
  10. package/dist/debug/index.d.ts +6 -0
  11. package/dist/debug/index.d.ts.map +1 -0
  12. package/dist/debug/index.js +4 -0
  13. package/dist/debug/useLogger.d.ts +14 -0
  14. package/dist/debug/useLogger.d.ts.map +1 -0
  15. package/dist/debug/useLogger.js +23 -0
  16. package/dist/debug/utils.d.ts +10 -0
  17. package/dist/debug/utils.d.ts.map +1 -0
  18. package/dist/debug/utils.js +53 -0
  19. package/dist/e2e/assertions.d.ts +5 -0
  20. package/dist/e2e/assertions.d.ts.map +1 -0
  21. package/dist/e2e/assertions.js +18 -0
  22. package/dist/e2e/browser.d.ts +37 -0
  23. package/dist/e2e/browser.d.ts.map +1 -0
  24. package/dist/e2e/browser.js +97 -0
  25. package/dist/e2e/env.d.ts +18 -0
  26. package/dist/e2e/env.d.ts.map +1 -0
  27. package/dist/e2e/env.js +57 -0
  28. package/dist/e2e/index.d.ts +11 -0
  29. package/dist/e2e/index.d.ts.map +1 -0
  30. package/dist/e2e/index.js +8 -0
  31. package/dist/e2e/navigation.d.ts +4 -0
  32. package/dist/e2e/navigation.d.ts.map +1 -0
  33. package/dist/e2e/navigation.js +32 -0
  34. package/dist/e2e/siwe-mock.d.ts +11 -0
  35. package/dist/e2e/siwe-mock.d.ts.map +1 -0
  36. package/dist/e2e/siwe-mock.js +112 -0
  37. package/dist/e2e/siwe.d.ts +15 -0
  38. package/dist/e2e/siwe.d.ts.map +1 -0
  39. package/dist/e2e/siwe.js +85 -0
  40. package/dist/e2e/wallet-mock.d.ts +13 -0
  41. package/dist/e2e/wallet-mock.d.ts.map +1 -0
  42. package/dist/e2e/wallet-mock.js +91 -0
  43. package/dist/i18n/common-cli.d.ts +11 -0
  44. package/dist/i18n/common-cli.d.ts.map +1 -0
  45. package/dist/i18n/common-cli.js +22 -0
  46. package/dist/i18n/createTranslator.d.ts +28 -0
  47. package/dist/i18n/createTranslator.d.ts.map +1 -0
  48. package/dist/i18n/createTranslator.js +48 -0
  49. package/dist/i18n/index.d.ts +4 -0
  50. package/dist/i18n/index.d.ts.map +1 -0
  51. package/dist/i18n/index.js +2 -0
  52. package/dist/i18n/locales/cli.d.ts +3 -0
  53. package/dist/i18n/locales/cli.d.ts.map +1 -0
  54. package/dist/i18n/locales/cli.js +180 -0
  55. package/dist/i18n/types.d.ts +3 -0
  56. package/dist/i18n/types.d.ts.map +1 -0
  57. package/dist/i18n/types.js +1 -0
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +15 -0
  61. package/dist/index.test.d.ts +2 -0
  62. package/dist/index.test.d.ts.map +1 -0
  63. package/dist/index.test.js +10 -0
  64. package/dist/m.d.ts +2 -0
  65. package/dist/m.d.ts.map +1 -0
  66. package/dist/m.js +334 -0
  67. package/dist/plugin.d.ts +10 -0
  68. package/dist/plugin.d.ts.map +1 -0
  69. package/dist/plugin.js +7 -0
  70. package/dist/shadcn_components/cn.d.ts +13 -0
  71. package/dist/shadcn_components/cn.d.ts.map +1 -0
  72. package/dist/shadcn_components/cn.js +15 -0
  73. package/dist/shadcn_components/ui/accordion.d.ts +8 -0
  74. package/dist/shadcn_components/ui/accordion.d.ts.map +1 -0
  75. package/dist/shadcn_components/ui/accordion.js +14 -0
  76. package/dist/shadcn_components/ui/alert-dialog.d.ts +21 -0
  77. package/dist/shadcn_components/ui/alert-dialog.d.ts.map +1 -0
  78. package/dist/shadcn_components/ui/alert-dialog.js +27 -0
  79. package/dist/shadcn_components/ui/alert.d.ts +9 -0
  80. package/dist/shadcn_components/ui/alert.d.ts.map +1 -0
  81. package/dist/shadcn_components/ui/alert.js +22 -0
  82. package/dist/shadcn_components/ui/avatar.d.ts +7 -0
  83. package/dist/shadcn_components/ui/avatar.d.ts.map +1 -0
  84. package/dist/shadcn_components/ui/avatar.js +12 -0
  85. package/dist/shadcn_components/ui/badge.d.ts +10 -0
  86. package/dist/shadcn_components/ui/badge.d.ts.map +1 -0
  87. package/dist/shadcn_components/ui/badge.js +22 -0
  88. package/dist/shadcn_components/ui/button.d.ts +11 -0
  89. package/dist/shadcn_components/ui/button.d.ts.map +1 -0
  90. package/dist/shadcn_components/ui/button.js +31 -0
  91. package/dist/shadcn_components/ui/card.d.ts +10 -0
  92. package/dist/shadcn_components/ui/card.d.ts.map +1 -0
  93. package/dist/shadcn_components/ui/card.js +24 -0
  94. package/dist/shadcn_components/ui/checkbox.d.ts +5 -0
  95. package/dist/shadcn_components/ui/checkbox.d.ts.map +1 -0
  96. package/dist/shadcn_components/ui/checkbox.js +9 -0
  97. package/dist/shadcn_components/ui/dialog.d.ts +20 -0
  98. package/dist/shadcn_components/ui/dialog.d.ts.map +1 -0
  99. package/dist/shadcn_components/ui/dialog.js +23 -0
  100. package/dist/shadcn_components/ui/dropdown-menu.d.ts +28 -0
  101. package/dist/shadcn_components/ui/dropdown-menu.d.ts.map +1 -0
  102. package/dist/shadcn_components/ui/dropdown-menu.js +36 -0
  103. package/dist/shadcn_components/ui/form.d.ts +24 -0
  104. package/dist/shadcn_components/ui/form.d.ts.map +1 -0
  105. package/dist/shadcn_components/ui/form.js +63 -0
  106. package/dist/shadcn_components/ui/input.d.ts +4 -0
  107. package/dist/shadcn_components/ui/input.d.ts.map +1 -0
  108. package/dist/shadcn_components/ui/input.js +6 -0
  109. package/dist/shadcn_components/ui/label.d.ts +6 -0
  110. package/dist/shadcn_components/ui/label.d.ts.map +1 -0
  111. package/dist/shadcn_components/ui/label.js +10 -0
  112. package/dist/shadcn_components/ui/menubar.d.ts +29 -0
  113. package/dist/shadcn_components/ui/menubar.d.ts.map +1 -0
  114. package/dist/shadcn_components/ui/menubar.js +46 -0
  115. package/dist/shadcn_components/ui/popover.d.ts +7 -0
  116. package/dist/shadcn_components/ui/popover.d.ts.map +1 -0
  117. package/dist/shadcn_components/ui/popover.js +10 -0
  118. package/dist/shadcn_components/ui/progress.d.ts +5 -0
  119. package/dist/shadcn_components/ui/progress.d.ts.map +1 -0
  120. package/dist/shadcn_components/ui/progress.js +8 -0
  121. package/dist/shadcn_components/ui/radio-group.d.ts +6 -0
  122. package/dist/shadcn_components/ui/radio-group.d.ts.map +1 -0
  123. package/dist/shadcn_components/ui/radio-group.js +15 -0
  124. package/dist/shadcn_components/ui/scroll-area.d.ts +6 -0
  125. package/dist/shadcn_components/ui/scroll-area.d.ts.map +1 -0
  126. package/dist/shadcn_components/ui/scroll-area.js +12 -0
  127. package/dist/shadcn_components/ui/select.d.ts +14 -0
  128. package/dist/shadcn_components/ui/select.d.ts.map +1 -0
  129. package/dist/shadcn_components/ui/select.js +27 -0
  130. package/dist/shadcn_components/ui/separator.d.ts +5 -0
  131. package/dist/shadcn_components/ui/separator.d.ts.map +1 -0
  132. package/dist/shadcn_components/ui/separator.js +8 -0
  133. package/dist/shadcn_components/ui/sheet.d.ts +26 -0
  134. package/dist/shadcn_components/ui/sheet.d.ts.map +1 -0
  135. package/dist/shadcn_components/ui/sheet.js +37 -0
  136. package/dist/shadcn_components/ui/skeleton.d.ts +3 -0
  137. package/dist/shadcn_components/ui/skeleton.d.ts.map +1 -0
  138. package/dist/shadcn_components/ui/skeleton.js +6 -0
  139. package/dist/shadcn_components/ui/slider.d.ts +5 -0
  140. package/dist/shadcn_components/ui/slider.d.ts.map +1 -0
  141. package/dist/shadcn_components/ui/slider.js +8 -0
  142. package/dist/shadcn_components/ui/switch.d.ts +5 -0
  143. package/dist/shadcn_components/ui/switch.d.ts.map +1 -0
  144. package/dist/shadcn_components/ui/switch.js +8 -0
  145. package/dist/shadcn_components/ui/table.d.ts +11 -0
  146. package/dist/shadcn_components/ui/table.d.ts.map +1 -0
  147. package/dist/shadcn_components/ui/table.js +20 -0
  148. package/dist/shadcn_components/ui/tabs.d.ts +8 -0
  149. package/dist/shadcn_components/ui/tabs.d.ts.map +1 -0
  150. package/dist/shadcn_components/ui/tabs.js +13 -0
  151. package/dist/shadcn_components/ui/textarea.d.ts +4 -0
  152. package/dist/shadcn_components/ui/textarea.d.ts.map +1 -0
  153. package/dist/shadcn_components/ui/textarea.js +8 -0
  154. package/dist/shadcn_components/ui/toast.d.ts +16 -0
  155. package/dist/shadcn_components/ui/toast.d.ts.map +1 -0
  156. package/dist/shadcn_components/ui/toast.js +34 -0
  157. package/dist/shadcn_components/ui/toaster.d.ts +2 -0
  158. package/dist/shadcn_components/ui/toaster.d.ts.map +1 -0
  159. package/dist/shadcn_components/ui/toaster.js +10 -0
  160. package/dist/shadcn_components/ui/tooltip.d.ts +8 -0
  161. package/dist/shadcn_components/ui/tooltip.d.ts.map +1 -0
  162. package/dist/shadcn_components/ui/tooltip.js +11 -0
  163. package/dist/shadcn_components/ui/use-toast.d.ts +45 -0
  164. package/dist/shadcn_components/ui/use-toast.d.ts.map +1 -0
  165. package/dist/shadcn_components/ui/use-toast.js +126 -0
  166. package/dist/tasks/context.d.ts +13 -0
  167. package/dist/tasks/context.d.ts.map +1 -0
  168. package/dist/tasks/context.js +310 -0
  169. package/dist/tasks/create.d.ts +2 -0
  170. package/dist/tasks/create.d.ts.map +1 -0
  171. package/dist/tasks/create.js +91 -0
  172. package/dist/tasks/db.d.ts +19 -0
  173. package/dist/tasks/db.d.ts.map +1 -0
  174. package/dist/tasks/db.js +791 -0
  175. package/dist/tasks/e2e.d.ts +2 -0
  176. package/dist/tasks/e2e.d.ts.map +1 -0
  177. package/dist/tasks/e2e.js +124 -0
  178. package/dist/tasks/edit.d.ts +7 -0
  179. package/dist/tasks/edit.d.ts.map +1 -0
  180. package/dist/tasks/edit.js +471 -0
  181. package/dist/tasks/engine.d.ts +2 -0
  182. package/dist/tasks/engine.d.ts.map +1 -0
  183. package/dist/tasks/engine.js +149 -0
  184. package/dist/tasks/env-diff.d.ts +2 -0
  185. package/dist/tasks/env-diff.d.ts.map +1 -0
  186. package/dist/tasks/env-diff.js +140 -0
  187. package/dist/tasks/fuzzy.d.ts +9 -0
  188. package/dist/tasks/fuzzy.d.ts.map +1 -0
  189. package/dist/tasks/fuzzy.js +153 -0
  190. package/dist/tasks/glob.d.ts +5 -0
  191. package/dist/tasks/glob.d.ts.map +1 -0
  192. package/dist/tasks/glob.js +57 -0
  193. package/dist/tasks/grep.d.ts +9 -0
  194. package/dist/tasks/grep.d.ts.map +1 -0
  195. package/dist/tasks/grep.js +93 -0
  196. package/dist/tasks/readfile.d.ts +2 -0
  197. package/dist/tasks/readfile.d.ts.map +1 -0
  198. package/dist/tasks/readfile.js +177 -0
  199. package/dist/tasks/update.d.ts +5 -0
  200. package/dist/tasks/update.d.ts.map +1 -0
  201. package/dist/tasks/update.js +200 -0
  202. package/dist/tasks/util.d.ts +12 -0
  203. package/dist/tasks/util.d.ts.map +1 -0
  204. package/dist/tasks/util.js +42 -0
  205. package/dist/tasks/wallet.d.ts +2 -0
  206. package/dist/tasks/wallet.d.ts.map +1 -0
  207. package/dist/tasks/wallet.js +697 -0
  208. package/dist/tasks/writefile.d.ts +2 -0
  209. package/dist/tasks/writefile.d.ts.map +1 -0
  210. package/dist/tasks/writefile.js +66 -0
  211. package/dist/templates/AGENTS.md.hbs +81 -0
  212. package/dist/templates/ARCHITECTURE.md.hbs +146 -0
  213. package/dist/templates/CONTRIBUTING.md.hbs +83 -0
  214. package/dist/templates/LICENCIA.md +21 -0
  215. package/dist/templates/LICENSE.md +15 -0
  216. package/dist/templates/Makefile +16 -0
  217. package/dist/templates/README.md.hbs +111 -0
  218. package/dist/templates/apps/.env.example.hbs +75 -0
  219. package/dist/templates/apps/hardhat/.prettierrc +16 -0
  220. package/dist/templates/apps/hardhat/MOCK_USDT_README.md +20 -0
  221. package/dist/templates/apps/hardhat/Makefile +13 -0
  222. package/dist/templates/apps/hardhat/README.md +129 -0
  223. package/dist/templates/apps/hardhat/bin/MusdtVerification +4 -0
  224. package/dist/templates/apps/hardhat/bin/approveDepositOwner +7 -0
  225. package/dist/templates/apps/hardhat/bin/contractVerification +9 -0
  226. package/dist/templates/apps/hardhat/bin/deployMockUSDT +7 -0
  227. package/dist/templates/apps/hardhat/bin/prepadJ.sh +14 -0
  228. package/dist/templates/apps/hardhat/bin/verifyMockUSDT +7 -0
  229. package/dist/templates/apps/hardhat/contracts/MockUSDT.sol +47 -0
  230. package/dist/templates/apps/hardhat/hardhat.config.ts +102 -0
  231. package/dist/templates/apps/hardhat/package.json +55 -0
  232. package/dist/templates/apps/hardhat/scripts/approveDepositOwner.ts +22 -0
  233. package/dist/templates/apps/hardhat/scripts/deployMockUSDT.ts +49 -0
  234. package/dist/templates/apps/hardhat/scripts/verifyDeployment.ts +93 -0
  235. package/dist/templates/apps/hardhat/scripts/verifyMockUSDT.ts +52 -0
  236. package/dist/templates/apps/hardhat/sync-abis.mjs +58 -0
  237. package/dist/templates/apps/hardhat/test/MockUSDT.test.ts +40 -0
  238. package/dist/templates/apps/hardhat/tsconfig.json +27 -0
  239. package/dist/templates/apps/nextjs/.config/kysely.config.ts +36 -0
  240. package/dist/templates/apps/nextjs/Makefile +24 -0
  241. package/dist/templates/apps/nextjs/README.md.hbs +76 -0
  242. package/dist/templates/apps/nextjs/abis/IERC20.json +74 -0
  243. package/dist/templates/apps/nextjs/abis/MockUSDT.json +242 -0
  244. package/dist/templates/apps/nextjs/abis/ReentrancyGuard.json +1 -0
  245. package/dist/templates/apps/nextjs/app/globals.css +3 -0
  246. package/dist/templates/apps/nextjs/app/layout.tsx.hbs +26 -0
  247. package/dist/templates/apps/nextjs/app/page.tsx.hbs +225 -0
  248. package/dist/templates/apps/nextjs/app/testui/page.tsx +371 -0
  249. package/dist/templates/apps/nextjs/bin/m +8 -0
  250. package/dist/templates/apps/nextjs/components.json +21 -0
  251. package/dist/templates/apps/nextjs/next-env.d.ts +5 -0
  252. package/dist/templates/apps/nextjs/next.config.ts +10 -0
  253. package/dist/templates/apps/nextjs/package.json.hbs +48 -0
  254. package/dist/templates/apps/nextjs/pnpm-workspace.yaml +13 -0
  255. package/dist/templates/apps/nextjs/postcss.config.mjs +6 -0
  256. package/dist/templates/apps/nextjs/tailwind.config.js +11 -0
  257. package/dist/templates/apps/nextjs/tests/helpers.ts +31 -0
  258. package/dist/templates/apps/nextjs/tests/index.test.ts +7 -0
  259. package/dist/templates/apps/nextjs/tests/setup-env.ts.hbs +8 -0
  260. package/dist/templates/apps/nextjs/tests/test-utils.example.test.ts +168 -0
  261. package/dist/templates/apps/nextjs/tsconfig.json +44 -0
  262. package/dist/templates/apps/nextjs/tsconfig.test.json +38 -0
  263. package/dist/templates/apps/nextjs/vitest.config.ts +13 -0
  264. package/dist/test-utils/fs-mocks.d.ts +32 -0
  265. package/dist/test-utils/fs-mocks.d.ts.map +1 -0
  266. package/dist/test-utils/fs-mocks.js +63 -0
  267. package/dist/test-utils/i18n-mock.d.ts +21 -0
  268. package/dist/test-utils/i18n-mock.d.ts.map +1 -0
  269. package/dist/test-utils/i18n-mock.js +29 -0
  270. package/dist/test-utils/index.d.ts +12 -0
  271. package/dist/test-utils/index.d.ts.map +1 -0
  272. package/dist/test-utils/index.js +11 -0
  273. package/dist/test-utils/kysely-mocks.d.ts +298 -0
  274. package/dist/test-utils/kysely-mocks.d.ts.map +1 -0
  275. package/dist/test-utils/kysely-mocks.js +173 -0
  276. package/dist/test-utils/radix-mocks.d.ts +134 -0
  277. package/dist/test-utils/radix-mocks.d.ts.map +1 -0
  278. package/dist/test-utils/radix-mocks.js +175 -0
  279. package/dist/test-utils/rainbowkit-mocks.d.ts +80 -0
  280. package/dist/test-utils/rainbowkit-mocks.d.ts.map +1 -0
  281. package/dist/test-utils/rainbowkit-mocks.js +247 -0
  282. package/dist/test-utils/viem-mocks.d.ts +86 -0
  283. package/dist/test-utils/viem-mocks.d.ts.map +1 -0
  284. package/dist/test-utils/viem-mocks.js +54 -0
  285. package/dist/util/cli-parser.d.ts +20 -0
  286. package/dist/util/cli-parser.d.ts.map +1 -0
  287. package/dist/util/cli-parser.js +38 -0
  288. package/dist/util/colors.d.ts +5 -0
  289. package/dist/util/colors.d.ts.map +1 -0
  290. package/dist/util/colors.js +5 -0
  291. package/dist/util/locale.d.ts +3 -0
  292. package/dist/util/locale.d.ts.map +1 -0
  293. package/dist/util/locale.js +10 -0
  294. package/dist/wba/client.d.ts +19 -0
  295. package/dist/wba/client.d.ts.map +1 -0
  296. package/dist/wba/client.js +31 -0
  297. package/dist/wba/index.d.ts +4 -0
  298. package/dist/wba/index.d.ts.map +1 -0
  299. package/dist/wba/index.js +2 -0
  300. package/dist/wba/routes/event.d.ts +32 -0
  301. package/dist/wba/routes/event.d.ts.map +1 -0
  302. package/dist/wba/routes/event.js +42 -0
  303. package/dist/wba/routes/index.d.ts +3 -0
  304. package/dist/wba/routes/index.d.ts.map +1 -0
  305. package/dist/wba/routes/index.js +2 -0
  306. package/dist/wba/routes/summary.d.ts +44 -0
  307. package/dist/wba/routes/summary.d.ts.map +1 -0
  308. package/dist/wba/routes/summary.js +146 -0
  309. package/dist/wba/server.d.ts +18 -0
  310. package/dist/wba/server.d.ts.map +1 -0
  311. package/dist/wba/server.js +29 -0
  312. package/dist/wba/types.d.ts +68 -0
  313. package/dist/wba/types.d.ts.map +1 -0
  314. package/dist/wba/types.js +6 -0
  315. package/package.json +223 -0
  316. package/src/blockchain/README.md +80 -0
  317. package/src/debug/README.md +94 -0
  318. package/src/e2e/README.md +105 -0
  319. package/src/i18n/README.md +143 -0
  320. package/src/shadcn_components/README.md +125 -0
  321. package/src/tasks/README.md +69 -0
  322. package/src/test-utils/README.md +638 -0
  323. package/src/util/README.md +18 -0
  324. package/src/wba/README.md +175 -0
@@ -0,0 +1,177 @@
1
+ import { readFile, stat } from 'node:fs/promises';
2
+ import { resolve } from 'node:path';
3
+ import { success, problem, warn } from '../util/colors.js';
4
+ import { setClipboard as setCB } from './edit.js';
5
+ import { createTranslator } from '../i18n/createTranslator.js';
6
+ import { detectLocale } from '../util/locale.js';
7
+ import commonCli from '../i18n/common-cli.js';
8
+ const t = createTranslator(detectLocale(), {
9
+ en: {
10
+ 'readfile.no_files': '❌ No files specified. Diagnostic copied to clipboard.',
11
+ 'readfile.not_regular': '⚠️ {{0}}: Not a regular file',
12
+ 'readfile.header': '📄 {{0}} ({{1}} lines, {{2}}KB)',
13
+ 'readfile.not_found': '❌ {{0}}: File not found. Diagnostic copied to clipboard.',
14
+ 'readfile.read_error': '❌ {{0}}: Read error. Diagnostic copied to clipboard.',
15
+ 'readfile.copied_kb': '📋 Content copied to clipboard ({{0}}KB)',
16
+ 'readfile.copied_bytes': '📋 Content copied to clipboard ({{0}} bytes)',
17
+ },
18
+ es: {
19
+ 'readfile.no_files': '❌ No se especificó ningún archivo. Diagnóstico copiado al portapapeles.',
20
+ 'readfile.not_regular': '⚠️ {{0}}: No es un archivo regular',
21
+ 'readfile.header': '📄 {{0}} ({{1}} líneas, {{2}}KB)',
22
+ 'readfile.not_found': '❌ {{0}}: Archivo no encontrado. Diagnóstico copiado al portapapeles.',
23
+ 'readfile.read_error': '❌ {{0}}: Error de lectura. Diagnóstico copiado al portapapeles.',
24
+ 'readfile.copied_kb': '📋 Contenido copiado al portapapeles ({{0}}KB)',
25
+ 'readfile.copied_bytes': '📋 Contenido copiado al portapapeles ({{0}} bytes)',
26
+ },
27
+ }, commonCli);
28
+ function formatFileContent(content, _filePath, options) {
29
+ const lines = content.split('\n');
30
+ let startLine = 0;
31
+ let endLine = lines.length;
32
+ if (options.offset !== undefined)
33
+ startLine = Math.max(0, options.offset - 1);
34
+ if (options.lines !== undefined)
35
+ endLine = Math.min(lines.length, startLine + options.lines);
36
+ if (options.head !== undefined) {
37
+ endLine = Math.min(lines.length, options.head);
38
+ startLine = 0;
39
+ }
40
+ if (options.tail !== undefined) {
41
+ startLine = Math.max(0, lines.length - options.tail);
42
+ endLine = lines.length;
43
+ }
44
+ const selectedLines = lines.slice(startLine, endLine);
45
+ if (options.raw)
46
+ return selectedLines.join('\n');
47
+ return selectedLines.map((_, idx) => {
48
+ const lineNum = startLine + idx + 1;
49
+ return `${lineNum.toString().padStart(4, ' ')} | ${selectedLines[idx]}`;
50
+ }).join('\n');
51
+ }
52
+ async function setClipboard(content) {
53
+ try {
54
+ await setCB(content);
55
+ }
56
+ catch { /* silent */ }
57
+ }
58
+ export async function runAiReadFile(args) {
59
+ const files = [];
60
+ const options = {};
61
+ for (let i = 0; i < args.length; i++) {
62
+ const arg = args[i];
63
+ switch (arg) {
64
+ case '--lines':
65
+ options.lines = parseInt(args[++i]);
66
+ break;
67
+ case '--offset':
68
+ options.offset = parseInt(args[++i]);
69
+ break;
70
+ case '--head':
71
+ options.head = parseInt(args[++i]);
72
+ break;
73
+ case '--tail':
74
+ options.tail = parseInt(args[++i]);
75
+ break;
76
+ case '--raw':
77
+ options.raw = true;
78
+ break;
79
+ case '--no-clip':
80
+ options.noClip = true;
81
+ break;
82
+ default:
83
+ if (!arg.startsWith('-'))
84
+ files.push(arg);
85
+ }
86
+ }
87
+ if (files.length === 0) {
88
+ const diagnostic = `❌ Error: No se especificó ningún archivo.
89
+
90
+ Uso correcto:
91
+ ./bin/m ai:readfile <archivo1> [archivo2 ...]
92
+
93
+ Opciones disponibles:
94
+ --lines <N> Mostrar N líneas (desde offset o inicio)
95
+ --offset <N> Comenzar desde la línea N
96
+ --head <N> Mostrar primeras N líneas
97
+ --tail <N> Mostrar últimas N líneas
98
+ --raw Mostrar sin números de línea en pantalla
99
+ --no-clip No copiar al portapapeles (por defecto copia)
100
+
101
+ Ejemplo:
102
+ ./bin/m ai:readfile src/m.ts --head 20`;
103
+ await setClipboard(diagnostic);
104
+ problem(t('readfile.no_files'));
105
+ }
106
+ const shouldClip = !options.noClip;
107
+ const clipboardContents = [];
108
+ for (const file of files) {
109
+ const fullPath = resolve(process.cwd(), file);
110
+ try {
111
+ const fileStat = await stat(fullPath);
112
+ if (!fileStat.isFile()) {
113
+ warn(t('readfile.not_regular', file));
114
+ continue;
115
+ }
116
+ const content = await readFile(fullPath, 'utf-8');
117
+ const formatted = formatFileContent(content, file, options);
118
+ const sizeKB = Math.round(fileStat.size / 1024);
119
+ const lineCount = content.split('\n').length;
120
+ success(`\n${t('readfile.header', file, lineCount.toString(), sizeKB.toString())}`);
121
+ console.log(formatted);
122
+ console.log('');
123
+ if (shouldClip) {
124
+ let clipContent = content;
125
+ let lineInfo = '';
126
+ const lines = content.split('\n');
127
+ if (options.head !== undefined) {
128
+ clipContent = lines.slice(0, options.head).join('\n');
129
+ lineInfo = ` (primeras ${options.head} líneas)`;
130
+ }
131
+ else if (options.tail !== undefined) {
132
+ clipContent = lines.slice(-options.tail).join('\n');
133
+ lineInfo = ` (últimas ${options.tail} líneas)`;
134
+ }
135
+ else if (options.offset !== undefined) {
136
+ const start = options.offset - 1;
137
+ const end = options.lines ? start + options.lines : lines.length;
138
+ clipContent = lines.slice(start, end).join('\n');
139
+ lineInfo = ` (líneas ${options.offset}-${end})`;
140
+ }
141
+ else if (options.lines !== undefined) {
142
+ clipContent = lines.slice(0, options.lines).join('\n');
143
+ lineInfo = ` (primeras ${options.lines} líneas)`;
144
+ }
145
+ const HASH = '\u0023\u0023';
146
+ clipboardContents.push(`${HASH} Archivo: ${file}${lineInfo}`);
147
+ clipboardContents.push('```');
148
+ clipboardContents.push(clipContent);
149
+ clipboardContents.push('```');
150
+ clipboardContents.push('');
151
+ }
152
+ }
153
+ catch (err) {
154
+ if (err.code === 'ENOENT') {
155
+ const diagnostic = `❌ Error: Archivo no encontrado\n\nNo se encontró el archivo: ${file}\n\nRuta buscada: ${fullPath}\nDirectorio actual: ${process.cwd()}\n\nSugerencias:\n1. Verifica que la ruta sea correcta y relativa al directorio actual.\n2. Usa rutas relativas, no absolutas (ej: "src/m.ts" en lugar de "/home/usuario/src/m.ts").\n3. Ejecuta: ls -la ${file} para confirmar que existe.\n4. Usa ./bin/m ai:glob "*.ts" para listar archivos disponibles.`;
156
+ await setClipboard(diagnostic);
157
+ problem(t('readfile.not_found', file));
158
+ }
159
+ else {
160
+ const diagnostic = `❌ Error leyendo archivo: ${file}\n\nMensaje: ${err.message}\nRuta: ${fullPath}\n\nSugerencia: Verifica los permisos del archivo.`;
161
+ await setClipboard(diagnostic);
162
+ problem(t('readfile.read_error', file));
163
+ }
164
+ }
165
+ }
166
+ if (shouldClip && clipboardContents.length > 0) {
167
+ const clipContent = clipboardContents.join('\n');
168
+ if (clipContent.length > 0) {
169
+ await setClipboard(clipContent);
170
+ const sizeKB = Math.round(clipContent.length / 1024);
171
+ if (sizeKB > 0)
172
+ success(t('readfile.copied_kb', sizeKB.toString()));
173
+ else
174
+ success(t('readfile.copied_bytes', clipContent.length.toString()));
175
+ }
176
+ }
177
+ }
@@ -0,0 +1,5 @@
1
+ export declare function runUpdate(options?: {
2
+ check?: boolean;
3
+ yes?: boolean;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/tasks/update.ts"],"names":[],"mappings":"AA2GA,wBAAsB,SAAS,CAAC,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,iBAsG3E"}
@@ -0,0 +1,200 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as readline from 'readline';
4
+ import { spawnSync } from 'child_process';
5
+ import { fileURLToPath } from 'url';
6
+ import { dirname } from 'path';
7
+ import { globSync } from 'glob';
8
+ import { success, info, warn } from '../util/colors.js';
9
+ import { createTranslator } from '../i18n/createTranslator.js';
10
+ import { detectLocale } from '../util/locale.js';
11
+ import commonCli from '../i18n/common-cli.js';
12
+ const updateT = createTranslator(detectLocale(), {
13
+ en: {
14
+ 'update.comparing': 'Comparing project files with templates...',
15
+ 'update.file_new': 'New file available: {{0}}',
16
+ 'update.file_diff': 'Differences found in {{0}}',
17
+ 'update.prompt': 'Apply this update? [y: yes, n: no, d: diff, e: edit]: ',
18
+ 'update.applied': 'Update applied to {{0}}',
19
+ 'update.skipped': 'Skipped {{0}}',
20
+ 'update.error': 'Error updating {{0}}: {{1}}',
21
+ 'update.finished': 'Update process finished.',
22
+ },
23
+ es: {
24
+ 'update.comparing': 'Comparando los archivos del proyecto con las plantillas...',
25
+ 'update.file_new': 'Nuevo archivo disponible: {{0}}',
26
+ 'update.file_diff': 'Diferencias encontradas en {{0}}',
27
+ 'update.prompt': '¿Deseas aplicar esta actualización? [y: sí, n: no, d: diff, e: editar]: ',
28
+ 'update.applied': 'Actualización aplicada a {{0}}',
29
+ 'update.skipped': 'Se saltó {{0}}',
30
+ 'update.error': 'Error al actualizar {{0}}: {{1}}',
31
+ 'update.finished': 'Proceso de actualización terminado.',
32
+ },
33
+ }, commonCli);
34
+ const __filename = fileURLToPath(import.meta.url);
35
+ const __dirname = dirname(__filename);
36
+ function getTemplateDir() {
37
+ // __dirname is dist/tasks/ in the npm package
38
+ // dist/templates/ is where build copies templates
39
+ const distTemplates = path.join(__dirname, '..', 'templates');
40
+ if (fs.existsSync(distTemplates))
41
+ return distTemplates;
42
+ // Fallback for development: source tree templates/
43
+ const srcTemplates = path.join(__dirname, '..', '..', 'templates');
44
+ if (fs.existsSync(srcTemplates))
45
+ return srcTemplates;
46
+ // Last resort: templates/ next to tasks/
47
+ return path.join(__dirname, 'templates');
48
+ }
49
+ function getAllFiles(dirPath) {
50
+ return globSync('**/*', { cwd: dirPath, nodir: true });
51
+ }
52
+ async function showDiff(file1, file2) {
53
+ const hasDiff = spawnSync('which', ['diff'], { stdio: 'ignore' }).status === 0;
54
+ if (hasDiff) {
55
+ // OpenBSD diff doesn't support --color=always; test if it does before using it
56
+ const supportsColor = spawnSync('diff', ['--color=always', '/dev/null', '/dev/null'], { stdio: 'ignore' }).status === 0;
57
+ if (supportsColor) {
58
+ spawnSync('diff', ['-u', '--color=always', file1, file2], { stdio: 'inherit' });
59
+ }
60
+ else {
61
+ spawnSync('diff', ['-u', file1, file2], { stdio: 'inherit' });
62
+ }
63
+ }
64
+ else {
65
+ warn('Command "diff" not found. Showing content directly.');
66
+ info(`Template content for ${path.basename(file1)}:`);
67
+ console.log(fs.readFileSync(file1, 'utf-8'));
68
+ }
69
+ }
70
+ async function mergePackageJson(projectPath, templatePath) {
71
+ const projectPkg = JSON.parse(fs.readFileSync(projectPath, 'utf-8'));
72
+ const templatePkg = JSON.parse(fs.readFileSync(templatePath, 'utf-8'));
73
+ // Logic to merge specifically pnpm overrides and missing devDependencies
74
+ if (templatePkg.pnpm) {
75
+ projectPkg.pnpm = { ...(projectPkg.pnpm || {}), ...templatePkg.pnpm };
76
+ }
77
+ // Update dependencies only if they are missing or if we want to force template versions
78
+ const sections = ['dependencies', 'devDependencies'];
79
+ for (const section of sections) {
80
+ if (templatePkg[section]) {
81
+ projectPkg[section] = { ...(projectPkg[section] || {}), ...templatePkg[section] };
82
+ }
83
+ }
84
+ fs.writeFileSync(projectPath, JSON.stringify(projectPkg, null, 2), 'utf-8');
85
+ }
86
+ function findProjectRoot(startDir) {
87
+ let current = startDir;
88
+ while (current !== path.parse(current).root) {
89
+ // A project root in 'm' must have an 'apps' directory
90
+ if (fs.existsSync(path.join(current, 'apps'))) {
91
+ return current;
92
+ }
93
+ current = path.dirname(current);
94
+ }
95
+ return startDir;
96
+ }
97
+ export async function runUpdate(options) {
98
+ const t = updateT;
99
+ const opts = options || {};
100
+ const yesMode = opts.yes || false;
101
+ const checkMode = opts.check || false;
102
+ // Initialize readline only when needed (lazy initialization)
103
+ const rl = readline.createInterface({
104
+ input: process.stdin,
105
+ output: process.stdout
106
+ });
107
+ const question = (query) => new Promise((resolve) => rl.question(query, resolve));
108
+ try {
109
+ const startDir = process.cwd();
110
+ const projectRoot = findProjectRoot(startDir);
111
+ const templateDir = getTemplateDir();
112
+ info(`Project root identified at: ${projectRoot}`);
113
+ info(t('update.comparing'));
114
+ // Filter out .env files and other non-template assets
115
+ const templateFiles = getAllFiles(templateDir).filter(f => {
116
+ const name = path.basename(f);
117
+ return f !== 'pnpm-lock.yaml' &&
118
+ !name.startsWith('.env');
119
+ });
120
+ for (const relPath of templateFiles) {
121
+ // Determine project path (remove .hbs from relPath if present)
122
+ const projectRelPath = relPath.endsWith('.hbs') ? relPath.slice(0, -4) : relPath;
123
+ const projectPath = path.join(projectRoot, projectRelPath);
124
+ const templatePath = path.join(templateDir, relPath);
125
+ if (!fs.existsSync(projectPath)) {
126
+ if (checkMode) {
127
+ info(t('update.file_new', projectRelPath));
128
+ }
129
+ else if (yesMode) {
130
+ fs.mkdirSync(path.dirname(projectPath), { recursive: true });
131
+ fs.copyFileSync(templatePath, projectPath);
132
+ success(t('update.applied', projectRelPath));
133
+ }
134
+ else {
135
+ info(t('update.file_new', projectRelPath));
136
+ const answer = await question(t('update.prompt'));
137
+ if (answer.toLowerCase() === 'y') {
138
+ fs.mkdirSync(path.dirname(projectPath), { recursive: true });
139
+ fs.copyFileSync(templatePath, projectPath);
140
+ success(t('update.applied', projectRelPath));
141
+ }
142
+ }
143
+ }
144
+ else {
145
+ const projectContent = fs.readFileSync(projectPath, 'utf-8');
146
+ const templateContent = fs.readFileSync(templatePath, 'utf-8');
147
+ if (projectContent !== templateContent) {
148
+ if (checkMode) {
149
+ info(t('update.file_diff', projectRelPath));
150
+ await showDiff(templatePath, projectPath);
151
+ }
152
+ else if (yesMode) {
153
+ if (projectRelPath.endsWith('package.json')) {
154
+ await mergePackageJson(projectPath, templatePath);
155
+ }
156
+ else {
157
+ fs.copyFileSync(templatePath, projectPath);
158
+ }
159
+ success(t('update.applied', projectRelPath));
160
+ }
161
+ else {
162
+ info(t('update.file_diff', projectRelPath));
163
+ let loop = true;
164
+ while (loop) {
165
+ const answer = await question(t('update.prompt'));
166
+ switch (answer.toLowerCase()) {
167
+ case 'y':
168
+ if (projectRelPath.endsWith('package.json')) {
169
+ await mergePackageJson(projectPath, templatePath);
170
+ }
171
+ else {
172
+ fs.copyFileSync(templatePath, projectPath);
173
+ }
174
+ success(t('update.applied', projectRelPath));
175
+ loop = false;
176
+ break;
177
+ case 'n':
178
+ info(t('update.skipped', relPath));
179
+ loop = false;
180
+ break;
181
+ case 'd':
182
+ await showDiff(templatePath, projectPath);
183
+ break;
184
+ case 'e':
185
+ const editor = process.env.EDITOR || 'vi';
186
+ spawnSync(editor, [projectPath], { stdio: 'inherit' });
187
+ loop = false;
188
+ break;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ success(t('update.finished'));
196
+ }
197
+ finally {
198
+ rl.close();
199
+ }
200
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Searches for the `ia/` directory in multiple locations.
3
+ * Returns the first path found, or null if none exists.
4
+ *
5
+ * Search order:
6
+ * 1. Global installation: /usr/local/lib/node_modules/@pasosdejesus/m/ia
7
+ * 2. Package root: <package>/ia
8
+ * 3. Explicit node_modules: <cwd>/node_modules/@pasosdejesus/m/ia
9
+ * 4. Local project: <cwd>/ia
10
+ */
11
+ export declare function findIaDir(): Promise<string | null>;
12
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/tasks/util.ts"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBxD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared utilities for task implementations.
3
+ */
4
+ import { access } from 'node:fs/promises';
5
+ import { join, dirname } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ /**
9
+ * Searches for the `ia/` directory in multiple locations.
10
+ * Returns the first path found, or null if none exists.
11
+ *
12
+ * Search order:
13
+ * 1. Global installation: /usr/local/lib/node_modules/@pasosdejesus/m/ia
14
+ * 2. Package root: <package>/ia
15
+ * 3. Explicit node_modules: <cwd>/node_modules/@pasosdejesus/m/ia
16
+ * 4. Local project: <cwd>/ia
17
+ */
18
+ export async function findIaDir() {
19
+ const packageRoot = join(__dirname, '..', '..', '..');
20
+ const distIa = join(__dirname, '..', 'ia');
21
+ const paths = [
22
+ join('/usr/local/lib/node_modules', '@pasosdejesus', 'm', 'ia'),
23
+ join(packageRoot, 'ia'),
24
+ distIa,
25
+ join(process.cwd(), 'node_modules', '@pasosdejesus', 'm', 'ia'),
26
+ join(process.cwd(), 'node_modules', '@pasosdejesus', 'mpdj', 'ia'),
27
+ join(process.cwd(), 'ia'),
28
+ // Monorepo root: check packages/mpdj/ia/ (source) and packages/mpdj/dist/ia/ (compiled)
29
+ join(process.cwd(), 'packages', 'mpdj', 'ia'),
30
+ join(process.cwd(), 'packages', 'mpdj', 'dist', 'ia'),
31
+ ];
32
+ for (const p of paths) {
33
+ try {
34
+ await access(p);
35
+ return p;
36
+ }
37
+ catch {
38
+ // Not found, continue
39
+ }
40
+ }
41
+ return null;
42
+ }
@@ -0,0 +1,2 @@
1
+ export declare function runWallet(args: string[]): Promise<void>;
2
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/tasks/wallet.ts"],"names":[],"mappings":"AAorBA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,iBAiE7C"}