@techwavedev/agi-agent-kit 1.1.3

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 (196) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +147 -0
  3. package/bin/init.js +471 -0
  4. package/package.json +36 -0
  5. package/templates/.agent/agents/backend-specialist.md +263 -0
  6. package/templates/.agent/agents/code-archaeologist.md +106 -0
  7. package/templates/.agent/agents/database-architect.md +226 -0
  8. package/templates/.agent/agents/debugger.md +225 -0
  9. package/templates/.agent/agents/devops-engineer.md +242 -0
  10. package/templates/.agent/agents/documentation-writer.md +104 -0
  11. package/templates/.agent/agents/explorer-agent.md +73 -0
  12. package/templates/.agent/agents/frontend-specialist.md +556 -0
  13. package/templates/.agent/agents/game-developer.md +162 -0
  14. package/templates/.agent/agents/mobile-developer.md +377 -0
  15. package/templates/.agent/agents/orchestrator.md +416 -0
  16. package/templates/.agent/agents/penetration-tester.md +188 -0
  17. package/templates/.agent/agents/performance-optimizer.md +187 -0
  18. package/templates/.agent/agents/product-manager.md +112 -0
  19. package/templates/.agent/agents/project-planner.md +403 -0
  20. package/templates/.agent/agents/qa-automation-engineer.md +109 -0
  21. package/templates/.agent/agents/security-auditor.md +170 -0
  22. package/templates/.agent/agents/seo-specialist.md +111 -0
  23. package/templates/.agent/agents/test-engineer.md +158 -0
  24. package/templates/.agent/rules/GEMINI.md +253 -0
  25. package/templates/.agent/workflows/brainstorm.md +113 -0
  26. package/templates/.agent/workflows/create.md +59 -0
  27. package/templates/.agent/workflows/debug.md +103 -0
  28. package/templates/.agent/workflows/deploy.md +176 -0
  29. package/templates/.agent/workflows/enhance.md +63 -0
  30. package/templates/.agent/workflows/orchestrate.md +237 -0
  31. package/templates/.agent/workflows/plan.md +89 -0
  32. package/templates/.agent/workflows/preview.md +81 -0
  33. package/templates/.agent/workflows/status.md +86 -0
  34. package/templates/.agent/workflows/test.md +144 -0
  35. package/templates/.agent/workflows/ui-ux-pro-max.md +296 -0
  36. package/templates/base/.env.example +54 -0
  37. package/templates/base/AGENTS.md +463 -0
  38. package/templates/base/requirements.txt +6 -0
  39. package/templates/base/skill-creator/LICENSE.txt +202 -0
  40. package/templates/base/skill-creator/SKILL_skillcreator.md +389 -0
  41. package/templates/base/skill-creator/references/output-patterns.md +82 -0
  42. package/templates/base/skill-creator/references/workflows.md +28 -0
  43. package/templates/base/skill-creator/scripts/init_skill.py +304 -0
  44. package/templates/base/skill-creator/scripts/package_skill.py +110 -0
  45. package/templates/base/skill-creator/scripts/quick_validate.py +95 -0
  46. package/templates/base/skill-creator/scripts/update_catalog.py +371 -0
  47. package/templates/skills/core/README.md +21 -0
  48. package/templates/skills/core/documentation/SKILL.md +351 -0
  49. package/templates/skills/core/documentation/references/best_practices.md +201 -0
  50. package/templates/skills/core/documentation/scripts/analyze_code.py +307 -0
  51. package/templates/skills/core/documentation/scripts/detect_changes.py +460 -0
  52. package/templates/skills/core/documentation/scripts/generate_changelog.py +312 -0
  53. package/templates/skills/core/documentation/scripts/sync_docs.py +272 -0
  54. package/templates/skills/core/documentation/scripts/update_skill_docs.py +366 -0
  55. package/templates/skills/core/pdf-reader/SKILL.md +104 -0
  56. package/templates/skills/core/pdf-reader/references/pdf_libraries.md +83 -0
  57. package/templates/skills/core/pdf-reader/scripts/extract_text.py +295 -0
  58. package/templates/skills/core/qdrant-memory/SKILL.md +435 -0
  59. package/templates/skills/core/qdrant-memory/references/advanced_patterns.md +375 -0
  60. package/templates/skills/core/qdrant-memory/references/collection_schemas.md +229 -0
  61. package/templates/skills/core/qdrant-memory/references/complete_guide.md +724 -0
  62. package/templates/skills/core/qdrant-memory/references/embedding_models.md +325 -0
  63. package/templates/skills/core/qdrant-memory/scripts/benchmark_token_savings.py +640 -0
  64. package/templates/skills/core/qdrant-memory/scripts/embedding_utils.py +323 -0
  65. package/templates/skills/core/qdrant-memory/scripts/hybrid_search.py +214 -0
  66. package/templates/skills/core/qdrant-memory/scripts/init_collection.py +193 -0
  67. package/templates/skills/core/qdrant-memory/scripts/memory_retrieval.py +345 -0
  68. package/templates/skills/core/qdrant-memory/scripts/semantic_cache.py +282 -0
  69. package/templates/skills/core/qdrant-memory/scripts/test_skill.py +655 -0
  70. package/templates/skills/core/webcrawler/SKILL.md +292 -0
  71. package/templates/skills/core/webcrawler/references/advanced_crawling.md +181 -0
  72. package/templates/skills/core/webcrawler/scripts/crawl_docs.py +532 -0
  73. package/templates/skills/core/webcrawler/scripts/extract_page.py +189 -0
  74. package/templates/skills/core/webcrawler/scripts/filter_docs.py +200 -0
  75. package/templates/skills/knowledge/api-patterns/SKILL.md +81 -0
  76. package/templates/skills/knowledge/api-patterns/api-style.md +42 -0
  77. package/templates/skills/knowledge/api-patterns/auth.md +24 -0
  78. package/templates/skills/knowledge/api-patterns/documentation.md +26 -0
  79. package/templates/skills/knowledge/api-patterns/graphql.md +41 -0
  80. package/templates/skills/knowledge/api-patterns/rate-limiting.md +31 -0
  81. package/templates/skills/knowledge/api-patterns/response.md +37 -0
  82. package/templates/skills/knowledge/api-patterns/rest.md +40 -0
  83. package/templates/skills/knowledge/api-patterns/scripts/api_validator.py +211 -0
  84. package/templates/skills/knowledge/api-patterns/security-testing.md +122 -0
  85. package/templates/skills/knowledge/api-patterns/trpc.md +41 -0
  86. package/templates/skills/knowledge/api-patterns/versioning.md +22 -0
  87. package/templates/skills/knowledge/app-builder/SKILL.md +75 -0
  88. package/templates/skills/knowledge/app-builder/agent-coordination.md +71 -0
  89. package/templates/skills/knowledge/app-builder/feature-building.md +53 -0
  90. package/templates/skills/knowledge/app-builder/project-detection.md +34 -0
  91. package/templates/skills/knowledge/app-builder/scaffolding.md +118 -0
  92. package/templates/skills/knowledge/app-builder/tech-stack.md +40 -0
  93. package/templates/skills/knowledge/app-builder/templates/SKILL.md +39 -0
  94. package/templates/skills/knowledge/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  95. package/templates/skills/knowledge/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  96. package/templates/skills/knowledge/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  97. package/templates/skills/knowledge/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  98. package/templates/skills/knowledge/app-builder/templates/express-api/TEMPLATE.md +83 -0
  99. package/templates/skills/knowledge/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  100. package/templates/skills/knowledge/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  101. package/templates/skills/knowledge/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
  102. package/templates/skills/knowledge/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
  103. package/templates/skills/knowledge/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
  104. package/templates/skills/knowledge/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
  105. package/templates/skills/knowledge/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  106. package/templates/skills/knowledge/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
  107. package/templates/skills/knowledge/architecture/SKILL.md +55 -0
  108. package/templates/skills/knowledge/architecture/context-discovery.md +43 -0
  109. package/templates/skills/knowledge/architecture/examples.md +94 -0
  110. package/templates/skills/knowledge/architecture/pattern-selection.md +68 -0
  111. package/templates/skills/knowledge/architecture/patterns-reference.md +50 -0
  112. package/templates/skills/knowledge/architecture/trade-off-analysis.md +77 -0
  113. package/templates/skills/knowledge/bash-linux/SKILL.md +199 -0
  114. package/templates/skills/knowledge/behavioral-modes/SKILL.md +242 -0
  115. package/templates/skills/knowledge/brainstorming/SKILL.md +163 -0
  116. package/templates/skills/knowledge/brainstorming/dynamic-questioning.md +350 -0
  117. package/templates/skills/knowledge/clean-code/SKILL.md +201 -0
  118. package/templates/skills/knowledge/code-review-checklist/SKILL.md +109 -0
  119. package/templates/skills/knowledge/database-design/SKILL.md +52 -0
  120. package/templates/skills/knowledge/database-design/database-selection.md +43 -0
  121. package/templates/skills/knowledge/database-design/indexing.md +39 -0
  122. package/templates/skills/knowledge/database-design/migrations.md +48 -0
  123. package/templates/skills/knowledge/database-design/optimization.md +36 -0
  124. package/templates/skills/knowledge/database-design/orm-selection.md +30 -0
  125. package/templates/skills/knowledge/database-design/schema-design.md +56 -0
  126. package/templates/skills/knowledge/database-design/scripts/schema_validator.py +172 -0
  127. package/templates/skills/knowledge/deployment-procedures/SKILL.md +241 -0
  128. package/templates/skills/knowledge/doc.md +177 -0
  129. package/templates/skills/knowledge/documentation-templates/SKILL.md +194 -0
  130. package/templates/skills/knowledge/frontend-design/SKILL.md +396 -0
  131. package/templates/skills/knowledge/frontend-design/animation-guide.md +331 -0
  132. package/templates/skills/knowledge/frontend-design/color-system.md +311 -0
  133. package/templates/skills/knowledge/frontend-design/decision-trees.md +418 -0
  134. package/templates/skills/knowledge/frontend-design/motion-graphics.md +306 -0
  135. package/templates/skills/knowledge/frontend-design/scripts/accessibility_checker.py +183 -0
  136. package/templates/skills/knowledge/frontend-design/scripts/ux_audit.py +722 -0
  137. package/templates/skills/knowledge/frontend-design/typography-system.md +345 -0
  138. package/templates/skills/knowledge/frontend-design/ux-psychology.md +541 -0
  139. package/templates/skills/knowledge/frontend-design/visual-effects.md +383 -0
  140. package/templates/skills/knowledge/game-development/2d-games/SKILL.md +119 -0
  141. package/templates/skills/knowledge/game-development/3d-games/SKILL.md +135 -0
  142. package/templates/skills/knowledge/game-development/SKILL.md +167 -0
  143. package/templates/skills/knowledge/game-development/game-art/SKILL.md +185 -0
  144. package/templates/skills/knowledge/game-development/game-audio/SKILL.md +190 -0
  145. package/templates/skills/knowledge/game-development/game-design/SKILL.md +129 -0
  146. package/templates/skills/knowledge/game-development/mobile-games/SKILL.md +108 -0
  147. package/templates/skills/knowledge/game-development/multiplayer/SKILL.md +132 -0
  148. package/templates/skills/knowledge/game-development/pc-games/SKILL.md +144 -0
  149. package/templates/skills/knowledge/game-development/vr-ar/SKILL.md +123 -0
  150. package/templates/skills/knowledge/game-development/web-games/SKILL.md +150 -0
  151. package/templates/skills/knowledge/geo-fundamentals/SKILL.md +156 -0
  152. package/templates/skills/knowledge/geo-fundamentals/scripts/geo_checker.py +289 -0
  153. package/templates/skills/knowledge/i18n-localization/SKILL.md +154 -0
  154. package/templates/skills/knowledge/i18n-localization/scripts/i18n_checker.py +241 -0
  155. package/templates/skills/knowledge/intelligent-routing/SKILL.md +334 -0
  156. package/templates/skills/knowledge/lint-and-validate/SKILL.md +45 -0
  157. package/templates/skills/knowledge/lint-and-validate/scripts/lint_runner.py +172 -0
  158. package/templates/skills/knowledge/lint-and-validate/scripts/type_coverage.py +173 -0
  159. package/templates/skills/knowledge/mcp-builder/SKILL.md +176 -0
  160. package/templates/skills/knowledge/mobile-design/SKILL.md +394 -0
  161. package/templates/skills/knowledge/mobile-design/decision-trees.md +516 -0
  162. package/templates/skills/knowledge/mobile-design/mobile-backend.md +491 -0
  163. package/templates/skills/knowledge/mobile-design/mobile-color-system.md +420 -0
  164. package/templates/skills/knowledge/mobile-design/mobile-debugging.md +122 -0
  165. package/templates/skills/knowledge/mobile-design/mobile-design-thinking.md +357 -0
  166. package/templates/skills/knowledge/mobile-design/mobile-navigation.md +458 -0
  167. package/templates/skills/knowledge/mobile-design/mobile-performance.md +767 -0
  168. package/templates/skills/knowledge/mobile-design/mobile-testing.md +356 -0
  169. package/templates/skills/knowledge/mobile-design/mobile-typography.md +433 -0
  170. package/templates/skills/knowledge/mobile-design/platform-android.md +666 -0
  171. package/templates/skills/knowledge/mobile-design/platform-ios.md +561 -0
  172. package/templates/skills/knowledge/mobile-design/scripts/mobile_audit.py +670 -0
  173. package/templates/skills/knowledge/mobile-design/touch-psychology.md +537 -0
  174. package/templates/skills/knowledge/nextjs-best-practices/SKILL.md +203 -0
  175. package/templates/skills/knowledge/nodejs-best-practices/SKILL.md +333 -0
  176. package/templates/skills/knowledge/parallel-agents/SKILL.md +175 -0
  177. package/templates/skills/knowledge/performance-profiling/SKILL.md +143 -0
  178. package/templates/skills/knowledge/performance-profiling/scripts/lighthouse_audit.py +76 -0
  179. package/templates/skills/knowledge/plan-writing/SKILL.md +152 -0
  180. package/templates/skills/knowledge/powershell-windows/SKILL.md +167 -0
  181. package/templates/skills/knowledge/python-patterns/SKILL.md +441 -0
  182. package/templates/skills/knowledge/react-patterns/SKILL.md +198 -0
  183. package/templates/skills/knowledge/red-team-tactics/SKILL.md +199 -0
  184. package/templates/skills/knowledge/seo-fundamentals/SKILL.md +129 -0
  185. package/templates/skills/knowledge/seo-fundamentals/scripts/seo_checker.py +219 -0
  186. package/templates/skills/knowledge/server-management/SKILL.md +161 -0
  187. package/templates/skills/knowledge/systematic-debugging/SKILL.md +109 -0
  188. package/templates/skills/knowledge/tailwind-patterns/SKILL.md +269 -0
  189. package/templates/skills/knowledge/tdd-workflow/SKILL.md +149 -0
  190. package/templates/skills/knowledge/testing-patterns/SKILL.md +178 -0
  191. package/templates/skills/knowledge/testing-patterns/scripts/test_runner.py +219 -0
  192. package/templates/skills/knowledge/vulnerability-scanner/SKILL.md +276 -0
  193. package/templates/skills/knowledge/vulnerability-scanner/checklists.md +121 -0
  194. package/templates/skills/knowledge/vulnerability-scanner/scripts/security_scan.py +458 -0
  195. package/templates/skills/knowledge/webapp-testing/SKILL.md +187 -0
  196. package/templates/skills/knowledge/webapp-testing/scripts/playwright_runner.py +173 -0
