glossr 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- glossr-0.1.0/.gitignore +49 -0
- glossr-0.1.0/.python-version +1 -0
- glossr-0.1.0/LICENSE +21 -0
- glossr-0.1.0/PKG-INFO +160 -0
- glossr-0.1.0/README.md +135 -0
- glossr-0.1.0/backend/gloss/__init__.py +1 -0
- glossr-0.1.0/backend/gloss/__main__.py +3 -0
- glossr-0.1.0/backend/gloss/cli.py +111 -0
- glossr-0.1.0/backend/gloss/config.py +89 -0
- glossr-0.1.0/backend/gloss/course_tools.py +508 -0
- glossr-0.1.0/backend/gloss/digest.py +310 -0
- glossr-0.1.0/backend/gloss/doctor.py +149 -0
- glossr-0.1.0/backend/gloss/export.py +90 -0
- glossr-0.1.0/backend/gloss/folders.py +244 -0
- glossr-0.1.0/backend/gloss/i18n.py +91 -0
- glossr-0.1.0/backend/gloss/ingest.py +92 -0
- glossr-0.1.0/backend/gloss/jobs.py +134 -0
- glossr-0.1.0/backend/gloss/mcp_server.py +65 -0
- glossr-0.1.0/backend/gloss/profile.py +546 -0
- glossr-0.1.0/backend/gloss/providers/__init__.py +4 -0
- glossr-0.1.0/backend/gloss/providers/anthropic_api.py +163 -0
- glossr-0.1.0/backend/gloss/providers/base.py +85 -0
- glossr-0.1.0/backend/gloss/providers/claude_cli.py +198 -0
- glossr-0.1.0/backend/gloss/quiz.py +399 -0
- glossr-0.1.0/backend/gloss/schema.py +118 -0
- glossr-0.1.0/backend/gloss/server.py +800 -0
- glossr-0.1.0/backend/gloss/static/SOURCE_HASH +1 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- glossr-0.1.0/backend/gloss/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- glossr-0.1.0/backend/gloss/static/assets/index-0B_we-15.js +302 -0
- glossr-0.1.0/backend/gloss/static/assets/index-crKBFfcm.css +1 -0
- glossr-0.1.0/backend/gloss/static/index.html +17 -0
- glossr-0.1.0/backend/gloss/store.py +496 -0
- glossr-0.1.0/backend/gloss/transcript.py +192 -0
- glossr-0.1.0/backend/gloss/tutor.py +537 -0
- glossr-0.1.0/claude_workspace/CLAUDE.md +16 -0
- glossr-0.1.0/claude_workspace/prompts/align-transcript.md +25 -0
- glossr-0.1.0/claude_workspace/prompts/build-tree.md +18 -0
- glossr-0.1.0/claude_workspace/prompts/digest-lecture.md +49 -0
- glossr-0.1.0/claude_workspace/prompts/explain-slide.md +24 -0
- glossr-0.1.0/claude_workspace/prompts/pre-quiz.md +32 -0
- glossr-0.1.0/claude_workspace/prompts/qa-opening.md +12 -0
- glossr-0.1.0/claude_workspace/prompts/qa-rebuild.md +8 -0
- glossr-0.1.0/claude_workspace/prompts/qa-retrieval.md +14 -0
- glossr-0.1.0/claude_workspace/prompts/qa-system.md +11 -0
- glossr-0.1.0/claude_workspace/prompts/quiz-verify.md +11 -0
- glossr-0.1.0/claude_workspace/prompts/update-profile.md +41 -0
- glossr-0.1.0/config.example.toml +43 -0
- glossr-0.1.0/pyproject.toml +66 -0
- glossr-0.1.0/tests/conftest.py +16 -0
- glossr-0.1.0/tests/fake_claude.py +78 -0
- glossr-0.1.0/tests/fakes.py +58 -0
- glossr-0.1.0/tests/make_pdfs.py +54 -0
- glossr-0.1.0/tests/test_anthropic_api.py +186 -0
- glossr-0.1.0/tests/test_claude_cli.py +167 -0
- glossr-0.1.0/tests/test_cli.py +50 -0
- glossr-0.1.0/tests/test_course_tools.py +268 -0
- glossr-0.1.0/tests/test_digest.py +179 -0
- glossr-0.1.0/tests/test_export.py +61 -0
- glossr-0.1.0/tests/test_folders.py +175 -0
- glossr-0.1.0/tests/test_frontend_build.py +15 -0
- glossr-0.1.0/tests/test_ingest.py +111 -0
- glossr-0.1.0/tests/test_jobs.py +127 -0
- glossr-0.1.0/tests/test_profile.py +339 -0
- glossr-0.1.0/tests/test_quiz.py +181 -0
- glossr-0.1.0/tests/test_schema.py +167 -0
- glossr-0.1.0/tests/test_server.py +303 -0
- glossr-0.1.0/tests/test_store.py +207 -0
- glossr-0.1.0/tests/test_transcript.py +109 -0
- glossr-0.1.0/tests/test_tree.py +152 -0
- glossr-0.1.0/tests/test_tutor.py +324 -0
- glossr-0.1.0/uv.lock +649 -0
glossr-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# --- Gloss: user data and course material (never commit) ---
|
|
2
|
+
*.gloss
|
|
3
|
+
*.gloss-wal
|
|
4
|
+
*.gloss-shm
|
|
5
|
+
claude_workspace/courses/
|
|
6
|
+
claude_workspace/scopes/
|
|
7
|
+
*.glossq
|
|
8
|
+
*.glossq-wal
|
|
9
|
+
*.glossq-shm
|
|
10
|
+
config.toml
|
|
11
|
+
# lecture material used for local testing
|
|
12
|
+
*.pdf
|
|
13
|
+
!tests/fixtures/**/*.pdf
|
|
14
|
+
|
|
15
|
+
# --- Python ---
|
|
16
|
+
__pycache__/
|
|
17
|
+
*.py[cod]
|
|
18
|
+
*.egg-info/
|
|
19
|
+
.eggs/
|
|
20
|
+
build/
|
|
21
|
+
dist/
|
|
22
|
+
.venv/
|
|
23
|
+
venv/
|
|
24
|
+
.pytest_cache/
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
|
|
30
|
+
# --- Frontend ---
|
|
31
|
+
node_modules/
|
|
32
|
+
frontend/dist/
|
|
33
|
+
# backend/gloss/static/ is committed: the built frontend ships with the repo (see scripts/frontend_hash.py)
|
|
34
|
+
|
|
35
|
+
# --- Editors / OS ---
|
|
36
|
+
.DS_Store
|
|
37
|
+
Thumbs.db
|
|
38
|
+
.idea/
|
|
39
|
+
.vscode/
|
|
40
|
+
*.swp
|
|
41
|
+
|
|
42
|
+
# --- Env ---
|
|
43
|
+
.env
|
|
44
|
+
.env.*
|
|
45
|
+
|
|
46
|
+
# --- Local only: design notes and Claude Code dev instructions ---
|
|
47
|
+
# (root only: claude_workspace/CLAUDE.md is the runtime tutor role and must stay tracked)
|
|
48
|
+
/docs/
|
|
49
|
+
/CLAUDE.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
glossr-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rong Gu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
glossr-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: glossr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Ask questions right on your lecture slides. A local study app powered by your own Claude.
|
|
5
|
+
Project-URL: Homepage, https://github.com/rongrgu/gloss
|
|
6
|
+
Project-URL: Issues, https://github.com/rongrgu/gloss/issues
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: claude,learning,lecture slides,pdf,study
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Web Environment
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Education
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Requires-Dist: fastapi>=0.143.0
|
|
19
|
+
Requires-Dist: pymupdf>=1.24
|
|
20
|
+
Requires-Dist: python-multipart>=0.0.32
|
|
21
|
+
Requires-Dist: uvicorn>=0.54.0
|
|
22
|
+
Provides-Extra: api
|
|
23
|
+
Requires-Dist: anthropic>=1.13.0; extra == 'api'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# Gloss
|
|
27
|
+
|
|
28
|
+
Ask questions right on your lecture slides. A local study app powered by your own Claude.
|
|
29
|
+
|
|
30
|
+
把 PDF 课件变成可以提问的学习空间:思维导图、逐页讲解、在 slide 上框选提问、笔记。全部在本地运行,用你自己的 Claude。
|
|
31
|
+
|
|
32
|
+
## What it does
|
|
33
|
+
|
|
34
|
+
Import a PDF of lecture slides and Gloss gives you:
|
|
35
|
+
|
|
36
|
+
- **A mind map** of the lecture: topics on the left, every slide as a thumbnail, with badges for slides you asked about or took notes on.
|
|
37
|
+
- **A workspace for each slide**: the slide, an explanation of it, and your notes for that page.
|
|
38
|
+
- **Questions anchored to the slide**: drag a box around anything (a formula, a diagram) and ask about it. The answer appears next to that spot. Minimize it and a marker stays on the slide; click it later to pick the conversation back up. You can also select a sentence in the explanation and ask about just that.
|
|
39
|
+
- **The lecturer's words, matched to each slide** (optional): upload a transcript (`.txt`, `.vtt`, `.srt`) and Claude works out which part of the talk goes with which slide. Explanations and answers then draw on what was actually said in class.
|
|
40
|
+
- **Answers that know the whole course**: when a question reaches beyond the current slide ("where was this symbol defined?", "how is this different from the method on slide 12?"), Claude searches the rest of the lecture and tells you which slide to look at.
|
|
41
|
+
- **One file per course.** Everything — the slides, explanations, every question and answer, your notes and layout — is saved in a single `.gloss` file as you go. There is no save button. Close it, reopen it, it's all there.
|
|
42
|
+
|
|
43
|
+
Feeding slides straight into a chat gives you one long linear transcript where follow-ups lose track of which part of which slide they were about. Gloss keeps each question attached to the place it came from.
|
|
44
|
+
|
|
45
|
+
## Requirements
|
|
46
|
+
|
|
47
|
+
- **Python 3.11+** and [uv](https://docs.astral.sh/uv/).
|
|
48
|
+
- **[@Claude Code](https://code.claude.com)**, installed and logged in with your Claude account (run `claude` once and use `/login`). Gloss calls the `claude` command on your machine; it never sees your credentials.
|
|
49
|
+
- A Claude plan with Claude Code access. Explanations and answers count toward your plan's usage limits, so Pro users may want a lighter model (see [Configuration](#configuration)).
|
|
50
|
+
|
|
51
|
+
You do **not** need Node.js: the web interface ships pre-built.
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
Install from PyPI (the package is called `glossr`; the command is `gloss`):
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
uv tool install glossr # or: pipx install glossr
|
|
59
|
+
gloss doctor # checks Python, claude, login, and the install
|
|
60
|
+
gloss # starts the app and opens it in your browser
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
To try it without installing: `uvx glossr`. To update later: `uv tool upgrade glossr`.
|
|
64
|
+
|
|
65
|
+
Running from a clone instead (for development, or the latest unreleased code):
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
git clone https://github.com/rongrgu/gloss && cd gloss
|
|
69
|
+
uv run gloss doctor
|
|
70
|
+
uv run gloss
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then drop a PDF onto the home page. The first time you open a course, Claude organizes it into a mind map (one call, about 10–20 seconds). Each slide's explanation is generated the first time you stay on that slide for a moment, and then saved.
|
|
74
|
+
|
|
75
|
+
Other commands (prefix with `uv run` when running from a clone):
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
gloss --port 9000 --no-browser
|
|
79
|
+
gloss doctor --live # also sends a tiny test prompt (uses a little quota)
|
|
80
|
+
gloss export course.gloss # writes course.md
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Using it
|
|
84
|
+
|
|
85
|
+
- **Language** — the interface is in English by default; the 中文 / EN button in the top bar switches it (and the language Claude explains and answers in, unless `language` is set in `config.toml`). Content already generated keeps its language; use Regenerate to redo it.
|
|
86
|
+
- **Mind map** — drag to pan, scroll or use the buttons to zoom, click a topic to fold it. Click a thumbnail to open that slide. "Regenerate map" asks Claude to regroup the slides; your questions and notes are untouched.
|
|
87
|
+
- **Slide workspace** — `←` / `→` change pages. The Layout menu switches between stacked and side-by-side, hides panels, and resets; drag the dividers to resize (double-click resets one).
|
|
88
|
+
- **Ask** — drag a rectangle on the slide, type your question, press Enter. Follow up in the same box. Questions on the same slide are answered one at a time, so a second question may briefly show as queued. To ask about part of the explanation, select the text and press "Ask about this"; those questions show up as numbered chips under the explanation.
|
|
89
|
+
- **Transcript** — on the course page, "Upload transcript". Claude aligns it to the slides (one call, usually under 20 seconds). Each slide's explanation panel can show its excerpt ("Transcript passage"). Explanations generated before the upload aren't redone automatically — use "Regenerate" on the slides you care about.
|
|
90
|
+
- **Notes** — plain text per slide, saved automatically. "Clip to notes" under an answer copies the question and the answer's first paragraph into the page's notes.
|
|
91
|
+
- **Session log** — shows exactly what was sent to Claude for this slide (for the curious).
|
|
92
|
+
- **Library** — the home page is your library folder (`~/Gloss` by default). Organize it however you like: folders for school, year, term, course… A folder that holds lectures is a course. Lectures are listed in the order you imported them; drag to reorder, or drag onto a folder (or a breadcrumb) to move. "Import PDF" puts the new lecture in the folder you are looking at. Folders on disk are the source of truth, so organizing in Finder works too.
|
|
93
|
+
- **Got it / still confused** — under each answer, mark whether you understand now. Unresolved questions turn orange on the slide and on the mind map, and pre-quizzes and summaries take your marks into account.
|
|
94
|
+
- **Finish lecture** — on the mind map, "Finish lecture" has Claude write a study summary from your questions, notes and quiz answers: what the lecture covered, what you asked (grouped by concept), what is still unclear, what you now understand, open questions, and slides worth reviewing. Every point links back to the question it came from. When you ask more later, "Update summary" refreshes it.
|
|
95
|
+
- **Study profile** — each course keeps a list of what you still find unclear, by concept and with evidence (your questions, marks and quiz answers). Finishing a lecture updates it; quiz answers and marks move items between "still unclear", "improving" and "resolved" on their own. You can resolve, reopen, rename, merge or delete items, and undo the last automatic change. New explanations and question sessions mention a weak point when, and only when, the slide is related to it (turn this off with `use_profile = false`).
|
|
96
|
+
- **Pre-quiz** — on any course (or any folder above it), "New pre-quiz" has Claude write practice questions for exam prep. It reads the slides and, above all, what you asked and noted while studying, so it targets where you got stuck, and it covers topics you never asked about too. Each question cites the slide it comes from, says why it was chosen, and has an answer and explanation; a second pass checks every answer key against the slides. Multiple choice is marked automatically; for written answers you compare with the reference answer and mark yourself. Generation takes about a minute and uses noticeably more quota than a question.
|
|
97
|
+
- **Export** — "Export Markdown" on the course page (or `gloss export`) writes the map, explanations, questions and answers, and notes as one Markdown file.
|
|
98
|
+
|
|
99
|
+
A `.gloss` file is self-contained: send it to a classmate and they can read everything in Gloss, even without Claude installed (they just can't ask new questions).
|
|
100
|
+
|
|
101
|
+
## Your data, your Claude account
|
|
102
|
+
|
|
103
|
+
- **Everything stays on your computer.** Courses are saved as `.gloss` files (by default in `~/Gloss/`). The recent-files list lives in `~/.gloss/`. Gloss runs a small web server on your own machine (`127.0.0.1`) and has no cloud service, no account, no telemetry.
|
|
104
|
+
- **What goes to Anthropic:** when you ask for an explanation, a question, or a mind map, Gloss runs your `claude` command with the relevant slide text and images, so that content is processed by Anthropic under your account, exactly as if you had pasted it into Claude Code yourself.
|
|
105
|
+
- **It uses your Claude login and your plan's usage.** Gloss does not log you in, store tokens, or proxy anyone else's account. Each person runs their own copy with their own account.
|
|
106
|
+
- **About Anthropic's terms:** Anthropic does not allow third-party products to offer claude.ai login or to use people's subscription usage unless approved, and expects commercial products to use API keys. Gloss is a free, open-source tool that you run yourself, driving your own locally installed Claude Code. It is not affiliated with or endorsed by Anthropic. Whether Claude Code usage keeps counting toward subscription limits is up to Anthropic and may change; you can switch Gloss to an API key instead (see [Using an API key](#using-an-api-key-instead)).
|
|
107
|
+
- **`ANTHROPIC_API_KEY`:** if this is set in your environment, Claude Code bills that API key instead of your subscription. Gloss removes it when it calls `claude`, and `gloss doctor` warns you if it's set.
|
|
108
|
+
- **Locked down by default:** Claude is run with only read-only file tools (Read, plus Grep/Glob for searching the course), restricted to that course's own working folder (`--restricted`), so it can't run commands, edit files, or read anything else on your disk — not even your other courses. The local server only accepts requests from `localhost` and refuses requests from other websites.
|
|
109
|
+
|
|
110
|
+
## Course materials and copyright
|
|
111
|
+
|
|
112
|
+
Lecture slides, transcripts and recordings belong to their authors. Use Gloss with material you're allowed to use, and **don't commit course files or `.gloss` files to this repository** (they're in `.gitignore`). Tests generate their own PDFs.
|
|
113
|
+
|
|
114
|
+
## Configuration
|
|
115
|
+
|
|
116
|
+
Copy `config.example.toml` to `config.toml` (in the repo; or `~/.gloss/config.toml` if you installed Gloss with pip):
|
|
117
|
+
|
|
118
|
+
| key | default | meaning |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| `model` | `"sonnet"` | passed to `claude --model` — an alias (`haiku`, `sonnet`, `opus`) or a full model name |
|
|
121
|
+
| `language` | (unset) | language for explanations, answers and the mind map. Unset, it follows the interface language (English by default; switch with the 中文 / EN button in the top bar). Set it to pin one, e.g. `"中文"` |
|
|
122
|
+
| `concurrency` | `2` | how many Claude calls may run at once (different slides) |
|
|
123
|
+
| `qa_retrieval` | `true` | let answers search the rest of the course when a question needs it |
|
|
124
|
+
| `quiz_model` | (unset) | model for pre-quiz generation; unset uses `model` |
|
|
125
|
+
| `quiz_verify` | `true` | check every pre-quiz answer key against the slides with a second call |
|
|
126
|
+
| `digest_model` | (unset) | model for lecture summaries and study-profile updates; unset uses `model` |
|
|
127
|
+
| `use_profile` | `true` | mention relevant weak points from the study profile in new explanations and question sessions |
|
|
128
|
+
| `provider` | `"claude_cli"` | `"claude_cli"` (your Claude Code login) or `"anthropic_api"` (see below) |
|
|
129
|
+
| `library` | `~/Gloss` | where imported courses are saved |
|
|
130
|
+
| `claude_bin` | found on `PATH` | path to the `claude` executable |
|
|
131
|
+
|
|
132
|
+
### Using an API key instead
|
|
133
|
+
|
|
134
|
+
Set `provider = "anthropic_api"` in `config.toml`, install the extra (`uv tool install 'glossr[api]'`, `pip install 'glossr[api]'`, or `uv sync --extra api` in a clone), and export `ANTHROPIC_API_KEY`. Calls are then billed to that key at API rates instead of counting toward your Claude plan; `gloss doctor` checks the setup. Differences: answers can't search the rest of the course and pre-quizzes aren't available (both need tools, which this route doesn't have), and every follow-up resends the slide's earlier questions and answers (prompt caching keeps the repeated part cheap). On models that support it, Gloss turns on Anthropic's server-side refusal fallback, so a request one model declines is retried on another automatically.
|
|
135
|
+
|
|
136
|
+
**Changing how Claude explains things:** the prompts are plain Markdown in `claude_workspace/` (`CLAUDE.md` for the tutor's role, `prompts/*.md` for each task). Edit them to change the style, for example exam-focused or more concise. Changes apply to new explanations and to new question sessions.
|
|
137
|
+
|
|
138
|
+
## Troubleshooting
|
|
139
|
+
|
|
140
|
+
Start with `uv run gloss doctor`.
|
|
141
|
+
|
|
142
|
+
- **"claude not found"** — install Claude Code, or set `claude_bin` in `config.toml`.
|
|
143
|
+
- **"not logged in"** — run `claude` in a terminal and use `/login`.
|
|
144
|
+
- **An answer failed** — the question is kept; press 重试 (retry). Common causes are usage limits or a network problem; the error message comes from Claude Code.
|
|
145
|
+
- **Port in use** — Gloss picks the next free port automatically, or pass `--port`.
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
Common commands:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
uv run pytest # backend tests
|
|
153
|
+
cd frontend && npm install && npm test # frontend tests
|
|
154
|
+
npm run dev # dev server, proxies /api to `uv run gloss --port 8765`
|
|
155
|
+
npm run build # rebuilds backend/gloss/static (committed; a test checks it's current)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT — see [LICENSE](LICENSE).
|
glossr-0.1.0/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Gloss
|
|
2
|
+
|
|
3
|
+
Ask questions right on your lecture slides. A local study app powered by your own Claude.
|
|
4
|
+
|
|
5
|
+
把 PDF 课件变成可以提问的学习空间:思维导图、逐页讲解、在 slide 上框选提问、笔记。全部在本地运行,用你自己的 Claude。
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
Import a PDF of lecture slides and Gloss gives you:
|
|
10
|
+
|
|
11
|
+
- **A mind map** of the lecture: topics on the left, every slide as a thumbnail, with badges for slides you asked about or took notes on.
|
|
12
|
+
- **A workspace for each slide**: the slide, an explanation of it, and your notes for that page.
|
|
13
|
+
- **Questions anchored to the slide**: drag a box around anything (a formula, a diagram) and ask about it. The answer appears next to that spot. Minimize it and a marker stays on the slide; click it later to pick the conversation back up. You can also select a sentence in the explanation and ask about just that.
|
|
14
|
+
- **The lecturer's words, matched to each slide** (optional): upload a transcript (`.txt`, `.vtt`, `.srt`) and Claude works out which part of the talk goes with which slide. Explanations and answers then draw on what was actually said in class.
|
|
15
|
+
- **Answers that know the whole course**: when a question reaches beyond the current slide ("where was this symbol defined?", "how is this different from the method on slide 12?"), Claude searches the rest of the lecture and tells you which slide to look at.
|
|
16
|
+
- **One file per course.** Everything — the slides, explanations, every question and answer, your notes and layout — is saved in a single `.gloss` file as you go. There is no save button. Close it, reopen it, it's all there.
|
|
17
|
+
|
|
18
|
+
Feeding slides straight into a chat gives you one long linear transcript where follow-ups lose track of which part of which slide they were about. Gloss keeps each question attached to the place it came from.
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- **Python 3.11+** and [uv](https://docs.astral.sh/uv/).
|
|
23
|
+
- **[@Claude Code](https://code.claude.com)**, installed and logged in with your Claude account (run `claude` once and use `/login`). Gloss calls the `claude` command on your machine; it never sees your credentials.
|
|
24
|
+
- A Claude plan with Claude Code access. Explanations and answers count toward your plan's usage limits, so Pro users may want a lighter model (see [Configuration](#configuration)).
|
|
25
|
+
|
|
26
|
+
You do **not** need Node.js: the web interface ships pre-built.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
Install from PyPI (the package is called `glossr`; the command is `gloss`):
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
uv tool install glossr # or: pipx install glossr
|
|
34
|
+
gloss doctor # checks Python, claude, login, and the install
|
|
35
|
+
gloss # starts the app and opens it in your browser
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
To try it without installing: `uvx glossr`. To update later: `uv tool upgrade glossr`.
|
|
39
|
+
|
|
40
|
+
Running from a clone instead (for development, or the latest unreleased code):
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
git clone https://github.com/rongrgu/gloss && cd gloss
|
|
44
|
+
uv run gloss doctor
|
|
45
|
+
uv run gloss
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Then drop a PDF onto the home page. The first time you open a course, Claude organizes it into a mind map (one call, about 10–20 seconds). Each slide's explanation is generated the first time you stay on that slide for a moment, and then saved.
|
|
49
|
+
|
|
50
|
+
Other commands (prefix with `uv run` when running from a clone):
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
gloss --port 9000 --no-browser
|
|
54
|
+
gloss doctor --live # also sends a tiny test prompt (uses a little quota)
|
|
55
|
+
gloss export course.gloss # writes course.md
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Using it
|
|
59
|
+
|
|
60
|
+
- **Language** — the interface is in English by default; the 中文 / EN button in the top bar switches it (and the language Claude explains and answers in, unless `language` is set in `config.toml`). Content already generated keeps its language; use Regenerate to redo it.
|
|
61
|
+
- **Mind map** — drag to pan, scroll or use the buttons to zoom, click a topic to fold it. Click a thumbnail to open that slide. "Regenerate map" asks Claude to regroup the slides; your questions and notes are untouched.
|
|
62
|
+
- **Slide workspace** — `←` / `→` change pages. The Layout menu switches between stacked and side-by-side, hides panels, and resets; drag the dividers to resize (double-click resets one).
|
|
63
|
+
- **Ask** — drag a rectangle on the slide, type your question, press Enter. Follow up in the same box. Questions on the same slide are answered one at a time, so a second question may briefly show as queued. To ask about part of the explanation, select the text and press "Ask about this"; those questions show up as numbered chips under the explanation.
|
|
64
|
+
- **Transcript** — on the course page, "Upload transcript". Claude aligns it to the slides (one call, usually under 20 seconds). Each slide's explanation panel can show its excerpt ("Transcript passage"). Explanations generated before the upload aren't redone automatically — use "Regenerate" on the slides you care about.
|
|
65
|
+
- **Notes** — plain text per slide, saved automatically. "Clip to notes" under an answer copies the question and the answer's first paragraph into the page's notes.
|
|
66
|
+
- **Session log** — shows exactly what was sent to Claude for this slide (for the curious).
|
|
67
|
+
- **Library** — the home page is your library folder (`~/Gloss` by default). Organize it however you like: folders for school, year, term, course… A folder that holds lectures is a course. Lectures are listed in the order you imported them; drag to reorder, or drag onto a folder (or a breadcrumb) to move. "Import PDF" puts the new lecture in the folder you are looking at. Folders on disk are the source of truth, so organizing in Finder works too.
|
|
68
|
+
- **Got it / still confused** — under each answer, mark whether you understand now. Unresolved questions turn orange on the slide and on the mind map, and pre-quizzes and summaries take your marks into account.
|
|
69
|
+
- **Finish lecture** — on the mind map, "Finish lecture" has Claude write a study summary from your questions, notes and quiz answers: what the lecture covered, what you asked (grouped by concept), what is still unclear, what you now understand, open questions, and slides worth reviewing. Every point links back to the question it came from. When you ask more later, "Update summary" refreshes it.
|
|
70
|
+
- **Study profile** — each course keeps a list of what you still find unclear, by concept and with evidence (your questions, marks and quiz answers). Finishing a lecture updates it; quiz answers and marks move items between "still unclear", "improving" and "resolved" on their own. You can resolve, reopen, rename, merge or delete items, and undo the last automatic change. New explanations and question sessions mention a weak point when, and only when, the slide is related to it (turn this off with `use_profile = false`).
|
|
71
|
+
- **Pre-quiz** — on any course (or any folder above it), "New pre-quiz" has Claude write practice questions for exam prep. It reads the slides and, above all, what you asked and noted while studying, so it targets where you got stuck, and it covers topics you never asked about too. Each question cites the slide it comes from, says why it was chosen, and has an answer and explanation; a second pass checks every answer key against the slides. Multiple choice is marked automatically; for written answers you compare with the reference answer and mark yourself. Generation takes about a minute and uses noticeably more quota than a question.
|
|
72
|
+
- **Export** — "Export Markdown" on the course page (or `gloss export`) writes the map, explanations, questions and answers, and notes as one Markdown file.
|
|
73
|
+
|
|
74
|
+
A `.gloss` file is self-contained: send it to a classmate and they can read everything in Gloss, even without Claude installed (they just can't ask new questions).
|
|
75
|
+
|
|
76
|
+
## Your data, your Claude account
|
|
77
|
+
|
|
78
|
+
- **Everything stays on your computer.** Courses are saved as `.gloss` files (by default in `~/Gloss/`). The recent-files list lives in `~/.gloss/`. Gloss runs a small web server on your own machine (`127.0.0.1`) and has no cloud service, no account, no telemetry.
|
|
79
|
+
- **What goes to Anthropic:** when you ask for an explanation, a question, or a mind map, Gloss runs your `claude` command with the relevant slide text and images, so that content is processed by Anthropic under your account, exactly as if you had pasted it into Claude Code yourself.
|
|
80
|
+
- **It uses your Claude login and your plan's usage.** Gloss does not log you in, store tokens, or proxy anyone else's account. Each person runs their own copy with their own account.
|
|
81
|
+
- **About Anthropic's terms:** Anthropic does not allow third-party products to offer claude.ai login or to use people's subscription usage unless approved, and expects commercial products to use API keys. Gloss is a free, open-source tool that you run yourself, driving your own locally installed Claude Code. It is not affiliated with or endorsed by Anthropic. Whether Claude Code usage keeps counting toward subscription limits is up to Anthropic and may change; you can switch Gloss to an API key instead (see [Using an API key](#using-an-api-key-instead)).
|
|
82
|
+
- **`ANTHROPIC_API_KEY`:** if this is set in your environment, Claude Code bills that API key instead of your subscription. Gloss removes it when it calls `claude`, and `gloss doctor` warns you if it's set.
|
|
83
|
+
- **Locked down by default:** Claude is run with only read-only file tools (Read, plus Grep/Glob for searching the course), restricted to that course's own working folder (`--restricted`), so it can't run commands, edit files, or read anything else on your disk — not even your other courses. The local server only accepts requests from `localhost` and refuses requests from other websites.
|
|
84
|
+
|
|
85
|
+
## Course materials and copyright
|
|
86
|
+
|
|
87
|
+
Lecture slides, transcripts and recordings belong to their authors. Use Gloss with material you're allowed to use, and **don't commit course files or `.gloss` files to this repository** (they're in `.gitignore`). Tests generate their own PDFs.
|
|
88
|
+
|
|
89
|
+
## Configuration
|
|
90
|
+
|
|
91
|
+
Copy `config.example.toml` to `config.toml` (in the repo; or `~/.gloss/config.toml` if you installed Gloss with pip):
|
|
92
|
+
|
|
93
|
+
| key | default | meaning |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `model` | `"sonnet"` | passed to `claude --model` — an alias (`haiku`, `sonnet`, `opus`) or a full model name |
|
|
96
|
+
| `language` | (unset) | language for explanations, answers and the mind map. Unset, it follows the interface language (English by default; switch with the 中文 / EN button in the top bar). Set it to pin one, e.g. `"中文"` |
|
|
97
|
+
| `concurrency` | `2` | how many Claude calls may run at once (different slides) |
|
|
98
|
+
| `qa_retrieval` | `true` | let answers search the rest of the course when a question needs it |
|
|
99
|
+
| `quiz_model` | (unset) | model for pre-quiz generation; unset uses `model` |
|
|
100
|
+
| `quiz_verify` | `true` | check every pre-quiz answer key against the slides with a second call |
|
|
101
|
+
| `digest_model` | (unset) | model for lecture summaries and study-profile updates; unset uses `model` |
|
|
102
|
+
| `use_profile` | `true` | mention relevant weak points from the study profile in new explanations and question sessions |
|
|
103
|
+
| `provider` | `"claude_cli"` | `"claude_cli"` (your Claude Code login) or `"anthropic_api"` (see below) |
|
|
104
|
+
| `library` | `~/Gloss` | where imported courses are saved |
|
|
105
|
+
| `claude_bin` | found on `PATH` | path to the `claude` executable |
|
|
106
|
+
|
|
107
|
+
### Using an API key instead
|
|
108
|
+
|
|
109
|
+
Set `provider = "anthropic_api"` in `config.toml`, install the extra (`uv tool install 'glossr[api]'`, `pip install 'glossr[api]'`, or `uv sync --extra api` in a clone), and export `ANTHROPIC_API_KEY`. Calls are then billed to that key at API rates instead of counting toward your Claude plan; `gloss doctor` checks the setup. Differences: answers can't search the rest of the course and pre-quizzes aren't available (both need tools, which this route doesn't have), and every follow-up resends the slide's earlier questions and answers (prompt caching keeps the repeated part cheap). On models that support it, Gloss turns on Anthropic's server-side refusal fallback, so a request one model declines is retried on another automatically.
|
|
110
|
+
|
|
111
|
+
**Changing how Claude explains things:** the prompts are plain Markdown in `claude_workspace/` (`CLAUDE.md` for the tutor's role, `prompts/*.md` for each task). Edit them to change the style, for example exam-focused or more concise. Changes apply to new explanations and to new question sessions.
|
|
112
|
+
|
|
113
|
+
## Troubleshooting
|
|
114
|
+
|
|
115
|
+
Start with `uv run gloss doctor`.
|
|
116
|
+
|
|
117
|
+
- **"claude not found"** — install Claude Code, or set `claude_bin` in `config.toml`.
|
|
118
|
+
- **"not logged in"** — run `claude` in a terminal and use `/login`.
|
|
119
|
+
- **An answer failed** — the question is kept; press 重试 (retry). Common causes are usage limits or a network problem; the error message comes from Claude Code.
|
|
120
|
+
- **Port in use** — Gloss picks the next free port automatically, or pass `--port`.
|
|
121
|
+
|
|
122
|
+
## Development
|
|
123
|
+
|
|
124
|
+
Common commands:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
uv run pytest # backend tests
|
|
128
|
+
cd frontend && npm install && npm test # frontend tests
|
|
129
|
+
npm run dev # dev server, proxies /api to `uv run gloss --port 8765`
|
|
130
|
+
npm run build # rebuilds backend/gloss/static (committed; a test checks it's current)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Gloss: ask questions right on your lecture slides."""
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""`gloss` command.
|
|
2
|
+
|
|
3
|
+
gloss start the app and open it in the browser
|
|
4
|
+
gloss doctor [--live] check that Gloss can run here
|
|
5
|
+
gloss export FILE write a course as Markdown
|
|
6
|
+
gloss mcp-serve (internal) course tools for claude, over stdio (DESIGN.md §13.4)
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import socket
|
|
13
|
+
import sys
|
|
14
|
+
import threading
|
|
15
|
+
import time
|
|
16
|
+
import urllib.request
|
|
17
|
+
import webbrowser
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
DEFAULT_PORT = 8765
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def free_port(start: int, tries: int = 20) -> int:
|
|
24
|
+
for port in range(start, start + tries):
|
|
25
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
26
|
+
try:
|
|
27
|
+
s.bind(("127.0.0.1", port))
|
|
28
|
+
return port
|
|
29
|
+
except OSError:
|
|
30
|
+
continue
|
|
31
|
+
raise SystemExit(f"no free port in {start}–{start + tries - 1}; pass --port")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def open_when_ready(url: str, timeout: float = 30) -> None:
|
|
35
|
+
deadline = time.monotonic() + timeout
|
|
36
|
+
while time.monotonic() < deadline:
|
|
37
|
+
try:
|
|
38
|
+
urllib.request.urlopen(url + "api/health", timeout=2).close()
|
|
39
|
+
webbrowser.open(url)
|
|
40
|
+
return
|
|
41
|
+
except OSError:
|
|
42
|
+
time.sleep(0.3)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def serve(args: argparse.Namespace) -> int:
|
|
46
|
+
import uvicorn
|
|
47
|
+
|
|
48
|
+
from .config import Config
|
|
49
|
+
from .doctor import run_checks
|
|
50
|
+
from .server import create_app
|
|
51
|
+
|
|
52
|
+
cfg = Config.load()
|
|
53
|
+
problems = [c for c in run_checks(cfg) if c.status == "fail"]
|
|
54
|
+
for c in problems:
|
|
55
|
+
print(f" ✗ {c.name}: {c.detail}", file=sys.stderr)
|
|
56
|
+
if problems:
|
|
57
|
+
print(" (run `gloss doctor` for details; starting anyway)\n", file=sys.stderr)
|
|
58
|
+
|
|
59
|
+
port = args.port or free_port(DEFAULT_PORT)
|
|
60
|
+
url = f"http://127.0.0.1:{port}/"
|
|
61
|
+
print(f"Gloss is running at {url} (Ctrl+C to stop)", flush=True)
|
|
62
|
+
if not args.no_browser:
|
|
63
|
+
threading.Thread(target=open_when_ready, args=(url,), daemon=True).start()
|
|
64
|
+
uvicorn.run(create_app(cfg), host="127.0.0.1", port=port, log_level="warning")
|
|
65
|
+
return 0
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def export(args: argparse.Namespace) -> int:
|
|
69
|
+
from .config import app_dir
|
|
70
|
+
from .export import export_markdown
|
|
71
|
+
from .i18n import Prefs
|
|
72
|
+
from .store import Course
|
|
73
|
+
|
|
74
|
+
src = Path(args.file)
|
|
75
|
+
out = Path(args.output) if args.output else src.with_suffix(".md")
|
|
76
|
+
with Course.open(src) as c:
|
|
77
|
+
out.write_text(export_markdown(c, Prefs(app_dir() / "prefs.json").locale), encoding="utf-8")
|
|
78
|
+
print(f"wrote {out}")
|
|
79
|
+
return 0
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def main(argv: list[str] | None = None) -> None:
|
|
83
|
+
ap = argparse.ArgumentParser(prog="gloss", description="Ask questions right on your lecture slides.")
|
|
84
|
+
ap.add_argument("--port", type=int, help=f"port to listen on (default: first free from {DEFAULT_PORT})")
|
|
85
|
+
ap.add_argument("--no-browser", action="store_true", help="don't open the browser")
|
|
86
|
+
sub = ap.add_subparsers(dest="cmd")
|
|
87
|
+
d = sub.add_parser("doctor", help="check that Gloss can run here")
|
|
88
|
+
d.add_argument("--live", action="store_true", help="also send a tiny test prompt (uses a little quota)")
|
|
89
|
+
e = sub.add_parser("export", help="export a .gloss course as Markdown")
|
|
90
|
+
e.add_argument("file")
|
|
91
|
+
e.add_argument("-o", "--output", help="output path (default: next to the file, .md)")
|
|
92
|
+
m = sub.add_parser("mcp-serve", help="(internal) serve the course tools to claude over stdio")
|
|
93
|
+
m.add_argument("--library", required=True)
|
|
94
|
+
m.add_argument("--folder", default="")
|
|
95
|
+
m.add_argument("--only", help="comma-separated lecture labels or course ids")
|
|
96
|
+
args = ap.parse_args(argv)
|
|
97
|
+
|
|
98
|
+
if args.cmd == "mcp-serve":
|
|
99
|
+
from .mcp_server import serve as mcp_serve
|
|
100
|
+
mcp_serve(Path(args.library), args.folder, args.only.split(",") if args.only else None)
|
|
101
|
+
sys.exit(0)
|
|
102
|
+
if args.cmd == "doctor":
|
|
103
|
+
from .doctor import main as doctor_main
|
|
104
|
+
sys.exit(doctor_main(["--live"] if args.live else []))
|
|
105
|
+
if args.cmd == "export":
|
|
106
|
+
sys.exit(export(args))
|
|
107
|
+
sys.exit(serve(args))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if __name__ == "__main__":
|
|
111
|
+
main()
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""App configuration (`config.toml`, see config.example.toml).
|
|
2
|
+
|
|
3
|
+
Two ways to run Gloss:
|
|
4
|
+
- From a git clone (`uv run gloss`): config.toml and claude_workspace/ live in the repo.
|
|
5
|
+
- Installed (`pip install`): config.toml and the runtime workspace live in ~/.gloss/
|
|
6
|
+
(override with GLOSS_HOME). The workspace is seeded from the copy bundled in the
|
|
7
|
+
package; files you edit there are never overwritten.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import shutil
|
|
14
|
+
import tomllib
|
|
15
|
+
from dataclasses import dataclass, field, fields
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
PACKAGE_DIR = Path(__file__).resolve().parent
|
|
19
|
+
REPO_ROOT = PACKAGE_DIR.parents[1]
|
|
20
|
+
REPO_WORKSPACE = REPO_ROOT / "claude_workspace"
|
|
21
|
+
BUNDLED_WORKSPACE = PACKAGE_DIR / "_workspace" # only present in a built wheel
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def app_dir() -> Path:
|
|
25
|
+
"""Per-user app data (recent files list; config and workspace when installed). Not inside any .gloss."""
|
|
26
|
+
if env := os.environ.get("GLOSS_HOME"):
|
|
27
|
+
return Path(env)
|
|
28
|
+
return Path.home() / ".gloss"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def in_repo() -> bool:
|
|
32
|
+
return (REPO_WORKSPACE / "CLAUDE.md").exists()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def config_path() -> Path:
|
|
36
|
+
if env := os.environ.get("GLOSS_CONFIG"):
|
|
37
|
+
return Path(env)
|
|
38
|
+
return REPO_ROOT / "config.toml" if in_repo() else app_dir() / "config.toml"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def default_workspace() -> Path:
|
|
42
|
+
if in_repo():
|
|
43
|
+
return REPO_WORKSPACE
|
|
44
|
+
ws = app_dir() / "workspace"
|
|
45
|
+
seed_workspace(BUNDLED_WORKSPACE, ws)
|
|
46
|
+
return ws
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def seed_workspace(src: Path, dst: Path) -> None:
|
|
50
|
+
"""Copy runtime prompts into `dst`, adding missing files only (user edits win)."""
|
|
51
|
+
if not src.exists():
|
|
52
|
+
return
|
|
53
|
+
for f in src.rglob("*.md"):
|
|
54
|
+
target = dst / f.relative_to(src)
|
|
55
|
+
if not target.exists():
|
|
56
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
57
|
+
shutil.copyfile(f, target)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclass
|
|
61
|
+
class Config:
|
|
62
|
+
provider: str = "claude_cli" # claude_cli (your Claude login) | anthropic_api (ANTHROPIC_API_KEY, `glossr[api]`)
|
|
63
|
+
model: str = "sonnet"
|
|
64
|
+
concurrency: int = 2 # global cap on simultaneous LLM calls
|
|
65
|
+
language: str | None = None # explanation / answer language; None follows the interface language (§9.3)
|
|
66
|
+
workspace: Path = field(default_factory=default_workspace)
|
|
67
|
+
library: Path = field(default_factory=lambda: Path.home() / "Gloss") # where new .gloss files go
|
|
68
|
+
claude_bin: str | None = None # default: found on PATH
|
|
69
|
+
timeout: float = 600 # seconds per call
|
|
70
|
+
qa_retrieval: bool = True # answers may search the whole course (Grep/Read in the course folder)
|
|
71
|
+
quiz_model: str | None = None # model for pre-quiz generation (§13.5); None = `model`
|
|
72
|
+
quiz_verify: bool = True # a second call checks every answer key against the slides
|
|
73
|
+
digest_model: str | None = None # model for lecture summaries (§15.3); None = `model`
|
|
74
|
+
use_profile: bool = True # mention relevant study-profile weak points in explanations and Q&A (§15.5)
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def load(cls, path: Path | None = None) -> Config:
|
|
78
|
+
path = path or config_path()
|
|
79
|
+
if not path.exists():
|
|
80
|
+
return cls()
|
|
81
|
+
data = tomllib.loads(path.read_text())
|
|
82
|
+
known = {f.name for f in fields(cls)}
|
|
83
|
+
unknown = set(data) - known
|
|
84
|
+
if unknown:
|
|
85
|
+
raise ValueError(f"unknown config keys in {path}: {sorted(unknown)}")
|
|
86
|
+
for k in ("workspace", "library"):
|
|
87
|
+
if k in data:
|
|
88
|
+
data[k] = Path(data[k]).expanduser()
|
|
89
|
+
return cls(**data)
|