@sunub/obsidian-mcp-server 0.3.0 → 0.3.2

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 (128) hide show
  1. package/README.md +21 -5
  2. package/build/cli/app.d.ts +1 -0
  3. package/build/cli/colors.d.ts +15 -0
  4. package/build/cli/colors.js +15 -0
  5. package/build/cli/colors.js.map +1 -0
  6. package/build/cli/commands/types.d.ts +19 -0
  7. package/build/cli/commands/types.js +11 -0
  8. package/build/cli/commands/types.js.map +1 -0
  9. package/build/cli/config/mcpServersConfig.d.ts +15 -3
  10. package/build/cli/config/mcpServersConfig.js +1 -1
  11. package/build/cli/config/mcpServersConfig.js.map +1 -1
  12. package/build/cli/constants.d.ts +47 -0
  13. package/build/cli/constants.js +101 -0
  14. package/build/cli/constants.js.map +1 -0
  15. package/build/cli/index.d.ts +1 -0
  16. package/build/cli/index.js +16 -4
  17. package/build/cli/index.js.map +1 -1
  18. package/build/cli/key/input.d.ts +5 -0
  19. package/build/cli/key/input.js +9 -0
  20. package/build/cli/key/input.js.map +1 -0
  21. package/build/cli/key/mouse.d.ts +23 -0
  22. package/build/cli/key/mouse.js +155 -0
  23. package/build/cli/key/mouse.js.map +1 -0
  24. package/build/cli/key/text-buffer-bestcase.d.ts +867 -0
  25. package/build/cli/key/text-buffer.d.ts +509 -0
  26. package/build/cli/main.d.ts +1 -0
  27. package/build/cli/main.js +20 -0
  28. package/build/cli/main.js.map +1 -0
  29. package/build/cli/reference/text-buffer.d.ts +867 -0
  30. package/build/cli/reference/text-buffer.js +2754 -0
  31. package/build/cli/reference/text-buffer.js.map +1 -0
  32. package/build/cli/theme/builtin/default-dark.d.ts +7 -0
  33. package/build/cli/theme/builtin/default-dark.js +143 -0
  34. package/build/cli/theme/builtin/default-dark.js.map +1 -0
  35. package/build/cli/theme/builtin/no-color.d.ts +7 -0
  36. package/build/cli/theme/builtin/tokyonight-dark.d.ts +7 -0
  37. package/build/cli/theme/semantic-colors.d.ts +2 -0
  38. package/build/cli/theme/semantic-tokens.d.ts +42 -0
  39. package/build/cli/theme/theme.d.ts +107 -0
  40. package/build/cli/tmp.d.ts +1 -0
  41. package/build/cli/utils/cache.d.ts +21 -0
  42. package/build/cli/utils/cache.js +56 -0
  43. package/build/cli/utils/cache.js.map +1 -0
  44. package/build/cli/utils/debugLogger.js +5 -5
  45. package/build/cli/utils/debugLogger.js.map +1 -1
  46. package/build/config.d.ts +30 -0
  47. package/build/config.js +1 -1
  48. package/build/config.js.map +1 -1
  49. package/build/db.d.ts +1 -0
  50. package/build/index.d.ts +2 -0
  51. package/build/index.js +4 -2
  52. package/build/index.js.map +1 -1
  53. package/build/server.d.ts +2 -0
  54. package/build/server.js +39 -0
  55. package/build/server.js.map +1 -0
  56. package/build/tools/create_document_with_properties/params.d.ts +2 -2
  57. package/build/tools/create_document_with_properties/params.js +33 -0
  58. package/build/tools/create_document_with_properties/params.js.map +1 -0
  59. package/build/tools/generate_property/index.d.ts +34 -0
  60. package/build/tools/generate_property/params.d.ts +48 -0
  61. package/build/tools/generate_property/params.js +55 -0
  62. package/build/tools/generate_property/params.js.map +1 -0
  63. package/build/tools/index.js +13 -0
  64. package/build/tools/index.js.map +1 -0
  65. package/build/tools/organize_attachments/index.d.ts +32 -0
  66. package/build/tools/organize_attachments/params.d.ts +16 -16
  67. package/build/tools/organize_attachments/params.js +61 -0
  68. package/build/tools/organize_attachments/params.js.map +1 -0
  69. package/build/tools/organize_attachments/utils.d.ts +22 -0
  70. package/build/tools/organize_attachments/utils.js +66 -0
  71. package/build/tools/organize_attachments/utils.js.map +1 -0
  72. package/build/tools/vault/index.d.ts +50 -0
  73. package/build/tools/vault/metrics.d.ts +25 -0
  74. package/build/tools/vault/metrics.js +130 -0
  75. package/build/tools/vault/metrics.js.map +1 -0
  76. package/build/tools/vault/params.d.ts +12 -12
  77. package/build/tools/vault/params.js +148 -0
  78. package/build/tools/vault/params.js.map +1 -0
  79. package/build/tools/vault/types/collect_context.d.ts +249 -249
  80. package/build/tools/vault/types/collect_context.js +103 -0
  81. package/build/tools/vault/types/collect_context.js.map +1 -0
  82. package/build/tools/vault/types/list_all.d.ts +14 -14
  83. package/build/tools/vault/types/list_all.js +53 -0
  84. package/build/tools/vault/types/list_all.js.map +1 -0
  85. package/build/tools/vault/types/read_specific.d.ts +18 -18
  86. package/build/tools/vault/types/read_specific.js +41 -0
  87. package/build/tools/vault/types/read_specific.js.map +1 -0
  88. package/build/tools/vault/types/search.d.ts +22 -22
  89. package/build/tools/vault/types/search.js +59 -0
  90. package/build/tools/vault/types/search.js.map +1 -0
  91. package/build/tools/vault/utils/actions/collect_context.d.ts +4 -0
  92. package/build/tools/vault/utils/actions/index_rag.d.ts +2 -0
  93. package/build/tools/vault/utils/actions/list_all.d.ts +4 -0
  94. package/build/tools/vault/utils/actions/load_memory.d.ts +4 -0
  95. package/build/tools/vault/utils/actions/read.d.ts +4 -0
  96. package/build/tools/vault/utils/actions/search.d.ts +4 -0
  97. package/build/tools/vault/utils/actions/search_semantic.d.ts +3 -0
  98. package/build/tools/vault/utils/actions/search_semantic.js +23 -6
  99. package/build/tools/vault/utils/actions/search_semantic.js.map +1 -1
  100. package/build/tools/vault/utils/actions/stats.d.ts +3 -0
  101. package/build/tools/vault/utils/constants.d.ts +2 -0
  102. package/build/tools/vault/utils/constants.js +3 -0
  103. package/build/tools/vault/utils/constants.js.map +1 -0
  104. package/build/tools/vault/utils/document.d.ts +35 -0
  105. package/build/tools/vault/utils/shared.d.ts +29 -0
  106. package/build/tools/vault/utils/shared.js +75 -0
  107. package/build/tools/vault/utils/shared.js.map +1 -0
  108. package/build/tools/vault/utils.d.ts +8 -0
  109. package/build/tools/vault/utils.js +9 -0
  110. package/build/tools/vault/utils.js.map +1 -0
  111. package/build/tools/write_property/params.d.ts +60 -0
  112. package/build/tools/write_property/params.js +52 -0
  113. package/build/tools/write_property/params.js.map +1 -0
  114. package/build/utils/LLMClient.d.ts +1 -3
  115. package/build/utils/LLMClient.js +18 -4
  116. package/build/utils/LLMClient.js.map +1 -1
  117. package/build/utils/RerankerClient.d.ts +38 -4
  118. package/build/utils/RerankerClient.js +2 -1
  119. package/build/utils/RerankerClient.js.map +1 -1
  120. package/build/utils/VaultWatcher.js +35 -28
  121. package/build/utils/VaultWatcher.js.map +1 -1
  122. package/build/utils/processor/types.d.ts +2 -2
  123. package/build/utils/processor/types.js +21 -0
  124. package/build/utils/processor/types.js.map +1 -0
  125. package/build/utils/semaphore.d.ts +7 -0
  126. package/build/utils/semaphore.js +26 -0
  127. package/build/utils/semaphore.js.map +1 -0
  128. package/package.json +4 -2
