specialist-agent 2.13.0 → 3.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/LICENSE +1 -1
- package/README.md +36 -206
- package/dist/catalog.json +16677 -0
- package/dist/hw-worker.mjs +288 -0
- package/dist/icones/icone.ico +0 -0
- package/dist/icones/icone.png +0 -0
- package/dist/interface/assets/figtree-latin-400-normal-g7Dtegnw.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-500-normal-BWnGEVsr.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-600-normal-Cv_xCTDl.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-700-normal-th6qEP7c.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-400-normal-CXAzuTZb.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-500-normal-Du0rIuHj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-600-normal-DJlfifZj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-700-normal-CS4sQkGV.woff2 +0 -0
- package/dist/interface/assets/index-BltVv7tb.js +24 -0
- package/dist/interface/assets/index-Cpa6kApK.css +1 -0
- package/dist/interface/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-500-normal-4slEIF53.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-700-normal-CaoNriVp.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-500-normal-BTIpesyw.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-700-normal-BLzWLLjG.woff2 +0 -0
- package/dist/interface/icones/apple-touch-icon.png +0 -0
- package/dist/interface/icones/favicon-32.png +0 -0
- package/dist/interface/icones/icone-192.png +0 -0
- package/dist/interface/icones/icone-512.png +0 -0
- package/dist/interface/icones/icone-mascara-512.png +0 -0
- package/dist/interface/index.html +19 -0
- package/dist/interface/manifest.webmanifest +19 -0
- package/dist/interface/sw.js +64 -0
- package/dist/licencas/BRAND.md +22 -0
- package/dist/licencas/LICENSE-CONTENT.md +44 -0
- package/dist/licencas/OFL-Figtree.txt +93 -0
- package/dist/licencas/OFL-JetBrainsMono.txt +93 -0
- package/dist/licencas/OFL-Unbounded.txt +93 -0
- package/dist/licencas/TERCEIROS.txt +104 -0
- package/dist/specialist-agent.mjs +14515 -0
- package/dist/usage-worker.mjs +1077 -0
- package/package.json +34 -58
- package/.claude-plugin/marketplace.json +0 -52
- package/.claude-plugin/plugin.json +0 -37
- package/.codex/INSTALL.md +0 -145
- package/.cursor-plugin/marketplace.json +0 -52
- package/.cursor-plugin/plugin.json +0 -37
- package/.opencode/INSTALL.md +0 -127
- package/.opencode/opencode.json +0 -186
- package/agents/analyst-lite.md +0 -48
- package/agents/analyst.md +0 -396
- package/agents/api-lite.md +0 -43
- package/agents/api.md +0 -427
- package/agents/architect-lite.md +0 -104
- package/agents/architect.md +0 -571
- package/agents/autopilot-lite.md +0 -46
- package/agents/autopilot.md +0 -196
- package/agents/cloud-lite.md +0 -75
- package/agents/cloud.md +0 -213
- package/agents/data-lite.md +0 -67
- package/agents/data.md +0 -306
- package/agents/debugger-lite.md +0 -46
- package/agents/debugger.md +0 -410
- package/agents/deps-lite.md +0 -41
- package/agents/deps.md +0 -363
- package/agents/designer-lite.md +0 -67
- package/agents/designer.md +0 -195
- package/agents/devops-lite.md +0 -67
- package/agents/devops.md +0 -205
- package/agents/docs-lite.md +0 -42
- package/agents/docs.md +0 -454
- package/agents/executor-lite.md +0 -61
- package/agents/executor.md +0 -695
- package/agents/explorer-lite.md +0 -55
- package/agents/explorer.md +0 -152
- package/agents/finance-lite.md +0 -66
- package/agents/finance.md +0 -255
- package/agents/i18n-lite.md +0 -44
- package/agents/i18n.md +0 -594
- package/agents/legal-lite.md +0 -113
- package/agents/legal.md +0 -302
- package/agents/marketing-lite.md +0 -25
- package/agents/marketing.md +0 -188
- package/agents/memory.md +0 -166
- package/agents/orchestrator-lite.md +0 -40
- package/agents/orchestrator.md +0 -512
- package/agents/pair-lite.md +0 -38
- package/agents/pair.md +0 -310
- package/agents/perf-lite.md +0 -42
- package/agents/perf.md +0 -320
- package/agents/planner-lite.md +0 -59
- package/agents/planner.md +0 -272
- package/agents/product-lite.md +0 -25
- package/agents/product.md +0 -195
- package/agents/refactor-lite.md +0 -42
- package/agents/refactor.md +0 -467
- package/agents/ripple-lite.md +0 -106
- package/agents/ripple.md +0 -166
- package/agents/scout-lite.md +0 -37
- package/agents/scout.md +0 -224
- package/agents/security-lite.md +0 -66
- package/agents/security.md +0 -252
- package/agents/sentry-triage-lite.md +0 -54
- package/agents/sentry-triage.md +0 -217
- package/agents/starter-lite.md +0 -80
- package/agents/starter.md +0 -300
- package/agents/support-lite.md +0 -24
- package/agents/support.md +0 -191
- package/agents/tdd-lite.md +0 -43
- package/agents/tdd.md +0 -329
- package/agents/tester-lite.md +0 -71
- package/agents/tester.md +0 -237
- package/cli/architectures.mjs +0 -713
- package/cli/detect-architecture.mjs +0 -752
- package/cli/generate-architecture.mjs +0 -1096
- package/cli/index.mjs +0 -1217
- package/cli/recommend-architecture.mjs +0 -870
- package/hooks/after-review.mjs +0 -130
- package/hooks/after-task.mjs +0 -117
- package/hooks/before-plan.mjs +0 -155
- package/hooks/before-review.mjs +0 -139
- package/hooks/hooks.json +0 -66
- package/hooks/lifecycle.json +0 -91
- package/hooks/native/auto-dispatch.mjs +0 -207
- package/hooks/native/auto-format.mjs +0 -176
- package/hooks/native/mcp-discovery.mjs +0 -168
- package/hooks/native/security-config.json +0 -38
- package/hooks/native/security-guard.mjs +0 -323
- package/hooks/native/session-context.mjs +0 -179
- package/hooks/native/session-end.mjs +0 -42
- package/hooks/native/utils.mjs +0 -62
- package/hooks/on-error.mjs +0 -129
- package/hooks/session-end.mjs +0 -185
- package/hooks/session-start.mjs +0 -154
- package/packs/angular/ARCHITECTURE.md +0 -814
- package/packs/angular/CLAUDE.md +0 -105
- package/packs/angular/agents/builder.md +0 -113
- package/packs/angular/agents/doctor.md +0 -187
- package/packs/angular/agents/migrator.md +0 -101
- package/packs/angular/agents/reviewer.md +0 -252
- package/packs/angular/agents-lite/builder.md +0 -65
- package/packs/angular/agents-lite/doctor.md +0 -64
- package/packs/angular/agents-lite/migrator.md +0 -75
- package/packs/angular/agents-lite/reviewer.md +0 -69
- package/packs/angular/skills/dev-create-component/SKILL.md +0 -56
- package/packs/angular/skills/dev-create-injectable/SKILL.md +0 -60
- package/packs/angular/skills/dev-create-module/SKILL.md +0 -49
- package/packs/angular/skills/dev-create-service/SKILL.md +0 -34
- package/packs/angular/skills/dev-create-test/SKILL.md +0 -78
- package/packs/angular/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/angular/skills/docs-onboard/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-component/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/angular/skills/review-check-architecture/SKILL.md +0 -67
- package/packs/angular/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/angular/skills/review-review/SKILL.md +0 -43
- package/packs/astro/ARCHITECTURE.md +0 -718
- package/packs/astro/CLAUDE.md +0 -106
- package/packs/astro/agents/builder.md +0 -123
- package/packs/astro/agents/doctor.md +0 -200
- package/packs/astro/agents/migrator.md +0 -105
- package/packs/astro/agents/reviewer.md +0 -253
- package/packs/astro/agents-lite/builder.md +0 -71
- package/packs/astro/agents-lite/doctor.md +0 -66
- package/packs/astro/agents-lite/migrator.md +0 -71
- package/packs/astro/agents-lite/reviewer.md +0 -70
- package/packs/astro/skills/dev-create-component/SKILL.md +0 -50
- package/packs/astro/skills/dev-create-island/SKILL.md +0 -63
- package/packs/astro/skills/dev-create-module/SKILL.md +0 -49
- package/packs/astro/skills/dev-create-service/SKILL.md +0 -34
- package/packs/astro/skills/dev-create-test/SKILL.md +0 -76
- package/packs/astro/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/astro/skills/docs-onboard/SKILL.md +0 -51
- package/packs/astro/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/astro/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/astro/skills/review-check-architecture/SKILL.md +0 -72
- package/packs/astro/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/astro/skills/review-review/SKILL.md +0 -45
- package/packs/nextjs/ARCHITECTURE.md +0 -1033
- package/packs/nextjs/CLAUDE.md +0 -106
- package/packs/nextjs/agents/builder.md +0 -132
- package/packs/nextjs/agents/doctor.md +0 -226
- package/packs/nextjs/agents/migrator.md +0 -101
- package/packs/nextjs/agents/reviewer.md +0 -243
- package/packs/nextjs/agents-lite/builder.md +0 -74
- package/packs/nextjs/agents-lite/doctor.md +0 -74
- package/packs/nextjs/agents-lite/migrator.md +0 -75
- package/packs/nextjs/agents-lite/reviewer.md +0 -73
- package/packs/nextjs/skills/dev-create-component/SKILL.md +0 -82
- package/packs/nextjs/skills/dev-create-hook/SKILL.md +0 -90
- package/packs/nextjs/skills/dev-create-module/SKILL.md +0 -63
- package/packs/nextjs/skills/dev-create-service/SKILL.md +0 -35
- package/packs/nextjs/skills/dev-create-test/SKILL.md +0 -106
- package/packs/nextjs/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nextjs/skills/docs-onboard/SKILL.md +0 -55
- package/packs/nextjs/skills/migration-migrate-component/SKILL.md +0 -58
- package/packs/nextjs/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nextjs/skills/review-check-architecture/SKILL.md +0 -101
- package/packs/nextjs/skills/review-fix-violations/SKILL.md +0 -48
- package/packs/nextjs/skills/review-review/SKILL.md +0 -47
- package/packs/nuxt/ARCHITECTURE.md +0 -831
- package/packs/nuxt/CLAUDE.md +0 -111
- package/packs/nuxt/agents/builder.md +0 -120
- package/packs/nuxt/agents/doctor.md +0 -198
- package/packs/nuxt/agents/migrator.md +0 -101
- package/packs/nuxt/agents/reviewer.md +0 -255
- package/packs/nuxt/agents-lite/builder.md +0 -67
- package/packs/nuxt/agents-lite/doctor.md +0 -67
- package/packs/nuxt/agents-lite/migrator.md +0 -80
- package/packs/nuxt/agents-lite/reviewer.md +0 -71
- package/packs/nuxt/skills/dev-create-component/SKILL.md +0 -60
- package/packs/nuxt/skills/dev-create-composable/SKILL.md +0 -33
- package/packs/nuxt/skills/dev-create-module/SKILL.md +0 -49
- package/packs/nuxt/skills/dev-create-service/SKILL.md +0 -34
- package/packs/nuxt/skills/dev-create-test/SKILL.md +0 -61
- package/packs/nuxt/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nuxt/skills/docs-onboard/SKILL.md +0 -49
- package/packs/nuxt/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/nuxt/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nuxt/skills/review-check-architecture/SKILL.md +0 -71
- package/packs/nuxt/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/nuxt/skills/review-review/SKILL.md +0 -45
- package/packs/react/ARCHITECTURE.md +0 -991
- package/packs/react/CLAUDE.md +0 -102
- package/packs/react/agents/builder.md +0 -113
- package/packs/react/agents/doctor.md +0 -203
- package/packs/react/agents/migrator.md +0 -101
- package/packs/react/agents/reviewer.md +0 -252
- package/packs/react/agents-lite/builder.md +0 -65
- package/packs/react/agents-lite/doctor.md +0 -64
- package/packs/react/agents-lite/migrator.md +0 -74
- package/packs/react/agents-lite/reviewer.md +0 -69
- package/packs/react/skills/dev-create-component/SKILL.md +0 -53
- package/packs/react/skills/dev-create-hook/SKILL.md +0 -78
- package/packs/react/skills/dev-create-module/SKILL.md +0 -51
- package/packs/react/skills/dev-create-service/SKILL.md +0 -34
- package/packs/react/skills/dev-create-test/SKILL.md +0 -92
- package/packs/react/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/react/skills/docs-onboard/SKILL.md +0 -42
- package/packs/react/skills/migration-migrate-component/SKILL.md +0 -44
- package/packs/react/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/react/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/react/skills/review-fix-violations/SKILL.md +0 -45
- package/packs/react/skills/review-review/SKILL.md +0 -44
- package/packs/svelte/ARCHITECTURE.md +0 -975
- package/packs/svelte/CLAUDE.md +0 -102
- package/packs/svelte/agents/builder.md +0 -114
- package/packs/svelte/agents/doctor.md +0 -174
- package/packs/svelte/agents/migrator.md +0 -101
- package/packs/svelte/agents/reviewer.md +0 -238
- package/packs/svelte/agents-lite/builder.md +0 -66
- package/packs/svelte/agents-lite/doctor.md +0 -67
- package/packs/svelte/agents-lite/migrator.md +0 -82
- package/packs/svelte/agents-lite/reviewer.md +0 -70
- package/packs/svelte/skills/dev-create-component/SKILL.md +0 -77
- package/packs/svelte/skills/dev-create-module/SKILL.md +0 -59
- package/packs/svelte/skills/dev-create-service/SKILL.md +0 -35
- package/packs/svelte/skills/dev-create-store/SKILL.md +0 -94
- package/packs/svelte/skills/dev-create-test/SKILL.md +0 -98
- package/packs/svelte/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/svelte/skills/docs-onboard/SKILL.md +0 -47
- package/packs/svelte/skills/migration-migrate-component/SKILL.md +0 -51
- package/packs/svelte/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/svelte/skills/review-check-architecture/SKILL.md +0 -79
- package/packs/svelte/skills/review-fix-violations/SKILL.md +0 -47
- package/packs/svelte/skills/review-review/SKILL.md +0 -45
- package/packs/vue/ARCHITECTURE.md +0 -798
- package/packs/vue/CLAUDE.md +0 -102
- package/packs/vue/agents/builder.md +0 -112
- package/packs/vue/agents/doctor.md +0 -185
- package/packs/vue/agents/migrator.md +0 -101
- package/packs/vue/agents/reviewer.md +0 -249
- package/packs/vue/agents-lite/builder.md +0 -65
- package/packs/vue/agents-lite/doctor.md +0 -63
- package/packs/vue/agents-lite/migrator.md +0 -73
- package/packs/vue/agents-lite/reviewer.md +0 -68
- package/packs/vue/skills/dev-create-component/SKILL.md +0 -58
- package/packs/vue/skills/dev-create-composable/SKILL.md +0 -31
- package/packs/vue/skills/dev-create-module/SKILL.md +0 -50
- package/packs/vue/skills/dev-create-service/SKILL.md +0 -34
- package/packs/vue/skills/dev-create-test/SKILL.md +0 -62
- package/packs/vue/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/vue/skills/docs-onboard/SKILL.md +0 -42
- package/packs/vue/skills/migration-migrate-component/SKILL.md +0 -41
- package/packs/vue/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/vue/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/vue/skills/review-fix-violations/SKILL.md +0 -42
- package/packs/vue/skills/review-review/SKILL.md +0 -43
- package/skills/audit/SKILL.md +0 -231
- package/skills/autofix/SKILL.md +0 -166
- package/skills/autopilot/SKILL.md +0 -286
- package/skills/brainstorm/SKILL.md +0 -298
- package/skills/checkpoint/SKILL.md +0 -217
- package/skills/codereview/SKILL.md +0 -268
- package/skills/commit/SKILL.md +0 -150
- package/skills/copywriting/SKILL.md +0 -218
- package/skills/cro/SKILL.md +0 -234
- package/skills/debug/SKILL.md +0 -210
- package/skills/design-review/SKILL.md +0 -217
- package/skills/discovery/SKILL.md +0 -218
- package/skills/estimate/SKILL.md +0 -154
- package/skills/finish/SKILL.md +0 -220
- package/skills/grill/SKILL.md +0 -270
- package/skills/health/SKILL.md +0 -251
- package/skills/improve-architecture/SKILL.md +0 -205
- package/skills/learn/SKILL.md +0 -260
- package/skills/lint/SKILL.md +0 -126
- package/skills/migrate-architecture/SKILL.md +0 -242
- package/skills/migrate-framework/SKILL.md +0 -172
- package/skills/onboard/SKILL.md +0 -168
- package/skills/plan/SKILL.md +0 -141
- package/skills/prd/SKILL.md +0 -241
- package/skills/recall/SKILL.md +0 -112
- package/skills/remember/SKILL.md +0 -108
- package/skills/seo-audit/SKILL.md +0 -240
- package/skills/tdd/SKILL.md +0 -201
- package/skills/tutorial/SKILL.md +0 -346
- package/skills/verify/SKILL.md +0 -168
- package/skills/worktree/SKILL.md +0 -168
- package/skills/write-skill/SKILL.md +0 -225
- package/templates/autopilot/PROMPT.md +0 -39
- package/templates/autopilot/README.md +0 -122
- package/templates/autopilot/devcontainer.json +0 -21
- package/templates/industry/ecommerce.md +0 -127
- package/templates/industry/fintech.md +0 -161
- package/templates/industry/saas.md +0 -134
- package/templates/session-memory.json +0 -48
- package/templates/skill-template/SKILL.md +0 -90
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Security Guard - PreToolUse Hook (Bash)
|
|
5
|
-
*
|
|
6
|
-
* Blocks dangerous shell commands BEFORE they execute.
|
|
7
|
-
* Design: fail-closed (if this script crashes, exit 2 = block).
|
|
8
|
-
*
|
|
9
|
-
* Claude Code event: PreToolUse (matcher: "Bash")
|
|
10
|
-
* Stdin: { tool_input: { command: "..." } }
|
|
11
|
-
* Block: exit 2 + stderr reason
|
|
12
|
-
* Allow: exit 0 (silent)
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { dirname, resolve } from 'path';
|
|
16
|
-
import { fileURLToPath } from 'url';
|
|
17
|
-
import { readStdin, readJsonFile } from './utils.mjs';
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
const __dirname = dirname(__filename);
|
|
21
|
-
|
|
22
|
-
// ── Security Rules ──────────────────────────────────────────
|
|
23
|
-
|
|
24
|
-
const RULES = [
|
|
25
|
-
// CRITICAL - always block, no exceptions
|
|
26
|
-
{
|
|
27
|
-
id: 'catastrophic-rm',
|
|
28
|
-
severity: 'CRITICAL',
|
|
29
|
-
test: (cmd) => {
|
|
30
|
-
const normalized = cmd.replace(/\s+/g, ' ').trim();
|
|
31
|
-
// Match rm with -r and -f flags targeting / or ~ or bare .
|
|
32
|
-
if (!/\brm\b/.test(normalized)) return false;
|
|
33
|
-
if (!/-[a-zA-Z]*r/.test(normalized) && !/-[a-zA-Z]*R/.test(normalized)) return false;
|
|
34
|
-
// Check target paths
|
|
35
|
-
const dangerousTargets = [
|
|
36
|
-
/\s\/\s*$/, /\s\/[^a-zA-Z]/, // rm -rf /
|
|
37
|
-
/\s~\s*$/, /\s~\//, // rm -rf ~ or ~/...
|
|
38
|
-
/\s\.\s*$/, /\s\.\//, // rm -rf . or ./...
|
|
39
|
-
/\s\.\.\s*$/, /\s\.\.\//, // rm -rf .. or ../...
|
|
40
|
-
];
|
|
41
|
-
for (const pattern of dangerousTargets) {
|
|
42
|
-
if (pattern.test(' ' + normalized)) {
|
|
43
|
-
// Check allowlist - safe directories are OK
|
|
44
|
-
const safeTargets = [
|
|
45
|
-
/node_modules/, /dist[\/\\]?/, /build[\/\\]?/, /\.next[\/\\]?/,
|
|
46
|
-
/\.nuxt[\/\\]?/, /\.svelte-kit[\/\\]?/, /coverage[\/\\]?/,
|
|
47
|
-
/\.turbo[\/\\]?/, /\.cache[\/\\]?/, /__pycache__[\/\\]?/,
|
|
48
|
-
];
|
|
49
|
-
if (safeTargets.some(safe => safe.test(normalized))) return false;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
},
|
|
55
|
-
message: 'BLOCKED [CRITICAL]: Recursive delete of system/home/project root detected.\nThis command could destroy your entire filesystem.\nIf you need to clean a specific directory, target it explicitly (e.g., rm -rf dist/).'
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: 'fork-bomb',
|
|
59
|
-
severity: 'CRITICAL',
|
|
60
|
-
test: (cmd) => /:\(\)\s*\{.*\|.*&\s*\}\s*;?\s*:/.test(cmd) || /\.\/bomb/.test(cmd),
|
|
61
|
-
message: 'BLOCKED [CRITICAL]: Fork bomb detected. This would crash the system by spawning infinite processes.'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
id: 'disk-wipe',
|
|
65
|
-
severity: 'CRITICAL',
|
|
66
|
-
test: (cmd) => {
|
|
67
|
-
return /\bmkfs\b/.test(cmd) ||
|
|
68
|
-
/\bdd\b.*\bif=.*\/dev\//.test(cmd) && /\bof=.*\/dev\//.test(cmd) ||
|
|
69
|
-
/>\s*\/dev\/[hs]d[a-z]/.test(cmd);
|
|
70
|
-
},
|
|
71
|
-
message: 'BLOCKED [CRITICAL]: Disk wipe command detected. This would destroy disk data irreversibly.'
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// HIGH - block with descriptive message
|
|
75
|
-
{
|
|
76
|
-
id: 'force-push-protected',
|
|
77
|
-
severity: 'HIGH',
|
|
78
|
-
test: (cmd, config) => {
|
|
79
|
-
if (!/\bgit\s+push\b/.test(cmd)) return false;
|
|
80
|
-
if (!/(-f\b|--force\b)/.test(cmd)) return false;
|
|
81
|
-
// force-with-lease is safer, allow it
|
|
82
|
-
if (/--force-with-lease/.test(cmd)) return false;
|
|
83
|
-
// Check if targeting a protected branch
|
|
84
|
-
const branches = config?.protectedBranches || ['main', 'master', 'production', 'release'];
|
|
85
|
-
return branches.some(branch => new RegExp(`\\b${branch}\\b`).test(cmd));
|
|
86
|
-
},
|
|
87
|
-
message: 'BLOCKED [HIGH]: Force push to protected branch.\nUse a feature branch and create a PR instead.\nIf you need to force push, use --force-with-lease for safety, or target a feature branch.'
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
id: 'hard-reset',
|
|
91
|
-
severity: 'HIGH',
|
|
92
|
-
test: (cmd) => {
|
|
93
|
-
if (!/\bgit\s+reset\b/.test(cmd)) return false;
|
|
94
|
-
if (/--hard/.test(cmd)) return true;
|
|
95
|
-
return false;
|
|
96
|
-
},
|
|
97
|
-
message: 'BLOCKED [HIGH]: git reset --hard discards all uncommitted changes permanently.\nConsider using: git stash (to save changes), git reset --soft (to unstage), or git checkout -- <file> (for specific files).'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: 'sql-destructive',
|
|
101
|
-
severity: 'HIGH',
|
|
102
|
-
test: (cmd) => {
|
|
103
|
-
const upper = cmd.toUpperCase();
|
|
104
|
-
return /\bDROP\s+(TABLE|DATABASE|SCHEMA)\b/.test(upper) ||
|
|
105
|
-
/\bTRUNCATE\s+TABLE\b/.test(upper) ||
|
|
106
|
-
/\bDELETE\s+FROM\s+\w+\s*;?\s*$/.test(upper); // DELETE without WHERE
|
|
107
|
-
},
|
|
108
|
-
message: 'BLOCKED [HIGH]: Destructive SQL command detected.\nDROP/TRUNCATE/DELETE-without-WHERE can cause irreversible data loss.\nUse a transaction, add a WHERE clause, or test on a staging database first.'
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
id: 'pipe-to-shell',
|
|
112
|
-
severity: 'HIGH',
|
|
113
|
-
test: (cmd) => {
|
|
114
|
-
return /\bcurl\b.*\|\s*(bash|sh|zsh)\b/.test(cmd) ||
|
|
115
|
-
/\bwget\b.*\|\s*(bash|sh|zsh)\b/.test(cmd) ||
|
|
116
|
-
/\bcurl\b.*-[a-zA-Z]*o\s*-\s*\|/.test(cmd);
|
|
117
|
-
},
|
|
118
|
-
message: 'BLOCKED [HIGH]: Pipe-to-shell pattern detected (curl/wget | bash).\nThis downloads and executes remote code without inspection.\nDownload the script first, review it, then execute: curl -o script.sh <url> && cat script.sh && bash script.sh'
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
id: 'chmod-777',
|
|
122
|
-
severity: 'HIGH',
|
|
123
|
-
test: (cmd) => /\bchmod\b.*\b777\b/.test(cmd),
|
|
124
|
-
message: 'BLOCKED [HIGH]: chmod 777 makes files world-readable/writable/executable.\nUse specific permissions instead: chmod 755 (directories), chmod 644 (files), chmod 600 (secrets).'
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
id: 'git-branch-force-delete',
|
|
128
|
-
severity: 'HIGH',
|
|
129
|
-
test: (cmd) => {
|
|
130
|
-
if (!/\bgit\s+branch\b/.test(cmd)) return false;
|
|
131
|
-
return /-D\b/.test(cmd);
|
|
132
|
-
},
|
|
133
|
-
message: 'BLOCKED [HIGH]: git branch -D force-deletes a branch even if not fully merged.\nUse git branch -d (lowercase) for safe deletion — it warns if the branch has unmerged changes.'
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: 'npm-publish-no-dry-run',
|
|
137
|
-
severity: 'HIGH',
|
|
138
|
-
test: (cmd) => {
|
|
139
|
-
if (!/\bnpm\s+publish\b/.test(cmd)) return false;
|
|
140
|
-
if (/--dry-run/.test(cmd)) return false;
|
|
141
|
-
return true;
|
|
142
|
-
},
|
|
143
|
-
message: 'BLOCKED [HIGH]: npm publish without --dry-run detected.\nPublishing to npm is irreversible (versions cannot be overwritten).\nRun with --dry-run first to verify, then publish manually in your terminal.'
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
id: 'docker-system-prune',
|
|
147
|
-
severity: 'HIGH',
|
|
148
|
-
test: (cmd) => /\bdocker\s+system\s+prune\b/.test(cmd) && /-a\b/.test(cmd),
|
|
149
|
-
message: 'BLOCKED [HIGH]: docker system prune -a removes ALL unused images, containers, networks, and volumes.\nUse targeted cleanup: docker image prune, docker container prune, or docker volume prune.'
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
id: 'kubectl-delete-namespace',
|
|
153
|
-
severity: 'HIGH',
|
|
154
|
-
test: (cmd) => /\bkubectl\s+delete\s+(namespace|ns)\b/.test(cmd),
|
|
155
|
-
message: 'BLOCKED [HIGH]: kubectl delete namespace destroys ALL resources within the namespace.\nThis is a cascading delete that removes deployments, services, pods, secrets, and more.\nVerify the namespace and run this command manually in your terminal.'
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
// MEDIUM - block access to sensitive files
|
|
159
|
-
{
|
|
160
|
-
id: 'env-file-read',
|
|
161
|
-
severity: 'MEDIUM',
|
|
162
|
-
test: (cmd) => {
|
|
163
|
-
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type)\b/;
|
|
164
|
-
// Block reading .env files (but allow .env.example, .env.sample, .env.template)
|
|
165
|
-
if (readCmds.test(cmd) && /\.env\b/.test(cmd)) {
|
|
166
|
-
if (/\.env\.(example|sample|template|test|development)/.test(cmd)) return false;
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
// Block reading private keys
|
|
170
|
-
if (readCmds.test(cmd) && /\.(pem|key|p12|pfx)\b/.test(cmd)) return true;
|
|
171
|
-
return false;
|
|
172
|
-
},
|
|
173
|
-
message: 'BLOCKED [MEDIUM]: Reading sensitive file (.env or private key) via shell.\nUse the Read tool instead, which provides better access control.\nAllowed: .env.example, .env.sample, .env.template'
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
id: 'ssh-key-access',
|
|
177
|
-
severity: 'MEDIUM',
|
|
178
|
-
test: (cmd) => {
|
|
179
|
-
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type|cp|scp)\b/;
|
|
180
|
-
if (!readCmds.test(cmd)) return false;
|
|
181
|
-
return /[~\/]\.ssh\/(id_|authorized_keys|known_hosts|config)/.test(cmd);
|
|
182
|
-
},
|
|
183
|
-
message: 'BLOCKED [MEDIUM]: Accessing SSH keys or config via shell.\nSSH keys are sensitive credentials that should never be read or copied by AI agents.\nIf you need to configure SSH, do it manually in your terminal.'
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
id: 'aws-credentials',
|
|
187
|
-
severity: 'MEDIUM',
|
|
188
|
-
test: (cmd) => {
|
|
189
|
-
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type|cp)\b/;
|
|
190
|
-
if (!readCmds.test(cmd)) return false;
|
|
191
|
-
return /[~\/]\.aws\/(credentials|config)/.test(cmd);
|
|
192
|
-
},
|
|
193
|
-
message: 'BLOCKED [MEDIUM]: Accessing AWS credentials via shell.\nAWS credentials contain secret access keys. Use environment variables ($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY) or IAM roles instead.'
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
id: 'cloud-credentials',
|
|
197
|
-
severity: 'MEDIUM',
|
|
198
|
-
test: (cmd) => {
|
|
199
|
-
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type|cp)\b/;
|
|
200
|
-
if (!readCmds.test(cmd)) return false;
|
|
201
|
-
return /application_default_credentials\.json/.test(cmd) ||
|
|
202
|
-
/service[_-]account[_-]?key.*\.json/.test(cmd) ||
|
|
203
|
-
/[~\/]\.azure\/(credentials|config|accessTokens)/.test(cmd) ||
|
|
204
|
-
/[~\/]\.kube\/config/.test(cmd) ||
|
|
205
|
-
/[~\/]\.docker\/config\.json/.test(cmd) ||
|
|
206
|
-
/[~\/]\.npmrc/.test(cmd) ||
|
|
207
|
-
/[~\/]\.netrc/.test(cmd) ||
|
|
208
|
-
/[~\/]\.pgpass/.test(cmd);
|
|
209
|
-
},
|
|
210
|
-
message: 'BLOCKED [MEDIUM]: Accessing cloud/service credentials via shell.\nThese files contain sensitive tokens and secrets. Use environment variables or secret managers instead.'
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
id: 'env-file-write',
|
|
214
|
-
severity: 'MEDIUM',
|
|
215
|
-
test: (cmd) => {
|
|
216
|
-
// Block writing to .env files
|
|
217
|
-
return />\s*\.env\b/.test(cmd) && !/\.env\.(example|sample|template)/.test(cmd);
|
|
218
|
-
},
|
|
219
|
-
message: 'BLOCKED [MEDIUM]: Writing to .env file via shell.\nManage secrets through environment variables or a secrets manager, not by writing them to files via commands.'
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
id: 'inline-secrets',
|
|
223
|
-
severity: 'MEDIUM',
|
|
224
|
-
test: (cmd) => {
|
|
225
|
-
// Block patterns like: export SECRET_KEY=actual_value, TOKEN=xxx command
|
|
226
|
-
const secretPatterns = [
|
|
227
|
-
/\b\w*(API_KEY|SECRET|TOKEN|PASSWORD|CREDENTIALS|PRIVATE_KEY)\w*\s*=\s*['"][^'"]{8,256}['"]/i,
|
|
228
|
-
/\bexport\s+\w*(API_KEY|SECRET|TOKEN|PASSWORD|CREDENTIALS|PRIVATE_KEY)\w*\s*=\s*\S{8,256}/i,
|
|
229
|
-
];
|
|
230
|
-
return secretPatterns.some(p => p.test(cmd));
|
|
231
|
-
},
|
|
232
|
-
message: 'BLOCKED [MEDIUM]: Inline secret detected in command.\nNever put secrets directly in shell commands. Use environment variables already set in the system:\n export MY_SECRET=... (in your shell profile)\n Then reference as $MY_SECRET in commands.'
|
|
233
|
-
},
|
|
234
|
-
];
|
|
235
|
-
|
|
236
|
-
// ── Core Evaluation Function (exported for testing) ─────────
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Evaluate a command against security rules.
|
|
240
|
-
* @param {string} command - The shell command to evaluate
|
|
241
|
-
* @param {object} config - Security config (from security-config.json)
|
|
242
|
-
* @returns {{ blocked: boolean, rule?: string, severity?: string, message?: string }}
|
|
243
|
-
*/
|
|
244
|
-
export function evaluateCommand(command, config = {}) {
|
|
245
|
-
if (!command || typeof command !== 'string') {
|
|
246
|
-
return { blocked: false };
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const enabledRules = config?.rules || {};
|
|
250
|
-
|
|
251
|
-
for (const rule of RULES) {
|
|
252
|
-
// Check if rule is disabled in config
|
|
253
|
-
if (enabledRules[rule.id]?.enabled === false) continue;
|
|
254
|
-
|
|
255
|
-
// Check allowlist — normalize whitespace and compare the full command
|
|
256
|
-
// to prevent bypass via chaining (e.g. "rm -rf dist; malicious")
|
|
257
|
-
const allowlist = config?.allowlist || [];
|
|
258
|
-
const normalizedCmd = command.replace(/\s+/g, ' ').trim();
|
|
259
|
-
const isAllowed = allowlist.some(pattern => {
|
|
260
|
-
const normalizedPattern = pattern.replace(/\s+/g, ' ').trim();
|
|
261
|
-
return normalizedCmd === normalizedPattern;
|
|
262
|
-
});
|
|
263
|
-
if (isAllowed) continue;
|
|
264
|
-
|
|
265
|
-
// Test the rule
|
|
266
|
-
if (rule.test(command, config)) {
|
|
267
|
-
return {
|
|
268
|
-
blocked: true,
|
|
269
|
-
rule: rule.id,
|
|
270
|
-
severity: rule.severity,
|
|
271
|
-
message: rule.message,
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return { blocked: false };
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// ── Main Execution ──────────────────────────────────────────
|
|
280
|
-
|
|
281
|
-
async function main() {
|
|
282
|
-
const input = await readStdin();
|
|
283
|
-
|
|
284
|
-
if (!input) {
|
|
285
|
-
// Fail-closed: if we can't parse input, block
|
|
286
|
-
process.stderr.write('Security Guard: Failed to parse input. Blocking as precaution.');
|
|
287
|
-
process.exit(2);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (!input?.tool_input?.command) {
|
|
291
|
-
// No command to evaluate - allow
|
|
292
|
-
process.exit(0);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const command = input.tool_input.command;
|
|
296
|
-
|
|
297
|
-
// Load config
|
|
298
|
-
const configPath = resolve(__dirname, 'security-config.json');
|
|
299
|
-
const config = readJsonFile(configPath) || {};
|
|
300
|
-
|
|
301
|
-
if (config.enabled === false) {
|
|
302
|
-
process.exit(0);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const result = evaluateCommand(command, config);
|
|
306
|
-
|
|
307
|
-
if (result.blocked) {
|
|
308
|
-
process.stderr.write(`\n🛡️ Security Guard\n${result.message}\n\nRule: ${result.rule} (${result.severity})\nTo customize: edit .claude/hooks/security-config.json\n`);
|
|
309
|
-
process.exit(2);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Allow - silent exit
|
|
313
|
-
process.exit(0);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Only run main when executed directly
|
|
317
|
-
if (process.argv[1] && resolve(process.argv[1]) === resolve(__filename)) {
|
|
318
|
-
main().catch(() => {
|
|
319
|
-
// Fail-closed: any unhandled error = block
|
|
320
|
-
process.stderr.write('Security Guard: Unexpected error. Blocking as precaution.');
|
|
321
|
-
process.exit(2);
|
|
322
|
-
});
|
|
323
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Session Context - SessionStart Hook
|
|
5
|
-
*
|
|
6
|
-
* Injects project state as context when a Claude Code session begins.
|
|
7
|
-
* All operations are read-only. Errors are silently ignored.
|
|
8
|
-
*
|
|
9
|
-
* Claude Code event: SessionStart
|
|
10
|
-
* Output: { "additionalContext": "Project state summary..." }
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { execSync } from 'child_process';
|
|
14
|
-
import { readdirSync, existsSync } from 'fs';
|
|
15
|
-
import { join, resolve } from 'path';
|
|
16
|
-
import { fileURLToPath } from 'url';
|
|
17
|
-
import { outputJson, readJsonFile } from './utils.mjs';
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
|
|
21
|
-
// ── Data Collectors ─────────────────────────────────────────
|
|
22
|
-
|
|
23
|
-
function getGitInfo() {
|
|
24
|
-
try {
|
|
25
|
-
const branch = execSync('git branch --show-current', { encoding: 'utf-8', timeout: 5000 }).trim();
|
|
26
|
-
const statusOutput = execSync('git status --porcelain', { encoding: 'utf-8', timeout: 5000 });
|
|
27
|
-
const dirtyCount = statusOutput ? statusOutput.trim().split('\n').filter(Boolean).length : 0;
|
|
28
|
-
const lastCommit = execSync('git log -1 --oneline', { encoding: 'utf-8', timeout: 5000 }).trim();
|
|
29
|
-
return { branch, dirtyCount, lastCommit };
|
|
30
|
-
} catch {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getAgentCount(cwd) {
|
|
36
|
-
try {
|
|
37
|
-
const agentsDir = join(cwd, '.claude', 'agents');
|
|
38
|
-
if (!existsSync(agentsDir)) return 0;
|
|
39
|
-
return readdirSync(agentsDir).filter(f => f.endsWith('.md')).length;
|
|
40
|
-
} catch {
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getSkillCount(cwd) {
|
|
46
|
-
try {
|
|
47
|
-
const skillsDir = join(cwd, '.claude', 'skills');
|
|
48
|
-
if (!existsSync(skillsDir)) return 0;
|
|
49
|
-
return readdirSync(skillsDir, { withFileTypes: true }).filter(d => d.isDirectory()).length;
|
|
50
|
-
} catch {
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getMemoryDecisions(cwd) {
|
|
56
|
-
const memoryPath = join(cwd, '.claude', 'session-memory.json');
|
|
57
|
-
const memory = readJsonFile(memoryPath);
|
|
58
|
-
if (!memory) return 0;
|
|
59
|
-
return Array.isArray(memory.decisions) ? memory.decisions.length : 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getActiveProfile(cwd) {
|
|
63
|
-
const configPath = join(cwd, '.claude', 'config.json');
|
|
64
|
-
const config = readJsonFile(configPath);
|
|
65
|
-
return config?.profile || null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function detectFramework(cwd) {
|
|
69
|
-
const pkg = readJsonFile(join(cwd, 'package.json'));
|
|
70
|
-
if (!pkg) return null;
|
|
71
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
72
|
-
if (deps['nuxt']) return 'Nuxt';
|
|
73
|
-
if (deps['next']) return 'Next.js';
|
|
74
|
-
if (deps['@sveltejs/kit']) return 'SvelteKit';
|
|
75
|
-
if (deps['@angular/core']) return 'Angular';
|
|
76
|
-
if (deps['astro']) return 'Astro';
|
|
77
|
-
if (deps['vue']) return 'Vue';
|
|
78
|
-
if (deps['react']) return 'React';
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function detectProjectFeatures(cwd) {
|
|
83
|
-
const features = [];
|
|
84
|
-
const pkg = readJsonFile(join(cwd, 'package.json'));
|
|
85
|
-
const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
|
|
86
|
-
|
|
87
|
-
if (existsSync(join(cwd, 'tsconfig.json'))) features.push('TypeScript');
|
|
88
|
-
if (deps?.['vitest'] || deps?.['jest'] || deps?.['mocha']) features.push('Tests');
|
|
89
|
-
if (existsSync(join(cwd, 'docs', 'ARCHITECTURE.md')) || existsSync(join(cwd, 'ARCHITECTURE.md'))) features.push('ARCHITECTURE.md');
|
|
90
|
-
if (existsSync(join(cwd, '.mcp.json'))) features.push('MCP configured');
|
|
91
|
-
|
|
92
|
-
return features;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getAvailableMCPs(cwd) {
|
|
96
|
-
const mcpConfig = readJsonFile(join(cwd, '.mcp.json'));
|
|
97
|
-
if (!mcpConfig?.mcpServers) return [];
|
|
98
|
-
return Object.keys(mcpConfig.mcpServers);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// ── Context Builder (exported for testing) ──────────────────
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Build project context string from current state.
|
|
105
|
-
* @param {string} cwd - Project root directory
|
|
106
|
-
* @returns {string} Context summary or empty string
|
|
107
|
-
*/
|
|
108
|
-
export function buildContext(cwd) {
|
|
109
|
-
const parts = [];
|
|
110
|
-
|
|
111
|
-
// Git info
|
|
112
|
-
const git = getGitInfo();
|
|
113
|
-
if (git) {
|
|
114
|
-
parts.push(`Branch: ${git.branch}`);
|
|
115
|
-
if (git.dirtyCount > 0) {
|
|
116
|
-
parts.push(`Uncommitted files: ${git.dirtyCount}`);
|
|
117
|
-
}
|
|
118
|
-
parts.push(`Last commit: ${git.lastCommit}`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Framework
|
|
122
|
-
const framework = detectFramework(cwd);
|
|
123
|
-
if (framework) {
|
|
124
|
-
parts.push(`Framework: ${framework}`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Project features
|
|
128
|
-
const features = detectProjectFeatures(cwd);
|
|
129
|
-
if (features.length > 0) {
|
|
130
|
-
parts.push(`Features: ${features.join(', ')}`);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Agents & skills
|
|
134
|
-
const agents = getAgentCount(cwd);
|
|
135
|
-
const skills = getSkillCount(cwd);
|
|
136
|
-
if (agents > 0 || skills > 0) {
|
|
137
|
-
parts.push(`Installed: ${agents} agents, ${skills} skills`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// MCPs
|
|
141
|
-
const mcps = getAvailableMCPs(cwd);
|
|
142
|
-
if (mcps.length > 0) {
|
|
143
|
-
parts.push(`MCPs: ${mcps.join(', ')}`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Memory
|
|
147
|
-
const decisions = getMemoryDecisions(cwd);
|
|
148
|
-
if (decisions > 0) {
|
|
149
|
-
parts.push(`Session memory: ${decisions} saved decisions (use /recall to query)`);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Profile
|
|
153
|
-
const profile = getActiveProfile(cwd);
|
|
154
|
-
if (profile) {
|
|
155
|
-
parts.push(`Active profile: ${profile}`);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return parts.length > 0 ? `[Specialist Agent] ${parts.join(' | ')}` : '';
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// ── Main Execution ──────────────────────────────────────────
|
|
162
|
-
|
|
163
|
-
async function main() {
|
|
164
|
-
const cwd = process.cwd();
|
|
165
|
-
const context = buildContext(cwd);
|
|
166
|
-
|
|
167
|
-
if (context) {
|
|
168
|
-
outputJson({ additionalContext: context });
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
process.exit(0);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (process.argv[1] && resolve(process.argv[1]) === resolve(__filename)) {
|
|
175
|
-
main().catch(() => {
|
|
176
|
-
// Advisory hook - never block on error
|
|
177
|
-
process.exit(0);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Session End - Stop Hook
|
|
5
|
-
*
|
|
6
|
-
* Fires when Claude Code finishes responding. Can be used to
|
|
7
|
-
* trigger lifecycle hooks (session-end) or log session metrics.
|
|
8
|
-
* All operations are best-effort. Errors are silently ignored.
|
|
9
|
-
*
|
|
10
|
-
* Claude Code event: Stop
|
|
11
|
-
* Output: { "additionalContext": "..." } or empty
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { readFileSync, existsSync } from 'fs';
|
|
15
|
-
import { join } from 'path';
|
|
16
|
-
|
|
17
|
-
const lifecyclePath = join(process.cwd(), 'hooks', 'lifecycle.json');
|
|
18
|
-
|
|
19
|
-
function main() {
|
|
20
|
-
try {
|
|
21
|
-
if (!existsSync(lifecyclePath)) {
|
|
22
|
-
process.stdout.write(JSON.stringify({}));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const lifecycle = JSON.parse(readFileSync(lifecyclePath, 'utf-8'));
|
|
27
|
-
const sessionEnd = lifecycle?.hooks?.['session-end'];
|
|
28
|
-
|
|
29
|
-
if (!sessionEnd?.enabled) {
|
|
30
|
-
process.stdout.write(JSON.stringify({}));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Log session end for metrics/notifications if configured
|
|
35
|
-
// The lifecycle.json may define webhook URLs or log destinations
|
|
36
|
-
process.stdout.write(JSON.stringify({}));
|
|
37
|
-
} catch {
|
|
38
|
-
process.stdout.write(JSON.stringify({}));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
main();
|
package/hooks/native/utils.mjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Native Hooks - Shared Utilities
|
|
5
|
-
* Common functions for all Claude Code native hooks.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { readFileSync } from 'fs';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Read JSON from stdin (Claude Code passes event data this way).
|
|
12
|
-
* Returns parsed object or null on failure.
|
|
13
|
-
*/
|
|
14
|
-
export async function readStdin() {
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
let data = '';
|
|
17
|
-
const timeout = setTimeout(() => resolve(null), 5000);
|
|
18
|
-
|
|
19
|
-
process.stdin.setEncoding('utf-8');
|
|
20
|
-
process.stdin.on('data', (chunk) => { data += chunk; });
|
|
21
|
-
process.stdin.on('end', () => {
|
|
22
|
-
clearTimeout(timeout);
|
|
23
|
-
try {
|
|
24
|
-
resolve(JSON.parse(data));
|
|
25
|
-
} catch {
|
|
26
|
-
resolve(null);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
process.stdin.on('error', () => {
|
|
30
|
-
clearTimeout(timeout);
|
|
31
|
-
resolve(null);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
process.stdin.resume();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Output JSON to stdout for Claude Code to consume.
|
|
40
|
-
*/
|
|
41
|
-
export function outputJson(obj) {
|
|
42
|
-
process.stdout.write(JSON.stringify(obj));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Output error to stderr and exit with code 2 (block action).
|
|
47
|
-
*/
|
|
48
|
-
export function blockWithReason(reason) {
|
|
49
|
-
process.stderr.write(reason);
|
|
50
|
-
process.exit(2);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Safe JSON file reader. Returns null on any error.
|
|
55
|
-
*/
|
|
56
|
-
export function readJsonFile(filePath) {
|
|
57
|
-
try {
|
|
58
|
-
return JSON.parse(readFileSync(filePath, 'utf-8'));
|
|
59
|
-
} catch {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|