โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโ โโโ โโโ โโโ โโโโโโโ โโโโโโโโโโ โโโ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโ โโโ โโโโโโโโโโโโโโโโโโโโ โโโโ
โโโโโโโโ โโโ โโโ โโโโโโ โโโ โโโโโโโ โโโ โโโ โโโโโโ โโโโโโโ
โโโโโโโโ โโโ โโโ โโโโโโ โโโ โโโโโ โโโ โโโ โโโโโโ โโโโโโโ
โโโโโโโโ โโโ โโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ
โโโโโโโโ โโโ โโโโโโโ โโโโโโโ โโโ โโโโโโโโ โโโโโโโ โโโโโโโโโโ โโโ
The AI study agent that locks you in, teaches you properly, and won't let you leave until you actually understand it. Runs 100% locally. No cloud. No subscription. No excuses.
You know that feeling where you open a YouTube tutorial, watch 4 minutes, think "wait let me just check one thing", and then 45 minutes later you're watching a video about why cats hate water?
That's not a willpower problem. That's a missing accountability loop.
Study Lock is a terminal app that:
- Takes any learning resource โ a YouTube video, a PDF, a website, raw notes
- Reads it completely and chunks it into digestible topic sections
- Locks your terminal into fullscreen (you can't
Ctrl+Cyour way out) - Assigns you one of 4 AI teacher personas who teach each chunk their way
- Won't let you advance until you score 70+ on a comprehension question
- Tracks exactly which concepts you're weak on and hammers those specifically
- Unlocks you when the session is done โ with a full breakdown of what you know and what needs work
The timer is a soft deadline. If it runs out mid-chunk, you still have to clear that chunk. The material wins. Always.
_ _____ __________ * . * . *
__/ \__ [=o=o=] [##########] . ( ) .
/ o o \ / \___/ \ | > < | * ( o . o ) *
| w | | ' ___ ' | | ____ | . \ ___ / .
\_______/ | ( ) | | ( __ ) | * . . *
| | \_______/ |__________| * * * * *
~~| |~~ | | | | | |
/ \ _|___|_ _|_|_
Sensei Sam Prof. Maya Drill Sgt. Rex The Oracle
โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโ
Gentle Rigorous Demanding Adaptive
Calm analogies, Socratic method, Dense. Direct. Watches your
walks you through expects you to No fluff. Calls answers and
it like a friend reason, not out vague answers adjusts the
over coffee just recall immediately whole session
Pick one at the start. Your choice sets the entire tone of the session โ how concepts are explained, how questions are framed, how feedback lands.
You paste a resource
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ INGEST โ
โ YouTube โ transcript API โ
โ Website โ article extraction (strips nav, ads, footer) โ
โ PDF โ full text via PyMuPDF โ
โ DOCX โ paragraph extraction โ
โ Text โ used directly โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SMART CHUNKER โ
โ Strips filler words, timestamps, transcript noise โ
โ Detects topic transitions ("now let's look at...", โ
โ "the next thing...", "in other words...") โ
โ Groups into ~700-word topic chunks with 80-word overlap โ
โ Labels each chunk with a topic hint โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SESSION LOCK โ
โ Terminal goes fullscreen via AppleScript โ
โ Ctrl+C blocked with a reminder message โ
โ Background timer thread starts countdown โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโดโโโโโ
โ CHUNK โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโฌโโโโโ โ
โ โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ โ
โ TEACH โ โ
โ Persona reads chunk โ โ
โ Teaches from OWN โ โ
โ knowledge (material โ โ
โ is a reference, not โ โ
โ a script) โ โ
โ Streams token-by- โ โ
โ token live โ โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ โ
โ QUESTION โ โ
โ Generated based on โ โ
โ concept + your known โ โ
โ weak areas โ โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ โ
โ YOUR ANSWER โ โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ score < 70 โ
โ EVALUATE โโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Score 0โ100 โ rephrase question โ
โ Specific feedback โ every 3 fails โ
โ Records weak areas โ โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโ โ
โ score โฅ 70 โ
โผ โ
โโโโโโโโโโโโโโโโโโโโโโโโโ more chunks? โ
โ CHUNK CLEARED โ โโโโโ yes โโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ no more chunks
โผ
SESSION SUMMARY + UNLOCK
- macOS (fullscreen lock uses AppleScript โ on other OS the session still works, just no forced fullscreen)
- Python 3.11+
- Ollama (runs Gemma locally โ no internet needed after initial setup)
- ~10GB disk space for the Gemma model
# Install Ollama (macOS)
brew install ollama
# Start the Ollama server in the background
ollama serve &
# Pull Gemma 4 (~10GB, one-time download โ go make a coffee)
ollama pull gemma4Why Gemma? It's Google's open-weights model that runs well on consumer hardware. If you have a different model already pulled, you can use that instead โ see the Model Options section below.
# Navigate into the project folder
cd study-lock-v2-improved
# Create a virtual environment (keeps your system Python clean)
python3 -m venv venv
# Activate it
source venv/bin/activate
# Install all dependencies
pip install -r requirements.txtYou'll see (venv) appear in your terminal prompt. That means you're inside the virtual environment. Every time you open a new terminal to use Study Lock, run source venv/bin/activate again first.
python main.pyThat's it. The app takes over from here.
What's your name? โ Ray
Source? โ https://youtu.be/lfmg-EJ8gm4
โ /Users/ray/notes.pdf
โ https://docs.python.org/3/tutorial/
โ (paste raw text directly)
Duration? โ 30 (minutes)
Teacher? โ 1 (Sensei Sam)
โ 2 (Prof. Maya)
โ 3 (Drill Sgt. Rex)
โ 4 (The Oracle)
Then you're locked in.
By default the app uses gemma4. You can swap any Ollama model in:
# Use Gemma 3 (smaller, faster)
STUDY_MODEL=gemma3 python main.py
# Use Llama 3.2
STUDY_MODEL=llama3.2 python main.py
# Use Mistral
STUDY_MODEL=mistral python main.pyOr change the default permanently โ open main.py and find this line near the top:
MODEL = os.environ.get("STUDY_MODEL", "gemma4")Replace "gemma4" with whatever model you want.
To see what models you have pulled:
ollama listWhen a session starts, the app fires an AppleScript that sets AXFullScreen = true on whatever terminal window is active. This works with Terminal.app and iTerm2.
For this to work, you need to grant Accessibility access once:
System Settings โ Privacy & Security โ Accessibility โ enable Terminal (or iTerm2)
If you skip this, the session still runs โ it just won't force fullscreen. You'd be on the honour system.
During the session, Ctrl+C is intercepted. Instead of killing the process, it prints:
โก Ctrl+C blocked during study session.
To exit early, type: "i commit to finishing"
Yes, the exit phrase is ironic on purpose.
| Type | Example |
|---|---|
| YouTube | https://youtu.be/dQw4w9WgXcQ ยท https://youtube.com/watch?v=... |
| Website | https://docs.python.org/3/tutorial/ ยท any article URL |
/Users/ray/Downloads/lecture.pdf |
|
| Word doc | /Users/ray/notes.docx |
| Plain text | Just paste it directly at the source prompt |
YouTube note: The video needs English captions enabled (auto-generated is fine). If a video has no captions at all, you'll get an error โ paste the transcript manually instead.
study-lock-v2-improved/
โ
โโโ main.py โ Entry point. Onboarding, persona picker, session loop
โ
โโโ requirements.txt โ All Python dependencies
โ
โโโ content/
โ โโโ ingester.py โ Pulls text from YouTube / websites / PDFs / DOCX / text
โ โโโ chunker.py โ Cleans transcript noise, detects topic boundaries,
โ groups into ~700-word chunks with topic labels
โ
โโโ agents/
โ โโโ personas.py โ 4 persona definitions: prompts, ASCII art, difficulty
โ โโโ study_agent.py โ Core loop: teach โ question โ evaluate โ gate
โ Also contains WeaknessTracker
โ
โโโ session/
โโโ manager.py โ Timer thread, fullscreen AppleScript,
Ctrl+C signal trap, session state
This is the part that makes Study Lock actually adaptive rather than just a fancy flashcard app.
Every time you answer a question, the app:
- Extracts a "concept label" from the question (strips stop words, keeps the 5 most meaningful words)
- Records your score against that concept
- On every subsequent
teachandquestioncall, if you have weak concepts (score < 65), that context is injected into the prompt:
Student has struggled with: 'recursion base case' (score: 32),
'stack frame allocation' (score: 45). Address these proactively.
The Oracle persona responds to this most aggressively โ it'll pivot the entire explanation toward your gaps. Drill Sergeant Rex will specifically target your weak spots in the question. At the end of the session, your weak areas are listed in the summary so you know exactly what to review.
When you're done, you get a breakdown:
โญโโโโโโโโโโโโโโโโโโโ Session Summary โโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Ray โ session complete! โ
โ โ
โ Material: Python Tutorial for Beginners โ
โ Teacher: ๐ง Sensei Sam โ
โ Time: 28.4 min โ
โ Chunks: 4 / 6 โ
โ Questions: 3 cleared / 4 asked โ
โ Score: 75% โ Good โ
โ โ
โ Solid session. Keep the momentum. โ
โ โ
โ Watch out for: 'variable scope closures' (score 41) โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
| Package | What it does |
|---|---|
ollama |
Talks to your local Ollama server |
rich |
All the terminal UI โ panels, spinners, score bars, colour |
youtube-transcript-api |
Pulls captions from YouTube videos |
requests + beautifulsoup4 |
Fetches and parses websites |
readability-lxml |
Extracts the article content from a webpage (strips nav, ads, sidebars) |
PyMuPDF |
Extracts text from PDFs page by page |
python-docx |
Reads Word documents |
Everything runs locally. After the initial pip install and model pull, this works fully offline.
Could not connect to Ollama
# Ollama isn't running. Start it:
ollama serve
# (run this in a separate terminal tab, or add & to background it)Model 'gemma4' not found
ollama pull gemma4
# or check what you have:
ollama list
# then run with a model you actually have:
STUDY_MODEL=gemma3 python main.pyNo English transcript available
The video doesn't have English captions. Either find a video that does, or copy-paste the transcript manually at the source prompt.
Fullscreen doesn't work
Go to System Settings โ Privacy & Security โ Accessibility and enable your terminal app. Or just manually fullscreen your terminal before starting โ same effect.
(venv) disappeared from my prompt
Your virtual environment got deactivated (new terminal tab, shell restart). Run:
source venv/bin/activateMost study tools optimise for engagement. Study Lock optimises for one thing: did you actually understand it?
The comprehension gate (score 70+ to advance) means you can't passively consume. The weakness tracker means the session responds to your actual gaps, not a generic curriculum. The fullscreen lock means your phone-checking reflex has to fight the OS rather than just your willpower.
It's not supposed to be fun the way scrolling is fun. It's supposed to feel like the good kind of hard โ the kind where you close the terminal and actually know something you didn't know before.
MIT โ do whatever you want with it.
Built with Ollama + Gemma + Rich. Runs entirely on your machine.