-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathcursor_data.json
More file actions
705 lines (705 loc) · 202 KB
/
cursor_data.json
File metadata and controls
705 lines (705 loc) · 202 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
[
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.updated",
"properties": {
"info": {
"time": { "created": 1761846174794 },
"id": "msg_a3637244a001FDRDfoBYVPEGpd",
"role": "user",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a3637244a001FDRDfoBYVPEGpd",
"text": "what is this doing",
"id": "prt_a3637244b0011ts76CwACOFqk7",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a3637244a001FDRDfoBYVPEGpd",
"synthetic": true,
"text": "Called the Read tool with the following input: {\"filePath\":\"/home/francis/Projects/_nvim/opencode.nvim/lua/opencode/context.lua\"}",
"id": "prt_a3637244e0015gCGQiQq5R8bn0",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a3637244a001FDRDfoBYVPEGpd",
"synthetic": true,
"text": "<file>\n00001| -- Gathers editor context\n00002| \n00003| local util = require('opencode.util')\n00004| local config = require('opencode.config') --[[@as OpencodeConfig]]\n00005| local state = require('opencode.state')\n00006| \n00007| local M = {}\n00008| \n00009| ---@type OpencodeContext\n00010| M.context = {\n00011| -- current file\n00012| current_file = nil,\n00013| cursor_data = nil,\n00014| \n00015| -- attachments\n00016| mentioned_files = nil,\n00017| selections = {},\n00018| linter_errors = {},\n00019| mentioned_subagents = {},\n00020| }\n00021| \n00022| function M.unload_attachments()\n00023| M.context.mentioned_files = nil\n00024| M.context.selections = nil\n00025| M.context.linter_errors = nil\n00026| end\n00027| \n00028| function M.get_current_buf()\n00029| local curr_buf = state.current_code_buf or vim.api.nvim_get_current_buf()\n00030| if util.is_buf_a_file(curr_buf) then\n00031| return curr_buf, state.last_code_win_before_opencode or vim.api.nvim_get_current_win()\n00032| end\n00033| end\n00034| \n00035| function M.load()\n00036| local buf, win = M.get_current_buf()\n00037| \n00038| if buf then\n00039| local current_file = M.get_current_file(buf)\n00040| local cursor_data = M.get_current_cursor_data(buf, win)\n00041| \n00042| M.context.current_file = current_file\n00043| M.context.cursor_data = cursor_data\n00044| M.context.linter_errors = M.get_diagnostics(buf)\n00045| end\n00046| \n00047| local current_selection = M.get_current_selection()\n00048| if current_selection then\n00049| local selection = M.new_selection(M.context.current_file, current_selection.text, current_selection.lines)\n00050| M.add_selection(selection)\n00051| end\n00052| state.context_updated_at = vim.uv.now()\n00053| end\n00054| \n00055| -- Checks if a context feature is enabled in config or state\n00056| ---@param context_key string\n00057| ---@return boolean\n00058| function M.is_context_enabled(context_key)\n00059| local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')\n00060| local is_state_enabled = vim.tbl_get(state, 'current_context_config', context_key, 'enabled')\n00061| \n00062| if is_state_enabled ~= nil then\n00063| return is_state_enabled\n00064| else\n00065| return is_enabled\n00066| end\n00067| end\n00068| \n00069| function M.get_diagnostics(buf)\n00070| if not M.is_context_enabled('diagnostics') then\n00071| return nil\n00072| end\n00073| \n00074| local diagnostic_conf = config.context and state.current_context_config.diagnostics or config.context.diagnostics\n00075| \n00076| local severity_levels = {}\n00077| if diagnostic_conf.error then\n00078| table.insert(severity_levels, vim.diagnostic.severity.ERROR)\n00079| end\n00080| if diagnostic_conf.warning then\n00081| table.insert(severity_levels, vim.diagnostic.severity.WARN)\n00082| end\n00083| if diagnostic_conf.info then\n00084| table.insert(severity_levels, vim.diagnostic.severity.INFO)\n00085| end\n00086| \n00087| local diagnostics = vim.diagnostic.get(buf, { severity = severity_levels })\n00088| if #diagnostics == 0 then\n00089| return {}\n00090| end\n00091| \n00092| return diagnostics\n00093| end\n00094| \n00095| function M.new_selection(file, content, lines)\n00096| return {\n00097| file = file,\n00098| content = util.indent_code_block(content),\n00099| lines = lines,\n00100| }\n00101| end\n00102| \n00103| function M.add_selection(selection)\n00104| if not M.context.selections then\n00105| M.context.selections = {}\n00106| end\n00107| \n00108| table.insert(M.context.selections, selection)\n00109| \n00110| state.context_updated_at = vim.uv.now()\n00111| end\n00112| \n00113| function M.remove_selection(selection)\n00114| if not M.context.selections then\n00115| return\n00116| end\n00117| \n00118| for i, sel in ipairs(M.context.selections) do\n00119| if sel.file.path == selection.file.path and sel.lines == selection.lines then\n00120| table.remove(M.context.selections, i)\n00121| break\n00122| end\n00123| end\n00124| state.context_updated_at = vim.uv.now()\n00125| end\n00126| \n00127| function M.clear_selections()\n00128| M.context.selections = nil\n00129| end\n00130| \n00131| function M.add_file(file)\n00132| if not M.context.mentioned_files then\n00133| M.context.mentioned_files = {}\n00134| end\n00135| \n00136| local is_file = vim.fn.filereadable(file) == 1\n00137| local is_dir = vim.fn.isdirectory(file) == 1\n00138| if not is_file and not is_dir then\n00139| vim.notify('File not added to context. Could not read.')\n00140| return\n00141| end\n00142| \n00143| file = vim.fn.fnamemodify(file, ':p')\n00144| \n00145| if not vim.tbl_contains(M.context.mentioned_files, file) then\n00146| table.insert(M.context.mentioned_files, file)\n00147| end\n00148| end\n00149| \n00150| function M.remove_file(file)\n00151| file = vim.fn.fnamemodify(file, ':p')\n00152| if not M.context.mentioned_files then\n00153| return\n00154| end\n00155| \n00156| for i, f in ipairs(M.context.mentioned_files) do\n00157| if f == file then\n00158| table.remove(M.context.mentioned_files, i)\n00159| break\n00160| end\n00161| end\n00162| state.context_updated_at = vim.uv.now()\n00163| end\n00164| \n00165| function M.clear_files()\n00166| M.context.mentioned_files = nil\n00167| end\n00168| \n00169| function M.add_subagent(subagent)\n00170| if not M.context.mentioned_subagents then\n00171| M.context.mentioned_subagents = {}\n00172| end\n00173| \n00174| if not vim.tbl_contains(M.context.mentioned_subagents, subagent) then\n00175| table.insert(M.context.mentioned_subagents, subagent)\n00176| end\n00177| state.context_updated_at = vim.uv.now()\n00178| end\n00179| \n00180| function M.remove_subagent(subagent)\n00181| if not M.context.mentioned_subagents then\n00182| return\n00183| end\n00184| \n00185| for i, a in ipairs(M.context.mentioned_subagents) do\n00186| if a == subagent then\n00187| table.remove(M.context.mentioned_subagents, i)\n00188| break\n00189| end\n00190| end\n00191| state.context_updated_at = vim.uv.now()\n00192| end\n00193| \n00194| function M.clear_subagents()\n00195| M.context.mentioned_subagents = nil\n00196| end\n00197| \n00198| ---@param opts? OpencodeContextConfig\n00199| ---@return OpencodeContext\n00200| function M.delta_context(opts)\n00201| opts = opts or config.context\n00202| if opts.enabled == false then\n00203| return {\n00204| current_file = nil,\n00205| mentioned_files = nil,\n00206| selections = nil,\n00207| linter_errors = nil,\n00208| cursor_data = nil,\n00209| mentioned_subagents = nil,\n00210| }\n00211| end\n00212| \n00213| local context = vim.deepcopy(M.context)\n00214| local last_context = state.last_sent_context\n00215| if not last_context then\n00216| return context\n00217| end\n00218| \n00219| -- no need to send file context again\n00220| if\n00221| context.current_file\n00222| and last_context.current_file\n00223| and context.current_file.name == last_context.current_file.name\n00224| then\n00225| context.current_file = nil\n00226| end\n00227| \n00228| -- no need to send subagents again\n00229| if\n00230| context.mentioned_subagents\n00231| and last_context.mentioned_subagents\n00232| and vim.deep_equal(context.mentioned_subagents, last_context.mentioned_subagents)\n00233| then\n00234| context.mentioned_subagents = nil\n00235| end\n00236| \n00237| return context\n00238| end\n00239| \n00240| function M.get_current_file(buf)\n00241| if not M.is_context_enabled('current_file') then\n00242| return nil\n00243| end\n00244| local file = vim.api.nvim_buf_get_name(buf)\n00245| if not file or file == '' or vim.fn.filereadable(file) ~= 1 then\n00246| return nil\n00247| end\n00248| return {\n00249| path = file,\n00250| name = vim.fn.fnamemodify(file, ':t'),\n00251| extension = vim.fn.fnamemodify(file, ':e'),\n00252| }\n00253| end\n00254| \n00255| function M.get_current_cursor_data(buf, win)\n00256| if not M.is_context_enabled('cursor_data') then\n00257| return nil\n00258| end\n00259| \n00260| local cursor_pos = vim.fn.getcurpos(win)\n00261| local cursor_content = vim.trim(vim.api.nvim_buf_get_lines(buf, cursor_pos[2] - 1, cursor_pos[2], false)[1] or '')\n00262| return { line = cursor_pos[2], column = cursor_pos[3], line_content = cursor_content }\n00263| end\n00264| \n00265| function M.get_current_selection()\n00266| if not M.is_context_enabled('selection') then\n00267| return nil\n00268| end\n00269| \n00270| -- Return nil if not in a visual mode\n00271| if not vim.fn.mode():match('[vV\\022]') then\n00272| return nil\n00273| end\n00274| \n00275| -- Save current position and register state\n00276| local current_pos = vim.fn.getpos('.')\n00277| local old_reg = vim.fn.getreg('x')\n00278| local old_regtype = vim.fn.getregtype('x')\n00279| \n00280| -- Capture selection text and position\n00281| vim.cmd('normal! \"xy')\n00282| local text = vim.fn.getreg('x')\n00283| \n00284| -- Get line numbers\n00285| vim.cmd('normal! `<')\n00286| local start_line = vim.fn.line('.')\n00287| vim.cmd('normal! `>')\n00288| local end_line = vim.fn.line('.')\n00289| \n00290| -- Restore state\n00291| vim.fn.setreg('x', old_reg, old_regtype)\n00292| vim.cmd('normal! gv')\n00293| vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 'nx', true)\n00294| vim.fn.setpos('.', current_pos)\n00295| \n00296| if not text or text == '' then\n00297| return nil\n00298| end\n00299| \n00300| return {\n00301| text = text and text:match('[^%s]') and text or nil,\n00302| lines = start_line .. ', ' .. end_line,\n00303| }\n00304| end\n00305| \n00306| local function format_file_part(path, prompt)\n00307| local rel_path = vim.fn.fnamemodify(path, ':~:.')\n00308| local mention = '@' .. rel_path\n00309| local pos = prompt and prompt:find(mention)\n00310| pos = pos and pos - 1 or 0 -- convert to 0-based index\n00311| \n00312| local file_part = { filename = rel_path, type = 'file', mime = 'text/plain', url = 'file://' .. path }\n00313| if prompt then\n00314| file_part.source = {\n00315| path = path,\n00316| type = 'file',\n00317| text = { start = pos, value = mention, ['end'] = pos + #mention },\n00318| }\n00319| end\n00320| return file_part\n00321| end\n00322| \n00323| ---@param selection OpencodeContextSelection\n00324| local function format_selection_part(selection)\n00325| local lang = util.get_markdown_filetype(selection.file and selection.file.name or '') or ''\n00326| \n00327| return {\n00328| type = 'text',\n00329| text = vim.json.encode({\n00330| context_type = 'selection',\n00331| file = selection.file,\n00332| content = string.format('`````%s\\n%s\\n`````', lang, selection.content),\n00333| lines = selection.lines,\n00334| }),\n00335| synthetic = true,\n00336| }\n00337| end\n00338| \n00339| local function format_diagnostics_part(diagnostics)\n00340| return {\n00341| type = 'text',\n00342| text = vim.json.encode({ context_type = 'diagnostics', content = diagnostics }),\n00343| synthetic = true,\n00344| }\n00345| end\n00346| \n00347| local function format_cursor_data_part(cursor_data)\n00348| local buf = (M.get_current_buf() or 0) --[[@as integer]]\n00349| local lang = util.get_markdown_filetype(vim.api.nvim_buf_get_name(buf)) or ''\n00350| return {\n00351| type = 'text',\n00352| text = vim.json.encode({\n00353| context_type = 'cursor-data',\n00354| line = cursor_data.line,\n00355| column = cursor_data.column,\n00356| line_content = string.format('`````%s\\n%s\\n`````', lang, cursor_data.line_content),\n00357| }),\n00358| synthetic = true,\n00359| }\n00360| end\n00361| \n00362| local function format_subagents_part(agent, prompt)\n00363| local mention = '@' .. agent\n00364| local pos = prompt:find(mention)\n00365| pos = pos and pos - 1 or 0 -- convert to 0-based index\n00366| \n00367| return {\n00368| type = 'agent',\n00369| name = agent,\n00370| source = { value = mention, start = pos, ['end'] = pos + #mention },\n00371| }\n00372| end\n00373| \n00374| --- Formats a prompt and context into message with parts for the opencode API\n00375| ---@param prompt string\n00376| ---@param opts? OpencodeContextConfig|nil\n00377| ---@return OpencodeMessagePart[]\n00378| function M.format_message(prompt, opts)\n00379| opts = opts or config.context\n00380| local context = M.delta_context(opts)\n00381| context.prompt = prompt\n00382| \n00383| local parts = { { type = 'text', text = prompt } }\n00384| \n00385| for _, path in ipairs(context.mentioned_files or {}) do\n00386| -- don't resend current file if it's also mentioned\n00387| if not context.current_file or path ~= context.current_file.path then\n00388| table.insert(parts, format_file_part(path, prompt))\n00389| end\n00390| end\n00391| \n00392| for _, sel in ipairs(context.selections or {}) do\n00393| table.insert(parts, format_selection_part(sel))\n00394| end\n00395| \n00396| for _, agent in ipairs(context.mentioned_subagents or {}) do\n00397| table.insert(parts, format_subagents_part(agent, prompt))\n00398| end\n00399| \n00400| if context.current_file then\n00401| table.insert(parts, format_file_part(context.current_file.path))\n00402| end\n00403| \n00404| if context.linter_errors then\n00405| table.insert(parts, format_diagnostics_part(context.linter_errors))\n00406| end\n00407| \n00408| if context.cursor_data then\n00409| table.insert(parts, format_cursor_data_part(context.cursor_data))\n00410| end\n00411| \n00412| return parts\n00413| end\n00414| \n00415| ---@param text string\n00416| ---@param context_type string|nil\n00417| function M.decode_json_context(text, context_type)\n00418| local ok, result = pcall(vim.json.decode, text)\n00419| if not ok or (context_type and result.context_type ~= context_type) then\n00420| return nil\n00421| end\n00422| return result\n00423| end\n00424| \n00425| --- Extracts context from an OpencodeMessage (with parts)\n00426| ---@param message { parts: OpencodeMessagePart[] }\n00427| ---@return { prompt: string, selected_text: string|nil, current_file: string|nil, mentioned_files: string[]|nil}\n00428| function M.extract_from_opencode_message(message)\n00429| local ctx = { prompt = nil, selected_text = nil, current_file = nil }\n00430| \n00431| local handlers = {\n00432| text = function(part)\n00433| ctx.prompt = ctx.prompt or part.text or ''\n00434| end,\n00435| text_context = function(part)\n00436| local json = M.decode_json_context(part.text, 'selection')\n00437| ctx.selected_text = json and json.content or ctx.selected_text\n00438| end,\n00439| file = function(part)\n00440| if not part.source then\n00441| ctx.current_file = part.filename\n00442| end\n00443| end,\n00444| }\n00445| \n00446| for _, part in ipairs(message and message.parts or {}) do\n00447| local handler = handlers[part.type .. (part.synthetic and '_context' or '')]\n00448| if handler then\n00449| handler(part)\n00450| end\n00451| \n00452| if ctx.prompt and ctx.selected_text and ctx.current_file then\n00453| break\n00454| end\n00455| end\n00456| \n00457| return ctx\n00458| end\n00459| \n00460| function M.extract_from_message_legacy(text)\n00461| local current_file = M.extract_legacy_tag('current-file', text)\n00462| local context = {\n00463| prompt = M.extract_legacy_tag('user-query', text) or text,\n00464| selected_text = M.extract_legacy_tag('manually-added-selection', text),\n00465| current_file = current_file and current_file:match('Path: (.+)') or nil,\n00466| }\n00467| return context\n00468| end\n00469| \n00470| function M.extract_legacy_tag(tag, text)\n00471| local start_tag = '<' .. tag .. '>'\n00472| local end_tag = '</' .. tag .. '>'\n00473| \n00474| local pattern = vim.pesc(start_tag) .. '(.-)' .. vim.pesc(end_tag)\n00475| local content = text:match(pattern)\n00476| \n00477| if content then\n00478| return vim.trim(content)\n00479| end\n00480| \n00481| -- Fallback to the original method if pattern matching fails\n00482| local query_start = text:find(start_tag)\n00483| local query_end = text:find(end_tag)\n00484| \n00485| if query_start and query_end then\n00486| local query_content = text:sub(query_start + #start_tag, query_end - 1)\n00487| return vim.trim(query_content)\n00488| end\n00489| \n00490| return nil\n00491| end\n00492| \n00493| function M.setup()\n00494| state.subscribe({ 'current_code_buf', 'current_context_config', 'is_opencode_focused' }, function(a)\n00495| M.load()\n00496| end)\n00497| \n00498| vim.api.nvim_create_autocmd('BufWritePost', {\n00499| pattern = '*',\n00500| callback = function(args)\n00501| local buf = args.buf\n00502| local curr_buf = state.current_code_buf or vim.api.nvim_get_current_buf()\n00503| if buf == curr_buf and util.is_buf_a_file(buf) then\n00504| M.load()\n00505| end\n00506| end,\n00507| })\n00508| \n00509| vim.api.nvim_create_autocmd('DiagnosticChanged', {\n00510| pattern = '*',\n00511| callback = function(args)\n00512| local buf = args.buf\n00513| local curr_buf = state.current_code_buf or vim.api.nvim_get_current_buf()\n00514| if buf == curr_buf and util.is_buf_a_file(buf) and M.is_context_enabled('diagnostics') then\n00515| M.load()\n00516| end\n00517| end,\n00518| })\n00519| end\n00520| \n00521| return M\n00522| \n</file>",
"id": "prt_a3637244e0025IN5Ze5THoeXcU",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "file",
"url": "file:///home/francis/Projects/_nvim/opencode.nvim/lua/opencode/context.lua",
"messageID": "msg_a3637244a001FDRDfoBYVPEGpd",
"id": "prt_a3637244e003lil8R9cdkNVRup",
"mime": "text/plain",
"filename": "lua/opencode/context.lua",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a3637244a001FDRDfoBYVPEGpd",
"synthetic": true,
"text": "{\"column\":1,\"line_content\":\"`````lua\\nlocal is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')\\n`````\",\"context_type\":\"cursor-data\",\"line\":59}",
"id": "prt_a3637244b002S0euEXp3CXpwDw",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "session.updated",
"properties": {
"info": {
"version": "0.15.20",
"directory": "/home/francis/Projects/_nvim/opencode.nvim",
"title": "New session - 2025-10-30T17:42:54.734Z",
"time": { "created": 1761846174734, "updated": 1761846174807 },
"id": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"projectID": "29d43526f88157cd4edd071b899dd01f240b771b"
}
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.updated",
"properties": {
"info": {
"role": "assistant",
"time": { "created": 1761846176666 },
"path": {
"root": "/home/francis/Projects/_nvim/opencode.nvim",
"cwd": "/home/francis/Projects/_nvim/opencode.nvim"
},
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"mode": "build",
"parentID": "msg_a3637244a001FDRDfoBYVPEGpd",
"id": "msg_a36372b9a001M1lQEix4SK5QE5",
"modelID": "gpt-5-mini",
"providerID": "github-copilot",
"cost": 0,
"tokens": { "output": 0, "input": 0, "reasoning": 0, "cache": { "write": 0, "read": 0 } },
"system": [
"You are a coding agent running in the opencode, a terminal-based coding assistant. opencode is an open source project. You are expected to be precise, safe, and helpful.\n\nYour capabilities:\n\n- Receive user prompts and other context provided by the harness, such as files in the workspace.\n- Communicate with the user by streaming thinking & responses, and by making & updating plans.\n- Emit function calls to run terminal commands and apply edits. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the \"Sandbox and approvals\" section.\n\nWithin this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n# How you work\n\n## Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# AGENTS.md spec\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n## Responsiveness\n\n### Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you’re about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you’re about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8–12 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what’s been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it’s part of a larger grouped action.\n\n**Examples:**\n\n- “I’ve explored the repo; now checking the API route definitions.”\n- “Next, I’ll patch the config and update the related tests.”\n- “I’m about to scaffold the CLI commands and helper functions.”\n- “Ok cool, so I’ve wrapped my head around the repo. Now digging into the API routes.”\n- “Config’s looking tidy. Next up is editing helpers to keep things in sync.”\n- “Finished poking at the DB gateway. I will now chase down error handling.”\n- “Alright, build pipeline order is interesting. Checking how it reports failures.”\n- “Spotted a clever caching util; now hunting where it gets used.”\n\n## Planning\n\nYou have access to an `todowrite` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nDo not repeat the full contents of the plan after an `todowrite` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the\nprevious step, and make sure to mark it as completed before moving on to the\nnext step. It may be the case that you complete all steps in your plan after a\nsingle pass of implementation. If this is the case, you can simply mark all the\nplanned steps as completed. Sometimes, you may need to change plans in the\nmiddle of a task: call `todowrite` with the updated plan and make sure to provide an `explanation` of the rationale when doing so.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n### Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the `edit` tool to edit files \n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after calling `edit` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Do not add inline comments within code unless explicitly requested.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"【F:README.md†L5-L14】\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n## Sandbox and approvals\n\nThe Codex CLI harness supports several different sandboxing, and approval configurations that the user can choose from.\n\nFilesystem sandboxing prevents you from editing files without user approval. The options are:\n\n- **read-only**: You can only read files.\n- **workspace-write**: You can read files. You can write to files in your workspace folder, but not outside it.\n- **danger-full-access**: No filesystem sandboxing.\n\nNetwork sandboxing prevents you from accessing network without approval. Options are\n\n- **restricted**\n- **enabled**\n\nApprovals are your mechanism to get user consent to perform more privileged actions. Although they introduce friction to the user because your work is paused until the user responds, you should leverage them to accomplish your important work. Do not let these settings or the sandbox deter you from attempting to accomplish the user's task. Approval options are\n\n- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe \"read\" commands.\n- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.\n- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)\n- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is pared with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.\n\nWhen you are running with approvals `on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:\n\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /tmp)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for\n- (For all of these, you should weigh alternative paths that do not require approval.)\n\nNote that when sandboxing is set to read-only, you'll need to request approval for any command that isn't a read.\n\nYou will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing ON, and approval on-failure.\n\n## Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete. \n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.\n\n## Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n## Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n## Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user’s style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using `edit`, there's no need to tell users to \"save the file\" or \"copy the code into a file\"—just reference the file path.\n\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there’s something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n### Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity — they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1–3 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Leave no blank line before the first bullet under a header.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4–6 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it’s a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don’t mix unrelated concepts in the same section.\n- Order sections from general → specific → supporting info.\n- For subsections (e.g., “Binaries” under “Rust Workspace”), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results → use clear headers and grouped bullets.\n - Simple results → minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., “Runs tests” not “This will run tests”).\n- Keep descriptions self-contained; don’t refer to “above” or “below”.\n- Use parallel structure in lists for consistency.\n\n**Don’t**\n\n- Don’t use literal words “bold” or “monospace” in the content.\n- Don’t nest bullets or create deep hierarchies.\n- Don’t output ANSI escape codes directly — the CLI renderer applies them.\n- Don’t cram unrelated keywords into a single bullet; split for clarity.\n- Don’t let keyword lists run long — wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what’s needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Tool Guidelines\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n- Read files in chunks with a max chunk size of 250 lines. Do not use python scripts to attempt to output larger chunks of a file. Command line output will be truncated after 10 kilobytes or 256 lines of output, regardless of the command used.\n\n## `todowrite`\n\nA tool named `todowrite` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.\n\nTo create a new plan, call `todowrite` with a short list of 1‑sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, or `completed`).\n\nWhen steps have been completed, use `todowrite` to mark each finished step as\n`completed` and the next step you are working on as `in_progress`. There should\nalways be exactly one `in_progress` step until everything is done. You can mark\nmultiple items as complete in a single `todowrite` call.\n\nIf all steps are complete, ensure you call `todowrite` to mark all steps as `completed`.\n",
"Here is some useful information about the environment you are running in:\n<env>\n Working directory: /home/francis/Projects/_nvim/opencode.nvim\n Is directory a git repo: yes\n Platform: linux\n Today's date: Thu Oct 30 2025\n</env>\n<project>\n .github/\n\tworkflows/\n\t\ttests.yml\nlua/\n\topencode/\n\t\tui/\n\t\t\tcompletion/\n\t\t\t\tengines/\n\t\t\t\t\tblink_cmp.lua\n\t\t\t\t\tnvim_cmp.lua\n\t\t\t\t\tvim_complete.lua\n\t\t\t\tcommands.lua\n\t\t\t\tcontext.lua\n\t\t\t\tfiles.lua\n\t\t\t\tsort.lua\n\t\t\t\tsubagents.lua\n\t\t\tautocmds.lua\n\t\t\tcompletion.lua\n\t\t\tcontext_bar.lua\n\t\t\tcontextual_actions.lua\n\t\t\tdebug_helper.lua\n\t\t\tdiff_tab.lua\n\t\t\tfile_picker.lua\n\t\t\tfooter.lua\n\t\t\tformatter.lua\n\t\t\thighlight.lua\n\t\t\ticons.lua\n\t\t\tinput_window.lua\n\t\t\tloading_animation.lua\n\t\t\tmention.lua\n\t\t\tnavigation.lua\n\t\t\toutput_window.lua\n\t\t\toutput.lua\n\t\t\tpicker.lua\n\t\t\tprompt_guard_indicator.lua\n\t\t\trender_state.lua\n\t\t\trenderer.lua\n\t\t\tsession_picker.lua\n\t\t\ttimer.lua\n\t\t\ttopbar.lua\n\t\t\tui.lua\n\t\tapi_client.lua\n\t\tapi.lua\n\t\tconfig_file.lua\n\t\tconfig.lua\n\t\tcontext.lua\n\t\tcore.lua\n\t\tcurl.lua\n\t\tevent_manager.lua\n\t\tgit_review.lua\n\t\thealth.lua\n\t\thistory.lua\n\t\tid.lua\n\t\tinit.lua\n\t\tkeymap.lua\n\t\topencode_server.lua\n\t\tpromise.lua\n\t\tprovider.lua\n\t\treactive_state.lua\n\t\treview.lua\n\t\tserver_job.lua\n\t\tsession.lua\n\t\tsnapshot.lua\n\t\tstate.lua\n\t\tthrottling_emitter.lua\n\t\ttypes.lua\n\t\tutil.lua\nplugin/\n\topencode.lua\ntests/\n\tdata/\n\t\tansi-codes.expected.json\n\t\tansi-codes.json\n\t\tapi-abort.expected.json\n\t\tapi-abort.json\n\t\tapi-error.expected.json\n\t\tapi-error.json\n\t\tcursor_data.json\n\t\tdiff.expected.json\n\t\tdiff.json\n\t\tmarkdown-codefence.expected.json\n\t\tmarkdown-codefence.json\n\t\tmentions-with-ranges.expected.json\n\t\tmentions-with-ranges.json\n\t\tmessage-removal.expected.json\n\t\tmessage-removal.json\n\t\tperf.expected.json\n\t\tperf.json\n\t\tpermission-denied.expected.json\n\t\tpermission-denied.json\n\t\tpermission-prompt.expected.json\n\t\tpermission-prompt.json\n\t\tpermission.expected.json\n\t\tpermission.json\n\t\tplanning.expected.json\n\t\tplanning.json\n\t\tredo-all.expected.json\n\t\tredo-all.json\n\t\tredo-once.expected.json\n\t\tredo-once.json\n\t\trevert.expected.json\n\t\trevert.json\n\t\tselection.expected.json\n\t\tselection.json\n\t\tshifting-and-multiple-perms.expected.json\n\t\tshifting-and-multiple-perms.json\n\t\tsimple-session.expected.json\n\t\tsimple-session.json\n\t\ttool-invalid.expected.json\n\t\ttool-invalid.json\n\t\tupdating-text.expected.json\n\t\tupdating-text.json\n\tmanual/\n\t\tinit_replay.lua\n\t\tQUICKSTART.md\n\t\tREADME.md\n\t\tregenerate_expected.sh\n\t\trenderer_replay.lua\n\t\treplay.ps1\n\t\trun_replay.sh\n\tminimal/\n\t\tinit.lua\n\t\tplugin_spec.lua\n\tmocks/\n\t\tsession_list.lua\n\tunit/\n\t\tapi_client_spec.lua\n\t\tapi_spec.lua\n\t\tconfig_file_spec.lua\n\t\tconfig_spec.lua\n\t\tcontext_bar_spec.lua\n\t\tcontext_completion_spec.lua\n\t\tcontext_spec.lua\n\t\tcore_spec.lua\n\t\tevent_manager_spec.lua\n\t\tid_spec.lua\n\t\tinit_spec.lua\n\t\tkeymap_spec.lua\n\t\topencode_server_spec.lua\n\t\trender_state_spec.lua\n\t\trenderer_spec.lua\n\t\tserver_job_spec.lua\n\t\tsession_spec.lua\n\t\tsnapshot_spec.lua\n\t\tstate_spec.lua\n\t\ttimer_spec.lua\n\t\tutil_spec.lua\n\thelpers.lua\n.emmyrc.json\n.gitignore\n.stylua.toml\nLICENSE\nREADME.md\nrun_tests.sh\ntest.txt\n</project>\n# AGENTS.md\n\n## Build, Lint, and Test\n\n- **Run all tests:** `./run_tests.sh`\n- **Minimal tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/minimal', {minimal_init = './tests/minimal/init.lua', sequential = true})\"`\n- **Unit tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Run a single test:** Replace the directory in the above command with the test file path, e.g.:\n `nvim --headless -u tests/manual/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit/job_spec.lua', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Manual/Visual tests:** `./tests/manual/run_replay.sh` - Replay captured event data for visual testing\n- **Debug rendering in headless mode:**\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/FILE.json\" \"+ReplayAll 0\" \"+qa\"`\n This will replay events and dump the output buffer to stdout, useful for debugging rendering issues without a UI.\n You can also run to just a specific message # with (e.g. message # 12):\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/message-removal.json\" \"+ReplayNext 12\" \"+qa\"`\n- **Lint:** No explicit lint command; follow Lua best practices.\n\n## Code Style Guidelines\n\n- **Imports:** `local mod = require('mod')` at the top. Group standard, then project imports.\n- **Formatting:** 2 spaces per indent. No trailing whitespace. Lines ≤ 100 chars.\n- **Types:** Use Lua annotations (`---@class`, `---@field`, etc.) for public APIs/config.\n- **Naming:** Modules: `snake_case.lua`; functions/vars: `snake_case`; classes: `CamelCase`.\n- **Error Handling:** Use `vim.notify` for user-facing errors. Return early on error.\n- **Comments:** Only when necessary for clarity. Prefer self-explanatory code.\n- **Functions:** Prefer local functions. Use `M.func` for module exports.\n- **Config:** Centralize in `config.lua`. Use deep merge for user overrides.\n- **Tests:** Place in `tests/minimal/` or `tests/unit/`. Manual/visual tests in `tests/manual/`.\n\n_Agentic coding agents must follow these conventions strictly for consistency and reliability._\n"
]
}
}
},
{
"type": "session.updated",
"properties": {
"info": {
"version": "0.15.20",
"directory": "/home/francis/Projects/_nvim/opencode.nvim",
"title": "New session - 2025-10-30T17:42:54.734Z",
"time": { "created": 1761846174734, "updated": 1761846176690 },
"summary": { "diffs": [] },
"id": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"projectID": "29d43526f88157cd4edd071b899dd01f240b771b"
}
}
},
{
"type": "message.updated",
"properties": {
"info": {
"role": "user",
"time": { "created": 1761846174794 },
"summary": { "diffs": [] },
"id": "msg_a3637244a001FDRDfoBYVPEGpd",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "session.updated",
"properties": {
"info": {
"version": "0.15.20",
"directory": "/home/francis/Projects/_nvim/opencode.nvim",
"title": "Analyzing opencode/context.lua cursor-data handling",
"time": { "created": 1761846174734, "updated": 1761846178487 },
"summary": { "diffs": [] },
"id": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"projectID": "29d43526f88157cd4edd071b899dd01f240b771b"
}
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "step-start",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"snapshot": "41a7223d54ec54b5d1ef4fd276420230fc159812",
"id": "prt_a36374121001y0L7HUbCtVdq5o",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": "_get"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " ("
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " read"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Con",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " Con"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": "]."
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context`",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": "`"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " intermediate"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " the"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " value"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " key"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n -",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " -"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": "enabled"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " returned"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": "from"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": ".selection"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": ".enabled"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled == false`, the function returns `false` (",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " ("
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled == false`, the function returns `false` (state overrides config). If the state value is `",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " `"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled == false`, the function returns `false` (state overrides config). If the state value is `nil`, the config value is used.\n- Why this matters: `",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " `"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled == false`, the function returns `false` (state overrides config). If the state value is `nil`, the config value is used.\n- Why this matters: `vim",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": "vim"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled == false`, the function returns `false` (state overrides config). If the state value is `nil`, the config value is used.\n- Why this matters: `vim.tbl_get` provides safe nested access; using it",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " it"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "start": 1761846182179 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled == false`, the function returns `false` (state overrides config). If the state value is `nil`, the config value is used.\n- Why this matters: `vim.tbl_get` provides safe nested access; using it avoids runtime errors when some parts of the nested",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
},
"delta": " nested"
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "text",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"time": { "end": 1761846183728, "start": 1761846183728 },
"text": "**Explanation**\n\n- The line `local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')` (in `lua/opencode/context.lua:58`) uses `vim.tbl_get` to safely read a nested field from a table.\n- Concretely it attempts to read `config.context[context_key].enabled` but without throwing an error if `config.context` or `config.context[context_key]` is nil. If any intermediate key is missing it returns `nil`.\n- In the surrounding function `M.is_context_enabled`, that value is the default config value for the given context key. The function then checks the state override:\n - If `state.current_context_config[context_key].enabled` is not `nil`, that state value (true/false) is returned.\n - Otherwise the `is_enabled` value (from `config`) is returned.\n- Example: if `config.context.selection.enabled == true` but `state.current_context_config.selection.enabled == false`, the function returns `false` (state overrides config). If the state value is `nil`, the config value is used.\n- Why this matters: `vim.tbl_get` provides safe nested access; using it avoids runtime errors when some parts of the nested config are absent.",
"id": "prt_a36374123001u3GzKEsk03I3ZQ",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.part.updated",
"properties": {
"part": {
"type": "step-finish",
"snapshot": "41a7223d54ec54b5d1ef4fd276420230fc159812",
"id": "prt_a363747330018z5AYX660czh96",
"messageID": "msg_a36372b9a001M1lQEix4SK5QE5",
"reason": "stop",
"cost": 0,
"tokens": { "output": 846, "input": 18962, "reasoning": 0, "cache": { "write": 0, "read": 12544 } },
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{
"type": "message.updated",
"properties": {
"info": {
"role": "assistant",
"time": { "created": 1761846176666 },
"path": {
"root": "/home/francis/Projects/_nvim/opencode.nvim",
"cwd": "/home/francis/Projects/_nvim/opencode.nvim"
},
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"mode": "build",
"parentID": "msg_a3637244a001FDRDfoBYVPEGpd",
"id": "msg_a36372b9a001M1lQEix4SK5QE5",
"modelID": "gpt-5-mini",
"providerID": "github-copilot",
"cost": 0,
"tokens": { "output": 846, "input": 18962, "reasoning": 0, "cache": { "write": 0, "read": 12544 } },
"system": [
"You are a coding agent running in the opencode, a terminal-based coding assistant. opencode is an open source project. You are expected to be precise, safe, and helpful.\n\nYour capabilities:\n\n- Receive user prompts and other context provided by the harness, such as files in the workspace.\n- Communicate with the user by streaming thinking & responses, and by making & updating plans.\n- Emit function calls to run terminal commands and apply edits. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the \"Sandbox and approvals\" section.\n\nWithin this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n# How you work\n\n## Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# AGENTS.md spec\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n## Responsiveness\n\n### Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you’re about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you’re about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8–12 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what’s been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it’s part of a larger grouped action.\n\n**Examples:**\n\n- “I’ve explored the repo; now checking the API route definitions.”\n- “Next, I’ll patch the config and update the related tests.”\n- “I’m about to scaffold the CLI commands and helper functions.”\n- “Ok cool, so I’ve wrapped my head around the repo. Now digging into the API routes.”\n- “Config’s looking tidy. Next up is editing helpers to keep things in sync.”\n- “Finished poking at the DB gateway. I will now chase down error handling.”\n- “Alright, build pipeline order is interesting. Checking how it reports failures.”\n- “Spotted a clever caching util; now hunting where it gets used.”\n\n## Planning\n\nYou have access to an `todowrite` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nDo not repeat the full contents of the plan after an `todowrite` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the\nprevious step, and make sure to mark it as completed before moving on to the\nnext step. It may be the case that you complete all steps in your plan after a\nsingle pass of implementation. If this is the case, you can simply mark all the\nplanned steps as completed. Sometimes, you may need to change plans in the\nmiddle of a task: call `todowrite` with the updated plan and make sure to provide an `explanation` of the rationale when doing so.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n### Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the `edit` tool to edit files \n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after calling `edit` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Do not add inline comments within code unless explicitly requested.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"【F:README.md†L5-L14】\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n## Sandbox and approvals\n\nThe Codex CLI harness supports several different sandboxing, and approval configurations that the user can choose from.\n\nFilesystem sandboxing prevents you from editing files without user approval. The options are:\n\n- **read-only**: You can only read files.\n- **workspace-write**: You can read files. You can write to files in your workspace folder, but not outside it.\n- **danger-full-access**: No filesystem sandboxing.\n\nNetwork sandboxing prevents you from accessing network without approval. Options are\n\n- **restricted**\n- **enabled**\n\nApprovals are your mechanism to get user consent to perform more privileged actions. Although they introduce friction to the user because your work is paused until the user responds, you should leverage them to accomplish your important work. Do not let these settings or the sandbox deter you from attempting to accomplish the user's task. Approval options are\n\n- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe \"read\" commands.\n- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.\n- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)\n- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is pared with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.\n\nWhen you are running with approvals `on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:\n\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /tmp)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for\n- (For all of these, you should weigh alternative paths that do not require approval.)\n\nNote that when sandboxing is set to read-only, you'll need to request approval for any command that isn't a read.\n\nYou will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing ON, and approval on-failure.\n\n## Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete. \n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.\n\n## Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n## Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n## Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user’s style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using `edit`, there's no need to tell users to \"save the file\" or \"copy the code into a file\"—just reference the file path.\n\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there’s something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n### Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity — they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1–3 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Leave no blank line before the first bullet under a header.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4–6 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it’s a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don’t mix unrelated concepts in the same section.\n- Order sections from general → specific → supporting info.\n- For subsections (e.g., “Binaries” under “Rust Workspace”), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results → use clear headers and grouped bullets.\n - Simple results → minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., “Runs tests” not “This will run tests”).\n- Keep descriptions self-contained; don’t refer to “above” or “below”.\n- Use parallel structure in lists for consistency.\n\n**Don’t**\n\n- Don’t use literal words “bold” or “monospace” in the content.\n- Don’t nest bullets or create deep hierarchies.\n- Don’t output ANSI escape codes directly — the CLI renderer applies them.\n- Don’t cram unrelated keywords into a single bullet; split for clarity.\n- Don’t let keyword lists run long — wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what’s needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Tool Guidelines\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n- Read files in chunks with a max chunk size of 250 lines. Do not use python scripts to attempt to output larger chunks of a file. Command line output will be truncated after 10 kilobytes or 256 lines of output, regardless of the command used.\n\n## `todowrite`\n\nA tool named `todowrite` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.\n\nTo create a new plan, call `todowrite` with a short list of 1‑sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, or `completed`).\n\nWhen steps have been completed, use `todowrite` to mark each finished step as\n`completed` and the next step you are working on as `in_progress`. There should\nalways be exactly one `in_progress` step until everything is done. You can mark\nmultiple items as complete in a single `todowrite` call.\n\nIf all steps are complete, ensure you call `todowrite` to mark all steps as `completed`.\n",
"Here is some useful information about the environment you are running in:\n<env>\n Working directory: /home/francis/Projects/_nvim/opencode.nvim\n Is directory a git repo: yes\n Platform: linux\n Today's date: Thu Oct 30 2025\n</env>\n<project>\n .github/\n\tworkflows/\n\t\ttests.yml\nlua/\n\topencode/\n\t\tui/\n\t\t\tcompletion/\n\t\t\t\tengines/\n\t\t\t\t\tblink_cmp.lua\n\t\t\t\t\tnvim_cmp.lua\n\t\t\t\t\tvim_complete.lua\n\t\t\t\tcommands.lua\n\t\t\t\tcontext.lua\n\t\t\t\tfiles.lua\n\t\t\t\tsort.lua\n\t\t\t\tsubagents.lua\n\t\t\tautocmds.lua\n\t\t\tcompletion.lua\n\t\t\tcontext_bar.lua\n\t\t\tcontextual_actions.lua\n\t\t\tdebug_helper.lua\n\t\t\tdiff_tab.lua\n\t\t\tfile_picker.lua\n\t\t\tfooter.lua\n\t\t\tformatter.lua\n\t\t\thighlight.lua\n\t\t\ticons.lua\n\t\t\tinput_window.lua\n\t\t\tloading_animation.lua\n\t\t\tmention.lua\n\t\t\tnavigation.lua\n\t\t\toutput_window.lua\n\t\t\toutput.lua\n\t\t\tpicker.lua\n\t\t\tprompt_guard_indicator.lua\n\t\t\trender_state.lua\n\t\t\trenderer.lua\n\t\t\tsession_picker.lua\n\t\t\ttimer.lua\n\t\t\ttopbar.lua\n\t\t\tui.lua\n\t\tapi_client.lua\n\t\tapi.lua\n\t\tconfig_file.lua\n\t\tconfig.lua\n\t\tcontext.lua\n\t\tcore.lua\n\t\tcurl.lua\n\t\tevent_manager.lua\n\t\tgit_review.lua\n\t\thealth.lua\n\t\thistory.lua\n\t\tid.lua\n\t\tinit.lua\n\t\tkeymap.lua\n\t\topencode_server.lua\n\t\tpromise.lua\n\t\tprovider.lua\n\t\treactive_state.lua\n\t\treview.lua\n\t\tserver_job.lua\n\t\tsession.lua\n\t\tsnapshot.lua\n\t\tstate.lua\n\t\tthrottling_emitter.lua\n\t\ttypes.lua\n\t\tutil.lua\nplugin/\n\topencode.lua\ntests/\n\tdata/\n\t\tansi-codes.expected.json\n\t\tansi-codes.json\n\t\tapi-abort.expected.json\n\t\tapi-abort.json\n\t\tapi-error.expected.json\n\t\tapi-error.json\n\t\tcursor_data.json\n\t\tdiff.expected.json\n\t\tdiff.json\n\t\tmarkdown-codefence.expected.json\n\t\tmarkdown-codefence.json\n\t\tmentions-with-ranges.expected.json\n\t\tmentions-with-ranges.json\n\t\tmessage-removal.expected.json\n\t\tmessage-removal.json\n\t\tperf.expected.json\n\t\tperf.json\n\t\tpermission-denied.expected.json\n\t\tpermission-denied.json\n\t\tpermission-prompt.expected.json\n\t\tpermission-prompt.json\n\t\tpermission.expected.json\n\t\tpermission.json\n\t\tplanning.expected.json\n\t\tplanning.json\n\t\tredo-all.expected.json\n\t\tredo-all.json\n\t\tredo-once.expected.json\n\t\tredo-once.json\n\t\trevert.expected.json\n\t\trevert.json\n\t\tselection.expected.json\n\t\tselection.json\n\t\tshifting-and-multiple-perms.expected.json\n\t\tshifting-and-multiple-perms.json\n\t\tsimple-session.expected.json\n\t\tsimple-session.json\n\t\ttool-invalid.expected.json\n\t\ttool-invalid.json\n\t\tupdating-text.expected.json\n\t\tupdating-text.json\n\tmanual/\n\t\tinit_replay.lua\n\t\tQUICKSTART.md\n\t\tREADME.md\n\t\tregenerate_expected.sh\n\t\trenderer_replay.lua\n\t\treplay.ps1\n\t\trun_replay.sh\n\tminimal/\n\t\tinit.lua\n\t\tplugin_spec.lua\n\tmocks/\n\t\tsession_list.lua\n\tunit/\n\t\tapi_client_spec.lua\n\t\tapi_spec.lua\n\t\tconfig_file_spec.lua\n\t\tconfig_spec.lua\n\t\tcontext_bar_spec.lua\n\t\tcontext_completion_spec.lua\n\t\tcontext_spec.lua\n\t\tcore_spec.lua\n\t\tevent_manager_spec.lua\n\t\tid_spec.lua\n\t\tinit_spec.lua\n\t\tkeymap_spec.lua\n\t\topencode_server_spec.lua\n\t\trender_state_spec.lua\n\t\trenderer_spec.lua\n\t\tserver_job_spec.lua\n\t\tsession_spec.lua\n\t\tsnapshot_spec.lua\n\t\tstate_spec.lua\n\t\ttimer_spec.lua\n\t\tutil_spec.lua\n\thelpers.lua\n.emmyrc.json\n.gitignore\n.stylua.toml\nLICENSE\nREADME.md\nrun_tests.sh\ntest.txt\n</project>\n# AGENTS.md\n\n## Build, Lint, and Test\n\n- **Run all tests:** `./run_tests.sh`\n- **Minimal tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/minimal', {minimal_init = './tests/minimal/init.lua', sequential = true})\"`\n- **Unit tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Run a single test:** Replace the directory in the above command with the test file path, e.g.:\n `nvim --headless -u tests/manual/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit/job_spec.lua', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Manual/Visual tests:** `./tests/manual/run_replay.sh` - Replay captured event data for visual testing\n- **Debug rendering in headless mode:**\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/FILE.json\" \"+ReplayAll 0\" \"+qa\"`\n This will replay events and dump the output buffer to stdout, useful for debugging rendering issues without a UI.\n You can also run to just a specific message # with (e.g. message # 12):\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/message-removal.json\" \"+ReplayNext 12\" \"+qa\"`\n- **Lint:** No explicit lint command; follow Lua best practices.\n\n## Code Style Guidelines\n\n- **Imports:** `local mod = require('mod')` at the top. Group standard, then project imports.\n- **Formatting:** 2 spaces per indent. No trailing whitespace. Lines ≤ 100 chars.\n- **Types:** Use Lua annotations (`---@class`, `---@field`, etc.) for public APIs/config.\n- **Naming:** Modules: `snake_case.lua`; functions/vars: `snake_case`; classes: `CamelCase`.\n- **Error Handling:** Use `vim.notify` for user-facing errors. Return early on error.\n- **Comments:** Only when necessary for clarity. Prefer self-explanatory code.\n- **Functions:** Prefer local functions. Use `M.func` for module exports.\n- **Config:** Centralize in `config.lua`. Use deep merge for user overrides.\n- **Tests:** Place in `tests/minimal/` or `tests/unit/`. Manual/visual tests in `tests/manual/`.\n\n_Agentic coding agents must follow these conventions strictly for consistency and reliability._\n"
]
}
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{
"type": "message.updated",
"properties": {
"info": {
"role": "assistant",
"time": { "completed": 1761846183769, "created": 1761846176666 },
"path": {
"root": "/home/francis/Projects/_nvim/opencode.nvim",
"cwd": "/home/francis/Projects/_nvim/opencode.nvim"
},
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"mode": "build",
"parentID": "msg_a3637244a001FDRDfoBYVPEGpd",
"id": "msg_a36372b9a001M1lQEix4SK5QE5",
"modelID": "gpt-5-mini",
"providerID": "github-copilot",
"cost": 0,
"tokens": { "output": 846, "input": 18962, "reasoning": 0, "cache": { "write": 0, "read": 12544 } },
"system": [
"You are a coding agent running in the opencode, a terminal-based coding assistant. opencode is an open source project. You are expected to be precise, safe, and helpful.\n\nYour capabilities:\n\n- Receive user prompts and other context provided by the harness, such as files in the workspace.\n- Communicate with the user by streaming thinking & responses, and by making & updating plans.\n- Emit function calls to run terminal commands and apply edits. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the \"Sandbox and approvals\" section.\n\nWithin this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n# How you work\n\n## Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# AGENTS.md spec\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n## Responsiveness\n\n### Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you’re about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you’re about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8–12 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what’s been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it’s part of a larger grouped action.\n\n**Examples:**\n\n- “I’ve explored the repo; now checking the API route definitions.”\n- “Next, I’ll patch the config and update the related tests.”\n- “I’m about to scaffold the CLI commands and helper functions.”\n- “Ok cool, so I’ve wrapped my head around the repo. Now digging into the API routes.”\n- “Config’s looking tidy. Next up is editing helpers to keep things in sync.”\n- “Finished poking at the DB gateway. I will now chase down error handling.”\n- “Alright, build pipeline order is interesting. Checking how it reports failures.”\n- “Spotted a clever caching util; now hunting where it gets used.”\n\n## Planning\n\nYou have access to an `todowrite` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nDo not repeat the full contents of the plan after an `todowrite` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the\nprevious step, and make sure to mark it as completed before moving on to the\nnext step. It may be the case that you complete all steps in your plan after a\nsingle pass of implementation. If this is the case, you can simply mark all the\nplanned steps as completed. Sometimes, you may need to change plans in the\nmiddle of a task: call `todowrite` with the updated plan and make sure to provide an `explanation` of the rationale when doing so.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n### Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the `edit` tool to edit files \n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after calling `edit` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Do not add inline comments within code unless explicitly requested.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"【F:README.md†L5-L14】\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n## Sandbox and approvals\n\nThe Codex CLI harness supports several different sandboxing, and approval configurations that the user can choose from.\n\nFilesystem sandboxing prevents you from editing files without user approval. The options are:\n\n- **read-only**: You can only read files.\n- **workspace-write**: You can read files. You can write to files in your workspace folder, but not outside it.\n- **danger-full-access**: No filesystem sandboxing.\n\nNetwork sandboxing prevents you from accessing network without approval. Options are\n\n- **restricted**\n- **enabled**\n\nApprovals are your mechanism to get user consent to perform more privileged actions. Although they introduce friction to the user because your work is paused until the user responds, you should leverage them to accomplish your important work. Do not let these settings or the sandbox deter you from attempting to accomplish the user's task. Approval options are\n\n- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe \"read\" commands.\n- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.\n- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)\n- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is pared with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.\n\nWhen you are running with approvals `on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:\n\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /tmp)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for\n- (For all of these, you should weigh alternative paths that do not require approval.)\n\nNote that when sandboxing is set to read-only, you'll need to request approval for any command that isn't a read.\n\nYou will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing ON, and approval on-failure.\n\n## Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete. \n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.\n\n## Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n## Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n## Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user’s style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using `edit`, there's no need to tell users to \"save the file\" or \"copy the code into a file\"—just reference the file path.\n\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there’s something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n### Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity — they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1–3 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Leave no blank line before the first bullet under a header.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4–6 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it’s a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don’t mix unrelated concepts in the same section.\n- Order sections from general → specific → supporting info.\n- For subsections (e.g., “Binaries” under “Rust Workspace”), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results → use clear headers and grouped bullets.\n - Simple results → minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., “Runs tests” not “This will run tests”).\n- Keep descriptions self-contained; don’t refer to “above” or “below”.\n- Use parallel structure in lists for consistency.\n\n**Don’t**\n\n- Don’t use literal words “bold” or “monospace” in the content.\n- Don’t nest bullets or create deep hierarchies.\n- Don’t output ANSI escape codes directly — the CLI renderer applies them.\n- Don’t cram unrelated keywords into a single bullet; split for clarity.\n- Don’t let keyword lists run long — wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what’s needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Tool Guidelines\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n- Read files in chunks with a max chunk size of 250 lines. Do not use python scripts to attempt to output larger chunks of a file. Command line output will be truncated after 10 kilobytes or 256 lines of output, regardless of the command used.\n\n## `todowrite`\n\nA tool named `todowrite` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.\n\nTo create a new plan, call `todowrite` with a short list of 1‑sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, or `completed`).\n\nWhen steps have been completed, use `todowrite` to mark each finished step as\n`completed` and the next step you are working on as `in_progress`. There should\nalways be exactly one `in_progress` step until everything is done. You can mark\nmultiple items as complete in a single `todowrite` call.\n\nIf all steps are complete, ensure you call `todowrite` to mark all steps as `completed`.\n",
"Here is some useful information about the environment you are running in:\n<env>\n Working directory: /home/francis/Projects/_nvim/opencode.nvim\n Is directory a git repo: yes\n Platform: linux\n Today's date: Thu Oct 30 2025\n</env>\n<project>\n .github/\n\tworkflows/\n\t\ttests.yml\nlua/\n\topencode/\n\t\tui/\n\t\t\tcompletion/\n\t\t\t\tengines/\n\t\t\t\t\tblink_cmp.lua\n\t\t\t\t\tnvim_cmp.lua\n\t\t\t\t\tvim_complete.lua\n\t\t\t\tcommands.lua\n\t\t\t\tcontext.lua\n\t\t\t\tfiles.lua\n\t\t\t\tsort.lua\n\t\t\t\tsubagents.lua\n\t\t\tautocmds.lua\n\t\t\tcompletion.lua\n\t\t\tcontext_bar.lua\n\t\t\tcontextual_actions.lua\n\t\t\tdebug_helper.lua\n\t\t\tdiff_tab.lua\n\t\t\tfile_picker.lua\n\t\t\tfooter.lua\n\t\t\tformatter.lua\n\t\t\thighlight.lua\n\t\t\ticons.lua\n\t\t\tinput_window.lua\n\t\t\tloading_animation.lua\n\t\t\tmention.lua\n\t\t\tnavigation.lua\n\t\t\toutput_window.lua\n\t\t\toutput.lua\n\t\t\tpicker.lua\n\t\t\tprompt_guard_indicator.lua\n\t\t\trender_state.lua\n\t\t\trenderer.lua\n\t\t\tsession_picker.lua\n\t\t\ttimer.lua\n\t\t\ttopbar.lua\n\t\t\tui.lua\n\t\tapi_client.lua\n\t\tapi.lua\n\t\tconfig_file.lua\n\t\tconfig.lua\n\t\tcontext.lua\n\t\tcore.lua\n\t\tcurl.lua\n\t\tevent_manager.lua\n\t\tgit_review.lua\n\t\thealth.lua\n\t\thistory.lua\n\t\tid.lua\n\t\tinit.lua\n\t\tkeymap.lua\n\t\topencode_server.lua\n\t\tpromise.lua\n\t\tprovider.lua\n\t\treactive_state.lua\n\t\treview.lua\n\t\tserver_job.lua\n\t\tsession.lua\n\t\tsnapshot.lua\n\t\tstate.lua\n\t\tthrottling_emitter.lua\n\t\ttypes.lua\n\t\tutil.lua\nplugin/\n\topencode.lua\ntests/\n\tdata/\n\t\tansi-codes.expected.json\n\t\tansi-codes.json\n\t\tapi-abort.expected.json\n\t\tapi-abort.json\n\t\tapi-error.expected.json\n\t\tapi-error.json\n\t\tcursor_data.json\n\t\tdiff.expected.json\n\t\tdiff.json\n\t\tmarkdown-codefence.expected.json\n\t\tmarkdown-codefence.json\n\t\tmentions-with-ranges.expected.json\n\t\tmentions-with-ranges.json\n\t\tmessage-removal.expected.json\n\t\tmessage-removal.json\n\t\tperf.expected.json\n\t\tperf.json\n\t\tpermission-denied.expected.json\n\t\tpermission-denied.json\n\t\tpermission-prompt.expected.json\n\t\tpermission-prompt.json\n\t\tpermission.expected.json\n\t\tpermission.json\n\t\tplanning.expected.json\n\t\tplanning.json\n\t\tredo-all.expected.json\n\t\tredo-all.json\n\t\tredo-once.expected.json\n\t\tredo-once.json\n\t\trevert.expected.json\n\t\trevert.json\n\t\tselection.expected.json\n\t\tselection.json\n\t\tshifting-and-multiple-perms.expected.json\n\t\tshifting-and-multiple-perms.json\n\t\tsimple-session.expected.json\n\t\tsimple-session.json\n\t\ttool-invalid.expected.json\n\t\ttool-invalid.json\n\t\tupdating-text.expected.json\n\t\tupdating-text.json\n\tmanual/\n\t\tinit_replay.lua\n\t\tQUICKSTART.md\n\t\tREADME.md\n\t\tregenerate_expected.sh\n\t\trenderer_replay.lua\n\t\treplay.ps1\n\t\trun_replay.sh\n\tminimal/\n\t\tinit.lua\n\t\tplugin_spec.lua\n\tmocks/\n\t\tsession_list.lua\n\tunit/\n\t\tapi_client_spec.lua\n\t\tapi_spec.lua\n\t\tconfig_file_spec.lua\n\t\tconfig_spec.lua\n\t\tcontext_bar_spec.lua\n\t\tcontext_completion_spec.lua\n\t\tcontext_spec.lua\n\t\tcore_spec.lua\n\t\tevent_manager_spec.lua\n\t\tid_spec.lua\n\t\tinit_spec.lua\n\t\tkeymap_spec.lua\n\t\topencode_server_spec.lua\n\t\trender_state_spec.lua\n\t\trenderer_spec.lua\n\t\tserver_job_spec.lua\n\t\tsession_spec.lua\n\t\tsnapshot_spec.lua\n\t\tstate_spec.lua\n\t\ttimer_spec.lua\n\t\tutil_spec.lua\n\thelpers.lua\n.emmyrc.json\n.gitignore\n.stylua.toml\nLICENSE\nREADME.md\nrun_tests.sh\ntest.txt\n</project>\n# AGENTS.md\n\n## Build, Lint, and Test\n\n- **Run all tests:** `./run_tests.sh`\n- **Minimal tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/minimal', {minimal_init = './tests/minimal/init.lua', sequential = true})\"`\n- **Unit tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Run a single test:** Replace the directory in the above command with the test file path, e.g.:\n `nvim --headless -u tests/manual/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit/job_spec.lua', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Manual/Visual tests:** `./tests/manual/run_replay.sh` - Replay captured event data for visual testing\n- **Debug rendering in headless mode:**\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/FILE.json\" \"+ReplayAll 0\" \"+qa\"`\n This will replay events and dump the output buffer to stdout, useful for debugging rendering issues without a UI.\n You can also run to just a specific message # with (e.g. message # 12):\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/message-removal.json\" \"+ReplayNext 12\" \"+qa\"`\n- **Lint:** No explicit lint command; follow Lua best practices.\n\n## Code Style Guidelines\n\n- **Imports:** `local mod = require('mod')` at the top. Group standard, then project imports.\n- **Formatting:** 2 spaces per indent. No trailing whitespace. Lines ≤ 100 chars.\n- **Types:** Use Lua annotations (`---@class`, `---@field`, etc.) for public APIs/config.\n- **Naming:** Modules: `snake_case.lua`; functions/vars: `snake_case`; classes: `CamelCase`.\n- **Error Handling:** Use `vim.notify` for user-facing errors. Return early on error.\n- **Comments:** Only when necessary for clarity. Prefer self-explanatory code.\n- **Functions:** Prefer local functions. Use `M.func` for module exports.\n- **Config:** Centralize in `config.lua`. Use deep merge for user overrides.\n- **Tests:** Place in `tests/minimal/` or `tests/unit/`. Manual/visual tests in `tests/manual/`.\n\n_Agentic coding agents must follow these conventions strictly for consistency and reliability._\n"
]
}
}
},
{
"type": "message.updated",
"properties": {
"info": {
"role": "assistant",
"time": { "completed": 1761846183772, "created": 1761846176666 },
"path": {
"root": "/home/francis/Projects/_nvim/opencode.nvim",
"cwd": "/home/francis/Projects/_nvim/opencode.nvim"
},
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"mode": "build",
"parentID": "msg_a3637244a001FDRDfoBYVPEGpd",
"id": "msg_a36372b9a001M1lQEix4SK5QE5",
"modelID": "gpt-5-mini",
"providerID": "github-copilot",
"cost": 0,
"tokens": { "output": 846, "input": 18962, "reasoning": 0, "cache": { "write": 0, "read": 12544 } },
"system": [
"You are a coding agent running in the opencode, a terminal-based coding assistant. opencode is an open source project. You are expected to be precise, safe, and helpful.\n\nYour capabilities:\n\n- Receive user prompts and other context provided by the harness, such as files in the workspace.\n- Communicate with the user by streaming thinking & responses, and by making & updating plans.\n- Emit function calls to run terminal commands and apply edits. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the \"Sandbox and approvals\" section.\n\nWithin this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n# How you work\n\n## Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# AGENTS.md spec\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n## Responsiveness\n\n### Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you’re about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you’re about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8–12 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what’s been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it’s part of a larger grouped action.\n\n**Examples:**\n\n- “I’ve explored the repo; now checking the API route definitions.”\n- “Next, I’ll patch the config and update the related tests.”\n- “I’m about to scaffold the CLI commands and helper functions.”\n- “Ok cool, so I’ve wrapped my head around the repo. Now digging into the API routes.”\n- “Config’s looking tidy. Next up is editing helpers to keep things in sync.”\n- “Finished poking at the DB gateway. I will now chase down error handling.”\n- “Alright, build pipeline order is interesting. Checking how it reports failures.”\n- “Spotted a clever caching util; now hunting where it gets used.”\n\n## Planning\n\nYou have access to an `todowrite` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nDo not repeat the full contents of the plan after an `todowrite` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the\nprevious step, and make sure to mark it as completed before moving on to the\nnext step. It may be the case that you complete all steps in your plan after a\nsingle pass of implementation. If this is the case, you can simply mark all the\nplanned steps as completed. Sometimes, you may need to change plans in the\nmiddle of a task: call `todowrite` with the updated plan and make sure to provide an `explanation` of the rationale when doing so.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n### Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the `edit` tool to edit files \n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after calling `edit` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Do not add inline comments within code unless explicitly requested.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"【F:README.md†L5-L14】\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n## Sandbox and approvals\n\nThe Codex CLI harness supports several different sandboxing, and approval configurations that the user can choose from.\n\nFilesystem sandboxing prevents you from editing files without user approval. The options are:\n\n- **read-only**: You can only read files.\n- **workspace-write**: You can read files. You can write to files in your workspace folder, but not outside it.\n- **danger-full-access**: No filesystem sandboxing.\n\nNetwork sandboxing prevents you from accessing network without approval. Options are\n\n- **restricted**\n- **enabled**\n\nApprovals are your mechanism to get user consent to perform more privileged actions. Although they introduce friction to the user because your work is paused until the user responds, you should leverage them to accomplish your important work. Do not let these settings or the sandbox deter you from attempting to accomplish the user's task. Approval options are\n\n- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe \"read\" commands.\n- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.\n- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)\n- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is pared with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.\n\nWhen you are running with approvals `on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:\n\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /tmp)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for\n- (For all of these, you should weigh alternative paths that do not require approval.)\n\nNote that when sandboxing is set to read-only, you'll need to request approval for any command that isn't a read.\n\nYou will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing ON, and approval on-failure.\n\n## Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete. \n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.\n\n## Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n## Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n## Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user’s style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using `edit`, there's no need to tell users to \"save the file\" or \"copy the code into a file\"—just reference the file path.\n\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there’s something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n### Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity — they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1–3 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Leave no blank line before the first bullet under a header.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4–6 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it’s a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don’t mix unrelated concepts in the same section.\n- Order sections from general → specific → supporting info.\n- For subsections (e.g., “Binaries” under “Rust Workspace”), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results → use clear headers and grouped bullets.\n - Simple results → minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., “Runs tests” not “This will run tests”).\n- Keep descriptions self-contained; don’t refer to “above” or “below”.\n- Use parallel structure in lists for consistency.\n\n**Don’t**\n\n- Don’t use literal words “bold” or “monospace” in the content.\n- Don’t nest bullets or create deep hierarchies.\n- Don’t output ANSI escape codes directly — the CLI renderer applies them.\n- Don’t cram unrelated keywords into a single bullet; split for clarity.\n- Don’t let keyword lists run long — wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what’s needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Tool Guidelines\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n- Read files in chunks with a max chunk size of 250 lines. Do not use python scripts to attempt to output larger chunks of a file. Command line output will be truncated after 10 kilobytes or 256 lines of output, regardless of the command used.\n\n## `todowrite`\n\nA tool named `todowrite` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.\n\nTo create a new plan, call `todowrite` with a short list of 1‑sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, or `completed`).\n\nWhen steps have been completed, use `todowrite` to mark each finished step as\n`completed` and the next step you are working on as `in_progress`. There should\nalways be exactly one `in_progress` step until everything is done. You can mark\nmultiple items as complete in a single `todowrite` call.\n\nIf all steps are complete, ensure you call `todowrite` to mark all steps as `completed`.\n",
"Here is some useful information about the environment you are running in:\n<env>\n Working directory: /home/francis/Projects/_nvim/opencode.nvim\n Is directory a git repo: yes\n Platform: linux\n Today's date: Thu Oct 30 2025\n</env>\n<project>\n .github/\n\tworkflows/\n\t\ttests.yml\nlua/\n\topencode/\n\t\tui/\n\t\t\tcompletion/\n\t\t\t\tengines/\n\t\t\t\t\tblink_cmp.lua\n\t\t\t\t\tnvim_cmp.lua\n\t\t\t\t\tvim_complete.lua\n\t\t\t\tcommands.lua\n\t\t\t\tcontext.lua\n\t\t\t\tfiles.lua\n\t\t\t\tsort.lua\n\t\t\t\tsubagents.lua\n\t\t\tautocmds.lua\n\t\t\tcompletion.lua\n\t\t\tcontext_bar.lua\n\t\t\tcontextual_actions.lua\n\t\t\tdebug_helper.lua\n\t\t\tdiff_tab.lua\n\t\t\tfile_picker.lua\n\t\t\tfooter.lua\n\t\t\tformatter.lua\n\t\t\thighlight.lua\n\t\t\ticons.lua\n\t\t\tinput_window.lua\n\t\t\tloading_animation.lua\n\t\t\tmention.lua\n\t\t\tnavigation.lua\n\t\t\toutput_window.lua\n\t\t\toutput.lua\n\t\t\tpicker.lua\n\t\t\tprompt_guard_indicator.lua\n\t\t\trender_state.lua\n\t\t\trenderer.lua\n\t\t\tsession_picker.lua\n\t\t\ttimer.lua\n\t\t\ttopbar.lua\n\t\t\tui.lua\n\t\tapi_client.lua\n\t\tapi.lua\n\t\tconfig_file.lua\n\t\tconfig.lua\n\t\tcontext.lua\n\t\tcore.lua\n\t\tcurl.lua\n\t\tevent_manager.lua\n\t\tgit_review.lua\n\t\thealth.lua\n\t\thistory.lua\n\t\tid.lua\n\t\tinit.lua\n\t\tkeymap.lua\n\t\topencode_server.lua\n\t\tpromise.lua\n\t\tprovider.lua\n\t\treactive_state.lua\n\t\treview.lua\n\t\tserver_job.lua\n\t\tsession.lua\n\t\tsnapshot.lua\n\t\tstate.lua\n\t\tthrottling_emitter.lua\n\t\ttypes.lua\n\t\tutil.lua\nplugin/\n\topencode.lua\ntests/\n\tdata/\n\t\tansi-codes.expected.json\n\t\tansi-codes.json\n\t\tapi-abort.expected.json\n\t\tapi-abort.json\n\t\tapi-error.expected.json\n\t\tapi-error.json\n\t\tcursor_data.json\n\t\tdiff.expected.json\n\t\tdiff.json\n\t\tmarkdown-codefence.expected.json\n\t\tmarkdown-codefence.json\n\t\tmentions-with-ranges.expected.json\n\t\tmentions-with-ranges.json\n\t\tmessage-removal.expected.json\n\t\tmessage-removal.json\n\t\tperf.expected.json\n\t\tperf.json\n\t\tpermission-denied.expected.json\n\t\tpermission-denied.json\n\t\tpermission-prompt.expected.json\n\t\tpermission-prompt.json\n\t\tpermission.expected.json\n\t\tpermission.json\n\t\tplanning.expected.json\n\t\tplanning.json\n\t\tredo-all.expected.json\n\t\tredo-all.json\n\t\tredo-once.expected.json\n\t\tredo-once.json\n\t\trevert.expected.json\n\t\trevert.json\n\t\tselection.expected.json\n\t\tselection.json\n\t\tshifting-and-multiple-perms.expected.json\n\t\tshifting-and-multiple-perms.json\n\t\tsimple-session.expected.json\n\t\tsimple-session.json\n\t\ttool-invalid.expected.json\n\t\ttool-invalid.json\n\t\tupdating-text.expected.json\n\t\tupdating-text.json\n\tmanual/\n\t\tinit_replay.lua\n\t\tQUICKSTART.md\n\t\tREADME.md\n\t\tregenerate_expected.sh\n\t\trenderer_replay.lua\n\t\treplay.ps1\n\t\trun_replay.sh\n\tminimal/\n\t\tinit.lua\n\t\tplugin_spec.lua\n\tmocks/\n\t\tsession_list.lua\n\tunit/\n\t\tapi_client_spec.lua\n\t\tapi_spec.lua\n\t\tconfig_file_spec.lua\n\t\tconfig_spec.lua\n\t\tcontext_bar_spec.lua\n\t\tcontext_completion_spec.lua\n\t\tcontext_spec.lua\n\t\tcore_spec.lua\n\t\tevent_manager_spec.lua\n\t\tid_spec.lua\n\t\tinit_spec.lua\n\t\tkeymap_spec.lua\n\t\topencode_server_spec.lua\n\t\trender_state_spec.lua\n\t\trenderer_spec.lua\n\t\tserver_job_spec.lua\n\t\tsession_spec.lua\n\t\tsnapshot_spec.lua\n\t\tstate_spec.lua\n\t\ttimer_spec.lua\n\t\tutil_spec.lua\n\thelpers.lua\n.emmyrc.json\n.gitignore\n.stylua.toml\nLICENSE\nREADME.md\nrun_tests.sh\ntest.txt\n</project>\n# AGENTS.md\n\n## Build, Lint, and Test\n\n- **Run all tests:** `./run_tests.sh`\n- **Minimal tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/minimal', {minimal_init = './tests/minimal/init.lua', sequential = true})\"`\n- **Unit tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Run a single test:** Replace the directory in the above command with the test file path, e.g.:\n `nvim --headless -u tests/manual/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit/job_spec.lua', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Manual/Visual tests:** `./tests/manual/run_replay.sh` - Replay captured event data for visual testing\n- **Debug rendering in headless mode:**\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/FILE.json\" \"+ReplayAll 0\" \"+qa\"`\n This will replay events and dump the output buffer to stdout, useful for debugging rendering issues without a UI.\n You can also run to just a specific message # with (e.g. message # 12):\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/message-removal.json\" \"+ReplayNext 12\" \"+qa\"`\n- **Lint:** No explicit lint command; follow Lua best practices.\n\n## Code Style Guidelines\n\n- **Imports:** `local mod = require('mod')` at the top. Group standard, then project imports.\n- **Formatting:** 2 spaces per indent. No trailing whitespace. Lines ≤ 100 chars.\n- **Types:** Use Lua annotations (`---@class`, `---@field`, etc.) for public APIs/config.\n- **Naming:** Modules: `snake_case.lua`; functions/vars: `snake_case`; classes: `CamelCase`.\n- **Error Handling:** Use `vim.notify` for user-facing errors. Return early on error.\n- **Comments:** Only when necessary for clarity. Prefer self-explanatory code.\n- **Functions:** Prefer local functions. Use `M.func` for module exports.\n- **Config:** Centralize in `config.lua`. Use deep merge for user overrides.\n- **Tests:** Place in `tests/minimal/` or `tests/unit/`. Manual/visual tests in `tests/manual/`.\n\n_Agentic coding agents must follow these conventions strictly for consistency and reliability._\n"
]
}
}
},
{
"type": "message.updated",
"properties": {
"info": {
"role": "assistant",
"time": { "completed": 1761846183774, "created": 1761846176666 },
"path": {
"root": "/home/francis/Projects/_nvim/opencode.nvim",
"cwd": "/home/francis/Projects/_nvim/opencode.nvim"
},
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"mode": "build",
"parentID": "msg_a3637244a001FDRDfoBYVPEGpd",
"id": "msg_a36372b9a001M1lQEix4SK5QE5",
"modelID": "gpt-5-mini",
"providerID": "github-copilot",
"cost": 0,
"tokens": { "output": 846, "input": 18962, "reasoning": 0, "cache": { "write": 0, "read": 12544 } },
"system": [
"You are a coding agent running in the opencode, a terminal-based coding assistant. opencode is an open source project. You are expected to be precise, safe, and helpful.\n\nYour capabilities:\n\n- Receive user prompts and other context provided by the harness, such as files in the workspace.\n- Communicate with the user by streaming thinking & responses, and by making & updating plans.\n- Emit function calls to run terminal commands and apply edits. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the \"Sandbox and approvals\" section.\n\nWithin this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n# How you work\n\n## Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# AGENTS.md spec\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n## Responsiveness\n\n### Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you’re about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you’re about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8–12 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what’s been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it’s part of a larger grouped action.\n\n**Examples:**\n\n- “I’ve explored the repo; now checking the API route definitions.”\n- “Next, I’ll patch the config and update the related tests.”\n- “I’m about to scaffold the CLI commands and helper functions.”\n- “Ok cool, so I’ve wrapped my head around the repo. Now digging into the API routes.”\n- “Config’s looking tidy. Next up is editing helpers to keep things in sync.”\n- “Finished poking at the DB gateway. I will now chase down error handling.”\n- “Alright, build pipeline order is interesting. Checking how it reports failures.”\n- “Spotted a clever caching util; now hunting where it gets used.”\n\n## Planning\n\nYou have access to an `todowrite` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nDo not repeat the full contents of the plan after an `todowrite` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the\nprevious step, and make sure to mark it as completed before moving on to the\nnext step. It may be the case that you complete all steps in your plan after a\nsingle pass of implementation. If this is the case, you can simply mark all the\nplanned steps as completed. Sometimes, you may need to change plans in the\nmiddle of a task: call `todowrite` with the updated plan and make sure to provide an `explanation` of the rationale when doing so.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n### Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the `edit` tool to edit files \n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after calling `edit` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Do not add inline comments within code unless explicitly requested.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"【F:README.md†L5-L14】\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n## Sandbox and approvals\n\nThe Codex CLI harness supports several different sandboxing, and approval configurations that the user can choose from.\n\nFilesystem sandboxing prevents you from editing files without user approval. The options are:\n\n- **read-only**: You can only read files.\n- **workspace-write**: You can read files. You can write to files in your workspace folder, but not outside it.\n- **danger-full-access**: No filesystem sandboxing.\n\nNetwork sandboxing prevents you from accessing network without approval. Options are\n\n- **restricted**\n- **enabled**\n\nApprovals are your mechanism to get user consent to perform more privileged actions. Although they introduce friction to the user because your work is paused until the user responds, you should leverage them to accomplish your important work. Do not let these settings or the sandbox deter you from attempting to accomplish the user's task. Approval options are\n\n- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe \"read\" commands.\n- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.\n- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)\n- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is pared with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.\n\nWhen you are running with approvals `on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:\n\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /tmp)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for\n- (For all of these, you should weigh alternative paths that do not require approval.)\n\nNote that when sandboxing is set to read-only, you'll need to request approval for any command that isn't a read.\n\nYou will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing ON, and approval on-failure.\n\n## Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete. \n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.\n\n## Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n## Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n## Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user’s style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using `edit`, there's no need to tell users to \"save the file\" or \"copy the code into a file\"—just reference the file path.\n\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there’s something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n### Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity — they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1–3 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Leave no blank line before the first bullet under a header.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4–6 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it’s a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don’t mix unrelated concepts in the same section.\n- Order sections from general → specific → supporting info.\n- For subsections (e.g., “Binaries” under “Rust Workspace”), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results → use clear headers and grouped bullets.\n - Simple results → minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., “Runs tests” not “This will run tests”).\n- Keep descriptions self-contained; don’t refer to “above” or “below”.\n- Use parallel structure in lists for consistency.\n\n**Don’t**\n\n- Don’t use literal words “bold” or “monospace” in the content.\n- Don’t nest bullets or create deep hierarchies.\n- Don’t output ANSI escape codes directly — the CLI renderer applies them.\n- Don’t cram unrelated keywords into a single bullet; split for clarity.\n- Don’t let keyword lists run long — wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what’s needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Tool Guidelines\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n- Read files in chunks with a max chunk size of 250 lines. Do not use python scripts to attempt to output larger chunks of a file. Command line output will be truncated after 10 kilobytes or 256 lines of output, regardless of the command used.\n\n## `todowrite`\n\nA tool named `todowrite` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.\n\nTo create a new plan, call `todowrite` with a short list of 1‑sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, or `completed`).\n\nWhen steps have been completed, use `todowrite` to mark each finished step as\n`completed` and the next step you are working on as `in_progress`. There should\nalways be exactly one `in_progress` step until everything is done. You can mark\nmultiple items as complete in a single `todowrite` call.\n\nIf all steps are complete, ensure you call `todowrite` to mark all steps as `completed`.\n",
"Here is some useful information about the environment you are running in:\n<env>\n Working directory: /home/francis/Projects/_nvim/opencode.nvim\n Is directory a git repo: yes\n Platform: linux\n Today's date: Thu Oct 30 2025\n</env>\n<project>\n .github/\n\tworkflows/\n\t\ttests.yml\nlua/\n\topencode/\n\t\tui/\n\t\t\tcompletion/\n\t\t\t\tengines/\n\t\t\t\t\tblink_cmp.lua\n\t\t\t\t\tnvim_cmp.lua\n\t\t\t\t\tvim_complete.lua\n\t\t\t\tcommands.lua\n\t\t\t\tcontext.lua\n\t\t\t\tfiles.lua\n\t\t\t\tsort.lua\n\t\t\t\tsubagents.lua\n\t\t\tautocmds.lua\n\t\t\tcompletion.lua\n\t\t\tcontext_bar.lua\n\t\t\tcontextual_actions.lua\n\t\t\tdebug_helper.lua\n\t\t\tdiff_tab.lua\n\t\t\tfile_picker.lua\n\t\t\tfooter.lua\n\t\t\tformatter.lua\n\t\t\thighlight.lua\n\t\t\ticons.lua\n\t\t\tinput_window.lua\n\t\t\tloading_animation.lua\n\t\t\tmention.lua\n\t\t\tnavigation.lua\n\t\t\toutput_window.lua\n\t\t\toutput.lua\n\t\t\tpicker.lua\n\t\t\tprompt_guard_indicator.lua\n\t\t\trender_state.lua\n\t\t\trenderer.lua\n\t\t\tsession_picker.lua\n\t\t\ttimer.lua\n\t\t\ttopbar.lua\n\t\t\tui.lua\n\t\tapi_client.lua\n\t\tapi.lua\n\t\tconfig_file.lua\n\t\tconfig.lua\n\t\tcontext.lua\n\t\tcore.lua\n\t\tcurl.lua\n\t\tevent_manager.lua\n\t\tgit_review.lua\n\t\thealth.lua\n\t\thistory.lua\n\t\tid.lua\n\t\tinit.lua\n\t\tkeymap.lua\n\t\topencode_server.lua\n\t\tpromise.lua\n\t\tprovider.lua\n\t\treactive_state.lua\n\t\treview.lua\n\t\tserver_job.lua\n\t\tsession.lua\n\t\tsnapshot.lua\n\t\tstate.lua\n\t\tthrottling_emitter.lua\n\t\ttypes.lua\n\t\tutil.lua\nplugin/\n\topencode.lua\ntests/\n\tdata/\n\t\tansi-codes.expected.json\n\t\tansi-codes.json\n\t\tapi-abort.expected.json\n\t\tapi-abort.json\n\t\tapi-error.expected.json\n\t\tapi-error.json\n\t\tcursor_data.json\n\t\tdiff.expected.json\n\t\tdiff.json\n\t\tmarkdown-codefence.expected.json\n\t\tmarkdown-codefence.json\n\t\tmentions-with-ranges.expected.json\n\t\tmentions-with-ranges.json\n\t\tmessage-removal.expected.json\n\t\tmessage-removal.json\n\t\tperf.expected.json\n\t\tperf.json\n\t\tpermission-denied.expected.json\n\t\tpermission-denied.json\n\t\tpermission-prompt.expected.json\n\t\tpermission-prompt.json\n\t\tpermission.expected.json\n\t\tpermission.json\n\t\tplanning.expected.json\n\t\tplanning.json\n\t\tredo-all.expected.json\n\t\tredo-all.json\n\t\tredo-once.expected.json\n\t\tredo-once.json\n\t\trevert.expected.json\n\t\trevert.json\n\t\tselection.expected.json\n\t\tselection.json\n\t\tshifting-and-multiple-perms.expected.json\n\t\tshifting-and-multiple-perms.json\n\t\tsimple-session.expected.json\n\t\tsimple-session.json\n\t\ttool-invalid.expected.json\n\t\ttool-invalid.json\n\t\tupdating-text.expected.json\n\t\tupdating-text.json\n\tmanual/\n\t\tinit_replay.lua\n\t\tQUICKSTART.md\n\t\tREADME.md\n\t\tregenerate_expected.sh\n\t\trenderer_replay.lua\n\t\treplay.ps1\n\t\trun_replay.sh\n\tminimal/\n\t\tinit.lua\n\t\tplugin_spec.lua\n\tmocks/\n\t\tsession_list.lua\n\tunit/\n\t\tapi_client_spec.lua\n\t\tapi_spec.lua\n\t\tconfig_file_spec.lua\n\t\tconfig_spec.lua\n\t\tcontext_bar_spec.lua\n\t\tcontext_completion_spec.lua\n\t\tcontext_spec.lua\n\t\tcore_spec.lua\n\t\tevent_manager_spec.lua\n\t\tid_spec.lua\n\t\tinit_spec.lua\n\t\tkeymap_spec.lua\n\t\topencode_server_spec.lua\n\t\trender_state_spec.lua\n\t\trenderer_spec.lua\n\t\tserver_job_spec.lua\n\t\tsession_spec.lua\n\t\tsnapshot_spec.lua\n\t\tstate_spec.lua\n\t\ttimer_spec.lua\n\t\tutil_spec.lua\n\thelpers.lua\n.emmyrc.json\n.gitignore\n.stylua.toml\nLICENSE\nREADME.md\nrun_tests.sh\ntest.txt\n</project>\n# AGENTS.md\n\n## Build, Lint, and Test\n\n- **Run all tests:** `./run_tests.sh`\n- **Minimal tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/minimal', {minimal_init = './tests/minimal/init.lua', sequential = true})\"`\n- **Unit tests:**\n `nvim --headless -u tests/minimal/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Run a single test:** Replace the directory in the above command with the test file path, e.g.:\n `nvim --headless -u tests/manual/init.lua -c \"lua require('plenary.test_harness').test_directory('./tests/unit/job_spec.lua', {minimal_init = './tests/minimal/init.lua'})\"`\n- **Manual/Visual tests:** `./tests/manual/run_replay.sh` - Replay captured event data for visual testing\n- **Debug rendering in headless mode:**\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/FILE.json\" \"+ReplayAll 0\" \"+qa\"`\n This will replay events and dump the output buffer to stdout, useful for debugging rendering issues without a UI.\n You can also run to just a specific message # with (e.g. message # 12):\n `nvim --headless -u tests/manual/init_replay.lua \"+ReplayHeadless\" \"+ReplayLoad tests/data/message-removal.json\" \"+ReplayNext 12\" \"+qa\"`\n- **Lint:** No explicit lint command; follow Lua best practices.\n\n## Code Style Guidelines\n\n- **Imports:** `local mod = require('mod')` at the top. Group standard, then project imports.\n- **Formatting:** 2 spaces per indent. No trailing whitespace. Lines ≤ 100 chars.\n- **Types:** Use Lua annotations (`---@class`, `---@field`, etc.) for public APIs/config.\n- **Naming:** Modules: `snake_case.lua`; functions/vars: `snake_case`; classes: `CamelCase`.\n- **Error Handling:** Use `vim.notify` for user-facing errors. Return early on error.\n- **Comments:** Only when necessary for clarity. Prefer self-explanatory code.\n- **Functions:** Prefer local functions. Use `M.func` for module exports.\n- **Config:** Centralize in `config.lua`. Use deep merge for user overrides.\n- **Tests:** Place in `tests/minimal/` or `tests/unit/`. Manual/visual tests in `tests/manual/`.\n\n_Agentic coding agents must follow these conventions strictly for consistency and reliability._\n"
]
}
}
},
{
"type": "session.updated",
"properties": {
"info": {
"version": "0.15.20",
"directory": "/home/francis/Projects/_nvim/opencode.nvim",
"title": "Analyzing opencode/context.lua cursor-data handling",
"time": { "created": 1761846174734, "updated": 1761846183792 },
"summary": { "diffs": [] },
"id": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS",
"projectID": "29d43526f88157cd4edd071b899dd01f240b771b"
}
}
},
{
"type": "message.updated",
"properties": {
"info": {
"role": "user",
"time": { "created": 1761846174794 },
"summary": { "diffs": [] },
"id": "msg_a3637244a001FDRDfoBYVPEGpd",
"sessionID": "ses_5c9c8dbf1ffeKzKcDjZ2llgPVS"
}
}
},
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] },
{ "type": "custom.emit_events.finished", "properties": [] }
]