pi-advisor-flow 0.9.2-dev.4 → 0.10.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 (40) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +16 -7
  3. package/dist/index.js +938 -287
  4. package/package.json +2 -2
  5. package/src/commands/activation-preparation.ts +4 -0
  6. package/src/commands/manual-consultation.ts +20 -3
  7. package/src/commands/model-commands.ts +5 -1
  8. package/src/commands/model-picker.ts +44 -2
  9. package/src/commands/outcome-stats.ts +98 -0
  10. package/src/commands/registration.ts +2 -0
  11. package/src/commands/renderers.ts +51 -0
  12. package/src/commands/runtime.ts +9 -1
  13. package/src/commands/settings-persistence.ts +4 -0
  14. package/src/commands/types.ts +5 -2
  15. package/src/config/defaults.ts +13 -0
  16. package/src/config/schema.ts +14 -0
  17. package/src/config/state.ts +10 -0
  18. package/src/config/types.ts +2 -0
  19. package/src/config.ts +4 -0
  20. package/src/follow-up.ts +85 -0
  21. package/src/outcome-stats.ts +154 -0
  22. package/src/outcomes.ts +8 -1
  23. package/src/preferences.ts +90 -12
  24. package/src/session-state.ts +33 -0
  25. package/src/tools/consult-context.ts +12 -1
  26. package/src/tools/consultation.ts +344 -47
  27. package/src/tools/jev-turn-gate.ts +2 -0
  28. package/src/tools/loop-gate.ts +2 -0
  29. package/src/tools/model-access.ts +7 -3
  30. package/src/tools/prompts.ts +28 -2
  31. package/src/tools/register-ask-advisor.ts +110 -23
  32. package/src/tools/register-lifecycle.ts +11 -0
  33. package/src/tools/register-renderers.ts +40 -6
  34. package/src/tools/render-advisor-result.ts +6 -0
  35. package/src/tools/render-common.ts +6 -2
  36. package/src/tools/types.ts +5 -0
  37. package/src/ui/settings-items.ts +43 -0
  38. package/src/ui/settings-mutations.ts +9 -0
  39. package/src/ui/settings-selector.ts +9 -0
  40. package/src/ui/types.ts +4 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.10.0 - 2026-10-02
10
+
11
+ ### Added
12
+
13
+ - Added an optional `advisorFallbackModel`, selectable from `/advisor-models` and `/advisor-settings`, that retries a failed primary Advisor request once while attributing the response to the model that answered.
14
+ - Added `followUpTo` support for short-lived, session-local Advisor follow-ups that reuse the original post-redaction payload prefix, enforce depth and conversation-advance limits, and render distinct usage status.
15
+ - Added `/advisor-stats`, a local rendered report for retained outcome triggers, adoption, followed-versus-rejected validation pass rates, distinct pseudonymous advice hashes, and the capped ledger time window.
16
+ - Added default-on, toggleable `AGENTS.md` context for trusted Advisor calls, with origin labels, redaction, byte caps, untrusted-rule framing, and explicit withholding for untrusted projects.
17
+
9
18
  ### Fixed
10
19
 
11
20
  - Prevented settings saves from overwriting malformed `advisor.json` files and rolled back runtime settings when persistence fails.
@@ -15,8 +24,10 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
15
24
 
16
25
  ### Changed
17
26
 
27
+ - Fallback retries count as one consultation against the shared Advisor budget; follow-ups count as one consultation each and require a new question without extra attachments or context overrides.
18
28
  - Pi 0.87.x and 0.99.x hosts are no longer supported; Pi 1.0.x is now the supported Pi host and the peer range is `^1.0.0`.
19
29
  - Updated the development toolchain to the Pi 1.0.0 packages.
30
+ - Updated the Node.js type definitions to 26.6.4.
20
31
 
21
32
  ## 0.9.1 - 2026-09-30
22
33
 
