Skip to content

refactor(vim): inject code via bracketed paste, reference buffers by @path#71

Closed
lloydzhou wants to merge 1 commit into
feature/vim-pluginfrom
refactor/vim-direct-inject
Closed

refactor(vim): inject code via bracketed paste, reference buffers by @path#71
lloydzhou wants to merge 1 commit into
feature/vim-pluginfrom
refactor/vim-direct-inject

Conversation

@lloydzhou

Copy link
Copy Markdown
Owner

Summary

  • AgentSend 改为用 bracketed paste 直接把选中代码粘贴进 agent 输入框,不再写临时文件。vim8 term_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 的代码片段))。这次按讨论简化为两条更直接的路径:

  • 选区 → 直接粘贴。ccagent 的 linenoise 已支持 bracketed paste(c/vendor/linenoise/linenoise.c:606 启用 \x1b[?2004h1786 解析 \x1b[200~...\x1b[201~),claude / codex CLI 的 TUI 也都支持,多行代码不会被逐行提交。
  • 整 buffer → @path 引用。即使后端原生不解析 @,也会作为提示让 agent 调 Read 工具读取。

Test plan

  • python3 vim/test/smoke.py PASS(覆盖:环境变量启停、AgentAsk 回显、AgentSendBuffer 注入 @/abs/path、focus 竞态无 i 泄漏、退出后窗口自动关闭、--continue fallback)
  • 人工审核:在真实 ccagent 上验证多行选区粘贴、整文件 @ 引用、未保存 buffer 退化路径

@lloydzhou
lloydzhou marked this pull request as draft July 22, 2026 08:49
@lloydzhou

Copy link
Copy Markdown
Owner Author

误提:本 PR 应该在 lloydzhou/bash-agent-vim 项目,不是这里。回滚中。

@lloydzhou lloydzhou closed this Jul 22, 2026
@lloydzhou
lloydzhou deleted the refactor/vim-direct-inject branch July 22, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant