pi-advisor-flow 0.5.6 → 0.7.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 +29 -0
- package/README.md +1 -0
- package/dist/index.js +3160 -1255
- package/extensions/index.ts +9 -9
- package/package.json +12 -8
- package/src/{untracked.ts → attachments.ts} +2 -5
- package/src/commands/activation-preparation.ts +6 -6
- package/src/commands/activation.ts +7 -7
- package/src/commands/lifecycle.ts +5 -5
- package/src/commands/manual-command.ts +13 -9
- package/src/commands/manual-consultation.ts +24 -10
- package/src/commands/manual-progress.ts +3 -3
- package/src/commands/model-commands.ts +6 -6
- package/src/commands/model-options.ts +4 -4
- package/src/commands/model-picker.ts +2 -2
- package/src/commands/registration.ts +8 -8
- package/src/commands/renderers.ts +5 -5
- package/src/commands/runtime.ts +8 -8
- package/src/commands/settings-commands.ts +8 -8
- package/src/commands/settings-persistence.ts +52 -4
- package/src/commands/types.ts +6 -13
- package/src/commands.ts +2 -2
- package/src/config/args.ts +3 -3
- package/src/config/defaults.ts +78 -3
- package/src/config/schema.ts +434 -0
- package/src/config/state.ts +71 -2
- package/src/config/storage.ts +27 -119
- package/src/config/types.ts +30 -1
- package/src/config/validation.ts +61 -181
- package/src/config.ts +7 -7
- package/src/content-utils.ts +30 -0
- package/src/conversation.ts +13 -168
- package/src/git.ts +4 -18
- package/src/herdr.ts +6 -8
- package/src/jev/client.ts +348 -0
- package/src/jev/key-store.ts +252 -0
- package/src/jev/ledger.ts +234 -0
- package/src/jev/questions.ts +119 -0
- package/src/jev/state.ts +47 -0
- package/src/jev/transport.ts +58 -0
- package/src/model-stream.ts +5 -8
- package/src/outcomes.ts +3 -2
- package/src/pi-settings.ts +59 -0
- package/src/preferences.ts +2 -2
- package/src/redaction.ts +50 -0
- package/src/scout-context.ts +121 -485
- package/src/scout-curation.ts +84 -0
- package/src/scout-groups.ts +485 -0
- package/src/scout-protocol.ts +122 -0
- package/src/scout-reconstruct.ts +44 -0
- package/src/scout-types.ts +66 -0
- package/src/scout.ts +53 -63
- package/src/session-state.ts +215 -78
- package/src/tool-result-cap.ts +88 -0
- package/src/tools/consult-context.ts +155 -0
- package/src/tools/consultation.ts +71 -220
- package/src/tools/gate-policy.ts +5 -5
- package/src/tools/gate-protocol.ts +2 -2
- package/src/tools/jev-filter.ts +202 -0
- package/src/tools/jev-turn-gate.ts +183 -0
- package/src/tools/loop-gate.ts +71 -61
- package/src/tools/outage-notifier.ts +30 -0
- package/src/tools/prompts.ts +4 -7
- package/src/tools/register-ask-advisor.ts +46 -15
- package/src/tools/register-lifecycle.ts +7 -7
- package/src/tools/register-outcome.ts +5 -5
- package/src/tools/register-renderers.ts +63 -5
- package/src/tools/registration.ts +27 -10
- package/src/tools/render-advisor-result.ts +54 -22
- package/src/tools/render-common.ts +25 -13
- package/src/tools/scout-status.ts +5 -5
- package/src/tools/session.ts +1 -1
- package/src/tools/types.ts +17 -7
- package/src/tools.ts +9 -9
- package/src/ui/jev-setup-submenu.ts +344 -0
- package/src/ui/manual-dialog-render.ts +2 -2
- package/src/ui/manual-dialog.ts +4 -9
- package/src/ui/masked-input.ts +68 -0
- package/src/ui/model-selector.ts +1 -1
- package/src/ui/settings-formatting.ts +2 -2
- package/src/ui/settings-items.ts +166 -5
- package/src/ui/settings-mutations.ts +37 -2
- package/src/ui/settings-selector.ts +5 -5
- package/src/ui/text-setting-submenu.ts +1 -1
- package/src/ui/types.ts +13 -2
- package/src/ui.ts +4 -4
- package/src/usage.ts +4 -7
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DEFAULT_JEV_MODEL } from "../config/types.ts";
|
|
2
|
+
import type { AdvisorSettings, ContextPreset, SettingValue } from "./types.ts";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const BOOLEAN_SETTING_IDS = new Set([
|
|
4
5
|
"scoutEnabled",
|
|
5
6
|
"showUsageDetails",
|
|
6
7
|
"showUsageFooter",
|
|
@@ -70,6 +71,40 @@ export const mutateAdvisorSettings = (
|
|
|
70
71
|
case "gitContextMaxChars":
|
|
71
72
|
settings.gitContextMaxChars = Number(value);
|
|
72
73
|
break;
|
|
74
|
+
case "jevFilter":
|
|
75
|
+
settings.jevFilterEnabled = value === "On";
|
|
76
|
+
break;
|
|
77
|
+
case "jevFilterSkipConfidence":
|
|
78
|
+
settings.jevFilterSkipConfidence = Number(value);
|
|
79
|
+
break;
|
|
80
|
+
case "jevFilterNoulMargin":
|
|
81
|
+
settings.jevFilterNoulMargin = Number(value);
|
|
82
|
+
break;
|
|
83
|
+
case "jevFilterOverrideWindow":
|
|
84
|
+
settings.jevFilterOverrideWindow = Number(value.replace(" turns", ""));
|
|
85
|
+
break;
|
|
86
|
+
case "jevTurnGateEveryTurns":
|
|
87
|
+
settings.jevTurnGateEveryTurns =
|
|
88
|
+
value === "Off" ? 0 : Number(value.replace(/[^0-9]/g, ""));
|
|
89
|
+
break;
|
|
90
|
+
case "jevTurnGateNoulThreshold":
|
|
91
|
+
settings.jevTurnGateNoulThreshold = Number(value);
|
|
92
|
+
break;
|
|
93
|
+
case "jevModel":
|
|
94
|
+
settings.jevModel = value.trim() || DEFAULT_JEV_MODEL;
|
|
95
|
+
break;
|
|
96
|
+
case "jevTimeoutMs":
|
|
97
|
+
settings.jevTimeoutMs = Number(value);
|
|
98
|
+
break;
|
|
99
|
+
case "jevDigestMaxChars":
|
|
100
|
+
settings.jevDigestMaxChars = Number(value);
|
|
101
|
+
break;
|
|
102
|
+
case "jevPricePerMtok":
|
|
103
|
+
settings.jevPricePerMtok = Number(value);
|
|
104
|
+
break;
|
|
105
|
+
case "jevTransport":
|
|
106
|
+
settings.jevTransport = value as AdvisorSettings["jevTransport"];
|
|
107
|
+
break;
|
|
73
108
|
default:
|
|
74
109
|
if (BOOLEAN_SETTING_IDS.has(id)) {
|
|
75
110
|
(settings as unknown as Record<string, SettingValue | boolean>)[id] =
|
|
@@ -8,15 +8,15 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
rainbowGradient,
|
|
10
10
|
SIMPLE_MODE_GRADIENT_INTERVAL_MS,
|
|
11
|
-
} from "./settings-formatting.
|
|
12
|
-
import { createSettingsItems } from "./settings-items.
|
|
13
|
-
import { SettingsListAdapter } from "./settings-list-adapter.
|
|
14
|
-
import { mutateAdvisorSettings } from "./settings-mutations.
|
|
11
|
+
} from "./settings-formatting.ts";
|
|
12
|
+
import { createSettingsItems } from "./settings-items.ts";
|
|
13
|
+
import { SettingsListAdapter } from "./settings-list-adapter.ts";
|
|
14
|
+
import { mutateAdvisorSettings } from "./settings-mutations.ts";
|
|
15
15
|
import type {
|
|
16
16
|
AdvisorSettings,
|
|
17
17
|
AdvisorSettingsSelectorOptions,
|
|
18
18
|
ContextPreset,
|
|
19
|
-
} from "./types.
|
|
19
|
+
} from "./types.ts";
|
|
20
20
|
|
|
21
21
|
export class AdvisorSettingsSelector implements Component, Focusable {
|
|
22
22
|
private readonly options: AdvisorSettingsSelectorOptions;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Input,
|
|
5
5
|
truncateToWidth,
|
|
6
6
|
} from "@earendil-works/pi-tui";
|
|
7
|
-
import type { TextSettingSubmenuOptions } from "./types.
|
|
7
|
+
import type { TextSettingSubmenuOptions } from "./types.ts";
|
|
8
8
|
|
|
9
9
|
/** Small inline editor used by SettingsList for the two free-form settings. */
|
|
10
10
|
export class TextSettingSubmenu implements Component, Focusable {
|
package/src/ui/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { KeybindingsManager, TUI } from "@earendil-works/pi-tui";
|
|
3
|
-
import type { GateFailureMode } from "../config/types.
|
|
4
|
-
import type { GitContextLevel } from "../git.
|
|
3
|
+
import type { GateFailureMode } from "../config/types.ts";
|
|
4
|
+
import type { GitContextLevel } from "../git.ts";
|
|
5
5
|
|
|
6
6
|
export interface RenderRequester {
|
|
7
7
|
requestRender: () => void;
|
|
@@ -69,6 +69,17 @@ export interface AdvisorSettings {
|
|
|
69
69
|
gitContext?: GitContextLevel;
|
|
70
70
|
gitContextMaxChars?: number;
|
|
71
71
|
herdrIntegration?: boolean;
|
|
72
|
+
jevDigestMaxChars?: number;
|
|
73
|
+
jevFilterEnabled?: boolean;
|
|
74
|
+
jevFilterNoulMargin?: number;
|
|
75
|
+
jevFilterOverrideWindow?: number;
|
|
76
|
+
jevFilterSkipConfidence?: number;
|
|
77
|
+
jevModel?: string;
|
|
78
|
+
jevPricePerMtok?: number;
|
|
79
|
+
jevTimeoutMs?: number;
|
|
80
|
+
jevTransport?: "auto" | "typesafe" | "openrouter";
|
|
81
|
+
jevTurnGateEveryTurns?: number;
|
|
82
|
+
jevTurnGateNoulThreshold?: number;
|
|
72
83
|
loopThreshold?: number;
|
|
73
84
|
maxCallsPerSession?: number;
|
|
74
85
|
outcomeLogging?: boolean;
|
package/src/ui.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// biome-ignore lint/performance/noBarrelFile: this facade intentionally preserves the public UI module contract.
|
|
2
|
-
export { ManualAdvisorDialog } from "./ui/manual-dialog.
|
|
3
|
-
export { SearchableModelSelector } from "./ui/model-selector.
|
|
4
|
-
export { AdvisorSettingsSelector } from "./ui/settings-selector.
|
|
2
|
+
export { ManualAdvisorDialog } from "./ui/manual-dialog.ts";
|
|
3
|
+
export { SearchableModelSelector } from "./ui/model-selector.ts";
|
|
4
|
+
export { AdvisorSettingsSelector } from "./ui/settings-selector.ts";
|
|
5
5
|
export type {
|
|
6
6
|
AdvisorSettings,
|
|
7
7
|
ContextPreset,
|
|
8
8
|
ManualAdvisorRequest,
|
|
9
|
-
} from "./ui/types.
|
|
9
|
+
} from "./ui/types.ts";
|
package/src/usage.ts
CHANGED
|
@@ -10,7 +10,6 @@ export interface AdvisorUsageSnapshot {
|
|
|
10
10
|
totalTokens?: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
/** Session-local totals for direct Advisor model requests. */
|
|
14
13
|
export interface AdvisorUsageTotals {
|
|
15
14
|
cacheRead?: number;
|
|
16
15
|
cacheWrite?: number;
|
|
@@ -31,8 +30,7 @@ const finite = (value: unknown) =>
|
|
|
31
30
|
const add = (left: number | undefined, right: number | undefined) =>
|
|
32
31
|
left === undefined || right === undefined ? (left ?? right) : left + right;
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
33
|
+
import { isRecord } from "./content-utils.ts";
|
|
36
34
|
|
|
37
35
|
const costFields = ["input", "output", "cacheRead", "cacheWrite", "total"];
|
|
38
36
|
|
|
@@ -127,7 +125,7 @@ export const addAdvisorUsage = (totals: AdvisorUsageTotals, usage: unknown) => {
|
|
|
127
125
|
}
|
|
128
126
|
};
|
|
129
127
|
|
|
130
|
-
const
|
|
128
|
+
export const formatTokenCount = (value: number) => {
|
|
131
129
|
if (value < 1000) {
|
|
132
130
|
return String(value);
|
|
133
131
|
}
|
|
@@ -143,6 +141,8 @@ const formatTokens = (value: number) => {
|
|
|
143
141
|
return `${Math.round(value / 1_000_000)}M`;
|
|
144
142
|
};
|
|
145
143
|
|
|
144
|
+
const formatTokens = formatTokenCount;
|
|
145
|
+
|
|
146
146
|
const formatCost = (value: number) => `$${value.toFixed(4)}`;
|
|
147
147
|
|
|
148
148
|
const formatUsageFields = (usage: AdvisorUsageSnapshot): string | undefined => {
|
|
@@ -165,13 +165,11 @@ const formatUsageFields = (usage: AdvisorUsageSnapshot): string | undefined => {
|
|
|
165
165
|
return tokens.join(" · ") || undefined;
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
/** Formats one response for an Advisor or Scout result renderer. */
|
|
169
168
|
export const formatAdvisorUsage = (usage: unknown): string | undefined => {
|
|
170
169
|
const snapshot = snapshotAdvisorUsage(usage);
|
|
171
170
|
return snapshot ? formatUsageFields(snapshot) : undefined;
|
|
172
171
|
};
|
|
173
172
|
|
|
174
|
-
/** Formats cumulative direct Advisor usage for a footer or session summary. */
|
|
175
173
|
export const formatAdvisorUsageTotals = (
|
|
176
174
|
totals: AdvisorUsageTotals
|
|
177
175
|
): string => {
|
|
@@ -187,7 +185,6 @@ export const formatAdvisorUsageTotals = (
|
|
|
187
185
|
);
|
|
188
186
|
};
|
|
189
187
|
|
|
190
|
-
/** Formats the current direct Advisor usage status for the Pi footer. */
|
|
191
188
|
export const formatAdvisorUsageStatus = (
|
|
192
189
|
totals: AdvisorUsageTotals
|
|
193
190
|
): string | undefined => {
|