@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.
- package/AGENTS.md +5 -29
- package/CHANGELOG.md +39 -0
- package/README.md +170 -27
- package/app/.claude-plugin/plugin.json +2 -2
- package/app/ARCHITECTURE.md +35 -19
- package/app/agents/ai-engineer.md +47 -5
- package/app/agents/fact-checker.md +1 -1
- package/app/agents/llm-ops-engineer.md +2 -2
- package/app/agents/{mcp-server-architect.md → mcp-specialist.md} +124 -18
- package/app/agents/mcp-testing-engineer.md +2 -2
- package/app/agents/nlp-engineer.md +1 -1
- package/app/agents/orchestrator.md +3 -4
- package/app/agents/project-planner.md +1 -1
- package/app/agents/technical-researcher.md +71 -21
- package/app/hooks/commit-quality.sh +53 -0
- package/app/hooks/governance-capture.sh +77 -0
- package/app/hooks/guard-config.sh +46 -0
- package/app/hooks/mcp-health.sh +53 -0
- package/app/hooks/pre-compact-save.sh +34 -0
- package/app/hooks/session-context.sh +60 -0
- package/app/hooks.json +60 -0
- package/app/mcp-templates/README.md +105 -0
- package/app/mcp-templates/brave-search.json +13 -0
- package/app/mcp-templates/cloudflare.json +14 -0
- package/app/mcp-templates/context7.json +10 -0
- package/app/mcp-templates/custom-template.json +13 -0
- package/app/mcp-templates/datadog.json +15 -0
- package/app/mcp-templates/docker.json +10 -0
- package/app/mcp-templates/fetch.json +10 -0
- package/app/mcp-templates/filesystem.json +10 -0
- package/app/mcp-templates/git.json +10 -0
- package/app/mcp-templates/github.json +13 -0
- package/app/mcp-templates/google-drive.json +15 -0
- package/app/mcp-templates/google-maps.json +13 -0
- package/app/mcp-templates/grafana.json +14 -0
- package/app/mcp-templates/linear.json +13 -0
- package/app/mcp-templates/memory.json +10 -0
- package/app/mcp-templates/notion.json +13 -0
- package/app/mcp-templates/postgres.json +10 -0
- package/app/mcp-templates/puppeteer.json +10 -0
- package/app/mcp-templates/redis.json +13 -0
- package/app/mcp-templates/sentry.json +14 -0
- package/app/mcp-templates/sequential-thinking.json +10 -0
- package/app/mcp-templates/slack.json +14 -0
- package/app/mcp-templates/sqlite.json +10 -0
- package/app/mcp-templates/supabase.json +14 -0
- package/app/mcp-templates/vercel.json +13 -0
- package/app/plugins/research-pack/README.md +1 -1
- package/app/plugins/research-pack/plugin.json +1 -1
- package/app/rules/claude-toolkit-rules.md +1 -1
- package/app/rules/common/coding-style.md +52 -0
- package/app/rules/common/git-workflow.md +45 -0
- package/app/rules/common/performance.md +49 -0
- package/app/rules/common/security.md +59 -0
- package/app/rules/common/testing.md +53 -0
- package/app/rules/cpp/coding-style.md +55 -0
- package/app/rules/cpp/frameworks.md +55 -0
- package/app/rules/cpp/patterns.md +57 -0
- package/app/rules/cpp/security.md +61 -0
- package/app/rules/cpp/testing.md +58 -0
- package/app/rules/csharp/coding-style.md +54 -0
- package/app/rules/csharp/frameworks.md +60 -0
- package/app/rules/csharp/patterns.md +61 -0
- package/app/rules/csharp/security.md +60 -0
- package/app/rules/csharp/testing.md +58 -0
- package/app/rules/dart/coding-style.md +61 -0
- package/app/rules/dart/frameworks.md +59 -0
- package/app/rules/dart/patterns.md +62 -0
- package/app/rules/dart/security.md +60 -0
- package/app/rules/dart/testing.md +60 -0
- package/app/rules/golang/coding-style.md +50 -0
- package/app/rules/golang/frameworks.md +56 -0
- package/app/rules/golang/patterns.md +52 -0
- package/app/rules/golang/security.md +61 -0
- package/app/rules/golang/testing.md +54 -0
- package/app/rules/java/coding-style.md +56 -0
- package/app/rules/java/frameworks.md +54 -0
- package/app/rules/java/patterns.md +59 -0
- package/app/rules/java/security.md +60 -0
- package/app/rules/java/testing.md +55 -0
- package/app/rules/kotlin/coding-style.md +56 -0
- package/app/rules/kotlin/frameworks.md +54 -0
- package/app/rules/kotlin/patterns.md +54 -0
- package/app/rules/kotlin/security.md +62 -0
- package/app/rules/kotlin/testing.md +56 -0
- package/app/rules/php/coding-style.md +53 -0
- package/app/rules/php/frameworks.md +57 -0
- package/app/rules/php/patterns.md +63 -0
- package/app/rules/php/security.md +61 -0
- package/app/rules/php/testing.md +60 -0
- package/app/rules/python/coding-style.md +52 -0
- package/app/rules/python/frameworks.md +53 -0
- package/app/rules/python/patterns.md +53 -0
- package/app/rules/python/security.md +58 -0
- package/app/rules/python/testing.md +52 -0
- package/app/rules/ruby/coding-style.md +56 -0
- package/app/rules/ruby/frameworks.md +56 -0
- package/app/rules/ruby/patterns.md +61 -0
- package/app/rules/ruby/security.md +61 -0
- package/app/rules/ruby/testing.md +63 -0
- package/app/rules/rust/coding-style.md +52 -0
- package/app/rules/rust/frameworks.md +59 -0
- package/app/rules/rust/patterns.md +58 -0
- package/app/rules/rust/security.md +64 -0
- package/app/rules/rust/testing.md +54 -0
- package/app/rules/swift/coding-style.md +55 -0
- package/app/rules/swift/frameworks.md +63 -0
- package/app/rules/swift/patterns.md +63 -0
- package/app/rules/swift/security.md +63 -0
- package/app/rules/swift/testing.md +60 -0
- package/app/rules/typescript/coding-style.md +51 -0
- package/app/rules/typescript/frameworks.md +51 -0
- package/app/rules/typescript/patterns.md +51 -0
- package/app/rules/typescript/security.md +55 -0
- package/app/rules/typescript/testing.md +52 -0
- package/app/skills/app-builder/SKILL.md +1 -1
- package/app/skills/brand-voice/SKILL.md +92 -0
- package/app/skills/council/SKILL.md +133 -0
- package/app/skills/introspect/SKILL.md +125 -0
- package/bin/ai-toolkit.js +103 -2
- package/kb/reference/agents-catalog.md +10 -13
- package/kb/reference/architecture-overview.md +29 -6
- package/kb/reference/commands-catalog.md +4 -4
- package/kb/reference/competitive-features-implementation.md +677 -0
- package/kb/reference/extension-api.md +175 -0
- package/kb/reference/hooks-catalog.md +90 -14
- package/kb/reference/language-rules.md +167 -0
- package/kb/reference/manifest-install.md +165 -0
- package/kb/reference/mcp-templates.md +110 -0
- package/kb/reference/skills-catalog.md +9 -6
- package/llms-full.txt +1511 -59
- package/llms.txt +8 -3
- package/package.json +2 -2
- package/scripts/inject_hook_cli.py +330 -0
- package/scripts/install.py +241 -7
- package/scripts/install_steps/ai_tools.py +63 -1
- package/scripts/install_steps/detect_language.py +50 -0
- package/scripts/install_steps/install_state.py +117 -0
- package/scripts/mcp_manager.py +206 -0
- package/app/agents/mcp-expert.md +0 -228
- package/app/agents/rag-engineer.md +0 -201
- package/app/agents/research-synthesizer.md +0 -138
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Extension API Reference"
|
|
3
|
+
category: reference
|
|
4
|
+
service: ai-toolkit
|
|
5
|
+
tags: [extension-api, inject-rule, inject-hook, mcp-templates, integration]
|
|
6
|
+
version: "1.3.0"
|
|
7
|
+
created: "2026-04-07"
|
|
8
|
+
last_updated: "2026-04-07"
|
|
9
|
+
description: "Reference for ai-toolkit's extension API: inject-rule, inject-hook, remove-rule, remove-hook, and mcp template management."
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Extension API Reference
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
ai-toolkit exposes a generic extension API that lets external tools register their own rules and hooks alongside the toolkit's built-in components. The toolkit has no knowledge of any specific consumer — it only provides the injection mechanism. Consumers call the public CLI commands from their own install scripts.
|
|
17
|
+
|
|
18
|
+
This design is intentional: ai-toolkit is a generic toolkit. Consumers (MCP servers, CI systems, custom tools) use the public API to add their own rules and hooks without modifying toolkit internals.
|
|
19
|
+
|
|
20
|
+
## Commands
|
|
21
|
+
|
|
22
|
+
| Command | Target File | Mechanism | Idempotent |
|
|
23
|
+
|---------|-------------|-----------|------------|
|
|
24
|
+
| `inject-rule <file.md>` | `~/.claude/CLAUDE.md` | HTML comment markers (`<!-- TOOLKIT:name -->`) | Yes |
|
|
25
|
+
| `remove-rule <name>` | `~/.claude/CLAUDE.md` | Strip markers by block name | Yes |
|
|
26
|
+
| `inject-hook <file.json>` | `~/.claude/settings.json` | JSON `_source` tag per entry | Yes |
|
|
27
|
+
| `remove-hook <name>` | `~/.claude/settings.json` | Strip all entries with matching `_source` | Yes |
|
|
28
|
+
| `add-rule <file.md>` | `~/.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 |
|
|
30
|
+
|
|
31
|
+
## inject-rule
|
|
32
|
+
|
|
33
|
+
Injects a Markdown rules file into `~/.claude/CLAUDE.md` between named HTML comment markers.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx @softspark/ai-toolkit inject-rule ./my-tool-rules.md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Implementation:** `scripts/inject_rule_cli.py` (delegates to `inject_section_cli.py`).
|
|
40
|
+
|
|
41
|
+
**Markers written:**
|
|
42
|
+
```html
|
|
43
|
+
<!-- TOOLKIT:my-tool-rules START -->
|
|
44
|
+
... content of my-tool-rules.md ...
|
|
45
|
+
<!-- TOOLKIT:my-tool-rules END -->
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The block name is derived from the file stem (`my-tool-rules.md` → `my-tool-rules`). Re-running replaces the existing block — no duplicates. Content outside these markers is never modified.
|
|
49
|
+
|
|
50
|
+
## remove-rule
|
|
51
|
+
|
|
52
|
+
Strips a previously injected rule block from `~/.claude/CLAUDE.md`.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx @softspark/ai-toolkit remove-rule my-tool-rules
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The argument is the block name (file stem used during `inject-rule`). If the block is not present, the command exits 0 silently.
|
|
59
|
+
|
|
60
|
+
## inject-hook
|
|
61
|
+
|
|
62
|
+
Injects hook entries from a JSON file into `~/.claude/settings.json`. Every injected entry is tagged with `"_source": "<source-name>"` where the source name is derived from the filename stem.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx @softspark/ai-toolkit inject-hook ./my-tool-hooks.json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Implementation:** `scripts/inject_hook_cli.py`.
|
|
69
|
+
|
|
70
|
+
**Input format:**
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"hooks": {
|
|
74
|
+
"SessionStart": [
|
|
75
|
+
{
|
|
76
|
+
"matcher": "",
|
|
77
|
+
"hooks": [{ "type": "command", "command": "$HOME/.my-tool/hooks/on-start.sh" }]
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"PostToolUse": [
|
|
81
|
+
{
|
|
82
|
+
"matcher": "Edit|Write",
|
|
83
|
+
"hooks": [{ "type": "command", "command": "$HOME/.my-tool/hooks/on-edit.sh" }]
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Source name derivation:** `my-tool-hooks.json` → source name `"my-tool-hooks"`. All entries are tagged `"_source": "my-tool-hooks"` in settings.json.
|
|
91
|
+
|
|
92
|
+
**Idempotency:** Re-running strips all existing entries with the same source name, then appends the new ones. No duplicates accumulate.
|
|
93
|
+
|
|
94
|
+
**Safety:** Entries tagged `"_source": "ai-toolkit"` are never modified or removed by this command. External tools cannot affect the toolkit's own hooks.
|
|
95
|
+
|
|
96
|
+
## remove-hook
|
|
97
|
+
|
|
98
|
+
Strips all hook entries from `~/.claude/settings.json` that carry a given `_source` tag.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx @softspark/ai-toolkit remove-hook my-tool-hooks
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
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.
|
|
105
|
+
|
|
106
|
+
## mcp add
|
|
107
|
+
|
|
108
|
+
Merges one or more MCP server templates from `app/mcp-templates/` into the project's `.mcp.json`.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
ai-toolkit mcp add github # add a single template
|
|
112
|
+
ai-toolkit mcp add github postgres slack # add multiple at once
|
|
113
|
+
ai-toolkit mcp list # list all available templates
|
|
114
|
+
ai-toolkit mcp show github # print a template's JSON
|
|
115
|
+
ai-toolkit mcp remove github # remove an entry from .mcp.json
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Implementation:** `scripts/mcp_manager.py`.
|
|
119
|
+
|
|
120
|
+
The `add` command merges the `mcpServers` block from the template into `.mcp.json`. If `.mcp.json` does not exist, it is created. If the server name already exists, the entry is overwritten. See [mcp-templates.md](mcp-templates.md) for the full list of available templates.
|
|
121
|
+
|
|
122
|
+
## Architecture
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
┌──────────────────────────────────────────────────────┐
|
|
126
|
+
│ ai-toolkit (generic) │
|
|
127
|
+
│ │
|
|
128
|
+
│ Public Extension API: │
|
|
129
|
+
│ inject-rule <file.md> → CLAUDE.md │
|
|
130
|
+
│ remove-rule <name> → CLAUDE.md │
|
|
131
|
+
│ inject-hook <file.json> → settings.json │
|
|
132
|
+
│ remove-hook <name> → settings.json │
|
|
133
|
+
│ add-rule <file.md> → rules/ registry │
|
|
134
|
+
│ mcp add <template> → .mcp.json │
|
|
135
|
+
│ │
|
|
136
|
+
│ Idempotent: markers (rules) / _source tags (hooks) │
|
|
137
|
+
│ ai-toolkit NEVER calls external services │
|
|
138
|
+
└──────────────────────────────────────────────────────┘
|
|
139
|
+
▲
|
|
140
|
+
│ uses API
|
|
141
|
+
┌───────────────┼───────────────┐
|
|
142
|
+
│ │ │
|
|
143
|
+
rag-mcp custom-tool ci-system
|
|
144
|
+
(consumer) (consumer) (consumer)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Example: Registering Rules and Hooks from an External Tool
|
|
148
|
+
|
|
149
|
+
An external tool's install script would call:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Register rules into CLAUDE.md
|
|
153
|
+
npx @softspark/ai-toolkit inject-rule ./rules/my-tool-rules.md
|
|
154
|
+
|
|
155
|
+
# Register hooks into settings.json
|
|
156
|
+
npx @softspark/ai-toolkit inject-hook ./hooks/my-tool-hooks.json
|
|
157
|
+
|
|
158
|
+
# Add an MCP server template
|
|
159
|
+
npx @softspark/ai-toolkit mcp add github
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
To uninstall:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npx @softspark/ai-toolkit remove-rule my-tool-rules
|
|
166
|
+
npx @softspark/ai-toolkit remove-hook my-tool-hooks
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
All operations are idempotent — safe to run on every install or update.
|
|
170
|
+
|
|
171
|
+
## Related Documentation
|
|
172
|
+
|
|
173
|
+
- [PATH: kb/reference/hooks-catalog.md] — built-in hooks reference
|
|
174
|
+
- [PATH: kb/reference/mcp-templates.md] — available MCP server templates
|
|
175
|
+
- [PATH: kb/reference/architecture-overview.md] — overall install model
|
|
@@ -3,9 +3,9 @@ title: "Hooks Catalog"
|
|
|
3
3
|
category: reference
|
|
4
4
|
service: ai-toolkit
|
|
5
5
|
tags: [hooks, quality, safety, enforcement, settings.json]
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.1.0"
|
|
7
7
|
created: "2026-03-27"
|
|
8
|
-
last_updated: "2026-04-
|
|
8
|
+
last_updated: "2026-04-07"
|
|
9
9
|
description: "Complete reference of all ai-toolkit hooks: events, scripts, installation, and runtime behavior."
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -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 21 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 `~/.ai-toolkit/hooks/`.
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
@@ -231,6 +231,76 @@ Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
|
231
231
|
|
|
232
232
|
**Action:** Reminds teammate to verify: files modified, tests written, docs updated.
|
|
233
233
|
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## New Hooks (v1.1.0)
|
|
237
|
+
|
|
238
|
+
### PreToolUse (config guard) — `guard-config.sh`
|
|
239
|
+
|
|
240
|
+
| Field | Value |
|
|
241
|
+
|-------|-------|
|
|
242
|
+
| Event | `PreToolUse` |
|
|
243
|
+
| Matcher | `Edit\|Write\|MultiEdit` |
|
|
244
|
+
| Script | `~/.ai-toolkit/hooks/guard-config.sh` |
|
|
245
|
+
| Fires | Before any file write/edit operation |
|
|
246
|
+
|
|
247
|
+
**Action:** Blocks (exit 2) edits to linter and formatter config files — `.eslintrc`, `.eslintrc.*`, `eslint.config.*`, `.prettierrc`, `.prettierrc.*`, `prettier.config.*`, `tsconfig.json`, `tsconfig.*.json` — unless the request contains an explicit acknowledgment phrase (e.g. "intentionally editing config"). Returns a human-readable explanation to Claude so it can ask the user for confirmation before retrying.
|
|
248
|
+
|
|
249
|
+
### SessionStart — `mcp-health.sh`
|
|
250
|
+
|
|
251
|
+
| Field | Value |
|
|
252
|
+
|-------|-------|
|
|
253
|
+
| Event | `SessionStart` |
|
|
254
|
+
| Matcher | *(all)* |
|
|
255
|
+
| Script | `~/.ai-toolkit/hooks/mcp-health.sh` |
|
|
256
|
+
| Fires | Session start |
|
|
257
|
+
|
|
258
|
+
**Action:** Non-blocking (always exits 0). Reads MCP server definitions from `~/.claude/settings.json` and any local `.mcp.json`. For each configured server, checks whether the required runtime command (`npx`, `uvx`, `docker`, etc.) is available in `$PATH`. Emits warnings for any missing runtimes, including install hints (e.g. "npm install -g npx"). Helps surface MCP misconfiguration early without interrupting the session.
|
|
259
|
+
|
|
260
|
+
### PostToolUse (governance) — `governance-capture.sh`
|
|
261
|
+
|
|
262
|
+
| Field | Value |
|
|
263
|
+
|-------|-------|
|
|
264
|
+
| Event | `PostToolUse` |
|
|
265
|
+
| Matcher | *(all)* |
|
|
266
|
+
| Script | `~/.ai-toolkit/hooks/governance-capture.sh` |
|
|
267
|
+
| Fires | After any tool use |
|
|
268
|
+
|
|
269
|
+
**Action:** Non-blocking (always exits 0). Logs security-sensitive operations (Bash commands, file writes to sensitive paths, large writes) to `~/.ai-toolkit/governance.log` with ISO timestamp, session ID, tool name, and a content excerpt. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
270
|
+
|
|
271
|
+
### PreCompact — `pre-compact-save.sh`
|
|
272
|
+
|
|
273
|
+
| Field | Value |
|
|
274
|
+
|-------|-------|
|
|
275
|
+
| Event | `PreCompact` |
|
|
276
|
+
| Matcher | *(all)* |
|
|
277
|
+
| Script | `~/.ai-toolkit/hooks/pre-compact-save.sh` |
|
|
278
|
+
| Fires | Before context compaction |
|
|
279
|
+
|
|
280
|
+
**Action:** Saves a timestamped context snapshot to `~/.ai-toolkit/compactions/YYYY-MM-DD_HH-MM-SS.txt`. Captures session ID, working directory, git branch and status, and environment metadata. Provides an audit trail of what was in context at each compaction point. Skipped when `TOOLKIT_HOOK_PROFILE=minimal`.
|
|
281
|
+
|
|
282
|
+
### PreToolUse (commit quality) — `commit-quality.sh`
|
|
283
|
+
|
|
284
|
+
| Field | Value |
|
|
285
|
+
|-------|-------|
|
|
286
|
+
| Event | `PreToolUse` |
|
|
287
|
+
| Matcher | `Bash` |
|
|
288
|
+
| Script | `~/.ai-toolkit/hooks/commit-quality.sh` |
|
|
289
|
+
| Fires | Before any Bash command |
|
|
290
|
+
|
|
291
|
+
**Action:** Non-blocking (always exits 0). Inspects Bash commands containing `git commit`. Extracts the commit message from the `-m` flag and checks it against Conventional Commits format (`type: description`, where type is one of feat/fix/docs/refactor/test/chore/ci/perf/style/revert). Emits an advisory warning if the message does not match — the commit is not blocked, only nudged. Commands without `git commit` or without a `-m` message (e.g. interactive commits) are ignored.
|
|
292
|
+
|
|
293
|
+
### SessionStart — `session-context.sh`
|
|
294
|
+
|
|
295
|
+
| Field | Value |
|
|
296
|
+
|-------|-------|
|
|
297
|
+
| Event | `SessionStart` |
|
|
298
|
+
| Matcher | *(all)* |
|
|
299
|
+
| Script | `~/.ai-toolkit/hooks/session-context.sh` |
|
|
300
|
+
| Fires | Session start |
|
|
301
|
+
|
|
302
|
+
**Action:** Captures an environment snapshot to `~/.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`.
|
|
303
|
+
|
|
234
304
|
## Runtime Profiles
|
|
235
305
|
|
|
236
306
|
Set in `.claude/settings.local.json`:
|
|
@@ -253,10 +323,14 @@ Set in `.claude/settings.local.json`:
|
|
|
253
323
|
└── hooks/ # Hook scripts (copied on install)
|
|
254
324
|
├── _profile-check.sh # Shared: profile skip logic (sourced by hooks)
|
|
255
325
|
├── session-start.sh
|
|
326
|
+
├── session-context.sh # NEW: capture session env snapshot
|
|
256
327
|
├── guard-destructive.sh
|
|
257
328
|
├── guard-path.sh
|
|
329
|
+
├── guard-config.sh # NEW: block config file edits
|
|
330
|
+
├── mcp-health.sh # NEW: check MCP runtime availability
|
|
258
331
|
├── user-prompt-submit.sh
|
|
259
332
|
├── post-tool-use.sh
|
|
333
|
+
├── governance-capture.sh # NEW: log security-sensitive operations
|
|
260
334
|
├── quality-check.sh
|
|
261
335
|
├── quality-gate.sh
|
|
262
336
|
├── save-session.sh
|
|
@@ -264,22 +338,24 @@ Set in `.claude/settings.local.json`:
|
|
|
264
338
|
├── subagent-stop.sh
|
|
265
339
|
├── track-usage.sh
|
|
266
340
|
├── pre-compact.sh
|
|
341
|
+
├── pre-compact-save.sh # NEW: timestamped context snapshot
|
|
342
|
+
├── commit-quality.sh # NEW: advisory commit message check
|
|
267
343
|
└── session-end.sh
|
|
268
344
|
|
|
269
345
|
~/.claude/settings.json
|
|
270
346
|
└── hooks: # Hook definitions referencing ~/.ai-toolkit/hooks/
|
|
271
|
-
├── SessionStart
|
|
272
|
-
├── Notification
|
|
273
|
-
├── PreToolUse
|
|
347
|
+
├── SessionStart → session-start.sh, mcp-health.sh, session-context.sh
|
|
348
|
+
├── Notification → osascript (inline)
|
|
349
|
+
├── PreToolUse → guard-destructive.sh, guard-path.sh, guard-config.sh, commit-quality.sh
|
|
274
350
|
├── UserPromptSubmit → user-prompt-submit.sh, track-usage.sh
|
|
275
|
-
├── PostToolUse
|
|
276
|
-
├── Stop
|
|
277
|
-
├── TaskCompleted
|
|
278
|
-
├── TeammateIdle
|
|
279
|
-
├── SubagentStart
|
|
280
|
-
├── SubagentStop
|
|
281
|
-
├── PreCompact
|
|
282
|
-
└── SessionEnd
|
|
351
|
+
├── PostToolUse → post-tool-use.sh, governance-capture.sh
|
|
352
|
+
├── Stop → quality-check.sh, save-session.sh
|
|
353
|
+
├── TaskCompleted → quality-gate.sh
|
|
354
|
+
├── TeammateIdle → echo (inline)
|
|
355
|
+
├── SubagentStart → subagent-start.sh
|
|
356
|
+
├── SubagentStop → subagent-stop.sh
|
|
357
|
+
├── PreCompact → pre-compact.sh, pre-compact-save.sh
|
|
358
|
+
└── SessionEnd → session-end.sh
|
|
283
359
|
```
|
|
284
360
|
|
|
285
361
|
**Key design decisions:**
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Language Rules System"
|
|
3
|
+
category: reference
|
|
4
|
+
service: ai-toolkit
|
|
5
|
+
tags: [rules, languages, coding-style, testing, patterns, security]
|
|
6
|
+
version: "1.0.0"
|
|
7
|
+
created: "2026-04-07"
|
|
8
|
+
last_updated: "2026-04-07"
|
|
9
|
+
description: "Reference for the language-specific rules system: 13 languages, 5 categories per language, auto-detection."
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Language Rules System
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
ai-toolkit ships 70 language-specific rule files covering 13 programming languages plus a common set. Rules are plain Markdown files injected into `CLAUDE.md` via `ai-toolkit install --local`. They provide coding-style, testing, patterns, frameworks, and security guidance specific to each language.
|
|
17
|
+
|
|
18
|
+
Rules are distinct from skills: rules are injected as static text into `CLAUDE.md` and are always visible to Claude, whereas skills are loaded contextually by agents.
|
|
19
|
+
|
|
20
|
+
## File Structure
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
app/rules/
|
|
24
|
+
├── common/
|
|
25
|
+
│ ├── coding-style.md # KISS, DRY, YAGNI, immutability
|
|
26
|
+
│ ├── testing.md # Universal testing standards
|
|
27
|
+
│ ├── git-workflow.md # Commit conventions
|
|
28
|
+
│ ├── performance.md # Performance guidelines
|
|
29
|
+
│ └── security.md # OWASP, input validation
|
|
30
|
+
├── typescript/
|
|
31
|
+
│ ├── coding-style.md # Strict mode, no-any, naming
|
|
32
|
+
│ ├── testing.md # Vitest/Jest patterns
|
|
33
|
+
│ ├── patterns.md # Discriminated unions, utility types
|
|
34
|
+
│ ├── frameworks.md # React hooks, Next.js, lifecycle
|
|
35
|
+
│ └── security.md # XSS prevention, sanitization
|
|
36
|
+
├── python/
|
|
37
|
+
│ ├── coding-style.md # PEP 8, type hints, dataclasses
|
|
38
|
+
│ ├── testing.md # pytest, fixtures, parametrize
|
|
39
|
+
│ ├── patterns.md # Python idioms, context managers
|
|
40
|
+
│ ├── frameworks.md # FastAPI/Django lifecycle, SQLAlchemy
|
|
41
|
+
│ └── security.md # SQL injection, SSTI prevention
|
|
42
|
+
├── golang/ # same 5-file structure
|
|
43
|
+
├── rust/
|
|
44
|
+
├── java/
|
|
45
|
+
├── kotlin/
|
|
46
|
+
├── swift/
|
|
47
|
+
├── dart/
|
|
48
|
+
├── csharp/
|
|
49
|
+
├── php/
|
|
50
|
+
├── cpp/
|
|
51
|
+
└── ruby/
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Total: 13 languages × 5 files + 5 common = 70 rule files**
|
|
55
|
+
|
|
56
|
+
## Supported Languages
|
|
57
|
+
|
|
58
|
+
| Language | Directory | Auto-detect Files |
|
|
59
|
+
|----------|-----------|------------------|
|
|
60
|
+
| Common | `rules/common/` | always included |
|
|
61
|
+
| TypeScript | `rules/typescript/` | `package.json`, `tsconfig.json` |
|
|
62
|
+
| Python | `rules/python/` | `requirements.txt`, `pyproject.toml`, `setup.py`, `Pipfile` |
|
|
63
|
+
| Go | `rules/golang/` | `go.mod` |
|
|
64
|
+
| Rust | `rules/rust/` | `Cargo.toml` |
|
|
65
|
+
| Java | `rules/java/` | `pom.xml`, `build.gradle`, `build.gradle.kts` |
|
|
66
|
+
| Kotlin | `rules/kotlin/` | `build.gradle.kts` |
|
|
67
|
+
| Swift | `rules/swift/` | `Package.swift`, `*.xcodeproj` |
|
|
68
|
+
| Dart | `rules/dart/` | `pubspec.yaml` |
|
|
69
|
+
| C# | `rules/csharp/` | `*.csproj`, `*.sln` |
|
|
70
|
+
| PHP | `rules/php/` | `composer.json` |
|
|
71
|
+
| C++ | `rules/cpp/` | `CMakeLists.txt`, `Makefile`, `*.cpp` |
|
|
72
|
+
| Ruby | `rules/ruby/` | `Gemfile`, `*.gemspec` |
|
|
73
|
+
|
|
74
|
+
## Rule Categories
|
|
75
|
+
|
|
76
|
+
| Category | Filename | Content |
|
|
77
|
+
|----------|----------|---------|
|
|
78
|
+
| `coding-style` | `coding-style.md` | Naming, formatting, idiomatic constructs, linter config |
|
|
79
|
+
| `testing` | `testing.md` | Test framework usage, fixture patterns, coverage targets |
|
|
80
|
+
| `patterns` | `patterns.md` | Language-specific design patterns and idioms |
|
|
81
|
+
| `frameworks` | `frameworks.md` | Recommended framework conventions and lifecycle hooks |
|
|
82
|
+
| `security` | `security.md` | Common language-specific vulnerabilities and mitigations |
|
|
83
|
+
|
|
84
|
+
The `common/` directory uses the same structure except `frameworks.md` is replaced by `git-workflow.md` and `performance.md`.
|
|
85
|
+
|
|
86
|
+
## Auto-Detection
|
|
87
|
+
|
|
88
|
+
When `--auto-detect` is passed, `scripts/install_steps/detect_language.py` scans the current directory for known marker files and selects the matching language module:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
ai-toolkit install --local --auto-detect
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Detection logic (first match wins when multiple markers are present):
|
|
95
|
+
1. `package.json` or `tsconfig.json` → TypeScript
|
|
96
|
+
2. `go.mod` → Go
|
|
97
|
+
3. `Cargo.toml` → Rust
|
|
98
|
+
4. `pubspec.yaml` → Dart
|
|
99
|
+
5. `composer.json` → PHP
|
|
100
|
+
6. `Gemfile` → Ruby
|
|
101
|
+
7. `requirements.txt`, `pyproject.toml`, `setup.py`, or `Pipfile` → Python
|
|
102
|
+
8. `pom.xml` or `build.gradle` → Java
|
|
103
|
+
9. `build.gradle.kts` → Kotlin
|
|
104
|
+
10. `Package.swift` → Swift
|
|
105
|
+
11. `*.csproj` or `*.sln` → C#
|
|
106
|
+
12. `CMakeLists.txt` or `Makefile` → C++
|
|
107
|
+
|
|
108
|
+
Common rules are always injected regardless of detected language.
|
|
109
|
+
|
|
110
|
+
## Installation
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Auto-detect language from project files
|
|
114
|
+
ai-toolkit install --local --auto-detect
|
|
115
|
+
|
|
116
|
+
# Explicitly select a language
|
|
117
|
+
ai-toolkit install --local --lang typescript
|
|
118
|
+
|
|
119
|
+
# Install without language rules
|
|
120
|
+
ai-toolkit install --local
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Language rules are injected into the project `CLAUDE.md` between named markers:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
<!-- TOOLKIT:rules-typescript START -->
|
|
127
|
+
... TypeScript rules content ...
|
|
128
|
+
<!-- TOOLKIT:rules-typescript END -->
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Re-running `install --local` is idempotent — existing blocks are replaced, not duplicated.
|
|
132
|
+
|
|
133
|
+
## Manifest Module Names
|
|
134
|
+
|
|
135
|
+
Language rules are tracked as modules in `manifest.json`:
|
|
136
|
+
|
|
137
|
+
| Module | Description |
|
|
138
|
+
|--------|-------------|
|
|
139
|
+
| `rules-common` | Common coding rules (5 files), included in `standard` profile |
|
|
140
|
+
| `rules-typescript` | TypeScript-specific rules |
|
|
141
|
+
| `rules-python` | Python-specific rules |
|
|
142
|
+
| `rules-golang` | Go-specific rules |
|
|
143
|
+
| `rules-rust` | Rust-specific rules |
|
|
144
|
+
| `rules-java` | Java-specific rules |
|
|
145
|
+
| `rules-kotlin` | Kotlin-specific rules |
|
|
146
|
+
| `rules-swift` | Swift-specific rules |
|
|
147
|
+
| `rules-dart` | Dart/Flutter-specific rules |
|
|
148
|
+
| `rules-csharp` | C#/.NET-specific rules |
|
|
149
|
+
| `rules-php` | PHP-specific rules |
|
|
150
|
+
| `rules-cpp` | C++-specific rules |
|
|
151
|
+
| `rules-ruby` | Ruby-specific rules |
|
|
152
|
+
|
|
153
|
+
## Rules vs Skills
|
|
154
|
+
|
|
155
|
+
| | Rules | Skills |
|
|
156
|
+
|---|-------|--------|
|
|
157
|
+
| Location | `app/rules/` | `app/skills/` |
|
|
158
|
+
| Delivery | Injected into `CLAUDE.md` text | Loaded from `~/.claude/skills/` |
|
|
159
|
+
| Visibility | Always visible in context | Loaded contextually by agents |
|
|
160
|
+
| Scope | Per-language static guidance | Domain-specific agent behavior |
|
|
161
|
+
| Install | `--local` only | Global install |
|
|
162
|
+
|
|
163
|
+
## Related Documentation
|
|
164
|
+
|
|
165
|
+
- [PATH: kb/reference/manifest-install.md] — module-level install granularity
|
|
166
|
+
- [PATH: kb/reference/extension-api.md] — injecting rules from external tools
|
|
167
|
+
- [PATH: kb/reference/architecture-overview.md] — overall install model
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Manifest-Driven Install System"
|
|
3
|
+
category: reference
|
|
4
|
+
service: ai-toolkit
|
|
5
|
+
tags: [install, manifest, modules, profiles, auto-detect, state-tracking]
|
|
6
|
+
version: "1.0.0"
|
|
7
|
+
created: "2026-04-07"
|
|
8
|
+
last_updated: "2026-04-07"
|
|
9
|
+
description: "Reference for the manifest-driven install system: 17 modules, 4 profiles, auto-detection, and state tracking in ~/.ai-toolkit/state.json."
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Manifest-Driven Install System
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
ai-toolkit's install system supports module-level granularity on top of the existing profile-based install. Instead of choosing only between minimal/standard/strict, you can select individual modules (specific language rules, MCP templates, etc.) or enable auto-detection of the project language.
|
|
17
|
+
|
|
18
|
+
All existing `--profile` behavior is preserved and unchanged. The manifest system is an additive opt-in layer.
|
|
19
|
+
|
|
20
|
+
## Modules
|
|
21
|
+
|
|
22
|
+
Modules are defined in `manifest.json` at the repository root. There are 17 modules:
|
|
23
|
+
|
|
24
|
+
| Module | Description | In Profile |
|
|
25
|
+
|--------|-------------|-----------|
|
|
26
|
+
| `core` | Core hooks and essential skills | minimal, standard, strict, full |
|
|
27
|
+
| `agents` | 47 specialized agents | standard, strict, full |
|
|
28
|
+
| `skills` | 90 skills (task, hybrid, knowledge) | standard, strict, full |
|
|
29
|
+
| `rules-common` | Common coding rules (5 files) | standard, strict, full |
|
|
30
|
+
| `rules-typescript` | TypeScript-specific rules (5 files) | auto-detect |
|
|
31
|
+
| `rules-python` | Python-specific rules (5 files) | auto-detect |
|
|
32
|
+
| `rules-golang` | Go-specific rules (5 files) | auto-detect |
|
|
33
|
+
| `rules-rust` | Rust-specific rules (5 files) | auto-detect |
|
|
34
|
+
| `rules-java` | Java-specific rules (5 files) | auto-detect |
|
|
35
|
+
| `rules-kotlin` | Kotlin-specific rules (5 files) | auto-detect |
|
|
36
|
+
| `rules-swift` | Swift-specific rules (5 files) | auto-detect |
|
|
37
|
+
| `rules-dart` | Dart/Flutter-specific rules (5 files) | auto-detect |
|
|
38
|
+
| `rules-csharp` | C#/.NET-specific rules (5 files) | auto-detect |
|
|
39
|
+
| `rules-php` | PHP-specific rules (5 files) | auto-detect |
|
|
40
|
+
| `rules-cpp` | C++-specific rules (5 files) | auto-detect |
|
|
41
|
+
| `rules-ruby` | Ruby-specific rules (5 files) | auto-detect |
|
|
42
|
+
| `mcp-templates` | 25 MCP server config templates | strict, full |
|
|
43
|
+
|
|
44
|
+
## Profiles
|
|
45
|
+
|
|
46
|
+
Profiles are predefined module sets. They map directly to `--profile` values:
|
|
47
|
+
|
|
48
|
+
| Profile | Modules |
|
|
49
|
+
|---------|---------|
|
|
50
|
+
| `minimal` | `core` |
|
|
51
|
+
| `standard` | `core`, `agents`, `skills`, `rules-common` |
|
|
52
|
+
| `strict` | `core`, `agents`, `skills`, `rules-common`, `mcp-templates` |
|
|
53
|
+
| `full` | All modules (same as strict currently; language rules added via `--auto-detect`) |
|
|
54
|
+
|
|
55
|
+
## CLI
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Profile-based install (existing behavior, unchanged)
|
|
59
|
+
ai-toolkit install --profile standard
|
|
60
|
+
|
|
61
|
+
# Module-based install (new)
|
|
62
|
+
ai-toolkit install --modules core,agents,rules-typescript
|
|
63
|
+
|
|
64
|
+
# Auto-detect project language and install matching rules
|
|
65
|
+
ai-toolkit install --local --auto-detect
|
|
66
|
+
|
|
67
|
+
# Show currently installed modules and their state
|
|
68
|
+
ai-toolkit status
|
|
69
|
+
|
|
70
|
+
# Incremental update (only re-applies modules with changed content)
|
|
71
|
+
ai-toolkit update
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### --modules
|
|
75
|
+
|
|
76
|
+
Accepts a comma-separated list of module names. Can be combined with a profile:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Start from standard profile, also add TypeScript rules
|
|
80
|
+
ai-toolkit install --profile standard --modules rules-typescript
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### --auto-detect
|
|
84
|
+
|
|
85
|
+
Scans the current working directory for marker files and selects the matching language module. Implemented in `scripts/install_steps/detect_language.py`.
|
|
86
|
+
|
|
87
|
+
Detection markers per module:
|
|
88
|
+
|
|
89
|
+
| Module | Detected when these files exist |
|
|
90
|
+
|--------|--------------------------------|
|
|
91
|
+
| `rules-typescript` | `package.json` or `tsconfig.json` |
|
|
92
|
+
| `rules-python` | `requirements.txt`, `pyproject.toml`, `setup.py`, or `Pipfile` |
|
|
93
|
+
| `rules-golang` | `go.mod` |
|
|
94
|
+
| `rules-rust` | `Cargo.toml` |
|
|
95
|
+
| `rules-java` | `pom.xml` or `build.gradle` |
|
|
96
|
+
| `rules-kotlin` | `build.gradle.kts` |
|
|
97
|
+
| `rules-swift` | `Package.swift` |
|
|
98
|
+
| `rules-dart` | `pubspec.yaml` |
|
|
99
|
+
| `rules-csharp` | `*.csproj` or `*.sln` |
|
|
100
|
+
| `rules-php` | `composer.json` |
|
|
101
|
+
| `rules-cpp` | `CMakeLists.txt` or `Makefile` |
|
|
102
|
+
| `rules-ruby` | `Gemfile` |
|
|
103
|
+
|
|
104
|
+
### status
|
|
105
|
+
|
|
106
|
+
Lists all currently installed modules with version and install timestamp:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
ai-toolkit status
|
|
110
|
+
# Installed modules (from ~/.ai-toolkit/state.json):
|
|
111
|
+
# core v1.3.0 installed 2026-04-07T10:00:00Z
|
|
112
|
+
# agents v1.3.0 installed 2026-04-07T10:00:00Z
|
|
113
|
+
# skills v1.3.0 installed 2026-04-07T10:00:00Z
|
|
114
|
+
# rules-common v1.3.0 installed 2026-04-07T10:00:00Z
|
|
115
|
+
# rules-typescript v1.3.0 installed 2026-04-07T10:00:00Z
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### update
|
|
119
|
+
|
|
120
|
+
Re-applies installed modules, skipping files whose content hash has not changed since last install. Implemented in `scripts/install_steps/install_state.py`.
|
|
121
|
+
|
|
122
|
+
## State Tracking
|
|
123
|
+
|
|
124
|
+
Installed module state is persisted to `~/.ai-toolkit/state.json`:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"installed_version": "1.3.0",
|
|
129
|
+
"installed_modules": ["core", "agents", "skills", "rules-common", "rules-typescript"],
|
|
130
|
+
"installed_at": "2026-04-07T10:00:00Z",
|
|
131
|
+
"last_updated": "2026-04-07T10:00:00Z",
|
|
132
|
+
"file_hashes": {
|
|
133
|
+
"app/hooks/session-start.sh": "abc123..."
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- `installed_modules` — used by `update` to know which modules to re-apply
|
|
139
|
+
- `file_hashes` — used to skip unchanged files during `update`
|
|
140
|
+
- The file is written after every successful install or update
|
|
141
|
+
|
|
142
|
+
## Implementation Files
|
|
143
|
+
|
|
144
|
+
| File | Purpose |
|
|
145
|
+
|------|---------|
|
|
146
|
+
| `manifest.json` | Module and profile definitions |
|
|
147
|
+
| `scripts/install_steps/detect_language.py` | Auto-detect project language from marker files |
|
|
148
|
+
| `scripts/install_steps/install_state.py` | Read/write `~/.ai-toolkit/state.json` |
|
|
149
|
+
|
|
150
|
+
## Backward Compatibility
|
|
151
|
+
|
|
152
|
+
Existing `--profile` usage works identically. The manifest system does not change what gets installed when you use `--profile minimal/standard/strict`. It only adds:
|
|
153
|
+
|
|
154
|
+
1. `--modules` for granular selection
|
|
155
|
+
2. `--auto-detect` for language rules
|
|
156
|
+
3. `state.json` tracking for incremental updates
|
|
157
|
+
4. `status` command to inspect installed state
|
|
158
|
+
|
|
159
|
+
No existing install scripts or CI configurations need changes.
|
|
160
|
+
|
|
161
|
+
## Related Documentation
|
|
162
|
+
|
|
163
|
+
- [PATH: kb/reference/language-rules.md] — language rules structure and auto-detection detail
|
|
164
|
+
- [PATH: kb/reference/mcp-templates.md] — MCP server templates (the `mcp-templates` module)
|
|
165
|
+
- [PATH: kb/reference/architecture-overview.md] — overall install model
|