@gtt-community/gtt-cli 0.0.0-stage → 1.1.2

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/README.md CHANGED
@@ -1,3 +1,14 @@
1
- # Temporary Holding Version
1
+ # gtt-cli
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
+ The GTT CLI: the operational doorway into [GTT Bootstrap](https://github.com/GTT-Community/gtt-bootstrap).
4
+
5
+ ```bash
6
+ npm install -g gtt-cli
7
+ gtt version
8
+ ```
9
+
10
+ This package installs the native `gtt` binary for your platform (Linux, macOS, Windows; x64, arm64) from the
11
+ matching [GitHub release](https://github.com/GTT-Community/gtt-cli/releases), verified against its SHA-256 checksum.
12
+ GTT Bootstrap also needs `git`, `bash` and `python3` (on Windows: Git for Windows and Python 3).
13
+
14
+ Documentation: https://github.com/GTT-Community/gtt-cli#readme
package/bin/gtt.js ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ // npm entry point: runs the native gtt binary, fetching it first if the
3
+ // install step was skipped. Arguments, streams and the exit code pass through.
4
+ "use strict";
5
+
6
+ const { spawnSync } = require("child_process");
7
+ const { install } = require("../install.js");
8
+
9
+ install().then(
10
+ (binary) => {
11
+ const res = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
12
+ if (res.error) {
13
+ console.error(`gtt: ${res.error.message}`);
14
+ process.exit(7);
15
+ }
16
+ process.exit(res.status === null ? 1 : res.status);
17
+ },
18
+ (err) => {
19
+ console.error(`gtt: could not install the gtt binary: ${err.message}`);
20
+ process.exit(7);
21
+ },
22
+ );
package/install.js ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ // Downloads the native gtt binary that matches this package version from the
3
+ // GitHub release, verifies its SHA-256 against the release checksums and
4
+ // unpacks it into vendor/. Run on install and, if that was skipped (for
5
+ // example with --ignore-scripts), on the first `gtt` call.
6
+ "use strict";
7
+
8
+ const crypto = require("crypto");
9
+ const fs = require("fs");
10
+ const os = require("os");
11
+ const path = require("path");
12
+ const { execFileSync } = require("child_process");
13
+
14
+ const REPO = "GTT-Community/gtt-cli";
15
+ const pkg = require("./package.json");
16
+
17
+ const PLATFORMS = { linux: "linux", darwin: "darwin", win32: "windows" };
18
+ const ARCHS = { x64: "amd64", arm64: "arm64" };
19
+
20
+ function binaryPath() {
21
+ return path.join(__dirname, "vendor", process.platform === "win32" ? "gtt.exe" : "gtt");
22
+ }
23
+
24
+ function asset() {
25
+ const goos = PLATFORMS[process.platform];
26
+ const goarch = ARCHS[process.arch];
27
+ if (!goos || !goarch) {
28
+ throw new Error(`gtt does not support ${process.platform}/${process.arch}`);
29
+ }
30
+ return `gtt_${goos}_${goarch}.${goos === "windows" ? "zip" : "tar.gz"}`;
31
+ }
32
+
33
+ async function download(url) {
34
+ const res = await fetch(url, { redirect: "follow" });
35
+ if (!res.ok) {
36
+ throw new Error(`download failed (${res.status}): ${url}`);
37
+ }
38
+ return Buffer.from(await res.arrayBuffer());
39
+ }
40
+
41
+ async function install() {
42
+ const target = binaryPath();
43
+ if (fs.existsSync(target)) {
44
+ return target;
45
+ }
46
+ const name = asset();
47
+ const base = process.env.GTT_DOWNLOAD_BASE || `https://github.com/${REPO}/releases/download/v${pkg.version}`;
48
+ const [archive, sums] = await Promise.all([download(`${base}/${name}`), download(`${base}/checksums.txt`)]);
49
+
50
+ const line = sums.toString("utf8").split(/\r?\n/).find((l) => l.trim().endsWith(` ${name}`));
51
+ if (!line) {
52
+ throw new Error(`${name} is not listed in checksums.txt`);
53
+ }
54
+ const expected = line.trim().split(/\s+/)[0].toLowerCase();
55
+ const actual = crypto.createHash("sha256").update(archive).digest("hex");
56
+ if (expected !== actual) {
57
+ throw new Error(`checksum mismatch for ${name}: expected ${expected}, got ${actual}`);
58
+ }
59
+
60
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "gtt-npm-"));
61
+ try {
62
+ const file = path.join(tmp, name);
63
+ fs.writeFileSync(file, archive);
64
+ // tar ships with Linux, macOS and Windows 10+ (bsdtar reads zip as well).
65
+ execFileSync("tar", ["-xf", file, "-C", tmp], { stdio: "ignore" });
66
+ const unpacked = path.join(tmp, path.basename(target));
67
+ fs.mkdirSync(path.dirname(target), { recursive: true });
68
+ fs.copyFileSync(unpacked, target);
69
+ fs.chmodSync(target, 0o755);
70
+ } finally {
71
+ fs.rmSync(tmp, { recursive: true, force: true });
72
+ }
73
+ return target;
74
+ }
75
+
76
+ module.exports = { install, binaryPath };
77
+
78
+ if (require.main === module) {
79
+ install().then(
80
+ (p) => console.log(`gtt ${pkg.version} installed: ${p}`),
81
+ (err) => {
82
+ // A failed postinstall must not break `npm install`; the first `gtt`
83
+ // call retries and reports the error.
84
+ console.warn(`gtt: binary not installed yet (${err.message}); it will be fetched on first use.`);
85
+ },
86
+ );
87
+ }
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@gtt-community/gtt-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.2",
4
+ "description": "GTT CLI - the operational doorway into GTT Bootstrap (installs the native gtt binary)",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/GTT-Community/gtt-cli#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/GTT-Community/gtt-cli.git"
10
+ },
11
+ "bugs": "https://github.com/GTT-Community/gtt-cli/issues",
12
+ "keywords": [
13
+ "gtt",
14
+ "governance",
15
+ "architecture",
16
+ "ai",
17
+ "cli",
18
+ "claude",
19
+ "copilot",
20
+ "kiro",
21
+ "codex"
22
+ ],
23
+ "bin": {
24
+ "gtt": "bin/gtt.js"
25
+ },
26
+ "files": [
27
+ "bin/",
28
+ "install.js",
29
+ "README.md"
30
+ ],
31
+ "scripts": {
32
+ "postinstall": "node install.js"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "os": [
38
+ "linux",
39
+ "darwin",
40
+ "win32"
41
+ ],
42
+ "cpu": [
43
+ "x64",
44
+ "arm64"
45
+ ]
46
+ }