@softspark/ai-toolkit 4.2.4 → 4.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.
- package/CHANGELOG.md +67 -0
- package/README.md +10 -9
- package/app/.claude-plugin/plugin.json +1 -1
- package/app/hooks/_hook-io.sh +64 -0
- package/app/hooks/_locate-toolkit.sh +39 -0
- package/app/hooks/_search-capability.sh +46 -0
- package/app/hooks/commit-quality.sh +3 -1
- package/app/hooks/config-desync-guard.sh +95 -0
- package/app/hooks/governance-capture.sh +5 -3
- package/app/hooks/guard-config.sh +5 -3
- package/app/hooks/guard-destructive.sh +3 -1
- package/app/hooks/guard-path.sh +8 -1
- package/app/hooks/instructions-audit.sh +43 -0
- package/app/hooks/post-tool-use.sh +20 -8
- package/app/hooks/quality-gate.sh +47 -0
- package/app/hooks/revert-guard.sh +84 -0
- package/app/hooks/search-tracker.sh +18 -0
- package/app/hooks/session-start.sh +14 -2
- package/app/hooks/stop-search-check.sh +37 -0
- package/app/hooks/test-cohesion-map.json +77 -0
- package/app/hooks/test-cohesion.sh +93 -0
- package/app/hooks/track-usage.sh +3 -1
- package/app/hooks/user-prompt-submit.sh +33 -6
- package/app/hooks.json +65 -1
- package/benchmarks/ecosystem-doctor-snapshot.json +8 -8
- package/bin/ai-toolkit.js +43 -0
- package/kb/procedures/release-verification-sop.md +2 -2
- package/kb/reference/architecture-overview.md +1 -1
- package/kb/reference/extension-api.md +77 -11
- package/kb/reference/hooks-catalog.md +149 -24
- package/kb/reference/mcp-templates.md +6 -4
- package/kb/reference/unique-features.md +11 -5
- package/llms-full.txt +163 -32
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/scripts/doctor.py +13 -0
- package/scripts/generate_augment_hooks.py +5 -1
- package/scripts/generate_codex_hooks.py +2 -0
- package/scripts/generate_cursor_hooks.py +6 -0
- package/scripts/generate_gemini_hooks.py +5 -1
- package/scripts/generate_windsurf_hooks.py +6 -0
- package/scripts/inject_mcp_cli.py +514 -0
- package/scripts/install.py +2 -1
- package/scripts/install_steps/hooks.py +5 -0
- package/scripts/install_steps/markers.py +40 -0
- package/scripts/mcp_sources.py +162 -0
- package/scripts/merge-hooks.py +10 -1
- package/scripts/paths.py +2 -0
- package/scripts/plugin_schema.py +4 -0
- package/scripts/session_state.py +150 -0
- package/scripts/test_cohesion.py +133 -0
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
title: "Extension API Reference"
|
|
3
3
|
category: reference
|
|
4
4
|
service: ai-toolkit
|
|
5
|
-
tags: [extension-api, inject-rule, inject-hook, mcp-templates, integration, editors]
|
|
6
|
-
version: "1.
|
|
5
|
+
tags: [extension-api, inject-rule, inject-hook, inject-mcp, mcp-templates, integration, editors]
|
|
6
|
+
version: "1.5.0"
|
|
7
7
|
created: "2026-04-07"
|
|
8
|
-
last_updated: "2026-
|
|
9
|
-
description: "Reference for ai-toolkit's extension API: inject-rule, inject-hook,
|
|
8
|
+
last_updated: "2026-05-12"
|
|
9
|
+
description: "Reference for ai-toolkit's extension API: inject-rule, inject-hook, inject-mcp, remove-* variants, and editor-aware MCP template management."
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
# Extension API Reference
|
|
@@ -25,8 +25,10 @@ This design is intentional: ai-toolkit is a generic toolkit. Consumers (MCP serv
|
|
|
25
25
|
| `remove-rule <name>` | `~/.claude/CLAUDE.md` | Strip markers by block name | Yes |
|
|
26
26
|
| `inject-hook <file.json\|url> [name]` | `~/.claude/settings.json` | JSON `_source` tag per entry, URL cached + registered | Yes |
|
|
27
27
|
| `remove-hook <name>` | `~/.claude/settings.json` | Strip all entries with matching `_source`, unregister URL source | Yes |
|
|
28
|
+
| `inject-mcp <file.json\|url> [name] [--force]` | `~/.mcp.json` + every editor with `global_path` | JSON `_source` tag per server, URL cached + registered, full editor propagation | Yes |
|
|
29
|
+
| `remove-mcp <name>` | `~/.mcp.json` + every editor with `global_path` | Strip all servers with matching `_source`, clean editor configs, unregister URL | Yes |
|
|
28
30
|
| `add-rule <file.md\|url>` | `~/.softspark/ai-toolkit/rules/` | File copy + re-inject all rules on next `update` | Yes |
|
|
29
|
-
| `mcp add <name...>` | `.mcp.json` | Merge `mcpServers` block from template | Yes |
|
|
31
|
+
| `mcp add <name...>` | `.mcp.json` | Merge `mcpServers` block from built-in template | Yes |
|
|
30
32
|
| `mcp install --editor <name...>` | Native editor MCP config | Render canonical template into editor format | Yes |
|
|
31
33
|
|
|
32
34
|
## inject-rule
|
|
@@ -115,6 +117,67 @@ npx @softspark/ai-toolkit remove-hook my-tool-hooks
|
|
|
115
117
|
|
|
116
118
|
The argument is the source name (file stem used during `inject-hook`). If no entries with that source are present, the command exits 0 silently.
|
|
117
119
|
|
|
120
|
+
## inject-mcp
|
|
121
|
+
|
|
122
|
+
Injects an external MCP server template into `~/.mcp.json` (toolkit source-of-truth) and propagates it to every editor that exposes a `global_path` in `EDITOR_SPECS`. Symmetric with `inject-hook` -- accepts both local file paths and HTTPS URLs, with cache + auto-refresh on `ai-toolkit update`.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# From local file
|
|
126
|
+
npx @softspark/ai-toolkit inject-mcp ./rag-mcp-template.json
|
|
127
|
+
|
|
128
|
+
# From URL (cached locally, auto-refreshed on update)
|
|
129
|
+
npx @softspark/ai-toolkit inject-mcp https://example.com/rag-mcp-template.json
|
|
130
|
+
|
|
131
|
+
# With explicit source name (preferred when filename stem is generic)
|
|
132
|
+
npx @softspark/ai-toolkit inject-mcp ./mcp/mcp-template.json --name rag-mcp
|
|
133
|
+
|
|
134
|
+
# With explicit target dir
|
|
135
|
+
npx @softspark/ai-toolkit inject-mcp ./template.json /custom/target --name my-rag
|
|
136
|
+
|
|
137
|
+
# Force overwrite of servers with a different _source (collision resolution)
|
|
138
|
+
npx @softspark/ai-toolkit inject-mcp ./conflict.json --force
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Flags:** `--name <name>` overrides the auto-derived source name (works for both local files and URLs). `--force` overwrites servers tagged with a different `_source`. Positional `template-name` is supported only for URL sources (legacy positional grammar inherited from `inject-hook`); for local files use `--name`.
|
|
142
|
+
|
|
143
|
+
**Implementation:** `scripts/inject_mcp_cli.py`, `scripts/mcp_sources.py`, `scripts/url_fetch.py`.
|
|
144
|
+
|
|
145
|
+
**Input format:** Same as built-in templates in `app/mcp-templates/`:
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"name": "rag-mcp",
|
|
149
|
+
"description": "Multi-tenant RAG over knowledge bases",
|
|
150
|
+
"mcpServers": {
|
|
151
|
+
"rag-mcp": {
|
|
152
|
+
"type": "http",
|
|
153
|
+
"url": "http://localhost:8081/mcp/sse?secret_key=${RAG_MCP_SECRET_KEY}"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Source name derivation:** `rag-mcp-template.json` → `"rag-mcp-template"`. For URLs: `https://example.com/rag-mcp-template.json` → `"rag-mcp-template"`. Every server in the `mcpServers` block is tagged with `"_source": "<source-name>"` inside `~/.mcp.json` only; native editor configs receive the same servers **without** the `_source` field (some clients reject unknown keys).
|
|
160
|
+
|
|
161
|
+
**URL support:** When an HTTPS URL is provided, the JSON is fetched, validated, cached in `~/.softspark/ai-toolkit/mcp-templates/external/<name>.json`, and registered in `sources.json`. On every `ai-toolkit update`, URL-sourced templates are re-fetched and re-injected automatically. If the fetch fails during update, the cached version is used.
|
|
162
|
+
|
|
163
|
+
**Editor propagation:** Every editor with a `global_path` in `EDITOR_SPECS` is updated -- Claude (`~/.claude.json`), Cursor (`~/.cursor/mcp.json`), GitHub Copilot (`~/.copilot/mcp-config.json`), Gemini CLI (`~/.gemini/settings.json`), Windsurf (`~/.codeium/windsurf/mcp_config.json`), Cline (`~/.cline/data/settings/cline_mcp_settings.json`), Augment (`~/.augment/settings.json`), Codex CLI (`~/.codex/config.toml`). Per-editor failures are non-fatal -- the command reports a warning and continues.
|
|
164
|
+
|
|
165
|
+
**Idempotency:** Re-running with the same source overwrites entries for that source cleanly -- no duplicates accumulate.
|
|
166
|
+
|
|
167
|
+
**Collisions:** If a server name in `~/.mcp.json` already exists under a *different* `_source` tag, the command exits with code 3 unless `--force` is passed. Entries tagged `"_source": "ai-toolkit"` are protected even with `--force` -- the built-in template namespace cannot be hijacked.
|
|
168
|
+
|
|
169
|
+
**Safety:** Only HTTPS URLs are accepted. The source name `ai-toolkit` is reserved.
|
|
170
|
+
|
|
171
|
+
## remove-mcp
|
|
172
|
+
|
|
173
|
+
Strips all server entries from `~/.mcp.json` that carry a given `_source` tag, cleans the same server names from every editor `global_path`, and (if URL-sourced) unregisters from `sources.json` and removes the cached file.
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npx @softspark/ai-toolkit remove-mcp rag-mcp-template
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The argument is the source name (file stem used during `inject-mcp`). If no entries with that source are present, the command exits 0 silently. `ai-toolkit` source is reserved and cannot be removed via this command.
|
|
180
|
+
|
|
118
181
|
## mcp add / install
|
|
119
182
|
|
|
120
183
|
Merges one or more MCP server templates from `app/mcp-templates/` into the project's `.mcp.json`.
|
|
@@ -153,6 +216,8 @@ When `install` runs with `--scope project`, ai-toolkit also updates `.mcp.json`
|
|
|
153
216
|
│ remove-rule <name> → CLAUDE.md │
|
|
154
217
|
│ inject-hook <file|url> → settings.json │
|
|
155
218
|
│ remove-hook <name> → settings.json │
|
|
219
|
+
│ inject-mcp <file|url> → .mcp.json + editors │
|
|
220
|
+
│ remove-mcp <name> → .mcp.json + editors │
|
|
156
221
|
│ add-rule <file|url> → rules/ registry │
|
|
157
222
|
│ mcp add <template> → .mcp.json │
|
|
158
223
|
│ mcp install <template> → editor-native MCP │
|
|
@@ -168,7 +233,7 @@ When `install` runs with `--scope project`, ai-toolkit also updates `.mcp.json`
|
|
|
168
233
|
(consumer) (consumer) (consumer)
|
|
169
234
|
```
|
|
170
235
|
|
|
171
|
-
## Example: Registering Rules and
|
|
236
|
+
## Example: Registering Rules, Hooks, and MCP Servers from an External Tool
|
|
172
237
|
|
|
173
238
|
An external tool's install script would call:
|
|
174
239
|
|
|
@@ -176,14 +241,14 @@ An external tool's install script would call:
|
|
|
176
241
|
# Register rules into CLAUDE.md
|
|
177
242
|
npx @softspark/ai-toolkit inject-rule ./rules/my-tool-rules.md
|
|
178
243
|
|
|
179
|
-
# Register hooks into settings.json
|
|
244
|
+
# Register hooks into settings.json (auto-propagates to Codex)
|
|
180
245
|
npx @softspark/ai-toolkit inject-hook ./hooks/my-tool-hooks.json
|
|
181
246
|
|
|
182
|
-
#
|
|
183
|
-
npx @softspark/ai-toolkit mcp
|
|
247
|
+
# Register MCP server template into .mcp.json + all editor MCP configs
|
|
248
|
+
npx @softspark/ai-toolkit inject-mcp ./mcp-template.json
|
|
184
249
|
|
|
185
|
-
#
|
|
186
|
-
npx @softspark/ai-toolkit mcp
|
|
250
|
+
# Alternative: pull MCP template from a URL (auto-refreshed on update)
|
|
251
|
+
npx @softspark/ai-toolkit inject-mcp https://example.com/mcp-template.json
|
|
187
252
|
```
|
|
188
253
|
|
|
189
254
|
To uninstall:
|
|
@@ -191,6 +256,7 @@ To uninstall:
|
|
|
191
256
|
```bash
|
|
192
257
|
npx @softspark/ai-toolkit remove-rule my-tool-rules
|
|
193
258
|
npx @softspark/ai-toolkit remove-hook my-tool-hooks
|
|
259
|
+
npx @softspark/ai-toolkit remove-mcp my-tool
|
|
194
260
|
```
|
|
195
261
|
|
|
196
262
|
All operations are idempotent — safe to run on every install or update.
|
|
@@ -13,7 +13,7 @@ description: "Complete reference of all ai-toolkit hooks: events, scripts, insta
|
|
|
13
13
|
|
|
14
14
|
## Overview
|
|
15
15
|
|
|
16
|
-
ai-toolkit provides
|
|
16
|
+
ai-toolkit provides 28 global hook entries across 14 lifecycle events that enforce quality, safety, and workflow rules across all Claude Code sessions. Hooks are merged into `~/.claude/settings.json` on install, with logic in standalone scripts at `~/.softspark/ai-toolkit/hooks/`.
|
|
17
17
|
|
|
18
18
|
## Supported Surface
|
|
19
19
|
|
|
@@ -327,6 +327,114 @@ Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
|
327
327
|
|
|
328
328
|
**Action:** Captures an environment snapshot to `~/.softspark/ai-toolkit/sessions/current-context.json`. Records working directory, git branch, git status summary, Node.js version, Python version, and timestamp. Used by other hooks and tools to access session metadata without re-running discovery commands. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
329
329
|
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## New Hooks (Constitution Art. VI Enforcement)
|
|
333
|
+
|
|
334
|
+
These six hooks turn Constitution Article VI ("Repair Discipline") from prose into executable enforcement. Each one closes a specific gap that previously relied on agent goodwill.
|
|
335
|
+
|
|
336
|
+
### PreToolUse (revert protection) — `revert-guard.sh`
|
|
337
|
+
|
|
338
|
+
| Field | Value |
|
|
339
|
+
|-------|-------|
|
|
340
|
+
| Event | `PreToolUse` |
|
|
341
|
+
| Matcher | `Bash` |
|
|
342
|
+
| Script | `~/.softspark/ai-toolkit/hooks/revert-guard.sh` |
|
|
343
|
+
| Fires | Before any Bash command |
|
|
344
|
+
|
|
345
|
+
**Action:** Blocks (exit 2) `git checkout/restore -- <file>`, `git reset --hard`, or `git clean -fd` when the affected files were edited in the current session (per `session_state.py` log). Forces the agent to fix root causes instead of reverting work-in-progress (Art. VI.2). Branch switches (`git checkout main`) and reverts on untouched files pass through unchanged.
|
|
346
|
+
|
|
347
|
+
**Override (one-off):** `CLAUDE_REVERT_OK=1`. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
348
|
+
|
|
349
|
+
### PostToolUse (test cohesion) — `test-cohesion.sh`
|
|
350
|
+
|
|
351
|
+
| Field | Value |
|
|
352
|
+
|-------|-------|
|
|
353
|
+
| Event | `PostToolUse` |
|
|
354
|
+
| Matcher | `Edit\|MultiEdit\|Write` |
|
|
355
|
+
| Script | `~/.softspark/ai-toolkit/hooks/test-cohesion.sh` |
|
|
356
|
+
| Fires | After every file edit |
|
|
357
|
+
|
|
358
|
+
**Action:** Runs the test commands mapped to the edited path via `test-cohesion-map.json`. Lookup order: project-local `.claude/test-cohesion-map.json`, then toolkit default `app/hooks/test-cohesion-map.json`. Blocks (exit 2) when the related test command fails. Runs **only** related tests, not the full suite (one of the user-stated requirements).
|
|
359
|
+
|
|
360
|
+
Map schema:
|
|
361
|
+
```json
|
|
362
|
+
[
|
|
363
|
+
{
|
|
364
|
+
"match": "src/auth/*.py",
|
|
365
|
+
"tests": ["tests/test_auth.py"],
|
|
366
|
+
"runner": "pytest",
|
|
367
|
+
"command": null
|
|
368
|
+
}
|
|
369
|
+
]
|
|
370
|
+
```
|
|
371
|
+
First-match-wins per file. Built-in runners: `bats`, `pytest`, `vitest`, `jest`. Use `"command"` for full overrides.
|
|
372
|
+
|
|
373
|
+
**Overrides:** `CLAUDE_SKIP_COHESION=1` (one-off), `CLAUDE_HOOK_BOOTSTRAP=1` (when editing the hook itself). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
374
|
+
|
|
375
|
+
### PostToolUse (search-first tracker) — `search-tracker.sh`
|
|
376
|
+
|
|
377
|
+
| Field | Value |
|
|
378
|
+
|-------|-------|
|
|
379
|
+
| Event | `PostToolUse` |
|
|
380
|
+
| Matcher | `mcp__rag-mcp__smart_query\|mcp__rag-mcp__hybrid_search_kb\|mcp__rag-mcp__crag_search\|mcp__rag-mcp__multi_hop_search\|mcp__rag-mcp__verify_answer\|WebSearch\|WebFetch` |
|
|
381
|
+
| Script | `~/.softspark/ai-toolkit/hooks/search-tracker.sh` |
|
|
382
|
+
| Fires | After any search-style tool call |
|
|
383
|
+
|
|
384
|
+
**Action:** Clears `~/.softspark/ai-toolkit/state/search-required.flag`. Pairs with `user-prompt-submit.sh` (sets flag on long technical prompts only when a search provider is detected or strict mode is enabled) and `stop-search-check.sh` (blocks Stop if flag still set). Together they enforce the global CLAUDE.md GOLDEN RULE without breaking offline/no-RAG installs.
|
|
385
|
+
|
|
386
|
+
Non-blocking (exit 0). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
387
|
+
|
|
388
|
+
### Stop (search-first enforcement) — `stop-search-check.sh`
|
|
389
|
+
|
|
390
|
+
| Field | Value |
|
|
391
|
+
|-------|-------|
|
|
392
|
+
| Event | `Stop` |
|
|
393
|
+
| Matcher | *(all)* |
|
|
394
|
+
| Script | `~/.softspark/ai-toolkit/hooks/stop-search-check.sh` |
|
|
395
|
+
| Fires | When Claude finishes a response |
|
|
396
|
+
|
|
397
|
+
**Action:** If `search-required.flag` is still present (no search tool ran during this turn) and a search provider is still detectable, emits `{"decision":"block","reason":"..."}` to continue the conversation with a search-first reminder. If no RAG/Web provider is detected, it clears the stale flag and exits 0, so offline/no-MCP users are not blocked.
|
|
398
|
+
|
|
399
|
+
**Overrides:** `CLAUDE_SKIP_SEARCH_FIRST=1`, `AI_TOOLKIT_SEARCH_FIRST=off`, or `AI_TOOLKIT_SEARCH_FIRST=strict` to force enforcement. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
400
|
+
|
|
401
|
+
### InstructionsLoaded — `instructions-audit.sh`
|
|
402
|
+
|
|
403
|
+
| Field | Value |
|
|
404
|
+
|-------|-------|
|
|
405
|
+
| Event | `InstructionsLoaded` |
|
|
406
|
+
| Matcher | *(all)* |
|
|
407
|
+
| Script | `~/.softspark/ai-toolkit/hooks/instructions-audit.sh` |
|
|
408
|
+
| Fires | Whenever CLAUDE.md / `.claude/rules/*.md` is loaded into context |
|
|
409
|
+
|
|
410
|
+
**Action:** Appends `<ts>\t<memory_type>\t<load_reason>\t<file_path>` to `~/.softspark/ai-toolkit/state/loaded-instructions.log`. Provides audit visibility: when a rule does NOT enter context (silently dropped, token budget, glob miss), the absence is observable. Auto-rotates at 2000 lines.
|
|
411
|
+
|
|
412
|
+
Non-blocking (exit 0). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
413
|
+
|
|
414
|
+
### ConfigChange — `config-desync-guard.sh`
|
|
415
|
+
|
|
416
|
+
| Field | Value |
|
|
417
|
+
|-------|-------|
|
|
418
|
+
| Event | `ConfigChange` |
|
|
419
|
+
| Matcher | `user_settings` |
|
|
420
|
+
| Script | `~/.softspark/ai-toolkit/hooks/config-desync-guard.sh` |
|
|
421
|
+
| Fires | When `~/.claude/settings.json` changes |
|
|
422
|
+
|
|
423
|
+
**Action:** Compares `_source: ai-toolkit` entries between `~/.claude/settings.json` (installed) and the toolkit source `app/hooks.json`. If they diverge (missing/stale entries), emits an advisory to stderr suggesting `ai-toolkit update` or `ai-toolkit doctor --fix`. Non-blocking by design — user's legitimate settings edits never get rejected.
|
|
424
|
+
|
|
425
|
+
**Override (silence advisory):** `CLAUDE_SKIP_CONFIG_DESYNC=1`. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
426
|
+
|
|
427
|
+
### Supporting Infrastructure
|
|
428
|
+
|
|
429
|
+
| Component | Purpose |
|
|
430
|
+
|-----------|---------|
|
|
431
|
+
| `scripts/session_state.py` | Append-only edit log keyed by session_id. Cleared on SessionStart. Read by revert-guard, test-cohesion, quality-gate. |
|
|
432
|
+
| `scripts/test_cohesion.py` | Resolves changed paths → test commands via cohesion map. First-match-wins. Stdlib-only. |
|
|
433
|
+
| `app/hooks/test-cohesion-map.json` | Toolkit-default path → tests mapping (used when no project map exists). |
|
|
434
|
+
| `app/hooks/_locate-toolkit.sh` | Shared bash helper that exports `$TOOLKIT_DIR` for hooks needing scripts/. |
|
|
435
|
+
| `app/hooks/_hook-io.sh` | Shared bash helper that normalizes hook payloads across Claude, Augment, Gemini, Windsurf, and Cursor-style JSON. |
|
|
436
|
+
| `app/hooks/_search-capability.sh` | Shared bash helper that enables search-first blocking only when RAG/Web is configured or strict mode is requested. |
|
|
437
|
+
|
|
330
438
|
## Runtime Profiles
|
|
331
439
|
|
|
332
440
|
Set in `.claude/settings.local.json`:
|
|
@@ -346,42 +454,59 @@ Set in `.claude/settings.local.json`:
|
|
|
346
454
|
```
|
|
347
455
|
~/.softspark/ai-toolkit/
|
|
348
456
|
├── rules/ # Registered rules (add-rule.sh)
|
|
457
|
+
├── state/ # Per-session runtime state (NEW)
|
|
458
|
+
│ ├── session-edits.json # Append-only edit log per session
|
|
459
|
+
│ ├── search-required.flag # Set by user-prompt-submit, cleared by search-tracker
|
|
460
|
+
│ ├── loaded-instructions.log # Audit trail of which rules entered context
|
|
461
|
+
│ └── test-cohesion-last.log # Last cohesion test command output
|
|
349
462
|
└── hooks/ # Hook scripts (copied on install)
|
|
350
|
-
├── _profile-check.sh
|
|
463
|
+
├── _profile-check.sh # Shared: profile skip logic (sourced by hooks)
|
|
464
|
+
├── _locate-toolkit.sh # NEW: shared $TOOLKIT_DIR locator
|
|
465
|
+
├── _hook-io.sh # NEW: shared multi-editor payload/output adapter
|
|
466
|
+
├── _search-capability.sh # NEW: capability-aware search-first enforcement
|
|
351
467
|
├── session-start.sh
|
|
352
|
-
├── session-context.sh
|
|
468
|
+
├── session-context.sh
|
|
353
469
|
├── guard-destructive.sh
|
|
354
470
|
├── guard-path.sh
|
|
355
|
-
├── guard-config.sh
|
|
356
|
-
├──
|
|
357
|
-
├──
|
|
358
|
-
├──
|
|
359
|
-
├──
|
|
471
|
+
├── guard-config.sh
|
|
472
|
+
├── revert-guard.sh # NEW: block revert on session-edited files (Art. VI.2)
|
|
473
|
+
├── mcp-health.sh
|
|
474
|
+
├── user-prompt-submit.sh # extended: arms search-required flag
|
|
475
|
+
├── post-tool-use.sh # extended: appends edits to session state
|
|
476
|
+
├── governance-capture.sh
|
|
477
|
+
├── test-cohesion.sh # NEW: runs mapped tests after edits (Art. VI.3)
|
|
478
|
+
├── test-cohesion-map.json # NEW: path → tests mapping
|
|
479
|
+
├── search-tracker.sh # NEW: clears search-required flag
|
|
360
480
|
├── quality-check.sh
|
|
361
|
-
├── quality-gate.sh
|
|
481
|
+
├── quality-gate.sh # extended: cohesion-tests session edits
|
|
482
|
+
├── stop-search-check.sh # NEW: enforces search-first on Stop
|
|
362
483
|
├── save-session.sh
|
|
363
484
|
├── subagent-start.sh
|
|
364
485
|
├── subagent-stop.sh
|
|
365
486
|
├── track-usage.sh
|
|
366
487
|
├── pre-compact.sh
|
|
367
|
-
├── pre-compact-save.sh
|
|
368
|
-
├── commit-quality.sh
|
|
488
|
+
├── pre-compact-save.sh
|
|
489
|
+
├── commit-quality.sh
|
|
490
|
+
├── instructions-audit.sh # NEW: logs CLAUDE.md / rules loads
|
|
491
|
+
├── config-desync-guard.sh # NEW: warns on settings ↔ source drift
|
|
369
492
|
└── session-end.sh
|
|
370
493
|
|
|
371
494
|
~/.claude/settings.json
|
|
372
495
|
└── hooks: # Hook definitions referencing ~/.softspark/ai-toolkit/hooks/
|
|
373
|
-
├── SessionStart
|
|
374
|
-
├── Notification
|
|
375
|
-
├── PreToolUse
|
|
376
|
-
├── UserPromptSubmit
|
|
377
|
-
├── PostToolUse
|
|
378
|
-
├── Stop
|
|
379
|
-
├── TaskCompleted
|
|
380
|
-
├── TeammateIdle
|
|
381
|
-
├── SubagentStart
|
|
382
|
-
├── SubagentStop
|
|
383
|
-
├── PreCompact
|
|
384
|
-
|
|
496
|
+
├── SessionStart → session-start.sh, mcp-health.sh, session-context.sh
|
|
497
|
+
├── Notification → notify-waiting.sh
|
|
498
|
+
├── PreToolUse → guard-destructive.sh, guard-path.sh, guard-config.sh, commit-quality.sh, revert-guard.sh
|
|
499
|
+
├── UserPromptSubmit → user-prompt-submit.sh, track-usage.sh
|
|
500
|
+
├── PostToolUse → post-tool-use.sh, governance-capture.sh, test-cohesion.sh, search-tracker.sh
|
|
501
|
+
├── Stop → quality-check.sh, save-session.sh, quality-gate.sh, stop-search-check.sh
|
|
502
|
+
├── TaskCompleted → quality-gate.sh
|
|
503
|
+
├── TeammateIdle → echo (inline)
|
|
504
|
+
├── SubagentStart → subagent-start.sh
|
|
505
|
+
├── SubagentStop → subagent-stop.sh
|
|
506
|
+
├── PreCompact → pre-compact.sh, pre-compact-save.sh
|
|
507
|
+
├── SessionEnd → session-end.sh
|
|
508
|
+
├── InstructionsLoaded → instructions-audit.sh
|
|
509
|
+
└── ConfigChange → config-desync-guard.sh
|
|
385
510
|
```
|
|
386
511
|
|
|
387
512
|
**Key design decisions:**
|
|
@@ -399,7 +524,7 @@ Set in `.claude/settings.local.json`:
|
|
|
399
524
|
|
|
400
525
|
**Hook script not found:**
|
|
401
526
|
```bash
|
|
402
|
-
ls ~/.softspark/ai-toolkit/hooks/ # should list
|
|
527
|
+
ls ~/.softspark/ai-toolkit/hooks/ # should list 27 .sh files (plus _profile-check.sh + _locate-toolkit.sh + _hook-io.sh + _search-capability.sh helpers + test-cohesion-map.json)
|
|
403
528
|
ai-toolkit update # re-copies scripts
|
|
404
529
|
```
|
|
405
530
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
title: "MCP Server Templates"
|
|
3
3
|
category: reference
|
|
4
4
|
service: ai-toolkit
|
|
5
|
-
tags: [mcp, templates, servers, configuration, editors]
|
|
6
|
-
version: "1.
|
|
5
|
+
tags: [mcp, templates, servers, configuration, editors, inject-mcp, external-templates]
|
|
6
|
+
version: "1.2.0"
|
|
7
7
|
created: "2026-04-07"
|
|
8
|
-
last_updated: "2026-
|
|
9
|
-
description: "Reference for 26 MCP server templates
|
|
8
|
+
last_updated: "2026-05-12"
|
|
9
|
+
description: "Reference for 26 built-in MCP server templates, external template injection via inject-mcp, and native editor MCP installation support."
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
# MCP Server Templates
|
|
@@ -15,6 +15,8 @@ description: "Reference for 26 MCP server templates plus native editor MCP insta
|
|
|
15
15
|
|
|
16
16
|
ai-toolkit ships 26 ready-to-use MCP server configuration templates in `app/mcp-templates/`. Each template is a JSON file that defines the canonical `mcpServers` block for a specific service. Templates can be merged into the project's `.mcp.json` and rendered into editor-native MCP config files via the `ai-toolkit mcp` CLI subcommand.
|
|
17
17
|
|
|
18
|
+
**External templates:** Tools outside the toolkit (MCP servers, plugins, custom integrations) can register their own MCP templates via `ai-toolkit inject-mcp <file|url>` -- the toolkit caches the template, tags every server with a `_source` field, and propagates the config to every editor that exposes a `global_path`. URL-sourced templates are auto-refreshed on every `ai-toolkit update`. See [PATH: kb/reference/extension-api.md] for the inject-mcp / remove-mcp reference.
|
|
19
|
+
|
|
18
20
|
## CLI
|
|
19
21
|
|
|
20
22
|
```bash
|
|
@@ -21,11 +21,11 @@ Unlike other toolkits that put safety rules in documentation only, ai-toolkit en
|
|
|
21
21
|
|
|
22
22
|
Hook logic lives in `app/hooks/*.sh` — not inline JSON one-liners. Scripts are copied to `~/.softspark/ai-toolkit/hooks/` on install and referenced from `~/.claude/settings.json`. Easy to read, debug, and extend.
|
|
23
23
|
|
|
24
|
-
**
|
|
24
|
+
**14 lifecycle events / 28 global hook entries:**
|
|
25
25
|
|
|
26
26
|
| Event | Script | Action |
|
|
27
27
|
|-------|--------|--------|
|
|
28
|
-
| SessionStart | `session-start.sh` | MANDATORY rules reminder + session context + instincts |
|
|
28
|
+
| SessionStart | `session-start.sh` | MANDATORY rules reminder + session context + instincts + reset session-edit state |
|
|
29
29
|
| SessionStart | `mcp-health.sh` | Check MCP server command availability (non-blocking warning) |
|
|
30
30
|
| SessionStart | `session-context.sh` | Capture environment snapshot to `~/.softspark/ai-toolkit/sessions/current-context.json` |
|
|
31
31
|
| Notification | `notify-waiting.sh` | Cross-platform desktop notification |
|
|
@@ -33,19 +33,25 @@ Hook logic lives in `app/hooks/*.sh` — not inline JSON one-liners. Scripts are
|
|
|
33
33
|
| PreToolUse | `guard-path.sh` | Block wrong-user path hallucination |
|
|
34
34
|
| PreToolUse | `guard-config.sh` | Block edits to linter/formatter config files unless explicitly requested |
|
|
35
35
|
| PreToolUse | `commit-quality.sh` | Advisory validation of git commit messages |
|
|
36
|
-
|
|
|
36
|
+
| PreToolUse | `revert-guard.sh` | Block `git checkout/restore/reset --hard/clean` on files edited this session (Art. VI.2) |
|
|
37
|
+
| UserPromptSubmit | `user-prompt-submit.sh` | Prompt governance reminder + arm search-first flag only when RAG/Web is available |
|
|
37
38
|
| UserPromptSubmit | `track-usage.sh` | Record skill invocations to local stats |
|
|
38
|
-
| PostToolUse | `post-tool-use.sh` | Lightweight validation reminders
|
|
39
|
+
| PostToolUse | `post-tool-use.sh` | Lightweight validation reminders + append edit to session state |
|
|
39
40
|
| PostToolUse | `governance-capture.sh` | Log security-sensitive operations to JSONL |
|
|
41
|
+
| PostToolUse | `test-cohesion.sh` | Run cohesion-mapped tests after edits; block on failure (Art. VI.3) |
|
|
42
|
+
| PostToolUse | `search-tracker.sh` | Clear search-first flag when smart_query/hybrid_search_kb/Web* runs |
|
|
40
43
|
| Stop | `quality-check.sh` | Multi-language lint (ruff/tsc/phpstan/dart/go) |
|
|
41
44
|
| Stop | `save-session.sh` | Persist session context for cross-session continuity |
|
|
42
|
-
| Stop | `quality-gate.sh` | Block final response on lint/type errors |
|
|
45
|
+
| Stop | `quality-gate.sh` | Block final response on lint/type errors + cohesion tests for session edits |
|
|
46
|
+
| Stop | `stop-search-check.sh` | Continue conversation if search-first rule was skipped and a provider exists; no-op offline |
|
|
43
47
|
| TaskCompleted | `quality-gate.sh` | Block task completion on lint/type errors |
|
|
44
48
|
| SubagentStart | `subagent-start.sh` | Narrow-scope reminder for spawned subagents |
|
|
45
49
|
| SubagentStop | `subagent-stop.sh` | Completion checklist for subagent handoff |
|
|
46
50
|
| PreCompact | `pre-compact.sh` | Smart compaction: prioritized context |
|
|
47
51
|
| PreCompact | `pre-compact-save.sh` | Save timestamped context backup |
|
|
48
52
|
| SessionEnd | `session-end.sh` | Persist a session-end handoff note |
|
|
53
|
+
| InstructionsLoaded | `instructions-audit.sh` | Append every CLAUDE.md / rules load to audit log (which rules actually entered context) |
|
|
54
|
+
| ConfigChange | `config-desync-guard.sh` | Warn when `~/.claude/settings.json` drifts from `app/hooks.json` (advisory) |
|
|
49
55
|
| TeammateIdle | *(inline)* | Completeness reminder |
|
|
50
56
|
|
|
51
57
|
**5 skill-scoped hooks:**
|