@girardmedia/bootspring 1.1.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 +21 -0
- package/README.md +255 -0
- package/agents/README.md +93 -0
- package/agents/api-expert/context.md +416 -0
- package/agents/architecture-expert/context.md +454 -0
- package/agents/backend-expert/context.md +483 -0
- package/agents/code-review-expert/context.md +365 -0
- package/agents/database-expert/context.md +250 -0
- package/agents/devops-expert/context.md +446 -0
- package/agents/frontend-expert/context.md +364 -0
- package/agents/index.js +140 -0
- package/agents/performance-expert/context.md +377 -0
- package/agents/security-expert/context.md +343 -0
- package/agents/testing-expert/context.md +414 -0
- package/agents/ui-ux-expert/context.md +448 -0
- package/agents/vercel-expert/context.md +426 -0
- package/bin/bootspring.js +310 -0
- package/cli/agent.js +337 -0
- package/cli/context.js +194 -0
- package/cli/dashboard.js +150 -0
- package/cli/generate.js +294 -0
- package/cli/init.js +410 -0
- package/cli/loop.js +421 -0
- package/cli/mcp.js +241 -0
- package/cli/memory.js +303 -0
- package/cli/orchestrator.js +400 -0
- package/cli/plugin.js +451 -0
- package/cli/quality.js +332 -0
- package/cli/skill.js +369 -0
- package/cli/task.js +628 -0
- package/cli/telemetry.js +114 -0
- package/cli/todo.js +614 -0
- package/cli/update.js +312 -0
- package/core/config.js +245 -0
- package/core/context.js +329 -0
- package/core/entitlements.js +209 -0
- package/core/index.js +43 -0
- package/core/policies.js +68 -0
- package/core/telemetry.js +247 -0
- package/core/utils.js +380 -0
- package/dashboard/server.js +818 -0
- package/docs/integrations/claude-code.md +42 -0
- package/docs/integrations/codex.md +42 -0
- package/docs/mcp-api-platform.md +102 -0
- package/generators/generate.js +598 -0
- package/generators/index.js +18 -0
- package/hooks/context-detector.js +177 -0
- package/hooks/index.js +35 -0
- package/hooks/prompt-enhancer.js +289 -0
- package/intelligence/git-memory.js +551 -0
- package/intelligence/index.js +59 -0
- package/intelligence/orchestrator.js +964 -0
- package/intelligence/prd.js +447 -0
- package/intelligence/recommendation-weights.json +18 -0
- package/intelligence/recommendations.js +234 -0
- package/mcp/capabilities.js +71 -0
- package/mcp/contracts/mcp-contract.v1.json +497 -0
- package/mcp/registry.js +213 -0
- package/mcp/response-formatter.js +462 -0
- package/mcp/server.js +99 -0
- package/mcp/tools/agent-tool.js +137 -0
- package/mcp/tools/capabilities-tool.js +54 -0
- package/mcp/tools/context-tool.js +49 -0
- package/mcp/tools/dashboard-tool.js +58 -0
- package/mcp/tools/generate-tool.js +46 -0
- package/mcp/tools/loop-tool.js +134 -0
- package/mcp/tools/memory-tool.js +180 -0
- package/mcp/tools/orchestrator-tool.js +232 -0
- package/mcp/tools/plugin-tool.js +76 -0
- package/mcp/tools/quality-tool.js +47 -0
- package/mcp/tools/skill-tool.js +233 -0
- package/mcp/tools/telemetry-tool.js +95 -0
- package/mcp/tools/todo-tool.js +133 -0
- package/package.json +98 -0
- package/plugins/index.js +141 -0
- package/quality/index.js +380 -0
- package/quality/lint-budgets.json +19 -0
- package/skills/index.js +787 -0
- package/skills/patterns/README.md +163 -0
- package/skills/patterns/api/route-handler.md +217 -0
- package/skills/patterns/api/server-action.md +249 -0
- package/skills/patterns/auth/clerk.md +132 -0
- package/skills/patterns/database/prisma.md +180 -0
- package/skills/patterns/payments/stripe.md +272 -0
- package/skills/patterns/security/validation.md +268 -0
- package/skills/patterns/testing/vitest.md +307 -0
- package/templates/bootspring.config.js +83 -0
- package/templates/mcp.json +9 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootspring Context Detector
|
|
3
|
+
* Detects task types and suggests relevant agents/skills
|
|
4
|
+
*
|
|
5
|
+
* @package bootspring
|
|
6
|
+
* @module hooks/context-detector
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Context trigger definitions
|
|
11
|
+
* Maps keywords to agents, skills, and categories
|
|
12
|
+
*/
|
|
13
|
+
const CONTEXT_TRIGGERS = {
|
|
14
|
+
database: {
|
|
15
|
+
keywords: ['database', 'schema', 'prisma', 'migration', 'query', 'sql', 'postgres', 'mongodb', 'drizzle', 'orm', 'table', 'column', 'foreign key', 'index'],
|
|
16
|
+
agents: ['database-expert'],
|
|
17
|
+
skills: ['database/prisma', 'database/drizzle'],
|
|
18
|
+
category: 'database'
|
|
19
|
+
},
|
|
20
|
+
authentication: {
|
|
21
|
+
keywords: ['auth', 'login', 'signup', 'sign up', 'sign in', 'session', 'clerk', 'jwt', 'token', 'password', 'oauth', 'nextauth', 'user authentication', 'protected route'],
|
|
22
|
+
agents: ['security-expert', 'backend-expert'],
|
|
23
|
+
skills: ['auth/clerk', 'auth/nextauth'],
|
|
24
|
+
category: 'authentication'
|
|
25
|
+
},
|
|
26
|
+
frontend: {
|
|
27
|
+
keywords: ['component', 'react', 'ui', 'tailwind', 'page', 'layout', 'client component', 'server component', 'css', 'styling', 'responsive', 'mobile', 'form', 'button', 'modal', 'dropdown'],
|
|
28
|
+
agents: ['frontend-expert', 'ui-ux-expert'],
|
|
29
|
+
skills: ['ui/components', 'ui/forms'],
|
|
30
|
+
category: 'frontend'
|
|
31
|
+
},
|
|
32
|
+
api: {
|
|
33
|
+
keywords: ['api', 'endpoint', 'route', 'rest', 'graphql', 'trpc', 'fetch', 'request', 'response', 'post', 'get', 'put', 'delete', 'server action', 'route handler'],
|
|
34
|
+
agents: ['api-expert', 'backend-expert'],
|
|
35
|
+
skills: ['api/route-handler', 'api/server-action'],
|
|
36
|
+
category: 'api'
|
|
37
|
+
},
|
|
38
|
+
payments: {
|
|
39
|
+
keywords: ['stripe', 'payment', 'subscription', 'checkout', 'billing', 'invoice', 'webhook', 'price', 'product', 'paddle', 'lemon squeezy'],
|
|
40
|
+
agents: ['backend-expert'],
|
|
41
|
+
skills: ['payments/stripe', 'payments/webhooks'],
|
|
42
|
+
category: 'payments'
|
|
43
|
+
},
|
|
44
|
+
testing: {
|
|
45
|
+
keywords: ['test', 'jest', 'vitest', 'playwright', 'coverage', 'unit test', 'integration test', 'e2e', 'mock', 'spy', 'assertion', 'expect'],
|
|
46
|
+
agents: ['testing-expert', 'code-review-expert'],
|
|
47
|
+
skills: ['testing/vitest', 'testing/playwright'],
|
|
48
|
+
category: 'testing'
|
|
49
|
+
},
|
|
50
|
+
performance: {
|
|
51
|
+
keywords: ['performance', 'optimize', 'cache', 'slow', 'speed', 'lighthouse', 'core web vitals', 'bundle size', 'lazy load', 'memory leak', 'profiling'],
|
|
52
|
+
agents: ['performance-expert'],
|
|
53
|
+
skills: ['performance/caching', 'performance/optimization'],
|
|
54
|
+
category: 'performance'
|
|
55
|
+
},
|
|
56
|
+
deployment: {
|
|
57
|
+
keywords: ['deploy', 'vercel', 'production', 'ci', 'cd', 'github actions', 'docker', 'kubernetes', 'hosting', 'environment', 'build', 'release'],
|
|
58
|
+
agents: ['devops-expert', 'vercel-expert'],
|
|
59
|
+
skills: ['deployment/vercel', 'deployment/docker'],
|
|
60
|
+
category: 'deployment'
|
|
61
|
+
},
|
|
62
|
+
security: {
|
|
63
|
+
keywords: ['security', 'vulnerability', 'owasp', 'xss', 'csrf', 'injection', 'sanitize', 'validate', 'rate limit', 'cors', 'helmet', 'encryption'],
|
|
64
|
+
agents: ['security-expert'],
|
|
65
|
+
skills: ['security/validation', 'security/rate-limiting'],
|
|
66
|
+
category: 'security'
|
|
67
|
+
},
|
|
68
|
+
ai: {
|
|
69
|
+
keywords: ['claude', 'openai', 'gpt', 'llm', 'ai', 'anthropic', 'gemini', 'embedding', 'vector', 'rag', 'prompt', 'completion', 'streaming'],
|
|
70
|
+
agents: ['backend-expert'],
|
|
71
|
+
skills: ['ai/streaming', 'ai/tool-use'],
|
|
72
|
+
category: 'ai'
|
|
73
|
+
},
|
|
74
|
+
architecture: {
|
|
75
|
+
keywords: ['architecture', 'design pattern', 'refactor', 'structure', 'module', 'clean code', 'solid', 'dependency injection', 'microservice', 'monolith'],
|
|
76
|
+
agents: ['architecture-expert', 'code-review-expert'],
|
|
77
|
+
skills: ['architecture/patterns'],
|
|
78
|
+
category: 'architecture'
|
|
79
|
+
},
|
|
80
|
+
accessibility: {
|
|
81
|
+
keywords: ['accessibility', 'a11y', 'aria', 'screen reader', 'keyboard navigation', 'wcag', 'contrast', 'focus', 'semantic'],
|
|
82
|
+
agents: ['ui-ux-expert', 'frontend-expert'],
|
|
83
|
+
skills: ['ui/accessibility'],
|
|
84
|
+
category: 'accessibility'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Detect context from a message/prompt
|
|
90
|
+
* @param {string} message - The user message or prompt
|
|
91
|
+
* @returns {object} Detection result with matches, agents, skills, and confidence
|
|
92
|
+
*/
|
|
93
|
+
function detectContext(message) {
|
|
94
|
+
const messageLower = message.toLowerCase();
|
|
95
|
+
const matches = [];
|
|
96
|
+
const suggestedAgents = new Set();
|
|
97
|
+
const suggestedSkills = new Set();
|
|
98
|
+
let totalKeywordMatches = 0;
|
|
99
|
+
|
|
100
|
+
// Check each trigger category
|
|
101
|
+
for (const [triggerName, trigger] of Object.entries(CONTEXT_TRIGGERS)) {
|
|
102
|
+
const matchedKeywords = [];
|
|
103
|
+
|
|
104
|
+
// Check for keyword matches
|
|
105
|
+
for (const keyword of trigger.keywords) {
|
|
106
|
+
if (messageLower.includes(keyword)) {
|
|
107
|
+
matchedKeywords.push(keyword);
|
|
108
|
+
totalKeywordMatches++;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// If we found matches, add this category
|
|
113
|
+
if (matchedKeywords.length > 0) {
|
|
114
|
+
matches.push({
|
|
115
|
+
category: trigger.category,
|
|
116
|
+
triggerName,
|
|
117
|
+
matchedKeywords,
|
|
118
|
+
keywordCount: matchedKeywords.length
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Add suggested agents and skills
|
|
122
|
+
trigger.agents.forEach(a => suggestedAgents.add(a));
|
|
123
|
+
trigger.skills.forEach(s => suggestedSkills.add(s));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Sort matches by keyword count (most relevant first)
|
|
128
|
+
matches.sort((a, b) => b.keywordCount - a.keywordCount);
|
|
129
|
+
|
|
130
|
+
// Calculate confidence (0-1)
|
|
131
|
+
// More keyword matches = higher confidence
|
|
132
|
+
const confidence = Math.min(totalKeywordMatches / 5, 1);
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
matches,
|
|
136
|
+
suggestedAgents: Array.from(suggestedAgents),
|
|
137
|
+
suggestedSkills: Array.from(suggestedSkills),
|
|
138
|
+
confidence,
|
|
139
|
+
primaryCategory: matches[0]?.category || null
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get agents for a specific category
|
|
145
|
+
* @param {string} category - Category name
|
|
146
|
+
* @returns {string[]} Array of agent names
|
|
147
|
+
*/
|
|
148
|
+
function getAgentsForCategory(category) {
|
|
149
|
+
const trigger = Object.values(CONTEXT_TRIGGERS).find(t => t.category === category);
|
|
150
|
+
return trigger?.agents || [];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Get skills for a specific category
|
|
155
|
+
* @param {string} category - Category name
|
|
156
|
+
* @returns {string[]} Array of skill names
|
|
157
|
+
*/
|
|
158
|
+
function getSkillsForCategory(category) {
|
|
159
|
+
const trigger = Object.values(CONTEXT_TRIGGERS).find(t => t.category === category);
|
|
160
|
+
return trigger?.skills || [];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get all available categories
|
|
165
|
+
* @returns {string[]} Array of category names
|
|
166
|
+
*/
|
|
167
|
+
function getCategories() {
|
|
168
|
+
return Object.values(CONTEXT_TRIGGERS).map(t => t.category);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = {
|
|
172
|
+
CONTEXT_TRIGGERS,
|
|
173
|
+
detectContext,
|
|
174
|
+
getAgentsForCategory,
|
|
175
|
+
getSkillsForCategory,
|
|
176
|
+
getCategories
|
|
177
|
+
};
|
package/hooks/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootspring Hook System
|
|
3
|
+
* Automatic context injection for AI assistants
|
|
4
|
+
*
|
|
5
|
+
* @package bootspring
|
|
6
|
+
* @module hooks
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const contextDetector = require('./context-detector');
|
|
10
|
+
const promptEnhancer = require('./prompt-enhancer');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
// Main exports
|
|
14
|
+
contextDetector,
|
|
15
|
+
promptEnhancer,
|
|
16
|
+
|
|
17
|
+
// Convenience functions
|
|
18
|
+
detectContext: contextDetector.detectContext,
|
|
19
|
+
enhancePrompt: promptEnhancer.enhance,
|
|
20
|
+
|
|
21
|
+
// Hook registration for Claude Code
|
|
22
|
+
hooks: {
|
|
23
|
+
UserPromptSubmit: async (prompt, projectContext) => {
|
|
24
|
+
// Detect context from the prompt
|
|
25
|
+
const detection = contextDetector.detectContext(prompt);
|
|
26
|
+
|
|
27
|
+
// If relevant context detected, enhance the response
|
|
28
|
+
if (detection.matches.length > 0) {
|
|
29
|
+
return promptEnhancer.enhance(prompt, detection, projectContext);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootspring Prompt Enhancer
|
|
3
|
+
* Enhances prompts with relevant context based on detection
|
|
4
|
+
*
|
|
5
|
+
* @package bootspring
|
|
6
|
+
* @module hooks/prompt-enhancer
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Agent context templates
|
|
14
|
+
*/
|
|
15
|
+
const AGENT_CONTEXTS = {
|
|
16
|
+
'database-expert': `
|
|
17
|
+
You have access to the Database Expert agent. Consider:
|
|
18
|
+
- Database schema design and normalization
|
|
19
|
+
- Query optimization and indexing
|
|
20
|
+
- Migration strategies
|
|
21
|
+
- ORM best practices (Prisma/Drizzle)
|
|
22
|
+
`,
|
|
23
|
+
'security-expert': `
|
|
24
|
+
You have access to the Security Expert agent. Consider:
|
|
25
|
+
- OWASP Top 10 vulnerabilities
|
|
26
|
+
- Input validation and sanitization
|
|
27
|
+
- Authentication and authorization patterns
|
|
28
|
+
- Secure session management
|
|
29
|
+
`,
|
|
30
|
+
'frontend-expert': `
|
|
31
|
+
You have access to the Frontend Expert agent. Consider:
|
|
32
|
+
- React component patterns (Server vs Client)
|
|
33
|
+
- Tailwind CSS best practices
|
|
34
|
+
- State management approaches
|
|
35
|
+
- Responsive design
|
|
36
|
+
`,
|
|
37
|
+
'backend-expert': `
|
|
38
|
+
You have access to the Backend Expert agent. Consider:
|
|
39
|
+
- API design patterns
|
|
40
|
+
- Server Actions vs Route Handlers
|
|
41
|
+
- Error handling strategies
|
|
42
|
+
- Data validation with Zod
|
|
43
|
+
`,
|
|
44
|
+
'api-expert': `
|
|
45
|
+
You have access to the API Expert agent. Consider:
|
|
46
|
+
- RESTful design principles
|
|
47
|
+
- GraphQL vs REST trade-offs
|
|
48
|
+
- API versioning
|
|
49
|
+
- Rate limiting and caching
|
|
50
|
+
`,
|
|
51
|
+
'testing-expert': `
|
|
52
|
+
You have access to the Testing Expert agent. Consider:
|
|
53
|
+
- Test pyramid (unit, integration, e2e)
|
|
54
|
+
- Mocking strategies
|
|
55
|
+
- Coverage goals
|
|
56
|
+
- Test organization
|
|
57
|
+
`,
|
|
58
|
+
'performance-expert': `
|
|
59
|
+
You have access to the Performance Expert agent. Consider:
|
|
60
|
+
- Core Web Vitals optimization
|
|
61
|
+
- Bundle size reduction
|
|
62
|
+
- Caching strategies
|
|
63
|
+
- Lazy loading
|
|
64
|
+
`,
|
|
65
|
+
'devops-expert': `
|
|
66
|
+
You have access to the DevOps Expert agent. Consider:
|
|
67
|
+
- CI/CD pipeline design
|
|
68
|
+
- Environment management
|
|
69
|
+
- Deployment strategies
|
|
70
|
+
- Monitoring and logging
|
|
71
|
+
`,
|
|
72
|
+
'ui-ux-expert': `
|
|
73
|
+
You have access to the UI/UX Expert agent. Consider:
|
|
74
|
+
- User experience patterns
|
|
75
|
+
- Accessibility (a11y) requirements
|
|
76
|
+
- Design system consistency
|
|
77
|
+
- Mobile-first approach
|
|
78
|
+
`,
|
|
79
|
+
'architecture-expert': `
|
|
80
|
+
You have access to the Architecture Expert agent. Consider:
|
|
81
|
+
- System design patterns
|
|
82
|
+
- Code organization
|
|
83
|
+
- Dependency management
|
|
84
|
+
- Scalability concerns
|
|
85
|
+
`,
|
|
86
|
+
'code-review-expert': `
|
|
87
|
+
You have access to the Code Review Expert agent. Consider:
|
|
88
|
+
- Code quality standards
|
|
89
|
+
- Best practices
|
|
90
|
+
- Potential improvements
|
|
91
|
+
- Technical debt
|
|
92
|
+
`,
|
|
93
|
+
'vercel-expert': `
|
|
94
|
+
You have access to the Vercel Expert agent. Consider:
|
|
95
|
+
- Vercel deployment configuration
|
|
96
|
+
- Edge functions
|
|
97
|
+
- ISR and SSR strategies
|
|
98
|
+
- Environment variables
|
|
99
|
+
`
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Skill snippet templates (simplified - would load from files in production)
|
|
104
|
+
*/
|
|
105
|
+
const SKILL_SNIPPETS = {
|
|
106
|
+
'auth/clerk': 'Use Clerk middleware for auth. Server: auth() from @clerk/nextjs/server. Client: useAuth() hook.',
|
|
107
|
+
'auth/nextauth': 'Configure NextAuth in app/api/auth/[...nextauth]/route.ts. Use getServerSession() server-side.',
|
|
108
|
+
'database/prisma': 'Use Prisma Client for queries. Run migrations with prisma migrate dev. Use transactions for multi-step operations.',
|
|
109
|
+
'database/drizzle': 'Define schema in drizzle/schema.ts. Use drizzle-kit for migrations. Type-safe queries with db.select().',
|
|
110
|
+
'api/route-handler': 'Export GET, POST, PUT, DELETE functions. Use NextRequest/NextResponse. Validate with Zod.',
|
|
111
|
+
'api/server-action': 'Mark with "use server". Return typed responses. Handle errors gracefully. Use revalidatePath/revalidateTag.',
|
|
112
|
+
'payments/stripe': 'Use Stripe.js for client-side. stripe.checkout.sessions.create() for checkout. Verify webhook signatures.',
|
|
113
|
+
'testing/vitest': 'Configure in vitest.config.ts. Use describe/it/expect. Mock with vi.mock(). Test utilities with @testing-library/react.',
|
|
114
|
+
'testing/playwright': 'Configure in playwright.config.ts. Use page.goto(), page.click(). Assert with expect(locator).',
|
|
115
|
+
'security/validation': 'Validate all inputs with Zod schemas. Sanitize HTML. Use parameterized queries.',
|
|
116
|
+
'security/rate-limiting': 'Implement with upstash/ratelimit or custom middleware. Apply to sensitive endpoints.',
|
|
117
|
+
'ai/streaming': 'Use Vercel AI SDK. stream: true option. Handle with useChat() hook or StreamingTextResponse.',
|
|
118
|
+
'ai/tool-use': 'Define tools with Zod schemas. Parse tool calls from response. Execute and return results.'
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Enhance a prompt with relevant context
|
|
123
|
+
* @param {string} originalPrompt - The original user prompt
|
|
124
|
+
* @param {object} detection - Detection result from context-detector
|
|
125
|
+
* @param {object} projectContext - Optional project context
|
|
126
|
+
* @returns {object|null} Enhanced context or null if no enhancement needed
|
|
127
|
+
*/
|
|
128
|
+
function enhance(originalPrompt, detection, projectContext = {}) {
|
|
129
|
+
if (!detection || detection.matches.length === 0) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const sections = [];
|
|
134
|
+
|
|
135
|
+
// Add agent contexts
|
|
136
|
+
if (detection.suggestedAgents.length > 0) {
|
|
137
|
+
sections.push('## Relevant Expertise\n');
|
|
138
|
+
for (const agentName of detection.suggestedAgents.slice(0, 3)) {
|
|
139
|
+
const context = AGENT_CONTEXTS[agentName];
|
|
140
|
+
if (context) {
|
|
141
|
+
sections.push(context);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Add skill hints
|
|
147
|
+
if (detection.suggestedSkills.length > 0) {
|
|
148
|
+
sections.push('\n## Recommended Patterns\n');
|
|
149
|
+
for (const skillName of detection.suggestedSkills.slice(0, 3)) {
|
|
150
|
+
const snippet = SKILL_SNIPPETS[skillName];
|
|
151
|
+
if (snippet) {
|
|
152
|
+
sections.push(`- **${skillName}**: ${snippet}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Add project context if available
|
|
158
|
+
if (projectContext.stack) {
|
|
159
|
+
sections.push('\n## Project Stack\n');
|
|
160
|
+
sections.push(`- Framework: ${projectContext.stack.framework || 'unknown'}`);
|
|
161
|
+
sections.push(`- Language: ${projectContext.stack.language || 'unknown'}`);
|
|
162
|
+
sections.push(`- Database: ${projectContext.stack.database || 'unknown'}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Add category-specific tips
|
|
166
|
+
if (detection.primaryCategory) {
|
|
167
|
+
const tips = getCategoryTips(detection.primaryCategory);
|
|
168
|
+
if (tips) {
|
|
169
|
+
sections.push(`\n## ${detection.primaryCategory.charAt(0).toUpperCase() + detection.primaryCategory.slice(1)} Tips\n`);
|
|
170
|
+
sections.push(tips);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (sections.length === 0) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
enhancedContext: sections.join('\n'),
|
|
180
|
+
agents: detection.suggestedAgents,
|
|
181
|
+
skills: detection.suggestedSkills,
|
|
182
|
+
confidence: detection.confidence,
|
|
183
|
+
category: detection.primaryCategory
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Get category-specific tips
|
|
189
|
+
* @param {string} category - Category name
|
|
190
|
+
* @returns {string|null} Tips string or null
|
|
191
|
+
*/
|
|
192
|
+
function getCategoryTips(category) {
|
|
193
|
+
const tips = {
|
|
194
|
+
database: `
|
|
195
|
+
- Always use migrations for schema changes
|
|
196
|
+
- Index frequently queried columns
|
|
197
|
+
- Use transactions for related operations
|
|
198
|
+
- Consider soft deletes for important data
|
|
199
|
+
`,
|
|
200
|
+
authentication: `
|
|
201
|
+
- Never store passwords in plain text
|
|
202
|
+
- Use secure session management
|
|
203
|
+
- Implement proper logout (invalidate tokens)
|
|
204
|
+
- Consider rate limiting login attempts
|
|
205
|
+
`,
|
|
206
|
+
frontend: `
|
|
207
|
+
- Use Server Components by default
|
|
208
|
+
- Add 'use client' only when needed
|
|
209
|
+
- Keep components focused and small
|
|
210
|
+
- Use Tailwind for consistent styling
|
|
211
|
+
`,
|
|
212
|
+
api: `
|
|
213
|
+
- Validate all inputs with Zod
|
|
214
|
+
- Return consistent error formats
|
|
215
|
+
- Use proper HTTP status codes
|
|
216
|
+
- Document your endpoints
|
|
217
|
+
`,
|
|
218
|
+
payments: `
|
|
219
|
+
- Always verify webhook signatures
|
|
220
|
+
- Store Stripe IDs in your database
|
|
221
|
+
- Handle subscription lifecycle events
|
|
222
|
+
- Test with Stripe CLI locally
|
|
223
|
+
`,
|
|
224
|
+
testing: `
|
|
225
|
+
- Write tests before complex refactors
|
|
226
|
+
- Mock external services
|
|
227
|
+
- Aim for 80%+ coverage on critical paths
|
|
228
|
+
- Use fixtures for test data
|
|
229
|
+
`,
|
|
230
|
+
security: `
|
|
231
|
+
- Validate and sanitize all inputs
|
|
232
|
+
- Use HTTPS everywhere
|
|
233
|
+
- Implement CSRF protection
|
|
234
|
+
- Review OWASP Top 10 regularly
|
|
235
|
+
`,
|
|
236
|
+
performance: `
|
|
237
|
+
- Profile before optimizing
|
|
238
|
+
- Lazy load non-critical resources
|
|
239
|
+
- Use appropriate caching strategies
|
|
240
|
+
- Monitor Core Web Vitals
|
|
241
|
+
`,
|
|
242
|
+
deployment: `
|
|
243
|
+
- Use environment variables for config
|
|
244
|
+
- Set up staging environments
|
|
245
|
+
- Implement health checks
|
|
246
|
+
- Have a rollback strategy
|
|
247
|
+
`
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
return tips[category] || null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Format enhanced context for display
|
|
255
|
+
* @param {object} enhancement - Enhancement result
|
|
256
|
+
* @returns {string} Formatted string
|
|
257
|
+
*/
|
|
258
|
+
function format(enhancement) {
|
|
259
|
+
if (!enhancement) return '';
|
|
260
|
+
|
|
261
|
+
const lines = [];
|
|
262
|
+
|
|
263
|
+
lines.push('---');
|
|
264
|
+
lines.push('**Bootspring Context Enhancement**');
|
|
265
|
+
lines.push(`Category: ${enhancement.category || 'general'}`);
|
|
266
|
+
lines.push(`Confidence: ${Math.round(enhancement.confidence * 100)}%`);
|
|
267
|
+
|
|
268
|
+
if (enhancement.agents.length > 0) {
|
|
269
|
+
lines.push(`Agents: ${enhancement.agents.join(', ')}`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (enhancement.skills.length > 0) {
|
|
273
|
+
lines.push(`Skills: ${enhancement.skills.join(', ')}`);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
lines.push('---');
|
|
277
|
+
lines.push(enhancement.enhancedContext);
|
|
278
|
+
lines.push('---');
|
|
279
|
+
|
|
280
|
+
return lines.join('\n');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
module.exports = {
|
|
284
|
+
enhance,
|
|
285
|
+
format,
|
|
286
|
+
getCategoryTips,
|
|
287
|
+
AGENT_CONTEXTS,
|
|
288
|
+
SKILL_SNIPPETS
|
|
289
|
+
};
|