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,498 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-File Compressor
|
|
3
|
+
*
|
|
4
|
+
* Compresses multiple files with cross-file deduplication,
|
|
5
|
+
* dependency-aware skeleton extraction, and smart chunking.
|
|
6
|
+
*/
|
|
7
|
+
import { countTokens } from "../utils/token-counter.js";
|
|
8
|
+
// ============================================
|
|
9
|
+
// Import Extraction
|
|
10
|
+
// ============================================
|
|
11
|
+
/**
|
|
12
|
+
* Extract imports from TypeScript/JavaScript content
|
|
13
|
+
*/
|
|
14
|
+
function extractTsImports(content) {
|
|
15
|
+
const imports = [];
|
|
16
|
+
// ES6 imports: import { x, y } from 'module'
|
|
17
|
+
const esImportRegex = /import\s+(?:(\w+)\s*,?\s*)?(?:\{([^}]+)\})?\s*(?:from\s+)?['"]([^'"]+)['"]/g;
|
|
18
|
+
// Namespace imports: import * as x from 'module'
|
|
19
|
+
const namespaceRegex = /import\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;
|
|
20
|
+
// Default imports: import x from 'module'
|
|
21
|
+
const defaultRegex = /import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;
|
|
22
|
+
let match;
|
|
23
|
+
// ES6 named imports
|
|
24
|
+
while ((match = esImportRegex.exec(content)) !== null) {
|
|
25
|
+
const defaultName = match[1];
|
|
26
|
+
const namedImports = match[2];
|
|
27
|
+
const source = match[3];
|
|
28
|
+
const names = [];
|
|
29
|
+
if (defaultName)
|
|
30
|
+
names.push(defaultName);
|
|
31
|
+
if (namedImports) {
|
|
32
|
+
names.push(...namedImports
|
|
33
|
+
.split(",")
|
|
34
|
+
.map((n) => n.trim().split(/\s+as\s+/)[0]?.trim() || "")
|
|
35
|
+
.filter((n) => n));
|
|
36
|
+
}
|
|
37
|
+
imports.push({
|
|
38
|
+
source: source || "",
|
|
39
|
+
names,
|
|
40
|
+
isDefault: !!defaultName && !namedImports,
|
|
41
|
+
isNamespace: false,
|
|
42
|
+
raw: match[0] || "",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// Namespace imports
|
|
46
|
+
while ((match = namespaceRegex.exec(content)) !== null) {
|
|
47
|
+
imports.push({
|
|
48
|
+
source: match[2] || "",
|
|
49
|
+
names: [match[1] || ""],
|
|
50
|
+
isDefault: false,
|
|
51
|
+
isNamespace: true,
|
|
52
|
+
raw: match[0] || "",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return imports;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Extract imports from Python content
|
|
59
|
+
*/
|
|
60
|
+
function extractPyImports(content) {
|
|
61
|
+
const imports = [];
|
|
62
|
+
// from module import x, y
|
|
63
|
+
const fromImportRegex = /from\s+([\w.]+)\s+import\s+([^#\n]+)/g;
|
|
64
|
+
// import module
|
|
65
|
+
const importRegex = /^import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/gm;
|
|
66
|
+
let match;
|
|
67
|
+
while ((match = fromImportRegex.exec(content)) !== null) {
|
|
68
|
+
const importPart = match[2] || "";
|
|
69
|
+
const names = importPart
|
|
70
|
+
.split(",")
|
|
71
|
+
.map((n) => n.trim().split(/\s+as\s+/)[0]?.trim() || "")
|
|
72
|
+
.filter((n) => n && n !== "*");
|
|
73
|
+
imports.push({
|
|
74
|
+
source: match[1] || "",
|
|
75
|
+
names,
|
|
76
|
+
isDefault: false,
|
|
77
|
+
isNamespace: importPart.trim() === "*",
|
|
78
|
+
raw: match[0] || "",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
82
|
+
const modulePart = match[1] || "";
|
|
83
|
+
const modules = modulePart.split(",").map((m) => m.trim());
|
|
84
|
+
for (const mod of modules) {
|
|
85
|
+
imports.push({
|
|
86
|
+
source: mod,
|
|
87
|
+
names: [mod.split(".").pop() || mod],
|
|
88
|
+
isDefault: true,
|
|
89
|
+
isNamespace: false,
|
|
90
|
+
raw: match[0] || "",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return imports;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Extract imports based on file language
|
|
98
|
+
*/
|
|
99
|
+
function extractImports(content, language) {
|
|
100
|
+
const lang = language?.toLowerCase() || "";
|
|
101
|
+
if (lang.includes("typescript") ||
|
|
102
|
+
lang.includes("javascript") ||
|
|
103
|
+
lang === "ts" ||
|
|
104
|
+
lang === "js" ||
|
|
105
|
+
lang === "tsx" ||
|
|
106
|
+
lang === "jsx") {
|
|
107
|
+
return extractTsImports(content);
|
|
108
|
+
}
|
|
109
|
+
if (lang.includes("python") || lang === "py") {
|
|
110
|
+
return extractPyImports(content);
|
|
111
|
+
}
|
|
112
|
+
// Default to TS-style extraction for unknown languages
|
|
113
|
+
return extractTsImports(content);
|
|
114
|
+
}
|
|
115
|
+
// ============================================
|
|
116
|
+
// Type/Interface Extraction
|
|
117
|
+
// ============================================
|
|
118
|
+
/**
|
|
119
|
+
* Extract type definitions from TypeScript content
|
|
120
|
+
*/
|
|
121
|
+
function extractTypeDefinitions(content) {
|
|
122
|
+
const types = [];
|
|
123
|
+
// Type aliases: type Foo = ...
|
|
124
|
+
const typeRegex = /export\s+type\s+(\w+)(?:<[^>]+>)?\s*=\s*([^;]+);/g;
|
|
125
|
+
// Interfaces: interface Foo { ... }
|
|
126
|
+
const interfaceRegex = /export\s+interface\s+(\w+)(?:<[^>]+>)?\s*(?:extends\s+[^{]+)?\s*\{([^}]+)\}/g;
|
|
127
|
+
// Classes: class Foo { ... }
|
|
128
|
+
const classRegex = /export\s+(?:abstract\s+)?class\s+(\w+)(?:<[^>]+>)?(?:\s+extends\s+\w+)?(?:\s+implements\s+[^{]+)?\s*\{/g;
|
|
129
|
+
// Enums: enum Foo { ... }
|
|
130
|
+
const enumRegex = /export\s+(?:const\s+)?enum\s+(\w+)\s*\{([^}]+)\}/g;
|
|
131
|
+
let match;
|
|
132
|
+
while ((match = typeRegex.exec(content)) !== null) {
|
|
133
|
+
types.push({
|
|
134
|
+
name: match[1] || "",
|
|
135
|
+
kind: "type",
|
|
136
|
+
definition: match[0] || "",
|
|
137
|
+
usedIn: [],
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
while ((match = interfaceRegex.exec(content)) !== null) {
|
|
141
|
+
types.push({
|
|
142
|
+
name: match[1] || "",
|
|
143
|
+
kind: "interface",
|
|
144
|
+
definition: match[0] || "",
|
|
145
|
+
usedIn: [],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
while ((match = classRegex.exec(content)) !== null) {
|
|
149
|
+
types.push({
|
|
150
|
+
name: match[1] || "",
|
|
151
|
+
kind: "class",
|
|
152
|
+
definition: (match[0] || "").replace(/\{$/, "{ ... }"),
|
|
153
|
+
usedIn: [],
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
while ((match = enumRegex.exec(content)) !== null) {
|
|
157
|
+
types.push({
|
|
158
|
+
name: match[1] || "",
|
|
159
|
+
kind: "enum",
|
|
160
|
+
definition: match[0] || "",
|
|
161
|
+
usedIn: [],
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return types;
|
|
165
|
+
}
|
|
166
|
+
// ============================================
|
|
167
|
+
// Cross-File Deduplication
|
|
168
|
+
// ============================================
|
|
169
|
+
/**
|
|
170
|
+
* Find shared imports across multiple files
|
|
171
|
+
*/
|
|
172
|
+
function findSharedImports(files) {
|
|
173
|
+
const importMap = new Map();
|
|
174
|
+
for (const file of files) {
|
|
175
|
+
const imports = extractImports(file.content, file.language);
|
|
176
|
+
for (const imp of imports) {
|
|
177
|
+
const key = imp.source;
|
|
178
|
+
if (!importMap.has(key)) {
|
|
179
|
+
importMap.set(key, { names: new Set(), usedIn: [] });
|
|
180
|
+
}
|
|
181
|
+
const entry = importMap.get(key);
|
|
182
|
+
imp.names.forEach((n) => entry.names.add(n));
|
|
183
|
+
if (!entry.usedIn.includes(file.path)) {
|
|
184
|
+
entry.usedIn.push(file.path);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return importMap;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Find shared types across multiple files
|
|
192
|
+
*/
|
|
193
|
+
function findSharedTypes(files) {
|
|
194
|
+
const typeMap = new Map();
|
|
195
|
+
for (const file of files) {
|
|
196
|
+
const types = extractTypeDefinitions(file.content);
|
|
197
|
+
for (const type of types) {
|
|
198
|
+
if (!typeMap.has(type.name)) {
|
|
199
|
+
typeMap.set(type.name, { ...type, usedIn: [file.path] });
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const existing = typeMap.get(type.name);
|
|
203
|
+
if (!existing.usedIn.includes(file.path)) {
|
|
204
|
+
existing.usedIn.push(file.path);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Only return types used in multiple files
|
|
210
|
+
return Array.from(typeMap.values()).filter((t) => t.usedIn.length > 1);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Extract shared elements from files
|
|
214
|
+
*/
|
|
215
|
+
export function extractSharedElements(files) {
|
|
216
|
+
const sharedImports = findSharedImports(files);
|
|
217
|
+
const sharedTypes = findSharedTypes(files);
|
|
218
|
+
// Filter to imports used in 2+ files
|
|
219
|
+
const imports = Array.from(sharedImports.entries())
|
|
220
|
+
.filter(([_, info]) => info.usedIn.length >= 2)
|
|
221
|
+
.map(([source, info]) => ({
|
|
222
|
+
source,
|
|
223
|
+
names: Array.from(info.names),
|
|
224
|
+
usedIn: info.usedIn,
|
|
225
|
+
}));
|
|
226
|
+
return {
|
|
227
|
+
imports,
|
|
228
|
+
types: sharedTypes,
|
|
229
|
+
constants: [], // TODO: Extract shared constants
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
// ============================================
|
|
233
|
+
// Content Deduplication
|
|
234
|
+
// ============================================
|
|
235
|
+
/**
|
|
236
|
+
* Remove shared imports from file content
|
|
237
|
+
*/
|
|
238
|
+
function removeSharedImports(content, sharedSources, language) {
|
|
239
|
+
const imports = extractImports(content, language);
|
|
240
|
+
let result = content;
|
|
241
|
+
// Remove imports that are in shared set
|
|
242
|
+
for (const imp of imports) {
|
|
243
|
+
if (sharedSources.has(imp.source)) {
|
|
244
|
+
result = result.replace(imp.raw, "");
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Clean up empty lines
|
|
248
|
+
result = result.replace(/\n\s*\n\s*\n/g, "\n\n");
|
|
249
|
+
return result.trim();
|
|
250
|
+
}
|
|
251
|
+
// ============================================
|
|
252
|
+
// Skeleton Extraction
|
|
253
|
+
// ============================================
|
|
254
|
+
/**
|
|
255
|
+
* Extract skeleton (signatures only) from file content
|
|
256
|
+
*/
|
|
257
|
+
function extractSkeleton(content, language) {
|
|
258
|
+
const lines = [];
|
|
259
|
+
const contentLines = content.split("\n");
|
|
260
|
+
// Track brace depth for function body extraction
|
|
261
|
+
let braceDepth = 0;
|
|
262
|
+
let inFunctionBody = false;
|
|
263
|
+
let currentSignature = "";
|
|
264
|
+
for (const line of contentLines) {
|
|
265
|
+
const trimmed = line.trim();
|
|
266
|
+
// Skip empty lines and comments in function bodies
|
|
267
|
+
if (inFunctionBody) {
|
|
268
|
+
braceDepth += (line.match(/\{/g) || []).length;
|
|
269
|
+
braceDepth -= (line.match(/\}/g) || []).length;
|
|
270
|
+
if (braceDepth === 0) {
|
|
271
|
+
inFunctionBody = false;
|
|
272
|
+
lines.push(currentSignature + " { ... }");
|
|
273
|
+
}
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
// Keep imports (they're already deduplicated)
|
|
277
|
+
if (trimmed.startsWith("import ") ||
|
|
278
|
+
trimmed.startsWith("from ") ||
|
|
279
|
+
trimmed.startsWith("export {")) {
|
|
280
|
+
lines.push(line);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
// Keep type definitions
|
|
284
|
+
if (trimmed.startsWith("export type ") ||
|
|
285
|
+
trimmed.startsWith("export interface ") ||
|
|
286
|
+
trimmed.startsWith("type ") ||
|
|
287
|
+
trimmed.startsWith("interface ")) {
|
|
288
|
+
lines.push(line);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
// Function/method signatures
|
|
292
|
+
if (/^(export\s+)?(async\s+)?function\s+\w+/.test(trimmed) ||
|
|
293
|
+
/^(export\s+)?const\s+\w+\s*=\s*(async\s+)?\([^)]*\)\s*(=>|:)/.test(trimmed)) {
|
|
294
|
+
if (trimmed.includes("{") && !trimmed.includes("}")) {
|
|
295
|
+
// Multi-line function
|
|
296
|
+
currentSignature = line.replace(/\{[^}]*$/, "").trim();
|
|
297
|
+
braceDepth = 1;
|
|
298
|
+
inFunctionBody = true;
|
|
299
|
+
}
|
|
300
|
+
else if (trimmed.includes("=>") && !trimmed.includes("{")) {
|
|
301
|
+
// Arrow function with expression body
|
|
302
|
+
lines.push(line.split("=>")[0] + "=> ...");
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
// Single-line function or declaration
|
|
306
|
+
lines.push(line);
|
|
307
|
+
}
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
// Class declarations
|
|
311
|
+
if (/^(export\s+)?(abstract\s+)?class\s+\w+/.test(trimmed)) {
|
|
312
|
+
if (trimmed.includes("{")) {
|
|
313
|
+
currentSignature = line.replace(/\{[^}]*$/, "").trim();
|
|
314
|
+
braceDepth = 1;
|
|
315
|
+
inFunctionBody = true;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
lines.push(line);
|
|
319
|
+
}
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
// Keep exports
|
|
323
|
+
if (trimmed.startsWith("export ")) {
|
|
324
|
+
lines.push(line);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return lines.join("\n");
|
|
328
|
+
}
|
|
329
|
+
// ============================================
|
|
330
|
+
// Smart Chunking
|
|
331
|
+
// ============================================
|
|
332
|
+
/**
|
|
333
|
+
* Build dependency graph from files
|
|
334
|
+
*/
|
|
335
|
+
function buildDependencyGraph(files) {
|
|
336
|
+
const graph = new Map();
|
|
337
|
+
for (const file of files) {
|
|
338
|
+
graph.set(file.path, new Set());
|
|
339
|
+
const imports = extractImports(file.content, file.language);
|
|
340
|
+
for (const imp of imports) {
|
|
341
|
+
// Check if import refers to another file in our set
|
|
342
|
+
for (const otherFile of files) {
|
|
343
|
+
if (otherFile.path !== file.path &&
|
|
344
|
+
(otherFile.path.includes(imp.source) ||
|
|
345
|
+
imp.source.includes(otherFile.path.replace(/\.(ts|js|tsx|jsx)$/, "")))) {
|
|
346
|
+
graph.get(file.path).add(otherFile.path);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return graph;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Create chunks based on dependencies
|
|
355
|
+
*/
|
|
356
|
+
export function createChunks(files, maxTokensPerChunk) {
|
|
357
|
+
const graph = buildDependencyGraph(files);
|
|
358
|
+
const chunks = [];
|
|
359
|
+
const assigned = new Set();
|
|
360
|
+
// Calculate tokens for each file
|
|
361
|
+
const fileTokens = new Map();
|
|
362
|
+
for (const file of files) {
|
|
363
|
+
fileTokens.set(file.path, countTokens(file.content));
|
|
364
|
+
}
|
|
365
|
+
// Group files by connected components
|
|
366
|
+
let chunkId = 0;
|
|
367
|
+
for (const file of files) {
|
|
368
|
+
if (assigned.has(file.path))
|
|
369
|
+
continue;
|
|
370
|
+
const chunk = {
|
|
371
|
+
id: `chunk-${chunkId++}`,
|
|
372
|
+
files: [],
|
|
373
|
+
tokens: 0,
|
|
374
|
+
dependencies: [],
|
|
375
|
+
};
|
|
376
|
+
// BFS to find related files
|
|
377
|
+
const queue = [file.path];
|
|
378
|
+
while (queue.length > 0 && chunk.tokens < maxTokensPerChunk) {
|
|
379
|
+
const current = queue.shift();
|
|
380
|
+
if (assigned.has(current))
|
|
381
|
+
continue;
|
|
382
|
+
const tokens = fileTokens.get(current) || 0;
|
|
383
|
+
if (chunk.tokens + tokens > maxTokensPerChunk && chunk.files.length > 0) {
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
assigned.add(current);
|
|
387
|
+
chunk.files.push(current);
|
|
388
|
+
chunk.tokens += tokens;
|
|
389
|
+
// Add dependencies to queue
|
|
390
|
+
const deps = graph.get(current);
|
|
391
|
+
if (deps) {
|
|
392
|
+
for (const dep of deps) {
|
|
393
|
+
if (!assigned.has(dep)) {
|
|
394
|
+
queue.push(dep);
|
|
395
|
+
if (!chunk.dependencies.includes(dep)) {
|
|
396
|
+
chunk.dependencies.push(dep);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (chunk.files.length > 0) {
|
|
403
|
+
chunks.push(chunk);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return chunks;
|
|
407
|
+
}
|
|
408
|
+
// ============================================
|
|
409
|
+
// Main Compression Function
|
|
410
|
+
// ============================================
|
|
411
|
+
/**
|
|
412
|
+
* Compress multiple files with cross-file deduplication
|
|
413
|
+
*/
|
|
414
|
+
export function compressMultiFile(files, options) {
|
|
415
|
+
const maxTokens = options.maxTokens || 50000;
|
|
416
|
+
const strategy = options.strategy || "deduplicate";
|
|
417
|
+
// Calculate original tokens
|
|
418
|
+
const originalTokens = files.reduce((sum, f) => sum + countTokens(f.content), 0);
|
|
419
|
+
// Extract shared elements
|
|
420
|
+
const sharedElements = extractSharedElements(files);
|
|
421
|
+
const sharedSources = new Set(sharedElements.imports.map((i) => i.source));
|
|
422
|
+
const parts = [];
|
|
423
|
+
let deduplicatedItems = 0;
|
|
424
|
+
// Add shared imports header
|
|
425
|
+
if (sharedElements.imports.length > 0) {
|
|
426
|
+
parts.push("// === Shared Imports ===");
|
|
427
|
+
for (const imp of sharedElements.imports) {
|
|
428
|
+
parts.push(`// ${imp.source}: ${imp.names.join(", ")}`);
|
|
429
|
+
deduplicatedItems += imp.names.length;
|
|
430
|
+
}
|
|
431
|
+
parts.push("");
|
|
432
|
+
}
|
|
433
|
+
// Add shared types header
|
|
434
|
+
if (sharedElements.types.length > 0) {
|
|
435
|
+
parts.push("// === Shared Types ===");
|
|
436
|
+
for (const type of sharedElements.types) {
|
|
437
|
+
parts.push(`// ${type.kind} ${type.name} (used in ${type.usedIn.length} files)`);
|
|
438
|
+
deduplicatedItems++;
|
|
439
|
+
}
|
|
440
|
+
parts.push("");
|
|
441
|
+
}
|
|
442
|
+
// Process files based on strategy
|
|
443
|
+
const filesIncluded = [];
|
|
444
|
+
switch (strategy) {
|
|
445
|
+
case "deduplicate": {
|
|
446
|
+
for (const file of files) {
|
|
447
|
+
const cleaned = removeSharedImports(file.content, sharedSources, file.language);
|
|
448
|
+
parts.push(`// === ${file.path} ===`);
|
|
449
|
+
parts.push(cleaned);
|
|
450
|
+
parts.push("");
|
|
451
|
+
filesIncluded.push(file.path);
|
|
452
|
+
}
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case "skeleton": {
|
|
456
|
+
for (const file of files) {
|
|
457
|
+
const skeleton = extractSkeleton(file.content, file.language);
|
|
458
|
+
parts.push(`// === ${file.path} (skeleton) ===`);
|
|
459
|
+
parts.push(skeleton);
|
|
460
|
+
parts.push("");
|
|
461
|
+
filesIncluded.push(file.path);
|
|
462
|
+
}
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
case "smart-chunk": {
|
|
466
|
+
const chunks = createChunks(files, maxTokens / 3);
|
|
467
|
+
for (const chunk of chunks.slice(0, 3)) {
|
|
468
|
+
// Limit to 3 chunks
|
|
469
|
+
parts.push(`// === ${chunk.id} (${chunk.files.length} files, ${chunk.tokens} tokens) ===`);
|
|
470
|
+
for (const filePath of chunk.files) {
|
|
471
|
+
const file = files.find((f) => f.path === filePath);
|
|
472
|
+
if (file) {
|
|
473
|
+
const skeleton = extractSkeleton(file.content, file.language);
|
|
474
|
+
parts.push(`// ${file.path}`);
|
|
475
|
+
parts.push(skeleton);
|
|
476
|
+
}
|
|
477
|
+
filesIncluded.push(filePath);
|
|
478
|
+
}
|
|
479
|
+
parts.push("");
|
|
480
|
+
}
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const compressed = parts.join("\n");
|
|
485
|
+
const compressedTokens = countTokens(compressed);
|
|
486
|
+
return {
|
|
487
|
+
compressed,
|
|
488
|
+
filesIncluded,
|
|
489
|
+
sharedElements,
|
|
490
|
+
stats: {
|
|
491
|
+
originalTokens,
|
|
492
|
+
compressedTokens,
|
|
493
|
+
filesProcessed: files.length,
|
|
494
|
+
deduplicatedItems,
|
|
495
|
+
reductionPercent: Math.round((1 - compressedTokens / originalTokens) * 100),
|
|
496
|
+
},
|
|
497
|
+
};
|
|
498
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 type { Compressor, CompressOptions, CompressedResult } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Extended options for semantic compression
|
|
14
|
+
*/
|
|
15
|
+
export interface SemanticCompressOptions extends CompressOptions {
|
|
16
|
+
/** Target compression ratio (0.5 = keep 50%). Default: 0.5 */
|
|
17
|
+
targetRatio?: number;
|
|
18
|
+
/** Compression model: 'fast' for rule-based. Default: 'fast' */
|
|
19
|
+
model?: "fast";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extended result with preserved segments info
|
|
23
|
+
*/
|
|
24
|
+
export interface SemanticCompressedResult extends CompressedResult {
|
|
25
|
+
/** Segments that were explicitly preserved */
|
|
26
|
+
preservedSegments: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Semantic compressor implementation
|
|
30
|
+
*/
|
|
31
|
+
export declare const semanticCompressor: Compressor;
|
|
32
|
+
export default semanticCompressor;
|
|
33
|
+
//# sourceMappingURL=semantic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../src/compressors/semantic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAYhF;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE,8CAA8C;IAC9C,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AA2JD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,UA8GhC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|