package/README.md CHANGED
@@ -20,9 +20,12 @@ 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, with same-model consultations skipped by default to avoid redundant calls.
23
+ - **Optional Advisor fallback model** that retries provider, auth, and availability failures once without consuming a second consultation budget slot.
24
+ - **Cached Advisor follow-ups** through `followUpTo`, reusing a short-lived, redacted payload prefix for focused questions.
23
25
  - **Model whitelist** that can restrict Advisor calls to exact `provider/model` Executor references.
24
26
  - **Advisor usage accounting** with per-response token and cost details, normalized usage in Pi's `/cost` totals, and an optional cumulative footer.
25
- - **Privacy controls** for conversation history, repository context, explicit file and image handoff, tool results, secret redaction, and outcome logging.
27
+ - **Outcome reporting** through `/advisor-stats`, with adoption and validation comparisons over the retained ledger window.
28
+ - **Privacy controls** for conversation history, repository context, trusted `AGENTS.md` rules, explicit file and image handoff, tool results, secret redaction, and outcome logging.
26
29
  - **Visual Advisor reviews** for supported PNG, JPEG, GIF, and WebP images in selected conversation or tool results when the Advisor model accepts images.
27
30
  - **Optional persistent activation, Simple mode, session summaries, and Herdr integration.**
28
31
  - **Compact searchable `/advisor-settings`** that matches Pi's settings list and saves changes immediately.
@@ -67,8 +70,9 @@ Reload Pi after installing.
67
70
 
68
71
  ```text
69
72
  /advisor # Enable the Advisor Flow
70
- /advisor-models # Choose the Executor and Advisor models
73
+ /advisor-models # Choose the Executor, Advisor, and optional fallback models
71
74
  /advisor-settings # Configure behavior, modes, etc.
75
+ /advisor-stats # Show retained outcome adoption and validation stats
72
76
  ```
73
77
 
74
78
  On first use, or whenever a saved model is unavailable, `/advisor` opens the same available-model picker as `/advisor-models`; it never silently chooses an unconfigured model. If the active Executor and Advisor use the same provider/model, calls and automatic gates are skipped with a notice; switching either model resumes consultations. Turn off **Disable same-model Advisor** in `/advisor-settings` (or set `"advisorDisableSameModel": false` globally) if you intentionally want a higher-effort review from that same model. You can also enable the flow and select both models at once:
@@ -87,9 +91,13 @@ Unknown fields in `advisor.json` are preserved for forward compatibility and rep
87
91
 
88
92
  ## Usage and accounting
89
93
 
90
- Advisor responses show provider-reported input, output, cache, and cost details when available. Successful `ask_advisor` calls also carry normalized usage into Pi's built-in `/cost` totals. Manual consultations and automatic gates keep their own session-local accounting instead, so nothing is double-counted. Missing or partial provider usage is shown as unavailable rather than fabricated as zero. `/advisor-settings` controls both the per-response details and the optional cumulative footer independently.
94
+ Advisor responses show provider-reported input, output, cache, and cost details when available. Successful `ask_advisor` calls also carry normalized usage into Pi's built-in `/cost` totals. Manual consultations and automatic gates keep their own session-local accounting instead, so nothing is double-counted. Missing or partial provider usage is shown as unavailable rather than fabricated as zero. `/advisor-settings` controls both the per-response details and the optional cumulative footer independently. Configure `advisorFallbackModel` or choose **Fallback Advisor model** in the model/settings pickers to retry one failed primary request; the final response is labelled with the model that answered, and both failures are shown together.
91
95
 
