pi-advisor-flow 0.6.0 → 0.8.0

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +34 -17
  2. package/README.md +10 -8
  3. package/dist/index.js +2852 -868
  4. package/extensions/index.ts +2 -1
  5. package/package.json +55 -40
  6. package/src/attachments.ts +11 -10
  7. package/src/commands/activation-preparation.ts +1 -0
  8. package/src/commands/activation.ts +2 -0
  9. package/src/commands/lifecycle.ts +1 -0
  10. package/src/commands/manual-command.ts +7 -1
  11. package/src/commands/manual-consultation.ts +103 -79
  12. package/src/commands/manual-progress.ts +7 -5
  13. package/src/commands/model-commands.ts +1 -1
  14. package/src/commands/model-options.ts +14 -3
  15. package/src/commands/model-picker.ts +1 -0
  16. package/src/commands/registration.ts +1 -0
  17. package/src/commands/renderers.ts +67 -55
  18. package/src/commands/runtime.ts +16 -14
  19. package/src/commands/settings-commands.ts +10 -4
  20. package/src/commands/settings-persistence.ts +64 -2
  21. package/src/commands/types.ts +2 -0
  22. package/src/commands.ts +0 -1
  23. package/src/config/args.ts +1 -1
  24. package/src/config/defaults.ts +83 -1
  25. package/src/config/schema.ts +152 -15
  26. package/src/config/state.ts +80 -2
  27. package/src/config/storage.ts +38 -22
  28. package/src/config/types.ts +45 -3
  29. package/src/config/validation.ts +33 -21
  30. package/src/config.ts +3 -0
  31. package/src/content-utils.ts +24 -4
  32. package/src/conversation.ts +16 -15
  33. package/src/git.ts +10 -3
  34. package/src/herdr-block.ts +83 -0
  35. package/src/herdr-shared.ts +108 -0
  36. package/src/herdr.ts +30 -192
  37. package/src/jev/client.ts +338 -0
  38. package/src/jev/failure.ts +19 -0
  39. package/src/jev/key-store.ts +267 -0
  40. package/src/jev/ledger.ts +228 -0
  41. package/src/jev/questions.ts +122 -0
  42. package/src/jev/state.ts +50 -0
  43. package/src/jev/transport.ts +63 -0
  44. package/src/model-stream.ts +35 -37
  45. package/src/outcomes.ts +20 -12
  46. package/src/pi-settings.ts +4 -9
  47. package/src/preferences.ts +4 -2
  48. package/src/redaction.ts +10 -12
  49. package/src/scout-context.ts +59 -60
  50. package/src/scout-curation.ts +4 -13
  51. package/src/scout-groups.ts +178 -175
  52. package/src/scout-protocol.ts +74 -70
  53. package/src/scout-reconstruct.ts +1 -1
  54. package/src/scout.ts +115 -73
  55. package/src/session-state.ts +148 -39
  56. package/src/tool-result-cap.ts +18 -17
  57. package/src/tools/consult-context.ts +7 -15
  58. package/src/tools/consultation.ts +14 -4
  59. package/src/tools/gate-policy.ts +1 -0
  60. package/src/tools/gate-protocol.ts +36 -23
  61. package/src/tools/jev-filter.ts +204 -0
  62. package/src/tools/jev-turn-gate.ts +203 -0
  63. package/src/tools/loop-gate.ts +32 -20
  64. package/src/tools/model-access.ts +46 -0
  65. package/src/tools/outage-notifier.ts +30 -0
  66. package/src/tools/prompts.ts +20 -25
  67. package/src/tools/register-ask-advisor.ts +73 -17
  68. package/src/tools/register-lifecycle.ts +22 -0
  69. package/src/tools/register-outcome.ts +2 -0
  70. package/src/tools/register-renderers.ts +149 -73
  71. package/src/tools/registration.ts +15 -0
  72. package/src/tools/render-advisor-result.ts +77 -35
  73. package/src/tools/render-common.ts +16 -19
  74. package/src/tools/scout-status.ts +42 -27
  75. package/src/tools/types.ts +11 -0
  76. package/src/tools.ts +0 -1
  77. package/src/ui/jev-setup-submenu.ts +350 -0
  78. package/src/ui/manual-dialog-render.ts +1 -0
  79. package/src/ui/manual-dialog.ts +39 -43
  80. package/src/ui/masked-input.ts +62 -0
  81. package/src/ui/model-multi-selector.ts +9 -0
  82. package/src/ui/model-selector-adapter.ts +31 -0
  83. package/src/ui/model-selector.ts +14 -161
  84. package/src/ui/searchable-model-list.ts +230 -0
  85. package/src/ui/settings-formatting.ts +24 -14
  86. package/src/ui/settings-items.ts +200 -2
  87. package/src/ui/settings-list-adapter.ts +15 -12
  88. package/src/ui/settings-mutations.ts +169 -47
  89. package/src/ui/settings-selector.ts +18 -9
  90. package/src/ui/text-setting-submenu.ts +3 -6
  91. package/src/ui/types.ts +25 -0
  92. package/src/ui.ts +0 -1
  93. package/src/usage.ts +29 -20
