pi-advisor-flow 0.15.1 → 0.15.2-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.
Files changed (71) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +16 -1
  3. package/dist/index.js +1157 -502
  4. package/docs/README.md +9 -0
  5. package/docs/benchmark.md +22 -0
  6. package/docs/configuration.md +194 -0
  7. package/docs/development.md +38 -0
  8. package/docs/herdr.md +169 -0
  9. package/docs/privacy.md +102 -0
  10. package/extensions/index.ts +23 -0
  11. package/locales/de.json +330 -0
  12. package/locales/en.json +331 -0
  13. package/locales/es.json +3 -0
  14. package/locales/fr.json +330 -0
  15. package/locales/pt-BR.json +3 -0
  16. package/locales/pt.json +3 -0
  17. package/locales/ru.json +3 -0
  18. package/locales/uk.json +3 -0
  19. package/locales/zh.json +3 -0
  20. package/package.json +15 -2
  21. package/skills/pi-advisor-flow/SKILL.md +62 -0
  22. package/src/commands/activation-preparation.ts +9 -2
  23. package/src/commands/activation.ts +28 -8
  24. package/src/commands/configuration-tool-models.ts +143 -0
  25. package/src/commands/configuration-tool-policy.ts +177 -0
  26. package/src/commands/configuration-tool-preview.ts +228 -0
  27. package/src/commands/configuration-tool-runtime.ts +40 -0
  28. package/src/commands/configuration-tool-transaction.ts +120 -0
  29. package/src/commands/configuration-tool-update.ts +230 -0
  30. package/src/commands/configuration-tool.ts +89 -0
  31. package/src/commands/lifecycle.ts +6 -1
  32. package/src/commands/manual-consultation.ts +6 -1
  33. package/src/commands/manual-progress.ts +4 -3
  34. package/src/commands/model-commands.ts +2 -1
  35. package/src/commands/model-options.ts +4 -6
  36. package/src/commands/model-picker.ts +16 -6
  37. package/src/commands/registration.ts +2 -0
  38. package/src/commands/runtime.ts +17 -4
  39. package/src/commands/settings-commands.ts +30 -7
  40. package/src/config/schema-validators.ts +104 -0
  41. package/src/config/schema.ts +35 -102
  42. package/src/config/storage.ts +160 -7
  43. package/src/i18n.ts +31 -0
  44. package/src/scout-group-serialization.ts +66 -0
  45. package/src/scout-groups.ts +3 -66
  46. package/src/scout-selection.ts +99 -0
  47. package/src/scout.ts +6 -93
  48. package/src/session-state.ts +27 -137
  49. package/src/tool-input-normalization.ts +119 -0
  50. package/src/tools/gate-policy.ts +13 -5
  51. package/src/tools/jev-filter.ts +2 -1
  52. package/src/tools/jev-turn-gate.ts +2 -1
  53. package/src/tools/register-lifecycle.ts +5 -1
  54. package/src/tools/register-outcome.ts +5 -1
  55. package/src/tools/register-renderers.ts +5 -2
  56. package/src/tools/render-advisor-result.ts +20 -8
  57. package/src/tools/render-common.ts +16 -4
  58. package/src/tools/scout-status.ts +10 -2
  59. package/src/ui/jev-classifier-submenu.ts +143 -38
  60. package/src/ui/jev-filter-submenu.ts +52 -14
  61. package/src/ui/jev-provider-submenu-view.ts +72 -20
  62. package/src/ui/jev-provider-submenu.ts +40 -12
  63. package/src/ui/jev-setup-support.ts +48 -19
  64. package/src/ui/manual-dialog-render.ts +71 -25
  65. package/src/ui/searchable-model-list.ts +18 -4
  66. package/src/ui/settings-formatting.ts +5 -2
  67. package/src/ui/settings-items-jev.ts +216 -0
  68. package/src/ui/settings-items.ts +216 -259
  69. package/src/ui/settings-selector.ts +9 -2
  70. package/src/ui/text-setting-submenu.ts +8 -1
  71. package/src/usage.ts +9 -3
@@ -9,6 +9,7 @@ import { Box, Markdown, Text } from "@earendil-works/pi-tui";
9
9
 
10
10
  import { getAdvisorSettings } from "../config/state.ts";
11
11
  import { isString } from "../content-utils.ts";
12
+ import { t } from "../i18n.ts";
12
13
  import { formatAdvisorUsage } from "../usage.ts";
