pi-lens 3.8.73 → 4.0.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/CHANGELOG.md +2614 -12
- package/README.md +50 -21
- package/dist/clients/actionable-warnings.js +73 -18
- package/dist/clients/agent-behavior-client.js +21 -4
- package/dist/clients/ast-grep-client.js +68 -16
- package/dist/clients/ast-grep-types.js +0 -1
- package/dist/clients/ast-grep-yaml-synth.js +37 -10
- package/dist/clients/atomic-write-staging.js +63 -0
- package/dist/clients/atomic-write.js +116 -16
- package/dist/clients/bash-file-access.js +193 -23
- package/dist/clients/biome-client.js +29 -25
- package/dist/clients/bootstrap.js +11 -2
- package/dist/clients/bounded-cache.js +34 -0
- package/dist/clients/bounded-pid-file-lock.js +192 -0
- package/dist/clients/bus-events-logger.js +5 -1
- package/dist/clients/bus-publish.js +10 -3
- package/dist/clients/cache/rule-cache.js +89 -6
- package/dist/clients/cache-manager.js +97 -9
- package/dist/clients/cache-observability.js +498 -0
- package/dist/clients/call-graph.js +460 -108
- package/dist/clients/cascade-logger.js +5 -1
- package/dist/clients/child-unref.js +85 -0
- package/dist/clients/codebase-model.js +52 -23
- package/dist/clients/collateral-test-role.js +40 -0
- package/dist/clients/complexity-client.js +6 -8
- package/dist/clients/console-guard-install.js +14 -0
- package/dist/clients/cooperative-budget.js +42 -0
- package/dist/clients/dead-code-client.js +2 -1
- package/dist/clients/debug-handles.js +206 -0
- package/dist/clients/debug-heap.js +167 -0
- package/dist/clients/degradation-ledger.js +153 -0
- package/dist/clients/dependency-checker.js +466 -63
- package/dist/clients/diagnostic-dispositions.js +83 -13
- package/dist/clients/diagnostics-publish.js +10 -3
- package/dist/clients/dispatch/auxiliary-lsp.js +34 -0
- package/dist/clients/dispatch/dispatcher.js +71 -13
- package/dist/clients/dispatch/fact-store.js +11 -0
- package/dist/clients/dispatch/facts/function-facts.js +37 -7
- package/dist/clients/dispatch/facts/import-facts.js +108 -119
- package/dist/clients/dispatch/facts/tree-sitter-facts.js +12 -12
- package/dist/clients/dispatch/facts/try-catch-facts.js +13 -0
- package/dist/clients/dispatch/indent-detect.js +35 -0
- package/dist/clients/dispatch/inline-suppressions.js +17 -8
- package/dist/clients/dispatch/integration.js +1094 -611
- package/dist/clients/dispatch/lazy.js +14 -0
- package/dist/clients/dispatch/plan.js +11 -1
- package/dist/clients/dispatch/rule-id-normalize.js +50 -0
- package/dist/clients/dispatch/rule-policy.js +135 -0
- package/dist/clients/dispatch/rules/async-noise.js +1 -0
- package/dist/clients/dispatch/rules/unsafe-boundary.js +7 -0
- package/dist/clients/dispatch/runners/ast-grep-napi.js +47 -6
- package/dist/clients/dispatch/runners/biome-check.js +5 -9
- package/dist/clients/dispatch/runners/detekt.js +3 -2
- package/dist/clients/dispatch/runners/hadolint.js +2 -1
- package/dist/clients/dispatch/runners/helm-lint.js +154 -0
- package/dist/clients/dispatch/runners/htmlhint.js +3 -2
- package/dist/clients/dispatch/runners/index.js +5 -1
- package/dist/clients/dispatch/runners/lsp.js +14 -6
- package/dist/clients/dispatch/runners/markdownlint.js +4 -9
- package/dist/clients/dispatch/runners/psscriptanalyzer.js +10 -1
- package/dist/clients/dispatch/runners/pyright.js +9 -5
- package/dist/clients/dispatch/runners/ruff.js +4 -8
- package/dist/clients/dispatch/runners/shellcheck.js +2 -3
- package/dist/clients/dispatch/runners/shfmt.js +2 -3
- package/dist/clients/dispatch/runners/spotbugs.js +2 -1
- package/dist/clients/dispatch/runners/taplo.js +2 -1
- package/dist/clients/dispatch/runners/terragrunt.js +163 -0
- package/dist/clients/dispatch/runners/tflint.js +37 -5
- package/dist/clients/dispatch/runners/tree-sitter.js +155 -166
- package/dist/clients/dispatch/runners/trivy-config.js +13 -7
- package/dist/clients/dispatch/runners/utils/lazy-installer.js +3 -0
- package/dist/clients/dispatch/runners/utils/runner-helpers.js +284 -34
- package/dist/clients/dispatch/runners/utils/spawn-outcome.js +22 -0
- package/dist/clients/dispatch/runners/yaml-rule-parser.js +5 -4
- package/dist/clients/disposition-publish.js +10 -3
- package/dist/clients/durable-store.js +97 -0
- package/dist/clients/event-loop-monitor.js +94 -3
- package/dist/clients/extension-log.js +139 -0
- package/dist/clients/extension-mode.js +73 -0
- package/dist/clients/feature-hints.js +53 -7
- package/dist/clients/file-kinds.js +143 -31
- package/dist/clients/file-role.js +18 -3
- package/dist/clients/file-utils.js +56 -34
- package/dist/clients/fix-worklog.js +14 -2
- package/dist/clients/format-events-publish.js +16 -3
- package/dist/clients/format-service.js +24 -8
- package/dist/clients/formatters-lazy.js +8 -0
- package/dist/clients/formatters.js +358 -61
- package/dist/clients/generated-artifacts.js +169 -15
- package/dist/clients/git-guard.js +681 -11
- package/dist/clients/git-tracked-ignore.js +4 -0
- package/dist/clients/go-client.js +2 -1
- package/dist/clients/govulncheck-client.js +8 -0
- package/dist/clients/grammar-source.js +12 -4
- package/dist/clients/gzip-stage-write.js +102 -0
- package/dist/clients/host-ports.js +31 -0
- package/dist/clients/installer/index.js +733 -213
- package/dist/clients/instance-reaper.js +142 -172
- package/dist/clients/jscpd-client.js +31 -54
- package/dist/clients/knip-client.js +78 -36
- package/dist/clients/language-policy.js +14 -2
- package/dist/clients/language-profile.js +72 -77
- package/dist/clients/latency-logger.js +28 -16
- package/dist/clients/lens-config.js +140 -166
- package/dist/clients/lens-engine.js +124 -21
- package/dist/clients/lens-events.js +27 -4
- package/dist/clients/lens-flag-registry.js +293 -0
- package/dist/clients/lens-map.js +96 -26
- package/dist/clients/live-bus-emitter.js +30 -0
- package/dist/clients/log-cleanup.js +8 -18
- package/dist/clients/lsp/cascade-tier.js +23 -3
- package/dist/clients/lsp/client.js +566 -57
- package/dist/clients/lsp/config.js +74 -10
- package/dist/clients/lsp/diagnostic-binding.js +86 -0
- package/dist/clients/lsp/edits.js +1012 -121
- package/dist/clients/lsp/index.js +1840 -803
- package/dist/clients/lsp/language.js +4 -1
- package/dist/clients/lsp/launch.js +40 -32
- package/dist/clients/lsp/path-utils.js +1 -1
- package/dist/clients/lsp/ruby-drive-dirs.js +83 -0
- package/dist/clients/lsp/server.js +279 -60
- package/dist/clients/lsp/workspace-diagnostics-cache.js +28 -4
- package/dist/clients/lsp-document-symbols.js +112 -0
- package/dist/clients/lsp-lazy.js +8 -0
- package/dist/clients/lsp-mutation.js +248 -0
- package/dist/clients/mcp/analyze.js +128 -36
- package/dist/clients/mcp/ipc.js +157 -24
- package/dist/clients/mcp/review.js +36 -3
- package/dist/clients/mcp/session.js +216 -8
- package/dist/clients/memory-sampler.js +115 -0
- package/dist/clients/metrics-client.js +2 -1
- package/dist/clients/metrics-history.js +2 -1
- package/dist/clients/module-report-lsp.js +5 -0
- package/dist/clients/module-report.js +267 -82
- package/dist/clients/ndjson-logger.js +334 -103
- package/dist/clients/opengrep-client.js +1 -1
- package/dist/clients/partial-edit-apply.js +120 -5
- package/dist/clients/path-keyed-map.js +76 -0
- package/dist/clients/path-utils.js +141 -5
- package/dist/clients/performance-report.js +327 -0
- package/dist/clients/pipeline.js +54 -13
- package/dist/clients/print-mode.js +21 -0
- package/dist/clients/project-changes.js +117 -4
- package/dist/clients/project-diagnostics/cache.js +3 -2
- package/dist/clients/project-diagnostics/extractors.js +26 -115
- package/dist/clients/project-diagnostics/fresh-fetch.js +149 -19
- package/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +117 -0
- package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +37 -5
- package/dist/clients/project-diagnostics/scanner.js +268 -128
- package/dist/clients/project-lens-config.js +138 -34
- package/dist/clients/project-report.js +64 -25
- package/dist/clients/project-scale.js +8 -10
- package/dist/clients/project-snapshot-persist-worker.js +6 -0
- package/dist/clients/project-snapshot.js +767 -8
- package/dist/clients/project-trust.js +181 -0
- package/dist/clients/quiet-window.js +27 -5
- package/dist/clients/read-bridge.js +147 -0
- package/dist/clients/read-expansion.js +22 -12
- package/dist/clients/read-guard-logger.js +159 -1
- package/dist/clients/read-guard-tool-lines.js +150 -29
- package/dist/clients/read-guard.js +262 -3
- package/dist/clients/redact/secrets.js +449 -0
- package/dist/clients/resource-sampler.js +144 -39
- package/dist/clients/reverse-deps.js +48 -0
- package/dist/clients/review-graph/builder.js +2570 -326
- package/dist/clients/review-graph/git-identity.js +2 -1
- package/dist/clients/review-graph/import-resolvers.js +21 -10
- package/dist/clients/review-graph/persist-worker.js +10 -0
- package/dist/clients/review-graph/query.js +5 -0
- package/dist/clients/review-graph/shared-extraction-ir.js +90 -0
- package/dist/clients/review-graph/symbol-id.js +46 -0
- package/dist/clients/review-graph/tsconfig-paths.js +57 -6
- package/dist/clients/review-graph/workspace-modules.js +51 -3
- package/dist/clients/review-graph-logger.js +53 -0
- package/dist/clients/ruff-client.js +27 -44
- package/dist/clients/runtime-agent-end.js +111 -75
- package/dist/clients/runtime-context.js +36 -12
- package/dist/clients/runtime-coordinator.js +76 -8
- package/dist/clients/runtime-session.js +799 -137
- package/dist/clients/runtime-tool-call.js +117 -62
- package/dist/clients/runtime-tool-result.js +218 -23
- package/dist/clients/runtime-turn.js +284 -40
- package/dist/clients/rust-client.js +2 -1
- package/dist/clients/safe-spawn.js +873 -71
- package/dist/clients/security-scan-client.js +2 -1
- package/dist/clients/session-start-observability.js +15 -0
- package/dist/clients/session-state-store.js +5 -3
- package/dist/clients/sessionstart-logger.js +18 -0
- package/dist/clients/sg-runner.js +284 -159
- package/dist/clients/slow-fs.js +2 -1
- package/dist/clients/smells-rollup.js +224 -0
- package/dist/clients/source-filter.js +231 -43
- package/dist/clients/source-walker.js +66 -10
- package/dist/clients/startup-scan.js +15 -16
- package/dist/clients/startup-timing.js +9 -0
- package/dist/clients/test-runner-client.js +38 -8
- package/dist/clients/todo-scanner.js +30 -3
- package/dist/clients/tool-event.js +35 -0
- package/dist/clients/tool-policy.js +388 -39
- package/dist/clients/tool-render.js +155 -0
- package/dist/clients/tree-sitter-cache.js +153 -140
- package/dist/clients/tree-sitter-client.js +1722 -80
- package/dist/clients/tree-sitter-logger.js +64 -1
- package/dist/clients/tree-sitter-query-loader.js +117 -12
- package/dist/clients/tree-sitter-shared.js +48 -19
- package/dist/clients/tree-sitter-symbol-extractor.js +115 -11
- package/dist/clients/user-notify.js +51 -0
- package/dist/clients/vanished-instance-marker.js +57 -0
- package/dist/clients/warm-attach.js +33 -13
- package/dist/clients/widget-state.js +342 -49
- package/dist/clients/word-index-logger.js +44 -0
- package/dist/clients/word-index.js +612 -68
- package/dist/clients/workspace-topology.js +100 -7
- package/dist/index.js +65923 -47161
- package/dist/mcp/analyze-cli.js +185 -29
- package/dist/mcp/cli.js +110 -0
- package/dist/mcp/server.js +272 -50
- package/dist/tools/ast-grep-search.js +93 -27
- package/dist/tools/lens-diagnostics.js +247 -41
- package/dist/tools/lsp-diagnostics.js +153 -40
- package/dist/tools/lsp-navigation.js +51 -31
- package/dist/tools/module-report.js +9 -0
- package/dist/tools/symbol-search.js +21 -2
- package/docs/agent-guide.md +247 -0
- package/docs/agent-tools.md +21 -10
- package/docs/analysisall.md +192 -0
- package/docs/api-ports-inventory.md +165 -0
- package/docs/ast-grep_rules_catalog.md +5 -2
- package/docs/astplayground.md +3 -4
- package/docs/audit1.md +5 -5
- package/docs/durable-store-audit-1202.md +32 -0
- package/docs/environment-variables.md +197 -11
- package/docs/fable.md +27 -0
- package/docs/features.md +35 -5
- package/docs/globalconfig.md +101 -5
- package/docs/language-coverage.md +6 -5
- package/docs/lsp-capability-matrix.md +2 -2
- package/docs/mcp.md +54 -20
- package/docs/servercapabilities.md +7 -4
- package/docs/settings.md +192 -0
- package/docs/tools.md +18 -1
- package/docs/tree-sitter_rules_catalog.md +11 -31
- package/docs/usage.md +31 -0
- package/package.json +139 -138
- package/rules/ast-grep-rules/rule-tests/hardcoded-url-js-test.yml +1 -0
- package/rules/ast-grep-rules/rule-tests/hardcoded-url-test.yml +2 -0
- package/rules/ast-grep-rules/rule-tests/no-bare-except-test.yml +49 -0
- package/rules/ast-grep-rules/rule-tests/no-bare-host-path-in-win32-branch-test.yml +87 -0
- package/rules/ast-grep-rules/rule-tests/no-case-declarations-js-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-case-declarations-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-javascript-url-js-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-javascript-url-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-nested-links-test.yml +11 -1
- package/rules/ast-grep-rules/rule-tests/no-raw-json-store-write-test.yml +17 -0
- package/rules/ast-grep-rules/rule-tests/no-win32-isabsolute-for-qualification-test.yml +16 -0
- package/rules/ast-grep-rules/rule-tests/strict-equality-js-test.yml +3 -0
- package/rules/ast-grep-rules/rule-tests/strict-equality-test.yml +3 -0
- package/rules/ast-grep-rules/rule-tests/strict-inequality-js-test.yml +3 -0
- package/rules/ast-grep-rules/rule-tests/strict-inequality-test.yml +4 -0
- package/rules/ast-grep-rules/rules/hardcoded-url-js.yml +22 -4
- package/rules/ast-grep-rules/rules/hardcoded-url.yml +22 -4
- package/rules/ast-grep-rules/rules/no-bare-except.yml +3 -15
- package/rules/ast-grep-rules/rules/no-bare-host-path-in-win32-branch.yml +25 -0
- package/rules/ast-grep-rules/rules/no-case-declarations-js.yml +4 -3
- package/rules/ast-grep-rules/rules/no-case-declarations.yml +4 -3
- package/rules/ast-grep-rules/rules/no-console-except-error-js.yml +10 -0
- package/rules/ast-grep-rules/rules/no-console-except-error.yml +10 -0
- package/rules/ast-grep-rules/rules/no-javascript-url-js.yml +42 -6
- package/rules/ast-grep-rules/rules/no-javascript-url.yml +42 -6
- package/rules/ast-grep-rules/rules/no-nested-links.yml +7 -0
- package/rules/ast-grep-rules/rules/no-raw-json-store-write.yml +30 -0
- package/rules/ast-grep-rules/rules/no-win32-isabsolute-for-qualification.yml +23 -0
- package/rules/ast-grep-rules/rules/strict-equality-js.yml +14 -1
- package/rules/ast-grep-rules/rules/strict-equality.yml +14 -1
- package/rules/ast-grep-rules/rules/strict-inequality-js.yml +14 -1
- package/rules/ast-grep-rules/rules/strict-inequality.yml +14 -1
- package/rules/tree-sitter-queries/cpp/no-memset-sensitive-data.yml +9 -3
- package/rules/tree-sitter-queries/cpp/no-scoped-lock-without-args.yml +6 -6
- package/rules/tree-sitter-queries/css/calc-spacing.yml +8 -6
- package/rules/tree-sitter-queries/go/go-mutex-copy.yml +21 -18
- package/rules/tree-sitter-queries/go/go-shared-map-write-goroutine.yml +3 -3
- package/rules/tree-sitter-queries/java/infinite-loop-java.yml +3 -3
- package/rules/tree-sitter-queries/java/junit-call-super.yml +6 -4
- package/rules/tree-sitter-queries/java/no-double-checked-locking.yml +10 -8
- package/rules/tree-sitter-queries/java/no-field-shadowing.yml +1 -1
- package/rules/tree-sitter-queries/java/prepared-statement-valid-indices.yml +2 -3
- package/rules/tree-sitter-queries/java/resources-closed.yml +2 -2
- package/rules/tree-sitter-queries/java/springboot-default-package.yml +6 -3
- package/rules/tree-sitter-queries/java/switch-fall-through.yml +6 -4
- package/rules/tree-sitter-queries/java/switch-non-case-labels.yml +4 -3
- package/rules/tree-sitter-queries/java/tests-include-assertions.yml +6 -5
- package/rules/tree-sitter-queries/javascript/switch-case-termination-js.yml +5 -8
- package/rules/tree-sitter-queries/javascript/switch-non-case-labels.yml +3 -2
- package/rules/tree-sitter-queries/kotlin/prepared-statement-indices.yml +9 -5
- package/rules/tree-sitter-queries/php/this-in-static-context.yml +5 -5
- package/rules/tree-sitter-queries/python/exit-signature-check.yml +2 -9
- package/rules/tree-sitter-queries/python/in-operator-unsupported.yml +3 -4
- package/rules/tree-sitter-queries/python/no-super-torchscript.yml +4 -8
- package/rules/tree-sitter-queries/python/notimplemented-boolean-context.yml +1 -5
- package/rules/tree-sitter-queries/python/python-empty-except.yml +1 -1
- package/rules/tree-sitter-queries/python/return-in-init.yml +0 -2
- package/rules/tree-sitter-queries/python/yield-return-outside-function.yml +0 -3
- package/rules/tree-sitter-queries/ruby/ruby-command-injection.yml +1 -12
- package/rules/tree-sitter-queries/ruby/ruby-eval.yml +1 -1
- package/rules/tree-sitter-queries/ruby/ruby-insecure-deserialization.yml +4 -4
- package/rules/tree-sitter-queries/ruby/ruby-insecure-random.yml +4 -11
- package/rules/tree-sitter-queries/ruby/ruby-open-struct.yml +1 -1
- package/rules/tree-sitter-queries/ruby/ruby-string-eval.yml +2 -3
- package/rules/tree-sitter-queries/ruby/ruby-weak-hash.yml +4 -4
- package/rules/tree-sitter-queries/rust/rust-lock-held-across-await.yml +4 -3
- package/rules/tree-sitter-queries/tsx/no-nested-links.yml +4 -6
- package/rules/tree-sitter-queries/typescript/console-statement.yml +11 -0
- package/rules/tree-sitter-queries/typescript/duplicate-function-arg.yml +4 -9
- package/rules/tree-sitter-queries/typescript/empty-switch-case.yml +13 -9
- package/rules/tree-sitter-queries/typescript/infinite-loop.yml +2 -2
- package/rules/tree-sitter-queries/typescript/mixed-async-styles.yml +10 -1
- package/rules/tree-sitter-queries/typescript/switch-case-termination.yml +5 -8
- package/rules/tree-sitter-queries/typescript/ts-insecure-random.yml +7 -10
- package/rules/tree-sitter-queries/typescript/unsafe-regex.yml +4 -2
- package/rules/typos/_typos.toml +17 -0
- package/scripts/analyze-pi-lens-logs.mjs +55 -2
- package/skills/pi-lens-write-tree-sitter-rule/SKILL.md +5 -0
- package/dist/clients/ast-grep-parser.js +0 -86
- package/dist/clients/config-enabled-shape.js +0 -39
- package/dist/clients/lsp/interactive-install.js +0 -367
- package/dist/clients/lsp/lsp-index.js +0 -10
- package/dist/clients/lsp/server-strategies.js +0 -5
- package/dist/clients/project-metadata.js +0 -690
- package/dist/clients/source-groups.js +0 -96
- package/dist/clients/types.js +0 -11
- package/docs/env_variables.md +0 -10
- package/rules/tree-sitter-queries/abap-disabled/delete-where.yml +0 -46
- package/rules/tree-sitter-queries/cpp/no-confused-move-forward.yml +0 -59
- package/rules/tree-sitter-queries/cpp/noexcept-functions.yml +0 -58
- package/rules/tree-sitter-queries/java/mockito-initialized.yml +0 -66
- package/rules/tree-sitter-queries/java/no-wait-notify-on-thread.yml +0 -58
- package/rules/tree-sitter-queries/java/short-circuit-logic.yml +0 -57
- package/rules/tree-sitter-queries/java/spring-session-attributes-setcomplete.yml +0 -75
- package/rules/tree-sitter-queries/plsql-disabled/delete-update-where.yml +0 -56
- package/rules/tree-sitter-queries/plsql-disabled/end-loop-semicolon.yml +0 -51
- package/rules/tree-sitter-queries/plsql-disabled/fetch-bulk-collect-limit.yml +0 -47
- package/rules/tree-sitter-queries/plsql-disabled/forallsave-exceptions.yml +0 -51
- package/rules/tree-sitter-queries/plsql-disabled/nchar-nvarchar2-bytes.yml +0 -54
- package/rules/tree-sitter-queries/plsql-disabled/not-null-initialization.yml +0 -59
- package/rules/tree-sitter-queries/plsql-disabled/raise-application-error-codes.yml +0 -50
- package/rules/tree-sitter-queries/typescript-disabled/ts-path-traversal.yml +0 -71
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { logExtension } from "./extension-log.js";
|
|
2
|
+
import { notifyUserDegradation } from "./user-notify.js";
|
|
1
3
|
import * as fs from "node:fs";
|
|
2
4
|
import * as os from "node:os";
|
|
3
5
|
import * as path from "node:path";
|
|
4
|
-
import {
|
|
6
|
+
import { assignFlagConfigSection, flagConfigSectionKeys, flagValueFromConfig, getLensFlagSpec, GLOBAL_NON_FLAG_CONFIG_SECTIONS, LENS_FLAGS, readFlagConfigValue, } from "./lens-flag-registry.js";
|
|
5
7
|
import { findNestedProjectMutationValue, } from "./project-lens-config.js";
|
|
6
8
|
export function getPiLensGlobalConfigPath(homeDir = os.homedir()) {
|
|
7
9
|
const override = process.env.PI_LENS_CONFIG_PATH;
|
|
@@ -20,12 +22,26 @@ function warnInvalidGlobalConfigOnce(configPath, reason) {
|
|
|
20
22
|
if (warnedInvalidGlobalConfigs.has(key))
|
|
21
23
|
return;
|
|
22
24
|
warnedInvalidGlobalConfigs.add(key);
|
|
23
|
-
|
|
25
|
+
const message = `ignoring invalid global config ${configPath}: ${reason}`;
|
|
26
|
+
logExtension({
|
|
27
|
+
subsystem: "lens-config",
|
|
28
|
+
level: "warn",
|
|
29
|
+
message,
|
|
30
|
+
metadata: { configPath, reason },
|
|
31
|
+
});
|
|
32
|
+
// HUMAN-audience too: a config the user wrote is being ignored. Routed
|
|
33
|
+
// through the host's own render path (#1333), never a raw write.
|
|
34
|
+
notifyUserDegradation(`pi-lens: ${message}`);
|
|
24
35
|
}
|
|
25
36
|
/** For tests that need to force the warn-once cache to reset between cases. */
|
|
26
37
|
export function resetGlobalConfigWarnCache() {
|
|
27
38
|
warnedInvalidGlobalConfigs.clear();
|
|
28
39
|
}
|
|
40
|
+
function asConfigObject(value) {
|
|
41
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
42
|
+
? value
|
|
43
|
+
: undefined;
|
|
44
|
+
}
|
|
29
45
|
export function loadPiLensGlobalConfig(configPath = getPiLensGlobalConfigPath()) {
|
|
30
46
|
try {
|
|
31
47
|
const parsed = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
@@ -33,94 +49,94 @@ export function loadPiLensGlobalConfig(configPath = getPiLensGlobalConfigPath())
|
|
|
33
49
|
return undefined;
|
|
34
50
|
const raw = parsed;
|
|
35
51
|
const warnInvalid = (reason) => warnInvalidGlobalConfigOnce(configPath, reason);
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
? widgetRaw
|
|
43
|
-
: undefined;
|
|
44
|
-
const format = parseEnabledShape(raw.format, "format", warnInvalid);
|
|
45
|
-
const autofix = parseEnabledShape(raw.autofix, "autofix", warnInvalid);
|
|
46
|
-
const formatModeRaw = raw.format;
|
|
47
|
-
const formatModeSource = formatModeRaw && typeof formatModeRaw === "object"
|
|
48
|
-
? formatModeRaw
|
|
49
|
-
: undefined;
|
|
50
|
-
const actionableWarningsRaw = raw.actionableWarnings;
|
|
51
|
-
const actionableWarnings = actionableWarningsRaw && typeof actionableWarningsRaw === "object"
|
|
52
|
-
? actionableWarningsRaw
|
|
53
|
-
: undefined;
|
|
54
|
-
const actionableWarningsAutoFix = parseEnabledShape(actionableWarnings?.autoFix, "actionableWarnings.autoFix", warnInvalid);
|
|
55
|
-
const contextInjectionRaw = raw.contextInjection;
|
|
56
|
-
const contextInjection = contextInjectionRaw && typeof contextInjectionRaw === "object"
|
|
57
|
-
? contextInjectionRaw
|
|
58
|
-
: undefined;
|
|
59
|
-
const turnSummaryRaw = raw.turnSummary;
|
|
60
|
-
const turnSummary = turnSummaryRaw && typeof turnSummaryRaw === "object"
|
|
61
|
-
? turnSummaryRaw
|
|
62
|
-
: undefined;
|
|
63
|
-
const formatMode = formatModeSource?.mode === "immediate" ||
|
|
64
|
-
formatModeSource?.mode === "deferred"
|
|
65
|
-
? formatModeSource.mode
|
|
66
|
-
: undefined;
|
|
52
|
+
const config = {};
|
|
53
|
+
for (const spec of LENS_FLAGS) {
|
|
54
|
+
if (spec.readGlobal)
|
|
55
|
+
continue;
|
|
56
|
+
assignFlagConfigSection(raw, config, spec.configKey, warnInvalid);
|
|
57
|
+
}
|
|
67
58
|
const ignore = Array.isArray(raw.ignore)
|
|
68
59
|
? raw.ignore.filter((p) => typeof p === "string")
|
|
69
60
|
: undefined;
|
|
70
|
-
|
|
71
|
-
ignore
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
if (ignore && ignore.length > 0)
|
|
62
|
+
config.ignore = ignore;
|
|
63
|
+
const dispatch = asConfigObject(raw.dispatch);
|
|
64
|
+
if (dispatch) {
|
|
65
|
+
const floor = dispatch.runnerTimeoutFloorMs;
|
|
66
|
+
if (typeof floor === "number" && Number.isFinite(floor) && floor > 0) {
|
|
67
|
+
config.dispatch = { runnerTimeoutFloorMs: floor };
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// #533: warn only when the key is PRESENT but malformed — an absent
|
|
71
|
+
// key stays silent so a config that never mentions it is not falsely
|
|
72
|
+
// flagged. Same warn-once path as the maxFixes case below.
|
|
73
|
+
if ("runnerTimeoutFloorMs" in dispatch) {
|
|
74
|
+
warnInvalid("dispatch.runnerTimeoutFloorMs must be a positive finite number");
|
|
79
75
|
}
|
|
80
|
-
: undefined
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
: undefined,
|
|
107
|
-
}
|
|
108
|
-
: undefined,
|
|
109
|
-
contextInjection: contextInjection
|
|
110
|
-
? {
|
|
111
|
-
enabled: typeof contextInjection.enabled === "boolean"
|
|
112
|
-
? contextInjection.enabled
|
|
113
|
-
: undefined,
|
|
76
|
+
config.dispatch = { runnerTimeoutFloorMs: undefined };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const autoFix = asConfigObject(asConfigObject(raw.actionableWarnings)?.autoFix);
|
|
80
|
+
if (autoFix && "maxFixes" in autoFix) {
|
|
81
|
+
if (typeof autoFix.maxFixes === "number" &&
|
|
82
|
+
Number.isFinite(autoFix.maxFixes) &&
|
|
83
|
+
autoFix.maxFixes >= 0) {
|
|
84
|
+
config.actionableWarnings ??= {};
|
|
85
|
+
const warnings = config.actionableWarnings;
|
|
86
|
+
warnings.autoFix ??= {};
|
|
87
|
+
warnings.autoFix.maxFixes = Math.floor(autoFix.maxFixes);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
warnInvalid("actionableWarnings.autoFix.maxFixes must be a non-negative finite number");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const widget = asConfigObject(raw.widget);
|
|
94
|
+
if (widget) {
|
|
95
|
+
if (typeof widget.visible === "boolean") {
|
|
96
|
+
config.widget = { visible: widget.visible };
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// #533: present-but-wrong-type warns; absent stays silent.
|
|
100
|
+
if ("visible" in widget) {
|
|
101
|
+
warnInvalid("widget.visible must be a boolean");
|
|
114
102
|
}
|
|
115
|
-
: undefined
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
103
|
+
config.widget = { visible: undefined };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const format = asConfigObject(raw.format);
|
|
107
|
+
if (format) {
|
|
108
|
+
config.format ??= {};
|
|
109
|
+
const formatSection = config.format;
|
|
110
|
+
if (format.mode === "immediate" || format.mode === "deferred") {
|
|
111
|
+
formatSection.mode = format.mode;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// #533: a present-but-invalid mode (e.g. "immedaite") warns and
|
|
115
|
+
// falls back; an absent mode stays silent.
|
|
116
|
+
if ("mode" in format) {
|
|
117
|
+
warnInvalid('format.mode must be "immediate" or "deferred"');
|
|
121
118
|
}
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
formatSection.mode = undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// #533 hygiene: a completely unknown top-level key (e.g. a typo like
|
|
123
|
+
// `lps` for `lsp`) is otherwise dropped silently, so a setting the user
|
|
124
|
+
// thought they made does nothing with no signal. Warn once per key. The
|
|
125
|
+
// recognized set is single-sourced (#883): the flag sections derived
|
|
126
|
+
// from the registry plus the declared non-flag global sections
|
|
127
|
+
// (`GLOBAL_NON_FLAG_CONFIG_SECTIONS`, which co-locates `$schema` and the
|
|
128
|
+
// hand-parsed namespaces beside the registry). Adding a flag needs no
|
|
129
|
+
// edit here; adding a namespace is a one-line edit in that one constant.
|
|
130
|
+
const knownGlobalConfigKeys = new Set([
|
|
131
|
+
...flagConfigSectionKeys(LENS_FLAGS),
|
|
132
|
+
...GLOBAL_NON_FLAG_CONFIG_SECTIONS,
|
|
133
|
+
]);
|
|
134
|
+
for (const key of Object.keys(raw)) {
|
|
135
|
+
if (!knownGlobalConfigKeys.has(key)) {
|
|
136
|
+
warnInvalid(`unknown key "${key}" is not a recognized pi-lens setting (check for a typo); ignored`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return config;
|
|
124
140
|
}
|
|
125
141
|
catch {
|
|
126
142
|
return undefined;
|
|
@@ -132,20 +148,10 @@ export function getGlobalIgnorePatterns(configPath) {
|
|
|
132
148
|
export function getGlobalWidgetDefaultVisible(configPath) {
|
|
133
149
|
return loadPiLensGlobalConfig(configPath)?.widget?.visible !== false;
|
|
134
150
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return loadPiLensGlobalConfig(configPath)?.autofix?.enabled !== false;
|
|
140
|
-
}
|
|
141
|
-
export function getGlobalImmediateFormatDefault(configPath) {
|
|
142
|
-
return loadPiLensGlobalConfig(configPath)?.format?.mode === "immediate";
|
|
143
|
-
}
|
|
144
|
-
export function getGlobalContextInjectionEnabled(configPath) {
|
|
145
|
-
return (loadPiLensGlobalConfig(configPath)?.contextInjection?.enabled !== false);
|
|
146
|
-
}
|
|
147
|
-
export function getGlobalTurnSummaryEnabled(configPath) {
|
|
148
|
-
return loadPiLensGlobalConfig(configPath)?.turnSummary?.enabled === true;
|
|
151
|
+
/** Per-turn quickfix cap; undefined means "use the built-in default of 5". */
|
|
152
|
+
export function getGlobalActionableWarningMaxFixes(configPath) {
|
|
153
|
+
return loadPiLensGlobalConfig(configPath)?.actionableWarnings?.autoFix
|
|
154
|
+
?.maxFixes;
|
|
149
155
|
}
|
|
150
156
|
/**
|
|
151
157
|
* Resolve a flag AND report which config tier decided it — same precedence
|
|
@@ -153,85 +159,53 @@ export function getGlobalTurnSummaryEnabled(configPath) {
|
|
|
153
159
|
* returning the `source` so callers can log e.g.
|
|
154
160
|
* "(--no-autofix, source=project)" instead of a bare boolean (#792).
|
|
155
161
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
162
|
+
* Every tier is driven by `clients/lens-flag-registry.ts` (#166): the spec's
|
|
163
|
+
* `configKey` is read out of each config object rather than matched by a
|
|
164
|
+
* per-flag branch, so a new toggle needs no change here at all.
|
|
165
|
+
*
|
|
166
|
+
* Precedence: env → cli → nested-project → project → global → default.
|
|
167
|
+
* Project tiers apply to `scope: "project"` flags only (maintainer decision —
|
|
168
|
+
* project wins over global, including re-enabling; only an explicit CLI
|
|
169
|
+
* disabling flag outranks project config). A name with no registry entry
|
|
170
|
+
* passes its CLI value straight through, which is how untyped string flags
|
|
171
|
+
* like `--lens-opengrep-config` keep working.
|
|
159
172
|
*/
|
|
160
173
|
export function resolvePiLensFlagWithSource(name, value, config, projectConfig, editedFilePath, projectRoot) {
|
|
174
|
+
const spec = getLensFlagSpec(name);
|
|
175
|
+
if (spec?.env && process.env[spec.env] === "1") {
|
|
176
|
+
return { value: true, source: "env" };
|
|
177
|
+
}
|
|
161
178
|
if (value)
|
|
162
179
|
return { value, source: "cli" };
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (name === "no-autoformat") {
|
|
177
|
-
if (nested)
|
|
178
|
-
return { value: !nested.value, source: nestedSource };
|
|
179
|
-
if (projectConfig?.format?.enabled !== undefined) {
|
|
180
|
-
return { value: !projectConfig.format.enabled, source: "project" };
|
|
181
|
-
}
|
|
182
|
-
if (config?.format?.enabled === false) {
|
|
183
|
-
return { value: true, source: "global" };
|
|
184
|
-
}
|
|
185
|
-
return { value: false, source: "default" };
|
|
186
|
-
}
|
|
187
|
-
if (name === "no-autofix") {
|
|
188
|
-
if (nested)
|
|
189
|
-
return { value: !nested.value, source: nestedSource };
|
|
190
|
-
if (projectConfig?.autofix?.enabled !== undefined) {
|
|
191
|
-
return { value: !projectConfig.autofix.enabled, source: "project" };
|
|
192
|
-
}
|
|
193
|
-
if (config?.autofix?.enabled === false) {
|
|
194
|
-
return { value: true, source: "global" };
|
|
180
|
+
if (!spec)
|
|
181
|
+
return { value, source: "default" };
|
|
182
|
+
if (spec.scope === "project") {
|
|
183
|
+
const nested = editedFilePath && projectRoot
|
|
184
|
+
? findNestedProjectMutationValue(spec, editedFilePath, projectRoot)
|
|
185
|
+
: undefined;
|
|
186
|
+
if (nested) {
|
|
187
|
+
return {
|
|
188
|
+
value: flagValueFromConfig(spec, nested.value),
|
|
189
|
+
source: path.resolve(nested.dir) === path.resolve(projectRoot)
|
|
190
|
+
? "project"
|
|
191
|
+
: `nested-project:${nested.dir}`,
|
|
192
|
+
};
|
|
195
193
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (name === "immediate-format") {
|
|
199
|
-
const immediate = config?.format?.mode === "immediate";
|
|
200
|
-
return { value: immediate, source: immediate ? "global" : "default" };
|
|
201
|
-
}
|
|
202
|
-
if (name === "lens-actionable-warnings") {
|
|
203
|
-
const enabled = config?.actionableWarnings?.enabled === true;
|
|
204
|
-
return { value: enabled, source: enabled ? "global" : "default" };
|
|
205
|
-
}
|
|
206
|
-
if (name === "lens-actionable-warning-actions") {
|
|
207
|
-
const enabled = config?.actionableWarnings?.includeLspCodeActions === true;
|
|
208
|
-
return { value: enabled, source: enabled ? "global" : "default" };
|
|
209
|
-
}
|
|
210
|
-
if (name === "lens-actionable-warning-autofix") {
|
|
211
|
-
if (nested)
|
|
212
|
-
return { value: nested.value, source: nestedSource };
|
|
213
|
-
if (projectConfig?.actionableWarnings?.autoFix?.enabled !== undefined) {
|
|
194
|
+
const projectValue = readFlagConfigValue(projectConfig, spec.configKey);
|
|
195
|
+
if (projectValue !== undefined) {
|
|
214
196
|
return {
|
|
215
|
-
value:
|
|
197
|
+
value: flagValueFromConfig(spec, projectValue),
|
|
216
198
|
source: "project",
|
|
217
199
|
};
|
|
218
200
|
}
|
|
219
|
-
const enabled = config?.actionableWarnings?.autoFix?.enabled === true;
|
|
220
|
-
return { value: enabled, source: enabled ? "global" : "default" };
|
|
221
|
-
}
|
|
222
|
-
if (name === "lens-actionable-warning-all") {
|
|
223
|
-
const all = config?.actionableWarnings?.deltaOnly === false;
|
|
224
|
-
return { value: all, source: all ? "global" : "default" };
|
|
225
|
-
}
|
|
226
|
-
if (name === "no-lens-context") {
|
|
227
|
-
const disabled = config?.contextInjection?.enabled === false;
|
|
228
|
-
return { value: disabled, source: disabled ? "global" : "default" };
|
|
229
201
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
202
|
+
const globalValue = spec.readGlobal
|
|
203
|
+
? spec.readGlobal((config ?? {}))
|
|
204
|
+
: readFlagConfigValue(config, spec.configKey);
|
|
205
|
+
if (globalValue !== undefined) {
|
|
206
|
+
return { value: flagValueFromConfig(spec, globalValue), source: "global" };
|
|
233
207
|
}
|
|
234
|
-
return { value, source: "default" };
|
|
208
|
+
return { value: spec.default, source: "default" };
|
|
235
209
|
}
|
|
236
210
|
export function resolvePiLensFlag(name, value, config, projectConfig, editedFilePath, projectRoot) {
|
|
237
211
|
return resolvePiLensFlagWithSource(name, value, config, projectConfig, editedFilePath, projectRoot).value;
|
|
@@ -13,26 +13,28 @@
|
|
|
13
13
|
* adds thin wrappers over the remaining internal reach-ins (latency, project
|
|
14
14
|
* scan, LSP status, diagnostic stats, LSP config).
|
|
15
15
|
*/
|
|
16
|
+
import * as path from "node:path";
|
|
17
|
+
import { minimatch } from "./deps/minimatch.js";
|
|
16
18
|
import { getDiagnosticTracker } from "./diagnostic-tracker.js";
|
|
17
19
|
import { getLatencyReports, } from "./dispatch/integration.js";
|
|
18
20
|
import { getResourceFootprint as getResourceFootprintSnapshot, } from "./instance-registry.js";
|
|
19
21
|
import { initLSPConfig } from "./lsp/config.js";
|
|
20
22
|
import { getLSPService } from "./lsp/index.js";
|
|
21
|
-
import {
|
|
22
|
-
import { scanProjectDiagnostics } from "./project-diagnostics/scanner.js";
|
|
23
|
-
import * as path from "node:path";
|
|
24
|
-
import { minimatch } from "./deps/minimatch.js";
|
|
23
|
+
import { acquireWarmWordIndex } from "./mcp/analyze.js";
|
|
25
24
|
import { normalizeMapKey } from "./path-utils.js";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
25
|
+
import { scanProjectDiagnostics } from "./project-diagnostics/scanner.js";
|
|
26
|
+
import { loadProjectSnapshotWithoutWordIndex } from "./project-snapshot.js";
|
|
27
|
+
import { getTreeSitterRuntimeStatus, } from "./tree-sitter-shared.js";
|
|
28
|
+
import { centralityFromReverseDeps, getWordIndexBuildStatus, searchWordIndex, triggerBackgroundWordIndexBuild, } from "./word-index.js";
|
|
28
29
|
// --- Facades (re-exported so adapters import only this module) ---------------
|
|
29
30
|
export { analyzeFile, } from "./mcp/analyze.js";
|
|
30
31
|
export { createMcpHost } from "./mcp/host-shim.js";
|
|
31
|
-
export { ipcPathForCwd, requestWarmAnalyze, } from "./mcp/ipc.js";
|
|
32
|
-
export { analyzeFileFresh, resolveRebuildScript, runRebuild, summarizeScan, } from "./mcp/review.js";
|
|
33
|
-
export { runSessionStart, runTurnEnd, } from "./mcp/session.js";
|
|
32
|
+
export { createWarmIpcLineReader, createWarmIpcRequestQueue, ipcPathForCwd, readTurnEndStatus, requestWarmAnalyze, WARM_TURN_END_SCHEMA_VERSION, } from "./mcp/ipc.js";
|
|
33
|
+
export { analyzeFileFresh, canRebuildPiLens, REBUILD_UNAVAILABLE_MESSAGE, resolveRebuildScript, runRebuild, summarizeScan, } from "./mcp/review.js";
|
|
34
|
+
export { acknowledgeTurnEnd, runSessionStart, runTurnEnd, runTurnEndForIpc, } from "./mcp/session.js";
|
|
34
35
|
export { moduleReport, readEnclosing, readSymbol, renderCompactModuleReport, } from "./module-report.js";
|
|
35
36
|
export { projectReport, renderCompactProjectReport, } from "./project-report.js";
|
|
37
|
+
export { createDefaultHostPorts, } from "./host-ports.js";
|
|
36
38
|
// --- Query wrappers (own the remaining internal reach-ins) -------------------
|
|
37
39
|
/** Recent dispatch latency reports (latency.log schema), newest first. */
|
|
38
40
|
export function recentLatency(limit = 5, fileFilter) {
|
|
@@ -43,9 +45,21 @@ export function recentLatency(limit = 5, fileFilter) {
|
|
|
43
45
|
}
|
|
44
46
|
return reports.slice(-limit).reverse();
|
|
45
47
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Cheap project-wide scan (tree-sitter + fact rules).
|
|
50
|
+
*
|
|
51
|
+
* `includeGenerated` (#1107 phase 2 review): scan WITHOUT the generated/
|
|
52
|
+
* artifact NAME-heuristic filter — the actionable opt-out
|
|
53
|
+
* `generatedSkipNotice` below points a user at. Default `false` (existing
|
|
54
|
+
* filtering behavior unchanged).
|
|
55
|
+
*/
|
|
56
|
+
export function projectScan(cwd, maxFiles, includeGenerated) {
|
|
57
|
+
return scanProjectDiagnostics({
|
|
58
|
+
cwd,
|
|
59
|
+
tier: "cheap",
|
|
60
|
+
maxFiles,
|
|
61
|
+
includeGenerated,
|
|
62
|
+
});
|
|
49
63
|
}
|
|
50
64
|
/**
|
|
51
65
|
* #784: `scanTruncated` (#760) reaches this seam intact but, until now, no
|
|
@@ -57,13 +71,78 @@ export function projectScan(cwd, maxFiles) {
|
|
|
57
71
|
export function scanTruncationNotice(snapshot) {
|
|
58
72
|
if (!snapshot.scanTruncated)
|
|
59
73
|
return undefined;
|
|
74
|
+
if (snapshot.treeSitterStatus === "wasm_aborted_restart_required") {
|
|
75
|
+
return (`⚠ Scan stopped after ${snapshot.filesScanned} complete file(s): the ` +
|
|
76
|
+
"tree-sitter WASM runtime aborted. Results are partial and were not cached; " +
|
|
77
|
+
"restart the pi-lens extension/MCP server to restore structural analysis.");
|
|
78
|
+
}
|
|
60
79
|
return (`⚠ Scan truncated at ${snapshot.filesScanned} file(s) — results are partial; ` +
|
|
61
80
|
"raise maxProjectFiles in .pi-lens.json to scan fully.");
|
|
62
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* #1107 phase 2: `generatedNameOnlySkips`/`generatedDirSkips` reach this seam
|
|
84
|
+
* via `ProjectDiagnosticsSnapshot` but need explicit rendering, same pattern
|
|
85
|
+
* as `scanTruncationNotice` above — otherwise a user has no way to learn the
|
|
86
|
+
* generated-name heuristic silently excluded files/directories short of
|
|
87
|
+
* reading `latency.log`'s `source_walk_skip_summary` line directly.
|
|
88
|
+
*
|
|
89
|
+
* #1107 phase 2 review round 2 (P1, empirically proven): this deliberately
|
|
90
|
+
* keys off `generatedNameOnlySkips`, NOT the raw `generatedFileSkips` total.
|
|
91
|
+
* `generatedFileSkips` counts every file the generated/artifact heuristic
|
|
92
|
+
* skipped, including STRONG evidence (lockfiles, declaration files, minified/
|
|
93
|
+
* bundle/chunk output — expected on nearly every real repo) and
|
|
94
|
+
* content-CONFIRMED WEAK matches (the escape hatch checked and a genuine
|
|
95
|
+
* generated-code header was present). Keying the notice off that total meant
|
|
96
|
+
* a repo with nothing more unusual than a `package-lock.json` and an ambient
|
|
97
|
+
* `.d.ts` showed "2 file(s) excluded" on literally every scan forever — the
|
|
98
|
+
* signal drowned itself on day one. `generatedNameOnlySkips` is the narrower,
|
|
99
|
+
* genuinely at-risk residual: a WEAK name match trusted with NO corroborating
|
|
100
|
+
* evidence check at all (only reachable when a caller opts out of the header
|
|
101
|
+
* probe — source-filter.ts's default project-walk path always enables it).
|
|
102
|
+
* Post-escape-hatch, this should be rare-to-zero on the default path, which
|
|
103
|
+
* is exactly what makes the notice meaningful again when it DOES fire.
|
|
104
|
+
* `generatedDirSkips` stays in the trigger condition unchanged: directory-
|
|
105
|
+
* level pruning has no escape hatch at all (the walk never enumerates a
|
|
106
|
+
* pruned directory's contents to check them), so it is always a genuine
|
|
107
|
+
* "real files may be hiding in here, unverified" signal, not a
|
|
108
|
+
* false-positive-prone one — see `generatedDirSkips`'s doc on
|
|
109
|
+
* `SourceCollectionResult`.
|
|
110
|
+
*
|
|
111
|
+
* Returns `undefined` when neither counter is set (nothing to append).
|
|
112
|
+
*/
|
|
113
|
+
export function generatedSkipNotice(snapshot) {
|
|
114
|
+
const files = snapshot.generatedNameOnlySkips ?? 0;
|
|
115
|
+
const dirs = snapshot.generatedDirSkips ?? 0;
|
|
116
|
+
if (files === 0 && dirs === 0)
|
|
117
|
+
return undefined;
|
|
118
|
+
const parts = [];
|
|
119
|
+
if (files > 0)
|
|
120
|
+
parts.push(`${files} file(s)`);
|
|
121
|
+
if (dirs > 0)
|
|
122
|
+
parts.push(`${dirs} director${dirs === 1 ? "y" : "ies"}`);
|
|
123
|
+
return (`ℹ ${parts.join(" and ")} excluded by generated-name heuristics with no ` +
|
|
124
|
+
"confirming evidence — a real hand-written file/directory whose name " +
|
|
125
|
+
"looks generated (e.g. `gen.ts`, `generated/`) can be excluded too; " +
|
|
126
|
+
"pass includeGenerated: true to pilens_project_scan / lens_diagnostics " +
|
|
127
|
+
"to scan without this filter if you suspect a false skip.");
|
|
128
|
+
}
|
|
129
|
+
/** Process-wide tree-sitter health for host status surfaces. */
|
|
130
|
+
export function treeSitterRuntimeStatus() {
|
|
131
|
+
return getTreeSitterRuntimeStatus();
|
|
132
|
+
}
|
|
63
133
|
/** Alive LSP client count + per-server status. */
|
|
64
134
|
export function lspStatus() {
|
|
65
135
|
const lsp = getLSPService();
|
|
66
|
-
return {
|
|
136
|
+
return {
|
|
137
|
+
aliveClients: lsp.getAliveClientCount(),
|
|
138
|
+
servers: lsp.getStatus(),
|
|
139
|
+
brokenServers: lsp.getBrokenStatus(),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function renderLspBrokenStatusLines(brokenServers) {
|
|
143
|
+
return brokenServers.map((server) => server.permanentlyBroken
|
|
144
|
+
? ` ✗ ${server.serverId} — disabled after ${server.failures} failures (${server.root})`
|
|
145
|
+
: ` ✗ ${server.serverId} — cooling down after ${server.failures} failure(s) until ${new Date(server.cooldownUntil).toISOString()} (${server.root})`);
|
|
67
146
|
}
|
|
68
147
|
/** Session diagnostic counters (shown / auto-fixed / unresolved …). */
|
|
69
148
|
export function diagnosticStats() {
|
|
@@ -194,7 +273,7 @@ function toSymbolSearchHit(result) {
|
|
|
194
273
|
* cwd, never blocking this call) so a retry shortly after succeeds (#348
|
|
195
274
|
* decision 3).
|
|
196
275
|
*
|
|
197
|
-
* #536 rider: prefers the warm in-memory index (`
|
|
276
|
+
* #536 rider: prefers the warm in-memory index (`acquireWarmWordIndex`,
|
|
198
277
|
* clients/mcp/analyze.ts) over a fresh disk read when one exists for this
|
|
199
278
|
* cwd — a warm `pilens_analyze` call updates that live copy synchronously but
|
|
200
279
|
* persists it to disk on a debounce (default 1500ms), so without this a query
|
|
@@ -220,22 +299,45 @@ function toSymbolSearchHit(result) {
|
|
|
220
299
|
* nothing on this hot path.
|
|
221
300
|
*/
|
|
222
301
|
export async function symbolSearch(query, cwd, limit = 20, options = {}) {
|
|
223
|
-
const
|
|
224
|
-
const
|
|
302
|
+
const warmLease = acquireWarmWordIndex(cwd);
|
|
303
|
+
const snapshot = loadProjectSnapshotWithoutWordIndex(cwd);
|
|
304
|
+
const index = warmLease.index;
|
|
225
305
|
if (!index) {
|
|
226
|
-
|
|
306
|
+
warmLease.release();
|
|
307
|
+
const priorStatus = getWordIndexBuildStatus(cwd);
|
|
308
|
+
const status = priorStatus?.state === "refused"
|
|
309
|
+
? priorStatus
|
|
310
|
+
: triggerBackgroundWordIndexBuild(cwd);
|
|
311
|
+
const unavailableReason = priorStatus?.state === "failed"
|
|
312
|
+
? "last-build-failed"
|
|
313
|
+
: status.state === "refused"
|
|
314
|
+
? "refused"
|
|
315
|
+
: "building";
|
|
316
|
+
const hint = unavailableReason === "refused"
|
|
317
|
+
? `Word index build was refused for safety: ${status.state === "refused" ? status.reason : "unsafe workspace root"}. Run symbol_search from inside a project directory.`
|
|
318
|
+
: unavailableReason === "last-build-failed"
|
|
319
|
+
? `The last word index build failed: ${priorStatus?.state === "failed" ? priorStatus.reason : "unknown error"}. A retry is now running in the background.`
|
|
320
|
+
: "Word index is building in the background for this workspace — retry this query shortly.";
|
|
227
321
|
return {
|
|
228
322
|
available: false,
|
|
229
323
|
query,
|
|
230
324
|
results: [],
|
|
231
|
-
|
|
325
|
+
unavailableReason,
|
|
326
|
+
hint,
|
|
232
327
|
};
|
|
233
328
|
}
|
|
234
329
|
// Boost well-connected files using the snapshot's reverse-dependency
|
|
235
330
|
// (importedBy) counts; snapshot keys are normalized, index keys are raw.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
331
|
+
let centrality;
|
|
332
|
+
let results;
|
|
333
|
+
try {
|
|
334
|
+
centrality = centralityFromReverseDeps(index, snapshot?.reverseDeps, (file) => normalizeMapKey(path.resolve(file)));
|
|
335
|
+
const fileFilter = buildSymbolSearchFileFilter(cwd, options);
|
|
336
|
+
results = searchWordIndex(index, query, { limit, centrality, fileFilter });
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
warmLease.release();
|
|
340
|
+
}
|
|
239
341
|
const hits = results.map(toSymbolSearchHit);
|
|
240
342
|
const { getCachedReviewGraph } = await import("./review-graph/builder.js");
|
|
241
343
|
const graph = getCachedReviewGraph(cwd);
|
|
@@ -245,6 +347,7 @@ export async function symbolSearch(query, cwd, limit = 20, options = {}) {
|
|
|
245
347
|
available: true,
|
|
246
348
|
query,
|
|
247
349
|
results: hits,
|
|
350
|
+
coverage: { files: index.docCount, truncated: index.truncated === true },
|
|
248
351
|
snapshotGeneratedAt: snapshot?.generatedAt,
|
|
249
352
|
};
|
|
250
353
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logExtension } from "./extension-log.js";
|
|
1
2
|
export const LENS_EVENT_VERSION = 1;
|
|
2
3
|
export const LENS_EVENT_NAMES = {
|
|
3
4
|
analysisComplete: "pi-lens/analysis-complete",
|
|
@@ -5,8 +6,15 @@ export const LENS_EVENT_NAMES = {
|
|
|
5
6
|
turnFindings: "pi-lens/turn-findings",
|
|
6
7
|
};
|
|
7
8
|
let lensEventBus;
|
|
9
|
+
let lensEventBusGetter;
|
|
8
10
|
export function initLensEvents(pi) {
|
|
9
11
|
lensEventBus = pi.events;
|
|
12
|
+
lensEventBusGetter = undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Keep deferred deliveries on the live extension activation. */
|
|
15
|
+
export function initLensEventsGetter(getter) {
|
|
16
|
+
lensEventBusGetter = getter;
|
|
17
|
+
lensEventBus = undefined;
|
|
10
18
|
}
|
|
11
19
|
function truncateText(value, maxChars) {
|
|
12
20
|
if (value === undefined)
|
|
@@ -26,13 +34,28 @@ function normalizeDiagnostic(diagnostic) {
|
|
|
26
34
|
function normalizeDiagnostics(diagnostics) {
|
|
27
35
|
return diagnostics.map(normalizeDiagnostic);
|
|
28
36
|
}
|
|
37
|
+
// Dropped-emit observability (#1128 review): drops are legitimate (no bus
|
|
38
|
+
// during startup/replacement windows) but must not be invisible. One line per
|
|
39
|
+
// process — enough to notice a permanently-missing bus without spamming.
|
|
40
|
+
let _droppedEmitLogged = false;
|
|
29
41
|
function emitLensEvent(eventName, payload) {
|
|
30
|
-
const emit = lensEventBus?.emit;
|
|
31
|
-
if (!emit)
|
|
32
|
-
return;
|
|
33
42
|
setImmediate(() => {
|
|
34
43
|
try {
|
|
35
|
-
|
|
44
|
+
const bus = lensEventBusGetter?.() ?? lensEventBus;
|
|
45
|
+
const emit = bus?.emit;
|
|
46
|
+
if (!emit) {
|
|
47
|
+
if (!_droppedEmitLogged) {
|
|
48
|
+
_droppedEmitLogged = true;
|
|
49
|
+
logExtension({
|
|
50
|
+
subsystem: "lens-events",
|
|
51
|
+
level: "warn",
|
|
52
|
+
message: `lens event dropped (no live bus): ${eventName} — further drops logged once per process`,
|
|
53
|
+
metadata: { eventName },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
emit.call(bus, eventName, payload);
|
|
36
59
|
}
|
|
37
60
|
catch {
|
|
38
61
|
// Inter-extension events are observational. A listener must never break
|