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
package/dist/server.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CtxOpt MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Main server implementation with dynamic tool loading.
|
|
5
|
+
* Only core tools are loaded at startup to minimize token consumption.
|
|
6
|
+
*/
|
|
7
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
10
|
+
// Middleware
|
|
11
|
+
import { createMiddlewareChain } from "./middleware/chain.js";
|
|
12
|
+
import { createLoggingMiddleware } from "./middleware/logging.js";
|
|
13
|
+
// Tools
|
|
14
|
+
import { createToolRegistry } from "./tools/registry.js";
|
|
15
|
+
import { getDynamicLoader, resetDynamicLoader } from "./tools/dynamic-loader.js";
|
|
16
|
+
import { discoverToolsTool } from "./tools/discover-tools.js";
|
|
17
|
+
import { lazyMcpTools, setLazyMcpRegistry, calculateLazySavings } from "./tools/lazy-mcp.js";
|
|
18
|
+
/**
|
|
19
|
+
* Create and configure the MCP server
|
|
20
|
+
*/
|
|
21
|
+
export async function createServer(config = {}) {
|
|
22
|
+
// Determine loading mode (support legacy loadAllTools option)
|
|
23
|
+
const mode = config.mode ?? (config.loadAllTools ? "all" : "core");
|
|
24
|
+
// Reset dynamic loader for fresh start
|
|
25
|
+
resetDynamicLoader();
|
|
26
|
+
const loader = getDynamicLoader();
|
|
27
|
+
// Create middleware chain
|
|
28
|
+
const middleware = createMiddlewareChain();
|
|
29
|
+
middleware.use(createLoggingMiddleware({ verbose: config.verbose ?? false }));
|
|
30
|
+
// Create tool registry
|
|
31
|
+
const tools = createToolRegistry();
|
|
32
|
+
tools.setMiddlewareChain(middleware);
|
|
33
|
+
// Load tools based on mode
|
|
34
|
+
if (mode === "lazy") {
|
|
35
|
+
// Lazy mode: Only 2 meta-tools (95% token savings)
|
|
36
|
+
for (const tool of lazyMcpTools) {
|
|
37
|
+
tools.register(tool);
|
|
38
|
+
}
|
|
39
|
+
// Connect registry to lazy-mcp for run_tool execution
|
|
40
|
+
setLazyMcpRegistry({
|
|
41
|
+
execute: async (name, args) => {
|
|
42
|
+
const result = await tools.execute(name, args);
|
|
43
|
+
return { content: result.content, isError: result.isError };
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
if (config.verbose) {
|
|
47
|
+
const savings = calculateLazySavings();
|
|
48
|
+
console.error(`[ctxopt] Lazy mode: ${savings.savingsPercent}% token savings`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (mode === "all") {
|
|
52
|
+
// All mode: Load all tools at startup
|
|
53
|
+
tools.register(discoverToolsTool);
|
|
54
|
+
const allTools = await loader.loadAllTools();
|
|
55
|
+
for (const tool of allTools) {
|
|
56
|
+
tools.register(tool);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Core mode (default): Core tools + discover_tools
|
|
61
|
+
tools.register(discoverToolsTool);
|
|
62
|
+
const coreTools = await loader.loadCoreTools();
|
|
63
|
+
for (const tool of coreTools) {
|
|
64
|
+
tools.register(tool);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Connect dynamic loader to registry
|
|
68
|
+
loader.onToolsChanged(() => {
|
|
69
|
+
// Register newly loaded tools
|
|
70
|
+
for (const tool of loader.getLoadedTools()) {
|
|
71
|
+
if (!tools.get(tool.name)) {
|
|
72
|
+
tools.register(tool);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// Create MCP server
|
|
77
|
+
const server = new Server({
|
|
78
|
+
name: "@ctxopt/mcp-server",
|
|
79
|
+
version: "0.1.0",
|
|
80
|
+
}, {
|
|
81
|
+
capabilities: {
|
|
82
|
+
tools: {},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
// Handle ListTools request
|
|
86
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
87
|
+
tools: tools.getToolDefinitions(),
|
|
88
|
+
}));
|
|
89
|
+
// Handle CallTool request
|
|
90
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
91
|
+
const { name, arguments: args } = request.params;
|
|
92
|
+
// Try to load tool dynamically if not found
|
|
93
|
+
if (!tools.get(name)) {
|
|
94
|
+
const loaded = await loader.loadByNames([name]);
|
|
95
|
+
for (const tool of loaded) {
|
|
96
|
+
tools.register(tool);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const result = await tools.execute(name, args);
|
|
100
|
+
return {
|
|
101
|
+
content: result.content,
|
|
102
|
+
isError: result.isError,
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
// Set up notification for tool list changes
|
|
106
|
+
tools.onToolsChanged(() => {
|
|
107
|
+
// Send notification to client that tool list has changed
|
|
108
|
+
server.notification({
|
|
109
|
+
method: "notifications/tools/list_changed",
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
server,
|
|
114
|
+
middleware,
|
|
115
|
+
tools,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Run the MCP server on stdio transport
|
|
120
|
+
*/
|
|
121
|
+
export async function runServer(config = {}) {
|
|
122
|
+
const { server } = await createServer(config);
|
|
123
|
+
const transport = new StdioServerTransport();
|
|
124
|
+
// Handle server close event
|
|
125
|
+
server.onclose = async () => {
|
|
126
|
+
if (config.verbose) {
|
|
127
|
+
console.error("[ctxopt] Server connection closed");
|
|
128
|
+
}
|
|
129
|
+
process.exit(0);
|
|
130
|
+
};
|
|
131
|
+
await server.connect(transport);
|
|
132
|
+
console.error("CtxOpt MCP Server running on stdio");
|
|
133
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build Logs Summarizer
|
|
3
|
+
*
|
|
4
|
+
* Summarizes build tool output (webpack, vite, tsc, esbuild, etc.).
|
|
5
|
+
*/
|
|
6
|
+
import type { Summarizer } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Build logs summarizer
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildLogsSummarizer: Summarizer;
|
|
11
|
+
//# sourceMappingURL=build-logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-logs.d.ts","sourceRoot":"","sources":["../../src/summarizers/build-logs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,YAAY,CAAC;AA+GpB;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAwHjC,CAAC"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build Logs Summarizer
|
|
3
|
+
*
|
|
4
|
+
* Summarizes build tool output (webpack, vite, tsc, esbuild, etc.).
|
|
5
|
+
*/
|
|
6
|
+
import { parseLogLine, calculateTimespan, deduplicateEntries, filterByTimeframe, isKeyEvent, } from "../utils/log-parser.js";
|
|
7
|
+
import { MAX_ENTRIES } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Build tool detection patterns
|
|
10
|
+
*/
|
|
11
|
+
const BUILD_TOOL_PATTERNS = {
|
|
12
|
+
webpack: /\b(webpack|Module|chunk|bundle)\b/i,
|
|
13
|
+
vite: /\b(vite|hmr|pre-bundling)\b/i,
|
|
14
|
+
tsc: /\b(tsc|typescript|\.ts\(\d+,\d+\)|error TS\d+)\b/i,
|
|
15
|
+
esbuild: /\b(esbuild|bundled?)\b/i,
|
|
16
|
+
rollup: /\b(rollup|bundle)\b/i,
|
|
17
|
+
npm: /\b(npm|added \d+ package|npm WARN|npm ERR)\b/i,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Build error patterns
|
|
21
|
+
*/
|
|
22
|
+
const ERROR_PATTERNS = [
|
|
23
|
+
// TypeScript: error TS2304: Cannot find name 'foo'
|
|
24
|
+
/error\s+TS(\d+):\s*(.+)/i,
|
|
25
|
+
// ESLint: error rule-name message
|
|
26
|
+
/error\s+([a-z\-@\/]+)\s+(.+)/i,
|
|
27
|
+
// Webpack: Module not found
|
|
28
|
+
/Module not found:\s*(.+)/i,
|
|
29
|
+
// Generic: ERROR: message
|
|
30
|
+
/\bERROR[:\s]+(.+)/i,
|
|
31
|
+
// npm ERR!
|
|
32
|
+
/npm ERR!\s*(.+)/,
|
|
33
|
+
];
|
|
34
|
+
/**
|
|
35
|
+
* Build duration patterns
|
|
36
|
+
*/
|
|
37
|
+
const DURATION_PATTERNS = [
|
|
38
|
+
// Built in 1.23s
|
|
39
|
+
/Built?\s+in\s+(\d+(?:\.\d+)?)\s*(s|ms)/i,
|
|
40
|
+
// Done in 1.23s
|
|
41
|
+
/Done\s+in\s+(\d+(?:\.\d+)?)\s*(s|ms)/i,
|
|
42
|
+
// Time: 1234ms
|
|
43
|
+
/Time:\s*(\d+(?:\.\d+)?)\s*(s|ms)/i,
|
|
44
|
+
// Compiled in 1.23s
|
|
45
|
+
/Compiled?\s+in\s+(\d+(?:\.\d+)?)\s*(s|ms)/i,
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Bundle size patterns
|
|
49
|
+
*/
|
|
50
|
+
const SIZE_PATTERNS = [
|
|
51
|
+
// dist/main.js 45.2 kB
|
|
52
|
+
/(\S+\.(?:js|css|mjs))\s+(\d+(?:\.\d+)?)\s*(B|KB|MB|kB)/i,
|
|
53
|
+
// gzipped: 12.3 kB
|
|
54
|
+
/gzip(?:ped)?:\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|kB)/i,
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Parse build duration from logs
|
|
58
|
+
*/
|
|
59
|
+
function parseBuildDuration(logs) {
|
|
60
|
+
for (const pattern of DURATION_PATTERNS) {
|
|
61
|
+
const match = logs.match(pattern);
|
|
62
|
+
if (match) {
|
|
63
|
+
const value = parseFloat(match[1] ?? "0");
|
|
64
|
+
const unit = (match[2] ?? "ms").toLowerCase();
|
|
65
|
+
return unit === "s" ? value * 1000 : value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse bundle sizes from logs
|
|
72
|
+
*/
|
|
73
|
+
function parseBundleSizes(logs) {
|
|
74
|
+
const sizes = [];
|
|
75
|
+
const lines = logs.split("\n");
|
|
76
|
+
for (const line of lines) {
|
|
77
|
+
const match = line.match(SIZE_PATTERNS[0]);
|
|
78
|
+
if (match) {
|
|
79
|
+
sizes.push({
|
|
80
|
+
file: match[1] ?? "",
|
|
81
|
+
size: parseFloat(match[2] ?? "0"),
|
|
82
|
+
unit: match[3] ?? "B",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return sizes;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Detect build tool from logs
|
|
90
|
+
*/
|
|
91
|
+
function detectBuildTool(logs) {
|
|
92
|
+
for (const [tool, pattern] of Object.entries(BUILD_TOOL_PATTERNS)) {
|
|
93
|
+
if (pattern.test(logs)) {
|
|
94
|
+
return tool;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return "generic";
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Build logs summarizer
|
|
101
|
+
*/
|
|
102
|
+
export const buildLogsSummarizer = {
|
|
103
|
+
name: "build-logs",
|
|
104
|
+
logType: "build",
|
|
105
|
+
canSummarize(logs) {
|
|
106
|
+
const indicators = [
|
|
107
|
+
/\b(webpack|vite|esbuild|rollup|parcel|tsc)\b/i,
|
|
108
|
+
/\b(Compiling|Bundling|Building)\b/i,
|
|
109
|
+
/\berror\s+TS\d+\b/,
|
|
110
|
+
/\bModule not found\b/i,
|
|
111
|
+
/\bBuilt?\s+in\b/i,
|
|
112
|
+
/\.(js|ts|tsx|jsx)\s+\d+(\.\d+)?\s*(KB|MB|B)/i,
|
|
113
|
+
];
|
|
114
|
+
return indicators.some((p) => p.test(logs));
|
|
115
|
+
},
|
|
116
|
+
summarize(logs, options) {
|
|
117
|
+
const lines = logs.split("\n").filter((l) => l.trim());
|
|
118
|
+
const errors = [];
|
|
119
|
+
const warnings = [];
|
|
120
|
+
const keyEvents = [];
|
|
121
|
+
const allEntries = [];
|
|
122
|
+
const buildTool = detectBuildTool(logs);
|
|
123
|
+
const buildDuration = parseBuildDuration(logs);
|
|
124
|
+
const bundleSizes = parseBundleSizes(logs);
|
|
125
|
+
// Track TypeScript errors by code
|
|
126
|
+
const tsErrorCodes = new Map();
|
|
127
|
+
// Parse all lines
|
|
128
|
+
for (const line of lines) {
|
|
129
|
+
const trimmed = line.trim();
|
|
130
|
+
if (!trimmed)
|
|
131
|
+
continue;
|
|
132
|
+
const entry = parseLogLine(trimmed);
|
|
133
|
+
allEntries.push(entry);
|
|
134
|
+
// Check for errors
|
|
135
|
+
let isError = false;
|
|
136
|
+
for (const pattern of ERROR_PATTERNS) {
|
|
137
|
+
const match = trimmed.match(pattern);
|
|
138
|
+
if (match) {
|
|
139
|
+
isError = true;
|
|
140
|
+
errors.push({
|
|
141
|
+
level: "error",
|
|
142
|
+
message: match[2] ?? match[1] ?? trimmed,
|
|
143
|
+
count: 1,
|
|
144
|
+
raw: trimmed,
|
|
145
|
+
});
|
|
146
|
+
// Track TS error codes
|
|
147
|
+
const tsMatch = trimmed.match(/TS(\d+)/);
|
|
148
|
+
if (tsMatch) {
|
|
149
|
+
const code = `TS${tsMatch[1]}`;
|
|
150
|
+
tsErrorCodes.set(code, (tsErrorCodes.get(code) || 0) + 1);
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Check for warnings
|
|
156
|
+
if (!isError && /\bwarn(?:ing)?\b/i.test(trimmed)) {
|
|
157
|
+
warnings.push({
|
|
158
|
+
level: "warning",
|
|
159
|
+
message: entry.message,
|
|
160
|
+
count: 1,
|
|
161
|
+
raw: trimmed,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
// Detect key events
|
|
165
|
+
if (isKeyEvent(trimmed) || /\b(start|done|finish|complet|success|fail)\b/i.test(trimmed)) {
|
|
166
|
+
keyEvents.push(entry);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Filter by timeframe if specified
|
|
170
|
+
const filteredEntries = filterByTimeframe(allEntries, options.timeframe);
|
|
171
|
+
// Calculate timespan
|
|
172
|
+
const timespan = calculateTimespan(filteredEntries);
|
|
173
|
+
// Deduplicate errors and warnings
|
|
174
|
+
const deduplicatedErrors = deduplicateEntries(errors);
|
|
175
|
+
const deduplicatedWarnings = deduplicateEntries(warnings);
|
|
176
|
+
// Calculate total bundle size
|
|
177
|
+
let totalBundleSize = 0;
|
|
178
|
+
for (const { size, unit } of bundleSizes) {
|
|
179
|
+
const multiplier = unit.toLowerCase() === "kb" ? 1024 : unit.toLowerCase() === "mb" ? 1024 * 1024 : 1;
|
|
180
|
+
totalBundleSize += size * multiplier;
|
|
181
|
+
}
|
|
182
|
+
// Build statistics
|
|
183
|
+
const statistics = {
|
|
184
|
+
timespan,
|
|
185
|
+
totalLines: lines.length,
|
|
186
|
+
errorCount: errors.length,
|
|
187
|
+
warningCount: warnings.length,
|
|
188
|
+
infoCount: allEntries.filter((e) => e.level === "info").length,
|
|
189
|
+
debugCount: allEntries.filter((e) => e.level === "debug").length,
|
|
190
|
+
buildDuration,
|
|
191
|
+
compiledFiles: bundleSizes.length,
|
|
192
|
+
bundleSize: totalBundleSize > 0 ? totalBundleSize : undefined,
|
|
193
|
+
};
|
|
194
|
+
// Build overview
|
|
195
|
+
const overview = buildOverview(buildTool, statistics, tsErrorCodes);
|
|
196
|
+
return {
|
|
197
|
+
logType: "build",
|
|
198
|
+
overview,
|
|
199
|
+
errors: deduplicatedErrors.slice(0, MAX_ENTRIES[options.detail].errors),
|
|
200
|
+
warnings: deduplicatedWarnings.slice(0, MAX_ENTRIES[options.detail].warnings),
|
|
201
|
+
keyEvents: keyEvents.slice(0, MAX_ENTRIES[options.detail].events),
|
|
202
|
+
statistics,
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Build overview text
|
|
208
|
+
*/
|
|
209
|
+
function buildOverview(buildTool, stats, tsErrorCodes) {
|
|
210
|
+
const parts = [`${buildTool} build`];
|
|
211
|
+
if (stats.buildDuration) {
|
|
212
|
+
parts.push(`completed in ${(stats.buildDuration / 1000).toFixed(2)}s`);
|
|
213
|
+
}
|
|
214
|
+
if (stats.errorCount > 0) {
|
|
215
|
+
parts.push(`${stats.errorCount} errors`);
|
|
216
|
+
// Add top TS error codes
|
|
217
|
+
if (tsErrorCodes.size > 0) {
|
|
218
|
+
const topCodes = Array.from(tsErrorCodes.entries())
|
|
219
|
+
.sort((a, b) => b[1] - a[1])
|
|
220
|
+
.slice(0, 3)
|
|
221
|
+
.map(([code, count]) => `${code}(${count})`)
|
|
222
|
+
.join(", ");
|
|
223
|
+
parts.push(`[${topCodes}]`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
parts.push("successful");
|
|
228
|
+
}
|
|
229
|
+
if (stats.bundleSize && stats.bundleSize > 0) {
|
|
230
|
+
const sizeKB = (stats.bundleSize / 1024).toFixed(1);
|
|
231
|
+
parts.push(`${sizeKB} KB total`);
|
|
232
|
+
}
|
|
233
|
+
return parts.join(" - ");
|
|
234
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Logs Summarizer
|
|
3
|
+
*
|
|
4
|
+
* Fallback summarizer for application logs that don't match specific patterns.
|
|
5
|
+
*/
|
|
6
|
+
import type { Summarizer } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Generic logs summarizer
|
|
9
|
+
*/
|
|
10
|
+
export declare const genericSummarizer: Summarizer;
|
|
11
|
+
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/summarizers/generic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,YAAY,CAAC;AAUpB;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAwE/B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Logs Summarizer
|
|
3
|
+
*
|
|
4
|
+
* Fallback summarizer for application logs that don't match specific patterns.
|
|
5
|
+
*/
|
|
6
|
+
import { parseLogLine, calculateTimespan, deduplicateEntries, filterByTimeframe, isKeyEvent, } from "../utils/log-parser.js";
|
|
7
|
+
import { MAX_ENTRIES } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Generic logs summarizer
|
|
10
|
+
*/
|
|
11
|
+
export const genericSummarizer = {
|
|
12
|
+
name: "generic",
|
|
13
|
+
logType: "generic",
|
|
14
|
+
canSummarize(_logs) {
|
|
15
|
+
// Generic summarizer can handle anything
|
|
16
|
+
return true;
|
|
17
|
+
},
|
|
18
|
+
summarize(logs, options) {
|
|
19
|
+
const lines = logs.split("\n").filter((l) => l.trim());
|
|
20
|
+
const errors = [];
|
|
21
|
+
const warnings = [];
|
|
22
|
+
const keyEvents = [];
|
|
23
|
+
const allEntries = [];
|
|
24
|
+
// Parse all lines
|
|
25
|
+
for (const line of lines) {
|
|
26
|
+
const trimmed = line.trim();
|
|
27
|
+
if (!trimmed)
|
|
28
|
+
continue;
|
|
29
|
+
const entry = parseLogLine(trimmed);
|
|
30
|
+
allEntries.push(entry);
|
|
31
|
+
// Categorize by level
|
|
32
|
+
switch (entry.level) {
|
|
33
|
+
case "error":
|
|
34
|
+
errors.push(entry);
|
|
35
|
+
break;
|
|
36
|
+
case "warning":
|
|
37
|
+
warnings.push(entry);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
// Detect key events
|
|
41
|
+
if (isKeyEvent(trimmed)) {
|
|
42
|
+
keyEvents.push(entry);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Filter by timeframe if specified
|
|
46
|
+
const filteredEntries = filterByTimeframe(allEntries, options.timeframe);
|
|
47
|
+
// Calculate timespan
|
|
48
|
+
const timespan = calculateTimespan(filteredEntries);
|
|
49
|
+
// Deduplicate errors and warnings
|
|
50
|
+
const deduplicatedErrors = deduplicateEntries(errors);
|
|
51
|
+
const deduplicatedWarnings = deduplicateEntries(warnings);
|
|
52
|
+
// Build statistics
|
|
53
|
+
const statistics = {
|
|
54
|
+
timespan,
|
|
55
|
+
totalLines: lines.length,
|
|
56
|
+
errorCount: errors.length,
|
|
57
|
+
warningCount: warnings.length,
|
|
58
|
+
infoCount: allEntries.filter((e) => e.level === "info").length,
|
|
59
|
+
debugCount: allEntries.filter((e) => e.level === "debug").length,
|
|
60
|
+
};
|
|
61
|
+
// Build overview
|
|
62
|
+
const overview = buildOverview(statistics);
|
|
63
|
+
return {
|
|
64
|
+
logType: options.logType || "generic",
|
|
65
|
+
overview,
|
|
66
|
+
errors: deduplicatedErrors.slice(0, MAX_ENTRIES[options.detail].errors),
|
|
67
|
+
warnings: deduplicatedWarnings.slice(0, MAX_ENTRIES[options.detail].warnings),
|
|
68
|
+
keyEvents: keyEvents.slice(0, MAX_ENTRIES[options.detail].events),
|
|
69
|
+
statistics,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Build overview text
|
|
75
|
+
*/
|
|
76
|
+
function buildOverview(stats) {
|
|
77
|
+
const parts = [];
|
|
78
|
+
parts.push(`${stats.totalLines.toLocaleString()} lines`);
|
|
79
|
+
if (stats.timespan) {
|
|
80
|
+
parts.push(`spanning ${stats.timespan.durationFormatted}`);
|
|
81
|
+
}
|
|
82
|
+
const levelCounts = [];
|
|
83
|
+
if (stats.errorCount > 0)
|
|
84
|
+
levelCounts.push(`${stats.errorCount} errors`);
|
|
85
|
+
if (stats.warningCount > 0)
|
|
86
|
+
levelCounts.push(`${stats.warningCount} warnings`);
|
|
87
|
+
if (stats.infoCount > 0)
|
|
88
|
+
levelCounts.push(`${stats.infoCount} info`);
|
|
89
|
+
if (levelCounts.length > 0) {
|
|
90
|
+
parts.push(`(${levelCounts.join(", ")})`);
|
|
91
|
+
}
|
|
92
|
+
return parts.join(" ") || "Log summary";
|
|
93
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log Summarizers
|
|
3
|
+
*
|
|
4
|
+
* Exports all summarizers and utility functions.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export { serverLogsSummarizer } from "./server-logs.js";
|
|
8
|
+
export { testLogsSummarizer } from "./test-logs.js";
|
|
9
|
+
export { buildLogsSummarizer } from "./build-logs.js";
|
|
10
|
+
export { genericSummarizer } from "./generic.js";
|
|
11
|
+
import type { Summarizer, LogType } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* All available summarizers in priority order
|
|
14
|
+
*/
|
|
15
|
+
export declare const summarizers: Summarizer[];
|
|
16
|
+
/**
|
|
17
|
+
* Get the appropriate summarizer for the given logs
|
|
18
|
+
*/
|
|
19
|
+
export declare function getSummarizer(logs: string, preferredType?: LogType): Summarizer;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/summarizers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMtD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,UAAU,EAKnC,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,UAAU,CAkB/E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log Summarizers
|
|
3
|
+
*
|
|
4
|
+
* Exports all summarizers and utility functions.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export { serverLogsSummarizer } from "./server-logs.js";
|
|
8
|
+
export { testLogsSummarizer } from "./test-logs.js";
|
|
9
|
+
export { buildLogsSummarizer } from "./build-logs.js";
|
|
10
|
+
export { genericSummarizer } from "./generic.js";
|
|
11
|
+
import { serverLogsSummarizer } from "./server-logs.js";
|
|
12
|
+
import { testLogsSummarizer } from "./test-logs.js";
|
|
13
|
+
import { buildLogsSummarizer } from "./build-logs.js";
|
|
14
|
+
import { genericSummarizer } from "./generic.js";
|
|
15
|
+
/**
|
|
16
|
+
* All available summarizers in priority order
|
|
17
|
+
*/
|
|
18
|
+
export const summarizers = [
|
|
19
|
+
serverLogsSummarizer,
|
|
20
|
+
testLogsSummarizer,
|
|
21
|
+
buildLogsSummarizer,
|
|
22
|
+
genericSummarizer, // Fallback
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Get the appropriate summarizer for the given logs
|
|
26
|
+
*/
|
|
27
|
+
export function getSummarizer(logs, preferredType) {
|
|
28
|
+
// If a type is specified, find that summarizer
|
|
29
|
+
if (preferredType) {
|
|
30
|
+
const preferred = summarizers.find((s) => s.logType === preferredType);
|
|
31
|
+
if (preferred) {
|
|
32
|
+
return preferred;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Auto-detect based on content
|
|
36
|
+
for (const summarizer of summarizers) {
|
|
37
|
+
if (summarizer.logType !== "generic" && summarizer.canSummarize(logs)) {
|
|
38
|
+
return summarizer;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Fallback to generic
|
|
42
|
+
return genericSummarizer;
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Logs Summarizer
|
|
3
|
+
*
|
|
4
|
+
* Summarizes HTTP server logs with request statistics, response times, and error tracking.
|
|
5
|
+
*/
|
|
6
|
+
import type { Summarizer } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Server logs summarizer
|
|
9
|
+
*/
|
|
10
|
+
export declare const serverLogsSummarizer: Summarizer;
|
|
11
|
+
//# sourceMappingURL=server-logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-logs.d.ts","sourceRoot":"","sources":["../../src/summarizers/server-logs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,UAAU,EAMX,MAAM,YAAY,CAAC;AA0EpB;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,UAyJlC,CAAC"}
|