@jr2/cli 0.1.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 Rich Snapp
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 ADDED
@@ -0,0 +1,18 @@
1
+ # @jr2/cli
2
+
3
+ The `jr2` binary: the interface to a jr2 [Instance](https://github.com/snapwich/jr2/blob/main/CONTEXT.md) — a folder of
4
+ workflows deployed to whatever cluster the current `kubectl` context names.
5
+
6
+ ```sh
7
+ npm i -g @jr2/cli
8
+ jr2 init my-instance && cd my-instance
9
+ npm install
10
+ jr2 up
11
+ jr2 run <workflow>
12
+ ```
13
+
14
+ `init` scaffolds an Instance pinned at this CLI's version; `up` converges the target namespace to match it (operator,
15
+ Orchestrator, Sandboxes, secrets), and every other verb (`run`, `runs`, `status`, `logs`, `send`, `down`, `gc`,
16
+ `kit push`) talks to what `up` deployed. Node 24, a kube context, and docker for the image `up` builds.
17
+
18
+ Docs, glossary, and architecture decisions: [github.com/snapwich/jr2](https://github.com/snapwich/jr2).
package/bin/jr2.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ // The `jr2` binary (ADR-0009). The kit is zero-build `.ts` — but Node's own type stripping REFUSES
3
+ // to run on files under `node_modules`, and an installed kit is nothing but files under
4
+ // `node_modules` (ADR-0043). So this entry is the one `.js` file in the package: it teaches the
5
+ // loader to erase types the same way Node would, then hands over to the `.ts` sources.
6
+ //
7
+ // One entry for both worlds, deliberately: a checkout-only `.ts` bin plus an installed-only `.js`
8
+ // bin would mean the binary users run is not the binary the checkout's tiers run. The image
9
+ // bundle solves the same problem with `tsx` (see INSTANCE_DOCKERFILE) because there the entry is
10
+ // the orchestrator's, not this one.
11
+ //
12
+ // After the hook it does nothing but hand argv to `main` and surface the exit code. `main` is
13
+ // pure-ish (takes an injectable IO) so the dispatch + commands stay unit-testable without a process.
14
+
15
+ import { readFileSync } from "node:fs";
16
+ import { registerHooks } from "node:module";
17
+ import { fileURLToPath } from "node:url";
18
+ import tsBlankSpace from "ts-blank-space";
19
+
20
+ // Erasure, not compilation: types are replaced by whitespace, so line and column numbers in a
21
+ // stack trace still point at the source (ADR-0034 makes the same trade for the Console). What
22
+ // `ts-blank-space` cannot erase — an enum, a namespace, a constructor parameter property — is
23
+ // exactly what Node's own stripping rejects too, so this hook widens where the kit runs, never
24
+ // what the kit may be written in. `module` is the only format the kit ships: every jr2 package is
25
+ // `type: "module"`, and the hook sees kit sources only (the CLI imports no instance code).
26
+ registerHooks({
27
+ load(url, context, nextLoad) {
28
+ if (!url.startsWith("file:") || !url.endsWith(".ts")) return nextLoad(url, context);
29
+ const source = tsBlankSpace(readFileSync(fileURLToPath(url), "utf8"));
30
+ return { format: "module", source, shortCircuit: true };
31
+ },
32
+ });
33
+
34
+ const { main } = await import("../src/cli.ts");
35
+
36
+ main(process.argv.slice(2)).then((code) => {
37
+ process.exitCode = code;
38
+ });