Skip to content
rachithrrPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

VecSpace

VecSpace is a local-first, zero-infrastructure knowledge workspace for AI agents. It ingests your documents — API references, PDFs, internal specs — into a local SQLite vector database and exposes them to Claude Code (and any MCP-compatible agent) as a queryable knowledge base. No Docker. No cloud. No server to manage. The binary IS the server.

Problems it solves:

  • Pasting docs into context bloats the window and degrades quality past ~30k tokens
  • A flat CLAUDE.md has no retrieval, goes stale, and has no structure
  • Cloud RAG services send private documents externally and require subscriptions

Design principles:

  • Zero infrastructure. No Docker, no cloud, no port to remember. vecspace serve spawns as an MCP child process.
  • Single file storage. All state — chunks, embeddings, metadata — lives in one .db file. Backup = cp. Delete = rm.
  • Private by design. Embeddings are computed locally via Ollama by default. Document content never leaves your machine unless you explicitly configure OpenAI.

Requirements

  • Go 1.22+ with CGO enabled (CGO_ENABLED=1) — required for the sqlite-vec extension
  • Ollama running locally (default) — or an OPENAI_API_KEY if using OpenAI embeddings
  • pdftotext (optional) — for PDF ingestion
# macOS
brew install poppler

# Ubuntu/Debian
apt-get install poppler-utils

Installation

git clone https://github.com/rachithrr/vecspace
cd vecspace
CGO_ENABLED=1 go build -o vecspace ./cmd/vecspace

Move the binary somewhere on your PATH:

mv vecspace /usr/local/bin/vecspace

Verify:

vecspace --help

Quick Start

# 1. Initialize the database and configure your embedding provider
vecspace init

# 2. Add documents to a workspace
vecspace add --workspace payment-docs --url https://developer.nmi.com/docs
vecspace add --workspace payment-docs --pdf ~/Downloads/nmi-reference.pdf

# 3. Query from the CLI to test what the agent will see
vecspace query --workspace payment-docs "what fields are required for a subscription?"

# 4. Check workspace status
vecspace status

Once documents are ingested, add VecSpace to Claude Code (see next section) and the agent can query your workspace mid-session without any manual context pasting.


Claude Code Integration (MCP Setup)

Add VecSpace as an MCP server in ~/.claude/settings.json:

{
  "mcpServers": {
    "vecspace": {
      "command": "vecspace",
      "args": ["serve"],
      "env": {}
    }
  }
}

Claude Code spawns vecspace serve as a child process at session start. The process reads JSON-RPC 2.0 from stdin and writes responses to stdout. All logs go to stderr so they never corrupt the protocol stream.

MCP Tools

VecSpace exposes 7 tools to the agent:

Tool When Claude uses it
list_workspaces At session start, to discover available knowledge and workspace health
search Mid-task, to retrieve relevant context by semantic query
list_documents When asked what sources are in a workspace
get_chunk To expand a search result and read adjacent context
create_or_reuse_workspace Before adding documents — resolves or creates the right workspace
add_document To ingest URLs, text, or chat logs directly from a session
vote After search — reports which chunks were useful, drives health decay

search example:

search(
  query="what fields are required to modify a subscription mid-cycle?",
  workspaces=["payment-docs", "alter-payment-plans"],
  top_k=5,
  rerank=true
)

create_or_reuse_workspace:

Resolves the right workspace before ingestion. Compares the intent description against existing workspace intents via semantic similarity and returns one of three outcomes:

confidence meaning
high similarity ≥ 0.85 — clear match, reuse confirmed
medium similarity 0.60–0.84 — likely match, agent should confirm
"" (empty) similarity < 0.60 — new workspace created
create_or_reuse_workspace(
  intent="NMI payment gateway API reference",
  suggested_name="payment-docs"
)
// → { name: "payment-docs", reused: true, confidence: "high", note: "" }

add_document:

Ingests URLs, text, or chat logs directly from a session. Deduplicates by URL (for source_type=url) or SHA-256 content hash (for text/chat). Auto-assigns doc_class: ephemeral for chat documents and documents in the chats workspace, permanent otherwise.

