@stupidloud/codegraph 0.8.1 → 0.9.9

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 (341) hide show
  1. package/README.md +319 -152
  2. package/dist/bin/codegraph.d.ts +4 -0
  3. package/dist/bin/codegraph.d.ts.map +1 -1
  4. package/dist/bin/codegraph.js +354 -90
  5. package/dist/bin/codegraph.js.map +1 -1
  6. package/dist/bin/node-version-check.d.ts +17 -0
  7. package/dist/bin/node-version-check.d.ts.map +1 -1
  8. package/dist/bin/node-version-check.js +37 -0
  9. package/dist/bin/node-version-check.js.map +1 -1
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +1 -11
  12. package/dist/config.js.map +1 -1
  13. package/dist/context/formatter.d.ts.map +1 -1
  14. package/dist/context/formatter.js +25 -6
  15. package/dist/context/formatter.js.map +1 -1
  16. package/dist/context/index.d.ts +22 -0
  17. package/dist/context/index.d.ts.map +1 -1
  18. package/dist/context/index.js +257 -6
  19. package/dist/context/index.js.map +1 -1
  20. package/dist/context/markers.d.ts +19 -0
  21. package/dist/context/markers.d.ts.map +1 -0
  22. package/dist/context/markers.js +22 -0
  23. package/dist/context/markers.js.map +1 -0
  24. package/dist/db/index.d.ts +30 -1
  25. package/dist/db/index.d.ts.map +1 -1
  26. package/dist/db/index.js +75 -25
  27. package/dist/db/index.js.map +1 -1
  28. package/dist/db/queries.d.ts +104 -0
  29. package/dist/db/queries.d.ts.map +1 -1
  30. package/dist/db/queries.js +328 -31
  31. package/dist/db/queries.js.map +1 -1
  32. package/dist/db/sqlite-adapter.d.ts +24 -23
  33. package/dist/db/sqlite-adapter.d.ts.map +1 -1
  34. package/dist/db/sqlite-adapter.js +54 -174
  35. package/dist/db/sqlite-adapter.js.map +1 -1
  36. package/dist/directory.d.ts.map +1 -1
  37. package/dist/directory.js +6 -20
  38. package/dist/directory.js.map +1 -1
  39. package/dist/extraction/generated-detection.d.ts +30 -0
  40. package/dist/extraction/generated-detection.d.ts.map +1 -0
  41. package/dist/extraction/generated-detection.js +80 -0
  42. package/dist/extraction/generated-detection.js.map +1 -0
  43. package/dist/extraction/grammars.d.ts +23 -1
  44. package/dist/extraction/grammars.d.ts.map +1 -1
  45. package/dist/extraction/grammars.js +107 -3
  46. package/dist/extraction/grammars.js.map +1 -1
  47. package/dist/extraction/index.d.ts +22 -14
  48. package/dist/extraction/index.d.ts.map +1 -1
  49. package/dist/extraction/index.js +272 -183
  50. package/dist/extraction/index.js.map +1 -1
  51. package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  52. package/dist/extraction/languages/c-cpp.js +45 -0
  53. package/dist/extraction/languages/c-cpp.js.map +1 -1
  54. package/dist/extraction/languages/csharp.d.ts.map +1 -1
  55. package/dist/extraction/languages/csharp.js +2 -1
  56. package/dist/extraction/languages/csharp.js.map +1 -1
  57. package/dist/extraction/languages/go.d.ts.map +1 -1
  58. package/dist/extraction/languages/go.js +18 -2
  59. package/dist/extraction/languages/go.js.map +1 -1
  60. package/dist/extraction/languages/index.d.ts.map +1 -1
  61. package/dist/extraction/languages/index.js +6 -0
  62. package/dist/extraction/languages/index.js.map +1 -1
  63. package/dist/extraction/languages/java.d.ts.map +1 -1
  64. package/dist/extraction/languages/java.js +6 -0
  65. package/dist/extraction/languages/java.js.map +1 -1
  66. package/dist/extraction/languages/kotlin.d.ts.map +1 -1
  67. package/dist/extraction/languages/kotlin.js +6 -0
  68. package/dist/extraction/languages/kotlin.js.map +1 -1
  69. package/dist/extraction/languages/lua.d.ts +3 -0
  70. package/dist/extraction/languages/lua.d.ts.map +1 -0
  71. package/dist/extraction/languages/lua.js +150 -0
  72. package/dist/extraction/languages/lua.js.map +1 -0
  73. package/dist/extraction/languages/luau.d.ts +3 -0
  74. package/dist/extraction/languages/luau.d.ts.map +1 -0
  75. package/dist/extraction/languages/luau.js +37 -0
  76. package/dist/extraction/languages/luau.js.map +1 -0
  77. package/dist/extraction/languages/objc.d.ts +3 -0
  78. package/dist/extraction/languages/objc.d.ts.map +1 -0
  79. package/dist/extraction/languages/objc.js +133 -0
  80. package/dist/extraction/languages/objc.js.map +1 -0
  81. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  82. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  83. package/dist/extraction/mybatis-extractor.js +198 -0
  84. package/dist/extraction/mybatis-extractor.js.map +1 -0
  85. package/dist/extraction/tree-sitter-types.d.ts +14 -0
  86. package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  87. package/dist/extraction/tree-sitter.d.ts +84 -0
  88. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  89. package/dist/extraction/tree-sitter.js +715 -16
  90. package/dist/extraction/tree-sitter.js.map +1 -1
  91. package/dist/extraction/vue-extractor.d.ts +15 -0
  92. package/dist/extraction/vue-extractor.d.ts.map +1 -1
  93. package/dist/extraction/vue-extractor.js +88 -0
  94. package/dist/extraction/vue-extractor.js.map +1 -1
  95. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  96. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  97. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  98. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  99. package/dist/extraction/wasm-runtime-flags.js +106 -0
  100. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  101. package/dist/graph/traversal.d.ts.map +1 -1
  102. package/dist/graph/traversal.js +76 -38
  103. package/dist/graph/traversal.js.map +1 -1
  104. package/dist/index.d.ts +77 -8
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +133 -19
  107. package/dist/index.js.map +1 -1
  108. package/dist/installer/config-writer.d.ts +7 -8
  109. package/dist/installer/config-writer.d.ts.map +1 -1
  110. package/dist/installer/config-writer.js +7 -27
  111. package/dist/installer/config-writer.js.map +1 -1
  112. package/dist/installer/index.d.ts +51 -16
  113. package/dist/installer/index.d.ts.map +1 -1
  114. package/dist/installer/index.js +120 -29
  115. package/dist/installer/index.js.map +1 -1
  116. package/dist/installer/instructions-template.d.ts +11 -21
  117. package/dist/installer/instructions-template.d.ts.map +1 -1
  118. package/dist/installer/instructions-template.js +12 -56
  119. package/dist/installer/instructions-template.js.map +1 -1
  120. package/dist/installer/targets/antigravity.d.ts +57 -0
  121. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  122. package/dist/installer/targets/antigravity.js +308 -0
  123. package/dist/installer/targets/antigravity.js.map +1 -0
  124. package/dist/installer/targets/claude.d.ts +26 -1
  125. package/dist/installer/targets/claude.d.ts.map +1 -1
  126. package/dist/installer/targets/claude.js +118 -40
  127. package/dist/installer/targets/claude.js.map +1 -1
  128. package/dist/installer/targets/codex.d.ts.map +1 -1
  129. package/dist/installer/targets/codex.js +15 -13
  130. package/dist/installer/targets/codex.js.map +1 -1
  131. package/dist/installer/targets/cursor.d.ts.map +1 -1
  132. package/dist/installer/targets/cursor.js +61 -36
  133. package/dist/installer/targets/cursor.js.map +1 -1
  134. package/dist/installer/targets/gemini.d.ts +26 -0
  135. package/dist/installer/targets/gemini.d.ts.map +1 -0
  136. package/dist/installer/targets/gemini.js +167 -0
  137. package/dist/installer/targets/gemini.js.map +1 -0
  138. package/dist/installer/targets/hermes.d.ts +18 -0
  139. package/dist/installer/targets/hermes.d.ts.map +1 -0
  140. package/dist/installer/targets/hermes.js +359 -0
  141. package/dist/installer/targets/hermes.js.map +1 -0
  142. package/dist/installer/targets/kiro.d.ts +27 -0
  143. package/dist/installer/targets/kiro.d.ts.map +1 -0
  144. package/dist/installer/targets/kiro.js +178 -0
  145. package/dist/installer/targets/kiro.js.map +1 -0
  146. package/dist/installer/targets/opencode.d.ts.map +1 -1
  147. package/dist/installer/targets/opencode.js +15 -13
  148. package/dist/installer/targets/opencode.js.map +1 -1
  149. package/dist/installer/targets/registry.d.ts.map +1 -1
  150. package/dist/installer/targets/registry.js +8 -0
  151. package/dist/installer/targets/registry.js.map +1 -1
  152. package/dist/installer/targets/shared.d.ts.map +1 -1
  153. package/dist/installer/targets/shared.js +3 -2
  154. package/dist/installer/targets/shared.js.map +1 -1
  155. package/dist/installer/targets/types.d.ts +1 -16
  156. package/dist/installer/targets/types.d.ts.map +1 -1
  157. package/dist/mcp/daemon-paths.d.ts +46 -0
  158. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  159. package/dist/mcp/daemon-paths.js +125 -0
  160. package/dist/mcp/daemon-paths.js.map +1 -0
  161. package/dist/mcp/daemon.d.ts +161 -0
  162. package/dist/mcp/daemon.d.ts.map +1 -0
  163. package/dist/mcp/daemon.js +403 -0
  164. package/dist/mcp/daemon.js.map +1 -0
  165. package/dist/mcp/engine.d.ts +105 -0
  166. package/dist/mcp/engine.d.ts.map +1 -0
  167. package/dist/mcp/engine.js +270 -0
  168. package/dist/mcp/engine.js.map +1 -0
  169. package/dist/mcp/index.d.ts +70 -52
  170. package/dist/mcp/index.d.ts.map +1 -1
  171. package/dist/mcp/index.js +355 -331
  172. package/dist/mcp/index.js.map +1 -1
  173. package/dist/mcp/proxy.d.ts +81 -0
  174. package/dist/mcp/proxy.d.ts.map +1 -0
  175. package/dist/mcp/proxy.js +510 -0
  176. package/dist/mcp/proxy.js.map +1 -0
  177. package/dist/mcp/server-instructions.d.ts +1 -1
  178. package/dist/mcp/server-instructions.d.ts.map +1 -1
  179. package/dist/mcp/server-instructions.js +21 -21
  180. package/dist/mcp/session.d.ts +77 -0
  181. package/dist/mcp/session.d.ts.map +1 -0
  182. package/dist/mcp/session.js +294 -0
  183. package/dist/mcp/session.js.map +1 -0
  184. package/dist/mcp/tools.d.ts +171 -15
  185. package/dist/mcp/tools.d.ts.map +1 -1
  186. package/dist/mcp/tools.js +1714 -298
  187. package/dist/mcp/tools.js.map +1 -1
  188. package/dist/mcp/transport.d.ts +111 -29
  189. package/dist/mcp/transport.d.ts.map +1 -1
  190. package/dist/mcp/transport.js +181 -71
  191. package/dist/mcp/transport.js.map +1 -1
  192. package/dist/mcp/version.d.ts +19 -0
  193. package/dist/mcp/version.d.ts.map +1 -0
  194. package/dist/mcp/version.js +71 -0
  195. package/dist/mcp/version.js.map +1 -0
  196. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  197. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  198. package/dist/resolution/callback-synthesizer.js +1300 -0
  199. package/dist/resolution/callback-synthesizer.js.map +1 -0
  200. package/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  201. package/dist/resolution/frameworks/csharp.js +36 -8
  202. package/dist/resolution/frameworks/csharp.js.map +1 -1
  203. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  204. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  205. package/dist/resolution/frameworks/drupal.js +367 -0
  206. package/dist/resolution/frameworks/drupal.js.map +1 -0
  207. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  208. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  209. package/dist/resolution/frameworks/expo-modules.js +143 -0
  210. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  211. package/dist/resolution/frameworks/express.d.ts.map +1 -1
  212. package/dist/resolution/frameworks/express.js +102 -19
  213. package/dist/resolution/frameworks/express.js.map +1 -1
  214. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  215. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  216. package/dist/resolution/frameworks/fabric.js +354 -0
  217. package/dist/resolution/frameworks/fabric.js.map +1 -0
  218. package/dist/resolution/frameworks/go.d.ts.map +1 -1
  219. package/dist/resolution/frameworks/go.js +6 -3
  220. package/dist/resolution/frameworks/go.js.map +1 -1
  221. package/dist/resolution/frameworks/index.d.ts +6 -0
  222. package/dist/resolution/frameworks/index.d.ts.map +1 -1
  223. package/dist/resolution/frameworks/index.js +29 -1
  224. package/dist/resolution/frameworks/index.js.map +1 -1
  225. package/dist/resolution/frameworks/java.d.ts.map +1 -1
  226. package/dist/resolution/frameworks/java.js +339 -12
  227. package/dist/resolution/frameworks/java.js.map +1 -1
  228. package/dist/resolution/frameworks/laravel.d.ts.map +1 -1
  229. package/dist/resolution/frameworks/laravel.js +17 -8
  230. package/dist/resolution/frameworks/laravel.js.map +1 -1
  231. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  232. package/dist/resolution/frameworks/nestjs.js +324 -0
  233. package/dist/resolution/frameworks/nestjs.js.map +1 -1
  234. package/dist/resolution/frameworks/play.d.ts +19 -0
  235. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  236. package/dist/resolution/frameworks/play.js +111 -0
  237. package/dist/resolution/frameworks/play.js.map +1 -0
  238. package/dist/resolution/frameworks/python.d.ts.map +1 -1
  239. package/dist/resolution/frameworks/python.js +134 -16
  240. package/dist/resolution/frameworks/python.js.map +1 -1
  241. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  242. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  243. package/dist/resolution/frameworks/react-native.js +360 -0
  244. package/dist/resolution/frameworks/react-native.js.map +1 -0
  245. package/dist/resolution/frameworks/react.d.ts.map +1 -1
  246. package/dist/resolution/frameworks/react.js +96 -3
  247. package/dist/resolution/frameworks/react.js.map +1 -1
  248. package/dist/resolution/frameworks/ruby.d.ts.map +1 -1
  249. package/dist/resolution/frameworks/ruby.js +106 -2
  250. package/dist/resolution/frameworks/ruby.js.map +1 -1
  251. package/dist/resolution/frameworks/rust.d.ts.map +1 -1
  252. package/dist/resolution/frameworks/rust.js +102 -5
  253. package/dist/resolution/frameworks/rust.js.map +1 -1
  254. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  255. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  256. package/dist/resolution/frameworks/swift-objc.js +252 -0
  257. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  258. package/dist/resolution/frameworks/swift.d.ts.map +1 -1
  259. package/dist/resolution/frameworks/swift.js +30 -6
  260. package/dist/resolution/frameworks/swift.js.map +1 -1
  261. package/dist/resolution/go-module.d.ts +26 -0
  262. package/dist/resolution/go-module.d.ts.map +1 -0
  263. package/dist/resolution/go-module.js +78 -0
  264. package/dist/resolution/go-module.js.map +1 -0
  265. package/dist/resolution/import-resolver.d.ts +28 -0
  266. package/dist/resolution/import-resolver.d.ts.map +1 -1
  267. package/dist/resolution/import-resolver.js +617 -5
  268. package/dist/resolution/import-resolver.js.map +1 -1
  269. package/dist/resolution/index.d.ts +11 -0
  270. package/dist/resolution/index.d.ts.map +1 -1
  271. package/dist/resolution/index.js +196 -10
  272. package/dist/resolution/index.js.map +1 -1
  273. package/dist/resolution/lru-cache.d.ts +24 -0
  274. package/dist/resolution/lru-cache.d.ts.map +1 -0
  275. package/dist/resolution/lru-cache.js +62 -0
  276. package/dist/resolution/lru-cache.js.map +1 -0
  277. package/dist/resolution/name-matcher.d.ts.map +1 -1
  278. package/dist/resolution/name-matcher.js +212 -0
  279. package/dist/resolution/name-matcher.js.map +1 -1
  280. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  281. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  282. package/dist/resolution/swift-objc-bridge.js +256 -0
  283. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  284. package/dist/resolution/types.d.ts +44 -0
  285. package/dist/resolution/types.d.ts.map +1 -1
  286. package/dist/resolution/workspace-packages.d.ts +48 -0
  287. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  288. package/dist/resolution/workspace-packages.js +208 -0
  289. package/dist/resolution/workspace-packages.js.map +1 -0
  290. package/dist/search/query-utils.d.ts +18 -0
  291. package/dist/search/query-utils.d.ts.map +1 -1
  292. package/dist/search/query-utils.js +30 -0
  293. package/dist/search/query-utils.js.map +1 -1
  294. package/dist/sync/git-hooks.d.ts.map +1 -1
  295. package/dist/sync/git-hooks.js +2 -0
  296. package/dist/sync/git-hooks.js.map +1 -1
  297. package/dist/sync/index.d.ts +3 -1
  298. package/dist/sync/index.d.ts.map +1 -1
  299. package/dist/sync/index.js +8 -1
  300. package/dist/sync/index.js.map +1 -1
  301. package/dist/sync/watcher.d.ts +214 -12
  302. package/dist/sync/watcher.d.ts.map +1 -1
  303. package/dist/sync/watcher.js +467 -55
  304. package/dist/sync/watcher.js.map +1 -1
  305. package/dist/sync/worktree.d.ts +54 -0
  306. package/dist/sync/worktree.d.ts.map +1 -0
  307. package/dist/sync/worktree.js +137 -0
  308. package/dist/sync/worktree.js.map +1 -0
  309. package/dist/types.d.ts +9 -1
  310. package/dist/types.d.ts.map +1 -1
  311. package/dist/types.js +14 -0
  312. package/dist/types.js.map +1 -1
  313. package/dist/utils.js +1 -1
  314. package/package.json +2 -2
  315. package/scripts/add-lang/bench.sh +60 -0
  316. package/scripts/add-lang/check-grammar.mjs +75 -0
  317. package/scripts/add-lang/dump-ast.mjs +103 -0
  318. package/scripts/add-lang/verify-extraction.mjs +70 -0
  319. package/scripts/agent-eval/arms-F.sh +21 -0
  320. package/scripts/agent-eval/arms-matrix.sh +37 -0
  321. package/scripts/agent-eval/bench-readme.sh +28 -0
  322. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  323. package/scripts/agent-eval/block-read-hook.sh +19 -0
  324. package/scripts/agent-eval/hook-settings.json +15 -0
  325. package/scripts/agent-eval/itrun.sh +24 -11
  326. package/scripts/agent-eval/parse-arms.mjs +116 -0
  327. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  328. package/scripts/agent-eval/probe-context.mjs +21 -0
  329. package/scripts/agent-eval/probe-explore.mjs +40 -0
  330. package/scripts/agent-eval/probe-node.mjs +20 -0
  331. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  332. package/scripts/agent-eval/probe-trace.mjs +20 -0
  333. package/scripts/agent-eval/run-arms.sh +56 -0
  334. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  335. package/scripts/build-bundle.sh +118 -0
  336. package/scripts/npm-sdk.js +75 -0
  337. package/scripts/npm-shim.js +246 -0
  338. package/scripts/pack-npm.sh +119 -0
  339. package/scripts/prepare-release.mjs +270 -0
  340. package/scripts/patch-tree-sitter-dart.js +0 -112
  341. package/scripts/release.sh +0 -68
