feat(cli): add --type to the write-note tool command#907
Conversation
Expose the MCP write_note note_type parameter through the CLI wrapper as a --type option (defaults to "note"), so callers can state the note type explicitly instead of relying on content frontmatter derivation. A 'type:' in the note's own content frontmatter still takes precedence over --type (entity_service _apply_schema_frontmatter_overrides), preserving existing behavior; the help text documents this. Adds integration coverage (real harness, no mocks) locking in note_type round-trip behavior: content-frontmatter type persists and is searchable via the note_types filter, the update path flips the persisted type, and the CLI --type round-trips through read-note/search-notes. Mock-based CLI tests assert the --type passthrough and the "note" default. Closes #875 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 11s —— View job PR Review: feat(cli): add --type to the write-note tool commandTasks
SummaryClean, focused change that exposes the existing Team Checklist
Implementation (
|
Summary
Adds a
--typeoption tobm tool write-note, exposing the MCPwrite_notenote_typeparameter (which the CLI wrapper previously didn't surface). Locks innote_typebehavior with integration tests so a futureentity_servicechange can't silently break typed-note callers (e.g. the Claude Code memory bridge). Closes #875 (the descoped scope: passthrough flag + tests only).What changed
src/basic_memory/cli/commands/tool.py: added anote_typetyper.Option bound to--type(default"note") on thewrite-notecommand and passednote_type=note_typeintomcp_write_note(...). Help text documents that atype:in the note's own content frontmatter takes precedence over--type(preserving today'sentity_service._apply_schema_frontmatter_overridesbehavior). Per the maintainer's descope, the "explicit--typewins over content frontmatter" precedence sentinel was intentionally NOT implemented.test-int/mcp/test_write_note_type_integration.py(new, real harness, no mocks):type: sessionpersists and is returned bysearch_notes(note_types=["session"]).type: sessionthen overwriting withtype: schemaflips the persisted type toschema.test-int/cli/test_cli_tool_write_note_type_integration.py(new):bm tool write-note ... --type guideround-trips —read-note --include-frontmattershowstype: guideandsearch-notes --type guidefinds it; a content-frontmattertype:wins over the--typeflag (documented behavior).tests/cli/test_cli_tool_json_output.py: mock-based assertions that--typeforwardsnote_typeand that it defaults to"note".Testing (commands + results)
uv run ruff check . --fix/uv run ruff format .— clean.uv run ty check src tests test-int— All checks passed!uv run pytest tests/cli/test_cli_tool_json_output.py::test_write_note_type_passthrough tests/cli/test_cli_tool_json_output.py::test_write_note_type_defaults_to_note test-int/mcp/test_write_note_type_integration.py test-int/cli/test_cli_tool_write_note_type_integration.py -q --no-cov— 6 passed.uv run pytest tests/cli/test_cli_tool_json_output.py test-int/cli/test_cli_tool_json_integration.py test-int/cli/test_search_notes_meta_integration.py tests/mcp/test_tool_write_note.py test-int/mcp/test_write_note_integration.py -q --no-cov— all passed.--typeoption +note_type=kwarg) are not in the missing-lines set forcli/commands/tool.py. Did not run the Postgres variants — the change is in the CLI passthrough layer, not the search/db layer.Risk
Low. Additive CLI option with a default that preserves prior behavior; no change to the entity/persistence layer. Content-frontmatter
type:precedence is unchanged and documented.Closes #875
🤖 Generated with Claude Code