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]>
40 lines
1.4 KiB
YAML
40 lines
1.4 KiB
YAML
# Standalone development: the site serving THIS checkout's problems, with no
|
|
# login (AUTH_MODE=dev, everyone is the admin). http://localhost:8080/usaco/
|
|
#
|
|
# docker compose up --build
|
|
#
|
|
# The repo root is mounted read-only at /seed and cloned from there, and
|
|
# GIT_PUSH=false keeps edits made in the browser as commits in the
|
|
# container's own clone (docker compose exec usaco git -C /data/repo log),
|
|
# so nothing here can touch your working tree or the real remote. Only
|
|
# committed work shows up: it is a clone, not the working tree.
|
|
#
|
|
# This is NOT how it runs in production. There it is one service in the main
|
|
# site's docker-compose.yml, behind its nginx, cloning from Gitea and
|
|
# borrowing the site's login; see README.md.
|
|
services:
|
|
usaco:
|
|
build: .
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
DEV_MODE: "true"
|
|
AUTH_MODE: dev
|
|
GIT_REMOTE_URL: file:///seed
|
|
GIT_PUSH: "false"
|
|
# The checkout belongs to your host user, which git refuses to read
|
|
# from as a different uid unless told it is safe.
|
|
GIT_CONFIG_COUNT: "1"
|
|
GIT_CONFIG_KEY_0: safe.directory
|
|
GIT_CONFIG_VALUE_0: "*"
|
|
# From your shell or a .env next to this file; blank turns the
|
|
# Explain button off.
|
|
CLAUDE_API_KEY: ${CLAUDE_API_KEY:-}
|
|
CLAUDE_MODEL: ${CLAUDE_MODEL:-}
|
|
volumes:
|
|
- ..:/seed:ro
|
|
- usaco-data:/data
|
|
|
|
volumes:
|
|
usaco-data:
|