@pristine-ts/cli 2.0.7 → 2.0.16

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 (289) hide show
  1. package/dist/lib/cjs/bin.js +0 -0
  2. package/dist/lib/cjs/bootstrap/app-module-cache.js +71 -0
  3. package/dist/lib/cjs/bootstrap/app-module-cache.js.map +1 -0
  4. package/dist/lib/cjs/bootstrap/app-module-discoverer.js +119 -0
  5. package/dist/lib/cjs/bootstrap/app-module-discoverer.js.map +1 -0
  6. package/dist/lib/cjs/bootstrap/app-module-discovery-candidate.js +21 -0
  7. package/dist/lib/cjs/bootstrap/app-module-discovery-candidate.js.map +1 -0
  8. package/dist/lib/cjs/bootstrap/app-module-discovery-reason.enum.js +15 -0
  9. package/dist/lib/cjs/bootstrap/app-module-discovery-reason.enum.js.map +1 -0
  10. package/dist/lib/cjs/bootstrap/app-module-prompt.js +78 -0
  11. package/dist/lib/cjs/bootstrap/app-module-prompt.js.map +1 -0
  12. package/dist/lib/cjs/bootstrap/build-staleness-prompt.js +12 -13
  13. package/dist/lib/cjs/bootstrap/build-staleness-prompt.js.map +1 -1
  14. package/dist/lib/cjs/bootstrap/init-prompt.js +16 -47
  15. package/dist/lib/cjs/bootstrap/init-prompt.js.map +1 -1
  16. package/dist/lib/cjs/cli.configuration-keys.js +24 -0
  17. package/dist/lib/cjs/cli.configuration-keys.js.map +1 -0
  18. package/dist/lib/cjs/cli.js +23 -10
  19. package/dist/lib/cjs/cli.js.map +1 -1
  20. package/dist/lib/cjs/cli.module.js +29 -1
  21. package/dist/lib/cjs/cli.module.js.map +1 -1
  22. package/dist/lib/cjs/commands/commands.js +6 -0
  23. package/dist/lib/cjs/commands/commands.js.map +1 -1
  24. package/dist/lib/cjs/commands/config-init.command.js +133 -0
  25. package/dist/lib/cjs/commands/config-init.command.js.map +1 -0
  26. package/dist/lib/cjs/commands/logs-alias.command.js +49 -0
  27. package/dist/lib/cjs/commands/logs-alias.command.js.map +1 -0
  28. package/dist/lib/cjs/commands/logs.command-options.js +72 -0
  29. package/dist/lib/cjs/commands/logs.command-options.js.map +1 -0
  30. package/dist/lib/cjs/commands/logs.command.js +102 -0
  31. package/dist/lib/cjs/commands/logs.command.js.map +1 -0
  32. package/dist/lib/cjs/commands/requests-alias.command.js +49 -0
  33. package/dist/lib/cjs/commands/requests-alias.command.js.map +1 -0
  34. package/dist/lib/cjs/commands/requests.command-options.js +26 -0
  35. package/dist/lib/cjs/commands/requests.command-options.js.map +1 -0
  36. package/dist/lib/cjs/commands/requests.command.js +88 -0
  37. package/dist/lib/cjs/commands/requests.command.js.map +1 -0
  38. package/dist/lib/cjs/commands/trace-alias.command.js +49 -0
  39. package/dist/lib/cjs/commands/trace-alias.command.js.map +1 -0
  40. package/dist/lib/cjs/commands/trace.command-options.js +59 -0
  41. package/dist/lib/cjs/commands/trace.command-options.js.map +1 -0
  42. package/dist/lib/cjs/commands/trace.command.js +84 -0
  43. package/dist/lib/cjs/commands/trace.command.js.map +1 -0
  44. package/dist/lib/cjs/config/config-loader.js +34 -13
  45. package/dist/lib/cjs/config/config-loader.js.map +1 -1
  46. package/dist/lib/cjs/decorators/command-parameter.decorator.js +40 -0
  47. package/dist/lib/cjs/decorators/command-parameter.decorator.js.map +1 -0
  48. package/dist/lib/cjs/decorators/decorators.js +18 -0
  49. package/dist/lib/cjs/decorators/decorators.js.map +1 -0
  50. package/dist/lib/cjs/enums/cli-decorator-metadata-keyname.enum.js +14 -0
  51. package/dist/lib/cjs/enums/cli-decorator-metadata-keyname.enum.js.map +1 -0
  52. package/dist/lib/cjs/enums/enums.js +19 -0
  53. package/dist/lib/cjs/enums/enums.js.map +1 -0
  54. package/dist/lib/cjs/enums/exit-code.enum.js +9 -0
  55. package/dist/lib/cjs/enums/exit-code.enum.js.map +1 -0
  56. package/dist/lib/cjs/enums/terminal-key-name.enum.js +21 -0
  57. package/dist/lib/cjs/enums/terminal-key-name.enum.js.map +1 -0
  58. package/dist/lib/cjs/errors/cli-error-code.enum.js +11 -1
  59. package/dist/lib/cjs/errors/cli-error-code.enum.js.map +1 -1
  60. package/dist/lib/cjs/errors/errors.js +1 -0
  61. package/dist/lib/cjs/errors/errors.js.map +1 -1
  62. package/dist/lib/cjs/errors/prompt-cancelled.error.js +25 -0
  63. package/dist/lib/cjs/errors/prompt-cancelled.error.js.map +1 -0
  64. package/dist/lib/cjs/event-handlers/cli.event-handler.js +21 -65
  65. package/dist/lib/cjs/event-handlers/cli.event-handler.js.map +1 -1
  66. package/dist/lib/cjs/event-handlers/event-handlers.js +1 -0
  67. package/dist/lib/cjs/event-handlers/event-handlers.js.map +1 -1
  68. package/dist/lib/cjs/event-handlers/repl-start.event-handler.js +280 -0
  69. package/dist/lib/cjs/event-handlers/repl-start.event-handler.js.map +1 -0
  70. package/dist/lib/cjs/event-payloads/event-payloads.js +1 -0
  71. package/dist/lib/cjs/event-payloads/event-payloads.js.map +1 -1
  72. package/dist/lib/cjs/event-payloads/start-repl.event-payload.js +19 -0
  73. package/dist/lib/cjs/event-payloads/start-repl.event-payload.js.map +1 -0
  74. package/dist/lib/cjs/interfaces/interfaces.js +1 -0
  75. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
  76. package/dist/lib/cjs/interfaces/terminal-key.interface.js +3 -0
  77. package/dist/lib/cjs/interfaces/terminal-key.interface.js.map +1 -0
  78. package/dist/lib/cjs/managers/cli-prompt.manager.js +181 -15
  79. package/dist/lib/cjs/managers/cli-prompt.manager.js.map +1 -1
  80. package/dist/lib/cjs/managers/console.manager.js +277 -0
  81. package/dist/lib/cjs/managers/console.manager.js.map +1 -0
  82. package/dist/lib/cjs/managers/managers.js +1 -0
  83. package/dist/lib/cjs/managers/managers.js.map +1 -1
  84. package/dist/lib/cjs/managers/repl-session.js +251 -0
  85. package/dist/lib/cjs/managers/repl-session.js.map +1 -0
  86. package/dist/lib/cjs/managers/terminal-key-reader.manager.js +99 -0
  87. package/dist/lib/cjs/managers/terminal-key-reader.manager.js.map +1 -0
  88. package/dist/lib/cjs/mappers/command-event.mapper.js +48 -8
  89. package/dist/lib/cjs/mappers/command-event.mapper.js.map +1 -1
  90. package/dist/lib/cjs/mappers/mappers.js +1 -0
  91. package/dist/lib/cjs/mappers/mappers.js.map +1 -1
  92. package/dist/lib/cjs/mappers/repl-start-event.mapper.js +80 -0
  93. package/dist/lib/cjs/mappers/repl-start-event.mapper.js.map +1 -0
  94. package/dist/lib/cjs/options/command-parameter.options.js +3 -0
  95. package/dist/lib/cjs/options/command-parameter.options.js.map +1 -0
  96. package/dist/lib/cjs/options/options.js +1 -0
  97. package/dist/lib/cjs/options/options.js.map +1 -1
  98. package/dist/lib/cjs/services/command-argument-resolver.js +62 -0
  99. package/dist/lib/cjs/services/command-argument-resolver.js.map +1 -0
  100. package/dist/lib/cjs/services/command-options-resolver.js +114 -0
  101. package/dist/lib/cjs/services/command-options-resolver.js.map +1 -0
  102. package/dist/lib/cjs/services/command-parameter-prompter.js +311 -0
  103. package/dist/lib/cjs/services/command-parameter-prompter.js.map +1 -0
  104. package/dist/lib/cjs/services/services.js +20 -0
  105. package/dist/lib/cjs/services/services.js.map +1 -0
  106. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  107. package/dist/lib/cjs/types/start-repl-event-response.type.js +13 -0
  108. package/dist/lib/cjs/types/start-repl-event-response.type.js.map +1 -0
  109. package/dist/lib/cjs/types/types.js +1 -0
  110. package/dist/lib/cjs/types/types.js.map +1 -1
  111. package/dist/lib/cjs/utils/boolean-answer-parser.js +25 -0
  112. package/dist/lib/cjs/utils/boolean-answer-parser.js.map +1 -0
  113. package/dist/lib/cjs/utils/pristine-argv.js +87 -0
  114. package/dist/lib/cjs/utils/pristine-argv.js.map +1 -0
  115. package/dist/lib/cjs/utils/terminal-key-decoder.js +71 -0
  116. package/dist/lib/cjs/utils/terminal-key-decoder.js.map +1 -0
  117. package/dist/lib/esm/bootstrap/app-module-cache.js +65 -0
  118. package/dist/lib/esm/bootstrap/app-module-cache.js.map +1 -0
  119. package/dist/lib/esm/bootstrap/app-module-discoverer.js +113 -0
  120. package/dist/lib/esm/bootstrap/app-module-discoverer.js.map +1 -0
  121. package/dist/lib/esm/bootstrap/app-module-discovery-candidate.js +17 -0
  122. package/dist/lib/esm/bootstrap/app-module-discovery-candidate.js.map +1 -0
  123. package/dist/lib/esm/bootstrap/app-module-discovery-reason.enum.js +12 -0
  124. package/dist/lib/esm/bootstrap/app-module-discovery-reason.enum.js.map +1 -0
  125. package/dist/lib/esm/bootstrap/app-module-prompt.js +75 -0
  126. package/dist/lib/esm/bootstrap/app-module-prompt.js.map +1 -0
  127. package/dist/lib/esm/bootstrap/build-staleness-prompt.js +12 -13
  128. package/dist/lib/esm/bootstrap/build-staleness-prompt.js.map +1 -1
  129. package/dist/lib/esm/bootstrap/init-prompt.js +16 -47
  130. package/dist/lib/esm/bootstrap/init-prompt.js.map +1 -1
  131. package/dist/lib/esm/cli.configuration-keys.js +21 -0
  132. package/dist/lib/esm/cli.configuration-keys.js.map +1 -0
  133. package/dist/lib/esm/cli.js +23 -10
  134. package/dist/lib/esm/cli.js.map +1 -1
  135. package/dist/lib/esm/cli.module.js +29 -1
  136. package/dist/lib/esm/cli.module.js.map +1 -1
  137. package/dist/lib/esm/commands/commands.js +6 -0
  138. package/dist/lib/esm/commands/commands.js.map +1 -1
  139. package/dist/lib/esm/commands/config-init.command.js +127 -0
  140. package/dist/lib/esm/commands/config-init.command.js.map +1 -0
  141. package/dist/lib/esm/commands/logs-alias.command.js +46 -0
  142. package/dist/lib/esm/commands/logs-alias.command.js.map +1 -0
  143. package/dist/lib/esm/commands/logs.command-options.js +68 -0
  144. package/dist/lib/esm/commands/logs.command-options.js.map +1 -0
  145. package/dist/lib/esm/commands/logs.command.js +99 -0
  146. package/dist/lib/esm/commands/logs.command.js.map +1 -0
  147. package/dist/lib/esm/commands/requests-alias.command.js +46 -0
  148. package/dist/lib/esm/commands/requests-alias.command.js.map +1 -0
  149. package/dist/lib/esm/commands/requests.command-options.js +22 -0
  150. package/dist/lib/esm/commands/requests.command-options.js.map +1 -0
  151. package/dist/lib/esm/commands/requests.command.js +85 -0
  152. package/dist/lib/esm/commands/requests.command.js.map +1 -0
  153. package/dist/lib/esm/commands/trace-alias.command.js +46 -0
  154. package/dist/lib/esm/commands/trace-alias.command.js.map +1 -0
  155. package/dist/lib/esm/commands/trace.command-options.js +55 -0
  156. package/dist/lib/esm/commands/trace.command-options.js.map +1 -0
  157. package/dist/lib/esm/commands/trace.command.js +81 -0
  158. package/dist/lib/esm/commands/trace.command.js.map +1 -0
  159. package/dist/lib/esm/config/config-loader.js +34 -13
  160. package/dist/lib/esm/config/config-loader.js.map +1 -1
  161. package/dist/lib/esm/decorators/command-parameter.decorator.js +36 -0
  162. package/dist/lib/esm/decorators/command-parameter.decorator.js.map +1 -0
  163. package/dist/lib/esm/decorators/decorators.js +2 -0
  164. package/dist/lib/esm/decorators/decorators.js.map +1 -0
  165. package/dist/lib/esm/enums/cli-decorator-metadata-keyname.enum.js +11 -0
  166. package/dist/lib/esm/enums/cli-decorator-metadata-keyname.enum.js.map +1 -0
  167. package/dist/lib/esm/enums/enums.js +3 -0
  168. package/dist/lib/esm/enums/enums.js.map +1 -0
  169. package/dist/lib/esm/enums/exit-code.enum.js +6 -0
  170. package/dist/lib/esm/enums/exit-code.enum.js.map +1 -0
  171. package/dist/lib/esm/enums/terminal-key-name.enum.js +18 -0
  172. package/dist/lib/esm/enums/terminal-key-name.enum.js.map +1 -0
  173. package/dist/lib/esm/errors/cli-error-code.enum.js +11 -1
  174. package/dist/lib/esm/errors/cli-error-code.enum.js.map +1 -1
  175. package/dist/lib/esm/errors/errors.js +1 -0
  176. package/dist/lib/esm/errors/errors.js.map +1 -1
  177. package/dist/lib/esm/errors/prompt-cancelled.error.js +21 -0
  178. package/dist/lib/esm/errors/prompt-cancelled.error.js.map +1 -0
  179. package/dist/lib/esm/event-handlers/cli.event-handler.js +22 -66
  180. package/dist/lib/esm/event-handlers/cli.event-handler.js.map +1 -1
  181. package/dist/lib/esm/event-handlers/event-handlers.js +1 -0
  182. package/dist/lib/esm/event-handlers/event-handlers.js.map +1 -1
  183. package/dist/lib/esm/event-handlers/repl-start.event-handler.js +244 -0
  184. package/dist/lib/esm/event-handlers/repl-start.event-handler.js.map +1 -0
  185. package/dist/lib/esm/event-payloads/event-payloads.js +1 -0
  186. package/dist/lib/esm/event-payloads/event-payloads.js.map +1 -1
  187. package/dist/lib/esm/event-payloads/start-repl.event-payload.js +15 -0
  188. package/dist/lib/esm/event-payloads/start-repl.event-payload.js.map +1 -0
  189. package/dist/lib/esm/interfaces/interfaces.js +1 -0
  190. package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
  191. package/dist/lib/esm/interfaces/terminal-key.interface.js +2 -0
  192. package/dist/lib/esm/interfaces/terminal-key.interface.js.map +1 -0
  193. package/dist/lib/esm/managers/cli-prompt.manager.js +182 -16
  194. package/dist/lib/esm/managers/cli-prompt.manager.js.map +1 -1
  195. package/dist/lib/esm/managers/console.manager.js +241 -0
  196. package/dist/lib/esm/managers/console.manager.js.map +1 -0
  197. package/dist/lib/esm/managers/managers.js +1 -0
  198. package/dist/lib/esm/managers/managers.js.map +1 -1
  199. package/dist/lib/esm/managers/repl-session.js +215 -0
  200. package/dist/lib/esm/managers/repl-session.js.map +1 -0
  201. package/dist/lib/esm/managers/terminal-key-reader.manager.js +96 -0
  202. package/dist/lib/esm/managers/terminal-key-reader.manager.js.map +1 -0
  203. package/dist/lib/esm/mappers/command-event.mapper.js +49 -9
  204. package/dist/lib/esm/mappers/command-event.mapper.js.map +1 -1
  205. package/dist/lib/esm/mappers/mappers.js +1 -0
  206. package/dist/lib/esm/mappers/mappers.js.map +1 -1
  207. package/dist/lib/esm/mappers/repl-start-event.mapper.js +77 -0
  208. package/dist/lib/esm/mappers/repl-start-event.mapper.js.map +1 -0
  209. package/dist/lib/esm/options/command-parameter.options.js +2 -0
  210. package/dist/lib/esm/options/command-parameter.options.js.map +1 -0
  211. package/dist/lib/esm/options/options.js +1 -0
  212. package/dist/lib/esm/options/options.js.map +1 -1
  213. package/dist/lib/esm/services/command-argument-resolver.js +59 -0
  214. package/dist/lib/esm/services/command-argument-resolver.js.map +1 -0
  215. package/dist/lib/esm/services/command-options-resolver.js +111 -0
  216. package/dist/lib/esm/services/command-options-resolver.js.map +1 -0
  217. package/dist/lib/esm/services/command-parameter-prompter.js +308 -0
  218. package/dist/lib/esm/services/command-parameter-prompter.js.map +1 -0
  219. package/dist/lib/esm/services/services.js +4 -0
  220. package/dist/lib/esm/services/services.js.map +1 -0
  221. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
  222. package/dist/lib/esm/types/start-repl-event-response.type.js +9 -0
  223. package/dist/lib/esm/types/start-repl-event-response.type.js.map +1 -0
  224. package/dist/lib/esm/types/types.js +1 -0
  225. package/dist/lib/esm/types/types.js.map +1 -1
  226. package/dist/lib/esm/utils/boolean-answer-parser.js +21 -0
  227. package/dist/lib/esm/utils/boolean-answer-parser.js.map +1 -0
  228. package/dist/lib/esm/utils/pristine-argv.js +50 -0
  229. package/dist/lib/esm/utils/pristine-argv.js.map +1 -0
  230. package/dist/lib/esm/utils/terminal-key-decoder.js +67 -0
  231. package/dist/lib/esm/utils/terminal-key-decoder.js.map +1 -0
  232. package/dist/types/bootstrap/app-module-cache.d.ts +15 -0
  233. package/dist/types/bootstrap/app-module-discoverer.d.ts +30 -0
  234. package/dist/types/bootstrap/app-module-discovery-candidate.d.ts +18 -0
  235. package/dist/types/bootstrap/app-module-discovery-reason.enum.d.ts +10 -0
  236. package/dist/types/bootstrap/app-module-prompt.d.ts +20 -0
  237. package/dist/types/bootstrap/build-staleness-prompt.d.ts +3 -3
  238. package/dist/types/bootstrap/init-prompt.d.ts +5 -5
  239. package/dist/types/cli.configuration-keys.d.ts +32 -0
  240. package/dist/types/cli.d.ts +8 -4
  241. package/dist/types/cli.module.d.ts +4 -0
  242. package/dist/types/commands/commands.d.ts +6 -0
  243. package/dist/types/commands/config-init.command.d.ts +18 -0
  244. package/dist/types/commands/logs-alias.command.d.ts +14 -0
  245. package/dist/types/commands/logs.command-options.d.ts +38 -0
  246. package/dist/types/commands/logs.command.d.ts +31 -0
  247. package/dist/types/commands/requests-alias.command.d.ts +14 -0
  248. package/dist/types/commands/requests.command-options.d.ts +8 -0
  249. package/dist/types/commands/requests.command.d.ts +25 -0
  250. package/dist/types/commands/trace-alias.command.d.ts +14 -0
  251. package/dist/types/commands/trace.command-options.d.ts +31 -0
  252. package/dist/types/commands/trace.command.d.ts +21 -0
  253. package/dist/types/config/config-loader.d.ts +15 -3
  254. package/dist/types/decorators/command-parameter.decorator.d.ts +30 -0
  255. package/dist/types/decorators/decorators.d.ts +1 -0
  256. package/dist/types/enums/cli-decorator-metadata-keyname.enum.d.ts +9 -0
  257. package/dist/types/enums/enums.d.ts +2 -0
  258. package/dist/types/enums/exit-code.enum.d.ts +4 -0
  259. package/dist/types/enums/terminal-key-name.enum.d.ts +16 -0
  260. package/dist/types/errors/cli-error-code.enum.d.ts +12 -2
  261. package/dist/types/errors/errors.d.ts +1 -0
  262. package/dist/types/errors/prompt-cancelled.error.d.ts +13 -0
  263. package/dist/types/event-handlers/cli.event-handler.d.ts +16 -13
  264. package/dist/types/event-handlers/event-handlers.d.ts +1 -0
  265. package/dist/types/event-handlers/repl-start.event-handler.d.ts +70 -0
  266. package/dist/types/event-payloads/event-payloads.d.ts +1 -0
  267. package/dist/types/event-payloads/start-repl.event-payload.d.ts +13 -0
  268. package/dist/types/interfaces/interfaces.d.ts +1 -0
  269. package/dist/types/interfaces/terminal-key.interface.d.ts +11 -0
  270. package/dist/types/managers/cli-prompt.manager.d.ts +63 -6
  271. package/dist/types/managers/console.manager.d.ts +93 -0
  272. package/dist/types/managers/managers.d.ts +1 -0
  273. package/dist/types/managers/repl-session.d.ts +62 -0
  274. package/dist/types/managers/terminal-key-reader.manager.d.ts +31 -0
  275. package/dist/types/mappers/command-event.mapper.d.ts +10 -1
  276. package/dist/types/mappers/mappers.d.ts +1 -0
  277. package/dist/types/mappers/repl-start-event.mapper.d.ts +28 -0
  278. package/dist/types/options/command-parameter.options.d.ts +29 -0
  279. package/dist/types/options/options.d.ts +1 -0
  280. package/dist/types/services/command-argument-resolver.d.ts +24 -0
  281. package/dist/types/services/command-options-resolver.d.ts +35 -0
  282. package/dist/types/services/command-parameter-prompter.d.ts +113 -0
  283. package/dist/types/services/services.d.ts +3 -0
  284. package/dist/types/types/start-repl-event-response.type.d.ts +10 -0
  285. package/dist/types/types/types.d.ts +1 -0
  286. package/dist/types/utils/boolean-answer-parser.d.ts +11 -0
  287. package/dist/types/utils/pristine-argv.d.ts +33 -0
  288. package/dist/types/utils/terminal-key-decoder.d.ts +28 -0
  289. package/package.json +16 -12
