@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.
Files changed (51) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +10 -9
  3. package/app/.claude-plugin/plugin.json +1 -1
  4. package/app/hooks/_hook-io.sh +64 -0
  5. package/app/hooks/_locate-toolkit.sh +39 -0
  6. package/app/hooks/_search-capability.sh +46 -0
  7. package/app/hooks/commit-quality.sh +3 -1
  8. package/app/hooks/config-desync-guard.sh +95 -0
  9. package/app/hooks/governance-capture.sh +5 -3
  10. package/app/hooks/guard-config.sh +5 -3
  11. package/app/hooks/guard-destructive.sh +3 -1
  12. package/app/hooks/guard-path.sh +8 -1
  13. package/app/hooks/instructions-audit.sh +43 -0
  14. package/app/hooks/post-tool-use.sh +20 -8
  15. package/app/hooks/quality-gate.sh +47 -0
  16. package/app/hooks/revert-guard.sh +84 -0
  17. package/app/hooks/search-tracker.sh +18 -0
  18. package/app/hooks/session-start.sh +14 -2
  19. package/app/hooks/stop-search-check.sh +37 -0
  20. package/app/hooks/test-cohesion-map.json +77 -0
  21. package/app/hooks/test-cohesion.sh +93 -0
  22. package/app/hooks/track-usage.sh +3 -1
  23. package/app/hooks/user-prompt-submit.sh +33 -6
  24. package/app/hooks.json +65 -1
  25. package/benchmarks/ecosystem-doctor-snapshot.json +8 -8
  26. package/bin/ai-toolkit.js +43 -0
  27. package/kb/procedures/release-verification-sop.md +2 -2
  28. package/kb/reference/architecture-overview.md +1 -1
  29. package/kb/reference/extension-api.md +77 -11
  30. package/kb/reference/hooks-catalog.md +149 -24
  31. package/kb/reference/mcp-templates.md +6 -4
  32. package/kb/reference/unique-features.md +11 -5
  33. package/llms-full.txt +163 -32
  34. package/manifest.json +1 -1
  35. package/package.json +1 -1
  36. package/scripts/doctor.py +13 -0
  37. package/scripts/generate_augment_hooks.py +5 -1
  38. package/scripts/generate_codex_hooks.py +2 -0
  39. package/scripts/generate_cursor_hooks.py +6 -0
  40. package/scripts/generate_gemini_hooks.py +5 -1
  41. package/scripts/generate_windsurf_hooks.py +6 -0
  42. package/scripts/inject_mcp_cli.py +514 -0
  43. package/scripts/install.py +2 -1
  44. package/scripts/install_steps/hooks.py +5 -0
  45. package/scripts/install_steps/markers.py +40 -0
  46. package/scripts/mcp_sources.py +162 -0
  47. package/scripts/merge-hooks.py +10 -1
  48. package/scripts/paths.py +2 -0
  49. package/scripts/plugin_schema.py +4 -0
  50. package/scripts/session_state.py +150 -0
  51. package/scripts/test_cohesion.py +133 -0
package/llms-full.txt CHANGED
@@ -5391,7 +5391,7 @@ ai-toolkit doctor
5391
5391
  - Environment: node, bash, python3, bats
5392
5392
  - Global Install: .claude exists, agents/skills symlinks (0 broken), settings.json hooks
5393
5393
  - Hook Scripts: all present and executable
5394
- - Hook Configuration: 12 events registered
5394
+ - Hook Configuration: 14 events registered
5395
5395
  - Generated Artifacts: AGENTS.md, llms.txt, llms-full.txt
5396
5396
  - Planned Assets: plugin.json, benchmarks, plugin packs
5397
5397
  - Benchmark Freshness: < 30 days
@@ -5441,7 +5441,7 @@ python3 scripts/audit_skills.py --ci
5441
5441
 
5442
5442
  **Verify validate.py:**
5443
5443
  - [ ] Agents >= 44, Skills >= 99, Tests >= 900
5444
- - [ ] Hook events: 12, Hook scripts: >= 20
5444
+ - [ ] Hook events: 14, Hook scripts: >= 30
5445
5445
  - [ ] Plugin packs >= 10, KB documents >= 20
5446
5446
  - [ ] `Errors: 0 | Warnings: 0` → `VALIDATION PASSED`
5447
5447
 
@@ -6352,7 +6352,7 @@ Agents (code-reviewer, debugger, devops-implementer, ...)
6352
6352
 
