@herbertgao/pi-extensions 2026.8.4 → 2026.8.6
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 +11 -3
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +11 -3
- 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/feature/context.ts +74 -5
- 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 +53 -14
- 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 +18 -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 +20 -4
- 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/fleet-list.ts +15 -6
- 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/@herbertgao/pi-subagents/src/worktree.ts +9 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +2 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +20 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +6 -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 +32 -24
- package/node_modules/@narumitw/pi-btw/package.json +6 -6
- package/node_modules/@narumitw/pi-btw/src/btw.ts +4 -2
- package/node_modules/@narumitw/pi-btw/src/menu.ts +34 -13
- package/node_modules/@narumitw/pi-btw/src/settings.ts +22 -2
- package/node_modules/pi-lens/CHANGELOG.md +2535 -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/advisory-provenance.js +314 -0
- package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +21 -4
- package/node_modules/pi-lens/dist/clients/agent-nudge.js +14 -7
- 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 +136 -24
- 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-events-logger.js +62 -6
- package/node_modules/pi-lens/dist/clients/bus-publish.js +19 -4
- 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/cascade-format.js +57 -2
- 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 +26 -0
- package/node_modules/pi-lens/dist/clients/cooperative-budget.js +42 -0
- package/node_modules/pi-lens/dist/clients/dead-code-client.js +137 -31
- 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 +361 -77
- package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +65 -13
- package/node_modules/pi-lens/dist/clients/diagnostics-publish.js +18 -4
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +176 -29
- 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 +1172 -683
- 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 +47 -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/availability-policy.js +226 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +69 -0
- 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 +473 -42
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +22 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +97 -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 +18 -4
- package/node_modules/pi-lens/dist/clients/durable-store.js +97 -0
- package/node_modules/pi-lens/dist/clients/eval-timestamp.js +17 -0
- package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +94 -3
- package/node_modules/pi-lens/dist/clients/extension-log.js +432 -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/fix-worklog.js +5 -1
- package/node_modules/pi-lens/dist/clients/format-events-publish.js +51 -7
- 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 +678 -11
- package/node_modules/pi-lens/dist/clients/git-tracked-ignore.js +4 -0
- package/node_modules/pi-lens/dist/clients/go-client.js +23 -40
- package/node_modules/pi-lens/dist/clients/govulncheck-client.js +124 -7
- 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 +395 -100
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +142 -172
- package/node_modules/pi-lens/dist/clients/jscpd-client.js +27 -55
- package/node_modules/pi-lens/dist/clients/knip-client.js +58 -42
- 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 +72 -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 +63 -9
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +16 -0
- package/node_modules/pi-lens/dist/clients/lens-map.js +94 -19
- package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +73 -0
- package/node_modules/pi-lens/dist/clients/log-cleanup.js +2 -1
- package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +30 -4
- package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +59 -14
- package/node_modules/pi-lens/dist/clients/lsp/client.js +662 -56
- package/node_modules/pi-lens/dist/clients/lsp/config.js +13 -2
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +115 -0
- package/node_modules/pi-lens/dist/clients/lsp/edits.js +1012 -121
- package/node_modules/pi-lens/dist/clients/lsp/index.js +2025 -800
- 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 +437 -86
- package/node_modules/pi-lens/dist/clients/lsp/tsserver-sync.js +96 -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 +18 -3
- 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 +127 -32
- package/node_modules/pi-lens/dist/clients/mcp/ipc.js +157 -24
- package/node_modules/pi-lens/dist/clients/mcp/session.js +235 -14
- 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/model-provider.js +53 -0
- 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 +76 -15
- 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/fresh-fetch.js +1 -1
- 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/runner-adapters/runner-findings.js +23 -2
- 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/query.js +24 -0
- 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/run-duration.js +55 -0
- package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +257 -77
- package/node_modules/pi-lens/dist/clients/runtime-context.js +129 -12
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +242 -26
- package/node_modules/pi-lens/dist/clients/runtime-session.js +428 -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 +342 -33
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +619 -93
- package/node_modules/pi-lens/dist/clients/rust-client.js +23 -38
- package/node_modules/pi-lens/dist/clients/safe-spawn.js +777 -62
- package/node_modules/pi-lens/dist/clients/security-scan-client.js +90 -6
- package/node_modules/pi-lens/dist/clients/session-state-store.js +3 -2
- package/node_modules/pi-lens/dist/clients/sg-runner.js +424 -196
- package/node_modules/pi-lens/dist/clients/slow-fs.js +2 -1
- package/node_modules/pi-lens/dist/clients/smells-rollup.js +231 -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 +7 -1
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +469 -32
- package/node_modules/pi-lens/dist/clients/tool-event.js +35 -0
- package/node_modules/pi-lens/dist/clients/tool-policy.js +390 -39
- package/node_modules/pi-lens/dist/clients/tool-render.js +155 -0
- package/node_modules/pi-lens/dist/clients/tool-set-policy.js +76 -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 +50 -13
- package/node_modules/pi-lens/dist/clients/widget-state.js +300 -43
- package/node_modules/pi-lens/dist/clients/word-index.js +680 -81
- package/node_modules/pi-lens/dist/clients/workspace-topology.js +89 -6
- package/node_modules/pi-lens/dist/index.js +51785 -36118
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +182 -29
- package/node_modules/pi-lens/dist/mcp/server.js +219 -46
- 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/ast-grep-search.js +93 -27
- package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +5 -2
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +203 -38
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +210 -42
- 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/dist/tools/symbol-search.js +1 -1
- package/node_modules/pi-lens/docs/agent-guide.md +40 -15
- 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 +14 -3
- 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 +45 -3
- package/node_modules/pi-lens/docs/globalconfig.md +56 -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 +18 -1
- package/node_modules/pi-lens/docs/tools.md +4 -1
- package/node_modules/pi-lens/docs/usage.md +41 -5
- package/node_modules/pi-lens/docs/word-index.md +35 -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-chained-type-assertions-test.yml +8 -0
- 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-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-reflect-apply-js-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-apply-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-get-js-test.yml +8 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-get-test.yml +8 -0
- 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-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-chained-type-assertions.yml +21 -0
- 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-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-reflect-apply-js.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-apply.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-get-js.yml +13 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-get.yml +16 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-unknown-laundering.yml +27 -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 +134 -2
- package/node_modules/pi-lens/skills/pi-lens-ast-grep/SKILL.md +10 -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 +8 -114
- package/node_modules/pi-lens/skills/pi-lens-write-ast-grep-rule/reference.md +129 -0
- package/node_modules/pi-lens/skills/pi-lens-write-tree-sitter-rule/SKILL.md +3 -1
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +38 -0
- package/node_modules/pi-mcp-adapter/README.md +38 -4
- package/node_modules/pi-mcp-adapter/agent-dir.ts +12 -4
- package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +1 -1
- package/node_modules/pi-mcp-adapter/cli.js +25 -4
- package/node_modules/pi-mcp-adapter/commands.ts +15 -7
- package/node_modules/pi-mcp-adapter/config.ts +4 -4
- package/node_modules/pi-mcp-adapter/direct-tools.ts +58 -8
- 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/mcp-setup-panel.ts +2 -1
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +37 -4
- package/node_modules/pi-mcp-adapter/npx-resolver.ts +81 -26
- package/node_modules/pi-mcp-adapter/package.json +4 -3
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +108 -26
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +336 -0
- package/node_modules/pi-mcp-adapter/search-ranking.ts +86 -7
- package/node_modules/pi-mcp-adapter/server-manager.ts +41 -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 +62 -4
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +138 -12
- package/node_modules/pi-mcp-adapter/types.ts +176 -27
- package/node_modules/pi-mcp-adapter/ui-server.ts +20 -1
- package/node_modules/pi-web-access/CHANGELOG.md +14 -0
- package/node_modules/pi-web-access/README.md +18 -12
- package/node_modules/pi-web-access/auth-fetch.ts +148 -0
- package/node_modules/pi-web-access/chrome-cookies.ts +110 -23
- package/node_modules/pi-web-access/curator-page.ts +5 -3
- package/node_modules/pi-web-access/curator-server.ts +2 -1
- package/node_modules/pi-web-access/extract.ts +106 -34
- 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 +18 -4
- package/node_modules/pi-web-access/index.ts +120 -48
- package/node_modules/pi-web-access/package.json +2 -2
- package/node_modules/pi-web-access/summary-review.ts +11 -5
- package/node_modules/pi-web-access/youtube-extract.ts +2 -2
- package/package.json +12 -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
|
@@ -96,7 +96,7 @@ function visibleLines(lines: string[]): string[] {
|
|
|
96
96
|
|
|
97
97
|
function stripLeadingStatusIcon(line: string): string {
|
|
98
98
|
return line.replace(
|
|
99
|
-
/^((?:\x1b\[[0-9;]*m|[ \t]|[├└│─])*)(?:\x1b\[[0-9;]*m)*(?:[
|
|
99
|
+
/^((?:\x1b\[[0-9;]*m|[ \t]|[├└│─])*)(?:\x1b\[[0-9;]*m)*(?:[✓✗●○■⬤•·⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏])(?:\x1b\[[0-9;]*m)*\s+/,
|
|
100
100
|
"$1",
|
|
101
101
|
);
|
|
102
102
|
}
|
|
@@ -127,6 +127,10 @@ function stripLeadingSpaces(line: string, count: number): string {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/** 生成一行铺满 width 的 slot 背景行;bgAnsiOverride 可替换背景 ANSI(用于提亮等)。 */
|
|
130
|
+
function panelInnerWidth(width: number): number {
|
|
131
|
+
return Math.max(0, Math.floor(width) - 2);
|
|
132
|
+
}
|
|
133
|
+
|
|
130
134
|
export function paddedBackgroundRow(
|
|
131
135
|
theme: any,
|
|
132
136
|
slot: string,
|
|
@@ -134,9 +138,12 @@ export function paddedBackgroundRow(
|
|
|
134
138
|
width: number,
|
|
135
139
|
bgAnsiOverride?: string,
|
|
136
140
|
): string {
|
|
137
|
-
const
|
|
141
|
+
const safeWidth = Math.max(0, Math.floor(width));
|
|
142
|
+
const leftPadding = safeWidth > 0 ? " " : "";
|
|
143
|
+
const rightPadding = safeWidth > 1 ? " " : "";
|
|
144
|
+
const innerWidth = panelInnerWidth(width);
|
|
138
145
|
const clipped = truncateToWidth(stripBackgroundAnsi(content), innerWidth, "");
|
|
139
|
-
const row =
|
|
146
|
+
const row = `${leftPadding}${clipped}${" ".repeat(Math.max(0, innerWidth - visibleWidth(clipped)))}${rightPadding}`;
|
|
140
147
|
const bgAnsi =
|
|
141
148
|
bgAnsiOverride ||
|
|
142
149
|
(typeof theme?.bg === "function"
|
|
@@ -147,11 +154,10 @@ export function paddedBackgroundRow(
|
|
|
147
154
|
return `${bgAnsi}${stable}\x1b[49m`;
|
|
148
155
|
}
|
|
149
156
|
|
|
150
|
-
function oneLine(value: unknown
|
|
151
|
-
|
|
157
|
+
function oneLine(value: unknown): string {
|
|
158
|
+
return sanitizeToolResultText(String(value ?? ""), 4096)
|
|
152
159
|
.replace(/\s+/g, " ")
|
|
153
160
|
.trim();
|
|
154
|
-
return text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
function humanizeToolName(name: string): string {
|
|
@@ -264,6 +270,10 @@ function toolNameList(tools: any[]): string {
|
|
|
264
270
|
|
|
265
271
|
let nextGroupId = 1;
|
|
266
272
|
|
|
273
|
+
function groupChildWidth(width: number): number {
|
|
274
|
+
return Math.max(1, panelInnerWidth(width));
|
|
275
|
+
}
|
|
276
|
+
|
|
267
277
|
export class ToolGroupComponent extends Container {
|
|
268
278
|
readonly toolCallId = `ccstyle-tool-group-${nextGroupId++}`;
|
|
269
279
|
readonly toolName = "Tool group";
|
|
@@ -311,7 +321,7 @@ export class ToolGroupComponent extends Container {
|
|
|
311
321
|
|
|
312
322
|
/**
|
|
313
323
|
* 展开时按局部行定位内部组件(null = 行属于 group 自身:空行/头行/尾行)。
|
|
314
|
-
* 行数计算与 render
|
|
324
|
+
* 行数计算与 render 保持一致:预留背景 padding、分支和状态前缀后再过滤空行。
|
|
315
325
|
*/
|
|
316
326
|
childAtRow(localRow: number, width: number): { component: any; row: number } | null {
|
|
317
327
|
if (!this._expanded || localRow < 2) return null;
|
|
@@ -319,7 +329,7 @@ export class ToolGroupComponent extends Container {
|
|
|
319
329
|
for (const tool of this.children) {
|
|
320
330
|
let lines: string[] = [];
|
|
321
331
|
try {
|
|
322
|
-
const rendered = tool.render?.(
|
|
332
|
+
const rendered = tool.render?.(groupChildWidth(width));
|
|
323
333
|
if (Array.isArray(rendered)) lines = visibleLines(rendered.map((line) => String(line)));
|
|
324
334
|
} catch {
|
|
325
335
|
lines = [];
|
|
@@ -386,7 +396,7 @@ export class ToolGroupComponent extends Container {
|
|
|
386
396
|
);
|
|
387
397
|
continue;
|
|
388
398
|
}
|
|
389
|
-
const rendered = visibleLines(tool.render(
|
|
399
|
+
const rendered = visibleLines(tool.render(groupChildWidth(width)));
|
|
390
400
|
if (rendered.length) {
|
|
391
401
|
rendered[0] = stripLeadingStatusIcon(rendered[0])
|
|
392
402
|
.replace(/^ +/, "")
|
|
@@ -434,7 +444,7 @@ function ungroup(patch: Patch): void {
|
|
|
434
444
|
}
|
|
435
445
|
}
|
|
436
446
|
|
|
437
|
-
function normalizeGroup(
|
|
447
|
+
function normalizeGroup(group: ToolGroupComponent): void {
|
|
438
448
|
if (group.children.length > 1) return;
|
|
439
449
|
const parent = (group as any)[PARENT_KEY];
|
|
440
450
|
const index = parent?.children?.indexOf(group) ?? -1;
|
|
@@ -565,12 +575,12 @@ export function installToolGrouping(getEnabled: () => boolean): ToolGroupingHook
|
|
|
565
575
|
const group = component?.[PARENT_KEY];
|
|
566
576
|
if (group instanceof ToolGroupComponent && (group as any)[PARENT_KEY] === this) {
|
|
567
577
|
group.removeTool(component);
|
|
568
|
-
normalizeGroup(
|
|
578
|
+
normalizeGroup(group);
|
|
569
579
|
return;
|
|
570
580
|
}
|
|
571
581
|
const result = patch.original.removeChild.call(this, component);
|
|
572
582
|
if (component?.[PARENT_KEY] === this) delete component[PARENT_KEY];
|
|
573
|
-
if (this instanceof ToolGroupComponent) normalizeGroup(
|
|
583
|
+
if (this instanceof ToolGroupComponent) normalizeGroup(this);
|
|
574
584
|
if (component instanceof ToolGroupComponent) {
|
|
575
585
|
for (const tool of component.releaseTools()) delete tool[PARENT_KEY];
|
|
576
586
|
}
|
|
@@ -5,10 +5,8 @@ import { showMoreHintText } from "../show-more-hint.ts";
|
|
|
5
5
|
import { TOOL_LOADING_INTERVAL_MS, toolLoadingIcon } from "../../utils/tool-loading-icon.ts";
|
|
6
6
|
import { sanitizeToolResultText } from "../../utils/tool-result-sanitize.ts";
|
|
7
7
|
|
|
8
|
-
const TOOL_VIEWPORT_WIDTH_RATIO = 0.8;
|
|
9
|
-
|
|
10
8
|
export function toolViewportWidth(width: number): number {
|
|
11
|
-
return Math.max(1, Math.floor(width
|
|
9
|
+
return Math.max(1, Math.floor(width));
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
/** 与默认工具结果相同的一级缩进包装。 */
|
|
@@ -23,7 +21,7 @@ export function insetComponent(component: any): any {
|
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export function oneLine(value: unknown, max =
|
|
24
|
+
export function oneLine(value: unknown, max = 4096): string {
|
|
27
25
|
const text = sanitizeToolResultText(String(value ?? ""))
|
|
28
26
|
.replace(/\s+/g, " ")
|
|
29
27
|
.trim();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herbertgao/pi-cc-extensions",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.55",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A Pi productivity suite with Claude Code-style UI, context inspection, and agent/session references",
|
|
6
6
|
"type": "module",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
},
|
|
70
70
|
"x-upstream": {
|
|
71
71
|
"package": "pi-cc-extensions",
|
|
72
|
-
"version": "0.8.
|
|
72
|
+
"version": "0.8.60",
|
|
73
73
|
"repository": "https://github.com/minuque/pi-cc-extensions",
|
|
74
|
-
"commit": "
|
|
74
|
+
"commit": "268e017acde0b2adb65cefef3c740e37b1aef202"
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#72](https://github.com/HerbertGao/pi-extensions/pull/72) [`5a133d4`](https://github.com/HerbertGao/pi-extensions/commit/5a133d4753532beef884b093638bceacf0545629) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Bypass Git signing for internal worktree preservation commits so interactive signers cannot time out and discard agent changes.
|
|
8
|
+
|
|
9
|
+
- [#73](https://github.com/HerbertGao/pi-extensions/pull/73) [`553f466`](https://github.com/HerbertGao/pi-extensions/commit/553f4662b968cacaf969c1f4e588d29403c54bfc) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Use the primary text color across selected FleetView rows while preserving configured agent badges, and record the reviewed post-0.16.1 upstream range.
|
|
10
|
+
|
|
11
|
+
- [#66](https://github.com/HerbertGao/pi-extensions/pull/66) [`af56b15`](https://github.com/HerbertGao/pi-extensions/commit/af56b159ce7081daf191d12da6afe3155e2b52b0) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Sync the applicable pi-subagents 0.16.1 compatibility fix and advance the reviewed upstream baseline to bb47763 while preserving the local fork behavior.
|
|
12
|
+
|
|
13
|
+
## 0.15.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#45](https://github.com/HerbertGao/pi-extensions/pull/45) [`97bad4e`](https://github.com/HerbertGao/pi-extensions/commit/97bad4e05f7398d9910786e8d614ffd4943cac8c) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Link persisted subagent sessions to their parent Pi session and advance the reviewed upstream baseline to 0.15.1.
|
|
18
|
+
|
|
19
|
+
- [#52](https://github.com/HerbertGao/pi-extensions/pull/52) [`b12ab55`](https://github.com/HerbertGao/pi-extensions/commit/b12ab5597059ff2020e2108f8e8de85ce64e49c7) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Sync the applicable pi-subagents 0.16.0 fixes and advance the reviewed upstream baseline to bcbd602.
|
|
20
|
+
|
|
3
21
|
## 0.15.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herbertgao/pi-subagents",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
4
4
|
"description": "Claude Code-style autonomous subagents for Pi, with HerbertGao-maintained UI extensions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -40,13 +40,17 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"lint": "biome check src/ test/",
|
|
42
42
|
"typecheck": "tsc --noEmit",
|
|
43
|
-
"test": "vitest run"
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:coverage": "vitest run --coverage"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@sinclair/typebox": "^0.34.49",
|
|
47
48
|
"croner": "^10.0.1",
|
|
48
49
|
"nanoid": "^5.0.0"
|
|
49
50
|
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@vitest/coverage-istanbul": "^4.1.10"
|
|
53
|
+
},
|
|
50
54
|
"peerDependencies": {
|
|
51
55
|
"@earendil-works/pi-ai": ">=0.80.0",
|
|
52
56
|
"@earendil-works/pi-coding-agent": ">=0.80.0",
|
|
@@ -64,8 +68,8 @@
|
|
|
64
68
|
},
|
|
65
69
|
"x-upstream": {
|
|
66
70
|
"package": "@tintinweb/pi-subagents",
|
|
67
|
-
"version": "0.
|
|
71
|
+
"version": "0.16.1",
|
|
68
72
|
"repository": "https://github.com/tintinweb/pi-subagents",
|
|
69
|
-
"commit": "
|
|
73
|
+
"commit": "bb47763"
|
|
70
74
|
}
|
|
71
75
|
}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* agent-color.ts — Claude Code-compatible agent name
|
|
2
|
+
* agent-color.ts — Claude Code-compatible agent name badges.
|
|
3
3
|
*
|
|
4
|
-
* Claude Code
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Claude Code renders a subagent's name as a badge: the configured color is the
|
|
5
|
+
* background, the text an inverse foreground. Its eight named colors are
|
|
6
|
+
* reproduced here, along with six-digit hex and the extra palette names Agency
|
|
7
|
+
* Agents uses, so those definitions render as written.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import { getConfig } from "./agent-types.js"
|
|
10
11
|
|
|
11
12
|
const NAMED_AGENT_COLORS: Readonly<Record<string, string>> = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
// Claude Code's eight subagent colors, as its default theme renders them.
|
|
14
|
+
red: "#DC2626",
|
|
15
|
+
blue: "#6A9BCC",
|
|
16
|
+
green: "#16A34A",
|
|
17
|
+
yellow: "#CA8A04",
|
|
18
|
+
purple: "#827DBD",
|
|
19
|
+
orange: "#D97757",
|
|
20
|
+
pink: "#C46686",
|
|
21
|
+
cyan: "#0891B2",
|
|
22
|
+
// Agency Agents palette aliases.
|
|
20
23
|
amber: "#F59E0B",
|
|
21
24
|
teal: "#008080",
|
|
22
25
|
indigo: "#6366F1",
|
|
@@ -34,8 +37,10 @@ const NAMED_AGENT_COLORS: Readonly<Record<string, string>> = {
|
|
|
34
37
|
navy: "#1E3A8A",
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
const CUBE_VALUES = [0, 95, 135, 175, 215, 255]
|
|
40
|
+
const CUBE_VALUES = [0, 95, 135, 175, 215, 255]
|
|
38
41
|
const GRAY_VALUES = Array.from({ length: 24 }, (_, i) => 8 + i * 10)
|
|
42
|
+
const BLACK = { r: 0, g: 0, b: 0 }
|
|
43
|
+
const WHITE = { r: 255, g: 255, b: 255 }
|
|
39
44
|
|
|
40
45
|
type Rgb = { r: number; g: number; b: number }
|
|
41
46
|
type ColorMode = "truecolor" | "256color"
|
|
@@ -72,51 +77,48 @@ function parseHex(hex: string): Rgb {
|
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
best
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
/** Index of the entry in `values` closest to `value`. */
|
|
81
|
+
function nearest(values: readonly number[], value: number): number {
|
|
82
|
+
return values.reduce(
|
|
83
|
+
(best, v, i) =>
|
|
84
|
+
Math.abs(value - v) < Math.abs(value - values[best]) ? i : best,
|
|
85
|
+
0,
|
|
86
|
+
)
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Quantize to the xterm-256 palette the way pi's own theme does, returning both
|
|
91
|
+
* the index to emit and the color the terminal will actually show — badge
|
|
92
|
+
* contrast is judged against the latter.
|
|
93
|
+
*/
|
|
84
94
|
function rgbTo256({ r, g, b }: Rgb): { index: number; rgb: Rgb } {
|
|
85
|
-
const rIndex =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
r
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const dg = g - candidate.g
|
|
96
|
-
const db = b - candidate.b
|
|
97
|
-
return dr * dr * 0.299 + dg * dg * 0.587 + db * db * 0.114
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const gray = Math.round(0.299 * r + 0.587 * g + 0.114 * b)
|
|
101
|
-
let grayIndex = 0
|
|
102
|
-
for (let i = 1; i < GRAY_VALUES.length; i++) {
|
|
103
|
-
if (
|
|
104
|
-
Math.abs(gray - GRAY_VALUES[i]) < Math.abs(gray - GRAY_VALUES[grayIndex])
|
|
105
|
-
)
|
|
106
|
-
grayIndex = i
|
|
107
|
-
}
|
|
108
|
-
const grayRgb = {
|
|
95
|
+
const [rIndex, gIndex, bIndex] = [r, g, b].map((channel) =>
|
|
96
|
+
nearest(CUBE_VALUES, channel),
|
|
97
|
+
)
|
|
98
|
+
const distance = ({ r: cr, g: cg, b: cb }: Rgb) =>
|
|
99
|
+
0.299 * (r - cr) ** 2 + 0.587 * (g - cg) ** 2 + 0.114 * (b - cb) ** 2
|
|
100
|
+
const grayIndex = nearest(
|
|
101
|
+
GRAY_VALUES,
|
|
102
|
+
Math.round(0.299 * r + 0.587 * g + 0.114 * b),
|
|
103
|
+
)
|
|
104
|
+
const gray = {
|
|
109
105
|
r: GRAY_VALUES[grayIndex],
|
|
110
106
|
g: GRAY_VALUES[grayIndex],
|
|
111
107
|
b: GRAY_VALUES[grayIndex],
|
|
112
108
|
}
|
|
109
|
+
const cube = {
|
|
110
|
+
r: CUBE_VALUES[rIndex],
|
|
111
|
+
g: CUBE_VALUES[gIndex],
|
|
112
|
+
b: CUBE_VALUES[bIndex],
|
|
113
|
+
}
|
|
114
|
+
// Only near-neutral colors may take the gray ramp; anything else keeps its tint.
|
|
113
115
|
if (
|
|
114
116
|
Math.max(r, g, b) - Math.min(r, g, b) < 10 &&
|
|
115
|
-
distance(
|
|
117
|
+
distance(gray) < distance(cube)
|
|
116
118
|
) {
|
|
117
|
-
return { index: 232 + grayIndex, rgb:
|
|
119
|
+
return { index: 232 + grayIndex, rgb: gray }
|
|
118
120
|
}
|
|
119
|
-
return { index: 16 + 36 * rIndex + 6 * gIndex + bIndex, rgb:
|
|
121
|
+
return { index: 16 + 36 * rIndex + 6 * gIndex + bIndex, rgb: cube }
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
function ansiColor(
|
|
@@ -140,9 +142,10 @@ function relativeLuminance({ r, g, b }: Rgb): number {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
/**
|
|
143
|
-
* Render one name as a padded background badge when `color` is valid.
|
|
144
|
-
*
|
|
145
|
-
*
|
|
145
|
+
* Render one name as a padded background badge when `color` is valid. Claude
|
|
146
|
+
* Code uses one inverse color for every badge's text; black or white is picked
|
|
147
|
+
* by WCAG contrast here instead, so each palette entry stays readable. Invalid
|
|
148
|
+
* or omitted colors preserve the caller's existing theme styling.
|
|
146
149
|
*/
|
|
147
150
|
export function renderAgentNameLabel(
|
|
148
151
|
name: string,
|
|
@@ -156,32 +159,34 @@ export function renderAgentNameLabel(
|
|
|
156
159
|
return style.fallbackColor ? theme.fg(style.fallbackColor, text) : text
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
effectiveBackground = quantized.rgb
|
|
167
|
-
}
|
|
168
|
-
const foregroundRgb =
|
|
169
|
-
relativeLuminance(effectiveBackground) > 0.179
|
|
170
|
-
? { r: 0, g: 0, b: 0 }
|
|
171
|
-
: { r: 255, g: 255, b: 255 }
|
|
172
|
-
const foreground =
|
|
173
|
-
mode === "256color" ? rgbTo256(foregroundRgb).index : foregroundRgb
|
|
162
|
+
const rgb = parseHex(resolved)
|
|
163
|
+
const quantized =
|
|
164
|
+
(theme.getColorMode?.() ?? "truecolor") === "256color"
|
|
165
|
+
? rgbTo256(rgb)
|
|
166
|
+
: undefined
|
|
167
|
+
const shown = quantized?.rgb ?? rgb
|
|
168
|
+
const contrasting = relativeLuminance(shown) > 0.179 ? BLACK : WHITE
|
|
174
169
|
const label = style.bold ? theme.bold(` ${name} `) : ` ${name} `
|
|
175
170
|
|
|
176
171
|
return (
|
|
177
|
-
ansiColor("background",
|
|
178
|
-
ansiColor(
|
|
172
|
+
ansiColor("background", quantized?.index ?? rgb) +
|
|
173
|
+
ansiColor(
|
|
174
|
+
"foreground",
|
|
175
|
+
quantized ? rgbTo256(contrasting).index : contrasting,
|
|
176
|
+
) +
|
|
179
177
|
label +
|
|
180
178
|
"\u001b[39m" +
|
|
181
179
|
(style.restoreBackground ?? "\u001b[49m")
|
|
182
180
|
)
|
|
183
181
|
}
|
|
184
182
|
|
|
183
|
+
/** Whether an agent renders as a badge — i.e. it has a valid configured color. */
|
|
184
|
+
export function hasAgentBadge(type: string | undefined): boolean {
|
|
185
|
+
return (
|
|
186
|
+
type !== undefined && resolveAgentColor(getConfig(type).color) !== undefined
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
185
190
|
/** Render a registered agent's display name with its configured color. */
|
|
186
191
|
export function renderAgentName(
|
|
187
192
|
type: string | undefined,
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent-file-toggle.ts — Pure helpers for the `/agents` file-editing operations:
|
|
3
|
+
* locating an agent's .md file, toggling its `enabled:` frontmatter flag, and
|
|
4
|
+
* serializing an AgentConfig back to frontmatter for eject.
|
|
5
|
+
*
|
|
6
|
+
* These live outside src/index.ts so they can be tested directly: the `/agents`
|
|
7
|
+
* command handler is an ~890-line closure reached only through `registerCommand`,
|
|
8
|
+
* which every test mocks.
|
|
9
|
+
*
|
|
10
|
+
* The read side of this data (src/custom-agents.ts) parses frontmatter with a
|
|
11
|
+
* real YAML parser, so it honors `enabled: false` at any position in the block.
|
|
12
|
+
* This module must agree with it, and splits the work accordingly:
|
|
13
|
+
*
|
|
14
|
+
* - Deciding whether a file is disabled is a *read*, so it calls that same parser
|
|
15
|
+
* (`isDisabledContent`) instead of mirroring it. A mirror has to be right about
|
|
16
|
+
* YAML's boolean spellings and about pi's fence scan, and a regex was wrong
|
|
17
|
+
* about both.
|
|
18
|
+
* - *Editing* cannot go through the parser, because re-serializing a parsed
|
|
19
|
+
* document would reformat a file the README tells users to hand-author —
|
|
20
|
+
* discarding their comments, key order, and quoting. So the edits are line-wise
|
|
21
|
+
* and preserve everything they don't touch.
|
|
22
|
+
*
|
|
23
|
+
* That leaves removal best-effort: it recognizes the parser's case-insensitive
|
|
24
|
+
* bare `false` spellings and trailing comments, and reports `changed: false`
|
|
25
|
+
* for values it cannot rewrite, so the caller refuses honestly rather than
|
|
26
|
+
* announcing a change it did not make.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { existsSync } from "node:fs"
|
|
30
|
+
import { join } from "node:path"
|
|
31
|
+
import { getAgentDir, parseFrontmatter } from "@earendil-works/pi-coding-agent"
|
|
32
|
+
import type { AgentConfig } from "./types.js"
|
|
33
|
+
|
|
34
|
+
export type AgentFileLocation = "project" | "workspace" | "personal"
|
|
35
|
+
|
|
36
|
+
export const projectAgentsDir = (cwd: string = process.cwd()) =>
|
|
37
|
+
join(cwd, ".pi", "agents")
|
|
38
|
+
export const workspaceAgentsDir = (cwd: string = process.cwd()) =>
|
|
39
|
+
join(cwd, ".agents", "agents")
|
|
40
|
+
export const personalAgentsDir = () => join(getAgentDir(), "agents")
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Find the file path of a custom agent by name, in discovery-precedence order
|
|
44
|
+
* (project, workspace, then global). Mirrors the load-side precedence in
|
|
45
|
+
* src/custom-agents.ts — if the two drift, `/agents` edits a file the loader
|
|
46
|
+
* isn't reading.
|
|
47
|
+
*/
|
|
48
|
+
export function findAgentFile(
|
|
49
|
+
name: string,
|
|
50
|
+
cwd: string = process.cwd(),
|
|
51
|
+
): { path: string; location: AgentFileLocation } | undefined {
|
|
52
|
+
const projectPath = join(projectAgentsDir(cwd), `${name}.md`)
|
|
53
|
+
if (existsSync(projectPath)) return { path: projectPath, location: "project" }
|
|
54
|
+
const workspacePath = join(workspaceAgentsDir(cwd), `${name}.md`)
|
|
55
|
+
if (existsSync(workspacePath))
|
|
56
|
+
return { path: workspacePath, location: "workspace" }
|
|
57
|
+
const personalPath = join(personalAgentsDir(), `${name}.md`)
|
|
58
|
+
if (existsSync(personalPath))
|
|
59
|
+
return { path: personalPath, location: "personal" }
|
|
60
|
+
return undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type DisableOutcome = "disabled" | "already-disabled" | "no-frontmatter"
|
|
64
|
+
|
|
65
|
+
/** A line that sets `enabled: false`, accepting YAML case and comments. */
|
|
66
|
+
const ENABLED_FALSE = /^[ \t]*enabled:[ \t]*false[ \t]*(?:#[^\r\n]*)?$/i
|
|
67
|
+
/** An opening or closing `---` fence line. */
|
|
68
|
+
const FENCE = /^---[ \t]*$/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Split a file into its frontmatter lines and everything else, agreeing with
|
|
72
|
+
* what `parseFrontmatter` (the load side) considers a frontmatter block.
|
|
73
|
+
*
|
|
74
|
+
* Lines keep their terminators, so an edit preserves the file's existing line
|
|
75
|
+
* endings instead of rewriting CRLF to LF. Returns undefined when there is no
|
|
76
|
+
* usable block — notably for a BOM-prefixed file, which the parser also reads
|
|
77
|
+
* as having none, so writing a key into it would change nothing on load.
|
|
78
|
+
*/
|
|
79
|
+
function splitFrontmatter(
|
|
80
|
+
content: string,
|
|
81
|
+
):
|
|
82
|
+
| { lines: string[]; openIdx: number; closeIdx: number; eol: string }
|
|
83
|
+
| undefined {
|
|
84
|
+
const lines = content.split(/(?<=\n)/)
|
|
85
|
+
if (lines.length === 0 || !FENCE.test(lines[0].replace(/\r?\n$/, "")))
|
|
86
|
+
return undefined
|
|
87
|
+
const closeIdx = lines.findIndex(
|
|
88
|
+
(l, i) => i > 0 && FENCE.test(l.replace(/\r?\n$/, "")),
|
|
89
|
+
)
|
|
90
|
+
if (closeIdx === -1) return undefined
|
|
91
|
+
return {
|
|
92
|
+
lines,
|
|
93
|
+
openIdx: 0,
|
|
94
|
+
closeIdx,
|
|
95
|
+
eol: lines[0].endsWith("\r\n") ? "\r\n" : "\n",
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Does the loader consider this file disabled?
|
|
101
|
+
*
|
|
102
|
+
* Detection is a READ operation, so it asks the same parser the loader uses
|
|
103
|
+
* rather than mirroring it with a regex — that mirror has to be right about
|
|
104
|
+
* YAML's boolean spellings (`False`, `FALSE`, a trailing `# comment`, a quoted
|
|
105
|
+
* key) *and* about pi's fence scan, which closes the block on any line starting
|
|
106
|
+
* `---` and so ends it early on `----`. A throw means the file is already
|
|
107
|
+
* unparseable, which is what the loader sees too: it skips the agent, so there
|
|
108
|
+
* is no "disabled" state to report.
|
|
109
|
+
*/
|
|
110
|
+
export function isDisabledContent(content: string): boolean {
|
|
111
|
+
try {
|
|
112
|
+
return (
|
|
113
|
+
parseFrontmatter<Record<string, unknown>>(content).frontmatter.enabled ===
|
|
114
|
+
false
|
|
115
|
+
)
|
|
116
|
+
} catch {
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Add `enabled: false` to a file's frontmatter.
|
|
123
|
+
*
|
|
124
|
+
* `outcome` distinguishes a real edit from a no-op so the caller can report
|
|
125
|
+
* honestly instead of unconditionally claiming success.
|
|
126
|
+
*/
|
|
127
|
+
export function disableInContent(content: string): {
|
|
128
|
+
content: string
|
|
129
|
+
outcome: DisableOutcome
|
|
130
|
+
} {
|
|
131
|
+
const block = splitFrontmatter(content)
|
|
132
|
+
if (!block) return { content, outcome: "no-frontmatter" }
|
|
133
|
+
if (isDisabledContent(content))
|
|
134
|
+
return { content, outcome: "already-disabled" }
|
|
135
|
+
const lines = [...block.lines]
|
|
136
|
+
lines.splice(1, 0, `enabled: false${block.eol}`)
|
|
137
|
+
return { content: lines.join(""), outcome: "disabled" }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Remove `enabled: false` from a file's frontmatter, wherever it appears in the
|
|
142
|
+
* block — the loader honors the key at any position, so the two must agree or a
|
|
143
|
+
* hand-authored agent can be disabled and never re-enabled.
|
|
144
|
+
*
|
|
145
|
+
* `changed` is false when the key wasn't found, so the caller can avoid
|
|
146
|
+
* reporting "Enabled <name>" for a write that did nothing.
|
|
147
|
+
*/
|
|
148
|
+
export function enableInContent(content: string): {
|
|
149
|
+
content: string
|
|
150
|
+
changed: boolean
|
|
151
|
+
} {
|
|
152
|
+
const block = splitFrontmatter(content)
|
|
153
|
+
if (!block) return { content, changed: false }
|
|
154
|
+
const kept = block.lines.filter(
|
|
155
|
+
(l, i) =>
|
|
156
|
+
!(
|
|
157
|
+
i > 0 &&
|
|
158
|
+
i < block.closeIdx &&
|
|
159
|
+
ENABLED_FALSE.test(l.replace(/\r?\n$/, ""))
|
|
160
|
+
),
|
|
161
|
+
)
|
|
162
|
+
if (kept.length === block.lines.length) return { content, changed: false }
|
|
163
|
+
return { content: kept.join(""), changed: true }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Is this the empty stub `/agents` writes when disabling a built-in default? */
|
|
167
|
+
export function isEmptyStub(content: string): boolean {
|
|
168
|
+
return content.replace(/\r\n/g, "\n").trim() === "---\n---"
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The answers `/agents → Create agent → Manual` collects, before serialization. */
|
|
172
|
+
export interface NewAgentInput {
|
|
173
|
+
description: string
|
|
174
|
+
/** Already-resolved `tools:` value ("none", "all", or a CSV of tool names). */
|
|
175
|
+
tools: string
|
|
176
|
+
/** `provider/modelId`, or undefined to inherit the parent's model. */
|
|
177
|
+
model?: string
|
|
178
|
+
/** A pi thinking level, or undefined to inherit. */
|
|
179
|
+
thinking?: string
|
|
180
|
+
systemPrompt: string
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Build the .md file the create wizard writes.
|
|
185
|
+
*
|
|
186
|
+
* `description` and `model` come straight from a free-text prompt, so they are
|
|
187
|
+
* quoted rather than interpolated — `serializeAgentFile` above quotes the
|
|
188
|
+
* description for the same reason. An unquoted YAML scalar mishandles ordinary
|
|
189
|
+
* input in two ways, and both are silent: a colon ("Scout: find things") makes
|
|
190
|
+
* the file unparseable, and since #212 an unparseable agent file is *skipped*,
|
|
191
|
+
* so the wizard reports success for an agent that does not exist; a `#`
|
|
192
|
+
* ("audit #security") opens a comment and truncates the value. `model` can
|
|
193
|
+
* carry a colon too — pi accepts a `provider/model:thinking` suffix.
|
|
194
|
+
*
|
|
195
|
+
* `tools` and `thinking` are not quoted: both are chosen from fixed menus, and
|
|
196
|
+
* `tools` is a CSV that must stay a bare scalar for the loader's parser.
|
|
197
|
+
*/
|
|
198
|
+
export function buildNewAgentFile(input: NewAgentInput): string {
|
|
199
|
+
const modelLine = input.model ? `\nmodel: ${JSON.stringify(input.model)}` : ""
|
|
200
|
+
const thinkingLine = input.thinking ? `\nthinking: ${input.thinking}` : ""
|
|
201
|
+
return `---
|
|
202
|
+
description: ${JSON.stringify(input.description)}
|
|
203
|
+
tools: ${input.tools}${modelLine}${thinkingLine}
|
|
204
|
+
prompt_mode: replace
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
${input.systemPrompt}
|
|
208
|
+
`
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Render a built-in tool list as a `tools:` frontmatter value. */
|
|
212
|
+
function formatToolsField(tools: string[] | undefined): string {
|
|
213
|
+
if (tools === undefined) return "all"
|
|
214
|
+
if (tools.length === 0) return "none"
|
|
215
|
+
return tools.join(", ")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Serialize an AgentConfig to a full .md file (frontmatter + system prompt) for eject. */
|
|
219
|
+
export function serializeAgentFile(cfg: AgentConfig): string {
|
|
220
|
+
const fmFields: string[] = []
|
|
221
|
+
fmFields.push(`description: ${JSON.stringify(cfg.description)}`)
|
|
222
|
+
if (cfg.displayName) fmFields.push(`display_name: ${cfg.displayName}`)
|
|
223
|
+
if (cfg.color) fmFields.push(`color: ${JSON.stringify(cfg.color)}`)
|
|
224
|
+
// Absent means "all built-ins"; an EMPTY list means explicitly zero. Writing
|
|
225
|
+
// `all` for both would hand a deliberately tool-less agent the whole toolbox
|
|
226
|
+
// the first time it is ejected.
|
|
227
|
+
fmFields.push(`tools: ${formatToolsField(cfg.builtinToolNames)}`)
|
|
228
|
+
if (cfg.model) fmFields.push(`model: ${cfg.model}`)
|
|
229
|
+
if (cfg.thinking) fmFields.push(`thinking: ${cfg.thinking}`)
|
|
230
|
+
if (cfg.maxTurns) fmFields.push(`max_turns: ${cfg.maxTurns}`)
|
|
231
|
+
if (cfg.allowedSubagents !== undefined) {
|
|
232
|
+
fmFields.push(
|
|
233
|
+
`allowed_subagents: ${cfg.allowedSubagents === "all" ? "all" : cfg.allowedSubagents.join(", ")}`,
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
fmFields.push(`prompt_mode: ${cfg.promptMode}`)
|
|
237
|
+
if (cfg.extensions === false) fmFields.push("extensions: false")
|
|
238
|
+
else if (Array.isArray(cfg.extensions))
|
|
239
|
+
fmFields.push(`extensions: ${cfg.extensions.join(", ")}`)
|
|
240
|
+
if (cfg.excludeExtensions?.length)
|
|
241
|
+
fmFields.push(`exclude_extensions: ${cfg.excludeExtensions.join(", ")}`)
|
|
242
|
+
if (cfg.skills === false) fmFields.push("skills: false")
|
|
243
|
+
else if (Array.isArray(cfg.skills))
|
|
244
|
+
fmFields.push(`skills: ${cfg.skills.join(", ")}`)
|
|
245
|
+
if (cfg.disallowedTools?.length)
|
|
246
|
+
fmFields.push(`disallowed_tools: ${cfg.disallowedTools.join(", ")}`)
|
|
247
|
+
if (cfg.inheritContext) fmFields.push("inherit_context: true")
|
|
248
|
+
if (cfg.runInBackground) fmFields.push("run_in_background: true")
|
|
249
|
+
if (cfg.outputTranscript === false) fmFields.push("output_transcript: false")
|
|
250
|
+
if (cfg.isolated) fmFields.push("isolated: true")
|
|
251
|
+
if (cfg.memory) fmFields.push(`memory: ${cfg.memory}`)
|
|
252
|
+
if (cfg.isolation) fmFields.push(`isolation: ${cfg.isolation}`)
|
|
253
|
+
|
|
254
|
+
return `---\n${fmFields.join("\n")}\n---\n\n${cfg.systemPrompt}\n`
|
|
255
|
+
}
|