@@ -0,0 +1,21 @@
1
+ import { ExitCode } from "@pristine-ts/common";
2
+ import { TraceStore } from "@pristine-ts/observability";
3
+ import { CommandInterface } from "../interfaces/command.interface";
4
+ import { CliOutput } from "../managers/cli-output.manager";
5
+ import { TraceCommandOptions } from "./trace.command-options";
6
+ /**
7
+ * Renders the span tree of one captured trace. Look it up by any of event/trace/request
8
+ * id — `pristine trace <id>` tries all three, or use the explicit `--event-id`,
9
+ * `--trace-id`, `--request-id` flags.
10
+ *
11
+ * `--format tree|flat|json` controls the rendering (defaults to `tree`).
12
+ */
13
+ export declare class TraceCommand implements CommandInterface<TraceCommandOptions> {
14
+ private readonly cliOutput;
15
+ private readonly traceStore;
16
+ optionsType: typeof TraceCommandOptions;
17
+ name: string;
18
+ description: string;
19
+ constructor(cliOutput: CliOutput, traceStore: TraceStore);
20
+ run(args: TraceCommandOptions): Promise<ExitCode | number>;
21
+ }
@@ -3,7 +3,8 @@ import { DynamicImporter } from "../bootstrap/dynamic-importer";
3
3
  /**
4
4
  * Loads `pristine.config.ts` (preferred) or `pristine.config.js` (escape hatch for
5
5
  * pure-JS projects). Walks up from `process.cwd()` looking for the file, then loads it
6
- * through `jiti` (for `.ts`) or Node's dynamic `import()` (for `.js`).
6
+ * through Node's native dynamic `import()`: TypeScript type-stripping (Node >= 22.18)
7
+ * handles `.ts`, while `.js` loads directly.
7
8
  *
8
9
  * Returns a `ResolvedPristineConfig` carrying the file path (when found) and per-field
9
10
  * provenance, which `pristine p:config:print` uses to render an annotated dump.
@@ -31,10 +32,21 @@ export declare class ConfigLoader {
31
32
  */