add_document(
  workspace="chats",
  source_type="chat",
  content="<session transcript>",
  title="debugging session 2026-04-15"
)
// → { doc_id: "chat-abc123", chunk_count: 4, already_exists: false }

vote:

Reports which chunks were useful after a search. Drives chunk suppression and immediate document health recalculation. Pass only chunks you actually used — skip ones you ignored entirely.

vote(
  votes=[
    { chunk_id: "abc", verdict: 10 },
    { chunk_id: "def", verdict: -15 }
  ],
  query_text="how to void a transaction"
)
// → { processed: 2, suppressed_count: 1 }

Accepted verdicts: 10 (helpful) and -15 (unhelpful). Any other value is rejected. Health score on the parent document is recalculated immediately after the call — not deferred to the next decay tick.


Activating the Agent Integration

The MCP connection alone does nothing. Claude sees the tools but will not call them without behavioral instructions. The instructions below tell the agent: check for knowledge before answering, save useful context after a session, and vote on results so the health system self-regulates.

For Claude Code — add to ~/.claude/CLAUDE.md

# VecSpace — knowledge retrieval
At the start of every session, call `list_workspaces` to see what knowledge is available.

When working on a task that involves a known domain (payments, APIs, architecture, etc.):
- Call `search` with the relevant workspaces before answering from memory
- Prefer retrieved context over assumptions

When you find a useful URL or documentation during research:
- Call `create_or_reuse_workspace` with a plain-English intent description
- Call `add_document` to ingest it into that workspace

At the end of a session where significant decisions were made or context was built:
- Call `create_or_reuse_workspace` with intent "chat session logs and decisions"
- Call `add_document` with source_type="chat", content = a distilled summary of what was decided and what context would be useful next time (not a raw transcript)

# VecSpace — vote after every search
After calling `search`, call `vote` with the chunk IDs you actually used.
- verdict: 10 if the chunk directly answered the question or informed your response
- verdict: -15 if the chunk was irrelevant, outdated, or misleading
Omit chunks you skipped entirely. Pass `query_text` for the audit trail.
A chunk is suppressed after vote_score ≤ -30 with ≥ 3 votes.

For Cursor — add to .cursor/rules or cursor_rules.md

Paste the same block above into .cursor/rules in your project root (or cursor_rules.md if your setup uses that convention). The instructions are identical — Cursor reads rules from those files at session start.

For other agents (Windsurf, Copilot, etc.)

Paste the same block into whatever system prompt or rules file that agent reads. The tool names (search, vote, add_document, list_workspaces, etc.) match the MCP tool names VecSpace exposes — they work the same regardless of which agent is calling them.


What happens without this step:

Without instructions With instructions
Session start Agent ignores list_workspaces Agent discovers available workspaces and health
Mid-task Agent answers from training data Agent searches before answering, retrieves relevant context
After search No votes cast Agent votes → health system self-regulates
Session end No knowledge saved Agent saves a distilled summary → knowledge compounds
Health system No signal — everything stagnates Votes drive chunk suppression and document decay

Enforcement Hooks (Claude Code)

CLAUDE.md and cursor rules tell the agent what to do. They are not reliable on their own — agents rationalize skipping rules, treat deferred tools as unavailable, or simply forget to vote. Two Claude Code hooks in ~/.claude/settings.json close this gap by injecting reminders as system-level signals the agent cannot filter out.

Hook 1 — UserPromptSubmit checklist (task c0a03)

What it does: Fires before the agent processes every user turn. Uses an inline printf (no external script, no side effects, 5 s timeout) to emit a [VecSpace Checklist] block as a system-reminder into the conversation:

[VecSpace Checklist] MANDATORY — execute in order:
1. TURN 1: call mcp__vecspace__list_workspaces if not done this session.
2. BEFORE ANY DOMAIN Q: call mcp__vecspace__search on relevant workspaces.
3. AFTER SEARCH: call mcp__vecspace__vote on every chunk you used (+10 helpful / -15 irrelevant).
4. AFTER SUBSTANTIVE TURN: call mcp__vecspace__add_document (source_type=chat) with 3-5 sentence summary.

