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.
Files changed (87) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +1 -0
  3. package/dist/index.js +3160 -1255
  4. package/extensions/index.ts +9 -9
  5. package/package.json +12 -8
  6. package/src/{untracked.ts → attachments.ts} +2 -5
  7. package/src/commands/activation-preparation.ts +6 -6
  8. package/src/commands/activation.ts +7 -7
  9. package/src/commands/lifecycle.ts +5 -5
  10. package/src/commands/manual-command.ts +13 -9
  11. package/src/commands/manual-consultation.ts +24 -10
  12. package/src/commands/manual-progress.ts +3 -3
  13. package/src/commands/model-commands.ts +6 -6
  14. package/src/commands/model-options.ts +4 -4
  15. package/src/commands/model-picker.ts +2 -2
  16. package/src/commands/registration.ts +8 -8
  17. package/src/commands/renderers.ts +5 -5
  18. package/src/commands/runtime.ts +8 -8
  19. package/src/commands/settings-commands.ts +8 -8
  20. package/src/commands/settings-persistence.ts +52 -4
  21. package/src/commands/types.ts +6 -13
  22. package/src/commands.ts +2 -2
  23. package/src/config/args.ts +3 -3
  24. package/src/config/defaults.ts +78 -3
  25. package/src/config/schema.ts +434 -0
  26. package/src/config/state.ts +71 -2
  27. package/src/config/storage.ts +27 -119
  28. package/src/config/types.ts +30 -1
  29. package/src/config/validation.ts +61 -181
  30. package/src/config.ts +7 -7
  31. package/src/content-utils.ts +30 -0
  32. package/src/conversation.ts +13 -168
  33. package/src/git.ts +4 -18
  34. package/src/herdr.ts +6 -8
  35. package/src/jev/client.ts +348 -0
  36. package/src/jev/key-store.ts +252 -0
  37. package/src/jev/ledger.ts +234 -0
  38. package/src/jev/questions.ts +119 -0
  39. package/src/jev/state.ts +47 -0
  40. package/src/jev/transport.ts +58 -0
  41. package/src/model-stream.ts +5 -8
  42. package/src/outcomes.ts +3 -2
  43. package/src/pi-settings.ts +59 -0
  44. package/src/preferences.ts +2 -2
  45. package/src/redaction.ts +50 -0
  46. package/src/scout-context.ts +121 -485
  47. package/src/scout-curation.ts +84 -0
  48. package/src/scout-groups.ts +485 -0
  49. package/src/scout-protocol.ts +122 -0
  50. package/src/scout-reconstruct.ts +44 -0
  51. package/src/scout-types.ts +66 -0
  52. package/src/scout.ts +53 -63
  53. package/src/session-state.ts +215 -78
  54. package/src/tool-result-cap.ts +88 -0
  55. package/src/tools/consult-context.ts +155 -0
  56. package/src/tools/consultation.ts +71 -220
  57. package/src/tools/gate-policy.ts +5 -5
  58. package/src/tools/gate-protocol.ts +2 -2
  59. package/src/tools/jev-filter.ts +202 -0
  60. package/src/tools/jev-turn-gate.ts +183 -0
  61. package/src/tools/loop-gate.ts +71 -61
  62. package/src/tools/outage-notifier.ts +30 -0
  63. package/src/tools/prompts.ts +4 -7
  64. package/src/tools/register-ask-advisor.ts +46 -15
  65. package/src/tools/register-lifecycle.ts +7 -7
  66. package/src/tools/register-outcome.ts +5 -5
  67. package/src/tools/register-renderers.ts +63 -5
  68. package/src/tools/registration.ts +27 -10
  69. package/src/tools/render-advisor-result.ts +54 -22
  70. package/src/tools/render-common.ts +25 -13
  71. package/src/tools/scout-status.ts +5 -5
  72. package/src/tools/session.ts +1 -1
  73. package/src/tools/types.ts +17 -7
  74. package/src/tools.ts +9 -9
  75. package/src/ui/jev-setup-submenu.ts +344 -0
  76. package/src/ui/manual-dialog-render.ts +2 -2
  77. package/src/ui/manual-dialog.ts +4 -9
  78. package/src/ui/masked-input.ts +68 -0
  79. package/src/ui/model-selector.ts +1 -1
  80. package/src/ui/settings-formatting.ts +2 -2
  81. package/src/ui/settings-items.ts +166 -5
  82. package/src/ui/settings-mutations.ts +37 -2
  83. package/src/ui/settings-selector.ts +5 -5
  84. package/src/ui/text-setting-submenu.ts +1 -1
  85. package/src/ui/types.ts +13 -2
  86. package/src/ui.ts +4 -4
  87. package/src/usage.ts +4 -7
@@ -1,6 +1,7 @@
1
- import type { AdvisorSettings, ContextPreset, SettingValue } from "./types.js";
1
+ import { DEFAULT_JEV_MODEL } from "../config/types.ts";
2
+ import type { AdvisorSettings, ContextPreset, SettingValue } from "./types.ts";
2
3
 
3
- export const BOOLEAN_SETTING_IDS = new Set([
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.js";
12
- import { createSettingsItems } from "./settings-items.js";
13
- import { SettingsListAdapter } from "./settings-list-adapter.js";
14
- import { mutateAdvisorSettings } from "./settings-mutations.js";
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.js";
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.js";
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.js";
4
- import type { GitContextLevel } from "../git.js";
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.js";
3
- export { SearchableModelSelector } from "./ui/model-selector.js";
4
- export { AdvisorSettingsSelector } from "./ui/settings-selector.js";
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.js";
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
- const isRecord = (value: unknown): value is Record<string, unknown> =>
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 formatTokens = (value: number) => {
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 => {