32
33
  private findConfigFile;
33
34
  /**
34
- * Loads a config file from `absolutePath`. `.ts` goes through `jiti`; `.js` uses Node's
35
- * native dynamic `import()`. Extracts the default export, falling back to a named
35
+ * Loads a config file from `absolutePath` via Node's native dynamic `import()`. A `.ts`
36
+ * config is handled by Node's built-in TypeScript type-stripping (Node >= 22.18); a `.js`
37
+ * config loads directly. Extracts the default export, falling back to a named
36
38
  * `pristineConfig` export for users who prefer not to use `export default`.
37
39
  * @private
38
40
  */
39
41
  private importConfigFile;
42
+ /**
43
+ * Translates Node's low-level module-loading failures for a `.ts` config into an
44
+ * actionable error. Native type-stripping has two distinct failure modes worth telling
45
+ * apart: the running Node is too old (or has stripping disabled) to import `.ts` at all
46
+ * (`ERR_UNKNOWN_FILE_EXTENSION`), versus a config written with non-erasable TypeScript that
47
+ * stripping refuses (`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`). Any other error is passed through
48
+ * unchanged so genuine config bugs surface as-is.
49
+ * @private
50
+ */
51
+ private describeImportError;
40
52
  }
@@ -0,0 +1,30 @@
1
+ import { CommandParameterOptions } from "../options/command-parameter.options";
2
+ /**
3
+ * Describes a command-line parameter on a command's options class. Stored as property
4
+ * metadata and read by the CLI while resolving a command's arguments — before the arguments
5
+ * are mapped onto the options instance and validated.
6
+ *
7
+ * Two behaviors flow from the options:
8
+ *
9
+ * - `flag` rebinds the property to a differently-named flag (the property name is the
10
+ * default), so the property and the flag no longer have to be spelled identically.
11
+ * - `question` makes the CLI ask for the value interactively when the flag is absent
12
+ * (subject to configuration and an interactive terminal). Omit it to never prompt.
13
+ *
14
+ * ```ts
15
+ * import {IsString, IsOptional} from "@pristine-ts/class-validator";
16
+ * import {commandParameter} from "@pristine-ts/cli";
17
+ *
18
+ * export class MigrateCommandOptions {
19
+ * @commandParameter({flag: "db-url", question: "What is the database URL?"})
20
+ * @IsString()
21
+ * databaseUrl?: string; // bound to --db-url; asked for when missing
22
+ *
23
+ * @commandParameter({flag: "dir"}) // bound to --dir; never asked for
24
+ * @IsOptional()
25
+ * @IsString()
26
+ * migrationsDirectory?: string;
27
+ * }
28
+ * ```
29
+ */
30
+ export declare const commandParameter: (options?: CommandParameterOptions) => (target: any, propertyKey: string) => void;
@@ -0,0 +1 @@
1
+ export * from "./command-parameter.decorator";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Metadata keynames written by `@pristine-ts/cli`'s own property/class decorators and read
3
+ * back when resolving a command's options. Namespaced under `cli:` so they never collide
4
+ * with the keys other Pristine decorators (validation, data-mapping, mysql, …) store on the
5
+ * same class.
6
+ */
7
+ export declare enum CliDecoratorMetadataKeynameEnum {
8
+ CommandParameter = "cli:command-parameter"
9
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./cli-decorator-metadata-keyname.enum";
2
+ export * from "./terminal-key-name.enum";
@@ -0,0 +1,4 @@
1
+ export declare enum ExitCodeEnum {
2
+ Success = 0,
3
+ Error = 1
4
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The kinds of keypress the CLI's interactive prompts understand. `TerminalKeyDecoder`
3
+ * maps the raw bytes Node delivers from a raw-mode stdin onto one of these; every printable
4
+ * keystroke collapses to `Character` (with the literal character carried separately on
5
+ * {@link TerminalKey}). `Other` covers control/escape sequences the prompts don't act on
6
+ * (function keys, unhandled arrows) so callers can ignore them instead of echoing garbage.
7
+ */
8
+ export declare enum TerminalKeyName {
9
+ Up = "up",
10
+ Down = "down",
11
+ Enter = "enter",
12
+ Backspace = "backspace",
13
+ CtrlC = "ctrl-c",
14
+ Character = "character",
15
+ Other = "other"
16
+ }
@@ -3,10 +3,20 @@
3
3
  * (typed `PristineErrorCode | string`, so any enum value is accepted).
4
4
  *
5
5
  * Codes here describe CLI-specific failures — command resolution, argument mapping,
6
- * and argument validation.
6
+ * argument validation, and command-parameter binding.
7
7
  */
8
8
  export declare enum CliErrorCode {
9
9
  CommandNotFound = "COMMAND_NOT_FOUND",
10
10
  ArgumentMappingFailed = "ARGUMENT_MAPPING_FAILED",
11
- ArgumentValidationFailed = "ARGUMENT_VALIDATION_FAILED"
11
+ ArgumentValidationFailed = "ARGUMENT_VALIDATION_FAILED",
12
+ /**
13
+ * Two `@commandParameter` properties on the same options class resolve to the same flag.
14
+ * A programming error in the command's options definition, not bad user input.
15
+ */
16
+ CommandParameterFlagConflict = "COMMAND_PARAMETER_FLAG_CONFLICT",
17
+ /**
18
+ * The user cancelled an interactive prompt with `Ctrl+C`. Carried by
19
+ * `PromptCancelledError` — a clean, user-initiated cancellation, not a failure.
20
+ */
21
+ PromptCancelled = "PROMPT_CANCELLED"
12
22
  }
@@ -1,2 +1,3 @@
1
1
  export * from "./cli-error-code.enum";
2
2
  export * from "./command-not-found.error";
3
+ export * from "./prompt-cancelled.error";
@@ -0,0 +1,13 @@
1
+ import { PristineError } from "@pristine-ts/common";
2
+ /**
3
+ * Thrown when the user cancels an interactive prompt with `Ctrl+C`. A clean, user-initiated
4
+ * cancellation — not a crash — so it carries `kind: UserError` (the `CliErrorReporter`
5
+ * renders the message verbatim instead of a stack dump) and exit code `130`, following the
6
+ * POSIX `128 + SIGINT(2)` convention so shell pipelines can detect the interrupt.
7
+ *
8
+ * Callers that treat cancellation as a normal branch (e.g. `BuildStalenessPrompt`) catch it
9
+ * via `instanceof`; everywhere else it propagates to the reporter for a tidy exit.
10
+ */
11
+ export declare class PromptCancelledError extends PristineError {
12
+ constructor();
13
+ }
@@ -3,24 +3,27 @@ import { CommandEvent } from "../types/command-event.type";
3
3
  import { CommandEventResponse } from "../types/command-event-response.type";
4
4
  import { CommandInterface } from "../interfaces/command.interface";
5
5
  import { LogHandlerInterface } from "@pristine-ts/logging";
6
- import { Validator } from "@pristine-ts/class-validator";
6
+ import { CommandArgumentResolver } from "../services/command-argument-resolver";
7
7
  export declare class CliEventHandler implements EventHandlerInterface<any, any> {
8
8
  private readonly logHandler;
9
- private readonly validator;
9
+ private readonly commandArgumentResolver;
10
10
  private readonly commands;
11
- constructor(logHandler: LogHandlerInterface, validator: Validator, commands: CommandInterface<any>[]);
12
- handle(event: CommandEvent): Promise<CommandEventResponse>;
11
+ constructor(logHandler: LogHandlerInterface, commandArgumentResolver: CommandArgumentResolver, commands: CommandInterface<any>[]);
13
12
  /**
14
- * Maps `rawArgs` (the parsed argv shape produced by `CommandEventMapper`) into a typed
15
- * instance of `command.optionsType`, then runs `class-validator` against the instance.
16
- *
17
- * For commands that opt out of typed options (`optionsType === null`), passes the raw
18
- * args through unchanged — the legacy escape hatch for commands that want to handle
19
- * argv parsing themselves.
13
+ * Resolves and runs the command, then **returns** its exit code wrapped in a
14
+ * `CommandEventResponse` it does not call `process.exit`.
20
15
  *
21
- * Throws `UsageError` for mapping failures and `ValidationError` for class-validator
22
- * failures. Both carry structured `details` so `CliErrorReporter` can render them as
23
- * readable stderr lines without this method touching the console directly.
16
+ * Process lifecycle is the bin's job: `kernel.handle` resolves with this exit code,
17
+ * `Cli.bootstrap` returns it, and `bin.ts` does the actual `process.exit`. Returning
18
+ * (rather than exiting) is also what lets the interactive REPL dispatch commands
19
+ * through this very handler — `kernel.handle(argv, {keyname: Cli})` per typed line —
20
+ * without the process dying after the first command.
21
+ */
22
+ handle(event: CommandEvent): Promise<CommandEventResponse>;
23
+ /**
24
+ * Maps + validates a command's raw arguments. Delegates to the shared
25
+ * `CommandArgumentResolver`. Since the REPL dispatches through this same handler, the
26
+ * one-shot CLI and the REPL resolve arguments through identical logic.
24
27
  */
25
28
  resolveArgs(command: CommandInterface<any>, rawArgs: any): Promise<any>;
26
29
  supports(event: Event<any>): boolean;
@@ -1 +1,2 @@
1
1
  export * from "./cli.event-handler";
2
+ export * from "./repl-start.event-handler";
@@ -0,0 +1,70 @@
1
+ import { DependencyContainer } from "tsyringe";
2
+ import { Event, EventHandlerInterface, Kernel } from "@pristine-ts/core";
3
+ import { ExitCode } from "@pristine-ts/common";
4
+ import { TraceStore } from "@pristine-ts/observability";
5
+ import { CliOutput } from "../managers/cli-output.manager";
6
+ import { StartReplEventPayload } from "../event-payloads/start-repl.event-payload";
7
+ import { StartReplEventResponse } from "../types/start-repl-event-response.type";
8
+ /**
9
+ * The interactive `pristine` console, modelled as a long-running event handler. Launched
10
+ * when the bin is invoked with no command (or `pristine repl`) — `ReplStartEventMapper`
11
+ * produces a `StartReplEventPayload` and this handler runs the readline loop for the rest
12
+ * of the process lifetime.
13
+ *
14
+ * **Why an event handler.** The REPL is the same shape as `pristine start` (or any
15
+ * long-running command): an EventHandler whose `handle()` doesn't return until the
16
+ * session ends. This gives the CLI bootstrap a uniform shape — `cli.ts` just calls
17
+ * `kernel.handle(argv, {keyname: Cli})` regardless of whether the user invoked a one-shot
18
+ * command or wants the interactive console. There is no driver/handler asymmetry left in
19
+ * the bootstrap; the mapping layer routes argv to the right payload.
20
+ *
21
+ * **Per-line dispatch.** Each typed line is re-entered through `kernel.handle(...,
22
+ * {keyname: Cli})` — using `Kernel` (the proper re-entry seam — it owns trace lifecycle,
23
+ * child container creation, the works). The `Kernel` is `registerInstance`-d into its
24
+ * own container by `Cli.bootstrap()`, so this handler injects it via DI like any other
25
+ * service.
26
+ *
27
+ * Plus the session verbs `/help`, `/clear`, `/exit` handled in-process (they're not
28
+ * commands — they don't re-enter the kernel). Tab-completion is driven by the live
29
+ * command registry and by recent trace ids for `/trace` / `/logs`.
30
+ */
31
+ export declare class ReplStartEventHandler implements EventHandlerInterface<StartReplEventPayload, ExitCode | number> {
32
+ private readonly kernel;
33
+ private readonly container;
34
+ private readonly cliOutput;
35
+ private readonly traceStore;
36
+ private static readonly PROMPT;
37
+ private static readonly SESSION_VERBS;
38
+ private static readonly TRACE_ID_COMPLETION_LIMIT;
39
+ private commands;
40
+ constructor(kernel: Kernel, container: DependencyContainer, cliOutput: CliOutput, traceStore: TraceStore);
41
+ supports<T>(event: Event<T>): boolean;
42
+ /**
43
+ * Runs the read-eval-print loop until `/exit` or EOF (Ctrl-D). Resolves with the exit
44
+ * code wrapped in a `StartReplEventResponse`; the mapper surfaces that to `Cli.bootstrap`.
45
+ */
46
+ handle(event: Event<StartReplEventPayload>): Promise<StartReplEventResponse>;
47
+ /**
48
+ * Handles one input line. Returns true when the session should end.
49
+ */
50
+ private handleLine;
51
+ /**
52
+ * Readline completer. Completes `/`-prefixed command names and session verbs; for
53
+ * `/trace` and `/logs` it completes the trailing token with recent trace ids.
54
+ */
55
+ private complete;
56
+ private printBanner;
57
+ private printHelp;
58
+ private shutdown;
59
+ /**
60
+ * Enumerates every registered command. Resolved from the per-event child container the
61
+ * kernel handed this handler when it dispatched the REPL-start event — same container
62
+ * `HelpCommand`/`ListCommand` themselves use, so commands that depend on
63
+ * `CurrentChildContainer` resolve cleanly.
64
+ *
65
+ * `resolveAll`, justified: framework REPL infrastructure at session start — enumerating
66
+ * every `Command`-tagged service is a container-introspection operation with no
67
+ * constructor seam.
68
+ */
69
+ private resolveCommands;
70
+ }
@@ -1 +1,2 @@
1
1
  export * from "./command.event-payload";
2
+ export * from "./start-repl.event-payload";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Payload that signals "launch the interactive REPL." Produced by `ReplStartEventMapper`
3
+ * for argv shapes with no command (`pristine`) or with the explicit `repl` command
4
+ * (`pristine repl`). Consumed by `ReplStartEventHandler` which runs the readline loop
5
+ * for the rest of the process lifetime.
6
+ *
7
+ * The payload carries the `scriptPath` (argv[1]) for parity with `CommandEventPayload`
8
+ * and for diagnostics; the REPL itself reads its input from stdin, not from the payload.
9
+ */
10
+ export declare class StartReplEventPayload {
11
+ scriptPath: string;
12
+ constructor(scriptPath: string);
13
+ }
@@ -1 +1,2 @@
1
1
  export * from "./command.interface";
2
+ export * from "./terminal-key.interface";
@@ -0,0 +1,11 @@
1
+ import { TerminalKeyName } from "../enums/terminal-key-name.enum";
2
+ /**
3
+ * A single decoded keypress from an interactive terminal. `name` classifies the key;
4
+ * `sequence` is the raw character(s) it produced — meaningful for `Character` keys (the
5
+ * literal typed character, echoed/accumulated by callers) and retained for the rest for
6
+ * diagnostics.
7
+ */
8
+ export interface TerminalKey {
9
+ name: TerminalKeyName;
10
+ sequence: string;
11
+ }
@@ -1,9 +1,24 @@
1
1
  import { ConsoleReadlineOptions } from "../options/console-readline.options";
2
+ import { TerminalKeyReader } from "./terminal-key-reader.manager";
2
3
  /**
3
- * Interactive stdin reader for CLI commands. Wraps Node's `readline/promises` and offers
4
- * a single `readLine` method with optional masking after input is received.
4
+ * Interactive terminal prompts for CLI commands, implemented entirely on Node's `readline`
5
+ * and raw-mode stdin no third-party prompt library. Line-based prompts (`readLine`,
6
+ * `input`, `confirm`) go through `readline/promises`; the keystroke-level prompts (`select`
7
+ * arrow menu, masked `readSecret`) go through {@link TerminalKeyReader}.
8
+ *
9
+ * `Ctrl+C` rejects with {@link PromptCancelledError} across all of them — the line prompts
10
+ * via a `readline` SIGINT handler, the raw-mode prompts via the key reader — so callers get
11
+ * one consistent cancellation signal.
5
12
  */
6
13
  export declare class CliPrompt {
14
+ private readonly terminalKeyReader;
15
+ private static readonly CYAN;
16
+ private static readonly DIM;
17
+ private static readonly RESET;
18
+ private static readonly HIDE_CURSOR;
19
+ private static readonly SHOW_CURSOR;
20
+ private static readonly POINTER;
21
+ constructor(terminalKeyReader: TerminalKeyReader);
7
22
  /**
8
23
  * Reads a string from stdin synchronously. Returns whatever `process.stdin.read()`
9
24
  * gives back (which may be `null` when no data is buffered).
@@ -12,11 +27,53 @@ export declare class CliPrompt {
12
27
  /**
13
28
  * Reads a line from stdin after displaying a prompt. When
14
29
  * `options.showCharactersOnTyping` is false, the answered line is cleared and replaced
15
- * with a masked echo so the typed value isn't left visible on screen.
30
+ * with a masked echo so the typed value isn't left visible on screen (a post-input clear,
31
+ * not true keystroke suppression — use {@link readSecret} for real masking).
16
32
  *
17
- * Note: this is not a true keystroke-suppressing password input — Node's stock
18
- * `readline` does not support that without raw-mode handling. The current behavior is
19
- * a post-input clear, sufficient for most CLI prompts.
33
+ * `Ctrl+C` rejects with {@link PromptCancelledError}: registering a `SIGINT` listener on
34
+ * the readline interface overrides Node's default interrupt handling, turning it into a
35
+ * clean rejection rather than a hung promise.
20
36
  */
21
37
  readLine(question: string, options?: ConsoleReadlineOptions): Promise<string>;
38
+ /**
39
+ * Asks a free-text question, optionally with a default. The default is shown as a hint and
40
+ * returned verbatim when the user submits an empty line. The answer is trimmed.
41
+ */
42
+ input(message: string, defaultValue?: string): Promise<string>;
43
+ /**
44
+ * Asks a yes/no question. An empty answer takes the default; anything `BooleanAnswerParser`
45
+ * understands (`y`/`yes`/`true`/`1`, `n`/`no`/`false`/`0`) is accepted; anything else is
46
+ * re-asked. The default is shown capitalized in the `(Y/n)` / `(y/N)` hint.
47
+ */
48
+ confirm(message: string, defaultValue?: boolean): Promise<boolean>;
49
+ /**
50
+ * Presents an arrow-key menu and returns the chosen choice's `value`. `↑`/`↓` move the
51
+ * highlight (wrapping at the ends), `Enter` selects, `Ctrl+C` cancels. When `defaultValue`
52
+ * matches a choice, the menu starts on it. The cursor is hidden while the menu is active
53
+ * and restored afterward.
54
+ */
55
+ select<T>(message: string, choices: {
56
+ name: string;
57
+ value: T;
58
+ }[], defaultValue?: T): Promise<T>;
59
+ /**
60
+ * Reads a secret (password, token, …) from stdin with the typed characters masked as `*`.
61
+ * Real keystroke suppression via raw mode (unlike {@link readLine}'s post-input clear):
62
+ * each character echoes a `*`, `Backspace` erases one, `Enter` submits, `Ctrl+C` cancels.
63
+ * The value is returned untrimmed — a secret may legitimately contain surrounding
64
+ * whitespace.
65
+ */
66
+ readSecret(question: string): Promise<string>;
67
+ /**
68
+ * Writes the choice rows, highlighting the active one with a colored pointer. Each row is
69
+ * cleared before it's written so a repaint never leaves a longer previous label behind.
70
+ * @private
71
+ */
72
+ private renderChoices;
73
+ /**
74
+ * Moves the cursor back up over the previously-rendered choice rows and rewrites them, so
75
+ * the menu updates in place as the selection moves.
76
+ * @private
77
+ */
78
+ private repaintChoices;
22
79
  }
@@ -0,0 +1,93 @@
1
+ import { ConsoleReadlineOptions } from "../options/console-readline.options";
2
+ export declare class ConsoleManager {
3
+ private spinnerInterval;
4
+ private isSpinning;
5
+ /**
6
+ * Writes a message to stdout without a newline.
7
+ * @param message The message to write.
8
+ */
9
+ write(message: string): void;
10
+ /**
11
+ * Writes a message to stdout with a newline.
12
+ * @param message The message to write.
13
+ */
14
+ writeLine(message: string): void;
15
+ /**
16
+ * Writes a table to stdout.
17
+ * @param table The array of objects to display as a table.
18
+ */
19
+ writeTable(table: any[]): void;
20
+ /**
21
+ * Writes an error message in red with an 'Error:' prefix.
22
+ * @param message The error message to display.
23
+ */
24
+ writeError(message: string): void;
25
+ /**
26
+ * Writes a success message in green with a 'Success:' prefix.
27
+ * @param message The success message to display.
28
+ */
29
+ writeSuccess(message: string): void;
30
+ /**
31
+ * Writes a warning message in yellow with a 'Warning:' prefix.
32
+ * @param message The warning message to display.
33
+ */
34
+ writeWarning(message: string): void;
35
+ /**
36
+ * Writes an info message in cyan with an 'Info:' prefix.
37
+ * @param message The info message to display.
38
+ */
39
+ writeInfo(message: string): void;
40
+ /**
41
+ * Starts a loading spinner with a message.
42
+ *
43
+ * @param message The message to display next to the spinner.
44
+ * @remarks
45
+ * This method hides the cursor and continuously updates the current line.
46
+ * Avoid calling other write methods while the spinner is active as they may conflict with the spinner's line clearing.
47
+ */
48
+ startSpinner(message: string): void;
49
+ /**
50
+ * Stops the loading spinner and optionally prints a completion message.
51
+ *
52
+ * @param message Optional completion message to display.
53
+ * @param success Whether the operation was successful. Defaults to true.
54
+ * @remarks
55
+ * Stops the spinner, shows the cursor, and prints a final success or error message on the same line.
56
+ */
57
+ stopSpinner(message?: string, success?: boolean): void;
58
+ /**
59
+ * Displays or updates a progress bar.
60
+ *
61
+ * @param current The current progress value.
62
+ * @param total The total value to reach (100%).
63
+ * @param message Optional message to display next to the bar.
64
+ * @param width The visual width of the progress bar in characters. Defaults to 30.
65
+ *
66
+ * @remarks
67
+ * This method clears the *current* line and writes the progress bar.
68
+ *
69
+ * **Important:** If you call `writeLine()` (or any other method that outputs a newline) between calls to `updateProgressBar()`,
70
+ * the next call to `updateProgressBar()` will start on the *new* line, leaving the previous progress bar state on the line above.
71
+ *
72
+ * **Example of creating artifacts:**
73
+ * ```typescript
74
+ * manager.updateProgressBar(10, 100); // Draws bar at line N
75
+ * manager.writeLine("Log message"); // Moves cursor to line N+1
76
+ * manager.updateProgressBar(20, 100); // Draws bar at line N+1 (Line N has the old bar)
77
+ * ```
78
+ */
79
+ updateProgressBar(current: number, total: number, message?: string, width?: number): void;
80
+ /**
81
+ * Reads a string from stdin.
82
+ * @returns The raw string read from stdin.
83
+ */
84
+ read(): string;
85
+ /**
86
+ * Reads a line from stdin with a prompt.
87
+ *
88
+ * @param question The prompt text to display.
89
+ * @param options Configuration options for the input (e.g., masking characters).
90
+ * @returns A promise resolving to the user's input string.
91
+ */
92
+ readLine(question: string, options?: ConsoleReadlineOptions): Promise<string>;
93
+ }
@@ -2,4 +2,5 @@ export * from "./cli-output.manager";
2
2
  export * from "./cli-progress-bar.manager";
3
3
  export * from "./cli-prompt.manager";
4
4
  export * from "./cli-spinner.manager";
5
+ export * from "./terminal-key-reader.manager";
5
6
  export * from "./shell.manager";
@@ -0,0 +1,62 @@
1
+ import { Kernel } from "@pristine-ts/core";
2
+ import { ObservabilityStoreReader } from "@pristine-ts/observability";
3
+ import { CliOutput } from "./cli-output.manager";
4
+ /**
5
+ * The interactive `pristine` console — launched when the bin is invoked with no command
6
+ * (or `pristine repl`). It keeps the kernel booted for the whole session, so every
7
+ * command runs instantly with no per-invocation boot cost.
8
+ *
9
+ * Slash-prefixed commands dispatch through the *same* path as a one-shot
10
+ * `pristine <command>` invocation — `kernel.handle(argv, {keyname: Cli})` — so the REPL
11
+ * and the command line resolve, validate and run commands identically. (This works
12
+ * because `CliEventHandler` returns the exit code instead of calling `process.exit`.)
13
+ * Plus the session verbs `/help`, `/clear`, `/exit`. Tab-completion is driven by the live
14
+ * command registry and by recent trace ids for `/trace` / `/logs`.
15
+ *
16
+ * The kernel is **not** a constructor dependency — `ReplSession` is a driver *of* the
17
+ * kernel, so the running kernel is handed to `start()` by whoever owns it (`Cli`). Only
18
+ * genuine collaborator services are injected.
19
+ */
20
+ export declare class ReplSession {
21
+ private readonly cliOutput;
22
+ private readonly storeReader;
23
+ private static readonly PROMPT;
24
+ private static readonly SESSION_VERBS;
25
+ private static readonly TRACE_ID_COMPLETION_LIMIT;
26
+ private commands;
27
+ constructor(cliOutput: CliOutput, storeReader: ObservabilityStoreReader);
28
+ /**
29
+ * Runs the read-eval-print loop until `/exit` or EOF (Ctrl-D). Resolves with the exit
30
+ * code the bin should return.
31
+ *
32
+ * @param kernel The already-started kernel this session drives — passed in by the
33
+ * caller that owns it, rather than injected.
34
+ */
35
+ start(kernel: Kernel): Promise<number>;
36
+ /**
37
+ * Handles one input line. Returns true when the session should end.
38
+ */
39
+ private handleLine;
40
+ /**
41
+ * Readline completer. Completes `/`-prefixed command names and session verbs; for
42
+ * `/trace` and `/logs` it completes the trailing token with recent trace ids.
43
+ */
44
+ private complete;
45
+ private printBanner;
46
+ private printHelp;
47
+ private shutdown;
48
+ /**
49
+ * Enumerates every registered command.
50
+ *
51
+ * Resolved from a dedicated child container with the `CurrentChildContainer` token
52
+ * registered — some commands (`HelpCommand`, `ListCommand`) inject that token, which
53
+ * only the kernel's per-event child containers carry. The one-shot path gets it for
54
+ * free because `CliEventHandler` runs inside such a child container; the REPL builds an
55
+ * equivalent one once for the whole session.
56
+ *
57
+ * `resolveAll`, justified: this is framework REPL infrastructure resolved at session
58
+ * start, mirroring `Cli.warnOnCommandCollisions`. Enumerating every `Command`-tagged
59
+ * service is inherently a container-introspection operation with no constructor seam.
60
+ */
61
+ private resolveCommands;
62
+ }
@@ -0,0 +1,31 @@
1
+ import { TerminalKey } from "../interfaces/terminal-key.interface";
2
+ /**
3
+ * Owns the raw-mode keystroke reading the interactive prompts need (arrow-key `select`,
4
+ * masked `readSecret`) — the one place in the CLI that flips stdin into raw mode. Node's
5
+ * stock `readline` is line-buffered and echoes input, so it can't drive an arrow-key menu
6
+ * or suppress a password's characters; this reads keys one at a time instead.
7
+ *
8
+ * Two responsibilities are handled centrally so callers don't each reimplement them:
9
+ * - **Cancellation:** `Ctrl+C` rejects the read with {@link PromptCancelledError}.
10
+ * - **Terminal restore:** raw mode is entered on start and restored in every exit path,
11
+ * so a thrown handler or a cancellation never leaves the terminal in raw mode.
12
+ *
13
+ * The `input`/`output` fields default to the process streams and exist as a seam so tests
14
+ * can drive synthetic keystrokes without a real TTY.
15
+ */
16
+ export declare class TerminalKeyReader {
17
+ input: NodeJS.ReadStream;
18
+ output: NodeJS.WriteStream;
19
+ /**
20
+ * Whether both stdin and stdout are interactive terminals. Raw-mode reading is only
21
+ * meaningful on a real TTY; callers fall back (or skip prompting) when this is false.
22
+ */
23
+ isInteractive(): boolean;
24
+ /**
25
+ * Reads keystrokes in raw mode, handing each decoded {@link TerminalKey} to `onKey` until
26
+ * `onKey` ends the read by invoking its `resolve` callback with the result. Resolves to
27
+ * that value; rejects with {@link PromptCancelledError} on `Ctrl+C`. Raw mode is entered
28
+ * on start and restored to its prior state in every exit path.
29
+ */
30
+ read<T>(onKey: (key: TerminalKey, resolve: (value: T) => void) => void): Promise<T>;
31
+ }
@@ -1,6 +1,15 @@
1
- import { EventMapperInterface, EventResponse, EventsExecutionOptionsInterface, ExecutionContextInterface } from "@pristine-ts/core";
1
+ import { EventIdManager, EventMapperInterface, EventResponse, EventsExecutionOptionsInterface, ExecutionContextInterface } from "@pristine-ts/core";
2
2
  import { CommandEventPayload } from "../event-payloads/command.event-payload";
3
3
  export declare class CommandEventMapper implements EventMapperInterface<CommandEventPayload, number> {
4
+ private readonly eventIdManager;
5
+ constructor(eventIdManager: EventIdManager);
6
+ /**
7
+ * Matches argv that names an explicit command. The no-command shape and the bare
8
+ * `pristine repl` form are deliberately rejected here; `ReplStartEventMapper` claims
9
+ * those. Commands typed inside the interactive session are also re-dispatched under
10
+ * `Cli`, so this mapper handles them too. Argv parsing is delegated to `PristineArgv`,
11
+ * which scans for the bin token rather than relying on positional indexing.
12
+ */
4
13
  supportsMapping(rawEvent: any, executionContext: ExecutionContextInterface<any>): boolean;
5
14
  /**
6
15
  * Inspired from: https://github.com/eveningkid/args-parser
@@ -1 +1,2 @@
1
1
  export * from "./command-event.mapper";
2
+ export * from "./repl-start-event.mapper";