Where it lives: ~/.claude/settings.json, under hooks.UserPromptSubmit. It is user-global (applies to every Claude Code session on the machine).

Why hooks instead of CLAUDE.md: CLAUDE.md is part of the context window — it can be deprioritized, summarized away, or rationalized past. A UserPromptSubmit hook fires at the harness level and injects output as a system-reminder, which appears adjacent to the user's message where it is hardest to ignore.

Hook 2 — PostToolUse vote reminder (task 102a1)

What it does: Fires immediately after every mcp__vecspace__search call. Reads the tool result from stdin, uses jq recursive descent to extract chunk IDs, and emits a systemMessage requiring the agent to call vote before continuing. If chunk IDs are found in the result they are listed explicitly; otherwise a generic reminder is emitted.

Where it lives:

  • Hook entry: ~/.claude/settings.json, under hooks.PostToolUse, matcher mcp__vecspace__search
  • Script: ~/.claude/hooks/vecspace-vote-reminder.sh (must be executable)

Why voting matters: A chunk is suppressed from future searches after its vote_score ≤ -30 with at least 3 votes. A document is marked dying when more than 80% of its chunks are suppressed. Without consistent voting the health system has no quality signal — everything stagnates at whatever state time-decay leaves it in.

Verifying the hooks are working

Hooks load at session start — restart Claude Code after any change to settings.json or the hook script.

Hook What to look for in a conversation
UserPromptSubmit A [VecSpace Checklist] MANDATORY block appears in a <system-reminder> tag on every turn
PostToolUse / search Immediately after mcp__vecspace__search, a VOTE NOW (mandatory) system message appears before the agent's next response

Smoke-test the vote reminder script directly:

echo '{"tool_name":"mcp__vecspace__search","tool_result":"[{\"chunk_id\":\"abc123\",\"rank\":1}]"}' \
  | bash ~/.claude/hooks/vecspace-vote-reminder.sh
# Expected: {"continue":true,"systemMessage":"VOTE NOW (mandatory): ... Chunk IDs: abc123 ..."}

Setup on a new machine

The hooks are not committed to this repository — they live in your user-global ~/.claude/settings.json. After cloning on a new machine:

1. Add the hook entries to ~/.claude/settings.json:

"hooks": {
  "UserPromptSubmit": [
    {
      "hooks": [
        {
          "type": "command",
          "command": "printf '[VecSpace Checklist] MANDATORY — execute in order:\\n1. TURN 1: call mcp__vecspace__list_workspaces if not done this session.\\n2. BEFORE ANY DOMAIN Q: call mcp__vecspace__search on relevant workspaces.\\n3. AFTER SEARCH: call mcp__vecspace__vote on every chunk you used (+10 helpful / -15 irrelevant).\\n4. AFTER SUBSTANTIVE TURN: call mcp__vecspace__add_document (source_type=chat) with 3-5 sentence summary.'",
          "timeout": 5
        }
      ]
    }
  ],
  "PostToolUse": [
    {
      "matcher": "mcp__vecspace__search",
      "hooks": [
        {
          "type": "command",
          "command": "bash ~/.claude/hooks/vecspace-vote-reminder.sh",
          "timeout": 10
        }
      ]
    }
  ]
}

2. Create the vote reminder script:

mkdir -p ~/.claude/hooks
cat > ~/.claude/hooks/vecspace-vote-reminder.sh << 'EOF'
#!/usr/bin/env bash
input=$(cat)
chunk_ids=$(
  printf '%s' "$input" \
  | jq -r '
      .tool_result
      | if type == "string" then fromjson? // [] else . end
      | [.. | objects | select(has("chunk_id")) | .chunk_id]
      | if length == 0 then empty else join(", ") end
    ' 2>/dev/null
)
if [ -n "$chunk_ids" ]; then
  msg="VOTE NOW (mandatory): Call mcp__vecspace__vote before continuing. Chunk IDs: ${chunk_ids}. Use +1 helpful, -1 irrelevant. Pass query_text. Do not skip."
