@qinghuangniao/heron-connect 1.4.0 → 1.4.1

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/README.md CHANGED
@@ -27,16 +27,28 @@ Repository: https://github.com/janostudio/heron-connect
27
27
 
28
28
  Full documentation: see the repository README and `docs/` directory.
29
29
 
30
+ ## Distribution
31
+
32
+ The binary ships in per-platform npm packages. The main package only contains the
33
+ wrapper scripts; `optionalDependencies` point at `@qinghuangniao/heron-connect-<platform>`
34
+ (same package name, pre-release version like `1.4.0-linux-x64`), and npm installs only
35
+ the package matching the current `os`/`cpu`. Installing therefore goes through the npm
36
+ registry (mirrors work) instead of downloading from GitHub Releases.
37
+
30
38
  ## Publish Flow
31
39
 
32
- Running `npm publish` in this directory triggers `prepublishOnly`, which:
40
+ Run from the repository root:
41
+
42
+ ```bash
43
+ node npm/publish.js # build missing artifacts, publish platform packages, then the main package
44
+ node npm/publish.js --dry-run # pack and verify without publishing
45
+ ```
33
46
 
34
- 1. builds missing release archives into `../dist`
35
- 2. uses `gh` to create or update the GitHub release `v<package-version>`
36
- 3. uploads required archives and `checksums.txt` before publishing to npm
47
+ `release-assets.js ensure` still uploads archives to the GitHub release for manual
48
+ downloads, but that release is no longer required for `npm install` to work.
37
49
 
38
50
  Prerequisites:
39
51
 
40
- - `gh auth login`
52
+ - `npm whoami` succeeds (token in `npm/.npmrc` or the user config)
53
+ - `gh auth login` (only when syncing GitHub release archives)
41
54
  - Go build environment available locally
42
- - release repository push permission on `janostudio/heron-connect`
package/install.js CHANGED
@@ -10,6 +10,7 @@ const http = require("http");
10
10
  const zlib = require("zlib");
11
11
 
12
12
  const PACKAGE = require("./package.json");
13
+ const { resolveBinary } = require("./lib/resolve-binary");
13
14
  const VERSION = `v${PACKAGE.version}`;
14
15
  const NAME = "heron-connect";
15
16
 
@@ -181,6 +182,14 @@ async function main() {
181
182
  }
182
183
  }
183
184
 
185
+ // 平台包已经带二进制时不再下载:安装阶段 npm 按 os/cpu 只拉当前平台的一份,
186
+ // 走 registry(国内可用镜像),比从 GitHub Releases 下载稳定得多。
187
+ const resolved = resolveBinary();
188
+ if (resolved.binaryPath) {
189
+ console.log(`[heron-connect] Binary provided by npm platform package: ${resolved.binaryPath}`);
190
+ return;
191
+ }
192
+
184
193
  const urls = getDownloadURLs(filename);
185
194
  const data = await download(urls);
186
195
 
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ // 解析当前平台可用的连接器二进制。
4
+ //
5
+ // 解析顺序:
6
+ // 1. 主包 bin/ 下的 heron-connect。本地构建(make build-local)直接把产物
7
+ // 覆盖在这里,优先保证开发时用的是未发布版本。
8
+ // 2. npm 平台包 @qinghuangniao/heron-connect-<platform>。发布时每个平台的
9
+ // 二进制打成独立包,安装时 npm 按平台包的 os/cpu 字段只拉当前平台那一份,
10
+ // 走 registry(国内可用镜像),不依赖 GitHub Releases 的连通性。
11
+ // 3. 都没有时返回 binaryPath=null,由调用方决定回退下载或报错。
12
+
13
+ const fs = require("fs");
14
+ const path = require("path");
15
+
16
+ const APP = "heron-connect";
17
+
18
+ const PLATFORM_KEYS = {
19
+ "linux-x64": true,
20
+ "linux-arm64": true,
21
+ "darwin-x64": true,
22
+ "darwin-arm64": true,
23
+ "win32-x64": true,
24
+ "win32-arm64": true,
25
+ };
26
+
27
+ const PLATFORM_PACKAGE_PREFIX = "@qinghuangniao/heron-connect-";
28
+
29
+ function currentPlatformKey() {
30
+ return `${process.platform}-${process.arch}`;
31
+ }
32
+
33
+ function platformPackageName(platformKey) {
34
+ return PLATFORM_PACKAGE_PREFIX + platformKey;
35
+ }
36
+
37
+ function binaryNameFor(platformKey) {
38
+ return platformKey.startsWith("win32") ? `${APP}.exe` : APP;
39
+ }
40
+
41
+ // resolveBinary 返回 { supported, platformKey, binaryPath, source, packageName }。
42
+ // binaryPath 为 null 表示当前平台受支持但二进制还没就位。
43
+ function resolveBinary() {
44
+ const platformKey = currentPlatformKey();
45
+ if (!PLATFORM_KEYS[platformKey]) {
46
+ return { supported: false, platformKey, binaryPath: null, source: null };
47
+ }
48
+
49
+ const binaryName = binaryNameFor(platformKey);
50
+ const localPath = path.join(__dirname, "..", "bin", binaryName);
51
+ if (fs.existsSync(localPath)) {
52
+ return { supported: true, platformKey, binaryPath: localPath, source: "local" };
53
+ }
54
+
55
+ const packageName = platformPackageName(platformKey);
56
+ try {
57
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
58
+ const candidate = path.join(path.dirname(packageJsonPath), "bin", binaryName);
59
+ if (fs.existsSync(candidate)) {
60
+ return { supported: true, platformKey, binaryPath: candidate, source: "platform-package", packageName };
61
+ }
62
+ } catch (err) {
63
+ // 平台包没装:用了 --no-optional、registry 镜像还没同步到当前版本,
64
+ // 或者不是通过 npm 安装的。交给调用方回退。
65
+ }
66
+
67
+ return { supported: true, platformKey, binaryPath: null, source: null };
68
+ }
69
+
70
+ module.exports = { resolveBinary, currentPlatformKey, platformPackageName, binaryNameFor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qinghuangniao/heron-connect",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Multi-IM agent bridge connecting AI coding agents to messaging platforms",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -27,9 +27,6 @@
27
27
  "heron-connect": "run.js"
28
28
  },
