specialist-agent 2.9.0 → 2.11.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/.claude-plugin/marketplace.json +5 -5
- package/.claude-plugin/plugin.json +2 -2
- package/.cursor-plugin/marketplace.json +1 -1
- package/.cursor-plugin/plugin.json +2 -2
- package/.opencode/INSTALL.md +74 -79
- package/.opencode/opencode.json +141 -0
- package/README.md +128 -250
- package/agents/analyst.md +1 -0
- package/agents/api.md +4 -4
- package/agents/architect-lite.md +2 -2
- package/agents/architect.md +29 -20
- package/agents/cloud-lite.md +1 -1
- package/agents/cloud.md +4 -4
- package/agents/data-lite.md +1 -1
- package/agents/data.md +4 -4
- package/agents/debugger.md +1 -0
- package/agents/deps.md +4 -4
- package/agents/designer-lite.md +1 -1
- package/agents/designer.md +4 -4
- package/agents/devops-lite.md +1 -1
- package/agents/devops.md +4 -4
- package/agents/docs.md +4 -4
- package/agents/executor.md +95 -0
- package/agents/explorer-lite.md +1 -1
- package/agents/explorer.md +4 -4
- package/agents/finance-lite.md +1 -1
- package/agents/finance.md +4 -4
- package/agents/i18n.md +4 -4
- package/agents/legal-lite.md +1 -1
- package/agents/legal.md +4 -4
- package/agents/marketing-lite.md +25 -0
- package/agents/marketing.md +179 -0
- package/agents/memory.md +13 -12
- package/agents/orchestrator.md +102 -0
- package/agents/pair.md +1 -0
- package/agents/perf.md +4 -4
- package/agents/planner.md +1 -0
- package/agents/product-lite.md +25 -0
- package/agents/product.md +186 -0
- package/agents/refactor.md +4 -4
- package/agents/ripple.md +1 -0
- package/agents/scout.md +1 -0
- package/agents/security-lite.md +1 -1
- package/agents/security.md +4 -4
- package/agents/sentry-triage-lite.md +54 -0
- package/agents/sentry-triage.md +214 -0
- package/agents/starter-lite.md +4 -4
- package/agents/starter.md +8 -8
- package/agents/support-lite.md +24 -0
- package/agents/support.md +190 -0
- package/agents/tdd.md +1 -0
- package/agents/tester-lite.md +1 -1
- package/agents/tester.md +43 -10
- package/cli/architectures.mjs +713 -0
- package/cli/detect-architecture.mjs +752 -0
- package/cli/generate-architecture.mjs +1096 -0
- package/cli/index.mjs +681 -179
- package/cli/recommend-architecture.mjs +870 -0
- package/hooks/native/auto-dispatch.mjs +22 -23
- package/hooks/native/auto-format.mjs +5 -25
- package/hooks/native/mcp-discovery.mjs +168 -0
- package/hooks/native/security-config.json +7 -0
- package/hooks/native/security-guard.mjs +77 -27
- package/hooks/native/session-context.mjs +61 -18
- package/hooks/native/settings-template.json +9 -0
- package/package.json +1 -1
- package/packs/angular/agents/builder.md +10 -54
- package/packs/angular/agents/doctor.md +7 -61
- package/packs/angular/agents/migrator.md +7 -101
- package/packs/angular/agents/reviewer.md +22 -33
- package/packs/angular/skills/review-check-architecture/SKILL.md +7 -7
- package/packs/angular/skills/review-review/SKILL.md +1 -0
- package/packs/astro/agents/builder.md +10 -79
- package/packs/astro/agents/doctor.md +7 -61
- package/packs/astro/agents/migrator.md +7 -111
- package/packs/astro/agents/reviewer.md +22 -32
- package/packs/astro/skills/review-check-architecture/SKILL.md +9 -9
- package/packs/astro/skills/review-review/SKILL.md +1 -0
- package/packs/nextjs/agents/builder.md +11 -108
- package/packs/nextjs/agents/doctor.md +7 -62
- package/packs/nextjs/agents/migrator.md +6 -194
- package/packs/nextjs/agents/reviewer.md +22 -76
- package/packs/nextjs/skills/review-check-architecture/SKILL.md +15 -15
- package/packs/nextjs/skills/review-review/SKILL.md +1 -0
- package/packs/nuxt/agents/builder.md +10 -55
- package/packs/nuxt/agents/doctor.md +7 -61
- package/packs/nuxt/agents/migrator.md +7 -109
- package/packs/nuxt/agents/reviewer.md +22 -42
- package/packs/nuxt/skills/review-check-architecture/SKILL.md +11 -11
- package/packs/nuxt/skills/review-review/SKILL.md +1 -0
- package/packs/react/agents/builder.md +10 -55
- package/packs/react/agents/doctor.md +7 -61
- package/packs/react/agents/migrator.md +7 -106
- package/packs/react/agents/reviewer.md +22 -55
- package/packs/react/skills/review-check-architecture/SKILL.md +10 -10
- package/packs/react/skills/review-review/SKILL.md +1 -0
- package/packs/svelte/agents/builder.md +10 -58
- package/packs/svelte/agents/doctor.md +7 -60
- package/packs/svelte/agents/migrator.md +7 -118
- package/packs/svelte/agents/reviewer.md +22 -42
- package/packs/svelte/skills/review-check-architecture/SKILL.md +12 -12
- package/packs/svelte/skills/review-review/SKILL.md +1 -0
- package/packs/vue/agents/builder.md +10 -55
- package/packs/vue/agents/doctor.md +7 -61
- package/packs/vue/agents/migrator.md +7 -93
- package/packs/vue/agents/reviewer.md +20 -32
- package/packs/vue/skills/review-check-architecture/SKILL.md +10 -10
- package/packs/vue/skills/review-review/SKILL.md +1 -0
- package/skills/autofix/SKILL.md +166 -0
- package/skills/discovery/SKILL.md +218 -0
- package/skills/migrate-architecture/SKILL.md +242 -0
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { resolve } from 'path';
|
|
15
15
|
import { fileURLToPath } from 'url';
|
|
16
|
+
import { readStdin, outputJson } from './utils.mjs';
|
|
16
17
|
|
|
17
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
18
19
|
|
|
@@ -53,11 +54,19 @@ const INTENT_MAP = {
|
|
|
53
54
|
designer: { phrases: ['design system', 'component library', 'accessibility audit'], keywords: ['design system', 'accessibility', 'a11y', 'ui library', 'theme'], weight: 1.5 },
|
|
54
55
|
tester: { phrases: ['test strategy', 'test coverage', 'e2e tests', 'testing plan'], keywords: ['test strategy', 'coverage', 'e2e', 'testing'], weight: 1 },
|
|
55
56
|
|
|
57
|
+
// Business agents
|
|
58
|
+
marketing: { phrases: ['landing page', 'marketing copy', 'seo optimization', 'growth strategy', 'social media'], keywords: ['marketing', 'seo', 'copy', 'landing', 'growth', 'conversion', 'funnel'], weight: 1.5 },
|
|
59
|
+
product: { phrases: ['product strategy', 'user story', 'product roadmap', 'feature prioritization', 'product requirement'], keywords: ['product', 'roadmap', 'prd', 'user story', 'prioritization', 'backlog'], weight: 1.5 },
|
|
60
|
+
support: { phrases: ['knowledge base', 'runbook', 'changelog', 'support docs', 'faq'], keywords: ['support', 'runbook', 'changelog', 'faq', 'knowledge base', 'help docs'], weight: 1.5 },
|
|
61
|
+
|
|
62
|
+
// Automation agents
|
|
63
|
+
'sentry-triage': { phrases: ['sentry error', 'triage errors', 'sentry issue', 'error triage', 'fix sentry'], keywords: ['sentry', 'triage', 'error tracking', 'alert'], weight: 2 },
|
|
64
|
+
|
|
56
65
|
// Support agents
|
|
57
66
|
scout: { phrases: ['analyze project', 'project analysis', 'quick scan'], keywords: ['analyze', 'scan', 'overview', 'analysis'], weight: 1 },
|
|
58
67
|
explorer: { phrases: ['explore codebase', 'understand code', 'how does this work'], keywords: ['explore', 'understand', 'codebase', 'how does'], weight: 1 },
|
|
59
68
|
memory: { phrases: ['remember this', 'save decision', 'recall decision', 'session memory'], keywords: ['remember', 'recall', 'memory', 'decision log'], weight: 1.5 },
|
|
60
|
-
architect: { phrases: ['architecture migration', 'monolith to microservices', 'system redesign', 'clean architecture', 'hexagonal architecture', 'migrate architecture'], keywords: ['architecture', 'hexagonal', 'ddd', 'cqrs', 'modular monolith', 'bounded context', 'strangler fig'], weight: 1.5 },
|
|
69
|
+
architect: { phrases: ['architecture migration', 'monolith to microservices', 'system redesign', 'clean architecture', 'hexagonal architecture', 'migrate architecture', 'detect architecture', 'change architecture', 'improve architecture', 'modular monolith', 'domain driven design', 'feature sliced design', 'ports and adapters'], keywords: ['architecture', 'hexagonal', 'ddd', 'cqrs', 'modular monolith', 'bounded context', 'strangler fig', 'modular', 'fsd', 'clean arch', 'ports adapters'], weight: 1.5 },
|
|
61
70
|
ripple: { phrases: ['impact analysis', 'cascading effects', 'what will break', 'change impact'], keywords: ['impact', 'ripple', 'cascade', 'breaking change', 'downstream'], weight: 1.5 },
|
|
62
71
|
};
|
|
63
72
|
|
|
@@ -94,6 +103,10 @@ const AGENT_DESCRIPTIONS = {
|
|
|
94
103
|
memory: 'saves and recalls decisions across sessions',
|
|
95
104
|
architect: 'designs and migrates full system architecture (hexagonal, DDD, CQRS, microservices)',
|
|
96
105
|
ripple: 'analyzes cascading impact of changes across the codebase',
|
|
106
|
+
marketing: 'creates landing pages, marketing copy, SEO optimization, and growth strategies',
|
|
107
|
+
product: 'defines product strategy, user stories, roadmaps, and feature prioritization',
|
|
108
|
+
support: 'generates knowledge base articles, runbooks, changelogs, and FAQs',
|
|
109
|
+
'sentry-triage': 'triages Sentry errors, prioritizes by impact, and auto-creates fix PRs',
|
|
97
110
|
};
|
|
98
111
|
|
|
99
112
|
// ── Intent Matching Engine (exported for testing) ───────────
|
|
@@ -158,24 +171,7 @@ export function matchIntent(prompt) {
|
|
|
158
171
|
// ── Main Execution ──────────────────────────────────────────
|
|
159
172
|
|
|
160
173
|
async function main() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
try {
|
|
164
|
-
const data = await new Promise((resolve) => {
|
|
165
|
-
let buf = '';
|
|
166
|
-
const timeout = setTimeout(() => resolve(buf), 3000);
|
|
167
|
-
process.stdin.setEncoding('utf-8');
|
|
168
|
-
process.stdin.on('data', (chunk) => { buf += chunk; });
|
|
169
|
-
process.stdin.on('end', () => { clearTimeout(timeout); resolve(buf); });
|
|
170
|
-
process.stdin.on('error', () => { clearTimeout(timeout); resolve(''); });
|
|
171
|
-
process.stdin.resume();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
input = data ? JSON.parse(data) : null;
|
|
175
|
-
} catch {
|
|
176
|
-
// Can't parse input - silently allow (this hook is advisory, not blocking)
|
|
177
|
-
process.exit(0);
|
|
178
|
-
}
|
|
174
|
+
const input = await readStdin();
|
|
179
175
|
|
|
180
176
|
const prompt = input?.prompt || '';
|
|
181
177
|
|
|
@@ -186,10 +182,13 @@ async function main() {
|
|
|
186
182
|
const match = matchIntent(prompt);
|
|
187
183
|
|
|
188
184
|
if (match) {
|
|
189
|
-
|
|
190
|
-
additionalContext: `Specialist Agent suggests: @${match.agent}
|
|
191
|
-
};
|
|
192
|
-
|
|
185
|
+
outputJson({
|
|
186
|
+
additionalContext: `Specialist Agent suggests: @${match.agent} — ${match.description}. Mention @${match.agent} in your prompt to activate it. Agents provide domain expertise, structured workflows, and verification — always prefer them over generic prompts.`,
|
|
187
|
+
});
|
|
188
|
+
} else {
|
|
189
|
+
outputJson({
|
|
190
|
+
additionalContext: 'Tip: Specialist Agent has 35 agents for this project. Use @builder to create, @reviewer to review, @doctor to debug, @planner to plan, @tdd for test-driven development. Agents deliver better results than generic prompts.',
|
|
191
|
+
});
|
|
193
192
|
}
|
|
194
193
|
|
|
195
194
|
process.exit(0);
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
import { execFileSync } from 'child_process';
|
|
16
16
|
import { existsSync } from 'fs';
|
|
17
|
-
import { resolve, extname,
|
|
17
|
+
import { resolve, extname, join, relative, isAbsolute } from 'path';
|
|
18
18
|
import { fileURLToPath } from 'url';
|
|
19
|
+
import { readStdin, readJsonFile } from './utils.mjs';
|
|
19
20
|
|
|
20
21
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
22
|
|
|
@@ -64,12 +65,8 @@ export function detectFormatter(cwd) {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
// Check package.json for prettier key
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (pkg.prettier) return 'prettier';
|
|
70
|
-
} catch {
|
|
71
|
-
// ignore
|
|
72
|
-
}
|
|
68
|
+
const pkg = readJsonFile(join(cwd, 'package.json'));
|
|
69
|
+
if (pkg?.prettier) return 'prettier';
|
|
73
70
|
|
|
74
71
|
// Check biome
|
|
75
72
|
for (const config of BIOME_CONFIGS) {
|
|
@@ -139,24 +136,7 @@ export function formatFile(filePath, formatter, cwd) {
|
|
|
139
136
|
// ── Main Execution ──────────────────────────────────────────
|
|
140
137
|
|
|
141
138
|
async function main() {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
const data = await new Promise((resolve) => {
|
|
146
|
-
let buf = '';
|
|
147
|
-
const timeout = setTimeout(() => resolve(buf), 3000);
|
|
148
|
-
process.stdin.setEncoding('utf-8');
|
|
149
|
-
process.stdin.on('data', (chunk) => { buf += chunk; });
|
|
150
|
-
process.stdin.on('end', () => { clearTimeout(timeout); resolve(buf); });
|
|
151
|
-
process.stdin.on('error', () => { clearTimeout(timeout); resolve(''); });
|
|
152
|
-
process.stdin.resume();
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
input = data ? JSON.parse(data) : null;
|
|
156
|
-
} catch {
|
|
157
|
-
process.exit(0);
|
|
158
|
-
}
|
|
159
|
-
|
|
139
|
+
const input = await readStdin();
|
|
160
140
|
const filePath = input?.tool_input?.file_path;
|
|
161
141
|
|
|
162
142
|
if (!filePath) {
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MCP Discovery - SessionStart Hook
|
|
5
|
+
*
|
|
6
|
+
* Detects configured MCP servers and injects availability context
|
|
7
|
+
* so agents know which external tools they can leverage.
|
|
8
|
+
* All operations are read-only. Errors are silently ignored.
|
|
9
|
+
*
|
|
10
|
+
* Claude Code event: SessionStart
|
|
11
|
+
* Output: { "additionalContext": "MCP availability summary..." }
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { join, resolve } from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
import { outputJson, readJsonFile } from './utils.mjs';
|
|
17
|
+
|
|
18
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// ── MCP Registry ────────────────────────────────────────────
|
|
21
|
+
// Maps MCP server names to the agents/skills that benefit from them.
|
|
22
|
+
|
|
23
|
+
const MCP_AGENT_MAP = {
|
|
24
|
+
context7: {
|
|
25
|
+
description: 'Library documentation lookups',
|
|
26
|
+
agents: ['@builder', '@doctor', '@migrator', '@deps'],
|
|
27
|
+
skills: ['/tdd', '/debug'],
|
|
28
|
+
hint: 'Agents can fetch up-to-date API docs instead of relying on training data.',
|
|
29
|
+
},
|
|
30
|
+
azion: {
|
|
31
|
+
description: 'Edge deployment & configuration',
|
|
32
|
+
agents: ['@starter', '@cloud'],
|
|
33
|
+
skills: [],
|
|
34
|
+
hint: 'Enables edge deploy, Rules Engine config generation, and Terraform resources.',
|
|
35
|
+
},
|
|
36
|
+
playwright: {
|
|
37
|
+
description: 'Browser automation & testing',
|
|
38
|
+
agents: ['@tester', '@doctor', '@debugger', '@perf'],
|
|
39
|
+
skills: ['/verify', '/debug'],
|
|
40
|
+
hint: 'Agents can interact with the browser — take screenshots, run e2e tests, inspect DOM.',
|
|
41
|
+
},
|
|
42
|
+
github: {
|
|
43
|
+
description: 'GitHub issues, PRs & CI',
|
|
44
|
+
agents: ['@sentry-triage', '@reviewer', '@ripple', '@deps', '@devops'],
|
|
45
|
+
skills: ['/autofix', '/finish', '/codereview'],
|
|
46
|
+
hint: 'Agents can create issues/PRs, read CI status, and manage releases.',
|
|
47
|
+
},
|
|
48
|
+
sentry: {
|
|
49
|
+
description: 'Error tracking & triage',
|
|
50
|
+
agents: ['@sentry-triage', '@doctor', '@debugger'],
|
|
51
|
+
skills: ['/autofix', '/debug'],
|
|
52
|
+
hint: 'Agents can fetch Sentry errors directly instead of requiring CLI or curl.',
|
|
53
|
+
},
|
|
54
|
+
linear: {
|
|
55
|
+
description: 'Issue tracking & project management',
|
|
56
|
+
agents: ['@planner', '@analyst', '@product', '@orchestrator'],
|
|
57
|
+
skills: ['/plan'],
|
|
58
|
+
hint: 'Agents can read/create Linear issues and link tasks to code changes.',
|
|
59
|
+
},
|
|
60
|
+
jira: {
|
|
61
|
+
description: 'Issue tracking & project management',
|
|
62
|
+
agents: ['@planner', '@analyst', '@product', '@orchestrator'],
|
|
63
|
+
skills: ['/plan'],
|
|
64
|
+
hint: 'Agents can read/create Jira issues and link tasks to code changes.',
|
|
65
|
+
},
|
|
66
|
+
supabase: {
|
|
67
|
+
description: 'Database & auth management',
|
|
68
|
+
agents: ['@data', '@builder', '@security'],
|
|
69
|
+
skills: [],
|
|
70
|
+
hint: 'Agents can read schemas, manage migrations, and configure auth rules.',
|
|
71
|
+
},
|
|
72
|
+
postgres: {
|
|
73
|
+
description: 'PostgreSQL database access',
|
|
74
|
+
agents: ['@data', '@builder'],
|
|
75
|
+
skills: [],
|
|
76
|
+
hint: 'Agents can read live schemas and validate queries.',
|
|
77
|
+
},
|
|
78
|
+
slack: {
|
|
79
|
+
description: 'Team notifications',
|
|
80
|
+
agents: ['@orchestrator', '@support'],
|
|
81
|
+
skills: ['/finish'],
|
|
82
|
+
hint: 'Agents can send notifications on review completion, deploys, and errors.',
|
|
83
|
+
},
|
|
84
|
+
filesystem: {
|
|
85
|
+
description: 'Extended file system access',
|
|
86
|
+
agents: ['@explorer', '@scout'],
|
|
87
|
+
skills: ['/onboard'],
|
|
88
|
+
hint: 'Extended file system capabilities for deep codebase exploration.',
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// ── Discovery Logic (exported for testing) ──────────────────
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Discover configured MCP servers and map them to agent capabilities.
|
|
96
|
+
* @param {string} cwd - Project root directory
|
|
97
|
+
* @returns {{ configured: string[], agentCapabilities: Record<string, string[]>, suggestions: string[] }}
|
|
98
|
+
*/
|
|
99
|
+
export function discoverMCPs(cwd) {
|
|
100
|
+
const mcpConfig = readJsonFile(join(cwd, '.mcp.json'));
|
|
101
|
+
const configured = mcpConfig?.mcpServers ? Object.keys(mcpConfig.mcpServers) : [];
|
|
102
|
+
|
|
103
|
+
// Map configured MCPs to agent capabilities
|
|
104
|
+
const agentCapabilities = {};
|
|
105
|
+
for (const mcpName of configured) {
|
|
106
|
+
const mapping = MCP_AGENT_MAP[mcpName];
|
|
107
|
+
if (!mapping) continue;
|
|
108
|
+
|
|
109
|
+
for (const agent of mapping.agents) {
|
|
110
|
+
if (!agentCapabilities[agent]) agentCapabilities[agent] = [];
|
|
111
|
+
agentCapabilities[agent].push(mcpName);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Suggest MCPs that would benefit current agents but aren't configured
|
|
116
|
+
const suggestions = [];
|
|
117
|
+
for (const [mcpName, mapping] of Object.entries(MCP_AGENT_MAP)) {
|
|
118
|
+
if (configured.includes(mcpName)) continue;
|
|
119
|
+
// Only suggest if user has relevant agents installed
|
|
120
|
+
suggestions.push(`${mcpName}: ${mapping.description} → benefits ${mapping.agents.join(', ')}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { configured, agentCapabilities, suggestions };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Build MCP context string for session injection.
|
|
128
|
+
* @param {string} cwd - Project root directory
|
|
129
|
+
* @returns {string} MCP context or empty string
|
|
130
|
+
*/
|
|
131
|
+
export function buildMCPContext(cwd) {
|
|
132
|
+
const { configured, agentCapabilities } = discoverMCPs(cwd);
|
|
133
|
+
|
|
134
|
+
if (configured.length === 0) return '';
|
|
135
|
+
|
|
136
|
+
const parts = [`MCPs available: ${configured.join(', ')}`];
|
|
137
|
+
|
|
138
|
+
// Add agent-specific hints
|
|
139
|
+
const enhancedAgents = Object.entries(agentCapabilities)
|
|
140
|
+
.map(([agent, mcps]) => `${agent}(+${mcps.join(',')})`)
|
|
141
|
+
.join(' ');
|
|
142
|
+
|
|
143
|
+
if (enhancedAgents) {
|
|
144
|
+
parts.push(`Enhanced agents: ${enhancedAgents}`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return parts.join(' | ');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ── Main Execution ──────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
async function main() {
|
|
153
|
+
const cwd = process.cwd();
|
|
154
|
+
const context = buildMCPContext(cwd);
|
|
155
|
+
|
|
156
|
+
if (context) {
|
|
157
|
+
outputJson({ additionalContext: `[MCP Discovery] ${context}` });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
process.exit(0);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (process.argv[1] && resolve(process.argv[1]) === resolve(__filename)) {
|
|
164
|
+
main().catch(() => {
|
|
165
|
+
// Advisory hook - never block on error
|
|
166
|
+
process.exit(0);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
@@ -12,7 +12,14 @@
|
|
|
12
12
|
"sql-destructive": { "enabled": true, "severity": "HIGH" },
|
|
13
13
|
"pipe-to-shell": { "enabled": true, "severity": "HIGH" },
|
|
14
14
|
"chmod-777": { "enabled": true, "severity": "HIGH" },
|
|
15
|
+
"git-branch-force-delete": { "enabled": true, "severity": "HIGH" },
|
|
16
|
+
"npm-publish-no-dry-run": { "enabled": true, "severity": "HIGH" },
|
|
17
|
+
"docker-system-prune": { "enabled": true, "severity": "HIGH" },
|
|
18
|
+
"kubectl-delete-namespace": { "enabled": true, "severity": "HIGH" },
|
|
15
19
|
"env-file-read": { "enabled": true, "severity": "MEDIUM" },
|
|
20
|
+
"ssh-key-access": { "enabled": true, "severity": "MEDIUM" },
|
|
21
|
+
"aws-credentials": { "enabled": true, "severity": "MEDIUM" },
|
|
22
|
+
"cloud-credentials": { "enabled": true, "severity": "MEDIUM" },
|
|
16
23
|
"env-file-write": { "enabled": true, "severity": "MEDIUM" },
|
|
17
24
|
"inline-secrets": { "enabled": true, "severity": "MEDIUM" }
|
|
18
25
|
},
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* Allow: exit 0 (silent)
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import { join, dirname, resolve, normalize } from 'path';
|
|
15
|
+
import { dirname, resolve } from 'path';
|
|
17
16
|
import { fileURLToPath } from 'url';
|
|
17
|
+
import { readStdin, readJsonFile } from './utils.mjs';
|
|
18
18
|
|
|
19
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
20
20
|
const __dirname = dirname(__filename);
|
|
@@ -123,24 +123,92 @@ const RULES = [
|
|
|
123
123
|
test: (cmd) => /\bchmod\b.*\b777\b/.test(cmd),
|
|
124
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
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
|
+
},
|
|
126
157
|
|
|
127
158
|
// MEDIUM - block access to sensitive files
|
|
128
159
|
{
|
|
129
160
|
id: 'env-file-read',
|
|
130
161
|
severity: 'MEDIUM',
|
|
131
162
|
test: (cmd) => {
|
|
163
|
+
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type)\b/;
|
|
132
164
|
// Block reading .env files (but allow .env.example, .env.sample, .env.template)
|
|
133
|
-
if (
|
|
165
|
+
if (readCmds.test(cmd) && /\.env\b/.test(cmd)) {
|
|
134
166
|
if (/\.env\.(example|sample|template|test|development)/.test(cmd)) return false;
|
|
135
|
-
if (/\.env\.local/.test(cmd)) return true; // .env.local has secrets
|
|
136
167
|
return true;
|
|
137
168
|
}
|
|
138
169
|
// Block reading private keys
|
|
139
|
-
if (
|
|
170
|
+
if (readCmds.test(cmd) && /\.(pem|key|p12|pfx)\b/.test(cmd)) return true;
|
|
140
171
|
return false;
|
|
141
172
|
},
|
|
142
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'
|
|
143
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
|
+
},
|
|
144
212
|
{
|
|
145
213
|
id: 'env-file-write',
|
|
146
214
|
severity: 'MEDIUM',
|
|
@@ -211,22 +279,9 @@ export function evaluateCommand(command, config = {}) {
|
|
|
211
279
|
// ── Main Execution ──────────────────────────────────────────
|
|
212
280
|
|
|
213
281
|
async function main() {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
try {
|
|
217
|
-
// Read stdin
|
|
218
|
-
const data = await new Promise((resolve) => {
|
|
219
|
-
let buf = '';
|
|
220
|
-
const timeout = setTimeout(() => resolve(buf), 3000);
|
|
221
|
-
process.stdin.setEncoding('utf-8');
|
|
222
|
-
process.stdin.on('data', (chunk) => { buf += chunk; });
|
|
223
|
-
process.stdin.on('end', () => { clearTimeout(timeout); resolve(buf); });
|
|
224
|
-
process.stdin.on('error', () => { clearTimeout(timeout); resolve(''); });
|
|
225
|
-
process.stdin.resume();
|
|
226
|
-
});
|
|
282
|
+
const input = await readStdin();
|
|
227
283
|
|
|
228
|
-
|
|
229
|
-
} catch {
|
|
284
|
+
if (!input) {
|
|
230
285
|
// Fail-closed: if we can't parse input, block
|
|
231
286
|
process.stderr.write('Security Guard: Failed to parse input. Blocking as precaution.');
|
|
232
287
|
process.exit(2);
|
|
@@ -240,13 +295,8 @@ async function main() {
|
|
|
240
295
|
const command = input.tool_input.command;
|
|
241
296
|
|
|
242
297
|
// Load config
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const configPath = join(__dirname, 'security-config.json');
|
|
246
|
-
config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
247
|
-
} catch {
|
|
248
|
-
// No config = use defaults (all rules enabled)
|
|
249
|
-
}
|
|
298
|
+
const configPath = resolve(__dirname, 'security-config.json');
|
|
299
|
+
const config = readJsonFile(configPath) || {};
|
|
250
300
|
|
|
251
301
|
if (config.enabled === false) {
|
|
252
302
|
process.exit(0);
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { execSync } from 'child_process';
|
|
14
|
-
import {
|
|
14
|
+
import { readdirSync, existsSync } from 'fs';
|
|
15
15
|
import { join, resolve } from 'path';
|
|
16
16
|
import { fileURLToPath } from 'url';
|
|
17
|
+
import { outputJson, readJsonFile } from './utils.mjs';
|
|
17
18
|
|
|
18
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
20
|
|
|
@@ -52,25 +53,49 @@ function getSkillCount(cwd) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
function getMemoryDecisions(cwd) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return Array.isArray(memory.decisions) ? memory.decisions.length : 0;
|
|
60
|
-
} catch {
|
|
61
|
-
return 0;
|
|
62
|
-
}
|
|
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;
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
function getActiveProfile(cwd) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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);
|
|
74
99
|
}
|
|
75
100
|
|
|
76
101
|
// ── Context Builder (exported for testing) ──────────────────
|
|
@@ -93,6 +118,18 @@ export function buildContext(cwd) {
|
|
|
93
118
|
parts.push(`Last commit: ${git.lastCommit}`);
|
|
94
119
|
}
|
|
95
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
|
+
|
|
96
133
|
// Agents & skills
|
|
97
134
|
const agents = getAgentCount(cwd);
|
|
98
135
|
const skills = getSkillCount(cwd);
|
|
@@ -100,6 +137,12 @@ export function buildContext(cwd) {
|
|
|
100
137
|
parts.push(`Installed: ${agents} agents, ${skills} skills`);
|
|
101
138
|
}
|
|
102
139
|
|
|
140
|
+
// MCPs
|
|
141
|
+
const mcps = getAvailableMCPs(cwd);
|
|
142
|
+
if (mcps.length > 0) {
|
|
143
|
+
parts.push(`MCPs: ${mcps.join(', ')}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
103
146
|
// Memory
|
|
104
147
|
const decisions = getMemoryDecisions(cwd);
|
|
105
148
|
if (decisions > 0) {
|
|
@@ -122,7 +165,7 @@ async function main() {
|
|
|
122
165
|
const context = buildContext(cwd);
|
|
123
166
|
|
|
124
167
|
if (context) {
|
|
125
|
-
|
|
168
|
+
outputJson({ additionalContext: context });
|
|
126
169
|
}
|
|
127
170
|
|
|
128
171
|
process.exit(0);
|