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
|
@@ -92,26 +92,91 @@ export const summarizeAdvisorConfigPatch = (
|
|
|
92
92
|
})
|
|
93
93
|
.join("\n");
|
|
94
94
|
|
|
95
|
-
const
|
|
95
|
+
const enabledToolsRiskNote = (
|
|
96
|
+
sessionScoped: boolean,
|
|
97
|
+
alwaysOn: boolean,
|
|
98
|
+
enabledByAlwaysOn: boolean
|
|
99
|
+
) => {
|
|
100
|
+
if (sessionScoped && enabledByAlwaysOn) {
|
|
101
|
+
return "The saved tool preference changes; enabling Always on does not activate this session.";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (sessionScoped) {
|
|
105
|
+
return "Advisor tools become available in this session; later session starts remain inactive.";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (alwaysOn) {
|
|
109
|
+
return "Advisor tools become available, and saved Always on will activate the flow in future sessions.";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return "Advisor tools become available; this does not activate Always on.";
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const activationRiskNotes = (
|
|
96
116
|
changes: AdvisorConfigPatch,
|
|
97
117
|
before: AdvisorConfigSnapshot
|
|
98
118
|
) => {
|
|
99
119
|
const notes: string[] = [];
|
|
100
120
|
|
|
101
|
-
|
|
121
|
+
const sessionScoped =
|
|
122
|
+
changes.advisorActivation === "session" ||
|
|
123
|
+
(changes.advisorActivation === undefined &&
|
|
124
|
+
before.advisorActivation === "session");
|
|
125
|
+
|
|
126
|
+
if (changes.advisorActivation === "session") {
|
|
102
127
|
notes.push(
|
|
103
|
-
"
|
|
128
|
+
"The current Advisor on/off state is kept; advisor_config follows it. Every session start, including /reload, starts inactive even when Always on is saved."
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (
|
|
133
|
+
changes.advisorActivation === "persistent" ||
|
|
134
|
+
changes.advisorActivation === null
|
|
135
|
+
) {
|
|
136
|
+
notes.push(
|
|
137
|
+
"Persistent mode applies the saved Advisor tools preference immediately and makes advisor_config available."
|
|
104
138
|
);
|
|
105
139
|
}
|
|
106
140
|
|
|
107
141
|
if (changes.advisorToolsEnabled === false) {
|
|
108
142
|
notes.push(
|
|
109
|
-
|
|
143
|
+
sessionScoped
|
|
144
|
+
? "Advisor tools, including advisor_config, will be disabled immediately; use /advisor to enable them for this session."
|
|
145
|
+
: "Advisor tools will be disabled immediately. advisor_config remains available to re-enable them."
|
|
110
146
|
);
|
|
111
147
|
}
|
|
112
148
|
|
|
113
149
|
if (changes.alwaysOn === true) {
|
|
114
|
-
notes.push(
|
|
150
|
+
notes.push(
|
|
151
|
+
sessionScoped
|
|
152
|
+
? "Always on is saved, but session activation starts inactive."
|
|
153
|
+
: "Always on enables automatic activation for future sessions."
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (changes.advisorToolsEnabled === true) {
|
|
158
|
+
notes.push(
|
|
159
|
+
enabledToolsRiskNote(
|
|
160
|
+
sessionScoped,
|
|
161
|
+
before.alwaysOn === true || changes.alwaysOn === true,
|
|
162
|
+
changes.alwaysOn === true && before.advisorToolsEnabled === false
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return notes;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const automationRiskNotes = (
|
|
171
|
+
changes: AdvisorConfigPatch,
|
|
172
|
+
before: AdvisorConfigSnapshot
|
|
173
|
+
) => {
|
|
174
|
+
const notes = activationRiskNotes(changes, before);
|
|
175
|
+
|
|
176
|
+
if (changes.simpleMode === true) {
|
|
177
|
+
notes.push(
|
|
178
|
+
"Simple mode disables automatic gates, gate blocking, and configured call budgets; voluntary Advisor calls remain available."
|
|
179
|
+
);
|
|
115
180
|
}
|
|
116
181
|
|
|
117
182
|
if (
|
|
@@ -132,18 +197,13 @@ const automationRiskNotes = (
|
|
|
132
197
|
notes.push("A blocked gate may stop the current session.");
|
|
133
198
|
}
|
|
134
199
|
|
|
135
|
-
if (changes.advisorToolsEnabled === true) {
|
|
136
|
-
notes.push(
|
|
137
|
-
before.alwaysOn === true || changes.alwaysOn === true
|
|
138
|
-
? "Advisor tools become available, and saved Always on will activate the flow in future sessions."
|
|
139
|
-
: "Advisor tools become available; this does not activate Always on."
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
200
|
return notes;
|
|
144
201
|
};
|
|
145
202
|
|
|
146
|
-
const disclosureRiskNotes = (
|
|
203
|
+
const disclosureRiskNotes = (
|
|
204
|
+
changes: AdvisorConfigPatch,
|
|
205
|
+
before: AdvisorConfigSnapshot
|
|
206
|
+
) => {
|
|
147
207
|
const notes: string[] = [];
|
|
148
208
|
|
|
149
209
|
if (changes.advisorGitContext === "full") {
|
|
@@ -158,6 +218,38 @@ const disclosureRiskNotes = (changes: AdvisorConfigPatch) => {
|
|
|
158
218
|
);
|
|
159
219
|
}
|
|
160
220
|
|
|
221
|
+
if (changes.advisorTrackedFileHandoff === "executor") {
|
|
222
|
+
notes.push(
|
|
223
|
+
"The Executor will choose which tracked files to attach, and their contents may be sent to the Advisor on any consultation without the Advisor naming them first. Tracked file content consent is still required."
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// A null patch value resets to the extension default: consent off, advisor-named.
|
|
228
|
+
const trackedFileContent =
|
|
229
|
+
changes.advisorTrackedFileContent === undefined
|
|
230
|
+
? before.advisorTrackedFileContent
|
|
231
|
+
: changes.advisorTrackedFileContent;
|
|
232
|
+
|
|
233
|
+
const trackedFileHandoff =
|
|
234
|
+
changes.advisorTrackedFileHandoff === undefined
|
|
235
|
+
? before.advisorTrackedFileHandoff
|
|
236
|
+
: changes.advisorTrackedFileHandoff;
|
|
237
|
+
|
|
238
|
+
// Only a tracked-file change can create this state; unrelated updates must not repeat it.
|
|
239
|
+
const touchesTrackedFiles =
|
|
240
|
+
changes.advisorTrackedFileContent !== undefined ||
|
|
241
|
+
changes.advisorTrackedFileHandoff !== undefined;
|
|
242
|
+
|
|
243
|
+
if (
|
|
244
|
+
touchesTrackedFiles &&
|
|
245
|
+
trackedFileHandoff === "executor" &&
|
|
246
|
+
trackedFileContent !== true
|
|
247
|
+
) {
|
|
248
|
+
notes.push(
|
|
249
|
+
"Executor tracked file handoff has no effect until Tracked file content is enabled."
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
161
253
|
if (changes.advisorUntrackedContent === true) {
|
|
162
254
|
notes.push(
|
|
163
255
|
"This enables explicitly requested untracked file contents to be sent to the Advisor."
|
|
@@ -223,6 +315,6 @@ export const advisorConfigRiskNotes = (
|
|
|
223
315
|
? persisted.alwaysOn === true
|
|
224
316
|
: before.alwaysOn,
|
|
225
317
|
}),
|
|
226
|
-
...disclosureRiskNotes(changes),
|
|
318
|
+
...disclosureRiskNotes(changes, before),
|
|
227
319
|
...costRiskNotes(changes),
|
|
228
320
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
-
import { getAdvisorSettings } from "../config/state.ts";
|
|
4
|
-
import {
|
|
3
|
+
import type { getAdvisorSettings } from "../config/state.ts";
|
|
4
|
+
import { reconcileAdvisorToolsAfterSettings } from "./activation-settings.ts";
|
|
5
5
|
import type { CommandRuntime } from "./types.ts";
|
|
6
6
|
|
|
7
7
|
export const applyAdvisorConfigRuntimeSettings = (
|
|
@@ -9,24 +9,7 @@ export const applyAdvisorConfigRuntimeSettings = (
|
|
|
9
9
|
ctx: ExtensionContext,
|
|
10
10
|
previous: ReturnType<typeof getAdvisorSettings>
|
|
11
11
|
) => {
|
|
12
|
-
|
|
13
|
-
const shouldEnable = next.advisorToolsEnabled ?? true;
|
|
14
|
-
const toolsAreActive = runtime.pi.getActiveTools().includes("ask_advisor");
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
previous.advisorToolsEnabled !== next.advisorToolsEnabled ||
|
|
18
|
-
toolsAreActive !== shouldEnable
|
|
19
|
-
) {
|
|
20
|
-
runtime.noteAdvisorToolsStateChange();
|
|
21
|
-
setAdvisorToolsActive(runtime.pi, shouldEnable);
|
|
22
|
-
|
|
23
|
-
if (!shouldEnable) {
|
|
24
|
-
runtime.resetSameModelNotice();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
runtime.updateSameModelNotice(ctx);
|
|
29
|
-
runtime.updateAdvisorUsageStatus(ctx);
|
|
12
|
+
reconcileAdvisorToolsAfterSettings(runtime, ctx, previous, false);
|
|
30
13
|
};
|
|
31
14
|
|
|
32
15
|
export const cancelledAdvisorConfigResult = (message: string) => ({
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
clearSessionActivationOverrides,
|
|
5
|
+
SESSION_ACTIVATION_KEYS,
|
|
6
|
+
} from "../config/session-overrides.ts";
|
|
3
7
|
import { getAdvisorSettings, setContextMaxCharsRef } from "../config/state.ts";
|
|
4
8
|
import {
|
|
5
9
|
configPaths,
|
|
@@ -95,12 +99,19 @@ const appliedAdvisorConfigResult = (
|
|
|
95
99
|
) => {
|
|
96
100
|
const notices: string[] = [];
|
|
97
101
|
|
|
102
|
+
const sessionScoped =
|
|
103
|
+
prepared.proposed.advisorActivation === "session" ||
|
|
104
|
+
(prepared.proposed.advisorActivation === undefined &&
|
|
105
|
+
prepared.beforeSettings.advisorActivation === "session");
|
|
106
|
+
|
|
98
107
|
if (
|
|
99
108
|
Object.hasOwn(prepared.proposed, "alwaysOn") &&
|
|
100
109
|
prepared.proposed.alwaysOn === true
|
|
101
110
|
) {
|
|
102
111
|
notices.push(
|
|
103
|
-
|
|
112
|
+
sessionScoped
|
|
113
|
+
? "Always on is saved but session activation starts inactive; this did not start an Advisor call."
|
|
114
|
+
: "Always on applies to future sessions; this did not start an Advisor call."
|
|
104
115
|
);
|
|
105
116
|
}
|
|
106
117
|
|
|
@@ -162,6 +173,17 @@ const applyAdvisorConfigUpdate = (
|
|
|
162
173
|
savedPath: string
|
|
163
174
|
) => {
|
|
164
175
|
try {
|
|
176
|
+
if (Object.hasOwn(prepared.proposed, "advisorActivation")) {
|
|
177
|
+
clearSessionActivationOverrides(ctx);
|
|
178
|
+
} else {
|
|
179
|
+
clearSessionActivationOverrides(
|
|
180
|
+
ctx,
|
|
181
|
+
SESSION_ACTIVATION_KEYS.filter((key) =>
|
|
182
|
+
Object.hasOwn(prepared.proposed, key)
|
|
183
|
+
)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
165
187
|
loadConfig(ctx);
|
|
166
188
|
|
|
167
189
|
if (
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { clearSessionActivationOverrides } from "../config/session-overrides.ts";
|
|
4
|
+
import {
|
|
5
|
+
advisorActivationRef,
|
|
6
|
+
advisorToolsEnabledRef,
|
|
7
|
+
alwaysOnRef,
|
|
8
|
+
} from "../config/state.ts";
|
|
4
9
|
import { loadConfig } from "../config/storage.ts";
|
|
5
10
|
import { t } from "../i18n.ts";
|
|
6
11
|
import { setAdvisorToolsActive } from "./advisor-tools.ts";
|
|
@@ -18,6 +23,9 @@ export const registerCommandLifecycle = (
|
|
|
18
23
|
activateAdvisor: ActivateAdvisor
|
|
19
24
|
) => {
|
|
20
25
|
runtime.pi.on("session_start", async (_event, ctx) => {
|
|
26
|
+
runtime.noteAdvisorToolsStateChange();
|
|
27
|
+
runtime.advisorSessionState.sessionToolsEnabled = false;
|
|
28
|
+
clearSessionActivationOverrides(ctx);
|
|
21
29
|
runtime.resetSameModelNotice();
|
|
22
30
|
|
|
23
31
|
// A malformed advisor.json or a provider auth failure must not reject a
|
|
@@ -25,6 +33,12 @@ export const registerCommandLifecycle = (
|
|
|
25
33
|
try {
|
|
26
34
|
loadConfig(ctx);
|
|
27
35
|
|
|
36
|
+
if (advisorActivationRef === "session") {
|
|
37
|
+
setAdvisorToolsActive(runtime.pi, false, true);
|
|
38
|
+
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
if (!advisorToolsEnabledRef) {
|
|
29
43
|
setAdvisorToolsActive(runtime.pi, false);
|
|
30
44
|
runtime.updateSameModelNotice(ctx);
|
|
@@ -49,6 +63,18 @@ export const registerCommandLifecycle = (
|
|
|
49
63
|
}
|
|
50
64
|
});
|
|
51
65
|
|
|
66
|
+
runtime.pi.on("session_tree", (_event, ctx) => {
|
|
67
|
+
if (advisorActivationRef === "session") {
|
|
68
|
+
runtime.noteAdvisorToolsStateChange();
|
|
69
|
+
setAdvisorToolsActive(
|
|
70
|
+
runtime.pi,
|
|
71
|
+
runtime.advisorSessionState.sessionToolsEnabled,
|
|
72
|
+
true
|
|
73
|
+
);
|
|
74
|
+
runtime.updateSameModelNotice(ctx);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
52
78
|
runtime.pi.on("model_select", (event, ctx) => {
|
|
53
79
|
if (!runtime.suppressModelSelectionSync) {
|
|
54
80
|
runtime.updateSameModelNotice(ctx, event.model);
|
|
@@ -59,6 +85,9 @@ export const registerCommandLifecycle = (
|
|
|
59
85
|
});
|
|
60
86
|
|
|
61
87
|
runtime.pi.on("session_shutdown", (_event, ctx) => {
|
|
88
|
+
runtime.noteAdvisorToolsStateChange();
|
|
89
|
+
clearSessionActivationOverrides(ctx);
|
|
90
|
+
|
|
62
91
|
if (ctx.hasUI) {
|
|
63
92
|
ctx.ui.setStatus("advisor-usage", undefined);
|
|
64
93
|
}
|
|
@@ -36,7 +36,7 @@ export class ManualAdvisorProgressComponent implements Component {
|
|
|
36
36
|
const box = renderAdvisorCallBox(this.question, this.theme);
|
|
37
37
|
|
|
38
38
|
if (this.state.phase === "complete" || this.state.phase === "cancelled") {
|
|
39
|
-
return box.render(width);
|
|
39
|
+
return [...box.render(width)];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const { scout } = this.state;
|
|
@@ -47,11 +47,11 @@ export class ManualAdvisorProgressComponent implements Component {
|
|
|
47
47
|
if (scoutActive) {
|
|
48
48
|
renderScoutDetails(box, scout, this.expanded, this.theme);
|
|
49
49
|
|
|
50
|
-
return box.render(width);
|
|
50
|
+
return [...box.render(width)];
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (scout?.status === "cancelled") {
|
|
54
|
-
return box.render(width);
|
|
54
|
+
return [...box.render(width)];
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (this.state.phase === "error") {
|
|
@@ -63,7 +63,7 @@ export class ManualAdvisorProgressComponent implements Component {
|
|
|
63
63
|
)
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
return box.render(width);
|
|
66
|
+
return [...box.render(width)];
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const frame =
|
|
@@ -102,7 +102,7 @@ export class ManualAdvisorProgressComponent implements Component {
|
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
return box.render(width);
|
|
105
|
+
return [...box.render(width)];
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
readonly invalidate = noop;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { clearSessionActivationOverrides } from "../config/session-overrides.ts";
|
|
1
2
|
import {
|
|
3
|
+
advisorActivationRef,
|
|
2
4
|
advisorEffortRef,
|
|
3
5
|
advisorFallbackModelRef,
|
|
4
6
|
advisorRef,
|
|
@@ -18,6 +20,14 @@ import { activateAdvisor } from "./activation.ts";
|
|
|
18
20
|
import { selectAdvisorModels } from "./model-picker.ts";
|
|
19
21
|
import type { CommandRuntime } from "./types.ts";
|
|
20
22
|
|
|
23
|
+
const MODEL_SETTINGS = [
|
|
24
|
+
"advisor",
|
|
25
|
+
"advisorEffort",
|
|
26
|
+
"advisorFallbackModel",
|
|
27
|
+
"executor",
|
|
28
|
+
"executorEffort",
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
21
31
|
export const registerModelCommands = (runtime: CommandRuntime) => {
|
|
22
32
|
runtime.pi.registerCommand("advisor", {
|
|
23
33
|
description:
|
|
@@ -58,11 +68,18 @@ export const registerModelCommands = (runtime: CommandRuntime) => {
|
|
|
58
68
|
setExecutorEffortRef(selection.executorEffort);
|
|
59
69
|
setAdvisorEffortRef(selection.advisorEffort);
|
|
60
70
|
|
|
71
|
+
const sessionScoped = advisorActivationRef === "session";
|
|
72
|
+
|
|
61
73
|
const path = saveConfig(ctx, {
|
|
74
|
+
forceKeys: sessionScoped ? MODEL_SETTINGS : undefined,
|
|
62
75
|
persistAdvisor: true,
|
|
63
76
|
persistExecutor: true,
|
|
64
77
|
});
|
|
65
78
|
|
|
79
|
+
if (sessionScoped) {
|
|
80
|
+
clearSessionActivationOverrides(ctx, MODEL_SETTINGS);
|
|
81
|
+
}
|
|
82
|
+
|
|
66
83
|
runtime.updateSameModelNotice(ctx);
|
|
67
84
|
ctx.ui.notify(
|
|
68
85
|
`${t("notify.modelsSaved.prefix", "Saved Executor + Advisor configurations to")} ${path}`,
|
|
@@ -21,6 +21,7 @@ export interface AdvisorModelSelection {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface AdvisorModelPickerOptions {
|
|
24
|
+
canContinue?: () => boolean;
|
|
24
25
|
advisor: string | undefined;
|
|
25
26
|
advisorEffort: string | undefined;
|
|
26
27
|
advisorFallbackModel: string | undefined;
|
|
@@ -30,11 +31,18 @@ export interface AdvisorModelPickerOptions {
|
|
|
30
31
|
selectExecutor: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
const isCurrentChoice = (
|
|
35
|
+
choice: string | undefined,
|
|
36
|
+
canContinue: () => boolean
|
|
37
|
+
): choice is string => Boolean(choice) && canContinue();
|
|
38
|
+
|
|
33
39
|
export const selectAdvisorModels = async (
|
|
34
40
|
ctx: ExtensionContext,
|
|
35
41
|
options: AdvisorModelPickerOptions
|
|
36
42
|
): Promise<AdvisorModelSelection | undefined> => {
|
|
37
|
-
|
|
43
|
+
const canContinue = () => options.canContinue?.() ?? true;
|
|
44
|
+
|
|
45
|
+
if (!canContinue() || !ctx.hasUI) {
|
|
38
46
|
return undefined;
|
|
39
47
|
}
|
|
40
48
|
|
|
@@ -84,7 +92,7 @@ export const selectAdvisorModels = async (
|
|
|
84
92
|
})
|
|
85
93
|
);
|
|
86
94
|
|
|
87
|
-
if (!selectedExecutor) {
|
|
95
|
+
if (!isCurrentChoice(selectedExecutor, canContinue)) {
|
|
88
96
|
return undefined;
|
|
89
97
|
}
|
|
90
98
|
|
|
@@ -96,7 +104,7 @@ export const selectAdvisorModels = async (
|
|
|
96
104
|
effortChoices(executorEffort)
|
|
97
105
|
);
|
|
98
106
|
|
|
99
|
-
if (!selectedExecutorEffort) {
|
|
107
|
+
if (!isCurrentChoice(selectedExecutorEffort, canContinue)) {
|
|
100
108
|
return undefined;
|
|
101
109
|
}
|
|
102
110
|
|
|
@@ -122,7 +130,7 @@ export const selectAdvisorModels = async (
|
|
|
122
130
|
})
|
|
123
131
|
);
|
|
124
132
|
|
|
125
|
-
if (!selectedAdvisor) {
|
|
133
|
+
if (!isCurrentChoice(selectedAdvisor, canContinue)) {
|
|
126
134
|
return undefined;
|
|
127
135
|
}
|
|
128
136
|
|
|
@@ -131,7 +139,7 @@ export const selectAdvisorModels = async (
|
|
|
131
139
|
effortChoices(advisorEffort)
|
|
132
140
|
);
|
|
133
141
|
|
|
134
|
-
if (!selectedAdvisorEffort) {
|
|
142
|
+
if (!isCurrentChoice(selectedAdvisorEffort, canContinue)) {
|
|
135
143
|
return undefined;
|
|
136
144
|
}
|
|
137
145
|
|
|
@@ -162,7 +170,7 @@ export const selectAdvisorModels = async (
|
|
|
162
170
|
})
|
|
163
171
|
);
|
|
164
172
|
|
|
165
|
-
if (selectedFallback === undefined) {
|
|
173
|
+
if (selectedFallback === undefined || !canContinue()) {
|
|
166
174
|
return undefined;
|
|
167
175
|
}
|
|
168
176
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
advisorActivationRef,
|
|
4
5
|
alwaysOnRef,
|
|
5
6
|
getAdvisorSettings,
|
|
6
7
|
getPersistedModelRefs,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
import { AdvisorSettingsSelector } from "../ui/settings-selector.ts";
|
|
18
19
|
import type { AdvisorSettings } from "../ui/types.ts";
|
|
19
20
|
import { loadCommandConfig } from "./activation-preparation.ts";
|
|
21
|
+
import { reconcileAdvisorToolsAfterSettings } from "./activation-settings.ts";
|
|
20
22
|
import { setAdvisorToolsActive } from "./advisor-tools.ts";
|
|
21
23
|
import {
|
|
22
24
|
CONTEXT_PRESETS,
|
|
@@ -32,6 +34,8 @@ const persistJevSettings = (
|
|
|
32
34
|
settings: AdvisorSettings,
|
|
33
35
|
runtime: CommandRuntime
|
|
34
36
|
): boolean => {
|
|
37
|
+
const previous = getAdvisorSettings();
|
|
38
|
+
|
|
35
39
|
try {
|
|
36
40
|
saveAdvisorSettings(ctx, settings, { skipOutcomeLogging: true });
|
|
37
41
|
} catch (error) {
|
|
@@ -45,9 +49,7 @@ const persistJevSettings = (
|
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
try {
|
|
48
|
-
|
|
49
|
-
runtime.updateSameModelNotice(ctx);
|
|
50
|
-
runtime.updateAdvisorUsageStatus(ctx);
|
|
52
|
+
reconcileAdvisorToolsAfterSettings(runtime, ctx, previous);
|
|
51
53
|
} catch (error) {
|
|
52
54
|
const message = error instanceof Error ? error.message : String(error);
|
|
53
55
|
ctx.ui.notify(
|
|
@@ -86,30 +88,26 @@ export const registerSettingsCommands = (runtime: CommandRuntime) => {
|
|
|
86
88
|
modelRefs: getConfiguredModelRefs(ctx),
|
|
87
89
|
onCancel: () => done(undefined),
|
|
88
90
|
onChange: (settings) => {
|
|
89
|
-
const
|
|
90
|
-
getAdvisorSettings().advisorToolsEnabled ?? true;
|
|
91
|
-
|
|
92
|
-
const toolsEnabled = settings.advisorToolsEnabled ?? true;
|
|
91
|
+
const previous = getAdvisorSettings();
|
|
93
92
|
|
|
94
93
|
try {
|
|
95
94
|
saveAdvisorSettings(ctx, settings);
|
|
96
|
-
|
|
97
|
-
if (toolsWereEnabled !== toolsEnabled) {
|
|
98
|
-
runtime.noteAdvisorToolsStateChange();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
setAdvisorToolsActive(runtime.pi, toolsEnabled);
|
|
102
|
-
runtime.updateSameModelNotice(ctx);
|
|
103
|
-
runtime.updateAdvisorUsageStatus(ctx);
|
|
95
|
+
reconcileAdvisorToolsAfterSettings(runtime, ctx, previous);
|
|
104
96
|
} catch (error) {
|
|
105
97
|
const toolsDisabled =
|
|
106
|
-
|
|
98
|
+
previous.advisorToolsEnabled &&
|
|
99
|
+
settings.advisorToolsEnabled === false;
|
|
107
100
|
|
|
108
101
|
if (toolsDisabled) {
|
|
109
102
|
runtime.noteAdvisorToolsStateChange();
|
|
110
103
|
setAdvisorToolsEnabledRef(false);
|
|
111
104
|
setAlwaysOnRef(false);
|
|
112
|
-
|
|
105
|
+
runtime.advisorSessionState.sessionToolsEnabled = false;
|
|
106
|
+
setAdvisorToolsActive(
|
|
107
|
+
runtime.pi,
|
|
108
|
+
false,
|
|
109
|
+
previous.advisorActivation === "session"
|
|
110
|
+
);
|
|
113
111
|
runtime.resetSameModelNotice();
|
|
114
112
|
}
|
|
115
113
|
|
|
@@ -140,11 +138,15 @@ export const registerSettingsCommands = (runtime: CommandRuntime) => {
|
|
|
140
138
|
});
|
|
141
139
|
|
|
142
140
|
runtime.pi.registerCommand("advisor-off", {
|
|
143
|
-
description:
|
|
144
|
-
"Disable model-facing Advisor tools across sessions; keep the current model",
|
|
141
|
+
description: "Disable Advisor tools; keep the current model",
|
|
145
142
|
handler: (_args, ctx) => {
|
|
146
143
|
runtime.noteAdvisorToolsStateChange();
|
|
147
|
-
|
|
144
|
+
runtime.advisorSessionState.sessionToolsEnabled = false;
|
|
145
|
+
setAdvisorToolsActive(
|
|
146
|
+
runtime.pi,
|
|
147
|
+
false,
|
|
148
|
+
advisorActivationRef === "session"
|
|
149
|
+
);
|
|
148
150
|
runtime.resetSameModelNotice();
|
|
149
151
|
|
|
150
152
|
try {
|
|
@@ -165,6 +167,20 @@ export const registerSettingsCommands = (runtime: CommandRuntime) => {
|
|
|
165
167
|
return Promise.resolve();
|
|
166
168
|
}
|
|
167
169
|
|
|
170
|
+
if (advisorActivationRef === "session") {
|
|
171
|
+
setAdvisorToolsActive(runtime.pi, false, true);
|
|
172
|
+
notify(
|
|
173
|
+
ctx,
|
|
174
|
+
t(
|
|
175
|
+
"settingsCmd.off.session",
|
|
176
|
+
"Advisor tools disabled for this session. Current model unchanged."
|
|
177
|
+
),
|
|
178
|
+
"info"
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
return Promise.resolve();
|
|
182
|
+
}
|
|
183
|
+
|
|
168
184
|
const wasAlwaysOn = alwaysOnRef;
|
|
169
185
|
const persisted = getPersistedModelRefs();
|
|
170
186
|
setAdvisorToolsEnabledRef(false);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
+
import { clearSessionActivationOverrides } from "../config/session-overrides.ts";
|
|
4
|
+
import type { SessionActivationValues } from "../config/session-overrides.ts";
|
|
3
5
|
import {
|
|
4
6
|
getAdvisorSettings,
|
|
5
7
|
getPersistedModelRefs,
|
|
8
|
+
setAdvisorActivationRef,
|
|
6
9
|
setAdvisorAgentsMdContextRef,
|
|
7
10
|
setAdvisorAutoLoopGateRef,
|
|
8
11
|
setAdvisorBlockOnBlockedRef,
|
|
@@ -41,6 +44,7 @@ import {
|
|
|
41
44
|
setAdvisorToolResultMaxLinesRef,
|
|
42
45
|
setAdvisorToolsEnabledRef,
|
|
43
46
|
setAdvisorTrackedFileContentRef,
|
|
47
|
+
setAdvisorTrackedFileHandoffRef,
|
|
44
48
|
setAdvisorUntrackedContentRef,
|
|
45
49
|
setAlwaysOnRef,
|
|
46
50
|
setContextMaxCharsRef,
|
|
@@ -48,7 +52,11 @@ import {
|
|
|
48
52
|
setShowUsageFooterRef,
|
|
49
53
|
setSimpleModeRef,
|
|
50
54
|
} from "../config/state.ts";
|
|
51
|
-
import {
|
|
55
|
+
import {
|
|
56
|
+
loadConfig,
|
|
57
|
+
saveConfig,
|
|
58
|
+
saveGlobalOutcomeLogging,
|
|
59
|
+
} from "../config/storage.ts";
|
|
52
60
|
import {
|
|
53
61
|
DEFAULT_JEV_DIGEST_MAX_CHARS,
|
|
54
62
|
DEFAULT_JEV_FILTER_NOUL_MARGIN,
|
|
@@ -87,6 +95,7 @@ const applySessionSettings = (settings: AdvisorSettings) => {
|
|
|
87
95
|
setShowUsageDetailsRef(settings.showUsageDetails ?? true);
|
|
88
96
|
setShowUsageFooterRef(settings.showUsageFooter ?? false);
|
|
89
97
|
setSimpleModeRef(settings.simpleMode ?? false);
|
|
98
|
+
setAdvisorActivationRef(settings.advisorActivation ?? "persistent");
|
|
90
99
|
setAdvisorToolsEnabledRef(settings.advisorToolsEnabled ?? true);
|
|
91
100
|
setAlwaysOnRef(settings.alwaysOn ?? false);
|
|
92
101
|
setAdvisorFailureModeRef(settings.failureMode ?? "block-session");
|
|
@@ -126,6 +135,9 @@ const applyDisclosureSettings = (settings: AdvisorSettings) => {
|
|
|
126
135
|
setAdvisorToolPoliciesRef(settings.toolPolicies ?? {});
|
|
127
136
|
setAdvisorAgentsMdContextRef(settings.agentsMdContext ?? true);
|
|
128
137
|
setAdvisorTrackedFileContentRef(settings.trackedFileContent ?? false);
|
|
138
|
+
setAdvisorTrackedFileHandoffRef(
|
|
139
|
+
settings.trackedFileHandoff ?? "advisor-named"
|
|
140
|
+
);
|
|
129
141
|
setAdvisorUntrackedContentRef(settings.untrackedContent ?? false);
|
|
130
142
|
setAdvisorOutcomeLoggingRef(settings.outcomeLogging ?? false);
|
|
131
143
|
};
|
|
@@ -158,6 +170,30 @@ export const saveAdvisorSettings = (
|
|
|
158
170
|
if (!options.skipOutcomeLogging) {
|
|
159
171
|
saveGlobalOutcomeLogging(settings.outcomeLogging ?? false);
|
|
160
172
|
}
|
|
173
|
+
|
|
174
|
+
if (previous.advisorActivation === "session") {
|
|
175
|
+
const next = getAdvisorSettings();
|
|
176
|
+
const changed: (keyof SessionActivationValues)[] = [];
|
|
177
|
+
|
|
178
|
+
if (previous.contextMaxChars !== next.contextMaxChars) {
|
|
179
|
+
changed.push("contextMaxChars");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (previous.effort !== next.effort) {
|
|
183
|
+
changed.push("advisorEffort");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (previous.fallbackModel !== next.fallbackModel) {
|
|
187
|
+
changed.push("advisorFallbackModel");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (next.advisorActivation === "persistent") {
|
|
191
|
+
clearSessionActivationOverrides(ctx);
|
|
192
|
+
loadConfig(ctx);
|
|
193
|
+
} else {
|
|
194
|
+
clearSessionActivationOverrides(ctx, changed);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
161
197
|
} catch (error) {
|
|
162
198
|
applyAdvisorSettings(previous);
|
|
163
199
|
throw error;
|