@fmatar/archlens-skill 0.1.0-Beta-02 → 0.1.0-Beta-03

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fmatar/archlens-skill",
3
- "version": "0.1.0-Beta-02",
3
+ "version": "0.1.0-Beta-03",
4
4
  "description": "Cross-platform CLI and installer for Archlens Clean Architecture governance policies and AI assistant skills",
5
5
  "main": "src/installer.js",
6
6
  "type": "module",
package/src/analyzer.js CHANGED
@@ -47,6 +47,79 @@ export function detectProjectLanguage(projectRoot) {
47
47
  return 'java';
48
48
  }
49
49
 
50
+ function findNestedSourceRoots(dir, lang, depth = 0, maxDepth = 5, results = []) {
51
+ if (depth > maxDepth || !fs.existsSync(dir)) {
52
+ return results;
53
+ }
54
+
55
+ const skipDirs = new Set([
56
+ '.git',
57
+ 'node_modules',
58
+ 'target',
59
+ 'build',
60
+ '.gradle',
61
+ '.idea',
62
+ '.vscode',
63
+ '.svelte-kit',
64
+ 'dist',
65
+ 'out',
66
+ 'bin',
67
+ '.archlens',
68
+ '.uml-viewer',
69
+ '.mvn',
70
+ 'infra',
71
+ 'cpln',
72
+ 'assets',
73
+ 'screenshots',
74
+ 'docs'
75
+ ]);
76
+
77
+ try {
78
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
79
+ for (const entry of entries) {
80
+ if (!entry.isDirectory() || skipDirs.has(entry.name) || entry.name.startsWith('.')) {
81
+ continue;
82
+ }
83
+
84
+ const fullPath = path.join(dir, entry.name);
85
+
86
+ if (lang === 'java' && fullPath.endsWith(path.join('src', 'main', 'java'))) {
87
+ results.push(fullPath);
88
+ continue;
89
+ }
90
+ if (
91
+ lang === 'kotlin' &&
92
+ (fullPath.endsWith(path.join('src', 'main', 'kotlin')) ||
93
+ fullPath.endsWith(path.join('src', 'main', 'java')))
94
+ ) {
95
+ results.push(fullPath);
96
+ continue;
97
+ }
98
+ if ((lang === 'typescript' || lang === 'javascript') && entry.name === 'src') {
99
+ results.push(fullPath);
100
+ continue;
101
+ }
102
+ if (lang === 'python' && (entry.name === 'src' || entry.name === 'app')) {
103
+ results.push(fullPath);
104
+ continue;
105
+ }
106
+ if (
107
+ lang === 'go' &&
108
+ (entry.name === 'pkg' || entry.name === 'internal' || entry.name === 'cmd')
109
+ ) {
110
+ results.push(fullPath);
111
+ continue;
112
+ }
113
+
114
+ findNestedSourceRoots(fullPath, lang, depth + 1, maxDepth, results);
115
+ }
116
+ } catch {
117
+ // Gracefully handle unreadable directories
118
+ }
119
+
120
+ return results;
121
+ }
122
+
50
123
  export function detectSourceRoot(projectRoot, lang) {
51
124
  const root = path.resolve(projectRoot);
52
125
 
@@ -64,12 +137,48 @@ export function detectSourceRoot(projectRoot, lang) {
64
137
  const candidates = candidateMap[lang] || ['src', '.'];
65
138
 
66
139
  for (const cand of candidates) {
140
+ if (cand === '.') continue;
67
141
  const p = path.join(root, cand);
68
142
  if (fs.existsSync(p) && fs.statSync(p).isDirectory()) {
69
143
  return cand;
70
144
  }
71
145
  }
72
146
 
147
+ // Multi-module dynamic discovery if standard candidates are not found
148
+ const nested = findNestedSourceRoots(root, lang);
149
+ if (nested.length > 0) {
150
+ const ext =
151
+ lang === 'java'
152
+ ? '.java'
153
+ : lang === 'kotlin'
154
+ ? '.kt'
155
+ : lang === 'typescript'
156
+ ? '.ts'
157
+ : lang === 'python'
158
+ ? '.py'
159
+ : '';
160
+ const ranked = nested.map((dir) => {
161
+ const rel = path.relative(root, dir).replace(/\\/g, '/');
162
+ const files = ext
163
+ ? findMatchingFiles(dir, (f) => f.endsWith(ext), 100)
164
+ : [];
165
+ let score = files.length;
166
+ const lower = rel.toLowerCase();
167
+ if (lower.includes('api')) score += 15;
168
+ if (lower.includes('backend') || lower.includes('server')) score += 10;
169
+ if (lower.includes('core') || lower.includes('app')) score += 5;
170
+ return { rel, score };
171
+ });
172
+ ranked.sort((a, b) => b.score - a.score);
173
+ if (ranked[0] && ranked[0].rel) {
174
+ return ranked[0].rel;
175
+ }
176
+ }
177
+
178
+ if (candidates.includes('.')) {
179
+ return '.';
180
+ }
181
+
73
182
  return 'src';
74
183
  }
75
184
 
package/src/mcp-server.js CHANGED
@@ -237,7 +237,7 @@ export async function handleMcpMessage(request, options = {}, deps = {}) {
237
237
  },
238
238
  serverInfo: {
239
239
  name: 'archlens-mcp-server',
240
- version: options.version || '0.1.0-Beta-02'
240
+ version: options.version || '0.1.0-Beta-03'
241
241
  }
242
242
  }
243
243
  };