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,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript Parser
|
|
3
|
+
*
|
|
4
|
+
* Uses TypeScript Compiler API for accurate AST parsing.
|
|
5
|
+
*/
|
|
6
|
+
import ts from "typescript";
|
|
7
|
+
import { createEmptyStructure } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Get line number from position in source file
|
|
10
|
+
*/
|
|
11
|
+
function getLineNumber(sourceFile, pos) {
|
|
12
|
+
return sourceFile.getLineAndCharacterOfPosition(pos).line + 1;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get JSDoc comment for a node
|
|
16
|
+
*/
|
|
17
|
+
function getJSDoc(node) {
|
|
18
|
+
// Use ts.getJSDocCommentsAndTags which works across all node types
|
|
19
|
+
const jsDocs = ts.getJSDocCommentsAndTags(node);
|
|
20
|
+
if (jsDocs && jsDocs.length > 0) {
|
|
21
|
+
return jsDocs.map((doc) => doc.getText()).join("\n");
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if a node has an export modifier
|
|
27
|
+
*/
|
|
28
|
+
function isExported(node) {
|
|
29
|
+
const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined;
|
|
30
|
+
return modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if a function is async
|
|
34
|
+
*/
|
|
35
|
+
function isAsync(node) {
|
|
36
|
+
const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined;
|
|
37
|
+
return modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) ?? false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get function signature
|
|
41
|
+
*/
|
|
42
|
+
function getFunctionSignature(node, sourceFile) {
|
|
43
|
+
const params = node.parameters.map((p) => p.getText(sourceFile)).join(", ");
|
|
44
|
+
const returnType = node.type ? `: ${node.type.getText(sourceFile)}` : "";
|
|
45
|
+
const asyncMod = isAsync(node) ? "async " : "";
|
|
46
|
+
if (ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node)) {
|
|
47
|
+
const name = node.name?.getText(sourceFile) ?? "anonymous";
|
|
48
|
+
return `${asyncMod}function ${name}(${params})${returnType}`;
|
|
49
|
+
}
|
|
50
|
+
return `${asyncMod}(${params})${returnType} =>`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Parse TypeScript/JavaScript content into FileStructure
|
|
54
|
+
* @param options ParseOptions - set detailed: true to extract signature/documentation
|
|
55
|
+
*/
|
|
56
|
+
export function parseTypeScript(content, isTypeScript = true, options = {}) {
|
|
57
|
+
const { detailed = false } = options;
|
|
58
|
+
const sourceFile = ts.createSourceFile(isTypeScript ? "temp.ts" : "temp.js", content, ts.ScriptTarget.Latest, true, isTypeScript ? ts.ScriptKind.TS : ts.ScriptKind.JS);
|
|
59
|
+
const language = isTypeScript ? "typescript" : "javascript";
|
|
60
|
+
const structure = createEmptyStructure(language, content.split("\n").length);
|
|
61
|
+
function visit(node, parentClass) {
|
|
62
|
+
const startLine = getLineNumber(sourceFile, node.getStart(sourceFile));
|
|
63
|
+
const endLine = getLineNumber(sourceFile, node.getEnd());
|
|
64
|
+
// Import declarations
|
|
65
|
+
if (ts.isImportDeclaration(node)) {
|
|
66
|
+
const importClause = node.importClause;
|
|
67
|
+
const moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['"]/g, "");
|
|
68
|
+
if (importClause) {
|
|
69
|
+
// Default import
|
|
70
|
+
if (importClause.name) {
|
|
71
|
+
const imp = {
|
|
72
|
+
type: "import",
|
|
73
|
+
name: importClause.name.getText(sourceFile),
|
|
74
|
+
startLine,
|
|
75
|
+
endLine,
|
|
76
|
+
};
|
|
77
|
+
if (detailed) {
|
|
78
|
+
imp.signature = `import ${importClause.name.getText(sourceFile)} from "${moduleSpecifier}"`;
|
|
79
|
+
}
|
|
80
|
+
structure.imports.push(imp);
|
|
81
|
+
}
|
|
82
|
+
// Named imports
|
|
83
|
+
if (importClause.namedBindings && ts.isNamedImports(importClause.namedBindings)) {
|
|
84
|
+
for (const element of importClause.namedBindings.elements) {
|
|
85
|
+
const imp = {
|
|
86
|
+
type: "import",
|
|
87
|
+
name: element.name.getText(sourceFile),
|
|
88
|
+
startLine,
|
|
89
|
+
endLine,
|
|
90
|
+
};
|
|
91
|
+
if (detailed) {
|
|
92
|
+
imp.signature = `import { ${element.name.getText(sourceFile)} } from "${moduleSpecifier}"`;
|
|
93
|
+
}
|
|
94
|
+
structure.imports.push(imp);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Function declarations
|
|
100
|
+
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
101
|
+
const fn = {
|
|
102
|
+
type: "function",
|
|
103
|
+
name: node.name.getText(sourceFile),
|
|
104
|
+
startLine,
|
|
105
|
+
endLine,
|
|
106
|
+
isExported: isExported(node),
|
|
107
|
+
isAsync: isAsync(node),
|
|
108
|
+
};
|
|
109
|
+
if (detailed) {
|
|
110
|
+
fn.signature = getFunctionSignature(node, sourceFile);
|
|
111
|
+
fn.documentation = getJSDoc(node);
|
|
112
|
+
}
|
|
113
|
+
structure.functions.push(fn);
|
|
114
|
+
}
|
|
115
|
+
// Variable declarations with arrow functions
|
|
116
|
+
if (ts.isVariableStatement(node)) {
|
|
117
|
+
for (const decl of node.declarationList.declarations) {
|
|
118
|
+
if (decl.name && ts.isIdentifier(decl.name)) {
|
|
119
|
+
const name = decl.name.getText(sourceFile);
|
|
120
|
+
if (decl.initializer && ts.isArrowFunction(decl.initializer)) {
|
|
121
|
+
const fn = {
|
|
122
|
+
type: "function",
|
|
123
|
+
name,
|
|
124
|
+
startLine,
|
|
125
|
+
endLine,
|
|
126
|
+
isExported: isExported(node),
|
|
127
|
+
isAsync: isAsync(decl.initializer),
|
|
128
|
+
};
|
|
129
|
+
if (detailed) {
|
|
130
|
+
fn.signature = `const ${name} = ${getFunctionSignature(decl.initializer, sourceFile)}`;
|
|
131
|
+
fn.documentation = getJSDoc(node);
|
|
132
|
+
}
|
|
133
|
+
structure.functions.push(fn);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
structure.variables.push({
|
|
137
|
+
type: "variable",
|
|
138
|
+
name,
|
|
139
|
+
startLine,
|
|
140
|
+
endLine,
|
|
141
|
+
isExported: isExported(node),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Class declarations
|
|
148
|
+
if (ts.isClassDeclaration(node) && node.name) {
|
|
149
|
+
const className = node.name.getText(sourceFile);
|
|
150
|
+
const cls = {
|
|
151
|
+
type: "class",
|
|
152
|
+
name: className,
|
|
153
|
+
startLine,
|
|
154
|
+
endLine,
|
|
155
|
+
isExported: isExported(node),
|
|
156
|
+
};
|
|
157
|
+
if (detailed) {
|
|
158
|
+
cls.documentation = getJSDoc(node);
|
|
159
|
+
}
|
|
160
|
+
structure.classes.push(cls);
|
|
161
|
+
// Visit class members
|
|
162
|
+
for (const member of node.members) {
|
|
163
|
+
if (ts.isMethodDeclaration(member) && member.name) {
|
|
164
|
+
const methodName = member.name.getText(sourceFile);
|
|
165
|
+
const methodStart = getLineNumber(sourceFile, member.getStart(sourceFile));
|
|
166
|
+
const methodEnd = getLineNumber(sourceFile, member.getEnd());
|
|
167
|
+
const method = {
|
|
168
|
+
type: "method",
|
|
169
|
+
name: methodName,
|
|
170
|
+
startLine: methodStart,
|
|
171
|
+
endLine: methodEnd,
|
|
172
|
+
isAsync: isAsync(member),
|
|
173
|
+
parent: className,
|
|
174
|
+
};
|
|
175
|
+
if (detailed) {
|
|
176
|
+
method.signature = getFunctionSignature(member, sourceFile);
|
|
177
|
+
method.documentation = getJSDoc(member);
|
|
178
|
+
}
|
|
179
|
+
structure.functions.push(method);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Interface declarations
|
|
184
|
+
if (ts.isInterfaceDeclaration(node) && node.name) {
|
|
185
|
+
const iface = {
|
|
186
|
+
type: "interface",
|
|
187
|
+
name: node.name.getText(sourceFile),
|
|
188
|
+
startLine,
|
|
189
|
+
endLine,
|
|
190
|
+
isExported: isExported(node),
|
|
191
|
+
};
|
|
192
|
+
if (detailed) {
|
|
193
|
+
iface.documentation = getJSDoc(node);
|
|
194
|
+
}
|
|
195
|
+
structure.interfaces.push(iface);
|
|
196
|
+
}
|
|
197
|
+
// Type alias declarations
|
|
198
|
+
if (ts.isTypeAliasDeclaration(node) && node.name) {
|
|
199
|
+
const typeAlias = {
|
|
200
|
+
type: "type",
|
|
201
|
+
name: node.name.getText(sourceFile),
|
|
202
|
+
startLine,
|
|
203
|
+
endLine,
|
|
204
|
+
isExported: isExported(node),
|
|
205
|
+
};
|
|
206
|
+
if (detailed) {
|
|
207
|
+
typeAlias.documentation = getJSDoc(node);
|
|
208
|
+
}
|
|
209
|
+
structure.types.push(typeAlias);
|
|
210
|
+
}
|
|
211
|
+
// Export declarations
|
|
212
|
+
if (ts.isExportDeclaration(node)) {
|
|
213
|
+
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
214
|
+
for (const element of node.exportClause.elements) {
|
|
215
|
+
structure.exports.push({
|
|
216
|
+
type: "export",
|
|
217
|
+
name: element.name.getText(sourceFile),
|
|
218
|
+
startLine,
|
|
219
|
+
endLine,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
ts.forEachChild(node, (child) => visit(child, parentClass));
|
|
225
|
+
}
|
|
226
|
+
visit(sourceFile);
|
|
227
|
+
return structure;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Find identifiers used in a code snippet
|
|
231
|
+
*/
|
|
232
|
+
function findUsedIdentifiers(code) {
|
|
233
|
+
const identifiers = new Set();
|
|
234
|
+
// Simple regex to find potential identifiers (not perfect but good enough)
|
|
235
|
+
const matches = code.match(/\b[A-Za-z_][A-Za-z0-9_]*\b/g);
|
|
236
|
+
if (matches) {
|
|
237
|
+
matches.forEach((m) => identifiers.add(m));
|
|
238
|
+
}
|
|
239
|
+
return identifiers;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Find related imports for extracted code
|
|
243
|
+
*/
|
|
244
|
+
function findRelatedImports(content, structure, extractedCode) {
|
|
245
|
+
const usedIds = findUsedIdentifiers(extractedCode);
|
|
246
|
+
const lines = content.split("\n");
|
|
247
|
+
const imports = [];
|
|
248
|
+
for (const imp of structure.imports) {
|
|
249
|
+
if (usedIds.has(imp.name)) {
|
|
250
|
+
const importLine = lines[imp.startLine - 1];
|
|
251
|
+
if (importLine && !imports.includes(importLine)) {
|
|
252
|
+
imports.push(importLine);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return imports;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Extract a specific element from TypeScript content
|
|
260
|
+
*/
|
|
261
|
+
export function extractTypeScriptElement(content, target, options, isTypeScript = true) {
|
|
262
|
+
// Extraction needs detailed parsing for proper signature/documentation display
|
|
263
|
+
const structure = parseTypeScript(content, isTypeScript, { detailed: true });
|
|
264
|
+
// Find the target element
|
|
265
|
+
let element;
|
|
266
|
+
switch (target.type) {
|
|
267
|
+
case "function":
|
|
268
|
+
case "method":
|
|
269
|
+
element = structure.functions.find((f) => f.name === target.name);
|
|
270
|
+
break;
|
|
271
|
+
case "class":
|
|
272
|
+
element = structure.classes.find((c) => c.name === target.name);
|
|
273
|
+
break;
|
|
274
|
+
case "interface":
|
|
275
|
+
element = structure.interfaces.find((i) => i.name === target.name);
|
|
276
|
+
break;
|
|
277
|
+
case "type":
|
|
278
|
+
element = structure.types.find((t) => t.name === target.name);
|
|
279
|
+
break;
|
|
280
|
+
case "variable":
|
|
281
|
+
element = structure.variables.find((v) => v.name === target.name);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
if (!element) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
const lines = content.split("\n");
|
|
288
|
+
// Include documentation if present and requested
|
|
289
|
+
let startLine = element.startLine;
|
|
290
|
+
if (options.includeComments && element.documentation) {
|
|
291
|
+
// Look for JSDoc above the element
|
|
292
|
+
for (let i = element.startLine - 2; i >= 0; i--) {
|
|
293
|
+
const line = lines[i]?.trim() ?? "";
|
|
294
|
+
if (line.startsWith("/**") || line.startsWith("*") || line.startsWith("*/")) {
|
|
295
|
+
startLine = i + 1;
|
|
296
|
+
}
|
|
297
|
+
else if (line === "") {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const extractedLines = lines.slice(startLine - 1, element.endLine);
|
|
306
|
+
const extractedCode = extractedLines.join("\n");
|
|
307
|
+
// Find related imports
|
|
308
|
+
const relatedImports = options.includeImports
|
|
309
|
+
? findRelatedImports(content, structure, extractedCode)
|
|
310
|
+
: [];
|
|
311
|
+
return {
|
|
312
|
+
content: extractedCode,
|
|
313
|
+
elements: [element],
|
|
314
|
+
relatedImports,
|
|
315
|
+
startLine,
|
|
316
|
+
endLine: element.endLine,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Search for elements matching a query
|
|
321
|
+
*/
|
|
322
|
+
export function searchTypeScriptElements(content, query) {
|
|
323
|
+
// Search needs detailed parsing to match against signature/documentation
|
|
324
|
+
const structure = parseTypeScript(content, true, { detailed: true });
|
|
325
|
+
const queryLower = query.toLowerCase();
|
|
326
|
+
const results = [];
|
|
327
|
+
const allElements = [
|
|
328
|
+
...structure.functions,
|
|
329
|
+
...structure.classes,
|
|
330
|
+
...structure.interfaces,
|
|
331
|
+
...structure.types,
|
|
332
|
+
...structure.variables,
|
|
333
|
+
];
|
|
334
|
+
for (const element of allElements) {
|
|
335
|
+
if (element.name.toLowerCase().includes(queryLower) ||
|
|
336
|
+
element.signature?.toLowerCase().includes(queryLower) ||
|
|
337
|
+
element.documentation?.toLowerCase().includes(queryLower)) {
|
|
338
|
+
results.push(element);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return results;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* TypeScript parser implementation
|
|
345
|
+
*/
|
|
346
|
+
export const typescriptParser = {
|
|
347
|
+
languages: ["typescript", "javascript"],
|
|
348
|
+
parse(content, options) {
|
|
349
|
+
return parseTypeScript(content, true, options);
|
|
350
|
+
},
|
|
351
|
+
extractElement(content, target, options) {
|
|
352
|
+
return extractTypeScriptElement(content, target, options, true);
|
|
353
|
+
},
|
|
354
|
+
searchElements(content, query) {
|
|
355
|
+
return searchTypeScriptElements(content, query);
|
|
356
|
+
},
|
|
357
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Hash Utilities
|
|
3
|
+
*
|
|
4
|
+
* Computes fast file hashes for cache validation.
|
|
5
|
+
* Uses a combination of file stats (mtime, size) for speed,
|
|
6
|
+
* with optional content hash for accuracy.
|
|
7
|
+
*/
|
|
8
|
+
import type { FileHashInfo } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Compute a fast hash based on file stats (mtime + size)
|
|
11
|
+
* This is fast but may miss in-place edits with same size
|
|
12
|
+
*
|
|
13
|
+
* @param filePath - Path to the file
|
|
14
|
+
* @returns FileHashInfo or null if file doesn't exist
|
|
15
|
+
*/
|
|
16
|
+
export declare function computeFastFileHash(filePath: string): Promise<FileHashInfo | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Compute a content-based hash (slower but accurate)
|
|
19
|
+
* Use for critical files or when fast hash fails validation
|
|
20
|
+
*
|
|
21
|
+
* @param filePath - Path to the file
|
|
22
|
+
* @returns MD5 hash string or null if file doesn't exist
|
|
23
|
+
*/
|
|
24
|
+
export declare function computeContentHash(filePath: string): Promise<string | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Validate if a file has changed since the hash was computed
|
|
27
|
+
*
|
|
28
|
+
* @param filePath - Path to the file
|
|
29
|
+
* @param storedHash - Previously computed hash to compare against
|
|
30
|
+
* @returns true if file is unchanged, false if changed or doesn't exist
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateFileHash(filePath: string, storedHash: string): Promise<boolean>;
|
|
33
|
+
//# sourceMappingURL=file-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-hash.d.ts","sourceRoot":"","sources":["../../src/cache/file-hash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAY9B;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOxB;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,CAIlB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Hash Utilities
|
|
3
|
+
*
|
|
4
|
+
* Computes fast file hashes for cache validation.
|
|
5
|
+
* Uses a combination of file stats (mtime, size) for speed,
|
|
6
|
+
* with optional content hash for accuracy.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from "fs/promises";
|
|
9
|
+
import * as crypto from "crypto";
|
|
10
|
+
/**
|
|
11
|
+
* Compute a fast hash based on file stats (mtime + size)
|
|
12
|
+
* This is fast but may miss in-place edits with same size
|
|
13
|
+
*
|
|
14
|
+
* @param filePath - Path to the file
|
|
15
|
+
* @returns FileHashInfo or null if file doesn't exist
|
|
16
|
+
*/
|
|
17
|
+
export async function computeFastFileHash(filePath) {
|
|
18
|
+
try {
|
|
19
|
+
const stats = await fs.stat(filePath);
|
|
20
|
+
const hash = `${stats.mtimeMs}-${stats.size}`;
|
|
21
|
+
return {
|
|
22
|
+
hash,
|
|
23
|
+
mtime: stats.mtimeMs,
|
|
24
|
+
size: stats.size,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Compute a content-based hash (slower but accurate)
|
|
33
|
+
* Use for critical files or when fast hash fails validation
|
|
34
|
+
*
|
|
35
|
+
* @param filePath - Path to the file
|
|
36
|
+
* @returns MD5 hash string or null if file doesn't exist
|
|
37
|
+
*/
|
|
38
|
+
export async function computeContentHash(filePath) {
|
|
39
|
+
try {
|
|
40
|
+
const content = await fs.readFile(filePath);
|
|
41
|
+
return crypto.createHash("md5").update(content).digest("hex");
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validate if a file has changed since the hash was computed
|
|
49
|
+
*
|
|
50
|
+
* @param filePath - Path to the file
|
|
51
|
+
* @param storedHash - Previously computed hash to compare against
|
|
52
|
+
* @returns true if file is unchanged, false if changed or doesn't exist
|
|
53
|
+
*/
|
|
54
|
+
export async function validateFileHash(filePath, storedHash) {
|
|
55
|
+
const currentHash = await computeFastFileHash(filePath);
|
|
56
|
+
if (!currentHash)
|
|
57
|
+
return false;
|
|
58
|
+
return currentHash.hash === storedHash;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Cache Implementation
|
|
3
|
+
*
|
|
4
|
+
* LRU cache with TTL and file hash validation.
|
|
5
|
+
* Designed for caching parsed file content but works for any data.
|
|
6
|
+
*/
|
|
7
|
+
import type { CacheStats, CacheConfig, CacheKey, CacheGetResult, SmartCacheOptions } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Smart Cache class with LRU eviction, TTL expiration, and file hash validation
|
|
10
|
+
*/
|
|
11
|
+
export declare class SmartCache {
|
|
12
|
+
private cache;
|
|
13
|
+
private config;
|
|
14
|
+
private stats;
|
|
15
|
+
private operationCount;
|
|
16
|
+
constructor(config?: Partial<CacheConfig>);
|
|
17
|
+
/**
|
|
18
|
+
* Get a value from cache with automatic validation
|
|
19
|
+
*/
|
|
20
|
+
get<T>(key: CacheKey): Promise<CacheGetResult<T>>;
|
|
21
|
+
/**
|
|
22
|
+
* Set a value in cache
|
|
23
|
+
*/
|
|
24
|
+
set<T>(key: CacheKey, value: T, options?: SmartCacheOptions): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Invalidate a specific cache entry
|
|
27
|
+
*/
|
|
28
|
+
invalidate(key: CacheKey): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Invalidate all entries for a specific file path
|
|
31
|
+
*/
|
|
32
|
+
invalidateByPath(filePath: string): number;
|
|
33
|
+
/**
|
|
34
|
+
* Clear all cache entries
|
|
35
|
+
*/
|
|
36
|
+
clear(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Get cache statistics
|
|
39
|
+
*/
|
|
40
|
+
getStats(): CacheStats;
|
|
41
|
+
/**
|
|
42
|
+
* Get list of cached keys (for debugging/inspection)
|
|
43
|
+
*/
|
|
44
|
+
getKeys(): CacheKey[];
|
|
45
|
+
/**
|
|
46
|
+
* Check if a key exists (without updating access time)
|
|
47
|
+
*/
|
|
48
|
+
has(key: CacheKey): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get the number of entries in cache
|
|
51
|
+
*/
|
|
52
|
+
get size(): number;
|
|
53
|
+
private updateHitRate;
|
|
54
|
+
private estimateSize;
|
|
55
|
+
private ensureCapacity;
|
|
56
|
+
private evictLRU;
|
|
57
|
+
private maybeCleanup;
|
|
58
|
+
private cleanupExpired;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the global cache instance (creates one if needed)
|
|
62
|
+
*/
|
|
63
|
+
export declare function getGlobalCache(): SmartCache;
|
|
64
|
+
/**
|
|
65
|
+
* Reset the global cache (for testing or explicit reset)
|
|
66
|
+
*/
|
|
67
|
+
export declare function resetGlobalCache(): void;
|
|
68
|
+
//# sourceMappingURL=smart-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-cache.d.ts","sourceRoot":"","sources":["../../src/cache/smart-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAEV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAYpB;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,cAAc,CAAS;gBAEnB,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM;IAgB7C;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAuDvD;;OAEG;IACG,GAAG,CAAC,CAAC,EACT,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC;IA6ChB;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO;IAYlC;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAc1C;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,QAAQ,IAAI,UAAU;IAItB;;OAEG;IACH,OAAO,IAAI,QAAQ,EAAE;IAIrB;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO;IAI3B;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAID,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,YAAY;YAUN,cAAc;IAe5B,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,cAAc;CAWvB;AAKD;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,CAK3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
|