feat: git credential backend for credential storage (#371)

## Problem

Credentials were stored as plaintext JSON in
`stdpath('data')/cp-nvim.json`, with no integration with system
credential managers.

## Solution

Replace file-based credential storage with `git credential
fill/approve/reject`, delegating to whatever credential helper the user
has configured (`cache`, `store`, `libsecret`, macOS Keychain, etc.).

- New `lua/cp/git_credential.lua` module wrapping the git credential
protocol
- All credential consumers (`credentials.lua`, `submit.lua`,
`scraper.lua`) use `git_credential` directly — `cache.lua` no longer
handles credentials
- CSES API token packed into the password field (`password<TAB>token`)
so it works with helpers that ignore the `path` field
- `has_helper()` guard on `:CP login`, `:CP logout`, and `:CP submit`
with an error message if no helper is configured
- Healthcheck split into `[required]`/`[optional]` sections; git version
and credential helper status shown
- `git` checked at startup in `check_required_runtime()`
- Cache version system (`CACHE_VERSION`, v1→v2 migration) removed — the
cache file is now a plain JSON blob
- `:CP` command gets `bar = true`
This commit is contained in:
Barrett Ruth 2026-03-07 20:15:06 -05:00 committed by GitHub
parent 27d7a4e6b5
commit da4e2ebeba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 283 additions and 150 deletions

View file

@ -347,7 +347,9 @@ function M.login(platform, credentials, on_status, callback)
stdin = vim.json.encode(credentials),
on_event = function(ev)
if ev.credentials ~= nil and next(ev.credentials) ~= nil then
require('cp.cache').set_credentials(platform, ev.credentials)
vim.schedule(function()
require('cp.git_credential').store(platform, ev.credentials)
end)
end
if ev.status ~= nil then
if type(on_status) == 'function' then
@ -395,7 +397,9 @@ function M.submit(
stdin = vim.json.encode(credentials),
on_event = function(ev)
if ev.credentials ~= nil and next(ev.credentials) ~= nil then
require('cp.cache').set_credentials(platform, ev.credentials)
vim.schedule(function()
require('cp.git_credential').store(platform, ev.credentials)
end)
end
if ev.status ~= nil then
if type(on_status) == 'function' then