@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,435 @@
1
+ ---
2
+ name: qdrant-memory
3
+ description: "Intelligent token optimization through Qdrant-powered semantic caching and long-term memory. Use for (1) Semantic Cache - avoid LLM calls entirely for semantically similar queries with 100% token savings, (2) Long-Term Memory - retrieve only relevant context chunks instead of full conversation history with 80-95% context reduction, (3) Hybrid Search - combine vector similarity with keyword filtering for technical queries, (4) Memory Management - store and retrieve conversation memories, decisions, and code patterns with metadata filtering. Triggers when needing to cache responses, remember past interactions, optimize context windows, or implement RAG patterns."
4
+ ---
5
+
6
+ # Qdrant Memory Skill
7
+
8
+ Token optimization engine using Qdrant vector database for semantic caching and intelligent memory retrieval.
9
+
10
+ ## Architecture Overview
11
+
12
+ ```
13
+ ┌─────────────────────────────────────────────────────────────┐
14
+ │ USER QUERY │
15
+ └─────────────────────────────────────────────────────────────┘
16
+
17
+
18
+ ┌─────────────────────────────────────────────────────────────┐
19
+ │ 1. SEMANTIC CACHE CHECK (Cache Hit = 100% Token Savings) │
20
+ │ ┌─────────────────┐ ┌─────────────────────────────────┐ │
21
+ │ │ Embed Query │───▶│ Search Qdrant (similarity>0.9) │ │
22
+ │ └─────────────────┘ └─────────────────────────────────┘ │
23
+ │ │ │
24
+ │ ┌─────────────────┴──────────────────┐ │
25
+ │ ▼ ▼ │
26
+ │ [CACHE HIT] [CACHE MISS] │
27
+ │ Return cached Continue to │
28
+ │ response LLM │
29
+ └─────────────────────────────────────────────────────────────┘
30
+
31
+
32
+ ┌─────────────────────────────────────────────────────────────┐
33
+ │ 2. CONTEXT RETRIEVAL (RAG - 80-95% Context Reduction) │
34
+ │ ┌─────────────────┐ ┌─────────────────────────────────┐ │
35
+ │ │ Identify Need │───▶│ Retrieve Top-K Relevant Chunks │ │
36
+ │ └─────────────────┘ └─────────────────────────────────┘ │
37
+ │ Instead of 20K tokens ───▶ Only 500-1000 tokens │
38
+ └─────────────────────────────────────────────────────────────┘
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Prerequisites
44
+
45
+ ### Qdrant (Vector Database)
46
+
47
+ ```bash
48
+ # Option 1: Docker (recommended)
49
+ docker run -d -p 6333:6333 -v qdrant_storage:/qdrant/storage qdrant/qdrant
50
+
51
+ # Option 2: Docker Compose (persistent)
52
+ # See references/complete_guide.md for docker-compose.yml
53
+ ```
54
+
55
+ ### Embeddings Provider
56
+
57
+ Choose based on your needs:
58
+
59
+ | Provider | Privacy | Cost | Speed | Setup |
60
+ | ------------------------ | -------------- | ---------------- | ------------ | ------------------------- |
61
+ | **Ollama** (recommended) | ✅ Fully Local | Free | Fast (Metal) | `brew install ollama` |
62
+ | **Bedrock** (AWS/Kiro) | ⚡ AWS Cloud | ~$0.02/1M tokens | Fast | Uses AWS profile (no key) |
63
+ | OpenAI | ❌ Cloud | ~$0.02/1M tokens | Fast | API key required |
64
+
65
+ #### Ollama Setup (M3 Mac Optimized)
66
+
67
+ ```bash
68
+ # 1. Install Ollama (if not already installed)
69
+ brew install ollama
70
+
71
+ # 2. Start server (choose one option)
72
+ ollama serve # Foreground (Ctrl+C to stop)
73
+ ollama serve & # Background (current terminal)
74
+ nohup ollama serve & # Background (survives terminal close)
75
+
76
+ # 3. Pull embedding model (768 dimensions, excellent quality)
77
+ ollama pull nomic-embed-text
78
+
79
+ # 4. Verify server is running
80
+ curl http://localhost:11434/api/tags
81
+
82
+ # 5. Test embedding generation
83
+ curl http://localhost:11434/api/embeddings -d '{"model":"nomic-embed-text","prompt":"hello"}'
84
+ ```
85
+
86
+ > **Tip**: To auto-start Ollama on login, add `ollama serve &` to your `~/.zshrc` or use `brew services start ollama`.
87
+
88
+ > **Note**: For Ollama, use `--dimension 768` when creating collections.
89
+
90
+ #### Amazon Bedrock Setup (AWS/Kiro Subscription)
91
+
92
+ Uses your existing AWS credentials - no secrets stored in code.
93
+
94
+ ```bash
95
+ # 1. Ensure AWS CLI is configured (uses ~/.aws/credentials)
96
+ aws configure # Or set AWS_PROFILE for specific profile
97
+
98
+ # 2. Install boto3 if not present
99
+ pip install boto3
100
+
101
+ # 3. Set environment variables
102
+ export EMBEDDING_PROVIDER=bedrock
103
+ export AWS_REGION=eu-west-1 # Default region
104
+
105
+ # 4. Test authentication
106
+ python3 skills/qdrant-memory/scripts/embedding_utils.py
107
+ ```
108
+
109
+ **Models Available** (cheapest first):
110
+
111
+ | Model | Dimensions | Pricing |
112
+ | ------------------------------ | ---------- | ---------------- |
113
+ | `amazon.titan-embed-text-v2:0` | 1024 | ~$0.02/1M tokens |
114
+ | `amazon.titan-embed-text-v1` | 1536 | ~$0.02/1M tokens |
115
+ | `cohere.embed-english-v3` | 1024 | ~$0.10/1M tokens |
116
+
117
+ > **Note**: For Bedrock Titan V2, use `--dimension 1024` when creating collections.
118
+
119
+ #### OpenAI Setup (Cloud)
120
+
121
+ ```bash
122
+ export OPENAI_API_KEY="sk-..."
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Quick Start
128
+
129
+ ### MCP Server Configuration
130
+
131
+ ```json
132
+ {
133
+ "qdrant-mcp": {
134
+ "command": "npx",
135
+ "args": ["-y", "@qdrant/mcp-server-qdrant"],
136
+ "env": {
137
+ "QDRANT_URL": "http://localhost:6333",
138
+ "QDRANT_API_KEY": "${QDRANT_API_KEY}",
139
+ "COLLECTION_NAME": "agent_memory"
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ ### Initialize Memory Collection
146
+
147
+ Run `scripts/init_collection.py` to create the optimized collection:
148
+
149
+ ```bash
150
+ # For Ollama (nomic-embed-text - 768 dimensions)
151
+ python3 scripts/init_collection.py --collection agent_memory --dimension 768
152
+
153
+ # For OpenAI (text-embedding-3-small - 1536 dimensions)
154
+ python3 scripts/init_collection.py --collection agent_memory --dimension 1536
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Core Capabilities
160
+
161
+ ### 1. Semantic Cache (Maximum Token Savings)
162
+
163
+ **Purpose**: Avoid LLM calls entirely for semantically similar queries.
164
+
165
+ **Flow**:
166
+
167
+ 1. Embed incoming query
168
+ 2. Search Qdrant for similar past queries (threshold > 0.9)
169
+ 3. If match found → return cached response (100% token savings)
170
+ 4. If no match → proceed to LLM, then cache result
171
+
172
+ **Implementation**:
173
+
174
+ ```python
175
+ # Cache check before LLM call
176
+ from scripts.semantic_cache import check_cache, store_response
177
+
178
+ # Check cache first
179
+ cached = check_cache(query, similarity_threshold=0.92)
180
+ if cached:
181
+ return cached["response"] # 100% token savings
182
+
183
+ # Generate response with LLM
184
+ response = llm.generate(query)
185
+
186
+ # Store for future cache hits
187
+ store_response(query, response, metadata={
188
+ "type": "cache",
189
+ "model": "gpt-4",
190
+ "tokens_saved": len(response.split())
191
+ })
192
+ ```
193
+
194
+ **Collection Schema**:
195
+
196
+ ```json
197
+ {
198
+ "collection": "semantic_cache",
199
+ "vectors": {
200
+ "size": 1536,
201
+ "distance": "Cosine"
202
+ },
203
+ "payload_schema": {
204
+ "query": "keyword",
205
+ "response": "text",
206
+ "timestamp": "datetime",
207
+ "model": "keyword",
208
+ "token_count": "integer"
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### 2. Long-Term Memory (Context Optimization)
214
+
215
+ **Purpose**: Retrieve only relevant context instead of full conversation history.
216
+
217
+ **Problem**: 20,000 token conversation history → Expensive + Confuses model
218
+ **Solution**: Query Qdrant → Return only top 3-5 relevant chunks (500-1000 tokens)
219
+
220
+ **Memory Types**:
221
+
222
+ | Type | Payload Filter | Use Case |
223
+ | ---------------- | ---------------------- | ----------------------------------- |
224
+ | `decision` | `type: "decision"` | Past architectural/design decisions |
225
+ | `code_pattern` | `type: "code"` | Previously written code patterns |
226
+ | `error_solution` | `type: "error"` | How past errors were resolved |
227
+ | `conversation` | `type: "conversation"` | Key conversation points |
228
+ | `technical` | `type: "technical"` | Technical knowledge/docs |
229
+
230
+ **Implementation**:
231
+
232
+ ```python
233
+ from scripts.memory_retrieval import retrieve_context
234
+
235
+ # Instead of passing 20K tokens of history:
236
+ relevant_chunks = retrieve_context(
237
+ query="What did we decide about the database architecture?",
238
+ filters={"type": "decision"},
239
+ top_k=5,
240
+ score_threshold=0.7
241
+ )
242
+
243
+ # Build optimized prompt with only relevant context
244
+ prompt = f"""
245
+ Relevant Context:
246
+ {relevant_chunks}
247
+
248
+ User Question: {user_query}
249
+ """
250
+ # Now only ~1000 tokens instead of 20,000
251
+ ```
252
+
253
+ ### 3. Hybrid Search (Vector + Keyword)
254
+
255
+ **Purpose**: Combine semantic similarity with exact keyword matching for technical queries.
256
+
257
+ **When to use**: Error codes, variable names, specific identifiers
258
+
259
+ ```python
260
+ from scripts.hybrid_search import hybrid_query
261
+
262
+ results = hybrid_query(
263
+ text_query="kubernetes deployment failed",
264
+ keyword_filters={
265
+ "error_code": "ImagePullBackOff",
266
+ "namespace": "production"
267
+ },
268
+ fusion_weights={"text": 0.7, "keyword": 0.3}
269
+ )
270
+ ```
271
+
272
+ ---
273
+
274
+ ## MCP Tools Reference
275
+
276
+ | Tool | Purpose |
277
+ | ---------------------------- | ------------------------------- |
278
+ | `qdrant_store_memory` | Store embeddings with metadata |
279
+ | `qdrant_search_memory` | Semantic search with filters |
280
+ | `qdrant_delete_memory` | Remove memories by ID or filter |
281
+ | `qdrant_list_collections` | View available collections |
282
+ | `qdrant_get_collection_info` | Collection stats and config |
283
+
284
+ ### Store Memory
285
+
286
+ ```json
287
+ {
288
+ "tool": "qdrant_store_memory",
289
+ "arguments": {
290
+ "content": "We decided to use PostgreSQL for user data due to ACID compliance requirements",
291
+ "metadata": {
292
+ "type": "decision",
293
+ "project": "api-catalogue",
294
+ "date": "2026-01-22",
295
+ "tags": ["database", "architecture"]
296
+ }
297
+ }
298
+ }
299
+ ```
300
+
301
+ ### Search Memory
302
+
303
+ ```json
304
+ {
305
+ "tool": "qdrant_search_memory",
306
+ "arguments": {
307
+ "query": "database architecture decisions",
308
+ "filter": {
309
+ "must": [{ "key": "type", "match": { "value": "decision" } }]
310
+ },
311
+ "limit": 5,
312
+ "score_threshold": 0.7
313
+ }
314
+ }
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Payload Filtering Patterns
320
+
321
+ ### Filter by Type
322
+
323
+ ```json
324
+ {
325
+ "filter": {
326
+ "must": [{ "key": "type", "match": { "value": "technical" } }]
327
+ }
328
+ }
329
+ ```
330
+
331
+ ### Filter by Project + Date Range
332
+
333
+ ```json
334
+ {
335
+ "filter": {
336
+ "must": [
337
+ { "key": "project", "match": { "value": "api-catalogue" } },
338
+ { "key": "timestamp", "range": { "gte": "2026-01-01" } }
339
+ ]
340
+ }
341
+ }
342
+ ```
343
+
344
+ ### Exclude Certain Tags
345
+
346
+ ```json
347
+ {
348
+ "filter": {
349
+ "must_not": [
350
+ { "key": "tags", "match": { "any": ["deprecated", "archived"] } }
351
+ ]
352
+ }
353
+ }
354
+ ```
355
+
356
+ ---
357
+
358
+ ## Collection Design Patterns
359
+
360
+ ### Single Collection (Simple)
361
+
362
+ ```
363
+ agent_memory/
364
+ ├── type: "cache" | "decision" | "code" | "error" | "conversation"
365
+ ├── project: "<project_name>"
366
+ ├── timestamp: "<ISO8601>"
367
+ └── content: "<text>"
368
+ ```
369
+
370
+ ### Multi-Collection (Advanced)
371
+
372
+ | Collection | Purpose | Retention |
373
+ | ---------------- | ----------------------- | --------- |
374
+ | `semantic_cache` | Query-response cache | 7 days |
375
+ | `decisions` | Architectural decisions | Permanent |
376
+ | `code_patterns` | Reusable code snippets | 90 days |
377
+ | `conversations` | Key conversation points | 30 days |
378
+ | `errors` | Error solutions | 60 days |
379
+
380
+ ---
381
+
382
+ ## Token Savings Metrics
383
+
384
+ Track savings with metadata:
385
+
386
+ ```python
387
+ {
388
+ "tokens_input_saved": 15000,
389
+ "tokens_output_saved": 2000,
390
+ "cost_saved_usd": 0.27,
391
+ "cache_hit": True,
392
+ "retrieval_latency_ms": 45
393
+ }
394
+ ```
395
+
396
+ **Expected Savings**:
397
+
398
+ | Scenario | Without Qdrant | With Qdrant | Savings |
399
+ | ----------------- | -------------- | ----------- | ------- |
400
+ | Repeated question | 8K tokens | 0 tokens | 100% |
401
+ | Context retrieval | 20K tokens | 1K tokens | 95% |
402
+ | Hybrid lookup | 15K tokens | 2K tokens | 87% |
403
+
404
+ ---
405
+
406
+ ## Best Practices
407
+
408
+ ### Embedding Model Selection
409
+
410
+ | Model | Dimensions | Speed | Quality | Use Case |
411
+ | ------------------------ | ---------- | ------- | --------- | ------------- |
412
+ | `text-embedding-3-small` | 1536 | Fast | Good | General use |
413
+ | `text-embedding-3-large` | 3072 | Medium | Excellent | High accuracy |
414
+ | `all-MiniLM-L6-v2` | 384 | Fastest | Good | Local/private |
415
+
416
+ ### Cache Invalidation
417
+
418
+ - **Time-based**: Expire cache entries after N days
419
+ - **Manual**: Clear cache when underlying data changes
420
+ - **Version-based**: Include model version in metadata
421
+
422
+ ### Memory Hygiene
423
+
424
+ 1. **Deduplicate**: Check similarity before storing
425
+ 2. **Prune**: Remove low-value memories periodically
426
+ 3. **Compress**: Summarize long conversations before storing
427
+
428
+ ---
429
+
430
+ ## References
431
+
432
+ - See `references/complete_guide.md` for **full setup, testing, and troubleshooting**
433
+ - See `references/collection_schemas.md` for complete schema definitions
434
+ - See `references/embedding_models.md` for model comparisons
435
+ - See `references/advanced_patterns.md` for RAG optimization patterns