docs-haven 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ .venv/
5
+ venv/
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+ *.db
10
+ *.db-journal
11
+ *.db-wal
12
+ *.db-shm
13
+ .cache/
14
+ .pytest_cache/
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+ .docshaven/
18
+ .docshaven-sync/
19
+ .env
20
+ .env.*
21
+ *.log
22
+ .repowise/
CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to DocsHaven will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.0] - 2026-07-16
8
+
9
+ ### Added
10
+ - SQLite FTS5 search engine (replaces QMD dependency)
11
+ - BM25 full-text search with LIKE fallback
12
+ - Auto strategy selection (fts/hybrid by query length)
13
+ - Document chunking for better search precision
14
+ - Type-aware result boosting
15
+ - URI routing (core://, ref://, guide://, lib://, src://, test://, note://)
16
+ - Git sync with compressed chunks (no merge conflicts)
17
+ - Conflict detection when adding documents
18
+ - MCP server with 15 tools
19
+ - MIT license
20
+ - pytest test suite
21
+
22
+ ### Changed
23
+ - Storage backend: QMD → SQLite FTS5 (zero external dependencies)
24
+ - Search: FTS5 + LIKE fallback (pattern from mcp-ariel-memory)
25
+ - Conflicts: now uses Storage.search() instead of QMD CLI
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,41 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to a positive environment:
15
+
16
+ * Using welcoming and inclusive language
17
+ * Being respectful of differing viewpoints and experiences
18
+ * Gracefully accepting constructive criticism
19
+ * Focusing on what is best for the community
20
+ * Showing empathy towards other community members
21
+
22
+ Examples of unacceptable behavior:
23
+
24
+ * The use of sexualized language or imagery and unwelcome sexual attention
25
+ * Trolling, insulting or derogatory comments, and personal or political attacks
26
+ * Public or private harassment
27
+ * Publishing others' private information without explicit permission
28
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
29
+
30
+ ## Enforcement
31
+
32
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
33
+ reported to the project maintainer. All complaints will be reviewed and
34
+ investigated and will result in a response that is deemed necessary and
35
+ appropriate to the circumstances.
36
+
37
+ ## Attribution
38
+
39
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
40
+ version 2.0, available at
41
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
CONTRIBUTING.md ADDED
@@ -0,0 +1,47 @@
1
+ # Contributing to DocsHaven
2
+
3
+ Thank you for your interest in contributing!
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/Cipher208/docs-haven.git
9
+ cd docs-haven
10
+ pip install -e ".[test]"
11
+ ```
12
+
13
+ ## Running Tests
14
+
15
+ ```bash
16
+ pytest tests/ -v
17
+ ```
18
+
19
+ ## Code Quality
20
+
21
+ ```bash
22
+ ruff check .
23
+ ruff format --check .
24
+ mypy uri.py storage.py sync.py conflicts.py server.py --ignore-missing-imports
25
+ ```
26
+
27
+ ## Pull Request Process
28
+
29
+ 1. Fork the repository
30
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
31
+ 3. Make your changes
32
+ 4. Run tests (`pytest tests/ -v`)
33
+ 5. Run linting (`ruff check .`)
34
+ 6. Commit your changes (`git commit -m 'Add amazing feature'`)
35
+ 7. Push to the branch (`git push origin feature/amazing-feature`)
36
+ 8. Open a Pull Request
37
+
38
+ ## Code Style
39
+
40
+ - Use ruff for linting and formatting
41
+ - Follow PEP 8
42
+ - Add docstrings to public functions
43
+ - Keep functions focused and small
44
+
45
+ ## Reporting Issues
46
+
47
+ Use the [GitHub issue tracker](https://github.com/Cipher208/docs-haven/issues) to report bugs or request features.
LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DocsHaven Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
PKG-INFO ADDED
@@ -0,0 +1,344 @@
1
+ Metadata-Version: 2.4
2
+ Name: docs-haven
3
+ Version: 0.1.0
4
+ Summary: Local knowledge base for AI agents with SQLite FTS5 search, URI routing, and conflict detection
5
+ Project-URL: Homepage, https://github.com/Cipher208/docs-haven
6
+ Project-URL: Documentation, https://github.com/Cipher208/docs-haven/tree/main/docs
7
+ Project-URL: Repository, https://github.com/Cipher208/docs-haven
8
+ Project-URL: Issues, https://github.com/Cipher208/docs-haven/issues
9
+ Project-URL: Changelog, https://github.com/Cipher208/docs-haven/blob/main/CHANGELOG.md
10
+ Author: DocsHaven Contributors
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: ai-agent,fts5,knowledge-base,mcp,rag,search
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: mcp[cli]>=1.0.0
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'test'
27
+ Requires-Dist: pytest-timeout>=2.0; extra == 'test'
28
+ Requires-Dist: pytest>=7.0; extra == 'test'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # DocsHaven
32
+
33
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
34
+ [![GitHub stars](https://img.shields.io/github/stars/Cipher208/docs-haven)](https://github.com/Cipher208/docs-haven/stargazers)
35
+ [![GitHub last commit](https://img.shields.io/github/last-commit/Cipher208/docs-haven)](https://github.com/Cipher208/docs-haven/commits/main)
36
+ [![CI](https://github.com/Cipher208/docs-haven/actions/workflows/ci.yml/badge.svg)](https://github.com/Cipher208/docs-haven/actions/workflows/ci.yml)
37
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
38
+
39
+ > **Your AI agent keeps forgetting what it learned last session. DocsHaven fixes that.**
40
+
41
+ **Add your repos, and your agent always has them at hand.** DocsHaven is a local knowledge base that lets you index any GitHub repository, search it instantly, and keep your agent informed across sessions. Zero dependencies, works with any MCP-compatible agent — Claude, Cursor, Gemini, Codex.
42
+
43
+ **Why DocsHaven?**
44
+ - 🧠 **Add repos once, search forever** — your agent always has the knowledge it needs
45
+ - ⚡ **Instant search** — SQLite FTS5 finds relevant docs in <100ms
46
+ - 🔌 **Works with any AI agent** — Claude, Cursor, Gemini, Codex via MCP
47
+ - 🏠 **100% local** — no cloud, no API keys, no data leaves your machine
48
+ - 📦 **Zero dependencies** — built into Python, no Docker or external services
49
+
50
+ ## Features
51
+
52
+ - **SQLite FTS5 search** — BM25 ranking with LIKE fallback
53
+ - **URI routing** — organize knowledge by domain: `core://`, `ref://`, `guide://`
54
+ - **Git sync** — compressed chunks for multi-machine sync (no merge conflicts)
55
+ - **Conflict detection** — flag contradictions when adding documents
56
+ - **MCP server** — 14 tools for any MCP-compatible agent
57
+ - **Document chunking** — split long documents for better search precision
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ git clone https://github.com/Cipher208/docs-haven.git
63
+ cd docs-haven
64
+ pip install -e .
65
+ ```
66
+
67
+ <details>
68
+ <summary><b>With test dependencies</b></summary>
69
+
70
+ ```bash
71
+ pip install -e ".[test]"
72
+ ```
73
+
74
+ </details>
75
+
76
+ ## How to Use
77
+
78
+ <details open>
79
+ <summary><b>1. Add Repositories to Your Knowledge Base</b></summary>
80
+
81
+ ```python
82
+ from storage import Storage
83
+ from pathlib import Path
84
+
85
+ storage = Storage(Path.home() / ".docshaven")
86
+
87
+ # Add a GitHub repo (clones and indexes markdown files)
88
+ result = storage.add_repo(
89
+ url="https://github.com/fastapi/fastapi",
90
+ description="FastAPI web framework",
91
+ )
92
+ print(f"Indexed {result['files_indexed']} files in {result['chunks']} chunks")
93
+
94
+ # Add with custom file mask (index Python files)
95
+ result = storage.add_repo(
96
+ url="https://github.com/pallets/flask",
97
+ mask="**/*.py",
98
+ )
99
+ ```
100
+
101
+ </details>
102
+
103
+ <details open>
104
+ <summary><b>2. Search Your Knowledge Base</b></summary>
105
+
106
+ ```python
107
+ # Basic search
108
+ results = storage.search("dependency injection")
109
+ for r in results:
110
+ print(f"{r['score']:.2f} [{r['collection']}] {r['title']}")
111
+ print(f" {r['content'][:100]}...")
112
+ print()
113
+
114
+ # Search with filters
115
+ results = storage.search(
116
+ "async middleware",
117
+ collections=["fastapi"],
118
+ limit=5,
119
+ min_score=0.3,
120
+ )
121
+
122
+ # Use auto strategy (fts for short queries, hybrid for long)
123
+ results = storage.search("how to use Depends()", strategy="auto")
124
+ ```
125
+
126
+ </details>
127
+
128
+ <details open>
129
+ <summary><b>3. Organize with URI Routing</b></summary>
130
+
131
+ ```python
132
+ from uri import URI, URIRouter
133
+
134
+ # Parse URIs
135
+ uri = URI.parse("core://fastapi/dependencies")
136
+ print(uri.domain) # "core"
137
+ print(uri.path) # "fastapi/dependencies"
138
+ print(uri.to_collection()) # "core__fastapi"
139
+
140
+ # Search within a URI scope
141
+ router = URIRouter(storage)
142
+ results = router.search_by_uri("core://fastapi", limit=5)
143
+
144
+ # List all domains
145
+ domains = router.list_all_domains()
146
+ # {'core': {'count': 3, 'doc': 'Core documentation'}, 'ref': {'count': 2, ...}}
147
+ ```
148
+
149
+ **Available domains:** `core`, `ref`, `guide`, `lib`, `src`, `test`, `note`
150
+
151
+ </details>
152
+
153
+ <details>
154
+ <summary><b>4. Detect Conflicts</b></summary>
155
+
156
+ ```python
157
+ from conflicts import ConflictDetector
158
+
159
+ detector = ConflictDetector(storage)
160
+ result = detector.detect(
161
+ title="FastAPI dependency injection",
162
+ content="How to use Depends()...",
163
+ )
164
+
165
+ if result.has_conflicts:
166
+ print(f"Found {len(result.candidates)} similar documents:")
167
+ for c in result.candidates:
168
+ print(f" - {c['title']} (score: {c['score']})")
169
+ print(f" {c['snippet'][:80]}...")
170
+
171
+ # Record judgment
172
+ detector.judge("new_doc_id", "existing_doc_id", "supersedes")
173
+ ```
174
+
175
+ </details>
176
+
177
+ <details>
178
+ <summary><b>5. Sync Between Machines</b></summary>
179
+
180
+ ```python
181
+ from sync import Syncer
182
+ from pathlib import Path
183
+
184
+ syncer = Syncer(Path.home() / ".docshaven-sync")
185
+
186
+ # On machine A: export
187
+ result = syncer.export(
188
+ {"fastapi": docs, "sqlalchemy": docs},
189
+ created_by="alice",
190
+ )
191
+ print(f"Exported chunk {result['chunk_id']}")
192
+
193
+ # On machine B: import
194
+ result = syncer.import_chunks()
195
+ print(f"Imported {result['chunks_imported']} chunks")
196
+
197
+ # Check status
198
+ status = syncer.status()
199
+ print(f"Chunks: {status['local_chunks']}")
200
+ ```
201
+
202
+ </details>
203
+
204
+ <details>
205
+ <summary><b>6. Use as MCP Server</b></summary>
206
+
207
+ Add to your MCP client config (Claude Desktop, Cursor, etc.):
208
+
209
+ ```json
210
+ {
211
+ "mcpServers": {
212
+ "docs-haven": {
213
+ "command": "python",
214
+ "args": ["/path/to/docs-haven/server.py"]
215
+ }
216
+ }
217
+ }
218
+ ```
219
+
220
+ Then ask your agent:
221
+
222
+ > "Search for FastAPI middleware examples"
223
+ > "What documentation do we have about SQLAlchemy?"
224
+ > "Check if this new doc conflicts with existing ones"
225
+
226
+ </details>
227
+
228
+ ## MCP Tools
229
+
230
+ | Tool | Description |
231
+ |------|-------------|
232
+ | `kb_search` | Search with BM25 ranking |
233
+ | `kb_add_repo` | Clone and index a GitHub repo |
234
+ | `kb_get` | Get document content |
235
+ | `kb_list_collections` | List all collections |
236
+ | `kb_stats` | Database statistics |
237
+ | `kb_uri_resolve` | URI to collection mapping |
238
+ | `kb_uri_search` | Search within URI scope |
239
+ | `kb_uri_list` | List URIs in domain |
240
+ | `kb_uri_domains` | All domains with counts |
241
+ | `kb_sync_export` | Export compressed chunk |
242
+ | `kb_sync_import` | Import chunks |
243
+ | `kb_sync_status` | Sync status |
244
+ | `kb_conflict_check` | Detect conflicts |
245
+ | `kb_conflict_judge` | Record judgment |
246
+
247
+ ## Comparison
248
+
249
+ | Feature | DocsHaven | QMD | Elasticsearch | Context7 |
250
+ |---------|-----------|-----|---------------|----------|
251
+ | Dependencies | 0 (stdlib) | 1 (npm) | JVM + plugins | External service |
252
+ | Setup time | 10 seconds | 5 minutes | 30+ minutes | API key needed |
253
+ | MCP server | Built-in | No | No | Yes |
254
+ | URI routing | Yes | No | No | No |
255
+ | Conflict detection | Yes | No | No | No |
256
+ | Git sync | Compressed chunks | No | No | No |
257
+ | Cost | Free | Free | Free (self-hosted) | Paid tiers |
258
+
259
+ ## FAQ
260
+
261
+ <details>
262
+ <summary><b>What is DocsHaven?</b></summary>
263
+
264
+ DocsHaven is a local knowledge base designed for AI agents. It provides full-text search via SQLite FTS5, organizes knowledge by URI domains (core://, ref://, guide://), and detects contradictions when adding new documents. It runs as an MCP server with 14 tools.
265
+
266
+ </details>
267
+
268
+ <details>
269
+ <summary><b>How is this different from just using SQLite?</b></summary>
270
+
271
+ DocsHaven adds a complete knowledge management layer on top of SQLite: automatic document chunking, BM25 ranking with LIKE fallback, URI-based organization, conflict detection, and compressed multi-machine sync — all exposed via MCP tools.
272
+
273
+ </details>
274
+
275
+ <details>
276
+ <summary><b>Can I use this with Claude Desktop / Cursor / other AI agents?</b></summary>
277
+
278
+ Yes. DocsHaven runs as an MCP server. Add it to your MCP client config and all 14 tools become available to your agent.
279
+
280
+ </details>
281
+
282
+ <details>
283
+ <summary><b>How fast is search?</b></summary>
284
+
285
+ SQLite FTS5 with BM25 ranking handles 1,000+ documents in under 100ms on modern hardware. No network latency since everything is local.
286
+
287
+ </details>
288
+
289
+ <details>
290
+ <summary><b>Is my data sent anywhere?</b></summary>
291
+
292
+ No. DocsHaven is fully local. The only network operation is cloning GitHub repositories (which you initiate). All search and storage happens on your machine.
293
+
294
+ </details>
295
+
296
+ ## Architecture
297
+
298
+ ```
299
+ docs-haven/
300
+ ├── server.py # MCP server (14 tools)
301
+ ├── storage.py # SQLite FTS5 backend
302
+ ├── uri.py # URI routing
303
+ ├── sync.py # Git sync (compressed chunks)
304
+ ├── conflicts.py # Conflict detection
305
+ ├── tests/ # pytest test suite (39 tests)
306
+ ├── docs/ # Documentation
307
+ └── pyproject.toml # Package config
308
+ ```
309
+
310
+ ## Development
311
+
312
+ ```bash
313
+ # Install with test dependencies
314
+ pip install -e ".[test]"
315
+
316
+ # Run tests
317
+ pytest tests/ -v
318
+
319
+ # Run linting
320
+ ruff check .
321
+
322
+ # Run formatting
323
+ ruff format .
324
+
325
+ # Run type checking
326
+ mypy . --ignore-missing-imports
327
+ ```
328
+
329
+ ## Security
330
+
331
+ - SQLite FTS5 with parameterized queries (no SQL injection)
332
+ - Input validation on all MCP tool parameters
333
+ - No external network dependencies (local-only operation)
334
+ - Secret scanning via GitHub Actions (gitleaks)
335
+
336
+ See [SECURITY.md](SECURITY.md) for vulnerability reporting.
337
+
338
+ ## Author
339
+
340
+ Built with ❤️ by [Cipher208](https://github.com/Cipher208)
341
+
342
+ ## License
343
+
344
+ MIT