@furaflight/mcp 0.0.1 → 0.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furaflight/mcp",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "MCP server exposing a flight search tool backed by flightlist.io",
5
5
  "homepage": "https://github.com/eddienubes/furaflight#readme",
6
6
  "bugs": {
@@ -12,19 +12,25 @@
12
12
  "url": "git+https://github.com/eddienubes/furaflight.git"
13
13
  },
14
14
  "bin": {
15
- "furaflight": "dist/furaflight"
15
+ "furaflight": "bin/furaflight.exe"
16
16
  },
17
17
  "files": [
18
- "dist/**/*"
18
+ "scripts/install.cjs",
19
+ "README.md",
20
+ "LICENSE"
19
21
  ],
22
+ "type": "module",
20
23
  "publishConfig": {
21
24
  "access": "public",
22
25
  "registry": "https://registry.npmjs.org",
23
26
  "tag": "latest"
24
27
  },
25
- "type": "module",
26
28
  "scripts": {
27
29
  "build": "bun build --compile --bytecode --minify --format esm --sourcemap --outfile dist/furaflight ./src/main.ts",
30
+ "build:platforms": "bun run scripts/build-platforms.ts",
31
+ "gen:platforms": "bun run scripts/generate-platform-packages.ts",
32
+ "publish:platforms": "bun run scripts/publish-platforms.ts",
33
+ "postinstall": "node scripts/install.cjs",
28
34
  "start": "bun run src/main.ts",
29
35
  "test": "bun test",
30
36
  "lint": "oxlint",
@@ -41,5 +47,15 @@
41
47
  "oxfmt": "^0.61.0",
42
48
  "oxlint": "^1.76.0",
43
49
  "typescript": "^7.0.2"
50
+ },
51
+ "optionalDependencies": {
52
+ "@furaflight/mcp-darwin-arm64": "0.0.1",
53
+ "@furaflight/mcp-darwin-x64": "0.0.1",
54
+ "@furaflight/mcp-linux-arm64": "0.0.1",
55
+ "@furaflight/mcp-linux-arm64-musl": "0.0.1",
56
+ "@furaflight/mcp-linux-x64": "0.0.1",
57
+ "@furaflight/mcp-linux-x64-musl": "0.0.1",
58
+ "@furaflight/mcp-win32-arm64": "0.0.1",
59
+ "@furaflight/mcp-win32-x64": "0.0.1"
44
60
  }
