feat(daemon): lazy background indexing on first search#36
Draft
andrewgazelka wants to merge 1 commit intomixedbread-ai:mainfrom
Draft
feat(daemon): lazy background indexing on first search#36andrewgazelka wants to merge 1 commit intomixedbread-ai:mainfrom
andrewgazelka wants to merge 1 commit intomixedbread-ai:mainfrom
Conversation
Eliminate the need to manually run `mgrep watch` by automatically spawning a background daemon on first `mgrep search` invocation. Key features: - Lazy start: daemon spawns automatically when you first search - One daemon per directory with hierarchy awareness: - Parent directory daemon covers all subdirectories - Starting a parent daemon consolidates/kills child daemons - Atomic startup using O_EXCL file locking to prevent race conditions - New commands: `daemon:list` and `daemon:stop` for management Implementation: - Add src/lib/daemon.ts with daemon lifecycle management - Modify search.ts to call ensureDaemon() before searching - Add SIGTERM handler to watch.ts for graceful shutdown - Add daemon:list and daemon:stop commands to CLI State files stored in ~/.local/state/mgrep/daemons/ Update README to reflect that mgrep watch is now optional and document the new daemon management commands. Future consideration: Add idle timeout so daemons auto-stop after inactivity (e.g., 30 minutes). Currently daemons run indefinitely until manually stopped with `mgrep daemon:stop`. Closes: mixedbread-ai#34
andrewgazelka
referenced
this pull request
Nov 25, 2025
* feat: add a stub mcp server to start watch To start the watch command in the background we can use a mcp server and start the watch in the background. This way we can start watch for all agents that use mcp. * feat: add a install codex command * chore: only register the signal handlers when mcp is called * chore: await for exec * chore: properly handle AGENTS.md file * chore: do not add the skill twice * chore: respect the store selection in the parameters * chore: resolve wrong parameter count * chore: fix formating
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.
Closes: #34
Requires #35 to be fixed to test.
Warning
This is an AI-assisted PR where I have given it the architecture. I want to refine before promoting to ready for review.
Eliminate the need to manually run
mgrep watchby automatically spawning a background daemon on firstmgrep searchinvocation.Key features:
daemon:listanddaemon:stopfor managementImplementation:
State files stored in ~/.local/state/mgrep/daemons/
Update README to reflect that mgrep watch is now optional and document the new daemon management commands.
Future consideration
Perhaps add idle timeout so daemons auto-stop after inactivity (e.g., 30 minutes). Currently daemons run indefinitely until manually stopped with
mgrep daemon:stop.