Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9d7ff1d
Add .beads/ to .gitignore
ddebowczyk Dec 9, 2025
1d1fa25
Fix: Replace embeddinggemma with nomic-embed-text and add model confi…
ddebowczyk Dec 9, 2025
01f2fe2
Docs: Update README with correct embedding models and configuration
ddebowczyk Dec 9, 2025
dea3e68
Add --version command to display qmd version
ddebowczyk Dec 9, 2025
94b84fa
Fix: Remove terminal escape codes from progress output when not TTY
ddebowczyk Dec 9, 2025
167946b
Add comprehensive TypeScript refactoring plan
ddebowczyk Dec 9, 2025
22ebb67
Phase 1.1: Extract TypeScript types to src/models/types.ts
ddebowczyk Dec 9, 2025
d901cf0
Add V2 refactoring plan with oclif CLI framework
ddebowczyk Dec 9, 2025
911dd78
Phase 0: Set up oclif CLI framework
ddebowczyk Dec 9, 2025
42478e4
Phase 1.2: Extract formatter utilities
ddebowczyk Dec 9, 2025
4ec638a
Phase 1.3: Extract utilities and configuration
ddebowczyk Dec 9, 2025
6313543
Phase 2: Extract database layer with repositories
ddebowczyk Dec 9, 2025
a85a919
Phase 3: Extract services layer
ddebowczyk Dec 9, 2025
2247eb6
Add comprehensive refactoring summary
ddebowczyk Dec 9, 2025
ed43e5e
Add GetCommand and VSearchCommand
ddebowczyk Dec 9, 2025
afc638e
Complete oclif command migration (7/8 core commands)
ddebowczyk Dec 9, 2025
9c41afa
βœ… Option B Complete: Deprecate qmd.ts monolith
ddebowczyk Dec 9, 2025
4822d49
Final cleanup: Remove empty directories and document architecture
ddebowczyk Dec 9, 2025
7affb9e
Add GitHub Actions CI/CD workflow
ddebowczyk Dec 9, 2025
9c1f5a2
Phase 1: Test Infrastructure Setup
ddebowczyk Dec 9, 2025
b8ab344
Phase 2: Test Utils Layer (hash.ts, paths.ts)
ddebowczyk Dec 9, 2025
efec718
Phase 3: Test Config & Models Layer
ddebowczyk Dec 9, 2025
49a2c37
Phase 4: Test Database (db.ts) - Schema, Migrations, Vector Tables
ddebowczyk Dec 9, 2025
79d7459
Phase 4: Test Repositories (documents) + SQL Injection Prevention
ddebowczyk Dec 9, 2025
7b263f0
Phase 4: Test Repositories (collections) + SQL Injection
ddebowczyk Dec 9, 2025
82430fb
Add qmd init and qmd doctor commands
ddebowczyk Dec 9, 2025
a230868
Phase 4: Test Repositories (path-contexts.ts)
ddebowczyk Dec 9, 2025
7dcc2a2
Phase 4: Test Repositories (vectors.ts)
ddebowczyk Dec 9, 2025
a3bedd2
Phase 4: Test Database Exports
ddebowczyk Dec 9, 2025
ad8f551
Implement .qmd/ directory auto-detection for project-local indexes
ddebowczyk Dec 9, 2025
95d9082
Phase 5: Test Services (ollama.ts)
ddebowczyk Dec 9, 2025
6467162
Add qmd update command for re-indexing collections
ddebowczyk Dec 9, 2025
ec124cb
Phase 5: Test Services (embedding.ts)
ddebowczyk Dec 9, 2025
67c7478
Phase 5: Test Services (search.ts)
ddebowczyk Dec 9, 2025
2f3d4ae
Phase 5: Test Services (reranking.ts, indexing.ts)
ddebowczyk Dec 9, 2025
9906389
Phase 5 Complete: Test Services Index
ddebowczyk Dec 9, 2025
3558497
Phase 8: GitHub Actions CI/CD Workflow
ddebowczyk Dec 9, 2025
eda5308
Add comprehensive documentation to docs/
ddebowczyk Dec 9, 2025
2b6b710
Improve glob pattern handling to prevent shell expansion issues
ddebowczyk Dec 9, 2025
0a884ef
Phase 6 Complete: Test Commands Layer
ddebowczyk Dec 9, 2025
2af048a
Phase 7: E2E Integration Tests Complete
ddebowczyk Dec 9, 2025
3662c0e
Implement search history tracking (queries only)
ddebowczyk Dec 9, 2025
6fbb70f
Fix type-database mismatches across all entity types
ddebowczyk Dec 9, 2025
cb54c5c
Add missing database indexes for performance
ddebowczyk Dec 9, 2025
5adbe6e
Add Zod schema validation for runtime type safety
ddebowczyk Dec 9, 2025
d969875
Move search history from file to database
ddebowczyk Dec 9, 2025
c741767
Refactor to structured migration system
ddebowczyk Dec 9, 2025
85bfded
Add data integrity checks to doctor command
ddebowczyk Dec 9, 2025
417b11d
Implement unified configuration system (Option A)
ddebowczyk Dec 9, 2025
0cbe158
Add cleanup command for soft-deleted documents
ddebowczyk Dec 9, 2025
64fc705
Add performance optimizations (ANALYZE, batch operations)
ddebowczyk Dec 9, 2025
dbe59fa
Archive Kysely POC to research/archive/2025-12-kysely-poc
ddebowczyk Dec 9, 2025
7ab598d
Fix: Replace Bun.spawnSync with native realpathSync for better perfor…
ddebowczyk Dec 11, 2025
e60c45d
Add build infrastructure and document compilation limitations
ddebowczyk Dec 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Use bd merge for beads JSONL files
.beads/issues.jsonl merge=beads
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Run tests
run: bun test

