{"id":20783531,"url":"https://github.com/fredm23579/openai-chat-commandline","last_synced_at":"2026-04-20T08:03:04.344Z","repository":{"id":233038613,"uuid":"785861038","full_name":"fredm23579/openai-chat-commandline","owner":"fredm23579","description":"chatGPT command line chat using nodejs which works on any command line.","archived":false,"fork":false,"pushed_at":"2024-04-18T01:16:15.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T09:30:23.913Z","etag":null,"topics":["ai","chat","chatgpt","chatgpt-turbo","command-line","command-line-tool","commandline","openai","openai-api","openai-chatgpt"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fredm23579.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-12T19:30:21.000Z","updated_at":"2024-06-07T11:41:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"78e7c4ce-dd95-4518-ba88-a9c06e678ca3","html_url":"https://github.com/fredm23579/openai-chat-commandline","commit_stats":null,"previous_names":["fredm23579/openai-chat-commandline"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredm23579%2Fopenai-chat-commandline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredm23579%2Fopenai-chat-commandline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredm23579%2Fopenai-chat-commandline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredm23579%2Fopenai-chat-commandline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredm23579","download_url":"https://codeload.github.com/fredm23579/openai-chat-commandline/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243125563,"owners_count":20240276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chat","chatgpt","chatgpt-turbo","command-line","command-line-tool","commandline","openai","openai-api","openai-chatgpt"],"created_at":"2024-11-17T14:20:01.347Z","updated_at":"2026-04-20T08:03:04.337Z","avatar_url":"https://github.com/fredm23579.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI Chat — Universal Command-Line Assistant\n\nA Node.js command-line chat application supporting **six AI providers**, **automatic web search with cited sources**, **file and URL attachments**, **Google Drive and Gmail integration**, **persistent session history**, **cross-session memory**, and **chat import from other AIs**.\n\n---\n\n## Features\n\n### AI Providers\n\nSelect from six providers at startup (or set a default):\n\n| Provider | Models | Notes |\n|---|---|---|\n| **OpenAI** | gpt-4o, gpt-4.1, o3-mini, … | Vision support, 1 M ctx |\n| **Anthropic (Claude)** | claude-opus-4-6, claude-sonnet-4-6, … | Vision support, 200 k ctx |\n| **Google Gemini** | gemini-2.0-flash, gemini-1.5-pro, … | Up to 2 M ctx, vision |\n| **Perplexity** | sonar, sonar-pro, sonar-deep-research | Built-in real-time web search |\n| **X AI (Grok)** | grok-3, grok-3-fast, grok-2-1212 | xAI flagship models |\n| **Meta / Llama (Groq)** | llama-3.3-70b, llama-3.1-8b, mixtral | Fast open-weights inference |\n\n### Automatic Web Search\n\nEvery prompt is searched via **Tavily** or **Brave Search** before the AI responds. Results are injected as context and cited sources (`[1]`, `[2]`, …) are printed below each reply.\n\n### File \u0026 URL Attachments\n\nAttach content to any message with `/file` or `/url`:\n\n| Type | Details |\n|---|---|\n| Text / code | `.txt`, `.md`, `.js`, `.py`, `.json`, `.csv`, `.html`, and any UTF-8 file |\n| PDF | `.pdf` — text extracted locally or from a URL |\n| Word | `.docx` — text extracted via mammoth |\n| PowerPoint | `.pptx` — slide text extracted |\n| Images | `.jpg`, `.png`, `.gif`, `.webp` — passed to vision models |\n| Audio | `.mp3`, `.wav`, `.m4a`, … — transcribed via OpenAI Whisper |\n| URLs | Any `https://` page — text extracted |\n| Google Docs | `docs.google.com/document/…` — exported as text (public or OAuth) |\n| Google Sheets | `docs.google.com/spreadsheets/…` — exported as CSV |\n\n### Google Drive \u0026 Gmail (OAuth2)\n\n- `/gdrive \u003cquery\u003e` — full-text search across your Drive; select a file to attach\n- `/gdrive \u003cfile-id or URL\u003e` — attach a specific Drive file directly\n- `/gmail \u003cquery\u003e` — search Gmail and multi-select emails to attach as context\n- One-time OAuth2 browser consent; tokens cached automatically\n\n### Persistent Session History\n\n- Every conversation is saved to `~/.ai-chat/sessions/` as a JSON file\n- `/history` — browse and reload any saved session\n- `/context` — multi-select previous sessions as reference context for the current chat\n- `/save` — force-save at any time; sessions also auto-save on exit\n\n### Cross-Session Memory\n\n- `/remember \u003cfact\u003e` — persist any fact about yourself across all future sessions\n- `/memory` — list all stored memories\n- `/forget \u003cid\u003e` — remove a specific memory\n- Memories are automatically injected into every AI call\n\n### Personalization\n\n- `/config` — set your name, default provider/model, auto-search preference, and more\n- Saved defaults skip the provider/model selection menus on startup\n\n### Chat Import\n\n`/import \u003cfile\u003e` — import conversation history from:\n\n- **ChatGPT** (`conversations.json` from Settings → Data export)\n- **Claude.ai** (Claude conversation export JSON)\n- **Gemini / Bard** (Google Takeout export)\n- **Generic JSON** (`[{role, content}]` arrays)\n- **Markdown** transcripts (`# User` / `# Assistant` headings)\n\nImported sessions are saved and available via `/history` or `/context`.\n\n### REPL Quality of Life\n\n- **Streaming output** — tokens appear live for all providers\n- **↑/↓ prompt history** — persisted to `~/.ai-chat/prompt_history` across sessions\n- **Tab completion** — commands and file paths\n- **Ctrl-C** — auto-saves session and exits cleanly\n\n---\n\n## Prerequisites\n\n- **Node.js v18.0+**\n- **npm**\n- At least one AI provider API key (see Configuration)\n\n---\n\n## Installation\n\n```bash\ngit clone https://github.com/fredm23579/openai-chat-commandline.git\ncd openai-chat-commandline\nnpm install\n```\n\n---\n\n## Configuration\n\nCopy the example env file and add your keys:\n\n```bash\ncp .env.example .env\n```\n\nThen edit `.env`. At minimum, set one AI provider key:\n\n```env\n# At least one provider required\nOPENAI_API_KEY=sk-...\n# ANTHROPIC_API_KEY=sk-ant-...\n# GOOGLE_API_KEY=AI...\n# PERPLEXITY_API_KEY=pplx-...\n# XAI_API_KEY=xai-...\n# GROQ_API_KEY=gsk_...\n\n# Recommended: enables automatic web search\nTAVILY_API_KEY=tvly-...\n```\n\nSee `.env.example` for the full list including Brave Search and local model endpoints.\n\n### Google Drive \u0026 Gmail (optional)\n\n1. Go to [Google Cloud Console → Credentials](https://console.cloud.google.com/apis/credentials)\n2. Create a project → enable **Google Drive API** and **Gmail API**\n3. Create credential → **OAuth 2.0 Client ID → Desktop app** → Download JSON\n4. Save the downloaded file as `~/.ai-chat/google-credentials.json`\n\nOn first use of `/gdrive` or `/gmail`, your browser will open for consent. Tokens are cached in `~/.ai-chat/google-tokens.json`.\n\n### Custom / Local Models (optional)\n\nPoint the OpenAI client at any compatible server such as Ollama or LM Studio:\n\n```env\nOPENAI_BASE_URL=http://localhost:11434/v1\nOPENAI_API_KEY=ollama   # any non-empty string\n```\n\n---\n\n## Usage\n\n```bash\nnode chat.js\n# or\nnpm start\n```\n\nOn startup you will be prompted to select a provider and model (or your saved defaults will be used). Then type any message to begin chatting.\n\n---\n\n## Commands\n\n| Command | Description |\n|---|---|\n| `/help` | Show full command reference |\n| `/clear` | Clear conversation, context, and system prompt |\n| `/save` | Save current session immediately |\n| `/history` | Browse and reload a saved session |\n| `/context` | Multi-select previous sessions as reference context |\n| `/model` | Switch provider / model mid-session |\n| `/system \u003ctext\u003e` | Set a system prompt |\n| `/file \u003cpath\u003e` | Attach a local file |\n| `/url \u003curl\u003e` | Attach a URL or Google Doc |\n| `/gdrive \u003cquery or id\u003e` | Search or attach a Google Drive file |\n| `/gmail \u003cquery\u003e` | Search Gmail and attach emails |\n| `/search \u003cquery\u003e` | Manual web search (no AI call) |\n| `/remember \u003cfact\u003e` | Persist a fact across all sessions |\n| `/memory` | List stored memories |\n| `/forget \u003cid\u003e` | Delete a memory |\n| `/config` | Edit name, defaults, and settings |\n| `/import \u003cfile\u003e` | Import chat history from another AI |\n| `/tokens` | Show estimated token count in context |\n| `exit` / `quit` | Save session and exit |\n\n---\n\n## Data Storage\n\nAll user data lives in `~/.ai-chat/`:\n\n```\n~/.ai-chat/\n├── sessions/          # saved conversation JSON files\n├── memory.json        # persistent memories\n├── config.json        # personalization settings\n├── prompt_history     # readline ↑/↓ history\n├── google-credentials.json   # Google OAuth2 client (user-provided)\n└── google-tokens.json        # Google OAuth2 tokens (auto-generated)\n```\n\n---\n\n## Adding Models \u0026 Providers\n\n- **Add a model:** append to the `models` array for the relevant provider in `lib/providers.js`\n- **Add a provider:** create a new class (or reuse `OpenAICompatibleProvider`) in `lib/providers.js` and detect its env key in `chat.js`\n\n---\n\n## License\n\nMIT — see [LICENSE](LICENSE) for details.\n\n## Contact\n\nQuestions or feedback: [motta@g.ucla.edu](mailto:motta@g.ucla.edu) or [open an issue](https://github.com/fredm23579/openai-chat-commandline/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredm23579%2Fopenai-chat-commandline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredm23579%2Fopenai-chat-commandline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredm23579%2Fopenai-chat-commandline/lists"}