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
package/bin/cli.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runServer } from "../dist/server.js";
|
|
4
|
+
import { setup, parseSetupArgs } from "../dist/cli/setup.js";
|
|
5
|
+
import { doctor } from "../dist/cli/doctor.js";
|
|
6
|
+
import { runAnalyze } from "../dist/cli/analyze.js";
|
|
7
|
+
import { getPackageVersion, COLORS, log } from "../dist/cli/utils.js";
|
|
8
|
+
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
const command = args[0];
|
|
11
|
+
|
|
12
|
+
function showHelp() {
|
|
13
|
+
const version = getPackageVersion();
|
|
14
|
+
console.log(`
|
|
15
|
+
${COLORS.bright}${COLORS.cyan}CtxOpt MCP Server${COLORS.reset} v${version}
|
|
16
|
+
Context Engineering Optimizer for Claude Code, Cursor, and Windsurf
|
|
17
|
+
|
|
18
|
+
${COLORS.bright}Usage:${COLORS.reset}
|
|
19
|
+
ctxopt-mcp <command> [options]
|
|
20
|
+
|
|
21
|
+
${COLORS.bright}Commands:${COLORS.reset}
|
|
22
|
+
serve Start the MCP server (stdio mode)
|
|
23
|
+
setup Configure IDEs to use CtxOpt
|
|
24
|
+
doctor Check installation and configuration
|
|
25
|
+
analyze Analyze files for token usage
|
|
26
|
+
|
|
27
|
+
${COLORS.bright}Setup Options:${COLORS.reset}
|
|
28
|
+
--claude Configure Claude Code only
|
|
29
|
+
--cursor Configure Cursor only
|
|
30
|
+
--windsurf Configure Windsurf only
|
|
31
|
+
--hooks Install project hooks (enforces MCP tool usage)
|
|
32
|
+
--force, -f Overwrite existing configuration
|
|
33
|
+
|
|
34
|
+
${COLORS.bright}Server Options:${COLORS.reset}
|
|
35
|
+
--lazy Enable lazy mode (95% token savings, only 2 meta-tools)
|
|
36
|
+
--mode <mode> Loading mode: lazy|core|all (default: core)
|
|
37
|
+
--verbose Enable verbose logging (shows tool calls, timing, tokens)
|
|
38
|
+
|
|
39
|
+
${COLORS.bright}Analyze Options:${COLORS.reset}
|
|
40
|
+
--patterns, -p Glob patterns to match (default: **/*.{ts,tsx,js,jsx,py,go,rs})
|
|
41
|
+
--threshold, -t Token threshold for warnings (default: 2000)
|
|
42
|
+
--json, -j Output as JSON
|
|
43
|
+
--output, -o Write report to file
|
|
44
|
+
|
|
45
|
+
${COLORS.bright}Other Options:${COLORS.reset}
|
|
46
|
+
--version, -v Show version number
|
|
47
|
+
--help, -h Show this help message
|
|
48
|
+
|
|
49
|
+
${COLORS.bright}Examples:${COLORS.reset}
|
|
50
|
+
ctxopt-mcp setup Auto-detect and configure all IDEs
|
|
51
|
+
ctxopt-mcp setup --claude Configure Claude Code only
|
|
52
|
+
ctxopt-mcp setup --claude --hooks Configure Claude Code + install hooks
|
|
53
|
+
ctxopt-mcp setup --hooks Install hooks only (current project)
|
|
54
|
+
ctxopt-mcp setup --force Overwrite existing configurations
|
|
55
|
+
ctxopt-mcp doctor Verify installation
|
|
56
|
+
ctxopt-mcp serve Start MCP server (used by IDE)
|
|
57
|
+
ctxopt-mcp serve --lazy Start with lazy mode (95% savings)
|
|
58
|
+
ctxopt-mcp serve --verbose Start with verbose logging
|
|
59
|
+
ctxopt-mcp analyze Analyze token usage in codebase
|
|
60
|
+
ctxopt-mcp analyze -t 5000 --json Custom threshold, JSON output
|
|
61
|
+
|
|
62
|
+
${COLORS.bright}Documentation:${COLORS.reset}
|
|
63
|
+
https://ctxopt.dev/docs
|
|
64
|
+
`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function showVersion() {
|
|
68
|
+
console.log(getPackageVersion());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function main() {
|
|
72
|
+
// Handle version flag anywhere
|
|
73
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
74
|
+
showVersion();
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Handle help flag anywhere
|
|
79
|
+
if (args.includes("--help") || args.includes("-h") || args.length === 0) {
|
|
80
|
+
showHelp();
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
switch (command) {
|
|
85
|
+
case "serve": {
|
|
86
|
+
// Parse mode option
|
|
87
|
+
let mode = "core";
|
|
88
|
+
const modeIndex = args.indexOf("--mode");
|
|
89
|
+
if (modeIndex !== -1 && args[modeIndex + 1]) {
|
|
90
|
+
mode = args[modeIndex + 1];
|
|
91
|
+
} else if (args.includes("--lazy")) {
|
|
92
|
+
mode = "lazy";
|
|
93
|
+
} else if (args.includes("--all")) {
|
|
94
|
+
mode = "all";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const config = {
|
|
98
|
+
verbose: args.includes("--verbose"),
|
|
99
|
+
mode,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
await runServer(config);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
case "setup": {
|
|
107
|
+
const options = parseSetupArgs(args.slice(1));
|
|
108
|
+
await setup(options);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
case "doctor": {
|
|
113
|
+
await doctor();
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
case "analyze": {
|
|
118
|
+
await runAnalyze(args.slice(1));
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
default: {
|
|
123
|
+
console.error(`Unknown command: ${command}`);
|
|
124
|
+
console.error('Run "ctxopt-mcp --help" for usage information.');
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
main().catch((error) => {
|
|
131
|
+
console.error("Error:", error.message);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Tracker
|
|
3
|
+
*
|
|
4
|
+
* Singleton class that tracks per-session statistics for tool usage,
|
|
5
|
+
* token savings, and optimization metrics.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Per-tool statistics
|
|
9
|
+
*/
|
|
10
|
+
export interface ToolStats {
|
|
11
|
+
invocations: number;
|
|
12
|
+
tokensIn: number;
|
|
13
|
+
tokensOut: number;
|
|
14
|
+
tokensSaved: number;
|
|
15
|
+
totalDurationMs: number;
|
|
16
|
+
errors: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Session-wide statistics
|
|
20
|
+
*/
|
|
21
|
+
export interface SessionStats {
|
|
22
|
+
startTime: Date;
|
|
23
|
+
lastActivityTime: Date;
|
|
24
|
+
totalInvocations: number;
|
|
25
|
+
totalTokensIn: number;
|
|
26
|
+
totalTokensOut: number;
|
|
27
|
+
totalTokensSaved: number;
|
|
28
|
+
totalDurationMs: number;
|
|
29
|
+
totalErrors: number;
|
|
30
|
+
toolStats: Record<string, ToolStats>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Session Tracker class
|
|
34
|
+
* Accumulates statistics across all tool invocations in a session.
|
|
35
|
+
*/
|
|
36
|
+
declare class SessionTracker {
|
|
37
|
+
private startTime;
|
|
38
|
+
private lastActivityTime;
|
|
39
|
+
private toolStats;
|
|
40
|
+
constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Record a tool invocation
|
|
43
|
+
*/
|
|
44
|
+
recordInvocation(toolName: string, tokensIn: number, tokensOut: number, tokensSaved: number, durationMs: number, isError?: boolean): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get current session statistics
|
|
47
|
+
*/
|
|
48
|
+
getStats(): SessionStats;
|
|
49
|
+
/**
|
|
50
|
+
* Reset session statistics
|
|
51
|
+
*/
|
|
52
|
+
reset(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get session duration in milliseconds
|
|
55
|
+
*/
|
|
56
|
+
getSessionDurationMs(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Get optimization rate (tokens saved / tokens in)
|
|
59
|
+
*/
|
|
60
|
+
getOptimizationRate(): number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the global session tracker instance
|
|
64
|
+
*/
|
|
65
|
+
export declare function getSessionTracker(): SessionTracker;
|
|
66
|
+
/**
|
|
67
|
+
* Reset the global session tracker
|
|
68
|
+
*/
|
|
69
|
+
export declare function resetSessionTracker(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Export session stats for the session tracker
|
|
72
|
+
*/
|
|
73
|
+
export { SessionTracker };
|
|
74
|
+
//# sourceMappingURL=session-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-tracker.d.ts","sourceRoot":"","sources":["../../src/analytics/session-tracker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,IAAI,CAAC;IAChB,gBAAgB,EAAE,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,gBAAgB,CAAO;IAC/B,OAAO,CAAC,SAAS,CAAyB;;IAQ1C;;OAEG;IACH,gBAAgB,CACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,OAAe,GACvB,IAAI;IAsBP;;OAEG;IACH,QAAQ,IAAI,YAAY;IAiCxB;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,oBAAoB,IAAI,MAAM;IAI9B;;OAEG;IACH,mBAAmB,IAAI,MAAM;CAK9B;AAKD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C;AAED;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Tracker
|
|
3
|
+
*
|
|
4
|
+
* Singleton class that tracks per-session statistics for tool usage,
|
|
5
|
+
* token savings, and optimization metrics.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Session Tracker class
|
|
9
|
+
* Accumulates statistics across all tool invocations in a session.
|
|
10
|
+
*/
|
|
11
|
+
class SessionTracker {
|
|
12
|
+
startTime;
|
|
13
|
+
lastActivityTime;
|
|
14
|
+
toolStats;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.startTime = new Date();
|
|
17
|
+
this.lastActivityTime = new Date();
|
|
18
|
+
this.toolStats = new Map();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Record a tool invocation
|
|
22
|
+
*/
|
|
23
|
+
recordInvocation(toolName, tokensIn, tokensOut, tokensSaved, durationMs, isError = false) {
|
|
24
|
+
this.lastActivityTime = new Date();
|
|
25
|
+
const existing = this.toolStats.get(toolName) || {
|
|
26
|
+
invocations: 0,
|
|
27
|
+
tokensIn: 0,
|
|
28
|
+
tokensOut: 0,
|
|
29
|
+
tokensSaved: 0,
|
|
30
|
+
totalDurationMs: 0,
|
|
31
|
+
errors: 0,
|
|
32
|
+
};
|
|
33
|
+
existing.invocations++;
|
|
34
|
+
existing.tokensIn += tokensIn;
|
|
35
|
+
existing.tokensOut += tokensOut;
|
|
36
|
+
existing.tokensSaved += tokensSaved;
|
|
37
|
+
existing.totalDurationMs += durationMs;
|
|
38
|
+
if (isError)
|
|
39
|
+
existing.errors++;
|
|
40
|
+
this.toolStats.set(toolName, existing);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get current session statistics
|
|
44
|
+
*/
|
|
45
|
+
getStats() {
|
|
46
|
+
let totalInvocations = 0;
|
|
47
|
+
let totalTokensIn = 0;
|
|
48
|
+
let totalTokensOut = 0;
|
|
49
|
+
let totalTokensSaved = 0;
|
|
50
|
+
let totalDurationMs = 0;
|
|
51
|
+
let totalErrors = 0;
|
|
52
|
+
const toolStatsObj = {};
|
|
53
|
+
for (const [name, stats] of this.toolStats.entries()) {
|
|
54
|
+
totalInvocations += stats.invocations;
|
|
55
|
+
totalTokensIn += stats.tokensIn;
|
|
56
|
+
totalTokensOut += stats.tokensOut;
|
|
57
|
+
totalTokensSaved += stats.tokensSaved;
|
|
58
|
+
totalDurationMs += stats.totalDurationMs;
|
|
59
|
+
totalErrors += stats.errors;
|
|
60
|
+
toolStatsObj[name] = { ...stats };
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
startTime: this.startTime,
|
|
64
|
+
lastActivityTime: this.lastActivityTime,
|
|
65
|
+
totalInvocations,
|
|
66
|
+
totalTokensIn,
|
|
67
|
+
totalTokensOut,
|
|
68
|
+
totalTokensSaved,
|
|
69
|
+
totalDurationMs,
|
|
70
|
+
totalErrors,
|
|
71
|
+
toolStats: toolStatsObj,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Reset session statistics
|
|
76
|
+
*/
|
|
77
|
+
reset() {
|
|
78
|
+
this.startTime = new Date();
|
|
79
|
+
this.lastActivityTime = new Date();
|
|
80
|
+
this.toolStats.clear();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get session duration in milliseconds
|
|
84
|
+
*/
|
|
85
|
+
getSessionDurationMs() {
|
|
86
|
+
return Date.now() - this.startTime.getTime();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get optimization rate (tokens saved / tokens in)
|
|
90
|
+
*/
|
|
91
|
+
getOptimizationRate() {
|
|
92
|
+
const stats = this.getStats();
|
|
93
|
+
if (stats.totalTokensIn === 0)
|
|
94
|
+
return 0;
|
|
95
|
+
return stats.totalTokensSaved / stats.totalTokensIn;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Global singleton instance
|
|
99
|
+
let globalTracker = null;
|
|
100
|
+
/**
|
|
101
|
+
* Get the global session tracker instance
|
|
102
|
+
*/
|
|
103
|
+
export function getSessionTracker() {
|
|
104
|
+
if (!globalTracker) {
|
|
105
|
+
globalTracker = new SessionTracker();
|
|
106
|
+
}
|
|
107
|
+
return globalTracker;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Reset the global session tracker
|
|
111
|
+
*/
|
|
112
|
+
export function resetSessionTracker() {
|
|
113
|
+
if (globalTracker) {
|
|
114
|
+
globalTracker.reset();
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
globalTracker = new SessionTracker();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Export session stats for the session tracker
|
|
122
|
+
*/
|
|
123
|
+
export { SessionTracker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benchmark.test.d.ts","sourceRoot":"","sources":["../../src/ast/benchmark.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Parser Benchmarks
|
|
3
|
+
*
|
|
4
|
+
* Performance tests comparing Tree-sitter parsers to regex-based parsing.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect, beforeAll } from "vitest";
|
|
7
|
+
import { initPythonParser, parsePythonAsync } from "./python/parser.js";
|
|
8
|
+
import { initGoParser, parseGoAsync } from "./go/parser.js";
|
|
9
|
+
// Generate large Python code sample
|
|
10
|
+
function generateLargePythonCode(numFunctions, numClasses) {
|
|
11
|
+
let code = `"""Large Python module for benchmarking."""\n\n`;
|
|
12
|
+
code += `import os\nimport sys\nfrom typing import List, Dict, Optional\n\n`;
|
|
13
|
+
for (let i = 0; i < numClasses; i++) {
|
|
14
|
+
code += `class TestClass${i}:\n`;
|
|
15
|
+
code += ` """Class ${i} documentation."""\n`;
|
|
16
|
+
code += ` def __init__(self, value: int):\n`;
|
|
17
|
+
code += ` self.value = value\n\n`;
|
|
18
|
+
code += ` def method_a(self) -> int:\n`;
|
|
19
|
+
code += ` """Return the value."""\n`;
|
|
20
|
+
code += ` return self.value\n\n`;
|
|
21
|
+
code += ` async def method_b(self) -> str:\n`;
|
|
22
|
+
code += ` """Async method."""\n`;
|
|
23
|
+
code += ` return str(self.value)\n\n`;
|
|
24
|
+
}
|
|
25
|
+
for (let i = 0; i < numFunctions; i++) {
|
|
26
|
+
code += `def function_${i}(x: int, y: int) -> int:\n`;
|
|
27
|
+
code += ` """Calculate something with ${i}."""\n`;
|
|
28
|
+
code += ` return x + y + ${i}\n\n`;
|
|
29
|
+
}
|
|
30
|
+
return code;
|
|
31
|
+
}
|
|
32
|
+
// Generate large Go code sample
|
|
33
|
+
function generateLargeGoCode(numFunctions, numStructs) {
|
|
34
|
+
let code = `package benchmark\n\n`;
|
|
35
|
+
code += `import (\n\t"fmt"\n\t"strings"\n)\n\n`;
|
|
36
|
+
for (let i = 0; i < numStructs; i++) {
|
|
37
|
+
code += `// TestStruct${i} is a test struct\n`;
|
|
38
|
+
code += `type TestStruct${i} struct {\n`;
|
|
39
|
+
code += `\tValue int\n`;
|
|
40
|
+
code += `\tName string\n`;
|
|
41
|
+
code += `}\n\n`;
|
|
42
|
+
code += `// MethodA returns the value\n`;
|
|
43
|
+
code += `func (t *TestStruct${i}) MethodA() int {\n`;
|
|
44
|
+
code += `\treturn t.Value\n`;
|
|
45
|
+
code += `}\n\n`;
|
|
46
|
+
code += `// MethodB returns the name\n`;
|
|
47
|
+
code += `func (t TestStruct${i}) MethodB() string {\n`;
|
|
48
|
+
code += `\treturn t.Name\n`;
|
|
49
|
+
code += `}\n\n`;
|
|
50
|
+
}
|
|
51
|
+
for (let i = 0; i < numFunctions; i++) {
|
|
52
|
+
code += `// Function${i} calculates something\n`;
|
|
53
|
+
code += `func Function${i}(x, y int) int {\n`;
|
|
54
|
+
code += `\treturn x + y + ${i}\n`;
|
|
55
|
+
code += `}\n\n`;
|
|
56
|
+
}
|
|
57
|
+
return code;
|
|
58
|
+
}
|
|
59
|
+
describe("Parser Benchmarks", () => {
|
|
60
|
+
beforeAll(async () => {
|
|
61
|
+
// Initialize parsers
|
|
62
|
+
await Promise.all([initPythonParser(), initGoParser()]);
|
|
63
|
+
});
|
|
64
|
+
describe("Python Parser Performance", () => {
|
|
65
|
+
it("should parse small Python code quickly", async () => {
|
|
66
|
+
const code = generateLargePythonCode(10, 5);
|
|
67
|
+
const start = performance.now();
|
|
68
|
+
const structure = await parsePythonAsync(code);
|
|
69
|
+
const elapsed = performance.now() - start;
|
|
70
|
+
expect(structure.functions.length).toBeGreaterThan(0);
|
|
71
|
+
expect(structure.classes.length).toBe(5);
|
|
72
|
+
expect(elapsed).toBeLessThan(1000); // Should complete in under 1 second
|
|
73
|
+
console.log(`Python small (10 funcs, 5 classes): ${elapsed.toFixed(2)}ms`);
|
|
74
|
+
});
|
|
75
|
+
it("should parse medium Python code efficiently", async () => {
|
|
76
|
+
const code = generateLargePythonCode(50, 20);
|
|
77
|
+
const start = performance.now();
|
|
78
|
+
const structure = await parsePythonAsync(code);
|
|
79
|
+
const elapsed = performance.now() - start;
|
|
80
|
+
expect(structure.functions.length).toBeGreaterThan(50);
|
|
81
|
+
expect(structure.classes.length).toBe(20);
|
|
82
|
+
expect(elapsed).toBeLessThan(2000);
|
|
83
|
+
console.log(`Python medium (50 funcs, 20 classes): ${elapsed.toFixed(2)}ms`);
|
|
84
|
+
});
|
|
85
|
+
it("should parse large Python code acceptably", async () => {
|
|
86
|
+
const code = generateLargePythonCode(100, 50);
|
|
87
|
+
const start = performance.now();
|
|
88
|
+
const structure = await parsePythonAsync(code);
|
|
89
|
+
const elapsed = performance.now() - start;
|
|
90
|
+
expect(structure.functions.length).toBeGreaterThan(100);
|
|
91
|
+
expect(structure.classes.length).toBe(50);
|
|
92
|
+
expect(elapsed).toBeLessThan(5000);
|
|
93
|
+
console.log(`Python large (100 funcs, 50 classes): ${elapsed.toFixed(2)}ms`);
|
|
94
|
+
console.log(` - Functions: ${structure.functions.length}`);
|
|
95
|
+
console.log(` - Classes: ${structure.classes.length}`);
|
|
96
|
+
console.log(` - Total lines: ${structure.totalLines}`);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
describe("Go Parser Performance", () => {
|
|
100
|
+
it("should parse small Go code quickly", async () => {
|
|
101
|
+
const code = generateLargeGoCode(10, 5);
|
|
102
|
+
const start = performance.now();
|
|
103
|
+
const structure = await parseGoAsync(code);
|
|
104
|
+
const elapsed = performance.now() - start;
|
|
105
|
+
expect(structure.functions.length).toBeGreaterThan(0);
|
|
106
|
+
expect(structure.classes.length).toBe(5);
|
|
107
|
+
expect(elapsed).toBeLessThan(1000);
|
|
108
|
+
console.log(`Go small (10 funcs, 5 structs): ${elapsed.toFixed(2)}ms`);
|
|
109
|
+
});
|
|
110
|
+
it("should parse medium Go code efficiently", async () => {
|
|
111
|
+
const code = generateLargeGoCode(50, 20);
|
|
112
|
+
const start = performance.now();
|
|
113
|
+
const structure = await parseGoAsync(code);
|
|
114
|
+
const elapsed = performance.now() - start;
|
|
115
|
+
expect(structure.functions.length).toBeGreaterThan(50);
|
|
116
|
+
expect(structure.classes.length).toBe(20);
|
|
117
|
+
expect(elapsed).toBeLessThan(2000);
|
|
118
|
+
console.log(`Go medium (50 funcs, 20 structs): ${elapsed.toFixed(2)}ms`);
|
|
119
|
+
});
|
|
120
|
+
it("should parse large Go code acceptably", async () => {
|
|
121
|
+
const code = generateLargeGoCode(100, 50);
|
|
122
|
+
const start = performance.now();
|
|
123
|
+
const structure = await parseGoAsync(code);
|
|
124
|
+
const elapsed = performance.now() - start;
|
|
125
|
+
expect(structure.functions.length).toBeGreaterThan(100);
|
|
126
|
+
expect(structure.classes.length).toBe(50);
|
|
127
|
+
expect(elapsed).toBeLessThan(5000);
|
|
128
|
+
console.log(`Go large (100 funcs, 50 structs): ${elapsed.toFixed(2)}ms`);
|
|
129
|
+
console.log(` - Functions: ${structure.functions.length}`);
|
|
130
|
+
console.log(` - Structs: ${structure.classes.length}`);
|
|
131
|
+
console.log(` - Total lines: ${structure.totalLines}`);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
describe("Parsing accuracy comparison", () => {
|
|
135
|
+
it("should accurately count all elements in Python code", async () => {
|
|
136
|
+
const numFuncs = 25;
|
|
137
|
+
const numClasses = 10;
|
|
138
|
+
const code = generateLargePythonCode(numFuncs, numClasses);
|
|
139
|
+
const structure = await parsePythonAsync(code);
|
|
140
|
+
// Each class has 3 methods (__init__, method_a, method_b)
|
|
141
|
+
const expectedMethods = numClasses * 3;
|
|
142
|
+
const totalFunctions = structure.functions.filter((f) => f.type === "function").length;
|
|
143
|
+
const totalMethods = structure.functions.filter((f) => f.type === "method").length;
|
|
144
|
+
expect(totalFunctions).toBe(numFuncs);
|
|
145
|
+
expect(totalMethods).toBe(expectedMethods);
|
|
146
|
+
expect(structure.classes.length).toBe(numClasses);
|
|
147
|
+
});
|
|
148
|
+
it("should accurately count all elements in Go code", async () => {
|
|
149
|
+
const numFuncs = 25;
|
|
150
|
+
const numStructs = 10;
|
|
151
|
+
const code = generateLargeGoCode(numFuncs, numStructs);
|
|
152
|
+
const structure = await parseGoAsync(code);
|
|
153
|
+
// Each struct has 2 methods
|
|
154
|
+
const expectedMethods = numStructs * 2;
|
|
155
|
+
const totalFunctions = structure.functions.filter((f) => f.type === "function").length;
|
|
156
|
+
const totalMethods = structure.functions.filter((f) => f.type === "method").length;
|
|
157
|
+
expect(totalFunctions).toBe(numFuncs);
|
|
158
|
+
expect(totalMethods).toBe(expectedMethods);
|
|
159
|
+
expect(structure.classes.length).toBe(numStructs);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
describe("Memory efficiency", () => {
|
|
163
|
+
it("should handle repeated parsing without memory leaks", async () => {
|
|
164
|
+
const pythonCode = generateLargePythonCode(20, 10);
|
|
165
|
+
const goCode = generateLargeGoCode(20, 10);
|
|
166
|
+
// Parse multiple times
|
|
167
|
+
for (let i = 0; i < 10; i++) {
|
|
168
|
+
await parsePythonAsync(pythonCode);
|
|
169
|
+
await parseGoAsync(goCode);
|
|
170
|
+
}
|
|
171
|
+
// If we get here without running out of memory, test passes
|
|
172
|
+
expect(true).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go AST Parser Module
|
|
3
|
+
*
|
|
4
|
+
* Exports the Tree-sitter based Go parser.
|
|
5
|
+
*/
|
|
6
|
+
export { goTreeSitterParser, parseGo, parseGoAsync, extractGoElement, searchGoElements, initGoParser, } from "./parser.js";
|
|
7
|
+
export { QUERIES } from "./queries.js";
|
|
8
|
+
export { getLineNumber, getEndLineNumber, extractGoDoc, getFunctionSignature, getMethodSignature, getTypeSignature, isExported, createCodeElement, } from "./utils.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ast/go/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go AST Parser Module
|
|
3
|
+
*
|
|
4
|
+
* Exports the Tree-sitter based Go parser.
|
|
5
|
+
*/
|
|
6
|
+
export { goTreeSitterParser, parseGo, parseGoAsync, extractGoElement, searchGoElements, initGoParser, } from "./parser.js";
|
|
7
|
+
export { QUERIES } from "./queries.js";
|
|
8
|
+
export { getLineNumber, getEndLineNumber, extractGoDoc, getFunctionSignature, getMethodSignature, getTypeSignature, isExported, createCodeElement, } from "./utils.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Tree-sitter Parser
|
|
3
|
+
*
|
|
4
|
+
* AST parser for Go using Tree-sitter for accurate code analysis.
|
|
5
|
+
*/
|
|
6
|
+
import type { CodeElement, FileStructure, ExtractedContent, ExtractionTarget, ExtractionOptions, LanguageParser } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Parse Go content and extract structure
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseGo(content: string): FileStructure;
|
|
11
|
+
/**
|
|
12
|
+
* Async version of parseGo
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseGoAsync(content: string): Promise<FileStructure>;
|
|
15
|
+
/**
|
|
16
|
+
* Extract a specific element from Go code
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractGoElement(content: string, target: ExtractionTarget, options: ExtractionOptions): Promise<ExtractedContent | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Search for elements matching a query
|
|
21
|
+
*/
|
|
22
|
+
export declare function searchGoElements(content: string, query: string): Promise<CodeElement[]>;
|
|
23
|
+
/**
|
|
24
|
+
* LanguageParser implementation for Go
|
|
25
|
+
*/
|
|
26
|
+
export declare const goTreeSitterParser: LanguageParser;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the Go parser
|
|
29
|
+
*/
|
|
30
|
+
export declare function initGoParser(): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/ast/go/parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAEjB,cAAc,EACf,MAAM,aAAa,CAAC;AAiErB;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAWtD;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAW1E;AAkLD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAoElC;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAwB7F;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,cAmHhC,CAAC;AAEF;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD"}
|