Ask About Selection

unlisted

by pijohn23

Ask a question about selected text and keep the answer as a linked note. Needs the OpenAI Codex CLI installed and signed in on your computer.

Updated 7d agoMIT
View on GitHub

Ask About Selection

A plugin for Obsidian: select some text in a note, ask a question about it, and keep the answer as a note that links back to where you asked.

The answers come from the Codex CLI, OpenAI's command-line program, which must be installed and signed in on your computer. The plugin only starts that program. It contains no account, key or password, and it never reads, stores or forwards your sign-in.

Status: beta (0.4.0). The parts that talk to the AI and build the notes are covered by automated tests, and the request path has been tried against the real Codex CLI. The plugin as published here has not yet been used for long inside the real Obsidian app. Try it in a test vault first, and keep a backup of your vault.

What it does

  1. Select text with the mouse in a note (Source mode or Live Preview). A small Ask button appears next to the selection. Or run the command Ask about selection (you can give it a hotkey).
  2. A small window opens. Type your question and choose a mode:
    • Explain: a clear explanation.
    • Give only a hint: one short hint, no full solution.
    • Check my reasoning: you describe your own thinking and get told what is right, missing or wrong.
  3. Choose how much of the note is shared: Selected text only, Current section, Whole note or No note context. You can look at exactly what will be sent before you send it.
  4. Click Send question. After roughly 10 to 30 seconds a new note with the question, the shared excerpt and the answer opens next to your note. Formulas are written the way Obsidian renders them ($…$, $$…$$).

More commands:

  • Ask a follow-up question: run it while an answer note is open. Codex continues the same conversation and the new answer is added to the same note.
  • Ask a free question: a question without any note.
  • Open request / draft and Cancel the running request.

If you close the window before sending, your question is kept as a draft; click the status bar item to continue.

What it does not do

  • By default it never changes your notes. It only creates answer notes in one folder (AI Answers, you can change it). The answer note links back to your note.
  • Optional: with Add a link below the paragraph switched on in the settings, a question about a normal paragraph also adds a block ID and a small link (💬1) to the answer below that paragraph. Lists, tables, callouts, code and formula blocks are never changed.
  • Codex is started without tools: it cannot read your files, change anything or use the internet. It receives only the context you chose and your question. Note text is treated as content to be discussed, not as instructions.
  • Nothing is sent when you merely select text. A request is only made when you send a question.
  • It does not work on phones or tablets (it needs to start a program on your computer).

Your account, privacy and the provider's rules

  • When you send a question, the context shown in the window and your question are sent to OpenAI by the Codex CLI, under your own account. The plugin sends nothing anywhere else. Your personal Codex configuration file is not loaded for these requests; only your existing sign-in is used.
  • Your use of Codex is covered by the agreement between you and OpenAI (its terms of use and usage policies), and requests count against your own plan or API key. Please read those terms; this plugin does not change them.
  • The plugin is free and non-commercial. It is an independent project: not affiliated with, endorsed by or supported by OpenAI or Obsidian. "OpenAI" and "Codex" are named only to say which program is needed.
  • Answers are generated by an AI model and can be wrong. Check anything important against your own sources.
  • Each answer note stores two IDs at the top (a conversation ID and the Codex session ID) so that follow-up questions can continue the same conversation. The session itself stays in the Codex folder of your user account.

What you need

  • Obsidian 1.5.0 or newer on a computer (desktop only). Developed on macOS; it is written to also run on Linux and Windows, but that has not been tested yet. Reports are welcome.
  • The Codex CLI, installed and signed in. Check in a terminal: codex login status

Install

By hand

  1. Download main.js, manifest.json and styles.css from the latest entry on the Releases page of this repository (or the zip file that contains all three).
  2. Put them into a new folder ask-about-selection inside your vault's plugin folder: <your vault>/.obsidian/plugins/ask-about-selection/
  3. In Obsidian: Settings → Community plugins, switch on Ask About Selection. (If you have never used community plugins, Obsidian first asks you to turn them on.)

With BRAT (a community plugin for installing plugins straight from GitHub): install BRAT, choose Add beta plugin, and paste the address of this repository.

If the plugin says the Codex CLI was not found: open a terminal, run which codex, and paste the path it prints into Settings → Ask About Selection → Codex CLI.

Settings

SettingMeaningDefault
Ask button after selectingshow the small button after a mouse selectionon
Answer folderfolder in the vault for answer notesAI Answers
Add a link below the paragraphalso mark the paragraph you asked about (changes your note)off
Codex CLIcomplete path to the program; empty = search for itempty
Modelmodel name; empty = the CLI's defaultempty
Time limit in seconds10 to 1800180

Remove

Switch the plugin off in Settings → Community plugins and delete the folder <your vault>/.obsidian/plugins/ask-about-selection/. Your answer notes stay where they are.

For developers

You need Node.js 20 or newer.

npm ci
npm run typecheck
npm run build
npm test

npm run build writes the plugin to dist/ (main.js, manifest.json, styles.css) and test modules to .test-build/. Run the tests after building.

FileContent
src/core.tseverything about text: finding the paragraph, building the request, parsing the answer, building notes and links
src/backend.tsfinding and starting the Codex CLI safely, with cancel and time limit
src/composer.tsthe question window
src/selection-ui.tsthe small Ask button
src/main.tsthe plugin itself: commands, drafts, saving notes through Obsidian
tests/automated tests; obsidian.test.cjs runs the built plugin against a small stand-in for Obsidian

Licence

MIT. The file vendor/markdown-it.cjs is the markdown-it library, also MIT; its licence is in vendor/markdown-it.LICENSE.

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.