Skip to content

feat(cli)!: bm tool mirrors the bm_* MCP tools - #1943

Merged
phernandez merged 2 commits into
mainfrom
feat/977-bm-tool-mirrors-bm-tools
Oct 29, 2026
Merged

phernandez merged 2 commits into
mainfrom
feat/977-bm-tool-mirrors-bm-tools

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

bm tool still called the retired note tools (write_note, read_note, search_notes, ...) with its own flag names (--folder, --operation, --after_date, --meta), and kept Rich and plain renderers for their old JSON shapes. An agent that knows the bm_* schemas could not write a working CLI command from them. Fixes #977.

What changed

bm tool is the 1.0 surface from the shell

  • One subcommand per tool: read, write, edit, move, delete, list, find, search, context, project, schema.
  • Flags are the tool's parameter names in kebab case (--directory, --note-type, --command, --since, --mode, --items, --filters).
  • Arguments go through pydantic.validate_call over the bm_* function, so they get the same Annotated validators and coercion an MCP client gets. For example, --filters is the same JSON object, and --mode bogus fails with the same message, naming the flag. (FastMCP.call_tool needs a live session, so it can't be used here.)
  • Output is the tool's text result, or its JSON with --json. Refusals and invalid arguments go to stderr with exit 1.
  • Without --project, commands use the configured default project. search --projects/--all-projects and project recent choose their own scope.

Removed, no aliases (same rule 1.0 applied to the MCP tool names)

  • Subcommands recent, projects, workspaces, validate, infer, diff.
  • The old flags, --project-id (--project takes an id), automatic JSON when piped, --plain, and the Rich renderers.
  • docs/1.0.md has the old-to-new CLI table.

Kept

  • The renderers bm cat, bm grep and bm inspect use move to cli/commands/output.py with public names.
  • The POSIX commands themselves are unchanged.

Callers

  • Pi integration: new flags, and --json on write. It previously relied on JSON-when-piped. projectArgs sends the project id via --project.
  • Docs: metadata-search.md, COMPACT_DISCOVERY.md, bm.1, docs/1.0.md.

Tests (net -4,700 lines)

  • Removed tests for the old CLI's renderers, JSON shapes and CLI/MCP parity bugs. Both now call the same validated tool, so those can't recur. Tool behavior stays covered by the bm_* suites.
  • New tests/cli/test_tool_commands.py checks that each subcommand's flags equal its tool's parameters, by signature introspection.
  • New test-int/cli/test_tool_commands_integration.py runs write (stdin), edit with a checksum guard, read by section, search with --filters, move, list, delete, text output, a bad argument, and a missing default project against a real project. No patching.
  • Tests that use bm tool only to create notes switch to the new flags.

Verification

  • tests/cli and test-int/cli in full: 1,248 passed, 7 skipped (before the last test additions). New tests: 16 passed.
  • OKF and pagination integration tests pass.
  • just package-check-pi passes.
  • just fast-check is clean.
  • The repo-wide testmon run was stopped before finishing; CI runs the full SQLite and Postgres suites.

Follow-ups

  • Next PR: move bm hook and bm ci to bm_write/bm_search, then delete the old tool modules nothing imports (delete_note, move_note, list_directory, read_content, view_note, basic_memory_diagnostics, then write_note, search).
  • read_note, edit_note helpers, workspaces, chatgpt_tools and list_memory_projects are still imported by Cloud's hosted MCP. They go with the next Cloud re-pin.
  • 1.0 manual: section 3 lists only registered tools, plus one migration page #1941 updates the bm_* man pages' CLI lines and removes the retired stubs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8

bm tool called the retired note tools directly, with its own flag names
and renderers for their JSON shapes. Rebuild it on the 1.0 surface: one
subcommand per bm_* tool (read, write, edit, move, delete, list, find,
search, context, project, schema), flags named after the tool's
parameters, and arguments passed through pydantic.validate_call so the
shell gets the same validation an MCP client gets.

Output is the tool's text result, or its JSON result with --json. The
pipe-detects-JSON rule, --plain and the Rich renderers are gone from bm
tool. Old subcommands and flags are removed without aliases, the same
rule 1.0 applied to the MCP tool names.

The renderers bm cat, bm grep and bm inspect still use move to
cli/commands/output.py. The Pi integration, docs and the 1.0 migration
table use the new flags. Tests that covered the old CLI's own renderers
and parity bugs are removed; a signature test keeps every subcommand's
flags equal to its tool's parameters.

Fixes #977

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50dcb59af5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/basic_memory/cli/commands/tool.py Resolved
Comment thread src/basic_memory/cli/commands/tool.py Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T05:17:13.965486Z 51221b2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…t models as JSON

bm_project's recent command requires a project, so bm tool project recent
without --project now uses the default project; list and create still
take none. bm_read returns images and documents as MCP content models,
which json.dumps turned into a quoted repr; --json now dumps them with
their wire names (mimeType).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 51221b243c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez merged commit 8d1940c into main Oct 29, 2026
62 checks passed
@phernandez
phernandez deleted the feat/977-bm-tool-mirrors-bm-tools branch October 29, 2026 05:26
phernandez added a commit that referenced this pull request Oct 29, 2026
Stacked on #1943.

## Why

After #1943, `bm hook` and `bm ci` were the last callers of the retired
`write_note` and `search_notes` implementations, and six retired tool
modules had no callers at all.

## What changed

**`bm hook` and `bm ci` use the 1.0 tools**
- The session brief queries call `bm_search`; checkpoints and CI project
updates call `bm_write`.
- One `project` parameter carries a name, `workspace/project` route, or
id, so `split_project_ref` is gone.
- `filters` replaces `metadata_filters` and `status`; `since` replaces
`after_date`.
- An unmapped hook directory reads the default project, as before.
- A refused checkpoint write arrives as a `ToolError` and is still
reported on stderr without failing the hook.
- `_routed_project` in `bm ci` returns the id when one is configured,
and falls back to the default project.

**Deleted** (no importers in core or Cloud, checked against
basic-memory-cloud main)
- `basic_memory_diagnostics`, `delete_note`, `list_directory`,
`move_note`, `read_content`, `view_note`, plus their re-exports, tests,
contract-table entries and implementation-harness names.

**Kept for now**
- `write_note`: about 20 test files use it to create notes, many parsing
its text output. Moving them to `bm_write` is its own PR.
- `read_note`, the `edit_note` helpers, `workspaces`, `chatgpt_tools`,
`list_memory_projects`: Cloud's hosted MCP imports them. They go with
the next Cloud re-pin.
- Implementation modules the `bm_*` tools call (`build_context`,
`recent_activity`, `project_management`, `schema`, `search`), and
`posix_tools` for the shell commands.
- Man pages for the deleted tools: removed in #1941.

**Tests**
- `bm ci`: the seeding and publish tests now run against a real project.
Publish moved to `test-int/cli/test_ci_publish_integration.py`, because
the command needs the integration fixtures' shared database. Routing (id
over name, workspace qualification) is tested directly on
`_routed_project`.
- Ported to the 1.0 tools rather than dropped: the workspace-qualified
`memory://` delete regression (now on `bm_delete`), the
wiki-after-API-writes test, and the write-conflict-after-move test (now
on `bm_move`).
- The brief-formatting hook tests still stub the search tool; their
patches now target `bm_search`/`bm_write` with the new argument names.

