cliprobe 1.8.0 → 1.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.
- package/README.md +14 -4
- package/dist/cli.js +56 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ control-chars
|
|
|
78
78
|
|
|
79
79
|
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.
|
|
80
80
|
|
|
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
|
|
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, browserslist and autoprefixer have fixed it; the other six still crash at their December 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/`.) The census is repeatable: [`census/`](https://github.com/KhaledSaeed18/cliprobe/tree/main/census) pins the packages, runs them offline with one command, and keeps [the latest results](https://github.com/KhaledSaeed18/cliprobe/blob/main/census/results/top-100.md).
|
|
82
82
|
|
|
83
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.
|
|
84
84
|
|
|
@@ -130,6 +130,7 @@ npx cliprobe --probe "watch app.ts" -- tsx # adds a probe: --version, --help a
|
|
|
130
130
|
npx cliprobe -- node ./dist/cli.js list # test your own CLI before publishing
|
|
131
131
|
npx cliprobe --json -- <command> # machine-readable results
|
|
132
132
|
npx cliprobe --format junit -o report.xml -- <command> # JUnit file for CI; human report on stdout
|
|
133
|
+
npx cliprobe --format github -- <command> # in GitHub Actions: the report, plus an annotation per finding
|
|
133
134
|
npx cliprobe -- ls {fixture} # {fixture}: a directory of hostile file names
|
|
134
135
|
npx cliprobe --bare -- htop # the command alone: a REPL, a full-screen program, a server
|
|
135
136
|
npx cliprobe --check startup,baseline -- node ./dist/cli.js # info checks, only when named
|
|
@@ -145,7 +146,7 @@ npx cliprobe # no command: the run in cliprobe.conf
|
|
|
145
146
|
| `--check <name>` | Run only this check; repeat it or use commas for several |
|
|
146
147
|
| `--skip <name>` | Leave this check out; repeat it or use commas for several |
|
|
147
148
|
| `--strict` | Exit 1 on a warning too, not only on a failure |
|
|
148
|
-
| `--format <name>` | Output format: `human` (default), `json`, `markdown` (a GitHub job summary or PR comment)
|
|
149
|
+
| `--format <name>` | Output format: `human` (default), `json`, `markdown` (a GitHub job summary or PR comment), `junit` (XML for CI test reports) or `github` (the human report, then an annotation for each failure and warning, for a GitHub Actions step) |
|
|
149
150
|
| `--json` | Same as `--format json` |
|
|
150
151
|
| `-o`, `--output-file <path>` | Write the `--format` report to a file (replaced atomically, keeping its mode and following symlinks, with parent folders created; a FIFO, `/dev/stdout` or `/dev/fd/N` is written in place); the human report still prints. For a path that starts with `-`, write `-o=<path>` or `./<path>` |
|
|
151
152
|
| `--timeout <ms>` | Kill a probe after this long (default 15000, at most 2147483647, about 24 days); a command still running then is judged on what it did so far |
|
|
@@ -229,6 +230,15 @@ A failed check exits 1, so the step fails. Warnings don't fail it unless you add
|
|
|
229
230
|
run: npx --yes cliprobe@1 --format markdown --output-file "$GITHUB_STEP_SUMMARY" -- node ./dist/cli.js
|
|
230
231
|
```
|
|
231
232
|
|
|
233
|
+
To see each finding on the workflow run and on the pull request's checks, without opening the log, use `--format github`. It prints the human report, then a GitHub annotation for every result that needs attention: an error for a `FAIL` or could-not-run (and for a `WARN` under `--strict`), a warning for a `WARN`, and a notice for a finding the [config file accepts](#accepted-findings).
|
|
234
|
+
|
|
235
|
+
```yaml
|
|
236
|
+
- name: Check the CLI for terminal-edge bugs
|
|
237
|
+
run: npx --yes "cliprobe@^1.9" --format github -- node ./dist/cli.js
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The report quotes the program under test, and GitHub reads a workflow command from any log line that starts with `::`. So cliprobe prints the report with command processing stopped (`::stop-commands::`) behind a random token, and escapes every annotation onto one line: a program can't use cliprobe's output to forge an annotation or run another workflow command.
|
|
241
|
+
|
|
232
242
|
With a [config file](#config-file) in the repository, the step needs no probes of its own; ask for 1.8 or later, the first version that reads it:
|
|
233
243
|
|
|
234
244
|
```yaml
|
|
@@ -290,7 +300,7 @@ From 1.0, cliprobe follows semantic versioning, and these hold for every 1.x rel
|
|
|
290
300
|
- **Names and exit codes.** Check names, verdicts, options, config file keys and exit codes stay as they are.
|
|
291
301
|
- **`--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.
|
|
292
302
|
- **JSON.** `schemaVersion` stays `1`. Fields are only added, never removed, renamed or given a new type.
|
|
293
|
-
- **Not covered.** The wording of `reason` and `evidence`, and the human and
|
|
303
|
+
- **Not covered.** The wording of `reason` and `evidence`, and the human, Markdown and `github` output, are for people and may change. Match on `check` and `verdict`, not on text.
|
|
294
304
|
|
|
295
305
|
## Checks
|
|
296
306
|
|
|
@@ -327,7 +337,7 @@ cliprobe runs the command twice: once normally, then with stdout set to `/dev/fu
|
|
|
327
337
|
| `WARN` | Exited 0 though its output was lost, crashed with a stack trace, or hung |
|
|
328
338
|
| `SKIP` | Wrote nothing to stdout for this invocation (or before the timeout), or the system has no `/dev/full` (macOS) |
|
|
329
339
|
|
|
330
|
-
The check is new in 1.7 and only warns
|
|
340
|
+
The check is new in 1.7 and only warns. The December 2026 census shows why it should stay that way for now: of the 157 `--help` and `--version` runs of the top 100 npm commands that print something, 138 warned. 119 exited 0 with their output lost, among them esbuild, eslint, prettier and `tsc`, and 19 crashed with a stack trace; only 19, such as pnpm and uuid, reported the error and exited non-zero. Every one checked by hand was real (`esbuild --version > /dev/full; echo $?` prints 0), so the warning is true, but a check that most tools would fail is not one to gate a build on yet. It runs on Linux only, since macOS has no `/dev/full`; run it in CI on a Linux runner, or in a container.
|
|
331
341
|
|
|
332
342
|
### color
|
|
333
343
|
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import { execFile, execFileSync, spawn } from "node:child_process";
|
|
|
4
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
|
+
import { randomUUID } from "node:crypto";
|
|
7
8
|
import { chmod, mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
8
9
|
// src/core/interrupt.ts
|
|
9
10
|
const cleanups = /* @__PURE__ */ new Set();
|
|
@@ -2560,6 +2561,54 @@ function formatHuman({ version, command, checks, strict, results }, { color }) {
|
|
|
2560
2561
|
lines.push("", summaryLine(countVerdicts(results), strict, countAccepted(results)));
|
|
2561
2562
|
return lines.join("\n") + "\n";
|
|
2562
2563
|
}
|
|
2564
|
+
// src/report/github.ts
|
|
2565
|
+
/** The text of a workflow command: GitHub reads `%0A` back as a line break. */
|
|
2566
|
+
const commandData = (text) => text.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
|
|
2567
|
+
/** A workflow command's property value, where `:` and `,` also end something. */
|
|
2568
|
+
const commandProperty = (text) => commandData(text).replaceAll(":", "%3A").replaceAll(",", "%2C");
|
|
2569
|
+
/**
|
|
2570
|
+
* The annotation level for a result, if it gets one: an error for what fails
|
|
2571
|
+
* the step (a failure, could-not-run, a warning under --strict), a warning for
|
|
2572
|
+
* other warnings, and a notice for a finding the config file accepts.
|
|
2573
|
+
*/
|
|
2574
|
+
function annotationLevel(r, strict) {
|
|
2575
|
+
if (r.verdict === "error") return "error";
|
|
2576
|
+
if (r.verdict !== "fail" && r.verdict !== "warn") return null;
|
|
2577
|
+
if (r.accepted) return "notice";
|
|
2578
|
+
return r.verdict === "fail" || strict ? "error" : "warning";
|
|
2579
|
+
}
|
|
2580
|
+
function annotation(r, strict) {
|
|
2581
|
+
const level = annotationLevel(r, strict);
|
|
2582
|
+
if (level === null) return null;
|
|
2583
|
+
const title = `cliprobe ${r.check}: ${safe(shellJoin(r.invocation))}`;
|
|
2584
|
+
const lines = [
|
|
2585
|
+
safe(r.reason),
|
|
2586
|
+
...r.evidence ? [showEvidence(r.evidence)] : [],
|
|
2587
|
+
...r.accepted ? [`accepted: ${safe(r.accepted.reason)}`] : []
|
|
2588
|
+
];
|
|
2589
|
+
return `::${level} title=${commandProperty(title)}::${commandData(lines.join("\n"))}`;
|
|
2590
|
+
}
|
|
2591
|
+
/**
|
|
2592
|
+
* For a GitHub Actions step: the human report for the log, then one workflow
|
|
2593
|
+
* command per finding, which GitHub shows as an annotation on the run and on the
|
|
2594
|
+
* pull request's checks.
|
|
2595
|
+
*
|
|
2596
|
+
* The report quotes the program under test, and GitHub reads a workflow command
|
|
2597
|
+
* from any log line that starts with `::`, even an indented one. So the report
|
|
2598
|
+
* is printed with command processing stopped, behind a token made after the
|
|
2599
|
+
* program ran, which it therefore can't know and can't use to switch it back on.
|
|
2600
|
+
*/
|
|
2601
|
+
function formatGithub(report) {
|
|
2602
|
+
const token = randomUUID();
|
|
2603
|
+
const annotations = report.results.map((r) => annotation(r, report.strict)).filter((line) => line !== null);
|
|
2604
|
+
return [
|
|
2605
|
+
`::stop-commands::${token}`,
|
|
2606
|
+
formatHuman(report, { color: false }).trimEnd(),
|
|
2607
|
+
`::${token}::`,
|
|
2608
|
+
...annotations,
|
|
2609
|
+
""
|
|
2610
|
+
].join("\n");
|
|
2611
|
+
}
|
|
2563
2612
|
/**
|
|
2564
2613
|
* The report as JSON. Each result keeps the fields every check shares at the top
|
|
2565
2614
|
* and moves the check's own measurements into `details`.
|
|
@@ -2687,7 +2736,8 @@ const FORMAT_NAMES = [
|
|
|
2687
2736
|
"human",
|
|
2688
2737
|
"json",
|
|
2689
2738
|
"markdown",
|
|
2690
|
-
"junit"
|
|
2739
|
+
"junit",
|
|
2740
|
+
"github"
|
|
2691
2741
|
];
|
|
2692
2742
|
function isFormat(name) {
|
|
2693
2743
|
return FORMAT_NAMES.includes(name);
|
|
@@ -2697,7 +2747,8 @@ const FORMATS = {
|
|
|
2697
2747
|
human: formatHuman,
|
|
2698
2748
|
json: formatJson,
|
|
2699
2749
|
markdown: formatMarkdown,
|
|
2700
|
-
junit: formatJunit
|
|
2750
|
+
junit: formatJunit,
|
|
2751
|
+
github: formatGithub
|
|
2701
2752
|
};
|
|
2702
2753
|
// src/report/write.ts
|
|
2703
2754
|
/** Why a report can't be written to a path, in words for the person who gave it. */
|
|
@@ -3159,7 +3210,9 @@ Options:
|
|
|
3159
3210
|
--skip <name> Leave this check out; repeat it or use commas for several
|
|
3160
3211
|
--strict Exit 1 on a warning too, not only on a failure
|
|
3161
3212
|
--format <name> Output format: human (default), json, markdown (a CI job
|
|
3162
|
-
summary or PR comment)
|
|
3213
|
+
summary or PR comment), junit (XML for CI test reports)
|
|
3214
|
+
or github (the human report, then an annotation for each
|
|
3215
|
+
failure and warning, for a GitHub Actions step)
|
|
3163
3216
|
--json Same as --format json
|
|
3164
3217
|
-o, --output-file <path>
|
|
3165
3218
|
Write the --format report to a file (replaced atomically,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cliprobe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
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": {
|