Skip to content

Commit 3151e08

Browse files
divideby0claude
andcommitted
feat: default formatter_command to npx prettier
Users can now just set format_on_save=true and formatting will work out of the box (assuming Node.js is installed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Cedric Hurst <cedric@spantree.net>
1 parent 8333e93 commit 3151e08

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/basic_memory/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ class BasicMemoryConfig(BaseSettings):
172172
)
173173

174174
formatter_command: Optional[str] = Field(
175-
default=None,
176-
description="Default formatter command. Use {file} as placeholder for file path. Example: 'prettier --write {file}'",
175+
default="npx prettier --write {file}",
176+
description="Default formatter command. Use {file} as placeholder for file path. Uses npx prettier by default.",
177177
)
178178

179179
formatters: Dict[str, str] = Field(

tests/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,10 @@ def test_format_on_save_can_be_enabled(self):
498498
config = BasicMemoryConfig(format_on_save=True)
499499
assert config.format_on_save is True
500500

501-
def test_formatter_command_defaults_to_none(self):
502-
"""Test that formatter_command defaults to None."""
501+
def test_formatter_command_defaults_to_npx_prettier(self):
502+
"""Test that formatter_command defaults to npx prettier."""
503503
config = BasicMemoryConfig()
504-
assert config.formatter_command is None
504+
assert config.formatter_command == "npx prettier --write {file}"
505505

506506
def test_formatter_command_can_be_set(self):
507507
"""Test that formatter_command can be configured."""

tests/utils/test_file_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ async def test_format_file_no_formatter_configured(tmp_path: Path):
242242
test_file = tmp_path / "test.md"
243243
test_file.write_text("# Test\n")
244244

245-
config = BasicMemoryConfig(format_on_save=True)
246-
# No formatter_command or formatters configured
245+
# Explicitly set formatter_command to None to test the "no formatter" case
246+
config = BasicMemoryConfig(format_on_save=True, formatter_command=None)
247247

248248
result = await format_file(test_file, config)
249249
assert result is None

0 commit comments

Comments
 (0)