@@ -0,0 +1,867 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { type EditorType } from "@google/gemini-cli-core";
7
+ import type { Key } from "../../contexts/KeypressContext.js";
8
+ export declare const LARGE_PASTE_LINE_THRESHOLD = 5;
9
+ export declare const LARGE_PASTE_CHAR_THRESHOLD = 500;
10
+ export declare const PASTED_TEXT_PLACEHOLDER_REGEX: RegExp;
11
+ export declare function expandPastePlaceholders(text: string, pastedContent: Record<string, string>): string;
12
+ export type Direction = "left" | "right" | "up" | "down" | "wordLeft" | "wordRight" | "home" | "end";
13
+ export declare const isWordCharStrict: (char: string) => boolean;
14
+ export declare const isWhitespace: (char: string) => boolean;
15
+ export declare const isCombiningMark: (char: string) => boolean;
16
+ export declare const isWordCharWithCombining: (char: string) => boolean;
17
+ export declare const getCharScript: (char: string) => string;
18
+ export declare const isDifferentScript: (char1: string, char2: string) => boolean;
19
+ export declare const findNextWordStartInLine: (line: string, col: number) => number | null;
20
+ export declare const findPrevWordStartInLine: (line: string, col: number) => number | null;
21
+ export declare const findWordEndInLine: (line: string, col: number) => number | null;
22
+ export declare const findNextBigWordStartInLine: (line: string, col: number) => number | null;
23
+ export declare const findPrevBigWordStartInLine: (line: string, col: number) => number | null;
24
+ export declare const findBigWordEndInLine: (line: string, col: number) => number | null;
25
+ export declare const findNextWordAcrossLines: (lines: string[], cursorRow: number, cursorCol: number, searchForWordStart: boolean) => {
26
+ row: number;
27
+ col: number;
28
+ } | null;
29
+ export declare const findPrevWordAcrossLines: (lines: string[], cursorRow: number, cursorCol: number) => {
30
+ row: number;
31
+ col: number;
32
+ } | null;
33
+ export declare const findNextBigWordAcrossLines: (lines: string[], cursorRow: number, cursorCol: number, searchForWordStart: boolean) => {
34
+ row: number;
35
+ col: number;
36
+ } | null;
37
+ export declare const findPrevBigWordAcrossLines: (lines: string[], cursorRow: number, cursorCol: number) => {
38
+ row: number;
39
+ col: number;
40
+ } | null;
41
+ export declare const getPositionFromOffsets: (startOffset: number, endOffset: number, lines: string[]) => {
42
+ startRow: number;
43
+ startCol: number;
44
+ endRow: number;
45
+ endCol: number;
46
+ };
47
+ export declare const getLineRangeOffsets: (startRow: number, lineCount: number, lines: string[]) => {
48
+ startOffset: number;
49
+ endOffset: number;
50
+ };
51
+ export declare const replaceRangeInternal: (state: TextBufferState, startRow: number, startCol: number, endRow: number, endCol: number, text: string) => TextBufferState;
52
+ export interface Viewport {
53
+ height: number;
54
+ width: number;
55
+ }
56
+ interface UseTextBufferProps {
57
+ initialText?: string;
58
+ initialCursorOffset?: number;
59
+ viewport: Viewport;
60
+ stdin?: NodeJS.ReadStream | null;
61
+ setRawMode?: (mode: boolean) => void;
62
+ onChange?: (text: string) => void;
63
+ escapePastedPaths?: boolean;
64
+ shellModeActive?: boolean;
65
+ inputFilter?: (text: string) => string;
66
+ singleLine?: boolean;
67
+ getPreferredEditor?: () => EditorType | undefined;
68
+ }
69
+ interface UndoHistoryEntry {
70
+ lines: string[];
71
+ cursorRow: number;
72
+ cursorCol: number;
73
+ pastedContent: Record<string, string>;
74
+ expandedPaste: ExpandedPasteInfo | null;
75
+ }
76
+ export declare function offsetToLogicalPos(text: string, offset: number): [number, number];
77
+ /**
78
+ * Converts logical row/col position to absolute text offset
79
+ * Inverse operation of offsetToLogicalPos
80
+ */
81
+ export declare function logicalPosToOffset(lines: string[], row: number, col: number): number;
82
+ /**
83
+ * Transformations allow for the CLI to render terse representations of things like file paths
84
+ * (e.g., "@some/path/to/an/image.png" to "[Image image.png]")
85
+ * When the cursor enters a transformed representation, it expands to reveal the logical representation.
86
+ * (e.g., "[Image image.png]" to "@some/path/to/an/image.png")
87
+ */
88
+ export interface Transformation {
89
+ logStart: number;
90
+ logEnd: number;
91
+ logicalText: string;
92
+ collapsedText: string;
93
+ type: "image" | "paste";
94
+ id?: string;
95
+ }
96
+ export declare const imagePathRegex: RegExp;
97
+ export declare function getTransformedImagePath(filePath: string): string;
98
+ export declare function calculateTransformationsForLine(line: string): Transformation[];
99
+ export declare function calculateTransformations(lines: string[]): Transformation[][];
100
+ export declare function getTransformUnderCursor(row: number, col: number, spansByLine: Transformation[][], options?: {
101
+ includeEdge?: boolean;
102
+ }): Transformation | null;
103
+ export interface ExpandedPasteInfo {
104
+ id: string;
105
+ startLine: number;
106
+ lineCount: number;
107
+ prefix: string;
108
+ suffix: string;
109
+ }
110
+ /**
111
+ * Check if a line index falls within an expanded paste region.
112
+ * Returns the paste placeholder ID if found, null otherwise.
113
+ */
114
+ export declare function getExpandedPasteAtLine(lineIndex: number, expandedPaste: ExpandedPasteInfo | null): string | null;
115
+ /**
116
+ * Surgery for expanded paste regions when lines are added or removed.
117
+ * Adjusts startLine indices and detaches any region that is partially or fully deleted.
118
+ */
119
+ export declare function shiftExpandedRegions(expandedPaste: ExpandedPasteInfo | null, changeStartLine: number, lineDelta: number, changeEndLine?: number): {
120
+ newInfo: ExpandedPasteInfo | null;
121
+ isDetached: boolean;
122
+ };
123
+ /**
124
+ * Detach any expanded paste region if the cursor is within it.
125
+ * This converts the expanded content to regular text that can no longer be collapsed.
126
+ * Returns the state unchanged if cursor is not in an expanded region.
127
+ */
128
+ export declare function detachExpandedPaste(state: TextBufferState): TextBufferState;
129
+ export declare function calculateTransformedLine(logLine: string, logIndex: number, logicalCursor: [number, number], transformations: Transformation[]): {
130
+ transformedLine: string;
131
+ transformedToLogMap: number[];
132
+ };
133
+ export interface VisualLayout {
134
+ visualLines: string[];
135
+ logicalToVisualMap: Array<Array<[number, number]>>;
136
+ visualToLogicalMap: Array<[number, number]>;
137
+ transformedToLogicalMaps: number[][];
138
+ visualToTransformedMap: number[];
139
+ }
140
+ export interface TextBufferState {
141
+ lines: string[];
142
+ cursorRow: number;
143
+ cursorCol: number;
144
+ transformationsByLine: Transformation[][];
145
+ preferredCol: number | null;
146
+ undoStack: UndoHistoryEntry[];
147
+ redoStack: UndoHistoryEntry[];
148
+ clipboard: string | null;
149
+ selectionAnchor: [number, number] | null;
150
+ viewportWidth: number;
151
+ viewportHeight: number;
152
+ visualLayout: VisualLayout;
153
+ pastedContent: Record<string, string>;
154
+ expandedPaste: ExpandedPasteInfo | null;
155
+ yankRegister: {
156
+ text: string;
157
+ linewise: boolean;
158
+ } | null;
159
+ }
160
+ export declare const pushUndo: (currentState: TextBufferState) => TextBufferState;
161
+ export type TextBufferAction = {
162
+ type: "insert";
163
+ payload: string;
164
+ isPaste?: boolean;
165
+ } | {
166
+ type: "set_text";
167
+ payload: string;
168
+ pushToUndo?: boolean;
169
+ cursorPosition?: "start" | "end" | number;
170
+ } | {
171
+ type: "add_pasted_content";
172
+ payload: {
173
+ id: string;
174
+ text: string;
175
+ };
176
+ } | {
177
+ type: "backspace";
178
+ } | {
179
+ type: "move";
180
+ payload: {
181
+ dir: Direction;
182
+ };
183
+ } | {
184
+ type: "set_cursor";
185
+ payload: {
186
+ cursorRow: number;
187
+ cursorCol: number;
188
+ preferredCol: number | null;
189
+ };
190
+ } | {
191
+ type: "delete";
192
+ } | {
193
+ type: "delete_word_left";
194
+ } | {
195
+ type: "delete_word_right";
196
+ } | {
197
+ type: "kill_line_right";
198
+ } | {
199
+ type: "kill_line_left";
200
+ } | {
201
+ type: "undo";
202
+ } | {
203
+ type: "redo";
204
+ } | {
205
+ type: "replace_range";
206
+ payload: {
207
+ startRow: number;
208
+ startCol: number;
209
+ endRow: number;
210
+ endCol: number;
211
+ text: string;
212
+ };
213
+ } | {
214
+ type: "move_to_offset";
215
+ payload: {
216
+ offset: number;
217
+ };
218
+ } | {
219
+ type: "create_undo_snapshot";
220
+ } | {
221
+ type: "set_viewport";
222
+ payload: {
223
+ width: number;
224
+ height: number;
225
+ };
226
+ } | {
227
+ type: "vim_delete_word_forward";
228
+ payload: {
229
+ count: number;
230
+ };
231
+ } | {
232
+ type: "vim_delete_word_backward";
233
+ payload: {
234
+ count: number;
235
+ };
236
+ } | {
237
+ type: "vim_delete_word_end";
238
+ payload: {
239
+ count: number;
240
+ };
241
+ } | {
242
+ type: "vim_delete_big_word_forward";
243
+ payload: {
244
+ count: number;
245
+ };
246
+ } | {
247
+ type: "vim_delete_big_word_backward";
248
+ payload: {
249
+ count: number;
250
+ };
251
+ } | {
252
+ type: "vim_delete_big_word_end";
253
+ payload: {
254
+ count: number;
255
+ };
256
+ } | {
257
+ type: "vim_change_word_forward";
258
+ payload: {
259
+ count: number;
260
+ };
261
+ } | {
262
+ type: "vim_change_word_backward";
263
+ payload: {
264
+ count: number;
265
+ };
266
+ } | {
267
+ type: "vim_change_word_end";
268
+ payload: {
269
+ count: number;
270
+ };
271
+ } | {
272
+ type: "vim_change_big_word_forward";
273
+ payload: {
274
+ count: number;
275
+ };
276
+ } | {
277
+ type: "vim_change_big_word_backward";
278
+ payload: {
279
+ count: number;
280
+ };
281
+ } | {
282
+ type: "vim_change_big_word_end";
283
+ payload: {
284
+ count: number;
285
+ };
286
+ } | {
287
+ type: "vim_delete_line";
288
+ payload: {
289
+ count: number;
290
+ };
291
+ } | {
292
+ type: "vim_change_line";
293
+ payload: {
294
+ count: number;
295
+ };
296
+ } | {
297
+ type: "vim_delete_to_end_of_line";
298
+ payload: {
299
+ count: number;
300
+ };
301
+ } | {
302
+ type: "vim_delete_to_start_of_line";
303
+ } | {
304
+ type: "vim_change_to_end_of_line";
305
+ payload: {
306
+ count: number;
307
+ };
308
+ } | {
309
+ type: "vim_change_movement";
310
+ payload: {
311
+ movement: "h" | "j" | "k" | "l";
312
+ count: number;
313
+ };
314
+ } | {
315
+ type: "vim_move_left";
316
+ payload: {
317
+ count: number;
318
+ };
319
+ } | {
320
+ type: "vim_move_right";
321
+ payload: {
322
+ count: number;
323
+ };
324
+ } | {
325
+ type: "vim_move_up";
326
+ payload: {
327
+ count: number;
328
+ };
329
+ } | {
330
+ type: "vim_move_down";
331
+ payload: {
332
+ count: number;
333
+ };
334
+ } | {
335
+ type: "vim_move_word_forward";
336
+ payload: {
337
+ count: number;
338
+ };
339
+ } | {
340
+ type: "vim_move_word_backward";
341
+ payload: {
342
+ count: number;
343
+ };
344
+ } | {
345
+ type: "vim_move_word_end";
346
+ payload: {
347
+ count: number;
348
+ };
349
+ } | {
350
+ type: "vim_move_big_word_forward";
351
+ payload: {
352
+ count: number;
353
+ };
354
+ } | {
355
+ type: "vim_move_big_word_backward";
356
+ payload: {
357
+ count: number;
358
+ };
359
+ } | {
360
+ type: "vim_move_big_word_end";
361
+ payload: {
362
+ count: number;
363
+ };
364
+ } | {
365
+ type: "vim_delete_char";
366
+ payload: {
367
+ count: number;
368
+ };
369
+ } | {
370
+ type: "vim_insert_at_cursor";
371
+ } | {
372
+ type: "vim_append_at_cursor";
373
+ } | {
374
+ type: "vim_open_line_below";
375
+ } | {
376
+ type: "vim_open_line_above";
377
+ } | {
378
+ type: "vim_append_at_line_end";
379
+ } | {
380
+ type: "vim_insert_at_line_start";
381
+ } | {
382
+ type: "vim_move_to_line_start";
383
+ } | {
384
+ type: "vim_move_to_line_end";
385
+ } | {
386
+ type: "vim_move_to_first_nonwhitespace";
387
+ } | {
388
+ type: "vim_move_to_first_line";
389
+ } | {
390
+ type: "vim_move_to_last_line";
391
+ } | {
392
+ type: "vim_move_to_line";
393
+ payload: {
394
+ lineNumber: number;
395
+ };
396
+ } | {
397
+ type: "vim_escape_insert_mode";
398
+ } | {
399
+ type: "vim_delete_to_first_nonwhitespace";
400
+ } | {
401
+ type: "vim_change_to_start_of_line";
402
+ } | {
403
+ type: "vim_change_to_first_nonwhitespace";
404
+ } | {
405
+ type: "vim_delete_to_first_line";
406
+ payload: {
407
+ count: number;
408
+ };
409
+ } | {
410
+ type: "vim_delete_to_last_line";
411
+ payload: {
412
+ count: number;
413
+ };
414
+ } | {
415
+ type: "vim_delete_char_before";
416
+ payload: {
417
+ count: number;
418
+ };
419
+ } | {
420
+ type: "vim_toggle_case";
421
+ payload: {
422
+ count: number;
423
+ };
424
+ } | {
425
+ type: "vim_replace_char";
426
+ payload: {
427
+ char: string;
428
+ count: number;
429
+ };
430
+ } | {
431
+ type: "vim_find_char_forward";
432
+ payload: {
433
+ char: string;
434
+ count: number;
435
+ till: boolean;
436
+ };
437
+ } | {
438
+ type: "vim_find_char_backward";
439
+ payload: {
440
+ char: string;
441
+ count: number;
442
+ till: boolean;
443
+ };
444
+ } | {
445
+ type: "vim_delete_to_char_forward";
446
+ payload: {
447
+ char: string;
448
+ count: number;
449
+ till: boolean;
450
+ };
451
+ } | {
452
+ type: "vim_delete_to_char_backward";
453
+ payload: {
454
+ char: string;
455
+ count: number;
456
+ till: boolean;
457
+ };
458
+ } | {
459
+ type: "vim_yank_line";
460
+ payload: {
461
+ count: number;
462
+ };
463
+ } | {
464
+ type: "vim_yank_word_forward";
465
+ payload: {
466
+ count: number;
467
+ };
468
+ } | {
469
+ type: "vim_yank_big_word_forward";
470
+ payload: {
471
+ count: number;
472
+ };
473
+ } | {
474
+ type: "vim_yank_word_end";
475
+ payload: {
476
+ count: number;
477
+ };
478
+ } | {
479
+ type: "vim_yank_big_word_end";
480
+ payload: {
481
+ count: number;
482
+ };
483
+ } | {
484
+ type: "vim_yank_to_end_of_line";
485
+ payload: {
486
+ count: number;
487
+ };
488
+ } | {
489
+ type: "vim_paste_after";
490
+ payload: {
491
+ count: number;
492
+ };
493
+ } | {
494
+ type: "vim_paste_before";
495
+ payload: {
496
+ count: number;
497
+ };
498
+ } | {
499
+ type: "toggle_paste_expansion";
500
+ payload: {
501
+ id: string;
502
+ row: number;
503
+ col: number;
504
+ };
505
+ };
506
+ export interface TextBufferOptions {
507
+ inputFilter?: (text: string) => string;
508
+ singleLine?: boolean;
509
+ }
510
+ export declare function textBufferReducer(state: TextBufferState, action: TextBufferAction, options?: TextBufferOptions): TextBufferState;
511
+ export declare function useTextBuffer({ initialText, initialCursorOffset, viewport, stdin, setRawMode, onChange, escapePastedPaths, shellModeActive, inputFilter, singleLine, getPreferredEditor, }: UseTextBufferProps): TextBuffer;
512
+ export interface TextBuffer {
513
+ lines: string[];
514
+ text: string;
515
+ cursor: [number, number];
516
+ /**
517
+ * When the user moves the caret vertically we try to keep their original
518
+ * horizontal column even when passing through shorter lines. We remember
519
+ * that *preferred* column in this field while the user is still travelling
520
+ * vertically. Any explicit horizontal movement resets the preference.
521
+ */
522
+ preferredCol: number | null;
523
+ selectionAnchor: [number, number] | null;
524
+ pastedContent: Record<string, string>;
525
+ allVisualLines: string[];
526
+ viewportVisualLines: string[];
527
+ visualCursor: [number, number];
528
+ visualScrollRow: number;
529
+ viewportHeight: number;
530
+ /**
531
+ * For each visual line (by absolute index in allVisualLines) provides a tuple
532
+ * [logicalLineIndex, startColInLogical] that maps where that visual line
533
+ * begins within the logical buffer. Indices are code-point based.
534
+ */
535
+ visualToLogicalMap: Array<[number, number]>;
536
+ /**
537
+ * For each logical line, an array mapping transformed positions (in the transformed
538
+ * line) back to logical column indices.
539
+ */
540
+ transformedToLogicalMaps: number[][];
541
+ /**
542
+ * For each visual line (absolute index across all visual lines), the start index
543
+ * within that logical line's transformed content.
544
+ */
545
+ visualToTransformedMap: number[];
546
+ /** Cached transformations per logical line */
547
+ transformationsByLine: Transformation[][];
548
+ visualLayout: VisualLayout;
549
+ /**
550
+ * Replaces the entire buffer content with the provided text.
551
+ * The operation is undoable.
552
+ */
553
+ setText: (text: string, cursorPosition?: "start" | "end" | number) => void;
554
+ /**
555
+ * Insert a single character or string without newlines.
556
+ */
557
+ insert: (ch: string, opts?: {
558
+ paste?: boolean;
559
+ }) => void;
560
+ newline: () => void;
561
+ backspace: () => void;
562
+ del: () => void;
563
+ move: (dir: Direction) => void;
564
+ undo: () => void;
565
+ redo: () => void;
566
+ /**
567
+ * Replaces the text within the specified range with new text.
568
+ * Handles both single-line and multi-line ranges.
569
+ *
570
+ * @param startRow The starting row index (inclusive).
571
+ * @param startCol The starting column index (inclusive, code-point based).
572
+ * @param endRow The ending row index (inclusive).
573
+ * @param endCol The ending column index (exclusive, code-point based).
574
+ * @param text The new text to insert.
575
+ * @returns True if the buffer was modified, false otherwise.
576
+ */
577
+ replaceRange: (startRow: number, startCol: number, endRow: number, endCol: number, text: string) => void;
578
+ /**
579
+ * Delete the word to the *left* of the caret, mirroring common
580
+ * Ctrl/Alt+Backspace behaviour in editors & terminals. Both the adjacent
581
+ * whitespace *and* the word characters immediately preceding the caret are
582
+ * removed. If the caret is already at column‑0 this becomes a no-op.
583
+ */
584
+ deleteWordLeft: () => void;
585
+ /**
586
+ * Delete the word to the *right* of the caret, akin to many editors'
587
+ * Ctrl/Alt+Delete shortcut. Removes any whitespace/punctuation that
588
+ * follows the caret and the next contiguous run of word characters.
589
+ */
590
+ deleteWordRight: () => void;
591
+ /**
592
+ * Deletes text from the cursor to the end of the current line.
593
+ */
594
+ killLineRight: () => void;
595
+ /**
596
+ * Deletes text from the start of the current line to the cursor.
597
+ */
598
+ killLineLeft: () => void;
599
+ /**
600
+ * High level "handleInput" – receives what Ink gives us.
601
+ */
602
+ handleInput: (key: Key) => boolean;
603
+ /**
604
+ * Opens the current buffer contents in the user's preferred terminal text
605
+ * editor ($VISUAL or $EDITOR, falling back to "vi"). The method blocks
606
+ * until the editor exits, then reloads the file and replaces the in‑memory
607
+ * buffer with whatever the user saved.
608
+ *
609
+ * The operation is treated as a single undoable edit – we snapshot the
610
+ * previous state *once* before launching the editor so one `undo()` will
611
+ * revert the entire change set.
612
+ *
613
+ * Note: We purposefully rely on the *synchronous* spawn API so that the
614
+ * calling process genuinely waits for the editor to close before
615
+ * continuing. This mirrors Git's behaviour and simplifies downstream
616
+ * control‑flow (callers can simply `await` the Promise).
617
+ */
618
+ openInExternalEditor: () => Promise<void>;
619
+ replaceRangeByOffset: (startOffset: number, endOffset: number, replacementText: string) => void;
620
+ getOffset: () => number;
621
+ moveToOffset(offset: number): void;
622
+ moveToVisualPosition(visualRow: number, visualCol: number): void;
623
+ /**
624
+ * Convert visual coordinates to logical position without moving cursor.
625
+ * Returns null if the position is out of bounds.
626
+ */
627
+ getLogicalPositionFromVisual(visualRow: number, visualCol: number): {
628
+ row: number;
629
+ col: number;
630
+ } | null;
631
+ /**
632
+ * Check if a line index falls within an expanded paste region.
633
+ * Returns the paste placeholder ID if found, null otherwise.
634
+ */
635
+ getExpandedPasteAtLine(lineIndex: number): string | null;
636
+ /**
637
+ * Toggle expansion state for a paste placeholder.
638
+ * If collapsed, expands to show full content inline.
639
+ * If expanded, collapses back to placeholder.
640
+ */
641
+ togglePasteExpansion(id: string, row: number, col: number): void;
642
+ /**
643
+ * The current expanded paste info (read-only).
644
+ */
645
+ expandedPaste: ExpandedPasteInfo | null;
646
+ /**
647
+ * Delete N words forward from cursor position (vim 'dw' command)
648
+ */
649
+ vimDeleteWordForward: (count: number) => void;
650
+ /**
651
+ * Delete N words backward from cursor position (vim 'db' command)
652
+ */
653
+ vimDeleteWordBackward: (count: number) => void;
654
+ /**
655
+ * Delete to end of N words from cursor position (vim 'de' command)
656
+ */
657
+ vimDeleteWordEnd: (count: number) => void;
658
+ /**
659
+ * Delete N big words forward from cursor position (vim 'dW' command)
660
+ */
661
+ vimDeleteBigWordForward: (count: number) => void;
662
+ /**
663
+ * Delete N big words backward from cursor position (vim 'dB' command)
664
+ */
665
+ vimDeleteBigWordBackward: (count: number) => void;
666
+ /**
667
+ * Delete to end of N big words from cursor position (vim 'dE' command)
668
+ */
669
+ vimDeleteBigWordEnd: (count: number) => void;
670
+ /**
671
+ * Change N words forward from cursor position (vim 'cw' command)
672
+ */
673
+ vimChangeWordForward: (count: number) => void;
674
+ /**
675
+ * Change N words backward from cursor position (vim 'cb' command)
676
+ */
677
+ vimChangeWordBackward: (count: number) => void;
678
+ /**
679
+ * Change to end of N words from cursor position (vim 'ce' command)
680
+ */
681
+ vimChangeWordEnd: (count: number) => void;
682
+ /**
683
+ * Change N big words forward from cursor position (vim 'cW' command)
684
+ */
685
+ vimChangeBigWordForward: (count: number) => void;
686
+ /**
687
+ * Change N big words backward from cursor position (vim 'cB' command)
688
+ */
689
+ vimChangeBigWordBackward: (count: number) => void;
690
+ /**
691
+ * Change to end of N big words from cursor position (vim 'cE' command)
692
+ */
693
+ vimChangeBigWordEnd: (count: number) => void;
694
+ /**
695
+ * Delete N lines from cursor position (vim 'dd' command)
696
+ */
697
+ vimDeleteLine: (count: number) => void;
698
+ /**
699
+ * Change N lines from cursor position (vim 'cc' command)
700
+ */
701
+ vimChangeLine: (count: number) => void;
702
+ /**
703
+ * Delete from cursor to end of line (vim 'D' command)
704
+ * With count > 1, deletes to end of current line plus (count-1) additional lines
705
+ */
706
+ vimDeleteToEndOfLine: (count?: number) => void;
707
+ /**
708
+ * Delete from start of line to cursor (vim 'd0' command)
709
+ */
710
+ vimDeleteToStartOfLine: () => void;
711
+ /**
712
+ * Change from cursor to end of line (vim 'C' command)
713
+ * With count > 1, changes to end of current line plus (count-1) additional lines
714
+ */
715
+ vimChangeToEndOfLine: (count?: number) => void;
716
+ /**
717
+ * Delete from cursor to first non-whitespace character (vim 'd^' command)
718
+ */
719
+ vimDeleteToFirstNonWhitespace: () => void;
720
+ /**
721
+ * Change from cursor to start of line (vim 'c0' command)
722
+ */
723
+ vimChangeToStartOfLine: () => void;
724
+ /**
725
+ * Change from cursor to first non-whitespace character (vim 'c^' command)
726
+ */
727
+ vimChangeToFirstNonWhitespace: () => void;
728
+ /**
729
+ * Delete from current line to first line (vim 'dgg' command)
730
+ */
731
+ vimDeleteToFirstLine: (count: number) => void;
732
+ /**
733
+ * Delete from current line to last line (vim 'dG' command)
734
+ */
735
+ vimDeleteToLastLine: (count: number) => void;
736
+ /**
737
+ * Change movement operations (vim 'ch', 'cj', 'ck', 'cl' commands)
738
+ */
739
+ vimChangeMovement: (movement: "h" | "j" | "k" | "l", count: number) => void;
740
+ /**
741
+ * Move cursor left N times (vim 'h' command)
742
+ */
743
+ vimMoveLeft: (count: number) => void;
744
+ /**
745
+ * Move cursor right N times (vim 'l' command)
746
+ */
747
+ vimMoveRight: (count: number) => void;
748
+ /**
749
+ * Move cursor up N times (vim 'k' command)
750
+ */
751
+ vimMoveUp: (count: number) => void;
752
+ /**
753
+ * Move cursor down N times (vim 'j' command)
754
+ */
755
+ vimMoveDown: (count: number) => void;
756
+ /**
757
+ * Move cursor forward N words (vim 'w' command)
758
+ */
759
+ vimMoveWordForward: (count: number) => void;
760
+ /**
761
+ * Move cursor backward N words (vim 'b' command)
762
+ */
763
+ vimMoveWordBackward: (count: number) => void;
764
+ /**
765
+ * Move cursor to end of Nth word (vim 'e' command)
766
+ */
767
+ vimMoveWordEnd: (count: number) => void;
768
+ /**
769
+ * Move cursor forward N big words (vim 'W' command)
770
+ */
771
+ vimMoveBigWordForward: (count: number) => void;
772
+ /**
773
+ * Move cursor backward N big words (vim 'B' command)
774
+ */
775
+ vimMoveBigWordBackward: (count: number) => void;
776
+ /**
777
+ * Move cursor to end of Nth big word (vim 'E' command)
778
+ */
779
+ vimMoveBigWordEnd: (count: number) => void;
780
+ /**
781
+ * Delete N characters at cursor (vim 'x' command)
782
+ */
783
+ vimDeleteChar: (count: number) => void;
784
+ /** Delete N characters before cursor (vim 'X') */
785
+ vimDeleteCharBefore: (count: number) => void;
786
+ /** Toggle case of N characters at cursor (vim '~') */
787
+ vimToggleCase: (count: number) => void;
788
+ /** Replace N characters at cursor with char, stay in NORMAL mode (vim 'r') */
789
+ vimReplaceChar: (char: string, count: number) => void;
790
+ /** Move to Nth occurrence of char forward on line; till=true stops before it (vim 'f'/'t') */
791
+ vimFindCharForward: (char: string, count: number, till: boolean) => void;
792
+ /** Move to Nth occurrence of char backward on line; till=true stops after it (vim 'F'/'T') */
793
+ vimFindCharBackward: (char: string, count: number, till: boolean) => void;
794
+ /** Delete from cursor to Nth occurrence of char forward; till=true excludes the char (vim 'df'/'dt') */
795
+ vimDeleteToCharForward: (char: string, count: number, till: boolean) => void;
796
+ /** Delete from Nth occurrence of char backward to cursor; till=true excludes the char (vim 'dF'/'dT') */
797
+ vimDeleteToCharBackward: (char: string, count: number, till: boolean) => void;
798
+ /**
799
+ * Enter insert mode at cursor (vim 'i' command)
800
+ */
801
+ vimInsertAtCursor: () => void;
802
+ /**
803
+ * Enter insert mode after cursor (vim 'a' command)
804
+ */
805
+ vimAppendAtCursor: () => void;
806
+ /**
807
+ * Open new line below and enter insert mode (vim 'o' command)
808
+ */
809
+ vimOpenLineBelow: () => void;
810
+ /**
811
+ * Open new line above and enter insert mode (vim 'O' command)
812
+ */
813
+ vimOpenLineAbove: () => void;
814
+ /**
815
+ * Move to end of line and enter insert mode (vim 'A' command)
816
+ */
817
+ vimAppendAtLineEnd: () => void;
818
+ /**
819
+ * Move to first non-whitespace and enter insert mode (vim 'I' command)
820
+ */
821
+ vimInsertAtLineStart: () => void;
822
+ /**
823
+ * Move cursor to beginning of line (vim '0' command)
824
+ */
825
+ vimMoveToLineStart: () => void;
826
+ /**
827
+ * Move cursor to end of line (vim '$' command)
828
+ */
829
+ vimMoveToLineEnd: () => void;
830
+ /**
831
+ * Move cursor to first non-whitespace character (vim '^' command)
832
+ */
833
+ vimMoveToFirstNonWhitespace: () => void;
834
+ /**
835
+ * Move cursor to first line (vim 'gg' command)
836
+ */
837
+ vimMoveToFirstLine: () => void;
838
+ /**
839
+ * Move cursor to last line (vim 'G' command)
840
+ */
841
+ vimMoveToLastLine: () => void;
842
+ /**
843
+ * Move cursor to specific line number (vim '[N]G' command)
844
+ */
845
+ vimMoveToLine: (lineNumber: number) => void;
846
+ /**
847
+ * Handle escape from insert mode (moves cursor left if not at line start)
848
+ */
849
+ vimEscapeInsertMode: () => void;
850
+ /** Yank N lines into the unnamed register (vim 'yy' / 'Nyy') */
851
+ vimYankLine: (count: number) => void;
852
+ /** Yank forward N words into the unnamed register (vim 'yw') */
853
+ vimYankWordForward: (count: number) => void;
854
+ /** Yank forward N big words into the unnamed register (vim 'yW') */
855
+ vimYankBigWordForward: (count: number) => void;
856
+ /** Yank to end of N words into the unnamed register (vim 'ye') */
857
+ vimYankWordEnd: (count: number) => void;
858
+ /** Yank to end of N big words into the unnamed register (vim 'yE') */
859
+ vimYankBigWordEnd: (count: number) => void;
860
+ /** Yank from cursor to end of line into the unnamed register (vim 'y$') */
861
+ vimYankToEndOfLine: (count: number) => void;
862
+ /** Paste the unnamed register after cursor (vim 'p') */
863
+ vimPasteAfter: (count: number) => void;
864
+ /** Paste the unnamed register before cursor (vim 'P') */
865
+ vimPasteBefore: (count: number) => void;
866
+ }
867
+ export {};