homegraph 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.
- package/LICENSE +21 -0
- package/README.md +709 -0
- package/dist/bin/codegraph.d.ts +26 -0
- package/dist/bin/codegraph.d.ts.map +1 -0
- package/dist/bin/codegraph.js +1572 -0
- package/dist/bin/codegraph.js.map +1 -0
- package/dist/bin/homegraph.d.ts +26 -0
- package/dist/bin/homegraph.d.ts.map +1 -0
- package/dist/bin/homegraph.js +1572 -0
- package/dist/bin/homegraph.js.map +1 -0
- package/dist/bin/node-version-check.d.ts +37 -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 +14 -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 +30 -0
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +263 -0
- package/dist/context/formatter.js.map +1 -0
- package/dist/context/index.d.ts +119 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +1289 -0
- 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 +101 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +250 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +131 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/queries.d.ts +386 -0
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +1562 -0
- package/dist/db/queries.js.map +1 -0
- package/dist/db/schema.sql +151 -0
- package/dist/db/sqlite-adapter.d.ts +53 -0
- package/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/db/sqlite-adapter.js +117 -0
- package/dist/db/sqlite-adapter.js.map +1 -0
- package/dist/directory.d.ts +57 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +253 -0
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +136 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +219 -0
- package/dist/errors.js.map +1 -0
- package/dist/extraction/arkanalyzer-extractor.d.ts +6 -0
- package/dist/extraction/arkanalyzer-extractor.d.ts.map +1 -0
- package/dist/extraction/arkanalyzer-extractor.js +11 -0
- package/dist/extraction/arkanalyzer-extractor.js.map +1 -0
- package/dist/extraction/arkanalyzer-project.d.ts +20 -0
- package/dist/extraction/arkanalyzer-project.d.ts.map +1 -0
- package/dist/extraction/arkanalyzer-project.js +596 -0
- package/dist/extraction/arkanalyzer-project.js.map +1 -0
- package/dist/extraction/context.d.ts +12 -0
- package/dist/extraction/context.d.ts.map +1 -0
- package/dist/extraction/context.js +29 -0
- package/dist/extraction/context.js.map +1 -0
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/dfm-extractor.d.ts.map +1 -0
- package/dist/extraction/dfm-extractor.js +151 -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/generated-detection.d.ts +30 -0
- package/dist/extraction/generated-detection.d.ts.map +1 -0
- package/dist/extraction/generated-detection.js +80 -0
- package/dist/extraction/generated-detection.js.map +1 -0
- package/dist/extraction/grammars.d.ts +108 -0
- package/dist/extraction/grammars.d.ts.map +1 -0
- package/dist/extraction/grammars.js +465 -0
- package/dist/extraction/grammars.js.map +1 -0
- package/dist/extraction/index.d.ts +138 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +1396 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/languages/arkts.d.ts +18 -0
- package/dist/extraction/languages/arkts.d.ts.map +1 -0
- package/dist/extraction/languages/arkts.js +878 -0
- package/dist/extraction/languages/arkts.js.map +1 -0
- package/dist/extraction/languages/c-cpp.d.ts +4 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
- package/dist/extraction/languages/c-cpp.js +173 -0
- package/dist/extraction/languages/c-cpp.js.map +1 -0
- package/dist/extraction/languages/csharp.d.ts +25 -0
- package/dist/extraction/languages/csharp.d.ts.map +1 -0
- package/dist/extraction/languages/csharp.js +120 -0
- package/dist/extraction/languages/csharp.js.map +1 -0
- package/dist/extraction/languages/dart.d.ts +3 -0
- package/dist/extraction/languages/dart.d.ts.map +1 -0
- package/dist/extraction/languages/dart.js +192 -0
- package/dist/extraction/languages/dart.js.map +1 -0
- package/dist/extraction/languages/go.d.ts +3 -0
- package/dist/extraction/languages/go.d.ts.map +1 -0
- package/dist/extraction/languages/go.js +74 -0
- package/dist/extraction/languages/go.js.map +1 -0
- package/dist/extraction/languages/index.d.ts +10 -0
- package/dist/extraction/languages/index.d.ts.map +1 -0
- package/dist/extraction/languages/index.js +51 -0
- package/dist/extraction/languages/index.js.map +1 -0
- package/dist/extraction/languages/java.d.ts +3 -0
- package/dist/extraction/languages/java.d.ts.map +1 -0
- package/dist/extraction/languages/java.js +74 -0
- package/dist/extraction/languages/java.js.map +1 -0
- package/dist/extraction/languages/javascript.d.ts +3 -0
- package/dist/extraction/languages/javascript.d.ts.map +1 -0
- package/dist/extraction/languages/javascript.js +90 -0
- package/dist/extraction/languages/javascript.js.map +1 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -0
- package/dist/extraction/languages/kotlin.d.ts.map +1 -0
- package/dist/extraction/languages/kotlin.js +285 -0
- package/dist/extraction/languages/kotlin.js.map +1 -0
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts.map +1 -0
- package/dist/extraction/languages/lua.js +150 -0
- package/dist/extraction/languages/lua.js.map +1 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts.map +1 -0
- package/dist/extraction/languages/luau.js +37 -0
- package/dist/extraction/languages/luau.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 +133 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/languages/pascal.d.ts +3 -0
- package/dist/extraction/languages/pascal.d.ts.map +1 -0
- package/dist/extraction/languages/pascal.js +66 -0
- package/dist/extraction/languages/pascal.js.map +1 -0
- package/dist/extraction/languages/php.d.ts +3 -0
- package/dist/extraction/languages/php.d.ts.map +1 -0
- package/dist/extraction/languages/php.js +120 -0
- package/dist/extraction/languages/php.js.map +1 -0
- package/dist/extraction/languages/python.d.ts +3 -0
- package/dist/extraction/languages/python.d.ts.map +1 -0
- package/dist/extraction/languages/python.js +56 -0
- package/dist/extraction/languages/python.js.map +1 -0
- package/dist/extraction/languages/ruby.d.ts +3 -0
- package/dist/extraction/languages/ruby.d.ts.map +1 -0
- package/dist/extraction/languages/ruby.js +149 -0
- package/dist/extraction/languages/ruby.js.map +1 -0
- package/dist/extraction/languages/rust.d.ts +3 -0
- package/dist/extraction/languages/rust.d.ts.map +1 -0
- package/dist/extraction/languages/rust.js +113 -0
- package/dist/extraction/languages/rust.js.map +1 -0
- package/dist/extraction/languages/scala.d.ts +3 -0
- package/dist/extraction/languages/scala.d.ts.map +1 -0
- package/dist/extraction/languages/scala.js +174 -0
- package/dist/extraction/languages/scala.js.map +1 -0
- package/dist/extraction/languages/swift.d.ts +3 -0
- package/dist/extraction/languages/swift.d.ts.map +1 -0
- package/dist/extraction/languages/swift.js +91 -0
- package/dist/extraction/languages/swift.js.map +1 -0
- package/dist/extraction/languages/typescript.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts.map +1 -0
- package/dist/extraction/languages/typescript.js +129 -0
- package/dist/extraction/languages/typescript.js.map +1 -0
- package/dist/extraction/liquid-extractor.d.ts +59 -0
- package/dist/extraction/liquid-extractor.d.ts.map +1 -0
- package/dist/extraction/liquid-extractor.js +354 -0
- package/dist/extraction/liquid-extractor.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +198 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/parse-worker.d.ts +8 -0
- package/dist/extraction/parse-worker.d.ts.map +1 -0
- package/dist/extraction/parse-worker.js +94 -0
- 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 +56 -0
- package/dist/extraction/svelte-extractor.d.ts.map +1 -0
- package/dist/extraction/svelte-extractor.js +272 -0
- package/dist/extraction/svelte-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-helpers.js +103 -0
- package/dist/extraction/tree-sitter-helpers.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +210 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-types.js +10 -0
- package/dist/extraction/tree-sitter-types.js.map +1 -0
- package/dist/extraction/tree-sitter.d.ts +455 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -0
- package/dist/extraction/tree-sitter.js +4089 -0
- package/dist/extraction/tree-sitter.js.map +1 -0
- package/dist/extraction/vue-extractor.d.ts +51 -0
- package/dist/extraction/vue-extractor.d.ts.map +1 -0
- package/dist/extraction/vue-extractor.js +251 -0
- package/dist/extraction/vue-extractor.js.map +1 -0
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/dist/extraction/wasm-runtime-flags.js +106 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +106 -0
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +339 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/traversal.d.ts +127 -0
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +531 -0
- package/dist/graph/traversal.js.map +1 -0
- package/dist/index.d.ts +522 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +947 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/config-writer.d.ts +28 -0
- 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 +100 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +497 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/instructions-template.d.ts +18 -0
- package/dist/installer/instructions-template.d.ts.map +1 -0
- package/dist/installer/instructions-template.js +21 -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 +56 -0
- package/dist/installer/targets/claude.d.ts.map +1 -0
- package/dist/installer/targets/claude.js +388 -0
- package/dist/installer/targets/claude.js.map +1 -0
- package/dist/installer/targets/codex.d.ts +18 -0
- package/dist/installer/targets/codex.d.ts.map +1 -0
- package/dist/installer/targets/codex.js +187 -0
- package/dist/installer/targets/codex.js.map +1 -0
- package/dist/installer/targets/cursor.d.ts +35 -0
- 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 +167 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- 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 +30 -0
- package/dist/installer/targets/opencode.d.ts.map +1 -0
- package/dist/installer/targets/opencode.js +237 -0
- package/dist/installer/targets/opencode.js.map +1 -0
- package/dist/installer/targets/registry.d.ts +35 -0
- 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 +77 -0
- package/dist/installer/targets/shared.d.ts.map +1 -0
- package/dist/installer/targets/shared.js +247 -0
- package/dist/installer/targets/shared.js.map +1 -0
- package/dist/installer/targets/toml.d.ts +52 -0
- 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 +101 -0
- 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-paths.d.ts +46 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +125 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon.d.ts +220 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +616 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/engine.d.ts +105 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +270 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +112 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +478 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/ppid-watchdog.d.ts +44 -0
- package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
- package/dist/mcp/ppid-watchdog.js +27 -0
- package/dist/mcp/ppid-watchdog.js.map +1 -0
- package/dist/mcp/proxy.d.ts +81 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +584 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +19 -0
- package/dist/mcp/server-instructions.d.ts.map +1 -0
- package/dist/mcp/server-instructions.js +74 -0
- package/dist/mcp/server-instructions.js.map +1 -0
- package/dist/mcp/session.d.ts +77 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +294 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +413 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +3049 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/transport.d.ts +188 -0
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +343 -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/resolution/callback-synthesizer.d.ts +10 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +1818 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.js +225 -0
- package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
- package/dist/resolution/frameworks/csharp.js +241 -0
- package/dist/resolution/frameworks/csharp.js.map +1 -0
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/dist/resolution/frameworks/drupal.js +367 -0
- 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 +8 -0
- package/dist/resolution/frameworks/express.d.ts.map +1 -0
- package/dist/resolution/frameworks/express.js +308 -0
- 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 +8 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -0
- package/dist/resolution/frameworks/go.js +161 -0
- package/dist/resolution/frameworks/go.js.map +1 -0
- package/dist/resolution/frameworks/index.d.ts +48 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -0
- package/dist/resolution/frameworks/index.js +161 -0
- package/dist/resolution/frameworks/index.js.map +1 -0
- package/dist/resolution/frameworks/java.d.ts +8 -0
- package/dist/resolution/frameworks/java.d.ts.map +1 -0
- package/dist/resolution/frameworks/java.js +504 -0
- package/dist/resolution/frameworks/java.js.map +1 -0
- package/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
- package/dist/resolution/frameworks/laravel.js +257 -0
- package/dist/resolution/frameworks/laravel.js.map +1 -0
- package/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
- package/dist/resolution/frameworks/nestjs.js +698 -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 +10 -0
- package/dist/resolution/frameworks/python.d.ts.map +1 -0
- package/dist/resolution/frameworks/python.js +400 -0
- 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 +8 -0
- package/dist/resolution/frameworks/react.d.ts.map +1 -0
- package/dist/resolution/frameworks/react.js +365 -0
- package/dist/resolution/frameworks/react.js.map +1 -0
- package/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
- package/dist/resolution/frameworks/ruby.js +302 -0
- package/dist/resolution/frameworks/ruby.js.map +1 -0
- package/dist/resolution/frameworks/rust.d.ts +8 -0
- package/dist/resolution/frameworks/rust.d.ts.map +1 -0
- package/dist/resolution/frameworks/rust.js +304 -0
- package/dist/resolution/frameworks/rust.js.map +1 -0
- package/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
- package/dist/resolution/frameworks/svelte.js +249 -0
- 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 +10 -0
- package/dist/resolution/frameworks/swift.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift.js +400 -0
- package/dist/resolution/frameworks/swift.js.map +1 -0
- package/dist/resolution/frameworks/vue.d.ts +9 -0
- package/dist/resolution/frameworks/vue.d.ts.map +1 -0
- package/dist/resolution/frameworks/vue.js +306 -0
- 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/import-resolver.d.ts +68 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -0
- package/dist/resolution/import-resolver.js +1726 -0
- package/dist/resolution/import-resolver.js.map +1 -0
- package/dist/resolution/index.d.ts +159 -0
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +1025 -0
- package/dist/resolution/index.js.map +1 -0
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/lru-cache.d.ts.map +1 -0
- package/dist/resolution/lru-cache.js +62 -0
- package/dist/resolution/lru-cache.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +52 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -0
- package/dist/resolution/name-matcher.js +707 -0
- package/dist/resolution/name-matcher.js.map +1 -0
- package/dist/resolution/path-aliases.d.ts +68 -0
- package/dist/resolution/path-aliases.d.ts.map +1 -0
- package/dist/resolution/path-aliases.js +238 -0
- package/dist/resolution/path-aliases.js.map +1 -0
- package/dist/resolution/strip-comments.d.ts +27 -0
- package/dist/resolution/strip-comments.d.ts.map +1 -0
- package/dist/resolution/strip-comments.js +441 -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 +216 -0
- package/dist/resolution/types.d.ts.map +1 -0
- package/dist/resolution/types.js +8 -0
- package/dist/resolution/types.js.map +1 -0
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/dist/resolution/workspace-packages.js +208 -0
- package/dist/resolution/workspace-packages.js.map +1 -0
- package/dist/search/query-parser.d.ts +57 -0
- package/dist/search/query-parser.d.ts.map +1 -0
- package/dist/search/query-parser.js +177 -0
- package/dist/search/query-parser.js.map +1 -0
- package/dist/search/query-utils.d.ts +71 -0
- package/dist/search/query-utils.d.ts.map +1 -0
- package/dist/search/query-utils.js +380 -0
- package/dist/search/query-utils.js.map +1 -0
- package/dist/sync/git-hooks.d.ts +45 -0
- package/dist/sync/git-hooks.d.ts.map +1 -0
- package/dist/sync/git-hooks.js +225 -0
- package/dist/sync/git-hooks.js.map +1 -0
- package/dist/sync/index.d.ts +19 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +35 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/watch-policy.d.ts +48 -0
- package/dist/sync/watch-policy.d.ts.map +1 -0
- package/dist/sync/watch-policy.js +124 -0
- package/dist/sync/watch-policy.js.map +1 -0
- package/dist/sync/watcher.d.ts +283 -0
- package/dist/sync/watcher.d.ts.map +1 -0
- package/dist/sync/watcher.js +606 -0
- package/dist/sync/watcher.js.map +1 -0
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +137 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/types.d.ts +377 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +80 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/glyphs.d.ts +42 -0
- 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 +11 -0
- 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 -0
- 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 +17 -0
- 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 +132 -0
- package/dist/upgrade/index.d.ts.map +1 -0
- package/dist/upgrade/index.js +462 -0
- package/dist/upgrade/index.js.map +1 -0
- package/dist/utils.d.ts +205 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +549 -0
- package/dist/utils.js.map +1 -0
- package/package.json +57 -0
- 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/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/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/run-agent.sh +34 -0
- package/scripts/agent-eval/run-all.sh +67 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +118 -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 +246 -0
- package/scripts/pack-npm.sh +119 -0
- package/scripts/prepare-release.mjs +270 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Search Query Utilities
|
|
4
|
+
*
|
|
5
|
+
* Shared module for search term extraction and scoring.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.STOP_WORDS = void 0;
|
|
42
|
+
exports.getStemVariants = getStemVariants;
|
|
43
|
+
exports.extractSearchTerms = extractSearchTerms;
|
|
44
|
+
exports.scorePathRelevance = scorePathRelevance;
|
|
45
|
+
exports.isTestFile = isTestFile;
|
|
46
|
+
exports.nameMatchBonus = nameMatchBonus;
|
|
47
|
+
exports.kindBonus = kindBonus;
|
|
48
|
+
exports.isDistinctiveIdentifier = isDistinctiveIdentifier;
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
/**
|
|
51
|
+
* Common stop words to filter from search queries.
|
|
52
|
+
* Includes generic English + code-specific noise words.
|
|
53
|
+
*/
|
|
54
|
+
exports.STOP_WORDS = new Set([
|
|
55
|
+
// English
|
|
56
|
+
'the', 'a', 'an', 'and', 'or', 'but', 'in', 'on', 'at', 'to', 'for',
|
|
57
|
+
'of', 'with', 'by', 'from', 'is', 'it', 'that', 'this', 'are', 'was',
|
|
58
|
+
'be', 'has', 'had', 'have', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
59
|
+
'should', 'may', 'might', 'can', 'shall', 'not', 'no', 'all', 'each',
|
|
60
|
+
'every', 'how', 'what', 'where', 'when', 'who', 'which', 'why',
|
|
61
|
+
'i', 'me', 'my', 'we', 'our', 'you', 'your', 'he', 'she', 'they',
|
|
62
|
+
'show', 'give', 'tell',
|
|
63
|
+
'been', 'done', 'made', 'used', 'using', 'work', 'works', 'found',
|
|
64
|
+
'also', 'into', 'then', 'than', 'just', 'more', 'some', 'such',
|
|
65
|
+
'over', 'only', 'out', 'its', 'so', 'up', 'as', 'if',
|
|
66
|
+
'look', 'need', 'needs', 'want', 'happen', 'happens',
|
|
67
|
+
'affect', 'affected', 'break', 'breaks', 'failing',
|
|
68
|
+
'implemented', 'implement',
|
|
69
|
+
// Code-specific noise (avoid filtering common symbol names like get/set/add/build/find/list)
|
|
70
|
+
'code', 'file', 'files', 'function', 'method', 'class', 'type',
|
|
71
|
+
'fix', 'bug', 'called',
|
|
72
|
+
]);
|
|
73
|
+
/**
|
|
74
|
+
* Generate stem variants of a search term by removing common English suffixes.
|
|
75
|
+
* Used for FTS query expansion so "caching" also finds "cache", "eviction" finds "evict", etc.
|
|
76
|
+
* Stems are used as PREFIX matches in FTS, so they don't need to be perfect English words.
|
|
77
|
+
*/
|
|
78
|
+
function getStemVariants(term) {
|
|
79
|
+
const variants = new Set();
|
|
80
|
+
const t = term.toLowerCase();
|
|
81
|
+
// -ing: caching→cach/cache, handling→handl/handle, running→run
|
|
82
|
+
if (t.endsWith('ing') && t.length > 5) {
|
|
83
|
+
const base = t.slice(0, -3);
|
|
84
|
+
variants.add(base);
|
|
85
|
+
variants.add(base + 'e');
|
|
86
|
+
if (base.length >= 2 && base[base.length - 1] === base[base.length - 2]) {
|
|
87
|
+
variants.add(base.slice(0, -1));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// -tion/-sion: eviction→evict, expression→express
|
|
91
|
+
if ((t.endsWith('tion') || t.endsWith('sion')) && t.length > 5) {
|
|
92
|
+
variants.add(t.slice(0, -3));
|
|
93
|
+
}
|
|
94
|
+
// -ment: management→manage
|
|
95
|
+
if (t.endsWith('ment') && t.length > 6) {
|
|
96
|
+
variants.add(t.slice(0, -4));
|
|
97
|
+
}
|
|
98
|
+
// -ies: entries→entry
|
|
99
|
+
if (t.endsWith('ies') && t.length > 4) {
|
|
100
|
+
variants.add(t.slice(0, -3) + 'y');
|
|
101
|
+
}
|
|
102
|
+
// -es: processes→process, classes→class
|
|
103
|
+
else if (t.endsWith('es') && t.length > 4) {
|
|
104
|
+
variants.add(t.slice(0, -2));
|
|
105
|
+
}
|
|
106
|
+
// -s: errors→error (skip -ss endings like "class")
|
|
107
|
+
else if (t.endsWith('s') && !t.endsWith('ss') && t.length > 4) {
|
|
108
|
+
variants.add(t.slice(0, -1));
|
|
109
|
+
}
|
|
110
|
+
// -ed: handled→handle, propagated→propagate, carried→carry
|
|
111
|
+
if (t.endsWith('ed') && !t.endsWith('eed') && t.length > 4) {
|
|
112
|
+
variants.add(t.slice(0, -1));
|
|
113
|
+
variants.add(t.slice(0, -2));
|
|
114
|
+
if (t.endsWith('ied') && t.length > 5) {
|
|
115
|
+
variants.add(t.slice(0, -3) + 'y');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// -er: builder→build/builde, handler→handl/handle, getter→get
|
|
119
|
+
if (t.endsWith('er') && t.length > 4) {
|
|
120
|
+
const base = t.slice(0, -2);
|
|
121
|
+
variants.add(base);
|
|
122
|
+
variants.add(base + 'e');
|
|
123
|
+
if (base.length >= 2 && base[base.length - 1] === base[base.length - 2]) {
|
|
124
|
+
variants.add(base.slice(0, -1));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return [...variants].filter(v => v.length >= 3 && v !== t);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Extract meaningful search terms from a natural language query.
|
|
131
|
+
* Splits camelCase, PascalCase, snake_case, SCREAMING_SNAKE, and dot.notation
|
|
132
|
+
* into individual tokens before filtering.
|
|
133
|
+
*
|
|
134
|
+
* Preserves original compound identifiers (e.g., "scrapeLoop") alongside
|
|
135
|
+
* their split parts so that FTS can match both the full symbol name and
|
|
136
|
+
* individual words within it.
|
|
137
|
+
*
|
|
138
|
+
* Also generates stem variants (e.g., "caching"→"cache", "eviction"→"evict")
|
|
139
|
+
* so FTS prefix matching can find related code symbols.
|
|
140
|
+
*/
|
|
141
|
+
function extractSearchTerms(query, options) {
|
|
142
|
+
const includeStems = options?.stems !== false;
|
|
143
|
+
const tokens = new Set();
|
|
144
|
+
// First, extract and preserve compound identifiers before splitting
|
|
145
|
+
// CamelCase: scrapeLoop, UserService, getCallGraph
|
|
146
|
+
const compoundPattern = /\b([a-zA-Z][a-zA-Z0-9]*(?:[A-Z][a-z]+)+|[A-Z][a-z]+(?:[A-Z][a-z]*)+)\b/g;
|
|
147
|
+
let match;
|
|
148
|
+
while ((match = compoundPattern.exec(query)) !== null) {
|
|
149
|
+
if (match[1] && match[1].length >= 3) {
|
|
150
|
+
tokens.add(match[1].toLowerCase()); // preserve full compound: "scrapeloop"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// snake_case: scrape_loop, user_service
|
|
154
|
+
const snakePattern = /\b([a-zA-Z][a-zA-Z0-9]*(?:_[a-zA-Z0-9]+)+)\b/g;
|
|
155
|
+
while ((match = snakePattern.exec(query)) !== null) {
|
|
156
|
+
if (match[1] && match[1].length >= 3) {
|
|
157
|
+
tokens.add(match[1].toLowerCase());
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Split camelCase / PascalCase: "getUserName" → "get User Name"
|
|
161
|
+
const camelSplit = query
|
|
162
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
163
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2');
|
|
164
|
+
// Replace underscores and dots with spaces (snake_case, dot.notation)
|
|
165
|
+
const normalised = camelSplit.replace(/[_.]+/g, ' ');
|
|
166
|
+
// Split on any non-alphanumeric character
|
|
167
|
+
const words = normalised.split(/[^a-zA-Z0-9]+/).filter(Boolean);
|
|
168
|
+
for (const word of words) {
|
|
169
|
+
const lower = word.toLowerCase();
|
|
170
|
+
if (lower.length < 3)
|
|
171
|
+
continue;
|
|
172
|
+
if (exports.STOP_WORDS.has(lower))
|
|
173
|
+
continue;
|
|
174
|
+
tokens.add(lower);
|
|
175
|
+
}
|
|
176
|
+
// Generate stem variants for broader FTS matching.
|
|
177
|
+
// "caching" → "cache" finds CacheBuilder; "eviction" → "evict" finds evictEntries.
|
|
178
|
+
// Also enables co-occurrence dampening by increasing term count above 1.
|
|
179
|
+
// Stems are skipped when scoring path relevance (stems inflate path scores).
|
|
180
|
+
if (includeStems) {
|
|
181
|
+
const stems = new Set();
|
|
182
|
+
for (const token of tokens) {
|
|
183
|
+
for (const variant of getStemVariants(token)) {
|
|
184
|
+
if (!tokens.has(variant) && !exports.STOP_WORDS.has(variant)) {
|
|
185
|
+
stems.add(variant);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const stem of stems) {
|
|
190
|
+
tokens.add(stem);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return [...tokens];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Score path relevance to a query
|
|
197
|
+
* Higher score = more relevant path
|
|
198
|
+
*/
|
|
199
|
+
function scorePathRelevance(filePath, query) {
|
|
200
|
+
// Use base terms only — stem variants inflate path scores by generating
|
|
201
|
+
// many near-duplicate terms that all match the same path segments.
|
|
202
|
+
const terms = extractSearchTerms(query, { stems: false });
|
|
203
|
+
if (terms.length === 0)
|
|
204
|
+
return 0;
|
|
205
|
+
const pathLower = filePath.toLowerCase();
|
|
206
|
+
const fileName = path.basename(filePath).toLowerCase();
|
|
207
|
+
const dirName = path.dirname(filePath).toLowerCase();
|
|
208
|
+
let score = 0;
|
|
209
|
+
for (const term of terms) {
|
|
210
|
+
// Exact filename match (strongest)
|
|
211
|
+
if (fileName.includes(term))
|
|
212
|
+
score += 10;
|
|
213
|
+
// Directory match
|
|
214
|
+
if (dirName.includes(term))
|
|
215
|
+
score += 5;
|
|
216
|
+
// General path match
|
|
217
|
+
else if (pathLower.includes(term))
|
|
218
|
+
score += 3;
|
|
219
|
+
}
|
|
220
|
+
// Deprioritize test files unless the query is explicitly about tests
|
|
221
|
+
const queryLower = query.toLowerCase();
|
|
222
|
+
const isTestQuery = queryLower.includes('test') || queryLower.includes('spec');
|
|
223
|
+
if (!isTestQuery && isTestFile(filePath)) {
|
|
224
|
+
score -= 15;
|
|
225
|
+
}
|
|
226
|
+
return score;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Check if a file path looks like a test file
|
|
230
|
+
*/
|
|
231
|
+
function isTestFile(filePath) {
|
|
232
|
+
const lower = filePath.toLowerCase();
|
|
233
|
+
const fileName = path.basename(filePath); // original case — needed for camelCase boundaries
|
|
234
|
+
const lowerName = fileName.toLowerCase();
|
|
235
|
+
// --- Filename patterns ---
|
|
236
|
+
if (lowerName.startsWith('test_') || // python: test_foo.py
|
|
237
|
+
lowerName.startsWith('test.') ||
|
|
238
|
+
// separator-delimited: foo_test.go, foo.test.ts, foo-spec.rb, bar_spec.py
|
|
239
|
+
/[._-](test|tests|spec|specs)\.[a-z0-9]+$/.test(lowerName) ||
|
|
240
|
+
// CamelCase suffix (Java/Kotlin/Swift/C#/Scala): FooTest.kt, BarTests.swift,
|
|
241
|
+
// BazSpec.scala, QuxTestCase.java. Capital-led so "latest.kt"/"manifest.kt"
|
|
242
|
+
// (lowercase "test") are NOT matched.
|
|
243
|
+
/(?:Test|Tests|TestCase|Tester|Spec|Specs)\.[A-Za-z0-9]+$/.test(fileName)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
// --- Directory patterns ---
|
|
247
|
+
if (lower.includes('/tests/') || lower.includes('/test/') ||
|
|
248
|
+
lower.includes('/__tests__/') || lower.includes('/spec/') ||
|
|
249
|
+
lower.includes('/specs/') || lower.includes('/testlib/') ||
|
|
250
|
+
lower.includes('/testing/') ||
|
|
251
|
+
lower.startsWith('test/') || lower.startsWith('tests/') ||
|
|
252
|
+
lower.startsWith('spec/') || lower.startsWith('specs/') ||
|
|
253
|
+
// CamelCase test source-set dirs (Kotlin Multiplatform / Gradle / Xcode):
|
|
254
|
+
// jvmTest/, commonTest/, androidTest/, iosTest/, integrationTest/. Capital-led
|
|
255
|
+
// so "latest/" / "manifest/" are not matched.
|
|
256
|
+
/(?:^|\/)[A-Za-z0-9]*(?:Test|Tests|Spec)\//.test(filePath)) {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
// Non-production directories: examples, samples, benchmarks, fixtures, demos.
|
|
260
|
+
// Check both mid-path (/integration/) and start-of-path (integration/) since
|
|
261
|
+
// file paths may be stored as relative paths without a leading slash.
|
|
262
|
+
return matchesNonProductionDir(lower);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Check if a path is in a non-production directory (integration, sample, example, etc.)
|
|
266
|
+
* Handles both absolute paths (/foo/integration/bar) and relative paths (integration/bar).
|
|
267
|
+
*/
|
|
268
|
+
function matchesNonProductionDir(lowerPath) {
|
|
269
|
+
const dirs = [
|
|
270
|
+
'integration', 'sample', 'samples', 'example', 'examples',
|
|
271
|
+
'fixture', 'fixtures', 'benchmark', 'benchmarks', 'demo', 'demos',
|
|
272
|
+
];
|
|
273
|
+
for (const dir of dirs) {
|
|
274
|
+
if (lowerPath.includes('/' + dir + '/') || lowerPath.startsWith(dir + '/')) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Bonus when a node's name matches the search query.
|
|
282
|
+
* Exact matches get the largest boost; prefix matches get smaller boosts.
|
|
283
|
+
* Multi-word queries also check individual term matches against the name.
|
|
284
|
+
*/
|
|
285
|
+
function nameMatchBonus(nodeName, query) {
|
|
286
|
+
const nameLower = nodeName.toLowerCase();
|
|
287
|
+
// Split query into word-level terms (handles "CacheBuilder build" → ["cache","builder","build"])
|
|
288
|
+
const rawTerms = query
|
|
289
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
290
|
+
.split(/[\s_.\-]+/)
|
|
291
|
+
.map(t => t.toLowerCase())
|
|
292
|
+
.filter(t => t.length >= 2);
|
|
293
|
+
// Also keep original space-separated tokens for exact-term matching
|
|
294
|
+
const queryTokens = query.split(/\s+/).map(t => t.toLowerCase()).filter(t => t.length >= 2);
|
|
295
|
+
// Full query as a single token (for compound identifiers like "CacheBuilder")
|
|
296
|
+
const queryLower = query.replace(/[\s]+/g, '').toLowerCase();
|
|
297
|
+
// Exact match: query exactly equals the node name
|
|
298
|
+
if (nameLower === queryLower)
|
|
299
|
+
return 80;
|
|
300
|
+
// Exact match on a query token: "CacheBuilder build" and node name is "build"
|
|
301
|
+
if (queryTokens.length > 1 && queryTokens.includes(nameLower))
|
|
302
|
+
return 60;
|
|
303
|
+
// Name starts with query — scale by length ratio so "Pod"→"Pod" (exact, handled above)
|
|
304
|
+
// scores much higher than "Pod"→"PodGCControllerOptions" (ratio 0.125).
|
|
305
|
+
if (nameLower.startsWith(queryLower)) {
|
|
306
|
+
const ratio = queryLower.length / nameLower.length;
|
|
307
|
+
return Math.round(10 + 30 * ratio);
|
|
308
|
+
}
|
|
309
|
+
// All camelCase-split terms appear in the name
|
|
310
|
+
if (rawTerms.length > 1) {
|
|
311
|
+
const allMatch = rawTerms.every(t => nameLower.includes(t));
|
|
312
|
+
if (allMatch)
|
|
313
|
+
return 15;
|
|
314
|
+
}
|
|
315
|
+
// Name contains the full query as substring
|
|
316
|
+
if (nameLower.includes(queryLower))
|
|
317
|
+
return 10;
|
|
318
|
+
return 0;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Kind-based bonus for search ranking
|
|
322
|
+
* Functions and classes are typically more relevant than variables/imports
|
|
323
|
+
*/
|
|
324
|
+
function kindBonus(kind) {
|
|
325
|
+
const bonuses = {
|
|
326
|
+
function: 10,
|
|
327
|
+
method: 10,
|
|
328
|
+
class: 8,
|
|
329
|
+
interface: 9,
|
|
330
|
+
type_alias: 6,
|
|
331
|
+
struct: 6,
|
|
332
|
+
trait: 9,
|
|
333
|
+
enum: 5,
|
|
334
|
+
component: 8,
|
|
335
|
+
route: 9,
|
|
336
|
+
module: 4,
|
|
337
|
+
property: 3,
|
|
338
|
+
field: 3,
|
|
339
|
+
variable: 2,
|
|
340
|
+
constant: 3,
|
|
341
|
+
import: 1,
|
|
342
|
+
export: 1,
|
|
343
|
+
parameter: 0,
|
|
344
|
+
namespace: 4,
|
|
345
|
+
file: 0,
|
|
346
|
+
protocol: 9,
|
|
347
|
+
enum_member: 3,
|
|
348
|
+
};
|
|
349
|
+
return bonuses[kind] ?? 0;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Whether a query token looks like a code identifier the user deliberately typed
|
|
353
|
+
* (camelCase / PascalCase-with-internal-caps / snake_case / has a digit) rather
|
|
354
|
+
* than a plain dictionary word ("flat", "object", "screen").
|
|
355
|
+
*
|
|
356
|
+
* Used to decide whether an EXACT name match earns the "the user named this
|
|
357
|
+
* symbol" exemption from single-term dampening. A common English word that
|
|
358
|
+
* happens to exact-match an unrelated symbol — the query "flat object" matching
|
|
359
|
+
* a constant named `FLAT` — must NOT get that exemption, or the +exact-name
|
|
360
|
+
* bonus floats it to the top of a prose query on its own.
|
|
361
|
+
*
|
|
362
|
+
* Classifies the token AS THE USER TYPED IT, not the matched symbol's name:
|
|
363
|
+
* "flat" (lowercase, descriptive) is non-distinctive even though it matches
|
|
364
|
+
* `FLAT`. A leading-capital-only word ("Screen", "Zustand") is also treated as
|
|
365
|
+
* a plain word — sentence-start capitalization and proper nouns aren't reliable
|
|
366
|
+
* identifier signals.
|
|
367
|
+
*/
|
|
368
|
+
function isDistinctiveIdentifier(token) {
|
|
369
|
+
if (!token)
|
|
370
|
+
return false;
|
|
371
|
+
// snake_case / SCREAMING_SNAKE, or an embedded digit → a deliberate identifier.
|
|
372
|
+
if (/[_0-9]/.test(token))
|
|
373
|
+
return true;
|
|
374
|
+
// An uppercase letter anywhere AFTER the first char → a camelCase/PascalCase
|
|
375
|
+
// boundary (setLastEmail, OrgUserStore) or an acronym (REST, HTTP).
|
|
376
|
+
if (/[A-Z]/.test(token.slice(1)))
|
|
377
|
+
return true;
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=query-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-utils.js","sourceRoot":"","sources":["../../src/search/query-utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,0CAyDC;AAcD,gDA2DC;AAMD,gDA4BC;AAKD,gCAuCC;AAwBD,wCAuCC;AAMD,8BA0BC;AAmBD,0DAQC;AA1WD,2CAA6B;AAG7B;;;GAGG;AACU,QAAA,UAAU,GAAG,IAAI,GAAG,CAAC;IAChC,UAAU;IACV,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;IACnE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IACpE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACzE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM;IACpE,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AE,CAAC;QACT,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,SAAS,EAAE,CAAC;QACZ,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,MAAM,EAAE,CAAC;QACT,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,CAAC;KACf,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IACnD,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,gFAAgF;IAChF,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,6EAA6E;IAC7E,oEAAoE;IACpE,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Sync Hooks
|
|
3
|
+
*
|
|
4
|
+
* When the live file watcher is disabled (e.g. on WSL2 `/mnt/*` drives,
|
|
5
|
+
* see watch-policy.ts), the CodeGraph index would otherwise go stale until
|
|
6
|
+
* the user runs `homegraph sync` by hand. As an opt-in alternative, we can
|
|
7
|
+
* install git hooks that refresh the index after the operations that change
|
|
8
|
+
* files on disk: commit, merge (covers `git pull`), and checkout.
|
|
9
|
+
*
|
|
10
|
+
* The hooks run `homegraph sync` in the background so they never block git,
|
|
11
|
+
* and are guarded by `command -v homegraph` so they no-op cleanly when the
|
|
12
|
+
* CLI isn't on PATH. Our snippet is delimited by marker comments so install
|
|
13
|
+
* is idempotent and removal preserves any user-authored hook content.
|
|
14
|
+
*/
|
|
15
|
+
export type GitHookName = 'post-commit' | 'post-merge' | 'post-checkout';
|
|
16
|
+
/** Hooks installed by default: commit, merge (git pull), and checkout. */
|
|
17
|
+
export declare const DEFAULT_SYNC_HOOKS: GitHookName[];
|
|
18
|
+
export interface GitHookResult {
|
|
19
|
+
/** Hook names that were created or updated. */
|
|
20
|
+
installed: GitHookName[];
|
|
21
|
+
/** Resolved hooks directory, or null when not a git repo. */
|
|
22
|
+
hooksDir: string | null;
|
|
23
|
+
/** Reason nothing happened (e.g. not a git repository). */
|
|
24
|
+
skipped?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether `projectRoot` is inside a git working tree. Returns false if git
|
|
28
|
+
* isn't installed or the path isn't a repo.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isGitRepo(projectRoot: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Install (or update) the CodeGraph sync hooks in a git repository.
|
|
33
|
+
* Idempotent: re-running replaces our marker block rather than duplicating
|
|
34
|
+
* it, and any user-authored hook content is preserved.
|
|
35
|
+
*/
|
|
36
|
+
export declare function installGitSyncHook(projectRoot: string, hooks?: GitHookName[]): GitHookResult;
|
|
37
|
+
/**
|
|
38
|
+
* Remove the CodeGraph sync hooks. Strips only our marker block; deletes the
|
|
39
|
+
* hook file entirely when nothing but a shebang remains, otherwise rewrites
|
|
40
|
+
* the user's content untouched.
|
|
41
|
+
*/
|
|
42
|
+
export declare function removeGitSyncHook(projectRoot: string, hooks?: GitHookName[]): GitHookResult;
|
|
43
|
+
/** Whether any CodeGraph sync hook is currently installed. */
|
|
44
|
+
export declare function isSyncHookInstalled(projectRoot: string, hooks?: GitHookName[]): boolean;
|
|
45
|
+
//# sourceMappingURL=git-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../../src/sync/git-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,YAAY,GAAG,eAAe,CAAC;AAEzE,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAAmD,CAAC;AAEhG,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAYtD;AAiED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,WAAW,EAAuB,GACxC,aAAa,CAmCf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,WAAW,EAAuB,GACxC,aAAa,CA0Bf;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,WAAW,EAAuB,GACxC,OAAO,CAOT"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Git Sync Hooks
|
|
4
|
+
*
|
|
5
|
+
* When the live file watcher is disabled (e.g. on WSL2 `/mnt/*` drives,
|
|
6
|
+
* see watch-policy.ts), the CodeGraph index would otherwise go stale until
|
|
7
|
+
* the user runs `homegraph sync` by hand. As an opt-in alternative, we can
|
|
8
|
+
* install git hooks that refresh the index after the operations that change
|
|
9
|
+
* files on disk: commit, merge (covers `git pull`), and checkout.
|
|
10
|
+
*
|
|
11
|
+
* The hooks run `homegraph sync` in the background so they never block git,
|
|
12
|
+
* and are guarded by `command -v homegraph` so they no-op cleanly when the
|
|
13
|
+
* CLI isn't on PATH. Our snippet is delimited by marker comments so install
|
|
14
|
+
* is idempotent and removal preserves any user-authored hook content.
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
33
|
+
var ownKeys = function(o) {
|
|
34
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35
|
+
var ar = [];
|
|
36
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
return ownKeys(o);
|
|
40
|
+
};
|
|
41
|
+
return function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.DEFAULT_SYNC_HOOKS = void 0;
|
|
51
|
+
exports.isGitRepo = isGitRepo;
|
|
52
|
+
exports.installGitSyncHook = installGitSyncHook;
|
|
53
|
+
exports.removeGitSyncHook = removeGitSyncHook;
|
|
54
|
+
exports.isSyncHookInstalled = isSyncHookInstalled;
|
|
55
|
+
const fs = __importStar(require("fs"));
|
|
56
|
+
const path = __importStar(require("path"));
|
|
57
|
+
const child_process_1 = require("child_process");
|
|
58
|
+
const MARKER_BEGIN = '# >>> homegraph sync hook >>>';
|
|
59
|
+
const MARKER_END = '# <<< homegraph sync hook <<<';
|
|
60
|
+
/** Hooks installed by default: commit, merge (git pull), and checkout. */
|
|
61
|
+
exports.DEFAULT_SYNC_HOOKS = ['post-commit', 'post-merge', 'post-checkout'];
|
|
62
|
+
/**
|
|
63
|
+
* Whether `projectRoot` is inside a git working tree. Returns false if git
|
|
64
|
+
* isn't installed or the path isn't a repo.
|
|
65
|
+
*/
|
|
66
|
+
function isGitRepo(projectRoot) {
|
|
67
|
+
try {
|
|
68
|
+
const out = (0, child_process_1.execFileSync)('git', ['rev-parse', '--is-inside-work-tree'], {
|
|
69
|
+
cwd: projectRoot,
|
|
70
|
+
encoding: 'utf8',
|
|
71
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
72
|
+
windowsHide: true,
|
|
73
|
+
}).trim();
|
|
74
|
+
return out === 'true';
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolve the git hooks directory for a project, honoring `core.hooksPath`
|
|
82
|
+
* and git worktrees. Returns an absolute path, or null when not a repo.
|
|
83
|
+
*/
|
|
84
|
+
function gitHooksDir(projectRoot) {
|
|
85
|
+
try {
|
|
86
|
+
const out = (0, child_process_1.execFileSync)('git', ['rev-parse', '--git-path', 'hooks'], {
|
|
87
|
+
cwd: projectRoot,
|
|
88
|
+
encoding: 'utf8',
|
|
89
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
90
|
+
windowsHide: true,
|
|
91
|
+
}).trim();
|
|
92
|
+
if (!out)
|
|
93
|
+
return null;
|
|
94
|
+
return path.isAbsolute(out) ? out : path.resolve(projectRoot, out);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** The shell snippet (between markers) injected into each hook. */
|
|
101
|
+
function markerBlock() {
|
|
102
|
+
return [
|
|
103
|
+
MARKER_BEGIN,
|
|
104
|
+
'# Keeps the CodeGraph index fresh while the live file watcher is off',
|
|
105
|
+
'# (e.g. WSL2 /mnt drives). Runs in the background so it never blocks git.',
|
|
106
|
+
'# Managed by homegraph; remove with `homegraph uninit` or delete this block.',
|
|
107
|
+
'if command -v homegraph >/dev/null 2>&1; then',
|
|
108
|
+
' ( homegraph sync >/dev/null 2>&1 & ) >/dev/null 2>&1',
|
|
109
|
+
'fi',
|
|
110
|
+
MARKER_END,
|
|
111
|
+
].join('\n');
|
|
112
|
+
}
|
|
113
|
+
/** Remove our marker block (and the marker lines) from hook content. */
|
|
114
|
+
function stripMarkerBlock(content) {
|
|
115
|
+
const lines = content.split('\n');
|
|
116
|
+
const kept = [];
|
|
117
|
+
let inBlock = false;
|
|
118
|
+
for (const line of lines) {
|
|
119
|
+
const trimmed = line.trim();
|
|
120
|
+
if (trimmed === MARKER_BEGIN) {
|
|
121
|
+
inBlock = true;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (trimmed === MARKER_END) {
|
|
125
|
+
inBlock = false;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (!inBlock)
|
|
129
|
+
kept.push(line);
|
|
130
|
+
}
|
|
131
|
+
return kept.join('\n');
|
|
132
|
+
}
|
|
133
|
+
/** Whether a hook body is just a shebang / blank lines (i.e. only ever ours). */
|
|
134
|
+
function isEffectivelyEmpty(content) {
|
|
135
|
+
return content
|
|
136
|
+
.split('\n')
|
|
137
|
+
.map((l) => l.trim())
|
|
138
|
+
.every((l) => l.length === 0 || l.startsWith('#!'));
|
|
139
|
+
}
|
|
140
|
+
function chmodExecutable(file) {
|
|
141
|
+
try {
|
|
142
|
+
fs.chmodSync(file, 0o755);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
/* chmod is a no-op / unsupported on some platforms (e.g. Windows) */
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Install (or update) the CodeGraph sync hooks in a git repository.
|
|
150
|
+
* Idempotent: re-running replaces our marker block rather than duplicating
|
|
151
|
+
* it, and any user-authored hook content is preserved.
|
|
152
|
+
*/
|
|
153
|
+
function installGitSyncHook(projectRoot, hooks = exports.DEFAULT_SYNC_HOOKS) {
|
|
154
|
+
const hooksDir = gitHooksDir(projectRoot);
|
|
155
|
+
if (!hooksDir) {
|
|
156
|
+
return { installed: [], hooksDir: null, skipped: 'not a git repository' };
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
fs.mkdirSync(hooksDir, { recursive: true });
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return { installed: [], hooksDir, skipped: 'could not access the git hooks directory' };
|
|
163
|
+
}
|
|
164
|
+
const block = markerBlock();
|
|
165
|
+
const installed = [];
|
|
166
|
+
for (const hook of hooks) {
|
|
167
|
+
const file = path.join(hooksDir, hook);
|
|
168
|
+
let content;
|
|
169
|
+
if (fs.existsSync(file)) {
|
|
170
|
+
// Strip any prior block, then re-append the current one.
|
|
171
|
+
const base = stripMarkerBlock(fs.readFileSync(file, 'utf8')).replace(/\s*$/, '');
|
|
172
|
+
content = base.length > 0
|
|
173
|
+
? `${base}\n\n${block}\n`
|
|
174
|
+
: `#!/bin/sh\n${block}\n`;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
content = `#!/bin/sh\n${block}\n`;
|
|
178
|
+
}
|
|
179
|
+
fs.writeFileSync(file, content);
|
|
180
|
+
chmodExecutable(file);
|
|
181
|
+
installed.push(hook);
|
|
182
|
+
}
|
|
183
|
+
return { installed, hooksDir };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Remove the CodeGraph sync hooks. Strips only our marker block; deletes the
|
|
187
|
+
* hook file entirely when nothing but a shebang remains, otherwise rewrites
|
|
188
|
+
* the user's content untouched.
|
|
189
|
+
*/
|
|
190
|
+
function removeGitSyncHook(projectRoot, hooks = exports.DEFAULT_SYNC_HOOKS) {
|
|
191
|
+
const hooksDir = gitHooksDir(projectRoot);
|
|
192
|
+
if (!hooksDir) {
|
|
193
|
+
return { installed: [], hooksDir: null, skipped: 'not a git repository' };
|
|
194
|
+
}
|
|
195
|
+
const removed = [];
|
|
196
|
+
for (const hook of hooks) {
|
|
197
|
+
const file = path.join(hooksDir, hook);
|
|
198
|
+
if (!fs.existsSync(file))
|
|
199
|
+
continue;
|
|
200
|
+
const original = fs.readFileSync(file, 'utf8');
|
|
201
|
+
if (!original.includes(MARKER_BEGIN))
|
|
202
|
+
continue;
|
|
203
|
+
const stripped = stripMarkerBlock(original);
|
|
204
|
+
if (isEffectivelyEmpty(stripped)) {
|
|
205
|
+
fs.unlinkSync(file);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
fs.writeFileSync(file, `${stripped.replace(/\s*$/, '')}\n`);
|
|
209
|
+
chmodExecutable(file);
|
|
210
|
+
}
|
|
211
|
+
removed.push(hook);
|
|
212
|
+
}
|
|
213
|
+
return { installed: removed, hooksDir };
|
|
214
|
+
}
|
|
215
|
+
/** Whether any CodeGraph sync hook is currently installed. */
|
|
216
|
+
function isSyncHookInstalled(projectRoot, hooks = exports.DEFAULT_SYNC_HOOKS) {
|
|
217
|
+
const hooksDir = gitHooksDir(projectRoot);
|
|
218
|
+
if (!hooksDir)
|
|
219
|
+
return false;
|
|
220
|
+
return hooks.some((hook) => {
|
|
221
|
+
const file = path.join(hooksDir, hook);
|
|
222
|
+
return fs.existsSync(file) && fs.readFileSync(file, 'utf8').includes(MARKER_BEGIN);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=git-hooks.js.map
|