repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

docs(neovim): specify native pivi integration

c1da466837edfe921e9406bc22ca80aeacd72155

Oliver Krylow <o.krylow@isp-insoft.de> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (2)

+215 / −0 text lines

Diff layout

neovim/.system/specs/NL-SPEC-GMWDCMJZ-pivi-native-neovim-integration/index.md

Added
new file mode 100644

+123 / −0 text lines

1---
2id: NL-SPEC-GMWDCMJZ
3type: spec
4title: pivi Native Neovim Integration
5---
6
7# pivi Native Neovim Integration
8
9## Intent
11pivi makes Pi feel native inside Neovim rather than embedding Pi's terminal interface.
12Pi remains a fully empowered coding agent.
13Neovim supplies editing, navigation, presentation, and live editor context.
15[Accepted native edit and follow-mode mockup](./native-agent-trail.html)
17## Scope
19pivi provides:
21- Persistent Pi sessions controlled through Pi RPC.
22- Neovim buffers for prompts, transcripts, session navigation, and detailed output.
23- Native quickfix lists, location lists, diagnostics, extmarks, signs, diffs, and navigation.
24- Live access to core Neovim state and unrestricted Neovim Lua execution.
25- A bundled Pi companion extension loaded in addition to the user's normal Pi configuration.
27Initial editor tools focus on buffers, selections, windows, tabs, marks, jumps, changes, lists, diagnostics, commands, and Lua execution.
28LSP-specific tools are outside the initial scope.
30## Session behavior
32- A Pi session is an explicit task identity with persistent history.
33- Each session captures a working directory as its execution scope.
34- Multiple sessions may share one working directory.
35- A tab may select a default session but does not own its lifetime.
36- Source buffers do not own sessions.
37- Closing a session window hides presentation without deleting history or implicitly stopping Pi.
39## Editor context
41- Each submission may carry an immutable snapshot of its originating buffer, path, revision, cursor, range, selection kind, selected text, and bounded surrounding text.
42- Queued submissions retain their own snapshots.
43- Pi can obtain fresh ambient editor state before later model calls.
44- Full buffer contents are fetched on demand rather than attaching every open buffer automatically.
45- Loaded buffers, including unsaved contents, are authoritative for editor-aware reads.
46- The Pi prompt receives a short stable orientation to the live Neovim environment without replacing existing system or project instructions.
48## Editing
50- Pi may edit without an approval gate.
51- Reads, edits, and writes preserve the behavior and improvements of Pi's upstream tools while making loaded Neovim buffers authoritative.
52- Agent changes to loaded buffers appear directly in Neovim, remain undoable, and become visible to filesystem-based commands without requiring manual reload.
53- Unloaded paths retain normal Pi filesystem behavior.
54- Validated edit intent may appear progressively as ghost text while tool arguments stream.
55- Real buffer mutation begins only after complete valid edit arguments exist.
56- An edit operation presents one coherent undoable change where Neovim permits it.
57- pivi uses no filesystem watchers.
58- Arbitrary shell or third-party tool mutations without identified paths are not represented as precise editor edits.
60## Agent activity
62- Active edits may use signs, line highlights, extmarks, virtual text, or virtual lines.
63- Completed edits leave a navigable changed-line trail until cleared by defined editor activity or session action.
64- Activity belongs to its Pi session and does not overwrite unrelated diagnostic or extmark namespaces.
65- File and range references are navigable through normal Neovim motions and lists.
66- Cross-file findings use quickfix lists.
67- Window-associated findings use location lists.
68- AI diagnostics remain distinguishable from compiler and language-server diagnostics.
70## Follow-agent mode
72- Follow mode is optional and disabled unless selected by the user.
73- It follows location-bearing reads, edits, findings, and explicit navigation rather than every event.
74- It can follow in a dedicated window, a dedicated tab, or the current window.
75- Dedicated-window following preserves the user's working window.
76- Passive following avoids unnecessary jumplist pollution.
77- The user can return to the location held before following began.
79## Pi compatibility
81- The companion extension is shipped with pivi and injected additively when Pi starts.
82- User, project, package, provider, skill, prompt, and tool configuration continues to load under Pi's normal rules.
83- pivi does not silently alter Pi project trust or restrict available tools.
84- Extension tools, commands, hooks, prompt changes, session behavior, and supported RPC dialogs remain functional.
85- TUI-only renderers, custom components, keybindings, headers, footers, and terminal input are not emulated.
86- Supported extension dialogs and status requests map to native Neovim surfaces.
87- Unrestricted Neovim Lua execution is available alongside structured convenience tools.
89## Native integration invariant
91pivi is an optional producer of native Neovim state, never the owner of surrounding configuration.
93- It does not replace or require a statusline, winbar, tabline, picker, notification system, layout, or keymap framework.
94- It publishes cached state through native variables and semantic `User` events.
95- It offers commands and `<Plug>` mappings without imposing global mappings.
96- Consumers can degrade to ordinary Neovim behavior when pivi is absent.
97- Loading pivi succeeds when the Pi executable is unavailable; starting Pi reports the missing capability.
98- Status consumers never perform Pi RPC during statusline evaluation.
100## Transport and status
102- Pi RPC uses a non-terminal JSONL subprocess channel.
103- Terminal dimensions, alternate screens, cursor escapes, and terminal key forwarding are not part of pivi.
104- Standard error remains separate from protocol output.
105- ANSI styling in payload text is stripped or translated before native presentation.
106- Semantic session status includes connection, queue, run, tool, waiting, compaction, retry, abort, and error states.
107- Status also exposes available model, thinking, session, context, usage, and extension-status data.
108- Status changes redraw native status surfaces and emit a semantic event.
110## Acceptance criteria
112- A user can create, resume, switch, and stop explicit Pi sessions without tying their lifetime to a source buffer or tab.
113- A prompt can include an unsaved selection with stable source and revision metadata.
114- Pi can read unsaved loaded-buffer content and use current core Neovim context on demand.
115- Pi can execute arbitrary Neovim Lua and use structured editor operations.
116- A normal Pi edit to a loaded buffer appears without reload, is undoable, remains coherent with subsequent shell work, and receives visible activity markers.
117- Streaming edit arguments can produce non-mutating ghost presentation; incomplete arguments never mutate the real buffer.
118- Follow mode can track an agent edit in a dedicated viewport without taking over the user's working window.
119- Quickfix, location-list, diagnostic, and file navigation use normal Neovim behavior.
120- Existing Pi extensions and tools continue to run except for capabilities inherently specific to Pi's TUI.
121- A custom Neovim configuration can consume pivi state and events without requiring pivi to be installed or loaded.
122- pivi does not modify user-owned statuslines, winbars, tablines, global mappings, or picker configuration.
123- No filesystem watcher is started.

