cliprobe 1.6.1 → 1.7.1

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.
package/README.md CHANGED
@@ -31,13 +31,18 @@ npx cliprobe -- tsx
31
31
  ```
32
32
 
33
33
  ```
34
- cliprobe 1.4.3: closed-pipe, color, pipe-escapes, stdin, ctrl-c, sigterm, restore, control-chars checks for tsx
34
+ cliprobe 1.7.0: closed-pipe, write-error, color, pipe-escapes, stdin, ctrl-c, sigterm, restore, control-chars checks for tsx
35
35
 
36
36
  closed-pipe
37
37
  FAIL tsx --version crashed when stdout was closed (exit 0 -> 1)
38
38
  Error: write EPIPE (at node_modules/tsx/dist/cli.mjs:53:36962)
39
39
  PASS tsx --help exited quietly
40
40
 
41
+ write-error
42
+ WARN tsx --version crashed with a stack trace when a write to stdout failed (exit 1)
43
+ Error: ENOSPC: no space left on device, write (at node_modules/tsx/dist/cli.mjs:53:36962)
44
+ WARN tsx --help exited 0 though every write to stdout failed (no space left on device), so `> file` on a full disk looks like success
45
+
41
46
  color
42
47
  PASS tsx --version no color in a pipe or in a terminal
43
48
  FAIL tsx --help printed color codes into a pipe
@@ -64,10 +69,10 @@ restore
64
69
  control-chars
65
70
  SKIP tsx no {fixture} in the arguments; add a probe that takes a path, e.g. --probe "ls {fixture}"
66
71
 
67
- 2 failed, 0 warned, 8 passed, 3 skipped
72
+ 2 failed, 2 warned, 8 passed, 3 skipped
68
73
  ```
69
74
 
70
- <sub>tsx 4.23.15, run offline in a container in November 2026.</sub>
75
+ <sub>tsx 4.23.15 on Linux, run offline in a container in December 2026. On macOS, write-error is skipped.</sub>
71
76
 
72
77
  ## Why cliprobe?
73
78
 
@@ -75,7 +80,7 @@ When a program's output goes into a reader that stops early (`| head`, `grep -q`
75
80
 
76
81
  In a census of the 100 most-downloaded npm packages that ship a command (119 commands, run offline in a throwaway container), **9 crashed this way every time**: esbuild, browserslist, update-browserslist-db, autoprefixer, husky, tsconfck, ts-jest, rolldown, and tsx on `--version`. Since then esbuild and browserslist have fixed it; the other seven still crashed when re-checked at their November 2026 versions. The best-known existing CLI auditor rated the first 8 as passing its SIGPIPE check. The same census found two commands that print color codes into a pipe (`giget --help`, `tsx --help`), five whose `--help` or `--version` waits for stdin (he, cssesc, ansi-html, webpack and webpack-dev-server), and no false failures: every `FAIL` reproduced by hand. (A census of `--help` and `--version` can't exercise ctrl-c, sigterm or control-chars, which need a command that keeps running or takes a path; their fixtures and real-tool tests are in `test/`.)
77
82
 
78
- The other checks cover the rest of what goes wrong between a program and the thing reading it: color codes leaking into logs and agent transcripts, Ctrl-C that is ignored or ends in a stack trace, child processes left running after `kill` or `docker stop`, a terminal left with a hidden cursor or no line wrapping after Ctrl-C, and file names that can send escape sequences to your terminal.
83
+ The other checks cover the rest of what goes wrong between a program and the thing reading it: output lost on a full disk while the program exits 0, color codes leaking into logs and agent transcripts, Ctrl-C that is ignored or ends in a stack trace, child processes left running after `kill` or `docker stop`, a terminal left with a hidden cursor or no line wrapping after Ctrl-C, and file names that can send escape sequences to your terminal.
79
84
 
80
85
  - **Evidence, never a score.** Every result is a verdict with the error line, the first stack frame in the target's own code, or the escape sequence that leaked.
81
86
  - **No false fails.** A new check starts as warn-only and is calibrated against real tools before it may fail.
@@ -91,7 +96,7 @@ The other checks cover the rest of what goes wrong between a program and the thi
91
96
  - [In CI](#in-ci)
92
97
  - [JSON output](#json-output)
93
98
  - [Stability](#stability)
94
- - [Checks](#checks): [closed-pipe](#closed-pipe), [color](#color), [pipe-escapes](#pipe-escapes), [stdin](#stdin), [ctrl-c](#ctrl-c), [sigterm](#sigterm), [restore](#restore), [control-chars](#control-chars), [info checks](#info-checks)
99
+ - [Checks](#checks): [closed-pipe](#closed-pipe), [write-error](#write-error), [color](#color), [pipe-escapes](#pipe-escapes), [stdin](#stdin), [ctrl-c](#ctrl-c), [sigterm](#sigterm), [restore](#restore), [control-chars](#control-chars), [info checks](#info-checks)
95
100
  - [Fixing a failure in a Node.js CLI](#fixing-a-failure-in-a-nodejs-cli)
96
101
  - [Agent skill](#agent-skill)
97
102
  - [Safety](#safety)
@@ -101,7 +106,7 @@ The other checks cover the rest of what goes wrong between a program and the thi
101
106
 
102
107
  ## Installation
103
108
 
104
- Requires Node.js 22.12 or later, on macOS or Linux (including Alpine). Windows isn't supported yet. The terminal checks (color, restore and control-chars) also need the system's `script` command, which macOS has and most Linux distributions install by default. Without it they're skipped, and each skip says so. If it's missing, install the package that has it: `bsdutils` on Debian and Ubuntu, `util-linux-script` on Fedora, `util-linux-misc` on Alpine.
109
+ Requires Node.js 22.12 or later, on macOS or Linux (including Alpine). Windows isn't supported yet. The terminal checks (color, restore and control-chars) also need the system's `script` command, which macOS has and most Linux distributions install by default. Without it they're skipped, and each skip says so. If it's missing, install the package that has it: `bsdutils` on Debian and Ubuntu, `util-linux-script` on Fedora, `util-linux-misc` on Alpine. The write-error check needs Linux's `/dev/full`, so it's skipped on macOS.
105
110
 
106
111
  Run it without installing:
107
112
 
@@ -150,17 +155,19 @@ A probe runs `<command>` with its own args, in place of the args after the comma
150
155
 
151
156
  ## Exit codes
152
157
 
153
- | Code | Meaning |
154
- | ---- | ------------------------------------------------------------------------------------------ |
155
- | `0` | No check failed |
156
- | `1` | A check failed, or warned with `--strict` |
157
- | `2` | Usage error, the command could not run, or the `--output-file` report could not be written |
158
+ | Code | Meaning |
159
+ | ---- | ------------------------------------------------------------------------------------------------------------- |
160
+ | `0` | No check failed |
161
+ | `1` | A check failed, or warned with `--strict` |
162
+ | `2` | Usage error, the command could not run, or the report could not be written (to stdout or the `--output-file`) |
163
+
164
+ Any non-zero exit fails a CI step, so cliprobe works as a gate.
158
165
 
159
- A command that can't run is reported once, before any check runs, with exit `2` and no report: one that isn't on `PATH`, a directory, a file without the execute bit (`chmod +x`), or a script whose `#!` interpreter is missing. A file this system can't execute at all, such as a binary built for another platform, makes every check say could-not-run (`ERROR`), so cliprobe exits `2` there too; on Linux, where `/bin/sh` tries such a file as a script, cliprobe recognizes the shell's complaint. An `--output-file` path that can't be written, such as a directory or a folder without write permission, is also reported before any check runs, with exit `2`. If the file still can't be written at the end, cliprobe prints the human report first, so no result is lost, then the error, and exits `2` even when a check failed: CI fails the step either way. That makes cliprobe usable as a CI gate.
166
+ A command that can't run is reported once, before any check runs, with exit `2` and no report: one that isn't on `PATH`, a directory, a file without the execute bit (`chmod +x`), or a script whose `#!` interpreter is missing. A file this system can't execute at all, such as a binary built for another platform, makes every check say could-not-run (`ERROR`), so cliprobe exits `2` there too; on Linux, where `/bin/sh` tries such a file as a script, cliprobe recognizes the shell's complaint. An `--output-file` path that can't be written, such as a directory or a folder without write permission, is also reported before any check runs, with exit `2`. If the file still can't be written at the end, cliprobe prints the human report first, so no result is lost, then the error, and exits `2` even when a check failed: CI fails the step either way.
160
167
 
