@kaynooo/cli-check 0.20.0 → 0.21.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 CHANGED
@@ -1,6 +1,6 @@
1
- # check and fix
1
+ # check
2
2
 
3
- `check` runs a repo's validation and `check --fix` its fixers, both showing only what failed, so a Claude Code session spends no tokens on passing output. `fix` stays installed as the alias of `check --fix`: same options, output and exit codes.
3
+ `check` runs a repo's validation and `check --fix` its fixers, both showing only what failed, so a Claude Code session spends no tokens on passing output.
4
4
 
5
5
  ```sh
6
6
  bun install -g @kaynooo/cli-check
@@ -12,7 +12,7 @@ check --no-slot # run the steps at once; by default each queues behind the mach
12
12
  check --in app # run every step in this compose service, whatever is detected
13
13
  check --failed # run again only the steps that failed in this folder's last run
14
14
  check --quiet # print only the failing steps, nothing when all pass
15
- check --fix # run the fixers instead, what `fix` does
15
+ check --fix # run the fixers and formatters instead
16
16
  check --host # run on the host even when a compose service mounts the folder
17
17
  check --json # [{name, command, in?, ok, ms, log, failed?}] once every step ran
18
18
  ```
@@ -37,7 +37,7 @@ A folder with no step of its own but subfolders that have some (a root with `api
37
37
 
38
38
  ## In the compose service
39
39
 
40
- Athome repos run their tools in a container, so `check`, `fix` and `errs -- <command>` run a step inside the docker compose service that bind-mounts its folder, instead of on the host. The project is the nearest `compose.yaml`, `compose.yml`, `docker-compose.yaml` or `docker-compose.yml` from the step's folder up to the repository root (the folder holding `.git`), with its `compose.override.*` merged in. A service qualifies when one of its bind mounts (`.:/app`, `./api:/var/www/html`, the long `type: bind` syntax, `${VAR:-default}` interpolated with the environment and the project's `.env`) holds the folder, a mount of a parent folder included; named volumes are ignored. The step runs `docker compose exec -T -w <path of the folder in the container> <service> sh -c '<command>'` from the project's folder, with `NO_COLOR=1 FORCE_COLOR=0` set, and the container path is the mount's target plus the folder's path under its source.
40
+ In a repo that runs its tools in a container, `check`, `check --fix` and `errs -- <command>` run a step inside the docker compose service that bind-mounts its folder, instead of on the host. The project is the nearest `compose.yaml`, `compose.yml`, `docker-compose.yaml` or `docker-compose.yml` from the step's folder up to the repository root (the folder holding `.git`), with its `compose.override.*` merged in. A service qualifies when one of its bind mounts (`.:/app`, `./api:/var/www/html`, the long `type: bind` syntax, `${VAR:-default}` interpolated with the environment and the project's `.env`) holds the folder, a mount of a parent folder included; named volumes are ignored. The step runs `docker compose exec -T -w <path of the folder in the container> <service> sh -c '<command>'` from the project's folder, with `NO_COLOR=1 FORCE_COLOR=0` set, and the container path is the mount's target plus the folder's path under its source.
41
41
 
42
42
  - The stack is only read: `docker compose ps --services --status running` is asked once per project, and a service that is down is never started. The step fails, naming the service and where its project lives, and the other steps go on; start the stack yourself, or pass `--host`.
43
43
  - Several services mounting the folder (php and a worker): the one whose name, image or build names the step's tool wins (`bun` and `node` look for `bun` or `node`, `composer`, `php`, `phpunit`, `phpstan` and `vendor/bin/*` for `php`). When none or several stand out the call fails listing them and asks for `--in <service>`.
@@ -48,7 +48,7 @@ Athome repos run their tools in a container, so `check`, `fix` and `errs -- <com
48
48
  - A compose file that does not parse fails the call naming the file and the parse error, and points at `--host`; it never falls back to the host silently, even without docker.
49
49
  - The slot queue (the default when `slot` is installed, `--slot` to require it) holds the whole docker command. `--timeout` ends the `docker compose exec` client, which does not always end what it started inside the container.
50
50
  - `check --changed` (`-c`) narrows `lint` to the changed source files (staged, unstaged and untracked, against HEAD) when its script is a bare `keslint`, `eslint` or `oxlint`, and `test` to the changed test files and the tests next to changed sources (same folder, `tests/`, `../tests/`) when its script is a bare `bun test`. Every other step runs in full and its line says so, a test step finding no test for the diff included. The typecheck is never narrowed.
51
- - `fix` runs the project's scripts and `php-cs-fixer` in the service, and keeps its own formatters (`justfile`, `go`, `rust`, `python`, `makefile`) on the host. The recursion guard variable is passed into the container.
51
+ - `check --fix` runs the project's scripts and `php-cs-fixer` in the service, and keeps its own formatters (`justfile`, `go`, `rust`, `python`, `makefile`) on the host. The recursion guard variable is passed into the container.
52
52
 
53
53
  ## Output
54
54
 
@@ -60,16 +60,16 @@ Exit code 0 when every step passed, 1 when one failed, 2 on bad usage, when no s
60
60
 
61
61
  `--failed` reads the last finished run's folder of logs, where each run leaves a `results.json` of its steps' names and results, and runs the steps that failed there again. When that run had none, or there was no run, it says so and exits 2. The re-run leaves its own `results.json`.
62
62
 
63
- ## fix
63
+ ## check --fix
64
64
 
65
- `fix` is `check --fix`: `check --fix --only lint:fix` is the same call. `--only` then names fixers, and `--changed`, `--failed`, `--slot`, `--no-slot` and `--parallel` are refused.
65
+ `--only` then names fixers, and `--changed`, `--failed`, `--slot`, `--no-slot` and `--parallel` are refused.
66
66
 
67
67
  ```sh
68
- fix # run every fixer that applies to this folder
69
- fix --list # print them and their commands
70
- fix --only lint:fix,justfile
71
- fix --in app # run the scripts in this compose service; --host forces the host
72
- fix --json # {fixers, changed}, a skipped fixer as {name, command, skipped}
68
+ check --fix # run every fixer that applies to this folder
69
+ check --fix --list # print them and their commands
70
+ check --fix --only lint:fix,justfile
71
+ check --fix --in app # run the scripts in this compose service; --host forces the host
72
+ check --fix --json # {fixers, changed}, a skipped fixer as {name, command, skipped}
73
73
  ```
74
74
 
75
75
  The project's own `fix` script, recipe or target when it has one, else its `lint:fix` (or `lint-fix`) and `format` ones, found in the same sources as `check`'s steps. Then the formatters the folder's files call for:
@@ -83,7 +83,7 @@ The project's own `fix` script, recipe or target when it has one, else its `lint
83
83
  | `rust` | `Cargo.toml` | `cargo fmt` |
84
84
  | `python` | `ruff.toml`, `.ruff.toml` or a `[tool.ruff]` section | `ruff check --fix . && ruff format .` |
85
85
 
86
- It looks at the folder itself only, so each package of a monorepo gets its own run. A fixer whose binary is missing is skipped with a `skip` line. Lines and logs read like `check`'s, then the files the run changed are listed, leaving out those already dirty before it, when the folder is in a git repository. A script that calls `fix` again fails instead of recursing.
86
+ It looks at the folder itself only, so each package of a monorepo gets its own run. A fixer whose binary is missing is skipped with a `skip` line. Lines and logs read like `check`'s, then the files the run changed are listed, leaving out those already dirty before it, when the folder is in a git repository. A script calling `check` is skipped, and one reaching `check --fix` again some other way fails instead of recursing.
87
87
 
88
88
  Exit code 0 when every fixer ran, 1 when one failed, 2 on bad usage or when nothing applies.
89
89
 
package/dist/cli.js CHANGED
@@ -616,7 +616,7 @@ class Completing {
616
616
  }
617
617
  var completion = { active: false };
618
618
  var OUTPUT_OPTIONS = {
619
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
619
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
620
620
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
621
621
  };
622
622
  function applyOutput(color, plain, env = process10.env) {
@@ -944,6 +944,66 @@ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs
944
944
  import { dirname as dirname3, join as join6 } from "path";
945
945
  import process16 from "process";
946
946
 
947
+ // ../kit/src/completions.ts
948
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
949
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
950
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
951
+ set -l current (commandline -ct)
952
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
953
+ if test "$line" = __files__
954
+ __fish_complete_path $current
955
+ else
956
+ echo $line
957
+ end
958
+ end
959
+ end`;
960
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
961
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
962
+ local -a lines
963
+ COMPREPLY=()
964
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
965
+ for line in "\${lines[@]}"; do
966
+ if [[ $line == __files__ ]]; then
967
+ COMPREPLY+=($(compgen -f -- "$cur"))
968
+ else
969
+ words+="\${line%%$'\\t'*}"$'\\n'
970
+ fi
971
+ done
972
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
973
+ }`;
974
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
975
+ local line
976
+ local -a described plain
977
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
978
+ if [[ $line == __files__ ]]; then
979
+ _files
980
+ elif [[ $line == *$'\\t'* ]]; then
981
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
982
+ else
983
+ plain+=("$line")
984
+ fi
985
+ done
986
+ (( \${#described} )) && _describe -V value described
987
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
988
+ return 0
989
+ }`;
990
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
991
+ if (shell === "fish")
992
+ return `${header}
993
+ ${FISH_FUNCTION}
994
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
995
+ `).join("")}`;
996
+ if (shell === "bash")
997
+ return `${header}
998
+ ${BASH_FUNCTION}
999
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1000
+ `;
1001
+ return `${header}
1002
+ ${ZSH_FUNCTION}
1003
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1004
+ `;
1005
+ }
1006
+
947
1007
  // ../kit/src/notify.ts
948
1008
  import process13 from "process";
949
1009
  var NOTIFY_AFTER_MS = 1e4;
@@ -1061,7 +1121,11 @@ var LEVEL_OPTIONS = {
1061
1121
  ...OUTPUT_OPTIONS,
1062
1122
  help: { type: "boolean", short: "h", description: "show this help" }
1063
1123
  };
1064
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1124
+ var TOP_OPTIONS = {
1125
+ ...LEVEL_OPTIONS,
1126
+ version: { type: "boolean", short: "v", description: "print the version" },
1127
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1128
+ };
1065
1129
  function printError(prefix, message, hint, cause) {
1066
1130
  const colors = paint(process16.stderr);
1067
1131
  const styled = takesControlCodes(process16.stderr);
@@ -1141,6 +1205,19 @@ async function leafCandidates(run, words) {
1141
1205
  const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1142
1206
  return values === undefined ? [FILES] : values.map(candidateLine);
1143
1207
  }
1208
+ var COMPLETIONS = "--completions";
1209
+ function flagValue([flag = "", ...rest]) {
1210
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1211
+ }
1212
+ function printCompletionScript(name, args) {
1213
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1214
+ if (shell === undefined || args.length !== 1) {
1215
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1216
+ return 2;
1217
+ }
1218
+ console.log(completionScript(shell, [name]).trimEnd());
1219
+ return 0;
1220
+ }
1144
1221
  async function printCandidates(found) {
1145
1222
  for (const line of await found)
1146
1223
  console.log(line);
@@ -1164,6 +1241,8 @@ function packageVersion(entry = Bun.main) {
1164
1241
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1165
1242
  if (argv[0] === COMPLETE)
1166
1243
  return printCandidates(leafCandidates(run, argv.slice(1)));
1244
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1245
+ return printCompletionScript(name, flagValue(argv));
1167
1246
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1168
1247
  console.log(version ?? packageVersion());
1169
1248
  return 0;
@@ -1358,7 +1437,7 @@ var {Glob } = globalThis.Bun;
1358
1437
  var SESSION_FILES = new Glob("*.json");
1359
1438
  var ACCOUNT_DIRS = new Glob("*/sessions");
1360
1439
  // package.json
1361
- var version = "0.20.0";
1440
+ var version = "0.21.0";
1362
1441
 
1363
1442
  // src/check.ts
1364
1443
  import { writeFile as writeFile3 } from "fs/promises";
@@ -1865,16 +1944,13 @@ async function discover(dir) {
1865
1944
  }
1866
1945
 
1867
1946
  // src/options.ts
1868
- var fixOptions = {
1947
+ var options = {
1869
1948
  list: { type: "boolean", short: "l", description: "print the steps (or, with --fix, the fixers) found, the commands that run them and where (host or service), without running them" },
1870
- only: { type: "string", short: "o", description: `comma separated steps to run, among ${STEP_NAMES.join(", ")}; with --fix the fixers to run, by the names --list prints` },
1949
+ only: { type: "string", short: "o", description: `comma separated steps to run, among ${STEP_NAMES.join(", ")}; with --fix the fixers to run, by the names --list prints`, candidates: () => [...STEP_NAMES] },
1871
1950
  timeout: { type: "string", short: "t", description: "longest a step or fixer may run before it is ended (30s, 5m, 1h), none by default" },
1872
1951
  ...placeOptions,
1873
- json: jsonOption()
1874
- };
1875
- var options = {
1876
- ...fixOptions,
1877
- fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps, as the fix bin does" },
1952
+ json: jsonOption(),
1953
+ fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps" },
1878
1954
  quiet: { type: "boolean", short: "q", description: "print nothing for a passing step, and nothing at all when every step passes" },
1879
1955
  failed: { type: "boolean", description: "run only the steps that failed in the last run of this folder, read from the run folder" },
1880
1956
  changed: { type: "boolean", short: "c", description: "narrow lint and test to the files changed against HEAD (a bare linter script, a bare bun test script), every other step runs in full and says so" },
@@ -1974,15 +2050,6 @@ function printOutcome(name, width, command, logFile, outcome) {
1974
2050
  }
1975
2051
 
1976
2052
  // src/fix.ts
1977
- var fixUsage = `fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
1978
-
1979
- Alias of \`check --fix\`. Runs the folder's fixers: the project's own \`fix\` script, else its \`lint:fix\` and \`format\` ones (package.json through bun run, composer.json, a Justfile or a Makefile), then the formatters its files call for: php-cs-fixer where configured and composer.json has no fixer, just --fmt, go fmt and go mod tidy, cargo fmt, ruff where configured, and every Makefile target declared .PHONY.
1980
- It looks at the folder itself only, so each package of a monorepo gets its own run.
1981
- A script or php-cs-fixer runs inside the docker compose service that bind-mounts the folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path; a service that is down is never started, the fixer fails naming it. The formatters run on the host. --in picks the service, --host forces the host.
1982
- Prints one line per fixer, what a failing one said, then the files the run changed. Each fixer's full output is saved to the file whose path ends its line.
1983
- A fixer still running after --timeout is ended with everything it started, but not what it started inside a container.
1984
- --json prints {fixers: [{name, command, in?, ok, ms, log, failed?} or {name, command, skipped}], changed} once every fixer ran, changed null outside a git repository.`;
1985
- var EXITS = [[0, "every fixer ran or was skipped for a missing binary"], [1, "one failed"], [2, "bad usage, nothing applies or a fixer timed out"]];
1986
2053
  var RUNNING = "KAYNOOO_CLI_FIX";
1987
2054
  var JUSTFILES2 = ["justfile", "Justfile", ".justfile"];
1988
2055
  var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
@@ -1994,7 +2061,7 @@ async function replaceFile(path, content) {
1994
2061
  await rename(temporary, path);
1995
2062
  }
1996
2063
  async function projectFixers(dir) {
1997
- const found = await candidates(dir, "fix");
2064
+ const found = await candidates(dir, "check");
1998
2065
  const named = (name) => found.find((step) => step.name === name);
1999
2066
  const all = named("fix");
2000
2067
  if (all !== undefined)
@@ -2061,15 +2128,11 @@ function printChanged(changed) {
2061
2128
  if (changed.length > MAX_CHANGED)
2062
2129
  console.log(` and ${changed.length - MAX_CHANGED} more`);
2063
2130
  }
2064
- async function fix(args, cwd = process21.cwd()) {
2065
- const parsed = parse(args, fixUsage, fixOptions, { exits: EXITS, replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
2066
- return runFixers(parsed.values, cwd);
2067
- }
2068
2131
  async function runFixers(values, cwd) {
2069
2132
  const parsed = { values };
2070
2133
  const settings = placeSettings(values);
2071
2134
  if (process21.env[RUNNING] !== undefined)
2072
- fail("a fixer called fix again, which would recurse: give its script another command");
2135
+ fail("a fixer called check --fix again, which would recurse: give its script another command");
2073
2136
  const found = await fixers(cwd);
2074
2137
  if (found.length === 0)
2075
2138
  fail("nothing to fix here: no fix, lint:fix or format script, php-cs-fixer config, Makefile, Justfile, go.mod, Cargo.toml nor ruff config");
@@ -2222,9 +2285,9 @@ With --parallel, the steps run at the same time, each one's output held and prin
2222
2285
  With --quiet, passing steps print nothing, and a fully passing run prints nothing at all: only the failing steps and the closing summary of a run that failed.
2223
2286
  A step still running after --timeout is ended with everything it started, but not what it started inside a container.
2224
2287
  With --failed, only the steps that failed in the last run of this folder run again, read from that run's folder of logs; when no last run failed, it says so and exits 2.
2225
- With --fix, the folder's fixers and formatters run instead of the steps, exactly as the \`fix\` bin does (it is the alias of \`check --fix\`): its own scripts, php-cs-fixer, just --fmt, go fmt, cargo fmt, ruff and the Makefile's .PHONY targets, then the files the run changed are listed. --only then names fixers, as --list prints them; --changed, --failed, --slot, --no-slot and --parallel do not apply.
2226
- --json prints [{name, command, in?, ok, ms, log, failed?}] once every step ran, --list --json [{name, command, source, in?}], in the compose service the step ran in; with --fix the shape \`fix --json\` prints.`;
2227
- var EXITS2 = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
2288
+ With --fix, the folder's fixers and formatters run instead of the steps: the project's own \`fix\` script, else its \`lint:fix\` and \`format\` ones, from the same sources as the steps, then the formatters its files call for: php-cs-fixer where configured and composer.json has no fixer, just --fmt, go fmt and go mod tidy, cargo fmt, ruff where configured, and every Makefile target declared .PHONY. The scripts and php-cs-fixer run in the compose service, the formatters on the host. One line per fixer, then the files the run changed. --only then names fixers, as --list prints them; --changed, --failed, --slot, --no-slot and --parallel do not apply.
2289
+ --json prints [{name, command, in?, ok, ms, log, failed?}] once every step ran, --list --json [{name, command, source, in?}], in the compose service the step ran in; with --fix {fixers: [{name, command, in?, ok, ms, log, failed?} or {name, command, skipped}], changed}, changed null outside a git repository.`;
2290
+ var EXITS = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
2228
2291
  function slotted(command) {
2229
2292
  return `slot -- sh -c ${shellQuote(command)}`;
2230
2293
  }
@@ -2260,7 +2323,7 @@ function summaryLine(outcomes) {
2260
2323
  return parts.join(colors.dim(" \xB7 "));
2261
2324
  }
2262
2325
  async function check(args, cwd = process22.cwd()) {
2263
- const parsed = parse(args, usage2, options, { exits: EXITS2, replaces: "chaining docker compose exec <service> bun run check | tail, lint and test by hand, or bun run check && bun run lint && bun run test read through tail", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"]] });
2326
+ const parsed = parse(args, usage2, options, { exits: EXITS, replaces: "chaining docker compose exec <service> bun run check | tail, lint and test by hand, or bun run check && bun run lint && bun run test read through tail, and with --fix each fixer and formatter run by hand", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"], ["check --fix", "the fixers and formatters instead"], ["check --fix --list", "the fixers it would run"]] });
2264
2327
  const settings = placeSettings(parsed.values);
2265
2328
  if (parsed.values.fix === true) {
2266
2329
  for (const flag of ["changed", "failed", "slot", "no-slot", "parallel"]) {
package/dist/errs-cli.js CHANGED
@@ -616,7 +616,7 @@ class Completing {
616
616
  }
617
617
  var completion = { active: false };
618
618
  var OUTPUT_OPTIONS = {
619
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
619
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
620
620
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
621
621
  };
622
622
  function applyOutput(color, plain, env = process10.env) {
@@ -944,6 +944,66 @@ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs
944
944
  import { dirname as dirname3, join as join6 } from "path";
945
945
  import process16 from "process";
946
946
 
947
+ // ../kit/src/completions.ts
948
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
949
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
950
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
951
+ set -l current (commandline -ct)
952
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
953
+ if test "$line" = __files__
954
+ __fish_complete_path $current
955
+ else
956
+ echo $line
957
+ end
958
+ end
959
+ end`;
960
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
961
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
962
+ local -a lines
963
+ COMPREPLY=()
964
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
965
+ for line in "\${lines[@]}"; do
966
+ if [[ $line == __files__ ]]; then
967
+ COMPREPLY+=($(compgen -f -- "$cur"))
968
+ else
969
+ words+="\${line%%$'\\t'*}"$'\\n'
970
+ fi
971
+ done
972
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
973
+ }`;
974
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
975
+ local line
976
+ local -a described plain
977
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
978
+ if [[ $line == __files__ ]]; then
979
+ _files
980
+ elif [[ $line == *$'\\t'* ]]; then
981
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
982
+ else
983
+ plain+=("$line")
984
+ fi
985
+ done
986
+ (( \${#described} )) && _describe -V value described
987
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
988
+ return 0
989
+ }`;
990
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
991
+ if (shell === "fish")
992
+ return `${header}
993
+ ${FISH_FUNCTION}
994
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
995
+ `).join("")}`;
996
+ if (shell === "bash")
997
+ return `${header}
998
+ ${BASH_FUNCTION}
999
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1000
+ `;
1001
+ return `${header}
1002
+ ${ZSH_FUNCTION}
1003
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1004
+ `;
1005
+ }
1006
+
947
1007
  // ../kit/src/notify.ts
948
1008
  import process13 from "process";
949
1009
  var NOTIFY_AFTER_MS = 1e4;
@@ -1061,7 +1121,11 @@ var LEVEL_OPTIONS = {
1061
1121
  ...OUTPUT_OPTIONS,
1062
1122
  help: { type: "boolean", short: "h", description: "show this help" }
1063
1123
  };
1064
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1124
+ var TOP_OPTIONS = {
1125
+ ...LEVEL_OPTIONS,
1126
+ version: { type: "boolean", short: "v", description: "print the version" },
1127
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1128
+ };
1065
1129
  function printError(prefix, message, hint, cause) {
1066
1130
  const colors = paint(process16.stderr);
1067
1131
  const styled = takesControlCodes(process16.stderr);
@@ -1141,6 +1205,19 @@ async function leafCandidates(run, words) {
1141
1205
  const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1142
1206
  return values === undefined ? [FILES] : values.map(candidateLine);
1143
1207
  }
1208
+ var COMPLETIONS = "--completions";
1209
+ function flagValue([flag = "", ...rest]) {
1210
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1211
+ }
1212
+ function printCompletionScript(name, args) {
1213
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1214
+ if (shell === undefined || args.length !== 1) {
1215
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1216
+ return 2;
1217
+ }
1218
+ console.log(completionScript(shell, [name]).trimEnd());
1219
+ return 0;
1220
+ }
1144
1221
  async function printCandidates(found) {
1145
1222
  for (const line of await found)
1146
1223
  console.log(line);
@@ -1164,6 +1241,8 @@ function packageVersion(entry = Bun.main) {
1164
1241
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1165
1242
  if (argv[0] === COMPLETE)
1166
1243
  return printCandidates(leafCandidates(run, argv.slice(1)));
1244
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1245
+ return printCompletionScript(name, flagValue(argv));
1167
1246
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1168
1247
  console.log(version ?? packageVersion());
1169
1248
  return 0;
@@ -1358,7 +1437,7 @@ var {Glob } = globalThis.Bun;
1358
1437
  var SESSION_FILES = new Glob("*.json");
1359
1438
  var ACCOUNT_DIRS = new Glob("*/sessions");
1360
1439
  // package.json
1361
- var version = "0.20.0";
1440
+ var version = "0.21.0";
1362
1441
 
1363
1442
  // src/errs.ts
1364
1443
  import { relative as relative2 } from "path";
package/dist/j-cli.js CHANGED
@@ -616,7 +616,7 @@ class Completing {
616
616
  }
617
617
  var completion = { active: false };
618
618
  var OUTPUT_OPTIONS = {
619
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
619
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
620
620
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
621
621
  };
622
622
  function applyOutput(color, plain, env = process10.env) {
@@ -944,6 +944,66 @@ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs
944
944
  import { dirname as dirname3, join as join6 } from "path";
945
945
  import process16 from "process";
946
946
 
947
+ // ../kit/src/completions.ts
948
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
949
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
950
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
951
+ set -l current (commandline -ct)
952
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
953
+ if test "$line" = __files__
954
+ __fish_complete_path $current
955
+ else
956
+ echo $line
957
+ end
958
+ end
959
+ end`;
960
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
961
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
962
+ local -a lines
963
+ COMPREPLY=()
964
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
965
+ for line in "\${lines[@]}"; do
966
+ if [[ $line == __files__ ]]; then
967
+ COMPREPLY+=($(compgen -f -- "$cur"))
968
+ else
969
+ words+="\${line%%$'\\t'*}"$'\\n'
970
+ fi
971
+ done
972
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
973
+ }`;
974
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
975
+ local line
976
+ local -a described plain
977
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
978
+ if [[ $line == __files__ ]]; then
979
+ _files
980
+ elif [[ $line == *$'\\t'* ]]; then
981
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
982
+ else
983
+ plain+=("$line")
984
+ fi
985
+ done
986
+ (( \${#described} )) && _describe -V value described
987
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
988
+ return 0
989
+ }`;
990
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
991
+ if (shell === "fish")
992
+ return `${header}
993
+ ${FISH_FUNCTION}
994
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
995
+ `).join("")}`;
996
+ if (shell === "bash")
997
+ return `${header}
998
+ ${BASH_FUNCTION}
999
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1000
+ `;
1001
+ return `${header}
1002
+ ${ZSH_FUNCTION}
1003
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1004
+ `;
1005
+ }
1006
+
947
1007
  // ../kit/src/notify.ts
948
1008
  import process13 from "process";
949
1009
  var NOTIFY_AFTER_MS = 1e4;
@@ -1061,7 +1121,11 @@ var LEVEL_OPTIONS = {
1061
1121
  ...OUTPUT_OPTIONS,
1062
1122
  help: { type: "boolean", short: "h", description: "show this help" }
1063
1123
  };
1064
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1124
+ var TOP_OPTIONS = {
1125
+ ...LEVEL_OPTIONS,
1126
+ version: { type: "boolean", short: "v", description: "print the version" },
1127
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1128
+ };
1065
1129
  function printError(prefix, message, hint, cause) {
1066
1130
  const colors = paint(process16.stderr);
1067
1131
  const styled = takesControlCodes(process16.stderr);
@@ -1141,6 +1205,19 @@ async function leafCandidates(run, words) {
1141
1205
  const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1142
1206
  return values === undefined ? [FILES] : values.map(candidateLine);
1143
1207
  }
1208
+ var COMPLETIONS = "--completions";
1209
+ function flagValue([flag = "", ...rest]) {
1210
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1211
+ }
1212
+ function printCompletionScript(name, args) {
1213
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1214
+ if (shell === undefined || args.length !== 1) {
1215
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1216
+ return 2;
1217
+ }
1218
+ console.log(completionScript(shell, [name]).trimEnd());
1219
+ return 0;
1220
+ }
1144
1221
  async function printCandidates(found) {
1145
1222
  for (const line of await found)
1146
1223
  console.log(line);
@@ -1164,6 +1241,8 @@ function packageVersion(entry = Bun.main) {
1164
1241
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1165
1242
  if (argv[0] === COMPLETE)
1166
1243
  return printCandidates(leafCandidates(run, argv.slice(1)));
1244
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1245
+ return printCompletionScript(name, flagValue(argv));
1167
1246
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1168
1247
  console.log(version ?? packageVersion());
1169
1248
  return 0;
@@ -1358,7 +1437,7 @@ var {Glob } = globalThis.Bun;
1358
1437
  var SESSION_FILES = new Glob("*.json");
1359
1438
  var ACCOUNT_DIRS = new Glob("*/sessions");
1360
1439
  // package.json
1361
- var version = "0.20.0";
1440
+ var version = "0.21.0";
1362
1441
 
1363
1442
  // src/j.ts
1364
1443
  import process25 from "process";
@@ -2954,7 +3033,7 @@ function names(found) {
2954
3033
  return same.length === 1 ? [[name, described(same[0])]] : [[name, same.map((entry) => entry.tag).join(", ")], ...same.map((entry) => [id(entry), described(entry)])];
2955
3034
  });
2956
3035
  }
2957
- function completions() {
3036
+ function completions2() {
2958
3037
  try {
2959
3038
  return [...names(everything()), ["-", "the last one again, with its arguments"]];
2960
3039
  } catch {
@@ -3011,7 +3090,7 @@ async function j2(argv) {
3011
3090
  const parsed = last ? { values: {}, positionals: ["-"], rest: args.slice(1) } : parse(args, usage2, options, {
3012
3091
  exits: EXITS,
3013
3092
  positionals: ["[name]"],
3014
- candidates: { "[name]": completions },
3093
+ candidates: { "[name]": completions2 },
3015
3094
  trailing: true,
3016
3095
  replaces: "reading the Justfile, Makefile, package.json scripts or composer scripts to find what to run, then retyping it",
3017
3096
  examples: ["j", ["j test", "run the test recipe, script or task"], ["j api/test --watch", "a child folder's, with an argument"], ["j just:check", "the one of a runner, when several share the name"], ["j -", "the last one again"]]
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-check",
3
3
  "type": "module",
4
- "version": "0.20.0",
5
- "description": "check, fix and errs: run a repo's check, typecheck, lint and test steps or its fixers, inside its docker compose service when one mounts the folder, showing only what failed with each full output saved to a file, and turn tsc, eslint, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer logs into file:line:col errors.",
4
+ "version": "0.21.0",
5
+ "description": "check and errs: run a repo's check, typecheck, lint and test steps or, with --fix, its fixers, inside its docker compose service when one mounts the folder, showing only what failed with each full output saved to a file, and turn tsc, eslint, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer logs into file:line:col errors.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
8
- "homepage": "https://git.kaynooo.fr/kaynooo/cli/src/branch/main/packages/check#readme",
8
+ "homepage": "https://github.com/Kayno0o/cli/tree/main/packages/check#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://git.kaynooo.fr/kaynooo/cli.git",
11
+ "url": "git+https://github.com/Kayno0o/cli.git",
12
12
  "directory": "packages/check"
13
13
  },
14
- "bugs": "https://git.kaynooo.fr/kaynooo/cli/issues",
14
+ "bugs": "https://github.com/Kayno0o/cli/issues",
15
15
  "keywords": ["check", "fix", "lint", "format", "typecheck", "test", "claude-code"],
16
16
  "bin": {
17
17
  "check": "./dist/cli.js",
18
- "fix": "./dist/fix-cli.js",
19
18
  "errs": "./dist/errs-cli.js",
20
19
  "j": "./dist/j-cli.js"
21
20
  },
@@ -27,13 +26,12 @@
27
26
  "registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
28
27
  },
29
28
  "scripts": {
30
- "build": "$npm_execpath build src/cli.ts src/fix-cli.ts src/errs-cli.ts src/j-cli.ts --target bun --outdir dist",
29
+ "build": "$npm_execpath build src/cli.ts src/errs-cli.ts src/j-cli.ts --target bun --outdir dist",
31
30
  "check": "$npm_execpath src/cli.ts",
32
- "fix": "$npm_execpath src/fix-cli.ts",
33
31
  "errs": "$npm_execpath src/errs-cli.ts",
34
32
  "j": "$npm_execpath src/j-cli.ts"
35
33
  },
36
34
  "devDependencies": {
37
- "@kaynooo/cli-kit": "0.39.0"
35
+ "@kaynooo/cli-kit": "0.41.0"
38
36
  }
39
37
  }