Skip to content

Commit

Permalink
feat: show available toolkits (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Alvoeiro authored and lily-de committed Oct 7, 2024
1 parent 97e0b48 commit eb04c4c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/goose/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ def session() -> None:
pass


@goose_cli.group()
def toolkit() -> None:
"""Manage toolkits"""
pass


@toolkit.command(name="list")
def list_toolkits() -> None:
print("[green]Available toolkits:[/green]")
for toolkit_name, toolkit in load_plugins("goose.toolkit").items():
first_line_of_doc = toolkit.__doc__.split("\n")[0]
print(f" - [bold]{toolkit_name}[/bold]: {first_line_of_doc}")


@session.command(name="start")
@click.option("--profile")
@click.option("--plan", type=click.Path(exists=True))
Expand Down
2 changes: 1 addition & 1 deletion src/goose/toolkit/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def keep_unsafe_command_prompt(command: str) -> PromptType:


class Developer(Toolkit):
"""The developer toolkit provides a set of general purpose development capabilities
"""Provides a set of general purpose development capabilities
The tools include plan management, a general purpose shell execution tool, and file operations.
We also include some default shell strategies in the prompt, such as using ripgrep
Expand Down
12 changes: 12 additions & 0 deletions src/goose/toolkit/lint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from goose.utils import load_plugins


def lint_toolkits() -> None:
for toolkit_name, toolkit in load_plugins("goose.toolkit").items():
assert toolkit.__doc__ is not None, f"`{toolkit_name}` toolkit must have a docstring"
first_line_of_docstring = toolkit.__doc__.split("\n")[0]
assert len(first_line_of_docstring.split(" ")) > 5, f"`{toolkit_name}` toolkit docstring is too short"
assert len(first_line_of_docstring.split(" ")) < 12, f"`{toolkit_name}` toolkit docstring is too long"
assert first_line_of_docstring[
0
].isupper(), f"`{toolkit_name}` toolkit docstring must start with a capital letter"
2 changes: 2 additions & 0 deletions src/goose/toolkit/repo_context/repo_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@


class RepoContext(Toolkit):
"""Provides context about the current repository"""

def __init__(self, notifier: Notifier, requires: Requirements) -> None:
super().__init__(notifier=notifier, requires=requires)

Expand Down
5 changes: 5 additions & 0 deletions tests/test_linting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from goose.toolkit.lint import lint_toolkits


def test_lint_toolkits():
lint_toolkits()

0 comments on commit eb04c4c

Please sign in to comment.