else
  msg="VOTE NOW (mandatory): Call mcp__vecspace__vote on the chunk IDs returned by the search you just ran. Use +1 helpful, -1 irrelevant. Do not skip."
fi
jq -n --arg m "$msg" '{"continue": true, "systemMessage": $m}'
EOF
chmod +x ~/.claude/hooks/vecspace-vote-reminder.sh

3. Restart Claude Code. Hooks load at session start.

4. Verify using the smoke test command above.


Verify Everything Works

After completing setup (binary installed, MCP registered, hooks added, CLAUDE.md updated), run through this checklist before trusting the system:

1. Server starts cleanly

vecspace serve
# Should hang (waiting for stdin) — that means it started. Ctrl-C to exit.

2. Claude Code picks it up

claude mcp list
# Expected: vecspace listed with status "connected"

Or open a Claude Code session and run /mcp — you should see vecspace with its tools listed.

3. Hook fires on first turn

Open a Claude Code session and send any message. The first response should contain a <system-reminder> block starting with:

[VecSpace Checklist] MANDATORY — execute in order:

If it doesn't appear, check that:

  • ~/.claude/settings.json has the hooks.UserPromptSubmit entry
  • You restarted Claude Code after adding it

4. Vote reminder fires after search

Run a session where the agent calls mcp__vecspace__search. Immediately after the tool result, you should see a system message: VOTE NOW (mandatory): Call mcp__vecspace__vote before continuing.

Smoke-test the script directly:

echo '{"tool_name":"mcp__vecspace__search","tool_result":"[{\"chunk_id\":\"abc123\",\"rank\":1}]"}' \
  | bash ~/.claude/hooks/vecspace-vote-reminder.sh
# Expected: {"continue":true,"systemMessage":"VOTE NOW (mandatory): ... Chunk IDs: abc123 ..."}

5. Health decay is running

vecspace health
# Should show workspace health summaries without errors

6. Votes work end-to-end

# Run a query to see available chunks
vecspace query --workspace <name> "test query"
# Then vote on chunks from a Claude Code session using the mcp__vecspace__vote tool,
# or use vecspace ui to view health scores update after an agent session.

Workspace Lifecycle

Two design principles:

  1. Agents build the knowledge base. Humans only constrain destruction — via prune --confirm, workspace delete --confirm, or manual vecspace remove.
  2. The system self-regulates freshness. Documents degrade naturally when unused; votes accelerate or slow the process. No manual curation required.

Workspace resolution (create_or_reuse_workspace): Before adding any document, the agent calls this tool with a plain-English intent description. VecSpace embeds the intent and compares it against all existing workspace intent embeddings. A high-confidence match reuses the existing workspace; a medium-confidence match returns a note for the agent to confirm; below threshold, a new workspace is created. This prevents accumulation of near-duplicate workspaces over time.

The chats workspace is auto-created on vecspace init with decay_rate=5.0. All documents ingested into it are automatically ephemeral. It is the intended destination for end-of-session chat summaries and session notes. Documents there decay to dead in roughly 20 days without use or votes.


Document Health + Decay

Each document has a doc_class that controls whether it decays:

Class Decay Default for
permanent none — always included in search URLs, PDFs, files
ephemeral time-based — excluded when health reaches 0 Chat logs, session notes

Health formula:

Ephemeral documents start at health 100. Each day without use or votes they lose points equal to their decay_rate. Upvotes (+10) and active use (+5) slow decay. Downvotes (-15) accelerate it. Health is clamped to [0, 100].

Decay rate inheritance: When a document is ingested, it copies decay_rate from its workspace. Changing a workspace's decay_rate after ingestion does not affect existing documents — only new ingestions pick up the new rate.

Status thresholds:

Status Health range Search behavior
active ≥ 60 Included
degraded 30–59 Included
dying 1–29 Included
dead 0 Excluded

Dying documents are still searchable — they can recover with upvotes. Only dead documents are excluded from search and eligible for pruning.

Decay runs lazily on vecspace status, vecspace health, and vecspace query (no-op if already ran within the last hour), and on a 24-hour background tick while vecspace serve is running.


Voting

Without votes, the system decays by time alone. Votes are what make it self-regulate on quality, not just recency — surfacing docs that stay useful and suppressing ones that generate noise.

