@kaynooo/cli-base 0.0.0-stage → 0.4.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 +21 -0
- package/README.md +31 -2
- package/dist/cli.js +948 -0
- package/dist/proof.js +999 -0
- package/package.json +41 -4
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,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# base
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Runs a command at HEAD or another ref for Claude Code, where a session would otherwise reach for `git stash` to see whether a test fails without its change: `base` checks the ref out in a temporary worktree, runs the command there and removes it, the working tree untouched.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
bun install -g @kaynooo/cli-base
|
|
7
|
+
base --keep tests/NewTest.php -- vendor/bin/phpunit tests/NewTest.php
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Behaviour
|
|
11
|
+
|
|
12
|
+
- The ref is HEAD unless `--ref <rev>` names another commit; the command runs in the caller's folder of the worktree, `api/` in `api/`.
|
|
13
|
+
- `--keep <path>` (repeatable) copies a working-tree file or folder over, such as the new test of a red-then-green check; a path missing or outside the repository is refused before anything is created.
|
|
14
|
+
- The env files (`.env.local`, `.env.test.local`), `node_modules`, `vendor` and `.venv` the checkout has but git ignores are symlinked into the worktree, at any depth, so the run finds its dependencies and settings; `--no-link` leaves them out. Other ignored files (build output, caches) are not, so the ref's own are rebuilt; `--keep` copies one a run needs.
|
|
15
|
+
- The worktree is removed afterwards, on failure and on SIGINT, SIGTERM or SIGHUP too (passed on to the command), its links unlinked first so nothing is deleted through them.
|
|
16
|
+
- One argument holding spaces runs through `sh -c`: `base -- 'bun test a.test.ts | tail -5'`.
|
|
17
|
+
- A command run through `docker compose exec|run` or `docker exec` is refused: the container mounts the main checkout, not the temporary worktree, so it would not run at the ref.
|
|
18
|
+
- The exit code is the command's; a last stderr line says which ref ran, `base: ran at HEAD (1a2b3c4), exit 1`.
|
|
19
|
+
- Exit codes of its own: 2 a usage error, an unknown ref or a refused command, 127 a command that cannot start.
|
|
20
|
+
|
|
21
|
+
## proof
|
|
22
|
+
|
|
23
|
+
`proof` shows that a test fails before a change and passes after it, the check `base` makes by hand: it runs the command at HEAD (or `--ref <rev>`) in the same temporary worktree as `base`, then in the working tree, both captured.
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
proof --keep tests/NewTest.php -- vendor/bin/phpunit tests/NewTest.php
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- `--ref`, `--keep`, `--no-link` and the single spaced argument through `sh -c` behave as in `base`.
|
|
30
|
+
- Four outcomes, each printed as one line followed by the output of the side that explains it: `fails at 1a2b3c4, passes now` (the proof, exit 0, the output before), `passes at 1a2b3c4 too: it does not fail without the change`, `fails at 1a2b3c4 and fails now too` (the output now) and `passes at 1a2b3c4, fails now` (the output now), all three exit 1.
|
|
31
|
+
- `--json` prints `{outcome, proved, ref, sha, before: {code, output}, now: {code, output}}`, `outcome` being `proved`, `passes-before`, `fails-both` or `regressed`.
|
|
32
|
+
- Exit codes: 0 fails before and passes now, 1 any other outcome, 2 a usage error, an unknown ref, a refused command or one that cannot start.
|