@wrktr/cli 0.1.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.
Files changed (3) hide show
  1. package/README.md +14 -0
  2. package/bin/wrktr.cjs +72 -0
  3. package/package.json +21 -0
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # @wrktr/cli
2
+
3
+ Agent-first git on Cloudflare: give each agent a branch and a worktree, keep them synced, and land them
4
+ through review and CI.
5
+
6
+ ```sh
7
+ npm i -g @wrktr/cli # or: curl -fsSL https://wrktr.com/install | sh
8
+ wrktr login
9
+ wrktr clone <org>/<project> # or, in a repo you have: wrktr init
10
+ wrktr branch new <name>
11
+ wrktr daemon install
12
+ ```
13
+
14
+ A standalone binary per platform (no Node or Bun needed to run it); needs git. https://wrktr.com
package/bin/wrktr.cjs ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ // The `wrktr` npm package's command: finds the binary for this machine (installed by npm as one of the
3
+ // package's optional dependencies, `@wrktr/cli-<os>-<arch>[-musl]`) and runs it. WRKTR_BIN_PATH overrides it.
4
+ "use strict";
5
+
6
+ const { spawn, spawnSync } = require("node:child_process");
7
+ const { existsSync } = require("node:fs");
8
+ const { dirname, join } = require("node:path");
9
+
10
+ const os = process.platform === "win32" ? "windows" : process.platform;
11
+ const binary = process.platform === "win32" ? "wrktr.exe" : "wrktr";
12
+
13
+ /** Alpine and other musl distributions can't run glibc binaries. */
14
+ const isMusl = () => {
15
+ if (process.platform !== "linux") return false;
16
+ if (existsSync("/etc/alpine-release")) return true;
17
+ const ldd = spawnSync("ldd", ["--version"], { encoding: "utf8" });
18
+ return `${ldd.stdout ?? ""}${ldd.stderr ?? ""}`.toLowerCase().includes("musl");
19
+ };
20
+
21
+ const base = `@wrktr/cli-${os}-${process.arch}`;
22
+ const candidates = isMusl() ? [`${base}-musl`, base] : [base, `${base}-musl`];
23
+
24
+ const find = () => {
25
+ if (process.env.WRKTR_BIN_PATH) return process.env.WRKTR_BIN_PATH;
26
+ for (const name of candidates) {
27
+ try {
28
+ const path = join(dirname(require.resolve(`${name}/package.json`)), "bin", binary);
29
+ if (existsSync(path)) return path;
30
+ } catch {
31
+ // Not installed for this platform; try the next.
32
+ }
33
+ }
34
+ return null;
35
+ };
36
+
37
+ const target = find();
38
+ if (target === null) {
39
+ console.error(
40
+ `wrktr: no binary for ${process.platform}-${process.arch}. Your package manager may have skipped optional ` +
41
+ `dependencies; install ${candidates[0]} directly, or use the installer at https://wrktr.com/install.`,
42
+ );
43
+ process.exit(1);
44
+ }
45
+
46
+ const child = spawn(target, process.argv.slice(2), { stdio: "inherit" });
47
+ if (candidates[0].endsWith("-musl") && !existsSync("/usr/lib/libstdc++.so.6")) {
48
+ console.error("wrktr: on Alpine, the binary needs the C++ runtime: apk add libstdc++ libgcc");
49
+ }
50
+ const handlers = Object.fromEntries(
51
+ ["SIGINT", "SIGTERM", "SIGHUP"].map((signal) => [
52
+ signal,
53
+ () => {
54
+ try {
55
+ child.kill(signal);
56
+ } catch {
57
+ // Already exited.
58
+ }
59
+ },
60
+ ]),
61
+ );
62
+ for (const [signal, handler] of Object.entries(handlers)) process.on(signal, handler);
63
+ child.on("error", (error) => {
64
+ console.error(`wrktr: ${error.message}`);
65
+ process.exit(1);
66
+ });
67
+ child.on("exit", (code, signal) => {
68
+ // Die the way the binary did; drop our forwarding first, or re-raising the signal would only reach it.
69
+ for (const [name, handler] of Object.entries(handlers)) process.removeListener(name, handler);
70
+ if (signal !== null) process.kill(process.pid, signal);
71
+ else process.exit(code ?? 0);
72
+ });
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@wrktr/cli",
3
+ "version": "0.1.1",
4
+ "description": "Agent-first git on Cloudflare: a branch and a worktree per agent, live review, CI and landing.",
5
+ "homepage": "https://wrktr.com",
6
+ "bin": {
7
+ "wrktr": "bin/wrktr.cjs"
8
+ },
9
+ "files": [
10
+ "bin"
11
+ ],
12
+ "optionalDependencies": {
13
+ "@wrktr/cli-darwin-arm64": "0.1.1",
14
+ "@wrktr/cli-darwin-x64": "0.1.1",
15
+ "@wrktr/cli-linux-x64": "0.1.1",
16
+ "@wrktr/cli-linux-arm64": "0.1.1",
17
+ "@wrktr/cli-linux-x64-musl": "0.1.1",
18
+ "@wrktr/cli-linux-arm64-musl": "0.1.1",
19
+ "@wrktr/cli-windows-x64": "0.1.1"
20
+ }
21
+ }