clipea-cli


Nameclipea-cli JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/dave1010/clipea/
Summary๐Ÿ“Ž๐ŸŸข Like Clippy but for the CLI. A blazing fast AI helper for your command line
upload_time2023-11-29 20:33:53
maintainer
docs_urlNone
authorDave Hulbert
requires_python>=3.10
licenseMIT
keywords cli ai assistant automation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Clipea ๐Ÿ“Ž๐ŸŸข

[![Install with Homebrew](https://img.shields.io/badge/Homebrew-Tap-blue.svg)](https://github.com/dave1010/homebrew-clipea)

**Like Clippy but for the CLI. A blazing fast AI helper for your command line.**

Clipea is a streamlined, cheap and hackable tool that integrates GPT with your console.
It's like Github's [Copilot for CLI](https://githubnext.com/projects/copilot-cli) but it's cheaper, faster and doesn't get in your way.

Tell Clipea what you want to do and it'll give you a shell command, asking you if you want to run it. Clipea works even better with Zsh, as it adds the shell command to your console as a pending command, just as if you had typed it yourself!

![clipea-gif](https://github.com/dave1010/clipea/assets/50682/9aae6c64-2d09-4e7f-9d86-4d82dd4bc076)

Clipea was born out of [Hubcap](https://github.com/dave1010/hubcap), an experimental autonomous agent.
Clipea is less dangerous and actually designed to be a usable productivity tool, rather than just a tech demo.

Advantages over copying and pasting from ChatGPT:

* Speed. No need to switch to your browser and back
* Shell integration, like filename completion
* Automatically knows things like your shell and OS

> [!CAUTION]
> AI isn't perfect. Clipea might suggest a dangerous command. Be careful.

## ๐Ÿš€ Quick Start

    brew tap dave1010/clipea
    brew install clipea
    clipea setup
    clipea alias

## ๐Ÿช„ Usage

Once installed, just ask Clipea for a command:

    clipea convert test.mp4 to a gif

Type `y<enter>` to run the command. Anything else or `<ctrl-c>` to cancel.

Or, if you have the Zsh integration (highly recommended), it's even easier:

    ?? how many gig free do i have

Just press `<enter>` to run the command or `<backspace>` if you want to edit it.

Clipea works best when you give it a task to complete, rather than a question: LLMs love explaining things whenever you're not sure.

### โ“โ“ Using the Zsh shell integration (recommended)

The Zsh integration is more than just a quick alias.
It allows Clipea to put the command in your input buffer, ready to run, just as if you'd typed it yourself.

    # setup
    clipea alias

    # usage
    ?? how many gig free do i have

Benefits:

* Quicker to type
* Shows up in your shell history
* Allows editing with normal shell commands like `<ctrl-c>` to cancel or `<ctrl-a>` to go to the start of the line
* Runs the command as a child process of your shell, rather than a child of Clipea

Behind the scenes this is using zsh's [`print -z`](https://gist.github.com/YumaInaura/2a1a915b848728b34eacf4e674ca61eb#print--z).

### ๐Ÿง™ Advanced usage and tips

#### GPT-4 mode

Just start the query with a "4". Remember that OpenAI charge lots more for GPT-4.
Generally the standard GPT-3.5 is fine for commandline stuff.

    ?? 4 create a text file explaining quantum mechanics in a haiku in the style of a pirate

#### Getting data from stdin

You can also send in data via stdin. Clipea limits you to 8192 bytes, so the LLM isn't overwhelmed.

    ls -F | ?? explain this project setup

Most of the time it's best to give Clipea a filename to create a command for, rather than the actual file contents.

    cat package.json | ?? how many packages here     # GPT isn't great at counting
    ?? count how many packages are in package.json   # GPT is good at suggesting commands

#### Environment

Clipea gets given some environment limited information like your OS, shell and path.
This allows it to give better responses.

    ?? wheres my shell config
    ?? install curl
    ?? compare README.md to my clipboard

#### Custom Prompt

You can customize your prompt by creating a prompt file in your home directory.

    ~/.config/clipea/system-prompt.txt

You might wanna start by copying the default prompt:

    cp $(dirname $(readlink -f $(which clipea)))/system-prompt.txt ~/.config/clipea/system-prompt.txt

Then edit `~/.config/clipea/system-prompt.txt` to your liking, but be aware that environment info is always added to the end of the prompt.

### โคด๏ธ Feedback and editing

Just use your shell history by pressing the `<up>` arrow key. Your cursor will be at the end of
the last line, ready to edit it.

For example: typing `?? list js files recursively` may give

    $ find . -name "*.js"

Then to edit, press `<up>` then ` ignore node modules` to get something like

    $ find . -name "*.js" -not -path "./node_modules/*"

Clipea doesn't have any context of what it said before, though this may be added in the future if there's use cases it helps with.

### More examples

#### System Operations

    ?? open my shell login script in my editor
    ?? Extract package.tar.gz
    ?? Install something that converts pdf to text
    ?? Make a 30 char password

#### File Operations

    ?? Find files bigger than 10mb
    ?? Rename all txt files space to underscore
    ?? Convert file.avi to gif
    ?? Decrypt data.txt.gpg

#### Text Files and Coding

    ?? Highlight URLs in index.html
    ?? Show me just the headings from README.md
    ?? count loc recursively
    ?? Find replace all PHP files in project that call eval function with safe_eval
    ?? git fetch, rebase master, safely force push
    ?? turn orders.csv into sqlite
    ?? count payments in orders.db

#### Web and Network Tasks

    ?? open bbc news
    ?? check the spf record for example.com
    ?? What port is my webserver listening on
    ?? Check cors headers for api.example.com
    ?? Where is nginx writing logs
    ?? Quick http server

## ๐Ÿ“ฆ Installation and setup

### Manual installation

Python >=3.10 is required.

You can use the provided `setup.py`. ([setuptools docs](https://setuptools.pypa.io/en/latest/deprecated/easy_install.html))

You can install it quickly like so:

    python3 setup.py sdist
    pip install dist/clipea-{version}.tar.gz

Or development mode:

    pip install -e .

### With PyPi (soon)

    #pip install clipea

### Zsh Shell integration and Alias

> [!TIP]
> The `??` shell alias is highly recommended if you use zsh

    clipea alias

## Internals

Clipea is written in Python (3.10+).

Clipea uses [llm](https://github.com/simonw/llm) to interact with large language models.

By default it will use OpenAI's GPT-3.5 model but can be configured to other models, such as Llama.
Running `clipea setup` will talk you through getting OpenAI keys.

## โ— Warnings

### Safety

> [!CAUTION]
> Always read and check what Clipea suggests before accepting it.

![destroy all humans](https://github.com/dave1010/clipea/assets/50682/afa819bd-a8cc-4968-973f-9b99ceaab5b4)

### Privacy

Clipea uses OpenAI's APIs by default, though can be set to use any LLM that `llm` supports.

Only very basic environment info like your OS and editor is sent to the LLM.
Run `clipea env` to see the data the LLM gets.

### Cost

As a very rough example, using the default GPT-3.5, 100 Clipea queries to OpenAI cost $0.02.
Set a quota and keep an eye on costs to make sure.

## Acknowledgements

Big thanks to @edouard-sn for the port to Python.

## Contributing

Contributions welcome.

## License

MIT License

Copyright (c) 2023 Dave Hulbert

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dave1010/clipea/",
    "name": "clipea-cli",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "cli,ai,assistant,automation",
    "author": "Dave Hulbert",
    "author_email": "dave1010@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9f/3b/81db9f7842a950d9f4d8ea4de69b46ecc465fa602f933a549d19aa140ac6/clipea-cli-0.1.0.tar.gz",
    "platform": null,
    "description": "# Clipea \ud83d\udcce\ud83d\udfe2\n\n[![Install with Homebrew](https://img.shields.io/badge/Homebrew-Tap-blue.svg)](https://github.com/dave1010/homebrew-clipea)\n\n**Like Clippy but for the CLI. A blazing fast AI helper for your command line.**\n\nClipea is a streamlined, cheap and hackable tool that integrates GPT with your console.\nIt's like Github's [Copilot for CLI](https://githubnext.com/projects/copilot-cli) but it's cheaper, faster and doesn't get in your way.\n\nTell Clipea what you want to do and it'll give you a shell command, asking you if you want to run it. Clipea works even better with Zsh, as it adds the shell command to your console as a pending command, just as if you had typed it yourself!\n\n![clipea-gif](https://github.com/dave1010/clipea/assets/50682/9aae6c64-2d09-4e7f-9d86-4d82dd4bc076)\n\nClipea was born out of [Hubcap](https://github.com/dave1010/hubcap), an experimental autonomous agent.\nClipea is less dangerous and actually designed to be a usable productivity tool, rather than just a tech demo.\n\nAdvantages over copying and pasting from ChatGPT:\n\n* Speed. No need to switch to your browser and back\n* Shell integration, like filename completion\n* Automatically knows things like your shell and OS\n\n> [!CAUTION]\n> AI isn't perfect. Clipea might suggest a dangerous command. Be careful.\n\n## \ud83d\ude80 Quick Start\n\n    brew tap dave1010/clipea\n    brew install clipea\n    clipea setup\n    clipea alias\n\n## \ud83e\ude84 Usage\n\nOnce installed, just ask Clipea for a command:\n\n    clipea convert test.mp4 to a gif\n\nType `y<enter>` to run the command. Anything else or `<ctrl-c>` to cancel.\n\nOr, if you have the Zsh integration (highly recommended), it's even easier:\n\n    ?? how many gig free do i have\n\nJust press `<enter>` to run the command or `<backspace>` if you want to edit it.\n\nClipea works best when you give it a task to complete, rather than a question: LLMs love explaining things whenever you're not sure.\n\n### \u2753\u2753 Using the Zsh shell integration (recommended)\n\nThe Zsh integration is more than just a quick alias.\nIt allows Clipea to put the command in your input buffer, ready to run, just as if you'd typed it yourself.\n\n    # setup\n    clipea alias\n\n    # usage\n    ?? how many gig free do i have\n\nBenefits:\n\n* Quicker to type\n* Shows up in your shell history\n* Allows editing with normal shell commands like `<ctrl-c>` to cancel or `<ctrl-a>` to go to the start of the line\n* Runs the command as a child process of your shell, rather than a child of Clipea\n\nBehind the scenes this is using zsh's [`print -z`](https://gist.github.com/YumaInaura/2a1a915b848728b34eacf4e674ca61eb#print--z).\n\n### \ud83e\uddd9 Advanced usage and tips\n\n#### GPT-4 mode\n\nJust start the query with a \"4\". Remember that OpenAI charge lots more for GPT-4.\nGenerally the standard GPT-3.5 is fine for commandline stuff.\n\n    ?? 4 create a text file explaining quantum mechanics in a haiku in the style of a pirate\n\n#### Getting data from stdin\n\nYou can also send in data via stdin. Clipea limits you to 8192 bytes, so the LLM isn't overwhelmed.\n\n    ls -F | ?? explain this project setup\n\nMost of the time it's best to give Clipea a filename to create a command for, rather than the actual file contents.\n\n    cat package.json | ?? how many packages here     # GPT isn't great at counting\n    ?? count how many packages are in package.json   # GPT is good at suggesting commands\n\n#### Environment\n\nClipea gets given some environment limited information like your OS, shell and path.\nThis allows it to give better responses.\n\n    ?? wheres my shell config\n    ?? install curl\n    ?? compare README.md to my clipboard\n\n#### Custom Prompt\n\nYou can customize your prompt by creating a prompt file in your home directory.\n\n    ~/.config/clipea/system-prompt.txt\n\nYou might wanna start by copying the default prompt:\n\n    cp $(dirname $(readlink -f $(which clipea)))/system-prompt.txt ~/.config/clipea/system-prompt.txt\n\nThen edit `~/.config/clipea/system-prompt.txt` to your liking, but be aware that environment info is always added to the end of the prompt.\n\n### \u2934\ufe0f Feedback and editing\n\nJust use your shell history by pressing the `<up>` arrow key. Your cursor will be at the end of\nthe last line, ready to edit it.\n\nFor example: typing `?? list js files recursively` may give\n\n    $ find . -name \"*.js\"\n\nThen to edit, press `<up>` then ` ignore node modules` to get something like\n\n    $ find . -name \"*.js\" -not -path \"./node_modules/*\"\n\nClipea doesn't have any context of what it said before, though this may be added in the future if there's use cases it helps with.\n\n### More examples\n\n#### System Operations\n\n    ?? open my shell login script in my editor\n    ?? Extract package.tar.gz\n    ?? Install something that converts pdf to text\n    ?? Make a 30 char password\n\n#### File Operations\n\n    ?? Find files bigger than 10mb\n    ?? Rename all txt files space to underscore\n    ?? Convert file.avi to gif\n    ?? Decrypt data.txt.gpg\n\n#### Text Files and Coding\n\n    ?? Highlight URLs in index.html\n    ?? Show me just the headings from README.md\n    ?? count loc recursively\n    ?? Find replace all PHP files in project that call eval function with safe_eval\n    ?? git fetch, rebase master, safely force push\n    ?? turn orders.csv into sqlite\n    ?? count payments in orders.db\n\n#### Web and Network Tasks\n\n    ?? open bbc news\n    ?? check the spf record for example.com\n    ?? What port is my webserver listening on\n    ?? Check cors headers for api.example.com\n    ?? Where is nginx writing logs\n    ?? Quick http server\n\n## \ud83d\udce6 Installation and setup\n\n### Manual installation\n\nPython >=3.10 is required.\n\nYou can use the provided `setup.py`. ([setuptools docs](https://setuptools.pypa.io/en/latest/deprecated/easy_install.html))\n\nYou can install it quickly like so:\n\n    python3 setup.py sdist\n    pip install dist/clipea-{version}.tar.gz\n\nOr development mode:\n\n    pip install -e .\n\n### With PyPi (soon)\n\n    #pip install clipea\n\n### Zsh Shell integration and Alias\n\n> [!TIP]\n> The `??` shell alias is highly recommended if you use zsh\n\n    clipea alias\n\n## Internals\n\nClipea is written in Python (3.10+).\n\nClipea uses [llm](https://github.com/simonw/llm) to interact with large language models.\n\nBy default it will use OpenAI's GPT-3.5 model but can be configured to other models, such as Llama.\nRunning `clipea setup` will talk you through getting OpenAI keys.\n\n## \u2757 Warnings\n\n### Safety\n\n> [!CAUTION]\n> Always read and check what Clipea suggests before accepting it.\n\n![destroy all humans](https://github.com/dave1010/clipea/assets/50682/afa819bd-a8cc-4968-973f-9b99ceaab5b4)\n\n### Privacy\n\nClipea uses OpenAI's APIs by default, though can be set to use any LLM that `llm` supports.\n\nOnly very basic environment info like your OS and editor is sent to the LLM.\nRun `clipea env` to see the data the LLM gets.\n\n### Cost\n\nAs a very rough example, using the default GPT-3.5, 100 Clipea queries to OpenAI cost $0.02.\nSet a quota and keep an eye on costs to make sure.\n\n## Acknowledgements\n\nBig thanks to @edouard-sn for the port to Python.\n\n## Contributing\n\nContributions welcome.\n\n## License\n\nMIT License\n\nCopyright (c) 2023 Dave Hulbert\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\ud83d\udcce\ud83d\udfe2 Like Clippy but for the CLI. A blazing fast AI helper for your command line",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/dave1010/clipea/"
    },
    "split_keywords": [
        "cli",
        "ai",
        "assistant",
        "automation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f3b81db9f7842a950d9f4d8ea4de69b46ecc465fa602f933a549d19aa140ac6",
                "md5": "d29dcc9fe36e587d54a813a5b82114a8",
                "sha256": "d2316993f0c77bc8e1d0fe8e0e0145ad03cd4a836bdffd7ae98239f22298a4ad"
            },
            "downloads": -1,
            "filename": "clipea-cli-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d29dcc9fe36e587d54a813a5b82114a8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 13234,
            "upload_time": "2023-11-29T20:33:53",
            "upload_time_iso_8601": "2023-11-29T20:33:53.785126Z",
            "url": "https://files.pythonhosted.org/packages/9f/3b/81db9f7842a950d9f4d8ea4de69b46ecc465fa602f933a549d19aa140ac6/clipea-cli-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-29 20:33:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dave1010",
    "github_project": "clipea",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "clipea-cli"
}
        
Elapsed time: 0.15338s