Repository navigation
feat: add basic-memory watch CLI command - #559
Conversation
Standalone long-running file watcher that reuses SyncCoordinator without starting the MCP server. Useful for running Basic Memory sync alongside external tools like openclaw-basic-memory. - Add `quiet` field to SyncCoordinator, threaded through to WatchService - Add `quiet` param to `initialize_file_sync()` (defaults True for MCP) - New `watch.py` command: init → sync coordinator → block until signal → clean shutdown - Supports `--project` flag to constrain to a single project Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 44570a0736
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| loop = asyncio.get_running_loop() | ||
| for sig in (signal.SIGINT, signal.SIGTERM): | ||
| loop.add_signal_handler(sig, _signal_handler) |
There was a problem hiding this comment.
Handle Windows where add_signal_handler is unsupported
run_watch registers SIGINT/SIGTERM with loop.add_signal_handler(...) unconditionally, but that API is not implemented on Windows event loops, so basic-memory watch fails with NotImplementedError before the watcher starts. This impacts all win32 users of the new command even though the command explicitly tries to support Windows via selector policy setup.
Useful? React with 👍 / 👎.
| project_name, _ = config_manager.get_project(project) | ||
| if not project_name: | ||
| typer.echo(f"No project found named: {project}", err=True) | ||
| raise typer.Exit(1) |
There was a problem hiding this comment.
Ensure DB cleanup on invalid --project exit path
When --project is invalid, run_watch raises typer.Exit(1) after initialize_app(config) has already run, but before entering the try/finally block that calls db.shutdown_db(). That leaves initialization-opened DB resources unclosed on this error path and can cause noisy or hanging event-loop teardown for users who mistype the project name.
Useful? React with 👍 / 👎.
- Resolve merge conflicts in app.py (add both "reindex" and "watch" to skip_init_commands) and rclone_commands.py (use --header for Tigris consistency) - Address Codex P1: handle Windows where add_signal_handler is unsupported by falling back to signal.signal() - Address Codex P2: ensure DB cleanup on all exit paths (including invalid --project) by wrapping post-init code in try/finally - Add test for Windows signal handler fallback - Apply ruff formatting to files from main Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>

Summary
basic-memory watchcommand that runs the file watcher as a standalone long-running process without starting the MCP serverquietparameter throughSyncCoordinator→initialize_file_sync→WatchServiceso the watch command shows Rich console output while MCP keeps quiet--projectflag to constrain watching to a single projectTest plan
tests/cli/test_watch.py(init, coordinator args, project env var, invalid project exit, shutdown cleanup)tests/sync/test_coordinator.py(quiet defaults, quiet override, quiet passthrough)basic-memory watchstarts and shows file changes, stops on Ctrl+Cbasic-memory watch --project my-projectconstrains to single project🤖 Generated with Claude Code