AI Cloze Reading

approvedunreviewed

by liufree

AI-powered cloze reading view: open any note to generate a cloze reading view, adjust cloze density, remember the last AI cloze result (unless you regenerate), and spaced-repetition review mode (integrated with the Obsidian API). Supports custom AI providers and models.

↓ 17 downloadsUpdated 12d agoMIT

ai-cloze · AI Cloze Reading (Obsidian Plugin)

AI-powered cloze reading view + spaced-repetition review mode. Stack: Obsidian Plugin API + React 18 + Ant Design 5 + esbuild + TypeScript.

中文

Features

  1. Custom markdown reading view: The "Open AI cloze reading view for current note" command renders the current note in a separate tab, where the AI automatically identifies key knowledge points and blanks them out. Click a blank to reveal/hide the answer in place (only a CSS class toggle — no full-page rebuild, no flicker). Tables, dataview, math formulas, code, mermaid, and other elements are all preserved intact.
  2. Configurable provider & model: The settings panel supports OpenAI-compatible / Anthropic / Ollama (local), with Base URL, API Key, model, temperature, and max tokens; a "Test AI connection" button fires a minimal request to verify connectivity in one click.
  3. Adjustable cloze density: A 0–100% slider adjusts the blank ratio in real time (top-N% ranked by AI importance).
  4. Memory & auto-cloze switches: Each open reads the per-note cache (data.json) directly for the last result; the AI is only re-invoked when you click "Re-cloze with AI"; a yellow hint appears when "original note modified". Enable "auto cloze" in settings to invoke the AI automatically when opening an uncached note (long notes consume a lot of tokens; a hint is shown when this triggers).
  5. Review memory mode: Flip through cards term by term, click "reveal answer", and rate Again / Hard / Good / Easy (SM-2-style spaced repetition; ease/interval/lapses/reps/due stored in data.json). On completion, Good/Easy terms can be written back to the note as under a "🎴 cloze flashcards" section (#flashcards review/flashcard, compatible with the Spaced Repetition plugin).
  6. Bidirectional document navigation: When any markdown note is open, an "AI cloze" button in the view header opens its cloze reading view in one click; the "Back to note" button in the cloze view toolbar jumps back to the original note (activates the existing tab if already open).

Demo

A demo note is included at demo/demo-note.md. Open it in Obsidian and run "Open AI cloze reading view for current note" to try AI cloze generation, density adjustment, review cards, and flashcard export.

Development

npm install
npm run dev        # watch build
npm run build      # typecheck + production build + deploy to .obsidian/plugins/ai-cloze
npm run smoke      # pure logic + jsdom DOM + React component smoke tests

Build output auto-deploys to .obsidian/plugins/ai-cloze/; restart Obsidian or reload the plugin in settings to take effect.

Files

FileDescription
src/main.tsxPlugin entry: registers view, commands, settings tab
src/view.tsxCustom ItemView (React mount)
src/components/App.tsxMain UI: toolbar + reading/review switch + cache & generation logic
src/components/ReadingMode.tsxReading cloze rendering
src/components/ReviewMode.tsxReview mode
src/ai.tsAI provider client (OpenAI-compatible / Anthropic / Ollama)
src/cloze.tsAI prompt, JSON parsing, density selection
src/dom.tsMarkdown DOM cloze wrapping
src/srs.tsSM-2 spaced repetition
src/settings.tsSettings tab

License

MIT

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.