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,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart File Read Tool
|
|
3
|
+
*
|
|
4
|
+
* Reads files intelligently using AST analysis to extract only
|
|
5
|
+
* relevant portions (functions, classes, types) instead of full files.
|
|
6
|
+
*
|
|
7
|
+
* Security: Path sandboxing restricts file access to the working directory.
|
|
8
|
+
*/
|
|
9
|
+
import * as fs from "fs/promises";
|
|
10
|
+
import * as path from "path";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { parseFile, extractElement, searchElements, extractLines, formatStructureSummary, hasParserSupport, } from "../ast/index.js";
|
|
13
|
+
import { detectLanguageFromPath } from "../utils/language-detector.js";
|
|
14
|
+
import { getGlobalCache } from "../cache/smart-cache.js";
|
|
15
|
+
// Parseable languages (excluding json, yaml, unknown)
|
|
16
|
+
const PARSEABLE_LANGUAGES = [
|
|
17
|
+
"typescript",
|
|
18
|
+
"javascript",
|
|
19
|
+
"python",
|
|
20
|
+
"go",
|
|
21
|
+
"rust",
|
|
22
|
+
"php",
|
|
23
|
+
"swift",
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Validate and normalize a language string
|
|
27
|
+
*/
|
|
28
|
+
function validateLanguage(lang) {
|
|
29
|
+
const normalized = lang.toLowerCase().trim();
|
|
30
|
+
if (PARSEABLE_LANGUAGES.includes(normalized)) {
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
// Handle common aliases
|
|
34
|
+
const aliases = {
|
|
35
|
+
ts: "typescript",
|
|
36
|
+
js: "javascript",
|
|
37
|
+
py: "python",
|
|
38
|
+
golang: "go",
|
|
39
|
+
rs: "rust",
|
|
40
|
+
};
|
|
41
|
+
return aliases[normalized] || null;
|
|
42
|
+
}
|
|
43
|
+
// Sensitive file patterns that should never be read
|
|
44
|
+
const BLOCKED_PATTERNS = [
|
|
45
|
+
/\.env($|\.)/i, // .env files
|
|
46
|
+
/\.pem$/i, // Private keys
|
|
47
|
+
/\.key$/i, // Key files
|
|
48
|
+
/id_rsa/i, // SSH keys
|
|
49
|
+
/id_ed25519/i, // SSH keys
|
|
50
|
+
/credentials/i, // Credentials files
|
|
51
|
+
/secrets?\./i, // Secret files
|
|
52
|
+
/\.keystore$/i, // Java keystores
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* Validate that a file path is safe to read
|
|
56
|
+
* - Must be within the working directory (no directory traversal)
|
|
57
|
+
* - Must not match sensitive file patterns
|
|
58
|
+
*/
|
|
59
|
+
function validatePath(filePath, workingDir) {
|
|
60
|
+
// Resolve to absolute path
|
|
61
|
+
const resolvedPath = path.isAbsolute(filePath)
|
|
62
|
+
? path.normalize(filePath)
|
|
63
|
+
: path.resolve(workingDir, filePath);
|
|
64
|
+
// Normalize both paths for comparison
|
|
65
|
+
const normalizedResolved = path.normalize(resolvedPath);
|
|
66
|
+
const normalizedWorkingDir = path.normalize(workingDir);
|
|
67
|
+
// Check if resolved path is within working directory
|
|
68
|
+
if (!normalizedResolved.startsWith(normalizedWorkingDir + path.sep) &&
|
|
69
|
+
normalizedResolved !== normalizedWorkingDir) {
|
|
70
|
+
return {
|
|
71
|
+
safe: false,
|
|
72
|
+
error: `Access denied: Path '${filePath}' is outside the working directory. Only files within '${workingDir}' can be read.`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Check for blocked patterns
|
|
76
|
+
const basename = path.basename(resolvedPath);
|
|
77
|
+
for (const pattern of BLOCKED_PATTERNS) {
|
|
78
|
+
if (pattern.test(basename) || pattern.test(resolvedPath)) {
|
|
79
|
+
return {
|
|
80
|
+
safe: false,
|
|
81
|
+
error: `Access denied: Cannot read sensitive file '${basename}'. This file type is blocked for security reasons.`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { safe: true, resolvedPath };
|
|
86
|
+
}
|
|
87
|
+
// Minimal schema for MCP - removes rarely-used properties to save tokens
|
|
88
|
+
// Full validation is done by Zod inputSchema below
|
|
89
|
+
export const smartFileReadSchema = {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
filePath: { type: "string" },
|
|
93
|
+
target: {
|
|
94
|
+
properties: {
|
|
95
|
+
type: { enum: ["function", "class", "interface", "type", "variable", "method"] },
|
|
96
|
+
name: { type: "string" },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
query: { type: "string" },
|
|
100
|
+
lines: {
|
|
101
|
+
properties: { start: { type: "number" }, end: { type: "number" } },
|
|
102
|
+
},
|
|
103
|
+
skeleton: { type: "boolean" },
|
|
104
|
+
// Rarely-used properties omitted from schema but still supported:
|
|
105
|
+
// cache, language, format, includeImports, includeComments
|
|
106
|
+
},
|
|
107
|
+
required: ["filePath"],
|
|
108
|
+
};
|
|
109
|
+
const inputSchema = z.object({
|
|
110
|
+
filePath: z.string(),
|
|
111
|
+
target: z
|
|
112
|
+
.object({
|
|
113
|
+
type: z.enum(["function", "class", "interface", "type", "variable", "method"]),
|
|
114
|
+
name: z.string(),
|
|
115
|
+
})
|
|
116
|
+
.optional(),
|
|
117
|
+
query: z.string().optional(),
|
|
118
|
+
includeImports: z.boolean().optional().default(true),
|
|
119
|
+
includeComments: z.boolean().optional().default(true),
|
|
120
|
+
lines: z
|
|
121
|
+
.object({
|
|
122
|
+
start: z.number(),
|
|
123
|
+
end: z.number(),
|
|
124
|
+
})
|
|
125
|
+
.optional(),
|
|
126
|
+
skeleton: z.boolean().optional().default(false),
|
|
127
|
+
cache: z.boolean().optional().default(true),
|
|
128
|
+
language: z.string().optional(),
|
|
129
|
+
format: z.enum(["plain", "markdown"]).optional().default("plain"),
|
|
130
|
+
});
|
|
131
|
+
function formatExtractedContent(extracted, filePath, language, totalLines, includeImports, format = "plain") {
|
|
132
|
+
const parts = [];
|
|
133
|
+
const element = extracted.elements[0];
|
|
134
|
+
const md = format === "markdown";
|
|
135
|
+
if (element) {
|
|
136
|
+
parts.push(md ? `## Extracted: ${element.type} \`${element.name}\`` : `[${element.type}] ${element.name}`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
parts.push(md ? `## Extracted: lines ${extracted.startLine}-${extracted.endLine}` : `[lines ${extracted.startLine}-${extracted.endLine}]`);
|
|
140
|
+
}
|
|
141
|
+
parts.push(md ? "" : `${filePath}:${extracted.startLine}-${extracted.endLine} (${language}, ${totalLines} lines)`);
|
|
142
|
+
if (md) {
|
|
143
|
+
parts.push(`**File:** ${filePath}`);
|
|
144
|
+
parts.push(`**Lines:** ${extracted.startLine}-${extracted.endLine} of ${totalLines}`);
|
|
145
|
+
parts.push("");
|
|
146
|
+
}
|
|
147
|
+
// Add related imports if present
|
|
148
|
+
if (includeImports && extracted.relatedImports.length > 0) {
|
|
149
|
+
if (md)
|
|
150
|
+
parts.push("```" + language);
|
|
151
|
+
parts.push("// Related imports");
|
|
152
|
+
for (const imp of extracted.relatedImports) {
|
|
153
|
+
parts.push(imp);
|
|
154
|
+
}
|
|
155
|
+
parts.push("");
|
|
156
|
+
parts.push(extracted.content);
|
|
157
|
+
if (md)
|
|
158
|
+
parts.push("```");
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
if (md)
|
|
162
|
+
parts.push("```" + language);
|
|
163
|
+
parts.push(extracted.content);
|
|
164
|
+
if (md)
|
|
165
|
+
parts.push("```");
|
|
166
|
+
}
|
|
167
|
+
// Token savings estimate
|
|
168
|
+
const extractedLines = extracted.endLine - extracted.startLine + 1;
|
|
169
|
+
const savedLines = totalLines - extractedLines;
|
|
170
|
+
if (savedLines > 0 && totalLines > 10) {
|
|
171
|
+
const savingsPercent = Math.round((savedLines / totalLines) * 100);
|
|
172
|
+
parts.push(md ? "" : "---");
|
|
173
|
+
parts.push(md
|
|
174
|
+
? `**Extracted:** ${extractedLines} lines (of ${totalLines}) - ${savingsPercent}% reduction`
|
|
175
|
+
: `Extracted: ${extractedLines}/${totalLines} lines (${savingsPercent}% reduction)`);
|
|
176
|
+
}
|
|
177
|
+
return parts.join("\n");
|
|
178
|
+
}
|
|
179
|
+
function formatSearchResults(results, filePath, query, format = "plain") {
|
|
180
|
+
const parts = [];
|
|
181
|
+
const md = format === "markdown";
|
|
182
|
+
parts.push(md ? `## Search Results: "${query}"` : `Search: "${query}" in ${filePath}`);
|
|
183
|
+
if (md) {
|
|
184
|
+
parts.push(`**File:** ${filePath}`);
|
|
185
|
+
parts.push(`**Matches:** ${results.length}`);
|
|
186
|
+
parts.push("");
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
parts.push(`Matches: ${results.length}`);
|
|
190
|
+
}
|
|
191
|
+
if (results.length === 0) {
|
|
192
|
+
parts.push("No matches found.");
|
|
193
|
+
return parts.join("\n");
|
|
194
|
+
}
|
|
195
|
+
for (const element of results) {
|
|
196
|
+
const prefix = element.parent ? `${element.parent}.` : "";
|
|
197
|
+
const exported = element.isExported ? " (exported)" : "";
|
|
198
|
+
const async = element.isAsync ? " async" : "";
|
|
199
|
+
if (md) {
|
|
200
|
+
parts.push(`- **${element.type}** \`${prefix}${element.name}\`${exported}${async} - lines ${element.startLine}-${element.endLine}`);
|
|
201
|
+
if (element.signature) {
|
|
202
|
+
parts.push(` \`${element.signature}\``);
|
|
203
|
+
}
|
|
204
|
+
if (element.documentation) {
|
|
205
|
+
const docPreview = element.documentation.split("\n")[0]?.slice(0, 80);
|
|
206
|
+
if (docPreview) {
|
|
207
|
+
parts.push(` _${docPreview}${element.documentation.length > 80 ? "..." : ""}_`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
parts.push(`${element.type} ${prefix}${element.name}${exported}${async} (${element.startLine}-${element.endLine})`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (md) {
|
|
216
|
+
parts.push("");
|
|
217
|
+
parts.push("Use `target: { type, name }` to extract a specific element.");
|
|
218
|
+
}
|
|
219
|
+
return parts.join("\n");
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Format file structure as a skeleton (signatures only, no bodies)
|
|
223
|
+
* This provides a compact overview of a file's API surface.
|
|
224
|
+
* @param quickMode When true, only shows start line (from quick scan mode)
|
|
225
|
+
*/
|
|
226
|
+
function formatSkeletonOutput(structure, filePath, languageId, totalLines, format = "plain", quickMode = false) {
|
|
227
|
+
const parts = [];
|
|
228
|
+
const md = format === "markdown";
|
|
229
|
+
// Format line reference: quick mode shows only start line, full mode shows range
|
|
230
|
+
const lineRef = (el) => quickMode || el.startLine === el.endLine ? `(${el.startLine})` : `(${el.startLine}-${el.endLine})`;
|
|
231
|
+
parts.push(md ? `## File Skeleton: ${filePath}` : `${filePath} (${languageId}, ${totalLines} lines)`);
|
|
232
|
+
if (md) {
|
|
233
|
+
parts.push("");
|
|
234
|
+
parts.push(`**Language:** ${languageId}`);
|
|
235
|
+
parts.push(`**Total Lines:** ${totalLines}`);
|
|
236
|
+
parts.push("");
|
|
237
|
+
}
|
|
238
|
+
let elementCount = 0;
|
|
239
|
+
// Imports summary (collapsed, max 3)
|
|
240
|
+
if (structure.imports?.length) {
|
|
241
|
+
if (md) {
|
|
242
|
+
parts.push(`### Imports (${structure.imports.length})`);
|
|
243
|
+
const displayImports = structure.imports.slice(0, 3);
|
|
244
|
+
for (const imp of displayImports) {
|
|
245
|
+
parts.push(`- \`${imp}\``);
|
|
246
|
+
}
|
|
247
|
+
if (structure.imports.length > 3) {
|
|
248
|
+
parts.push(`- ... and ${structure.imports.length - 3} more`);
|
|
249
|
+
}
|
|
250
|
+
parts.push("");
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const importList = structure.imports.slice(0, 3).join(", ");
|
|
254
|
+
const more = structure.imports.length > 3 ? ` +${structure.imports.length - 3}` : "";
|
|
255
|
+
parts.push(`IMPORTS: ${importList}${more}`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Types and Interfaces (no line numbers in plain - minor elements)
|
|
259
|
+
if (structure.types?.length) {
|
|
260
|
+
if (md) {
|
|
261
|
+
parts.push("### Types/Interfaces");
|
|
262
|
+
for (const t of structure.types) {
|
|
263
|
+
const exported = t.isExported ? "export " : "";
|
|
264
|
+
parts.push(`- \`${exported}${t.signature || t.name}\``);
|
|
265
|
+
elementCount++;
|
|
266
|
+
}
|
|
267
|
+
parts.push("");
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
const typeList = structure.types.map(t => t.name).join(", ");
|
|
271
|
+
parts.push(`TYPES: ${typeList}`);
|
|
272
|
+
elementCount += structure.types.length;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// Functions (signatures only)
|
|
276
|
+
const functions = structure.functions?.filter((f) => !f.parent) || [];
|
|
277
|
+
if (functions.length) {
|
|
278
|
+
if (md) {
|
|
279
|
+
parts.push("### Functions");
|
|
280
|
+
for (const fn of functions) {
|
|
281
|
+
const exported = fn.isExported ? "export " : "";
|
|
282
|
+
const asyncMod = fn.isAsync ? "async " : "";
|
|
283
|
+
const sig = fn.signature || `${fn.name}()`;
|
|
284
|
+
parts.push(`- \`${exported}${asyncMod}${sig}\` (lines ${lineRef(fn).slice(1, -1)})`);
|
|
285
|
+
elementCount++;
|
|
286
|
+
}
|
|
287
|
+
parts.push("");
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
const fnList = functions.map(fn => `${fn.name} ${lineRef(fn)}`).join(", ");
|
|
291
|
+
parts.push(`FUNCTIONS: ${fnList}`);
|
|
292
|
+
elementCount += functions.length;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Classes with method signatures
|
|
296
|
+
if (structure.classes?.length) {
|
|
297
|
+
if (md) {
|
|
298
|
+
parts.push("### Classes");
|
|
299
|
+
for (const cls of structure.classes) {
|
|
300
|
+
const exported = cls.isExported ? "export " : "";
|
|
301
|
+
parts.push(`- \`${exported}class ${cls.name}\` (lines ${lineRef(cls).slice(1, -1)})`);
|
|
302
|
+
elementCount++;
|
|
303
|
+
const methods = structure.functions?.filter((f) => f.parent === cls.name) || [];
|
|
304
|
+
for (const m of methods) {
|
|
305
|
+
const asyncMod = m.isAsync ? "async " : "";
|
|
306
|
+
const sig = m.signature || `${m.name}()`;
|
|
307
|
+
parts.push(` - \`${asyncMod}${sig}\``);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
parts.push("");
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
const clsList = structure.classes.map(cls => {
|
|
314
|
+
const methods = structure.functions?.filter((f) => f.parent === cls.name) || [];
|
|
315
|
+
const methodNames = methods.length > 0 ? ` [${methods.map(m => m.name).join(", ")}]` : "";
|
|
316
|
+
return `${cls.name} ${lineRef(cls)}${methodNames}`;
|
|
317
|
+
}).join(", ");
|
|
318
|
+
parts.push(`CLASSES: ${clsList}`);
|
|
319
|
+
elementCount += structure.classes.length;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// Variables (exported only for skeleton)
|
|
323
|
+
const exportedVars = structure.variables?.filter((v) => v.isExported) || [];
|
|
324
|
+
if (exportedVars.length) {
|
|
325
|
+
if (md) {
|
|
326
|
+
parts.push("### Exported Variables");
|
|
327
|
+
for (const v of exportedVars) {
|
|
328
|
+
parts.push(`- \`${v.signature || v.name}\``);
|
|
329
|
+
elementCount++;
|
|
330
|
+
}
|
|
331
|
+
parts.push("");
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
const varList = exportedVars.map(v => v.name).join(", ");
|
|
335
|
+
parts.push(`EXPORTS: ${varList}`);
|
|
336
|
+
elementCount += exportedVars.length;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
// Skeleton summary
|
|
340
|
+
if (md) {
|
|
341
|
+
parts.push("---");
|
|
342
|
+
parts.push(`**Skeleton:** ${elementCount} elements extracted (use \`target\` to get full implementation)`);
|
|
343
|
+
}
|
|
344
|
+
return parts.join("\n");
|
|
345
|
+
}
|
|
346
|
+
export async function executeSmartFileRead(args) {
|
|
347
|
+
const input = inputSchema.parse(args);
|
|
348
|
+
const workingDir = process.cwd();
|
|
349
|
+
// Validate path for security (sandboxing)
|
|
350
|
+
const validation = validatePath(input.filePath, workingDir);
|
|
351
|
+
if (!validation.safe || !validation.resolvedPath) {
|
|
352
|
+
return {
|
|
353
|
+
content: [{ type: "text", text: validation.error || "Invalid path" }],
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
const resolvedPath = validation.resolvedPath;
|
|
357
|
+
// Check if file exists
|
|
358
|
+
try {
|
|
359
|
+
await fs.access(resolvedPath);
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return {
|
|
363
|
+
content: [{ type: "text", text: `File not found: ${resolvedPath}` }],
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
// Read file content
|
|
367
|
+
const content = await fs.readFile(resolvedPath, "utf-8");
|
|
368
|
+
const totalLines = content.split("\n").length;
|
|
369
|
+
// Detect or force language
|
|
370
|
+
let language;
|
|
371
|
+
if (input.language) {
|
|
372
|
+
const forcedLang = validateLanguage(input.language);
|
|
373
|
+
if (!forcedLang) {
|
|
374
|
+
return {
|
|
375
|
+
content: [
|
|
376
|
+
{
|
|
377
|
+
type: "text",
|
|
378
|
+
text: `Unsupported language: '${input.language}'. Supported: ${PARSEABLE_LANGUAGES.join(", ")} (or aliases: ts, js, py, golang, rs)`,
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
language = forcedLang;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
language = detectLanguageFromPath(resolvedPath);
|
|
387
|
+
}
|
|
388
|
+
const languageId = language === "typescript" ? "typescript" : language === "javascript" ? "javascript" : language;
|
|
389
|
+
// Cache setup
|
|
390
|
+
const cache = getGlobalCache();
|
|
391
|
+
const cacheKey = `smart-read:${resolvedPath}:${JSON.stringify({
|
|
392
|
+
target: input.target,
|
|
393
|
+
query: input.query,
|
|
394
|
+
skeleton: input.skeleton,
|
|
395
|
+
lines: input.lines,
|
|
396
|
+
language: input.language,
|
|
397
|
+
format: input.format,
|
|
398
|
+
})}`;
|
|
399
|
+
// Check cache if enabled
|
|
400
|
+
if (input.cache !== false) {
|
|
401
|
+
const cached = await cache.get(cacheKey);
|
|
402
|
+
if (cached.hit && cached.value) {
|
|
403
|
+
return { content: [{ type: "text", text: cached.value + "\n\n_📦 (from cache)_" }] };
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
// Helper to cache and return result
|
|
407
|
+
const cacheAndReturn = async (result) => {
|
|
408
|
+
if (input.cache !== false) {
|
|
409
|
+
await cache.set(cacheKey, result, { filePath: resolvedPath });
|
|
410
|
+
}
|
|
411
|
+
return { content: [{ type: "text", text: result }] };
|
|
412
|
+
};
|
|
413
|
+
// Priority 1: Extract specific line range (no caching - simple operation)
|
|
414
|
+
if (input.lines) {
|
|
415
|
+
const extracted = extractLines(content, input.lines.start, input.lines.end);
|
|
416
|
+
const result = formatExtractedContent(extracted, input.filePath, languageId, totalLines, false, input.format);
|
|
417
|
+
return { content: [{ type: "text", text: result }] };
|
|
418
|
+
}
|
|
419
|
+
// Check if we have parser support
|
|
420
|
+
if (!hasParserSupport(language)) {
|
|
421
|
+
// Fallback: return full file with warning
|
|
422
|
+
const parts = [];
|
|
423
|
+
const md = input.format === "markdown";
|
|
424
|
+
if (md) {
|
|
425
|
+
parts.push(`## File: ${input.filePath}`);
|
|
426
|
+
parts.push("");
|
|
427
|
+
parts.push(`**Language:** ${language} (no AST support, returning full file)`);
|
|
428
|
+
parts.push(`**Lines:** ${totalLines}`);
|
|
429
|
+
parts.push("");
|
|
430
|
+
parts.push("```" + languageId);
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
parts.push(`${input.filePath} (${language}, ${totalLines} lines, no AST support)`);
|
|
434
|
+
}
|
|
435
|
+
parts.push(content);
|
|
436
|
+
if (md)
|
|
437
|
+
parts.push("```");
|
|
438
|
+
return { content: [{ type: "text", text: parts.join("\n") }] };
|
|
439
|
+
}
|
|
440
|
+
// Priority 2: Skeleton mode - signatures only overview (uses quick regex scan)
|
|
441
|
+
if (input.skeleton) {
|
|
442
|
+
const structure = parseFile(content, language, "quick");
|
|
443
|
+
const skeleton = formatSkeletonOutput(structure, input.filePath, languageId, totalLines, input.format, true);
|
|
444
|
+
return cacheAndReturn(skeleton);
|
|
445
|
+
}
|
|
446
|
+
// Priority 3: Extract specific target element
|
|
447
|
+
if (input.target) {
|
|
448
|
+
const extracted = extractElement(content, language, input.target, {
|
|
449
|
+
includeImports: input.includeImports,
|
|
450
|
+
includeComments: input.includeComments,
|
|
451
|
+
});
|
|
452
|
+
if (!extracted) {
|
|
453
|
+
return {
|
|
454
|
+
content: [
|
|
455
|
+
{
|
|
456
|
+
type: "text",
|
|
457
|
+
text: `${input.target.type} '${input.target.name}' not found in ${input.filePath}`,
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
const result = formatExtractedContent(extracted, input.filePath, languageId, totalLines, input.includeImports, input.format);
|
|
463
|
+
return cacheAndReturn(result);
|
|
464
|
+
}
|
|
465
|
+
// Priority 4: Search by query
|
|
466
|
+
if (input.query) {
|
|
467
|
+
const results = searchElements(content, language, input.query);
|
|
468
|
+
const result = formatSearchResults(results, input.filePath, input.query, input.format);
|
|
469
|
+
return cacheAndReturn(result);
|
|
470
|
+
}
|
|
471
|
+
// Default: Return file structure summary
|
|
472
|
+
const structure = parseFile(content, language);
|
|
473
|
+
const summary = formatStructureSummary(structure, input.filePath, input.format);
|
|
474
|
+
return cacheAndReturn(summary);
|
|
475
|
+
}
|
|
476
|
+
export const smartFileReadTool = {
|
|
477
|
+
name: "smart_file_read",
|
|
478
|
+
description: "Read code with AST extraction. Modes: structure, target, query, lines, skeleton.",
|
|
479
|
+
inputSchema: smartFileReadSchema,
|
|
480
|
+
execute: executeSmartFileRead,
|
|
481
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Pipeline Tool
|
|
3
|
+
*
|
|
4
|
+
* Automatically chains compression tools based on detected content type.
|
|
5
|
+
* Executes multiple optimization steps sequentially with result passthrough.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolDefinition } from "./registry.js";
|
|
8
|
+
/**
|
|
9
|
+
* JSON Schema for MCP tool registration
|
|
10
|
+
*/
|
|
11
|
+
export declare const smartPipelineSchema: {
|
|
12
|
+
type: "object";
|
|
13
|
+
properties: {
|
|
14
|
+
content: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
mode: {
|
|
18
|
+
enum: string[];
|
|
19
|
+
};
|
|
20
|
+
contentType: {
|
|
21
|
+
enum: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
required: string[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Execute the smart pipeline tool
|
|
28
|
+
*/
|
|
29
|
+
export declare function executeSmartPipeline(args: unknown): Promise<{
|
|
30
|
+
content: Array<{
|
|
31
|
+
type: "text";
|
|
32
|
+
text: string;
|
|
33
|
+
}>;
|
|
34
|
+
isError?: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Tool definition for MCP registration
|
|
38
|
+
*/
|
|
39
|
+
export declare const smartPipelineTool: ToolDefinition;
|
|
40
|
+
//# sourceMappingURL=smart-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-pipeline.d.ts","sourceRoot":"","sources":["../../src/tools/smart-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAiBpD;;GAEG;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;CAQ/B,CAAC;AAmOF;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,CA6FD;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,cAK/B,CAAC"}
|