akbo-cli 0.0.0-stage → 2.0.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 +786 -2
- package/dist/catalog_store.d.ts +131 -0
- package/dist/catalog_store.js +506 -0
- package/dist/cleaner.d.ts +11 -0
- package/dist/cleaner.js +92 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1961 -0
- package/dist/dream_engine.d.ts +61 -0
- package/dist/dream_engine.js +330 -0
- package/dist/extractors/base.d.ts +35 -0
- package/dist/extractors/base.js +17 -0
- package/dist/extractors/custom_extractor.d.ts +55 -0
- package/dist/extractors/custom_extractor.js +198 -0
- package/dist/extractors/dotnet_extractor.d.ts +11 -0
- package/dist/extractors/dotnet_extractor.js +579 -0
- package/dist/extractors/golang_extractor.d.ts +11 -0
- package/dist/extractors/golang_extractor.js +73 -0
- package/dist/extractors/index.d.ts +14 -0
- package/dist/extractors/index.js +30 -0
- package/dist/extractors/jvm_extractor.d.ts +11 -0
- package/dist/extractors/jvm_extractor.js +319 -0
- package/dist/extractors/node_extractor.d.ts +11 -0
- package/dist/extractors/node_extractor.js +306 -0
- package/dist/extractors/proto_graphql_extractor.d.ts +11 -0
- package/dist/extractors/proto_graphql_extractor.js +125 -0
- package/dist/extractors/python_extractor.d.ts +11 -0
- package/dist/extractors/python_extractor.js +298 -0
- package/dist/extractors/rust_extractor.d.ts +11 -0
- package/dist/extractors/rust_extractor.js +66 -0
- package/dist/graph_builder.d.ts +87 -0
- package/dist/graph_builder.js +1516 -0
- package/dist/guard_service.d.ts +33 -0
- package/dist/guard_service.js +167 -0
- package/dist/harvester.d.ts +38 -0
- package/dist/harvester.js +461 -0
- package/dist/hook_generator.d.ts +34 -0
- package/dist/hook_generator.js +269 -0
- package/dist/importers/skill_importer.d.ts +43 -0
- package/dist/importers/skill_importer.js +470 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/indexer.d.ts +19 -0
- package/dist/indexer.js +108 -0
- package/dist/init_service.d.ts +37 -0
- package/dist/init_service.js +246 -0
- package/dist/mcp_server.d.ts +10 -0
- package/dist/mcp_server.js +846 -0
- package/dist/pool_resolver.d.ts +40 -0
- package/dist/pool_resolver.js +84 -0
- package/dist/provider.d.ts +135 -0
- package/dist/provider.js +880 -0
- package/dist/query_service.d.ts +33 -0
- package/dist/query_service.js +161 -0
- package/dist/schema_generator.d.ts +236 -0
- package/dist/schema_generator.js +264 -0
- package/dist/standards_loader.d.ts +7 -0
- package/dist/standards_loader.js +33 -0
- package/dist/types.d.ts +323 -0
- package/dist/types.js +123 -0
- package/dist/unit_synthesizer.d.ts +22 -0
- package/dist/unit_synthesizer.js +196 -0
- package/dist/validator.d.ts +13 -0
- package/dist/validator.js +152 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +16 -0
- package/dist/watcher.d.ts +38 -0
- package/dist/watcher.js +132 -0
- package/package.json +56 -6
- package/schemas/index-schema.json +98 -0
- package/schemas/knowledge-unit.json +154 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { cleanClientUrl } from './base.js';
|
|
3
|
+
export class NodeExtractor {
|
|
4
|
+
name = 'node';
|
|
5
|
+
canExtractManifest(filePath) {
|
|
6
|
+
const lower = path.basename(filePath).toLowerCase();
|
|
7
|
+
return (lower === 'package.json' ||
|
|
8
|
+
lower === 'pnpm-workspace.yaml' ||
|
|
9
|
+
lower === 'turbo.json');
|
|
10
|
+
}
|
|
11
|
+
extractManifest(filePath, content) {
|
|
12
|
+
const filename = path.basename(filePath);
|
|
13
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
14
|
+
if (filename === 'package.json') {
|
|
15
|
+
try {
|
|
16
|
+
const pkg = JSON.parse(content);
|
|
17
|
+
return {
|
|
18
|
+
path: normalized,
|
|
19
|
+
type: 'npm',
|
|
20
|
+
contentSummary: {
|
|
21
|
+
name: pkg.name,
|
|
22
|
+
dependencies: Object.keys(pkg.dependencies || {}),
|
|
23
|
+
devDependencies: Object.keys(pkg.devDependencies || {}),
|
|
24
|
+
scripts: pkg.scripts || {},
|
|
25
|
+
workspaces: Array.isArray(pkg.workspaces) ? pkg.workspaces : (pkg.workspaces?.packages || [])
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return {
|
|
31
|
+
path: normalized,
|
|
32
|
+
type: 'npm',
|
|
33
|
+
contentSummary: { rawPreview: content.slice(0, 300) }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (filename === 'pnpm-workspace.yaml') {
|
|
38
|
+
const pkgMatches = Array.from(content.matchAll(/-\s*['"]?([^'"\s]+)['"]?/g)).map(m => m[1]);
|
|
39
|
+
return {
|
|
40
|
+
path: normalized,
|
|
41
|
+
type: 'config',
|
|
42
|
+
contentSummary: {
|
|
43
|
+
packages: pkgMatches
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (filename === 'turbo.json') {
|
|
48
|
+
try {
|
|
49
|
+
const turbo = JSON.parse(content);
|
|
50
|
+
return {
|
|
51
|
+
path: normalized,
|
|
52
|
+
type: 'config',
|
|
53
|
+
contentSummary: {
|
|
54
|
+
pipeline: Object.keys(turbo.pipeline || turbo.tasks || {})
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
canExtractSchema(filePath) {
|
|
65
|
+
const lower = filePath.toLowerCase();
|
|
66
|
+
return lower.endsWith('.prisma') || lower.endsWith('.ts') || lower.endsWith('.js');
|
|
67
|
+
}
|
|
68
|
+
extractSchemas(filePath, content) {
|
|
69
|
+
const schemas = [];
|
|
70
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
71
|
+
// 1. Prisma Schemas
|
|
72
|
+
if (normalized.endsWith('.prisma')) {
|
|
73
|
+
const modelsAndEnums = Array.from(content.matchAll(/(?:model|enum)\s+([A-Za-z0-9_]+)\s*\{/g)).map(m => m[1]);
|
|
74
|
+
if (modelsAndEnums.length > 0) {
|
|
75
|
+
schemas.push({ file: normalized, type: 'prisma', tablesOrModels: [...new Set(modelsAndEnums)] });
|
|
76
|
+
}
|
|
77
|
+
return schemas;
|
|
78
|
+
}
|
|
79
|
+
// 2. TypeScript / JavaScript Drizzle and TypeORM
|
|
80
|
+
if (normalized.endsWith('.ts') || normalized.endsWith('.js')) {
|
|
81
|
+
const drizzleMatches = Array.from(content.matchAll(/(?:pgTable|mysqlTable|sqliteTable)\s*\(\s*['"`]([^'"`]+)['"`]/g)).map(m => m[1]);
|
|
82
|
+
if (drizzleMatches.length > 0) {
|
|
83
|
+
schemas.push({ file: normalized, type: 'drizzle', tablesOrModels: [...new Set(drizzleMatches)] });
|
|
84
|
+
}
|
|
85
|
+
const typeormMatches = Array.from(content.matchAll(/@Entity\s*(?:\(\s*['"`]([^'"`]+)['"`]\s*\)|\(\s*\))?\s*(?:export\s+)?class\s+(\w+)/g))
|
|
86
|
+
.map(m => m[1] || m[2]);
|
|
87
|
+
if (typeormMatches.length > 0) {
|
|
88
|
+
schemas.push({ file: normalized, type: 'typeorm', tablesOrModels: [...new Set(typeormMatches)] });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return schemas;
|
|
92
|
+
}
|
|
93
|
+
canExtractRoutes(filePath) {
|
|
94
|
+
const lower = filePath.toLowerCase();
|
|
95
|
+
return (lower.endsWith('.ts') ||
|
|
96
|
+
lower.endsWith('.js') ||
|
|
97
|
+
lower.endsWith('.tsx') ||
|
|
98
|
+
lower.endsWith('.jsx') ||
|
|
99
|
+
lower.endsWith('.mjs') ||
|
|
100
|
+
lower.endsWith('.cjs'));
|
|
101
|
+
}
|
|
102
|
+
extractRoutesAndCommands(filePath, content) {
|
|
103
|
+
const items = [];
|
|
104
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
105
|
+
// 1. NestJS Controllers, Microservices, and BullMQ Processors
|
|
106
|
+
if (content.includes('@Controller') || content.includes('@Processor') || content.includes('@MessagePattern') || content.includes('@EventPattern')) {
|
|
107
|
+
const controllerClassMatch = content.match(/@Controller\s*\((?:[^)'"]*['"`]([^'"`]+)['"`][^)]*)?\s*\)/);
|
|
108
|
+
if (controllerClassMatch) {
|
|
109
|
+
const rawPrefix = controllerClassMatch[1] ?? '';
|
|
110
|
+
const prefix = rawPrefix ? `/${rawPrefix.replace(/^\//, '').replace(/\/$/, '')}` : '';
|
|
111
|
+
const methodRegex = /@(Get|Post|Put|Delete|Patch|All|Options|Head)\s*\((?:[^)'"]*['"`]([^'"`]+)['"`][^)]*)?\s*\)\s*(?:@\w+(?:\([^)]*\))?\s*)*(?:async\s+)?([\p{L}\p{N}_]+)\s*\(([\s\S]*?)\)\s*(?=\{)/gu;
|
|
112
|
+
for (const mMatch of content.matchAll(methodRegex)) {
|
|
113
|
+
const verb = mMatch[1].toUpperCase();
|
|
114
|
+
const rawSub = mMatch[2] ?? '';
|
|
115
|
+
const subPath = rawSub ? `/${rawSub.replace(/^\//, '')}` : '';
|
|
116
|
+
const fullRoute = `${prefix}${subPath}` || '/';
|
|
117
|
+
const methodName = mMatch[3];
|
|
118
|
+
const params = mMatch[4]?.trim() || '';
|
|
119
|
+
items.push({
|
|
120
|
+
file: normalized,
|
|
121
|
+
framework: 'NestJS',
|
|
122
|
+
method: verb,
|
|
123
|
+
identifier: methodName,
|
|
124
|
+
signature: `${verb} ${fullRoute} -> ${methodName}(${params.replace(/\s+/g, ' ')})`
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// NestJS Microservice patterns
|
|
129
|
+
const microserviceRegex = /@(MessagePattern|EventPattern)\s*\((?:[^)'"]*['"`]([^'"`]+)['"`])?\s*\)\s*(?:@\w+(?:\([^)]*\))?\s*)*(?:async\s+)?([\p{L}\p{N}_]+)\s*\(([^)]*)\)/gu;
|
|
130
|
+
for (const msMatch of content.matchAll(microserviceRegex)) {
|
|
131
|
+
const kind = msMatch[1];
|
|
132
|
+
const pattern = msMatch[2] || 'unknown';
|
|
133
|
+
const methodName = msMatch[3];
|
|
134
|
+
const params = msMatch[4]?.trim() || '';
|
|
135
|
+
items.push({
|
|
136
|
+
file: normalized,
|
|
137
|
+
framework: 'NestJS',
|
|
138
|
+
method: kind === 'MessagePattern' ? 'MESSAGE' : 'EVENT',
|
|
139
|
+
identifier: pattern,
|
|
140
|
+
signature: `${kind === 'MessagePattern' ? 'Message' : 'Event'}: ${pattern} -> ${methodName}(${params})`
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// NestJS BullMQ @Processor / @Process
|
|
144
|
+
if (content.includes('@Processor')) {
|
|
145
|
+
const processorMatch = content.match(/@Processor\s*\(\s*(?:['"`]([^'"`]+)['"`]|(?:\{\s*name:\s*['"`]([^'"`]+)['"`]\s*\}))\s*\)/);
|
|
146
|
+
const queueName = processorMatch ? (processorMatch[1] || processorMatch[2]) : 'default';
|
|
147
|
+
const processRegex = /@Process\s*(?:\(\s*['"`]?([^'"`]*)['"`]?\s*\))?\s*(?:async\s+)?([\p{L}\p{N}_]+)\s*\(([^)]*)\)/gu;
|
|
148
|
+
for (const pm of content.matchAll(processRegex)) {
|
|
149
|
+
const jobName = pm[1] || 'default';
|
|
150
|
+
const methodName = pm[2];
|
|
151
|
+
items.push({
|
|
152
|
+
file: normalized,
|
|
153
|
+
framework: 'BullMQ',
|
|
154
|
+
identifier: methodName,
|
|
155
|
+
signature: `Processor: ${queueName} [job: ${jobName}] -> ${methodName}`
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// 2. Direct BullMQ Workers & Queues
|
|
161
|
+
if (content.includes('new Worker(') || content.includes('new Queue(')) {
|
|
162
|
+
const workerRegex = /new\s+Worker\s*(?:<[^>]+>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*,\s*(?:async\s+)?(?:function\s+([\p{L}\p{N}_]+)|([\p{L}\p{N}_]+)\b|\(([^)]*)\)|(?:\(([^)]*)\)\s*=>)|([A-Za-z0-9_]+))/gu;
|
|
163
|
+
for (const match of content.matchAll(workerRegex)) {
|
|
164
|
+
const queueName = match[1];
|
|
165
|
+
const handlerName = match[2] || match[3] || match[6] || 'inline';
|
|
166
|
+
items.push({
|
|
167
|
+
file: normalized,
|
|
168
|
+
framework: 'BullMQ',
|
|
169
|
+
identifier: `${queueName}Worker`,
|
|
170
|
+
signature: `Worker: ${queueName} -> ${handlerName}`
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const queueRegex = /new\s+Queue\s*(?:<[^>]+>)?\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
174
|
+
for (const match of content.matchAll(queueRegex)) {
|
|
175
|
+
const queueName = match[1];
|
|
176
|
+
if (!items.some(it => it.signature === `Queue: ${queueName}`)) {
|
|
177
|
+
items.push({
|
|
178
|
+
file: normalized,
|
|
179
|
+
framework: 'BullMQ',
|
|
180
|
+
method: 'QUEUE',
|
|
181
|
+
identifier: `${queueName}Queue`,
|
|
182
|
+
signature: `Queue: ${queueName}`
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// 3. Next.js App Router route handlers
|
|
188
|
+
if (normalized.includes('/route.ts') || normalized.includes('/route.js') || normalized.includes('/route.tsx') || normalized.includes('/route.jsx')) {
|
|
189
|
+
const funcRegex = /export\s+(?:async\s+)?function\s+(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s*\(/gu;
|
|
190
|
+
const constRegex = /export\s+const\s+(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s*=/gu;
|
|
191
|
+
const methods = new Set();
|
|
192
|
+
for (const m of content.matchAll(funcRegex))
|
|
193
|
+
methods.add(m[1].toUpperCase());
|
|
194
|
+
for (const m of content.matchAll(constRegex))
|
|
195
|
+
methods.add(m[1].toUpperCase());
|
|
196
|
+
if (methods.size > 0) {
|
|
197
|
+
let routePath = '/' + normalized.replace(/^(?:.*\/)?(?:src\/)?app\//, '').replace(/\/route\.[jt]sx?$/, '');
|
|
198
|
+
if (!routePath || routePath === '')
|
|
199
|
+
routePath = '/';
|
|
200
|
+
for (const method of methods) {
|
|
201
|
+
items.push({
|
|
202
|
+
file: normalized,
|
|
203
|
+
framework: 'Next.js/AppRouter',
|
|
204
|
+
method,
|
|
205
|
+
identifier: method,
|
|
206
|
+
signature: `${method} ${routePath}`
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// 4. Next.js Pages Router API routes
|
|
212
|
+
if (/(?:^|\/)pages\/api\//.test(normalized)) {
|
|
213
|
+
const relPath = normalized.replace(/^(?:.*\/)?(?:src\/)?pages\/api\//, '').replace(/\.[jt]sx?$/, '');
|
|
214
|
+
const routePath = `/api/${relPath}`;
|
|
215
|
+
if (content.includes('export default')) {
|
|
216
|
+
items.push({
|
|
217
|
+
file: normalized,
|
|
218
|
+
framework: 'Next.js/PagesRouter',
|
|
219
|
+
method: 'ALL',
|
|
220
|
+
identifier: `API ${routePath}`,
|
|
221
|
+
signature: `ANY ${routePath} -> handler`
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// 5. Express / Fastify / Node HTTP endpoints
|
|
226
|
+
const expressRegex = /(?:\b(?:app|router|server|api|fastify))\s*\.\s*(get|post|put|delete|patch|all|options|head)\s*\(\s*['"`]([^'"`]+)['"`]\s*(?:,\s*(?:[A-Za-z0-9_.]+\s*,\s*)*(?:async\s+)?(?:function\s+([\p{L}\p{N}_]+)|([\p{L}\p{N}_]+)\b|\(([^)]*)\)))?/gu;
|
|
227
|
+
for (const match of content.matchAll(expressRegex)) {
|
|
228
|
+
const verb = match[1].toUpperCase();
|
|
229
|
+
const routePath = match[2];
|
|
230
|
+
const handlerName = match[3] || match[4] || '';
|
|
231
|
+
const sig = handlerName ? `${verb} ${routePath} -> ${handlerName}` : `${verb} ${routePath}`;
|
|
232
|
+
items.push({
|
|
233
|
+
file: normalized,
|
|
234
|
+
framework: 'Express/Node',
|
|
235
|
+
method: verb,
|
|
236
|
+
identifier: handlerName || routePath,
|
|
237
|
+
signature: sig
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
// Chained Express routes
|
|
241
|
+
const chainedRegex = /(?:\b(?:app|router))\s*\.\s*route\s*\(\s*['"`]([^'"`]+)['"`]\s*\)\s*((?:\s*\.\s*(?:get|post|put|delete|patch|all)\s*\([^)]*\))+)/gu;
|
|
242
|
+
for (const match of content.matchAll(chainedRegex)) {
|
|
243
|
+
const routePath = match[1];
|
|
244
|
+
const chainBody = match[2];
|
|
245
|
+
const chainMethodRegex = /\.\s*(get|post|put|delete|patch|all)\s*\(\s*(?:(?:async\s+)?(?:function\s+([\p{L}\p{N}_]+)|([\p{L}\p{N}_]+))|(?:\(([^)]*)\)|[\p{L}\p{N}_]+)\s*=>)?/gu;
|
|
246
|
+
for (const cm of chainBody.matchAll(chainMethodRegex)) {
|
|
247
|
+
const verb = cm[1].toUpperCase();
|
|
248
|
+
const handler = cm[2] || cm[3] || '';
|
|
249
|
+
const sig = handler ? `${verb} ${routePath} -> ${handler}` : `${verb} ${routePath}`;
|
|
250
|
+
items.push({
|
|
251
|
+
file: normalized,
|
|
252
|
+
framework: 'Express/Node',
|
|
253
|
+
method: verb,
|
|
254
|
+
identifier: handler || routePath,
|
|
255
|
+
signature: sig
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// 6. TypeScript / Node HTTP Client calls: fetch(), axios.get()
|
|
260
|
+
const fetchRegex = /\bfetch\s*\(\s*(?:['"`]([^'"`]+)['"`]|`([^`]+)`)(?:\s*,\s*\{[\s\S]*?method\s*:\s*['"`]([A-Za-z]+)['"`])?/g;
|
|
261
|
+
for (const match of content.matchAll(fetchRegex)) {
|
|
262
|
+
const rawUrl = match[1] || match[2];
|
|
263
|
+
const verb = match[3] ? match[3].toUpperCase() : 'GET';
|
|
264
|
+
const cleanPath = cleanClientUrl(rawUrl);
|
|
265
|
+
if (cleanPath) {
|
|
266
|
+
items.push({
|
|
267
|
+
file: normalized,
|
|
268
|
+
framework: 'HttpClient',
|
|
269
|
+
method: verb,
|
|
270
|
+
identifier: cleanPath,
|
|
271
|
+
signature: `${verb} ${cleanPath} [HTTP Client]`
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const axiosRegex = /(?:\b(?:axios|httpClient|apiClient|client|http))\s*\.\s*(get|post|put|delete|patch)\s*(?:<[^>]+>)?\s*\(\s*(?:['"`]([^'"`]+)['"`]|`([^`]+)`)/gi;
|
|
276
|
+
for (const match of content.matchAll(axiosRegex)) {
|
|
277
|
+
const verb = match[1].toUpperCase();
|
|
278
|
+
const rawUrl = match[2] || match[3];
|
|
279
|
+
const cleanPath = cleanClientUrl(rawUrl);
|
|
280
|
+
if (cleanPath) {
|
|
281
|
+
items.push({
|
|
282
|
+
file: normalized,
|
|
283
|
+
framework: 'HttpClient',
|
|
284
|
+
method: verb,
|
|
285
|
+
identifier: cleanPath,
|
|
286
|
+
signature: `${verb} ${cleanPath} [HTTP Client]`
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// 7. TypeScript / Node gRPC Client calls
|
|
291
|
+
const tsGrpcRegex = /(?:\b(?:grpcClient|stub|invoiceClient|userClient|orderClient))\s*\.\s*([A-Za-z0-9_]+)\s*\(/g;
|
|
292
|
+
for (const match of content.matchAll(tsGrpcRegex)) {
|
|
293
|
+
const method = match[1];
|
|
294
|
+
if (!['get', 'post', 'put', 'delete', 'patch', 'then', 'catch', 'finally', 'json', 'send', 'status', 'setHeader', 'end', 'on', 'emit', 'pipe', 'log', 'error', 'warn'].includes(method)) {
|
|
295
|
+
items.push({
|
|
296
|
+
file: normalized,
|
|
297
|
+
framework: 'GrpcClient',
|
|
298
|
+
method: 'RPC',
|
|
299
|
+
identifier: method,
|
|
300
|
+
signature: `rpc client: ${method}`
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return items;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CodebaseExtractor } from './base.js';
|
|
2
|
+
import type { ManifestSummary, SchemaSummary, RouteOrSignature } from '../types.js';
|
|
3
|
+
export declare class ProtoGraphqlExtractor implements CodebaseExtractor {
|
|
4
|
+
readonly name = "proto-graphql";
|
|
5
|
+
canExtractManifest(filePath: string): boolean;
|
|
6
|
+
extractManifest(filePath: string, content: string): ManifestSummary | null;
|
|
7
|
+
canExtractSchema(filePath: string): boolean;
|
|
8
|
+
extractSchemas(filePath: string, content: string): SchemaSummary[];
|
|
9
|
+
canExtractRoutes(filePath: string): boolean;
|
|
10
|
+
extractRoutesAndCommands(filePath: string, content: string): RouteOrSignature[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
export class ProtoGraphqlExtractor {
|
|
3
|
+
name = 'proto-graphql';
|
|
4
|
+
canExtractManifest(filePath) {
|
|
5
|
+
const lower = path.basename(filePath).toLowerCase();
|
|
6
|
+
return (lower === 'dockerfile' ||
|
|
7
|
+
lower === 'docker-compose.yml' ||
|
|
8
|
+
lower === 'docker-compose.yaml' ||
|
|
9
|
+
lower === 'tsconfig.json' ||
|
|
10
|
+
lower === 'vite.config.ts' ||
|
|
11
|
+
lower === 'vite.config.js' ||
|
|
12
|
+
lower === 'svelte.config.js' ||
|
|
13
|
+
lower === 'nx.json' ||
|
|
14
|
+
lower === 'lerna.json');
|
|
15
|
+
}
|
|
16
|
+
extractManifest(filePath, content) {
|
|
17
|
+
const filename = path.basename(filePath);
|
|
18
|
+
const lower = filename.toLowerCase();
|
|
19
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
20
|
+
const isDocker = lower.startsWith('docker');
|
|
21
|
+
const manifestType = isDocker ? 'docker' : 'config';
|
|
22
|
+
return {
|
|
23
|
+
path: normalized,
|
|
24
|
+
type: manifestType,
|
|
25
|
+
contentSummary: {
|
|
26
|
+
snippet: content.split('\n').slice(0, 20).join('\n')
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
canExtractSchema(filePath) {
|
|
31
|
+
const lower = filePath.toLowerCase();
|
|
32
|
+
return (lower.endsWith('.proto') ||
|
|
33
|
+
lower.endsWith('.graphql') ||
|
|
34
|
+
lower.endsWith('.gql') ||
|
|
35
|
+
(lower.endsWith('.sql') && (lower.includes('schema') || lower.includes('migration'))));
|
|
36
|
+
}
|
|
37
|
+
extractSchemas(filePath, content) {
|
|
38
|
+
const schemas = [];
|
|
39
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
40
|
+
// 1. SQL schemas
|
|
41
|
+
if (normalized.endsWith('.sql')) {
|
|
42
|
+
const tables = Array.from(content.matchAll(/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?([`"']?\w+[`"']?)/gi)).map(m => m[1].replace(/[`"']/g, ''));
|
|
43
|
+
schemas.push({
|
|
44
|
+
file: normalized,
|
|
45
|
+
type: 'sql',
|
|
46
|
+
tablesOrModels: tables
|
|
47
|
+
});
|
|
48
|
+
return schemas;
|
|
49
|
+
}
|
|
50
|
+
// 2. GraphQL schemas
|
|
51
|
+
if (normalized.endsWith('.graphql') || normalized.endsWith('.gql')) {
|
|
52
|
+
const types = Array.from(content.matchAll(/(?:type|interface|input|enum)\s+([A-Z]\w*)\b/g)).map(m => m[1]);
|
|
53
|
+
if (types.length > 0) {
|
|
54
|
+
schemas.push({
|
|
55
|
+
file: normalized,
|
|
56
|
+
type: 'graphql',
|
|
57
|
+
tablesOrModels: [...new Set(types)]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return schemas;
|
|
61
|
+
}
|
|
62
|
+
// 3. Protocol Buffers schemas
|
|
63
|
+
if (normalized.endsWith('.proto')) {
|
|
64
|
+
const messageMatches = Array.from(content.matchAll(/message\s+(\w+)\s*\{/g)).map(m => m[1]);
|
|
65
|
+
const serviceMatches = Array.from(content.matchAll(/service\s+(\w+)\s*\{/g)).map(m => m[1]);
|
|
66
|
+
const allModels = [...new Set([...serviceMatches, ...messageMatches])];
|
|
67
|
+
if (allModels.length > 0) {
|
|
68
|
+
schemas.push({
|
|
69
|
+
file: normalized,
|
|
70
|
+
type: 'protobuf',
|
|
71
|
+
tablesOrModels: allModels
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return schemas;
|
|
75
|
+
}
|
|
76
|
+
return schemas;
|
|
77
|
+
}
|
|
78
|
+
canExtractRoutes(filePath) {
|
|
79
|
+
const lower = filePath.toLowerCase();
|
|
80
|
+
return lower.endsWith('.proto') || lower.endsWith('.graphql') || lower.endsWith('.gql');
|
|
81
|
+
}
|
|
82
|
+
extractRoutesAndCommands(filePath, content) {
|
|
83
|
+
const items = [];
|
|
84
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
85
|
+
// 1. Protocol Buffers service definitions
|
|
86
|
+
if (normalized.endsWith('.proto')) {
|
|
87
|
+
const serviceBlockRegex = /service\s+(\w+)\s*\{([^}]+)\}/g;
|
|
88
|
+
for (const serviceMatch of content.matchAll(serviceBlockRegex)) {
|
|
89
|
+
const serviceName = serviceMatch[1];
|
|
90
|
+
const serviceBody = serviceMatch[2];
|
|
91
|
+
const rpcRegex = /rpc\s+(\w+)\s*\(\s*(stream\s+)?([A-Za-z0-9_.]+)\s*\)\s*returns\s*\(\s*(stream\s+)?([A-Za-z0-9_.]+)\s*\)/g;
|
|
92
|
+
for (const rpcMatch of serviceBody.matchAll(rpcRegex)) {
|
|
93
|
+
const rpcName = rpcMatch[1];
|
|
94
|
+
const reqStream = rpcMatch[2] ? 'stream ' : '';
|
|
95
|
+
const reqType = rpcMatch[3];
|
|
96
|
+
const respStream = rpcMatch[4] ? 'stream ' : '';
|
|
97
|
+
const respType = rpcMatch[5];
|
|
98
|
+
items.push({
|
|
99
|
+
file: normalized,
|
|
100
|
+
framework: 'gRPC/Protobuf',
|
|
101
|
+
method: 'RPC',
|
|
102
|
+
identifier: rpcName,
|
|
103
|
+
signature: `rpc ${serviceName}.${rpcName}(${reqStream}${reqType}) returns (${respStream}${respType})`
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return items;
|
|
108
|
+
}
|
|
109
|
+
// 2. GraphQL operations
|
|
110
|
+
if (normalized.endsWith('.graphql') || normalized.endsWith('.gql')) {
|
|
111
|
+
const gqlOps = Array.from(content.matchAll(/(query|mutation|subscription)\s+(\w+)/g));
|
|
112
|
+
for (const match of gqlOps) {
|
|
113
|
+
items.push({
|
|
114
|
+
file: normalized,
|
|
115
|
+
framework: 'GraphQL',
|
|
116
|
+
method: match[1].toUpperCase(),
|
|
117
|
+
identifier: match[2],
|
|
118
|
+
signature: `${match[1].toUpperCase()} ${match[2]}`
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return items;
|
|
122
|
+
}
|
|
123
|
+
return items;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CodebaseExtractor } from './base.js';
|
|
2
|
+
import type { ManifestSummary, SchemaSummary, RouteOrSignature } from '../types.js';
|
|
3
|
+
export declare class PythonExtractor implements CodebaseExtractor {
|
|
4
|
+
readonly name = "python";
|
|
5
|
+
canExtractManifest(filePath: string): boolean;
|
|
6
|
+
extractManifest(filePath: string, content: string): ManifestSummary | null;
|
|
7
|
+
canExtractSchema(filePath: string): boolean;
|
|
8
|
+
extractSchemas(filePath: string, content: string): SchemaSummary[];
|
|
9
|
+
canExtractRoutes(filePath: string): boolean;
|
|
10
|
+
extractRoutesAndCommands(filePath: string, content: string): RouteOrSignature[];
|
|
11
|
+
}
|