Skip to content

Comments

feat: add stdin piping support for search command#45

Draft
andrewgazelka wants to merge 1 commit intomixedbread-ai:mainfrom
andrewgazelka:andrewgazelka/stdin
Draft

feat: add stdin piping support for search command#45
andrewgazelka wants to merge 1 commit intomixedbread-ai:mainfrom
andrewgazelka:andrewgazelka/stdin

Conversation

@andrewgazelka
Copy link

@andrewgazelka andrewgazelka commented Nov 26, 2025

can't test as on free tier rn lol. rn AI assisted haven't looked carefully. will do if you agree this makes sense

❯ git log | mgrep search "fix bug"
⠴ Uploading stdin content...Failed to search: 403 Free tier stores can contain at most 1000 files. Remove an existing file or upgrade your plan.
⠋ Uploading stdin content...

Summary

  • Add stdin piping support for the search command
  • Enable usage patterns like git log | mgrep search "query" or cat file.txt | mgrep search -a "what is this?"
  • Use SHA-256 hash-based caching for stdin content (__stdin__/<hash>)
  • Auto-detect stdin and sync content before searching

Test plan

  • Run pnpm test - all 24 tests pass
  • Manual test: echo "test content" | mgrep search "test"
  • Verify stdin results display as <stdin> in output

Note

Add stdin piping to mgrep search, uploading and indexing piped content under __stdin__/<hash> and showing results as <stdin>.

  • CLI: search
    • Auto-detects stdin, uploads content, and waits for indexing (uses ora spinner); skips normal --sync when stdin is used.
    • Uses hash-based virtual path __stdin__/<hash> and renders it as <stdin> in output; scoping prefers stdin path when present.
    • Works across normal, --content, and --answer modes.
  • Utils
    • Add tryReadStdin (non-blocking stdin read) and uploadBuffer (direct buffer upload); reuse computeBufferHash.
  • Tests
    • Add tests for stdin pipe, answer/content modes, and empty-stdin fallback to regular search.

Written by Cursor Bugbot for commit 941c5c8. This will update automatically on new commits. Configure here.

- Add tryReadStdin() to detect and read piped stdin data
- Add uploadBuffer() to upload stdin content to store
- Auto-detect stdin mode and sync content before searching
- Use SHA-256 hash for stdin caching (__stdin__/<hash>)
- Display <stdin> in search results for stdin-originated content
- Add tests for stdin piping functionality
@andrewgazelka andrewgazelka marked this pull request as draft November 26, 2025 21:17
@joeldierkes
Copy link
Contributor

Hey, I'm a bit puzzled with this use case. While we strive to support grep like features we also want to primarily focus on agents.

My main problem is that we don't return lines but chunks, and chunks are typically way bigger than lines. For most smaller input this leads to a search over just one chunk, which does not make sense.

On the other hand semantic search in a single big file might make sense.

Do you have a specific use case for this?

@andrewgazelka
Copy link
Author

andrewgazelka commented Nov 28, 2025

Hey, I'm a bit puzzled with this use case. While we strive to support grep like features we also want to primarily focus on agents.

My main problem is that we don't return lines but chunks, and chunks are typically way bigger than lines. For most smaller input this leads to a search over just one chunk, which does not make sense.

On the other hand semantic search in a single big file might make sense.

Do you have a specific use case for this?

The provided example git log | mgrep search "query" , especially when trying to find similar commits in large repos like https://github.com/NixOS/nixpkgs

This should be done by agents see https://imandrew.pages.dev/thoughts/mcp-not-enough

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.

2 participants