161
168
  ## In CI
162
169
 
163
- A failed check exits 1, so the step fails. Warnings don't fail it unless you add `--strict`; with `--strict`, `--skip` leaves out a check whose warning you accept. Add `--probe` for a command that keeps running and one with `{fixture}`, so a single step covers every check. In GitHub Actions, write a Markdown report to the job summary while the log keeps the human report:
170
+ A failed check exits 1, so the step fails. Warnings don't fail it unless you add `--strict`; with `--strict`, `--skip` leaves out a check whose warning you accept. Add `--probe` for a command that keeps running and one with `{fixture}`, so a single step covers every check. Use a Linux runner, where write-error also runs. In GitHub Actions, write a Markdown report to the job summary while the log keeps the human report:
164
171
 
165
172
  ```yaml
166
173
  - name: Check the CLI for terminal-edge bugs
@@ -188,7 +195,7 @@ In JUnit, each check is a test suite and each probe a test case: `FAIL` is a fai
188
195
  {
189
196
  "tool": "cliprobe",
190
197
  "schemaVersion": 1,
191
- "version": "1.0.0",
198
+ "version": "1.7.0",
192
199
  "command": "node",
193
200
  "checks": ["ctrl-c"],
194
201
  "strict": false,
@@ -204,6 +211,7 @@ In JUnit, each check is a test suite and each probe a test case: `FAIL` is a fai
204
211
  "exitedAfterMs": null,
205
212
  "exitCode": null,
206
213
  "signal": "SIGKILL",
214
+ "leftRunning": [],
207
215
  "stderrAfter": ""
208
216
  }
209
217
  }
@@ -219,13 +227,13 @@ From 1.0, cliprobe follows semantic versioning, and these hold for every 1.x rel
219
227
 
220
228
  - **No new failures.** A minor release never makes a passing or warning program fail. New checks, and new things an existing check notices, only warn until the next major release. So `cliprobe@1` in CI turns red only when your program changes.
221
229
  - **Names and exit codes.** Check names, verdicts, options and exit codes stay as they are.
222
- - **`--strict` opts out of the first promise.** It fails on warnings, so a new warning in a minor release can fail your build. Pin an exact version (`cliprobe@1.1.0`) if that matters, or `--skip` the check.
230
+ - **`--strict` opts out of the first promise.** It fails on warnings, so a new warning in a minor release can fail your build. Pin an exact version (`cliprobe@1.7.0`) if that matters, or `--skip` the check.
223
231
  - **JSON.** `schemaVersion` stays `1`. Fields are only added, never removed, renamed or given a new type.
224
232
  - **Not covered.** The wording of `reason` and `evidence`, and the human and Markdown output, are for people and may change. Match on `check` and `verdict`, not on text.
225
233
 
226
234
  ## Checks
227
235
 
228
- A default run does the eight checks below: closed-pipe, color, pipe-escapes, stdin, ctrl-c, sigterm, restore and control-chars. Each one reports evidence, never a score. Two info checks, startup and baseline, run only when you name them with `--check`.
236
+ A default run does the nine checks below: closed-pipe, write-error, color, pipe-escapes, stdin, ctrl-c, sigterm, restore and control-chars. Each one reports evidence, never a score. Two info checks, startup and baseline, run only when you name them with `--check`.
229
237
 
230
238
  A command that keeps running, such as a server, a watcher or a full-screen program, is what ctrl-c, sigterm and restore need. Give it after the command, or add it with `--probe` to keep the `--version` and `--help` probes in the same run; ctrl-c and sigterm only run the probes you name, and control-chars only those with `{fixture}`, so one run covers every check:
231
239
 
@@ -248,16 +256,28 @@ cliprobe runs the command twice: once normally, then with stdout set to a pipe w
248
256
 
249
257
  Servers and watchers crash the same way. Among 38 watch and serve modes of popular npm tools, 8 died with `Error: write EPIPE` as soon as their stdout reader went away, each confirmed by hand: `jest --watchAll`, `live-server`, `mocha --watch`, `nodemon`, `parcel`, `rolldown -w`, `srvx` and `vite build --watch`. None was flagged falsely.
250
258
 
259
+ ### write-error
260
+
261
+ cliprobe runs the command twice: once normally, then with stdout set to `/dev/full`, a Linux device where every write fails with `ENOSPC` (no space left on device), exactly as on a full disk. A program whose output never arrived must say so and exit non-zero, or `my-cli > report.json` on a full disk looks like success to the script, CI job or agent that ran it. GNU coreutils, git and Python do this. Node.js programs that print with `console.log` don't: it drops the failed write silently, and the program exits 0. Results:
262
+
263
+ | Verdict | Meaning |
264
+ | ------- | --------------------------------------------------------------------------------------------------------------------------- |
265
+ | `PASS` | Exited non-zero (with its error as evidence) or was stopped by a signal, or, for a command that keeps running, kept running |
266
+ | `WARN` | Exited 0 though its output was lost, crashed with a stack trace, or hung |
267
+ | `SKIP` | Wrote nothing to stdout for this invocation (or before the timeout), or the system has no `/dev/full` (macOS) |
268
+
269
+ The check is new in 1.7 and only warns: it never fails before a census of real tools and the next major release. It runs on Linux only, since macOS has no `/dev/full`; run it in CI on a Linux runner, or in a container.
270
+
251
271
  ### color
252
272
 
253
273
  cliprobe runs the command up to three times: into a pipe, under a real terminal (a pseudo-terminal through the system's `script` command, 80×24), and under a terminal with `NO_COLOR=1`. Every run gets `TERM=xterm-256color` and no `CI` variable, so a program can't pass just because the terminal type looks colorless, and color libraries that force color in CI don't fail it. Color codes in piped output end up in log files and agent transcripts as `\x1b[31m` noise. Results:
254
274
 
255
- | Verdict | Meaning |
256
- | ------- | ----------------------------------------------------------------------------------------------------------- |
257
- | `PASS` | No color in a pipe; in a terminal, either no color at all or color that `NO_COLOR` turns off |
258
- | `FAIL` | Printed color or style codes (bold counts, a bare reset doesn't) to stdout in a pipe |
259
- | `WARN` | Printed color to stderr in a pipe, or kept printing color under `NO_COLOR` |
260
- | `SKIP` | Printed nothing, waited for input in a terminal, or no `script` command (see [Installation](#installation)) |
275
+ | Verdict | Meaning |
276
+ | ------- | ------------------------------------------------------------------------------------------------------------- |
277
+ | `PASS` | No color in a pipe; in a terminal, either no color at all or color that `NO_COLOR` turns off |
278
+ | `FAIL` | Printed color or style codes (bold counts, a bare reset doesn't) to stdout in a pipe |
279
+ | `WARN` | Printed color to stderr in a pipe, or kept printing color under `NO_COLOR` |
280
+ | `SKIP` | Printed nothing, kept running or waited for input, or no `script` command (see [Installation](#installation)) |
261
281
 
262
282
  Many classic tools (git, BSD `ls` and `grep`) color correctly but don't implement [`NO_COLOR`](https://no-color.org), so they get a `WARN`, never a `FAIL`. Probe a command that prints color in normal use: almost no CLI colors its `--help`.
263
283
 
@@ -326,7 +346,7 @@ Spinners, prompts and full-screen programs switch terminal modes on: they hide t
326
346
  | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
327
347
  | `PASS` | Left no mode switched on, either because it never switched one or because it switched each back off (or reset the terminal), and left the terminal's settings as it found them |
328
348
  | `WARN` | Left one or more on, or switched a setting off and left it off (raw mode); the evidence quotes each sequence that was never undone and its line, and the settings as `stty` flags such as `-icanon -echo` |
329
- | `SKIP` | Still running 3 seconds after Ctrl-C (REPLs quit on a second one), more than 1 MiB of output, or no usable `script` command |
349
+ | `SKIP` | Still running 3 seconds after Ctrl-C (REPLs quit on a second one), `--version` or `--help` waited for input, more than 1 MiB of output, or no usable `script` command |
330
350
 
331
351
  It only warns: a terminal left in the wrong mode is a nuisance you can undo, not a failure of the program's job. Across the top 100 npm CLIs, their watch modes and servers, and popular prompt and spinner libraries (about 300 runs), nothing warned falsely, and one tool really did break the terminal: `taze -I` turns line wrapping off for its progress bars and leaves it off after Ctrl-C.
332
352
 
@@ -353,15 +373,18 @@ These report an observation with the verdict `INFO` and never fail. They run onl
353
373
 
354
374
  ## Fixing a failure in a Node.js CLI
355
375
 
356
- **closed-pipe:** handle `EPIPE` on stdout once, near your entry point:
376
+ **closed-pipe** and **write-error:** handle errors on stdout once, near your entry point. A closed pipe (`EPIPE`) means the reader has all it wants, so stop quietly; any other failed write, such as a full disk (`ENOSPC`), lost output, so say so and exit non-zero:
357
377
 
358
378
  ```js
359
379
  process.stdout.on('error', (error) => {
360
380
  if (error.code === 'EPIPE') process.exit(0);
361
- throw error;
381
+ console.error(`my-cli: cannot write output: ${error.message}`);
382
+ process.exit(1);
362
383
  });
363
384
  ```
364
385
 
386
+ The same handler catches writes made with `console.log`, which otherwise drops a failed write silently and lets the program exit 0.
387
+
365
388
  **color:** decide once, from the stream you write to:
366
389
 
367
390
  ```js
@@ -445,7 +468,16 @@ Then ask in your own words, for example "check my CLI for pipe and Ctrl-C bugs b
445
468
 
446
469
  ## Safety
447
470
 
448
- cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin, ctrl-c and sigterm checks use a pipe that they never write to), a temporary `HOME`, and a minimal environment (no tokens from your shell; see [the probe's environment](#the-probes-environment)). It still executes the program, so only probe programs you trust. By default cliprobe passes only the arguments you give, after the command or with `--probe`, or `--version` and `--help`, or none with `--bare`; only the baseline check, when you name it, adds an unknown flag. The only input it ever sends is Ctrl-C, from the ctrl-c and restore checks, and SIGTERM, from the sigterm check, to probes you write. It kills each run's whole process group on timeout, including under a pseudo-terminal, and when a program exits it kills whatever it left running, in its group or started in another one, in every check. If cliprobe itself is stopped by Ctrl-C, SIGTERM or SIGHUP, it first kills the probe it is running and removes its temporary directories and any half-written report file, then exits by the same signal (130, 143 or 129). It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command (see [Installation](#installation)). Windows isn't supported yet.
471
+ cliprobe executes the program you name, so only probe programs you trust. It limits what a probe can touch and cleans up after it:
472
+
473
+ - **No shell.** The target runs in your current directory, started directly.
474
+ - **A minimal environment.** A temporary `HOME` and no tokens from your shell; see [the probe's environment](#the-probes-environment).
475
+ - **Only your arguments.** cliprobe passes the arguments you give, after the command or with `--probe`, or `--version` and `--help`, or none with `--bare`. Only the baseline check, when you name it, adds an unknown flag.
476
+ - **No input.** stdin is closed (`/dev/null`); the stdin, ctrl-c and sigterm checks use a pipe that they never write to. The only input cliprobe ever sends is Ctrl-C, from the ctrl-c and restore checks, and SIGTERM, from the sigterm check, to probes you write.
477
+ - **Nothing left running.** It kills each run's whole process group on timeout, including under a pseudo-terminal. When a program exits, it kills whatever the program left running, in its group or started in another one, in every check.
478
+ - **Clean when interrupted.** If cliprobe itself is stopped by Ctrl-C, SIGTERM or SIGHUP, it first kills the probe it is running and removes its temporary directories and any half-written report file, then exits by the same signal (130, 143 or 129).
479
+
480
+ It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command (see [Installation](#installation)). Windows isn't supported yet.
449
481
 
450
482
  ### The probe's environment
451
483
 
@@ -469,7 +501,9 @@ The runs under a terminal are color's second and third, restore's, and control-c
469
501
 
470
502
  **Why were ctrl-c, sigterm and control-chars skipped?** They need probes that a plain `--version` and `--help` run doesn't have: ctrl-c and sigterm need a command that keeps running, such as a server or a watcher, and control-chars needs one that prints file names from `{fixture}`. Add them with `--probe`, so one run covers every check: `npx cliprobe --probe "serve --port 0" --probe "list {fixture}" -- my-cli`. If the reason adds that the probe exited with a failure code, it never ran as intended: check its arguments, and with `-- node ./cli.js`, name the script in the probe (`--probe "./cli.js serve"`).
471
503
 
472
- **My program works when I run it, so why does a check fail?** cliprobe sets up conditions that are rare by hand: stdout closed before the program starts, output into a pipe, stdin that nobody writes to, a minimal environment. Reproduce the failure the way the check's section shows, for example `my-cli --help | head -n 1` for closed-pipe or `my-cli --help | cat -v` for color, and read the evidence in `--json`. If you still believe the verdict is wrong, [open a wrong verdict issue](https://github.com/KhaledSaeed18/cliprobe/issues/new?template=wrong_verdict.yml).
504
+ **Why was write-error skipped?** It needs `/dev/full`, which only Linux has, so on macOS every probe is skipped. Run cliprobe in CI on a Linux runner or in a container to get its verdict. It is also skipped for a probe that writes nothing to stdout.
505
+
506
+ **My program works when I run it, so why does a check fail?** cliprobe sets up conditions that are rare by hand: stdout closed before the program starts, a full disk, output into a pipe, stdin that nobody writes to, a minimal environment. Reproduce the failure the way the check's section shows, for example `my-cli --help | head -n 1` for closed-pipe or `my-cli --help | cat -v` for color, and read the evidence in `--json`. If you still believe the verdict is wrong, [open a wrong verdict issue](https://github.com/KhaledSaeed18/cliprobe/issues/new?template=wrong_verdict.yml).
473
507
 
474
508
  **Why does my program behave differently under cliprobe?** It runs without your shell's variables or your home directory, with `TERM=dumb` and `CI=1` in most checks: [the probe's environment](#the-probes-environment) lists every variable. A program that needs a token or a config file from your home directory sees neither, as on a fresh CI runner.
475
509
 
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
3
  import { execFile, execFileSync, spawn } from "node:child_process";
4
- import { accessSync, closeSync, constants, lstatSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
4
+ import { accessSync, closeSync, constants, existsSync, lstatSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
5
5
  import { delimiter, dirname, join, resolve, sep } from "node:path";
6
6
  import { tmpdir } from "node:os";
7
7
  import { chmod, mkdir, rename, rm, writeFile } from "node:fs/promises";
@@ -325,6 +325,10 @@ function shellFallbackError(command, exitCode, stderr, path = process.env["PATH"
325
325
  }
326
326
  // src/core/run.ts
327
327
  const STDERR_CAP = 65536;
328
+ /** A device on Linux that accepts no data: every write to it fails with ENOSPC. */
329
+ const DEV_FULL = "/dev/full";
330
+ /** Whether this system has /dev/full (Linux does; macOS doesn't). */
331
+ const hasDevFull = () => existsSync(DEV_FULL);
328
332
  const STDOUT_CAP = 1048576;
329
333
  /**
330
334
  * The longest delay setTimeout takes (2^31 - 1 ms, about 24.8 days). Node turns
@@ -344,8 +348,9 @@ const delay = (ms) => new Promise((resolve) => {
344
348
  * Runs one invocation. With `closedStdout`, stdout is the write end of a FIFO
345
349
  * whose read end is closed before the program starts, so its first write to
346
350
  * stdout fails (EPIPE, or SIGPIPE for programs that keep the default handler).
351
+ * With `fullStdout`, stdout is /dev/full, so every write fails with ENOSPC.
347
352
  */
348
- function run$1(command, args, { closedStdout = false, timeout, env: overrides = {}, extraGroup, signal, stdin = "null", leftoversMs = 250 }) {
353
+ function run$1(command, args, { closedStdout = false, fullStdout = false, timeout, env: overrides = {}, extraGroup, signal, stdin = "null", leftoversMs = 250 }) {
349
354
  const { dir, env: base } = sandbox();
350
355
  const env = { ...base };
351
356
  for (const [key, value] of Object.entries(overrides)) if (value === void 0) delete env[key];
@@ -357,7 +362,7 @@ function run$1(command, args, { closedStdout = false, timeout, env: overrides =
357
362
  const reader = openSync(fifo, constants.O_RDONLY | constants.O_NONBLOCK);
358
363
  stdoutFd = openSync(fifo, constants.O_WRONLY | constants.O_NONBLOCK);
359
364
  closeSync(reader);
360
- }
365
+ } else if (fullStdout) stdoutFd = openSync(DEV_FULL, "w");
361
366
  return new Promise((resolve) => {
362
367
  let stdoutBytes = 0;
363
368
  const stdoutChunks = [];
@@ -558,12 +563,12 @@ function firstLine(r) {
558
563
  const err = lines(r.stderr)[0];
559
564
  return err === void 0 ? "" : `stderr: ${err}`;
560
565
  }
561
- const exitText = (r) => r.signal ? `was stopped by ${r.signal}` : `exited ${r.exitCode}`;
566
+ const exitText$1 = (r) => r.signal ? `was stopped by ${r.signal}` : `exited ${r.exitCode}`;
562
567
  /** Each describes one convention scripts and agents rely on; observations, never verdicts. */
563
568
  function describeVersion(r) {
564
569
  const out = lines(r.stdout.toString("utf8"));
565
570
  if (r.exitCode !== 0) return {
566
- reason: `${exitText(r)}; there may be no --version`,
571
+ reason: `${exitText$1(r)}; there may be no --version`,
567
572
  evidence: firstLine(r)
568
573
  };
569
574
  if (out.length === 1) return {
@@ -587,9 +592,9 @@ function describeHelp(r) {
587
592
  const noun = out.length === 1 ? "line" : "lines";
588
593
  return { reason: `printed ${out.length} ${noun} to stdout and exited 0` };
589
594
  }
590
- if (out.length) return { reason: `printed help to stdout but ${exitText(r)}` };
591
- if (err.length) return { reason: `printed help to stderr and ${exitText(r)}, so "--help | less" and agents reading stdout get nothing` };
592
- return { reason: `printed nothing and ${exitText(r)}` };
595
+ if (out.length) return { reason: `printed help to stdout but ${exitText$1(r)}` };
596
+ if (err.length) return { reason: `printed help to stderr and ${exitText$1(r)}, so "--help | less" and agents reading stdout get nothing` };
597
+ return { reason: `printed nothing and ${exitText$1(r)}` };
593
598
  }
594
599
  function describeUnknownFlag(r) {
595
600
  if (r.timedOut) return { reason: `still running after ${UNKNOWN_FLAG_TIMEOUT_MS / 1e3} s; it may have ignored the flag and started its default action` };
@@ -599,9 +604,9 @@ function describeUnknownFlag(r) {
599
604
  evidence
600
605
  } : { reason };
601
606
  if (r.exitCode === 0) return withEvidence("exited 0, so a script cannot tell the flag was wrong");
602
- if (lines(r.stdout.toString("utf8")).length) return withEvidence(`${exitText(r)}, but printed its message to stdout rather than stderr`);
603
- if (lines(r.stderr).length) return withEvidence(`${exitText(r)} with its message on stderr`);
604
- return { reason: `${exitText(r)} without saying why` };
607
+ if (lines(r.stdout.toString("utf8")).length) return withEvidence(`${exitText$1(r)}, but printed its message to stdout rather than stderr`);
608
+ if (lines(r.stderr).length) return withEvidence(`${exitText$1(r)} with its message on stderr`);
609
+ return { reason: `${exitText$1(r)} without saying why` };
605
610
  }
606
611
  async function probe(command, args, timeout, describe) {
607
612
  const r = await run$1(command, args, { timeout });
@@ -711,7 +716,7 @@ const newWriteError = (base, closed) => ERROR_RE.test(closed.stderr) && !ERROR_R
711
716
  * For a program that keeps running (a server, a watcher): there is no normal exit
712
717
  * to compare with, but a crash once stdout is closed is still a crash.
713
718
  */
714
- function judgeLongRunning(base, closed) {
719
+ function judgeLongRunning$1(base, closed) {
715
720
  if (!closed.timedOut && newWriteError(base, closed)) return {
716
721
  verdict: "fail",
717
722
  reason: `crashed when stdout was closed, while a normal run kept running (exit ${closed.exitCode})`,
@@ -740,12 +745,12 @@ function judgeLongRunning(base, closed) {
740
745
  };
741
746
  }
742
747
  /** Compares a normal run with a closed-stdout run of the same invocation. */
743
- function judge(base, closed) {
748
+ function judge$1(base, closed) {
744
749
  if (base.spawnError) return {
745
750
  verdict: "error",
746
751
  reason: `could not start: ${base.spawnError}`
747
752
  };
748
- if (base.timedOut) return judgeLongRunning(base, closed);
753
+ if (base.timedOut) return judgeLongRunning$1(base, closed);
749
754
  if (base.stdoutBytes === 0) return noteFailedExit({
750
755
  verdict: "skip",
751
756
  reason: "wrote nothing to stdout, so a closed stdout is never touched"
@@ -791,7 +796,7 @@ async function closedPipe(command, args, ctx) {
791
796
  return {
792
797
  check: "closed-pipe",
793
798
  invocation: [command, ...args],
794
- ...judge(base, closed),
799
+ ...judge$1(base, closed),
795
800
  baseline: {
796
801
  exitCode: base.exitCode,
797
802
  signal: base.signal,
@@ -2256,22 +2261,127 @@ async function stdinCheck(command, args, defaultProbe, ctx) {
2256
2261
  finishedAfterCloseMs: proven && runs.closing ? runs.closing.durationMs - (runs.closeAfterMs ?? 1e3) : null
2257
2262
  };
2258
2263
  }
2264
+ const stdinCheckDefinition = {
2265
+ name: "stdin",
2266
+ kind: "check",
2267
+ summary: "waits for stdin when it is an open pipe, as agents and CI runners leave it",
2268
+ async run(target, ctx) {
2269
+ const results = [];
2270
+ for (const { args, own } of target.probes) results.push(await stdinCheck(target.command, args, !own, ctx));
2271
+ return results;
2272
+ }
2273
+ };
2274
+ // src/checks/write-error.ts
2275
+ /** A stack trace that only the failed writes brought out. */
2276
+ const newTrace = (base, full) => TRACE_RE.test(full.stderr) && !TRACE_RE.test(base.stderr);
2277
+ /** The first line it printed to stderr, as evidence of how it reported the error. */
2278
+ const stderrLine = (r) => {
2279
+ const message = crashEvidence(r.stderr);
2280
+ return message ? { evidence: message } : {};
2281
+ };
2282
+ const EXITED_ZERO = "exited 0 though every write to stdout failed (no space left on device), so `> file` on a full disk looks like success";
2283
+ /** For a program that keeps running: only how it ends, if it ends, is judged. */
2284
+ function judgeLongRunning(base, full) {
2285
+ if (full.timedOut) return {
2286
+ verdict: "pass",
2287
+ reason: `${stillRunning(base.durationMs)}; with stdout on a full disk it kept running`
2288
+ };
2289
+ if (newTrace(base, full)) return {
2290
+ verdict: "warn",
2291
+ reason: "crashed with a stack trace when a write to stdout failed",
2292
+ evidence: crashEvidence(full.stderr)
2293
+ };
2294
+ if (full.exitCode === 0) return {
2295
+ verdict: "warn",
2296
+ reason: EXITED_ZERO
2297
+ };
2298
+ return {
2299
+ verdict: "pass",
2300
+ reason: `stopped when a write to stdout failed (${exitText(full)})`,
2301
+ ...stderrLine(full)
2302
+ };
2303
+ }
2304
+ const exitText = (r) => r.signal ? `stopped by ${r.signal}` : `exit ${r.exitCode}`;
2305
+ /**
2306
+ * Compares a normal run with a run whose stdout is /dev/full, where every write
2307
+ * fails with ENOSPC. A careful program says so and exits non-zero, as GNU
2308
+ * coreutils, git and Python do. Warn-only until a census shows no false warns.
2309
+ */
2310
+ function judge(base, full) {
2311
+ if (base.spawnError) return {
2312
+ verdict: "error",
2313
+ reason: `could not start: ${base.spawnError}`
2314
+ };
2315
+ if (base.stdoutBytes === 0) return noteFailedExit({
2316
+ verdict: "skip",
2317
+ reason: base.timedOut ? `${stillRunning(base.durationMs)} without writing to stdout, so a failed write never happened` : "wrote nothing to stdout, so a failed write never happens"
2318
+ }, base);
2319
+ if (!full) return {
2320
+ verdict: "skip",
2321
+ reason: "no /dev/full on this system (it needs Linux)"
2322
+ };
2323
+ if (base.timedOut) return judgeLongRunning(base, full);
2324
+ if (full.timedOut) return {
2325
+ verdict: "warn",
2326
+ reason: "hung when a write to stdout failed",
2327
+ ...stderrLine(full)
2328
+ };
2329
+ if (newTrace(base, full)) return {
2330
+ verdict: "warn",
2331
+ reason: `crashed with a stack trace when a write to stdout failed (${exitText(full)})`,
2332
+ evidence: crashEvidence(full.stderr)
2333
+ };
2334
+ if (full.exitCode === 0) return {
2335
+ verdict: "warn",
2336
+ reason: EXITED_ZERO
2337
+ };
2338
+ return {
2339
+ verdict: "pass",
2340
+ reason: `reported the failed write (${exitText(full)})`,
2341
+ ...stderrLine(full)
2342
+ };
2343
+ }
2344
+ async function writeError(command, args, ctx) {
2345
+ const base = await run$1(command, args, { timeout: probeTimeout(ctx, command, args) });
2346
+ if (base.timedOut) markLongRunning(ctx, command, args);
2347
+ const full = !base.spawnError && base.stdoutBytes > 0 && hasDevFull() ? await run$1(command, args, {
2348
+ fullStdout: true,
2349
+ timeout: base.timedOut ? Math.min(ctx.timeout, LONG_RUN_WINDOW_MS) : ctx.timeout
2350
+ }) : void 0;
2351
+ return {
2352
+ check: "write-error",
2353
+ invocation: [command, ...args],
2354
+ ...judge(base, full),
2355
+ baseline: {
2356
+ exitCode: base.exitCode,
2357
+ signal: base.signal,
2358
+ stdoutBytes: base.stdoutBytes
2359
+ },
2360
+ full: full ? {
2361
+ exitCode: full.exitCode,
2362
+ signal: full.signal,
2363
+ timedOut: full.timedOut,
2364
+ stderr: full.stderr.slice(-2e3)
2365
+ } : null
2366
+ };
2367
+ }
2259
2368
  // src/checks/index.ts
2260
2369
  /** Every check, in the order they run and are reported. */
2261
2370
  const CHECKS = [
2262
2371
  closedPipeCheck,
2263
- colorCheck,
2264
- pipeEscapesCheck,
2265
2372
  {
2266
- name: "stdin",
2373
+ name: "write-error",
2267
2374
  kind: "check",
2268
- summary: "waits for stdin when it is an open pipe, as agents and CI runners leave it",
2375
+ summary: "exits 0 or crashes when writing stdout fails (a full disk)",
2269
2376
  async run(target, ctx) {
2270
2377
  const results = [];
2271
- for (const { args, own } of target.probes) results.push(await stdinCheck(target.command, args, !own, ctx));
2378
+ for (const { args } of target.probes) results.push(await writeError(target.command, args, ctx));
2272
2379
  return results;
2273
2380
  }
2274
2381
  },
2382
+ colorCheck,
2383
+ pipeEscapesCheck,
2384
+ stdinCheckDefinition,
2275
2385
  ctrlCCheck,
2276
2386
  sigtermCheck,
2277
2387
  restoreCheck,
@@ -2853,6 +2963,11 @@ Checks:
2853
2963
  piped into a reader that quits early (head, grep -q, an agent).
2854
2964
  A well-behaved program exits quietly; a buggy one crashes with
2855
2965
  an EPIPE error and a stack trace.
2966
+ write-error Runs the command with stdout on /dev/full, where every write
2967
+ fails as on a full disk (Linux only; skipped elsewhere). Warns
2968
+ if it exits 0 anyway, so the lost output looks like success,
2969
+ crashes with a stack trace, or hangs. A careful program prints
2970
+ the error and exits non-zero.
2856
2971
  color Runs the command into a pipe, then under a terminal, then under
2857
2972
  a terminal with NO_COLOR=1. Fails if color codes reach a pipe;
2858
2973
  warns if color goes to a piped stderr or NO_COLOR is ignored.
@@ -2927,7 +3042,7 @@ Options:
2927
3042
  -v, --version Show the version
2928
3043
 
2929
3044
  Exit codes: 0 no failures, 1 a check failed (or warned, with --strict), 2 usage
2930
- error, could not run, or could not write the --output-file report.
3045
+ error, could not run, or could not write the report (to stdout or the file).
2931
3046
  Runs the target in the current directory without a shell, with stdin closed
2932
3047
  (the stdin, ctrl-c and sigterm checks use a pipe they never write to), a
2933
3048
  temporary HOME and a minimal environment. Only run programs you trust. When a
@@ -3046,7 +3161,8 @@ async function run(argv, io) {
3046
3161
  // src/cli/main.ts
3047
3162
  process.stdout.on("error", (error) => {
3048
3163
  if (error.code === "EPIPE") process.exit(process.exitCode ?? 0);
3049
- throw error;
3164
+ process.stderr.write(`cliprobe: cannot write the report: ${error.message}\n`);
3165
+ process.exit(2);
3050
3166
  });
3051
3167
  handleInterrupts();
3052
3168
  process.exitCode = await run(process.argv.slice(2), {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cliprobe",
3
- "version": "1.6.1",
4
- "description": "Black-box test any command-line program for terminal-edge bugs: crashes on a closed pipe (| head), color and control codes leaking into pipes, hangs waiting on stdin, broken Ctrl-C handling, child processes left running after SIGTERM, a terminal left broken after Ctrl-C, and control characters from file names reaching your terminal.",
3
+ "version": "1.7.1",
4
+ "description": "Black-box test any command-line program for terminal-edge bugs: crashes on a closed pipe (| head), output lost on a full disk while exiting 0, color and control codes leaking into pipes, hangs waiting on stdin, broken Ctrl-C handling, child processes left running after SIGTERM, a terminal left broken after Ctrl-C, and control characters from file names reaching your terminal.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "cliprobe": "dist/cli.js"
@@ -34,6 +34,7 @@
34
34
  "cli",
35
35
  "testing",
36
36
  "epipe",
37
+ "enospc",
37
38
  "sigpipe",
38
39
  "broken-pipe",
39
40
  "black-box",
@@ -87,20 +88,20 @@
87
88
  "@semantic-release/release-notes-generator": "^14.1.1",
88
89
  "@types/markdown-it": "^14.2.0",
89
90
  "@types/node": "^22.20.5",
90
- "@vitest/coverage-v8": "^5.1.0",
91
+ "@vitest/coverage-v8": "^5.1.1",
91
92
  "ajv": "^8.20.0",
92
93
  "conventional-changelog-conventionalcommits": "^9.3.1",
93
94
  "fast-xml-parser": "^5.12.1",
94
95
  "husky": "^9.1.7",
95
96
  "markdown-it": "^15.0.3",
96
- "oxlint": "^1.93.0",
97
- "oxlint-tsgolint": "^7.0.2007",
97
+ "oxlint": "^1.94.0",
98
+ "oxlint-tsgolint": "^7.0.2008",
98
99
  "prettier": "^3.10.1",
99
100
  "publint": "^0.3.25",
100
101
  "semantic-release": "^26.0.1",
101
102
  "tsdown": "^0.23.1",
102
103
  "typescript": "^7.0.2",
103
- "vitest": "^5.1.0"
104
+ "vitest": "^5.1.1"
104
105
  },
105
106
  "packageManager": "pnpm@12.14.0"
106
107
  }
package/schema.json CHANGED
@@ -73,6 +73,7 @@
73
73
  "checkName": {
74
74
  "enum": [
75
75
  "closed-pipe",
76
+ "write-error",
76
77
  "color",
77
78
  "pipe-escapes",
78
79
  "stdin",
@@ -153,6 +154,22 @@
153
154
  }
154
155
  }
155
156
  },
157
+ {
158
+ "if": {
159
+ "properties": {
160
+ "check": {
161
+ "const": "write-error"
162
+ }
163
+ }
164
+ },
165
+ "then": {
166
+ "properties": {
167
+ "details": {
168
+ "$ref": "#/$defs/details.write-error"
169
+ }
170
+ }
171
+ }
172
+ },
156
173
  {
157
174
  "if": {
158
175
  "properties": {
@@ -347,6 +364,54 @@
347
364
  }
348
365
  }
349
366
  },
367
+ "details.write-error": {
368
+ "type": "object",
369
+ "description": "A normal run into a pipe, then a run with stdout on /dev/full, where every write fails with ENOSPC.",
370
+ "required": ["baseline", "full"],
371
+ "properties": {
372
+ "baseline": {
373
+ "type": "object",
374
+ "description": "The normal run.",
375
+ "required": ["exitCode", "signal", "stdoutBytes"],
376
+ "properties": {
377
+ "exitCode": {
378
+ "type": ["integer", "null"],
379
+ "description": "Exit code; null if it was killed by a signal or never ran."
380
+ },
381
+ "signal": {
382
+ "type": ["string", "null"],
383
+ "description": "Signal that ended it, such as \"SIGPIPE\"; null if it exited."
384
+ },
385
+ "stdoutBytes": {
386
+ "type": "integer",
387
+ "minimum": 0
388
+ }
389
+ }
390
+ },
391
+ "full": {
392
+ "type": ["object", "null"],
393
+ "description": "The run with stdout on /dev/full; null if it did not run (nothing written to stdout, the program could not start, or no /dev/full, as on macOS).",
394
+ "required": ["exitCode", "signal", "timedOut", "stderr"],
395
+ "properties": {
396
+ "exitCode": {
397
+ "type": ["integer", "null"],
398
+ "description": "Exit code; null if it was killed by a signal or never ran."
399
+ },
400
+ "signal": {
401
+ "type": ["string", "null"],
402
+ "description": "Signal that ended it, such as \"SIGPIPE\"; null if it exited."
403
+ },
404
+ "timedOut": {
405
+ "type": "boolean"
406
+ },
407
+ "stderr": {
408
+ "type": "string",
409
+ "description": "What it printed to stderr, up to 64 KiB."
410
+ }
411
+ }
412
+ }
413
+ }
414
+ },
350
415
  "details.color": {
351
416
  "type": "object",
352
417
  "description": "Runs into a pipe, under a terminal and under a terminal with NO_COLOR=1; null for a run that was not needed.",