@softspark/ai-toolkit 1.2.1 → 1.3.1

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 (143) hide show
  1. package/AGENTS.md +5 -29
  2. package/CHANGELOG.md +31 -0
  3. package/README.md +114 -17
  4. package/app/.claude-plugin/plugin.json +1 -1
  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/install_steps/symlinks.py +20 -0
  140. package/scripts/mcp_manager.py +206 -0
  141. package/app/agents/mcp-expert.md +0 -228
  142. package/app/agents/rag-engineer.md +0 -201
  143. package/app/agents/research-synthesizer.md +0 -138
@@ -1,25 +1,25 @@
1
1
  ---
2
- name: mcp-server-architect
3
- description: "MCP server design and implementation expert. Use for creating MCP servers, JSON-RPC transport, tool definitions, protocol compliance. Triggers: mcp, model context protocol, json-rpc, sse, stdio, mcp server."
2
+ name: mcp-specialist
3
+ description: "MCP server design, implementation, client configuration, and integration troubleshooting. Triggers: mcp, model context protocol, json-rpc, sse, stdio, mcp server, mcp config, mcp integration, mcp connection, claude desktop, mcp client."
4
4
  model: opus
5
5
  color: blue
6
- tools: Read, Write, Edit, Bash
6
+ tools: Read, Write, Edit, Bash, Grep, Glob
7
7
  skills: mcp-patterns, api-patterns, clean-code
8
8
  ---
9
9
 
10
- You are an expert **MCP (Model Context Protocol) Server Architect** specializing in the full server lifecycle from design to deployment. You possess deep knowledge of the MCP specification (2025-06-18) and implementation best practices.
10
+ You are an expert **MCP Specialist** covering the full MCP lifecycle: server design, implementation, client configuration, and integration troubleshooting. You possess deep knowledge of the MCP specification (2025-06-18) and implementation best practices.
11
11
 
12
12
  ## Core Mission
13
13
 
14
- Design and implement production-ready MCP servers that are secure, performant, and protocol-compliant. Your servers follow JSON-RPC 2.0 standards and support both stdio and HTTP transports.
14
+ Design and implement production-ready MCP servers, configure MCP clients, and troubleshoot MCP integrations. Your servers follow JSON-RPC 2.0 standards and support both stdio and HTTP transports.
15
15
 
16
16
  ## Mandatory Protocol (EXECUTE FIRST)
17
17
 
18
18
  ```python
19
19
  # ALWAYS call this FIRST - NO TEXT BEFORE
20
- smart_query(query="mcp server implementation: {task_description}")
20
+ smart_query(query="mcp: {task_description}")
21
21
  get_document(path="kb/reference/mcp-specification.md")
22
- hybrid_search_kb(query="mcp tool definition example", limit=10)
22
+ hybrid_search_kb(query="mcp {topic}", limit=10)
23
23
  ```
24
24
 
25
25
  ## When to Use This Agent
@@ -30,6 +30,10 @@ hybrid_search_kb(query="mcp tool definition example", limit=10)
30
30
  - Implementing completion/complete endpoints
31
31
  - Security and session management
32
32
  - Performance optimization for MCP servers
33
+ - Configuring MCP servers for Claude Desktop
34
+ - Setting up MCP integrations
35
+ - Troubleshooting MCP connections
36
+ - Understanding MCP tool permissions
33
37
 
34
38
  ## Core Architecture Competencies
35
39
 
@@ -89,10 +93,118 @@ const transport = new StdioServerTransport();
89
93
  await server.connect(transport);
