docs(neovim): specify native pivi integration
c1da466837edfe921e9406bc22ca80aeacd72155
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
- Parent 1: a05395f9e7fd
bugabingas dorkfiles
c1da466837edfe921e9406bc22ca80aeacd72155
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
+215 / −0 text lines
new file mode 100644+123 / −0 text lines
---id: NL-SPEC-GMWDCMJZtype: spectitle: pivi Native Neovim Integration---# pivi Native Neovim Integration## Intentpivi makes Pi feel native inside Neovim rather than embedding Pi's terminal interface.Pi remains a fully empowered coding agent.Neovim supplies editing, navigation, presentation, and live editor context.[Accepted native edit and follow-mode mockup](./native-agent-trail.html)## Scopepivi provides:- Persistent Pi sessions controlled through Pi RPC.- Neovim buffers for prompts, transcripts, session navigation, and detailed output.- Native quickfix lists, location lists, diagnostics, extmarks, signs, diffs, and navigation.- Live access to core Neovim state and unrestricted Neovim Lua execution.- A bundled Pi companion extension loaded in addition to the user's normal Pi configuration.Initial editor tools focus on buffers, selections, windows, tabs, marks, jumps, changes, lists, diagnostics, commands, and Lua execution.LSP-specific tools are outside the initial scope.## Session behavior- A Pi session is an explicit task identity with persistent history.- Each session captures a working directory as its execution scope.- Multiple sessions may share one working directory.- A tab may select a default session but does not own its lifetime.- Source buffers do not own sessions.- Closing a session window hides presentation without deleting history or implicitly stopping Pi.## Editor context- Each submission may carry an immutable snapshot of its originating buffer, path, revision, cursor, range, selection kind, selected text, and bounded surrounding text.- Queued submissions retain their own snapshots.- Pi can obtain fresh ambient editor state before later model calls.- Full buffer contents are fetched on demand rather than attaching every open buffer automatically.- Loaded buffers, including unsaved contents, are authoritative for editor-aware reads.- The Pi prompt receives a short stable orientation to the live Neovim environment without replacing existing system or project instructions.## Editing- Pi may edit without an approval gate.- Reads, edits, and writes preserve the behavior and improvements of Pi's upstream tools while making loaded Neovim buffers authoritative.- Agent changes to loaded buffers appear directly in Neovim, remain undoable, and become visible to filesystem-based commands without requiring manual reload.- Unloaded paths retain normal Pi filesystem behavior.- Validated edit intent may appear progressively as ghost text while tool arguments stream.- Real buffer mutation begins only after complete valid edit arguments exist.- An edit operation presents one coherent undoable change where Neovim permits it.- pivi uses no filesystem watchers.- Arbitrary shell or third-party tool mutations without identified paths are not represented as precise editor edits.## Agent activity- Active edits may use signs, line highlights, extmarks, virtual text, or virtual lines.- Completed edits leave a navigable changed-line trail until cleared by defined editor activity or session action.- Activity belongs to its Pi session and does not overwrite unrelated diagnostic or extmark namespaces.- File and range references are navigable through normal Neovim motions and lists.- Cross-file findings use quickfix lists.- Window-associated findings use location lists.- AI diagnostics remain distinguishable from compiler and language-server diagnostics.## Follow-agent mode- Follow mode is optional and disabled unless selected by the user.- It follows location-bearing reads, edits, findings, and explicit navigation rather than every event.- It can follow in a dedicated window, a dedicated tab, or the current window.- Dedicated-window following preserves the user's working window.- Passive following avoids unnecessary jumplist pollution.- The user can return to the location held before following began.## Pi compatibility- The companion extension is shipped with pivi and injected additively when Pi starts.- User, project, package, provider, skill, prompt, and tool configuration continues to load under Pi's normal rules.- pivi does not silently alter Pi project trust or restrict available tools.- Extension tools, commands, hooks, prompt changes, session behavior, and supported RPC dialogs remain functional.- TUI-only renderers, custom components, keybindings, headers, footers, and terminal input are not emulated.- Supported extension dialogs and status requests map to native Neovim surfaces.- Unrestricted Neovim Lua execution is available alongside structured convenience tools.## Native integration invariantpivi is an optional producer of native Neovim state, never the owner of surrounding configuration.- It does not replace or require a statusline, winbar, tabline, picker, notification system, layout, or keymap framework.- It publishes cached state through native variables and semantic `User` events.- It offers commands and `<Plug>` mappings without imposing global mappings.- Consumers can degrade to ordinary Neovim behavior when pivi is absent.- Loading pivi succeeds when the Pi executable is unavailable; starting Pi reports the missing capability.- Status consumers never perform Pi RPC during statusline evaluation.## Transport and status- Pi RPC uses a non-terminal JSONL subprocess channel.- Terminal dimensions, alternate screens, cursor escapes, and terminal key forwarding are not part of pivi.- Standard error remains separate from protocol output.- ANSI styling in payload text is stripped or translated before native presentation.- Semantic session status includes connection, queue, run, tool, waiting, compaction, retry, abort, and error states.- Status also exposes available model, thinking, session, context, usage, and extension-status data.- Status changes redraw native status surfaces and emit a semantic event.## Acceptance criteria- A user can create, resume, switch, and stop explicit Pi sessions without tying their lifetime to a source buffer or tab.- A prompt can include an unsaved selection with stable source and revision metadata.- Pi can read unsaved loaded-buffer content and use current core Neovim context on demand.- Pi can execute arbitrary Neovim Lua and use structured editor operations.- A normal Pi edit to a loaded buffer appears without reload, is undoable, remains coherent with subsequent shell work, and receives visible activity markers.- Streaming edit arguments can produce non-mutating ghost presentation; incomplete arguments never mutate the real buffer.- Follow mode can track an agent edit in a dedicated viewport without taking over the user's working window.- Quickfix, location-list, diagnostic, and file navigation use normal Neovim behavior.- Existing Pi extensions and tools continue to run except for capabilities inherently specific to Pi's TUI.- A custom Neovim configuration can consume pivi state and events without requiring pivi to be installed or loaded.- pivi does not modify user-owned statuslines, winbars, tablines, global mappings, or picker configuration.- No filesystem watcher is started.new file mode 100644+92 / −0 text lines
<section class="pivi-mockup"> <style> :host { color-scheme: dark; font: 14px/1.35 ui-monospace, "Cascadia Mono", Consolas, monospace; } .pivi-mockup { max-width: 1120px; margin: 0 auto; color: #d7d7d7; background: #17191d; border: 1px solid #464b55; box-shadow: 0 10px 35px #0008; } .tabs, .winbar, .status { display: flex; align-items: center; min-height: 1.7em; padding: 0 .65em; white-space: pre; } .tabs { background: #242830; gap: 1.1em; color: #a9b0bc; } .tabs .active { color: #f0f0f0; background: #343945; margin: 0 -.4em; padding: 0 .4em; } .workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(24em, 2fr); min-height: 29em; } .window { min-width: 0; position: relative; } .window + .window { border-left: 1px solid #464b55; } .winbar { justify-content: space-between; background: #202329; color: #bfc5cf; border-bottom: 1px solid #30343c; } .agent { color: #deb887; } .buffer { padding: .45em 0 1em; overflow: hidden; } .line { display: grid; grid-template-columns: 2em 1.2em minmax(0, 1fr); min-height: 1.45em; } .num { color: #636b78; text-align: right; padding-right: .45em; user-select: none; } .sign { color: #7f8794; text-align: center; } .code { white-space: pre; overflow: hidden; } .kw { color: #d49adf; } .str { color: #e6c384; } .editing { background: #3a3223; } .editing .sign { color: #efbd6b; } .changed { background: #22352c; } .changed .sign { color: #8ec07c; } .virt { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); color: #87b98b; background: #1c2923; } .virt::before { content: "+"; text-align: right; padding-right: .55em; color: #8ec07c; } .ghost { color: #98a1ad; font-style: italic; } .status { justify-content: space-between; background: #292d35; color: #ccd0d8; border-top: 1px solid #464b55; } .external { color: #89919e; } .controls { display: flex; gap: .5em; padding: .65em; border-top: 1px solid #343944; background: #202329; } button { font: inherit; color: #d7d7d7; background: #303540; border: 1px solid #565d69; padding: .3em .7em; } button[aria-pressed="true"] { border-color: #d7a85d; color: #f3c77b; } button:focus-visible { outline: 2px solid #9ccfd8; outline-offset: 2px; } .note { margin-left: auto; align-self: center; color: #7f8794; } </style> <div class="tabs"><span class="active">1 api</span><span>2 tests</span><span>3 docs</span><span class="agent">π refactor-parser</span></div> <div class="workspace"> <article class="window"> <header class="winbar"><span>lua/parser.lua</span><span>human workspace</span></header> <div class="buffer"> <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> <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> <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> <div class="line"><span class="num">41</span><span class="sign"> </span><span class="code"><span class="kw">end</span></span></div> <div class="line"><span class="num">42</span><span class="sign"> </span><span class="code"></span></div> <div class="line"><span class="num">43</span><span class="sign"> </span><span class="code"><span class="kw">return</span> { parse = parse }</span></div> </div> </article> <article class="window"> <header class="winbar"><span>lua/tokenize.lua</span><span class="agent">π editing 17:19</span></header> <div class="buffer"> <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> <div class="line"><span class="num">16</span><span class="sign"> </span><span class="code"> <span class="kw">local</span> result = {}</span></div> <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> <div class="virt"><span></span><span class="code"> result[#result + 1] = normalize(token)</span></div> <div class="line editing"><span class="num">18</span><span class="sign">│</span><span class="code"> result[#result + 1] = token</span></div> <div class="line editing"><span class="num">19</span><span class="sign">└</span><span class="code"> <span class="kw">end</span></span></div> <div class="line"><span class="num">20</span><span class="sign"> </span><span class="code"> <span class="kw">return</span> result</span></div> <div class="line"><span class="num">21</span><span class="sign"> </span><span class="code"><span class="kw">end</span></span></div> </div> </article> </div> <footer class="status"><span>NORMAL lua/parser.lua</span><span class="external">existing user-owned statusline remains untouched</span><span>40:3</span></footer> <div class="controls" aria-label="Representative controls"> <button type="button" data-follow aria-pressed="true">Follow: window</button> <button type="button" data-state aria-pressed="false">Show completed state</button> <span class="note">Illustrative interaction only</span> </div> <script> (() => { const root = document.currentScript.mockupRoot; const follow = root.querySelector('[data-follow]'); const state = root.querySelector('[data-state]'); follow.addEventListener('click', () => { const on = follow.getAttribute('aria-pressed') !== 'true'; follow.setAttribute('aria-pressed', String(on)); follow.textContent = on ? 'Follow: window' : 'Follow: off'; }); state.addEventListener('click', () => { const completed = state.getAttribute('aria-pressed') !== 'true'; state.setAttribute('aria-pressed', String(completed)); state.textContent = completed ? 'Show active state' : 'Show completed state'; root.querySelectorAll('.editing').forEach((line) => { line.classList.toggle('editing', !completed); line.classList.toggle('changed', completed); }); const winbar = root.querySelectorAll('.winbar')[1].lastElementChild; winbar.textContent = completed ? 'π edited 17:19' : 'π editing 17:19'; const ghost = root.querySelector('.ghost'); ghost.textContent = completed ? 'π changed' : 'π editing…'; }); })(); </script></section>