homegraph 1.1.2 → 1.1.3

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 (175) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +243 -243
  3. package/dist/bin/homegraph.js +371 -9
  4. package/dist/bin/homegraph.js.map +1 -1
  5. package/dist/db/migrations.js +18 -18
  6. package/dist/db/queries.js +140 -140
  7. package/dist/db/schema.sql +152 -152
  8. package/dist/directory.js +5 -5
  9. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  10. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  11. package/dist/installer/instructions-template.js +9 -9
  12. package/dist/installer/targets/shared.d.ts +5 -6
  13. package/dist/installer/targets/shared.d.ts.map +1 -1
  14. package/dist/installer/targets/shared.js +5 -6
  15. package/dist/installer/targets/shared.js.map +1 -1
  16. package/dist/mcp/liveness-watchdog.js +16 -16
  17. package/dist/mcp/server-instructions.js +69 -69
  18. package/dist/mcp/tools.d.ts +17 -4
  19. package/dist/mcp/tools.d.ts.map +1 -1
  20. package/dist/mcp/tools.js +192 -22
  21. package/dist/mcp/tools.js.map +1 -1
  22. package/dist/reasoning/reasoner.js +32 -32
  23. package/dist/spec/config.d.ts +43 -0
  24. package/dist/spec/config.d.ts.map +1 -0
  25. package/dist/spec/config.js +275 -0
  26. package/dist/spec/config.js.map +1 -0
  27. package/dist/spec/db/commit-node.d.ts +23 -0
  28. package/dist/spec/db/commit-node.d.ts.map +1 -0
  29. package/dist/spec/db/commit-node.js +62 -0
  30. package/dist/spec/db/commit-node.js.map +1 -0
  31. package/dist/spec/db/fragment-node.d.ts +23 -0
  32. package/dist/spec/db/fragment-node.d.ts.map +1 -0
  33. package/dist/spec/db/fragment-node.js +120 -0
  34. package/dist/spec/db/fragment-node.js.map +1 -0
  35. package/dist/spec/db/fts.d.ts +60 -0
  36. package/dist/spec/db/fts.d.ts.map +1 -0
  37. package/dist/spec/db/fts.js +285 -0
  38. package/dist/spec/db/fts.js.map +1 -0
  39. package/dist/spec/db/index.d.ts +13 -0
  40. package/dist/spec/db/index.d.ts.map +1 -0
  41. package/dist/spec/db/index.js +50 -0
  42. package/dist/spec/db/index.js.map +1 -0
  43. package/dist/spec/db/relations.d.ts +55 -0
  44. package/dist/spec/db/relations.d.ts.map +1 -0
  45. package/dist/spec/db/relations.js +158 -0
  46. package/dist/spec/db/relations.js.map +1 -0
  47. package/dist/spec/db/schema.d.ts +30 -0
  48. package/dist/spec/db/schema.d.ts.map +1 -0
  49. package/dist/spec/db/schema.js +87 -0
  50. package/dist/spec/db/schema.js.map +1 -0
  51. package/dist/spec/db/schema.sql +107 -0
  52. package/dist/spec/db/spec-node.d.ts +41 -0
  53. package/dist/spec/db/spec-node.d.ts.map +1 -0
  54. package/dist/spec/db/spec-node.js +114 -0
  55. package/dist/spec/db/spec-node.js.map +1 -0
  56. package/dist/spec/evolve/impact-locator.d.ts +13 -0
  57. package/dist/spec/evolve/impact-locator.d.ts.map +1 -0
  58. package/dist/spec/evolve/impact-locator.js +25 -0
  59. package/dist/spec/evolve/impact-locator.js.map +1 -0
  60. package/dist/spec/evolve/llm-client.d.ts +50 -0
  61. package/dist/spec/evolve/llm-client.d.ts.map +1 -0
  62. package/dist/spec/evolve/llm-client.js +176 -0
  63. package/dist/spec/evolve/llm-client.js.map +1 -0
  64. package/dist/spec/evolve/logic-checker.d.ts +12 -0
  65. package/dist/spec/evolve/logic-checker.d.ts.map +1 -0
  66. package/dist/spec/evolve/logic-checker.js +48 -0
  67. package/dist/spec/evolve/logic-checker.js.map +1 -0
  68. package/dist/spec/evolve/pipeline.d.ts +40 -0
  69. package/dist/spec/evolve/pipeline.d.ts.map +1 -0
  70. package/dist/spec/evolve/pipeline.js +314 -0
  71. package/dist/spec/evolve/pipeline.js.map +1 -0
  72. package/dist/spec/evolve/spec-rewriter.d.ts +42 -0
  73. package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -0
  74. package/dist/spec/evolve/spec-rewriter.js +254 -0
  75. package/dist/spec/evolve/spec-rewriter.js.map +1 -0
  76. package/dist/spec/graph/queries.d.ts +58 -0
  77. package/dist/spec/graph/queries.d.ts.map +1 -0
  78. package/dist/spec/graph/queries.js +215 -0
  79. package/dist/spec/graph/queries.js.map +1 -0
  80. package/dist/spec/mining/diff-parser.d.ts +33 -0
  81. package/dist/spec/mining/diff-parser.d.ts.map +1 -0
  82. package/dist/spec/mining/diff-parser.js +166 -0
  83. package/dist/spec/mining/diff-parser.js.map +1 -0
  84. package/dist/spec/mining/git-scanner.d.ts +91 -0
  85. package/dist/spec/mining/git-scanner.d.ts.map +1 -0
  86. package/dist/spec/mining/git-scanner.js +266 -0
  87. package/dist/spec/mining/git-scanner.js.map +1 -0
  88. package/dist/spec/mining/pipeline.d.ts +53 -0
  89. package/dist/spec/mining/pipeline.d.ts.map +1 -0
  90. package/dist/spec/mining/pipeline.js +165 -0
  91. package/dist/spec/mining/pipeline.js.map +1 -0
  92. package/dist/spec/mining/scope-resolver.d.ts +45 -0
  93. package/dist/spec/mining/scope-resolver.d.ts.map +1 -0
  94. package/dist/spec/mining/scope-resolver.js +103 -0
  95. package/dist/spec/mining/scope-resolver.js.map +1 -0
  96. package/dist/spec/mining/spec-extractor.d.ts +69 -0
  97. package/dist/spec/mining/spec-extractor.d.ts.map +1 -0
  98. package/dist/spec/mining/spec-extractor.js +369 -0
  99. package/dist/spec/mining/spec-extractor.js.map +1 -0
  100. package/dist/spec/types.d.ts +149 -0
  101. package/dist/spec/types.d.ts.map +1 -0
  102. package/dist/spec/types.js +15 -0
  103. package/dist/spec/types.js.map +1 -0
  104. package/dist/spec/utils.d.ts +166 -0
  105. package/dist/spec/utils.d.ts.map +1 -0
  106. package/dist/spec/utils.js +461 -0
  107. package/dist/spec/utils.js.map +1 -0
  108. package/package.json +58 -57
  109. package/scripts/add-lang/bench.sh +60 -60
  110. package/scripts/add-lang/check-grammar.mjs +75 -75
  111. package/scripts/add-lang/dump-ast.mjs +103 -103
  112. package/scripts/add-lang/verify-extraction.mjs +70 -70
  113. package/scripts/agent-eval/ab-adoption.sh +91 -91
  114. package/scripts/agent-eval/ab-hook.sh +86 -86
  115. package/scripts/agent-eval/ab-impl.sh +78 -78
  116. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -102
  117. package/scripts/agent-eval/ab-sufficiency.sh +78 -78
  118. package/scripts/agent-eval/arms-F.sh +21 -21
  119. package/scripts/agent-eval/arms-matrix.sh +37 -37
  120. package/scripts/agent-eval/audit.sh +68 -68
  121. package/scripts/agent-eval/bench-readme.sh +28 -28
  122. package/scripts/agent-eval/bench-why-repo.sh +22 -22
  123. package/scripts/agent-eval/block-read-hook.sh +19 -19
  124. package/scripts/agent-eval/hook-settings.json +15 -15
  125. package/scripts/agent-eval/itrun.sh +120 -120
  126. package/scripts/agent-eval/offload-eval-3arm.sh +72 -72
  127. package/scripts/agent-eval/offload-eval-cost.mjs +133 -133
  128. package/scripts/agent-eval/offload-eval-effort.mjs +108 -108
  129. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -25
  130. package/scripts/agent-eval/offload-eval-frontload.sh +47 -47
  131. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -18
  132. package/scripts/agent-eval/offload-eval-hook.mjs +84 -84
  133. package/scripts/agent-eval/offload-eval-judge.mjs +103 -103
  134. package/scripts/agent-eval/offload-eval-matrix.sh +20 -20
  135. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -94
  136. package/scripts/agent-eval/offload-eval-refs1.sh +50 -50
  137. package/scripts/agent-eval/offload-eval-setup.sh +24 -24
  138. package/scripts/agent-eval/offload-eval-styles.sh +71 -71
  139. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -68
  140. package/scripts/agent-eval/offload-eval.md +76 -76
  141. package/scripts/agent-eval/parse-arms.mjs +116 -116
  142. package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
  143. package/scripts/agent-eval/parse-run.mjs +45 -45
  144. package/scripts/agent-eval/parse-session.mjs +93 -93
  145. package/scripts/agent-eval/probe-context.mjs +21 -21
  146. package/scripts/agent-eval/probe-explore.mjs +40 -40
  147. package/scripts/agent-eval/probe-node.mjs +20 -20
  148. package/scripts/agent-eval/probe-sweep.mjs +119 -119
  149. package/scripts/agent-eval/probe-trace.mjs +20 -20
  150. package/scripts/agent-eval/redirect-read-hook.sh +38 -38
  151. package/scripts/agent-eval/run-agent.sh +34 -34
  152. package/scripts/agent-eval/run-all.sh +69 -69
  153. package/scripts/agent-eval/run-arms.sh +56 -56
  154. package/scripts/agent-eval/seq-matrix.mjs +137 -137
  155. package/scripts/build-bundle.sh +118 -118
  156. package/scripts/extract-release-notes.mjs +130 -130
  157. package/scripts/local-install.sh +41 -41
  158. package/scripts/npm-sdk.js +75 -75
  159. package/scripts/npm-shim.js +246 -246
  160. package/scripts/pack-npm.sh +119 -119
  161. package/scripts/prepare-release.mjs +270 -270
  162. package/scripts/qa_eval/README.md +407 -404
  163. package/scripts/qa_eval/_test_deveco_probe.py +41 -41
  164. package/scripts/qa_eval/agent_runner.py +526 -526
  165. package/scripts/qa_eval/data/.gitignore +4 -4
  166. package/scripts/qa_eval/data/test-set.jsonl +2 -22
  167. package/scripts/qa_eval/eval_metrics.py +274 -233
  168. package/scripts/qa_eval/external_agent.py +976 -671
  169. package/scripts/qa_eval/llm_config.py +92 -92
  170. package/scripts/qa_eval/memory_monitor.py +132 -132
  171. package/scripts/qa_eval/my_answer_accuracy.py +187 -187
  172. package/scripts/qa_eval/requirements.txt +2 -2
  173. package/scripts/qa_eval/run_pipeline.py +804 -711
  174. package/scripts/qa_eval/stats_efficiency.py +279 -279
  175. package/scripts/qa_eval/stats_scores.py +207 -207