6353
6353
  ## Quality Hooks
6354
6354
 
6355
- 22 entries across 12 lifecycle events. See [hooks-catalog.md](hooks-catalog.md) for full details.
6355
+ 28 entries across 14 lifecycle events. See [hooks-catalog.md](hooks-catalog.md) for full details.
6356
6356
 
6357
6357
  | Hook | Trigger | Script | Action |
6358
6358
  |------|---------|--------|--------|
@@ -8768,7 +8768,7 @@ description: "Complete reference of all ai-toolkit hooks: events, scripts, insta
8768
8768
 
8769
8769
  ## Overview
8770
8770
 
8771
- ai-toolkit provides 22 global hook entries across 12 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/`.
8771
+ 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/`.
8772
8772
 
8773
8773
  ## Supported Surface
8774
8774
 
@@ -9082,6 +9082,114 @@ Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
9082
9082
 
9083
9083
  **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`.
9084
9084
 
9085
+ ---
9086
+
9087
+ ## New Hooks (Constitution Art. VI Enforcement)
9088
+
9089
+ 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.
9090
+
9091
+ ### PreToolUse (revert protection) — `revert-guard.sh`
9092
+
9093
+ | Field | Value |
9094
+ |-------|-------|
9095
+ | Event | `PreToolUse` |
9096
+ | Matcher | `Bash` |
9097
+ | Script | `~/.softspark/ai-toolkit/hooks/revert-guard.sh` |
9098
+ | Fires | Before any Bash command |
9099
+
9100
+ **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.
9101
+
9102
+ **Override (one-off):** `CLAUDE_REVERT_OK=1`. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
9103
+
9104
+ ### PostToolUse (test cohesion) — `test-cohesion.sh`
9105
+
9106
+ | Field | Value |
9107
+ |-------|-------|
9108
+ | Event | `PostToolUse` |
9109
+ | Matcher | `Edit\|MultiEdit\|Write` |
9110
+ | Script | `~/.softspark/ai-toolkit/hooks/test-cohesion.sh` |
9111
+ | Fires | After every file edit |
9112
+
9113
+ **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).
9114
+
9115
+ Map schema:
9116
+ ```json
9117
+ [
9118
+ {
9119
+ "match": "src/auth/*.py",
9120
+ "tests": ["tests/test_auth.py"],
9121
+ "runner": "pytest",
9122
+ "command": null
9123
+ }
9124
+ ]
9125
+ ```
9126
+ First-match-wins per file. Built-in runners: `bats`, `pytest`, `vitest`, `jest`. Use `"command"` for full overrides.
9127
+
9128
+ **Overrides:** `CLAUDE_SKIP_COHESION=1` (one-off), `CLAUDE_HOOK_BOOTSTRAP=1` (when editing the hook itself). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
9129
+
9130
+ ### PostToolUse (search-first tracker) — `search-tracker.sh`
9131
+
9132
+ | Field | Value |
9133
+ |-------|-------|
9134
+ | Event | `PostToolUse` |
9135
+ | 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` |
9136
+ | Script | `~/.softspark/ai-toolkit/hooks/search-tracker.sh` |
9137
+ | Fires | After any search-style tool call |
9138
+
9139
+ **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.
9140
+
9141
+ Non-blocking (exit 0). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
9142
+
9143
+ ### Stop (search-first enforcement) — `stop-search-check.sh`
9144
+
9145
+ | Field | Value |
9146
+ |-------|-------|
9147
+ | Event | `Stop` |
9148
+ | Matcher | *(all)* |
9149
+ | Script | `~/.softspark/ai-toolkit/hooks/stop-search-check.sh` |
9150
+ | Fires | When Claude finishes a response |
9151
+
9152
+ **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.
9153
+
9154
+ **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`.
9155
+
9156
+ ### InstructionsLoaded — `instructions-audit.sh`
9157
+
9158
+ | Field | Value |
9159
+ |-------|-------|
9160
+ | Event | `InstructionsLoaded` |
9161
+ | Matcher | *(all)* |
9162
+ | Script | `~/.softspark/ai-toolkit/hooks/instructions-audit.sh` |
9163
+ | Fires | Whenever CLAUDE.md / `.claude/rules/*.md` is loaded into context |
9164
+
9165
+ **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.
9166
+
9167
+ Non-blocking (exit 0). Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
9168
+
9169
+ ### ConfigChange — `config-desync-guard.sh`
9170
+
9171
+ | Field | Value |
9172
+ |-------|-------|
9173
+ | Event | `ConfigChange` |
9174
+ | Matcher | `user_settings` |
9175
+ | Script | `~/.softspark/ai-toolkit/hooks/config-desync-guard.sh` |
9176
+ | Fires | When `~/.claude/settings.json` changes |
9177
+
9178
+ **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.
9179
+
9180
+ **Override (silence advisory):** `CLAUDE_SKIP_CONFIG_DESYNC=1`. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
9181
+
9182
+ ### Supporting Infrastructure
9183
+
9184
+ | Component | Purpose |
9185
+ |-----------|---------|
9186
+ | `scripts/session_state.py` | Append-only edit log keyed by session_id. Cleared on SessionStart. Read by revert-guard, test-cohesion, quality-gate. |
9187
+ | `scripts/test_cohesion.py` | Resolves changed paths → test commands via cohesion map. First-match-wins. Stdlib-only. |
9188
+ | `app/hooks/test-cohesion-map.json` | Toolkit-default path → tests mapping (used when no project map exists). |
9189
+ | `app/hooks/_locate-toolkit.sh` | Shared bash helper that exports `$TOOLKIT_DIR` for hooks needing scripts/. |
9190
+ | `app/hooks/_hook-io.sh` | Shared bash helper that normalizes hook payloads across Claude, Augment, Gemini, Windsurf, and Cursor-style JSON. |
9191
+ | `app/hooks/_search-capability.sh` | Shared bash helper that enables search-first blocking only when RAG/Web is configured or strict mode is requested. |
9192
+
9085
9193
  ## Runtime Profiles
9086
9194
 
9087
9195
  Set in `.claude/settings.local.json`:
@@ -9101,42 +9209,59 @@ Set in `.claude/settings.local.json`:
9101
9209
  ```
9102
9210
  ~/.softspark/ai-toolkit/
9103
9211
  ├── rules/ # Registered rules (add-rule.sh)
9212
+ ├── state/ # Per-session runtime state (NEW)
9213
+ │ ├── session-edits.json # Append-only edit log per session
9214
+ │ ├── search-required.flag # Set by user-prompt-submit, cleared by search-tracker
9215
+ │ ├── loaded-instructions.log # Audit trail of which rules entered context
9216
+ │ └── test-cohesion-last.log # Last cohesion test command output
9104
9217
  └── hooks/ # Hook scripts (copied on install)
9105
- ├── _profile-check.sh # Shared: profile skip logic (sourced by hooks)
9218
+ ├── _profile-check.sh # Shared: profile skip logic (sourced by hooks)
9219
+ ├── _locate-toolkit.sh # NEW: shared $TOOLKIT_DIR locator
9220
+ ├── _hook-io.sh # NEW: shared multi-editor payload/output adapter
9221
+ ├── _search-capability.sh # NEW: capability-aware search-first enforcement
9106
9222
  ├── session-start.sh
9107
- ├── session-context.sh # NEW: capture session env snapshot
9223
+ ├── session-context.sh
9108
9224
  ├── guard-destructive.sh
9109
9225
  ├── guard-path.sh
9110
- ├── guard-config.sh # NEW: block config file edits
9111
- ├── mcp-health.sh # NEW: check MCP runtime availability
9112
- ├── user-prompt-submit.sh
9113
- ├── post-tool-use.sh
9114
- ├── governance-capture.sh # NEW: log security-sensitive operations
9226
+ ├── guard-config.sh
9227
+ ├── revert-guard.sh # NEW: block revert on session-edited files (Art. VI.2)
9228
+ ├── mcp-health.sh
9229
+ ├── user-prompt-submit.sh # extended: arms search-required flag
9230
+ ├── post-tool-use.sh # extended: appends edits to session state
9231
+ ├── governance-capture.sh
9232
+ ├── test-cohesion.sh # NEW: runs mapped tests after edits (Art. VI.3)
9233
+ ├── test-cohesion-map.json # NEW: path → tests mapping
9234
+ ├── search-tracker.sh # NEW: clears search-required flag
9115
9235
  ├── quality-check.sh
9116
- ├── quality-gate.sh
9236
+ ├── quality-gate.sh # extended: cohesion-tests session edits
9237
+ ├── stop-search-check.sh # NEW: enforces search-first on Stop
9117
9238
  ├── save-session.sh
9118
9239
  ├── subagent-start.sh
9119
9240
  ├── subagent-stop.sh
9120
9241
  ├── track-usage.sh
9121
9242
  ├── pre-compact.sh
9122
- ├── pre-compact-save.sh # NEW: timestamped context snapshot
9123
- ├── commit-quality.sh # NEW: advisory commit message check
9243
+ ├── pre-compact-save.sh
9244
+ ├── commit-quality.sh
9245
+ ├── instructions-audit.sh # NEW: logs CLAUDE.md / rules loads
9246
+ ├── config-desync-guard.sh # NEW: warns on settings ↔ source drift
9124
9247
  └── session-end.sh
9125
9248
 
9126
9249
  ~/.claude/settings.json
9127
9250
  └── hooks: # Hook definitions referencing ~/.softspark/ai-toolkit/hooks/
9128
- ├── SessionStart → session-start.sh, mcp-health.sh, session-context.sh
9129
- ├── Notification osascript (inline)
9130
- ├── PreToolUse → guard-destructive.sh, guard-path.sh, guard-config.sh, commit-quality.sh
9131
- ├── UserPromptSubmit → user-prompt-submit.sh, track-usage.sh
9132
- ├── PostToolUse → post-tool-use.sh, governance-capture.sh
9133
- ├── Stop → quality-check.sh, save-session.sh, quality-gate.sh
9134
- ├── TaskCompleted → quality-gate.sh
9135
- ├── TeammateIdle → echo (inline)
9136
- ├── SubagentStart → subagent-start.sh
9137
- ├── SubagentStop → subagent-stop.sh
9138
- ├── PreCompact → pre-compact.sh, pre-compact-save.sh
9139
- └── SessionEnd → session-end.sh
9251
+ ├── SessionStart → session-start.sh, mcp-health.sh, session-context.sh
9252
+ ├── Notification notify-waiting.sh
9253
+ ├── PreToolUse → guard-destructive.sh, guard-path.sh, guard-config.sh, commit-quality.sh, revert-guard.sh
9254
+ ├── UserPromptSubmit → user-prompt-submit.sh, track-usage.sh
9255
+ ├── PostToolUse → post-tool-use.sh, governance-capture.sh, test-cohesion.sh, search-tracker.sh
9256
+ ├── Stop → quality-check.sh, save-session.sh, quality-gate.sh, stop-search-check.sh
9257
+ ├── TaskCompleted → quality-gate.sh
9258
+ ├── TeammateIdle → echo (inline)
9259
+ ├── SubagentStart → subagent-start.sh
9260
+ ├── SubagentStop → subagent-stop.sh
9261
+ ├── PreCompact → pre-compact.sh, pre-compact-save.sh
9262
+ ├── SessionEnd → session-end.sh
9263
+ ├── InstructionsLoaded → instructions-audit.sh
9264
+ └── ConfigChange → config-desync-guard.sh
9140
9265
  ```
9141
9266
 
9142
9267
  **Key design decisions:**
@@ -9154,7 +9279,7 @@ Set in `.claude/settings.local.json`:
9154
9279
 
9155
9280
  **Hook script not found:**
9156
9281
  ```bash
9157
- ls ~/.softspark/ai-toolkit/hooks/ # should list 21 .sh files (plus _profile-check.sh helper)
9282
+ 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)
9158
9283
  ai-toolkit update # re-copies scripts
9159
9284
  ```
9160
9285
 
@@ -11780,11 +11905,11 @@ Unlike other toolkits that put safety rules in documentation only, ai-toolkit en
11780
11905
 
11781
11906
  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.
11782
11907
 
11783
- **12 lifecycle events / 22 global hook entries:**
11908
+ **14 lifecycle events / 28 global hook entries:**
11784
11909
 
11785
11910
  | Event | Script | Action |
11786
11911
  |-------|--------|--------|
11787
- | SessionStart | `session-start.sh` | MANDATORY rules reminder + session context + instincts |
11912
+ | SessionStart | `session-start.sh` | MANDATORY rules reminder + session context + instincts + reset session-edit state |
11788
11913
  | SessionStart | `mcp-health.sh` | Check MCP server command availability (non-blocking warning) |
11789
11914
  | SessionStart | `session-context.sh` | Capture environment snapshot to `~/.softspark/ai-toolkit/sessions/current-context.json` |
11790
11915
  | Notification | `notify-waiting.sh` | Cross-platform desktop notification |
@@ -11792,19 +11917,25 @@ Hook logic lives in `app/hooks/*.sh` — not inline JSON one-liners. Scripts are
11792
11917
  | PreToolUse | `guard-path.sh` | Block wrong-user path hallucination |
11793
11918
  | PreToolUse | `guard-config.sh` | Block edits to linter/formatter config files unless explicitly requested |
11794
11919
  | PreToolUse | `commit-quality.sh` | Advisory validation of git commit messages |
11795
- | UserPromptSubmit | `user-prompt-submit.sh` | Prompt governance reminder |
11920
+ | PreToolUse | `revert-guard.sh` | Block `git checkout/restore/reset --hard/clean` on files edited this session (Art. VI.2) |
11921
+ | UserPromptSubmit | `user-prompt-submit.sh` | Prompt governance reminder + arm search-first flag only when RAG/Web is available |
11796
11922
  | UserPromptSubmit | `track-usage.sh` | Record skill invocations to local stats |
11797
- | PostToolUse | `post-tool-use.sh` | Lightweight validation reminders after edits |
11923
+ | PostToolUse | `post-tool-use.sh` | Lightweight validation reminders + append edit to session state |
11798
11924
  | PostToolUse | `governance-capture.sh` | Log security-sensitive operations to JSONL |
11925
+ | PostToolUse | `test-cohesion.sh` | Run cohesion-mapped tests after edits; block on failure (Art. VI.3) |
11926
+ | PostToolUse | `search-tracker.sh` | Clear search-first flag when smart_query/hybrid_search_kb/Web* runs |
11799
11927
  | Stop | `quality-check.sh` | Multi-language lint (ruff/tsc/phpstan/dart/go) |
11800
11928
  | Stop | `save-session.sh` | Persist session context for cross-session continuity |
11801
- | Stop | `quality-gate.sh` | Block final response on lint/type errors |
11929
+ | Stop | `quality-gate.sh` | Block final response on lint/type errors + cohesion tests for session edits |
11930
+ | Stop | `stop-search-check.sh` | Continue conversation if search-first rule was skipped and a provider exists; no-op offline |
11802
11931
  | TaskCompleted | `quality-gate.sh` | Block task completion on lint/type errors |
11803
11932
  | SubagentStart | `subagent-start.sh` | Narrow-scope reminder for spawned subagents |
11804
11933
  | SubagentStop | `subagent-stop.sh` | Completion checklist for subagent handoff |
11805
11934
  | PreCompact | `pre-compact.sh` | Smart compaction: prioritized context |
11806
11935
  | PreCompact | `pre-compact-save.sh` | Save timestamped context backup |
11807
11936
  | SessionEnd | `session-end.sh` | Persist a session-end handoff note |
11937
+ | InstructionsLoaded | `instructions-audit.sh` | Append every CLAUDE.md / rules load to audit log (which rules actually entered context) |
11938
+ | ConfigChange | `config-desync-guard.sh` | Warn when `~/.claude/settings.json` drifts from `app/hooks.json` (advisory) |
11808
11939
  | TeammateIdle | *(inline)* | Completeness reminder |
11809
11940
 
11810
11941
  **5 skill-scoped hooks:**
package/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.2.4",
2
+ "version": "4.3.0",
3
3
  "components": {
4
4
  "agents": {
5
5
  "description": "44 specialized agents (orchestrator, backend, frontend, security, devops, etc.)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softspark/ai-toolkit",
3
- "version": "4.2.4",
3
+ "version": "4.3.0",
4
4
  "description": "AI coding toolkit: 107 skills, 44 agents, 12-editor write-through (Claude, Cursor, Windsurf, Copilot, Gemini, Cline, Roo, Aider, Augment, Antigravity, Codex, opencode), machine-enforced safety constitution, SARIF audit, signed npm provenance.",
5
5
  "keywords": [
6
6
  "claude",
package/scripts/doctor.py CHANGED
@@ -45,16 +45,29 @@ VALID_EVENTS = frozenset({
45
45
  "SessionStart", "Notification", "PreToolUse", "PostToolUse", "Stop",
46
46
  "PreCompact", "SubagentStop", "UserPromptSubmit", "TaskCompleted",
47
47
  "TeammateIdle", "SubagentStart", "SessionEnd", "PermissionRequest", "Setup",
48
+ "InstructionsLoaded", "ConfigChange", "PostToolUseFailure", "PostToolBatch",
49
+ "UserPromptExpansion", "PostCompact", "StopFailure", "CwdChanged",
50
+ "FileChanged", "PermissionDenied", "Elicitation", "ElicitationResult",
51
+ "WorktreeCreate", "WorktreeRemove",
48
52
  })
49
53
 
50
54
  EXPECTED_HOOKS = [
55
+ "_hook-io.sh",
56
+ "_locate-toolkit.sh",
57
+ "_search-capability.sh",
51
58
  "guard-destructive.sh",
52
59
  "guard-path.sh",
60
+ "config-desync-guard.sh",
61
+ "instructions-audit.sh",
53
62
  "post-tool-use.sh",
54
63
  "quality-check.sh",
55
64
  "quality-gate.sh",
65
+ "revert-guard.sh",
66
+ "search-tracker.sh",
56
67
  "save-session.sh",
57
68
  "session-start.sh",
69
+ "stop-search-check.sh",
70
+ "test-cohesion.sh",
58
71
  "pre-compact.sh",
59
72
  "user-prompt-submit.sh",
60
73
  "track-usage.sh",
@@ -32,7 +32,7 @@ import os
32
32
  import sys
33
33
  from pathlib import Path
34
34
 
35
- HOOKS_PREFIX = '"$HOME/.softspark/ai-toolkit/hooks/'
35
+ HOOKS_PREFIX = 'AI_TOOLKIT_HOOK_FORMAT=json "$HOME/.softspark/ai-toolkit/hooks/'
36
36
  SOURCE_TAG = "ai-toolkit"
37
37
 
38
38
  # Event -> list of (matcher, script). Matcher is a regex over tool_name.
@@ -45,16 +45,20 @@ AUGMENT_HOOKS: dict[str, list[tuple[str, str]]] = {
45
45
  "PreToolUse": [
46
46
  ("launch-process", "guard-destructive.sh"),
47
47
  ("launch-process", "commit-quality.sh"),
48
+ ("launch-process", "revert-guard.sh"),
48
49
  ("view|str-replace-editor|save-file|remove-files", "guard-path.sh"),
49
50
  ("str-replace-editor|save-file", "guard-config.sh"),
50
51
  ],
51
52
  "PostToolUse": [
52
53
  ("str-replace-editor|save-file", "post-tool-use.sh"),
54
+ ("str-replace-editor|save-file", "test-cohesion.sh"),
53
55
  ("launch-process|str-replace-editor|save-file", "governance-capture.sh"),
56
+ ("web-fetch|web-search|codebase-retrieval", "search-tracker.sh"),
54
57
  ],
55
58
  "Stop": [
56
59
  ("", "quality-check.sh"),
57
60
  ("", "save-session.sh"),
61
+ ("", "stop-search-check.sh"),
58
62
  ],
59
63
  "SessionEnd": [
60
64
  ("", "session-end.sh"),
@@ -37,6 +37,7 @@ CODEX_HOOKS: dict[str, list[tuple[str, str]]] = {
37
37
  "PreToolUse": [
38
38
  ("Bash", "guard-destructive.sh"),
39
39
  ("Bash", "commit-quality.sh"),
40
+ ("Bash", "revert-guard.sh"),
40
41
  ],
41
42
  "PermissionRequest": [
42
43
  # Fires when Codex asks the user to approve a tool call. Our guard
@@ -51,6 +52,7 @@ CODEX_HOOKS: dict[str, list[tuple[str, str]]] = {
51
52
  "Stop": [
52
53
  ("", "quality-check.sh"),
53
54
  ("", "save-session.sh"),
55
+ ("", "stop-search-check.sh"),
54
56
  ],
55
57
  }
56
58
 
@@ -43,6 +43,7 @@ CURSOR_HOOKS: dict[str, list[tuple[str, str]]] = {
43
43
  "beforeShellExecution": [
44
44
  ("", "guard-destructive.sh"),
45
45
  ("", "commit-quality.sh"),
46
+ ("", "revert-guard.sh"),
46
47
  ],
47
48
  "beforeReadFile": [
48
49
  ("", "guard-path.sh"),
@@ -50,6 +51,7 @@ CURSOR_HOOKS: dict[str, list[tuple[str, str]]] = {
50
51
  "afterFileEdit": [
51
52
  ("", "post-tool-use.sh"),
52
53
  ("", "governance-capture.sh"),
54
+ ("", "test-cohesion.sh"),
53
55
  ],
54
56
  "beforeSubmitPrompt": [
55
57
  ("", "user-prompt-submit.sh"),
@@ -58,6 +60,9 @@ CURSOR_HOOKS: dict[str, list[tuple[str, str]]] = {
58
60
  "beforeMCPExecution": [
59
61
  ("", "guard-config.sh"),
60
62
  ],
63
+ "afterMCPExecution": [
64
+ ("", "search-tracker.sh"),
65
+ ],
61
66
  "preCompact": [
62
67
  ("", "pre-compact.sh"),
63
68
  ("", "pre-compact-save.sh"),
@@ -71,6 +76,7 @@ CURSOR_HOOKS: dict[str, list[tuple[str, str]]] = {
71
76
  "stop": [
72
77
  ("", "quality-check.sh"),
73
78
  ("", "save-session.sh"),
79
+ ("", "stop-search-check.sh"),
74
80
  ],
75
81
  "sessionEnd": [
76
82
  ("", "session-end.sh"),
@@ -29,7 +29,7 @@ import json
29
29
  import sys
30
30
  from pathlib import Path
31
31
 
32
- HOOKS_PREFIX = '"$HOME/.softspark/ai-toolkit/hooks/'
32
+ HOOKS_PREFIX = 'AI_TOOLKIT_HOOK_FORMAT=json "$HOME/.softspark/ai-toolkit/hooks/'
33
33
  SOURCE_TAG = "ai-toolkit"
34
34
 
35
35
  # Event -> list of (matcher, script) pairs. Matcher semantics:
@@ -46,13 +46,16 @@ GEMINI_HOOKS: dict[str, list[tuple[str, str]]] = {
46
46
  # run_shell_command covers Bash-equivalent destructive patterns
47
47
  ("run_shell_command", "guard-destructive.sh"),
48
48
  ("run_shell_command", "commit-quality.sh"),
49
+ ("run_shell_command", "revert-guard.sh"),
49
50
  # File-touching tools — guard paths + config
50
51
  ("write_file|edit|replace|read_file", "guard-path.sh"),
51
52
  ("write_file|edit|replace", "guard-config.sh"),
52
53
  ],
53
54
  "AfterTool": [
54
55
  ("write_file|edit|replace", "post-tool-use.sh"),
56
+ ("write_file|edit|replace", "test-cohesion.sh"),
55
57
  ("run_shell_command|write_file|edit|replace", "governance-capture.sh"),
58
+ ("google_web_search|web_fetch", "search-tracker.sh"),
56
59
  ],
57
60
  "BeforeAgent": [
58
61
  ("", "user-prompt-submit.sh"),
@@ -62,6 +65,7 @@ GEMINI_HOOKS: dict[str, list[tuple[str, str]]] = {
62
65
  # Closest equivalent to Claude's Stop event. Gemini has no native Stop.
63
66
  ("", "quality-check.sh"),
64
67
  ("", "save-session.sh"),
68
+ ("", "stop-search-check.sh"),
65
69
  ],
66
70
  "BeforeModel": [
67
71
  # Light-weight observability slot. Reuses the session-context probe.
@@ -41,10 +41,12 @@ WINDSURF_HOOKS: dict[str, list[str]] = {
41
41
  "post_write_code": [
42
42
  "post-tool-use.sh",
43
43
  "governance-capture.sh",
44
+ "test-cohesion.sh",
44
45
  ],
45
46
  "pre_run_command": [
46
47
  "guard-destructive.sh",
47
48
  "commit-quality.sh",
49
+ "revert-guard.sh",
48
50
  ],
49
51
  "post_run_command": [
50
52
  "governance-capture.sh",
@@ -52,6 +54,9 @@ WINDSURF_HOOKS: dict[str, list[str]] = {
52
54
  "pre_mcp_tool_use": [
53
55
  "guard-config.sh",
54
56
  ],
57
+ "post_mcp_tool_use": [
58
+ "search-tracker.sh",
59
+ ],
55
60
  "pre_user_prompt": [
56
61
  "user-prompt-submit.sh",
57
62
  "track-usage.sh",
@@ -59,6 +64,7 @@ WINDSURF_HOOKS: dict[str, list[str]] = {
59
64
  "post_cascade_response": [
60
65
  "quality-check.sh",
61
66
  "save-session.sh",
67
+ "stop-search-check.sh",
62
68
  ],
63
69
  "post_setup_worktree": [
64
70
  "session-context.sh",