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,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy MCP - Pattern for 95% token reduction
|
|
3
|
+
*
|
|
4
|
+
* Implements the lazy-mcp pattern where only 2 meta-tools are exposed:
|
|
5
|
+
* - browse_tools: Navigate the tool hierarchy
|
|
6
|
+
* - run_tool: Execute any tool by name
|
|
7
|
+
*
|
|
8
|
+
* This reduces initial context from ~15,000 tokens to ~800 tokens.
|
|
9
|
+
*
|
|
10
|
+
* @see https://github.com/voicetreelab/lazy-mcp
|
|
11
|
+
*/
|
|
12
|
+
import { getDynamicLoader, TOOL_CATALOG } from "./dynamic-loader.js";
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// browse_tools - Navigate the tool hierarchy
|
|
15
|
+
// ============================================================================
|
|
16
|
+
const browseToolsSchema = {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
category: {
|
|
20
|
+
type: "string",
|
|
21
|
+
enum: ["compress", "analyze", "logs", "code", "pipeline"],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
async function executeBrowseTools(args) {
|
|
26
|
+
const { category } = args;
|
|
27
|
+
const loader = getDynamicLoader();
|
|
28
|
+
if (!category) {
|
|
29
|
+
// Return category overview with tool counts
|
|
30
|
+
const categories = new Map();
|
|
31
|
+
for (const tool of TOOL_CATALOG) {
|
|
32
|
+
if (tool.category !== "core") {
|
|
33
|
+
categories.set(tool.category, (categories.get(tool.category) || 0) + 1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const lines = ["ctxopt/", ""];
|
|
37
|
+
for (const [cat, count] of categories) {
|
|
38
|
+
lines.push(` ${cat}/ (${count} tools)`);
|
|
39
|
+
}
|
|
40
|
+
lines.push("");
|
|
41
|
+
lines.push("Use category to list tools. Use run_tool to execute.");
|
|
42
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
43
|
+
}
|
|
44
|
+
// Return tools in category
|
|
45
|
+
const tools = loader.getToolsByCategory(category);
|
|
46
|
+
if (tools.length === 0) {
|
|
47
|
+
return {
|
|
48
|
+
content: [{ type: "text", text: `No tools in category: ${category}` }],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const lines = [`ctxopt/${category}/`, ""];
|
|
52
|
+
for (const tool of tools) {
|
|
53
|
+
lines.push(` ${tool.name}: ${tool.description}`);
|
|
54
|
+
}
|
|
55
|
+
lines.push("");
|
|
56
|
+
const firstTool = tools[0];
|
|
57
|
+
if (firstTool) {
|
|
58
|
+
lines.push(`run_tool name="${firstTool.name}" args={...}`);
|
|
59
|
+
}
|
|
60
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
61
|
+
}
|
|
62
|
+
export const browseToolsTool = {
|
|
63
|
+
name: "browse_tools",
|
|
64
|
+
description: "List tool categories or tools in a category. Omit category for overview.",
|
|
65
|
+
inputSchema: browseToolsSchema,
|
|
66
|
+
execute: executeBrowseTools,
|
|
67
|
+
};
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// run_tool - Execute any tool by name
|
|
70
|
+
// ============================================================================
|
|
71
|
+
const runToolSchema = {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
name: { type: "string" },
|
|
75
|
+
args: { type: "object" },
|
|
76
|
+
},
|
|
77
|
+
required: ["name"],
|
|
78
|
+
};
|
|
79
|
+
// Registry reference for tool execution (set by server)
|
|
80
|
+
let registryRef = null;
|
|
81
|
+
/**
|
|
82
|
+
* Set the registry reference for tool execution
|
|
83
|
+
* Called by the server during initialization
|
|
84
|
+
*/
|
|
85
|
+
export function setLazyMcpRegistry(registry) {
|
|
86
|
+
registryRef = registry;
|
|
87
|
+
}
|
|
88
|
+
async function executeRunTool(args) {
|
|
89
|
+
const { name, args: toolArgs = {} } = args;
|
|
90
|
+
// Check if tool exists in catalog
|
|
91
|
+
const toolMeta = TOOL_CATALOG.find((t) => t.name === name);
|
|
92
|
+
if (!toolMeta) {
|
|
93
|
+
const available = TOOL_CATALOG.map((t) => t.name).join(", ");
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: "text",
|
|
98
|
+
text: `Unknown tool: ${name}\n\nAvailable: ${available}`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
isError: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// Load tool if not already loaded
|
|
105
|
+
const loader = getDynamicLoader();
|
|
106
|
+
if (!loader.isLoaded(name)) {
|
|
107
|
+
await loader.loadByNames([name]);
|
|
108
|
+
}
|
|
109
|
+
// Execute via registry (which applies middleware)
|
|
110
|
+
if (!registryRef) {
|
|
111
|
+
// Fallback: direct execution without middleware
|
|
112
|
+
const loadedTools = loader.getLoadedTools();
|
|
113
|
+
const tool = loadedTools.find((t) => t.name === name);
|
|
114
|
+
if (!tool) {
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: `Failed to load tool: ${name}` }],
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return tool.execute(toolArgs);
|
|
121
|
+
}
|
|
122
|
+
// Use registry for proper middleware chain
|
|
123
|
+
const result = await registryRef.execute(name, toolArgs);
|
|
124
|
+
return {
|
|
125
|
+
content: result.content,
|
|
126
|
+
isError: result.isError,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export const runToolTool = {
|
|
130
|
+
name: "run_tool",
|
|
131
|
+
description: "Execute a tool by name. Use browse_tools to find tools.",
|
|
132
|
+
inputSchema: runToolSchema,
|
|
133
|
+
execute: executeRunTool,
|
|
134
|
+
};
|
|
135
|
+
// ============================================================================
|
|
136
|
+
// Lazy MCP meta-tools collection
|
|
137
|
+
// ============================================================================
|
|
138
|
+
export const lazyMcpTools = [browseToolsTool, runToolTool];
|
|
139
|
+
/**
|
|
140
|
+
* Calculate token savings from lazy loading
|
|
141
|
+
*/
|
|
142
|
+
export function calculateLazySavings() {
|
|
143
|
+
// Approximate token counts based on schema sizes
|
|
144
|
+
const lazyTokens = 150; // 2 simple tools with minimal schemas
|
|
145
|
+
const fullTokens = TOOL_CATALOG.length * 100; // ~100 tokens per tool definition
|
|
146
|
+
return {
|
|
147
|
+
lazyTokens,
|
|
148
|
+
fullTokens,
|
|
149
|
+
savingsPercent: Math.round((1 - lazyTokens / fullTokens) * 100),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy MCP Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for the lazy-mcp pattern implementation:
|
|
5
|
+
* - browse_tools meta-tool for navigating tool hierarchy
|
|
6
|
+
* - run_tool meta-tool for executing tools by name
|
|
7
|
+
* - Token savings from lazy loading (95%+ reduction)
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=lazy-mcp.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-mcp.test.d.ts","sourceRoot":"","sources":["../../src/tools/lazy-mcp.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy MCP Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for the lazy-mcp pattern implementation:
|
|
5
|
+
* - browse_tools meta-tool for navigating tool hierarchy
|
|
6
|
+
* - run_tool meta-tool for executing tools by name
|
|
7
|
+
* - Token savings from lazy loading (95%+ reduction)
|
|
8
|
+
*/
|
|
9
|
+
import { describe, it, expect, beforeEach } from "vitest";
|
|
10
|
+
import { browseToolsTool, runToolTool, lazyMcpTools, setLazyMcpRegistry, calculateLazySavings, } from "./lazy-mcp.js";
|
|
11
|
+
import { resetDynamicLoader, TOOL_CATALOG } from "./dynamic-loader.js";
|
|
12
|
+
import { countTokens } from "../utils/token-counter.js";
|
|
13
|
+
describe("Lazy MCP Pattern", () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
resetDynamicLoader();
|
|
16
|
+
});
|
|
17
|
+
describe("browse_tools", () => {
|
|
18
|
+
it("should list categories when no category specified", async () => {
|
|
19
|
+
const result = await browseToolsTool.execute({});
|
|
20
|
+
const text = result.content[0]?.text ?? "";
|
|
21
|
+
expect(text).toContain("ctxopt/");
|
|
22
|
+
expect(text).toContain("compress/");
|
|
23
|
+
expect(text).toContain("analyze/");
|
|
24
|
+
expect(text).toContain("logs/");
|
|
25
|
+
expect(text).toContain("code/");
|
|
26
|
+
expect(text).toContain("pipeline/");
|
|
27
|
+
});
|
|
28
|
+
it("should list tools in a specific category", async () => {
|
|
29
|
+
const result = await browseToolsTool.execute({ category: "compress" });
|
|
30
|
+
const text = result.content[0]?.text ?? "";
|
|
31
|
+
expect(text).toContain("ctxopt/compress/");
|
|
32
|
+
expect(text).toContain("compress_context");
|
|
33
|
+
expect(text).toContain("semantic_compress");
|
|
34
|
+
});
|
|
35
|
+
it("should show tool count per category", async () => {
|
|
36
|
+
const result = await browseToolsTool.execute({});
|
|
37
|
+
const text = result.content[0]?.text ?? "";
|
|
38
|
+
// Should show something like "compress/ (4 tools)"
|
|
39
|
+
expect(text).toMatch(/\(\d+ tools?\)/);
|
|
40
|
+
});
|
|
41
|
+
it("should handle invalid category", async () => {
|
|
42
|
+
const result = await browseToolsTool.execute({ category: "invalid" });
|
|
43
|
+
const text = result.content[0]?.text ?? "";
|
|
44
|
+
expect(text).toContain("No tools in category");
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("run_tool", () => {
|
|
48
|
+
it("should execute a tool by name", async () => {
|
|
49
|
+
const result = await runToolTool.execute({
|
|
50
|
+
name: "auto_optimize",
|
|
51
|
+
args: { content: "test content that is long enough to process" },
|
|
52
|
+
});
|
|
53
|
+
// Should return tool output (not error about unknown tool)
|
|
54
|
+
expect(result.isError).not.toBe(true);
|
|
55
|
+
});
|
|
56
|
+
it("should return error for unknown tool", async () => {
|
|
57
|
+
const result = await runToolTool.execute({
|
|
58
|
+
name: "nonexistent_tool",
|
|
59
|
+
args: {},
|
|
60
|
+
});
|
|
61
|
+
const text = result.content[0]?.text ?? "";
|
|
62
|
+
expect(result.isError).toBe(true);
|
|
63
|
+
expect(text).toContain("Unknown tool");
|
|
64
|
+
});
|
|
65
|
+
it("should list available tools on error", async () => {
|
|
66
|
+
const result = await runToolTool.execute({
|
|
67
|
+
name: "bad_tool",
|
|
68
|
+
args: {},
|
|
69
|
+
});
|
|
70
|
+
const text = result.content[0]?.text ?? "";
|
|
71
|
+
expect(text).toContain("Available:");
|
|
72
|
+
expect(text).toContain("auto_optimize");
|
|
73
|
+
});
|
|
74
|
+
it("should pass args to the tool", async () => {
|
|
75
|
+
const result = await runToolTool.execute({
|
|
76
|
+
name: "auto_optimize",
|
|
77
|
+
args: {
|
|
78
|
+
content: "Error: Something went wrong\nError: Something went wrong",
|
|
79
|
+
hint: "errors",
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
expect(result.isError).not.toBe(true);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
describe("lazyMcpTools collection", () => {
|
|
86
|
+
it("should contain exactly 2 tools", () => {
|
|
87
|
+
expect(lazyMcpTools).toHaveLength(2);
|
|
88
|
+
});
|
|
89
|
+
it("should contain browse_tools and run_tool", () => {
|
|
90
|
+
const names = lazyMcpTools.map((t) => t.name);
|
|
91
|
+
expect(names).toContain("browse_tools");
|
|
92
|
+
expect(names).toContain("run_tool");
|
|
93
|
+
});
|
|
94
|
+
it("should have minimal schemas", () => {
|
|
95
|
+
for (const tool of lazyMcpTools) {
|
|
96
|
+
const schemaStr = JSON.stringify(tool.inputSchema);
|
|
97
|
+
const tokens = countTokens(schemaStr);
|
|
98
|
+
expect(tokens).toBeLessThan(100);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe("Token savings", () => {
|
|
103
|
+
it("should calculate significant savings", () => {
|
|
104
|
+
const savings = calculateLazySavings();
|
|
105
|
+
expect(savings.savingsPercent).toBeGreaterThan(80);
|
|
106
|
+
expect(savings.lazyTokens).toBeLessThan(savings.fullTokens);
|
|
107
|
+
console.log(` Lazy tokens: ${savings.lazyTokens}, Full tokens: ${savings.fullTokens}, Savings: ${savings.savingsPercent}%`);
|
|
108
|
+
});
|
|
109
|
+
it("should use fewer tokens than core loading", async () => {
|
|
110
|
+
// Calculate lazy mode tokens
|
|
111
|
+
const lazyTokens = lazyMcpTools.reduce((sum, tool) => {
|
|
112
|
+
const serialized = JSON.stringify({
|
|
113
|
+
name: tool.name,
|
|
114
|
+
description: tool.description,
|
|
115
|
+
inputSchema: tool.inputSchema,
|
|
116
|
+
});
|
|
117
|
+
return sum + countTokens(serialized);
|
|
118
|
+
}, 0);
|
|
119
|
+
// Calculate full catalog tokens (simulated)
|
|
120
|
+
const fullTokens = TOOL_CATALOG.length * 80; // ~80 tokens per tool
|
|
121
|
+
const savingsPercent = Math.round((1 - lazyTokens / fullTokens) * 100);
|
|
122
|
+
expect(savingsPercent).toBeGreaterThan(90);
|
|
123
|
+
console.log(` Lazy: ${lazyTokens} tokens, Full: ${fullTokens} tokens, Savings: ${savingsPercent}%`);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe("Registry integration", () => {
|
|
127
|
+
it("should work with custom registry", async () => {
|
|
128
|
+
let executedTool = "";
|
|
129
|
+
let executedArgs = null;
|
|
130
|
+
setLazyMcpRegistry({
|
|
131
|
+
execute: async (name, args) => {
|
|
132
|
+
executedTool = name;
|
|
133
|
+
executedArgs = args;
|
|
134
|
+
return { content: [{ type: "text", text: "mocked result" }] };
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const result = await runToolTool.execute({
|
|
138
|
+
name: "auto_optimize",
|
|
139
|
+
args: { content: "test" },
|
|
140
|
+
});
|
|
141
|
+
expect(executedTool).toBe("auto_optimize");
|
|
142
|
+
expect(executedArgs).toEqual({ content: "test" });
|
|
143
|
+
expect(result.content[0]?.text).toBe("mocked result");
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
describe("Lazy mode comparison", () => {
|
|
148
|
+
beforeEach(() => {
|
|
149
|
+
resetDynamicLoader();
|
|
150
|
+
});
|
|
151
|
+
it("should show lazy vs core vs all token usage", async () => {
|
|
152
|
+
// Lazy mode: 2 tools
|
|
153
|
+
const lazyTokens = lazyMcpTools.reduce((sum, tool) => {
|
|
154
|
+
const serialized = JSON.stringify({
|
|
155
|
+
name: tool.name,
|
|
156
|
+
description: tool.description,
|
|
157
|
+
inputSchema: tool.inputSchema,
|
|
158
|
+
});
|
|
159
|
+
return sum + countTokens(serialized);
|
|
160
|
+
}, 0);
|
|
161
|
+
// Simulated core mode: ~4 tools
|
|
162
|
+
const coreTokens = 4 * 80;
|
|
163
|
+
// Simulated all mode: all catalog tools
|
|
164
|
+
const allTokens = TOOL_CATALOG.length * 80;
|
|
165
|
+
console.log(` Mode comparison:`);
|
|
166
|
+
console.log(` lazy: ${lazyTokens} tokens (2 tools)`);
|
|
167
|
+
console.log(` core: ~${coreTokens} tokens (4 tools)`);
|
|
168
|
+
console.log(` all: ~${allTokens} tokens (${TOOL_CATALOG.length} tools)`);
|
|
169
|
+
expect(lazyTokens).toBeLessThan(coreTokens);
|
|
170
|
+
expect(coreTokens).toBeLessThan(allTokens);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-File Compress Tool
|
|
3
|
+
*
|
|
4
|
+
* Compresses multiple files with cross-file deduplication,
|
|
5
|
+
* extracting shared imports and types.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolDefinition } from "./registry.js";
|
|
8
|
+
export declare const multifileCompressSchema: {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: {
|
|
11
|
+
patterns: {
|
|
12
|
+
type: string;
|
|
13
|
+
items: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
strategy: {
|
|
19
|
+
type: string;
|
|
20
|
+
enum: string[];
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
maxTokens: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
action: {
|
|
28
|
+
type: string;
|
|
29
|
+
enum: string[];
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
required: string[];
|
|
34
|
+
};
|
|
35
|
+
export declare const multifileCompressTool: ToolDefinition;
|
|
36
|
+
//# sourceMappingURL=multifile-compress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multifile-compress.d.ts","sourceRoot":"","sources":["../../src/tools/multifile-compress.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAepD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBnC,CAAC;AAuPF,eAAO,MAAM,qBAAqB,EAAE,cAMnC,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-File Compress Tool
|
|
3
|
+
*
|
|
4
|
+
* Compresses multiple files with cross-file deduplication,
|
|
5
|
+
* extracting shared imports and types.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { compressMultiFile, extractSharedElements, createChunks, } from "../compressors/multifile.js";
|
|
11
|
+
import { detectLanguageFromPath } from "../utils/language-detector.js";
|
|
12
|
+
import { getSessionTracker } from "../analytics/session-tracker.js";
|
|
13
|
+
import { getOutputConfig } from "../config/output-config.js";
|
|
14
|
+
import { serializeResultToToon, } from "../utils/toon-serializer.js";
|
|
15
|
+
export const multifileCompressSchema = {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
patterns: {
|
|
19
|
+
type: "array",
|
|
20
|
+
items: { type: "string" },
|
|
21
|
+
description: "Glob patterns for files to compress (e.g., [\"src/**/*.ts\"])",
|
|
22
|
+
},
|
|
23
|
+
strategy: {
|
|
24
|
+
type: "string",
|
|
25
|
+
enum: ["deduplicate", "skeleton", "smart-chunk"],
|
|
26
|
+
description: "Compression strategy: deduplicate (default), skeleton, or smart-chunk",
|
|
27
|
+
},
|
|
28
|
+
maxTokens: {
|
|
29
|
+
type: "number",
|
|
30
|
+
description: "Maximum tokens for output (default: 50000)",
|
|
31
|
+
},
|
|
32
|
+
action: {
|
|
33
|
+
type: "string",
|
|
34
|
+
enum: ["compress", "extract-shared", "chunk"],
|
|
35
|
+
description: "Action: compress (default), extract-shared, or chunk",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ["patterns"],
|
|
39
|
+
};
|
|
40
|
+
const inputSchema = z.object({
|
|
41
|
+
patterns: z.array(z.string()).min(1),
|
|
42
|
+
strategy: z
|
|
43
|
+
.enum(["deduplicate", "skeleton", "smart-chunk"])
|
|
44
|
+
.optional()
|
|
45
|
+
.default("deduplicate"),
|
|
46
|
+
maxTokens: z.number().optional().default(50000),
|
|
47
|
+
action: z
|
|
48
|
+
.enum(["compress", "extract-shared", "chunk"])
|
|
49
|
+
.optional()
|
|
50
|
+
.default("compress"),
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Find files matching glob patterns (simple implementation)
|
|
54
|
+
*/
|
|
55
|
+
function findFiles(patterns, workingDir) {
|
|
56
|
+
const files = [];
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
function walkDir(dir, pattern) {
|
|
59
|
+
try {
|
|
60
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
const fullPath = path.join(dir, entry.name);
|
|
63
|
+
const relativePath = path.relative(workingDir, fullPath);
|
|
64
|
+
if (entry.isDirectory()) {
|
|
65
|
+
if (!entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
66
|
+
walkDir(fullPath, pattern);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (entry.isFile()) {
|
|
70
|
+
if (matchesPattern(relativePath, pattern) && !seen.has(relativePath)) {
|
|
71
|
+
seen.add(relativePath);
|
|
72
|
+
files.push(relativePath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Skip directories we can't read
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const pattern of patterns) {
|
|
82
|
+
walkDir(workingDir, pattern);
|
|
83
|
+
}
|
|
84
|
+
return files.slice(0, 100); // Limit results
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Simple glob pattern matching
|
|
88
|
+
*/
|
|
89
|
+
function matchesPattern(filePath, pattern) {
|
|
90
|
+
// Handle **/*.ext patterns
|
|
91
|
+
if (pattern.includes("**")) {
|
|
92
|
+
const ext = pattern.split(".").pop();
|
|
93
|
+
if (ext) {
|
|
94
|
+
return filePath.endsWith(`.${ext}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Handle *.ext patterns
|
|
98
|
+
if (pattern.startsWith("*.")) {
|
|
99
|
+
const ext = pattern.slice(1);
|
|
100
|
+
return filePath.endsWith(ext);
|
|
101
|
+
}
|
|
102
|
+
// Direct path match
|
|
103
|
+
return filePath.includes(pattern.replace(/\*/g, ""));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Load file contents
|
|
107
|
+
*/
|
|
108
|
+
function loadFiles(filePaths, workingDir) {
|
|
109
|
+
const files = [];
|
|
110
|
+
for (const filePath of filePaths) {
|
|
111
|
+
try {
|
|
112
|
+
const fullPath = path.join(workingDir, filePath);
|
|
113
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
114
|
+
const language = detectLanguageFromPath(filePath);
|
|
115
|
+
files.push({
|
|
116
|
+
path: filePath,
|
|
117
|
+
content,
|
|
118
|
+
language,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Skip files that can't be read
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return files;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Format output for display
|
|
129
|
+
*/
|
|
130
|
+
function formatOutput(result, action) {
|
|
131
|
+
const config = getOutputConfig();
|
|
132
|
+
if (config.mode === "toon" || config.useToon) {
|
|
133
|
+
const schema = {
|
|
134
|
+
name: action === "chunk" ? "Chunks" : "MultiFileCompress",
|
|
135
|
+
fields: ["compressed", "filesIncluded", "sharedElements", "stats"],
|
|
136
|
+
};
|
|
137
|
+
return serializeResultToToon(result, schema, {
|
|
138
|
+
verbosity: config.verbosity,
|
|
139
|
+
includeStats: config.includeStats,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// Standard format
|
|
143
|
+
const parts = [];
|
|
144
|
+
if (result.stats) {
|
|
145
|
+
parts.push(`[MultiFile] ${result.stats.originalTokens}→${result.stats.compressedTokens} tokens (-${result.stats.reductionPercent}%)`);
|
|
146
|
+
parts.push(`Files: ${result.stats.filesProcessed}, Deduplicated: ${result.stats.deduplicatedItems}`);
|
|
147
|
+
parts.push("");
|
|
148
|
+
}
|
|
149
|
+
if (result.compressed) {
|
|
150
|
+
parts.push(result.compressed);
|
|
151
|
+
}
|
|
152
|
+
if (result.chunks) {
|
|
153
|
+
parts.push(`Chunks: ${result.chunks.length}`);
|
|
154
|
+
for (const chunk of result.chunks) {
|
|
155
|
+
parts.push(` ${chunk.id}: ${chunk.files.length} files, ${chunk.tokens} tokens`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return parts.join("\n");
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Execute multi-file compress tool
|
|
162
|
+
*/
|
|
163
|
+
async function executeMultifileCompress(args) {
|
|
164
|
+
const input = inputSchema.parse(args);
|
|
165
|
+
const workingDir = process.cwd();
|
|
166
|
+
// Find files matching patterns
|
|
167
|
+
const filePaths = findFiles(input.patterns, workingDir);
|
|
168
|
+
if (filePaths.length === 0) {
|
|
169
|
+
return {
|
|
170
|
+
content: [
|
|
171
|
+
{
|
|
172
|
+
type: "text",
|
|
173
|
+
text: `No files found matching patterns: ${input.patterns.join(", ")}`,
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// Load file contents
|
|
179
|
+
const files = loadFiles(filePaths, workingDir);
|
|
180
|
+
let output;
|
|
181
|
+
switch (input.action) {
|
|
182
|
+
case "extract-shared": {
|
|
183
|
+
const shared = extractSharedElements(files);
|
|
184
|
+
output = formatOutput({
|
|
185
|
+
sharedElements: shared,
|
|
186
|
+
stats: {
|
|
187
|
+
originalTokens: 0,
|
|
188
|
+
compressedTokens: 0,
|
|
189
|
+
filesProcessed: files.length,
|
|
190
|
+
deduplicatedItems: shared.imports.length + shared.types.length,
|
|
191
|
+
reductionPercent: 0,
|
|
192
|
+
},
|
|
193
|
+
}, "extract-shared");
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case "chunk": {
|
|
197
|
+
const chunks = createChunks(files, input.maxTokens / 3);
|
|
198
|
+
output = formatOutput({ chunks }, "chunk");
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "compress":
|
|
202
|
+
default: {
|
|
203
|
+
const result = compressMultiFile(files, {
|
|
204
|
+
strategy: input.strategy,
|
|
205
|
+
maxTokens: input.maxTokens,
|
|
206
|
+
});
|
|
207
|
+
// Track usage
|
|
208
|
+
const tokensSaved = result.stats.originalTokens - result.stats.compressedTokens;
|
|
209
|
+
getSessionTracker().recordInvocation("multifile_compress", result.stats.originalTokens, result.stats.compressedTokens, tokensSaved, 0);
|
|
210
|
+
output = formatOutput(result, "compress");
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
content: [{ type: "text", text: output }],
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export const multifileCompressTool = {
|
|
219
|
+
name: "multifile_compress",
|
|
220
|
+
description: "Compress multiple files with cross-file deduplication. Extracts shared imports/types. Strategies: deduplicate, skeleton, smart-chunk.",
|
|
221
|
+
inputSchema: multifileCompressSchema,
|
|
222
|
+
execute: executeMultifileCompress,
|
|
223
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ServerConfig } from "../server";
|
|
2
|
+
export declare const optimizationTipsSchema: {
|
|
3
|
+
type: "object";
|
|
4
|
+
properties: {
|
|
5
|
+
focus: {
|
|
6
|
+
type: string;
|
|
7
|
+
enum: string[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
required: never[];
|
|
11
|
+
};
|
|
12
|
+
export declare function optimizationTips(args: unknown, _config: ServerConfig): Promise<{
|
|
13
|
+
content: Array<{
|
|
14
|
+
type: "text";
|
|
15
|
+
text: string;
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=optimization-tips.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimization-tips.d.ts","sourceRoot":"","sources":["../../src/tools/optimization-tips.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,sBAAsB;;;;;;;;;CAMlC,CAAC;AAyHF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAc7D"}
|