pi-advisor-flow 0.13.1 → 0.13.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 (105) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/index.js +14 -7
  3. package/extensions/index.ts +6 -0
  4. package/package.json +9 -9
  5. package/scripts/check-bun-version.mjs +9 -0
  6. package/src/attachments.ts +36 -0
  7. package/src/child-session.ts +1 -0
  8. package/src/commands/activation-preparation.ts +12 -0
  9. package/src/commands/activation.ts +43 -0
  10. package/src/commands/advisor-tools.ts +3 -0
  11. package/src/commands/lifecycle.ts +15 -0
  12. package/src/commands/manual-command.ts +19 -0
  13. package/src/commands/manual-consultation.ts +20 -0
  14. package/src/commands/manual-progress.ts +13 -0
  15. package/src/commands/model-commands.ts +4 -0
  16. package/src/commands/model-options.ts +18 -0
  17. package/src/commands/model-picker.ts +16 -0
  18. package/src/commands/outcome-stats.ts +9 -0
  19. package/src/commands/registration.ts +1 -0
  20. package/src/commands/renderers.ts +14 -0
  21. package/src/commands/runtime.ts +5 -0
  22. package/src/commands/settings-commands.ts +18 -0
  23. package/src/commands/settings-persistence.ts +2 -0
  24. package/src/commands.ts +1 -0
  25. package/src/config/args.ts +7 -0
  26. package/src/config/defaults.ts +1 -0
  27. package/src/config/schema.ts +1 -0
  28. package/src/config/state.ts +64 -1
  29. package/src/config/storage.ts +37 -0
  30. package/src/config/types.ts +9 -0
  31. package/src/config/validation.ts +7 -0
  32. package/src/config.ts +6 -0
  33. package/src/content-utils.ts +5 -0
  34. package/src/conversation.ts +39 -0
  35. package/src/follow-up.ts +8 -0
  36. package/src/git.ts +8 -0
  37. package/src/herdr-block.ts +7 -0
  38. package/src/herdr-shared.ts +23 -0
  39. package/src/herdr.ts +18 -0
  40. package/src/image-attachments.ts +24 -0
  41. package/src/image-validation.ts +58 -0
  42. package/src/images.ts +24 -0
  43. package/src/jev/base-url.ts +14 -0
  44. package/src/jev/client.ts +49 -0
  45. package/src/jev/decisions-client.ts +14 -0
  46. package/src/jev/decisions-response.ts +38 -0
  47. package/src/jev/endpoint-key-store.ts +18 -0
  48. package/src/jev/key-store.ts +28 -0
  49. package/src/jev/ledger.ts +30 -12
  50. package/src/jev/openai-key-store.ts +17 -0
  51. package/src/jev/questions.ts +15 -0
  52. package/src/jev/state.ts +5 -0
  53. package/src/jev/transport.ts +35 -0
  54. package/src/model-stream.ts +32 -0
  55. package/src/outcome-stats.ts +16 -0
  56. package/src/outcomes.ts +31 -0
  57. package/src/pi-settings.ts +9 -0
  58. package/src/preferences.ts +26 -0
  59. package/src/redaction.ts +8 -0
  60. package/src/scout-context.ts +17 -0
  61. package/src/scout-curation.ts +12 -0
  62. package/src/scout-groups.ts +47 -0
  63. package/src/scout-protocol.ts +17 -0
  64. package/src/scout-reconstruct.ts +12 -0
  65. package/src/scout.ts +47 -0
  66. package/src/session-context.ts +11 -0
  67. package/src/session-state.ts +73 -13
  68. package/src/tool-result-cap.ts +11 -0
  69. package/src/tools/consult-context.ts +24 -0
  70. package/src/tools/consultation.ts +43 -0
  71. package/src/tools/gate-policy.ts +18 -0
  72. package/src/tools/gate-protocol.ts +22 -0
  73. package/src/tools/jev-filter.ts +26 -0
  74. package/src/tools/jev-turn-gate.ts +17 -0
  75. package/src/tools/loop-gate.ts +25 -0
  76. package/src/tools/model-access.ts +12 -0
  77. package/src/tools/outage-notifier.ts +4 -0
  78. package/src/tools/prompts.ts +17 -0
  79. package/src/tools/register-ask-advisor.ts +44 -0
  80. package/src/tools/register-lifecycle.ts +32 -0
  81. package/src/tools/register-outcome.ts +7 -0
  82. package/src/tools/register-renderers.ts +14 -0
  83. package/src/tools/registration.ts +3 -0
  84. package/src/tools/render-advisor-result.ts +44 -0
  85. package/src/tools/render-common.ts +10 -0
  86. package/src/tools/scout-status.ts +34 -0
  87. package/src/tools/session.ts +3 -0
  88. package/src/tools.ts +8 -0
  89. package/src/ui/jev-filter-submenu.ts +21 -0
  90. package/src/ui/jev-provider-submenu-view.ts +22 -0
  91. package/src/ui/jev-provider-submenu.ts +81 -0
  92. package/src/ui/jev-setup-support.ts +26 -0
  93. package/src/ui/manual-dialog-render.ts +20 -0
  94. package/src/ui/manual-dialog.ts +38 -0
  95. package/src/ui/masked-input.ts +2 -0
  96. package/src/ui/searchable-model-list.ts +28 -0
  97. package/src/ui/settings-formatting.ts +26 -0
  98. package/src/ui/settings-items.ts +11 -0
  99. package/src/ui/settings-list-adapter.ts +13 -0
  100. package/src/ui/settings-mutations.ts +60 -0
  101. package/src/ui/settings-selector.ts +30 -0
  102. package/src/ui/text-setting-submenu.ts +9 -0
  103. package/src/ui-guard.ts +1 -0
  104. package/src/ui.ts +3 -0
  105. package/src/usage.ts +31 -0