45
61
  }
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * Postinstall script for @furaflight/mcp. Finds the already-installed
6
+ * `@furaflight/mcp-<platform>` optionalDependency matching this machine and
7
+ * places its binary at `bin/furaflight.exe` (the `.exe` suffix is used on
8
+ * every platform, not just Windows, because npm's Windows cmd-shim
9
+ * generator requires the target to literally be a `.exe`; POSIX ignores
10
+ * the extension so it's harmless elsewhere).
11
+ *
12
+ * Plain Node.js CommonJS on purpose (no Bun-only syntax, no dependencies
13
+ * of its own) — Node is what's guaranteed present regardless of whether
14
+ * the end user separately has Bun installed.
15
+ */
16
+
17
+ const fs = require("node:fs");
18
+ const os = require("node:os");
19
+ const path = require("node:path");
20
+
21
+ // Keep this table's keys/packages in lockstep with scripts/constants.ts by
22
+ // hand (this file ships standalone in the published tarball, so it can't
23
+ // import that module at runtime) — a parity test in install.spec.ts fails
24
+ // CI if the two ever drift apart.
25
+ const PLATFORM_PACKAGES = {
26
+ "darwin-x64": { pkg: "@furaflight/mcp-darwin-x64", bin: "furaflight" },
27
+ "darwin-arm64": { pkg: "@furaflight/mcp-darwin-arm64", bin: "furaflight" },
28
+ "linux-x64-glibc": { pkg: "@furaflight/mcp-linux-x64", bin: "furaflight" },
29
+ "linux-x64-musl": { pkg: "@furaflight/mcp-linux-x64-musl", bin: "furaflight" },
30
+ "linux-arm64-glibc": { pkg: "@furaflight/mcp-linux-arm64", bin: "furaflight" },
31
+ "linux-arm64-musl": { pkg: "@furaflight/mcp-linux-arm64-musl", bin: "furaflight" },
32
+ "win32-x64": { pkg: "@furaflight/mcp-win32-x64", bin: "furaflight.exe" },
33
+ "win32-arm64": { pkg: "@furaflight/mcp-win32-arm64", bin: "furaflight.exe" },
34
+ };
35
+
36
+ const DEST_BINARY_NAME = "furaflight.exe";
37
+
38
+ /**
39
+ * Detects musl vs glibc on Linux via `process.report.getReport()` instead
40
+ * of spawning `ldd` (which can fail or simply be missing in minimal
41
+ * containers). A glibc runtime report includes `header.glibcVersionRuntime`;
42
+ * its absence on Linux is treated as musl.
43
+ */
44
+ const isMusl = () => {
45
+ if (typeof process.report?.getReport !== "function") {
46
+ // No process.report support (very old Node) — assume glibc, the more
47
+ // common case, rather than fail outright.
48
+ return false;
49
+ }
50
+ try {
51
+ const report = process.report.getReport();
52
+ return !report?.header?.glibcVersionRuntime;
53
+ } catch {
54
+ return false;
55
+ }
56
+ };
57
+
58
+ const detectPlatformKey = () => {
59
+ const platform = process.platform;
60
+ const arch = os.arch();
61
+ if (platform === "linux") {
62
+ return `linux-${arch}-${isMusl() ? "musl" : "glibc"}`;
63
+ }
64
+ return `${platform}-${arch}`;
65
+ };
66
+
67
+ const getDestPath = () => path.join(__dirname, "bin", DEST_BINARY_NAME);
68
+
69
+ /**
70
+ * True only when running against a checkout of the source repo itself
71
+ * (e.g. a contributor's `bun install`), never for a real end-user install:
72
+ * the published tarball's `files` list never includes `src/`, so this
73
+ * can't false-positive for a real consumer install.
74
+ */
75
+ const isRunningInsideSourceRepo = () => fs.existsSync(path.join(__dirname, "..", "src", "main.ts"));
76
+
77
+ /**
78
+ * Places `srcPath` at `destPath`: hardlink first (fast, zero extra disk
79
+ * use), falling back to unlink-then-hardlink, falling back further to a
80
+ * plain copy (handles cross-device links or restrictive permissions).
81
+ */
82
+ const placeBinary = (srcPath, destPath) => {
83
+ fs.mkdirSync(path.dirname(destPath), { recursive: true });
84
+
85
+ try {
86
+ fs.linkSync(srcPath, destPath);
87
+ } catch {
88
+ try {
89
+ fs.unlinkSync(destPath);
90
+ } catch {
91
+ // destPath may not exist yet — fine, keep going.
92
+ }
93
+ try {
94
+ fs.linkSync(srcPath, destPath);
95
+ } catch {
96
+ fs.copyFileSync(srcPath, destPath);
97
+ }
98
+ }
99
+
100
+ if (process.platform !== "win32") {
101
+ fs.chmodSync(destPath, 0o755);
102
+ }
103
+ };
104
+
105
+ const printUnsupportedPlatformError = (platformKey) => {
106
+ const supported = Object.keys(PLATFORM_PACKAGES).sort().join(", ");
107
+ console.error(
108
+ [
109
+ `furaflight: unsupported platform "${platformKey}" (process.platform=${process.platform}, os.arch()=${os.arch()}).`,
110
+ `Supported platforms: ${supported}.`,
111
+ "If you believe this is wrong, please open an issue at https://github.com/eddienubes/furaflight/issues.",
112
+ ].join("\n"),
113
+ );
114
+ };
115
+
116
+ const printMissingPackageError = (platformKey, entry) => {
117
+ console.error(
118
+ [
119
+ `furaflight: could not find the "${entry.pkg}" package on disk (expected for platform "${platformKey}").`,
120
+ "This usually means it was skipped during install — try reinstalling without",
121
+ '"--ignore-scripts" and without "--no-optional" (or your package manager\'s',
122
+ "equivalent flags), so npm can download the platform-specific binary package.",
123
+ ].join("\n"),
124
+ );
125
+ };
126
+
127
+ const main = () => {
128
+ if (isRunningInsideSourceRepo()) {
129
+ console.log("furaflight: running inside the source repo, skipping binary placement.");
130
+ return;
131
+ }
132
+
133
+ const platformKey = detectPlatformKey();
134
+ const entry = PLATFORM_PACKAGES[platformKey];
135
+
136
+ if (!entry) {
137
+ printUnsupportedPlatformError(platformKey);
138
+ process.exit(1);
139
+ return;
140
+ }
141
+
142
+ let resolvedBinaryPath;
143
+ try {
144
+ resolvedBinaryPath = require.resolve(`${entry.pkg}/bin/${entry.bin}`);
145
+ } catch {
146
+ printMissingPackageError(platformKey, entry);
147
+ process.exit(1);
148
+ return;
149
+ }
150
+
151
+ const destPath = getDestPath();
152
+ try {
153
+ placeBinary(resolvedBinaryPath, destPath);
154
+ } catch (err) {
155
+ console.error(`furaflight: failed to place binary at ${destPath}: ${err.message}`);
156
+ process.exit(1);
157
+ return;
158
+ }
159
+ };
160
+
161
+ if (require.main === module) {
162
+ main();
163
+ }
164
+
165
+ module.exports = {
166
+ PLATFORM_PACKAGES,
167
+ DEST_BINARY_NAME,
168
+ isMusl,
169
+ detectPlatformKey,
170
+ getDestPath,
171
+ isRunningInsideSourceRepo,
172
+ };
package/dist/furaflight DELETED
Binary file