@causyne/agent 1.18.0 → 1.20.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 (76) hide show
  1. package/package.json +1 -1
  2. package/src/agentLoop.js +2348 -2531
  3. package/src/agentLoop.ts +2865 -0
  4. package/src/checkpoints.d.ts +4 -0
  5. package/src/cliMode.js +30 -17
  6. package/src/commands.js +307 -57
  7. package/src/config.js +22 -0
  8. package/src/contextManager.d.ts +10 -0
  9. package/src/continuum/adapters/antigravity.js +193 -0
  10. package/src/continuum/adapters/antigravity.ts +204 -0
  11. package/src/continuum/adapters/base.js +48 -0
  12. package/src/continuum/adapters/base.ts +57 -0
  13. package/src/continuum/adapters/causyne.js +66 -0
  14. package/src/continuum/adapters/causyne.ts +72 -0
  15. package/src/continuum/adapters/claudeCode.js +171 -0
  16. package/src/continuum/adapters/claudeCode.ts +179 -0
  17. package/src/continuum/adapters/codex.js +181 -0
  18. package/src/continuum/adapters/codex.ts +193 -0
  19. package/src/continuum/adapters/opencode.js +134 -0
  20. package/src/continuum/adapters/opencode.ts +153 -0
  21. package/src/continuum/compactor.js +54 -0
  22. package/src/continuum/compactor.ts +83 -0
  23. package/src/continuum/index.js +8 -0
  24. package/src/continuum/index.ts +9 -0
  25. package/src/continuum/ingest.js +63 -0
  26. package/src/continuum/ingest.ts +89 -0
  27. package/src/continuum/sanitizer.js +55 -0
  28. package/src/continuum/sanitizer.ts +59 -0
  29. package/src/continuum/scanner.js +86 -0
  30. package/src/continuum/scanner.ts +106 -0
  31. package/src/continuum/types.js +3 -0
  32. package/src/continuum/types.ts +51 -0
  33. package/src/continuum/ui/continuumPicker.js +111 -0
  34. package/src/continuum/ui/continuumPicker.ts +145 -0
  35. package/src/cortex/autoCondenser.d.ts +2 -0
  36. package/src/cortex/vectorDb.d.ts +1 -0
  37. package/src/designPalettes.d.ts +2 -0
  38. package/src/devMode.d.ts +1 -0
  39. package/src/dynamicCatalogue.js +5 -3
  40. package/src/dynamicCatalogue.ts +7 -4
  41. package/src/embodimentSession.d.ts +2 -0
  42. package/src/entrypoint.js +12 -0
  43. package/src/memory.d.ts +1 -0
  44. package/src/memoryManager.d.ts +1 -0
  45. package/src/memoryManager.js +10 -6
  46. package/src/modelIds.d.ts +2 -0
  47. package/src/outputStore.d.ts +4 -0
  48. package/src/providers/acp.js +320 -299
  49. package/src/providers/acp.ts +360 -0
  50. package/src/providers/antigravity.js +387 -278
  51. package/src/providers/antigravity.ts +450 -0
  52. package/src/providers/base.d.ts +68 -0
  53. package/src/providers/factory.d.ts +1 -0
  54. package/src/provisioning/capabilityProvisioner.d.ts +2 -0
  55. package/src/sandbox.d.ts +1 -0
  56. package/src/sessionJournal.js +14 -1
  57. package/src/sessionJournal.ts +21 -1
  58. package/src/skillsManager.d.ts +3 -0
  59. package/src/slopDetector.d.ts +3 -0
  60. package/src/taskBuffer.d.ts +1 -0
  61. package/src/tokenTracker.d.ts +1 -0
  62. package/src/toolPacks.d.ts +8 -0
  63. package/src/tools/registry.d.ts +4 -0
  64. package/src/tui/chatRenderer.js +148 -8
  65. package/src/tui/clipboardSync.js +36 -0
  66. package/src/tui/clipboardSync.ts +36 -0
  67. package/src/tui/dialogs.js +15 -2
  68. package/src/tui/home.js +2 -1
  69. package/src/tui/modelPicker.js +254 -0
  70. package/src/tui/modelPicker.ts +318 -0
  71. package/src/tui/prompt.js +90 -8
  72. package/src/tui/selectList.js +20 -0
  73. package/src/tui/sessionPicker.js +185 -0
  74. package/src/tui/sessionPicker.ts +259 -0
  75. package/src/tui/stageSurface.js +9 -0
  76. package/src/tui/statusLine.js +5 -5
