|
1 | 1 | #' @include tool-result.R |
2 | 2 | NULL |
3 | 3 |
|
| 4 | +btw_can_register_git_tool <- function() { |
| 5 | + if (!rlang::is_installed("gert")) { |
| 6 | + return(FALSE) |
| 7 | + } |
| 8 | + |
| 9 | + tryCatch( |
| 10 | + { |
| 11 | + gert::git_info() |
| 12 | + TRUE |
| 13 | + }, |
| 14 | + error = function(e) FALSE |
| 15 | + ) |
| 16 | +} |
| 17 | + |
4 | 18 | # Git Status ------------------------------------------------------------------ |
5 | 19 |
|
6 | 20 | #' Tool: Git Status |
@@ -74,7 +88,7 @@ RETURNS: A list of file paths, their status (new, modified, deleted, etc.), and |
74 | 88 | read_only_hint = TRUE, |
75 | 89 | open_world_hint = FALSE, |
76 | 90 | idempotent_hint = FALSE, |
77 | | - btw_can_register = function() rlang::is_installed("gert") |
| 91 | + btw_can_register = btw_can_register_git_tool |
78 | 92 | ), |
79 | 93 | arguments = list( |
80 | 94 | include = ellmer::type_enum( |
@@ -164,7 +178,7 @@ LIMITATION: This tool does not support diffing between two arbitrary commits. |
164 | 178 | read_only_hint = TRUE, |
165 | 179 | open_world_hint = FALSE, |
166 | 180 | idempotent_hint = TRUE, |
167 | | - btw_can_register = function() rlang::is_installed("gert") |
| 181 | + btw_can_register = btw_can_register_git_tool |
168 | 182 | ), |
169 | 183 | arguments = list( |
170 | 184 | ref = ellmer::type_string( |
@@ -267,7 +281,7 @@ RETURNS: A list of commits with SHA (short), author, timestamp, number of files, |
267 | 281 | read_only_hint = TRUE, |
268 | 282 | open_world_hint = FALSE, |
269 | 283 | idempotent_hint = FALSE, |
270 | | - btw_can_register = function() rlang::is_installed("gert") |
| 284 | + btw_can_register = btw_can_register_git_tool |
271 | 285 | ), |
272 | 286 | arguments = list( |
273 | 287 | ref = ellmer::type_string( |
@@ -365,7 +379,7 @@ RETURNS: The commit SHA and confirmation message. |
365 | 379 | read_only_hint = FALSE, |
366 | 380 | open_world_hint = FALSE, |
367 | 381 | idempotent_hint = FALSE, |
368 | | - btw_can_register = function() rlang::is_installed("gert") |
| 382 | + btw_can_register = btw_can_register_git_tool |
369 | 383 | ), |
370 | 384 | arguments = list( |
371 | 385 | message = ellmer::type_string( |
@@ -451,7 +465,7 @@ RETURNS: A table of branch names, upstream tracking, and last update time. |
451 | 465 | read_only_hint = TRUE, |
452 | 466 | open_world_hint = FALSE, |
453 | 467 | idempotent_hint = TRUE, |
454 | | - btw_can_register = function() rlang::is_installed("gert") |
| 468 | + btw_can_register = btw_can_register_git_tool |
455 | 469 | ), |
456 | 470 | arguments = list( |
457 | 471 | include = ellmer::type_enum( |
@@ -541,7 +555,7 @@ RETURNS: Confirmation message with branch name and ref. |
541 | 555 | read_only_hint = FALSE, |
542 | 556 | open_world_hint = FALSE, |
543 | 557 | idempotent_hint = FALSE, |
544 | | - btw_can_register = function() rlang::is_installed("gert") |
| 558 | + btw_can_register = btw_can_register_git_tool |
545 | 559 | ), |
546 | 560 | arguments = list( |
547 | 561 | branch = ellmer::type_string( |
@@ -627,7 +641,7 @@ RETURNS: Confirmation message with branch name. |
627 | 641 | read_only_hint = FALSE, |
628 | 642 | open_world_hint = FALSE, |
629 | 643 | idempotent_hint = FALSE, |
630 | | - btw_can_register = function() rlang::is_installed("gert") |
| 644 | + btw_can_register = btw_can_register_git_tool |
631 | 645 | ), |
632 | 646 | arguments = list( |
633 | 647 | branch = ellmer::type_string( |
|
0 commit comments