{{ message }}
feat(cli): add --type to the write-note tool command - #907
Merged
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>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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