cliprobe 0.7.0 → 0.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 +103 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<a href="https://www.npmjs.com/package/cliprobe">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/KhaledSaeed18/cliprobe/main/.github/assets/cliprobe-banner.png" alt="cliprobe: black-box tests for the terminal bugs that only show up in a pipe" width="100%" />
|
|
5
|
+
</a>
|
|
6
|
+
|
|
7
|
+
<h1>cliprobe</h1>
|
|
8
|
+
|
|
9
|
+
<p><strong>Black-box tests any command-line program for terminal-edge bugs:</strong> the ones that only show up when output is piped, cut short, or read by a script or an AI agent.</p>
|
|
10
|
+
|
|
11
|
+
<p>
|
|
12
|
+
<a href="https://www.npmjs.com/package/cliprobe"><img src="https://shieldcn.dev/npm/cliprobe.svg?logo=npm" alt="npm version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/cliprobe"><img src="https://shieldcn.dev/npm/dw/cliprobe.svg" alt="npm downloads" /></a>
|
|
14
|
+
<a href="https://github.com/KhaledSaeed18/cliprobe/actions/workflows/ci.yml"><img src="https://shieldcn.dev/github/ci/KhaledSaeed18/cliprobe.svg" alt="CI status" /></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/cliprobe"><img src="https://shieldcn.dev/npm/node/cliprobe.svg" alt="Node.js version" /></a>
|
|
16
|
+
<a href="https://github.com/KhaledSaeed18/cliprobe/blob/main/LICENSE"><img src="https://shieldcn.dev/npm/license/cliprobe.svg?variant=secondary" alt="License: MIT" /></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p>
|
|
20
|
+
<a href="https://github.com/KhaledSaeed18/cliprobe/stargazers"><img src="https://shieldcn.dev/github/stars/KhaledSaeed18/cliprobe.svg?variant=outline" alt="GitHub stars" /></a>
|
|
21
|
+
<a href="https://github.com/KhaledSaeed18/cliprobe/issues"><img src="https://shieldcn.dev/github/issues/KhaledSaeed18/cliprobe.svg?variant=outline" alt="GitHub issues" /></a>
|
|
22
|
+
<a href="https://github.com/KhaledSaeed18/cliprobe/releases"><img src="https://shieldcn.dev/github/release/KhaledSaeed18/cliprobe.svg?variant=ghost" alt="Latest release" /></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
---
|
|
4
28
|
|
|
5
29
|
```sh
|
|
6
30
|
npx cliprobe -- esbuild
|
|
@@ -40,7 +64,7 @@ control-chars
|
|
|
40
64
|
2 failed, 0 warned, 8 passed, 2 skipped
|
|
41
65
|
```
|
|
42
66
|
|
|
43
|
-
## Why
|
|
67
|
+
## Why cliprobe?
|
|
44
68
|
|
|
45
69
|
When a program's output goes into a reader that stops early (`| head`, `grep -q`, a closed agent pipe), its next write to stdout fails. A well-behaved program exits quietly. Many Node.js CLIs instead crash with `Error: write EPIPE`, a stack trace, and exit code 1. That breaks scripts running under `set -o pipefail` and confuses agents that read stderr.
|
|
46
70
|
|
|
@@ -48,6 +72,38 @@ In a census of the 100 most-downloaded npm packages that ship a command (119 com
|
|
|
48
72
|
|
|
49
73
|
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, 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.
|
|
50
74
|
|
|
75
|
+
- **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.
|
|
76
|
+
- **No false fails.** A new check starts as warn-only and is calibrated against real tools before it may fail.
|
|
77
|
+
- **Deterministic.** A closed pipe is a FIFO closed before the program starts, Ctrl-C is a signal to its process group, and the terminal is always 80×24.
|
|
78
|
+
- **Any language.** It tests the program from the outside, so a Go, Rust, Python or shell CLI works as well as a Node.js one.
|
|
79
|
+
- **Zero dependencies.** Nothing but Node.js and, for the terminal checks, the system's `script` command.
|
|
80
|
+
|
|
81
|
+
## Contents
|
|
82
|
+
|
|
83
|
+
- [Installation](#installation)
|
|
84
|
+
- [Usage](#usage)
|
|
85
|
+
- [Exit codes](#exit-codes)
|
|
86
|
+
- [In CI](#in-ci)
|
|
87
|
+
- [Checks](#checks): [closed-pipe](#closed-pipe), [color](#color), [pipe-escapes](#pipe-escapes), [stdin](#stdin), [ctrl-c](#ctrl-c), [restore](#restore), [control-chars](#control-chars), [info checks](#info-checks)
|
|
88
|
+
- [Fixing a failure in a Node.js CLI](#fixing-a-failure-in-a-nodejs-cli)
|
|
89
|
+
- [Safety](#safety)
|
|
90
|
+
- [Contributing](#contributing)
|
|
91
|
+
- [License](#license)
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
Requires Node.js 22.12 or later, on macOS or Linux (including Alpine). Windows isn't supported yet. Run it without installing:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
npx cliprobe -- <command>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Or add it to a project, to run in CI against your own CLI:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
npm install --save-dev cliprobe # or: pnpm add -D cliprobe
|
|
105
|
+
```
|
|
106
|
+
|
|
51
107
|
## Usage
|
|
52
108
|
|
|
53
109
|
```sh
|
|
@@ -72,9 +128,17 @@ npx cliprobe --check startup,baseline -- node ./dist/cli.js # info checks, onl
|
|
|
72
128
|
| `-h`, `--help` | Show help |
|
|
73
129
|
| `-v`, `--version` | Show the version |
|
|
74
130
|
|
|
75
|
-
Exit codes
|
|
131
|
+
## Exit codes
|
|
132
|
+
|
|
133
|
+
| Code | Meaning |
|
|
134
|
+
| ---- | ----------------------------------------- |
|
|
135
|
+
| `0` | No check failed |
|
|
136
|
+
| `1` | A check failed |
|
|
137
|
+
| `2` | Usage error, or the command could not run |
|
|
76
138
|
|
|
77
|
-
|
|
139
|
+
A command that isn't on `PATH` is reported once, before any check runs, with exit `2` and no report. That makes cliprobe usable as a CI gate.
|
|
140
|
+
|
|
141
|
+
## In CI
|
|
78
142
|
|
|
79
143
|
A failed check exits 1, so the step fails. In GitHub Actions, write a Markdown report to the job summary while the log keeps the human report:
|
|
80
144
|
|
|
@@ -102,7 +166,9 @@ A default run does the seven checks below: closed-pipe, color, pipe-escapes, std
|
|
|
102
166
|
|
|
103
167
|
A command that keeps running, such as a server, a watcher or a full-screen program, is what ctrl-c and restore need. The other checks judge it on what it did before the timeout (`--timeout`, 15 seconds by default): a crash once stdout is closed still fails, color or a spinner in a pipe still counts, and stdin is skipped. The timeout is paid once: after the first check sees the command still running, the others watch it for 3 seconds.
|
|
104
168
|
|
|
105
|
-
|
|
169
|
+
### closed-pipe
|
|
170
|
+
|
|
171
|
+
cliprobe runs the command twice: once normally, then with stdout set to a pipe whose reading end is already closed, so the first write fails every time, even for fast native programs. Results:
|
|
106
172
|
|
|
107
173
|
| Verdict | Meaning |
|
|
108
174
|
| ------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -113,7 +179,9 @@ A command that keeps running, such as a server, a watcher or a full-screen progr
|
|
|
113
179
|
|
|
114
180
|
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.
|
|
115
181
|
|
|
116
|
-
|
|
182
|
+
### color
|
|
183
|
+
|
|
184
|
+
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:
|
|
117
185
|
|
|
118
186
|
| Verdict | Meaning |
|
|
119
187
|
| ------- | -------------------------------------------------------------------------------------------------------------- |
|
|
@@ -124,7 +192,9 @@ Servers and watchers crash the same way. Among 38 watch and serve modes of popul
|
|
|
124
192
|
|
|
125
193
|
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`.
|
|
126
194
|
|
|
127
|
-
|
|
195
|
+
### pipe-escapes
|
|
196
|
+
|
|
197
|
+
cliprobe runs the command into a pipe, with the same environment as the color check, and looks at stdout and stderr for terminal control codes that only make sense on a screen: cursor movement, line and screen erases, mode switches such as hiding the cursor, hyperlinks (OSC 8), window titles, and carriage returns that redraw a line. Spinners and progress bars are the usual source. In a pipe they turn logs and agent transcripts into `\r\x1b[2K` noise. Results:
|
|
128
198
|
|
|
129
199
|
| Verdict | Meaning |
|
|
130
200
|
| ------- | -------------------------------------------------------------------------- |
|
|
@@ -134,7 +204,9 @@ Many classic tools (git, BSD `ls` and `grep`) color correctly but don't implemen
|
|
|
134
204
|
|
|
135
205
|
It only warns for now, never fails. In the census of the top 100 npm CLIs, no `--help` or `--version` printed any of these codes, which says nothing about their spinners: probe a command that does real work, such as an install or a build. With `{fixture}` in the args, the hostile file names themselves are left to the control-chars check: a lister that prints them raw into a pipe, as `ls` does, isn't warned about.
|
|
136
206
|
|
|
137
|
-
|
|
207
|
+
### stdin
|
|
208
|
+
|
|
209
|
+
Agents and CI runners often start a command with stdin as a pipe that stays open and never receives anything. A program that reads stdin, or asks a question, then waits forever. cliprobe runs the command three ways: with stdin closed (`/dev/null`), with an open pipe, and, if that hangs for 3 seconds, with a pipe it closes after 1 second. Finishing right after the close proves stdin was the cause. Results:
|
|
138
210
|
|
|
139
211
|
| Verdict | Meaning |
|
|
140
212
|
| ------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -145,7 +217,9 @@ It only warns for now, never fails. In the census of the top 100 npm CLIs, no `-
|
|
|
145
217
|
|
|
146
218
|
In the census of the top 100 npm CLIs, 9 of 238 `--help` and `--version` runs failed, each confirmed by hand. he, cssesc and ansi-html read stdin before looking at their arguments. webpack and webpack-dev-server, when webpack-cli is missing, ask whether to install it and wait for an answer without checking for a terminal. With no arguments, 17 tools waited on stdin as filters by design, which is why probes you write never fail this check.
|
|
147
219
|
|
|
148
|
-
|
|
220
|
+
### ctrl-c
|
|
221
|
+
|
|
222
|
+
cliprobe lets the command run for 1 second, then sends SIGINT to its process group, which is what a terminal does when you press Ctrl-C, and gives it 3 seconds to exit. Results:
|
|
149
223
|
|
|
150
224
|
| Verdict | Meaning |
|
|
151
225
|
| ------- | ---------------------------------------------------------------------------------------------- |
|
|
@@ -156,7 +230,9 @@ In the census of the top 100 npm CLIs, 9 of 238 `--help` and `--version` runs fa
|
|
|
156
230
|
|
|
157
231
|
A stack trace printed before the Ctrl-C doesn't count. Python's default `KeyboardInterrupt` traceback is the classic failure here, so `python3 -c 'import time; time.sleep(30)'` fails.
|
|
158
232
|
|
|
159
|
-
|
|
233
|
+
### restore
|
|
234
|
+
|
|
235
|
+
Spinners, prompts and full-screen programs switch terminal modes on: they hide the cursor, open the alternate screen, turn on mouse reporting or bracketed paste, or turn line wrapping off. If they don't switch them back off on the way out, the shell they return to is broken until you run `reset`: no cursor, a blank screen, mouse clicks typed as junk, long lines cut off at the edge. cliprobe runs the command under a terminal and, for probes you write, types Ctrl-C after 1 second, as a person would. The keystroke goes through the terminal, so a program in raw mode gets it as a key rather than a signal, just as it would from a keyboard. `--version` and `--help` aren't interrupted; they're judged as they exit. Results:
|
|
160
236
|
|
|
161
237
|
| Verdict | Meaning |
|
|
162
238
|
| ------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -166,7 +242,9 @@ A stack trace printed before the Ctrl-C doesn't count. Python's default `Keyboar
|
|
|
166
242
|
|
|
167
243
|
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.
|
|
168
244
|
|
|
169
|
-
|
|
245
|
+
### control-chars
|
|
246
|
+
|
|
247
|
+
Put `{fixture}` in the arguments where your command takes a path, for example `npx cliprobe -- ls {fixture}` or `npx cliprobe -- node ./dist/cli.js scan --dir={fixture}`. cliprobe replaces it with a temporary directory of file names holding escape sequences (one sets the window title, one clears the screen), a C1 control character, a carriage return, a newline and a bidirectional override. It runs the command under a terminal and looks for those characters, unescaped, in what reaches it. A file name that can clear someone's screen or retitle their window is a terminal injection, the same bug class as the `ls`/`find` escaping that GNU coreutils added years ago. Reports show `{fixture}`, never the temporary path, and the directory is removed afterwards. Results:
|
|
170
248
|
|
|
171
249
|
| Verdict | Meaning |
|
|
172
250
|
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -243,6 +321,18 @@ Also escape U+2028, U+2029 and the bidi controls (U+202A to U+202E, U+2066 to U+
|
|
|
243
321
|
|
|
244
322
|
cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin check also uses a pipe that it never writes to), a temporary `HOME`, and a minimal environment (no tokens from your shell). It still executes the program, so only probe programs you trust. By default cliprobe passes only the arguments you give, 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, to probes you write. It kills each run's whole process group on timeout, including under a pseudo-terminal. It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command, which Alpine ships in `util-linux-misc`. Windows isn't supported yet.
|
|
245
323
|
|
|
324
|
+
## Contributing
|
|
325
|
+
|
|
326
|
+
Bug reports and pull requests are welcome. Development needs Node.js 22.12 or later and pnpm (the version is pinned in `package.json`):
|
|
327
|
+
|
|
328
|
+
```sh
|
|
329
|
+
pnpm install
|
|
330
|
+
pnpm dev --check closed-pipe -- printf hi # run the CLI from source
|
|
331
|
+
pnpm check # everything CI runs
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
[AGENTS.md](https://github.com/KhaledSaeed18/cliprobe/blob/main/AGENTS.md) describes the layout, the product rules and how to add a check. Commits follow [Conventional Commits](https://www.conventionalcommits.org), and every `feat` or `fix` merged to `main` is released to npm.
|
|
335
|
+
|
|
246
336
|
## License
|
|
247
337
|
|
|
248
|
-
MIT
|
|
338
|
+
[MIT](https://github.com/KhaledSaeed18/cliprobe/blob/main/LICENSE), by [Khaled Saeed](https://github.com/KhaledSaeed18).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cliprobe",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
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, a terminal left broken after Ctrl-C, and control characters from file names reaching your terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|