@herbertgao/pi-extensions 2026.9.0 → 2026.9.2
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/node_modules/@czottmann/pi-automode/CHANGELOG.md +13 -1
- package/node_modules/@czottmann/pi-automode/README.md +20 -0
- package/node_modules/@czottmann/pi-automode/docs/GLOSSARY.md +1 -1
- package/node_modules/@czottmann/pi-automode/docs/automode-classifier-flow.md +2 -1
- package/node_modules/@czottmann/pi-automode/docs/defaults.md +3 -2
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +38 -2
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +5 -3
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/extension.ts +11 -3
- package/node_modules/@czottmann/pi-automode/package.json +1 -1
- package/node_modules/@narumitw/pi-btw/README.md +57 -141
- package/node_modules/@narumitw/pi-btw/dist/index.ts +466 -41
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
- package/node_modules/@narumitw/pi-btw/docs/workflows.md +74 -0
- package/node_modules/@narumitw/pi-btw/package.json +2 -1
- package/node_modules/@narumitw/pi-btw/src/btw.ts +15 -1
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +32 -2
- package/node_modules/@narumitw/pi-btw/src/keybindings.ts +330 -0
- package/node_modules/@narumitw/pi-btw/src/menu.ts +136 -19
- package/node_modules/@narumitw/pi-btw/src/settings.ts +32 -0
- package/node_modules/@narumitw/pi-btw/src/side-thread.ts +57 -5
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +52 -30
- package/node_modules/@pi-plugins/fast-mode/README.md +5 -3
- package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +20 -55
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
- package/node_modules/pi-lens/CHANGELOG.md +1072 -0
- package/node_modules/pi-lens/README.md +3 -0
- package/node_modules/pi-lens/config/biome/core.jsonc +11 -2
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +13 -1
- package/node_modules/pi-lens/dist/clients/actionable-warnings-logger.js +2 -9
- package/node_modules/pi-lens/dist/clients/actionable-warnings.js +927 -80
- package/node_modules/pi-lens/dist/clients/advisory-provenance.js +1 -1
- package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +13 -4
- package/node_modules/pi-lens/dist/clients/ast-grep-client.js +123 -3
- package/node_modules/pi-lens/dist/clients/ast-grep-rule-manager.js +60 -5
- package/node_modules/pi-lens/dist/clients/ast-grep-tool-logger.js +2 -9
- package/node_modules/pi-lens/dist/clients/ast-grep-types.js +2 -0
- package/node_modules/pi-lens/dist/clients/bash-file-access.js +133 -3
- package/node_modules/pi-lens/dist/clients/biome-client.js +9 -2
- package/node_modules/pi-lens/dist/clients/blocker-freshness.js +14 -6
- package/node_modules/pi-lens/dist/clients/bootstrap.js +509 -73
- package/node_modules/pi-lens/dist/clients/bounded-cache.js +152 -12
- package/node_modules/pi-lens/dist/clients/bounded-pid-file-lock.js +1 -1
- package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +59 -9
- package/node_modules/pi-lens/dist/clients/bundled-resource-health.js +113 -0
- package/node_modules/pi-lens/dist/clients/bus-events-logger.js +3 -11
- package/node_modules/pi-lens/dist/clients/cache/rule-cache.js +31 -4
- package/node_modules/pi-lens/dist/clients/cache-manager.js +105 -6
- package/node_modules/pi-lens/dist/clients/cache-observability.js +40 -19
- package/node_modules/pi-lens/dist/clients/cargo-manifest.js +422 -0
- package/node_modules/pi-lens/dist/clients/cascade-logger.js +2 -9
- package/node_modules/pi-lens/dist/clients/child-unref.js +1 -19
- package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +13 -3
- package/node_modules/pi-lens/dist/clients/complexity-client.js +16 -5
- package/node_modules/pi-lens/dist/clients/config-core/deny.js +221 -0
- package/node_modules/pi-lens/dist/clients/config-core/index.js +50 -0
- package/node_modules/pi-lens/dist/clients/config-core/merge.js +357 -0
- package/node_modules/pi-lens/dist/clients/config-core/normalize.js +340 -0
- package/node_modules/pi-lens/dist/clients/config-core/process-spec.js +248 -0
- package/node_modules/pi-lens/dist/clients/config-core/provenance.js +164 -0
- package/node_modules/pi-lens/dist/clients/config-core/records.js +218 -0
- package/node_modules/pi-lens/dist/clients/config-core/resolve.js +125 -0
- package/node_modules/pi-lens/dist/clients/config-core/safe-object.js +78 -0
- package/node_modules/pi-lens/dist/clients/config-core/schema.js +165 -0
- package/node_modules/pi-lens/dist/clients/config-diagnostic-codes.js +281 -0
- package/node_modules/pi-lens/dist/clients/config-locations.js +160 -0
- package/node_modules/pi-lens/dist/clients/config-resolve.js +789 -0
- package/node_modules/pi-lens/dist/clients/config-schema.js +234 -0
- package/node_modules/pi-lens/dist/clients/config-warn.js +407 -0
- package/node_modules/pi-lens/dist/clients/dead-code-client.js +19 -14
- package/node_modules/pi-lens/dist/clients/dead-code-logger.js +2 -6
- package/node_modules/pi-lens/dist/clients/deadline-utils.js +178 -0
- package/node_modules/pi-lens/dist/clients/debug-handles.js +2 -2
- package/node_modules/pi-lens/dist/clients/debug-heap.js +3 -3
- package/node_modules/pi-lens/dist/clients/deferred-lsp-work.js +106 -0
- package/node_modules/pi-lens/dist/clients/degradation-ledger.js +113 -7
- package/node_modules/pi-lens/dist/clients/dependency-checker.js +8 -19
- package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +1 -1
- package/node_modules/pi-lens/dist/clients/diagnostic-line-freshness.js +12 -9
- package/node_modules/pi-lens/dist/clients/diagnostic-logger.js +15 -5
- package/node_modules/pi-lens/dist/clients/dispatch/collect-later-tier.js +0 -4
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +162 -44
- package/node_modules/pi-lens/dist/clients/dispatch/fact-store.js +97 -0
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +27 -8
- package/node_modules/pi-lens/dist/clients/dispatch/lazy.js +0 -6
- package/node_modules/pi-lens/dist/clients/dispatch/pending-runner-findings.js +1 -1
- package/node_modules/pi-lens/dist/clients/dispatch/plan.js +0 -3
- package/node_modules/pi-lens/dist/clients/dispatch/rules/high-complexity.js +2 -2
- package/node_modules/pi-lens/dist/clients/dispatch/rules/high-fan-out.js +1 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/actionlint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +383 -27
- package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/cpp-check.js +4 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/credo.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/cue-vet.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/dart-analyze.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/detekt.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/dotnet-build.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/elixir-check.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/eslint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/fact-rules.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/fish-indent.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/gleam-check.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/go-vet.js +1 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/golangci-lint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/hadolint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-lint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-render.js +1 -2
- package/node_modules/pi-lens/dist/clients/dispatch/runners/htmlhint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/javac.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ktlint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/mypy.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/oxlint.js +14 -18
- package/node_modules/pi-lens/dist/clients/dispatch/runners/php-lint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/phpstan.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/prisma-validate.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +6 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/pyright.js +7 -4
- package/node_modules/pi-lens/dist/clients/dispatch/runners/rubocop.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ruff.js +1 -2
- package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +1 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shellcheck.js +1 -2
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/spellcheck.js +4 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/spotbugs.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/sqlfluff.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/stylelint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/swiftlint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/taplo.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/terragrunt.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/tflint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/trivy-config.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/availability-policy.js +3 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +3 -67
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +194 -80
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +84 -15
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils.js +0 -21
- package/node_modules/pi-lens/dist/clients/dispatch/runners/vale.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +2 -20
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yamllint.js +1 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/zig-check.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/utils/format-utils.js +2 -2
- package/node_modules/pi-lens/dist/clients/disposition-logger.js +3 -10
- package/node_modules/pi-lens/dist/clients/effective-config.js +403 -0
- package/node_modules/pi-lens/dist/clients/error-class.js +23 -0
- package/node_modules/pi-lens/dist/clients/event-loop-hold.js +274 -0
- package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +2 -2
- package/node_modules/pi-lens/dist/clients/extension-log.js +2 -2
- package/node_modules/pi-lens/dist/clients/feature-hints.js +2 -1
- package/node_modules/pi-lens/dist/clients/file-kinds.js +1 -38
- package/node_modules/pi-lens/dist/clients/file-time.js +7 -2
- package/node_modules/pi-lens/dist/clients/file-utils.js +117 -10
- package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +50 -13
- package/node_modules/pi-lens/dist/clients/format-service.js +6 -2
- package/node_modules/pi-lens/dist/clients/formatters.js +385 -104
- package/node_modules/pi-lens/dist/clients/freshness-cadence.js +17 -0
- package/node_modules/pi-lens/dist/clients/generated-artifacts.js +116 -22
- package/node_modules/pi-lens/dist/clients/generation-guard.js +4 -9
- package/node_modules/pi-lens/dist/clients/git-guard.js +6 -1
- package/node_modules/pi-lens/dist/clients/go-client.js +39 -0
- package/node_modules/pi-lens/dist/clients/gradle-ktfmt-style.js +252 -0
- package/node_modules/pi-lens/dist/clients/grammar-source.js +3 -3
- package/node_modules/pi-lens/dist/clients/hashline-anchor.js +424 -0
- package/node_modules/pi-lens/dist/clients/hook-budgets.js +76 -0
- package/node_modules/pi-lens/dist/clients/host-edit-normalize.js +5 -2
- package/node_modules/pi-lens/dist/clients/host-ports.js +1 -1
- package/node_modules/pi-lens/dist/clients/installer/index.js +289 -59
- package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh.js +84 -18
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +110 -236
- package/node_modules/pi-lens/dist/clients/instance-registry.js +6 -3
- package/node_modules/pi-lens/dist/clients/language-profile.js +0 -9
- package/node_modules/pi-lens/dist/clients/language-registry.js +599 -0
- package/node_modules/pi-lens/dist/clients/latency-logger.js +165 -9
- package/node_modules/pi-lens/dist/clients/ledger-bounds.js +34 -1
- package/node_modules/pi-lens/dist/clients/lens-config.js +160 -30
- package/node_modules/pi-lens/dist/clients/lens-engine.js +33 -41
- package/node_modules/pi-lens/dist/clients/lens-events.js +1 -1
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +77 -6
- package/node_modules/pi-lens/dist/clients/lens-map.js +1 -1
- package/node_modules/pi-lens/dist/clients/log-cleanup.js +2 -38
- package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +3 -1
- package/node_modules/pi-lens/dist/clients/lsp/client.js +172 -33
- package/node_modules/pi-lens/dist/clients/lsp/config.js +484 -158
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp/document-drift.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp/edits.js +18 -5
- package/node_modules/pi-lens/dist/clients/lsp/index.js +892 -96
- package/node_modules/pi-lens/dist/clients/lsp/inferred-project.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp/language.js +18 -177
- package/node_modules/pi-lens/dist/clients/lsp/launch.js +2 -1
- package/node_modules/pi-lens/dist/clients/lsp/path-utils.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp/pending-aux-coverage.js +5 -18
- package/node_modules/pi-lens/dist/clients/lsp/server.js +284 -147
- package/node_modules/pi-lens/dist/clients/lsp/session-roots.js +116 -23
- package/node_modules/pi-lens/dist/clients/lsp/spawn-history.js +2 -7
- package/node_modules/pi-lens/dist/clients/lsp/sync-kind.js +0 -1
- package/node_modules/pi-lens/dist/clients/lsp/tsserver-sync.js +14 -7
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/classification.js +6 -0
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/strategies.js +2 -1
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp-document-symbols.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp-mutation.js +163 -21
- package/node_modules/pi-lens/dist/clients/map-with-concurrency.js +36 -0
- package/node_modules/pi-lens/dist/clients/mcp/analyze.js +33 -4
- package/node_modules/pi-lens/dist/clients/mcp/session.js +5 -16
- package/node_modules/pi-lens/dist/clients/memory-sampler.js +8 -3
- package/node_modules/pi-lens/dist/clients/metrics-history.js +28 -107
- package/node_modules/pi-lens/dist/clients/middle-man-analysis.js +3 -5
- package/node_modules/pi-lens/dist/clients/module-report.js +21 -46
- package/node_modules/pi-lens/dist/clients/mutating-tool.js +651 -0
- package/node_modules/pi-lens/dist/clients/mutation-attribution.js +368 -0
- package/node_modules/pi-lens/dist/clients/mutation-bridge.js +240 -0
- package/node_modules/pi-lens/dist/clients/ndjson-logger.js +247 -24
- package/node_modules/pi-lens/dist/clients/observed-mutation-sources.js +101 -0
- package/node_modules/pi-lens/dist/clients/observed-mutation.js +1215 -0
- package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +70 -28
- package/node_modules/pi-lens/dist/clients/opengrep-config.js +5 -1
- package/node_modules/pi-lens/dist/clients/package-manager.js +195 -26
- package/node_modules/pi-lens/dist/clients/partial-edit-apply.js +359 -80
- package/node_modules/pi-lens/dist/clients/path-attribution-telemetry.js +23 -7
- package/node_modules/pi-lens/dist/clients/path-keyed-map.js +21 -2
- package/node_modules/pi-lens/dist/clients/path-utils.js +451 -15
- package/node_modules/pi-lens/dist/clients/performance-report.js +2 -2
- package/node_modules/pi-lens/dist/clients/persist-debounce.js +8 -1
- package/node_modules/pi-lens/dist/clients/php-cs-fixer-config.js +114 -0
- package/node_modules/pi-lens/dist/clients/pipeline.js +79 -18
- package/node_modules/pi-lens/dist/clients/probe-home-state.js +228 -0
- package/node_modules/pi-lens/dist/clients/process-bridge.js +66 -0
- package/node_modules/pi-lens/dist/clients/process-snapshot.js +68 -0
- package/node_modules/pi-lens/dist/clients/project-changes.js +1 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/extractors.js +1 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +4 -3
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/jscpd.js +1 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/knip.js +1 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +1 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/opengrep.js +1 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +28 -4
- package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +51 -20
- package/node_modules/pi-lens/dist/clients/project-lens-config.js +438 -122
- package/node_modules/pi-lens/dist/clients/project-scan-policy.js +3 -51
- package/node_modules/pi-lens/dist/clients/project-snapshot.js +52 -24
- package/node_modules/pi-lens/dist/clients/python-environment.js +217 -0
- package/node_modules/pi-lens/dist/clients/python-provenance.js +639 -0
- package/node_modules/pi-lens/dist/clients/quiet-window.js +6 -1
- package/node_modules/pi-lens/dist/clients/read-bridge.js +13 -21
- package/node_modules/pi-lens/dist/clients/read-expansion.js +9 -46
- package/node_modules/pi-lens/dist/clients/read-guard-logger.js +16 -5
- package/node_modules/pi-lens/dist/clients/read-guard-tool-lines.js +364 -212
- package/node_modules/pi-lens/dist/clients/read-guard.js +26 -2
- package/node_modules/pi-lens/dist/clients/recent-touches.js +2 -2
- package/node_modules/pi-lens/dist/clients/resource-sampler.js +195 -96
- package/node_modules/pi-lens/dist/clients/review-graph/builder.js +155 -114
- package/node_modules/pi-lens/dist/clients/review-graph/import-resolvers.js +1 -1
- package/node_modules/pi-lens/dist/clients/review-graph/service.js +55 -3
- package/node_modules/pi-lens/dist/clients/review-graph/shared-extraction-ir.js +7 -15
- package/node_modules/pi-lens/dist/clients/review-graph/workspace-modules.js +10 -74
- package/node_modules/pi-lens/dist/clients/review-graph-logger.js +9 -3
- package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +19 -3
- package/node_modules/pi-lens/dist/clients/runtime-context.js +49 -16
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +25 -6
- package/node_modules/pi-lens/dist/clients/runtime-session.js +184 -32
- package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +179 -36
- package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +797 -243
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +1028 -53
- package/node_modules/pi-lens/dist/clients/rust-client.js +31 -0
- package/node_modules/pi-lens/dist/clients/safe-spawn.js +33 -10
- package/node_modules/pi-lens/dist/clients/sanitize.js +7 -12
- package/node_modules/pi-lens/dist/clients/scan-utils.js +1 -56
- package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +1 -3
- package/node_modules/pi-lens/dist/clients/security-scan-client.js +3 -0
- package/node_modules/pi-lens/dist/clients/session-lifecycle.js +1 -1
- package/node_modules/pi-lens/dist/clients/session-start-observability.js +79 -0
- package/node_modules/pi-lens/dist/clients/session-summary.js +0 -24
- package/node_modules/pi-lens/dist/clients/sessionstart-logger.js +12 -3
- package/node_modules/pi-lens/dist/clients/sgconfig.js +7 -6
- package/node_modules/pi-lens/dist/clients/shared-checkout-guard.js +1 -1
- package/node_modules/pi-lens/dist/clients/skills-resolver.js +105 -0
- package/node_modules/pi-lens/dist/clients/smells-rollup.js +4 -4
- package/node_modules/pi-lens/dist/clients/startup-scan.js +2 -10
- package/node_modules/pi-lens/dist/clients/string-utils.js +13 -0
- package/node_modules/pi-lens/dist/clients/subagent-mode.js +17 -4
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +176 -39
- package/node_modules/pi-lens/dist/clients/test-runner-delivery.js +244 -0
- package/node_modules/pi-lens/dist/clients/tool-definition.js +41 -1
- package/node_modules/pi-lens/dist/clients/tool-policy.js +92 -22
- package/node_modules/pi-lens/dist/clients/tree-sitter-cache.js +40 -40
- package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +87 -100
- package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +2 -2
- package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +81 -1
- package/node_modules/pi-lens/dist/clients/tree-sitter-shared.js +51 -46
- package/node_modules/pi-lens/dist/clients/tree-sitter-symbol-extractor.js +28 -0
- package/node_modules/pi-lens/dist/clients/tui-fit.js +0 -4
- package/node_modules/pi-lens/dist/clients/typos-config.js +5 -0
- package/node_modules/pi-lens/dist/clients/user-notify.js +6 -6
- package/node_modules/pi-lens/dist/clients/widget-state.js +191 -26
- package/node_modules/pi-lens/dist/clients/word-index-logger.js +2 -9
- package/node_modules/pi-lens/dist/clients/word-index-store.js +23 -12
- package/node_modules/pi-lens/dist/clients/word-index.js +252 -47
- package/node_modules/pi-lens/dist/clients/workspace-topology.js +8 -1
- package/node_modules/pi-lens/dist/clients/zizmor-config.js +4 -1
- package/node_modules/pi-lens/dist/index.js +65899 -55340
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +3 -1
- package/node_modules/pi-lens/dist/mcp/build-staleness.js +1 -1
- package/node_modules/pi-lens/dist/mcp/server.js +127 -5
- package/node_modules/pi-lens/dist/scripts/lib/process-scan.mjs +583 -0
- package/node_modules/pi-lens/dist/scripts/lib/skills-predicate.mjs +129 -0
- package/node_modules/pi-lens/dist/tools/effective-config.js +89 -0
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +96 -25
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +104 -86
- package/node_modules/pi-lens/dist/tools/lsp-navigation.js +37 -16
- package/node_modules/pi-lens/dist/tools/lsp-structured-output.js +3 -3
- package/node_modules/pi-lens/dist/tools/render-compact.js +1 -1
- package/node_modules/pi-lens/dist/tools/shared.js +0 -1
- package/node_modules/pi-lens/dist/tools/symbol-search.js +1 -2
- package/node_modules/pi-lens/docs/agent-guide.md +64 -1
- package/node_modules/pi-lens/docs/configuration.md +222 -0
- package/node_modules/pi-lens/docs/dependencies.md +3 -3
- package/node_modules/pi-lens/docs/features.md +44 -5
- package/node_modules/pi-lens/docs/globalconfig.md +20 -0
- package/node_modules/pi-lens/docs/language-coverage.md +2 -2
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +9 -1
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +25 -0
- package/node_modules/pi-lens/docs/pi-lens-investigator.md +25 -0
- package/node_modules/pi-lens/docs/pi-lens-reviewer.md +33 -0
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +49 -0
- package/node_modules/pi-lens/docs/pi-lens-warden.md +55 -0
- package/node_modules/pi-lens/docs/public-api-stability.md +359 -0
- package/node_modules/pi-lens/docs/release-qa-baseline.md +190 -0
- package/node_modules/pi-lens/docs/servercapabilities.md +7 -3
- package/node_modules/pi-lens/docs/subagent-compat.md +110 -30
- package/node_modules/pi-lens/docs/tree-sitter_rules_catalog.md +2 -2
- package/node_modules/pi-lens/docs/word-index.md +1 -1
- package/node_modules/pi-lens/package.json +18 -35
- package/node_modules/pi-lens/rules/tree-sitter-queries/python/python-cross-language-method.yml +3 -3
- package/node_modules/pi-lens/rules/tree-sitter-queries/python/python-hallucinated-import.yml +2 -2
- package/node_modules/pi-lens/rules/tree-sitter-queries/python/python-sql-injection.yml +12 -2
- package/node_modules/pi-lens/rules/typos/_typos.toml +4 -2
- package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +192 -1
- package/node_modules/pi-lens/scripts/install-selftest.mjs +58 -2
- package/node_modules/pi-lens/scripts/lib/skills-predicate.mjs +129 -0
- package/node_modules/pi-lens/scripts/lib/warm-loader-cache.mjs +1 -1
- package/node_modules/pi-lens/scripts/rpc-load-check.mjs +3 -1
- package/node_modules/pi-lens/scripts/warm-loader-cache.mjs +4 -2
- package/node_modules/pi-web-access/CHANGELOG.md +28 -0
- package/node_modules/pi-web-access/README.md +62 -15
- package/node_modules/pi-web-access/curator-page.ts +3 -1
- package/node_modules/pi-web-access/curator-server.ts +5 -1
- package/node_modules/pi-web-access/gemini-search.ts +8 -4
- package/node_modules/pi-web-access/github-extract.ts +242 -1
- package/node_modules/pi-web-access/index.ts +118 -64
- package/node_modules/pi-web-access/mistral-search.ts +281 -0
- package/node_modules/pi-web-access/package.json +2 -2
- package/node_modules/pi-web-access/perplexity.ts +14 -1
- package/node_modules/pi-web-access/utils.ts +23 -6
- package/node_modules/pi-web-access/xai-search.ts +96 -33
- package/package.json +6 -6
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #2507: hold the event loop for the lifetime of in-flight work that would
|
|
3
|
+
* otherwise be kept alive by NOTHING.
|
|
4
|
+
*
|
|
5
|
+
* Every handle pi-lens owns on the way to an LSP answer is deliberately
|
|
6
|
+
* unref'd. `clients/lsp/launch.ts#unrefLspProcessHandles` unrefs the language
|
|
7
|
+
* server child AND its three stdio pipes so a settled one-shot `pi --print`
|
|
8
|
+
* can exit without waiting for a lingering server (the #1097/#1110 class);
|
|
9
|
+
* `clients/child-unref.ts` does the same for every fire-and-forget probe
|
|
10
|
+
* spawn; `bounded()` and several LSP waits unref their timers for the same
|
|
11
|
+
* reason. That is correct for an IDLE process and wrong for a BUSY one: in a
|
|
12
|
+
* headless child (`pi --mode json -p --no-extensions`, stdin ignored, no TUI,
|
|
13
|
+
* no other extension holding a socket or timer) an in-flight `lsp_diagnostics`
|
|
14
|
+
* call reaches a point where the only thing it is waiting on is an unref'd
|
|
15
|
+
* timer or an unref'd pipe, libuv finds no referenced handle, and Node exits 0
|
|
16
|
+
* IN THE MIDDLE of the tool call — no error, no result, no `turn_end`. The
|
|
17
|
+
* reporter measured it against pyright; the drain site the repro lands on is
|
|
18
|
+
* `LSPService.ensureWarmForSweep`'s warm-up retry backoff (an explicitly
|
|
19
|
+
* `.unref()`'d `setTimeout`), but it is one of many: any await whose only
|
|
20
|
+
* pending handle is unref'd has the same shape.
|
|
21
|
+
*
|
|
22
|
+
* The fix is NOT to stop unref'ing — that would leak a lingering server into
|
|
23
|
+
* every settled one-shot process, which is the reason the unref exists. It is
|
|
24
|
+
* to hold ONE referenced handle for exactly as long as something is in
|
|
25
|
+
* flight: a counted keep-alive, armed while at least one hold is taken and
|
|
26
|
+
* disarmed the moment the last one is released. Idle behaviour is therefore
|
|
27
|
+
* byte-identical to before — no hold, no timer, nothing referenced.
|
|
28
|
+
*
|
|
29
|
+
* Shape 15's screen (AGENTS.md), which this follows deliberately:
|
|
30
|
+
* - a COUNTER of tokens, not a boolean, so overlapping tool calls each
|
|
31
|
+
* release independently and a throwing/aborted caller still releases
|
|
32
|
+
* (callers release from `finally`);
|
|
33
|
+
* - a bounded lifetime PER HOLD, because a leaked hold is the INVERSE defect
|
|
34
|
+
* (a process that can never exit). Each token gets {@link
|
|
35
|
+
* getEventLoopHoldMaxMs} measured from its OWN acquire — derived from the
|
|
36
|
+
* longest legitimate operation's ceiling (`getWorkspaceSweepMaxHoldAgeMs`,
|
|
37
|
+
* the full-scan wall clock plus its safety margin) rather than a second,
|
|
38
|
+
* independently-drifting literal. The keep-alive is armed for the SOONEST
|
|
39
|
+
* outstanding deadline; when it fires, only tokens that are actually stale
|
|
40
|
+
* are released (with a log record naming them), and it re-arms for
|
|
41
|
+
* whatever remains. An epoch-anchored version of this — one timer from the
|
|
42
|
+
* first hold, clearing every token when it fired — was #2649 review F1: a
|
|
43
|
+
* call issued late in a legitimate 300s `lens_diagnostics mode=full` was
|
|
44
|
+
* force-released seconds after starting, i.e. #2507's drain reproduced BY
|
|
45
|
+
* the fix.
|
|
46
|
+
*
|
|
47
|
+
* There is deliberately NO session-boundary clear here, unlike
|
|
48
|
+
* `clients/lsp/workspace-sweep-hold.ts`. A `session_start` can land mid-turn
|
|
49
|
+
* (see `clients/bootstrap.ts`), so clearing holds on a session boundary would
|
|
50
|
+
* un-hold a tool call that is still running and reintroduce this exact defect
|
|
51
|
+
* for it. The hold is scoped to one call's try/finally, not to a session.
|
|
52
|
+
*/
|
|
53
|
+
import { claimPhaseOncePerSession, logLatency, releaseOncePerSessionPhase, } from "./latency-logger.js";
|
|
54
|
+
import { getWorkspaceSweepMaxHoldAgeMs } from "./lsp/workspace-sweep-hold.js";
|
|
55
|
+
import { getProcessSingleton } from "./process-singletons.js";
|
|
56
|
+
/** The one row per session proving the keep-alive was taken (#2649 F2). */
|
|
57
|
+
const EVENT_LOOP_HOLD_ARMED_PHASE = "event_loop_hold_armed";
|
|
58
|
+
const EVENT_LOOP_HOLD_FAMILY = "event-loop-hold";
|
|
59
|
+
const EVENT_LOOP_HOLD_VERSION = 1;
|
|
60
|
+
/**
|
|
61
|
+
* Process-scoped on purpose: pi evaluates the pi-lens module graph more than
|
|
62
|
+
* once in one process (see `clients/process-singletons.ts`), and what is being
|
|
63
|
+
* counted here is a property of the PROCESS's event loop, not of one module
|
|
64
|
+
* evaluation. Two copies would arm two timers for one loop.
|
|
65
|
+
*/
|
|
66
|
+
function state() {
|
|
67
|
+
return getProcessSingleton(EVENT_LOOP_HOLD_FAMILY, EVENT_LOOP_HOLD_VERSION, () => ({ holds: new Map(), nextHoldId: 1, timer: undefined }));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Upper bound on how long ONE hold — each hold, measured from its OWN
|
|
71
|
+
* acquire — may keep this process alive. Derived from `lens_diagnostics
|
|
72
|
+
* mode=full`'s own wall-clock ceiling plus the shared
|
|
73
|
+
* `SWEEP_IDLE_SAFETY_MARGIN_MS` — the same derivation the workspace-sweep
|
|
74
|
+
* hold's max-hold-age failsafe uses, so the two cannot drift apart into a
|
|
75
|
+
* relationship where the longest legitimate tool call outlives the bound that
|
|
76
|
+
* is supposed to only catch bugs.
|
|
77
|
+
*/
|
|
78
|
+
export function getEventLoopHoldMaxMs() {
|
|
79
|
+
return getWorkspaceSweepMaxHoldAgeMs();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Arm the keep-alive for the SOONEST deadline any outstanding hold has — the
|
|
83
|
+
* earliest moment a token can become stale — never for a fixed epoch from the
|
|
84
|
+
* first hold (#2649 review F1).
|
|
85
|
+
*
|
|
86
|
+
* Round 1 armed once on 0→1 and cleared every token when it fired, so a call
|
|
87
|
+
* that started while an older one was still running inherited whatever was
|
|
88
|
+
* left of the FIRST call's bound: a `lens_diagnostics mode=full` legitimately
|
|
89
|
+
* running to its 300s ceiling force-released a healthy `lsp_diagnostics`
|
|
90
|
+
* issued at t=305s, which is #2507's own drain produced by the fix. The
|
|
91
|
+
* reviewer reproduced it in a real child with the bound shortened: both calls
|
|
92
|
+
* unsettled, `active=[]`, `EXIT code=0`.
|
|
93
|
+
*
|
|
94
|
+
* Soonest-deadline, not the youngest survivor's: the youngest would let an
|
|
95
|
+
* older survivor overstay its own max age by the whole age gap. Each token is
|
|
96
|
+
* released when IT is stale and never before.
|
|
97
|
+
*/
|
|
98
|
+
function armForNextDeadline(current) {
|
|
99
|
+
if (current.timer !== undefined)
|
|
100
|
+
return;
|
|
101
|
+
if (current.holds.size === 0)
|
|
102
|
+
return;
|
|
103
|
+
const maxMs = getEventLoopHoldMaxMs();
|
|
104
|
+
let soonest = Number.POSITIVE_INFINITY;
|
|
105
|
+
for (const entry of current.holds.values()) {
|
|
106
|
+
soonest = Math.min(soonest, entry.acquiredAt + maxMs);
|
|
107
|
+
}
|
|
108
|
+
// A past-due deadline is left negative on purpose: Node clamps any delay
|
|
109
|
+
// below 1ms to 1ms, so it fires on a later turn of the loop either way, and
|
|
110
|
+
// a hand-written floor here would be a guard naming a recurrence that
|
|
111
|
+
// cannot happen (#2649 verify F4 — probed: 5 re-arms at delay -5000
|
|
112
|
+
// completed in 5ms, and no test reds without the floor).
|
|
113
|
+
const delayMs = soonest - Date.now();
|
|
114
|
+
// NOT `unref()`'d — referencing the loop is this timer's entire job. It is
|
|
115
|
+
// also the failsafe: when it fires, whatever is stale is over either way.
|
|
116
|
+
current.timer = setTimeout(() => reapStaleHolds(), delayMs);
|
|
117
|
+
}
|
|
118
|
+
function disarmIfIdle(current) {
|
|
119
|
+
if (current.holds.size > 0)
|
|
120
|
+
return;
|
|
121
|
+
if (current.timer === undefined)
|
|
122
|
+
return;
|
|
123
|
+
clearTimeout(current.timer);
|
|
124
|
+
current.timer = undefined;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Release every hold that has outlived {@link getEventLoopHoldMaxMs} ON ITS
|
|
128
|
+
* OWN CLOCK, log what was released, and re-arm for whatever is still
|
|
129
|
+
* outstanding. Same shape as `clients/lsp/workspace-sweep-hold.ts`'s
|
|
130
|
+
* `reapStaleHolds` — deliberately a second, independent implementation rather
|
|
131
|
+
* than a shared ledger (that consolidation is tracked separately).
|
|
132
|
+
*/
|
|
133
|
+
function reapStaleHolds() {
|
|
134
|
+
const current = state();
|
|
135
|
+
current.timer = undefined;
|
|
136
|
+
try {
|
|
137
|
+
const maxMs = getEventLoopHoldMaxMs();
|
|
138
|
+
const now = Date.now();
|
|
139
|
+
const released = [];
|
|
140
|
+
for (const [holdId, entry] of current.holds) {
|
|
141
|
+
if (now - entry.acquiredAt <= maxMs)
|
|
142
|
+
continue;
|
|
143
|
+
current.holds.delete(holdId);
|
|
144
|
+
released.push(entry);
|
|
145
|
+
}
|
|
146
|
+
if (released.length > 0) {
|
|
147
|
+
recordForceReleased(released, current.holds.size, maxMs, now);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
// A survivor is held by nothing until this re-arms — the drain — and
|
|
152
|
+
// forever if it never does — the leak. In a `finally` because this runs
|
|
153
|
+
// inside a timer callback, where anything that escapes is an uncaught
|
|
154
|
+
// exception, and because the round-2 code put the log between the reap
|
|
155
|
+
// and the re-arm: a throwing sink stranded the survivor (#2649 verify
|
|
156
|
+
// F3). The map is already consistent by here — entries are deleted
|
|
157
|
+
// before anything is logged.
|
|
158
|
+
armForNextDeadline(current);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The force-release record, and its own absorption. Telemetry may not break
|
|
163
|
+
* the guard it observes — the house rule spelled at
|
|
164
|
+
* `clients/runtime-tool-call.ts`'s blocked-attribution cleanup: a guard that
|
|
165
|
+
* fails because its telemetry broke is worse than no guard. Nothing here has
|
|
166
|
+
* a fallback sink to escalate to; the keep-alive's correctness does not
|
|
167
|
+
* depend on the row being written.
|
|
168
|
+
*/
|
|
169
|
+
function recordForceReleased(released, stillHeld, maxMs, now) {
|
|
170
|
+
try {
|
|
171
|
+
const oldestAcquiredAt = Math.min(...released.map((entry) => entry.acquiredAt));
|
|
172
|
+
logLatency({
|
|
173
|
+
type: "phase",
|
|
174
|
+
phase: "event_loop_hold_force_released",
|
|
175
|
+
filePath: "",
|
|
176
|
+
durationMs: now - oldestAcquiredAt,
|
|
177
|
+
metadata: {
|
|
178
|
+
maxHoldMs: maxMs,
|
|
179
|
+
releasedHolds: released.length,
|
|
180
|
+
stillHeld,
|
|
181
|
+
labels: [...new Set(released.map((entry) => entry.label))].slice(0, 8),
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// see the doc comment — a broken sink must not reach the reap path
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* ONE row per session saying the keep-alive was actually taken (#2649 review
|
|
191
|
+
* F2). Without it the only record this module ever writes is the failsafe, so
|
|
192
|
+
* a silent log cannot distinguish "working as designed" from "never wired at
|
|
193
|
+
* all" — the #2526 gap shape. Claimed through the logger's own
|
|
194
|
+
* once-per-session mechanism rather than a private latch, so the "one row per
|
|
195
|
+
* session" a reader counts against is the same property `config_resolved`
|
|
196
|
+
* has.
|
|
197
|
+
*/
|
|
198
|
+
function recordFirstArm(entry, maxMs) {
|
|
199
|
+
try {
|
|
200
|
+
if (!claimPhaseOncePerSession(EVENT_LOOP_HOLD_ARMED_PHASE, "process")) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
logLatency({
|
|
204
|
+
type: "phase",
|
|
205
|
+
phase: EVENT_LOOP_HOLD_ARMED_PHASE,
|
|
206
|
+
filePath: "",
|
|
207
|
+
durationMs: 0,
|
|
208
|
+
metadata: { label: entry.label, maxHoldMs: maxMs },
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
// This runs on the ACQUIRE path, and `normalizeToolDefinition` takes the
|
|
213
|
+
// hold outside its own try — so a throw here rejected the tool call with
|
|
214
|
+
// the sink's error instead of returning the tool's result (#2649 verify
|
|
215
|
+
// F3). Same house rule as `recordForceReleased` above: the hold is
|
|
216
|
+
// already taken and armed by this point, so absorbing the throw loses a
|
|
217
|
+
// log row and nothing else.
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Take one hold for the lifetime of a piece of in-flight work, and return its
|
|
222
|
+
* release. Callers MUST release from a `finally` block: a throw, a rejection
|
|
223
|
+
* or an abort has to release exactly like a normal return, or the hold leaks
|
|
224
|
+
* and the process stops being able to exit.
|
|
225
|
+
*
|
|
226
|
+
* The release is identity-guarded and idempotent — calling it twice, or after
|
|
227
|
+
* the max-age failsafe already force-released it, is a no-op and never
|
|
228
|
+
* disarms another caller's hold.
|
|
229
|
+
*/
|
|
230
|
+
export function acquireEventLoopHold(label) {
|
|
231
|
+
const current = state();
|
|
232
|
+
const holdId = current.nextHoldId++;
|
|
233
|
+
const entry = { acquiredAt: Date.now(), label };
|
|
234
|
+
current.holds.set(holdId, entry);
|
|
235
|
+
const wasArmed = current.timer !== undefined;
|
|
236
|
+
armForNextDeadline(current);
|
|
237
|
+
if (!wasArmed)
|
|
238
|
+
recordFirstArm(entry, getEventLoopHoldMaxMs());
|
|
239
|
+
return () => {
|
|
240
|
+
const now = state();
|
|
241
|
+
if (!now.holds.delete(holdId))
|
|
242
|
+
return;
|
|
243
|
+
disarmIfIdle(now);
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/** Test-only: how many holds are outstanding right now. */
|
|
247
|
+
export function _eventLoopHoldCountForTests() {
|
|
248
|
+
return state().holds.size;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Test-only: the keep-alive handle's own state. `hasRef` is the property the
|
|
252
|
+
* whole fix rests on — a handle that is armed but unref'd holds nothing — so
|
|
253
|
+
* it is read from the live `Timeout` (`hasRef()`), not asserted from the
|
|
254
|
+
* source text.
|
|
255
|
+
*/
|
|
256
|
+
export function _eventLoopKeepAliveForTests() {
|
|
257
|
+
const timer = state().timer;
|
|
258
|
+
return {
|
|
259
|
+
armed: timer !== undefined,
|
|
260
|
+
hasRef: timer?.hasRef?.() === true,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** Test-only: drop every hold and disarm, between tests. */
|
|
264
|
+
export function _resetEventLoopHoldForTests() {
|
|
265
|
+
// This module's own phase only — never a blanket clear of a structure other
|
|
266
|
+
// producers claim in (`releaseOncePerSessionPhase`'s doc comment).
|
|
267
|
+
releaseOncePerSessionPhase(EVENT_LOOP_HOLD_ARMED_PHASE);
|
|
268
|
+
const current = state();
|
|
269
|
+
current.holds.clear();
|
|
270
|
+
if (current.timer !== undefined)
|
|
271
|
+
clearTimeout(current.timer);
|
|
272
|
+
current.timer = undefined;
|
|
273
|
+
current.nextHoldId = 1;
|
|
274
|
+
}
|
|
@@ -88,14 +88,14 @@ export function startEventLoopMonitor(resolutionMs = 20) {
|
|
|
88
88
|
* every block that tier cares about while keeping sub-second jitter — where
|
|
89
89
|
* measurement slop rivals the signal — out of the verdict.
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
const STALL_CLASSIFY_FLOOR_MS = 1000;
|
|
92
92
|
/**
|
|
93
93
|
* Slack allowed to the CPU budget before a block counts as unaccounted.
|
|
94
94
|
* `process.cpuUsage()` and the histogram are sampled at slightly different
|
|
95
95
|
* instants and the histogram quantizes, so a block whose CPU coverage is
|
|
96
96
|
* within this much of exact is called `cpu-accounted`, not a stall.
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
const STALL_CLASSIFY_SLOP_MS = 250;
|
|
99
99
|
/**
|
|
100
100
|
* Split a block into compute-vs-stall from the CPU it could possibly have
|
|
101
101
|
* burned (#1980). Pure, so the discrimination is testable without the native
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
24
24
|
import * as path from "node:path";
|
|
25
25
|
import { isTestMode } from "./env-utils.js";
|
|
26
|
-
import {
|
|
26
|
+
import { getGlobalPiLensLogDir } from "./probe-home-state.js";
|
|
27
27
|
import { getMaxLogSizeMB } from "./log-cleanup.js";
|
|
28
28
|
import { createNdjsonLogger } from "./ndjson-logger.js";
|
|
29
|
-
export const EXTENSION_LOG_FILE = path.join(
|
|
29
|
+
export const EXTENSION_LOG_FILE = path.join(getGlobalPiLensLogDir(), "extension.log");
|
|
30
30
|
const writer = createNdjsonLogger({
|
|
31
31
|
filePath: EXTENSION_LOG_FILE,
|
|
32
32
|
maxBytes: getMaxLogSizeMB() * 1024 * 1024,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { escapeRegExp } from "./string-utils.js";
|
|
1
2
|
function normalizeHintInput(value) {
|
|
2
3
|
return value.replace(/\\/g, "/");
|
|
3
4
|
}
|
|
4
5
|
function hasHintToken(value, tokens) {
|
|
5
|
-
const escaped = tokens.map((token) => token
|
|
6
|
+
const escaped = tokens.map((token) => escapeRegExp(token));
|
|
6
7
|
const alternatives = escaped.join("|");
|
|
7
8
|
// Path/word boundaries are deliberately explicit: a token must occupy a
|
|
8
9
|
// segment (or a dot/dash/underscore-separated word), never an arbitrary
|
|
@@ -92,7 +92,7 @@ export const KIND_EXTENSIONS = {
|
|
|
92
92
|
zig: [".zig", ".zon"],
|
|
93
93
|
};
|
|
94
94
|
/** Return whether a path has an extension registered for the given file kind. */
|
|
95
|
-
|
|
95
|
+
function hasKindExtension(filePath, kind) {
|
|
96
96
|
const extension = extname(filePath).toLowerCase();
|
|
97
97
|
return KIND_EXTENSIONS[kind].some((candidate) => candidate === extension);
|
|
98
98
|
}
|
|
@@ -284,18 +284,6 @@ export const NON_CODE_KINDS = new Set([
|
|
|
284
284
|
"toml",
|
|
285
285
|
"yaml",
|
|
286
286
|
]);
|
|
287
|
-
/**
|
|
288
|
-
* Check if a file kind represents a code file (not config/markdown).
|
|
289
|
-
*/
|
|
290
|
-
export function isCodeKind(kind) {
|
|
291
|
-
return CODE_KINDS.has(kind);
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Check if a file kind represents a text/config/doc/markup file.
|
|
295
|
-
*/
|
|
296
|
-
export function isConfigKind(kind) {
|
|
297
|
-
return NON_CODE_KINDS.has(kind);
|
|
298
|
-
}
|
|
299
287
|
/**
|
|
300
288
|
* Check if a file path resolves to a {@link CODE_KINDS} kind. Undetectable
|
|
301
289
|
* files (unknown extension, e.g. `.coffee` from SOURCE_PRECEDENCE) are
|
|
@@ -351,31 +339,6 @@ export function getFileKindLabel(kind) {
|
|
|
351
339
|
};
|
|
352
340
|
return labels[kind] ?? kind;
|
|
353
341
|
}
|
|
354
|
-
/**
|
|
355
|
-
* Get file extensions for a file kind.
|
|
356
|
-
*/
|
|
357
|
-
export function getExtensionsForKind(kind) {
|
|
358
|
-
return [...(KIND_EXTENSIONS[kind] ?? [])];
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Check if a file should be scanned for linting/formatting.
|
|
362
|
-
* Excludes test files, generated files, etc.
|
|
363
|
-
*/
|
|
364
|
-
export function isScannableFile(filePath) {
|
|
365
|
-
const kind = detectFileKind(filePath);
|
|
366
|
-
if (!kind)
|
|
367
|
-
return false;
|
|
368
|
-
// Exclude test files for most kinds
|
|
369
|
-
const base = basename(filePath);
|
|
370
|
-
if (base.includes(".test.") ||
|
|
371
|
-
base.includes(".spec.") ||
|
|
372
|
-
base.startsWith("test-") ||
|
|
373
|
-
base.startsWith("spec-")) {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
// Only scan code and config files
|
|
377
|
-
return isCodeKind(kind) || isConfigKind(kind);
|
|
378
|
-
}
|
|
379
342
|
/**
|
|
380
343
|
* Get the language identifier for LSP/tools that use language IDs.
|
|
381
344
|
*/
|
|
@@ -95,7 +95,12 @@ export class FileTime {
|
|
|
95
95
|
const lockPromise = fn().finally(() => {
|
|
96
96
|
globalState.locks.delete(absolutePath);
|
|
97
97
|
});
|
|
98
|
-
|
|
98
|
+
// The STORED lock promise must never reject unhandled: a rejecting fn
|
|
99
|
+
// (e.g. partial-apply's pre-write rejection, #2402) would otherwise leave
|
|
100
|
+
// an orphaned rejected promise on every withLock caller. Waiters awaiting
|
|
101
|
+
// the stored copy still resume — the finally above already deleted the
|
|
102
|
+
// lock entry by the time the rejection settles.
|
|
103
|
+
globalState.locks.set(absolutePath, lockPromise.then(() => { }, () => { }));
|
|
99
104
|
return lockPromise;
|
|
100
105
|
}
|
|
101
106
|
/**
|
|
@@ -114,7 +119,7 @@ export class FileTime {
|
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
// --- Error Type ---
|
|
117
|
-
|
|
122
|
+
class FileTimeError extends Error {
|
|
118
123
|
filePath;
|
|
119
124
|
reason;
|
|
120
125
|
constructor(message, filePath, reason) {
|
|
@@ -5,10 +5,11 @@ import * as fs from "node:fs";
|
|
|
5
5
|
import * as os from "node:os";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import { Minimatch } from "./deps/minimatch.js";
|
|
8
|
+
import { FRESHNESS_CADENCE_MS } from "./freshness-cadence.js";
|
|
8
9
|
import { isInSpawnTimeoutCooldown, noteSpawnTimeout, } from "./spawn-timeout-cooldown.js";
|
|
9
10
|
import { collectTrackedFiles, getTrackedFilesSnapshot, } from "./git-tracked-ignore.js";
|
|
10
11
|
import { getGlobalIgnorePatterns, getPiLensGlobalConfigPath, } from "./lens-config.js";
|
|
11
|
-
import { isUnderDir, normalizeEphemeralMapKey, normalizeFilePath, } from "./path-utils.js";
|
|
12
|
+
import { homeRelativePath, isExternalOrVendorFile, isUnderDir, normalizeEphemeralMapKey, normalizeFilePath, toProjectRelativePath, } from "./path-utils.js";
|
|
12
13
|
import { findPiLensConfigInDir, findPiLensProjectConfig, loadPiLensConfigInDir, loadPiLensProjectConfig, } from "./project-lens-config.js";
|
|
13
14
|
import { safeSpawnAsync } from "./safe-spawn.js";
|
|
14
15
|
/**
|
|
@@ -42,27 +43,101 @@ export function getProjectDataDir(cwd) {
|
|
|
42
43
|
.replace(/-+$/, ""); // trim trailing dashes
|
|
43
44
|
return path.join(base.trim(), slug || "default");
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* The project-data path to SHOW an agent or a human, for a file that
|
|
48
|
+
* {@link getProjectDataDir} owns.
|
|
49
|
+
*
|
|
50
|
+
* #2521: the turn-end actionable-warnings advisory told the agent to read a
|
|
51
|
+
* hardcoded `.pi-lens/cache/actionable-warnings.json`, but that spelling is
|
|
52
|
+
* only correct in the LEGACY arm of `getProjectDataDir` — a project with no
|
|
53
|
+
* `.pi-lens/` directory (the common case) stores the report under
|
|
54
|
+
* `~/.pi-lens/projects/<slug>/cache/`, and a `PILENS_DATA_DIR` project stores
|
|
55
|
+
* it somewhere else again. Agents followed the advisory literally and got
|
|
56
|
+
* `cat: .pi-lens/cache/actionable-warnings.json: No such file or directory`.
|
|
57
|
+
*
|
|
58
|
+
* Any instructional string that NAMES a project-data location must be built
|
|
59
|
+
* here, so the displayed path and the written path can never disagree. Guarded
|
|
60
|
+
* by `tests/clients/data-dir-display-path-sweep.test.ts`.
|
|
61
|
+
*
|
|
62
|
+
* Two output shapes, matching `toRunnerDisplayPath`'s convention
|
|
63
|
+
* (`clients/dispatch/runner-context.ts`) so one advisory never mixes styles:
|
|
64
|
+
* - under `cwd` → a `/`-separated path relative to it
|
|
65
|
+
* (`.pi-lens/cache/actionable-warnings.json`), which is what the legacy
|
|
66
|
+
* arm produces and what an agent can paste straight into a shell.
|
|
67
|
+
* - anywhere else → absolute, `/`-separated, and `~`-folded via
|
|
68
|
+
* {@link homeRelativePath} so the default `~/.pi-lens/projects/...` store
|
|
69
|
+
* does not leak the account name into agent context (#2440 F5).
|
|
70
|
+
*
|
|
71
|
+
* Pure string work on top of `getProjectDataDir`'s own resolution: it never
|
|
72
|
+
* stats the target, so it is safe to call for a file that has not been written
|
|
73
|
+
* yet and cannot throw on a surface whose whole job is to render a hint.
|
|
74
|
+
*
|
|
75
|
+
* The relative-or-absolute decision reuses `toProjectRelativePath`
|
|
76
|
+
* (`clients/path-utils.ts`) — the same shape-aware, non-stat'ing primitive
|
|
77
|
+
* `toRunnerDisplayPath` (`clients/dispatch/runner-context.ts`) composes for
|
|
78
|
+
* the analogous "relative path if under this root, else something else"
|
|
79
|
+
* decision — rather than a second hand-rolled `path.relative` fold. It is NOT
|
|
80
|
+
* `toRunnerDisplayPath` itself: that helper routes its result through
|
|
81
|
+
* `normalizeMapKey`, which on win32 calls `realpathSync.native()` (or, for a
|
|
82
|
+
* not-yet-existing path, lowercases the unresolved tail) — exactly the
|
|
83
|
+
* stat-and-mutate-casing behavior this function's contract above rules out.
|
|
84
|
+
*/
|
|
85
|
+
export function displayProjectDataPath(cwd, ...segments) {
|
|
86
|
+
const absolute = path.resolve(getProjectDataDir(cwd), ...segments);
|
|
87
|
+
const absolutePosix = absolute.replace(/\\/g, "/");
|
|
88
|
+
const relative = toProjectRelativePath(absolute, cwd);
|
|
89
|
+
if (relative !== absolutePosix) {
|
|
90
|
+
return relative;
|
|
91
|
+
}
|
|
92
|
+
// `toProjectRelativePath` fell back to the (posix-ified) absolute path —
|
|
93
|
+
// `absolute` is not under `cwd`. Fold `~` so the default
|
|
94
|
+
// `~/.pi-lens/projects/...` store does not leak the account name into
|
|
95
|
+
// agent context (#2440 F5). Posix-ify BEFORE the fold: `homeRelativePath`
|
|
96
|
+
// deliberately returns a path that is not under `$HOME` unchanged,
|
|
97
|
+
// separators included, so a `PILENS_DATA_DIR=D:\lens-data` store would
|
|
98
|
+
// otherwise render with backslashes while the legacy arm above renders
|
|
99
|
+
// with forward ones — `absolutePosix` is already folded, so this is a
|
|
100
|
+
// no-op fold, not a second one.
|
|
101
|
+
return homeRelativePath(absolutePosix);
|
|
102
|
+
}
|
|
45
103
|
/**
|
|
46
104
|
* Machine-global pi-lens directory: `~/.pi-lens/` by default.
|
|
47
105
|
*
|
|
48
|
-
* Used for
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
106
|
+
* Used for tool binaries (`~/.pi-lens/tools/`, `~/.pi-lens/bin/`), the
|
|
107
|
+
* cross-process instance registry (`instances.json`, #449/#525) and the
|
|
108
|
+
* orphan-backstop lease beside it, the auto-install probe cache, the
|
|
109
|
+
* canonical global config (`config.json`), LSP server storage (intelephense's
|
|
110
|
+
* index, PSES's per-PID session dir) and JVM runtimes — state that is
|
|
111
|
+
* intentionally NOT project-scoped, because it spans every project pi-lens
|
|
112
|
+
* has touched.
|
|
53
113
|
*
|
|
54
114
|
* Override: set `PI_LENS_HOME=/some/path` to relocate this ENTIRE root (every
|
|
55
|
-
* caller
|
|
115
|
+
* caller routes through this one function, so one env var covers all of
|
|
56
116
|
* them — see #525). Tests MUST set this to a per-worker temp dir in
|
|
57
117
|
* `tests/support/vitest-setup.ts` rather than mocking each caller separately;
|
|
58
118
|
* otherwise a test that exercises `registerInstance`/`sweepOrphans` or any
|
|
59
119
|
* logger writes into the developer's REAL `~/.pi-lens` (dogfooded live: a
|
|
60
120
|
* test-fixture instance survived in the real `instances.json` for 17h).
|
|
61
121
|
*
|
|
122
|
+
* DELIBERATELY cwd-INDEPENDENT (#2506 round 3). Its sibling
|
|
123
|
+
* `getGlobalPiLensLogDir()` (`probe-home-state.ts`) carries the probe-home
|
|
124
|
+
* redirect; this one must not, because the things resolved here are shared
|
|
125
|
+
* machine state a session needs to KEEP: a pi session running from an agent
|
|
126
|
+
* worktree or a throwaway temp project must still find the tools it already
|
|
127
|
+
* installed and must still register in the one `instances.json` every other
|
|
128
|
+
* pi-lens process on the box reads. Redirecting THIS function (as round 2 of
|
|
129
|
+
* #2506 did) would silently give every worktree its own empty tool tree and
|
|
130
|
+
* its own private registry, so the reaper could never see across them — a
|
|
131
|
+
* worse defect than the telemetry pollution the redirect exists to stop.
|
|
132
|
+
*
|
|
62
133
|
* Distinct from `getProjectDataDir(cwd)`, which respects `PILENS_DATA_DIR`
|
|
63
134
|
* (project-scoped) and produces per-project subdirectories. Callers writing
|
|
64
135
|
* project caches, snapshots, or worklogs should use `getProjectDataDir(cwd)`
|
|
65
136
|
* instead — `PI_LENS_HOME` is the MACHINE-scoped sibling of that override.
|
|
137
|
+
* `getProjectDataDir` composes through THIS function, not the log one: a
|
|
138
|
+
* probe's project caches are already isolated by its own path slug, and a
|
|
139
|
+
* worktree session keeping its warm caches is the same "do not break the
|
|
140
|
+
* session" argument as the tools above.
|
|
66
141
|
*/
|
|
67
142
|
export function getGlobalPiLensDir() {
|
|
68
143
|
const override = process.env.PI_LENS_HOME?.trim();
|
|
@@ -227,7 +302,7 @@ function matchesGitignorePattern(pattern, relativePath, isDirectory, matchExpand
|
|
|
227
302
|
return candidates.some((value) => matchExpanded(value, expanded));
|
|
228
303
|
});
|
|
229
304
|
}
|
|
230
|
-
|
|
305
|
+
function readGitignorePatterns(rootDir, layer = "gitignore") {
|
|
231
306
|
const gitignorePath = path.join(rootDir, ".gitignore");
|
|
232
307
|
try {
|
|
233
308
|
return parseGitignoreContent(fs.readFileSync(gitignorePath, "utf-8"), layer);
|
|
@@ -493,8 +568,17 @@ export function createProjectIgnoreMatcher(rootDir, extraPatterns = [], globalPa
|
|
|
493
568
|
return buildProjectIgnoreMatcher(resolvedRoot, patterns);
|
|
494
569
|
}
|
|
495
570
|
const projectIgnoreMatcherCache = new Map();
|
|
496
|
-
/**
|
|
497
|
-
|
|
571
|
+
/**
|
|
572
|
+
* Nested ignore sources are checked at most once per root per cadence window.
|
|
573
|
+
* Sourced from the shared leaf (`freshness-cadence.ts`) rather than owning the
|
|
574
|
+
* value: `project-lens-config.ts`'s no-config discovery cache (#2483 round 2)
|
|
575
|
+
* needs the same cadence and cannot import it FROM here, because this module
|
|
576
|
+
* already imports `project-lens-config.ts` (the `clients/` acyclic-imports
|
|
577
|
+
* rule would reject the reverse edge). Re-exported under this name so the
|
|
578
|
+
* existing test imports (`tests/clients/project-ignore-freshness.test.ts` and
|
|
579
|
+
* siblings) are unaffected.
|
|
580
|
+
*/
|
|
581
|
+
export const PROJECT_IGNORE_FRESHNESS_CADENCE_MS = FRESHNESS_CADENCE_MS;
|
|
498
582
|
function fileFreshnessSignature(filePath) {
|
|
499
583
|
try {
|
|
500
584
|
const stat = fs.statSync(filePath);
|
|
@@ -627,6 +711,25 @@ export function invalidateProjectIgnoreMatcherForPath(filePath) {
|
|
|
627
711
|
export function isPathIgnoredByProject(filePath, rootDir, isDirectory = false) {
|
|
628
712
|
return getProjectIgnoreMatcher(rootDir).isIgnored(filePath, isDirectory);
|
|
629
713
|
}
|
|
714
|
+
/**
|
|
715
|
+
* "Is this a project-source path pi-lens's bookkeeping should care about" —
|
|
716
|
+
* the `isPathIgnoredByProject` + `isExternalOrVendorFile` pair, previously
|
|
717
|
+
* hand-duplicated at each of its 2 call sites (`registerReadBridge` and
|
|
718
|
+
* `registerMutationBridge` in `index.ts`, both #2423). Consolidated here
|
|
719
|
+
* (#2450 review round 2, F4) when a THIRD call site — `tools/lsp-navigation.ts`
|
|
720
|
+
* threading the same gate onto its directly-threaded `LspMutationContext`, so
|
|
721
|
+
* the direct LSP-mutation path and the mutation-bridge fallback path apply
|
|
722
|
+
* the identical gate instead of the fallback silently being narrower. A
|
|
723
|
+
* caller still layers its own `no-read-guard`-style flag check on top; that
|
|
724
|
+
* flag has no file path to check against, so it stays outside this helper.
|
|
725
|
+
*/
|
|
726
|
+
export function isRecordableProjectPath(filePath, projectRoot) {
|
|
727
|
+
if (isPathIgnoredByProject(filePath, projectRoot, false))
|
|
728
|
+
return false;
|
|
729
|
+
if (isExternalOrVendorFile(filePath, projectRoot))
|
|
730
|
+
return false;
|
|
731
|
+
return true;
|
|
732
|
+
}
|
|
630
733
|
const projectIgnoreGlobsCache = new Map();
|
|
631
734
|
export function getProjectIgnoreGlobs(rootDir) {
|
|
632
735
|
const resolvedRoot = path.resolve(rootDir);
|
|
@@ -659,7 +762,11 @@ export function readGitignoreDirs(rootDir) {
|
|
|
659
762
|
.map((entry) => entry.pattern);
|
|
660
763
|
}
|
|
661
764
|
function globToRegExp(glob) {
|
|
765
|
+
// Directory names use the same `*`-only dialect as read-guard exemptions.
|
|
766
|
+
// Collapse adjacent stars before compiling to avoid nullable-group
|
|
767
|
+
// backtracking on a non-matching name (#2622).
|
|
662
768
|
const escaped = glob
|
|
769
|
+
.replace(/\*+/g, "*")
|
|
663
770
|
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
664
771
|
.replace(/\*/g, ".*")
|
|
665
772
|
.replace(/\?/g, ".");
|