pi-advisor-flow 0.16.1-dev.2 → 0.17.1-dev.1
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/CHANGELOG.md +14 -0
- package/README.md +17 -9
- package/dist/index.js +396 -106
- package/docs/configuration.md +21 -10
- package/docs/privacy.md +2 -2
- package/locales/de.json +8 -1
- package/locales/en.json +8 -1
- package/locales/fr.json +8 -1
- package/package.json +11 -11
- package/src/commands/activation-preparation.ts +30 -3
- package/src/commands/activation-settings.ts +73 -0
- package/src/commands/activation.ts +75 -56
- package/src/commands/advisor-tools.ts +27 -6
- package/src/commands/configuration-tool-preview.ts +107 -15
- package/src/commands/configuration-tool-runtime.ts +3 -20
- package/src/commands/configuration-tool-update.ts +23 -1
- package/src/commands/lifecycle.ts +30 -1
- package/src/commands/manual-progress.ts +5 -5
- package/src/commands/model-commands.ts +17 -0
- package/src/commands/model-picker.ts +14 -6
- package/src/commands/settings-commands.ts +36 -20
- package/src/commands/settings-persistence.ts +37 -1
- package/src/config/defaults.ts +10 -0
- package/src/config/schema-validators.ts +10 -0
- package/src/config/schema.ts +24 -1
- package/src/config/session-overrides.ts +109 -0
- package/src/config/state.ts +19 -0
- package/src/config/storage.ts +15 -1
- package/src/config/types.ts +11 -0
- package/src/session-state.ts +2 -0
- package/src/tools/budget-feedback.ts +2 -2
- package/src/tools/prompts.ts +18 -0
- package/src/tools/register-ask-advisor.ts +10 -4
- package/src/tools/register-lifecycle.ts +12 -6
- package/src/tools/registration.ts +8 -1
- package/src/tools/session-availability.ts +10 -0
- package/src/ui/settings-items.ts +43 -6
- package/src/ui/settings-list-adapter.ts +1 -1
- package/src/ui/settings-mutations.ts +14 -0
- package/src/ui/settings-selector.ts +1 -0
- package/src/ui/types.ts +8 -1
package/docs/configuration.md
CHANGED
|
@@ -6,11 +6,11 @@ Repository-controlled project `advisor.json` files are not applied. Models, prom
|
|
|
6
6
|
|
|
7
7
|
## Configure from chat
|
|
8
8
|
|
|
9
|
-
When the user asks the Executor to configure pi-advisor, it can call `advisor_config` with `action: "read"` to inspect current effective settings and persisted global overrides, or `action: "update"` with a sparse `changes` object. Updates use the exact keys returned as `writableKeys`; `null` removes a saved override and restores the extension default. The tool validates the merged config, preserves unknown fields, displays the old-to-new changes, and requires interactive confirmation before writing. It remains available
|
|
9
|
+
When the user asks the Executor to configure pi-advisor, it can call `advisor_config` with `action: "read"` to inspect current effective settings and persisted global overrides, or `action: "update"` with a sparse `changes` object. Updates use the exact keys returned as `writableKeys`; `null` removes a saved override and restores the extension default. The tool validates the merged config, preserves unknown fields, displays the old-to-new changes, and requires interactive confirmation before writing. It remains available when model-facing Advisor tools are disabled in persistent mode; session mode also disables `advisor_config` until `/advisor` is run.
|
|
10
10
|
|
|
11
11
|
Model changes open the existing interactive picker rather than accepting a model-generated ref as approval. Saving an Executor model only pins it; run `/advisor` to activate that model in the current session. Jev classifier and credential provisioning stays in `/advisor-settings`. `advisorOutcomeLogging` is supported only as a separate update through its existing consent path. Always on changes apply to future sessions and do not start an Advisor call immediately.
|
|
12
12
|
|
|
13
|
-
`/advisor` also accepts `executor=`, `advisor=`, and `contextMaxChars=` overrides for the current activation. For example, `/advisor contextMaxChars=30000` sets the reconstructed-history limit; use `0` for no history. The `ALL` option in settings represents the complete current branch and remains subject to the Advisor model's context limit. When `executor` is unset, the Executor is the current Pi session model and thinking level (unless `executorEffort` is set); `/advisor` does not switch models. On first use, or when the saved Advisor ref is missing from the configuration or Pi's available model list, `/advisor` opens the available-model picker instead of silently choosing an unconfigured model. An explicit `executor` that is no longer available is picked again; choose **Current session model** to clear it.
|
|
13
|
+
`/advisor` also accepts `executor=`, `advisor=`, and `contextMaxChars=` overrides for the current activation. For example, `/advisor contextMaxChars=30000` sets the reconstructed-history limit; use `0` for no history. The `ALL` option in settings represents the complete current branch and remains subject to the Advisor model's context limit. When `executor` is unset, the Executor is the current Pi session model and thinking level (unless `executorEffort` is set); `/advisor` does not switch models. On first use, or when the saved Advisor ref is missing from the configuration or Pi's available model list, `/advisor` opens the available-model picker instead of silently choosing an unconfigured model. An explicit `executor` that is no longer available is picked again; choose **Current session model** to clear it. In the default persistent mode, selected refs are saved only after the models pass activation checks. In session mode, `/advisor` keeps model selections and arguments in memory without writing `advisor.json`; use `/advisor-models` to save them explicitly.
|
|
14
14
|
|
|
15
15
|
All fields are optional. The model refs below are explicit examples of models available through your configured providers; omit them to choose models interactively with `/advisor`. Disclosure and redaction fields are explained in [Privacy and data handling](privacy.md).
|
|
16
16
|
|
|
@@ -47,6 +47,7 @@ All fields are optional. The model refs below are explicit examples of models av
|
|
|
47
47
|
"advisorGitContext": "summary",
|
|
48
48
|
"advisorGitContextMaxChars": 20000,
|
|
49
49
|
"simpleMode": false,
|
|
50
|
+
"advisorActivation": "persistent",
|
|
50
51
|
"advisorToolsEnabled": true,
|
|
51
52
|
"alwaysOn": false,
|
|
52
53
|
"advisorHerdrIntegration": true,
|
|
@@ -56,6 +57,7 @@ All fields are optional. The model refs below are explicit examples of models av
|
|
|
56
57
|
"advisorRedactSecrets": false,
|
|
57
58
|
"advisorAgentsMdContext": true,
|
|
58
59
|
"advisorTrackedFileContent": false,
|
|
60
|
+
"advisorTrackedFileHandoff": "advisor-named",
|
|
59
61
|
"advisorUntrackedContent": false,
|
|
60
62
|
"advisorDisableSameModel": true,
|
|
61
63
|
"advisorOutcomeLogging": false,
|
|
@@ -77,6 +79,15 @@ All fields are optional. The model refs below are explicit examples of models av
|
|
|
77
79
|
|
|
78
80
|
`advisorDisableSameModel` defaults to `true`. When the active Executor model is the same provider/model as the configured Advisor, `ask_advisor` returns a skipped result without calling the provider, screening with Jev, consuming a consultation, or using a tracked-file handoff. Manual calls and automatic gates are skipped too; they never create a tool or session block. The active model (including models selected by `/model`) is compared, not just the saved Executor setting. `/advisor`, `/advisor-models`, and model selection re-check the match and show a notice on transitions. Turn this setting off in `/advisor-settings` if you want a same-model consultation with a different reasoning level.
|
|
79
81
|
|
|
82
|
+
## Tracked file handoff
|
|
83
|
+
|
|
84
|
+
`advisorTrackedFileHandoff` controls when the Executor may pass `includeTrackedFiles` to `ask_advisor`. Both modes require `advisorTrackedFileContent` to be `true`, and both keep the same path, size, redaction, and untrusted-data rules.
|
|
85
|
+
|
|
86
|
+
- `advisor-named` (default) allows `includeTrackedFiles` only after the latest Advisor answer names each requested path exactly. The attachment is a fresh consultation after that answer and spends one call from the shared budget.
|
|
87
|
+
- `executor` allows `includeTrackedFiles` on any consultation, so the first answer can use the documents the Executor already cites. The Executor decides which files to send.
|
|
88
|
+
|
|
89
|
+
Set it with **Tracked file handoff** in `/advisor-settings`, or with `"advisorTrackedFileHandoff": "executor"` in `advisor.json`. Enforcement applies to the next tool call; the Executor's guidance updates on its next turn.
|
|
90
|
+
|
|
80
91
|
## Follow-up consultations
|
|
81
92
|
|
|
82
93
|
Pass `followUpTo` with a new non-empty `question` to `ask_advisor` to continue an existing response. The tool reuses the exact post-redaction payload prefix captured for that `adviceId` and appends only the follow-up question, so Scout does not rebuild the conversation. Jev screening, same-model suppression, the whitelist, current privacy policy, and the shared call budget still apply. Follow-ups count once against `advisorMaxCallsPerSession` and render a distinct follow-up usage line.
|
|
@@ -89,15 +100,15 @@ Payloads are session-local and never persisted. They expire after five minutes,
|
|
|
89
100
|
|
|
90
101
|
The `/advisor-settings` row opens a searchable multi-select menu containing the models configured in Pi. Type to fuzzy-filter the list, use Space to toggle models, and press Enter to apply. The setting is checked before budgets, repeated-call tracking, Jev screening, or any Advisor provider request, so a denied model neither spends Advisor budget nor triggers a gate. Matching is exact and case-sensitive.
|
|
91
102
|
|
|
92
|
-
## Simple mode and
|
|
103
|
+
## Simple mode and activation scope
|
|
93
104
|
|
|
94
105
|
- `simpleMode` defaults to `false`. When enabled, `ask_advisor` remains available for voluntary second opinions when Advisor tools are enabled, and `/advisor-manual` remains available. Plan/failure/completion rules, loop gates, blocking, call budgets, and session summaries are disabled. Context limits, result caps, redaction, and tool disclosure policies still apply.
|
|
95
|
-
- `
|
|
96
|
-
- `
|
|
97
|
-
-
|
|
98
|
-
- `/advisor-off` persists `advisorToolsEnabled: false` and turns `alwaysOn` off, keeping model-facing Advisor tools disabled in later sessions.
|
|
99
|
-
- In Simple mode, settings keeps the Context window/history, Advisor tools, Simple mode, and Always on controls. Advanced values remain saved and take effect when Simple mode is disabled.
|
|
100
|
-
- Settings changes are applied and persisted as they happen; Escape closes the screen without a separate Save action.
|
|
106
|
+
- `advisorActivation` defaults to `"persistent"`, preserving the existing behavior. Set it to `"session"` in `/advisor-settings`, through `advisor_config`, or in the global `advisor.json` to start with `ask_advisor`, `record_advisor_outcome`, and `advisor_config` inactive. `/advisor` and `/advisor-off` then change only the current session and never write `advisor.json`, including when `/advisor` opens the model picker or receives arguments. Model choices and arguments from `/advisor` remain in memory until the next session start; `/advisor-models` and `/advisor-settings` still save explicit configuration changes. `/advisor-manual` and `/advisor-settings` remain available while the tools are inactive.
|
|
107
|
+
- In persistent mode, `advisorToolsEnabled` defaults to `true` to preserve on-demand tool access. When `false`, Pi removes `ask_advisor` and `record_advisor_outcome` from the active tool set for new, resumed, forked, and reloaded sessions. This explicit opt-out takes precedence over `alwaysOn`. Re-enable tools in `/advisor-settings`, or run `/advisor`; the latter clears the opt-out only after successful activation. In session mode, the saved preference is left unchanged by `/advisor` and `/advisor-off` and does not prevent explicit activation.
|
|
108
|
+
- `alwaysOn` defaults to `false` and controls automatic flow activation separately from tool availability. In persistent mode, when enabled and Advisor tools are enabled, Pi restores the configured Executor, if any, and activates the flow for new, resumed, forked, and reloaded sessions. If model refs are missing or unavailable, startup reports the problem without activating; run `/advisor` to choose available models interactively. A native subagent launcher that sets `PI_SUBAGENT_CHILD=1` keeps its host-selected model and thinking level; Advisor tools still activate, but the child is not switched to the parent Executor. Session mode takes precedence at every `session_start`, including `/reload`, and leaves the saved `alwaysOn` value untouched.
|
|
109
|
+
- In persistent mode, `/advisor-off` persists `advisorToolsEnabled: false` and turns `alwaysOn` off, keeping model-facing Advisor tools disabled in later sessions. In session mode it disables all three Advisor tools without changing either saved value.
|
|
110
|
+
- In Simple mode, settings keeps the Context window/history, Advisor activation, Advisor tools, Simple mode, and Always on controls. Advanced values remain saved and take effect when Simple mode is disabled.
|
|
111
|
+
- Settings changes are applied and persisted as they happen; Escape closes the screen without a separate Save action. Switching to session mode keeps the current Advisor on/off state while making `advisor_config` follow it; the next `session_start` starts inactive. Switching back to persistent mode immediately applies the saved `advisorToolsEnabled` preference and makes `advisor_config` available.
|
|
101
112
|
|
|
102
113
|
## Experimental Advisor Scout
|
|
103
114
|
|
|
@@ -133,7 +144,7 @@ An untrusted project sends neither rules file; the Advisor is told that rules we
|
|
|
133
144
|
|
|
134
145
|
## Consultation responses
|
|
135
146
|
|
|
136
|
-
Normal consultations preserve the provider's final Markdown and never block execution.
|
|
147
|
+
Normal consultations preserve the provider's final Markdown and never block execution. Under the default `advisor-named` handoff, if the Advisor explicitly says it cannot review a specifically named file, the Executor may make a sequential follow-up call with `includeTrackedFiles` when global tracked-file consent is enabled; this is discretionary, not an automatic retry. The `executor` handoff lets the Executor attach tracked files without that step (see [Tracked file handoff](#tracked-file-handoff)). When the Advisor has no material concern or recommendation, it may begin with the exact first line `Verdict: sound`. Pi renders that response with the static `◆ ADVISOR · SOUND` header for both `ask_advisor` results and `/advisor-manual`.
|
|
137
148
|
|
|
138
149
|
## Jev/Decisions consultation filter
|
|
139
150
|
|
package/docs/privacy.md
CHANGED
|
@@ -15,11 +15,11 @@ The `advisor_config` tool reads recognized effective settings and persisted glob
|
|
|
15
15
|
- `summary` sends changed file names, change status, and line counts. It never sends file contents.
|
|
16
16
|
- `full` additionally sends the patch.
|
|
17
17
|
- Changes are measured against the last commit and cover staged and unstaged work. Untracked files are always listed by name only; `gitContext: full` never sends their contents.
|
|
18
|
-
- `advisorTrackedFileContent` defaults to `false`. When enabled, `includeTrackedFiles` can attach only exact named, repository-relative, tracked regular files from the current working tree.
|
|
18
|
+
- `advisorTrackedFileContent` defaults to `false`. When enabled, `includeTrackedFiles` can attach only exact named, repository-relative, tracked regular files from the current working tree. By default (`advisorTrackedFileHandoff: "advisor-named"`), this is a discretionary sequential follow-up after the Advisor explicitly names a missing file. With `advisorTrackedFileHandoff: "executor"`, the Executor may attach files on any consultation without that naming step; consent, path checks, size limits, and redaction still apply. Sibling files remain withheld.
|
|
19
19
|
- `advisorUntrackedContent` defaults to `false`. When enabled, `includeUntracked` can attach only exact named, repository-relative, untracked regular files. Files are redacted and capped before egress; sibling files remain withheld.
|
|
20
20
|
- Tracked and untracked text attachments share the 8 KiB per-file and 24 KiB aggregate limits. Binary non-image files, symlinks, directories, submodules, traversal paths, and files outside the repository are refused. Current tracked bodies may include unstaged edits.
|
|
21
21
|
- For an image-capable Advisor, selected user messages and full-policy tool results may forward PNG, JPEG, GIF, or WebP pixels (not just their descriptions). Tool `summary` and `exclude` policies withhold result images; conversation and Scout selection limits also apply. Scout sees bounded image markers, never the pixels. Text-only models receive an explicit no-pixels notice.
|
|
22
|
-
- Explicit `includeTrackedFiles` and `includeUntracked` paths with supported image extensions can forward image files under the same tracked
|
|
22
|
+
- Explicit `includeTrackedFiles` and `includeUntracked` paths with supported image extensions can forward image files under the same tracked handoff mode and global file-content consent rules. Images have a separate cap of 4 MiB each, four images and 8 MiB total across history and files. Mismatched MIME/format, unsupported formats (including SVG), invalid data and oversized images are withheld. When pixels are unavailable, the Advisor is told not to claim visual review.
|
|
23
23
|
- Credential redaction cannot inspect or scrub pixels. Do not attach screenshots containing sensitive data unless you intend the Advisor provider to receive it.
|
|
24
24
|
- `advisorGitContextMaxChars` defaults to `20000`. Repository context may claim its own cap or half of `contextMaxChars`, whichever is smaller, so it cannot crowd out the conversation.
|
|
25
25
|
- The Executor may pass `gitContext` to `ask_advisor` as `none`, `summary`, or `full`. `advisorGitContext` is the ceiling. A larger request is narrowed to the configured level, and the Advisor is told that a fuller view was withheld.
|
package/locales/de.json
CHANGED
|
@@ -211,8 +211,12 @@
|
|
|
211
211
|
"sessionSummary.title": "[Sitzungs-Advisor-Zusammenfassung]",
|
|
212
212
|
"sessionSummary.triggers.label": "Auslöser:",
|
|
213
213
|
"sessionSummary.usage.label": "Nutzung:",
|
|
214
|
-
"settings.
|
|
214
|
+
"settings.advisorActivation.desc": "Dauerhafte Aktivierung wählen oder bei jedem Sitzungsstart, einschließlich /reload, inaktiv beginnen.",
|
|
215
|
+
"settings.advisorActivation.label": "Advisor-Aktivierung",
|
|
216
|
+
"settings.advisorToolsEnabled.desc": "Erlaubt dem Modell, die Advisor-Tools aufzurufen; der Aktivierungsmodus bestimmt die Dauer.",
|
|
215
217
|
"settings.advisorToolsEnabled.label": "Advisor-Tools",
|
|
218
|
+
"settings.advisorToolsEnabled.savedLabel": "Advisor-Tools (gespeichert)",
|
|
219
|
+
"settings.advisorToolsEnabled.sessionDesc": "Gespeicherte Einstellung für den dauerhaften Modus. Änderungen schalten auch die Advisor-Tools dieser Sitzung um.",
|
|
216
220
|
"settings.agentsMdContext.desc": "Vertrauenswürdige globale und Projekt-AGENTS.md-Regeln in Advisor-Aufrufe einbeziehen.",
|
|
217
221
|
"settings.agentsMdContext.label": "AGENTS.md-Kontext",
|
|
218
222
|
"settings.alwaysOn.desc": "Den Advisor-Flow automatisch für unterstützte Agent-Turns ausführen.",
|
|
@@ -310,10 +314,13 @@
|
|
|
310
314
|
"settings.toolResultMaxLines.label": "Tool-Ergebnis Zeilen",
|
|
311
315
|
"settings.trackedFileContent.desc": "Getrackte Dateiinhalte dürfen mit dem Advisor-Kontext gesendet werden.",
|
|
312
316
|
"settings.trackedFileContent.label": "Getrackter Dateiinhalt",
|
|
317
|
+
"settings.trackedFileHandoff.desc": "Legt fest, wann der Executor getrackte Dateien anhängen darf: erst nachdem der Advisor sie benannt hat, oder bei jeder Konsultation. Setzt die Option „Getrackter Dateiinhalt“ voraus.",
|
|
318
|
+
"settings.trackedFileHandoff.label": "Übergabe getrackter Dateien",
|
|
313
319
|
"settings.untrackedContent.desc": "Ungetrackte Dateiinhalte dürfen mit dem Advisor-Kontext gesendet werden.",
|
|
314
320
|
"settings.untrackedContent.label": "Ungetrackter Dateiinhalt",
|
|
315
321
|
"settingsCmd.off.alwaysOnTurnedOff": "Immer aktiv ausgeschaltet.",
|
|
316
322
|
"settingsCmd.off.message": "Advisor-Tools deaktiviert. Aktuelles Modell unverändert.",
|
|
323
|
+
"settingsCmd.off.session": "Advisor-Tools für diese Sitzung deaktiviert. Aktuelles Modell unverändert.",
|
|
317
324
|
"settingsCmd.offReloadFailed.prefix": "Advisor-Tools für diese Sitzung deaktiviert, aber die Konfiguration konnte nicht neu geladen werden:",
|
|
318
325
|
"settingsCmd.offSaveFailed.prefix": "Advisor-Tools für diese Sitzung deaktiviert, aber die Einstellung konnte nicht gespeichert werden:",
|
|
319
326
|
"settingsCmd.refreshFailed.prefix": "Advisor-Einstellungen gespeichert, aber die Statusaktualisierung schlug fehl:",
|
package/locales/en.json
CHANGED
|
@@ -212,8 +212,12 @@
|
|
|
212
212
|
"sessionSummary.title": "[Session Advisor Summary]",
|
|
213
213
|
"sessionSummary.triggers.label": "Triggers:",
|
|
214
214
|
"sessionSummary.usage.label": "Usage:",
|
|
215
|
-
"settings.
|
|
215
|
+
"settings.advisorActivation.desc": "Choose persistent activation or start inactive at each session start, including /reload.",
|
|
216
|
+
"settings.advisorActivation.label": "Advisor activation",
|
|
217
|
+
"settings.advisorToolsEnabled.desc": "Allow the model to call the Advisor tools; activation scope determines how long they stay enabled.",
|
|
216
218
|
"settings.advisorToolsEnabled.label": "Advisor tools",
|
|
219
|
+
"settings.advisorToolsEnabled.savedLabel": "Advisor tools (saved)",
|
|
220
|
+
"settings.advisorToolsEnabled.sessionDesc": "Saved preference for persistent mode. Changing it also toggles this session’s Advisor tools.",
|
|
217
221
|
"settings.agentsMdContext.desc": "Include trusted project and global AGENTS.md rules in Advisor calls.",
|
|
218
222
|
"settings.agentsMdContext.label": "AGENTS.md context",
|
|
219
223
|
"settings.alwaysOn.desc": "Run the Advisor flow automatically for supported agent turns.",
|
|
@@ -311,10 +315,13 @@
|
|
|
311
315
|
"settings.toolResultMaxLines.label": "Tool result lines",
|
|
312
316
|
"settings.trackedFileContent.desc": "Allow tracked file contents to be sent with Advisor context.",
|
|
313
317
|
"settings.trackedFileContent.label": "Tracked file content",
|
|
318
|
+
"settings.trackedFileHandoff.desc": "When the Executor may attach tracked files: only after the Advisor names them, or on any consultation. Requires Tracked file content.",
|
|
319
|
+
"settings.trackedFileHandoff.label": "Tracked file handoff",
|
|
314
320
|
"settings.untrackedContent.desc": "Allow untracked file contents to be sent with Advisor context.",
|
|
315
321
|
"settings.untrackedContent.label": "Untracked file content",
|
|
316
322
|
"settingsCmd.off.alwaysOnTurnedOff": "Always on turned off.",
|
|
317
323
|
"settingsCmd.off.message": "Advisor tools disabled. Current model unchanged.",
|
|
324
|
+
"settingsCmd.off.session": "Advisor tools disabled for this session. Current model unchanged.",
|
|
318
325
|
"settingsCmd.offReloadFailed.prefix": "Advisor tools disabled for this session, but configuration could not be reloaded:",
|
|
319
326
|
"settingsCmd.offSaveFailed.prefix": "Advisor tools disabled for this session, but the setting could not be saved:",
|
|
320
327
|
"settingsCmd.refreshFailed.prefix": "Advisor settings were saved, but the status refresh failed:",
|
package/locales/fr.json
CHANGED
|
@@ -211,8 +211,12 @@
|
|
|
211
211
|
"sessionSummary.title": "[Résumé Advisor de session]",
|
|
212
212
|
"sessionSummary.triggers.label": "Déclencheurs :",
|
|
213
213
|
"sessionSummary.usage.label": "Utilisation :",
|
|
214
|
-
"settings.
|
|
214
|
+
"settings.advisorActivation.desc": "Choisir une activation persistante ou démarrer inactif à chaque début de session, y compris /reload.",
|
|
215
|
+
"settings.advisorActivation.label": "Activation Advisor",
|
|
216
|
+
"settings.advisorToolsEnabled.desc": "Autorise le modèle à appeler les outils Advisor ; le mode d’activation détermine leur durée.",
|
|
215
217
|
"settings.advisorToolsEnabled.label": "Outils Advisor",
|
|
218
|
+
"settings.advisorToolsEnabled.savedLabel": "Outils Advisor (enregistrés)",
|
|
219
|
+
"settings.advisorToolsEnabled.sessionDesc": "Préférence enregistrée pour le mode persistant. La modifier active ou désactive aussi les outils Advisor de cette session.",
|
|
216
220
|
"settings.agentsMdContext.desc": "Inclure les règles AGENTS.md globales et du projet de confiance dans les appels Advisor.",
|
|
217
221
|
"settings.agentsMdContext.label": "Contexte AGENTS.md",
|
|
218
222
|
"settings.alwaysOn.desc": "Exécuter le flux Advisor automatiquement pour les tours d'agent pris en charge.",
|
|
@@ -310,10 +314,13 @@
|
|
|
310
314
|
"settings.toolResultMaxLines.label": "Lignes de résultat d'outil",
|
|
311
315
|
"settings.trackedFileContent.desc": "Autoriser l'envoi du contenu des fichiers suivis avec le contexte Advisor.",
|
|
312
316
|
"settings.trackedFileContent.label": "Contenu des fichiers suivis",
|
|
317
|
+
"settings.trackedFileHandoff.desc": "Définit quand l'Executor peut joindre des fichiers suivis : seulement après que l'Advisor les a nommés, ou à chaque consultation. Nécessite le contenu des fichiers suivis.",
|
|
318
|
+
"settings.trackedFileHandoff.label": "Transmission des fichiers suivis",
|
|
313
319
|
"settings.untrackedContent.desc": "Autoriser l'envoi du contenu des fichiers non suivis avec le contexte Advisor.",
|
|
314
320
|
"settings.untrackedContent.label": "Contenu des fichiers non suivis",
|
|
315
321
|
"settingsCmd.off.alwaysOnTurnedOff": "Toujours actif désactivé.",
|
|
316
322
|
"settingsCmd.off.message": "Outils Advisor désactivés. Modèle actuel inchangé.",
|
|
323
|
+
"settingsCmd.off.session": "Outils Advisor désactivés pour cette session. Modèle actuel inchangé.",
|
|
317
324
|
"settingsCmd.offReloadFailed.prefix": "Outils Advisor désactivés pour cette session, mais la configuration n'a pas pu être rechargée :",
|
|
318
325
|
"settingsCmd.offSaveFailed.prefix": "Outils Advisor désactivés pour cette session, mais le réglage n'a pas pu être enregistré :",
|
|
319
326
|
"settingsCmd.refreshFailed.prefix": "Réglages Advisor enregistrés, mais l'actualisation du statut a échoué :",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-advisor-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1-dev.1",
|
|
4
4
|
"description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advisor",
|
|
@@ -62,21 +62,21 @@
|
|
|
62
62
|
"format:check": "bun fmt --no-script --print-width 80 --trailing-comma es5 --sort-imports --bracket-same-line --ignore-pattern 'bench/tasks/**/traps.toml' --ignore-pattern 'dist/**' --check"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@earendil-works/pi-ai": "1.
|
|
66
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
67
|
-
"@earendil-works/pi-tui": "1.
|
|
65
|
+
"@earendil-works/pi-ai": "1.6.0",
|
|
66
|
+
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
67
|
+
"@earendil-works/pi-tui": "1.6.0",
|
|
68
68
|
"@juicesharp/rpiv-i18n": "2.15.0",
|
|
69
|
-
"@oxlint/plugins": "1.
|
|
69
|
+
"@oxlint/plugins": "1.94.0",
|
|
70
70
|
"@types/node": "^26.6.6",
|
|
71
71
|
"@typesafe-ai/sdk": "^0.7.0",
|
|
72
|
-
"bun-types": "1.4.
|
|
72
|
+
"bun-types": "1.4.5",
|
|
73
73
|
"husky": "^9.1.7",
|
|
74
|
-
"knip": "6.
|
|
75
|
-
"lint-staged": "^17.6.
|
|
76
|
-
"oxlint": "1.
|
|
77
|
-
"typebox": "1.4.
|
|
74
|
+
"knip": "6.47.0",
|
|
75
|
+
"lint-staged": "^17.6.1",
|
|
76
|
+
"oxlint": "1.94.0",
|
|
77
|
+
"typebox": "1.4.7",
|
|
78
78
|
"typescript": "^7.0.2",
|
|
79
|
-
"ultracite": "8.
|
|
79
|
+
"ultracite": "8.3.1"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@earendil-works/pi-ai": "^1.0.0",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
+
import { getSessionActivationOverrides } from "../config/session-overrides.ts";
|
|
3
4
|
import {
|
|
5
|
+
advisorActivationRef,
|
|
4
6
|
advisorEffortRef,
|
|
5
7
|
advisorFallbackModelRef,
|
|
6
8
|
advisorRef,
|
|
@@ -53,9 +55,27 @@ export const prepareActivationModels = async (
|
|
|
53
55
|
ctx: ExtensionContext,
|
|
54
56
|
announce: boolean,
|
|
55
57
|
executorOverride: boolean,
|
|
56
|
-
advisorOverride: boolean
|
|
58
|
+
advisorOverride: boolean,
|
|
59
|
+
canContinue: () => boolean
|
|
57
60
|
): Promise<PreparedActivationModels | undefined> => {
|
|
58
|
-
const
|
|
61
|
+
const saved = getPersistedModelRefs();
|
|
62
|
+
|
|
63
|
+
const overrides =
|
|
64
|
+
advisorActivationRef === "session"
|
|
65
|
+
? getSessionActivationOverrides(ctx)
|
|
66
|
+
: undefined;
|
|
67
|
+
|
|
68
|
+
const persisted = {
|
|
69
|
+
advisor:
|
|
70
|
+
overrides && Object.hasOwn(overrides, "advisor")
|
|
71
|
+
? advisorRef || undefined
|
|
72
|
+
: saved.advisor,
|
|
73
|
+
executor:
|
|
74
|
+
overrides && Object.hasOwn(overrides, "executor")
|
|
75
|
+
? executorRef || undefined
|
|
76
|
+
: saved.executor,
|
|
77
|
+
};
|
|
78
|
+
|
|
59
79
|
const availableRefs = getAvailableModelRefs(ctx);
|
|
60
80
|
const availableRefSet = availableRefs ? new Set(availableRefs) : undefined;
|
|
61
81
|
|
|
@@ -111,6 +131,7 @@ export const prepareActivationModels = async (
|
|
|
111
131
|
}
|
|
112
132
|
|
|
113
133
|
const selection = await selectAdvisorModels(ctx, {
|
|
134
|
+
canContinue,
|
|
114
135
|
advisor: advisorOverride || persisted.advisor ? advisorRef : "",
|
|
115
136
|
advisorEffort: advisorEffortRef,
|
|
116
137
|
advisorFallbackModel: advisorFallbackModelRef,
|
|
@@ -118,9 +139,15 @@ export const prepareActivationModels = async (
|
|
|
118
139
|
executorEffort: executorEffortRef,
|
|
119
140
|
selectAdvisor: plan.selectAdvisor,
|
|
120
141
|
selectExecutor: plan.selectExecutor,
|
|
142
|
+
}).catch((error) => {
|
|
143
|
+
if (!canContinue()) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
throw error;
|
|
121
148
|
});
|
|
122
149
|
|
|
123
|
-
if (!selection) {
|
|
150
|
+
if (!selection || !canContinue()) {
|
|
124
151
|
return;
|
|
125
152
|
}
|
|
126
153
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import { getAdvisorSettings } from "../config/state.ts";
|
|
4
|
+
import {
|
|
5
|
+
enableAdvisorConfigurationTool,
|
|
6
|
+
setAdvisorToolsActive,
|
|
7
|
+
} from "./advisor-tools.ts";
|
|
8
|
+
import type { CommandRuntime } from "./types.ts";
|
|
9
|
+
|
|
10
|
+
export const reconcileAdvisorToolsAfterSettings = (
|
|
11
|
+
runtime: CommandRuntime,
|
|
12
|
+
ctx: ExtensionContext,
|
|
13
|
+
previous: ReturnType<typeof getAdvisorSettings>,
|
|
14
|
+
refreshPersistentTools = true
|
|
15
|
+
) => {
|
|
16
|
+
const next = getAdvisorSettings();
|
|
17
|
+
const modeChanged = previous.advisorActivation !== next.advisorActivation;
|
|
18
|
+
|
|
19
|
+
const preferenceChanged =
|
|
20
|
+
previous.advisorToolsEnabled !== next.advisorToolsEnabled;
|
|
21
|
+
|
|
22
|
+
const sessionScoped = next.advisorActivation === "session";
|
|
23
|
+
|
|
24
|
+
const enabledByAlwaysOn =
|
|
25
|
+
!previous.alwaysOn &&
|
|
26
|
+
next.alwaysOn &&
|
|
27
|
+
!previous.advisorToolsEnabled &&
|
|
28
|
+
next.advisorToolsEnabled;
|
|
29
|
+
|
|
30
|
+
const persistentOutOfSync =
|
|
31
|
+
!sessionScoped && runtime.flowEnabled() !== next.advisorToolsEnabled;
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
modeChanged ||
|
|
35
|
+
preferenceChanged ||
|
|
36
|
+
(!refreshPersistentTools && persistentOutOfSync)
|
|
37
|
+
) {
|
|
38
|
+
runtime.noteAdvisorToolsStateChange();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let enabled = next.advisorToolsEnabled;
|
|
42
|
+
|
|
43
|
+
if (sessionScoped) {
|
|
44
|
+
if (modeChanged) {
|
|
45
|
+
runtime.advisorSessionState.sessionToolsEnabled = runtime.flowEnabled();
|
|
46
|
+
} else if (preferenceChanged && !enabledByAlwaysOn) {
|
|
47
|
+
runtime.advisorSessionState.sessionToolsEnabled = enabled;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
enabled = runtime.advisorSessionState.sessionToolsEnabled;
|
|
51
|
+
setAdvisorToolsActive(runtime.pi, enabled, true);
|
|
52
|
+
} else {
|
|
53
|
+
if (modeChanged) {
|
|
54
|
+
enableAdvisorConfigurationTool(runtime.pi);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
refreshPersistentTools ||
|
|
59
|
+
modeChanged ||
|
|
60
|
+
preferenceChanged ||
|
|
61
|
+
persistentOutOfSync
|
|
62
|
+
) {
|
|
63
|
+
setAdvisorToolsActive(runtime.pi, enabled);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!enabled) {
|
|
68
|
+
runtime.resetSameModelNotice();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
runtime.updateSameModelNotice(ctx);
|
|
72
|
+
runtime.updateAdvisorUsageStatus(ctx);
|
|
73
|
+
};
|
|
@@ -7,21 +7,25 @@ import {
|
|
|
7
7
|
isMarkedSubagent,
|
|
8
8
|
} from "../child-session.ts";
|
|
9
9
|
import { parseArgs } from "../config/args.ts";
|
|
10
|
+
import { rememberSessionActivationOverrides } from "../config/session-overrides.ts";
|
|
10
11
|
import {
|
|
12
|
+
advisorActivationRef,
|
|
11
13
|
advisorEffortRef,
|
|
14
|
+
advisorFallbackModelRef,
|
|
12
15
|
advisorRef,
|
|
13
16
|
advisorToolsEnabledRef,
|
|
14
17
|
contextMaxCharsRef,
|
|
15
18
|
executorEffortRef,
|
|
16
19
|
executorRef,
|
|
17
20
|
setAdvisorEffortRef,
|
|
21
|
+
setAdvisorFallbackModelRef,
|
|
18
22
|
setAdvisorRef,
|
|
19
23
|
setAdvisorToolsEnabledRef,
|
|
20
24
|
setContextMaxCharsRef,
|
|
21
25
|
setExecutorEffortRef,
|
|
22
26
|
setExecutorRef,
|
|
23
27
|
} from "../config/state.ts";
|
|
24
|
-
import { saveConfig } from "../config/storage.ts";
|
|
28
|
+
import { rebaseConfigBaseline, saveConfig } from "../config/storage.ts";
|
|
25
29
|
import { t } from "../i18n.ts";
|
|
26
30
|
import { hasUsableModelAuth } from "../model-auth.ts";
|
|
27
31
|
import { sameModelAdvisorDisabled } from "../tools/model-access.ts";
|
|
@@ -106,11 +110,41 @@ const restoreActivationRefsIfCurrent = (
|
|
|
106
110
|
const liveRefSnapshot = () => ({
|
|
107
111
|
advisor: advisorRef,
|
|
108
112
|
advisorEffort: advisorEffortRef,
|
|
113
|
+
advisorFallbackModel: advisorFallbackModelRef,
|
|
109
114
|
contextMaxChars: contextMaxCharsRef,
|
|
110
115
|
executor: executorRef,
|
|
111
116
|
executorEffort: executorEffortRef,
|
|
112
117
|
});
|
|
113
118
|
|
|
119
|
+
const restoreActivationRefs = (
|
|
120
|
+
previous: ReturnType<typeof liveRefSnapshot>,
|
|
121
|
+
attempted: ReturnType<typeof liveRefSnapshot>
|
|
122
|
+
) => {
|
|
123
|
+
if (advisorRef === attempted.advisor) {
|
|
124
|
+
setAdvisorRef(previous.advisor);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (advisorEffortRef === attempted.advisorEffort) {
|
|
128
|
+
setAdvisorEffortRef(previous.advisorEffort);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (advisorFallbackModelRef === attempted.advisorFallbackModel) {
|
|
132
|
+
setAdvisorFallbackModelRef(previous.advisorFallbackModel);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (contextMaxCharsRef === attempted.contextMaxChars) {
|
|
136
|
+
setContextMaxCharsRef(previous.contextMaxChars);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (executorRef === attempted.executor) {
|
|
140
|
+
setExecutorRef(previous.executor);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (executorEffortRef === attempted.executorEffort) {
|
|
144
|
+
setExecutorEffortRef(previous.executorEffort);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
114
148
|
const persistSuccessfulActivation = (
|
|
115
149
|
ctx: ExtensionContext,
|
|
116
150
|
shouldSave: boolean,
|
|
@@ -149,6 +183,27 @@ const persistSuccessfulActivation = (
|
|
|
149
183
|
return true;
|
|
150
184
|
};
|
|
151
185
|
|
|
186
|
+
const announceActivation = (
|
|
187
|
+
ctx: ExtensionContext,
|
|
188
|
+
activeModel: { id: string; provider: string } | undefined
|
|
189
|
+
) => {
|
|
190
|
+
const activeExecutorRef = effectiveExecutorRef(ctx);
|
|
191
|
+
const activeExecutorEffort = effectiveExecutorEffort(ctx);
|
|
192
|
+
|
|
193
|
+
notify(
|
|
194
|
+
ctx,
|
|
195
|
+
`${t(
|
|
196
|
+
"activation.explanation",
|
|
197
|
+
"The Advisor is a second-opinion model that reviews the Executor's context and returns risks, alternatives, and verification steps without changing files or running tools."
|
|
198
|
+
)}\n\n${t("activation.flow", "Advisor flow")} ${
|
|
199
|
+
sameModelAdvisorDisabled(ctx, activeModel)
|
|
200
|
+
? t("activation.flowConfigured", "configured")
|
|
201
|
+
: t("activation.flowReady", "ready")
|
|
202
|
+
} — Executor: ${activeExecutorRef} (thinking: ${activeExecutorEffort || "default"}) · Advisor: ${advisorRef} (thinking: ${advisorEffortRef || "default"})`,
|
|
203
|
+
"info"
|
|
204
|
+
);
|
|
205
|
+
};
|
|
206
|
+
|
|
152
207
|
export const activateAdvisor = async (
|
|
153
208
|
runtime: CommandRuntime,
|
|
154
209
|
args: string,
|
|
@@ -164,39 +219,10 @@ export const activateAdvisor = async (
|
|
|
164
219
|
const canContinue = () =>
|
|
165
220
|
runtime.toolAvailabilityRevision === toolAvailabilityRevision;
|
|
166
221
|
|
|
167
|
-
const previous =
|
|
168
|
-
advisor: advisorRef,
|
|
169
|
-
advisorEffort: advisorEffortRef,
|
|
170
|
-
contextMaxChars: contextMaxCharsRef,
|
|
171
|
-
executor: executorRef,
|
|
172
|
-
executorEffort: executorEffortRef,
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const liveSnapshot = liveRefSnapshot;
|
|
176
|
-
|
|
177
|
-
// Restores only refs this activation still owns. A concurrent settings
|
|
178
|
-
// save that replaced a ref keeps its newer value.
|
|
179
|
-
const restoreRefs = (attempted: ReturnType<typeof liveSnapshot>) => {
|
|
180
|
-
if (advisorRef === attempted.advisor) {
|
|
181
|
-
setAdvisorRef(previous.advisor);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (advisorEffortRef === attempted.advisorEffort) {
|
|
185
|
-
setAdvisorEffortRef(previous.advisorEffort);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (contextMaxCharsRef === attempted.contextMaxChars) {
|
|
189
|
-
setContextMaxCharsRef(previous.contextMaxChars);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (executorRef === attempted.executor) {
|
|
193
|
-
setExecutorRef(previous.executor);
|
|
194
|
-
}
|
|
222
|
+
const previous = liveRefSnapshot();
|
|
195
223
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
};
|
|
224
|
+
const restoreRefs = (attempted: ReturnType<typeof liveRefSnapshot>) =>
|
|
225
|
+
restoreActivationRefs(previous, attempted);
|
|
200
226
|
|
|
201
227
|
let attempted = liveRefSnapshot();
|
|
202
228
|
const executorOverride = hasExecutorOverride(args);
|
|
@@ -216,7 +242,8 @@ export const activateAdvisor = async (
|
|
|
216
242
|
ctx,
|
|
217
243
|
announce,
|
|
218
244
|
executorOverride,
|
|
219
|
-
advisorOverride
|
|
245
|
+
advisorOverride,
|
|
246
|
+
canContinue
|
|
220
247
|
);
|
|
221
248
|
|
|
222
249
|
if (!prepared) {
|
|
@@ -243,18 +270,17 @@ export const activateAdvisor = async (
|
|
|
243
270
|
return;
|
|
244
271
|
}
|
|
245
272
|
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const reenableTools = !advisorToolsEnabledRef;
|
|
273
|
+
// Persist model changes only after both models are known and authenticated.
|
|
274
|
+
const sessionScoped = advisorActivationRef === "session";
|
|
275
|
+
const reenableTools = !sessionScoped && !advisorToolsEnabledRef;
|
|
250
276
|
|
|
251
277
|
if (reenableTools) {
|
|
252
278
|
setAdvisorToolsEnabledRef(true);
|
|
253
279
|
}
|
|
254
280
|
|
|
255
|
-
const shouldSave =
|
|
256
|
-
|
|
257
|
-
|
|
281
|
+
const shouldSave =
|
|
282
|
+
!sessionScoped &&
|
|
283
|
+
Boolean(args.trim() || prepared.pickedModels || reenableTools);
|
|
258
284
|
|
|
259
285
|
if (
|
|
260
286
|
!persistSuccessfulActivation(ctx, shouldSave, reenableTools, () =>
|
|
@@ -269,7 +295,13 @@ export const activateAdvisor = async (
|
|
|
269
295
|
runtime.pi.setThinkingLevel(executorEffortRef as ThinkingLevel);
|
|
270
296
|
}
|
|
271
297
|
|
|
272
|
-
|
|
298
|
+
if (sessionScoped) {
|
|
299
|
+
rememberSessionActivationOverrides(ctx, previous, liveRefSnapshot());
|
|
300
|
+
rebaseConfigBaseline();
|
|
301
|
+
runtime.advisorSessionState.sessionToolsEnabled = true;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
setAdvisorToolsActive(runtime.pi, true, sessionScoped);
|
|
273
305
|
|
|
274
306
|
const activeModel = followsSessionExecutor()
|
|
275
307
|
? ctx.model
|
|
@@ -278,19 +310,6 @@ export const activateAdvisor = async (
|
|
|
278
310
|
runtime.updateSameModelNotice(ctx, activeModel);
|
|
279
311
|
|
|
280
312
|
if (announce) {
|
|
281
|
-
|
|
282
|
-
const activeExecutorEffort = effectiveExecutorEffort(ctx);
|
|
283
|
-
notify(
|
|
284
|
-
ctx,
|
|
285
|
-
`${t(
|
|
286
|
-
"activation.explanation",
|
|
287
|
-
"The Advisor is a second-opinion model that reviews the Executor's context and returns risks, alternatives, and verification steps without changing files or running tools."
|
|
288
|
-
)}\n\n${t("activation.flow", "Advisor flow")} ${
|
|
289
|
-
sameModelAdvisorDisabled(ctx, activeModel)
|
|
290
|
-
? t("activation.flowConfigured", "configured")
|
|
291
|
-
: t("activation.flowReady", "ready")
|
|
292
|
-
} — Executor: ${activeExecutorRef} (thinking: ${activeExecutorEffort || "default"}) · Advisor: ${advisorRef} (thinking: ${advisorEffortRef || "default"})`,
|
|
293
|
-
"info"
|
|
294
|
-
);
|
|
313
|
+
announceActivation(ctx, activeModel);
|
|
295
314
|
}
|
|
296
315
|
};
|
|
@@ -2,18 +2,24 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
|
|
3
3
|
const ADVISOR_TOOL_NAMES = new Set(["ask_advisor", "record_advisor_outcome"]);
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const ALL_ADVISOR_TOOL_NAMES = new Set([
|
|
6
|
+
...ADVISOR_TOOL_NAMES,
|
|
7
|
+
"advisor_config",
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
const CONFIGURATION_TOOL_NAME = new Set(["advisor_config"]);
|
|
11
|
+
|
|
12
|
+
const setToolsActive = (
|
|
6
13
|
pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools">,
|
|
7
|
-
enabled: boolean
|
|
14
|
+
enabled: boolean,
|
|
15
|
+
names: Set<string>
|
|
8
16
|
) => {
|
|
9
17
|
const current = pi.getActiveTools();
|
|
10
18
|
|
|
11
|
-
const next = current.filter(
|
|
12
|
-
(name) => enabled || !ADVISOR_TOOL_NAMES.has(name)
|
|
13
|
-
);
|
|
19
|
+
const next = current.filter((name) => enabled || !names.has(name));
|
|
14
20
|
|
|
15
21
|
if (enabled) {
|
|
16
|
-
for (const name of
|
|
22
|
+
for (const name of names) {
|
|
17
23
|
if (!next.includes(name)) {
|
|
18
24
|
next.push(name);
|
|
19
25
|
}
|
|
@@ -27,3 +33,18 @@ export const setAdvisorToolsActive = (
|
|
|
27
33
|
pi.setActiveTools(next);
|
|
28
34
|
}
|
|
29
35
|
};
|
|
36
|
+
|
|
37
|
+
export const setAdvisorToolsActive = (
|
|
38
|
+
pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools">,
|
|
39
|
+
enabled: boolean,
|
|
40
|
+
includeConfiguration = false
|
|
41
|
+
) =>
|
|
42
|
+
setToolsActive(
|
|
43
|
+
pi,
|
|
44
|
+
enabled,
|
|
45
|
+
includeConfiguration ? ALL_ADVISOR_TOOL_NAMES : ADVISOR_TOOL_NAMES
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export const enableAdvisorConfigurationTool = (
|
|
49
|
+
pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools">
|
|
50
|
+
) => setToolsActive(pi, true, CONFIGURATION_TOOL_NAME);
|