@softspark/ai-toolkit 1.2.0 → 1.3.0

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 (142) hide show
  1. package/AGENTS.md +5 -29
  2. package/CHANGELOG.md +39 -0
  3. package/README.md +170 -27
  4. package/app/.claude-plugin/plugin.json +2 -2
  5. package/app/ARCHITECTURE.md +35 -19
  6. package/app/agents/ai-engineer.md +47 -5
  7. package/app/agents/fact-checker.md +1 -1
  8. package/app/agents/llm-ops-engineer.md +2 -2
  9. package/app/agents/{mcp-server-architect.md → mcp-specialist.md} +124 -18
  10. package/app/agents/mcp-testing-engineer.md +2 -2
  11. package/app/agents/nlp-engineer.md +1 -1
  12. package/app/agents/orchestrator.md +3 -4
  13. package/app/agents/project-planner.md +1 -1
  14. package/app/agents/technical-researcher.md +71 -21
  15. package/app/hooks/commit-quality.sh +53 -0
  16. package/app/hooks/governance-capture.sh +77 -0
  17. package/app/hooks/guard-config.sh +46 -0
  18. package/app/hooks/mcp-health.sh +53 -0
  19. package/app/hooks/pre-compact-save.sh +34 -0
  20. package/app/hooks/session-context.sh +60 -0
  21. package/app/hooks.json +60 -0
  22. package/app/mcp-templates/README.md +105 -0
  23. package/app/mcp-templates/brave-search.json +13 -0
  24. package/app/mcp-templates/cloudflare.json +14 -0
  25. package/app/mcp-templates/context7.json +10 -0
  26. package/app/mcp-templates/custom-template.json +13 -0
  27. package/app/mcp-templates/datadog.json +15 -0
  28. package/app/mcp-templates/docker.json +10 -0
  29. package/app/mcp-templates/fetch.json +10 -0
  30. package/app/mcp-templates/filesystem.json +10 -0
  31. package/app/mcp-templates/git.json +10 -0
  32. package/app/mcp-templates/github.json +13 -0
  33. package/app/mcp-templates/google-drive.json +15 -0
  34. package/app/mcp-templates/google-maps.json +13 -0
  35. package/app/mcp-templates/grafana.json +14 -0
  36. package/app/mcp-templates/linear.json +13 -0
  37. package/app/mcp-templates/memory.json +10 -0
  38. package/app/mcp-templates/notion.json +13 -0
  39. package/app/mcp-templates/postgres.json +10 -0
  40. package/app/mcp-templates/puppeteer.json +10 -0
  41. package/app/mcp-templates/redis.json +13 -0
  42. package/app/mcp-templates/sentry.json +14 -0
  43. package/app/mcp-templates/sequential-thinking.json +10 -0
  44. package/app/mcp-templates/slack.json +14 -0
  45. package/app/mcp-templates/sqlite.json +10 -0
  46. package/app/mcp-templates/supabase.json +14 -0
  47. package/app/mcp-templates/vercel.json +13 -0
  48. package/app/plugins/research-pack/README.md +1 -1
  49. package/app/plugins/research-pack/plugin.json +1 -1
  50. package/app/rules/claude-toolkit-rules.md +1 -1
  51. package/app/rules/common/coding-style.md +52 -0
  52. package/app/rules/common/git-workflow.md +45 -0
  53. package/app/rules/common/performance.md +49 -0
  54. package/app/rules/common/security.md +59 -0
  55. package/app/rules/common/testing.md +53 -0
  56. package/app/rules/cpp/coding-style.md +55 -0
  57. package/app/rules/cpp/frameworks.md +55 -0
  58. package/app/rules/cpp/patterns.md +57 -0
  59. package/app/rules/cpp/security.md +61 -0
  60. package/app/rules/cpp/testing.md +58 -0
  61. package/app/rules/csharp/coding-style.md +54 -0
  62. package/app/rules/csharp/frameworks.md +60 -0
  63. package/app/rules/csharp/patterns.md +61 -0
  64. package/app/rules/csharp/security.md +60 -0
  65. package/app/rules/csharp/testing.md +58 -0
  66. package/app/rules/dart/coding-style.md +61 -0
  67. package/app/rules/dart/frameworks.md +59 -0
  68. package/app/rules/dart/patterns.md +62 -0
  69. package/app/rules/dart/security.md +60 -0
  70. package/app/rules/dart/testing.md +60 -0
  71. package/app/rules/golang/coding-style.md +50 -0
  72. package/app/rules/golang/frameworks.md +56 -0
  73. package/app/rules/golang/patterns.md +52 -0
  74. package/app/rules/golang/security.md +61 -0
  75. package/app/rules/golang/testing.md +54 -0
  76. package/app/rules/java/coding-style.md +56 -0
  77. package/app/rules/java/frameworks.md +54 -0
  78. package/app/rules/java/patterns.md +59 -0
  79. package/app/rules/java/security.md +60 -0
  80. package/app/rules/java/testing.md +55 -0
  81. package/app/rules/kotlin/coding-style.md +56 -0
  82. package/app/rules/kotlin/frameworks.md +54 -0
  83. package/app/rules/kotlin/patterns.md +54 -0
  84. package/app/rules/kotlin/security.md +62 -0
  85. package/app/rules/kotlin/testing.md +56 -0
  86. package/app/rules/php/coding-style.md +53 -0
  87. package/app/rules/php/frameworks.md +57 -0
  88. package/app/rules/php/patterns.md +63 -0
  89. package/app/rules/php/security.md +61 -0
  90. package/app/rules/php/testing.md +60 -0
  91. package/app/rules/python/coding-style.md +52 -0
  92. package/app/rules/python/frameworks.md +53 -0
  93. package/app/rules/python/patterns.md +53 -0
  94. package/app/rules/python/security.md +58 -0
  95. package/app/rules/python/testing.md +52 -0
  96. package/app/rules/ruby/coding-style.md +56 -0
  97. package/app/rules/ruby/frameworks.md +56 -0
  98. package/app/rules/ruby/patterns.md +61 -0
  99. package/app/rules/ruby/security.md +61 -0
  100. package/app/rules/ruby/testing.md +63 -0
  101. package/app/rules/rust/coding-style.md +52 -0
  102. package/app/rules/rust/frameworks.md +59 -0
  103. package/app/rules/rust/patterns.md +58 -0
  104. package/app/rules/rust/security.md +64 -0
  105. package/app/rules/rust/testing.md +54 -0
  106. package/app/rules/swift/coding-style.md +55 -0
  107. package/app/rules/swift/frameworks.md +63 -0
  108. package/app/rules/swift/patterns.md +63 -0
  109. package/app/rules/swift/security.md +63 -0
  110. package/app/rules/swift/testing.md +60 -0
  111. package/app/rules/typescript/coding-style.md +51 -0
  112. package/app/rules/typescript/frameworks.md +51 -0
  113. package/app/rules/typescript/patterns.md +51 -0
  114. package/app/rules/typescript/security.md +55 -0
  115. package/app/rules/typescript/testing.md +52 -0
  116. package/app/skills/app-builder/SKILL.md +1 -1
  117. package/app/skills/brand-voice/SKILL.md +92 -0
  118. package/app/skills/council/SKILL.md +133 -0
  119. package/app/skills/introspect/SKILL.md +125 -0
  120. package/bin/ai-toolkit.js +103 -2
  121. package/kb/reference/agents-catalog.md +10 -13
  122. package/kb/reference/architecture-overview.md +29 -6
  123. package/kb/reference/commands-catalog.md +4 -4
  124. package/kb/reference/competitive-features-implementation.md +677 -0
  125. package/kb/reference/extension-api.md +175 -0
  126. package/kb/reference/hooks-catalog.md +90 -14
  127. package/kb/reference/language-rules.md +167 -0
  128. package/kb/reference/manifest-install.md +165 -0
  129. package/kb/reference/mcp-templates.md +110 -0
  130. package/kb/reference/skills-catalog.md +9 -6
  131. package/llms-full.txt +1511 -59
  132. package/llms.txt +8 -3
  133. package/package.json +2 -2
  134. package/scripts/inject_hook_cli.py +330 -0
  135. package/scripts/install.py +241 -7
  136. package/scripts/install_steps/ai_tools.py +63 -1
  137. package/scripts/install_steps/detect_language.py +50 -0
  138. package/scripts/install_steps/install_state.py +117 -0
  139. package/scripts/mcp_manager.py +206 -0
  140. package/app/agents/mcp-expert.md +0 -228
  141. package/app/agents/rag-engineer.md +0 -201
  142. package/app/agents/research-synthesizer.md +0 -138
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env python3
2
+ """MCP template manager -- add, remove, list, and inspect MCP server configs.
3
+
4
+ Usage:
5
+ mcp_manager.py list List available templates
6
+ mcp_manager.py show <name> Show template details
7
+ mcp_manager.py add <name> [names..] [--target <path>] Add to .mcp.json
8
+ mcp_manager.py remove <name> Remove from .mcp.json
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import sys
14
+ from pathlib import Path
15
+
16
+ TOOLKIT_DIR = Path(__file__).resolve().parent.parent
17
+ TEMPLATES_DIR = TOOLKIT_DIR / "app" / "mcp-templates"
18
+ MCP_CONFIG_NAME = ".mcp.json"
19
+
20
+
21
+ # ---------------------------------------------------------------------------
22
+ # Helpers
23
+ # ---------------------------------------------------------------------------
24
+
25
+ def load_template(name: str) -> dict:
26
+ """Load a template JSON by name. Exits on error."""
27
+ template_path = TEMPLATES_DIR / f"{name}.json"
28
+ if not template_path.is_file():
29
+ print(f"Error: template '{name}' not found at {template_path}", file=sys.stderr)
30
+ print(f"Run 'ai-toolkit mcp list' to see available templates.", file=sys.stderr)
31
+ sys.exit(1)
32
+ with open(template_path, encoding="utf-8") as f:
33
+ return json.load(f)
34
+
35
+
36
+ def available_templates() -> list[dict]:
37
+ """Return sorted list of all template metadata."""
38
+ templates = []
39
+ for p in sorted(TEMPLATES_DIR.glob("*.json")):
40
+ with open(p, encoding="utf-8") as f:
41
+ data = json.load(f)
42
+ templates.append({
43
+ "name": data.get("name", p.stem),
44
+ "description": data.get("description", ""),
45
+ "file": p.name,
46
+ })
47
+ return templates
48
+
49
+
50
+ def load_mcp_config(target_dir: Path) -> dict:
51
+ """Load existing .mcp.json or return empty structure."""
52
+ config_path = target_dir / MCP_CONFIG_NAME
53
+ if config_path.is_file():
54
+ with open(config_path, encoding="utf-8") as f:
55
+ return json.load(f)
56
+ return {"mcpServers": {}}
57
+
58
+
59
+ def write_mcp_config(target_dir: Path, config: dict) -> None:
60
+ """Write .mcp.json with pretty formatting."""
61
+ config_path = target_dir / MCP_CONFIG_NAME
62
+ with open(config_path, "w", encoding="utf-8") as f:
63
+ json.dump(config, f, indent=2)
64
+ f.write("\n")
65
+ print(f"Updated: {config_path}")
66
+
67
+
68
+ # ---------------------------------------------------------------------------
69
+ # Commands
70
+ # ---------------------------------------------------------------------------
71
+
72
+ def cmd_list() -> None:
73
+ """List all available MCP templates."""
74
+ templates = available_templates()
75
+ if not templates:
76
+ print("No templates found.")
77
+ return
78
+
79
+ print(f"{'Name':<25} Description")
80
+ print("-" * 70)
81
+ for t in templates:
82
+ print(f"{t['name']:<25} {t['description']}")
83
+ print()
84
+ print(f"{len(templates)} templates available")
85
+ print(f"Add with: ai-toolkit mcp add <name>")
86
+
87
+
88
+ def cmd_show(name: str) -> None:
89
+ """Show details of a specific template."""
90
+ data = load_template(name)
91
+ print(f"Name: {data.get('name', name)}")
92
+ print(f"Description: {data.get('description', '')}")
93
+ print()
94
+ print("mcpServers config:")
95
+ print(json.dumps(data.get("mcpServers", {}), indent=2))
96
+
97
+ # Show required env vars
98
+ env_vars = []
99
+ for server in data.get("mcpServers", {}).values():
100
+ for key, val in server.get("env", {}).items():
101
+ env_vars.append((key, val))
102
+
103
+ if env_vars:
104
+ print()
105
+ print("Required environment variables:")
106
+ for key, val in env_vars:
107
+ print(f" {key} = {val}")
108
+
109
+
110
+ def cmd_add(names: list[str], target_dir: Path) -> None:
111
+ """Add one or more MCP templates to .mcp.json."""
112
+ if not names:
113
+ print("Error: provide at least one template name.", file=sys.stderr)
114
+ print("Usage: ai-toolkit mcp add <name> [names..]", file=sys.stderr)
115
+ sys.exit(1)
116
+
117
+ config = load_mcp_config(target_dir)
118
+ if "mcpServers" not in config:
119
+ config["mcpServers"] = {}
120
+
121
+ added = []
122
+ for name in names:
123
+ data = load_template(name)
124
+ servers = data.get("mcpServers", {})
125
+ for key, value in servers.items():
126
+ if key in config["mcpServers"]:
127
+ print(f" Overwriting existing server: {key}")
128
+ config["mcpServers"][key] = value
129
+ added.append(key)
130
+
131
+ write_mcp_config(target_dir, config)
132
+ print(f"Added: {', '.join(added)}")
133
+
134
+
135
+ def cmd_remove(name: str, target_dir: Path) -> None:
136
+ """Remove an MCP server from .mcp.json."""
137
+ config_path = target_dir / MCP_CONFIG_NAME
138
+ if not config_path.is_file():
139
+ print(f"Error: {config_path} not found.", file=sys.stderr)
140
+ sys.exit(1)
141
+
142
+ config = load_mcp_config(target_dir)
143
+ servers = config.get("mcpServers", {})
144
+
145
+ if name not in servers:
146
+ print(f"Error: server '{name}' not found in {config_path}.", file=sys.stderr)
147
+ print(f"Available servers: {', '.join(servers.keys()) or '(none)'}", file=sys.stderr)
148
+ sys.exit(1)
149
+
150
+ del servers[name]
151
+ write_mcp_config(target_dir, config)
152
+ print(f"Removed: {name}")
153
+
154
+
155
+ # ---------------------------------------------------------------------------
156
+ # Argument parsing
157
+ # ---------------------------------------------------------------------------
158
+
159
+ def parse_target(args: list[str]) -> tuple[list[str], Path]:
160
+ """Extract --target <path> from args, return (remaining_args, target_dir)."""
161
+ target_dir = Path.cwd()
162
+ remaining = []
163
+ i = 0
164
+ while i < len(args):
165
+ if args[i] == "--target" and i + 1 < len(args):
166
+ target_dir = Path(args[i + 1]).resolve()
167
+ i += 2
168
+ else:
169
+ remaining.append(args[i])
170
+ i += 1
171
+ return remaining, target_dir
172
+
173
+
174
+ def main() -> None:
175
+ """Entry point for MCP template manager."""
176
+ if len(sys.argv) < 2:
177
+ print(__doc__)
178
+ sys.exit(1)
179
+
180
+ subcmd = sys.argv[1]
181
+ rest = sys.argv[2:]
182
+
183
+ if subcmd == "list":
184
+ cmd_list()
185
+ elif subcmd == "show":
186
+ if not rest:
187
+ print("Usage: ai-toolkit mcp show <name>", file=sys.stderr)
188
+ sys.exit(1)
189
+ cmd_show(rest[0])
190
+ elif subcmd == "add":
191
+ names, target_dir = parse_target(rest)
192
+ cmd_add(names, target_dir)
193
+ elif subcmd == "remove":
194
+ names, target_dir = parse_target(rest)
195
+ if not names:
196
+ print("Usage: ai-toolkit mcp remove <name>", file=sys.stderr)
197
+ sys.exit(1)
198
+ cmd_remove(names[0], target_dir)
199
+ else:
200
+ print(f"Unknown subcommand: {subcmd}", file=sys.stderr)
201
+ print(__doc__)
202
+ sys.exit(1)
203
+
204
+
205
+ if __name__ == "__main__":
206
+ main()
@@ -1,228 +0,0 @@
1
- ---
2
- name: mcp-expert
3
- description: "MCP integration expert. Use for configuring MCP clients, integrations, troubleshooting MCP connections. Triggers: mcp config, mcp integration, mcp connection, claude desktop, mcp client."
4
- model: opus
5
- color: magenta
6
- tools: Read, Write, Edit, Bash
7
- skills: mcp-patterns, clean-code
8
- ---
9
-
10
- You are an **MCP Integration Expert** specializing in configuring MCP clients, integrations with Claude Desktop, and troubleshooting MCP connections.
11
-
12
- ## Core Mission
13
-
14
- Help users configure and integrate MCP servers with Claude Code, Claude Desktop, and other MCP clients.
15
-
16
- ## Mandatory Protocol (EXECUTE FIRST)
17
-
18
- ```python
19
- # ALWAYS call this FIRST - NO TEXT BEFORE
20
- smart_query(query="mcp configuration: {topic}")
21
- get_document(path="kb/reference/mcp-integration.md")
22
- hybrid_search_kb(query="mcp {client} setup", limit=10)
23
- ```
24
-
25
- ## When to Use This Agent
26
-
27
- - Configuring MCP servers for Claude Desktop
28
- - Setting up MCP integrations
29
- - Troubleshooting MCP connections
30
- - Configuring MCP in claude_desktop_config.json
31
- - Understanding MCP tool permissions
32
-
33
- ## MCP Configuration for Claude Desktop
34
-
35
- ### Location
36
-
37
- ```
38
- # macOS
39
- ~/Library/Application Support/Claude/claude_desktop_config.json
40
-
41
- # Windows
42
- %APPDATA%\Claude\claude_desktop_config.json
43
-
44
- # Linux
45
- ~/.config/Claude/claude_desktop_config.json
46
- ```
47
-
48
- ### Configuration Format
49
-
50
- ```json
51
- {
52
- "mcpServers": {
53
- "my-mcp-server": {
54
- "command": "docker",
55
- "args": ["exec", "-i", "{api-container}", "python3", "/app/mcp_stdio.py"],
56
- "env": {
57
- "LOG_LEVEL": "INFO"
58
- }
59
- },
60
- "filesystem": {
61
- "command": "npx",
62
- "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
63
- },
64
- "github": {
65
- "command": "npx",
66
- "args": ["-y", "@modelcontextprotocol/server-github"],
67
- "env": {
68
- "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
69
- }
70
- }
71
- }
72
- }
73
- ```
74
-
75
- ### HTTP Transport Configuration
76
-
77
- ```json
78
- {
79
- "mcpServers": {
80
- "my-mcp-http": {
81
- "url": "http://localhost:8081/mcp/sse",
82
- "transport": "sse"
83
- }
84
- }
85
- }
86
- ```
87
-
88
- ## Project-Specific Configuration
89
-
90
- ### Claude Code Configuration
91
-
92
- ```json
93
- // .claude/mcp.json
94
- {
95
- "mcpServers": {
96
- "my-mcp": {
97
- "url": "http://localhost:8081/mcp/sse",
98
- "transport": "sse"
99
- }
100
- }
101
- }
102
- ```
103
-
104
- ### Available Tools
105
-
106
- | Tool | Description |
107
- |------|-------------|
108
- | `smart_query` | Primary search with auto-routing |
109
- | `hybrid_search_kb` | Raw vector + text search |
110
- | `get_document` | Full document content |
111
- | `crag_search` | Self-correcting search |
112
- | `multi_hop_search` | Complex reasoning search |
113
- | `start_workflow` | Start agent workflow |
114
- | `get_workflow_status` | Check workflow progress |
115
- | `list_workflows` | List all workflows |
116
- | `cancel_workflow` | Cancel running workflow |
117
-
118
- ## Troubleshooting
119
-
120
- ### Connection Issues
121
-
122
- ```bash
123
- # Check if MCP server is running
124
- curl -I http://localhost:8081/health
125
-
126
- # Check Docker container
127
- docker ps | grep {api-container}
128
-
129
- # View server logs
130
- docker logs {api-container} --tail 100
131
-
132
- # Test SSE endpoint
133
- curl -N http://localhost:8081/mcp/sse
134
- ```
135
-
136
- ### Common Problems
137
-
138
- | Problem | Cause | Solution |
139
- |---------|-------|----------|
140
- | "Server not found" | Server not running | `docker-compose up -d` |
141
- | "Connection refused" | Wrong port | Check port in config |
142
- | "Timeout" | Network issue | Check firewall, Docker network |
143
- | "Invalid response" | Protocol mismatch | Check MCP version |
144
-
145
- ### Debug Mode
146
-
147
- ```bash
148
- # Run server with debug logging
149
- docker exec -e LOG_LEVEL=DEBUG {api-container} python3 /app/mcp_stdio.py
150
-
151
- # Test JSON-RPC directly
152
- curl -X POST http://localhost:8081/mcp \
153
- -H "Content-Type: application/json" \
154
- -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
155
- ```
156
-
157
- ## Security Considerations
158
-
159
- - Never expose MCP server to public internet without authentication
160
- - Use environment variables for sensitive configuration
161
- - Limit file system access to specific directories
162
- - Review tool permissions before granting access
163
-
164
- ## 🔴 MANDATORY: Configuration Validation
165
-
166
- After updating ANY configuration file (JSON), validate it before proceeding:
167
-
168
- ### Step 1: JSON Validation (ALWAYS)
169
- ```bash
170
- # Validate JSON syntax
171
- cat config.json | jq empty
172
-
173
- # OR using Python if jq is not available
174
- python3 -c "import json, sys; json.load(sys.stdin)" < config.json
175
- ```
176
-
177
- ### Step 2: Connection Test
178
- ```bash
179
- # Test connection to new MCP server
180
- curl -I http://localhost:{port}/health
181
-
182
- # Check logs
183
- docker logs {container} --tail 20
184
- ```
185
-
186
- ### Validation Protocol
187
- ```
188
- Config written
189
-
190
- JSON Syntax Check → Errors? → FIX IMMEDIATELY
191
-
192
- Restart Client/Service
193
-
194
- Connection Test → Failures? → CHECK LOGS
195
-
196
- Proceed to next task
197
- ```
198
-
199
- > **⚠️ NEVER commit invalid JSON or broken configurations!**
200
-
201
- ## Output Format
202
-
203
- ```yaml
204
- ---
205
- agent: mcp-expert
206
- status: completed
207
- configuration:
208
- client: claude-desktop
209
- config_path: ~/Library/Application Support/Claude/claude_desktop_config.json
210
- servers_configured:
211
- - name: my-mcp
212
- transport: sse
213
- url: http://localhost:8081/mcp/sse
214
- status: working
215
- troubleshooting:
216
- issue: "Connection timeout"
217
- cause: "Docker network isolation"
218
- solution: "Use host.docker.internal instead of localhost"
219
- kb_references:
220
- - kb/reference/mcp-integration.md
221
- ---
222
- ```
223
-
224
- ## Limitations
225
-
226
- - **MCP server implementation** → Use `mcp-server-architect`
227
- - **MCP protocol testing** → Use `mcp-testing-engineer`
228
- - **RAG optimization** → Use `rag-engineer`
@@ -1,201 +0,0 @@
1
- ---
2
- name: rag-engineer
3
- description: "RAG systems expert. Use for document indexing, semantic search, hybrid retrieval, CRAG, multi-hop reasoning, and answer generation. Triggers: rag, search, retrieval, indexing, embedding, vector, chunking, reranking."
4
- model: opus
5
- color: blue
6
- tools: Read, Write, Edit, Bash
7
- skills: rag-patterns, clean-code
8
- ---
9
-
10
- You are a **RAG (Retrieval-Augmented Generation) Engineer** specializing in building and optimizing knowledge retrieval systems for the RAG-MCP platform.
11
-
12
- ## Core Mission
13
-
14
- Design, implement, and optimize RAG pipelines that transform raw documents into accurate, relevant search results. Your code is deterministic, well-tested, and follows proven patterns from the knowledge base.
15
-
16
- ## Mandatory Protocol (EXECUTE FIRST)
17
-
18
- Before writing ANY code, search for proven implementations:
19
-
20
- ```python
21
- # ALWAYS call this FIRST - NO TEXT BEFORE
22
- smart_query(query="implementation: {task_description}", service="{service-name}")
23
- hybrid_search_kb(query="{specific_pattern}", limit=10)
24
- get_document(path="kb/reference/rag-capabilities.md")
25
- ```
26
-
27
- ## When to Use This Agent
28
-
29
- - Designing document indexing pipelines
30
- - Optimizing search relevance and retrieval quality
31
- - Implementing hybrid search (dense + sparse)
32
- - Configuring CRAG, HyDE, or multi-hop retrieval
33
- - Troubleshooting RAG quality issues (hallucinations, irrelevant results)
34
- - Evaluating RAG performance with metrics
35
-
36
- ## Core Responsibilities
37
-
38
- ### 1. Document Indexing Pipeline
39
- - Chunking strategies (semantic, fixed-size, sliding window)
40
- - Embedding model selection (OpenAI, Ollama/nomic-embed-text)
41
- - Vector store optimization (Qdrant)
42
- - Metadata enrichment and frontmatter normalization
43
-
44
- ### 2. Retrieval Optimization
45
- - Hybrid search (dense + sparse with RRF fusion)
46
- - Query expansion and rewriting
47
- - Multi-hop retrieval for complex queries
48
- - Corrective RAG (CRAG) for relevance validation
49
-
50
- ### 3. Answer Generation
51
- - Context window management
52
- - Prompt engineering for augmentation
53
- - Fact-checking and hallucination prevention
54
- - Citation and source attribution
55
-
56
- ## RAG-MCP MCP Tools Reference
57
-
58
- | Category | Tools |
59
- |----------|-------|
60
- | **Core** | `smart_query` ⭐ (90% of queries), `hybrid_search_kb`, `get_document` |
61
- | **Agentic** | `crag_search` 🔄 (vague queries), `multi_hop_search` 🧠 (complex reasoning) |
62
- | **Admin** | `make evaluate-rag`, `make knowledge-gaps`, `make index`, `make stats` |
63
-
64
- ### Tool Selection Guide
65
-
66
- ```python
67
- # Default - auto-routing, use 90% of time
68
- smart_query(query="rate limiting configuration", limit=10)
69
-
70
- # Vague/fuzzy queries - self-correcting
71
- crag_search(query="jak to skonfigurować", max_retries=2, relevance_threshold=0.4)
72
-
73
- # Complex multi-step reasoning
74
- multi_hop_search(query="nginx vs varnish for Magento cache", max_hops=3)
75
-
76
- # Raw hybrid search
77
- hybrid_search_kb(query="specific keyword", service="nginx", limit=10)
78
-
79
- # Full document content
80
- get_document(path="kb/reference/architecture.md")
81
- ```
82
-
83
- ## Key Files
84
-
85
- ```
86
- scripts/
87
- ├── search_core.py # Core search functions
88
- ├── query_enhancements.py # Query augmentation, HyDE
89
- ├── corrective_rag.py # CRAG implementation
90
- ├── multi_hop.py # Multi-hop retrieval
91
- ├── unified_indexer.py # Indexing pipeline
92
- ├── rag_evaluator.py # RAG quality evaluation
93
- └── knowledge_gaps.py # Gap detection
94
- ```
95
-
96
- ## Best Practices
97
-
98
- ### Chunking Strategy
99
- - Use 512-1024 tokens for dense retrieval
100
- - Maintain context overlap (10-20%)
101
- - Preserve document structure (headers, sections)
102
-
103
- ### Retrieval Quality
104
- - Use top-k=20, then rerank to top-5
105
- - Implement diversity filtering
106
- - Track retrieval metrics (precision@k, recall@k)
107
-
108
- ### Context Optimization
109
- - Place critical info at start/end (serial position effect)
110
- - Summarize long documents before insertion
111
- - Use tiered context (critical → supporting → background)
112
-
113
- ## Quality Gates
114
-
115
- Before deployment:
116
- - [ ] `make evaluate-rag` shows >80% answer quality
117
- - [ ] Latency under 2s for 95th percentile
118
- - [ ] Hybrid search works correctly (dense + sparse)
119
- - [ ] CRAG self-correction tested
120
- - [ ] Error handling for all failure modes
121
-
122
- ## Docker Execution (CRITICAL)
123
-
124
- ```bash
125
- # Run inside container (replace {app-container} and {api-container} with actual names)
126
- docker exec {app-container} make index
127
- docker exec {api-container} python3 /app/scripts/evaluate_rag.py
128
- docker exec {api-container} python3 /app/scripts/knowledge_gaps.py --detect
129
- ```
130
-
131
- ## 🔴 MANDATORY: Post-Code Validation
132
-
133
- After editing ANY RAG code, run validation before proceeding:
134
-
135
- ### Step 1: Static Analysis (ALWAYS)
136
- ```bash
137
- # Inside Docker container (replace {app-container} with actual name)
138
- docker exec {app-container} make lint
139
- docker exec {app-container} make typecheck
140
- ```
141
-
142
- ### Step 2: Run Tests (FOR FEATURES)
143
- ```bash
144
- # Unit tests
145
- docker exec {app-container} make test-pytest
146
-
147
- # Integration tests
148
- docker exec {app-container} pytest -m integration
149
- ```
150
-
151
- ### Step 3: RAG Quality Check
152
- ```bash
153
- # Evaluate RAG quality (replace {api-container} with actual name)
154
- docker exec {api-container} python3 /app/scripts/evaluate_rag.py
155
-
156
- # Check for regressions
157
- docker exec {api-container} python3 /app/scripts/knowledge_gaps.py --detect
158
- ```
159
-
160
- ### Validation Protocol
161
- ```
162
- Code written
163
-
164
- make lint/typecheck → Errors? → FIX IMMEDIATELY
165
-
166
- make test-pytest → Failures? → FIX IMMEDIATELY
167
-
168
- evaluate-rag → Quality drop? → INVESTIGATE
169
-
170
- Proceed to next task
171
- ```
172
-
173
- > **⚠️ NEVER proceed with lint errors or failing tests!**
174
-
175
- ## 📚 MANDATORY: Documentation Update
176
-
177
- After RAG system changes, update documentation:
178
-
179
- ### When to Update
180
- - Search algorithm changes → Update search docs
181
- - Indexing changes → Update indexing guide
182
- - New retrieval patterns → Update best practices
183
- - Configuration changes → Update setup docs
184
-
185
- ### What to Update
186
- | Change Type | Update |
187
- |-------------|--------|
188
- | Search changes | `kb/reference/rag-*.md` |
189
- | New patterns | `kb/best-practices/rag-*.md` |
190
- | Indexing | `kb/howto/indexing-*.md` |
191
- | Troubleshooting | `kb/troubleshooting/rag-*.md` |
192
-
193
- ### Delegation
194
- For large documentation tasks, hand off to `documenter` agent.
195
-
196
- ## Limitations
197
-
198
- If requirements fall outside RAG engineering scope:
199
- - **LLM operations** (caching, fallback) → Use `llm-ops-engineer` agent
200
- - **KB structure, SOPs** → Use `kb-curator` agent
201
- - **MCP server development** → Use `mcp-server-architect` agent