Skip to content

Commit

Permalink
fix: removed the panel in the output so that the user won't have unne…
Browse files Browse the repository at this point in the history
…cessary pane borders in the copied content (#109)

Co-authored-by: Bradley Axen <baxen@squareup.com>
  • Loading branch information
lifeizhou-ap and baxen authored Oct 3, 2024
1 parent 8f671e7 commit 9da4881
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/goose/toolkit/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
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

RULESTYLE = "bold"
RULEPREFIX = f"[{RULESTYLE}]───[/] "


def keep_unsafe_command_prompt(command: str) -> bool:
Expand Down Expand Up @@ -124,7 +126,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(RULEPREFIX + path, style=RULESTYLE, align="left"))
self.notifier.log(Markdown(output))
return "Succesfully replaced before with after."

@tool
Expand All @@ -136,7 +139,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```"
Expand All @@ -155,7 +158,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(RULEPREFIX + "shell", style=RULESTYLE, align="left"))
self.notifier.log(Markdown(f"```bash\n{command}\n```"))

if is_dangerous_command(command):
# Stop the notifications so we can prompt
Expand Down Expand Up @@ -262,7 +266,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(RULEPREFIX + path, style=RULESTYLE, align="left"))
self.notifier.log(Markdown(md))

_path = Path(path)
if path in self.timestamps:
Expand Down

0 comments on commit 9da4881

Please sign in to comment.