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,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift Parser Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for converting Tree-sitter nodes to CodeElements
|
|
5
|
+
* and extracting Swift-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 Swift documentation comment from above a declaration
|
|
20
|
+
* Swift uses /// for single-line doc comments and block comments
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractSwiftDoc(node: Node, lines: string[]): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Swift access levels
|
|
25
|
+
*/
|
|
26
|
+
export type SwiftAccessLevel = "private" | "fileprivate" | "internal" | "public" | "open";
|
|
27
|
+
/**
|
|
28
|
+
* Get access level from a node
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAccessLevel(node: Node): SwiftAccessLevel | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a node has public or open visibility (external API)
|
|
33
|
+
*/
|
|
34
|
+
export declare function isPublic(node: Node): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if a function/method is async
|
|
37
|
+
*/
|
|
38
|
+
export declare function isAsync(node: Node): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a node has static modifier
|
|
41
|
+
*/
|
|
42
|
+
export declare function isStatic(node: Node): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Get function signature from a function_declaration node
|
|
45
|
+
*/
|
|
46
|
+
export declare function getFunctionSignature(node: Node): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get method signature (same as function but with receiver context)
|
|
49
|
+
*/
|
|
50
|
+
export declare function getMethodSignature(node: Node): string;
|
|
51
|
+
/**
|
|
52
|
+
* Get class signature
|
|
53
|
+
*/
|
|
54
|
+
export declare function getClassSignature(node: Node): string;
|
|
55
|
+
/**
|
|
56
|
+
* Get struct signature
|
|
57
|
+
*/
|
|
58
|
+
export declare function getStructSignature(node: Node): string;
|
|
59
|
+
/**
|
|
60
|
+
* Get protocol signature
|
|
61
|
+
*/
|
|
62
|
+
export declare function getProtocolSignature(node: Node): string;
|
|
63
|
+
/**
|
|
64
|
+
* Get enum signature
|
|
65
|
+
*/
|
|
66
|
+
export declare function getEnumSignature(node: Node): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get extension signature
|
|
69
|
+
*/
|
|
70
|
+
export declare function getExtensionSignature(node: Node): string;
|
|
71
|
+
/**
|
|
72
|
+
* Get typealias signature
|
|
73
|
+
*/
|
|
74
|
+
export declare function getTypealiasSignature(node: Node): string;
|
|
75
|
+
/**
|
|
76
|
+
* Get import path from import declaration
|
|
77
|
+
*/
|
|
78
|
+
export declare function getImportPath(node: Node): string;
|
|
79
|
+
/**
|
|
80
|
+
* Get variable/constant signature
|
|
81
|
+
*/
|
|
82
|
+
export declare function getVariableSignature(node: Node): string;
|
|
83
|
+
/**
|
|
84
|
+
* Create a CodeElement from a Tree-sitter node
|
|
85
|
+
*/
|
|
86
|
+
export declare function createCodeElement(type: ElementType, name: string, node: Node, options?: {
|
|
87
|
+
signature?: string;
|
|
88
|
+
documentation?: string;
|
|
89
|
+
isAsync?: boolean;
|
|
90
|
+
isExported?: boolean;
|
|
91
|
+
parent?: string;
|
|
92
|
+
}): CodeElement;
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ast/swift/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,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,G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H,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"}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift Parser Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for converting Tree-sitter nodes to CodeElements
|
|
5
|
+
* and extracting Swift-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 Swift documentation comment from above a declaration
|
|
21
|
+
* Swift uses /// for single-line doc comments and block comments
|
|
22
|
+
*/
|
|
23
|
+
export function extractSwiftDoc(node, lines) {
|
|
24
|
+
const startLine = node.startPosition.row;
|
|
25
|
+
const comments = [];
|
|
26
|
+
// Look for doc comments above the node
|
|
27
|
+
for (let i = startLine - 1; i >= 0; i--) {
|
|
28
|
+
const line = lines[i]?.trim();
|
|
29
|
+
if (!line) {
|
|
30
|
+
// Empty line - continue looking
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
else if (line.startsWith("///")) {
|
|
34
|
+
// Single-line doc comment
|
|
35
|
+
const content = line.slice(3).trim();
|
|
36
|
+
if (content)
|
|
37
|
+
comments.unshift(content);
|
|
38
|
+
}
|
|
39
|
+
else if (line.endsWith("*/")) {
|
|
40
|
+
// End of block comment - look for the start
|
|
41
|
+
for (let j = i; j >= 0; j--) {
|
|
42
|
+
const commentLine = lines[j]?.trim();
|
|
43
|
+
if (commentLine?.startsWith("/**")) {
|
|
44
|
+
// Found start of doc block
|
|
45
|
+
for (let k = j; k <= i; k++) {
|
|
46
|
+
let cl = lines[k]?.trim() ?? "";
|
|
47
|
+
// Clean up comment markers
|
|
48
|
+
if (cl.startsWith("/**"))
|
|
49
|
+
cl = cl.slice(3).trim();
|
|
50
|
+
if (cl.endsWith("*/"))
|
|
51
|
+
cl = cl.slice(0, -2).trim();
|
|
52
|
+
if (cl.startsWith("*"))
|
|
53
|
+
cl = cl.slice(1).trim();
|
|
54
|
+
if (cl)
|
|
55
|
+
comments.push(cl);
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
else if (line.startsWith("*")) {
|
|
63
|
+
// Middle of block comment
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
else if (line.startsWith("//") && !line.startsWith("///")) {
|
|
67
|
+
// Regular comment - skip
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
else if (line.startsWith("@")) {
|
|
71
|
+
// Attribute like @available, @discardableResult - continue
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Something else (code) - stop
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return comments.length > 0 ? comments.join("\n") : undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get access level from a node
|
|
83
|
+
*/
|
|
84
|
+
export function getAccessLevel(node) {
|
|
85
|
+
for (const child of node.children) {
|
|
86
|
+
if (child.type === "modifiers") {
|
|
87
|
+
for (const modifier of child.children) {
|
|
88
|
+
const text = modifier.text;
|
|
89
|
+
if (text === "private" || text === "fileprivate" || text === "internal" || text === "public" || text === "open") {
|
|
90
|
+
return text;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Also check for direct visibility_modifier nodes
|
|
95
|
+
if (child.type === "visibility_modifier") {
|
|
96
|
+
const text = child.text;
|
|
97
|
+
if (text === "private" || text === "fileprivate" || text === "internal" || text === "public" || text === "open") {
|
|
98
|
+
return text;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if a node has public or open visibility (external API)
|
|
106
|
+
*/
|
|
107
|
+
export function isPublic(node) {
|
|
108
|
+
const accessLevel = getAccessLevel(node);
|
|
109
|
+
return accessLevel === "public" || accessLevel === "open" || accessLevel === undefined;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Check if a function/method is async
|
|
113
|
+
*/
|
|
114
|
+
export function isAsync(node) {
|
|
115
|
+
for (const child of node.children) {
|
|
116
|
+
if (child.type === "modifiers") {
|
|
117
|
+
for (const modifier of child.children) {
|
|
118
|
+
if (modifier.text === "async") {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (child.text === "async") {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Check if a node has static modifier
|
|
131
|
+
*/
|
|
132
|
+
export function isStatic(node) {
|
|
133
|
+
for (const child of node.children) {
|
|
134
|
+
if (child.type === "modifiers") {
|
|
135
|
+
for (const modifier of child.children) {
|
|
136
|
+
if (modifier.text === "static" || modifier.text === "class") {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get function signature from a function_declaration node
|
|
146
|
+
*/
|
|
147
|
+
export function getFunctionSignature(node) {
|
|
148
|
+
const parts = [];
|
|
149
|
+
// Access level
|
|
150
|
+
const accessLevel = getAccessLevel(node);
|
|
151
|
+
if (accessLevel && accessLevel !== "internal") {
|
|
152
|
+
parts.push(accessLevel);
|
|
153
|
+
}
|
|
154
|
+
// Static/class modifier
|
|
155
|
+
if (isStatic(node)) {
|
|
156
|
+
parts.push("static");
|
|
157
|
+
}
|
|
158
|
+
// Async modifier
|
|
159
|
+
if (isAsync(node)) {
|
|
160
|
+
parts.push("async");
|
|
161
|
+
}
|
|
162
|
+
parts.push("func");
|
|
163
|
+
// Function name
|
|
164
|
+
const nameNode = node.childForFieldName("name");
|
|
165
|
+
const name = nameNode?.text ?? "unknown";
|
|
166
|
+
// Parameters
|
|
167
|
+
let params = "()";
|
|
168
|
+
for (const child of node.children) {
|
|
169
|
+
if (child.type === "parameter_clause" || child.type === "function_signature") {
|
|
170
|
+
const paramClause = child.type === "function_signature"
|
|
171
|
+
? child.children.find(c => c.type === "parameter_clause")
|
|
172
|
+
: child;
|
|
173
|
+
if (paramClause) {
|
|
174
|
+
params = paramClause.text;
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Return type
|
|
180
|
+
let returnType = "";
|
|
181
|
+
for (const child of node.children) {
|
|
182
|
+
if (child.type === "function_signature") {
|
|
183
|
+
const returnClause = child.children.find(c => c.type === "function_result");
|
|
184
|
+
if (returnClause) {
|
|
185
|
+
returnType = ` ${returnClause.text}`;
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
parts.push(`${name}${params}${returnType}`);
|
|
191
|
+
return parts.join(" ");
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get method signature (same as function but with receiver context)
|
|
195
|
+
*/
|
|
196
|
+
export function getMethodSignature(node) {
|
|
197
|
+
return getFunctionSignature(node);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get class signature
|
|
201
|
+
*/
|
|
202
|
+
export function getClassSignature(node) {
|
|
203
|
+
const parts = [];
|
|
204
|
+
const accessLevel = getAccessLevel(node);
|
|
205
|
+
if (accessLevel && accessLevel !== "internal") {
|
|
206
|
+
parts.push(accessLevel);
|
|
207
|
+
}
|
|
208
|
+
// Check for final modifier
|
|
209
|
+
for (const child of node.children) {
|
|
210
|
+
if (child.type === "modifiers") {
|
|
211
|
+
for (const modifier of child.children) {
|
|
212
|
+
if (modifier.text === "final") {
|
|
213
|
+
parts.push("final");
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
parts.push("class");
|
|
220
|
+
// Class name - look for type_identifier
|
|
221
|
+
let name = "unknown";
|
|
222
|
+
for (const child of node.children) {
|
|
223
|
+
if (child.type === "type_identifier") {
|
|
224
|
+
name = child.text;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
parts.push(name);
|
|
229
|
+
// Inheritance clause
|
|
230
|
+
for (const child of node.children) {
|
|
231
|
+
if (child.type === "type_inheritance_clause" || child.type === "inheritance_specifier") {
|
|
232
|
+
parts.push(child.text);
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return parts.join(" ");
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Get struct signature
|
|
240
|
+
*/
|
|
241
|
+
export function getStructSignature(node) {
|
|
242
|
+
const parts = [];
|
|
243
|
+
const accessLevel = getAccessLevel(node);
|
|
244
|
+
if (accessLevel && accessLevel !== "internal") {
|
|
245
|
+
parts.push(accessLevel);
|
|
246
|
+
}
|
|
247
|
+
parts.push("struct");
|
|
248
|
+
// Struct name - look for type_identifier
|
|
249
|
+
let name = "unknown";
|
|
250
|
+
for (const child of node.children) {
|
|
251
|
+
if (child.type === "type_identifier") {
|
|
252
|
+
name = child.text;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
parts.push(name);
|
|
257
|
+
// Inheritance clause (protocols)
|
|
258
|
+
for (const child of node.children) {
|
|
259
|
+
if (child.type === "type_inheritance_clause" || child.type === "inheritance_specifier") {
|
|
260
|
+
parts.push(child.text);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return parts.join(" ");
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get protocol signature
|
|
268
|
+
*/
|
|
269
|
+
export function getProtocolSignature(node) {
|
|
270
|
+
const parts = [];
|
|
271
|
+
const accessLevel = getAccessLevel(node);
|
|
272
|
+
if (accessLevel && accessLevel !== "internal") {
|
|
273
|
+
parts.push(accessLevel);
|
|
274
|
+
}
|
|
275
|
+
parts.push("protocol");
|
|
276
|
+
// Protocol name - look for type_identifier
|
|
277
|
+
let name = "unknown";
|
|
278
|
+
for (const child of node.children) {
|
|
279
|
+
if (child.type === "type_identifier") {
|
|
280
|
+
name = child.text;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
parts.push(name);
|
|
285
|
+
// Inheritance clause
|
|
286
|
+
for (const child of node.children) {
|
|
287
|
+
if (child.type === "type_inheritance_clause" || child.type === "inheritance_specifier") {
|
|
288
|
+
parts.push(child.text);
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return parts.join(" ");
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Get enum signature
|
|
296
|
+
*/
|
|
297
|
+
export function getEnumSignature(node) {
|
|
298
|
+
const parts = [];
|
|
299
|
+
const accessLevel = getAccessLevel(node);
|
|
300
|
+
if (accessLevel && accessLevel !== "internal") {
|
|
301
|
+
parts.push(accessLevel);
|
|
302
|
+
}
|
|
303
|
+
parts.push("enum");
|
|
304
|
+
// Enum name - look for type_identifier
|
|
305
|
+
let name = "unknown";
|
|
306
|
+
for (const child of node.children) {
|
|
307
|
+
if (child.type === "type_identifier") {
|
|
308
|
+
name = child.text;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
parts.push(name);
|
|
313
|
+
// Raw type or protocol conformance
|
|
314
|
+
for (const child of node.children) {
|
|
315
|
+
if (child.type === "type_inheritance_clause" || child.type === "inheritance_specifier") {
|
|
316
|
+
parts.push(child.text);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return parts.join(" ");
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Get extension signature
|
|
324
|
+
*/
|
|
325
|
+
export function getExtensionSignature(node) {
|
|
326
|
+
const parts = [];
|
|
327
|
+
const accessLevel = getAccessLevel(node);
|
|
328
|
+
if (accessLevel && accessLevel !== "internal") {
|
|
329
|
+
parts.push(accessLevel);
|
|
330
|
+
}
|
|
331
|
+
parts.push("extension");
|
|
332
|
+
// Extended type
|
|
333
|
+
for (const child of node.children) {
|
|
334
|
+
if (child.type === "type_identifier" || child.type === "user_type") {
|
|
335
|
+
parts.push(child.text);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
// Protocol conformance
|
|
340
|
+
for (const child of node.children) {
|
|
341
|
+
if (child.type === "type_inheritance_clause") {
|
|
342
|
+
parts.push(child.text);
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return parts.join(" ");
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get typealias signature
|
|
350
|
+
*/
|
|
351
|
+
export function getTypealiasSignature(node) {
|
|
352
|
+
const parts = [];
|
|
353
|
+
const accessLevel = getAccessLevel(node);
|
|
354
|
+
if (accessLevel && accessLevel !== "internal") {
|
|
355
|
+
parts.push(accessLevel);
|
|
356
|
+
}
|
|
357
|
+
parts.push("typealias");
|
|
358
|
+
// Typealias name
|
|
359
|
+
const nameNode = node.childForFieldName("name");
|
|
360
|
+
const name = nameNode?.text ?? "unknown";
|
|
361
|
+
parts.push(name);
|
|
362
|
+
// Type assignment
|
|
363
|
+
for (const child of node.children) {
|
|
364
|
+
if (child.type === "type_annotation" || child.text.startsWith("=")) {
|
|
365
|
+
// Get the type after =
|
|
366
|
+
const typeText = child.text.replace(/^=\s*/, "");
|
|
367
|
+
if (typeText) {
|
|
368
|
+
parts.push("=", typeText);
|
|
369
|
+
}
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return parts.join(" ");
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Get import path from import declaration
|
|
377
|
+
*/
|
|
378
|
+
export function getImportPath(node) {
|
|
379
|
+
// Remove "import " prefix
|
|
380
|
+
const text = node.text.trim();
|
|
381
|
+
if (text.startsWith("import ")) {
|
|
382
|
+
return text.slice(7).trim();
|
|
383
|
+
}
|
|
384
|
+
return text;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Get variable/constant signature
|
|
388
|
+
*/
|
|
389
|
+
export function getVariableSignature(node) {
|
|
390
|
+
const text = node.text.trim();
|
|
391
|
+
// Get just the declaration part (first line)
|
|
392
|
+
const firstLine = text.split("\n")[0] ?? text;
|
|
393
|
+
// Clean up and return
|
|
394
|
+
return firstLine.replace(/\s*[={].*$/, "").trim();
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Create a CodeElement from a Tree-sitter node
|
|
398
|
+
*/
|
|
399
|
+
export function createCodeElement(type, name, node, options) {
|
|
400
|
+
return {
|
|
401
|
+
type,
|
|
402
|
+
name,
|
|
403
|
+
startLine: getLineNumber(node),
|
|
404
|
+
endLine: getEndLineNumber(node),
|
|
405
|
+
signature: options?.signature,
|
|
406
|
+
documentation: options?.documentation,
|
|
407
|
+
isAsync: options?.isAsync,
|
|
408
|
+
isExported: options?.isExported,
|
|
409
|
+
parent: options?.parent,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Types
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions for code parsing and extraction.
|
|
5
|
+
*/
|
|
6
|
+
export type SupportedLanguage = "typescript" | "javascript" | "python" | "go" | "rust" | "php" | "swift" | "json" | "yaml" | "unknown";
|
|
7
|
+
export type ElementType = "function" | "class" | "interface" | "type" | "variable" | "import" | "export" | "method";
|
|
8
|
+
export interface CodeElement {
|
|
9
|
+
/** Type of code element */
|
|
10
|
+
type: ElementType;
|
|
11
|
+
/** Name of the element */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Starting line number (1-indexed) */
|
|
14
|
+
startLine: number;
|
|
15
|
+
/** Ending line number (1-indexed) */
|
|
16
|
+
endLine: number;
|
|
17
|
+
/** Function/method signature if applicable */
|
|
18
|
+
signature?: string;
|
|
19
|
+
/** JSDoc/docstring content if present */
|
|
20
|
+
documentation?: string;
|
|
21
|
+
/** Whether this element is exported */
|
|
22
|
+
isExported?: boolean;
|
|
23
|
+
/** Whether this is async (for functions) */
|
|
24
|
+
isAsync?: boolean;
|
|
25
|
+
/** Parent element name (for methods in classes) */
|
|
26
|
+
parent?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface FileStructure {
|
|
29
|
+
/** Detected language */
|
|
30
|
+
language: SupportedLanguage;
|
|
31
|
+
/** Total lines in file */
|
|
32
|
+
totalLines: number;
|
|
33
|
+
/** Import statements */
|
|
34
|
+
imports: CodeElement[];
|
|
35
|
+
/** Export statements */
|
|
36
|
+
exports: CodeElement[];
|
|
37
|
+
/** Function declarations */
|
|
38
|
+
functions: CodeElement[];
|
|
39
|
+
/** Class declarations */
|
|
40
|
+
classes: CodeElement[];
|
|
41
|
+
/** Interface declarations (TS) */
|
|
42
|
+
interfaces: CodeElement[];
|
|
43
|
+
/** Type alias declarations (TS) */
|
|
44
|
+
types: CodeElement[];
|
|
45
|
+
/** Variable/constant declarations */
|
|
46
|
+
variables: CodeElement[];
|
|
47
|
+
}
|
|
48
|
+
export interface ExtractedContent {
|
|
49
|
+
/** Extracted code content */
|
|
50
|
+
content: string;
|
|
51
|
+
/** Elements that were extracted */
|
|
52
|
+
elements: CodeElement[];
|
|
53
|
+
/** Related import statements */
|
|
54
|
+
relatedImports: string[];
|
|
55
|
+
/** Start line of extraction */
|
|
56
|
+
startLine: number;
|
|
57
|
+
/** End line of extraction */
|
|
58
|
+
endLine: number;
|
|
59
|
+
}
|
|
60
|
+
export interface ExtractionTarget {
|
|
61
|
+
/** Type of element to find */
|
|
62
|
+
type: ElementType;
|
|
63
|
+
/** Name of element to find */
|
|
64
|
+
name: string;
|
|
65
|
+
}
|
|
66
|
+
export interface ExtractionOptions {
|
|
67
|
+
/** Include related imports */
|
|
68
|
+
includeImports: boolean;
|
|
69
|
+
/** Include JSDoc/docstring comments */
|
|
70
|
+
includeComments: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Options for parsing control
|
|
74
|
+
*/
|
|
75
|
+
export interface ParseOptions {
|
|
76
|
+
/** Extract signature and documentation (default: false for performance) */
|
|
77
|
+
detailed?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Parser interface that all language parsers must implement
|
|
81
|
+
*/
|
|
82
|
+
export interface LanguageParser {
|
|
83
|
+
/** Supported languages */
|
|
84
|
+
languages: SupportedLanguage[];
|
|
85
|
+
/** Parse file content and return structure */
|
|
86
|
+
parse(content: string, options?: ParseOptions): FileStructure;
|
|
87
|
+
/** Extract a specific element by target */
|
|
88
|
+
extractElement(content: string, target: ExtractionTarget, options: ExtractionOptions): ExtractedContent | null;
|
|
89
|
+
/** Search for elements matching a query */
|
|
90
|
+
searchElements(content: string, query: string): CodeElement[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create an empty file structure
|
|
94
|
+
*/
|
|
95
|
+
export declare function createEmptyStructure(language: SupportedLanguage, totalLines: number): FileStructure;
|
|
96
|
+
//# source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AE,UAAU,EAAE,MAAM,GAAG,aAAa,CAYnG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Types
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions for code parsing and extraction.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create an empty file structure
|
|
8
|
+
*/
|
|
9
|
+
export function createEmptyStructure(language, totalLines) {
|
|
10
|
+
return {
|
|
11
|
+
language,
|
|
12
|
+
totalLines,
|
|
13
|
+
imports: [],
|
|
14
|
+
exports: [],
|
|
15
|
+
functions: [],
|
|
16
|
+
classes: [],
|
|
17
|
+
interfaces: [],
|
|
18
|
+
types: [],
|
|
19
|
+
variables: [],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript Parser
|
|
3
|
+
*
|
|
4
|
+
* Uses TypeScript Compiler API for accurate AST parsing.
|
|
5
|
+
*/
|
|
6
|
+
import type { CodeElement, FileStructure, ExtractedContent, ExtractionTarget, ExtractionOptions, ParseOptions, LanguageParser } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Parse TypeScript/JavaScript content into FileStructure
|
|
9
|
+
* @param options ParseOptions - set detailed: true to extract signature/documentation
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseTypeScript(content: string, isTypeScript?: boolean, options?: ParseOptions): FileStructure;
|
|
12
|
+
/**
|
|
13
|
+
* Extract a specific element from TypeScript content
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractTypeScriptElement(content: string, target: ExtractionTarget, options: ExtractionOptions, isTypeScript?: boolean): ExtractedContent | null;
|
|
16
|
+
/**
|
|
17
|
+
* Search for elements matching a query
|
|
18
|
+
*/
|
|
19
|
+
export declare function searchTypeScriptElements(content: string, query: string): CodeElement[];
|
|
20
|
+
/**
|
|
21
|
+
* TypeScript parser implementation
|
|
22
|
+
*/
|
|
23
|
+
export declare const typescriptParser: LanguageParser;
|
|
24
|
+
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/ast/typescript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EAEf,MAAM,YAAY,CAAC;AAyDpB;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,YAAY,GAAE,OAAc,EAC5B,OAAO,GAAE,YAAiB,GACzB,aAAa,CAkMf;AAuCD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,iBAAiB,EAC1B,YAAY,GAAE,OAAc,GAC3B,gBAAgB,GAAG,IAAI,CA+DzB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAyBtF;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAkB9B,CAAC"}
|