feat(memory): migrate MEMORY.md to global path & enhance ask-user prompts (#161)

* feat(prompt): enhance user interaction with multiple-choice and free-text questions

* refactor(paths): rename MEMORY_DIR to MEMORIES_DIR for consistency

* style(tests): format code for better readability in test cases

* feat(prompt): add validation for 'other' option in user prompt

* feat(prompt): refactor validation logic for user prompts and add skip option

* feat(style): refactor to use shared _PICKER_STYLE from interactive module
This commit is contained in:
Xi Zhang
2026-04-16 16:33:45 +02:00
committed by GitHub
parent 7f522cb4fe
commit 210e8864f6
13 changed files with 221 additions and 118 deletions
+38 -17
View File
@@ -95,38 +95,51 @@ class TestFormatToolCompact:
result = format_tool_compact("edit_file", {"path": "f.py"})
assert result == "edit_file(f.py)"
# Memory file special display
def test_read_file_memory(self):
result = format_tool_compact("read_file", {"path": "/memory/MEMORY.md"})
# Global memory file special display (/memories/ = global)
def test_read_file_global_memory(self):
result = format_tool_compact("read_file", {"path": "/memories/MEMORY.md"})
assert result == "Reading memory"
def test_read_file_memory_file_path_alias(self):
result = format_tool_compact("read_file", {"file_path": "/memory/MEMORY.md"})
def test_read_file_global_memory_file_path_alias(self):
result = format_tool_compact("read_file", {"file_path": "/memories/MEMORY.md"})
assert result == "Reading memory"
def test_read_file_any_memory_file(self):
result = format_tool_compact("read_file", {"path": "/memory/history.md"})
def test_read_file_any_global_memory_file(self):
result = format_tool_compact("read_file", {"path": "/memories/history.md"})
assert result == "Reading memory"
def test_write_file_memory(self):
def test_write_file_global_memory(self):
result = format_tool_compact("write_file", {"path": "/MEMORY.md"})
assert result == "Updating memory"
# Also covers paths with /memory/ prefix
result2 = format_tool_compact("write_file", {"path": "/memory/MEMORY.md"})
# Also covers paths with /memories/ prefix
result2 = format_tool_compact("write_file", {"path": "/memories/MEMORY.md"})
assert result2 == "Updating memory"
def test_edit_file_memory(self):
result = format_tool_compact("edit_file", {"path": "/memory/MEMORY.md"})
def test_edit_file_global_memory(self):
result = format_tool_compact("edit_file", {"path": "/memories/MEMORY.md"})
assert result == "Updating memory"
def test_write_edit_any_memory_file(self):
write_result = format_tool_compact("write_file", {"path": "/memory/soul.md"})
def test_write_edit_any_global_memory_file(self):
write_result = format_tool_compact("write_file", {"path": "/memories/soul.md"})
edit_result = format_tool_compact(
"edit_file", {"path": "/memory/skills-context.md"}
"edit_file", {"path": "/memories/skills-context.md"}
)
assert write_result == "Updating memory"
assert edit_result == "Updating memory"
# Project-local /memory/ files show normal tool display
def test_read_file_project_memory(self):
result = format_tool_compact(
"read_file", {"path": "/memory/ideation-memory.md"}
)
assert result == "read_file(/memory/ideation-memory.md)"
def test_edit_file_project_memory(self):
result = format_tool_compact(
"edit_file", {"path": "/memory/experiment-memory.md"}
)
assert result == "edit_file(/memory/experiment-memory.md)"
def test_memory_display_inferred_from_result_when_args_sparse(self):
read_result = format_tool_compact_with_result(
"read_file",
@@ -138,17 +151,25 @@ class TestFormatToolCompact:
edit_result = format_tool_compact_with_result(
"edit_file",
{},
"Successfully replaced 1 instance(s) of the string in '/memory/MEMORY.md'",
"Successfully replaced 1 instance(s) of the string in '/memories/MEMORY.md'",
)
assert edit_result == "Updating memory"
write_result = format_tool_compact_with_result(
"write_file",
{},
"Wrote updated content to '/memory/history.md'",
"Wrote updated content to '/memories/history.md'",
)
assert write_result == "Updating memory"
def test_project_memory_result_not_special(self):
result = format_tool_compact_with_result(
"write_file",
{},
"Wrote updated content to '/memory/ideation-memory.md'",
)
assert result != "Updating memory"
def test_glob(self):
result = format_tool_compact("glob", {"pattern": "*.py"})
assert result == "glob(*.py)"