@@ -0,0 +1,119 @@
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
+ # codegraph-<target>/ one per built bundle — the vendored Node + app, tagged
7
+ # with os/cpu so npm installs only the matching one.
8
+ # main/ the @colbymchenry/codegraph 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/codegraph-*.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"/codegraph-*.tar.gz "$REL"/codegraph-*.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}" ;; # codegraph-<target>
38
+ *.zip) base="${fname%.zip}" ;;
39
+ esac
40
+ target="${base#codegraph-}" # <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/codegraph-${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}/codegraph-${process.env.TARGET}`,
63
+ version: process.env.VERSION,
64
+ description: `CodeGraph 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}/codegraph-${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}/codegraph-${t}`]=process.env.VERSION;
101
+ fs.writeFileSync(process.argv[1], JSON.stringify({
102
+ name: `${process.env.SCOPE}/codegraph`,
103
+ version: process.env.VERSION,
104
+ description: "Local-first code intelligence for AI agents (MCP). Self-contained — bundles its own runtime.",
105
+ bin: { codegraph: "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}/codegraph@${VERSION} (${#targets[@]} platform packages in optionalDependencies)"
119
+ echo "[pack-npm] output: $NPM"
@@ -0,0 +1,270 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Promote `## [Unreleased]` content into `## [<version>]` in CHANGELOG.md
4
+ * so the release.yml workflow's `extract-release-notes.mjs <version>` call
5
+ * picks up everything that landed since the last release.
6
+ *
7
+ * **Why this exists:** the release workflow used to do a literal
8
+ * `extract-release-notes.mjs <version>` lookup with an `[Unreleased]`
9
+ * fallback. The fallback only triggers if the `[<version>]` block
10
+ * doesn't exist at all — and in practice maintainers sometimes had a
11
+ * sparse `[<version>]` block pre-populated (e.g. one early fix
12
+ * documented before the rest of the work landed). The workflow then
13
+ * extracted that sparse block, ignoring the much larger `[Unreleased]`
14
+ * section above it — so the published release notes were missing most
15
+ * of what shipped. See v0.9.5 for the canonical post-mortem.
16
+ *
17
+ * **What it does**, idempotently:
18
+ *
19
+ * Case A — `[<version>]` does not exist yet:
20
+ * Rename the `[Unreleased]` header to `[<version>] - <YYYY-MM-DD>`
21
+ * and add a fresh empty `## [Unreleased]` block above it. This is
22
+ * the common case.
23
+ *
24
+ * Case B — `[<version>]` exists AND `[Unreleased]` has content:
25
+ * Merge `[Unreleased]`'s sub-sections (### Added / ### Fixed /
26
+ * ### Changed / ### Removed / ### Deprecated / ### Security) into
27
+ * the corresponding sub-sections of `[<version>]`. Unmatched
28
+ * sub-sections are appended to `[<version>]`. The `[Unreleased]`
29
+ * block is then emptied.
30
+ *
31
+ * Case C — `[Unreleased]` has no content:
32
+ * No-op. Exit 0. Re-runs of the workflow are safe.
33
+ *
34
+ * **Where the date comes from:** for Case A, `<YYYY-MM-DD>` is the
35
+ * UTC date at run time. Matches the existing CHANGELOG convention.
36
+ *
37
+ * **Usage:**
38
+ *
39
+ * node scripts/prepare-release.mjs # reads version from package.json
40
+ * node scripts/prepare-release.mjs 1.2.3 # explicit version
41
+ *
42
+ * **Output:**
43
+ *
44
+ * Writes CHANGELOG.md in place. Prints a summary line to stdout
45
+ * like `prepare-release: 0.9.5 — promoted 6 Unreleased entries`.
46
+ * Exits non-zero on parse failures.
47
+ */
48
+
49
+ import { readFileSync, writeFileSync } from 'node:fs';
50
+ import { resolve } from 'node:path';
51
+
52
+ const CHANGELOG_PATH = resolve(process.cwd(), 'CHANGELOG.md');
53
+
54
+ function readPackageVersion() {
55
+ const pkg = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf8'));
56
+ if (!pkg.version) throw new Error('package.json has no "version" field');
57
+ return pkg.version;
58
+ }
59
+
60
+ function todayUtcIsoDate() {
61
+ // YYYY-MM-DD in UTC. Matches the CHANGELOG's existing convention
62
+ // (the existing dated entries don't disclose a timezone, but UTC is
63
+ // stable across runners and is what the workflow's runner produces
64
+ // by default anyway).
65
+ return new Date().toISOString().slice(0, 10);
66
+ }
67
+
68
+ /**
69
+ * Split the CHANGELOG into a header preface + an ordered list of
70
+ * version blocks `{ header, body[] }`, preserving line content
71
+ * verbatim so we can re-join without surprises.
72
+ */
73
+ function parseChangelog(text) {
74
+ const lines = text.split('\n');
75
+ const versionHeaderRe = /^## \[([^\]]+)\](?:\s+-\s+(.+))?\s*$/;
76
+ const preface = [];
77
+ const blocks = []; // { header: string, name: string, body: string[] }
78
+ let cur = null;
79
+ for (const line of lines) {
80
+ const m = line.match(versionHeaderRe);
81
+ if (m) {
82
+ if (cur) blocks.push(cur);
83
+ cur = { header: line, name: m[1], date: m[2] ?? null, body: [] };
84
+ } else if (cur) {
85
+ cur.body.push(line);
86
+ } else {
87
+ preface.push(line);
88
+ }
89
+ }
90
+ if (cur) blocks.push(cur);
91
+ return { preface, blocks };
92
+ }
93
+
94
+ function joinChangelog({ preface, blocks }) {
95
+ const parts = [preface.join('\n')];
96
+ for (const b of blocks) {
97
+ // Reconstruct: header + body. The block body INCLUDES the blank
98
+ // line after the header (it was captured verbatim).
99
+ parts.push([b.header, ...b.body].join('\n'));
100
+ }
101
+ return parts.join('\n');
102
+ }
103
+
104
+ /**
105
+ * Split a block body into ordered sub-sections keyed by their
106
+ * `### Heading`. Lines before the first `### Heading` go in
107
+ * `leading`. Preserves the original (line-array) body inside each
108
+ * sub-section so we can splice cleanly when merging.
109
+ */
110
+ function splitSubsections(body) {
111
+ const subsectionRe = /^### (\w+)\s*$/;
112
+ const leading = [];
113
+ const subs = []; // { heading: 'Added' | 'Fixed' | …, headerLine: string, body: string[] }
114
+ let cur = null;
115
+ for (const line of body) {
116
+ const m = line.match(subsectionRe);
117
+ if (m) {
118
+ if (cur) subs.push(cur);
119
+ cur = { heading: m[1], headerLine: line, body: [] };
120
+ } else if (cur) {
121
+ cur.body.push(line);
122
+ } else {
123
+ leading.push(line);
124
+ }
125
+ }
126
+ if (cur) subs.push(cur);
127
+ return { leading, subs };
128
+ }
129
+
130
+ function rebuildBody({ leading, subs }) {
131
+ const parts = [];
132
+ if (leading.length) parts.push(leading.join('\n'));
133
+ for (const s of subs) {
134
+ parts.push([s.headerLine, ...s.body].join('\n'));
135
+ }
136
+ return parts.join('\n').split('\n');
137
+ }
138
+
139
+ /**
140
+ * Return true when the block has any meaningful entries (a bullet line
141
+ * starting with `-`, `*`, or a digit) — vs. being empty / just
142
+ * whitespace / just sub-section headers with nothing under them.
143
+ */
144
+ function blockHasContent(body) {
145
+ for (const line of body) {
146
+ if (/^\s*([-*]|\d+\.)\s+/.test(line)) return true;
147
+ }
148
+ return false;
149
+ }
150
+
151
+ /**
152
+ * Trim trailing blank lines from an array of lines, then return.
153
+ * Keeps the output tidy when merging.
154
+ */
155
+ function trimTrailingBlank(arr) {
156
+ let i = arr.length;
157
+ while (i > 0 && /^\s*$/.test(arr[i - 1])) i--;
158
+ return arr.slice(0, i);
159
+ }
160
+
161
+ function main() {
162
+ const versionArg = process.argv[2];
163
+ const version = versionArg || readPackageVersion();
164
+
165
+ const text = readFileSync(CHANGELOG_PATH, 'utf8');
166
+ const parsed = parseChangelog(text);
167
+
168
+ const unrelIdx = parsed.blocks.findIndex((b) => b.name === 'Unreleased');
169
+ const verIdx = parsed.blocks.findIndex((b) => b.name === version);
170
+
171
+ if (unrelIdx === -1) {
172
+ console.log(`prepare-release: no [Unreleased] block — nothing to do`);
173
+ return;
174
+ }
175
+
176
+ const unrel = parsed.blocks[unrelIdx];
177
+ if (!blockHasContent(unrel.body)) {
178
+ console.log(`prepare-release: [Unreleased] is empty — nothing to do`);
179
+ return;
180
+ }
181
+
182
+ if (verIdx === -1) {
183
+ // Case A — promote Unreleased → [version].
184
+ const today = todayUtcIsoDate();
185
+ const promoted = {
186
+ header: `## [${version}] - ${today}`,
187
+ name: version,
188
+ date: today,
189
+ body: trimTrailingBlank(unrel.body).concat(['']), // single trailing blank
190
+ };
191
+ const emptied = {
192
+ header: `## [Unreleased]`,
193
+ name: 'Unreleased',
194
+ date: null,
195
+ body: ['', ''], // two blank lines for the next round of entries
196
+ };
197
+ parsed.blocks.splice(unrelIdx, 1, emptied, promoted);
198
+ const next = joinChangelog(parsed);
199
+ writeFileSync(CHANGELOG_PATH, appendLinkRef(next, version));
200
+ console.log(`prepare-release: ${version} — renamed [Unreleased] to [${version}] - ${today}`);
201
+ return;
202
+ }
203
+
204
+ // Case B — merge Unreleased sub-sections into the existing
205
+ // [version] sub-sections. New sub-section headings encountered in
206
+ // Unreleased that don't exist in [version] get appended.
207
+ const ver = parsed.blocks[verIdx];
208
+ const unrelSubs = splitSubsections(unrel.body);
209
+ const verSubs = splitSubsections(ver.body);
210
+
211
+ let merged = 0;
212
+ for (const us of unrelSubs.subs) {
213
+ const target = verSubs.subs.find((s) => s.heading === us.heading);
214
+ const usBody = trimTrailingBlank(us.body);
215
+ if (usBody.length === 0) continue;
216
+ if (target) {
217
+ // Append Unreleased's entries to the end of the version's matching
218
+ // sub-section, keeping their original ordering. Insert a separating
219
+ // blank line if the existing sub-section doesn't already end in one.
220
+ const existing = trimTrailingBlank(target.body);
221
+ const sep = existing.length && !/^\s*$/.test(existing[existing.length - 1]) ? [''] : [];
222
+ target.body = existing.concat(sep, usBody, ['']);
223
+ } else {
224
+ // Append the whole sub-section to the end.
225
+ verSubs.subs.push({
226
+ heading: us.heading,
227
+ headerLine: us.headerLine,
228
+ body: usBody.concat(['']),
229
+ });
230
+ }
231
+ merged += usBody.filter((l) => /^\s*([-*]|\d+\.)\s+/.test(l)).length;
232
+ }
233
+
234
+ ver.body = rebuildBody(verSubs);
235
+ // Empty out Unreleased.
236
+ unrel.body = ['', ''];
237
+
238
+ const merged_text = joinChangelog(parsed);
239
+ writeFileSync(CHANGELOG_PATH, appendLinkRef(merged_text, version));
240
+ console.log(`prepare-release: ${version} — merged ${merged} Unreleased entries into existing [${version}] block`);
241
+ }
242
+
243
+ /**
244
+ * Append a `[X.Y.Z]: https://github.com/colbymchenry/codegraph/releases/tag/vX.Y.Z`
245
+ * link reference at the end of the file IF one doesn't already exist. The
246
+ * link ref is what makes `## [X.Y.Z]` heading text auto-link to its tag in
247
+ * GitHub's renderer; without it the heading still renders, just unlinked.
248
+ *
249
+ * Idempotent. The existing CHANGELOG mixes link refs scattered through the
250
+ * file and a sorted block at the bottom — we just append at the very end,
251
+ * which CommonMark accepts regardless.
252
+ */
253
+ function appendLinkRef(text, version) {
254
+ const refLine = `[${version}]: https://github.com/colbymchenry/codegraph/releases/tag/v${version}`;
255
+ // Already there? Look for a line that EQUALS this (anywhere in the file)
256
+ // to keep idempotency robust against the scattered-vs-block layout.
257
+ const lines = text.split('\n');
258
+ if (lines.some((l) => l.trim() === refLine)) return text;
259
+ // Append, separated by a blank line from the prior content. Preserve a
260
+ // single trailing newline at EOF.
261
+ const trailingNewline = text.endsWith('\n') ? '' : '\n';
262
+ return text + trailingNewline + refLine + '\n';
263
+ }
264
+
265
+ try {
266
+ main();
267
+ } catch (err) {
268
+ console.error(`prepare-release: ${err?.message ?? err}`);
269
+ process.exit(1);
270
+ }
@@ -1,112 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Patches tree-sitter-dart to use NAPI bindings compatible with tree-sitter 0.22+
4
- *
5
- * tree-sitter-dart v1.0.0 ships with NAN-style bindings that are incompatible
6
- * with tree-sitter 0.22+ which expects NAPI-style bindings with type-tagged
7
- * externals. This script rewrites the binding files and rebuilds.
8
- */
9
- const { writeFileSync, existsSync } = require('fs');
10
- const { join } = require('path');
11
- const { execSync } = require('child_process');
12
-
13
- const DART_DIR = join(__dirname, '..', 'node_modules', 'tree-sitter-dart');
14
-
15
- if (!existsSync(DART_DIR)) {
16
- // tree-sitter-dart not installed, skip
17
- process.exit(0);
18
- }
19
-
20
- // Check if already patched (look for NAPI-style binding)
21
- const bindingPath = join(DART_DIR, 'bindings', 'node', 'binding.cc');
22
- const { readFileSync } = require('fs');
23
- try {
24
- const existing = readFileSync(bindingPath, 'utf8');
25
- if (existing.includes('napi.h')) {
26
- // Already patched, check if build exists
27
- const buildPath = join(DART_DIR, 'build', 'Release', 'tree_sitter_dart_binding.node');
28
- if (existsSync(buildPath)) {
29
- console.log('tree-sitter-dart: already patched and built.');
30
- process.exit(0);
31
- }
32
- // Patched but not built, fall through to rebuild
33
- }
34
- } catch {
35
- // Can't read, continue with patch
36
- }
37
-
38
- console.log('Patching tree-sitter-dart for NAPI compatibility...');
39
-
40
- // Write NAPI-compatible binding.cc
41
- const bindingCC = `#include <napi.h>
42
-
43
- typedef struct TSLanguage TSLanguage;
44
-
45
- extern "C" TSLanguage *tree_sitter_dart();
46
-
47
- // "tree-sitter", "language" hashed with BLAKE2
48
- const napi_type_tag LANGUAGE_TYPE_TAG = {
49
- 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
50
- };
51
-
52
- Napi::Object Init(Napi::Env env, Napi::Object exports) {
53
- exports["name"] = Napi::String::New(env, "dart");
54
- auto language = Napi::External<TSLanguage>::New(env, tree_sitter_dart());
55
- language.TypeTag(&LANGUAGE_TYPE_TAG);
56
- exports["language"] = language;
57
- return exports;
58
- }
59
-
60
- NODE_API_MODULE(tree_sitter_dart_binding, Init)
61
- `;
62
- writeFileSync(bindingPath, bindingCC);
63
-
64
- // Write NAPI-compatible binding.gyp
65
- const bindingGyp = `{
66
- "targets": [
67
- {
68
- "target_name": "tree_sitter_dart_binding",
69
- "dependencies": [
70
- "<!(node -p \\"require('node-addon-api').targets\\"):node_addon_api_except"
71
- ],
72
- "include_dirs": [
73
- "src"
74
- ],
75
- "sources": [
76
- "src/parser.c",
77
- "bindings/node/binding.cc",
78
- "src/scanner.c"
79
- ],
80
- "conditions": [
81
- ["OS!='win'", {
82
- "cflags_c": [
83
- "-std=c99"
84
- ]
85
- }, {
86
- "cflags_c": [
87
- "/std:c11",
88
- "/utf-8"
89
- ]
90
- }]
91
- ]
92
- }
93
- ]
94
- }
95
- `;
96
- writeFileSync(join(DART_DIR, 'binding.gyp'), bindingGyp);
97
-
98
- // Rebuild native module
99
- try {
100
- execSync('npx node-gyp rebuild', {
101
- cwd: DART_DIR,
102
- stdio: 'pipe',
103
- timeout: 120000,
104
- });
105
- console.log('tree-sitter-dart: patched and rebuilt successfully.');
106
- } catch (error) {
107
- console.error('Warning: Failed to rebuild tree-sitter-dart native module.');
108
- console.error('Dart language support may not work.');
109
- if (process.env.DEBUG) {
110
- console.error(error.stderr?.toString());
111
- }
112
- }
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Tag the current commit with the version in package.json and publish a
3
- # matching GitHub Release whose body is the corresponding CHANGELOG.md entry.
4
- #
5
- # Run AFTER you have:
6
- # - bumped package.json
7
- # - added a `## [X.Y.Z] - YYYY-MM-DD` block at the top of CHANGELOG.md
8
- # - committed, pushed to origin, and run `npm publish`
9
- #
10
- # Idempotent: safe to re-run after a partial failure. Skips steps that are
11
- # already done (tag created, tag pushed, release published).
12
- #
13
- # Usage: ./scripts/release.sh
14
-
15
- set -euo pipefail
16
-
17
- cd "$(dirname "$0")/.."
18
-
19
- VERSION=$(node -p "require('./package.json').version")
20
- TAG="v${VERSION}"
21
-
22
- REPO=$(git remote get-url origin | sed -E 's|.*github\.com[:/]||; s|\.git$||')
23
- if [ -z "${REPO}" ]; then
24
- echo "error: could not derive owner/repo from origin remote URL" >&2
25
- exit 1
26
- fi
27
-
28
- if ! grep -q "^## \[${VERSION}\]" CHANGELOG.md; then
29
- echo "error: no '## [${VERSION}]' entry found in CHANGELOG.md" >&2
30
- exit 1
31
- fi
32
-
33
- # Extract notes with paragraph unwrapping — GitHub Releases render with
34
- # GFM hard-breaks, so the CHANGELOG's hard-wrapped lines would show as
35
- # visible `<br>` breaks otherwise. The helper joins continuation lines
36
- # into a single line per bullet.
37
- NOTES=$(node scripts/extract-release-notes.mjs "${VERSION}")
38
-
39
- if [ -z "${NOTES}" ]; then
40
- echo "error: failed to extract changelog notes for ${VERSION}" >&2
41
- exit 1
42
- fi
43
-
44
- if git rev-parse "${TAG}" >/dev/null 2>&1; then
45
- echo "✓ tag ${TAG} already exists locally"
46
- else
47
- echo "→ tagging ${TAG}"
48
- git tag "${TAG}"
49
- fi
50
-
51
- if git ls-remote --exit-code --tags origin "${TAG}" >/dev/null 2>&1; then
52
- echo "✓ tag ${TAG} already on origin"
53
- else
54
- echo "→ pushing ${TAG} to origin"
55
- git push origin "${TAG}"
56
- fi
57
-
58
- if gh release view "${TAG}" --repo "${REPO}" >/dev/null 2>&1; then
59
- echo "✓ release ${TAG} already published"
60
- else
61
- echo "→ creating GitHub Release ${TAG} on ${REPO}"
62
- gh release create "${TAG}" \
63
- --repo "${REPO}" \
64
- --title "${TAG}" \
65
- --notes "${NOTES}"
66
- fi
67
-
68
- echo "done: https://github.com/${REPO}/releases/tag/${TAG}"