Skip to content

Commit 1df1ad3

Browse files
groksrcclaude
authored andcommitted
feat(cli): rename read-note --include-frontmatter to --frontmatter
Keep --include-frontmatter as a deprecated alias for back-compat (the old name shipped in 0.22.0). The MCP tool parameter include_frontmatter is unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Drew Cain <groksrc@gmail.com>
1 parent 82d6303 commit 1df1ad3

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/basic_memory/cli/commands/tool.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _display_read_note(result: dict[str, Any], *, include_frontmatter: bool = Fa
190190

191191
console.print(Panel(header, expand=False))
192192

193-
# Trigger: --include-frontmatter was passed; the MCP tool populates "frontmatter".
193+
# Trigger: --frontmatter was passed; the MCP tool populates "frontmatter".
194194
# Why: the JSON payload always carries a "frontmatter" key regardless of the flag,
195195
# so checking non-empty alone would render it even without the flag. The flag
196196
# must be threaded in to gate the panel.
@@ -207,7 +207,7 @@ def _display_read_note(result: dict[str, Any], *, include_frontmatter: bool = Fa
207207
fm_table.add_row(markup_escape(str(key)), markup_escape(str(value)))
208208
console.print(Panel(fm_table, title="[dim]frontmatter[/dim]", expand=False))
209209

210-
# Trigger: --include-frontmatter makes the API return the literal file, so
210+
# Trigger: --frontmatter makes the API return the literal file, so
211211
# content starts with the frontmatter block the panel above already shows.
212212
# Why: rendering it again through Markdown duplicates the frontmatter (and
213213
# Markdown mangles the --- fences into rules/headings).
@@ -385,11 +385,11 @@ def _plain_read_note(result: dict[str, Any]) -> None:
385385
"""Render read-note content faithfully: the note body, or the literal file.
386386
387387
Plain mode adds NO decoration: no header line, no synthesized frontmatter
388-
block, no placeholder for empty notes. Without --include-frontmatter the
388+
block, no placeholder for empty notes. Without --frontmatter the
389389
API returns the note body; with it, the literal file (frontmatter block
390390
included). Either is printed verbatim, trimmed only of the surrounding
391391
newline artifacts the API keeps from frontmatter stripping, so the output
392-
round-trips (e.g. ``read-note X --plain --include-frontmatter > note.md``).
392+
round-trips (e.g. ``read-note X --plain --frontmatter > note.md``).
393393
"""
394394
content = result.get("content", "")
395395
body = content.strip("\n") if content else ""
@@ -595,7 +595,10 @@ def write_note(
595595
def read_note(
596596
identifier: str,
597597
include_frontmatter: bool = typer.Option(
598-
False, "--include-frontmatter", help="Include YAML frontmatter in output"
598+
False,
599+
"--frontmatter",
600+
"--include-frontmatter",
601+
help="Include YAML frontmatter in output (--include-frontmatter is a deprecated alias)",
599602
),
600603
json_output: bool = typer.Option(
601604
False, "--json", help="Output raw JSON instead of formatted display"
@@ -629,7 +632,7 @@ def read_note(
629632
Examples:
630633
631634
bm tool read-note my-note
632-
bm tool read-note my-note --include-frontmatter
635+
bm tool read-note my-note --frontmatter
633636
bm tool read-note my-note --plain
634637
bm tool read-note my-note --json
635638
"""

tests/cli/test_cli_tool_rich_output.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def test_read_note_rich_include_frontmatter(mock_mcp):
456456
frontmatter block must be stripped from the Markdown body or it renders
457457
again under the panel.
458458
"""
459-
result = _tty_runner(["tool", "read-note", "test-note", "--include-frontmatter"])
459+
result = _tty_runner(["tool", "read-note", "test-note", "--frontmatter"])
460460

461461
assert result.exit_code == 0, f"CLI failed: {result.output}"
462462
# Frontmatter panel appears with key/value data
@@ -776,7 +776,7 @@ def test_read_note_plain_include_frontmatter(mock_mcp):
776776
With the flag, content IS the file (frontmatter block included); plain mode
777777
prints it verbatim and must not prepend a synthesized key/value block.
778778
"""
779-
result = _tty_runner(["tool", "read-note", "test-note", "--plain", "--include-frontmatter"])
779+
result = _tty_runner(["tool", "read-note", "test-note", "--plain", "--frontmatter"])
780780

781781
assert result.exit_code == 0, f"CLI failed: {result.output}"
782782
# ONLY the literal file: no header line, output starts at the fence
@@ -787,6 +787,19 @@ def test_read_note_plain_include_frontmatter(mock_mcp):
787787
assert result.output.count("title: Test Note") == 1
788788

789789

790+
@patch(
791+
"basic_memory.cli.commands.tool.mcp_read_note",
792+
new_callable=AsyncMock,
793+
return_value=READ_NOTE_RESULT_WITH_FRONTMATTER,
794+
)
795+
def test_read_note_include_frontmatter_alias(mock_mcp):
796+
"""--include-frontmatter still works as a deprecated alias for --frontmatter."""
797+
result = _tty_runner(["tool", "read-note", "test-note", "--plain", "--include-frontmatter"])
798+
799+
assert result.exit_code == 0, f"CLI failed: {result.output}"
800+
assert result.output.startswith("---\ntitle: Test Note")
801+
802+
790803
@patch(
791804
"basic_memory.cli.commands.tool.mcp_read_note",
792805
new_callable=AsyncMock,

0 commit comments

Comments
 (0)