Add --fix option to correct the last command (#698)#699
Open
demouo wants to merge 4 commits intoTheR1D:mainfrom
Open
Add --fix option to correct the last command (#698)#699demouo wants to merge 4 commits intoTheR1D:mainfrom
demouo wants to merge 4 commits intoTheR1D:mainfrom
Conversation
Author
|
The 2nd~4th Commits' changes:
Hope everything goes well! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! Backgroud and motivation from #698
When I got an error command, I would like to correct ai that
the command ... was wrong with the output ..., please fix it.example follows:

This PR introduces a
--fixflag. When used, sgpt retrieves the last executed command and its output, then prompts the AI to provide a corrected version based on the error.Key changes:
--fixoption tosgpt/app.py.sgpt/command.pyto manage storing and retrieving the last command and output in json format.sgpt/utils.pyto set and get the last command.os.systemwithsubprocess.Popeninrun_commandto capture output.get_fixed_promptto generate the prompt for the AI.tests/test_shell.pyto reflect the use ofsubprocess.sgpt/config.py.make sure the lint and test result as usual:

Closes #698