@@ -1,130 +1,130 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Extract a release-notes block from CHANGELOG.md for a given version
4
- * (or unwrap text supplied on stdin), then join hard-wrapped paragraphs.
5
- *
6
- * Why: GitHub renders release-note Markdown with GFM hard breaks, so
7
- * every `\n` becomes `<br>`. The CHANGELOG is hard-wrapped at ~75
8
- * chars for readable diffs, which then renders as awkward visible
9
- * line breaks on the release page. This script joins indented
10
- * continuation lines into a single line per bullet so the GFM
11
- * renderer produces clean paragraphs.
12
- *
13
- * Repo-level CHANGELOG.md viewing is unaffected (CommonMark treats
14
- * newlines as spaces there).
15
- *
16
- * Usage:
17
- * extract-release-notes.mjs <version> # read CHANGELOG.md
18
- * extract-release-notes.mjs --stdin # read from stdin (any text)
19
- */
20
-
21
- import { readFileSync } from 'fs';
22
-
23
- const arg = process.argv[2];
24
- if (!arg) {
25
- console.error('usage: extract-release-notes.mjs <version> | --stdin');
26
- process.exit(1);
27
- }
28
-
29
- let block;
30
- if (arg === '--stdin') {
31
- block = readFileSync(0, 'utf8').replace(/\r\n?/g, '\n').split('\n');
32
- } else {
33
- const version = arg;
34
- const escaped = version.replace(/\./g, '\\.');
35
- const headerRe = new RegExp(`^## \\[${escaped}\\]`);
36
- const anyHeaderRe = /^## \[/;
37
- const lines = readFileSync('CHANGELOG.md', 'utf8').split('\n');
38
- const start = lines.findIndex((l) => headerRe.test(l));
39
- if (start === -1) {
40
- console.error(`no '## [${version}]' entry found in CHANGELOG.md`);
41
- process.exit(1);
42
- }
43
- const after = lines.findIndex((l, i) => i > start && anyHeaderRe.test(l));
44
- block = lines.slice(start, after === -1 ? lines.length : after);
45
- }
46
-
47
- // Track a stack of `{ indent: number }` frames so a continuation line
48
- // can attach to the right ancestor. Handles the post-nested-list
49
- // continuation pattern:
50
- //
51
- // - top-level
52
- // - nested
53
- // back to top-level <- 2-space indent, joins the top-level bullet
54
- const out = [];
55
- let buf = '';
56
- let stack = [];
57
-
58
- function flushBuf() {
59
- if (buf !== '') {
60
- out.push(buf);
61
- buf = '';
62
- }
63
- }
64
-
65
- function leadingSpaces(s) {
66
- const m = s.match(/^(\s*)/);
67
- return m ? m[1].length : 0;
68
- }
69
-
70
- // Bullets: `-`, `*`, `digit.` only. `+` is intentionally excluded — the
71
- // CHANGELOG uses literal `+` inline (`config + instructions`) and we
72
- // don't want to misread those as nested bullets.
73
- const listItemRe = /^(\s*)([-*]|\d+\.)\s+/;
74
- const fenceRe = /^\s*```/;
75
-
76
- let inFence = false;
77
-
78
- for (const line of block) {
79
- // Fenced code blocks: pass through verbatim, no joining.
80
- if (fenceRe.test(line)) {
81
- flushBuf();
82
- stack = [];
83
- out.push(line);
84
- inFence = !inFence;
85
- continue;
86
- }
87
- if (inFence) {
88
- out.push(line);
89
- continue;
90
- }
91
- if (/^\s*$/.test(line)) {
92
- flushBuf();
93
- out.push('');
94
- continue;
95
- }
96
- if (/^#/.test(line)) {
97
- flushBuf();
98
- stack = [];
99
- out.push(line);
100
- continue;
101
- }
102
- const itemMatch = line.match(listItemRe);
103
- if (itemMatch) {
104
- flushBuf();
105
- const indent = itemMatch[1].length;
106
- while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
107
- stack.pop();
108
- }
109
- stack.push({ indent });
110
- buf = line;
111
- continue;
112
- }
113
- if (/^\s/.test(line)) {
114
- const indent = leadingSpaces(line);
115
- while (stack.length > 1 && stack[stack.length - 1].indent >= indent) {
116
- flushBuf();
117
- stack.pop();
118
- }
119
- const trimmed = line.replace(/^\s+/, '');
120
- buf = buf === '' ? trimmed : `${buf} ${trimmed}`;
121
- continue;
122
- }
123
- flushBuf();
124
- stack = [];
125
- out.push(line);
126
- }
127
- flushBuf();
128
-
129
- process.stdout.write(out.join('\n'));
130
- if (!out[out.length - 1]?.endsWith('\n')) process.stdout.write('\n');
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Extract a release-notes block from CHANGELOG.md for a given version
4
+ * (or unwrap text supplied on stdin), then join hard-wrapped paragraphs.
5
+ *
6
+ * Why: GitHub renders release-note Markdown with GFM hard breaks, so
7
+ * every `\n` becomes `<br>`. The CHANGELOG is hard-wrapped at ~75
8
+ * chars for readable diffs, which then renders as awkward visible
9
+ * line breaks on the release page. This script joins indented
10
+ * continuation lines into a single line per bullet so the GFM
11
+ * renderer produces clean paragraphs.
12
+ *
13
+ * Repo-level CHANGELOG.md viewing is unaffected (CommonMark treats
14
+ * newlines as spaces there).
15
+ *
16
+ * Usage:
17
+ * extract-release-notes.mjs <version> # read CHANGELOG.md
18
+ * extract-release-notes.mjs --stdin # read from stdin (any text)
19
+ */
20
+
21
+ import { readFileSync } from 'fs';
22
+
23
+ const arg = process.argv[2];
24
+ if (!arg) {
25
+ console.error('usage: extract-release-notes.mjs <version> | --stdin');
26
+ process.exit(1);
27
+ }
28
+
29
+ let block;
30
+ if (arg === '--stdin') {
31
+ block = readFileSync(0, 'utf8').replace(/\r\n?/g, '\n').split('\n');
32
+ } else {
33
+ const version = arg;
34
+ const escaped = version.replace(/\./g, '\\.');
35
+ const headerRe = new RegExp(`^## \\[${escaped}\\]`);
36
+ const anyHeaderRe = /^## \[/;
37
+ const lines = readFileSync('CHANGELOG.md', 'utf8').split('\n');
38
+ const start = lines.findIndex((l) => headerRe.test(l));
39
+ if (start === -1) {
40
+ console.error(`no '## [${version}]' entry found in CHANGELOG.md`);
41
+ process.exit(1);
42
+ }
43
+ const after = lines.findIndex((l, i) => i > start && anyHeaderRe.test(l));
44
+ block = lines.slice(start, after === -1 ? lines.length : after);
45
+ }
46
+
47
+ // Track a stack of `{ indent: number }` frames so a continuation line
48
+ // can attach to the right ancestor. Handles the post-nested-list
49
+ // continuation pattern:
50
+ //
51
+ // - top-level
52
+ // - nested
53
+ // back to top-level <- 2-space indent, joins the top-level bullet
54
+ const out = [];
55
+ let buf = '';
56
+ let stack = [];
57
+
58
+ function flushBuf() {
59
+ if (buf !== '') {
60
+ out.push(buf);
61
+ buf = '';
62
+ }
63
+ }
64
+
65
+ function leadingSpaces(s) {
66
+ const m = s.match(/^(\s*)/);
67
+ return m ? m[1].length : 0;
68
+ }
69
+
70
+ // Bullets: `-`, `*`, `digit.` only. `+` is intentionally excluded — the
71
+ // CHANGELOG uses literal `+` inline (`config + instructions`) and we
72
+ // don't want to misread those as nested bullets.
73
+ const listItemRe = /^(\s*)([-*]|\d+\.)\s+/;
74
+ const fenceRe = /^\s*```/;
75
+
76
+ let inFence = false;
77
+
78
+ for (const line of block) {
79
+ // Fenced code blocks: pass through verbatim, no joining.
80
+ if (fenceRe.test(line)) {
81
+ flushBuf();
82
+ stack = [];
83
+ out.push(line);
84
+ inFence = !inFence;
85
+ continue;
86
+ }
87
+ if (inFence) {
88
+ out.push(line);
89
+ continue;
90
+ }
91
+ if (/^\s*$/.test(line)) {
92
+ flushBuf();
93
+ out.push('');
94
+ continue;
95
+ }
96
+ if (/^#/.test(line)) {
97
+ flushBuf();
98
+ stack = [];
99
+ out.push(line);
100
+ continue;
101
+ }
102
+ const itemMatch = line.match(listItemRe);
103
+ if (itemMatch) {
104
+ flushBuf();
105
+ const indent = itemMatch[1].length;
106
+ while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
107
+ stack.pop();
108
+ }
109
+ stack.push({ indent });
110
+ buf = line;
111
+ continue;
112
+ }
113
+ if (/^\s/.test(line)) {
114
+ const indent = leadingSpaces(line);
115
+ while (stack.length > 1 && stack[stack.length - 1].indent >= indent) {
116
+ flushBuf();
117
+ stack.pop();
118
+ }
119
+ const trimmed = line.replace(/^\s+/, '');
120
+ buf = buf === '' ? trimmed : `${buf} ${trimmed}`;
121
+ continue;
122
+ }
123
+ flushBuf();
124
+ stack = [];
125
+ out.push(line);
126
+ }
127
+ flushBuf();
128
+
129
+ process.stdout.write(out.join('\n'));
130
+ if (!out[out.length - 1]?.endsWith('\n')) process.stdout.write('\n');
@@ -1,41 +1,41 @@
1
- #!/usr/bin/env bash
2
- # Build the current branch and link it as the global `homegraph` for
3
- # hands-on testing. Replaces any existing global install for as long
4
- # as the symlink is in place.
5
- #
6
- # Usage:
7
- # ./scripts/local-install.sh # build + link
8
- # ./scripts/local-install.sh --undo # unlink + restore the published version
9
-
10
- set -euo pipefail
11
-
12
- cd "$(dirname "$0")/.."
13
-
14
- PKG=$(node -p "require('./package.json').name")
15
- VERSION=$(node -p "require('./package.json').version")
16
- BRANCH=$(git rev-parse --abbrev-ref HEAD)
17
-
18
- if [ "${1:-}" = "--undo" ]; then
19
- echo "→ unlinking ${PKG}"
20
- npm unlink -g "${PKG}" >/dev/null 2>&1 || true
21
- echo "→ reinstalling published ${PKG}"
22
- npm install -g "${PKG}"
23
- echo "done: global homegraph -> $(command -v homegraph)"
24
- exit 0
25
- fi
26
-
27
- echo "→ building ${PKG} ${VERSION} (${BRANCH})"
28
- npm run build
29
-
30
- echo "→ linking globally"
31
- npm link
32
-
33
- LINKED=$(command -v homegraph || echo "(not on PATH)")
34
- echo
35
- echo "✓ global homegraph now points to this branch"
36
- echo " binary: ${LINKED}"
37
- echo " branch: ${BRANCH}"
38
- echo " version: ${VERSION}"
39
- echo
40
- echo "To restore the published version:"
41
- echo " ./scripts/local-install.sh --undo"
1
+ #!/usr/bin/env bash
2
+ # Build the current branch and link it as the global `homegraph` for
3
+ # hands-on testing. Replaces any existing global install for as long
4
+ # as the symlink is in place.
5
+ #
6
+ # Usage:
7
+ # ./scripts/local-install.sh # build + link
8
+ # ./scripts/local-install.sh --undo # unlink + restore the published version
9
+
10
+ set -euo pipefail
11
+
12
+ cd "$(dirname "$0")/.."
13
+
14
+ PKG=$(node -p "require('./package.json').name")
15
+ VERSION=$(node -p "require('./package.json').version")
16
+ BRANCH=$(git rev-parse --abbrev-ref HEAD)
17
+
18
+ if [ "${1:-}" = "--undo" ]; then
19
+ echo "→ unlinking ${PKG}"
20
+ npm unlink -g "${PKG}" >/dev/null 2>&1 || true
21
+ echo "→ reinstalling published ${PKG}"
22
+ npm install -g "${PKG}"
23
+ echo "done: global homegraph -> $(command -v homegraph)"
24
+ exit 0
25
+ fi
26
+
27
+ echo "→ building ${PKG} ${VERSION} (${BRANCH})"
28
+ npm run build
29
+
30
+ echo "→ linking globally"
31
+ npm link
32
+
33
+ LINKED=$(command -v homegraph || echo "(not on PATH)")
34
+ echo
35
+ echo "✓ global homegraph now points to this branch"
36
+ echo " binary: ${LINKED}"
37
+ echo " branch: ${BRANCH}"
38
+ echo " version: ${VERSION}"
39
+ echo
40
+ echo "To restore the published version:"
41
+ echo " ./scripts/local-install.sh --undo"
@@ -1,75 +1,75 @@
1
- 'use strict';
2
- //
3
- // Programmatic / embedded SDK entry for homegraph (issue #354).
4
- //
5
- // The CLI/MCP `bin` (npm-shim.js) execs the per-platform bundle's OWN Node 24 so
6
- // the tool never depends on the user's runtime. Embedded library consumers are
7
- // the opposite case: they already run their own Node and just want the compiled
8
- // API — `require("homegraph")` returning the HomeGraph class et al.
9
- //
10
- // The compiled library + its production dependencies (web-tree-sitter,
11
- // tree-sitter-wasms, …) ship INSIDE the per-platform bundle, at
12
- // homegraph-<platform>-<arch>/lib/dist/index.js
13
- // (with the deps in the sibling lib/node_modules). Re-exporting that bundle keeps
14
- // the main package thin — no second 50 MB copy of the grammars — while making the
15
- // SDK work in the consumer's process. Types are a separate concern: the main
16
- // package ships its own dist/**/*.d.ts tree (pointed at by `types`), built from
17
- // the same release so it can never skew from the runtime it re-exports.
18
- //
19
- // node:sqlite (Node >= 22.5) is required to OPEN a graph, but only lazily inside
20
- // the SQLite adapter — so loading this module is safe on older Node, and the
21
- // node:sqlite requirement surfaces with an actionable error only when a DB is
22
- // actually opened. Heavy extraction additionally wants the bundled launcher's
23
- // --liftoff-only flag (the WASM Zone-OOM guard, issues #293/#298); an embedded
24
- // host that drives large indexing should pass that flag to its own Node.
25
-
26
- var path = require('path');
27
- var os = require('os');
28
- var fs = require('fs');
29
-
30
- var target = process.platform + '-' + process.arch; // e.g. darwin-arm64, linux-x64
31
- var pkg = 'homegraph-' + target;
32
-
33
- module.exports = require(resolveLibrary());
34
-
35
- // Locate the compiled library entry inside the installed per-platform bundle.
36
- // Throws an actionable error (rather than a bare MODULE_NOT_FOUND) when no bundle
37
- // is present, so an embedded consumer knows exactly what to install.
38
- function resolveLibrary() {
39
- // 1) The npm-installed optional dependency — the normal case.
40
- try {
41
- return require.resolve(pkg + '/lib/dist/index.js');
42
- } catch (e) {
43
- /* fall through to the self-healed cache */
44
- }
45
-
46
- // 2) A bundle the CLI shim self-healed from GitHub Releases into the cache
47
- // (issue #303). Same node/lib/bin layout as the npm package. We only REUSE a
48
- // cached bundle here — unlike the CLI shim we never trigger a network
49
- // download from inside require(), which must stay synchronous and cheap.
50
- var cached = cachedLibrary();
51
- if (cached) return cached;
52
-
53
- throw new Error(
54
- 'homegraph: the programmatic API is unavailable because the platform bundle\n' +
55
- '(' + pkg + ') is not installed.\n' +
56
- 'The compiled library ships inside that per-platform optional dependency.\n' +
57
- 'Fixes:\n' +
58
- ' - install from the official npm registry so the matching bundle is fetched:\n' +
59
- ' npm i homegraph --registry=https://registry.npmjs.org\n' +
60
- ' - or run the CLI once (e.g. `npx homegraph status`) to\n' +
61
- ' self-heal the bundle into ~/.homegraph, then require() will find it.'
62
- );
63
- }
64
-
65
- function cachedLibrary() {
66
- try {
67
- var version = require(path.join(__dirname, 'package.json')).version;
68
- var base = process.env.HOMEGRAPH_INSTALL_DIR || path.join(os.homedir(), '.homegraph');
69
- var lib = path.join(base, 'bundles', target + '-' + version, 'lib', 'dist', 'index.js');
70
- if (fs.existsSync(lib)) return lib;
71
- } catch (e) {
72
- /* no readable cache → caller reports the install guidance */
73
- }
74
- return null;
75
- }
1
+ 'use strict';
2
+ //
3
+ // Programmatic / embedded SDK entry for homegraph (issue #354).
4
+ //
5
+ // The CLI/MCP `bin` (npm-shim.js) execs the per-platform bundle's OWN Node 24 so
6
+ // the tool never depends on the user's runtime. Embedded library consumers are
7
+ // the opposite case: they already run their own Node and just want the compiled
8
+ // API — `require("homegraph")` returning the HomeGraph class et al.
9
+ //
10
+ // The compiled library + its production dependencies (web-tree-sitter,
11
+ // tree-sitter-wasms, …) ship INSIDE the per-platform bundle, at
12
+ // homegraph-<platform>-<arch>/lib/dist/index.js
13
+ // (with the deps in the sibling lib/node_modules). Re-exporting that bundle keeps
14
+ // the main package thin — no second 50 MB copy of the grammars — while making the
15
+ // SDK work in the consumer's process. Types are a separate concern: the main
16
+ // package ships its own dist/**/*.d.ts tree (pointed at by `types`), built from
17
+ // the same release so it can never skew from the runtime it re-exports.
18
+ //
19
+ // node:sqlite (Node >= 22.5) is required to OPEN a graph, but only lazily inside
20
+ // the SQLite adapter — so loading this module is safe on older Node, and the
21
+ // node:sqlite requirement surfaces with an actionable error only when a DB is
22
+ // actually opened. Heavy extraction additionally wants the bundled launcher's
23
+ // --liftoff-only flag (the WASM Zone-OOM guard, issues #293/#298); an embedded
24
+ // host that drives large indexing should pass that flag to its own Node.
25
+
26
+ var path = require('path');
27
+ var os = require('os');
28
+ var fs = require('fs');
29
+
30
+ var target = process.platform + '-' + process.arch; // e.g. darwin-arm64, linux-x64
31
+ var pkg = 'homegraph-' + target;
32
+
33
+ module.exports = require(resolveLibrary());
34
+
35
+ // Locate the compiled library entry inside the installed per-platform bundle.
36
+ // Throws an actionable error (rather than a bare MODULE_NOT_FOUND) when no bundle
37
+ // is present, so an embedded consumer knows exactly what to install.
38
+ function resolveLibrary() {
39
+ // 1) The npm-installed optional dependency — the normal case.
40
+ try {
41
+ return require.resolve(pkg + '/lib/dist/index.js');
42
+ } catch (e) {
43
+ /* fall through to the self-healed cache */
44
+ }
45
+
46
+ // 2) A bundle the CLI shim self-healed from GitHub Releases into the cache
47
+ // (issue #303). Same node/lib/bin layout as the npm package. We only REUSE a
48
+ // cached bundle here — unlike the CLI shim we never trigger a network
49
+ // download from inside require(), which must stay synchronous and cheap.
50
+ var cached = cachedLibrary();
51
+ if (cached) return cached;
52
+
53
+ throw new Error(
54
+ 'homegraph: the programmatic API is unavailable because the platform bundle\n' +
55
+ '(' + pkg + ') is not installed.\n' +
56
+ 'The compiled library ships inside that per-platform optional dependency.\n' +
57
+ 'Fixes:\n' +
58
+ ' - install from the official npm registry so the matching bundle is fetched:\n' +
59
+ ' npm i homegraph --registry=https://registry.npmjs.org\n' +
60
+ ' - or run the CLI once (e.g. `npx homegraph status`) to\n' +
61
+ ' self-heal the bundle into ~/.homegraph, then require() will find it.'
62
+ );
63
+ }
64
+
65
+ function cachedLibrary() {
66
+ try {
67
+ var version = require(path.join(__dirname, 'package.json')).version;
68
+ var base = process.env.HOMEGRAPH_INSTALL_DIR || path.join(os.homedir(), '.homegraph');
69
+ var lib = path.join(base, 'bundles', target + '-' + version, 'lib', 'dist', 'index.js');
70
+ if (fs.existsSync(lib)) return lib;
71
+ } catch (e) {
72
+ /* no readable cache → caller reports the install guidance */
73
+ }
74
+ return null;
75
+ }