cgraphx 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.claude-template/FLOW-MAP.md +7 -5
- package/dist/.claude-template/commands/end.md +1 -1
- package/dist/.claude-template/skills/cgraphx-guide/SKILL.md +2 -1
- package/dist/.claude-template/skills/cgraphx-guide/how-to-use.html +4 -2
- package/dist/.claude-template/skills/cgraphx-guide/how-to-use.md +5 -2
- package/dist/.claude-template/skills/iboc-check/SKILL.md +116 -0
- package/dist/.claude-template/skills/iboc-check/filler-prompt.md +75 -0
- package/dist/.claude-template/skills/implementation/SKILL.md +7 -0
- package/dist/.claude-template/skills/init-project-guides/SKILL.md +1 -1
- package/dist/.claude-template/skills/run-api-test/references/db-verification.md +2 -2
- package/dist/.claude-template/skills/subagent-implement/SKILL.md +3 -2
- package/dist/.claude-template/skills/write-api/assets/template-request.bru +3 -3
- package/dist/.claude-template/skills/write-api/references/bru-format.md +6 -6
- package/dist/.claude-template/skills/write-delivery-guide/SKILL.md +97 -0
- package/dist/.claude-template/skills/write-delivery-guide/template-change-type.md +120 -0
- package/dist/.claude-template/skills/write-delivery-guide/template-multi-role-flow.md +148 -0
- package/dist/.claude-template/skills/write-unit-test-code/SKILL.md +23 -6
- package/dist/core/code/engine/cli/analyze-config.js +320 -0
- package/dist/core/code/engine/cli/analyze.js +1086 -0
- package/dist/core/code/engine/cli/cli-message.js +83 -0
- package/dist/core/code/engine/cli/detect-changes-format.js +58 -0
- package/dist/core/code/engine/cli/embedding-dims.js +43 -0
- package/dist/core/code/engine/cli/format-elapsed.js +12 -0
- package/dist/core/code/engine/cli/help-i18n.js +144 -0
- package/dist/core/code/engine/cli/i18n/en.js +110 -0
- package/dist/core/code/engine/cli/i18n/index.js +47 -0
- package/dist/core/code/engine/cli/i18n/resources.js +9 -0
- package/dist/core/code/engine/cli/i18n/zh-CN.js +110 -0
- package/dist/core/code/engine/cli/lazy-action.js +67 -0
- package/dist/core/code/engine/cli/optional-grammars.js +136 -0
- package/dist/core/code/engine/cli/resolve-invocation.js +76 -0
- package/dist/core/code/engine/cli/status.js +156 -0
- package/dist/core/code/engine/cli/tool.js +384 -0
- package/dist/core/code/engine/config/ignore-service.js +511 -0
- package/dist/core/code/engine/config/supported-languages.js +17 -0
- package/dist/core/code/engine/core/analysis-features.js +64 -0
- package/dist/core/code/engine/core/analyzer-identity.js +2171 -0
- package/dist/core/code/engine/core/git-staleness.js +180 -0
- package/dist/core/code/engine/core/graph/graph.js +180 -0
- package/dist/core/code/engine/core/graph/import-cycles.js +106 -0
- package/dist/core/code/engine/core/graph/types.js +2 -0
- package/dist/core/code/engine/core/index-freshness.js +12 -0
- package/dist/core/code/engine/core/ingestion/binding-accumulator.js +341 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/c-cpp.js +168 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/csharp.js +9 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/dart.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/go.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/jvm.js +54 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/php.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/python.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/ruby.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/rust.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/swift.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/typescript-javascript.js +11 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/generic.js +62 -0
- package/dist/core/code/engine/core/ingestion/call-processor.js +503 -0
- package/dist/core/code/engine/core/ingestion/call-routing.js +98 -0
- package/dist/core/code/engine/core/ingestion/call-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/cfg/callee-cell-format.js +45 -0
- package/dist/core/code/engine/core/ingestion/cfg/cfg-builder.js +202 -0
- package/dist/core/code/engine/core/ingestion/cfg/collect.js +81 -0
- package/dist/core/code/engine/core/ingestion/cfg/control-dependence.js +185 -0
- package/dist/core/code/engine/core/ingestion/cfg/control-flow-context.js +130 -0
- package/dist/core/code/engine/core/ingestion/cfg/emit.js +646 -0
- package/dist/core/code/engine/core/ingestion/cfg/post-dominators.js +182 -0
- package/dist/core/code/engine/core/ingestion/cfg/reaching-def-reason-codec.js +139 -0
- package/dist/core/code/engine/core/ingestion/cfg/reaching-defs-graph.js +322 -0
- package/dist/core/code/engine/core/ingestion/cfg/reaching-defs.js +792 -0
- package/dist/core/code/engine/core/ingestion/cfg/synthetic-escape.js +305 -0
- package/dist/core/code/engine/core/ingestion/cfg/traversal-result.js +6 -0
- package/dist/core/code/engine/core/ingestion/cfg/types.js +14 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/c-cpp-harvest.js +545 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/c-cpp.js +590 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/call-site-harvest.js +356 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/csharp-harvest.js +593 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/csharp.js +871 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/dart-harvest.js +874 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/dart.js +840 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/go-harvest.js +625 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/go.js +642 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/java-harvest.js +517 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/java.js +816 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/kotlin-harvest.js +723 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/kotlin.js +813 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/php-harvest.js +630 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/php.js +725 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/python-harvest.js +776 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/python.js +562 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/ruby-harvest.js +591 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/ruby.js +760 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/rust-harvest.js +877 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/rust.js +562 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/scope-tree-harvest.js +120 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/swift-harvest.js +683 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/swift.js +791 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/typescript-harvest.js +1060 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/typescript.js +587 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/c-cpp.js +77 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/csharp.js +24 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/dart.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/go.js +28 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/jvm.js +67 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/php.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/python.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/ruby.js +13 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/rust.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/swift.js +21 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/typescript-javascript.js +31 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/generic.js +144 -0
- package/dist/core/code/engine/core/ingestion/class-types.js +2 -0
- package/dist/core/code/engine/core/ingestion/cluster-enricher.js +174 -0
- package/dist/core/code/engine/core/ingestion/community-processor.js +604 -0
- package/dist/core/code/engine/core/ingestion/constants.js +26 -0
- package/dist/core/code/engine/core/ingestion/cpp-ue-preprocessor.js +263 -0
- package/dist/core/code/engine/core/ingestion/csharp-namespace-gate.js +133 -0
- package/dist/core/code/engine/core/ingestion/di-extractors/index.js +38 -0
- package/dist/core/code/engine/core/ingestion/di-extractors/spring.js +310 -0
- package/dist/core/code/engine/core/ingestion/emit-references.js +244 -0
- package/dist/core/code/engine/core/ingestion/entry-point-scoring.js +201 -0
- package/dist/core/code/engine/core/ingestion/export-detection.js +244 -0
- package/dist/core/code/engine/core/ingestion/field-extractor.js +29 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/c-cpp.js +107 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/csharp.js +124 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/dart.js +99 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/go.js +102 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/helpers.js +198 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/jvm.js +172 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/php.js +67 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/python.js +94 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/ruby.js +79 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/rust.js +55 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/swift.js +93 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/typescript-javascript.js +59 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/generic.js +147 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/typescript.js +266 -0
- package/dist/core/code/engine/core/ingestion/field-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/filesystem-walker.js +136 -0
- package/dist/core/code/engine/core/ingestion/finalize-orchestrator.js +159 -0
- package/dist/core/code/engine/core/ingestion/framework-detection.js +432 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/analysis-features.js +38 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/annotation-arguments.js +234 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/aop-candidates.js +88 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/aop.js +487 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/auto-configuration.js +21 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/bean-candidates.js +189 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/bean-catalog.js +32 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/bean-factories.js +73 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/conditionals.js +323 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/config-bindings.js +119 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/di-metadata.js +385 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/resource-injection.js +96 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/c-cpp.js +17 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/csharp.js +46 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/dart.js +59 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/go.js +30 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/jvm.js +73 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/php.js +19 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/python.js +45 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/ruby.js +20 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/rust.js +58 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/swift.js +94 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/typescript-javascript.js +26 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/csharp.js +128 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/go.js +50 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/jvm.js +112 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/php.js +80 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/python.js +75 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/resolver-factory.js +36 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/ruby.js +20 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/rust.js +79 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/standard.js +180 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/types.js +7 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/utils.js +153 -0
- package/dist/core/code/engine/core/ingestion/import-target-adapter.js +99 -0
- package/dist/core/code/engine/core/ingestion/language-config.js +391 -0
- package/dist/core/code/engine/core/ingestion/language-provider.js +25 -0
- package/dist/core/code/engine/core/ingestion/languages/c/arity-metadata.js +98 -0
- package/dist/core/code/engine/core/ingestion/languages/c/arity.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/c/capture-side-channel.js +69 -0
- package/dist/core/code/engine/core/ingestion/languages/c/captures.js +189 -0
- package/dist/core/code/engine/core/ingestion/languages/c/header-scan.js +58 -0
- package/dist/core/code/engine/core/ingestion/languages/c/import-decomposer.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/c/import-target.js +103 -0
- package/dist/core/code/engine/core/ingestion/languages/c/index.js +33 -0
- package/dist/core/code/engine/core/ingestion/languages/c/interpret.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/c/merge-bindings.js +26 -0
- package/dist/core/code/engine/core/ingestion/languages/c/query.js +210 -0
- package/dist/core/code/engine/core/ingestion/languages/c/scope-resolver.js +112 -0
- package/dist/core/code/engine/core/ingestion/languages/c/simple-hooks.js +24 -0
- package/dist/core/code/engine/core/ingestion/languages/c/static-linkage.js +109 -0
- package/dist/core/code/engine/core/ingestion/languages/c-cpp.js +506 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/adl.js +804 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/arity-metadata.js +258 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/arity.js +37 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/capture-side-channel.js +89 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/captures.js +1975 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/constraint-extractor.js +311 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/constraint-filter.js +210 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/conversion-rank.js +163 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/file-local-linkage.js +327 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/header-scan.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/import-decomposer.js +134 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/import-target.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/index.js +33 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/inline-namespaces.js +379 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/interpret.js +239 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/member-lookup.js +470 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/merge-bindings.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/query.js +763 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/range-bindings.js +230 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/scope-resolver.js +354 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/simple-hooks.js +67 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/two-phase-lookup.js +348 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/type-classifier.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/user-defined-conversions.js +128 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/accessor-unwrap.js +67 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/arity-metadata.js +49 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/arity.js +40 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/captures.js +557 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/import-decomposer.js +96 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/import-target.js +176 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/index.js +95 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/interpret.js +150 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/merge-bindings.js +58 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/namespace-siblings.js +708 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/qualified-type-names.js +62 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/query.js +578 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/receiver-binding.js +142 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/resolution-config.js +18 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/scope-resolver.js +84 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/simple-hooks.js +81 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp.js +204 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/arity-metadata.js +38 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/arity.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/built-ins.js +37 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/cache-stats.js +30 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/captures.js +1096 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/expand-wildcards.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/extension-type-preprocess.js +33 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/import-target.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/index.js +45 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/interpret.js +101 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/merge-bindings.js +42 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/query.js +246 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/receiver-binding.js +90 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/scope-resolver.js +197 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/signature-bindings.js +54 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/simple-hooks.js +61 -0
- package/dist/core/code/engine/core/ingestion/languages/dart.js +138 -0
- package/dist/core/code/engine/core/ingestion/languages/go/arity-metadata.js +71 -0
- package/dist/core/code/engine/core/ingestion/languages/go/arity.js +17 -0
- package/dist/core/code/engine/core/ingestion/languages/go/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/go/captures.js +492 -0
- package/dist/core/code/engine/core/ingestion/languages/go/expand-wildcards.js +97 -0
- package/dist/core/code/engine/core/ingestion/languages/go/generic-type-parameters.js +146 -0
- package/dist/core/code/engine/core/ingestion/languages/go/import-decomposer.js +47 -0
- package/dist/core/code/engine/core/ingestion/languages/go/import-target.js +70 -0
- package/dist/core/code/engine/core/ingestion/languages/go/index.js +39 -0
- package/dist/core/code/engine/core/ingestion/languages/go/interface-impls.js +955 -0
- package/dist/core/code/engine/core/ingestion/languages/go/interpret.js +177 -0
- package/dist/core/code/engine/core/ingestion/languages/go/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/go/method-owners.js +131 -0
- package/dist/core/code/engine/core/ingestion/languages/go/namespace-mirror.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/go/package-clause.js +79 -0
- package/dist/core/code/engine/core/ingestion/languages/go/package-siblings.js +83 -0
- package/dist/core/code/engine/core/ingestion/languages/go/query.js +298 -0
- package/dist/core/code/engine/core/ingestion/languages/go/range-binding.js +127 -0
- package/dist/core/code/engine/core/ingestion/languages/go/receiver-binding.js +24 -0
- package/dist/core/code/engine/core/ingestion/languages/go/scope-resolver.js +75 -0
- package/dist/core/code/engine/core/ingestion/languages/go/simple-hooks.js +31 -0
- package/dist/core/code/engine/core/ingestion/languages/go/type-binding.js +279 -0
- package/dist/core/code/engine/core/ingestion/languages/go.js +160 -0
- package/dist/core/code/engine/core/ingestion/languages/index.js +66 -0
- package/dist/core/code/engine/core/ingestion/languages/java/analysis-features.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/java/arity-metadata.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/java/arity.js +27 -0
- package/dist/core/code/engine/core/ingestion/languages/java/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/java/capture-side-channel.js +123 -0
- package/dist/core/code/engine/core/ingestion/languages/java/captures.js +791 -0
- package/dist/core/code/engine/core/ingestion/languages/java/import-decomposer.js +88 -0
- package/dist/core/code/engine/core/ingestion/languages/java/import-target.js +103 -0
- package/dist/core/code/engine/core/ingestion/languages/java/index.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/java/interpret.js +146 -0
- package/dist/core/code/engine/core/ingestion/languages/java/merge-bindings.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/java/package-facts.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/java/package-siblings.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/java/query.js +319 -0
- package/dist/core/code/engine/core/ingestion/languages/java/receiver-binding.js +98 -0
- package/dist/core/code/engine/core/ingestion/languages/java/scope-resolver.js +213 -0
- package/dist/core/code/engine/core/ingestion/languages/java/simple-hooks.js +39 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-aop.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-bean-metadata.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-conditionals.js +52 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-config-bindings.js +222 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-di.js +165 -0
- package/dist/core/code/engine/core/ingestion/languages/java.js +192 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/arity.js +15 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/captures.js +1122 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/import-target.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/index.js +109 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/interpret.js +45 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/query.js +659 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/scope-resolver.js +78 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/simple-hooks.js +44 -0
- package/dist/core/code/engine/core/ingestion/languages/jvm/package-facts.js +46 -0
- package/dist/core/code/engine/core/ingestion/languages/jvm/package-siblings.js +200 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/arity-metadata.js +23 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/arity.js +18 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/capture-side-channel.js +160 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/captures.js +1262 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/companion-scopes.js +72 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/import-decomposer.js +40 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/import-target.js +135 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/index.js +26 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/interpret.js +75 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/merge-bindings.js +28 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/owners.js +134 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/package-facts.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/package-siblings.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/query.js +243 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/receiver-binding.js +103 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/scope-resolver.js +207 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/simple-hooks.js +42 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-aop.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-bean-metadata.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-conditionals.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-di.js +304 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin.js +189 -0
- package/dist/core/code/engine/core/ingestion/languages/php/arity-metadata.js +66 -0
- package/dist/core/code/engine/core/ingestion/languages/php/arity.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/php/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/php/captures.js +1166 -0
- package/dist/core/code/engine/core/ingestion/languages/php/import-decomposer.js +238 -0
- package/dist/core/code/engine/core/ingestion/languages/php/import-target.js +213 -0
- package/dist/core/code/engine/core/ingestion/languages/php/index.js +85 -0
- package/dist/core/code/engine/core/ingestion/languages/php/interpret.js +256 -0
- package/dist/core/code/engine/core/ingestion/languages/php/merge-bindings.js +50 -0
- package/dist/core/code/engine/core/ingestion/languages/php/namespace-siblings.js +353 -0
- package/dist/core/code/engine/core/ingestion/languages/php/query.js +391 -0
- package/dist/core/code/engine/core/ingestion/languages/php/receiver-binding.js +135 -0
- package/dist/core/code/engine/core/ingestion/languages/php/scope-resolver.js +361 -0
- package/dist/core/code/engine/core/ingestion/languages/php/simple-hooks.js +116 -0
- package/dist/core/code/engine/core/ingestion/languages/php.js +302 -0
- package/dist/core/code/engine/core/ingestion/languages/python/arity-metadata.js +49 -0
- package/dist/core/code/engine/core/ingestion/languages/python/arity.js +41 -0
- package/dist/core/code/engine/core/ingestion/languages/python/cache-stats.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/python/captures.js +299 -0
- package/dist/core/code/engine/core/ingestion/languages/python/depends-references.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/python/import-decomposer.js +115 -0
- package/dist/core/code/engine/core/ingestion/languages/python/import-target.js +440 -0
- package/dist/core/code/engine/core/ingestion/languages/python/index-stats.js +30 -0
- package/dist/core/code/engine/core/ingestion/languages/python/index.js +96 -0
- package/dist/core/code/engine/core/ingestion/languages/python/interpret.js +430 -0
- package/dist/core/code/engine/core/ingestion/languages/python/merge-bindings.js +47 -0
- package/dist/core/code/engine/core/ingestion/languages/python/query.js +323 -0
- package/dist/core/code/engine/core/ingestion/languages/python/receiver-binding.js +310 -0
- package/dist/core/code/engine/core/ingestion/languages/python/scope-resolver.js +80 -0
- package/dist/core/code/engine/core/ingestion/languages/python/simple-hooks.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/python.js +140 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/arity.js +41 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/captures.js +864 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/import-target.js +88 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/index.js +29 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/interpret.js +115 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/query.js +349 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/receiver-binding.js +70 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/scope-resolver.js +263 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/simple-hooks.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby.js +215 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/arity.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/captures.js +304 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/import-decomposer.js +167 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/import-target.js +108 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/index.js +29 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/interpret.js +201 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/method-owners.js +76 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/module-path.js +222 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/qualified-call.js +482 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/query.js +280 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/range-binding.js +687 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/receiver-binding.js +148 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/scope-resolver.js +151 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/simple-hooks.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/rust.js +183 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/arity-metadata.js +44 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/arity.js +45 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/base-type.js +30 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/captures.js +594 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/conditional-directive-preprocess.js +256 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/implicit-imports.js +60 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/import-decomposer.js +87 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/import-target.js +84 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/index.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/interpret.js +93 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/merge-bindings.js +51 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/query.js +226 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/receiver-binding.js +169 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/scope-resolver.js +192 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/sibling-type-bindings.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/signature-bindings.js +69 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/simple-hooks.js +65 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/target-grouping.js +97 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/target-siblings.js +74 -0
- package/dist/core/code/engine/core/ingestion/languages/swift.js +246 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/arity-metadata.js +106 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/arity.js +57 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/array-callback.js +58 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/cache-stats.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/captures.js +956 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/cjs-export-assignment.js +535 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/cjs-module-exports.js +196 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/import-decomposer.js +374 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/import-target.js +65 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/index.js +108 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/interpret.js +344 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/merge-bindings.js +161 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/nuxt-auto-imports.js +325 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/query.js +1328 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/receiver-binding.js +201 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/scope-resolver.js +293 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/simple-hooks.js +139 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript.js +455 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/captures.js +70 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/import-target.js +61 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/index.js +55 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/scope-resolver.js +295 -0
- package/dist/core/code/engine/core/ingestion/languages/vue.js +96 -0
- package/dist/core/code/engine/core/ingestion/local-symbol-pruner.js +68 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/c-cpp.js +387 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/csharp.js +290 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/dart.js +392 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/go.js +179 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/jvm.js +350 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/php.js +306 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/python.js +312 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/ruby.js +289 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/rust.js +198 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/swift.js +286 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/typescript-javascript.js +341 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/generic.js +209 -0
- package/dist/core/code/engine/core/ingestion/method-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/model/field-registry.js +41 -0
- package/dist/core/code/engine/core/ingestion/model/index.js +52 -0
- package/dist/core/code/engine/core/ingestion/model/method-registry.js +138 -0
- package/dist/core/code/engine/core/ingestion/model/owned-members-lookup.js +46 -0
- package/dist/core/code/engine/core/ingestion/model/registration-table.js +234 -0
- package/dist/core/code/engine/core/ingestion/model/resolve.js +183 -0
- package/dist/core/code/engine/core/ingestion/model/scope-resolution-indexes.js +43 -0
- package/dist/core/code/engine/core/ingestion/model/semantic-model.js +179 -0
- package/dist/core/code/engine/core/ingestion/model/symbol-table.js +216 -0
- package/dist/core/code/engine/core/ingestion/model/type-registry.js +84 -0
- package/dist/core/code/engine/core/ingestion/mro-processor.js +709 -0
- package/dist/core/code/engine/core/ingestion/parsing-processor.js +312 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/communities.js +69 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/cross-file.js +71 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/di.js +338 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/http-api-calls.js +312 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/index.js +54 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/mro.js +40 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/orm.js +78 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/parse-impl.js +1286 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/parse.js +41 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/processes.js +193 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/prune-local-symbols.js +29 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/registry.js +52 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/routes.js +409 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/rpc-edges.js +301 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/runner.js +207 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/scan.js +49 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/spring-aop.js +442 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/spring-auto-configuration.js +264 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/spring-config.js +440 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/structure.js +38 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/tools.js +89 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/types.js +40 -0
- package/dist/core/code/engine/core/ingestion/pipeline.js +152 -0
- package/dist/core/code/engine/core/ingestion/process-processor.js +325 -0
- package/dist/core/code/engine/core/ingestion/resolve-references.js +205 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/constant-resolver.js +135 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/django-root-discovery.js +221 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/django.js +428 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/expo.js +39 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/fastapi-router-bindings.js +264 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/laravel.js +501 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/middleware.js +175 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/nextjs.js +81 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/php.js +25 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/python-const-resolver.js +307 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/response-shapes.js +299 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/route-path.js +71 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/spring-shared.js +310 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/spring.js +441 -0
- package/dist/core/code/engine/core/ingestion/scope-extractor-bridge.js +60 -0
- package/dist/core/code/engine/core/ingestion/scope-extractor.js +1373 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/contract/scope-resolver.js +282 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/callee-id-sink.js +72 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/edges.js +194 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/ids.js +472 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/imports-to-edges.js +49 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/method-dispatch.js +43 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +274 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/references-to-edges.js +93 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/callable-value-flow.js +1240 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/compound-receiver.js +1174 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/free-call-fallback.js +873 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/imported-return-types.js +226 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/mro.js +107 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/overload-narrowing.js +441 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/property-dispatch.js +122 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +1720 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/phase.js +395 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/reconcile-ownership.js +208 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/registry.js +49 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/run.js +632 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +112 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/resolution-outcome.js +41 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/scope/namespace-targets.js +81 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/scope/walkers.js +1835 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/unresolved-receivers.js +242 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/utils/definition-id.js +22 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/workspace-index.js +151 -0
- package/dist/core/code/engine/core/ingestion/structure-processor.js +40 -0
- package/dist/core/code/engine/core/ingestion/tree-sitter-queries.js +2244 -0
- package/dist/core/code/engine/core/ingestion/ts-js-hoc-utils.js +115 -0
- package/dist/core/code/engine/core/ingestion/type-env.js +1136 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/c-cpp.js +555 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/csharp.js +570 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/dart.js +372 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/go.js +508 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/jvm.js +875 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/php.js +537 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/python.js +477 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/ruby.js +380 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/rust.js +502 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/shared.js +843 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/swift.js +490 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/types.js +2 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/typescript.js +690 -0
- package/dist/core/code/engine/core/ingestion/utils/ast-helpers.js +1693 -0
- package/dist/core/code/engine/core/ingestion/utils/call-analysis.js +779 -0
- package/dist/core/code/engine/core/ingestion/utils/callable-flow-captures.js +932 -0
- package/dist/core/code/engine/core/ingestion/utils/callable-labels.js +49 -0
- package/dist/core/code/engine/core/ingestion/utils/deferred-resolution-profile.js +151 -0
- package/dist/core/code/engine/core/ingestion/utils/effective-ram.js +67 -0
- package/dist/core/code/engine/core/ingestion/utils/env.js +60 -0
- package/dist/core/code/engine/core/ingestion/utils/event-loop.js +9 -0
- package/dist/core/code/engine/core/ingestion/utils/graph-sort.js +103 -0
- package/dist/core/code/engine/core/ingestion/utils/heap-probe.js +45 -0
- package/dist/core/code/engine/core/ingestion/utils/heritage-marker.js +47 -0
- package/dist/core/code/engine/core/ingestion/utils/line-base.js +24 -0
- package/dist/core/code/engine/core/ingestion/utils/max-file-size.js +59 -0
- package/dist/core/code/engine/core/ingestion/utils/method-props.js +198 -0
- package/dist/core/code/engine/core/ingestion/utils/qualified-name.js +73 -0
- package/dist/core/code/engine/core/ingestion/utils/receiver-chain-captures.js +60 -0
- package/dist/core/code/engine/core/ingestion/utils/receiver-chain-codec.js +188 -0
- package/dist/core/code/engine/core/ingestion/utils/scope-tree-walk.js +36 -0
- package/dist/core/code/engine/core/ingestion/utils/symbol-labels.js +48 -0
- package/dist/core/code/engine/core/ingestion/utils/template-arguments.js +187 -0
- package/dist/core/code/engine/core/ingestion/utils/type-parameters.js +209 -0
- package/dist/core/code/engine/core/ingestion/utils/verbose.js +6 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/c-cpp.js +133 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/csharp.js +66 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/dart.js +111 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/go.js +153 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/jvm.js +145 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/php.js +61 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/python.js +104 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/ruby.js +55 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/rust.js +79 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/swift.js +91 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/typescript-javascript.js +86 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/generic.js +111 -0
- package/dist/core/code/engine/core/ingestion/variable-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/vue-sfc-extractor.js +544 -0
- package/dist/core/code/engine/core/ingestion/workers/callable-id.js +122 -0
- package/dist/core/code/engine/core/ingestion/workers/clone-safety.js +470 -0
- package/dist/core/code/engine/core/ingestion/workers/parse-worker.js +2456 -0
- package/dist/core/code/engine/core/ingestion/workers/post-result.js +90 -0
- package/dist/core/code/engine/core/ingestion/workers/quarantine.js +41 -0
- package/dist/core/code/engine/core/ingestion/workers/result-merge.js +59 -0
- package/dist/core/code/engine/core/ingestion/workers/worker-pool.js +1725 -0
- package/dist/core/code/engine/core/ingestion/workspace-config.js +139 -0
- package/dist/core/code/engine/core/lbug/conn-lock.js +72 -0
- package/dist/core/code/engine/core/lbug/csv-generator.js +710 -0
- package/dist/core/code/engine/core/lbug/cypher-escape.js +24 -0
- package/dist/core/code/engine/core/lbug/extension-load-error.js +339 -0
- package/dist/core/code/engine/core/lbug/extension-loader.js +261 -0
- package/dist/core/code/engine/core/lbug/graph-emit-sink.js +584 -0
- package/dist/core/code/engine/core/lbug/lbug-adapter.js +2703 -0
- package/dist/core/code/engine/core/lbug/lbug-config.js +1029 -0
- package/dist/core/code/engine/core/lbug/native-check.js +435 -0
- package/dist/core/code/engine/core/lbug/pool-adapter.js +973 -0
- package/dist/core/code/engine/core/lbug/query-params.js +25 -0
- package/dist/core/code/engine/core/lbug/query-result-utils.js +31 -0
- package/dist/core/code/engine/core/lbug/rel-pair-routing.js +373 -0
- package/dist/core/code/engine/core/lbug/schema.js +771 -0
- package/dist/core/code/engine/core/lbug/shutdown-helpers.js +40 -0
- package/dist/core/code/engine/core/lbug/sidecar-recovery.js +716 -0
- package/dist/core/code/engine/core/lbug/stdio-capture.js +49 -0
- package/dist/core/code/engine/core/lbug/sync-csv-writer.js +115 -0
- package/dist/core/code/engine/core/lbug/wal-checkpoint-driver.js +215 -0
- package/dist/core/code/engine/core/lbug/wal-driver-state.js +28 -0
- package/dist/core/code/engine/core/logger.js +339 -0
- package/dist/core/code/engine/core/platform/capabilities.js +91 -0
- package/dist/core/code/engine/core/run-analyze.js +1098 -0
- package/dist/core/code/engine/core/tree-sitter/parser-loader.js +281 -0
- package/dist/core/code/engine/core/tree-sitter/safe-parse.js +258 -0
- package/dist/core/code/engine/core/tree-sitter/vendored-grammars.js +64 -0
- package/dist/core/code/engine/lib/utils.js +121 -0
- package/dist/core/code/engine/mcp/core/lbug-adapter.js +27 -0
- package/dist/core/code/engine/mcp/local/aop-metadata.js +230 -0
- package/dist/core/code/engine/mcp/local/bean-metadata.js +49 -0
- package/dist/core/code/engine/mcp/local/limits.js +15 -0
- package/dist/core/code/engine/mcp/local/line-display.js +6 -0
- package/dist/core/code/engine/mcp/local/local-backend.js +4142 -0
- package/dist/core/code/engine/storage/branch-index.js +72 -0
- package/dist/core/code/engine/storage/file-hash.js +95 -0
- package/dist/core/code/engine/storage/fs-atomic.js +34 -0
- package/dist/core/code/engine/storage/git.js +555 -0
- package/dist/core/code/engine/storage/index-lock.js +664 -0
- package/dist/core/code/engine/storage/parse-cache.js +650 -0
- package/dist/core/code/engine/storage/parsedfile-store.js +620 -0
- package/dist/core/code/engine/storage/repo-manager.js +1061 -0
- package/dist/core/code/engine/storage/scope-index-store.js +247 -0
- package/dist/core/code/engine/types/pipeline.js +2 -0
- package/dist/core/code/scripts/install-duckdb-extension.mjs +125 -0
- package/dist/core/code/scripts/resolve-analyze-cmd.cjs +346 -0
- package/dist/core/code/shared/graph/types.js +8 -0
- package/dist/core/code/shared/index.js +105 -0
- package/dist/core/code/shared/integrations/circuit-breaker.js +242 -0
- package/dist/core/code/shared/integrations/resilient-fetch.js +224 -0
- package/dist/core/code/shared/integrations/retry.js +70 -0
- package/dist/core/code/shared/integrations/understand-quickly.js +145 -0
- package/dist/core/code/shared/language-detection.js +162 -0
- package/dist/core/code/shared/languages.js +27 -0
- package/dist/core/code/shared/lbug/schema-constants.js +98 -0
- package/dist/core/code/shared/mro-strategy.js +2 -0
- package/dist/core/code/shared/pipeline.js +5 -0
- package/dist/core/code/shared/scope-resolution/callable-flow-site.js +11 -0
- package/dist/core/code/shared/scope-resolution/def-index.js +53 -0
- package/dist/core/code/shared/scope-resolution/evidence-weights.js +87 -0
- package/dist/core/code/shared/scope-resolution/finalize-algorithm.js +807 -0
- package/dist/core/code/shared/scope-resolution/language-classification.js +46 -0
- package/dist/core/code/shared/scope-resolution/method-dispatch-index.js +100 -0
- package/dist/core/code/shared/scope-resolution/module-scope-index.js +59 -0
- package/dist/core/code/shared/scope-resolution/origin-priority.js +23 -0
- package/dist/core/code/shared/scope-resolution/parsed-file.js +54 -0
- package/dist/core/code/shared/scope-resolution/position-index.js +136 -0
- package/dist/core/code/shared/scope-resolution/qualified-name-index.js +77 -0
- package/dist/core/code/shared/scope-resolution/reference-site.js +24 -0
- package/dist/core/code/shared/scope-resolution/registries/class-registry.js +32 -0
- package/dist/core/code/shared/scope-resolution/registries/context.js +52 -0
- package/dist/core/code/shared/scope-resolution/registries/evidence.js +152 -0
- package/dist/core/code/shared/scope-resolution/registries/field-registry.js +33 -0
- package/dist/core/code/shared/scope-resolution/registries/lookup-core.js +392 -0
- package/dist/core/code/shared/scope-resolution/registries/lookup-qualified.js +58 -0
- package/dist/core/code/shared/scope-resolution/registries/macro-registry.js +34 -0
- package/dist/core/code/shared/scope-resolution/registries/method-registry.js +34 -0
- package/dist/core/code/shared/scope-resolution/registries/tie-breaks.js +63 -0
- package/dist/core/code/shared/scope-resolution/resolve-type-ref.js +128 -0
- package/dist/core/code/shared/scope-resolution/scope-id.js +49 -0
- package/dist/core/code/shared/scope-resolution/scope-tree.js +225 -0
- package/dist/core/code/shared/scope-resolution/symbol-definition.js +12 -0
- package/dist/core/code/shared/scope-resolution/types.js +25 -0
- package/dist/core/code/shared/test-helpers.js +17 -0
- package/dist/core/code/vendor/leiden/index.cjs +355 -0
- package/dist/core/code/vendor/leiden/utils.cjs +419 -0
- package/dist/core/features/scanner.d.ts +2 -0
- package/dist/core/features/scanner.d.ts.map +1 -1
- package/dist/core/features/scanner.js +27 -6
- package/dist/core/features/scanner.js.map +1 -1
- package/dist/core/timeline/cli.d.ts.map +1 -1
- package/dist/core/timeline/cli.js +13 -6
- package/dist/core/timeline/cli.js.map +1 -1
- package/dist/core/timeline/debris.d.ts +20 -0
- package/dist/core/timeline/debris.d.ts.map +1 -0
- package/dist/core/timeline/debris.js +124 -0
- package/dist/core/timeline/debris.js.map +1 -0
- package/dist/core/timeline/hook-runner.d.ts.map +1 -1
- package/dist/core/timeline/hook-runner.js +3 -1
- package/dist/core/timeline/hook-runner.js.map +1 -1
- package/dist/core/timeline/hooks.d.ts.map +1 -1
- package/dist/core/timeline/hooks.js +13 -5
- package/dist/core/timeline/hooks.js.map +1 -1
- package/dist/core/timeline/installer.d.ts +2 -0
- package/dist/core/timeline/installer.d.ts.map +1 -1
- package/dist/core/timeline/installer.js +12 -0
- package/dist/core/timeline/installer.js.map +1 -1
- package/dist/core/timeline/project-root.d.ts +21 -0
- package/dist/core/timeline/project-root.d.ts.map +1 -0
- package/dist/core/timeline/project-root.js +83 -0
- package/dist/core/timeline/project-root.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Per-process circuit breaker.
|
|
4
|
+
*
|
|
5
|
+
* Closed -> Open transition fires after `failureThreshold` consecutive
|
|
6
|
+
* failures. While Open, `check` throws `CircuitOpenError` until
|
|
7
|
+
* `cooldownMs` has elapsed since the breaker tripped. The first call
|
|
8
|
+
* after the cooldown enters Half-Open and consumes the *probe permit*:
|
|
9
|
+
* a recorded success returns to Closed; a recorded failure flips back
|
|
10
|
+
* to Open with a fresh timestamp.
|
|
11
|
+
*
|
|
12
|
+
* Half-open admits exactly one in-flight probe at a time. Concurrent
|
|
13
|
+
* callers attempting `check()` while a probe is outstanding receive
|
|
14
|
+
* `CircuitOpenError` with `retryAfterMs = halfOpenRetryAfterMs` (default
|
|
15
|
+
* 1000ms; configurable). This prevents the recovery-time thundering
|
|
16
|
+
* herd that defeats the breaker's "fail fast" promise.
|
|
17
|
+
*
|
|
18
|
+
* Outcome reporting splits permit-release from state-resolution:
|
|
19
|
+
* - `recordSuccess` — releases the probe permit, resets the failure
|
|
20
|
+
* counter, transitions to Closed. Reserved for true 2xx/3xx outcomes.
|
|
21
|
+
* - `recordFailure` — releases the probe permit, increments the
|
|
22
|
+
* consecutive-failure counter, transitions to Open with a fresh
|
|
23
|
+
* `openedAt` (when called from Half-Open or when the threshold
|
|
24
|
+
* trips from Closed).
|
|
25
|
+
* - `recordNeutral` — releases the probe permit, BUT leaves state and
|
|
26
|
+
* counter untouched. Used for outcomes that are neither evidence of
|
|
27
|
+
* backend health nor evidence of backend failure (caller-driven
|
|
28
|
+
* cancellation, local timeout, terminal 4xx client errors). Critical
|
|
29
|
+
* design point: if `recordNeutral` did not release the permit, a
|
|
30
|
+
* single `TimeoutError` from per-attempt `AbortSignal.timeout` would
|
|
31
|
+
* route through `recordNeutral` and permanently park the breaker in
|
|
32
|
+
* half-open until process restart. Releasing the permit while leaving
|
|
33
|
+
* state half-open keeps the "neutral doesn't claim health" semantic
|
|
34
|
+
* without creating that wedge.
|
|
35
|
+
*
|
|
36
|
+
* Pairing invariant: every successful `check()` MUST be paired with
|
|
37
|
+
* exactly one `record*()` on every code path including throws. Direct
|
|
38
|
+
* consumers should wrap the protected operation in `try/finally`:
|
|
39
|
+
*
|
|
40
|
+
* breaker.check();
|
|
41
|
+
* try {
|
|
42
|
+
* const result = await operation();
|
|
43
|
+
* breaker.recordSuccess();
|
|
44
|
+
* return result;
|
|
45
|
+
* } catch (err) {
|
|
46
|
+
* // classify err and call recordFailure / recordNeutral / etc.
|
|
47
|
+
* throw err;
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* `resilientFetch`'s catch-all on `fetchImpl` already satisfies this
|
|
51
|
+
* for that consumer.
|
|
52
|
+
*
|
|
53
|
+
* Atomicity model: the half-open gate relies on JavaScript event-loop
|
|
54
|
+
* single-threadedness within a synchronous `check()` body. There is no
|
|
55
|
+
* `await` inside `check()`; concurrent callers serialize on microtask
|
|
56
|
+
* order, and exactly one observes `probeInFlight === false`. Do not
|
|
57
|
+
* introduce `await` inside `check()` without revisiting the gate. If
|
|
58
|
+
* this code is ever ported to a runtime with shared-memory threads
|
|
59
|
+
* (Node `worker_threads` with `SharedArrayBuffer`, Web Workers with
|
|
60
|
+
* shared registries), the boolean must become an atomic CAS — Resilience4j
|
|
61
|
+
* and Hystrix use atomic permits *because* they run in JVM thread pools.
|
|
62
|
+
*
|
|
63
|
+
* Runtime-agnostic: depends only on a `now()` clock and standard JS —
|
|
64
|
+
* no Node-only imports. Tests inject `now` to advance the clock
|
|
65
|
+
* deterministically without `vi.useFakeTimers()`.
|
|
66
|
+
*/
|
|
67
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
+
exports.CircuitBreaker = exports.CircuitOpenError = void 0;
|
|
69
|
+
exports.getBreaker = getBreaker;
|
|
70
|
+
exports.__resetBreakerRegistry__ = __resetBreakerRegistry__;
|
|
71
|
+
class CircuitOpenError extends Error {
|
|
72
|
+
name = 'CircuitOpenError';
|
|
73
|
+
/** Approximate wait time before the breaker may transition to Half-Open
|
|
74
|
+
* (or before the in-flight probe is expected to resolve). */
|
|
75
|
+
retryAfterMs;
|
|
76
|
+
constructor(retryAfterMs, key) {
|
|
77
|
+
super(key
|
|
78
|
+
? `Circuit '${key}' is open; retry in ${Math.ceil(retryAfterMs / 1000)}s`
|
|
79
|
+
: `Circuit is open; retry in ${Math.ceil(retryAfterMs / 1000)}s`);
|
|
80
|
+
this.retryAfterMs = retryAfterMs;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.CircuitOpenError = CircuitOpenError;
|
|
84
|
+
class CircuitBreaker {
|
|
85
|
+
failureThreshold;
|
|
86
|
+
cooldownMs;
|
|
87
|
+
halfOpenRetryAfterMs;
|
|
88
|
+
key;
|
|
89
|
+
now;
|
|
90
|
+
state = 'closed';
|
|
91
|
+
consecutiveFailures = 0;
|
|
92
|
+
openedAt = null;
|
|
93
|
+
/**
|
|
94
|
+
* True between a successful `check()` and the next `record*()` call
|
|
95
|
+
* during Half-Open. Gates concurrent callers from stampeding a still-
|
|
96
|
+
* recovering dependency. Boolean rather than counter — single-permit
|
|
97
|
+
* is the conservative end of the Hystrix/Resilience4j spectrum.
|
|
98
|
+
*/
|
|
99
|
+
probeInFlight = false;
|
|
100
|
+
constructor(opts = {}) {
|
|
101
|
+
this.failureThreshold = opts.failureThreshold ?? 3;
|
|
102
|
+
this.cooldownMs = opts.cooldownMs ?? 30_000;
|
|
103
|
+
this.halfOpenRetryAfterMs = opts.halfOpenRetryAfterMs ?? 1_000;
|
|
104
|
+
this.key = opts.key;
|
|
105
|
+
this.now = opts.now ?? (() => Date.now());
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Throw `CircuitOpenError` if the breaker won't admit this call.
|
|
109
|
+
* Otherwise consume the half-open probe permit (if applicable) and
|
|
110
|
+
* return so the caller can attempt the protected work.
|
|
111
|
+
*
|
|
112
|
+
* Three rejection paths:
|
|
113
|
+
* 1. Open and still in cooldown → throws with `retryAfterMs` =
|
|
114
|
+
* remaining cooldown.
|
|
115
|
+
* 2. Open with cooldown elapsed AND a probe is already in flight
|
|
116
|
+
* (race: another caller transitioned to half-open and grabbed
|
|
117
|
+
* the permit on a microtask before us) → throws with
|
|
118
|
+
* `halfOpenRetryAfterMs`.
|
|
119
|
+
* 3. Half-Open with probe in flight → throws with `halfOpenRetryAfterMs`.
|
|
120
|
+
*
|
|
121
|
+
* **Pairing invariant**: every successful return from `check()` MUST
|
|
122
|
+
* be paired with exactly one `recordSuccess` / `recordFailure` /
|
|
123
|
+
* `recordNeutral` on every code path including thrown exceptions.
|
|
124
|
+
* Failing to pair leaves the probe permit consumed forever and
|
|
125
|
+
* wedges the breaker. See file-header JSDoc for the canonical
|
|
126
|
+
* try/finally pattern.
|
|
127
|
+
*/
|
|
128
|
+
check() {
|
|
129
|
+
if (this.state === 'open' && this.openedAt !== null) {
|
|
130
|
+
const elapsed = this.now() - this.openedAt;
|
|
131
|
+
if (elapsed < this.cooldownMs) {
|
|
132
|
+
throw new CircuitOpenError(this.cooldownMs - elapsed, this.key);
|
|
133
|
+
}
|
|
134
|
+
// Cooldown elapsed — transition to Half-Open. The very next
|
|
135
|
+
// `probeInFlight` check below decides whether THIS caller gets
|
|
136
|
+
// the permit or hits the gate.
|
|
137
|
+
this.state = 'half-open';
|
|
138
|
+
}
|
|
139
|
+
if (this.state === 'half-open') {
|
|
140
|
+
if (this.probeInFlight) {
|
|
141
|
+
throw new CircuitOpenError(this.halfOpenRetryAfterMs, this.key);
|
|
142
|
+
}
|
|
143
|
+
this.probeInFlight = true;
|
|
144
|
+
}
|
|
145
|
+
// Closed state falls through silently.
|
|
146
|
+
}
|
|
147
|
+
recordSuccess() {
|
|
148
|
+
this.probeInFlight = false;
|
|
149
|
+
this.consecutiveFailures = 0;
|
|
150
|
+
this.state = 'closed';
|
|
151
|
+
this.openedAt = null;
|
|
152
|
+
}
|
|
153
|
+
recordFailure() {
|
|
154
|
+
this.probeInFlight = false;
|
|
155
|
+
this.consecutiveFailures += 1;
|
|
156
|
+
if (this.state === 'half-open' || this.consecutiveFailures >= this.failureThreshold) {
|
|
157
|
+
this.state = 'open';
|
|
158
|
+
this.openedAt = this.now();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Releases the probe permit BUT leaves state and counter untouched.
|
|
163
|
+
* Use when an attempt produced a response or error that should not
|
|
164
|
+
* influence breaker health in either direction — caller-driven aborts,
|
|
165
|
+
* local AbortSignal timeouts, terminal 4xx client errors.
|
|
166
|
+
*
|
|
167
|
+
* Why permit-release-without-state-resolution: if `recordNeutral` did
|
|
168
|
+
* not clear `probeInFlight`, a single `TimeoutError` from per-attempt
|
|
169
|
+
* `AbortSignal.timeout` (which routes through neutral classification)
|
|
170
|
+
* would permanently park the breaker in half-open. Since timeouts are
|
|
171
|
+
* an *expected* outcome under flaky-dependency conditions, the cited
|
|
172
|
+
* "per-attempt timeout bounds the stuck state" mitigation would itself
|
|
173
|
+
* be the trigger for a permanent wedge. Releasing the permit closes
|
|
174
|
+
* that loop while keeping the "neutral doesn't claim dependency
|
|
175
|
+
* health" semantic.
|
|
176
|
+
*
|
|
177
|
+
* Calling `recordSuccess` for these would erase legitimate prior
|
|
178
|
+
* failure signal; calling `recordFailure` would trip the breaker for
|
|
179
|
+
* outcomes the backend isn't responsible for.
|
|
180
|
+
*/
|
|
181
|
+
recordNeutral() {
|
|
182
|
+
this.probeInFlight = false;
|
|
183
|
+
// State and consecutiveFailures are preserved by design.
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Pure read — no state mutation, no permit accounting. Returns the
|
|
187
|
+
* *would-be* state at the current instant: 'half-open' if the breaker
|
|
188
|
+
* is open with cooldown elapsed (regardless of whether a probe is in
|
|
189
|
+
* flight), 'open' if open and still in cooldown, 'closed' otherwise.
|
|
190
|
+
*
|
|
191
|
+
* Inspection-only; safe to call from tests without consuming a probe
|
|
192
|
+
* permit. The implicit Open -> Half-Open transition that mutates
|
|
193
|
+
* `state` lives in `check()` only.
|
|
194
|
+
*/
|
|
195
|
+
getState() {
|
|
196
|
+
if (this.state === 'open' && this.openedAt !== null) {
|
|
197
|
+
const elapsed = this.now() - this.openedAt;
|
|
198
|
+
if (elapsed >= this.cooldownMs)
|
|
199
|
+
return 'half-open';
|
|
200
|
+
}
|
|
201
|
+
return this.state;
|
|
202
|
+
}
|
|
203
|
+
getConsecutiveFailures() {
|
|
204
|
+
return this.consecutiveFailures;
|
|
205
|
+
}
|
|
206
|
+
/** Inspection-only test accessor for the half-open probe permit. */
|
|
207
|
+
isProbeInFlight() {
|
|
208
|
+
return this.probeInFlight;
|
|
209
|
+
}
|
|
210
|
+
/** Timestamp (ms since epoch) when the breaker last transitioned to Open,
|
|
211
|
+
* or `null` if it's currently Closed. Useful for computing remaining
|
|
212
|
+
* cooldown without consuming a probe permit via `check()`. */
|
|
213
|
+
getOpenedAt() {
|
|
214
|
+
return this.openedAt;
|
|
215
|
+
}
|
|
216
|
+
/** Configured cooldown duration in milliseconds. */
|
|
217
|
+
getCooldownMs() {
|
|
218
|
+
return this.cooldownMs;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.CircuitBreaker = CircuitBreaker;
|
|
222
|
+
// ─── Per-process registry ────────────────────────────────────────────
|
|
223
|
+
//
|
|
224
|
+
// Single shared map keyed on caller-chosen strings. Used by
|
|
225
|
+
// `resilient-fetch.ts` so multiple call sites targeting the same logical
|
|
226
|
+
// endpoint share breaker state. Per-process only — not persisted.
|
|
227
|
+
const registry = new Map();
|
|
228
|
+
function getBreaker(key, opts) {
|
|
229
|
+
let breaker = registry.get(key);
|
|
230
|
+
if (!breaker) {
|
|
231
|
+
breaker = new CircuitBreaker({ ...opts, key });
|
|
232
|
+
registry.set(key, breaker);
|
|
233
|
+
}
|
|
234
|
+
return breaker;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Test-only: clear all registered breakers. Tests must call this in
|
|
238
|
+
* `beforeEach` to prevent breaker state from leaking across test cases.
|
|
239
|
+
*/
|
|
240
|
+
function __resetBreakerRegistry__() {
|
|
241
|
+
registry.clear();
|
|
242
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `resilientFetch` — fetch wrapped in retry + circuit breaker, with
|
|
4
|
+
* GitHub-flavoured retry classification baked in (Retry-After parsing,
|
|
5
|
+
* 401/403/404/422 treated as terminal client errors).
|
|
6
|
+
*
|
|
7
|
+
* Designed for the `gitnexus publish` GitHub `repository_dispatch`
|
|
8
|
+
* call, but the classification rules apply to any GitHub REST endpoint.
|
|
9
|
+
* Runtime-agnostic — no Node-only imports.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ResilientFetchExhaustedError = exports.RETRY_AFTER_CAP_MS = exports.CircuitOpenError = void 0;
|
|
13
|
+
exports.parseRetryAfter = parseRetryAfter;
|
|
14
|
+
exports.isTerminalNetworkError = isTerminalNetworkError;
|
|
15
|
+
exports.classifyOutcome = classifyOutcome;
|
|
16
|
+
exports.resilientFetch = resilientFetch;
|
|
17
|
+
const circuit_breaker_js_1 = require("./circuit-breaker.js");
|
|
18
|
+
Object.defineProperty(exports, "CircuitOpenError", { enumerable: true, get: function () { return circuit_breaker_js_1.CircuitOpenError; } });
|
|
19
|
+
const retry_js_1 = require("./retry.js");
|
|
20
|
+
/** Cap on any single Retry-After wait — protects CLI from a buggy registry. */
|
|
21
|
+
exports.RETRY_AFTER_CAP_MS = 30_000;
|
|
22
|
+
const DEFAULT_RETRY = {
|
|
23
|
+
maxAttempts: 3,
|
|
24
|
+
baseDelayMs: 500,
|
|
25
|
+
capDelayMs: 5_000,
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Parse a `Retry-After` header value into milliseconds.
|
|
29
|
+
* Accepts either a delta-seconds integer (`"30"`) or an HTTP-date.
|
|
30
|
+
* Returns null on parse failure or negative deltas.
|
|
31
|
+
*/
|
|
32
|
+
function parseRetryAfter(value, now = Date.now) {
|
|
33
|
+
if (!value)
|
|
34
|
+
return null;
|
|
35
|
+
const trimmed = value.trim();
|
|
36
|
+
if (trimmed === '')
|
|
37
|
+
return null;
|
|
38
|
+
if (/^[0-9]+$/.test(trimmed)) {
|
|
39
|
+
const seconds = parseInt(trimmed, 10);
|
|
40
|
+
if (Number.isNaN(seconds) || seconds < 0)
|
|
41
|
+
return null;
|
|
42
|
+
return seconds * 1000;
|
|
43
|
+
}
|
|
44
|
+
const target = Date.parse(trimmed);
|
|
45
|
+
if (Number.isNaN(target))
|
|
46
|
+
return null;
|
|
47
|
+
const delta = target - now();
|
|
48
|
+
return delta >= 0 ? delta : 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The network errors `resilientFetch` treats as terminal — never retried, and
|
|
52
|
+
* routed through the breaker's neutral path.
|
|
53
|
+
*
|
|
54
|
+
* Both timer-fired aborts (`AbortSignal.timeout()` → `TimeoutError`) and
|
|
55
|
+
* caller-driven aborts (`AbortController.abort()` → `AbortError`) qualify:
|
|
56
|
+
* retrying against an already-aborted signal would fail again immediately, and
|
|
57
|
+
* neither outcome reflects backend health.
|
|
58
|
+
*
|
|
59
|
+
* Exported because callers that hook into the retry loop (a `fetchImpl` that
|
|
60
|
+
* inspects or re-wraps its own throws) have to agree with {@link
|
|
61
|
+
* classifyOutcome} about which errors are terminal. Sharing this predicate is
|
|
62
|
+
* what makes that agreement structural instead of a hand-copied condition that
|
|
63
|
+
* can drift.
|
|
64
|
+
*/
|
|
65
|
+
function isTerminalNetworkError(err) {
|
|
66
|
+
return err instanceof DOMException && (err.name === 'TimeoutError' || err.name === 'AbortError');
|
|
67
|
+
}
|
|
68
|
+
/** Exported for unit tests. */
|
|
69
|
+
function classifyOutcome(result, now, retryAfterCapMs = exports.RETRY_AFTER_CAP_MS) {
|
|
70
|
+
if (result.kind === 'error') {
|
|
71
|
+
if (isTerminalNetworkError(result.err)) {
|
|
72
|
+
return { kind: 'terminal-network', err: result.err };
|
|
73
|
+
}
|
|
74
|
+
return { kind: 'retryable-network', err: result.err };
|
|
75
|
+
}
|
|
76
|
+
const resp = result.resp;
|
|
77
|
+
if (resp.status >= 200 && resp.status < 400)
|
|
78
|
+
return { kind: 'success', resp };
|
|
79
|
+
if (resp.status === 429) {
|
|
80
|
+
// `resp.headers` is always present on a real `Response`, but tests
|
|
81
|
+
// sometimes stub `fetch` with a plain `{ ok, status }` object. Be
|
|
82
|
+
// defensive — a missing `Retry-After` falls through to exponential
|
|
83
|
+
// backoff, which is the correct behaviour anyway.
|
|
84
|
+
const retryAfterHeader = typeof resp.headers?.get === 'function' ? resp.headers.get('Retry-After') : null;
|
|
85
|
+
const parsed = parseRetryAfter(retryAfterHeader, now);
|
|
86
|
+
return {
|
|
87
|
+
kind: 'retryable-status',
|
|
88
|
+
resp,
|
|
89
|
+
afterMs: parsed !== null ? Math.min(parsed, retryAfterCapMs) : undefined,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (resp.status >= 500)
|
|
93
|
+
return { kind: 'retryable-status', resp, afterMs: undefined };
|
|
94
|
+
return { kind: 'terminal-client', resp };
|
|
95
|
+
}
|
|
96
|
+
const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
97
|
+
function defaultBreakerKey(input) {
|
|
98
|
+
try {
|
|
99
|
+
const url = typeof input === 'string' ? new URL(input) : input;
|
|
100
|
+
return `${url.host}${url.pathname}`;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return String(input);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Final error thrown when retries are exhausted on a 5xx / 429. */
|
|
107
|
+
class ResilientFetchExhaustedError extends Error {
|
|
108
|
+
response;
|
|
109
|
+
name = 'ResilientFetchExhaustedError';
|
|
110
|
+
constructor(response) {
|
|
111
|
+
super(`Request failed after retries (HTTP ${response.status})`);
|
|
112
|
+
this.response = response;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.ResilientFetchExhaustedError = ResilientFetchExhaustedError;
|
|
116
|
+
/**
|
|
117
|
+
* Wrap `fetch` with bounded retries and a per-process circuit breaker.
|
|
118
|
+
*
|
|
119
|
+
* Semantics:
|
|
120
|
+
* - 5xx and 429 responses are retried; 429 honors `Retry-After` (capped).
|
|
121
|
+
* - Network throws are retried unless they are `TimeoutError` DOMExceptions.
|
|
122
|
+
* - Timeouts and 4xx (other than 429) are returned/thrown without retry
|
|
123
|
+
* AND without incrementing the breaker — they reflect caller config
|
|
124
|
+
* or local network state, not registry health.
|
|
125
|
+
* - Each `fetch` call carries the caller-supplied `signal` (e.g. an
|
|
126
|
+
* `AbortSignal.timeout()`) — that timeout bounds each individual
|
|
127
|
+
* attempt, not the whole retry sequence.
|
|
128
|
+
* - When the breaker is open, throws `CircuitOpenError` synchronously
|
|
129
|
+
* without invoking `fetch`.
|
|
130
|
+
* - When retries are exhausted on a 5xx / 429, throws
|
|
131
|
+
* `ResilientFetchExhaustedError` carrying the last response.
|
|
132
|
+
*
|
|
133
|
+
* Cumulative wall-clock budget:
|
|
134
|
+
* maxAttempts × (per-attempt-timeout + capDelayMs)
|
|
135
|
+
* With defaults (3, 500ms base, 5000ms cap) and a typical 15s per-attempt
|
|
136
|
+
* timeout from the caller's signal, worst case is ~3 × (15s + 5s) = 60s.
|
|
137
|
+
* Callers that want a tighter total bound should reduce `maxAttempts` or
|
|
138
|
+
* wrap `resilientFetch` in their own outer `AbortSignal.timeout()`.
|
|
139
|
+
*/
|
|
140
|
+
async function resilientFetch(input, init, opts = {}) {
|
|
141
|
+
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
142
|
+
const now = opts.now ?? (() => Date.now());
|
|
143
|
+
const breaker = opts.breaker ?? (0, circuit_breaker_js_1.getBreaker)(opts.breakerKey ?? defaultBreakerKey(input), opts.breakerOptions);
|
|
144
|
+
const retryConfig = {
|
|
145
|
+
maxAttempts: opts.retry?.maxAttempts ?? DEFAULT_RETRY.maxAttempts,
|
|
146
|
+
baseDelayMs: opts.retry?.baseDelayMs ?? DEFAULT_RETRY.baseDelayMs,
|
|
147
|
+
capDelayMs: opts.retry?.capDelayMs ?? DEFAULT_RETRY.capDelayMs,
|
|
148
|
+
retryAfterCapMs: opts.retry?.retryAfterCapMs ?? exports.RETRY_AFTER_CAP_MS,
|
|
149
|
+
};
|
|
150
|
+
const sleep = opts.retry?.sleep ?? defaultSleep;
|
|
151
|
+
const random = opts.retry?.random ?? Math.random;
|
|
152
|
+
// Fail fast on an open breaker, before invoking fetch.
|
|
153
|
+
breaker.check();
|
|
154
|
+
for (let attempt = 0; attempt < retryConfig.maxAttempts; attempt++) {
|
|
155
|
+
let result;
|
|
156
|
+
try {
|
|
157
|
+
// CodeQL js/server-side-request-forgery — flagged because `input`
|
|
158
|
+
// is caller-supplied. Suppressed: every concrete caller passes
|
|
159
|
+
// either a hardcoded URL constant (UNDERSTAND_QUICKLY_DISPATCH_URL,
|
|
160
|
+
// OpenRouter base URL) or a value derived from configuration
|
|
161
|
+
// (env vars, saved settings, the local backend URL). User-input
|
|
162
|
+
// request fields (e.g. PR title, repo name) never flow into
|
|
163
|
+
// `input`. Validating URL shape here would push false-positive
|
|
164
|
+
// rejection onto every caller — wrong layer for the check.
|
|
165
|
+
// lgtm[js/server-side-request-forgery]
|
|
166
|
+
// codeql[js/server-side-request-forgery]
|
|
167
|
+
const resp = await fetchImpl(input, init);
|
|
168
|
+
result = { kind: 'response', resp };
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
result = { kind: 'error', err };
|
|
172
|
+
}
|
|
173
|
+
const outcome = classifyOutcome(result, now, retryConfig.retryAfterCapMs);
|
|
174
|
+
switch (outcome.kind) {
|
|
175
|
+
case 'success':
|
|
176
|
+
breaker.recordSuccess();
|
|
177
|
+
return outcome.resp;
|
|
178
|
+
case 'terminal-client':
|
|
179
|
+
// 4xx: do not count as breaker failure (the server is healthy
|
|
180
|
+
// and rejecting our request — auth, scope, or routing). But
|
|
181
|
+
// also do NOT call recordSuccess: a 401 sandwiched between
|
|
182
|
+
// 5xx responses would otherwise erase the running outage
|
|
183
|
+
// signal. The breaker's neutral path leaves state untouched.
|
|
184
|
+
breaker.recordNeutral();
|
|
185
|
+
return outcome.resp;
|
|
186
|
+
case 'terminal-network':
|
|
187
|
+
// Either `AbortSignal.timeout()` fired locally OR an external
|
|
188
|
+
// caller cancelled the request via AbortController. The server
|
|
189
|
+
// never had a chance to answer; this reflects the user's
|
|
190
|
+
// network or an explicit cancel, not registry health. Don't
|
|
191
|
+
// punish the breaker AND don't reset its outage signal.
|
|
192
|
+
breaker.recordNeutral();
|
|
193
|
+
throw outcome.err;
|
|
194
|
+
case 'retryable-status':
|
|
195
|
+
if (attempt + 1 >= retryConfig.maxAttempts) {
|
|
196
|
+
breaker.recordFailure();
|
|
197
|
+
throw new ResilientFetchExhaustedError(outcome.resp);
|
|
198
|
+
}
|
|
199
|
+
await sleep((0, retry_js_1.computeBackoffMs)(attempt, retryConfig.baseDelayMs, retryConfig.capDelayMs, outcome.afterMs, random));
|
|
200
|
+
break;
|
|
201
|
+
case 'retryable-network':
|
|
202
|
+
if (attempt + 1 >= retryConfig.maxAttempts) {
|
|
203
|
+
breaker.recordFailure();
|
|
204
|
+
throw outcome.err;
|
|
205
|
+
}
|
|
206
|
+
await sleep((0, retry_js_1.computeBackoffMs)(attempt, retryConfig.baseDelayMs, retryConfig.capDelayMs, undefined, random));
|
|
207
|
+
break;
|
|
208
|
+
default: {
|
|
209
|
+
// Exhaustiveness guard. If a sixth `Outcome` kind is added in
|
|
210
|
+
// future, TypeScript will refuse to assign it to `never` and
|
|
211
|
+
// this line forces the maintainer to add an explicit arm
|
|
212
|
+
// rather than silently fall through to retry/no-retry behaviour.
|
|
213
|
+
const _exhaustive = outcome;
|
|
214
|
+
throw new Error(`resilientFetch: unhandled outcome ${JSON.stringify(_exhaustive)}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Unreachable: every iteration of the loop either returns (success
|
|
219
|
+
// / terminal-client) or throws (terminal-network / retry exhaustion).
|
|
220
|
+
// The throw is here purely so TypeScript's control-flow analysis sees
|
|
221
|
+
// the function never falls off the end without producing `Promise<Response>`.
|
|
222
|
+
/* c8 ignore next 2 */
|
|
223
|
+
throw new Error('resilientFetch: retry loop terminated unexpectedly');
|
|
224
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bounded retry helper with full-jitter exponential backoff.
|
|
4
|
+
*
|
|
5
|
+
* Runtime-agnostic: depends only on `setTimeout`, `Math.random`, and the
|
|
6
|
+
* Promise machinery — no Node-only imports. Safe to consume from CLI,
|
|
7
|
+
* server, or browser callers.
|
|
8
|
+
*
|
|
9
|
+
* Pattern reference: cgraph/src/core/embeddings/http-client.ts. This
|
|
10
|
+
* helper is the upgraded form: classification is caller-supplied (so
|
|
11
|
+
* 4xx-vs-5xx-vs-timeout decisions live with the protocol that knows
|
|
12
|
+
* them), backoff is exponential with full jitter, and an optional
|
|
13
|
+
* `afterMs` lets callers honor `Retry-After` headers.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.computeBackoffMs = computeBackoffMs;
|
|
17
|
+
exports.withRetry = withRetry;
|
|
18
|
+
const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
19
|
+
/**
|
|
20
|
+
* Compute the delay before the next retry attempt.
|
|
21
|
+
*
|
|
22
|
+
* - When the caller specifies `afterMs` (e.g., from `Retry-After`), use
|
|
23
|
+
* `min(afterMs, capDelayMs)` so a misbehaving server can't pin the
|
|
24
|
+
* client for an arbitrarily long wait.
|
|
25
|
+
* - Otherwise compute full-jitter exponential backoff:
|
|
26
|
+
* `random() * min(cap, base * 2^attempt)`. Full jitter (rather than
|
|
27
|
+
* "equal jitter") avoids retry-storm thundering herd, per AWS
|
|
28
|
+
* guidance on backoff strategies.
|
|
29
|
+
*/
|
|
30
|
+
function computeBackoffMs(attempt, baseDelayMs, capDelayMs, afterMs, random) {
|
|
31
|
+
if (afterMs !== undefined) {
|
|
32
|
+
return Math.min(Math.max(0, afterMs), capDelayMs);
|
|
33
|
+
}
|
|
34
|
+
const exponential = baseDelayMs * Math.pow(2, attempt);
|
|
35
|
+
const upper = Math.min(capDelayMs, exponential);
|
|
36
|
+
return Math.floor(random() * upper);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Execute `fn` with bounded retries.
|
|
40
|
+
*
|
|
41
|
+
* The classification of "retryable" is the caller's responsibility — see
|
|
42
|
+
* `resilient-fetch.ts` for the GitHub-dispatch-specific rules. This
|
|
43
|
+
* helper is the mechanical retry loop only.
|
|
44
|
+
*/
|
|
45
|
+
async function withRetry(fn, opts) {
|
|
46
|
+
if (opts.maxAttempts < 1) {
|
|
47
|
+
throw new Error(`withRetry: maxAttempts must be >= 1, got ${opts.maxAttempts}`);
|
|
48
|
+
}
|
|
49
|
+
const sleep = opts.sleep ?? defaultSleep;
|
|
50
|
+
const random = opts.random ?? Math.random;
|
|
51
|
+
let lastError;
|
|
52
|
+
for (let attempt = 0; attempt < opts.maxAttempts; attempt++) {
|
|
53
|
+
try {
|
|
54
|
+
return await fn(attempt);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
lastError = err;
|
|
58
|
+
const decision = opts.isRetryable(err, attempt);
|
|
59
|
+
if (!decision.retry)
|
|
60
|
+
throw err;
|
|
61
|
+
// Don't sleep after the final attempt.
|
|
62
|
+
if (attempt + 1 >= opts.maxAttempts)
|
|
63
|
+
break;
|
|
64
|
+
const delayMs = computeBackoffMs(attempt, opts.baseDelayMs, opts.capDelayMs, decision.afterMs, random);
|
|
65
|
+
if (delayMs > 0)
|
|
66
|
+
await sleep(delayMs);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
throw lastError;
|
|
70
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Understand-Quickly registry integration helpers.
|
|
4
|
+
*
|
|
5
|
+
* Pure, runtime-agnostic logic for opting in to publishing a GitNexus
|
|
6
|
+
* index to the [`looptech-ai/understand-quickly`](https://github.com/looptech-ai/understand-quickly)
|
|
7
|
+
* registry. Lives in `cgraph-shared` so both the Node CLI and any
|
|
8
|
+
* future browser-side surface can construct identical dispatch payloads.
|
|
9
|
+
*
|
|
10
|
+
* Network I/O lives in the CLI command (`cgraph/src/cli/publish.ts`)
|
|
11
|
+
* to keep this module free of Node-only imports — see the comment at
|
|
12
|
+
* the top of `cgraph-shared/src/graph/types.ts`.
|
|
13
|
+
*
|
|
14
|
+
* The protocol contract (single dispatch event, no graph upload) is
|
|
15
|
+
* documented at:
|
|
16
|
+
* https://github.com/looptech-ai/understand-quickly/blob/main/docs/integrations/protocol.md
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.UNDERSTAND_QUICKLY_TOKEN_ENV = exports.UNDERSTAND_QUICKLY_EVENT_TYPE = exports.UNDERSTAND_QUICKLY_DISPATCH_URL = void 0;
|
|
20
|
+
exports.buildUqDispatchPayload = buildUqDispatchPayload;
|
|
21
|
+
exports.isValidOwnerRepo = isValidOwnerRepo;
|
|
22
|
+
exports.stripGitSuffix = stripGitSuffix;
|
|
23
|
+
exports.parseOwnerRepoFromRemote = parseOwnerRepoFromRemote;
|
|
24
|
+
/**
|
|
25
|
+
* URL of the registry repo's repository_dispatch endpoint. Hardcoded
|
|
26
|
+
* because the registry is the canonical home for this integration —
|
|
27
|
+
* users who want a private registry can fork and patch.
|
|
28
|
+
*/
|
|
29
|
+
exports.UNDERSTAND_QUICKLY_DISPATCH_URL = 'https://api.github.com/repos/looptech-ai/understand-quickly/dispatches';
|
|
30
|
+
/**
|
|
31
|
+
* Event type the registry's sync workflow listens for.
|
|
32
|
+
* See `looptech-ai/understand-quickly/.github/workflows/sync.yml`.
|
|
33
|
+
*/
|
|
34
|
+
exports.UNDERSTAND_QUICKLY_EVENT_TYPE = 'sync-entry';
|
|
35
|
+
/** Environment variable that gates the dispatch. */
|
|
36
|
+
exports.UNDERSTAND_QUICKLY_TOKEN_ENV = 'UNDERSTAND_QUICKLY_TOKEN';
|
|
37
|
+
/**
|
|
38
|
+
* Build the JSON body for the `repository_dispatch` ping. Pure — no
|
|
39
|
+
* env reads, no network. Validates that `id` looks like `owner/repo`
|
|
40
|
+
* (one slash, no whitespace, both halves non-empty) so a misconfigured
|
|
41
|
+
* caller fails loudly before the round-trip.
|
|
42
|
+
*/
|
|
43
|
+
function buildUqDispatchPayload(id) {
|
|
44
|
+
if (!isValidOwnerRepo(id)) {
|
|
45
|
+
throw new Error(`[understand-quickly] expected id of the form "owner/repo", got "${id}". ` +
|
|
46
|
+
`The registry uses this string to look up your entry in registry.json — ` +
|
|
47
|
+
`it must match the GitHub owner/repo of the source code, not a local path.`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
event_type: exports.UNDERSTAND_QUICKLY_EVENT_TYPE,
|
|
51
|
+
client_payload: { id },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* `owner/repo` validation. Conservative on purpose: GitHub's actual
|
|
56
|
+
* naming rules are looser, but we want to catch local paths
|
|
57
|
+
* (`/Users/...`), bare slugs (`my-repo`), and accidental whitespace.
|
|
58
|
+
*
|
|
59
|
+
* Matches GitHub's published slug rules:
|
|
60
|
+
* owner: starts with alnum, then alnum/hyphen only, must end with
|
|
61
|
+
* alnum (no trailing hyphen — GitHub rejects this at account
|
|
62
|
+
* creation, so a `my-org-/repo` input would otherwise pass us
|
|
63
|
+
* and 422 from GitHub). No underscore, no dot. Length cap 39.
|
|
64
|
+
* repo: any of alnum/dot/hyphen/underscore. Length cap 100.
|
|
65
|
+
*/
|
|
66
|
+
function isValidOwnerRepo(id) {
|
|
67
|
+
return /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?\/[A-Za-z0-9._-]{1,100}$/.test(id);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Strip a single trailing `.git` (case-insensitive) and any trailing
|
|
71
|
+
* slashes from a URL-ish string. Bounded linear: each character is
|
|
72
|
+
* visited at most twice, no backtracking.
|
|
73
|
+
*
|
|
74
|
+
* Replaces `s.replace(/\.git\/*$/i, '').replace(/\/+$/, '')` which
|
|
75
|
+
* CodeQL's polynomial-regex check (codeql/js/polynomial-redos) flags as
|
|
76
|
+
* a worst-case O(n²) on adversarial input like "////.../x".
|
|
77
|
+
*/
|
|
78
|
+
function stripGitSuffix(input) {
|
|
79
|
+
let end = input.length;
|
|
80
|
+
// Trim trailing '/'.
|
|
81
|
+
while (end > 0 && input.charCodeAt(end - 1) === 0x2f)
|
|
82
|
+
end--;
|
|
83
|
+
// Drop one trailing '.git' (case-insensitive).
|
|
84
|
+
if (end >= 4) {
|
|
85
|
+
const tail = input.slice(end - 4, end).toLowerCase();
|
|
86
|
+
if (tail === '.git')
|
|
87
|
+
end -= 4;
|
|
88
|
+
}
|
|
89
|
+
// Trim trailing '/' that may have sat between '.git' and the rest.
|
|
90
|
+
while (end > 0 && input.charCodeAt(end - 1) === 0x2f)
|
|
91
|
+
end--;
|
|
92
|
+
return input.slice(0, end);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Parse `owner/repo` out of a git remote URL. Mirrors the heuristic in
|
|
96
|
+
* `cgraph/src/storage/git.ts:parseRepoNameFromUrl` but keeps both
|
|
97
|
+
* halves so we can build a registry id. Returns `null` on shapes we
|
|
98
|
+
* don't recognise.
|
|
99
|
+
*
|
|
100
|
+
* Examples:
|
|
101
|
+
* git@github.com:looptech-ai/understand-quickly.git
|
|
102
|
+
* https://github.com/looptech-ai/understand-quickly
|
|
103
|
+
* ssh://git@github.com/looptech-ai/understand-quickly.git
|
|
104
|
+
*/
|
|
105
|
+
function parseOwnerRepoFromRemote(url) {
|
|
106
|
+
if (!url)
|
|
107
|
+
return null;
|
|
108
|
+
const trimmed = url.trim();
|
|
109
|
+
if (!trimmed)
|
|
110
|
+
return null;
|
|
111
|
+
// Strip a trailing `.git` (case-insensitive) and any trailing slashes
|
|
112
|
+
// so https://h/o/r and https://h/o/r.git collapse to the same id.
|
|
113
|
+
// Bounded-linear helper avoids the polynomial-regex CodeQL alert.
|
|
114
|
+
const stripped = stripGitSuffix(trimmed);
|
|
115
|
+
// SCP-form SSH (`git@host:owner/repo`). Capture host so we can reject
|
|
116
|
+
// non-GitHub remotes — a GitLab origin like
|
|
117
|
+
// `https://gitlab.example.com/group/sub/project.git` would otherwise
|
|
118
|
+
// silently dispatch the wrong id (LOW 9).
|
|
119
|
+
const ssh = stripped.match(/^[^@]+@([^:]+):([^/]+)\/([^/]+)$/);
|
|
120
|
+
if (ssh) {
|
|
121
|
+
const host = ssh[1].toLowerCase();
|
|
122
|
+
if (host !== 'github.com' && host !== 'www.github.com')
|
|
123
|
+
return null;
|
|
124
|
+
return `${ssh[2]}/${ssh[3]}`;
|
|
125
|
+
}
|
|
126
|
+
// URL forms (https://, ssh://, git://, file://) — last two path segments.
|
|
127
|
+
const url2 = stripped.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/([^/]+)\/(.+)$/);
|
|
128
|
+
if (url2) {
|
|
129
|
+
// Strip optional `userinfo@` (e.g. `ssh://git@github.com/...`).
|
|
130
|
+
const authority = url2[1];
|
|
131
|
+
const atIdx = authority.lastIndexOf('@');
|
|
132
|
+
const hostAndPort = atIdx >= 0 ? authority.slice(atIdx + 1) : authority;
|
|
133
|
+
// Strip `:port` suffix if present.
|
|
134
|
+
const colonIdx = hostAndPort.indexOf(':');
|
|
135
|
+
const host = (colonIdx >= 0 ? hostAndPort.slice(0, colonIdx) : hostAndPort).toLowerCase();
|
|
136
|
+
if (host !== 'github.com' && host !== 'www.github.com')
|
|
137
|
+
return null;
|
|
138
|
+
const segments = url2[2].split('/').filter(Boolean);
|
|
139
|
+
if (segments.length >= 2) {
|
|
140
|
+
const [owner, repo] = segments.slice(-2);
|
|
141
|
+
return `${owner}/${repo}`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|