yusufcanb / tlm

Local CLI Copilot, powered by CodeLLaMa. 💻🦙
Apache License 2.0
1.15k stars 36 forks source link

Trim shell prefix #18

Closed hanchchch closed 4 months ago

hanchchch commented 4 months ago

Hi, thank you for building and publishing this fascinating cli app. I had a tiny issue with suggest command. llama puts a shell prefix such as $ or sometimes, like below.

❯ tlm s 'create secret'
┃ > Thinking... (3.875119084s)
┃ > $ openssl rand -base64 32
┃ > Executing...

bash: $: command not found

It's not very often but it's disrupting the experience since you can't execute the command right after the suggestion when it happens.

I made a small solution simply by trimming the shell prefix if exists. I think it can be more developed like adding below method.

func (s *Suggest) refineCommand(command string) string {
  // refine the generated command, such as trimming shell prefix or removing possible mistakes
}

Because the generated commands are not always perfect, it would be helpful to handle known/possible issues.

yusufcanb commented 4 months ago

Thanks for your kind words and your contribution. Would you be interested in writing a unit test for func (s *Suggest) refineCommand(command string) string as well? This is what I'm gonna do before approving it.

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

hanchchch commented 4 months ago

Sure, I just added it. Note that I had to write it in suggest package instead of suggest_test, because the refineCommand method is not exported.

yusufcanb commented 4 months ago

Thank you for your contribution! ❤