Explain concepts on the site, and reuse their code from the CLI
/usaco/concepts is a library of techniques Claude explained: the admin
asks by topic ("help explain fenwick trees") or pastes code they could
not follow, and gets an intuitive explanation with SVG diagrams plus a
C++ snippet in contest style. Given code, the walkthrough traces that
code and the snippet is a general version of it. Anyone can read the
library; generating, rewriting and deleting are admin-only.
Each concept is committed as concepts/<slug>/: concept.md (tags in a
header comment, then a # title), snippet.cpp (first line
"// concept: <slug>") and request.md (the question, for rewrites). The
slug is Claude's to pick, so a new concept's job is keyed by an id and
returns {slug} as its result; a taken slug gets -2, -3... rather than
overwriting. Rewriting starts from the saved question and version plus
a note on what to change. The index reads concepts into Index.Concepts,
with their date from git.
internal/concept shares explain's math and diagram rules, now split out
as explain.MathRules and explain.DiagramRules; the explain prompt is
byte-for-byte unchanged. Code fences in explanations are highlighted
with the same highlight.js setup as CodeBlock (web/src/highlight.js).
`usaco snippet` lists concepts, prints one's snippet, or pastes it into
a solution above main (or class Solution), keeping a .bak and refusing
a concept the file already has. In interactive mode it pastes into the
selection.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
// for solved problems, everything for the admin), the admin's edits, the
|
||||
// Claude explanations (explain.go) and recording reviews (review.go), the
|
||||
// solve page's code editing and runs (run.go) and evaluations
|
||||
// (evaluate.go), and the Gitea webhook that tells the server to pull.
|
||||
// (evaluate.go), the library of concepts Claude explained (concept.go), and
|
||||
// the Gitea webhook that tells the server to pull.
|
||||
package handlers
|
||||
|
||||
import (
|
||||
@@ -70,6 +71,9 @@ type Server struct {
|
||||
// Separate, so a review, an explanation and an evaluation of one
|
||||
// problem can run at the same time.
|
||||
jobs, reviewJobs, evalJobs explain.Jobs
|
||||
// New concepts are keyed by a job id (the slug is Claude's to pick),
|
||||
// rewrites by slug.
|
||||
newConceptJobs, conceptJobs explain.Jobs
|
||||
}
|
||||
|
||||
// SetIndex swaps in a freshly built index. repo.Repo calls it (through
|
||||
@@ -114,6 +118,14 @@ func (s *Server) Routes(api *gin.RouterGroup) {
|
||||
admin.POST("/problems/:name/evaluate", s.startEvaluate)
|
||||
admin.GET("/problems/:name/evaluate", s.evaluateStatus)
|
||||
admin.POST("/leetcode/daily", s.startDaily)
|
||||
api.GET("/concepts", s.listConcepts)
|
||||
api.GET("/concepts/:slug", s.getConcept)
|
||||
admin.POST("/concepts", s.startConcept)
|
||||
// Not under /concepts/, where "jobs" would be a slug.
|
||||
admin.GET("/concept-jobs/:id", s.newConceptStatus)
|
||||
admin.POST("/concepts/:slug/explain", s.rewriteConcept)
|
||||
admin.GET("/concepts/:slug/explain", s.rewriteStatus)
|
||||
admin.DELETE("/concepts/:slug", s.deleteConcept)
|
||||
api.POST("/hooks/gitea", s.webhook)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user