npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

shell-ask

v0.0.39

Published

Ask LLM any question in your terminal

Downloads

108

Readme

shell-ask

preview


Shell Ask is sponsored by ChatKit, a free chat app for ChatGPT and many other models.

Install

This requires Node.js to be installed.

npm i -g shell-ask

Supported LLMs

Configuration

Minimal config to use OpenAI, create a ~/.config/shell-ask/config.json with the following content:

{
  "openai_api_key": "sk-your-key-xxx"
}

Check out config documentation for more.

Usage

Ask a question:

# Ask a question
ask "get git logs first line only"

# Make sure it outputs a command only with -c or --command flag
ask "get git logs first line only" -c

Using command output as context:

cat package.json | ask "please fix exports"

Interactively select a model:

# show all models
ask quest -m
# show all gpt models
ask quest -m gpt
# show all claude models
ask quest -m claude
# show all ollama models
ask quest -m ollama
# show all groq models
ask quest -m groq

Select a model by id:

ask "question" -m gpt-4o
ask "question" -m claude-3-opus

Prompt without quotes:

# Same prompt
ask "how to delete a docker image"
ask how to delete a docker image

# Escape using backslash if you need quotes inside the prompt
ask who\'s john titor

Piping

You can pipe the output of other programs to ask, for example you can use cat to add file contents to the LLM context:

cat main.ts | ask "explain the code"

If you want to add multiple files, especially when you also want to include filenames in the context, you can use --files flag to add files into model context:

ask --files "src/*.ts " "write a concise outline for this project"

Ask Follow-up Questions

Using -r or --reply flag to ask follow-up questions to the previous answer:

ask "how to delete a docker image"

ask -r "delete last 30 days"

Result Type

Command

Using -c or --command flag to enforce the output to be a command only:

ask "turn foo.mp4 to 720p using ffmpeg" -c

Using -b or --breakdown flag to return a command and the breakdown of the command:

ask "turn foo.mp4 to 720p using ffmpeg" -b

Custom Type

Define the type of the result using -t or --type flag:

cat package.json | ask "extract dependency names" -t "string[]"

cat README.md | ask "extract headings" -t "{depth:number,title:string}[]"

Copilot Chat

First you need to login to Copilot Chat:

ask copilot-login

Then you can ask questions:

ask "how to delete a docker image" -m copilot

# or a specific model
ask "how to delete a docker image" -m copilot-claude-3.5-sonnet

To log out, run ask copilot-logout.

Web Search

Enable web search by using -s or --search flag:

ask -s "how to delete a docker image"

Web search is powered by https://s.jina.ai

Fetching Web Pages

For a single page, you can just use curl:

curl -s https://example.com | ask "summarize it"

For multiple pages, you can use -u or --url flag:

ask -u https://example.com/about -u https://example.com/introduction "summarize it"

You may only need the markdown output of the web page, you can use https://r.jina.ai to retrive markdown content instead:

ask -u https://r.jina.ai/example.com "summarize it"

Disable Streaming Output

Using --no-stream flag to disable streaming output:

ask "how to delete a docker image" --no-stream

When --no-stream is enabled the output markdown will have proper syntax highlighting, when streaming is enabled the output will be plain text because the terminal have trouble clearing the screen when the output is too long

Reusable AI Commands

Shell Ask allows you to define reusable AI commands in the config file, for example the builtin ask cm command:

{
  "commands": [
    {
      "command": "cm",
      "description": "Generate git commit message based on git diff output",
      "prompt": "Generate git commit message following Conventional Commits specification based on the git diff output in stdin\nYou must return a commit message only, without any other text or quotes."
    }
  ]
}

Built-in AI Commands

  • ask cm: Generate git commit message from stdin
    • example: git diff | ask cm

License

MIT.