Skip to content

Commit ef8e498

Browse files
committed
docs(README.md): feating up the readme of QueraCode the Quera workbench for vscode
1 parent fb0327d commit ef8e498

1 file changed

Lines changed: 373 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
<div align="center">
2+
3+
<img src="media/banner.png" alt="QueraCode" width="100%" />
4+
5+
<br/>
6+
7+
8+
<h1>QueraCode</h1>
9+
10+
**The all-in-one [Quera](https://quera.org) workbench for Visual Studio Code — dashboard, problemset, contests, classes & colleges, solve/submit with verdicts, author lessons/problems/judges with one-click actions, versioning, AI assist, and coder-agent hand-off. Everything Quera, without opening quera.org.**
11+
12+
[![CI](https://img.shields.io/badge/CI-passing-0099CC.svg)](.github/workflows/ci.yml)
13+
[![Tests](https://img.shields.io/badge/tests-160%20unit%20%2B%20117%20live-brightgreen.svg)](test/)
14+
[![VS Code](https://img.shields.io/badge/VS%20Code-1.85%2B-007ACC.svg?logo=visualstudiocode&logoColor=white)](https://code.visualstudio.com/)
15+
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178C6.svg?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
16+
[![Commands](https://img.shields.io/badge/commands-93-0099CC.svg)](#commands)
17+
[![RTL](https://img.shields.io/badge/RTL%20%2B%20Persian-supported-0099CC.svg)](#rtl--persian)
18+
[![AI](https://img.shields.io/badge/AI-15%20providers-6E56CF.svg)](#ai-assistance-optional)
19+
[![Agent-ready](https://img.shields.io/badge/coder%20agents-ready-6E56CF.svg)](#coder-agent-integration)
20+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
21+
22+
</div>
23+
24+
---
25+
26+
QueraCode brings the whole Quera experience **inside your editor**. It serves
27+
**everyone** — a learner who wants to browse, read LLM/programming lessons, solve
28+
and submit; and Quera **staff** who develop courses, lessons, problems, and
29+
project judges. Everything you can do on Quera, from VS Code.
30+
31+
<div align="center">
32+
33+
<img src="media/demo/demo1.png" alt="QueraCode in VS Code — problemset sidebar + problem panel" width="100%" />
34+
35+
<sub>QueraCode in VS Code: the Problemset sidebar (with live counts and difficulty) and the problem panel. The panel is rendered by the extension's own webview code; RTL + Persian (Vazirmatn) is fully supported for Persian content.</sub>
36+
37+
</div>
38+
39+
40+
<img src="media/demo/demo2.png" alt="QueraCode in VS Code — problemset sidebar + problem panel" width="100%" />
41+
42+
## Architecture
43+
44+
QueraCode talks to Quera the way a browser does (session cookie + CSRF), reading
45+
the Next.js data endpoint with an HTML `__NEXT_DATA__` fallback and the legacy
46+
Django pages — fully self-contained, no other tool required. Optionally, one
47+
command registers the sibling **QueraMCP** server so coder agents can drive
48+
Quera too (it then appears under "MCP Servers" in the Extensions view; that
49+
entry is the server registration, not this extension).
50+
51+
![architecture](media/diagrams/architecture.png)
52+
53+
## Feature map
54+
55+
![features](media/diagrams/features.png)
56+
57+
### For learners
58+
59+
- **Quera Dashboard** as the landing page (`Ctrl/Cmd+Alt+D`): profile, college
60+
progress bars, LMS classes, upcoming **deadlines**, contests, practice
61+
suggestions — every card is a one-click action. A **pulsing Quera logo**
62+
shows while anything loads.
63+
- **Problemset browser** with **every Quera filter** — difficulty, tags, type,
64+
category, solve status, order, free-text search — and **lazy loading**
65+
("Load more" accumulates pages).
66+
- **Contests view**: active + finished contests from quera.org/contest — open,
67+
read, and **solve contest problems** without the website.
68+
- **Classes (کلاس‌ها) and Colleges (کالج)** as separate tree sections — exactly
69+
how Quera splits them.
70+
- **Problem viewer** webview that renders the statement as Markdown with **RTL +
71+
Persian (Vazirmatn)** typography and Quera branding.
72+
- **Solve**: pick a language, get a solution scaffold, **download the initial
73+
project**, **run against the samples** in a Docker/local sandbox, then
74+
**submit** (gated) and **watch the judge verdict** — all without leaving VS Code.
75+
- **My Submissions** tree with verdicts and per-test results.
76+
- **Quick Submit**: a Quera button on *every* editor tab (`Ctrl/Cmd+Alt+U`) —
77+
paste any problem URL and the active file is submitted with the live
78+
file-type id (auto **version snapshot** first).
79+
- **Custom tests**: `Quera: Add Custom Test` (`Ctrl/Cmd+Alt+T`) stores your own
80+
input/output pairs; **Run on Samples** runs statement samples *and* yours.
81+
- **Version history** (`Ctrl/Cmd+Alt+H`): every submit/publish auto-snapshots;
82+
diff, restore, or open any prior state.
83+
- **CP power tools**: one-click **Send to CPH** (Competitive Companion
84+
protocol) and **Setup CP Library** (AtCoder Library, KACTL, testlib,
85+
cp-algorithms cloned into your workspace).
86+
87+
88+
<img src="media/demo/demo3.png" alt="QueraCode in VS Code — problemset sidebar + problem panel" width="100%" />
89+
90+
### For staff / authors
91+
92+
- **New lesson / problem** skeletons in Quera's Markdown dialect.
93+
- **Validate** everything: the Markdown dialect linter, Persian normalizer,
94+
`tester_config.json` judge validator, test-name checker, and DevOps image
95+
(qregistry) validator — results shown in a themed panel.
96+
- **Insert** Quera macros (`%problem.X%`, `%video.X%`) and CP templates
97+
(DSU, Dijkstra, sieve, Fenwick).
98+
- **Live RTL + Persian preview** — modern and interactive: copy buttons on
99+
code blocks, a jump table-of-contents, RTL/LTR and font-size toggles.
100+
- **One-click authoring overlays (CodeLens)** on every Markdown file: validate,
101+
preview, publish, insert sample test / code block / limits / accordion at any
102+
section.
103+
- **Test bundles**: generate seeded inputs, build `problem.zip`
104+
(`in/` + `out/` + `tester.cpp`), validate the structure — the exact
105+
Sharif-Judge layout Quera's judge expects.
106+
107+
![submit-flow](media/diagrams/submit-flow.png)
108+
109+
## Install
110+
111+
**Easy install (recommended)** — grab `queracode-0.1.0.vsix` and either:
112+
113+
- drag it onto the Extensions view, **or**
114+
- `Ctrl/Cmd+Shift+P` → *"Extensions: Install from VSIX…"*, **or**
115+
- `code --install-extension queracode-0.1.0.vsix`
116+
117+
Build the `.vsix` yourself from source:
118+
119+
```bash
120+
cd queracode
121+
npm install
122+
npm run compile # type-check + emit
123+
npm run unit # 67 unit tests
124+
npm run package # -> queracode.vsix
125+
# or press F5 in VS Code for an Extension Development Host
126+
```
127+
128+
Full walkthrough (install, sign-in, first solve, staff authoring, AI setup):
129+
[`docs/INSTALL.md`](docs/INSTALL.md).
130+
131+
## Sign in
132+
133+
Two ways, chosen by `queracode.authMethod`:
134+
135+
- **Session id** — run **“Quera: Sign In”** and paste your `session_id` cookie
136+
(stored in VS Code SecretStorage, never in settings).
137+
- **Username / password** — set `queracode.username`, then sign in and enter the
138+
password (also stored in SecretStorage).
139+
140+
## Commands
141+
142+
| Command | What it does |
143+
| --- | --- |
144+
| `Quera: Sign In` / `Sign Out` / `Who Am I` | session management |
145+
| `Quera: Set Problemset Filters` / `Search Problems` | filter/search the problemset |
146+
| `Quera: Open Problem` | open the statement in an RTL webview |
147+
| `Quera: Solve Problem` | language picker → solution scaffold in your workspace |
148+
| `Quera: Download Initial Project` | fetch the starter ZIP |
149+
| `Quera: Run Solution on Samples` | run in a sandbox and diff outputs |
150+
| `Quera: Submit Solution` ⚠ | submit the active file to Quera |
151+
| `Quera: View Submission Result` | verdict + per-test breakdown |
152+
| `Quera: Open Course` / `Open Lesson` | course dashboard / chapter problem list |
153+
| `Quera: Read Lesson` | read any lesson/problem page as rendered RTL Markdown |
154+
| `Quera: New Lesson` / `New Problem` | authoring skeletons |
155+
| `Quera: Edit Lesson` | load a lesson's stored Markdown for editing (staff) |
156+
| `Quera: Publish Lesson` ⚠ | lint then publish |
157+
| `Quera: Preview (RTL + Persian)` | rendered Quera-flavor preview |
158+
| `Quera: Validate Markdown / Judge / Test Names / DevOps Image` | validators |
159+
| `Quera: Normalize Persian Text` | fix ZWNJ / Arabic letters in place |
160+
| `Quera: Insert Macro / CP Template` | snippets |
161+
| `Quera: Generate Test Inputs` | random/edge-case judge inputs from a spec |
162+
| `Quera: Build Test Bundle (problem.zip)` | write `in/` + `out/` + `tester.cpp` + zip |
163+
| `Quera: Insert tester.cpp` / `Validate Test Bundle` | special-judge scaffold / structure check |
164+
| `Quera AI: Configure AI Provider` | pick a provider, store the key in SecretStorage |
165+
| `Quera AI: Generate Solution / Explain Problem / Review Submission / Chat` | model-assisted solving |
166+
| `Quera: Open Dashboard` | your Quera home — progress, deadlines, contests |
167+
| `Quera: Open/Solve Contest Problem` | contests without the website |
168+
| `Quera: Quick Submit (by problem URL)` | the Quera button on every editor tab |
169+
| `Quera: Save Problem Locally` | statement + meta + sample tests to disk |
170+
| `Quera: Add Custom Test` | your own input/output for the sample runner |
171+
| `Quera: Snapshot Version / Version History` | local versioning, diff & restore |
172+
| `Quera: Send to CPH` | Competitive Companion hand-off (port 27121) |
173+
| `Quera: Setup CP Library` | clone ACL / KACTL / testlib / cp-algorithms |
174+
| `Quera: Solve with Claude Code` | launch `claude` with a solving brief |
175+
| `Quera: Insert Sample Test / Code Block / Limits / Accordion` | CodeLens one-click authoring |
176+
| `Quera: Register QueraMCP for Coder Agents` | wire up agent access |
177+
| `Quera: Solve with Coder Agent` | hand a solving brief to your agent |
178+
179+
⚠ = gated by `queracode.enableSubmission` / `queracode.enableWrite` (both off by
180+
default; `queracode.readOnly` forces them off).
181+
182+
## Keybindings
183+
184+
| Shortcut | Command |
185+
| --- | --- |
186+
| `Ctrl/Cmd+Alt+Enter` | Submit Solution |
187+
| `Ctrl/Cmd+Alt+R` | Run on Samples |
188+
| `Ctrl/Cmd+Alt+V` | Preview (RTL + Persian) |
189+
| `Ctrl/Cmd+Alt+P` | Search Problems |
190+
| `Ctrl/Cmd+Alt+J` | Validate Judge |
191+
192+
## RTL + Persian
193+
194+
QueraCode is built for Persian content: the problem/lesson webviews render
195+
right-to-left with a configurable **Vazirmatn** font stack, code blocks stay LTR
196+
and monospaced, and Quera's Markdown macros are highlighted. Configure via
197+
`queracode.editorDirection`, `queracode.persianFont`, `queracode.latinFont`,
198+
`queracode.monoFont`.
199+
200+
## Sandboxing
201+
202+
“Run on samples” executes your solution **isolated in Docker** by default
203+
(`--network=none`, memory/CPU caps), or locally, or emits the command for you to
204+
run — set `queracode.sandbox` to `docker` / `local` / `none`. All languages and
205+
frameworks Quera supports are covered.
206+
207+
## AI assistance (optional)
208+
209+
QueraCode can call an AI model directly — pick a provider with
210+
**"Quera AI: Configure AI Provider"**: **OpenRouter**, OpenAI, Anthropic, Groq,
211+
Together, DeepSeek, Mistral, Fireworks, xAI, Perplexity, Gemini, AvalAI
212+
(Iran-reachable), local **Ollama** / **LM Studio**, or any OpenAI-compatible
213+
endpoint. The API key is stored in **SecretStorage** (never in settings) and
214+
local providers need no key at all.
215+
216+
- **Generate Solution** — drafts code for a problem into your workspace (never submits).
217+
- **Explain Problem** — a learner-friendly brief, no spoiler code.
218+
- **Review Submission** — feeds the verdict + judge log + your code to the model.
219+
- **Chat** — free-form prompt, rendered in a themed panel.
220+
221+
Settings: `queracode.ai.provider`, `queracode.ai.model`, `queracode.ai.baseUrl`.
222+
223+
## Test generators (judge bundles)
224+
225+
Author the exact `problem.zip` Quera's judge (Sharif-Judge) expects:
226+
**Generate Test Inputs** (arrays, matrices, strings, pairs, graphs — seeded and
227+
reproducible, plus edge cases), **Build Test Bundle** (writes `in/inputN.txt`,
228+
`out/outputN.txt`, optional `tester.cpp`, and a store-only `problem.zip`),
229+
**Insert tester.cpp** (the argv contract: input / jury output / user output;
230+
exit 0 = accept, 1 = reject), and **Validate Test Bundle** (naming, pairing,
231+
contiguous numbering) — all offline.
232+
233+
## Claude Code & coder agents
234+
235+
**Quera: Solve with Claude Code** saves the statement into your workspace and
236+
launches `claude` in the integrated terminal with a ready solving brief.
237+
QueraCode also stays fully **independent** of QueraMCP — its own fetch client
238+
does all Quera I/O — while optionally registering QueraMCP for MCP-capable
239+
agents:
240+
241+
## Coder-agent integration
242+
243+
QueraCode is agent-friendly. It writes a `.vscode/mcp.json` that registers
244+
**QueraMCP** so MCP-capable agents (GitHub Copilot agent mode, Claude, …) can
245+
browse/solve/submit Quera, and it exposes an **extension API** other extensions
246+
can consume:
247+
248+
```ts
249+
const quera = vscode.extensions.getExtension("dwin-gharibi.queracode")?.exports;
250+
const page = await quera.listProblems({ difficulty: ["HARD"], tag: ["78"] }, 1);
251+
```
252+
253+
## Settings
254+
255+
All under the `queracode.*` namespace. **Credentials live only in VS Code
256+
SecretStorage — never in `settings.json`.**
257+
258+
| Setting | Default | Description |
259+
| --- | --- | --- |
260+
| `baseUrl` | `https://quera.org/` | Quera base URL. |
261+
| `authMethod` | `sessionId` | `sessionId` or `usernamePassword`. |
262+
| `username` | — | Quera username/email (password goes to SecretStorage). |
263+
| `defaultLanguage` | `python` | Default language for new solutions. |
264+
| `locale` | `fa` | Content locale (`fa` / `en` / `ar`). |
265+
| `editorDirection` | `auto` | `auto` / `rtl` / `ltr` for the preview & panels. |
266+
| `persianFont` / `latinFont` / `monoFont` | Vazirmatn / Inter / JetBrains Mono | Webview font stacks. |
267+
| `enableSubmission` | `false` | Allow submitting solutions (gated). |
268+
| `enableWrite` | `false` | Allow publishing/editing content (gated). |
269+
| `readOnly` | `false` | Master switch: forces both gates off. |
270+
| `sandbox` | `docker` | `docker` / `local` / `none` for running samples. |
271+
| `problemsetPageSize` | `25` | Problems per page in the sidebar. |
272+
| `solutionsDir` | `quera` | Workspace subfolder for solutions & downloads. |
273+
| `autoRegisterMcp` | `false` | Opt-in: write `.vscode/mcp.json` registering QueraMCP for coder agents (shows under "MCP Servers" in the Extensions view). |
274+
| `openDashboardOnStartup` | `false` | Open the Quera Dashboard when VS Code starts. Off by default — the dashboard is one keystroke away (`Ctrl+Alt+D`), and opening a panel on every launch was unwelcome. |
275+
| `customCss` | — | Custom CSS injected into every webview — bring your own fonts (`@font-face`), colors, sizes. |
276+
| `fontSize` | `14.5` | Base font size (px) for panels and previews. |
277+
| `accentColor` | — | Override the Quera cyan (`#RRGGBB`). |
278+
| `ai.provider` / `ai.model` / `ai.baseUrl` | `openrouter` | AI provider (key lives in SecretStorage). |
279+
| `repo.autoPull` | `false` | Fast-forward the course repo on a timer. Skipped while the tree is dirty or mid-merge. |
280+
| `repo.autoPullIntervalMinutes` | `15` | How often to fast-forward. |
281+
| `repo.autoPush` | `false` | Commit and push saved changes. **A push runs the repo's workflow and publishes to the live college.** Requires `enableWrite`. |
282+
| `repo.autoPushDelaySeconds` | `45` | Quiet period before auto-push commits. |
283+
| `repo.branch` | — | Branch auto-commits land on; created from HEAD if absent. Empty = whatever is checked out. |
284+
| `repo.commitMessage` | `درسنامه: ${files} (QueraCode)` | Template — `${files}`, `${count}`, `${date}`. |
285+
| `sync.autoPublishOnSave` | `false` | Publish a **bound** file straight to Quera on save. Students see it immediately; requires `enableWrite`. |
286+
| `sync.publishDelaySeconds` | `3` | Quiet period before auto-publish fires. |
287+
| `sync.confirmBeforePublish` | `true` | Ask before a manual publish. |
288+
289+
## Course authoring and sync
290+
291+
A Quera college can be authored as a Git repository — chapters are folders,
292+
each درسنامه is a directory holding `statement.md` (its first `#` heading is the
293+
title Quera matches on), and a GitHub Actions workflow publishes what changed on
294+
push. QueraCode drives that shape, and offers a direct route that skips git.
295+
296+
![submit flow](media/diagrams/submit-flow.png)
297+
298+
**Course Repository view** — the linked college as curriculum rather than files:
299+
chapters in config order, and inside each the درسنامه the sync will actually
300+
publish. Create, rename, delete and reveal from the row. Folders with no
301+
statement stay hidden, because the sync ignores them too.
302+
303+
**Two routes to Quera**
304+
305+
| | Route | What happens |
306+
| --- | --- | --- |
307+
| Git | `repo.autoPush` | Commit → push to your branch → the repo's workflow publishes. |
308+
| Direct | `sync.autoPublishOnSave` | Bind a file, then publish straight to Quera from the editor. |
309+
310+
**Getting started**
311+
312+
```bash
313+
# link an existing folder to a college — writes .quera-sync/config.json
314+
# Quera: Link a College to This Repository
315+
# or pull an existing college down into it
316+
# Quera: Import a College into This Repository
317+
```
318+
319+
Add `QUERA_SESSION_ID` as a repository secret so the workflow can publish.
320+
321+
**Safety.** Both routes are off by default and gated behind
322+
`queracode.enableWrite`. Auto-pull is `--ff-only` and skips a dirty or
323+
mid-merge tree, so it can never overwrite local work. A direct pull shows a
324+
real diff before replacing a non-empty file. Deleting a درسنامه locally does
325+
not delete it on Quera — the sync renames it using
326+
`deleted_lesson.title_template`.
327+
328+
## Troubleshooting
329+
330+
| Symptom | Cause & fix |
331+
| --- | --- |
332+
| Sidebar shows "Sign in to Quera…" | Not signed in — run **Quera: Sign In**. |
333+
| "Error: Authentication failed (401/403)" | `session_id` missing/expired or lacks permission — sign in again. |
334+
| Problems don't load / connection reset | Quera is geo-restricted + WAF-protected; reads can fail outside Iran. |
335+
| "Submitting is disabled" | Enable `queracode.enableSubmission` (and turn off `readOnly`). |
336+
| "Run on samples" prints a command instead of running | `queracode.sandbox` is `none`, or Docker isn't installed — set it to `docker`/`local`. |
337+
338+
## Testing
339+
340+
```bash
341+
npm run lint # tsc --noEmit (strict)
342+
npm run unit # 160 unit tests — validators, testkit, zip writer, verdicts,
343+
# Persian formatting, command-argument coercion, bindings
344+
npm run check:manifest # contributions point at things that exist; icon-only
345+
# slots have icons; nothing stray would ship
346+
npm run test:repo # 43 checks: course-repo sync against a real clone
347+
npm run verify # all of the above
348+
349+
# these need a Quera session
350+
QUERA_SESSION_ID=… npm run test:live # 38 checks against live Quera
351+
QUERA_SESSION_ID=… npm run test:extension # 36 checks driving activate() + trees
352+
QUERA_SESSION_ID=… npm run test:commands # every registered command, executed
353+
QUERA_SESSION_ID=… npm run verify:live # everything
354+
355+
npm run package # build queracode.vsix (needs Node 20+)
356+
```
357+
358+
## Related
359+
360+
<img src="media/illustrations/quera-dev.png" alt="Quera in the Iranian tech ecosystem" width="42%" align="right" />
361+
362+
- **[QueraMCP](../quera-mcp/)** — the sibling MCP server (203 tools). Independent
363+
project; QueraCode registers it for agents and mirrors its Quera knowledge.
364+
365+
## License
366+
367+
[MIT](LICENSE). Unofficial, community-built; the Quera name and logo belong to
368+
their owner.
369+
370+
371+
<div align="center">
372+
<img src="media/quera-logo.png" alt="Quera" height="46" />
373+
<br/>

0 commit comments

Comments
 (0)