29
29
  "scripts": {
30
- "prepare-release": "node release-assets.js build",
31
- "sync-release": "node release-assets.js ensure",
32
- "prepublishOnly": "node release-assets.js ensure",
33
30
  "postinstall": "node install.js"
34
31
  },
35
32
  "publishConfig": {
@@ -39,6 +36,15 @@
39
36
  "install.js",
40
37
  "run.js",
41
38
  "release-assets.js",
39
+ "lib/resolve-binary.js",
42
40
  "README.md"
43
- ]
41
+ ],
42
+ "optionalDependencies": {
43
+ "@qinghuangniao/heron-connect-linux-x64": "npm:@qinghuangniao/heron-connect@1.4.1-linux-x64",
44
+ "@qinghuangniao/heron-connect-linux-arm64": "npm:@qinghuangniao/heron-connect@1.4.1-linux-arm64",
45
+ "@qinghuangniao/heron-connect-darwin-x64": "npm:@qinghuangniao/heron-connect@1.4.1-darwin-x64",
46
+ "@qinghuangniao/heron-connect-darwin-arm64": "npm:@qinghuangniao/heron-connect@1.4.1-darwin-arm64",
47
+ "@qinghuangniao/heron-connect-win32-x64": "npm:@qinghuangniao/heron-connect@1.4.1-win32-x64",
48
+ "@qinghuangniao/heron-connect-win32-arm64": "npm:@qinghuangniao/heron-connect@1.4.1-win32-arm64"
49
+ }
44
50
  }
package/run.js CHANGED
@@ -4,14 +4,11 @@
4
4
 
5
5
  const { execFileSync, execSync } = require("child_process");
6
6
  const path = require("path");
7
- const fs = require("fs");
8
7
 
9
8
  const PACKAGE = require("./package.json");
9
+ const { resolveBinary, platformPackageName } = require("./lib/resolve-binary");
10
+
10
11
  const EXPECTED_VER = PACKAGE.version; // e.g. "1.1.0-beta.4"
11
- const NAME = "heron-connect";
12
- const binDir = path.join(__dirname, "bin");
13
- const ext = process.platform === "win32" ? ".exe" : "";
14
- const binaryPath = path.join(binDir, NAME + ext);
15
12
 
16
13
  // parseVersion splits "1.2.3-beta.1" into { nums: [1,2,3], preTag: "beta", preNum: 1 }
17
14
  function parseVersion(v) {
@@ -43,8 +40,7 @@ function isNewerOrEqual(installed, expected) {
43
40
  return a.preNum >= b.preNum;
44
41
  }
45
42
 
46
- function needsReinstall() {
47
- if (!fs.existsSync(binaryPath)) return true;
43
+ function needsReinstall(binaryPath) {
48
44
  try {
49
45
  const out = execFileSync(binaryPath, ["--version"], { encoding: "utf8", timeout: 5000 });
50
46
  if (out.includes(EXPECTED_VER)) return false;
@@ -57,7 +53,15 @@ function needsReinstall() {
57
53
  }
58
54
  }
59
55
 
60
- if (needsReinstall()) {
56
+ let resolved = resolveBinary();
57
+
58
+ if (!resolved.supported) {
59
+ console.error(`[heron-connect] Unsupported platform: ${resolved.platformKey}`);
60
+ console.error("[heron-connect] Supported: linux/darwin/windows x64/arm64");
61
+ process.exit(1);
62
+ }
63
+
64
+ if (!resolved.binaryPath || needsReinstall(resolved.binaryPath)) {
61
65
  console.log(`[heron-connect] Binary missing or outdated, installing v${EXPECTED_VER}...`);
62
66
  try {
63
67
  execSync("node " + JSON.stringify(path.join(__dirname, "install.js")), {
@@ -68,10 +72,19 @@ if (needsReinstall()) {
68
72
  console.error("[heron-connect] Auto-install failed. Run manually: npm uninstall -g @qinghuangniao/heron-connect && npm install -g @qinghuangniao/heron-connect");
69
73
  process.exit(1);
70
74
  }
75
+ resolved = resolveBinary();
76
+ }
77
+
78
+ if (!resolved.binaryPath) {
79
+ console.error(`[heron-connect] Missing binary for ${resolved.platformKey}.`);
80
+ console.error(`[heron-connect] Expected npm platform package: ${platformPackageName(resolved.platformKey)}`);
81
+ console.error("[heron-connect] Reinstall with: npm install -g @qinghuangniao/heron-connect@latest");
82
+ console.error("[heron-connect] If you installed with --no-optional, drop that flag so the platform package is installed.");
83
+ process.exit(1);
71
84
  }
72
85
 
73
86
  try {
74
- execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
87
+ execFileSync(resolved.binaryPath, process.argv.slice(2), { stdio: "inherit" });
75
88
  } catch (err) {
76
89
  process.exit(err.status || 1);
77
90
  }