distill-mcp 0.6.0-beta
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/bin/cli.js +133 -0
- package/dist/analytics/session-tracker.d.ts +74 -0
- package/dist/analytics/session-tracker.d.ts.map +1 -0
- package/dist/analytics/session-tracker.js +123 -0
- package/dist/ast/benchmark.test.d.ts +7 -0
- package/dist/ast/benchmark.test.d.ts.map +1 -0
- package/dist/ast/benchmark.test.js +175 -0
- package/dist/ast/go/index.d.ts +9 -0
- package/dist/ast/go/index.d.ts.map +1 -0
- package/dist/ast/go/index.js +8 -0
- package/dist/ast/go/parser.d.ts +31 -0
- package/dist/ast/go/parser.d.ts.map +1 -0
- package/dist/ast/go/parser.js +428 -0
- package/dist/ast/go/parser.test.d.ts +5 -0
- package/dist/ast/go/parser.test.d.ts.map +1 -0
- package/dist/ast/go/parser.test.js +241 -0
- package/dist/ast/go/queries.d.ts +51 -0
- package/dist/ast/go/queries.d.ts.map +1 -0
- package/dist/ast/go/queries.js +114 -0
- package/dist/ast/go/utils.d.ts +66 -0
- package/dist/ast/go/utils.d.ts.map +1 -0
- package/dist/ast/go/utils.js +140 -0
- package/dist/ast/index.d.ts +39 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/index.js +245 -0
- package/dist/ast/php/index.d.ts +9 -0
- package/dist/ast/php/index.d.ts.map +1 -0
- package/dist/ast/php/index.js +8 -0
- package/dist/ast/php/parser.d.ts +31 -0
- package/dist/ast/php/parser.d.ts.map +1 -0
- package/dist/ast/php/parser.js +388 -0
- package/dist/ast/php/parser.test.d.ts +5 -0
- package/dist/ast/php/parser.test.d.ts.map +1 -0
- package/dist/ast/php/parser.test.js +328 -0
- package/dist/ast/php/queries.d.ts +61 -0
- package/dist/ast/php/queries.d.ts.map +1 -0
- package/dist/ast/php/queries.js +117 -0
- package/dist/ast/php/utils.d.ts +83 -0
- package/dist/ast/php/utils.d.ts.map +1 -0
- package/dist/ast/php/utils.js +246 -0
- package/dist/ast/python/index.d.ts +9 -0
- package/dist/ast/python/index.d.ts.map +1 -0
- package/dist/ast/python/index.js +8 -0
- package/dist/ast/python/parser.d.ts +32 -0
- package/dist/ast/python/parser.d.ts.map +1 -0
- package/dist/ast/python/parser.js +422 -0
- package/dist/ast/python/parser.test.d.ts +5 -0
- package/dist/ast/python/parser.test.d.ts.map +1 -0
- package/dist/ast/python/parser.test.js +186 -0
- package/dist/ast/python/queries.d.ts +73 -0
- package/dist/ast/python/queries.d.ts.map +1 -0
- package/dist/ast/python/queries.js +137 -0
- package/dist/ast/python/utils.d.ts +63 -0
- package/dist/ast/python/utils.d.ts.map +1 -0
- package/dist/ast/python/utils.js +159 -0
- package/dist/ast/quick-scan.d.ts +40 -0
- package/dist/ast/quick-scan.d.ts.map +1 -0
- package/dist/ast/quick-scan.js +287 -0
- package/dist/ast/rust/index.d.ts +9 -0
- package/dist/ast/rust/index.d.ts.map +1 -0
- package/dist/ast/rust/index.js +8 -0
- package/dist/ast/rust/parser.d.ts +31 -0
- package/dist/ast/rust/parser.d.ts.map +1 -0
- package/dist/ast/rust/parser.js +416 -0
- package/dist/ast/rust/parser.test.d.ts +5 -0
- package/dist/ast/rust/parser.test.d.ts.map +1 -0
- package/dist/ast/rust/parser.test.js +329 -0
- package/dist/ast/rust/queries.d.ts +66 -0
- package/dist/ast/rust/queries.d.ts.map +1 -0
- package/dist/ast/rust/queries.js +132 -0
- package/dist/ast/rust/utils.d.ts +91 -0
- package/dist/ast/rust/utils.d.ts.map +1 -0
- package/dist/ast/rust/utils.js +254 -0
- package/dist/ast/swift/index.d.ts +10 -0
- package/dist/ast/swift/index.d.ts.map +1 -0
- package/dist/ast/swift/index.js +8 -0
- package/dist/ast/swift/parser.d.ts +31 -0
- package/dist/ast/swift/parser.d.ts.map +1 -0
- package/dist/ast/swift/parser.js +554 -0
- package/dist/ast/swift/parser.test.d.ts +5 -0
- package/dist/ast/swift/parser.test.d.ts.map +1 -0
- package/dist/ast/swift/parser.test.js +398 -0
- package/dist/ast/swift/queries.d.ts +71 -0
- package/dist/ast/swift/queries.d.ts.map +1 -0
- package/dist/ast/swift/queries.js +137 -0
- package/dist/ast/swift/utils.d.ts +94 -0
- package/dist/ast/swift/utils.d.ts.map +1 -0
- package/dist/ast/swift/utils.js +411 -0
- package/dist/ast/types.d.ts +96 -0
- package/dist/ast/types.d.ts.map +1 -0
- package/dist/ast/types.js +21 -0
- package/dist/ast/typescript.d.ts +24 -0
- package/dist/ast/typescript.d.ts.map +1 -0
- package/dist/ast/typescript.js +357 -0
- package/dist/cache/file-hash.d.ts +33 -0
- package/dist/cache/file-hash.d.ts.map +1 -0
- package/dist/cache/file-hash.js +59 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +8 -0
- package/dist/cache/smart-cache.d.ts +68 -0
- package/dist/cache/smart-cache.d.ts.map +1 -0
- package/dist/cache/smart-cache.js +266 -0
- package/dist/cache/types.d.ts +102 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +6 -0
- package/dist/cli/analyze.d.ts +43 -0
- package/dist/cli/analyze.d.ts.map +1 -0
- package/dist/cli/analyze.js +250 -0
- package/dist/cli/doctor.d.ts +2 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +127 -0
- package/dist/cli/hooks.d.ts +14 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +229 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +4 -0
- package/dist/cli/setup.d.ts +10 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +117 -0
- package/dist/cli/utils.d.ts +30 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +116 -0
- package/dist/compressors/config.d.ts +9 -0
- package/dist/compressors/config.d.ts.map +1 -0
- package/dist/compressors/config.js +183 -0
- package/dist/compressors/conversation.d.ts +109 -0
- package/dist/compressors/conversation.d.ts.map +1 -0
- package/dist/compressors/conversation.js +404 -0
- package/dist/compressors/diff.d.ts +35 -0
- package/dist/compressors/diff.d.ts.map +1 -0
- package/dist/compressors/diff.js +389 -0
- package/dist/compressors/generic.d.ts +9 -0
- package/dist/compressors/generic.d.ts.map +1 -0
- package/dist/compressors/generic.js +188 -0
- package/dist/compressors/index.d.ts +31 -0
- package/dist/compressors/index.d.ts.map +1 -0
- package/dist/compressors/index.js +82 -0
- package/dist/compressors/logs.d.ts +9 -0
- package/dist/compressors/logs.d.ts.map +1 -0
- package/dist/compressors/logs.js +245 -0
- package/dist/compressors/multifile.d.ts +106 -0
- package/dist/compressors/multifile.d.ts.map +1 -0
- package/dist/compressors/multifile.js +498 -0
- package/dist/compressors/semantic.d.ts +33 -0
- package/dist/compressors/semantic.d.ts.map +1 -0
- package/dist/compressors/semantic.js +233 -0
- package/dist/compressors/stacktrace.d.ts +9 -0
- package/dist/compressors/stacktrace.d.ts.map +1 -0
- package/dist/compressors/stacktrace.js +259 -0
- package/dist/compressors/types.d.ts +146 -0
- package/dist/compressors/types.d.ts.map +1 -0
- package/dist/compressors/types.js +6 -0
- package/dist/config/output-config.d.ts +56 -0
- package/dist/config/output-config.d.ts.map +1 -0
- package/dist/config/output-config.js +78 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/middleware/chain.d.ts +49 -0
- package/dist/middleware/chain.d.ts.map +1 -0
- package/dist/middleware/chain.js +126 -0
- package/dist/middleware/index.d.ts +4 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +3 -0
- package/dist/middleware/logging.d.ts +8 -0
- package/dist/middleware/logging.d.ts.map +1 -0
- package/dist/middleware/logging.js +71 -0
- package/dist/middleware/types.d.ts +58 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/middleware/types.js +7 -0
- package/dist/parsers/eslint.d.ts +8 -0
- package/dist/parsers/eslint.d.ts.map +1 -0
- package/dist/parsers/eslint.js +132 -0
- package/dist/parsers/generic.d.ts +8 -0
- package/dist/parsers/generic.d.ts.map +1 -0
- package/dist/parsers/generic.js +234 -0
- package/dist/parsers/index.d.ts +34 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +216 -0
- package/dist/parsers/types.d.ts +84 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/types.js +6 -0
- package/dist/parsers/typescript.d.ts +8 -0
- package/dist/parsers/typescript.d.ts.map +1 -0
- package/dist/parsers/typescript.js +107 -0
- package/dist/pipelines/definitions.d.ts +50 -0
- package/dist/pipelines/definitions.d.ts.map +1 -0
- package/dist/pipelines/definitions.js +206 -0
- package/dist/sandbox/executor.d.ts +12 -0
- package/dist/sandbox/executor.d.ts.map +1 -0
- package/dist/sandbox/executor.js +191 -0
- package/dist/sandbox/index.d.ts +11 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +9 -0
- package/dist/sandbox/sandbox.test.d.ts +7 -0
- package/dist/sandbox/sandbox.test.d.ts.map +1 -0
- package/dist/sandbox/sandbox.test.js +202 -0
- package/dist/sandbox/sdk/analyze.d.ts +36 -0
- package/dist/sandbox/sdk/analyze.d.ts.map +1 -0
- package/dist/sandbox/sdk/analyze.js +413 -0
- package/dist/sandbox/sdk/analyze.test.d.ts +7 -0
- package/dist/sandbox/sdk/analyze.test.d.ts.map +1 -0
- package/dist/sandbox/sdk/analyze.test.js +191 -0
- package/dist/sandbox/sdk/code.d.ts +20 -0
- package/dist/sandbox/sdk/code.d.ts.map +1 -0
- package/dist/sandbox/sdk/code.js +104 -0
- package/dist/sandbox/sdk/compress.d.ts +23 -0
- package/dist/sandbox/sdk/compress.d.ts.map +1 -0
- package/dist/sandbox/sdk/compress.js +107 -0
- package/dist/sandbox/sdk/conversation.d.ts +148 -0
- package/dist/sandbox/sdk/conversation.d.ts.map +1 -0
- package/dist/sandbox/sdk/conversation.js +177 -0
- package/dist/sandbox/sdk/files.d.ts +29 -0
- package/dist/sandbox/sdk/files.d.ts.map +1 -0
- package/dist/sandbox/sdk/files.js +41 -0
- package/dist/sandbox/sdk/git.d.ts +37 -0
- package/dist/sandbox/sdk/git.d.ts.map +1 -0
- package/dist/sandbox/sdk/git.js +313 -0
- package/dist/sandbox/sdk/git.test.d.ts +8 -0
- package/dist/sandbox/sdk/git.test.d.ts.map +1 -0
- package/dist/sandbox/sdk/git.test.js +160 -0
- package/dist/sandbox/sdk/index.d.ts +16 -0
- package/dist/sandbox/sdk/index.d.ts.map +1 -0
- package/dist/sandbox/sdk/index.js +15 -0
- package/dist/sandbox/sdk/multifile.d.ts +63 -0
- package/dist/sandbox/sdk/multifile.d.ts.map +1 -0
- package/dist/sandbox/sdk/multifile.js +130 -0
- package/dist/sandbox/sdk/pipeline.d.ts +16 -0
- package/dist/sandbox/sdk/pipeline.d.ts.map +1 -0
- package/dist/sandbox/sdk/pipeline.js +454 -0
- package/dist/sandbox/sdk/pipeline.test.d.ts +7 -0
- package/dist/sandbox/sdk/pipeline.test.d.ts.map +1 -0
- package/dist/sandbox/sdk/pipeline.test.js +197 -0
- package/dist/sandbox/sdk/search.d.ts +36 -0
- package/dist/sandbox/sdk/search.d.ts.map +1 -0
- package/dist/sandbox/sdk/search.js +338 -0
- package/dist/sandbox/sdk/search.test.d.ts +7 -0
- package/dist/sandbox/sdk/search.test.d.ts.map +1 -0
- package/dist/sandbox/sdk/search.test.js +183 -0
- package/dist/sandbox/sdk/utils.d.ts +18 -0
- package/dist/sandbox/sdk/utils.d.ts.map +1 -0
- package/dist/sandbox/sdk/utils.js +24 -0
- package/dist/sandbox/security/code-analyzer.d.ts +15 -0
- package/dist/sandbox/security/code-analyzer.d.ts.map +1 -0
- package/dist/sandbox/security/code-analyzer.js +87 -0
- package/dist/sandbox/security/index.d.ts +6 -0
- package/dist/sandbox/security/index.d.ts.map +1 -0
- package/dist/sandbox/security/index.js +5 -0
- package/dist/sandbox/security/path-validator.d.ts +23 -0
- package/dist/sandbox/security/path-validator.d.ts.map +1 -0
- package/dist/sandbox/security/path-validator.js +113 -0
- package/dist/sandbox/types.d.ts +577 -0
- package/dist/sandbox/types.d.ts.map +1 -0
- package/dist/sandbox/types.js +14 -0
- package/dist/server.d.ts +36 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +133 -0
- package/dist/summarizers/build-logs.d.ts +11 -0
- package/dist/summarizers/build-logs.d.ts.map +1 -0
- package/dist/summarizers/build-logs.js +234 -0
- package/dist/summarizers/generic.d.ts +11 -0
- package/dist/summarizers/generic.d.ts.map +1 -0
- package/dist/summarizers/generic.js +93 -0
- package/dist/summarizers/index.d.ts +20 -0
- package/dist/summarizers/index.d.ts.map +1 -0
- package/dist/summarizers/index.js +43 -0
- package/dist/summarizers/server-logs.d.ts +11 -0
- package/dist/summarizers/server-logs.d.ts.map +1 -0
- package/dist/summarizers/server-logs.js +215 -0
- package/dist/summarizers/test-logs.d.ts +11 -0
- package/dist/summarizers/test-logs.d.ts.map +1 -0
- package/dist/summarizers/test-logs.js +258 -0
- package/dist/summarizers/types.d.ts +146 -0
- package/dist/summarizers/types.d.ts.map +1 -0
- package/dist/summarizers/types.js +21 -0
- package/dist/tools/analyze-build-output.d.ts +30 -0
- package/dist/tools/analyze-build-output.d.ts.map +1 -0
- package/dist/tools/analyze-build-output.js +45 -0
- package/dist/tools/analyze-context.d.ts +23 -0
- package/dist/tools/analyze-context.d.ts.map +1 -0
- package/dist/tools/analyze-context.js +78 -0
- package/dist/tools/auto-optimize.d.ts +9 -0
- package/dist/tools/auto-optimize.d.ts.map +1 -0
- package/dist/tools/auto-optimize.js +191 -0
- package/dist/tools/code-execute.d.ts +9 -0
- package/dist/tools/code-execute.d.ts.map +1 -0
- package/dist/tools/code-execute.js +84 -0
- package/dist/tools/code-skeleton.d.ts +33 -0
- package/dist/tools/code-skeleton.d.ts.map +1 -0
- package/dist/tools/code-skeleton.js +206 -0
- package/dist/tools/compress-context.d.ts +33 -0
- package/dist/tools/compress-context.d.ts.map +1 -0
- package/dist/tools/compress-context.js +64 -0
- package/dist/tools/context-budget.d.ts +43 -0
- package/dist/tools/context-budget.d.ts.map +1 -0
- package/dist/tools/context-budget.js +260 -0
- package/dist/tools/context-budget.test.d.ts +5 -0
- package/dist/tools/context-budget.test.d.ts.map +1 -0
- package/dist/tools/context-budget.test.js +219 -0
- package/dist/tools/conversation-compress.d.ts +46 -0
- package/dist/tools/conversation-compress.d.ts.map +1 -0
- package/dist/tools/conversation-compress.js +78 -0
- package/dist/tools/conversation-memory.d.ts +75 -0
- package/dist/tools/conversation-memory.d.ts.map +1 -0
- package/dist/tools/conversation-memory.js +289 -0
- package/dist/tools/deduplicate-errors.d.ts +30 -0
- package/dist/tools/deduplicate-errors.d.ts.map +1 -0
- package/dist/tools/deduplicate-errors.js +72 -0
- package/dist/tools/detect-retry-loop.d.ts +40 -0
- package/dist/tools/detect-retry-loop.d.ts.map +1 -0
- package/dist/tools/detect-retry-loop.js +212 -0
- package/dist/tools/diff-compress.d.ts +40 -0
- package/dist/tools/diff-compress.d.ts.map +1 -0
- package/dist/tools/diff-compress.js +94 -0
- package/dist/tools/discover-tools.d.ts +11 -0
- package/dist/tools/discover-tools.d.ts.map +1 -0
- package/dist/tools/discover-tools.js +163 -0
- package/dist/tools/dynamic-loader.d.ts +131 -0
- package/dist/tools/dynamic-loader.d.ts.map +1 -0
- package/dist/tools/dynamic-loader.js +378 -0
- package/dist/tools/dynamic-loader.test.d.ts +10 -0
- package/dist/tools/dynamic-loader.test.d.ts.map +1 -0
- package/dist/tools/dynamic-loader.test.js +164 -0
- package/dist/tools/lazy-mcp.d.ts +31 -0
- package/dist/tools/lazy-mcp.d.ts.map +1 -0
- package/dist/tools/lazy-mcp.js +151 -0
- package/dist/tools/lazy-mcp.test.d.ts +10 -0
- package/dist/tools/lazy-mcp.test.d.ts.map +1 -0
- package/dist/tools/lazy-mcp.test.js +172 -0
- package/dist/tools/multifile-compress.d.ts +36 -0
- package/dist/tools/multifile-compress.d.ts.map +1 -0
- package/dist/tools/multifile-compress.js +223 -0
- package/dist/tools/optimization-tips.d.ts +18 -0
- package/dist/tools/optimization-tips.d.ts.map +1 -0
- package/dist/tools/optimization-tips.js +133 -0
- package/dist/tools/registry.d.ts +70 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +169 -0
- package/dist/tools/semantic-compress.d.ts +39 -0
- package/dist/tools/semantic-compress.d.ts.map +1 -0
- package/dist/tools/semantic-compress.js +113 -0
- package/dist/tools/semantic-compress.test.d.ts +5 -0
- package/dist/tools/semantic-compress.test.d.ts.map +1 -0
- package/dist/tools/semantic-compress.test.js +182 -0
- package/dist/tools/session-stats.d.ts +34 -0
- package/dist/tools/session-stats.d.ts.map +1 -0
- package/dist/tools/session-stats.js +194 -0
- package/dist/tools/set-output-config.d.ts +38 -0
- package/dist/tools/set-output-config.d.ts.map +1 -0
- package/dist/tools/set-output-config.js +122 -0
- package/dist/tools/smart-cache-tool.d.ts +38 -0
- package/dist/tools/smart-cache-tool.d.ts.map +1 -0
- package/dist/tools/smart-cache-tool.js +224 -0
- package/dist/tools/smart-file-read.d.ts +52 -0
- package/dist/tools/smart-file-read.d.ts.map +1 -0
- package/dist/tools/smart-file-read.js +481 -0
- package/dist/tools/smart-pipeline.d.ts +40 -0
- package/dist/tools/smart-pipeline.d.ts.map +1 -0
- package/dist/tools/smart-pipeline.js +295 -0
- package/dist/tools/summarize-logs.d.ts +36 -0
- package/dist/tools/summarize-logs.d.ts.map +1 -0
- package/dist/tools/summarize-logs.js +184 -0
- package/dist/tools/token-budget.test.d.ts +11 -0
- package/dist/tools/token-budget.test.d.ts.map +1 -0
- package/dist/tools/token-budget.test.js +275 -0
- package/dist/utils/bm25.d.ts +86 -0
- package/dist/utils/bm25.d.ts.map +1 -0
- package/dist/utils/bm25.js +153 -0
- package/dist/utils/bm25.test.d.ts +5 -0
- package/dist/utils/bm25.test.d.ts.map +1 -0
- package/dist/utils/bm25.test.js +156 -0
- package/dist/utils/command-normalizer.d.ts +39 -0
- package/dist/utils/command-normalizer.d.ts.map +1 -0
- package/dist/utils/command-normalizer.js +90 -0
- package/dist/utils/content-detector.d.ts +27 -0
- package/dist/utils/content-detector.d.ts.map +1 -0
- package/dist/utils/content-detector.js +127 -0
- package/dist/utils/embeddings.d.ts +54 -0
- package/dist/utils/embeddings.d.ts.map +1 -0
- package/dist/utils/embeddings.js +97 -0
- package/dist/utils/embeddings.test.d.ts +8 -0
- package/dist/utils/embeddings.test.d.ts.map +1 -0
- package/dist/utils/embeddings.test.js +96 -0
- package/dist/utils/error-normalizer.d.ts +39 -0
- package/dist/utils/error-normalizer.d.ts.map +1 -0
- package/dist/utils/error-normalizer.js +233 -0
- package/dist/utils/hybrid-search.d.ts +79 -0
- package/dist/utils/hybrid-search.d.ts.map +1 -0
- package/dist/utils/hybrid-search.js +146 -0
- package/dist/utils/hybrid-search.test.d.ts +5 -0
- package/dist/utils/hybrid-search.test.d.ts.map +1 -0
- package/dist/utils/hybrid-search.test.js +172 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/language-detector.d.ts +27 -0
- package/dist/utils/language-detector.d.ts.map +1 -0
- package/dist/utils/language-detector.js +94 -0
- package/dist/utils/log-parser.d.ts +46 -0
- package/dist/utils/log-parser.d.ts.map +1 -0
- package/dist/utils/log-parser.js +287 -0
- package/dist/utils/output-estimator.d.ts +54 -0
- package/dist/utils/output-estimator.d.ts.map +1 -0
- package/dist/utils/output-estimator.js +119 -0
- package/dist/utils/output-estimator.test.d.ts +5 -0
- package/dist/utils/output-estimator.test.d.ts.map +1 -0
- package/dist/utils/output-estimator.test.js +115 -0
- package/dist/utils/output-similarity.d.ts +48 -0
- package/dist/utils/output-similarity.d.ts.map +1 -0
- package/dist/utils/output-similarity.js +140 -0
- package/dist/utils/project-detector.d.ts +16 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +119 -0
- package/dist/utils/segment-scorer.d.ts +99 -0
- package/dist/utils/segment-scorer.d.ts.map +1 -0
- package/dist/utils/segment-scorer.js +148 -0
- package/dist/utils/signature-grouper.d.ts +58 -0
- package/dist/utils/signature-grouper.d.ts.map +1 -0
- package/dist/utils/signature-grouper.js +185 -0
- package/dist/utils/tfidf.d.ts +45 -0
- package/dist/utils/tfidf.d.ts.map +1 -0
- package/dist/utils/tfidf.js +204 -0
- package/dist/utils/tfidf.test.d.ts +5 -0
- package/dist/utils/tfidf.test.d.ts.map +1 -0
- package/dist/utils/tfidf.test.js +115 -0
- package/dist/utils/token-counter.d.ts +35 -0
- package/dist/utils/token-counter.d.ts.map +1 -0
- package/dist/utils/token-counter.js +83 -0
- package/dist/utils/toon-serializer.d.ts +120 -0
- package/dist/utils/toon-serializer.d.ts.map +1 -0
- package/dist/utils/toon-serializer.js +472 -0
- package/dist/utils/toon-serializer.test.d.ts +7 -0
- package/dist/utils/toon-serializer.test.d.ts.map +1 -0
- package/dist/utils/toon-serializer.test.js +290 -0
- package/package.json +63 -0
- package/scripts/install.ps1 +133 -0
- package/scripts/install.sh +183 -0
- package/scripts/pre-commit-hook.sh +86 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust Tree-sitter Parser Tests
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect, beforeAll } from "vitest";
|
|
5
|
+
import { rustTreeSitterParser, parseRustAsync, initRustParser, } from "./parser.js";
|
|
6
|
+
// Sample Rust code for testing
|
|
7
|
+
const SAMPLE_RUST = `
|
|
8
|
+
use std::collections::HashMap;
|
|
9
|
+
use std::io::{self, Read, Write};
|
|
10
|
+
use serde::{Deserialize, Serialize};
|
|
11
|
+
|
|
12
|
+
/// Maximum allowed size for the buffer
|
|
13
|
+
pub const MAX_SIZE: usize = 1024;
|
|
14
|
+
|
|
15
|
+
/// Debug mode flag
|
|
16
|
+
static DEBUG: bool = false;
|
|
17
|
+
|
|
18
|
+
/// Represents a user in the system
|
|
19
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
20
|
+
pub struct User {
|
|
21
|
+
pub name: String,
|
|
22
|
+
pub age: u32,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
impl User {
|
|
26
|
+
/// Creates a new user with the given name and age
|
|
27
|
+
pub fn new(name: String, age: u32) -> Self {
|
|
28
|
+
Self { name, age }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Returns a greeting message
|
|
32
|
+
pub fn greet(&self) -> String {
|
|
33
|
+
format!("Hello, {}!", self.name)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// Fetches user data as a map
|
|
37
|
+
async fn fetch_data(&self) -> HashMap<String, String> {
|
|
38
|
+
let mut data = HashMap::new();
|
|
39
|
+
data.insert("name".to_string(), self.name.clone());
|
|
40
|
+
data
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Admin user with additional permissions
|
|
45
|
+
pub struct AdminUser {
|
|
46
|
+
user: User,
|
|
47
|
+
permissions: Vec<String>,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
impl AdminUser {
|
|
51
|
+
/// Checks if the admin has a specific permission
|
|
52
|
+
pub fn has_permission(&self, perm: &str) -> bool {
|
|
53
|
+
self.permissions.iter().any(|p| p == perm)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Represents different error types
|
|
58
|
+
pub enum AppError {
|
|
59
|
+
NotFound,
|
|
60
|
+
Unauthorized,
|
|
61
|
+
InternalError(String),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// Handler trait for processing requests
|
|
65
|
+
pub trait Handler {
|
|
66
|
+
/// Handles the incoming request
|
|
67
|
+
fn handle(&self, request: &str) -> Result<String, AppError>;
|
|
68
|
+
|
|
69
|
+
/// Gets the handler name
|
|
70
|
+
fn name(&self) -> &str;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Calculates the sum of numbers
|
|
74
|
+
pub fn calculate_sum(numbers: &[i32]) -> i32 {
|
|
75
|
+
numbers.iter().sum()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// Private function for internal use
|
|
79
|
+
fn private_func() {
|
|
80
|
+
// internal function
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// Async function that processes data
|
|
84
|
+
pub async fn process_data(data: &str) -> Result<String, io::Error> {
|
|
85
|
+
Ok(data.to_uppercase())
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// Type alias for a result type
|
|
89
|
+
pub type AppResult<T> = Result<T, AppError>;
|
|
90
|
+
|
|
91
|
+
/// Module for utilities
|
|
92
|
+
mod utils {
|
|
93
|
+
pub fn helper() {}
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
describe("Rust Tree-sitter Parser", () => {
|
|
97
|
+
beforeAll(async () => {
|
|
98
|
+
await initRustParser();
|
|
99
|
+
});
|
|
100
|
+
describe("parseRustAsync", () => {
|
|
101
|
+
it("should parse use statements correctly", async () => {
|
|
102
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
103
|
+
expect(structure.language).toBe("rust");
|
|
104
|
+
expect(structure.imports.length).toBeGreaterThanOrEqual(3);
|
|
105
|
+
const importNames = structure.imports.map((i) => i.name);
|
|
106
|
+
expect(importNames).toContain("HashMap");
|
|
107
|
+
expect(importNames.some((n) => n.includes("Read") || n.includes("Write"))).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
it("should parse functions correctly", async () => {
|
|
110
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
111
|
+
const funcNames = structure.functions.map((f) => f.name);
|
|
112
|
+
expect(funcNames).toContain("calculate_sum");
|
|
113
|
+
expect(funcNames).toContain("private_func");
|
|
114
|
+
expect(funcNames).toContain("process_data");
|
|
115
|
+
});
|
|
116
|
+
it("should detect exported functions (pub)", async () => {
|
|
117
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
118
|
+
const calcSum = structure.functions.find((f) => f.name === "calculate_sum");
|
|
119
|
+
expect(calcSum?.isExported).toBe(true);
|
|
120
|
+
const privateFunc = structure.functions.find((f) => f.name === "private_func");
|
|
121
|
+
expect(privateFunc?.isExported).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
it("should detect async functions", async () => {
|
|
124
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
125
|
+
const processData = structure.functions.find((f) => f.name === "process_data");
|
|
126
|
+
expect(processData?.isAsync).toBe(true);
|
|
127
|
+
const calcSum = structure.functions.find((f) => f.name === "calculate_sum");
|
|
128
|
+
expect(calcSum?.isAsync).toBeFalsy();
|
|
129
|
+
});
|
|
130
|
+
it("should parse methods from impl blocks", async () => {
|
|
131
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
132
|
+
const methods = structure.functions.filter((f) => f.type === "method");
|
|
133
|
+
expect(methods.length).toBeGreaterThanOrEqual(4);
|
|
134
|
+
const methodNames = methods.map((m) => m.name);
|
|
135
|
+
expect(methodNames).toContain("new");
|
|
136
|
+
expect(methodNames).toContain("greet");
|
|
137
|
+
expect(methodNames).toContain("fetch_data");
|
|
138
|
+
expect(methodNames).toContain("has_permission");
|
|
139
|
+
});
|
|
140
|
+
it("should track parent type for methods", async () => {
|
|
141
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
142
|
+
const greet = structure.functions.find((f) => f.name === "greet");
|
|
143
|
+
expect(greet?.parent).toBe("User");
|
|
144
|
+
const hasPermission = structure.functions.find((f) => f.name === "has_permission");
|
|
145
|
+
expect(hasPermission?.parent).toBe("AdminUser");
|
|
146
|
+
});
|
|
147
|
+
it("should parse structs as classes", async () => {
|
|
148
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
149
|
+
expect(structure.classes.length).toBeGreaterThanOrEqual(2);
|
|
150
|
+
const classNames = structure.classes.map((c) => c.name);
|
|
151
|
+
expect(classNames).toContain("User");
|
|
152
|
+
expect(classNames).toContain("AdminUser");
|
|
153
|
+
});
|
|
154
|
+
it("should parse enums as classes", async () => {
|
|
155
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
156
|
+
const classNames = structure.classes.map((c) => c.name);
|
|
157
|
+
expect(classNames).toContain("AppError");
|
|
158
|
+
});
|
|
159
|
+
it("should detect exported structs (pub)", async () => {
|
|
160
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
161
|
+
const user = structure.classes.find((c) => c.name === "User");
|
|
162
|
+
expect(user?.isExported).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
it("should parse traits as interfaces", async () => {
|
|
165
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
166
|
+
expect(structure.interfaces.length).toBeGreaterThanOrEqual(1);
|
|
167
|
+
const interfaceNames = structure.interfaces.map((i) => i.name);
|
|
168
|
+
expect(interfaceNames).toContain("Handler");
|
|
169
|
+
});
|
|
170
|
+
it("should extract doc comments", async () => {
|
|
171
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
172
|
+
const userStruct = structure.classes.find((c) => c.name === "User");
|
|
173
|
+
expect(userStruct?.documentation).toContain("Represents a user");
|
|
174
|
+
const calcSum = structure.functions.find((f) => f.name === "calculate_sum");
|
|
175
|
+
expect(calcSum?.documentation).toContain("Calculates the sum");
|
|
176
|
+
});
|
|
177
|
+
it("should parse constants", async () => {
|
|
178
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
179
|
+
const varNames = structure.variables.map((v) => v.name);
|
|
180
|
+
expect(varNames).toContain("MAX_SIZE");
|
|
181
|
+
});
|
|
182
|
+
it("should parse static variables", async () => {
|
|
183
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
184
|
+
const varNames = structure.variables.map((v) => v.name);
|
|
185
|
+
expect(varNames).toContain("DEBUG");
|
|
186
|
+
});
|
|
187
|
+
it("should parse type aliases", async () => {
|
|
188
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
189
|
+
const typeNames = structure.types.map((t) => t.name);
|
|
190
|
+
expect(typeNames).toContain("AppResult");
|
|
191
|
+
});
|
|
192
|
+
it("should return correct line numbers", async () => {
|
|
193
|
+
const structure = await parseRustAsync(SAMPLE_RUST);
|
|
194
|
+
const userStruct = structure.classes.find((c) => c.name === "User");
|
|
195
|
+
expect(userStruct?.startLine).toBeGreaterThan(0);
|
|
196
|
+
expect(userStruct?.endLine).toBeGreaterThan(userStruct?.startLine ?? 0);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
describe("LanguageParser interface", () => {
|
|
200
|
+
it("should implement parse() method", () => {
|
|
201
|
+
const structure = rustTreeSitterParser.parse(SAMPLE_RUST);
|
|
202
|
+
expect(structure).toBeDefined();
|
|
203
|
+
expect(structure.language).toBe("rust");
|
|
204
|
+
});
|
|
205
|
+
it("should implement extractElement() method for functions", async () => {
|
|
206
|
+
await initRustParser();
|
|
207
|
+
const result = rustTreeSitterParser.extractElement(SAMPLE_RUST, { type: "function", name: "calculate_sum" }, { includeImports: true, includeComments: true });
|
|
208
|
+
expect(result).not.toBeNull();
|
|
209
|
+
expect(result?.content).toContain("fn calculate_sum");
|
|
210
|
+
expect(result?.elements[0]?.name).toBe("calculate_sum");
|
|
211
|
+
});
|
|
212
|
+
it("should extract methods by name", async () => {
|
|
213
|
+
await initRustParser();
|
|
214
|
+
const result = rustTreeSitterParser.extractElement(SAMPLE_RUST, { type: "method", name: "greet" }, { includeImports: false, includeComments: true });
|
|
215
|
+
expect(result).not.toBeNull();
|
|
216
|
+
expect(result?.content).toContain("fn greet");
|
|
217
|
+
});
|
|
218
|
+
it("should extract structs by name", async () => {
|
|
219
|
+
await initRustParser();
|
|
220
|
+
const result = rustTreeSitterParser.extractElement(SAMPLE_RUST, { type: "class", name: "User" }, { includeImports: false, includeComments: true });
|
|
221
|
+
expect(result).not.toBeNull();
|
|
222
|
+
expect(result?.content).toContain("pub struct User");
|
|
223
|
+
});
|
|
224
|
+
it("should implement searchElements() method", async () => {
|
|
225
|
+
await initRustParser();
|
|
226
|
+
const results = rustTreeSitterParser.searchElements(SAMPLE_RUST, "user");
|
|
227
|
+
expect(results.length).toBeGreaterThan(0);
|
|
228
|
+
const names = results.map((r) => r.name.toLowerCase());
|
|
229
|
+
expect(names.some((n) => n.includes("user"))).toBe(true);
|
|
230
|
+
});
|
|
231
|
+
it("should return null for non-existent elements", async () => {
|
|
232
|
+
await initRustParser();
|
|
233
|
+
const result = rustTreeSitterParser.extractElement(SAMPLE_RUST, { type: "function", name: "non_existent_func" }, { includeImports: false, includeComments: false });
|
|
234
|
+
expect(result).toBeNull();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
describe("Edge cases", () => {
|
|
238
|
+
it("should handle empty content", async () => {
|
|
239
|
+
const structure = await parseRustAsync("");
|
|
240
|
+
expect(structure.language).toBe("rust");
|
|
241
|
+
expect(structure.totalLines).toBe(1);
|
|
242
|
+
expect(structure.functions).toHaveLength(0);
|
|
243
|
+
});
|
|
244
|
+
it("should handle simple use statement", async () => {
|
|
245
|
+
const code = `
|
|
246
|
+
use std::io;
|
|
247
|
+
|
|
248
|
+
fn main() {}
|
|
249
|
+
`;
|
|
250
|
+
const structure = await parseRustAsync(code);
|
|
251
|
+
expect(structure.imports.length).toBeGreaterThanOrEqual(1);
|
|
252
|
+
});
|
|
253
|
+
it("should handle use with as alias", async () => {
|
|
254
|
+
const code = `
|
|
255
|
+
use std::collections::HashMap as Map;
|
|
256
|
+
use std::io::Result as IoResult;
|
|
257
|
+
`;
|
|
258
|
+
const structure = await parseRustAsync(code);
|
|
259
|
+
expect(structure.imports.length).toBeGreaterThanOrEqual(2);
|
|
260
|
+
});
|
|
261
|
+
it("should handle glob imports", async () => {
|
|
262
|
+
const code = `
|
|
263
|
+
use std::collections::*;
|
|
264
|
+
`;
|
|
265
|
+
const structure = await parseRustAsync(code);
|
|
266
|
+
expect(structure.imports.length).toBeGreaterThanOrEqual(1);
|
|
267
|
+
});
|
|
268
|
+
it("should handle nested modules in use", async () => {
|
|
269
|
+
const code = `
|
|
270
|
+
use std::{
|
|
271
|
+
collections::{HashMap, HashSet},
|
|
272
|
+
io::{self, Read, Write},
|
|
273
|
+
};
|
|
274
|
+
`;
|
|
275
|
+
const structure = await parseRustAsync(code);
|
|
276
|
+
expect(structure.imports.length).toBeGreaterThanOrEqual(1);
|
|
277
|
+
});
|
|
278
|
+
it("should handle impl for trait", async () => {
|
|
279
|
+
const code = `
|
|
280
|
+
pub trait Greet {
|
|
281
|
+
fn greet(&self) -> String;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
pub struct Person {
|
|
285
|
+
name: String,
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
impl Greet for Person {
|
|
289
|
+
fn greet(&self) -> String {
|
|
290
|
+
format!("Hello, {}!", self.name)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
`;
|
|
294
|
+
const structure = await parseRustAsync(code);
|
|
295
|
+
expect(structure.interfaces.length).toBeGreaterThanOrEqual(1);
|
|
296
|
+
expect(structure.classes.length).toBeGreaterThanOrEqual(1);
|
|
297
|
+
expect(structure.functions.filter((f) => f.type === "method").length).toBeGreaterThanOrEqual(1);
|
|
298
|
+
});
|
|
299
|
+
it("should handle generic types", async () => {
|
|
300
|
+
const code = `
|
|
301
|
+
pub struct Container<T> {
|
|
302
|
+
value: T,
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
impl<T> Container<T> {
|
|
306
|
+
pub fn new(value: T) -> Self {
|
|
307
|
+
Self { value }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
const structure = await parseRustAsync(code);
|
|
312
|
+
expect(structure.classes.some((c) => c.name === "Container")).toBe(true);
|
|
313
|
+
});
|
|
314
|
+
it("should handle async methods", async () => {
|
|
315
|
+
const code = `
|
|
316
|
+
pub struct Client {}
|
|
317
|
+
|
|
318
|
+
impl Client {
|
|
319
|
+
pub async fn fetch(&self) -> Result<String, Error> {
|
|
320
|
+
Ok("data".to_string())
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
`;
|
|
324
|
+
const structure = await parseRustAsync(code);
|
|
325
|
+
const fetchMethod = structure.functions.find((f) => f.name === "fetch");
|
|
326
|
+
expect(fetchMethod?.isAsync).toBe(true);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust Tree-sitter Queries
|
|
3
|
+
*
|
|
4
|
+
* S-expression queries for extracting Rust code elements.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Query to find all function declarations
|
|
8
|
+
*/
|
|
9
|
+
export declare const FUNCTION_QUERY = "\n(function_item\n name: (identifier) @name) @function\n";
|
|
10
|
+
/**
|
|
11
|
+
* Query to find all struct declarations
|
|
12
|
+
*/
|
|
13
|
+
export declare const STRUCT_QUERY = "\n(struct_item\n name: (type_identifier) @name) @struct\n";
|
|
14
|
+
/**
|
|
15
|
+
* Query to find all enum declarations
|
|
16
|
+
*/
|
|
17
|
+
export declare const ENUM_QUERY = "\n(enum_item\n name: (type_identifier) @name) @enum\n";
|
|
18
|
+
/**
|
|
19
|
+
* Query to find all trait declarations
|
|
20
|
+
*/
|
|
21
|
+
export declare const TRAIT_QUERY = "\n(trait_item\n name: (type_identifier) @name) @trait\n";
|
|
22
|
+
/**
|
|
23
|
+
* Query to find all impl blocks
|
|
24
|
+
*/
|
|
25
|
+
export declare const IMPL_QUERY = "\n(impl_item\n type: (type_identifier) @impl_type) @impl\n";
|
|
26
|
+
/**
|
|
27
|
+
* Query to find all use declarations (imports)
|
|
28
|
+
*/
|
|
29
|
+
export declare const USE_QUERY = "\n(use_declaration) @use\n";
|
|
30
|
+
/**
|
|
31
|
+
* Query to find type aliases
|
|
32
|
+
*/
|
|
33
|
+
export declare const TYPE_ALIAS_QUERY = "\n(type_item\n name: (type_identifier) @name) @type_alias\n";
|
|
34
|
+
/**
|
|
35
|
+
* Query to find const declarations
|
|
36
|
+
*/
|
|
37
|
+
export declare const CONST_QUERY = "\n(const_item\n name: (identifier) @name) @const\n";
|
|
38
|
+
/**
|
|
39
|
+
* Query to find static declarations
|
|
40
|
+
*/
|
|
41
|
+
export declare const STATIC_QUERY = "\n(static_item\n name: (identifier) @name) @static\n";
|
|
42
|
+
/**
|
|
43
|
+
* Query to find module declarations
|
|
44
|
+
*/
|
|
45
|
+
export declare const MOD_QUERY = "\n(mod_item\n name: (identifier) @name) @mod\n";
|
|
46
|
+
/**
|
|
47
|
+
* Combined query for all definitions
|
|
48
|
+
*/
|
|
49
|
+
export declare const ALL_DEFINITIONS_QUERY = "\n; Use declarations (imports)\n(use_declaration) @use_decl\n\n; Function declarations\n(function_item\n name: (identifier) @func_name) @function\n\n; Struct declarations\n(struct_item\n name: (type_identifier) @struct_name) @struct\n\n; Enum declarations\n(enum_item\n name: (type_identifier) @enum_name) @enum\n\n; Trait declarations\n(trait_item\n name: (type_identifier) @trait_name) @trait\n\n; Impl blocks\n(impl_item) @impl\n\n; Type aliases\n(type_item\n name: (type_identifier) @type_name) @type_alias\n\n; Const declarations\n(const_item\n name: (identifier) @const_name) @const\n\n; Static declarations\n(static_item\n name: (identifier) @static_name) @static\n\n; Module declarations\n(mod_item\n name: (identifier) @mod_name) @mod\n";
|
|
50
|
+
/**
|
|
51
|
+
* Query patterns as a single object for easy access
|
|
52
|
+
*/
|
|
53
|
+
export declare const QUERIES: {
|
|
54
|
+
readonly function: "\n(function_item\n name: (identifier) @name) @function\n";
|
|
55
|
+
readonly struct: "\n(struct_item\n name: (type_identifier) @name) @struct\n";
|
|
56
|
+
readonly enum: "\n(enum_item\n name: (type_identifier) @name) @enum\n";
|
|
57
|
+
readonly trait: "\n(trait_item\n name: (type_identifier) @name) @trait\n";
|
|
58
|
+
readonly impl: "\n(impl_item\n type: (type_identifier) @impl_type) @impl\n";
|
|
59
|
+
readonly use: "\n(use_declaration) @use\n";
|
|
60
|
+
readonly typeAlias: "\n(type_item\n name: (type_identifier) @name) @type_alias\n";
|
|
61
|
+
readonly const: "\n(const_item\n name: (identifier) @name) @const\n";
|
|
62
|
+
readonly static: "\n(static_item\n name: (identifier) @name) @static\n";
|
|
63
|
+
readonly mod: "\n(mod_item\n name: (identifier) @name) @mod\n";
|
|
64
|
+
readonly all: "\n; Use declarations (imports)\n(use_declaration) @use_decl\n\n; Function declarations\n(function_item\n name: (identifier) @func_name) @function\n\n; Struct declarations\n(struct_item\n name: (type_identifier) @struct_name) @struct\n\n; Enum declarations\n(enum_item\n name: (type_identifier) @enum_name) @enum\n\n; Trait declarations\n(trait_item\n name: (type_identifier) @trait_name) @trait\n\n; Impl blocks\n(impl_item) @impl\n\n; Type aliases\n(type_item\n name: (type_identifier) @type_name) @type_alias\n\n; Const declarations\n(const_item\n name: (identifier) @const_name) @const\n\n; Static declarations\n(static_item\n name: (identifier) @static_name) @static\n\n; Module declarations\n(mod_item\n name: (identifier) @mod_name) @mod\n";
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/ast/rust/queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,8DAG1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,+DAGxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,2DAGtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,6DAGvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,gEAGtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,+BAErB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,iEAG5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,wDAGvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,0DAGxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,oDAGrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,svBAsCjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;CAYV,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust Tree-sitter Queries
|
|
3
|
+
*
|
|
4
|
+
* S-expression queries for extracting Rust code elements.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Query to find all function declarations
|
|
8
|
+
*/
|
|
9
|
+
export const FUNCTION_QUERY = `
|
|
10
|
+
(function_item
|
|
11
|
+
name: (identifier) @name) @function
|
|
12
|
+
`;
|
|
13
|
+
/**
|
|
14
|
+
* Query to find all struct declarations
|
|
15
|
+
*/
|
|
16
|
+
export const STRUCT_QUERY = `
|
|
17
|
+
(struct_item
|
|
18
|
+
name: (type_identifier) @name) @struct
|
|
19
|
+
`;
|
|
20
|
+
/**
|
|
21
|
+
* Query to find all enum declarations
|
|
22
|
+
*/
|
|
23
|
+
export const ENUM_QUERY = `
|
|
24
|
+
(enum_item
|
|
25
|
+
name: (type_identifier) @name) @enum
|
|
26
|
+
`;
|
|
27
|
+
/**
|
|
28
|
+
* Query to find all trait declarations
|
|
29
|
+
*/
|
|
30
|
+
export const TRAIT_QUERY = `
|
|
31
|
+
(trait_item
|
|
32
|
+
name: (type_identifier) @name) @trait
|
|
33
|
+
`;
|
|
34
|
+
/**
|
|
35
|
+
* Query to find all impl blocks
|
|
36
|
+
*/
|
|
37
|
+
export const IMPL_QUERY = `
|
|
38
|
+
(impl_item
|
|
39
|
+
type: (type_identifier) @impl_type) @impl
|
|
40
|
+
`;
|
|
41
|
+
/**
|
|
42
|
+
* Query to find all use declarations (imports)
|
|
43
|
+
*/
|
|
44
|
+
export const USE_QUERY = `
|
|
45
|
+
(use_declaration) @use
|
|
46
|
+
`;
|
|
47
|
+
/**
|
|
48
|
+
* Query to find type aliases
|
|
49
|
+
*/
|
|
50
|
+
export const TYPE_ALIAS_QUERY = `
|
|
51
|
+
(type_item
|
|
52
|
+
name: (type_identifier) @name) @type_alias
|
|
53
|
+
`;
|
|
54
|
+
/**
|
|
55
|
+
* Query to find const declarations
|
|
56
|
+
*/
|
|
57
|
+
export const CONST_QUERY = `
|
|
58
|
+
(const_item
|
|
59
|
+
name: (identifier) @name) @const
|
|
60
|
+
`;
|
|
61
|
+
/**
|
|
62
|
+
* Query to find static declarations
|
|
63
|
+
*/
|
|
64
|
+
export const STATIC_QUERY = `
|
|
65
|
+
(static_item
|
|
66
|
+
name: (identifier) @name) @static
|
|
67
|
+
`;
|
|
68
|
+
/**
|
|
69
|
+
* Query to find module declarations
|
|
70
|
+
*/
|
|
71
|
+
export const MOD_QUERY = `
|
|
72
|
+
(mod_item
|
|
73
|
+
name: (identifier) @name) @mod
|
|
74
|
+
`;
|
|
75
|
+
/**
|
|
76
|
+
* Combined query for all definitions
|
|
77
|
+
*/
|
|
78
|
+
export const ALL_DEFINITIONS_QUERY = `
|
|
79
|
+
; Use declarations (imports)
|
|
80
|
+
(use_declaration) @use_decl
|
|
81
|
+
|
|
82
|
+
; Function declarations
|
|
83
|
+
(function_item
|
|
84
|
+
name: (identifier) @func_name) @function
|
|
85
|
+
|
|
86
|
+
; Struct declarations
|
|
87
|
+
(struct_item
|
|
88
|
+
name: (type_identifier) @struct_name) @struct
|
|
89
|
+
|
|
90
|
+
; Enum declarations
|
|
91
|
+
(enum_item
|
|
92
|
+
name: (type_identifier) @enum_name) @enum
|
|
93
|
+
|
|
94
|
+
; Trait declarations
|
|
95
|
+
(trait_item
|
|
96
|
+
name: (type_identifier) @trait_name) @trait
|
|
97
|
+
|
|
98
|
+
; Impl blocks
|
|
99
|
+
(impl_item) @impl
|
|
100
|
+
|
|
101
|
+
; Type aliases
|
|
102
|
+
(type_item
|
|
103
|
+
name: (type_identifier) @type_name) @type_alias
|
|
104
|
+
|
|
105
|
+
; Const declarations
|
|
106
|
+
(const_item
|
|
107
|
+
name: (identifier) @const_name) @const
|
|
108
|
+
|
|
109
|
+
; Static declarations
|
|
110
|
+
(static_item
|
|
111
|
+
name: (identifier) @static_name) @static
|
|
112
|
+
|
|
113
|
+
; Module declarations
|
|
114
|
+
(mod_item
|
|
115
|
+
name: (identifier) @mod_name) @mod
|
|
116
|
+
`;
|
|
117
|
+
/**
|
|
118
|
+
* Query patterns as a single object for easy access
|
|
119
|
+
*/
|
|
120
|
+
export const QUERIES = {
|
|
121
|
+
function: FUNCTION_QUERY,
|
|
122
|
+
struct: STRUCT_QUERY,
|
|
123
|
+
enum: ENUM_QUERY,
|
|
124
|
+
trait: TRAIT_QUERY,
|
|
125
|
+
impl: IMPL_QUERY,
|
|
126
|
+
use: USE_QUERY,
|
|
127
|
+
typeAlias: TYPE_ALIAS_QUERY,
|
|
128
|
+
const: CONST_QUERY,
|
|
129
|
+
static: STATIC_QUERY,
|
|
130
|
+
mod: MOD_QUERY,
|
|
131
|
+
all: ALL_DEFINITIONS_QUERY,
|
|
132
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust Parser Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for converting Tree-sitter nodes to CodeElements
|
|
5
|
+
* and extracting Rust-specific constructs.
|
|
6
|
+
*/
|
|
7
|
+
import type Parser from "web-tree-sitter";
|
|
8
|
+
type Node = Parser.SyntaxNode;
|
|
9
|
+
import type { CodeElement, ElementType } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Get line number from a Tree-sitter node (1-indexed)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getLineNumber(node: Node): number;
|
|
14
|
+
/**
|
|
15
|
+
* Get end line number from a Tree-sitter node (1-indexed)
|
|
16
|
+
*/
|
|
17
|
+
export declare function getEndLineNumber(node: Node): number;
|
|
18
|
+
/**
|
|
19
|
+
* Extract Rust doc comment from above a declaration
|
|
20
|
+
* Rust uses /// and //! for doc comments, or block doc comments
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractRustDoc(node: Node, lines: string[]): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a node has a visibility modifier (pub, pub(crate), etc.)
|
|
25
|
+
*/
|
|
26
|
+
export declare function hasVisibility(node: Node): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get visibility string from a node
|
|
29
|
+
*/
|
|
30
|
+
export declare function getVisibility(node: Node): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a function is async
|
|
33
|
+
*/
|
|
34
|
+
export declare function isAsyncFn(node: Node): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get function signature from a function_item node
|
|
37
|
+
*/
|
|
38
|
+
export declare function getFunctionSignature(node: Node): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get struct signature
|
|
41
|
+
*/
|
|
42
|
+
export declare function getStructSignature(node: Node): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get enum signature
|
|
45
|
+
*/
|
|
46
|
+
export declare function getEnumSignature(node: Node): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get trait signature
|
|
49
|
+
*/
|
|
50
|
+
export declare function getTraitSignature(node: Node): string;
|
|
51
|
+
/**
|
|
52
|
+
* Get impl block signature
|
|
53
|
+
*/
|
|
54
|
+
export declare function getImplSignature(node: Node): string;
|
|
55
|
+
/**
|
|
56
|
+
* Get the type name from an impl block
|
|
57
|
+
*/
|
|
58
|
+
export declare function getImplTypeName(node: Node): string;
|
|
59
|
+
/**
|
|
60
|
+
* Get the trait name from an impl block (if implementing a trait)
|
|
61
|
+
*/
|
|
62
|
+
export declare function getImplTraitName(node: Node): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Extract the use path from a use_declaration
|
|
65
|
+
*/
|
|
66
|
+
export declare function getUsePath(node: Node): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get the short name from a use path
|
|
69
|
+
* e.g., "std::collections::HashMap" -> "HashMap"
|
|
70
|
+
*/
|
|
71
|
+
export declare function getUseShortName(usePath: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get const/static signature
|
|
74
|
+
*/
|
|
75
|
+
export declare function getConstSignature(node: Node, kind: "const" | "static"): string;
|
|
76
|
+
/**
|
|
77
|
+
* Get type alias signature
|
|
78
|
+
*/
|
|
79
|
+
export declare function getTypeAliasSignature(node: Node): string;
|
|
80
|
+
/**
|
|
81
|
+
* Create a CodeElement from a Tree-sitter node
|
|
82
|
+
*/
|
|
83
|
+
export declare function createCodeElement(type: ElementType, name: string, node: Node, options?: {
|
|
84
|
+
signature?: string;
|
|
85
|
+
documentation?: string;
|
|
86
|
+
isAsync?: boolean;
|
|
87
|
+
isExported?: boolean;
|
|
88
|
+
parent?: string;
|
|
89
|
+
}): CodeElement;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ast/rust/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,KAAK,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CA8B9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAWjD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAO5D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAW7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAgBvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAOrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAOnD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAOpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAUnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAG/D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAY7C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA4BvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAS9E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAOxD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,WAAW,CAYb"}
|