{"id":13408085,"url":"https://github.com/clevercli/clevercli","last_synced_at":"2025-03-14T12:32:05.880Z","repository":{"id":127679027,"uuid":"611005467","full_name":"clevercli/clevercli","owner":"clevercli","description":"ChatGPT powered CLI utilities. Easily add new prompt types in ~/.clevercli/","archived":false,"fork":false,"pushed_at":"2023-03-26T17:16:56.000Z","size":599,"stargazers_count":117,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-31T20:28:56.988Z","etag":null,"topics":["chatgpt","cli","gpt","gpt-3","openai"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/clevercli.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}},"created_at":"2023-03-07T23:04:25.000Z","updated_at":"2024-07-31T00:17:00.000Z","dependencies_parsed_at":"2024-01-03T04:14:11.035Z","dependency_job_id":"a3e420c6-19e0-4448-9a75-3a1f04ba31b7","html_url":"https://github.com/clevercli/clevercli","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clevercli%2Fclevercli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clevercli%2Fclevercli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clevercli%2Fclevercli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clevercli%2Fclevercli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clevercli","download_url":"https://codeload.github.com/clevercli/clevercli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243578487,"owners_count":20313836,"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":["chatgpt","cli","gpt","gpt-3","openai"],"created_at":"2024-07-30T20:00:50.668Z","updated_at":"2025-03-14T12:32:04.096Z","avatar_url":"https://github.com/clevercli.png","language":"TypeScript","funding_links":[],"categories":["\u003ca name=\"ai\"\u003e\u003c/a\u003eAI / ChatGPT","Utilities","TypeScript","CLI tools","cli"],"sub_categories":["Calendars","Examples"],"readme":"# clevercli\n\n**clevercli** is a CLI that queries OpenAI models (e.g. ChatGPT). New prompt types can easily be added and there is a growing list of community maintained prompts.\n\nSome examples:\n\n```console\n$ $(clevercli unix-command \"undo the last commit\")\n$ clevercli unix-command \"add a collaborator to a npm package\"\n$ clevercli eli5 \"why is the sky blue?\"\n$ man du | clevercli summarize\n$ clevercli convert-to-rust \u003c index.ts \u003e main.rs\n$ clevercli ask \"in node.js, how to check if stdin is open?\"\n```\n\n## Install\n\n```console\n$ npm install -g @clevercli/cli\n```\n\nRequires Node v16+.\n\n## Usage\n\n```console\n$ clevercli \u003cprompt_type\u003e \u003cprompt_input\u003e\n```\n\nOr using `stdin`:\n\n```console\n$ echo \"\u003cprompt_input\u003e\" | clevercli \u003cprompt_type\u003e\n```\n\nList available prompt types:\n\n```\n$ clevercli --list\n```\n\nRequires an [OpenAI API key](https://platform.openai.com/account/api-keys). Add `export OPENAI_API_KEY=\"\u003cyour OpenAI api key\u003e\"` to your shell script (e.g. `~/.bashrc`).\n\n## Examples\n\n```console\n$ clevercli joke \"banana\"\nWhy did the banana go to the doctor? Because it wasn't peeling well!\n$ echo \"what is stdin?\" | clevercli eli5\n...\n$ man du | clevercli summarize\n...\n$ clevercli convert-to-rust \u003c index.ts \u003e main.rs\n```\n\nTip: since many answers use markdown, you can pipe to [glow](https://github.com/charmbracelet/glow) to get a nicer rendering:\n\n```console\n$ clevercli ask \"in node.js, how to check if stdin is open?\" | glow\n```\n\n![glow-example](./images/glow-example.png)\n\n## Built-in prompts\n\n- [ask](./src/prompts/ask.ts) Just passes through the input directly to ChatGPT.\n\nExample: `clevercli ask \"in node.js, how to check if stdin is open?\"`\n\n- [eli5](./src/prompts/eli5.ts): Explain Me Like I'm 5.\n\nExample: `clevercli eli5 \"why is the sky blue?\"`\n\n- [joke](./src/prompts/joke.ts): Tells a joke about the topic.\n\nExample: `clevercli joke \"git being difficult to learn\"`\n\n- [refactor](./src/prompts/refactor.ts): Asks ChatGPT to refactor code in a file.\n\nExample: `clevercli refactor \u003c index.ts`\n\n- [poem](./src/prompts/poem.ts): Asks ChatGPT to write a small poem on the topic.\n\nExample: `clevercli poem \"hacker news\"`\n\n- [recipe](./src/prompts/recipe.ts): Outputs recipe suggestions given a list of available ingredients.\n\nExample: `clevercli recipe \"ham, cheese, bread\"`\n\n- [summarize](./src/prompts/summarize.ts) Outputs a short summary of the text.\n\nExample: `clevercli summarize \u003c README.md`\n\n- [synonyms](./src/prompts/synonyms.ts): List synonyms for the input words.\n\nExample: `clevercli synonyms \"cat\"`\n\n- [convert-to-rust](./src/prompts/convert-to-rust.ts): Converts file to Rust\n\nExample: `clevercli convert-to-rust \u003c index.ts \u003e main.rs`\n\n- [convert-to-typescript](./src/prompts/convert-to-typescript.ts): Converts file to TypeScript\n\nExample: `clevercli convert-to-typescript \u003c index.js \u003e main.ts`\n\n- [unix-command](./src/prompts/unix-command.ts): Outputs a UNIX command based on the input description.\n\nExample: `bash -c $(clevercli unix-command \"list all .md files\")`\n\n- [regex](./src/prompts/regex.ts): Outputs a JavaScript-compatible RegEx that matches the input examples.\n\nExample `clevercli regex \"http://google.com https://news.ycombinator.com/some/path\"`\n\n- [jsdoc](./src/prompts/jsdoc.ts): Adds JSDoc comments to exported functions.\n\nExample `clevercli jsdoc \u003c index.js`\n\nSee [./src/prompts/](./src/prompts) for the list of available prompts.\n\nSee [Adding a built-in prompt](#adding-a-built-in-prompt) for adding an official prompt.\n\n## Adding a prompt\n\nCreate a file `~/.clevercli/\u003cprompt name\u003e.mjs` which returns an object that follows the `PromptConfiguration` interface.\n\n```typescript\nexport interface PromptConfiguration {\n  createPrompt(input: string): string;\n  model?: string;\n  description?: string;\n}\n```\n\nFor example:\n\n```javascript\n// eli5.mjs\nexport default {\n  createPrompt(input) {\n    return `Provide a very detailed explanation but like I am 5 years old (ELI5) on this topic: ${input}.\\n###\\n`;\n  },\n};\n```\n\n## Adding a built-in prompt\n\n1. Fork the repository.\n\n2. Create a new prompt configuration in [./src/prompts/](./src/prompts/). You can use the [eli5](./src/prompts/eli5.ts) prompt configuration as a base.\n\n3. Send a pull request!\n\nHere's a sample prompt configuration:\n\n```typescript\nimport { ParsedResponse, PromptConfiguration } from \"../types.js\";\n\nconst promptConfiguration: PromptConfiguration = {\n  createPrompt(input: string) {\n    return `Provide a very detailed explanation but like I am 5 years old (ELI5) on this topic: ${input}.\\n###\\n`;\n  },\n  parseResponse(response: string): ParsedResponse {\n    return { message: response };\n  },\n};\n\nexport default promptConfiguration;\n```\n\n## Cache\n\nQuery results are cached on your filesystem's cache directory.\n\n## Debugging\n\n```\nDEBUG=\"clevercli:*\" clevercli eli5 \"friendship\"\n```\n\n## TODO\n\n- [x] Streaming API.\n- [ ] Proper CLI arg parsing and options\n- [ ] GH workflow + tests\n- [ ] Support older Node.js versions?\n- [ ] Interactively prompt OpenAI API key and save to filesystem (when OPENAPI_KEY is not set)\n- [ ] Distributed cache (not just local)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclevercli%2Fclevercli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclevercli%2Fclevercli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclevercli%2Fclevercli/lists"}