socratic-knowledge 0.1.0__tar.gz

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.
Files changed (60) hide show
  1. socratic_knowledge-0.1.0/LICENSE +21 -0
  2. socratic_knowledge-0.1.0/MANIFEST.in +5 -0
  3. socratic_knowledge-0.1.0/PKG-INFO +340 -0
  4. socratic_knowledge-0.1.0/README.md +296 -0
  5. socratic_knowledge-0.1.0/examples/01_basic_usage.py +174 -0
  6. socratic_knowledge-0.1.0/examples/02_access_control.py +179 -0
  7. socratic_knowledge-0.1.0/examples/03_versioning_audit.py +181 -0
  8. socratic_knowledge-0.1.0/examples/04_rag_integration.py +308 -0
  9. socratic_knowledge-0.1.0/pyproject.toml +106 -0
  10. socratic_knowledge-0.1.0/setup.cfg +4 -0
  11. socratic_knowledge-0.1.0/src/socratic_knowledge/__init__.py +26 -0
  12. socratic_knowledge-0.1.0/src/socratic_knowledge/access/__init__.py +9 -0
  13. socratic_knowledge-0.1.0/src/socratic_knowledge/access/permissions.py +234 -0
  14. socratic_knowledge-0.1.0/src/socratic_knowledge/access/rbac.py +37 -0
  15. socratic_knowledge-0.1.0/src/socratic_knowledge/audit/__init__.py +10 -0
  16. socratic_knowledge-0.1.0/src/socratic_knowledge/audit/events.py +91 -0
  17. socratic_knowledge-0.1.0/src/socratic_knowledge/audit/logger.py +216 -0
  18. socratic_knowledge-0.1.0/src/socratic_knowledge/collaboration/__init__.py +13 -0
  19. socratic_knowledge-0.1.0/src/socratic_knowledge/collaboration/conflict.py +273 -0
  20. socratic_knowledge-0.1.0/src/socratic_knowledge/collaboration/locks.py +186 -0
  21. socratic_knowledge-0.1.0/src/socratic_knowledge/core/__init__.py +15 -0
  22. socratic_knowledge-0.1.0/src/socratic_knowledge/core/collection.py +139 -0
  23. socratic_knowledge-0.1.0/src/socratic_knowledge/core/knowledge_item.py +145 -0
  24. socratic_knowledge-0.1.0/src/socratic_knowledge/core/tenant.py +89 -0
  25. socratic_knowledge-0.1.0/src/socratic_knowledge/core/user.py +51 -0
  26. socratic_knowledge-0.1.0/src/socratic_knowledge/core/version.py +99 -0
  27. socratic_knowledge-0.1.0/src/socratic_knowledge/integrations/__init__.py +9 -0
  28. socratic_knowledge-0.1.0/src/socratic_knowledge/integrations/langchain/__init__.py +5 -0
  29. socratic_knowledge-0.1.0/src/socratic_knowledge/integrations/langchain/tools.py +228 -0
  30. socratic_knowledge-0.1.0/src/socratic_knowledge/integrations/openclaw/__init__.py +5 -0
  31. socratic_knowledge-0.1.0/src/socratic_knowledge/integrations/openclaw/skill.py +327 -0
  32. socratic_knowledge-0.1.0/src/socratic_knowledge/manager.py +825 -0
  33. socratic_knowledge-0.1.0/src/socratic_knowledge/retrieval/__init__.py +12 -0
  34. socratic_knowledge-0.1.0/src/socratic_knowledge/retrieval/indexer.py +80 -0
  35. socratic_knowledge-0.1.0/src/socratic_knowledge/retrieval/rag_integration.py +152 -0
  36. socratic_knowledge-0.1.0/src/socratic_knowledge/retrieval/search.py +183 -0
  37. socratic_knowledge-0.1.0/src/socratic_knowledge/storage/__init__.py +9 -0
  38. socratic_knowledge-0.1.0/src/socratic_knowledge/storage/base.py +264 -0
  39. socratic_knowledge-0.1.0/src/socratic_knowledge/storage/sqlite_store.py +606 -0
  40. socratic_knowledge-0.1.0/src/socratic_knowledge/versioning/__init__.py +9 -0
  41. socratic_knowledge-0.1.0/src/socratic_knowledge/versioning/history.py +126 -0
  42. socratic_knowledge-0.1.0/src/socratic_knowledge/versioning/version_model.py +35 -0
  43. socratic_knowledge-0.1.0/src/socratic_knowledge.egg-info/PKG-INFO +340 -0
  44. socratic_knowledge-0.1.0/src/socratic_knowledge.egg-info/SOURCES.txt +58 -0
  45. socratic_knowledge-0.1.0/src/socratic_knowledge.egg-info/dependency_links.txt +1 -0
  46. socratic_knowledge-0.1.0/src/socratic_knowledge.egg-info/requires.txt +21 -0
  47. socratic_knowledge-0.1.0/src/socratic_knowledge.egg-info/top_level.txt +1 -0
  48. socratic_knowledge-0.1.0/tests/__init__.py +1 -0
  49. socratic_knowledge-0.1.0/tests/unit/__init__.py +1 -0
  50. socratic_knowledge-0.1.0/tests/unit/test_access_control.py +442 -0
  51. socratic_knowledge-0.1.0/tests/unit/test_audit.py +394 -0
  52. socratic_knowledge-0.1.0/tests/unit/test_collaboration.py +342 -0
  53. socratic_knowledge-0.1.0/tests/unit/test_indexer.py +135 -0
  54. socratic_knowledge-0.1.0/tests/unit/test_knowledge_item.py +99 -0
  55. socratic_knowledge-0.1.0/tests/unit/test_langchain_tools.py +312 -0
  56. socratic_knowledge-0.1.0/tests/unit/test_openclaw_skill.py +287 -0
  57. socratic_knowledge-0.1.0/tests/unit/test_rag_integration.py +302 -0
  58. socratic_knowledge-0.1.0/tests/unit/test_search.py +385 -0
  59. socratic_knowledge-0.1.0/tests/unit/test_sqlite_store.py +294 -0
  60. socratic_knowledge-0.1.0/tests/unit/test_versioning.py +437 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Socratic Knowledge 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.
