feat: keychain secret picker, proofreading timing and reasoning controls

- API keys: pick an existing Obsidian keychain secret per provider (SecretComponent); data.json stores only the secret name and keys are read at call time. One-time migration links the old fixed-name secrets and drops legacy fields; no more writing empty secrets on every save.
- AIService: treat max-token truncation and empty content as errors instead of crashing on null.trim() or replacing text with a truncated answer.
- Proofreading: live elapsed-time notice, then a summary with model, upstream host and prompt/output/reasoning tokens.
- Proofreading (OpenRouter): Reasoning toggle and Effort setting, default off/low.
This commit is contained in:
olivier committed 2026-10-12 13:32:53 -04:00
1 parent bf27867d20
commit f66d45db68
10 files changed
+264 -108

No files matched your search

+5 -2
View File
@@ -26,6 +26,7 @@ Fix punctuation and grammar of selected text with a single command or right-clic
- **Prompt injection resistant** — the built-in system prompt explicitly guards against prompt injection attacks in the text being proofread
- **Smart quote replacement** — straight quotes → curly quotes (except in code blocks)
- **Timing and token report** — a live timer runs while the model works; when done, a notice shows elapsed time, model, upstream host (OpenRouter), and prompt/output/reasoning token counts (also logged to the console)
- Works with any OpenAI-compatible provider (OpenRouter, OpenAI, etc.)
### 🏷️ Title Generation
@@ -71,7 +72,7 @@ Then copy the `main.js`, `manifest.json`, and `styles.css` to your vault's plugi
## Getting Started
### 1. Configure API Keys
Open **Settings** → **NibbleAI** and add at least one API key:
Open **Settings** → **NibbleAI** and, for at least one provider, pick the secret holding its key from Obsidian's keychain (**Settings** → **Keychain**):
| Key | Used For |
|-----|----------|
@@ -144,7 +145,7 @@ Wherever you need to select an AI model (post-processing, proofreading, title ge
## Settings Reference
### API Keys
Securely stored in your system keychain via Obsidian's SecretStorage. Never written to `data.json`.
Keys live in Obsidian's keychain (SecretStorage). NibbleAI stores only the name of the secret you picked for each provider in `data.json`, and reads the key at the moment it calls the API, so a key rotated in the keychain applies immediately. Upgrading from ≤ 1.2.1 links the previously used `groq-api-key`, `openai-api-key`, `anthropic-api-key`, `openrouter-api-key` and `custom-api-key` secrets automatically.
### Transcription
| Setting | Default | Description |
@@ -187,6 +188,8 @@ Securely stored in your system keychain via Obsidian's SecretStorage. Never writ
| Model | `openai/gpt-4o-mini` | Model for proofreading |
| Temperature | `0.2` | Lower = more consistent |
| Max tokens | `2000` | Maximum response length |
| Reasoning | Off | OpenRouter only. Let the model think before answering; slower and uses more tokens |
| Effort | Low | OpenRouter only. Output effort (`verbosity`); with reasoning on, also reasoning depth |
| System prompt | *(built-in)* | Editable with prompt injection protections |
### Title Generation