@herbertgao/pi-extensions 2026.8.3 → 2026.8.5
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 +45 -4
- package/examples/pi-footer.json +275 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +10 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +10 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +24 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +91 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +7 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +7 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +21 -12
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +4 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +5 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +22 -12
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +2 -4
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +8 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +8 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-color.ts +72 -67
- package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +255 -0
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +191 -3
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +15 -2
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +289 -113
- package/node_modules/@herbertgao/pi-subagents/src/output-file.ts +24 -1
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +24 -2
- package/node_modules/@herbertgao/pi-subagents/src/ui/schedule-menu.ts +9 -8
- package/node_modules/@herbertgao/pi-subagents/src/ui/select-item.ts +48 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +7 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +7 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +16 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +4 -2
- package/node_modules/@narumitw/pi-btw/README.md +8 -7
- package/node_modules/@narumitw/pi-btw/package.json +2 -2
- package/node_modules/@narumitw/pi-btw/src/menu.ts +1 -0
- package/node_modules/pi-footer/CHANGELOG.md +145 -0
- package/node_modules/pi-footer/LICENSE +21 -0
- package/node_modules/pi-footer/README.md +354 -0
- package/node_modules/pi-footer/package.json +68 -0
- package/node_modules/pi-footer/src/cache.ts +106 -0
- package/node_modules/pi-footer/src/colors.ts +237 -0
- package/node_modules/pi-footer/src/config.ts +202 -0
- package/node_modules/pi-footer/src/event-widgets.ts +41 -0
- package/node_modules/pi-footer/src/extension-statuses.ts +102 -0
- package/node_modules/pi-footer/src/git.ts +135 -0
- package/node_modules/pi-footer/src/index.ts +268 -0
- package/node_modules/pi-footer/src/metrics.ts +141 -0
- package/node_modules/pi-footer/src/presets.ts +383 -0
- package/node_modules/pi-footer/src/render.ts +114 -0
- package/node_modules/pi-footer/src/separators.ts +52 -0
- package/node_modules/pi-footer/src/types.ts +122 -0
- package/node_modules/pi-footer/src/ui/color-level-confirm.ts +22 -0
- package/node_modules/pi-footer/src/ui/color-options.ts +195 -0
- package/node_modules/pi-footer/src/ui/config-lifecycle.ts +61 -0
- package/node_modules/pi-footer/src/ui/edit-colors.ts +13 -0
- package/node_modules/pi-footer/src/ui/events.ts +35 -0
- package/node_modules/pi-footer/src/ui/extension-status-picker.ts +60 -0
- package/node_modules/pi-footer/src/ui/extension-statuses.ts +73 -0
- package/node_modules/pi-footer/src/ui/fields.ts +252 -0
- package/node_modules/pi-footer/src/ui/global-menu.ts +126 -0
- package/node_modules/pi-footer/src/ui/helpers.ts +44 -0
- package/node_modules/pi-footer/src/ui/layout.ts +17 -0
- package/node_modules/pi-footer/src/ui/line-list.ts +19 -0
- package/node_modules/pi-footer/src/ui/model.ts +64 -0
- package/node_modules/pi-footer/src/ui/navigation.ts +29 -0
- package/node_modules/pi-footer/src/ui/option-edit.ts +93 -0
- package/node_modules/pi-footer/src/ui/overlay-render.ts +103 -0
- package/node_modules/pi-footer/src/ui/screen-context.ts +18 -0
- package/node_modules/pi-footer/src/ui/screen-controller.ts +27 -0
- package/node_modules/pi-footer/src/ui/screen-render.ts +32 -0
- package/node_modules/pi-footer/src/ui/screen-state.ts +20 -0
- package/node_modules/pi-footer/src/ui/screen.ts +243 -0
- package/node_modules/pi-footer/src/ui/screens/add-widget.ts +92 -0
- package/node_modules/pi-footer/src/ui/screens/confirm-exit.ts +52 -0
- package/node_modules/pi-footer/src/ui/screens/controller.ts +12 -0
- package/node_modules/pi-footer/src/ui/screens/edit-colors.ts +68 -0
- package/node_modules/pi-footer/src/ui/screens/edit-widget.ts +115 -0
- package/node_modules/pi-footer/src/ui/screens/extension-status-row.ts +61 -0
- package/node_modules/pi-footer/src/ui/screens/global.ts +75 -0
- package/node_modules/pi-footer/src/ui/screens/line-list.ts +108 -0
- package/node_modules/pi-footer/src/ui/screens/main.ts +99 -0
- package/node_modules/pi-footer/src/ui/screens/terminal.ts +121 -0
- package/node_modules/pi-footer/src/ui/screens/widget-list.ts +154 -0
- package/node_modules/pi-footer/src/ui/terminal-menu.ts +32 -0
- package/node_modules/pi-footer/src/ui/theme.ts +48 -0
- package/node_modules/pi-footer/src/ui/title-bar.ts +100 -0
- package/node_modules/pi-footer/src/ui/widget-actions.ts +76 -0
- package/node_modules/pi-footer/src/ui.ts +66 -0
- package/node_modules/pi-footer/src/widgets/context.ts +28 -0
- package/node_modules/pi-footer/src/widgets/core/active-tools.ts +17 -0
- package/node_modules/pi-footer/src/widgets/core/context-window.ts +24 -0
- package/node_modules/pi-footer/src/widgets/core/cwd-basename.ts +19 -0
- package/node_modules/pi-footer/src/widgets/core/cwd.ts +108 -0
- package/node_modules/pi-footer/src/widgets/core/event.ts +34 -0
- package/node_modules/pi-footer/src/widgets/core/external-status.ts +102 -0
- package/node_modules/pi-footer/src/widgets/core/model-provider.ts +20 -0
- package/node_modules/pi-footer/src/widgets/core/model.ts +35 -0
- package/node_modules/pi-footer/src/widgets/core/provider.ts +17 -0
- package/node_modules/pi-footer/src/widgets/core/session-name.ts +17 -0
- package/node_modules/pi-footer/src/widgets/core/text-verbosity.ts +17 -0
- package/node_modules/pi-footer/src/widgets/core/thinking-level.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/ahead-behind.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/branch.ts +81 -0
- package/node_modules/pi-footer/src/widgets/git/clean.ts +19 -0
- package/node_modules/pi-footer/src/widgets/git/deletions.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/diff.ts +38 -0
- package/node_modules/pi-footer/src/widgets/git/insertions.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/remote.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/root.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/sha.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/staged.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/status.ts +19 -0
- package/node_modules/pi-footer/src/widgets/git/unstaged.ts +17 -0
- package/node_modules/pi-footer/src/widgets/git/untracked.ts +17 -0
- package/node_modules/pi-footer/src/widgets/instance.ts +118 -0
- package/node_modules/pi-footer/src/widgets/layout/custom-text.ts +18 -0
- package/node_modules/pi-footer/src/widgets/layout/flex-separator.ts +32 -0
- package/node_modules/pi-footer/src/widgets/layout/separator.ts +57 -0
- package/node_modules/pi-footer/src/widgets/layout/spacer.ts +31 -0
- package/node_modules/pi-footer/src/widgets/options.ts +122 -0
- package/node_modules/pi-footer/src/widgets/project/runtime.ts +361 -0
- package/node_modules/pi-footer/src/widgets/registry.ts +223 -0
- package/node_modules/pi-footer/src/widgets/session/assistant-messages.ts +17 -0
- package/node_modules/pi-footer/src/widgets/session/compactions.ts +17 -0
- package/node_modules/pi-footer/src/widgets/session/elapsed.ts +18 -0
- package/node_modules/pi-footer/src/widgets/session/last-activity.ts +18 -0
- package/node_modules/pi-footer/src/widgets/session/messages.ts +19 -0
- package/node_modules/pi-footer/src/widgets/session/session-id.ts +17 -0
- package/node_modules/pi-footer/src/widgets/session/session-start.ts +18 -0
- package/node_modules/pi-footer/src/widgets/session/tool-results.ts +17 -0
- package/node_modules/pi-footer/src/widgets/session/total-messages.ts +19 -0
- package/node_modules/pi-footer/src/widgets/session/total-time.ts +18 -0
- package/node_modules/pi-footer/src/widgets/session/user-messages.ts +17 -0
- package/node_modules/pi-footer/src/widgets/store.ts +26 -0
- package/node_modules/pi-footer/src/widgets/tokens/cache-hit-rate.ts +55 -0
- package/node_modules/pi-footer/src/widgets/tokens/cache-read.ts +18 -0
- package/node_modules/pi-footer/src/widgets/tokens/cache-write.ts +18 -0
- package/node_modules/pi-footer/src/widgets/tokens/context-bar.ts +108 -0
- package/node_modules/pi-footer/src/widgets/tokens/context-length.ts +26 -0
- package/node_modules/pi-footer/src/widgets/tokens/context-remaining.ts +29 -0
- package/node_modules/pi-footer/src/widgets/tokens/context.ts +29 -0
- package/node_modules/pi-footer/src/widgets/tokens/cost.ts +51 -0
- package/node_modules/pi-footer/src/widgets/tokens/input-speed.ts +25 -0
- package/node_modules/pi-footer/src/widgets/tokens/input-tokens.ts +18 -0
- package/node_modules/pi-footer/src/widgets/tokens/output-speed.ts +25 -0
- package/node_modules/pi-footer/src/widgets/tokens/output-tokens.ts +18 -0
- package/node_modules/pi-footer/src/widgets/tokens/tokens.ts +20 -0
- package/node_modules/pi-footer/src/widgets/tokens/total-speed.ts +25 -0
- package/node_modules/pi-footer/src/widgets/tokens/total-tokens.ts +18 -0
- package/node_modules/pi-footer/src/widgets/types.ts +181 -0
- package/node_modules/pi-footer/src/widgets/utils/colors.ts +11 -0
- package/node_modules/pi-footer/src/widgets/utils/context.ts +112 -0
- package/node_modules/pi-footer/src/widgets/utils/session.ts +19 -0
- package/node_modules/pi-footer/src/widgets/utils/token-format.ts +78 -0
- package/node_modules/pi-lens/CHANGELOG.md +2440 -954
- package/node_modules/pi-lens/README.md +13 -0
- package/node_modules/pi-lens/dist/clients/actionable-warnings.js +73 -18
- package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +21 -4
- package/node_modules/pi-lens/dist/clients/ast-grep-client.js +68 -16
- package/node_modules/pi-lens/dist/clients/ast-grep-types.js +0 -1
- package/node_modules/pi-lens/dist/clients/ast-grep-yaml-synth.js +37 -10
- package/node_modules/pi-lens/dist/clients/atomic-write-staging.js +63 -0
- package/node_modules/pi-lens/dist/clients/atomic-write.js +114 -14
- package/node_modules/pi-lens/dist/clients/bash-file-access.js +193 -23
- package/node_modules/pi-lens/dist/clients/biome-client.js +29 -25
- package/node_modules/pi-lens/dist/clients/bootstrap.js +11 -2
- package/node_modules/pi-lens/dist/clients/bounded-cache.js +34 -0
- package/node_modules/pi-lens/dist/clients/bounded-pid-file-lock.js +192 -0
- package/node_modules/pi-lens/dist/clients/bus-publish.js +10 -3
- package/node_modules/pi-lens/dist/clients/cache/rule-cache.js +47 -5
- package/node_modules/pi-lens/dist/clients/cache-manager.js +97 -9
- package/node_modules/pi-lens/dist/clients/cache-observability.js +301 -14
- package/node_modules/pi-lens/dist/clients/call-graph.js +449 -117
- package/node_modules/pi-lens/dist/clients/child-unref.js +85 -0
- package/node_modules/pi-lens/dist/clients/codebase-model.js +52 -23
- package/node_modules/pi-lens/dist/clients/collateral-test-role.js +40 -0
- package/node_modules/pi-lens/dist/clients/complexity-client.js +2 -1
- package/node_modules/pi-lens/dist/clients/console-guard-install.js +14 -0
- package/node_modules/pi-lens/dist/clients/cooperative-budget.js +42 -0
- package/node_modules/pi-lens/dist/clients/dead-code-client.js +2 -1
- package/node_modules/pi-lens/dist/clients/debug-handles.js +206 -0
- package/node_modules/pi-lens/dist/clients/debug-heap.js +167 -0
- package/node_modules/pi-lens/dist/clients/degradation-ledger.js +153 -0
- package/node_modules/pi-lens/dist/clients/dependency-checker.js +347 -75
- package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +61 -11
- package/node_modules/pi-lens/dist/clients/diagnostics-publish.js +10 -3
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +63 -20
- package/node_modules/pi-lens/dist/clients/dispatch/facts/function-facts.js +23 -7
- package/node_modules/pi-lens/dist/clients/dispatch/facts/import-facts.js +8 -18
- package/node_modules/pi-lens/dist/clients/dispatch/facts/tree-sitter-facts.js +8 -5
- package/node_modules/pi-lens/dist/clients/dispatch/indent-detect.js +35 -0
- package/node_modules/pi-lens/dist/clients/dispatch/inline-suppressions.js +17 -8
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +1085 -681
- package/node_modules/pi-lens/dist/clients/dispatch/lazy.js +14 -0
- package/node_modules/pi-lens/dist/clients/dispatch/plan.js +11 -1
- package/node_modules/pi-lens/dist/clients/dispatch/rule-id-normalize.js +50 -0
- package/node_modules/pi-lens/dist/clients/dispatch/rule-policy.js +135 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +23 -5
- package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +5 -9
- package/node_modules/pi-lens/dist/clients/dispatch/runners/detekt.js +3 -2
- package/node_modules/pi-lens/dist/clients/dispatch/runners/hadolint.js +2 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-lint.js +154 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/htmlhint.js +3 -2
- package/node_modules/pi-lens/dist/clients/dispatch/runners/index.js +5 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +14 -6
- package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +4 -9
- package/node_modules/pi-lens/dist/clients/dispatch/runners/pyright.js +9 -5
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ruff.js +4 -8
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shellcheck.js +2 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +2 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/spotbugs.js +2 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/taplo.js +2 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/terragrunt.js +163 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/tflint.js +37 -5
- package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +3 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/trivy-config.js +13 -7
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/lazy-installer.js +3 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +277 -26
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +22 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +5 -4
- package/node_modules/pi-lens/dist/clients/disposition-publish.js +10 -3
- package/node_modules/pi-lens/dist/clients/durable-store.js +97 -0
- package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +94 -3
- package/node_modules/pi-lens/dist/clients/extension-log.js +139 -0
- package/node_modules/pi-lens/dist/clients/extension-mode.js +73 -0
- package/node_modules/pi-lens/dist/clients/file-kinds.js +57 -0
- package/node_modules/pi-lens/dist/clients/file-role.js +18 -3
- package/node_modules/pi-lens/dist/clients/file-utils.js +56 -34
- package/node_modules/pi-lens/dist/clients/format-events-publish.js +16 -3
- package/node_modules/pi-lens/dist/clients/format-service.js +24 -8
- package/node_modules/pi-lens/dist/clients/formatters-lazy.js +8 -0
- package/node_modules/pi-lens/dist/clients/formatters.js +358 -61
- package/node_modules/pi-lens/dist/clients/generated-artifacts.js +148 -15
- package/node_modules/pi-lens/dist/clients/git-guard.js +681 -11
- package/node_modules/pi-lens/dist/clients/git-tracked-ignore.js +4 -0
- package/node_modules/pi-lens/dist/clients/go-client.js +2 -1
- package/node_modules/pi-lens/dist/clients/govulncheck-client.js +8 -0
- package/node_modules/pi-lens/dist/clients/grammar-source.js +12 -4
- package/node_modules/pi-lens/dist/clients/gzip-stage-write.js +21 -3
- package/node_modules/pi-lens/dist/clients/host-ports.js +31 -0
- package/node_modules/pi-lens/dist/clients/installer/index.js +390 -99
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +142 -172
- package/node_modules/pi-lens/dist/clients/jscpd-client.js +31 -54
- package/node_modules/pi-lens/dist/clients/knip-client.js +15 -36
- package/node_modules/pi-lens/dist/clients/language-policy.js +14 -2
- package/node_modules/pi-lens/dist/clients/language-profile.js +13 -7
- package/node_modules/pi-lens/dist/clients/latency-logger.js +23 -1
- package/node_modules/pi-lens/dist/clients/lens-config.js +12 -1
- package/node_modules/pi-lens/dist/clients/lens-engine.js +86 -17
- package/node_modules/pi-lens/dist/clients/lens-events.js +27 -4
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +8 -0
- package/node_modules/pi-lens/dist/clients/lens-map.js +94 -19
- package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +30 -0
- package/node_modules/pi-lens/dist/clients/log-cleanup.js +2 -1
- package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp/client.js +493 -48
- package/node_modules/pi-lens/dist/clients/lsp/config.js +13 -2
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +86 -0
- package/node_modules/pi-lens/dist/clients/lsp/edits.js +1012 -121
- package/node_modules/pi-lens/dist/clients/lsp/index.js +1807 -780
- package/node_modules/pi-lens/dist/clients/lsp/launch.js +32 -26
- package/node_modules/pi-lens/dist/clients/lsp/path-utils.js +1 -1
- package/node_modules/pi-lens/dist/clients/lsp/ruby-drive-dirs.js +83 -0
- package/node_modules/pi-lens/dist/clients/lsp/server.js +196 -32
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +28 -4
- package/node_modules/pi-lens/dist/clients/lsp-lazy.js +8 -0
- package/node_modules/pi-lens/dist/clients/lsp-mutation.js +248 -0
- package/node_modules/pi-lens/dist/clients/mcp/analyze.js +123 -32
- package/node_modules/pi-lens/dist/clients/mcp/ipc.js +157 -24
- package/node_modules/pi-lens/dist/clients/mcp/session.js +216 -8
- package/node_modules/pi-lens/dist/clients/memory-sampler.js +115 -0
- package/node_modules/pi-lens/dist/clients/metrics-client.js +2 -1
- package/node_modules/pi-lens/dist/clients/metrics-history.js +2 -1
- package/node_modules/pi-lens/dist/clients/module-report-lsp.js +5 -0
- package/node_modules/pi-lens/dist/clients/module-report.js +168 -3
- package/node_modules/pi-lens/dist/clients/ndjson-logger.js +319 -118
- package/node_modules/pi-lens/dist/clients/opengrep-client.js +1 -1
- package/node_modules/pi-lens/dist/clients/partial-edit-apply.js +120 -5
- package/node_modules/pi-lens/dist/clients/path-utils.js +110 -9
- package/node_modules/pi-lens/dist/clients/pipeline.js +47 -13
- package/node_modules/pi-lens/dist/clients/print-mode.js +21 -0
- package/node_modules/pi-lens/dist/clients/project-changes.js +40 -0
- package/node_modules/pi-lens/dist/clients/project-diagnostics/cache.js +3 -2
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +8 -0
- package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +21 -1
- package/node_modules/pi-lens/dist/clients/project-lens-config.js +86 -9
- package/node_modules/pi-lens/dist/clients/project-report.js +27 -13
- package/node_modules/pi-lens/dist/clients/project-snapshot.js +175 -20
- package/node_modules/pi-lens/dist/clients/project-trust.js +181 -0
- package/node_modules/pi-lens/dist/clients/quiet-window.js +18 -4
- package/node_modules/pi-lens/dist/clients/read-bridge.js +147 -0
- package/node_modules/pi-lens/dist/clients/read-guard-logger.js +159 -1
- package/node_modules/pi-lens/dist/clients/read-guard-tool-lines.js +150 -29
- package/node_modules/pi-lens/dist/clients/read-guard.js +185 -4
- package/node_modules/pi-lens/dist/clients/resource-sampler.js +70 -84
- package/node_modules/pi-lens/dist/clients/review-graph/builder.js +1122 -221
- package/node_modules/pi-lens/dist/clients/review-graph/git-identity.js +2 -1
- package/node_modules/pi-lens/dist/clients/review-graph/import-resolvers.js +21 -10
- package/node_modules/pi-lens/dist/clients/review-graph/symbol-id.js +46 -0
- package/node_modules/pi-lens/dist/clients/review-graph/tsconfig-paths.js +57 -6
- package/node_modules/pi-lens/dist/clients/review-graph/workspace-modules.js +51 -3
- package/node_modules/pi-lens/dist/clients/review-graph-logger.js +30 -1
- package/node_modules/pi-lens/dist/clients/ruff-client.js +27 -44
- package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +107 -73
- package/node_modules/pi-lens/dist/clients/runtime-context.js +36 -12
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +74 -6
- package/node_modules/pi-lens/dist/clients/runtime-session.js +405 -117
- package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +71 -48
- package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +218 -23
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +237 -64
- package/node_modules/pi-lens/dist/clients/rust-client.js +2 -1
- package/node_modules/pi-lens/dist/clients/safe-spawn.js +777 -62
- package/node_modules/pi-lens/dist/clients/security-scan-client.js +2 -1
- package/node_modules/pi-lens/dist/clients/session-state-store.js +3 -2
- package/node_modules/pi-lens/dist/clients/sg-runner.js +284 -174
- package/node_modules/pi-lens/dist/clients/slow-fs.js +2 -1
- package/node_modules/pi-lens/dist/clients/smells-rollup.js +224 -0
- package/node_modules/pi-lens/dist/clients/source-filter.js +184 -20
- package/node_modules/pi-lens/dist/clients/source-walker.js +66 -10
- package/node_modules/pi-lens/dist/clients/startup-scan.js +15 -16
- package/node_modules/pi-lens/dist/clients/startup-timing.js +1 -1
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +38 -8
- package/node_modules/pi-lens/dist/clients/tool-event.js +35 -0
- package/node_modules/pi-lens/dist/clients/tool-policy.js +388 -39
- package/node_modules/pi-lens/dist/clients/tool-render.js +155 -0
- package/node_modules/pi-lens/dist/clients/tree-sitter-cache.js +6 -1
- package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +419 -50
- package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +21 -0
- package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +7 -1
- package/node_modules/pi-lens/dist/clients/tree-sitter-shared.js +7 -2
- package/node_modules/pi-lens/dist/clients/tree-sitter-symbol-extractor.js +44 -7
- package/node_modules/pi-lens/dist/clients/user-notify.js +51 -0
- package/node_modules/pi-lens/dist/clients/vanished-instance-marker.js +57 -0
- package/node_modules/pi-lens/dist/clients/warm-attach.js +33 -13
- package/node_modules/pi-lens/dist/clients/widget-state.js +300 -43
- package/node_modules/pi-lens/dist/clients/word-index.js +391 -64
- package/node_modules/pi-lens/dist/clients/workspace-topology.js +89 -6
- package/node_modules/pi-lens/dist/index.js +49361 -36888
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +182 -29
- package/node_modules/pi-lens/dist/mcp/server.js +211 -44
- package/node_modules/pi-lens/dist/tools/ast-grep-search.js +93 -27
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +200 -36
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +153 -40
- package/node_modules/pi-lens/dist/tools/lsp-navigation.js +46 -3
- package/node_modules/pi-lens/dist/tools/module-report.js +9 -0
- package/node_modules/pi-lens/docs/agent-guide.md +2 -2
- package/node_modules/pi-lens/docs/agent-tools.md +21 -10
- package/node_modules/pi-lens/docs/analysisall.md +192 -0
- package/node_modules/pi-lens/docs/api-ports-inventory.md +165 -0
- package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +5 -2
- package/node_modules/pi-lens/docs/durable-store-audit-1202.md +32 -0
- package/node_modules/pi-lens/docs/environment-variables.md +44 -0
- package/node_modules/pi-lens/docs/fable.md +27 -0
- package/node_modules/pi-lens/docs/features.md +31 -2
- package/node_modules/pi-lens/docs/globalconfig.md +45 -1
- package/node_modules/pi-lens/docs/language-coverage.md +4 -3
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +2 -2
- package/node_modules/pi-lens/docs/mcp.md +37 -4
- package/node_modules/pi-lens/docs/servercapabilities.md +3 -3
- package/node_modules/pi-lens/docs/settings.md +12 -1
- package/node_modules/pi-lens/docs/tools.md +4 -1
- package/node_modules/pi-lens/docs/usage.md +18 -0
- package/node_modules/pi-lens/package.json +10 -10
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-bare-except-test.yml +49 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-bare-host-path-in-win32-branch-test.yml +87 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-nested-links-test.yml +11 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-raw-json-store-write-test.yml +17 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-win32-isabsolute-for-qualification-test.yml +16 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-bare-except.yml +3 -15
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-bare-host-path-in-win32-branch.yml +25 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-nested-links.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-raw-json-store-write.yml +30 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-win32-isabsolute-for-qualification.yml +23 -0
- package/node_modules/pi-lens/rules/tree-sitter-queries/tsx/no-nested-links.yml +4 -6
- package/node_modules/pi-lens/rules/tree-sitter-queries/typescript/duplicate-function-arg.yml +2 -2
- package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +55 -2
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +25 -0
- package/node_modules/pi-mcp-adapter/README.md +34 -3
- package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +1 -1
- package/node_modules/pi-mcp-adapter/commands.ts +15 -7
- package/node_modules/pi-mcp-adapter/direct-tools.ts +54 -7
- package/node_modules/pi-mcp-adapter/host-html-template.ts +0 -8
- package/node_modules/pi-mcp-adapter/index.ts +8 -3
- package/node_modules/pi-mcp-adapter/init.ts +29 -5
- package/node_modules/pi-mcp-adapter/lifecycle.ts +0 -4
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +1 -2
- package/node_modules/pi-mcp-adapter/mcp-auth.ts +60 -2
- package/node_modules/pi-mcp-adapter/mcp-panel.ts +45 -9
- package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +22 -20
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +27 -4
- package/node_modules/pi-mcp-adapter/npx-resolver.ts +81 -26
- package/node_modules/pi-mcp-adapter/package.json +3 -3
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +108 -26
- package/node_modules/pi-mcp-adapter/search-ranking.ts +86 -7
- package/node_modules/pi-mcp-adapter/server-manager.ts +36 -7
- package/node_modules/pi-mcp-adapter/session-recovery.ts +8 -2
- package/node_modules/pi-mcp-adapter/tool-approval.ts +48 -7
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +42 -4
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +138 -12
- package/node_modules/pi-mcp-adapter/types.ts +93 -27
- package/node_modules/pi-mcp-adapter/ui-server.ts +20 -1
- package/package.json +17 -13
- package/node_modules/pi-lens/dist/clients/ast-grep-parser.js +0 -86
- package/node_modules/pi-lens/dist/clients/lsp/interactive-install.js +0 -367
- package/node_modules/pi-lens/dist/clients/lsp/lsp-index.js +0 -10
- package/node_modules/pi-lens/dist/clients/lsp/server-strategies.js +0 -5
- package/node_modules/pi-lens/dist/clients/project-metadata.js +0 -690
- package/node_modules/pi-lens/dist/clients/source-groups.js +0 -96
- package/node_modules/pi-lens/dist/clients/startup-marker.js +0 -6
- package/node_modules/pi-lens/dist/clients/types.js +0 -11
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { normalizeColor } from "../colors.js";
|
|
2
|
+
import type { WidgetOptions } from "../types.js";
|
|
3
|
+
import type { WidgetProperty, WidgetPropertyDefault, WidgetSpec } from "./types.js";
|
|
4
|
+
|
|
5
|
+
const SYSTEM_BASE_OPTION_DEFAULTS = {
|
|
6
|
+
raw: false,
|
|
7
|
+
hideWhenEmpty: false,
|
|
8
|
+
hideWhenZero: false,
|
|
9
|
+
text: "-",
|
|
10
|
+
icon: "",
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
// The options-relevant slice of a spec, derived from WidgetSpec (excludes render so concrete
|
|
14
|
+
// widget specs stay assignable — render's generic params make the full spec invariant).
|
|
15
|
+
type WidgetOptionsSpec = Pick<
|
|
16
|
+
WidgetSpec,
|
|
17
|
+
"baseOptions" | "baseOptionDefaults" | "properties" | "defaultStyle" | "createOptionDefaults"
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export function defaultOptionsFromSpec(spec: WidgetOptionsSpec): WidgetOptions {
|
|
21
|
+
const base: WidgetOptions = {};
|
|
22
|
+
|
|
23
|
+
for (const option of spec.baseOptions) {
|
|
24
|
+
const optionId: string = option;
|
|
25
|
+
base[optionId] = SYSTEM_BASE_OPTION_DEFAULTS[option];
|
|
26
|
+
}
|
|
27
|
+
Object.assign(base, spec.baseOptionDefaults ?? {});
|
|
28
|
+
|
|
29
|
+
for (const property of spec.properties) {
|
|
30
|
+
base[property.id] = property.default;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const dynamicDefaults = spec.createOptionDefaults?.();
|
|
34
|
+
if (dynamicDefaults) Object.assign(base, dynamicDefaults);
|
|
35
|
+
|
|
36
|
+
if (spec.defaultStyle.fg !== undefined) base.fg = spec.defaultStyle.fg;
|
|
37
|
+
if (spec.defaultStyle.bg !== undefined) base.bg = spec.defaultStyle.bg;
|
|
38
|
+
if (spec.defaultStyle.bold !== undefined) base.bold = spec.defaultStyle.bold;
|
|
39
|
+
|
|
40
|
+
return base;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function sanitizeOptionsFromSpec(
|
|
44
|
+
spec: WidgetOptionsSpec,
|
|
45
|
+
input: Record<string, unknown>,
|
|
46
|
+
): WidgetOptions {
|
|
47
|
+
const defaults = defaultOptionsFromSpec(spec);
|
|
48
|
+
const merged: Record<string, unknown> = { ...defaults, ...input };
|
|
49
|
+
const next: WidgetOptions = {};
|
|
50
|
+
|
|
51
|
+
for (const option of spec.baseOptions) {
|
|
52
|
+
if (!(option in defaults)) continue;
|
|
53
|
+
const optionId: string = option;
|
|
54
|
+
next[optionId] = sanitizeMetadataValue(merged[optionId], defaults[optionId]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const fg = normalizeColor(merged.fg);
|
|
58
|
+
if (fg) next.fg = fg;
|
|
59
|
+
const bg = normalizeColor(merged.bg);
|
|
60
|
+
if (bg) next.bg = bg;
|
|
61
|
+
next.bold = typeof merged.bold === "boolean" ? merged.bold : Boolean(defaults.bold);
|
|
62
|
+
|
|
63
|
+
for (const property of spec.properties) {
|
|
64
|
+
next[property.id] = sanitizeWidgetProperty(property, merged[property.id]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return next;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function sanitizeWidgetProperty(
|
|
71
|
+
property: WidgetProperty,
|
|
72
|
+
value: unknown,
|
|
73
|
+
): string | number | boolean {
|
|
74
|
+
switch (property.kind) {
|
|
75
|
+
case "boolean":
|
|
76
|
+
return typeof value === "boolean" ? value : property.default;
|
|
77
|
+
case "number":
|
|
78
|
+
return sanitizeMetadataNumber(
|
|
79
|
+
value,
|
|
80
|
+
property.default,
|
|
81
|
+
property.options?.min,
|
|
82
|
+
property.options?.max,
|
|
83
|
+
);
|
|
84
|
+
case "text":
|
|
85
|
+
if (
|
|
86
|
+
property.id === "warningFg" ||
|
|
87
|
+
property.id === "warningBg" ||
|
|
88
|
+
property.id === "dangerFg" ||
|
|
89
|
+
property.id === "dangerBg"
|
|
90
|
+
)
|
|
91
|
+
return normalizeColor(value) ?? property.default;
|
|
92
|
+
return typeof value === "string" ? value : property.default;
|
|
93
|
+
case "choice": {
|
|
94
|
+
const choices = property.options?.choices ?? [];
|
|
95
|
+
return typeof value === "string" && choices.some((choice) => choice.id === value)
|
|
96
|
+
? value
|
|
97
|
+
: property.default;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function sanitizeMetadataValue(
|
|
103
|
+
value: unknown,
|
|
104
|
+
defaultValue: WidgetOptions[keyof WidgetOptions],
|
|
105
|
+
): WidgetOptions[keyof WidgetOptions] {
|
|
106
|
+
if (typeof defaultValue === "boolean") return typeof value === "boolean" ? value : defaultValue;
|
|
107
|
+
if (typeof defaultValue === "number")
|
|
108
|
+
return typeof value === "number" && Number.isInteger(value) ? value : defaultValue;
|
|
109
|
+
if (typeof defaultValue === "string") return typeof value === "string" ? value : defaultValue;
|
|
110
|
+
return defaultValue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function sanitizeMetadataNumber(
|
|
114
|
+
value: unknown,
|
|
115
|
+
defaultValue: WidgetPropertyDefault,
|
|
116
|
+
min = Number.NEGATIVE_INFINITY,
|
|
117
|
+
max = Number.POSITIVE_INFINITY,
|
|
118
|
+
): number {
|
|
119
|
+
const numberValue = typeof value === "number" && Number.isInteger(value) ? value : defaultValue;
|
|
120
|
+
const safeNumber = typeof numberValue === "number" ? numberValue : 0;
|
|
121
|
+
return Math.min(max, Math.max(min, safeNumber));
|
|
122
|
+
}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { readdir } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
import type { ColorName } from "../../colors.js";
|
|
5
|
+
import { CACHE_NAMESPACES, asyncCache } from "../../cache.js";
|
|
6
|
+
import type { WidgetIconSet } from "../types.js";
|
|
7
|
+
import { defineWidget } from "../types.js";
|
|
8
|
+
|
|
9
|
+
const VERSION_TIMEOUT_MS = 1_000;
|
|
10
|
+
const RUNTIME_CACHE_TTL_MS = 10_000;
|
|
11
|
+
|
|
12
|
+
interface VersionCommand {
|
|
13
|
+
command: string;
|
|
14
|
+
args: readonly string[];
|
|
15
|
+
parse: (output: string) => string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface RuntimeDefinition<TName extends string = string> {
|
|
19
|
+
name: TName;
|
|
20
|
+
files: readonly string[];
|
|
21
|
+
matchesEntry?: (entry: CwdEntry) => boolean;
|
|
22
|
+
versionCommands: readonly VersionCommand[];
|
|
23
|
+
icons: WidgetIconSet;
|
|
24
|
+
color: ColorName;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface CwdEntry {
|
|
28
|
+
name: string;
|
|
29
|
+
isFile: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const RUNTIME_DEFINITIONS = [
|
|
33
|
+
{
|
|
34
|
+
name: "bun",
|
|
35
|
+
files: ["bun.lock", "bun.lockb"],
|
|
36
|
+
versionCommands: [
|
|
37
|
+
{
|
|
38
|
+
command: "bun",
|
|
39
|
+
args: ["--version"],
|
|
40
|
+
parse: (output) => /\bv?([0-9][^\s]*)/i.exec(output)?.[1],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
icons: { emoji: "🥟", nerd: "", text: "" },
|
|
44
|
+
color: "pi:warning",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "deno",
|
|
48
|
+
files: ["deno.json", "deno.jsonc", "deno.lock"],
|
|
49
|
+
versionCommands: [
|
|
50
|
+
{
|
|
51
|
+
command: "deno",
|
|
52
|
+
args: ["--version"],
|
|
53
|
+
parse: (output) => /deno\s+([0-9][^\s]*)/i.exec(output)?.[1],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
icons: { emoji: "🦕", nerd: "", text: "" },
|
|
57
|
+
color: "pi:syntaxType",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "lua",
|
|
61
|
+
files: ["stylua.toml", ".stylua.toml", ".luarc.json", ".luarc.jsonc", "init.lua"],
|
|
62
|
+
matchesEntry: (entry) => entry.name === "lua" || (entry.isFile && entry.name.endsWith(".lua")),
|
|
63
|
+
versionCommands: [
|
|
64
|
+
{ command: "lua", args: ["-v"], parse: (output) => /Lua\s+([0-9][^\s]*)/i.exec(output)?.[1] },
|
|
65
|
+
{
|
|
66
|
+
command: "luajit",
|
|
67
|
+
args: ["-v"],
|
|
68
|
+
parse: (output) => /LuaJIT\s+([0-9][^\s]*)/i.exec(output)?.[1],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
icons: { emoji: "🌙", nerd: "", text: "" },
|
|
72
|
+
color: "pi:accent",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "node",
|
|
76
|
+
files: ["package.json", ".nvmrc", ".node-version"],
|
|
77
|
+
versionCommands: [
|
|
78
|
+
{
|
|
79
|
+
command: "node",
|
|
80
|
+
args: ["--version"],
|
|
81
|
+
parse: (output) => /\bv?([0-9][^\s]*)/i.exec(output)?.[1],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
icons: { emoji: "⬢", nerd: "", text: "" },
|
|
85
|
+
color: "pi:success",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "python",
|
|
89
|
+
files: [
|
|
90
|
+
"pyproject.toml",
|
|
91
|
+
"requirements.txt",
|
|
92
|
+
"setup.py",
|
|
93
|
+
"setup.cfg",
|
|
94
|
+
"Pipfile",
|
|
95
|
+
".python-version",
|
|
96
|
+
],
|
|
97
|
+
versionCommands: [
|
|
98
|
+
{
|
|
99
|
+
command: "python3",
|
|
100
|
+
args: ["--version"],
|
|
101
|
+
parse: (output) => /Python\s+([0-9][^\s]*)/i.exec(output)?.[1],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
command: "python",
|
|
105
|
+
args: ["--version"],
|
|
106
|
+
parse: (output) => /Python\s+([0-9][^\s]*)/i.exec(output)?.[1],
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
icons: { emoji: "🐍", nerd: "", text: "" },
|
|
110
|
+
color: "pi:warning",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "go",
|
|
114
|
+
files: ["go.mod"],
|
|
115
|
+
versionCommands: [
|
|
116
|
+
{
|
|
117
|
+
command: "go",
|
|
118
|
+
args: ["version"],
|
|
119
|
+
parse: (output) => /go version go([0-9][^\s]*)/i.exec(output)?.[1],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
icons: { emoji: "🐹", nerd: "", text: "" },
|
|
123
|
+
color: "pi:syntaxType",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "rust",
|
|
127
|
+
files: ["Cargo.toml"],
|
|
128
|
+
versionCommands: [
|
|
129
|
+
{
|
|
130
|
+
command: "rustc",
|
|
131
|
+
args: ["--version"],
|
|
132
|
+
parse: (output) => /rustc\s+([0-9][^\s]*)/i.exec(output)?.[1],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
icons: { emoji: "🦀", nerd: "", text: "" },
|
|
136
|
+
color: "pi:error",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "java",
|
|
140
|
+
files: ["pom.xml", "build.gradle", "build.gradle.kts"],
|
|
141
|
+
versionCommands: [
|
|
142
|
+
{
|
|
143
|
+
command: "java",
|
|
144
|
+
args: ["-version"],
|
|
145
|
+
parse: (output) => /(?:openjdk|java)\s+version\s+"?([0-9][^"\s]*)/i.exec(output)?.[1],
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
icons: { emoji: "☕", nerd: "", text: "" },
|
|
149
|
+
color: "pi:warning",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "ruby",
|
|
153
|
+
files: ["Gemfile", ".ruby-version"],
|
|
154
|
+
versionCommands: [
|
|
155
|
+
{
|
|
156
|
+
command: "ruby",
|
|
157
|
+
args: ["--version"],
|
|
158
|
+
parse: (output) => /ruby\s+([0-9][^\s]*)/i.exec(output)?.[1],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
icons: { emoji: "💎", nerd: "", text: "" },
|
|
162
|
+
color: "pi:error",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "php",
|
|
166
|
+
files: ["composer.json"],
|
|
167
|
+
versionCommands: [
|
|
168
|
+
{
|
|
169
|
+
command: "php",
|
|
170
|
+
args: ["--version"],
|
|
171
|
+
parse: (output) => /PHP\s+([0-9][^\s]*)/i.exec(output)?.[1],
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
icons: { emoji: "🐘", nerd: "", text: "" },
|
|
175
|
+
color: "pi:accent",
|
|
176
|
+
},
|
|
177
|
+
] as const satisfies readonly RuntimeDefinition[];
|
|
178
|
+
|
|
179
|
+
export type RuntimeName = (typeof RUNTIME_DEFINITIONS)[number]["name"];
|
|
180
|
+
|
|
181
|
+
interface RuntimeInfo {
|
|
182
|
+
name: RuntimeName;
|
|
183
|
+
version?: string;
|
|
184
|
+
icons: WidgetIconSet;
|
|
185
|
+
color: ColorName;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface RuntimeDetection {
|
|
189
|
+
cwd: string;
|
|
190
|
+
displayVersion: boolean;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export const RuntimeWidget = defineWidget({
|
|
194
|
+
type: "runtime",
|
|
195
|
+
label: "Runtime",
|
|
196
|
+
category: "Project",
|
|
197
|
+
description: "Current project runtime (e.g. Bun, Python, Go, Rust)",
|
|
198
|
+
dependencies: ["cwd"],
|
|
199
|
+
baseOptions: ["raw", "hideWhenEmpty", "icon", "text"],
|
|
200
|
+
baseOptionDefaults: { hideWhenEmpty: true },
|
|
201
|
+
properties: [
|
|
202
|
+
{
|
|
203
|
+
id: "style",
|
|
204
|
+
label: "Style",
|
|
205
|
+
kind: "choice",
|
|
206
|
+
description: "Display style",
|
|
207
|
+
default: "compact",
|
|
208
|
+
options: {
|
|
209
|
+
choices: [
|
|
210
|
+
{ id: "default", label: "Default", list: "default" },
|
|
211
|
+
{ id: "compact", label: "Compact", list: "compact" },
|
|
212
|
+
],
|
|
213
|
+
showInWidgets: true,
|
|
214
|
+
showInColors: false,
|
|
215
|
+
listProperty: "style",
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
id: "displayVersion",
|
|
220
|
+
label: "Display version",
|
|
221
|
+
kind: "boolean",
|
|
222
|
+
description: "Show runtime version",
|
|
223
|
+
default: true,
|
|
224
|
+
options: {
|
|
225
|
+
label: "with-version",
|
|
226
|
+
showInWidgets: true,
|
|
227
|
+
showInColors: true,
|
|
228
|
+
listProperty: "",
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
icons: { emoji: "⚙️", nerd: "", text: "runtime" },
|
|
233
|
+
defaultStyle: { fg: "default", bg: "default", bold: false },
|
|
234
|
+
render({ ctx, options, renderWidget }) {
|
|
235
|
+
const cwd = ctx.cwd;
|
|
236
|
+
if (cwd.length === 0) return renderWidget("");
|
|
237
|
+
|
|
238
|
+
const info = asyncCache.get(
|
|
239
|
+
CACHE_NAMESPACES.runtime,
|
|
240
|
+
`${cwd}:${options.displayVersion ? "version" : "no-version"}`,
|
|
241
|
+
RUNTIME_CACHE_TTL_MS,
|
|
242
|
+
{ cwd, displayVersion: options.displayVersion },
|
|
243
|
+
detectRuntime,
|
|
244
|
+
ctx.requestRender,
|
|
245
|
+
);
|
|
246
|
+
if (!info) return renderWidget("", { icons: { emoji: "", nerd: "", text: "" } });
|
|
247
|
+
|
|
248
|
+
return renderWidget(renderRuntimeValue(info, options.displayVersion, options.style), {
|
|
249
|
+
icons: info.icons,
|
|
250
|
+
fg: options.fg && options.fg !== "default" ? options.fg : info.color,
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
function renderRuntimeValue(
|
|
256
|
+
info: RuntimeInfo,
|
|
257
|
+
displayVersion: boolean,
|
|
258
|
+
style: "default" | "compact",
|
|
259
|
+
) {
|
|
260
|
+
if (!displayVersion || !info.version) return info.name;
|
|
261
|
+
if (style === "compact") return compactRuntimeVersion(info.name, info.version);
|
|
262
|
+
return `${info.name} ${info.version}`;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function prefixRuntimeVersion(version: string) {
|
|
266
|
+
const trimmed = version.trim();
|
|
267
|
+
if (!trimmed) return trimmed;
|
|
268
|
+
return trimmed.toLowerCase().startsWith("v") ? trimmed : `v${trimmed}`;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function compactRuntimeVersion(name: RuntimeName, version: string) {
|
|
272
|
+
const prefixed = prefixRuntimeVersion(version);
|
|
273
|
+
const match = /^v([0-9]+)(?:\.([0-9]+))?/i.exec(prefixed);
|
|
274
|
+
if (!match) return prefixed;
|
|
275
|
+
|
|
276
|
+
const major = match[1] ?? "";
|
|
277
|
+
const minor = match[2];
|
|
278
|
+
if ((name === "python" || name === "go" || name === "bun") && minor !== undefined)
|
|
279
|
+
return `v${major}.${minor}`;
|
|
280
|
+
return `v${major}`;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async function detectRuntime({
|
|
284
|
+
cwd,
|
|
285
|
+
displayVersion,
|
|
286
|
+
}: RuntimeDetection): Promise<RuntimeInfo | null> {
|
|
287
|
+
const entries = await readCwdEntries(cwd);
|
|
288
|
+
if (!entries) return null;
|
|
289
|
+
|
|
290
|
+
for (const definition of RUNTIME_DEFINITIONS) {
|
|
291
|
+
if (!matchesRuntime(definition, entries)) continue;
|
|
292
|
+
|
|
293
|
+
const version = displayVersion ? await detectVersion(definition) : undefined;
|
|
294
|
+
return version
|
|
295
|
+
? {
|
|
296
|
+
name: definition.name,
|
|
297
|
+
version,
|
|
298
|
+
icons: definition.icons,
|
|
299
|
+
color: definition.color,
|
|
300
|
+
}
|
|
301
|
+
: {
|
|
302
|
+
name: definition.name,
|
|
303
|
+
icons: definition.icons,
|
|
304
|
+
color: definition.color,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async function readCwdEntries(cwd: string) {
|
|
312
|
+
try {
|
|
313
|
+
const entries = await readdir(cwd, { withFileTypes: true });
|
|
314
|
+
return entries.map((entry) => ({ name: entry.name, isFile: entry.isFile() }));
|
|
315
|
+
} catch {
|
|
316
|
+
return undefined;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function matchesRuntime(definition: RuntimeDefinition, entries: readonly CwdEntry[]) {
|
|
321
|
+
if (hasAnyFile(entries, definition.files)) return true;
|
|
322
|
+
return definition.matchesEntry
|
|
323
|
+
? entries.some((entry) => definition.matchesEntry?.(entry) === true)
|
|
324
|
+
: false;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function hasAnyFile(entries: readonly CwdEntry[], files: readonly string[]) {
|
|
328
|
+
const fileNames = new Set(entries.filter((entry) => entry.isFile).map((entry) => entry.name));
|
|
329
|
+
return files.some((file) => fileNames.has(file));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async function detectVersion(definition: RuntimeDefinition) {
|
|
333
|
+
for (const command of definition.versionCommands) {
|
|
334
|
+
const version = await runVersion(command);
|
|
335
|
+
if (version) return version;
|
|
336
|
+
}
|
|
337
|
+
return undefined;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async function runVersion(versionCommand: VersionCommand) {
|
|
341
|
+
return new Promise<string | undefined>((resolve) => {
|
|
342
|
+
execFile(
|
|
343
|
+
versionCommand.command,
|
|
344
|
+
[...versionCommand.args],
|
|
345
|
+
{ encoding: "utf8", timeout: VERSION_TIMEOUT_MS, windowsHide: true },
|
|
346
|
+
(error, stdout, stderr) => {
|
|
347
|
+
const output = `${stringOutput(stdout)}\n${stringOutput(stderr)}`;
|
|
348
|
+
if (error && output.trim().length === 0) {
|
|
349
|
+
resolve(undefined);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const parsed = versionCommand.parse(output);
|
|
353
|
+
resolve(parsed ? prefixRuntimeVersion(parsed) : undefined);
|
|
354
|
+
},
|
|
355
|
+
);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function stringOutput(value: string | Buffer) {
|
|
360
|
+
return typeof value === "string" ? value : value.toString("utf8");
|
|
361
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { WidgetEntry, WidgetOptions } from "../types.js";
|
|
2
|
+
import { ActiveToolsWidget } from "./core/active-tools.js";
|
|
3
|
+
import { ContextWindowWidget } from "./core/context-window.js";
|
|
4
|
+
import { CwdBasenameWidget } from "./core/cwd-basename.js";
|
|
5
|
+
import { CwdWidget } from "./core/cwd.js";
|
|
6
|
+
import { EventValueWidget } from "./core/event.js";
|
|
7
|
+
import { ExtensionStatusWidget } from "./core/external-status.js";
|
|
8
|
+
import { ModelProviderWidget } from "./core/model-provider.js";
|
|
9
|
+
import { ModelWidget } from "./core/model.js";
|
|
10
|
+
import { ProviderWidget } from "./core/provider.js";
|
|
11
|
+
import { SessionNameWidget } from "./core/session-name.js";
|
|
12
|
+
import { TextVerbosityWidget } from "./core/text-verbosity.js";
|
|
13
|
+
import { ThinkingLevelWidget } from "./core/thinking-level.js";
|
|
14
|
+
import { GitAheadBehindWidget } from "./git/ahead-behind.js";
|
|
15
|
+
import { GitBranchWidget } from "./git/branch.js";
|
|
16
|
+
import { GitCleanStatusWidget } from "./git/clean.js";
|
|
17
|
+
import { GitDeletionsWidget } from "./git/deletions.js";
|
|
18
|
+
import { GitDiffWidget } from "./git/diff.js";
|
|
19
|
+
import { GitInsertionsWidget } from "./git/insertions.js";
|
|
20
|
+
import { GitRemoteWidget } from "./git/remote.js";
|
|
21
|
+
import { GitRootDirWidget } from "./git/root.js";
|
|
22
|
+
import { GitShaWidget } from "./git/sha.js";
|
|
23
|
+
import { GitStagedWidget } from "./git/staged.js";
|
|
24
|
+
import { GitStatusWidget } from "./git/status.js";
|
|
25
|
+
import { GitUnstagedWidget } from "./git/unstaged.js";
|
|
26
|
+
import { GitUntrackedWidget } from "./git/untracked.js";
|
|
27
|
+
import { WidgetInstance } from "./instance.js";
|
|
28
|
+
import { CustomTextWidget } from "./layout/custom-text.js";
|
|
29
|
+
import { FlexSeparatorWidget } from "./layout/flex-separator.js";
|
|
30
|
+
import { SeparatorWidget } from "./layout/separator.js";
|
|
31
|
+
import { SpacerWidget } from "./layout/spacer.js";
|
|
32
|
+
import { sanitizeOptionsFromSpec } from "./options.js";
|
|
33
|
+
import { RuntimeWidget } from "./project/runtime.js";
|
|
34
|
+
import { AssistantMessagesWidget } from "./session/assistant-messages.js";
|
|
35
|
+
import { CompactionsWidget } from "./session/compactions.js";
|
|
36
|
+
import { ElapsedWidget } from "./session/elapsed.js";
|
|
37
|
+
import { LastActivityWidget } from "./session/last-activity.js";
|
|
38
|
+
import { MessagesWidget } from "./session/messages.js";
|
|
39
|
+
import { SessionIdWidget } from "./session/session-id.js";
|
|
40
|
+
import { SessionStartWidget } from "./session/session-start.js";
|
|
41
|
+
import { ToolResultsWidget } from "./session/tool-results.js";
|
|
42
|
+
import { TotalMessagesWidget } from "./session/total-messages.js";
|
|
43
|
+
import { TotalTimeWidget } from "./session/total-time.js";
|
|
44
|
+
import { UserMessagesWidget } from "./session/user-messages.js";
|
|
45
|
+
import { CacheHitRateWidget } from "./tokens/cache-hit-rate.js";
|
|
46
|
+
import { CacheReadWidget } from "./tokens/cache-read.js";
|
|
47
|
+
import { CacheWriteWidget } from "./tokens/cache-write.js";
|
|
48
|
+
import { ContextBarWidget } from "./tokens/context-bar.js";
|
|
49
|
+
import { ContextLengthWidget } from "./tokens/context-length.js";
|
|
50
|
+
import { ContextRemainingWidget } from "./tokens/context-remaining.js";
|
|
51
|
+
import { ContextWidget } from "./tokens/context.js";
|
|
52
|
+
import { CostWidget } from "./tokens/cost.js";
|
|
53
|
+
import { InputSpeedWidget } from "./tokens/input-speed.js";
|
|
54
|
+
import { InputTokensWidget } from "./tokens/input-tokens.js";
|
|
55
|
+
import { OutputSpeedWidget } from "./tokens/output-speed.js";
|
|
56
|
+
import { OutputTokensWidget } from "./tokens/output-tokens.js";
|
|
57
|
+
import { TokensWidget } from "./tokens/tokens.js";
|
|
58
|
+
import { TotalSpeedWidget } from "./tokens/total-speed.js";
|
|
59
|
+
import { TotalTokensWidget } from "./tokens/total-tokens.js";
|
|
60
|
+
import type { Widget } from "./types.js";
|
|
61
|
+
|
|
62
|
+
const WIDGETS = [
|
|
63
|
+
ModelWidget,
|
|
64
|
+
ProviderWidget,
|
|
65
|
+
ModelProviderWidget,
|
|
66
|
+
ThinkingLevelWidget,
|
|
67
|
+
TextVerbosityWidget,
|
|
68
|
+
ContextWindowWidget,
|
|
69
|
+
ActiveToolsWidget,
|
|
70
|
+
SessionNameWidget,
|
|
71
|
+
CwdWidget,
|
|
72
|
+
CwdBasenameWidget,
|
|
73
|
+
EventValueWidget,
|
|
74
|
+
ExtensionStatusWidget,
|
|
75
|
+
CustomTextWidget,
|
|
76
|
+
SeparatorWidget,
|
|
77
|
+
SpacerWidget,
|
|
78
|
+
FlexSeparatorWidget,
|
|
79
|
+
RuntimeWidget,
|
|
80
|
+
AssistantMessagesWidget,
|
|
81
|
+
CompactionsWidget,
|
|
82
|
+
ElapsedWidget,
|
|
83
|
+
LastActivityWidget,
|
|
84
|
+
MessagesWidget,
|
|
85
|
+
SessionIdWidget,
|
|
86
|
+
SessionStartWidget,
|
|
87
|
+
ToolResultsWidget,
|
|
88
|
+
TotalMessagesWidget,
|
|
89
|
+
TotalTimeWidget,
|
|
90
|
+
UserMessagesWidget,
|
|
91
|
+
GitAheadBehindWidget,
|
|
92
|
+
GitBranchWidget,
|
|
93
|
+
GitCleanStatusWidget,
|
|
94
|
+
GitDeletionsWidget,
|
|
95
|
+
GitDiffWidget,
|
|
96
|
+
GitInsertionsWidget,
|
|
97
|
+
GitRemoteWidget,
|
|
98
|
+
GitRootDirWidget,
|
|
99
|
+
GitShaWidget,
|
|
100
|
+
GitStagedWidget,
|
|
101
|
+
GitStatusWidget,
|
|
102
|
+
GitUnstagedWidget,
|
|
103
|
+
GitUntrackedWidget,
|
|
104
|
+
ContextBarWidget,
|
|
105
|
+
ContextLengthWidget,
|
|
106
|
+
ContextWidget,
|
|
107
|
+
ContextRemainingWidget,
|
|
108
|
+
CostWidget,
|
|
109
|
+
CacheReadWidget,
|
|
110
|
+
CacheWriteWidget,
|
|
111
|
+
CacheHitRateWidget,
|
|
112
|
+
TokensWidget,
|
|
113
|
+
InputTokensWidget,
|
|
114
|
+
OutputTokensWidget,
|
|
115
|
+
TotalTokensWidget,
|
|
116
|
+
InputSpeedWidget,
|
|
117
|
+
OutputSpeedWidget,
|
|
118
|
+
TotalSpeedWidget,
|
|
119
|
+
] as const;
|
|
120
|
+
|
|
121
|
+
export type WidgetSpecUnion = (typeof WIDGETS)[number];
|
|
122
|
+
export type WidgetType = WidgetSpecUnion["type"];
|
|
123
|
+
export type WidgetCategory = WidgetSpecUnion["category"];
|
|
124
|
+
|
|
125
|
+
export interface WidgetDefinition {
|
|
126
|
+
readonly type: WidgetType;
|
|
127
|
+
readonly label: string;
|
|
128
|
+
readonly category: WidgetCategory;
|
|
129
|
+
readonly description: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface WidgetRegistry {
|
|
133
|
+
readonly specs: readonly WidgetSpecUnion[];
|
|
134
|
+
readonly definitions: readonly WidgetDefinition[];
|
|
135
|
+
readonly types: readonly WidgetType[];
|
|
136
|
+
readonly typeSet: ReadonlySet<WidgetType>;
|
|
137
|
+
|
|
138
|
+
spec(type: WidgetType): WidgetSpecUnion;
|
|
139
|
+
maybeSpec(type: string): WidgetSpecUnion | undefined;
|
|
140
|
+
createEntry(type: WidgetType, options?: Record<string, unknown>): WidgetEntry;
|
|
141
|
+
cloneEntry(entry: WidgetEntry): WidgetEntry;
|
|
142
|
+
normalizeOptions(type: WidgetType, input: Record<string, unknown>): WidgetOptions;
|
|
143
|
+
createWidget(type: WidgetType, options?: Record<string, unknown>): Widget;
|
|
144
|
+
cloneWidget(widget: Widget): Widget;
|
|
145
|
+
hydrateWidget(entry: WidgetEntry): Widget;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function createWidgetRegistry(widgets: readonly WidgetSpecUnion[]): WidgetRegistry {
|
|
149
|
+
const specs = [...widgets];
|
|
150
|
+
const specsByType = new Map<WidgetType, WidgetSpecUnion>(
|
|
151
|
+
specs.map((spec) => [spec.type as WidgetType, spec]),
|
|
152
|
+
);
|
|
153
|
+
const definitions = specs.map(definitionFromWidgetSpec);
|
|
154
|
+
const types = definitions.map((definition) => definition.type);
|
|
155
|
+
const typeSet = new Set<WidgetType>(types);
|
|
156
|
+
|
|
157
|
+
const specFor = (type: WidgetType): WidgetSpecUnion => {
|
|
158
|
+
const spec = specsByType.get(type);
|
|
159
|
+
if (!spec) throw new Error(`Unsupported widget type: ${type}`);
|
|
160
|
+
return spec;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const buildEntry = (
|
|
164
|
+
type: WidgetType,
|
|
165
|
+
options: Record<string, unknown> = {},
|
|
166
|
+
enabled = true,
|
|
167
|
+
): WidgetEntry => ({
|
|
168
|
+
id: `${type}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`,
|
|
169
|
+
type,
|
|
170
|
+
enabled,
|
|
171
|
+
options: sanitizeOptionsFromSpec(specFor(type), options),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
specs,
|
|
176
|
+
definitions,
|
|
177
|
+
types,
|
|
178
|
+
typeSet,
|
|
179
|
+
spec(type) {
|
|
180
|
+
return specFor(type);
|
|
181
|
+
},
|
|
182
|
+
maybeSpec(type) {
|
|
183
|
+
return specsByType.get(type as WidgetType);
|
|
184
|
+
},
|
|
185
|
+
createEntry(type, options = {}) {
|
|
186
|
+
return buildEntry(type, options);
|
|
187
|
+
},
|
|
188
|
+
normalizeOptions(type, input) {
|
|
189
|
+
return sanitizeOptionsFromSpec(specFor(type), input);
|
|
190
|
+
},
|
|
191
|
+
cloneEntry(entry) {
|
|
192
|
+
return buildEntry(entry.type, entry.options, entry.enabled);
|
|
193
|
+
},
|
|
194
|
+
createWidget(type, options = {}) {
|
|
195
|
+
return new WidgetInstance(specFor(type), buildEntry(type, options));
|
|
196
|
+
},
|
|
197
|
+
cloneWidget(widget) {
|
|
198
|
+
return new WidgetInstance(
|
|
199
|
+
specFor(widget.type),
|
|
200
|
+
buildEntry(widget.type, widget.options, widget.enabled),
|
|
201
|
+
);
|
|
202
|
+
},
|
|
203
|
+
hydrateWidget(entry) {
|
|
204
|
+
return new WidgetInstance(specFor(entry.type), {
|
|
205
|
+
id: entry.id,
|
|
206
|
+
type: entry.type,
|
|
207
|
+
enabled: entry.enabled,
|
|
208
|
+
options: { ...entry.options },
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function definitionFromWidgetSpec(spec: WidgetSpecUnion): WidgetDefinition {
|
|
215
|
+
return {
|
|
216
|
+
type: spec.type as WidgetType,
|
|
217
|
+
label: spec.label,
|
|
218
|
+
category: spec.category as WidgetCategory,
|
|
219
|
+
description: spec.description,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export const registry = createWidgetRegistry(WIDGETS);
|