@@ -0,0 +1,5 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include src/socratic_knowledge *.py
4
+ recursive-include tests *.py
5
+ recursive-include examples *.py
@@ -0,0 +1,340 @@
1
+ Metadata-Version: 2.4
2
+ Name: socratic-knowledge
3
+ Version: 0.1.0
4
+ Summary: Enterprise knowledge management system with multi-tenancy, access control, versioning, and RAG integration.
5
+ Author: Socratic Knowledge Contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Nireus79/Socratic-knowledge
8
+ Project-URL: Repository, https://github.com/Nireus79/Socratic-knowledge
9
+ Project-URL: Documentation, https://github.com/Nireus79/Socratic-knowledge#readme
10
+ Project-URL: Issues, https://github.com/Nireus79/Socratic-knowledge/issues
11
+ Keywords: knowledge,management,multi-tenant,access-control,versioning,rag,semantic-search,langchain,openclaw,enterprise
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Information Technology
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Office/Business
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: pydantic>=2.0.0
28
+ Provides-Extra: rag
29
+ Requires-Dist: socratic-rag>=0.1.0; extra == "rag"
30
+ Provides-Extra: openclaw
31
+ Provides-Extra: langchain
32
+ Requires-Dist: langchain>=0.1.0; extra == "langchain"
33
+ Provides-Extra: all
34
+ Requires-Dist: socratic-rag>=0.1.0; extra == "all"
35
+ Requires-Dist: langchain>=0.1.0; extra == "all"
36
+ Provides-Extra: dev
37
+ Requires-Dist: pytest>=7.0; extra == "dev"
38
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
39
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
40
+ Requires-Dist: black>=23.0; extra == "dev"
41
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
42
+ Requires-Dist: mypy>=1.0; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # Socratic Knowledge
46
+
47
+ [![Tests](https://github.com/Nireus79/Socratic-knowledge/workflows/Tests/badge.svg)](https://github.com/Nireus79/Socratic-knowledge/actions)
48
+ [![Code Quality](https://github.com/Nireus79/Socratic-knowledge/workflows/Quality/badge.svg)](https://github.com/Nireus79/Socratic-knowledge/actions)
49
+ [![PyPI](https://img.shields.io/pypi/v/socratic-knowledge)](https://pypi.org/project/socratic-knowledge/)
50
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
51
+
52
+ Enterprise knowledge management system with **multi-tenancy**, **access control**, **versioning**, and **RAG integration**.
53
+
54
+ ## Features
55
+
56
+ - **📚 Knowledge Organization** - Hierarchical knowledge base with collections and documents
57
+ - **🔐 Multi-Tenancy** - Isolated knowledge spaces for multiple organizations
58
+ - **👥 Access Control** - Role-based permissions (RBAC) with fine-grained control
59
+ - **📝 Versioning** - Full history tracking with rollback capabilities
60
+ - **🔍 Semantic Search** - RAG-powered semantic search with embeddings
61
+ - **🤝 Collaboration** - Multi-user editing with conflict detection
62
+ - **📋 Audit Logging** - Complete audit trail for compliance
63
+ - **🔌 Framework Integration** - Works with Openclaw and LangChain
64
+
65
+ ## Quick Start
66
+
67
+ ### Installation
68
+
69
+ ```bash
70
+ # Basic installation
71
+ pip install socratic-knowledge
72
+
73
+ # With RAG integration
74
+ pip install socratic-knowledge[rag]
75
+
76
+ # With LangChain integration
77
+ pip install socratic-knowledge[langchain]
78
+
79
+ # Everything
80
+ pip install socratic-knowledge[all]
81
+ ```
82
+
83
+ ### Simple Example
84
+
85
+ ```python
86
+ from socratic_knowledge import KnowledgeManager
87
+
88
+ # Create knowledge manager
89
+ km = KnowledgeManager(storage="sqlite", db_path="knowledge.db")
90
+
91
+ # Create tenant (organization)
92
+ tenant = km.create_tenant(name="Acme Corp", domain="acme.com")
93
+
94
+ # Create collection (folder)
95
+ docs = km.create_collection(
96
+ tenant_id=tenant.tenant_id,
97
+ name="Documentation",
98
+ created_by="user123"
99
+ )
100
+
101
+ # Add knowledge item
102
+ item = km.create_item(
103
+ tenant_id=tenant.tenant_id,
104
+ collection_id=docs.collection_id,
105
+ title="API Guide",
106
+ content="How to use our API...",
107
+ created_by="user123",
108
+ tags=["api", "guide"]
109
+ )
110
+
111
+ # Search
112
+ results = km.search(tenant_id=tenant.tenant_id, query="API")
113
+
114
+ # Get item
115
+ retrieved = km.get_item(item.item_id, tenant_id=tenant.tenant_id)
116
+ ```
117
+
118
+ ## Core Concepts
119
+
120
+ ### KnowledgeItem
121
+
122
+ The main entity representing any knowledge artifact (document, note, etc.)
123
+
124
+ ```python
125
+ @dataclass
126
+ class KnowledgeItem:
127
+ item_id: str # UUID
128
+ tenant_id: str # For multi-tenancy
129
+ collection_id: Optional[str] # Parent collection
130
+ title: str
131
+ content: str
132
+ content_type: str # "text", "markdown", "json"
133
+ version: int
134
+ created_at: datetime
135
+ updated_at: datetime
136
+ created_by: str
137
+ updated_by: str
138
+ owner_id: str
139
+ permissions: Dict[str, List[str]] # {role: [user_ids]}
140
+ tags: List[str]
141
+ metadata: Dict[str, Any]
142
+ ```
143
+
144
+ ### Collection
145
+
146
+ Hierarchical container for organizing knowledge items (like folders)
147
+
148
+ ```python
149
+ @dataclass
150
+ class Collection:
151
+ collection_id: str
152
+ tenant_id: str
153
+ parent_id: Optional[str] # For hierarchy
154
+ name: str
155
+ owner_id: str
156
+ permissions: Dict[str, List[str]]
157
+ inherit_permissions: bool # Inherit ACL from parent
158
+ ```
159
+
160
+ ### Tenant
161
+
162
+ Organization/account for multi-tenancy support
163
+
164
+ ```python
165
+ @dataclass
166
+ class Tenant:
167
+ tenant_id: str
168
+ name: str
169
+ domain: Optional[str] # e.g., "acme.com"
170
+ max_storage_mb: int
171
+ is_active: bool
172
+ ```
173
+
174
+ ### Access Control
175
+
176
+ Role-based permissions (RBAC):
177
+
178
+ - **VIEWER** - Read only
179
+ - **EDITOR** - Read + Write
180
+ - **ADMIN** - Full access
181
+ - **OWNER** - All permissions
182
+
183
+ ## API Reference
184
+
185
+ ### KnowledgeManager
186
+
187
+ Main interface for knowledge management operations.
188
+
189
+ ```python
190
+ class KnowledgeManager:
191
+ # Tenant operations
192
+ def create_tenant(self, name: str, **kwargs) -> Tenant
193
+ def get_tenant(self, tenant_id: str) -> Optional[Tenant]
194
+
195
+ # Collection operations
196
+ def create_collection(self, tenant_id: str, name: str, created_by: str,
197
+ parent_id: Optional[str] = None) -> Collection
198
+ def get_collection(self, collection_id: str) -> Optional[Collection]
199
+ def list_collections(self, tenant_id: str, parent_id: Optional[str] = None) -> List[Collection]
200
+
201
+ # Knowledge item operations
202
+ def create_item(self, tenant_id: str, title: str, content: str,
203
+ created_by: str, collection_id: Optional[str] = None,
204
+ **kwargs) -> KnowledgeItem
205
+ def get_item(self, item_id: str, tenant_id: str) -> Optional[KnowledgeItem]
206
+ def update_item(self, item: KnowledgeItem, change_message: str = "") -> KnowledgeItem
207
+ def delete_item(self, item_id: str, tenant_id: str, soft: bool = True) -> bool
208
+ def list_items(self, tenant_id: str, collection_id: Optional[str] = None,
209
+ limit: int = 100, offset: int = 0) -> List[KnowledgeItem]
210
+
211
+ # Search operations
212
+ def search(self, tenant_id: str, query: str, limit: int = 10) -> List[KnowledgeItem]
213
+ def semantic_search(self, tenant_id: str, query: str, top_k: int = 5,
214
+ collection_id: Optional[str] = None) -> List[KnowledgeItem]
215
+
216
+ # Access control
217
+ def grant_permission(self, item_id: str, user_id: str, role: Role,
218
+ granted_by: str) -> None
219
+ def can_user_edit(self, user_id: str, item_id: str) -> bool
220
+
221
+ # Versioning
222
+ def get_version_history(self, item_id: str, limit: int = 10) -> List[Version]
223
+ def rollback_item(self, item_id: str, version_number: int) -> KnowledgeItem
224
+
225
+ # Audit
226
+ def get_audit_log(self, tenant_id: str, limit: int = 100) -> List[Dict[str, Any]]
227
+ ```
228
+
229
+ ## Examples
230
+
231
+ See `examples/` directory for complete examples:
232
+
233
+ - `01_basic_usage.py` - Basic CRUD operations
234
+ - `02_access_control.py` - Role-based permissions
235
+ - `03_versioning.py` - Version history and rollback
236
+ - `04_rag_integration.py` - Semantic search with RAG
237
+
238
+ ## Integrations
239
+
240
+ ### Openclaw
241
+
242
+ ```python
243
+ from socratic_knowledge.integrations.openclaw import SocraticKnowledgeSkill
244
+
245
+ skill = SocraticKnowledgeSkill(storage="sqlite")
246
+ result = skill.search(tenant_id="org1", query="LLM prompt engineering", top_k=5)
247
+ ```
248
+
249
+ ### LangChain
250
+
251
+ ```python
252
+ from socratic_knowledge.integrations.langchain import SocraticKnowledgeTool
253
+
254
+ tool = SocraticKnowledgeTool(storage="sqlite", enable_rag=True)
255
+ results = tool.semantic_search(
256
+ tenant_id="org1",
257
+ query="How to fine-tune models?",
258
+ top_k=5
259
+ )
260
+ ```
261
+
262
+ ## Contributing
263
+
264
+ Contributions welcome! Please:
265
+
266
+ 1. Fork the repository
267
+ 2. Create a feature branch
268
+ 3. Add tests for new functionality
269
+ 4. Ensure all tests pass
270
+ 5. Submit a pull request
271
+
272
+ ## Testing
273
+
274
+ ```bash
275
+ # Run tests
276
+ pytest
277
+
278
+ # With coverage
279
+ pytest --cov=src/socratic_knowledge
280
+
281
+ # Specific test file
282
+ pytest tests/unit/test_knowledge_item.py -v
283
+ ```
284
+
285
+ ## Quality
286
+
287
+ ```bash
288
+ # Format code
289
+ black src/ tests/ examples/
290
+
291
+ # Lint
292
+ ruff check src/ tests/ examples/
293
+
294
+ # Type check
295
+ mypy src/socratic_knowledge
296
+ ```
297
+
298
+ ## License
299
+
300
+ MIT License - see [LICENSE](LICENSE) file for details.
301
+
302
+ ## Project Status
303
+
304
+ **Version**: 0.1.0 (MVP)
305
+
306
+ ### Statistics
307
+
308
+ - **Lines of Code**: ~3,610 (implementation) + ~2,500 (tests)
309
+ - **Total Tests**: 197 tests across 5 phases
310
+ - **Test Coverage**: ~93% (exceeds 75% target)
311
+ - **Supported Python**: 3.9, 3.10, 3.11, 3.12
312
+ - **Quality**: Black 100%, Ruff 0 issues, MyPy 0 errors ✅
313
+ - **CI/CD**: GitHub Actions
314
+
315
+ ### Implementation Progress
316
+
317
+ - Phase 1: Core Foundation ✅ Complete
318
+ - Phase 2: Access Control & Versioning ✅ Complete
319
+ - Phase 3: RAG Integration & Search ✅ Complete
320
+ - Phase 4: Collaboration & Audit ✅ Complete
321
+ - Phase 5: Integrations ✅ Complete
322
+ - Phase 6: Polish & Documentation ✅ Complete
323
+
324
+ ## Support
325
+
326
+ - 📖 [Documentation](https://github.com/Nireus79/Socratic-knowledge#readme)
327
+ - 🐛 [Issues](https://github.com/Nireus79/Socratic-knowledge/issues)
328
+ - 💬 [Discussions](https://github.com/Nireus79/Socratic-knowledge/discussions)
329
+
330
+ ## Related Projects
331
+
332
+ - [Socratic Workflow](https://github.com/Nireus79/Socratic-workflow) - Workflow orchestration
333
+ - [Socratic Agents](https://github.com/Nireus79/Socratic-agents) - Multi-agent orchestration
334
+ - [Socratic RAG](https://github.com/Nireus79/Socratic-rag) - Retrieval-augmented generation
335
+ - [Socratic Analyzer](https://github.com/Nireus79/Socratic-analyzer) - Code analysis
336
+ - [Socrates Nexus](https://github.com/Nireus79/socrates-nexus) - Universal LLM client
337
+
338
+ ---
339
+
340
+ **Built with ❤️ by the Socratic Ecosystem**
@@ -0,0 +1,296 @@
1
+ # Socratic Knowledge
2
+
3
+ [![Tests](https://github.com/Nireus79/Socratic-knowledge/workflows/Tests/badge.svg)](https://github.com/Nireus79/Socratic-knowledge/actions)
4
+ [![Code Quality](https://github.com/Nireus79/Socratic-knowledge/workflows/Quality/badge.svg)](https://github.com/Nireus79/Socratic-knowledge/actions)
5
+ [![PyPI](https://img.shields.io/pypi/v/socratic-knowledge)](https://pypi.org/project/socratic-knowledge/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ Enterprise knowledge management system with **multi-tenancy**, **access control**, **versioning**, and **RAG integration**.
9
+
10
+ ## Features
11
+
12
+ - **📚 Knowledge Organization** - Hierarchical knowledge base with collections and documents
13
+ - **🔐 Multi-Tenancy** - Isolated knowledge spaces for multiple organizations
14
+ - **👥 Access Control** - Role-based permissions (RBAC) with fine-grained control
15
+ - **📝 Versioning** - Full history tracking with rollback capabilities
16
+ - **🔍 Semantic Search** - RAG-powered semantic search with embeddings
17
+ - **🤝 Collaboration** - Multi-user editing with conflict detection
18
+ - **📋 Audit Logging** - Complete audit trail for compliance
19
+ - **🔌 Framework Integration** - Works with Openclaw and LangChain
20
+
21
+ ## Quick Start
22
+
23
+ ### Installation
24
+
25
+ ```bash
26
+ # Basic installation
27
+ pip install socratic-knowledge
28
+
29
+ # With RAG integration
30
+ pip install socratic-knowledge[rag]
31
+
32
+ # With LangChain integration
33
+ pip install socratic-knowledge[langchain]
34
+
35
+ # Everything
36
+ pip install socratic-knowledge[all]
37
+ ```
38
+
39
+ ### Simple Example
40
+
41
+ ```python
42
+ from socratic_knowledge import KnowledgeManager
43
+
44
+ # Create knowledge manager
45
+ km = KnowledgeManager(storage="sqlite", db_path="knowledge.db")
46
+
47
+ # Create tenant (organization)
48
+ tenant = km.create_tenant(name="Acme Corp", domain="acme.com")
49
+
50
+ # Create collection (folder)
51
+ docs = km.create_collection(
52
+ tenant_id=tenant.tenant_id,
53
+ name="Documentation",
54
+ created_by="user123"
55
+ )
56
+
57
+ # Add knowledge item
58
+ item = km.create_item(
59
+ tenant_id=tenant.tenant_id,
60
+ collection_id=docs.collection_id,
61
+ title="API Guide",
62
+ content="How to use our API...",
63
+ created_by="user123",
64
+ tags=["api", "guide"]
65
+ )
66
+
67
+ # Search
68
+ results = km.search(tenant_id=tenant.tenant_id, query="API")
69
+
70
+ # Get item
71
+ retrieved = km.get_item(item.item_id, tenant_id=tenant.tenant_id)
72
+ ```
73
+
74
+ ## Core Concepts
75
+
76
+ ### KnowledgeItem
77
+
78
+ The main entity representing any knowledge artifact (document, note, etc.)
79
+
80
+ ```python
81
+ @dataclass
82
+ class KnowledgeItem:
83
+ item_id: str # UUID
84
+ tenant_id: str # For multi-tenancy
85
+ collection_id: Optional[str] # Parent collection
86
+ title: str
87
+ content: str
88
+ content_type: str # "text", "markdown", "json"
89
+ version: int
90
+ created_at: datetime
91
+ updated_at: datetime
92
+ created_by: str
93
+ updated_by: str
94
+ owner_id: str
95
+ permissions: Dict[str, List[str]] # {role: [user_ids]}
96
+ tags: List[str]
97
+ metadata: Dict[str, Any]
98
+ ```
99
+
100
+ ### Collection
101
+
102
+ Hierarchical container for organizing knowledge items (like folders)
103
+
104
+ ```python
105
+ @dataclass
106
+ class Collection:
107
+ collection_id: str
108
+ tenant_id: str
109
+ parent_id: Optional[str] # For hierarchy
110
+ name: str
111
+ owner_id: str
112
+ permissions: Dict[str, List[str]]
113
+ inherit_permissions: bool # Inherit ACL from parent
114
+ ```
115
+
116
+ ### Tenant
117
+
118
+ Organization/account for multi-tenancy support
119
+
120
+ ```python
121
+ @dataclass
122
+ class Tenant:
123
+ tenant_id: str
124
+ name: str
125
+ domain: Optional[str] # e.g., "acme.com"
126
+ max_storage_mb: int
127
+ is_active: bool
128
+ ```
129
+
130
+ ### Access Control
131
+
132
+ Role-based permissions (RBAC):
133
+
134
+ - **VIEWER** - Read only
135
+ - **EDITOR** - Read + Write
136
+ - **ADMIN** - Full access
137
+ - **OWNER** - All permissions
138
+
139
+ ## API Reference
140
+
141
+ ### KnowledgeManager
142
+
143
+ Main interface for knowledge management operations.
144
+
145
+ ```python
146
+ class KnowledgeManager:
147
+ # Tenant operations
148
+ def create_tenant(self, name: str, **kwargs) -> Tenant
149
+ def get_tenant(self, tenant_id: str) -> Optional[Tenant]
150
+
151
+ # Collection operations
152
+ def create_collection(self, tenant_id: str, name: str, created_by: str,
153
+ parent_id: Optional[str] = None) -> Collection
154
+ def get_collection(self, collection_id: str) -> Optional[Collection]
155
+ def list_collections(self, tenant_id: str, parent_id: Optional[str] = None) -> List[Collection]
156
+
157
+ # Knowledge item operations
158
+ def create_item(self, tenant_id: str, title: str, content: str,
159
+ created_by: str, collection_id: Optional[str] = None,
160
+ **kwargs) -> KnowledgeItem
161
+ def get_item(self, item_id: str, tenant_id: str) -> Optional[KnowledgeItem]
162
+ def update_item(self, item: KnowledgeItem, change_message: str = "") -> KnowledgeItem
163
+ def delete_item(self, item_id: str, tenant_id: str, soft: bool = True) -> bool
164
+ def list_items(self, tenant_id: str, collection_id: Optional[str] = None,
165
+ limit: int = 100, offset: int = 0) -> List[KnowledgeItem]
166
+
167
+ # Search operations
168
+ def search(self, tenant_id: str, query: str, limit: int = 10) -> List[KnowledgeItem]
169
+ def semantic_search(self, tenant_id: str, query: str, top_k: int = 5,
170
+ collection_id: Optional[str] = None) -> List[KnowledgeItem]
171
+
172
+ # Access control
173
+ def grant_permission(self, item_id: str, user_id: str, role: Role,
174
+ granted_by: str) -> None
175
+ def can_user_edit(self, user_id: str, item_id: str) -> bool
176
+
177
+ # Versioning
178
+ def get_version_history(self, item_id: str, limit: int = 10) -> List[Version]
179
+ def rollback_item(self, item_id: str, version_number: int) -> KnowledgeItem
180
+
181
+ # Audit
182
+ def get_audit_log(self, tenant_id: str, limit: int = 100) -> List[Dict[str, Any]]
183
+ ```
184
+
185
+ ## Examples
186
+
187
+ See `examples/` directory for complete examples:
188
+
189
+ - `01_basic_usage.py` - Basic CRUD operations
190
+ - `02_access_control.py` - Role-based permissions
191
+ - `03_versioning.py` - Version history and rollback
192
+ - `04_rag_integration.py` - Semantic search with RAG
193
+
194
+ ## Integrations
195
+
196
+ ### Openclaw
197
+
198
+ ```python
199
+ from socratic_knowledge.integrations.openclaw import SocraticKnowledgeSkill
200
+
201
+ skill = SocraticKnowledgeSkill(storage="sqlite")
202
+ result = skill.search(tenant_id="org1", query="LLM prompt engineering", top_k=5)
203
+ ```
204
+
205
+ ### LangChain
206
+
207
+ ```python
208
+ from socratic_knowledge.integrations.langchain import SocraticKnowledgeTool
209
+
210
+ tool = SocraticKnowledgeTool(storage="sqlite", enable_rag=True)
211
+ results = tool.semantic_search(
212
+ tenant_id="org1",
213
+ query="How to fine-tune models?",
214
+ top_k=5
215
+ )
216
+ ```
217
+
218
+ ## Contributing
219
+
220
+ Contributions welcome! Please:
221
+
222
+ 1. Fork the repository
223
+ 2. Create a feature branch
224
+ 3. Add tests for new functionality
225
+ 4. Ensure all tests pass
226
+ 5. Submit a pull request
227
+
228
+ ## Testing
229
+
230
+ ```bash
231
+ # Run tests
232
+ pytest
233
+
234
+ # With coverage
235
+ pytest --cov=src/socratic_knowledge
236
+
237
+ # Specific test file
238
+ pytest tests/unit/test_knowledge_item.py -v
239
+ ```
240
+
241
+ ## Quality
242
+
243
+ ```bash
244
+ # Format code
245
+ black src/ tests/ examples/
246
+
247
+ # Lint
248
+ ruff check src/ tests/ examples/
249
+
250
+ # Type check
251
+ mypy src/socratic_knowledge
252
+ ```
253
+
254
+ ## License
255
+
256
+ MIT License - see [LICENSE](LICENSE) file for details.
257
+
258
+ ## Project Status
259
+
260
+ **Version**: 0.1.0 (MVP)
261
+
262
+ ### Statistics
263
+
264
+ - **Lines of Code**: ~3,610 (implementation) + ~2,500 (tests)
265
+ - **Total Tests**: 197 tests across 5 phases
266
+ - **Test Coverage**: ~93% (exceeds 75% target)
267
+ - **Supported Python**: 3.9, 3.10, 3.11, 3.12
268
+ - **Quality**: Black 100%, Ruff 0 issues, MyPy 0 errors ✅
269
+ - **CI/CD**: GitHub Actions
270
+
271
+ ### Implementation Progress
272
+
273
+ - Phase 1: Core Foundation ✅ Complete
274
+ - Phase 2: Access Control & Versioning ✅ Complete
275
+ - Phase 3: RAG Integration & Search ✅ Complete
276
+ - Phase 4: Collaboration & Audit ✅ Complete
277
+ - Phase 5: Integrations ✅ Complete
278
+ - Phase 6: Polish & Documentation ✅ Complete
279
+
280
+ ## Support
281
+
282
+ - 📖 [Documentation](https://github.com/Nireus79/Socratic-knowledge#readme)
283
+ - 🐛 [Issues](https://github.com/Nireus79/Socratic-knowledge/issues)
284
+ - 💬 [Discussions](https://github.com/Nireus79/Socratic-knowledge/discussions)
285
+
286
+ ## Related Projects
287
+
288
+ - [Socratic Workflow](https://github.com/Nireus79/Socratic-workflow) - Workflow orchestration
289
+ - [Socratic Agents](https://github.com/Nireus79/Socratic-agents) - Multi-agent orchestration
290
+ - [Socratic RAG](https://github.com/Nireus79/Socratic-rag) - Retrieval-augmented generation
291
+ - [Socratic Analyzer](https://github.com/Nireus79/Socratic-analyzer) - Code analysis
292
+ - [Socrates Nexus](https://github.com/Nireus79/socrates-nexus) - Universal LLM client
293
+
294
+ ---
295
+
296
+ **Built with ❤️ by the Socratic Ecosystem**