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,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Estimator Tests
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from "vitest";
|
|
5
|
+
import { estimateOutputTokens, isQuestion, isInstruction, getOutputRatio, } from "./output-estimator.js";
|
|
6
|
+
describe("Output Estimator", () => {
|
|
7
|
+
describe("isQuestion", () => {
|
|
8
|
+
it("should detect questions starting with question words", () => {
|
|
9
|
+
expect(isQuestion("What is TypeScript?")).toBe(true);
|
|
10
|
+
expect(isQuestion("How do I fix this error?")).toBe(true);
|
|
11
|
+
expect(isQuestion("Why is this happening?")).toBe(true);
|
|
12
|
+
expect(isQuestion("Can you explain this?")).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
it("should detect questions ending with question mark", () => {
|
|
15
|
+
expect(isQuestion("This is broken?")).toBe(true);
|
|
16
|
+
expect(isQuestion("Is this correct?")).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
it("should detect explain/describe patterns", () => {
|
|
19
|
+
expect(isQuestion("Explain how promises work")).toBe(true);
|
|
20
|
+
expect(isQuestion("Describe the architecture")).toBe(true);
|
|
21
|
+
expect(isQuestion("Tell me about this function")).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
it("should not detect non-questions", () => {
|
|
24
|
+
expect(isQuestion("Fix this bug")).toBe(false);
|
|
25
|
+
expect(isQuestion("Create a new function")).toBe(false);
|
|
26
|
+
expect(isQuestion("const x = 5")).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe("isInstruction", () => {
|
|
30
|
+
it("should detect imperative commands", () => {
|
|
31
|
+
expect(isInstruction("Create a new function")).toBe(true);
|
|
32
|
+
expect(isInstruction("Write a test for this")).toBe(true);
|
|
33
|
+
expect(isInstruction("Fix the authentication bug")).toBe(true);
|
|
34
|
+
expect(isInstruction("Add error handling")).toBe(true);
|
|
35
|
+
expect(isInstruction("Refactor this code")).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
it("should detect polite requests", () => {
|
|
38
|
+
expect(isInstruction("Please update the README")).toBe(true);
|
|
39
|
+
expect(isInstruction("Can you implement this feature")).toBe(true);
|
|
40
|
+
expect(isInstruction("Could you review this PR")).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
it("should detect creation patterns", () => {
|
|
43
|
+
expect(isInstruction("I need a function to parse JSON")).toBe(false); // Not at start
|
|
44
|
+
expect(isInstruction("Write a utility for caching")).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
it("should not detect non-instructions", () => {
|
|
47
|
+
expect(isInstruction("What is this?")).toBe(false);
|
|
48
|
+
expect(isInstruction("const x = 5")).toBe(false);
|
|
49
|
+
expect(isInstruction("Error: something failed")).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe("estimateOutputTokens", () => {
|
|
53
|
+
it("should estimate output for code content", () => {
|
|
54
|
+
const codeContent = `
|
|
55
|
+
function hello() {
|
|
56
|
+
return "world";
|
|
57
|
+
}
|
|
58
|
+
`.trim();
|
|
59
|
+
const result = estimateOutputTokens(codeContent, 500, "code");
|
|
60
|
+
// Code default ratio is 0.8x
|
|
61
|
+
expect(result.estimated).toBeGreaterThan(0);
|
|
62
|
+
expect(result.estimated).toBeLessThanOrEqual(500 * 1.5);
|
|
63
|
+
expect(result.confidence).toBe("medium");
|
|
64
|
+
});
|
|
65
|
+
it("should estimate lower output for logs", () => {
|
|
66
|
+
const logsContent = `
|
|
67
|
+
[2025-12-23 10:00:00] INFO: Server started
|
|
68
|
+
[2025-12-23 10:00:01] DEBUG: Loading config
|
|
69
|
+
`.trim();
|
|
70
|
+
const result = estimateOutputTokens(logsContent, 1000, "logs");
|
|
71
|
+
// Logs ratio is 0.2x, so output should be much smaller than input
|
|
72
|
+
expect(result.estimated).toBeLessThan(500);
|
|
73
|
+
});
|
|
74
|
+
it("should estimate higher output for questions", () => {
|
|
75
|
+
const question = "What is the difference between let and const?";
|
|
76
|
+
const result = estimateOutputTokens(question, 100, "generic");
|
|
77
|
+
// Questions get 1.0x ratio by default
|
|
78
|
+
expect(result.estimated).toBeGreaterThanOrEqual(50); // Minimum floor
|
|
79
|
+
expect(result.confidence).toBeDefined();
|
|
80
|
+
});
|
|
81
|
+
it("should apply minimum floor of 50 tokens", () => {
|
|
82
|
+
const shortContent = "Hi";
|
|
83
|
+
const result = estimateOutputTokens(shortContent, 5, "generic");
|
|
84
|
+
expect(result.estimated).toBeGreaterThanOrEqual(50);
|
|
85
|
+
});
|
|
86
|
+
it("should apply maximum ceiling of 16000 tokens", () => {
|
|
87
|
+
const longContent = "x".repeat(100000);
|
|
88
|
+
const result = estimateOutputTokens(longContent, 50000, "generic");
|
|
89
|
+
expect(result.estimated).toBeLessThanOrEqual(16000);
|
|
90
|
+
});
|
|
91
|
+
it("should have low confidence for short inputs", () => {
|
|
92
|
+
const shortInput = "Help";
|
|
93
|
+
const result = estimateOutputTokens(shortInput, 50, "generic");
|
|
94
|
+
expect(result.confidence).toBe("low");
|
|
95
|
+
expect(result.reasoning).toContain("Short input");
|
|
96
|
+
});
|
|
97
|
+
it("should adjust for very long inputs", () => {
|
|
98
|
+
const longInput = "x".repeat(50000);
|
|
99
|
+
const result = estimateOutputTokens(longInput, 15000, "generic");
|
|
100
|
+
expect(result.reasoning).toContain("Long input");
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe("getOutputRatio", () => {
|
|
104
|
+
it("should return ratio config for known types", () => {
|
|
105
|
+
const codeRatio = getOutputRatio("code");
|
|
106
|
+
expect(codeRatio.defaultRatio).toBe(0.8);
|
|
107
|
+
const logsRatio = getOutputRatio("logs");
|
|
108
|
+
expect(logsRatio.defaultRatio).toBe(0.2);
|
|
109
|
+
});
|
|
110
|
+
it("should return generic ratio for unknown types", () => {
|
|
111
|
+
const ratio = getOutputRatio("generic");
|
|
112
|
+
expect(ratio.defaultRatio).toBe(0.5);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Similarity Calculator
|
|
3
|
+
*
|
|
4
|
+
* Calculates similarity between command outputs to detect
|
|
5
|
+
* retry loops with similar errors.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate a short hash of the output for quick comparison
|
|
9
|
+
*/
|
|
10
|
+
export declare function hashOutput(output: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Calculate similarity percentage between two hashes
|
|
13
|
+
* Returns 100 if identical, 0 otherwise (hash-based)
|
|
14
|
+
*/
|
|
15
|
+
export declare function calculateHashSimilarity(hash1: string, hash2: string): number;
|
|
16
|
+
/**
|
|
17
|
+
* Count error lines in output (lines containing "error", "Error", "ERROR")
|
|
18
|
+
*/
|
|
19
|
+
export declare function countErrors(output: string): number;
|
|
20
|
+
/**
|
|
21
|
+
* Count warning lines in output
|
|
22
|
+
*/
|
|
23
|
+
export declare function countWarnings(output: string): number;
|
|
24
|
+
/**
|
|
25
|
+
* Extract error count from common build output patterns
|
|
26
|
+
* e.g., "Found 147 errors" or "147 errors"
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractErrorCount(output: string): number | null;
|
|
29
|
+
/**
|
|
30
|
+
* Analyze the trend of errors across multiple outputs
|
|
31
|
+
*/
|
|
32
|
+
export interface ErrorTrendAnalysis {
|
|
33
|
+
trend: "same" | "decreasing" | "increasing" | "fluctuating" | "unknown";
|
|
34
|
+
errorCounts: number[];
|
|
35
|
+
firstCount: number;
|
|
36
|
+
lastCount: number;
|
|
37
|
+
delta: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function analyzeErrorTrend(outputs: string[]): ErrorTrendAnalysis;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate overall similarity between current output and history
|
|
42
|
+
*/
|
|
43
|
+
export declare function calculateOutputSimilarity(historyHashes: string[], currentHash: string): number;
|
|
44
|
+
/**
|
|
45
|
+
* Format a timespan for display
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatTimespan(startTime: Date, endTime: Date | number): string;
|
|
48
|
+
//# sourceMappingURL=output-similarity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-similarity.d.ts","sourceRoot":"","sources":["../../src/utils/output-similarity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAe/D;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC;IACxE,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAwDvE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAQ9F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAe9E"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Similarity Calculator
|
|
3
|
+
*
|
|
4
|
+
* Calculates similarity between command outputs to detect
|
|
5
|
+
* retry loops with similar errors.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from "crypto";
|
|
8
|
+
/**
|
|
9
|
+
* Generate a short hash of the output for quick comparison
|
|
10
|
+
*/
|
|
11
|
+
export function hashOutput(output) {
|
|
12
|
+
return createHash("sha256").update(output).digest("hex").slice(0, 16);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Calculate similarity percentage between two hashes
|
|
16
|
+
* Returns 100 if identical, 0 otherwise (hash-based)
|
|
17
|
+
*/
|
|
18
|
+
export function calculateHashSimilarity(hash1, hash2) {
|
|
19
|
+
return hash1 === hash2 ? 100 : 0;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Count error lines in output (lines containing "error", "Error", "ERROR")
|
|
23
|
+
*/
|
|
24
|
+
export function countErrors(output) {
|
|
25
|
+
const errorPattern = /\b(error|Error|ERROR|fail|Fail|FAIL)\b/gi;
|
|
26
|
+
const lines = output.split("\n");
|
|
27
|
+
return lines.filter((line) => errorPattern.test(line)).length;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Count warning lines in output
|
|
31
|
+
*/
|
|
32
|
+
export function countWarnings(output) {
|
|
33
|
+
const warningPattern = /\b(warning|Warning|WARNING|warn|Warn|WARN)\b/gi;
|
|
34
|
+
const lines = output.split("\n");
|
|
35
|
+
return lines.filter((line) => warningPattern.test(line)).length;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extract error count from common build output patterns
|
|
39
|
+
* e.g., "Found 147 errors" or "147 errors"
|
|
40
|
+
*/
|
|
41
|
+
export function extractErrorCount(output) {
|
|
42
|
+
// TypeScript: "Found X error(s)"
|
|
43
|
+
const tsMatch = output.match(/Found\s+(\d+)\s+error/i);
|
|
44
|
+
if (tsMatch) {
|
|
45
|
+
return parseInt(tsMatch[1] ?? "0", 10);
|
|
46
|
+
}
|
|
47
|
+
// ESLint: "X error(s)"
|
|
48
|
+
const eslintMatch = output.match(/(\d+)\s+error/i);
|
|
49
|
+
if (eslintMatch) {
|
|
50
|
+
return parseInt(eslintMatch[1] ?? "0", 10);
|
|
51
|
+
}
|
|
52
|
+
// Generic: count error lines
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
export function analyzeErrorTrend(outputs) {
|
|
56
|
+
if (outputs.length === 0) {
|
|
57
|
+
return {
|
|
58
|
+
trend: "unknown",
|
|
59
|
+
errorCounts: [],
|
|
60
|
+
firstCount: 0,
|
|
61
|
+
lastCount: 0,
|
|
62
|
+
delta: 0,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const errorCounts = outputs.map((output) => {
|
|
66
|
+
const extracted = extractErrorCount(output);
|
|
67
|
+
return extracted ?? countErrors(output);
|
|
68
|
+
});
|
|
69
|
+
const firstCount = errorCounts[0] ?? 0;
|
|
70
|
+
const lastCount = errorCounts[errorCounts.length - 1] ?? 0;
|
|
71
|
+
const delta = lastCount - firstCount;
|
|
72
|
+
// Determine trend
|
|
73
|
+
let trend = "unknown";
|
|
74
|
+
if (errorCounts.length >= 2) {
|
|
75
|
+
const allSame = errorCounts.every((c) => c === firstCount);
|
|
76
|
+
if (allSame) {
|
|
77
|
+
trend = "same";
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Check if monotonically increasing or decreasing
|
|
81
|
+
let increasing = true;
|
|
82
|
+
let decreasing = true;
|
|
83
|
+
for (let i = 1; i < errorCounts.length; i++) {
|
|
84
|
+
const prev = errorCounts[i - 1] ?? 0;
|
|
85
|
+
const curr = errorCounts[i] ?? 0;
|
|
86
|
+
if (curr < prev)
|
|
87
|
+
increasing = false;
|
|
88
|
+
if (curr > prev)
|
|
89
|
+
decreasing = false;
|
|
90
|
+
}
|
|
91
|
+
if (decreasing && delta < 0) {
|
|
92
|
+
trend = "decreasing";
|
|
93
|
+
}
|
|
94
|
+
else if (increasing && delta > 0) {
|
|
95
|
+
trend = "increasing";
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
trend = "fluctuating";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
trend,
|
|
104
|
+
errorCounts,
|
|
105
|
+
firstCount,
|
|
106
|
+
lastCount,
|
|
107
|
+
delta,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Calculate overall similarity between current output and history
|
|
112
|
+
*/
|
|
113
|
+
export function calculateOutputSimilarity(historyHashes, currentHash) {
|
|
114
|
+
if (historyHashes.length === 0)
|
|
115
|
+
return 0;
|
|
116
|
+
// Count how many previous outputs match exactly
|
|
117
|
+
const matches = historyHashes.filter((h) => h === currentHash).length;
|
|
118
|
+
// Return percentage of matches
|
|
119
|
+
return Math.round((matches / historyHashes.length) * 100);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Format a timespan for display
|
|
123
|
+
*/
|
|
124
|
+
export function formatTimespan(startTime, endTime) {
|
|
125
|
+
const start = startTime.getTime();
|
|
126
|
+
const end = typeof endTime === "number" ? endTime : endTime.getTime();
|
|
127
|
+
const diffMs = end - start;
|
|
128
|
+
if (diffMs < 60000) {
|
|
129
|
+
const seconds = Math.round(diffMs / 1000);
|
|
130
|
+
return `last ${seconds} seconds`;
|
|
131
|
+
}
|
|
132
|
+
else if (diffMs < 3600000) {
|
|
133
|
+
const minutes = Math.round(diffMs / 60000);
|
|
134
|
+
return `last ${minutes} minute${minutes > 1 ? "s" : ""}`;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
const hours = Math.round(diffMs / 3600000);
|
|
138
|
+
return `last ${hours} hour${hours > 1 ? "s" : ""}`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Detector
|
|
3
|
+
*
|
|
4
|
+
* Detects the type of project in the current working directory.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProjectInfo {
|
|
7
|
+
rootPath: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: "node" | "python" | "rust" | "go" | "unknown";
|
|
10
|
+
packageManager?: "npm" | "yarn" | "pnpm" | "bun";
|
|
11
|
+
hasTypeScript: boolean;
|
|
12
|
+
detectedAt: Date;
|
|
13
|
+
}
|
|
14
|
+
export declare function detectProject(rootPath?: string): ProjectInfo | null;
|
|
15
|
+
export declare function getProjectSummary(project: ProjectInfo | null): string;
|
|
16
|
+
//# sourceMappingURL=project-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-detector.d.ts","sourceRoot":"","sources":["../../src/utils/project-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpD,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IACjD,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,IAAI,CAAC;CAClB;AAQD,wBAAgB,aAAa,CAAC,QAAQ,GAAE,MAAsB,GAAG,WAAW,GAAG,IAAI,CA8GlF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM,CAgBrE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Detector
|
|
3
|
+
*
|
|
4
|
+
* Detects the type of project in the current working directory.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync } from "fs";
|
|
7
|
+
import { join, basename } from "path";
|
|
8
|
+
export function detectProject(rootPath = process.cwd()) {
|
|
9
|
+
// Try to detect project type based on config files
|
|
10
|
+
const projectInfo = {
|
|
11
|
+
rootPath,
|
|
12
|
+
name: basename(rootPath),
|
|
13
|
+
type: "unknown",
|
|
14
|
+
hasTypeScript: false,
|
|
15
|
+
detectedAt: new Date(),
|
|
16
|
+
};
|
|
17
|
+
// Check for Node.js project
|
|
18
|
+
const packageJsonPath = join(rootPath, "package.json");
|
|
19
|
+
if (existsSync(packageJsonPath)) {
|
|
20
|
+
try {
|
|
21
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
22
|
+
projectInfo.name = packageJson.name || projectInfo.name;
|
|
23
|
+
projectInfo.type = "node";
|
|
24
|
+
// Check for TypeScript
|
|
25
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
26
|
+
projectInfo.hasTypeScript = "typescript" in deps || existsSync(join(rootPath, "tsconfig.json"));
|
|
27
|
+
// Detect package manager
|
|
28
|
+
if (existsSync(join(rootPath, "bun.lockb")) || existsSync(join(rootPath, "bun.lock"))) {
|
|
29
|
+
projectInfo.packageManager = "bun";
|
|
30
|
+
}
|
|
31
|
+
else if (existsSync(join(rootPath, "pnpm-lock.yaml"))) {
|
|
32
|
+
projectInfo.packageManager = "pnpm";
|
|
33
|
+
}
|
|
34
|
+
else if (existsSync(join(rootPath, "yarn.lock"))) {
|
|
35
|
+
projectInfo.packageManager = "yarn";
|
|
36
|
+
}
|
|
37
|
+
else if (existsSync(join(rootPath, "package-lock.json"))) {
|
|
38
|
+
projectInfo.packageManager = "npm";
|
|
39
|
+
}
|
|
40
|
+
return projectInfo;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Invalid package.json, continue checking other types
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Check for Python project
|
|
47
|
+
if (existsSync(join(rootPath, "pyproject.toml")) ||
|
|
48
|
+
existsSync(join(rootPath, "setup.py")) ||
|
|
49
|
+
existsSync(join(rootPath, "requirements.txt"))) {
|
|
50
|
+
projectInfo.type = "python";
|
|
51
|
+
// Try to get project name from pyproject.toml
|
|
52
|
+
const pyprojectPath = join(rootPath, "pyproject.toml");
|
|
53
|
+
if (existsSync(pyprojectPath)) {
|
|
54
|
+
try {
|
|
55
|
+
const content = readFileSync(pyprojectPath, "utf-8");
|
|
56
|
+
const nameMatch = content.match(/name\s*=\s*["']([^"']+)["']/);
|
|
57
|
+
if (nameMatch?.[1]) {
|
|
58
|
+
projectInfo.name = nameMatch[1];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Ignore parsing errors
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return projectInfo;
|
|
66
|
+
}
|
|
67
|
+
// Check for Rust project
|
|
68
|
+
if (existsSync(join(rootPath, "Cargo.toml"))) {
|
|
69
|
+
projectInfo.type = "rust";
|
|
70
|
+
try {
|
|
71
|
+
const cargoToml = readFileSync(join(rootPath, "Cargo.toml"), "utf-8");
|
|
72
|
+
const nameMatch = cargoToml.match(/name\s*=\s*["']([^"']+)["']/);
|
|
73
|
+
if (nameMatch?.[1]) {
|
|
74
|
+
projectInfo.name = nameMatch[1];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Ignore parsing errors
|
|
79
|
+
}
|
|
80
|
+
return projectInfo;
|
|
81
|
+
}
|
|
82
|
+
// Check for Go project
|
|
83
|
+
if (existsSync(join(rootPath, "go.mod"))) {
|
|
84
|
+
projectInfo.type = "go";
|
|
85
|
+
try {
|
|
86
|
+
const goMod = readFileSync(join(rootPath, "go.mod"), "utf-8");
|
|
87
|
+
const moduleMatch = goMod.match(/module\s+(\S+)/);
|
|
88
|
+
if (moduleMatch?.[1]) {
|
|
89
|
+
const modulePath = moduleMatch[1];
|
|
90
|
+
projectInfo.name = modulePath.split("/").pop() ?? modulePath;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Ignore parsing errors
|
|
95
|
+
}
|
|
96
|
+
return projectInfo;
|
|
97
|
+
}
|
|
98
|
+
// If we found any config files but couldn't determine type
|
|
99
|
+
if (existsSync(join(rootPath, ".git")) ||
|
|
100
|
+
existsSync(join(rootPath, "README.md")) ||
|
|
101
|
+
existsSync(join(rootPath, "Makefile"))) {
|
|
102
|
+
return projectInfo;
|
|
103
|
+
}
|
|
104
|
+
// No project detected
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
export function getProjectSummary(project) {
|
|
108
|
+
if (!project) {
|
|
109
|
+
return "No project detected in current directory.";
|
|
110
|
+
}
|
|
111
|
+
const parts = [`**${project.name}** (${project.type})`];
|
|
112
|
+
if (project.packageManager) {
|
|
113
|
+
parts.push(`Package Manager: ${project.packageManager}`);
|
|
114
|
+
}
|
|
115
|
+
if (project.hasTypeScript) {
|
|
116
|
+
parts.push("TypeScript enabled");
|
|
117
|
+
}
|
|
118
|
+
return parts.join(" | ");
|
|
119
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segment Scorer
|
|
3
|
+
*
|
|
4
|
+
* Combines multiple scoring signals to determine segment importance:
|
|
5
|
+
* - TF-IDF: Unique/rare terms are more important
|
|
6
|
+
* - Position: Beginning and end of content are more important
|
|
7
|
+
* - Keywords: Errors, instructions, code blocks get priority
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Segment types based on content structure
|
|
11
|
+
*/
|
|
12
|
+
export type SegmentType = "sentence" | "line" | "paragraph" | "code-block";
|
|
13
|
+
/**
|
|
14
|
+
* A segment of content with metadata
|
|
15
|
+
*/
|
|
16
|
+
export interface Segment {
|
|
17
|
+
text: string;
|
|
18
|
+
startLine: number;
|
|
19
|
+
endLine: number;
|
|
20
|
+
type: SegmentType;
|
|
21
|
+
/** Normalized position in document (0-1) */
|
|
22
|
+
position: number;
|
|
23
|
+
/** Token count for this segment */
|
|
24
|
+
tokens: number;
|
|
25
|
+
/** Whether this segment matches a preserve pattern */
|
|
26
|
+
isPreserved: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Segment with calculated importance scores
|
|
30
|
+
*/
|
|
31
|
+
export interface ScoredSegment extends Segment {
|
|
32
|
+
/** Combined importance score (0-1) */
|
|
33
|
+
importance: number;
|
|
34
|
+
/** Individual score components */
|
|
35
|
+
scores: {
|
|
36
|
+
tfidf: number;
|
|
37
|
+
position: number;
|
|
38
|
+
keyword: number;
|
|
39
|
+
combined: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Weights for combining different scoring signals
|
|
44
|
+
*/
|
|
45
|
+
export interface ScoringWeights {
|
|
46
|
+
tfidf: number;
|
|
47
|
+
position: number;
|
|
48
|
+
keyword: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Default scoring weights (must sum to 1.0)
|
|
52
|
+
*/
|
|
53
|
+
export declare const DEFAULT_WEIGHTS: ScoringWeights;
|
|
54
|
+
/**
|
|
55
|
+
* Calculate position weight using a U-shaped curve
|
|
56
|
+
* Beginning (0-10%) and end (90-100%) get highest weight
|
|
57
|
+
* Middle content gets lower weight
|
|
58
|
+
*
|
|
59
|
+
* @param position - Normalized position (0-1)
|
|
60
|
+
* @returns Position weight (0.6-1.0)
|
|
61
|
+
*/
|
|
62
|
+
export declare function calculatePositionWeight(position: number): number;
|
|
63
|
+
/**
|
|
64
|
+
* Calculate keyword boost based on content patterns
|
|
65
|
+
* Multiple matches compound additively up to 1.0
|
|
66
|
+
*
|
|
67
|
+
* @param text - Segment text to analyze
|
|
68
|
+
* @returns Keyword boost (0-1)
|
|
69
|
+
*/
|
|
70
|
+
export declare function calculateKeywordBoost(text: string): number;
|
|
71
|
+
/**
|
|
72
|
+
* Create a segment from text
|
|
73
|
+
*
|
|
74
|
+
* @param text - Segment text
|
|
75
|
+
* @param startLine - Starting line number
|
|
76
|
+
* @param endLine - Ending line number
|
|
77
|
+
* @param type - Segment type
|
|
78
|
+
* @param totalLines - Total lines in document (for position calculation)
|
|
79
|
+
* @returns Segment object
|
|
80
|
+
*/
|
|
81
|
+
export declare function createSegment(text: string, startLine: number, endLine: number, type: SegmentType, totalLines: number): Segment;
|
|
82
|
+
/**
|
|
83
|
+
* Score a segment combining all signals
|
|
84
|
+
*
|
|
85
|
+
* @param segment - Segment to score
|
|
86
|
+
* @param tfidfScore - Pre-calculated TF-IDF score (0-1)
|
|
87
|
+
* @param weights - Scoring weights
|
|
88
|
+
* @returns Scored segment with importance
|
|
89
|
+
*/
|
|
90
|
+
export declare function scoreSegment(segment: Segment, tfidfScore: number, weights?: ScoringWeights): ScoredSegment;
|
|
91
|
+
/**
|
|
92
|
+
* Check if text contains error indicators
|
|
93
|
+
*/
|
|
94
|
+
export declare function hasErrorIndicators(text: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Check if text contains instruction indicators
|
|
97
|
+
*/
|
|
98
|
+
export declare function hasInstructionIndicators(text: string): boolean;
|
|
99
|
+
//# sourceMappingURL=segment-scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment-scorer.d.ts","sourceRoot":"","sources":["../../src/utils/segment-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,WAAW,CAAC;IAClB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAI7B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYhE;AA+BD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0B1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAUT;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,cAAgC,GACxC,aAAa,CAoBf;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D"}
|