Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
20.91k stars 1.93k forks source link

REQ: Pre- and Post- prompt hooks to enable extended local scripting #2045

Open 5ocworkshop opened 1 week ago

5ocworkshop commented 1 week ago

Issue

I was thinking it might be nice to have the ability to have pre- and post- prompt script hooks built in to aider so that if a user wanted to they could trigger the script to run before the prompt is submitted and again after the prompt returns.

Such an extension would allow a user to programmatically handle data interactions with external code to extend aider in personalized directions without having to get under the hood.

Version and model info

Aider v0.59.1 Main model: claude-3-5-sonnet-20240620 with diff edit format, prompt cache, infinite output Weak model: claude-3-haiku-20240307 Git repo: .git with 10 files

paul-gauthier commented 4 days ago

Thanks for trying aider and filing this issue.

Can you explain some use cases for this?

5ocworkshop commented 4 days ago

Sure. The ability to write and read long term status information, for example for a multi-cycle debugging cycle using aider.

Imagine you run the first cycle, investigate, analyze and take some acctions. You want to keep your notes and details about what questions you've already been able to answer and what resolutions you've tried. You can pass that info off to an outside program that can manage it when you get your prompt response and you can recall that information from it before you submit your next prompt, to track counters and so forth.

Also, in the case of debugging, I want to keep a cycle counter so that if we've tried say 5 attempts and it isn't working, we use a different prompt or approach so we don't grind in a debugging loop that isn't yielding anything.

With pre- submission scripts and post (response) scripts, there is flexibility. In this way you can write code that extends capabilities, stores data, providing persistence and flexibility in ways that aren't really possible right now. Persistence is especially useful because it means you can clear the tokens to avoid token buildup (especially pernicious during debugging as you amp up verbosity) without losing track of what attack vectors have been exhausted already etc.

5ocworkshop commented 4 days ago

The other case that I am particularly interested in is on the pre-hook side.

I have a number of prompts I've been developing and refining that are somewhat situational but also a bit large at times. Coding conventions, detail debugging routines and so forth. I don't necessarily want them loaded in the chat all the time, as often they are idle and just waste tokens, but it's easy also to forget to add them sometimes.

A pre-hook script could ask whether or not you want to add files like this before submitting, to allow you to easily pick and choose from a short list or even just tag them with a spacebar, and pass the results back to aider to act before it submits the prompt.

Likewise, on the response/post end, a script could identify various things in the output and take actions based on those, like updating status files or even running other tasks based on the information in the response.

paul-gauthier commented 2 days ago

This sounds fairly out of scope, although I admit I am not fully following your use case or goals here.