neovim/.system/specs/NL-SPEC-GMWDCMJZ-pivi-native-neovim-integration/native-agent-trail.html

Added
new file mode 100644

+92 / −0 text lines

1<section class="pivi-mockup">
2 <style>
3 :host { color-scheme: dark; font: 14px/1.35 ui-monospace, "Cascadia Mono", Consolas, monospace; }
4 .pivi-mockup { max-width: 1120px; margin: 0 auto; color: #d7d7d7; background: #17191d; border: 1px solid #464b55; box-shadow: 0 10px 35px #0008; }
5 .tabs, .winbar, .status { display: flex; align-items: center; min-height: 1.7em; padding: 0 .65em; white-space: pre; }
6 .tabs { background: #242830; gap: 1.1em; color: #a9b0bc; }
7 .tabs .active { color: #f0f0f0; background: #343945; margin: 0 -.4em; padding: 0 .4em; }
8 .workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(24em, 2fr); min-height: 29em; }
9 .window { min-width: 0; position: relative; }
10 .window + .window { border-left: 1px solid #464b55; }
11 .winbar { justify-content: space-between; background: #202329; color: #bfc5cf; border-bottom: 1px solid #30343c; }
12 .agent { color: #deb887; }
13 .buffer { padding: .45em 0 1em; overflow: hidden; }
14 .line { display: grid; grid-template-columns: 2em 1.2em minmax(0, 1fr); min-height: 1.45em; }
15 .num { color: #636b78; text-align: right; padding-right: .45em; user-select: none; }
16 .sign { color: #7f8794; text-align: center; }
17 .code { white-space: pre; overflow: hidden; }
18 .kw { color: #d49adf; } .str { color: #e6c384; }
19 .editing { background: #3a3223; }
20 .editing .sign { color: #efbd6b; }
21 .changed { background: #22352c; }
22 .changed .sign { color: #8ec07c; }
23 .virt { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); color: #87b98b; background: #1c2923; }
24 .virt::before { content: "+"; text-align: right; padding-right: .55em; color: #8ec07c; }
25 .ghost { color: #98a1ad; font-style: italic; }
26 .status { justify-content: space-between; background: #292d35; color: #ccd0d8; border-top: 1px solid #464b55; }
27 .external { color: #89919e; }
28 .controls { display: flex; gap: .5em; padding: .65em; border-top: 1px solid #343944; background: #202329; }
29 button { font: inherit; color: #d7d7d7; background: #303540; border: 1px solid #565d69; padding: .3em .7em; }
30 button[aria-pressed="true"] { border-color: #d7a85d; color: #f3c77b; }
31 button:focus-visible { outline: 2px solid #9ccfd8; outline-offset: 2px; }
32 .note { margin-left: auto; align-self: center; color: #7f8794; }
33 </style>
34 <div class="tabs"><span class="active">1 api</span><span>2 tests</span><span>3 docs</span><span class="agent">π refactor-parser</span></div>
35 <div class="workspace">
36 <article class="window">
37 <header class="winbar"><span>lua/parser.lua</span><span>human workspace</span></header>
38 <div class="buffer">
39 <div class="line"><span class="num">38</span><span class="sign"> </span><span class="code"><span class="kw">local function</span> parse(input)</span></div>
40 <div class="line"><span class="num">39</span><span class="sign"> </span><span class="code"> <span class="kw">local</span> tokens = tokenize(input)</span></div>
41 <div class="line changed"><span class="num">40</span><span class="sign">┃</span><span class="code"> <span class="kw">return</span> parse_tokens(tokens)</span></div>
42 <div class="line"><span class="num">41</span><span class="sign"> </span><span class="code"><span class="kw">end</span></span></div>
43 <div class="line"><span class="num">42</span><span class="sign"> </span><span class="code"></span></div>
44 <div class="line"><span class="num">43</span><span class="sign"> </span><span class="code"><span class="kw">return</span> { parse = parse }</span></div>
45 </div>
46 </article>
47 <article class="window">
48 <header class="winbar"><span>lua/tokenize.lua</span><span class="agent">π editing 17:19</span></header>
49 <div class="buffer">
50 <div class="line"><span class="num">15</span><span class="sign"> </span><span class="code"><span class="kw">local function</span> scan(input)</span></div>
51 <div class="line"><span class="num">16</span><span class="sign"> </span><span class="code"> <span class="kw">local</span> result = {}</span></div>
52 <div class="line editing"><span class="num">17</span><span class="sign">●</span><span class="code"> <span class="kw">for</span> token <span class="kw">in</span> input:gmatch(<span class="str">'%S+'</span>) <span class="kw">do</span> <span class="ghost">π editing…</span></span></div>
53 <div class="virt"><span></span><span class="code"> result[#result + 1] = normalize(token)</span></div>
54 <div class="line editing"><span class="num">18</span><span class="sign">│</span><span class="code"> result[#result + 1] = token</span></div>
55 <div class="line editing"><span class="num">19</span><span class="sign">└</span><span class="code"> <span class="kw">end</span></span></div>
56 <div class="line"><span class="num">20</span><span class="sign"> </span><span class="code"> <span class="kw">return</span> result</span></div>
57 <div class="line"><span class="num">21</span><span class="sign"> </span><span class="code"><span class="kw">end</span></span></div>
58 </div>
59 </article>
60 </div>
61 <footer class="status"><span>NORMAL lua/parser.lua</span><span class="external">existing user-owned statusline remains untouched</span><span>40:3</span></footer>
62 <div class="controls" aria-label="Representative controls">
63 <button type="button" data-follow aria-pressed="true">Follow: window</button>
64 <button type="button" data-state aria-pressed="false">Show completed state</button>
65 <span class="note">Illustrative interaction only</span>
66 </div>
67 <script>
68 (() => {
69 const root = document.currentScript.mockupRoot;
70 const follow = root.querySelector('[data-follow]');
71 const state = root.querySelector('[data-state]');
72 follow.addEventListener('click', () => {
73 const on = follow.getAttribute('aria-pressed') !== 'true';
74 follow.setAttribute('aria-pressed', String(on));
75 follow.textContent = on ? 'Follow: window' : 'Follow: off';
76 });
77 state.addEventListener('click', () => {
78 const completed = state.getAttribute('aria-pressed') !== 'true';
79 state.setAttribute('aria-pressed', String(completed));
80 state.textContent = completed ? 'Show active state' : 'Show completed state';
81 root.querySelectorAll('.editing').forEach((line) => {
82 line.classList.toggle('editing', !completed);
83 line.classList.toggle('changed', completed);
84 });
85 const winbar = root.querySelectorAll('.winbar')[1].lastElementChild;
86 winbar.textContent = completed ? 'π edited 17:19' : 'π editing 17:19';
87 const ghost = root.querySelector('.ghost');
88 ghost.textContent = completed ? 'π changed' : 'π editing…';
89 });
90 })();
91 </script>
92</section>