@@ -0,0 +1,724 @@
1
+ # Qdrant Memory Skill - Complete Guide
2
+
3
+ Complete setup, usage, and testing documentation for the Qdrant-powered token optimization system.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Overview](#overview)
10
+ 2. [Prerequisites](#prerequisites)
11
+ 3. [Qdrant Setup](#qdrant-setup)
12
+ 4. [Environment Configuration](#environment-configuration)
13
+ 5. [Collection Initialization](#collection-initialization)
14
+ 6. [Usage Guide](#usage-guide)
15
+ 7. [Testing](#testing)
16
+ 8. [Troubleshooting](#troubleshooting)
17
+ 9. [Production Considerations](#production-considerations)
18
+
19
+ ---
20
+
21
+ ## Overview
22
+
23
+ The Qdrant Memory Skill provides intelligent token optimization through:
24
+
25
+ | Feature | Token Savings | Use Case |
26
+ | -------------------- | ------------- | -------------------------------------------- |
27
+ | **Semantic Cache** | 100% | Avoid LLM calls for repeated/similar queries |
28
+ | **Long-Term Memory** | 80-95% | Retrieve only relevant context chunks |
29
+ | **Hybrid Search** | 87% | Combine vectors with keyword filtering |
30
+
31
+ ### Architecture
32
+
33
+ ```
34
+ USER QUERY
35
+
36
+
37
+ ┌─────────────────────────────┐
38
+ │ 1. Semantic Cache Check │ ──── Cache Hit? → Return cached (100% savings)
39
+ └─────────────────────────────┘
40
+ │ Cache Miss
41
+
42
+ ┌─────────────────────────────┐
43
+ │ 2. Context Retrieval │ ──── Retrieve top-K relevant chunks
44
+ └─────────────────────────────┘
45
+
46
+
47
+ ┌─────────────────────────────┐
48
+ │ 3. LLM Call (optimized) │ ──── Only 1K tokens instead of 20K
49
+ └─────────────────────────────┘
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Prerequisites
55
+
56
+ ### Required
57
+
58
+ - **Python 3.9+** with pip
59
+ - **OpenAI API Key** (for embeddings)
60
+ - **Docker** (for local Qdrant) OR **Qdrant Cloud** account
61
+
62
+ ### Optional
63
+
64
+ - Node.js 18+ (for MCP server)
65
+ - Local embedding models (for offline use)
66
+
67
+ ### Python Dependencies
68
+
69
+ ```bash
70
+ # Required for scripts
71
+ pip install requests
72
+
73
+ # Optional for local embeddings
74
+ pip install sentence-transformers torch
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Qdrant Setup
80
+
81
+ ### Option 1: Docker (Recommended for Development)
82
+
83
+ ```bash
84
+ # Pull and run Qdrant
85
+ docker run -d \
86
+ --name qdrant \
87
+ -p 6333:6333 \
88
+ -p 6334:6334 \
89
+ -v $(pwd)/qdrant_storage:/qdrant/storage:z \
90
+ qdrant/qdrant:latest
91
+
92
+ # Verify it's running
93
+ curl http://localhost:6333/health
94
+ # Expected: {"title":"qdrant - vector search engine","version":"..."}
95
+ ```
96
+
97
+ ### Option 2: Docker Compose
98
+
99
+ Create `docker-compose.qdrant.yml`:
100
+
101
+ ```yaml
102
+ version: "3.8"
103
+ services:
104
+ qdrant:
105
+ image: qdrant/qdrant:latest
106
+ container_name: qdrant
107
+ ports:
108
+ - "6333:6333" # REST API
109
+ - "6334:6334" # gRPC
110
+ volumes:
111
+ - ./qdrant_storage:/qdrant/storage
112
+ environment:
113
+ - QDRANT__SERVICE__GRPC_PORT=6334
114
+ - QDRANT__SERVICE__HTTP_PORT=6333
115
+ # Uncomment for API key protection
116
+ # - QDRANT__SERVICE__API_KEY=your-secret-key
117
+ restart: unless-stopped
118
+ ```
119
+
120
+ Run:
121
+
122
+ ```bash
123
+ docker compose -f docker-compose.qdrant.yml up -d
124
+ ```
125
+
126
+ ### Option 3: Qdrant Cloud (Production)
127
+
128
+ 1. Create account at [cloud.qdrant.io](https://cloud.qdrant.io)
129
+ 2. Create a cluster (Free tier available)
130
+ 3. Get your cluster URL and API key
131
+ 4. Configure environment:
132
+
133
+ ```bash
134
+ export QDRANT_URL="https://your-cluster-id.us-east4-0.gcp.cloud.qdrant.io:6333"
135
+ export QDRANT_API_KEY="your-api-key"
136
+ ```
137
+
138
+ ### Option 4: Kubernetes (EKS/Production)
139
+
140
+ ```bash
141
+ # Add Qdrant Helm repo
142
+ helm repo add qdrant https://qdrant.github.io/qdrant-helm
143
+ helm repo update
144
+
145
+ # Install Qdrant
146
+ helm install qdrant qdrant/qdrant \
147
+ --namespace qdrant \
148
+ --create-namespace \
149
+ --set replicaCount=3 \
150
+ --set persistence.size=10Gi \
151
+ --set service.type=ClusterIP
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Environment Configuration
157
+
158
+ ### Create Environment File
159
+
160
+ ```bash
161
+ # Create .env file in your project
162
+ cat > .env.qdrant << 'EOF'
163
+ # Qdrant Configuration
164
+ QDRANT_URL=http://localhost:6333
165
+ QDRANT_API_KEY=
166
+
167
+ # Collections
168
+ MEMORY_COLLECTION=agent_memory
169
+ CACHE_COLLECTION=semantic_cache
170
+
171
+ # OpenAI Configuration
172
+ OPENAI_API_KEY=sk-your-api-key-here
173
+ EMBEDDING_MODEL=text-embedding-3-small
174
+ EMBEDDING_DIMENSION=1536
175
+
176
+ # Cache Settings
177
+ CACHE_THRESHOLD=0.92
178
+ CACHE_TTL_DAYS=7
179
+
180
+ # Memory Settings
181
+ MEMORY_TOP_K=5
182
+ MEMORY_THRESHOLD=0.7
183
+ EOF
184
+ ```
185
+
186
+ ### Load Environment
187
+
188
+ ```bash
189
+ # In your shell
190
+ source .env.qdrant
191
+ export $(grep -v '^#' .env.qdrant | xargs)
192
+ ```
193
+
194
+ ### MCP Server Configuration
195
+
196
+ Add to your Claude Desktop or MCP config:
197
+
198
+ ```json
199
+ {
200
+ "mcpServers": {
201
+ "qdrant-memory": {
202
+ "command": "npx",
203
+ "args": ["-y", "@qdrant/mcp-server-qdrant"],
204
+ "env": {
205
+ "QDRANT_URL": "http://localhost:6333",
206
+ "QDRANT_API_KEY": "",
207
+ "COLLECTION_NAME": "agent_memory"
208
+ }
209
+ }
210
+ }
211
+ }
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Collection Initialization
217
+
218
+ ### Initialize Collections
219
+
220
+ Navigate to the skill directory and run:
221
+
222
+ ```bash
223
+ cd /path/to/agi/skills/qdrant-memory
224
+
225
+ # Initialize main memory collection
226
+ python scripts/init_collection.py \
227
+ --collection agent_memory \
228
+ --dimension 1536 \
229
+ --distance cosine
230
+
231
+ # Initialize semantic cache collection
232
+ python scripts/init_collection.py \
233
+ --collection semantic_cache \
234
+ --dimension 1536 \
235
+ --distance cosine
236
+ ```
237
+
238
+ Expected output:
239
+
240
+ ```
241
+ 🔧 Initializing collection: agent_memory
242
+ URL: http://localhost:6333
243
+ Dimension: 1536
244
+ Distance: cosine
245
+ ✅ Collection created: {'status': 'ok', 'result': True}
246
+ 📑 Creating payload indexes...
247
+ type: created
248
+ project: created
249
+ timestamp: created
250
+ tags: created
251
+ model: created
252
+ token_count: created
253
+ score_threshold: created
254
+ {"status": "success", "collection": "agent_memory", "dimension": 1536, "distance": "cosine"}
255
+ ```
256
+
257
+ ### Verify Collections
258
+
259
+ ```bash
260
+ # Check collections exist
261
+ curl http://localhost:6333/collections | jq
262
+
263
+ # Check specific collection
264
+ curl http://localhost:6333/collections/agent_memory | jq
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Usage Guide
270
+
271
+ ### 1. Semantic Cache - 100% Token Savings
272
+
273
+ #### Check Cache Before LLM Call
274
+
275
+ ```bash
276
+ # Check if a similar query exists
277
+ python scripts/semantic_cache.py check \
278
+ --query "How do I reset my password?" \
279
+ --threshold 0.92
280
+ ```
281
+
282
+ **Cache Hit Response:**
283
+
284
+ ```json
285
+ {
286
+ "cache_hit": true,
287
+ "score": 0.94,
288
+ "query": "How can I reset my password?",
289
+ "response": "To reset your password, go to Settings > Account > Reset Password...",
290
+ "timestamp": "2026-01-22T10:30:00Z",
291
+ "tokens_saved": 150
292
+ }
293
+ ```
294
+
295
+ **Cache Miss Response:**
296
+
297
+ ```json
298
+ {
299
+ "cache_hit": false,
300
+ "query": "How do I reset my password?"
301
+ }
302
+ ```
303
+
304
+ #### Store Response in Cache
305
+
306
+ ```bash
307
+ # After LLM generates a response, cache it
308
+ python scripts/semantic_cache.py store \
309
+ --query "How do I reset my password?" \
310
+ --response "To reset your password, navigate to Settings > Account > Reset Password. Click the 'Reset' button and follow the email instructions." \
311
+ --model gpt-4 \
312
+ --project api-catalogue
313
+ ```
314
+
315
+ #### Clear Old Cache Entries
316
+
317
+ ```bash
318
+ # Remove entries older than 7 days
319
+ python scripts/semantic_cache.py clear --older-than 7
320
+ ```
321
+
322
+ ### 2. Long-Term Memory - Context Optimization
323
+
324
+ #### Store a Memory
325
+
326
+ ```bash
327
+ python scripts/memory_retrieval.py store \
328
+ --content "We decided to use PostgreSQL for the user database due to ACID compliance requirements. MongoDB was considered but rejected for this use case." \
329
+ --type decision \
330
+ --project api-catalogue \
331
+ --tags database architecture
332
+ ```
333
+
334
+ #### Retrieve Relevant Context
335
+
336
+ ```bash
337
+ # Retrieve memories about database decisions
338
+ python scripts/memory_retrieval.py retrieve \
339
+ --query "What database did we choose and why?" \
340
+ --type decision \
341
+ --project api-catalogue \
342
+ --top-k 5 \
343
+ --threshold 0.7
344
+ ```
345
+
346
+ **Response:**
347
+
348
+ ```json
349
+ {
350
+ "chunks": [
351
+ {
352
+ "content": "We decided to use PostgreSQL for the user database...",
353
+ "score": 0.89,
354
+ "type": "decision",
355
+ "project": "api-catalogue",
356
+ "timestamp": "2026-01-22T10:30:00Z",
357
+ "tags": ["database", "architecture"],
358
+ "token_estimate": 35
359
+ }
360
+ ],
361
+ "total_chunks": 1,
362
+ "total_tokens_estimate": 35,
363
+ "query": "What database did we choose and why?"
364
+ }
365
+ ```
366
+
367
+ #### List Memories
368
+
369
+ ```bash
370
+ # List all decision memories for a project
371
+ python scripts/memory_retrieval.py list \
372
+ --type decision \
373
+ --project api-catalogue \
374
+ --limit 20
375
+ ```
376
+
377
+ ### 3. Hybrid Search - Vector + Keyword
378
+
379
+ ```bash
380
+ # Search for Kubernetes errors with specific error code
381
+ python scripts/hybrid_search.py \
382
+ --query "kubernetes deployment failed" \
383
+ --keyword error_code=ImagePullBackOff \
384
+ --keyword namespace=production \
385
+ --top-k 5 \
386
+ --threshold 0.6
387
+ ```
388
+
389
+ ---
390
+
391
+ ## Testing
392
+
393
+ ### Test 1: Verify Qdrant Connection
394
+
395
+ ```bash
396
+ # Check Qdrant health
397
+ curl -s http://localhost:6333/health | jq
398
+ ```
399
+
400
+ Expected:
401
+
402
+ ```json
403
+ {
404
+ "title": "qdrant - vector search engine",
405
+ "version": "1.x.x"
406
+ }
407
+ ```
408
+
409
+ ### Test 2: Collection Initialization
410
+
411
+ ```bash
412
+ # Create test collection
413
+ python scripts/init_collection.py \
414
+ --collection test_collection \
415
+ --dimension 1536
416
+
417
+ # Verify
418
+ curl -s http://localhost:6333/collections/test_collection | jq '.result.status'
419
+ # Expected: "green"
420
+
421
+ # Cleanup
422
+ curl -X DELETE http://localhost:6333/collections/test_collection
423
+ ```
424
+
425
+ ### Test 3: Semantic Cache Round-Trip
426
+
427
+ ```bash
428
+ export OPENAI_API_KEY="sk-your-key"
429
+
430
+ # Store a test response
431
+ python scripts/semantic_cache.py store \
432
+ --query "What is the capital of France?" \
433
+ --response "The capital of France is Paris." \
434
+ --model gpt-4
435
+
436
+ # Check cache hit with exact query
437
+ python scripts/semantic_cache.py check \
438
+ --query "What is the capital of France?" \
439
+ --threshold 0.9
440
+
441
+ # Check cache hit with similar query
442
+ python scripts/semantic_cache.py check \
443
+ --query "What's France's capital city?" \
444
+ --threshold 0.85
445
+ ```
446
+
447
+ ### Test 4: Memory Storage and Retrieval
448
+
449
+ ```bash
450
+ # Store test memories
451
+ python scripts/memory_retrieval.py store \
452
+ --content "We implemented JWT authentication with RS256 signing." \
453
+ --type decision \
454
+ --project test-project \
455
+ --tags auth security
456
+
457
+ python scripts/memory_retrieval.py store \
458
+ --content "The API rate limit is set to 100 requests per minute per user." \
459
+ --type technical \
460
+ --project test-project \
461
+ --tags api limits
462
+
463
+ # Retrieve by type
464
+ python scripts/memory_retrieval.py retrieve \
465
+ --query "How is authentication implemented?" \
466
+ --type decision \
467
+ --top-k 3
468
+
469
+ # Retrieve without filter
470
+ python scripts/memory_retrieval.py retrieve \
471
+ --query "API request limits" \
472
+ --top-k 3
473
+ ```
474
+
475
+ ### Test 5: Hybrid Search
476
+
477
+ ```bash
478
+ # Store test data with specific metadata
479
+ python scripts/memory_retrieval.py store \
480
+ --content "Error: ImagePullBackOff in production namespace for api-gateway deployment" \
481
+ --type error \
482
+ --project kubernetes \
483
+ --tags production error
484
+
485
+ # Hybrid search with keyword filter
486
+ python scripts/hybrid_search.py \
487
+ --query "image pull error" \
488
+ --keyword type=error \
489
+ --top-k 5
490
+ ```
491
+
492
+ ### Test 6: End-to-End Token Savings Simulation
493
+
494
+ ```bash
495
+ #!/bin/bash
496
+ # test_token_savings.sh
497
+
498
+ echo "=== Token Savings Simulation ==="
499
+
500
+ # Simulate first query (cache miss)
501
+ echo "1. First query (should be cache miss):"
502
+ python scripts/semantic_cache.py check \
503
+ --query "Explain the architecture of our authentication system" \
504
+ --threshold 0.9
505
+ echo ""
506
+
507
+ # Simulate LLM response and store
508
+ echo "2. Storing LLM response in cache:"
509
+ python scripts/semantic_cache.py store \
510
+ --query "Explain the architecture of our authentication system" \
511
+ --response "Our authentication system uses JWT tokens with RS256 signing. The flow is: 1) User submits credentials, 2) Server validates and issues JWT, 3) Client stores token, 4) Token is passed in Authorization header for subsequent requests. The token expires after 1 hour and can be refreshed using a refresh token." \
512
+ --model gpt-4
513
+ echo ""
514
+
515
+ # Simulate similar query (should be cache hit)
516
+ echo "3. Similar query (should be cache hit - 100% savings):"
517
+ python scripts/semantic_cache.py check \
518
+ --query "How does our auth system work?" \
519
+ --threshold 0.85
520
+
521
+ echo ""
522
+ echo "=== Test Complete ==="
523
+ ```
524
+
525
+ ---
526
+
527
+ ## Troubleshooting
528
+
529
+ ### Connection Errors
530
+
531
+ ```
532
+ Error: Cannot connect to Qdrant at http://localhost:6333
533
+ ```
534
+
535
+ **Solutions:**
536
+
537
+ 1. Verify Qdrant is running:
538
+
539
+ ```bash
540
+ docker ps | grep qdrant
541
+ ```
542
+
543
+ 2. Check port binding:
544
+
545
+ ```bash
546
+ curl http://localhost:6333/health
547
+ ```
548
+
549
+ 3. Check firewall/network:
550
+ ```bash
551
+ netstat -an | grep 6333
552
+ ```
553
+
554
+ ### Embedding Errors
555
+
556
+ ```
557
+ Error: OPENAI_API_KEY environment variable not set
558
+ ```
559
+
560
+ **Solution:**
561
+
562
+ ```bash
563
+ export OPENAI_API_KEY="sk-your-key-here"
564
+ ```
565
+
566
+ ### Collection Not Found
567
+
568
+ ```
569
+ Error: Collection 'agent_memory' not found
570
+ ```
571
+
572
+ **Solution:**
573
+
574
+ ```bash
575
+ python scripts/init_collection.py --collection agent_memory --dimension 1536
576
+ ```
577
+
578
+ ### Low Similarity Scores
579
+
580
+ If cache hits are rare:
581
+
582
+ 1. Lower the threshold:
583
+
584
+ ```bash
585
+ python scripts/semantic_cache.py check --query "..." --threshold 0.8
586
+ ```
587
+
588
+ 2. Check embedding model consistency (use same model for store and search)
589
+
590
+ 3. Verify content quality (longer, more detailed text = better matching)
591
+
592
+ ### Memory Issues with Large Collections
593
+
594
+ For collections > 1M vectors:
595
+
596
+ ```bash
597
+ # Enable disk-based index
598
+ curl -X PATCH http://localhost:6333/collections/agent_memory \
599
+ -H "Content-Type: application/json" \
600
+ -d '{
601
+ "optimizers_config": {
602
+ "memmap_threshold": 10000
603
+ }
604
+ }'
605
+ ```
606
+
607
+ ---
608
+
609
+ ## Production Considerations
610
+
611
+ ### High Availability
612
+
613
+ ```yaml
614
+ # Qdrant HA configuration (Kubernetes)
615
+ replicaCount: 3
616
+ qdrant:
617
+ config:
618
+ cluster:
619
+ enabled: true
620
+ storage:
621
+ wal:
622
+ wal_capacity_mb: 256
623
+ ```
624
+
625
+ ### Performance Tuning
626
+
627
+ ```json
628
+ {
629
+ "optimizers_config": {
630
+ "indexing_threshold": 20000,
631
+ "memmap_threshold": 50000
632
+ },
633
+ "hnsw_config": {
634
+ "m": 32,
635
+ "ef_construct": 200
636
+ }
637
+ }
638
+ ```
639
+
640
+ ### Backup Strategy
641
+
642
+ ```bash
643
+ # Snapshot collection
644
+ curl -X POST "http://localhost:6333/collections/agent_memory/snapshots"
645
+
646
+ # List snapshots
647
+ curl "http://localhost:6333/collections/agent_memory/snapshots"
648
+
649
+ # Restore from snapshot
650
+ curl -X PUT "http://localhost:6333/collections/agent_memory/snapshots/recover" \
651
+ -H "Content-Type: application/json" \
652
+ -d '{"location": "/qdrant/snapshots/agent_memory/snapshot-2026-01-22.snapshot"}'
653
+ ```
654
+
655
+ ### Monitoring
656
+
657
+ Key metrics to monitor:
658
+
659
+ | Metric | Warning | Critical |
660
+ | -------------- | ------- | -------- |
661
+ | Search Latency | > 100ms | > 500ms |
662
+ | Memory Usage | > 80% | > 95% |
663
+ | Indexing Queue | > 10K | > 100K |
664
+ | Cache Hit Rate | < 50% | < 20% |
665
+
666
+ ### Security
667
+
668
+ ```bash
669
+ # Enable API key authentication
670
+ docker run -d \
671
+ -e QDRANT__SERVICE__API_KEY=your-secure-key \
672
+ -p 6333:6333 \
673
+ qdrant/qdrant
674
+
675
+ # Use API key in requests
676
+ export QDRANT_API_KEY="your-secure-key"
677
+ curl -H "api-key: $QDRANT_API_KEY" http://localhost:6333/collections
678
+ ```
679
+
680
+ ---
681
+
682
+ ## Quick Reference
683
+
684
+ ### Script Commands
685
+
686
+ | Action | Command |
687
+ | --------------- | ----------------------------------------------------------------------- |
688
+ | Init collection | `python scripts/init_collection.py --collection NAME` |
689
+ | Check cache | `python scripts/semantic_cache.py check --query "..."` |
690
+ | Store cache | `python scripts/semantic_cache.py store --query "..." --response "..."` |
691
+ | Clear cache | `python scripts/semantic_cache.py clear --older-than 7` |
692
+ | Store memory | `python scripts/memory_retrieval.py store --content "..." --type TYPE` |
693
+ | Retrieve memory | `python scripts/memory_retrieval.py retrieve --query "..."` |
694
+ | List memories | `python scripts/memory_retrieval.py list --type TYPE` |
695
+ | Hybrid search | `python scripts/hybrid_search.py --query "..." --keyword key=value` |
696
+
697
+ ### Environment Variables
698
+
699
+ | Variable | Default | Description |
700
+ | ------------------- | ------------------------ | ---------------------- |
701
+ | `QDRANT_URL` | `http://localhost:6333` | Qdrant server URL |
702
+ | `QDRANT_API_KEY` | (none) | API key if required |
703
+ | `MEMORY_COLLECTION` | `agent_memory` | Memory collection name |
704
+ | `CACHE_COLLECTION` | `semantic_cache` | Cache collection name |
705
+ | `OPENAI_API_KEY` | (required) | OpenAI API key |
706
+ | `EMBEDDING_MODEL` | `text-embedding-3-small` | Embedding model |
707
+
708
+ ### Token Savings Cheat Sheet
709
+
710
+ | Scenario | Before | After | Savings |
711
+ | ----------------- | ---------- | --------- | ------- |
712
+ | Repeated question | 8K tokens | 0 tokens | 100% |
713
+ | Context retrieval | 20K tokens | 1K tokens | 95% |
714
+ | Hybrid lookup | 15K tokens | 2K tokens | 87% |
715
+
716
+ ---
717
+
718
+ ## Next Steps
719
+
720
+ 1. **Start small**: Begin with semantic caching for frequently asked questions
721
+ 2. **Monitor savings**: Track token costs before/after implementation
722
+ 3. **Tune thresholds**: Adjust similarity thresholds based on your use case
723
+ 4. **Scale gradually**: Start with Docker, move to Qdrant Cloud for production
724
+ 5. **Add memory types**: Customize memory categories for your domain