shlogg · Early preview
Radzion Chachura @geekrodion

Create Grammar Fixing Mac Tool With TypeScript & Automator

Create a Mac tool for fixing grammar in selected text using TypeScript, AppleScript & Automator: Set up a new TypeScript project, write code with OpenAI API, bundle & integrate with Automator & assign a shortcut.

🐙 GitHub
In this post, we’ll create a highly useful Mac tool to fix the grammar of any selected text. We’ll build it using TypeScript, the OpenAI API, and AppleScript, integrated into Automator for seamless functionality. You can find all the code here.

  
  
  Core Functionality: The fixGrammar Function

The heart of this tool is the fixGrammar function—a straightforward utility that takes a piece of text as input and returns a grammatically corrected version.

import { shouldBePresent } from "@lib/utils/assert/shouldBePresent"
import OpenAI from "openai"
export const fixGrammar = async (in...