## Verification

- `tests/mcp`, `tests/cli`, `tests/hooks`, `test-int/cli` and
`test-int/mcp`: 3,406 passed on the first run. The 7 failures and 22
errors were stale references to the deleted tools; all fixed, and those
files rerun at 245 passed.
- `just fast-check` is clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8

Signed-off-by: phernandez <paul@basicmachines.co>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
phernandez added a commit that referenced this pull request Oct 29, 2026
)

## Why

Section 3 of the bundled manual mixed the 1.0 `bm_*` pages with 20 pages
for tools no server registers. Those were retired stubs that went on to
document old `bm tool` commands, plus `cloud-info`, which became
`bm_project(command="info")`. `docs/manual-pages.md` still described the
retired `manual` Basic Memory project. Fixes #1941.

## What changed

- **Removed 20 section 3 pages.** Every remaining page names a
registered tool: the `bm_*` tools, plus `bm_agent` and the ChatGPT
`search`/`fetch` adapters that Cloud registers. The registry test's
allowed gaps shrink to those three Cloud tools.
- **Added `tools-migration(7)`.** It maps every pre-1.0 MCP tool and `bm
tool` command to its 1.0 replacement, and is linked from `bm-man(3)` and
`docs/1.0.md`.
- **Rewrote `docs/manual-pages.md`** around the bundled pages: where
they live, how to read them, page anatomy, generated sections, and
adding or removing a page.
- **Fixed two examples** that named removed pages: the page-reference
docstring and the `chatgpt-search(3)` sample output.
- **Tests:** the man-page tests use remaining pages as fixtures
(`bm-search`, `bm-agent`), and the retired-pages test is gone with the
pages.
- The `bm_*` pages carry no CLI flag lines, so the flag rename in #1943
needed no page edits.

## Verification

- `just man-regen`: all pages already match their source.
- Man-page, man-resource, `bm_man` and `bm man` tests: 98 passed. `just
fast-check` is clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8

---------

Signed-off-by: phernandez <paul@basicmachines.co>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
phernandez added a commit that referenced this pull request Oct 29, 2026
## Why

`just release v1.0.0` pre-flight-checks for a `## v1.0.0` heading on
`main`, so the changelog has to land first.

## What changed

`CHANGELOG.md`: the Unreleased section becomes `## v1.0.0 (2026-10-29)`.
Its existing items are kept, and the 60 or so commits since #1871 are
added:

- **Breaking:**
- the MCP surface is only `bm_*`, with the old tools deleted (#1944,
#1947, #1959, #1962–#1964)
  - `project` is required (#1934)
  - the ChatGPT adapters moved to Cloud
  - `bm tool` mirrors the tools (#1943)
  - the POSIX verbs are rebuilt and `bm tail` is removed (#1960)
  - cloud sync/bisync are removed (#1953)
  - `bm schema` project resolution (#1959)
  - LiteLLM is an optional extra
- **Features:** text-file line ranges in `bm_read`; chat imports return
their file paths.
- **Bug fixes:** including the three found in the 1.0 live test (#1971,
#1972, #1974), with contributor credits for @Flynn-Kawolsky (#1957),
@SWSAmor (#1951) and @MbappeWU (#1948).
- **Security:** the CodeRabbit deep-scan hardening batch.

I checked the entries against PR bodies rather than titles, and
corrected #1954, #1948 and #1967 to describe what they actually fixed.

The date is today; change it if the tag lands tomorrow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8

Signed-off-by: phernandez <paul@basicmachines.co>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.0: bm tool commands and flags mirror the bm_* MCP tools

1 participant