Repository navigation
Expand file tree
/
Copy pathprd.json
More file actions
62 lines (62 loc) · 6.27 KB
/
Copy pathprd.json
File metadata and controls
62 lines (62 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
"version": "1.0",
"projectName": "pdf-library",
"description": "Database adapter scheme and configurable embeddings for pdf-brain",
"stories": [
{
"id": "story-mlioqrd9",
"title": "Database adapter registry with config-driven backend selection",
"description": "Create a DatabaseRegistry that selects the Database implementation based on config. \n\nCurrently LibSQLDatabase.make() is hardcoded throughout. Instead:\n\n1. Add `database.backend` to config schema in types.ts (values: \"libsql\" | \"qdrant\") with \"libsql\" as default\n2. Add `database.qdrant` config section: `{ url: string, collection: string, apiKey?: string }`\n3. Create `src/services/DatabaseRegistry.ts` that reads config and returns the appropriate Database Layer:\n - \"libsql\" → existing LibSQLDatabase.make(config)\n - \"qdrant\" → QdrantDatabase.make(config) (stub for now, will implement in next story)\n4. Update `src/cli.ts` and `src/index.ts` to use DatabaseRegistry instead of directly constructing LibSQLDatabase\n5. Update `src/agent/protocol.ts` if it constructs Database directly\n\nThe config should be read from PDF_BRAIN_CONFIG env var or ~/.config/pdf-brain/config.json. Extend the existing loadConfig() in types.ts.\n\nKeep backward compatible — if no config exists, default to libsql with existing behavior.",
"priority": 1,
"passes": true,
"validationCommand": "cd /home/joel/Code/joelhooks/pdf-library && bun test 2>&1 | grep -E '(pass|fail)' | tail -5",
"targetFiles": [
"DatabaseRegistry.ts",
"types.ts",
"cli.ts"
]
},
{
"id": "story-mlioqs85",
"title": "Qdrant Database adapter implementing Database interface",
"description": "Implement `src/services/QdrantDatabase.ts` that implements the full Database interface using Qdrant as the vector store + metadata backend.\n\nArchitecture:\n- Use `@qdrant/js-client-rest` npm package for Qdrant HTTP API\n- Documents stored as points in a \"documents\" collection (metadata as payload, no vector)\n- Chunks stored as points in a \"chunks\" collection with embeddings as vectors\n- Document metadata (title, path, tags, pageCount, etc.) stored in Qdrant point payloads\n- Use Qdrant's filtering for document lookups, tag queries, etc.\n- vectorSearch maps directly to Qdrant's search endpoint\n- ftsSearch uses Qdrant's full-text index on chunk content field\n\nImplementation notes:\n- Collection auto-creation on first use (with configurable vector dimension from embedding config)\n- Batch operations for addChunks/addEmbeddings (Qdrant supports upsert batches)\n- replaceDocument: delete existing points by docId filter, then insert new ones\n- streamEmbeddings: use Qdrant scroll API with pagination\n- getExpandedContext: filter chunks by docId + page, sort by chunkIndex, concatenate\n- repair: scan for orphaned chunks (docId not in documents collection)\n- checkpoint/dumpDataDir: no-op for Qdrant (it handles persistence internally)\n\nConfig from DatabaseRegistry:\n```\ndatabase: {\n backend: \"qdrant\",\n qdrant: {\n url: \"http://localhost:6333\",\n collection: \"pdf-brain\", \n apiKey: \"optional\"\n }\n}\n```\n\nAdd `@qdrant/js-client-rest` to dependencies in package.json.\nWrite tests in QdrantDatabase.test.ts that mock the Qdrant client.",
"priority": 2,
"passes": true,
"validationCommand": "cd /home/joel/Code/joelhooks/pdf-library && bun test 2>&1 | grep -E '(pass|fail)' | tail -5",
"targetFiles": [
"QdrantDatabase.ts",
"package.json"
]
},
{
"id": "story-mlioqsz6",
"title": "OpenAI embedding adapter for EmbeddingProvider",
"description": "Add OpenAI as a third embedding provider option. Minimal changes to two existing files.\n\nIn src/types.ts:\n- Add \"openai\" to embedding.provider union: \"ollama\" | \"gateway\" | \"openai\"\n- Add embedding.openai config: { apiKey?: string, model?: string, baseUrl?: string }\n- Default model: \"text-embedding-3-small\"\n\nIn src/services/EmbeddingProvider.ts:\n- Add an inline OpenAI embed implementation (no separate file needed):\n - Use fetch() to POST to https://api.openai.com/v1/embeddings (or baseUrl)\n - Headers: Authorization Bearer from config or OPENAI_API_KEY env\n - embed(): single text, return embedding array\n - embedBatch(): send array of texts in one request (OpenAI supports batch)\n - checkHealth(): test embed with \"test\"\n- Route to it when provider === \"openai\" in EmbeddingProviderLive\n- Update EmbeddingProviderFullLive for the openai case",
"priority": 3,
"passes": true,
"validationCommand": "cd /home/joel/Code/joelhooks/pdf-library && bun test 2>&1 | grep -E '(pass|fail)' | tail -5",
"targetFiles": [
"EmbeddingProvider.ts",
"types.ts"
]
},
{
"id": "story-mlioqto5",
"title": "Network listener config for Tailscale/remote access",
"description": "Make the MCP server and any HTTP endpoints configurable for network access (not just localhost).\n\n1. Update config schema with `server` section:\n ```\n server: {\n host: \"0.0.0.0\", // default: \"127.0.0.1\" for local-only\n port: 3838, // default port\n auth: {\n enabled: false,\n token?: string // simple bearer token auth\n }\n }\n ```\n\n2. Update `src/agent/protocol.ts` (MCP server) to respect host/port config\n3. Add simple bearer token middleware if auth.enabled\n4. Add `pdf-brain serve` CLI command that starts the MCP server with network config\n - `--host` and `--port` CLI flags override config\n - `--auth-token` flag for quick token setup\n5. Update README with Tailscale usage example:\n ```\n # On clanker-001 (Tailscale)\n pdf-brain serve --host 0.0.0.0 --port 3838\n \n # From Mac\n pdf-brain search \"query\" --remote http://clanker-001:3838\n ```\n\nThis enables serving pdf-brain over Tailscale network so other machines can query it.",
"priority": 4,
"passes": true,
"validationCommand": "cd /home/joel/Code/joelhooks/pdf-library && bun test 2>&1 | grep -E '(pass|fail)' | tail -5",
"targetFiles": [
"protocol.ts",
"cli.ts",
"types.ts"
]
}
],
"metadata": {
"createdAt": "2026-02-11T23:52:26.179Z",
"totalIterations": 4,
"lastIteration": "2026-02-12T00:32:42.172Z"
}
}