mirror of
https://github.com/dwinkler1/nvimConfig.git
synced 2026-08-22 17:43:13 -04:00
8.4 KiB
8.4 KiB
CodeCompanion Revamp Plan
Context
- Current: CodeCompanion 19.18.0 via nixpkgs
vimPlugins.codecompanion-nvim(nixpkgs input lastModified ~2026-05-15). - Latest: 19.20.0. Key changes since 19.18.0:
- v19.19.0:
claude-sonnet-5support, async/dynamic model fetching, copilottop_pfixes, inline orphaned-keymap fix, background command deregistration. - v19.20.0:
gemini_interactionsadapter, PDF support for http adapters (/fileon Anthropic/Copilot/OpenAI/OpenRouter), env vars from files, prompt-library items auto-receive default rule groups, copilot schema options removed.
- v19.19.0:
- Bug in current setup: config sets
model = "claude-sonnet-5"but 19.18.0 predates its support; the model name may not resolve. The nixpkgs bump fixes this. - Files involved:
plugin/24_completion.lua—get_codecompanion_config(), setup, blink integration.plugin/10_keymap.lua—<leader>a*keymaps (lines 69–84, contains duplicates/commented cruft).overlays/plugins.nix— codecompanion overlay (nvimSkipModules); likely unchanged.modules/module/specs/plugins.nix— plugin spec; unchanged.
Decisions (confirmed with user)
- Version bump:
nix flake update nixpkgs(accepts wider plugin bump; do NOT override src). - Adopt: agent-mode keymaps, one workflow prompt, minor slash-command config (
/sharetoken). No MCP. - Models:
claude-sonnet-5(copilot) for chat only; cheaper copilot model for inline and background (title generation) — usegpt-5-minias placeholder; verify exact model id viagamodel picker in a chat buffer after the bump and adjust. - Codex (ChatGPT Edu) = heavy agent lane. Copilot stays the default chat adapter; Codex ACP is launched explicitly for heavy autonomous tasks. Auth via ChatGPT login only (no API key) — user's existing
auth_method = "chatgpt"is correct per the v19.20.0 adapter source ("openai-api-key"|"codex-api-key"|"chatgpt"; the docs page comment"chat-gpt"is stale).
Tasks
-
Bump nixpkgs
- Run
nix flake update nixpkgs. - Verify:
nix eval --raw nixpkgs#vimPlugins.codecompanion-nvim.versionreports ≥ 19.20.0. - Rebuild the wrapped Neovim per this repo's normal build (
nix build/ the repo's usual package target) and smoke-test that the editor starts.
- Run
-
plugin/24_completion.lua—get_codecompanion_config()- Keep
interactions.chat.adapter = { name = "copilot", model = "claude-sonnet-5" }. - Change
interactions.inline.adapterto{ name = "copilot", model = "gpt-5-mini" }(cheap/fast). - Add a background adapter so title generation doesn't use Sonnet: set the background chat adapter to copilot/
gpt-5-mini(config lives underinteractions.background.chat; confirm exact key against:h codecompanion/:checkhealth codecompanionafter the bump — the docs page "Generating Titles" says an adapter must be configured for background interactions). - Keep existing context_management, rules, display, shared keymaps unchanged.
- Add
interactions.chat.slash_commands["share"].opts.token = os.getenv("GITHUB_GIST_TOKEN"). - Prompt library additions (keep
expert,fixer,suggest):["agent"]: interaction "chat", aliasagent, first user prompt starts with@{agent}plus selected code block, so Copilot/Claude gets the file-editing tool group (read_file, insert_edit_into_file, grep_search, run_command, etc., with approvals).["tdd"](name flexible): interaction "chat",opts = { is_workflow = true, alias = "tdd" }— 3-stage workflow: (1) plan/understand#buffer, (2)@{agent}implement, (3)@{run_command}run the test suite (leverages run_command's test-flag for agentic workflows).
- Keep
-
plugin/10_keymap.lua— clean up + add- Remove duplicated/commented lines (70–71, 77, 81).
- Add:
nmap_leader("aa", "<cmd>CodeCompanionChat<CR>", "Agent chat (use @{agent})")or directly<cmd>CodeCompanion /agent<CR>.xmap_leader("aa", "<cmd>CodeCompanion /agent<CR>", "Agent on selection").nmap_leader("aw", "<cmd>CodeCompanion /tdd<CR>", "Workflow: plan→implement→test").nmap_leader("aC", "<cmd>CodeCompanion /compact<CR>", "Compact chat")(verify<leader>aCdoesn't clash).
- Keep existing mappings unchanged.
-
No changes to
overlays/plugins.nixormodules/module/specs/plugins.nixunless the new version introduces new lazy-module load failures (re-run the build's check phase;doCheck = falseis already set on the spec entry). -
Codex ACP lane (ChatGPT Edu)
- Resolved prerequisite: user has installed
codex-acpat~/.nix-profile/bin/codex-acp(verified on PATH 2026-07-24). The preset adapter's default command (codex-acp) now works as-is — nocommandsoverride in the Lua config. Fallback only if the binary misbehaves: override withcommands = { default = { "codex", "acp" } }(requires the codex CLI's built-inacpsubcommand; verify withcodex acp --help). - Config change (small): none strictly required — the existing
extend("codex", { defaults = { auth_method = "chatgpt" } })block inplugin/24_completion.luais correct. Keep it. - Auth: prereq is an active
codex loginsession with the ChatGPT Edu account (~/.codex/auth.jsonexists — user confirms validity; if expired, re-runcodex login, browser/ChatGPT-app flow, no API key). - Keep codex on-demand (do NOT make it the default chat adapter):
- Keep
<leader>ak(:CodeCompanionChat adapter=codex). - Add comment documenting ACP-only slash commands for this lane:
/resume(restore past codex session, fresh chat only),/mode(switch agent mode),/command,/acp_session_options, plus\-triggered ACP command completion in the chat buffer.
- Keep
- Do not set a default codex model in config; pick per-session via
ga//acp_session_options(avoids hardcoding model ids that change with the Edu plan). - PATH note: Neovim must inherit a PATH containing
~/.nix-profile/binso the spawnedcodex-acpresolves — true when nvim is launched from the user's normal shell; call it out if validation fails with "command not found".
- Resolved prerequisite: user has installed
-
Docs/habit notes (add as comment block above the codecompanion setup, no separate docs file):
/compact,/fork,/symbols,/share,/resume+/mode(codex ACP),gm(btw),gty(YOLO),gba/gbd(buffer sync),gd(debug window).
Validation
nix flake update nixpkgsthen repo build succeeds.- In Neovim:
:checkhealth codecompanionclean. :CodeCompanionChat, pressga→ copilot adapter listsclaude-sonnet-5; send a trivial message and confirm response + auto title generation.- In chat: type
@→ completion showsagent,files,memory, etc.; run@{agent}task on a scratch repo and confirm the approval prompt flow works. :CodeCompanion /tddstarts the workflow stages in order.- Inline: visual-select code,
:CodeCompanionprompt → confirm diff shows andga/graccept/reject still work on the cheap model. :CodeCompanion /shareprompts/errors sensibly ifGITHUB_GIST_TOKENunset.- Codex lane:
<leader>akopens a chat with the codex ACP adapter; the spawnedcodex-acpprocess initializes without auth errors (ChatGPT method), a trivial prompt gets a response, and/modelists codex session modes. If it fails with command-not-found, check that Neovim inherited~/.nix-profile/binin PATH (:echo $PATHinside nvim).
Risks
nix flake update nixpkgsbumps all vimPlugins and Neovim itself; other plugins may break. If the blast radius is too large, fall back to overriding codecompanionsrcto tagv19.20.0inoverlays/plugins.nix(fetchFromGitHub,doCheck = false).- Model ids (
claude-sonnet-5,gpt-5-mini) must match the copilot adapter's choices post-bump; verify viagapicker and adjust literals. gpt-5-minimay not support tool use on copilot — fine, since inline/background don't use tools.codex-acplives in the user's nix profile (outside this flake). If the profile is rebuilt/removed, the codex lane breaks — long-term consider addingcodex-acpto this flake's runtime deps so it's pinned with the rest of the setup (optional follow-up, not required now).- ChatGPT Edu accounts authenticate codex via browser/ChatGPT-app login; token expiry will surface as ACP auth errors → re-run
codex login.
Out of scope
- MCP server integration.
- Custom rules parsers, custom tools, extensions (mcphub/history/vectorcode).