Skip to content

Add grammar-fixer extension#27444

Open
prathamVaidya wants to merge 6 commits intoraycast:mainfrom
prathamVaidya:ext/grammar-fixer
Open

Add grammar-fixer extension#27444
prathamVaidya wants to merge 6 commits intoraycast:mainfrom
prathamVaidya:ext/grammar-fixer

Conversation

@prathamVaidya
Copy link
Copy Markdown

@prathamVaidya prathamVaidya commented Apr 26, 2026

Description

Grammar Fixer fixes grammar, spelling, and punctuation of selected text in-place using an LLM — no copy-paste needed, no context switch.

How it works:

  1. Select any text in any app
  2. Trigger the command via hotkey (Cmd+Shift+G on macOS, Ctrl+Shift+G on Windows)
  3. The selected text is replaced with the corrected version instantly

If the text is already correct, a toast notifies the user — nothing is pasted.

Supported providers:

  • Anthropic (Claude)
  • OpenAI
  • OpenRouter
  • Google (Gemini)
  • Groq
  • Ollama (local models, no API key needed)
  • Raycast AI (Raycast Pro users — no API key needed)

Features:

  • Works on selected text in any app via getSelectedText() — no clipboard interaction required
  • 5-minute response cache — repeated fixes on the same text are instant
  • No-change detection — shows a toast instead of pasting if the model returns identical text
  • Extra instructions preference — e.g. "Use British English", "Keep it formal"
  • Custom base URL support for OpenRouter and self-hosted endpoints
  • Friendly, specific error messages for all common failure cases (invalid key, rate limit, quota exceeded, context too long, no text selected, network errors)

Screencast

1 - Setup 2- Select Text 3 - Run Command 4 - Output

Checklist

- Fix Prettier formatting
- Rename to Grammar Fixer, add Windows hotkey to docs
- chore: removed unused skill lock file
- Show toast when fixed text matches original
- chore: removed a loading copy
- chore: remove success toast
- Switch from clipboard to selected text flow
- Fix PR review comments
- chore: removed unused raycast skill
- chore: fixed prettier issues
- chore: updated icon
- refactor: abstract the helper functions, constants and types for improved code readability
- feat: added prompt caching of 5mins
- chore: updated icon
- chore: fix hard requirements for raycast
- chore: added eslint
- docs: added icon
- docs: fix readme and added metadata
- fix: image false positive detection as text
- fix: image false positive detection as text
- docs: added hotkey instruction
- chore: made publish ready
- chore: updated copy for raycast AI
- feat: added Raycast AI support to use without API Keys
- fix: moved preference variables to plugin root
- feat: added user instruction field and updated default models to cheapest models for grammar fixups
- chore: added 1 more loading msg
- feat: added ollama provider
- chore: improved error handling
- fix: add error handlers
- chore: v0 ready
- chore: added raycast extension skill
@raycastbot
Copy link
Copy Markdown
Collaborator

Congratulations on your new Raycast extension! 🚀

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

Once the PR is approved and merged, the extension will be available on our Store.

@prathamVaidya prathamVaidya marked this pull request as ready for review April 26, 2026 15:40
- Resize screenshots to 2000x1250
- chore: updated metadata screenshots
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 26, 2026

Greptile Summary

This PR adds a new grammar-fixer extension that corrects selected text in-place using an LLM, supporting Anthropic, OpenAI, OpenRouter, Google, Groq, Ollama, and Raycast AI as providers via the Vercel AI SDK. The implementation is clean and well-structured, but there is one notable UX issue:

  • apiKey is required: true but is completely unused for OllamabuildModel replaces the user-supplied value with the hardcoded string \"ollama\", yet Raycast blocks the command until the field is filled. The field description mentions Raycast Pro users need a placeholder but says nothing about Ollama users, leaving them without guidance.

Confidence Score: 3/5

Not safe to merge without fixing the Ollama API key UX issue — users are forced to enter a meaningless placeholder.

