Repository navigation
Expand file tree
/
Copy pathtypes.lua
More file actions
746 lines (636 loc) · 29.9 KB
/
Copy pathtypes.lua
File metadata and controls
746 lines (636 loc) · 29.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
---@class OpencodeDiagnostic
---@field message string
---@field severity number
---@field lnum number
---@field col number
---@field end_lnum? number
---@field end_col? number
---@field source? string
---@field code? string|number
---@field user_data? any
---@class OpencodeConfigFile
---@field theme string
---@field autoshare boolean
---@field autoupdate boolean
---@field model string
---@field agent table<string, table>
---@field mcp table<string, table>
---@field mode table<string, table>
---@field command table<string, table>
---@field plugin table[]
---@field username string
---@class OpencodeProject
---@field id string
---@field worktree string
---@field vcs string
---@field time { created: number }
---@class OpencodePath
---@field state string
---@field config string
---@field worktree string
---@field directory string
---@class OpencodeSkill
---@field name string
---@field description string|nil
---@field location string
---@field content string
---@class OpencodeCommand
---@field description string
---@field agent string
---@field model string
---@field template string
---@class OpencodeUICommand
---@field hook_key? string Default hook group, unless the intent supplies one
---@field desc string
---@field execute fun(args: string[], range: OpencodeSelectionRange|nil): any
---@field completions? string[]
---@field nested_subcommand? OpencodeNestedSubcommandValidation
---@field completion_provider_id? string
---@field sub_completions? string[]
---@field nargs? string|integer
---@field range? boolean
---@field complete? boolean
---@class OpencodeNestedSubcommandValidation
---@field allow_empty boolean
---@class OpencodeCommandSubcommandSpec
---@field completions? string[]
---@field nested_subcommand? OpencodeNestedSubcommandValidation
---@field sub_completions? string[]
---@field completion_provider_id? string
---@class OpencodeCommandApi
---@field [string] any
---@alias OpencodeCommandHandler fun(api: OpencodeCommandApi, args: string[], range?: OpencodeSelectionRange): any
---@alias OpencodeCommandHandlerMap table<string, OpencodeCommandHandler>
---@class OpencodeParsedIntentSource
---@field raw_args string
---@field argv string[]
---@class OpencodeParsedIntent
---@field name string
---@field hook_key? string
---@field args string[]
---@field range OpencodeSelectionRange|nil
---@field source OpencodeParsedIntentSource
---@class OpencodeCommandParseError
---@field code 'unknown_subcommand'|'invalid_subcommand'
---@field message string
---@field subcommand string
---@class OpencodeCommandParseResult
---@field ok boolean
---@field intent? OpencodeParsedIntent
---@field error? OpencodeCommandParseError
---@class OpencodeCommandRouteOpts
---@field args? string
---@field range? integer
---@field line1? integer
---@field line2? integer
---@class OpencodeCommandDispatchError
---@field code 'unknown_subcommand'|'missing_handler'|'missing_execute'|'invalid_subcommand'|'invalid_arguments'|'execute_error'
---@field message string
---@field subcommand? string
---@class OpencodeCommandDispatchResult
---@field ok boolean
---@field intent? OpencodeParsedIntent
---@field result? any
---@field error? OpencodeCommandDispatchError
---@class OpencodeCommandActionContext
---@field parsed OpencodeCommandParseResult
---@field intent? OpencodeParsedIntent
---@field args? string[]
---@field range? OpencodeSelectionRange|nil
---@field execute? fun(args: string[], range: OpencodeSelectionRange|nil): any
---@class SessionRevertInfo
---@field messageID string
---@field partID? string
---@field snapshot? string
---@field diff? string
---@class SessionShareInfo
---@field url string
---@class OpencodeLocation
---@field directory string
---@class OpencodeSession
---@field workspace string
---@field title string
---@field time { created: number, updated: number }
---@field id string
---@field parentID string|nil
---@field agent string|nil
---@field model { id: string, providerID: string, variant?: string }|nil
---@field directory? string
---@field cost? number
---@field tokens? { input: number, output: number, reasoning: number, cache: { read: number, write: number } }
---@field location? OpencodeLocation
---@field revert? SessionRevertInfo
---@field share? SessionShareInfo
---@class OpencodeSessionTab
---@field id string Logical panel-tab identifier
---@field active_session OpencodeSession|nil Session assigned to this tab
---@field windows OpencodeWindowState|nil UI windows owned by this tab
---@class SessionProjectInfo
---@field id string
---@field name? string
---@field worktree string
---@class GlobalSession : OpencodeSession
---@field project SessionProjectInfo|nil
---@class OpencodeKeymapEntry
---@field [1] string|function # Action name or callback
---@field [2]? any # Arguments passed to the action or callback
---@field mode? string|string[] # Mode(s) for the keymap
---@field desc? string # Keymap description
---@field nowait? boolean # Execute without waiting for longer mappings
---@field defer_to_completion? boolean # Whether to defer the keymap when completion menu is open
---@class OpencodeKeymapEditor : table<string, OpencodeKeymapEntry>
---@class OpencodeKeymapInputWindow : table<string, OpencodeKeymapEntry>
---@class OpencodeKeymapOutputWindow : table<string, OpencodeKeymapEntry>
---@alias OpencodeSessionDiffMappings table<string, OpencodeKeymapEntry|false>
---@class OpencodeSessionDiffKeymaps
---@field list OpencodeSessionDiffMappings
---@field messages OpencodeSessionDiffMappings
---@field preview OpencodeSessionDiffMappings
---@field comment OpencodeSessionDiffMappings
---@field message_preview OpencodeSessionDiffMappings
---@field help OpencodeSessionDiffMappings
---@class OpencodeKeymap
---@field editor OpencodeKeymapEditor
---@field input_window OpencodeKeymapInputWindow
---@field output_window OpencodeKeymapOutputWindow
---@field session_diff OpencodeSessionDiffKeymaps
---@field tab_strip_window table<string, OpencodeKeymapEntry>
---@field session_picker OpencodeSessionPickerKeymap
---@field session_tab_picker OpencodeSessionTabPickerKeymap
---@field timeline_picker OpencodeTimelinePickerKeymap
---@field history_picker OpencodeHistoryPickerKeymap
---@field quick_chat OpencodeQuickChatKeymap
---@class OpencodeSessionPickerKeymap
---@field delete_session OpencodeKeymapEntry
---@field new_session OpencodeKeymapEntry
---@field open_in_tab OpencodeKeymapEntry
---@field rename_session OpencodeKeymapEntry
---@field fork_session OpencodeKeymapEntry
---@field toggle_scope OpencodeKeymapEntry
---@class OpencodeSessionTabPickerKeymap
---@field new_tab OpencodeKeymapEntry
---@field close_tab OpencodeKeymapEntry
---@class OpencodeTimelinePickerKeymap
---@field undo OpencodeKeymapEntry
---@field fork OpencodeKeymapEntry
---@class OpencodeHistoryPickerKeymap
---@field delete_entry OpencodeKeymapEntry
---@field clear_all OpencodeKeymapEntry
---@class OpencodeQuickChatKeymap
---@field cancel OpencodeKeymapEntry
---@class OpencodeCompletionFileSourcesConfig
---@field enabled boolean
---@field preferred_cli_tool 'server'|'fd'|'fdfind'|'rg'|'git'
---@field ignore_patterns string[]
---@field max_files number
---@field max_display_length number
---@class OpencodeCompletionConfig
---@field file_sources OpencodeCompletionFileSourcesConfig
---@class OpencodeLoadingAnimationConfig
---@field frames string[]
---@class OpencodeServerConfig
---@field url string | nil -- URL/hostname of custom opencode server (e.g., "http://192.168.1.100" or "localhost")
---@field port number | 'auto' | nil -- Explicit V1 port, 'auto' for an available port, or nil for source-specific discovery
---@field timeout number -- Timeout in seconds for health check (default: 5)
---@field health_check_ttl_ms number -- Cached connection health lifetime in milliseconds (default: 5000)
---@field retry_delay number -- Delay in milliseconds between health check retries (default: 2000)
---@field spawn_command? fun(port: number, url: string, env?: table<string, string>): number | nil -- Optional function to start the server, may return server PID
---@field kill_command? fun(port: number, url: string): nil -- Optional function to stop the server when auto_kill is true
---@field auto_kill boolean -- Kill spawned servers when nvim exits (default: true)
---@field path_map (string | fun(host_path: string): string) | nil -- Map host paths to server paths
---@field reverse_path_map (fun(server_path: string): string) | nil -- Map server paths back to host paths
---@field username? string | fun(): string | nil -- Username for Basic auth. Falls back to OPENCODE_SERVER_USERNAME env var, then "opencode"
---@field password? string | fun(): string | nil -- Basic auth password; falls back to password_file, OPENCODE_PASSWORD, then OPENCODE_SERVER_PASSWORD
---@field password_file? string -- File used to persist a generated V1 password; fixed ports default to an owner-only per-port state file
---@class OpencodeUIFloatConfig
---@field width number # Width in columns, or ratio when <= 1 (default: 0.95)
---@field height number # Height in rows, or ratio when <= 1 (default: 0.9)
---@field row number|nil # Top row, centered when nil
---@field col number|nil # Left column, centered when nil
---@field border string|string[]|nil # Float border passed to nvim_open_win
---@field gap integer # Rows between output and input floats
---@field zindex integer # Output float zindex; input uses zindex + 1
---@field opts table<string, any> # Window-local options applied to float windows
---@class OpencodeUIConfig
---@field enable_treesitter_markdown boolean
---@field position 'right'|'left'|'current'|'float' # Position of the UI (default: 'right')
---@field input_position 'bottom'|'top' # Position of the input window (default: 'bottom')
---@field window_width number
---@field persist_state boolean
---@field zoom_width number
---@field float OpencodeUIFloatConfig
---@field picker_width number|false|nil # Width for pickers. 0<w<=1 = fraction of screen; >1 = absolute columns; false = use picker backend defaults.
---@field display_model boolean
---@field display_context_size boolean
---@field display_cost boolean
---@field hide_single_tab boolean
---@field notify_on_background_prompt boolean
---@field window_highlight string
---@field icons { preset: 'text'|'nerdfonts', overrides: table<string,string> }
---@field loading_animation OpencodeLoadingAnimationConfig
---@field output OpencodeUIOutputConfig
---@field input OpencodeUIInputConfig
---@field completion OpencodeCompletionConfig
---@field highlights? OpencodeHighlightConfig
---@field picker OpencodeUIPickerConfig
---@field questions OpencodeUIQuestionConfig
---@class OpencodeUIQuestionConfig
---@field use_vim_ui_select boolean
---@field inline_other_input boolean
---Window-local options applied to the input window.
---Any valid Neovim window-local option (`:h window-variable`) can be set here.
---Common examples:
--- signcolumn = 'no'
--- cursorline = true
--- number = true
--- relativenumber = true
--- foldcolumn = '0'
--- statuscolumn = ''
--- conceallevel = 2
---@class OpencodeUIInputWinOptions : table<string, any>
---@field signcolumn? string # Value for 'signcolumn' (e.g. 'yes', 'no', 'auto')
---@field cursorline? boolean
---@field number? boolean
---@field relativenumber? boolean
---@class OpencodeUIInputConfig
---@field text { wrap: boolean }
---@field min_height number
---@field max_height number
---@field auto_hide boolean
---@field win_options? OpencodeUIInputWinOptions # Window-local options applied to the input window. Any valid Neovim window option is accepted.
---@class OpencodeHighlightConfig
---@field vertical_borders? { tool?: { fg?: string, bg?: string }, user?: { fg?: string, bg?: string }, assistant?: { fg?: string, bg?: string } }
---@class OpencodeUIOutputRenderingConfig
---@field markdown_debounce_ms number
---@field on_data_rendered (fun(buf: integer, win: integer)|boolean)|nil
---@field markdown_on_idle boolean
---@field event_throttle_ms number -- Minimum batching interval for streaming message renders; 0 disables the delay
---@field event_collapsing boolean -- Coalesce streaming notifications within the batching interval
---@class OpencodeUIOutputToolsConfig
---@field show_output boolean
---@field show_reasoning_output boolean
---@field use_folds boolean
---@field fold_exclude (string|{server: string, tool: string})[]|nil
---@field folding_threshold number
---@class OpencodeUIOutputConfig
---@field time_format string|nil # Custom os.date format for timestamps, e.g. '%m/%d %H:%M'. Uses fixed default when nil.
---@field actions OpencodeUIOutputActionsConfig
---@field tools OpencodeUIOutputToolsConfig
---@field rendering OpencodeUIOutputRenderingConfig
---@field max_messages integer|nil
---@field always_scroll_to_bottom boolean
---@field filetype string
---@field compact_assistant_headers boolean | 'minimal' | 'hidden' | 'full'
---@class OpencodeUIOutputActionsConfig
---@field open_in_new_tab boolean # Open inline session actions in a new panel tab
---@class OpencodeUIPickerConfig
---@field snacks_layout? snacks.picker.layout.Config
--- TODO: add more picker-specific presets
---@class OpencodeContextConfig
---@field enabled boolean
---@field cursor_data { enabled: boolean, context_lines?: number }
---@field diagnostics { enabled:boolean, info: boolean, warning: boolean, error: boolean, only_closest: boolean}
---@field current_file { enabled: boolean }
---@field selection { enabled: boolean }
---@field review_comments { enabled: boolean }
---@field agents { enabled: boolean }
---@field buffer { enabled: boolean }
---@field git_diff { enabled: boolean }
---@alias OpencodeToggleableContextKey
---| 'current_file'
---| 'selection'
---| 'review_comments'
---| 'diagnostics'
---| 'cursor_data'
---| 'buffer'
---| 'git_diff'
---@class OpencodeDebugConfig
---@field enabled boolean
---@field capture_streamed_events boolean
---@field show_ids boolean
---@field highlight_changed_lines boolean
---@field highlight_changed_lines_timeout_ms integer
---@field quick_chat {keep_session: boolean, set_active_session: boolean}
---@alias OpencodeCommandLifecycleStage 'before'|'after'|'error'|'finally'
---@alias OpencodeCommandDispatchHook fun(ctx: OpencodeCommandDispatchContext): OpencodeCommandDispatchContext|nil
---@alias OpencodeCommandHookScope string|string[]|'*'
---@class OpencodeCommandHookRegisterOptions
---@field command? OpencodeCommandHookScope
---@alias OpencodeBarSegment { [1]: string, [2]?: string, align?: 'left'|'right' }
---@alias OpencodeBarSegmentsHook fun(segments: OpencodeBarSegment[]): OpencodeBarSegment[]|nil
---@class OpencodeHooks
---@field on_topbar_render? OpencodeBarSegmentsHook
---@field on_footer_render? OpencodeBarSegmentsHook
---@field on_file_edited? fun(file: string): nil
---@field on_session_loaded? fun(session: OpencodeSession): nil
---@field on_done_thinking? fun(session: OpencodeSession): nil Called when a session becomes idle.
---@field on_permission_requested? fun(session: OpencodeSession): nil
---@field on_question_asked? fun(session: OpencodeSession): nil
---@field on_command_before? OpencodeCommandDispatchHook
---@field on_command_after? OpencodeCommandDispatchHook
---@field on_command_error? OpencodeCommandDispatchHook
---@field on_command_finally? OpencodeCommandDispatchHook
---@class OpencodeCommandDispatchContext
---@field parsed OpencodeCommandParseResult
---@field intent OpencodeParsedIntent|nil
---@field args string[]|nil
---@field range OpencodeSelectionRange|nil
---@field result? any
---@field error OpencodeCommandDispatchError|nil
---@class OpencodeCommandLifecycleHookSpec
---@field before? OpencodeCommandDispatchHook
---@field after? OpencodeCommandDispatchHook
---@field error? OpencodeCommandDispatchHook
---@field finally? OpencodeCommandDispatchHook
---@field on_command_before? OpencodeCommandDispatchHook
---@field on_command_after? OpencodeCommandDispatchHook
---@field on_command_error? OpencodeCommandDispatchHook
---@field on_command_finally? OpencodeCommandDispatchHook
---@class OpencodeProviders
---@field [string] string[]
---@class OpencodeConfigModule
---@field defaults OpencodeConfig
---@field values OpencodeConfig
---@field setup fun(opts?: OpencodeConfig): nil
---@field get_key_for_function fun(scope: 'editor'|'input_window'|'output_window', function_name: string): string|nil
---@class OpencodeQuickChatConfig
---@field default_model? string -- Use current model if nil
---@field default_agent? string -- Use current mode if nil
---@field instructions? string[] -- Custom instructions for quick chat
---@class OpencodeLoggingConfig
---@field enabled boolean
---@field level 'debug' | 'info' | 'warn' | 'error'
---@field outfile string|nil
---@class OpencodeSlashCommandSpec
---@field desc? string
---@field args? boolean
---@field cmd_str? string
---@field command_name? string
---@field preset_args? string[]
---@field fn? fun(args:string[]|nil):nil|Promise<any>|any
---@class OpencodeDirectoryChange
---@field from string Directory the session is bound to (or was loaded from)
---@field to string Directory the editor is moving to
---@field session OpencodeSession The active session
---@class OpencodeConfig
---@field preferred_picker 'telescope' | 'telescope.nvim' | 'fzf' | 'fzf-lua' | 'mini.pick' | 'snacks' | 'snacks.nvim' | 'select' | nil
---@field default_global_keymaps boolean
---@field default_mode 'build' | 'plan' | string -- Default mode
---@field default_system_prompt string | nil
---@field keymap_prefix string
---@field opencode_executable 'opencode' | string -- Command run for calling opencode
---@field lock_session_to_directory boolean|fun(change: OpencodeDirectoryChange): boolean -- true locks everywhere; a function decides per directory change; errors fall back to following cwd
---@field server OpencodeServerConfig -- Custom/external server configuration
---@field keymap OpencodeKeymap
---@field ui OpencodeUIConfig
---@field context OpencodeContextConfig
---@field logging OpencodeLoggingConfig
---@field debug OpencodeDebugConfig
---@field prompt_guard? fun(mentioned_files: string[]): boolean
---@field child_readonly boolean
---@field hooks OpencodeHooks
---@field quick_chat OpencodeQuickChatConfig
---@field snapshot_path? string -- Override base path for snapshot storage (default: $XDG_DATA_HOME/opencode). Appends /snapshot/<project_id>/<worktree_hash>
---@class OpencodeQuestionOption
---@field value any Value submitted to the owning Observation
---@field label string Display text
---@field description string Explanation of choice
---@class OpencodeQuestionInfo
---@field key string Stable key within the request
---@field prompt string Complete question
---@field title? string Short display label
---@field type 'string'|'multiselect'|'boolean'|'number'|'integer'
---@field options OpencodeQuestionOption[] Available choices
---@field custom? boolean Allow a custom response
---@field required? boolean
---@class OpencodeQuestionRequest
---@field id string Request ID
---@field session_id string Owning session
---@field status 'pending'|'answered'|'rejected'
---@field fields OpencodeQuestionInfo[]
---@field unavailable_reason? string
---@class OutputAction
---@field text string Action text
---@field type 'diff_revert_all'|'diff_revert_selected_file'|'diff_open'|'diff_toggle_file'|'diff_restore_snapshot_file'|'diff_restore_snapshot_all'|'navigate_session_tree'|'toggle_max_messages'|'undo'|'copy_message'|'fork_session'
---@field args? string[] Optional arguments for the command
---@field key string keybinding for the action
---@field display_line number Line number to display the action
---@field range? { from: number, to: number } Optional range for the action
---@class CodeReferenceTextRange
---@field start_offset integer Raw part text offset, 1-based inclusive
---@field end_offset integer Raw part text offset, 1-based inclusive
---@class CodeReference
---@field session_id string
---@field message_id string
---@field part_id string
---@field path string
---@field line? integer
---@field col? integer
---@field source_kind 'assistant_text'|'tool_file_path'
---@field raw_range? CodeReferenceTextRange Required for assistant_text references
---@field order integer Smaller values appear earlier in the session message/part/text order.
---@class SymbolSnapshotCycle
---@field warm_path fun(self: SymbolSnapshotCycle, path: string)
---@class FormatterContext
---@field interactive boolean
---@field resolve_symbol_targets? boolean
---@field get_child_parts? fun(session_id: string): table[]?
---@field current_refs? CodeReference[]
---@field current_files? string[]
---@field symbol_cycle? SymbolSnapshotCycle
---@class OutputTargetRange
---@field line integer Output-local line, 1-based
---@field start_col integer Output-local column, 0-based inclusive
---@field end_col integer Output-local column, 0-based exclusive
---@class OutputTarget
---@field kind 'file'|'diff'|'symbol'|'uri'
---@field range OutputTargetRange
---@field path? string
---@field line? integer
---@field col? integer
---@field token? string
---@field uri? string
---@class RenderedTarget: OutputTarget
---@field part_id string
---@field message_id string
---@alias OutputExtmarkType vim.api.keyset.set_extmark & {start_col:0}
---@alias OutputExtmark OutputExtmarkType|fun():OutputExtmarkType
---@class RestorePoint
---@field id string Unique restore point identifier
---@field from_snapshot_id string|nil ID of the snapshot this restore point is based on
---@field files string[] List of file paths included in the restore point
---@field deleted_files string[] List of files that were deleted in this restore point
---@field created_at number Timestamp when the restore point was created
---@class OpencodeSnapshotPatch
---@field hash string Unique identifier for the snapshot
---@field files string[] List of file paths included in the snapshot
---@class OpenOpts
---@field focus? 'input' | 'output'
---@field start_insert? boolean
---@field new_session? boolean
---@field open_action? 'reuse_visible'|'restore_hidden'|'create_fresh'
---@class SendMessageOpts
---@field new_session? boolean
---@field context? OpencodeContextConfig
---@field model? string
---@field agent? string
---@field variant? string
---@field system? string
---@field skills? OpencodeV2SkillInput[] Native V2 skill attachments
---@class CompletionContext
---@field trigger_char string The character that triggered completion
---@field input string The current input text
---@field cursor_pos number Current cursor position
---@field line string The full current line text
---@class CompletionItem
---@field label string Display text for the completion item
---@field kind string Type of completion item (e.g., 'file', 'subagent')
---@field kind_icon string Icon representing the kind
---@field kind_hl? string Highlight group for the kind
---@field detail string Additional detail text
---@field documentation string Documentation text
---@field insert_text string Text to insert when selected
---@field source_name string Name of the completion source
---@field priority? number Optional priority for individual item sorting (lower numbers have higher priority)
---@field data table Additional data associated with the item
---@class CompletionSource
---@field name string Name of the completion source
---@field priority number Priority for ordering sources
---@field complete fun(context: CompletionContext): Promise<CompletionItem[]> Function to generate completion items
---@field on_complete? fun(item: CompletionItem): nil Callback when item is selected
---@field is_incomplete? boolean Whether the completion results are incomplete (for sources that support pagination)
---@field get_trigger_character? fun(): string|nil Optional function returning the trigger character for this source
---@field custom_kind? integer Custom LSP CompletionItemKind registered for this source
---Extended LSP completion item with opencode-specific rendering fields
---@class OpencodeLspItem : lsp.CompletionItem
---@field kind lsp.CompletionItemKind
---@field kind_hl? string Highlight group for the kind icon
---@field kind_icon string Icon string for the kind
---@class OpencodeContext
---@field current_file OpencodeContextFile|nil
---@field cursor_data OpencodeContextCursorData|nil
---@field mentioned_files string[]|nil
---@field mentioned_subagents string[]|nil
---@field selections OpencodeContextSelection[]|nil
---@field review_comments? OpencodeContextReviewComment[]
---@field linter_errors OpencodeDiagnostic[]|nil
---@field automatic_context? table<string, string> Fingerprints for automatic payloads considered by the last submission
---@class OpencodeContextSelection
---@field file OpencodeContextFile
---@field content string|nil
---@field lines string|nil
---@alias OpencodeReviewCommentSide 'before'|'after'
---@alias OpencodeReviewCommentStatus 'exact'|'moved'|'modified'|'removed'|'missing_file'
---@class OpencodeReviewCommentResolution
---@field status OpencodeReviewCommentStatus
---@field start_line? integer
---@field end_line? integer
---@field current_code? string
---@class OpencodeContextReviewComment
---@field id integer
---@field file string
---@field side OpencodeReviewCommentSide
---@field start_line integer
---@field end_line integer
---@field code string
---@field comment string
---@field session_id string
---@field from? string
---@field to? string
---@field context_before string[]
---@field context_after string[]
---@field anchor_side_line integer
---@field resolution? OpencodeReviewCommentResolution
---@class OpencodeContextCursorData
---@field line number
---@field column number
---@field line_content string
---@field lines_before string[]
---@field lines_after string[]
---@class OpencodeContextFile
---@field path string
---@field name string
---@field extension string
---@field sent_at? number
---@class OpencodeModelModalities
---@field input ('text'|'image'|'audio'|'video')[] Supported input modalities
---@field output ('text')[] Supported output modalities
---@class OpencodeModelCost
---@field input number Cost per input token
---@field output number Cost per output token
---@field cache_read number|nil Cost per cache read token
---@field cache_write number|nil Cost per cache write token
---@class OpencodeModelLimits
---@field context number Maximum context length in tokens
---@field output number Maximum output length in tokens
---@class OpencodeModelVariant
---@field reasoningEffort string Reasoning effort level (e.g., "low", "medium", "high")
---@class OpencodeModel
---@field id string Unique identifier for the model
---@field name string Human-readable name of the model
---@field attachment boolean Whether the model supports file attachments
---@field reasoning boolean Whether the model supports reasoning/thinking
---@field temperature boolean Whether the model supports temperature parameter
---@field tool_call boolean Whether the model supports tool calling
---@field knowledge string|nil Knowledge cutoff date (e.g., "2024-04")
---@field release_date string Release date in YYYY-MM-DD format
---@field last_updated string Last updated date in YYYY-MM-DD format
---@field modalities OpencodeModelModalities Supported input/output modalities
---@field open_weights boolean Whether the model has open weights
---@field limit OpencodeModelLimits Token limits for the model
---@field cost OpencodeModelCost Pricing information for the model
---@field variants table<string, OpencodeModelVariant>|nil Model variants with different configurations
---@class OpencodeProvider
---@field id string Unique identifier for the provider
---@field env string[] Required environment variables for authentication
---@field npm string NPM package name for the provider SDK
---@field api string|nil Base API URL for the provider
---@field name string Human-readable name of the provider
---@field doc string|nil Documentation URL for the provider
---@field models table<string, OpencodeModel> Map of model ID to model configuration
---@class OpencodeProvidersResponse
---@field providers OpencodeProvider[] List of available providers
---@field default table<string, string> Map of provider ID to default model ID
---@class OpencodeToolListItem
---@field id string Tool identifier
---@field description string Tool description
---@field parameters any JSON schema parameters for the tool
---@alias OpencodeToolList OpencodeToolListItem[]
---@class OpencodeAgentPermissionBash
---@field [string] string Permission level ('allow', 'deny', etc.)
---@class OpencodeAgentPermission
---@field edit string Permission level for edit operations
---@field webfetch string Permission level for web fetch operations
---@field bash OpencodeAgentPermissionBash Bash command permissions
---@class OpencodeAgentModel
---@field providerID string Provider identifier
---@field modelID string Model identifier
---@class OpencodeAgent
---@field name string Unique identifier for the agent
---@field description string Human-readable description of the agent
---@field tools table<string, boolean> Map of tool names to availability
---@field options table Additional configuration options
---@field permission OpencodeAgentPermission Permissions for various operations
---@field mode 'primary'|'subagent'|'all' Agent execution mode
---@field builtIn boolean Whether this is a built-in agent
---@field model OpencodeAgentModel|nil Optional model configuration
---@field prompt string|nil Optional custom prompt for the agent
---@field temperature number|nil Optional temperature setting
---@class OpencodeSlashCommand
---@field slash_cmd string The command trigger (e.g., "/help")
---@field desc string|nil Description of the command
---@field fn fun(args:string[]|nil):nil|Promise<any>|any Function to execute the command
---@field args boolean Whether the command accepts arguments
---@class OpencodeRevertSummary
---@field messages number Number of messages reverted
---@field tool_calls number Number of tool calls reverted
---@field files table<string, {additions: number, deletions: number}> Summary of file changes reverted
---@class OpencodeSelectionRange
---@field start number Starting line number (inclusive)
---@field stop number Ending line number (inclusive)
---@class OpencodeSessionStatusInfo
---@field type 'idle'|'busy'|'retry' Current status of the session
---@field message? string Human-readable detail (populated for `retry`)
---@field attempt? number Retry attempt counter (populated for `retry`)
---@field next? number Server-side timestamp of the next retry (populated for `retry`)
---@field action? table Optional retry action metadata (populated for `retry`)