@syke1/mcp-server 1.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 +112 -0
- package/dist/ai/analyzer.d.ts +3 -0
- package/dist/ai/analyzer.js +120 -0
- package/dist/ai/realtime-analyzer.d.ts +20 -0
- package/dist/ai/realtime-analyzer.js +182 -0
- package/dist/graph.d.ts +13 -0
- package/dist/graph.js +105 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +518 -0
- package/dist/languages/cpp.d.ts +2 -0
- package/dist/languages/cpp.js +109 -0
- package/dist/languages/dart.d.ts +2 -0
- package/dist/languages/dart.js +162 -0
- package/dist/languages/go.d.ts +2 -0
- package/dist/languages/go.js +111 -0
- package/dist/languages/java.d.ts +2 -0
- package/dist/languages/java.js +113 -0
- package/dist/languages/plugin.d.ts +20 -0
- package/dist/languages/plugin.js +148 -0
- package/dist/languages/python.d.ts +2 -0
- package/dist/languages/python.js +129 -0
- package/dist/languages/ruby.d.ts +2 -0
- package/dist/languages/ruby.js +97 -0
- package/dist/languages/rust.d.ts +2 -0
- package/dist/languages/rust.js +121 -0
- package/dist/languages/typescript.d.ts +2 -0
- package/dist/languages/typescript.js +138 -0
- package/dist/license/validator.d.ts +23 -0
- package/dist/license/validator.js +297 -0
- package/dist/tools/analyze-impact.d.ts +23 -0
- package/dist/tools/analyze-impact.js +102 -0
- package/dist/tools/gate-build.d.ts +25 -0
- package/dist/tools/gate-build.js +243 -0
- package/dist/watcher/file-cache.d.ts +56 -0
- package/dist/watcher/file-cache.js +241 -0
- package/dist/web/public/app.js +2398 -0
- package/dist/web/public/index.html +258 -0
- package/dist/web/public/style.css +1827 -0
- package/dist/web/server.d.ts +29 -0
- package/dist/web/server.js +744 -0
- package/package.json +50 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.dartPlugin = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const plugin_1 = require("./plugin");
|
|
40
|
+
const IMPORT_RE = /^import\s+['"](.+?)['"]/;
|
|
41
|
+
exports.dartPlugin = {
|
|
42
|
+
id: "dart",
|
|
43
|
+
name: "Dart",
|
|
44
|
+
extensions: [".dart"],
|
|
45
|
+
codeBlockLang: "dart",
|
|
46
|
+
detectProject(root) {
|
|
47
|
+
return fs.existsSync(path.join(root, "pubspec.yaml"));
|
|
48
|
+
},
|
|
49
|
+
getSourceDirs(root) {
|
|
50
|
+
const libDir = path.join(root, "lib");
|
|
51
|
+
return fs.existsSync(libDir) ? [libDir] : [];
|
|
52
|
+
},
|
|
53
|
+
getPackageName(root) {
|
|
54
|
+
try {
|
|
55
|
+
const pubspec = fs.readFileSync(path.join(root, "pubspec.yaml"), "utf-8");
|
|
56
|
+
const match = pubspec.match(/^name:\s*(\S+)/m);
|
|
57
|
+
return match ? match[1] : path.basename(root);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return path.basename(root);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
discoverFiles(dir) {
|
|
64
|
+
return (0, plugin_1.discoverAllFiles)(dir, [".dart"]);
|
|
65
|
+
},
|
|
66
|
+
parseImports(filePath, projectRoot, sourceDir) {
|
|
67
|
+
let content;
|
|
68
|
+
try {
|
|
69
|
+
content = fs.readFileSync(filePath, "utf-8");
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
const libDir = sourceDir;
|
|
75
|
+
const imports = [];
|
|
76
|
+
// Read package name for resolving package: imports
|
|
77
|
+
let packageName = path.basename(projectRoot);
|
|
78
|
+
try {
|
|
79
|
+
const pubspec = fs.readFileSync(path.join(projectRoot, "pubspec.yaml"), "utf-8");
|
|
80
|
+
const match = pubspec.match(/^name:\s*(\S+)/m);
|
|
81
|
+
if (match)
|
|
82
|
+
packageName = match[1];
|
|
83
|
+
}
|
|
84
|
+
catch { }
|
|
85
|
+
for (const line of content.split("\n")) {
|
|
86
|
+
const trimmed = line.trim();
|
|
87
|
+
if (trimmed.length > 0 &&
|
|
88
|
+
!trimmed.startsWith("import ") &&
|
|
89
|
+
!trimmed.startsWith("//") &&
|
|
90
|
+
!trimmed.startsWith("library ") &&
|
|
91
|
+
!trimmed.startsWith("part ") &&
|
|
92
|
+
!trimmed.startsWith("export ")) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
const match = trimmed.match(IMPORT_RE);
|
|
96
|
+
if (!match)
|
|
97
|
+
continue;
|
|
98
|
+
const importPath = match[1];
|
|
99
|
+
if (importPath.startsWith("dart:"))
|
|
100
|
+
continue;
|
|
101
|
+
if (importPath.startsWith("package:")) {
|
|
102
|
+
const pkgPrefix = `package:${packageName}/`;
|
|
103
|
+
if (!importPath.startsWith(pkgPrefix))
|
|
104
|
+
continue;
|
|
105
|
+
const relative = importPath.slice(pkgPrefix.length);
|
|
106
|
+
imports.push(path.normalize(path.join(libDir, relative)));
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const fileDir = path.dirname(filePath);
|
|
110
|
+
imports.push(path.normalize(path.resolve(fileDir, importPath)));
|
|
111
|
+
}
|
|
112
|
+
return imports;
|
|
113
|
+
},
|
|
114
|
+
classifyLayer(relPath) {
|
|
115
|
+
const lower = relPath.toLowerCase();
|
|
116
|
+
const fileName = lower.split("/").pop() || "";
|
|
117
|
+
if (lower.includes("/presentation/") || lower.includes("/widgets/") ||
|
|
118
|
+
lower.includes("/screens/") || lower.includes("/pages/") ||
|
|
119
|
+
fileName.endsWith("_screen.dart") || fileName.endsWith("_page.dart") ||
|
|
120
|
+
fileName.endsWith("_widget.dart") || fileName.endsWith("_dialog.dart") ||
|
|
121
|
+
fileName.endsWith("_view.dart") || fileName.endsWith("_card.dart") ||
|
|
122
|
+
fileName.endsWith("_tile.dart") || fileName.endsWith("_form.dart") ||
|
|
123
|
+
fileName.endsWith("_bottom_sheet.dart")) {
|
|
124
|
+
return "FE";
|
|
125
|
+
}
|
|
126
|
+
if (lower.includes("/data/") || lower.includes("/domain/") ||
|
|
127
|
+
lower.includes("/application/") || lower.includes("/providers/") ||
|
|
128
|
+
lower.includes("/notifiers/") ||
|
|
129
|
+
fileName.endsWith("_repository.dart") || fileName.endsWith("_service.dart") ||
|
|
130
|
+
fileName.endsWith("_provider.dart") || fileName.endsWith("_notifier.dart") ||
|
|
131
|
+
fileName.endsWith("_controller.dart") || fileName.endsWith("_usecase.dart") ||
|
|
132
|
+
fileName.endsWith("_state.dart") || fileName.endsWith("_bloc.dart") ||
|
|
133
|
+
fileName.endsWith("_cubit.dart")) {
|
|
134
|
+
return "BE";
|
|
135
|
+
}
|
|
136
|
+
if (lower.includes("/models/") || lower.includes("/entities/") ||
|
|
137
|
+
fileName.endsWith("_model.dart") || fileName.endsWith("_entity.dart") ||
|
|
138
|
+
fileName.endsWith("_dto.dart")) {
|
|
139
|
+
return "DB";
|
|
140
|
+
}
|
|
141
|
+
if (lower.includes("/api/") || fileName.includes("cloud_function") ||
|
|
142
|
+
fileName.endsWith("_api.dart") || fileName.endsWith("_client.dart") ||
|
|
143
|
+
fileName.endsWith("_remote.dart") || fileName.includes("_datasource") ||
|
|
144
|
+
fileName.includes("_data_source")) {
|
|
145
|
+
return "API";
|
|
146
|
+
}
|
|
147
|
+
if (lower.includes("/config/") || lower.includes("/theme/") ||
|
|
148
|
+
lower.includes("/router/") || lower.includes("/routing/") ||
|
|
149
|
+
fileName.endsWith("_config.dart") || fileName.endsWith("_theme.dart") ||
|
|
150
|
+
fileName.endsWith("_constants.dart") || fileName.endsWith("_routes.dart") ||
|
|
151
|
+
fileName === "main.dart") {
|
|
152
|
+
return "CONFIG";
|
|
153
|
+
}
|
|
154
|
+
if (lower.includes("/utils/") || lower.includes("/helpers/") ||
|
|
155
|
+
lower.includes("/extensions/") || lower.includes("shared/") ||
|
|
156
|
+
fileName.endsWith("_util.dart") || fileName.endsWith("_helper.dart") ||
|
|
157
|
+
fileName.endsWith("_extension.dart") || fileName.endsWith("_mixin.dart")) {
|
|
158
|
+
return "UTIL";
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
},
|
|
162
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.goPlugin = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const plugin_1 = require("./plugin");
|
|
40
|
+
const IMPORT_LINE_RE = /^\s*"([^"]+)"/;
|
|
41
|
+
exports.goPlugin = {
|
|
42
|
+
id: "go",
|
|
43
|
+
name: "Go",
|
|
44
|
+
extensions: [".go"],
|
|
45
|
+
codeBlockLang: "go",
|
|
46
|
+
detectProject(root) {
|
|
47
|
+
return fs.existsSync(path.join(root, "go.mod"));
|
|
48
|
+
},
|
|
49
|
+
getSourceDirs(root) {
|
|
50
|
+
return [root];
|
|
51
|
+
},
|
|
52
|
+
getPackageName(root) {
|
|
53
|
+
try {
|
|
54
|
+
const goMod = fs.readFileSync(path.join(root, "go.mod"), "utf-8");
|
|
55
|
+
const match = goMod.match(/^module\s+(\S+)/m);
|
|
56
|
+
return match ? match[1] : path.basename(root);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return path.basename(root);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
discoverFiles(dir) {
|
|
63
|
+
return (0, plugin_1.discoverAllFiles)(dir, [".go"]).filter(f => !f.endsWith("_test.go"));
|
|
64
|
+
},
|
|
65
|
+
parseImports(filePath, projectRoot, _sourceDir) {
|
|
66
|
+
let content;
|
|
67
|
+
try {
|
|
68
|
+
content = fs.readFileSync(filePath, "utf-8");
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
// Get module prefix from go.mod
|
|
74
|
+
let modulePrefix = "";
|
|
75
|
+
try {
|
|
76
|
+
const goMod = fs.readFileSync(path.join(projectRoot, "go.mod"), "utf-8");
|
|
77
|
+
const match = goMod.match(/^module\s+(\S+)/m);
|
|
78
|
+
if (match)
|
|
79
|
+
modulePrefix = match[1];
|
|
80
|
+
}
|
|
81
|
+
catch { }
|
|
82
|
+
const imports = [];
|
|
83
|
+
// Parse import block or single imports
|
|
84
|
+
const importBlockMatch = content.match(/import\s*\(([\s\S]*?)\)/);
|
|
85
|
+
const singleImports = content.matchAll(/^import\s+"([^"]+)"/gm);
|
|
86
|
+
const importLines = [];
|
|
87
|
+
if (importBlockMatch) {
|
|
88
|
+
importLines.push(...importBlockMatch[1].split("\n"));
|
|
89
|
+
}
|
|
90
|
+
for (const m of singleImports) {
|
|
91
|
+
importLines.push(`"${m[1]}"`);
|
|
92
|
+
}
|
|
93
|
+
for (const line of importLines) {
|
|
94
|
+
const match = line.match(IMPORT_LINE_RE);
|
|
95
|
+
if (!match)
|
|
96
|
+
continue;
|
|
97
|
+
const importPath = match[1];
|
|
98
|
+
// Only include internal module imports
|
|
99
|
+
if (modulePrefix && importPath.startsWith(modulePrefix + "/")) {
|
|
100
|
+
const relImport = importPath.slice(modulePrefix.length + 1);
|
|
101
|
+
const resolved = path.normalize(path.join(projectRoot, relImport));
|
|
102
|
+
// Go packages are directories, find any .go file in it
|
|
103
|
+
if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {
|
|
104
|
+
const goFiles = (0, plugin_1.discoverAllFiles)(resolved, [".go"]).filter(f => !f.endsWith("_test.go"));
|
|
105
|
+
imports.push(...goFiles);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return imports;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.javaPlugin = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const plugin_1 = require("./plugin");
|
|
40
|
+
const IMPORT_RE = /^import\s+([\w.]+)\s*;/;
|
|
41
|
+
exports.javaPlugin = {
|
|
42
|
+
id: "java",
|
|
43
|
+
name: "Java",
|
|
44
|
+
extensions: [".java"],
|
|
45
|
+
codeBlockLang: "java",
|
|
46
|
+
detectProject(root) {
|
|
47
|
+
return fs.existsSync(path.join(root, "pom.xml")) ||
|
|
48
|
+
fs.existsSync(path.join(root, "build.gradle")) ||
|
|
49
|
+
fs.existsSync(path.join(root, "build.gradle.kts"));
|
|
50
|
+
},
|
|
51
|
+
getSourceDirs(root) {
|
|
52
|
+
const mainJava = path.join(root, "src", "main", "java");
|
|
53
|
+
if (fs.existsSync(mainJava))
|
|
54
|
+
return [mainJava];
|
|
55
|
+
const src = path.join(root, "src");
|
|
56
|
+
if (fs.existsSync(src))
|
|
57
|
+
return [src];
|
|
58
|
+
return [];
|
|
59
|
+
},
|
|
60
|
+
getPackageName(root) {
|
|
61
|
+
// Try reading from pom.xml
|
|
62
|
+
try {
|
|
63
|
+
const pom = fs.readFileSync(path.join(root, "pom.xml"), "utf-8");
|
|
64
|
+
const groupMatch = pom.match(/<groupId>([^<]+)<\/groupId>/);
|
|
65
|
+
const artifactMatch = pom.match(/<artifactId>([^<]+)<\/artifactId>/);
|
|
66
|
+
if (groupMatch && artifactMatch) {
|
|
67
|
+
return `${groupMatch[1]}.${artifactMatch[1]}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch { }
|
|
71
|
+
return path.basename(root);
|
|
72
|
+
},
|
|
73
|
+
discoverFiles(dir) {
|
|
74
|
+
return (0, plugin_1.discoverAllFiles)(dir, [".java"]);
|
|
75
|
+
},
|
|
76
|
+
parseImports(filePath, _projectRoot, sourceDir) {
|
|
77
|
+
let content;
|
|
78
|
+
try {
|
|
79
|
+
content = fs.readFileSync(filePath, "utf-8");
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const imports = [];
|
|
85
|
+
for (const line of content.split("\n")) {
|
|
86
|
+
const trimmed = line.trim();
|
|
87
|
+
if (trimmed.length > 0 &&
|
|
88
|
+
!trimmed.startsWith("import ") &&
|
|
89
|
+
!trimmed.startsWith("package ") &&
|
|
90
|
+
!trimmed.startsWith("//") &&
|
|
91
|
+
!trimmed.startsWith("/*") &&
|
|
92
|
+
!trimmed.startsWith("*")) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
const match = trimmed.match(IMPORT_RE);
|
|
96
|
+
if (!match)
|
|
97
|
+
continue;
|
|
98
|
+
const importPath = match[1];
|
|
99
|
+
// Skip standard library and common frameworks
|
|
100
|
+
if (importPath.startsWith("java.") || importPath.startsWith("javax.") ||
|
|
101
|
+
importPath.startsWith("org.springframework.") || importPath.startsWith("lombok.")) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
// Convert dots to path separators
|
|
105
|
+
const relFile = importPath.replace(/\./g, path.sep) + ".java";
|
|
106
|
+
const resolved = path.normalize(path.join(sourceDir, relFile));
|
|
107
|
+
if (fs.existsSync(resolved)) {
|
|
108
|
+
imports.push(resolved);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return imports;
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface LanguagePlugin {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
extensions: string[];
|
|
5
|
+
codeBlockLang: string;
|
|
6
|
+
detectProject(root: string): boolean;
|
|
7
|
+
getSourceDirs(root: string): string[];
|
|
8
|
+
getPackageName(root: string): string;
|
|
9
|
+
discoverFiles(dir: string): string[];
|
|
10
|
+
parseImports(filePath: string, projectRoot: string, sourceDir: string): string[];
|
|
11
|
+
classifyLayer?(relPath: string): string | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function registerPlugin(plugin: LanguagePlugin): void;
|
|
14
|
+
export declare function getPlugins(): LanguagePlugin[];
|
|
15
|
+
export declare function getPluginById(id: string): LanguagePlugin | undefined;
|
|
16
|
+
export declare function getPluginForFile(filePath: string): LanguagePlugin | undefined;
|
|
17
|
+
export declare function detectLanguages(root: string): LanguagePlugin[];
|
|
18
|
+
export declare function detectProjectRoot(startDir?: string): string;
|
|
19
|
+
export declare function detectPackageName(root: string, detectedPlugins: LanguagePlugin[]): string;
|
|
20
|
+
export declare function discoverAllFiles(rootDir: string, extensions: string[], extraSkipDirs?: string[]): string[];
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.registerPlugin = registerPlugin;
|
|
37
|
+
exports.getPlugins = getPlugins;
|
|
38
|
+
exports.getPluginById = getPluginById;
|
|
39
|
+
exports.getPluginForFile = getPluginForFile;
|
|
40
|
+
exports.detectLanguages = detectLanguages;
|
|
41
|
+
exports.detectProjectRoot = detectProjectRoot;
|
|
42
|
+
exports.detectPackageName = detectPackageName;
|
|
43
|
+
exports.discoverAllFiles = discoverAllFiles;
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
// ── Registry ──
|
|
47
|
+
const plugins = [];
|
|
48
|
+
function registerPlugin(plugin) {
|
|
49
|
+
plugins.push(plugin);
|
|
50
|
+
}
|
|
51
|
+
function getPlugins() {
|
|
52
|
+
return plugins;
|
|
53
|
+
}
|
|
54
|
+
function getPluginById(id) {
|
|
55
|
+
return plugins.find(p => p.id === id);
|
|
56
|
+
}
|
|
57
|
+
function getPluginForFile(filePath) {
|
|
58
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
59
|
+
return plugins.find(p => p.extensions.includes(ext));
|
|
60
|
+
}
|
|
61
|
+
// ── Auto-detect ──
|
|
62
|
+
function detectLanguages(root) {
|
|
63
|
+
return plugins.filter(p => p.detectProject(root));
|
|
64
|
+
}
|
|
65
|
+
function detectProjectRoot(startDir) {
|
|
66
|
+
let dir = startDir || process.cwd();
|
|
67
|
+
const manifestFiles = [
|
|
68
|
+
"pubspec.yaml", "package.json", "tsconfig.json",
|
|
69
|
+
"pyproject.toml", "requirements.txt", "setup.py",
|
|
70
|
+
"go.mod", "Cargo.toml",
|
|
71
|
+
"pom.xml", "build.gradle",
|
|
72
|
+
"CMakeLists.txt", "Makefile",
|
|
73
|
+
"Gemfile",
|
|
74
|
+
];
|
|
75
|
+
for (let i = 0; i < 20; i++) {
|
|
76
|
+
if (fs.existsSync(path.join(dir, ".git")))
|
|
77
|
+
return dir;
|
|
78
|
+
for (const f of manifestFiles) {
|
|
79
|
+
if (fs.existsSync(path.join(dir, f)))
|
|
80
|
+
return dir;
|
|
81
|
+
}
|
|
82
|
+
const parent = path.dirname(dir);
|
|
83
|
+
if (parent === dir)
|
|
84
|
+
break;
|
|
85
|
+
dir = parent;
|
|
86
|
+
}
|
|
87
|
+
return startDir || process.cwd();
|
|
88
|
+
}
|
|
89
|
+
function detectPackageName(root, detectedPlugins) {
|
|
90
|
+
for (const plugin of detectedPlugins) {
|
|
91
|
+
const name = plugin.getPackageName(root);
|
|
92
|
+
if (name)
|
|
93
|
+
return name;
|
|
94
|
+
}
|
|
95
|
+
return path.basename(root);
|
|
96
|
+
}
|
|
97
|
+
// ── Common Utilities ──
|
|
98
|
+
const SKIP_DIRS = new Set([
|
|
99
|
+
"node_modules", ".git", "dist", "build", ".dart_tool", ".pub-cache",
|
|
100
|
+
"__pycache__", ".mypy_cache", ".pytest_cache", "venv", ".venv",
|
|
101
|
+
"target", "vendor", ".gradle", "bin", "obj",
|
|
102
|
+
]);
|
|
103
|
+
function discoverAllFiles(rootDir, extensions, extraSkipDirs) {
|
|
104
|
+
const results = [];
|
|
105
|
+
if (!fs.existsSync(rootDir))
|
|
106
|
+
return results;
|
|
107
|
+
const skipSet = extraSkipDirs
|
|
108
|
+
? new Set([...SKIP_DIRS, ...extraSkipDirs])
|
|
109
|
+
: SKIP_DIRS;
|
|
110
|
+
function walk(dir) {
|
|
111
|
+
let entries;
|
|
112
|
+
try {
|
|
113
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
for (const entry of entries) {
|
|
119
|
+
if (entry.isDirectory()) {
|
|
120
|
+
if (skipSet.has(entry.name))
|
|
121
|
+
continue;
|
|
122
|
+
walk(path.join(dir, entry.name));
|
|
123
|
+
}
|
|
124
|
+
else if (entry.isFile() && extensions.some(ext => entry.name.endsWith(ext))) {
|
|
125
|
+
results.push(path.normalize(path.join(dir, entry.name)));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
walk(rootDir);
|
|
130
|
+
return results;
|
|
131
|
+
}
|
|
132
|
+
// ── Register All Plugins ──
|
|
133
|
+
const dart_1 = require("./dart");
|
|
134
|
+
const typescript_1 = require("./typescript");
|
|
135
|
+
const python_1 = require("./python");
|
|
136
|
+
const go_1 = require("./go");
|
|
137
|
+
const rust_1 = require("./rust");
|
|
138
|
+
const java_1 = require("./java");
|
|
139
|
+
const cpp_1 = require("./cpp");
|
|
140
|
+
const ruby_1 = require("./ruby");
|
|
141
|
+
registerPlugin(dart_1.dartPlugin);
|
|
142
|
+
registerPlugin(typescript_1.typescriptPlugin);
|
|
143
|
+
registerPlugin(python_1.pythonPlugin);
|
|
144
|
+
registerPlugin(go_1.goPlugin);
|
|
145
|
+
registerPlugin(rust_1.rustPlugin);
|
|
146
|
+
registerPlugin(java_1.javaPlugin);
|
|
147
|
+
registerPlugin(cpp_1.cppPlugin);
|
|
148
|
+
registerPlugin(ruby_1.rubyPlugin);
|