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,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diff Compressor
|
|
3
|
+
*
|
|
4
|
+
* Compresses git diff output to reduce tokens while preserving essential changes.
|
|
5
|
+
* Supports three strategies: hunks-only, summary, and semantic.
|
|
6
|
+
*/
|
|
7
|
+
import { countTokens } from "../utils/token-counter.js";
|
|
8
|
+
import { calculateTFIDF, getSegmentTFIDFScore } from "../utils/tfidf.js";
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Diff Parser
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Parse unified diff format into structured data
|
|
14
|
+
*
|
|
15
|
+
* Handles:
|
|
16
|
+
* - Standard unified diff (git diff, diff -u)
|
|
17
|
+
* - File headers: diff --git a/path b/path
|
|
18
|
+
* - Index lines: index abc123..def456 100644
|
|
19
|
+
* - --- / +++ file markers
|
|
20
|
+
* - @@ hunk headers
|
|
21
|
+
* - Context lines (space prefix)
|
|
22
|
+
* - Addition lines (+ prefix)
|
|
23
|
+
* - Deletion lines (- prefix)
|
|
24
|
+
* - Binary file indicators
|
|
25
|
+
* - Renamed files (similarity index)
|
|
26
|
+
*/
|
|
27
|
+
export function parseDiff(diff) {
|
|
28
|
+
const files = [];
|
|
29
|
+
const lines = diff.split("\n");
|
|
30
|
+
let currentFile = null;
|
|
31
|
+
let currentHunk = null;
|
|
32
|
+
let hunkLines = [];
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
// Detect file header: diff --git a/path b/path
|
|
35
|
+
if (line.startsWith("diff --git ")) {
|
|
36
|
+
// Save previous file
|
|
37
|
+
if (currentFile) {
|
|
38
|
+
if (currentHunk) {
|
|
39
|
+
currentHunk.content = hunkLines.join("\n");
|
|
40
|
+
currentFile.hunks.push(currentHunk);
|
|
41
|
+
}
|
|
42
|
+
files.push(currentFile);
|
|
43
|
+
}
|
|
44
|
+
// Parse paths from header
|
|
45
|
+
const match = line.match(/diff --git a\/(.+) b\/(.+)/);
|
|
46
|
+
currentFile = {
|
|
47
|
+
oldPath: match?.[1] ?? null,
|
|
48
|
+
newPath: match?.[2] ?? null,
|
|
49
|
+
status: "modified",
|
|
50
|
+
isBinary: false,
|
|
51
|
+
hunks: [],
|
|
52
|
+
additions: 0,
|
|
53
|
+
deletions: 0,
|
|
54
|
+
};
|
|
55
|
+
currentHunk = null;
|
|
56
|
+
hunkLines = [];
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// Detect new file mode
|
|
60
|
+
if (line.startsWith("new file mode")) {
|
|
61
|
+
if (currentFile)
|
|
62
|
+
currentFile.status = "added";
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
// Detect deleted file mode
|
|
66
|
+
if (line.startsWith("deleted file mode")) {
|
|
67
|
+
if (currentFile)
|
|
68
|
+
currentFile.status = "deleted";
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Detect rename
|
|
72
|
+
if (line.startsWith("similarity index") || line.startsWith("rename from")) {
|
|
73
|
+
if (currentFile)
|
|
74
|
+
currentFile.status = "renamed";
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// Detect binary file
|
|
78
|
+
if (line.startsWith("Binary files")) {
|
|
79
|
+
if (currentFile)
|
|
80
|
+
currentFile.isBinary = true;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// Detect hunk header: @@ -oldStart,oldCount +newStart,newCount @@
|
|
84
|
+
if (line.startsWith("@@")) {
|
|
85
|
+
// Save previous hunk
|
|
86
|
+
if (currentHunk && currentFile) {
|
|
87
|
+
currentHunk.content = hunkLines.join("\n");
|
|
88
|
+
currentFile.hunks.push(currentHunk);
|
|
89
|
+
}
|
|
90
|
+
const match = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
91
|
+
currentHunk = {
|
|
92
|
+
oldStart: parseInt(match?.[1] ?? "0"),
|
|
93
|
+
oldCount: parseInt(match?.[2] ?? "1"),
|
|
94
|
+
newStart: parseInt(match?.[3] ?? "0"),
|
|
95
|
+
newCount: parseInt(match?.[4] ?? "1"),
|
|
96
|
+
content: "",
|
|
97
|
+
additions: 0,
|
|
98
|
+
deletions: 0,
|
|
99
|
+
};
|
|
100
|
+
hunkLines = [line]; // Include @@ header
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
// Hunk content lines
|
|
104
|
+
if (currentHunk) {
|
|
105
|
+
hunkLines.push(line);
|
|
106
|
+
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
107
|
+
currentHunk.additions++;
|
|
108
|
+
if (currentFile)
|
|
109
|
+
currentFile.additions++;
|
|
110
|
+
}
|
|
111
|
+
else if (line.startsWith("-") && !line.startsWith("---")) {
|
|
112
|
+
currentHunk.deletions++;
|
|
113
|
+
if (currentFile)
|
|
114
|
+
currentFile.deletions++;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Save final file/hunk
|
|
119
|
+
if (currentFile) {
|
|
120
|
+
if (currentHunk) {
|
|
121
|
+
currentHunk.content = hunkLines.join("\n");
|
|
122
|
+
currentFile.hunks.push(currentHunk);
|
|
123
|
+
}
|
|
124
|
+
files.push(currentFile);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
files,
|
|
128
|
+
totalAdditions: files.reduce((sum, f) => sum + f.additions, 0),
|
|
129
|
+
totalDeletions: files.reduce((sum, f) => sum + f.deletions, 0),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// =============================================================================
|
|
133
|
+
// Compression Strategies
|
|
134
|
+
// =============================================================================
|
|
135
|
+
/**
|
|
136
|
+
* Strategy 1: hunks-only
|
|
137
|
+
* Keep only changed lines with minimal context
|
|
138
|
+
*/
|
|
139
|
+
function compressHunksOnly(parsed, contextLines = 1) {
|
|
140
|
+
const output = [];
|
|
141
|
+
for (const file of parsed.files) {
|
|
142
|
+
// File header
|
|
143
|
+
const path = file.newPath ?? file.oldPath ?? "unknown";
|
|
144
|
+
const statusIcon = {
|
|
145
|
+
modified: "M",
|
|
146
|
+
added: "A",
|
|
147
|
+
deleted: "D",
|
|
148
|
+
renamed: "R",
|
|
149
|
+
}[file.status];
|
|
150
|
+
output.push(`${statusIcon} ${path}`);
|
|
151
|
+
if (file.isBinary) {
|
|
152
|
+
output.push(" (binary file)");
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
// Process hunks
|
|
156
|
+
for (const hunk of file.hunks) {
|
|
157
|
+
// Simplified hunk header
|
|
158
|
+
output.push(`@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@`);
|
|
159
|
+
// Filter to only changed lines + minimal context
|
|
160
|
+
const hunkContentLines = hunk.content.split("\n").slice(1); // Skip @@ header
|
|
161
|
+
const relevantLines = [];
|
|
162
|
+
const changeIndices = [];
|
|
163
|
+
// Find all change indices
|
|
164
|
+
hunkContentLines.forEach((line, idx) => {
|
|
165
|
+
if (line.startsWith("+") || line.startsWith("-")) {
|
|
166
|
+
changeIndices.push(idx);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
// Include lines near changes
|
|
170
|
+
hunkContentLines.forEach((line, i) => {
|
|
171
|
+
if (line.startsWith("+") || line.startsWith("-")) {
|
|
172
|
+
relevantLines.push(line);
|
|
173
|
+
}
|
|
174
|
+
else if (line.startsWith(" ")) {
|
|
175
|
+
// Context line - check if near a change
|
|
176
|
+
const nearChange = changeIndices.some((idx) => Math.abs(idx - i) <= contextLines);
|
|
177
|
+
if (nearChange) {
|
|
178
|
+
relevantLines.push(line);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
output.push(...relevantLines);
|
|
183
|
+
}
|
|
184
|
+
output.push(""); // Blank line between files
|
|
185
|
+
}
|
|
186
|
+
return output.join("\n").trim();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Strategy 2: summary
|
|
190
|
+
* Generate human-readable summary without diff content
|
|
191
|
+
*/
|
|
192
|
+
function compressSummary(parsed) {
|
|
193
|
+
const output = [];
|
|
194
|
+
// Overall summary
|
|
195
|
+
output.push("## Diff Summary");
|
|
196
|
+
output.push(`- Files changed: ${parsed.files.length}`);
|
|
197
|
+
output.push(`- Additions: +${parsed.totalAdditions}`);
|
|
198
|
+
output.push(`- Deletions: -${parsed.totalDeletions}`);
|
|
199
|
+
output.push("");
|
|
200
|
+
// Group by status
|
|
201
|
+
const byStatus = {
|
|
202
|
+
added: parsed.files.filter((f) => f.status === "added"),
|
|
203
|
+
modified: parsed.files.filter((f) => f.status === "modified"),
|
|
204
|
+
deleted: parsed.files.filter((f) => f.status === "deleted"),
|
|
205
|
+
renamed: parsed.files.filter((f) => f.status === "renamed"),
|
|
206
|
+
};
|
|
207
|
+
// List new files
|
|
208
|
+
if (byStatus.added.length > 0) {
|
|
209
|
+
output.push(`### Added (${byStatus.added.length})`);
|
|
210
|
+
for (const file of byStatus.added) {
|
|
211
|
+
output.push(`- ${file.newPath} (+${file.additions})`);
|
|
212
|
+
}
|
|
213
|
+
output.push("");
|
|
214
|
+
}
|
|
215
|
+
// List modified files with change description
|
|
216
|
+
if (byStatus.modified.length > 0) {
|
|
217
|
+
output.push(`### Modified (${byStatus.modified.length})`);
|
|
218
|
+
for (const file of byStatus.modified) {
|
|
219
|
+
const changeDesc = `+${file.additions}/-${file.deletions}, ${file.hunks.length} hunk${file.hunks.length !== 1 ? "s" : ""}`;
|
|
220
|
+
output.push(`- ${file.newPath}: ${changeDesc}`);
|
|
221
|
+
}
|
|
222
|
+
output.push("");
|
|
223
|
+
}
|
|
224
|
+
// List deleted files
|
|
225
|
+
if (byStatus.deleted.length > 0) {
|
|
226
|
+
output.push(`### Deleted (${byStatus.deleted.length})`);
|
|
227
|
+
for (const file of byStatus.deleted) {
|
|
228
|
+
output.push(`- ${file.oldPath} (-${file.deletions})`);
|
|
229
|
+
}
|
|
230
|
+
output.push("");
|
|
231
|
+
}
|
|
232
|
+
// List renamed files
|
|
233
|
+
if (byStatus.renamed.length > 0) {
|
|
234
|
+
output.push(`### Renamed (${byStatus.renamed.length})`);
|
|
235
|
+
for (const file of byStatus.renamed) {
|
|
236
|
+
output.push(`- ${file.oldPath} -> ${file.newPath}`);
|
|
237
|
+
}
|
|
238
|
+
output.push("");
|
|
239
|
+
}
|
|
240
|
+
return output.join("\n").trim();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Strategy 3: semantic
|
|
244
|
+
* Use TF-IDF to rank hunks by importance, keep most significant
|
|
245
|
+
*/
|
|
246
|
+
function compressSemantic(parsed, maxTokens) {
|
|
247
|
+
const allHunks = [];
|
|
248
|
+
// Flatten hunks with file context
|
|
249
|
+
for (const file of parsed.files) {
|
|
250
|
+
for (const hunk of file.hunks) {
|
|
251
|
+
allHunks.push({
|
|
252
|
+
file,
|
|
253
|
+
hunk,
|
|
254
|
+
score: 0,
|
|
255
|
+
tokens: countTokens(hunk.content),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (allHunks.length === 0) {
|
|
260
|
+
return compressSummary(parsed);
|
|
261
|
+
}
|
|
262
|
+
// Calculate TF-IDF scores for hunk content
|
|
263
|
+
const hunkTexts = allHunks.map((h) => h.hunk.content);
|
|
264
|
+
const tfidfMap = calculateTFIDF(hunkTexts);
|
|
265
|
+
// Score each hunk
|
|
266
|
+
allHunks.forEach((item, i) => {
|
|
267
|
+
let score = getSegmentTFIDFScore(i, tfidfMap);
|
|
268
|
+
const content = item.hunk.content;
|
|
269
|
+
// Boost for certain patterns
|
|
270
|
+
// Errors/exceptions are critical
|
|
271
|
+
if (/error|exception|fail|throw|panic/i.test(content)) {
|
|
272
|
+
score += 0.3;
|
|
273
|
+
}
|
|
274
|
+
// Function/class definitions are important
|
|
275
|
+
if (/^[+-]\s*(export\s+)?(function|class|interface|type|const|let|var|def |fn |pub fn|func )/m.test(content)) {
|
|
276
|
+
score += 0.2;
|
|
277
|
+
}
|
|
278
|
+
// Test files have lower priority (usually verbose)
|
|
279
|
+
if (/\.(test|spec)\.[jt]sx?$/.test(item.file.newPath ?? "")) {
|
|
280
|
+
score -= 0.1;
|
|
281
|
+
}
|
|
282
|
+
// More changes = more important
|
|
283
|
+
score += Math.min((item.hunk.additions + item.hunk.deletions) / 50, 0.2);
|
|
284
|
+
item.score = Math.min(Math.max(score, 0), 1);
|
|
285
|
+
});
|
|
286
|
+
// Sort by score descending
|
|
287
|
+
allHunks.sort((a, b) => b.score - a.score);
|
|
288
|
+
// Select hunks until maxTokens
|
|
289
|
+
const selected = [];
|
|
290
|
+
let tokensUsed = 0;
|
|
291
|
+
for (const item of allHunks) {
|
|
292
|
+
if (tokensUsed + item.tokens <= maxTokens) {
|
|
293
|
+
selected.push(item);
|
|
294
|
+
tokensUsed += item.tokens;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// If nothing selected, at least include summary
|
|
298
|
+
if (selected.length === 0) {
|
|
299
|
+
return compressSummary(parsed);
|
|
300
|
+
}
|
|
301
|
+
// Group by file and output
|
|
302
|
+
const fileMap = new Map();
|
|
303
|
+
for (const item of selected) {
|
|
304
|
+
const path = item.file.newPath ?? item.file.oldPath ?? "unknown";
|
|
305
|
+
if (!fileMap.has(path)) {
|
|
306
|
+
fileMap.set(path, []);
|
|
307
|
+
}
|
|
308
|
+
fileMap.get(path).push(item);
|
|
309
|
+
}
|
|
310
|
+
const output = [];
|
|
311
|
+
output.push("## Semantic Diff Compression");
|
|
312
|
+
output.push(`Showing ${selected.length} of ${allHunks.length} hunks (most important)`);
|
|
313
|
+
output.push("");
|
|
314
|
+
for (const [path, items] of fileMap) {
|
|
315
|
+
output.push(`### ${path}`);
|
|
316
|
+
output.push("```diff");
|
|
317
|
+
for (const item of items) {
|
|
318
|
+
output.push(item.hunk.content);
|
|
319
|
+
}
|
|
320
|
+
output.push("```");
|
|
321
|
+
output.push("");
|
|
322
|
+
}
|
|
323
|
+
return output.join("\n").trim();
|
|
324
|
+
}
|
|
325
|
+
// =============================================================================
|
|
326
|
+
// Main Compressor
|
|
327
|
+
// =============================================================================
|
|
328
|
+
/**
|
|
329
|
+
* Compress a git diff using the specified strategy
|
|
330
|
+
*/
|
|
331
|
+
export function compressDiff(diff, options) {
|
|
332
|
+
const parsed = parseDiff(diff);
|
|
333
|
+
// Extract file paths
|
|
334
|
+
const filesChanged = parsed.files
|
|
335
|
+
.map((f) => f.newPath ?? f.oldPath ?? "unknown")
|
|
336
|
+
.filter((p) => p !== "unknown");
|
|
337
|
+
// Calculate original tokens
|
|
338
|
+
const originalTokens = countTokens(diff);
|
|
339
|
+
// Apply compression strategy
|
|
340
|
+
let compressed;
|
|
341
|
+
let technique;
|
|
342
|
+
switch (options.strategy) {
|
|
343
|
+
case "hunks-only":
|
|
344
|
+
compressed = compressHunksOnly(parsed, options.contextLines ?? 1);
|
|
345
|
+
technique = "diff:hunks-only";
|
|
346
|
+
break;
|
|
347
|
+
case "summary":
|
|
348
|
+
compressed = compressSummary(parsed);
|
|
349
|
+
technique = "diff:summary";
|
|
350
|
+
break;
|
|
351
|
+
case "semantic":
|
|
352
|
+
const maxTokens = options.maxTokens ?? Math.ceil(originalTokens * 0.5);
|
|
353
|
+
compressed = compressSemantic(parsed, maxTokens);
|
|
354
|
+
technique = "diff:semantic";
|
|
355
|
+
break;
|
|
356
|
+
default:
|
|
357
|
+
compressed = compressHunksOnly(parsed);
|
|
358
|
+
technique = "diff:hunks-only";
|
|
359
|
+
}
|
|
360
|
+
const compressedTokens = countTokens(compressed);
|
|
361
|
+
// Generate summary
|
|
362
|
+
const summary = `${parsed.files.length} file${parsed.files.length !== 1 ? "s" : ""} changed, +${parsed.totalAdditions}/-${parsed.totalDeletions}`;
|
|
363
|
+
// Calculate stats
|
|
364
|
+
const stats = {
|
|
365
|
+
originalLines: diff.split("\n").length,
|
|
366
|
+
compressedLines: compressed.split("\n").length,
|
|
367
|
+
originalTokens,
|
|
368
|
+
compressedTokens,
|
|
369
|
+
reductionPercent: originalTokens > 0
|
|
370
|
+
? Math.round((1 - compressedTokens / originalTokens) * 100)
|
|
371
|
+
: 0,
|
|
372
|
+
technique,
|
|
373
|
+
};
|
|
374
|
+
return {
|
|
375
|
+
compressed,
|
|
376
|
+
filesChanged,
|
|
377
|
+
summary,
|
|
378
|
+
additions: parsed.totalAdditions,
|
|
379
|
+
deletions: parsed.totalDeletions,
|
|
380
|
+
stats,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Diff compressor instance for use with tool system
|
|
385
|
+
*/
|
|
386
|
+
export const diffCompressor = {
|
|
387
|
+
name: "diff",
|
|
388
|
+
compress: compressDiff,
|
|
389
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Compressor
|
|
3
|
+
*
|
|
4
|
+
* Fallback compressor for unrecognized content types.
|
|
5
|
+
* Uses line deduplication and repetition detection.
|
|
6
|
+
*/
|
|
7
|
+
import type { Compressor } from "./types.js";
|
|
8
|
+
export declare const genericCompressor: Compressor;
|
|
9
|
+
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/compressors/generic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAgD,MAAM,YAAY,CAAC;AAoK3F,eAAO,MAAM,iBAAiB,EAAE,UA4C/B,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Compressor
|
|
3
|
+
*
|
|
4
|
+
* Fallback compressor for unrecognized content types.
|
|
5
|
+
* Uses line deduplication and repetition detection.
|
|
6
|
+
*/
|
|
7
|
+
import { encodingForModel } from "js-tiktoken";
|
|
8
|
+
const encoding = encodingForModel("gpt-4");
|
|
9
|
+
function countTokens(text) {
|
|
10
|
+
return encoding.encode(text).length;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Normalize a line for pattern matching (remove numbers, normalize whitespace)
|
|
14
|
+
*/
|
|
15
|
+
function normalizeLine(line) {
|
|
16
|
+
return line
|
|
17
|
+
.replace(/\d+/g, "N") // Replace numbers
|
|
18
|
+
.replace(/0x[a-fA-F0-9]+/g, "HEX") // Replace hex values
|
|
19
|
+
.replace(/[a-f0-9]{8,}/gi, "HASH") // Replace hash-like strings
|
|
20
|
+
.replace(/\s+/g, " ") // Normalize whitespace
|
|
21
|
+
.trim();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Check if a line contains error indicators
|
|
25
|
+
*/
|
|
26
|
+
function isErrorLine(line) {
|
|
27
|
+
return /\b(error|Error|ERROR|fail|Fail|FAIL|fatal|Fatal|FATAL)\b/.test(line);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if a line contains warning indicators
|
|
31
|
+
*/
|
|
32
|
+
function isWarningLine(line) {
|
|
33
|
+
return /\b(warn|Warn|WARN|warning|Warning|WARNING)\b/.test(line);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if a line matches any preserve pattern
|
|
37
|
+
*/
|
|
38
|
+
function shouldPreserve(line, patterns) {
|
|
39
|
+
if (!patterns || patterns.length === 0)
|
|
40
|
+
return false;
|
|
41
|
+
return patterns.some((pattern) => pattern.test(line));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Group lines by their normalized pattern
|
|
45
|
+
*/
|
|
46
|
+
function groupLines(lines, preservePatterns) {
|
|
47
|
+
const groups = new Map();
|
|
48
|
+
const result = [];
|
|
49
|
+
for (const line of lines) {
|
|
50
|
+
if (!line.trim())
|
|
51
|
+
continue;
|
|
52
|
+
// Always keep preserved lines as individual groups
|
|
53
|
+
if (shouldPreserve(line, preservePatterns)) {
|
|
54
|
+
result.push({
|
|
55
|
+
pattern: line,
|
|
56
|
+
sample: line,
|
|
57
|
+
lines: [line],
|
|
58
|
+
count: 1,
|
|
59
|
+
hasError: isErrorLine(line),
|
|
60
|
+
hasWarning: isWarningLine(line),
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const normalized = normalizeLine(line);
|
|
65
|
+
const existing = groups.get(normalized);
|
|
66
|
+
if (existing) {
|
|
67
|
+
existing.lines.push(line);
|
|
68
|
+
existing.count++;
|
|
69
|
+
if (isErrorLine(line))
|
|
70
|
+
existing.hasError = true;
|
|
71
|
+
if (isWarningLine(line))
|
|
72
|
+
existing.hasWarning = true;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const group = {
|
|
76
|
+
pattern: normalized,
|
|
77
|
+
sample: line,
|
|
78
|
+
lines: [line],
|
|
79
|
+
count: 1,
|
|
80
|
+
hasError: isErrorLine(line),
|
|
81
|
+
hasWarning: isWarningLine(line),
|
|
82
|
+
};
|
|
83
|
+
groups.set(normalized, group);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Add grouped lines to result
|
|
87
|
+
result.push(...groups.values());
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Compress grouped lines based on detail level
|
|
92
|
+
*/
|
|
93
|
+
function compressGroups(groups, detail) {
|
|
94
|
+
const output = [];
|
|
95
|
+
const threshold = detail === "minimal" ? 2 : detail === "normal" ? 3 : 5;
|
|
96
|
+
for (const group of groups) {
|
|
97
|
+
// Always show errors and warnings fully
|
|
98
|
+
if (group.hasError || group.hasWarning) {
|
|
99
|
+
if (detail === "detailed" || group.count <= threshold) {
|
|
100
|
+
output.push(...group.lines);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
output.push(group.sample);
|
|
104
|
+
if (group.count > 1) {
|
|
105
|
+
output.push(` ... (${group.count - 1} similar ${group.hasError ? "errors" : "warnings"})`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Regular lines: show sample and count if above threshold
|
|
111
|
+
if (group.count <= threshold) {
|
|
112
|
+
output.push(...group.lines);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
output.push(group.sample);
|
|
116
|
+
output.push(` ... (${group.count - 1} similar lines omitted)`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return output;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Detect consecutive repeating lines
|
|
123
|
+
*/
|
|
124
|
+
function compressConsecutiveRepeats(lines, threshold = 3) {
|
|
125
|
+
const output = [];
|
|
126
|
+
let i = 0;
|
|
127
|
+
while (i < lines.length) {
|
|
128
|
+
const currentLine = lines[i];
|
|
129
|
+
let repeatCount = 1;
|
|
130
|
+
// Count consecutive identical or similar lines
|
|
131
|
+
while (i + repeatCount < lines.length) {
|
|
132
|
+
const nextLine = lines[i + repeatCount];
|
|
133
|
+
if (nextLine === currentLine ||
|
|
134
|
+
normalizeLine(nextLine ?? "") === normalizeLine(currentLine ?? "")) {
|
|
135
|
+
repeatCount++;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (repeatCount >= threshold) {
|
|
142
|
+
output.push(currentLine ?? "");
|
|
143
|
+
output.push(` ... (repeated ${repeatCount - 1} more times)`);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
for (let j = 0; j < repeatCount; j++) {
|
|
147
|
+
output.push(lines[i + j] ?? "");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
i += repeatCount;
|
|
151
|
+
}
|
|
152
|
+
return output;
|
|
153
|
+
}
|
|
154
|
+
export const genericCompressor = {
|
|
155
|
+
name: "generic",
|
|
156
|
+
supportedTypes: ["generic", "code"],
|
|
157
|
+
canCompress(_content) {
|
|
158
|
+
// Generic compressor can always compress
|
|
159
|
+
return true;
|
|
160
|
+
},
|
|
161
|
+
compress(content, options) {
|
|
162
|
+
const lines = content.split("\n");
|
|
163
|
+
const originalTokens = countTokens(content);
|
|
164
|
+
// First pass: compress consecutive repeats
|
|
165
|
+
const afterRepeats = compressConsecutiveRepeats(lines);
|
|
166
|
+
// Second pass: group and deduplicate similar lines
|
|
167
|
+
const groups = groupLines(afterRepeats, options.preservePatterns);
|
|
168
|
+
const compressedLines = compressGroups(groups, options.detail);
|
|
169
|
+
const compressed = compressedLines.join("\n");
|
|
170
|
+
const compressedTokens = countTokens(compressed);
|
|
171
|
+
const reductionPercent = originalTokens > 0 ? Math.round((1 - compressedTokens / originalTokens) * 100) : 0;
|
|
172
|
+
// Build omitted info
|
|
173
|
+
const totalOmitted = lines.length - compressedLines.length;
|
|
174
|
+
const omittedInfo = totalOmitted > 0 ? `${totalOmitted} lines omitted through deduplication` : undefined;
|
|
175
|
+
return {
|
|
176
|
+
compressed,
|
|
177
|
+
stats: {
|
|
178
|
+
originalLines: lines.length,
|
|
179
|
+
compressedLines: compressedLines.length,
|
|
180
|
+
originalTokens,
|
|
181
|
+
compressedTokens,
|
|
182
|
+
reductionPercent,
|
|
183
|
+
technique: "line-deduplication",
|
|
184
|
+
},
|
|
185
|
+
omittedInfo,
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compressors Index
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates content compression with auto-detection and routing.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
import type { Compressor, CompressOptions, CompressedResult, ContentType } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Get the appropriate compressor for a content type
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCompressor(contentType: ContentType): Compressor;
|
|
12
|
+
/**
|
|
13
|
+
* Compress content with auto-detection
|
|
14
|
+
*/
|
|
15
|
+
export declare function compressContent(content: string, options?: Partial<CompressOptions> & {
|
|
16
|
+
contentType?: ContentType;
|
|
17
|
+
}): CompressedResult;
|
|
18
|
+
/**
|
|
19
|
+
* Analyze content and suggest compression approach
|
|
20
|
+
*/
|
|
21
|
+
export declare function analyzeContent(content: string): {
|
|
22
|
+
detectedType: ContentType;
|
|
23
|
+
suggestedCompressor: string;
|
|
24
|
+
estimatedReduction: string;
|
|
25
|
+
};
|
|
26
|
+
export { logsCompressor } from "./logs.js";
|
|
27
|
+
export { stacktraceCompressor } from "./stacktrace.js";
|
|
28
|
+
export { configCompressor } from "./config.js";
|
|
29
|
+
export { genericCompressor } from "./generic.js";
|
|
30
|
+
export { semanticCompressor } from "./semantic.js";
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compressors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAe7F;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU,CAOlE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,OAAO,CAAC,eAAe,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACrE,gBAAgB,CAqBlB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG;IAC/C,YAAY,EAAE,WAAW,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAyBA;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
|