Commit Graph
6 Commits
Author SHA1 Message Date
adamfandClaude Opus 5.5 c972fa9fd9 Run and lint solutions on the site
Test and publish the site / test (push) Successful in 1m23s
Test and publish the site / publish (push) Failing after 4m22s
A new admin-only solve page, /p/<name>/solve, edits a problem's code in
C++ or Python (a dropdown switches between them), runs it on custom
input or against the saved tests with per-test verdicts (AC, WA, RE,
TLE, unchecked) and compile errors, marks lint diagnostics in the
editor, and saves the code back as a commit ("Edit <name>"). Drafts
stay in the browser per problem and language until saved. LeetCode
problems are C++ only, since their tests run through driver.h.

Code never runs in the site, which holds the Claude, Gitea and S3
secrets. A separate runner service (cmd/usacorunner, Dockerfile.runner)
does it in a container meant to have no environment, an internal-only
network, a read-only root apart from /tmp, and memory, CPU and pids
limits, with tini to reap orphans. Runs copy the CLI: the same g++
flags with -DLOCAL and the repo's headers, <io>.in on disk and on
stdin, <io>.out or stdout as the output, and usaco test's comparison.
Unlike the CLI they have CPU, memory, file and wall-clock limits.

C++ lint is g++'s warnings plus clang-tidy with a new .clang-tidy
(bugprone, performance and a few readability checks; template.cpp is
clean). Python lint is a syntax check plus ruff. template.py is the
Python starter, with a stdio() helper like template.rs's.

CI builds, smoke-tests and rolls out the runner image before the site.
The web_server stack needs a usaco-runner service before that rollout
can succeed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 11:24:22 +01:00
adamfandClaude Opus 5.5 4dc8d1674c Tidy the site's problem pages and typeset math in explanations
Test and publish the site / test (push) Successful in 1m10s
Test and publish the site / publish (push) Successful in 1m29s
The problem page's Explain and recording-review forms took most of the
first screen, above the solution. They now fold into the admin bar with
the editor, one open at a time; a running job is reported in the bar,
so a form can be closed while it works.

The problem list is grouped by month when sorted by recency, as one
card per month with divided rows, laid out on a fixed grid so rows
line up on a phone. Empty status tabs are hidden.

Rust solutions are now highlighted, the file picker is styled like the
other buttons, header links no longer break mid-word on a phone, and
keyboard focus is visible.

Markdown everywhere now goes through one renderer that typesets
$...$, $$...$$ and ```math with KaTeX. The explanation prompt asked for
$...$ only when the statement used it, so formulas came out as inline
code; it now asks for LaTeX for math and code spans for code, and the
review prompt does the same for complexities.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 02:19:24 +01:00
adamfandClaude Opus 5.5 63608f130c Review recorded explanations of a solution on the site
Test and publish the site / test (push) Successful in 2m4s
Test and publish the site / publish (push) Successful in 1m44s
The admin can upload a recording of themselves explaining a problem's
solution out loud (mp3, m4a, wav, webm, ogg or flac, up to 25 MB) and
get interview-style feedback, committed as reviews/<id>.md so every
attempt is kept.

Claude can't take audio, so the recording is transcribed first by an
OpenAI-compatible endpoint (whisper-1 by default; TRANSCRIBE_API_KEY,
with TRANSCRIBE_URL for a self-hosted server). Pace, pauses, filler
words and when complexity first comes up are measured from the word
timestamps and given to Claude with the timestamped transcript, the
statement and optionally the code. The reply covers the verdict, scores
in five areas, the approach and its complexity, missed edge cases,
delivery and what to work on.

Recordings are kept for playback in an S3 bucket (Garage) when the
S3_* settings are given, and are thrown away otherwise. Reviews are
admin-only. The job runs in the background like Explain, and the
statement fetch and save-error handling are now shared between the two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 01:56:55 +01:00
adamfandClaude Opus 5.5 1aee0050a0 Add Rust support: usaco lang, lint, and main.rs problems
Brings in the stashed Rust work, merged onto the current CLI. A
problem's language is whichever source it has (main.cpp or main.rs);
'usaco lang' sets the default for new problems (.lang, or $USACO_LANG),
and 'new --rust/--cpp' picks per problem. template.rs is a paste-ready
Rust template whose stdio() uses <io>.in/.out when present and
stdin/stdout otherwise.

run/test now feed <io>.in on stdin and capture stdout when the program
doesn't write <io>.out itself, so Codeforces-style solutions work too.
'reset <name> rust|cpp' switches a problem's language (template is
still an alias), and --debug builds Rust with overflow checks and debug
assertions. 'usaco lint' runs clippy through a generated, gitignored
Cargo.toml that also gives rust-analyzer a project; done/skip/undo
keep it in step. LeetCode imports stay C++.

Also: done stages solved/ and solving/ separately, so a problem that
was never committed from solving/ still gets its "Solve" commit, and
the site lists main.rs ahead of other files like it does main.cpp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 21:17:50 +01:00
adamfandClaude Opus 5.5 995b44a57a Add an Explain button that has Claude explain a problem
Test and publish the site / publish (push) Successful in 8m15s
Test and publish the site / test (push) Successful in 5m51s
When stuck, the admin can ask Claude for an intuitive explanation of a
problem. It is committed as explain.md and shown as folded sections, so
the reader opens only as much as they need: the key observation, hints
that get stronger, the approach, a walkthrough with an SVG diagram per
step, complexity, pitfalls and a pseudocode sketch.

- internal/claude: streamed call with a JSON-schema reply, high effort,
  the server-side refusal fallback, fixed error messages and logged
  token usage. CLAUDE_API_KEY and CLAUDE_MODEL (default claude-opus-5-5);
  without a key only this feature is off.
- internal/explain: the prompt, the schema, rendering to markdown, and
  a per-problem job tracker. The request starts a job and the page polls,
  since a call outlasts nginx's 120s timeout.
- internal/statement: fetches statements from LeetCode's GraphQL API and
  USACO's problem pages. Others (Codeforces is behind Cloudflare) are
  pasted.
- problem.md holds the statement, editable from the meta editor and
  shown only to the admin. Diagrams are sanitized with DOMPurify.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 20:38:15 +01:00
adamfandClaude Opus 5.5 6d956f1c76 Add the website: Go server + Vue SPA in site/, with CI
A standalone container for web_server, shaped like job-tracker: serves
/usaco/ with solved problems public and solving/skipped plus edits
(status, link, notes) for the site admin. Git is the only store: the
server clones adamf/usaco from Gitea, pulls on the push webhook, and
commits edits back. CI builds the image only when site/ changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 21:51:34 +01:00