feat(cses): implement submit via REST API (#299)

## Problem

CSES submit was a stub returning "not yet implemented".

## Solution

Authenticate via web login + API token bridge (POST `/login` form, then
POST `/api/login` and confirm the auth page), submit source to
`/api/courses/problemset/submissions` with base64-encoded content, and
poll for verdict. Uses the same username/password credential model as
AtCoder — no browser dependencies needed. Tested end-to-end with a real
CSES account (verdict: `ACCEPTED`).

Also updates `scraper.lua` to pass the full ndjson event object to
`on_status` and handle `credentials` events for future platform use.
This commit is contained in:
Barrett Ruth 2026-03-05 01:07:57 -05:00 committed by GitHub
parent e674265527
commit e9f72dfbbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 210 additions and 9 deletions

View file

@ -25,6 +25,7 @@ local function prompt_credentials(platform, callback)
vim.fn.inputsave()
local password = vim.fn.inputsecret(platform .. ' password: ')
vim.fn.inputrestore()
vim.cmd.redraw()
if not password or password == '' then
logger.log('Submit cancelled', vim.log.levels.WARN)
return
@ -64,9 +65,9 @@ function M.submit(opts)
language,
source_code,
creds,
function(status)
function(ev)
vim.schedule(function()
vim.notify('[cp.nvim] ' .. (STATUS_MSGS[status] or status), vim.log.levels.INFO)
vim.notify('[cp.nvim] ' .. (STATUS_MSGS[ev.status] or ev.status), vim.log.levels.INFO)
end)
end,
function(result)