callstack / ai-cli

AI assistant in your terminal.
https://callstack.github.io/ai-cli/
MIT License
21 stars 0 forks source link

feat: add syntax highlighting #10

Closed okwasniewski closed 1 month ago

okwasniewski commented 6 months ago

Summary

This PR adds syntax highlighting feature

Demo:

CleanShot 2024-02-19 at 17 37 35@2x

Test plan

Ask AI for a message that can contain codeblock, for example: show me swift class that stores a counter state and has methods to increment and decrement

TODO

okwasniewski commented 6 months ago

I was wondering if we need an option to disable syntax highlighting - I've added it as TODO by Im not sure if it will be useful

mdjastrzebski commented 6 months ago

@okwasniewski perhaps we could keep the opening and closing ``` and just colorize the content? That would make it stand out more, and also be easier for copy pasting to markdown (a minor thing).

okwasniewski commented 5 months ago

Ugh, I'm sorry @mdjastrzebski I forgot about this PR.. I guess by looking at https://github.com/callstack/ai-cli/pull/34 this solution wouldn't be valid after Ink get's merged. Should I close the PR and later on reimplement it?

mdjastrzebski commented 5 months ago

No worries @okwasniewski.

We've added ink to be able to implement streaming responses, and overall better UI in the near future.

The chalk code in your PR might not work directly either ink, but on the other hand it also seems to use chalk, so perhaps there is some easy way to adapt it.

mdjastrzebski commented 5 months ago

@okwasniewski Ink implemenation is stable now. If you have some free capacity, please adjust the PR to the current codebase.

okwasniewski commented 1 month ago

I'm sorry I won't find time to finish this soon and don't want to block implementing this feature. If anyone else wants to add this feature feel free to use my implementation as a base reference