nitpiq-mcp 0.5.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/bin/nitpiq-mcp ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const os = require("os");
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ });
12
+ if (result.error) {
13
+ console.error(result.error.message);
14
+ process.exit(1);
15
+ }
16
+ process.exit(typeof result.status === "number" ? result.status : 0);
17
+ }
18
+
19
+ const scriptDir = path.dirname(fs.realpathSync(__filename));
20
+
21
+ const cached = path.join(scriptDir, ".nitpiq-mcp");
22
+ if (fs.existsSync(cached)) {
23
+ run(cached);
24
+ }
25
+
26
+ const platformMap = { darwin: "darwin", linux: "linux" };
27
+ const archMap = { x64: "x64", arm64: "arm64" };
28
+
29
+ const platform = platformMap[os.platform()] || os.platform();
30
+ const arch = archMap[os.arch()] || os.arch();
31
+ const pkg = `nitpiq-${platform}-${arch}`;
32
+
33
+ function findBinary(startDir) {
34
+ let current = startDir;
35
+ for (;;) {
36
+ const candidate = path.join(current, "node_modules", pkg, "bin", "nitpiq-mcp");
37
+ if (fs.existsSync(candidate)) return candidate;
38
+ const parent = path.dirname(current);
39
+ if (parent === current) return null;
40
+ current = parent;
41
+ }
42
+ }
43
+
44
+ const resolved = findBinary(scriptDir);
45
+ if (!resolved) {
46
+ console.error(
47
+ `Could not find the nitpiq-mcp binary. Try installing the platform package manually: npm install ${pkg}`,
48
+ );
49
+ process.exit(1);
50
+ }
51
+
52
+ run(resolved);
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "nitpiq-mcp",
3
+ "version": "0.5.0",
4
+ "description": "MCP server for nitpiq local code review",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "nitpiq-mcp": "bin/nitpiq-mcp"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node postinstall.mjs"
11
+ },
12
+ "optionalDependencies": {
13
+ "nitpiq-linux-x64": "0.5.0",
14
+ "nitpiq-linux-arm64": "0.5.0",
15
+ "nitpiq-darwin-x64": "0.5.0",
16
+ "nitpiq-darwin-arm64": "0.5.0"
17
+ }
18
+ }
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import os from "os";
6
+ import { fileURLToPath } from "url";
7
+ import { createRequire } from "module";
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const require = createRequire(import.meta.url);
11
+
12
+ const PLATFORM_MAP = { darwin: "darwin", linux: "linux" };
13
+ const ARCH_MAP = { x64: "x64", arm64: "arm64" };
14
+
15
+ function detect() {
16
+ const platform = PLATFORM_MAP[os.platform()];
17
+ const arch = ARCH_MAP[os.arch()];
18
+ if (!platform || !arch) {
19
+ throw new Error(`Unsupported platform: ${os.platform()}-${os.arch()}`);
20
+ }
21
+ return { platform, arch };
22
+ }
23
+
24
+ function findBinary(name) {
25
+ const { platform, arch } = detect();
26
+ const pkg = `nitpiq-${platform}-${arch}`;
27
+
28
+ const pkgJson = require.resolve(`${pkg}/package.json`);
29
+ const pkgDir = path.dirname(pkgJson);
30
+ const bin = path.join(pkgDir, "bin", name);
31
+
32
+ if (!fs.existsSync(bin)) {
33
+ throw new Error(`Binary not found at ${bin}`);
34
+ }
35
+ return bin;
36
+ }
37
+
38
+ function linkBinary(name) {
39
+ const source = findBinary(name);
40
+ const target = path.join(__dirname, "bin", `.${name}`);
41
+
42
+ if (fs.existsSync(target)) fs.unlinkSync(target);
43
+
44
+ try {
45
+ fs.linkSync(source, target);
46
+ } catch {
47
+ fs.copyFileSync(source, target);
48
+ }
49
+ fs.chmodSync(target, 0o755);
50
+ }
51
+
52
+ try {
53
+ linkBinary("nitpiq");
54
+ linkBinary("nitpiq-mcp");
55
+ } catch (error) {
56
+ console.error("nitpiq postinstall:", error.message);
57
+ process.exit(1);
58
+ }