refactor(vim): inject code via bracketed paste, reference buffers by @path#71
Closed
lloydzhou wants to merge 1 commit into
Closed
refactor(vim): inject code via bracketed paste, reference buffers by @path#71lloydzhou wants to merge 1 commit into
lloydzhou wants to merge 1 commit into
Conversation
lloydzhou
marked this pull request as draft
July 22, 2026 08:49
Owner
Author
|
误提:本 PR 应该在 lloydzhou/bash-agent-vim 项目,不是这里。回滚中。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentSend改为用 bracketed paste 直接把选中代码粘贴进 agent 输入框,不再写临时文件。vim8term_sendkeys的<...>特殊键解析通过把字面量<转成<LT>记法规避。AgentSendBuffer已落盘且未修改的 buffer 改为注入@/abs/path引用,由 agent 自行用 Read 工具读取;未落盘 / 已修改 / 无名 buffer 自动退化为粘贴当前内容(避免 agent 读到磁盘旧版本)。s:ctx_dir/s:ensure_ctx_dir/s:write_ctx/agent#build_context/s:seq)和对应单测test_build_context.vim;同步更新 smoke 测试和中英文 README。Background
之前的方案是把代码写入
$TMPDIR/bash-agent-vim/ctx-*.md,再向 agent 注入一行短引用(看 /tmp/.../ctx.md(file:1-10 的代码片段))。这次按讨论简化为两条更直接的路径:c/vendor/linenoise/linenoise.c:606启用\x1b[?2004h,1786解析\x1b[200~...\x1b[201~),claude / codex CLI 的 TUI 也都支持,多行代码不会被逐行提交。@path引用。即使后端原生不解析@,也会作为提示让 agent 调 Read 工具读取。Test plan
python3 vim/test/smoke.pyPASS(覆盖:环境变量启停、AgentAsk回显、AgentSendBuffer注入@/abs/path、focus 竞态无i泄漏、退出后窗口自动关闭、--continuefallback)@引用、未保存 buffer 退化路径