pi-advisor-flow 0.16.1-dev.1 → 0.17.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.
- package/CHANGELOG.md +7 -0
- package/README.md +16 -8
- package/dist/index.js +328 -96
- package/docs/configuration.md +10 -9
- package/locales/de.json +6 -1
- package/locales/en.json +6 -1
- package/locales/fr.json +6 -1
- package/package.json +1 -1
- 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 +70 -13
- 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-command.ts +4 -3
- package/src/commands/manual-consultation.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 +33 -1
- package/src/config/defaults.ts +3 -0
- package/src/config/schema.ts +14 -1
- package/src/config/session-overrides.ts +109 -0
- package/src/config/state.ts +7 -0
- package/src/config/storage.ts +15 -1
- package/src/config/types.ts +3 -0
- package/src/session-state.ts +2 -0
- package/src/tools/budget-feedback.ts +2 -2
- 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 +27 -6
- package/src/ui/settings-mutations.ts +7 -0
- package/src/ui/settings-selector.ts +1 -0
- package/src/ui/types.ts +6 -1
package/src/config/storage.ts
CHANGED
|
@@ -26,6 +26,11 @@ import {
|
|
|
26
26
|
} from "./schema.ts";
|
|
27
27
|
import type { PersistedConfigKey } from "./schema.ts";
|
|
28
28
|
import {
|
|
29
|
+
applySessionActivationOverrides,
|
|
30
|
+
clearSessionActivationOverrides,
|
|
31
|
+
} from "./session-overrides.ts";
|
|
32
|
+
import {
|
|
33
|
+
advisorActivationRef,
|
|
29
34
|
advisorJevClassifierRef,
|
|
30
35
|
advisorJevFilterEnabledRef,
|
|
31
36
|
setAdvisorOutcomeLoggingRef,
|
|
@@ -260,6 +265,12 @@ export const loadConfig = (_ctx: ExtensionContext) => {
|
|
|
260
265
|
// Repository-controlled project configuration is never applied. Models,
|
|
261
266
|
// prompts, gates, budgets, disclosure, redaction, integrations, and consent
|
|
262
267
|
// remain under the user's global Pi configuration.
|
|
268
|
+
if (advisorActivationRef === "session") {
|
|
269
|
+
applySessionActivationOverrides(_ctx);
|
|
270
|
+
} else {
|
|
271
|
+
clearSessionActivationOverrides(_ctx);
|
|
272
|
+
}
|
|
273
|
+
|
|
263
274
|
setAdvisorOutcomeLoggingRef(globalConfig?.advisorOutcomeLogging === true);
|
|
264
275
|
loadedConfigState = currentConfigState();
|
|
265
276
|
loadedConfigPath = global;
|
|
@@ -274,6 +285,7 @@ export const loadConfig = (_ctx: ExtensionContext) => {
|
|
|
274
285
|
* external edit to advisor.json coexist with a later settings or model save.
|
|
275
286
|
*/
|
|
276
287
|
export interface SaveConfigOptions {
|
|
288
|
+
forceKeys?: readonly PersistedConfigKey[];
|
|
277
289
|
persistAdvisor?: boolean;
|
|
278
290
|
persistExecutor?: boolean;
|
|
279
291
|
}
|
|
@@ -293,10 +305,12 @@ export const saveConfig = (
|
|
|
293
305
|
const persistExecutor = options.persistExecutor ?? true;
|
|
294
306
|
const current = currentConfigState();
|
|
295
307
|
const baseline = loadedConfigPath === path ? loadedConfigState : undefined;
|
|
308
|
+
const forcedKeys = new Set(options.forceKeys);
|
|
296
309
|
|
|
297
310
|
const changedKeys = baseline
|
|
298
311
|
? SAVED_CONFIG_KEYS.filter(
|
|
299
|
-
(key) =>
|
|
312
|
+
(key) =>
|
|
313
|
+
forcedKeys.has(key) || !sameConfigValue(current[key], baseline[key])
|
|
300
314
|
)
|
|
301
315
|
: [...SAVED_CONFIG_KEYS];
|
|
302
316
|
|
package/src/config/types.ts
CHANGED
|
@@ -68,8 +68,11 @@ export const GATE_FAILURE_MODES: GateFailureMode[] = [
|
|
|
68
68
|
"warn-and-continue",
|
|
69
69
|
];
|
|
70
70
|
|
|
71
|
+
export type AdvisorActivation = "persistent" | "session";
|
|
72
|
+
|
|
71
73
|
export interface AdvisorConfig {
|
|
72
74
|
advisor?: string;
|
|
75
|
+
advisorActivation?: AdvisorActivation;
|
|
73
76
|
advisorFallbackModel?: string;
|
|
74
77
|
advisorAgentsMdContext?: boolean;
|
|
75
78
|
advisorAutoLoopGate?: boolean;
|
package/src/session-state.ts
CHANGED
|
@@ -100,12 +100,14 @@ export class AdvisorSessionState {
|
|
|
100
100
|
readonly #followUps: AdvisorFollowUpCache;
|
|
101
101
|
#sessionTurnOrdinal = 0;
|
|
102
102
|
#turnsSinceConsultation = 0;
|
|
103
|
+
sessionToolsEnabled = false;
|
|
103
104
|
|
|
104
105
|
constructor(now?: () => number) {
|
|
105
106
|
this.#followUps = new AdvisorFollowUpCache(now);
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
resetTask() {
|
|
110
|
+
this.sessionToolsEnabled = false;
|
|
109
111
|
this.#repetition = freshRepetition();
|
|
110
112
|
this.#blockedReason = undefined;
|
|
111
113
|
this.#ledger = freshAdviceLedger();
|
|
@@ -6,13 +6,13 @@ import type {
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
advisorLogFeedbackRef,
|
|
9
|
-
advisorToolsEnabledRef,
|
|
10
9
|
getAdvisorMaxCallsPerSession,
|
|
11
10
|
isSimpleMode,
|
|
12
11
|
} from "../config/state.ts";
|
|
13
12
|
import { loadConfig } from "../config/storage.ts";
|
|
14
13
|
import type { AdvisorSessionState } from "../session-state.ts";
|
|
15
14
|
import { advisorModelIsAllowed } from "./model-access.ts";
|
|
15
|
+
import { advisorToolsAllowed } from "./session-availability.ts";
|
|
16
16
|
|
|
17
17
|
export const advisorBudgetMessage = (session: AdvisorSessionState) => {
|
|
18
18
|
const simple = isSimpleMode();
|
|
@@ -50,7 +50,7 @@ export const advisorBudgetUpdate = (
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
if (!
|
|
53
|
+
if (!advisorToolsAllowed(session) || !advisorModelIsAllowed(ctx)) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
advisorActivationRef,
|
|
2
3
|
advisorLogFeedbackRef,
|
|
3
4
|
advisorSessionSummaryRef,
|
|
4
|
-
advisorToolsEnabledRef,
|
|
5
5
|
getAdvisorMaxCallsPerSession,
|
|
6
6
|
isSimpleMode,
|
|
7
7
|
} from "../config/state.ts";
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
sameModelAdvisorDisabled,
|
|
16
16
|
} from "./model-access.ts";
|
|
17
17
|
import { advisorInvocationGuidelines } from "./prompts.ts";
|
|
18
|
+
import { advisorToolsAllowed } from "./session-availability.ts";
|
|
18
19
|
import type { ToolRegistrationContext } from "./types.ts";
|
|
19
20
|
|
|
20
21
|
const modelAccessBlock = (
|
|
@@ -103,7 +104,7 @@ export const registerToolLifecycle = ({
|
|
|
103
104
|
loadConfig(ctx);
|
|
104
105
|
|
|
105
106
|
if (
|
|
106
|
-
!
|
|
107
|
+
!advisorToolsAllowed(session) ||
|
|
107
108
|
!advisorModelAccess(ctx).allowed ||
|
|
108
109
|
sameModelAdvisorDisabled(ctx)
|
|
109
110
|
) {
|
|
@@ -153,9 +154,11 @@ export const registerToolLifecycle = ({
|
|
|
153
154
|
|
|
154
155
|
const isAdvisorTool =
|
|
155
156
|
event.toolName === "ask_advisor" ||
|
|
156
|
-
event.toolName === "record_advisor_outcome"
|
|
157
|
+
event.toolName === "record_advisor_outcome" ||
|
|
158
|
+
(event.toolName === "advisor_config" &&
|
|
159
|
+
advisorActivationRef === "session");
|
|
157
160
|
|
|
158
|
-
if (isAdvisorTool && !
|
|
161
|
+
if (isAdvisorTool && !advisorToolsAllowed(session)) {
|
|
159
162
|
return {
|
|
160
163
|
block: true,
|
|
161
164
|
reason:
|
|
@@ -163,7 +166,10 @@ export const registerToolLifecycle = ({
|
|
|
163
166
|
};
|
|
164
167
|
}
|
|
165
168
|
|
|
166
|
-
if (
|
|
169
|
+
if (
|
|
170
|
+
!pi.getActiveTools().includes("ask_advisor") ||
|
|
171
|
+
(advisorActivationRef === "session" && !session.sessionToolsEnabled)
|
|
172
|
+
) {
|
|
167
173
|
return;
|
|
168
174
|
}
|
|
169
175
|
|
|
@@ -173,7 +179,7 @@ export const registerToolLifecycle = ({
|
|
|
173
179
|
return;
|
|
174
180
|
}
|
|
175
181
|
|
|
176
|
-
if (isAdvisorTool && !
|
|
182
|
+
if (isAdvisorTool && !advisorToolsAllowed(session)) {
|
|
177
183
|
return {
|
|
178
184
|
block: true,
|
|
179
185
|
reason:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
+
import { advisorActivationRef } from "../config/state.ts";
|
|
3
4
|
import { herdrAdvisorActivity, herdrAdvisorBlock } from "../herdr.ts";
|
|
4
5
|
import { appendOutcome } from "../outcomes.ts";
|
|
5
6
|
import type { AdvisorSessionState } from "../session-state.ts";
|
|
@@ -43,7 +44,13 @@ export const registerAdvisorTool = (
|
|
|
43
44
|
registerOutcomeTool(registration);
|
|
44
45
|
|
|
45
46
|
const turnGate: JevTurnGateRegistration = {
|
|
46
|
-
activeTools: () =>
|
|
47
|
+
activeTools: () => {
|
|
48
|
+
const active = pi.getActiveTools();
|
|
49
|
+
|
|
50
|
+
return advisorActivationRef === "session" && !session.sessionToolsEnabled
|
|
51
|
+
? active.filter((name) => name !== "ask_advisor")
|
|
52
|
+
: active;
|
|
53
|
+
},
|
|
47
54
|
consult: registration.consult,
|
|
48
55
|
herdrActivity: registration.herdrActivity,
|
|
49
56
|
send: (message) => pi.sendMessage(message, { deliverAs: "steer" }),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
advisorActivationRef,
|
|
3
|
+
advisorToolsEnabledRef,
|
|
4
|
+
} from "../config/state.ts";
|
|
5
|
+
import type { AdvisorSessionState } from "../session-state.ts";
|
|
6
|
+
|
|
7
|
+
export const advisorToolsAllowed = (session: AdvisorSessionState) =>
|
|
8
|
+
advisorActivationRef === "session"
|
|
9
|
+
? session.sessionToolsEnabled
|
|
10
|
+
: advisorToolsEnabledRef;
|
package/src/ui/settings-items.ts
CHANGED
|
@@ -149,6 +149,26 @@ export const advisorModelWhitelistItem = (
|
|
|
149
149
|
}),
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
+
const advisorToolsItem = (settings: AdvisorSettings): SettingItem => ({
|
|
153
|
+
currentValue: settingValue(settings.advisorToolsEnabled, true),
|
|
154
|
+
description:
|
|
155
|
+
settings.advisorActivation === "session"
|
|
156
|
+
? t(
|
|
157
|
+
"settings.advisorToolsEnabled.sessionDesc",
|
|
158
|
+
"Saved preference for persistent mode. Changing it also toggles this session’s Advisor tools."
|
|
159
|
+
)
|
|
160
|
+
: t(
|
|
161
|
+
"settings.advisorToolsEnabled.desc",
|
|
162
|
+
"Allow the model to call the Advisor tools; activation scope determines how long they stay enabled."
|
|
163
|
+
),
|
|
164
|
+
id: "advisorToolsEnabled",
|
|
165
|
+
label:
|
|
166
|
+
settings.advisorActivation === "session"
|
|
167
|
+
? t("settings.advisorToolsEnabled.savedLabel", "Advisor tools (saved)")
|
|
168
|
+
: t("settings.advisorToolsEnabled.label", "Advisor tools"),
|
|
169
|
+
values: TOGGLE_VALUES,
|
|
170
|
+
});
|
|
171
|
+
|
|
152
172
|
export const createSettingsItems = ({
|
|
153
173
|
effortLevels,
|
|
154
174
|
fallbackModel,
|
|
@@ -171,15 +191,16 @@ export const createSettingsItems = ({
|
|
|
171
191
|
values: presets.map((preset) => preset.label),
|
|
172
192
|
},
|
|
173
193
|
{
|
|
174
|
-
currentValue:
|
|
194
|
+
currentValue: settings.advisorActivation ?? "persistent",
|
|
175
195
|
description: t(
|
|
176
|
-
"settings.
|
|
177
|
-
"
|
|
196
|
+
"settings.advisorActivation.desc",
|
|
197
|
+
"Choose persistent activation or start inactive at each session start, including /reload."
|
|
178
198
|
),
|
|
179
|
-
id: "
|
|
180
|
-
label: t("settings.
|
|
181
|
-
values:
|
|
199
|
+
id: "advisorActivation",
|
|
200
|
+
label: t("settings.advisorActivation.label", "Advisor activation"),
|
|
201
|
+
values: ["persistent", "session"],
|
|
182
202
|
},
|
|
203
|
+
advisorToolsItem(settings),
|
|
183
204
|
{
|
|
184
205
|
currentValue: settingValue(settings.simpleMode, false),
|
|
185
206
|
description: t(
|
|
@@ -41,6 +41,13 @@ const applyModeMutation = (
|
|
|
41
41
|
value: string
|
|
42
42
|
): boolean => {
|
|
43
43
|
switch (id) {
|
|
44
|
+
case "advisorActivation": {
|
|
45
|
+
settings.advisorActivation =
|
|
46
|
+
value === "session" ? "session" : "persistent";
|
|
47
|
+
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
44
51
|
case "advisorToolsEnabled": {
|
|
45
52
|
settings.advisorToolsEnabled = value === "On";
|
|
46
53
|
|
package/src/ui/types.ts
CHANGED
|
@@ -8,7 +8,11 @@ import type {
|
|
|
8
8
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
9
9
|
import type { KeybindingsManager, TUI } from "@earendil-works/pi-tui";
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
AdvisorActivation,
|
|
13
|
+
GateFailureMode,
|
|
14
|
+
JevTransport,
|
|
15
|
+
} from "../config/types.ts";
|
|
12
16
|
import type { GitContextLevel } from "../git.ts";
|
|
13
17
|
import type { JevClassifierKeySnapshot } from "../jev/classifier-key-store.ts";
|
|
14
18
|
import type { JevKeyStoreResult } from "../jev/key-store.ts";
|
|
@@ -84,6 +88,7 @@ export const EXECUTOR_FOLLOWS_SESSION_MODEL =
|
|
|
84
88
|
"Current session model (no override)";
|
|
85
89
|
|
|
86
90
|
export interface AdvisorSettings {
|
|
91
|
+
advisorActivation?: AdvisorActivation;
|
|
87
92
|
advisorToolsEnabled?: boolean;
|
|
88
93
|
agentsMdContext?: boolean;
|
|
89
94
|
fallbackModel?: string;
|