flowspec-mcp 4.0.0 → 4.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/README.md +1 -10
- package/dist/db.js +398 -231
- package/dist/db.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/server.js +4 -6
- package/dist/server.js.map +1 -1
- package/dist/tools/createEdge.d.ts +4 -4
- package/dist/tools/createNode.d.ts +2 -2
- package/dist/tools/updateEdge.d.ts +2 -2
- package/dist/tools/updateNode.d.ts +2 -2
- package/dist/tools/updateProject.d.ts +2 -2
- package/package.json +2 -2
- package/dist/analysis/analysisUtils.d.ts +0 -36
- package/dist/analysis/analysisUtils.js +0 -284
- package/dist/analysis/analysisUtils.js.map +0 -1
- package/dist/export/jsonExporter.d.ts +0 -7
- package/dist/export/jsonExporter.js +0 -152
- package/dist/export/jsonExporter.js.map +0 -1
- package/dist/layout/semanticLayout.d.ts +0 -24
- package/dist/layout/semanticLayout.js +0 -233
- package/dist/layout/semanticLayout.js.map +0 -1
- package/dist/tools/captureScreen.d.ts +0 -48
- package/dist/tools/captureScreen.js +0 -135
- package/dist/tools/captureScreen.js.map +0 -1
- package/dist/tools/generateSpec.d.ts +0 -26
- package/dist/tools/generateSpec.js +0 -336
- package/dist/tools/generateSpec.js.map +0 -1
- package/dist/tools/getJson.d.ts +0 -21
- package/dist/tools/getJson.js +0 -23
- package/dist/tools/getJson.js.map +0 -1
- package/dist/tools/healthCheck.d.ts +0 -8
- package/dist/tools/healthCheck.js +0 -16
- package/dist/tools/healthCheck.js.map +0 -1
- package/dist/tools/ingestCodebase.d.ts +0 -27
- package/dist/tools/ingestCodebase.js +0 -516
- package/dist/tools/ingestCodebase.js.map +0 -1
- package/dist/tools/smartLayout.d.ts +0 -30
- package/dist/tools/smartLayout.js +0 -74
- package/dist/tools/smartLayout.js.map +0 -1
|
@@ -1,516 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
export const ingestCodebaseSchema = z.object({
|
|
5
|
-
projectPath: z.string().describe('Absolute path to codebase root directory'),
|
|
6
|
-
framework: z.enum(['svelte', 'react', 'auto']).default('auto').describe('Framework to parse (auto-detects if not specified)'),
|
|
7
|
-
scope: z.string().optional().describe('Glob pattern to limit files (e.g., "src/routes/**/*.svelte")')
|
|
8
|
-
});
|
|
9
|
-
export async function handleIngestCodebase(args) {
|
|
10
|
-
// Verify project path exists
|
|
11
|
-
if (!fs.existsSync(args.projectPath)) {
|
|
12
|
-
return {
|
|
13
|
-
content: [{ type: 'text', text: `Project path not found: ${args.projectPath}` }],
|
|
14
|
-
isError: true
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
// Detect framework if auto
|
|
18
|
-
let framework = args.framework;
|
|
19
|
-
if (framework === 'auto') {
|
|
20
|
-
framework = detectFramework(args.projectPath);
|
|
21
|
-
if (framework === 'auto') {
|
|
22
|
-
return {
|
|
23
|
-
content: [
|
|
24
|
-
{
|
|
25
|
-
type: 'text',
|
|
26
|
-
text: `Could not auto-detect framework. Please specify 'svelte' or 'react'.`
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
isError: true
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
// Extract architecture based on framework
|
|
34
|
-
const architecture = framework === 'svelte'
|
|
35
|
-
? await extractSvelteArchitecture(args.projectPath, args.scope)
|
|
36
|
-
: await extractReactArchitecture(args.projectPath, args.scope);
|
|
37
|
-
// Generate YAML
|
|
38
|
-
const yaml = generateYaml(architecture);
|
|
39
|
-
// Return result
|
|
40
|
-
const lines = [];
|
|
41
|
-
lines.push(`# Codebase Ingestion Complete`);
|
|
42
|
-
lines.push(``);
|
|
43
|
-
lines.push(`**Framework:** ${framework}`);
|
|
44
|
-
lines.push(`**Path:** ${args.projectPath}`);
|
|
45
|
-
lines.push(`**Scope:** ${args.scope || 'all files'}`);
|
|
46
|
-
lines.push(``);
|
|
47
|
-
lines.push(`## Extracted Architecture`);
|
|
48
|
-
lines.push(`- DataPoints: ${architecture.dataPoints.length}`);
|
|
49
|
-
lines.push(`- Components: ${architecture.components.length}`);
|
|
50
|
-
lines.push(`- Transforms: ${architecture.transforms.length}`);
|
|
51
|
-
lines.push(`- Tables: ${architecture.tables.length}`);
|
|
52
|
-
lines.push(``);
|
|
53
|
-
lines.push(`## Generated YAML`);
|
|
54
|
-
lines.push('```yaml');
|
|
55
|
-
lines.push(yaml);
|
|
56
|
-
lines.push('```');
|
|
57
|
-
lines.push(``);
|
|
58
|
-
lines.push(`Use \`flowspec_import_yaml(projectId, yaml)\` to import this into a FlowSpec project.`);
|
|
59
|
-
return {
|
|
60
|
-
content: [{ type: 'text', text: lines.join('\n') }]
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
// ─── Framework Detection ─────────────────────────────────────────
|
|
64
|
-
function detectFramework(projectPath) {
|
|
65
|
-
try {
|
|
66
|
-
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
67
|
-
if (!fs.existsSync(packageJsonPath))
|
|
68
|
-
return 'auto';
|
|
69
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
70
|
-
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
71
|
-
if (deps['@sveltejs/kit'] || deps['svelte'])
|
|
72
|
-
return 'svelte';
|
|
73
|
-
if (deps['next'] || deps['react'])
|
|
74
|
-
return 'react';
|
|
75
|
-
// Check directory structure
|
|
76
|
-
if (fs.existsSync(path.join(projectPath, 'src/routes')))
|
|
77
|
-
return 'svelte';
|
|
78
|
-
if (fs.existsSync(path.join(projectPath, 'app')) ||
|
|
79
|
-
fs.existsSync(path.join(projectPath, 'pages'))) {
|
|
80
|
-
return 'react';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
// Ignore errors, return auto
|
|
85
|
-
}
|
|
86
|
-
return 'auto';
|
|
87
|
-
}
|
|
88
|
-
// ─── Svelte Extraction ───────────────────────────────────────────
|
|
89
|
-
async function extractSvelteArchitecture(projectPath, scopePattern) {
|
|
90
|
-
const architecture = {
|
|
91
|
-
dataPoints: [],
|
|
92
|
-
components: [],
|
|
93
|
-
transforms: [],
|
|
94
|
-
tables: []
|
|
95
|
-
};
|
|
96
|
-
// Extract types from TypeScript files
|
|
97
|
-
const typesPath = path.join(projectPath, 'src/lib/types');
|
|
98
|
-
if (fs.existsSync(typesPath)) {
|
|
99
|
-
const typeFiles = fs.readdirSync(typesPath).filter((f) => f.endsWith('.ts'));
|
|
100
|
-
for (const file of typeFiles) {
|
|
101
|
-
const filePath = path.join(typesPath, file);
|
|
102
|
-
const types = extractTypesFromFile(filePath);
|
|
103
|
-
architecture.dataPoints.push(...types);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// Extract components from routes
|
|
107
|
-
const routesPath = path.join(projectPath, 'src/routes');
|
|
108
|
-
if (fs.existsSync(routesPath)) {
|
|
109
|
-
const routes = findRoutes(routesPath, scopePattern);
|
|
110
|
-
for (const route of routes) {
|
|
111
|
-
const component = extractSvelteComponent(route);
|
|
112
|
-
if (component)
|
|
113
|
-
architecture.components.push(component);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Extract transforms from utils
|
|
117
|
-
const utilsPath = path.join(projectPath, 'src/lib/utils');
|
|
118
|
-
if (fs.existsSync(utilsPath)) {
|
|
119
|
-
const transforms = extractTransformsFromDir(utilsPath);
|
|
120
|
-
architecture.transforms.push(...transforms);
|
|
121
|
-
}
|
|
122
|
-
// Extract tables from schema files (Prisma, Drizzle, etc.)
|
|
123
|
-
const schemaFiles = findSchemaFiles(projectPath);
|
|
124
|
-
for (const schemaFile of schemaFiles) {
|
|
125
|
-
const tables = extractTablesFromSchema(schemaFile);
|
|
126
|
-
architecture.tables.push(...tables);
|
|
127
|
-
}
|
|
128
|
-
return architecture;
|
|
129
|
-
}
|
|
130
|
-
// ─── React Extraction ────────────────────────────────────────────
|
|
131
|
-
async function extractReactArchitecture(projectPath, scopePattern) {
|
|
132
|
-
const architecture = {
|
|
133
|
-
dataPoints: [],
|
|
134
|
-
components: [],
|
|
135
|
-
transforms: [],
|
|
136
|
-
tables: []
|
|
137
|
-
};
|
|
138
|
-
// Extract types
|
|
139
|
-
const typesPath = path.join(projectPath, 'types');
|
|
140
|
-
if (fs.existsSync(typesPath)) {
|
|
141
|
-
const typeFiles = fs.readdirSync(typesPath).filter((f) => f.endsWith('.ts') || f.endsWith('.tsx'));
|
|
142
|
-
for (const file of typeFiles) {
|
|
143
|
-
const filePath = path.join(typesPath, file);
|
|
144
|
-
const types = extractTypesFromFile(filePath);
|
|
145
|
-
architecture.dataPoints.push(...types);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// Extract components from pages
|
|
149
|
-
const pagesPath = path.join(projectPath, 'pages');
|
|
150
|
-
const appPath = path.join(projectPath, 'app');
|
|
151
|
-
const componentsPath = fs.existsSync(pagesPath) ? pagesPath : appPath;
|
|
152
|
-
if (fs.existsSync(componentsPath)) {
|
|
153
|
-
const routes = findReactRoutes(componentsPath, scopePattern);
|
|
154
|
-
for (const route of routes) {
|
|
155
|
-
const component = extractReactComponent(route);
|
|
156
|
-
if (component)
|
|
157
|
-
architecture.components.push(component);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Extract transforms
|
|
161
|
-
const libPath = path.join(projectPath, 'lib');
|
|
162
|
-
if (fs.existsSync(libPath)) {
|
|
163
|
-
const transforms = extractTransformsFromDir(libPath);
|
|
164
|
-
architecture.transforms.push(...transforms);
|
|
165
|
-
}
|
|
166
|
-
// Extract tables
|
|
167
|
-
const schemaFiles = findSchemaFiles(projectPath);
|
|
168
|
-
for (const schemaFile of schemaFiles) {
|
|
169
|
-
const tables = extractTablesFromSchema(schemaFile);
|
|
170
|
-
architecture.tables.push(...tables);
|
|
171
|
-
}
|
|
172
|
-
return architecture;
|
|
173
|
-
}
|
|
174
|
-
// ─── Type Extraction (Regex-based for simplicity) ────────────────
|
|
175
|
-
function extractTypesFromFile(filePath) {
|
|
176
|
-
const source = fs.readFileSync(filePath, 'utf-8');
|
|
177
|
-
const dataPoints = [];
|
|
178
|
-
// Match interface declarations: interface User { name: string; age: number; }
|
|
179
|
-
const interfaceRegex = /interface\s+(\w+)\s*\{([^}]+)\}/gs;
|
|
180
|
-
const interfaces = source.matchAll(interfaceRegex);
|
|
181
|
-
for (const match of interfaces) {
|
|
182
|
-
const [, interfaceName, body] = match;
|
|
183
|
-
// Extract properties: name: string; age?: number;
|
|
184
|
-
const propRegex = /(\w+)\??:\s*([^;]+);/g;
|
|
185
|
-
const props = body.matchAll(propRegex);
|
|
186
|
-
for (const prop of props) {
|
|
187
|
-
const [, name, type] = prop;
|
|
188
|
-
dataPoints.push({
|
|
189
|
-
id: `${interfaceName.toLowerCase()}_${name}`,
|
|
190
|
-
label: `${interfaceName}.${name}`,
|
|
191
|
-
type: mapTypeToFlowSpec(type.trim()),
|
|
192
|
-
source: 'inferred',
|
|
193
|
-
sourceDefinition: `TypeScript interface: ${interfaceName}`,
|
|
194
|
-
constraints: []
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// Match type aliases: type User = { name: string; age: number }
|
|
199
|
-
const typeRegex = /type\s+(\w+)\s*=\s*\{([^}]+)\}/gs;
|
|
200
|
-
const types = source.matchAll(typeRegex);
|
|
201
|
-
for (const match of types) {
|
|
202
|
-
const [, typeName, body] = match;
|
|
203
|
-
const propRegex = /(\w+)\??:\s*([^;,]+)/g;
|
|
204
|
-
const props = body.matchAll(propRegex);
|
|
205
|
-
for (const prop of props) {
|
|
206
|
-
const [, name, type] = prop;
|
|
207
|
-
dataPoints.push({
|
|
208
|
-
id: `${typeName.toLowerCase()}_${name}`,
|
|
209
|
-
label: `${typeName}.${name}`,
|
|
210
|
-
type: mapTypeToFlowSpec(type.trim()),
|
|
211
|
-
source: 'inferred',
|
|
212
|
-
sourceDefinition: `TypeScript type: ${typeName}`,
|
|
213
|
-
constraints: []
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return dataPoints;
|
|
218
|
-
}
|
|
219
|
-
function mapTypeToFlowSpec(tsType) {
|
|
220
|
-
if (tsType.includes('string'))
|
|
221
|
-
return 'string';
|
|
222
|
-
if (tsType.includes('number'))
|
|
223
|
-
return 'number';
|
|
224
|
-
if (tsType.includes('boolean'))
|
|
225
|
-
return 'boolean';
|
|
226
|
-
if (tsType.includes('[]') || tsType.includes('Array'))
|
|
227
|
-
return 'array';
|
|
228
|
-
return 'object';
|
|
229
|
-
}
|
|
230
|
-
// ─── Component Extraction ────────────────────────────────────────
|
|
231
|
-
function findRoutes(routesPath, scopePattern) {
|
|
232
|
-
const routes = [];
|
|
233
|
-
function traverse(dir) {
|
|
234
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
235
|
-
for (const entry of entries) {
|
|
236
|
-
const fullPath = path.join(dir, entry.name);
|
|
237
|
-
if (entry.isDirectory()) {
|
|
238
|
-
traverse(fullPath);
|
|
239
|
-
}
|
|
240
|
-
else if (entry.name === '+page.svelte') {
|
|
241
|
-
routes.push(path.dirname(fullPath));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
traverse(routesPath);
|
|
246
|
-
return routes;
|
|
247
|
-
}
|
|
248
|
-
function findReactRoutes(componentsPath, scopePattern) {
|
|
249
|
-
const routes = [];
|
|
250
|
-
function traverse(dir) {
|
|
251
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
252
|
-
for (const entry of entries) {
|
|
253
|
-
const fullPath = path.join(dir, entry.name);
|
|
254
|
-
if (entry.isDirectory()) {
|
|
255
|
-
traverse(fullPath);
|
|
256
|
-
}
|
|
257
|
-
else if (entry.name.endsWith('.tsx') ||
|
|
258
|
-
entry.name.endsWith('.jsx') ||
|
|
259
|
-
entry.name === 'page.tsx') {
|
|
260
|
-
routes.push(fullPath);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
traverse(componentsPath);
|
|
265
|
-
return routes;
|
|
266
|
-
}
|
|
267
|
-
function extractSvelteComponent(routePath) {
|
|
268
|
-
const pageFile = path.join(routePath, '+page.svelte');
|
|
269
|
-
if (!fs.existsSync(pageFile))
|
|
270
|
-
return null;
|
|
271
|
-
const source = fs.readFileSync(pageFile, 'utf-8');
|
|
272
|
-
const routeName = path.basename(routePath);
|
|
273
|
-
// Simple regex-based extraction
|
|
274
|
-
// Find bind:value={...} for captures
|
|
275
|
-
const bindRegex = /bind:value=\{(\w+)\}/g;
|
|
276
|
-
const captures = [...source.matchAll(bindRegex)].map((m) => m[1]);
|
|
277
|
-
// Find {data.field} or {@const field = ...} for displays
|
|
278
|
-
const displayRegex = /\{(?:data|@const)\s*\.?(\w+)/g;
|
|
279
|
-
const displays = [...source.matchAll(displayRegex)].map((m) => m[1]);
|
|
280
|
-
return {
|
|
281
|
-
id: routeName.replace(/\s+/g, '_').toLowerCase(),
|
|
282
|
-
label: routeName,
|
|
283
|
-
displays: [...new Set(displays)],
|
|
284
|
-
captures: [...new Set(captures)]
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
function extractReactComponent(filePath) {
|
|
288
|
-
const source = fs.readFileSync(filePath, 'utf-8');
|
|
289
|
-
const fileName = path.basename(filePath, path.extname(filePath));
|
|
290
|
-
// Find useState calls
|
|
291
|
-
const stateRegex = /useState(?:<\w+>)?\(([^)]*)\)/g;
|
|
292
|
-
const states = [...source.matchAll(stateRegex)];
|
|
293
|
-
const captures = states.map((m, i) => `state_${i}`);
|
|
294
|
-
// Find data.field patterns
|
|
295
|
-
const displayRegex = /\{?data\.(\w+)\}?/g;
|
|
296
|
-
const displays = [...source.matchAll(displayRegex)].map((m) => m[1]);
|
|
297
|
-
return {
|
|
298
|
-
id: fileName.toLowerCase(),
|
|
299
|
-
label: fileName,
|
|
300
|
-
displays: [...new Set(displays)],
|
|
301
|
-
captures: [...new Set(captures)]
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
// ─── Transform Extraction ────────────────────────────────────────
|
|
305
|
-
function extractTransformsFromDir(dirPath) {
|
|
306
|
-
const transforms = [];
|
|
307
|
-
const files = fs.readdirSync(dirPath).filter((f) => f.endsWith('.ts') || f.endsWith('.js'));
|
|
308
|
-
for (const file of files) {
|
|
309
|
-
const filePath = path.join(dirPath, file);
|
|
310
|
-
const source = fs.readFileSync(filePath, 'utf-8');
|
|
311
|
-
// Match export function declarations
|
|
312
|
-
const fnRegex = /export\s+(?:async\s+)?function\s+(\w+)\s*\(([^)]*)\)/g;
|
|
313
|
-
const functions = source.matchAll(fnRegex);
|
|
314
|
-
for (const fn of functions) {
|
|
315
|
-
const [, name, params] = fn;
|
|
316
|
-
const inputs = params.split(',').map((p) => p.trim().split(':')[0].trim()).filter(Boolean);
|
|
317
|
-
let type = 'formula';
|
|
318
|
-
if (name.includes('validate') || name.includes('check'))
|
|
319
|
-
type = 'validation';
|
|
320
|
-
if (name.includes('workflow') || name.includes('process'))
|
|
321
|
-
type = 'workflow';
|
|
322
|
-
transforms.push({
|
|
323
|
-
id: name.toLowerCase(),
|
|
324
|
-
label: name,
|
|
325
|
-
type: type,
|
|
326
|
-
description: `Function from ${file}`,
|
|
327
|
-
inputs: inputs,
|
|
328
|
-
outputs: [name + '_result']
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return transforms;
|
|
333
|
-
}
|
|
334
|
-
// ─── Table Extraction ────────────────────────────────────────────
|
|
335
|
-
function findSchemaFiles(projectPath) {
|
|
336
|
-
const schemaFiles = [];
|
|
337
|
-
// Common schema file locations
|
|
338
|
-
const candidates = [
|
|
339
|
-
path.join(projectPath, 'prisma/schema.prisma'),
|
|
340
|
-
path.join(projectPath, 'drizzle.config.ts'),
|
|
341
|
-
path.join(projectPath, 'src/lib/db/schema.ts'),
|
|
342
|
-
path.join(projectPath, 'db/schema.sql')
|
|
343
|
-
];
|
|
344
|
-
for (const candidate of candidates) {
|
|
345
|
-
if (fs.existsSync(candidate)) {
|
|
346
|
-
schemaFiles.push(candidate);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return schemaFiles;
|
|
350
|
-
}
|
|
351
|
-
function extractTablesFromSchema(schemaFile) {
|
|
352
|
-
const tables = [];
|
|
353
|
-
const source = fs.readFileSync(schemaFile, 'utf-8');
|
|
354
|
-
// Prisma schema: model User { ... }
|
|
355
|
-
if (schemaFile.endsWith('.prisma')) {
|
|
356
|
-
const modelRegex = /model\s+(\w+)\s*\{([^}]+)\}/gs;
|
|
357
|
-
const models = source.matchAll(modelRegex);
|
|
358
|
-
for (const model of models) {
|
|
359
|
-
const [, tableName, body] = model;
|
|
360
|
-
// Extract fields: id Int @id
|
|
361
|
-
const fieldRegex = /(\w+)\s+(\w+)/g;
|
|
362
|
-
const fields = body.matchAll(fieldRegex);
|
|
363
|
-
const columns = [];
|
|
364
|
-
for (const field of fields) {
|
|
365
|
-
const [, name, type] = field;
|
|
366
|
-
if (name.startsWith('@'))
|
|
367
|
-
continue; // Skip attributes
|
|
368
|
-
columns.push({
|
|
369
|
-
name: name,
|
|
370
|
-
type: mapPrismaTypeToFlowSpec(type)
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
if (columns.length > 0) {
|
|
374
|
-
tables.push({
|
|
375
|
-
id: tableName.toLowerCase(),
|
|
376
|
-
label: tableName,
|
|
377
|
-
columns: columns,
|
|
378
|
-
sourceType: 'database',
|
|
379
|
-
endpoint: 'prisma'
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
// SQL schema: CREATE TABLE users ( ... )
|
|
385
|
-
if (schemaFile.endsWith('.sql')) {
|
|
386
|
-
const tableRegex = /CREATE\s+TABLE\s+(\w+)\s*\(([^)]+)\)/gis;
|
|
387
|
-
const sqlTables = source.matchAll(tableRegex);
|
|
388
|
-
for (const table of sqlTables) {
|
|
389
|
-
const [, tableName, body] = table;
|
|
390
|
-
const columnRegex = /(\w+)\s+(\w+)/g;
|
|
391
|
-
const columns = [];
|
|
392
|
-
const fields = body.matchAll(columnRegex);
|
|
393
|
-
for (const field of fields) {
|
|
394
|
-
const [, name, type] = field;
|
|
395
|
-
columns.push({
|
|
396
|
-
name: name,
|
|
397
|
-
type: mapSQLTypeToFlowSpec(type)
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
if (columns.length > 0) {
|
|
401
|
-
tables.push({
|
|
402
|
-
id: tableName.toLowerCase(),
|
|
403
|
-
label: tableName,
|
|
404
|
-
columns: columns,
|
|
405
|
-
sourceType: 'database',
|
|
406
|
-
endpoint: 'postgresql'
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return tables;
|
|
412
|
-
}
|
|
413
|
-
function mapPrismaTypeToFlowSpec(prismaType) {
|
|
414
|
-
const map = {
|
|
415
|
-
String: 'string',
|
|
416
|
-
Int: 'number',
|
|
417
|
-
Float: 'number',
|
|
418
|
-
Boolean: 'boolean',
|
|
419
|
-
DateTime: 'string',
|
|
420
|
-
Json: 'object'
|
|
421
|
-
};
|
|
422
|
-
return map[prismaType] || 'string';
|
|
423
|
-
}
|
|
424
|
-
function mapSQLTypeToFlowSpec(sqlType) {
|
|
425
|
-
const upper = sqlType.toUpperCase();
|
|
426
|
-
if (upper.includes('VARCHAR') || upper.includes('TEXT'))
|
|
427
|
-
return 'string';
|
|
428
|
-
if (upper.includes('INT') || upper.includes('NUMERIC'))
|
|
429
|
-
return 'number';
|
|
430
|
-
if (upper.includes('BOOL'))
|
|
431
|
-
return 'boolean';
|
|
432
|
-
if (upper.includes('JSON'))
|
|
433
|
-
return 'object';
|
|
434
|
-
return 'string';
|
|
435
|
-
}
|
|
436
|
-
// ─── YAML Generation ─────────────────────────────────────────────
|
|
437
|
-
function generateYaml(architecture) {
|
|
438
|
-
const lines = [];
|
|
439
|
-
lines.push('version: "1.2.0"');
|
|
440
|
-
lines.push('');
|
|
441
|
-
lines.push('dataPoints:');
|
|
442
|
-
if (architecture.dataPoints.length === 0) {
|
|
443
|
-
lines.push(' []');
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
for (const dp of architecture.dataPoints) {
|
|
447
|
-
lines.push(` - id: ${dp.id}`);
|
|
448
|
-
lines.push(` label: "${dp.label}"`);
|
|
449
|
-
lines.push(` type: ${dp.type}`);
|
|
450
|
-
lines.push(` source: ${dp.source}`);
|
|
451
|
-
lines.push(` sourceDefinition: "${dp.sourceDefinition}"`);
|
|
452
|
-
if (dp.constraints.length > 0) {
|
|
453
|
-
lines.push(` constraints: [${dp.constraints.join(', ')}]`);
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
lines.push(` constraints: []`);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
lines.push('');
|
|
461
|
-
lines.push('components:');
|
|
462
|
-
if (architecture.components.length === 0) {
|
|
463
|
-
lines.push(' []');
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
for (const comp of architecture.components) {
|
|
467
|
-
lines.push(` - id: ${comp.id}`);
|
|
468
|
-
lines.push(` label: "${comp.label}"`);
|
|
469
|
-
lines.push(` displays: [${comp.displays.join(', ')}]`);
|
|
470
|
-
lines.push(` captures: [${comp.captures.join(', ')}]`);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
lines.push('');
|
|
474
|
-
lines.push('transforms:');
|
|
475
|
-
if (architecture.transforms.length === 0) {
|
|
476
|
-
lines.push(' []');
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
for (const tf of architecture.transforms) {
|
|
480
|
-
lines.push(` - id: ${tf.id}`);
|
|
481
|
-
lines.push(` label: "${tf.label}"`);
|
|
482
|
-
lines.push(` type: ${tf.type}`);
|
|
483
|
-
lines.push(` description: "${tf.description}"`);
|
|
484
|
-
lines.push(` inputs: [${tf.inputs.join(', ')}]`);
|
|
485
|
-
lines.push(` outputs: [${tf.outputs.join(', ')}]`);
|
|
486
|
-
lines.push(` logic:`);
|
|
487
|
-
lines.push(` type: formula`);
|
|
488
|
-
lines.push(` content: "See source code"`);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
lines.push('');
|
|
492
|
-
lines.push('tables:');
|
|
493
|
-
if (architecture.tables.length === 0) {
|
|
494
|
-
lines.push(' []');
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
for (const table of architecture.tables) {
|
|
498
|
-
lines.push(` - id: ${table.id}`);
|
|
499
|
-
lines.push(` label: "${table.label}"`);
|
|
500
|
-
lines.push(` columns:`);
|
|
501
|
-
for (const col of table.columns) {
|
|
502
|
-
lines.push(` - name: ${col.name}`);
|
|
503
|
-
lines.push(` type: ${col.type}`);
|
|
504
|
-
}
|
|
505
|
-
lines.push(` sourceType: ${table.sourceType}`);
|
|
506
|
-
if (table.endpoint) {
|
|
507
|
-
lines.push(` endpoint: "${table.endpoint}"`);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
lines.push('');
|
|
512
|
-
lines.push('dataFlow: []');
|
|
513
|
-
lines.push('screens: []');
|
|
514
|
-
return lines.join('\n');
|
|
515
|
-
}
|
|
516
|
-
//# sourceMappingURL=ingestCodebase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ingestCodebase.js","sourceRoot":"","sources":["../../src/tools/ingestCodebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0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B,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAE1B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const smartLayoutSchema: z.ZodObject<{
|
|
3
|
-
projectId: z.ZodString;
|
|
4
|
-
command: z.ZodString;
|
|
5
|
-
canvasWidth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
6
|
-
canvasHeight: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
projectId: string;
|
|
9
|
-
command: string;
|
|
10
|
-
canvasWidth: number;
|
|
11
|
-
canvasHeight: number;
|
|
12
|
-
}, {
|
|
13
|
-
projectId: string;
|
|
14
|
-
command: string;
|
|
15
|
-
canvasWidth?: number | undefined;
|
|
16
|
-
canvasHeight?: number | undefined;
|
|
17
|
-
}>;
|
|
18
|
-
export declare function handleSmartLayout(args: z.infer<typeof smartLayoutSchema>): Promise<{
|
|
19
|
-
content: {
|
|
20
|
-
type: "text";
|
|
21
|
-
text: string;
|
|
22
|
-
}[];
|
|
23
|
-
isError: boolean;
|
|
24
|
-
} | {
|
|
25
|
-
content: {
|
|
26
|
-
type: "text";
|
|
27
|
-
text: string;
|
|
28
|
-
}[];
|
|
29
|
-
isError?: undefined;
|
|
30
|
-
}>;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { getProject, updateProjectViaApi } from '../db.js';
|
|
3
|
-
import { parseNaturalLanguageLayout, applySemanticLayout, SUPPORTED_COMMANDS, SUPPORTED_REGIONS } from '../layout/semanticLayout.js';
|
|
4
|
-
export const smartLayoutSchema = z.object({
|
|
5
|
-
projectId: z.string().describe('UUID of the project to apply smart layout to'),
|
|
6
|
-
command: z.string().describe(`Natural language layout command. Examples: ${SUPPORTED_COMMANDS.slice(0, 3).join('; ')}. ` +
|
|
7
|
-
`Supported regions: ${SUPPORTED_REGIONS.slice(0, 5).join(', ')}, etc.`),
|
|
8
|
-
canvasWidth: z.number().optional().default(2000).describe('Canvas width for region calculation'),
|
|
9
|
-
canvasHeight: z.number().optional().default(2000).describe('Canvas height for region calculation')
|
|
10
|
-
});
|
|
11
|
-
export async function handleSmartLayout(args) {
|
|
12
|
-
const project = await getProject(args.projectId);
|
|
13
|
-
if (!project) {
|
|
14
|
-
return {
|
|
15
|
-
content: [{ type: 'text', text: `Project not found: ${args.projectId}` }],
|
|
16
|
-
isError: true
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const nodes = project.canvas_state?.nodes ?? [];
|
|
20
|
-
const edges = project.canvas_state?.edges ?? [];
|
|
21
|
-
if (nodes.length === 0) {
|
|
22
|
-
return {
|
|
23
|
-
content: [{ type: 'text', text: `Project has no nodes to layout.` }],
|
|
24
|
-
isError: true
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
// Parse natural language command
|
|
28
|
-
const layoutCommand = parseNaturalLanguageLayout(args.command, nodes, { width: args.canvasWidth, height: args.canvasHeight });
|
|
29
|
-
if ('error' in layoutCommand) {
|
|
30
|
-
return {
|
|
31
|
-
content: [{ type: 'text', text: `Layout parsing error: ${layoutCommand.error}` }],
|
|
32
|
-
isError: true
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
// Apply semantic layout
|
|
36
|
-
const newPositions = applySemanticLayout(nodes, edges, layoutCommand);
|
|
37
|
-
if (newPositions.size === 0) {
|
|
38
|
-
return {
|
|
39
|
-
content: [{ type: 'text', text: `No nodes matched the layout command.` }],
|
|
40
|
-
isError: true
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// Update node positions
|
|
44
|
-
let updatedCount = 0;
|
|
45
|
-
for (const node of nodes) {
|
|
46
|
-
const newPos = newPositions.get(node.id);
|
|
47
|
-
if (newPos) {
|
|
48
|
-
node.position = newPos;
|
|
49
|
-
updatedCount++;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Save project
|
|
53
|
-
await updateProjectViaApi(args.projectId, { canvas_state: project.canvas_state });
|
|
54
|
-
// Format result
|
|
55
|
-
const affectedLabels = nodes
|
|
56
|
-
.filter((n) => newPositions.has(n.id))
|
|
57
|
-
.map((n) => n.data?.label ?? 'Untitled')
|
|
58
|
-
.join(', ');
|
|
59
|
-
return {
|
|
60
|
-
content: [
|
|
61
|
-
{
|
|
62
|
-
type: 'text',
|
|
63
|
-
text: [
|
|
64
|
-
`✅ Smart layout applied to ${updatedCount} node(s).`,
|
|
65
|
-
`Command: "${args.command}"`,
|
|
66
|
-
`Arrangement: ${layoutCommand.arrangement}${layoutCommand.direction ? ` (${layoutCommand.direction})` : ''}`,
|
|
67
|
-
`Region: (${layoutCommand.targetBounds.x}, ${layoutCommand.targetBounds.y})`,
|
|
68
|
-
`Nodes: ${affectedLabels}`
|
|
69
|
-
].join('\n')
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=smartLayout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smartLayout.js","sourceRoot":"","sources":["../../src/tools/smartLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EACN,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IAC9E,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAC3B,8CAA8C,kBAAkB,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