@@ -0,0 +1,318 @@
1
+ // Sovereign Interactive Model Picker — modal dialog for ACP & BYOK models.
2
+ //
3
+ // Pure Node over ./dialogs.js, ../dynamicCatalogue.js, and ../config.js.
4
+ // No shell, zero malware, source-available under BUSL-1.1.
5
+
6
+ // @ts-expect-error untyped local TUI dialogs
7
+ import { SelectLayer, InputLayer } from './dialogs.js';
8
+ import { loadConfig, saveConfig } from '../config.js';
9
+ import { getAvailableProvidersOverview, type ProviderOverview } from '../dynamicCatalogue.js';
10
+
11
+ export interface ModelPickerItemValue {
12
+ type: 'acp' | 'byok';
13
+ providerId: string;
14
+ modelId: string;
15
+ providerLabel: string;
16
+ installed: boolean;
17
+ isCurrent: boolean;
18
+ isConfigured: boolean;
19
+ envVar?: string | undefined;
20
+ setupInstruction?: string | undefined;
21
+ }
22
+
23
+ export interface ModelPickerItem {
24
+ id: string;
25
+ label: string;
26
+ category: string;
27
+ description: string;
28
+ value: ModelPickerItemValue;
29
+ }
30
+
31
+ export interface ConfigStore {
32
+ loadConfig(): Record<string, any>;
33
+ saveConfig(config: Record<string, any>): void;
34
+ }
35
+
36
+ export interface PromptHost {
37
+ openLayer(layer: unknown): void;
38
+ }
39
+
40
+ export interface InteractiveModelPickerOptions {
41
+ loop?: {
42
+ config?: Record<string, any>;
43
+ updateTierLimits?: () => void;
44
+ initializeProvider?: () => any;
45
+ llm?: any;
46
+ _utilityLlm?: any;
47
+ } | undefined;
48
+ }
49
+
50
+ async function showConfiguringAnimation(providerLabel: string): Promise<void> {
51
+ if (!process.stdout.isTTY) return;
52
+ const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
53
+ const text = `Configuring ${providerLabel} in secure local vault…`;
54
+ for (let i = 0; i < 5; i++) {
55
+ const f = frames[i % frames.length];
56
+ process.stdout.write(`\r \x1b[36m${f}\x1b[0m ${text}`);
57
+ await new Promise(r => setTimeout(r, 60));
58
+ }
59
+ process.stdout.write(`\r\x1b[K \x1b[32m✓\x1b[0m ${providerLabel} credentials saved.\n`);
60
+ }
61
+
62
+ /**
63
+ * Build items for SelectLayer categorized by ACP peers and BYOK providers.
64
+ */
65
+ export function buildModelPickerItems(
66
+ config: { provider?: string; model?: string; apiKey?: string; providerKeys?: Record<string, string> },
67
+ overview: ProviderOverview
68
+ ): ModelPickerItem[] {
69
+ const items: ModelPickerItem[] = [];
70
+ const activeProvider = config.provider || '';
71
+ const activeModel = config.model || '';
72
+
73
+ // 1. ACP Peer Agents & Sovereign Local Engines
74
+ for (const peer of overview.acp) {
75
+ const isCurrentProvider = activeProvider === peer.providerKey;
76
+ const catTitle = peer.installed
77
+ ? `ACP · ${peer.label} (ready)`
78
+ : `ACP · ${peer.label} (not installed)`;
79
+
80
+ if (peer.installed && Array.isArray(peer.models) && peer.models.length > 0) {
81
+ for (const m of peer.models) {
82
+ const isCurrent = isCurrentProvider && activeModel === m;
83
+ items.push({
84
+ id: `${peer.providerKey}/${m}`,
85
+ label: m,
86
+ category: catTitle,
87
+ description: isCurrent ? '● active' : 'ready',
88
+ value: {
89
+ type: 'acp',
90
+ providerId: peer.providerKey,
91
+ modelId: m,
92
+ providerLabel: peer.label,
93
+ installed: true,
94
+ isCurrent,
95
+ isConfigured: true,
96
+ setupInstruction: peer.setupInstruction
97
+ }
98
+ });
99
+ }
100
+ } else {
101
+ // Uninstalled ACP agent: show entry so user can see it's supported
102
+ items.push({
103
+ id: `${peer.providerKey}:uninstalled`,
104
+ label: peer.label,
105
+ category: catTitle,
106
+ description: 'not installed — setup needed',
107
+ value: {
108
+ type: 'acp',
109
+ providerId: peer.providerKey,
110
+ modelId: peer.models[0] || peer.id,
111
+ providerLabel: peer.label,
112
+ installed: false,
113
+ isCurrent: false,
114
+ isConfigured: false,
115
+ setupInstruction: peer.setupInstruction
116
+ }
117
+ });
118
+ }
119
+ }
120
+
121
+ // 2. BYOK Providers (Cloud & Local APIs)
122
+ for (const p of overview.byok) {
123
+ const isCurrentProvider = activeProvider === p.id || (p.id === 'qwen' && activeProvider === 'dashscope-byok');
124
+ const catTitle = p.id === 'ollama'
125
+ ? `BYOK · ${p.label}`
126
+ : `BYOK · ${p.label} ${p.isConfigured ? '(configured)' : '(needs key)'}`;
127
+
128
+ const models = Array.isArray(p.models) && p.models.length > 0 ? p.models : [p.defaultModel];
129
+ for (const m of models) {
130
+ const isCurrent = isCurrentProvider && activeModel === m;
131
+ const desc = isCurrent ? '● active' : (p.id === 'ollama' ? 'local' : (p.isConfigured ? 'configured' : 'needs API key'));
132
+ items.push({
133
+ id: `${p.id}/${m}`,
134
+ label: m,
135
+ category: catTitle,
136
+ description: desc,
137
+ value: {
138
+ type: 'byok',
139
+ providerId: p.id,
140
+ modelId: m,
141
+ providerLabel: p.label,
142
+ installed: true,
143
+ isCurrent,
144
+ isConfigured: p.isConfigured,
145
+ envVar: p.envVar
146
+ }
147
+ });
148
+ }
149
+ }
150
+
151
+ return items;
152
+ }
153
+
154
+ /**
155
+ * Run interactive model picker in the provided TUI prompt.
156
+ *
157
+ * Automatically handles:
158
+ * - Direct selection of ACP models without prompting for an API key.
159
+ * - Direct selection of configured BYOK models without prompting for an API key.
160
+ * - InputLayer modal prompt for API key when selecting an unconfigured BYOK model,
161
+ * safely encrypting it into ~/.causyne/config.json.
162
+ * - Synchronous runtime loop re-initialization so the live session switches immediately.
163
+ */
164
+ export async function runInteractiveModelPicker(
165
+ prompt: PromptHost,
166
+ store: ConfigStore = { loadConfig, saveConfig },
167
+ options: InteractiveModelPickerOptions = {}
168
+ ): Promise<string> {
169
+ if (!prompt || typeof prompt.openLayer !== 'function') {
170
+ return 'Run causyne in an interactive terminal to use the model picker.';
171
+ }
172
+
173
+ const config = store.loadConfig();
174
+ const overview = getAvailableProvidersOverview(config);
175
+ const items = buildModelPickerItems(config, overview);
176
+
177
+ const picked = await new Promise<ModelPickerItem | null>((resolve) => {
178
+ const layer = new SelectLayer({
179
+ title: 'Select Model',
180
+ placeholder: 'type to filter (e.g. gemini, sonnet, opencode)…',
181
+ emptyText: 'No models matched your search',
182
+ items,
183
+ width: 76,
184
+ height: 20,
185
+ onPick: resolve
186
+ });
187
+ prompt.openLayer(layer);
188
+ });
189
+
190
+ const notifyPromptAndClean = (providerId: string, modelId: string) => {
191
+ if (typeof (prompt as any).updateModel === 'function') {
192
+ (prompt as any).updateModel(providerId, modelId);
193
+ } else if ((prompt as any).renderer?.status) {
194
+ (prompt as any).renderer.status.setSession({ provider: providerId, model: modelId });
195
+ if (typeof (prompt as any).scheduleDraw === 'function') (prompt as any).scheduleDraw();
196
+ }
197
+ if ((prompt as any).editor && typeof (prompt as any).editor.clear === 'function') {
198
+ (prompt as any).editor.clear();
199
+ if (typeof (prompt as any).scheduleDraw === 'function') (prompt as any).scheduleDraw();
200
+ }
201
+ };
202
+
203
+ if (!picked || !picked.value) {
204
+ if ((prompt as any).editor && typeof (prompt as any).editor.clear === 'function') {
205
+ (prompt as any).editor.clear();
206
+ if (typeof (prompt as any).scheduleDraw === 'function') (prompt as any).scheduleDraw();
207
+ }
208
+ return 'Cancelled. Model was not changed.';
209
+ }
210
+
211
+ const target = picked.value;
212
+
213
+ // Case 1: ACP Peer Agent or Antigravity
214
+ if (target.type === 'acp') {
215
+ if (!target.installed) {
216
+ if ((prompt as any).editor && typeof (prompt as any).editor.clear === 'function') {
217
+ (prompt as any).editor.clear();
218
+ if (typeof (prompt as any).scheduleDraw === 'function') (prompt as any).scheduleDraw();
219
+ }
220
+ return (
221
+ `⚠️ Notice: "${target.providerLabel}" is not installed on this machine.\n` +
222
+ `Setup: ${target.setupInstruction || 'Install the CLI binary.'}\n\n` +
223
+ `Model was not changed.`
224
+ );
225
+ }
226
+
227
+ config['provider'] = target.providerId;
228
+ config['model'] = target.modelId;
229
+ config['apiKey'] = '';
230
+ delete config['baseUrl'];
231
+ store.saveConfig(config);
232
+
233
+ if (options.loop) {
234
+ options.loop.config = config;
235
+ if (typeof options.loop.updateTierLimits === 'function') {
236
+ options.loop.updateTierLimits();
237
+ }
238
+ }
239
+ notifyPromptAndClean(target.providerId, target.modelId);
240
+ return `Now using ${target.providerLabel} / ${target.modelId}.`;
241
+ }
242
+
243
+ // Case 2: BYOK Provider (Cloud or Local API)
244
+ let existingKey = '';
245
+ const providerKeys: Record<string, string> = (config['providerKeys'] && typeof config['providerKeys'] === 'object') ? config['providerKeys'] : {};
246
+ if (config['provider'] === target.providerId && typeof config['apiKey'] === 'string' && config['apiKey']) {
247
+ existingKey = config['apiKey'];
248
+ } else if (providerKeys[target.providerId] || (target.providerId === 'qwen' && providerKeys['dashscope-byok'])) {
249
+ existingKey = providerKeys[target.providerId] || providerKeys['dashscope-byok'] || '';
250
+ } else if (target.envVar && process.env[target.envVar]) {
251
+ existingKey = process.env[target.envVar] || '';
252
+ }
253
+
254
+ // If provider is Ollama (needs no key) or key is already present
255
+ if (target.providerId === 'ollama' || existingKey) {
256
+ config['provider'] = target.providerId;
257
+ config['model'] = target.modelId;
258
+ if (existingKey) {
259
+ config['apiKey'] = existingKey;
260
+ config['providerKeys'] = providerKeys;
261
+ config['providerKeys'][target.providerId] = existingKey;
262
+ }
263
+ store.saveConfig(config);
264
+
265
+ if (options.loop) {
266
+ options.loop.config = config;
267
+ if (typeof options.loop.updateTierLimits === 'function') {
268
+ options.loop.updateTierLimits();
269
+ }
270
+ }
271
+ notifyPromptAndClean(target.providerId, target.modelId);
272
+ return `Now using ${target.providerLabel} / ${target.modelId}.`;
273
+ }
274
+
275
+ // Key is required: open modal input dialog (InputLayer)
276
+ const enteredKey = await new Promise<string | null>((resolve) => {
277
+ const layer = new InputLayer({
278
+ title: `Set API Key · ${target.providerLabel}`,
279
+ lines: [
280
+ `Enter your ${target.providerLabel} API key to use ${target.modelId}.`,
281
+ 'Stored encrypted in your local vault (~/.causyne/config.json).'
282
+ ],
283
+ mask: true,
284
+ placeholder: 'paste API key (Esc to cancel)',
285
+ onSubmit: resolve,
286
+ onCancel: () => resolve(null)
287
+ });
288
+ prompt.openLayer(layer);
289
+ });
290
+
291
+ if (!enteredKey || !enteredKey.trim()) {
292
+ if ((prompt as any).editor && typeof (prompt as any).editor.clear === 'function') {
293
+ (prompt as any).editor.clear();
294
+ if (typeof (prompt as any).scheduleDraw === 'function') (prompt as any).scheduleDraw();
295
+ }
296
+ return `Cancelled. An API key is required to use ${target.providerLabel} / ${target.modelId}. Model was not changed.`;
297
+ }
298
+
299
+ const cleanKey = enteredKey.trim();
300
+ await showConfiguringAnimation(target.providerLabel);
301
+
302
+ config['provider'] = target.providerId;
303
+ config['model'] = target.modelId;
304
+ config['apiKey'] = cleanKey;
305
+ config['providerKeys'] = providerKeys;
306
+ config['providerKeys'][target.providerId] = cleanKey;
307
+ store.saveConfig(config);
308
+
309
+ if (options.loop) {
310
+ options.loop.config = config;
311
+ if (typeof options.loop.updateTierLimits === 'function') {
312
+ options.loop.updateTierLimits();
313
+ }
314
+ }
315
+
316
+ notifyPromptAndClean(target.providerId, target.modelId);
317
+ return `Saved API key. Now using ${target.providerLabel} / ${target.modelId}.`;
318
+ }
package/src/tui/prompt.js CHANGED
@@ -28,6 +28,7 @@ import { pickExample, fitHints } from './banner.js';
28
28
  import { panelRows } from './overlay.js';
