9 ms·
Show HN: Magic-cli – A copilot for your command line
Blog post: https://guywaldman.com/posts/introducing-magic-cli https://guywaldman.com/posts/introducing-magic-cli
- deleted 2y ago[deleted]
- darby_nine 2y agoHow's the latency?
- Carrok 2y agoThat would depend on the LLM provider you select.
- deckar01 2y agoIt isn’t streaming the ollama output so it feels slow (~3 words/second on a 3090 with the defaults). Using ollama directly streams within a second and you can kill it early. I don’t understand the UX of looping responses to the same question either. This does not feel like magic.
- guywald 2y agoIt's currently set not to stream (https://github.com/guywaldman/magic-cli/blob/4d4dca034063aa6433ebaadcbdb7cc192f55c05c/src/llm/ollama/ollama_llm.rs#L55C13-L55C19 https://github.com/guywaldman/magic-cli/blob/4d4dca034063aa6...). The performance is something I plan to improve.
- largbae 2y ago[flagged]
- deleted 2y ago[deleted]
- dang 2y ago"Don't be snarky." "Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something." https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- Carrok 2y agoDefault mode should probably not be “unsafe-execution” but instead should be “clipboard”. Make people turn on the unsafe mode.
- thelastparadise 2y agoI disagree. It should be unsage execution but with an easy undo like git or zfs.
- Carrok 2y agoI eagerly await your proposal on how to undo arbitrary cli commands.
- IgorPartola 2y agoRun the code backwards!
- verandaguy 2y ago$ man mr MR(1) NAME mr, relink - restore directory entries $ mr -fr / # restore a filesystem root after deleting it (recursively, forced restore)
- _lvbh 2y agoI can’t believe I just learned about this. So many lost files Edit: lies!
- IgorPartola 2y agoWait until you discover sl
- xnzakg 2y agoI wonder how long until <insert favorite llm> picks this up and thinks it's a real command
- h43z 2y agoI've never seen this extra measure "curl --proto '=https' ..."
- ape4 2y agoMe neither - so I looked it up at https://curl.se/docs/manpage.html https://curl.se/docs/manpage.html With the equals it means only allow the named protocols.
- metadat 2y agoWhat would be allowed after SSL? By default, does curl allow redirects to http:// http:// via -L? If so.. that's kinda sketchy from a security perspective. Especially because the flag you've shown is very unwieldy.
- deleted 2y ago[deleted]
- guywald 2y agoYep, this is auto-generated by cargo-dist (https://opensource.axo.dev/cargo-dist/book/ https://opensource.axo.dev/cargo-dist/book/)
- xp84 2y agoI'm not affiliated with it, but I've been using the Warp terminal program for a few months now and suspect that if you're interested in this kind of thing, you might like that too. In short, besides the obvious AI stuff, which works well: - You can edit the command line as though it's in a GUI program (including with mouse, etc) instead of it being inside the terminal where you need to use different keybindings and no mouse. - When in a shell, instead of your window being one long stream of text, each command and each output is a discrete area, so it's easier to, say, select the whole output of a command.
- deleted 2y ago[deleted]
- dayjah 2y agoWarp also has a cool looking cataloging feature where commands can be bundled up and shared with your co-workers. Seems a good solution for sharing those dark arts folks tend to build up over time. Edit: link to feature: https://docs.warp.dev/features/blocks https://docs.warp.dev/features/blocks
- scubbo 2y ago> Seems a good solution for sharing those dark arts folks tend to build up over time This is one of the things I most _dislike_ about it. Don't incentivize hording those useful tools in yet-another-silo, get them out into a shared code package!
- dayjah 2y agoFair! I’d not considered that aspect, but you’re right, serializing these into a git repo would be the correct solution here. I think the integration is important though; I’ve vented plenty of steam at co-workers who don’t look at the COMMANDS.md / README.md / etc in a repo. It being auto imported into their terminal program (with search, autosuggestion, and adjacent documentation) seems a pretty killer offering for teams.
- bongodongobob 2y agoCan I ask why it's so complicated? I made something similar about a year ago and it's less that 150 lines of Python. Gives you an explanation, option to run it with/without sudo, pretty colors, etc. I guess I'm not very familiar with Rust but it just seems like a lot for what it does.
- guywald 2y agoThis is a great question. I added a "Why Rust?" section to the blog post to provide my rationale: https://guywaldman.com/posts/introducing-magic-cli#why-rust https://guywaldman.com/posts/introducing-magic-cli#why-rust
- secretlyadog 2y ago[flagged]
- Lienetic 2y agoI assume you didn't mean to share a localhost link :)
- thelastparadise 2y agoWould be a great way to tell someone to "fuck off" lol.
- ekidd 2y agoHere is a corrected link: https://guywaldman.com/posts/introducing-magic-cli#why-rust https://guywaldman.com/posts/introducing-magic-cli#why-rust
- guywald 2y agoWoops, fixed the original reply. Thanks. I guess I'm excited that I got all this traction from HN ;)
- thelastparadise 2y agoUh buddy you linked to localhost:3000.
- renewiltord 2y agoAll of these solutions seemed very heavyweight in my usage. I wanted something that fit within my existing flow and using copilot.vim, EDITOR=nvim, C-x C-e was the solution for me. https://news.ycombinator.com/item?id=40911564 https://news.ycombinator.com/item?id=40911564 It's very composable and I can do incremental work with it.
- deleted 2y ago[deleted]
- beacon294 2y agoYou can also use esc-v to get to the editor if you switch your input to vim mode with "set -o vi" in your .bashrc file. Or for extra points ^[v which will serve as a handier escape, as well.
- renewiltord 2y agoDespite being vimian I've found set -o vi hard to work with. Do you like it? Neovim terminal seems better for me since output is selectable in the buffer.
- beacon294 2y agoIt's a muscle you build. If you're using vim then you'll like it better. You have to imagine the ex mode buffer.
- rekttrader 2y agoWe as a computing populace are getting more and more comfortable with footguns.
- Buttons840 2y agoYou imply this is a footgun. How so? How is this different than looking up a random webpage with the same information?
- dijit 2y agoI mean... This: curl google.com/?search=remove+directory+linux&feeling_lucky=1 | html_strip | head -n 1 | bash Is pretty dangerous, all things being equal, much more dangerous than copying and pasting and of course everything is more dangerous if you avoid engaging your brain entirely.
- Buttons840 2y agoIt appears from the screenshots that this tool shows you the command it will run, with some explanation of what it does, and the command options used, and then confirms you want to run the command. That is very different than the curl command you suggested is equivalent.
- imp0cat 2y agosuggest.mode: The mode to use for suggesting commands. Supported values: "clipboard" (copying command to clipboard), "unsafe-execution" (executing in the current shell session) (default: "unsafe-execution") So default mode seems to be shoot first, ask questions later.
- deleted 2y ago[deleted]
- Closi 2y agoMost people are pretty comfortable copying and pasting arbitrary commands they find on google and don't understand into the terminal, so I'm not convinced this is any worse.
- Aperocky 2y ago[flagged]
- deleted 2y ago[deleted]
- tiberriver256 2y agoI'll bet this was a lot of fun to make. Very cool project. Was there any particular motive for building your own over using something that's been around a bit longer like aichat? https://github.com/sigoden/aichat https://github.com/sigoden/aichat
- deleted 2y ago[deleted]
- guywald 2y agoWoah, the shell features are super similar. Honestly was not familiar with this project, looks great (and ambitious). I'll try it out. Thanks for the share.
- jimmySixDOF 2y agoAnother approach converts into python: An CLI assistant that responds by generating and auto-executing a Python script. https://github.com/AbanteAI/rawdog https://github.com/AbanteAI/rawdog
- Lord_Zero 2y agoAichat is super polished and I use it all the time. I don't see why I would use anything else at this time.
- icholy 2y agoI use https://github.com/simonw/llm-cmd https://github.com/simonw/llm-cmd
- deleted 2y ago[deleted]
- guywald 2y agoAwesome share! Thank you. There are definitely similarities, and I love Simon's work. I guess the extra features are some sophisticated UX (requesting the user to fill out "placeholders" in the response, ability to revise the prompt), the "ask" command and the "search" command. Will definitely give this a spin.
- fragmede 2y agohttps://github.com/KillianLucas/open-interpreter/ https://github.com/KillianLucas/open-interpreter/ is my preferred implementation of approximately the same thing
- deleted 2y ago[deleted]
- notarealllama 2y agoHuh, and I'm here running llama 3 locally (and claude.ai for less complex stuff), asking well formatted and specific questions and still adjusting the output before implementing it. Besides I need .sh scripts not just cli completion. But this reminds me of warp. Gonna have to give it a spin in the morning.
- voodooEntity 2y agoFunny, i recently build something really similar ^^ https://github.com/voodooEntity/go-clibuddy https://github.com/voodooEntity/go-clibuddy
- deleted 2y ago[deleted]
- pmarreck 2y agoI have a single Bash function called "please" that basically does the same thing https://github.com/pmarreck/dotfiles/blob/master/bin/functions/please.bash https://github.com/pmarreck/dotfiles/blob/master/bin/functio...
- guywald 2y agoNice! I like the `needs` utility :)
- prmoustache 2y agoBut then you need to find another alias for sudo!
- gkfasdfasdf 2y agoWhat does this line do? [ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return Very cool script overall, thanks for sharing
- pmarreck 2y agoAh, forgot to include that! That's a way to edit any of my functions via "edit <functionname>" and it drops you right on the correct line in your $EDITOR of choice. Otherwise it defaults to passing it into your editor (ostensibly a path). needs() { [ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return; local bin="$1"; shift; command -v "$bin" > /dev/null 2>&1 || { printf "%s is required but it's not installed or in PATH; %s\n" "$bin" "$*" 1>&2; return 1 } } contains() { [ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return; local word; for word in $1; do if [[ "$word" == "$2" ]]; then return 0; fi; done; return 1 } edit_function() { [ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return; needs rg "please install ripgrep!"; local function_name="$1"; local function_name="${function_name//\?/\\?}"; local file="$2"; local fl=$(rg -n -e "${function_name} *\(\) *\{" -e "function +${function_name}(?: *\(\))? *\{" "$file" | tail -n1 | cut -d: -f1); $EDITOR "$file":$fl } edit() { [ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return; if contains "$(functions)" $1; then EDIT=1 $1; else $EDITOR "$@"; fi } Once you have those set in your environment, and EDITOR points to whatever editor you prefer, you can simply add the following line to the top of any bash function you define and make it editable-in-place basically: [ -v EDIT ] && unset EDIT && edit_function "${FUNCNAME[0]}" "$BASH_SOURCE" && return; I use the [ -v variablename ] pattern to detect whether it's set or not so that things like EDIT=1 and EDIT=true will work the same way, but I've also seen ((EDIT)) used, which for values of 1 gives a return code of 0 (making that expression true) otherwise returns a fail, but that only works if you use 1 or 0 to designate "true" and "false" for switches... and it's of course confusing that you need to reverse those in Bash logic which works off return codes and not actual values
- computatrum 2y agoThere is also https://github.com/TNG/please-cli https://github.com/TNG/please-cli
- lordgrenville 2y ago[flagged]
- deleted 2y ago[deleted]
- gembelhitam 2y ago[flagged]
- teddyh 2y agoBeware the pitfalls of yesteryear: <http://www.catb.org/~esr/jargon/html/D/DWIM.html http://www.catb.org/~esr/jargon/html/D/DWIM.html>
- compressedgas 2y agohttps://en.wikipedia.org/wiki/Warren_Teitelman https://en.wikipedia.org/wiki/Warren_Teitelman
- _def 2y agoFunny to see this, I first came across it with https://github.com/nvbn/thefuck https://github.com/nvbn/thefuck
- boomskats 2y agoThis is nice. I've been taking Termium[0] for a spin and it's been pretty great for the most part, but the Rumsfeld-complete always-on autosuggest/copilot UX they're aiming for does feel like a bit of a compromise. On occasions when I do know what I don't know, and want to specifically opt in, this looks perfect. [0]: https://codeium.com/blog/termium-codeium-in-terminal-launch https://codeium.com/blog/termium-codeium-in-terminal-launch
- Xen9 2y agoThe general concept is limited "command line" as means of giving a single agent agency without the need to program every integration separatively. The AGI version is "command line" also enabling the agents to communicate, modify, make each other.
- deleted 2y ago[deleted]
- pcwelder 2y agoI've been using https://github.com/tom-doerr/zsh_codex https://github.com/tom-doerr/zsh_codex with gpt4-o and it saves a lot of strokes as compared to github copilot cli to query, since I just have to press ctrl-x in addition to the prompt. Magic-cli also seems to be using same workflow as github copilot, so I'm not rushing to use it.
- ano-ther 2y agoNeat. How does it compare to https://llm.datasette.io/en/stable/ https://llm.datasette.io/en/stable/ ?
- swyx 2y agoit's built in RUST!
- satvikpendem 2y agoThen that's good enough for me to use it :)
- kordlessagain 2y agoI got stuck on setting the ollama.embedding_model. No clue what to do.
- sathishvj 2y agoMy version called "gencmd" also has a web page, supports multiple models, and also has org+groups support. Please try it out - would love your feedback. https://gencmd.com/ https://gencmd.com/
- jmkx 2y ago[dead]
- vhvj 2y ago[dead]