@autodevjapan/godd-mcp-alpha 1.28.0 → 1.30.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autodevjapan/godd-mcp-alpha",
3
- "version": "1.28.0",
3
+ "version": "1.30.0",
4
4
  "type": "module",
5
5
  "description": "GoDD MCP α Server — AI Prompt Delivery System for Cursor IDE",
6
6
  "license": "UNLICENSED",
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "files": [
12
12
  "dist/godd.cjs",
13
+ "scripts/postinstall-godd-tk.js",
13
14
  "README.md"
14
15
  ],
15
16
  "engines": {
@@ -29,7 +30,8 @@
29
30
  "test": "vitest run",
30
31
  "test:watch": "vitest",
31
32
  "dev": "tsx src/index.ts serve",
32
- "prepublishOnly": "node esbuild.config.js"
33
+ "prepublishOnly": "node esbuild.config.js",
34
+ "postinstall": "node scripts/postinstall-godd-tk.js || true"
33
35
  },
34
36
  "dependencies": {
35
37
  "@modelcontextprotocol/sdk": "1.29.0",
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * GoDD Token Killer — postinstall script
5
+ *
6
+ * Downloads the pre-built godd-tk binary for the current OS/arch
7
+ * from GitHub Releases and places it in ~/.local/bin/ (Unix) or
8
+ * %LOCALAPPDATA%/godd-tk/ (Windows).
9
+ */
10
+
11
+ import { createWriteStream, mkdirSync, chmodSync, existsSync, renameSync, unlinkSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { homedir, platform, arch } from "node:os";
14
+ import { get } from "node:https";
15
+ import { execFileSync } from "node:child_process";
16
+
17
+ const REPO = "AutoDevJapan/GoDD-MCP-Alpha";
18
+ const BINARY_NAME = "godd-tk";
19
+ const VERSION_TAG = "godd-tk-v0.1.0";
20
+
21
+ const TARGETS = {
22
+ "darwin-x64": "godd-tk-x86_64-apple-darwin",
23
+ "darwin-arm64": "godd-tk-aarch64-apple-darwin",
24
+ "linux-x64": "godd-tk-x86_64-unknown-linux-musl",
25
+ "win32-x64": "godd-tk-x86_64-pc-windows-msvc.exe",
26
+ };
27
+
28
+ function getInstallDir() {
29
+ if (platform() === "win32") {
30
+ const localAppData = process.env.LOCALAPPDATA || join(homedir(), "AppData", "Local");
31
+ return join(localAppData, "godd-tk");
32
+ }
33
+ return join(homedir(), ".local", "bin");
34
+ }
35
+
36
+ function getTarget() {
37
+ const key = `${platform()}-${arch()}`;
38
+ return TARGETS[key];
39
+ }
40
+
41
+ function getBinaryPath(installDir) {
42
+ const ext = platform() === "win32" ? ".exe" : "";
43
+ return join(installDir, `${BINARY_NAME}${ext}`);
44
+ }
45
+
46
+ function download(url) {
47
+ return new Promise((resolve, reject) => {
48
+ const followRedirects = (url, redirectCount = 0) => {
49
+ if (redirectCount > 5) return reject(new Error("Too many redirects"));
50
+
51
+ get(url, (res) => {
52
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
53
+ return followRedirects(res.headers.location, redirectCount + 1);
54
+ }
55
+ if (res.statusCode !== 200) {
56
+ return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
57
+ }
58
+ resolve(res);
59
+ }).on("error", reject);
60
+ };
61
+ followRedirects(url);
62
+ });
63
+ }
64
+
65
+ async function main() {
66
+ const target = getTarget();
67
+ if (!target) {
68
+ console.log(`[godd-tk] No pre-built binary for ${platform()}-${arch()}, skipping install.`);
69
+ console.log(`[godd-tk] You can build from source: cd godd-mcp-alpha/godd-tk && cargo build --release`);
70
+ return;
71
+ }
72
+
73
+ const installDir = getInstallDir();
74
+ const binaryPath = getBinaryPath(installDir);
75
+
76
+ if (existsSync(binaryPath)) {
77
+ try {
78
+ const version = execFileSync(binaryPath, ["--version"], { encoding: "utf8" }).trim();
79
+ console.log(`[godd-tk] Already installed: ${version}`);
80
+ return;
81
+ } catch {
82
+ // corrupted binary, re-download
83
+ }
84
+ }
85
+
86
+ const url = `https://github.com/${REPO}/releases/download/${VERSION_TAG}/${target}`;
87
+ console.log(`[godd-tk] Downloading ${target}...`);
88
+
89
+ try {
90
+ mkdirSync(installDir, { recursive: true });
91
+
92
+ const tmpPath = `${binaryPath}.tmp`;
93
+ const stream = await download(url);
94
+ const file = createWriteStream(tmpPath);
95
+
96
+ await new Promise((resolve, reject) => {
97
+ stream.pipe(file);
98
+ file.on("finish", () => { file.close(); resolve(); });
99
+ file.on("error", reject);
100
+ });
101
+
102
+ if (existsSync(binaryPath)) unlinkSync(binaryPath);
103
+ renameSync(tmpPath, binaryPath);
104
+
105
+ if (platform() !== "win32") {
106
+ chmodSync(binaryPath, 0o755);
107
+ }
108
+
109
+ console.log(`[godd-tk] Installed to ${binaryPath}`);
110
+ console.log(`[godd-tk] Run 'godd-tk init --agent cursor' to set up hooks`);
111
+ } catch (err) {
112
+ console.log(`[godd-tk] Download failed: ${err.message}`);
113
+ console.log(`[godd-tk] You can build from source: cd godd-mcp-alpha/godd-tk && cargo build --release`);
114
+ try { unlinkSync(`${binaryPath}.tmp`); } catch {}
115
+ }
116
+ }
117
+
118
+ main().catch(console.error);