29
29
  import { commandPalette, skillPicker, ApprovalLayer, DecisionLayer, ConfirmLayer, HomeLayer, TextLayer } from './dialogs.js';
30
30
  import { describeTool } from './toolDisplay.js';
31
+ import { readClipboardSync } from './clipboardSync.js';
31
32
 
32
33
  const CTRL_C_WINDOW_MS = 2000;
33
34
 
@@ -421,6 +422,17 @@ export class ChatPrompt {
421
422
  this.scheduleDraw();
422
423
  }
423
424
 
425
+ /** Update active model and provider displayed in agentRow and status footer. */
426
+ updateModel(provider, model) {
427
+ if (this.renderer && this.renderer.status) {
428
+ this.renderer.status.setSession({
429
+ provider: provider ? String(provider) : '',
430
+ model: model ? String(model) : ''
431
+ });
432
+ }
433
+ this.scheduleDraw();
434
+ }
435
+
424
436
  /**
425
437
  * Browse the compiled skill library.
426
438
  *
@@ -584,6 +596,23 @@ export class ChatPrompt {
584
596
  this.editor.clear();
585
597
  this.completion = null;
586
598
 
599
+ // Control commands take priority over busy turns so the user is never locked out.
600
+ // Commands like /stop, /new, /model, /session, /sessions, /continuum, /clear can interrupt
601
+ // a stalled/long-running turn and execute immediately.
602
+ const isControlCommand = this.isCommand(text) && (
603
+ text === '/stop' || text === '/interrupt' ||
604
+ text.startsWith('/new') ||
605
+ text.startsWith('/model') ||
606
+ text.startsWith('/session') ||
607
+ text.startsWith('/sessions') ||
608
+ text.startsWith('/continuum') ||
609
+ text === '/clear'
610
+ );
611
+
612
+ if (isControlCommand && this.busy) {
613
+ this.interrupt();
614
+ }
615
+
587
616
  if (this.busy) {
588
617
  // The turn is still running: hold the line rather than dropping it.
589
618
  this.queue.push(text);
@@ -638,12 +667,6 @@ export class ChatPrompt {
638
667
  if (this.surface.captureMouse() && this.notice.startsWith('top of this view')) this.notice = '';
639
668
  }
640
669
 
641
- if (key.name === 'paste') {
642
- this.editor.insert(key.text);
643
- this.refreshCompletion();
644
- return;
645
- }
646
-
647
670
  if (key.ctrl && key.name === 'c') {
648
671
  // A modal owns the screen, so ctrl+c must dismiss THAT before it touches
649
672
  // the turn behind it. closeLayer() answers false, which is what makes
@@ -662,6 +685,8 @@ export class ChatPrompt {
662
685
 
663
686
  // A dialog owns the keyboard while it is up — the editor must not also see
664
687
  // the keystroke, or typing a filter would edit the message behind it.
688
+ // This MUST route before any default key handling (like paste) so modal
689
+ // dialogs (e.g. InputLayer for API keys) receive bracketed paste events.
665
690
  if (this.layer) {
666
691
  const action = this.layer.key(key);
667
692
  if (action === 'close') { this.closeLayer(); return; }
@@ -676,6 +701,12 @@ export class ChatPrompt {
676
701
  else if (action !== 'passthrough') return;
677
702
  }
678
703
 
704
+ if (key.name === 'paste') {
705
+ this.editor.insert(key.text);
706
+ this.refreshCompletion();
707
+ return;
708
+ }
709
+
679
710
  if (this.completion && this.handleCompletionKey(key)) return;
680
711
  if (this.handleScrollKey(key)) return;
681
712
 
@@ -712,6 +743,14 @@ export class ChatPrompt {
712
743
  case 'p': return this.openPalette();
713
744
  case 'l': return this.clearScreen();
714
745
  case 'o': return this.expand();
746
+ case 'v': {
747
+ const text = readClipboardSync();
748
+ if (text) {
749
+ this.editor.insert(text);
750
+ this.refreshCompletion();
751
+ }
752
+ return;
753
+ }
715
754
  default: break;
716
755
  }
717
756
  }
@@ -869,7 +908,14 @@ export class ChatPrompt {
869
908
  }
870
909
 
871
910
  handleEscape() {
872
- if (this.completion) { this.completion = null; return; }
911
+ if (this.completion) {
912
+ this.completion = null;
913
+ if (this.editor.getText().startsWith('/')) {
914
+ this.editor.clear();
915
+ }
916
+ this.scheduleDraw();
917
+ return;
918
+ }
873
919
  if (this.busy) return this.interrupt();
874
920
  this.editor.clear();
875
921
  }
@@ -994,6 +1040,35 @@ export class ChatPrompt {
994
1040
  if (key.name === 'up') { this.moveSelection(-1); return true; }
995
1041
  if (key.name === 'down') { this.moveSelection(1); return true; }
996
1042
  if (key.name === 'enter' && !key.alt) {
1043
+ const item = this.completion.items && this.completion.items[this.selected];
1044
+ if (this.completion.kind === 'command' && item) {
1045
+ if (item.value === '/model' || item.value === '/sessions' || item.value === '/session' || item.value === '/new' || item.value === '/continuum') {
1046
+ this.editor.clear();
1047
+ this.completion = null;
1048
+ this.deliver(item.value);
1049
+ return true;
1050
+ }
1051
+ }
1052
+ if (this.completion.kind === 'command-argument' && item) {
1053
+ if (this.completion.command === 'model') {
1054
+ this.editor.clear();
1055
+ this.completion = null;
1056
+ this.deliver(`/model ${item.value}`);
1057
+ return true;
1058
+ }
1059
+ if (this.completion.command === 'sessions' || this.completion.command === 'session') {
1060
+ this.editor.clear();
1061
+ this.completion = null;
1062
+ this.deliver(`/sessions ${item.value}`);
1063
+ return true;
1064
+ }
1065
+ if (this.completion.command === 'continuum') {
1066
+ this.editor.clear();
1067
+ this.completion = null;
1068
+ this.deliver(`/continuum ${item.value}`);
1069
+ return true;
1070
+ }
1071
+ }
997
1072
  if (this.completionIsExact()) {
998
1073
  // Nothing left to complete. Close the picker and let the key through to
999
1074
  // submit, rather than re-offering what is already on the line.
@@ -1004,7 +1079,14 @@ export class ChatPrompt {
1004
1079
  return true;
1005
1080
  }
1006
1081
  if (key.name === 'tab') { this.acceptCompletion(); return true; }
1007
- if (key.name === 'escape') { this.completion = null; return true; }
1082
+ if (key.name === 'escape') {
1083
+ this.completion = null;
1084
+ if (this.editor.getText().startsWith('/')) {
1085
+ this.editor.clear();
1086
+ }
1087
+ this.scheduleDraw();
1088
+ return true;
1089
+ }
1008
1090
  return false;
1009
1091
  }
1010
1092
 
@@ -16,6 +16,7 @@
16
16
 
17
17
  import { paint, bold, dim, GLYPHS } from './theme.js';
18
18
  import { truncate, visibleWidth, safeDisplay } from './text.js';
19
+ import { readClipboardSync } from './clipboardSync.js';
19
20
 
20
21
  /**
21
22
  * Score `query` against `text` as a fuzzy subsequence.
@@ -223,6 +224,14 @@ export class SelectList {
223
224
  return 'handled';
224
225
  }
225
226
  return 'cancel';
227
+ case 'paste': {
228
+ const clean = String(key.text || '').replace(/[\r\n]+/g, ' ').trim();
229
+ if (clean) {
230
+ this.query += clean;
231
+ this.refilter();
232
+ }
233
+ return 'handled';
234
+ }
226
235
  default: break;
227
236
  }
228
237
 
@@ -231,6 +240,17 @@ export class SelectList {
231
240
  if (key.name === 'p') { this.move(-1, rows); return 'handled'; }
232
241
  if (key.name === 'n') { this.move(1, rows); return 'handled'; }
233
242
  if (key.name === 'u') { this.query = ''; this.refilter(); return 'handled'; }
243
+ if (key.name === 'v') {
244
+ const text = readClipboardSync();
245
+ if (text) {
246
+ const clean = String(text).replace(/[\r\n]+/g, ' ').trim();
247
+ if (clean) {
248
+ this.query += clean;
249
+ this.refilter();
250
+ }
251
+ }
252
+ return 'handled';
253
+ }
234
254
  return null;
235
255
  }
236
256