gorilla-llm / gorilla-cli

LLMs for your CLI
https://gorilla.cs.berkeley.edu/
Apache License 2.0
1.28k stars 75 forks source link

Added history feature #54

Closed royh02 closed 11 months ago

royh02 commented 1 year ago

The history feature (-p or --history) will allow users to find their past commands executed and execute them using the questionary selection feature.

The history will be stored in ~/.gorilla_cli_history and currently, it is set so that the newest 5 commands in the history will be displayable (there is an adjustable constant for HISTORY_LENGTH).

Repeated executions of the same command within the most recent 5 commands will not be appended to the history, but as long as that command is out of the recent window, it is again able to be added to the history list. This is to prevent cluttering of the history by repeated executions of the same command consecutively.

This address the issue #39 for bash history appending for executed commands. Since the CLI, using python, runs on a separate subprocess than the current user's shell, it is against best security practices to violate this subprocess distinction and force write to a global history. As well, since different shells work differently when tracking history (zsh, bash, cmd.exe), it is also a very big hassle to introduce cross-platform support. This is why I opted for this in-house history solution.

image