- name: Run tests with coverage
run: bun test --coverage
continue-on-error: true
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ node_modules/
archive/
texts/
.cursor/
research/
*.md
!README.md
!docs/dev/README.md
!CLAUDE.md
!BUILD.md
!*PLAN*.md
!*STRATEGY*.md
!*SUMMARY*.md
!docs/dev/ARCHITECTURE.md
!SQL_SAFETY.md
!docs/**/*.md
.beads/
builds/
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/qmd.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 121 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# QMD Build Process

## TL;DR: Compilation Doesn't Work

❌ **`bun build --compile` does NOT work for QMD**
βœ… **Use the existing shell wrapper approach**

## What We Tested

### Test 1: Compiled Binary (`bun run build`)
```bash
bun build bin/run --compile --outfile builds/qmd
```

**Result:**
- βœ… Binary created (101MB)
- βœ… Runs without errors (exit code 0)
- ❌ **Produces NO output**
- ❌ All commands fail silently

**Issue:** Bun's `--compile` flag doesn't properly handle oclif's dynamic imports and output streams.

### Test 2: Bundled Version (`bun run build:bundle`)
```bash
bun build bin/run --target bun --outdir builds
```

**Result:**
- ❌ Doesn't properly bundle the code
- Creates only a stub file with asset reference
- oclif's dynamic command loading isn't compatible with Bun's bundler

## Why Compilation Fails

1. **oclif uses dynamic imports** for command discovery
2. **stdout/stderr handling** in compiled Bun binaries has issues
3. **Bun's bundler** can't properly handle oclif's architecture
4. **Not specifically a sqlite-vec issue** - the entire binary doesn't work

## Working Solution: Current Setup

The existing setup works perfectly:

```
./qmd (shell wrapper)
↓
bin/run (Bun script)
↓
@oclif/core
↓
src/commands/*
```

**Benefits:**
- βœ… All features work (including sqlite-vec)
- βœ… Fast startup time
- βœ… Easy debugging
- βœ… Simple updates

## Distribution Options

### Option 1: Require Bun on Target Machine (Recommended)
```bash
# On target machine:
curl -fsSL https://bun.sh/install | bash
git clone <repo>
cd qmd
bun install
bun link # or use ./qmd directly
```

**Pros:**
- Everything works
- Bun installs in seconds
- sqlite-vec works perfectly

### Option 2: Docker Container
```dockerfile
FROM oven/bun:1
WORKDIR /app
COPY . .
RUN bun install
ENTRYPOINT ["./qmd"]
```

**Pros:**
- Portable across machines
- No Bun installation needed on host
- Consistent environment

