A personal workspace for small OpenAI-powered command line tools.
tts: turns.txtand.mdfiles into audio with OpenAI text-to-speech.
- Root Google Drive helpers live in
utils/. - TTS runnable scripts live in
tts/cli/. - TTS-local helpers live in
tts/utils/.
New CLI entry files should keep their runnable workflow inside a main() function
and only call it when the file is run directly. Use the shared guard from
utils/cli.ts:
import { checkIsDirectlyCalledFile } from "../utils/cli";
async function main(): Promise<void> {
// CLI workflow here.
}
if (checkIsDirectlyCalledFile(import.meta.url)) {
main().catch((error: unknown) => {
console.error(error instanceof Error ? error.message : String(error));
process.exit(1);
});
}This keeps CLI modules import-safe for tests or future reuse.
Install everything from the repo root. npm workspaces install the root utilities and tool packages together:
npm installRun the full repo check from the root:
npm run verifyThis runs TypeScript typechecking and the unit test suite.
Create a top-level .env file:
cp .env.example .envThen add your OpenAI API key:
OPENAI_API_KEY=your_api_key_hereOptional Google Drive uploads use OAuth. A plain Google API key cannot upload files to a personal Google Drive.
- Enable the Google Drive API.
- Configure the OAuth consent screen, keep the app in Testing, and add yourself as a test user.
- Create an OAuth client ID with application type Desktop app.
- Download the client JSON, rename it to
google-oauth-client.json, and put it in the repo root. - Run the setup command and approve the browser consent flow:
npm run setup-gdriveThat creates google-oauth-token.json in the repo root. Both Google OAuth JSON files are gitignored.
Run npm run setup-gdrive once on a machine with a browser, then copy both files to the headless repo root:
google-oauth-client.json
google-oauth-token.json
To print the consent URL without opening a browser automatically, use this. The browser still needs to reach the printed localhost callback URL.
GOOGLE_DRIVE_OAUTH_NO_BROWSER=1 npm run setup-gdriveRun the TTS tool from the repo root:
npm run tts -- my-file.mdOr from inside the tool folder:
cd tts
npm run tts -- my-file.mdSee tts/README.md for TTS-specific usage and options.