@@ -72,21 +72,29 @@ export class JevProviderSubmenu implements Component, Focusable {
72
72
  if (this.mode === "key-entry") {
73
73
  this.maskedInput.handleInput(keyData);
74
74
  this.options.tui.requestRender();
75
+
75
76
  return;
76
77
  }
78
+
77
79
  if (this.mode === "base-url" || this.mode === "provider-id") {
78
80
  const before = this.textInput.getValue();
79
81
  this.textInput.handleInput(keyData);
82
+
80
83
  if (this.inputError && this.textInput.getValue() !== before) {
81
84
  this.inputError = undefined;
82
85
  }
86
+
83
87
  this.options.tui.requestRender();
88
+
84
89
  return;
85
90
  }
91
+
86
92
  if (this.mode !== "menu") {
87
93
  return;
88
94
  }
95
+
89
96
  const actions = setupActions(this.viewState());
97
+
90
98
  if (
91
99
  matchesKey(keyData, Key.down) ||
92
100
  keyData === "\u001B[B" ||
@@ -105,11 +113,13 @@ export class JevProviderSubmenu implements Component, Focusable {
105
113
  } else {
106
114
  return;
107
115
  }
116
+
108
117
  this.options.tui.requestRender();
109
118
  }
110
119
 
111
120
  render(width: number): string[] {
112
121
  const input = this.mode === "key-entry" ? this.maskedInput : this.textInput;
122
+
113
123
  return renderJevProvider(this.options, this.viewState(), input, width);
114
124
  }
115
125
 
@@ -139,22 +149,28 @@ export class JevProviderSubmenu implements Component, Focusable {
139
149
  private async refresh(): Promise<void> {
140
150
  this.mode = "resolving";
141
151
  this.options.tui.requestRender();
152
+
142
153
  try {
143
154
  const credentials = await this.deps.resolveTransport(
144
155
  this.options.currentTransport === "auto"
145
156
  ? undefined
146
157
  : this.options.currentTransport
147
158
  );
159
+
148
160
  this.credentials = credentials;
149
161
  this.selectedTransport = credentials?.transport;
162
+
150
163
  if (credentials?.transport === "typesafe-compatible") {
151
164
  this.baseUrl = credentials.baseUrl ?? this.baseUrl;
152
165
  }
166
+
153
167
  this.mode = "menu";
154
168
  this.selectedIndex = 0;
169
+
155
170
  if (credentials?.source === "advisor-json") {
156
171
  this.notice = consumeSetupPlaintextWarning();
157
172
  }
173
+
158
174
  this.options.tui.requestRender();
159
175
  } catch (error) {
160
176
  this.reportBackgroundError(
@@ -179,29 +195,40 @@ export class JevProviderSubmenu implements Component, Focusable {
179
195
  private activate(action: JevProviderAction): void {
180
196
  if (action === "done") {
181
197
  this.closeSetup();
198
+
182
199
  return;
183
200
  }
201
+
184
202
  if (action === "clear-stored-key") {
185
203
  void fireAndForget(this.clearStoredKey(), this.reportBackgroundError);
204
+
186
205
  return;
187
206
  }
207
+
188
208
  if (action === "enter-key") {
189
209
  if (this.selectedTransport) {
190
210
  this.openKeyEntry(this.selectedTransport);
191
211
  }
212
+
192
213
  return;
193
214
  }
215
+
194
216
  if (action === "reuse-provider-login") {
195
217
  this.openProviderIdEntry();
218
+
196
219
  return;
197
220
  }
221
+
198
222
  if (action === "typesafe-compatible") {
199
223
  this.openBaseUrlEntry();
224
+
200
225
  return;
201
226
  }
227
+
202
228
  if (this.mode !== "menu") {
203
229
  return;
204
230
  }
231
+
205
232
  void fireAndForget(this.selectProvider(action), this.reportBackgroundError);
206
233
  }
207
234
 
@@ -235,8 +262,10 @@ export class JevProviderSubmenu implements Component, Focusable {
235
262
  private submitText(value: string): void {
236
263
  if (this.mode === "base-url") {
237
264
  void fireAndForget(this.submitBaseUrl(value), this.reportBackgroundError);
265
+
238
266
  return;
239
267
  }
268
+
240
269
  if (this.mode === "provider-id") {
241
270
  void fireAndForget(
242
271
  this.submitProviderId(value),
@@ -247,55 +276,72 @@ export class JevProviderSubmenu implements Component, Focusable {
247
276
 
248
277
  private async submitBaseUrl(value: string): Promise<void> {
249
278
  const { baseUrl, error } = normalizeJevBaseUrl(value);
279
+
250
280
  if (!baseUrl) {
251
281
  this.inputError = error;
252
282
  this.options.tui.requestRender();
283
+
253
284
  return;
254
285
  }
286
+
255
287
  this.baseUrl = baseUrl;
256
288
  this.selectedTransport = "typesafe-compatible";
257
289
  this.mode = "resolving";
258
290
  this.inputError = undefined;
259
291
  this.options.tui.requestRender();
292
+
260
293
  const options = this.providerId
261
294
  ? { baseUrl, keyProvider: this.providerId }
262
295
  : { baseUrl };
296
+
263
297
  const credentials = await this.deps.resolveEndpoint(options);
298
+
264
299
  if (!credentials) {
265
300
  this.openKeyEntry("typesafe-compatible");
301
+
266
302
  return;
267
303
  }
304
+
268
305
  await this.verifyAndSave(credentials);
269
306
  }
270
307
 
271
308
  private async submitProviderId(value: string): Promise<void> {
272
309
  const providerId = value.trim();
310
+
273
311
  if (!providerId || /\s/u.test(providerId)) {
274
312
  this.inputError =
275
313
  "Enter a single Pi provider id, for example openrouter.";
276
314
  this.options.tui.requestRender();
315
+
277
316
  return;
278
317
  }
318
+
279
319
  if (!this.baseUrl) {
280
320
  this.inputError = "Enter the Base URL first.";
281
321
  this.options.tui.requestRender();
322
+
282
323
  return;
283
324
  }
325
+
284
326
  this.providerId = providerId;
285
327
  this.selectedTransport = "typesafe-compatible";
286
328
  this.mode = "resolving";
287
329
  this.inputError = undefined;
288
330
  this.options.tui.requestRender();
331
+
289
332
  const credentials = await this.deps.resolveEndpoint({
290
333
  baseUrl: this.baseUrl,
291
334
  keyProvider: providerId,
292
335
  });
336
+
293
337
  if (!credentials) {
294
338
  this.mode = "menu";
295
339
  this.notice = `No stored login for Pi provider "${providerId}". Add one in Pi and retry.`;
296
340
  this.options.tui.requestRender();
341
+
297
342
  return;
298
343
  }
344
+
299
345
  await this.verifyAndSave(credentials);
300
346
  }
301
347
 
@@ -306,16 +352,20 @@ export class JevProviderSubmenu implements Component, Focusable {
306
352
  this.canEnterKey = false;
307
353
  this.options.tui.requestRender();
308
354
  let credentials: JevCredentials | undefined;
355
+
309
356
  try {
310
357
  credentials = await this.deps.resolveTransport(transport);
311
358
  } catch (error) {
312
359
  this.mode = "menu";
313
360
  this.notice = `Credential lookup failed: ${error instanceof Error ? error.message : String(error)}`;
314
361
  this.options.tui.requestRender();
362
+
315
363
  return;
316
364
  }
365
+
317
366
  this.credentials = credentials;
318
367
  this.mode = "menu";
368
+
319
369
  if (!credentials) {
320
370
  if (transport === "typesafe" || transport === "openai-decisions") {
321
371
  this.notice = undefined;
@@ -323,15 +373,20 @@ export class JevProviderSubmenu implements Component, Focusable {
323
373
  } else {
324
374
  this.notice = "No OpenRouter Pi login found. Add one in Pi and retry.";
325
375
  }
376
+
326
377
  this.options.tui.requestRender();
378
+
327
379
  return;
328
380
  }
381
+
329
382
  if (credentials.transport !== transport) {
330
383
  this.notice =
331
384
  "The selected provider did not resolve matching credentials.";
332
385
  this.options.tui.requestRender();
386
+
333
387
  return;
334
388
  }
389
+
335
390
  await this.verifyAndSave(credentials);
336
391
  }
337
392
 
@@ -339,13 +394,17 @@ export class JevProviderSubmenu implements Component, Focusable {
339
394
  const transport = this.selectedTransport;
340
395
  const key = value.trim();
341
396
  this.maskedInput.setValue("");
397
+
342
398
  if (!transport || !key) {
343
399
  return;
344
400
  }
401
+
345
402
  const credentials: JevCredentials = { apiKey: key, transport };
403
+
346
404
  if (transport === "typesafe-compatible" && this.baseUrl) {
347
405
  credentials.baseUrl = this.baseUrl;
348
406
  }
407
+
349
408
  await this.verifyAndSave(credentials, key);
350
409
  }
351
410
 
@@ -357,36 +416,47 @@ export class JevProviderSubmenu implements Component, Focusable {
357
416
  this.notice = undefined;
358
417
  this.options.tui.requestRender();
359
418
  const outcome = await this.deps.verify(credentials);
419
+
360
420
  if (!outcome.ok) {
361
421
  this.notice = `Verification failed: ${outcome.message ?? "unknown error"}`;
362
422
  this.mode = enteredKey ? "key-entry" : "menu";
363
423
  this.canEnterKey = !enteredKey && canReplaceWithEnteredKey(credentials);
364
424
  this.options.tui.requestRender();
425
+
365
426
  return;
366
427
  }
428
+
367
429
  if (enteredKey) {
368
430
  const stored = await this.deps.writeKey(
369
431
  enteredKey,
370
432
  credentials.transport
371
433
  );
434
+
372
435
  if (!stored.ok) {
373
436
  this.notice = stored.message;
374
437
  this.mode = "key-entry";
375
438
  this.canEnterKey = false;
376
439
  this.options.tui.requestRender();
440
+
377
441
  return;
378
442
  }
443
+
379
444
  this.notice = `${stored.message} Verification succeeded.`;
445
+
380
446
  // An entered key is the more explicit choice, so it clears a reused login.
381
447
  if (credentials.transport === "typesafe-compatible") {
382
448
  this.providerId = undefined;
383
449
  }
384
450
  }
451
+
385
452
  this.credentials = credentials;
453
+
386
454
  if (this.commitSelection(credentials)) {
387
455
  this.closeSetup(true);
456
+
388
457
  return;
389
458
  }
459
+
390
460
  this.mode = "menu";
391
461
  this.canEnterKey = false;
392
462
  this.notice = "Provider verified, but settings could not be saved.";
@@ -397,6 +467,7 @@ export class JevProviderSubmenu implements Component, Focusable {
397
467
  if (!this.options.onSelection) {
398
468
  return false;
399
469
  }
470
+
400
471
  return this.options.onSelection(this.selectionFor(credentials));
401
472
  }
402
473
 
@@ -404,41 +475,51 @@ export class JevProviderSubmenu implements Component, Focusable {
404
475
  if (credentials.transport !== "typesafe-compatible") {
405
476
  return { transport: credentials.transport };
406
477
  }
478
+
407
479
  const selection: JevProviderSelection = {
408
480
  transport: credentials.transport,
409
481
  };
482
+
410
483
  if (this.baseUrl) {
411
484
  selection.baseUrl = this.baseUrl;
412
485
  }
486
+
413
487
  if (this.providerId) {
414
488
  selection.keyProvider = this.providerId;
415
489
  }
490
+
416
491
  return selection;
417
492
  }
418
493
 
419
494
  private async clearStoredKey(): Promise<void> {
420
495
  const { credentials } = this;
496
+
421
497
  if (!(credentials && credentials.source)) {
422
498
  return;
423
499
  }
500
+
424
501
  this.mode = "clearing";
425
502
  this.notice = undefined;
426
503
  this.options.tui.requestRender();
427
504
  const result = await this.deps.clearStoredKey(credentials.transport);
428
505
  this.mode = "menu";
429
506
  this.notice = result.message;
507
+
430
508
  if (result.ok) {
431
509
  this.credentials = undefined;
432
510
  this.pendingSelectionRefresh = true;
433
511
  }
512
+
434
513
  this.options.tui.requestRender();
435
514
  }
436
515
 
437
516
  private closeSetup(refreshSettings = false): void {
438
517
  this.options.done();
518
+
439
519
  if (refreshSettings || this.pendingSelectionRefresh) {
440
520
  this.options.afterSelection?.();
441
521
  }
522
+
442
523
  this.pendingSelectionRefresh = false;
443
524
  }
444
525
  }
@@ -88,12 +88,15 @@ export const providerName = (transport: JevTransportKind): string => {
88
88
  if (transport === "typesafe") {
89
89
  return "TypeSafe Jev";
90
90
  }
91
+
91
92
  if (transport === "openrouter") {
92
93
  return "OpenRouter (Pi login)";
93
94
  }
95
+
94
96
  if (transport === "typesafe-compatible") {
95
97
  return "System One–compatible endpoint";
96
98
  }
99
+
97
100
  return `OpenAI Decisions (${OPENAI_DECISIONS_MODEL})`;
98
101
  };
99
102
 
@@ -102,12 +105,15 @@ const endpointSourceLabel = (source: JevCredentials["source"]): string => {
102
105
  case "provider-credential": {
103
106
  return "Pi provider login";
104
107
  }
108
+
105
109
  case "jev-bun-secrets": {
106
110
  return "Bun.secrets";
107
111
  }
112
+
108
113
  case "jev-file": {
109
114
  return "stored file, mode 0600";
110
115
  }
116
+
111
117
  default: {
112
118
  return "JEV_API_KEY";
113
119
  }
@@ -118,44 +124,56 @@ export const transportLabel = (credentials: JevCredentials): string => {
118
124
  if (credentials.transport === "openrouter") {
119
125
  return "OpenRouter (reusing Pi login)";
120
126
  }
127
+
121
128
  if (credentials.transport === "typesafe-compatible") {
122
129
  return `System One–compatible (${credentials.baseUrl ?? "no Base URL"}; key: ${endpointSourceLabel(credentials.source)})`;
123
130
  }
131
+
124
132
  if (credentials.transport === "openai-decisions") {
125
133
  let source = "verified API key";
134
+
126
135
  switch (credentials.source) {
127
136
  case "openai-bun-secrets": {
128
137
  source = "Bun.secrets";
129
138
  break;
130
139
  }
140
+
131
141
  case "openai-env": {
132
142
  source = "OPENAI_API_KEY";
133
143
  break;
134
144
  }
145
+
135
146
  case "openai-file": {
136
147
  source = "stored file, mode 0600";
137
148
  break;
138
149
  }
150
+
139
151
  case "openai-provider-credential": {
140
152
  source = "Pi stored API key";
141
153
  break;
142
154
  }
155
+
143
156
  default: {
144
157
  break;
145
158
  }
146
159
  }
160
+
147
161
  return `OpenAI Decisions (${OPENAI_DECISIONS_MODEL}; key: ${source})`;
148
162
  }
163
+
149
164
  switch (credentials.source) {
150
165
  case "advisor-json": {
151
166
  return "TypeSafe (key: advisor.json — plaintext, not recommended)";
152
167
  }
168
+
153
169
  case "bun-secrets": {
154
170
  return "TypeSafe (key: Bun.secrets)";
155
171
  }
172
+
156
173
  case "file": {
157
174
  return "TypeSafe (key: stored file, mode 0600)";
158
175
  }
176
+
159
177
  default: {
160
178
  return "TypeSafe (key: TYPESAFE_API_KEY)";
161
179
  }
@@ -181,19 +199,23 @@ export const keyEntryPrompt = (transport: JevTransportKind): string => {
181
199
  if (transport === "openai-decisions") {
182
200
  return "Paste an OpenAI Platform API key";
183
201
  }
202
+
184
203
  if (transport === "typesafe-compatible") {
185
204
  return "Paste the endpoint API key";
186
205
  }
206
+
187
207
  return "Paste a TypeSafe API key";
188
208
  };
189
209
 
190
210
  export const defaultVerify = async (credentials: JevCredentials) => {
191
211
  const client = jevClientFromCredentials(credentials);
212
+
192
213
  try {
193
214
  await client.ask(
194
215
  { purpose: "pi-advisor setup verification" },
195
216
  { verified: noul("Answer yes.") }
196
217
  );
218
+
197
219
  return { ok: true };
198
220
  } catch (error) {
199
221
  return {
@@ -207,9 +229,11 @@ const writeKeyFor = (key: string, transport: JevTransportKind) => {
207
229
  if (transport === "openai-decisions") {
208
230
  return writeOpenAIDecisionsKey(key);
209
231
  }
232
+
210
233
  if (transport === "typesafe-compatible") {
211
234
  return writeJevEndpointKey(key);
212
235
  }
236
+
213
237
  return writeKeyTypeSafeKey(key);
214
238
  };
215
239
 
@@ -217,9 +241,11 @@ const clearKeyFor = (transport: JevTransportKind) => {
217
241
  if (transport === "openai-decisions") {
218
242
  return clearOpenAIDecisionsKey();
219
243
  }
244
+
220
245
  if (transport === "typesafe-compatible") {
221
246
  return clearJevEndpointKey();
222
247
  }
248
+
223
249
  return clearKeyTypeSafeKey();
224
250
  };
225
251
 
@@ -30,17 +30,21 @@ export const renderManualAdvisorDialog = (
30
30
  renderWidth,
31
31
  theme,
32
32
  } = view;
33
+
33
34
  const innerWidth = Math.max(0, renderWidth - 2);
34
35
  const contentWidth = Math.max(0, innerWidth - horizontalPadding * 2);
35
36
  const lines: string[] = [];
36
37
 
37
38
  const focusMarker = (target: ManualAdvisorDialogView["focusTarget"]) =>
38
39
  focusTarget === target ? theme.fg("accent", "▸ ") : " ";
40
+
39
41
  const addLine = (text: string) => {
40
42
  if (renderWidth < 2) {
41
43
  lines.push(truncateToWidth(text, renderWidth, ""));
44
+
42
45
  return;
43
46
  }
47
+
44
48
  lines.push(
45
49
  `${theme.fg("border", "│")}${" ".repeat(
46
50
  horizontalPadding
@@ -49,12 +53,14 @@ export const renderManualAdvisorDialog = (
49
53
  )}${theme.fg("border", "│")}`
50
54
  );
51
55
  };
56
+
52
57
  const addWrapped = (
53
58
  text: string,
54
59
  color: "accent" | "text" | "muted" | "dim" = "text"
55
60
  ) => {
56
61
  const content = theme.fg(color, text);
57
62
  const wrapped = wrapTextWithAnsi(content, Math.max(1, contentWidth - 2));
63
+
58
64
  for (const line of wrapped.length > 0 ? wrapped : [""]) {
59
65
  addLine(` ${line}`);
60
66
  }
@@ -67,6 +73,7 @@ export const renderManualAdvisorDialog = (
67
73
  "",
68
74
  false
69
75
  );
76
+
70
77
  const titleWidth = visibleWidth(title);
71
78
  const remaining = Math.max(0, innerWidth - titleWidth);
72
79
  const left = Math.floor(remaining / 2);
@@ -82,9 +89,11 @@ export const renderManualAdvisorDialog = (
82
89
  addLine(
83
90
  `${focusMarker("editor")}${theme.bold("Message for Advisor (optional)")}`
84
91
  );
92
+
85
93
  for (const editorLine of editorLines) {
86
94
  addLine(editorLine);
87
95
  }
96
+
88
97
  addLine("");
89
98
  addWrapped(
90
99
  "Automatic context follows your settings: conversation history, tool disclosure, project preferences, redaction, and configured limits remain unchanged.",
@@ -105,6 +114,7 @@ export const renderManualAdvisorDialog = (
105
114
  `Git repository context (max: ${gitCeiling}; ↑/↓ or Space to choose)`
106
115
  )}`
107
116
  );
117
+
108
118
  for (let index = 0; index < gitLevels.length; index += 1) {
109
119
  const level = gitLevels[index];
110
120
  const copy = MANUAL_GIT_CONTEXT_COPY[level];
@@ -117,10 +127,12 @@ export const renderManualAdvisorDialog = (
117
127
  color
118
128
  );
119
129
  }
130
+
120
131
  addLine("");
121
132
 
122
133
  let interactionHint =
123
134
  "Enter submit · Shift+Enter newline · Tab/Shift+Tab focus · Esc cancel";
135
+
124
136
  if (focusTarget === "git") {
125
137
  interactionHint =
126
138
  "↑/↓ or Space choose · Enter next · Tab/Shift+Tab focus · Esc cancel";
@@ -128,21 +140,28 @@ export const renderManualAdvisorDialog = (
128
140
  interactionHint =
129
141
  "←/→ choose · Enter/Space activate · Tab/Shift+Tab focus · Esc cancel";
130
142
  }
143
+
131
144
  const submit = focusTarget === "actions" && actionIndex === 0;
145
+
132
146
  const submitLabel = submit
133
147
  ? theme.fg("accent", "[Submit]")
134
148
  : theme.fg("text", "[Submit]");
149
+
135
150
  const cancel = focusTarget === "actions" && actionIndex === 1;
151
+
136
152
  const cancelLabel = cancel
137
153
  ? theme.fg("accent", "[Cancel]")
138
154
  : theme.fg("text", "[Cancel]");
155
+
139
156
  const actionButtons = `${submitLabel} ${cancelLabel}`;
157
+
140
158
  // Center the buttons in the content area; the 2-column focus marker sits
141
159
  // left of the computed offset.
142
160
  const buttonOffset = Math.max(
143
161
  0,
144
162
  Math.floor((contentWidth - visibleWidth(actionButtons)) / 2) - 2
145
163
  );
164
+
146
165
  addLine(
147
166
  `${focusMarker("actions")}${" ".repeat(buttonOffset)}${actionButtons}`
148
167
  );
@@ -154,5 +173,6 @@ export const renderManualAdvisorDialog = (
154
173
  theme.fg("border", `╰${"─".repeat(Math.max(0, renderWidth - 2))}╯`)
155
174
  );
156
175
  }
176
+
157
177
  return lines.map((line) => truncateToWidth(line, renderWidth, ""));
158
178
  };