@autodevjapan/godd-mcp-alpha 1.30.0 → 1.31.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.30.0",
3
+ "version": "1.31.0",
4
4
  "type": "module",
5
5
  "description": "GoDD MCP α Server — AI Prompt Delivery System for Cursor IDE",
6
6
  "license": "UNLICENSED",
@@ -4,15 +4,14 @@
4
4
  * GoDD Token Killer — postinstall script
5
5
  *
6
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).
7
+ * from GitHub Releases via `gh` CLI (supports private repos) and
8
+ * places it in ~/.local/bin/ (Unix) or %LOCALAPPDATA%/godd-tk/ (Windows).
9
9
  */
10
10
 
11
- import { createWriteStream, mkdirSync, chmodSync, existsSync, renameSync, unlinkSync } from "node:fs";
11
+ import { mkdirSync, chmodSync, existsSync, renameSync, unlinkSync } from "node:fs";
12
12
  import { join } from "node:path";
13
13
  import { homedir, platform, arch } from "node:os";
14
- import { get } from "node:https";
15
- import { execFileSync } from "node:child_process";
14
+ import { execFileSync, execSync } from "node:child_process";
16
15
 
17
16
  const REPO = "AutoDevJapan/GoDD-MCP-Alpha";
18
17
  const BINARY_NAME = "godd-tk";
@@ -43,30 +42,20 @@ function getBinaryPath(installDir) {
43
42
  return join(installDir, `${BINARY_NAME}${ext}`);
44
43
  }
45
44
 
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
- });
45
+ function isGhAvailable() {
46
+ try {
47
+ execFileSync("gh", ["--version"], { stdio: "ignore", timeout: 5000 });
48
+ return true;
49
+ } catch {
50
+ return false;
51
+ }
63
52
  }
64
53
 
65
54
  async function main() {
66
55
  const target = getTarget();
67
56
  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`);
57
+ console.log(`[godd-tk] No pre-built binary for ${platform()}-${arch()}, skipping.`);
58
+ console.log(`[godd-tk] Build from source: cd godd-mcp-alpha/godd-tk && cargo build --release`);
70
59
  return;
71
60
  }
72
61
 
@@ -83,35 +72,54 @@ async function main() {
83
72
  }
84
73
  }
85
74
 
86
- const url = `https://github.com/${REPO}/releases/download/${VERSION_TAG}/${target}`;
87
- console.log(`[godd-tk] Downloading ${target}...`);
75
+ if (!isGhAvailable()) {
76
+ console.log(`[godd-tk] GitHub CLI (gh) not found — required for private repo download.`);
77
+ console.log(`[godd-tk] Install gh: https://cli.github.com/ then run this script again.`);
78
+ console.log(`[godd-tk] Or build from source: cd godd-mcp-alpha/godd-tk && cargo build --release`);
79
+ return;
80
+ }
81
+
82
+ console.log(`[godd-tk] Downloading ${target} via gh CLI...`);
88
83
 
89
84
  try {
90
85
  mkdirSync(installDir, { recursive: true });
91
86
 
92
- const tmpPath = `${binaryPath}.tmp`;
93
- const stream = await download(url);
94
- const file = createWriteStream(tmpPath);
87
+ const tmpDir = join(installDir, ".godd-tk-tmp");
88
+ mkdirSync(tmpDir, { recursive: true });
95
89
 
96
- await new Promise((resolve, reject) => {
97
- stream.pipe(file);
98
- file.on("finish", () => { file.close(); resolve(); });
99
- file.on("error", reject);
100
- });
90
+ execSync(
91
+ `gh release download ${VERSION_TAG} --repo ${REPO} --pattern "${target}" --dir "${tmpDir}" --clobber`,
92
+ { stdio: "pipe", timeout: 60000 }
93
+ );
94
+
95
+ const downloadedPath = join(tmpDir, target);
96
+ if (!existsSync(downloadedPath)) {
97
+ throw new Error(`Downloaded file not found at ${downloadedPath}`);
98
+ }
101
99
 
102
100
  if (existsSync(binaryPath)) unlinkSync(binaryPath);
103
- renameSync(tmpPath, binaryPath);
101
+ renameSync(downloadedPath, binaryPath);
104
102
 
105
103
  if (platform() !== "win32") {
106
104
  chmodSync(binaryPath, 0o755);
107
105
  }
108
106
 
107
+ // Clean up temp dir
108
+ try { unlinkSync(tmpDir); } catch {}
109
+
109
110
  console.log(`[godd-tk] Installed to ${binaryPath}`);
110
111
  console.log(`[godd-tk] Run 'godd-tk init --agent cursor' to set up hooks`);
112
+
113
+ // Add to PATH hint for Windows
114
+ if (platform() === "win32") {
115
+ const pathDirs = (process.env.PATH || "").toLowerCase().split(";");
116
+ if (!pathDirs.includes(installDir.toLowerCase())) {
117
+ console.log(`[godd-tk] Add ${installDir} to your PATH for global access`);
118
+ }
119
+ }
111
120
  } catch (err) {
112
121
  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 {}
122
+ console.log(`[godd-tk] Build from source: cd godd-mcp-alpha/godd-tk && cargo build --release`);
115
123
  }
116
124
  }
117
125