@kaynooo/cli-guard 0.14.4 → 0.14.7
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/dist/cli.js +38 -9
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -2700,6 +2700,33 @@ function printsTrackedEnv(program, args) {
|
|
|
2700
2700
|
return rest.some((arg) => GIT_PATCH_FLAGS.has(arg));
|
|
2701
2701
|
return !rest.some((arg) => GIT_NO_PATCH.has(arg));
|
|
2702
2702
|
}
|
|
2703
|
+
var REDIRECT = /^(\d*|&)(>>|>&|>|<)(.*)$/;
|
|
2704
|
+
var BARE_REDIRECT = /^(?:\d*|&)(?:>>|>&|>|<)$/;
|
|
2705
|
+
var FD = /^\d$/;
|
|
2706
|
+
function withoutRedirects(words) {
|
|
2707
|
+
return words.filter((word, at) => !REDIRECT.test(word) && !BARE_REDIRECT.test(words[at - 1] ?? ""));
|
|
2708
|
+
}
|
|
2709
|
+
function resolveTarget(operator, to, target) {
|
|
2710
|
+
if (operator === ">&" && FD.test(to))
|
|
2711
|
+
return target[to] ?? "other";
|
|
2712
|
+
return to === "-" ? "/dev/null" : to;
|
|
2713
|
+
}
|
|
2714
|
+
function discardsStdout(words) {
|
|
2715
|
+
const target = { 1: "tty", 2: "tty" };
|
|
2716
|
+
for (let at = 0;at < words.length; at++) {
|
|
2717
|
+
const match = REDIRECT.exec(words[at] ?? "");
|
|
2718
|
+
if (match === null || match[2] === "<")
|
|
2719
|
+
continue;
|
|
2720
|
+
const [, fd = "", operator, written] = match;
|
|
2721
|
+
const to = written === "" ? words[++at] ?? "" : written;
|
|
2722
|
+
const resolved = resolveTarget(operator, to, target);
|
|
2723
|
+
if (fd === "&" || operator === ">&" && fd === "" && !FD.test(to))
|
|
2724
|
+
target[1] = target[2] = resolved;
|
|
2725
|
+
else
|
|
2726
|
+
target[fd === "" ? 1 : fd] = resolved;
|
|
2727
|
+
}
|
|
2728
|
+
return target[1] === "/dev/null";
|
|
2729
|
+
}
|
|
2703
2730
|
|
|
2704
2731
|
// ../env/src/mask.ts
|
|
2705
2732
|
var PLAIN_VALUE = /^(?:true|false|null|none|nil|yes|no|on|off|undefined)$/i;
|
|
@@ -2769,7 +2796,7 @@ var TEMPLATE = /\.(?:example|sample|template|dist|defaults)$/;
|
|
|
2769
2796
|
var SKIPPED = ignoredFolders([".git", ".kay"]);
|
|
2770
2797
|
|
|
2771
2798
|
// ../env/src/guard-paths.ts
|
|
2772
|
-
var
|
|
2799
|
+
var REDIRECT2 = /^\d*[<>]+&?/;
|
|
2773
2800
|
var ENVRC = ".envrc";
|
|
2774
2801
|
var PROC_ENVIRON = /^\/proc\/[^/]+\/environ$/;
|
|
2775
2802
|
var ENV_SAMPLES = [".env", ".env.local", ".env.production", ".envrc"];
|
|
@@ -2810,7 +2837,7 @@ function reachesEnvFile(path) {
|
|
|
2810
2837
|
return braceExpand(path).some((each) => isEnvFile(each) || globReachesEnv(each));
|
|
2811
2838
|
}
|
|
2812
2839
|
function targetOf(word) {
|
|
2813
|
-
const bare = word.replace(
|
|
2840
|
+
const bare = word.replace(REDIRECT2, "");
|
|
2814
2841
|
return bare.includes("=") ? bare.slice(bare.indexOf("=") + 1) : bare;
|
|
2815
2842
|
}
|
|
2816
2843
|
function namesEnvFile(word, previous, isGlob) {
|
|
@@ -3068,8 +3095,9 @@ function touchingPieces(command, options = {}) {
|
|
|
3068
3095
|
const { program, args } = parseCommand(piece.command);
|
|
3069
3096
|
if (readsEnv(piece, variables) || searchesEnv(program, args) || runnerReadsListedEnv(pieces, index, variables) || loopReadsListedEnv(pieces, index, variables))
|
|
3070
3097
|
return true;
|
|
3071
|
-
const
|
|
3072
|
-
|
|
3098
|
+
const operands = withoutRedirects(args);
|
|
3099
|
+
const isDump = dumpsContainerEnv(program, operands) || dumpsEnvironment(program, operands, tokenize(piece.command)) || options.hasTrackedEnv === true && printsTrackedEnv(program, operands);
|
|
3100
|
+
if (!isDump || discardsStdout(tokenize(piece.command)))
|
|
3073
3101
|
return false;
|
|
3074
3102
|
for (let at = index;pieces[at]?.separator === "|"; at++) {
|
|
3075
3103
|
const next = parseCommand(pieces[at + 1]?.command ?? "");
|
|
@@ -3415,8 +3443,8 @@ function mismatchFor(request, pinned) {
|
|
|
3415
3443
|
}
|
|
3416
3444
|
|
|
3417
3445
|
// ../pkg/src/added.ts
|
|
3418
|
-
var
|
|
3419
|
-
var
|
|
3446
|
+
var REDIRECT3 = /^\d*[<>]/;
|
|
3447
|
+
var BARE_REDIRECT2 = /^\d*(?:[<>]|>>)$/;
|
|
3420
3448
|
var ADDS = {
|
|
3421
3449
|
bun: new Set(["add", "a", "install", "i"]),
|
|
3422
3450
|
npm: new Set([...NPM_INSTALLS, ...NPM_TEST_INSTALLS, "add"]),
|
|
@@ -3489,7 +3517,7 @@ function piecePackages(program, sub, args, rest) {
|
|
|
3489
3517
|
return rest.flatMap((word, index) => isSkipped(word, rest[index - 1] ?? "", program) ? [] : registryName(word));
|
|
3490
3518
|
}
|
|
3491
3519
|
function isSkipped(word, previous, program = "") {
|
|
3492
|
-
return word.startsWith("-") ||
|
|
3520
|
+
return word.startsWith("-") || REDIRECT3.test(word) || VALUE_FLAGS2.has(previous) || OWN_VALUE_FLAGS[program]?.has(previous) === true || BARE_REDIRECT2.test(previous);
|
|
3493
3521
|
}
|
|
3494
3522
|
function registryName(word) {
|
|
3495
3523
|
const at = word.indexOf("@", 1);
|
|
@@ -4743,7 +4771,7 @@ function checkPath(path) {
|
|
|
4743
4771
|
|
|
4744
4772
|
// src/bins.ts
|
|
4745
4773
|
var BINS = {
|
|
4746
|
-
check: "`check`: runs the repo's check, typecheck, lint and test steps (package.json, composer.json and PHP tool configs, a Justfile, a Makefile) and prints only what failed, each full log saved to a file; a step runs inside the running compose service that mounts its folder (`--in <service>`, `--host`), never starting one; validate a change with it rather than chaining the scripts or `docker compose exec` by hand (`--only lint,test`, `--list`, `--slot`, `--failed` to re-run what failed last); `check --fix` runs its fixers and formatters instead (its fix, lint:fix and format scripts, php-cs-fixer, just fmt, go fmt, cargo fmt, ruff) and lists the files they changed.",
|
|
4774
|
+
check: "`check`: runs the repo's check, typecheck, lint, fmt:check and test steps (package.json, composer.json and PHP tool configs, a Justfile, a Makefile) and prints only what failed, each full log saved to a file; a step runs inside the running compose service that mounts its folder (`--in <service>`, `--host`), never starting one; validate a change with it rather than chaining the scripts or `docker compose exec` by hand (`--only lint,test`, `--list`, `--slot`, `--failed` to re-run what failed last); `check --fix` runs its fixers and formatters instead (its fix, lint:fix and fmt or format scripts, php-cs-fixer, just fmt, go fmt, cargo fmt, ruff) and lists the files they changed.",
|
|
4747
4775
|
errs: "`errs [log]`, `errs -- <cmd>`: turns tsc, tsgo, eslint, bun check, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer output into one `file:line:col: message (rule)` line per error, counting the lines it did not recognise (`--json`); use it instead of reading raw type, lint or test logs.",
|
|
4748
4776
|
db: '`db "<sql>"`: one read-only statement against the Postgres, MySQL or MariaDB in DATABASE_URL (`-e KEY` for another) or, without one, the compose project\'s running database service (`-s <service>`, `-c <container>` for any container, `-d <database>`), credentials never shown; a write runs on a database whose name ends in `_test` and is printed for the user to run otherwise; `db tables`, `db describe <table>`, `db dbs`; use it instead of `docker exec <container> psql` or `mysql`.',
|
|
4749
4777
|
ev: "`ev`: .env files read and edited with values masked (`ev list`, `ev get KEY`, `ev grep <regex>`, `ev show <rev>:<file>`, `ev set`, `ev diff`, `ev missing`); `ev audit [dir]` finds env files others can read or git tracks, and compose files writing secrets out; `ev pins [dir]` lists the env vars reaching outside that the tests of an app leave unpinned; `ev redact` masks secrets in piped output, `<cmd> | ev redact`.",
|
|
@@ -4758,7 +4786,7 @@ var BINS = {
|
|
|
4758
4786
|
gb: "`gb [branch]`: switches to a branch, a remote one getting its tracking branch, `gb -c <name>` creating one; without a terminal it lists the branches (`--json`), with how each stands against its upstream and whether it is merged.",
|
|
4759
4787
|
gf: "`gf [--repos] [dir]...`: fetches with prune and fast-forwards the branch onto its upstream, saying what came in; a diverged branch or a tree the fast-forward would overwrite is refused untouched, `--no-pull` fetches only; use it instead of `git pull` and a git fetch per nested repository.",
|
|
4760
4788
|
gm: "`gm [branch]`: merges the branch into the current one, saying fast-forward or merge commit, the commits and the files that came in; a conflict lists every conflicted file with its conflict regions and exits 1, `--dry-run` tries the merge without touching the tree, `--continue`/`--abort`, `--squash`; with no branch it picks one, or lists each with its verdict off a terminal; use it instead of git merge then git diff and reading conflict markers.",
|
|
4761
|
-
gcl: "`gcl <repo> [dir]`: clones a URL, scp address or owner/name
|
|
4789
|
+
gcl: "`gcl <repo> [dir]`: clones a URL, scp address or owner/name (over ssh first) into ./<name> and prints the path, an existing clone being fetched instead; use it instead of git clone with the folder typed out.",
|
|
4762
4790
|
gd: "`gd [path]...`: the tracked changes per file with added and removed lines, staged apart from unstaged, the patch of the paths given, `--staged`, `--ref <rev>`; use it instead of `git diff --stat` then `git diff <path>`.",
|
|
4763
4791
|
gu: "`gu <path>...`: discards the unstaged changes of the paths after saving them as a patch, `--staged` unstages, `--commit` undoes the last unpushed commit keeping its changes staged; use it instead of git restore and git reset.",
|
|
4764
4792
|
waitfor: "`waitfor --file <log> --until <regex> [--fail <regex>]`, `--port <n>`, `--url <url>`, `--pid <n>` (`-t 5m`): waits until the line shows, the port listens, the URL answers 2xx or the process exits, exits 1 on a --fail line with the lines around it, 2 on a timeout with the last lines; `waitfor task <id>` waits for a background Bash task and prints its exit code, last lines and failure lines; use it instead of sleep and tail, `until ! pgrep -f` or polling loops.",
|
|
@@ -4768,6 +4796,7 @@ var BINS = {
|
|
|
4768
4796
|
doctor: "`doctor`: checks this host's @kaynooo/cli-* install, one line per check with its fix: each bin's version against the registry, tea's login, the Claude Code hooks, the Bun floor (`--json`); run it when a bin lacks a command or a flag its docs name.",
|
|
4769
4797
|
cli: "`cli list`: every @kaynooo/cli-* bin in one line, what it does and what it is reached for instead of, read from each bin's own --help (`--json` adds the synopsis and examples); run it to find the bin that fits a task.",
|
|
4770
4798
|
dl: "`dl <url>`: downloads into a new folder and prints the path, size, final URL and sha256, with the diff of a text file since its last download; `--sha256 <hex>` or `--sums <url>` checks it, `-x` extracts, `--bin [name]` installs into ~/.local/bin, `--exec --sha256 <sha>` runs a script exactly as read, `dl ls` lists what it installed or ran; use it instead of `curl | sh`, `curl -LO` and `sha256sum -c`.",
|
|
4799
|
+
page: "`page check <file|url>...`: shoots each page full-page at 1440 and 400px (`-w`) in a local Chromium, prints the PNG paths, then one `<target> <width>px <kind> <selector>: <measure>` line per defect: sideways overflow, console errors, failed requests, text in a fallback font (naming the one drawn), tap targets under 44px on phones and 24px elsewhere, text touching its box edge, broken images, layout shift over 0.1; `page diff <mockup> <built>` writes a side-by-side and a pixel-diff PNG per width with the differing regions boxed and listed; use it instead of judging screenshots by eye or a one-off Playwright script; it never starts the app.",
|
|
4771
4800
|
out: "`out -- <cmd>`: folds long output, keeping the errors and saving the full log; run noisy builds, installs, tests and linters through it.",
|
|
4772
4801
|
changelog: "`changelog --dry`: the release notes since the last tag, grouped from the conventional commits, without publishing them; `changelog` publishes them as the Forgejo release of the tag at HEAD, `changelog undo [tag]` takes a release back."
|
|
4773
4802
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-guard",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.7",
|
|
5
5
|
"description": "guard: the safety rules a Claude Code Bash call is held to (git, remote machines, SQL writes, env files, package managers, commit messages), each refusal naming the route.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@kaynooo/cli-db": "0.13.4",
|
|
40
|
-
"@kaynooo/cli-edit": "0.11.
|
|
41
|
-
"@kaynooo/cli-env": "0.15.
|
|
42
|
-
"@kaynooo/cli-git": "0.
|
|
43
|
-
"@kaynooo/cli-kit": "0.46.
|
|
40
|
+
"@kaynooo/cli-edit": "0.11.5",
|
|
41
|
+
"@kaynooo/cli-env": "0.15.3",
|
|
42
|
+
"@kaynooo/cli-git": "0.19.0",
|
|
43
|
+
"@kaynooo/cli-kit": "0.46.4",
|
|
44
44
|
"@kaynooo/cli-out": "0.14.8",
|
|
45
|
-
"@kaynooo/cli-pkg": "0.
|
|
45
|
+
"@kaynooo/cli-pkg": "0.18.0"
|
|
46
46
|
}
|
|
47
47
|
}
|