One P1 finding: apiKey is required: true but the field is entirely unused for Ollama, actively blocking Ollama users from running the command without entering a fake key. The rest of the issues (unbounded cache key, hardcoded Raycast AI model, capitalisation typo) are P2.

extensions/grammar-fixer/package.json — the apiKey preference definition needs required: false or conditional guidance for Ollama users.

Important Files Changed

Filename Overview
extensions/grammar-fixer/package.json Extension manifest with preferences; apiKey is required: true but completely ignored for Ollama users, forcing a confusing placeholder entry.
extensions/grammar-fixer/src/fix-grammar.ts Main command entry point; caches results and pastes corrected text. Raycast AI path hardcodes model, ignoring user preference.
extensions/grammar-fixer/src/helpers/cache.ts 5-minute TTL in-memory cache; cache key uses raw full text which can be arbitrarily large for long selections.
extensions/grammar-fixer/src/helpers/model.ts Builds the AI SDK model instance per provider; correctly hardcodes "ollama" as the API key for the Ollama provider.
extensions/grammar-fixer/src/helpers/errors.ts Maps Vercel AI SDK error types to user-friendly messages; covers common HTTP status codes and network errors cleanly.
extensions/grammar-fixer/src/constants.ts System prompt and loading messages; minor capitalisation issue with "english" in one message.
extensions/grammar-fixer/src/types.ts Defines the Provider union type; straightforward and correct.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/grammar-fixer/package.json
Line: 57-61

Comment:
**`apiKey` marked required but unused for Ollama**

`apiKey` is `required: true`, which forces Raycast to block the command until the user fills it in. For Ollama users, `buildModel` replaces their entered value with the hardcoded string `"ollama"`, so the field is completely ignored. The description only mentions Raycast Pro users need a placeholder, leaving Ollama users confused about why they must supply an API key they don't have.

Consider setting `"required": false` and adding a note in the description that Ollama and Raycast AI users can leave this blank.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/grammar-fixer/src/helpers/cache.ts
Line: 12-14

Comment:
**Cache key size unbounded for large selections**

The key is built from the full text and system prompt verbatim. For a user who selects a large document, this produces a multi-kilobyte cache key. Raycast's `Cache` stores keys in SQLite; very long keys degrade lookup performance and can exceed storage limits. Hashing the inputs (e.g. a simple djb2 or using `crypto.createHash`) would keep keys small and collision-resistant.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/grammar-fixer/src/fix-grammar.ts
Line: 56-60

Comment:
**Raycast AI path ignores user's model preference**

When `useRaycastAI` is `true`, the model is hardcoded to `AI.Model["OpenAI_GPT-4.1_nano"]` regardless of what the user has set in the `model` preference field. If a Raycast Pro user wants a different model (e.g. a more capable one), their preference is silently ignored. Consider reading `prefs.model` and passing it through, or documenting this limitation.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/grammar-fixer/src/constants.ts
Line: 9

Comment:
**"english" should be capitalised**

"english" is a proper noun and should always be capitalised to `"English"`.

```suggestion
  "Making your English teacher proud…",
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Update grammar-fixer extension" | Re-trigger Greptile

Comment thread extensions/grammar-fixer/package.json
Comment thread extensions/grammar-fixer/src/helpers/cache.ts Outdated
Comment thread extensions/grammar-fixer/src/fix-grammar.ts Outdated
Comment thread extensions/grammar-fixer/src/constants.ts Outdated
@prathamVaidya
Copy link
Copy Markdown
Author

Fixed all the comments

- Regenerate raycast-env.d.ts: apiKey required
- Restore apiKey as required, clarify Ollama exception in description
- Fix OpenRouter base URL not applied when customBaseURL is empty string
- fix: temp to 0 for least creativity
@prathamVaidya
Copy link
Copy Markdown
Author

@raycastbot review again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants