@johannesbraeunig/ghi 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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/bin/ghi.js +71 -0
  3. package/package.json +30 -0
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @johannesbraeunig/ghi
2
+
3
+ A GitHub-native issue tracker CLI for AI agents. Drives GitHub Issues and
4
+ GitHub Projects v2 directly, authenticating via the locally installed
5
+ [`gh` CLI](https://cli.github.com/).
6
+
7
+ ```sh
8
+ npm install -D @johannesbraeunig/ghi
9
+ npx ghi --help
10
+ ```
11
+
12
+ Full documentation: https://github.com/johannesbraeunig/ghi
package/bin/ghi.js ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("child_process");
5
+
6
+ // Maps `${process.platform}-${process.arch}` to the optionalDependency
7
+ // package that ships the matching prebuilt binary.
8
+ const PLATFORM_PACKAGES = {
9
+ "darwin-arm64": "@johannesbraeunig/ghi-darwin-arm64",
10
+ "darwin-x64": "@johannesbraeunig/ghi-darwin-x64",
11
+ "linux-arm64": "@johannesbraeunig/ghi-linux-arm64",
12
+ "linux-x64": "@johannesbraeunig/ghi-linux-x64",
13
+ "win32-arm64": "@johannesbraeunig/ghi-win32-arm64",
14
+ "win32-x64": "@johannesbraeunig/ghi-win32-x64",
15
+ };
16
+
17
+ function platformKey() {
18
+ return `${process.platform}-${process.arch}`;
19
+ }
20
+
21
+ function resolveBinary() {
22
+ const key = platformKey();
23
+ const pkg = PLATFORM_PACKAGES[key];
24
+ if (!pkg) {
25
+ throw new Error(
26
+ `ghi does not publish a prebuilt binary for "${key}". ` +
27
+ `Supported platforms: ${Object.keys(PLATFORM_PACKAGES).join(", ")}.`
28
+ );
29
+ }
30
+
31
+ const binName = process.platform === "win32" ? "ghi.exe" : "ghi";
32
+ try {
33
+ return require.resolve(`${pkg}/bin/${binName}`);
34
+ } catch (err) {
35
+ throw new Error(
36
+ `Could not find the "${pkg}" package for your platform (${key}). ` +
37
+ `It should have installed automatically as an optionalDependency. Likely causes:\n` +
38
+ ` - npm/yarn/pnpm was run with --no-optional or --omit=optional\n` +
39
+ ` - "npm ci" was run against a package-lock.json generated on a different OS/CPU\n` +
40
+ ` - a very old package manager that doesn't filter optionalDependencies by os/cpu\n` +
41
+ ` - Yarn Plug'n'Play in "hardened" mode (ghi's platform packages opt into unplugged mode, but this can still occur)\n` +
42
+ `Try reinstalling with a plain "npm install" (no --no-optional/--omit=optional flags).`
43
+ );
44
+ }
45
+ }
46
+
47
+ let binaryPath;
48
+ try {
49
+ binaryPath = resolveBinary();
50
+ } catch (err) {
51
+ console.error(`ghi: ${err.message}`);
52
+ process.exit(1);
53
+ }
54
+
55
+ const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
56
+
57
+ if (result.error) {
58
+ console.error(`ghi: failed to launch ${binaryPath}: ${result.error.message}`);
59
+ process.exit(1);
60
+ }
61
+
62
+ // result.status is null when the child was killed by a signal (e.g. Ctrl+C
63
+ // during a network call) rather than exiting normally — process.exit(null)
64
+ // would silently report success (exit 0) in that case, which is wrong for a
65
+ // tool other scripts/agents branch on. Forward the signal instead so the
66
+ // parent shell sees the same termination the child actually had.
67
+ if (result.signal) {
68
+ process.kill(process.pid, result.signal);
69
+ } else {
70
+ process.exit(result.status ?? 1);
71
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@johannesbraeunig/ghi",
3
+ "version": "0.1.0",
4
+ "description": "A GitHub-native issue tracker CLI for AI agents",
5
+ "bin": {
6
+ "ghi": "bin/ghi.js"
7
+ },
8
+ "files": [
9
+ "bin"
10
+ ],
11
+ "engines": {
12
+ "node": ">=18"
13
+ },
14
+ "license": "MIT",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/johannesbraeunig/ghi.git"
21
+ },
22
+ "optionalDependencies": {
23
+ "@johannesbraeunig/ghi-darwin-arm64": "0.1.0",
24
+ "@johannesbraeunig/ghi-darwin-x64": "0.1.0",
25
+ "@johannesbraeunig/ghi-linux-arm64": "0.1.0",
26
+ "@johannesbraeunig/ghi-linux-x64": "0.1.0",
27
+ "@johannesbraeunig/ghi-win32-arm64": "0.1.0",
28
+ "@johannesbraeunig/ghi-win32-x64": "0.1.0"
29
+ }
30
+ }