Skip to content

feat: add scrollback buffer to llm contextΒ #534

@Realiserad

Description

@Realiserad

πŸ’‘ Summary

Add terminal scrollback buffer to the LLM user prompt and consider removing the inclusion of file contents.

πŸ—¨ Details

In Ghostty, there is no API, so I used built-in function to extract the scrollback into a file, put the path of the scrollback file into the prompt and then call a fish function which takes that path and replaces it with the content.

Ghostty setup: https://codeberg.org/00sapo/dotfiles/src/commit/d03eebe10939702b71034edda597f56124a41754/home/dot_config/ghostty/config#L35-L36
Fish function: https://codeberg.org/00sapo/dotfiles/src/branch/main/home/dot_config/private_fish/functions/fish_ai_with_scrollback.fish

I don't think this is an elegant solution, honestly.

In wezterm, there are usable API that I had integrated into a plugin. We could do something similar. Reference: https://github.com/Michal1993r/ai-helper.wezterm/blob/68ce596a822761eb796d40646bb8d02f94f7155e/plugin/init.lua#L168-L176

Another option is to start script when fish-ai is started, so we can always access the "scrollback" and send the last N lines to the AI. This solution would be more general, but would probably impact the performance of the user's shell [1].

πŸ“š References

[1] #531 (comment)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions