@herbertgao/pi-extensions 2026.9.0 → 2026.9.1
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/@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 +988 -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 -2
- package/node_modules/pi-lens/dist/clients/actionable-warnings.js +927 -80
- 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 -2
- package/node_modules/pi-lens/dist/clients/bash-file-access.js +1 -3
- package/node_modules/pi-lens/dist/clients/biome-client.js +9 -2
- package/node_modules/pi-lens/dist/clients/blocker-freshness.js +14 -0
- 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-telemetry.js +59 -4
- package/node_modules/pi-lens/dist/clients/bundled-resource-health.js +113 -0
- package/node_modules/pi-lens/dist/clients/bus-events-logger.js +2 -2
- 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 +44 -18
- package/node_modules/pi-lens/dist/clients/cargo-manifest.js +422 -0
- package/node_modules/pi-lens/dist/clients/cascade-logger.js +2 -2
- 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 +47 -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 +171 -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 +167 -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 +197 -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 -2
- 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-line-freshness.js +12 -9
- package/node_modules/pi-lens/dist/clients/diagnostic-logger.js +14 -4
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +162 -18
- package/node_modules/pi-lens/dist/clients/dispatch/fact-store.js +97 -0
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +9 -7
- 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 +380 -26
- 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 +0 -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 +0 -1
- 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 +13 -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 +0 -1
- 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 +0 -1
- 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 +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/spellcheck.js +0 -1
- 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 -4
- 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/vale.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yamllint.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/zig-check.js +0 -1
- package/node_modules/pi-lens/dist/clients/disposition-logger.js +3 -3
- 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/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-time.js +6 -1
- package/node_modules/pi-lens/dist/clients/file-utils.js +112 -9
- package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +50 -13
- package/node_modules/pi-lens/dist/clients/format-service.js +6 -1
- package/node_modules/pi-lens/dist/clients/formatters.js +276 -102
- package/node_modules/pi-lens/dist/clients/freshness-cadence.js +17 -0
- package/node_modules/pi-lens/dist/clients/generated-artifacts.js +114 -19
- package/node_modules/pi-lens/dist/clients/generation-guard.js +4 -9
- package/node_modules/pi-lens/dist/clients/git-guard.js +1 -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/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 +71 -52
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +104 -230
- package/node_modules/pi-lens/dist/clients/instance-registry.js +6 -3
- package/node_modules/pi-lens/dist/clients/language-registry.js +595 -0
- package/node_modules/pi-lens/dist/clients/latency-logger.js +160 -2
- package/node_modules/pi-lens/dist/clients/ledger-bounds.js +13 -0
- package/node_modules/pi-lens/dist/clients/lens-config.js +141 -30
- package/node_modules/pi-lens/dist/clients/lens-engine.js +30 -37
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +59 -6
- package/node_modules/pi-lens/dist/clients/log-cleanup.js +2 -2
- package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +3 -1
- package/node_modules/pi-lens/dist/clients/lsp/client.js +168 -30
- package/node_modules/pi-lens/dist/clients/lsp/config.js +483 -158
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp/edits.js +15 -2
- package/node_modules/pi-lens/dist/clients/lsp/index.js +676 -71
- package/node_modules/pi-lens/dist/clients/lsp/language.js +18 -169
- package/node_modules/pi-lens/dist/clients/lsp/launch.js +2 -1
- package/node_modules/pi-lens/dist/clients/lsp/pending-aux-coverage.js +5 -16
- 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/tsserver-sync.js +9 -2
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.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/middle-man-analysis.js +2 -4
- package/node_modules/pi-lens/dist/clients/module-report.js +20 -45
- 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 -20
- 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 +68 -22
- package/node_modules/pi-lens/dist/clients/opengrep-config.js +4 -0
- 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 +428 -13
- 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 +77 -16
- 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-diagnostics/fresh-fetch.js +4 -3
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +27 -3
- package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +51 -20
- package/node_modules/pi-lens/dist/clients/project-lens-config.js +393 -122
- 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 +15 -4
- package/node_modules/pi-lens/dist/clients/read-guard-tool-lines.js +364 -212
- package/node_modules/pi-lens/dist/clients/read-guard.js +21 -0
- package/node_modules/pi-lens/dist/clients/resource-sampler.js +195 -96
- package/node_modules/pi-lens/dist/clients/review-graph/builder.js +152 -109
- 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 +18 -2
- 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 +139 -22
- package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +168 -35
- 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 -1
- 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/sessionstart-logger.js +12 -3
- package/node_modules/pi-lens/dist/clients/sgconfig.js +6 -1
- package/node_modules/pi-lens/dist/clients/skills-resolver.js +105 -0
- package/node_modules/pi-lens/dist/clients/smells-rollup.js +2 -2
- 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 +239 -0
- package/node_modules/pi-lens/dist/clients/tool-definition.js +41 -1
- package/node_modules/pi-lens/dist/clients/tool-policy.js +91 -21
- package/node_modules/pi-lens/dist/clients/tree-sitter-cache.js +40 -40
- package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +86 -48
- 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/typos-config.js +5 -0
- package/node_modules/pi-lens/dist/clients/user-notify.js +6 -2
- package/node_modules/pi-lens/dist/clients/widget-state.js +191 -26
- package/node_modules/pi-lens/dist/clients/word-index-logger.js +2 -2
- package/node_modules/pi-lens/dist/clients/word-index-store.js +20 -5
- package/node_modules/pi-lens/dist/clients/word-index.js +243 -31
- package/node_modules/pi-lens/dist/clients/workspace-topology.js +8 -1
- package/node_modules/pi-lens/dist/clients/zizmor-config.js +3 -0
- package/node_modules/pi-lens/dist/index.js +64335 -54300
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +3 -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 +95 -24
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +67 -80
- package/node_modules/pi-lens/dist/tools/lsp-navigation.js +37 -16
- package/node_modules/pi-lens/dist/tools/shared.js +0 -1
- 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/language-coverage.md +2 -2
- 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 +27 -0
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +38 -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 +182 -0
- 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/package.json +15 -23
- 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/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/rpc-load-check.mjs +3 -1
- 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 +5 -5
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { createHash } from "node:crypto";
|
|
14
14
|
import * as fs from "node:fs";
|
|
15
15
|
import * as path from "node:path";
|
|
16
|
+
import { BoundedFifoMap } from "./bounded-cache.js";
|
|
16
17
|
import { emitBounded } from "./bounded-telemetry.js";
|
|
17
18
|
import { LEDGER_FIELD_MAX } from "./degradation-ledger.js";
|
|
18
19
|
import { minimatch } from "./deps/minimatch.js";
|
|
@@ -20,9 +21,46 @@ import { createSubsystemLogger } from "./extension-log.js";
|
|
|
20
21
|
import { detectFileRole } from "./file-role.js";
|
|
21
22
|
import { findGlobalBinary } from "./package-manager.js";
|
|
22
23
|
import { PathKeyedMap } from "./path-keyed-map.js";
|
|
23
|
-
import {
|
|
24
|
+
import { augmentPythonEnvironment, detectPythonEnvironment, } from "./python-environment.js";
|
|
25
|
+
import { normalizeEphemeralMapKey, normalizeMapKey, toPosix, } from "./path-utils.js";
|
|
24
26
|
import { isMeasuredDuration, toMeasuredDurationMs } from "./run-duration.js";
|
|
25
27
|
import { safeSpawn, safeSpawnAsync } from "./safe-spawn.js";
|
|
28
|
+
import { stripAnsi } from "./sanitize.js";
|
|
29
|
+
/**
|
|
30
|
+
* #2532: the ONE classification seam for "this `TestResult` carries NO
|
|
31
|
+
* counted failure the agent needs to fix, even though the runner also
|
|
32
|
+
* reported an `error`" — i.e. `failed === 0 && !!error`. This is NOT "the
|
|
33
|
+
* suite never started": a runner can report BOTH counted failures and an
|
|
34
|
+
* error (pytest exit 2 "Interrupted" after `2 failed, 1 passed` already
|
|
35
|
+
* printed — `parsePytestOutput` sets `error` from the exit code
|
|
36
|
+
* independently of the parsed counts, review round 1 S2). The rule is
|
|
37
|
+
* exactly `failed === 0`, nothing about `error`'s presence or cause: a
|
|
38
|
+
* result with counted failures stays blocking even when `error` is also
|
|
39
|
+
* set (`testResultToProjectDiagnostics`/`formatResult` still mention the
|
|
40
|
+
* error in that case, they just don't let it downgrade the verdict).
|
|
41
|
+
*
|
|
42
|
+
* `hasRealFailure`/`runnerErrorOnly` (`runtime-turn.ts`, #2522) key off the
|
|
43
|
+
* exact same fact for the turn-end delivery framing — a batch made
|
|
44
|
+
* entirely of `isRunnerErrorResult` results is advisory, one containing
|
|
45
|
+
* even one counted failure keeps "fix before continuing". Three more
|
|
46
|
+
* surfaces route through this SAME predicate instead of re-deriving it
|
|
47
|
+
* (review round 1 S1's class sweep), so the identical `TestResult` cannot
|
|
48
|
+
* classify differently across them: `testResultToProjectDiagnostics`
|
|
49
|
+
* (`lens_diagnostics mode=full`), the `--lens-guard` merge call in
|
|
50
|
+
* `handleTurnEnd`, and `TestRunnerClient.formatResult`/the turn-end dbg
|
|
51
|
+
* summary (both in this file / `runtime-turn.ts`).
|
|
52
|
+
*
|
|
53
|
+
* Two call sites intentionally test the COMPLEMENT (a truly clean result,
|
|
54
|
+
* no counted failure AND no error) rather than this predicate, and are not
|
|
55
|
+
* a missed fourth spelling: `runtime-turn.ts`'s `cleanFiles` filter
|
|
56
|
+
* (`--lens-guard`'s clear-blocker list) and `testResultToProjectDiagnostics`'s
|
|
57
|
+
* own early "nothing to report" return. Both need "genuinely clean", which
|
|
58
|
+
* `!isRunnerErrorResult(result)` cannot express (it is also true for a
|
|
59
|
+
* counted failure).
|
|
60
|
+
*/
|
|
61
|
+
export function isRunnerErrorResult(result) {
|
|
62
|
+
return result.failed === 0 && !!result.error;
|
|
63
|
+
}
|
|
26
64
|
// Source file → test file patterns (reverse lookup)
|
|
27
65
|
const SOURCE_TO_TEST_PATTERNS = [
|
|
28
66
|
{
|
|
@@ -70,6 +108,57 @@ const MAX_NODE_MODULES_WALK_UP = 5;
|
|
|
70
108
|
// test type rather than mirroring source layout) — capped depth, never an
|
|
71
109
|
// unbounded walk of the whole tests tree.
|
|
72
110
|
const MAX_PYTEST_RECURSE_DEPTH = 3;
|
|
111
|
+
/**
|
|
112
|
+
* #2522: built-in exclusion list for the turn-end auto-fired test selection.
|
|
113
|
+
*
|
|
114
|
+
* `getTestRunTarget`'s three strategies (failed-first / related / self) will
|
|
115
|
+
* happily resolve to ANY test file on disk, including integration/e2e suites
|
|
116
|
+
* that spawn external processes. A plegma dogfooding turn resolved
|
|
117
|
+
* `tests/integration/opencode-delegate.test.ts` this way — it spawns
|
|
118
|
+
* `opencode` and needs a configured provider, so on a box without one it took
|
|
119
|
+
* 17s to fail and was reported to the agent as "3/3 failed, fix before
|
|
120
|
+
* proceeding" on an unrelated model-switch turn (#2522, refs #2504/#2509).
|
|
121
|
+
*
|
|
122
|
+
* One hard-coded list, no per-project config knob (maintainer decision
|
|
123
|
+
* 2026-09-03) — this is a safety bound on what turn_end may auto-fire, not a
|
|
124
|
+
* project preference. Documented in AGENTS.md and docs/. Matched against the
|
|
125
|
+
* resolved test file's project-relative, POSIX-folded path so it applies
|
|
126
|
+
* uniformly to whichever strategy produced the target.
|
|
127
|
+
*/
|
|
128
|
+
export const TURN_END_EXCLUDED_TEST_GLOBS = [
|
|
129
|
+
"**/integration/**",
|
|
130
|
+
"**/e2e/**",
|
|
131
|
+
"**/*.integration.*",
|
|
132
|
+
"**/*.e2e.*",
|
|
133
|
+
];
|
|
134
|
+
/**
|
|
135
|
+
* Whether a resolved test target falls under the built-in turn-end
|
|
136
|
+
* exclusion list (#2522). `testFilePath` may be absolute or relative, and
|
|
137
|
+
* may use either path-separator form — folded through `toPosix` after being
|
|
138
|
+
* made cwd-relative so `\`- and `/`-separated inputs match identically
|
|
139
|
+
* (AGENTS.md cross-form-path screen).
|
|
140
|
+
*/
|
|
141
|
+
export function isExcludedTestTarget(testFilePath, cwd) {
|
|
142
|
+
const rel = toPosix(path.relative(cwd, path.resolve(cwd, testFilePath)));
|
|
143
|
+
// #2522 review round 2, F6: a target that resolves OUTSIDE the project root
|
|
144
|
+
// yields a `..`-leading relative path (or, across Windows drives, a still
|
|
145
|
+
// absolute one), which matches none of the globs — so the bare `some()`
|
|
146
|
+
// below reported it as "not excluded" and turn_end would have auto-spawned a
|
|
147
|
+
// runner against a file outside the project the turn is running in. An
|
|
148
|
+
// out-of-tree target, and the project root itself, fail CLOSED.
|
|
149
|
+
if (rel === "" ||
|
|
150
|
+
rel === ".." ||
|
|
151
|
+
rel.startsWith("../") ||
|
|
152
|
+
path.isAbsolute(rel))
|
|
153
|
+
return true;
|
|
154
|
+
// #2522 review round 2, F5: case-INSENSITIVE. `tests/Integration/`,
|
|
155
|
+
// `tests/E2E/` and `foo.E2E.test.ts` are the same hazard as their lowercase
|
|
156
|
+
// spellings, and on the case-insensitive filesystems Windows and macOS ship
|
|
157
|
+
// by default they are literally the same files — so a case-sensitive match
|
|
158
|
+
// made the SAME repo excluded on one box and unbounded on another. A safety
|
|
159
|
+
// bound a capital letter defeats is not a bound.
|
|
160
|
+
return TURN_END_EXCLUDED_TEST_GLOBS.some((glob) => minimatch(rel, glob, { dot: true, nocase: true }));
|
|
161
|
+
}
|
|
73
162
|
// --- Runner Detection ---
|
|
74
163
|
export const RUNNERS = {
|
|
75
164
|
vitest: {
|
|
@@ -223,7 +312,7 @@ function canonicalProjectRoot(cwd) {
|
|
|
223
312
|
return { key: normalizeEphemeralMapKey(absolute), resolved: false };
|
|
224
313
|
}
|
|
225
314
|
}
|
|
226
|
-
const MAX_CANONICAL_ROOT_MEMO_ENTRIES = 512;
|
|
315
|
+
export const MAX_CANONICAL_ROOT_MEMO_ENTRIES = 512;
|
|
227
316
|
function filesystemErrorCode(error) {
|
|
228
317
|
if (error !== null &&
|
|
229
318
|
typeof error === "object" &&
|
|
@@ -233,6 +322,50 @@ function filesystemErrorCode(error) {
|
|
|
233
322
|
}
|
|
234
323
|
return undefined;
|
|
235
324
|
}
|
|
325
|
+
const PYTEST_SUMMARY_OUTCOME = "(?:passed|failed|skipped|reruns?|errors?|warnings?|deselected|xfailed|xpassed)";
|
|
326
|
+
const PYTEST_SUMMARY_LINE = new RegExp(`^\\s*(?:=+\\s*)?\\d+\\s+${PYTEST_SUMMARY_OUTCOME}` +
|
|
327
|
+
`(?:\\s*,\\s*\\d+\\s+${PYTEST_SUMMARY_OUTCOME})*` +
|
|
328
|
+
`\\s+in\\s+[\\d.]+s(?:\\s*=+)?\\s*$`, "i");
|
|
329
|
+
/** Extract aggregate values from pytest's final outcome line only. */
|
|
330
|
+
function parsePytestSummary(output) {
|
|
331
|
+
// Pytest may color the whole summary or individual tokens. Strip ANSI before
|
|
332
|
+
// selecting and extracting so formatting cannot turn the first count into 0.
|
|
333
|
+
const normalizedOutput = stripAnsi(output);
|
|
334
|
+
const summaryLine = normalizedOutput
|
|
335
|
+
.split(/\r?\n/)
|
|
336
|
+
.reverse()
|
|
337
|
+
.find((line) => PYTEST_SUMMARY_LINE.test(line));
|
|
338
|
+
let passed = 0;
|
|
339
|
+
let failed = 0;
|
|
340
|
+
let skipped = 0;
|
|
341
|
+
if (!summaryLine)
|
|
342
|
+
return { passed, failed, skipped };
|
|
343
|
+
const summaryBody = summaryLine.replace(/^=+\s*|\s*=+\s*$/g, "");
|
|
344
|
+
for (const field of summaryBody.split(",")) {
|
|
345
|
+
const [countText, outcome] = field.trim().split(/\s+/, 2);
|
|
346
|
+
const count = Number.parseInt(countText, 10);
|
|
347
|
+
if (!Number.isFinite(count))
|
|
348
|
+
continue;
|
|
349
|
+
switch (outcome) {
|
|
350
|
+
case "passed":
|
|
351
|
+
passed = count;
|
|
352
|
+
break;
|
|
353
|
+
case "failed":
|
|
354
|
+
failed = count;
|
|
355
|
+
break;
|
|
356
|
+
case "skipped":
|
|
357
|
+
skipped = count;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const durationMatch = /in\s+([\d.]+)s/.exec(summaryLine);
|
|
362
|
+
// Rounded, like `jsonRunDurationMs` and PHPUnit's legacy path:
|
|
363
|
+
// `in 2.01s` is 2009.9999999999998 in binary floating point.
|
|
364
|
+
const duration = durationMatch
|
|
365
|
+
? Math.round(Number.parseFloat(durationMatch[1]) * 1000)
|
|
366
|
+
: undefined;
|
|
367
|
+
return { passed, failed, skipped, duration };
|
|
368
|
+
}
|
|
236
369
|
export class TestRunnerClient {
|
|
237
370
|
log;
|
|
238
371
|
// This is an instance-lifetime memo of RESOLVED spellings only, which leaves
|
|
@@ -247,7 +380,7 @@ export class TestRunnerClient {
|
|
|
247
380
|
// resolve — a state where `detectRunner` already walks node_modules on every
|
|
248
381
|
// call. Keep the memo bounded so pathological spelling churn cannot grow it
|
|
249
382
|
// without limit.
|
|
250
|
-
canonicalRootMemo = new
|
|
383
|
+
canonicalRootMemo = new BoundedFifoMap(MAX_CANONICAL_ROOT_MEMO_ENTRIES);
|
|
251
384
|
availableRunners = new PathKeyedMap(normalizeEphemeralMapKey);
|
|
252
385
|
failedTestsByRunner = new Map();
|
|
253
386
|
failedTargetSequence = 0;
|
|
@@ -271,14 +404,13 @@ export class TestRunnerClient {
|
|
|
271
404
|
const { key, resolved } = canonicalProjectRoot(cwd);
|
|
272
405
|
if (!resolved)
|
|
273
406
|
return key;
|
|
274
|
-
if (this.canonicalRootMemo.size >= MAX_CANONICAL_ROOT_MEMO_ENTRIES) {
|
|
275
|
-
const oldest = this.canonicalRootMemo.keys().next().value;
|
|
276
|
-
if (oldest !== undefined)
|
|
277
|
-
this.canonicalRootMemo.delete(oldest);
|
|
278
|
-
}
|
|
279
407
|
this.canonicalRootMemo.set(cwd, key);
|
|
280
408
|
return key;
|
|
281
409
|
}
|
|
410
|
+
/** #2442 test-only: exercise canonicalRootMemo's bounded eviction directly. */
|
|
411
|
+
_getCanonicalProjectRootForTests(cwd) {
|
|
412
|
+
return this.getCanonicalProjectRoot(cwd);
|
|
413
|
+
}
|
|
282
414
|
getRunnerAvailability(byRunner, runner) {
|
|
283
415
|
const cached = byRunner?.get(runner);
|
|
284
416
|
if (!cached)
|
|
@@ -904,16 +1036,20 @@ export class TestRunnerClient {
|
|
|
904
1036
|
else {
|
|
905
1037
|
request = runnerOrRequest;
|
|
906
1038
|
}
|
|
907
|
-
const { runner, config, turnIndex } = request;
|
|
1039
|
+
const { runner, config, turnIndex, signal } = request;
|
|
908
1040
|
if (!fs.existsSync(absoluteTestFile)) {
|
|
909
1041
|
return this.emptyResult(absoluteTestFile, "", runner, "Test file not found");
|
|
910
1042
|
}
|
|
911
1043
|
try {
|
|
912
|
-
const { command, args } = await this.resolveExec(runner, config, absoluteTestFile, cwd);
|
|
1044
|
+
const { command, args, env } = await this.resolveExec(runner, config, absoluteTestFile, cwd);
|
|
913
1045
|
this.log(`Running (async): ${command} ${args.join(" ")}`);
|
|
914
1046
|
const result = await safeSpawnAsync(command, args, {
|
|
915
1047
|
cwd,
|
|
916
1048
|
timeout: 60000,
|
|
1049
|
+
env,
|
|
1050
|
+
// #2522 R2 F1. `safeSpawnAsync` resolves `options.signal ?? ambient`,
|
|
1051
|
+
// so an absent batch signal keeps the pre-#2522 ambient behaviour.
|
|
1052
|
+
signal,
|
|
917
1053
|
});
|
|
918
1054
|
const stdout = result.stdout || "";
|
|
919
1055
|
const stderr = result.stderr || "";
|
|
@@ -1273,31 +1409,9 @@ export class TestRunnerClient {
|
|
|
1273
1409
|
parsePytestOutput(stdout, stderr, exitCode, testFile, _cwd, runner) {
|
|
1274
1410
|
const failures = [];
|
|
1275
1411
|
const output = `${stdout}\n${stderr}`;
|
|
1276
|
-
//
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
let passed = 0;
|
|
1280
|
-
let failed = 0;
|
|
1281
|
-
let skipped = 0;
|
|
1282
|
-
// #1479: undefined until pytest's own `in N.NNs` is read. `in 0.00s` is
|
|
1283
|
-
// a real pytest summary, so 0 has to stay available as a measurement.
|
|
1284
|
-
let duration;
|
|
1285
|
-
if (summaryMatch) {
|
|
1286
|
-
// Extract numbers from various patterns
|
|
1287
|
-
const passedMatch = output.match(/(\d+)\s+passed/);
|
|
1288
|
-
const failedMatch = output.match(/(\d+)\s+failed/);
|
|
1289
|
-
const skippedMatch = output.match(/(\d+)\s+skipped/);
|
|
1290
|
-
const durationMatch = output.match(/in\s+([\d.]+)s/);
|
|
1291
|
-
passed = passedMatch ? parseInt(passedMatch[1], 10) : 0;
|
|
1292
|
-
failed = failedMatch ? parseInt(failedMatch[1], 10) : 0;
|
|
1293
|
-
skipped = skippedMatch ? parseInt(skippedMatch[1], 10) : 0;
|
|
1294
|
-
// Rounded, like `jsonRunDurationMs` and PHPUnit's legacy path:
|
|
1295
|
-
// `in 2.01s` is 2009.9999999999998 in binary floating point, and
|
|
1296
|
-
// the turn-end log prints the number as it stands.
|
|
1297
|
-
// (Routing this through `toMeasuredDurationMs` is #1484, not this.)
|
|
1298
|
-
if (durationMatch)
|
|
1299
|
-
duration = Math.round(parseFloat(durationMatch[1]) * 1000);
|
|
1300
|
-
}
|
|
1412
|
+
// #1479: `duration` stays undefined unless pytest emits its own `in N.NNs`
|
|
1413
|
+
// summary. A measured `in 0.00s` remains a real zero.
|
|
1414
|
+
const { passed, failed, skipped, duration } = parsePytestSummary(output);
|
|
1301
1415
|
// Parse individual failures: "FAILED tests/test_foo.py::test_something - AssertionError: ..."
|
|
1302
1416
|
const failureRegex = /FAILED\s+(\S+::\S+)\s*-\s*(.+?)(?:\n|$)/g;
|
|
1303
1417
|
let match;
|
|
@@ -1325,7 +1439,11 @@ export class TestRunnerClient {
|
|
|
1325
1439
|
skipped,
|
|
1326
1440
|
failures,
|
|
1327
1441
|
duration,
|
|
1328
|
-
error: exitCode ===
|
|
1442
|
+
error: exitCode === 4
|
|
1443
|
+
? "Pytest configuration error"
|
|
1444
|
+
: exitCode === 2
|
|
1445
|
+
? "Pytest interrupted"
|
|
1446
|
+
: undefined,
|
|
1329
1447
|
};
|
|
1330
1448
|
}
|
|
1331
1449
|
// --- PHPUnit Parser (text-based, default CLI output) ---
|
|
@@ -1961,9 +2079,15 @@ export class TestRunnerClient {
|
|
|
1961
2079
|
* Format test result for LLM consumption
|
|
1962
2080
|
*/
|
|
1963
2081
|
formatResult(result) {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2082
|
+
// #2532 review S1: folded onto `isRunnerErrorResult` instead of the old
|
|
2083
|
+
// local `error && passed === 0 && failed === 0` spelling — that missed a
|
|
2084
|
+
// runner error reported alongside partial passes (pytest `Interrupted`
|
|
2085
|
+
// after some tests already ran clean), which fell through to the normal
|
|
2086
|
+
// "N/N passed" branch below and silently dropped the interruption.
|
|
2087
|
+
if (isRunnerErrorResult(result)) {
|
|
2088
|
+
return result.passed > 0
|
|
2089
|
+
? `[Tests] ⚠ Could not complete tests: ${result.error} (${result.passed} passed before)`
|
|
2090
|
+
: `[Tests] ⚠ Could not run tests: ${result.error}`;
|
|
1967
2091
|
}
|
|
1968
2092
|
const total = result.passed + result.failed + result.skipped;
|
|
1969
2093
|
if (total === 0) {
|
|
@@ -2094,6 +2218,19 @@ export class TestRunnerClient {
|
|
|
2094
2218
|
* runners like vitest/jest/pytest).
|
|
2095
2219
|
*/
|
|
2096
2220
|
async resolveExec(runner, config, testFile, cwd) {
|
|
2221
|
+
// Run pytest through the project interpreter itself, not a generic `python`
|
|
2222
|
+
// resolved from the host PATH. The child-only environment also keeps tools
|
|
2223
|
+
// spawned by tests inside the same project environment.
|
|
2224
|
+
if (runner === "pytest") {
|
|
2225
|
+
const pythonEnvironment = await detectPythonEnvironment(cwd);
|
|
2226
|
+
if (pythonEnvironment) {
|
|
2227
|
+
return {
|
|
2228
|
+
command: pythonEnvironment.pythonPath,
|
|
2229
|
+
args: config.args(testFile, cwd),
|
|
2230
|
+
env: augmentPythonEnvironment(process.env, pythonEnvironment),
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2097
2234
|
// PHPUnit has no npx-style automatic local-binary resolution — Composer's
|
|
2098
2235
|
// standard local-install location is vendor/bin/phpunit, so check that
|
|
2099
2236
|
// explicitly before falling back to a global `phpunit` on PATH.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic test-runner delivery for the post-agent idle window (#2366).
|
|
3
|
+
*
|
|
4
|
+
* Test results remain in `test-runner-findings` for pull diagnostics and the
|
|
5
|
+
* commit guard. This module only stages an owner-qualified pointer and
|
|
6
|
+
* appends a non-context custom entry after the host proves that the agent is
|
|
7
|
+
* idle. Provenance validation stays in `peekTestFindings`, the one shared
|
|
8
|
+
* delivery gate for this cache.
|
|
9
|
+
*/
|
|
10
|
+
import { emitBounded } from "./bounded-telemetry.js";
|
|
11
|
+
import { peekTestFindings } from "./runtime-context.js";
|
|
12
|
+
import { fitLines } from "./tui-fit.js";
|
|
13
|
+
export const TEST_RUNNER_ENTRY_TYPE = "pilens:test-runner-findings";
|
|
14
|
+
const MAX_PENDING_DELIVERIES = 32;
|
|
15
|
+
const MAX_ENTRY_CONTENT = 12_000;
|
|
16
|
+
const pending = new Map();
|
|
17
|
+
function key(cwd, sessionId, ownerId) {
|
|
18
|
+
// `cwd` comes from the same host session field at turn_end and settle. Keep
|
|
19
|
+
// that canonical value unchanged so cache reads use the identical workspace
|
|
20
|
+
// identity; dispatch contexts already normalize their own path fields.
|
|
21
|
+
return `${ownerId ?? "direct"}\u0000${cwd}\u0000${sessionId}`;
|
|
22
|
+
}
|
|
23
|
+
function boundedContent(content) {
|
|
24
|
+
if (content.length <= MAX_ENTRY_CONTENT)
|
|
25
|
+
return { content, droppedDetailCount: 0 };
|
|
26
|
+
return {
|
|
27
|
+
content: `${content.slice(0, MAX_ENTRY_CONTENT)}\n[…details truncated]`,
|
|
28
|
+
droppedDetailCount: content.length - MAX_ENTRY_CONTENT,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function record(identity, outcome, delivery, metadata = {}) {
|
|
32
|
+
emitBounded("test_runner_delivery", identity, {
|
|
33
|
+
filePath: delivery.cwd,
|
|
34
|
+
durationMs: 0,
|
|
35
|
+
metadata: {
|
|
36
|
+
outcome,
|
|
37
|
+
sessionId: delivery.sessionId,
|
|
38
|
+
generation: delivery.generation,
|
|
39
|
+
targetCount: delivery.targetCount,
|
|
40
|
+
deliveryBoundary: "agent_settled",
|
|
41
|
+
ownership: "pi",
|
|
42
|
+
droppedDetailCount: 0,
|
|
43
|
+
...metadata,
|
|
44
|
+
},
|
|
45
|
+
}, {
|
|
46
|
+
capPerTurn: { limit: 8, turnIndex: delivery.generation },
|
|
47
|
+
ledgerKind: outcome === "delivery-failed" || outcome === "capability-unavailable"
|
|
48
|
+
? "test-runner-delivery"
|
|
49
|
+
: undefined,
|
|
50
|
+
reason: `test runner delivery ${outcome}`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function prunePending() {
|
|
54
|
+
while (pending.size > MAX_PENDING_DELIVERIES) {
|
|
55
|
+
const oldest = pending.keys().next();
|
|
56
|
+
if (oldest.done)
|
|
57
|
+
return;
|
|
58
|
+
pending.delete(oldest.value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Stage the newest result for this session. Clean results supersede failures. */
|
|
62
|
+
export function stageTestRunnerDelivery(args) {
|
|
63
|
+
const deliveryKey = key(args.cwd, args.sessionId, args.owner?.ownerId);
|
|
64
|
+
const prior = pending.get(deliveryKey);
|
|
65
|
+
if (prior && prior.generation > args.generation) {
|
|
66
|
+
const superseded = {
|
|
67
|
+
cwd: args.cwd,
|
|
68
|
+
sessionId: args.sessionId,
|
|
69
|
+
ownerId: args.owner?.ownerId,
|
|
70
|
+
generation: args.generation,
|
|
71
|
+
targetCount: args.targetCount,
|
|
72
|
+
createdAt: Date.now(),
|
|
73
|
+
owner: args.owner,
|
|
74
|
+
};
|
|
75
|
+
record(deliveryKey, "superseded", superseded, {
|
|
76
|
+
currentGeneration: prior.generation,
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (!args.hasFindings) {
|
|
81
|
+
if (prior) {
|
|
82
|
+
pending.delete(deliveryKey);
|
|
83
|
+
record(deliveryKey, "superseded", {
|
|
84
|
+
...prior,
|
|
85
|
+
targetCount: args.targetCount,
|
|
86
|
+
generation: args.generation,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const delivery = {
|
|
92
|
+
cwd: args.cwd,
|
|
93
|
+
sessionId: args.sessionId,
|
|
94
|
+
ownerId: args.owner?.ownerId,
|
|
95
|
+
generation: args.generation,
|
|
96
|
+
targetCount: args.targetCount,
|
|
97
|
+
createdAt: Date.now(),
|
|
98
|
+
owner: args.owner,
|
|
99
|
+
};
|
|
100
|
+
pending.set(deliveryKey, delivery);
|
|
101
|
+
prunePending();
|
|
102
|
+
record(deliveryKey, "staged", delivery);
|
|
103
|
+
}
|
|
104
|
+
/** Deliver the latest staged result during a host-confirmed idle window. */
|
|
105
|
+
export function deliverTestRunnerFindings(args) {
|
|
106
|
+
const cwd = args.ctx.cwd ?? process.cwd();
|
|
107
|
+
const deliveryKey = key(cwd, args.sessionId, args.ownerId);
|
|
108
|
+
const delivery = pending.get(deliveryKey);
|
|
109
|
+
if (!delivery)
|
|
110
|
+
return;
|
|
111
|
+
const currentGeneration = args.cacheManager.readCache("test-runner-findings", cwd)?.data?.testRunGeneration;
|
|
112
|
+
if (currentGeneration !== undefined &&
|
|
113
|
+
currentGeneration > delivery.generation) {
|
|
114
|
+
pending.delete(deliveryKey);
|
|
115
|
+
record(deliveryKey, "superseded", delivery, {
|
|
116
|
+
currentGeneration,
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (typeof args.ctx.isIdle !== "function") {
|
|
121
|
+
pending.delete(deliveryKey);
|
|
122
|
+
record(deliveryKey, "capability-unavailable", delivery, {
|
|
123
|
+
reason: "host does not expose ctx.isIdle",
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
if (!args.ctx.isIdle()) {
|
|
129
|
+
record(deliveryKey, "carried", delivery);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
record(deliveryKey, "delivery-failed", delivery, {
|
|
135
|
+
error: String(error).slice(0, 500),
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const findings = peekTestFindings(args.cacheManager, cwd, args.runtime, true);
|
|
140
|
+
if (!findings) {
|
|
141
|
+
pending.delete(deliveryKey);
|
|
142
|
+
record(deliveryKey, "superseded", delivery);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Recheck immediately before append. The host may accept a prompt between
|
|
146
|
+
// the first check and this synchronous call.
|
|
147
|
+
try {
|
|
148
|
+
if (!args.ctx.isIdle()) {
|
|
149
|
+
record(deliveryKey, "carried", delivery);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
record(deliveryKey, "delivery-failed", delivery, {
|
|
155
|
+
error: String(error).slice(0, 500),
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// SAFETY: appendEntry is an optional host capability absent from older Pi SDKs.
|
|
160
|
+
const appendEntry = args.pi.appendEntry;
|
|
161
|
+
if (typeof appendEntry !== "function") {
|
|
162
|
+
pending.delete(deliveryKey);
|
|
163
|
+
record(deliveryKey, "capability-unavailable", delivery);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const bounded = boundedContent(findings.messages[0]?.content ?? "");
|
|
167
|
+
try {
|
|
168
|
+
appendEntry.call(args.pi, TEST_RUNNER_ENTRY_TYPE, {
|
|
169
|
+
...bounded,
|
|
170
|
+
sessionId: delivery.sessionId,
|
|
171
|
+
generation: delivery.generation,
|
|
172
|
+
targetCount: delivery.targetCount,
|
|
173
|
+
});
|
|
174
|
+
pending.delete(deliveryKey);
|
|
175
|
+
record(deliveryKey, "delivered", delivery, {
|
|
176
|
+
droppedDetailCount: bounded.droppedDetailCount,
|
|
177
|
+
ageMs: Math.max(0, Date.now() - delivery.createdAt),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
record(deliveryKey, "delivery-failed", delivery, {
|
|
182
|
+
error: String(error).slice(0, 500),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** Deliver only the result staged by this activation and settled session. */
|
|
187
|
+
export function deliverStagedTestRunnerFindings(args) {
|
|
188
|
+
if (!args?.cwd || !args.ownerId)
|
|
189
|
+
return;
|
|
190
|
+
const delivery = args.sessionId
|
|
191
|
+
? pending.get(key(args.cwd, args.sessionId, args.ownerId))
|
|
192
|
+
: [...pending.values()]
|
|
193
|
+
.reverse()
|
|
194
|
+
.find((candidate) => candidate.cwd === args.cwd && candidate.ownerId === args.ownerId);
|
|
195
|
+
if (!delivery?.owner)
|
|
196
|
+
return;
|
|
197
|
+
deliverTestRunnerFindings({
|
|
198
|
+
pi: delivery.owner.pi,
|
|
199
|
+
ctx: delivery.owner.getCtx(),
|
|
200
|
+
cacheManager: delivery.owner.cacheManager,
|
|
201
|
+
runtime: delivery.owner.runtime,
|
|
202
|
+
sessionId: delivery.sessionId,
|
|
203
|
+
ownerId: delivery.ownerId,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
export function registerTestRunnerEntryRenderer(pi) {
|
|
207
|
+
// SAFETY: registerEntryRenderer is an optional host capability absent from older Pi SDKs.
|
|
208
|
+
const register = pi.registerEntryRenderer;
|
|
209
|
+
if (typeof register !== "function")
|
|
210
|
+
return false;
|
|
211
|
+
try {
|
|
212
|
+
register.call(pi, TEST_RUNNER_ENTRY_TYPE, renderTestRunnerEntry);
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function renderTestRunnerEntry(entry, _options, theme) {
|
|
220
|
+
const content = entry.data?.content;
|
|
221
|
+
if (typeof content !== "string")
|
|
222
|
+
return undefined;
|
|
223
|
+
const lines = [
|
|
224
|
+
theme.fg("error", "pi-lens test failures"),
|
|
225
|
+
...content.split("\n"),
|
|
226
|
+
];
|
|
227
|
+
return {
|
|
228
|
+
render: (width) => fitLines(lines, width),
|
|
229
|
+
invalidate: () => { },
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** Test-only reset; session ownership prevents cross-session consumption. */
|
|
233
|
+
export function _resetTestRunnerDeliveryForTests() {
|
|
234
|
+
pending.clear();
|
|
235
|
+
}
|
|
236
|
+
/** Clear staged results when a primary session replaces the owning runtime. */
|
|
237
|
+
export function resetTestRunnerDelivery() {
|
|
238
|
+
pending.clear();
|
|
239
|
+
}
|
|
@@ -1,7 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE final registration boundary for a host-facing tool: everything that
|
|
3
|
+
* must be true of a tool definition the instant before `pi.registerTool`
|
|
4
|
+
* sees it. `index.ts` runs every tool it registers — always-active,
|
|
5
|
+
* situational, and the compact-line-wrapped variants — through this one
|
|
6
|
+
* function, so a property added here reaches every tool without a second
|
|
7
|
+
* call site to keep in sync.
|
|
8
|
+
*
|
|
9
|
+
* Two jobs today:
|
|
10
|
+
* 1. metadata the host requires is present (a non-empty description);
|
|
11
|
+
* 2. an in-flight tool call HOLDS the event loop (#2507). pi-lens unrefs the
|
|
12
|
+
* LSP child, its stdio pipes and several waiting timers so an idle
|
|
13
|
+
* one-shot process can exit; in a headless child with no other referenced
|
|
14
|
+
* handle that let Node exit 0 in the middle of `lsp_diagnostics`. Every
|
|
15
|
+
* tool call therefore takes a counted hold for its own duration — see
|
|
16
|
+
* `clients/event-loop-hold.ts` for why the hold lives there and not in
|
|
17
|
+
* the unref itself.
|
|
18
|
+
*/
|
|
19
|
+
import { acquireEventLoopHold } from "./event-loop-hold.js";
|
|
1
20
|
export function normalizeToolDefinition(tool) {
|
|
2
21
|
const name = typeof tool.name === "string" ? tool.name.trim() : "tool";
|
|
3
22
|
const description = typeof tool.description === "string" && tool.description.trim().length > 0
|
|
4
23
|
? tool.description
|
|
5
24
|
: `Use the ${name} tool.`;
|
|
6
|
-
|
|
25
|
+
const execute = tool.execute;
|
|
26
|
+
if (typeof execute !== "function") {
|
|
27
|
+
return { ...tool, description };
|
|
28
|
+
}
|
|
29
|
+
const inner = execute;
|
|
30
|
+
return {
|
|
31
|
+
...tool,
|
|
32
|
+
description,
|
|
33
|
+
// A plain function, not an arrow: `this` stays whatever the host called
|
|
34
|
+
// the tool with, so a definition whose `execute` reads `this` keeps
|
|
35
|
+
// working. The hold is released in `finally`, so a rejected or aborted
|
|
36
|
+
// call releases exactly like a resolved one.
|
|
37
|
+
execute: async function (...args) {
|
|
38
|
+
const release = acquireEventLoopHold(name);
|
|
39
|
+
try {
|
|
40
|
+
return await inner.apply(this, args);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
release();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
7
47
|
}
|