Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removed the panel in the output so that the user won't have unnecessary pane borders in the copied content #109

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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