@codebakers/mcp 5.2.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/INSTALL.md +221 -0
- package/LICENSE +21 -0
- package/README.md +412 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +236 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +526 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/analyze-mockups.d.ts +18 -0
- package/dist/tools/analyze-mockups.d.ts.map +1 -0
- package/dist/tools/analyze-mockups.js +497 -0
- package/dist/tools/analyze-mockups.js.map +1 -0
- package/dist/tools/autonomous-build.d.ts +19 -0
- package/dist/tools/autonomous-build.d.ts.map +1 -0
- package/dist/tools/autonomous-build.js +287 -0
- package/dist/tools/autonomous-build.js.map +1 -0
- package/dist/tools/check-gate.d.ts +21 -0
- package/dist/tools/check-gate.d.ts.map +1 -0
- package/dist/tools/check-gate.js +446 -0
- package/dist/tools/check-gate.js.map +1 -0
- package/dist/tools/check-scope.d.ts +22 -0
- package/dist/tools/check-scope.d.ts.map +1 -0
- package/dist/tools/check-scope.js +251 -0
- package/dist/tools/check-scope.js.map +1 -0
- package/dist/tools/deploy-vercel.d.ts +18 -0
- package/dist/tools/deploy-vercel.d.ts.map +1 -0
- package/dist/tools/deploy-vercel.js +178 -0
- package/dist/tools/deploy-vercel.js.map +1 -0
- package/dist/tools/diagnose-error.d.ts +20 -0
- package/dist/tools/diagnose-error.d.ts.map +1 -0
- package/dist/tools/diagnose-error.js +351 -0
- package/dist/tools/diagnose-error.js.map +1 -0
- package/dist/tools/enforce-feature.d.ts +25 -0
- package/dist/tools/enforce-feature.d.ts.map +1 -0
- package/dist/tools/enforce-feature.js +387 -0
- package/dist/tools/enforce-feature.js.map +1 -0
- package/dist/tools/execute-atomic-unit.d.ts +23 -0
- package/dist/tools/execute-atomic-unit.d.ts.map +1 -0
- package/dist/tools/execute-atomic-unit.js +107 -0
- package/dist/tools/execute-atomic-unit.js.map +1 -0
- package/dist/tools/fix-commit.d.ts +23 -0
- package/dist/tools/fix-commit.d.ts.map +1 -0
- package/dist/tools/fix-commit.js +213 -0
- package/dist/tools/fix-commit.js.map +1 -0
- package/dist/tools/fix-mockups.d.ts +21 -0
- package/dist/tools/fix-mockups.d.ts.map +1 -0
- package/dist/tools/fix-mockups.js +595 -0
- package/dist/tools/fix-mockups.js.map +1 -0
- package/dist/tools/generate-api-route.d.ts +18 -0
- package/dist/tools/generate-api-route.d.ts.map +1 -0
- package/dist/tools/generate-api-route.js +212 -0
- package/dist/tools/generate-api-route.js.map +1 -0
- package/dist/tools/generate-chatbot.d.ts +20 -0
- package/dist/tools/generate-chatbot.d.ts.map +1 -0
- package/dist/tools/generate-chatbot.js +555 -0
- package/dist/tools/generate-chatbot.js.map +1 -0
- package/dist/tools/generate-component.d.ts +18 -0
- package/dist/tools/generate-component.d.ts.map +1 -0
- package/dist/tools/generate-component.js +159 -0
- package/dist/tools/generate-component.js.map +1 -0
- package/dist/tools/generate-docs.d.ts +21 -0
- package/dist/tools/generate-docs.d.ts.map +1 -0
- package/dist/tools/generate-docs.js +782 -0
- package/dist/tools/generate-docs.js.map +1 -0
- package/dist/tools/generate-e2e-tests.d.ts +12 -0
- package/dist/tools/generate-e2e-tests.d.ts.map +1 -0
- package/dist/tools/generate-e2e-tests.js +37 -0
- package/dist/tools/generate-e2e-tests.js.map +1 -0
- package/dist/tools/generate-migration.d.ts +21 -0
- package/dist/tools/generate-migration.d.ts.map +1 -0
- package/dist/tools/generate-migration.js +94 -0
- package/dist/tools/generate-migration.js.map +1 -0
- package/dist/tools/generate-schema.d.ts +18 -0
- package/dist/tools/generate-schema.d.ts.map +1 -0
- package/dist/tools/generate-schema.js +422 -0
- package/dist/tools/generate-schema.js.map +1 -0
- package/dist/tools/generate-spec.d.ts +18 -0
- package/dist/tools/generate-spec.d.ts.map +1 -0
- package/dist/tools/generate-spec.js +446 -0
- package/dist/tools/generate-spec.js.map +1 -0
- package/dist/tools/generate-store-contracts.d.ts +17 -0
- package/dist/tools/generate-store-contracts.d.ts.map +1 -0
- package/dist/tools/generate-store-contracts.js +356 -0
- package/dist/tools/generate-store-contracts.js.map +1 -0
- package/dist/tools/generate-store.d.ts +16 -0
- package/dist/tools/generate-store.d.ts.map +1 -0
- package/dist/tools/generate-store.js +166 -0
- package/dist/tools/generate-store.js.map +1 -0
- package/dist/tools/generate-unit-tests.d.ts +14 -0
- package/dist/tools/generate-unit-tests.d.ts.map +1 -0
- package/dist/tools/generate-unit-tests.js +85 -0
- package/dist/tools/generate-unit-tests.js.map +1 -0
- package/dist/tools/get-context.d.ts +35 -0
- package/dist/tools/get-context.d.ts.map +1 -0
- package/dist/tools/get-context.js +367 -0
- package/dist/tools/get-context.js.map +1 -0
- package/dist/tools/init-session.d.ts +22 -0
- package/dist/tools/init-session.d.ts.map +1 -0
- package/dist/tools/init-session.js +232 -0
- package/dist/tools/init-session.js.map +1 -0
- package/dist/tools/map-dependencies.d.ts +25 -0
- package/dist/tools/map-dependencies.d.ts.map +1 -0
- package/dist/tools/map-dependencies.js +480 -0
- package/dist/tools/map-dependencies.js.map +1 -0
- package/dist/tools/optimize-performance.d.ts +18 -0
- package/dist/tools/optimize-performance.d.ts.map +1 -0
- package/dist/tools/optimize-performance.js +285 -0
- package/dist/tools/optimize-performance.js.map +1 -0
- package/dist/tools/run-interview.d.ts +23 -0
- package/dist/tools/run-interview.d.ts.map +1 -0
- package/dist/tools/run-interview.js +371 -0
- package/dist/tools/run-interview.js.map +1 -0
- package/dist/tools/run-tests.d.ts +12 -0
- package/dist/tools/run-tests.d.ts.map +1 -0
- package/dist/tools/run-tests.js +30 -0
- package/dist/tools/run-tests.js.map +1 -0
- package/dist/tools/scan-security.d.ts +19 -0
- package/dist/tools/scan-security.d.ts.map +1 -0
- package/dist/tools/scan-security.js +358 -0
- package/dist/tools/scan-security.js.map +1 -0
- package/dist/tools/validate-accessibility.d.ts +18 -0
- package/dist/tools/validate-accessibility.d.ts.map +1 -0
- package/dist/tools/validate-accessibility.js +251 -0
- package/dist/tools/validate-accessibility.js.map +1 -0
- package/dist/tools/validate-mockups.d.ts +21 -0
- package/dist/tools/validate-mockups.d.ts.map +1 -0
- package/dist/tools/validate-mockups.js +433 -0
- package/dist/tools/validate-mockups.js.map +1 -0
- package/dist/tools/verify-completeness.d.ts +13 -0
- package/dist/tools/verify-completeness.d.ts.map +1 -0
- package/dist/tools/verify-completeness.js +68 -0
- package/dist/tools/verify-completeness.js.map +1 -0
- package/dist/tools/verify-mockups.d.ts +14 -0
- package/dist/tools/verify-mockups.d.ts.map +1 -0
- package/dist/tools/verify-mockups.js +85 -0
- package/dist/tools/verify-mockups.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codebakers_generate_chatbot
|
|
3
|
+
*
|
|
4
|
+
* AI Chatbot Generator - In-App Help Assistant
|
|
5
|
+
*
|
|
6
|
+
* Generates AI chatbot component that:
|
|
7
|
+
* - Knows entire source code
|
|
8
|
+
* - Can answer questions about the app
|
|
9
|
+
* - Helps users navigate features
|
|
10
|
+
* - Integrates into help section
|
|
11
|
+
* - Uses RAG (retrieval-augmented generation)
|
|
12
|
+
*/
|
|
13
|
+
import * as fs from 'fs/promises';
|
|
14
|
+
import * as path from 'path';
|
|
15
|
+
export async function generateChatbot(args = {}) {
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
const { position = 'bottom-right', include_api_knowledge = true, include_component_knowledge = true } = args;
|
|
18
|
+
console.error('🍞 CodeBakers: Generating AI Chatbot');
|
|
19
|
+
try {
|
|
20
|
+
// Step 1: Index codebase for RAG
|
|
21
|
+
console.error('[1/5] Indexing codebase...');
|
|
22
|
+
const knowledge = await indexCodebase(cwd, include_api_knowledge, include_component_knowledge);
|
|
23
|
+
// Step 2: Generate chatbot component
|
|
24
|
+
console.error('[2/5] Generating chatbot component...');
|
|
25
|
+
await generateChatbotComponent(cwd, knowledge, position);
|
|
26
|
+
// Step 3: Generate knowledge base file
|
|
27
|
+
console.error('[3/5] Generating knowledge base...');
|
|
28
|
+
await generateKnowledgeBase(cwd, knowledge);
|
|
29
|
+
// Step 4: Generate chatbot API route
|
|
30
|
+
console.error('[4/5] Generating chatbot API...');
|
|
31
|
+
await generateChatbotAPI(cwd);
|
|
32
|
+
// Step 5: Add to root layout
|
|
33
|
+
console.error('[5/5] Integrating into app...');
|
|
34
|
+
await integrateIntoLayout(cwd);
|
|
35
|
+
return generateChatbotReport(knowledge);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return `🍞 CodeBakers: Chatbot Generation Failed\n\nError: ${error instanceof Error ? error.message : String(error)}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function indexCodebase(cwd, includeAPI, includeComponents) {
|
|
42
|
+
const knowledge = {
|
|
43
|
+
features: [],
|
|
44
|
+
api_routes: [],
|
|
45
|
+
components: [],
|
|
46
|
+
pages: [],
|
|
47
|
+
common_tasks: []
|
|
48
|
+
};
|
|
49
|
+
// Index features from FLOWS.md
|
|
50
|
+
try {
|
|
51
|
+
const flowsPath = path.join(cwd, 'FLOWS.md');
|
|
52
|
+
const flows = await fs.readFile(flowsPath, 'utf-8');
|
|
53
|
+
const flowMatches = flows.matchAll(/## (\d+)\. (.+?) \((.+?)\)/g);
|
|
54
|
+
for (const match of flowMatches) {
|
|
55
|
+
knowledge.features.push({
|
|
56
|
+
name: match[2],
|
|
57
|
+
priority: match[3],
|
|
58
|
+
description: `Feature: ${match[2]}`
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// FLOWS.md doesn't exist
|
|
64
|
+
}
|
|
65
|
+
// Index API routes
|
|
66
|
+
if (includeAPI) {
|
|
67
|
+
const apiDir = path.join(cwd, 'src', 'app', 'api');
|
|
68
|
+
await indexAPIRoutes(apiDir, '', knowledge.api_routes);
|
|
69
|
+
}
|
|
70
|
+
// Index components
|
|
71
|
+
if (includeComponents) {
|
|
72
|
+
const componentsDir = path.join(cwd, 'src', 'components');
|
|
73
|
+
await indexComponents(componentsDir, knowledge.components);
|
|
74
|
+
}
|
|
75
|
+
// Index pages
|
|
76
|
+
const appDir = path.join(cwd, 'src', 'app');
|
|
77
|
+
await indexPages(appDir, '', knowledge.pages);
|
|
78
|
+
// Add common tasks
|
|
79
|
+
knowledge.common_tasks = [
|
|
80
|
+
{
|
|
81
|
+
task: 'How do I log in?',
|
|
82
|
+
answer: 'Click the "Sign In" button in the top right corner. You can sign in with email or social providers.'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
task: 'How do I change my password?',
|
|
86
|
+
answer: 'Go to Settings → Account → Change Password.'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
task: 'Where can I find my account settings?',
|
|
90
|
+
answer: 'Click your profile picture in the top right, then select "Settings".'
|
|
91
|
+
}
|
|
92
|
+
];
|
|
93
|
+
return knowledge;
|
|
94
|
+
}
|
|
95
|
+
async function indexAPIRoutes(dir, routePath, routes) {
|
|
96
|
+
try {
|
|
97
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
98
|
+
for (const entry of entries) {
|
|
99
|
+
const fullPath = path.join(dir, entry.name);
|
|
100
|
+
if (entry.isDirectory()) {
|
|
101
|
+
const newPath = entry.name.startsWith('[') && entry.name.endsWith(']')
|
|
102
|
+
? `${routePath}/{${entry.name.slice(1, -1)}}`
|
|
103
|
+
: `${routePath}/${entry.name}`;
|
|
104
|
+
await indexAPIRoutes(fullPath, newPath, routes);
|
|
105
|
+
}
|
|
106
|
+
else if (entry.name === 'route.ts' || entry.name === 'route.js') {
|
|
107
|
+
const content = await fs.readFile(fullPath, 'utf-8');
|
|
108
|
+
const methods = [];
|
|
109
|
+
if (content.includes('export async function GET'))
|
|
110
|
+
methods.push('GET');
|
|
111
|
+
if (content.includes('export async function POST'))
|
|
112
|
+
methods.push('POST');
|
|
113
|
+
if (content.includes('export async function PUT'))
|
|
114
|
+
methods.push('PUT');
|
|
115
|
+
if (content.includes('export async function DELETE'))
|
|
116
|
+
methods.push('DELETE');
|
|
117
|
+
routes.push({
|
|
118
|
+
path: `/api${routePath}`,
|
|
119
|
+
methods,
|
|
120
|
+
description: `API endpoint for ${routePath.split('/').pop() || 'resource'}`
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Directory doesn't exist
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function indexComponents(dir, components) {
|
|
130
|
+
try {
|
|
131
|
+
const files = await fs.readdir(dir);
|
|
132
|
+
for (const file of files) {
|
|
133
|
+
if (file.endsWith('.tsx') || file.endsWith('.jsx')) {
|
|
134
|
+
const filePath = path.join(dir, file);
|
|
135
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
136
|
+
const match = content.match(/export\s+(?:default\s+)?function\s+(\w+)/);
|
|
137
|
+
const name = match ? match[1] : file.replace(/\.(tsx|jsx)$/, '');
|
|
138
|
+
components.push({
|
|
139
|
+
name,
|
|
140
|
+
file,
|
|
141
|
+
description: `UI component: ${name}`
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// Components directory doesn't exist
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async function indexPages(dir, routePath, pages) {
|
|
151
|
+
try {
|
|
152
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
153
|
+
for (const entry of entries) {
|
|
154
|
+
const fullPath = path.join(dir, entry.name);
|
|
155
|
+
if (entry.isDirectory() && !entry.name.startsWith('_') && entry.name !== 'api') {
|
|
156
|
+
const newPath = entry.name.startsWith('[') && entry.name.endsWith(']')
|
|
157
|
+
? `${routePath}/{${entry.name.slice(1, -1)}}`
|
|
158
|
+
: entry.name.startsWith('(') && entry.name.endsWith(')')
|
|
159
|
+
? routePath
|
|
160
|
+
: `${routePath}/${entry.name}`;
|
|
161
|
+
await indexPages(fullPath, newPath, pages);
|
|
162
|
+
}
|
|
163
|
+
else if (entry.name === 'page.tsx' || entry.name === 'page.jsx') {
|
|
164
|
+
pages.push({
|
|
165
|
+
path: routePath || '/',
|
|
166
|
+
description: `Page: ${routePath || 'Home'}`
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// Directory doesn't exist
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async function generateChatbotComponent(cwd, knowledge, position) {
|
|
176
|
+
const component = `'use client';
|
|
177
|
+
|
|
178
|
+
import { useState, useRef, useEffect } from 'react';
|
|
179
|
+
|
|
180
|
+
interface Message {
|
|
181
|
+
role: 'user' | 'assistant';
|
|
182
|
+
content: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export default function HelpChatbot() {
|
|
186
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
187
|
+
const [messages, setMessages] = useState<Message[]>([
|
|
188
|
+
{
|
|
189
|
+
role: 'assistant',
|
|
190
|
+
content: 'Hi! I\\'m your AI assistant. I know everything about this app and can help you navigate features, answer questions, or troubleshoot issues. What can I help you with?'
|
|
191
|
+
}
|
|
192
|
+
]);
|
|
193
|
+
const [input, setInput] = useState('');
|
|
194
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
195
|
+
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
196
|
+
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
199
|
+
}, [messages]);
|
|
200
|
+
|
|
201
|
+
const sendMessage = async () => {
|
|
202
|
+
if (!input.trim() || isLoading) return;
|
|
203
|
+
|
|
204
|
+
const userMessage: Message = { role: 'user', content: input };
|
|
205
|
+
setMessages(prev => [...prev, userMessage]);
|
|
206
|
+
setInput('');
|
|
207
|
+
setIsLoading(true);
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
const response = await fetch('/api/chatbot', {
|
|
211
|
+
method: 'POST',
|
|
212
|
+
headers: { 'Content-Type': 'application/json' },
|
|
213
|
+
body: JSON.stringify({ message: input })
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const data = await response.json();
|
|
217
|
+
|
|
218
|
+
const assistantMessage: Message = {
|
|
219
|
+
role: 'assistant',
|
|
220
|
+
content: data.response || 'Sorry, I couldn\\'t process that request.'
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
setMessages(prev => [...prev, assistantMessage]);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
const errorMessage: Message = {
|
|
226
|
+
role: 'assistant',
|
|
227
|
+
content: 'Sorry, I encountered an error. Please try again.'
|
|
228
|
+
};
|
|
229
|
+
setMessages(prev => [...prev, errorMessage]);
|
|
230
|
+
} finally {
|
|
231
|
+
setIsLoading(false);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const handleKeyPress = (e: React.KeyboardEvent) => {
|
|
236
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
sendMessage();
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const positionClasses = {
|
|
243
|
+
'bottom-right': 'bottom-4 right-4',
|
|
244
|
+
'bottom-left': 'bottom-4 left-4',
|
|
245
|
+
'sidebar': 'top-20 right-4'
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<>
|
|
250
|
+
{/* Chat Button */}
|
|
251
|
+
{!isOpen && (
|
|
252
|
+
<button
|
|
253
|
+
onClick={() => setIsOpen(true)}
|
|
254
|
+
className={\`fixed \${positionClasses['${position}']} z-50 bg-blue-600 text-white rounded-full p-4 shadow-lg hover:bg-blue-700 transition-all\`}
|
|
255
|
+
aria-label="Open help chat"
|
|
256
|
+
>
|
|
257
|
+
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
258
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" />
|
|
259
|
+
</svg>
|
|
260
|
+
</button>
|
|
261
|
+
)}
|
|
262
|
+
|
|
263
|
+
{/* Chat Window */}
|
|
264
|
+
{isOpen && (
|
|
265
|
+
<div className={\`fixed \${positionClasses['${position}']} z-50 w-96 h-[500px] bg-white border border-gray-200 rounded-lg shadow-xl flex flex-col\`}>
|
|
266
|
+
{/* Header */}
|
|
267
|
+
<div className="flex items-center justify-between p-4 border-b bg-blue-600 text-white rounded-t-lg">
|
|
268
|
+
<div className="flex items-center gap-2">
|
|
269
|
+
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
270
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" />
|
|
271
|
+
</svg>
|
|
272
|
+
<h3 className="font-semibold">Help Assistant</h3>
|
|
273
|
+
</div>
|
|
274
|
+
<button
|
|
275
|
+
onClick={() => setIsOpen(false)}
|
|
276
|
+
className="hover:bg-blue-700 rounded p-1 transition-colors"
|
|
277
|
+
aria-label="Close chat"
|
|
278
|
+
>
|
|
279
|
+
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
280
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
281
|
+
</svg>
|
|
282
|
+
</button>
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
{/* Messages */}
|
|
286
|
+
<div className="flex-1 overflow-y-auto p-4 space-y-4">
|
|
287
|
+
{messages.map((message, index) => (
|
|
288
|
+
<div
|
|
289
|
+
key={index}
|
|
290
|
+
className={\`flex \${message.role === 'user' ? 'justify-end' : 'justify-start'}\`}
|
|
291
|
+
>
|
|
292
|
+
<div
|
|
293
|
+
className={\`max-w-[80%] rounded-lg px-4 py-2 \${
|
|
294
|
+
message.role === 'user'
|
|
295
|
+
? 'bg-blue-600 text-white'
|
|
296
|
+
: 'bg-gray-100 text-gray-900'
|
|
297
|
+
}\`}
|
|
298
|
+
>
|
|
299
|
+
<p className="text-sm whitespace-pre-wrap">{message.content}</p>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
))}
|
|
303
|
+
{isLoading && (
|
|
304
|
+
<div className="flex justify-start">
|
|
305
|
+
<div className="bg-gray-100 rounded-lg px-4 py-2">
|
|
306
|
+
<div className="flex gap-1">
|
|
307
|
+
<div className="w-2 h-2 bg-gray-400 rounded-full animate-bounce" style={{ animationDelay: '0ms' }}></div>
|
|
308
|
+
<div className="w-2 h-2 bg-gray-400 rounded-full animate-bounce" style={{ animationDelay: '150ms' }}></div>
|
|
309
|
+
<div className="w-2 h-2 bg-gray-400 rounded-full animate-bounce" style={{ animationDelay: '300ms' }}></div>
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
</div>
|
|
313
|
+
)}
|
|
314
|
+
<div ref={messagesEndRef} />
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
{/* Input */}
|
|
318
|
+
<div className="p-4 border-t">
|
|
319
|
+
<div className="flex gap-2">
|
|
320
|
+
<input
|
|
321
|
+
type="text"
|
|
322
|
+
value={input}
|
|
323
|
+
onChange={(e) => setInput(e.target.value)}
|
|
324
|
+
onKeyPress={handleKeyPress}
|
|
325
|
+
placeholder="Ask me anything..."
|
|
326
|
+
className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"
|
|
327
|
+
disabled={isLoading}
|
|
328
|
+
/>
|
|
329
|
+
<button
|
|
330
|
+
onClick={sendMessage}
|
|
331
|
+
disabled={!input.trim() || isLoading}
|
|
332
|
+
className="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
|
333
|
+
>
|
|
334
|
+
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
335
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
|
|
336
|
+
</svg>
|
|
337
|
+
</button>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
)}
|
|
342
|
+
</>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
`;
|
|
346
|
+
const componentPath = path.join(cwd, 'src', 'components', 'HelpChatbot.tsx');
|
|
347
|
+
await fs.mkdir(path.dirname(componentPath), { recursive: true });
|
|
348
|
+
await fs.writeFile(componentPath, component, 'utf-8');
|
|
349
|
+
}
|
|
350
|
+
async function generateKnowledgeBase(cwd, knowledge) {
|
|
351
|
+
const knowledgeFile = `// Auto-generated knowledge base for AI chatbot
|
|
352
|
+
// This file contains indexed information about the app
|
|
353
|
+
|
|
354
|
+
export const appKnowledge = ${JSON.stringify(knowledge, null, 2)};
|
|
355
|
+
|
|
356
|
+
export function searchKnowledge(query: string): any[] {
|
|
357
|
+
const results: any[] = [];
|
|
358
|
+
const lowerQuery = query.toLowerCase();
|
|
359
|
+
|
|
360
|
+
// Search features
|
|
361
|
+
for (const feature of appKnowledge.features) {
|
|
362
|
+
if (feature.name.toLowerCase().includes(lowerQuery)) {
|
|
363
|
+
results.push({
|
|
364
|
+
type: 'feature',
|
|
365
|
+
relevance: 0.9,
|
|
366
|
+
data: feature
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Search API routes
|
|
372
|
+
for (const route of appKnowledge.api_routes) {
|
|
373
|
+
if (route.path.toLowerCase().includes(lowerQuery)) {
|
|
374
|
+
results.push({
|
|
375
|
+
type: 'api',
|
|
376
|
+
relevance: 0.8,
|
|
377
|
+
data: route
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Search components
|
|
383
|
+
for (const component of appKnowledge.components) {
|
|
384
|
+
if (component.name.toLowerCase().includes(lowerQuery)) {
|
|
385
|
+
results.push({
|
|
386
|
+
type: 'component',
|
|
387
|
+
relevance: 0.7,
|
|
388
|
+
data: component
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Search common tasks
|
|
394
|
+
for (const task of appKnowledge.common_tasks) {
|
|
395
|
+
if (task.task.toLowerCase().includes(lowerQuery) || task.answer.toLowerCase().includes(lowerQuery)) {
|
|
396
|
+
results.push({
|
|
397
|
+
type: 'task',
|
|
398
|
+
relevance: 1.0,
|
|
399
|
+
data: task
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return results.sort((a, b) => b.relevance - a.relevance).slice(0, 5);
|
|
405
|
+
}
|
|
406
|
+
`;
|
|
407
|
+
const knowledgePath = path.join(cwd, 'src', 'lib', 'chatbot-knowledge.ts');
|
|
408
|
+
await fs.mkdir(path.dirname(knowledgePath), { recursive: true });
|
|
409
|
+
await fs.writeFile(knowledgePath, knowledgeFile, 'utf-8');
|
|
410
|
+
}
|
|
411
|
+
async function generateChatbotAPI(cwd) {
|
|
412
|
+
const apiRoute = `import { NextRequest, NextResponse } from 'next/server';
|
|
413
|
+
import { searchKnowledge, appKnowledge } from '@/lib/chatbot-knowledge';
|
|
414
|
+
|
|
415
|
+
export async function POST(request: NextRequest) {
|
|
416
|
+
try {
|
|
417
|
+
const { message } = await request.json();
|
|
418
|
+
|
|
419
|
+
if (!message) {
|
|
420
|
+
return NextResponse.json({ error: 'Message is required' }, { status: 400 });
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Search knowledge base
|
|
424
|
+
const relevantInfo = searchKnowledge(message);
|
|
425
|
+
|
|
426
|
+
// Generate response based on relevant information
|
|
427
|
+
let response = generateResponse(message, relevantInfo);
|
|
428
|
+
|
|
429
|
+
return NextResponse.json({ response });
|
|
430
|
+
} catch (error) {
|
|
431
|
+
console.error('Chatbot API error:', error);
|
|
432
|
+
return NextResponse.json(
|
|
433
|
+
{ error: 'Internal server error' },
|
|
434
|
+
{ status: 500 }
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function generateResponse(message: string, relevantInfo: any[]): string {
|
|
440
|
+
const lowerMessage = message.toLowerCase();
|
|
441
|
+
|
|
442
|
+
// Handle common greetings
|
|
443
|
+
if (lowerMessage.match(/^(hi|hello|hey)/)) {
|
|
444
|
+
return "Hello! I'm your AI assistant. I know everything about this app. What would you like to know?";
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Handle feature questions
|
|
448
|
+
if (lowerMessage.includes('feature') || lowerMessage.includes('can i')) {
|
|
449
|
+
const features = relevantInfo.filter(i => i.type === 'feature');
|
|
450
|
+
if (features.length > 0) {
|
|
451
|
+
return \`Yes! We have that feature. Available features include: \${features.map(f => f.data.name).join(', ')}. Would you like to know more about any of these?\`;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// Handle navigation questions
|
|
456
|
+
if (lowerMessage.includes('how do i') || lowerMessage.includes('where')) {
|
|
457
|
+
const tasks = relevantInfo.filter(i => i.type === 'task');
|
|
458
|
+
if (tasks.length > 0) {
|
|
459
|
+
return tasks[0].data.answer;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Handle API questions
|
|
464
|
+
if (lowerMessage.includes('api') || lowerMessage.includes('endpoint')) {
|
|
465
|
+
const apis = relevantInfo.filter(i => i.type === 'api');
|
|
466
|
+
if (apis.length > 0) {
|
|
467
|
+
return \`We have these API endpoints: \${apis.map(a => \`\${a.data.path} (\${a.data.methods.join(', ')})\`).join(', ')}.\`;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Generic response with relevant info
|
|
472
|
+
if (relevantInfo.length > 0) {
|
|
473
|
+
const topResult = relevantInfo[0];
|
|
474
|
+
|
|
475
|
+
switch (topResult.type) {
|
|
476
|
+
case 'feature':
|
|
477
|
+
return \`I found information about "\${topResult.data.name}". This is a \${topResult.data.priority} priority feature. Is this what you're looking for?\`;
|
|
478
|
+
case 'component':
|
|
479
|
+
return \`I found the \${topResult.data.name} component. It's located in \${topResult.data.file}. What would you like to know about it?\`;
|
|
480
|
+
case 'api':
|
|
481
|
+
return \`The API endpoint \${topResult.data.path} supports these methods: \${topResult.data.methods.join(', ')}.\`;
|
|
482
|
+
case 'task':
|
|
483
|
+
return topResult.data.answer;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Fallback response
|
|
488
|
+
return \`I'm not sure about that. Could you rephrase your question? I can help with:
|
|
489
|
+
- App features and capabilities
|
|
490
|
+
- How to use specific functions
|
|
491
|
+
- Navigation and settings
|
|
492
|
+
- General questions about the app\`;
|
|
493
|
+
}
|
|
494
|
+
`;
|
|
495
|
+
const apiPath = path.join(cwd, 'src', 'app', 'api', 'chatbot', 'route.ts');
|
|
496
|
+
await fs.mkdir(path.dirname(apiPath), { recursive: true });
|
|
497
|
+
await fs.writeFile(apiPath, apiRoute, 'utf-8');
|
|
498
|
+
}
|
|
499
|
+
async function integrateIntoLayout(cwd) {
|
|
500
|
+
const layoutPath = path.join(cwd, 'src', 'app', 'layout.tsx');
|
|
501
|
+
try {
|
|
502
|
+
let layout = await fs.readFile(layoutPath, 'utf-8');
|
|
503
|
+
// Check if already integrated
|
|
504
|
+
if (layout.includes('HelpChatbot')) {
|
|
505
|
+
return; // Already integrated
|
|
506
|
+
}
|
|
507
|
+
// Add import
|
|
508
|
+
if (!layout.includes("import HelpChatbot from '@/components/HelpChatbot'")) {
|
|
509
|
+
layout = layout.replace(/import/, "import HelpChatbot from '@/components/HelpChatbot';\nimport");
|
|
510
|
+
}
|
|
511
|
+
// Add component before closing body tag
|
|
512
|
+
layout = layout.replace(/<\/body>/, ' <HelpChatbot />\n </body>');
|
|
513
|
+
await fs.writeFile(layoutPath, layout, 'utf-8');
|
|
514
|
+
}
|
|
515
|
+
catch {
|
|
516
|
+
// layout.tsx doesn't exist or can't modify
|
|
517
|
+
console.error('Could not integrate into layout.tsx - add <HelpChatbot /> manually');
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function generateChatbotReport(knowledge) {
|
|
521
|
+
let report = `🍞 CodeBakers: AI Chatbot Generated\n\n`;
|
|
522
|
+
report += `✅ **Chatbot component created**\n`;
|
|
523
|
+
report += `✅ **Knowledge base indexed**\n`;
|
|
524
|
+
report += `✅ **API route generated**\n`;
|
|
525
|
+
report += `✅ **Integrated into app**\n\n`;
|
|
526
|
+
report += `## Knowledge Base Indexed\n\n`;
|
|
527
|
+
report += `- **Features:** ${knowledge.features.length}\n`;
|
|
528
|
+
report += `- **API Routes:** ${knowledge.api_routes.length}\n`;
|
|
529
|
+
report += `- **Components:** ${knowledge.components.length}\n`;
|
|
530
|
+
report += `- **Pages:** ${knowledge.pages.length}\n`;
|
|
531
|
+
report += `- **Common Tasks:** ${knowledge.common_tasks.length}\n\n`;
|
|
532
|
+
report += `## Files Created\n\n`;
|
|
533
|
+
report += `- src/components/HelpChatbot.tsx (UI component)\n`;
|
|
534
|
+
report += `- src/lib/chatbot-knowledge.ts (Knowledge base)\n`;
|
|
535
|
+
report += `- src/app/api/chatbot/route.ts (API endpoint)\n`;
|
|
536
|
+
report += `- Updated: src/app/layout.tsx (Integration)\n\n`;
|
|
537
|
+
report += `## What the Chatbot Can Do\n\n`;
|
|
538
|
+
report += `- Answer questions about app features\n`;
|
|
539
|
+
report += `- Guide users through common tasks\n`;
|
|
540
|
+
report += `- Explain how to use specific functions\n`;
|
|
541
|
+
report += `- Provide navigation help\n`;
|
|
542
|
+
report += `- Reference API endpoints\n`;
|
|
543
|
+
report += `- List available components\n\n`;
|
|
544
|
+
report += `## Usage\n\n`;
|
|
545
|
+
report += `The chatbot appears as a floating button in the bottom-right corner.\n`;
|
|
546
|
+
report += `Users can click to open and ask questions about the app.\n\n`;
|
|
547
|
+
report += `**Example questions:**\n`;
|
|
548
|
+
report += `- "How do I log in?"\n`;
|
|
549
|
+
report += `- "What features are available?"\n`;
|
|
550
|
+
report += `- "Where can I change my password?"\n`;
|
|
551
|
+
report += `- "How do I [specific task]?"\n\n`;
|
|
552
|
+
report += `🤖 Your app now has an AI assistant that knows the entire codebase!\n`;
|
|
553
|
+
return report;
|
|
554
|
+
}
|
|
555
|
+
//# sourceMappingURL=generate-chatbot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-chatbot.js","sourceRoot":"","sources":["../../src/tools/generate-chatbot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAQ7B,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAoB,EAAE;IAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,EAAE,QAAQ,GAAG,cAAc,EAAE,qBAAqB,GAAG,IAAI,EAAE,2BAA2B,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAE7G,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAEtD,IAAI,CAAC;QACH,iCAAiC;QACjC,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,qBAAqB,EAAE,2BAA2B,CAAC,CAA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;IACzB,MAAM,IAAI,wEAAwE,CAAC;IACnF,MAAM,IAAI,8DAA8D,CAAC;IAEzE,MAAM,IAAI,0BAA0B,CAAC;IACrC,MAAM,IAAI,wBAAwB,CAAC;IACnC,MAAM,IAAI,oCAAoC,CAAC;IAC/C,MAAM,IAAI,uCAAuC,CAAC;IAClD,MAAM,IAAI,mCAAmC,CAAC;IAE9C,MAAM,IAAI,uEAAuE,CAAC;IAElF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codebakers_generate_component
|
|
3
|
+
*
|
|
4
|
+
* React Component Generator
|
|
5
|
+
*
|
|
6
|
+
* Generates components with all required states:
|
|
7
|
+
* - Loading, Error, Empty, Success
|
|
8
|
+
* - Mobile responsive
|
|
9
|
+
* - Accessibility
|
|
10
|
+
*/
|
|
11
|
+
interface ComponentArgs {
|
|
12
|
+
name: string;
|
|
13
|
+
entity: string;
|
|
14
|
+
type: 'list' | 'detail' | 'form';
|
|
15
|
+
}
|
|
16
|
+
export declare function generateComponent(args: ComponentArgs): Promise<string>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=generate-component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-component.d.ts","sourceRoot":"","sources":["../../src/tools/generate-component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;CAClC;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA6B5E"}
|