Skip to content

Commit d0d9734

Browse files
authored
feat: add global optional user goosehints file (#73)
1 parent 3bf4045 commit d0d9734

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ To install Goose, use `pipx`. First ensure [pipx][pipx] is installed:
101101
brew install pipx
102102
pipx ensurepath
103103
```
104+
You can also place `.goosehints` in `~/.config/goose/.goosehints` if you like for always loaded hints personal to you.
104105

105106
Then install Goose:
106107

src/goose/toolkit/developer.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ def system(self) -> str:
4141
"""Retrieve system configuration details for developer"""
4242
hints_path = Path(".goosehints")
4343
system_prompt = Message.load("prompts/developer.jinja").text
44+
home_hints_path = Path.home() / ".config/goose/.goosehints"
45+
hints = []
4446
if hints_path.is_file():
45-
goosehints = render_template(hints_path)
46-
system_prompt = f"{system_prompt}\n\nHints:\n{goosehints}"
47+
hints.append(render_template(hints_path))
48+
if home_hints_path.is_file():
49+
hints.append(render_template(home_hints_path))
50+
if hints:
51+
hints_text = "\n".join(hints)
52+
system_prompt = f"{system_prompt}\n\nHints:\n{hints_text}"
4753
return system_prompt
4854

4955
@tool

tests/toolkit/test_developer.py

+44-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,50 @@ def test_system_prompt_with_goosehints(temp_dir, developer_toolkit):
5555
assert system_prompt.endswith(expected_end)
5656

5757

58-
def test_update_plan(developer_toolkit):
58+
def test_system_prompt_with_goosehints_only_from_home_dir(temp_dir, developer_toolkit):
59+
readme_file_home = Path.home() / ".config/goose/README.md"
60+
readme_file_home.parent.mkdir(parents=True, exist_ok=True)
61+
readme_file_home.write_text("This is from the README.md file in home.")
62+
63+
home_hints_file = Path.home() / ".config/goose/.goosehints"
64+
home_jinja_template_content = "Hints from home:\n\n{% include 'README.md' %}\nEnd."
65+
home_hints_file.write_text(home_jinja_template_content)
66+
67+
try:
68+
with change_dir(temp_dir):
69+
system_prompt = developer_toolkit.system()
70+
expected_content_home = "Hints from home:\n\nThis is from the README.md file in home.\nEnd."
71+
expected_end = f"Hints:\n{expected_content_home}"
72+
assert system_prompt.endswith(expected_end)
73+
finally:
74+
home_hints_file.unlink()
75+
readme_file_home.unlink()
76+
77+
readme_file = temp_dir / "README.md"
78+
readme_file.write_text("This is from the README.md file.")
79+
80+
hints_file = temp_dir / ".goosehints"
81+
jinja_template_content = "Hints from local:\n\n{% include 'README.md' %}\nEnd."
82+
hints_file.write_text(jinja_template_content)
83+
84+
home_hints_file = Path.home() / ".config/goose/.goosehints"
85+
home_jinja_template_content = "Hints from home:\n\n{% include 'README.md' %}\nEnd."
86+
home_hints_file.write_text(home_jinja_template_content)
87+
88+
home_readme_file = Path.home() / ".config/goose/README.md"
89+
home_readme_file.write_text("This is from the README.md file in home.")
90+
91+
try:
92+
with change_dir(temp_dir):
93+
system_prompt = developer_toolkit.system()
94+
expected_content_local = "Hints from local:\n\nThis is from the README.md file.\nEnd."
95+
expected_content_home = "Hints from home:\n\nThis is from the README.md file in home.\nEnd."
96+
expected_end = f"Hints:\n{expected_content_local}\n{expected_content_home}"
97+
assert system_prompt.endswith(expected_end)
98+
finally:
99+
home_hints_file.unlink()
100+
home_readme_file.unlink()
101+
59102
tasks = [
60103
{"description": "Task 1", "status": "planned"},
61104
{"description": "Task 2", "status": "complete"},

0 commit comments

Comments
 (0)