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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Configuration
|
|
3
|
+
*
|
|
4
|
+
* Global configuration for tool output formatting.
|
|
5
|
+
* Singleton pattern for session-wide settings.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Verbosity levels for output
|
|
9
|
+
*/
|
|
10
|
+
export type VerbosityLevel = "minimal" | "normal" | "detailed";
|
|
11
|
+
/**
|
|
12
|
+
* Output format modes
|
|
13
|
+
*/
|
|
14
|
+
export type OutputMode = "structured" | "prose" | "toon";
|
|
15
|
+
/**
|
|
16
|
+
* Global output configuration
|
|
17
|
+
*/
|
|
18
|
+
export interface OutputConfig {
|
|
19
|
+
/** Verbosity level for output */
|
|
20
|
+
verbosity: VerbosityLevel;
|
|
21
|
+
/** Output format mode */
|
|
22
|
+
mode: OutputMode;
|
|
23
|
+
/** Use TOON format when applicable */
|
|
24
|
+
useToon: boolean;
|
|
25
|
+
/** Include statistics in output */
|
|
26
|
+
includeStats: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get current output configuration
|
|
30
|
+
*/
|
|
31
|
+
export declare function getOutputConfig(): OutputConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Update output configuration
|
|
34
|
+
*/
|
|
35
|
+
export declare function setOutputConfig(config: Partial<OutputConfig>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Reset to default configuration
|
|
38
|
+
*/
|
|
39
|
+
export declare function resetOutputConfig(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get verbosity-based limits
|
|
42
|
+
*/
|
|
43
|
+
export declare function getVerbosityLimits(verbosity?: VerbosityLevel): {
|
|
44
|
+
maxDescriptionLength: number;
|
|
45
|
+
maxItems: number;
|
|
46
|
+
includeDetails: boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Format output based on current configuration
|
|
50
|
+
*/
|
|
51
|
+
export declare function shouldUseToon(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if stats should be included
|
|
54
|
+
*/
|
|
55
|
+
export declare function shouldIncludeStats(): boolean;
|
|
56
|
+
//# sourceMappingURL=output-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-config.d.ts","sourceRoot":"","sources":["../../src/config/output-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,SAAS,EAAE,cAAc,CAAC;IAC1B,yBAAyB;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,mCAAmC;IACnC,YAAY,EAAE,OAAO,CAAC;CACvB;AAiBD;;GAEG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAKnE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,cAAc,GAAG;IAC9D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;CACzB,CAuBA;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Configuration
|
|
3
|
+
*
|
|
4
|
+
* Global configuration for tool output formatting.
|
|
5
|
+
* Singleton pattern for session-wide settings.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration values
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_CONFIG = {
|
|
11
|
+
verbosity: "normal",
|
|
12
|
+
mode: "structured",
|
|
13
|
+
useToon: false,
|
|
14
|
+
includeStats: true,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Global configuration instance (singleton)
|
|
18
|
+
*/
|
|
19
|
+
let globalConfig = { ...DEFAULT_CONFIG };
|
|
20
|
+
/**
|
|
21
|
+
* Get current output configuration
|
|
22
|
+
*/
|
|
23
|
+
export function getOutputConfig() {
|
|
24
|
+
return { ...globalConfig };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Update output configuration
|
|
28
|
+
*/
|
|
29
|
+
export function setOutputConfig(config) {
|
|
30
|
+
globalConfig = {
|
|
31
|
+
...globalConfig,
|
|
32
|
+
...config,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reset to default configuration
|
|
37
|
+
*/
|
|
38
|
+
export function resetOutputConfig() {
|
|
39
|
+
globalConfig = { ...DEFAULT_CONFIG };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get verbosity-based limits
|
|
43
|
+
*/
|
|
44
|
+
export function getVerbosityLimits(verbosity) {
|
|
45
|
+
const level = verbosity ?? globalConfig.verbosity;
|
|
46
|
+
switch (level) {
|
|
47
|
+
case "minimal":
|
|
48
|
+
return {
|
|
49
|
+
maxDescriptionLength: 40,
|
|
50
|
+
maxItems: 5,
|
|
51
|
+
includeDetails: false,
|
|
52
|
+
};
|
|
53
|
+
case "normal":
|
|
54
|
+
return {
|
|
55
|
+
maxDescriptionLength: 80,
|
|
56
|
+
maxItems: 15,
|
|
57
|
+
includeDetails: true,
|
|
58
|
+
};
|
|
59
|
+
case "detailed":
|
|
60
|
+
return {
|
|
61
|
+
maxDescriptionLength: 200,
|
|
62
|
+
maxItems: 50,
|
|
63
|
+
includeDetails: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Format output based on current configuration
|
|
69
|
+
*/
|
|
70
|
+
export function shouldUseToon() {
|
|
71
|
+
return globalConfig.useToon || globalConfig.mode === "toon";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if stats should be included
|
|
75
|
+
*/
|
|
76
|
+
export function shouldIncludeStats() {
|
|
77
|
+
return globalConfig.includeStats;
|
|
78
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ctxopt/mcp-server
|
|
3
|
+
*
|
|
4
|
+
* MCP Server for CtxOpt - Context Engineering Optimizer
|
|
5
|
+
*
|
|
6
|
+
* Provides tools for analyzing and optimizing LLM context usage.
|
|
7
|
+
*/
|
|
8
|
+
export { createServer, runServer, type ServerConfig, type ServerInstance, type LoadingMode } from "./server.js";
|
|
9
|
+
export * from "./cache/index.js";
|
|
10
|
+
export * from "./middleware/index.js";
|
|
11
|
+
export { analyzeContext } from "./tools/analyze-context.js";
|
|
12
|
+
export { optimizationTips } from "./tools/optimization-tips.js";
|
|
13
|
+
export { analyzeBuildOutputTool, executeAnalyzeBuildOutput } from "./tools/analyze-build-output.js";
|
|
14
|
+
export { smartCacheTool, executeSmartCache } from "./tools/smart-cache-tool.js";
|
|
15
|
+
export { createToolRegistry, type ToolRegistry, type ToolDefinition } from "./tools/registry.js";
|
|
16
|
+
export { getDynamicLoader, resetDynamicLoader, TOOL_CATALOG, type ToolCategory, type ToolMetadata, DynamicToolLoader, } from "./tools/dynamic-loader.js";
|
|
17
|
+
export { discoverToolsTool } from "./tools/discover-tools.js";
|
|
18
|
+
export { browseToolsTool, runToolTool, lazyMcpTools, setLazyMcpRegistry, calculateLazySavings, } from "./tools/lazy-mcp.js";
|
|
19
|
+
export * from "./parsers/index.js";
|
|
20
|
+
export * from "./utils/index.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAKhH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ctxopt/mcp-server
|
|
3
|
+
*
|
|
4
|
+
* MCP Server for CtxOpt - Context Engineering Optimizer
|
|
5
|
+
*
|
|
6
|
+
* Provides tools for analyzing and optimizing LLM context usage.
|
|
7
|
+
*/
|
|
8
|
+
// Server
|
|
9
|
+
export { createServer, runServer } from "./server.js";
|
|
10
|
+
// State management
|
|
11
|
+
// Cache
|
|
12
|
+
export * from "./cache/index.js";
|
|
13
|
+
// Middleware
|
|
14
|
+
export * from "./middleware/index.js";
|
|
15
|
+
// Tools
|
|
16
|
+
export { analyzeContext } from "./tools/analyze-context.js";
|
|
17
|
+
export { optimizationTips } from "./tools/optimization-tips.js";
|
|
18
|
+
export { analyzeBuildOutputTool, executeAnalyzeBuildOutput } from "./tools/analyze-build-output.js";
|
|
19
|
+
export { smartCacheTool, executeSmartCache } from "./tools/smart-cache-tool.js";
|
|
20
|
+
export { createToolRegistry } from "./tools/registry.js";
|
|
21
|
+
export { getDynamicLoader, resetDynamicLoader, TOOL_CATALOG, DynamicToolLoader, } from "./tools/dynamic-loader.js";
|
|
22
|
+
export { discoverToolsTool } from "./tools/discover-tools.js";
|
|
23
|
+
export { browseToolsTool, runToolTool, lazyMcpTools, setLazyMcpRegistry, calculateLazySavings, } from "./tools/lazy-mcp.js";
|
|
24
|
+
// Parsers
|
|
25
|
+
export * from "./parsers/index.js";
|
|
26
|
+
// Utils
|
|
27
|
+
export * from "./utils/index.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Chain
|
|
3
|
+
*
|
|
4
|
+
* Manages the execution of middleware before and after tool calls.
|
|
5
|
+
* Errors in middleware are tracked but don't stop execution (fail-safe).
|
|
6
|
+
*/
|
|
7
|
+
import type { Middleware, ToolContext, ToolResult } from "./types.js";
|
|
8
|
+
export declare class MiddlewareChain {
|
|
9
|
+
private middlewares;
|
|
10
|
+
/**
|
|
11
|
+
* Add a middleware to the chain
|
|
12
|
+
*/
|
|
13
|
+
use(middleware: Middleware): this;
|
|
14
|
+
/**
|
|
15
|
+
* Remove a middleware by name
|
|
16
|
+
*/
|
|
17
|
+
remove(name: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get all registered middlewares
|
|
20
|
+
*/
|
|
21
|
+
list(): Middleware[];
|
|
22
|
+
/**
|
|
23
|
+
* Track a middleware error
|
|
24
|
+
*/
|
|
25
|
+
private trackError;
|
|
26
|
+
/**
|
|
27
|
+
* Execute beforeTool hooks for all middlewares
|
|
28
|
+
* Returns null if any middleware wants to skip execution
|
|
29
|
+
*/
|
|
30
|
+
executeBefore(ctx: ToolContext): Promise<ToolContext | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Execute afterTool hooks for all middlewares (in reverse order)
|
|
33
|
+
*/
|
|
34
|
+
executeAfter(ctx: ToolContext, result: ToolResult): Promise<ToolResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Execute onError hooks for all middlewares
|
|
37
|
+
* Returns the first non-null result, or null if none handled the error
|
|
38
|
+
*/
|
|
39
|
+
executeOnError(ctx: ToolContext, error: Error): Promise<ToolResult | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Get count of errors that occurred during middleware execution
|
|
42
|
+
*/
|
|
43
|
+
getErrorCount(ctx: ToolContext): number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a new middleware chain instance
|
|
47
|
+
*/
|
|
48
|
+
export declare function createMiddlewareChain(): MiddlewareChain;
|
|
49
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/middleware/chain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAmB,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvF,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAoB;IAEvC;;OAEG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAOjC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAS7B;;OAEG;IACH,IAAI,IAAI,UAAU,EAAE;IAIpB;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB;;;OAGG;IACG,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAsBlE;;OAEG;IACG,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAoB7E;;;OAGG;IACG,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAkBhF;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM;CAGxC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Chain
|
|
3
|
+
*
|
|
4
|
+
* Manages the execution of middleware before and after tool calls.
|
|
5
|
+
* Errors in middleware are tracked but don't stop execution (fail-safe).
|
|
6
|
+
*/
|
|
7
|
+
export class MiddlewareChain {
|
|
8
|
+
middlewares = [];
|
|
9
|
+
/**
|
|
10
|
+
* Add a middleware to the chain
|
|
11
|
+
*/
|
|
12
|
+
use(middleware) {
|
|
13
|
+
this.middlewares.push(middleware);
|
|
14
|
+
// Sort by priority (lower runs first)
|
|
15
|
+
this.middlewares.sort((a, b) => a.priority - b.priority);
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Remove a middleware by name
|
|
20
|
+
*/
|
|
21
|
+
remove(name) {
|
|
22
|
+
const index = this.middlewares.findIndex((m) => m.name === name);
|
|
23
|
+
if (index !== -1) {
|
|
24
|
+
this.middlewares.splice(index, 1);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get all registered middlewares
|
|
31
|
+
*/
|
|
32
|
+
list() {
|
|
33
|
+
return [...this.middlewares];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Track a middleware error
|
|
37
|
+
*/
|
|
38
|
+
trackError(ctx, middlewareName, phase, error) {
|
|
39
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
40
|
+
ctx.middlewareErrors.push({
|
|
41
|
+
middlewareName,
|
|
42
|
+
phase,
|
|
43
|
+
error: err,
|
|
44
|
+
timestamp: Date.now(),
|
|
45
|
+
});
|
|
46
|
+
// Also log for debugging
|
|
47
|
+
console.error(`[ctxopt] Middleware ${middlewareName} ${phase} error:`, err.message);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Execute beforeTool hooks for all middlewares
|
|
51
|
+
* Returns null if any middleware wants to skip execution
|
|
52
|
+
*/
|
|
53
|
+
async executeBefore(ctx) {
|
|
54
|
+
let currentCtx = ctx;
|
|
55
|
+
for (const middleware of this.middlewares) {
|
|
56
|
+
if (!middleware.beforeTool)
|
|
57
|
+
continue;
|
|
58
|
+
try {
|
|
59
|
+
const result = await middleware.beforeTool(currentCtx);
|
|
60
|
+
if (result === null) {
|
|
61
|
+
// Middleware wants to skip execution
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
currentCtx = result;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
this.trackError(currentCtx, middleware.name, "beforeTool", error);
|
|
68
|
+
// Continue with unmodified context on error (fail-safe)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return currentCtx;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Execute afterTool hooks for all middlewares (in reverse order)
|
|
75
|
+
*/
|
|
76
|
+
async executeAfter(ctx, result) {
|
|
77
|
+
let currentResult = result;
|
|
78
|
+
// Execute in reverse order for afterTool
|
|
79
|
+
const reversedMiddlewares = [...this.middlewares].reverse();
|
|
80
|
+
for (const middleware of reversedMiddlewares) {
|
|
81
|
+
if (!middleware.afterTool)
|
|
82
|
+
continue;
|
|
83
|
+
try {
|
|
84
|
+
currentResult = await middleware.afterTool(ctx, currentResult);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
this.trackError(ctx, middleware.name, "afterTool", error);
|
|
88
|
+
// Continue with unmodified result on error (fail-safe)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return currentResult;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Execute onError hooks for all middlewares
|
|
95
|
+
* Returns the first non-null result, or null if none handled the error
|
|
96
|
+
*/
|
|
97
|
+
async executeOnError(ctx, error) {
|
|
98
|
+
for (const middleware of this.middlewares) {
|
|
99
|
+
if (!middleware.onError)
|
|
100
|
+
continue;
|
|
101
|
+
try {
|
|
102
|
+
const result = await middleware.onError(ctx, error);
|
|
103
|
+
if (result !== null) {
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (middlewareError) {
|
|
108
|
+
this.trackError(ctx, middleware.name, "onError", middlewareError);
|
|
109
|
+
// Continue to next middleware (fail-safe)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get count of errors that occurred during middleware execution
|
|
116
|
+
*/
|
|
117
|
+
getErrorCount(ctx) {
|
|
118
|
+
return ctx.middlewareErrors.length;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create a new middleware chain instance
|
|
123
|
+
*/
|
|
124
|
+
export function createMiddlewareChain() {
|
|
125
|
+
return new MiddlewareChain();
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging Middleware
|
|
3
|
+
*
|
|
4
|
+
* Logs tool calls and results when verbose mode is enabled.
|
|
5
|
+
*/
|
|
6
|
+
import type { Middleware, MiddlewareConfig } from "./types.js";
|
|
7
|
+
export declare function createLoggingMiddleware(config: MiddlewareConfig): Middleware;
|
|
8
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/middleware/logging.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAA2B,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqBxF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAoE5E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging Middleware
|
|
3
|
+
*
|
|
4
|
+
* Logs tool calls and results when verbose mode is enabled.
|
|
5
|
+
*/
|
|
6
|
+
const COLORS = {
|
|
7
|
+
reset: "\x1b[0m",
|
|
8
|
+
dim: "\x1b[2m",
|
|
9
|
+
cyan: "\x1b[36m",
|
|
10
|
+
green: "\x1b[32m",
|
|
11
|
+
yellow: "\x1b[33m",
|
|
12
|
+
red: "\x1b[31m",
|
|
13
|
+
};
|
|
14
|
+
function formatDuration(ms) {
|
|
15
|
+
if (ms < 1000)
|
|
16
|
+
return `${ms}ms`;
|
|
17
|
+
return `${(ms / 1000).toFixed(2)}s`;
|
|
18
|
+
}
|
|
19
|
+
function formatTokens(tokens) {
|
|
20
|
+
if (tokens < 1000)
|
|
21
|
+
return tokens.toString();
|
|
22
|
+
return `${(tokens / 1000).toFixed(1)}k`;
|
|
23
|
+
}
|
|
24
|
+
export function createLoggingMiddleware(config) {
|
|
25
|
+
const verbose = config.verbose;
|
|
26
|
+
return {
|
|
27
|
+
name: "logging",
|
|
28
|
+
priority: 0, // Run first
|
|
29
|
+
async beforeTool(ctx) {
|
|
30
|
+
if (!verbose)
|
|
31
|
+
return ctx;
|
|
32
|
+
const timestamp = new Date().toISOString().slice(11, 23);
|
|
33
|
+
console.error(`${COLORS.dim}[${timestamp}]${COLORS.reset} ${COLORS.cyan}→${COLORS.reset} ${ctx.toolName}`, ctx.arguments);
|
|
34
|
+
return ctx;
|
|
35
|
+
},
|
|
36
|
+
async afterTool(ctx, result) {
|
|
37
|
+
if (!verbose)
|
|
38
|
+
return result;
|
|
39
|
+
const duration = Date.now() - ctx.startTime;
|
|
40
|
+
const timestamp = new Date().toISOString().slice(11, 23);
|
|
41
|
+
const statusColor = result.isError ? COLORS.red : COLORS.green;
|
|
42
|
+
const statusIcon = result.isError ? "✗" : "✓";
|
|
43
|
+
const parts = [
|
|
44
|
+
`${COLORS.dim}[${timestamp}]${COLORS.reset}`,
|
|
45
|
+
`${statusColor}${statusIcon}${COLORS.reset}`,
|
|
46
|
+
ctx.toolName,
|
|
47
|
+
`${COLORS.dim}(${formatDuration(duration)})${COLORS.reset}`,
|
|
48
|
+
];
|
|
49
|
+
if (result.tokensOut > 0) {
|
|
50
|
+
parts.push(`${COLORS.dim}tokens:${formatTokens(result.tokensOut)}${COLORS.reset}`);
|
|
51
|
+
}
|
|
52
|
+
if (result.tokensSaved > 0) {
|
|
53
|
+
parts.push(`${COLORS.green}saved:${formatTokens(result.tokensSaved)}${COLORS.reset}`);
|
|
54
|
+
}
|
|
55
|
+
if (result.wasFiltered) {
|
|
56
|
+
parts.push(`${COLORS.yellow}[filtered]${COLORS.reset}`);
|
|
57
|
+
}
|
|
58
|
+
console.error(parts.join(" "));
|
|
59
|
+
return result;
|
|
60
|
+
},
|
|
61
|
+
async onError(ctx, error) {
|
|
62
|
+
if (!verbose)
|
|
63
|
+
return null;
|
|
64
|
+
const duration = Date.now() - ctx.startTime;
|
|
65
|
+
const timestamp = new Date().toISOString().slice(11, 23);
|
|
66
|
+
console.error(`${COLORS.dim}[${timestamp}]${COLORS.reset} ${COLORS.red}✗${COLORS.reset} ${ctx.toolName}`, `${COLORS.dim}(${formatDuration(duration)})${COLORS.reset}`, `${COLORS.red}Error: ${error.message}${COLORS.reset}`);
|
|
67
|
+
// Don't handle the error, just log it
|
|
68
|
+
return null;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the interface for middleware that can intercept and transform
|
|
5
|
+
* tool calls before and after execution.
|
|
6
|
+
*/
|
|
7
|
+
export interface MiddlewareError {
|
|
8
|
+
middlewareName: string;
|
|
9
|
+
phase: "beforeTool" | "afterTool" | "onError";
|
|
10
|
+
error: Error;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolContext {
|
|
14
|
+
toolName: string;
|
|
15
|
+
arguments: Record<string, unknown>;
|
|
16
|
+
startTime: number;
|
|
17
|
+
metadata: Record<string, unknown>;
|
|
18
|
+
/** Errors encountered during middleware execution (non-fatal) */
|
|
19
|
+
middlewareErrors: MiddlewareError[];
|
|
20
|
+
}
|
|
21
|
+
export interface ToolResult {
|
|
22
|
+
content: Array<{
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
}>;
|
|
26
|
+
isError?: boolean;
|
|
27
|
+
tokensIn: number;
|
|
28
|
+
tokensOut: number;
|
|
29
|
+
tokensSaved: number;
|
|
30
|
+
wasFiltered: boolean;
|
|
31
|
+
metadata: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface Middleware {
|
|
34
|
+
name: string;
|
|
35
|
+
priority: number;
|
|
36
|
+
/**
|
|
37
|
+
* Called before tool execution.
|
|
38
|
+
* Return null to skip the tool execution.
|
|
39
|
+
* Return modified context to continue.
|
|
40
|
+
*/
|
|
41
|
+
beforeTool?(ctx: ToolContext): Promise<ToolContext | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Called after tool execution.
|
|
44
|
+
* Can modify the result before returning to the client.
|
|
45
|
+
*/
|
|
46
|
+
afterTool?(ctx: ToolContext, result: ToolResult): Promise<ToolResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Called on error during tool execution.
|
|
49
|
+
* Can transform or suppress errors.
|
|
50
|
+
*/
|
|
51
|
+
onError?(ctx: ToolContext, error: Error): Promise<ToolResult | null>;
|
|
52
|
+
}
|
|
53
|
+
export type MiddlewareFactory = (config: MiddlewareConfig) => Middleware;
|
|
54
|
+
export interface MiddlewareConfig {
|
|
55
|
+
verbose: boolean;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/middleware/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC;IAC9C,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,iEAAiE;IACjE,gBAAgB,EAAE,eAAe,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,UAAU,CAAC,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAE3D;;;OAGG;IACH,SAAS,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtE;;;OAGG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CACtE;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,UAAU,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../../src/parsers/eslint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,YAAY,CAAC;AA6ErE,eAAO,MAAM,YAAY,EAAE,WAiF1B,CAAC"}
|