Skip to content

Add FTS5 project search with dual-backend indexing#21

Merged
heiko-braun merged 6 commits intomainfrom
feat/index
Mar 14, 2026
Merged

Add FTS5 project search with dual-backend indexing#21
heiko-braun merged 6 commits intomainfrom
feat/index

Conversation

@heiko-braun
Copy link
Owner

Summary

  • Add full-text search over the project tree using SQLite FTS5 with two backends: porter-stemmed for natural language and trigram for substring/identifier matching
  • New draft index and draft search CLI commands with incremental indexing (mtime fast-path + xxh3 hashing)
  • Search output formatted as markdown fenced code blocks with language-appropriate syntax highlighting
  • Integrate auto-indexing into /spec and /refine skills, auto-search context into /implement
  • Switch from mattn/go-sqlite3 to modernc.org/sqlite for CGo-free builds
  • Add draft-search rules for both Claude and Cursor agents, synced via draft init

Test plan

  • Run go test ./... — all 45 search tests pass (store, indexer, searcher, project)
  • Run draft index on a project, verify incremental re-index is fast (~50ms)
  • Run draft search "query" and verify markdown fenced output with language tags
  • Run draft init in a fresh directory, verify .claude/rules/draft-search.md and .cursor/rules/draft-search.md are created
  • Run /spec, verify draft index runs after spec write
  • Run /implement, verify search results appear as context

🤖 Generated with Claude Code

heiko-braun and others added 6 commits March 14, 2026 14:03
Implement full-text search over the project tree using SQLite FTS5 with
two backends: porter-stemmed for natural language and trigram for substring
matching. Includes incremental indexing (mtime fast-path + xxh3 hashing),
query classification/routing, BM25 score merging, and CLI commands
(draft index, draft search). Integrates into /spec, /refine, and
/implement skills for automatic indexing and context retrieval.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mattn/go-sqlite3 requires CGO_ENABLED=1 and a C compiler, which breaks
cross-compilation in goreleaser (CGO_ENABLED=0). modernc.org/sqlite is
a pure-Go SQLite implementation that includes FTS5 by default and needs
no build tags or CGo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The sync-templates script copies from .cursor/ (source of truth) into
cmd/draft/templates/.cursor/. The previous commit only updated the
template copies, not the source. This adds the same draft index/search
hooks to the source .cursor/ skills.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ference

detail=none is incompatible with FTS5 trigram tokenizer (trigram matching
relies on phrase queries which require detail=full). Also update driver
reference from mattn/go-sqlite3 to modernc.org/sqlite to match implementation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace flat snippet format with path header + fenced code block using
language tag inferred from file extension. Keeps »« match markers and
score display. Adds langFromExt helper with 40+ extension mappings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Include .claude/rules/ and .cursor/rules/ in template sync so
draft init installs the draft-search usage guide. Updates
findConflicts and sync-templates.sh for both agents.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@heiko-braun heiko-braun merged commit e3de19b into main Mar 14, 2026
1 check passed
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.

1 participant