92
- Successful calls return an opaque `adviceId`. If global outcome logging is enabled, the Executor can call `record_advisor_outcome` once to record whether the advice was adopted and whether final validation passed.
96
+ A follow-up reuses only the original post-redaction payload in memory. It expires after five minutes, is cleared by a new user turn or three subsequent non-Advisor tool results, and allows at most three chained follow-ups. Use a fresh consultation when it expires or when you need new repository context or attachments.
97
+
98
+ `/advisor-stats` reads the local outcomes ledger and reports trigger counts, adoption, followed-versus-rejected validation pass rates, distinct pseudonymous advice hashes, and the retained time window. It never fabricates historical cost data; the ledger is capped at 1 MiB and rewritten on overflow.
99
+
100
+ Successful calls return an opaque `adviceId`. If global outcome logging is enabled, the Executor can call `record_advisor_outcome` once to record whether the advice was adopted and whether final validation passed. A later `ask_advisor` call can pass that ID as `followUpTo` with a new question; the follow-up is counted once against the session budget and shows its responding model and follow-up status.
93
101
 
94
102
  ## Commands
95
103
 
@@ -97,8 +105,9 @@ Successful calls return an opaque `adviceId`. If global outcome logging is enabl
97
105
  | --- | --- |
98
106
  | `/advisor` | Enable the flow; choose available models when needed. |
99
107
  | `/advisor-manual [focus]` | Ask for an immediate second opinion. |
100
- | `/advisor-models` | Choose the Executor and Advisor models. |
101
- | `/advisor-settings` | Configure behavior, context, privacy, and limits. |
108
+ | `/advisor-models` | Choose the Executor, Advisor, and optional fallback models. |
109
+ | `/advisor-settings` | Configure behavior, models, context, privacy, and limits. |
110
+ | `/advisor-stats` | Show retained outcome adoption and validation stats. |
102
111
  | `/advisor-off` | Disable the flow and persistent activation. |
103
112
 
104
113
  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.
@@ -109,7 +118,7 @@ Advisor Scout is off by default. When enabled in `/advisor-settings` or via `"ad
109
118
 
110
119
  ## Privacy
111
120
 
112
- Advisor requests can include user messages, tool calls, tool results, targeted questions, and repository information. Repository context is configurable from no access through changed-file summaries to a capped patch; when it is disabled, the Advisor is told so rather than shown an apparently clean tree. Images from disclosed conversation and full-policy tool results can be sent as pixels only to image-capable Advisor models; Scout sees markers, not pixels. Exact tracked and untracked image files can be attached using `includeTrackedFiles` and `includeUntracked` under their existing separate global consent rules. Images are limited to four and 8 MiB total, with a 4 MiB per-image cap; unsupported, missing, or oversized images are reported as withheld, not reviewed. Explicit tracked and untracked file contents require separate global opt-ins and are sent as untrusted data. Secret redaction is off by default; when enabled, credential-shaped values in targeted questions are redacted before the provider request. Tools without an explicit policy use full context. Settings are global, so a project cannot silently change them.
121
+ Advisor requests can include user messages, tool calls, tool results, targeted questions, trusted project and global `AGENTS.md` rules, and repository information. `advisorAgentsMdContext` is on by default and can be disabled in `/advisor-settings`; rules are sent as origin-labelled, capped, redacted, untrusted review guidance only. Untrusted projects withhold both rule files and tell the Advisor that rules were withheld. Repository context is configurable from no access through changed-file summaries to a capped patch; when it is disabled, the Advisor is told so rather than shown an apparently clean tree. Images from disclosed conversation and full-policy tool results can be sent as pixels only to image-capable Advisor models; Scout sees markers, not pixels. Exact tracked and untracked image files can be attached using `includeTrackedFiles` and `includeUntracked` under their existing separate global consent rules. Images are limited to four and 8 MiB total, with a 4 MiB per-image cap; unsupported, missing, or oversized images are reported as withheld, not reviewed. Explicit tracked and untracked file contents require separate global opt-ins and are sent as untrusted data. Secret redaction is off by default; when enabled, credential-shaped values in targeted questions are redacted before the provider request. Tools without an explicit policy use full context. Settings are global, so a project cannot silently change them.
113
122
 
114
123
  When Scout is enabled, the Executor model provider also receives bounded Advisor-eligible conversation history. Read [Privacy and data handling](https://github.com/philipbrembeck/pi-advisor/blob/main/docs/privacy.md) before using pi-advisor with sensitive work.
115
124