Vote values: 10 (helpful) and -15 (unhelpful). These are the raw weight values, not sentinels — any other integer is rejected.

Suppression: A chunk is suppressed (excluded from future search results) when its vote_score ≤ -30 with at least 3 total votes. Two downvotes (-15 × 2 = -30) with one additional vote of any kind triggers suppression. A document is marked dying when more than 80% of its chunks are suppressed.

Immediate health impact: Voting recalculates the parent document's health score immediately (not deferred to the next decay tick). Upvotes slow decay; downvotes accelerate it.

Add this to your CLAUDE.md so the agent votes automatically after every search:

# VecSpace — vote after every search
After calling `search`, call `vote` with the chunk IDs you actually used.
- verdict: 10 if the chunk directly answered the question or informed your response
- verdict: -15 if the chunk was irrelevant, outdated, or misleading
Omit chunks you skipped entirely. Pass `query_text` for audit trail.

A chunk is suppressed after vote_score ≤ -30 with ≥ 3 votes.
A document is marked dying when >80% of its chunks are suppressed.

Without this snippet, votes must be cast manually or via explicit agent instructions.


CLI Reference

vecspace init

Initialize the database and configuration. Interactive on first run — prompts for embedding provider and model. Safe to re-run (idempotent).

vecspace init

Providers available:

  • ollama (default) — fully local, no API key
  • llamacpp — local llama.cpp HTTP API
  • openai — remote, requires OPENAI_API_KEY

Default models: nomic-embed-text (768 dims) for Ollama/llama.cpp, text-embedding-3-small (1536 dims) for OpenAI.


vecspace add

Ingest a document into a workspace. The workspace is created automatically if it doesn't exist. Re-ingesting unchanged content is a no-op (deduplication by SHA-256).

# From a URL (fetched via Jina Reader — returns clean markdown)
vecspace add --workspace <name> --url <url> [--doc-id <slug>] [--title <title>]

# From a PDF file
vecspace add --workspace <name> --pdf <path> [--doc-id <slug>] [--title <title>]

# From a text or markdown file
vecspace add --workspace <name> --file <path> [--doc-id <slug>] [--title <title>]

# Inline text
vecspace add --workspace <name> --text "..." [--doc-id <slug>] [--title <title>]

Exactly one of --url, --pdf, --file, or --text must be provided.


vecspace remove

Delete a document and all its chunks atomically.

vecspace remove --workspace <name> --doc <doc-id>

vecspace query

Search one or more workspaces from the CLI. Useful for testing what the agent will see.

vecspace query --workspace <name> [--workspace <name2>] [--top-k N] [--rerank] "<question>"

--rerank blends vector scores with BM25 full-text scores (~50ms overhead, better precision for exact-term queries).


vecspace status

Show database path, size, embedding configuration, and per-workspace doc/chunk counts. Runs lazy health decay.

vecspace status

vecspace health

Show document health and decay status. Runs lazy decay before displaying results.

# Summary across all workspaces
vecspace health

# Per-document breakdown for a specific workspace
vecspace health --workspace chats

The per-workspace view shows doc ID, title, health score (0–100), status, last-used date, and vote tallies. Dead documents are listed first so they're easy to spot before pruning.


vecspace prune

Delete dead (health=0) documents from a workspace. Without --confirm, shows a dry-run preview of what would be deleted.

# Dry-run: show what would be pruned
vecspace prune --workspace chats

# Delete dead documents from a workspace
vecspace prune --workspace chats --confirm

# Prune dead documents from all workspaces at once
vecspace prune --all --confirm

dying documents (health 1–29) are NOT deleted — they can still recover with upvotes.


vecspace unsuppress

Clear chunk suppression for a document. Sets suppressed=0 on all chunks belonging to the specified document, making them eligible for search again.

vecspace unsuppress --workspace payment-docs --doc nmi-api

Both --workspace and --doc are required.


vecspace boost

Manually set the health score for a document. Resets the decay baseline so the next decay run starts fresh from the new value.

vecspace boost --workspace chats --doc chat-session-42 --health 80

