@saluzi/codegraph 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +885 -0
- package/dist/bin/codegraph.d.ts +2 -1
- package/dist/bin/codegraph.d.ts.map +1 -0
- package/dist/bin/codegraph.js +2248 -0
- package/dist/bin/codegraph.js.map +1 -0
- package/dist/bin/command-supervision.d.ts +49 -0
- package/dist/bin/command-supervision.d.ts.map +1 -0
- package/dist/bin/command-supervision.js +95 -0
- package/dist/bin/command-supervision.js.map +1 -0
- package/dist/bin/fatal-handler.d.ts +20 -0
- package/dist/bin/fatal-handler.d.ts.map +1 -0
- package/dist/bin/fatal-handler.js +118 -0
- package/dist/bin/fatal-handler.js.map +1 -0
- package/dist/bin/node-version-check.d.ts.map +1 -0
- package/dist/bin/node-version-check.js +79 -0
- package/dist/bin/node-version-check.js.map +1 -0
- package/dist/bin/uninstall.d.ts.map +1 -0
- package/dist/bin/uninstall.js +36 -0
- package/dist/bin/uninstall.js.map +1 -0
- package/dist/context/formatter.d.ts +6 -9
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +25 -6
- package/dist/context/formatter.js.map +1 -0
- package/dist/context/index.d.ts +102 -100
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +252 -6
- package/dist/context/index.js.map +1 -0
- package/dist/context/markers.d.ts +19 -0
- package/dist/context/markers.d.ts.map +1 -0
- package/dist/context/markers.js +22 -0
- package/dist/context/markers.js.map +1 -0
- package/dist/db/index.d.ts +185 -85
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +257 -14
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +15 -18
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +82 -1
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/queries.d.ts +503 -281
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +644 -107
- package/dist/db/queries.js.map +1 -0
- package/dist/db/schema.sql +69 -26
- package/dist/db/sqlite-adapter.d.ts +26 -22
- package/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/db/sqlite-adapter.js +11 -35
- package/dist/db/sqlite-adapter.js.map +1 -0
- package/dist/db/wal-valve.d.ts +106 -0
- package/dist/db/wal-valve.d.ts.map +1 -0
- package/dist/db/wal-valve.js +208 -0
- package/dist/db/wal-valve.js.map +1 -0
- package/dist/directory.d.ts +140 -19
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +568 -35
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +32 -45
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js.map +1 -0
- package/dist/extraction/astro-extractor.d.ts +79 -0
- package/dist/extraction/astro-extractor.d.ts.map +1 -0
- package/dist/extraction/astro-extractor.js +320 -0
- package/dist/extraction/astro-extractor.js.map +1 -0
- package/dist/extraction/cfml-extractor.d.ts +107 -0
- package/dist/extraction/cfml-extractor.d.ts.map +1 -0
- package/dist/extraction/cfml-extractor.js +494 -0
- package/dist/extraction/cfml-extractor.js.map +1 -0
- package/dist/extraction/dfm-extractor.d.ts +17 -17
- package/dist/extraction/dfm-extractor.d.ts.map +1 -0
- package/dist/extraction/dfm-extractor.js.map +1 -0
- package/dist/extraction/extraction-version.d.ts +25 -0
- package/dist/extraction/extraction-version.d.ts.map +1 -0
- package/dist/extraction/extraction-version.js +28 -0
- package/dist/extraction/extraction-version.js.map +1 -0
- package/dist/extraction/function-ref.d.ts +118 -0
- package/dist/extraction/function-ref.d.ts.map +1 -0
- package/dist/extraction/function-ref.js +727 -0
- package/dist/extraction/function-ref.js.map +1 -0
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/generated-detection.d.ts.map +1 -0
- package/dist/extraction/generated-detection.js +83 -0
- package/dist/extraction/generated-detection.js.map +1 -0
- package/dist/extraction/grammars.d.ts +74 -30
- package/dist/extraction/grammars.d.ts.map +1 -0
- package/dist/extraction/grammars.js +289 -15
- package/dist/extraction/grammars.js.map +1 -0
- package/dist/extraction/index.d.ts +193 -109
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +1485 -362
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/languages/arkts.d.ts +3 -0
- package/dist/extraction/languages/arkts.d.ts.map +1 -0
- package/dist/extraction/languages/arkts.js +127 -0
- package/dist/extraction/languages/arkts.js.map +1 -0
- package/dist/extraction/languages/c-cpp.d.ts +110 -4
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
- package/dist/extraction/languages/c-cpp.js +713 -2
- package/dist/extraction/languages/c-cpp.js.map +1 -0
- package/dist/extraction/languages/cfquery.d.ts +12 -0
- package/dist/extraction/languages/cfquery.d.ts.map +1 -0
- package/dist/extraction/languages/cfquery.js +28 -0
- package/dist/extraction/languages/cfquery.js.map +1 -0
- package/dist/extraction/languages/cfscript.d.ts +3 -0
- package/dist/extraction/languages/cfscript.d.ts.map +1 -0
- package/dist/extraction/languages/cfscript.js +73 -0
- package/dist/extraction/languages/cfscript.js.map +1 -0
- package/dist/extraction/languages/cobol.d.ts +33 -0
- package/dist/extraction/languages/cobol.d.ts.map +1 -0
- package/dist/extraction/languages/cobol.js +499 -0
- package/dist/extraction/languages/cobol.js.map +1 -0
- package/dist/extraction/languages/csharp.d.ts +25 -3
- package/dist/extraction/languages/csharp.d.ts.map +1 -0
- package/dist/extraction/languages/csharp.js +106 -3
- package/dist/extraction/languages/csharp.js.map +1 -0
- package/dist/extraction/languages/dart.d.ts +3 -3
- package/dist/extraction/languages/dart.d.ts.map +1 -0
- package/dist/extraction/languages/dart.js +183 -1
- package/dist/extraction/languages/dart.js.map +1 -0
- package/dist/extraction/languages/erlang.d.ts +3 -0
- package/dist/extraction/languages/erlang.d.ts.map +1 -0
- package/dist/extraction/languages/erlang.js +350 -0
- package/dist/extraction/languages/erlang.js.map +1 -0
- package/dist/extraction/languages/go.d.ts +3 -3
- package/dist/extraction/languages/go.d.ts.map +1 -0
- package/dist/extraction/languages/go.js +55 -2
- package/dist/extraction/languages/go.js.map +1 -0
- package/dist/extraction/languages/index.d.ts +4 -4
- package/dist/extraction/languages/index.d.ts.map +1 -0
- package/dist/extraction/languages/index.js +22 -0
- package/dist/extraction/languages/index.js.map +1 -0
- package/dist/extraction/languages/java.d.ts +3 -3
- package/dist/extraction/languages/java.d.ts.map +1 -0
- package/dist/extraction/languages/java.js +252 -1
- package/dist/extraction/languages/java.js.map +1 -0
- package/dist/extraction/languages/javascript.d.ts +3 -3
- package/dist/extraction/languages/javascript.d.ts.map +1 -0
- package/dist/extraction/languages/javascript.js +16 -0
- package/dist/extraction/languages/javascript.js.map +1 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -3
- package/dist/extraction/languages/kotlin.d.ts.map +1 -0
- package/dist/extraction/languages/kotlin.js +126 -0
- package/dist/extraction/languages/kotlin.js.map +1 -0
- package/dist/extraction/languages/lua.d.ts +3 -3
- package/dist/extraction/languages/lua.d.ts.map +1 -0
- package/dist/extraction/languages/lua.js.map +1 -0
- package/dist/extraction/languages/luau.d.ts +3 -3
- package/dist/extraction/languages/luau.d.ts.map +1 -0
- package/dist/extraction/languages/luau.js.map +1 -0
- package/dist/extraction/languages/nix.d.ts +3 -0
- package/dist/extraction/languages/nix.d.ts.map +1 -0
- package/dist/extraction/languages/nix.js +294 -0
- package/dist/extraction/languages/nix.js.map +1 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts.map +1 -0
- package/dist/extraction/languages/objc.js +175 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/languages/pascal.d.ts +3 -3
- package/dist/extraction/languages/pascal.d.ts.map +1 -0
- package/dist/extraction/languages/pascal.js +11 -0
- package/dist/extraction/languages/pascal.js.map +1 -0
- package/dist/extraction/languages/php.d.ts +3 -3
- package/dist/extraction/languages/php.d.ts.map +1 -0
- package/dist/extraction/languages/php.js +90 -1
- package/dist/extraction/languages/php.js.map +1 -0
- package/dist/extraction/languages/python.d.ts +3 -3
- package/dist/extraction/languages/python.d.ts.map +1 -0
- package/dist/extraction/languages/python.js.map +1 -0
- package/dist/extraction/languages/r.d.ts +3 -0
- package/dist/extraction/languages/r.d.ts.map +1 -0
- package/dist/extraction/languages/r.js +314 -0
- package/dist/extraction/languages/r.js.map +1 -0
- package/dist/extraction/languages/ruby.d.ts +3 -3
- package/dist/extraction/languages/ruby.d.ts.map +1 -0
- package/dist/extraction/languages/ruby.js +35 -0
- package/dist/extraction/languages/ruby.js.map +1 -0
- package/dist/extraction/languages/rust.d.ts +3 -3
- package/dist/extraction/languages/rust.d.ts.map +1 -0
- package/dist/extraction/languages/rust.js +35 -2
- package/dist/extraction/languages/rust.js.map +1 -0
- package/dist/extraction/languages/scala.d.ts +3 -3
- package/dist/extraction/languages/scala.d.ts.map +1 -0
- package/dist/extraction/languages/scala.js +80 -10
- package/dist/extraction/languages/scala.js.map +1 -0
- package/dist/extraction/languages/solidity.d.ts +3 -0
- package/dist/extraction/languages/solidity.d.ts.map +1 -0
- package/dist/extraction/languages/solidity.js +293 -0
- package/dist/extraction/languages/solidity.js.map +1 -0
- package/dist/extraction/languages/swift.d.ts +3 -3
- package/dist/extraction/languages/swift.d.ts.map +1 -0
- package/dist/extraction/languages/swift.js +61 -0
- package/dist/extraction/languages/swift.js.map +1 -0
- package/dist/extraction/languages/terraform.d.ts +3 -0
- package/dist/extraction/languages/terraform.d.ts.map +1 -0
- package/dist/extraction/languages/terraform.js +641 -0
- package/dist/extraction/languages/terraform.js.map +1 -0
- package/dist/extraction/languages/typescript.d.ts +16 -3
- package/dist/extraction/languages/typescript.d.ts.map +1 -0
- package/dist/extraction/languages/typescript.js +38 -0
- package/dist/extraction/languages/typescript.js.map +1 -0
- package/dist/extraction/languages/vbnet.d.ts +11 -0
- package/dist/extraction/languages/vbnet.d.ts.map +1 -0
- package/dist/extraction/languages/vbnet.js +141 -0
- package/dist/extraction/languages/vbnet.js.map +1 -0
- package/dist/extraction/liquid-extractor.d.ts +48 -41
- package/dist/extraction/liquid-extractor.d.ts.map +1 -0
- package/dist/extraction/liquid-extractor.js +53 -9
- package/dist/extraction/liquid-extractor.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +68 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +300 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/parse-pool.d.ts +152 -0
- package/dist/extraction/parse-pool.d.ts.map +1 -0
- package/dist/extraction/parse-pool.js +387 -0
- package/dist/extraction/parse-pool.js.map +1 -0
- package/dist/extraction/parse-worker.d.ts +2 -2
- package/dist/extraction/parse-worker.d.ts.map +1 -0
- package/dist/extraction/parse-worker.js +13 -3
- package/dist/extraction/parse-worker.js.map +1 -0
- package/dist/extraction/razor-extractor.d.ts +42 -0
- package/dist/extraction/razor-extractor.d.ts.map +1 -0
- package/dist/extraction/razor-extractor.js +285 -0
- package/dist/extraction/razor-extractor.js.map +1 -0
- package/dist/extraction/svelte-extractor.d.ts +42 -42
- package/dist/extraction/svelte-extractor.d.ts.map +1 -0
- package/dist/extraction/svelte-extractor.js +6 -3
- package/dist/extraction/svelte-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +7 -18
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-helpers.js +60 -10
- package/dist/extraction/tree-sitter-helpers.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +224 -157
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-types.js.map +1 -0
- package/dist/extraction/tree-sitter.d.ts +689 -221
- package/dist/extraction/tree-sitter.d.ts.map +1 -0
- package/dist/extraction/tree-sitter.js +4193 -117
- package/dist/extraction/tree-sitter.js.map +1 -0
- package/dist/extraction/vue-extractor.d.ts +40 -25
- package/dist/extraction/vue-extractor.d.ts.map +1 -0
- package/dist/extraction/vue-extractor.js +94 -3
- package/dist/extraction/vue-extractor.js.map +1 -0
- package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +6 -14
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/dist/extraction/wasm-runtime-flags.js +1 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +96 -99
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +13 -40
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/traversal.d.ts +117 -127
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +92 -21
- package/dist/graph/traversal.js.map +1 -0
- package/dist/index.d.ts +615 -481
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +709 -18
- package/dist/index.js.map +1 -0
- package/dist/installer/config-writer.d.ts +13 -14
- package/dist/installer/config-writer.d.ts.map +1 -0
- package/dist/installer/config-writer.js +91 -0
- package/dist/installer/config-writer.js.map +1 -0
- package/dist/installer/index.d.ts +84 -82
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +619 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/instructions-template.d.ts +35 -24
- package/dist/installer/instructions-template.d.ts.map +1 -0
- package/dist/installer/instructions-template.js +53 -0
- package/dist/installer/instructions-template.js.map +1 -0
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/antigravity.d.ts.map +1 -0
- package/dist/installer/targets/antigravity.js +308 -0
- package/dist/installer/targets/antigravity.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +34 -27
- package/dist/installer/targets/claude.d.ts.map +1 -0
- package/dist/installer/targets/claude.js +454 -0
- package/dist/installer/targets/claude.js.map +1 -0
- package/dist/installer/targets/codex.d.ts +3 -3
- package/dist/installer/targets/codex.d.ts.map +1 -0
- package/dist/installer/targets/codex.js +185 -0
- package/dist/installer/targets/codex.js.map +1 -0
- package/dist/installer/targets/cursor.d.ts +3 -3
- package/dist/installer/targets/cursor.d.ts.map +1 -0
- package/dist/installer/targets/cursor.js +254 -0
- package/dist/installer/targets/cursor.js.map +1 -0
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/gemini.d.ts.map +1 -0
- package/dist/installer/targets/gemini.js +165 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts +3 -3
- package/dist/installer/targets/hermes.d.ts.map +1 -0
- package/dist/installer/targets/hermes.js +359 -0
- package/dist/installer/targets/hermes.js.map +1 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/kiro.d.ts.map +1 -0
- package/dist/installer/targets/kiro.js +178 -0
- package/dist/installer/targets/kiro.js.map +1 -0
- package/dist/installer/targets/opencode.d.ts +12 -4
- package/dist/installer/targets/opencode.d.ts.map +1 -0
- package/dist/installer/targets/opencode.js +288 -0
- package/dist/installer/targets/opencode.js.map +1 -0
- package/dist/installer/targets/registry.d.ts +9 -12
- package/dist/installer/targets/registry.d.ts.map +1 -0
- package/dist/installer/targets/registry.js +91 -0
- package/dist/installer/targets/registry.js.map +1 -0
- package/dist/installer/targets/shared.d.ts +38 -29
- package/dist/installer/targets/shared.d.ts.map +1 -0
- package/dist/installer/targets/shared.js +264 -0
- package/dist/installer/targets/shared.js.map +1 -0
- package/dist/installer/targets/toml.d.ts +11 -23
- package/dist/installer/targets/toml.d.ts.map +1 -0
- package/dist/installer/targets/toml.js +147 -0
- package/dist/installer/targets/toml.js.map +1 -0
- package/dist/installer/targets/types.d.ts +62 -76
- package/dist/installer/targets/types.d.ts.map +1 -0
- package/dist/installer/targets/types.js +16 -0
- package/dist/installer/targets/types.js.map +1 -0
- package/dist/mcp/daemon-manager.d.ts +42 -0
- package/dist/mcp/daemon-manager.d.ts.map +1 -0
- package/dist/mcp/daemon-manager.js +129 -0
- package/dist/mcp/daemon-manager.js.map +1 -0
- package/dist/mcp/daemon-paths.d.ts +73 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +165 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon-registry.d.ts +47 -0
- package/dist/mcp/daemon-registry.d.ts.map +1 -0
- package/dist/mcp/daemon-registry.js +233 -0
- package/dist/mcp/daemon-registry.js.map +1 -0
- package/dist/mcp/daemon.d.ts +290 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +862 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
- package/dist/mcp/dynamic-boundaries.js +360 -0
- package/dist/mcp/dynamic-boundaries.js.map +1 -0
- package/dist/mcp/early-ppid.d.ts +26 -0
- package/dist/mcp/early-ppid.d.ts.map +1 -0
- package/dist/mcp/early-ppid.js +29 -0
- package/dist/mcp/early-ppid.js.map +1 -0
- package/dist/mcp/engine.d.ts +122 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +350 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +89 -74
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +506 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/liveness-watchdog.d.ts +35 -0
- package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
- package/dist/mcp/liveness-watchdog.js +267 -0
- package/dist/mcp/liveness-watchdog.js.map +1 -0
- package/dist/mcp/ppid-watchdog.d.ts +62 -0
- package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
- package/dist/mcp/ppid-watchdog.js +64 -0
- package/dist/mcp/ppid-watchdog.js.map +1 -0
- package/dist/mcp/proxy.d.ts +87 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +667 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/query-pool.d.ts +108 -0
- package/dist/mcp/query-pool.d.ts.map +1 -0
- package/dist/mcp/query-pool.js +315 -0
- package/dist/mcp/query-pool.js.map +1 -0
- package/dist/mcp/query-worker.d.ts +24 -0
- package/dist/mcp/query-worker.d.ts.map +1 -0
- package/dist/mcp/query-worker.js +87 -0
- package/dist/mcp/query-worker.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +22 -8
- package/dist/mcp/server-instructions.d.ts.map +1 -0
- package/dist/mcp/server-instructions.js +106 -0
- package/dist/mcp/server-instructions.js.map +1 -0
- package/dist/mcp/session.d.ts +93 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +357 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/startup-handshake.d.ts +44 -0
- package/dist/mcp/startup-handshake.d.ts.map +1 -0
- package/dist/mcp/startup-handshake.js +73 -0
- package/dist/mcp/startup-handshake.js.map +1 -0
- package/dist/mcp/stdin-teardown.d.ts +27 -0
- package/dist/mcp/stdin-teardown.d.ts.map +1 -0
- package/dist/mcp/stdin-teardown.js +49 -0
- package/dist/mcp/stdin-teardown.js.map +1 -0
- package/dist/mcp/tools.d.ts +557 -213
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +4477 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/transport.d.ts +158 -87
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +377 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/mcp/version.d.ts +19 -0
- package/dist/mcp/version.d.ts.map +1 -0
- package/dist/mcp/version.js +71 -0
- package/dist/mcp/version.js.map +1 -0
- package/dist/project-config.d.ts +94 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +374 -0
- package/dist/project-config.js.map +1 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
- package/dist/resolution/c-fnptr-synthesizer.js +1062 -0
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
- package/dist/resolution/callback-synthesizer.d.ts +15 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +3938 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/cooperative-yield.d.ts +32 -0
- package/dist/resolution/cooperative-yield.d.ts.map +1 -0
- package/dist/resolution/cooperative-yield.js +42 -0
- package/dist/resolution/cooperative-yield.js.map +1 -0
- package/dist/resolution/frameworks/astro.d.ts +9 -0
- package/dist/resolution/frameworks/astro.d.ts.map +1 -0
- package/dist/resolution/frameworks/astro.js +169 -0
- package/dist/resolution/frameworks/astro.js.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +3 -5
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
- package/dist/resolution/frameworks/cics.d.ts +20 -0
- package/dist/resolution/frameworks/cics.d.ts.map +1 -0
- package/dist/resolution/frameworks/cics.js +90 -0
- package/dist/resolution/frameworks/cics.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts +3 -3
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
- package/dist/resolution/frameworks/csharp.js +36 -8
- package/dist/resolution/frameworks/csharp.js.map +1 -0
- package/dist/resolution/frameworks/drupal.d.ts +3 -3
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/dist/resolution/frameworks/drupal.js +44 -12
- package/dist/resolution/frameworks/drupal.js.map +1 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/dist/resolution/frameworks/expo-modules.js +148 -0
- package/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts +3 -3
- package/dist/resolution/frameworks/express.d.ts.map +1 -0
- package/dist/resolution/frameworks/express.js +102 -19
- package/dist/resolution/frameworks/express.js.map +1 -0
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/dist/resolution/frameworks/fabric.js +354 -0
- package/dist/resolution/frameworks/fabric.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts +3 -3
- package/dist/resolution/frameworks/go.d.ts.map +1 -0
- package/dist/resolution/frameworks/go.js +6 -3
- package/dist/resolution/frameworks/go.js.map +1 -0
- package/dist/resolution/frameworks/goframe.d.ts +41 -0
- package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
- package/dist/resolution/frameworks/goframe.js +112 -0
- package/dist/resolution/frameworks/goframe.js.map +1 -0
- package/dist/resolution/frameworks/index.d.ts +29 -31
- package/dist/resolution/frameworks/index.d.ts.map +1 -0
- package/dist/resolution/frameworks/index.js +39 -1
- package/dist/resolution/frameworks/index.js.map +1 -0
- package/dist/resolution/frameworks/java.d.ts +3 -3
- package/dist/resolution/frameworks/java.d.ts.map +1 -0
- package/dist/resolution/frameworks/java.js +352 -12
- package/dist/resolution/frameworks/java.js.map +1 -0
- package/dist/resolution/frameworks/laravel.d.ts +4 -4
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
- package/dist/resolution/frameworks/laravel.js +17 -8
- package/dist/resolution/frameworks/laravel.js.map +1 -0
- package/dist/resolution/frameworks/nestjs.d.ts +3 -3
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
- package/dist/resolution/frameworks/nestjs.js +324 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -0
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/dist/resolution/frameworks/play.js +111 -0
- package/dist/resolution/frameworks/play.js.map +1 -0
- package/dist/resolution/frameworks/python.d.ts +5 -5
- package/dist/resolution/frameworks/python.d.ts.map +1 -0
- package/dist/resolution/frameworks/python.js +138 -16
- package/dist/resolution/frameworks/python.js.map +1 -0
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/dist/resolution/frameworks/react-native.js +410 -0
- package/dist/resolution/frameworks/react-native.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts +3 -3
- package/dist/resolution/frameworks/react.d.ts.map +1 -0
- package/dist/resolution/frameworks/react.js +122 -60
- package/dist/resolution/frameworks/react.js.map +1 -0
- package/dist/resolution/frameworks/ruby.d.ts +3 -3
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
- package/dist/resolution/frameworks/ruby.js +106 -2
- package/dist/resolution/frameworks/ruby.js.map +1 -0
- package/dist/resolution/frameworks/rust.d.ts +3 -3
- package/dist/resolution/frameworks/rust.d.ts.map +1 -0
- package/dist/resolution/frameworks/rust.js +102 -5
- package/dist/resolution/frameworks/rust.js.map +1 -0
- package/dist/resolution/frameworks/svelte.d.ts +3 -3
- package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
- package/dist/resolution/frameworks/svelte.js +5 -1
- package/dist/resolution/frameworks/svelte.js.map +1 -0
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift-objc.js +252 -0
- package/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/dist/resolution/frameworks/swift.d.ts +5 -5
- package/dist/resolution/frameworks/swift.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift.js +30 -6
- package/dist/resolution/frameworks/swift.js.map +1 -0
- package/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
- package/dist/resolution/frameworks/terraform.js +277 -0
- package/dist/resolution/frameworks/terraform.js.map +1 -0
- package/dist/resolution/frameworks/vue.d.ts +3 -3
- package/dist/resolution/frameworks/vue.d.ts.map +1 -0
- package/dist/resolution/frameworks/vue.js +24 -27
- package/dist/resolution/frameworks/vue.js.map +1 -0
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/go-module.d.ts.map +1 -0
- package/dist/resolution/go-module.js +78 -0
- package/dist/resolution/go-module.js.map +1 -0
- package/dist/resolution/goframe-synthesizer.d.ts +29 -0
- package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
- package/dist/resolution/goframe-synthesizer.js +163 -0
- package/dist/resolution/goframe-synthesizer.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +53 -29
- package/dist/resolution/import-resolver.d.ts.map +1 -0
- package/dist/resolution/import-resolver.js +1319 -8
- package/dist/resolution/import-resolver.js.map +1 -0
- package/dist/resolution/index.d.ts +243 -103
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +1055 -53
- package/dist/resolution/index.js.map +1 -0
- package/dist/resolution/lru-cache.d.ts +9 -9
- package/dist/resolution/lru-cache.d.ts.map +1 -0
- package/dist/resolution/lru-cache.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +91 -29
- package/dist/resolution/name-matcher.d.ts.map +1 -0
- package/dist/resolution/name-matcher.js +1478 -32
- package/dist/resolution/name-matcher.js.map +1 -0
- package/dist/resolution/path-aliases.d.ts +23 -27
- package/dist/resolution/path-aliases.d.ts.map +1 -0
- package/dist/resolution/path-aliases.js.map +1 -0
- package/dist/resolution/strip-comments.d.ts +3 -16
- package/dist/resolution/strip-comments.d.ts.map +1 -0
- package/dist/resolution/strip-comments.js +51 -0
- package/dist/resolution/strip-comments.js.map +1 -0
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/dist/resolution/swift-objc-bridge.js +256 -0
- package/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/dist/resolution/types.d.ts +217 -136
- package/dist/resolution/types.d.ts.map +1 -0
- package/dist/resolution/types.js.map +1 -0
- package/dist/resolution/workspace-packages.d.ts +58 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/dist/resolution/workspace-packages.js +346 -0
- package/dist/resolution/workspace-packages.js.map +1 -0
- package/dist/search/identifier-segments.d.ts +60 -0
- package/dist/search/identifier-segments.d.ts.map +1 -0
- package/dist/search/identifier-segments.js +176 -0
- package/dist/search/identifier-segments.js.map +1 -0
- package/dist/search/query-parser.d.ts +14 -18
- package/dist/search/query-parser.d.ts.map +1 -0
- package/dist/search/query-parser.js.map +1 -0
- package/dist/search/query-utils.d.ts +45 -17
- package/dist/search/query-utils.d.ts.map +1 -0
- package/dist/search/query-utils.js +113 -47
- package/dist/search/query-utils.js.map +1 -0
- package/dist/sync/git-hooks.d.ts +13 -22
- package/dist/sync/git-hooks.d.ts.map +1 -0
- package/dist/sync/git-hooks.js +4 -0
- package/dist/sync/git-hooks.js.map +1 -0
- package/dist/sync/index.d.ts +6 -12
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +8 -1
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/watch-policy.d.ts +8 -11
- package/dist/sync/watch-policy.d.ts.map +1 -0
- package/dist/sync/watch-policy.js.map +1 -0
- package/dist/sync/watcher.d.ts +335 -63
- package/dist/sync/watcher.d.ts.map +1 -0
- package/dist/sync/watcher.js +709 -53
- package/dist/sync/watcher.js.map +1 -0
- package/dist/sync/worktree.d.ts +63 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +182 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/telemetry/index.d.ts +143 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +541 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/types.d.ts +308 -326
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/glyphs.d.ts +20 -20
- package/dist/ui/glyphs.d.ts.map +1 -0
- package/dist/ui/glyphs.js +78 -0
- package/dist/ui/glyphs.js.map +1 -0
- package/dist/ui/shimmer-progress.d.ts +7 -7
- package/dist/ui/shimmer-progress.d.ts.map +1 -0
- package/dist/ui/shimmer-progress.js +90 -0
- package/dist/ui/shimmer-progress.js.map +1 -0
- package/dist/ui/shimmer-worker.d.ts +2 -2
- package/dist/ui/shimmer-worker.d.ts.map +1 -0
- package/dist/ui/shimmer-worker.js +118 -0
- package/dist/ui/shimmer-worker.js.map +1 -0
- package/dist/ui/types.d.ts +14 -17
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +3 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/upgrade/index.d.ts +164 -0
- package/dist/upgrade/index.d.ts.map +1 -0
- package/dist/upgrade/index.js +646 -0
- package/dist/upgrade/index.js.map +1 -0
- package/dist/upgrade/remove-binary.d.ts +87 -0
- package/dist/upgrade/remove-binary.d.ts.map +1 -0
- package/dist/upgrade/remove-binary.js +289 -0
- package/dist/upgrade/remove-binary.js.map +1 -0
- package/dist/upgrade/update-check.d.ts +92 -0
- package/dist/upgrade/update-check.d.ts.map +1 -0
- package/dist/upgrade/update-check.js +258 -0
- package/dist/upgrade/update-check.js.map +1 -0
- package/dist/utils.d.ts +116 -123
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +83 -49
- package/dist/utils.js.map +1 -0
- package/package.json +42 -10
- package/scripts/add-lang/bench.sh +60 -0
- package/scripts/add-lang/check-grammar.mjs +75 -0
- package/scripts/add-lang/dump-ast.mjs +103 -0
- package/scripts/add-lang/verify-extraction.mjs +70 -0
- package/scripts/agent-eval/ab-adoption.sh +91 -0
- package/scripts/agent-eval/ab-hook.sh +86 -0
- package/scripts/agent-eval/ab-impl.sh +78 -0
- package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
- package/scripts/agent-eval/ab-sufficiency.sh +78 -0
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/audit.sh +68 -0
- package/scripts/agent-eval/bench-readme.sh +28 -0
- package/scripts/agent-eval/bench-why-repo.sh +22 -0
- package/scripts/agent-eval/block-read-hook.sh +19 -0
- package/scripts/agent-eval/hook-settings.json +15 -0
- package/scripts/agent-eval/itrun.sh +120 -0
- package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
- package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
- package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
- package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
- package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
- package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
- package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
- package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
- package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
- package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
- package/scripts/agent-eval/offload-eval-setup.sh +24 -0
- package/scripts/agent-eval/offload-eval-styles.sh +72 -0
- package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
- package/scripts/agent-eval/offload-eval.md +76 -0
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
- package/scripts/agent-eval/parse-run.mjs +45 -0
- package/scripts/agent-eval/parse-session.mjs +93 -0
- package/scripts/agent-eval/probe-context.mjs +21 -0
- package/scripts/agent-eval/probe-explore.mjs +40 -0
- package/scripts/agent-eval/probe-node.mjs +20 -0
- package/scripts/agent-eval/probe-sweep.mjs +119 -0
- package/scripts/agent-eval/probe-trace.mjs +20 -0
- package/scripts/agent-eval/redirect-read-hook.sh +38 -0
- package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
- package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
- package/scripts/agent-eval/run-agent.sh +34 -0
- package/scripts/agent-eval/run-all.sh +75 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +123 -0
- package/scripts/extract-release-notes.mjs +130 -0
- package/scripts/local-install.sh +41 -0
- package/scripts/npm-sdk.js +75 -0
- package/scripts/npm-shim.js +275 -0
- package/scripts/pack-npm.sh +119 -0
- package/scripts/prepare-release.mjs +270 -0
- package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
- package/dist/installer/claude-md-template.d.ts +0 -19
|
@@ -0,0 +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');
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Build the current branch and link it as the global `codegraph` 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 codegraph -> $(command -v codegraph)"
|
|
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 codegraph || echo "(not on PATH)")
|
|
34
|
+
echo
|
|
35
|
+
echo "✓ global codegraph 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"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
//
|
|
3
|
+
// Programmatic / embedded SDK entry for @colbymchenry/codegraph (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("@colbymchenry/codegraph")` returning the CodeGraph 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
|
+
// @colbymchenry/codegraph-<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 = '@colbymchenry/codegraph-' + 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
|
+
'codegraph: 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 @colbymchenry/codegraph --registry=https://registry.npmjs.org\n' +
|
|
60
|
+
' - or run the CLI once (e.g. `npx @colbymchenry/codegraph status`) to\n' +
|
|
61
|
+
' self-heal the bundle into ~/.codegraph, 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.CODEGRAPH_INSTALL_DIR || path.join(os.homedir(), '.codegraph');
|
|
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
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
//
|
|
4
|
+
// npm thin-installer launcher for CodeGraph.
|
|
5
|
+
//
|
|
6
|
+
// The heavy artifact (a vendored Node runtime + the app) ships as a per-platform
|
|
7
|
+
// optionalDependency: @colbymchenry/codegraph-<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
|
+
// CODEGRAPH_NO_DOWNLOAD=1 disable the network fallback (print guidance)
|
|
22
|
+
// CODEGRAPH_INSTALL_DIR=DIR cache location (default: ~/.codegraph)
|
|
23
|
+
// CODEGRAPH_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": { "codegraph": "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 = '@colbymchenry/codegraph-' + target;
|
|
36
|
+
var isWindows = process.platform === 'win32';
|
|
37
|
+
var REPO = 'colbymchenry/codegraph';
|
|
38
|
+
|
|
39
|
+
main().catch(function (e) {
|
|
40
|
+
process.stderr.write('codegraph: ' + (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.CODEGRAPH_HOST_PPID) env.CODEGRAPH_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('codegraph: ' + 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/codegraph.js');
|
|
73
|
+
return { command: nodeExe, args: liftoff(entry) };
|
|
74
|
+
}
|
|
75
|
+
return { command: require.resolve(pkg + '/bin/codegraph'), 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', 'codegraph.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', 'codegraph');
|
|
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/codegraph
|
|
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.CODEGRAPH_INSTALL_DIR || path.join(os.homedir(), '.codegraph'), '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 — CODEGRAPH_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.CODEGRAPH_NO_DOWNLOAD) {
|
|
118
|
+
fail('the network fallback is disabled (CODEGRAPH_NO_DOWNLOAD is set).');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var asset = 'codegraph-' + target + (isWindows ? '.zip' : '.tar.gz');
|
|
122
|
+
var base = process.env.CODEGRAPH_DOWNLOAD_BASE || ('https://github.com/' + REPO + '/releases/download');
|
|
123
|
+
var url = base + '/v' + version + '/' + asset;
|
|
124
|
+
|
|
125
|
+
process.stderr.write(
|
|
126
|
+
'codegraph: platform bundle missing (registry did not provide ' + pkg + ').\n' +
|
|
127
|
+
'codegraph: 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 codegraph-<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('codegraph: 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': 'codegraph-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('codegraph: 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
|
+
'codegraph: no prebuilt bundle for ' + target + '.\n' +
|
|
265
|
+
(reason ? 'codegraph: ' + 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 @colbymchenry/codegraph --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
|
+
}
|
|
@@ -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"
|