Skip to content

Commit 0631048

Browse files
committed
Add usage instructions, update edit command, and refine code generation
1 parent 8ecd9cc commit 0631048

File tree

6 files changed

+60
-3
lines changed

6 files changed

+60
-3
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,40 @@ otto config --model $MODEL_NAME
5454
You can add a GitHub Personal Access Token for opening PRs by running:
5555

5656
```sh
57-
otto config --token $GITHUB_TOKEN
57+
otto config --token $GITHUB_TOKEN # Optional. Only needed for opening PRs and reading Issues
5858
```
5959

6060
Make sure that your access token has the `repo` scope.
6161

62-
Once that is complete, you can start generating documentation by running the following command:
62+
Once that is complete, you can start running commands!
63+
64+
## Usage
65+
66+
More detailed usage can be found in the [documentation](https://ottodocs.chand1012.dev/docs/usage/otto).
67+
68+
### Code Generation
69+
70+
![Made with VHS](https://vhs.charm.sh/vhs-5A6u3ITYSIp2qd1T7XdYEM.gif)
71+
72+
Otto can generate code and save it directly to your project! To do this, you can run the following command:
73+
74+
```sh
75+
otto edit <path to file> -g "Write me a Python function that returns the sum of two numbers"
76+
```
77+
78+
You can also give Otto additional context to help it generate better code:
79+
80+
```sh
81+
otto edit <path to file> -g "Write me a Python function that returns the sum of two numbers" -c hello_world.py
82+
```
83+
84+
Or you can have it use as much of the repo as possible as context:
85+
86+
```sh
87+
otto edit <path to file> -g "Write me a Python function that returns the sum of two numbers" -r
88+
```
89+
90+
### Documentation
6391

6492
```sh
6593
otto docs <path to repo or file>
@@ -71,6 +99,8 @@ Or for a single file, you can run:
7199
otto doc -f <path to file>
72100
```
73101

102+
### Ask
103+
74104
Ask a question about a repo:
75105

76106
```sh

cmd/edit.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ Example: otto edit main.go --start 1 --end 10 --goal "Refactor the function"`,
114114
}
115115

116116
for _, file := range repo.Files {
117+
if file.Path == fileName {
118+
continue
119+
}
117120
err = m.Add(file.Path, file.Contents)
118121
if err != nil {
119122
log.Errorf("Error indexing file: %s", err)
@@ -253,7 +256,7 @@ Example: otto edit main.go --start 1 --end 10 --goal "Refactor the function"`,
253256
newMessages = []openai.ChatCompletionMessage{
254257
{
255258
Role: openai.ChatMessageRoleUser,
256-
Content: "Use the following input to edit the code: " + confirm,
259+
Content: "Use the following input to edit the code: " + confirm + "\n\nMake sure to only output the code, do not print anything else.",
257260
},
258261
{
259262
Role: openai.ChatMessageRoleAssistant,

img/commit.gif

53.5 KB
Loading

img/commit.tape

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Output img/commit.gif
2+
3+
Set Shell "zsh"
4+
Set FontSize 32
5+
Set Width 1600
6+
Set Height 900
7+
8+
Type "otto commit" Sleep 500ms Enter
9+
Sleep 5s
10+
Type "y" Sleep 500ms Enter
11+
Sleep 1s

img/edit.gif

181 KB
Loading

img/edit.tape

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Output img/edit.gif
2+
3+
Set Shell "zsh"
4+
Set FontSize 32
5+
Set Width 1600
6+
Set Height 900
7+
8+
Type "otto edit hello.py -g 'Write me a Python hello world program' " Sleep 500ms Enter
9+
Sleep 5s
10+
Type "Add user input" Sleep 500ms Enter
11+
Sleep 5s
12+
Type "y" Sleep 500ms Enter
13+
Sleep 1s

0 commit comments

Comments
 (0)