@kaynooo/cli-env 0.0.0-stage → 0.8.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kaynooo <contact@kaynooo.fr>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,48 @@
1
- # Temporary Holding Version
1
+ # ev and redact
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Two CLIs that keep secrets out of a Claude Code transcript: `ev` lists and edits `.env` files with every secret masked, and `redact` masks secrets in any piped output.
4
+
5
+ ```sh
6
+ bun install -g @kaynooo/cli-env
7
+ ```
8
+
9
+ ## ev
10
+
11
+ | Command | What it does |
12
+ | --- | --- |
13
+ | `ev list [file]` | every key of the folder's `.env*` files (or one file), secrets masked |
14
+ | `ev get KEY [file]` | one key's masked value, from every file that sets it or from one |
15
+ | `ev grep [-i] <regex> [file...]` | the keys matching the regex (matched against the key, never the value), values masked |
16
+ | `ev show <rev>:<file>` | an env file as a git revision holds it, values masked |
17
+ | `ev set KEY [file]` | sets a key in `.env` (or the file), the value read from stdin or `-F <file>` so it never appears in a command line, `--empty` for an empty value |
18
+ | `ev unset KEY [file]` | removes a key |
19
+ | `ev cp KEY --from <file> --to <file>` | copies a key's value to another file without printing it, replacing the key there or appending it, `--as NEWKEY` to rename |
20
+ | `ev mv KEY --from <file> --to <file>` | moves a key's line as written, `--force` to replace one the target has |
21
+ | `ev diff <a> <b>` | names the keys set in one file and not the other, exit 1 when they differ |
22
+ | `ev missing [file]` | names the keys of `.env.example` (`--against`) that the file lacks, exit 1 when some are |
23
+ | `ev pins [dir]` | checks an app's tests pin the env that reaches outside: lists the optional URL, key, token, secret, password and host variables of its `defineEnv` schema that no `.env.test` entry, test `overrideEnv` or local bunfig preload dropping what `.env` sets pins, and each test file calling `testSite` or `proxyKeyTests` without pinning them (`// ev pins: none reached, <why>` exempts one), names only, exit 1 when something is unpinned |
24
+ | `ev audit [dir...]` | lists the `.env` files any account can read or git tracks, and the compose files any account can read that write a secret or URL password out, with the fix for each, exit 1 when it finds one |
25
+ | `ev audit --fix [dir...]` | moves each secret a listed compose file writes out into the `.env` beside it as `${KEY}` (a key the `.env` sets to another value stays put), puts it back when `docker compose config` resolves differently, and shuts other accounts out of both files and of every listed `.env`; exit 1 when something is left |
26
+
27
+ A value is masked when its key is named like a secret (`TOKEN`, `SECRET`, `PASSWORD`, `PASS`, `PWD`, `KEY`, `PRIVATE`, `DSN`, `AUTH`, `SALT`, `COOKIE`, `CREDENTIALS`, the definition `isSecretName` of `@kaynooo/cli-kit` that `db` shares), when it equals a secret value of the folder's `.env*` files whatever its own key, when it is a private key (PEM or PGP, also escaped on one line), or in the password part of any URL (`postgres://user:***@host/db`) and any known token format (GitHub, GitLab, Slack, AWS, npm, Stripe, Google, SendGrid, `sk-`, JWTs, `Authorization` credentials and `password=`/`secret=` pairs). A URL is also masked where it carries a token, whatever its key is named: the last segment of a Discord, Slack, Uptime Kuma push or healthchecks.io ping URL, any path segment of 20 or more characters of `A-Za-z0-9_-` mixing lowercase, uppercase and digits, any path segment of 32 or more letters and digits of any case (hex, base32, dashless UUIDs), and the value of a query parameter named `token`, `key`, `apikey`, `secret`, `password`, `sig`, `signature`, `auth` or ending in `_token` or `_secret`; the host and the rest of the URL stay readable. A masked value keeps a few leading characters and its length (`ghp***(40)`) so two values can be told apart. There is no flag that prints a secret unmasked.
28
+
29
+ Files are parsed and written back preserving comments, order, `export KEY=` prefixes, quoting and multiline values; only the lines a command touches change.
30
+
31
+ ## redact
32
+
33
+ ```sh
34
+ some-command 2>&1 | redact
35
+ git diff --cached | redact --check
36
+ ```
37
+
38
+ `redact` copies stdin to stdout line by line, masking:
39
+
40
+ - known token formats: `ghp_`, `github_pat_`, `glpat-`, `sk-`, `xox?-`, JWTs and the body of PEM private key blocks
41
+ - the password and the tokens of any URL (webhook and push URLs, opaque path segments, token query parameters)
42
+ - the values of secret-looking keys in the `.env*` files of the current folder and the folders below it (whole words only, from 4 characters, also in their percent-encoded and JSON-escaped forms), `--no-env` skips them
43
+
44
+ `redact --check` prints nothing of the input: it lists `<file>:<line>: <kind>` for each secret found and exits 1. On a diff it reads the added lines only and names the new file's line numbers.
45
+
46
+ ## The parser and the guard
47
+
48
+ `import { parseDotenv, entries } from '@kaynooo/cli-env/dotenv'` gives the dotenv parser ev reads with: quotes, `export` prefixes, comments and multiline values. `src/guard.ts` holds the env file rules the `guard` bin of `@kaynooo/cli-guard` runs, exported to it as `./guard` within the workspace only.