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,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Tree-sitter Queries
|
|
3
|
+
*
|
|
4
|
+
* S-expression queries for extracting Go code elements.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Query to find all function declarations
|
|
8
|
+
*/
|
|
9
|
+
export declare const FUNCTION_QUERY = "\n(function_declaration\n name: (identifier) @name) @function\n";
|
|
10
|
+
/**
|
|
11
|
+
* Query to find all method declarations
|
|
12
|
+
*/
|
|
13
|
+
export declare const METHOD_QUERY = "\n(method_declaration\n receiver: (parameter_list) @receiver\n name: (field_identifier) @name) @method\n";
|
|
14
|
+
/**
|
|
15
|
+
* Query to find all type declarations (struct, interface)
|
|
16
|
+
*/
|
|
17
|
+
export declare const TYPE_QUERY = "\n(type_declaration\n (type_spec\n name: (type_identifier) @name\n type: [\n (struct_type) @struct\n (interface_type) @interface\n ])) @type\n";
|
|
18
|
+
/**
|
|
19
|
+
* Query to find all import declarations
|
|
20
|
+
*/
|
|
21
|
+
export declare const IMPORT_QUERY = "\n[\n (import_declaration\n (import_spec) @import)\n (import_declaration\n (import_spec_list\n (import_spec) @import))\n]\n";
|
|
22
|
+
/**
|
|
23
|
+
* Query to find package-level variable declarations
|
|
24
|
+
*/
|
|
25
|
+
export declare const VARIABLE_QUERY = "\n(source_file\n (var_declaration\n (var_spec\n name: (identifier) @name)) @variable)\n";
|
|
26
|
+
/**
|
|
27
|
+
* Query to find package-level constant declarations
|
|
28
|
+
*/
|
|
29
|
+
export declare const CONST_QUERY = "\n(source_file\n (const_declaration\n (const_spec\n name: (identifier) @name)) @constant)\n";
|
|
30
|
+
/**
|
|
31
|
+
* Query to find type aliases
|
|
32
|
+
*/
|
|
33
|
+
export declare const TYPE_ALIAS_QUERY = "\n(type_declaration\n (type_spec\n name: (type_identifier) @name\n type: (type_identifier) @alias_type)) @type_alias\n";
|
|
34
|
+
/**
|
|
35
|
+
* Combined query for common elements
|
|
36
|
+
*/
|
|
37
|
+
export declare const ALL_DEFINITIONS_QUERY = "\n; Package declaration\n(package_clause\n (package_identifier) @package_name) @package\n\n; Import declarations\n(import_declaration) @import_decl\n\n; Function declarations\n(function_declaration\n name: (identifier) @func_name) @function\n\n; Method declarations\n(method_declaration\n name: (field_identifier) @method_name) @method\n\n; Type declarations\n(type_declaration\n (type_spec\n name: (type_identifier) @type_name)) @type\n\n; Variable declarations\n(var_declaration) @var_decl\n\n; Constant declarations\n(const_declaration) @const_decl\n";
|
|
38
|
+
/**
|
|
39
|
+
* Query patterns as a single object for easy access
|
|
40
|
+
*/
|
|
41
|
+
export declare const QUERIES: {
|
|
42
|
+
readonly function: "\n(function_declaration\n name: (identifier) @name) @function\n";
|
|
43
|
+
readonly method: "\n(method_declaration\n receiver: (parameter_list) @receiver\n name: (field_identifier) @name) @method\n";
|
|
44
|
+
readonly type: "\n(type_declaration\n (type_spec\n name: (type_identifier) @name\n type: [\n (struct_type) @struct\n (interface_type) @interface\n ])) @type\n";
|
|
45
|
+
readonly import: "\n[\n (import_declaration\n (import_spec) @import)\n (import_declaration\n (import_spec_list\n (import_spec) @import))\n]\n";
|
|
46
|
+
readonly variable: "\n(source_file\n (var_declaration\n (var_spec\n name: (identifier) @name)) @variable)\n";
|
|
47
|
+
readonly constant: "\n(source_file\n (const_declaration\n (const_spec\n name: (identifier) @name)) @constant)\n";
|
|
48
|
+
readonly typeAlias: "\n(type_declaration\n (type_spec\n name: (type_identifier) @name\n type: (type_identifier) @alias_type)) @type_alias\n";
|
|
49
|
+
readonly all: "\n; Package declaration\n(package_clause\n (package_identifier) @package_name) @package\n\n; Import declarations\n(import_declaration) @import_decl\n\n; Function declarations\n(function_declaration\n name: (identifier) @func_name) @function\n\n; Method declarations\n(method_declaration\n name: (field_identifier) @method_name) @method\n\n; Type declarations\n(type_declaration\n (type_spec\n name: (type_identifier) @type_name)) @type\n\n; Variable declarations\n(var_declaration) @var_decl\n\n; Constant declarations\n(const_declaration) @const_decl\n";
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/ast/go/queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,qEAG1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,+GAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,uKAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,6IAQxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,qGAK1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,yGAKvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,kIAK5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,qjBA0BjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;CASV,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Tree-sitter Queries
|
|
3
|
+
*
|
|
4
|
+
* S-expression queries for extracting Go code elements.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Query to find all function declarations
|
|
8
|
+
*/
|
|
9
|
+
export const FUNCTION_QUERY = `
|
|
10
|
+
(function_declaration
|
|
11
|
+
name: (identifier) @name) @function
|
|
12
|
+
`;
|
|
13
|
+
/**
|
|
14
|
+
* Query to find all method declarations
|
|
15
|
+
*/
|
|
16
|
+
export const METHOD_QUERY = `
|
|
17
|
+
(method_declaration
|
|
18
|
+
receiver: (parameter_list) @receiver
|
|
19
|
+
name: (field_identifier) @name) @method
|
|
20
|
+
`;
|
|
21
|
+
/**
|
|
22
|
+
* Query to find all type declarations (struct, interface)
|
|
23
|
+
*/
|
|
24
|
+
export const TYPE_QUERY = `
|
|
25
|
+
(type_declaration
|
|
26
|
+
(type_spec
|
|
27
|
+
name: (type_identifier) @name
|
|
28
|
+
type: [
|
|
29
|
+
(struct_type) @struct
|
|
30
|
+
(interface_type) @interface
|
|
31
|
+
])) @type
|
|
32
|
+
`;
|
|
33
|
+
/**
|
|
34
|
+
* Query to find all import declarations
|
|
35
|
+
*/
|
|
36
|
+
export const IMPORT_QUERY = `
|
|
37
|
+
[
|
|
38
|
+
(import_declaration
|
|
39
|
+
(import_spec) @import)
|
|
40
|
+
(import_declaration
|
|
41
|
+
(import_spec_list
|
|
42
|
+
(import_spec) @import))
|
|
43
|
+
]
|
|
44
|
+
`;
|
|
45
|
+
/**
|
|
46
|
+
* Query to find package-level variable declarations
|
|
47
|
+
*/
|
|
48
|
+
export const VARIABLE_QUERY = `
|
|
49
|
+
(source_file
|
|
50
|
+
(var_declaration
|
|
51
|
+
(var_spec
|
|
52
|
+
name: (identifier) @name)) @variable)
|
|
53
|
+
`;
|
|
54
|
+
/**
|
|
55
|
+
* Query to find package-level constant declarations
|
|
56
|
+
*/
|
|
57
|
+
export const CONST_QUERY = `
|
|
58
|
+
(source_file
|
|
59
|
+
(const_declaration
|
|
60
|
+
(const_spec
|
|
61
|
+
name: (identifier) @name)) @constant)
|
|
62
|
+
`;
|
|
63
|
+
/**
|
|
64
|
+
* Query to find type aliases
|
|
65
|
+
*/
|
|
66
|
+
export const TYPE_ALIAS_QUERY = `
|
|
67
|
+
(type_declaration
|
|
68
|
+
(type_spec
|
|
69
|
+
name: (type_identifier) @name
|
|
70
|
+
type: (type_identifier) @alias_type)) @type_alias
|
|
71
|
+
`;
|
|
72
|
+
/**
|
|
73
|
+
* Combined query for common elements
|
|
74
|
+
*/
|
|
75
|
+
export const ALL_DEFINITIONS_QUERY = `
|
|
76
|
+
; Package declaration
|
|
77
|
+
(package_clause
|
|
78
|
+
(package_identifier) @package_name) @package
|
|
79
|
+
|
|
80
|
+
; Import declarations
|
|
81
|
+
(import_declaration) @import_decl
|
|
82
|
+
|
|
83
|
+
; Function declarations
|
|
84
|
+
(function_declaration
|
|
85
|
+
name: (identifier) @func_name) @function
|
|
86
|
+
|
|
87
|
+
; Method declarations
|
|
88
|
+
(method_declaration
|
|
89
|
+
name: (field_identifier) @method_name) @method
|
|
90
|
+
|
|
91
|
+
; Type declarations
|
|
92
|
+
(type_declaration
|
|
93
|
+
(type_spec
|
|
94
|
+
name: (type_identifier) @type_name)) @type
|
|
95
|
+
|
|
96
|
+
; Variable declarations
|
|
97
|
+
(var_declaration) @var_decl
|
|
98
|
+
|
|
99
|
+
; Constant declarations
|
|
100
|
+
(const_declaration) @const_decl
|
|
101
|
+
`;
|
|
102
|
+
/**
|
|
103
|
+
* Query patterns as a single object for easy access
|
|
104
|
+
*/
|
|
105
|
+
export const QUERIES = {
|
|
106
|
+
function: FUNCTION_QUERY,
|
|
107
|
+
method: METHOD_QUERY,
|
|
108
|
+
type: TYPE_QUERY,
|
|
109
|
+
import: IMPORT_QUERY,
|
|
110
|
+
variable: VARIABLE_QUERY,
|
|
111
|
+
constant: CONST_QUERY,
|
|
112
|
+
typeAlias: TYPE_ALIAS_QUERY,
|
|
113
|
+
all: ALL_DEFINITIONS_QUERY,
|
|
114
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Parser Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for converting Tree-sitter nodes to CodeElements
|
|
5
|
+
* and extracting Go-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 Go doc comment from above a declaration
|
|
20
|
+
* Go uses // comments above declarations
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractGoDoc(node: Node, lines: string[]): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get function signature from a function_declaration node
|
|
25
|
+
*/
|
|
26
|
+
export declare function getFunctionSignature(node: Node): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get method signature from a method_declaration node
|
|
29
|
+
*/
|
|
30
|
+
export declare function getMethodSignature(node: Node): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get type signature (struct, interface)
|
|
33
|
+
*/
|
|
34
|
+
export declare function getTypeSignature(node: Node, kind: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Check if a declaration is exported (starts with uppercase)
|
|
37
|
+
*/
|
|
38
|
+
export declare function isExported(name: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Get receiver type name from a method
|
|
41
|
+
*/
|
|
42
|
+
export declare function getReceiverType(node: Node): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Create a CodeElement from a Tree-sitter node
|
|
45
|
+
*/
|
|
46
|
+
export declare function createCodeElement(type: ElementType, name: string, node: Node, options?: {
|
|
47
|
+
signature?: string;
|
|
48
|
+
documentation?: string;
|
|
49
|
+
isAsync?: boolean;
|
|
50
|
+
isExported?: boolean;
|
|
51
|
+
parent?: string;
|
|
52
|
+
}): CodeElement;
|
|
53
|
+
/**
|
|
54
|
+
* Extract import path from an import spec
|
|
55
|
+
*/
|
|
56
|
+
export declare function getImportPath(node: Node): string;
|
|
57
|
+
/**
|
|
58
|
+
* Get the short name from an import path
|
|
59
|
+
*/
|
|
60
|
+
export declare function getImportName(importPath: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Get alias if import has one
|
|
63
|
+
*/
|
|
64
|
+
export declare function getImportAlias(node: Node): string | undefined;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ast/go/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,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAkB5E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAUvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAYrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAO9D;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;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQhD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAM7D"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Parser Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for converting Tree-sitter nodes to CodeElements
|
|
5
|
+
* and extracting Go-specific constructs.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get line number from a Tree-sitter node (1-indexed)
|
|
9
|
+
*/
|
|
10
|
+
export function getLineNumber(node) {
|
|
11
|
+
return node.startPosition.row + 1;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get end line number from a Tree-sitter node (1-indexed)
|
|
15
|
+
*/
|
|
16
|
+
export function getEndLineNumber(node) {
|
|
17
|
+
return node.endPosition.row + 1;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extract Go doc comment from above a declaration
|
|
21
|
+
* Go uses // comments above declarations
|
|
22
|
+
*/
|
|
23
|
+
export function extractGoDoc(node, lines) {
|
|
24
|
+
const startLine = node.startPosition.row;
|
|
25
|
+
const comments = [];
|
|
26
|
+
// Look for comments above the node
|
|
27
|
+
for (let i = startLine - 1; i >= 0; i--) {
|
|
28
|
+
const line = lines[i]?.trim();
|
|
29
|
+
if (line?.startsWith("//")) {
|
|
30
|
+
comments.unshift(line.slice(2).trim());
|
|
31
|
+
}
|
|
32
|
+
else if (line === "") {
|
|
33
|
+
// Allow empty lines between comments
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return comments.length > 0 ? comments.join("\n") : undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get function signature from a function_declaration node
|
|
44
|
+
*/
|
|
45
|
+
export function getFunctionSignature(node) {
|
|
46
|
+
const nameNode = node.childForFieldName("name");
|
|
47
|
+
const paramsNode = node.childForFieldName("parameters");
|
|
48
|
+
const resultNode = node.childForFieldName("result");
|
|
49
|
+
const name = nameNode?.text ?? "unknown";
|
|
50
|
+
const params = paramsNode?.text ?? "()";
|
|
51
|
+
const result = resultNode ? ` ${resultNode.text}` : "";
|
|
52
|
+
return `func ${name}${params}${result}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get method signature from a method_declaration node
|
|
56
|
+
*/
|
|
57
|
+
export function getMethodSignature(node) {
|
|
58
|
+
const receiverNode = node.childForFieldName("receiver");
|
|
59
|
+
const nameNode = node.childForFieldName("name");
|
|
60
|
+
const paramsNode = node.childForFieldName("parameters");
|
|
61
|
+
const resultNode = node.childForFieldName("result");
|
|
62
|
+
const receiver = receiverNode?.text ?? "";
|
|
63
|
+
const name = nameNode?.text ?? "unknown";
|
|
64
|
+
const params = paramsNode?.text ?? "()";
|
|
65
|
+
const result = resultNode ? ` ${resultNode.text}` : "";
|
|
66
|
+
return `func ${receiver} ${name}${params}${result}`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get type signature (struct, interface)
|
|
70
|
+
*/
|
|
71
|
+
export function getTypeSignature(node, kind) {
|
|
72
|
+
const nameNode = node.childForFieldName("name");
|
|
73
|
+
const name = nameNode?.text ?? "unknown";
|
|
74
|
+
return `type ${name} ${kind}`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if a declaration is exported (starts with uppercase)
|
|
78
|
+
*/
|
|
79
|
+
export function isExported(name) {
|
|
80
|
+
if (!name || name.length === 0)
|
|
81
|
+
return false;
|
|
82
|
+
const firstChar = name.charAt(0);
|
|
83
|
+
return firstChar === firstChar.toUpperCase() && firstChar !== firstChar.toLowerCase();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get receiver type name from a method
|
|
87
|
+
*/
|
|
88
|
+
export function getReceiverType(node) {
|
|
89
|
+
const receiverNode = node.childForFieldName("receiver");
|
|
90
|
+
if (!receiverNode)
|
|
91
|
+
return undefined;
|
|
92
|
+
// Find the type identifier in the receiver
|
|
93
|
+
const typeNode = receiverNode.descendantsOfType("type_identifier")[0];
|
|
94
|
+
return typeNode?.text;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a CodeElement from a Tree-sitter node
|
|
98
|
+
*/
|
|
99
|
+
export function createCodeElement(type, name, node, options) {
|
|
100
|
+
return {
|
|
101
|
+
type,
|
|
102
|
+
name,
|
|
103
|
+
startLine: getLineNumber(node),
|
|
104
|
+
endLine: getEndLineNumber(node),
|
|
105
|
+
signature: options?.signature,
|
|
106
|
+
documentation: options?.documentation,
|
|
107
|
+
isAsync: options?.isAsync,
|
|
108
|
+
isExported: options?.isExported,
|
|
109
|
+
parent: options?.parent,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Extract import path from an import spec
|
|
114
|
+
*/
|
|
115
|
+
export function getImportPath(node) {
|
|
116
|
+
// Find the interpreted_string_literal child
|
|
117
|
+
const pathNode = node.descendantsOfType("interpreted_string_literal")[0];
|
|
118
|
+
if (pathNode) {
|
|
119
|
+
// Remove quotes
|
|
120
|
+
return pathNode.text.slice(1, -1);
|
|
121
|
+
}
|
|
122
|
+
return node.text;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get the short name from an import path
|
|
126
|
+
*/
|
|
127
|
+
export function getImportName(importPath) {
|
|
128
|
+
const parts = importPath.split("/");
|
|
129
|
+
return parts[parts.length - 1] ?? importPath;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get alias if import has one
|
|
133
|
+
*/
|
|
134
|
+
export function getImportAlias(node) {
|
|
135
|
+
const nameNode = node.childForFieldName("name");
|
|
136
|
+
if (nameNode && nameNode.type === "package_identifier") {
|
|
137
|
+
return nameNode.text;
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Parser Router
|
|
3
|
+
*
|
|
4
|
+
* Routes parsing requests to the appropriate language parser.
|
|
5
|
+
*/
|
|
6
|
+
export type { SupportedLanguage, ElementType, CodeElement, FileStructure, ExtractedContent, ExtractionTarget, ExtractionOptions, ParseOptions, LanguageParser, } from "./types.js";
|
|
7
|
+
export { createEmptyStructure } from "./types.js";
|
|
8
|
+
import type { SupportedLanguage, CodeElement, FileStructure, ExtractedContent, ExtractionTarget, ExtractionOptions, ParseOptions, LanguageParser } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Get parser for a language
|
|
11
|
+
*/
|
|
12
|
+
export declare function getParser(language: SupportedLanguage): LanguageParser | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a language has parser support
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasParserSupport(language: SupportedLanguage): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Parse file content and return structure
|
|
19
|
+
* @param mode 'full' for AST parsing, 'quick' for regex-based scan (faster, less detail)
|
|
20
|
+
* @param options ParseOptions to control extraction (detailed: true for signature/documentation)
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseFile(content: string, language: SupportedLanguage, mode?: "full" | "quick", options?: ParseOptions): FileStructure;
|
|
23
|
+
/**
|
|
24
|
+
* Extract a specific element from content
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractElement(content: string, language: SupportedLanguage, target: ExtractionTarget, options: ExtractionOptions): ExtractedContent | null;
|
|
27
|
+
/**
|
|
28
|
+
* Search for elements matching a query
|
|
29
|
+
*/
|
|
30
|
+
export declare function searchElements(content: string, language: SupportedLanguage, query: string): CodeElement[];
|
|
31
|
+
/**
|
|
32
|
+
* Extract lines from content
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractLines(content: string, startLine: number, endLine: number): ExtractedContent;
|
|
35
|
+
/**
|
|
36
|
+
* Format file structure as summary
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatStructureSummary(structure: FileStructure, filePath: string, format?: "plain" | "markdown"): string;
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACf,MAAM,YAAY,CAAC;AAuBpB;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,iBAAiB,GAAG,cAAc,GAAG,SAAS,CAEjF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAErE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,GAAE,MAAM,GAAG,OAAgB,EAC/B,OAAO,GAAE,YAAiB,GACzB,aAAa,CAkBf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,iBAAiB,GACzB,gBAAgB,GAAG,IAAI,CAQzB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,MAAM,GACZ,WAAW,EAAE,CAQf;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,gBAAgB,CAiBlB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,OAAO,GAAG,UAAoB,GACrC,MAAM,CAuIR"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Parser Router
|
|
3
|
+
*
|
|
4
|
+
* Routes parsing requests to the appropriate language parser.
|
|
5
|
+
*/
|
|
6
|
+
export { createEmptyStructure } from "./types.js";
|
|
7
|
+
import { createEmptyStructure } from "./types.js";
|
|
8
|
+
import { typescriptParser, parseTypeScript } from "./typescript.js";
|
|
9
|
+
import { quickScan } from "./quick-scan.js";
|
|
10
|
+
import { pythonTreeSitterParser } from "./python/index.js";
|
|
11
|
+
import { goTreeSitterParser } from "./go/index.js";
|
|
12
|
+
import { rustTreeSitterParser } from "./rust/index.js";
|
|
13
|
+
import { phpTreeSitterParser } from "./php/index.js";
|
|
14
|
+
import { swiftTreeSitterParser } from "./swift/index.js";
|
|
15
|
+
/**
|
|
16
|
+
* Registry of language parsers
|
|
17
|
+
*/
|
|
18
|
+
const parserRegistry = new Map([
|
|
19
|
+
["typescript", typescriptParser],
|
|
20
|
+
["javascript", typescriptParser], // JS uses same parser
|
|
21
|
+
["python", pythonTreeSitterParser], // Tree-sitter based parser
|
|
22
|
+
["go", goTreeSitterParser], // Tree-sitter based parser
|
|
23
|
+
["rust", rustTreeSitterParser], // Tree-sitter based parser
|
|
24
|
+
["php", phpTreeSitterParser], // Tree-sitter based parser
|
|
25
|
+
["swift", swiftTreeSitterParser], // Tree-sitter based parser
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* Get parser for a language
|
|
29
|
+
*/
|
|
30
|
+
export function getParser(language) {
|
|
31
|
+
return parserRegistry.get(language);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Check if a language has parser support
|
|
35
|
+
*/
|
|
36
|
+
export function hasParserSupport(language) {
|
|
37
|
+
return parserRegistry.has(language);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parse file content and return structure
|
|
41
|
+
* @param mode 'full' for AST parsing, 'quick' for regex-based scan (faster, less detail)
|
|
42
|
+
* @param options ParseOptions to control extraction (detailed: true for signature/documentation)
|
|
43
|
+
*/
|
|
44
|
+
export function parseFile(content, language, mode = "full", options = {}) {
|
|
45
|
+
// Quick mode: use regex-based scan (90% faster, no endLine/signatures)
|
|
46
|
+
if (mode === "quick") {
|
|
47
|
+
return quickScan(content, language);
|
|
48
|
+
}
|
|
49
|
+
const parser = parserRegistry.get(language);
|
|
50
|
+
if (parser) {
|
|
51
|
+
// Special case for JavaScript (use TS parser with isTypeScript=false)
|
|
52
|
+
if (language === "javascript") {
|
|
53
|
+
return parseTypeScript(content, false, options);
|
|
54
|
+
}
|
|
55
|
+
return parser.parse(content, options);
|
|
56
|
+
}
|
|
57
|
+
// No parser available - return minimal structure
|
|
58
|
+
return createEmptyStructure(language, content.split("\n").length);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Extract a specific element from content
|
|
62
|
+
*/
|
|
63
|
+
export function extractElement(content, language, target, options) {
|
|
64
|
+
const parser = parserRegistry.get(language);
|
|
65
|
+
if (!parser) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return parser.extractElement(content, target, options);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Search for elements matching a query
|
|
72
|
+
*/
|
|
73
|
+
export function searchElements(content, language, query) {
|
|
74
|
+
const parser = parserRegistry.get(language);
|
|
75
|
+
if (!parser) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
return parser.searchElements(content, query);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Extract lines from content
|
|
82
|
+
*/
|
|
83
|
+
export function extractLines(content, startLine, endLine) {
|
|
84
|
+
const lines = content.split("\n");
|
|
85
|
+
const totalLines = lines.length;
|
|
86
|
+
// Clamp line numbers
|
|
87
|
+
const start = Math.max(1, Math.min(startLine, totalLines));
|
|
88
|
+
const end = Math.max(start, Math.min(endLine, totalLines));
|
|
89
|
+
const extractedLines = lines.slice(start - 1, end);
|
|
90
|
+
return {
|
|
91
|
+
content: extractedLines.join("\n"),
|
|
92
|
+
elements: [],
|
|
93
|
+
relatedImports: [],
|
|
94
|
+
startLine: start,
|
|
95
|
+
endLine: end,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Format file structure as summary
|
|
100
|
+
*/
|
|
101
|
+
export function formatStructureSummary(structure, filePath, format = "plain") {
|
|
102
|
+
const parts = [];
|
|
103
|
+
const md = format === "markdown";
|
|
104
|
+
if (md) {
|
|
105
|
+
parts.push(`## File Structure: ${filePath}`);
|
|
106
|
+
parts.push("");
|
|
107
|
+
parts.push(`**Language:** ${formatLanguageName(structure.language)}`);
|
|
108
|
+
parts.push(`**Lines:** ${structure.totalLines}`);
|
|
109
|
+
parts.push("");
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
parts.push(`${filePath} (${formatLanguageName(structure.language)}, ${structure.totalLines} lines)`);
|
|
113
|
+
}
|
|
114
|
+
// Exports
|
|
115
|
+
if (structure.exports.length > 0) {
|
|
116
|
+
if (md) {
|
|
117
|
+
parts.push("### Exports");
|
|
118
|
+
for (const exp of structure.exports) {
|
|
119
|
+
parts.push(`- \`${exp.name}\` (line ${exp.startLine})`);
|
|
120
|
+
}
|
|
121
|
+
parts.push("");
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const expList = structure.exports.map(e => e.name).join(", ");
|
|
125
|
+
parts.push(`EXPORTS: ${expList}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Functions
|
|
129
|
+
if (structure.functions.length > 0) {
|
|
130
|
+
if (md) {
|
|
131
|
+
parts.push("### Functions");
|
|
132
|
+
for (const func of structure.functions) {
|
|
133
|
+
const prefix = func.type === "method" ? `${func.parent}.` : "";
|
|
134
|
+
const async = func.isAsync ? "async " : "";
|
|
135
|
+
const exported = func.isExported ? "exported " : "";
|
|
136
|
+
parts.push(`- \`${prefix}${func.name}\` (${exported}${async}${func.type}, lines ${func.startLine}-${func.endLine})`);
|
|
137
|
+
}
|
|
138
|
+
parts.push("");
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const fnList = structure.functions.map(f => `${f.name} (${f.startLine}-${f.endLine})`).join(", ");
|
|
142
|
+
parts.push(`FUNCTIONS: ${fnList}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Classes
|
|
146
|
+
if (structure.classes.length > 0) {
|
|
147
|
+
if (md) {
|
|
148
|
+
parts.push("### Classes");
|
|
149
|
+
for (const cls of structure.classes) {
|
|
150
|
+
const exported = cls.isExported ? "exported " : "";
|
|
151
|
+
parts.push(`- \`${cls.name}\` (${exported}class, lines ${cls.startLine}-${cls.endLine})`);
|
|
152
|
+
}
|
|
153
|
+
parts.push("");
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const clsList = structure.classes.map(c => `${c.name} (${c.startLine}-${c.endLine})`).join(", ");
|
|
157
|
+
parts.push(`CLASSES: ${clsList}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Interfaces (no line numbers in plain - minor elements)
|
|
161
|
+
if (structure.interfaces.length > 0) {
|
|
162
|
+
if (md) {
|
|
163
|
+
parts.push("### Interfaces");
|
|
164
|
+
for (const iface of structure.interfaces) {
|
|
165
|
+
const exported = iface.isExported ? "exported " : "";
|
|
166
|
+
parts.push(`- \`${iface.name}\` (${exported}interface, lines ${iface.startLine}-${iface.endLine})`);
|
|
167
|
+
}
|
|
168
|
+
parts.push("");
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
const ifList = structure.interfaces.map(i => i.name).join(", ");
|
|
172
|
+
parts.push(`INTERFACES: ${ifList}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Types (no line numbers in plain - minor elements)
|
|
176
|
+
if (structure.types.length > 0) {
|
|
177
|
+
if (md) {
|
|
178
|
+
parts.push("### Types");
|
|
179
|
+
for (const type of structure.types) {
|
|
180
|
+
const exported = type.isExported ? "exported " : "";
|
|
181
|
+
parts.push(`- \`${type.name}\` (${exported}type, lines ${type.startLine}-${type.endLine})`);
|
|
182
|
+
}
|
|
183
|
+
parts.push("");
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const typeList = structure.types.map(t => t.name).join(", ");
|
|
187
|
+
parts.push(`TYPES: ${typeList}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Variables (exported only)
|
|
191
|
+
const exportedVars = structure.variables.filter(v => v.isExported);
|
|
192
|
+
if (exportedVars.length > 0) {
|
|
193
|
+
if (md) {
|
|
194
|
+
parts.push("### Exported Variables");
|
|
195
|
+
for (const variable of exportedVars) {
|
|
196
|
+
parts.push(`- \`${variable.name}\` (variable, lines ${variable.startLine}-${variable.endLine})`);
|
|
197
|
+
}
|
|
198
|
+
parts.push("");
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const varList = exportedVars.map(v => v.name).join(", ");
|
|
202
|
+
parts.push(`EXPORTS: ${varList}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Imports (collapsed, max 3)
|
|
206
|
+
if (structure.imports.length > 0) {
|
|
207
|
+
const uniqueImports = [...new Set(structure.imports.map((i) => i.name))];
|
|
208
|
+
if (md) {
|
|
209
|
+
parts.push(`### Imports (${structure.imports.length})`);
|
|
210
|
+
if (uniqueImports.length <= 3) {
|
|
211
|
+
for (const name of uniqueImports) {
|
|
212
|
+
parts.push(`- \`${name}\``);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
for (const name of uniqueImports.slice(0, 3)) {
|
|
217
|
+
parts.push(`- \`${name}\``);
|
|
218
|
+
}
|
|
219
|
+
parts.push(`- ... and ${uniqueImports.length - 3} more`);
|
|
220
|
+
}
|
|
221
|
+
parts.push("");
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const importList = uniqueImports.slice(0, 3).join(", ");
|
|
225
|
+
const more = uniqueImports.length > 3 ? ` +${uniqueImports.length - 3}` : "";
|
|
226
|
+
parts.push(`IMPORTS: ${importList}${more}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return parts.join("\n");
|
|
230
|
+
}
|
|
231
|
+
function formatLanguageName(language) {
|
|
232
|
+
const names = {
|
|
233
|
+
typescript: "TypeScript",
|
|
234
|
+
javascript: "JavaScript",
|
|
235
|
+
python: "Python",
|
|
236
|
+
go: "Go",
|
|
237
|
+
rust: "Rust",
|
|
238
|
+
php: "PHP",
|
|
239
|
+
swift: "Swift",
|
|
240
|
+
json: "JSON",
|
|
241
|
+
yaml: "YAML",
|
|
242
|
+
unknown: "Unknown",
|
|
243
|
+
};
|
|
244
|
+
return names[language];
|
|
245
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PHP AST Parser Module
|
|
3
|
+
*
|
|
4
|
+
* Exports the Tree-sitter based PHP parser.
|
|
5
|
+
*/
|
|
6
|
+
export { phpTreeSitterParser, parsePhp, parsePhpAsync, extractPhpElement, searchPhpElements, initPhpParser, } from "./parser.js";
|
|
7
|
+
export { QUERIES } from "./queries.js";
|
|
8
|
+
export { getLineNumber, getEndLineNumber, extractPhpDoc, getVisibility, isPublic, getFunctionSignature, getMethodSignature, getClassSignature, createCodeElement, } from "./utils.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ast/php/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|