@herbertgao/pi-extensions 2026.9.6 → 2026.9.8
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 +3 -8
- package/THIRD_PARTY_NOTICES.md +0 -4
- 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/grok-mermaid/CHANGELOG.md +46 -0
- package/node_modules/grok-mermaid/LICENSE +205 -0
- package/node_modules/grok-mermaid/README.md +191 -0
- package/node_modules/grok-mermaid/dist/ansi.d.ts +16 -0
- package/node_modules/grok-mermaid/dist/ansi.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/ansi.js +23 -0
- package/node_modules/grok-mermaid/dist/ansi.js.map +1 -0
- package/node_modules/grok-mermaid/dist/canvas.d.ts +87 -0
- package/node_modules/grok-mermaid/dist/canvas.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/canvas.js +366 -0
- package/node_modules/grok-mermaid/dist/canvas.js.map +1 -0
- package/node_modules/grok-mermaid/dist/graph.d.ts +74 -0
- package/node_modules/grok-mermaid/dist/graph.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/graph.js +91 -0
- package/node_modules/grok-mermaid/dist/graph.js.map +1 -0
- package/node_modules/grok-mermaid/dist/index.d.ts +32 -0
- package/node_modules/grok-mermaid/dist/index.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/index.js +100 -0
- package/node_modules/grok-mermaid/dist/index.js.map +1 -0
- package/node_modules/grok-mermaid/dist/labels.d.ts +62 -0
- package/node_modules/grok-mermaid/dist/labels.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/labels.js +324 -0
- package/node_modules/grok-mermaid/dist/labels.js.map +1 -0
- package/node_modules/grok-mermaid/dist/layout-seq.d.ts +12 -0
- package/node_modules/grok-mermaid/dist/layout-seq.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/layout-seq.js +194 -0
- package/node_modules/grok-mermaid/dist/layout-seq.js.map +1 -0
- package/node_modules/grok-mermaid/dist/layout.d.ts +87 -0
- package/node_modules/grok-mermaid/dist/layout.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/layout.js +881 -0
- package/node_modules/grok-mermaid/dist/layout.js.map +1 -0
- package/node_modules/grok-mermaid/dist/parse.d.ts +83 -0
- package/node_modules/grok-mermaid/dist/parse.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/parse.js +1151 -0
- package/node_modules/grok-mermaid/dist/parse.js.map +1 -0
- package/node_modules/grok-mermaid/dist/source-box.d.ts +18 -0
- package/node_modules/grok-mermaid/dist/source-box.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/source-box.js +78 -0
- package/node_modules/grok-mermaid/dist/source-box.js.map +1 -0
- package/node_modules/grok-mermaid/dist/types.d.ts +42 -0
- package/node_modules/grok-mermaid/dist/types.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/types.js +1 -0
- package/node_modules/grok-mermaid/dist/types.js.map +1 -0
- package/node_modules/grok-mermaid/dist/width-data.d.ts +2 -0
- package/node_modules/grok-mermaid/dist/width-data.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/width-data.js +994 -0
- package/node_modules/grok-mermaid/dist/width-data.js.map +1 -0
- package/node_modules/grok-mermaid/dist/width.d.ts +18 -0
- package/node_modules/grok-mermaid/dist/width.d.ts.map +1 -0
- package/node_modules/grok-mermaid/dist/width.js +76 -0
- package/node_modules/grok-mermaid/dist/width.js.map +1 -0
- package/node_modules/grok-mermaid/package.json +49 -0
- package/node_modules/grok-mermaid/src/ansi.ts +34 -0
- package/node_modules/grok-mermaid/src/canvas.ts +373 -0
- package/node_modules/grok-mermaid/src/graph.ts +142 -0
- package/node_modules/grok-mermaid/src/index.ts +104 -0
- package/node_modules/grok-mermaid/src/labels.ts +326 -0
- package/node_modules/grok-mermaid/src/layout-seq.ts +203 -0
- package/node_modules/grok-mermaid/src/layout.ts +1015 -0
- package/node_modules/grok-mermaid/src/parse.ts +1189 -0
- package/node_modules/grok-mermaid/src/source-box.ts +89 -0
- package/node_modules/grok-mermaid/src/types.ts +43 -0
- package/node_modules/grok-mermaid/src/width-data.ts +993 -0
- package/node_modules/grok-mermaid/src/width.ts +74 -0
- 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 -11
- 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,105 +0,0 @@
|
|
|
1
|
-
import type { ExtensionUIContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { DynamicBorder, keyHint } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import {
|
|
4
|
-
decodeKittyPrintable,
|
|
5
|
-
getKeybindings,
|
|
6
|
-
Input,
|
|
7
|
-
type Component,
|
|
8
|
-
} from "@earendil-works/pi-tui";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* True when the keystroke would insert text into Pi's Input
|
|
12
|
-
* (printable or Kitty CSI-u printable). Used for select-all prefill replace.
|
|
13
|
-
*/
|
|
14
|
-
export function isPrefillReplacingInput(data: string): boolean {
|
|
15
|
-
if (!data) return false;
|
|
16
|
-
if (decodeKittyPrintable(data) !== undefined) return true;
|
|
17
|
-
for (let i = 0; i < data.length; i += 1) {
|
|
18
|
-
const code = data.charCodeAt(i);
|
|
19
|
-
if (code < 32 || code === 0x7f || (code >= 0x80 && code <= 0x9f)) return false;
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type PrefillTheme = {
|
|
25
|
-
fg: (name: string, text: string) => string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Input dialog with a visible prefill. First printable keystroke replaces the
|
|
30
|
-
* whole prefill (select-all UX). Enter keeps the current value; Esc cancels.
|
|
31
|
-
* Empty prefill falls through to stock `ui.input`.
|
|
32
|
-
*/
|
|
33
|
-
export async function inputWithPrefill(
|
|
34
|
-
ui: Pick<ExtensionUIContext, "input" | "custom">,
|
|
35
|
-
title: string,
|
|
36
|
-
prefill: string,
|
|
37
|
-
): Promise<string | undefined> {
|
|
38
|
-
const initial = prefill;
|
|
39
|
-
// No prefill, or host without custom UI (tests / RPC stubs): stock input.
|
|
40
|
-
if (!initial || typeof ui.custom !== "function") return ui.input(title, initial);
|
|
41
|
-
|
|
42
|
-
return ui.custom<string | undefined>((tui, theme, _keybindings, done) =>
|
|
43
|
-
createPrefillInputComponent({
|
|
44
|
-
title,
|
|
45
|
-
prefill: initial,
|
|
46
|
-
theme: theme as PrefillTheme,
|
|
47
|
-
done,
|
|
48
|
-
requestRender: () => tui.requestRender(),
|
|
49
|
-
}),
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function createPrefillInputComponent(args: {
|
|
54
|
-
title: string;
|
|
55
|
-
prefill: string;
|
|
56
|
-
theme: PrefillTheme;
|
|
57
|
-
done: (value: string | undefined) => void;
|
|
58
|
-
requestRender: () => void;
|
|
59
|
-
}): Component & { handleInput(data: string): void; dispose?(): void } {
|
|
60
|
-
const input = new Input();
|
|
61
|
-
input.setValue(args.prefill);
|
|
62
|
-
// Move cursor to end so the prefill reads as an editable default.
|
|
63
|
-
input.handleInput("\x05");
|
|
64
|
-
let pristine = true;
|
|
65
|
-
const border = new DynamicBorder((s) => args.theme.fg("borderAccent", s));
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
render(width: number): string[] {
|
|
69
|
-
return [
|
|
70
|
-
...border.render(width),
|
|
71
|
-
"",
|
|
72
|
-
args.theme.fg("accent", args.title),
|
|
73
|
-
"",
|
|
74
|
-
...input.render(width),
|
|
75
|
-
"",
|
|
76
|
-
`${keyHint("tui.select.confirm", "submit")} ${keyHint("tui.select.cancel", "cancel")}`,
|
|
77
|
-
"",
|
|
78
|
-
...border.render(width),
|
|
79
|
-
];
|
|
80
|
-
},
|
|
81
|
-
invalidate() {
|
|
82
|
-
input.invalidate();
|
|
83
|
-
border.invalidate();
|
|
84
|
-
},
|
|
85
|
-
handleInput(data: string) {
|
|
86
|
-
const kb = getKeybindings();
|
|
87
|
-
if (kb.matches(data, "tui.select.confirm") || data === "\n") {
|
|
88
|
-
args.done(input.getValue());
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (kb.matches(data, "tui.select.cancel")) {
|
|
92
|
-
args.done(undefined);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (pristine && isPrefillReplacingInput(data)) {
|
|
96
|
-
input.setValue("");
|
|
97
|
-
pristine = false;
|
|
98
|
-
} else if (pristine) {
|
|
99
|
-
pristine = false;
|
|
100
|
-
}
|
|
101
|
-
input.handleInput(data);
|
|
102
|
-
args.requestRender();
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { Key, matchesKey } from "@earendil-works/pi-tui";
|
|
2
|
-
import type { ConfigEditingField, ConfigEditingTab } from "../config/config-editing-model.js";
|
|
3
|
-
import type {
|
|
4
|
-
SetupActionId,
|
|
5
|
-
SetupProfileChoice,
|
|
6
|
-
SetupStep,
|
|
7
|
-
SetupUiState,
|
|
8
|
-
} from "./setup-tui-types.js";
|
|
9
|
-
|
|
10
|
-
export type SetupIntent =
|
|
11
|
-
| { type: "close" }
|
|
12
|
-
| { type: "chooseDeployment" }
|
|
13
|
-
| { type: "guidedSetup" }
|
|
14
|
-
| { type: "flushQueue" }
|
|
15
|
-
| { type: "setMode" }
|
|
16
|
-
| { type: "nextOptOut" }
|
|
17
|
-
| { type: "applyMentalModels" }
|
|
18
|
-
| { type: "importSessions" }
|
|
19
|
-
| { type: "runDoctor" }
|
|
20
|
-
| { type: "initConfig" }
|
|
21
|
-
| { type: "toggleAdvanced" }
|
|
22
|
-
| { type: "moveTab"; delta: number }
|
|
23
|
-
| { type: "moveSelection"; delta: number }
|
|
24
|
-
| { type: "resetSelectedField" }
|
|
25
|
-
| { type: "editSelectedField" }
|
|
26
|
-
| { type: "startGuidedSetup" }
|
|
27
|
-
| { type: "chooseProfile"; profile: SetupProfileChoice }
|
|
28
|
-
| { type: "back" }
|
|
29
|
-
| { type: "finish" };
|
|
30
|
-
|
|
31
|
-
export type SetupResult =
|
|
32
|
-
| { kind: "state"; state: SetupUiState }
|
|
33
|
-
| { kind: "action"; action: SetupActionId | null; state: SetupUiState };
|
|
34
|
-
|
|
35
|
-
function defaultStep(step: SetupStep | undefined): SetupStep {
|
|
36
|
-
return step ?? "config";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function normalizedTabIndex(tabs: ConfigEditingTab[], tabIndex: number): number {
|
|
40
|
-
if (tabs.length === 0) return 0;
|
|
41
|
-
return Math.min(Math.max(0, tabIndex), tabs.length - 1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function selectedIndexForTab(tab: ConfigEditingTab | undefined, state: SetupUiState): number {
|
|
45
|
-
if (!tab) return 0;
|
|
46
|
-
return Math.min(state.selectedByTab[tab.id] ?? 0, Math.max(0, tab.fields.length - 1));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function withState(state: SetupUiState): SetupResult {
|
|
50
|
-
return { kind: "state", state };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function withAction(action: SetupActionId | null, state: SetupUiState): SetupResult {
|
|
54
|
-
return { kind: "action", action, state };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function nextStep(step: SetupStep): SetupStep {
|
|
58
|
-
if (step === "profile") return "banks";
|
|
59
|
-
if (step === "banks") return "review";
|
|
60
|
-
if (step === "review") return "done";
|
|
61
|
-
return step;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function previousStep(step: SetupStep): SetupStep {
|
|
65
|
-
if (step === "profile") return "config";
|
|
66
|
-
if (step === "banks") return "profile";
|
|
67
|
-
if (step === "review") return "banks";
|
|
68
|
-
if (step === "done") return "review";
|
|
69
|
-
return step;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function normalizeSetupUiState(tabs: ConfigEditingTab[], state: SetupUiState): SetupUiState {
|
|
73
|
-
const tabIndex = normalizedTabIndex(tabs, state.tabIndex);
|
|
74
|
-
const tab = tabs[tabIndex];
|
|
75
|
-
const selectedByTab = { ...state.selectedByTab };
|
|
76
|
-
if (tab) selectedByTab[tab.id] = selectedIndexForTab(tab, { ...state, tabIndex, selectedByTab });
|
|
77
|
-
return {
|
|
78
|
-
...state,
|
|
79
|
-
step: defaultStep(state.step),
|
|
80
|
-
tabIndex,
|
|
81
|
-
selectedByTab,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function currentSetupTab(
|
|
86
|
-
tabs: ConfigEditingTab[],
|
|
87
|
-
state: SetupUiState,
|
|
88
|
-
): ConfigEditingTab | undefined {
|
|
89
|
-
return tabs[normalizedTabIndex(tabs, state.tabIndex)];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function selectedSetupIndex(tabs: ConfigEditingTab[], state: SetupUiState): number {
|
|
93
|
-
return selectedIndexForTab(currentSetupTab(tabs, state), normalizeSetupUiState(tabs, state));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function selectedSetupField(
|
|
97
|
-
tabs: ConfigEditingTab[],
|
|
98
|
-
state: SetupUiState,
|
|
99
|
-
): ConfigEditingField | undefined {
|
|
100
|
-
const normalized = normalizeSetupUiState(tabs, state);
|
|
101
|
-
return currentSetupTab(tabs, normalized)?.fields[selectedSetupIndex(tabs, normalized)];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function setupIntentFromInput(data: string): SetupIntent | undefined {
|
|
105
|
-
if (matchesKey(data, Key.escape) || data === "q") return { type: "close" };
|
|
106
|
-
if (data === "d") return { type: "chooseDeployment" };
|
|
107
|
-
if (data === "g") return { type: "guidedSetup" };
|
|
108
|
-
if (data === "f") return { type: "flushQueue" };
|
|
109
|
-
if (data === "m") return { type: "setMode" };
|
|
110
|
-
if (data === "x") return { type: "nextOptOut" };
|
|
111
|
-
if (data === "t") return { type: "applyMentalModels" };
|
|
112
|
-
if (data === "i") return { type: "importSessions" };
|
|
113
|
-
if (data === "o") return { type: "runDoctor" };
|
|
114
|
-
if (data === "n") return { type: "initConfig" };
|
|
115
|
-
if (matchesKey(data, Key.left) || data === "h" || data === "<") {
|
|
116
|
-
return { type: "moveTab", delta: -1 };
|
|
117
|
-
}
|
|
118
|
-
if (matchesKey(data, Key.right) || data === "l" || data === ">") {
|
|
119
|
-
return { type: "moveTab", delta: 1 };
|
|
120
|
-
}
|
|
121
|
-
if (matchesKey(data, Key.up) || data === "k") return { type: "moveSelection", delta: -1 };
|
|
122
|
-
if (matchesKey(data, Key.down) || data === "j") return { type: "moveSelection", delta: 1 };
|
|
123
|
-
if (data === "r") return { type: "resetSelectedField" };
|
|
124
|
-
if (data === "a") return { type: "toggleAdvanced" };
|
|
125
|
-
if (matchesKey(data, Key.enter)) return { type: "editSelectedField" };
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function applySetupIntent(
|
|
130
|
-
tabs: ConfigEditingTab[],
|
|
131
|
-
state: SetupUiState,
|
|
132
|
-
intent: SetupIntent,
|
|
133
|
-
): SetupResult {
|
|
134
|
-
const normalized = normalizeSetupUiState(tabs, state);
|
|
135
|
-
if (intent.type === "close") return withAction(null, normalized);
|
|
136
|
-
if (intent.type === "chooseDeployment") return withAction("choose-deployment", normalized);
|
|
137
|
-
if (intent.type === "guidedSetup") return withAction("guided-setup", normalized);
|
|
138
|
-
if (intent.type === "flushQueue") return withAction("flush-queue", normalized);
|
|
139
|
-
if (intent.type === "setMode") return withAction("set-mode", normalized);
|
|
140
|
-
if (intent.type === "nextOptOut") return withAction("next-opt-out", normalized);
|
|
141
|
-
if (intent.type === "applyMentalModels") return withAction("apply-mental-models", normalized);
|
|
142
|
-
if (intent.type === "importSessions") return withAction("import-sessions", normalized);
|
|
143
|
-
if (intent.type === "runDoctor") return withAction("run-doctor", normalized);
|
|
144
|
-
if (intent.type === "initConfig") return withAction("init-config", normalized);
|
|
145
|
-
if (intent.type === "toggleAdvanced") return withAction("toggle-advanced", normalized);
|
|
146
|
-
if (intent.type === "finish") return withAction("done", { ...normalized, step: "done" });
|
|
147
|
-
if (intent.type === "startGuidedSetup") return withState({ ...normalized, step: "profile" });
|
|
148
|
-
if (intent.type === "chooseProfile") {
|
|
149
|
-
return withState({
|
|
150
|
-
...normalized,
|
|
151
|
-
profileChoice: intent.profile,
|
|
152
|
-
step: nextStep("profile"),
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if (intent.type === "back") {
|
|
156
|
-
return withState({ ...normalized, step: previousStep(defaultStep(normalized.step)) });
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const tab = currentSetupTab(tabs, normalized);
|
|
160
|
-
if (!tab || tabs.length === 0) return withState(normalized);
|
|
161
|
-
|
|
162
|
-
if (intent.type === "moveTab") {
|
|
163
|
-
const tabIndex = (normalized.tabIndex + intent.delta + tabs.length) % tabs.length;
|
|
164
|
-
const nextTab = tabs[tabIndex];
|
|
165
|
-
const selectedByTab = { ...normalized.selectedByTab };
|
|
166
|
-
if (nextTab)
|
|
167
|
-
selectedByTab[nextTab.id] = selectedIndexForTab(nextTab, { ...normalized, tabIndex });
|
|
168
|
-
return withState({ ...normalized, tabIndex, selectedByTab });
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (intent.type === "moveSelection") {
|
|
172
|
-
if (tab.fields.length === 0) return withState(normalized);
|
|
173
|
-
const index = selectedIndexForTab(tab, normalized);
|
|
174
|
-
return withState({
|
|
175
|
-
...normalized,
|
|
176
|
-
selectedByTab: {
|
|
177
|
-
...normalized.selectedByTab,
|
|
178
|
-
[tab.id]: (index + intent.delta + tab.fields.length) % tab.fields.length,
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const field = selectedSetupField(tabs, normalized);
|
|
184
|
-
if (intent.type === "resetSelectedField") {
|
|
185
|
-
return field?.changed ? withAction(`reset:${field.id}`, normalized) : withState(normalized);
|
|
186
|
-
}
|
|
187
|
-
if (intent.type === "editSelectedField") return withAction(field?.id ?? null, normalized);
|
|
188
|
-
return withState(normalized);
|
|
189
|
-
}
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { checkHindsight, createHindsightClient } from "../client/client.js";
|
|
3
|
-
import type { MemoryOperationsDeps } from "../operations/memory-operation-service.js";
|
|
4
|
-
import { createMemoryOperations } from "../operations/memory-operation-service.js";
|
|
5
|
-
import type { HindsightLikeClient, ResolvedConfig } from "../types.js";
|
|
6
|
-
import { apiKeyEnvName } from "../config/config-editing-registry.js";
|
|
7
|
-
|
|
8
|
-
export const LOCAL_DEFAULT_BASE_URL = "http://localhost:8888";
|
|
9
|
-
const DOCS_BASE_URL = "https://luxus.github.io/pi-hindsight";
|
|
10
|
-
const CLOUD_SIGNUP_URL = "https://ui.hindsight.vectorize.io/signup";
|
|
11
|
-
const INSTALL_URL = "https://hindsight.vectorize.io/developer/installation";
|
|
12
|
-
|
|
13
|
-
export type ServerProbeResult = {
|
|
14
|
-
ok: boolean;
|
|
15
|
-
baseUrl: string;
|
|
16
|
-
usedApiKey: boolean;
|
|
17
|
-
error?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** Result of the guided-setup server connection step. */
|
|
21
|
-
export type SetupServerConnection = {
|
|
22
|
-
/** false = cancel guided setup entirely */
|
|
23
|
-
continue: boolean;
|
|
24
|
-
/** true when proceeding without a reachable server (skip network offers) */
|
|
25
|
-
offline: boolean;
|
|
26
|
-
serverReachable: boolean;
|
|
27
|
-
baseUrl?: string;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function normalizeBaseUrl(url: string): string {
|
|
31
|
-
return url.trim().replace(/\/$/, "") || LOCAL_DEFAULT_BASE_URL;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Ordered unique base URLs to try during guided setup. */
|
|
35
|
-
export function buildServerProbeCandidates(config: ResolvedConfig): string[] {
|
|
36
|
-
const configured = normalizeBaseUrl(config.hindsight.baseUrl);
|
|
37
|
-
const candidates = [configured];
|
|
38
|
-
if (configured !== LOCAL_DEFAULT_BASE_URL) candidates.push(LOCAL_DEFAULT_BASE_URL);
|
|
39
|
-
return [...new Set(candidates)];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function hasResolvedApiKey(config: ResolvedConfig): boolean {
|
|
43
|
-
return Boolean(config.hindsight.apiKey?.trim());
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function formatServerProbeDocs(): string {
|
|
47
|
-
return [
|
|
48
|
-
"Pi Hindsight docs:",
|
|
49
|
-
` Setup TUI: ${DOCS_BASE_URL}/start/setup-tui/`,
|
|
50
|
-
` Getting started: ${DOCS_BASE_URL}/start/getting-started/`,
|
|
51
|
-
` Minimal config: ${DOCS_BASE_URL}/start/minimal-config/`,
|
|
52
|
-
`Hindsight server: ${INSTALL_URL}`,
|
|
53
|
-
`Hindsight Cloud signup: ${CLOUD_SIGNUP_URL}`,
|
|
54
|
-
].join("\n");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function formatServerProbeSuccess(result: ServerProbeResult): string {
|
|
58
|
-
const key = result.usedApiKey ? "with API key" : "without API key";
|
|
59
|
-
return `Hindsight server reachable at ${result.baseUrl} (${key}).`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function formatServerProbeFailure(args: {
|
|
63
|
-
results: ServerProbeResult[];
|
|
64
|
-
hasApiKey: boolean;
|
|
65
|
-
apiKeyEnvLabel: string;
|
|
66
|
-
}): string {
|
|
67
|
-
const lines = args.results.map((result) => {
|
|
68
|
-
const key = result.usedApiKey ? "with key" : "no key";
|
|
69
|
-
return ` • ${result.baseUrl} (${key}): ${result.error ?? "unreachable"}`;
|
|
70
|
-
});
|
|
71
|
-
return [
|
|
72
|
-
"Could not reach a Hindsight server yet.",
|
|
73
|
-
...lines,
|
|
74
|
-
`API key: ${args.hasApiKey ? "resolved" : `not set (${args.apiKeyEnvLabel})`}`,
|
|
75
|
-
"",
|
|
76
|
-
"Local embed often needs no key. Cloud / locked APIs need HINDSIGHT_API_TOKEN (or HINDSIGHT_API_KEY / your env name).",
|
|
77
|
-
"Cloud base URL comes from your Hindsight dashboard after signup — not a fixed public URL.",
|
|
78
|
-
].join("\n");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function formatApiKeyRestartRequired(envName: string): string {
|
|
82
|
-
return [
|
|
83
|
-
`Saved API key env ref “${envName}”, but it is not set in this Pi process.`,
|
|
84
|
-
`Export it, then restart Pi so the key is available:`,
|
|
85
|
-
` export ${envName}=…`,
|
|
86
|
-
` # restart Pi, then re-run /hindsight guided setup`,
|
|
87
|
-
"Or continue offline now for config-only setup (no mental models / import until online).",
|
|
88
|
-
].join("\n");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export async function probeHindsightBaseUrl(args: {
|
|
92
|
-
config: ResolvedConfig;
|
|
93
|
-
baseUrl: string;
|
|
94
|
-
createClient?: (config: ResolvedConfig) => HindsightLikeClient;
|
|
95
|
-
check?: typeof checkHindsight;
|
|
96
|
-
}): Promise<ServerProbeResult> {
|
|
97
|
-
const baseUrl = normalizeBaseUrl(args.baseUrl);
|
|
98
|
-
const createClient = args.createClient ?? createHindsightClient;
|
|
99
|
-
const check = args.check ?? checkHindsight;
|
|
100
|
-
const probeConfig: ResolvedConfig = {
|
|
101
|
-
...args.config,
|
|
102
|
-
hindsight: { ...args.config.hindsight, baseUrl },
|
|
103
|
-
};
|
|
104
|
-
const client = createClient(probeConfig);
|
|
105
|
-
const health = await check(client, "setup-probe");
|
|
106
|
-
return {
|
|
107
|
-
ok: health.ok,
|
|
108
|
-
baseUrl,
|
|
109
|
-
usedApiKey: hasResolvedApiKey(probeConfig),
|
|
110
|
-
...(health.error ? { error: health.error } : {}),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export async function probeHindsightCandidates(args: {
|
|
115
|
-
config: ResolvedConfig;
|
|
116
|
-
/** When probing the configured URL, prefer the live runtime client (tests/hooks). */
|
|
117
|
-
configuredClient?: HindsightLikeClient;
|
|
118
|
-
createClient?: (config: ResolvedConfig) => HindsightLikeClient;
|
|
119
|
-
check?: typeof checkHindsight;
|
|
120
|
-
}): Promise<{ ok: ServerProbeResult | undefined; attempts: ServerProbeResult[] }> {
|
|
121
|
-
const attempts: ServerProbeResult[] = [];
|
|
122
|
-
const check = args.check ?? checkHindsight;
|
|
123
|
-
const configured = normalizeBaseUrl(args.config.hindsight.baseUrl);
|
|
124
|
-
for (const baseUrl of buildServerProbeCandidates(args.config)) {
|
|
125
|
-
let result: ServerProbeResult;
|
|
126
|
-
if (baseUrl === configured && args.configuredClient) {
|
|
127
|
-
const health = await check(args.configuredClient, "setup-probe");
|
|
128
|
-
result = {
|
|
129
|
-
ok: health.ok,
|
|
130
|
-
baseUrl,
|
|
131
|
-
usedApiKey: hasResolvedApiKey(args.config),
|
|
132
|
-
...(health.error ? { error: health.error } : {}),
|
|
133
|
-
};
|
|
134
|
-
} else {
|
|
135
|
-
result = await probeHindsightBaseUrl({
|
|
136
|
-
config: args.config,
|
|
137
|
-
baseUrl,
|
|
138
|
-
...(args.createClient ? { createClient: args.createClient } : {}),
|
|
139
|
-
...(args.check ? { check: args.check } : {}),
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
attempts.push(result);
|
|
143
|
-
if (result.ok) return { ok: result, attempts };
|
|
144
|
-
}
|
|
145
|
-
return { ok: undefined, attempts };
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function chooseOfflineOrCancel(
|
|
149
|
-
ctx: ExtensionCommandContext,
|
|
150
|
-
title: string,
|
|
151
|
-
): Promise<SetupServerConnection> {
|
|
152
|
-
const choice = await ctx.ui.select(title, [
|
|
153
|
-
"Continue offline (config only)",
|
|
154
|
-
"Cancel guided setup",
|
|
155
|
-
]);
|
|
156
|
-
if (!choice || choice === "Cancel guided setup") {
|
|
157
|
-
return { continue: false, offline: false, serverReachable: false };
|
|
158
|
-
}
|
|
159
|
-
ctx.ui.notify(
|
|
160
|
-
"Continuing guided setup offline. Mental models and import are skipped until a server is reachable.",
|
|
161
|
-
"warning",
|
|
162
|
-
);
|
|
163
|
-
return { continue: true, offline: true, serverReachable: false };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Guided-setup step: health-check Hindsight, recover base URL / API key env, show docs.
|
|
168
|
-
* Returns offline=true when continuing without a reachable server (caller should skip MM/import).
|
|
169
|
-
*/
|
|
170
|
-
export async function ensureServerConnectionForSetup(args: {
|
|
171
|
-
ctx: ExtensionCommandContext;
|
|
172
|
-
deps: MemoryOperationsDeps;
|
|
173
|
-
cwd: string;
|
|
174
|
-
}): Promise<SetupServerConnection> {
|
|
175
|
-
const { ctx, deps, cwd } = args;
|
|
176
|
-
ctx.ui.notify(formatServerProbeDocs(), "info");
|
|
177
|
-
ctx.ui.notify("Checking Hindsight server connectivity…", "info");
|
|
178
|
-
|
|
179
|
-
let config = deps.getConfig();
|
|
180
|
-
let attempts = 0;
|
|
181
|
-
const maxAttempts = 4;
|
|
182
|
-
/** After saving an env ref that is missing in-process, do not re-probe empty. */
|
|
183
|
-
let pendingKeyRestart = false;
|
|
184
|
-
|
|
185
|
-
while (attempts < maxAttempts) {
|
|
186
|
-
attempts += 1;
|
|
187
|
-
|
|
188
|
-
if (pendingKeyRestart) {
|
|
189
|
-
ctx.ui.notify(
|
|
190
|
-
"API key env is configured in project config but not loaded in this process. Restart Pi after exporting the key, or continue offline.",
|
|
191
|
-
"warning",
|
|
192
|
-
);
|
|
193
|
-
const choice = await ctx.ui.select("API key requires restart", [
|
|
194
|
-
"Cancel guided setup (export key + restart Pi)",
|
|
195
|
-
"Continue offline (config only)",
|
|
196
|
-
]);
|
|
197
|
-
if (!choice || choice.startsWith("Cancel")) {
|
|
198
|
-
return { continue: false, offline: false, serverReachable: false };
|
|
199
|
-
}
|
|
200
|
-
ctx.ui.notify(
|
|
201
|
-
"Continuing guided setup offline. Mental models and import are skipped until a server is reachable.",
|
|
202
|
-
"warning",
|
|
203
|
-
);
|
|
204
|
-
return { continue: true, offline: true, serverReachable: false };
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const { ok, attempts: probeAttempts } = await probeHindsightCandidates({
|
|
208
|
-
config,
|
|
209
|
-
configuredClient: deps.getClient(),
|
|
210
|
-
});
|
|
211
|
-
if (ok) {
|
|
212
|
-
if (normalizeBaseUrl(config.hindsight.baseUrl) !== ok.baseUrl) {
|
|
213
|
-
await createMemoryOperations(deps).configure(cwd, { baseUrl: ok.baseUrl });
|
|
214
|
-
deps.reloadConfig?.(cwd);
|
|
215
|
-
config = deps.getConfig();
|
|
216
|
-
}
|
|
217
|
-
ctx.ui.notify(formatServerProbeSuccess(ok), "info");
|
|
218
|
-
return {
|
|
219
|
-
continue: true,
|
|
220
|
-
offline: false,
|
|
221
|
-
serverReachable: true,
|
|
222
|
-
baseUrl: ok.baseUrl,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const apiKeyEnvLabel =
|
|
227
|
-
apiKeyEnvName(config) !== "not set" ? apiKeyEnvName(config) : "HINDSIGHT_API_TOKEN";
|
|
228
|
-
ctx.ui.notify(
|
|
229
|
-
formatServerProbeFailure({
|
|
230
|
-
results: probeAttempts,
|
|
231
|
-
hasApiKey: hasResolvedApiKey(config),
|
|
232
|
-
apiKeyEnvLabel,
|
|
233
|
-
}),
|
|
234
|
-
"warning",
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
if (!hasResolvedApiKey(config)) {
|
|
238
|
-
const setKey = await ctx.ui.confirm(
|
|
239
|
-
"Configure API key env var?",
|
|
240
|
-
`No API key is resolved. Local servers often work without one. Cloud needs export ${apiKeyEnvLabel}=… then restart Pi. Save env var name to project config?`,
|
|
241
|
-
);
|
|
242
|
-
if (setKey) {
|
|
243
|
-
const envName = await ctx.ui.input("API key environment variable name", apiKeyEnvLabel);
|
|
244
|
-
if (envName?.trim()) {
|
|
245
|
-
await createMemoryOperations(deps).configure(cwd, {
|
|
246
|
-
apiKeyEnvVar: envName.trim(),
|
|
247
|
-
});
|
|
248
|
-
deps.reloadConfig?.(cwd);
|
|
249
|
-
config = deps.getConfig();
|
|
250
|
-
if (!hasResolvedApiKey(config)) {
|
|
251
|
-
ctx.ui.notify(formatApiKeyRestartRequired(envName.trim()), "warning");
|
|
252
|
-
pendingKeyRestart = true;
|
|
253
|
-
// Do not empty-reprobe; next loop handles restart vs offline.
|
|
254
|
-
continue;
|
|
255
|
-
}
|
|
256
|
-
// Key resolved after reload (unlikely mid-process unless injected) → re-probe.
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
} else {
|
|
261
|
-
const alt = await ctx.ui.confirm(
|
|
262
|
-
"Try a different base URL?",
|
|
263
|
-
"API key is set but the server was unreachable. Paste a Cloud/self-hosted API base URL from your Hindsight dashboard?",
|
|
264
|
-
);
|
|
265
|
-
if (alt) {
|
|
266
|
-
const url = await ctx.ui.input(
|
|
267
|
-
"Hindsight API base URL",
|
|
268
|
-
config.hindsight.baseUrl || LOCAL_DEFAULT_BASE_URL,
|
|
269
|
-
);
|
|
270
|
-
if (url?.trim()) {
|
|
271
|
-
await createMemoryOperations(deps).configure(cwd, { baseUrl: url.trim() });
|
|
272
|
-
deps.reloadConfig?.(cwd);
|
|
273
|
-
config = deps.getConfig();
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const choice = await ctx.ui.select("Server still unreachable", [
|
|
280
|
-
"Retry health check",
|
|
281
|
-
"Continue offline (config only)",
|
|
282
|
-
"Cancel guided setup",
|
|
283
|
-
]);
|
|
284
|
-
if (!choice || choice === "Cancel guided setup") {
|
|
285
|
-
return { continue: false, offline: false, serverReachable: false };
|
|
286
|
-
}
|
|
287
|
-
if (choice === "Retry health check") continue;
|
|
288
|
-
ctx.ui.notify(
|
|
289
|
-
"Continuing guided setup offline. Mental models and import are skipped until a server is reachable.",
|
|
290
|
-
"warning",
|
|
291
|
-
);
|
|
292
|
-
return { continue: true, offline: true, serverReachable: false };
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return chooseOfflineOrCancel(
|
|
296
|
-
ctx,
|
|
297
|
-
"Still no server after several attempts. Continue offline or cancel?",
|
|
298
|
-
);
|
|
299
|
-
}
|