Allows an LLM to create a new git branch using gert::git_branch_create(),
equivalent to git branch <branch> in the terminal.
btw_tool_git_branch_create(
branch,
ref = "HEAD",
checkout = TRUE,
`_intent` = ""
)Name of the new branch to create.
Optional reference point for the new branch. Defaults to "HEAD".
Whether to check out the new branch after creation. Defaults
to TRUE.
An optional string describing the intent of the tool use. When the tool is used by an LLM, the model will use this argument to explain why it called the tool.
Returns a confirmation message.
withr::with_tempdir({
gert::git_init()
gert::git_config_set("user.name", "R Example")
gert::git_config_set("user.email", "ex@example.com")
fs::file_touch("hello.md")
gert::git_add("hello.md")
gert::git_commit("Initial commit")
# LLM creates a new branch
res <- btw_tool_git_branch_create(branch = "feature/new-analysis")
# What the LLM sees
cat(res@value)
})
#> Created branch `feature/new-analysis` from `HEAD` and checked it out.