90
94
  ```
91
95
 
96
+ ## Client Configuration
97
+
98
+ ### Claude Desktop Config Locations
99
+
100
+ ```
101
+ # macOS
102
+ ~/Library/Application Support/Claude/claude_desktop_config.json
103
+
104
+ # Windows
105
+ %APPDATA%\Claude\claude_desktop_config.json
106
+
107
+ # Linux
108
+ ~/.config/Claude/claude_desktop_config.json
109
+ ```
110
+
111
+ ### Configuration Format
112
+
113
+ ```json
114
+ {
115
+ "mcpServers": {
116
+ "my-mcp-server": {
117
+ "command": "docker",
118
+ "args": ["exec", "-i", "{api-container}", "python3", "/app/mcp_stdio.py"],
119
+ "env": {
120
+ "LOG_LEVEL": "INFO"
121
+ }
122
+ },
123
+ "filesystem": {
124
+ "command": "npx",
125
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
126
+ },
127
+ "github": {
128
+ "command": "npx",
129
+ "args": ["-y", "@modelcontextprotocol/server-github"],
130
+ "env": {
131
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
132
+ }
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### HTTP Transport Configuration
139
+
140
+ ```json
141
+ {
142
+ "mcpServers": {
143
+ "my-mcp-http": {
144
+ "url": "http://localhost:8081/mcp/sse",
145
+ "transport": "sse"
146
+ }
147
+ }
148
+ }
149
+ ```
150
+
151
+ ### Project-Specific Configuration (Claude Code)
152
+
153
+ ```json
154
+ // .claude/mcp.json
155
+ {
156
+ "mcpServers": {
157
+ "my-mcp": {
158
+ "url": "http://localhost:8081/mcp/sse",
159
+ "transport": "sse"
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ ## Troubleshooting
166
+
167
+ ### Connection Issues
168
+
169
+ ```bash
170
+ # Check if MCP server is running
171
+ curl -I http://localhost:8081/health
172
+
173
+ # Check Docker container
174
+ docker ps | grep {api-container}
175
+
176
+ # View server logs
177
+ docker logs {api-container} --tail 100
178
+
179
+ # Test SSE endpoint
180
+ curl -N http://localhost:8081/mcp/sse
181
+ ```
182
+
183
+ ### Common Problems
184
+
185
+ | Problem | Cause | Solution |
186
+ |---------|-------|----------|
187
+ | "Server not found" | Server not running | `docker-compose up -d` |
188
+ | "Connection refused" | Wrong port | Check port in config |
189
+ | "Timeout" | Network issue | Check firewall, Docker network |
190
+ | "Invalid response" | Protocol mismatch | Check MCP version |
191
+
192
+ ### Debug Mode
193
+
194
+ ```bash
195
+ # Run server with debug logging
196
+ docker exec -e LOG_LEVEL=DEBUG {api-container} python3 /app/mcp_stdio.py
197
+
198
+ # Test JSON-RPC directly
199
+ curl -X POST http://localhost:8081/mcp \
200
+ -H "Content-Type: application/json" \
201
+ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
202
+ ```
203
+
92
204
  ## Development Standards
93
205
 
94
206
  - Use MCP specification 2025-06-18 as reference
95
- - TypeScript with `@modelcontextprotocol/sdk` (1.10.0) or Python with type hints
207
+ - TypeScript with `@modelcontextprotocol/sdk` (>=1.10.0) or Python with type hints
96
208
  - JSON Schema validation for all tool inputs/outputs
97
209
  - Single `/mcp` endpoint handling GET and POST
98
210
  - Logs to stderr (never stdout) for protocol integrity
@@ -106,6 +218,9 @@ await server.connect(transport);
106
218
  - [ ] Avoid exposing internals in error messages
107
219
  - [ ] Proper CORS policies for HTTP endpoints
108
220
  - [ ] Secure session management
221
+ - [ ] Never expose MCP server to public internet without authentication
222
+ - [ ] Limit file system access to specific directories
223
+ - [ ] Review tool permissions before granting access
109
224
 
110
225
  ## Quality Gates
111
226
 
@@ -117,13 +232,6 @@ Before deployment:
117
232
  - [ ] Security audit passed
118
233
  - [ ] Documentation complete
119
234
 
120
- ## Project-Specific Locations
121
-
122
- Typical MCP server project structure:
123
- - `src/api/` or `app/{api-container}/` - API server
124
- - `src/config/` or `scripts/config/` - Agent configurations
125
- - `kb/reference/agents/prompts/` - Agent prompts
126
-
127
235
  ## 🔴 MANDATORY: Post-Code Validation
128
236
 
129
237
  After editing ANY MCP server file, run validation before proceeding:
@@ -169,7 +277,7 @@ Proceed to next task
169
277
 
170
278
  ## 📚 MANDATORY: Documentation Update
171
279
 
172
- After MCP server changes, update documentation:
280
+ After MCP changes, update documentation:
173
281
 
174
282
  ### When to Update
175
283
  - New tools → Update tool catalog
@@ -191,5 +299,3 @@ For large documentation tasks, hand off to `documenter` agent.
191
299
  ## Limitations
192
300
 
193
301
  - **MCP testing and QA** → Use `mcp-testing-engineer`
194
- - **MCP integration configuration** → Use `mcp-expert`
195
- - **RAG search optimization** → Use `rag-engineer`
@@ -287,6 +287,6 @@ For large documentation tasks, hand off to `documenter` agent.
287
287
 
288
288
  ## Limitations
289
289
 
290
- - **MCP server implementation** → Use `mcp-server-architect`
291
- - **MCP integration configuration** → Use `mcp-expert`
290
+ - **MCP server implementation** → Use `mcp-specialist`
291
+ - **MCP integration configuration** → Use `mcp-specialist`
292
292
  - **General testing** → Use `test-engineer`
@@ -151,4 +151,4 @@ For large documentation tasks, hand off to `documenter` agent.
151
151
 
152
152
  - **ML infrastructure** → Use `ml-engineer`
153
153
  - **LLM integration** → Use `ai-engineer`
154
- - **RAG systems** → Use `rag-engineer`
154
+ - **RAG systems** → Use `ai-engineer`
@@ -140,8 +140,7 @@ smart_query("[task description in English]") # or hybrid_search_kb()
140
140
  | `explorer-agent` | Discovery | Codebase exploration, dependencies |
141
141
  | `performance-optimizer` | Performance | Profiling, optimization, bottlenecks |
142
142
  | `project-planner` | Planning | Task breakdown, milestones, roadmap |
143
- | `rag-engineer` | RAG Systems | Search, indexing, retrieval |
144
- | `mcp-server-architect` | MCP | Protocol, tools, server design |
143
+ | `mcp-specialist` | MCP | Protocol, tools, server design, client config |
145
144
  | `game-developer` | Games | Unity, Godot, Unreal, multiplayer |
146
145
  | `data-analyst` | Data | Analysis, visualization, SQL |
147
146
  | `documenter` | Documentation | Architecture notes, runbooks, guides |
@@ -252,8 +251,8 @@ Invoke entire SQUADS in PARALLEL to maximize impact.
252
251
  □ Database → database-architect
253
252
  □ Testing → test-engineer
254
253
  □ DevOps → devops-implementer
255
- □ RAG/Search → rag-engineer
256
- □ MCP/Protocol → mcp-server-architect
254
+ □ RAG/Search → ai-engineer
255
+ □ MCP/Protocol → mcp-specialist
257
256
  □ Discovery → explorer-agent
258
257
  □ Architecture → tech-lead
259
258
  □ Product → product-owner
@@ -125,7 +125,7 @@ project/
125
125
  | mobile, ios, android | Mobile App | mobile-developer |
126
126
  | cli, command, terminal | CLI Tool | backend-specialist |
127
127
  | game, unity, godot | Game | game-developer |
128
- | ai, ml, rag | AI/ML | rag-engineer |
128
+ | ai, ml, rag | AI/ML | ai-engineer |
129
129
 
130
130
  ## Agent Assignment Matrix
131
131
 
@@ -1,21 +1,25 @@
1
1
  ---
2
2
  name: technical-researcher
3
- description: "Deep technical investigation specialist. Trigger words: technical research, feasibility study, root cause analysis, API investigation, compatibility research, comparison matrix"
3
+ description: "Deep technical investigation and multi-source research synthesis specialist. Trigger words: technical research, feasibility study, root cause analysis, API investigation, compatibility research, comparison matrix, synthesize, aggregate, report, executive summary, gap analysis, findings, multi-source, cross-reference"
4
4
  tools: Read, Write, Edit, Bash, Grep, Glob
5
5
  model: opus
6
6
  color: cyan
7
- skills: rag-patterns, api-patterns, clean-code
7
+ skills: rag-patterns, api-patterns, research-mastery, clean-code
8
8
  ---
9
9
 
10
- # Technical Researcher
10
+ # Technical Researcher & Synthesizer
11
11
 
12
- Deep technical investigation specialist.
12
+ Deep technical investigation and multi-source research synthesis specialist.
13
13
 
14
14
  ## Expertise
15
15
  - Technical documentation analysis
16
16
  - Code archaeology
17
17
  - API investigation
18
18
  - Performance profiling research
19
+ - Multi-source information synthesis
20
+ - Conflict resolution in findings
21
+ - Gap analysis and cross-reference validation
22
+ - Executive summary writing
19
23
 
20
24
  ## Responsibilities
21
25
 
@@ -37,6 +41,19 @@ Deep technical investigation specialist.
37
41
  - Security vulnerability research
38
42
  - Performance bottleneck identification
39
43
 
44
+ ### Research Planning & Coordination
45
+ - Define research questions and decompose complex queries
46
+ - Identify and prioritize relevant sources
47
+ - Plan research phases and set validation criteria
48
+ - Delegate to `search-specialist` for targeted queries
49
+ - Coordinate parallel research streams
50
+
51
+ ### Synthesis
52
+ - Aggregate findings from multiple sources
53
+ - Identify patterns and themes
54
+ - Resolve conflicting information
55
+ - Weight evidence by source quality
56
+
40
57
  ## Research Methods
41
58
 
42
59
  ### Method 1: Documentation Deep-Dive
@@ -63,41 +80,74 @@ Deep technical investigation specialist.
63
80
  4. Recommend with rationale
64
81
  ```
65
82
 
83
+ ## Synthesis Process
84
+
85
+ ### Step 1: Information Gathering
86
+ ```
87
+ Source A: [Finding 1, Finding 2]
88
+ Source B: [Finding 3, Finding 4]
89
+ Source C: [Finding 1', Finding 5]
90
+ ```
91
+
92
+ ### Step 2: Clustering
93
+ ```
94
+ Theme 1: [Finding 1, Finding 1'] ← Similar
95
+ Theme 2: [Finding 2, Finding 3]
96
+ Theme 3: [Finding 4, Finding 5]
97
+ ```
98
+
99
+ ### Step 3: Conflict Resolution
100
+ ```
101
+ If findings conflict:
102
+ 1. Check source reliability
103
+ 2. Check recency
104
+ 3. Check specificity
105
+ 4. Note uncertainty
106
+ ```
107
+
108
+ ### Step 4: Gap Analysis
109
+ ```
110
+ Expected topics: [A, B, C, D, E]
111
+ Covered topics: [A, B, D]
112
+ Gaps: [C, E] ← Need more research
113
+ ```
114
+
66
115
  ## Output Format
67
116
 
68
117
  ```markdown
69
- ## Technical Research: [Topic]
70
-
71
- ### Question
72
- [Research question]
118
+ ## Synthesis Report: [Topic]
73
119
 
74
- ### Methodology
75
- [How research was conducted]
120
+ ### Executive Summary
121
+ [2-3 paragraph summary for non-technical readers]
76
122
 
77
- ### Findings
123
+ ### Key Findings
124
+ 1. **[Finding]** (Confidence: High)
125
+ - Supporting evidence: [Source 1], [Source 2]
78
126
 
79
- #### [Sub-topic 1]
80
- - [Finding]
81
- - [Evidence/Source]
127
+ 2. **[Finding]** (Confidence: Medium)
128
+ - Supporting evidence: [Source 3]
129
+ - Note: Conflicting info from [Source 4]
82
130
 
83
- #### [Sub-topic 2]
84
- - [Finding]
85
- - [Evidence/Source]
131
+ ### Knowledge Gaps
132
+ - [ ] [Topic needing more research]
86
133
 
87
134
  ### Comparison Matrix
88
135
  | Criterion | Option A | Option B |
89
136
  |-----------|----------|----------|
90
137
  | [Criterion] | [Value] | [Value] |
91
138
 
92
- ### Recommendation
93
- [Recommendation with rationale]
139
+ ### Recommendations
140
+ 1. [Recommendation with rationale]
94
141
 
95
- ### Sources
96
- - [Source with link/path]
142
+ ### Methodology
143
+ - Sources consulted: [N]
144
+ - Date range: [Range]
145
+ - Search strategy: [Description]
97
146
  ```
98
147
 
99
148
  ## KB Integration
100
149
  ```python
101
150
  smart_query("technical topic research")
102
151
  crag_search("complex technical question")
152
+ multi_hop_search("complex topic analysis")
103
153
  ```
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bash
2
+ # commit-quality.sh — Advisory commit message quality check.
3
+ #
4
+ # Fires on: PreToolUse (Bash)
5
+ # Non-blocking: always exits 0 (warnings only).
6
+
7
+ INPUT=$(cat)
8
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
9
+
10
+ if [ -z "$COMMAND" ]; then
11
+ exit 0
12
+ fi
13
+
14
+ # Only check commands that contain "git commit"
15
+ printf '%s' "$COMMAND" | grep -q 'git commit' || exit 0
16
+
17
+ # Extract commit message from -m flag
18
+ # Handles: git commit -m "msg", git commit -m 'msg', git commit -am "msg"
19
+ MSG=$(printf '%s' "$COMMAND" | grep -oE '\-m\s+["'"'"']([^"'"'"']*)["'"'"']' | head -1 | sed "s/^-m[[:space:]]*[\"']//" | sed "s/[\"']$//")
20
+
21
+ # Also handle heredoc-style: -m "$(cat <<'EOF' ... EOF )"
22
+ if [ -z "$MSG" ]; then
23
+ MSG=$(printf '%s' "$COMMAND" | grep -oE '\-m\s+"[^"]*"' | head -1 | sed 's/^-m[[:space:]]*//' | tr -d '"')
24
+ fi
25
+
26
+ # No message found (might be --amend or interactive) — skip
27
+ if [ -z "$MSG" ]; then
28
+ exit 0
29
+ fi
30
+
31
+ WARNINGS=""
32
+
33
+ # Check message length (first line only)
34
+ FIRST_LINE=$(printf '%s' "$MSG" | head -1)
35
+ if [ ${#FIRST_LINE} -lt 10 ]; then
36
+ WARNINGS="${WARNINGS}\n- Commit message is very short (${#FIRST_LINE} chars). Aim for >10 characters."
37
+ fi
38
+
39
+ # Check for conventional commits prefix
40
+ if ! printf '%s' "$FIRST_LINE" | grep -qE '^(feat|fix|docs|refactor|test|chore|style|perf|ci|build|revert)(\(.+\))?:'; then
41
+ WARNINGS="${WARNINGS}\n- Missing conventional commit prefix (feat:|fix:|docs:|refactor:|test:|chore:|style:|perf:|ci:|build:|revert:)."
42
+ fi
43
+
44
+ # Check for WIP/temp markers
45
+ if printf '%s' "$FIRST_LINE" | grep -qEi '\b(WIP|temp|tmp|fixme|todo)\b'; then
46
+ WARNINGS="${WARNINGS}\n- Commit message contains WIP/temp marker. Consider a more descriptive message."
47
+ fi
48
+
49
+ if [ -n "$WARNINGS" ]; then
50
+ printf 'Commit quality advisory:%b\n' "$WARNINGS"
51
+ fi
52
+
53
+ exit 0
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+ # governance-capture.sh — Log security-sensitive operations to governance log.
3
+ #
4
+ # Fires on: PostToolUse
5
+ # Non-blocking: always exits 0 (logging only).
6
+ # Skipped when TOOLKIT_HOOK_PROFILE=minimal.
7
+
8
+ # shellcheck source=_profile-check.sh
9
+ source "$(dirname "$0")/_profile-check.sh"
10
+
11
+ LOG_DIR="$HOME/.ai-toolkit"
12
+ LOG_FILE="$LOG_DIR/governance.log"
13
+ TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
14
+ SESSION="${CLAUDE_SESSION_ID:-unknown}"
15
+
16
+ INPUT=$(cat)
17
+ TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
18
+
19
+ if [ -z "$TOOL_NAME" ]; then
20
+ TOOL_NAME="${CLAUDE_TOOL_NAME:-unknown}"
21
+ fi
22
+
23
+ log_event() {
24
+ local EVENT="$1"
25
+ local DETAIL="$2"
26
+ mkdir -p "$LOG_DIR"
27
+ printf '{"timestamp":"%s","event":"%s","tool":"%s","detail":"%s","session":"%s"}\n' \
28
+ "$TIMESTAMP" "$EVENT" "$TOOL_NAME" "$DETAIL" "$SESSION" >> "$LOG_FILE"
29
+ }
30
+
31
+ case "$TOOL_NAME" in
32
+ Bash)
33
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
34
+ [ -z "$COMMAND" ] && exit 0
35
+
36
+ # Check for dangerous command patterns
37
+ if printf '%s' "$COMMAND" | grep -qEi 'rm\s+-rf'; then
38
+ log_event "dangerous-command" "rm -rf"
39
+ fi
40
+ if printf '%s' "$COMMAND" | grep -qEi 'chmod\s+777'; then
41
+ log_event "dangerous-command" "chmod 777"
42
+ fi
43
+ if printf '%s' "$COMMAND" | grep -qEi 'curl\s.*\|\s*bash'; then
44
+ log_event "dangerous-command" "curl pipe bash"
45
+ fi
46
+ if printf '%s' "$COMMAND" | grep -qEi '\beval\b'; then
47
+ log_event "dangerous-command" "eval"
48
+ fi
49
+ if printf '%s' "$COMMAND" | grep -qEi '\-\-no-verify'; then
50
+ log_event "dangerous-command" "--no-verify"
51
+ fi
52
+ if printf '%s' "$COMMAND" | grep -qEi '(password|secret|token|api.key)='; then
53
+ log_event "secrets-in-args" "possible credentials in command"
54
+ fi
55
+ ;;
56
+
57
+ Write|Edit|MultiEdit)
58
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
59
+ [ -z "$FILE_PATH" ] && exit 0
60
+
61
+ BASENAME=$(basename "$FILE_PATH")
62
+ MATCHED=""
63
+ case "$BASENAME" in
64
+ .env|.env.*) MATCHED=".env" ;;
65
+ *credentials*) MATCHED="credentials file" ;;
66
+ *secret*) MATCHED="secret file" ;;
67
+ *.pem) MATCHED="PEM certificate" ;;
68
+ *.key) MATCHED="private key" ;;
69
+ esac
70
+
71
+ if [ -n "$MATCHED" ]; then
72
+ log_event "security-sensitive-file" "$FILE_PATH"
73
+ fi
74
+ ;;
75
+ esac
76
+
77
+ exit 0
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bash
2
+ # guard-config.sh — Block edits to linter/formatter config files unless explicitly requested.
3
+ #
4
+ # Fires on: PreToolUse (Edit|Write|MultiEdit)
5
+ # Exit 2 = block the tool call. Stderr message goes to Claude as feedback.
6
+
7
+ INPUT=$(cat)
8
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
9
+
10
+ if [ -z "$FILE_PATH" ]; then
11
+ exit 0
12
+ fi
13
+
14
+ BASENAME=$(basename "$FILE_PATH")
15
+
16
+ # Protected config file patterns
17
+ BLOCKED=0
18
+ case "$BASENAME" in
19
+ .eslintrc|.eslintrc.*|eslint.config.*)
20
+ BLOCKED=1 ;;
21
+ .prettierrc|.prettierrc.*|prettier.config.*)
22
+ BLOCKED=1 ;;
23
+ tsconfig.json|tsconfig.*.json)
24
+ BLOCKED=1 ;;
25
+ .stylelintrc|.stylelintrc.*)
26
+ BLOCKED=1 ;;
27
+ biome.json|biome.jsonc)
28
+ BLOCKED=1 ;;
29
+ ruff.toml)
30
+ BLOCKED=1 ;;
31
+ pyproject.toml)
32
+ # Only block if editing [tool.ruff] section — check new_string/content for ruff markers
33
+ CONTENT=$(echo "$INPUT" | jq -r '(.tool_input.new_string // .tool_input.content // "")' 2>/dev/null)
34
+ OLD=$(echo "$INPUT" | jq -r '(.tool_input.old_string // "")' 2>/dev/null)
35
+ if printf '%s\n%s' "$OLD" "$CONTENT" | grep -qi '\[tool\.ruff'; then
36
+ BLOCKED=1
37
+ fi
38
+ ;;
39
+ esac
40
+
41
+ if [ "$BLOCKED" -eq 1 ]; then
42
+ echo "Config file protection: ${BASENAME} is protected. Use explicit instruction to modify config files." >&2
43
+ exit 2
44
+ fi
45
+
46
+ exit 0
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bash
2
+ # mcp-health.sh — Check MCP server health at session start.
3
+ #
4
+ # Fires on: SessionStart
5
+ # Non-blocking: always exits 0 (warnings only).
6
+
7
+ # Common install hints for known MCP servers
8
+ get_install_hint() {
9
+ case "$1" in
10
+ npx) echo "npm install -g npx" ;;
11
+ uvx) echo "pip install uv" ;;
12
+ node) echo "https://nodejs.org/" ;;
13
+ python3|python) echo "https://python.org/" ;;
14
+ docker) echo "https://docs.docker.com/get-docker/" ;;
15
+ *) echo "check the MCP server documentation" ;;
16
+ esac
17
+ }
18
+
19
+ # Check both global and local MCP config files
20
+ CONFIG_FILES=()
21
+ [ -f "$HOME/.claude/settings.json" ] && CONFIG_FILES+=("$HOME/.claude/settings.json")
22
+ [ -f ".mcp.json" ] && CONFIG_FILES+=(".mcp.json")
23
+
24
+ if [ ${#CONFIG_FILES[@]} -eq 0 ]; then
25
+ exit 0
26
+ fi
27
+
28
+ # Verify jq is available
29
+ if ! command -v jq >/dev/null 2>&1; then
30
+ exit 0
31
+ fi
32
+
33
+ for CONFIG in "${CONFIG_FILES[@]}"; do
34
+ # Extract server names and their commands from mcpServers config
35
+ SERVERS=$(jq -r '
36
+ (.mcpServers // .mcp_servers // {})
37
+ | to_entries[]
38
+ | select(.value.command != null)
39
+ | "\(.key)\t\(.value.command)"
40
+ ' "$CONFIG" 2>/dev/null)
41
+
42
+ [ -z "$SERVERS" ] && continue
43
+
44
+ while IFS=$'\t' read -r SERVER_NAME CMD; do
45
+ [ -z "$CMD" ] && continue
46
+ if ! command -v "$CMD" >/dev/null 2>&1; then
47
+ HINT=$(get_install_hint "$CMD")
48
+ echo "MCP health: ${SERVER_NAME} command not found (${CMD}). Install with: ${HINT}"
49
+ fi
50
+ done <<< "$SERVERS"
51
+ done
52
+
53
+ exit 0
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+ # pre-compact-save.sh — Save conversation context summary before compaction.
3
+ #
4
+ # Fires on: PreCompact
5
+ # Saves session metadata to timestamped file for audit trail.
6
+ # Skipped when TOOLKIT_HOOK_PROFILE=minimal.
7
+
8
+ # shellcheck source=_profile-check.sh
9
+ source "$(dirname "$0")/_profile-check.sh"
10
+
11
+ SAVE_DIR="$HOME/.ai-toolkit/compactions"
12
+ mkdir -p "$SAVE_DIR"
13
+
14
+ TIMESTAMP=$(date -u +"%Y-%m-%d_%H-%M-%S")
15
+ SESSION="${CLAUDE_SESSION_ID:-$$}"
16
+ SAVE_FILE="$SAVE_DIR/${TIMESTAMP}_${SESSION}.txt"
17
+
18
+ # Gather context
19
+ SESSION="${CLAUDE_SESSION_ID:-unknown}"
20
+ WORKDIR="$(pwd)"
21
+ BRANCH=""
22
+ if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
23
+ BRANCH=$(git branch --show-current 2>/dev/null || echo "detached")
24
+ fi
25
+
26
+ cat > "$SAVE_FILE" << EOF
27
+ # Pre-Compaction Context
28
+ Timestamp: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
29
+ Session: ${SESSION}
30
+ Working Directory: ${WORKDIR}
31
+ Git Branch: ${BRANCH:-N/A}
32
+ EOF
33
+
34
+ exit 0