13
14
  import type { TurnGateResultDetails as TurnGateResultRecord } from "./jev-turn-gate.ts";
14
15
  import { adviceForDisplay, renderAdvisorCallBox } from "./render-common.ts";
@@ -137,7 +138,7 @@ const turnGateResultRenderer: MessageRenderer<TurnGateResultDetails> = (
137
138
  "error",
138
139
  isString(message.content)
139
140
  ? message.content
140
- : "Advisor turn review failed."
141
+ : t("render.turnReviewFailed", "Advisor turn review failed.")
141
142
  ),
142
143
  0,
143
144
  0
@@ -186,7 +187,9 @@ const loopResultRenderer: MessageRenderer<LoopResultDetails> = (
186
187
  new Text(
187
188
  theme.fg(
188
189
  "error",
189
- isString(message.content) ? message.content : "Advisor gate failed."
190
+ isString(message.content)
191
+ ? message.content
192
+ : t("render.gateFailed", "Advisor gate failed.")
190
193
  ),
191
194
  0,
192
195
  0
@@ -8,6 +8,7 @@ import { Box, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
8
8
 
9
9
  import { getAdvisorSettings } from "../config/state.ts";
10
10
  import { textFrom } from "../conversation.ts";
11
+ import { t } from "../i18n.ts";
11
12
  import { formatAdvisorUsage } from "../usage.ts";
12
13
  import {
13
14
  adviceForDisplay,
@@ -77,13 +78,13 @@ const attachmentLabels = (details: AdvisorToolDetails | undefined) =>
77
78
  ? `Project preferences attached · ${formatByteSize(details.preferenceBytes)}`
78
79
  : undefined,
79
80
  details?.trackedBytes
80
- ? `Tracked files attached · ${formatByteSize(details.trackedBytes)}`
81
+ ? `${t("render.trackedAttached", "Tracked files attached")} · ${formatByteSize(details.trackedBytes)}`
81
82
  : undefined,
82
83
  details?.untrackedBytes
83
- ? `Untracked files attached · ${formatByteSize(details.untrackedBytes)}`
84
+ ? `${t("render.untrackedAttached", "Untracked files attached")} · ${formatByteSize(details.untrackedBytes)}`
84
85
  : undefined,
85
86
  details?.imageCount
86
- ? `${details.imageCount} image${details.imageCount === 1 ? "" : "s"} attached${details.imageBytes ? ` · ${formatByteSize(details.imageBytes)}` : ""}${details.imageOmissions ? ` · ${details.imageOmissions} withheld` : ""}`
87
+ ? `${details.imageCount} ${details.imageCount === 1 ? t("render.image", "image") : t("render.images", "images")} ${t("render.attached", "attached")}${details.imageBytes ? ` · ${formatByteSize(details.imageBytes)}` : ""}${details.imageOmissions ? ` · ${details.imageOmissions} ${t("render.withheld", "withheld")}` : ""}`
87
88
  : undefined,
88
89
  ].filter((label): label is string => label !== undefined);
89
90
 
@@ -96,7 +97,10 @@ const renderSkipBox = (
96
97
  const details = advisorResultDetails(result);
97
98
 
98
99
  const lines = [
99
- theme.fg("dim", theme.bold("◆ ADVISOR · SKIPPED")),
100
+ theme.fg(
101
+ "dim",
102
+ theme.bold(`◆ ADVISOR · ${t("render.skipped", "SKIPPED")}`)
103
+ ),
100
104
  theme.fg("dim", ` ${details?.skipReason ?? details?.jev?.reason ?? ""}`),
101
105
  ];
102
106
 
@@ -147,7 +151,7 @@ const renderPartialAdvisorResult = (
147
151
  SPINNER_FRAMES[Math.floor(Date.now() / 80) % SPINNER_FRAMES.length];
148
152
 
149
153
  const lines = [
150
- `${theme.fg("warning", theme.bold(`◆ ADVISOR ${frame}`))} ${theme.fg("dim", "· Working…")}`,
154
+ `${theme.fg("warning", theme.bold(`◆ ADVISOR ${frame}`))} ${theme.fg("dim", `· ${t("render.working", "Working…")}`)}`,
151
155
  ];
152
156
 
153
157
  box.addChild(new Text(lines.join("\n"), 0, 0));
@@ -186,7 +190,12 @@ const finalResultLines = (
186
190
  const lines = [renderAdvisorResponseHeader(hasSoundVerdict(advice), theme)];
187
191
 
188
192
  if (details?.followUp) {
189
- lines.push(theme.fg("dim", " Follow-up consultation"));
193
+ lines.push(
194
+ theme.fg(
195
+ "dim",
196
+ ` ${t("render.followUpConsultation", "Follow-up consultation")}`
197
+ )
198
+ );
190
199
  }
191
200
 
192
201
  if (details?.advisor) {
@@ -197,7 +206,7 @@ const finalResultLines = (
197
206
  const usage = formatAdvisorUsage(details?.usage);
198
207
 
199
208
  if (usage) {
200
- lines.push(theme.fg("dim", ` Usage: ${usage}`));
209
+ lines.push(theme.fg("dim", ` ${t("render.usage", "Usage:")} ${usage}`));
201
210
  }
202
211
  }
203
212
 
@@ -249,7 +258,10 @@ const renderFinalAdvisorResult = (
249
258
  const advice = details?.text || textFrom(result.content);
250
259
  const thinking = thinkingPreview(details);
251
260
  const lines = finalResultLines(details, advice, theme);
252
- const displayAdvice = advice || "(Advisor returned no advice.)";
261
+
262
+ const displayAdvice =
263
+ advice || t("render.noAdvice", "(Advisor returned no advice.)");
264
+
253
265
  box.addChild(new Text(lines.join("\n"), 0, 0));
254
266
 
255
267
  if (thinking) {
@@ -10,6 +10,7 @@ import {
10
10
  import type { Component } from "@earendil-works/pi-tui";
11
11
 
12
12
  import { advisorCollapseResponsesRef } from "../config/state.ts";
13
+ import { t } from "../i18n.ts";
13
14
  import { piHideThinkingEnabled } from "../pi-settings.ts";
14
15
 
15
16
  export const SPINNER_FRAMES = [
@@ -67,7 +68,10 @@ class ThinkingMarkdown implements Component {
67
68
 
68
69
  /** Collapsed placeholder shown when Pi's hide_thinking setting is on. */
69
70
  const hiddenThinkingLabel = (theme: ThinkingTheme): Component => {
70
- const label = theme.fg("thinkingText", `${THINKING_PREFIX}Thinking…`);
71
+ const label = theme.fg(
72
+ "thinkingText",
73
+ `${THINKING_PREFIX}${t("render.thinking", "Thinking…")}`
74
+ );
71
75
 
72
76
  return {
73
77
  invalidate: noop,
@@ -96,7 +100,9 @@ export const renderAdvisorCallBox = (
96
100
 
97
101
  const title = theme.fg(
98
102
  "customMessageText",
99
- followUp ? "Executor → Advisor · Follow-up" : "Executor → Advisor"
103
+ followUp
104
+ ? `${t("render.executorToAdvisor", "Executor → Advisor")} · ${t("render.followUp", "Follow-up")}`
105
+ : t("render.executorToAdvisor", "Executor → Advisor")
100
106
  );
101
107
 
102
108
  box.addChild(
@@ -125,8 +131,14 @@ export const hasSoundVerdict = (advice: string) =>
125
131
  /** The single Advisor response header shared by tool and manual renderers. */
126
132
  export const renderAdvisorResponseHeader = (sound: boolean, theme: Theme) =>
127
133
  sound
128
- ? theme.fg("accent", theme.bold("◆ ADVISOR · SOUND"))
129
- : theme.fg("warning", theme.bold("◆ ADVISOR RESPONSE"));
134
+ ? theme.fg(
135
+ "accent",
136
+ theme.bold(`◆ ADVISOR · ${t("render.sound", "SOUND")}`)
137
+ )
138
+ : theme.fg(
139
+ "warning",
140
+ theme.bold(`◆ ADVISOR ${t("render.response", "RESPONSE")}`)
141
+ );
130
142
 
131
143
  export const adviceForDisplay = (advice: string, expanded: boolean) => {
132
144
  if (!advisorCollapseResponsesRef || expanded) {
@@ -11,6 +11,7 @@ import {
11
11
  executorRef,
12
12
  getAdvisorSettings,
13
13
  } from "../config/state.ts";
14
+ import { t } from "../i18n.ts";
14
15
  import type { ScoutLifecycleEvent } from "../scout.ts";
15
16
  import { uiAction, uiAvailable } from "../ui-guard.ts";
16
17
  import { formatAdvisorUsage, snapshotAdvisorUsage } from "../usage.ts";
@@ -113,7 +114,12 @@ export class ScoutStatusManager {
113
114
  this.#active.add(token);
114
115
 
115
116
  if (this.showStatus) {
116
- uiAction(ctx, (ui) => ui.setStatus("advisor-scout", "Scout curating…"));
117
+ uiAction(ctx, (ui) =>
118
+ ui.setStatus(
119
+ "advisor-scout",
120
+ t("status.scoutCurating", "Scout curating…")
121
+ )
122
+ );
117
123
  }
118
124
 
119
125
  return;
@@ -134,7 +140,9 @@ export class ScoutStatusManager {
134
140
  uiAction(ctx, (ui) =>
135
141
  ui.setStatus(
136
142
  "advisor-scout",
137
- this.#active.size > 0 ? "Scout curating…" : undefined
143
+ this.#active.size > 0
144
+ ? t("status.scoutCurating", "Scout curating…")
145
+ : undefined
138
146
  )
139
147
  );
140
148
  }
@@ -8,6 +8,7 @@ import type {
8
8
  } from "@earendil-works/pi-tui";
9
9
 
10
10
  import { JEV_API_KEY_CLASSIFIER } from "../config/types.ts";
11
+ import { t } from "../i18n.ts";
11
12
  import {
12
13
  disableJevClassifierKeyForRuntime,
13
14
  enableJevClassifierKeyForRuntime,
@@ -81,14 +82,21 @@ export class JevClassifierSubmenu implements Component, Focusable {
81
82
  if (this.mode === "key") {
82
83
  return [
83
84
  border,
84
- theme.fg("accent", theme.bold("Jev API Key")),
85
+ theme.fg(
86
+ "accent",
87
+ theme.bold(t("jevSubmenu.apiKeyTitle", "Jev API Key"))
88
+ ),
85
89
  "",
86
- this.notice ?? "Enter a new TypeSafe Jev API key:",
90
+ this.notice ??
91
+ t("jevSubmenu.enterNewKey", "Enter a new TypeSafe Jev API key:"),
87
92
  ` ${this.keyInput?.render(Math.max(1, width - 4))[0] ?? ""}`,
88
93
  "",
89
94
  this.failClosedKeyMode
90
- ? "Key restore failed. Re-enter and verify a valid Jev key."
91
- : "Enter to verify · Esc to cancel",
95
+ ? t(
96
+ "jevSubmenu.keyRestoreFailed",
97
+ "Key restore failed. Re-enter and verify a valid Jev key."
98
+ )
99
+ : t("jevSubmenu.keyEntryHint", "Enter to verify · Esc to cancel"),
92
100
  border,
93
101
  ];
94
102
  }
@@ -108,15 +116,20 @@ export class JevClassifierSubmenu implements Component, Focusable {
108
116
 
109
117
  return [
110
118
  border,
111
- theme.fg("accent", theme.bold("Jev classifier")),
119
+ theme.fg(
120
+ "accent",
121
+ theme.bold(t("jevSubmenu.classifierTitle", "Jev classifier"))
122
+ ),
112
123
  "",
113
124
  this.mode === "loading"
114
- ? "Loading Pi classifier catalog…"
115
- : `Search: ${this.search.render(Math.max(1, width - 10))[0]}`,
125
+ ? t("jevSubmenu.loading", "Loading Pi classifier catalog…")
126
+ : `${t("jevSubmenu.searchLabel", "Search:")} ${
127
+ this.search.render(Math.max(1, width - 10))[0]
128
+ }`,
116
129
  ...(this.notice ? [this.notice] : []),
117
130
  ...rows.slice(0, 10),
118
131
  "",
119
- "↑/↓ move · Enter select · Esc cancel",
132
+ t("jevSubmenu.listHint", "↑/↓ move · Enter select · Esc cancel"),
120
133
  border,
121
134
  ];
122
135
  }
@@ -161,7 +174,12 @@ export class JevClassifierSubmenu implements Component, Focusable {
161
174
  private async loadChoices() {
162
175
  try {
163
176
  if (!this.options.modelRegistry) {
164
- throw new Error("Pi classifier registry is unavailable.");
177
+ throw new Error(
178
+ t(
179
+ "jevSubmenu.registryUnavailable",
180
+ "Pi classifier registry is unavailable."
181
+ )
182
+ );
165
183
  }
166
184
 
167
185
  const models =
@@ -182,19 +200,22 @@ export class JevClassifierSubmenu implements Component, Focusable {
182
200
  this.choices.push(
183
201
  {
184
202
  action: "use-key",
185
- label: "Jev API Key (use stored key)",
203
+ label: t("jevSubmenu.useStoredKey", "Jev API Key (use stored key)"),
186
204
  ref: JEV_API_KEY_CLASSIFIER,
187
205
  },
188
206
  {
189
207
  action: "replace-key",
190
- label: "Replace Jev API Key…",
208
+ label: t("jevSubmenu.replaceKey", "Replace Jev API Key…"),
191
209
  ref: JEV_API_KEY_CLASSIFIER,
192
210
  }
193
211
  );
194
212
  } else {
195
213
  this.choices.push({
196
214
  action: "replace-key",
197
- label: "Jev API Key… (enter TypeSafe key)",
215
+ label: t(
216
+ "jevSubmenu.enterKeyChoice",
217
+ "Jev API Key… (enter TypeSafe key)"
218
+ ),
198
219
  ref: JEV_API_KEY_CLASSIFIER,
199
220
  });
200
221
  }
@@ -204,12 +225,21 @@ export class JevClassifierSubmenu implements Component, Focusable {
204
225
  this.notice =
205
226
  this.options.currentValue &&
206
227
  this.options.currentValue !== "Choose classifier"
207
- ? `Current: ${this.options.currentValue}`
228
+ ? `${t("jevSubmenu.currentPrefix", "Current:")} ${
229
+ this.options.currentValue
230
+ }`
208
231
  : undefined;
209
232
  } catch (error) {
210
233
  this.mode = "list";
211
234
  this.loaded.resolve(false);
212
- this.notice = `Could not load classifiers: ${error instanceof Error ? error.message : "unknown error"}. Retry /advisor-settings.`;
235
+ this.notice = `${t(
236
+ "jevSubmenu.loadFailedPrefix",
237
+ "Could not load classifiers:"
238
+ )} ${
239
+ error instanceof Error
240
+ ? error.message
241
+ : t("jevSetup.unknownError", "unknown error")
242
+ }${t("jevSubmenu.loadFailedSuffix", ". Retry /advisor-settings.")}`;
213
243
  }
214
244
 
215
245
  this.options.tui.requestRender();
@@ -223,8 +253,11 @@ export class JevClassifierSubmenu implements Component, Focusable {
223
253
  const rates = model.cost;
224
254
 
225
255
  return rates.input === 0 && rates.output === 0
226
- ? "$0/M tokens"
227
- : `$${rates.input}/$${rates.output} per Mtok`;
256
+ ? t("jevSubmenu.ratesFree", "$0/M tokens")
257
+ : `$${rates.input}/$${rates.output} ${t(
258
+ "jevSubmenu.perMtok",
259
+ "per Mtok"
260
+ )}`;
228
261
  }
229
262
 
230
263
  private async choose(choice: Choice) {
@@ -253,7 +286,7 @@ export class JevClassifierSubmenu implements Component, Focusable {
253
286
  }
254
287
 
255
288
  this.mode = "verifying";
256
- this.notice = `Verifying ${choice.ref}…`;
289
+ this.notice = `${t("jevSubmenu.verifying", "Verifying")} ${choice.ref}…`;
257
290
  this.options.tui.requestRender();
258
291
 
259
292
  try {
@@ -262,10 +295,20 @@ export class JevClassifierSubmenu implements Component, Focusable {
262
295
 
263
296
  if (!saved) {
264
297
  this.mode = "list";
265
- this.notice = "Verified, but settings could not be saved.";
298
+ this.notice = t(
299
+ "jevSubmenu.verifiedNotSaved",
300
+ "Verified, but settings could not be saved."
301
+ );
266
302
  }
267
303
  } catch (error) {
268
- this.notice = `Verification failed for ${choice.ref}: ${error instanceof Error ? error.message : "provider error"}`;
304
+ this.notice = `${t(
305
+ "jevSubmenu.verifyFailedFor",
306
+ "Verification failed for"
307
+ )} ${choice.ref}: ${
308
+ error instanceof Error
309
+ ? error.message
310
+ : t("jevSubmenu.providerError", "provider error")
311
+ }`;
269
312
  this.mode = "list";
270
313
  }
271
314
 
@@ -274,7 +317,12 @@ export class JevClassifierSubmenu implements Component, Focusable {
274
317
 
275
318
  private async verify(model: ClassifierModel<string>, apiKey?: string) {
276
319
  if (!this.options.modelRegistry) {
277
- throw new Error("Pi classifier registry is unavailable.");
320
+ throw new Error(
321
+ t(
322
+ "jevSubmenu.registryUnavailable",
323
+ "Pi classifier registry is unavailable."
324
+ )
325
+ );
278
326
  }
279
327
 
280
328
  const state = {
@@ -291,7 +339,12 @@ export class JevClassifierSubmenu implements Component, Focusable {
291
339
  );
292
340
 
293
341
  if (!result.answers.self_answerable || !result.answers.stakes) {
294
- throw new Error("Classifier returned an incomplete verification result.");
342
+ throw new Error(
343
+ t(
344
+ "jevSubmenu.incompleteResult",
345
+ "Classifier returned an incomplete verification result."
346
+ )
347
+ );
295
348
  }
296
349
  }
297
350
 
@@ -300,7 +353,7 @@ export class JevClassifierSubmenu implements Component, Focusable {
300
353
  this.keyInput?.setValue("");
301
354
 
302
355
  if (!candidate) {
303
- this.notice = "Enter a non-empty Jev API key.";
356
+ this.notice = t("jevSubmenu.emptyKey", "Enter a non-empty Jev API key.");
304
357
  this.options.tui.requestRender();
305
358
 
306
359
  return;
@@ -313,7 +366,10 @@ export class JevClassifierSubmenu implements Component, Focusable {
313
366
  );
314
367
 
315
368
  if (!model) {
316
- this.notice = "TypeSafe Jev classifier is not present in Pi's catalog.";
369
+ this.notice = t(
370
+ "jevSubmenu.classifierMissing",
371
+ "TypeSafe Jev classifier is not present in Pi's catalog."
372
+ );
317
373
  this.options.tui.requestRender();
318
374
 
319
375
  return;
@@ -325,15 +381,17 @@ export class JevClassifierSubmenu implements Component, Focusable {
325
381
 
326
382
  if (previous.failed) {
327
383
  this.mode = "list";
328
- this.notice =
329
- "Could not read the stored Jev API Key state; nothing was changed. Try again later.";
384
+ this.notice = t(
385
+ "jevSubmenu.keyStateUnreadable",
386
+ "Could not read the stored Jev API Key state; nothing was changed. Try again later."
387
+ );
330
388
  this.options.tui.requestRender();
331
389
 
332
390
  return;
333
391
  }
334
392
 
335
393
  this.mode = "verifying";
336
- this.notice = "Verifying Jev API Key…";
394
+ this.notice = t("jevSubmenu.verifyingKey", "Verifying Jev API Key…");
337
395
  this.options.tui.requestRender();
338
396
 
339
397
  try {
@@ -356,20 +414,36 @@ export class JevClassifierSubmenu implements Component, Focusable {
356
414
  this.failClosedKeyMode = true;
357
415
  disableJevClassifierKeyForRuntime();
358
416
  throw new Error(
359
- "Settings save failed and the previous key could not be restored. Re-enter and verify a valid Jev key before continuing."
417
+ t(
418
+ "jevSubmenu.saveFailedNoRestore",
419
+ "Settings save failed and the previous key could not be restored. Re-enter and verify a valid Jev key before continuing."
420
+ )
360
421
  );
361
422
  }
362
423
 
363
424
  throw new Error(
364
- "Could not save Jev classifier settings; existing key was restored."
425
+ t(
426
+ "jevSubmenu.saveFailedRestored",
427
+ "Could not save Jev classifier settings; existing key was restored."
428
+ )
365
429
  );
366
430
  }
367
431
 
368
432
  this.mode = "list";
369
- this.notice = "Jev API Key verified and saved securely.";
433
+ this.notice = t(
434
+ "jevSubmenu.keyVerifiedSaved",
435
+ "Jev API Key verified and saved securely."
436
+ );
370
437
  } catch (error) {
371
438
  this.mode = "key";
372
- this.notice = `Verification failed: ${error instanceof Error ? error.message : "provider error"}`;
439
+ this.notice = `${t(
440
+ "jevSubmenu.verificationFailedPrefix",
441
+ "Verification failed:"
442
+ )} ${
443
+ error instanceof Error
444
+ ? error.message
445
+ : t("jevSubmenu.providerError", "provider error")
446
+ }`;
373
447
  }
374
448
 
375
449
  this.options.tui.requestRender();
@@ -384,7 +458,7 @@ export class JevClassifierSubmenu implements Component, Focusable {
384
458
  this.options.tui.requestRender();
385
459
  },
386
460
  onSubmit: () => this.handleKeySubmit(),
387
- placeholder: "TypeSafe Jev API key",
461
+ placeholder: t("jevSubmenu.keyPlaceholder", "TypeSafe Jev API key"),
388
462
  });
389
463
  }
390
464
 
@@ -406,14 +480,20 @@ export class JevClassifierSubmenu implements Component, Focusable {
406
480
  );
407
481
 
408
482
  if (!model) {
409
- this.notice = "TypeSafe Jev classifier is not present in Pi's catalog.";
483
+ this.notice = t(
484
+ "jevSubmenu.classifierMissing",
485
+ "TypeSafe Jev classifier is not present in Pi's catalog."
486
+ );
410
487
  this.options.tui.requestRender();
411
488
 
412
489
  return;
413
490
  }
414
491
 
415
492
  this.mode = "verifying";
416
- this.notice = "Verifying stored Jev API Key…";
493
+ this.notice = t(
494
+ "jevSubmenu.verifyingStoredKey",
495
+ "Verifying stored Jev API Key…"
496
+ );
417
497
  this.options.tui.requestRender();
418
498
 
419
499
  try {
@@ -422,13 +502,28 @@ export class JevClassifierSubmenu implements Component, Focusable {
422
502
  if (
423
503
  !this.save({ classifier: JEV_API_KEY_CLASSIFIER, transport: "auto" })
424
504
  ) {
425
- throw new Error("Could not save the Jev classifier selection.");
505
+ throw new Error(
506
+ t(
507
+ "jevSubmenu.selectionNotSaved",
508
+ "Could not save the Jev classifier selection."
509
+ )
510
+ );
426
511
  }
427
512
 
428
- this.notice = "Stored Jev API Key verified.";
513
+ this.notice = t(
514
+ "jevSubmenu.storedKeyVerified",
515
+ "Stored Jev API Key verified."
516
+ );
429
517
  } catch (error) {
430
518
  this.mode = "list";
431
- this.notice = `Verification failed: ${error instanceof Error ? error.message : "provider error"}`;
519
+ this.notice = `${t(
520
+ "jevSubmenu.verificationFailedPrefix",
521
+ "Verification failed:"
522
+ )} ${
523
+ error instanceof Error
524
+ ? error.message
525
+ : t("jevSubmenu.providerError", "provider error")
526
+ }`;
432
527
  }
433
528
 
434
529
  this.options.tui.requestRender();
@@ -438,7 +533,14 @@ export class JevClassifierSubmenu implements Component, Focusable {
438
533
  try {
439
534
  await this.verifyKey();
440
535
  } catch (error) {
441
- this.notice = `Verification failed: ${error instanceof Error ? error.message : "provider error"}`;
536
+ this.notice = `${t(
537
+ "jevSubmenu.verificationFailedPrefix",
538
+ "Verification failed:"
539
+ )} ${
540
+ error instanceof Error
541
+ ? error.message
542
+ : t("jevSubmenu.providerError", "provider error")
543
+ }`;
442
544
  this.mode = "key";
443
545
  this.options.tui.requestRender();
444
546
  }
@@ -451,7 +553,10 @@ export class JevClassifierSubmenu implements Component, Focusable {
451
553
  this.options.done(selection.classifier);
452
554
  } else {
453
555
  this.mode = "list";
454
- this.notice = "Verified, but settings could not be saved.";
556
+ this.notice = t(
557
+ "jevSubmenu.verifiedNotSaved",
558
+ "Verified, but settings could not be saved."
559
+ );
455
560
  }
456
561
 
457
562
  return saved;
@@ -4,6 +4,7 @@ import { Key, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
4
4
  import type { Component, Focusable } from "@earendil-works/pi-tui";
5
5
 
6
6
  import { JEV_API_KEY_CLASSIFIER } from "../config/types.ts";
7
+ import { t } from "../i18n.ts";
7
8
  import { readJevClassifierKey } from "../jev/classifier-key-store.ts";
8
9
  import type { JevClassifierKeySnapshot } from "../jev/classifier-key-store.ts";
9
10
  import { parseJevClassifierRef } from "../jev/classifier.ts";
@@ -31,10 +32,12 @@ const actionsFor = (enabled: boolean): FilterAction[] =>
31
32
 
32
33
  const labelFor = (action: FilterAction) => {
33
34
  if (action === "enable") {
34
- return "Enable the filter";
35
+ return t("jevSubmenu.filter.enable", "Enable the filter");
35
36
  }
36
37
 
37
- return action === "disable" ? "Disable the filter" : "Done";
38
+ return action === "disable"
39
+ ? t("jevSubmenu.filter.disable", "Disable the filter")
40
+ : t("jevSubmenu.filter.done", "Done");
38
41
  };
39
42
 
40
43
  export class JevFilterSubmenu implements Component, Focusable {
@@ -70,14 +73,33 @@ export class JevFilterSubmenu implements Component, Focusable {
70
73
  const { theme } = this.options;
71
74
 
72
75
  const lines = [
73
- theme.fg("accent", theme.bold(" Jev classifier consultation filter")),
76
+ theme.fg(
77
+ "accent",
78
+ theme.bold(
79
+ ` ${t(
80
+ "jevSubmenu.filter.title",
81
+ "Jev classifier consultation filter"
82
+ )}`
83
+ )
84
+ ),
74
85
  "",
75
- ` Filter: ${this.enabled ? "On" : "Off"}`,
76
- ` Classifier: ${this.options.currentClassifier ?? "not selected"}`,
86
+ ` ${t("jevSubmenu.filter.filterLabel", "Filter:")} ${
87
+ this.enabled ? "On" : "Off"
88
+ }`,
89
+ ` ${t("jevSubmenu.filter.classifierLabel", "Classifier:")} ${
90
+ this.options.currentClassifier ??
91
+ t("jevSubmenu.filter.notSelected", "not selected")
92
+ }`,
77
93
  ];
78
94
 
79
95
  if (this.mode === "resolving") {
80
- lines.push("", " Checking selected classifier availability…");
96
+ lines.push(
97
+ "",
98
+ ` ${t(
99
+ "jevSubmenu.filter.checking",
100
+ "Checking selected classifier availability…"
101
+ )}`
102
+ );
81
103
  } else if (this.notice) {
82
104
  lines.push("", theme.fg("warning", ` ${this.notice}`));
83
105
  }
@@ -136,11 +158,15 @@ export class JevFilterSubmenu implements Component, Focusable {
136
158
  this.classifierAvailable = Boolean(stored.key);
137
159
 
138
160
  if (stored.failed) {
139
- this.notice =
140
- "Could not read the stored Jev API Key state; try again later.";
161
+ this.notice = t(
162
+ "jevSubmenu.filter.keyStateUnreadable",
163
+ "Could not read the stored Jev API Key state; try again later."
164
+ );
141
165
  } else if (!this.classifierAvailable) {
142
- this.notice =
143
- "No Jev API Key is stored. Choose Jev API Key in Jev classifier settings.";
166
+ this.notice = t(
167
+ "jevSubmenu.filter.noStoredKey",
168
+ "No Jev API Key is stored. Choose Jev API Key in Jev classifier settings."
169
+ );
144
170
  }
145
171
  } else {
146
172
  const parsed = selected ? parseJevClassifierRef(selected) : undefined;
@@ -158,12 +184,21 @@ export class JevFilterSubmenu implements Component, Focusable {
158
184
  }
159
185
 
160
186
  if (!this.classifierAvailable) {
161
- this.notice =
162
- "Select an available authenticated classifier in Jev classifier settings first.";
187
+ this.notice = t(
188
+ "jevSubmenu.filter.selectClassifierFirst",
189
+ "Select an available authenticated classifier in Jev classifier settings first."
190
+ );
163
191
  }
164
192
  }
165
193
  } catch (error) {
166
- this.notice = `Classifier lookup failed: ${error instanceof Error ? error.message : "Pi error"}`;
194
+ this.notice = `${t(
195
+ "jevSubmenu.filter.lookupFailedPrefix",
196
+ "Classifier lookup failed:"
197
+ )} ${
198
+ error instanceof Error
199
+ ? error.message
200
+ : t("jevSubmenu.filter.piError", "Pi error")
201
+ }`;
167
202
  }
168
203
 
169
204
  this.mode = "menu";
@@ -186,7 +221,10 @@ export class JevFilterSubmenu implements Component, Focusable {
186
221
  }
187
222
 
188
223
  if (this.options.onSelection?.({ enabled }) === false) {
189
- this.notice = "The filter state could not be saved.";
224
+ this.notice = t(
225
+ "jevSubmenu.filter.stateNotSaved",
226
+ "The filter state could not be saved."
227
+ );
190
228
  this.options.tui.requestRender();
191
229
 
192
230
  return;