kirograph 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1171 -0
- package/dist/architecture/index.d.ts +11 -0
- package/dist/architecture/index.d.ts.map +1 -0
- package/dist/architecture/index.js +207 -0
- package/dist/architecture/index.js.map +7 -0
- package/dist/architecture/layers/csharp.d.ts +6 -0
- package/dist/architecture/layers/csharp.d.ts.map +1 -0
- package/dist/architecture/layers/csharp.js +100 -0
- package/dist/architecture/layers/csharp.js.map +7 -0
- package/dist/architecture/layers/elixir.js +116 -0
- package/dist/architecture/layers/elixir.js.map +7 -0
- package/dist/architecture/layers/go.d.ts +7 -0
- package/dist/architecture/layers/go.d.ts.map +1 -0
- package/dist/architecture/layers/go.js +117 -0
- package/dist/architecture/layers/go.js.map +7 -0
- package/dist/architecture/layers/index.d.ts +30 -0
- package/dist/architecture/layers/index.d.ts.map +1 -0
- package/dist/architecture/layers/index.js +100 -0
- package/dist/architecture/layers/index.js.map +7 -0
- package/dist/architecture/layers/java.d.ts +7 -0
- package/dist/architecture/layers/java.d.ts.map +1 -0
- package/dist/architecture/layers/java.js +119 -0
- package/dist/architecture/layers/java.js.map +7 -0
- package/dist/architecture/layers/python.d.ts +7 -0
- package/dist/architecture/layers/python.d.ts.map +1 -0
- package/dist/architecture/layers/python.js +111 -0
- package/dist/architecture/layers/python.js.map +7 -0
- package/dist/architecture/layers/ruby.d.ts +6 -0
- package/dist/architecture/layers/ruby.d.ts.map +1 -0
- package/dist/architecture/layers/ruby.js +95 -0
- package/dist/architecture/layers/ruby.js.map +7 -0
- package/dist/architecture/layers/rust.d.ts +6 -0
- package/dist/architecture/layers/rust.d.ts.map +1 -0
- package/dist/architecture/layers/rust.js +98 -0
- package/dist/architecture/layers/rust.js.map +7 -0
- package/dist/architecture/layers/types.d.ts +2 -0
- package/dist/architecture/layers/types.d.ts.map +1 -0
- package/dist/architecture/layers/types.js +17 -0
- package/dist/architecture/layers/types.js.map +7 -0
- package/dist/architecture/layers/typescript.d.ts +9 -0
- package/dist/architecture/layers/typescript.d.ts.map +1 -0
- package/dist/architecture/layers/typescript.js +143 -0
- package/dist/architecture/layers/typescript.js.map +7 -0
- package/dist/architecture/manifest/cargo.d.ts +3 -0
- package/dist/architecture/manifest/cargo.d.ts.map +1 -0
- package/dist/architecture/manifest/cargo.js +94 -0
- package/dist/architecture/manifest/cargo.js.map +7 -0
- package/dist/architecture/manifest/csproj.d.ts +3 -0
- package/dist/architecture/manifest/csproj.d.ts.map +1 -0
- package/dist/architecture/manifest/csproj.js +75 -0
- package/dist/architecture/manifest/csproj.js.map +7 -0
- package/dist/architecture/manifest/go.d.ts +3 -0
- package/dist/architecture/manifest/go.d.ts.map +1 -0
- package/dist/architecture/manifest/go.js +85 -0
- package/dist/architecture/manifest/go.js.map +7 -0
- package/dist/architecture/manifest/gradle.d.ts +3 -0
- package/dist/architecture/manifest/gradle.d.ts.map +1 -0
- package/dist/architecture/manifest/gradle.js +80 -0
- package/dist/architecture/manifest/gradle.js.map +7 -0
- package/dist/architecture/manifest/index.d.ts +12 -0
- package/dist/architecture/manifest/index.d.ts.map +1 -0
- package/dist/architecture/manifest/index.js +130 -0
- package/dist/architecture/manifest/index.js.map +7 -0
- package/dist/architecture/manifest/maven.d.ts +3 -0
- package/dist/architecture/manifest/maven.d.ts.map +1 -0
- package/dist/architecture/manifest/maven.js +76 -0
- package/dist/architecture/manifest/maven.js.map +7 -0
- package/dist/architecture/manifest/npm.d.ts +3 -0
- package/dist/architecture/manifest/npm.d.ts.map +1 -0
- package/dist/architecture/manifest/npm.js +103 -0
- package/dist/architecture/manifest/npm.js.map +7 -0
- package/dist/architecture/manifest/python.d.ts +3 -0
- package/dist/architecture/manifest/python.d.ts.map +1 -0
- package/dist/architecture/manifest/python.js +105 -0
- package/dist/architecture/manifest/python.js.map +7 -0
- package/dist/architecture/manifest/types.d.ts +2 -0
- package/dist/architecture/manifest/types.d.ts.map +1 -0
- package/dist/architecture/manifest/types.js +17 -0
- package/dist/architecture/manifest/types.js.map +7 -0
- package/dist/architecture/types.d.ts +91 -0
- package/dist/architecture/types.d.ts.map +1 -0
- package/dist/architecture/types.js +17 -0
- package/dist/architecture/types.js.map +7 -0
- package/dist/assets/logo.png +0 -0
- package/dist/banner.d.ts +6 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +67 -0
- package/dist/banner.js.map +1 -0
- package/dist/bin/banner.d.ts +6 -0
- package/dist/bin/banner.d.ts.map +1 -0
- package/dist/bin/banner.js +88 -0
- package/dist/bin/banner.js.map +7 -0
- package/dist/bin/commands/affected.d.ts +3 -0
- package/dist/bin/commands/affected.d.ts.map +1 -0
- package/dist/bin/commands/affected.js +78 -0
- package/dist/bin/commands/affected.js.map +7 -0
- package/dist/bin/commands/architecture.d.ts +3 -0
- package/dist/bin/commands/architecture.d.ts.map +1 -0
- package/dist/bin/commands/architecture.js +125 -0
- package/dist/bin/commands/architecture.js.map +7 -0
- package/dist/bin/commands/caveman.js +136 -0
- package/dist/bin/commands/caveman.js.map +7 -0
- package/dist/bin/commands/context.d.ts +3 -0
- package/dist/bin/commands/context.d.ts.map +1 -0
- package/dist/bin/commands/context.js +81 -0
- package/dist/bin/commands/context.js.map +7 -0
- package/dist/bin/commands/coupling.d.ts +3 -0
- package/dist/bin/commands/coupling.d.ts.map +1 -0
- package/dist/bin/commands/coupling.js +164 -0
- package/dist/bin/commands/coupling.js.map +7 -0
- package/dist/bin/commands/dashboard.d.ts +3 -0
- package/dist/bin/commands/dashboard.d.ts.map +1 -0
- package/dist/bin/commands/dashboard.js +209 -0
- package/dist/bin/commands/dashboard.js.map +7 -0
- package/dist/bin/commands/dead-code.js +77 -0
- package/dist/bin/commands/dead-code.js.map +7 -0
- package/dist/bin/commands/export.js +2620 -0
- package/dist/bin/commands/export.js.map +7 -0
- package/dist/bin/commands/files.d.ts +3 -0
- package/dist/bin/commands/files.d.ts.map +1 -0
- package/dist/bin/commands/files.js +104 -0
- package/dist/bin/commands/files.js.map +7 -0
- package/dist/bin/commands/help.d.ts +4 -0
- package/dist/bin/commands/help.d.ts.map +1 -0
- package/dist/bin/commands/help.js +212 -0
- package/dist/bin/commands/help.js.map +7 -0
- package/dist/bin/commands/hotspots.js +77 -0
- package/dist/bin/commands/hotspots.js.map +7 -0
- package/dist/bin/commands/index.d.ts +3 -0
- package/dist/bin/commands/index.d.ts.map +1 -0
- package/dist/bin/commands/index.js +58 -0
- package/dist/bin/commands/index.js.map +7 -0
- package/dist/bin/commands/init.d.ts +3 -0
- package/dist/bin/commands/init.d.ts.map +1 -0
- package/dist/bin/commands/init.js +68 -0
- package/dist/bin/commands/init.js.map +7 -0
- package/dist/bin/commands/install.d.ts +3 -0
- package/dist/bin/commands/install.d.ts.map +1 -0
- package/dist/bin/commands/install.js +34 -0
- package/dist/bin/commands/install.js.map +7 -0
- package/dist/bin/commands/mark-dirty.d.ts +3 -0
- package/dist/bin/commands/mark-dirty.d.ts.map +1 -0
- package/dist/bin/commands/mark-dirty.js +51 -0
- package/dist/bin/commands/mark-dirty.js.map +7 -0
- package/dist/bin/commands/package.d.ts +3 -0
- package/dist/bin/commands/package.d.ts.map +1 -0
- package/dist/bin/commands/package.js +139 -0
- package/dist/bin/commands/package.js.map +7 -0
- package/dist/bin/commands/path.js +93 -0
- package/dist/bin/commands/path.js.map +7 -0
- package/dist/bin/commands/qdrant.d.ts +3 -0
- package/dist/bin/commands/qdrant.d.ts.map +1 -0
- package/dist/bin/commands/qdrant.js +159 -0
- package/dist/bin/commands/qdrant.js.map +1 -0
- package/dist/bin/commands/query.d.ts +3 -0
- package/dist/bin/commands/query.d.ts.map +1 -0
- package/dist/bin/commands/query.js +47 -0
- package/dist/bin/commands/query.js.map +7 -0
- package/dist/bin/commands/serve.d.ts +3 -0
- package/dist/bin/commands/serve.d.ts.map +1 -0
- package/dist/bin/commands/serve.js +59 -0
- package/dist/bin/commands/serve.js.map +7 -0
- package/dist/bin/commands/snapshot.js +122 -0
- package/dist/bin/commands/snapshot.js.map +7 -0
- package/dist/bin/commands/status.d.ts +3 -0
- package/dist/bin/commands/status.d.ts.map +1 -0
- package/dist/bin/commands/status.js +107 -0
- package/dist/bin/commands/status.js.map +7 -0
- package/dist/bin/commands/stop.d.ts +3 -0
- package/dist/bin/commands/stop.d.ts.map +1 -0
- package/dist/bin/commands/stop.js +81 -0
- package/dist/bin/commands/stop.js.map +1 -0
- package/dist/bin/commands/surprising.js +79 -0
- package/dist/bin/commands/surprising.js.map +7 -0
- package/dist/bin/commands/sync-if-dirty.d.ts +3 -0
- package/dist/bin/commands/sync-if-dirty.d.ts.map +1 -0
- package/dist/bin/commands/sync-if-dirty.js +67 -0
- package/dist/bin/commands/sync-if-dirty.js.map +7 -0
- package/dist/bin/commands/sync.d.ts +3 -0
- package/dist/bin/commands/sync.d.ts.map +1 -0
- package/dist/bin/commands/sync.js +81 -0
- package/dist/bin/commands/sync.js.map +7 -0
- package/dist/bin/commands/typesense.d.ts +3 -0
- package/dist/bin/commands/typesense.d.ts.map +1 -0
- package/dist/bin/commands/typesense.js +126 -0
- package/dist/bin/commands/typesense.js.map +1 -0
- package/dist/bin/commands/uninit.d.ts +4 -0
- package/dist/bin/commands/uninit.d.ts.map +1 -0
- package/dist/bin/commands/uninit.js +123 -0
- package/dist/bin/commands/uninit.js.map +7 -0
- package/dist/bin/commands/unlock.d.ts +3 -0
- package/dist/bin/commands/unlock.d.ts.map +1 -0
- package/dist/bin/commands/unlock.js +53 -0
- package/dist/bin/commands/unlock.js.map +7 -0
- package/dist/bin/commands/utils.d.ts +12 -0
- package/dist/bin/commands/utils.d.ts.map +1 -0
- package/dist/bin/commands/utils.js +56 -0
- package/dist/bin/commands/utils.js.map +7 -0
- package/dist/bin/installer/archive.js +230 -0
- package/dist/bin/installer/archive.js.map +7 -0
- package/dist/bin/installer/caveman.js +57 -0
- package/dist/bin/installer/caveman.js.map +7 -0
- package/dist/bin/installer/cli-agent.d.ts +15 -0
- package/dist/bin/installer/cli-agent.d.ts.map +1 -0
- package/dist/bin/installer/cli-agent.js +89 -0
- package/dist/bin/installer/cli-agent.js.map +7 -0
- package/dist/bin/installer/config-prompt.d.ts +13 -0
- package/dist/bin/installer/config-prompt.d.ts.map +1 -0
- package/dist/bin/installer/config-prompt.js +158 -0
- package/dist/bin/installer/config-prompt.js.map +7 -0
- package/dist/bin/installer/dashboard.d.ts +3 -0
- package/dist/bin/installer/dashboard.d.ts.map +1 -0
- package/dist/bin/installer/dashboard.js +149 -0
- package/dist/bin/installer/dashboard.js.map +7 -0
- package/dist/bin/installer/hooks.d.ts +5 -0
- package/dist/bin/installer/hooks.d.ts.map +1 -0
- package/dist/bin/installer/hooks.js +155 -0
- package/dist/bin/installer/hooks.js.map +7 -0
- package/dist/bin/installer/index.d.ts +11 -0
- package/dist/bin/installer/index.d.ts.map +1 -0
- package/dist/bin/installer/index.js +228 -0
- package/dist/bin/installer/index.js.map +7 -0
- package/dist/bin/installer/mcp.d.ts +5 -0
- package/dist/bin/installer/mcp.d.ts.map +1 -0
- package/dist/bin/installer/mcp.js +80 -0
- package/dist/bin/installer/mcp.js.map +7 -0
- package/dist/bin/installer/prompts.d.ts +28 -0
- package/dist/bin/installer/prompts.d.ts.map +1 -0
- package/dist/bin/installer/prompts.js +134 -0
- package/dist/bin/installer/prompts.js.map +7 -0
- package/dist/bin/installer/qdrant-dashboard.d.ts +4 -0
- package/dist/bin/installer/qdrant-dashboard.d.ts.map +1 -0
- package/dist/bin/installer/qdrant-dashboard.js +115 -0
- package/dist/bin/installer/qdrant-dashboard.js.map +7 -0
- package/dist/bin/installer/steering.d.ts +5 -0
- package/dist/bin/installer/steering.d.ts.map +1 -0
- package/dist/bin/installer/steering.js +283 -0
- package/dist/bin/installer/steering.js.map +7 -0
- package/dist/bin/kirograph.d.ts +6 -0
- package/dist/bin/kirograph.d.ts.map +1 -0
- package/dist/bin/kirograph.js +95 -0
- package/dist/bin/kirograph.js.map +7 -0
- package/dist/bin/progress.d.ts +14 -0
- package/dist/bin/progress.d.ts.map +1 -0
- package/dist/bin/progress.js +201 -0
- package/dist/bin/progress.js.map +7 -0
- package/dist/bin/ui.d.ts +11 -0
- package/dist/bin/ui.d.ts.map +1 -0
- package/dist/bin/ui.js +71 -0
- package/dist/bin/ui.js.map +7 -0
- package/dist/config.d.ts +48 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +273 -0
- package/dist/config.js.map +7 -0
- package/dist/context/index.d.ts +61 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +224 -0
- package/dist/context/index.js.map +7 -0
- package/dist/core/file-tree.d.ts +15 -0
- package/dist/core/file-tree.d.ts.map +1 -0
- package/dist/core/file-tree.js +69 -0
- package/dist/core/file-tree.js.map +7 -0
- package/dist/core/lock-manager.d.ts +20 -0
- package/dist/core/lock-manager.d.ts.map +1 -0
- package/dist/core/lock-manager.js +120 -0
- package/dist/core/lock-manager.js.map +7 -0
- package/dist/core/pipeline.d.ts +37 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +375 -0
- package/dist/core/pipeline.js.map +7 -0
- package/dist/core/snapshot.js +141 -0
- package/dist/core/snapshot.js.map +7 -0
- package/dist/db/database.d.ts +133 -0
- package/dist/db/database.d.ts.map +1 -0
- package/dist/db/database.js +929 -0
- package/dist/db/database.js.map +7 -0
- package/dist/db/schema.sql +174 -0
- package/dist/errors.d.ts +49 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +160 -0
- package/dist/errors.js.map +7 -0
- package/dist/extraction/extractor.d.ts +29 -0
- package/dist/extraction/extractor.d.ts.map +1 -0
- package/dist/extraction/extractor.js +764 -0
- package/dist/extraction/extractor.js.map +7 -0
- package/dist/extraction/grammars.d.ts +48 -0
- package/dist/extraction/grammars.d.ts.map +1 -0
- package/dist/extraction/grammars.js +166 -0
- package/dist/extraction/grammars.js.map +7 -0
- package/dist/extraction/languages.d.ts +9 -0
- package/dist/extraction/languages.d.ts.map +1 -0
- package/dist/extraction/languages.js +103 -0
- package/dist/extraction/languages.js.map +7 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/frameworks/csharp.d.ts +8 -0
- package/dist/frameworks/csharp.d.ts.map +1 -0
- package/dist/frameworks/csharp.js +93 -0
- package/dist/frameworks/csharp.js.map +7 -0
- package/dist/frameworks/elixir.js +142 -0
- package/dist/frameworks/elixir.js.map +7 -0
- package/dist/frameworks/express.d.ts +8 -0
- package/dist/frameworks/express.d.ts.map +1 -0
- package/dist/frameworks/express.js +143 -0
- package/dist/frameworks/express.js.map +7 -0
- package/dist/frameworks/go.d.ts +8 -0
- package/dist/frameworks/go.d.ts.map +1 -0
- package/dist/frameworks/go.js +85 -0
- package/dist/frameworks/go.js.map +7 -0
- package/dist/frameworks/index.d.ts +30 -0
- package/dist/frameworks/index.d.ts.map +1 -0
- package/dist/frameworks/index.js +243 -0
- package/dist/frameworks/index.js.map +7 -0
- package/dist/frameworks/java.d.ts +8 -0
- package/dist/frameworks/java.d.ts.map +1 -0
- package/dist/frameworks/java.js +87 -0
- package/dist/frameworks/java.js.map +7 -0
- package/dist/frameworks/laravel.d.ts +9 -0
- package/dist/frameworks/laravel.d.ts.map +1 -0
- package/dist/frameworks/laravel.js +115 -0
- package/dist/frameworks/laravel.js.map +7 -0
- package/dist/frameworks/python.d.ts +10 -0
- package/dist/frameworks/python.d.ts.map +1 -0
- package/dist/frameworks/python.js +158 -0
- package/dist/frameworks/python.js.map +7 -0
- package/dist/frameworks/react.d.ts +9 -0
- package/dist/frameworks/react.d.ts.map +1 -0
- package/dist/frameworks/react.js +230 -0
- package/dist/frameworks/react.js.map +7 -0
- package/dist/frameworks/ruby.d.ts +8 -0
- package/dist/frameworks/ruby.d.ts.map +1 -0
- package/dist/frameworks/ruby.js +136 -0
- package/dist/frameworks/ruby.js.map +7 -0
- package/dist/frameworks/rust.d.ts +8 -0
- package/dist/frameworks/rust.d.ts.map +1 -0
- package/dist/frameworks/rust.js +82 -0
- package/dist/frameworks/rust.js.map +7 -0
- package/dist/frameworks/svelte.d.ts +8 -0
- package/dist/frameworks/svelte.d.ts.map +1 -0
- package/dist/frameworks/svelte.js +174 -0
- package/dist/frameworks/svelte.js.map +7 -0
- package/dist/frameworks/swift.d.ts +10 -0
- package/dist/frameworks/swift.d.ts.map +1 -0
- package/dist/frameworks/swift.js +151 -0
- package/dist/frameworks/swift.js.map +7 -0
- package/dist/frameworks/types.d.ts +37 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +17 -0
- package/dist/frameworks/types.js.map +7 -0
- package/dist/graph/queries.d.ts +53 -0
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +224 -0
- package/dist/graph/queries.js.map +7 -0
- package/dist/graph/traversal.d.ts +35 -0
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +148 -0
- package/dist/graph/traversal.js.map +7 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +303 -0
- package/dist/index.js.map +7 -0
- package/dist/installer/index.d.ts +10 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +526 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/mcp/server.d.ts +16 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +116 -0
- package/dist/mcp/server.js.map +7 -0
- package/dist/mcp/tools.d.ts +37 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +779 -0
- package/dist/mcp/tools.js.map +7 -0
- package/dist/mcp/transport.d.ts +29 -0
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +70 -0
- package/dist/mcp/transport.js.map +7 -0
- package/dist/resolution/index.d.ts +56 -0
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +384 -0
- package/dist/resolution/index.js.map +7 -0
- package/dist/resolution/name-matcher.d.ts +25 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -0
- package/dist/resolution/name-matcher.js +60 -0
- package/dist/resolution/name-matcher.js.map +7 -0
- package/dist/scripts/postinstall.js +64 -0
- package/dist/search/query-utils.d.ts +21 -0
- package/dist/search/query-utils.d.ts.map +1 -0
- package/dist/search/query-utils.js +219 -0
- package/dist/search/query-utils.js.map +7 -0
- package/dist/search/searcher.d.ts +15 -0
- package/dist/search/searcher.d.ts.map +1 -0
- package/dist/search/searcher.js +49 -0
- package/dist/search/searcher.js.map +7 -0
- package/dist/sync/index.d.ts +33 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +200 -0
- package/dist/sync/index.js.map +7 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +37 -0
- package/dist/types.js.map +7 -0
- package/dist/utils.d.ts +52 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +254 -0
- package/dist/utils.js.map +7 -0
- package/dist/vectors/index.d.ts +71 -0
- package/dist/vectors/index.d.ts.map +1 -0
- package/dist/vectors/index.js +480 -0
- package/dist/vectors/index.js.map +7 -0
- package/dist/vectors/lancedb-index.d.ts +50 -0
- package/dist/vectors/lancedb-index.d.ts.map +1 -0
- package/dist/vectors/lancedb-index.js +153 -0
- package/dist/vectors/lancedb-index.js.map +7 -0
- package/dist/vectors/orama-index.d.ts +54 -0
- package/dist/vectors/orama-index.d.ts.map +1 -0
- package/dist/vectors/orama-index.js +213 -0
- package/dist/vectors/orama-index.js.map +7 -0
- package/dist/vectors/pglite-index.d.ts +53 -0
- package/dist/vectors/pglite-index.d.ts.map +1 -0
- package/dist/vectors/pglite-index.js +194 -0
- package/dist/vectors/pglite-index.js.map +7 -0
- package/dist/vectors/qdrant-index.d.ts +70 -0
- package/dist/vectors/qdrant-index.d.ts.map +1 -0
- package/dist/vectors/qdrant-index.js +364 -0
- package/dist/vectors/qdrant-index.js.map +7 -0
- package/dist/vectors/typesense-index.d.ts +75 -0
- package/dist/vectors/typesense-index.d.ts.map +1 -0
- package/dist/vectors/typesense-index.js +453 -0
- package/dist/vectors/typesense-index.js.map +7 -0
- package/dist/vectors/vec-index.d.ts +52 -0
- package/dist/vectors/vec-index.d.ts.map +1 -0
- package/dist/vectors/vec-index.js +198 -0
- package/dist/vectors/vec-index.js.map +7 -0
- package/package.json +67 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var python_exports = {};
|
|
20
|
+
__export(python_exports, {
|
|
21
|
+
djangoResolver: () => djangoResolver,
|
|
22
|
+
fastapiResolver: () => fastapiResolver,
|
|
23
|
+
flaskResolver: () => flaskResolver
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(python_exports);
|
|
26
|
+
const djangoResolver = {
|
|
27
|
+
name: "django",
|
|
28
|
+
detect(context) {
|
|
29
|
+
const req = context.readFile("requirements.txt");
|
|
30
|
+
if (req && req.includes("django")) return true;
|
|
31
|
+
const setup = context.readFile("setup.py");
|
|
32
|
+
if (setup && setup.includes("django")) return true;
|
|
33
|
+
const pyproject = context.readFile("pyproject.toml");
|
|
34
|
+
if (pyproject && pyproject.includes("django")) return true;
|
|
35
|
+
return context.fileExists("manage.py");
|
|
36
|
+
},
|
|
37
|
+
resolve(ref, context) {
|
|
38
|
+
if (ref.referenceName.endsWith("Model") || /^[A-Z][a-z]+$/.test(ref.referenceName)) {
|
|
39
|
+
const id = resolveInDirs(ref.referenceName, ["models", "app/models", "src/models"], ".py", "class", context);
|
|
40
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
41
|
+
}
|
|
42
|
+
if (ref.referenceName.endsWith("View") || ref.referenceName.endsWith("ViewSet")) {
|
|
43
|
+
const id = resolveInDirs(ref.referenceName, ["views", "app/views", "src/views", "api/views"], ".py", null, context);
|
|
44
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
45
|
+
}
|
|
46
|
+
if (ref.referenceName.endsWith("Form")) {
|
|
47
|
+
const id = resolveInDirs(ref.referenceName, ["forms", "app/forms", "src/forms"], ".py", "class", context);
|
|
48
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
},
|
|
52
|
+
extractNodes(filePath, content) {
|
|
53
|
+
const nodes = [];
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
for (const pattern of [/path\s*\(\s*['"]([^'"]+)['"],\s*(\w+)/g, /url\s*\(\s*r?['"]([^'"]+)['"],\s*(\w+)/g]) {
|
|
56
|
+
let match;
|
|
57
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
58
|
+
const [, urlPath] = match;
|
|
59
|
+
const line = content.slice(0, match.index).split("\n").length;
|
|
60
|
+
nodes.push({ id: `route:${filePath}:${urlPath}:${line}`, kind: "route", name: urlPath, qualifiedName: `${filePath}::route:${urlPath}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: "python", updatedAt: now });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return nodes;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const flaskResolver = {
|
|
67
|
+
name: "flask",
|
|
68
|
+
detect(context) {
|
|
69
|
+
const req = context.readFile("requirements.txt");
|
|
70
|
+
if (req && (req.includes("flask") || req.includes("Flask"))) return true;
|
|
71
|
+
const pyproject = context.readFile("pyproject.toml");
|
|
72
|
+
if (pyproject && pyproject.includes("flask")) return true;
|
|
73
|
+
for (const file of ["app.py", "application.py", "main.py", "__init__.py"]) {
|
|
74
|
+
const content = context.readFile(file);
|
|
75
|
+
if (content && content.includes("Flask(__name__)")) return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
},
|
|
79
|
+
resolve(ref, context) {
|
|
80
|
+
if (ref.referenceName.endsWith("_bp") || ref.referenceName.endsWith("_blueprint")) {
|
|
81
|
+
for (const file of context.getAllFiles()) {
|
|
82
|
+
if (file.endsWith(".py")) {
|
|
83
|
+
const node = context.getNodesInFile(file).find((n) => n.kind === "variable" && n.name === ref.referenceName);
|
|
84
|
+
if (node) return { original: ref, targetNodeId: node.id, confidence: 0.8, resolvedBy: "framework" };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
},
|
|
90
|
+
extractNodes(filePath, content) {
|
|
91
|
+
const nodes = [];
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
const routePattern = /@(\w+)\.route\s*\(\s*['"]([^'"]+)['"]/g;
|
|
94
|
+
let match;
|
|
95
|
+
while ((match = routePattern.exec(content)) !== null) {
|
|
96
|
+
const [, , routePath] = match;
|
|
97
|
+
const line = content.slice(0, match.index).split("\n").length;
|
|
98
|
+
nodes.push({ id: `route:${filePath}:${routePath}:${line}`, kind: "route", name: routePath, qualifiedName: `${filePath}::route:${routePath}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: "python", updatedAt: now });
|
|
99
|
+
}
|
|
100
|
+
return nodes;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const fastapiResolver = {
|
|
104
|
+
name: "fastapi",
|
|
105
|
+
detect(context) {
|
|
106
|
+
const req = context.readFile("requirements.txt");
|
|
107
|
+
if (req && req.includes("fastapi")) return true;
|
|
108
|
+
const pyproject = context.readFile("pyproject.toml");
|
|
109
|
+
if (pyproject && pyproject.includes("fastapi")) return true;
|
|
110
|
+
for (const file of ["app.py", "main.py", "api.py"]) {
|
|
111
|
+
const content = context.readFile(file);
|
|
112
|
+
if (content && content.includes("FastAPI()")) return true;
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
},
|
|
116
|
+
resolve(ref, context) {
|
|
117
|
+
if (ref.referenceName.endsWith("_router") || ref.referenceName === "router") {
|
|
118
|
+
const dirs = ["routers", "api", "routes", "endpoints"];
|
|
119
|
+
for (const file of context.getAllFiles()) {
|
|
120
|
+
if (file.endsWith(".py") && dirs.some((d) => file.startsWith(d) || file.includes(`/${d}/`))) {
|
|
121
|
+
const node = context.getNodesInFile(file).find((n) => n.kind === "variable" && n.name === ref.referenceName);
|
|
122
|
+
if (node) return { original: ref, targetNodeId: node.id, confidence: 0.8, resolvedBy: "framework" };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
},
|
|
128
|
+
extractNodes(filePath, content) {
|
|
129
|
+
const nodes = [];
|
|
130
|
+
const now = Date.now();
|
|
131
|
+
const routePattern = /@(\w+)\.(get|post|put|patch|delete|options|head)\s*\(\s*['"]([^'"]+)['"]/g;
|
|
132
|
+
let match;
|
|
133
|
+
while ((match = routePattern.exec(content)) !== null) {
|
|
134
|
+
const [, , method, routePath] = match;
|
|
135
|
+
const line = content.slice(0, match.index).split("\n").length;
|
|
136
|
+
nodes.push({ id: `route:${filePath}:${method.toUpperCase()}:${routePath}:${line}`, kind: "route", name: `${method.toUpperCase()} ${routePath}`, qualifiedName: `${filePath}::${method.toUpperCase()}:${routePath}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: "python", updatedAt: now });
|
|
137
|
+
}
|
|
138
|
+
return nodes;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
function resolveInDirs(name, dirs, ext, kind, context) {
|
|
142
|
+
for (const file of context.getAllFiles()) {
|
|
143
|
+
if (file.endsWith(ext) && dirs.some((d) => file.startsWith(d))) {
|
|
144
|
+
const node = context.getNodesInFile(file).find(
|
|
145
|
+
(n) => n.name === name && (kind === null || n.kind === kind)
|
|
146
|
+
);
|
|
147
|
+
if (node) return node.id;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
djangoResolver,
|
|
155
|
+
fastapiResolver,
|
|
156
|
+
flaskResolver
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/frameworks/python.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Python Framework Resolver (Django, Flask, FastAPI)\n *\n * Mirrors CodeGraph src/resolution/frameworks/python.ts\n */\n\nimport type { Node } from '../types';\nimport type { FrameworkResolver, UnresolvedRef, ResolvedRef, ResolutionContext } from './types';\n\nexport const djangoResolver: FrameworkResolver = {\n name: 'django',\n detect(context: ResolutionContext): boolean {\n const req = context.readFile('requirements.txt');\n if (req && req.includes('django')) return true;\n const setup = context.readFile('setup.py');\n if (setup && setup.includes('django')) return true;\n const pyproject = context.readFile('pyproject.toml');\n if (pyproject && pyproject.includes('django')) return true;\n return context.fileExists('manage.py');\n },\n resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null {\n if (ref.referenceName.endsWith('Model') || /^[A-Z][a-z]+$/.test(ref.referenceName)) {\n const id = resolveInDirs(ref.referenceName, ['models','app/models','src/models'], '.py', 'class', context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n if (ref.referenceName.endsWith('View') || ref.referenceName.endsWith('ViewSet')) {\n const id = resolveInDirs(ref.referenceName, ['views','app/views','src/views','api/views'], '.py', null, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n if (ref.referenceName.endsWith('Form')) {\n const id = resolveInDirs(ref.referenceName, ['forms','app/forms','src/forms'], '.py', 'class', context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n return null;\n },\n extractNodes(filePath: string, content: string): Node[] {\n const nodes: Node[] = [];\n const now = Date.now();\n for (const pattern of [/path\\s*\\(\\s*['\"]([^'\"]+)['\"],\\s*(\\w+)/g, /url\\s*\\(\\s*r?['\"]([^'\"]+)['\"],\\s*(\\w+)/g]) {\n let match;\n while ((match = pattern.exec(content)) !== null) {\n const [, urlPath] = match;\n const line = content.slice(0, match.index).split('\\n').length;\n nodes.push({ id: `route:${filePath}:${urlPath}:${line}`, kind: 'route', name: urlPath!, qualifiedName: `${filePath}::route:${urlPath}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: 'python', updatedAt: now });\n }\n }\n return nodes;\n },\n};\n\nexport const flaskResolver: FrameworkResolver = {\n name: 'flask',\n detect(context: ResolutionContext): boolean {\n const req = context.readFile('requirements.txt');\n if (req && (req.includes('flask') || req.includes('Flask'))) return true;\n const pyproject = context.readFile('pyproject.toml');\n if (pyproject && pyproject.includes('flask')) return true;\n for (const file of ['app.py','application.py','main.py','__init__.py']) {\n const content = context.readFile(file);\n if (content && content.includes('Flask(__name__)')) return true;\n }\n return false;\n },\n resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null {\n if (ref.referenceName.endsWith('_bp') || ref.referenceName.endsWith('_blueprint')) {\n for (const file of context.getAllFiles()) {\n if (file.endsWith('.py')) {\n const node = context.getNodesInFile(file).find(n => n.kind === 'variable' && n.name === ref.referenceName);\n if (node) return { original: ref, targetNodeId: node.id, confidence: 0.8, resolvedBy: 'framework' };\n }\n }\n }\n return null;\n },\n extractNodes(filePath: string, content: string): Node[] {\n const nodes: Node[] = [];\n const now = Date.now();\n const routePattern = /@(\\w+)\\.route\\s*\\(\\s*['\"]([^'\"]+)['\"]/g;\n let match;\n while ((match = routePattern.exec(content)) !== null) {\n const [, , routePath] = match;\n const line = content.slice(0, match.index).split('\\n').length;\n nodes.push({ id: `route:${filePath}:${routePath}:${line}`, kind: 'route', name: routePath!, qualifiedName: `${filePath}::route:${routePath}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: 'python', updatedAt: now });\n }\n return nodes;\n },\n};\n\nexport const fastapiResolver: FrameworkResolver = {\n name: 'fastapi',\n detect(context: ResolutionContext): boolean {\n const req = context.readFile('requirements.txt');\n if (req && req.includes('fastapi')) return true;\n const pyproject = context.readFile('pyproject.toml');\n if (pyproject && pyproject.includes('fastapi')) return true;\n for (const file of ['app.py','main.py','api.py']) {\n const content = context.readFile(file);\n if (content && content.includes('FastAPI()')) return true;\n }\n return false;\n },\n resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null {\n if (ref.referenceName.endsWith('_router') || ref.referenceName === 'router') {\n const dirs = ['routers','api','routes','endpoints'];\n for (const file of context.getAllFiles()) {\n if (file.endsWith('.py') && dirs.some(d => file.startsWith(d) || file.includes(`/${d}/`))) {\n const node = context.getNodesInFile(file).find(n => n.kind === 'variable' && n.name === ref.referenceName);\n if (node) return { original: ref, targetNodeId: node.id, confidence: 0.8, resolvedBy: 'framework' };\n }\n }\n }\n return null;\n },\n extractNodes(filePath: string, content: string): Node[] {\n const nodes: Node[] = [];\n const now = Date.now();\n const routePattern = /@(\\w+)\\.(get|post|put|patch|delete|options|head)\\s*\\(\\s*['\"]([^'\"]+)['\"]/g;\n let match;\n while ((match = routePattern.exec(content)) !== null) {\n const [, , method, routePath] = match;\n const line = content.slice(0, match.index).split('\\n').length;\n nodes.push({ id: `route:${filePath}:${method!.toUpperCase()}:${routePath}:${line}`, kind: 'route', name: `${method!.toUpperCase()} ${routePath}`, qualifiedName: `${filePath}::${method!.toUpperCase()}:${routePath}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: 'python', updatedAt: now });\n }\n return nodes;\n },\n};\n\nfunction resolveInDirs(name: string, dirs: string[], ext: string, kind: string | null, context: ResolutionContext): string | null {\n for (const file of context.getAllFiles()) {\n if (file.endsWith(ext) && dirs.some(d => file.startsWith(d))) {\n const node = context.getNodesInFile(file).find(\n n => n.name === name && (kind === null || n.kind === kind)\n );\n if (node) return node.id;\n }\n }\n return null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,iBAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,OAAO,SAAqC;AAC1C,UAAM,MAAM,QAAQ,SAAS,kBAAkB;AAC/C,QAAI,OAAO,IAAI,SAAS,QAAQ,EAAG,QAAO;AAC1C,UAAM,QAAQ,QAAQ,SAAS,UAAU;AACzC,QAAI,SAAS,MAAM,SAAS,QAAQ,EAAG,QAAO;AAC9C,UAAM,YAAY,QAAQ,SAAS,gBAAgB;AACnD,QAAI,aAAa,UAAU,SAAS,QAAQ,EAAG,QAAO;AACtD,WAAO,QAAQ,WAAW,WAAW;AAAA,EACvC;AAAA,EACA,QAAQ,KAAoB,SAAgD;AAC1E,QAAI,IAAI,cAAc,SAAS,OAAO,KAAK,gBAAgB,KAAK,IAAI,aAAa,GAAG;AAClF,YAAM,KAAK,cAAc,IAAI,eAAe,CAAC,UAAS,cAAa,YAAY,GAAG,OAAO,SAAS,OAAO;AACzG,UAAI,GAAI,QAAO,EAAE,UAAU,KAAK,cAAc,IAAI,YAAY,KAAK,YAAY,YAAY;AAAA,IAC7F;AACA,QAAI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AM,OAAO,QAAQ,MAAM,GAAG,MAAM,KAAK,EAAE,MAAM,IAAI,EAAE;AACvD,YAAM,KAAK,EAAE,IAAI,SAAS,QAAQ,IAAI,OAAQ,YAAY,CAAC,IAAI,SAAS,IAAI,IAAI,IAAI,MAAM,SAAS,MAAM,GAAG,OAAQ,YAAY,CAAC,IAAI,SAAS,IAAI,eAAe,GAAG,QAAQ,KAAK,OAAQ,YAAY,CAAC,IAAI,SAAS,IAAI,UAAU,WAAW,MAAM,SAAS,MAAM,aAAa,GAAG,WAAW,MAAM,CAAC,EAAE,QAAQ,UAAU,UAAU,WAAW,IAAI,CAAC;AAAA,IACnV;AACA,WAAO;AAAA,EACT;AACF;AAEA,SAAS,cAAc,MAAc,MAAgB,KAAa,MAAqB,SAA2C;AAChI,aAAW,QAAQ,QAAQ,YAAY,GAAG;AACxC,QAAI,KAAK,SAAS,GAAG,KAAK,KAAK,KAAK,OAAK,KAAK,WAAW,CAAC,CAAC,GAAG;AAC5D,YAAM,OAAO,QAAQ,eAAe,IAAI,EAAE;AAAA,QACxC,OAAK,EAAE,SAAS,SAAS,SAAS,QAAQ,EAAE,SAAS;AAAA,MACvD;AACA,UAAI,KAAM,QAAO,KAAK;AAAA,IACxB;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Mirrors CodeGraph src/resolution/frameworks/react.ts
|
|
5
|
+
* Handles React and Next.js patterns.
|
|
6
|
+
*/
|
|
7
|
+
import type { FrameworkResolver } from './types';
|
|
8
|
+
export declare const reactResolver: FrameworkResolver;
|
|
9
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/frameworks/react.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAiD,MAAM,SAAS,CAAC;AAEhG,eAAO,MAAM,aAAa,EAAE,iBAkH3B,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var react_exports = {};
|
|
20
|
+
__export(react_exports, {
|
|
21
|
+
reactResolver: () => reactResolver
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(react_exports);
|
|
24
|
+
const reactResolver = {
|
|
25
|
+
name: "react",
|
|
26
|
+
detect(context) {
|
|
27
|
+
const packageJson = context.readFile("package.json");
|
|
28
|
+
if (packageJson) {
|
|
29
|
+
try {
|
|
30
|
+
const pkg = JSON.parse(packageJson);
|
|
31
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
32
|
+
if (deps.react || deps.next || deps["react-native"]) return true;
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const allFiles = context.getAllFiles();
|
|
37
|
+
return allFiles.some((f) => f.endsWith(".jsx") || f.endsWith(".tsx"));
|
|
38
|
+
},
|
|
39
|
+
resolve(ref, context) {
|
|
40
|
+
if (isPascalCase(ref.referenceName) && !isBuiltInType(ref.referenceName)) {
|
|
41
|
+
const id = resolveComponent(ref.referenceName, ref.filePath, context);
|
|
42
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
43
|
+
}
|
|
44
|
+
if (ref.referenceName.startsWith("use") && ref.referenceName.length > 3) {
|
|
45
|
+
const id = resolveHook(ref.referenceName, context);
|
|
46
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.85, resolvedBy: "framework" };
|
|
47
|
+
}
|
|
48
|
+
if (ref.referenceName.endsWith("Context") || ref.referenceName.endsWith("Provider")) {
|
|
49
|
+
const id = resolveContext(ref.referenceName, context);
|
|
50
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
},
|
|
54
|
+
extractNodes(filePath, content) {
|
|
55
|
+
const nodes = [];
|
|
56
|
+
const now = Date.now();
|
|
57
|
+
const componentPatterns = [
|
|
58
|
+
/(?:export\s+)?function\s+([A-Z][a-zA-Z0-9]*)\s*\(/g,
|
|
59
|
+
/(?:export\s+)?(?:const|let)\s+([A-Z][a-zA-Z0-9]*)\s*=\s*(?:\([^)]*\)|[a-zA-Z_][a-zA-Z0-9_]*)\s*=>/g,
|
|
60
|
+
/(?:export\s+)?(?:const|let)\s+([A-Z][a-zA-Z0-9]*)\s*=\s*(?:React\.)?forwardRef/g,
|
|
61
|
+
/(?:export\s+)?(?:const|let)\s+([A-Z][a-zA-Z0-9]*)\s*=\s*(?:React\.)?memo/g
|
|
62
|
+
];
|
|
63
|
+
for (const pattern of componentPatterns) {
|
|
64
|
+
let match;
|
|
65
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
66
|
+
const [fullMatch, name] = match;
|
|
67
|
+
const line = content.slice(0, match.index).split("\n").length;
|
|
68
|
+
const afterMatch = content.slice(match.index + fullMatch.length, match.index + fullMatch.length + 500);
|
|
69
|
+
const hasJSX = afterMatch.includes("<") && (afterMatch.includes("/>") || afterMatch.includes("</"));
|
|
70
|
+
if (hasJSX) {
|
|
71
|
+
nodes.push({
|
|
72
|
+
id: `component:${filePath}:${name}:${line}`,
|
|
73
|
+
kind: "component",
|
|
74
|
+
name,
|
|
75
|
+
qualifiedName: `${filePath}::${name}`,
|
|
76
|
+
filePath,
|
|
77
|
+
startLine: line,
|
|
78
|
+
endLine: line,
|
|
79
|
+
startColumn: 0,
|
|
80
|
+
endColumn: fullMatch.length,
|
|
81
|
+
language: filePath.endsWith(".tsx") ? "tsx" : "jsx",
|
|
82
|
+
isExported: fullMatch.includes("export"),
|
|
83
|
+
updatedAt: now
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const hookPattern = /(?:export\s+)?(?:function|const|let)\s+(use[A-Z][a-zA-Z0-9]*)\s*[=(]/g;
|
|
89
|
+
let hookMatch;
|
|
90
|
+
while ((hookMatch = hookPattern.exec(content)) !== null) {
|
|
91
|
+
const [fullMatch, name] = hookMatch;
|
|
92
|
+
const line = content.slice(0, hookMatch.index).split("\n").length;
|
|
93
|
+
nodes.push({
|
|
94
|
+
id: `hook:${filePath}:${name}:${line}`,
|
|
95
|
+
kind: "function",
|
|
96
|
+
name,
|
|
97
|
+
qualifiedName: `${filePath}::${name}`,
|
|
98
|
+
filePath,
|
|
99
|
+
startLine: line,
|
|
100
|
+
endLine: line,
|
|
101
|
+
startColumn: 0,
|
|
102
|
+
endColumn: fullMatch.length,
|
|
103
|
+
language: filePath.endsWith(".ts") || filePath.endsWith(".tsx") ? "typescript" : "javascript",
|
|
104
|
+
isExported: fullMatch.includes("export"),
|
|
105
|
+
updatedAt: now
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (filePath.includes("pages/") || filePath.includes("app/")) {
|
|
109
|
+
if (content.includes("export default")) {
|
|
110
|
+
const routePath = filePathToRoute(filePath);
|
|
111
|
+
if (routePath) {
|
|
112
|
+
const line = content.slice(0, content.indexOf("export default")).split("\n").length;
|
|
113
|
+
nodes.push({
|
|
114
|
+
id: `route:${filePath}:${routePath}:${line}`,
|
|
115
|
+
kind: "route",
|
|
116
|
+
name: routePath,
|
|
117
|
+
qualifiedName: `${filePath}::route:${routePath}`,
|
|
118
|
+
filePath,
|
|
119
|
+
startLine: line,
|
|
120
|
+
endLine: line,
|
|
121
|
+
startColumn: 0,
|
|
122
|
+
endColumn: 0,
|
|
123
|
+
language: filePath.endsWith(".tsx") ? "tsx" : filePath.endsWith(".ts") ? "typescript" : "javascript",
|
|
124
|
+
updatedAt: now
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return nodes;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
function isPascalCase(str) {
|
|
133
|
+
return /^[A-Z][a-zA-Z0-9]*$/.test(str);
|
|
134
|
+
}
|
|
135
|
+
function isBuiltInType(name) {
|
|
136
|
+
const builtIns = /* @__PURE__ */ new Set([
|
|
137
|
+
"Array",
|
|
138
|
+
"Boolean",
|
|
139
|
+
"Date",
|
|
140
|
+
"Error",
|
|
141
|
+
"Function",
|
|
142
|
+
"JSON",
|
|
143
|
+
"Math",
|
|
144
|
+
"Number",
|
|
145
|
+
"Object",
|
|
146
|
+
"Promise",
|
|
147
|
+
"RegExp",
|
|
148
|
+
"String",
|
|
149
|
+
"Symbol",
|
|
150
|
+
"Map",
|
|
151
|
+
"Set",
|
|
152
|
+
"WeakMap",
|
|
153
|
+
"WeakSet",
|
|
154
|
+
"React",
|
|
155
|
+
"Component",
|
|
156
|
+
"Fragment",
|
|
157
|
+
"Suspense",
|
|
158
|
+
"StrictMode"
|
|
159
|
+
]);
|
|
160
|
+
return builtIns.has(name);
|
|
161
|
+
}
|
|
162
|
+
function resolveComponent(name, fromFile, context) {
|
|
163
|
+
const fromDir = fromFile.substring(0, fromFile.lastIndexOf("/"));
|
|
164
|
+
for (const file of context.getAllFiles().filter((f) => f.startsWith(fromDir))) {
|
|
165
|
+
if (file.toLowerCase().includes(name.toLowerCase())) {
|
|
166
|
+
const node = context.getNodesInFile(file).find(
|
|
167
|
+
(n) => (n.kind === "component" || n.kind === "function" || n.kind === "class") && n.name === name
|
|
168
|
+
);
|
|
169
|
+
if (node) return node.id;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const componentDirs = ["components", "src/components", "app/components", "pages", "src/pages", "views", "src/views"];
|
|
173
|
+
for (const dir of componentDirs) {
|
|
174
|
+
for (const file of context.getAllFiles()) {
|
|
175
|
+
if (file.startsWith(dir) && file.toLowerCase().includes(name.toLowerCase())) {
|
|
176
|
+
const node = context.getNodesInFile(file).find(
|
|
177
|
+
(n) => (n.kind === "component" || n.kind === "function" || n.kind === "class") && n.name === name
|
|
178
|
+
);
|
|
179
|
+
if (node) return node.id;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
function resolveHook(name, context) {
|
|
186
|
+
const hookDirs = ["hooks", "src/hooks", "lib/hooks", "utils/hooks"];
|
|
187
|
+
for (const dir of hookDirs) {
|
|
188
|
+
for (const file of context.getAllFiles()) {
|
|
189
|
+
if (file.startsWith(dir) || file.includes("/hooks/")) {
|
|
190
|
+
const node2 = context.getNodesInFile(file).find((n) => n.kind === "function" && n.name === name);
|
|
191
|
+
if (node2) return node2.id;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const node = context.getNodesByName(name).find((n) => n.kind === "function" && n.name.startsWith("use"));
|
|
196
|
+
return node?.id ?? null;
|
|
197
|
+
}
|
|
198
|
+
function resolveContext(name, context) {
|
|
199
|
+
const contextDirs = ["context", "contexts", "src/context", "src/contexts", "providers", "src/providers"];
|
|
200
|
+
for (const dir of contextDirs) {
|
|
201
|
+
for (const file of context.getAllFiles()) {
|
|
202
|
+
if (file.startsWith(dir) || file.includes("/context/") || file.includes("/contexts/")) {
|
|
203
|
+
const node = context.getNodesInFile(file).find(
|
|
204
|
+
(n) => n.name === name || n.name === name.replace(/Context$|Provider$/, "")
|
|
205
|
+
);
|
|
206
|
+
if (node) return node.id;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
function filePathToRoute(filePath) {
|
|
213
|
+
if (filePath.includes("pages/")) {
|
|
214
|
+
let route = filePath.replace(/^.*pages\//, "/").replace(/\/index\.(tsx?|jsx?)$/, "").replace(/\.(tsx?|jsx?)$/, "").replace(/\[([^\]]+)\]/g, ":$1");
|
|
215
|
+
if (route === "") route = "/";
|
|
216
|
+
return route;
|
|
217
|
+
}
|
|
218
|
+
if (filePath.includes("app/")) {
|
|
219
|
+
if (!filePath.includes("page.")) return null;
|
|
220
|
+
let route = filePath.replace(/^.*app\//, "/").replace(/\/page\.(tsx?|jsx?)$/, "").replace(/\[([^\]]+)\]/g, ":$1");
|
|
221
|
+
if (route === "") route = "/";
|
|
222
|
+
return route.replace(/\/$/, "");
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
227
|
+
0 && (module.exports = {
|
|
228
|
+
reactResolver
|
|
229
|
+
});
|
|
230
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/frameworks/react.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * React Framework Resolver\n *\n * Mirrors CodeGraph src/resolution/frameworks/react.ts\n * Handles React and Next.js patterns.\n */\n\nimport type { Node } from '../types';\nimport type { FrameworkResolver, UnresolvedRef, ResolvedRef, ResolutionContext } from './types';\n\nexport const reactResolver: FrameworkResolver = {\n name: 'react',\n\n detect(context: ResolutionContext): boolean {\n const packageJson = context.readFile('package.json');\n if (packageJson) {\n try {\n const pkg = JSON.parse(packageJson);\n const deps = { ...pkg.dependencies, ...pkg.devDependencies };\n if (deps.react || deps.next || deps['react-native']) return true;\n } catch { /* invalid JSON */ }\n }\n const allFiles = context.getAllFiles();\n return allFiles.some(f => f.endsWith('.jsx') || f.endsWith('.tsx'));\n },\n\n resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null {\n if (isPascalCase(ref.referenceName) && !isBuiltInType(ref.referenceName)) {\n const id = resolveComponent(ref.referenceName, ref.filePath, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n if (ref.referenceName.startsWith('use') && ref.referenceName.length > 3) {\n const id = resolveHook(ref.referenceName, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.85, resolvedBy: 'framework' };\n }\n if (ref.referenceName.endsWith('Context') || ref.referenceName.endsWith('Provider')) {\n const id = resolveContext(ref.referenceName, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n return null;\n },\n\n extractNodes(filePath: string, content: string): Node[] {\n const nodes: Node[] = [];\n const now = Date.now();\n\n const componentPatterns = [\n /(?:export\\s+)?function\\s+([A-Z][a-zA-Z0-9]*)\\s*\\(/g,\n /(?:export\\s+)?(?:const|let)\\s+([A-Z][a-zA-Z0-9]*)\\s*=\\s*(?:\\([^)]*\\)|[a-zA-Z_][a-zA-Z0-9_]*)\\s*=>/g,\n /(?:export\\s+)?(?:const|let)\\s+([A-Z][a-zA-Z0-9]*)\\s*=\\s*(?:React\\.)?forwardRef/g,\n /(?:export\\s+)?(?:const|let)\\s+([A-Z][a-zA-Z0-9]*)\\s*=\\s*(?:React\\.)?memo/g,\n ];\n\n for (const pattern of componentPatterns) {\n let match;\n while ((match = pattern.exec(content)) !== null) {\n const [fullMatch, name] = match;\n const line = content.slice(0, match.index).split('\\n').length;\n const afterMatch = content.slice(match.index + fullMatch.length, match.index + fullMatch.length + 500);\n const hasJSX = afterMatch.includes('<') && (afterMatch.includes('/>') || afterMatch.includes('</'));\n if (hasJSX) {\n nodes.push({\n id: `component:${filePath}:${name}:${line}`,\n kind: 'component',\n name: name!,\n qualifiedName: `${filePath}::${name}`,\n filePath,\n startLine: line,\n endLine: line,\n startColumn: 0,\n endColumn: fullMatch.length,\n language: filePath.endsWith('.tsx') ? 'tsx' : 'jsx',\n isExported: fullMatch.includes('export'),\n updatedAt: now,\n });\n }\n }\n }\n\n const hookPattern = /(?:export\\s+)?(?:function|const|let)\\s+(use[A-Z][a-zA-Z0-9]*)\\s*[=(]/g;\n let hookMatch;\n while ((hookMatch = hookPattern.exec(content)) !== null) {\n const [fullMatch, name] = hookMatch;\n const line = content.slice(0, hookMatch.index).split('\\n').length;\n nodes.push({\n id: `hook:${filePath}:${name}:${line}`,\n kind: 'function',\n name: name!,\n qualifiedName: `${filePath}::${name}`,\n filePath,\n startLine: line,\n endLine: line,\n startColumn: 0,\n endColumn: fullMatch.length,\n language: filePath.endsWith('.ts') || filePath.endsWith('.tsx') ? 'typescript' : 'javascript',\n isExported: fullMatch.includes('export'),\n updatedAt: now,\n });\n }\n\n if (filePath.includes('pages/') || filePath.includes('app/')) {\n if (content.includes('export default')) {\n const routePath = filePathToRoute(filePath);\n if (routePath) {\n const line = content.slice(0, content.indexOf('export default')).split('\\n').length;\n nodes.push({\n id: `route:${filePath}:${routePath}:${line}`,\n kind: 'route',\n name: routePath,\n qualifiedName: `${filePath}::route:${routePath}`,\n filePath,\n startLine: line,\n endLine: line,\n startColumn: 0,\n endColumn: 0,\n language: filePath.endsWith('.tsx') ? 'tsx' : filePath.endsWith('.ts') ? 'typescript' : 'javascript',\n updatedAt: now,\n });\n }\n }\n }\n\n return nodes;\n },\n};\n\nfunction isPascalCase(str: string): boolean {\n return /^[A-Z][a-zA-Z0-9]*$/.test(str);\n}\n\nfunction isBuiltInType(name: string): boolean {\n const builtIns = new Set([\n 'Array','Boolean','Date','Error','Function','JSON','Math','Number',\n 'Object','Promise','RegExp','String','Symbol','Map','Set','WeakMap','WeakSet',\n 'React','Component','Fragment','Suspense','StrictMode',\n ]);\n return builtIns.has(name);\n}\n\nfunction resolveComponent(name: string, fromFile: string, context: ResolutionContext): string | null {\n const fromDir = fromFile.substring(0, fromFile.lastIndexOf('/'));\n for (const file of context.getAllFiles().filter(f => f.startsWith(fromDir))) {\n if (file.toLowerCase().includes(name.toLowerCase())) {\n const node = context.getNodesInFile(file).find(\n n => (n.kind === 'component' || n.kind === 'function' || n.kind === 'class') && n.name === name\n );\n if (node) return node.id;\n }\n }\n const componentDirs = ['components','src/components','app/components','pages','src/pages','views','src/views'];\n for (const dir of componentDirs) {\n for (const file of context.getAllFiles()) {\n if (file.startsWith(dir) && file.toLowerCase().includes(name.toLowerCase())) {\n const node = context.getNodesInFile(file).find(\n n => (n.kind === 'component' || n.kind === 'function' || n.kind === 'class') && n.name === name\n );\n if (node) return node.id;\n }\n }\n }\n return null;\n}\n\nfunction resolveHook(name: string, context: ResolutionContext): string | null {\n const hookDirs = ['hooks','src/hooks','lib/hooks','utils/hooks'];\n for (const dir of hookDirs) {\n for (const file of context.getAllFiles()) {\n if (file.startsWith(dir) || file.includes('/hooks/')) {\n const node = context.getNodesInFile(file).find(n => n.kind === 'function' && n.name === name);\n if (node) return node.id;\n }\n }\n }\n const node = context.getNodesByName(name).find(n => n.kind === 'function' && n.name.startsWith('use'));\n return node?.id ?? null;\n}\n\nfunction resolveContext(name: string, context: ResolutionContext): string | null {\n const contextDirs = ['context','contexts','src/context','src/contexts','providers','src/providers'];\n for (const dir of contextDirs) {\n for (const file of context.getAllFiles()) {\n if (file.startsWith(dir) || file.includes('/context/') || file.includes('/contexts/')) {\n const node = context.getNodesInFile(file).find(\n n => n.name === name || n.name === name.replace(/Context$|Provider$/, '')\n );\n if (node) return node.id;\n }\n }\n }\n return null;\n}\n\nfunction filePathToRoute(filePath: string): string | null {\n if (filePath.includes('pages/')) {\n let route = filePath\n .replace(/^.*pages\\//, '/')\n .replace(/\\/index\\.(tsx?|jsx?)$/, '')\n .replace(/\\.(tsx?|jsx?)$/, '')\n .replace(/\\[([^\\]]+)\\]/g, ':$1');\n if (route === '') route = '/';\n return route;\n }\n if (filePath.includes('app/')) {\n if (!filePath.includes('page.')) return null;\n let route = filePath\n .replace(/^.*app\\//, '/')\n .replace(/\\/page\\.(tsx?|jsx?)$/, '')\n .replace(/\\[([^\\]]+)\\]/g, ':$1');\n if (route === '') route = '/';\n return route.replace(/\\/$/, '');\n }\n return null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,gBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,OAAO,SAAqC;AAC1C,UAAM,cAAc,QAAQ,SAAS,cAAc;AACnD,QAAI,aAAa;AACf,UAAI;AACF,cAAM,MAAM,KAAK,MAAM,WAAW;AAClC,cAAM,OAAO,EAAE,GAAG,IAAI,cAAc,GAAG,IAAI,gBAAgB;AAC3D,YAAI,KAAK,SAAS,KAAK,QAAQ,KAAK,cAAc,EAAG,QAAO;AAAA,MAC9D,QAAQ;AAAA,MAAqB;AAAA,IAC/B;AACA,UAAM,WAAW,QAAQ,YAAY;AACrC,WAAO,SAAS,KAAK,OAAK,EAAE,SAAS,MAAM,KAAK,EAAE,SAAS,MAAM,CAAC;AAAA,EACpE;AAAA,EAEA,QAAQ,KAAoB,SAAgD;AAC1E,QAAI,aAAa,IAAI,aAAa,KAAK,CAAC,cAAc,IAAI,aAAa,GAAG;AACxE,YAAM,KAAK,iBAAiB,IAAI,eAAe,IAAI,UAAU,OAAO;AACpE,UAAI,GAAI,QAAO,EAAE,UAAU,KAAK,cAAc,IAAI,YAAY,KAAK,YAAY,YAAY;AAAA,IAC7F;AACA,QAAI,IAAI,cAAc,WAAW,KAAK,KAAK,IAAI,cAAc,SAAS,GAAG;AACvE,YAAM,KAAK,YA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EACnC,QAAQ,kBAAkB,EAAE,EAC5B,QAAQ,iBAAiB,KAAK;AACjC,QAAI,UAAU,GAAI,SAAQ;AAC1B,WAAO;AAAA,EACT;AACA,MAAI,SAAS,SAAS,MAAM,GAAG;AAC7B,QAAI,CAAC,SAAS,SAAS,OAAO,EAAG,QAAO;AACxC,QAAI,QAAQ,SACT,QAAQ,YAAY,GAAG,EACvB,QAAQ,wBAAwB,EAAE,EAClC,QAAQ,iBAAiB,KAAK;AACjC,QAAI,UAAU,GAAI,SAAQ;AAC1B,WAAO,MAAM,QAAQ,OAAO,EAAE;AAAA,EAChC;AACA,SAAO;AACT;",
|
|
6
|
+
"names": ["node"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruby.d.ts","sourceRoot":"","sources":["../../src/frameworks/ruby.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAiD,MAAM,SAAS,CAAC;AAEhG,eAAO,MAAM,aAAa,EAAE,iBAuD3B,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ruby_exports = {};
|
|
20
|
+
__export(ruby_exports, {
|
|
21
|
+
railsResolver: () => railsResolver
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ruby_exports);
|
|
24
|
+
const railsResolver = {
|
|
25
|
+
name: "rails",
|
|
26
|
+
detect(context) {
|
|
27
|
+
const gemfile = context.readFile("Gemfile");
|
|
28
|
+
if (gemfile && gemfile.includes("'rails'")) return true;
|
|
29
|
+
return context.fileExists("config/application.rb") || context.fileExists("app/controllers/application_controller.rb") || context.fileExists("config/routes.rb");
|
|
30
|
+
},
|
|
31
|
+
resolve(ref, context) {
|
|
32
|
+
if (/^[A-Z][a-zA-Z]+$/.test(ref.referenceName)) {
|
|
33
|
+
const id = resolveModel(ref.referenceName, context);
|
|
34
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
35
|
+
}
|
|
36
|
+
if (ref.referenceName.endsWith("Controller")) {
|
|
37
|
+
const id = resolveController(ref.referenceName, context);
|
|
38
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.85, resolvedBy: "framework" };
|
|
39
|
+
}
|
|
40
|
+
if (ref.referenceName.endsWith("Helper")) {
|
|
41
|
+
const id = resolveHelper(ref.referenceName, context);
|
|
42
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
43
|
+
}
|
|
44
|
+
if (ref.referenceName.endsWith("Service") || ref.referenceName.endsWith("Job")) {
|
|
45
|
+
const id = resolveService(ref.referenceName, context);
|
|
46
|
+
if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
},
|
|
50
|
+
extractNodes(filePath, content) {
|
|
51
|
+
const nodes = [];
|
|
52
|
+
const now = Date.now();
|
|
53
|
+
if (filePath.includes("routes.rb")) {
|
|
54
|
+
for (const pattern of [
|
|
55
|
+
/(get|post|put|patch|delete)\s+['"]([^'"]+)['"]/g,
|
|
56
|
+
/resources?\s+:(\w+)/g,
|
|
57
|
+
/root\s+['"]([^'"]+)['"]/g
|
|
58
|
+
]) {
|
|
59
|
+
let match;
|
|
60
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
61
|
+
const line = content.slice(0, match.index).split("\n").length;
|
|
62
|
+
if (pattern.source.includes("resources")) {
|
|
63
|
+
const [, name] = match;
|
|
64
|
+
nodes.push({ id: `route:${filePath}:resource:${name}:${line}`, kind: "route", name: `resource:${name}`, qualifiedName: `${filePath}::resource:${name}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: "ruby", updatedAt: now });
|
|
65
|
+
} else if (pattern.source.includes("root")) {
|
|
66
|
+
const [, target] = match;
|
|
67
|
+
nodes.push({ id: `route:${filePath}:root:${line}`, kind: "route", name: `/ -> ${target}`, qualifiedName: `${filePath}::root`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: "ruby", updatedAt: now });
|
|
68
|
+
} else {
|
|
69
|
+
const [, method, path] = match;
|
|
70
|
+
nodes.push({ id: `route:${filePath}:${method.toUpperCase()}:${path}:${line}`, kind: "route", name: `${method.toUpperCase()} ${path}`, qualifiedName: `${filePath}::${method.toUpperCase()}:${path}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: "ruby", updatedAt: now });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return nodes;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
function toSnake(name) {
|
|
79
|
+
return name.replace(/([A-Z])/g, "_$1").toLowerCase().slice(1);
|
|
80
|
+
}
|
|
81
|
+
function resolveModel(name, context) {
|
|
82
|
+
const snake = toSnake(name);
|
|
83
|
+
for (const p of [`app/models/${snake}.rb`, `app/models/concerns/${snake}.rb`]) {
|
|
84
|
+
if (context.fileExists(p)) {
|
|
85
|
+
const node = context.getNodesInFile(p).find((n) => n.kind === "class" && n.name === name);
|
|
86
|
+
if (node) return node.id;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (const file of context.getAllFiles()) {
|
|
90
|
+
if (file.includes("app/models/") && file.endsWith(".rb")) {
|
|
91
|
+
const node = context.getNodesInFile(file).find((n) => n.kind === "class" && n.name === name);
|
|
92
|
+
if (node) return node.id;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function resolveController(name, context) {
|
|
98
|
+
const snake = toSnake(name);
|
|
99
|
+
for (const p of [`app/controllers/${snake}.rb`, `app/controllers/api/${snake}.rb`]) {
|
|
100
|
+
if (context.fileExists(p)) {
|
|
101
|
+
const node = context.getNodesInFile(p).find((n) => n.kind === "class" && n.name === name);
|
|
102
|
+
if (node) return node.id;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const file of context.getAllFiles()) {
|
|
106
|
+
if (file.includes("controllers/") && file.endsWith(".rb")) {
|
|
107
|
+
const node = context.getNodesInFile(file).find((n) => n.kind === "class" && n.name === name);
|
|
108
|
+
if (node) return node.id;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
function resolveHelper(name, context) {
|
|
114
|
+
const snake = toSnake(name);
|
|
115
|
+
const p = `app/helpers/${snake}.rb`;
|
|
116
|
+
if (context.fileExists(p)) {
|
|
117
|
+
const node = context.getNodesInFile(p).find((n) => n.kind === "module" && n.name === name);
|
|
118
|
+
if (node) return node.id;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
function resolveService(name, context) {
|
|
123
|
+
const snake = toSnake(name);
|
|
124
|
+
for (const p of [`app/services/${snake}.rb`, `app/jobs/${snake}.rb`, `app/workers/${snake}.rb`]) {
|
|
125
|
+
if (context.fileExists(p)) {
|
|
126
|
+
const node = context.getNodesInFile(p).find((n) => n.kind === "class" && n.name === name);
|
|
127
|
+
if (node) return node.id;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
railsResolver
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=ruby.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/frameworks/ruby.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Ruby on Rails Framework Resolver\n *\n * Mirrors CodeGraph src/resolution/frameworks/ruby.ts\n */\n\nimport type { Node } from '../types';\nimport type { FrameworkResolver, UnresolvedRef, ResolvedRef, ResolutionContext } from './types';\n\nexport const railsResolver: FrameworkResolver = {\n name: 'rails',\n detect(context: ResolutionContext): boolean {\n const gemfile = context.readFile('Gemfile');\n if (gemfile && gemfile.includes(\"'rails'\")) return true;\n return context.fileExists('config/application.rb') ||\n context.fileExists('app/controllers/application_controller.rb') ||\n context.fileExists('config/routes.rb');\n },\n resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null {\n if (/^[A-Z][a-zA-Z]+$/.test(ref.referenceName)) {\n const id = resolveModel(ref.referenceName, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n if (ref.referenceName.endsWith('Controller')) {\n const id = resolveController(ref.referenceName, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.85, resolvedBy: 'framework' };\n }\n if (ref.referenceName.endsWith('Helper')) {\n const id = resolveHelper(ref.referenceName, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n if (ref.referenceName.endsWith('Service') || ref.referenceName.endsWith('Job')) {\n const id = resolveService(ref.referenceName, context);\n if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: 'framework' };\n }\n return null;\n },\n extractNodes(filePath: string, content: string): Node[] {\n const nodes: Node[] = [];\n const now = Date.now();\n if (filePath.includes('routes.rb')) {\n for (const pattern of [\n /(get|post|put|patch|delete)\\s+['\"]([^'\"]+)['\"]/g,\n /resources?\\s+:(\\w+)/g,\n /root\\s+['\"]([^'\"]+)['\"]/g,\n ]) {\n let match;\n while ((match = pattern.exec(content)) !== null) {\n const line = content.slice(0, match.index).split('\\n').length;\n if (pattern.source.includes('resources')) {\n const [, name] = match;\n nodes.push({ id: `route:${filePath}:resource:${name}:${line}`, kind: 'route', name: `resource:${name}`, qualifiedName: `${filePath}::resource:${name}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: 'ruby', updatedAt: now });\n } else if (pattern.source.includes('root')) {\n const [, target] = match;\n nodes.push({ id: `route:${filePath}:root:${line}`, kind: 'route', name: `/ -> ${target}`, qualifiedName: `${filePath}::root`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: 'ruby', updatedAt: now });\n } else {\n const [, method, path] = match;\n nodes.push({ id: `route:${filePath}:${method!.toUpperCase()}:${path}:${line}`, kind: 'route', name: `${method!.toUpperCase()} ${path}`, qualifiedName: `${filePath}::${method!.toUpperCase()}:${path}`, filePath, startLine: line, endLine: line, startColumn: 0, endColumn: match[0].length, language: 'ruby', updatedAt: now });\n }\n }\n }\n }\n return nodes;\n },\n};\n\nfunction toSnake(name: string): string {\n return name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1);\n}\n\nfunction resolveModel(name: string, context: ResolutionContext): string | null {\n const snake = toSnake(name);\n for (const p of [`app/models/${snake}.rb`, `app/models/concerns/${snake}.rb`]) {\n if (context.fileExists(p)) {\n const node = context.getNodesInFile(p).find(n => n.kind === 'class' && n.name === name);\n if (node) return node.id;\n }\n }\n for (const file of context.getAllFiles()) {\n if (file.includes('app/models/') && file.endsWith('.rb')) {\n const node = context.getNodesInFile(file).find(n => n.kind === 'class' && n.name === name);\n if (node) return node.id;\n }\n }\n return null;\n}\n\nfunction resolveController(name: string, context: ResolutionContext): string | null {\n const snake = toSnake(name);\n for (const p of [`app/controllers/${snake}.rb`, `app/controllers/api/${snake}.rb`]) {\n if (context.fileExists(p)) {\n const node = context.getNodesInFile(p).find(n => n.kind === 'class' && n.name === name);\n if (node) return node.id;\n }\n }\n for (const file of context.getAllFiles()) {\n if (file.includes('controllers/') && file.endsWith('.rb')) {\n const node = context.getNodesInFile(file).find(n => n.kind === 'class' && n.name === name);\n if (node) return node.id;\n }\n }\n return null;\n}\n\nfunction resolveHelper(name: string, context: ResolutionContext): string | null {\n const snake = toSnake(name);\n const p = `app/helpers/${snake}.rb`;\n if (context.fileExists(p)) {\n const node = context.getNodesInFile(p).find(n => n.kind === 'module' && n.name === name);\n if (node) return node.id;\n }\n return null;\n}\n\nfunction resolveService(name: string, context: ResolutionContext): string | null {\n const snake = toSnake(name);\n for (const p of [`app/services/${snake}.rb`, `app/jobs/${snake}.rb`, `app/workers/${snake}.rb`]) {\n if (context.fileExists(p)) {\n const node = context.getNodesInFile(p).find(n => n.kind === 'class' && n.name === name);\n if (node) return node.id;\n }\n }\n return null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,gBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,OAAO,SAAqC;AAC1C,UAAM,UAAU,QAAQ,SAAS,SAAS;AAC1C,QAAI,WAAW,QAAQ,SAAS,SAAS,EAAG,QAAO;AACnD,WAAO,QAAQ,WAAW,uBAAuB,KAC1C,QAAQ,WAAW,2CAA2C,KAC9D,QAAQ,WAAW,kBAAkB;AAAA,EAC9C;AAAA,EACA,QAAQ,KAAoB,SAAgD;AAC1E,QAAI,mBAAmB,KAAK,IAAI,aAAa,GAAG;AAC9C,YAAM,KAAK,aAAa,IAAI,eAAe,OAAO;AAClD,UAAI,GAAI,QAAO,EAAE,UAAU,KAAK,cA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