@herbertgao/pi-extensions 2026.9.5 → 2026.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -22
- package/THIRD_PARTY_NOTICES.md +0 -4
- package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +1 -1
- package/node_modules/@herbertgao/sol-pi/package.json +1 -1
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/action-fusion/index.ts +0 -5
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/state.ts +3 -1
- package/node_modules/@narumitw/pi-btw/README.md +2 -0
- package/node_modules/@narumitw/pi-btw/dist/index.ts +284 -365
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +3 -3
- package/node_modules/@narumitw/pi-btw/package.json +52 -53
- package/node_modules/@narumitw/pi-btw/src/bring-to-main.ts +494 -547
- package/node_modules/@narumitw/pi-btw/src/btw.ts +814 -856
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +673 -674
- package/node_modules/@narumitw/pi-btw/src/keybindings.ts +228 -270
- package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +309 -318
- package/node_modules/@narumitw/pi-btw/src/menu.ts +416 -454
- package/node_modules/@narumitw/pi-btw/src/settings.ts +203 -219
- package/node_modules/@narumitw/pi-btw/src/side-thread.ts +173 -201
- package/node_modules/@narumitw/pi-btw/src/text.ts +21 -23
- package/node_modules/@narumitw/pi-btw/src/transcript-markdown.ts +65 -0
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +611 -662
- package/node_modules/pi-lens/CHANGELOG.md +239 -0
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +3 -0
- package/node_modules/pi-lens/dist/clients/actionable-warnings.js +30 -4
- package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +2 -0
- package/node_modules/pi-lens/dist/clients/bash-file-access.js +26 -0
- package/node_modules/pi-lens/dist/clients/biome-client.js +1 -1
- package/node_modules/pi-lens/dist/clients/blocker-freshness.js +403 -35
- package/node_modules/pi-lens/dist/clients/bootstrap.js +6 -1
- package/node_modules/pi-lens/dist/clients/cascade-format.js +200 -4
- package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +10 -2
- package/node_modules/pi-lens/dist/clients/degradation-ledger.js +16 -1
- package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +12 -1
- package/node_modules/pi-lens/dist/clients/dispatch/ast-grep-catalog.js +65 -0
- package/node_modules/pi-lens/dist/clients/dispatch/auxiliary-lsp.js +28 -0
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +9 -2
- package/node_modules/pi-lens/dist/clients/dispatch/finding-policy.js +222 -0
- package/node_modules/pi-lens/dist/clients/dispatch/indent-detect.js +389 -13
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +175 -25
- package/node_modules/pi-lens/dist/clients/dispatch/rule-ignores.js +62 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +21 -41
- package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +6 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +7 -7
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +2 -12
- package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +2 -21
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +1 -1
- package/node_modules/pi-lens/dist/clients/dispatch/types.js +4 -1
- package/node_modules/pi-lens/dist/clients/disposition-publish.js +1 -0
- package/node_modules/pi-lens/dist/clients/effective-config.js +1 -1
- package/node_modules/pi-lens/dist/clients/file-kinds.js +26 -1
- package/node_modules/pi-lens/dist/clients/file-role.js +21 -21
- package/node_modules/pi-lens/dist/clients/file-utils.js +156 -10
- package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +56 -9
- package/node_modules/pi-lens/dist/clients/format-service.js +39 -21
- package/node_modules/pi-lens/dist/clients/formatters.js +60 -13
- package/node_modules/pi-lens/dist/clients/generation-guard.js +2 -2
- package/node_modules/pi-lens/dist/clients/git-guard.js +11 -3
- package/node_modules/pi-lens/dist/clients/indent-retarget.js +78 -8
- package/node_modules/pi-lens/dist/clients/installer/index.js +333 -114
- package/node_modules/pi-lens/dist/clients/instance-reaper-state.js +7 -0
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +20 -10
- package/node_modules/pi-lens/dist/clients/language-profile.js +23 -1
- package/node_modules/pi-lens/dist/clients/language-registry.js +5 -1
- package/node_modules/pi-lens/dist/clients/latency-logger.js +4 -1
- package/node_modules/pi-lens/dist/clients/lens-engine.js +12 -3
- package/node_modules/pi-lens/dist/clients/lens-events.js +2 -1
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +79 -0
- package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +2 -1
- package/node_modules/pi-lens/dist/clients/lsp/client.js +25 -21
- package/node_modules/pi-lens/dist/clients/lsp/config.js +2 -2
- package/node_modules/pi-lens/dist/clients/lsp/index.js +7 -0
- package/node_modules/pi-lens/dist/clients/lsp/launch.js +16 -4
- package/node_modules/pi-lens/dist/clients/lsp/server.js +19 -2
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +2 -1
- package/node_modules/pi-lens/dist/clients/lsp-mutation.js +5 -3
- package/node_modules/pi-lens/dist/clients/map-with-concurrency.js +12 -8
- package/node_modules/pi-lens/dist/clients/mcp/session.js +36 -4
- package/node_modules/pi-lens/dist/clients/ndjson-logger.js +24 -7
- package/node_modules/pi-lens/dist/clients/observed-mutation.js +40 -2
- package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +23 -3
- package/node_modules/pi-lens/dist/clients/opengrep-client.js +110 -15
- package/node_modules/pi-lens/dist/clients/path-utils.js +123 -3
- package/node_modules/pi-lens/dist/clients/performance-report.js +5 -1
- package/node_modules/pi-lens/dist/clients/php-cs-fixer-config.js +1 -1
- package/node_modules/pi-lens/dist/clients/pipeline.js +74 -5
- package/node_modules/pi-lens/dist/clients/project-diagnostics/cache.js +37 -5
- package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +145 -18
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +4 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +59 -3
- package/node_modules/pi-lens/dist/clients/project-lens-config.js +45 -2
- package/node_modules/pi-lens/dist/clients/read-guard.js +70 -11
- package/node_modules/pi-lens/dist/clients/resource-sampler.js +147 -9
- package/node_modules/pi-lens/dist/clients/ruff-client.js +1 -1
- package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +33 -5
- package/node_modules/pi-lens/dist/clients/runtime-context.js +6 -2
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +77 -7
- package/node_modules/pi-lens/dist/clients/runtime-session.js +21 -2
- package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +43 -12
- package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +330 -85
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +147 -17
- package/node_modules/pi-lens/dist/clients/safe-spawn.js +258 -5
- package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +6 -0
- package/node_modules/pi-lens/dist/clients/session-event-guard.js +50 -5
- package/node_modules/pi-lens/dist/clients/sg-runner.js +23 -11
- package/node_modules/pi-lens/dist/clients/sgconfig.js +79 -2
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +6 -41
- package/node_modules/pi-lens/dist/clients/test-runner-delivery.js +43 -0
- package/node_modules/pi-lens/dist/clients/tool-agreement.js +423 -0
- package/node_modules/pi-lens/dist/clients/tool-config.js +50 -0
- package/node_modules/pi-lens/dist/clients/tool-cwd.js +47 -76
- package/node_modules/pi-lens/dist/clients/tool-policy.js +163 -7
- package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +120 -0
- package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +127 -189
- package/node_modules/pi-lens/dist/clients/widget-state.js +98 -0
- package/node_modules/pi-lens/dist/clients/word-index.js +5 -2
- package/node_modules/pi-lens/dist/clients/write-ordering-guard.js +7 -0
- package/node_modules/pi-lens/dist/index.js +27416 -24153
- package/node_modules/pi-lens/dist/mcp/server.js +5 -2
- package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +7 -1
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +168 -53
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +244 -72
- package/node_modules/pi-lens/docs/audit1.md +5 -5
- package/node_modules/pi-lens/docs/dependencies.md +11 -0
- package/node_modules/pi-lens/docs/dispositions.md +52 -0
- package/node_modules/pi-lens/docs/environment-variables.md +2 -2
- package/node_modules/pi-lens/docs/features.md +4 -4
- package/node_modules/pi-lens/docs/globalconfig.md +3 -1
- package/node_modules/pi-lens/docs/language-coverage.md +1 -0
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +53 -94
- package/node_modules/pi-lens/docs/pi-lens-investigator.md +43 -38
- package/node_modules/pi-lens/docs/pi-lens-retro.md +97 -0
- package/node_modules/pi-lens/docs/pi-lens-reviewer.md +53 -66
- package/node_modules/pi-lens/docs/release-qa-baseline.md +22 -0
- package/node_modules/pi-lens/docs/settings.md +7 -4
- package/node_modules/pi-lens/docs/tree-sitter_rules_catalog.md +1 -1
- package/node_modules/pi-lens/docs/usage.md +2 -0
- package/node_modules/pi-lens/package.json +1 -1
- package/node_modules/pi-lens/rules/tree-sitter-queries/typescript/sql-injection.yml +24 -12
- package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +40 -0
- package/node_modules/pi-lens/skills/pi-lens-ast-grep/SKILL.md +15 -0
- package/node_modules/pi-lens/skills/pi-lens-lsp-navigation/SKILL.md +7 -0
- package/package.json +6 -17
- package/examples/pi-footer.json +0 -275
- package/node_modules/@czottmann/pi-automode/CHANGELOG.md +0 -70
- package/node_modules/@czottmann/pi-automode/LICENSE.md +0 -21
- package/node_modules/@czottmann/pi-automode/README.md +0 -215
- package/node_modules/@czottmann/pi-automode/docs/GLOSSARY.md +0 -39
- package/node_modules/@czottmann/pi-automode/docs/adr/ADR-001-permission-precedence-and-trust-boundaries.md +0 -46
- package/node_modules/@czottmann/pi-automode/docs/adr/ADR-002-global-config-in-extension-data-directory.md +0 -60
- package/node_modules/@czottmann/pi-automode/docs/adr/INDEX.md +0 -6
- package/node_modules/@czottmann/pi-automode/docs/automode-classifier-flow.md +0 -428
- package/node_modules/@czottmann/pi-automode/docs/configuration.md +0 -171
- package/node_modules/@czottmann/pi-automode/docs/defaults.md +0 -178
- package/node_modules/@czottmann/pi-automode/docs/diagnostics.md +0 -90
- package/node_modules/@czottmann/pi-automode/docs/observability-logging.md +0 -160
- package/node_modules/@czottmann/pi-automode/examples/automode.local.json +0 -44
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/bash.ts +0 -692
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +0 -852
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +0 -904
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +0 -228
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/extension.ts +0 -954
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/hard-deny.ts +0 -429
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/log.ts +0 -173
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/model-selector.ts +0 -113
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/model.ts +0 -13
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/paths.ts +0 -297
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/permissions.ts +0 -623
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/state.ts +0 -102
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/transcript.ts +0 -236
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/types.ts +0 -205
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/utils.ts +0 -54
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode.ts +0 -26
- package/node_modules/@czottmann/pi-automode/package.json +0 -61
- package/node_modules/@czottmann/pi-automode/skills/automode-diagnostics/SKILL.md +0 -63
- package/node_modules/@luxusai/pi-hindsight/CHANGELOG.md +0 -376
- package/node_modules/@luxusai/pi-hindsight/README.md +0 -92
- package/node_modules/@luxusai/pi-hindsight/docs/adr/001-memory-lifecycle-and-scope.md +0 -56
- package/node_modules/@luxusai/pi-hindsight/docs/adr/002-explicit-routing-strategy-seam.md +0 -169
- package/node_modules/@luxusai/pi-hindsight/docs/adr/003-tui-memory-mode-vocabulary.md +0 -107
- package/node_modules/@luxusai/pi-hindsight/docs/adr/004-lifeos-dual-bank-design.md +0 -89
- package/node_modules/@luxusai/pi-hindsight/docs/adr/005-domain-banks-and-agent-first-surface.md +0 -189
- package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark.webp +0 -0
- package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark@2x.webp +0 -0
- package/node_modules/@luxusai/pi-hindsight/docs/coding-memory-evaluation.md +0 -54
- package/node_modules/@luxusai/pi-hindsight/docs/compatibility.md +0 -75
- package/node_modules/@luxusai/pi-hindsight/docs/hindsight-core-functions.md +0 -300
- package/node_modules/@luxusai/pi-hindsight/docs/mission-and-mental-model-quality.md +0 -158
- package/node_modules/@luxusai/pi-hindsight/docs/next-opt-out-design.md +0 -164
- package/node_modules/@luxusai/pi-hindsight/docs/risky-memory-modes.md +0 -139
- package/node_modules/@luxusai/pi-hindsight/docs/starter-mental-model-suggestions.md +0 -74
- package/node_modules/@luxusai/pi-hindsight/docs/surface-reference.md +0 -261
- package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-operations.ts +0 -151
- package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-selection.ts +0 -18
- package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-settings-presenter.ts +0 -46
- package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-templates.ts +0 -383
- package/node_modules/@luxusai/pi-hindsight/extensions/banks/banking.ts +0 -240
- package/node_modules/@luxusai/pi-hindsight/extensions/banks/knowledge-page-seed.ts +0 -176
- package/node_modules/@luxusai/pi-hindsight/extensions/banks/retain-strategies.ts +0 -178
- package/node_modules/@luxusai/pi-hindsight/extensions/client/client-retry.ts +0 -41
- package/node_modules/@luxusai/pi-hindsight/extensions/client/client.ts +0 -386
- package/node_modules/@luxusai/pi-hindsight/extensions/client/fetch-compat.ts +0 -39
- package/node_modules/@luxusai/pi-hindsight/extensions/client/timeout.ts +0 -34
- package/node_modules/@luxusai/pi-hindsight/extensions/config/config-defaults.ts +0 -140
- package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-model.ts +0 -61
- package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-registry.ts +0 -925
- package/node_modules/@luxusai/pi-hindsight/extensions/config/config-field-paths.ts +0 -247
- package/node_modules/@luxusai/pi-hindsight/extensions/config/config-normalize.ts +0 -547
- package/node_modules/@luxusai/pi-hindsight/extensions/config/config-writer.ts +0 -480
- package/node_modules/@luxusai/pi-hindsight/extensions/config/config.ts +0 -182
- package/node_modules/@luxusai/pi-hindsight/extensions/config/setup-gate.ts +0 -86
- package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-execute.ts +0 -1010
- package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-parse.ts +0 -175
- package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-plan.ts +0 -425
- package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-presentation.ts +0 -210
- package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-sessions.ts +0 -817
- package/node_modules/@luxusai/pi-hindsight/extensions/index.ts +0 -25
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/git-seed.ts +0 -319
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-recall.ts +0 -196
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-retain.ts +0 -189
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-runtime.ts +0 -65
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle.ts +0 -260
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/mental-models.ts +0 -244
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/observation-scopes.ts +0 -59
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-cleanup.ts +0 -82
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-visibility.ts +0 -45
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall.ts +0 -331
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-cursor.ts +0 -354
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-job-builder.ts +0 -66
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-receipts.ts +0 -132
- package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain.ts +0 -228
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-bank-template-operations.ts +0 -74
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-config-operations.ts +0 -16
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-control-operations.ts +0 -648
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-diagnostics-operations.ts +0 -105
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-identity.ts +0 -68
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-service.ts +0 -71
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-types.ts +0 -13
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-recall-operations.ts +0 -162
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-retain-operations.ts +0 -131
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-scope.ts +0 -104
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-session-operations.ts +0 -37
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/operation-catalog.ts +0 -893
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/reflect-presenter.ts +0 -35
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/scope-migrate.ts +0 -177
- package/node_modules/@luxusai/pi-hindsight/extensions/operations/tools.ts +0 -7
- package/node_modules/@luxusai/pi-hindsight/extensions/queue/flush-presenter.ts +0 -21
- package/node_modules/@luxusai/pi-hindsight/extensions/queue/jsonl-queue-store.ts +0 -112
- package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-delivery.ts +0 -111
- package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-lock.ts +0 -214
- package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-operations.ts +0 -70
- package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue.ts +0 -392
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/bank-template-presentation.ts +0 -45
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/commands.ts +0 -9
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/guided-setup.ts +0 -860
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/prefill-input.ts +0 -105
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-flow.ts +0 -189
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-server-probe.ts +0 -299
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-actions.ts +0 -201
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-facts.ts +0 -47
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-render.ts +0 -239
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-types.ts +0 -50
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui.ts +0 -259
- package/node_modules/@luxusai/pi-hindsight/extensions/tui/tool-presenters.ts +0 -77
- package/node_modules/@luxusai/pi-hindsight/extensions/types.ts +0 -534
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/diagnostics.ts +0 -319
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/messages.ts +0 -325
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/sanitize.ts +0 -42
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-memory-meta.ts +0 -244
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-operations.ts +0 -56
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/session.ts +0 -50
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-fields.ts +0 -167
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-health.ts +0 -207
- package/node_modules/@luxusai/pi-hindsight/extensions/utils/status.ts +0 -120
- package/node_modules/@luxusai/pi-hindsight/extensions/version.ts +0 -8
- package/node_modules/@luxusai/pi-hindsight/package.json +0 -118
- package/node_modules/@luxusai/pi-hindsight/skills/hindsight-memory-doctor/SKILL.md +0 -75
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { DENIAL_HISTORY_LIMIT } from "./constants.ts";
|
|
3
|
-
import type { AutoModeState, DenialRecord, EffectiveConfig } from "./types.ts";
|
|
4
|
-
import { safeJson, truncateMiddle } from "./utils.ts";
|
|
5
|
-
|
|
6
|
-
export function pushDenial(state: AutoModeState, denial: DenialRecord): void {
|
|
7
|
-
state.recentDenials = [
|
|
8
|
-
...state.recentDenials.slice(-(DENIAL_HISTORY_LIMIT - 1)),
|
|
9
|
-
denial,
|
|
10
|
-
];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function statusLine(
|
|
14
|
-
config: EffectiveConfig,
|
|
15
|
-
state: AutoModeState,
|
|
16
|
-
): string {
|
|
17
|
-
const enabled = state.enabledOverride ?? config.enabled;
|
|
18
|
-
const circle = enabled ? "●" : "○";
|
|
19
|
-
const allowed = state.checkedActions - state.blockedActions;
|
|
20
|
-
const classifier = state.classifierAllowed > 0 || state.classifierDenied > 0
|
|
21
|
-
? ` ca:${state.classifierAllowed} cd:${state.classifierDenied}`
|
|
22
|
-
: "";
|
|
23
|
-
return `AM${circle} a:${allowed} d:${state.blockedActions}${classifier}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function statusText(
|
|
27
|
-
config: EffectiveConfig,
|
|
28
|
-
state: AutoModeState,
|
|
29
|
-
): string {
|
|
30
|
-
return [
|
|
31
|
-
`enabled: ${(state.enabledOverride ?? config.enabled) ? "yes" : "no"}`,
|
|
32
|
-
`classifier: ${config.classifierModel ?? "current session model"}`,
|
|
33
|
-
`classifier reasoning: ${config.classifierReasoningLevel ?? "server default"}`,
|
|
34
|
-
`checked actions: ${state.checkedActions}`,
|
|
35
|
-
`blocked actions: ${state.blockedActions}`,
|
|
36
|
-
`classifier allowed: ${state.classifierAllowed}`,
|
|
37
|
-
`classifier denied: ${state.classifierDenied}`,
|
|
38
|
-
`permissions.deny rules: ${config.permissionDeny.length}`,
|
|
39
|
-
`permissions.ask rules: ${config.permissionAsk.length}`,
|
|
40
|
-
`permissions.allow rules: ${config.permissionAllow.length}`,
|
|
41
|
-
`environment entries: ${config.environment.length}`,
|
|
42
|
-
`allow entries: ${config.allow.length}`,
|
|
43
|
-
`soft_deny entries: ${config.softDeny.length}`,
|
|
44
|
-
`hard_deny entries: ${config.hardDeny.length}`,
|
|
45
|
-
`last decision: ${state.lastDecision ?? "none"}`,
|
|
46
|
-
`last reason: ${state.lastReason ?? "none"}`,
|
|
47
|
-
].join("\n");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function formatDenials(state: AutoModeState): string {
|
|
51
|
-
if (state.recentDenials.length === 0) return "No recent auto-mode denials.";
|
|
52
|
-
return state.recentDenials
|
|
53
|
-
.slice()
|
|
54
|
-
.reverse()
|
|
55
|
-
.map(
|
|
56
|
-
(denial) =>
|
|
57
|
-
`${
|
|
58
|
-
new Date(denial.timestamp).toLocaleTimeString()
|
|
59
|
-
} ${denial.kind} ${denial.toolName}: ${denial.reason}\n ${
|
|
60
|
-
truncateMiddle(denial.action, 300)
|
|
61
|
-
}`,
|
|
62
|
-
)
|
|
63
|
-
.join("\n\n");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function actionSummary(
|
|
67
|
-
toolName: string,
|
|
68
|
-
input: Record<string, unknown>,
|
|
69
|
-
): string {
|
|
70
|
-
return `${toolName} ${safeJson(input, 6000)}`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function restoreState(ctx: ExtensionContext): AutoModeState {
|
|
74
|
-
const entries = ctx.sessionManager.getEntries();
|
|
75
|
-
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
76
|
-
const entry = entries[i] as {
|
|
77
|
-
type?: string;
|
|
78
|
-
customType?: string;
|
|
79
|
-
data?: Partial<AutoModeState>;
|
|
80
|
-
};
|
|
81
|
-
if (
|
|
82
|
-
entry.type !== "custom" ||
|
|
83
|
-
entry.customType !== "pi-automode-state" ||
|
|
84
|
-
!entry.data
|
|
85
|
-
) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
enabledOverride: entry.data.enabledOverride,
|
|
90
|
-
lastDecision: entry.data.lastDecision,
|
|
91
|
-
lastReason: entry.data.lastReason,
|
|
92
|
-
checkedActions: entry.data.checkedActions ?? 0,
|
|
93
|
-
blockedActions: entry.data.blockedActions ?? 0,
|
|
94
|
-
classifierAllowed: entry.data.classifierAllowed ?? 0,
|
|
95
|
-
classifierDenied: entry.data.classifierDenied ?? 0,
|
|
96
|
-
recentDenials: Array.isArray(entry.data.recentDenials)
|
|
97
|
-
? entry.data.recentDenials.slice(-DENIAL_HISTORY_LIMIT)
|
|
98
|
-
: [],
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return { checkedActions: 0, blockedActions: 0, classifierAllowed: 0, classifierDenied: 0, recentDenials: [] };
|
|
102
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { safeJson, truncateMiddle } from "./utils.ts";
|
|
3
|
-
|
|
4
|
-
const MAX_USER_ENTRY_TOKENS = 1000;
|
|
5
|
-
const MAX_TOOL_ENTRY_TOKENS = 1000;
|
|
6
|
-
const MAX_RECENT_TOOL_ENTRIES = 40;
|
|
7
|
-
const CHARS_PER_APPROX_TOKEN = 4;
|
|
8
|
-
|
|
9
|
-
type TranscriptEntry = {
|
|
10
|
-
index: number;
|
|
11
|
-
order: number;
|
|
12
|
-
kind: "user" | "tool";
|
|
13
|
-
text: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type ClassifierTranscriptBudgets = {
|
|
17
|
-
maxUserTokens: number;
|
|
18
|
-
maxToolTokens: number;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function flattenUserContent(content: unknown): string {
|
|
22
|
-
if (typeof content === "string") return content;
|
|
23
|
-
if (!Array.isArray(content)) return "";
|
|
24
|
-
return content
|
|
25
|
-
.filter(
|
|
26
|
-
(block): block is { type: string; text?: string } =>
|
|
27
|
-
!!block && typeof block === "object" && "type" in block,
|
|
28
|
-
)
|
|
29
|
-
.filter((block) => block.type === "text" && typeof block.text === "string")
|
|
30
|
-
.map((block) => block.text ?? "")
|
|
31
|
-
.join("\n");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function collectAssistantToolCalls(content: unknown): Array<{
|
|
35
|
-
name: string;
|
|
36
|
-
input: unknown;
|
|
37
|
-
}> {
|
|
38
|
-
if (!Array.isArray(content)) return [];
|
|
39
|
-
return content
|
|
40
|
-
.filter(
|
|
41
|
-
(
|
|
42
|
-
block,
|
|
43
|
-
): block is {
|
|
44
|
-
type: string;
|
|
45
|
-
name?: string;
|
|
46
|
-
arguments?: unknown;
|
|
47
|
-
input?: unknown;
|
|
48
|
-
} => !!block && typeof block === "object" && "type" in block,
|
|
49
|
-
)
|
|
50
|
-
.filter((block) => block.type === "toolCall" || block.type === "tool_use")
|
|
51
|
-
.map((block) => ({
|
|
52
|
-
name: String(block.name ?? "tool"),
|
|
53
|
-
input: "arguments" in block ? block.arguments : block.input,
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function approximateTokenCount(text: string): number {
|
|
58
|
-
return Math.ceil(text.length / CHARS_PER_APPROX_TOKEN);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function truncateToTokenCap(
|
|
62
|
-
text: string,
|
|
63
|
-
maxTokens: number,
|
|
64
|
-
): { text: string; truncated: boolean } {
|
|
65
|
-
if (approximateTokenCount(text) <= maxTokens) {
|
|
66
|
-
return { text, truncated: false };
|
|
67
|
-
}
|
|
68
|
-
const maxCharacters = Math.max(1, maxTokens * CHARS_PER_APPROX_TOKEN);
|
|
69
|
-
const omittedTokens = Math.max(
|
|
70
|
-
1,
|
|
71
|
-
approximateTokenCount(text) - maxTokens,
|
|
72
|
-
);
|
|
73
|
-
const marker = `<truncated approx_tokens="${omittedTokens}" />`;
|
|
74
|
-
if (marker.length >= maxCharacters) {
|
|
75
|
-
return { text: marker.slice(0, maxCharacters), truncated: true };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const retainedCharacters = maxCharacters - marker.length;
|
|
79
|
-
const prefixCharacters = Math.ceil(retainedCharacters * 0.65);
|
|
80
|
-
const suffixCharacters = retainedCharacters - prefixCharacters;
|
|
81
|
-
return {
|
|
82
|
-
text: `${text.slice(0, prefixCharacters)}${marker}${
|
|
83
|
-
suffixCharacters > 0 ? text.slice(-suffixCharacters) : ""
|
|
84
|
-
}`,
|
|
85
|
-
truncated: true,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function collectTranscriptEntries(ctx: ExtensionContext): TranscriptEntry[] {
|
|
90
|
-
const entries: TranscriptEntry[] = [];
|
|
91
|
-
const sessionManager = ctx.sessionManager as typeof ctx.sessionManager & {
|
|
92
|
-
buildContextEntries?: () => ReturnType<typeof ctx.sessionManager.getBranch>;
|
|
93
|
-
};
|
|
94
|
-
const contextEntries = sessionManager.buildContextEntries?.() ??
|
|
95
|
-
sessionManager.getBranch();
|
|
96
|
-
|
|
97
|
-
for (const [index, entry] of contextEntries.entries()) {
|
|
98
|
-
if (entry.type !== "message") continue;
|
|
99
|
-
const message = entry.message as { role?: string; content?: unknown };
|
|
100
|
-
if (message.role === "user") {
|
|
101
|
-
const text = flattenUserContent(message.content).trim();
|
|
102
|
-
if (text) entries.push({ index, order: 0, kind: "user", text });
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
if (message.role !== "assistant") continue;
|
|
106
|
-
|
|
107
|
-
for (const [order, toolCall] of collectAssistantToolCalls(
|
|
108
|
-
message.content,
|
|
109
|
-
).entries()) {
|
|
110
|
-
entries.push({
|
|
111
|
-
index,
|
|
112
|
-
order,
|
|
113
|
-
kind: "tool",
|
|
114
|
-
text: `${toolCall.name}: ${safeJson(toolCall.input, 8000)}`,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return entries;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function selectUserEntries(
|
|
123
|
-
entries: TranscriptEntry[],
|
|
124
|
-
maxTokens: number,
|
|
125
|
-
): { selected: TranscriptEntry[]; omitted: boolean } {
|
|
126
|
-
const users = entries.filter((entry) => entry.kind === "user");
|
|
127
|
-
if (users.length === 0) return { selected: [], omitted: false };
|
|
128
|
-
|
|
129
|
-
const distinctAnchors = users.length > 1;
|
|
130
|
-
const anchorBudget = distinctAnchors
|
|
131
|
-
? Math.max(1, Math.floor(maxTokens / 2))
|
|
132
|
-
: maxTokens;
|
|
133
|
-
const entryCap = Math.min(MAX_USER_ENTRY_TOKENS, anchorBudget);
|
|
134
|
-
const rendered = users.map((entry) => {
|
|
135
|
-
const truncated = truncateToTokenCap(`User: ${entry.text}`, entryCap);
|
|
136
|
-
return { ...entry, text: truncated.text, truncated: truncated.truncated };
|
|
137
|
-
});
|
|
138
|
-
const selectedIndices = new Set<number>();
|
|
139
|
-
let usedTokens = 0;
|
|
140
|
-
|
|
141
|
-
const include = (index: number): void => {
|
|
142
|
-
if (selectedIndices.has(index)) return;
|
|
143
|
-
const entry = rendered[index];
|
|
144
|
-
if (!entry) return;
|
|
145
|
-
const tokens = approximateTokenCount(entry.text);
|
|
146
|
-
if (usedTokens + tokens > maxTokens) return;
|
|
147
|
-
selectedIndices.add(index);
|
|
148
|
-
usedTokens += tokens;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Prefer the latest user instruction when an extremely small configured
|
|
152
|
-
// budget cannot retain both intent anchors.
|
|
153
|
-
include(rendered.length - 1);
|
|
154
|
-
include(0);
|
|
155
|
-
for (let index = rendered.length - 2; index > 0; index -= 1) {
|
|
156
|
-
include(index);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
selected: rendered.filter((_entry, index) => selectedIndices.has(index)),
|
|
161
|
-
omitted: selectedIndices.size < users.length || rendered.some((entry) =>
|
|
162
|
-
entry.truncated
|
|
163
|
-
),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function selectToolEntries(
|
|
168
|
-
entries: TranscriptEntry[],
|
|
169
|
-
maxTokens: number,
|
|
170
|
-
): { selected: TranscriptEntry[]; omitted: boolean } {
|
|
171
|
-
const tools = entries.filter((entry) => entry.kind === "tool");
|
|
172
|
-
const selected: TranscriptEntry[] = [];
|
|
173
|
-
let usedTokens = 0;
|
|
174
|
-
|
|
175
|
-
for (let index = tools.length - 1; index >= 0; index -= 1) {
|
|
176
|
-
if (selected.length >= MAX_RECENT_TOOL_ENTRIES) break;
|
|
177
|
-
const entry = tools[index];
|
|
178
|
-
if (!entry) continue;
|
|
179
|
-
const truncated = truncateToTokenCap(
|
|
180
|
-
`ToolCall ${entry.text}`,
|
|
181
|
-
Math.min(MAX_TOOL_ENTRY_TOKENS, maxTokens),
|
|
182
|
-
);
|
|
183
|
-
const tokens = approximateTokenCount(truncated.text);
|
|
184
|
-
if (usedTokens + tokens > maxTokens) continue;
|
|
185
|
-
selected.push({ ...entry, text: truncated.text });
|
|
186
|
-
usedTokens += tokens;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
selected.reverse();
|
|
190
|
-
return {
|
|
191
|
-
selected,
|
|
192
|
-
omitted: selected.length < tools.length || tools.some((entry) =>
|
|
193
|
-
approximateTokenCount(`ToolCall ${entry.text}`) >
|
|
194
|
-
Math.min(MAX_TOOL_ENTRY_TOKENS, maxTokens)
|
|
195
|
-
),
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Build classifier evidence from user text and assistant tool-call payloads only. */
|
|
200
|
-
export function buildClassifierTranscript(
|
|
201
|
-
ctx: ExtensionContext,
|
|
202
|
-
budgets: ClassifierTranscriptBudgets,
|
|
203
|
-
): string {
|
|
204
|
-
const entries = collectTranscriptEntries(ctx);
|
|
205
|
-
const users = selectUserEntries(entries, budgets.maxUserTokens);
|
|
206
|
-
const tools = selectToolEntries(entries, budgets.maxToolTokens);
|
|
207
|
-
const selected = [...users.selected, ...tools.selected].sort(
|
|
208
|
-
(left, right) => left.index - right.index || left.order - right.order,
|
|
209
|
-
);
|
|
210
|
-
if (users.omitted || tools.omitted) {
|
|
211
|
-
selected.push({
|
|
212
|
-
index: Number.MAX_SAFE_INTEGER,
|
|
213
|
-
order: 0,
|
|
214
|
-
kind: "tool",
|
|
215
|
-
text: "<transcript_entries_omitted />",
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
return selected.map((entry) => entry.text).join("\n");
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export function loadedContextFromSystemPromptOptions(options: unknown): string {
|
|
222
|
-
const contextFiles = (
|
|
223
|
-
options as
|
|
224
|
-
| { contextFiles?: Array<{ path?: string; content?: string }> }
|
|
225
|
-
| undefined
|
|
226
|
-
)?.contextFiles;
|
|
227
|
-
if (!Array.isArray(contextFiles)) return "";
|
|
228
|
-
return contextFiles
|
|
229
|
-
.map(
|
|
230
|
-
(file) =>
|
|
231
|
-
`# ${file.path ?? "context"}\n${
|
|
232
|
-
truncateMiddle(file.content ?? "", 4000)
|
|
233
|
-
}`,
|
|
234
|
-
)
|
|
235
|
-
.join("\n\n");
|
|
236
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
2
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
|
|
4
|
-
export type ClassifierReasoningLevel =
|
|
5
|
-
| "low"
|
|
6
|
-
| "medium"
|
|
7
|
-
| "high"
|
|
8
|
-
| "xhigh"
|
|
9
|
-
| "max";
|
|
10
|
-
|
|
11
|
-
export type EffectiveClassifierReasoningLevel =
|
|
12
|
-
| "off"
|
|
13
|
-
| "minimal"
|
|
14
|
-
| ClassifierReasoningLevel;
|
|
15
|
-
|
|
16
|
-
export type ClassifierReasoning =
|
|
17
|
-
| { mode: "server-default" }
|
|
18
|
-
| {
|
|
19
|
-
mode: "explicit";
|
|
20
|
-
requestedLevel: ClassifierReasoningLevel;
|
|
21
|
-
effectiveLevel: EffectiveClassifierReasoningLevel;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type ClassifierReasoningLog =
|
|
25
|
-
| ClassifierReasoning
|
|
26
|
-
| {
|
|
27
|
-
mode: "explicit";
|
|
28
|
-
requestedLevel: ClassifierReasoningLevel;
|
|
29
|
-
effectiveLevel?: undefined;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/** Observability log configuration. Off by default. */
|
|
33
|
-
export type LogConfig = {
|
|
34
|
-
enabled: boolean;
|
|
35
|
-
/** When true, also log classifier prompt/response payloads. */
|
|
36
|
-
classifierIo: boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type AutoModeSettings = {
|
|
40
|
-
enabled?: boolean;
|
|
41
|
-
classifierModel?: string;
|
|
42
|
-
classifierReasoningLevel?: ClassifierReasoningLevel;
|
|
43
|
-
/** When true, read-only tools (read/grep/find/ls) are classified instead of auto-allowed. */
|
|
44
|
-
classifyReadOnlyTools?: boolean;
|
|
45
|
-
/** Override the fast-stage completion token budget (default 512). */
|
|
46
|
-
fastClassifierMaxTokens?: number;
|
|
47
|
-
/** Per-request timeout for classifier completions in milliseconds (default 20000). */
|
|
48
|
-
classifierTimeoutMs?: number;
|
|
49
|
-
/** When true, file tools whose resolved path is inside the working directory are allowed deterministically (no classifier), and outside-CWD file access is classified. */
|
|
50
|
-
allowInsideWorkingDirectory?: boolean;
|
|
51
|
-
/** Path glob patterns (file tools) that are always denied before the classifier. Supports `~` and `*` (matches any characters, including `/`). */
|
|
52
|
-
deniedPaths?: unknown;
|
|
53
|
-
maxUserTranscriptTokens?: number;
|
|
54
|
-
maxToolTranscriptTokens?: number;
|
|
55
|
-
environment?: unknown;
|
|
56
|
-
allow?: unknown;
|
|
57
|
-
protectedPaths?: unknown;
|
|
58
|
-
soft_deny?: unknown;
|
|
59
|
-
softDeny?: unknown;
|
|
60
|
-
hard_deny?: unknown;
|
|
61
|
-
hardDeny?: unknown;
|
|
62
|
-
log?: Partial<LogConfig>;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type SettingsFile = {
|
|
66
|
-
autoMode?: AutoModeSettings;
|
|
67
|
-
permissions?: {
|
|
68
|
-
deny?: unknown;
|
|
69
|
-
ask?: unknown;
|
|
70
|
-
/**
|
|
71
|
-
* Deterministic allow tier: matching calls skip the classifier only. Read
|
|
72
|
-
* from user-owned config sources, never shared project config.
|
|
73
|
-
*/
|
|
74
|
-
allow?: unknown;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type LoadedSettingsFile = {
|
|
79
|
-
path: string;
|
|
80
|
-
settings?: SettingsFile;
|
|
81
|
-
diagnostics: string[];
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type ToolPattern = {
|
|
85
|
-
raw: string;
|
|
86
|
-
toolName?: string;
|
|
87
|
-
argumentPattern?: string;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export type EffectiveConfig = {
|
|
91
|
-
enabled: boolean;
|
|
92
|
-
classifierModel?: string;
|
|
93
|
-
classifierReasoningLevel?: ClassifierReasoningLevel;
|
|
94
|
-
classifyReadOnlyTools: boolean;
|
|
95
|
-
fastClassifierMaxTokens: number;
|
|
96
|
-
classifierTimeoutMs: number;
|
|
97
|
-
allowInsideWorkingDirectory: boolean;
|
|
98
|
-
deniedPaths: string[];
|
|
99
|
-
maxUserTranscriptTokens: number;
|
|
100
|
-
maxToolTranscriptTokens: number;
|
|
101
|
-
environment: string[];
|
|
102
|
-
allow: string[];
|
|
103
|
-
protectedPaths: string[];
|
|
104
|
-
softDeny: string[];
|
|
105
|
-
hardDeny: string[];
|
|
106
|
-
permissionDeny: ToolPattern[];
|
|
107
|
-
permissionAsk: ToolPattern[];
|
|
108
|
-
permissionAllow: ToolPattern[];
|
|
109
|
-
log: LogConfig;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export type AutoModeState = {
|
|
113
|
-
enabledOverride?: boolean;
|
|
114
|
-
lastDecision?: "allow" | "block";
|
|
115
|
-
lastReason?: string;
|
|
116
|
-
checkedActions: number;
|
|
117
|
-
blockedActions: number;
|
|
118
|
-
classifierAllowed: number;
|
|
119
|
-
classifierDenied: number;
|
|
120
|
-
recentDenials: DenialRecord[];
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export type DenialRecord = {
|
|
124
|
-
timestamp: number;
|
|
125
|
-
toolName: string;
|
|
126
|
-
reason: string;
|
|
127
|
-
action: string;
|
|
128
|
-
kind:
|
|
129
|
-
| "permissions.deny"
|
|
130
|
-
| "permissions.ask"
|
|
131
|
-
| "deterministic-hard-deny"
|
|
132
|
-
| "deterministic-path-deny"
|
|
133
|
-
| "classifier"
|
|
134
|
-
| "setup";
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/** Denial kind plus the deterministic allow fast paths, used for decision log entries. */
|
|
138
|
-
export type DecisionKind =
|
|
139
|
-
| DenialRecord["kind"]
|
|
140
|
-
| "permissions.allow"
|
|
141
|
-
| "read-only"
|
|
142
|
-
| "inside-working-directory";
|
|
143
|
-
|
|
144
|
-
export type ClassificationDecision = {
|
|
145
|
-
decision: "allow" | "block";
|
|
146
|
-
tier: "hard_deny" | "soft_deny" | "allow" | "explicit_intent" | "none";
|
|
147
|
-
reason: string;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
/** One classifier attempt: the raw model response (or error) and parsed decision. */
|
|
151
|
-
export type ClassifierIoAttempt = {
|
|
152
|
-
stage: "fast" | "detailed";
|
|
153
|
-
attempt: number;
|
|
154
|
-
response?: {
|
|
155
|
-
stopReason?: string;
|
|
156
|
-
text: string;
|
|
157
|
-
model: string;
|
|
158
|
-
timestamp: number;
|
|
159
|
-
usage: AssistantMessage["usage"];
|
|
160
|
-
errorMessage?: string;
|
|
161
|
-
};
|
|
162
|
-
parsed?: ClassificationDecision;
|
|
163
|
-
error?: string;
|
|
164
|
-
durationMs: number;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/** Full classifier I/O for an action, surfaced for optional observability logging. */
|
|
168
|
-
export type ClassifierIo = {
|
|
169
|
-
model: string;
|
|
170
|
-
reasoning: ClassifierReasoning;
|
|
171
|
-
prompt: {
|
|
172
|
-
system: string;
|
|
173
|
-
context: string;
|
|
174
|
-
action: string;
|
|
175
|
-
fastInstruction: string;
|
|
176
|
-
detailedInstruction: string;
|
|
177
|
-
};
|
|
178
|
-
attempts: ClassifierIoAttempt[];
|
|
179
|
-
durationMs: number;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/** Classification decision plus resolved reasoning and the I/O that produced it (when available). */
|
|
183
|
-
export type ClassifyResult = ClassificationDecision & {
|
|
184
|
-
reasoning?: ClassifierReasoningLog;
|
|
185
|
-
io?: ClassifierIo;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export type SettingsSources = {
|
|
189
|
-
globalSettings?: SettingsFile[];
|
|
190
|
-
projectLocalSettings?: SettingsFile[];
|
|
191
|
-
projectSharedSettings?: SettingsFile[];
|
|
192
|
-
inlineSettings?: SettingsFile[];
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export type ConfigLoadResult = {
|
|
196
|
-
config: EffectiveConfig;
|
|
197
|
-
diagnostics: string[];
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export type ClassifyAction = (
|
|
201
|
-
ctx: ExtensionContext,
|
|
202
|
-
config: EffectiveConfig,
|
|
203
|
-
action: string,
|
|
204
|
-
loadedContext: string,
|
|
205
|
-
) => Promise<ClassifyResult>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export function stringArray(value: unknown): string[] | undefined {
|
|
2
|
-
if (!Array.isArray(value)) return undefined;
|
|
3
|
-
return value.filter(
|
|
4
|
-
(entry): entry is string =>
|
|
5
|
-
typeof entry === "string" && entry.trim().length > 0,
|
|
6
|
-
);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function hasOwn(object: object, key: string): boolean {
|
|
10
|
-
return Object.prototype.hasOwnProperty.call(object, key);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function truncateMiddle(text: string, maxLength: number): string {
|
|
14
|
-
if (text.length <= maxLength) return text;
|
|
15
|
-
const head = Math.floor(maxLength * 0.65);
|
|
16
|
-
const tail = maxLength - head - 18;
|
|
17
|
-
return `${text.slice(0, head)}… […] …${text.slice(text.length - tail)}`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function safeJson(value: unknown, maxLength = 4000): string {
|
|
21
|
-
const seen = new WeakSet<object>();
|
|
22
|
-
let text = "{}";
|
|
23
|
-
try {
|
|
24
|
-
text = JSON.stringify(
|
|
25
|
-
value,
|
|
26
|
-
(_key, current) => {
|
|
27
|
-
if (typeof current === "string") {
|
|
28
|
-
return truncateMiddle(
|
|
29
|
-
current,
|
|
30
|
-
Math.max(200, Math.floor(maxLength / 4)),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(current)) {
|
|
34
|
-
if (current.length <= 30) return current;
|
|
35
|
-
return {
|
|
36
|
-
$truncatedArray: true,
|
|
37
|
-
items: current.slice(0, 30),
|
|
38
|
-
omittedEntries: current.length - 30,
|
|
39
|
-
totalEntries: current.length,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (current && typeof current === "object") {
|
|
43
|
-
if (seen.has(current)) return "[Circular]";
|
|
44
|
-
seen.add(current);
|
|
45
|
-
}
|
|
46
|
-
return current;
|
|
47
|
-
},
|
|
48
|
-
2,
|
|
49
|
-
) ?? "{}";
|
|
50
|
-
} catch {
|
|
51
|
-
text = String(value);
|
|
52
|
-
}
|
|
53
|
-
return truncateMiddle(text, maxLength);
|
|
54
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Code-style auto mode for Pi.
|
|
3
|
-
*
|
|
4
|
-
* The enforcement order is deliberately different from simple "auto reviewer" plugins:
|
|
5
|
-
* permission deny/ask rules and deterministic hard-deny checks run before any fast-path allow.
|
|
6
|
-
* Only read-only built-in tools bypass classification; every side-effecting action goes through the classifier.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export * from "./auto-mode/classifier.ts";
|
|
10
|
-
export * from "./auto-mode/bash.ts";
|
|
11
|
-
export * from "./auto-mode/config.ts";
|
|
12
|
-
export * from "./auto-mode/constants.ts";
|
|
13
|
-
export * from "./auto-mode/extension.ts";
|
|
14
|
-
export * from "./auto-mode/hard-deny.ts";
|
|
15
|
-
export * from "./auto-mode/log.ts";
|
|
16
|
-
export * from "./auto-mode/model.ts";
|
|
17
|
-
export * from "./auto-mode/model-selector.ts";
|
|
18
|
-
export * from "./auto-mode/paths.ts";
|
|
19
|
-
export * from "./auto-mode/permissions.ts";
|
|
20
|
-
export * from "./auto-mode/state.ts";
|
|
21
|
-
export * from "./auto-mode/transcript.ts";
|
|
22
|
-
export * from "./auto-mode/types.ts";
|
|
23
|
-
|
|
24
|
-
import { createPiAutomode } from "./auto-mode/extension.ts";
|
|
25
|
-
|
|
26
|
-
export default createPiAutomode();
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@czottmann/pi-automode",
|
|
3
|
-
"version": "1.16.0",
|
|
4
|
-
"description": "Claude Code-style auto mode guardrail for pi.",
|
|
5
|
-
"repository": {
|
|
6
|
-
"url": "https://github.com/czottmann/pi-automode"
|
|
7
|
-
},
|
|
8
|
-
"type": "module",
|
|
9
|
-
"license": "MIT",
|
|
10
|
-
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"pi",
|
|
15
|
-
"pi-extension",
|
|
16
|
-
"pi-package",
|
|
17
|
-
"auto-mode",
|
|
18
|
-
"llm",
|
|
19
|
-
"coding-agent"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"typecheck": "tsc --noEmit",
|
|
23
|
-
"check": "tsc --noEmit",
|
|
24
|
-
"build": "tsc --noEmit",
|
|
25
|
-
"test": "node --import tsx --test tests/*.test.ts"
|
|
26
|
-
},
|
|
27
|
-
"files": [
|
|
28
|
-
"CHANGELOG.md",
|
|
29
|
-
"docs",
|
|
30
|
-
"extensions",
|
|
31
|
-
"examples",
|
|
32
|
-
"skills",
|
|
33
|
-
"README.md"
|
|
34
|
-
],
|
|
35
|
-
"pi": {
|
|
36
|
-
"extensions": [
|
|
37
|
-
"./extensions/auto-mode.ts"
|
|
38
|
-
],
|
|
39
|
-
"skills": [
|
|
40
|
-
"./skills"
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"@earendil-works/pi-ai": "*",
|
|
45
|
-
"@earendil-works/pi-coding-agent": "*",
|
|
46
|
-
"@earendil-works/pi-tui": "*",
|
|
47
|
-
"typebox": "*"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@earendil-works/pi-ai": "^0.84.1",
|
|
51
|
-
"@earendil-works/pi-coding-agent": "^0.84.1",
|
|
52
|
-
"@earendil-works/pi-tui": "^0.84.1",
|
|
53
|
-
"@types/node": "^24.0.0",
|
|
54
|
-
"tsx": "^4.22.4",
|
|
55
|
-
"typebox": "^1.3.10",
|
|
56
|
-
"typescript": "^5.8.0"
|
|
57
|
-
},
|
|
58
|
-
"dependencies": {
|
|
59
|
-
"unbash": "4.0.10"
|
|
60
|
-
}
|
|
61
|
-
}
|