@krysoworks/kryso 0.0.2 → 2.0.0-rc.1
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 +146 -6
- package/bin/kryso +31 -0
- package/bin/ship-it-status +14 -0
- package/bin/ship-ledger +14 -0
- package/bin/ship-loop +14 -0
- package/bin/ship-pass +14 -0
- package/bin/warden +14 -0
- package/dist/answer.d.ts +38 -0
- package/dist/answer.js +48 -0
- package/dist/bytes.d.ts +5 -0
- package/dist/bytes.js +35 -0
- package/dist/cleanup.d.ts +1 -0
- package/dist/cleanup.js +629 -0
- package/dist/commands.d.ts +48 -0
- package/dist/commands.js +293 -0
- package/dist/completions.d.ts +24 -0
- package/dist/completions.js +239 -0
- package/dist/daemon.d.ts +15 -0
- package/dist/daemon.js +23 -0
- package/dist/diagnose.d.ts +47 -0
- package/dist/diagnose.js +314 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +241 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.js +17 -0
- package/dist/evidence.d.ts +39 -0
- package/dist/evidence.js +327 -0
- package/dist/home.d.ts +3 -0
- package/dist/home.js +27 -0
- package/dist/install.d.ts +59 -0
- package/dist/install.js +137 -0
- package/dist/isolate.d.ts +28 -0
- package/dist/isolate.js +402 -0
- package/dist/leftovers.d.ts +5 -0
- package/dist/leftovers.js +156 -0
- package/dist/machine.d.ts +6 -0
- package/dist/machine.js +185 -0
- package/dist/palette.d.ts +147 -0
- package/dist/palette.js +167 -0
- package/dist/plan.d.ts +1 -0
- package/dist/plan.js +133 -0
- package/dist/proc.d.ts +23 -0
- package/dist/proc.js +23 -0
- package/dist/read.d.ts +1 -0
- package/dist/read.js +297 -0
- package/dist/readiness.d.ts +5 -0
- package/dist/readiness.js +64 -0
- package/dist/remote.d.ts +6 -0
- package/dist/remote.js +85 -0
- package/dist/self-update.d.ts +1 -0
- package/dist/self-update.js +224 -0
- package/dist/semver.d.ts +7 -0
- package/dist/semver.js +42 -0
- package/dist/style.d.ts +71 -0
- package/dist/style.js +187 -0
- package/dist/update.d.ts +47 -0
- package/dist/update.js +190 -0
- package/dist/work.d.ts +25 -0
- package/dist/work.js +449 -0
- package/dist/workflows.d.ts +4 -0
- package/dist/workflows.js +73 -0
- package/docker/entrypoint.sh +44 -0
- package/docker/runner.Dockerfile +39 -0
- package/package.json +55 -22
- package/scripts/install-skills.sh +607 -0
- package/skills/code-review/SKILL.md +231 -0
- package/skills/kryso/SKILL.md +107 -0
- package/skills/kryso/golden/help.rounded.ansi +23 -0
- package/skills/kryso/golden/help.square.ansi +23 -0
- package/skills/kryso/golden/help.txt +23 -0
- package/skills/kryso/golden/table-narrow.json +11 -0
- package/skills/kryso/golden/table-narrow.rounded.ansi +4 -0
- package/skills/kryso/golden/table-narrow.square.ansi +4 -0
- package/skills/kryso/golden/table.ansi +5 -0
- package/skills/kryso/golden/table.json +11 -0
- package/skills/kryso/ledger.sh +2146 -0
- package/skills/kryso/palette.json +57 -0
- package/skills/kryso/reference/resuming.md +30 -0
- package/skills/kryso/reference/routing.md +23 -0
- package/skills/kryso/reference/stage-1-claim.md +79 -0
- package/skills/kryso/reference/stage-2-build.md +133 -0
- package/skills/kryso/reference/stage-3-prove.md +51 -0
- package/skills/kryso/reference/stage-4-pr.md +76 -0
- package/skills/kryso/reference/stage-5-reconcile.md +81 -0
- package/skills/kryso/reference/stage-6-merge-or-park.md +73 -0
- package/skills/kryso/reference/stage-7-close-out.md +62 -0
- package/skills/kryso/reference/terminal.md +7 -0
- package/skills/kryso/ship-it-status.sh +1503 -0
- package/skills/kryso/ui.py +274 -0
- package/skills/kryso/ui.sh +609 -0
- package/skills/kryso-build/SKILL.md +168 -0
- package/skills/kryso-shift/SKILL.md +167 -0
- package/skills/kryso-shift/archive.py +2784 -0
- package/skills/kryso-shift/archive_checker.py +462 -0
- package/skills/kryso-shift/archive_checker_lambda.py +155 -0
- package/skills/kryso-shift/archive_health.py +364 -0
- package/skills/kryso-shift/archive_launchd.py +140 -0
- package/skills/kryso-shift/archive_remote.py +990 -0
- package/skills/kryso-shift/archiving-checker.md +140 -0
- package/skills/kryso-shift/archiving-keep.md +115 -0
- package/skills/kryso-shift/archiving-recovery.md +112 -0
- package/skills/kryso-shift/archiving-remote.md +166 -0
- package/skills/kryso-shift/archiving.md +146 -0
- package/skills/kryso-shift/coverage.schema.json +225 -0
- package/skills/kryso-shift/deadline.sh +254 -0
- package/skills/kryso-shift/feedback.schema.json +35 -0
- package/skills/kryso-shift/feedback.sh +228 -0
- package/skills/kryso-shift/history-manifest.schema.json +331 -0
- package/skills/kryso-shift/keep-after.sh +55 -0
- package/skills/kryso-shift/measure.sh +611 -0
- package/skills/kryso-shift/merge-ready.sh +207 -0
- package/skills/kryso-shift/outcome.schema.json +16 -0
- package/skills/kryso-shift/pass-rules.md +8 -0
- package/skills/kryso-shift/profile.schema.json +42 -0
- package/skills/kryso-shift/reader.sh +692 -0
- package/skills/kryso-shift/reads.sh +151 -0
- package/skills/kryso-shift/reference/allowance.md +21 -0
- package/skills/kryso-shift/reference/driver.md +95 -0
- package/skills/kryso-shift/reference/measuring.md +67 -0
- package/skills/kryso-shift/reference/outputs.md +21 -0
- package/skills/kryso-shift/reference/pass-script.md +115 -0
- package/skills/kryso-shift/reference/reconcile-and-merge.md +55 -0
- package/skills/kryso-shift/reference/second-reader.md +9 -0
- package/skills/kryso-shift/reference/sweeps.md +83 -0
- package/skills/kryso-shift/repair.schema.json +14 -0
- package/skills/kryso-shift/report-template.html +679 -0
- package/skills/kryso-shift/report.py +389 -0
- package/skills/kryso-shift/report_fixture.py +65 -0
- package/skills/kryso-shift/reporting.md +58 -0
- package/skills/kryso-shift/result.sh +91 -0
- package/skills/kryso-shift/runner.sh +1178 -0
- package/skills/kryso-shift/ship-loop.sh +3977 -0
- package/skills/kryso-shift/ship-pass.sh +4987 -0
- package/skills/kryso-shift/steps.jq +19 -0
- package/skills/kryso-shift/workflow.mjs +830 -0
- package/skills/kryso-shift/workflows/default.json +22 -0
- package/skills/kryso-shift/workflows/ralph.json +13 -0
- package/skills/kryso-watch/SKILL.md +100 -0
- package/skills/kryso-watch/answer.schema.json +23 -0
- package/skills/kryso-watch/base-refs.sh +44 -0
- package/skills/kryso-watch/board.sh +58 -0
- package/skills/kryso-watch/reference/config.md +23 -0
- package/skills/kryso-watch/reference/outputs.md +30 -0
- package/skills/kryso-watch/reference/report.md +29 -0
- package/skills/kryso-watch/reference/scheduler.md +32 -0
- package/skills/kryso-watch/reference/settlement.md +29 -0
- package/skills/kryso-watch/reference/shift.md +44 -0
- package/skills/kryso-watch/reference/shim-limits.md +22 -0
- package/skills/kryso-watch/reference/triage.md +26 -0
- package/skills/kryso-watch/schema.jq +40 -0
- package/skills/kryso-watch/settle.schema.json +36 -0
- package/skills/kryso-watch/stage-common.sh +187 -0
- package/skills/kryso-watch/stages/report.sh +525 -0
- package/skills/kryso-watch/stages/settle.sh +722 -0
- package/skills/kryso-watch/stages/shift.sh +466 -0
- package/skills/kryso-watch/stages/triage.sh +379 -0
- package/skills/kryso-watch/tracker.sh +27 -0
- package/skills/kryso-watch/triage.schema.json +77 -0
- package/skills/kryso-watch/warden.launchd.plist +50 -0
- package/skills/kryso-watch/warden.schema.json +98 -0
- package/skills/kryso-watch/warden.sh +1004 -0
- package/bin/kryso.js +0 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 John Valai
|
|
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,13 +1,153 @@
|
|
|
1
1
|
# kryso
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The command for [KrysoWorks](https://github.com/krysoworks/kryso), which works a repository's backlog while you are away: it takes issues from a GitHub tracker to merged or parked pull requests, one fresh model process per issue, and checks the evidence each one leaves instead of trusting its account.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```sh
|
|
6
|
+
npm install -g kryso@next
|
|
7
|
+
kryso skills install # the skills, for Claude Code and Codex
|
|
8
|
+
kryso shift --epic 124 --dry-run
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Until 2.0.0, `kryso` is published as release candidates under npm's `next` tag.
|
|
12
|
+
|
|
13
|
+
`kryso` runs the bash drivers it carries. Most subcommands pass their arguments to one driver unchanged and run it in kryso's own process, so the driver's help, output, signals and exit status are the command's. `remote`, `completions`, `doctor`, `cleanup` and `self-update` run in kryso itself, and `isolate build` runs `docker build`. With a remote set, `status` and `ledger` ask the daemon instead. `kryso --help` lists the subcommands and what each one runs, and `kryso <command> --help` prints its help.
|
|
14
|
+
|
|
15
|
+
The drivers need bash, git, `gh`, `jq` and python3, and a `claude` or `codex` command signed in to your own subscription.
|
|
16
|
+
|
|
17
|
+
## Shell completions
|
|
18
|
+
|
|
19
|
+
`kryso completions bash`, `kryso completions zsh` and `kryso completions fish` print a completion script for that shell. Tab then completes the commands, each command's options and verbs, and the values an option lists, such as `docker` or `none` after `--isolate`. After an option that takes a free value, such as `--base`, the shell completes file names as it would without the script.
|
|
20
|
+
|
|
21
|
+
The script holds no list of its own. At each Tab it asks `kryso completions complete -- <words>`, and kryso reads the words from the command's `--help`. So an option a new version adds completes with the script you already have, and you write the file again only when you move to another shell. The only driver it runs is the command's own help, never the command.
|
|
22
|
+
|
|
23
|
+
Write the script where your shell looks for completions:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
# bash, with bash-completion loaded
|
|
27
|
+
mkdir -p ~/.local/share/bash-completion/completions
|
|
28
|
+
kryso completions bash > ~/.local/share/bash-completion/completions/kryso
|
|
29
|
+
|
|
30
|
+
# zsh: any directory on $fpath that is set before compinit runs
|
|
31
|
+
kryso completions zsh > ~/.zfunc/_kryso # with fpath=(~/.zfunc $fpath) in ~/.zshrc
|
|
32
|
+
|
|
33
|
+
# fish
|
|
34
|
+
kryso completions fish > ~/.config/fish/completions/kryso.fish
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then open a new shell. In bash without bash-completion, add `source <(kryso completions bash)` to `~/.bashrc` instead. In zsh, `source <(kryso completions zsh)` after `compinit` in `~/.zshrc` works too, at the cost of one `kryso` run each time a shell starts.
|
|
38
|
+
|
|
39
|
+
### Add with an agent
|
|
40
|
+
|
|
41
|
+
To let a coding agent add the completion, give it this prompt:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
Add shell completion for the kryso command.
|
|
45
|
+
|
|
46
|
+
1. Run kryso --version. If kryso is not installed, stop and tell me.
|
|
47
|
+
2. Find my shell from $SHELL. If it is not bash, zsh or fish, stop and
|
|
48
|
+
tell me.
|
|
49
|
+
3. Find the file the steps below write. If it exists and its first lines
|
|
50
|
+
do not say it is the kryso completion, stop and tell me.
|
|
51
|
+
4. For bash: if bash-completion is installed, write the output of
|
|
52
|
+
`kryso completions bash` to
|
|
53
|
+
${XDG_DATA_HOME:-~/.local/share}/bash-completion/completions/kryso.
|
|
54
|
+
If it is not installed, add the line
|
|
55
|
+
`source <(kryso completions bash)` to ~/.bashrc, once.
|
|
56
|
+
5. For zsh: find a directory on $fpath that I own and that ~/.zshrc adds
|
|
57
|
+
before the line that runs compinit. If there is none, create ~/.zfunc
|
|
58
|
+
and add `fpath=(~/.zfunc $fpath)` to ~/.zshrc before that line. Write
|
|
59
|
+
the output of `kryso completions zsh` to _kryso in the directory.
|
|
60
|
+
Then remove ~/.zcompdump*, so that compinit reads the new file.
|
|
61
|
+
6. For fish: write the output of `kryso completions fish` to
|
|
62
|
+
~/.config/fish/completions/kryso.fish.
|
|
63
|
+
7. Tell me the file you wrote and each line you added to a startup file.
|
|
64
|
+
Tell me to open a new shell, type `kryso sh` and press Tab, which
|
|
65
|
+
completes `kryso shift`.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## A remote
|
|
69
|
+
|
|
70
|
+
`kryso remote <url>` points the command at a KrysoWorks daemon, and it is the only setting the command keeps, in `${XDG_CONFIG_HOME:-~/.config}/kryso/remote`. `kryso remote` prints it, and `kryso remote --unset` goes back to this machine's evidence, where status and ledger run their scripts exactly as before.
|
|
71
|
+
|
|
72
|
+
While it is set, `kryso status` and `kryso ledger` ask the daemon's API, and what they print differs from the scripts:
|
|
73
|
+
|
|
74
|
+
- `kryso status [repo-path]` and `kryso status --all` take what `ship-it-status.sh` takes, with the path read as the daemon names its repositories. The current directory is the default, as it is for the script. They print one line per repository, naming the shift running there, and a table of its passes in progress with each pass's stage, status, whether it is live, and when its checkpoint last moved. The script's owner sessions, transcripts and pull requests are not shown, because they are on the daemon's machine. `--inspect` reads the ledgers' files, so it is refused with one line, and `--inspect --follow` with it.
|
|
75
|
+
- `kryso ledger read <repository> <pass>` prints a pass's evidence as one JSON document, and `kryso ledger tail <repository> <pass> [--follow]` prints its ledger lines, with an older line in the form it is read as today. Following, it asks again after a refused connection or a failed answer for up to 30 seconds, from the last line it printed, so a daemon restart loses and repeats nothing.
|
|
76
|
+
- The ledger verbs that write run on the machine that runs the pass, so they are refused.
|
|
77
|
+
|
|
78
|
+
`kryso attach` follows the files of a run on this machine, so a remote changes nothing for it.
|
|
79
|
+
|
|
80
|
+
## Doctor
|
|
81
|
+
|
|
82
|
+
`kryso doctor` tells you whether kryso can work here before a shift finds out at two in the morning. It reads this machine and the repository you run it in, prints one line per diagnosis, and changes nothing, so you can run it at any time, a live shift included. It runs even when the drivers are missing, as `kryso self-update` does.
|
|
83
|
+
|
|
84
|
+
Each diagnosis has a severity and says who acts on it. An error means kryso cannot work, a warn that something needs action, and an info is a count or a size. Where one command settles it, the line ends with `Fix:` and that command, ready to paste. Where none does, the line says why. It reports the install, the machine and the work in the repository you run it in. For the install, that is the version and the install kind, a subcommand whose driver file is missing, an installed skill that differs from the copy this kryso carries, which `kryso skills install` brings back in line, and an update, from the check `kryso self-update --check` makes. It reads a checkout's remote with `git ls-remote` and fetches nothing. It also names what the installer left in your home directory: each dated skill backup past the newest five, and each skill copy under a name 2.0.0 retired (`ship-it`, `ship-it-build`, `ship-loop`, `warden`). A retired copy is cleanup's only when no launch agent names its path, no link in `~/bin` or `~/.claude/skills` points into it, and the installer's running-copy check finds no process on it. One that any of these uses is a person's, and the line says which. When the check cannot run, the copy is unknown, and nothing unknown is cleanup's.
|
|
6
85
|
|
|
7
|
-
|
|
86
|
+
For the machine, it names a missing or too old bash, git, gh, jq, python3 or node as an error. The version floors, and what needs each, are in `packages/cli/src/machine.ts`. It always names the first `bash` on PATH, because every driver runs on that one, and it is an error when that bash is too old even where a newer one comes later: a login shell in tmux that puts macOS's bash 3.2 first is caught here. A missing docker, or a missing or too old gum, is an info. A gh login that does not hold is an error. Each model host is checked by the runner's own preflight, so a codex that is not logged in is an error naming `codex login`, a host that is not installed is an info, and having neither is an error. A `kryso-runner` image of another version is an info naming the `docker image rm` that removes it. With docker missing or its daemon down there is no image line.
|
|
87
|
+
|
|
88
|
+
In a repository it lists each worktree under `.claude/worktrees` with what its ledger and its pull request say, so a pass a person merged by hand reads as merged here, though `kryso status`, which reads only open pull requests, calls it interrupted. A merged pass is a warn that `kryso cleanup` settles when the script engine wrote its ledger, and a person's when `/kryso` wrote it, there is none, a live pass holds it or one of its receipts is still open. A pass a resume can continue names `kryso pass <issue> --resume`. A worktree off its ledger's branch, or whose HEAD no longer contains its checkpoint's head, and a receipt no live process can close, are a person's warn. The pass lock files nothing holds are counted by their issue's state, and a watch lock or isolation file whose process has died is named. A local branch is merged when its tip is on origin's default branch, or its pull request merged at that tip, and an integration branch, the current branch and a branch a worktree has checked out are never cleanup's. Ledgers and locks are read through the ledger module, and GitHub through `gh`, read-only. Outside a repository it says so in one line.
|
|
89
|
+
|
|
90
|
+
It judges whether a shift and a watch can start in the repository by their own preflight: it runs `kryso shift --dry-run --read-only` and `kryso watch --dry-run --read-only`, which fetch nothing and change nothing, and each stop line either prints is a person's warn with its exit status. It holds no copy of a preflight rule. It sizes the evidence on disk, the shift folders and the shipped copies under `.claude/kryso` and the three largest logs among them, as infos. Where there is evidence, it says whether it exists anywhere else: it finds the keep configuration through the installed keep launch agent, reads what the remote has verified with `kryso archive status`, which reads the upload queue and not the remote, and reads when the last keep ran from the newest health snapshot in the archive. No keep configuration, no keep that has run, or a snapshot the upload queue has held unverified for more than 24 hours is a person's warn. A shift folder or a shipped copy whose newest file is more than 90 days old is an info with its size: cleanup's under `--evidence` when every file in it is held, byte for byte, by an archive snapshot the upload queue records as verified on the remote, and a person's, kept whole, when one file is not.
|
|
91
|
+
|
|
92
|
+
`--all` reads every repository a session has used, by the rule `kryso status --all` applies (`kryso status --repos` prints that list), and every repository in the watch schedule's list, each once. The machine's diagnoses print first and once, then each repository's under a line that names it. A listed path that no longer exists is one info line.
|
|
93
|
+
|
|
94
|
+
`--json` prints the same diagnoses as one document in the schema at `packages/core/schemas/doctor/1.schema.json`, and nothing else. `--offline` reads no registry, remote or GitHub and runs no dry run, so the update, the gh login, readiness and anything that needs a pull request's or an issue's state are unknown, and nothing unknown is ever cleanup's. In the JSON document, each diagnosis about a repository names it in `repository`.
|
|
95
|
+
|
|
96
|
+
With a remote set (`kryso remote <url>`), a plain run asks the daemon whether it answers and says so in one diagnosis, and `--offline` does not ask. `--remote` asks the daemon for its own machine's diagnoses, for the repositories it serves, and prints them after this machine's under a line that names the remote. Under `--json` it prints both documents, each marked with its machine, in the schema at `packages/core/schemas/doctor-remote/1.schema.json`. A daemon too old to have the doctor route is one diagnosis saying so, and the run exits on this machine's diagnoses. `--remote` with no remote set exits 64, and so does `--remote` with `--offline`.
|
|
97
|
+
|
|
98
|
+
A warn or an error makes it exit non-zero, so a script can gate on it. `kryso doctor --help` lists the exit codes.
|
|
99
|
+
|
|
100
|
+
## Cleanup
|
|
101
|
+
|
|
102
|
+
`kryso cleanup` removes what `kryso doctor` names as cleanup's. It builds the same diagnoses, keeps the ones it can remove, and prints them as a plan: one line per removal with its group, its size and its path, then a total. On a terminal it then asks one yes or no question, and nothing is removed until you answer yes. No removes nothing and exits 0.
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
kryso cleanup --dry-run # print the plan and stop
|
|
106
|
+
kryso cleanup worktrees # only the merged passes' worktrees
|
|
107
|
+
kryso cleanup locks branches # only the stale pass locks and merged branches
|
|
108
|
+
kryso cleanup --all # every repository kryso doctor --all reads
|
|
109
|
+
kryso cleanup backups # only the skill backups past the newest five
|
|
110
|
+
kryso cleanup --keep-backups 2 # keep two backups for this run
|
|
111
|
+
kryso cleanup --force # no question, for a run nobody attends
|
|
112
|
+
kryso cleanup --evidence # evidence too, with a question of its own
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`kryso cleanup --help` lists the groups it removes. Matching a branch's pull request at its tip is how a squash-merged branch is found, and the worktrees group is below. None of the groups is a repository's evidence. Cleanup removes on this machine alone: it has no `--remote`, and the daemon's API has no route that removes anything.
|
|
116
|
+
|
|
117
|
+
Its scope is doctor's: this machine and the repository of the current directory, or with `--all` every repository `kryso doctor --all` reads, the plan grouped under each one's path and one question for all of it. A repository an isolated run holds gets nothing planned, and the plan names the run's pid. A diagnosis whose state is unknown, because `gh` refused a read, is never planned, and the plan names each one it left out with its count.
|
|
118
|
+
|
|
119
|
+
A pass lock file goes through the ledger module's `drop`, which takes the file's lock, removes the file while it holds it, and refuses while a live pass holds it. Cleanup never unlinks one itself, so no removal can hand one issue to two passes, and a ledger module without `drop` leaves every lock file where it is. A branch is deleted at the tip the plan showed and no other, so a commit made on it since keeps it, and so does a worktree that checked it out since. `integration/*`, the default branch, the current branch and a branch a worktree has checked out are never planned, and a branch whose pull request merged at another head is kept, because its tip holds a commit that never merged.
|
|
120
|
+
|
|
121
|
+
A merged pass's worktree goes through the pass's own closeout, never a removal of cleanup's. For each worktree whose pull request merged and whose ledger the script engine wrote, the plan line says that the issue will be closed and the branch deleted on origin, and cleanup runs `kryso pass <issue> --resume` in the repository, one pass at a time. The resume records the merge a person made and runs the closeout a pass runs after its own merge, which copies the evidence out before the worktree goes. Cleanup reads the outcome block the pass prints: shipped with its closeout complete is a removal, and any other outcome is one line with the outcome and its reason. A closeout that stopped part-way is one line with the step it stopped at, and cleanup looks at the disk for what finishes it. While the worktree is there that is the same resume. Once the closeout has removed it, a person finishes the step by hand, and the line names where the evidence was copied. A worktree a live pass holds, or with a receipt still open, is not planned, and neither is one with a `/kryso` ledger or none.
|
|
122
|
+
|
|
123
|
+
`--force` answers the question and relaxes no rule, so a forced run removes exactly what `--dry-run` prints, evidence aside. An answer can take a while, so after a yes it reads everything again and removes only what is still cleanup's: a copy a run started on while the question waited stays, and counts as a removal that failed. `--dry-run` wins over `--force`. With no terminal and no `--force` it prints the plan, says nothing was removed, and exits 64, so a forgotten flag is noticed. A removal that fails, or a closeout that does not finish, is one line with its reason, the others still run, and the run exits 1. A second run straight after plans nothing and exits 0.
|
|
124
|
+
|
|
125
|
+
Evidence is what the run metrics report, `kryso measure` and the evals read, so no group name, `all` included, and no `--force` removes it. Only `--evidence` plans it, and only on a machine whose keep configuration names a remote: the one `--config` names, or the one the keep launch agent names. Without one it refuses in one line and exits 64. It plans each shift folder and shipped copy whose newest file is older than 90 days, or `--older-than N` days for one run, and whose every file is held, byte for byte, by an archive snapshot the upload queue records as verified on the remote. A copy with one file no such archive snapshot holds stays whole, and the plan names it as kept. The evidence question comes after the plan's own, and each answer stands alone. `--force` answers only the plan's, so with evidence planned and no terminal nothing goes: the run says so and exits 64. Cleanup reads the archive through `kryso archive status` and its archive snapshots' manifests, and changes nothing in it, on the remote or in the upload queue.
|
|
126
|
+
|
|
127
|
+
## Updating
|
|
128
|
+
|
|
129
|
+
`kryso self-update` updates kryso the way it was installed. A global package of npm, pnpm or bun is replaced with `<tool> install -g kryso@<channel>` (`add -g` for pnpm and bun) when the registry has a newer version, Homebrew's keg with `brew upgrade kryso`, and a checkout install by fetching its branch's upstream, fast-forwarding to the commit `--check` showed, building it and running its installer again. A branch ahead of its upstream installs its own head, and the output says how many commits ahead it is. After a package update it runs `kryso skills install`, so the installed skills match the new copy. A prerelease follows the `next` channel and a release follows `latest`, and `--channel` picks the other.
|
|
130
|
+
|
|
131
|
+
`kryso self-update --check` prints the install, the version installed and the one available, and exits 1 when there is an update. `--dry-run` prints the commands instead of running them. `kryso --version` names the install kind after the version, from the package's path alone. It starts no program, so it names an npm or pnpm install only as a global package.
|
|
132
|
+
|
|
133
|
+
It changes nothing while a shift, pass or watch runs from the copy it would replace, and exits 75 naming them, through the installer's own running-copy check. A checkout with uncommitted changes, on another branch than the one installed, or diverged from its upstream is refused in one line with the fix, and exits 78. Untracked files are not checked first. The fast-forward stops when an incoming commit adds a path an untracked file holds, and its step names the file. An install it cannot tell exits 78 with the command for each kind. A missing tool exits 69, and a step that fails exits 70 and names the step.
|
|
134
|
+
|
|
135
|
+
## Isolation
|
|
136
|
+
|
|
137
|
+
`kryso shift --isolate docker` and `kryso pass --isolate docker` run the driver inside one `kryso-runner` container instead of on your machine, as [ADR 0051](https://github.com/krysoworks/kryso/blob/main/docs/adr/0051-a-shift-runs-isolated-in-one-container-that-mounts-its-repository-at-the-same-path.md) decides. The flag goes straight after the subcommand. Setting `"isolate": "docker"` in the repository's `.kryso/config.json` turns it on for every run, and `--isolate none` turns it off for one.
|
|
138
|
+
|
|
139
|
+
The container mounts the repository read-write at its own path, so worktrees and ledgers land where they always do. The drivers and your installed skills are mounted read-only. Your home directory, your other checkouts and your shell's exported keys stay out. Only these go in: the `gh` token, your git name and email, one model login, and the `permissions` block of `~/.claude/settings.json`. A custom profile's file, named by `KRYSO_PROFILE_FILE`, is mounted read-only too. The secrets travel in an env file and a copy of the Codex login, which the container deletes from your disk as it starts, so no secret appears on a command line. Docker still hands those values to its daemon, so anyone who can run `docker inspect` on this machine can read them while the container runs.
|
|
140
|
+
|
|
141
|
+
Inside, git pushes over https with the `gh` token, and a remote written as `git@github.com:` is rewritten to https, so no ssh key goes in. The container runs as your uid with `no-new-privileges`, and its `/etc/passwd` and `/etc/group` are read-only files kryso writes, so nothing in it can become root.
|
|
142
|
+
|
|
143
|
+
Set it up once:
|
|
8
144
|
|
|
9
145
|
```sh
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
146
|
+
kryso isolate build # builds kryso-runner:<version> from docker/runner.Dockerfile
|
|
147
|
+
claude setup-token # then save the token it prints:
|
|
148
|
+
mkdir -p ~/.config/kryso && pbpaste > ~/.config/kryso/claude-token && chmod 600 ~/.config/kryso/claude-token
|
|
13
149
|
```
|
|
150
|
+
|
|
151
|
+
A Codex profile needs no token file, because the container gets a copy of `~/.codex/auth.json`. A custom profile takes its host from the profile file. kryso checks Docker, the image, the token and `gh auth token` before it starts anything, and stops with exit 69 if one is missing. A repository whose gate or install runs `xcodebuild` is refused, because that build only runs on the host.
|
|
152
|
+
|
|
153
|
+
An isolated run holds its locks inside Docker Desktop's VM, where the host cannot see them. So kryso writes `kryso-isolated.json` in the repository's git directory with the pid of the docker client. While that client runs, a host shift, pass, `--adopt` or watch on the repository refuses in one line naming the pid, and a second isolated run exits 75. [ADR 0039](https://github.com/krysoworks/kryso/blob/main/docs/adr/0039-isolated-runs-are-guarded-by-a-pid-file-because-kernel-locks-do-not-cross-docker-desktops-vm.md) records why.
|
package/bin/kryso
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# kryso: the KrysoWorks command. dist/plan.js reads the arguments and either answers itself
|
|
3
|
+
# (the help, the version, a usage error) or writes a plan to file descriptor 3: how many of the
|
|
4
|
+
# arguments name the subcommand, then the driver's command line up to the rest of them,
|
|
5
|
+
# shell-quoted. This script then execs the driver with the rest of its own arguments, byte for
|
|
6
|
+
# byte, in this same process, so the driver owns the terminal, every signal and the exit
|
|
7
|
+
# status, as if it had been started by hand. Its own names start __kryso_ and are unset before
|
|
8
|
+
# the exec, so the driver's environment is the caller's. One of the old command names in bin/
|
|
9
|
+
# sets __kryso_as to its name before it runs this, and the planner runs the new subcommand.
|
|
10
|
+
__kryso_p=$0
|
|
11
|
+
while [ -L "$__kryso_p" ]; do
|
|
12
|
+
__kryso_l=$(readlink "$__kryso_p")
|
|
13
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
14
|
+
case $__kryso_l in /*) __kryso_p=$__kryso_l ;; *) __kryso_p=$__kryso_d/$__kryso_l ;; esac
|
|
15
|
+
done
|
|
16
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
17
|
+
command -v node >/dev/null 2>&1 || { echo "kryso: node is not on PATH, and kryso runs on it" >&2; exit 127; }
|
|
18
|
+
# A closed stdout would fail the descriptor moves below before node starts, so it is opened on
|
|
19
|
+
# /dev/null, as node itself does for a closed standard stream. The probe runs in a subshell,
|
|
20
|
+
# because a failed redirection of exec would end this shell.
|
|
21
|
+
( exec 9>&1 ) 2>/dev/null || exec 1>/dev/null
|
|
22
|
+
__kryso_rc=70
|
|
23
|
+
# __kryso_pid is this shell's pid, which the exec below hands to the driver, so the planner can
|
|
24
|
+
# name the process that will run it: its own parent is the command substitution's subshell.
|
|
25
|
+
{ __kryso_plan=$(__kryso_plan_fd=3 __kryso_pid=$$ node "$__kryso_d/../dist/plan.js" "$@" 3>&1 1>&4 4>&-); __kryso_rc=$?; } 4>&1
|
|
26
|
+
[ "$__kryso_rc" -eq 0 ] || exit "$__kryso_rc"
|
|
27
|
+
[ -n "$__kryso_plan" ] || exit 0
|
|
28
|
+
shift "${__kryso_plan%% *}"
|
|
29
|
+
eval "set -- ${__kryso_plan#* } \"\$@\""
|
|
30
|
+
unset __kryso_p __kryso_l __kryso_d __kryso_rc __kryso_plan __kryso_as
|
|
31
|
+
exec "$@"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ship-it-status: what `kryso status` was called before 2.0.0, kept for one release. It runs bin/kryso
|
|
3
|
+
# beside it, which prints one line naming the new form and then runs it. Its own names start
|
|
4
|
+
# __kryso_, so nothing of the caller's is changed.
|
|
5
|
+
__kryso_p=$0
|
|
6
|
+
while [ -L "$__kryso_p" ]; do
|
|
7
|
+
__kryso_l=$(readlink "$__kryso_p")
|
|
8
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
9
|
+
case $__kryso_l in /*) __kryso_p=$__kryso_l ;; *) __kryso_p=$__kryso_d/$__kryso_l ;; esac
|
|
10
|
+
done
|
|
11
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
12
|
+
__kryso_as=ship-it-status
|
|
13
|
+
export __kryso_as
|
|
14
|
+
exec "$__kryso_d/kryso" "$@"
|
package/bin/ship-ledger
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ship-ledger: what `kryso ledger` was called before 2.0.0, kept for one release. It runs bin/kryso
|
|
3
|
+
# beside it, which prints one line naming the new form and then runs it. Its own names start
|
|
4
|
+
# __kryso_, so nothing of the caller's is changed.
|
|
5
|
+
__kryso_p=$0
|
|
6
|
+
while [ -L "$__kryso_p" ]; do
|
|
7
|
+
__kryso_l=$(readlink "$__kryso_p")
|
|
8
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
9
|
+
case $__kryso_l in /*) __kryso_p=$__kryso_l ;; *) __kryso_p=$__kryso_d/$__kryso_l ;; esac
|
|
10
|
+
done
|
|
11
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
12
|
+
__kryso_as=ship-ledger
|
|
13
|
+
export __kryso_as
|
|
14
|
+
exec "$__kryso_d/kryso" "$@"
|
package/bin/ship-loop
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ship-loop: what `kryso shift` was called before 2.0.0, kept for one release. It runs bin/kryso
|
|
3
|
+
# beside it, which prints one line naming the new form and then runs it. Its own names start
|
|
4
|
+
# __kryso_, so nothing of the caller's is changed.
|
|
5
|
+
__kryso_p=$0
|
|
6
|
+
while [ -L "$__kryso_p" ]; do
|
|
7
|
+
__kryso_l=$(readlink "$__kryso_p")
|
|
8
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
9
|
+
case $__kryso_l in /*) __kryso_p=$__kryso_l ;; *) __kryso_p=$__kryso_d/$__kryso_l ;; esac
|
|
10
|
+
done
|
|
11
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
12
|
+
__kryso_as=ship-loop
|
|
13
|
+
export __kryso_as
|
|
14
|
+
exec "$__kryso_d/kryso" "$@"
|
package/bin/ship-pass
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ship-pass: what `kryso pass` was called before 2.0.0, kept for one release. It runs bin/kryso
|
|
3
|
+
# beside it, which prints one line naming the new form and then runs it. Its own names start
|
|
4
|
+
# __kryso_, so nothing of the caller's is changed.
|
|
5
|
+
__kryso_p=$0
|
|
6
|
+
while [ -L "$__kryso_p" ]; do
|
|
7
|
+
__kryso_l=$(readlink "$__kryso_p")
|
|
8
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
9
|
+
case $__kryso_l in /*) __kryso_p=$__kryso_l ;; *) __kryso_p=$__kryso_d/$__kryso_l ;; esac
|
|
10
|
+
done
|
|
11
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
12
|
+
__kryso_as=ship-pass
|
|
13
|
+
export __kryso_as
|
|
14
|
+
exec "$__kryso_d/kryso" "$@"
|
package/bin/warden
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# warden: what `kryso watch` was called before 2.0.0, kept for one release. It runs bin/kryso
|
|
3
|
+
# beside it, which prints one line naming the new form and then runs it. Its own names start
|
|
4
|
+
# __kryso_, so nothing of the caller's is changed.
|
|
5
|
+
__kryso_p=$0
|
|
6
|
+
while [ -L "$__kryso_p" ]; do
|
|
7
|
+
__kryso_l=$(readlink "$__kryso_p")
|
|
8
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
9
|
+
case $__kryso_l in /*) __kryso_p=$__kryso_l ;; *) __kryso_p=$__kryso_d/$__kryso_l ;; esac
|
|
10
|
+
done
|
|
11
|
+
case $__kryso_p in */*) __kryso_d=${__kryso_p%/*} ;; *) __kryso_d=. ;; esac
|
|
12
|
+
__kryso_as=warden
|
|
13
|
+
export __kryso_as
|
|
14
|
+
exec "$__kryso_d/kryso" "$@"
|
package/dist/answer.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Env, type Stream, type Style } from "./style.js";
|
|
2
|
+
/** Output in both layers: the plain text, and how to draw it. With no drawing, the text goes
|
|
3
|
+
* out as it is either way; with no text, the drawing is all there is and a plain run prints
|
|
4
|
+
* nothing. */
|
|
5
|
+
export interface Said {
|
|
6
|
+
text: string;
|
|
7
|
+
draw?: (s: Style) => void;
|
|
8
|
+
}
|
|
9
|
+
/** What kryso says instead of running a driver, with the exit status: status 0 goes to stdout,
|
|
10
|
+
* anything else to stderr. */
|
|
11
|
+
export interface Answer extends Said {
|
|
12
|
+
status: number;
|
|
13
|
+
/** A refusal's plain line without its name, for a reader that reports it in its own words. */
|
|
14
|
+
line?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Writes to the stream: drawn when that stream is attended, else the plain text. */
|
|
17
|
+
export declare function say(said: Said, stream: Stream, env?: Env): void;
|
|
18
|
+
/** A help text: the brand line with the summary, then the text drawn in sections. */
|
|
19
|
+
export declare function helpAnswer(text: string, subcommand: string, summary: string, status?: number): Answer;
|
|
20
|
+
export interface RefusalOptions {
|
|
21
|
+
/** The fix, after the message and the joint in the plain line, and in the HINT pill drawn. */
|
|
22
|
+
hint?: string;
|
|
23
|
+
/** What joins the hint to the message in the plain line. Unless it is named, ". " does, and
|
|
24
|
+
* the hint starts with a capital, as a sentence of its own. */
|
|
25
|
+
join?: string;
|
|
26
|
+
/** A usage text the plain output prints after a blank line. The drawing leaves it out and
|
|
27
|
+
* names the help instead, when there is no hint. */
|
|
28
|
+
usage?: string;
|
|
29
|
+
}
|
|
30
|
+
/** An error kryso raises itself: `<who>: <message>` and the hint in plain, an ERROR pill with
|
|
31
|
+
* the message and a HINT pill drawn. */
|
|
32
|
+
export declare function refusal(status: number, who: string, message: string, { hint, join, usage }?: RefusalOptions): Answer;
|
|
33
|
+
/** Writes the answer to its stream, as say() does. */
|
|
34
|
+
export declare function give(answer: Answer, env?: Env, out?: Stream, err?: Stream): void;
|
|
35
|
+
/** Standard output or error written straight to its descriptor, so a line is out before what
|
|
36
|
+
* follows it: a child's output, or a question that waits on stdin. A pipe's stream on macOS
|
|
37
|
+
* writes later. */
|
|
38
|
+
export declare const descriptor: (fd: 1 | 2) => Stream;
|
package/dist/answer.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// What kryso prints itself, in both layers (ADR 0042): each line or block is declared once, as
|
|
2
|
+
// the plain text every caller has always printed and a drawing of it for an attended stream.
|
|
3
|
+
// say() and give() pick one by the attended check, which no caller makes itself.
|
|
4
|
+
import { writeSync } from "node:fs";
|
|
5
|
+
import { isatty } from "node:tty";
|
|
6
|
+
import { attended, style } from "./style.js";
|
|
7
|
+
/** Writes to the stream: drawn when that stream is attended, else the plain text. */
|
|
8
|
+
export function say(said, stream, env = process.env) {
|
|
9
|
+
if (said.draw && attended(stream, env))
|
|
10
|
+
said.draw(style(stream, stream, env));
|
|
11
|
+
else if (said.text)
|
|
12
|
+
stream.write(said.text);
|
|
13
|
+
}
|
|
14
|
+
/** A help text: the brand line with the summary, then the text drawn in sections. */
|
|
15
|
+
export function helpAnswer(text, subcommand, summary, status = 0) {
|
|
16
|
+
return {
|
|
17
|
+
text,
|
|
18
|
+
status,
|
|
19
|
+
draw: (s) => {
|
|
20
|
+
s.brand(subcommand, summary);
|
|
21
|
+
s.help(`\n${text}`);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** An error kryso raises itself: `<who>: <message>` and the hint in plain, an ERROR pill with
|
|
26
|
+
* the message and a HINT pill drawn. */
|
|
27
|
+
export function refusal(status, who, message, { hint, join, usage } = {}) {
|
|
28
|
+
const said = hint && join === undefined ? hint.charAt(0).toUpperCase() + hint.slice(1) : hint;
|
|
29
|
+
const line = `${message}${said ? `${join ?? ". "}${said}` : ""}`;
|
|
30
|
+
return {
|
|
31
|
+
text: `${who}: ${line}\n${usage ? `\n${usage}` : ""}`,
|
|
32
|
+
status,
|
|
33
|
+
line,
|
|
34
|
+
draw: (s) => s.error(message, hint ?? (usage ? `Run ${who} --help for its usage.` : undefined)),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Writes the answer to its stream, as say() does. */
|
|
38
|
+
export function give(answer, env = process.env, out = process.stdout, err = process.stderr) {
|
|
39
|
+
say(answer, answer.status === 0 ? out : err, env);
|
|
40
|
+
}
|
|
41
|
+
/** Standard output or error written straight to its descriptor, so a line is out before what
|
|
42
|
+
* follows it: a child's output, or a question that waits on stdin. A pipe's stream on macOS
|
|
43
|
+
* writes later. */
|
|
44
|
+
export const descriptor = (fd) => ({
|
|
45
|
+
write: (text) => void writeSync(fd, text),
|
|
46
|
+
isTTY: isatty(fd),
|
|
47
|
+
columns: isatty(fd) ? (fd === 1 ? process.stdout : process.stderr).columns : undefined,
|
|
48
|
+
});
|
package/dist/bytes.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The bytes of every file under a path, links counted as themselves and never followed, and
|
|
2
|
+
* directories as nothing of their own. */
|
|
3
|
+
export declare function sizeOf(at: string): number;
|
|
4
|
+
/** A size as a person reads it: bytes, then KB, MB and GB, a thousand each. */
|
|
5
|
+
export declare function size(bytes: number): string;
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Sizes on disk: what a path holds, and how a person reads the number.
|
|
2
|
+
import { lstatSync, readdirSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
/** The bytes of every file under a path, links counted as themselves and never followed, and
|
|
5
|
+
* directories as nothing of their own. */
|
|
6
|
+
export function sizeOf(at) {
|
|
7
|
+
let st;
|
|
8
|
+
try {
|
|
9
|
+
st = lstatSync(at);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
if (!st.isDirectory())
|
|
15
|
+
return st.size;
|
|
16
|
+
let names = [];
|
|
17
|
+
try {
|
|
18
|
+
names = readdirSync(at);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// A directory it cannot list counts as its own entry alone.
|
|
22
|
+
}
|
|
23
|
+
return names.reduce((sum, name) => sum + sizeOf(path.join(at, name)), 0);
|
|
24
|
+
}
|
|
25
|
+
/** A size as a person reads it: bytes, then KB, MB and GB, a thousand each. */
|
|
26
|
+
export function size(bytes) {
|
|
27
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
28
|
+
let n = bytes;
|
|
29
|
+
let u = 0;
|
|
30
|
+
while (n >= 1000 && u < units.length - 1) {
|
|
31
|
+
n /= 1000;
|
|
32
|
+
u++;
|
|
33
|
+
}
|
|
34
|
+
return u === 0 ? `${n} B` : `${n < 10 ? n.toFixed(1) : Math.round(n)} ${units[u]}`;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|