specialist-agent 2.10.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/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 +6 -6
- 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/index.mjs +469 -324
- package/hooks/native/auto-dispatch.mjs +19 -26
- package/hooks/native/auto-format.mjs +5 -25
- package/hooks/native/mcp-discovery.mjs +168 -0
- package/hooks/native/security-config.json +4 -0
- package/hooks/native/security-guard.mjs +37 -24
- 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
|
@@ -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,6 +54,14 @@ 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 },
|
|
@@ -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,16 +182,13 @@ async function main() {
|
|
|
186
182
|
const match = matchIntent(prompt);
|
|
187
183
|
|
|
188
184
|
if (match) {
|
|
189
|
-
|
|
185
|
+
outputJson({
|
|
190
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.`,
|
|
191
|
-
};
|
|
192
|
-
process.stdout.write(JSON.stringify(output));
|
|
187
|
+
});
|
|
193
188
|
} else {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
};
|
|
198
|
-
process.stdout.write(JSON.stringify(output));
|
|
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
|
+
});
|
|
199
192
|
}
|
|
200
193
|
|
|
201
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,6 +12,10 @@
|
|
|
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" },
|
|
16
20
|
"ssh-key-access": { "enabled": true, "severity": "MEDIUM" },
|
|
17
21
|
"aws-credentials": { "enabled": true, "severity": "MEDIUM" },
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* Allow: exit 0 (silent)
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import { join, dirname, resolve } 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,6 +123,37 @@ 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
|
{
|
|
@@ -248,22 +279,9 @@ export function evaluateCommand(command, config = {}) {
|
|
|
248
279
|
// ── Main Execution ──────────────────────────────────────────
|
|
249
280
|
|
|
250
281
|
async function main() {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
try {
|
|
254
|
-
// Read stdin
|
|
255
|
-
const data = await new Promise((resolve) => {
|
|
256
|
-
let buf = '';
|
|
257
|
-
const timeout = setTimeout(() => resolve(buf), 3000);
|
|
258
|
-
process.stdin.setEncoding('utf-8');
|
|
259
|
-
process.stdin.on('data', (chunk) => { buf += chunk; });
|
|
260
|
-
process.stdin.on('end', () => { clearTimeout(timeout); resolve(buf); });
|
|
261
|
-
process.stdin.on('error', () => { clearTimeout(timeout); resolve(''); });
|
|
262
|
-
process.stdin.resume();
|
|
263
|
-
});
|
|
282
|
+
const input = await readStdin();
|
|
264
283
|
|
|
265
|
-
|
|
266
|
-
} catch {
|
|
284
|
+
if (!input) {
|
|
267
285
|
// Fail-closed: if we can't parse input, block
|
|
268
286
|
process.stderr.write('Security Guard: Failed to parse input. Blocking as precaution.');
|
|
269
287
|
process.exit(2);
|
|
@@ -277,13 +295,8 @@ async function main() {
|
|
|
277
295
|
const command = input.tool_input.command;
|
|
278
296
|
|
|
279
297
|
// Load config
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const configPath = join(__dirname, 'security-config.json');
|
|
283
|
-
config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
284
|
-
} catch {
|
|
285
|
-
// No config = use defaults (all rules enabled)
|
|
286
|
-
}
|
|
298
|
+
const configPath = resolve(__dirname, 'security-config.json');
|
|
299
|
+
const config = readJsonFile(configPath) || {};
|
|
287
300
|
|
|
288
301
|
if (config.enabled === false) {
|
|
289
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);
|
package/package.json
CHANGED
|
@@ -14,28 +14,11 @@ Read `docs/ARCHITECTURE.md`.
|
|
|
14
14
|
|
|
15
15
|
## Core Principles
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
- Use HTTPS everywhere, set secure headers (CSP, HSTS, X-Frame-Options)
|
|
23
|
-
- Follow OWASP Top 10 - prevent XSS, CSRF, injection, broken auth, etc.
|
|
24
|
-
- Secrets in environment variables only - never hardcode
|
|
25
|
-
|
|
26
|
-
### Performance First (Mandatory)
|
|
27
|
-
- ALWAYS use OnPush change detection for components
|
|
28
|
-
- Use Angular Signals (signal, computed, effect) for reactive state
|
|
29
|
-
- Lazy load routes and feature modules
|
|
30
|
-
- Use trackBy with @for to minimize DOM operations
|
|
31
|
-
- Avoid unnecessary subscriptions - prefer signals over RxJS where possible
|
|
32
|
-
- Use HttpClient with proper typing - no inline transformations
|
|
33
|
-
- Avoid N+1 queries - batch requests, use proper data loading patterns
|
|
34
|
-
|
|
35
|
-
### Code Language (Mandatory)
|
|
36
|
-
- ALWAYS write code (variables, functions, comments, commits) in English
|
|
37
|
-
- Only use other languages if explicitly requested by the user
|
|
38
|
-
- User-facing text (UI labels, messages) should match project's i18n strategy
|
|
17
|
+
Refer to the pack CLAUDE.md for full stack details and key patterns.
|
|
18
|
+
|
|
19
|
+
- **Security**: Validate all inputs server-side, parameterized queries only, no secrets in code, OWASP Top 10
|
|
20
|
+
- **Performance**: Use the framework's recommended server state caching, lazy load routes and components, no N+1 queries
|
|
21
|
+
- **Code Language**: All code in English. User-facing text follows project i18n strategy
|
|
39
22
|
|
|
40
23
|
## Scope Detection
|
|
41
24
|
- **Module**: user wants a full feature (CRUD, page, multiple endpoints) -> Module mode
|
|
@@ -47,46 +30,19 @@ Read `docs/ARCHITECTURE.md`.
|
|
|
47
30
|
---
|
|
48
31
|
|
|
49
32
|
## Module Mode
|
|
50
|
-
|
|
51
|
-
2. Scaffold `src/modules/[kebab-name]/` with: components/, services/, adapters/, stores/, types/, pages/, __tests__/, index.ts
|
|
52
|
-
3. Create bottom-up:
|
|
53
|
-
- `types/[name].types.ts` -- exact API response (snake_case)
|
|
54
|
-
- `types/[name].contracts.ts` -- app contract (camelCase, Date objects)
|
|
55
|
-
- `adapters/[name].adapter.ts` -- pure functions: inbound (API->App) + outbound (App->API)
|
|
56
|
-
- `services/[name].service.ts` -- HttpClient only: `list, getById, create, update, delete`. No try/catch, no transformation. inject(HttpClient)
|
|
57
|
-
- `stores/[name].store.ts` -- client state only (filters, UI). Signal-based, private WritableSignal, public asReadonly()
|
|
58
|
-
- Components -- standalone, input()/output() signals, OnPush, < 200 lines
|
|
59
|
-
- Page -- compose components with content projection, provide context
|
|
60
|
-
4. Register lazy route in app.routes.ts using loadComponent
|
|
61
|
-
5. Create barrel export (index.ts): pages + contracts only
|
|
62
|
-
6. Validate: `npx tsc --noEmit`
|
|
33
|
+
Run `/dev-create-module $NAME`. This skill contains the full scaffold workflow -- do NOT duplicate it here.
|
|
63
34
|
|
|
64
35
|
## Component Mode
|
|
65
|
-
|
|
66
|
-
2. Use standalone component template: @Component decorator -> class with inject() -> input()/output() signals -> local signals -> computed -> handlers
|
|
67
|
-
3. Rules: < 200 lines, kebab-case.component.ts, no prop drilling (use content projection + shared injectable), handle loading/error/empty states, OnPush change detection
|
|
68
|
-
4. Extract logic > 20 lines to a service or injectable
|
|
36
|
+
Run `/dev-create-component $NAME`. This skill contains the full scaffold workflow -- do NOT duplicate it here.
|
|
69
37
|
|
|
70
38
|
## Service Mode
|
|
71
|
-
|
|
72
|
-
2. Create 4 files:
|
|
73
|
-
- `types/[name].types.ts` -- exact API (snake_case, string dates)
|
|
74
|
-
- `types/[name].contracts.ts` -- app contract (camelCase, Date, computed booleans)
|
|
75
|
-
- `adapters/[name].adapter.ts` -- pure functions, bidirectional. Rename snake->camel, convert string->Date, cents->currency
|
|
76
|
-
- `services/[name].service.ts` -- HttpClient only. No try/catch, no transformation, no logic. inject(HttpClient), @Injectable({ providedIn: 'root' })
|
|
77
|
-
3. Validate: `npx tsc --noEmit`
|
|
39
|
+
Run `/dev-create-service $NAME`. This skill contains the full scaffold workflow -- do NOT duplicate it here.
|
|
78
40
|
|
|
79
41
|
## Injectable Mode
|
|
80
|
-
|
|
81
|
-
2. **Utility service** (shared logic, no UI): @Injectable with inject() for deps, typed methods
|
|
82
|
-
3. **Data orchestrator** (API + adapter): @Injectable that injects Service, applies adapter, exposes data via signals or Observables
|
|
83
|
-
4. Rules: @Injectable({ providedIn: 'root' }) or scoped to component, inject() for all deps, no constructor DI
|
|
42
|
+
Run `/dev-create-injectable $NAME`. This skill contains the full scaffold workflow -- do NOT duplicate it here.
|
|
84
43
|
|
|
85
44
|
## Test Mode
|
|
86
|
-
|
|
87
|
-
2. Priority: adapters (pure functions, easy) > services (mock HttpClient, HttpClientTestingModule) > components (Angular Testing Library)
|
|
88
|
-
3. Create in `__tests__/[original-name].spec.ts`
|
|
89
|
-
4. Run: `npx jest --testPathPattern=[file]` or `npx vitest run [file]`
|
|
45
|
+
Run `/dev-create-test $NAME`. This skill contains the full scaffold workflow -- do NOT duplicate it here.
|
|
90
46
|
|
|
91
47
|
## Verification Protocol
|
|
92
48
|
|