Repository navigation
feat(completion): live "/" completion for claude, codex, and gemini (no adapter, per-tool config) - #55
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR replaces static/disk-scanned slash-command completion sources with live probing for Claude, Codex, and ACP-native agents (Gemini). It adds configuration types, shared probe/cache/omnifunc infrastructure, per-tool probe modules, ftplugin wiring, health checks, tests, and documentation. ChangesLive probe-based slash completion
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Ftplugin as ftplugin/aibo-tool-*.lua
participant PromptFtplugin as prompt_ftplugin
participant Completion as completion module (claude/codex/gemini)
participant Agent as CLI/Adapter process
Ftplugin->>PromptFtplugin: setup_completion(bufnr, module, config_key)
PromptFtplugin->>Completion: refresh_acp(opts, callback)
Completion->>Agent: spawn probe (initialize, protocol-specific request)
Agent-->>Completion: command/skill list
Completion-->>PromptFtplugin: cached entries or error
Ftplugin->>PromptFtplugin: setup_triggers(bufnr)
Note over Ftplugin,Completion: omnifunc later reads cached entries for "/" completion
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in Claude slash-command completion source that probes the Agent Client Protocol (ACP) adapter for a live, version-accurate command list, caches it per-cwd, and prefers it over the static BUILTIN_COMMANDS when present—while preserving the existing PTY-based interactive session and falling back to the static sources when ACP is unavailable.
Changes:
- Introduces an async ACP probe client (
vim.system, newline-delimited JSON-RPC) with per-cwd caching and defensive parsing. - Updates Claude completion to prefer cached ACP commands as the base list and adds an explicit
refresh_acp()warmer. - Adds opt-in cache warming in the Claude ftplugin plus documentation and test coverage (including a fake adapter fixture).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lua/aibo/completion/acp.lua |
New ACP probe client: initialize → session/new → cache available_commands_update. |
lua/aibo/completion/claude.lua |
Prefer cached ACP list as completion base; expose refresh_acp(). |
ftplugin/aibo-tool-claude.lua |
Opt-in cache warming on Claude prompt buffer load (only if adapter exists). |
tests/completion/test_acp.lua |
New unit/integration tests for parser, cache, refresh, and adapter-missing path. |
tests/completion/fixtures/fake_acp.lua |
Fake ACP adapter fixture that replays a recorded available_commands_update. |
tests/completion/test_claude.lua |
Tests that builtin base is used on cache miss and ACP base is preferred once cached. |
README.md |
Documents tools.claude.acp_completion option and requirements. |
lua/aibo/init.lua |
Adds acp_completion to the Claude tool config type annotation. |
ACP_COMPLETION_OVERVIEW.md |
Design/overview doc for ACP-backed completion and rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
ftplugin/aibo-tool-claude.lua (1)
24-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor duplication:
get_tool_config("claude")fetched twice.
claude_cfg(line 24) andcfg(line 34) resolve the same tool config. Reuse a single lookup to keep the ftplugin tidy.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ftplugin/aibo-tool-claude.lua` around lines 24 - 34, The claude ftplugin is doing the same tool-config lookup twice, once in the completion setup and again before the default key mappings. Reuse a single `aibo.get_tool_config("claude")` result in `aibo-tool-claude.lua` and thread that config through the completion and mapping setup so the file only resolves the claude config once.lua/aibo/completion/acp.lua (1)
182-217: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdapter early-exit / stdout EOF isn't handled, so failures wait the full timeout.
The
on_exithandler is a no-op (Line 212) andon_stdoutsimply returns on EOF (data == nil, Line 183). If the adapter spawns but crashes, exits, or closes stdout before pushingavailable_commands_update(e.g. not logged in, version mismatch), nothing callsfinishuntil the timer expires — the caller waits the fulltimeout(default 10s) before silently falling back. Wiringfinish(nil, err)intoon_exit(and on stdout EOF) lets the fallback happen promptly with a clearer error.♻️ Finish early on unexpected exit
state.proc = vim.system(cmd, { cwd = cwd, stdin = true, stdout = on_stdout, text = true, - }, function() end) + }, function(obj) + -- If the adapter exits before delivering available_commands_update, + -- fail fast instead of waiting out the timeout. + finish(nil, ("ACP adapter exited (code=%s, signal=%s) before delivering commands"):format( + tostring(obj.code), tostring(obj.signal))) + end)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/aibo/completion/acp.lua` around lines 182 - 217, The ACP probe path in on_stdout and the vim.system exit callback does not finish early when the adapter exits or closes stdout before sending available_commands_update, so failures wait for the full timeout. Update the acp.lua flow by handling EOF in on_stdout and replacing the no-op vim.system callback with an on_exit handler that calls finish(nil, err) for unexpected exits, while keeping the existing state.done guard so the fallback happens promptly instead of silently timing out.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ACP_COMPLETION_OVERVIEW.md`:
- Around line 1-6: The status header in ACP_COMPLETION_OVERVIEW.md is stale and
still says the design is only a proposal, which conflicts with the implemented
sections and shipped feature. Update the top-level status text to reflect the
completed/implemented state, and make it consistent with the ✅ items in §8 so
readers see the correct lifecycle for the ACP completion work.
In `@ftplugin/aibo-tool-claude.lua`:
- Line 28: The warm-up call to refresh_acp in aibo-tool-claude.lua is using
empty options, which makes the probe fall back to a different cwd and MCP server
set than the live Claude session. Update the call site to pass the session’s
actual cwd and mcpServers into refresh_acp so the ACP probe uses the same
configuration as the real session and returns a matching command list.
In `@lua/aibo/completion/acp.lua`:
- Around line 82-94: The ACP refresh path in M.refresh should not respawn the
adapter when the cache already has a live entry for the current cwd. Add a
short-circuit near the existing executable check and before launching the
refresh command so it consults acp.get_cached() (or the existing cache helper
used by the ACP module) and returns the cached result when warm, instead of
re-probing on every ftplugin load. Keep the behavior localized to M.refresh and
preserve the current callback/error flow when the adapter is actually missing or
stale.
---
Nitpick comments:
In `@ftplugin/aibo-tool-claude.lua`:
- Around line 24-34: The claude ftplugin is doing the same tool-config lookup
twice, once in the completion setup and again before the default key mappings.
Reuse a single `aibo.get_tool_config("claude")` result in `aibo-tool-claude.lua`
and thread that config through the completion and mapping setup so the file only
resolves the claude config once.
In `@lua/aibo/completion/acp.lua`:
- Around line 182-217: The ACP probe path in on_stdout and the vim.system exit
callback does not finish early when the adapter exits or closes stdout before
sending available_commands_update, so failures wait for the full timeout. Update
the acp.lua flow by handling EOF in on_stdout and replacing the no-op vim.system
callback with an on_exit handler that calls finish(nil, err) for unexpected
exits, while keeping the existing state.done guard so the fallback happens
promptly instead of silently timing out.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a3bb71ad-9071-4b64-9a80-3006d890198a
📒 Files selected for processing (9)
ACP_COMPLETION_OVERVIEW.mdREADME.mdftplugin/aibo-tool-claude.lualua/aibo/completion/acp.lualua/aibo/completion/claude.lualua/aibo/init.luatests/completion/fixtures/fake_acp.luatests/completion/test_acp.luatests/completion/test_claude.lua
6bf7f1f to
ef66d3f
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lua/aibo/completion/acp.lua`:
- Around line 174-188: The auto-install flow in M.acp currently runs even for
custom opts.cmd values that cannot use the plugin-local fallback, which can lead
to an unnecessary npm install followed by a refresh failure. Update the logic
around M.is_available, M.install, and the auto_install branch so installation
only happens for the default adapter command, or alternatively make
resolve_cmd() reuse the installed local bin for those cases; ensure custom
commands skip auto-install when they cannot resolve to the local binary.
- Around line 137-139: The npm-missing branch in the ACP auto-install flow
returns before the one-shot state is recorded, so repeated Claude prompt buffers
keep retrying the same failed install. Update the ACP adapter install logic
around the `install_attempted` flag so this failure path also marks the attempt
as handled before returning, and keep the early `callback(false, ...)` behavior
in the same `acp.lua` install routine.
In `@lua/aibo/init.lua`:
- Around line 39-48: The default ACP completion config for the Claude tool is
currently enabling warm-up implicitly, making it opt-out instead of opt-in.
Update the default in the `tools.claude.acp` setup so it is `false` or omitted
by default, and only activates when a user explicitly configures it; make sure
the `ftplugin/aibo-tool-claude.lua` warm-up path still keys off `claude_cfg.acp`
so explicit user settings continue to work.
In `@tests/completion/test_acp.lua`:
- Around line 95-116: The test mutates process-wide state by overriding
vim.env.XDG_DATA_HOME, but the cleanup runs only after the assertions, so a
failure can leak the temporary value into later tests. Update the test around
acp.resolve_cmd to restore the original XDG_DATA_HOME and delete the temp dir in
a guaranteed cleanup path (for example using pcall/xpcall or a finally-like
helper) so cleanup runs even when the assertion fails.
In `@tests/internal/test_init.lua`:
- Around line 102-123: The default ACP assertions in the `claude acp config
defaults and override` test are order-dependent because `aibo.setup()` is
incremental and previous tests may have already mutated `tools.claude.acp`.
Reload `aibo` before the initial default checks so the test starts from a clean
configuration state, then keep the existing override assertions against
`aibo.get_tool_config("claude")` and the later `aibo.setup(...)` calls
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fd3fadc7-ff65-4a6a-af97-f388658bf970
📒 Files selected for processing (11)
ACP_COMPLETION_OVERVIEW.mdREADME.mdftplugin/aibo-tool-claude.lualua/aibo/completion/acp.lualua/aibo/completion/claude.lualua/aibo/health.lualua/aibo/init.luatests/completion/fixtures/fake_acp.luatests/completion/test_acp.luatests/completion/test_claude.luatests/internal/test_init.lua
✅ Files skipped from review due to trivial changes (1)
- ACP_COMPLETION_OVERVIEW.md
🚧 Files skipped from review as they are similar to previous changes (3)
- tests/completion/fixtures/fake_acp.lua
- lua/aibo/completion/claude.lua
- tests/completion/test_claude.lua
17ea918 to
674ef06
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (6)
lua/aibo/completion/probe.lua (1)
53-76: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueConsider bounding
state.bufgrowth.If the spawned process emits data without newlines (e.g., a malfunctioning binary),
state.bufgrows unbounded until the timeout fires. Low risk given trusted CLI targets, but a simple size cap (finish with an error) would guard against pathological cases.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/aibo/completion/probe.lua` around lines 53 - 76, The stdout parser in on_stdout can accumulate an unbounded state.buf when the child process emits no newline-delimited output. Add a maximum buffer size check in probe.lua’s on_stdout loop, and if the cap is exceeded, stop processing and call finish with an error so malformed output cannot grow memory indefinitely. Keep the existing line-splitting and handlers.on_message flow intact while guarding the state.buf append path.lua/aibo/completion/codex.lua (1)
183-197: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueSame synchronous-callback inconsistency as flagged in
acp.lua'sensure_and_refresh(Lines 192-195 here mirror that pattern).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/aibo/completion/codex.lua` around lines 183 - 197, The refresh_acp callback path has the same synchronous-callback inconsistency as ensure_and_refresh: when codex is unavailable, callback is invoked immediately while the successful path is asynchronous via refresh_probe. Update M.refresh_acp to make callback timing consistent across both branches by deferring the error callback in the unavailable case, and keep the behavior aligned with the pattern used in the related ACP refresh flow.lua/aibo/completion/gemini.lua (1)
58-62: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAvoid mutating the caller-supplied
optstable.
opts.cmd = opts.cmd or DEFAULT_PROBE_CMDmutates the table passed in by the caller (e.g. a sharedtools.gemini.acpconfig table) rather than working on a local copy. Harmless today since the effective value stays consistent, but it's a side-effect surprise for callers reusing the same table across calls.♻️ Proposed fix
function M.refresh_acp(opts, callback) - opts = opts or {} - opts.cmd = opts.cmd or DEFAULT_PROBE_CMD - acp.ensure_and_refresh(opts, callback) + opts = opts or {} + acp.ensure_and_refresh(vim.tbl_extend("force", { cmd = DEFAULT_PROBE_CMD }, opts), callback) end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/aibo/completion/gemini.lua` around lines 58 - 62, In M.refresh_acp, avoid changing the caller’s opts table in place; the current opts.cmd assignment mutates shared config passed by callers. Make a local copy of opts inside refresh_acp, apply the DEFAULT_PROBE_CMD fallback on that copy, and pass the copied table to acp.ensure_and_refresh so repeated calls with the same tools.gemini.acp settings do not get side effects.lua/aibo/completion/acp.lua (1)
88-96: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueInconsistent sync/async callback contract in
ensure_and_refresh.The "not available" early return (Line 92) invokes
callbacksynchronously, whilerefresh's own "cmd not found" branch (Lines 108-113) wraps it invim.schedule. Callers that assume the callback always fires asynchronously (e.g., after the current call stack unwinds) can be surprised by the sync path. Worth making both branches consistently scheduled. The same pattern is repeated inclaude.lua's andcodex.lua'srefresh_acp.♻️ Proposed fix
function M.ensure_and_refresh(opts, callback) opts = opts or {} callback = callback or function() end if not M.is_available(opts) then - callback(nil, "ACP agent not found: " .. tostring(opts.cmd and opts.cmd[1])) - return + vim.schedule(function() + callback(nil, "ACP agent not found: " .. tostring(opts.cmd and opts.cmd[1])) + end) + return end M.refresh(opts, callback) endAlso applies to: 102-113
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/aibo/completion/acp.lua` around lines 88 - 96, `ensure_and_refresh` currently mixes synchronous and scheduled callback delivery: the early `M.is_available(opts)` failure calls `callback` immediately, while `M.refresh` and its missing-command path use `vim.schedule`. Make the not-available branch in `ensure_and_refresh` also invoke the callback via `vim.schedule` so the contract is consistently async; apply the same pattern in the corresponding `refresh_acp` flow in `claude.lua` and `codex.lua` if they have the same early-return path.lua/aibo/completion/claude.lua (1)
185-199: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueSame synchronous-callback inconsistency as
acp.lua'sensure_and_refresh: the "not found" branch (Lines 194-197) callscallbackdirectly instead of scheduling it, unlikerefresh_probe's own not-found path (Lines 122-127). See the comment onlua/aibo/completion/acp.lua(Lines 88-96) for the suggested fix; same pattern applies here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/aibo/completion/claude.lua` around lines 185 - 199, In M.refresh_acp, the "claude not found" branch currently invokes callback synchronously, which is inconsistent with the async callback behavior used elsewhere in the completion flow. Update this branch to schedule the callback on the next tick, matching the pattern used by refresh_probe and the corresponding ensure_and_refresh logic in acp.lua, and keep the same error message construction using M.is_available, DEFAULT_PROBE_CMD, and callback.lua/aibo/completion/prompt_ftplugin.lua (1)
25-34: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConcurrent buffer opens in the same cwd can trigger duplicate probe spawns.
get_cached()(sync) is checked beforerefresh_acp()(async) with no in-flight tracking. Opening two prompt buffers for the same cwd back-to-back, before the first probe's callback populates the cache, spawns the external agent process twice for the same cache key.♻️ Sketch: track in-flight refresh per cwd
+local inflight = {} + function M.setup_completion(bufnr, module_name, config_key) ... if probe_cfg then local cfg = type(probe_cfg) == "table" and probe_cfg or {} - if not completion.get_cached() then - completion.refresh_acp({ cmd = cfg.cmd, timeout = cfg.timeout }) + local cwd = cfg.cwd or vim.fn.getcwd() + local key = module_name .. ":" .. cwd + if not completion.get_cached(cwd) and not inflight[key] then + inflight[key] = true + completion.refresh_acp({ cmd = cfg.cmd, cwd = cwd, timeout = cfg.timeout }, function() + inflight[key] = nil + end) end end end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/aibo/completion/prompt_ftplugin.lua` around lines 25 - 34, The probe path in prompt_ftplugin.lua can spawn duplicate agents because completion.get_cached() is checked before the async refresh_acp() finishes. Update the prompt buffer setup logic around aibo.get_completion_config, completion.get_cached, and completion.refresh_acp to track an in-flight refresh per cwd and skip starting another probe while one is already pending. Use the existing cwd/cache-key flow in completion so back-to-back opens reuse the same pending request instead of launching the external agent twice.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lua/aibo/completion/acp.lua`:
- Around line 126-131: The initialize handshake in acp.lua is advertising a
capability that this client does not actually support. Update the on_start/send
path in the request("initialize", ...) setup so
clientCapabilities.fs.readTextFile is reported as false instead of true, since
fs/read_text_file is not implemented and should not be promised by this client.
---
Nitpick comments:
In `@lua/aibo/completion/acp.lua`:
- Around line 88-96: `ensure_and_refresh` currently mixes synchronous and
scheduled callback delivery: the early `M.is_available(opts)` failure calls
`callback` immediately, while `M.refresh` and its missing-command path use
`vim.schedule`. Make the not-available branch in `ensure_and_refresh` also
invoke the callback via `vim.schedule` so the contract is consistently async;
apply the same pattern in the corresponding `refresh_acp` flow in `claude.lua`
and `codex.lua` if they have the same early-return path.
In `@lua/aibo/completion/claude.lua`:
- Around line 185-199: In M.refresh_acp, the "claude not found" branch currently
invokes callback synchronously, which is inconsistent with the async callback
behavior used elsewhere in the completion flow. Update this branch to schedule
the callback on the next tick, matching the pattern used by refresh_probe and
the corresponding ensure_and_refresh logic in acp.lua, and keep the same error
message construction using M.is_available, DEFAULT_PROBE_CMD, and callback.
In `@lua/aibo/completion/codex.lua`:
- Around line 183-197: The refresh_acp callback path has the same
synchronous-callback inconsistency as ensure_and_refresh: when codex is
unavailable, callback is invoked immediately while the successful path is
asynchronous via refresh_probe. Update M.refresh_acp to make callback timing
consistent across both branches by deferring the error callback in the
unavailable case, and keep the behavior aligned with the pattern used in the
related ACP refresh flow.
In `@lua/aibo/completion/gemini.lua`:
- Around line 58-62: In M.refresh_acp, avoid changing the caller’s opts table in
place; the current opts.cmd assignment mutates shared config passed by callers.
Make a local copy of opts inside refresh_acp, apply the DEFAULT_PROBE_CMD
fallback on that copy, and pass the copied table to acp.ensure_and_refresh so
repeated calls with the same tools.gemini.acp settings do not get side effects.
In `@lua/aibo/completion/probe.lua`:
- Around line 53-76: The stdout parser in on_stdout can accumulate an unbounded
state.buf when the child process emits no newline-delimited output. Add a
maximum buffer size check in probe.lua’s on_stdout loop, and if the cap is
exceeded, stop processing and call finish with an error so malformed output
cannot grow memory indefinitely. Keep the existing line-splitting and
handlers.on_message flow intact while guarding the state.buf append path.
In `@lua/aibo/completion/prompt_ftplugin.lua`:
- Around line 25-34: The probe path in prompt_ftplugin.lua can spawn duplicate
agents because completion.get_cached() is checked before the async refresh_acp()
finishes. Update the prompt buffer setup logic around
aibo.get_completion_config, completion.get_cached, and completion.refresh_acp to
track an in-flight refresh per cwd and skip starting another probe while one is
already pending. Use the existing cwd/cache-key flow in completion so
back-to-back opens reuse the same pending request instead of launching the
external agent twice.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 42cf6b48-1b9a-4322-b3a8-5312ddc04f62
📒 Files selected for processing (28)
.claude/rules/completion/sync-claude-slash-commands.mdREADME.mddoc/aibo-acp.txtdoc/aibo-claude.txtdoc/aibo-codex.txtdoc/aibo-dev.txtdoc/aibo-live-completion.txtftplugin/aibo-tool-claude.luaftplugin/aibo-tool-codex.luaftplugin/aibo-tool-gemini.lualua/aibo/completion/acp.lualua/aibo/completion/claude.lualua/aibo/completion/codex.lualua/aibo/completion/cwd_cache.lualua/aibo/completion/gemini.lualua/aibo/completion/omnifunc.lualua/aibo/completion/probe.lualua/aibo/completion/prompt_ftplugin.lualua/aibo/health.lualua/aibo/init.luatests/completion/fixtures/fake_acp.luatests/completion/fixtures/fake_claude_probe.luatests/completion/fixtures/fake_codex_probe.luatests/completion/test_acp.luatests/completion/test_claude.luatests/completion/test_codex.luatests/completion/test_gemini.luatests/internal/test_init.lua
💤 Files with no reviewable changes (1)
- .claude/rules/completion/sync-claude-slash-commands.md
✅ Files skipped from review due to trivial changes (5)
- lua/aibo/completion/cwd_cache.lua
- README.md
- doc/aibo-dev.txt
- doc/aibo-live-completion.txt
- doc/aibo-acp.txt
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/completion/fixtures/fake_acp.lua
| on_start = function(send) | ||
| request(send, "initialize", { | ||
| protocolVersion = 1, | ||
| clientCapabilities = { fs = { readTextFile = true, writeTextFile = false } }, | ||
| }) | ||
| end, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does the Agent Client Protocol require a client that advertises fs.readTextFile=true to actually implement fs/read_text_file, and what happens if a client returns an empty object instead of {content}?
💡 Result:
Yes, the Agent Client Protocol (ACP) requires a client that advertises the fs.readTextFile capability to implement the fs/read_text_file method [1][2]. If a client signals this capability during initialization, it is committing to providing that functionality, and an agent is permitted to call the method [1][3]. If a client returns an empty object {} instead of the expected {content: string} response for an fs/read_text_file request, it violates the protocol's expected response schema [4]. The fs/read_text_file method is defined to return a response containing the file's content [1][5]. Because the agent expects a specific structure containing the file content to proceed with its task, receiving an empty object will cause a runtime error, deserialization failure, or an agent-side logic error when it attempts to access the missing 'content' property [4]. In contrast, the fs/write_text_file method is explicitly designed to return an empty object {} upon successful completion [4]. Clients must strictly adhere to the defined return types for each method to ensure protocol interoperability [5][4].
Citations:
- 1: https://agentclientprotocol.com/protocol/v1/file-system
- 2: https://agentclientprotocol.com/protocol/v1/overview
- 3: https://agentclientprotocol.github.io/typescript-sdk/types/ReadTextFileRequest.html
- 4: https://agentclientprotocol-typescript-sdk.mintlify.app/clients/file-system-operations
- 5: https://agentclientprotocol.github.io/typescript-sdk/interfaces/Client.html
🏁 Script executed:
git ls-files 'lua/aibo/completion/acp.lua' && wc -l lua/aibo/completion/acp.lua && sed -n '1,220p' lua/aibo/completion/acp.luaRepository: lambdalisue/nvim-aibo
Length of output: 6888
🏁 Script executed:
rg -n "readTextFile|writeTextFile|session/request_permission|available_commands_update|fs/read_text_file|vim.empty_dict|on_message|initialize" lua/aibo/completion/acp.luaRepository: lambdalisue/nvim-aibo
Length of output: 1036
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file='lua/aibo/completion/acp.lua'
echo '--- line count ---'
wc -l "$file"
echo '--- matching lines ---'
rg -n "readTextFile|writeTextFile|session/request_permission|available_commands_update|fs/read_text_file|vim.empty_dict|on_message|initialize" "$file"
echo '--- excerpt ---'
sed -n '100,190p' "$file"Repository: lambdalisue/nvim-aibo
Length of output: 3770
🏁 Script executed:
python3 - <<'PY'
from pathlib import Path
p = Path('lua/aibo/completion/acp.lua')
text = p.read_text()
for needle in ['readTextFile', 'writeTextFile', 'session/request_permission', 'available_commands_update', 'fs/read_text_file', 'vim.empty_dict', 'on_message', 'initialize']:
print(f'## {needle}')
for i, line in enumerate(text.splitlines(), 1):
if needle in line:
print(f'{i}: {line}')
PYRepository: lambdalisue/nvim-aibo
Length of output: 1298
Advertise readTextFile: false here. fs/read_text_file isn’t implemented, so readTextFile: true promises a request this client answers with {} and can leave the agent hanging until timeout.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lua/aibo/completion/acp.lua` around lines 126 - 131, The initialize handshake
in acp.lua is advertising a capability that this client does not actually
support. Update the on_start/send path in the request("initialize", ...) setup
so clientCapabilities.fs.readTextFile is reported as false instead of true,
since fs/read_text_file is not implemented and should not be promised by this
client.
… for live "/" completion Claude's static BUILTIN_COMMANDS table and the ~/.claude/commands and ~/.claude/skills disk scans drift with every release and never see plugin-provided, MCP-provided, or dynamically-enabled commands. Neither claude nor codex speaks the Agent Client Protocol (ACP) themselves -- that only exists via separate adapters wrapping their SDKs/runtimes -- so both are probed directly instead: claude via its own internal stream-json control protocol, codex via its self-documenting `codex app-server` JSON-RPC protocol. Both send only a control-plane request, never a prompt, so no inference runs and no tokens are spent. acp.lua stays a generic, agent-agnostic Agent Client Protocol client (no default cmd) for agents that speak ACP natively -- gemini.lua wires it up for Gemini CLI (`gemini --acp`) as the first consumer. probe.lua, cwd_cache.lua, and omnifunc.lua factor out the async subprocess/JSON-message plumbing, per-cwd result cache, and omnifunc/prefix-filtering logic shared by all of the above, since none of that differs between the three probes.
… helper The omnifunc setup, probe-cache warming, and "/"/"@" auto-trigger keymaps were identical across aibo-tool-claude.lua and aibo-tool-codex.lua, differing only in which completion submodule and config key they used. prompt_ftplugin.lua factors that out so adding Gemini's ftplugin is a few lines instead of a full copy.
New completion.{claude,codex,acp} config, keyed by tool (acp.lua itself
has no default agent, so a bare true/false wouldn't mean anything
without a tool-specific module to supply the default cmd). All three
are on by default since none of them has a static or disk-scanned
fallback to preserve.
checkhealth reports whether each probe target resolves.
test_claude.lua drops the BUILTIN_COMMANDS/disk-scan coverage (removed in the previous commits) and adds cases for the empty-cache and probed-cache states instead. test_acp.lua, test_codex.lua, and test_gemini.lua are new, each driven against a fake responder fixture that replays a recorded protocol exchange so no real agent binary is needed in CI.
Replace the root-level ACP_COMPLETION_OVERVIEW.md with proper :help pages, since this is a Neovim plugin: aibo-live-completion.txt is the overview (motivation, billing safety, process management, configuration); aibo-acp.txt narrows to the real Agent Client Protocol and Gemini's use of it; aibo-claude.txt and aibo-codex.txt cover each tool's own (non-ACP) probe protocol and verification notes.
Summarized a long-since-completed refactor (agent→tool terminology, module reorganization) with nothing left to track.
84a4de0 to
de68033
Compare
leafo/gh-actions-lua downloads and builds Lua from lua.org, which was consistently failing with a TLS connection reset (reproduced across multiple CI runs, unrelated to any code change). Ubuntu's own lua5.1 package needs no external download beyond GitHub's apt mirrors.
Summary
Adds a live "/" completion source per tool, replacing the hand-synced
BUILTIN_COMMANDStable and on-disk scanning with each agent's own, session-accurate command/skill list. The interactive session keeps running over the PTY exactly as today — this is a read-only side-channel purely for completion candidates.Motivation: a hardcoded table drifts with every release (manual sync toil), and plugin-/MCP-/dynamically-enabled commands are invisible to a disk scan. Each agent already knows its own authoritative, version-accurate list.
Design: three probes, no external adapter
Claude and Codex do not speak the Agent Client Protocol (ACP) themselves — that only exists via separate community/vendor adapters (
claude-agent-acp,codex-acp) wrapping their SDKs/runtimes, a real external dependency (Node.js, npm, a package to keep updated) for a feature that only needs a list of strings. Since aibo already hard-depends on theclaude/codexbinaries themselves, each is probed directly instead:completion/claude.lua) — talksclaude's own internal stream-json control protocol (reverse-engineered from@anthropic-ai/claude-agent-sdk'ssdk.mjs, the libraryclaude-agent-acpitself uses).completion/codex.lua) — talkscodex app-server, a subcommand already built into thecodexbinary with a self-documenting schema (codex app-server generate-json-schema) — a meaningfully stronger foundation than Claude's reverse-engineered case.completion/gemini.lua) — Gemini CLI speaks the real, documented ACP natively (gemini --acp), so this wires up a generic, agent-agnostic ACP client (completion/acp.lua, no defaultcmd) instead of a bespoke protocol. Ready to reuse for any other ACP-native agent (Copilot, Cursor, Cline, ...) without modification once it gets its own aibo integration.All three send only a control-plane request — never a prompt turn (
session/prompt,control_request{subtype:"initialize"}, orinitialize/skills/list, critically neverthread/start) — so no inference runs and no tokens are consumed. The real interactive session stays first-party regardless of any Agent-SDK/ACP billing split. Seedoc/aibo-live-completion.txtfor the full design, anddoc/aibo-acp.txt/doc/aibo-claude.txt/doc/aibo-codex.txtfor each probe's protocol details and live-verification notes.Shared plumbing (
completion/probe.lua,completion/cwd_cache.lua,completion/omnifunc.lua,completion/prompt_ftplugin.lua) factors out the async subprocess/JSON-message handling, per-cwd cache, omnifunc/prefix-filtering, and ftplugin wiring common to all three, so each module only carries its own protocol-specific logic.Activation model: per-tool config, on by default
None of the three probes has a static or disk-scanned fallback anymore, so each is on by default. Completion config lives under
tools.<tool>.completion.<source>— alongside each tool's other settings (on_attach,no_default_mappings) — rather than as a separate global list, so it can be configured per tool profile rather than once globally:<tool>is whatever name aibo dispatches on (the first word of the invoked command);<source>selects which completion module backs it. A custom tool profile can opt into any module, not just the one matching its own name — e.g. a wrapper that launches a claude-flavored model can settools["my-wrapper"].completion.claude = trueto reuse Claude's probe.:checkhealth aiboreports whether each probe target resolves.What's in this PR
lua/aibo/completion/{acp,claude,codex,gemini}.lua— the four completion sources described above.lua/aibo/completion/{probe,cwd_cache,omnifunc,prompt_ftplugin}.lua— shared plumbing.ftplugin/aibo-tool-{claude,codex,gemini}.lua— wire live completion into prompt buffers viaprompt_ftplugin.lua.init.lua—tools.<name>.completion.<source>config, on by default for the three built-in tools.health.lua—:checkhealth aibosection per completion source.doc/aibo-live-completion.txt(overview),doc/aibo-acp.txt,doc/aibo-claude.txt,doc/aibo-codex.txt, README.BUILTIN_COMMANDSand the~/.claude/commands/~/.claude/skillsdisk scan (superseded by Claude's own live list, which already includes custom commands/skills), Codex's.codex/skillsdisk scan (same reasoning), and the now-obsoletesync-claude-slash-commands.mdmaintenance rule.Testing
tests/completion/test_{acp,claude,codex,gemini}.lua— pure parsers, per-cwd cache,refresh/refresh_acpagainst fake responder fixtures (tests/completion/fixtures/fake_{acp,claude_probe,codex_probe}.lua) that replay recorded protocol exchanges, resolve_cmd/is_available, and probe-missing error paths.tests/internal/test_init.lua— per-tool completion config defaults/override/disable, including a custom tool-name profile.stylua --checkandluacheckclean.claude/codex/geminibinaries (not just fakes): Claude ~1s round trip with real account data and no~/.claude/projectsside effect (--no-session-persistence); Codex ~1-2s round trip with real skill metadata; Gemini's ACP handshake completes correctly at the protocol level (blocked only by an unrelated account-tier restriction on the specific test account).Notes / follow-ups
acp.lua's cache is keyed only by cwd, not by agent — fine while Gemini is the only ACP-native agent wired up; revisit if a second one is added for the same cwd.-tool=/alias option, so a customtools.<name>profile only applies to invocations whose first word is literally<name>(e.g.tools.ollamafor:Aibo ollama launch claude ..., not an arbitrary label). Adding such an override is a separate, larger change (touches argument parsing and buffer naming), not included here.completion/<agent>.luaover the existing generic client.🤖 Generated with Claude Code