package/CHANGELOG.md CHANGED
@@ -4,6 +4,35 @@ All notable changes to this project are documented here.
4
4
 
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0/).
6
6
 
7
+ ## 0.8.0 - 2026-09-22
8
+
9
+ ### Added
10
+
11
+ - Added the optional `advisorModelWhitelist` setting. Exact `provider/model` Executor references in the list may use `ask_advisor` or automatic Advisor gates; an empty list preserves the previous unrestricted behavior.
12
+
13
+ ### Changed
14
+
15
+ - Dropped peer-dependency support for Pi 0.84.x hosts; supported versions are 0.85.x and 0.87.x.
16
+ - Replaced the Biome linter and formatter with Oxlint and Oxfmt, keeping Ultracite presets and the existing scanner rules (`noConsole`, `noFloatingPromises`, `useImportExtensions`, undeclared-dependency checks via a local Oxlint rule; `noPrivateImports` remains enforced by `tsc --noEmit`).
17
+ - Added the Ultracite-bundled anti-slop ruleset (unjustified type assertions, `unknown` leakage, Reflect access, module mocking) and remediated all findings.
18
+ - Updated the Pi development and peer dependencies to `@earendil-works/*` 0.87.1.
19
+
20
+ ## 0.7.0 - 2026-09-19
21
+
22
+ ### Added
23
+
24
+ - **Jev consultation filter** — an optional gate in front of `ask_advisor`. Jev, a small classification model by TypeSafe, takes one quick, inexpensive look at each consultation request; when it is clearly low-stakes and resolvable without the Advisor, the consultation is skipped with a short note telling the Executor to carry on — saving a full Advisor call. Everything else consults exactly as before, and if Jev cannot be reached the consultation simply goes through. Off by default.
25
+ - **Proactive turn gate** — pi-advisor can now notice when the Executor has worked through several turns without any advice. Every N turns, one quick Jev check asks whether a senior second opinion is warranted right now; on a confident yes the Advisor consults and its advice is delivered to the Executor between turns. Also off by default.
26
+ - **One-step setup** — open `/advisor-settings` → _Jev consultation filter_ for guided setup: it verifies your access with one live call before turning anything on. Either paste a TypeSafe API key (stored securely — in your system's secret store when available, otherwise a dedicated owner-only file under `~/.pi/agent/`) or skip keys entirely: with an existing OpenRouter login in Pi, Jev reuses it automatically. A hand-placed plaintext key in `advisor.json` keeps working read-only and can be migrated to secure storage from the same screen.
27
+ - **Skip-aware accounting** — the Session Advisor Summary shows how many consultations were screened, skipped, or overridden, what the Jev checks cost, and a labelled upper-bound estimate of what the skips saved; skipped consultations never touch the Advisor-call budget.
28
+ - `/advisor-manual` consultations are now remembered by their question: if the Executor later asks the Advisor the exact same thing, the earlier advice is reattached instead of running another consultation. This deduplication is instant, free, and works even with the Jev screening filter turned off; sessions without any Jev activity report it as `Consultation dedup:` in the summary.
29
+ - All Jev thresholds, costs, and the turn-gate interval are tunable from the `Jev …` rows in `/advisor-settings` without editing files. The default Jev call timeout is provisional pending real-world measurements.
30
+
31
+ ### Changed
32
+
33
+ - The manual Advisor result message to the Executor now states it is informational and that no follow-up consultation is needed, preventing duplicate consultations.
34
+ - Updated development tooling dependencies (ultracite 7.12.0, Biome 2.5.13, knip 6.37.0, lint-staged 17.5.1, typebox 1.3.34, @types/node 26.6.2, bun-types 1.4.2); no runtime dependencies changed. Biome is held at 2.5.13 because 2.5.14's `noUnnecessaryConditions` regression falsely flags the gate parsers' required `RegExp.exec` null-guards as dead code.
35
+
7
36
  ## 0.6.0 - 2026-09-12
8
37
 
9
38
  ### Fixed
@@ -74,22 +103,11 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
74
103
 
75
104
  ### Added
76
105
 
77
- - Added a repository-only failsafe benchmark with an offline replay tier, a
78
- 24-item decision-point corpus, a fail-closed Pi/Harbor ReactBench adapter,
79
- pinned live-tier controls, hard budget limits, and task-level
80
- uplift/dominance reporting. See [Benchmarking](docs/benchmark.md).
81
- - Added bounded local Harbor runtime controls for Apple Container experiments,
82
- Docker build-cache cleanup, and a recorded one-hour agent timeout for complex
83
- ReactBench tasks.
84
- - Added a disposable, credential-free GitHub build compatibility layer for
85
- pinned ReactBench Dockerfiles whose Git 2.39 transport is rejected by the
86
- GitHub endpoint, with bounded pre-agent Harbor infrastructure retries and
87
- per-attempt artifacts for transient build and transport failures.
88
- - Derived the host Harbor command timeout from the bounded agent timeout and
89
- made timeout cleanup terminate the full Harbor process group, including the
90
- broker and descendants.
91
- - Ensured configured Advisor reasoning effort reaches the provider-facing
92
- request field used by current Pi AI adapters.
106
+ - Added a repository-only failsafe benchmark with an offline replay tier, a 24-item decision-point corpus, a fail-closed Pi/Harbor ReactBench adapter, pinned live-tier controls, hard budget limits, and task-level uplift/dominance reporting. See [Benchmarking](docs/benchmark.md).
107
+ - Added bounded local Harbor runtime controls for Apple Container experiments, Docker build-cache cleanup, and a recorded one-hour agent timeout for complex ReactBench tasks.
108
+ - Added a disposable, credential-free GitHub build compatibility layer for pinned ReactBench Dockerfiles whose Git 2.39 transport is rejected by the GitHub endpoint, with bounded pre-agent Harbor infrastructure retries and per-attempt artifacts for transient build and transport failures.
109
+ - Derived the host Harbor command timeout from the bounded agent timeout and made timeout cleanup terminate the full Harbor process group, including the broker and descendants.
110
+ - Ensured configured Advisor reasoning effort reaches the provider-facing request field used by current Pi AI adapters.
93
111
 
94
112
  ### Fixed
95
113
 
@@ -365,7 +383,6 @@ This version was never published to npm; its changes shipped in 0.2.6.
365
383
  - Manual, Executor-requested, and automatic Advisor consultations share the configured session call limit.
366
384
  - Herdr activity and blocked state use separate extension metadata sources so clearing one does not clear the other.
367
385
 
368
-
369
386
  ## [0.1.7]
370
387
 
371
388
  ### Added
package/README.md CHANGED
@@ -20,11 +20,13 @@ Keep implementation on a fast model and borrow frontier reasoning only when deci
20
20
  - **Configurable review gates** before plans, after repeated failures, and before declaring completion.
21
21
  - **Automatic loop detection** for repeated tool calls, with explicit proceed, revise, or blocked decisions.
22
22
  - **Separate model and reasoning controls** for the Executor and Advisor.
23
+ - **Model whitelist** that can restrict Advisor calls to exact `provider/model` Executor references.
23
24
  - **Advisor usage accounting** with per-response token and cost details, normalized usage in Pi's `/cost` totals, and an optional cumulative footer.
24
25
  - **Privacy controls** for conversation history, repository context, explicit file handoff, tool results, secret redaction, and outcome logging.
25
26
  - **Optional persistent activation, Simple mode, session summaries, and Herdr integration.**
26
27
  - **Compact searchable `/advisor-settings`** that matches Pi's settings list and saves changes immediately.
27
28
  - **Experimental Advisor Scout** that uses the configured Executor model to curate conversation evidence before every Advisor call.
29
+ - **Optional Jev consultation filter and proactive turn gate** (TypeSafe): one cheap typed screening call skips low-stakes, self-answerable consultations; a periodic turn check can proactively pull in the Advisor. Works directly with a TypeSafe key or by reusing an existing OpenRouter login; both features are off by default.
28
30
 
29
31
  ## How it works
30
32
 
@@ -66,7 +68,7 @@ On first use, or whenever a saved model is unavailable, `/advisor` opens the sam
66
68
  /advisor executor=openai-codex/gpt-5.6-luna advisor=openai-codex/gpt-5.6-sol
67
69
  ```
68
70
 
69
- From the Executor, `ask_advisor({})` requests a general review. A targeted `question` or concise `draft` can focus the review on a particular decision.
71
+ From the Executor, `ask_advisor({})` requests a general review. A targeted `question` or concise `draft` can focus the review on a particular decision. `/advisor-settings` can restrict this tool and every automatic Advisor gate to a whitelist of exact `provider/model` Executor references; an empty whitelist preserves the default of allowing every model.
70
72
 
71
73
  In the Settings, enable Simple Mode for a quick start.
72
74
 
@@ -82,13 +84,13 @@ Successful calls return an opaque `adviceId`. If global outcome logging is enabl
82
84
 
83
85
  ## Commands
84
86
 
85
- | Command | What it does |
86
- | ------------------------- | --------------------------------------------------- |
87
- | `/advisor` | Enable the flow; choose available models when needed. |
88
- | `/advisor-manual [focus]` | Ask for an immediate second opinion. |
89
- | `/advisor-models` | Choose the Executor and Advisor models. |
90
- | `/advisor-settings` | Configure behavior, context, privacy, and limits. |
91
- | `/advisor-off` | Disable the flow and persistent activation. |
87
+ | Command | What it does |
88
+ | --- | --- |
89
+ | `/advisor` | Enable the flow; choose available models when needed. |
90
+ | `/advisor-manual [focus]` | Ask for an immediate second opinion. |
91
+ | `/advisor-models` | Choose the Executor and Advisor models. |
92
+ | `/advisor-settings` | Configure behavior, context, privacy, and limits. |
93
+ | `/advisor-off` | Disable the flow and persistent activation. |
92
94
 
93
95
  In the interactive TUI, `/advisor-manual [focus]` opens a centered overlay with the focus text prefilled, a choice of permitted Git-context level, and live progress in the transcript. Canceling has no side effects.
94
96