homegraph 1.5.0 → 1.5.2

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.
Files changed (213) hide show
  1. package/dist/bin/command-supervision.d.ts.map +1 -1
  2. package/dist/bin/command-supervision.js +7 -4
  3. package/dist/bin/command-supervision.js.map +1 -1
  4. package/dist/extraction/index.d.ts +1 -1
  5. package/dist/extraction/index.d.ts.map +1 -1
  6. package/dist/extraction/index.js +54 -43
  7. package/dist/extraction/index.js.map +1 -1
  8. package/dist/extraction/languages/arkts.d.ts +69 -12
  9. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  10. package/dist/extraction/languages/arkts.js +739 -86
  11. package/dist/extraction/languages/arkts.js.map +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/mcp/diff-impact.d.ts +131 -0
  16. package/dist/mcp/diff-impact.d.ts.map +1 -0
  17. package/dist/mcp/diff-impact.js +385 -0
  18. package/dist/mcp/diff-impact.js.map +1 -0
  19. package/dist/mcp/liveness-watchdog.d.ts +18 -0
  20. package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  21. package/dist/mcp/liveness-watchdog.js +134 -22
  22. package/dist/mcp/liveness-watchdog.js.map +1 -1
  23. package/dist/mcp/server-instructions.d.ts +1 -1
  24. package/dist/mcp/server-instructions.d.ts.map +1 -1
  25. package/dist/mcp/server-instructions.js +2 -0
  26. package/dist/mcp/server-instructions.js.map +1 -1
  27. package/dist/mcp/tools.d.ts +21 -5
  28. package/dist/mcp/tools.d.ts.map +1 -1
  29. package/dist/mcp/tools.js +305 -55
  30. package/dist/mcp/tools.js.map +1 -1
  31. package/dist/resolution/callback-synthesizer.d.ts +2 -1
  32. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  33. package/dist/resolution/callback-synthesizer.js +153 -53
  34. package/dist/resolution/callback-synthesizer.js.map +1 -1
  35. package/dist/resolution/frameworks/arkts-entry.d.ts.map +1 -1
  36. package/dist/resolution/frameworks/arkts-entry.js +20 -9
  37. package/dist/resolution/frameworks/arkts-entry.js.map +1 -1
  38. package/dist/resolution/index.d.ts.map +1 -1
  39. package/dist/resolution/index.js +1 -1
  40. package/dist/resolution/index.js.map +1 -1
  41. package/dist/resolution/memory-budget.d.ts +33 -0
  42. package/dist/resolution/memory-budget.d.ts.map +1 -1
  43. package/dist/resolution/memory-budget.js +58 -0
  44. package/dist/resolution/memory-budget.js.map +1 -1
  45. package/dist/resolution/resolver-pool.d.ts +2 -0
  46. package/dist/resolution/resolver-pool.d.ts.map +1 -1
  47. package/dist/resolution/resolver-pool.js +4 -0
  48. package/dist/resolution/resolver-pool.js.map +1 -1
  49. package/dist/ui/shimmer-progress.d.ts.map +1 -1
  50. package/dist/ui/shimmer-progress.js +4 -1
  51. package/dist/ui/shimmer-progress.js.map +1 -1
  52. package/package.json +4 -5
  53. package/dist/arkts/ohos-api-index.d.ts +0 -15
  54. package/dist/arkts/ohos-api-index.d.ts.map +0 -1
  55. package/dist/arkts/ohos-api-index.js +0 -190
  56. package/dist/arkts/ohos-api-index.js.map +0 -1
  57. package/dist/arkts/ohos-sdk-input.d.ts +0 -36
  58. package/dist/arkts/ohos-sdk-input.d.ts.map +0 -1
  59. package/dist/arkts/ohos-sdk-input.js +0 -214
  60. package/dist/arkts/ohos-sdk-input.js.map +0 -1
  61. package/dist/extraction/languages/arkts-state-decorators.d.ts +0 -13
  62. package/dist/extraction/languages/arkts-state-decorators.d.ts.map +0 -1
  63. package/dist/extraction/languages/arkts-state-decorators.js +0 -26
  64. package/dist/extraction/languages/arkts-state-decorators.js.map +0 -1
  65. package/dist/extraction/languages/arkts-viewtree.d.ts +0 -24
  66. package/dist/extraction/languages/arkts-viewtree.d.ts.map +0 -1
  67. package/dist/extraction/languages/arkts-viewtree.js +0 -148
  68. package/dist/extraction/languages/arkts-viewtree.js.map +0 -1
  69. package/dist/extraction/languages/ohos-api-consumer.d.ts +0 -34
  70. package/dist/extraction/languages/ohos-api-consumer.d.ts.map +0 -1
  71. package/dist/extraction/languages/ohos-api-consumer.js +0 -283
  72. package/dist/extraction/languages/ohos-api-consumer.js.map +0 -1
  73. package/dist/reasoning/config.d.ts +0 -45
  74. package/dist/reasoning/config.d.ts.map +0 -1
  75. package/dist/reasoning/config.js +0 -171
  76. package/dist/reasoning/config.js.map +0 -1
  77. package/dist/reasoning/credentials.d.ts +0 -5
  78. package/dist/reasoning/credentials.d.ts.map +0 -1
  79. package/dist/reasoning/credentials.js +0 -83
  80. package/dist/reasoning/credentials.js.map +0 -1
  81. package/dist/reasoning/login.d.ts +0 -21
  82. package/dist/reasoning/login.d.ts.map +0 -1
  83. package/dist/reasoning/login.js +0 -85
  84. package/dist/reasoning/login.js.map +0 -1
  85. package/dist/reasoning/reasoner.d.ts +0 -43
  86. package/dist/reasoning/reasoner.d.ts.map +0 -1
  87. package/dist/reasoning/reasoner.js +0 -308
  88. package/dist/reasoning/reasoner.js.map +0 -1
  89. package/dist/spec/build/git-scanner.d.ts +0 -93
  90. package/dist/spec/build/git-scanner.d.ts.map +0 -1
  91. package/dist/spec/build/git-scanner.js +0 -254
  92. package/dist/spec/build/git-scanner.js.map +0 -1
  93. package/dist/spec/evolve/llm-client.d.ts +0 -50
  94. package/dist/spec/evolve/llm-client.d.ts.map +0 -1
  95. package/dist/spec/evolve/llm-client.js +0 -176
  96. package/dist/spec/evolve/llm-client.js.map +0 -1
  97. package/dist/spec/evolve/logic-checker.d.ts +0 -12
  98. package/dist/spec/evolve/logic-checker.d.ts.map +0 -1
  99. package/dist/spec/evolve/logic-checker.js +0 -24
  100. package/dist/spec/evolve/logic-checker.js.map +0 -1
  101. package/dist/spec/git-utils.d.ts +0 -8
  102. package/dist/spec/git-utils.d.ts.map +0 -1
  103. package/dist/spec/git-utils.js +0 -14
  104. package/dist/spec/git-utils.js.map +0 -1
  105. package/dist/spec/llm/index.d.ts +0 -3
  106. package/dist/spec/llm/index.d.ts.map +0 -1
  107. package/dist/spec/llm/index.js +0 -11
  108. package/dist/spec/llm/index.js.map +0 -1
  109. package/dist/spec/mine/clusterer.d.ts +0 -63
  110. package/dist/spec/mine/clusterer.d.ts.map +0 -1
  111. package/dist/spec/mine/clusterer.js +0 -904
  112. package/dist/spec/mine/clusterer.js.map +0 -1
  113. package/dist/spec/mine/progress-handler.d.ts +0 -22
  114. package/dist/spec/mine/progress-handler.d.ts.map +0 -1
  115. package/dist/spec/mine/progress-handler.js +0 -108
  116. package/dist/spec/mine/progress-handler.js.map +0 -1
  117. package/dist/spec/mine/progress.d.ts +0 -23
  118. package/dist/spec/mine/progress.d.ts.map +0 -1
  119. package/dist/spec/mine/progress.js +0 -12
  120. package/dist/spec/mine/progress.js.map +0 -1
  121. package/dist/spec/mining/diff-parser.d.ts +0 -33
  122. package/dist/spec/mining/diff-parser.d.ts.map +0 -1
  123. package/dist/spec/mining/diff-parser.js +0 -166
  124. package/dist/spec/mining/diff-parser.js.map +0 -1
  125. package/dist/spec/mining/git-scanner.d.ts +0 -103
  126. package/dist/spec/mining/git-scanner.d.ts.map +0 -1
  127. package/dist/spec/mining/git-scanner.js +0 -307
  128. package/dist/spec/mining/git-scanner.js.map +0 -1
  129. package/dist/spec/mining/pipeline.d.ts +0 -53
  130. package/dist/spec/mining/pipeline.d.ts.map +0 -1
  131. package/dist/spec/mining/pipeline.js +0 -178
  132. package/dist/spec/mining/pipeline.js.map +0 -1
  133. package/dist/spec/mining/scope-resolver.d.ts +0 -45
  134. package/dist/spec/mining/scope-resolver.d.ts.map +0 -1
  135. package/dist/spec/mining/scope-resolver.js +0 -103
  136. package/dist/spec/mining/scope-resolver.js.map +0 -1
  137. package/dist/spec/mining/spec-extractor.d.ts +0 -69
  138. package/dist/spec/mining/spec-extractor.d.ts.map +0 -1
  139. package/dist/spec/mining/spec-extractor.js +0 -369
  140. package/dist/spec/mining/spec-extractor.js.map +0 -1
  141. package/dist/spec/utils.d.ts +0 -155
  142. package/dist/spec/utils.d.ts.map +0 -1
  143. package/dist/spec/utils.js +0 -411
  144. package/dist/spec/utils.js.map +0 -1
  145. package/scripts/add-lang/bench.sh +0 -60
  146. package/scripts/add-lang/check-grammar.mjs +0 -75
  147. package/scripts/add-lang/dump-ast.mjs +0 -103
  148. package/scripts/add-lang/verify-extraction.mjs +0 -70
  149. package/scripts/agent-eval/ab-adoption.sh +0 -91
  150. package/scripts/agent-eval/ab-hook.sh +0 -86
  151. package/scripts/agent-eval/ab-impl.sh +0 -78
  152. package/scripts/agent-eval/ab-new-vs-baseline.sh +0 -102
  153. package/scripts/agent-eval/ab-sufficiency.sh +0 -78
  154. package/scripts/agent-eval/arms-F.sh +0 -21
  155. package/scripts/agent-eval/arms-matrix.sh +0 -37
  156. package/scripts/agent-eval/audit.sh +0 -68
  157. package/scripts/agent-eval/bench-readme.sh +0 -28
  158. package/scripts/agent-eval/bench-why-repo.sh +0 -22
  159. package/scripts/agent-eval/block-read-hook.sh +0 -19
  160. package/scripts/agent-eval/hook-settings.json +0 -15
  161. package/scripts/agent-eval/itrun.sh +0 -120
  162. package/scripts/agent-eval/offload-eval-3arm.sh +0 -72
  163. package/scripts/agent-eval/offload-eval-cost.mjs +0 -133
  164. package/scripts/agent-eval/offload-eval-effort.mjs +0 -108
  165. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +0 -25
  166. package/scripts/agent-eval/offload-eval-frontload.sh +0 -47
  167. package/scripts/agent-eval/offload-eval-ground-truth.json +0 -18
  168. package/scripts/agent-eval/offload-eval-hook.mjs +0 -84
  169. package/scripts/agent-eval/offload-eval-judge.mjs +0 -103
  170. package/scripts/agent-eval/offload-eval-matrix.sh +0 -20
  171. package/scripts/agent-eval/offload-eval-metrics.mjs +0 -94
  172. package/scripts/agent-eval/offload-eval-refs1.sh +0 -50
  173. package/scripts/agent-eval/offload-eval-setup.sh +0 -24
  174. package/scripts/agent-eval/offload-eval-styles.sh +0 -72
  175. package/scripts/agent-eval/offload-eval-summarize.mjs +0 -68
  176. package/scripts/agent-eval/offload-eval.md +0 -76
  177. package/scripts/agent-eval/parse-arms.mjs +0 -116
  178. package/scripts/agent-eval/parse-bench-readme.mjs +0 -84
  179. package/scripts/agent-eval/parse-run.mjs +0 -45
  180. package/scripts/agent-eval/parse-session.mjs +0 -93
  181. package/scripts/agent-eval/probe-context.mjs +0 -21
  182. package/scripts/agent-eval/probe-explore.mjs +0 -40
  183. package/scripts/agent-eval/probe-node.mjs +0 -20
  184. package/scripts/agent-eval/probe-sweep.mjs +0 -119
  185. package/scripts/agent-eval/probe-trace.mjs +0 -20
  186. package/scripts/agent-eval/redirect-read-hook.sh +0 -38
  187. package/scripts/agent-eval/repro-concurrent-explore.mjs +0 -119
  188. package/scripts/agent-eval/repro-daemon-clients.mjs +0 -125
  189. package/scripts/agent-eval/run-agent.sh +0 -34
  190. package/scripts/agent-eval/run-all.sh +0 -75
  191. package/scripts/agent-eval/run-arms.sh +0 -56
  192. package/scripts/agent-eval/seq-matrix.mjs +0 -137
  193. package/scripts/build-bundle.sh +0 -123
  194. package/scripts/exp_boundary_eval/README.md +0 -247
  195. package/scripts/exp_boundary_eval/_test_mcp_chain.py +0 -78
  196. package/scripts/exp_boundary_eval/_test_stdin.py +0 -8
  197. package/scripts/exp_boundary_eval/_utils.py +0 -1116
  198. package/scripts/exp_boundary_eval/analyze.py +0 -1313
  199. package/scripts/exp_boundary_eval/deveco_arm.py +0 -519
  200. package/scripts/exp_boundary_eval/run_all.py +0 -378
  201. package/scripts/exp_boundary_eval/run_one.py +0 -165
  202. package/scripts/exp_boundary_eval/run_session.py +0 -158
  203. package/scripts/exp_boundary_eval/setup.py +0 -120
  204. package/scripts/exp_boundary_eval/win_mcp_launcher.py +0 -73
  205. package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +0 -36
  206. package/scripts/exp_boundary_eval/win_node_launcher.py +0 -24
  207. package/scripts/extract-release-notes.mjs +0 -130
  208. package/scripts/local-install.sh +0 -41
  209. package/scripts/npm-sdk.js +0 -75
  210. package/scripts/npm-shim.js +0 -275
  211. package/scripts/ohos-sdk-publish.mjs +0 -133
  212. package/scripts/pack-npm.sh +0 -119
  213. package/scripts/prepare-release.mjs +0 -270
