gitnexus 1.6.6-rc.98 → 1.6.6
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/README.md +122 -68
- package/dist/_shared/graph/types.d.ts +17 -1
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/_shared/index.d.ts +3 -5
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js +2 -4
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/scope-resolution/module-scope-index.d.ts +1 -2
- package/dist/_shared/scope-resolution/module-scope-index.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/module-scope-index.js +1 -2
- package/dist/_shared/scope-resolution/module-scope-index.js.map +1 -1
- package/dist/_shared/scope-resolution/parsed-file.d.ts +24 -0
- package/dist/_shared/scope-resolution/parsed-file.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts +13 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.d.ts +1 -0
- package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.js +6 -0
- package/dist/_shared/scope-resolution/registries/context.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/evidence.d.ts +2 -3
- package/dist/_shared/scope-resolution/registries/evidence.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/evidence.js +2 -3
- package/dist/_shared/scope-resolution/registries/evidence.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/macro-registry.d.ts +29 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.d.ts.map +1 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.js +32 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.js.map +1 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts +9 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/types.d.ts +1 -1
- package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
- package/dist/cli/ai-context.d.ts +35 -1
- package/dist/cli/ai-context.js +111 -12
- package/dist/cli/analyze-config.d.ts +92 -0
- package/dist/cli/analyze-config.js +364 -0
- package/dist/cli/analyze.d.ts +17 -1
- package/dist/cli/analyze.js +224 -71
- package/dist/cli/cli-message.d.ts +1 -1
- package/dist/cli/doctor.d.ts +18 -0
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/i18n/en.d.ts +2 -2
- package/dist/cli/i18n/en.js +2 -2
- package/dist/cli/i18n/resources.d.ts +2 -2
- package/dist/cli/i18n/zh-CN.js +2 -2
- package/dist/cli/index.js +4 -2
- package/dist/cli/resolve-invocation.d.ts +21 -0
- package/dist/cli/resolve-invocation.js +68 -0
- package/dist/cli/setup.d.ts +33 -0
- package/dist/cli/setup.js +96 -35
- package/dist/cli/skill-gen.js +2 -2
- package/dist/cli/wiki.js +20 -4
- package/dist/core/embeddings/embedder.d.ts +1 -1
- package/dist/core/embeddings/embedder.js +14 -1
- package/dist/core/embeddings/runtime-support.d.ts +41 -0
- package/dist/core/embeddings/runtime-support.js +65 -0
- package/dist/core/group/extractors/grpc-patterns/proto.js +2 -1
- package/dist/core/group/extractors/http-patterns/java.js +15 -1
- package/dist/core/ingestion/call-processor.d.ts +57 -227
- package/dist/core/ingestion/call-processor.js +172 -2595
- package/dist/core/ingestion/call-routing.d.ts +6 -5
- package/dist/core/ingestion/call-routing.js +6 -6
- package/dist/core/ingestion/call-types.d.ts +0 -75
- package/dist/core/ingestion/class-extractors/configs/c-cpp.js +26 -1
- package/dist/core/ingestion/class-extractors/configs/ruby.js +3 -0
- package/dist/core/ingestion/class-extractors/generic.js +9 -11
- package/dist/core/ingestion/class-types.d.ts +23 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +11 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +227 -73
- package/dist/core/ingestion/cobol-processor.d.ts +1 -0
- package/dist/core/ingestion/cobol-processor.js +51 -2
- package/dist/core/ingestion/emit-references.js +8 -2
- package/dist/core/ingestion/export-detection.d.ts +2 -1
- package/dist/core/ingestion/export-detection.js +2 -6
- package/dist/core/ingestion/field-extractors/configs/dart.d.ts +0 -6
- package/dist/core/ingestion/field-extractors/configs/dart.js +62 -44
- package/dist/core/ingestion/field-extractors/configs/go.d.ts +0 -9
- package/dist/core/ingestion/field-extractors/configs/go.js +40 -1
- package/dist/core/ingestion/field-extractors/configs/jvm.js +43 -4
- package/dist/core/ingestion/field-extractors/configs/php.js +1 -2
- package/dist/core/ingestion/field-extractors/configs/swift.d.ts +12 -1
- package/dist/core/ingestion/field-extractors/configs/swift.js +31 -6
- package/dist/core/ingestion/field-extractors/generic.d.ts +6 -0
- package/dist/core/ingestion/field-extractors/generic.js +5 -4
- package/dist/core/ingestion/field-extractors/typescript.js +0 -29
- package/dist/core/ingestion/filesystem-walker.d.ts +0 -9
- package/dist/core/ingestion/filesystem-walker.js +0 -11
- package/dist/core/ingestion/finalize-orchestrator.js +14 -2
- package/dist/core/ingestion/import-resolvers/configs/swift.d.ts +21 -0
- package/dist/core/ingestion/import-resolvers/configs/swift.js +72 -11
- package/dist/core/ingestion/import-resolvers/python.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/standard.d.ts +2 -2
- package/dist/core/ingestion/import-resolvers/standard.js +6 -5
- package/dist/core/ingestion/import-resolvers/utils.d.ts +2 -5
- package/dist/core/ingestion/import-resolvers/utils.js +1 -9
- package/dist/core/ingestion/language-provider.d.ts +39 -119
- package/dist/core/ingestion/language-provider.js +0 -2
- package/dist/core/ingestion/languages/c/capture-side-channel.d.ts +62 -0
- package/dist/core/ingestion/languages/c/capture-side-channel.js +65 -0
- package/dist/core/ingestion/languages/c/captures.js +41 -23
- package/dist/core/ingestion/languages/c/import-decomposer.d.ts +9 -0
- package/dist/core/ingestion/languages/c/import-decomposer.js +15 -0
- package/dist/core/ingestion/languages/c/import-target.js +52 -9
- package/dist/core/ingestion/languages/c/index.d.ts +2 -1
- package/dist/core/ingestion/languages/c/index.js +2 -1
- package/dist/core/ingestion/languages/c/query.js +15 -0
- package/dist/core/ingestion/languages/c/scope-resolver.js +47 -4
- package/dist/core/ingestion/languages/c/static-linkage.d.ts +8 -0
- package/dist/core/ingestion/languages/c/static-linkage.js +46 -1
- package/dist/core/ingestion/languages/c-cpp.js +16 -7
- package/dist/core/ingestion/languages/cobol/captures.js +25 -2
- package/dist/core/ingestion/languages/cpp/adl.d.ts +88 -4
- package/dist/core/ingestion/languages/cpp/adl.js +380 -160
- package/dist/core/ingestion/languages/cpp/arity-metadata.js +2 -8
- package/dist/core/ingestion/languages/cpp/capture-side-channel.d.ts +65 -0
- package/dist/core/ingestion/languages/cpp/capture-side-channel.js +78 -0
- package/dist/core/ingestion/languages/cpp/captures.js +162 -54
- package/dist/core/ingestion/languages/cpp/file-local-linkage.d.ts +18 -52
- package/dist/core/ingestion/languages/cpp/file-local-linkage.js +49 -1
- package/dist/core/ingestion/languages/cpp/import-decomposer.d.ts +7 -0
- package/dist/core/ingestion/languages/cpp/import-decomposer.js +12 -0
- package/dist/core/ingestion/languages/cpp/index.d.ts +1 -0
- package/dist/core/ingestion/languages/cpp/index.js +1 -0
- package/dist/core/ingestion/languages/cpp/inline-namespaces.d.ts +8 -0
- package/dist/core/ingestion/languages/cpp/inline-namespaces.js +21 -0
- package/dist/core/ingestion/languages/cpp/query.js +21 -0
- package/dist/core/ingestion/languages/cpp/range-bindings.js +20 -5
- package/dist/core/ingestion/languages/cpp/scope-resolver.js +52 -5
- package/dist/core/ingestion/languages/cpp/two-phase-lookup.d.ts +20 -0
- package/dist/core/ingestion/languages/cpp/two-phase-lookup.js +83 -3
- package/dist/core/ingestion/languages/csharp/captures.js +205 -41
- package/dist/core/ingestion/languages/csharp/index.d.ts +3 -4
- package/dist/core/ingestion/languages/csharp/index.js +3 -4
- package/dist/core/ingestion/languages/csharp/interpret.js +17 -3
- package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +17 -7
- package/dist/core/ingestion/languages/csharp/namespace-siblings.js +129 -124
- package/dist/core/ingestion/languages/csharp/qualified-type-names.d.ts +14 -0
- package/dist/core/ingestion/languages/csharp/qualified-type-names.js +59 -0
- package/dist/core/ingestion/languages/csharp/query.js +13 -0
- package/dist/core/ingestion/languages/csharp/receiver-binding.js +10 -6
- package/dist/core/ingestion/languages/csharp/scope-resolver.js +8 -1
- package/dist/core/ingestion/languages/csharp.js +0 -5
- package/dist/core/ingestion/languages/dart/arity-metadata.d.ts +25 -0
- package/dist/core/ingestion/languages/dart/arity-metadata.js +35 -0
- package/dist/core/ingestion/languages/dart/arity.d.ts +19 -0
- package/dist/core/ingestion/languages/dart/arity.js +31 -0
- package/dist/core/ingestion/languages/dart/built-ins.d.ts +11 -0
- package/dist/core/ingestion/languages/dart/built-ins.js +34 -0
- package/dist/core/ingestion/languages/dart/cache-stats.d.ts +13 -0
- package/dist/core/ingestion/languages/dart/cache-stats.js +24 -0
- package/dist/core/ingestion/languages/dart/captures.d.ts +29 -0
- package/dist/core/ingestion/languages/dart/captures.js +445 -0
- package/dist/core/ingestion/languages/dart/expand-wildcards.d.ts +13 -0
- package/dist/core/ingestion/languages/dart/expand-wildcards.js +31 -0
- package/dist/core/ingestion/languages/dart/import-target.d.ts +15 -0
- package/dist/core/ingestion/languages/dart/import-target.js +65 -0
- package/dist/core/ingestion/languages/dart/index.d.ts +28 -0
- package/dist/core/ingestion/languages/dart/index.js +28 -0
- package/dist/core/ingestion/languages/dart/interpret.d.ts +24 -0
- package/dist/core/ingestion/languages/dart/interpret.js +95 -0
- package/dist/core/ingestion/languages/dart/merge-bindings.d.ts +10 -0
- package/dist/core/ingestion/languages/dart/merge-bindings.js +39 -0
- package/dist/core/ingestion/languages/dart/query.d.ts +26 -0
- package/dist/core/ingestion/languages/dart/query.js +142 -0
- package/dist/core/ingestion/languages/dart/receiver-binding.d.ts +24 -0
- package/dist/core/ingestion/languages/dart/receiver-binding.js +87 -0
- package/dist/core/ingestion/languages/dart/scope-resolver.d.ts +29 -0
- package/dist/core/ingestion/languages/dart/scope-resolver.js +194 -0
- package/dist/core/ingestion/languages/dart/signature-bindings.d.ts +23 -0
- package/dist/core/ingestion/languages/dart/signature-bindings.js +51 -0
- package/dist/core/ingestion/languages/dart/simple-hooks.d.ts +20 -0
- package/dist/core/ingestion/languages/dart/simple-hooks.js +47 -0
- package/dist/core/ingestion/languages/dart.d.ts +0 -1
- package/dist/core/ingestion/languages/dart.js +15 -29
- package/dist/core/ingestion/languages/go/arity-metadata.d.ts +1 -0
- package/dist/core/ingestion/languages/go/arity-metadata.js +31 -1
- package/dist/core/ingestion/languages/go/captures.js +247 -26
- package/dist/core/ingestion/languages/go/interface-impls.js +476 -50
- package/dist/core/ingestion/languages/go/interpret.js +21 -11
- package/dist/core/ingestion/languages/go/method-owners.js +20 -8
- package/dist/core/ingestion/languages/go/query.js +15 -7
- package/dist/core/ingestion/languages/go/range-binding.js +24 -9
- package/dist/core/ingestion/languages/go/receiver-binding.js +1 -1
- package/dist/core/ingestion/languages/go/scope-resolver.js +2 -2
- package/dist/core/ingestion/languages/go/simple-hooks.js +10 -5
- package/dist/core/ingestion/languages/go/type-binding.d.ts +1 -0
- package/dist/core/ingestion/languages/go/type-binding.js +40 -2
- package/dist/core/ingestion/languages/go.d.ts +0 -1
- package/dist/core/ingestion/languages/go.js +0 -5
- package/dist/core/ingestion/languages/index.d.ts +0 -5
- package/dist/core/ingestion/languages/index.js +0 -3
- package/dist/core/ingestion/languages/java/captures.js +252 -23
- package/dist/core/ingestion/languages/java/interpret.js +12 -6
- package/dist/core/ingestion/languages/java/package-siblings.js +18 -5
- package/dist/core/ingestion/languages/java/query.js +16 -1
- package/dist/core/ingestion/languages/java/scope-resolver.d.ts +2 -8
- package/dist/core/ingestion/languages/java/scope-resolver.js +2 -8
- package/dist/core/ingestion/languages/java.js +0 -5
- package/dist/core/ingestion/languages/javascript/captures.js +185 -11
- package/dist/core/ingestion/languages/javascript/query.js +107 -1
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.d.ts +57 -0
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.js +60 -0
- package/dist/core/ingestion/languages/kotlin/captures.js +213 -22
- package/dist/core/ingestion/languages/kotlin/companion-scopes.d.ts +7 -0
- package/dist/core/ingestion/languages/kotlin/companion-scopes.js +10 -0
- package/dist/core/ingestion/languages/kotlin/index.d.ts +1 -0
- package/dist/core/ingestion/languages/kotlin/index.js +1 -0
- package/dist/core/ingestion/languages/kotlin/query.js +30 -0
- package/dist/core/ingestion/languages/kotlin/scope-resolver.d.ts +5 -7
- package/dist/core/ingestion/languages/kotlin/scope-resolver.js +22 -7
- package/dist/core/ingestion/languages/kotlin.js +8 -5
- package/dist/core/ingestion/languages/php/captures.js +135 -19
- package/dist/core/ingestion/languages/php/import-decomposer.js +21 -63
- package/dist/core/ingestion/languages/php/index.d.ts +3 -4
- package/dist/core/ingestion/languages/php/index.js +3 -4
- package/dist/core/ingestion/languages/php/query.js +5 -0
- package/dist/core/ingestion/languages/php/receiver-binding.js +8 -4
- package/dist/core/ingestion/languages/php.js +0 -4
- package/dist/core/ingestion/languages/python/captures.js +128 -13
- package/dist/core/ingestion/languages/python/depends-references.js +1 -1
- package/dist/core/ingestion/languages/python/import-target.d.ts +4 -5
- package/dist/core/ingestion/languages/python/import-target.js +108 -16
- package/dist/core/ingestion/languages/python/index-stats.d.ts +18 -0
- package/dist/core/ingestion/languages/python/index-stats.js +25 -0
- package/dist/core/ingestion/languages/python/index.d.ts +3 -4
- package/dist/core/ingestion/languages/python/index.js +3 -4
- package/dist/core/ingestion/languages/python/query.js +17 -0
- package/dist/core/ingestion/languages/python/scope-resolver.js +7 -6
- package/dist/core/ingestion/languages/python.d.ts +0 -2
- package/dist/core/ingestion/languages/python.js +0 -7
- package/dist/core/ingestion/languages/ruby/captures.js +174 -31
- package/dist/core/ingestion/languages/ruby/import-target.js +2 -1
- package/dist/core/ingestion/languages/ruby/interpret.js +2 -1
- package/dist/core/ingestion/languages/ruby/query.js +10 -0
- package/dist/core/ingestion/languages/ruby/scope-resolver.js +61 -11
- package/dist/core/ingestion/languages/ruby.js +4 -53
- package/dist/core/ingestion/languages/rust/captures.js +95 -13
- package/dist/core/ingestion/languages/rust/query.js +64 -1
- package/dist/core/ingestion/languages/rust/range-binding.js +40 -12
- package/dist/core/ingestion/languages/rust/receiver-binding.js +9 -0
- package/dist/core/ingestion/languages/rust/scope-resolver.js +75 -1
- package/dist/core/ingestion/languages/rust.d.ts +0 -2
- package/dist/core/ingestion/languages/rust.js +0 -6
- package/dist/core/ingestion/languages/swift/arity-metadata.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/arity-metadata.js +41 -0
- package/dist/core/ingestion/languages/swift/arity.d.ts +29 -0
- package/dist/core/ingestion/languages/swift/arity.js +42 -0
- package/dist/core/ingestion/languages/swift/base-type.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/base-type.js +27 -0
- package/dist/core/ingestion/languages/swift/cache-stats.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/cache-stats.js +26 -0
- package/dist/core/ingestion/languages/swift/captures.d.ts +35 -0
- package/dist/core/ingestion/languages/swift/captures.js +495 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.js +57 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.js +84 -0
- package/dist/core/ingestion/languages/swift/import-target.d.ts +33 -0
- package/dist/core/ingestion/languages/swift/import-target.js +81 -0
- package/dist/core/ingestion/languages/swift/index.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/index.js +37 -0
- package/dist/core/ingestion/languages/swift/interpret.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/interpret.js +89 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.js +48 -0
- package/dist/core/ingestion/languages/swift/query.d.ts +46 -0
- package/dist/core/ingestion/languages/swift/query.js +194 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.d.ts +40 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.js +161 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.d.ts +50 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.js +189 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.js +65 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.d.ts +25 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.js +66 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.js +60 -0
- package/dist/core/ingestion/languages/swift/target-grouping.d.ts +51 -0
- package/dist/core/ingestion/languages/swift/target-grouping.js +93 -0
- package/dist/core/ingestion/languages/swift/target-siblings.d.ts +30 -0
- package/dist/core/ingestion/languages/swift/target-siblings.js +71 -0
- package/dist/core/ingestion/languages/swift.d.ts +0 -5
- package/dist/core/ingestion/languages/swift.js +11 -87
- package/dist/core/ingestion/languages/typescript/array-callback.d.ts +3 -29
- package/dist/core/ingestion/languages/typescript/array-callback.js +4 -43
- package/dist/core/ingestion/languages/typescript/captures.js +147 -17
- package/dist/core/ingestion/languages/typescript/index.d.ts +3 -4
- package/dist/core/ingestion/languages/typescript/index.js +3 -4
- package/dist/core/ingestion/languages/typescript/query.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript/query.js +125 -4
- package/dist/core/ingestion/languages/typescript/receiver-binding.js +0 -1
- package/dist/core/ingestion/languages/typescript.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript.js +46 -23
- package/dist/core/ingestion/languages/vue/captures.d.ts +46 -0
- package/dist/core/ingestion/languages/vue/captures.js +67 -0
- package/dist/core/ingestion/languages/vue/import-target.d.ts +27 -0
- package/dist/core/ingestion/languages/vue/import-target.js +58 -0
- package/dist/core/ingestion/languages/vue/index.d.ts +49 -0
- package/dist/core/ingestion/languages/vue/index.js +49 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.d.ts +55 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.js +292 -0
- package/dist/core/ingestion/languages/vue.js +12 -4
- package/dist/core/ingestion/local-symbol-pruner.d.ts +11 -0
- package/dist/core/ingestion/local-symbol-pruner.js +63 -0
- package/dist/core/ingestion/method-extractors/configs/dart.js +14 -1
- package/dist/core/ingestion/method-extractors/configs/jvm.js +37 -20
- package/dist/core/ingestion/method-extractors/configs/php.js +0 -1
- package/dist/core/ingestion/method-extractors/configs/swift.js +11 -4
- package/dist/core/ingestion/method-types.d.ts +2 -2
- package/dist/core/ingestion/model/index.d.ts +0 -3
- package/dist/core/ingestion/model/index.js +0 -8
- package/dist/core/ingestion/model/resolve.d.ts +7 -43
- package/dist/core/ingestion/model/resolve.js +7 -226
- package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +46 -1
- package/dist/core/ingestion/model/semantic-model.d.ts +4 -6
- package/dist/core/ingestion/model/semantic-model.js +1 -1
- package/dist/core/ingestion/model/symbol-table.d.ts +3 -4
- package/dist/core/ingestion/model/symbol-table.js +3 -4
- package/dist/core/ingestion/parsing-processor.d.ts +30 -24
- package/dist/core/ingestion/parsing-processor.js +76 -640
- package/dist/core/ingestion/pipeline-phases/communities.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/communities.js +5 -2
- package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +9 -8
- package/dist/core/ingestion/pipeline-phases/cross-file.js +16 -12
- package/dist/core/ingestion/pipeline-phases/index.d.ts +1 -0
- package/dist/core/ingestion/pipeline-phases/index.js +1 -0
- package/dist/core/ingestion/pipeline-phases/mro.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/mro.js +2 -2
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +44 -22
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +426 -565
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +13 -33
- package/dist/core/ingestion/pipeline-phases/parse.js +2 -2
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/processes.js +5 -3
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.d.ts +14 -0
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.js +26 -0
- package/dist/core/ingestion/pipeline.d.ts +27 -19
- package/dist/core/ingestion/pipeline.js +4 -2
- package/dist/core/ingestion/resolve-references.js +15 -3
- package/dist/core/ingestion/route-extractors/laravel.d.ts +10 -0
- package/dist/core/ingestion/route-extractors/laravel.js +88 -9
- package/dist/core/ingestion/scope-extractor-bridge.d.ts +2 -1
- package/dist/core/ingestion/scope-extractor-bridge.js +2 -2
- package/dist/core/ingestion/scope-extractor.js +13 -0
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +181 -15
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +21 -10
- package/dist/core/ingestion/scope-resolution/graph-bridge/edges.js +10 -2
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +7 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +58 -6
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +24 -5
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +68 -1
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +189 -29
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +21 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +1 -1
- package/dist/core/ingestion/scope-resolution/pipeline/phase.d.ts +8 -11
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +171 -50
- package/dist/core/ingestion/scope-resolution/pipeline/registry.d.ts +3 -4
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +9 -4
- package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +28 -5
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +191 -24
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +31 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +72 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +440 -39
- package/dist/core/ingestion/scope-resolution/workspace-index.d.ts +18 -2
- package/dist/core/ingestion/scope-resolution/workspace-index.js +94 -7
- package/dist/core/ingestion/tree-sitter-queries.d.ts +14 -14
- package/dist/core/ingestion/tree-sitter-queries.js +380 -158
- package/dist/core/ingestion/ts-js-hoc-utils.d.ts +12 -0
- package/dist/core/ingestion/ts-js-hoc-utils.js +105 -0
- package/dist/core/ingestion/type-env.d.ts +2 -1
- package/dist/core/ingestion/type-env.js +6 -8
- package/dist/core/ingestion/type-extractors/c-cpp.js +8 -10
- package/dist/core/ingestion/type-extractors/csharp.js +18 -34
- package/dist/core/ingestion/type-extractors/go.js +2 -10
- package/dist/core/ingestion/type-extractors/jvm.js +6 -5
- package/dist/core/ingestion/type-extractors/php.js +1 -1
- package/dist/core/ingestion/type-extractors/python.js +1 -1
- package/dist/core/ingestion/type-extractors/ruby.js +2 -2
- package/dist/core/ingestion/type-extractors/rust.js +0 -16
- package/dist/core/ingestion/type-extractors/shared.d.ts +2 -2
- package/dist/core/ingestion/type-extractors/shared.js +25 -11
- package/dist/core/ingestion/type-extractors/swift.js +5 -5
- package/dist/core/ingestion/type-extractors/types.d.ts +1 -1
- package/dist/core/ingestion/type-extractors/typescript.js +1 -1
- package/dist/core/ingestion/utils/ast-helpers.d.ts +119 -1
- package/dist/core/ingestion/utils/ast-helpers.js +260 -13
- package/dist/core/ingestion/utils/callable-labels.d.ts +13 -0
- package/dist/core/ingestion/utils/callable-labels.js +14 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.d.ts +10 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.js +30 -0
- package/dist/core/ingestion/utils/heap-probe.d.ts +20 -0
- package/dist/core/ingestion/utils/heap-probe.js +39 -0
- package/dist/core/ingestion/utils/heritage-marker.d.ts +33 -0
- package/dist/core/ingestion/utils/heritage-marker.js +41 -0
- package/dist/core/ingestion/utils/qualified-name.d.ts +37 -0
- package/dist/core/ingestion/utils/qualified-name.js +67 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +49 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.js +76 -62
- package/dist/core/ingestion/variable-extractors/configs/go.js +74 -7
- package/dist/core/ingestion/variable-extractors/configs/jvm.js +35 -8
- package/dist/core/ingestion/variable-extractors/generic.js +40 -12
- package/dist/core/ingestion/variable-types.d.ts +9 -0
- package/dist/core/ingestion/vue-sfc-extractor.d.ts +97 -7
- package/dist/core/ingestion/vue-sfc-extractor.js +433 -11
- package/dist/core/ingestion/workers/parse-worker.d.ts +0 -11
- package/dist/core/ingestion/workers/parse-worker.js +358 -187
- package/dist/core/ingestion/workers/worker-pool.d.ts +78 -9
- package/dist/core/ingestion/workers/worker-pool.js +346 -49
- package/dist/core/lbug/csv-generator.js +20 -2
- package/dist/core/lbug/lbug-adapter.js +29 -10
- package/dist/core/lbug/native-check.js +17 -5
- package/dist/core/lbug/pool-adapter.d.ts +0 -19
- package/dist/core/lbug/pool-adapter.js +40 -77
- package/dist/core/lbug/query-result-utils.d.ts +19 -0
- package/dist/core/lbug/query-result-utils.js +28 -0
- package/dist/core/run-analyze.d.ts +9 -2
- package/dist/core/run-analyze.js +24 -3
- package/dist/core/tree-sitter/parser-loader.d.ts +13 -0
- package/dist/core/tree-sitter/parser-loader.js +4 -0
- package/dist/core/tree-sitter/safe-parse.d.ts +70 -3
- package/dist/core/tree-sitter/safe-parse.js +214 -11
- package/dist/core/wiki/generator.js +13 -5
- package/dist/core/wiki/graph-queries.d.ts +3 -0
- package/dist/core/wiki/graph-queries.js +9 -1
- package/dist/core/wiki/llm-client.d.ts +1 -1
- package/dist/core/wiki/llm-client.js +7 -2
- package/dist/core/wiki/local-cli-client.d.ts +2 -1
- package/dist/core/wiki/local-cli-client.js +62 -4
- package/dist/mcp/compatible-stdio-transport.d.ts +3 -0
- package/dist/mcp/compatible-stdio-transport.js +22 -0
- package/dist/mcp/core/embedder.d.ts +1 -1
- package/dist/mcp/core/embedder.js +13 -1
- package/dist/mcp/local/local-backend.d.ts +37 -5
- package/dist/mcp/local/local-backend.js +227 -129
- package/dist/mcp/resources.js +3 -3
- package/dist/mcp/server.js +9 -1
- package/dist/storage/git.d.ts +11 -0
- package/dist/storage/git.js +30 -0
- package/dist/storage/parse-cache.d.ts +23 -1
- package/dist/storage/parse-cache.js +138 -32
- package/dist/storage/parsedfile-store.d.ts +142 -0
- package/dist/storage/parsedfile-store.js +367 -0
- package/dist/storage/repo-manager.d.ts +2 -1
- package/dist/storage/scope-index-store.d.ts +114 -0
- package/dist/storage/scope-index-store.js +236 -0
- package/dist/types/pipeline.d.ts +6 -3
- package/hooks/antigravity/gitnexus-antigravity-hook.cjs +2 -1
- package/hooks/claude/gitnexus-hook.cjs +2 -1
- package/hooks/claude/resolve-analyze-cmd.cjs +323 -0
- package/package.json +4 -5
- package/scripts/bench-scope-resolution.ts +1 -3
- package/scripts/cross-platform-tests.ts +4 -1
- package/skills/gitnexus-cli.md +8 -6
- package/skills/gitnexus-debugging.md +15 -15
- package/skills/gitnexus-exploring.md +11 -11
- package/skills/gitnexus-guide.md +1 -1
- package/skills/gitnexus-impact-analysis.md +10 -10
- package/skills/gitnexus-pr-review.md +19 -19
- package/skills/gitnexus-refactoring.md +25 -25
- package/web/assets/{agent-BRX-afm3.js → agent-EkX7webX.js} +156 -131
- package/web/assets/{architectureDiagram-UL44E2DR-B1oYB8-c.js → architectureDiagram-UL44E2DR-BoczH8cv.js} +1 -1
- package/web/assets/{chunk-LCXTWHL2-SPC6pgWI.js → chunk-LCXTWHL2-By5HB3b-.js} +1 -1
- package/web/assets/{chunk-RG4AUYOV-DZXr4Yv3.js → chunk-RG4AUYOV-BQE_DkpL.js} +1 -1
- package/web/assets/{classDiagram-KGZ6W3CR-BqpOj8L9.js → classDiagram-KGZ6W3CR-Dj_02GUH.js} +1 -1
- package/web/assets/{classDiagram-v2-72OJOZXJ-FmElywK2.js → classDiagram-v2-72OJOZXJ-D-NArMpf.js} +1 -1
- package/web/assets/{diagram-3NCE3AQN-BWtJXMDq.js → diagram-3NCE3AQN-VXtXDO95.js} +1 -1
- package/web/assets/{diagram-GF46GFSD-Hh-fChxU.js → diagram-GF46GFSD-B1qab2Ah.js} +1 -1
- package/web/assets/{diagram-QXG6HAR7-DYeQHxGU.js → diagram-QXG6HAR7-BSCHGzzT.js} +1 -1
- package/web/assets/{diagram-WEQXMOUZ-DYGU4T0y.js → diagram-WEQXMOUZ-DHtknmNT.js} +1 -1
- package/web/assets/{erDiagram-L5TCEMPS-bN3wlP2A.js → erDiagram-L5TCEMPS-Db-IYTmm.js} +1 -1
- package/web/assets/{flowDiagram-H6V6AXG4-YACVtF3-.js → flowDiagram-H6V6AXG4-BHDoyVoW.js} +1 -1
- package/web/assets/{index-BhnAdWTt.js → index-BR0IhgbR.js} +10 -10
- package/web/assets/{infoDiagram-3YFTVSEB-BWBzD28-.js → infoDiagram-3YFTVSEB-6h8wbWEe.js} +1 -1
- package/web/assets/{ishikawaDiagram-BNXS4ZKH-B8qYT-j9.js → ishikawaDiagram-BNXS4ZKH-Dx2OkPk1.js} +1 -1
- package/web/assets/{kanban-definition-75IXJCU3-BeoPr5Tl.js → kanban-definition-75IXJCU3-CIIEZfqV.js} +1 -1
- package/web/assets/{mindmap-definition-2TDM6QVE-CdLLN_so.js → mindmap-definition-2TDM6QVE-DUAqydRq.js} +1 -1
- package/web/assets/{pieDiagram-CU6KROY3-DEd2a_k_.js → pieDiagram-CU6KROY3-BntYuYZa.js} +1 -1
- package/web/assets/{requirementDiagram-JXO7QTGE-QNeTo5C_.js → requirementDiagram-JXO7QTGE-QCD6I29n.js} +1 -1
- package/web/assets/{sequenceDiagram-VS2MUI6T-BHC7q7yJ.js → sequenceDiagram-VS2MUI6T-DScFwLz2.js} +1 -1
- package/web/assets/{stateDiagram-7D4R322I-KONnc2Px.js → stateDiagram-7D4R322I-AkRAm6Hl.js} +1 -1
- package/web/assets/{stateDiagram-v2-36443NZ5-C2QfuMlu.js → stateDiagram-v2-36443NZ5-BCK1vigR.js} +1 -1
- package/web/assets/{timeline-definition-O6YCAMPW-D4t4NJx1.js → timeline-definition-O6YCAMPW-BvpIVXjX.js} +1 -1
- package/web/assets/{vennDiagram-MWXL3ELB-6bctC9Yg.js → vennDiagram-MWXL3ELB-BYGWk6dK.js} +1 -1
- package/web/assets/{wardleyDiagram-CUQ6CDDI-BPZYNTvC.js → wardleyDiagram-CUQ6CDDI-Dk1z7H2T.js} +1 -1
- package/web/assets/{xychartDiagram-N2JHSOCM-lBI9O6DW.js → xychartDiagram-N2JHSOCM-2N6NCSWN.js} +1 -1
- package/web/index.html +1 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts +0 -63
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.js +0 -122
- package/dist/_shared/scope-resolution/shadow/aggregate.js.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.d.ts +0 -59
- package/dist/_shared/scope-resolution/shadow/diff.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.js +0 -79
- package/dist/_shared/scope-resolution/shadow/diff.js.map +0 -1
- package/dist/core/ingestion/ast-cache.d.ts +0 -26
- package/dist/core/ingestion/ast-cache.js +0 -48
- package/dist/core/ingestion/heritage-extractors/configs/go.d.ts +0 -13
- package/dist/core/ingestion/heritage-extractors/configs/go.js +0 -20
- package/dist/core/ingestion/heritage-extractors/configs/ruby.d.ts +0 -18
- package/dist/core/ingestion/heritage-extractors/configs/ruby.js +0 -65
- package/dist/core/ingestion/heritage-extractors/generic.d.ts +0 -23
- package/dist/core/ingestion/heritage-extractors/generic.js +0 -47
- package/dist/core/ingestion/heritage-processor.d.ts +0 -54
- package/dist/core/ingestion/heritage-processor.js +0 -367
- package/dist/core/ingestion/heritage-types.d.ts +0 -73
- package/dist/core/ingestion/heritage-types.js +0 -2
- package/dist/core/ingestion/import-processor.d.ts +0 -23
- package/dist/core/ingestion/import-processor.js +0 -377
- package/dist/core/ingestion/model/heritage-map.d.ts +0 -105
- package/dist/core/ingestion/model/heritage-map.js +0 -294
- package/dist/core/ingestion/model/resolution-context.d.ts +0 -93
- package/dist/core/ingestion/model/resolution-context.js +0 -337
- package/dist/core/ingestion/named-bindings/csharp.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/csharp.js +0 -37
- package/dist/core/ingestion/named-bindings/java.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/java.js +0 -29
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/kotlin.js +0 -36
- package/dist/core/ingestion/named-bindings/php.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/php.js +0 -61
- package/dist/core/ingestion/named-bindings/python.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/python.js +0 -49
- package/dist/core/ingestion/named-bindings/rust.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/rust.js +0 -66
- package/dist/core/ingestion/named-bindings/types.d.ts +0 -16
- package/dist/core/ingestion/named-bindings/types.js +0 -6
- package/dist/core/ingestion/named-bindings/typescript.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/typescript.js +0 -58
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +0 -17
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +0 -209
- package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +0 -22
- package/dist/core/ingestion/pipeline-phases/orm-extraction.js +0 -92
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +0 -70
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +0 -312
- package/dist/core/ingestion/registry-primary-flag.d.ts +0 -89
- package/dist/core/ingestion/registry-primary-flag.js +0 -122
- package/dist/core/ingestion/shadow-harness.d.ts +0 -113
- package/dist/core/ingestion/shadow-harness.js +0 -148
- package/dist/core/ingestion/utils/ruby-self-call.d.ts +0 -52
- package/dist/core/ingestion/utils/ruby-self-call.js +0 -59
- package/scripts/ci-list-migrated-languages.ts +0 -24
- package/scripts/run-parity.ts +0 -128
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from '../logger.js';
|
|
1
2
|
/**
|
|
2
3
|
* tree-sitter 0.21.x's Node native binding crashes (SIGSEGV) on Windows when
|
|
3
4
|
* `parser.parse(string, …)` is handed a JS string longer than 32 767 chars.
|
|
@@ -16,17 +17,219 @@ const SAFE_PARSE_CHUNK_CHARS = 16 * 1024;
|
|
|
16
17
|
*/
|
|
17
18
|
const DIRECT_PARSE_LIMIT_CHARS = 16 * 1024;
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* Default per-parse wall-clock budget in milliseconds. A pathological input
|
|
21
|
+
* (deeply nested / quadratic-grammar source) can spin tree-sitter for tens of
|
|
22
|
+
* seconds, stalling the worker that holds it. The pool's per-dispatch idle
|
|
23
|
+
* timeout is 30 s (`DEFAULT_SUB_BATCH_IDLE_TIMEOUT_MS` in
|
|
24
|
+
* `workers/worker-pool.ts`); this budget MUST stay below it so a single bad
|
|
25
|
+
* file is hard-skipped here rather than tripping the slower pool-level
|
|
26
|
+
* retry/respawn machinery. 15 s leaves comfortable headroom.
|
|
27
|
+
*
|
|
28
|
+
* Override via `GITNEXUS_PARSE_TIMEOUT_MS`; `0` disables the budget entirely
|
|
29
|
+
* (unlimited parse time — restore the historical behaviour for debugging).
|
|
30
|
+
*/
|
|
31
|
+
const DEFAULT_PARSE_TIMEOUT_MS = 15_000;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the per-parse budget in milliseconds from the environment. A
|
|
34
|
+
* non-negative integer overrides the default; `0` disables the timeout.
|
|
35
|
+
* Unparseable / negative values fall back to the default rather than
|
|
36
|
+
* silently disabling the safety net.
|
|
37
|
+
*/
|
|
38
|
+
function resolveParseTimeoutMs() {
|
|
39
|
+
const raw = process.env.GITNEXUS_PARSE_TIMEOUT_MS;
|
|
40
|
+
if (raw === undefined || raw === '')
|
|
41
|
+
return DEFAULT_PARSE_TIMEOUT_MS;
|
|
42
|
+
const parsed = Number(raw);
|
|
43
|
+
if (!Number.isFinite(parsed) || parsed < 0)
|
|
44
|
+
return DEFAULT_PARSE_TIMEOUT_MS;
|
|
45
|
+
return Math.floor(parsed);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Tiny shim around the runtime's parse-interruption knob so the future
|
|
49
|
+
* 0.25/0.26 swap (where `setTimeoutMicros` is removed in favour of
|
|
50
|
+
* `Parser.Options.progressCallback`) is a single-function change.
|
|
51
|
+
*
|
|
52
|
+
* Returns `true` when a budget was armed (caller must clear it afterwards),
|
|
53
|
+
* `false` when the runtime offers no interruption mechanism (older/newer
|
|
54
|
+
* runtimes) so the caller can skip the reset/clear dance.
|
|
55
|
+
*
|
|
56
|
+
* Only the `setTimeoutMicros` branch is implemented today; add the
|
|
57
|
+
* `progressCallback` branch here when the runtime moves to 0.25+.
|
|
58
|
+
*/
|
|
59
|
+
function armParseBudget(parser, budgetMs) {
|
|
60
|
+
if (budgetMs <= 0)
|
|
61
|
+
return false;
|
|
62
|
+
const cap = parser;
|
|
63
|
+
if (typeof cap.setTimeoutMicros !== 'function')
|
|
64
|
+
return false;
|
|
65
|
+
cap.setTimeoutMicros(Math.floor(budgetMs * 1000));
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Clear any armed parse budget so it never leaks to the next parse on a
|
|
70
|
+
* reused/singleton parser. Safe to call when nothing was armed.
|
|
71
|
+
*/
|
|
72
|
+
function clearParseBudget(parser) {
|
|
73
|
+
const cap = parser;
|
|
74
|
+
cap.setTimeoutMicros?.(0);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Reset parser state after a timeout. tree-sitter RESUMES the interrupted
|
|
78
|
+
* parse on the next `parse()` call unless `reset()` is invoked first
|
|
79
|
+
* (tree-sitter `api.h`); skipping this corrupts the next file's tree on the
|
|
80
|
+
* shared singleton.
|
|
81
|
+
*/
|
|
82
|
+
function resetParser(parser) {
|
|
83
|
+
parser.reset?.();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Thrown when a parse exceeds its wall-clock budget (see
|
|
87
|
+
* {@link DEFAULT_PARSE_TIMEOUT_MS}). The parser has already been `reset()` and
|
|
88
|
+
* its budget cleared by the time this propagates, so callers may safely reuse
|
|
89
|
+
* the same parser for the next file.
|
|
90
|
+
*
|
|
91
|
+
* Hard-skip contract: a timeout is fatal for the offending file but MUST NOT
|
|
92
|
+
* abort the run. Every caller is responsible for catching this specific error
|
|
93
|
+
* (`instanceof ParseTimeoutError`), skipping that one file (degrade-and-
|
|
94
|
+
* continue), and re-throwing anything else. Catching it generically and
|
|
95
|
+
* swallowing all errors would mask real bugs, so callers match on the type.
|
|
96
|
+
*/
|
|
97
|
+
export class ParseTimeoutError extends Error {
|
|
98
|
+
budgetMs;
|
|
99
|
+
label;
|
|
100
|
+
constructor(budgetMs, label) {
|
|
101
|
+
super(`tree-sitter parse exceeded its ${budgetMs}ms budget` +
|
|
102
|
+
(label ? ` while parsing ${label}` : '') +
|
|
103
|
+
' (set GITNEXUS_PARSE_TIMEOUT_MS=0 to disable, or raise the budget)');
|
|
104
|
+
this.name = 'ParseTimeoutError';
|
|
105
|
+
this.budgetMs = budgetMs;
|
|
106
|
+
this.label = label;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Per-run counter so a corpus full of minor-error files emits a bounded
|
|
111
|
+
* number of degraded-parse logs instead of one per file. The count is
|
|
112
|
+
* reported on the throttled records so operators still see the true scale.
|
|
21
113
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
114
|
+
let degradedParseCount = 0;
|
|
115
|
+
const DEGRADED_PARSE_LOG_LIMIT = 20;
|
|
116
|
+
/**
|
|
117
|
+
* Reset the per-run degraded-parse log throttle. Called at the start of every
|
|
118
|
+
* analysis run (`runFullAnalysis`) so the first-N-then-suppress budget is
|
|
119
|
+
* scoped to a single run rather than to the lifetime of the module (which, on
|
|
120
|
+
* a reused process, would suppress all degraded-parse logs after the first
|
|
121
|
+
* run). Safe to call at any time.
|
|
122
|
+
*/
|
|
123
|
+
export function resetDegradedParseCounter() {
|
|
124
|
+
degradedParseCount = 0;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @internal Test-only alias for {@link resetDegradedParseCounter}, kept so the
|
|
128
|
+
* existing `safe-parse.test.ts` import keeps working. Prefer the public name.
|
|
129
|
+
*/
|
|
130
|
+
export function _resetDegradedParseCounter() {
|
|
131
|
+
resetDegradedParseCounter();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* True when the parsed tree contains any ERROR or MISSING node — i.e. the
|
|
135
|
+
* source did not parse cleanly and tree-sitter applied error recovery.
|
|
136
|
+
* `parse` never throws on bad syntax (it recovers into ERROR/MISSING nodes),
|
|
137
|
+
* so this is the only signal callers have that a tree is degraded.
|
|
138
|
+
*/
|
|
139
|
+
export function parseHadErrors(tree) {
|
|
140
|
+
const root = tree.rootNode;
|
|
141
|
+
if (root == null)
|
|
142
|
+
return false;
|
|
143
|
+
return root.hasError || root.isMissing;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Structured diagnostics for a parsed tree. Cheap (reads boolean node
|
|
147
|
+
* properties only); callers that just want a yes/no use {@link parseHadErrors}.
|
|
148
|
+
*/
|
|
149
|
+
export function getParseDiagnostics(tree) {
|
|
150
|
+
const root = tree.rootNode;
|
|
151
|
+
if (root == null)
|
|
152
|
+
return { hasError: false, isMissing: false };
|
|
153
|
+
return { hasError: root.hasError, isMissing: root.isMissing };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Parse `sourceText` safely on every platform.
|
|
157
|
+
*
|
|
158
|
+
* This is the single "parse safely" entry point and its contract covers three
|
|
159
|
+
* concerns:
|
|
160
|
+
*
|
|
161
|
+
* 1. **Windows crash workaround.** Inputs longer than 32 767 chars are fed
|
|
162
|
+
* through the chunked `Parser.Input` callback overload to dodge the
|
|
163
|
+
* 0.21.x string-to-buffer SIGSEGV. See {@link SAFE_PARSE_CHUNK_CHARS}.
|
|
164
|
+
*
|
|
165
|
+
* 2. **Runaway-parse timeout.** A per-parse budget (default 15 s, env
|
|
166
|
+
* `GITNEXUS_PARSE_TIMEOUT_MS`, `0` disables) is armed before parsing on
|
|
167
|
+
* both the direct and chunked paths. On timeout the runtime returns
|
|
168
|
+
* `null`; this function `reset()`s the parser, clears the budget, and
|
|
169
|
+
* throws {@link ParseTimeoutError}. The budget is always cleared in a
|
|
170
|
+
* `finally` so it never leaks to the next parse on a reused/singleton
|
|
171
|
+
* parser (`loadParser()` and the worker both reuse one `Parser`).
|
|
172
|
+
*
|
|
173
|
+
* 3. **Intrinsic error detection.** On a successful parse, a degraded tree
|
|
174
|
+
* (`rootNode.hasError`) is logged at `debug` level with throttling, then
|
|
175
|
+
* the tree is **returned anyway** — error recovery is a downgrade, never a
|
|
176
|
+
* drop. Callers wanting the boolean use {@link parseHadErrors}.
|
|
177
|
+
*
|
|
178
|
+
* @param label optional context (e.g. file path) attached to timeout errors
|
|
179
|
+
* and degraded-parse logs. Non-breaking trailing param.
|
|
180
|
+
*/
|
|
181
|
+
export function parseSourceSafe(parser, sourceText, oldTree, options, label) {
|
|
182
|
+
const budgetMs = resolveParseTimeoutMs();
|
|
183
|
+
const armed = armParseBudget(parser, budgetMs);
|
|
184
|
+
let tree;
|
|
185
|
+
try {
|
|
186
|
+
if (sourceText.length <= DIRECT_PARSE_LIMIT_CHARS) {
|
|
187
|
+
tree = parser.parse(sourceText, oldTree, options);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
const input = (index) => {
|
|
191
|
+
if (index >= sourceText.length)
|
|
192
|
+
return null;
|
|
193
|
+
return sourceText.slice(index, index + SAFE_PARSE_CHUNK_CHARS);
|
|
194
|
+
};
|
|
195
|
+
tree = parser.parse(input, oldTree, options);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
// Always clear the budget — otherwise it leaks onto the next parse on a
|
|
200
|
+
// reused singleton parser, prematurely killing an innocent file.
|
|
201
|
+
if (armed)
|
|
202
|
+
clearParseBudget(parser);
|
|
203
|
+
}
|
|
204
|
+
// A `null` return means the runtime hit the budget mid-parse. The parser
|
|
205
|
+
// would otherwise RESUME this parse on the next call, so reset it before
|
|
206
|
+
// surfacing the timeout as a typed throw (callers skip the file).
|
|
207
|
+
if (tree === null) {
|
|
208
|
+
if (armed)
|
|
209
|
+
resetParser(parser);
|
|
210
|
+
throw new ParseTimeoutError(budgetMs, label);
|
|
211
|
+
}
|
|
212
|
+
// Intrinsic ERROR detection. tree-sitter recovers from bad syntax into
|
|
213
|
+
// ERROR/MISSING nodes rather than throwing, so a clean return can still
|
|
214
|
+
// wrap a degraded tree. Log it (throttled, debug-level so common minor
|
|
215
|
+
// errors don't flood) but DOWNGRADE — never drop — and return the tree.
|
|
216
|
+
//
|
|
217
|
+
// Guard `rootNode` defensively: a real tree-sitter tree always exposes one,
|
|
218
|
+
// but stub parsers in tests (and any future non-standard `Parser.Tree`) may
|
|
219
|
+
// not. A missing root is treated as "no detectable errors" so detection
|
|
220
|
+
// never throws on the parse success path.
|
|
221
|
+
if (tree.rootNode != null && parseHadErrors(tree)) {
|
|
222
|
+
degradedParseCount += 1;
|
|
223
|
+
if (degradedParseCount <= DEGRADED_PARSE_LOG_LIMIT) {
|
|
224
|
+
logger.debug({
|
|
225
|
+
...(label ? { file: label } : {}),
|
|
226
|
+
rootType: tree.rootNode.type,
|
|
227
|
+
degradedParseCount,
|
|
228
|
+
...(degradedParseCount === DEGRADED_PARSE_LOG_LIMIT
|
|
229
|
+
? { note: 'further degraded-parse logs suppressed this run' }
|
|
230
|
+
: {}),
|
|
231
|
+
}, 'tree-sitter parsed with errors (degraded tree)');
|
|
232
|
+
}
|
|
25
233
|
}
|
|
26
|
-
|
|
27
|
-
if (index >= sourceText.length)
|
|
28
|
-
return null;
|
|
29
|
-
return sourceText.slice(index, index + SAFE_PARSE_CHUNK_CHARS);
|
|
30
|
-
};
|
|
31
|
-
return parser.parse(input, oldTree, options);
|
|
234
|
+
return tree;
|
|
32
235
|
}
|
|
@@ -17,7 +17,7 @@ import { generateHTMLViewer } from './html-viewer.js';
|
|
|
17
17
|
import { sanitizeMermaidMarkdown } from './mermaid-sanitizer.js';
|
|
18
18
|
import { callLLM, estimateTokens, } from './llm-client.js';
|
|
19
19
|
import { callCursorLLM, resolveCursorConfig } from './cursor-client.js';
|
|
20
|
-
import { callClaudeLLM, callCodexLLM, resolveLocalCLIConfig } from './local-cli-client.js';
|
|
20
|
+
import { callClaudeLLM, callCodexLLM, callOpenCodeLLM, resolveLocalCLIConfig, } from './local-cli-client.js';
|
|
21
21
|
import { GROUPING_SYSTEM_PROMPT, GROUPING_USER_PROMPT, MODULE_SYSTEM_PROMPT, MODULE_USER_PROMPT, PARENT_SYSTEM_PROMPT, PARENT_USER_PROMPT, OVERVIEW_SYSTEM_PROMPT, OVERVIEW_USER_PROMPT, fillTemplate, formatFileListForGrouping, formatDirectoryTree, formatCallEdges, formatProcesses, } from './prompts.js';
|
|
22
22
|
import { shouldIgnorePath } from '../../config/ignore-service.js';
|
|
23
23
|
// ─── Constants ────────────────────────────────────────────────────────
|
|
@@ -123,15 +123,23 @@ export class WikiGenerator {
|
|
|
123
123
|
});
|
|
124
124
|
return callCursorLLM(prompt, cursorConfig, systemPrompt, options);
|
|
125
125
|
}
|
|
126
|
-
if (this.llmConfig.provider === 'claude' ||
|
|
126
|
+
if (this.llmConfig.provider === 'claude' ||
|
|
127
|
+
this.llmConfig.provider === 'codex' ||
|
|
128
|
+
this.llmConfig.provider === 'opencode') {
|
|
127
129
|
const localConfig = resolveLocalCLIConfig({
|
|
128
130
|
model: this.llmConfig.model,
|
|
129
131
|
workingDirectory: this.repoPath,
|
|
130
132
|
requestTimeoutMs: this.llmConfig.requestTimeoutMs,
|
|
131
133
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
if (this.llmConfig.provider === 'claude') {
|
|
135
|
+
return callClaudeLLM(prompt, localConfig, systemPrompt, options);
|
|
136
|
+
}
|
|
137
|
+
if (this.llmConfig.provider === 'codex') {
|
|
138
|
+
return callCodexLLM(prompt, localConfig, systemPrompt, options);
|
|
139
|
+
}
|
|
140
|
+
if (this.llmConfig.provider === 'opencode') {
|
|
141
|
+
return callOpenCodeLLM(prompt, localConfig, systemPrompt, options);
|
|
142
|
+
}
|
|
135
143
|
}
|
|
136
144
|
return callLLM(prompt, this.llmConfig, systemPrompt, options);
|
|
137
145
|
}
|
|
@@ -43,6 +43,9 @@ export declare function initWikiDb(lbugPath: string): Promise<void>;
|
|
|
43
43
|
export declare function closeWikiDb(): Promise<void>;
|
|
44
44
|
/**
|
|
45
45
|
* Get all source files with their exported symbol names and types.
|
|
46
|
+
* Includes top-level exports (File→DEFINES→n) and exported class members
|
|
47
|
+
* (File→DEFINES→Class→HAS_METHOD/HAS_PROPERTY→n) since class members no
|
|
48
|
+
* longer have a direct File→DEFINES edge.
|
|
46
49
|
*/
|
|
47
50
|
export declare function getFilesWithExports(): Promise<FileWithExports[]>;
|
|
48
51
|
/**
|
|
@@ -26,13 +26,21 @@ export async function closeWikiDb() {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Get all source files with their exported symbol names and types.
|
|
29
|
+
* Includes top-level exports (File→DEFINES→n) and exported class members
|
|
30
|
+
* (File→DEFINES→Class→HAS_METHOD/HAS_PROPERTY→n) since class members no
|
|
31
|
+
* longer have a direct File→DEFINES edge.
|
|
29
32
|
*/
|
|
30
33
|
export async function getFilesWithExports() {
|
|
31
34
|
const rows = await executeQuery(REPO_ID, `
|
|
32
35
|
MATCH (f:File)-[:CodeRelation {type: 'DEFINES'}]->(n)
|
|
33
36
|
WHERE n.isExported = true
|
|
34
37
|
RETURN f.filePath AS filePath, n.name AS name, labels(n)[0] AS type
|
|
35
|
-
|
|
38
|
+
UNION
|
|
39
|
+
MATCH (f:File)-[:CodeRelation {type: 'DEFINES'}]->(c)
|
|
40
|
+
-[mr:CodeRelation]->(n)
|
|
41
|
+
WHERE mr.type IN ['HAS_METHOD', 'HAS_PROPERTY'] AND n.isExported = true
|
|
42
|
+
RETURN f.filePath AS filePath, n.name AS name, labels(n)[0] AS type
|
|
43
|
+
ORDER BY filePath
|
|
36
44
|
`);
|
|
37
45
|
const fileMap = new Map();
|
|
38
46
|
for (const row of rows) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Config priority: CLI flags > env vars > defaults
|
|
8
8
|
*/
|
|
9
|
-
export type LLMProvider = 'openai' | 'openrouter' | 'azure' | 'custom' | 'cursor' | 'claude' | 'codex';
|
|
9
|
+
export type LLMProvider = 'openai' | 'openrouter' | 'azure' | 'custom' | 'cursor' | 'claude' | 'codex' | 'opencode';
|
|
10
10
|
export interface LLMConfig {
|
|
11
11
|
apiKey: string;
|
|
12
12
|
baseUrl: string;
|
|
@@ -16,8 +16,13 @@ export async function resolveLLMConfig(overrides) {
|
|
|
16
16
|
? savedConfig.claudeModel
|
|
17
17
|
: savedProvider === 'codex'
|
|
18
18
|
? savedConfig.codexModel
|
|
19
|
-
:
|
|
20
|
-
|
|
19
|
+
: savedProvider === 'opencode'
|
|
20
|
+
? savedConfig.opencodeModel
|
|
21
|
+
: undefined;
|
|
22
|
+
const localProvider = savedProvider === 'cursor' ||
|
|
23
|
+
savedProvider === 'claude' ||
|
|
24
|
+
savedProvider === 'codex' ||
|
|
25
|
+
savedProvider === 'opencode';
|
|
21
26
|
const apiKey = overrides?.apiKey ||
|
|
22
27
|
process.env.GITNEXUS_API_KEY ||
|
|
23
28
|
process.env.OPENAI_API_KEY ||
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* an OpenAI-compatible HTTP API.
|
|
6
6
|
*/
|
|
7
7
|
import type { LLMResponse, CallLLMOptions } from './llm-client.js';
|
|
8
|
-
export type LocalAgentProvider = 'claude' | 'codex';
|
|
8
|
+
export type LocalAgentProvider = 'claude' | 'codex' | 'opencode';
|
|
9
9
|
export interface LocalCLIConfig {
|
|
10
10
|
model?: string;
|
|
11
11
|
workingDirectory?: string;
|
|
@@ -15,3 +15,4 @@ export declare function detectLocalCLI(provider: LocalAgentProvider): string | n
|
|
|
15
15
|
export declare function resolveLocalCLIConfig(overrides?: Partial<LocalCLIConfig>): LocalCLIConfig;
|
|
16
16
|
export declare function callClaudeLLM(prompt: string, config: LocalCLIConfig, systemPrompt?: string, options?: CallLLMOptions): Promise<LLMResponse>;
|
|
17
17
|
export declare function callCodexLLM(prompt: string, config: LocalCLIConfig, systemPrompt?: string, options?: CallLLMOptions): Promise<LLMResponse>;
|
|
18
|
+
export declare function callOpenCodeLLM(prompt: string, config: LocalCLIConfig, systemPrompt?: string, options?: CallLLMOptions): Promise<LLMResponse>;
|
|
@@ -14,6 +14,7 @@ import { logger } from '../logger.js';
|
|
|
14
14
|
const COMMANDS = {
|
|
15
15
|
claude: 'claude',
|
|
16
16
|
codex: 'codex',
|
|
17
|
+
opencode: 'opencode',
|
|
17
18
|
};
|
|
18
19
|
function killChildTree(child) {
|
|
19
20
|
if (process.platform === 'win32' && child.pid !== undefined) {
|
|
@@ -121,6 +122,66 @@ export async function callCodexLLM(prompt, config, systemPrompt, options) {
|
|
|
121
122
|
await fs.rm(outputDir, { recursive: true, force: true }).catch(() => undefined);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
125
|
+
function parseOpenCodeEventStream(output) {
|
|
126
|
+
const lines = output
|
|
127
|
+
.split(/\r?\n/)
|
|
128
|
+
.map((line) => line.trim())
|
|
129
|
+
.filter(Boolean);
|
|
130
|
+
const textParts = [];
|
|
131
|
+
for (const line of lines) {
|
|
132
|
+
let event;
|
|
133
|
+
try {
|
|
134
|
+
event = JSON.parse(line);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (event.type === 'error') {
|
|
140
|
+
const message = event.error?.data?.message ||
|
|
141
|
+
event.error?.name ||
|
|
142
|
+
event.message ||
|
|
143
|
+
event.part?.text ||
|
|
144
|
+
line;
|
|
145
|
+
throw new Error(`OpenCode CLI returned error event: ${message}`);
|
|
146
|
+
}
|
|
147
|
+
if (event.type === 'text' && typeof event.part?.text === 'string') {
|
|
148
|
+
textParts.push(event.part.text);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const content = textParts.join('').trim();
|
|
152
|
+
if (!content) {
|
|
153
|
+
throw new Error('OpenCode CLI returned no text output');
|
|
154
|
+
}
|
|
155
|
+
return content;
|
|
156
|
+
}
|
|
157
|
+
function buildChildEnv(provider) {
|
|
158
|
+
const env = {
|
|
159
|
+
...process.env,
|
|
160
|
+
CI: '1',
|
|
161
|
+
};
|
|
162
|
+
if (provider === 'opencode') {
|
|
163
|
+
delete env.OPENCODE_SERVER_PASSWORD;
|
|
164
|
+
delete env.OPENCODE_SERVER_USERNAME;
|
|
165
|
+
}
|
|
166
|
+
return env;
|
|
167
|
+
}
|
|
168
|
+
export async function callOpenCodeLLM(prompt, config, systemPrompt, options) {
|
|
169
|
+
const commandInfo = getDetectedCommand('opencode');
|
|
170
|
+
if (!commandInfo) {
|
|
171
|
+
throw new Error('OpenCode CLI not found. Install OpenCode CLI and ensure `opencode` is on PATH.');
|
|
172
|
+
}
|
|
173
|
+
const workingDirectory = config.workingDirectory || process.cwd();
|
|
174
|
+
const fullPrompt = systemPrompt ? `${systemPrompt}\n\n---\n\n${prompt}` : prompt;
|
|
175
|
+
// OpenCode does not expose a Codex-style read-only sandbox / no-tools flag,
|
|
176
|
+
// so we rely on its non-interactive permission model and tolerate any
|
|
177
|
+
// non-JSON stdout warnings in the parser.
|
|
178
|
+
const args = ['run', '--format', 'json', '--dir', workingDirectory];
|
|
179
|
+
if (config.model) {
|
|
180
|
+
args.push('--model', config.model);
|
|
181
|
+
}
|
|
182
|
+
const response = await runLocalCLI('opencode', commandInfo, args, config, fullPrompt, options);
|
|
183
|
+
return { content: parseOpenCodeEventStream(response.content) };
|
|
184
|
+
}
|
|
124
185
|
function runLocalCLI(provider, commandInfo, args, config, stdinText, options) {
|
|
125
186
|
const finalArgs = [...commandInfo.argsPrefix, ...args];
|
|
126
187
|
verboseLog(provider, 'Spawning:', commandInfo.command, maskPromptArgs(provider, finalArgs).join(' '));
|
|
@@ -137,10 +198,7 @@ function runLocalCLI(provider, commandInfo, args, config, stdinText, options) {
|
|
|
137
198
|
cwd: config.workingDirectory || process.cwd(),
|
|
138
199
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
139
200
|
windowsHide: true,
|
|
140
|
-
env:
|
|
141
|
-
...process.env,
|
|
142
|
-
CI: '1',
|
|
143
|
-
},
|
|
201
|
+
env: buildChildEnv(provider),
|
|
144
202
|
});
|
|
145
203
|
verboseLog(provider, 'Process spawned with PID:', child.pid);
|
|
146
204
|
let stdout = '';
|
|
@@ -6,10 +6,13 @@ export declare class CompatibleStdioServerTransport implements Transport {
|
|
|
6
6
|
private readonly _stdout;
|
|
7
7
|
private _readBuffer;
|
|
8
8
|
private _started;
|
|
9
|
+
private _closed;
|
|
9
10
|
private _framing;
|
|
10
11
|
onmessage?: (message: JSONRPCMessage) => void;
|
|
11
12
|
onerror?: (error: Error) => void;
|
|
12
13
|
onclose?: () => void;
|
|
14
|
+
/** Stable bound reference so `on`/`off` always use the same function. */
|
|
15
|
+
private readonly _boundClose;
|
|
13
16
|
constructor(_stdin?: NodeJS.ReadableStream, _stdout?: NodeJS.WritableStream);
|
|
14
17
|
private readonly _ondata;
|
|
15
18
|
private readonly _onerror;
|
|
@@ -35,10 +35,13 @@ export class CompatibleStdioServerTransport {
|
|
|
35
35
|
_stdout;
|
|
36
36
|
_readBuffer;
|
|
37
37
|
_started = false;
|
|
38
|
+
_closed = false;
|
|
38
39
|
_framing = null;
|
|
39
40
|
onmessage;
|
|
40
41
|
onerror;
|
|
41
42
|
onclose;
|
|
43
|
+
/** Stable bound reference so `on`/`off` always use the same function. */
|
|
44
|
+
_boundClose = this.close.bind(this);
|
|
42
45
|
constructor(_stdin = process.stdin, _stdout = process.stdout) {
|
|
43
46
|
this._stdin = _stdin;
|
|
44
47
|
this._stdout = _stdout;
|
|
@@ -59,9 +62,23 @@ export class CompatibleStdioServerTransport {
|
|
|
59
62
|
if (this._started) {
|
|
60
63
|
throw new Error('CompatibleStdioServerTransport already started!');
|
|
61
64
|
}
|
|
65
|
+
if (this._closed) {
|
|
66
|
+
throw new Error('CompatibleStdioServerTransport has been permanently closed');
|
|
67
|
+
}
|
|
68
|
+
// If stdin is already closed (parent died before we registered listeners),
|
|
69
|
+
// the 'end'/'close' event was already emitted and will never fire again.
|
|
70
|
+
// Close the transport immediately to avoid orphaned processes.
|
|
71
|
+
if (this._stdin.readableEnded ||
|
|
72
|
+
this._stdin.destroyed) {
|
|
73
|
+
this._started = true;
|
|
74
|
+
await this.close();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
62
77
|
this._started = true;
|
|
63
78
|
this._stdin.on('data', this._ondata);
|
|
64
79
|
this._stdin.on('error', this._onerror);
|
|
80
|
+
this._stdin.on('end', this._boundClose);
|
|
81
|
+
this._stdin.on('close', this._boundClose);
|
|
65
82
|
}
|
|
66
83
|
detectFraming() {
|
|
67
84
|
if (!this._readBuffer || this._readBuffer.length === 0) {
|
|
@@ -162,8 +179,13 @@ export class CompatibleStdioServerTransport {
|
|
|
162
179
|
}
|
|
163
180
|
}
|
|
164
181
|
async close() {
|
|
182
|
+
if (this._closed)
|
|
183
|
+
return;
|
|
184
|
+
this._closed = true;
|
|
165
185
|
this._stdin.off('data', this._ondata);
|
|
166
186
|
this._stdin.off('error', this._onerror);
|
|
187
|
+
this._stdin.off('end', this._boundClose);
|
|
188
|
+
this._stdin.off('close', this._boundClose);
|
|
167
189
|
const remainingDataListeners = this._stdin.listenerCount('data');
|
|
168
190
|
if (remainingDataListeners === 0) {
|
|
169
191
|
this._stdin.pause();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Singleton factory for transformers.js embedding pipeline.
|
|
5
5
|
* For MCP, we only need to compute query embeddings, not batch embed.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import type { FeatureExtractionPipeline } from '@huggingface/transformers';
|
|
8
8
|
/**
|
|
9
9
|
* Initialize the embedding model (lazy, on first search)
|
|
10
10
|
*/
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Singleton factory for transformers.js embedding pipeline.
|
|
5
5
|
* For MCP, we only need to compute query embeddings, not batch embed.
|
|
6
6
|
*/
|
|
7
|
-
import { pipeline, env } from '@huggingface/transformers';
|
|
8
7
|
import { isHttpMode, getHttpDimensions, httpEmbedQuery, } from '../../core/embeddings/http-client.js';
|
|
9
8
|
import { resolveEmbeddingConfig } from '../../core/embeddings/config.js';
|
|
10
9
|
import { applyHfEnvOverrides, isHfDownloadFailure, withHfDownloadRetry, } from '../../core/embeddings/hf-env.js';
|
|
10
|
+
import { getLocalEmbeddingRuntimeBlocker } from '../../core/embeddings/runtime-support.js';
|
|
11
11
|
import { silenceStdout, restoreStdout, realStderrWrite } from '../../core/lbug/pool-adapter.js';
|
|
12
12
|
import { logger } from '../../core/logger.js';
|
|
13
13
|
// Model config
|
|
@@ -23,6 +23,15 @@ export const initEmbedder = async () => {
|
|
|
23
23
|
if (isHttpMode()) {
|
|
24
24
|
throw new Error('initEmbedder() should not be called in HTTP mode.');
|
|
25
25
|
}
|
|
26
|
+
// Fail fast on platforms where the bundled native ONNX Runtime binding is not
|
|
27
|
+
// shipped (macOS Intel, #1515). Must run before any transformers.js /
|
|
28
|
+
// onnxruntime-node import or resolution — otherwise the native module load
|
|
29
|
+
// crashes with a raw "Cannot find module ...onnxruntime_binding.node" that
|
|
30
|
+
// ONNX_WEB_BACKEND=wasm cannot rescue (#1516).
|
|
31
|
+
const runtimeBlocker = getLocalEmbeddingRuntimeBlocker();
|
|
32
|
+
if (runtimeBlocker) {
|
|
33
|
+
throw new Error(runtimeBlocker);
|
|
34
|
+
}
|
|
26
35
|
if (embedderInstance) {
|
|
27
36
|
return embedderInstance;
|
|
28
37
|
}
|
|
@@ -32,6 +41,9 @@ export const initEmbedder = async () => {
|
|
|
32
41
|
isInitializing = true;
|
|
33
42
|
initPromise = (async () => {
|
|
34
43
|
try {
|
|
44
|
+
// Lazy-load transformers.js only after the runtime guard has passed, so
|
|
45
|
+
// unsupported platforms never reach the native ONNX import (#1515).
|
|
46
|
+
const { pipeline, env } = await import('@huggingface/transformers');
|
|
35
47
|
env.allowLocalModels = false;
|
|
36
48
|
// Bridge user-controlled env vars to transformers.js: HF_HOME →
|
|
37
49
|
// env.cacheDir, HF_ENDPOINT → env.remoteHost (#1205). Centralised in
|
|
@@ -74,9 +74,16 @@ interface RepoHandle {
|
|
|
74
74
|
*/
|
|
75
75
|
export declare function resolveWorktreeCwd(repoPath: string, launchCwd: string): string;
|
|
76
76
|
/**
|
|
77
|
-
* Length of the
|
|
77
|
+
* Length of the path-derived suffix appended to a colliding repo id.
|
|
78
78
|
* Exported so tests can pin the suffix shape without re-deriving the
|
|
79
|
-
* literal; see `
|
|
79
|
+
* literal; see `assignRepoId()` and the hashed-id resolution tier (#1658).
|
|
80
|
+
*
|
|
81
|
+
* Note: base64url is an *encoding*, not a hash — it preserves byte order, so
|
|
82
|
+
* two paths that share a long common prefix (sibling clones under one parent)
|
|
83
|
+
* collapse to the same sliced suffix. `assignRepoId()` keeps the legacy
|
|
84
|
+
* base64url suffix only for the first colliding duplicate (id compatibility)
|
|
85
|
+
* and falls back to a content hash of the resolved path on a real collision
|
|
86
|
+
* (#2054).
|
|
80
87
|
*/
|
|
81
88
|
export declare const REPO_ID_HASH_LENGTH = 6;
|
|
82
89
|
export declare class LocalBackend {
|
|
@@ -118,10 +125,25 @@ export declare class LocalBackend {
|
|
|
118
125
|
*/
|
|
119
126
|
private refreshRepos;
|
|
120
127
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
128
|
+
* Assign a collision-free in-memory id for a registered repo.
|
|
129
|
+
*
|
|
130
|
+
* - Unique name → the bare lowercased name.
|
|
131
|
+
* - Duplicate name → a path-derived suffix. The *first* colliding clone keeps
|
|
132
|
+
* the legacy `base64url(path)` suffix so ids generated before #2054 still
|
|
133
|
+
* resolve (the #1658 hashed-id tier). base64url is an encoding, not a hash:
|
|
134
|
+
* it preserves byte order, so sibling clones under one parent (e.g.
|
|
135
|
+
* `.../REPO_2` and `.../REPO_3`) yield identical leading characters and thus
|
|
136
|
+
* the same sliced suffix. Any further collision therefore falls back to a
|
|
137
|
+
* content hash of the *resolved* path (order-insensitive), extended
|
|
138
|
+
* deterministically until unique.
|
|
139
|
+
*
|
|
140
|
+
* `assigned` maps every id handed out in this refresh to its resolved path,
|
|
141
|
+
* so a candidate is "free" when it is unused or already owned by this exact
|
|
142
|
+
* path. This method records its own assignment into `assigned` before
|
|
143
|
+
* returning, so the map-update is the function's invariant, not a caller
|
|
144
|
+
* obligation. A returned id never overwrites a different path's handle (#2054).
|
|
123
145
|
*/
|
|
124
|
-
private
|
|
146
|
+
private assignRepoId;
|
|
125
147
|
/**
|
|
126
148
|
* Resolve which repo to use.
|
|
127
149
|
* - If repoParam is given, match by name or path
|
|
@@ -148,6 +170,16 @@ export declare class LocalBackend {
|
|
|
148
170
|
*/
|
|
149
171
|
private pickRepoHandleForCwd;
|
|
150
172
|
private handleToRegistryEntry;
|
|
173
|
+
/**
|
|
174
|
+
* Ensure the LadybugDB pool is open for the *resolved* repo.
|
|
175
|
+
*
|
|
176
|
+
* Takes the `RepoHandle` the caller resolved — NOT a bare id — and keys the
|
|
177
|
+
* pool (and the init/staleness/reinit maps) by the immutable `lbugPath`. Two
|
|
178
|
+
* things matter for multi-clone correctness: (1) the handle is the one the
|
|
179
|
+
* caller resolved, so a concurrent `refreshRepos` can't substitute a different
|
|
180
|
+
* clone; (2) the pool key is the database path, so distinct clones never share
|
|
181
|
+
* a pool entry even when their name-derived id transiently collides (#2067).
|
|
182
|
+
*/
|
|
151
183
|
private ensureInitialized;
|
|
152
184
|
/**
|
|
153
185
|
* Get context for a specific repo (or the single repo if only one).
|