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,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build Output Parser Types
|
|
3
|
+
*
|
|
4
|
+
* Common types for parsing build tool outputs.
|
|
5
|
+
*/
|
|
6
|
+
export type BuildTool = "tsc" | "eslint" | "webpack" | "vite" | "esbuild" | "rust" | "go" | "generic";
|
|
7
|
+
export type Severity = "error" | "warning" | "info";
|
|
8
|
+
export interface ParsedError {
|
|
9
|
+
/** Unique signature for grouping (e.g., "TS2304:Cannot find name") */
|
|
10
|
+
signature: string;
|
|
11
|
+
/** Error code (e.g., "TS2304", "E0433") */
|
|
12
|
+
code: string;
|
|
13
|
+
/** Error message */
|
|
14
|
+
message: string;
|
|
15
|
+
/** Source file path */
|
|
16
|
+
file: string;
|
|
17
|
+
/** Line number */
|
|
18
|
+
line: number;
|
|
19
|
+
/** Column number */
|
|
20
|
+
column: number;
|
|
21
|
+
/** Error severity */
|
|
22
|
+
severity: Severity;
|
|
23
|
+
/** Original raw line from output */
|
|
24
|
+
raw: string;
|
|
25
|
+
/** Additional context (surrounding lines, suggestions) */
|
|
26
|
+
context?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ErrorGroup {
|
|
29
|
+
/** Unique signature */
|
|
30
|
+
signature: string;
|
|
31
|
+
/** Error code */
|
|
32
|
+
code: string;
|
|
33
|
+
/** Canonical error message */
|
|
34
|
+
message: string;
|
|
35
|
+
/** Severity */
|
|
36
|
+
severity: Severity;
|
|
37
|
+
/** Total occurrences */
|
|
38
|
+
count: number;
|
|
39
|
+
/** First occurrence */
|
|
40
|
+
firstOccurrence: {
|
|
41
|
+
file: string;
|
|
42
|
+
line: number;
|
|
43
|
+
column: number;
|
|
44
|
+
};
|
|
45
|
+
/** All affected files */
|
|
46
|
+
affectedFiles: string[];
|
|
47
|
+
/** Sample of raw errors (max 3) */
|
|
48
|
+
samples: string[];
|
|
49
|
+
/** Suggested fix if available */
|
|
50
|
+
suggestion?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface BuildAnalysisResult {
|
|
53
|
+
/** Detected build tool */
|
|
54
|
+
buildTool: BuildTool;
|
|
55
|
+
/** Whether the build succeeded */
|
|
56
|
+
success: boolean;
|
|
57
|
+
/** Compressed summary */
|
|
58
|
+
summary: string;
|
|
59
|
+
/** Statistics */
|
|
60
|
+
stats: {
|
|
61
|
+
totalErrors: number;
|
|
62
|
+
totalWarnings: number;
|
|
63
|
+
uniqueErrorTypes: number;
|
|
64
|
+
uniqueWarningTypes: number;
|
|
65
|
+
tokensOriginal: number;
|
|
66
|
+
tokensCompressed: number;
|
|
67
|
+
reductionPercent: number;
|
|
68
|
+
};
|
|
69
|
+
/** Grouped errors */
|
|
70
|
+
errorGroups: ErrorGroup[];
|
|
71
|
+
/** Grouped warnings */
|
|
72
|
+
warningGroups: ErrorGroup[];
|
|
73
|
+
}
|
|
74
|
+
export interface BuildParser {
|
|
75
|
+
/** Name of the parser */
|
|
76
|
+
name: string;
|
|
77
|
+
/** Supported build tools */
|
|
78
|
+
supportedTools: BuildTool[];
|
|
79
|
+
/** Check if this parser can handle the output */
|
|
80
|
+
canParse(output: string): boolean;
|
|
81
|
+
/** Parse the output and extract errors */
|
|
82
|
+
parse(output: string): ParsedError[];
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/parsers/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEtG,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,eAAe,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,yBAAyB;IACzB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,mCAAmC;IACnC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,0BAA0B;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,KAAK,EAAE;QACL,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,qBAAqB;IACrB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,uBAAuB;IACvB,aAAa,EAAE,UAAU,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,cAAc,EAAE,SAAS,EAAE,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,0CAA0C;IAC1C,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/parsers/typescript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,YAAY,CAAC;AAwErE,eAAO,MAAM,gBAAgB,EAAE,WAqD9B,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Error Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses TypeScript compiler (tsc) output and extracts structured errors.
|
|
5
|
+
*/
|
|
6
|
+
// TypeScript error format: src/file.ts(12,5): error TS2304: Cannot find name 'foo'.
|
|
7
|
+
const TS_ERROR_PATTERN = /^(.+?)\((\d+),(\d+)\):\s*(error|warning)\s+(TS\d+):\s*(.+)$/;
|
|
8
|
+
// Alternative format: src/file.ts:12:5 - error TS2304: Cannot find name 'foo'.
|
|
9
|
+
const TS_ERROR_ALT_PATTERN = /^(.+?):(\d+):(\d+)\s*-\s*(error|warning)\s+(TS\d+):\s*(.+)$/;
|
|
10
|
+
// Build summary pattern
|
|
11
|
+
const BUILD_SUMMARY_PATTERN = /Found (\d+) errors?/;
|
|
12
|
+
/**
|
|
13
|
+
* Generate suggestion based on error code
|
|
14
|
+
*/
|
|
15
|
+
function getSuggestion(code, message) {
|
|
16
|
+
switch (code) {
|
|
17
|
+
case "TS2304": {
|
|
18
|
+
const nameMatch = message.match(/Cannot find name '(\w+)'/);
|
|
19
|
+
if (nameMatch?.[1]) {
|
|
20
|
+
return `Check if '${nameMatch[1]}' needs to be imported or declared.`;
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
case "TS2339": {
|
|
25
|
+
const propMatch = message.match(/Property '(\w+)' does not exist on type '(.+)'/);
|
|
26
|
+
if (propMatch?.[1] && propMatch[2]) {
|
|
27
|
+
return `Property '${propMatch[1]}' may have been renamed or removed from type '${propMatch[2]}'.`;
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case "TS2345":
|
|
32
|
+
return "Check the function signature and ensure argument types match.";
|
|
33
|
+
case "TS2322":
|
|
34
|
+
return "Verify the types are compatible or add explicit type casting.";
|
|
35
|
+
case "TS7006":
|
|
36
|
+
return "Add explicit type annotation to the parameter.";
|
|
37
|
+
case "TS2307": {
|
|
38
|
+
const moduleMatch = message.match(/Cannot find module '(.+)'/);
|
|
39
|
+
if (moduleMatch?.[1]) {
|
|
40
|
+
return `Install the module with: npm install ${moduleMatch[1].replace(/^@types\//, "")}`;
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case "TS1005":
|
|
45
|
+
return "Check for syntax errors like missing brackets, commas, or semicolons.";
|
|
46
|
+
case "TS2551":
|
|
47
|
+
return "Check the suggested name in the error message.";
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create error signature for grouping
|
|
53
|
+
*/
|
|
54
|
+
function createSignature(code, message) {
|
|
55
|
+
const normalizedMessage = message
|
|
56
|
+
.replace(/'[^']+'/g, "'X'")
|
|
57
|
+
.replace(/\d+/g, "N")
|
|
58
|
+
.replace(/\s+/g, " ")
|
|
59
|
+
.trim();
|
|
60
|
+
return `${code}:${normalizedMessage}`;
|
|
61
|
+
}
|
|
62
|
+
export const typescriptParser = {
|
|
63
|
+
name: "typescript",
|
|
64
|
+
supportedTools: ["tsc"],
|
|
65
|
+
canParse(output) {
|
|
66
|
+
return (TS_ERROR_PATTERN.test(output) ||
|
|
67
|
+
TS_ERROR_ALT_PATTERN.test(output) ||
|
|
68
|
+
output.includes("error TS") ||
|
|
69
|
+
output.includes("warning TS") ||
|
|
70
|
+
BUILD_SUMMARY_PATTERN.test(output));
|
|
71
|
+
},
|
|
72
|
+
parse(output) {
|
|
73
|
+
const errors = [];
|
|
74
|
+
const lines = output.split("\n");
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
const trimmed = line.trim();
|
|
77
|
+
if (!trimmed)
|
|
78
|
+
continue;
|
|
79
|
+
// Try main pattern
|
|
80
|
+
let match = trimmed.match(TS_ERROR_PATTERN);
|
|
81
|
+
if (!match) {
|
|
82
|
+
match = trimmed.match(TS_ERROR_ALT_PATTERN);
|
|
83
|
+
}
|
|
84
|
+
if (match) {
|
|
85
|
+
const file = match[1] ?? "unknown";
|
|
86
|
+
const lineNum = match[2] ?? "0";
|
|
87
|
+
const colNum = match[3] ?? "0";
|
|
88
|
+
const severityStr = match[4] ?? "error";
|
|
89
|
+
const code = match[5] ?? "TS0000";
|
|
90
|
+
const message = match[6] ?? "Unknown error";
|
|
91
|
+
const severity = severityStr === "warning" ? "warning" : "error";
|
|
92
|
+
errors.push({
|
|
93
|
+
signature: createSignature(code, message),
|
|
94
|
+
code,
|
|
95
|
+
message,
|
|
96
|
+
file: file.trim(),
|
|
97
|
+
line: parseInt(lineNum, 10),
|
|
98
|
+
column: parseInt(colNum, 10),
|
|
99
|
+
severity,
|
|
100
|
+
raw: trimmed,
|
|
101
|
+
context: getSuggestion(code, message),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return errors;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the automatic tool chains for different content types.
|
|
5
|
+
* Each pipeline is an ordered list of tool names to execute sequentially.
|
|
6
|
+
*/
|
|
7
|
+
import type { ContentType } from "../compressors/types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Extended content type for pipeline detection
|
|
10
|
+
*/
|
|
11
|
+
export type PipelineContentType = ContentType | "build" | "diff";
|
|
12
|
+
/**
|
|
13
|
+
* Pipeline definition with metadata
|
|
14
|
+
*/
|
|
15
|
+
export interface PipelineDefinition {
|
|
16
|
+
/** Ordered list of tool names to execute */
|
|
17
|
+
tools: string[];
|
|
18
|
+
/** Human-readable description */
|
|
19
|
+
description: string;
|
|
20
|
+
/** Expected token savings range */
|
|
21
|
+
expectedSavings: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Pipeline definitions by content type
|
|
25
|
+
*
|
|
26
|
+
* Each pipeline chains tools that work well together:
|
|
27
|
+
* - First tool does initial processing
|
|
28
|
+
* - Subsequent tools refine the output
|
|
29
|
+
* - Order matters: earlier tools prepare data for later ones
|
|
30
|
+
*/
|
|
31
|
+
export declare const PIPELINE_DEFINITIONS: Record<PipelineContentType, PipelineDefinition>;
|
|
32
|
+
/**
|
|
33
|
+
* Detect extended content type for pipeline selection
|
|
34
|
+
*
|
|
35
|
+
* Uses a scoring-based approach to handle content that might match multiple types.
|
|
36
|
+
* For example, server logs with errors should be detected as "logs" not "build".
|
|
37
|
+
*/
|
|
38
|
+
export declare function detectPipelineContentType(content: string): PipelineContentType;
|
|
39
|
+
/**
|
|
40
|
+
* Get the pipeline definition for a content type
|
|
41
|
+
*/
|
|
42
|
+
export declare function getPipelineForType(type: PipelineContentType): PipelineDefinition;
|
|
43
|
+
/**
|
|
44
|
+
* List all available pipeline types
|
|
45
|
+
*/
|
|
46
|
+
export declare function getAvailablePipelines(): Array<{
|
|
47
|
+
type: PipelineContentType;
|
|
48
|
+
definition: PipelineDefinition;
|
|
49
|
+
}>;
|
|
50
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/pipelines/definitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAwEhF,CAAC;AAoEF;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAkD9E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,GAAG,kBAAkB,CAEhF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,KAAK,CAAC;IAC7C,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,kBAAkB,CAAC;CAChC,CAAC,CAKD"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the automatic tool chains for different content types.
|
|
5
|
+
* Each pipeline is an ordered list of tool names to execute sequentially.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Pipeline definitions by content type
|
|
9
|
+
*
|
|
10
|
+
* Each pipeline chains tools that work well together:
|
|
11
|
+
* - First tool does initial processing
|
|
12
|
+
* - Subsequent tools refine the output
|
|
13
|
+
* - Order matters: earlier tools prepare data for later ones
|
|
14
|
+
*/
|
|
15
|
+
export const PIPELINE_DEFINITIONS = {
|
|
16
|
+
/**
|
|
17
|
+
* Build output (npm, tsc, webpack, etc.)
|
|
18
|
+
* analyze-build-output parses and groups errors
|
|
19
|
+
* deduplicate-errors removes repeated similar errors
|
|
20
|
+
*/
|
|
21
|
+
build: {
|
|
22
|
+
tools: ["analyze_build_output", "deduplicate_errors"],
|
|
23
|
+
description: "Parse build errors, then deduplicate similar messages",
|
|
24
|
+
expectedSavings: "90-98%",
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Log files (server, application, test output)
|
|
28
|
+
* summarize-logs extracts key information and groups patterns
|
|
29
|
+
*/
|
|
30
|
+
logs: {
|
|
31
|
+
tools: ["summarize_logs"],
|
|
32
|
+
description: "Summarize log patterns and extract key events",
|
|
33
|
+
expectedSavings: "80-90%",
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Stack traces and error dumps
|
|
37
|
+
* deduplicate-errors groups similar traces
|
|
38
|
+
* semantic-compress extracts most important parts
|
|
39
|
+
*/
|
|
40
|
+
stacktrace: {
|
|
41
|
+
tools: ["deduplicate_errors", "semantic_compress"],
|
|
42
|
+
description: "Group similar errors, then extract important content",
|
|
43
|
+
expectedSavings: "70-85%",
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Git diffs
|
|
47
|
+
* diff-compress with auto-selected strategy
|
|
48
|
+
*/
|
|
49
|
+
diff: {
|
|
50
|
+
tools: ["diff_compress"],
|
|
51
|
+
description: "Compress git diff output",
|
|
52
|
+
expectedSavings: "50-95%",
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Configuration files (JSON, YAML, TOML)
|
|
56
|
+
* compress-context handles structured data
|
|
57
|
+
*/
|
|
58
|
+
config: {
|
|
59
|
+
tools: ["compress_context"],
|
|
60
|
+
description: "Compress configuration data",
|
|
61
|
+
expectedSavings: "30-60%",
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Source code
|
|
65
|
+
* semantic-compress extracts important code sections
|
|
66
|
+
*/
|
|
67
|
+
code: {
|
|
68
|
+
tools: ["semantic_compress"],
|
|
69
|
+
description: "Extract important code sections",
|
|
70
|
+
expectedSavings: "40-60%",
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Generic content (fallback)
|
|
74
|
+
* semantic-compress using TF-IDF scoring
|
|
75
|
+
*/
|
|
76
|
+
generic: {
|
|
77
|
+
tools: ["semantic_compress"],
|
|
78
|
+
description: "Apply semantic compression",
|
|
79
|
+
expectedSavings: "40-60%",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Detection patterns for extended content types
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* Log patterns - used for scoring log-like content
|
|
87
|
+
* These patterns match individual lines, not the whole content
|
|
88
|
+
*/
|
|
89
|
+
const LOG_LINE_PATTERNS = [
|
|
90
|
+
/^\[\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}/, // [2025-12-23 10:15:23]
|
|
91
|
+
/^\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}/, // 2025-12-23 10:15:23
|
|
92
|
+
/^\[\w+\]\s+(INFO|WARN|WARNING|ERROR|DEBUG|TRACE|FATAL)[\s:]/i, // [tag] INFO:
|
|
93
|
+
/^(INFO|WARN|WARNING|ERROR|DEBUG|TRACE|FATAL)[\s:\[]/i, // INFO: at start
|
|
94
|
+
/^\d{2}:\d{2}:\d{2}[.,]\d{3}\s+(INFO|WARN|ERROR|DEBUG)/i, // 10:15:23.456 INFO
|
|
95
|
+
/^time="[^"]+"\s+level=/, // logrus style
|
|
96
|
+
/^{"(level|time|timestamp|msg)":/, // JSON logs
|
|
97
|
+
/^\[[A-Z]+\]\s*\d{4}-\d{2}-\d{2}/, // [INFO] 2025-12-23
|
|
98
|
+
/^\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}/, // syslog: Dec 23 10:15:23
|
|
99
|
+
/^\w{3}\s{1,2}\d{1,2}\s+\d{2}:\d{2}:\d{2}/, // syslog with padding: Dec 3 10:15:23
|
|
100
|
+
/^<\d+>\w{3}\s+\d{1,2}/, // syslog with priority: <134>Dec 23
|
|
101
|
+
/^<\d+>\d/, // syslog priority with timestamp
|
|
102
|
+
/\|\s*(INFO|WARN|ERROR|DEBUG|TRACE)\s*\|/i, // | INFO | format
|
|
103
|
+
/\s(INFO|WARN|WARNING|ERROR|DEBUG|TRACE|FATAL):\s/i, // embedded log level: "app: ERROR: msg"
|
|
104
|
+
/^\S+\s+\S+\[\d+\]:/, // daemon format: app[1234]:
|
|
105
|
+
];
|
|
106
|
+
/**
|
|
107
|
+
* Build error patterns - specific error formats from compilers/bundlers
|
|
108
|
+
* These are very specific to build tools, not general error messages
|
|
109
|
+
*/
|
|
110
|
+
const BUILD_LINE_PATTERNS = [
|
|
111
|
+
/error TS\d+:/i, // TypeScript: error TS2304
|
|
112
|
+
/error\[E\d+\]:/i, // Rust: error[E0425]
|
|
113
|
+
/:\d+:\d+:\s*error:/i, // GCC/Clang: file:10:5: error:
|
|
114
|
+
/\(\d+,\d+\):\s*error/i, // C#/TS: file(10,5): error
|
|
115
|
+
/npm ERR!/i, // npm specific
|
|
116
|
+
/ENOENT:|EACCES:|EPERM:/i, // Node.js errors
|
|
117
|
+
/Module not found.*Can't resolve/i, // Webpack
|
|
118
|
+
/SyntaxError:.*unexpected token/i, // Parse errors
|
|
119
|
+
/ModuleNotFoundError: No module named/i, // Python
|
|
120
|
+
/error: aborting due to/i, // Rust
|
|
121
|
+
/FAILURE: Build failed/i, // Gradle
|
|
122
|
+
/BUILD FAILED/i, // Ant/Maven
|
|
123
|
+
/error CS\d+:/i, // C# compiler
|
|
124
|
+
];
|
|
125
|
+
const DIFF_PATTERNS = [
|
|
126
|
+
/^diff --git/m, // Git diff header
|
|
127
|
+
/^@@\s*-\d+,?\d*\s*\+\d+,?\d*\s*@@/m, // Unified diff hunk
|
|
128
|
+
/^---\s+a\//m, // Git diff file marker
|
|
129
|
+
/^\+\+\+\s+b\//m, // Git diff file marker
|
|
130
|
+
];
|
|
131
|
+
/**
|
|
132
|
+
* Count how many lines match any of the given patterns
|
|
133
|
+
*/
|
|
134
|
+
function countMatchingLines(lines, patterns) {
|
|
135
|
+
let count = 0;
|
|
136
|
+
for (const line of lines) {
|
|
137
|
+
if (patterns.some((p) => p.test(line))) {
|
|
138
|
+
count++;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return count;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Detect extended content type for pipeline selection
|
|
145
|
+
*
|
|
146
|
+
* Uses a scoring-based approach to handle content that might match multiple types.
|
|
147
|
+
* For example, server logs with errors should be detected as "logs" not "build".
|
|
148
|
+
*/
|
|
149
|
+
export function detectPipelineContentType(content) {
|
|
150
|
+
// Check for diff first (very specific pattern, no ambiguity)
|
|
151
|
+
if (DIFF_PATTERNS.some((p) => p.test(content))) {
|
|
152
|
+
return "diff";
|
|
153
|
+
}
|
|
154
|
+
// Split into lines for scoring
|
|
155
|
+
const lines = content.split("\n").filter((line) => line.trim().length > 0);
|
|
156
|
+
if (lines.length === 0) {
|
|
157
|
+
return "generic";
|
|
158
|
+
}
|
|
159
|
+
// Count matches for each type
|
|
160
|
+
const logMatches = countMatchingLines(lines, LOG_LINE_PATTERNS);
|
|
161
|
+
const buildMatches = countMatchingLines(lines, BUILD_LINE_PATTERNS);
|
|
162
|
+
// Calculate percentages
|
|
163
|
+
const logPercent = logMatches / lines.length;
|
|
164
|
+
const buildPercent = buildMatches / lines.length;
|
|
165
|
+
// If we have significant log patterns (>10% of lines), prefer logs
|
|
166
|
+
// This handles the case where logs contain some error messages
|
|
167
|
+
if (logPercent >= 0.1 && logMatches >= 2) {
|
|
168
|
+
// Even if there are some build-like patterns, if log patterns are dominant, it's logs
|
|
169
|
+
if (logMatches >= buildMatches || logPercent >= 0.2) {
|
|
170
|
+
return "logs";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Strong build signal: specific compiler errors (even a few are significant)
|
|
174
|
+
if (buildMatches >= 1 && buildPercent >= 0.05) {
|
|
175
|
+
// Make sure it's not actually logs with some errors
|
|
176
|
+
// Build output typically has concentrated errors, not spread throughout
|
|
177
|
+
if (buildMatches > logMatches || logPercent < 0.1) {
|
|
178
|
+
return "build";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Fallback: if we have any log patterns, treat as logs
|
|
182
|
+
if (logMatches > 0) {
|
|
183
|
+
return "logs";
|
|
184
|
+
}
|
|
185
|
+
// If we have build patterns but didn't trigger above, still treat as build
|
|
186
|
+
if (buildMatches > 0) {
|
|
187
|
+
return "build";
|
|
188
|
+
}
|
|
189
|
+
// Fall back to generic
|
|
190
|
+
return "generic";
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get the pipeline definition for a content type
|
|
194
|
+
*/
|
|
195
|
+
export function getPipelineForType(type) {
|
|
196
|
+
return PIPELINE_DEFINITIONS[type] ?? PIPELINE_DEFINITIONS.generic;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* List all available pipeline types
|
|
200
|
+
*/
|
|
201
|
+
export function getAvailablePipelines() {
|
|
202
|
+
return Object.entries(PIPELINE_DEFINITIONS).map(([type, definition]) => ({
|
|
203
|
+
type: type,
|
|
204
|
+
definition,
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes user code in a sandboxed environment with ctxopt SDK.
|
|
5
|
+
* Uses Function constructor with restricted scope for isolation.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExecutionContext, ExecutionResult } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Execute code in sandbox
|
|
10
|
+
*/
|
|
11
|
+
export declare function executeSandbox(code: string, context: ExecutionContext): Promise<ExecutionResult>;
|
|
12
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/sandbox/executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0BH,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAIhB,MAAM,YAAY,CAAC;AAmHpB;;GAEG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CA6E1B"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes user code in a sandboxed environment with ctxopt SDK.
|
|
5
|
+
* Uses Function constructor with restricted scope for isolation.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
import { compressAuto, compressLogs, compressDiff, compressSemantic, codeParse, codeExtract, codeSkeleton, countTokens, detectType, detectLanguage, createFilesAPI, createGitAPI, createSearchAPI, createAnalyzeAPI, createPipelineAPI, createMultifileAPI, createConversationAPI, } from "./sdk/index.js";
|
|
10
|
+
import { analyzeCode, sanitizeError } from "./security/index.js";
|
|
11
|
+
import { validatePath, validateGlobPattern } from "./security/path-validator.js";
|
|
12
|
+
/**
|
|
13
|
+
* Create host callbacks for file operations
|
|
14
|
+
*/
|
|
15
|
+
function createHostCallbacks(workingDir) {
|
|
16
|
+
return {
|
|
17
|
+
readFile(filePath) {
|
|
18
|
+
const validation = validatePath(filePath, workingDir);
|
|
19
|
+
if (!validation.safe) {
|
|
20
|
+
throw new Error(validation.error || "Invalid path");
|
|
21
|
+
}
|
|
22
|
+
return fs.readFileSync(validation.resolvedPath, "utf-8");
|
|
23
|
+
},
|
|
24
|
+
fileExists(filePath) {
|
|
25
|
+
const validation = validatePath(filePath, workingDir);
|
|
26
|
+
if (!validation.safe) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
fs.accessSync(validation.resolvedPath);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
glob(pattern) {
|
|
38
|
+
const validation = validateGlobPattern(pattern, workingDir);
|
|
39
|
+
if (!validation.safe) {
|
|
40
|
+
throw new Error(validation.error || "Invalid glob pattern");
|
|
41
|
+
}
|
|
42
|
+
// Synchronous glob using fs
|
|
43
|
+
const results = [];
|
|
44
|
+
const searchDir = path.dirname(validation.resolvedPath);
|
|
45
|
+
const basePattern = path.basename(pattern);
|
|
46
|
+
function walkDir(dir, relativePath = "") {
|
|
47
|
+
try {
|
|
48
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const fullPath = path.join(dir, entry.name);
|
|
51
|
+
const relPath = path.join(relativePath, entry.name);
|
|
52
|
+
if (entry.isDirectory()) {
|
|
53
|
+
if (pattern.includes("**")) {
|
|
54
|
+
walkDir(fullPath, relPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (entry.isFile()) {
|
|
58
|
+
// Simple glob matching
|
|
59
|
+
if (matchesPattern(entry.name, basePattern)) {
|
|
60
|
+
results.push(relPath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Skip directories we can't read
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
walkDir(workingDir);
|
|
70
|
+
return results.slice(0, 100); // Limit results
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Simple glob pattern matching
|
|
76
|
+
*/
|
|
77
|
+
function matchesPattern(filename, pattern) {
|
|
78
|
+
// Handle common patterns
|
|
79
|
+
if (pattern === "*")
|
|
80
|
+
return true;
|
|
81
|
+
if (pattern.startsWith("*.")) {
|
|
82
|
+
const ext = pattern.slice(1);
|
|
83
|
+
return filename.endsWith(ext);
|
|
84
|
+
}
|
|
85
|
+
return filename === pattern;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create the SDK object for sandbox
|
|
89
|
+
*/
|
|
90
|
+
function createSDK(workingDir) {
|
|
91
|
+
const callbacks = createHostCallbacks(workingDir);
|
|
92
|
+
const filesAPI = createFilesAPI(callbacks);
|
|
93
|
+
return {
|
|
94
|
+
compress: {
|
|
95
|
+
auto: compressAuto,
|
|
96
|
+
logs: compressLogs,
|
|
97
|
+
diff: compressDiff,
|
|
98
|
+
semantic: compressSemantic,
|
|
99
|
+
},
|
|
100
|
+
code: {
|
|
101
|
+
parse: codeParse,
|
|
102
|
+
extract: codeExtract,
|
|
103
|
+
skeleton: codeSkeleton,
|
|
104
|
+
},
|
|
105
|
+
files: filesAPI,
|
|
106
|
+
utils: {
|
|
107
|
+
countTokens,
|
|
108
|
+
detectType,
|
|
109
|
+
detectLanguage,
|
|
110
|
+
},
|
|
111
|
+
git: createGitAPI(workingDir),
|
|
112
|
+
search: createSearchAPI(workingDir, callbacks),
|
|
113
|
+
analyze: createAnalyzeAPI(workingDir, callbacks),
|
|
114
|
+
pipeline: createPipelineAPI(workingDir, callbacks),
|
|
115
|
+
multifile: createMultifileAPI(workingDir, callbacks),
|
|
116
|
+
conversation: createConversationAPI(workingDir, callbacks),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Execute code in sandbox
|
|
121
|
+
*/
|
|
122
|
+
export async function executeSandbox(code, context) {
|
|
123
|
+
const startTime = Date.now();
|
|
124
|
+
// Security: analyze code before execution
|
|
125
|
+
const analysis = analyzeCode(code);
|
|
126
|
+
if (!analysis.safe) {
|
|
127
|
+
return {
|
|
128
|
+
success: false,
|
|
129
|
+
output: null,
|
|
130
|
+
error: `Blocked patterns: ${analysis.blockedPatterns.join(", ")}`,
|
|
131
|
+
stats: {
|
|
132
|
+
executionTimeMs: Date.now() - startTime,
|
|
133
|
+
tokensUsed: 0,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
// Create SDK
|
|
139
|
+
const ctx = createSDK(context.workingDir);
|
|
140
|
+
// Wrap code in async function
|
|
141
|
+
const wrappedCode = `
|
|
142
|
+
return (async function() {
|
|
143
|
+
${code}
|
|
144
|
+
})();
|
|
145
|
+
`;
|
|
146
|
+
// Create sandboxed function
|
|
147
|
+
// Note: This is not fully isolated, but provides some protection
|
|
148
|
+
const sandboxedFn = new Function("ctx", wrappedCode);
|
|
149
|
+
// Execute with timeout
|
|
150
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
151
|
+
setTimeout(() => reject(new Error("Execution timeout")), context.timeout);
|
|
152
|
+
});
|
|
153
|
+
const result = await Promise.race([sandboxedFn(ctx), timeoutPromise]);
|
|
154
|
+
// Count output tokens
|
|
155
|
+
const outputStr = JSON.stringify(result, null, 2);
|
|
156
|
+
const tokensUsed = countTokens(outputStr);
|
|
157
|
+
// Check output size
|
|
158
|
+
if (tokensUsed > context.maxOutputTokens) {
|
|
159
|
+
// Auto-compress large output
|
|
160
|
+
const compressed = compressAuto(outputStr);
|
|
161
|
+
return {
|
|
162
|
+
success: true,
|
|
163
|
+
output: compressed.compressed,
|
|
164
|
+
stats: {
|
|
165
|
+
executionTimeMs: Date.now() - startTime,
|
|
166
|
+
tokensUsed: compressed.stats.compressed,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
success: true,
|
|
172
|
+
output: result,
|
|
173
|
+
stats: {
|
|
174
|
+
executionTimeMs: Date.now() - startTime,
|
|
175
|
+
tokensUsed,
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
181
|
+
return {
|
|
182
|
+
success: false,
|
|
183
|
+
output: null,
|
|
184
|
+
error: sanitizeError(err, context.workingDir),
|
|
185
|
+
stats: {
|
|
186
|
+
executionTimeMs: Date.now() - startTime,
|
|
187
|
+
tokensUsed: 0,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|