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,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Compressor
|
|
3
|
+
*
|
|
4
|
+
* Compresses content based on semantic importance using:
|
|
5
|
+
* - TF-IDF scoring for unique/rare terms
|
|
6
|
+
* - Position weighting (beginning/end prioritized)
|
|
7
|
+
* - Keyword detection (errors, instructions, code)
|
|
8
|
+
*
|
|
9
|
+
* Phase 2: Rule-based implementation (no ML models)
|
|
10
|
+
*/
|
|
11
|
+
import { countTokens } from "../utils/token-counter.js";
|
|
12
|
+
import { calculateTFIDF, getSegmentTFIDFScore } from "../utils/tfidf.js";
|
|
13
|
+
import { createSegment, scoreSegment, hasErrorIndicators, } from "../utils/segment-scorer.js";
|
|
14
|
+
/**
|
|
15
|
+
* Segment content into meaningful chunks
|
|
16
|
+
* Respects:
|
|
17
|
+
* - Code blocks (keep as single unit)
|
|
18
|
+
* - Paragraphs (separated by blank lines)
|
|
19
|
+
* - Error lines (keep intact)
|
|
20
|
+
*/
|
|
21
|
+
function segmentContent(content) {
|
|
22
|
+
const segments = [];
|
|
23
|
+
const lines = content.split("\n");
|
|
24
|
+
const totalLines = lines.length;
|
|
25
|
+
let currentSegment = [];
|
|
26
|
+
let startLine = 0;
|
|
27
|
+
let inCodeBlock = false;
|
|
28
|
+
let codeBlockMarker = "";
|
|
29
|
+
for (let i = 0; i < lines.length; i++) {
|
|
30
|
+
const line = lines[i];
|
|
31
|
+
const trimmedLine = line.trim();
|
|
32
|
+
// Track code blocks (``` or ~~~)
|
|
33
|
+
if (trimmedLine.startsWith("```") || trimmedLine.startsWith("~~~")) {
|
|
34
|
+
const marker = trimmedLine.slice(0, 3);
|
|
35
|
+
if (!inCodeBlock) {
|
|
36
|
+
// Start of code block - save previous segment first
|
|
37
|
+
if (currentSegment.length > 0) {
|
|
38
|
+
const text = currentSegment.join("\n").trim();
|
|
39
|
+
if (text) {
|
|
40
|
+
segments.push(createSegment(text, startLine, i - 1, "paragraph", totalLines));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
currentSegment = [line];
|
|
44
|
+
startLine = i;
|
|
45
|
+
inCodeBlock = true;
|
|
46
|
+
codeBlockMarker = marker;
|
|
47
|
+
}
|
|
48
|
+
else if (marker === codeBlockMarker) {
|
|
49
|
+
// End of code block
|
|
50
|
+
currentSegment.push(line);
|
|
51
|
+
const text = currentSegment.join("\n");
|
|
52
|
+
segments.push(createSegment(text, startLine, i, "code-block", totalLines));
|
|
53
|
+
currentSegment = [];
|
|
54
|
+
startLine = i + 1;
|
|
55
|
+
inCodeBlock = false;
|
|
56
|
+
codeBlockMarker = "";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Different marker inside code block, treat as content
|
|
60
|
+
currentSegment.push(line);
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (inCodeBlock) {
|
|
65
|
+
currentSegment.push(line);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// Empty line ends a paragraph
|
|
69
|
+
if (trimmedLine === "") {
|
|
70
|
+
if (currentSegment.length > 0) {
|
|
71
|
+
const text = currentSegment.join("\n").trim();
|
|
72
|
+
if (text) {
|
|
73
|
+
// Check if this segment contains errors - treat as separate lines if so
|
|
74
|
+
if (hasErrorIndicators(text) && currentSegment.length > 1) {
|
|
75
|
+
// Split error-containing segments into individual lines
|
|
76
|
+
for (let j = 0; j < currentSegment.length; j++) {
|
|
77
|
+
const lineText = currentSegment[j].trim();
|
|
78
|
+
if (lineText) {
|
|
79
|
+
segments.push(createSegment(lineText, startLine + j, startLine + j, "line", totalLines));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
segments.push(createSegment(text, startLine, i - 1, "paragraph", totalLines));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
currentSegment = [];
|
|
88
|
+
}
|
|
89
|
+
startLine = i + 1;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
currentSegment.push(line);
|
|
93
|
+
}
|
|
94
|
+
// Handle remaining content
|
|
95
|
+
if (currentSegment.length > 0) {
|
|
96
|
+
const text = currentSegment.join("\n").trim();
|
|
97
|
+
if (text) {
|
|
98
|
+
const type = inCodeBlock ? "code-block" : "paragraph";
|
|
99
|
+
segments.push(createSegment(text, startLine, lines.length - 1, type, totalLines));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return segments;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Select segments to keep based on importance and target ratio
|
|
106
|
+
*/
|
|
107
|
+
function selectSegments(scored, targetTokens, preservePatterns) {
|
|
108
|
+
// Separate preserved segments (must keep) from regular
|
|
109
|
+
const preserved = [];
|
|
110
|
+
const regular = [];
|
|
111
|
+
for (const segment of scored) {
|
|
112
|
+
const isPreservedByPattern = preservePatterns?.some((p) => p.test(segment.text));
|
|
113
|
+
if (segment.isPreserved || isPreservedByPattern) {
|
|
114
|
+
segment.isPreserved = true;
|
|
115
|
+
preserved.push(segment);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
regular.push(segment);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Sort regular segments by importance (descending)
|
|
122
|
+
regular.sort((a, b) => b.importance - a.importance);
|
|
123
|
+
// Calculate tokens used by preserved segments
|
|
124
|
+
let tokensUsed = preserved.reduce((sum, s) => sum + s.tokens, 0);
|
|
125
|
+
const selected = [...preserved];
|
|
126
|
+
// Add regular segments until we hit target
|
|
127
|
+
for (const segment of regular) {
|
|
128
|
+
if (tokensUsed + segment.tokens <= targetTokens) {
|
|
129
|
+
selected.push(segment);
|
|
130
|
+
tokensUsed += segment.tokens;
|
|
131
|
+
}
|
|
132
|
+
else if (tokensUsed >= targetTokens) {
|
|
133
|
+
// Already at target
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Sort by original position to maintain reading order
|
|
138
|
+
selected.sort((a, b) => a.startLine - b.startLine);
|
|
139
|
+
return selected;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Semantic compressor implementation
|
|
143
|
+
*/
|
|
144
|
+
export const semanticCompressor = {
|
|
145
|
+
name: "semantic",
|
|
146
|
+
supportedTypes: ["generic", "code", "logs"],
|
|
147
|
+
canCompress(content) {
|
|
148
|
+
// Can compress any content with at least some substance
|
|
149
|
+
// Very short content (<100 chars) has no room for meaningful compression
|
|
150
|
+
return content.length >= 100;
|
|
151
|
+
},
|
|
152
|
+
compress(content, options) {
|
|
153
|
+
const originalTokens = countTokens(content);
|
|
154
|
+
const targetRatio = options.targetRatio ?? 0.5;
|
|
155
|
+
// If content is already very small, return as-is
|
|
156
|
+
// Below 50 tokens, compression would likely make content worse
|
|
157
|
+
if (originalTokens < 50) {
|
|
158
|
+
return {
|
|
159
|
+
compressed: content,
|
|
160
|
+
stats: {
|
|
161
|
+
originalLines: content.split("\n").length,
|
|
162
|
+
compressedLines: content.split("\n").length,
|
|
163
|
+
originalTokens,
|
|
164
|
+
compressedTokens: originalTokens,
|
|
165
|
+
reductionPercent: 0,
|
|
166
|
+
technique: "semantic-compression (no-op: content already optimized, <50 tokens)",
|
|
167
|
+
},
|
|
168
|
+
preservedSegments: [],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const targetTokens = Math.floor(originalTokens * targetRatio);
|
|
172
|
+
// Step 1: Segment content
|
|
173
|
+
const segments = segmentContent(content);
|
|
174
|
+
// If we only have one segment, can't compress further meaningfully
|
|
175
|
+
if (segments.length <= 1) {
|
|
176
|
+
return {
|
|
177
|
+
compressed: content,
|
|
178
|
+
stats: {
|
|
179
|
+
originalLines: content.split("\n").length,
|
|
180
|
+
compressedLines: content.split("\n").length,
|
|
181
|
+
originalTokens,
|
|
182
|
+
compressedTokens: originalTokens,
|
|
183
|
+
reductionPercent: 0,
|
|
184
|
+
technique: "semantic-compression (no-op: atomic content, cannot segment)",
|
|
185
|
+
},
|
|
186
|
+
preservedSegments: [],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// Step 2: Calculate TF-IDF scores
|
|
190
|
+
const segmentTexts = segments.map((s) => s.text);
|
|
191
|
+
const tfidfMap = calculateTFIDF(segmentTexts);
|
|
192
|
+
// Step 3: Score each segment
|
|
193
|
+
const scored = segments.map((segment, i) => {
|
|
194
|
+
const tfidfScore = getSegmentTFIDFScore(i, tfidfMap);
|
|
195
|
+
return scoreSegment(segment, tfidfScore);
|
|
196
|
+
});
|
|
197
|
+
// Step 4: Mark segments that match preserve patterns
|
|
198
|
+
if (options.preservePatterns) {
|
|
199
|
+
for (const segment of scored) {
|
|
200
|
+
if (options.preservePatterns.some((p) => p.test(segment.text))) {
|
|
201
|
+
segment.isPreserved = true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Step 5: Select segments to keep
|
|
206
|
+
const selected = selectSegments(scored, targetTokens, options.preservePatterns);
|
|
207
|
+
// Step 6: Reconstruct compressed text
|
|
208
|
+
const compressed = selected.map((s) => s.text).join("\n\n");
|
|
209
|
+
const compressedTokens = countTokens(compressed);
|
|
210
|
+
// Calculate stats
|
|
211
|
+
const reductionPercent = originalTokens > 0
|
|
212
|
+
? Math.round((1 - compressedTokens / originalTokens) * 100)
|
|
213
|
+
: 0;
|
|
214
|
+
// Build preserved segments list (truncated for display)
|
|
215
|
+
const preservedSegments = selected
|
|
216
|
+
.filter((s) => s.isPreserved)
|
|
217
|
+
.map((s) => (s.text.length > 50 ? s.text.slice(0, 47) + "..." : s.text));
|
|
218
|
+
return {
|
|
219
|
+
compressed,
|
|
220
|
+
stats: {
|
|
221
|
+
originalLines: content.split("\n").length,
|
|
222
|
+
compressedLines: compressed.split("\n").length,
|
|
223
|
+
originalTokens,
|
|
224
|
+
compressedTokens,
|
|
225
|
+
reductionPercent,
|
|
226
|
+
technique: "semantic-compression",
|
|
227
|
+
},
|
|
228
|
+
omittedInfo: `${segments.length - selected.length} of ${segments.length} segments removed based on importance scoring`,
|
|
229
|
+
preservedSegments,
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
export default semanticCompressor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack Trace Compressor
|
|
3
|
+
*
|
|
4
|
+
* Specialized compressor for error stack traces.
|
|
5
|
+
* Keeps relevant frames (project code) and summarizes internal frames.
|
|
6
|
+
*/
|
|
7
|
+
import type { Compressor } from "./types.js";
|
|
8
|
+
export declare const stacktraceCompressor: Compressor;
|
|
9
|
+
//# sourceMappingURL=stacktrace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stacktrace.d.ts","sourceRoot":"","sources":["../../src/compressors/stacktrace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAqC,MAAM,YAAY,CAAC;AAmPhF,eAAO,MAAM,oBAAoB,EAAE,UA4DlC,CAAC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack Trace Compressor
|
|
3
|
+
*
|
|
4
|
+
* Specialized compressor for error stack traces.
|
|
5
|
+
* Keeps relevant frames (project code) and summarizes internal frames.
|
|
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
|
+
// Patterns for internal frames (node_modules, runtime, etc.)
|
|
13
|
+
const INTERNAL_PATTERNS = [
|
|
14
|
+
/node_modules/,
|
|
15
|
+
/internal\//,
|
|
16
|
+
/<anonymous>/,
|
|
17
|
+
/native code/,
|
|
18
|
+
/\[native code\]/,
|
|
19
|
+
/webpack:/,
|
|
20
|
+
/turbopack:/,
|
|
21
|
+
/at Module\./,
|
|
22
|
+
/at require \(/,
|
|
23
|
+
/at Object\.<anonymous>/,
|
|
24
|
+
/at processTicksAndRejections/,
|
|
25
|
+
/at async /,
|
|
26
|
+
/__webpack_require__/,
|
|
27
|
+
];
|
|
28
|
+
// Patterns for project code (should be kept)
|
|
29
|
+
const PROJECT_PATTERNS = [
|
|
30
|
+
/\/(src|app|lib|pages|components|utils|services|hooks|store)\//,
|
|
31
|
+
/\.(ts|tsx|js|jsx):\d+/,
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Check if a frame is internal (should be summarized)
|
|
35
|
+
*/
|
|
36
|
+
function isInternalFrame(line) {
|
|
37
|
+
return INTERNAL_PATTERNS.some((pattern) => pattern.test(line));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if a frame is project code (should be kept)
|
|
41
|
+
*/
|
|
42
|
+
function isProjectFrame(line) {
|
|
43
|
+
if (isInternalFrame(line))
|
|
44
|
+
return false;
|
|
45
|
+
return PROJECT_PATTERNS.some((pattern) => pattern.test(line));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse a stack trace line into a frame
|
|
49
|
+
*/
|
|
50
|
+
function parseFrame(line) {
|
|
51
|
+
const isInternal = isInternalFrame(line);
|
|
52
|
+
const isProject = isProjectFrame(line);
|
|
53
|
+
// Extract location if present
|
|
54
|
+
const locationMatch = line.match(/\(([^)]+)\)$/) || line.match(/at\s+([^\s]+)$/);
|
|
55
|
+
const location = locationMatch?.[1];
|
|
56
|
+
return {
|
|
57
|
+
raw: line,
|
|
58
|
+
isInternal,
|
|
59
|
+
isProjectCode: isProject,
|
|
60
|
+
location,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Detect the type of stack trace
|
|
65
|
+
*/
|
|
66
|
+
function detectStackType(content) {
|
|
67
|
+
if (/^\s+at\s+/m.test(content))
|
|
68
|
+
return "javascript";
|
|
69
|
+
if (/^Traceback \(most recent call last\)/m.test(content))
|
|
70
|
+
return "python";
|
|
71
|
+
if (/^thread '.*' panicked at/m.test(content))
|
|
72
|
+
return "rust";
|
|
73
|
+
if (/^goroutine \d+ \[/m.test(content))
|
|
74
|
+
return "go";
|
|
75
|
+
if (/^\s+at [a-zA-Z0-9$.]+\([^)]*\)$/m.test(content))
|
|
76
|
+
return "java";
|
|
77
|
+
return "unknown";
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Compress JavaScript/Node.js stack trace
|
|
81
|
+
*/
|
|
82
|
+
function compressJSStack(lines, detail) {
|
|
83
|
+
const output = [];
|
|
84
|
+
let internalCount = 0;
|
|
85
|
+
let consecutiveInternal = 0;
|
|
86
|
+
for (let i = 0; i < lines.length; i++) {
|
|
87
|
+
const line = lines[i] ?? "";
|
|
88
|
+
// Keep error message lines (not starting with "at")
|
|
89
|
+
if (!line.trim().startsWith("at ") && !line.match(/^\s+at\s+/)) {
|
|
90
|
+
// If we have pending internal frames, summarize them
|
|
91
|
+
if (consecutiveInternal > 0) {
|
|
92
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
93
|
+
consecutiveInternal = 0;
|
|
94
|
+
}
|
|
95
|
+
output.push(line);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const frame = parseFrame(line);
|
|
99
|
+
if (frame.isInternal) {
|
|
100
|
+
consecutiveInternal++;
|
|
101
|
+
internalCount++;
|
|
102
|
+
// In detailed mode, keep more frames
|
|
103
|
+
if (detail === "detailed" && consecutiveInternal <= 3) {
|
|
104
|
+
output.push(line);
|
|
105
|
+
consecutiveInternal = 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// If we have pending internal frames, summarize them
|
|
110
|
+
if (consecutiveInternal > 0) {
|
|
111
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
112
|
+
consecutiveInternal = 0;
|
|
113
|
+
}
|
|
114
|
+
output.push(line);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Handle trailing internal frames
|
|
118
|
+
if (consecutiveInternal > 0) {
|
|
119
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
120
|
+
}
|
|
121
|
+
return { compressed: output, internalCount };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Compress Python traceback
|
|
125
|
+
*/
|
|
126
|
+
function compressPythonStack(lines, detail) {
|
|
127
|
+
const output = [];
|
|
128
|
+
let internalCount = 0;
|
|
129
|
+
let consecutiveInternal = 0;
|
|
130
|
+
let i = 0;
|
|
131
|
+
while (i < lines.length) {
|
|
132
|
+
const line = lines[i] ?? "";
|
|
133
|
+
// Keep traceback header and error message
|
|
134
|
+
if (line.startsWith("Traceback") || !line.startsWith(" ")) {
|
|
135
|
+
if (consecutiveInternal > 0) {
|
|
136
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
137
|
+
consecutiveInternal = 0;
|
|
138
|
+
}
|
|
139
|
+
output.push(line);
|
|
140
|
+
i++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
// File line followed by code line
|
|
144
|
+
if (line.trim().startsWith('File "')) {
|
|
145
|
+
const isInternal = line.includes("site-packages") ||
|
|
146
|
+
line.includes("/usr/lib/") ||
|
|
147
|
+
line.includes("\\lib\\");
|
|
148
|
+
if (isInternal) {
|
|
149
|
+
consecutiveInternal++;
|
|
150
|
+
internalCount++;
|
|
151
|
+
// Skip the next line (code line) too
|
|
152
|
+
i += 2;
|
|
153
|
+
if (detail === "detailed" && consecutiveInternal <= 2) {
|
|
154
|
+
output.push(line);
|
|
155
|
+
if (lines[i - 1])
|
|
156
|
+
output.push(lines[i - 1] ?? "");
|
|
157
|
+
consecutiveInternal = 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
if (consecutiveInternal > 0) {
|
|
162
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
163
|
+
consecutiveInternal = 0;
|
|
164
|
+
}
|
|
165
|
+
output.push(line);
|
|
166
|
+
i++;
|
|
167
|
+
// Include the code line
|
|
168
|
+
if (i < lines.length) {
|
|
169
|
+
output.push(lines[i] ?? "");
|
|
170
|
+
i++;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
output.push(line);
|
|
176
|
+
i++;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (consecutiveInternal > 0) {
|
|
180
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
181
|
+
}
|
|
182
|
+
return { compressed: output, internalCount };
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Generic stack compression (for Rust, Go, Java, etc.)
|
|
186
|
+
*/
|
|
187
|
+
function compressGenericStack(lines, _detail) {
|
|
188
|
+
const output = [];
|
|
189
|
+
let internalCount = 0;
|
|
190
|
+
let consecutiveInternal = 0;
|
|
191
|
+
for (const line of lines) {
|
|
192
|
+
const isInternal = isInternalFrame(line);
|
|
193
|
+
if (isInternal) {
|
|
194
|
+
consecutiveInternal++;
|
|
195
|
+
internalCount++;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
if (consecutiveInternal > 0) {
|
|
199
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
200
|
+
consecutiveInternal = 0;
|
|
201
|
+
}
|
|
202
|
+
output.push(line);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (consecutiveInternal > 0) {
|
|
206
|
+
output.push(` ... (${consecutiveInternal} internal frames omitted)`);
|
|
207
|
+
}
|
|
208
|
+
return { compressed: output, internalCount };
|
|
209
|
+
}
|
|
210
|
+
export const stacktraceCompressor = {
|
|
211
|
+
name: "stacktrace",
|
|
212
|
+
supportedTypes: ["stacktrace"],
|
|
213
|
+
canCompress(content) {
|
|
214
|
+
// Check for stack trace patterns
|
|
215
|
+
const patterns = [
|
|
216
|
+
/^(Error|TypeError|ReferenceError|SyntaxError|RangeError):/m,
|
|
217
|
+
/^\s+at\s+/m,
|
|
218
|
+
/^Traceback \(most recent call last\):/m,
|
|
219
|
+
/^thread '.*' panicked at/m,
|
|
220
|
+
/^goroutine \d+ \[/m,
|
|
221
|
+
];
|
|
222
|
+
return patterns.some((pattern) => pattern.test(content));
|
|
223
|
+
},
|
|
224
|
+
compress(content, options) {
|
|
225
|
+
const lines = content.split("\n");
|
|
226
|
+
const originalTokens = countTokens(content);
|
|
227
|
+
// Detect stack type
|
|
228
|
+
const stackType = detectStackType(content);
|
|
229
|
+
// Compress based on type
|
|
230
|
+
let result;
|
|
231
|
+
switch (stackType) {
|
|
232
|
+
case "javascript":
|
|
233
|
+
result = compressJSStack(lines, options.detail);
|
|
234
|
+
break;
|
|
235
|
+
case "python":
|
|
236
|
+
result = compressPythonStack(lines, options.detail);
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
result = compressGenericStack(lines, options.detail);
|
|
240
|
+
}
|
|
241
|
+
const compressed = result.compressed.join("\n");
|
|
242
|
+
const compressedTokens = countTokens(compressed);
|
|
243
|
+
const reductionPercent = originalTokens > 0 ? Math.round((1 - compressedTokens / originalTokens) * 100) : 0;
|
|
244
|
+
return {
|
|
245
|
+
compressed,
|
|
246
|
+
stats: {
|
|
247
|
+
originalLines: lines.length,
|
|
248
|
+
compressedLines: result.compressed.length,
|
|
249
|
+
originalTokens,
|
|
250
|
+
compressedTokens,
|
|
251
|
+
reductionPercent,
|
|
252
|
+
technique: `stacktrace-${stackType}`,
|
|
253
|
+
},
|
|
254
|
+
omittedInfo: result.internalCount > 0
|
|
255
|
+
? `${result.internalCount} internal/library frames summarized`
|
|
256
|
+
: undefined,
|
|
257
|
+
};
|
|
258
|
+
},
|
|
259
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compressor Types
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions for context compressors.
|
|
5
|
+
*/
|
|
6
|
+
export type ContentType = "logs" | "stacktrace" | "config" | "code" | "generic";
|
|
7
|
+
export type DetailLevel = "minimal" | "normal" | "detailed";
|
|
8
|
+
export interface CompressOptions {
|
|
9
|
+
/** Target compression ratio (0.1 = 10% of original) */
|
|
10
|
+
targetRatio?: number;
|
|
11
|
+
/** Patterns to preserve (will not be compressed) */
|
|
12
|
+
preservePatterns?: RegExp[];
|
|
13
|
+
/** Level of detail in output */
|
|
14
|
+
detail: DetailLevel;
|
|
15
|
+
}
|
|
16
|
+
export interface CompressedResult {
|
|
17
|
+
/** Compressed content */
|
|
18
|
+
compressed: string;
|
|
19
|
+
/** Compression statistics */
|
|
20
|
+
stats: CompressionStats;
|
|
21
|
+
/** Description of omitted information */
|
|
22
|
+
omittedInfo?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CompressionStats {
|
|
25
|
+
/** Number of lines in original content */
|
|
26
|
+
originalLines: number;
|
|
27
|
+
/** Number of lines after compression */
|
|
28
|
+
compressedLines: number;
|
|
29
|
+
/** Token count of original content */
|
|
30
|
+
originalTokens: number;
|
|
31
|
+
/** Token count after compression */
|
|
32
|
+
compressedTokens: number;
|
|
33
|
+
/** Percentage of tokens saved */
|
|
34
|
+
reductionPercent: number;
|
|
35
|
+
/** Technique used for compression */
|
|
36
|
+
technique: string;
|
|
37
|
+
}
|
|
38
|
+
export interface Compressor {
|
|
39
|
+
/** Compressor name */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Content types this compressor can handle */
|
|
42
|
+
supportedTypes: ContentType[];
|
|
43
|
+
/** Check if this compressor can handle the content */
|
|
44
|
+
canCompress(content: string): boolean;
|
|
45
|
+
/** Compress the content */
|
|
46
|
+
compress(content: string, options: CompressOptions): CompressedResult;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Line group for deduplication
|
|
50
|
+
*/
|
|
51
|
+
export interface LineGroup {
|
|
52
|
+
/** Normalized pattern for matching */
|
|
53
|
+
pattern: string;
|
|
54
|
+
/** First occurrence of this pattern */
|
|
55
|
+
sample: string;
|
|
56
|
+
/** All lines matching this pattern */
|
|
57
|
+
lines: string[];
|
|
58
|
+
/** Number of occurrences */
|
|
59
|
+
count: number;
|
|
60
|
+
/** Whether this group contains errors */
|
|
61
|
+
hasError: boolean;
|
|
62
|
+
/** Whether this group contains warnings */
|
|
63
|
+
hasWarning: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parsed diff hunk
|
|
67
|
+
*/
|
|
68
|
+
export interface DiffHunk {
|
|
69
|
+
/** Original file line start */
|
|
70
|
+
oldStart: number;
|
|
71
|
+
/** Original file line count */
|
|
72
|
+
oldCount: number;
|
|
73
|
+
/** New file line start */
|
|
74
|
+
newStart: number;
|
|
75
|
+
/** New file line count */
|
|
76
|
+
newCount: number;
|
|
77
|
+
/** The hunk content (including +/- prefixes) */
|
|
78
|
+
content: string;
|
|
79
|
+
/** Lines added in this hunk */
|
|
80
|
+
additions: number;
|
|
81
|
+
/** Lines removed in this hunk */
|
|
82
|
+
deletions: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parsed file diff
|
|
86
|
+
*/
|
|
87
|
+
export interface FileDiff {
|
|
88
|
+
/** Old file path (null if new file) */
|
|
89
|
+
oldPath: string | null;
|
|
90
|
+
/** New file path (null if deleted file) */
|
|
91
|
+
newPath: string | null;
|
|
92
|
+
/** File status */
|
|
93
|
+
status: "modified" | "added" | "deleted" | "renamed";
|
|
94
|
+
/** Binary file indicator */
|
|
95
|
+
isBinary: boolean;
|
|
96
|
+
/** Hunks in this file */
|
|
97
|
+
hunks: DiffHunk[];
|
|
98
|
+
/** Total additions */
|
|
99
|
+
additions: number;
|
|
100
|
+
/** Total deletions */
|
|
101
|
+
deletions: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Complete parsed diff
|
|
105
|
+
*/
|
|
106
|
+
export interface ParsedDiff {
|
|
107
|
+
/** All file diffs */
|
|
108
|
+
files: FileDiff[];
|
|
109
|
+
/** Total additions across all files */
|
|
110
|
+
totalAdditions: number;
|
|
111
|
+
/** Total deletions across all files */
|
|
112
|
+
totalDeletions: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Diff compression strategy
|
|
116
|
+
*/
|
|
117
|
+
export type DiffStrategy = "hunks-only" | "summary" | "semantic";
|
|
118
|
+
/**
|
|
119
|
+
* Diff compression options
|
|
120
|
+
*/
|
|
121
|
+
export interface DiffCompressOptions {
|
|
122
|
+
/** Compression strategy */
|
|
123
|
+
strategy: DiffStrategy;
|
|
124
|
+
/** Maximum tokens for output (semantic strategy) */
|
|
125
|
+
maxTokens?: number;
|
|
126
|
+
/** Number of context lines to keep (hunks-only strategy) */
|
|
127
|
+
contextLines?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Diff compression result
|
|
131
|
+
*/
|
|
132
|
+
export interface DiffCompressedResult {
|
|
133
|
+
/** Compressed diff content */
|
|
134
|
+
compressed: string;
|
|
135
|
+
/** List of changed file paths */
|
|
136
|
+
filesChanged: string[];
|
|
137
|
+
/** Summary of changes */
|
|
138
|
+
summary: string;
|
|
139
|
+
/** Total additions */
|
|
140
|
+
additions: number;
|
|
141
|
+
/** Total deletions */
|
|
142
|
+
deletions: number;
|
|
143
|
+
/** Compression statistics */
|
|
144
|
+
stats: CompressionStats;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compressors/types.ts"],"names":[],"mappings":"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"}
|