--health must be 0–100. If the document is permanent, a warning is printed — permanent documents don't participate in decay, so the boost has no effect on search inclusion.


vecspace workspace

vecspace workspace list                      # List all workspaces with doc/chunk counts
vecspace workspace describe <name>           # Show documents in a workspace
vecspace workspace delete <name> --confirm   # Delete workspace and all its contents

vecspace remove-workspace

Alias for workspace delete.

vecspace remove-workspace <name> --confirm

vecspace re-embed

Re-embed all chunks in a workspace using the current model. Required after changing embedding_provider or embedding_model. Prompts for confirmation before proceeding. Chunk text is preserved; only vectors are replaced.

vecspace re-embed --workspace <name>

vecspace serve

Start the MCP stdio server. This is what Claude Code invokes — you do not run it directly during normal use; Claude Code launches it as a child process via the MCP config.

vecspace serve takes no CLI flags. Configure it with environment variables:

Env var Default Effect
VECSPACE_DB_PATH ~/.vecspace/store.db Path to the SQLite database
VECSPACE_EMBEDDING_PROVIDER ollama ollama, llamacpp, or openai
VECSPACE_OLLAMA_URL http://localhost:11434 Ollama API base URL

Pass env vars through the MCP config env block:

{
  "mcpServers": {
    "vecspace": {
      "command": "vecspace",
      "args": ["serve"],
      "env": {
        "VECSPACE_DB_PATH": "/path/to/your/store.db"
      }
    }
  }
}
vecspace serve

vecspace ui

Start the web UI and open it in your browser.

vecspace ui [--port 6666] [--dev]

If the requested port is in use, tries the next three ports in sequence (6666 → 6667 → 6668 → 6669). --dev serves UI files from ./ui/ on disk instead of the embedded bundle.


vecspace skill ingest

Parse and ingest skill .md files into a workspace for semantic retrieval.

vecspace skill ingest --path <file-or-directory> [--workspace skills]

Accepts a single file or a directory of .md files. Modified files are re-indexed automatically (tracked by SHA-256 hash). The workspace defaults to skills.


vecspace skill list

List ingested skills in a workspace.

vecspace skill list [--workspace skills]

Web UI

vecspace ui

Opens at http://localhost:6666. The UI is embedded in the binary — no Node.js, no npm, no separate build step.

Six views:

View What it does
Workspaces List all workspaces with doc/chunk counts and health status indicators; create new ones
Workspace Detail List documents, ingest new ones with progress tracking, delete individual docs
Query Search across workspaces interactively, view ranked results with scores and source refs
Document Chunks Paginated view of all chunks in a document with section headings and token counts
Health Per-workspace health dashboard: document health scores, vote tallies, suppressed chunk counts, prune action
Settings Adjust chunk size, overlap, and default top-k; view embedding config and DB stats

Workspace cards show health status breakdowns (active / degraded / dying / dead). A duplicate workspace detection banner appears when create_or_reuse_workspace returns a medium-confidence match, prompting you to confirm reuse or proceed with a new workspace.


End-to-End Agent Flow

A typical agent session using all workspace memory features:

1. list_workspaces
   → discovers "payment-docs" (active), "chats" (decay_rate=5.0)

2. search(query="how to void a transaction", workspaces=["payment-docs"], top_k=5)
   → returns 5 ranked chunks from the nmi-api document

3. vote(votes=[{chunk_id: "abc", verdict: 10}, {chunk_id: "def", verdict: -15}],
        query_text="how to void a transaction")
   → processed: 2 — chunk "def" vote_score reached -30 with ≥3 votes, now suppressed

4. create_or_reuse_workspace(
     intent="notes from today's void-transaction debugging session",
     suggested_name="debug-2026-04-15")
   → confidence: "", reused: false — new workspace created

5. add_document(
     workspace="debug-2026-04-15",
     source_type="chat",
     content="<session transcript>",
     title="void transaction debugging")
   → doc_id: "chat-abc123", chunk_count: 4, already_exists: false

6. (At session end) add_document to "chats" with a summary of the session
   → ephemeral, decay_rate=5.0; decays to dead in ~20 days without reuse or votes