@@ -1,275 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- //
4
- // npm thin-installer launcher for HomeGraph.
5
- //
6
- // The heavy artifact (a vendored Node runtime + the app) ships as a per-platform
7
- // optionalDependency: homegraph-<platform>-<arch>. npm installs
8
- // only the one matching the host, via each package's `os`/`cpu` fields (the
9
- // esbuild pattern). This shim — run by the user's OWN Node — locates that bundle
10
- // and execs its launcher, so the real work always runs on the bundled Node 24
11
- // (with node:sqlite), regardless of the user's Node version. The user's Node is
12
- // only ever a launcher; even an ancient version can run this file.
13
- //
14
- // Self-heal (issue #303): some registries — notably the npmmirror/cnpm mirrors,
15
- // and some corporate proxies — don't reliably mirror the per-platform
16
- // optionalDependencies. npm treats an unfetchable optional dep as success and
17
- // silently skips it, so the bundle goes missing and every command fails. When
18
- // the installed bundle can't be resolved, this shim falls back to downloading
19
- // the matching bundle straight from GitHub Releases — the very archive
20
- // install.sh uses — into a cache dir, then runs that. Knobs:
21
- // HOMEGRAPH_NO_DOWNLOAD=1 disable the network fallback (print guidance)
22
- // HOMEGRAPH_INSTALL_DIR=DIR cache location (default: ~/.homegraph)
23
- // HOMEGRAPH_DOWNLOAD_BASE=URL release-download base (for mirrors/air-gapped)
24
- //
25
- // Wired up at release time as the main package's `bin`:
26
- // "bin": { "homegraph": "npm-shim.js" }
27
- // with the platform packages listed in `optionalDependencies`.
28
-
29
- var childProcess = require('child_process');
30
- var fs = require('fs');
31
- var os = require('os');
32
- var path = require('path');
33
-
34
- var target = process.platform + '-' + process.arch; // e.g. darwin-arm64, linux-x64
35
- var pkg = 'homegraph-' + target;
36
- var isWindows = process.platform === 'win32';
37
- var REPO = 'homegraph/homegraph';
38
-
39
- main().catch(function (e) {
40
- process.stderr.write('homegraph: ' + (e && e.message ? e.message : String(e)) + '\n');
41
- process.exit(1);
42
- });
43
-
44
- async function main() {
45
- // Happy path: the npm-installed optional dependency. Fall back to a download
46
- // when the registry didn't deliver it.
47
- var resolved = resolveInstalledBundle() || (await selfHealBundle());
48
- // Thread the MCP host's pid (our parent) down to the bundled server so its
49
- // orphan watchdog can poll the host directly. Without this, the server can
50
- // only watch THIS shim — and a shim killed during the server's first ~100ms
51
- // of startup used to leave the server orphaned forever (issue #1185). An
52
- // already-set value (an outer launcher) wins.
53
- var env = Object.assign({}, process.env);
54
- if (!env.HOMEGRAPH_HOST_PPID) env.HOMEGRAPH_HOST_PPID = String(process.ppid);
55
- var res = childProcess.spawnSync(resolved.command, resolved.args, { stdio: 'inherit', windowsHide: true, env: env });
56
- if (res.error) {
57
- process.stderr.write('homegraph: ' + res.error.message + '\n');
58
- process.exit(1);
59
- }
60
- process.exit(res.status === null ? 1 : res.status);
61
- }
62
-
63
- // Resolve the launcher from the installed per-platform optionalDependency.
64
- // Returns {command, args} or null if the package isn't installed.
65
- function resolveInstalledBundle() {
66
- try {
67
- if (isWindows) {
68
- // Modern Node refuses to spawn the bundle's .cmd directly (EINVAL, the
69
- // CVE-2024-27980 hardening on Node 24), so invoke the bundled node.exe
70
- // against the app entry point and pass --liftoff-only here.
71
- var nodeExe = require.resolve(pkg + '/node.exe');
72
- var entry = require.resolve(pkg + '/lib/dist/bin/homegraph.js');
73
- return { command: nodeExe, args: liftoff(entry) };
74
- }
75
- return { command: require.resolve(pkg + '/bin/homegraph'), args: process.argv.slice(2) };
76
- } catch (e) {
77
- return null;
78
- }
79
- }
80
-
81
- // Locate the launcher inside an extracted GitHub bundle directory (same
82
- // node/lib/bin layout as the npm platform package). Returns {command, args} or
83
- // null when the directory doesn't hold a usable bundle yet.
84
- function launcherIn(dir) {
85
- if (isWindows) {
86
- var nodeExe = path.join(dir, 'node.exe');
87
- var entry = path.join(dir, 'lib', 'dist', 'bin', 'homegraph.js');
88
- if (fs.existsSync(nodeExe) && fs.existsSync(entry)) {
89
- return { command: nodeExe, args: liftoff(entry) };
90
- }
91
- } else {
92
- var launcher = path.join(dir, 'bin', 'homegraph');
93
- if (fs.existsSync(launcher)) return { command: launcher, args: process.argv.slice(2) };
94
- }
95
- return null;
96
- }
97
-
98
- // --liftoff-only keeps tree-sitter's WASM grammars off V8's turboshaft tier to
99
- // avoid the Zone OOM on Node >= 22 (issues #293/#298). The unix bin/homegraph
100
- // launcher already passes it; on Windows we invoke node.exe directly so add it.
101
- function liftoff(entry) {
102
- return ['--liftoff-only', entry].concat(process.argv.slice(2));
103
- }
104
-
105
- // Download + cache the platform bundle from GitHub Releases. Returns
106
- // {command, args}; exits the process with guidance if it can't.
107
- async function selfHealBundle() {
108
- var version = readVersion();
109
- var bundlesDir = path.join(process.env.HOMEGRAPH_INSTALL_DIR || path.join(os.homedir(), '.homegraph'), 'bundles');
110
- var dest = path.join(bundlesDir, target + '-' + version);
111
-
112
- // Already downloaded by a previous run? Use it even when downloads are
113
- // disabled — HOMEGRAPH_NO_DOWNLOAD blocks fetching, not a cached bundle.
114
- var cached = launcherIn(dest);
115
- if (cached) { pruneOldBundles(bundlesDir, dest); return cached; }
116
-
117
- if (process.env.HOMEGRAPH_NO_DOWNLOAD) {
118
- fail('the network fallback is disabled (HOMEGRAPH_NO_DOWNLOAD is set).');
119
- }
120
-
121
- var asset = 'homegraph-' + target + (isWindows ? '.zip' : '.tar.gz');
122
- var base = process.env.HOMEGRAPH_DOWNLOAD_BASE || ('https://github.com/' + REPO + '/releases/download');
123
- var url = base + '/v' + version + '/' + asset;
124
-
125
- process.stderr.write(
126
- 'homegraph: platform bundle missing (registry did not provide ' + pkg + ').\n' +
127
- 'homegraph: downloading ' + asset + ' from GitHub Releases (' + version + ')...\n'
128
- );
129
-
130
- // Stage inside bundlesDir so the final rename is on the same filesystem (atomic,
131
- // no EXDEV across tmpfs). Strip the archive's top-level homegraph-<target>/ dir.
132
- fs.mkdirSync(bundlesDir, { recursive: true });
133
- var stage = fs.mkdtempSync(path.join(bundlesDir, '.dl-'));
134
- try {
135
- var archivePath = path.join(stage, asset);
136
- await download(url, archivePath, 6);
137
- await verifyChecksum(archivePath, asset, base, version);
138
- var extracted = path.join(stage, 'bundle');
139
- fs.mkdirSync(extracted);
140
- extract(archivePath, extracted);
141
-
142
- var raced = launcherIn(dest); // another process may have finished meanwhile
143
- if (raced) { rmrf(stage); return raced; }
144
- try {
145
- fs.renameSync(extracted, dest);
146
- } catch (e) {
147
- var other = launcherIn(dest); // lost the race but theirs is valid
148
- if (other) { rmrf(stage); return other; }
149
- throw e;
150
- }
151
- } catch (e) {
152
- rmrf(stage);
153
- fail('download failed (' + e.message + ').\n URL: ' + url);
154
- }
155
- rmrf(stage);
156
-
157
- var ready = launcherIn(dest);
158
- if (!ready) fail('downloaded bundle is missing its launcher under ' + dest + '.');
159
- pruneOldBundles(bundlesDir, dest);
160
- process.stderr.write('homegraph: bundle ready.\n');
161
- return ready;
162
- }
163
-
164
- function readVersion() {
165
- try {
166
- return require(path.join(__dirname, 'package.json')).version;
167
- } catch (e) {
168
- fail('could not read this package\'s version to locate a matching release.');
169
- }
170
- }
171
-
172
- // GET with manual redirect following (GitHub release URLs redirect to a CDN).
173
- function download(url, dest, redirectsLeft) {
174
- return new Promise(function (resolve, reject) {
175
- var https = require('https');
176
- // timeout is an idle/inactivity timeout — it won't kill a slow-but-progressing
177
- // download, only a stalled connection (so a blocked mirror fails fast with
178
- // guidance instead of hanging the user's command forever).
179
- var req = https.get(url, { headers: { 'User-Agent': 'homegraph-npm-shim' }, timeout: 30000 }, function (res) {
180
- var status = res.statusCode;
181
- if (status >= 300 && status < 400 && res.headers.location) {
182
- res.resume();
183
- if (redirectsLeft <= 0) { reject(new Error('too many redirects')); return; }
184
- download(new URL(res.headers.location, url).toString(), dest, redirectsLeft - 1).then(resolve, reject);
185
- return;
186
- }
187
- if (status !== 200) { res.resume(); reject(new Error('HTTP ' + status)); return; }
188
- var file = fs.createWriteStream(dest);
189
- res.on('error', reject);
190
- res.pipe(file);
191
- file.on('error', reject);
192
- file.on('finish', function () { file.close(function () { resolve(); }); });
193
- });
194
- req.on('timeout', function () { req.destroy(new Error('connection timed out')); });
195
- req.on('error', reject);
196
- });
197
- }
198
-
199
- // Best-effort integrity check. When the release publishes a SHA256SUMS file, the
200
- // downloaded archive MUST match its listed hash or we abort. When that file is
201
- // absent (older releases) or simply unreachable, we proceed — the archive still
202
- // arrived from GitHub over TLS. So tampering/corruption is caught, while a
203
- // missing checksum never breaks an install.
204
- async function verifyChecksum(archivePath, asset, base, version) {
205
- var sumsPath = archivePath + '.SHA256SUMS';
206
- try {
207
- await download(base + '/v' + version + '/SHA256SUMS', sumsPath, 6);
208
- } catch (e) {
209
- return; // not published / unreachable → skip
210
- }
211
- var expected = null;
212
- var lines = fs.readFileSync(sumsPath, 'utf8').split('\n');
213
- for (var i = 0; i < lines.length; i++) {
214
- var m = lines[i].trim().match(/^([0-9a-fA-F]{64})\s+\*?(.+)$/);
215
- if (m && path.basename(m[2].trim()) === asset) { expected = m[1].toLowerCase(); break; }
216
- }
217
- if (!expected) return; // asset not listed → nothing to check
218
- var actual = require('crypto').createHash('sha256').update(fs.readFileSync(archivePath)).digest('hex');
219
- if (actual !== expected) {
220
- throw new Error('checksum mismatch for ' + asset +
221
- ' (expected ' + expected.slice(0, 12) + '…, got ' + actual.slice(0, 12) + '…)');
222
- }
223
- process.stderr.write('homegraph: checksum verified.\n');
224
- }
225
-
226
- // Extract via the system tar — present on macOS, Linux, and Windows 10+
227
- // (bsdtar reads .zip too). No third-party dependency in the shim.
228
- function extract(archive, destDir) {
229
- var args = isWindows
230
- ? ['-xf', archive, '-C', destDir, '--strip-components=1']
231
- : ['-xzf', archive, '-C', destDir, '--strip-components=1'];
232
- var res = childProcess.spawnSync('tar', args, { stdio: 'ignore', windowsHide: true });
233
- if (res.error) throw new Error('tar unavailable: ' + res.error.message);
234
- if (res.status !== 0) throw new Error('tar exited ' + res.status);
235
- }
236
-
237
- function rmrf(p) {
238
- try { fs.rmSync(p, { recursive: true, force: true }); } catch (e) { /* best effort */ }
239
- }
240
-
241
- // Drop sibling bundles for OTHER versions of this same platform target, keeping
242
- // only keepDir. The self-heal cache otherwise accumulates a full ~50 MB bundle
243
- // per version forever (issue #1074). Best-effort: a locked/busy dir (a
244
- // concurrent run still mapping an older node.exe on Windows) just stays — rmrf
245
- // already swallows its own errors, and the readdir is guarded — so cleanup can
246
- // never break a working command. Only this target's "<target>-<version>" dirs
247
- // are touched; other platforms' bundles and the ".dl-*" staging dirs are left
248
- // alone.
249
- function pruneOldBundles(bundlesDir, keepDir) {
250
- var keep = path.basename(keepDir);
251
- try {
252
- var names = fs.readdirSync(bundlesDir);
253
- for (var i = 0; i < names.length; i++) {
254
- var name = names[i];
255
- if (name === keep) continue;
256
- if (name.indexOf(target + '-') !== 0) continue;
257
- rmrf(path.join(bundlesDir, name));
258
- }
259
- } catch (e) { /* best effort — never break a working run over cleanup */ }
260
- }
261
-
262
- function fail(reason) {
263
- process.stderr.write(
264
- 'homegraph: no prebuilt bundle for ' + target + '.\n' +
265
- (reason ? 'homegraph: ' + reason + '\n' : '') +
266
- 'Expected the optional package ' + pkg + ' to be installed.\n' +
267
- 'A registry mirror (e.g. npmmirror/cnpm) that did not mirror the per-platform\n' +
268
- 'package is the usual cause. Fixes:\n' +
269
- ' - install from the official registry:\n' +
270
- ' npm i -g homegraph --registry=https://registry.npmjs.org\n' +
271
- ' - or use the standalone installer (no Node required):\n' +
272
- ' curl -fsSL https://raw.githubusercontent.com/' + REPO + '/main/install.sh | sh\n'
273
- );
274
- process.exit(1);
275
- }
@@ -1,133 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Build and optionally publish homegraph-ohos-api-db-<version> (one npm package per API version).
4
- *
5
- * Usage:
6
- * node scripts/ohos-sdk-publish.mjs <zip-or-dir> [version] [--dry-run] [--no-publish]
7
- */
8
- import * as fs from 'fs';
9
- import * as path from 'path';
10
- import { fileURLToPath } from 'url';
11
- import {
12
- resolveOhosSdkInput,
13
- ohosApiDbFilename,
14
- ohosApiDbPackageName,
15
- indexOhosApiDb,
16
- } from '../dist/extraction/languages/arkts.js';
17
-
18
- const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
19
-
20
- function parseArgs(argv) {
21
- const positional = [];
22
- const flags = new Set();
23
- for (let i = 2; i < argv.length; i++) {
24
- const arg = argv[i];
25
- if (arg.startsWith('--')) flags.add(arg);
26
- else positional.push(arg);
27
- }
28
- return {
29
- input: positional[0] ?? '',
30
- version: positional[1] ?? '',
31
- dryRun: flags.has('--dry-run'),
32
- noPublish: flags.has('--no-publish'),
33
- };
34
- }
35
-
36
- function buildNpmPackage(version, dbPath, outDir) {
37
- const dbName = ohosApiDbFilename(version);
38
- const pkgName = ohosApiDbPackageName(version);
39
- fs.rmSync(outDir, { recursive: true, force: true });
40
- fs.mkdirSync(path.join(outDir, 'scripts'), { recursive: true });
41
- fs.copyFileSync(dbPath, path.join(outDir, dbName));
42
-
43
- const postinstall = `#!/usr/bin/env node
44
- 'use strict';
45
- const fs = require('fs');
46
- const path = require('path');
47
- const os = require('os');
48
- const dbName = ${JSON.stringify(dbName)};
49
- const src = path.join(__dirname, '..', dbName);
50
- const dest = path.join(os.homedir(), '.homegraph', 'api', dbName);
51
- if (!fs.existsSync(src)) process.exit(0);
52
- fs.mkdirSync(path.dirname(dest), { recursive: true });
53
- fs.copyFileSync(src, dest);
54
- `;
55
- fs.writeFileSync(path.join(outDir, 'scripts', 'postinstall.js'), postinstall, { mode: 0o755 });
56
- fs.writeFileSync(
57
- path.join(outDir, 'package.json'),
58
- JSON.stringify(
59
- {
60
- name: pkgName,
61
- version: '1.0.0',
62
- description: `Prebuilt HomeGraph OHOS API database for SDK ${version}`,
63
- license: 'MIT',
64
- files: [dbName, 'scripts/postinstall.js'],
65
- scripts: { postinstall: 'node scripts/postinstall.js' },
66
- homegraph: { ohosApiVersion: version, dbFile: dbName },
67
- },
68
- null,
69
- 2
70
- ) + '\n'
71
- );
72
- return pkgName;
73
- }
74
-
75
- const { input, version, dryRun, noPublish } = parseArgs(process.argv);
76
- if (!input) {
77
- console.error('Usage: node scripts/ohos-sdk-publish.mjs <zip-or-dir> [version] [--dry-run] [--no-publish]');
78
- process.exit(1);
79
- }
80
-
81
- if (!fs.existsSync(path.join(ROOT, 'dist/extraction/languages/arkts.js'))) {
82
- console.error('[ohos-sdk-publish] dist not built — run npm run build first');
83
- process.exit(1);
84
- }
85
-
86
- const resolved = resolveOhosSdkInput({
87
- inputPath: path.resolve(input),
88
- versionOverride: version || undefined,
89
- });
90
-
91
- const dbPath = path.join(
92
- fs.mkdtempSync(path.join(path.dirname(resolved.sdkHome), '.hg-ohos-pack-')),
93
- ohosApiDbFilename(resolved.version)
94
- );
95
- const pkgDir = path.join(path.dirname(dbPath), 'npm-package');
96
-
97
- try {
98
- process.stderr.write(`[ohos-sdk-publish] indexing ${resolved.version} …\n`);
99
- const result = await indexOhosApiDb({
100
- sdkHome: resolved.sdkHome,
101
- version: resolved.version,
102
- outputPath: dbPath,
103
- onProgress: (p) => {
104
- if (p.phase === 'arkts-batch') {
105
- const label = p.subphase === 'scene' ? 'Scene' : 'Persist';
106
- process.stderr.write(`\r${label}: ${p.current}/${p.total}`.padEnd(40));
107
- }
108
- },
109
- });
110
- process.stderr.write('\n');
111
- if (!result.success) {
112
- for (const err of result.errors.filter((e) => e.severity === 'error')) console.error(err.message);
113
- process.exit(1);
114
- }
115
-
116
- const pkgName = buildNpmPackage(resolved.version, dbPath, pkgDir);
117
- console.log(`[ohos-sdk-publish] package: ${pkgName} → ${pkgDir} (${result.nodesCreated} nodes)`);
118
-
119
- if (dryRun || noPublish) {
120
- console.log('[ohos-sdk-publish] skipping npm publish');
121
- process.exit(0);
122
- }
123
- if (!process.env.NPM_TOKEN) {
124
- console.error('[ohos-sdk-publish] NPM_TOKEN not set — package built, not published');
125
- process.exit(0);
126
- }
127
-
128
- const { execFileSync } = await import('child_process');
129
- execFileSync('npm', ['publish', '--access', 'public'], { cwd: pkgDir, stdio: 'inherit' });
130
- console.log(`[ohos-sdk-publish] published ${pkgName}`);
131
- } finally {
132
- resolved.cleanup?.();
133
- }
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Assemble the npm thin-installer packages from built bundles (esbuild pattern).
4
- #
5
- # Produces, under release/npm/:
6
- # homegraph-<target>/ one per built bundle — the vendored Node + app, tagged
7
- # with os/cpu so npm installs only the matching one.
8
- # main/ the homegraph shim package: a tiny bin
9
- # that execs the matching platform bundle, with every
10
- # platform package in optionalDependencies.
11
- #
12
- # The release pipeline then `npm publish`es each dir. This does NOT touch the
13
- # repo's package.json — the dev/from-source path keeps working; the *published*
14
- # main package's shape is generated here.
15
- #
16
- # Prereq: run build-bundle.sh for each target first (release/homegraph-*.tar.gz).
17
- # Usage: scripts/pack-npm.sh [version] (default: version from package.json)
18
- set -euo pipefail
19
-
20
- ROOT="$(cd "$(dirname "$0")/.." && pwd)"
21
- VERSION="${1:-$(node -p "require('$ROOT/package.json').version")}"
22
- SCOPE="@colbymchenry"
23
- REL="$ROOT/release"
24
- NPM="$REL/npm"
25
-
26
- rm -rf "$NPM"
27
- mkdir -p "$NPM/main"
28
-
29
- shopt -s nullglob
30
- archives=("$REL"/homegraph-*.tar.gz "$REL"/homegraph-*.zip)
31
- [ ${#archives[@]} -gt 0 ] || { echo "[pack-npm] no bundles in $REL — run build-bundle.sh first" >&2; exit 1; }
32
-
33
- targets=()
34
- for archive in "${archives[@]}"; do
35
- fname="$(basename "$archive")"
36
- case "$fname" in
37
- *.tar.gz) base="${fname%.tar.gz}" ;; # homegraph-<target>
38
- *.zip) base="${fname%.zip}" ;;
39
- esac
40
- target="${base#homegraph-}" # <target>, e.g. darwin-arm64 / win32-x64
41
- os="${target%-*}" # darwin | linux | win32
42
- arch="${target##*-}" # arm64 | x64
43
- pkgdir="$NPM/$base"
44
- mkdir -p "$pkgdir"
45
- case "$fname" in
46
- *.zip)
47
- tmpx="$(mktemp -d)"
48
- unzip -q "$archive" -d "$tmpx"
49
- mv "$tmpx/homegraph-${target}"/* "$pkgdir"/
50
- rm -rf "$tmpx"
51
- nodefile="node.exe"
52
- ;;
53
- *)
54
- tar -xzf "$archive" -C "$pkgdir" --strip-components=1
55
- nodefile="node"
56
- ;;
57
- esac
58
- VERSION="$VERSION" SCOPE="$SCOPE" TARGET="$target" OSV="$os" ARCHV="$arch" NODEFILE="$nodefile" \
59
- node -e '
60
- const fs=require("fs");
61
- fs.writeFileSync(process.argv[1], JSON.stringify({
62
- name: `${process.env.SCOPE}/homegraph-${process.env.TARGET}`,
63
- version: process.env.VERSION,
64
- description: `HomeGraph self-contained bundle for ${process.env.TARGET}`,
65
- os: [process.env.OSV], cpu: [process.env.ARCHV],
66
- files: [process.env.NODEFILE, "lib", "bin"],
67
- license: "MIT"
68
- }, null, 2) + "\n");
69
- ' "$pkgdir/package.json"
70
- targets+=("$target")
71
- echo "[pack-npm] ${SCOPE}/homegraph-${target}@${VERSION}"
72
- done
73
-
74
- # Main shim package.
75
- # npm-shim.js CLI/MCP launcher (execs the bundled Node) — the `bin`.
76
- # npm-sdk.js programmatic/embedded entry (#354): re-exports the installed
77
- # platform bundle's compiled library — the `main`.
78
- # dist/ the .d.ts tree only (types). The runtime .js stays in the
79
- # per-platform bundle so its deps aren't duplicated here.
80
- cp "$ROOT/scripts/npm-shim.js" "$NPM/main/npm-shim.js"
81
- cp "$ROOT/scripts/npm-sdk.js" "$NPM/main/npm-sdk.js"
82
- [ -f "$ROOT/README.md" ] && cp "$ROOT/README.md" "$NPM/main/README.md"
83
-
84
- # Ship the type declarations so `types`/`exports.types` resolve. Built from this
85
- # same release, so they can't skew from the runtime npm-sdk.js re-exports.
86
- [ -f "$ROOT/dist/index.d.ts" ] || ( echo "[pack-npm] building dist for .d.ts" >&2 && cd "$ROOT" && npm run build >/dev/null )
87
- ROOT="$ROOT" DEST="$NPM/main" node -e '
88
- const fs=require("fs"), path=require("path");
89
- const src=path.join(process.env.ROOT,"dist"), dest=path.join(process.env.DEST,"dist");
90
- fs.cpSync(src, dest, { recursive:true, filter(s){
91
- try { return fs.statSync(s).isDirectory() || s.endsWith(".d.ts"); } catch (e) { return false; }
92
- }});
93
- '
94
-
95
- VERSION="$VERSION" SCOPE="$SCOPE" TARGETS="${targets[*]}" \
96
- node -e '
97
- const fs=require("fs");
98
- const opt={};
99
- for (const t of process.env.TARGETS.split(/\s+/).filter(Boolean))
100
- opt[`${process.env.SCOPE}/homegraph-${t}`]=process.env.VERSION;
101
- fs.writeFileSync(process.argv[1], JSON.stringify({
102
- name: `${process.env.SCOPE}/homegraph`,
103
- version: process.env.VERSION,
104
- description: "Local-first code intelligence for AI agents (MCP). Self-contained — bundles its own runtime.",
105
- bin: { homegraph: "npm-shim.js" },
106
- main: "npm-sdk.js",
107
- types: "dist/index.d.ts",
108
- exports: {
109
- ".": { types: "./dist/index.d.ts", default: "./npm-sdk.js" },
110
- "./package.json": "./package.json"
111
- },
112
- optionalDependencies: opt,
113
- files: ["npm-shim.js","npm-sdk.js","dist","README.md"],
114
- license: "MIT"
115
- }, null, 2) + "\n");
116
- ' "$NPM/main/package.json"
117
-
118
- echo "[pack-npm] ${SCOPE}/homegraph@${VERSION} (${#targets[@]} platform packages in optionalDependencies)"
119
- echo "[pack-npm] output: $NPM"