codesift-mcp 0.14.0 → 0.15.0
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/README.md +5 -1
- package/dist/cli/commands-admin.d.ts +18 -0
- package/dist/cli/commands-admin.d.ts.map +1 -0
- package/dist/cli/commands-admin.js +187 -0
- package/dist/cli/commands-admin.js.map +1 -0
- package/dist/cli/commands-daemon.d.ts +42 -0
- package/dist/cli/commands-daemon.d.ts.map +1 -0
- package/dist/cli/commands-daemon.js +163 -0
- package/dist/cli/commands-daemon.js.map +1 -0
- package/dist/cli/commands-index.d.ts +12 -0
- package/dist/cli/commands-index.d.ts.map +1 -0
- package/dist/cli/commands-index.js +133 -0
- package/dist/cli/commands-index.js.map +1 -0
- package/dist/cli/commands-maintenance.d.ts +12 -0
- package/dist/cli/commands-maintenance.d.ts.map +1 -0
- package/dist/cli/commands-maintenance.js +409 -0
- package/dist/cli/commands-maintenance.js.map +1 -0
- package/dist/cli/commands-query.d.ts +21 -0
- package/dist/cli/commands-query.d.ts.map +1 -0
- package/dist/cli/commands-query.js +270 -0
- package/dist/cli/commands-query.js.map +1 -0
- package/dist/cli/commands.d.ts +2 -36
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +8 -867
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/embed-child.js +13 -2
- package/dist/cli/embed-child.js.map +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/instructions.d.ts.map +1 -1
- package/dist/instructions.js +5 -2
- package/dist/instructions.js.map +1 -1
- package/dist/parser/extractors/php-class-metadata.d.ts +10 -0
- package/dist/parser/extractors/php-class-metadata.d.ts.map +1 -0
- package/dist/parser/extractors/php-class-metadata.js +65 -0
- package/dist/parser/extractors/php-class-metadata.js.map +1 -0
- package/dist/parser/extractors/php-doc.d.ts +13 -0
- package/dist/parser/extractors/php-doc.d.ts.map +1 -0
- package/dist/parser/extractors/php-doc.js +39 -0
- package/dist/parser/extractors/php-doc.js.map +1 -0
- package/dist/parser/extractors/php-node-metadata.d.ts +26 -0
- package/dist/parser/extractors/php-node-metadata.d.ts.map +1 -0
- package/dist/parser/extractors/php-node-metadata.js +132 -0
- package/dist/parser/extractors/php-node-metadata.js.map +1 -0
- package/dist/parser/extractors/php-symbol-builders.d.ts +13 -0
- package/dist/parser/extractors/php-symbol-builders.d.ts.map +1 -0
- package/dist/parser/extractors/php-symbol-builders.js +58 -0
- package/dist/parser/extractors/php-symbol-builders.js.map +1 -0
- package/dist/parser/extractors/php-walker.d.ts +4 -0
- package/dist/parser/extractors/php-walker.d.ts.map +1 -0
- package/dist/parser/extractors/php-walker.js +238 -0
- package/dist/parser/extractors/php-walker.js.map +1 -0
- package/dist/parser/extractors/php.d.ts +2 -33
- package/dist/parser/extractors/php.d.ts.map +1 -1
- package/dist/parser/extractors/php.js +2 -747
- package/dist/parser/extractors/php.js.map +1 -1
- package/dist/register-tool-loaders.d.ts +11 -11
- package/dist/register-tool-loaders.d.ts.map +1 -1
- package/dist/register-tools/runtime.d.ts +11 -0
- package/dist/register-tools/runtime.d.ts.map +1 -1
- package/dist/register-tools/runtime.js +40 -0
- package/dist/register-tools/runtime.js.map +1 -1
- package/dist/register-tools.d.ts.map +1 -1
- package/dist/register-tools.js +5 -1
- package/dist/register-tools.js.map +1 -1
- package/dist/retrieval/semantic-handlers.d.ts.map +1 -1
- package/dist/retrieval/semantic-handlers.js +10 -3
- package/dist/retrieval/semantic-handlers.js.map +1 -1
- package/dist/search/semantic.d.ts +2 -0
- package/dist/search/semantic.d.ts.map +1 -1
- package/dist/search/semantic.js +41 -9
- package/dist/search/semantic.js.map +1 -1
- package/dist/storage/chunk-store.d.ts +14 -2
- package/dist/storage/chunk-store.d.ts.map +1 -1
- package/dist/storage/chunk-store.js +214 -34
- package/dist/storage/chunk-store.js.map +1 -1
- package/dist/storage/embedding-store.d.ts +0 -12
- package/dist/storage/embedding-store.d.ts.map +1 -1
- package/dist/storage/embedding-store.js +69 -9
- package/dist/storage/embedding-store.js.map +1 -1
- package/dist/storage/index-cache.d.ts +12 -0
- package/dist/storage/index-cache.d.ts.map +1 -0
- package/dist/storage/index-cache.js +89 -0
- package/dist/storage/index-cache.js.map +1 -0
- package/dist/storage/index-json-mutations.d.ts +11 -0
- package/dist/storage/index-json-mutations.d.ts.map +1 -0
- package/dist/storage/index-json-mutations.js +93 -0
- package/dist/storage/index-json-mutations.js.map +1 -0
- package/dist/storage/index-migration.d.ts +22 -0
- package/dist/storage/index-migration.d.ts.map +1 -0
- package/dist/storage/index-migration.js +80 -0
- package/dist/storage/index-migration.js.map +1 -0
- package/dist/storage/index-store.d.ts +5 -61
- package/dist/storage/index-store.d.ts.map +1 -1
- package/dist/storage/index-store.js +33 -414
- package/dist/storage/index-store.js.map +1 -1
- package/dist/storage/index-version.d.ts +39 -0
- package/dist/storage/index-version.d.ts.map +1 -0
- package/dist/storage/index-version.js +87 -0
- package/dist/storage/index-version.js.map +1 -0
- package/dist/storage/registry.d.ts +9 -1
- package/dist/storage/registry.d.ts.map +1 -1
- package/dist/storage/registry.js +169 -8
- package/dist/storage/registry.js.map +1 -1
- package/dist/storage/shared-embedding-cache.d.ts +23 -3
- package/dist/storage/shared-embedding-cache.d.ts.map +1 -1
- package/dist/storage/shared-embedding-cache.js +300 -45
- package/dist/storage/shared-embedding-cache.js.map +1 -1
- package/dist/storage/telemetry/config.d.ts.map +1 -1
- package/dist/storage/telemetry/config.js +3 -2
- package/dist/storage/telemetry/config.js.map +1 -1
- package/dist/storage/telemetry/retro-aggregator.d.ts +21 -0
- package/dist/storage/telemetry/retro-aggregator.d.ts.map +1 -1
- package/dist/storage/telemetry/retro-aggregator.js +58 -16
- package/dist/storage/telemetry/retro-aggregator.js.map +1 -1
- package/dist/storage/telemetry/sanitizer.d.ts +16 -0
- package/dist/storage/telemetry/sanitizer.d.ts.map +1 -1
- package/dist/storage/telemetry/sanitizer.js +2 -0
- package/dist/storage/telemetry/sanitizer.js.map +1 -1
- package/dist/storage/telemetry/uploader.d.ts +3 -1
- package/dist/storage/telemetry/uploader.d.ts.map +1 -1
- package/dist/storage/telemetry/uploader.js +158 -21
- package/dist/storage/telemetry/uploader.js.map +1 -1
- package/dist/tools/cross-repo-contract-adapters.d.ts +39 -0
- package/dist/tools/cross-repo-contract-adapters.d.ts.map +1 -0
- package/dist/tools/cross-repo-contract-adapters.js +70 -0
- package/dist/tools/cross-repo-contract-adapters.js.map +1 -0
- package/dist/tools/cross-repo-contract-group.d.ts +17 -0
- package/dist/tools/cross-repo-contract-group.d.ts.map +1 -0
- package/dist/tools/cross-repo-contract-group.js +89 -0
- package/dist/tools/cross-repo-contract-group.js.map +1 -0
- package/dist/tools/cross-repo-contract-matcher.d.ts +24 -0
- package/dist/tools/cross-repo-contract-matcher.d.ts.map +1 -0
- package/dist/tools/cross-repo-contract-matcher.js +134 -0
- package/dist/tools/cross-repo-contract-matcher.js.map +1 -0
- package/dist/tools/cross-repo-contract-resolver.d.ts +9 -0
- package/dist/tools/cross-repo-contract-resolver.d.ts.map +1 -0
- package/dist/tools/cross-repo-contract-resolver.js +86 -0
- package/dist/tools/cross-repo-contract-resolver.js.map +1 -0
- package/dist/tools/cross-repo-contract-tools.d.ts +12 -135
- package/dist/tools/cross-repo-contract-tools.d.ts.map +1 -1
- package/dist/tools/cross-repo-contract-tools.js +8 -589
- package/dist/tools/cross-repo-contract-tools.js.map +1 -1
- package/dist/tools/cross-repo-contract-types.d.ts +30 -0
- package/dist/tools/cross-repo-contract-types.d.ts.map +1 -0
- package/dist/tools/cross-repo-contract-types.js +3 -0
- package/dist/tools/cross-repo-contract-types.js.map +1 -0
- package/dist/tools/cross-repo-outbound-calls.d.ts +28 -0
- package/dist/tools/cross-repo-outbound-calls.d.ts.map +1 -0
- package/dist/tools/cross-repo-outbound-calls.js +347 -0
- package/dist/tools/cross-repo-outbound-calls.js.map +1 -0
- package/dist/tools/cross-repo-outbound-lexer/call-detectors.d.ts.map +1 -1
- package/dist/tools/cross-repo-outbound-lexer/call-detectors.js +2 -0
- package/dist/tools/cross-repo-outbound-lexer/call-detectors.js.map +1 -1
- package/dist/tools/cross-repo-outbound-lexer/types.d.ts +2 -0
- package/dist/tools/cross-repo-outbound-lexer/types.d.ts.map +1 -1
- package/dist/tools/index-tools/file-indexer.js +3 -3
- package/dist/tools/index-tools/file-indexer.js.map +1 -1
- package/dist/tools/index-tools/folder-indexer.d.ts.map +1 -1
- package/dist/tools/index-tools/folder-indexer.js +47 -2
- package/dist/tools/index-tools/folder-indexer.js.map +1 -1
- package/dist/tools/index-tools/parse.d.ts +12 -3
- package/dist/tools/index-tools/parse.d.ts.map +1 -1
- package/dist/tools/index-tools/parse.js +33 -8
- package/dist/tools/index-tools/parse.js.map +1 -1
- package/dist/tools/index-tools/registry.d.ts +19 -0
- package/dist/tools/index-tools/registry.d.ts.map +1 -1
- package/dist/tools/index-tools/registry.js +88 -2
- package/dist/tools/index-tools/registry.js.map +1 -1
- package/dist/tools/index-tools/state.d.ts +31 -0
- package/dist/tools/index-tools/state.d.ts.map +1 -1
- package/dist/tools/index-tools/state.js +53 -0
- package/dist/tools/index-tools/state.js.map +1 -1
- package/dist/tools/index-tools/types.d.ts +9 -0
- package/dist/tools/index-tools/types.d.ts.map +1 -1
- package/dist/tools/index-tools/watcher.js +3 -3
- package/dist/tools/index-tools/watcher.js.map +1 -1
- package/dist/tools/index-tools/worktree-seed.d.ts +44 -0
- package/dist/tools/index-tools/worktree-seed.d.ts.map +1 -0
- package/dist/tools/index-tools/worktree-seed.js +302 -0
- package/dist/tools/index-tools/worktree-seed.js.map +1 -0
- package/dist/tools/index-tools.d.ts.map +1 -1
- package/dist/tools/index-tools.js +3 -1
- package/dist/tools/index-tools.js.map +1 -1
- package/dist/tools/nest-ext-tools/graphql.d.ts +17 -0
- package/dist/tools/nest-ext-tools/graphql.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/graphql.js +54 -0
- package/dist/tools/nest-ext-tools/graphql.js.map +1 -0
- package/dist/tools/nest-ext-tools/microservice.d.ts +17 -0
- package/dist/tools/nest-ext-tools/microservice.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/microservice.js +51 -0
- package/dist/tools/nest-ext-tools/microservice.js.map +1 -0
- package/dist/tools/nest-ext-tools/openapi.d.ts +81 -0
- package/dist/tools/nest-ext-tools/openapi.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/openapi.js +254 -0
- package/dist/tools/nest-ext-tools/openapi.js.map +1 -0
- package/dist/tools/nest-ext-tools/queue.d.ts +27 -0
- package/dist/tools/nest-ext-tools/queue.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/queue.js +95 -0
- package/dist/tools/nest-ext-tools/queue.js.map +1 -0
- package/dist/tools/nest-ext-tools/schedule.d.ts +19 -0
- package/dist/tools/nest-ext-tools/schedule.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/schedule.js +89 -0
- package/dist/tools/nest-ext-tools/schedule.js.map +1 -0
- package/dist/tools/nest-ext-tools/scope.d.ts +19 -0
- package/dist/tools/nest-ext-tools/scope.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/scope.js +151 -0
- package/dist/tools/nest-ext-tools/scope.js.map +1 -0
- package/dist/tools/nest-ext-tools/shared.d.ts +33 -0
- package/dist/tools/nest-ext-tools/shared.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/shared.js +279 -0
- package/dist/tools/nest-ext-tools/shared.js.map +1 -0
- package/dist/tools/nest-ext-tools/typeorm.d.ts +22 -0
- package/dist/tools/nest-ext-tools/typeorm.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/typeorm.js +59 -0
- package/dist/tools/nest-ext-tools/typeorm.js.map +1 -0
- package/dist/tools/nest-ext-tools/websocket.d.ts +21 -0
- package/dist/tools/nest-ext-tools/websocket.d.ts.map +1 -0
- package/dist/tools/nest-ext-tools/websocket.js +70 -0
- package/dist/tools/nest-ext-tools/websocket.js.map +1 -0
- package/dist/tools/nest-ext-tools.d.ts +10 -204
- package/dist/tools/nest-ext-tools.d.ts.map +1 -1
- package/dist/tools/nest-ext-tools.js +10 -749
- package/dist/tools/nest-ext-tools.js.map +1 -1
- package/dist/tools/perf-tools.js +2 -2
- package/dist/tools/python-audit/checks/dead-code.d.ts +1 -1
- package/dist/tools/python-audit/checks/dead-code.d.ts.map +1 -1
- package/dist/tools/python-constants/constant-match.d.ts +5 -0
- package/dist/tools/python-constants/constant-match.d.ts.map +1 -0
- package/dist/tools/python-constants/constant-match.js +24 -0
- package/dist/tools/python-constants/constant-match.js.map +1 -0
- package/dist/tools/python-constants/file-context.d.ts +5 -0
- package/dist/tools/python-constants/file-context.d.ts.map +1 -0
- package/dist/tools/python-constants/file-context.js +91 -0
- package/dist/tools/python-constants/file-context.js.map +1 -0
- package/dist/tools/python-constants/function-defaults.d.ts +5 -0
- package/dist/tools/python-constants/function-defaults.d.ts.map +1 -0
- package/dist/tools/python-constants/function-defaults.js +98 -0
- package/dist/tools/python-constants/function-defaults.js.map +1 -0
- package/dist/tools/python-constants/model.d.ts +78 -0
- package/dist/tools/python-constants/model.d.ts.map +1 -0
- package/dist/tools/python-constants/model.js +2 -0
- package/dist/tools/python-constants/model.js.map +1 -0
- package/dist/tools/python-constants/syntax.d.ts +22 -0
- package/dist/tools/python-constants/syntax.d.ts.map +1 -0
- package/dist/tools/python-constants/syntax.js +93 -0
- package/dist/tools/python-constants/syntax.js.map +1 -0
- package/dist/tools/python-constants/value-resolver.d.ts +6 -0
- package/dist/tools/python-constants/value-resolver.d.ts.map +1 -0
- package/dist/tools/python-constants/value-resolver.js +320 -0
- package/dist/tools/python-constants/value-resolver.js.map +1 -0
- package/dist/tools/python-constants-tools.d.ts +3 -45
- package/dist/tools/python-constants-tools.d.ts.map +1 -1
- package/dist/tools/python-constants-tools.js +2 -505
- package/dist/tools/python-constants-tools.js.map +1 -1
- package/dist/tools/route-tools/django.d.ts +8 -0
- package/dist/tools/route-tools/django.d.ts.map +1 -0
- package/dist/tools/route-tools/django.js +52 -0
- package/dist/tools/route-tools/django.js.map +1 -0
- package/dist/tools/route-tools/express.d.ts +5 -0
- package/dist/tools/route-tools/express.d.ts.map +1 -0
- package/dist/tools/route-tools/express.js +33 -0
- package/dist/tools/route-tools/express.js.map +1 -0
- package/dist/tools/route-tools/file-sources.d.ts +7 -0
- package/dist/tools/route-tools/file-sources.d.ts.map +1 -0
- package/dist/tools/route-tools/file-sources.js +15 -0
- package/dist/tools/route-tools/file-sources.js.map +1 -0
- package/dist/tools/route-tools/handler-discovery.d.ts +4 -0
- package/dist/tools/route-tools/handler-discovery.d.ts.map +1 -0
- package/dist/tools/route-tools/handler-discovery.js +38 -0
- package/dist/tools/route-tools/handler-discovery.js.map +1 -0
- package/dist/tools/route-tools/hono.d.ts +5 -0
- package/dist/tools/route-tools/hono.d.ts.map +1 -0
- package/dist/tools/route-tools/hono.js +61 -0
- package/dist/tools/route-tools/hono.js.map +1 -0
- package/dist/tools/route-tools/ktor.d.ts +5 -0
- package/dist/tools/route-tools/ktor.d.ts.map +1 -0
- package/dist/tools/route-tools/ktor.js +76 -0
- package/dist/tools/route-tools/ktor.js.map +1 -0
- package/dist/tools/route-tools/laravel.d.ts +5 -0
- package/dist/tools/route-tools/laravel.d.ts.map +1 -0
- package/dist/tools/route-tools/laravel.js +45 -0
- package/dist/tools/route-tools/laravel.js.map +1 -0
- package/dist/tools/route-tools/mermaid-call-chain.d.ts +3 -0
- package/dist/tools/route-tools/mermaid-call-chain.d.ts.map +1 -0
- package/dist/tools/route-tools/mermaid-call-chain.js +50 -0
- package/dist/tools/route-tools/mermaid-call-chain.js.map +1 -0
- package/dist/tools/route-tools/nest.d.ts +5 -0
- package/dist/tools/route-tools/nest.d.ts.map +1 -0
- package/dist/tools/route-tools/nest.js +75 -0
- package/dist/tools/route-tools/nest.js.map +1 -0
- package/dist/tools/route-tools/next-trace.d.ts +4 -0
- package/dist/tools/route-tools/next-trace.d.ts.map +1 -0
- package/dist/tools/route-tools/next-trace.js +48 -0
- package/dist/tools/route-tools/next-trace.js.map +1 -0
- package/dist/tools/route-tools/next.d.ts +7 -0
- package/dist/tools/route-tools/next.d.ts.map +1 -0
- package/dist/tools/route-tools/next.js +77 -0
- package/dist/tools/route-tools/next.js.map +1 -0
- package/dist/tools/route-tools/python-decorators.d.ts +7 -0
- package/dist/tools/route-tools/python-decorators.d.ts.map +1 -0
- package/dist/tools/route-tools/python-decorators.js +53 -0
- package/dist/tools/route-tools/python-decorators.js.map +1 -0
- package/dist/tools/route-tools/route-mermaid.d.ts +4 -0
- package/dist/tools/route-tools/route-mermaid.d.ts.map +1 -0
- package/dist/tools/route-tools/route-mermaid.js +53 -0
- package/dist/tools/route-tools/route-mermaid.js.map +1 -0
- package/dist/tools/route-tools/spring-kotlin.d.ts +5 -0
- package/dist/tools/route-tools/spring-kotlin.d.ts.map +1 -0
- package/dist/tools/route-tools/spring-kotlin.js +52 -0
- package/dist/tools/route-tools/spring-kotlin.js.map +1 -0
- package/dist/tools/route-tools/trace-analysis.d.ts +4 -0
- package/dist/tools/route-tools/trace-analysis.d.ts.map +1 -0
- package/dist/tools/route-tools/trace-analysis.js +37 -0
- package/dist/tools/route-tools/trace-analysis.js.map +1 -0
- package/dist/tools/route-tools/trace-route.d.ts +6 -0
- package/dist/tools/route-tools/trace-route.d.ts.map +1 -0
- package/dist/tools/route-tools/trace-route.js +53 -0
- package/dist/tools/route-tools/trace-route.js.map +1 -0
- package/dist/tools/route-tools/types.d.ts +35 -0
- package/dist/tools/route-tools/types.d.ts.map +1 -0
- package/dist/tools/route-tools/types.js +2 -0
- package/dist/tools/route-tools/types.js.map +1 -0
- package/dist/tools/route-tools/yii2.d.ts +5 -0
- package/dist/tools/route-tools/yii2.d.ts.map +1 -0
- package/dist/tools/route-tools/yii2.js +73 -0
- package/dist/tools/route-tools/yii2.js.map +1 -0
- package/dist/tools/route-tools.d.ts +7 -49
- package/dist/tools/route-tools.d.ts.map +1 -1
- package/dist/tools/route-tools.js +5 -978
- package/dist/tools/route-tools.js.map +1 -1
- package/dist/tools/symbol-analysis-tools.d.ts +81 -0
- package/dist/tools/symbol-analysis-tools.d.ts.map +1 -0
- package/dist/tools/symbol-analysis-tools.js +327 -0
- package/dist/tools/symbol-analysis-tools.js.map +1 -0
- package/dist/tools/symbol-context-tools.d.ts +68 -0
- package/dist/tools/symbol-context-tools.d.ts.map +1 -0
- package/dist/tools/symbol-context-tools.js +232 -0
- package/dist/tools/symbol-context-tools.js.map +1 -0
- package/dist/tools/symbol-lookup-tools.d.ts +77 -0
- package/dist/tools/symbol-lookup-tools.d.ts.map +1 -0
- package/dist/tools/symbol-lookup-tools.js +305 -0
- package/dist/tools/symbol-lookup-tools.js.map +1 -0
- package/dist/tools/symbol-reference-tools.d.ts +38 -0
- package/dist/tools/symbol-reference-tools.d.ts.map +1 -0
- package/dist/tools/symbol-reference-tools.js +253 -0
- package/dist/tools/symbol-reference-tools.js.map +1 -0
- package/dist/tools/symbol-tool-internals.d.ts +9 -0
- package/dist/tools/symbol-tool-internals.d.ts.map +1 -0
- package/dist/tools/symbol-tool-internals.js +47 -0
- package/dist/tools/symbol-tool-internals.js.map +1 -0
- package/dist/tools/symbol-tools.d.ts +11 -270
- package/dist/tools/symbol-tools.d.ts.map +1 -1
- package/dist/tools/symbol-tools.js +7 -1131
- package/dist/tools/symbol-tools.js.map +1 -1
- package/dist/tools/taint/python-context.d.ts +10 -0
- package/dist/tools/taint/python-context.d.ts.map +1 -0
- package/dist/tools/taint/python-context.js +150 -0
- package/dist/tools/taint/python-context.js.map +1 -0
- package/dist/tools/taint/taint-analyzer.d.ts +2 -0
- package/dist/tools/taint/taint-analyzer.d.ts.map +1 -0
- package/dist/tools/taint/taint-analyzer.js +2 -0
- package/dist/tools/taint/taint-analyzer.js.map +1 -0
- package/dist/tools/taint/taint-expression.d.ts +18 -0
- package/dist/tools/taint/taint-expression.d.ts.map +1 -0
- package/dist/tools/taint/taint-expression.js +265 -0
- package/dist/tools/taint/taint-expression.js.map +1 -0
- package/dist/tools/taint/taint-flow.d.ts +10 -0
- package/dist/tools/taint/taint-flow.d.ts.map +1 -0
- package/dist/tools/taint/taint-flow.js +178 -0
- package/dist/tools/taint/taint-flow.js.map +1 -0
- package/dist/tools/taint/taint-model.d.ts +113 -0
- package/dist/tools/taint/taint-model.d.ts.map +1 -0
- package/dist/tools/taint/taint-model.js +277 -0
- package/dist/tools/taint/taint-model.js.map +1 -0
- package/dist/tools/taint-tools.d.ts +2 -34
- package/dist/tools/taint-tools.d.ts.map +1 -1
- package/dist/tools/taint-tools.js +2 -852
- package/dist/tools/taint-tools.js.map +1 -1
- package/dist/tools/typescript-constants/file-context.d.ts +7 -0
- package/dist/tools/typescript-constants/file-context.d.ts.map +1 -0
- package/dist/tools/typescript-constants/file-context.js +219 -0
- package/dist/tools/typescript-constants/file-context.js.map +1 -0
- package/dist/tools/typescript-constants/symbol-resolver.d.ts +7 -0
- package/dist/tools/typescript-constants/symbol-resolver.d.ts.map +1 -0
- package/dist/tools/typescript-constants/symbol-resolver.js +165 -0
- package/dist/tools/typescript-constants/symbol-resolver.js.map +1 -0
- package/dist/tools/typescript-constants/types.d.ts +44 -0
- package/dist/tools/typescript-constants/types.d.ts.map +1 -0
- package/dist/tools/typescript-constants/types.js +2 -0
- package/dist/tools/typescript-constants/types.js.map +1 -0
- package/dist/tools/typescript-constants/value-evaluator.d.ts +8 -0
- package/dist/tools/typescript-constants/value-evaluator.d.ts.map +1 -0
- package/dist/tools/typescript-constants/value-evaluator.js +404 -0
- package/dist/tools/typescript-constants/value-evaluator.js.map +1 -0
- package/dist/tools/typescript-constants-tools.d.ts.map +1 -1
- package/dist/tools/typescript-constants-tools.js +19 -709
- package/dist/tools/typescript-constants-tools.js.map +1 -1
- package/dist/utils/import-graph/collect.d.ts +5 -0
- package/dist/utils/import-graph/collect.d.ts.map +1 -0
- package/dist/utils/import-graph/collect.js +47 -0
- package/dist/utils/import-graph/collect.js.map +1 -0
- package/dist/utils/import-graph/edge-accumulator.d.ts +7 -0
- package/dist/utils/import-graph/edge-accumulator.d.ts.map +1 -0
- package/dist/utils/import-graph/edge-accumulator.js +47 -0
- package/dist/utils/import-graph/edge-accumulator.js.map +1 -0
- package/dist/utils/import-graph/language-imports.d.ts +6 -0
- package/dist/utils/import-graph/language-imports.d.ts.map +1 -0
- package/dist/utils/import-graph/language-imports.js +84 -0
- package/dist/utils/import-graph/language-imports.js.map +1 -0
- package/dist/utils/import-graph/metrics.d.ts +6 -0
- package/dist/utils/import-graph/metrics.d.ts.map +1 -0
- package/dist/utils/import-graph/metrics.js +51 -0
- package/dist/utils/import-graph/metrics.js.map +1 -0
- package/dist/utils/import-graph/path-map.d.ts +7 -0
- package/dist/utils/import-graph/path-map.d.ts.map +1 -0
- package/dist/utils/import-graph/path-map.js +56 -0
- package/dist/utils/import-graph/path-map.js.map +1 -0
- package/dist/utils/import-graph/python-php-edge-collectors.d.ts +5 -0
- package/dist/utils/import-graph/python-php-edge-collectors.d.ts.map +1 -0
- package/dist/utils/import-graph/python-php-edge-collectors.js +56 -0
- package/dist/utils/import-graph/python-php-edge-collectors.js.map +1 -0
- package/dist/utils/import-graph/source-edge-collector.d.ts +13 -0
- package/dist/utils/import-graph/source-edge-collector.d.ts.map +1 -0
- package/dist/utils/import-graph/source-edge-collector.js +42 -0
- package/dist/utils/import-graph/source-edge-collector.js.map +1 -0
- package/dist/utils/import-graph/source-imports.d.ts +5 -0
- package/dist/utils/import-graph/source-imports.d.ts.map +1 -0
- package/dist/utils/import-graph/source-imports.js +33 -0
- package/dist/utils/import-graph/source-imports.js.map +1 -0
- package/dist/utils/import-graph/types.d.ts +15 -0
- package/dist/utils/import-graph/types.d.ts.map +1 -0
- package/dist/utils/import-graph/types.js +2 -0
- package/dist/utils/import-graph/types.js.map +1 -0
- package/dist/utils/import-graph/typescript-edge-collector.d.ts +7 -0
- package/dist/utils/import-graph/typescript-edge-collector.d.ts.map +1 -0
- package/dist/utils/import-graph/typescript-edge-collector.js +58 -0
- package/dist/utils/import-graph/typescript-edge-collector.js.map +1 -0
- package/dist/utils/import-graph/workspace-alias.d.ts +7 -0
- package/dist/utils/import-graph/workspace-alias.d.ts.map +1 -0
- package/dist/utils/import-graph/workspace-alias.js +95 -0
- package/dist/utils/import-graph/workspace-alias.js.map +1 -0
- package/dist/utils/import-graph/workspace-entry.d.ts +3 -0
- package/dist/utils/import-graph/workspace-entry.d.ts.map +1 -0
- package/dist/utils/import-graph/workspace-entry.js +81 -0
- package/dist/utils/import-graph/workspace-entry.js.map +1 -0
- package/dist/utils/import-graph.d.ts +10 -94
- package/dist/utils/import-graph.d.ts.map +1 -1
- package/dist/utils/import-graph.js +6 -702
- package/dist/utils/import-graph.js.map +1 -1
- package/package.json +1 -1
- package/rules/codesift.md +11 -2
- package/rules/codesift.mdc +11 -2
- package/rules/codex.md +11 -2
- package/rules/gemini.md +11 -2
package/dist/cli/commands.js
CHANGED
|
@@ -1,871 +1,12 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
|
-
// CLI command
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
/** Default daemon port — clients point here via `setup --http`. */
|
|
12
|
-
export const DEFAULT_DAEMON_PORT = 7077;
|
|
13
|
-
/** Lockfile paths for the daemon in a given data dir (~/.codesift). */
|
|
14
|
-
export function daemonLockPaths(dataDir) {
|
|
15
|
-
return { pidPath: join(dataDir, "daemon.pid"), portPath: join(dataDir, "daemon.port") };
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* True if a process with `pid` is alive. `process.kill(pid, 0)` sends no signal
|
|
19
|
-
* but performs the permission/existence check: ESRCH = dead, EPERM = alive but
|
|
20
|
-
* owned by another user (still alive).
|
|
21
|
-
*/
|
|
22
|
-
export function isProcessAlive(pid) {
|
|
23
|
-
if (!Number.isInteger(pid) || pid <= 0)
|
|
24
|
-
return false;
|
|
25
|
-
try {
|
|
26
|
-
process.kill(pid, 0);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
return e.code === "EPERM";
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/** Read the current daemon lock, or null if absent/unparseable. */
|
|
34
|
-
export function readDaemonLock(dataDir) {
|
|
35
|
-
const { pidPath, portPath } = daemonLockPaths(dataDir);
|
|
36
|
-
try {
|
|
37
|
-
const pid = parseInt(readFileSync(pidPath, "utf-8").trim(), 10);
|
|
38
|
-
const port = parseInt(readFileSync(portPath, "utf-8").trim(), 10);
|
|
39
|
-
if (!Number.isInteger(pid) || !Number.isInteger(port))
|
|
40
|
-
return null;
|
|
41
|
-
return { pid, port };
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Acquire the daemon lock and start the shared HTTP server.
|
|
49
|
-
*
|
|
50
|
-
* Refuses if a LIVE daemon already holds the lock (single-instance). A STALE
|
|
51
|
-
* lock (pid no longer alive — kill -9, OOM, crash) is reclaimed so the daemon
|
|
52
|
-
* can always restart; without this, a crashed daemon would wedge the lock and
|
|
53
|
-
* coworkers would fall back to per-window stdio = the original OOM incident.
|
|
54
|
-
*
|
|
55
|
-
* `close()` removes the lockfiles, so a graceful SIGTERM leaves a clean slate.
|
|
56
|
-
*/
|
|
57
|
-
export async function startDaemon(opts = {}) {
|
|
58
|
-
const { loadConfig } = await import("../config.js");
|
|
59
|
-
const dataDir = opts.dataDir ?? loadConfig().dataDir;
|
|
60
|
-
const { pidPath, portPath } = daemonLockPaths(dataDir);
|
|
61
|
-
const existing = readDaemonLock(dataDir);
|
|
62
|
-
if (existing && isProcessAlive(existing.pid)) {
|
|
63
|
-
throw new Error(`codesift serve already running (pid ${existing.pid}, port ${existing.port}). Stop it first.`);
|
|
64
|
-
}
|
|
65
|
-
mkdirSync(dataDir, { recursive: true });
|
|
66
|
-
writeFileSync(pidPath, String(process.pid));
|
|
67
|
-
const { startHttpServer } = await import("../server.js");
|
|
68
|
-
const httpOpts = {};
|
|
69
|
-
if (opts.port !== undefined)
|
|
70
|
-
httpOpts.port = opts.port;
|
|
71
|
-
if (opts.host !== undefined)
|
|
72
|
-
httpOpts.host = opts.host;
|
|
73
|
-
if (opts.token !== undefined)
|
|
74
|
-
httpOpts.token = opts.token;
|
|
75
|
-
const handle = await startHttpServer(httpOpts);
|
|
76
|
-
writeFileSync(portPath, String(handle.port));
|
|
77
|
-
const release = () => {
|
|
78
|
-
try {
|
|
79
|
-
unlinkSync(pidPath);
|
|
80
|
-
}
|
|
81
|
-
catch { /* already gone */ }
|
|
82
|
-
try {
|
|
83
|
-
unlinkSync(portPath);
|
|
84
|
-
}
|
|
85
|
-
catch { /* already gone */ }
|
|
86
|
-
};
|
|
87
|
-
const origClose = handle.close;
|
|
88
|
-
return {
|
|
89
|
-
...handle,
|
|
90
|
-
close: async () => {
|
|
91
|
-
release();
|
|
92
|
-
await origClose();
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* `codesift serve` — boot the shared daemon and stay alive until SIGTERM/SIGINT.
|
|
98
|
-
*/
|
|
99
|
-
async function handleServe(_args, flags) {
|
|
100
|
-
const port = getNumFlag(flags, "port") ?? DEFAULT_DAEMON_PORT;
|
|
101
|
-
const host = getFlag(flags, "host");
|
|
102
|
-
let handle;
|
|
103
|
-
try {
|
|
104
|
-
handle = await startDaemon({ port, ...(host ? { host } : {}) });
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
die(`serve: ${e.message}`);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
output({ status: "serving", url: handle.url, port: handle.port, pid: process.pid }, flags);
|
|
111
|
-
const shutdown = () => {
|
|
112
|
-
void handle.close().then(() => process.exit(0));
|
|
113
|
-
};
|
|
114
|
-
process.on("SIGTERM", shutdown);
|
|
115
|
-
process.on("SIGINT", shutdown);
|
|
116
|
-
}
|
|
117
|
-
// ---------------------------------------------------------------------------
|
|
118
|
-
// Constants
|
|
119
|
-
// ---------------------------------------------------------------------------
|
|
120
|
-
const VALID_SYMBOL_KINDS = new Set([
|
|
121
|
-
"function", "method", "class", "interface", "type", "variable", "constant",
|
|
122
|
-
"field", "enum", "namespace", "module", "section", "metadata",
|
|
123
|
-
"test_suite", "test_case", "test_hook", "default_export", "unknown",
|
|
124
|
-
]);
|
|
125
|
-
const EXCLUDE_TESTS_QUERY_TYPES = new Set(["semantic", "hybrid"]);
|
|
126
|
-
// ---------------------------------------------------------------------------
|
|
127
|
-
// Index commands
|
|
128
|
-
// ---------------------------------------------------------------------------
|
|
129
|
-
/**
|
|
130
|
-
* Run the embedding phase in a separate process and wait for it.
|
|
131
|
-
*
|
|
132
|
-
* The child's EXIT CODE is deliberately not trusted. Once onnxruntime has run,
|
|
133
|
-
* the process aborts during native teardown (`mutex lock failed`, exit 134)
|
|
134
|
-
* even though every file was written correctly first — so the child prints a
|
|
135
|
-
* marker after its last successful write and that marker, not the status, is
|
|
136
|
-
* what decides success. See src/cli/embed-child.ts.
|
|
137
|
-
*
|
|
138
|
-
* Failures here are reported but never fatal: BM25 and symbol search work
|
|
139
|
-
* without embeddings, and the index itself is already committed to disk.
|
|
140
|
-
*/
|
|
141
|
-
async function runEmbeddingChild(repoName, rootPath) {
|
|
142
|
-
const { getIndexPath } = await import("../storage/index-store.js");
|
|
143
|
-
const { loadConfig } = await import("../config.js");
|
|
144
|
-
const { spawn } = await import("node:child_process");
|
|
145
|
-
const { fileURLToPath } = await import("node:url");
|
|
146
|
-
const { dirname, join } = await import("node:path");
|
|
147
|
-
const config = loadConfig();
|
|
148
|
-
if (!config.embeddingProvider)
|
|
149
|
-
return; // lite mode — nothing to embed
|
|
150
|
-
const indexPath = getIndexPath(config.dataDir, rootPath);
|
|
151
|
-
const childScript = join(dirname(fileURLToPath(import.meta.url)), "embed-child.js");
|
|
152
|
-
const { EMBED_CHILD_OK_MARKER } = await import("./embed-child-marker.js");
|
|
153
|
-
await new Promise((resolve) => {
|
|
154
|
-
const child = spawn(process.execPath, [childScript, indexPath, repoName, rootPath], {
|
|
155
|
-
stdio: ["ignore", "pipe", "inherit"],
|
|
156
|
-
env: { ...process.env, CODESIFT_EMBED_OUT_OF_PROCESS: "0" },
|
|
157
|
-
});
|
|
158
|
-
let sawMarker = false;
|
|
159
|
-
child.stdout.on("data", (buf) => {
|
|
160
|
-
if (buf.toString().includes(EMBED_CHILD_OK_MARKER))
|
|
161
|
-
sawMarker = true;
|
|
162
|
-
});
|
|
163
|
-
child.on("error", (err) => {
|
|
164
|
-
process.stderr.write(`[codesift] embedding skipped: ${err.message}\n`);
|
|
165
|
-
resolve();
|
|
166
|
-
});
|
|
167
|
-
child.on("close", (code, signal) => {
|
|
168
|
-
if (!sawMarker) {
|
|
169
|
-
process.stderr.write(`[codesift] embedding did not complete (exit ${code ?? signal}) — ` +
|
|
170
|
-
`search falls back to BM25 for this repo.\n`);
|
|
171
|
-
}
|
|
172
|
-
resolve();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
async function handleIndex(args, flags) {
|
|
177
|
-
const path = requireArg(args, 0, "path");
|
|
178
|
-
const { indexFolder } = await import("../tools/index-tools.js");
|
|
179
|
-
// Keep onnxruntime out of THIS process; the embedding runs in a child below.
|
|
180
|
-
process.env["CODESIFT_EMBED_OUT_OF_PROCESS"] = "1";
|
|
181
|
-
const result = await indexFolder(path, {
|
|
182
|
-
incremental: getBoolFlag(flags, "incremental"),
|
|
183
|
-
include_paths: parseCommaSeparated(flags, "include-paths"),
|
|
184
|
-
watch: getBoolFlag(flags, "no-watch") === true ? false : undefined,
|
|
185
|
-
});
|
|
186
|
-
// Any in-process embedding scheduled before the opt-out (or by another code
|
|
187
|
-
// path) still has to finish before we exit, or the command reports success
|
|
188
|
-
// having written nothing.
|
|
189
|
-
const { awaitPendingEmbeddings } = await import("../tools/index-tools/folder-indexer.js");
|
|
190
|
-
await awaitPendingEmbeddings();
|
|
191
|
-
const repo = result?.repo;
|
|
192
|
-
const root = result?.root;
|
|
193
|
-
if (repo && root)
|
|
194
|
-
await runEmbeddingChild(repo, root);
|
|
195
|
-
output(result, flags);
|
|
196
|
-
// Without `--no-watch` this command does not return: the watcher keeps the
|
|
197
|
-
// event loop alive so the index stays current. That is the intended default,
|
|
198
|
-
// but a process that prints a finished-looking result and then sits there is
|
|
199
|
-
// indistinguishable from a hang — long enough that I read it as one and spent
|
|
200
|
-
// a `timeout 240` proving otherwise, on a run whose indexing took 125 ms. Say
|
|
201
|
-
// which of the two it is. On stderr, so `codesift index … | jq` still works.
|
|
202
|
-
if (getBoolFlag(flags, "no-watch") !== true) {
|
|
203
|
-
console.error(`[codesift] watching ${root ?? path} for changes — Ctrl-C to stop, `
|
|
204
|
-
+ "or re-run with --no-watch to exit when indexing finishes.");
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
async function handleIndexRepo(args, flags) {
|
|
208
|
-
const url = requireArg(args, 0, "url");
|
|
209
|
-
const { indexRepo } = await import("../tools/index-tools.js");
|
|
210
|
-
// Same three protections as handleIndex. Without them this entry point still
|
|
211
|
-
// exits while the fire-and-forget embedding chain is in flight, so the repo
|
|
212
|
-
// ends up with partial or zero embeddings and the command reports success —
|
|
213
|
-
// the exact bug handleIndex was fixed for, left behind on this path.
|
|
214
|
-
process.env["CODESIFT_EMBED_OUT_OF_PROCESS"] = "1";
|
|
215
|
-
const result = await indexRepo(url, {
|
|
216
|
-
branch: getFlag(flags, "branch"),
|
|
217
|
-
include_paths: parseCommaSeparated(flags, "include-paths"),
|
|
218
|
-
});
|
|
219
|
-
const { awaitPendingEmbeddings } = await import("../tools/index-tools/folder-indexer.js");
|
|
220
|
-
await awaitPendingEmbeddings();
|
|
221
|
-
const repo = result?.repo;
|
|
222
|
-
const root = result?.root;
|
|
223
|
-
if (repo && root)
|
|
224
|
-
await runEmbeddingChild(repo, root);
|
|
225
|
-
output(result, flags);
|
|
226
|
-
}
|
|
227
|
-
async function handleRepos(_args, flags) {
|
|
228
|
-
const { listAllRepos } = await import("../tools/index-tools.js");
|
|
229
|
-
const result = await listAllRepos();
|
|
230
|
-
output(result, flags);
|
|
231
|
-
}
|
|
232
|
-
async function handleInvalidate(args, flags) {
|
|
233
|
-
const repo = requireArg(args, 0, "repo");
|
|
234
|
-
const { invalidateCache } = await import("../tools/index-tools.js");
|
|
235
|
-
const result = await invalidateCache(repo);
|
|
236
|
-
output({ invalidated: result, repo }, flags);
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Delete orphaned per-repo cache artifacts (embeddings/index/meta/bm25/graph)
|
|
240
|
-
* whose hash stem is no longer in the registry. These accumulate from
|
|
241
|
-
* re-indexes (hash changes) and ephemeral/test repos that were indexed then
|
|
242
|
-
* deleted — each leaves multi-GB embedding files behind. Use --dry-run to
|
|
243
|
-
* preview. Regenerable: re-indexing recreates anything still needed.
|
|
244
|
-
*/
|
|
245
|
-
async function handlePrune(_args, flags) {
|
|
246
|
-
const { readFileSync, readdirSync, statSync, unlinkSync } = await import("node:fs");
|
|
247
|
-
const { join } = await import("node:path");
|
|
248
|
-
const { loadConfig } = await import("../config.js");
|
|
249
|
-
const dataDir = loadConfig().dataDir;
|
|
250
|
-
const dryRun = getBoolFlag(flags, "dry-run");
|
|
251
|
-
// Live index hashes from the registry — everything else is orphaned cache.
|
|
252
|
-
//
|
|
253
|
-
// A registry entry counted as live even when its `root` no longer existed, so
|
|
254
|
-
// artifacts for deleted directories were protected indefinitely. Measured
|
|
255
|
-
// here: 101 of 119 indexed worktrees pointed at directories that were gone,
|
|
256
|
-
// holding 5.4 GB of embeddings for code that cannot be read. Task branches are
|
|
257
|
-
// created and deleted constantly, so this accumulates without bound.
|
|
258
|
-
//
|
|
259
|
-
// Entries whose root is missing are de-registered first; their artifacts then
|
|
260
|
-
// fall out as orphans through the sweep below.
|
|
261
|
-
const live = new Set();
|
|
262
|
-
const stale = [];
|
|
263
|
-
let reg;
|
|
264
|
-
try {
|
|
265
|
-
reg = JSON.parse(readFileSync(join(dataDir, "registry.json"), "utf-8"));
|
|
266
|
-
}
|
|
267
|
-
catch {
|
|
268
|
-
die("prune: cannot read registry.json — aborting so live data is never deleted.");
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
for (const [name, v] of Object.entries(reg.repos ?? {})) {
|
|
272
|
-
const ip = v.index_path;
|
|
273
|
-
const root = v.root;
|
|
274
|
-
// Only a root that is definitively absent counts. An unreadable path (a
|
|
275
|
-
// permissions error, an unmounted volume mid-check) throws and is treated
|
|
276
|
-
// as present — the conservative direction, since the cost of keeping a dead
|
|
277
|
-
// entry is disk, and the cost of dropping a live one is a re-index.
|
|
278
|
-
let rootGone = false;
|
|
279
|
-
if (typeof root === "string" && root.length > 0) {
|
|
280
|
-
try {
|
|
281
|
-
statSync(root);
|
|
282
|
-
}
|
|
283
|
-
catch {
|
|
284
|
-
rootGone = true;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (rootGone) {
|
|
288
|
-
stale.push({ name, root: root });
|
|
289
|
-
continue; // deliberately NOT added to `live`
|
|
290
|
-
}
|
|
291
|
-
if (typeof ip === "string")
|
|
292
|
-
live.add(ip.split("/").pop().replace(".index.json", ""));
|
|
293
|
-
}
|
|
294
|
-
// Safety: an empty live set would mark every artifact orphaned. Refuse rather
|
|
295
|
-
// than risk nuking a valid (but momentarily empty-looking) data dir.
|
|
296
|
-
if (live.size === 0) {
|
|
297
|
-
die("prune: registry lists 0 repos — aborting (refusing to treat all artifacts as orphans).");
|
|
298
|
-
}
|
|
299
|
-
// Suffix list lives with the helpers that build these names, so a new artifact kind
|
|
300
|
-
// cannot quietly become unreclaimable garbage — see ARTIFACT_SUFFIXES.
|
|
301
|
-
const { artifactPattern } = await import("../storage/_shared.js");
|
|
302
|
-
const re = artifactPattern();
|
|
303
|
-
let files = 0, bytes = 0, kept = 0;
|
|
304
|
-
for (const name of readdirSync(dataDir)) {
|
|
305
|
-
const m = re.exec(name);
|
|
306
|
-
if (!m)
|
|
307
|
-
continue;
|
|
308
|
-
if (live.has(m[1])) {
|
|
309
|
-
kept++;
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
const full = join(dataDir, name);
|
|
313
|
-
try {
|
|
314
|
-
bytes += statSync(full).size;
|
|
315
|
-
if (!dryRun)
|
|
316
|
-
unlinkSync(full);
|
|
317
|
-
files++;
|
|
318
|
-
}
|
|
319
|
-
catch { /* skip unreadable/already-gone */ }
|
|
320
|
-
}
|
|
321
|
-
// De-register the dead entries. After the sweep, so a failure above leaves the
|
|
322
|
-
// registry untouched rather than half-cleaned.
|
|
323
|
-
if (!dryRun && stale.length > 0) {
|
|
324
|
-
const { removeRepo } = await import("../storage/registry.js");
|
|
325
|
-
for (const s of stale)
|
|
326
|
-
await removeRepo(join(dataDir, "registry.json"), s.name);
|
|
327
|
-
}
|
|
328
|
-
output({
|
|
329
|
-
stale_repos: stale.length,
|
|
330
|
-
stale_examples: stale.slice(0, 5).map((s) => s.name),
|
|
331
|
-
pruned: !dryRun,
|
|
332
|
-
dry_run: dryRun,
|
|
333
|
-
orphan_files: files,
|
|
334
|
-
freed_gb: +(bytes / 1e9).toFixed(2),
|
|
335
|
-
kept_live_artifacts: kept,
|
|
336
|
-
data_dir: dataDir,
|
|
337
|
-
}, flags);
|
|
338
|
-
}
|
|
339
|
-
function listProcesses() {
|
|
340
|
-
const raw = execFileSync("ps", ["-axo", "pid=,ppid=,rss=,command="], { encoding: "utf-8" });
|
|
341
|
-
const rows = [];
|
|
342
|
-
for (const line of raw.split("\n")) {
|
|
343
|
-
const match = line.match(/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.+)$/);
|
|
344
|
-
if (!match)
|
|
345
|
-
continue;
|
|
346
|
-
rows.push({
|
|
347
|
-
pid: Number(match[1]),
|
|
348
|
-
ppid: Number(match[2]),
|
|
349
|
-
rssKb: Number(match[3]),
|
|
350
|
-
command: match[4] ?? "",
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
return rows;
|
|
354
|
-
}
|
|
355
|
-
function classifyCleanupTarget(command, includeGlobalCodesift) {
|
|
356
|
-
if (command === "" || command.includes("codesift cleanup-processes"))
|
|
357
|
-
return null;
|
|
358
|
-
if (command.startsWith("node /Users/") && command.includes("/DEV/codesift-mcp/dist/server.js")) {
|
|
359
|
-
return "legacy-dev-dist-server";
|
|
360
|
-
}
|
|
361
|
-
if (command.includes("npm exec chrome-devtools-mcp") || command === "chrome-devtools-mcp") {
|
|
362
|
-
return "chrome-devtools-mcp";
|
|
363
|
-
}
|
|
364
|
-
if (command.includes("chrome-devtools-mcp/") && command.includes("/watchdog/main.js")) {
|
|
365
|
-
return "chrome-devtools-watchdog";
|
|
366
|
-
}
|
|
367
|
-
if (command.includes("npm exec @sentry/mcp-server")) {
|
|
368
|
-
return "sentry-mcp";
|
|
369
|
-
}
|
|
370
|
-
if (command.includes("npm exec @playwright/mcp")) {
|
|
371
|
-
return "playwright-mcp";
|
|
372
|
-
}
|
|
373
|
-
if (includeGlobalCodesift && command.includes("/.npm-global/bin/codesift-mcp")) {
|
|
374
|
-
return "global-codesift-mcp";
|
|
375
|
-
}
|
|
376
|
-
return null;
|
|
377
|
-
}
|
|
378
|
-
async function handleCleanupProcesses(_args, flags) {
|
|
379
|
-
const dryRun = getBoolFlag(flags, "dry-run") === true;
|
|
380
|
-
const includeGlobalCodesift = getBoolFlag(flags, "global-codesift") === true;
|
|
381
|
-
const rows = listProcesses();
|
|
382
|
-
const targets = rows
|
|
383
|
-
.map((row) => ({ ...row, reason: classifyCleanupTarget(row.command, includeGlobalCodesift) }))
|
|
384
|
-
.filter((row) => row.reason !== null);
|
|
385
|
-
const beforeMb = targets.reduce((sum, row) => sum + row.rssKb, 0) / 1024;
|
|
386
|
-
const killed = [];
|
|
387
|
-
const failed = [];
|
|
388
|
-
if (!dryRun) {
|
|
389
|
-
for (const row of targets) {
|
|
390
|
-
try {
|
|
391
|
-
process.kill(row.pid, "SIGKILL");
|
|
392
|
-
killed.push(row);
|
|
393
|
-
}
|
|
394
|
-
catch (err) {
|
|
395
|
-
failed.push({ ...row, error: err instanceof Error ? err.message : String(err) });
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
const byReason = {};
|
|
400
|
-
for (const row of targets) {
|
|
401
|
-
byReason[row.reason] ??= { count: 0, rss_mb: 0 };
|
|
402
|
-
byReason[row.reason].count += 1;
|
|
403
|
-
byReason[row.reason].rss_mb += row.rssKb / 1024;
|
|
404
|
-
}
|
|
405
|
-
for (const value of Object.values(byReason)) {
|
|
406
|
-
value.rss_mb = Number(value.rss_mb.toFixed(1));
|
|
407
|
-
}
|
|
408
|
-
output({
|
|
409
|
-
dry_run: dryRun,
|
|
410
|
-
include_global_codesift: includeGlobalCodesift,
|
|
411
|
-
matched: targets.length,
|
|
412
|
-
killed: dryRun ? 0 : killed.length,
|
|
413
|
-
failed: failed.length,
|
|
414
|
-
matched_rss_mb: Number(beforeMb.toFixed(1)),
|
|
415
|
-
by_reason: byReason,
|
|
416
|
-
failed_pids: failed.map((row) => ({ pid: row.pid, reason: row.reason, error: row.error })),
|
|
417
|
-
}, flags);
|
|
418
|
-
}
|
|
419
|
-
async function handleIndexConversations(args, flags) {
|
|
420
|
-
const projectPath = args[0];
|
|
421
|
-
const { indexConversations } = await import("../tools/conversation-tools.js");
|
|
422
|
-
const result = await indexConversations(projectPath);
|
|
423
|
-
if (!getBoolFlag(flags, "quiet")) {
|
|
424
|
-
output(result, flags);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
// ---------------------------------------------------------------------------
|
|
428
|
-
// Search commands
|
|
429
|
-
// ---------------------------------------------------------------------------
|
|
430
|
-
async function handleSearch(args, flags) {
|
|
431
|
-
const repo = requireArg(args, 0, "repo");
|
|
432
|
-
const query = requireArg(args, 1, "query");
|
|
433
|
-
const { searchText } = await import("../tools/search-tools.js");
|
|
434
|
-
const result = await searchText(repo, query, {
|
|
435
|
-
file_pattern: getFlag(flags, "file-pattern"),
|
|
436
|
-
regex: getBoolFlag(flags, "regex"),
|
|
437
|
-
context_lines: getNumFlag(flags, "context-lines"),
|
|
438
|
-
max_results: getNumFlag(flags, "max-results"),
|
|
439
|
-
group_by_file: getBoolFlag(flags, "group-by-file"),
|
|
440
|
-
});
|
|
441
|
-
output(result, flags);
|
|
442
|
-
}
|
|
443
|
-
async function handleSymbols(args, flags) {
|
|
444
|
-
const repo = requireArg(args, 0, "repo");
|
|
445
|
-
const query = requireArg(args, 1, "query");
|
|
446
|
-
const { searchSymbols } = await import("../tools/search-tools.js");
|
|
447
|
-
const kindRaw = getFlag(flags, "kind");
|
|
448
|
-
if (kindRaw !== undefined && !VALID_SYMBOL_KINDS.has(kindRaw)) {
|
|
449
|
-
die(`Invalid --kind: ${kindRaw}. Valid: ${Array.from(VALID_SYMBOL_KINDS).join(", ")}`);
|
|
450
|
-
}
|
|
451
|
-
const includeSource = getBoolFlag(flags, "include-source");
|
|
452
|
-
const explicitTopK = getNumFlag(flags, "top-k");
|
|
453
|
-
// When --include-source is set and no explicit --top-k, default to 5
|
|
454
|
-
// instead of 50 to avoid returning 50 full function bodies
|
|
455
|
-
const topK = explicitTopK ?? (includeSource ? 5 : undefined);
|
|
456
|
-
const result = await searchSymbols(repo, query, {
|
|
457
|
-
kind: kindRaw,
|
|
458
|
-
file_pattern: getFlag(flags, "file-pattern"),
|
|
459
|
-
include_source: includeSource,
|
|
460
|
-
top_k: topK,
|
|
461
|
-
source_chars: getNumFlag(flags, "source-chars"),
|
|
462
|
-
});
|
|
463
|
-
output(result, flags);
|
|
464
|
-
}
|
|
465
|
-
// ---------------------------------------------------------------------------
|
|
466
|
-
// Outline commands
|
|
467
|
-
// ---------------------------------------------------------------------------
|
|
468
|
-
async function handleTree(args, flags) {
|
|
469
|
-
const repo = requireArg(args, 0, "repo");
|
|
470
|
-
const { getFileTree } = await import("../tools/outline-tools.js");
|
|
471
|
-
const result = await getFileTree(repo, {
|
|
472
|
-
path_prefix: getFlag(flags, "path") ?? args[1],
|
|
473
|
-
name_pattern: getFlag(flags, "name-pattern"),
|
|
474
|
-
depth: getNumFlag(flags, "depth"),
|
|
475
|
-
compact: getBoolFlag(flags, "compact"),
|
|
476
|
-
min_symbols: getNumFlag(flags, "min-symbols"),
|
|
477
|
-
});
|
|
478
|
-
output(result, flags);
|
|
479
|
-
}
|
|
480
|
-
async function handleOutline(args, flags) {
|
|
481
|
-
const repo = requireArg(args, 0, "repo");
|
|
482
|
-
const file = requireArg(args, 1, "file");
|
|
483
|
-
const { getFileOutline } = await import("../tools/outline-tools.js");
|
|
484
|
-
const result = await getFileOutline(repo, file);
|
|
485
|
-
output(result, flags);
|
|
486
|
-
}
|
|
487
|
-
async function handleRepoOutline(args, flags) {
|
|
488
|
-
const repo = requireArg(args, 0, "repo");
|
|
489
|
-
const { getRepoOutline } = await import("../tools/outline-tools.js");
|
|
490
|
-
const result = await getRepoOutline(repo);
|
|
491
|
-
output(result, flags);
|
|
492
|
-
}
|
|
493
|
-
// ---------------------------------------------------------------------------
|
|
494
|
-
// Symbol commands
|
|
495
|
-
// ---------------------------------------------------------------------------
|
|
496
|
-
async function handleSymbol(args, flags) {
|
|
497
|
-
const repo = requireArg(args, 0, "repo");
|
|
498
|
-
const id = requireArg(args, 1, "id");
|
|
499
|
-
const { getSymbol } = await import("../tools/symbol-tools.js");
|
|
500
|
-
const result = await getSymbol(repo, id);
|
|
501
|
-
if (result === null) {
|
|
502
|
-
die(`Symbol not found: ${id}`);
|
|
503
|
-
}
|
|
504
|
-
output(result.symbol, flags);
|
|
505
|
-
}
|
|
506
|
-
async function handleSymbolsBatch(args, flags) {
|
|
507
|
-
const repo = requireArg(args, 0, "repo");
|
|
508
|
-
const ids = args.slice(1);
|
|
509
|
-
if (ids.length === 0) {
|
|
510
|
-
die("Missing required argument: <ids...>");
|
|
511
|
-
}
|
|
512
|
-
const { getSymbols } = await import("../tools/symbol-tools.js");
|
|
513
|
-
const result = await getSymbols(repo, ids);
|
|
514
|
-
output(result, flags);
|
|
515
|
-
}
|
|
516
|
-
async function handleFind(args, flags) {
|
|
517
|
-
const repo = requireArg(args, 0, "repo");
|
|
518
|
-
const query = requireArg(args, 1, "query");
|
|
519
|
-
const { findAndShow } = await import("../tools/symbol-tools.js");
|
|
520
|
-
const result = await findAndShow(repo, query, getBoolFlag(flags, "include-refs"));
|
|
521
|
-
if (result === null) {
|
|
522
|
-
die(`No symbol found matching: ${query}`);
|
|
523
|
-
}
|
|
524
|
-
output(result, flags);
|
|
525
|
-
}
|
|
526
|
-
async function handleRefs(args, flags) {
|
|
527
|
-
const repo = requireArg(args, 0, "repo");
|
|
528
|
-
const name = requireArg(args, 1, "name");
|
|
529
|
-
const { findReferences } = await import("../tools/symbol-tools.js");
|
|
530
|
-
const result = await findReferences(repo, name, getFlag(flags, "file-pattern"));
|
|
531
|
-
if (getBoolFlag(flags, "json")) {
|
|
532
|
-
output(result, flags);
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
// Compact tabular output: file:line:col | context
|
|
536
|
-
for (const ref of result) {
|
|
537
|
-
const loc = `${ref.file}:${ref.line}${ref.col ? `:${ref.col}` : ""}`;
|
|
538
|
-
process.stdout.write(`${loc} | ${ref.context}\n`);
|
|
539
|
-
}
|
|
540
|
-
process.stderr.write(`\n${result.length} references found\n`);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
// ---------------------------------------------------------------------------
|
|
544
|
-
// Graph commands
|
|
545
|
-
// ---------------------------------------------------------------------------
|
|
546
|
-
function printTraceCompact(root) {
|
|
547
|
-
function printNode(node, indent) {
|
|
548
|
-
const prefix = indent === 0 ? "" : " ".repeat(indent) + "|- ";
|
|
549
|
-
const sym = node.symbol;
|
|
550
|
-
const sig = sym.signature ? ` ${sym.signature}` : "";
|
|
551
|
-
const loc = `${sym.file}:${sym.start_line}`;
|
|
552
|
-
process.stdout.write(`${prefix}${sym.kind} | ${sym.name}${sig} | ${loc}\n`);
|
|
553
|
-
for (const child of node.children) {
|
|
554
|
-
printNode(child, indent + 1);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
printNode(root, 0);
|
|
558
|
-
function countNodes(node) {
|
|
559
|
-
return 1 + node.children.reduce((sum, c) => sum + countNodes(c), 0);
|
|
560
|
-
}
|
|
561
|
-
process.stderr.write(`\n${countNodes(root)} symbols in trace\n`);
|
|
562
|
-
}
|
|
563
|
-
async function handleTrace(args, flags) {
|
|
564
|
-
const repo = requireArg(args, 0, "repo");
|
|
565
|
-
const name = requireArg(args, 1, "name");
|
|
566
|
-
const { traceCallChain } = await import("../tools/graph-tools.js");
|
|
567
|
-
const direction = (getFlag(flags, "direction") ?? "callers");
|
|
568
|
-
if (direction !== "callers" && direction !== "callees") {
|
|
569
|
-
die(`Invalid --direction: ${direction}. Must be "callers" or "callees".`);
|
|
570
|
-
}
|
|
571
|
-
const result = await traceCallChain(repo, name, direction, {
|
|
572
|
-
depth: getNumFlag(flags, "depth"),
|
|
573
|
-
include_source: getBoolFlag(flags, "include-source") ?? false,
|
|
574
|
-
include_tests: getBoolFlag(flags, "include-tests") ?? false,
|
|
575
|
-
});
|
|
576
|
-
if (getBoolFlag(flags, "json")) {
|
|
577
|
-
output(result, flags);
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
printTraceCompact(result);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
async function handleImpact(args, flags) {
|
|
584
|
-
const repo = requireArg(args, 0, "repo");
|
|
585
|
-
const since = requireFlag(flags, "since");
|
|
586
|
-
const { impactAnalysis } = await import("../tools/impact-tools.js");
|
|
587
|
-
const result = await impactAnalysis(repo, since, {
|
|
588
|
-
depth: getNumFlag(flags, "depth"),
|
|
589
|
-
until: getFlag(flags, "until"),
|
|
590
|
-
include_source: getBoolFlag(flags, "include-source"),
|
|
591
|
-
});
|
|
592
|
-
output(result, flags);
|
|
593
|
-
}
|
|
594
|
-
// ---------------------------------------------------------------------------
|
|
595
|
-
// Context commands
|
|
596
|
-
// ---------------------------------------------------------------------------
|
|
597
|
-
async function handleContext(args, flags) {
|
|
598
|
-
const repo = requireArg(args, 0, "repo");
|
|
599
|
-
const query = requireArg(args, 1, "query");
|
|
600
|
-
const { assembleContext } = await import("../tools/context-tools.js");
|
|
601
|
-
const result = await assembleContext(repo, query, getNumFlag(flags, "token-budget"));
|
|
602
|
-
output(result, flags);
|
|
603
|
-
}
|
|
604
|
-
async function handleKnowledgeMap(args, flags) {
|
|
605
|
-
const repo = requireArg(args, 0, "repo");
|
|
606
|
-
const { getKnowledgeMap } = await import("../tools/context-tools.js");
|
|
607
|
-
const result = await getKnowledgeMap(repo, getFlag(flags, "focus"), getNumFlag(flags, "depth"));
|
|
608
|
-
output(result, flags);
|
|
609
|
-
}
|
|
610
|
-
// ---------------------------------------------------------------------------
|
|
611
|
-
// Diff commands
|
|
612
|
-
// ---------------------------------------------------------------------------
|
|
613
|
-
async function handleDiff(args, flags) {
|
|
614
|
-
const repo = requireArg(args, 0, "repo");
|
|
615
|
-
const since = requireFlag(flags, "since");
|
|
616
|
-
const { diffOutline } = await import("../tools/diff-tools.js");
|
|
617
|
-
const result = await diffOutline(repo, since, getFlag(flags, "until"));
|
|
618
|
-
output(result, flags);
|
|
619
|
-
}
|
|
620
|
-
async function handleChanged(args, flags) {
|
|
621
|
-
const repo = requireArg(args, 0, "repo");
|
|
622
|
-
const since = requireFlag(flags, "since");
|
|
623
|
-
const { changedSymbols } = await import("../tools/diff-tools.js");
|
|
624
|
-
const result = await changedSymbols(repo, since, getFlag(flags, "until"));
|
|
625
|
-
output(result, flags);
|
|
626
|
-
}
|
|
627
|
-
// ---------------------------------------------------------------------------
|
|
628
|
-
// Retrieval & utility commands
|
|
629
|
-
// ---------------------------------------------------------------------------
|
|
630
|
-
function parseRetrievalQueries(flags) {
|
|
631
|
-
const queriesRaw = getFlag(flags, "queries");
|
|
632
|
-
if (!queriesRaw) {
|
|
633
|
-
die("Missing required flag: --queries <json>");
|
|
634
|
-
}
|
|
635
|
-
let parsed;
|
|
636
|
-
try {
|
|
637
|
-
parsed = JSON.parse(queriesRaw);
|
|
638
|
-
}
|
|
639
|
-
catch {
|
|
640
|
-
die("Invalid JSON for --queries flag");
|
|
641
|
-
}
|
|
642
|
-
if (!Array.isArray(parsed)) {
|
|
643
|
-
die("--queries must be a JSON array");
|
|
644
|
-
}
|
|
645
|
-
for (const item of parsed) {
|
|
646
|
-
if (typeof item !== "object" || item === null || typeof item.type !== "string") {
|
|
647
|
-
die("Each --queries entry must be an object with a \"type\" string field");
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
const queries = parsed;
|
|
651
|
-
// --exclude-tests (default: true) — inject into semantic/hybrid sub-queries
|
|
652
|
-
const excludeTests = getBoolFlag(flags, "exclude-tests") !== false;
|
|
653
|
-
for (const q of queries) {
|
|
654
|
-
if (EXCLUDE_TESTS_QUERY_TYPES.has(q.type) && q["exclude_tests"] === undefined) {
|
|
655
|
-
q["exclude_tests"] = excludeTests;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
return queries;
|
|
659
|
-
}
|
|
660
|
-
async function handleRetrieve(args, flags) {
|
|
661
|
-
const repo = requireArg(args, 0, "repo");
|
|
662
|
-
const queries = parseRetrievalQueries(flags);
|
|
663
|
-
const { codebaseRetrieval } = await import("../retrieval/codebase-retrieval.js");
|
|
664
|
-
const result = await codebaseRetrieval(repo, queries, getNumFlag(flags, "token-budget"));
|
|
665
|
-
output(result, flags);
|
|
666
|
-
}
|
|
667
|
-
async function handleStats(_args, flags) {
|
|
668
|
-
const { getUsageStats, formatUsageReport } = await import("../storage/usage-stats.js");
|
|
669
|
-
const stats = await getUsageStats();
|
|
670
|
-
// If --json flag is set (or default), output raw stats; otherwise formatted report
|
|
671
|
-
if (getBoolFlag(flags, "json") === false) {
|
|
672
|
-
const report = formatUsageReport(stats);
|
|
673
|
-
process.stdout.write(report + "\n");
|
|
674
|
-
}
|
|
675
|
-
else {
|
|
676
|
-
output(stats, flags);
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
async function handleGenerateClaudeMd(args, flags) {
|
|
680
|
-
const repo = requireArg(args, 0, "repo");
|
|
681
|
-
const { generateClaudeMd } = await import("../tools/generate-tools.js");
|
|
682
|
-
const result = await generateClaudeMd(repo, getFlag(flags, "output"));
|
|
683
|
-
output(result, flags);
|
|
684
|
-
}
|
|
685
|
-
// ---------------------------------------------------------------------------
|
|
686
|
-
// Analysis commands
|
|
687
|
-
// ---------------------------------------------------------------------------
|
|
688
|
-
async function handleComplexity(args, flags) {
|
|
689
|
-
const repo = requireArg(args, 0, "repo");
|
|
690
|
-
const { analyzeComplexity } = await import("../tools/complexity-tools.js");
|
|
691
|
-
const result = await analyzeComplexity(repo, {
|
|
692
|
-
file_pattern: getFlag(flags, "file-pattern"),
|
|
693
|
-
top_n: getNumFlag(flags, "top-n"),
|
|
694
|
-
min_complexity: getNumFlag(flags, "min-complexity"),
|
|
695
|
-
include_tests: getBoolFlag(flags, "include-tests"),
|
|
696
|
-
});
|
|
697
|
-
output(result, flags);
|
|
698
|
-
}
|
|
699
|
-
async function handleDeadCode(args, flags) {
|
|
700
|
-
const repo = requireArg(args, 0, "repo");
|
|
701
|
-
const { findDeadCode } = await import("../tools/symbol-tools.js");
|
|
702
|
-
const result = await findDeadCode(repo, {
|
|
703
|
-
file_pattern: getFlag(flags, "file-pattern"),
|
|
704
|
-
include_tests: getBoolFlag(flags, "include-tests"),
|
|
705
|
-
});
|
|
706
|
-
output(result, flags);
|
|
707
|
-
}
|
|
708
|
-
async function handleHotspots(args, flags) {
|
|
709
|
-
const repo = requireArg(args, 0, "repo");
|
|
710
|
-
const { analyzeHotspots } = await import("../tools/hotspot-tools.js");
|
|
711
|
-
const result = await analyzeHotspots(repo, {
|
|
712
|
-
since_days: getNumFlag(flags, "since-days"),
|
|
713
|
-
top_n: getNumFlag(flags, "top-n"),
|
|
714
|
-
file_pattern: getFlag(flags, "file-pattern"),
|
|
715
|
-
});
|
|
716
|
-
output(result, flags);
|
|
717
|
-
}
|
|
718
|
-
async function handleCommunities(args, flags) {
|
|
719
|
-
const repo = requireArg(args, 0, "repo");
|
|
720
|
-
const { detectCommunities } = await import("../tools/community-tools.js");
|
|
721
|
-
const result = await detectCommunities(repo, getFlag(flags, "focus"), getNumFlag(flags, "resolution"), getFlag(flags, "output-format"));
|
|
722
|
-
output(result, flags);
|
|
723
|
-
}
|
|
724
|
-
async function handlePatterns(args, flags) {
|
|
725
|
-
const repo = requireArg(args, 0, "repo");
|
|
726
|
-
const pattern = requireFlag(flags, "pattern");
|
|
727
|
-
const { searchPatterns } = await import("../tools/pattern-tools.js");
|
|
728
|
-
const result = await searchPatterns(repo, pattern, {
|
|
729
|
-
file_pattern: getFlag(flags, "file-pattern"),
|
|
730
|
-
include_tests: getBoolFlag(flags, "include-tests"),
|
|
731
|
-
max_results: getNumFlag(flags, "max-results"),
|
|
732
|
-
});
|
|
733
|
-
output(result, flags);
|
|
734
|
-
}
|
|
735
|
-
async function handleSetup(args, flags) {
|
|
736
|
-
const platform = args[0];
|
|
737
|
-
const { formatSetupLines, SUPPORTED_PLATFORMS } = await import("./setup.js");
|
|
738
|
-
if (!platform) {
|
|
739
|
-
die(`Missing platform. Usage: codesift setup <${SUPPORTED_PLATFORMS.join("|")}|all>`);
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
const hooks = getBoolFlag(flags, "no-hooks")
|
|
743
|
-
? false
|
|
744
|
-
: (getBoolFlag(flags, "hooks") ?? true);
|
|
745
|
-
const rules = getBoolFlag(flags, "no-rules")
|
|
746
|
-
? false
|
|
747
|
-
: (getBoolFlag(flags, "rules") ?? true);
|
|
748
|
-
const force = getBoolFlag(flags, "force") ?? false;
|
|
749
|
-
// `--no-git-hooks` is a standalone boolean flag (parseArgs stores "no-git-hooks", not "git-hooks": false).
|
|
750
|
-
const gitHooks = getBoolFlag(flags, "no-git-hooks")
|
|
751
|
-
? false
|
|
752
|
-
: (getBoolFlag(flags, "git-hooks") ?? hooks);
|
|
753
|
-
// --http points the client at the shared `codesift serve` daemon (one process
|
|
754
|
-
// per machine) instead of spawning a stdio server per editor window.
|
|
755
|
-
const http = getBoolFlag(flags, "http") ?? false;
|
|
756
|
-
const port = getNumFlag(flags, "port");
|
|
757
|
-
// A SHARED daemon needs a host and a token; without these `--http` could only
|
|
758
|
-
// ever mean "the daemon on this machine", which defeats the point of having
|
|
759
|
-
// one process serve several.
|
|
760
|
-
const daemonHost = getFlag(flags, "host");
|
|
761
|
-
const daemonToken = getFlag(flags, "token") ?? process.env["CODESIFT_HTTP_TOKEN"];
|
|
762
|
-
// A bearer token on a plaintext link to another machine is refused unless the operator either
|
|
763
|
-
// asks for https or states that the transport is already encrypted (tailnet/VPN/SSH tunnel).
|
|
764
|
-
const rawScheme = getFlag(flags, "scheme");
|
|
765
|
-
const daemonScheme = rawScheme === "https" ? "https" : rawScheme === "http" ? "http" : undefined;
|
|
766
|
-
const insecureTransport = getBoolFlag(flags, "insecure-transport") ?? false;
|
|
767
|
-
const options = {
|
|
768
|
-
hooks, rules, force, gitHooks, http,
|
|
769
|
-
...(port !== undefined ? { port } : {}),
|
|
770
|
-
...(daemonHost ? { host: daemonHost } : {}),
|
|
771
|
-
...(daemonToken ? { token: daemonToken } : {}),
|
|
772
|
-
...(daemonScheme ? { scheme: daemonScheme } : {}),
|
|
773
|
-
...(insecureTransport ? { insecureTransport } : {}),
|
|
774
|
-
};
|
|
775
|
-
/** Global post-commit backlog hook — wired here because `formatSetupLines` stays editor-setup only (see setup/setupAll for programmatic installs). */
|
|
776
|
-
async function emitGlobalGitHooksIfRequested() {
|
|
777
|
-
if (options.gitHooks === false)
|
|
778
|
-
return;
|
|
779
|
-
// Match setup(): git hooks accompany editor hooks by default; allow `--git-hooks` without `--hooks`.
|
|
780
|
-
const wantGitHooks = options.hooks || getBoolFlag(flags, "git-hooks") === true;
|
|
781
|
-
if (!wantGitHooks)
|
|
782
|
-
return;
|
|
783
|
-
const { installGitHooks } = await import("./git-hooks-installer.js");
|
|
784
|
-
const result = await installGitHooks({ force });
|
|
785
|
-
if (result.reason) {
|
|
786
|
-
process.stdout.write(`⚠️ git hooks: ${result.reason}\n`);
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
process.stdout.write(`✓ git post-commit hook → ${result.hooksPath}\n`);
|
|
790
|
-
if (result.hooksPathSkippedReason) {
|
|
791
|
-
process.stdout.write(` (${result.hooksPathSkippedReason})\n`);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
if (platform === "all") {
|
|
795
|
-
for (const p of SUPPORTED_PLATFORMS) {
|
|
796
|
-
const lines = await formatSetupLines(p, options);
|
|
797
|
-
for (const line of lines)
|
|
798
|
-
process.stdout.write(line + "\n");
|
|
799
|
-
}
|
|
800
|
-
await emitGlobalGitHooksIfRequested();
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
const lines = await formatSetupLines(platform, options);
|
|
804
|
-
for (const line of lines)
|
|
805
|
-
process.stdout.write(line + "\n");
|
|
806
|
-
await emitGlobalGitHooksIfRequested();
|
|
807
|
-
}
|
|
808
|
-
async function handleFindClones(args, flags) {
|
|
809
|
-
const repo = requireArg(args, 0, "repo");
|
|
810
|
-
const { findClones } = await import("../tools/clone-tools.js");
|
|
811
|
-
const result = await findClones(repo, {
|
|
812
|
-
file_pattern: getFlag(flags, "file-pattern"),
|
|
813
|
-
min_similarity: getNumFlag(flags, "threshold"),
|
|
814
|
-
min_lines: getNumFlag(flags, "min-lines"),
|
|
815
|
-
include_tests: getBoolFlag(flags, "include-tests"),
|
|
816
|
-
});
|
|
817
|
-
output(result, flags);
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* `codesift service install|uninstall|status` — supervise the shared daemon.
|
|
821
|
-
*
|
|
822
|
-
* `serve` alone dies with the terminal that started it and never comes back
|
|
823
|
-
* after a crash or reboot, which is precisely the failure the shared-daemon
|
|
824
|
-
* model cannot tolerate: every client is configured to talk to one process.
|
|
825
|
-
*/
|
|
826
|
-
async function handleService(args, flags) {
|
|
827
|
-
const { installService, uninstallService, serviceStatus, DEFAULT_SERVICE_PORT } = await import("./service.js");
|
|
828
|
-
const { loadConfig } = await import("../config.js");
|
|
829
|
-
const dataDir = loadConfig().dataDir;
|
|
830
|
-
const sub = args[0] ?? "status";
|
|
831
|
-
try {
|
|
832
|
-
if (sub === "install") {
|
|
833
|
-
const port = getNumFlag(flags, "port") ?? DEFAULT_SERVICE_PORT;
|
|
834
|
-
const host = getFlag(flags, "host") ?? "127.0.0.1";
|
|
835
|
-
// A routable bind needs a token; the server enforces the same rule.
|
|
836
|
-
const token = getFlag(flags, "token") ?? process.env["CODESIFT_HTTP_TOKEN"];
|
|
837
|
-
// Carry the caller's CODESIFT_* environment into the unit. A service gets
|
|
838
|
-
// almost nothing from the shell, so an embedding provider set only in the
|
|
839
|
-
// shell is silently lost and the daemon falls back to on-CPU ONNX.
|
|
840
|
-
const inheritedEnv = {};
|
|
841
|
-
for (const [k, v] of Object.entries(process.env)) {
|
|
842
|
-
if (k.startsWith("CODESIFT_") && k !== "CODESIFT_HTTP_TOKEN" && typeof v === "string") {
|
|
843
|
-
inheritedEnv[k] = v;
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
output(installService({
|
|
847
|
-
dataDir, port, host,
|
|
848
|
-
...(token ? { token } : {}),
|
|
849
|
-
...(Object.keys(inheritedEnv).length > 0 ? { env: inheritedEnv } : {}),
|
|
850
|
-
force: getBoolFlag(flags, "force") === true,
|
|
851
|
-
}), flags);
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
if (sub === "uninstall") {
|
|
855
|
-
output(uninstallService({ dataDir }), flags);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
if (sub === "status") {
|
|
859
|
-
output(serviceStatus({ dataDir }), flags);
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
catch (e) {
|
|
864
|
-
die(`service: ${e.message}`);
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
die(`service: unknown subcommand "${sub}" (expected install, uninstall or status)`);
|
|
868
|
-
}
|
|
2
|
+
// CLI command dispatch facade
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
import { handleServe } from "./commands-daemon.js";
|
|
5
|
+
import { handleIndex, handleIndexRepo, handleRepos, handleInvalidate, handleIndexConversations, } from "./commands-index.js";
|
|
6
|
+
import { handlePrune, handleCleanupProcesses } from "./commands-maintenance.js";
|
|
7
|
+
import { handleSearch, handleSymbols, handleTree, handleOutline, handleRepoOutline, handleSymbol, handleSymbolsBatch, handleFind, handleRefs, handleTrace, handleImpact, handleContext, handleKnowledgeMap, handleDiff, handleChanged, handleRetrieve, handleStats, handleGenerateClaudeMd, } from "./commands-query.js";
|
|
8
|
+
import { handleComplexity, handleDeadCode, handleHotspots, handleCommunities, handlePatterns, handleSetup, handleFindClones, handleService, } from "./commands-admin.js";
|
|
9
|
+
export { DEFAULT_DAEMON_PORT, daemonLockPaths, isProcessAlive, readDaemonLock, startDaemon, } from "./commands-daemon.js";
|
|
869
10
|
// ---------------------------------------------------------------------------
|
|
870
11
|
// Command dispatch map
|
|
871
12
|
// ---------------------------------------------------------------------------
|