xenodium / chatgpt-shell

ChatGPT and DALL-E Emacs shells + Org babel 🦄 + a shell maker for other providers
https://xenodium.com
GNU General Public License v3.0
804 stars 73 forks source link

[Feature Request] Eshell Extensions #222

Open gopar opened 1 month ago

gopar commented 1 month ago

Hey, thanks again for the package.

I've been playing with the eshell integration (didn't know there was one until recently!) and so far has been good. Which got me wondering if it would be a good idea (perhaps?) to have a eshell/?/ or maybe just eshell/chat to be able to ask chatgpt questions directly in eshell?

And once chatgpt answers, there could be a button (or keybinding) that jumps to the chatgpt buffer to continue the convo with the context still there.

~$ for file in *.py; echo $file; end
error

~$ ?/ how do I loop over all python files in a directory?

<chatgpt response>
---
<button to jump to chatgpt shell to continue conversation>

~$

Not sure how beneficial this might be since I got the idea from Warp Terminal which the kids these days seem to be excited for (honestly the only thing that it has over emacs in general is that it integrates with AI from the beginning, but packages like this are taking car of that 😃)

xenodium commented 1 month ago

Hi Gopar! Thanks for filing.

The eshell ?? command was a little weird to get working with streaming (it delegates to an external Emacs process). There's likely a better way.

While ?? does get streaming, the downside is we don't have an associated chatgpt shell in the current Emacs instance (so no follow-ups).

With the current approach, it'd be straightforward to add one-off streamed chat command (but no follow-up capability) or a chat command that automatically bumps you over to a chatgpt shell. There may be other options. Maybe need to think more.

Btw, have you used the "compose interface" some more (via chatgpt-shell-prompt-compose)? I have a global binding, making querying available from anywhere. I wonder if that can be extended further to draw context from eshell. Compose buffers are backed by chatgpt shells (so you can have follow-ups).

gopar commented 1 month ago

Btw, have you used the "compose interface" some more (via chatgpt-shell-prompt-compose)?

Honestly, I keep forgetting this feature exists, I even have it bind to an easy key. I default to simply calling a chat shell.


Hmm feel free to disregard this, but wouldn't it be possible to make chatgpt-shell-prompt-compose to be "context" aware in eshell? eg, if someone calls the compose command in eshell, it can look at the last output and automatically insert it into the buffer?

No need to take action on this, after thinking a bit more, even I'm not certain how useful having AI integration in eshell would be when "compose" and the general "chat shell" are a keybind away. Perhaps I got carried away after seeing a new shiny terminal doing something

xenodium commented 1 month ago

wouldn't it be possible to make chatgpt-shell-prompt-compose to be "context" aware in eshell?

Yup yup. This is what I meant by I wonder if that can be extended further to draw context from eshell.

No need to take action on this, after thinking a bit more, even I'm not certain how useful having AI integration in eshell would be when "compose" and the general "chat shell" are a keybind away.

These days, my usage is primarily via compose, with the ocasional peek at the shell/history. In a similar fashion to "context aware", if you invoke compose with point on a flymake issue, the compose buffer is automatically populated with the error and additional buffer context.

I'll have a look at adding eshell context to compose buffer.

xenodium commented 1 month ago

I've pushed https://github.com/xenodium/chatgpt-shell/commit/4263fb2897903bac0e136fa96be53c1eab599d63 so last eshell command is automatically added to the compose buffer. Active region takes precedence over last command.

See how well that works for ya. I'm thinking we may want to make it a tiny bit smarter so it includes the command/output at point if point is not at the end of buffer.

gopar commented 1 month ago

I've pushed https://github.com/xenodium/chatgpt-shell/commit/4263fb2897903bac0e136fa96be53c1eab599d63 so last eshell command is automatically added to the compose buffer. Active region takes precedence over last command.

Nice! I'm playing around with it. Seems to be working fine! :)

I'm thinking we may want to make it a tiny bit smarter so it includes the command/output at point if point is not at the end of buffer.

I like that idea!