@herbertgao/pi-extensions 2026.8.5 → 2026.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +19 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +30 -9
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +272 -22
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +74 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +94 -77
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +48 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/message-display.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/hover.ts +14 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +55 -17
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/layout.ts +41 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-renderer.ts +75 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/types.ts +7 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +64 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +16 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +30 -22
- package/node_modules/@herbertgao/pi-subagents/examples/agent-tool-description.md +5 -5
- package/node_modules/@herbertgao/pi-subagents/package.json +7 -7
- package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +7 -1
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +48 -19
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +22 -15
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +26 -2
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +219 -40
- package/node_modules/@herbertgao/pi-subagents/src/invocation-config.ts +101 -3
- package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +18 -4
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +99 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +22 -3
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +51 -3
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +20 -2
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +34 -10
- package/node_modules/@herbertgao/pi-subagents/src/usage.ts +129 -1
- package/node_modules/@herbertgao/pi-subagents/src/worktree.ts +29 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +3 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +46 -10
- package/node_modules/@juicesharp/rpiv-ask-user-question/config.ts +25 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +13 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +8 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/localization.md +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +3 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +10 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +30 -7
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +14 -6
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +30 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +26 -5
- package/node_modules/@narumitw/pi-btw/README.md +119 -103
- package/node_modules/@narumitw/pi-btw/dist/index.ts +2898 -0
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +7 -0
- package/node_modules/@narumitw/pi-btw/package.json +13 -9
- package/node_modules/@narumitw/pi-btw/src/btw.ts +40 -42
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +55 -10
- package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +390 -0
- package/node_modules/@narumitw/pi-btw/src/menu.ts +78 -15
- package/node_modules/@narumitw/pi-btw/src/settings.ts +22 -2
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +136 -45
- package/node_modules/pi-lens/CHANGELOG.md +1004 -0
- package/node_modules/pi-lens/README.md +11 -3
- package/node_modules/pi-lens/config/ruff/core.toml +42 -0
- package/node_modules/pi-lens/dist/clients/actionable-warnings.js +130 -27
- package/node_modules/pi-lens/dist/clients/advisory-provenance.js +427 -0
- package/node_modules/pi-lens/dist/clients/agent-nudge.js +79 -16
- package/node_modules/pi-lens/dist/clients/ast-grep-client.js +9 -3
- package/node_modules/pi-lens/dist/clients/atomic-write.js +9 -3
- package/node_modules/pi-lens/dist/clients/bash-file-access.js +285 -8
- package/node_modules/pi-lens/dist/clients/biome-client.js +176 -37
- package/node_modules/pi-lens/dist/clients/blocker-freshness.js +428 -0
- package/node_modules/pi-lens/dist/clients/blocker-past-eof.js +119 -0
- package/node_modules/pi-lens/dist/clients/bootstrap.js +12 -1
- package/node_modules/pi-lens/dist/clients/bounded-pid-file-lock.js +12 -3
- package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +192 -0
- package/node_modules/pi-lens/dist/clients/bus-events-logger.js +62 -6
- package/node_modules/pi-lens/dist/clients/bus-publish.js +11 -3
- package/node_modules/pi-lens/dist/clients/cascade-budget.js +196 -0
- package/node_modules/pi-lens/dist/clients/cascade-format.js +76 -2
- package/node_modules/pi-lens/dist/clients/cascade-types.js +9 -1
- package/node_modules/pi-lens/dist/clients/child-unref.js +54 -6
- package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +76 -24
- package/node_modules/pi-lens/dist/clients/console-guard-install.js +16 -4
- package/node_modules/pi-lens/dist/clients/dead-code-client.js +249 -52
- package/node_modules/pi-lens/dist/clients/deadline-utils.js +8 -1
- package/node_modules/pi-lens/dist/clients/debug-handles.js +5 -0
- package/node_modules/pi-lens/dist/clients/degradation-ledger.js +62 -13
- package/node_modules/pi-lens/dist/clients/dependency-checker.js +43 -9
- package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +153 -37
- package/node_modules/pi-lens/dist/clients/diagnostic-line-freshness.js +298 -0
- package/node_modules/pi-lens/dist/clients/diagnostics-publish.js +10 -3
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +165 -11
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +325 -72
- package/node_modules/pi-lens/dist/clients/dispatch/lazy.js +7 -4
- package/node_modules/pi-lens/dist/clients/dispatch/plan.js +5 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +234 -18
- package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +187 -19
- package/node_modules/pi-lens/dist/clients/dispatch/runners/cpp-check.js +6 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/credo.js +11 -9
- package/node_modules/pi-lens/dist/clients/dispatch/runners/cue-vet.js +398 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/elixir-check.js +11 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/eslint.js +12 -7
- package/node_modules/pi-lens/dist/clients/dispatch/runners/go-vet.js +18 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-render.js +895 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/index.js +4 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/javac.js +16 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +81 -41
- package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +16 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/mypy.js +23 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +331 -55
- package/node_modules/pi-lens/dist/clients/dispatch/runners/pyright.js +38 -5
- package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +97 -19
- package/node_modules/pi-lens/dist/clients/dispatch/runners/spellcheck.js +14 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/sqlfluff.js +20 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/stylelint.js +22 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/swiftlint.js +10 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/taplo.js +18 -6
- package/node_modules/pi-lens/dist/clients/dispatch/runners/trivy-config.js +73 -12
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/availability-policy.js +488 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +84 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/lazy-installer.js +260 -27
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +943 -93
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +86 -11
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/tool-failure.js +72 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +106 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/vale.js +9 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yamllint.js +18 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/zig-check.js +4 -2
- package/node_modules/pi-lens/dist/clients/disposition-publish.js +10 -3
- package/node_modules/pi-lens/dist/clients/eval-timestamp.js +17 -0
- package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +28 -5
- package/node_modules/pi-lens/dist/clients/extension-log.js +317 -3
- package/node_modules/pi-lens/dist/clients/file-kinds.js +8 -2
- package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +294 -0
- package/node_modules/pi-lens/dist/clients/finding-identity.js +88 -0
- package/node_modules/pi-lens/dist/clients/fix-worklog.js +5 -1
- package/node_modules/pi-lens/dist/clients/format-events-publish.js +39 -8
- package/node_modules/pi-lens/dist/clients/formatters-lazy.js +3 -2
- package/node_modules/pi-lens/dist/clients/formatters.js +500 -115
- package/node_modules/pi-lens/dist/clients/generation-guard.js +216 -0
- package/node_modules/pi-lens/dist/clients/git-guard.js +49 -21
- package/node_modules/pi-lens/dist/clients/gitleaks-client.js +181 -8
- package/node_modules/pi-lens/dist/clients/go-client.js +21 -39
- package/node_modules/pi-lens/dist/clients/govulncheck-client.js +219 -10
- package/node_modules/pi-lens/dist/clients/grammar-source.js +333 -10
- package/node_modules/pi-lens/dist/clients/host-ports.js +9 -1
- package/node_modules/pi-lens/dist/clients/installer/index.js +1119 -101
- package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh-session.js +58 -0
- package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh.js +715 -0
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +643 -97
- package/node_modules/pi-lens/dist/clients/instance-registry.js +87 -17
- package/node_modules/pi-lens/dist/clients/jscpd-client.js +86 -15
- package/node_modules/pi-lens/dist/clients/knip-client.js +361 -24
- package/node_modules/pi-lens/dist/clients/language-policy.js +8 -2
- package/node_modules/pi-lens/dist/clients/language-profile.js +2 -0
- package/node_modules/pi-lens/dist/clients/latency-logger.js +487 -9
- package/node_modules/pi-lens/dist/clients/lazy-import.js +21 -0
- package/node_modules/pi-lens/dist/clients/ledger-bounds.js +21 -0
- package/node_modules/pi-lens/dist/clients/lens-events.js +56 -25
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +16 -0
- package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +45 -2
- package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +30 -4
- package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +160 -20
- package/node_modules/pi-lens/dist/clients/lsp/client.js +1666 -148
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +111 -0
- package/node_modules/pi-lens/dist/clients/lsp/document-drift.js +389 -0
- package/node_modules/pi-lens/dist/clients/lsp/index.js +2496 -171
- package/node_modules/pi-lens/dist/clients/lsp/inferred-project.js +215 -0
- package/node_modules/pi-lens/dist/clients/lsp/jvm-runtime.js +146 -14
- package/node_modules/pi-lens/dist/clients/lsp/language.js +48 -4
- package/node_modules/pi-lens/dist/clients/lsp/server.js +517 -69
- package/node_modules/pi-lens/dist/clients/lsp/spawn-history.js +22 -0
- package/node_modules/pi-lens/dist/clients/lsp/sync-kind.js +43 -0
- package/node_modules/pi-lens/dist/clients/lsp/tsserver-sync.js +172 -0
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/classification.js +21 -5
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/strategies.js +61 -3
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +422 -28
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-session.js +30 -0
- package/node_modules/pi-lens/dist/clients/lsp/workspace-sweep-hold.js +175 -0
- package/node_modules/pi-lens/dist/clients/lsp-lazy.js +3 -2
- package/node_modules/pi-lens/dist/clients/mcp/analyze.js +4 -0
- package/node_modules/pi-lens/dist/clients/mcp/session.js +39 -18
- package/node_modules/pi-lens/dist/clients/model-provider.js +53 -0
- package/node_modules/pi-lens/dist/clients/module-report.js +8 -0
- package/node_modules/pi-lens/dist/clients/opengrep-client.js +15 -1
- package/node_modules/pi-lens/dist/clients/package-manager.js +170 -14
- package/node_modules/pi-lens/dist/clients/path-attribution-telemetry.js +27 -0
- package/node_modules/pi-lens/dist/clients/path-utils.js +160 -0
- package/node_modules/pi-lens/dist/clients/pipeline.js +178 -30
- package/node_modules/pi-lens/dist/clients/post-autofix-notice.js +37 -0
- package/node_modules/pi-lens/dist/clients/project-diagnostics/cache.js +17 -3
- package/node_modules/pi-lens/dist/clients/project-diagnostics/extractors.js +89 -22
- package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +85 -15
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +15 -3
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +23 -2
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/trivy.js +50 -2
- package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +5 -0
- package/node_modules/pi-lens/dist/clients/project-lens-config.js +3 -0
- package/node_modules/pi-lens/dist/clients/project-snapshot.js +299 -0
- package/node_modules/pi-lens/dist/clients/quiet-window-config.js +47 -0
- package/node_modules/pi-lens/dist/clients/quiet-window.js +11 -25
- package/node_modules/pi-lens/dist/clients/read-guard-logger.js +1 -1
- package/node_modules/pi-lens/dist/clients/read-guard.js +184 -10
- package/node_modules/pi-lens/dist/clients/resource-sampler.js +49 -17
- package/node_modules/pi-lens/dist/clients/reverse-deps.js +50 -11
- package/node_modules/pi-lens/dist/clients/review-graph/query.js +76 -4
- package/node_modules/pi-lens/dist/clients/run-duration.js +55 -0
- package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +248 -13
- package/node_modules/pi-lens/dist/clients/runtime-context.js +112 -12
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +472 -61
- package/node_modules/pi-lens/dist/clients/runtime-session.js +359 -13
- package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +217 -22
- package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +269 -22
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +948 -87
- package/node_modules/pi-lens/dist/clients/rust-client.js +21 -37
- package/node_modules/pi-lens/dist/clients/safe-spawn.js +220 -7
- package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +161 -0
- package/node_modules/pi-lens/dist/clients/search-read-registration.js +34 -6
- package/node_modules/pi-lens/dist/clients/security-scan-client.js +224 -8
- package/node_modules/pi-lens/dist/clients/sg-runner.js +249 -37
- package/node_modules/pi-lens/dist/clients/single-flight.js +158 -0
- package/node_modules/pi-lens/dist/clients/smells-rollup.js +18 -11
- package/node_modules/pi-lens/dist/clients/stale-marker.js +17 -0
- package/node_modules/pi-lens/dist/clients/startup-timing.js +26 -2
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +574 -32
- package/node_modules/pi-lens/dist/clients/tool-event.js +56 -5
- package/node_modules/pi-lens/dist/clients/tool-policy.js +127 -20
- package/node_modules/pi-lens/dist/clients/tool-set-policy.js +76 -0
- package/node_modules/pi-lens/dist/clients/tree-sitter-cache.js +75 -1
- package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +769 -64
- package/node_modules/pi-lens/dist/clients/tree-sitter-shared.js +11 -0
- package/node_modules/pi-lens/dist/clients/tree-sitter-symbol-extractor.js +90 -0
- package/node_modules/pi-lens/dist/clients/trivy-client.js +19 -1
- package/node_modules/pi-lens/dist/clients/warm-attach.js +17 -0
- package/node_modules/pi-lens/dist/clients/widget-state.js +336 -36
- package/node_modules/pi-lens/dist/clients/word-index.js +305 -33
- package/node_modules/pi-lens/dist/clients/zizmor-config.js +214 -14
- package/node_modules/pi-lens/dist/index.js +64677 -49484
- package/node_modules/pi-lens/dist/mcp/server.js +8 -2
- package/node_modules/pi-lens/dist/tools/activate-tools.js +17 -5
- package/node_modules/pi-lens/dist/tools/ast-grep-replace.js +9 -4
- package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +5 -2
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +469 -56
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +190 -46
- package/node_modules/pi-lens/dist/tools/lsp-navigation.js +46 -7
- package/node_modules/pi-lens/dist/tools/symbol-search.js +1 -1
- package/node_modules/pi-lens/docs/agent-guide.md +44 -14
- package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +518 -501
- package/node_modules/pi-lens/docs/dispositions.md +21 -0
- package/node_modules/pi-lens/docs/features.md +33 -6
- package/node_modules/pi-lens/docs/globalconfig.md +14 -0
- package/node_modules/pi-lens/docs/language-coverage.md +71 -5
- package/node_modules/pi-lens/docs/mcp.md +2 -2
- package/node_modules/pi-lens/docs/servercapabilities.md +4 -1
- package/node_modules/pi-lens/docs/settings.md +25 -1
- package/node_modules/pi-lens/docs/usage.md +24 -5
- package/node_modules/pi-lens/docs/word-index.md +35 -0
- package/node_modules/pi-lens/package.json +10 -6
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/__snapshots__/no-reflect-get-js-snapshot.yml +23 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/__snapshots__/no-reflect-get-snapshot.yml +23 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/__snapshots__/ts-void-zero-snapshot.yml +23 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-bare-object-param-test.yml +16 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-chained-type-assertions-test.yml +22 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-compile-call-test.yml +29 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-conditional-empty-object-spread-js-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-conditional-empty-object-spread-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-dupe-class-members-test.yml +33 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-inner-html-js-test.yml +7 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-inner-html-test.yml +7 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-known-value-widening-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-non-null-assertion-test.yml +216 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-apply-js-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-apply-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-get-js-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-get-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +12 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-runtime-typeof-test.yml +33 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-server-bind-wildcard-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-shape-in-symbol-names-test.yml +13 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-js-test.yml +5 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-test.yml +5 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-unknown-laundering-test.yml +11 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-unknown-parameters-test.yml +12 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-unknown-returns-test.yml +16 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-unsafe-dictionary-any-test.yml +10 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-unsafe-dictionary-unknown-test.yml +8 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/redundant-unsafe-function-test.yml +35 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/require-safety-comment-for-as-unknown-as-test.yml +177 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/ts-void-zero-test.yml +1 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-await-expression-member-js.yml +13 -2
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-await-expression-member.yml +13 -2
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-bare-host-path-in-win32-branch.yml +2 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-bare-object-param.yml +60 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-chained-type-assertions.yml +66 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-compile-call.yml +63 -5
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-conditional-empty-object-spread-js.yml +21 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-conditional-empty-object-spread.yml +29 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-dupe-class-members.yml +52 -8
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-inner-html-js.yml +27 -2
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-inner-html.yml +27 -2
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-known-value-widening.yml +71 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-non-null-assertion.yml +316 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-raw-json-store-write.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-apply-js.yml +29 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-apply.yml +30 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-get-js.yml +41 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-get.yml +42 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +22 -5
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-runtime-typeof.yml +121 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-server-bind-wildcard.yml +23 -7
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-shape-in-symbol-names.yml +68 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-js.yml +41 -2
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code.yml +41 -2
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-unknown-laundering.yml +32 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-unknown-parameters.yml +67 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-unknown-returns.yml +106 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-unsafe-dictionary-any.yml +50 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-unsafe-dictionary-unknown.yml +56 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-win32-isabsolute-for-qualification.yml +2 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/redundant-unsafe-function.yml +32 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/require-safety-comment-for-as-unknown-as.yml +184 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/ts-void-zero.yml +5 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/self-scan-baseline.json +5 -0
- package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +132 -1
- package/node_modules/pi-lens/scripts/download-grammars.js +25 -0
- package/node_modules/pi-lens/scripts/grammars.lock.json +9 -0
- package/node_modules/pi-lens/skills/pi-lens-ast-grep/SKILL.md +12 -11
- package/node_modules/pi-lens/skills/pi-lens-lsp-navigation/SKILL.md +22 -22
- package/node_modules/pi-lens/skills/pi-lens-write-ast-grep-rule/SKILL.md +87 -116
- package/node_modules/pi-lens/skills/pi-lens-write-ast-grep-rule/reference.md +170 -0
- package/node_modules/pi-lens/skills/pi-lens-write-tree-sitter-rule/SKILL.md +3 -1
- package/node_modules/pi-lens/vendor/grammars/tree-sitter-cue.wasm +0 -0
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +49 -0
- package/node_modules/pi-mcp-adapter/README.md +51 -6
- package/node_modules/pi-mcp-adapter/agent-dir.ts +12 -4
- package/node_modules/pi-mcp-adapter/cli.js +188 -5
- package/node_modules/pi-mcp-adapter/commands.ts +128 -22
- package/node_modules/pi-mcp-adapter/config.ts +28 -10
- package/node_modules/pi-mcp-adapter/direct-tools.ts +23 -19
- package/node_modules/pi-mcp-adapter/index.ts +219 -32
- package/node_modules/pi-mcp-adapter/init.ts +36 -4
- package/node_modules/pi-mcp-adapter/lifecycle.ts +315 -24
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +39 -6
- package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +387 -0
- package/node_modules/pi-mcp-adapter/mcp-callback-server.ts +27 -3
- package/node_modules/pi-mcp-adapter/mcp-code.ts +4 -0
- package/node_modules/pi-mcp-adapter/mcp-panel.ts +42 -13
- package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +2 -1
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +46 -25
- package/node_modules/pi-mcp-adapter/package-mcp-loader.ts +168 -0
- package/node_modules/pi-mcp-adapter/package.json +4 -1
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +5 -4
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +330 -0
- package/node_modules/pi-mcp-adapter/search-ranking.ts +92 -22
- package/node_modules/pi-mcp-adapter/server-manager.ts +145 -2
- package/node_modules/pi-mcp-adapter/session-recovery.ts +7 -0
- package/node_modules/pi-mcp-adapter/tool-approval.ts +15 -2
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +38 -18
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +44 -4
- package/node_modules/pi-mcp-adapter/types.ts +95 -10
- package/node_modules/pi-mcp-adapter/ui-server.ts +18 -16
- package/node_modules/pi-mcp-adapter/utils.ts +70 -0
- package/node_modules/pi-web-access/CHANGELOG.md +37 -0
- package/node_modules/pi-web-access/README.md +38 -14
- package/node_modules/pi-web-access/anysearch.ts +4 -2
- package/node_modules/pi-web-access/auth-fetch.ts +148 -0
- package/node_modules/pi-web-access/brave.ts +16 -4
- package/node_modules/pi-web-access/chrome-cookies.ts +110 -23
- package/node_modules/pi-web-access/curator-page.ts +8 -3
- package/node_modules/pi-web-access/curator-server.ts +5 -1
- package/node_modules/pi-web-access/exa.ts +18 -7
- package/node_modules/pi-web-access/extract.ts +134 -37
- package/node_modules/pi-web-access/fetch-params.ts +17 -3
- package/node_modules/pi-web-access/firecrawl.ts +172 -12
- package/node_modules/pi-web-access/gemini-search.ts +33 -7
- package/node_modules/pi-web-access/index.ts +160 -104
- package/node_modules/pi-web-access/package.json +2 -2
- package/node_modules/pi-web-access/page-query.ts +4 -2
- package/node_modules/pi-web-access/parallel-mcp.ts +249 -0
- package/node_modules/pi-web-access/parallel.ts +2 -2
- package/node_modules/pi-web-access/query-rewrite.ts +51 -0
- package/node_modules/pi-web-access/serper.ts +211 -0
- package/node_modules/pi-web-access/summary-model-scope.ts +12 -4
- package/node_modules/pi-web-access/summary-review.ts +51 -23
- package/node_modules/pi-web-access/tavily.ts +16 -4
- package/node_modules/pi-web-access/utils.ts +87 -0
- package/node_modules/pi-web-access/valyu.ts +199 -0
- package/node_modules/pi-web-access/youtube-extract.ts +2 -2
- package/package.json +13 -13
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { safeSpawnAsync } from "./safe-spawn.js";
|
|
3
3
|
import { findLocalToolConfig } from "./path-utils.js";
|
|
4
|
+
import { incrementDegradationCount } from "./degradation-ledger.js";
|
|
5
|
+
import { classifyProbeFailure, createAvailabilityLatch, logAvailabilityDecision, startHostStallSampler, } from "./dispatch/runners/utils/availability-policy.js";
|
|
4
6
|
/**
|
|
5
7
|
* zizmor (GitHub Actions workflow security scanner) configuration discovery and
|
|
6
8
|
* online-mode token resolution. zizmor runs as a cross-cutting auxiliary LSP
|
|
@@ -49,23 +51,178 @@ export function isZizmorAuditTarget(filePath) {
|
|
|
49
51
|
return true;
|
|
50
52
|
return false;
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
// A transient-aware latch for the `gh auth token` derivation (#1535, the
|
|
55
|
+
// #1467/#1494 permanent-probe-latch family). The old code folded EVERY
|
|
56
|
+
// failure — including a 5s host stall — into a memoized `{ value: undefined }`
|
|
57
|
+
// that stuck for the whole process, so a single slow `gh` disabled zizmor's
|
|
58
|
+
// GitHub-aware online audits (known-vulnerable-actions, unpinned-uses,
|
|
59
|
+
// impostor-commit) for the rest of the session while the scan still reported
|
|
60
|
+
// success. Only a genuine answer (gh ran and returned a real exit code, or is
|
|
61
|
+
// proven absent) latches now; a timeout/stall/unspawnable probe expires on the
|
|
62
|
+
// shared cooldown and is re-probed on the next call.
|
|
63
|
+
//
|
|
64
|
+
// The cooldown ladder is capped below zizmor's respawn cadence, but that
|
|
65
|
+
// cadence isn't a single number: `clients/runtime-turn.ts`'s ordinary LSP
|
|
66
|
+
// idle reset is 240s, while a subagent session or budget pressure can
|
|
67
|
+
// recycle the fleet on `clients/lsp-budget.ts`'s shorter
|
|
68
|
+
// `DEFAULT_LSP_BUDGET_IDLE_TIMEOUT_MS` (60s). The 120s cap sits BELOW the
|
|
69
|
+
// 240s cadence but ABOVE the 60s one, so that faster respawn can still land
|
|
70
|
+
// inside a still-cooling verdict — the shared default cap
|
|
71
|
+
// (`TRANSIENT_MAX_COOLDOWN_MS`, 5 min) would make either respawn read the
|
|
72
|
+
// cache instead of re-probing. The 60s gap is covered differently: the
|
|
73
|
+
// cache-hit path in `resolveZizmorGitHubToken` logs an
|
|
74
|
+
// `availability_decision` and counts a degradation on every transient cache
|
|
75
|
+
// read, not only on the probe that produced it, so a respawn landing inside
|
|
76
|
+
// EITHER cadence is still observable even when it isn't re-probed (#1535
|
|
77
|
+
// review).
|
|
78
|
+
const ZIZMOR_TOKEN_MAX_COOLDOWN_MS = 120_000;
|
|
79
|
+
const ghTokenLatch = createAvailabilityLatch({
|
|
80
|
+
maxCooldownMs: ZIZMOR_TOKEN_MAX_COOLDOWN_MS,
|
|
81
|
+
});
|
|
82
|
+
let cachedToken;
|
|
83
|
+
const GH_TOKEN_PROBE_TIMEOUT_MS = 5000;
|
|
84
|
+
/**
|
|
85
|
+
* Forget the memoized `gh auth token` verdict. Called at `session_start`
|
|
86
|
+
* (`clients/runtime-session.ts`, alongside the sibling `#1266`
|
|
87
|
+
* `resetDispatchAvailabilityState` reset) so a user who runs `gh auth login`
|
|
88
|
+
* and starts a new session doesn't keep reading a stale "no token" answer
|
|
89
|
+
* from the previous one — the latch is process-lived storage, but its
|
|
90
|
+
* DURABILITY contract is per-session, matching every other dispatch
|
|
91
|
+
* availability latch.
|
|
92
|
+
*/
|
|
93
|
+
export function resetZizmorTokenAvailability() {
|
|
94
|
+
ghTokenLatch.reset();
|
|
95
|
+
cachedToken = undefined;
|
|
96
|
+
}
|
|
97
|
+
/** Test-only alias — kept so existing tests don't need a rename. */
|
|
54
98
|
export function _resetZizmorTokenCacheForTests() {
|
|
55
|
-
|
|
99
|
+
resetZizmorTokenAvailability();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Classify a failed `gh auth token` probe.
|
|
103
|
+
*
|
|
104
|
+
* `classifyProbeFailure`'s default branch treats ANY unrecognized failure —
|
|
105
|
+
* including a spawn that never actually ran (EACCES, a resolution error, the
|
|
106
|
+
* generic `spawn-failed` bucket) — as a durable `non-installable` verdict.
|
|
107
|
+
* That is correct for a probe that ran and rejected, but wrong here: an
|
|
108
|
+
* unspawnable prober never asked `gh` anything, so it must not be read as a
|
|
109
|
+
* durable "no" (the lesson from this week's sibling-fix reviews on the
|
|
110
|
+
* #1467/#1494 latch family). Only two shapes may latch: a completed run (any
|
|
111
|
+
* exit code — that IS gh's answer) and a proven-absent `gh` binary.
|
|
112
|
+
*/
|
|
113
|
+
function classifyGhTokenFailure(res, hostStallMs) {
|
|
114
|
+
// #1651 review F5: `!res.error` alone is not proof gh ran and answered.
|
|
115
|
+
// A `null` or negative `status` is Node's OWN signal that the process
|
|
116
|
+
// never completed a real run — no completed process exits with either —
|
|
117
|
+
// so this never trusts a bare-`error` check over that shape, regardless
|
|
118
|
+
// of whether `safeSpawnAsync` happened to attach an `error` for this
|
|
119
|
+
// particular result. OS-independent by construction: it reads the status
|
|
120
|
+
// Node reports, not a platform-specific errno.
|
|
121
|
+
const neverAnswered = res.status === null || (res.status ?? 0) < 0;
|
|
122
|
+
if (!res.error && !neverAnswered) {
|
|
123
|
+
// The process ran to completion with a real (nonzero, since the zero
|
|
124
|
+
// exit is handled before this is ever called) exit code — a genuine
|
|
125
|
+
// "not authenticated" (or otherwise rejected) answer, safe to cache.
|
|
126
|
+
return { outcome: "non-installable", cause: "probe-rejected" };
|
|
127
|
+
}
|
|
128
|
+
if (res.spawnFailure?.kind === "tool-not-found") {
|
|
129
|
+
// gh genuinely isn't on PATH — a durable fact about the machine.
|
|
130
|
+
return { outcome: "missing", cause: "not-found" };
|
|
131
|
+
}
|
|
132
|
+
const classified = classifyProbeFailure(res, { hostStallMs });
|
|
133
|
+
if (classified.outcome === "transient" || classified.outcome === "missing") {
|
|
134
|
+
return classified;
|
|
135
|
+
}
|
|
136
|
+
// Everything else (EACCES/permission-denied, cwd-unresolvable, a generic
|
|
137
|
+
// spawn-failed, or an unrecognized errno) means the child never launched —
|
|
138
|
+
// that's evidence about this moment, not about gh's auth state.
|
|
139
|
+
return { outcome: "transient", cause: classified.cause };
|
|
56
140
|
}
|
|
57
141
|
async function deriveGhCliToken() {
|
|
142
|
+
const sampler = startHostStallSampler();
|
|
143
|
+
const startedAt = Date.now();
|
|
58
144
|
// Best-effort: a missing/unauthenticated `gh` just leaves zizmor offline.
|
|
59
145
|
// ignoreAmbientSignal so a mid-turn Esc can't silently drop the server into
|
|
60
146
|
// offline mode; short timeout so a wedged `gh` never stalls the warm spawn.
|
|
147
|
+
// safeSpawnAsync never rejects (every failure resolves into `res`), so no
|
|
148
|
+
// try/finally is needed to guarantee the sampler stops.
|
|
61
149
|
const res = await safeSpawnAsync("gh", ["auth", "token"], {
|
|
62
|
-
timeout:
|
|
150
|
+
timeout: GH_TOKEN_PROBE_TIMEOUT_MS,
|
|
63
151
|
ignoreAmbientSignal: true,
|
|
64
152
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
153
|
+
const hostStallMs = sampler.stop();
|
|
154
|
+
const elapsedMs = Date.now() - startedAt;
|
|
155
|
+
if (!res.error && res.status === 0) {
|
|
156
|
+
const token = res.stdout.trim();
|
|
157
|
+
if (token.length > 0) {
|
|
158
|
+
ghTokenLatch.noteAvailable();
|
|
159
|
+
logAvailabilityDecision({
|
|
160
|
+
tool: "zizmor-gh-token",
|
|
161
|
+
verdict: "available",
|
|
162
|
+
outcome: "success",
|
|
163
|
+
cause: "ok",
|
|
164
|
+
elapsedMs,
|
|
165
|
+
latched: true,
|
|
166
|
+
hostStallMs,
|
|
167
|
+
budgetMs: GH_TOKEN_PROBE_TIMEOUT_MS,
|
|
168
|
+
});
|
|
169
|
+
return token;
|
|
170
|
+
}
|
|
171
|
+
// `gh` ran cleanly and answered with nothing — a genuine, durable "no
|
|
172
|
+
// token" verdict (distinct from a rejected/nonzero exit), so it is safe
|
|
173
|
+
// to cache. Reviewer-caught #1535 gap: the pre-fix version of this
|
|
174
|
+
// branch called `noteAvailable()` / logged `verdict:"available"` here
|
|
175
|
+
// regardless of whether `token` was empty, so the record claimed the
|
|
176
|
+
// online audits ran while zizmor was actually about to launch offline
|
|
177
|
+
// — the #1535 silence moved into the telemetry instead of being fixed.
|
|
178
|
+
return recordGhTokenUnavailable({ outcome: "non-installable", cause: "empty-result" }, elapsedMs, hostStallMs);
|
|
179
|
+
}
|
|
180
|
+
return recordGhTokenUnavailable(classifyGhTokenFailure(res, hostStallMs), elapsedMs, hostStallMs);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Shared tail for every "no token" verdict: latches (or cools down) the
|
|
184
|
+
* memo, records the degradation this causes when it isn't durable-expected,
|
|
185
|
+
* and logs the decision. Centralized so the empty-answer and failure paths
|
|
186
|
+
* can't drift on which fields get set.
|
|
187
|
+
*/
|
|
188
|
+
function recordGhTokenUnavailable({ outcome, cause }, elapsedMs, hostStallMs) {
|
|
189
|
+
const retryAfterMs = ghTokenLatch.noteUnavailable(outcome, cause);
|
|
190
|
+
if (outcome === "transient") {
|
|
191
|
+
recordZizmorOfflineDegradation(`gh auth token probe ${cause}; running offline until the next zizmor start (retry allowed in ${Math.round(retryAfterMs / 1000)}s)`);
|
|
192
|
+
}
|
|
193
|
+
logAvailabilityDecision({
|
|
194
|
+
tool: "zizmor-gh-token",
|
|
195
|
+
verdict: "unavailable",
|
|
196
|
+
outcome,
|
|
197
|
+
cause,
|
|
198
|
+
elapsedMs,
|
|
199
|
+
latched: outcome !== "transient",
|
|
200
|
+
hostStallMs,
|
|
201
|
+
...(retryAfterMs > 0 && { retryAfterMs }),
|
|
202
|
+
budgetMs: GH_TOKEN_PROBE_TIMEOUT_MS,
|
|
203
|
+
});
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The degradation itself: zizmor is about to run offline
|
|
208
|
+
* (known-vulnerable-actions/unpinned-uses/impostor-commit skipped) NOT
|
|
209
|
+
* because the token is genuinely absent, but because a probe never got a
|
|
210
|
+
* fair hearing (or is still cooling down from one). Make that legible
|
|
211
|
+
* instead of letting the scan silently report "clean" (#1459's
|
|
212
|
+
* security-silence shape).
|
|
213
|
+
*
|
|
214
|
+
* `incrementDegradationCount` (not the bare `recordDegradation`) per
|
|
215
|
+
* AGENTS.md's degradation-telemetry convention: every offline spawn across a
|
|
216
|
+
* cooldown cycle contributes to the exact group count, but the health view
|
|
217
|
+
* retains only one updated entry per subject instead of five near-identical
|
|
218
|
+
* lines.
|
|
219
|
+
*/
|
|
220
|
+
function recordZizmorOfflineDegradation(reason) {
|
|
221
|
+
incrementDegradationCount({
|
|
222
|
+
kind: "mode-suppression",
|
|
223
|
+
subject: "zizmor",
|
|
224
|
+
reason,
|
|
225
|
+
});
|
|
69
226
|
}
|
|
70
227
|
/**
|
|
71
228
|
* Resolve a GitHub token to put zizmor into ONLINE mode, so the audits that need
|
|
@@ -77,7 +234,17 @@ async function deriveGhCliToken() {
|
|
|
77
234
|
* enables online mode. Those env vars already flow to the spawned server
|
|
78
235
|
* (launchLSP merges `process.env`), so the ONLY gap we close here is the very
|
|
79
236
|
* common case of a user who has authenticated the `gh` CLI but exported no
|
|
80
|
-
* token — we derive one via `gh auth token`. Memoized per
|
|
237
|
+
* token — we derive one via `gh auth token`. Memoized per session through a
|
|
238
|
+
* transient-aware latch (#1535, reset by `resetZizmorTokenAvailability` at
|
|
239
|
+
* `session_start`): only a genuine answer (gh ran and returned an exit code,
|
|
240
|
+
* or is proven absent) is remembered — a timeout/stall/unspawnable probe
|
|
241
|
+
* expires on a cooldown and is re-derived on the next call, so a single slow
|
|
242
|
+
* `gh` can't disable online audits for the rest of the session.
|
|
243
|
+
*
|
|
244
|
+
* Caveat callers should know: this only decides what token a NEW zizmor spawn
|
|
245
|
+
* receives. A warm zizmor process already has its `GH_TOKEN` set at launch
|
|
246
|
+
* time (`ZizmorServer.spawn`) and does not re-read it — recovering from a
|
|
247
|
+
* transient failure means the NEXT spawn goes online, not the current one.
|
|
81
248
|
*/
|
|
82
249
|
export async function resolveZizmorGitHubToken() {
|
|
83
250
|
// Respect an explicit offline request — never derive a token then.
|
|
@@ -88,9 +255,42 @@ export async function resolveZizmorGitHubToken() {
|
|
|
88
255
|
process.env.GITHUB_TOKEN;
|
|
89
256
|
if (fromEnv)
|
|
90
257
|
return fromEnv;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
258
|
+
const memo = ghTokenLatch.read();
|
|
259
|
+
if (memo !== null) {
|
|
260
|
+
if (memo === false && ghTokenLatch.getOutcome() === "transient") {
|
|
261
|
+
// Served straight from the still-cooling latch: no new probe runs,
|
|
262
|
+
// so `deriveGhCliToken`'s own logging never fires. Without this, once
|
|
263
|
+
// the cooldown ladder crosses zizmor's own respawn cadence (bounded
|
|
264
|
+
// below `TRANSIENT_MAX_COOLDOWN_MS` via `ZIZMOR_TOKEN_MAX_COOLDOWN_MS`
|
|
265
|
+
// for exactly this reason) a spawn could start offline with nothing
|
|
266
|
+
// in latency.log or the degradation ledger to say so (#1535 review).
|
|
267
|
+
const cause = ghTokenLatch.getCause();
|
|
268
|
+
if (cause === null) {
|
|
269
|
+
// `getOutcome() === "transient"` is only ever set by `noteUnavailable`
|
|
270
|
+
// in the same call that sets `cause` — the two fields are written
|
|
271
|
+
// together, so this can't happen without the latch's own invariant
|
|
272
|
+
// breaking. Assert rather than fabricate a plausible-looking default
|
|
273
|
+
// (e.g. `?? "probe-timeout"`): a fake cause here would silently
|
|
274
|
+
// mislabel WHY the current cycle is offline, in exactly the spot
|
|
275
|
+
// this fix exists to make honest.
|
|
276
|
+
throw new Error("zizmor gh-token latch: transient outcome with no cause (invariant violated)");
|
|
277
|
+
}
|
|
278
|
+
const retryAfterMs = Math.max(0, ghTokenLatch.getRetryAtMs() - Date.now());
|
|
279
|
+
recordZizmorOfflineDegradation(`gh auth token still cooling down (${cause}); serving cached offline verdict, retry allowed in ${Math.round(retryAfterMs / 1000)}s`);
|
|
280
|
+
logAvailabilityDecision({
|
|
281
|
+
tool: "zizmor-gh-token",
|
|
282
|
+
verdict: "unavailable",
|
|
283
|
+
outcome: "transient",
|
|
284
|
+
cause,
|
|
285
|
+
elapsedMs: 0,
|
|
286
|
+
latched: false,
|
|
287
|
+
hostStallMs: 0,
|
|
288
|
+
...(retryAfterMs > 0 && { retryAfterMs }),
|
|
289
|
+
budgetMs: GH_TOKEN_PROBE_TIMEOUT_MS,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return memo ? cachedToken : undefined;
|
|
293
|
+
}
|
|
294
|
+
cachedToken = await deriveGhCliToken();
|
|
295
|
+
return cachedToken;
|
|
96
296
|
}
|