command-stream 0.8.3 → 0.9.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 (500) hide show
  1. package/js/examples/01-basic-streaming.mjs +14 -0
  2. package/js/examples/02-async-iterator.mjs +9 -0
  3. package/js/examples/03-file-and-console.mjs +16 -0
  4. package/js/examples/04-claude-jq-pipe.mjs +16 -0
  5. package/js/examples/CI-DEBUG-README.md +138 -0
  6. package/js/examples/README-examples.mjs +111 -0
  7. package/js/examples/README.md +345 -0
  8. package/js/examples/STREAMING_INTERFACES_SUMMARY.md +116 -0
  9. package/js/examples/add-test-timeouts.js +107 -0
  10. package/js/examples/ansi-default-preserved.mjs +11 -0
  11. package/js/examples/ansi-global-config.mjs +12 -0
  12. package/js/examples/ansi-reset-default.mjs +12 -0
  13. package/js/examples/ansi-strip-utils.mjs +12 -0
  14. package/js/examples/baseline-child-process.mjs +23 -0
  15. package/js/examples/baseline-claude-test.mjs +47 -0
  16. package/js/examples/baseline-working.mjs +34 -0
  17. package/js/examples/capture-mirror-comparison.mjs +23 -0
  18. package/js/examples/capture-mirror-default.mjs +11 -0
  19. package/js/examples/capture-mirror-performance.mjs +16 -0
  20. package/js/examples/capture-mirror-show-only.mjs +16 -0
  21. package/js/examples/capture-mirror-silent-processing.mjs +16 -0
  22. package/js/examples/ci-debug-baseline-vs-library.mjs +265 -0
  23. package/js/examples/ci-debug-es-module-loading.mjs +184 -0
  24. package/js/examples/ci-debug-signal-handling.mjs +225 -0
  25. package/js/examples/ci-debug-stdout-buffering.mjs +94 -0
  26. package/js/examples/ci-debug-test-timeouts.mjs +259 -0
  27. package/js/examples/claude-exact-file-output.mjs +20 -0
  28. package/js/examples/claude-exact-jq.mjs +13 -0
  29. package/js/examples/claude-exact-streaming.mjs +13 -0
  30. package/js/examples/claude-jq-pipeline.mjs +13 -0
  31. package/js/examples/claude-json-stream.mjs +39 -0
  32. package/js/examples/claude-streaming-basic.mjs +99 -0
  33. package/js/examples/claude-streaming-demo.mjs +126 -0
  34. package/js/examples/claude-streaming-final.mjs +20 -0
  35. package/js/examples/cleanup-verification-test.mjs +115 -0
  36. package/js/examples/colors-buffer-processing.mjs +14 -0
  37. package/js/examples/colors-default-preserved.mjs +15 -0
  38. package/js/examples/colors-per-command-config.mjs +15 -0
  39. package/js/examples/colors-strip-ansi.mjs +13 -0
  40. package/js/examples/commandstream-jq.mjs +29 -0
  41. package/js/examples/commandstream-working.mjs +23 -0
  42. package/js/examples/comprehensive-streams-demo.mjs +121 -0
  43. package/js/examples/ctrl-c-concurrent-processes.mjs +20 -0
  44. package/js/examples/ctrl-c-long-running-command.mjs +20 -0
  45. package/js/examples/ctrl-c-real-system-command.mjs +17 -0
  46. package/js/examples/ctrl-c-sleep-command.mjs +17 -0
  47. package/js/examples/ctrl-c-stdin-forwarding.mjs +20 -0
  48. package/js/examples/ctrl-c-virtual-command.mjs +17 -0
  49. package/js/examples/debug-already-started.mjs +20 -0
  50. package/js/examples/debug-ansi-processing.mjs +42 -0
  51. package/js/examples/debug-basic-streaming.mjs +44 -0
  52. package/js/examples/debug-buildshellcommand.mjs +82 -0
  53. package/js/examples/debug-child-process.mjs +43 -0
  54. package/js/examples/debug-child-state.mjs +55 -0
  55. package/js/examples/debug-chunking.mjs +38 -0
  56. package/js/examples/debug-command-parsing.mjs +61 -0
  57. package/js/examples/debug-complete-consolidation.mjs +97 -0
  58. package/js/examples/debug-echo-args.mjs +22 -0
  59. package/js/examples/debug-emit-timing.mjs +28 -0
  60. package/js/examples/debug-end-event.mjs +56 -0
  61. package/js/examples/debug-errexit.mjs +16 -0
  62. package/js/examples/debug-event-emission.mjs +40 -0
  63. package/js/examples/debug-event-timing.mjs +67 -0
  64. package/js/examples/debug-event-vs-result.mjs +30 -0
  65. package/js/examples/debug-exact-command.mjs +28 -0
  66. package/js/examples/debug-exact-test-scenario.mjs +44 -0
  67. package/js/examples/debug-execution-path.mjs +27 -0
  68. package/js/examples/debug-exit-command.mjs +38 -0
  69. package/js/examples/debug-exit-virtual.mjs +54 -0
  70. package/js/examples/debug-finish-consolidation.mjs +44 -0
  71. package/js/examples/debug-force-cleanup.mjs +47 -0
  72. package/js/examples/debug-getter-basic.mjs +13 -0
  73. package/js/examples/debug-getter-direct.mjs +23 -0
  74. package/js/examples/debug-getter-internals.mjs +61 -0
  75. package/js/examples/debug-handler-detection.mjs +65 -0
  76. package/js/examples/debug-idempotent-finish.mjs +54 -0
  77. package/js/examples/debug-idempotent-kill.mjs +58 -0
  78. package/js/examples/debug-interpolation-individual.mjs +88 -0
  79. package/js/examples/debug-interpolation-issue.mjs +101 -0
  80. package/js/examples/debug-jq-streaming.mjs +57 -0
  81. package/js/examples/debug-jq-tty-colors.mjs +168 -0
  82. package/js/examples/debug-kill-cleanup.mjs +56 -0
  83. package/js/examples/debug-kill-method.mjs +33 -0
  84. package/js/examples/debug-listener-interference.mjs +38 -0
  85. package/js/examples/debug-listener-lifecycle.mjs +50 -0
  86. package/js/examples/debug-listener-timing.mjs +62 -0
  87. package/js/examples/debug-listeners-property.mjs +34 -0
  88. package/js/examples/debug-map-methods.mjs +39 -0
  89. package/js/examples/debug-not-awaited-cleanup.mjs +106 -0
  90. package/js/examples/debug-off-method.mjs +28 -0
  91. package/js/examples/debug-option-merging.mjs +17 -0
  92. package/js/examples/debug-options.mjs +36 -0
  93. package/js/examples/debug-output.mjs +25 -0
  94. package/js/examples/debug-pattern-matching.mjs +69 -0
  95. package/js/examples/debug-pipeline-cat.mjs +28 -0
  96. package/js/examples/debug-pipeline-cleanup.mjs +71 -0
  97. package/js/examples/debug-pipeline-error-detailed.mjs +78 -0
  98. package/js/examples/debug-pipeline-error.mjs +65 -0
  99. package/js/examples/debug-pipeline-issue.mjs +26 -0
  100. package/js/examples/debug-pipeline-method.mjs +22 -0
  101. package/js/examples/debug-pipeline-stream.mjs +66 -0
  102. package/js/examples/debug-pipeline.mjs +14 -0
  103. package/js/examples/debug-process-exit-trace.mjs +41 -0
  104. package/js/examples/debug-process-path.mjs +38 -0
  105. package/js/examples/debug-property-check.mjs +29 -0
  106. package/js/examples/debug-resource-cleanup.mjs +83 -0
  107. package/js/examples/debug-shell-args.mjs +103 -0
  108. package/js/examples/debug-sigint-child-handler.mjs +44 -0
  109. package/js/examples/debug-sigint-forwarding.mjs +61 -0
  110. package/js/examples/debug-sigint-handler-install.mjs +79 -0
  111. package/js/examples/debug-sigint-handler-order.mjs +85 -0
  112. package/js/examples/debug-sigint-listeners.mjs +48 -0
  113. package/js/examples/debug-sigint-start-pattern.mjs +62 -0
  114. package/js/examples/debug-sigint-timer.mjs +40 -0
  115. package/js/examples/debug-simple-command.mjs +49 -0
  116. package/js/examples/debug-simple-getter.mjs +30 -0
  117. package/js/examples/debug-simple.mjs +39 -0
  118. package/js/examples/debug-simplified-finished.mjs +102 -0
  119. package/js/examples/debug-stack-overflow.mjs +25 -0
  120. package/js/examples/debug-stdin-simple.mjs +28 -0
  121. package/js/examples/debug-stdin.mjs +28 -0
  122. package/js/examples/debug-stream-emitter-isolated.mjs +45 -0
  123. package/js/examples/debug-stream-emitter.mjs +25 -0
  124. package/js/examples/debug-stream-events.mjs +70 -0
  125. package/js/examples/debug-stream-generator.mjs +23 -0
  126. package/js/examples/debug-stream-getter-issue.mjs +37 -0
  127. package/js/examples/debug-stream-getter.mjs +19 -0
  128. package/js/examples/debug-stream-internals.mjs +64 -0
  129. package/js/examples/debug-stream-method.mjs +46 -0
  130. package/js/examples/debug-stream-object.mjs +58 -0
  131. package/js/examples/debug-stream-properties.mjs +37 -0
  132. package/js/examples/debug-stream-timing.mjs +28 -0
  133. package/js/examples/debug-streaming.mjs +24 -0
  134. package/js/examples/debug-test-isolation.mjs +54 -0
  135. package/js/examples/debug-test-state.mjs +27 -0
  136. package/js/examples/debug-user-sigint.mjs +19 -0
  137. package/js/examples/debug-virtual-disable.mjs +21 -0
  138. package/js/examples/debug-virtual-vs-real.mjs +68 -0
  139. package/js/examples/debug-with-trace.mjs +23 -0
  140. package/js/examples/debug_parent_stream.mjs +22 -0
  141. package/js/examples/emulate-claude-stream.mjs +30 -0
  142. package/js/examples/emulated-streaming-direct.mjs +22 -0
  143. package/js/examples/emulated-streaming-jq-pipe.mjs +22 -0
  144. package/js/examples/emulated-streaming-sh-pipe.mjs +23 -0
  145. package/js/examples/events-build-process.mjs +73 -0
  146. package/js/examples/events-concurrent-streams.mjs +51 -0
  147. package/js/examples/events-error-handling.mjs +59 -0
  148. package/js/examples/events-file-monitoring.mjs +66 -0
  149. package/js/examples/events-interactive-simulation.mjs +69 -0
  150. package/js/examples/events-log-processing.mjs +72 -0
  151. package/js/examples/events-network-monitoring.mjs +68 -0
  152. package/js/examples/events-ping-basic.mjs +37 -0
  153. package/js/examples/events-progress-tracking.mjs +55 -0
  154. package/js/examples/events-stdin-input.mjs +34 -0
  155. package/js/examples/example-ansi-ls.mjs +39 -0
  156. package/js/examples/example-top.mjs +27 -0
  157. package/js/examples/final-ping-stdin-proof.mjs +88 -0
  158. package/js/examples/final-test-shell-operators.mjs +123 -0
  159. package/js/examples/final-working-examples.mjs +162 -0
  160. package/js/examples/gh-auth-test.mjs +103 -0
  161. package/js/examples/gh-delete-hang-test.mjs +79 -0
  162. package/js/examples/gh-gist-creation-test.mjs +276 -0
  163. package/js/examples/gh-gist-minimal-test.mjs +89 -0
  164. package/js/examples/gh-hang-exact-original.mjs +83 -0
  165. package/js/examples/gh-hang-reproduction.mjs +151 -0
  166. package/js/examples/gh-hang-test-with-redirect.mjs +45 -0
  167. package/js/examples/gh-hang-test-without-redirect.mjs +43 -0
  168. package/js/examples/gh-minimal-hang-check.mjs +33 -0
  169. package/js/examples/gh-operations-with-cd.mjs +187 -0
  170. package/js/examples/gh-output-test.mjs +102 -0
  171. package/js/examples/gh-reproduce-hang.mjs +41 -0
  172. package/js/examples/git-operations-with-cd.mjs +186 -0
  173. package/js/examples/interactive-math-calc.mjs +45 -0
  174. package/js/examples/interactive-top-fixed.mjs +25 -0
  175. package/js/examples/interactive-top-improved.mjs +72 -0
  176. package/js/examples/interactive-top-pty-logging.mjs +69 -0
  177. package/js/examples/interactive-top-pty.mjs +27 -0
  178. package/js/examples/interactive-top-with-logging.mjs +56 -0
  179. package/js/examples/interactive-top.mjs +29 -0
  180. package/js/examples/jq-color-demo.mjs +53 -0
  181. package/js/examples/jq-colors-streaming.mjs +42 -0
  182. package/js/examples/manual-ctrl-c-test.mjs +50 -0
  183. package/js/examples/methods-multiple-options.mjs +25 -0
  184. package/js/examples/methods-run-basic.mjs +10 -0
  185. package/js/examples/methods-start-basic.mjs +10 -0
  186. package/js/examples/node-compat-data-events.mjs +36 -0
  187. package/js/examples/node-compat-readable-event.mjs +29 -0
  188. package/js/examples/node-compat-small-buffer.mjs +33 -0
  189. package/js/examples/options-capture-false.mjs +12 -0
  190. package/js/examples/options-combined-settings.mjs +13 -0
  191. package/js/examples/options-custom-input.mjs +16 -0
  192. package/js/examples/options-default-behavior.mjs +10 -0
  193. package/js/examples/options-maximum-performance.mjs +15 -0
  194. package/js/examples/options-mirror-false.mjs +10 -0
  195. package/js/examples/options-performance-mode.mjs +13 -0
  196. package/js/examples/options-performance-optimization.mjs +14 -0
  197. package/js/examples/options-run-alias-demo.mjs +15 -0
  198. package/js/examples/options-run-alias.mjs +10 -0
  199. package/js/examples/options-silent-execution.mjs +14 -0
  200. package/js/examples/options-streaming-capture.mjs +24 -0
  201. package/js/examples/options-streaming-multiple.mjs +35 -0
  202. package/js/examples/options-streaming-silent.mjs +21 -0
  203. package/js/examples/options-streaming-stdin.mjs +21 -0
  204. package/js/examples/ping-streaming-filtered.mjs +22 -0
  205. package/js/examples/ping-streaming-interruptible.mjs +47 -0
  206. package/js/examples/ping-streaming-silent.mjs +24 -0
  207. package/js/examples/ping-streaming-simple.mjs +13 -0
  208. package/js/examples/ping-streaming-statistics.mjs +49 -0
  209. package/js/examples/ping-streaming-timestamps.mjs +22 -0
  210. package/js/examples/ping-streaming.mjs +48 -0
  211. package/js/examples/prove-ping-stdin-limitation.mjs +94 -0
  212. package/js/examples/readme-example.mjs +39 -0
  213. package/js/examples/realtime-json-stream.mjs +143 -0
  214. package/js/examples/reliable-stdin-commands.mjs +135 -0
  215. package/js/examples/reproduce-issue-135-v2.mjs +15 -0
  216. package/js/examples/reproduce-issue-135.mjs +17 -0
  217. package/js/examples/shell-cd-behavior.mjs +88 -0
  218. package/js/examples/sigint-forwarding-test.mjs +60 -0
  219. package/js/examples/sigint-handler-test.mjs +72 -0
  220. package/js/examples/simple-async-test.mjs +49 -0
  221. package/js/examples/simple-claude-test.mjs +17 -0
  222. package/js/examples/simple-event-test.mjs +33 -0
  223. package/js/examples/simple-jq-streaming.mjs +48 -0
  224. package/js/examples/simple-stream-demo.mjs +35 -0
  225. package/js/examples/simple-test-sleep.js +30 -0
  226. package/js/examples/simple-working-stdin.mjs +30 -0
  227. package/js/examples/streaming-behavior-test.mjs +116 -0
  228. package/js/examples/streaming-direct-command.mjs +21 -0
  229. package/js/examples/streaming-filtered-output.mjs +33 -0
  230. package/js/examples/streaming-grep-pipeline.mjs +21 -0
  231. package/js/examples/streaming-interactive-stdin.mjs +24 -0
  232. package/js/examples/streaming-jq-pipeline.mjs +23 -0
  233. package/js/examples/streaming-multistage-pipeline.mjs +23 -0
  234. package/js/examples/streaming-pipes-event-pattern.mjs +27 -0
  235. package/js/examples/streaming-pipes-multistage.mjs +22 -0
  236. package/js/examples/streaming-pipes-realtime-jq.mjs +23 -0
  237. package/js/examples/streaming-progress-tracking.mjs +34 -0
  238. package/js/examples/streaming-reusable-configs.mjs +52 -0
  239. package/js/examples/streaming-silent-capture.mjs +20 -0
  240. package/js/examples/streaming-test-simple.mjs +70 -0
  241. package/js/examples/streaming-virtual-pipeline.mjs +18 -0
  242. package/js/examples/syntax-basic-comparison.mjs +31 -0
  243. package/js/examples/syntax-basic-options.mjs +12 -0
  244. package/js/examples/syntax-combined-options.mjs +19 -0
  245. package/js/examples/syntax-command-chaining.mjs +12 -0
  246. package/js/examples/syntax-custom-directory.mjs +10 -0
  247. package/js/examples/syntax-custom-environment.mjs +13 -0
  248. package/js/examples/syntax-custom-stdin.mjs +10 -0
  249. package/js/examples/syntax-mixed-regular.mjs +11 -0
  250. package/js/examples/syntax-mixed-usage.mjs +15 -0
  251. package/js/examples/syntax-multiple-listeners.mjs +87 -0
  252. package/js/examples/syntax-piping-comparison.mjs +32 -0
  253. package/js/examples/syntax-reusable-config.mjs +16 -0
  254. package/js/examples/syntax-reusable-configs.mjs +21 -0
  255. package/js/examples/syntax-silent-operations.mjs +10 -0
  256. package/js/examples/syntax-stdin-option.mjs +12 -0
  257. package/js/examples/temp-sigint-test.mjs +21 -0
  258. package/js/examples/test-actual-buildshell.mjs +44 -0
  259. package/js/examples/test-async-streams-working.mjs +102 -0
  260. package/js/examples/test-async-streams.mjs +90 -0
  261. package/js/examples/test-auth-parse.mjs +74 -0
  262. package/js/examples/test-auto-quoting.mjs +57 -0
  263. package/js/examples/test-auto-start-fix.mjs +95 -0
  264. package/js/examples/test-baseline-sigint.mjs +38 -0
  265. package/js/examples/test-buffer-behavior.mjs +39 -0
  266. package/js/examples/test-buffers-simple.mjs +35 -0
  267. package/js/examples/test-bun-specific-issue.mjs +106 -0
  268. package/js/examples/test-bun-streaming.mjs +81 -0
  269. package/js/examples/test-cat-direct.mjs +41 -0
  270. package/js/examples/test-cat-pipe.mjs +34 -0
  271. package/js/examples/test-cd-behavior.mjs +42 -0
  272. package/js/examples/test-child-process-timing.mjs +53 -0
  273. package/js/examples/test-child-sigint-handler.mjs +62 -0
  274. package/js/examples/test-cleanup-simple.mjs +21 -0
  275. package/js/examples/test-comprehensive-tracing.mjs +58 -0
  276. package/js/examples/test-correct-space-handling.mjs +46 -0
  277. package/js/examples/test-ctrl-c-debug.mjs +44 -0
  278. package/js/examples/test-ctrl-c-inherit.mjs +30 -0
  279. package/js/examples/test-ctrl-c-sleep.mjs +31 -0
  280. package/js/examples/test-ctrl-c.mjs +17 -0
  281. package/js/examples/test-debug-new-options.mjs +55 -0
  282. package/js/examples/test-debug-pty.mjs +49 -0
  283. package/js/examples/test-debug-tee.mjs +38 -0
  284. package/js/examples/test-debug.mjs +25 -0
  285. package/js/examples/test-direct-jq.mjs +47 -0
  286. package/js/examples/test-direct-pipe-reading.mjs +119 -0
  287. package/js/examples/test-direct-pipe.sh +28 -0
  288. package/js/examples/test-double-quoting-prevention.mjs +138 -0
  289. package/js/examples/test-edge-cases-quoting.mjs +89 -0
  290. package/js/examples/test-events.mjs +37 -0
  291. package/js/examples/test-explicit-stdio.mjs +51 -0
  292. package/js/examples/test-final-streaming.mjs +71 -0
  293. package/js/examples/test-fix.mjs +71 -0
  294. package/js/examples/test-incremental-streaming.mjs +46 -0
  295. package/js/examples/test-individual-spawn.mjs +35 -0
  296. package/js/examples/test-inherit-stdout-not-stdin.mjs +133 -0
  297. package/js/examples/test-injection-protection.mjs +77 -0
  298. package/js/examples/test-interactive-streaming.mjs +140 -0
  299. package/js/examples/test-interactive-top.md +24 -0
  300. package/js/examples/test-interactive.mjs +17 -0
  301. package/js/examples/test-interpolation.mjs +14 -0
  302. package/js/examples/test-interrupt.mjs +40 -0
  303. package/js/examples/test-issue-135-comprehensive.mjs +41 -0
  304. package/js/examples/test-issue12-detailed.mjs +89 -0
  305. package/js/examples/test-issue12-exact.mjs +33 -0
  306. package/js/examples/test-jq-color.mjs +57 -0
  307. package/js/examples/test-jq-colors.mjs +41 -0
  308. package/js/examples/test-jq-compact.mjs +33 -0
  309. package/js/examples/test-jq-native.sh +10 -0
  310. package/js/examples/test-jq-pipeline-behavior.mjs +80 -0
  311. package/js/examples/test-jq-realtime.mjs +40 -0
  312. package/js/examples/test-manual-start.mjs +54 -0
  313. package/js/examples/test-mixed-quoting.mjs +88 -0
  314. package/js/examples/test-multi-stream.mjs +50 -0
  315. package/js/examples/test-multistage-debug.mjs +44 -0
  316. package/js/examples/test-native-spawn-vs-command-stream.mjs +154 -0
  317. package/js/examples/test-no-parse-pipeline.mjs +33 -0
  318. package/js/examples/test-non-virtual.mjs +52 -0
  319. package/js/examples/test-operators.mjs +53 -0
  320. package/js/examples/test-parent-continues.mjs +44 -0
  321. package/js/examples/test-path-interpolation.mjs +86 -0
  322. package/js/examples/test-ping-kill-and-stdin.mjs +98 -0
  323. package/js/examples/test-ping.mjs +12 -0
  324. package/js/examples/test-pty-spawn.mjs +101 -0
  325. package/js/examples/test-pty.mjs +38 -0
  326. package/js/examples/test-quote-behavior-summary.mjs +110 -0
  327. package/js/examples/test-quote-edge-cases.mjs +69 -0
  328. package/js/examples/test-quote-parsing.mjs +23 -0
  329. package/js/examples/test-raw-function.mjs +153 -0
  330. package/js/examples/test-raw-streaming.mjs +47 -0
  331. package/js/examples/test-readme-examples.mjs +142 -0
  332. package/js/examples/test-real-cat.mjs +28 -0
  333. package/js/examples/test-real-commands.mjs +21 -0
  334. package/js/examples/test-real-shell.mjs +31 -0
  335. package/js/examples/test-real-stdin-commands.mjs +160 -0
  336. package/js/examples/test-runner-batched.mjs +98 -0
  337. package/js/examples/test-runner-simple.mjs +80 -0
  338. package/js/examples/test-runner.mjs +67 -0
  339. package/js/examples/test-scope-parse.mjs +31 -0
  340. package/js/examples/test-sh-pipeline.mjs +24 -0
  341. package/js/examples/test-shell-detection.mjs +71 -0
  342. package/js/examples/test-shell-parser.mjs +37 -0
  343. package/js/examples/test-sigint-behavior.mjs +241 -0
  344. package/js/examples/test-sigint-handling.sh +14 -0
  345. package/js/examples/test-simple-pipe.mjs +12 -0
  346. package/js/examples/test-simple-streaming.mjs +32 -0
  347. package/js/examples/test-sleep-stdin.js +27 -0
  348. package/js/examples/test-sleep.mjs +56 -0
  349. package/js/examples/test-smart-quoting.mjs +180 -0
  350. package/js/examples/test-spaces-in-path.mjs +48 -0
  351. package/js/examples/test-special-chars-quoting.mjs +54 -0
  352. package/js/examples/test-stdin-after-start.mjs +39 -0
  353. package/js/examples/test-stdin-simple.mjs +67 -0
  354. package/js/examples/test-stdin-timing.mjs +74 -0
  355. package/js/examples/test-stdio-combinations.mjs +124 -0
  356. package/js/examples/test-stream-access.mjs +84 -0
  357. package/js/examples/test-stream-cleanup.mjs +27 -0
  358. package/js/examples/test-stream-readers.mjs +152 -0
  359. package/js/examples/test-streaming-final.mjs +57 -0
  360. package/js/examples/test-streaming-interfaces.mjs +141 -0
  361. package/js/examples/test-streaming-timing.mjs +27 -0
  362. package/js/examples/test-streaming.mjs +32 -0
  363. package/js/examples/test-streams-stdin-comprehensive.mjs +134 -0
  364. package/js/examples/test-streams-stdin-ctrl-c.mjs +96 -0
  365. package/js/examples/test-template-literal.mjs +26 -0
  366. package/js/examples/test-template-vs-interpolation.mjs +49 -0
  367. package/js/examples/test-timing.mjs +41 -0
  368. package/js/examples/test-top-inherit-stdout-stdin-control.mjs +123 -0
  369. package/js/examples/test-top-quit-stdin.mjs +118 -0
  370. package/js/examples/test-trace-option.mjs +21 -0
  371. package/js/examples/test-user-double-quotes.mjs +36 -0
  372. package/js/examples/test-user-single-quotes.mjs +36 -0
  373. package/js/examples/test-verbose.mjs +18 -0
  374. package/js/examples/test-verbose2.mjs +32 -0
  375. package/js/examples/test-virtual-streaming.mjs +125 -0
  376. package/js/examples/test-waiting-command.mjs +52 -0
  377. package/js/examples/test-waiting-commands.mjs +83 -0
  378. package/js/examples/test-watch-mode.mjs +104 -0
  379. package/js/examples/test-yes-cancellation.mjs +26 -0
  380. package/js/examples/test-yes-detailed.mjs +58 -0
  381. package/js/examples/test-yes-trace.mjs +28 -0
  382. package/js/examples/trace-abort-controller.mjs +30 -0
  383. package/js/examples/trace-error-handling.mjs +22 -0
  384. package/js/examples/trace-pipeline-command.mjs +22 -0
  385. package/js/examples/trace-signal-handling.mjs +35 -0
  386. package/js/examples/trace-simple-command.mjs +18 -0
  387. package/js/examples/trace-stderr-output.mjs +22 -0
  388. package/js/examples/verify-fix-both-runtimes.mjs +73 -0
  389. package/js/examples/verify-issue12-fixed.mjs +78 -0
  390. package/js/examples/which-command-common-commands.mjs +19 -0
  391. package/js/examples/which-command-gh-test.mjs +23 -0
  392. package/js/examples/which-command-nonexistent.mjs +20 -0
  393. package/js/examples/which-command-system-comparison.mjs +28 -0
  394. package/js/examples/working-example.mjs +13 -0
  395. package/js/examples/working-stdin-examples.mjs +138 -0
  396. package/js/examples/working-streaming-demo.mjs +49 -0
  397. package/js/tests/$.features.test.mjs +283 -0
  398. package/js/tests/$.test.mjs +935 -0
  399. package/js/tests/builtin-commands.test.mjs +387 -0
  400. package/js/tests/bun-shell-path-fix.test.mjs +115 -0
  401. package/js/tests/bun.features.test.mjs +189 -0
  402. package/js/tests/cd-virtual-command.test.mjs +622 -0
  403. package/js/tests/cleanup-verification.test.mjs +127 -0
  404. package/js/tests/ctrl-c-baseline.test.mjs +207 -0
  405. package/js/tests/ctrl-c-basic.test.mjs +220 -0
  406. package/js/tests/ctrl-c-library.test.mjs +197 -0
  407. package/js/tests/ctrl-c-signal.test.mjs +915 -0
  408. package/js/tests/examples.test.mjs +252 -0
  409. package/js/tests/execa.features.test.mjs +198 -0
  410. package/js/tests/gh-commands.test.mjs +164 -0
  411. package/js/tests/gh-gist-operations.test.mjs +221 -0
  412. package/js/tests/git-gh-cd.test.mjs +466 -0
  413. package/js/tests/interactive-option.test.mjs +114 -0
  414. package/js/tests/interactive-streaming.test.mjs +307 -0
  415. package/js/tests/issue-135-final.test.mjs +58 -0
  416. package/js/tests/jq-color-behavior.test.mjs +140 -0
  417. package/js/tests/jq.test.mjs +318 -0
  418. package/js/tests/options-examples.test.mjs +106 -0
  419. package/js/tests/options-syntax.test.mjs +112 -0
  420. package/js/tests/path-interpolation.test.mjs +412 -0
  421. package/js/tests/pipe.test.mjs +291 -0
  422. package/js/tests/raw-function.test.mjs +266 -0
  423. package/js/tests/readme-examples.test.mjs +427 -0
  424. package/js/tests/resource-cleanup-internals.test.mjs +669 -0
  425. package/js/tests/shell-settings.test.mjs +279 -0
  426. package/js/tests/sigint-cleanup-isolated.test.mjs +151 -0
  427. package/js/tests/sigint-cleanup.test.mjs +118 -0
  428. package/js/tests/start-run-edge-cases.test.mjs +152 -0
  429. package/js/tests/start-run-options.test.mjs +181 -0
  430. package/js/tests/stderr-output-handling.test.mjs +279 -0
  431. package/js/tests/streaming-interfaces.test.mjs +194 -0
  432. package/js/tests/sync.test.mjs +297 -0
  433. package/js/tests/system-pipe.test.mjs +226 -0
  434. package/js/tests/test-cleanup.mjs +200 -0
  435. package/js/tests/test-helper-fixed.mjs +148 -0
  436. package/js/tests/test-helper-v2.mjs +118 -0
  437. package/js/tests/test-helper.mjs +171 -0
  438. package/js/tests/test-sigint-child.js +15 -0
  439. package/js/tests/text-method.test.mjs +225 -0
  440. package/js/tests/virtual.test.mjs +364 -0
  441. package/js/tests/yes-command-cleanup.test.mjs +208 -0
  442. package/js/tests/zx.features.test.mjs +233 -0
  443. package/package.json +13 -12
  444. package/rust/Cargo.lock +947 -0
  445. package/rust/Cargo.toml +47 -0
  446. package/rust/src/commands/basename.rs +69 -0
  447. package/rust/src/commands/cat.rs +123 -0
  448. package/rust/src/commands/cd.rs +67 -0
  449. package/rust/src/commands/cp.rs +187 -0
  450. package/rust/src/commands/dirname.rs +57 -0
  451. package/rust/src/commands/echo.rs +73 -0
  452. package/rust/src/commands/env.rs +33 -0
  453. package/rust/src/commands/exit.rs +36 -0
  454. package/rust/src/commands/false.rs +24 -0
  455. package/rust/src/commands/ls.rs +182 -0
  456. package/rust/src/commands/mkdir.rs +98 -0
  457. package/rust/src/commands/mod.rs +200 -0
  458. package/rust/src/commands/mv.rs +180 -0
  459. package/rust/src/commands/pwd.rs +28 -0
  460. package/rust/src/commands/rm.rs +150 -0
  461. package/rust/src/commands/seq.rs +179 -0
  462. package/rust/src/commands/sleep.rs +97 -0
  463. package/rust/src/commands/test.rs +204 -0
  464. package/rust/src/commands/touch.rs +99 -0
  465. package/rust/src/commands/true.rs +24 -0
  466. package/rust/src/commands/which.rs +87 -0
  467. package/rust/src/commands/yes.rs +99 -0
  468. package/rust/src/lib.rs +492 -0
  469. package/rust/src/main.rs +37 -0
  470. package/rust/src/shell_parser.rs +565 -0
  471. package/rust/src/utils.rs +335 -0
  472. package/rust/tests/builtin_commands.rs +549 -0
  473. package/rust/tests/process_runner.rs +286 -0
  474. package/rust/tests/shell_parser.rs +296 -0
  475. package/rust/tests/utils.rs +282 -0
  476. package/rust/tests/virtual_commands.rs +199 -0
  477. /package/{src → js/src}/$.mjs +0 -0
  478. /package/{src → js/src}/$.utils.mjs +0 -0
  479. /package/{src → js/src}/commands/$.basename.mjs +0 -0
  480. /package/{src → js/src}/commands/$.cat.mjs +0 -0
  481. /package/{src → js/src}/commands/$.cd.mjs +0 -0
  482. /package/{src → js/src}/commands/$.cp.mjs +0 -0
  483. /package/{src → js/src}/commands/$.dirname.mjs +0 -0
  484. /package/{src → js/src}/commands/$.echo.mjs +0 -0
  485. /package/{src → js/src}/commands/$.env.mjs +0 -0
  486. /package/{src → js/src}/commands/$.exit.mjs +0 -0
  487. /package/{src → js/src}/commands/$.false.mjs +0 -0
  488. /package/{src → js/src}/commands/$.ls.mjs +0 -0
  489. /package/{src → js/src}/commands/$.mkdir.mjs +0 -0
  490. /package/{src → js/src}/commands/$.mv.mjs +0 -0
  491. /package/{src → js/src}/commands/$.pwd.mjs +0 -0
  492. /package/{src → js/src}/commands/$.rm.mjs +0 -0
  493. /package/{src → js/src}/commands/$.seq.mjs +0 -0
  494. /package/{src → js/src}/commands/$.sleep.mjs +0 -0
  495. /package/{src → js/src}/commands/$.test.mjs +0 -0
  496. /package/{src → js/src}/commands/$.touch.mjs +0 -0
  497. /package/{src → js/src}/commands/$.true.mjs +0 -0
  498. /package/{src → js/src}/commands/$.which.mjs +0 -0
  499. /package/{src → js/src}/commands/$.yes.mjs +0 -0
  500. /package/{src → js/src}/shell-parser.mjs +0 -0
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ // Basic streaming example - shows real-time chunk processing
3
+ import { $ } from '../src/$.mjs';
4
+
5
+ let chunkCount = 0;
6
+
7
+ $`claude "Count from 1 to 3 briefly"`
8
+ .on('data', (chunk) => {
9
+ console.log(`Chunk ${++chunkCount}: ${chunk.data.toString().trim()}`);
10
+ })
11
+ .on('end', (result) =>
12
+ console.log(`Done! ${chunkCount} chunks, exit: ${result.code}`)
13
+ )
14
+ .start();
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ // Async iterator pattern - process chunks as they arrive
3
+ import { $ } from '../src/$.mjs';
4
+
5
+ console.log('Using async iteration:');
6
+
7
+ for await (const chunk of $`claude "List 3 colors"`.stream()) {
8
+ console.log(`→ ${chunk.data.toString().trim()}`);
9
+ }
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ // Stream to both console and file simultaneously
3
+ import { $ } from '../src/$.mjs';
4
+ import { appendFileSync } from 'fs';
5
+
6
+ const logFile = 'stream-output.log';
7
+ let chunks = 0;
8
+
9
+ $`claude "Say hello 3 times"`
10
+ .on('data', (chunk) => {
11
+ const data = chunk.data.toString();
12
+ console.log(`Console: ${data.trim()}`);
13
+ appendFileSync(logFile, `Chunk ${++chunks}: ${data}`);
14
+ })
15
+ .on('end', () => console.log(`Saved ${chunks} chunks to ${logFile}`))
16
+ .start();
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ // Claude output piped to jq for JSON processing
3
+ import { $ } from '../src/$.mjs';
4
+
5
+ console.log('Claude → jq pipeline:');
6
+
7
+ // Ask Claude for JSON output and pipe to jq
8
+ $`claude "Output a simple JSON object with name and age fields" --output-format json`
9
+ .pipe($`jq -r '.name'`)
10
+ .on('data', (chunk) => {
11
+ console.log(`jq result: ${chunk.data.toString().trim()}`);
12
+ })
13
+ .on('end', (result) => {
14
+ console.log(`Pipeline complete, exit: ${result.code}`);
15
+ })
16
+ .start();
@@ -0,0 +1,138 @@
1
+ # CI Debugging Examples
2
+
3
+ This directory contains examples for debugging common issues that occur in CI environments when testing command execution libraries.
4
+
5
+ ## Common CI Issues and Solutions
6
+
7
+ ### 1. Stdout Buffering (`ci-debug-stdout-buffering.mjs`)
8
+
9
+ **Problem**: Output doesn't appear immediately in CI (non-TTY environments) due to stdout buffering.
10
+
11
+ **Solution**: Force stdout flush when not in TTY mode.
12
+
13
+ ```bash
14
+ node js/examples/ci-debug-stdout-buffering.mjs
15
+ ```
16
+
17
+ ### 2. ES Module Loading Failures (`ci-debug-es-module-loading.mjs`)
18
+
19
+ **Problem**: Child processes with ES module imports fail immediately with SIGINT in CI.
20
+
21
+ **Solution**: Use different module loading strategies or fallback to shell commands.
22
+
23
+ ```bash
24
+ node js/examples/ci-debug-es-module-loading.mjs
25
+ ```
26
+
27
+ ### 3. Signal Handling (`ci-debug-signal-handling.mjs`)
28
+
29
+ **Problem**: SIGINT/SIGTERM signals behave differently in CI, especially with process groups.
30
+
31
+ **Solution**: Proper signal forwarding and environment-aware cleanup strategies.
32
+
33
+ ```bash
34
+ node js/examples/ci-debug-signal-handling.mjs
35
+ ```
36
+
37
+ ### 4. Test Timeouts (`ci-debug-test-timeouts.mjs`)
38
+
39
+ **Problem**: Tests hang indefinitely without proper timeout configuration.
40
+
41
+ **Solution**: Add explicit timeouts to all tests and implement timeout strategies.
42
+
43
+ ```bash
44
+ node js/examples/ci-debug-test-timeouts.mjs
45
+ ```
46
+
47
+ ### 5. Baseline vs Library Testing (`ci-debug-baseline-vs-library.mjs`)
48
+
49
+ **Problem**: Need to determine if failures are due to the library or underlying Node.js behavior.
50
+
51
+ **Solution**: Test both raw spawn and library functionality for comparison.
52
+
53
+ ```bash
54
+ node js/examples/ci-debug-baseline-vs-library.mjs
55
+ ```
56
+
57
+ ## Quick Debugging Checklist
58
+
59
+ When tests fail in CI but pass locally:
60
+
61
+ 1. **Check stdout buffering**: Is output being buffered in non-TTY mode?
62
+ 2. **Check module loading**: Are ES modules failing to load in child processes?
63
+ 3. **Check signal handling**: Are signals being properly forwarded?
64
+ 4. **Check timeouts**: Do all tests have appropriate timeouts?
65
+ 5. **Check environment**: What's different between CI and local (TTY, env vars, etc.)?
66
+
67
+ ## Environment Detection
68
+
69
+ ```javascript
70
+ const isCI = process.env.CI === 'true';
71
+ const isGitHubActions = process.env.GITHUB_ACTIONS === 'true';
72
+ const isTTY = process.stdout.isTTY;
73
+ ```
74
+
75
+ ## Common Fixes
76
+
77
+ ### Force Stdout Flush
78
+
79
+ ```javascript
80
+ process.stdout.write('output\n');
81
+ if (!process.stdout.isTTY) {
82
+ process.stdout.write('', () => {}); // Force flush
83
+ }
84
+ ```
85
+
86
+ ### Add Test Timeouts (Bun)
87
+
88
+ ```javascript
89
+ test('my test', async () => {
90
+ // test code
91
+ }, 30000); // 30 second timeout
92
+ ```
93
+
94
+ ### Fallback to Shell Commands
95
+
96
+ ```javascript
97
+ // Instead of spawning Node with ES modules
98
+ spawn('sh', ['-c', 'echo "test"'], { stdio: 'inherit' });
99
+ ```
100
+
101
+ ### Proper Signal Cleanup
102
+
103
+ ```javascript
104
+ const cleanup = () => {
105
+ children.forEach((child) => child.kill('SIGTERM'));
106
+ };
107
+ process.on('SIGINT', cleanup);
108
+ process.on('SIGTERM', cleanup);
109
+ process.on('exit', cleanup);
110
+ ```
111
+
112
+ ## Running All CI Debug Examples
113
+
114
+ ```bash
115
+ # Run all CI debugging examples
116
+ for f in js/examples/ci-debug-*.mjs; do
117
+ echo "Running $f..."
118
+ node "$f"
119
+ echo ""
120
+ done
121
+ ```
122
+
123
+ ## Tips for CI Testing
124
+
125
+ 1. **Always add timeouts** to prevent infinite hangs
126
+ 2. **Use environment detection** to adjust behavior for CI
127
+ 3. **Test both baseline and library** to isolate issues
128
+ 4. **Add extensive logging** with timestamps in CI mode
129
+ 5. **Handle signals properly** with cleanup on exit
130
+ 6. **Force output flushing** in non-TTY environments
131
+ 7. **Use simple shell commands** as fallback when ES modules fail
132
+
133
+ ## Related Test Files
134
+
135
+ - `tests/ctrl-c-baseline.test.mjs` - Baseline spawn tests
136
+ - `tests/ctrl-c-library.test.mjs` - Library-specific tests
137
+ - `tests/ctrl-c-signal.test.mjs` - Signal handling tests
138
+ - `tests/cleanup-verification.test.mjs` - Resource cleanup tests
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Examples for README - using manual timing approach until async streams are perfected
5
+ */
6
+
7
+ import { $ } from '../src/$.mjs';
8
+
9
+ console.log('📖 README Examples - Streaming Interfaces');
10
+ console.log('='.repeat(50));
11
+
12
+ async function readmeExamples() {
13
+ try {
14
+ console.log('\\n✅ EXAMPLE 1: Basic stdin control with manual timing');
15
+ console.log('─'.repeat(30));
16
+
17
+ const catCmd = $`cat`;
18
+
19
+ // Start the process explicitly
20
+ catCmd.start({
21
+ mode: 'async',
22
+ stdin: 'pipe',
23
+ stdout: 'pipe',
24
+ stderr: 'pipe',
25
+ });
26
+
27
+ // Wait for process to spawn
28
+ await new Promise((resolve) => setTimeout(resolve, 100));
29
+
30
+ // Now access stdin directly
31
+ const stdin = catCmd.child ? catCmd.child.stdin : null;
32
+ console.log('stdin available:', !!stdin);
33
+
34
+ if (stdin) {
35
+ stdin.write('Hello from stdin!\\n');
36
+ stdin.write('Multiple lines work!\\n');
37
+ stdin.end();
38
+ }
39
+
40
+ const result = await catCmd;
41
+ console.log('Output:', JSON.stringify(result.stdout));
42
+
43
+ console.log('\\n✅ EXAMPLE 2: Kill method for network commands');
44
+ console.log('─'.repeat(30));
45
+
46
+ const pingCmd = $`ping 8.8.8.8`;
47
+
48
+ // Start monitoring output
49
+ pingCmd.streams.stdout; // Auto-start
50
+
51
+ // Kill after 1 second since ping ignores stdin
52
+ setTimeout(() => {
53
+ console.log('Killing ping...');
54
+ pingCmd.kill();
55
+ }, 1000);
56
+
57
+ const pingResult = await pingCmd;
58
+ console.log('Ping stopped with code:', pingResult.code);
59
+ console.log('Captured output length:', pingResult.stdout.length);
60
+
61
+ console.log('\\n✅ EXAMPLE 3: Using buffers and strings interfaces');
62
+ console.log('─'.repeat(30));
63
+
64
+ // Using buffers interface
65
+ const bufferCmd = $`echo "Binary data"`;
66
+ const buffer = await bufferCmd.buffers.stdout;
67
+ console.log('Buffer result:', buffer.toString());
68
+
69
+ // Using strings interface
70
+ const stringCmd = $`echo "Text data"`;
71
+ const text = await stringCmd.strings.stdout;
72
+ console.log('String result:', JSON.stringify(text.trim()));
73
+
74
+ console.log('\\n✅ EXAMPLE 4: Mixed stdout/stderr');
75
+ console.log('─'.repeat(30));
76
+
77
+ const mixedCmd = $`sh -c 'echo "stdout" && echo "stderr" >&2'`;
78
+ const [stdout, stderr] = await Promise.all([
79
+ mixedCmd.strings.stdout,
80
+ mixedCmd.strings.stderr,
81
+ ]);
82
+
83
+ console.log('Stdout:', JSON.stringify(stdout.trim()));
84
+ console.log('Stderr:', JSON.stringify(stderr.trim()));
85
+
86
+ console.log('\\n✅ EXAMPLE 5: Backward compatibility');
87
+ console.log('─'.repeat(30));
88
+
89
+ // Traditional await syntax still works
90
+ const compatCmd = await $`echo "backward compatible"`;
91
+ console.log('Compatible result:', JSON.stringify(compatCmd.stdout.trim()));
92
+
93
+ console.log(`\\n${'='.repeat(50)}`);
94
+ console.log('🎉 All README examples completed!');
95
+ console.log('\\n📋 Key Features:');
96
+ console.log(' ✅ command.streams.stdin/stdout/stderr - Node.js streams');
97
+ console.log(' ✅ command.buffers.stdin/stdout/stderr - Buffer objects');
98
+ console.log(' ✅ command.strings.stdin/stdout/stderr - String data');
99
+ console.log(
100
+ ' ✅ command.kill() - Process termination'
101
+ );
102
+ console.log(
103
+ ' ✅ Backward compatible with await - Original syntax works'
104
+ );
105
+ } catch (error) {
106
+ console.error('❌ Error:', error.message);
107
+ console.error(error.stack);
108
+ }
109
+ }
110
+
111
+ readmeExamples();
@@ -0,0 +1,345 @@
1
+ # Command Stream Examples
2
+
3
+ This directory contains 160+ examples demonstrating various features of the command-stream library. Each example focuses on a specific concept or use case.
4
+
5
+ ## Quick Start
6
+
7
+ The simplest examples to get started:
8
+
9
+ - `readme-example.mjs` - Basic usage from the main README
10
+ - `ping-streaming-simple.mjs` - Simple streaming example
11
+ - `syntax-basic-options.mjs` - Basic $({ options }) syntax
12
+
13
+ ## Categories
14
+
15
+ ### 🎛️ Options and Configuration
16
+
17
+ **$({ options }) Syntax:**
18
+
19
+ - `syntax-basic-options.mjs` - Basic options verification
20
+ - `syntax-custom-stdin.mjs` - Custom stdin using options
21
+ - `syntax-custom-environment.mjs` - Custom environment variables
22
+ - `syntax-custom-directory.mjs` - Custom working directory
23
+ - `syntax-combined-options.mjs` - Multiple options combined
24
+ - `syntax-reusable-configs.mjs` - Reusable configurations
25
+ - `syntax-mixed-usage.mjs` - Mix with regular $ usage
26
+ - `syntax-silent-operations.mjs` - Silent operations (no mirror)
27
+ - `syntax-stdin-option.mjs` - stdin option verification
28
+ - `syntax-command-chaining.mjs` - Command chaining verification
29
+ - `syntax-reusable-config.mjs` - Multiple uses of same config
30
+
31
+ **Capture/Mirror Options:**
32
+
33
+ - `capture-mirror-default.mjs` - Default behavior (both enabled)
34
+ - `capture-mirror-silent-processing.mjs` - capture: true, mirror: false
35
+ - `capture-mirror-show-only.mjs` - capture: false, mirror: true
36
+ - `capture-mirror-performance.mjs` - capture: false, mirror: false
37
+ - `capture-mirror-comparison.mjs` - Summary of all combinations
38
+ - `options-capture-false.mjs` - Using .start() with capture: false
39
+ - `options-mirror-false.mjs` - Using .start() with mirror: false
40
+ - `options-combined-settings.mjs` - Using both mirror and capture options
41
+ - `options-default-behavior.mjs` - Default behavior comparison
42
+ - `options-performance-mode.mjs` - Maximum performance mode
43
+
44
+ **Performance Optimization:**
45
+
46
+ - `options-performance-optimization.mjs` - Disable capture for speed
47
+ - `options-silent-execution.mjs` - Disable mirroring
48
+ - `options-maximum-performance.mjs` - No capture, no mirror
49
+ - `options-custom-input.mjs` - Custom input with options
50
+
51
+ **Method Usage:**
52
+
53
+ - `methods-start-basic.mjs` - Using .start() method
54
+ - `methods-run-basic.mjs` - Using .run() method (identical to .start())
55
+ - `methods-multiple-options.mjs` - Both methods support same options
56
+ - `options-run-alias.mjs` - Using .run() alias with options
57
+ - `options-run-alias-demo.mjs` - Using .run() alias demonstration
58
+
59
+ ### 📡 Streaming Examples
60
+
61
+ **Basic Streaming:**
62
+
63
+ - `streaming-direct-command.mjs` - Direct command streaming
64
+ - `streaming-silent-capture.mjs` - Long-running with silent capture
65
+ - `streaming-progress-tracking.mjs` - Progress tracking with streaming
66
+ - `streaming-filtered-output.mjs` - Stream processing with filtering
67
+ - `streaming-reusable-configs.mjs` - Reusable streaming configurations
68
+ - `streaming-interactive-stdin.mjs` - Interactive streaming with custom stdin
69
+
70
+ **Pipeline Streaming:**
71
+
72
+ - `streaming-jq-pipeline.mjs` - jq pipeline streaming (critical test)
73
+ - `streaming-multistage-pipeline.mjs` - Multi-stage pipeline (cat | jq)
74
+ - `streaming-grep-pipeline.mjs` - grep pipeline streaming
75
+ - `streaming-virtual-pipeline.mjs` - Virtual command with pipeline
76
+
77
+ **Advanced Streaming:**
78
+
79
+ - `streaming-pipes-realtime-jq.mjs` - Real-time streaming through jq
80
+ - `streaming-pipes-multistage.mjs` - Multi-stage pipeline streaming
81
+ - `streaming-pipes-event-pattern.mjs` - EventEmitter pattern with pipes
82
+ - `streaming-behavior-test.mjs` - Comprehensive streaming behavior analysis
83
+
84
+ **Options-Based Streaming:**
85
+
86
+ - `options-streaming-silent.mjs` - Silent streaming with $({ mirror: false })
87
+ - `options-streaming-stdin.mjs` - Custom stdin streaming
88
+ - `options-streaming-capture.mjs` - Capture enabled with streaming
89
+ - `options-streaming-multiple.mjs` - Multiple configured instances
90
+
91
+ ### 🏓 Ping Examples
92
+
93
+ **Basic Ping:**
94
+
95
+ - `ping-streaming-simple.mjs` - Minimal ping streaming example
96
+ - `ping-streaming.mjs` - Enhanced ping with timestamps and parsing
97
+ - `ping-streaming-timestamps.mjs` - Basic ping with timestamps
98
+ - `ping-streaming-filtered.mjs` - Filtering only ping replies
99
+ - `ping-streaming-statistics.mjs` - Counting responses with statistics
100
+ - `ping-streaming-silent.mjs` - Silent streaming with options
101
+ - `ping-streaming-interruptible.mjs` - CTRL+C handling with streams
102
+
103
+ ### 🎨 ANSI Color Handling
104
+
105
+ **Basic Color Examples:**
106
+
107
+ - `colors-default-preserved.mjs` - Default behavior (ANSI preserved)
108
+ - `colors-strip-ansi.mjs` - Using AnsiUtils.stripAnsi()
109
+ - `colors-buffer-processing.mjs` - Using AnsiUtils.cleanForProcessing()
110
+ - `colors-per-command-config.mjs` - Per-command ANSI configuration
111
+ - `ansi-default-preserved.mjs` - Default ANSI preservation
112
+ - `ansi-strip-utils.mjs` - Using AnsiUtils to strip ANSI
113
+ - `ansi-global-config.mjs` - Global configuration to disable ANSI
114
+ - `ansi-reset-default.mjs` - Reset to default (preserve ANSI)
115
+
116
+ **Interactive Examples:**
117
+
118
+ - `interactive-top.mjs` - Interactive `top` command with full ANSI support
119
+ - `interactive-top-fixed.mjs` - Fixed version of interactive top
120
+ - `interactive-top-improved.mjs` - Improved interactive top
121
+ - `interactive-top-pty.mjs` - Interactive top with PTY
122
+ - `interactive-top-pty-logging.mjs` - PTY with logging
123
+ - `interactive-top-with-logging.mjs` - Interactive top with logging
124
+ - `example-top.mjs` - Simple `top` command example
125
+ - `example-ansi-ls.mjs` - ls command ANSI color handling
126
+
127
+ **jq Color Examples:**
128
+
129
+ - `jq-colors-streaming.mjs` - jq streaming with ANSI colors
130
+ - `test-jq-colors.mjs` - Comprehensive jq color testing
131
+
132
+ ### ⚡ Event-Based Processing
133
+
134
+ **Basic Events:**
135
+
136
+ - `events-ping-basic.mjs` - Basic event-based ping
137
+ - `events-stdin-input.mjs` - Event-based with custom stdin
138
+ - `events-progress-tracking.mjs` - Long-running process with progress events
139
+ - `events-error-handling.mjs` - Error handling and recovery
140
+ - `events-concurrent-streams.mjs` - Multiple concurrent event streams
141
+
142
+ **Real-World Event Patterns:**
143
+
144
+ - `events-log-processing.mjs` - Real-time log processing
145
+ - `events-file-monitoring.mjs` - File monitoring simulation
146
+ - `events-build-process.mjs` - Build process simulation
147
+ - `events-interactive-simulation.mjs` - Interactive command simulation
148
+ - `events-network-monitoring.mjs` - Network monitoring with multiple hosts
149
+
150
+ ### 🚦 CTRL+C Signal Handling
151
+
152
+ **Basic Signal Handling:**
153
+
154
+ - `ctrl-c-long-running-command.mjs` - Long-running command interruption
155
+ - `ctrl-c-sleep-command.mjs` - Sleep command with signal handling
156
+ - `ctrl-c-stdin-forwarding.mjs` - Command with stdin forwarding
157
+ - `ctrl-c-real-system-command.mjs` - Real system command CTRL+C
158
+ - `ctrl-c-virtual-command.mjs` - Virtual command CTRL+C
159
+ - `ctrl-c-concurrent-processes.mjs` - Multiple concurrent processes
160
+
161
+ ### 🔧 Syntax Comparisons
162
+
163
+ **Feature Comparisons:**
164
+
165
+ - `syntax-basic-comparison.mjs` - Basic $ vs $({ options }) comparison
166
+ - `syntax-piping-comparison.mjs` - Command chaining comparison
167
+ - `syntax-multiple-listeners.mjs` - Multiple event listeners comparison
168
+
169
+ ### 🧪 Testing and Debugging
170
+
171
+ **Core Functionality Tests:**
172
+
173
+ - `test-stream-cleanup.mjs` - Stream cleanup behavior
174
+ - `test-cleanup-simple.mjs` - Simplified cleanup test
175
+ - `test-debug.mjs` - Debug version with internal state
176
+ - `test-events.mjs` - Event handling tests
177
+ - `test-raw-streaming.mjs` - Raw streaming (no jq) tests
178
+ - `test-bun-streaming.mjs` - Bun-specific streaming tests
179
+
180
+ **Pipeline Tests:**
181
+
182
+ - `test-simple-pipe.mjs` - Simple pipeline tests
183
+ - `test-sh-pipeline.mjs` - Shell pipeline tests
184
+ - `test-direct-pipe-reading.mjs` - Direct pipe reading tests
185
+ - `test-no-parse-pipeline.mjs` - No parse pipeline tests
186
+
187
+ **Virtual Command Tests:**
188
+
189
+ - `test-virtual-streaming.mjs` - Virtual command streaming tests
190
+ - `test-real-commands.mjs` - Real command tests
191
+ - `test-real-shell.mjs` - Real shell command tests
192
+
193
+ **Advanced Tests:**
194
+
195
+ - `test-incremental-streaming.mjs` - Incremental streaming tests
196
+ - `test-multi-stream.mjs` - Multiple stream tests
197
+ - `test-final-streaming.mjs` - Final streaming tests
198
+ - `test-streaming-final.mjs` - Streaming final tests
199
+ - `test-multistage-debug.mjs` - Multi-stage debug tests
200
+
201
+ **CTRL+C Tests:**
202
+
203
+ - `test-ctrl-c.mjs` - Basic CTRL+C tests
204
+ - `test-ctrl-c-debug.mjs` - CTRL+C debug tests
205
+ - `test-ctrl-c-inherit.mjs` - CTRL+C inheritance tests
206
+ - `test-ctrl-c-sleep.mjs` - CTRL+C sleep tests
207
+ - `test-interrupt.mjs` - Interrupt tests
208
+ - `test-parent-continues.mjs` - Parent continuation tests
209
+ - `manual-ctrl-c-test.mjs` - Manual CTRL+C test
210
+
211
+ **PTY and Interactive Tests:**
212
+
213
+ - `test-pty.mjs` - PTY tests
214
+ - `test-pty-spawn.mjs` - PTY spawn tests
215
+ - `test-debug-pty.mjs` - Debug PTY tests
216
+ - `test-interactive.mjs` - Interactive tests
217
+
218
+ **jq and JSON Tests:**
219
+
220
+ - `test-jq-compact.mjs` - jq compact tests
221
+ - `test-jq-realtime.mjs` - jq realtime tests
222
+ - `test-direct-jq.mjs` - Direct jq tests
223
+ - `simple-jq-streaming.mjs` - Simple jq streaming tests
224
+ - `realtime-json-stream.mjs` - Realtime JSON streaming
225
+
226
+ **Node.js Compatibility:**
227
+
228
+ - `node-compat-data-events.mjs` - Node.js spawn with data events
229
+ - `node-compat-readable-event.mjs` - Using readable event
230
+ - `node-compat-small-buffer.mjs` - Reading with small buffer size
231
+
232
+ **Debug and Analysis:**
233
+
234
+ - `debug-already-started.mjs` - Already started behavior
235
+ - `debug-ansi-processing.mjs` - ANSI processing debug
236
+ - `debug-event-vs-result.mjs` - Event vs result debug
237
+ - `debug-exact-command.mjs` - Exact command debug
238
+ - `debug-option-merging.mjs` - Option merging debug
239
+ - `debug-pipeline.mjs` - Pipeline debug
240
+ - `debug-pipeline-issue.mjs` - Pipeline issue debug
241
+ - `debug-pipeline-method.mjs` - Pipeline method debug
242
+ - `debug-simple.mjs` - Simple debug
243
+ - `debug-streaming.mjs` - Streaming debug
244
+ - `debug-virtual-vs-real.mjs` - Virtual vs real command debug
245
+
246
+ **Stream Analysis:**
247
+
248
+ - `test-stream-readers.mjs` - Stream readers tests
249
+ - `test-debug-tee.mjs` - Debug tee tests
250
+ - `test-debug-new-options.mjs` - Debug new options tests
251
+ - `test-individual-spawn.mjs` - Individual spawn tests
252
+ - `test-verbose.mjs` - Verbose tests
253
+ - `test-verbose2.mjs` - Verbose tests v2
254
+
255
+ **Emulation and Demos:**
256
+
257
+ - `emulate-claude-stream.mjs` - Claude streaming emulator
258
+ - `emulated-streaming-direct.mjs` - Direct emulator execution
259
+ - `emulated-streaming-jq-pipe.mjs` - Emulator piped through jq
260
+ - `emulated-streaming-sh-pipe.mjs` - Using sh -c with pipe
261
+ - `simple-stream-demo.mjs` - Simple streaming demo
262
+ - `working-streaming-demo.mjs` - Working streaming demonstration
263
+
264
+ **which Command Tests:**
265
+
266
+ - `which-command-gh-test.mjs` - Testing which gh (GitHub issue #7)
267
+ - `which-command-system-comparison.mjs` - Comparing with system which
268
+ - `which-command-common-commands.mjs` - Testing with common commands
269
+ - `which-command-nonexistent.mjs` - Testing non-existent commands
270
+
271
+ **Cat Command Tests:**
272
+
273
+ - `test-cat-direct.mjs` - Direct cat tests
274
+ - `test-cat-pipe.mjs` - Cat pipe tests
275
+
276
+ ## Key Features Demonstrated
277
+
278
+ ### 🎛️ Options and Configuration
279
+
280
+ - ✅ **$({ options }) syntax** - Clean API for passing options
281
+ - ✅ **Capture control** - Enable/disable output capture with `capture: true/false`
282
+ - ✅ **Mirror control** - Enable/disable terminal output with `mirror: true/false`
283
+ - ✅ **Custom stdin** - Pass custom input with `stdin` option
284
+ - ✅ **Environment variables** - Set custom environment with `env` option
285
+ - ✅ **Working directory** - Change directory with `cwd` option
286
+ - ✅ **Method aliases** - Use `.run()` as alias for `.start()`
287
+
288
+ ### 📡 Real-Time Streaming
289
+
290
+ - ✅ **Async iteration** - `for await (const chunk of command.stream())`
291
+ - ✅ **Event-based processing** - `.on('stdout')`, `.on('stderr')`, `.on('close')`
292
+ - ✅ **Pipeline streaming** - Real-time streaming through jq, grep, sed
293
+ - ✅ **Multi-stage pipelines** - Complex command chains with streaming
294
+ - ✅ **Progress tracking** - Real-time progress monitoring
295
+
296
+ ### 🎨 ANSI Color Handling
297
+
298
+ - ✅ **ANSI colors preserved by default** (addresses GitHub issue #10)
299
+ - ✅ **No interference with interactive I/O** (addresses GitHub issue #11)
300
+ - ✅ **Easy data processing** with `AnsiUtils` export functions
301
+ - ✅ **Configurable behavior** for different use cases
302
+ - ✅ **Stream compatibility** with existing tools
303
+
304
+ ### 🚦 Signal Handling
305
+
306
+ - ✅ **CTRL+C forwarding** - Proper SIGINT signal forwarding to child processes
307
+ - ✅ **Process cleanup** - Clean termination without hanging processes
308
+ - ✅ **Interactive commands** - Full stdin/stdout/stderr inheritance
309
+ - ✅ **Virtual command cancellation** - Proper cleanup of async generators
310
+
311
+ ### 🔧 Stream Management
312
+
313
+ - ✅ **Proper cleanup** - Breaking from `for await` loops properly terminates processes
314
+ - ✅ **No resource leaks** - Virtual commands are properly closed
315
+ - ✅ **Clean exit** - No hanging processes after iteration stops
316
+
317
+ ## Usage Examples
318
+
319
+ ```bash
320
+ # Run a basic example
321
+ bun js/examples/ping-streaming-simple.mjs
322
+
323
+ # Test ANSI color handling
324
+ node js/examples/colors-default-preserved.mjs
325
+
326
+ # Try CTRL+C signal handling
327
+ node js/examples/ctrl-c-long-running-command.mjs
328
+
329
+ # Test streaming with options
330
+ node js/examples/options-streaming-silent.mjs
331
+
332
+ # Event-based processing
333
+ node js/examples/events-log-processing.mjs
334
+ ```
335
+
336
+ ## File Naming Convention
337
+
338
+ Files are named using the pattern `{category}-{feature}-{variant}.mjs`:
339
+
340
+ - `ping-streaming-simple.mjs` - Simple ping streaming
341
+ - `options-capture-false.mjs` - Options with capture disabled
342
+ - `events-log-processing.mjs` - Event-based log processing
343
+ - `syntax-basic-options.mjs` - Basic syntax for options
344
+
345
+ This makes it easy to find related examples and understand what each file demonstrates at a glance.