From 4b84c8ba098722623ee7ee4755d4cef232df5e8e Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Thu, 3 Oct 2024 17:43:52 +1000 Subject: [PATCH 1/2] removed the panel in the output so that the user won't have unnecessary pane borders in the copied content --- src/goose/toolkit/developer.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/goose/toolkit/developer.py b/src/goose/toolkit/developer.py index bf886b607..3dd6739ce 100644 --- a/src/goose/toolkit/developer.py +++ b/src/goose/toolkit/developer.py @@ -10,12 +10,11 @@ from goose.toolkit.utils import get_language, render_template from goose.utils.ask import ask_an_ai from goose.utils.check_shell_command import is_dangerous_command -from rich import box from rich.markdown import Markdown -from rich.panel import Panel from rich.prompt import Confirm from rich.table import Table from rich.text import Text +from rich.rule import Rule def keep_unsafe_command_prompt(command: str) -> bool: @@ -124,7 +123,8 @@ def patch_file(self, path: str, before: str, after: str) -> str: {after} ``` """ - self.notifier.log(Panel.fit(Markdown(output), title=path)) + self.notifier.log(Rule(path, style="bold black")) + self.notifier.log(Markdown(output)) return "Succesfully replaced before with after." @tool @@ -136,7 +136,7 @@ def read_file(self, path: str) -> str: """ language = get_language(path) content = Path(path).expanduser().read_text() - self.notifier.log(Panel.fit(Markdown(f"```\ncat {path}\n```"), box=box.MINIMAL)) + self.notifier.log(Markdown(f"```\ncat {path}\n```")) # Record the last read timestamp self.timestamps[path] = os.path.getmtime(path) return f"```{language}\n{content}\n```" @@ -155,7 +155,8 @@ def shell(self, command: str) -> str: if you need to run more than one at a time """ # Log the command being executed in a visually structured format (Markdown). - self.notifier.log(Panel.fit(Markdown(f"```bash\n{command}\n```"), title="shell")) + self.notifier.log(Rule("shell", style="bold black")) + self.notifier.log(Markdown(f"```bash\n{command}\n```")) if is_dangerous_command(command): # Stop the notifications so we can prompt @@ -262,7 +263,8 @@ def write_file(self, path: str, content: str) -> str: # Log the content that will be written to the file # .log` method is used here to log the command execution in the application's UX # this method is dynamically attached to functions in the Goose framework - self.notifier.log(Panel.fit(Markdown(md), title=path)) + self.notifier.log(Rule(path, style="bold black")) + self.notifier.log(Markdown(md)) _path = Path(path) if path in self.timestamps: From 4f436ed2d3acac51ecb1739b311daf496efdc3d0 Mon Sep 17 00:00:00 2001 From: Bradley Axen Date: Thu, 3 Oct 2024 11:21:05 -0700 Subject: [PATCH 2/2] fix: tweak the style --- src/goose/toolkit/developer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/goose/toolkit/developer.py b/src/goose/toolkit/developer.py index 3dd6739ce..ba600d921 100644 --- a/src/goose/toolkit/developer.py +++ b/src/goose/toolkit/developer.py @@ -16,6 +16,9 @@ from rich.text import Text from rich.rule import Rule +RULESTYLE = "bold" +RULEPREFIX = f"[{RULESTYLE}]───[/] " + def keep_unsafe_command_prompt(command: str) -> bool: command_text = Text(command, style="bold red") @@ -123,7 +126,7 @@ def patch_file(self, path: str, before: str, after: str) -> str: {after} ``` """ - self.notifier.log(Rule(path, style="bold black")) + self.notifier.log(Rule(RULEPREFIX + path, style=RULESTYLE, align="left")) self.notifier.log(Markdown(output)) return "Succesfully replaced before with after." @@ -155,7 +158,7 @@ def shell(self, command: str) -> str: if you need to run more than one at a time """ # Log the command being executed in a visually structured format (Markdown). - self.notifier.log(Rule("shell", style="bold black")) + self.notifier.log(Rule(RULEPREFIX + "shell", style=RULESTYLE, align="left")) self.notifier.log(Markdown(f"```bash\n{command}\n```")) if is_dangerous_command(command): @@ -263,7 +266,7 @@ def write_file(self, path: str, content: str) -> str: # Log the content that will be written to the file # .log` method is used here to log the command execution in the application's UX # this method is dynamically attached to functions in the Goose framework - self.notifier.log(Rule(path, style="bold black")) + self.notifier.log(Rule(RULEPREFIX + path, style=RULESTYLE, align="left")) self.notifier.log(Markdown(md)) _path = Path(path)