Skip to content

Commit cb2871b

Browse files
authored
docs: add minimal flow description (#9)
1 parent caa42f5 commit cb2871b

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

docs/git-draft.adoc

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ifndef::manversion[:manversion: 0.0.0]
22

3-
= git-traft(1)
3+
= git-draft(1)
44
Matthieu Monsch
55
v{manversion}
66
:doctype: manpage
@@ -10,7 +10,7 @@ v{manversion}
1010

1111
== Name
1212

13-
git-draft - a git-friendly way to edit code
13+
git-draft - git-friendly code assistant
1414

1515

1616
== Synopsis
@@ -21,12 +21,30 @@ git-draft - a git-friendly way to edit code
2121

2222
*git-draft* _-A_
2323

24-
*git-draft* _-D_
24+
*git-draft* _-D_ _[-b BRANCH]_
2525

2626

2727
== Description
2828

29-
TODO
29+
_git-draft_ is a git-centric way to edit code using AI.
30+
31+
=== How it works
32+
33+
When you create a new draft with `git draft -C $name`, a new branch called `$branch/drafts/$name-$hash` is created (`$hash` is a random suffix used to guarantee uniqueness of branch names) and checked out.
34+
Additionally, any uncommitted changes are automatically committed (`draft! sync`).
35+
36+
Once the draft is created, we can use AI to edit our code using `git draft -P`.
37+
It expects the prompt as standard input, for example `echo "Add a test for compute_offset in chart.py" | git draft -P`.
38+
The prompt will automatically get augmented with information about the files in the repository, and give the AI access to tools for reading and writing files.
39+
Once the response has been received and changes, applied a commit is created (`draft! prompt: a short summary of the change`).
40+
41+
The prompt step can be repeated as many times as needed. Once you are satisfied with the changes, run `git draft -A` to apply them.
42+
This will check out the branch used when creating the draft, adding the final state of the draft to the worktree.
43+
Note that you can come back to an existing draft anytime (by checking its branch out), but you will not be able to apply it if its origin branch has moved since the draft was created.
44+
45+
Finally, calling `git draft -D` will delete all drafts associated with a branch.
46+
By default the currently active branch is used, you can use the `-b` option to select another.
47+
You can also delete the drafts manually by deleting their branches using `git branch`.
3048

3149

3250
== See also

src/git_draft/__main__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,23 @@ def __call__(self, _option, _opt, value, parser, name) -> None:
5656
)
5757

5858
apply_command = Command.register(
59-
"apply", help="apply the current draft to the original state"
59+
"apply", help="apply the current draft to the original branch"
6060
)
6161
apply_command.option_group().add_option(
62-
"-k",
63-
"--keep",
64-
help="do not delete the draft after applying",
62+
"-d",
63+
help="delete the draft after applying",
6564
action="store_true",
6665
)
6766

68-
Command.register("delete", help="delete the current draft")
67+
delete_command = Command.register(
68+
"delete", help="delete all drafts associated with a branch"
69+
)
70+
delete_command.option_group().add_option(
71+
"-b",
72+
help="draft source branch [default: active branch]",
73+
type="string",
74+
metavar="BRANCH",
75+
)
6976

7077

7178
def main() -> None:

0 commit comments

Comments
 (0)