@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,677 @@
1
+ ---
2
+ title: "Plan: Competitive Features Implementation — Learning System, Language Rules, Hook Matrix, MCP Templates"
3
+ category: reference
4
+ service: ai-toolkit
5
+ tags:
6
+ - competitive-analysis
7
+ - continuous-learning
8
+ - language-rules
9
+ - hook-matrix
10
+ - mcp-templates
11
+ - install-profiles
12
+ - completed
13
+ doc_type: plan
14
+ status: completed
15
+ created: "2026-04-07"
16
+ last_updated: "2026-04-07"
17
+ completion: "100%"
18
+ description: "Implementation plan for features identified from competitive analysis of everything-claude-code and claude-mem. Focus on learning system, language rules, advanced hooks, MCP templates, and rag-mcp integration. COMPLETED: 8/9 features shipped (1 skipped). See kb/reference/ for permanent documentation."
19
+ ---
20
+
21
+ # Plan: Competitive Features — ai-toolkit
22
+
23
+ **Status:** :yellow_circle: IN PROGRESS
24
+ **Completion:** 100% (9/9 features)
25
+ **Started:** 2026-04-07
26
+ **Estimated Completion:** 2026-06-15
27
+ **Source:** Competitive analysis of `affaan-m/everything-claude-code` (ECC) + `thedotmack/claude-mem`
28
+
29
+ ---
30
+
31
+ ## 1. Objective
32
+
33
+ Strengthen ai-toolkit's competitive position by implementing 10 features from competitive analysis while maintaining our advantages (clean architecture, 9 editors, personas, safety constitution).
34
+
35
+ **Key design principle:** ai-toolkit is a **generic toolkit** — it does NOT know about rag-mcp or any specific consumer. Consumers (like rag-mcp) use ai-toolkit's public API (`inject-rule`, `inject-hook`, `merge-hooks`) to add their own rules and hooks.
36
+
37
+ **State before plan:** 88 skills, 47 agents, 14 hooks, 9 editor integrations
38
+ **State after plan:** 90 skills, 44 agents, 21 hooks, 70 language rules, 25 MCP templates, extension API
39
+
40
+ ---
41
+
42
+ ## 2. Progress Tracking
43
+
44
+ | # | Feature | Priority | Status | Est. Time | Actual | Notes |
45
+ |---|---------|----------|--------|-----------|--------|-------|
46
+ | 1.1 | Language-Specific Rules (13 langs) | P0 | :white_check_mark: | 5-7d | 1d | 70 files (13 langs × 5 + 5 common) |
47
+ | 1.2 | Advanced Hook Matrix | P0 | :white_check_mark: | 5-7d | 1d | 6 new hooks + hooks.json |
48
+ | 1.3 | MCP Server Templates (25) | P0 | :white_check_mark: | 2-3d | 1d | 25 templates + mcp_manager.py + CLI |
49
+ | 2.1 | `inject-hook` CLI command | P1 | :white_check_mark: | 3-5d | 1d | inject_hook_cli.py + 17 tests + CLI |
50
+ | 2.2 | Manifest-Driven Install | P1 | :white_check_mark: | 7-10d | 1d | modules, state tracking, auto-detect |
51
+ | 3.1 | Council Skill | P2 | :white_check_mark: | 3-5d | 1d | /council (4-perspective orchestrator) |
52
+ | 3.2 | Brand Voice Skill | P2 | :white_check_mark: | 2-3d | 1d | knowledge skill + anti-trope list |
53
+ | 3.3 | Agent Introspection Skill | P2 | :white_check_mark: | 3-5d | 1d | /introspect (7 failure patterns) |
54
+ | 4.1 | Documentation Site (Starlight/Astro) | P3 | :no_entry: SKIPPED | — | — | Unnecessary — README/CLAUDE.md sufficient |
55
+
56
+ ---
57
+
58
+ ## 3. Dependency Graph
59
+
60
+ ```
61
+ ALL FEATURES ARE INDEPENDENT — no external dependencies
62
+
63
+ MCP Templates (1.3) ← quick win, start here
64
+ Language Rules (1.1) ← independent
65
+ Hook Matrix (1.2) ← independent
66
+ inject-hook CLI (2.1) ← independent (extends existing inject-rule pattern)
67
+ Manifest Install (2.2) ← independent but complex
68
+ Council Skill (3.1) ← independent
69
+ Brand Voice (3.2) ← independent
70
+ Agent Introspection (3.3) ← independent
71
+ Documentation Site (4.1) ← independent
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 4. Detailed Implementation
77
+
78
+ ### Faza 1: Quick Wins + Foundation (tydzień 1-2)
79
+
80
+ #### 1.1 Language-Specific Rules System
81
+
82
+ **Source:** ECC — 13 language dirs × 5 files each = 65 rule files
83
+ **What we create:** Skill-based language rules that inject into CLAUDE.md via `--local`
84
+
85
+ **Current state:** We have `app/skills/` with some language patterns (typescript-patterns, ruby-patterns, etc.)
86
+ **Gap:** No systematic coding-style + testing + security + hooks + patterns per language
87
+
88
+ **Files to create:**
89
+
90
+ ```
91
+ app/rules/
92
+ ├── common/
93
+ │ ├── coding-style.md # KISS, DRY, YAGNI, immutability
94
+ │ ├── testing.md # Testing standards
95
+ │ ├── git-workflow.md # Commit conventions
96
+ │ ├── performance.md # Performance guidelines
97
+ │ └── security.md # OWASP, input validation
98
+ ├── typescript/
99
+ │ ├── coding-style.md # TS-specific (strict mode, no any, etc.)
100
+ │ ├── testing.md # Jest/Vitest patterns
101
+ │ ├── patterns.md # TS patterns (discriminated unions, etc.)
102
+ │ ├── hooks.md # React hooks, lifecycle
103
+ │ └── security.md # XSS, sanitization
104
+ ├── python/
105
+ │ ├── coding-style.md # PEP 8, type hints, dataclasses
106
+ │ ├── testing.md # pytest, fixtures, parametrize
107
+ │ ├── patterns.md # Python patterns
108
+ │ ├── hooks.md # Django/FastAPI lifecycle
109
+ │ └── security.md # SQL injection, SSTI
110
+ ├── golang/ # Same 5-file structure
111
+ ├── rust/
112
+ ├── java/
113
+ ├── kotlin/
114
+ ├── swift/
115
+ ├── dart/
116
+ ├── csharp/
117
+ ├── php/
118
+ ├── cpp/
119
+ └── ruby/
120
+ ```
121
+
122
+ **Total: 13 languages × 5 files + 5 common = 70 files**
123
+
124
+ **Integration with install:**
125
+ ```bash
126
+ # During ai-toolkit install --local
127
+ # Detect project language from package.json, Cargo.toml, go.mod, etc.
128
+ # Inject relevant language rules into CLAUDE.md
129
+ ```
130
+
131
+ **Files to modify:**
132
+
133
+ | File | Action | Description |
134
+ |------|--------|-------------|
135
+ | `app/rules/` (70 files) | CREATE | Language-specific rules |
136
+ | `scripts/install_steps/detect_language.py` | CREATE | Auto-detect project language |
137
+ | `scripts/install_steps/inject_rules.py` | EDIT | Inject language rules into CLAUDE.md |
138
+ | `scripts/validate.py` | EDIT | Validate rules format |
139
+ | `tests/test_rules.py` | CREATE | Tests |
140
+
141
+ **Success Criteria:**
142
+ - [ ] 13 languages × 5 rule files created
143
+ - [ ] `ai-toolkit install --local` auto-detects language and injects rules
144
+ - [ ] Manual override: `ai-toolkit install --local --lang typescript`
145
+ - [ ] validate.py checks rules format
146
+ - [ ] Tests: >=13 (one per language)
147
+
148
+ ---
149
+
150
+ #### 1.2 Advanced Hook Matrix
151
+
152
+ **Source:** ECC — 11+ specific hooks with PreToolUse/PostToolUse matrix
153
+ **Current state:** 14 hooks in `app/hooks/`
154
+ **Gap:** Missing specific hooks for config protection, MCP health, governance, continuous learning
155
+
156
+ **New hooks to add:**
157
+
158
+ | Hook | Event | Script | Purpose |
159
+ |------|-------|--------|---------|
160
+ | `guard-config.sh` | PreToolUse (Edit/Write) | Bash | Block edits to .eslintrc, .prettierrc, tsconfig unless explicit |
161
+ | `mcp-health.sh` | SessionStart | Bash | Check MCP server health before session |
162
+ | `governance-capture.sh` | PostToolUse | Bash | Log governance events (security, policy) |
163
+ | `observe-session.sh` | PostToolUse | Bash | Send observations to rag-mcp (bridge) |
164
+ | `pre-compact-save.sh` | PreCompact | Bash | Save context state before compaction |
165
+ | `commit-quality.sh` | PreToolUse (Bash) | Bash | Check commit message quality |
166
+
167
+ **Files:**
168
+
169
+ | File | Action | Description |
170
+ |------|--------|-------------|
171
+ | `app/hooks/guard-config.sh` | CREATE | Config file protection |
172
+ | `app/hooks/mcp-health.sh` | CREATE | MCP server health check |
173
+ | `app/hooks/governance-capture.sh` | CREATE | Governance event logging |
174
+ | `app/hooks/observe-session.sh` | CREATE | Send obs to rag-mcp |
175
+ | `app/hooks/pre-compact-save.sh` | CREATE | Context save before compact |
176
+ | `app/hooks/commit-quality.sh` | CREATE | Commit message quality |
177
+ | `scripts/install_steps/install_hooks.py` | EDIT | Register new hooks |
178
+ | `tests/test_hooks.py` | EDIT | Tests for new hooks |
179
+
180
+ **Success Criteria:**
181
+ - [ ] 6 new hooks created and registerable
182
+ - [ ] guard-config blocks config edits unless `--force`
183
+ - [ ] mcp-health pings configured MCP servers on session start
184
+ - [ ] All hooks optional (enable/disable in settings.json)
185
+ - [ ] Tests: >=6 (one per hook)
186
+
187
+ ---
188
+
189
+ #### 1.3 MCP Server Templates
190
+
191
+ **Source:** ECC — 25 preconfigured MCP servers
192
+ **What we create:** Template configs that users can copy
193
+
194
+ **File to create:**
195
+ ```
196
+ app/mcp-templates/
197
+ ├── README.md # How to use templates
198
+ ├── github.json # GitHub MCP server
199
+ ├── jira.json # Jira MCP server
200
+ ├── context7.json # Context7 docs
201
+ ├── filesystem.json # Filesystem MCP server
202
+ ├── sequential-thinking.json # Sequential thinking
203
+ ├── exa-search.json # Exa web search
204
+ ├── supabase.json # Supabase
205
+ ├── postgres.json # PostgreSQL
206
+ ├── redis.json # Redis
207
+ ├── cloudflare.json # Cloudflare
208
+ ├── vercel.json # Vercel
209
+ ├── railway.json # Railway
210
+ ├── docker.json # Docker
211
+ ├── browser-use.json # Browser automation
212
+ ├── fal-ai.json # fal.ai (image/video)
213
+ ├── firecrawl.json # Web scraping
214
+ ├── sentry.json # Sentry error tracking
215
+ ├── linear.json # Linear issue tracker
216
+ ├── slack.json # Slack
217
+ ├── notion.json # Notion
218
+ ├── confluence.json # Confluence
219
+ ├── grafana.json # Grafana
220
+ ├── datadog.json # Datadog
221
+ └── custom-template.json # Template for custom MCP
222
+ ```
223
+
224
+ **CLI command:**
225
+ ```bash
226
+ ai-toolkit mcp add github # Copy github.json to .mcp.json
227
+ ai-toolkit mcp add github jira # Add multiple
228
+ ai-toolkit mcp list # List available templates
229
+ ai-toolkit mcp show github # Show config details
230
+ ```
231
+
232
+ **Files:**
233
+
234
+ | File | Action | Description |
235
+ |------|--------|-------------|
236
+ | `app/mcp-templates/` (25 files) | CREATE | MCP configs |
237
+ | `bin/ai-toolkit` | EDIT | Add `mcp` subcommand |
238
+ | `scripts/mcp_manager.py` | CREATE | MCP template manager |
239
+ | `tests/test_mcp_templates.py` | CREATE | Validate JSON schemas |
240
+
241
+ **Success Criteria:**
242
+ - [ ] 25 MCP template configs created
243
+ - [ ] `ai-toolkit mcp add <name>` merges into .mcp.json
244
+ - [ ] `ai-toolkit mcp list` shows all available
245
+ - [ ] Tests: >=5 (schema validation)
246
+
247
+ ---
248
+
249
+ ### Faza 2: Extension API + Install (tydzień 3-5)
250
+
251
+ #### 2.1 `inject-hook` CLI Command (Generic Hook Injection)
252
+
253
+ **Purpose:** Allow ANY external tool to inject hooks into `~/.claude/settings.json` — the same way `inject-rule` works for `~/.claude/CLAUDE.md`. This is the missing piece that enables consumers (rag-mcp, custom tools, CI systems) to register hooks without knowing ai-toolkit internals.
254
+
255
+ **Current state:**
256
+ - `inject-rule ./my-rules.md` → injects rules into CLAUDE.md between `<!-- TOOLKIT:my-rules START/END -->` markers
257
+ - `merge-hooks.py inject <hooks.json> <settings.json>` → merges hooks but ONLY with `_source: "ai-toolkit"` tag
258
+ - **Gap:** No public CLI for external tools to inject hooks with their OWN `_source` tag
259
+
260
+ **Architecture (parallels inject-rule):**
261
+ ```
262
+ inject-rule ./rag-mcp-rules.md → CLAUDE.md (markers: <!-- TOOLKIT:rag-mcp-rules -->)
263
+ inject-hook ./rag-mcp-hooks.json → settings.json (tag: "_source": "rag-mcp-hooks")
264
+ remove-rule rag-mcp-rules → strips from CLAUDE.md
265
+ remove-hook rag-mcp-hooks → strips from settings.json
266
+ ```
267
+
268
+ **Example: rag-mcp consuming this API:**
269
+ ```bash
270
+ # rag-mcp creates a hooks file:
271
+ cat > /tmp/rag-mcp-hooks.json << 'EOF'
272
+ {
273
+ "hooks": {
274
+ "UserPromptSubmit": [
275
+ {
276
+ "matcher": "",
277
+ "hooks": [{ "type": "command", "command": "echo 'apply KB-first research'" }]
278
+ }
279
+ ],
280
+ "PostToolUse": [
281
+ {
282
+ "matcher": "Edit|Write",
283
+ "hooks": [{ "type": "command", "command": "$HOME/.rag-mcp/hooks/observe-session.sh" }]
284
+ }
285
+ ],
286
+ "SessionStart": [
287
+ {
288
+ "matcher": "",
289
+ "hooks": [{ "type": "command", "command": "$HOME/.rag-mcp/hooks/inject-instincts.sh" }]
290
+ }
291
+ ]
292
+ }
293
+ }
294
+ EOF
295
+
296
+ # rag-mcp calls ai-toolkit to inject:
297
+ npx @softspark/ai-toolkit inject-hook /tmp/rag-mcp-hooks.json
298
+ # → all entries tagged with _source: "rag-mcp-hooks" in settings.json
299
+ # → re-running is idempotent (strips old rag-mcp-hooks entries, appends new)
300
+
301
+ # rag-mcp removes its hooks:
302
+ npx @softspark/ai-toolkit remove-hook rag-mcp-hooks
303
+ ```
304
+
305
+ **Files:**
306
+
307
+ | File | Action | Description |
308
+ |------|--------|-------------|
309
+ | `scripts/inject_hook_cli.py` | CREATE | CLI: inject-hook / remove-hook |
310
+ | `scripts/merge-hooks.py` | EDIT | Support custom `_source` tag (not just "ai-toolkit") |
311
+ | `bin/ai-toolkit.js` | EDIT | Register `inject-hook` + `remove-hook` subcommands |
312
+ | `tests/test_inject_hook.bats` | CREATE | Tests |
313
+ | `kb/howto/inject-hook-api.md` | CREATE | Documentation for consumers |
314
+
315
+ **merge-hooks.py changes:**
316
+ ```python
317
+ # Current: always uses SOURCE_TAG = "ai-toolkit"
318
+ # New: accept --source parameter
319
+ SOURCE_TAG = "ai-toolkit" # default
320
+
321
+ def cmd_inject(toolkit_path: str, target_path: str, source: str = "") -> None:
322
+ source_tag = source or derive_source_from_filename(toolkit_path)
323
+ # ... tag all entries with _source: source_tag
324
+ # ... strip old entries with same source_tag
325
+ # ... append new entries
326
+ ```
327
+
328
+ **inject_hook_cli.py:**
329
+ ```python
330
+ #!/usr/bin/env python3
331
+ """Inject external hooks into ~/.claude/settings.json.
332
+
333
+ Usage:
334
+ inject_hook_cli.py <hooks-file.json> [target-dir]
335
+ inject_hook_cli.py --remove <hook-source-name> [target-dir]
336
+
337
+ The source name is derived from the filename stem (e.g., rag-mcp-hooks.json → "rag-mcp-hooks").
338
+ All entries are tagged with "_source": "<source-name>" for idempotent updates.
339
+ """
340
+ ```
341
+
342
+ **Consistency table — all ai-toolkit extension commands:**
343
+
344
+ | Command | Target File | Mechanism | Idempotent |
345
+ |---------|------------|-----------|------------|
346
+ | `inject-rule <file.md>` | `~/.claude/CLAUDE.md` | HTML markers (`<!-- TOOLKIT:name -->`) | Yes |
347
+ | `remove-rule <name>` | `~/.claude/CLAUDE.md` | Strip markers | Yes |
348
+ | `inject-hook <file.json>` | `~/.claude/settings.json` | JSON `_source` tag | Yes |
349
+ | `remove-hook <name>` | `~/.claude/settings.json` | Strip by `_source` | Yes |
350
+ | `add-rule <file.md>` | `~/.ai-toolkit/rules/` | File copy + re-inject all | Yes |
351
+
352
+ **Success Criteria:**
353
+ - [ ] `inject-hook ./my-hooks.json` merges hooks with auto-derived `_source` tag
354
+ - [ ] `remove-hook my-hooks` strips all entries with that `_source`
355
+ - [ ] Re-running is idempotent (update, not duplicate)
356
+ - [ ] Existing ai-toolkit hooks (`_source: "ai-toolkit"`) are never touched
357
+ - [ ] Tests: >=6 (inject, remove, idempotent, coexistence, malformed input, missing file)
358
+
359
+ ---
360
+
361
+ #### 2.2 Manifest-Driven Install System
362
+
363
+ **Source:** ECC — JSON manifests, state tracking, 5 profiles
364
+ **Current state:** Simple profile-based install (minimal/standard/strict)
365
+ **Gap:** No granular module selection, no state tracking, no incremental updates
366
+
367
+ **Files:**
368
+
369
+ | File | Action | Description |
370
+ |------|--------|-------------|
371
+ | `manifest.json` | EDIT | Full module manifest with dependencies |
372
+ | `scripts/install_steps/install_plan.py` | CREATE | Plan what to install |
373
+ | `scripts/install_steps/install_apply.py` | CREATE | Execute install plan |
374
+ | `scripts/install_steps/install_state.py` | CREATE | Track installed modules |
375
+ | `tests/test_manifest_install.py` | CREATE | Tests |
376
+
377
+ **manifest.json structure:**
378
+ ```json
379
+ {
380
+ "modules": {
381
+ "core": {
382
+ "description": "Core skills and hooks",
383
+ "files": ["app/skills/commit/*", "app/skills/review/*", "app/hooks/*.sh"],
384
+ "required": true
385
+ },
386
+ "agents": {
387
+ "description": "47 specialized agents",
388
+ "files": ["app/agents/*.md"],
389
+ "required": false,
390
+ "default": true
391
+ },
392
+ "rules-common": {
393
+ "description": "Common coding rules",
394
+ "files": ["app/rules/common/*.md"],
395
+ "required": false,
396
+ "default": true
397
+ },
398
+ "rules-typescript": {
399
+ "description": "TypeScript-specific rules",
400
+ "files": ["app/rules/typescript/*.md"],
401
+ "auto_detect": "package.json"
402
+ },
403
+ "rules-python": {
404
+ "description": "Python-specific rules",
405
+ "files": ["app/rules/python/*.md"],
406
+ "auto_detect": "requirements.txt|pyproject.toml|setup.py"
407
+ },
408
+ "mcp-templates": {
409
+ "description": "MCP server templates",
410
+ "files": ["app/mcp-templates/*.json"],
411
+ "required": false
412
+ },
413
+ "rag-mcp-bridge": {
414
+ "description": "rag-mcp integration hooks",
415
+ "files": ["app/hooks/observe-session.sh", "scripts/config/rag-mcp-bridge.yaml"],
416
+ "required": false,
417
+ "requires": ["core"]
418
+ }
419
+ },
420
+ "profiles": {
421
+ "minimal": ["core"],
422
+ "standard": ["core", "agents", "rules-common"],
423
+ "strict": ["core", "agents", "rules-common", "mcp-templates"],
424
+ "full": ["*"]
425
+ }
426
+ }
427
+ ```
428
+
429
+ **State tracking (~/.ai-toolkit/state.json):**
430
+ ```json
431
+ {
432
+ "installed_version": "1.2.1",
433
+ "installed_modules": ["core", "agents", "rules-common", "rules-typescript"],
434
+ "installed_at": "2026-04-07T10:00:00Z",
435
+ "last_updated": "2026-04-07T10:00:00Z",
436
+ "file_hashes": {
437
+ "app/hooks/session-start.sh": "abc123..."
438
+ }
439
+ }
440
+ ```
441
+
442
+ **CLI:**
443
+ ```bash
444
+ ai-toolkit install --profile standard # Profile-based (existing)
445
+ ai-toolkit install --modules core,agents # Module-based (new)
446
+ ai-toolkit install --auto-detect # Detect language, install matching rules
447
+ ai-toolkit update # Incremental update (only changed files)
448
+ ai-toolkit status # Show installed modules
449
+ ```
450
+
451
+ **Success Criteria:**
452
+ - [ ] manifest.json defines all modules with dependencies
453
+ - [ ] install --modules allows granular selection
454
+ - [ ] install --auto-detect detects language from project files
455
+ - [ ] state.json tracks what's installed
456
+ - [ ] update only changes modified files (content hash)
457
+ - [ ] Backward compatible with existing install
458
+ - [ ] Tests: >=10
459
+
460
+ ---
461
+
462
+ ### Faza 3: New Skills (tydzień 6-7)
463
+
464
+ #### 3.1 Council Skill (/council)
465
+
466
+ **Source:** ECC — 4-voice decision workflow
467
+ **Type:** Hybrid skill (user-invocable: true)
468
+
469
+ **File:** `app/skills/council/SKILL.md`
470
+
471
+ **Skill definition:**
472
+ ```yaml
473
+ ---
474
+ name: council
475
+ description: "4-perspective decision evaluation for architecture choices"
476
+ user-invocable: true
477
+ agent: orchestrator
478
+ context: fork
479
+ ---
480
+ ```
481
+
482
+ **Behavior:**
483
+ 1. User invokes `/council "Should we migrate from Redis to Valkey?"`
484
+ 2. Spawn 4 sub-agents in parallel:
485
+ - **Advocate:** Strongest case FOR
486
+ - **Critic:** Strongest case AGAINST (devil's advocate)
487
+ - **Pragmatist:** Trade-offs, costs, timeline, team capacity
488
+ - **User-Proxy:** End-user/customer impact
489
+ 3. Synthesize into structured output:
490
+ - Pros (from Advocate)
491
+ - Cons (from Critic)
492
+ - Trade-offs (from Pragmatist)
493
+ - User Impact (from User-Proxy)
494
+ - **Recommendation** with confidence level
495
+
496
+ **Success Criteria:**
497
+ - [ ] `/council` invocable
498
+ - [ ] 4 perspectives generated
499
+ - [ ] Structured output with recommendation
500
+ - [ ] Tests: >=2
501
+
502
+ ---
503
+
504
+ #### 3.2 Brand Voice Skill (/brand-voice)
505
+
506
+ **Source:** ECC — canonical voice system
507
+ **Type:** Knowledge skill (user-invocable: false, auto-loaded for writing tasks)
508
+
509
+ **File:** `app/skills/brand-voice/SKILL.md`
510
+
511
+ **Content:**
512
+ - Anti-trope list (banned LLM phrases: "dive into", "game-changer", "cutting-edge", etc.)
513
+ - Voice capture template (how to define a project's voice)
514
+ - Consistency checks (before outputting content, verify voice match)
515
+
516
+ **Success Criteria:**
517
+ - [ ] Skill auto-loads when writing docs/content
518
+ - [ ] Anti-trope list prevents generic LLM rhetoric
519
+ - [ ] Tests: >=2
520
+
521
+ ---
522
+
523
+ #### 3.3 Agent Introspection Skill (/introspect)
524
+
525
+ **Source:** ECC — agent-introspection-debugging
526
+ **Type:** Task skill (user-invocable: true)
527
+
528
+ **File:** `app/skills/introspect/SKILL.md`
529
+
530
+ **Behavior:**
531
+ 1. Capture current failure/stuck state
532
+ 2. Classify pattern (loop, wrong approach, missing context, etc.)
533
+ 3. Suggest smallest recovery action
534
+ 4. Emit structured introspection report
535
+ 5. Optionally hand off to verification
536
+
537
+ **Success Criteria:**
538
+ - [ ] `/introspect` invocable when agent is stuck
539
+ - [ ] Classifies failure pattern
540
+ - [ ] Suggests recovery action
541
+ - [ ] Tests: >=2
542
+
543
+ ---
544
+
545
+ ### Faza 4: Documentation & Marketing (tydzień 8)
546
+
547
+ #### 4.1 Documentation Site
548
+
549
+ **Source:** claude-mem (Mintlify, 27 languages)
550
+ **Options:**
551
+ 1. **Starlight (Astro)** — free, static, fast (recommended)
552
+ 2. **Mintlify** — paid, beautiful, hosted
553
+ 3. **Docusaurus** — free, React-based
554
+
555
+ **Structure:**
556
+ ```
557
+ docs/
558
+ ├── astro.config.mjs
559
+ ├── src/content/docs/
560
+ │ ├── getting-started/
561
+ │ │ ├── installation.md
562
+ │ │ ├── quick-start.md
563
+ │ │ └── first-skill.md
564
+ │ ├── skills/
565
+ │ │ ├── tier-1.md
566
+ │ │ ├── tier-2.md
567
+ │ │ └── tier-3.md
568
+ │ ├── agents/
569
+ │ │ └── catalog.md
570
+ │ ├── hooks/
571
+ │ │ └── lifecycle.md
572
+ │ ├── guides/
573
+ │ │ ├── create-skill.md
574
+ │ │ ├── create-agent.md
575
+ │ │ └── rag-mcp-integration.md
576
+ │ └── reference/
577
+ │ ├── cli.md
578
+ │ └── manifest.md
579
+ ```
580
+
581
+ **Success Criteria:**
582
+ - [ ] Documentation site deployed (GitHub Pages or Vercel)
583
+ - [ ] Covers: installation, skills, agents, hooks, CLI reference
584
+ - [ ] Auto-generated from existing CLAUDE.md/README.md content
585
+ - [ ] Tests: Build passes
586
+
587
+ ---
588
+
589
+ ## 5. Extension API Design (Generic — No Consumer Knowledge)
590
+
591
+ ai-toolkit provides a **generic extension API**. It does NOT know about any specific consumer. Consumers use the public CLI to register their rules and hooks.
592
+
593
+ ```
594
+ ┌──────────────────────────────────────────────────────┐
595
+ │ ai-toolkit (generic) │
596
+ │ │
597
+ │ Public Extension API: │
598
+ │ inject-rule <file.md> → CLAUDE.md │
599
+ │ remove-rule <name> → CLAUDE.md │
600
+ │ inject-hook <file.json> → settings.json [NEW] │
601
+ │ remove-hook <name> → settings.json [NEW] │
602
+ │ add-rule <file.md> → rules/ registry │
603
+ │ mcp add <template> → .mcp.json [NEW] │
604
+ │ │
605
+ │ Idempotent: markers (rules) / _source tags (hooks) │
606
+ │ ai-toolkit NEVER calls external services │
607
+ └──────────────────────────────────────────────────────┘
608
+
609
+ │ uses API
610
+ ┌───────────────┼───────────────┐
611
+ │ │ │
612
+ rag-mcp custom-tool ci-system
613
+ (consumer) (consumer) (consumer)
614
+ ```
615
+
616
+ **Example: how rag-mcp would consume (handled in rag-mcp repo, NOT here):**
617
+ ```bash
618
+ # rag-mcp install script calls:
619
+ npx @softspark/ai-toolkit inject-rule ./rag-mcp-rules.md # existing
620
+ npx @softspark/ai-toolkit inject-hook ./rag-mcp-hooks.json # NEW
621
+ # → rag-mcp's hooks + rules are registered, ai-toolkit doesn't care what they do
622
+ ```
623
+
624
+ ---
625
+
626
+ ## 6. Success Criteria (Overall)
627
+
628
+ | Metric | Before | Target |
629
+ |--------|--------|--------|
630
+ | Skills | 88 | ~91 (+3 new skills) |
631
+ | Hooks | 14 | 20 (+6) |
632
+ | Language rules | ~8 (pattern skills) | 70 (13 langs × 5 + 5 common) |
633
+ | MCP templates | 0 | 25 |
634
+ | Install granularity | 3 profiles | 3 profiles + module-level |
635
+ | Extension API | inject-rule only | inject-rule + inject-hook + mcp add |
636
+ | Documentation | README only | Published site |
637
+
638
+ ---
639
+
640
+ ## 7. Risks and Mitigation
641
+
642
+ | Risk | Probability | Impact | Mitigation |
643
+ |------|-------------|--------|------------|
644
+ | 70 rule files = maintenance burden | Medium | Medium | Auto-generate from ECC (port script), validate.py checks |
645
+ | inject-hook misuse by consumers | Low | Medium | Validate JSON schema, reject malformed hooks |
646
+ | Manifest install breaks existing | Low | High | Backward compatible, existing CLI preserved |
647
+ | Documentation site drift | Medium | Medium | Generate from source (CLAUDE.md → site), CI check |
648
+ | Too many hooks slow session start | Low | Medium | Hooks run async, timeout 5s each |
649
+
650
+ ---
651
+
652
+ ## 8. Pre-Mortem
653
+
654
+ 1. **Language rules become stale** — Mitigation: version in frontmatter, validate.py checks freshness
655
+ 2. **inject-hook consumers conflict** — Mitigation: each consumer has unique `_source` tag, never collide
656
+ 3. **Manifest install confuses users** — Mitigation: `--profile` still works, manifest is opt-in power feature
657
+ 4. **Council skill too slow** — Mitigation: parallel sub-agents, timeout 60s per perspective
658
+ 5. **Documentation out of sync** — Mitigation: CI job: generate docs → diff → fail if stale
659
+
660
+ ---
661
+
662
+ ## 9. Next Actions
663
+
664
+ 1. [ ] **Create `app/rules/common/` (5 files)** — Start with common rules
665
+ 2. [ ] **Create `app/mcp-templates/` (25 configs)** — Quick win, high impact
666
+ 3. [ ] **Create 6 new hooks** — Independent, can parallelize
667
+ 4. [ ] Review and approve this plan
668
+
669
+ ---
670
+
671
+ ## 10. Blockers
672
+
673
+ None — all features are independent of external systems.
674
+
675
+ ---
676
+
677
+ **Last Updated:** 2026-04-07