Skip to content

Conversation

@tobi
Copy link
Owner

@tobi tobi commented Jan 19, 2026

Summary

This PR adds an interactive REPL (qmd repl) that mounts qmd collections as a read-only virtual filesystem, enabling LLMs to interact with large knowledge bases symbolically through shell commands rather than loading everything into context.

Motivation: Recursive Language Models (RLMs)

This is groundwork for implementing RLM (Recursive Language Models) - an inference-time strategy that allows LLMs to process inputs far beyond their context windows.

The Key Insight

Instead of tokenizing massive documents directly into the model's context, RLMs treat the knowledge base as part of the environment that the LLM can symbolically interact with. The model writes commands to:

  • Filter context using grep/search based on learned patterns
  • Chunk information and query recursively
  • Verify answers through additional searches
  • Build outputs by composing results in files

This enables handling inputs two orders of magnitude beyond model context windows.

Why Bash Instead of Python

We use just-bash - a sandboxed bash environment - because:

  1. LLMs are excellent at shell commands - grep, cat, head, tail, find are intuitive
  2. Composability - Unix pipes naturally chain operations
  3. Safety - just-bash provides a sandboxed virtual filesystem
  4. Simplicity - No Python runtime overhead, just text processing

What This PR Adds

  • Virtual filesystem: All qmd collections mounted read-only at /qmd/<collection>/
  • Writable workspace: Home directory at /home/ for intermediate results
  • Search primitives: search (BM25) and query (hybrid) commands built-in
  • Standard tools: ls, cat, head, tail, grep, find, awk, etc.
  • Prompt injection: --prompt or --file flags to seed /home/prompt.txt

Usage

qmd repl                          # Start interactive REPL
qmd repl --prompt "Find all mentions of product strategy"
qmd repl --file ./task.md         # Load task description

Inside the REPL:

cd /qmd/journals
ls | wc -l                        # Count files
search "company strategy"         # Semantic search
grep -l "revenue" *.md            # Find files mentioning revenue
cat 2025-01-15.md | head -50      # Read snippet
echo "Found: $result" >> /home/notes.txt  # Save findings

Example RLM-style Workflow

# 1. Discover relevant documents
search "quarterly goals" > /home/candidates.txt

# 2. Filter and examine
for f in $(cat /home/candidates.txt | head -5); do
  echo "=== $f ===" >> /home/summary.txt
  cat "/qmd/$f" | head -30 >> /home/summary.txt
done

# 3. Output is in /home/summary.txt for the LLM to read back

🤖 Generated with Claude Code

- Add just-bash dependency for virtual filesystem support
- Create src/repl.ts with interactive shell environment
- Mount qmd collections read-only at /qmd/<collection>/
- Writable home directory at /home/
- Custom search and query commands
- Tab completion for files and commands
- --prompt and --file flags to initialize prompt.txt

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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