### Option 3: Package Manager Installation
Publish to npm/bun registry with Bun as peer dependency.

## Build Scripts

Available in `package.json`:

```bash
bun run build # Compile binary (doesn't work)
bun run build:bundle # Bundle code (doesn't work)
```

These are included for testing/experimentation, but **not recommended for production use**.

## Conclusion

**For now, stick with the shell wrapper approach.** It's simple, works perfectly, and requires minimal dependencies (just Bun).

If Bun improves `--compile` support for oclif in the future, we can revisit this.

## Testing Results

- **Compiled binary**: Exits with code 0 but produces no output
- **Regular wrapper**: Full output with formatting βœ“
- **sqlite-vec**: Works in regular setup, untestable in compiled binary (no output at all)

---

**Last Updated:** 2025-12-11
**Bun Version:** 1.3.0
**oclif Version:** 4.8.0
57 changes: 50 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ Use Bun instead of Node.js (`bun` not `node`, `bun install` not `npm install`).
## Commands

```sh
qmd init # Initialize .qmd/ directory for project-local index
qmd doctor # Check system health and diagnose issues
qmd add . # Index markdown files in current directory
qmd update # Re-index all collections
qmd update <id> # Re-index specific collection by ID
qmd status # Show index status and collections
qmd update-all # Re-index all collections
qmd embed # Generate vector embeddings (requires Ollama)
qmd search <query> # BM25 full-text search
qmd vsearch <query> # Vector similarity search
Expand All @@ -25,17 +28,57 @@ bun link # Install globally as 'qmd'

- SQLite FTS5 for full-text search (BM25)
- sqlite-vec for vector similarity search
- Ollama for embeddings (embeddinggemma) and reranking (qwen3-reranker)
- Ollama for embeddings (nomic-embed-text) and reranking (qwen3-reranker)
- Reciprocal Rank Fusion (RRF) for combining results
- Project-local indexes via `.qmd/` directory (like `.git/`)

## Index Location Priority

QMD searches for indexes in this order:
1. **`.qmd/` directory** - Walks up from current directory (project-local)
2. **`QMD_CACHE_DIR`** - Environment variable for custom location
3. **`~/.cache/qmd/`** - Global default (respects `XDG_CACHE_HOME`)

Example workflows:
```sh
# Project-local index (recommended)
qmd init # Creates .qmd/ directory
qmd add . # Uses .qmd/default.sqlite

# Custom location via environment variable
export QMD_CACHE_DIR=/custom/path
qmd add . # Uses /custom/path/default.sqlite

# Global index (no .qmd/ in tree)
qmd add ~/Documents/notes # Uses ~/.cache/qmd/default.sqlite
```

## Important: Do NOT run automatically

- Never run `qmd add`, `qmd add-context`, `qmd embed`, or `qmd update-all` automatically
- Never run `qmd add`, `qmd init`, or `qmd embed` automatically
- Never modify the SQLite database directly
- Write out example commands for the user to run manually
- Index is stored at `~/.cache/qmd/index.sqlite`
- Index location: `.qmd/` (project-local) or `~/.cache/qmd/` (global default)

## Build & Distribution

### ⚠️ Compilation Does NOT Work
- **Never use `bun build --compile`** - produces a binary that runs but outputs nothing
- Not specifically a sqlite-vec issue - oclif's dynamic imports aren't compatible with Bun's compiler
- See `BUILD.md` for detailed testing results

### βœ… Working Distribution Methods
1. **Install Bun on target machine** (recommended)
```sh
curl -fsSL https://bun.sh/install | bash
git clone <repo> && cd qmd && bun install
```
2. **Docker container** - packages everything including Bun runtime
3. **Package manager** - publish with Bun as peer dependency

## Do NOT compile
### Build Scripts (For Testing Only)
- `bun run build` - Creates compiled binary (doesn't work)
- `bun run build:bundle` - Attempts bundling (doesn't work)
- `./builds/` directory is git-ignored

- Never run `bun build --compile` - it overwrites the shell wrapper and breaks sqlite-vec
- The `qmd` file is a shell script that runs `bun qmd.ts` - do not replace it
The shell wrapper approach (`./qmd` β†’ `bin/run`) is the correct solution.
Loading