At any point: vecspace health --workspace chats to see what's still alive, vecspace prune --workspace chats --confirm to clean up what's dead.


Skill Migration

The problem: Static skill loading (load_skill(["chart"])) injects the entire skill file — 5–10k tokens — regardless of how much of it the task actually needs. Three skills loaded at session start burns 30k tokens before any real work begins.

The solution: Index skills into VecSpace and let the agent fetch only the sections it needs via skill_lookup.

Before After
Token cost ~10k per skill, loaded upfront ~1–1.5k, fetched on demand
Granularity Entire file Matching sections only
Updates Manual file edits Re-ingest detects changes via hash

Ingest your skills:

vecspace skill ingest --path ~/.claude/skills/

Each ##-level section becomes a separate chunk with the skill name and section heading embedded in the text. The agent calls skill_lookup("stacked bar chart plotly") and gets back only the relevant chunks within a ~1500-token budget.

Deprecating static skill loading: Remove skill file paths from your Claude Code MCP config or settings.json after ingestion. The agent will use skill_lookup instead.


Configuration Reference

Configuration is read in this order: environment variable (highest) → database config table → compiled default.

Key Default Env Var Override Description
embedding_provider ollama VECSPACE_EMBEDDING_PROVIDER ollama, llamacpp, or openai
embedding_model nomic-embed-text — Model name passed to the provider
embedding_dimensions 768 — Must match the model's output dimensions
ollama_base_url http://localhost:11434 VECSPACE_OLLAMA_URL Ollama API base URL
chunk_size_tokens 400 — Maximum tokens per chunk
chunk_overlap_tokens 50 — Token overlap between adjacent chunks
default_top_k 5 — Default number of results returned by search

Database path: ~/.vecspace/store.db — override with VECSPACE_DB_PATH.

To use a different embedding provider for a separate project without touching your default config:

VECSPACE_DB_PATH=~/projects/work.db vecspace init
VECSPACE_DB_PATH=~/projects/work.db vecspace add --workspace ...

Known Limitations

Single embedding model per database. All documents in a database must use the same embedding model. Vectors from different models are not comparable. To experiment with a different model, point VECSPACE_DB_PATH at a new file.

No real-time URL monitoring. VecSpace ingests a URL once. If the source changes, re-run vecspace add — the content hash will detect the change and update the chunks automatically.

sqlite-vec KNN is brute-force. sqlite-vec uses exact nearest-neighbor search (no HNSW approximate index). Under ~100k chunks per workspace this is fast enough (<100ms). Most developer workspaces — a few dozen documents — will never approach this limit.

PDF quality depends on the source. Multi-column layouts, scanned PDFs, and table-heavy documents produce degraded extraction. Verify results with vecspace query before relying on a PDF source.

Ollama must be running during ingestion and query. VecSpace gives a clear error if the provider is unreachable. Pre-embedded documents do not require Ollama to be running during CLI queries (the query itself still needs embedding).

Local only, no access control. VecSpace is a single-user tool. The MCP server has no authentication. Do not expose vecspace serve over a network interface.


Building and Contributing

CGO is required because sqlite-vec is a C extension compiled into the binary at build time. Without it, the vector index is unavailable.

# Build
CGO_ENABLED=1 go build -o vecspace ./cmd/vecspace

# Run tests
go test ./...

Project layout:

cmd/vecspace/       CLI entry point and all subcommands
internal/
  chunk/            Token-based document chunking
  config/           Config load/save with env var override
  domain/           Shared types and constants
  embedding/        Provider interface + Ollama/llama.cpp/OpenAI impls
  extract/          URL fetch, PDF extraction, file reading
  health/           Health decay engine and background ticker
  ingest/           End-to-end ingestion pipeline
  mcp/              MCP stdio server and tool handlers
  query/            Vector search + BM25 re-ranking
  skill/            Skill .md parser and ingestion
  store/            SQLite schema, migrations, all DB queries
  ui/               REST API server and embedded web UI
  vote/             Chunk vote recording and suppression logic
  workspace/        Workspace resolver (semantic dedup)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages