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,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline SDK Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for ctx.pipeline.* functions.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect, beforeAll } from "vitest";
|
|
7
|
+
import { createPipelineAPI } from "./pipeline.js";
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
// Get the monorepo root
|
|
11
|
+
function getProjectRoot() {
|
|
12
|
+
let dir = __dirname;
|
|
13
|
+
while (dir !== "/" && !fs.existsSync(path.join(dir, "package.json"))) {
|
|
14
|
+
dir = path.dirname(dir);
|
|
15
|
+
}
|
|
16
|
+
return dir;
|
|
17
|
+
}
|
|
18
|
+
const projectRoot = getProjectRoot();
|
|
19
|
+
// Create mock callbacks
|
|
20
|
+
function createMockCallbacks(workingDir) {
|
|
21
|
+
return {
|
|
22
|
+
readFile(filePath) {
|
|
23
|
+
const fullPath = path.isAbsolute(filePath)
|
|
24
|
+
? filePath
|
|
25
|
+
: path.join(workingDir, filePath);
|
|
26
|
+
return fs.readFileSync(fullPath, "utf-8");
|
|
27
|
+
},
|
|
28
|
+
fileExists(filePath) {
|
|
29
|
+
const fullPath = path.isAbsolute(filePath)
|
|
30
|
+
? filePath
|
|
31
|
+
: path.join(workingDir, filePath);
|
|
32
|
+
try {
|
|
33
|
+
fs.accessSync(fullPath);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
glob() {
|
|
41
|
+
return [];
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
describe("Pipeline SDK", () => {
|
|
46
|
+
let pipeline;
|
|
47
|
+
beforeAll(() => {
|
|
48
|
+
const callbacks = createMockCallbacks(projectRoot);
|
|
49
|
+
pipeline = createPipelineAPI(projectRoot, callbacks);
|
|
50
|
+
});
|
|
51
|
+
describe("executePipeline", () => {
|
|
52
|
+
it("should execute glob step", () => {
|
|
53
|
+
const result = pipeline([{ glob: "**/*.ts" }]);
|
|
54
|
+
expect(result).toBeDefined();
|
|
55
|
+
expect(result.data).toBeDefined();
|
|
56
|
+
expect(Array.isArray(result.data)).toBe(true);
|
|
57
|
+
expect(result.stats.stepsExecuted).toBe(1);
|
|
58
|
+
});
|
|
59
|
+
it("should execute filter step", () => {
|
|
60
|
+
const result = pipeline([
|
|
61
|
+
{ glob: "**/*.ts" },
|
|
62
|
+
{ filter: (f) => String(f).includes("test") },
|
|
63
|
+
]);
|
|
64
|
+
expect(result.stats.stepsExecuted).toBe(2);
|
|
65
|
+
const files = result.data;
|
|
66
|
+
expect(files.every((f) => f.includes("test"))).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
it("should execute limit step", () => {
|
|
69
|
+
const result = pipeline([{ glob: "**/*.ts" }, { limit: 5 }]);
|
|
70
|
+
expect(result.stats.stepsExecuted).toBe(2);
|
|
71
|
+
const files = result.data;
|
|
72
|
+
expect(files.length).toBeLessThanOrEqual(5);
|
|
73
|
+
});
|
|
74
|
+
it("should execute sort step", () => {
|
|
75
|
+
const result = pipeline([
|
|
76
|
+
{ glob: "**/*.ts" },
|
|
77
|
+
{ limit: 10 },
|
|
78
|
+
{ sort: "asc" },
|
|
79
|
+
]);
|
|
80
|
+
expect(result.stats.stepsExecuted).toBe(3);
|
|
81
|
+
const files = result.data;
|
|
82
|
+
// Verify sorted ascending
|
|
83
|
+
for (let i = 1; i < files.length; i++) {
|
|
84
|
+
expect(files[i] >= files[i - 1]).toBe(true);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
it("should execute unique step", () => {
|
|
88
|
+
const result = pipeline([
|
|
89
|
+
{ glob: "**/*.ts" },
|
|
90
|
+
{ unique: true },
|
|
91
|
+
]);
|
|
92
|
+
expect(result.stats.stepsExecuted).toBe(2);
|
|
93
|
+
const files = result.data;
|
|
94
|
+
const uniqueSet = new Set(files);
|
|
95
|
+
expect(files.length).toBe(uniqueSet.size);
|
|
96
|
+
});
|
|
97
|
+
it("should return stats with execution time", () => {
|
|
98
|
+
const result = pipeline([{ glob: "**/*.ts" }, { limit: 5 }]);
|
|
99
|
+
expect(result.stats).toBeDefined();
|
|
100
|
+
expect(typeof result.stats.executionTimeMs).toBe("number");
|
|
101
|
+
expect(result.stats.executionTimeMs).toBeGreaterThanOrEqual(0);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe("codebaseOverview", () => {
|
|
105
|
+
it("should return CodebaseOverview structure", () => {
|
|
106
|
+
const result = pipeline.codebaseOverview("src/sandbox/sdk");
|
|
107
|
+
expect(result).toBeDefined();
|
|
108
|
+
expect(typeof result.totalFiles).toBe("number");
|
|
109
|
+
expect(typeof result.totalLines).toBe("number");
|
|
110
|
+
expect(result.languages).toBeDefined();
|
|
111
|
+
expect(Array.isArray(result.largestFiles)).toBe(true);
|
|
112
|
+
expect(result.structure).toBeDefined();
|
|
113
|
+
});
|
|
114
|
+
it("should count files and lines", () => {
|
|
115
|
+
const result = pipeline.codebaseOverview("src/sandbox/sdk");
|
|
116
|
+
expect(result.totalFiles).toBeGreaterThan(0);
|
|
117
|
+
expect(result.totalLines).toBeGreaterThan(0);
|
|
118
|
+
});
|
|
119
|
+
it("should detect languages", () => {
|
|
120
|
+
const result = pipeline.codebaseOverview("src/sandbox/sdk");
|
|
121
|
+
expect(result.languages.typescript).toBeGreaterThan(0);
|
|
122
|
+
});
|
|
123
|
+
it("should list largest files", () => {
|
|
124
|
+
const result = pipeline.codebaseOverview("src/sandbox/sdk");
|
|
125
|
+
expect(result.largestFiles.length).toBeGreaterThan(0);
|
|
126
|
+
const firstFile = result.largestFiles[0];
|
|
127
|
+
expect(firstFile.path).toBeDefined();
|
|
128
|
+
expect(typeof firstFile.lines).toBe("number");
|
|
129
|
+
});
|
|
130
|
+
it("should build structure tree", () => {
|
|
131
|
+
const result = pipeline.codebaseOverview("src/sandbox/sdk");
|
|
132
|
+
expect(result.structure.type).toBe("directory");
|
|
133
|
+
expect(result.structure.name).toBe("sdk");
|
|
134
|
+
expect(result.structure.children).toBeDefined();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
describe("findUsages", () => {
|
|
138
|
+
it("should return SymbolUsage structure", () => {
|
|
139
|
+
const result = pipeline.findUsages("createPipelineAPI");
|
|
140
|
+
expect(result).toBeDefined();
|
|
141
|
+
expect(result.symbol).toBe("createPipelineAPI");
|
|
142
|
+
expect(Array.isArray(result.definitions)).toBe(true);
|
|
143
|
+
expect(Array.isArray(result.usages)).toBe(true);
|
|
144
|
+
expect(typeof result.totalReferences).toBe("number");
|
|
145
|
+
});
|
|
146
|
+
it("should find definitions", () => {
|
|
147
|
+
const result = pipeline.findUsages("createPipelineAPI");
|
|
148
|
+
expect(result.definitions.length).toBeGreaterThan(0);
|
|
149
|
+
const def = result.definitions[0];
|
|
150
|
+
expect(def.file).toBeDefined();
|
|
151
|
+
expect(typeof def.line).toBe("number");
|
|
152
|
+
});
|
|
153
|
+
it("should find usages", () => {
|
|
154
|
+
// Use a symbol that should have usages
|
|
155
|
+
const result = pipeline.findUsages("PipelineStep");
|
|
156
|
+
expect(result.totalReferences).toBeGreaterThan(0);
|
|
157
|
+
});
|
|
158
|
+
it("should support glob filter", () => {
|
|
159
|
+
const result = pipeline.findUsages("createPipelineAPI", "**/*.ts");
|
|
160
|
+
expect(result.symbol).toBe("createPipelineAPI");
|
|
161
|
+
expect(result.totalReferences).toBeGreaterThan(0);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
describe("analyzeDeps", () => {
|
|
165
|
+
it("should return DependencyAnalysis structure", () => {
|
|
166
|
+
const result = pipeline.analyzeDeps("src/sandbox/sdk/pipeline.ts");
|
|
167
|
+
expect(result).toBeDefined();
|
|
168
|
+
expect(result.file).toBe("src/sandbox/sdk/pipeline.ts");
|
|
169
|
+
expect(Array.isArray(result.directDeps)).toBe(true);
|
|
170
|
+
expect(Array.isArray(result.transitiveDeps)).toBe(true);
|
|
171
|
+
expect(Array.isArray(result.externalPackages)).toBe(true);
|
|
172
|
+
expect(Array.isArray(result.circularDeps)).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
it("should find external packages", () => {
|
|
175
|
+
const result = pipeline.analyzeDeps("src/sandbox/sdk/pipeline.ts");
|
|
176
|
+
// pipeline.ts imports fs and path
|
|
177
|
+
expect(result.externalPackages).toContain("fs");
|
|
178
|
+
expect(result.externalPackages).toContain("path");
|
|
179
|
+
});
|
|
180
|
+
it("should find direct dependencies", () => {
|
|
181
|
+
const result = pipeline.analyzeDeps("src/sandbox/sdk/pipeline.ts");
|
|
182
|
+
// pipeline.ts imports from ../types.js and ./compress.js
|
|
183
|
+
expect(result.directDeps.length).toBeGreaterThanOrEqual(0);
|
|
184
|
+
});
|
|
185
|
+
it("should respect depth parameter", () => {
|
|
186
|
+
const shallow = pipeline.analyzeDeps("src/sandbox/sdk/pipeline.ts", 1);
|
|
187
|
+
const deep = pipeline.analyzeDeps("src/sandbox/sdk/pipeline.ts", 3);
|
|
188
|
+
// Deep should potentially have more transitive deps
|
|
189
|
+
expect(shallow.directDeps.length).toBeLessThanOrEqual(shallow.directDeps.length + deep.transitiveDeps.length);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
describe("error handling", () => {
|
|
193
|
+
it("should throw for invalid glob pattern", () => {
|
|
194
|
+
expect(() => pipeline([{ glob: "../../../etc/passwd" }])).toThrow();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Search Functions
|
|
3
|
+
*
|
|
4
|
+
* Code search operations for sandbox use.
|
|
5
|
+
* Provides grep, symbol search, file search, and reference finding.
|
|
6
|
+
*/
|
|
7
|
+
import type { GrepResult, SymbolResult, FileResult, ReferenceMatch, HostCallbacks } from "../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Create Search API for sandbox
|
|
10
|
+
*/
|
|
11
|
+
export declare function createSearchAPI(workingDir: string, callbacks: HostCallbacks): {
|
|
12
|
+
/**
|
|
13
|
+
* Search for pattern in files (grep-style)
|
|
14
|
+
* @param pattern - Regex pattern to search for
|
|
15
|
+
* @param glob - Optional glob pattern to filter files (default: all supported code files)
|
|
16
|
+
*/
|
|
17
|
+
grep(pattern: string, glob?: string): GrepResult;
|
|
18
|
+
/**
|
|
19
|
+
* Search for symbols (functions, classes, etc.) across files
|
|
20
|
+
* @param query - Symbol name to search for (supports partial match)
|
|
21
|
+
* @param glob - Optional glob pattern to filter files
|
|
22
|
+
*/
|
|
23
|
+
symbols(query: string, glob?: string): SymbolResult;
|
|
24
|
+
/**
|
|
25
|
+
* Search for files by pattern
|
|
26
|
+
* @param pattern - Glob pattern to match files
|
|
27
|
+
*/
|
|
28
|
+
files(pattern: string): FileResult;
|
|
29
|
+
/**
|
|
30
|
+
* Find references to a symbol
|
|
31
|
+
* @param symbol - Symbol name to find references for
|
|
32
|
+
* @param glob - Optional glob pattern to filter files
|
|
33
|
+
*/
|
|
34
|
+
references(symbol: string, glob?: string): ReferenceMatch[];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/sandbox/sdk/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAEV,UAAU,EAEV,YAAY,EAEZ,UAAU,EACV,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AA0GrB;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa;IAExE;;;;OAIG;kBACW,MAAM,SAAS,MAAM,GAAG,UAAU;IAmDhD;;;;OAIG;mBACY,MAAM,SAAS,MAAM,GAAG,YAAY;IAuEnD;;;OAGG;mBACY,MAAM,GAAG,UAAU;IAoClC;;;;OAIG;uBACgB,MAAM,SAAS,MAAM,GAAG,cAAc,EAAE;EA+F9D"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Search Functions
|
|
3
|
+
*
|
|
4
|
+
* Code search operations for sandbox use.
|
|
5
|
+
* Provides grep, symbol search, file search, and reference finding.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
import { parseFile } from "../../ast/index.js";
|
|
10
|
+
import { detectLanguageFromPath } from "../../utils/language-detector.js";
|
|
11
|
+
import { validateGlobPattern } from "../security/path-validator.js";
|
|
12
|
+
const MAX_RESULTS = 100;
|
|
13
|
+
const MAX_FILES_TO_SEARCH = 500;
|
|
14
|
+
const MAX_FILE_SIZE = 1024 * 1024; // 1MB
|
|
15
|
+
/**
|
|
16
|
+
* Simple glob pattern matcher
|
|
17
|
+
*/
|
|
18
|
+
function matchGlob(filepath, pattern) {
|
|
19
|
+
// Convert glob pattern to regex
|
|
20
|
+
const regexPattern = pattern
|
|
21
|
+
.replace(/\./g, "\\.")
|
|
22
|
+
.replace(/\*\*/g, "{{DOUBLESTAR}}")
|
|
23
|
+
.replace(/\*/g, "[^/]*")
|
|
24
|
+
.replace(/{{DOUBLESTAR}}/g, ".*")
|
|
25
|
+
.replace(/\?/g, ".");
|
|
26
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
27
|
+
return regex.test(filepath);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Walk directory and find matching files
|
|
31
|
+
*/
|
|
32
|
+
function walkDirectory(dir, pattern, workingDir, maxFiles = MAX_FILES_TO_SEARCH) {
|
|
33
|
+
const results = [];
|
|
34
|
+
function walk(currentDir, relativePath = "") {
|
|
35
|
+
if (results.length >= maxFiles)
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
if (results.length >= maxFiles)
|
|
41
|
+
break;
|
|
42
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
43
|
+
const relPath = path.join(relativePath, entry.name);
|
|
44
|
+
// Skip hidden directories and node_modules
|
|
45
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (entry.isDirectory()) {
|
|
49
|
+
walk(fullPath, relPath);
|
|
50
|
+
}
|
|
51
|
+
else if (entry.isFile()) {
|
|
52
|
+
if (matchGlob(relPath, pattern)) {
|
|
53
|
+
results.push(relPath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Skip directories we can't read
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
walk(dir);
|
|
63
|
+
return results;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Search for pattern in file content
|
|
67
|
+
*/
|
|
68
|
+
function searchInFile(filePath, content, pattern) {
|
|
69
|
+
const matches = [];
|
|
70
|
+
const lines = content.split("\n");
|
|
71
|
+
for (let i = 0; i < lines.length; i++) {
|
|
72
|
+
const line = lines[i] ?? "";
|
|
73
|
+
let match;
|
|
74
|
+
// Reset lastIndex for global regex
|
|
75
|
+
pattern.lastIndex = 0;
|
|
76
|
+
while ((match = pattern.exec(line)) !== null) {
|
|
77
|
+
matches.push({
|
|
78
|
+
file: filePath,
|
|
79
|
+
line: i + 1,
|
|
80
|
+
column: match.index + 1,
|
|
81
|
+
content: line.trim(),
|
|
82
|
+
match: match[0],
|
|
83
|
+
});
|
|
84
|
+
// Prevent infinite loop for zero-length matches
|
|
85
|
+
if (match[0].length === 0)
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return matches;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create Search API for sandbox
|
|
93
|
+
*/
|
|
94
|
+
export function createSearchAPI(workingDir, callbacks) {
|
|
95
|
+
return {
|
|
96
|
+
/**
|
|
97
|
+
* Search for pattern in files (grep-style)
|
|
98
|
+
* @param pattern - Regex pattern to search for
|
|
99
|
+
* @param glob - Optional glob pattern to filter files (default: all supported code files)
|
|
100
|
+
*/
|
|
101
|
+
grep(pattern, glob) {
|
|
102
|
+
const filePattern = glob ?? "**/*.{ts,tsx,js,jsx,py,go,rs,php,swift}";
|
|
103
|
+
// Validate glob pattern
|
|
104
|
+
const validation = validateGlobPattern(filePattern, workingDir);
|
|
105
|
+
if (!validation.safe) {
|
|
106
|
+
throw new Error(validation.error ?? "Invalid glob pattern");
|
|
107
|
+
}
|
|
108
|
+
// Find matching files
|
|
109
|
+
const files = walkDirectory(workingDir, filePattern, workingDir);
|
|
110
|
+
const allMatches = [];
|
|
111
|
+
// Create regex from pattern
|
|
112
|
+
let regex;
|
|
113
|
+
try {
|
|
114
|
+
regex = new RegExp(pattern, "g");
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
throw new Error(`Invalid regex pattern: ${pattern}`);
|
|
118
|
+
}
|
|
119
|
+
// Search each file
|
|
120
|
+
for (const file of files) {
|
|
121
|
+
if (allMatches.length >= MAX_RESULTS)
|
|
122
|
+
break;
|
|
123
|
+
try {
|
|
124
|
+
const fullPath = path.join(workingDir, file);
|
|
125
|
+
const stats = fs.statSync(fullPath);
|
|
126
|
+
// Skip large files
|
|
127
|
+
if (stats.size > MAX_FILE_SIZE)
|
|
128
|
+
continue;
|
|
129
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
130
|
+
const matches = searchInFile(file, content, regex);
|
|
131
|
+
for (const match of matches) {
|
|
132
|
+
if (allMatches.length >= MAX_RESULTS)
|
|
133
|
+
break;
|
|
134
|
+
allMatches.push(match);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// Skip files we can't read
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
matches: allMatches,
|
|
143
|
+
totalMatches: allMatches.length,
|
|
144
|
+
filesSearched: files.length,
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* Search for symbols (functions, classes, etc.) across files
|
|
149
|
+
* @param query - Symbol name to search for (supports partial match)
|
|
150
|
+
* @param glob - Optional glob pattern to filter files
|
|
151
|
+
*/
|
|
152
|
+
symbols(query, glob) {
|
|
153
|
+
const filePattern = glob ?? "**/*.{ts,tsx,js,jsx,py,go,rs,php,swift}";
|
|
154
|
+
// Validate glob pattern
|
|
155
|
+
const validation = validateGlobPattern(filePattern, workingDir);
|
|
156
|
+
if (!validation.safe) {
|
|
157
|
+
throw new Error(validation.error ?? "Invalid glob pattern");
|
|
158
|
+
}
|
|
159
|
+
// Find matching files
|
|
160
|
+
const files = walkDirectory(workingDir, filePattern, workingDir);
|
|
161
|
+
const allSymbols = [];
|
|
162
|
+
const queryLower = query.toLowerCase();
|
|
163
|
+
// Parse each file and search for symbols
|
|
164
|
+
for (const file of files) {
|
|
165
|
+
if (allSymbols.length >= MAX_RESULTS)
|
|
166
|
+
break;
|
|
167
|
+
try {
|
|
168
|
+
const fullPath = path.join(workingDir, file);
|
|
169
|
+
const stats = fs.statSync(fullPath);
|
|
170
|
+
// Skip large files
|
|
171
|
+
if (stats.size > MAX_FILE_SIZE)
|
|
172
|
+
continue;
|
|
173
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
174
|
+
const language = detectLanguageFromPath(file);
|
|
175
|
+
if (language === "unknown")
|
|
176
|
+
continue;
|
|
177
|
+
const structure = parseFile(content, language);
|
|
178
|
+
// Search in all symbol types
|
|
179
|
+
const symbolTypes = [
|
|
180
|
+
{ type: "function", elements: structure.functions },
|
|
181
|
+
{ type: "class", elements: structure.classes },
|
|
182
|
+
{ type: "interface", elements: structure.interfaces },
|
|
183
|
+
{ type: "type", elements: structure.types },
|
|
184
|
+
{ type: "variable", elements: structure.variables },
|
|
185
|
+
];
|
|
186
|
+
for (const { type, elements } of symbolTypes) {
|
|
187
|
+
for (const element of elements) {
|
|
188
|
+
if (allSymbols.length >= MAX_RESULTS)
|
|
189
|
+
break;
|
|
190
|
+
if (element.name.toLowerCase().includes(queryLower)) {
|
|
191
|
+
allSymbols.push({
|
|
192
|
+
name: element.name,
|
|
193
|
+
type,
|
|
194
|
+
file,
|
|
195
|
+
line: element.startLine,
|
|
196
|
+
signature: element.signature,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// Skip files we can't parse
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
symbols: allSymbols,
|
|
208
|
+
totalMatches: allSymbols.length,
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
/**
|
|
212
|
+
* Search for files by pattern
|
|
213
|
+
* @param pattern - Glob pattern to match files
|
|
214
|
+
*/
|
|
215
|
+
files(pattern) {
|
|
216
|
+
// Validate glob pattern
|
|
217
|
+
const validation = validateGlobPattern(pattern, workingDir);
|
|
218
|
+
if (!validation.safe) {
|
|
219
|
+
throw new Error(validation.error ?? "Invalid glob pattern");
|
|
220
|
+
}
|
|
221
|
+
// Find matching files
|
|
222
|
+
const files = walkDirectory(workingDir, pattern, workingDir);
|
|
223
|
+
const fileMatches = [];
|
|
224
|
+
for (const file of files) {
|
|
225
|
+
if (fileMatches.length >= MAX_RESULTS)
|
|
226
|
+
break;
|
|
227
|
+
try {
|
|
228
|
+
const fullPath = path.join(workingDir, file);
|
|
229
|
+
const stats = fs.statSync(fullPath);
|
|
230
|
+
const parsed = path.parse(file);
|
|
231
|
+
fileMatches.push({
|
|
232
|
+
path: file,
|
|
233
|
+
name: parsed.base,
|
|
234
|
+
extension: parsed.ext,
|
|
235
|
+
size: stats.size,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
// Skip files we can't stat
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
files: fileMatches,
|
|
244
|
+
totalMatches: fileMatches.length,
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
/**
|
|
248
|
+
* Find references to a symbol
|
|
249
|
+
* @param symbol - Symbol name to find references for
|
|
250
|
+
* @param glob - Optional glob pattern to filter files
|
|
251
|
+
*/
|
|
252
|
+
references(symbol, glob) {
|
|
253
|
+
const filePattern = glob ?? "**/*.{ts,tsx,js,jsx,py,go,rs,php,swift}";
|
|
254
|
+
// Validate glob pattern
|
|
255
|
+
const validation = validateGlobPattern(filePattern, workingDir);
|
|
256
|
+
if (!validation.safe) {
|
|
257
|
+
throw new Error(validation.error ?? "Invalid glob pattern");
|
|
258
|
+
}
|
|
259
|
+
// Find matching files
|
|
260
|
+
const files = walkDirectory(workingDir, filePattern, workingDir);
|
|
261
|
+
const references = [];
|
|
262
|
+
// Create patterns for different reference types
|
|
263
|
+
// Definition: function/class/const/let/var name
|
|
264
|
+
const defPattern = new RegExp(`(?:function|class|const|let|var|interface|type)\\s+${escapeRegex(symbol)}\\b`, "g");
|
|
265
|
+
// Import: import { name } or import name
|
|
266
|
+
const importPattern = new RegExp(`import\\s+(?:{[^}]*\\b${escapeRegex(symbol)}\\b[^}]*}|${escapeRegex(symbol)})`, "g");
|
|
267
|
+
// Usage: general word boundary match (excluding definitions)
|
|
268
|
+
const usagePattern = new RegExp(`\\b${escapeRegex(symbol)}\\b`, "g");
|
|
269
|
+
for (const file of files) {
|
|
270
|
+
if (references.length >= MAX_RESULTS)
|
|
271
|
+
break;
|
|
272
|
+
try {
|
|
273
|
+
const fullPath = path.join(workingDir, file);
|
|
274
|
+
const stats = fs.statSync(fullPath);
|
|
275
|
+
// Skip large files
|
|
276
|
+
if (stats.size > MAX_FILE_SIZE)
|
|
277
|
+
continue;
|
|
278
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
279
|
+
const lines = content.split("\n");
|
|
280
|
+
for (let i = 0; i < lines.length; i++) {
|
|
281
|
+
if (references.length >= MAX_RESULTS)
|
|
282
|
+
break;
|
|
283
|
+
const line = lines[i] ?? "";
|
|
284
|
+
// Check for definition
|
|
285
|
+
defPattern.lastIndex = 0;
|
|
286
|
+
let match = defPattern.exec(line);
|
|
287
|
+
if (match) {
|
|
288
|
+
references.push({
|
|
289
|
+
file,
|
|
290
|
+
line: i + 1,
|
|
291
|
+
column: match.index + 1,
|
|
292
|
+
context: line.trim(),
|
|
293
|
+
type: "definition",
|
|
294
|
+
});
|
|
295
|
+
continue; // Don't double-count as usage
|
|
296
|
+
}
|
|
297
|
+
// Check for import
|
|
298
|
+
importPattern.lastIndex = 0;
|
|
299
|
+
match = importPattern.exec(line);
|
|
300
|
+
if (match) {
|
|
301
|
+
references.push({
|
|
302
|
+
file,
|
|
303
|
+
line: i + 1,
|
|
304
|
+
column: match.index + 1,
|
|
305
|
+
context: line.trim(),
|
|
306
|
+
type: "import",
|
|
307
|
+
});
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
// Check for usage
|
|
311
|
+
usagePattern.lastIndex = 0;
|
|
312
|
+
while ((match = usagePattern.exec(line)) !== null) {
|
|
313
|
+
if (references.length >= MAX_RESULTS)
|
|
314
|
+
break;
|
|
315
|
+
references.push({
|
|
316
|
+
file,
|
|
317
|
+
line: i + 1,
|
|
318
|
+
column: match.index + 1,
|
|
319
|
+
context: line.trim(),
|
|
320
|
+
type: "usage",
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
// Skip files we can't read
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return references;
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Escape special regex characters
|
|
335
|
+
*/
|
|
336
|
+
function escapeRegex(str) {
|
|
337
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
338
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.test.d.ts","sourceRoot":"","sources":["../../../src/sandbox/sdk/search.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|