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,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Multi-File Functions
|
|
3
|
+
*
|
|
4
|
+
* Multi-file compression and analysis for sandbox use.
|
|
5
|
+
* Provides cross-file deduplication, skeleton extraction, and chunking.
|
|
6
|
+
*/
|
|
7
|
+
import { detectLanguageFromPath } from "../../utils/language-detector.js";
|
|
8
|
+
import { compressMultiFile, extractSharedElements, createChunks, } from "../../compressors/multifile.js";
|
|
9
|
+
/**
|
|
10
|
+
* Create multi-file API with host callbacks
|
|
11
|
+
*/
|
|
12
|
+
export function createMultifileAPI(workingDir, callbacks) {
|
|
13
|
+
/**
|
|
14
|
+
* Load files from patterns into FileContext array
|
|
15
|
+
*/
|
|
16
|
+
function loadFiles(patterns) {
|
|
17
|
+
const files = [];
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
for (const pattern of patterns) {
|
|
20
|
+
const paths = callbacks.glob(pattern);
|
|
21
|
+
for (const filePath of paths) {
|
|
22
|
+
if (seen.has(filePath))
|
|
23
|
+
continue;
|
|
24
|
+
seen.add(filePath);
|
|
25
|
+
try {
|
|
26
|
+
const content = callbacks.readFile(filePath);
|
|
27
|
+
const language = detectLanguageFromPath(filePath);
|
|
28
|
+
files.push({
|
|
29
|
+
path: filePath,
|
|
30
|
+
content,
|
|
31
|
+
language,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Skip files that can't be read
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return files;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
/**
|
|
43
|
+
* Compress multiple files with cross-file deduplication
|
|
44
|
+
*
|
|
45
|
+
* @param patterns - Glob patterns for files to include
|
|
46
|
+
* @param options - Compression options
|
|
47
|
+
* @returns Compressed result with shared elements and stats
|
|
48
|
+
*/
|
|
49
|
+
compress(patterns, options) {
|
|
50
|
+
const files = loadFiles(patterns);
|
|
51
|
+
if (files.length === 0) {
|
|
52
|
+
return {
|
|
53
|
+
compressed: "// No files found matching patterns",
|
|
54
|
+
filesIncluded: [],
|
|
55
|
+
sharedElements: { imports: [], types: [], constants: [] },
|
|
56
|
+
stats: {
|
|
57
|
+
originalTokens: 0,
|
|
58
|
+
compressedTokens: 0,
|
|
59
|
+
filesProcessed: 0,
|
|
60
|
+
deduplicatedItems: 0,
|
|
61
|
+
reductionPercent: 0,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return compressMultiFile(files, {
|
|
66
|
+
maxTokens: options?.maxTokens || 50000,
|
|
67
|
+
strategy: options?.strategy || "deduplicate",
|
|
68
|
+
preservePatterns: options?.preservePatterns,
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Extract shared elements (imports, types) across files
|
|
73
|
+
*
|
|
74
|
+
* @param patterns - Glob patterns for files to analyze
|
|
75
|
+
* @returns Shared imports, types, and constants
|
|
76
|
+
*/
|
|
77
|
+
extractShared(patterns) {
|
|
78
|
+
const files = loadFiles(patterns);
|
|
79
|
+
return extractSharedElements(files);
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Create chunks from files for incremental processing
|
|
83
|
+
*
|
|
84
|
+
* @param patterns - Glob patterns for files to chunk
|
|
85
|
+
* @param maxTokensPerChunk - Maximum tokens per chunk
|
|
86
|
+
* @returns Array of chunk information
|
|
87
|
+
*/
|
|
88
|
+
chunk(patterns, maxTokensPerChunk) {
|
|
89
|
+
const files = loadFiles(patterns);
|
|
90
|
+
return createChunks(files, maxTokensPerChunk);
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Get dependency-aware skeletons for files
|
|
94
|
+
*
|
|
95
|
+
* @param patterns - Glob patterns for entry point files
|
|
96
|
+
* @param depth - Optional depth limit for dependency traversal
|
|
97
|
+
* @returns Compressed skeleton output
|
|
98
|
+
*/
|
|
99
|
+
skeletons(patterns, depth) {
|
|
100
|
+
const files = loadFiles(patterns);
|
|
101
|
+
if (files.length === 0) {
|
|
102
|
+
return "// No files found matching patterns";
|
|
103
|
+
}
|
|
104
|
+
const result = compressMultiFile(files, {
|
|
105
|
+
strategy: "skeleton",
|
|
106
|
+
dependencyDepth: depth || 2,
|
|
107
|
+
});
|
|
108
|
+
return result.compressed;
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Read multiple files into a combined context
|
|
112
|
+
*
|
|
113
|
+
* @param patterns - Glob patterns for files to read
|
|
114
|
+
* @returns Combined file contents with headers
|
|
115
|
+
*/
|
|
116
|
+
readAll(patterns) {
|
|
117
|
+
const files = loadFiles(patterns);
|
|
118
|
+
if (files.length === 0) {
|
|
119
|
+
return "// No files found matching patterns";
|
|
120
|
+
}
|
|
121
|
+
const parts = [];
|
|
122
|
+
for (const file of files) {
|
|
123
|
+
parts.push(`// === ${file.path} ===`);
|
|
124
|
+
parts.push(file.content);
|
|
125
|
+
parts.push("");
|
|
126
|
+
}
|
|
127
|
+
return parts.join("\n");
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Pipeline Functions
|
|
3
|
+
*
|
|
4
|
+
* Composable pipelines for chaining operations on files and data.
|
|
5
|
+
* Provides declarative data processing with built-in templates.
|
|
6
|
+
*/
|
|
7
|
+
import type { PipelineStep, PipelineResult, CodebaseOverview, SymbolUsage, DependencyAnalysis, HostCallbacks } from "../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Create Pipeline API for sandbox
|
|
10
|
+
*/
|
|
11
|
+
export declare function createPipelineAPI(workingDir: string, callbacks: HostCallbacks): ((steps: PipelineStep[]) => PipelineResult) & {
|
|
12
|
+
codebaseOverview: (dir?: string) => CodebaseOverview;
|
|
13
|
+
findUsages: (symbol: string, glob?: string) => SymbolUsage;
|
|
14
|
+
analyzeDeps: (file: string, depth?: number) => DependencyAnalysis;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/sandbox/sdk/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAElB,aAAa,EACd,MAAM,aAAa,CAAC;AAsIrB;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,YAI5C,YAAY,EAAE,KAAG,cAAc;sBAiH3C,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,gBAAgB;gBACxC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,WAAW;iBAC7C,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,kBAAkB;EA4PpE"}
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Pipeline Functions
|
|
3
|
+
*
|
|
4
|
+
* Composable pipelines for chaining operations on files and data.
|
|
5
|
+
* Provides declarative data processing with built-in templates.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
import { compressAuto, compressSemantic, compressLogs } from "./compress.js";
|
|
10
|
+
import { detectLanguageFromPath } from "../../utils/language-detector.js";
|
|
11
|
+
import { validateGlobPattern } from "../security/path-validator.js";
|
|
12
|
+
const MAX_ITEMS = 1000;
|
|
13
|
+
const CACHE_TTL_GLOB = 2 * 60 * 1000; // 2 minutes for glob results
|
|
14
|
+
const CACHE_TTL_TEMPLATE = 5 * 60 * 1000; // 5 minutes for template methods
|
|
15
|
+
const pipelineCache = new Map();
|
|
16
|
+
function getCached(key) {
|
|
17
|
+
const entry = pipelineCache.get(key);
|
|
18
|
+
if (!entry)
|
|
19
|
+
return null;
|
|
20
|
+
if (Date.now() > entry.expiresAt) {
|
|
21
|
+
pipelineCache.delete(key);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return entry.value;
|
|
25
|
+
}
|
|
26
|
+
function setCached(key, value, ttl) {
|
|
27
|
+
// Limit cache size to prevent memory issues
|
|
28
|
+
if (pipelineCache.size > 100) {
|
|
29
|
+
// Evict oldest entries
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
for (const [k, v] of pipelineCache.entries()) {
|
|
32
|
+
if (v.expiresAt < now || pipelineCache.size > 50) {
|
|
33
|
+
pipelineCache.delete(k);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
pipelineCache.set(key, { value, expiresAt: Date.now() + ttl });
|
|
38
|
+
}
|
|
39
|
+
const MAX_FILE_SIZE = 1024 * 1024; // 1MB
|
|
40
|
+
/**
|
|
41
|
+
* Simple glob pattern matcher with brace expansion support
|
|
42
|
+
*/
|
|
43
|
+
function matchGlob(filepath, pattern) {
|
|
44
|
+
// Handle brace expansion: {a,b,c} -> (a|b|c)
|
|
45
|
+
let regexPattern = pattern
|
|
46
|
+
.replace(/\{([^}]+)\}/g, (_match, group) => {
|
|
47
|
+
const alternatives = group.split(",").map((s) => s.trim());
|
|
48
|
+
return `(${alternatives.join("|")})`;
|
|
49
|
+
});
|
|
50
|
+
// Use placeholders to avoid order-dependent replacement issues
|
|
51
|
+
regexPattern = regexPattern
|
|
52
|
+
.replace(/\*\*\//g, "{{GLOBSTAR_SLASH}}") // **/ -> matches zero or more dirs
|
|
53
|
+
.replace(/\*\*/g, "{{GLOBSTAR}}") // ** -> matches anything
|
|
54
|
+
.replace(/\*/g, "{{STAR}}") // * -> matches within segment
|
|
55
|
+
.replace(/\?/g, "{{QUESTION}}") // ? -> matches single char
|
|
56
|
+
.replace(/\./g, "\\.") // escape dots
|
|
57
|
+
.replace(/{{GLOBSTAR_SLASH}}/g, "(.*/)?") // **/ can match empty or paths
|
|
58
|
+
.replace(/{{GLOBSTAR}}/g, ".*") // ** matches anything
|
|
59
|
+
.replace(/{{STAR}}/g, "[^/]*") // * matches non-slash chars
|
|
60
|
+
.replace(/{{QUESTION}}/g, "."); // ? matches any single char
|
|
61
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
62
|
+
return regex.test(filepath);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Walk directory and find files matching pattern (with caching)
|
|
66
|
+
*/
|
|
67
|
+
function walkDirectory(dir, pattern, maxFiles = MAX_ITEMS) {
|
|
68
|
+
const cacheKey = `pipeline:glob:${dir}:${pattern}:${maxFiles}`;
|
|
69
|
+
// Check cache first
|
|
70
|
+
const cached = getCached(cacheKey);
|
|
71
|
+
if (cached) {
|
|
72
|
+
return cached;
|
|
73
|
+
}
|
|
74
|
+
const results = [];
|
|
75
|
+
function walk(currentDir, relativePath = "") {
|
|
76
|
+
if (results.length >= maxFiles)
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
80
|
+
for (const entry of entries) {
|
|
81
|
+
if (results.length >= maxFiles)
|
|
82
|
+
break;
|
|
83
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
84
|
+
const relPath = path.join(relativePath, entry.name);
|
|
85
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (entry.isDirectory()) {
|
|
89
|
+
walk(fullPath, relPath);
|
|
90
|
+
}
|
|
91
|
+
else if (entry.isFile()) {
|
|
92
|
+
if (matchGlob(relPath, pattern)) {
|
|
93
|
+
results.push(relPath);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Skip directories we can't read
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
walk(dir);
|
|
103
|
+
// Cache the results
|
|
104
|
+
setCached(cacheKey, results, CACHE_TTL_GLOB);
|
|
105
|
+
return results;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Count lines in content
|
|
109
|
+
*/
|
|
110
|
+
function countLines(content) {
|
|
111
|
+
return content.split("\n").length;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create Pipeline API for sandbox
|
|
115
|
+
*/
|
|
116
|
+
export function createPipelineAPI(workingDir, callbacks) {
|
|
117
|
+
/**
|
|
118
|
+
* Execute a pipeline of steps
|
|
119
|
+
*/
|
|
120
|
+
function executePipeline(steps) {
|
|
121
|
+
const startTime = Date.now();
|
|
122
|
+
let data = [];
|
|
123
|
+
let stepsExecuted = 0;
|
|
124
|
+
let itemsProcessed = 0;
|
|
125
|
+
for (const step of steps) {
|
|
126
|
+
stepsExecuted++;
|
|
127
|
+
if ("glob" in step) {
|
|
128
|
+
// Glob step - find files
|
|
129
|
+
const validation = validateGlobPattern(step.glob, workingDir);
|
|
130
|
+
if (!validation.safe) {
|
|
131
|
+
throw new Error(validation.error ?? "Invalid glob pattern");
|
|
132
|
+
}
|
|
133
|
+
data = walkDirectory(workingDir, step.glob);
|
|
134
|
+
itemsProcessed = data.length;
|
|
135
|
+
}
|
|
136
|
+
else if ("filter" in step) {
|
|
137
|
+
// Filter step
|
|
138
|
+
data = data.filter(step.filter);
|
|
139
|
+
itemsProcessed = data.length;
|
|
140
|
+
}
|
|
141
|
+
else if ("read" in step && step.read) {
|
|
142
|
+
// Read step - read file contents
|
|
143
|
+
data = data.map((file) => {
|
|
144
|
+
if (typeof file !== "string")
|
|
145
|
+
return file;
|
|
146
|
+
try {
|
|
147
|
+
const fullPath = path.join(workingDir, file);
|
|
148
|
+
const stats = fs.statSync(fullPath);
|
|
149
|
+
if (stats.size > MAX_FILE_SIZE) {
|
|
150
|
+
return { file, content: null, error: "File too large" };
|
|
151
|
+
}
|
|
152
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
153
|
+
return { file, content };
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
return { file, content: null, error: String(err) };
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
else if ("map" in step) {
|
|
161
|
+
// Map step
|
|
162
|
+
data = data.map(step.map);
|
|
163
|
+
}
|
|
164
|
+
else if ("reduce" in step) {
|
|
165
|
+
// Reduce step
|
|
166
|
+
const result = data.reduce(step.reduce, step.initial);
|
|
167
|
+
data = [result];
|
|
168
|
+
}
|
|
169
|
+
else if ("compress" in step) {
|
|
170
|
+
// Compress step
|
|
171
|
+
const content = JSON.stringify(data, null, 2);
|
|
172
|
+
let compressed;
|
|
173
|
+
if (step.compress === "semantic") {
|
|
174
|
+
const result = compressSemantic(content, step.ratio);
|
|
175
|
+
compressed = result.compressed;
|
|
176
|
+
}
|
|
177
|
+
else if (step.compress === "logs") {
|
|
178
|
+
const result = compressLogs(content);
|
|
179
|
+
compressed = result.summary;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const result = compressAuto(content);
|
|
183
|
+
compressed = result.compressed;
|
|
184
|
+
}
|
|
185
|
+
data = [compressed];
|
|
186
|
+
}
|
|
187
|
+
else if ("limit" in step) {
|
|
188
|
+
// Limit step
|
|
189
|
+
data = data.slice(0, step.limit);
|
|
190
|
+
itemsProcessed = data.length;
|
|
191
|
+
}
|
|
192
|
+
else if ("sort" in step) {
|
|
193
|
+
// Sort step
|
|
194
|
+
const direction = step.sort === "desc" ? -1 : 1;
|
|
195
|
+
const key = step.by;
|
|
196
|
+
data = [...data].sort((a, b) => {
|
|
197
|
+
let valA = key ? a[key] : a;
|
|
198
|
+
let valB = key ? b[key] : b;
|
|
199
|
+
if (typeof valA === "string" && typeof valB === "string") {
|
|
200
|
+
return valA.localeCompare(valB) * direction;
|
|
201
|
+
}
|
|
202
|
+
if (typeof valA === "number" && typeof valB === "number") {
|
|
203
|
+
return (valA - valB) * direction;
|
|
204
|
+
}
|
|
205
|
+
return 0;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else if ("unique" in step) {
|
|
209
|
+
// Unique step
|
|
210
|
+
if (typeof step.unique === "string") {
|
|
211
|
+
const key = step.unique;
|
|
212
|
+
const seen = new Set();
|
|
213
|
+
data = data.filter((item) => {
|
|
214
|
+
const val = item[key];
|
|
215
|
+
if (seen.has(val))
|
|
216
|
+
return false;
|
|
217
|
+
seen.add(val);
|
|
218
|
+
return true;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else if (step.unique) {
|
|
222
|
+
data = [...new Set(data.map((d) => JSON.stringify(d)))].map((s) => JSON.parse(s));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
data,
|
|
228
|
+
stats: {
|
|
229
|
+
stepsExecuted,
|
|
230
|
+
itemsProcessed,
|
|
231
|
+
executionTimeMs: Date.now() - startTime,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
// Add template methods to the pipeline function
|
|
236
|
+
const pipeline = executePipeline;
|
|
237
|
+
/**
|
|
238
|
+
* Get codebase overview with statistics (cached)
|
|
239
|
+
*/
|
|
240
|
+
pipeline.codebaseOverview = (dir) => {
|
|
241
|
+
const targetDir = dir ?? ".";
|
|
242
|
+
const fullPath = path.join(workingDir, targetDir);
|
|
243
|
+
const cacheKey = `pipeline:overview:${fullPath}`;
|
|
244
|
+
// Check cache first
|
|
245
|
+
const cached = getCached(cacheKey);
|
|
246
|
+
if (cached) {
|
|
247
|
+
return cached;
|
|
248
|
+
}
|
|
249
|
+
const files = walkDirectory(fullPath, "**/*.{ts,tsx,js,jsx,py,go,rs,php,swift}");
|
|
250
|
+
const languages = {};
|
|
251
|
+
const fileSizes = [];
|
|
252
|
+
let totalLines = 0;
|
|
253
|
+
for (const file of files) {
|
|
254
|
+
try {
|
|
255
|
+
const filePath = path.join(fullPath, file);
|
|
256
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
257
|
+
const lines = countLines(content);
|
|
258
|
+
const lang = detectLanguageFromPath(file);
|
|
259
|
+
totalLines += lines;
|
|
260
|
+
if (lang !== "unknown") {
|
|
261
|
+
languages[lang] = (languages[lang] ?? 0) + 1;
|
|
262
|
+
}
|
|
263
|
+
fileSizes.push({ path: file, lines });
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// Skip files we can't read
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Sort by lines descending
|
|
270
|
+
fileSizes.sort((a, b) => b.lines - a.lines);
|
|
271
|
+
// Build structure (simplified)
|
|
272
|
+
const structure = {
|
|
273
|
+
path: targetDir,
|
|
274
|
+
type: "directory",
|
|
275
|
+
name: path.basename(targetDir) || "root",
|
|
276
|
+
children: files.slice(0, 20).map((f) => ({
|
|
277
|
+
path: f,
|
|
278
|
+
type: "file",
|
|
279
|
+
name: path.basename(f),
|
|
280
|
+
})),
|
|
281
|
+
};
|
|
282
|
+
const result = {
|
|
283
|
+
totalFiles: files.length,
|
|
284
|
+
totalLines,
|
|
285
|
+
languages,
|
|
286
|
+
largestFiles: fileSizes.slice(0, 10),
|
|
287
|
+
structure,
|
|
288
|
+
};
|
|
289
|
+
// Cache the result
|
|
290
|
+
setCached(cacheKey, result, CACHE_TTL_TEMPLATE);
|
|
291
|
+
return result;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Find all usages of a symbol (cached)
|
|
295
|
+
*/
|
|
296
|
+
pipeline.findUsages = (symbol, glob) => {
|
|
297
|
+
const pattern = glob ?? "**/*.{ts,tsx,js,jsx,py,go,rs}";
|
|
298
|
+
const cacheKey = `pipeline:usages:${symbol}:${pattern}`;
|
|
299
|
+
// Check cache first
|
|
300
|
+
const cached = getCached(cacheKey);
|
|
301
|
+
if (cached) {
|
|
302
|
+
return cached;
|
|
303
|
+
}
|
|
304
|
+
const files = walkDirectory(workingDir, pattern);
|
|
305
|
+
const definitions = [];
|
|
306
|
+
const usages = [];
|
|
307
|
+
// Definition patterns
|
|
308
|
+
const defPatterns = [
|
|
309
|
+
new RegExp(`(?:function|class|const|let|var|interface|type)\\s+${escapeRegex(symbol)}\\b`),
|
|
310
|
+
new RegExp(`${escapeRegex(symbol)}\\s*[=:]\\s*(?:function|\\(|async)`),
|
|
311
|
+
];
|
|
312
|
+
// Usage pattern
|
|
313
|
+
const usagePattern = new RegExp(`\\b${escapeRegex(symbol)}\\b`, "g");
|
|
314
|
+
for (const file of files) {
|
|
315
|
+
try {
|
|
316
|
+
const filePath = path.join(workingDir, file);
|
|
317
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
318
|
+
const lines = content.split("\n");
|
|
319
|
+
for (let i = 0; i < lines.length; i++) {
|
|
320
|
+
const line = lines[i] ?? "";
|
|
321
|
+
const lineNum = i + 1;
|
|
322
|
+
// Check for definitions
|
|
323
|
+
let isDef = false;
|
|
324
|
+
for (const defPattern of defPatterns) {
|
|
325
|
+
if (defPattern.test(line)) {
|
|
326
|
+
definitions.push({ file, line: lineNum });
|
|
327
|
+
isDef = true;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// Check for usages (excluding definitions)
|
|
332
|
+
if (!isDef && usagePattern.test(line)) {
|
|
333
|
+
usages.push({
|
|
334
|
+
file,
|
|
335
|
+
line: lineNum,
|
|
336
|
+
context: line.trim().slice(0, 100),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
// Reset regex lastIndex
|
|
340
|
+
usagePattern.lastIndex = 0;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
// Skip files we can't read
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
const result = {
|
|
348
|
+
symbol,
|
|
349
|
+
definitions,
|
|
350
|
+
usages,
|
|
351
|
+
totalReferences: definitions.length + usages.length,
|
|
352
|
+
};
|
|
353
|
+
// Cache the result
|
|
354
|
+
setCached(cacheKey, result, CACHE_TTL_TEMPLATE);
|
|
355
|
+
return result;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Analyze dependencies transitively (cached)
|
|
359
|
+
*/
|
|
360
|
+
pipeline.analyzeDeps = (file, depth) => {
|
|
361
|
+
const maxDepth = Math.min(depth ?? 3, 5);
|
|
362
|
+
const cacheKey = `pipeline:deps:${file}:${maxDepth}`;
|
|
363
|
+
// Check cache first
|
|
364
|
+
const cached = getCached(cacheKey);
|
|
365
|
+
if (cached) {
|
|
366
|
+
return cached;
|
|
367
|
+
}
|
|
368
|
+
const directDeps = [];
|
|
369
|
+
const transitiveDeps = [];
|
|
370
|
+
const externalPackages = [];
|
|
371
|
+
const circularDeps = [];
|
|
372
|
+
const visited = new Set();
|
|
373
|
+
function analyzeFile(filePath, currentDepth) {
|
|
374
|
+
if (currentDepth > maxDepth || visited.has(filePath)) {
|
|
375
|
+
if (visited.has(filePath) && currentDepth > 0) {
|
|
376
|
+
circularDeps.push(filePath);
|
|
377
|
+
}
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
visited.add(filePath);
|
|
381
|
+
try {
|
|
382
|
+
const fullPath = path.join(workingDir, filePath);
|
|
383
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
384
|
+
// Parse imports
|
|
385
|
+
const importRegex = /import\s+(?:.*?\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
386
|
+
let match;
|
|
387
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
388
|
+
const importSource = match[1] ?? "";
|
|
389
|
+
if (importSource.startsWith(".")) {
|
|
390
|
+
// Relative import - resolve path
|
|
391
|
+
const currentDir = path.dirname(fullPath);
|
|
392
|
+
let resolved = path.resolve(currentDir, importSource);
|
|
393
|
+
// Try with extensions
|
|
394
|
+
const extensions = [".ts", ".tsx", ".js", ".jsx", ""];
|
|
395
|
+
for (const ext of extensions) {
|
|
396
|
+
const withExt = resolved + ext;
|
|
397
|
+
if (fs.existsSync(withExt)) {
|
|
398
|
+
resolved = withExt;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
// Try index file
|
|
402
|
+
const indexPath = path.join(resolved, `index${ext || ".ts"}`);
|
|
403
|
+
if (fs.existsSync(indexPath)) {
|
|
404
|
+
resolved = indexPath;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
const relativePath = path.relative(workingDir, resolved);
|
|
409
|
+
if (currentDepth === 0) {
|
|
410
|
+
if (!directDeps.includes(relativePath)) {
|
|
411
|
+
directDeps.push(relativePath);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
if (!transitiveDeps.includes(relativePath) && !directDeps.includes(relativePath)) {
|
|
416
|
+
transitiveDeps.push(relativePath);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// Recurse
|
|
420
|
+
analyzeFile(relativePath, currentDepth + 1);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
// External package
|
|
424
|
+
const pkgName = importSource.split("/")[0] ?? importSource;
|
|
425
|
+
if (!externalPackages.includes(pkgName)) {
|
|
426
|
+
externalPackages.push(pkgName);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
catch {
|
|
432
|
+
// Skip files we can't read
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
analyzeFile(file, 0);
|
|
436
|
+
const result = {
|
|
437
|
+
file,
|
|
438
|
+
directDeps,
|
|
439
|
+
transitiveDeps,
|
|
440
|
+
externalPackages,
|
|
441
|
+
circularDeps: [...new Set(circularDeps)],
|
|
442
|
+
};
|
|
443
|
+
// Cache the result
|
|
444
|
+
setCached(cacheKey, result, CACHE_TTL_TEMPLATE);
|
|
445
|
+
return result;
|
|
446
|
+
};
|
|
447
|
+
return pipeline;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Escape special regex characters
|
|
451
|
+
*/
|
|
452
|
+
function escapeRegex(str) {
|
|
453
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
454
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.test.d.ts","sourceRoot":"","sources":["../../../src/sandbox/sdk/pipeline.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|