@colbymchenry/codegraph 0.9.7 → 0.9.8
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 +111 -24
- package/dist/bin/codegraph.d.ts +25 -0
- package/dist/bin/node-version-check.d.ts +37 -0
- package/dist/bin/uninstall.d.ts +14 -0
- package/dist/context/formatter.d.ts +30 -0
- package/dist/context/index.d.ts +110 -0
- package/dist/db/index.d.ts +101 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/queries.d.ts +344 -0
- package/dist/db/sqlite-adapter.d.ts +46 -0
- package/dist/directory.d.ts +57 -0
- package/dist/errors.d.ts +136 -0
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/grammars.d.ts +100 -0
- package/dist/extraction/index.d.ts +138 -0
- package/dist/extraction/languages/c-cpp.d.ts +4 -0
- package/dist/extraction/languages/csharp.d.ts +3 -0
- package/dist/extraction/languages/dart.d.ts +3 -0
- package/dist/extraction/languages/go.d.ts +3 -0
- package/dist/extraction/languages/index.d.ts +10 -0
- package/dist/extraction/languages/java.d.ts +3 -0
- package/dist/extraction/languages/javascript.d.ts +3 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/pascal.d.ts +3 -0
- package/dist/extraction/languages/php.d.ts +3 -0
- package/dist/extraction/languages/python.d.ts +3 -0
- package/dist/extraction/languages/ruby.d.ts +3 -0
- package/dist/extraction/languages/rust.d.ts +3 -0
- package/dist/extraction/languages/scala.d.ts +3 -0
- package/dist/extraction/languages/swift.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts +3 -0
- package/dist/extraction/liquid-extractor.d.ts +52 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/parse-worker.d.ts +8 -0
- package/dist/extraction/svelte-extractor.d.ts +56 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/dist/extraction/tree-sitter-types.d.ts +193 -0
- package/dist/extraction/tree-sitter.d.ts +291 -0
- package/dist/extraction/vue-extractor.d.ts +36 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/queries.d.ts +106 -0
- package/dist/graph/traversal.d.ts +127 -0
- package/dist/index.d.ts +492 -0
- package/dist/installer/config-writer.d.ts +28 -0
- package/dist/installer/index.d.ts +100 -0
- package/dist/installer/instructions-template.d.ts +18 -0
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/claude.d.ts +56 -0
- package/dist/installer/targets/codex.d.ts +18 -0
- package/dist/installer/targets/cursor.d.ts +35 -0
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/opencode.d.ts +30 -0
- package/dist/installer/targets/registry.d.ts +35 -0
- package/dist/installer/targets/shared.d.ts +77 -0
- package/dist/installer/targets/toml.d.ts +52 -0
- package/dist/installer/targets/types.d.ts +101 -0
- package/dist/mcp/daemon-paths.d.ts +46 -0
- package/dist/mcp/daemon.d.ts +161 -0
- package/dist/mcp/engine.d.ts +105 -0
- package/dist/mcp/index.d.ts +112 -0
- package/dist/mcp/proxy.d.ts +81 -0
- package/dist/mcp/server-instructions.d.ts +19 -0
- package/dist/mcp/session.d.ts +77 -0
- package/dist/mcp/tools.d.ts +423 -0
- package/dist/mcp/transport.d.ts +188 -0
- package/dist/mcp/version.d.ts +19 -0
- package/dist/resolution/callback-synthesizer.d.ts +10 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
- package/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/express.d.ts +8 -0
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/go.d.ts +8 -0
- package/dist/resolution/frameworks/index.d.ts +48 -0
- package/dist/resolution/frameworks/java.d.ts +8 -0
- package/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/python.d.ts +10 -0
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react.d.ts +8 -0
- package/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/dist/resolution/frameworks/rust.d.ts +8 -0
- package/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift.d.ts +10 -0
- package/dist/resolution/frameworks/vue.d.ts +9 -0
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/import-resolver.d.ts +68 -0
- package/dist/resolution/index.d.ts +116 -0
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/name-matcher.d.ts +32 -0
- package/dist/resolution/path-aliases.d.ts +68 -0
- package/dist/resolution/strip-comments.d.ts +27 -0
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/types.d.ts +209 -0
- package/dist/search/query-parser.d.ts +57 -0
- package/dist/search/query-utils.d.ts +53 -0
- package/dist/sync/git-hooks.d.ts +45 -0
- package/dist/sync/index.d.ts +19 -0
- package/dist/sync/watch-policy.d.ts +48 -0
- package/dist/sync/watcher.d.ts +191 -0
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/types.d.ts +369 -0
- package/dist/ui/glyphs.d.ts +42 -0
- package/dist/ui/shimmer-progress.d.ts +11 -0
- package/dist/ui/shimmer-worker.d.ts +2 -0
- package/dist/ui/types.d.ts +17 -0
- package/dist/utils.d.ts +205 -0
- package/npm-sdk.js +75 -0
- package/package.json +18 -7
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drupal Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Supports Drupal 8/9/10/11 (Composer-based projects). Drupal 7 is not supported.
|
|
5
|
+
*
|
|
6
|
+
* ## What this resolver does
|
|
7
|
+
*
|
|
8
|
+
* 1. **Detection** — reads composer.json and checks for any `drupal/*` dependency in
|
|
9
|
+
* `require` or `require-dev`.
|
|
10
|
+
*
|
|
11
|
+
* 2. **Route extraction** — parses `*.routing.yml` files and emits `route` nodes for each
|
|
12
|
+
* Drupal route, with `references` edges to the `_controller`, `_form`, or entity handler
|
|
13
|
+
* class/method.
|
|
14
|
+
*
|
|
15
|
+
* 3. **Hook detection** — scans `.module`, `.install`, `.theme`, and `.inc` files for Drupal
|
|
16
|
+
* hook implementations. Two strategies are used:
|
|
17
|
+
* a. Docblock: `@Implements hook_X()` → precise, no false positives.
|
|
18
|
+
* b. Name pattern: function `{moduleName}_{hookSuffix}()` → catches hooks without
|
|
19
|
+
* docblocks but may produce false positives on helper functions.
|
|
20
|
+
* Detected hooks emit an `UnresolvedRef` from the implementing function node to the
|
|
21
|
+
* canonical `hook_X` name, linking implementations to the hook when `codegraph_callers`
|
|
22
|
+
* is invoked.
|
|
23
|
+
*
|
|
24
|
+
* ## Design decisions (review in future iterations)
|
|
25
|
+
*
|
|
26
|
+
* - Hook graph resolution (v1): hook references are stored as UnresolvedRef pointing to the
|
|
27
|
+
* canonical `hook_X` name. If Drupal core is indexed, these will resolve to core hook
|
|
28
|
+
* definitions. Without core, they remain unresolved but are still searchable via
|
|
29
|
+
* `codegraph_search("form_alter")`. Full hook-node creation (virtual nodes for every hook)
|
|
30
|
+
* is deferred to a future iteration.
|
|
31
|
+
*
|
|
32
|
+
* - Services / plugins (out of scope for v1): `*.services.yml` service definitions and plugin
|
|
33
|
+
* annotations (`@Block`, `@FormElement`, etc.) are not extracted. Add a TODO below when
|
|
34
|
+
* ready to implement.
|
|
35
|
+
*
|
|
36
|
+
* - Twig templates (out of scope for v1): `.twig` files are tracked as file nodes but no
|
|
37
|
+
* symbol extraction is performed (no tree-sitter Twig grammar). Implement when a Twig
|
|
38
|
+
* grammar WASM is available.
|
|
39
|
+
*
|
|
40
|
+
* ## TODOs for future iterations
|
|
41
|
+
*
|
|
42
|
+
* - TODO: Extract service definitions from `*.services.yml` files (class → service-id edges).
|
|
43
|
+
* - TODO: Extract plugin annotations (`@Block`, `@FormElement`, `@Field`, etc.) from PHP
|
|
44
|
+
* docblocks and emit plugin nodes with references to the annotated class.
|
|
45
|
+
* - TODO: Add Twig symbol extraction when a tree-sitter Twig grammar becomes available.
|
|
46
|
+
* - TODO: Improve hook resolution: create virtual `hook_*` nodes so `codegraph_callers`
|
|
47
|
+
* returns all implementations even when Drupal core is not indexed.
|
|
48
|
+
*/
|
|
49
|
+
import { FrameworkResolver } from '../types';
|
|
50
|
+
export declare const drupalResolver: FrameworkResolver;
|
|
51
|
+
//# sourceMappingURL=drupal.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework Resolver Registry
|
|
3
|
+
*
|
|
4
|
+
* Manages framework-specific resolvers.
|
|
5
|
+
*/
|
|
6
|
+
import { FrameworkResolver, ResolutionContext } from '../types';
|
|
7
|
+
import type { Language } from '../../types';
|
|
8
|
+
/**
|
|
9
|
+
* Get all framework resolvers
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAllFrameworkResolvers(): FrameworkResolver[];
|
|
12
|
+
/**
|
|
13
|
+
* Get a resolver by name
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFrameworkResolver(name: string): FrameworkResolver | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Detect which frameworks are used in a project
|
|
18
|
+
*/
|
|
19
|
+
export declare function detectFrameworks(context: ResolutionContext): FrameworkResolver[];
|
|
20
|
+
/**
|
|
21
|
+
* Filter a list of detected frameworks down to ones that apply to a given language.
|
|
22
|
+
* Frameworks without an explicit `languages` list are treated as universal.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getApplicableFrameworks(detected: FrameworkResolver[], language: Language): FrameworkResolver[];
|
|
25
|
+
/**
|
|
26
|
+
* Register a custom framework resolver
|
|
27
|
+
*/
|
|
28
|
+
export declare function registerFrameworkResolver(resolver: FrameworkResolver): void;
|
|
29
|
+
export { drupalResolver } from './drupal';
|
|
30
|
+
export { laravelResolver, FACADE_MAPPINGS } from './laravel';
|
|
31
|
+
export { expressResolver } from './express';
|
|
32
|
+
export { nestjsResolver } from './nestjs';
|
|
33
|
+
export { reactResolver } from './react';
|
|
34
|
+
export { svelteResolver } from './svelte';
|
|
35
|
+
export { vueResolver } from './vue';
|
|
36
|
+
export { djangoResolver, flaskResolver, fastapiResolver } from './python';
|
|
37
|
+
export { railsResolver } from './ruby';
|
|
38
|
+
export { springResolver } from './java';
|
|
39
|
+
export { playResolver } from './play';
|
|
40
|
+
export { goResolver } from './go';
|
|
41
|
+
export { rustResolver } from './rust';
|
|
42
|
+
export { aspnetResolver } from './csharp';
|
|
43
|
+
export { swiftUIResolver, uikitResolver, vaporResolver } from './swift';
|
|
44
|
+
export { swiftObjcBridgeResolver } from './swift-objc';
|
|
45
|
+
export { reactNativeBridgeResolver } from './react-native';
|
|
46
|
+
export { expoModulesResolver } from './expo-modules';
|
|
47
|
+
export { fabricViewResolver } from './fabric';
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Laravel Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles Laravel-specific patterns for reference resolution.
|
|
5
|
+
*/
|
|
6
|
+
import { FrameworkResolver } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Laravel facade mappings to underlying classes
|
|
9
|
+
* Exported for potential use in facade resolution
|
|
10
|
+
*/
|
|
11
|
+
export declare const FACADE_MAPPINGS: Record<string, string>;
|
|
12
|
+
export declare const laravelResolver: FrameworkResolver;
|
|
13
|
+
//# sourceMappingURL=laravel.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NestJS Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles NestJS decorator-based routing across its transport layers:
|
|
5
|
+
* - HTTP: @Controller(prefix) + @Get/@Post/@Put/@Patch/@Delete/@Head/@Options/@All
|
|
6
|
+
* - GraphQL: @Resolver + @Query/@Mutation/@Subscription
|
|
7
|
+
* - Microservices: @MessagePattern / @EventPattern
|
|
8
|
+
* - WebSockets: @WebSocketGateway(namespace) + @SubscribeMessage(event)
|
|
9
|
+
*
|
|
10
|
+
* Like the other framework extractors this is regex-over-source (comment-
|
|
11
|
+
* stripped), not AST traversal. NestJS differs from Spring/ASP.NET in two ways
|
|
12
|
+
* that this resolver has to account for:
|
|
13
|
+
*
|
|
14
|
+
* 1. An HTTP route's path is split across TWO decorators — the class-level
|
|
15
|
+
* `@Controller` prefix and the method-level `@Get`/`@Post` path — and both
|
|
16
|
+
* are frequently empty (`@Controller()`, `@Get()`). We pair each method
|
|
17
|
+
* decorator with its enclosing class and join the two paths.
|
|
18
|
+
*
|
|
19
|
+
* 2. `@Query()` is overloaded: it's a GraphQL *method* decorator (from
|
|
20
|
+
* `@nestjs/graphql`) AND a REST *parameter* decorator (from
|
|
21
|
+
* `@nestjs/common`). We only treat it as GraphQL when it sits inside an
|
|
22
|
+
* `@Resolver` class, which is what disambiguates the two.
|
|
23
|
+
*/
|
|
24
|
+
import { FrameworkResolver } from '../types';
|
|
25
|
+
export declare const nestjsResolver: FrameworkResolver;
|
|
26
|
+
//# sourceMappingURL=nestjs.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Play Framework (Scala/Java) resolver.
|
|
3
|
+
*
|
|
4
|
+
* Play declares HTTP routes in a dedicated `conf/routes` file (and included
|
|
5
|
+
* `conf/*.routes`), Rails-style:
|
|
6
|
+
*
|
|
7
|
+
* GET /computers controllers.Application.list(p: Int ?= 0)
|
|
8
|
+
* POST /computers controllers.Application.save
|
|
9
|
+
* GET /assets/*file controllers.Assets.versioned(path = "/public", file: Asset)
|
|
10
|
+
*
|
|
11
|
+
* The file is extensionless, so the file walk only indexes it because
|
|
12
|
+
* `isPlayRoutesFile` (grammars.ts) opts it in; it's processed through the
|
|
13
|
+
* no-grammar path and this resolver extracts the routes. Each route references
|
|
14
|
+
* its handler as `Controller.method` (the package prefix is dropped), resolved
|
|
15
|
+
* to the action method in the controller class.
|
|
16
|
+
*/
|
|
17
|
+
import { FrameworkResolver } from '../types';
|
|
18
|
+
export declare const playResolver: FrameworkResolver;
|
|
19
|
+
//# sourceMappingURL=play.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles Django, Flask, and FastAPI patterns.
|
|
5
|
+
*/
|
|
6
|
+
import { FrameworkResolver } from '../types';
|
|
7
|
+
export declare const djangoResolver: FrameworkResolver;
|
|
8
|
+
export declare const flaskResolver: FrameworkResolver;
|
|
9
|
+
export declare const fastapiResolver: FrameworkResolver;
|
|
10
|
+
//# sourceMappingURL=python.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte / SvelteKit Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles Svelte component references, Svelte 5 runes,
|
|
5
|
+
* store auto-subscriptions, and SvelteKit route/module patterns.
|
|
6
|
+
*/
|
|
7
|
+
import { FrameworkResolver } from '../types';
|
|
8
|
+
export declare const svelteResolver: FrameworkResolver;
|
|
9
|
+
//# sourceMappingURL=svelte.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift ↔ Objective-C bridge resolver.
|
|
3
|
+
*
|
|
4
|
+
* Closes the cross-language flow gap in mixed iOS codebases. The pure
|
|
5
|
+
* bridging name math lives in `../swift-objc-bridge.ts`; this file wires
|
|
6
|
+
* it into the resolution pipeline.
|
|
7
|
+
*
|
|
8
|
+
* **Two directions to close:**
|
|
9
|
+
*
|
|
10
|
+
* 1. **Swift call → ObjC method** — A Swift caller writes
|
|
11
|
+
* `imageDownloader.download(url:completion:)`. Tree-sitter-swift parses
|
|
12
|
+
* this as a call_expression whose callee identifier is `download`
|
|
13
|
+
* (parameter labels live in the argument list, not the callee). The
|
|
14
|
+
* name-matcher tries to find any node named `download` and fails (no
|
|
15
|
+
* Swift method by that name in this project; the ObjC implementation is
|
|
16
|
+
* `-downloadURL:completion:`). We catch it here: from the bare Swift
|
|
17
|
+
* name `download`, look up ObjC methods whose bridged Swift base name
|
|
18
|
+
* would be `download` (using `swiftBaseNamesForObjcSelector`'s reverse
|
|
19
|
+
* map, precomputed once per session).
|
|
20
|
+
*
|
|
21
|
+
* 2. **ObjC call → Swift method** — An ObjC caller writes
|
|
22
|
+
* `[swiftThing fooWithBar:42]`. Tree-sitter-objc parses this as a
|
|
23
|
+
* message_expression with selector `fooWithBar:` (after the multi-
|
|
24
|
+
* keyword fix in this branch). The name-matcher tries to find a node
|
|
25
|
+
* named `fooWithBar:` — no Swift node has colons in its name, so it
|
|
26
|
+
* fails. We catch it: from the ObjC selector, derive candidate Swift
|
|
27
|
+
* base names (`['fooWithBar', 'foo']`), and look up Swift methods
|
|
28
|
+
* named those.
|
|
29
|
+
*
|
|
30
|
+
* **Provenance:** every edge produced here is recorded as a framework-
|
|
31
|
+
* resolved reference (`resolvedBy: 'framework'`) with `confidence: 0.7`
|
|
32
|
+
* (matches the django ORM dynamic-dispatch precedent — not exact, but
|
|
33
|
+
* deterministic from the bridging rule).
|
|
34
|
+
*/
|
|
35
|
+
import { FrameworkResolver } from '../types';
|
|
36
|
+
export declare const swiftObjcBridgeResolver: FrameworkResolver;
|
|
37
|
+
//# sourceMappingURL=swift-objc.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles SwiftUI, UIKit, and Vapor (server-side Swift) patterns.
|
|
5
|
+
*/
|
|
6
|
+
import { FrameworkResolver } from '../types';
|
|
7
|
+
export declare const swiftUIResolver: FrameworkResolver;
|
|
8
|
+
export declare const uikitResolver: FrameworkResolver;
|
|
9
|
+
export declare const vaporResolver: FrameworkResolver;
|
|
10
|
+
//# sourceMappingURL=swift.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue / Nuxt Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles Vue component references, compiler macros (defineProps, etc.),
|
|
5
|
+
* Nuxt auto-imports, and Nuxt file-based routing patterns.
|
|
6
|
+
*/
|
|
7
|
+
import { FrameworkResolver } from '../types';
|
|
8
|
+
export declare const vueResolver: FrameworkResolver;
|
|
9
|
+
//# sourceMappingURL=vue.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go module path detection.
|
|
3
|
+
*
|
|
4
|
+
* A Go monorepo's cross-package calls (`pkga.FuncX(...)`) only resolve when
|
|
5
|
+
* the resolver knows the project's module path (the `module ...` directive
|
|
6
|
+
* in `go.mod`). Without it, `isExternalImport` treats every in-module import
|
|
7
|
+
* — `github.com/example/myproject/pkga` — as a third-party package, so
|
|
8
|
+
* resolution falls through to name-matching with path proximity and returns
|
|
9
|
+
* a tiny fraction of the real call sites. See issue #388.
|
|
10
|
+
*/
|
|
11
|
+
export interface GoModule {
|
|
12
|
+
/** The module path declared in `go.mod`, e.g. `github.com/example/myproject` */
|
|
13
|
+
modulePath: string;
|
|
14
|
+
/** Absolute path to the directory containing the `go.mod` file. */
|
|
15
|
+
rootDir: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Read the `go.mod` file at the project root and extract the module path.
|
|
19
|
+
* Returns `null` if no `go.mod` exists or it has no `module` directive.
|
|
20
|
+
*
|
|
21
|
+
* Limitation: only the project-root `go.mod` is read. Nested `go.mod` files
|
|
22
|
+
* (Go workspaces, monorepos with multiple modules) are not yet resolved —
|
|
23
|
+
* a follow-up if a real repro shows up.
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadGoModule(projectRoot: string): GoModule | null;
|
|
26
|
+
//# sourceMappingURL=go-module.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import Resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves import paths to actual files and symbols.
|
|
5
|
+
*/
|
|
6
|
+
import { Language } from '../types';
|
|
7
|
+
import { UnresolvedRef, ResolvedRef, ResolutionContext, ImportMapping, ReExport } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Resolve an import path to an actual file
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveImportPath(importPath: string, fromFile: string, language: Language, context: ResolutionContext): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Clear the C/C++ include directory cache (call between indexing runs)
|
|
14
|
+
*/
|
|
15
|
+
export declare function clearCppIncludeDirCache(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Discover C/C++ include search directories for a project.
|
|
18
|
+
*
|
|
19
|
+
* Strategy:
|
|
20
|
+
* 1. Look for compile_commands.json (Clang compilation database) in the
|
|
21
|
+
* project root and common build subdirectories. Parse -I and -isystem
|
|
22
|
+
* flags from compiler commands.
|
|
23
|
+
* 2. If no compilation database is found, probe for common convention
|
|
24
|
+
* directories (include/, src/, lib/, api/) and top-level directories
|
|
25
|
+
* containing .h/.hpp files.
|
|
26
|
+
*
|
|
27
|
+
* Returns paths relative to projectRoot.
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadCppIncludeDirs(projectRoot: string): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Extract import mappings from a file
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractImportMappings(_filePath: string, content: string, language: Language): ImportMapping[];
|
|
34
|
+
/**
|
|
35
|
+
* Clear the import mapping cache (call between indexing runs)
|
|
36
|
+
*/
|
|
37
|
+
export declare function clearImportMappingCache(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Extract JS/TS re-export declarations from `content`.
|
|
40
|
+
*
|
|
41
|
+
* Recognised forms:
|
|
42
|
+
* export { foo } from './a';
|
|
43
|
+
* export { foo as bar } from './a';
|
|
44
|
+
* export * from './a';
|
|
45
|
+
* export * as ns from './a'; (treated as wildcard for chasing)
|
|
46
|
+
* export { default as Foo } from './a';
|
|
47
|
+
*
|
|
48
|
+
* The walker intentionally stays regex-based — the import-resolver
|
|
49
|
+
* elsewhere in this file already chooses regex over a fresh
|
|
50
|
+
* tree-sitter pass, and this function shares that trade-off. Errors
|
|
51
|
+
* fall through silently; resolution simply skips the broken file.
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractReExports(content: string, language: Language): ReExport[];
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a reference using import mappings
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* JVM (Java / Kotlin) imports use fully-qualified names (`import
|
|
59
|
+
* com.example.foo.Bar`) decoupled from filenames, so the JS/Python
|
|
60
|
+
* style filesystem path lookup misses them whenever the file isn't
|
|
61
|
+
* named after its primary symbol (Kotlin `Utils.kt` exporting `Bar`,
|
|
62
|
+
* top-level fns, extension fns). Resolve them through the
|
|
63
|
+
* `qualifiedName` index instead — populated by the package_header /
|
|
64
|
+
* package_declaration namespace wrappers in the extractor.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveJvmImport(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
67
|
+
export declare function resolveViaImport(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
68
|
+
//# sourceMappingURL=import-resolver.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference Resolution Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* Coordinates all reference resolution strategies.
|
|
5
|
+
*/
|
|
6
|
+
import { UnresolvedReference, Edge } from '../types';
|
|
7
|
+
import { QueryBuilder } from '../db/queries';
|
|
8
|
+
import { UnresolvedRef, ResolvedRef, ResolutionResult } from './types';
|
|
9
|
+
export * from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Reference Resolver
|
|
12
|
+
*
|
|
13
|
+
* Orchestrates reference resolution using multiple strategies.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ReferenceResolver {
|
|
16
|
+
private projectRoot;
|
|
17
|
+
private queries;
|
|
18
|
+
private context;
|
|
19
|
+
private frameworks;
|
|
20
|
+
private nodeCache;
|
|
21
|
+
private fileCache;
|
|
22
|
+
private importMappingCache;
|
|
23
|
+
private reExportCache;
|
|
24
|
+
private nameCache;
|
|
25
|
+
private lowerNameCache;
|
|
26
|
+
private qualifiedNameCache;
|
|
27
|
+
private knownNames;
|
|
28
|
+
private knownFiles;
|
|
29
|
+
private cachesWarmed;
|
|
30
|
+
private projectAliases;
|
|
31
|
+
private goModule;
|
|
32
|
+
constructor(projectRoot: string, queries: QueryBuilder);
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the resolver (detect frameworks, etc.)
|
|
35
|
+
*/
|
|
36
|
+
initialize(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Run each framework resolver's cross-file finalization pass and persist
|
|
39
|
+
* the returned node updates. Idempotent — safe to call after every indexAll
|
|
40
|
+
* and every incremental sync. Returns the number of nodes updated.
|
|
41
|
+
*
|
|
42
|
+
* Caches are cleared before/after so the post-extract pass sees fresh DB
|
|
43
|
+
* state and downstream queries see the updated names.
|
|
44
|
+
*/
|
|
45
|
+
runPostExtract(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Pre-build lightweight caches for resolution.
|
|
48
|
+
* Node lookups are now handled by indexed SQLite queries instead of
|
|
49
|
+
* loading all nodes into memory (which caused OOM on large codebases).
|
|
50
|
+
* We cache the set of known symbol names for fast pre-filtering.
|
|
51
|
+
*/
|
|
52
|
+
warmCaches(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Clear internal caches
|
|
55
|
+
*/
|
|
56
|
+
clearCaches(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Create the resolution context
|
|
59
|
+
*/
|
|
60
|
+
private createContext;
|
|
61
|
+
/**
|
|
62
|
+
* Resolve all unresolved references
|
|
63
|
+
*/
|
|
64
|
+
resolveAll(unresolvedRefs: UnresolvedReference[], onProgress?: (current: number, total: number) => void): ResolutionResult;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a reference name has any possible match in the codebase.
|
|
67
|
+
* Uses the pre-built knownNames set to skip expensive resolution
|
|
68
|
+
* for names that definitely don't exist as symbols.
|
|
69
|
+
*/
|
|
70
|
+
private hasAnyPossibleMatch;
|
|
71
|
+
/**
|
|
72
|
+
* Does `ref.referenceName` match an import declared in its containing
|
|
73
|
+
* file? Used as a pre-filter escape so re-export chain resolution
|
|
74
|
+
* still gets a chance when the name has no project-wide declaration.
|
|
75
|
+
*/
|
|
76
|
+
private matchesAnyImport;
|
|
77
|
+
/**
|
|
78
|
+
* Resolve a single reference
|
|
79
|
+
*/
|
|
80
|
+
resolveOne(ref: UnresolvedRef): ResolvedRef | null;
|
|
81
|
+
/**
|
|
82
|
+
* Create edges from resolved references
|
|
83
|
+
*/
|
|
84
|
+
createEdges(resolved: ResolvedRef[]): Edge[];
|
|
85
|
+
/**
|
|
86
|
+
* Resolve and persist edges to database
|
|
87
|
+
*/
|
|
88
|
+
resolveAndPersist(unresolvedRefs: UnresolvedReference[], onProgress?: (current: number, total: number) => void): ResolutionResult;
|
|
89
|
+
/**
|
|
90
|
+
* Resolve and persist in batches to keep memory bounded.
|
|
91
|
+
* Processes unresolved references in chunks, persisting edges and cleaning
|
|
92
|
+
* up resolved refs after each batch to avoid accumulating large arrays.
|
|
93
|
+
*/
|
|
94
|
+
resolveAndPersistBatched(onProgress?: (current: number, total: number) => void, batchSize?: number): Promise<ResolutionResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Get detected frameworks
|
|
97
|
+
*/
|
|
98
|
+
getDetectedFrameworks(): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Check if reference is to a built-in or external symbol
|
|
101
|
+
*/
|
|
102
|
+
private isBuiltInOrExternal;
|
|
103
|
+
/**
|
|
104
|
+
* Get file path from node ID
|
|
105
|
+
*/
|
|
106
|
+
private getFilePathFromNodeId;
|
|
107
|
+
/**
|
|
108
|
+
* Get language from node ID
|
|
109
|
+
*/
|
|
110
|
+
private getLanguageFromNodeId;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a reference resolver instance
|
|
114
|
+
*/
|
|
115
|
+
export declare function createResolver(projectRoot: string, queries: QueryBuilder): ReferenceResolver;
|
|
116
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple LRU cache backed by JavaScript's insertion-ordered Map.
|
|
3
|
+
*
|
|
4
|
+
* Used by ReferenceResolver to bound the per-resolver caches that
|
|
5
|
+
* previously grew without limit and OOM'd on large codebases (20k+
|
|
6
|
+
* files). Each cache is sized independently — see `index.ts` for
|
|
7
|
+
* the chosen limits per cache type.
|
|
8
|
+
*
|
|
9
|
+
* Eviction is plain LRU: on `set`, if the cache is full, the
|
|
10
|
+
* least-recently-used entry (the first one in iteration order) is
|
|
11
|
+
* evicted. Touching via `get` moves the entry to the most-recently-used
|
|
12
|
+
* position so hot keys survive eviction passes.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LRUCache<K, V> {
|
|
15
|
+
private readonly max;
|
|
16
|
+
private readonly store;
|
|
17
|
+
constructor(max: number);
|
|
18
|
+
get size(): number;
|
|
19
|
+
get(key: K): V | undefined;
|
|
20
|
+
has(key: K): boolean;
|
|
21
|
+
set(key: K, value: V): void;
|
|
22
|
+
clear(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=lru-cache.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name Matcher
|
|
3
|
+
*
|
|
4
|
+
* Handles symbol name matching for reference resolution.
|
|
5
|
+
*/
|
|
6
|
+
import { UnresolvedRef, ResolvedRef, ResolutionContext } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Try to resolve a path-like reference (e.g., "snippets/drawer-menu.liquid")
|
|
9
|
+
* by matching the filename against file nodes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function matchByFilePath(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
12
|
+
/**
|
|
13
|
+
* Try to resolve a reference by exact name match
|
|
14
|
+
*/
|
|
15
|
+
export declare function matchByExactName(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
16
|
+
/**
|
|
17
|
+
* Try to resolve by qualified name
|
|
18
|
+
*/
|
|
19
|
+
export declare function matchByQualifiedName(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
20
|
+
/**
|
|
21
|
+
* Try to resolve by method name on a class/object
|
|
22
|
+
*/
|
|
23
|
+
export declare function matchMethodCall(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
24
|
+
/**
|
|
25
|
+
* Fuzzy match - last resort with lower confidence
|
|
26
|
+
*/
|
|
27
|
+
export declare function matchFuzzy(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
28
|
+
/**
|
|
29
|
+
* Match all strategies in order of confidence
|
|
30
|
+
*/
|
|
31
|
+
export declare function matchReference(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
32
|
+
//# sourceMappingURL=name-matcher.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project-level import-path alias loading.
|
|
3
|
+
*
|
|
4
|
+
* Reads `compilerOptions.paths` from `tsconfig.json` / `jsconfig.json`
|
|
5
|
+
* at the project root and converts the patterns into a form the
|
|
6
|
+
* import-resolver can consult.
|
|
7
|
+
*
|
|
8
|
+
* This is the single biggest blocker to accurate resolution on modern
|
|
9
|
+
* JS/TS codebases: aliases like `@/components/Foo` (Next, Nuxt, Nest,
|
|
10
|
+
* Vite scaffolds) point into a `paths` map the resolver previously
|
|
11
|
+
* ignored — every import through an alias was treated as unresolvable
|
|
12
|
+
* unless it happened to match the small hard-coded fallback list.
|
|
13
|
+
*
|
|
14
|
+
* Scope deliberately small for v1:
|
|
15
|
+
* - reads tsconfig.json, then jsconfig.json
|
|
16
|
+
* - honours top-level `compilerOptions.baseUrl` and `compilerOptions.paths`
|
|
17
|
+
* - supports `*` wildcard (the only TS-supported wildcard)
|
|
18
|
+
* - does NOT follow `extends` chains yet (most projects don't need it)
|
|
19
|
+
* - does NOT read Vite/webpack/Rollup configs (separate follow-up)
|
|
20
|
+
*
|
|
21
|
+
* The file is parsed as JSON-with-comments-tolerant — tsconfigs in the
|
|
22
|
+
* wild routinely contain `//` and `/* *\/` comments and trailing
|
|
23
|
+
* commas, which JSON.parse rejects. We strip those before parsing.
|
|
24
|
+
*/
|
|
25
|
+
/** A single alias pattern from `compilerOptions.paths`. */
|
|
26
|
+
export interface AliasPattern {
|
|
27
|
+
/** The literal prefix before `*` (or the whole pattern if no `*`). */
|
|
28
|
+
prefix: string;
|
|
29
|
+
/** The literal suffix after `*` (almost always empty). */
|
|
30
|
+
suffix: string;
|
|
31
|
+
/** Whether the pattern contains a `*` wildcard. */
|
|
32
|
+
hasWildcard: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Replacement templates. When `hasWildcard` is true, `*` in the
|
|
35
|
+
* replacement is filled with the captured wildcard portion of the
|
|
36
|
+
* import path. Stored relative to {@link AliasMap.baseUrl}.
|
|
37
|
+
* tsconfig allows multiple targets per alias (priority order).
|
|
38
|
+
*/
|
|
39
|
+
replacements: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface AliasMap {
|
|
42
|
+
/** Absolute path. The directory `compilerOptions.paths` is rooted at. */
|
|
43
|
+
baseUrl: string;
|
|
44
|
+
/**
|
|
45
|
+
* Patterns ordered by specificity: longer prefix first, then literal-
|
|
46
|
+
* before-wildcard, so the resolver tries the most-specific match.
|
|
47
|
+
*/
|
|
48
|
+
patterns: AliasPattern[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Load aliases for `projectRoot`. Returns `null` when no tsconfig /
|
|
52
|
+
* jsconfig is present or when the file has no usable `paths`.
|
|
53
|
+
*
|
|
54
|
+
* Cheap to call repeatedly — caching is the caller's job (the
|
|
55
|
+
* resolver does it via {@link aliasCache}).
|
|
56
|
+
*/
|
|
57
|
+
export declare function loadProjectAliases(projectRoot: string): AliasMap | null;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve an import path through an {@link AliasMap}. Returns the list
|
|
60
|
+
* of candidate filesystem paths (relative to `projectRoot`), in the
|
|
61
|
+
* priority order defined by tsconfig (multiple replacements per alias
|
|
62
|
+
* are tried in order). Returns `[]` when no alias matches.
|
|
63
|
+
*
|
|
64
|
+
* Callers still need to try each candidate with the language's
|
|
65
|
+
* extension list — this function only does the alias rewrite.
|
|
66
|
+
*/
|
|
67
|
+
export declare function applyAliases(importPath: string, aliases: AliasMap, projectRoot: string): string[];
|
|
68
|
+
//# sourceMappingURL=path-aliases.d.ts.map
|