@mrpatronz/nexusflow 0.2.18 → 1.3.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.
Files changed (236) hide show
  1. package/README.md +27 -3
  2. package/dist/analyzers/index.d.ts +23 -0
  3. package/dist/analyzers/index.d.ts.map +1 -1
  4. package/dist/analyzers/index.js +62 -0
  5. package/dist/analyzers/index.js.map +1 -1
  6. package/dist/commands/commands.test.js +20 -6
  7. package/dist/commands/commands.test.js.map +1 -1
  8. package/dist/commands/commit.d.ts +2 -0
  9. package/dist/commands/commit.d.ts.map +1 -1
  10. package/dist/commands/commit.js +27 -5
  11. package/dist/commands/commit.js.map +1 -1
  12. package/dist/commands/diff.d.ts +9 -2
  13. package/dist/commands/diff.d.ts.map +1 -1
  14. package/dist/commands/diff.js +36 -12
  15. package/dist/commands/diff.js.map +1 -1
  16. package/dist/commands/doctor.js +2 -2
  17. package/dist/commands/doctor.js.map +1 -1
  18. package/dist/commands/handoff.js +2 -2
  19. package/dist/commands/handoff.js.map +1 -1
  20. package/dist/commands/refresh.d.ts +4 -2
  21. package/dist/commands/refresh.d.ts.map +1 -1
  22. package/dist/commands/refresh.js +20 -36
  23. package/dist/commands/refresh.js.map +1 -1
  24. package/dist/commands/schedule.d.ts +35 -0
  25. package/dist/commands/schedule.d.ts.map +1 -0
  26. package/dist/commands/schedule.js +151 -0
  27. package/dist/commands/schedule.js.map +1 -0
  28. package/dist/commands/sync.d.ts.map +1 -1
  29. package/dist/commands/sync.js +58 -50
  30. package/dist/commands/sync.js.map +1 -1
  31. package/dist/core/analysis-cache.d.ts +58 -0
  32. package/dist/core/analysis-cache.d.ts.map +1 -0
  33. package/dist/core/analysis-cache.js +116 -0
  34. package/dist/core/analysis-cache.js.map +1 -0
  35. package/dist/core/analysis-cache.test.d.ts +2 -0
  36. package/dist/core/analysis-cache.test.d.ts.map +1 -0
  37. package/dist/core/analysis-cache.test.js +108 -0
  38. package/dist/core/analysis-cache.test.js.map +1 -0
  39. package/dist/core/refresh.d.ts +41 -0
  40. package/dist/core/refresh.d.ts.map +1 -0
  41. package/dist/core/refresh.js +60 -0
  42. package/dist/core/refresh.js.map +1 -0
  43. package/dist/core/scheduler.d.ts +117 -0
  44. package/dist/core/scheduler.d.ts.map +1 -0
  45. package/dist/core/scheduler.js +247 -0
  46. package/dist/core/scheduler.js.map +1 -0
  47. package/dist/core/scheduler.test.d.ts +2 -0
  48. package/dist/core/scheduler.test.d.ts.map +1 -0
  49. package/dist/core/scheduler.test.js +111 -0
  50. package/dist/core/scheduler.test.js.map +1 -0
  51. package/dist/core/sync.d.ts +50 -0
  52. package/dist/core/sync.d.ts.map +1 -0
  53. package/dist/core/sync.js +92 -0
  54. package/dist/core/sync.js.map +1 -0
  55. package/dist/core/workspace-state.d.ts +51 -0
  56. package/dist/core/workspace-state.d.ts.map +1 -0
  57. package/dist/core/workspace-state.js +108 -0
  58. package/dist/core/workspace-state.js.map +1 -0
  59. package/dist/core/workspace-state.test.d.ts +2 -0
  60. package/dist/core/workspace-state.test.d.ts.map +1 -0
  61. package/dist/core/workspace-state.test.js +84 -0
  62. package/dist/core/workspace-state.test.js.map +1 -0
  63. package/dist/generators/index.d.ts +7 -1
  64. package/dist/generators/index.d.ts.map +1 -1
  65. package/dist/generators/index.js +14 -1
  66. package/dist/generators/index.js.map +1 -1
  67. package/dist/gui/assets/index-Bdbld6yY.css +1 -0
  68. package/dist/gui/assets/index-D8iJPvnk.js +26 -0
  69. package/dist/gui/index.html +2 -2
  70. package/dist/index.js +107 -4
  71. package/dist/index.js.map +1 -1
  72. package/dist/mcp/server.d.ts.map +1 -1
  73. package/dist/mcp/server.js +42 -0
  74. package/dist/mcp/server.js.map +1 -1
  75. package/dist/server.d.ts.map +1 -1
  76. package/dist/server.js +175 -13
  77. package/dist/server.js.map +1 -1
  78. package/dist/server.test.js +66 -0
  79. package/dist/server.test.js.map +1 -1
  80. package/dist/types.d.ts +31 -0
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/utils/multi-git.d.ts +54 -8
  83. package/dist/utils/multi-git.d.ts.map +1 -1
  84. package/dist/utils/multi-git.js +129 -21
  85. package/dist/utils/multi-git.js.map +1 -1
  86. package/dist/utils/multi-git.test.d.ts +2 -0
  87. package/dist/utils/multi-git.test.d.ts.map +1 -0
  88. package/dist/utils/multi-git.test.js +125 -0
  89. package/dist/utils/multi-git.test.js.map +1 -0
  90. package/package.json +13 -1
  91. package/.agents/skills/ccc/SKILL.md +0 -71
  92. package/.agents/skills/ccc/references/management.md +0 -110
  93. package/.agents/skills/ccc/references/settings.md +0 -126
  94. package/.github/dependabot.yml +0 -52
  95. package/.github/workflows/ci.yml +0 -44
  96. package/.github/workflows/dependabot-merge.yml +0 -53
  97. package/.github/workflows/release-desktop.yml +0 -67
  98. package/.github/workflows/release-npm.yml +0 -65
  99. package/.github/workflows/release-vscode.yml +0 -61
  100. package/.vscode/launch.json +0 -17
  101. package/.vscode/tasks.json +0 -17
  102. package/GETTING_STARTED.md +0 -114
  103. package/desktop/build-installer.js +0 -228
  104. package/desktop/build.js +0 -118
  105. package/desktop/installer/nexusflow.iss +0 -35
  106. package/desktop/neutralino.config.json +0 -39
  107. package/desktop/package-lock.json +0 -1060
  108. package/desktop/package.json +0 -14
  109. package/dist/gui/assets/index-CB-jWded.css +0 -1
  110. package/dist/gui/assets/index-DDXpZZu3.js +0 -25
  111. package/extension/media/icon.svg +0 -1
  112. package/extension/package-lock.json +0 -6044
  113. package/extension/package.json +0 -117
  114. package/extension/src/extension.ts +0 -653
  115. package/extension/tsconfig.json +0 -21
  116. package/gui/README.md +0 -73
  117. package/gui/e2e/wizard.spec.ts +0 -346
  118. package/gui/eslint.config.js +0 -26
  119. package/gui/index.html +0 -17
  120. package/gui/package-lock.json +0 -3079
  121. package/gui/package.json +0 -36
  122. package/gui/playwright.config.ts +0 -41
  123. package/gui/public/app_logo.png +0 -0
  124. package/gui/public/favicon.svg +0 -1
  125. package/gui/public/icons.svg +0 -24
  126. package/gui/src/App.css +0 -1
  127. package/gui/src/App.tsx +0 -3632
  128. package/gui/src/assets/hero.png +0 -0
  129. package/gui/src/assets/react.svg +0 -1
  130. package/gui/src/assets/vite.svg +0 -1
  131. package/gui/src/features/changes/ChangesViewer.tsx +0 -388
  132. package/gui/src/features/knowledge/KnowledgeBase.tsx +0 -84
  133. package/gui/src/features/onboarding/OnboardingWizard.tsx +0 -230
  134. package/gui/src/features/plan/ImplementationPlan.tsx +0 -32
  135. package/gui/src/features/services/ServiceConsole.tsx +0 -250
  136. package/gui/src/features/sessions/SessionHistory.tsx +0 -195
  137. package/gui/src/features/workspace/WorkspaceList.tsx +0 -666
  138. package/gui/src/index.css +0 -152
  139. package/gui/src/main.tsx +0 -94
  140. package/gui/src/types.ts +0 -62
  141. package/gui/tsconfig.app.json +0 -25
  142. package/gui/tsconfig.json +0 -7
  143. package/gui/tsconfig.node.json +0 -24
  144. package/gui/vite.config.ts +0 -12
  145. package/resources/workflows/plan-implement-review.md +0 -8
  146. package/resources/workflows/research-verify.md +0 -6
  147. package/resources/workflows/solo-developer.md +0 -3
  148. package/scripts/simulate-workspaces.ts +0 -55
  149. package/skills-lock.json +0 -11
  150. package/src/analyzers/detect-apis.ts +0 -290
  151. package/src/analyzers/detect-deps.ts +0 -315
  152. package/src/analyzers/detect-existing.ts +0 -74
  153. package/src/analyzers/detect-ports.ts +0 -110
  154. package/src/analyzers/index.ts +0 -97
  155. package/src/analyzers/messaging-analyzer.ts +0 -254
  156. package/src/analyzers/readme-summarizer.ts +0 -102
  157. package/src/analyzers/run-analyzer.ts +0 -269
  158. package/src/analyzers/tech-stack.ts +0 -283
  159. package/src/commands/adapter.ts +0 -348
  160. package/src/commands/add-repo.ts +0 -156
  161. package/src/commands/commands.test.ts +0 -156
  162. package/src/commands/commit.ts +0 -131
  163. package/src/commands/config.ts +0 -52
  164. package/src/commands/create.ts +0 -204
  165. package/src/commands/desktop.ts +0 -128
  166. package/src/commands/diff.ts +0 -125
  167. package/src/commands/doctor.ts +0 -370
  168. package/src/commands/handoff.ts +0 -266
  169. package/src/commands/init.ts +0 -134
  170. package/src/commands/list.ts +0 -46
  171. package/src/commands/logs.ts +0 -63
  172. package/src/commands/mcp.ts +0 -94
  173. package/src/commands/open.ts +0 -129
  174. package/src/commands/refresh.ts +0 -137
  175. package/src/commands/remove.ts +0 -98
  176. package/src/commands/start.ts +0 -117
  177. package/src/commands/status.ts +0 -54
  178. package/src/commands/stop.ts +0 -55
  179. package/src/commands/sync.ts +0 -147
  180. package/src/commands/tui.ts +0 -484
  181. package/src/commands/ui.ts +0 -111
  182. package/src/core/adapters/local-storage.ts +0 -66
  183. package/src/core/adapters/obsidian-storage.ts +0 -151
  184. package/src/core/adapters/registry.ts +0 -44
  185. package/src/core/adapters/storage.test.ts +0 -174
  186. package/src/core/adapters/vault-storage.ts +0 -86
  187. package/src/core/config.test.ts +0 -96
  188. package/src/core/config.ts +0 -140
  189. package/src/core/graph.ts +0 -344
  190. package/src/core/plugins/index.ts +0 -17
  191. package/src/core/plugins/loader.ts +0 -36
  192. package/src/core/ports/storage.ts +0 -71
  193. package/src/core/scanner.test.ts +0 -61
  194. package/src/core/scanner.ts +0 -91
  195. package/src/core/storage.ts +0 -37
  196. package/src/core/workspace.ts +0 -487
  197. package/src/core/worktree.ts +0 -120
  198. package/src/generators/antigravity.ts +0 -32
  199. package/src/generators/base.ts +0 -243
  200. package/src/generators/claude.ts +0 -34
  201. package/src/generators/codex.ts +0 -48
  202. package/src/generators/copilot.ts +0 -56
  203. package/src/generators/cursor.ts +0 -44
  204. package/src/generators/diff-context.ts +0 -75
  205. package/src/generators/index.ts +0 -322
  206. package/src/generators/map-generator.test.ts +0 -159
  207. package/src/generators/map-generator.ts +0 -539
  208. package/src/generators/plan-generator.ts +0 -483
  209. package/src/generators/skills-generator.ts +0 -259
  210. package/src/index.ts +0 -539
  211. package/src/mcp/server.ts +0 -294
  212. package/src/orchestration/detect.ts +0 -313
  213. package/src/orchestration/index.ts +0 -7
  214. package/src/orchestration/runner.ts +0 -283
  215. package/src/server.test.ts +0 -618
  216. package/src/server.ts +0 -1314
  217. package/src/types.ts +0 -415
  218. package/src/utils/detect-ai.test.ts +0 -44
  219. package/src/utils/detect-ai.ts +0 -84
  220. package/src/utils/detect-editors.test.ts +0 -48
  221. package/src/utils/detect-editors.ts +0 -57
  222. package/src/utils/git.test.ts +0 -74
  223. package/src/utils/git.ts +0 -117
  224. package/src/utils/local-ai.test.ts +0 -130
  225. package/src/utils/local-ai.ts +0 -116
  226. package/src/utils/multi-git.ts +0 -313
  227. package/src/utils/prompts.ts +0 -209
  228. package/src/utils/session-finder.ts +0 -483
  229. package/src/utils/system-scanner.test.ts +0 -89
  230. package/src/utils/system-scanner.ts +0 -96
  231. package/src/utils/update-check.ts +0 -286
  232. package/src/utils/workflow-advisor.ts +0 -118
  233. package/src/utils/workflows.test.ts +0 -114
  234. package/src/utils/workflows.ts +0 -178
  235. package/tsconfig.json +0 -19
  236. package/vitest.config.ts +0 -14
@@ -1,269 +0,0 @@
1
- /**
2
- * @module analyzers/run-analyzer
3
- * Analyzes projects to discover local run configurations, entry points,
4
- * database dependencies, external services, and flags shared staging/test
5
- * infrastructure or committed secrets.
6
- */
7
-
8
- import * as fs from 'node:fs';
9
- import * as fsp from 'node:fs/promises';
10
- import * as path from 'node:path';
11
- import { globby } from 'globby';
12
- import type { RunConfig, RunConfigEntryPoint, RunConfigDatabase, RunConfigSharedInfraWarning, RunConfigSecret } from '../types.js';
13
-
14
- /**
15
- * Analyzes local run configurations, databases, and dependencies in a repository.
16
- *
17
- * @param repoPath - Absolute path to the repository root.
18
- * @returns Run configuration analysis.
19
- */
20
- export async function analyzeRunConfig(repoPath: string): Promise<RunConfig> {
21
- const entryPoints: RunConfigEntryPoint[] = [];
22
- const databases: RunConfigDatabase[] = [];
23
- const sharedInfraWarnings: RunConfigSharedInfraWarning[] = [];
24
- const committedSecrets: RunConfigSecret[] = [];
25
- const externalDependencies: string[] = [];
26
-
27
- const isLocalHost = (host: string): boolean => {
28
- const h = host.toLowerCase().trim();
29
- return (
30
- h.includes('localhost') ||
31
- h.includes('127.0.0.1') ||
32
- h.includes('[::1]') ||
33
- h.includes('(localdb)') ||
34
- h === 'db' ||
35
- h === 'postgres' ||
36
- h === 'redis' ||
37
- h === 'mongo'
38
- );
39
- };
40
-
41
- try {
42
- // ── 1. Entry Points Detection ──────────────────────────────────────────
43
- // A. Check for C# Web/Worker apps
44
- const csprojFiles = await globby('**/*.csproj', {
45
- cwd: repoPath,
46
- absolute: true,
47
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
48
- });
49
-
50
- for (const file of csprojFiles) {
51
- try {
52
- const content = await fsp.readFile(file, 'utf-8');
53
- const relPath = path.relative(repoPath, file).replace(/\\/g, '/');
54
- if (content.includes('Sdk="Microsoft.NET.Sdk.Web"')) {
55
- entryPoints.push({
56
- projectPath: relPath,
57
- type: 'aspnet',
58
- command: 'dotnet run',
59
- });
60
- } else if (content.includes('Sdk="Microsoft.NET.Sdk.Worker"')) {
61
- entryPoints.push({
62
- projectPath: relPath,
63
- type: 'worker',
64
- command: 'dotnet run',
65
- });
66
- }
67
- } catch {}
68
- }
69
-
70
- // B. Check for package.json (Node/JS/TS)
71
- const packageJsonPath = path.join(repoPath, 'package.json');
72
- try {
73
- const raw = await fsp.readFile(packageJsonPath, 'utf-8');
74
- const pkg = JSON.parse(raw);
75
- if (pkg.scripts && (pkg.scripts.start || pkg.scripts.dev)) {
76
- entryPoints.push({
77
- projectPath: 'package.json',
78
- type: pkg.dependencies && pkg.dependencies.next ? 'nextjs' : 'node',
79
- command: pkg.scripts.dev ? 'npm run dev' : 'npm start',
80
- });
81
- }
82
- } catch {}
83
-
84
- // C. Check for Python/Go
85
- const goModFiles = await globby('**/go.mod', { cwd: repoPath, absolute: true });
86
- if (goModFiles.length > 0) {
87
- entryPoints.push({
88
- projectPath: path.relative(repoPath, goModFiles[0]!).replace(/\\/g, '/'),
89
- type: 'go',
90
- command: 'go run .',
91
- });
92
- }
93
-
94
- const pyFiles = await globby(['**/requirements.txt', '**/Pipfile', '**/pyproject.toml'], { cwd: repoPath, absolute: true });
95
- if (pyFiles.length > 0) {
96
- entryPoints.push({
97
- projectPath: path.relative(repoPath, pyFiles[0]!).replace(/\\/g, '/'),
98
- type: 'python',
99
- command: 'python main.py',
100
- });
101
- }
102
-
103
- // ── 2. Config Files Parsing (DBs, Shared Infra, Secrets) ───────────────
104
- const configFiles = await globby(
105
- ['**/appsettings.json', '**/appsettings.Development.json', '**/appsettings.*.json', '**/.env', '**/.env.development', '**/.env.local'],
106
- {
107
- cwd: repoPath,
108
- absolute: true,
109
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
110
- }
111
- );
112
-
113
- for (const file of configFiles) {
114
- try {
115
- const content = await fsp.readFile(file, 'utf-8');
116
- const relPath = path.relative(repoPath, file).replace(/\\/g, '/');
117
-
118
- // Secrets Check (Universal regex for high probability secrets)
119
- const secretRegex = /(?:password|pwd|secret|key|token|privatekey|accountkey|sharedaccesskey)\s*[=:]\s*['"`]?([^'";\s]{12,})['"`]?/gi;
120
- let secretMatch: RegExpExecArray | null;
121
- while ((secretMatch = secretRegex.exec(content)) !== null) {
122
- const matchedVal = secretMatch[1]!;
123
- // Skip if it looks like a placeholder
124
- if (!matchedVal.includes('placeholder') && !matchedVal.includes('<your') && !matchedVal.toLowerCase().includes('your_')) {
125
- committedSecrets.push({
126
- file: relPath,
127
- lineHint: secretMatch[0]!.split(/[=:]/)[0]!.trim(),
128
- });
129
- }
130
- }
131
-
132
- if (file.endsWith('.json')) {
133
- const parsed = JSON.parse(content);
134
-
135
- // connectionStrings
136
- if (parsed.ConnectionStrings) {
137
- for (const [key, value] of Object.entries(parsed.ConnectionStrings)) {
138
- if (typeof value === 'string') {
139
- let provider = 'unknown';
140
- if (value.toLowerCase().includes('sql server') || value.toLowerCase().includes('sqlexpress') || value.toLowerCase().includes('server=')) {
141
- provider = 'SQL Server';
142
- }
143
- if (value.toLowerCase().includes('postgresql') || value.toLowerCase().includes('port=5432')) {
144
- provider = 'PostgreSQL';
145
- }
146
-
147
- // Extract Host
148
- const hostMatch = value.match(/Server=([^;]+)/i) ?? value.match(/Host=([^;]+)/i) ?? value.match(/Data Source=([^;]+)/i);
149
- const host = hostMatch ? hostMatch[1]!.trim() : 'unknown';
150
-
151
- databases.push({
152
- provider,
153
- host,
154
- configFile: relPath,
155
- });
156
-
157
- if (host !== 'unknown' && !isLocalHost(host)) {
158
- sharedInfraWarnings.push({
159
- resource: key,
160
- host,
161
- configFile: relPath,
162
- warning: `⚠️ SHARED INFRA: ${relPath} binds ConnectionString "${key}" to non-local host (${host}). Running locally may connect to shared test/production databases.`,
163
- });
164
- }
165
- }
166
- }
167
- }
168
-
169
- // Service Bus or MQ settings
170
- const rabbitRegex = /"HostName"\s*:\s*"([^"]+)"/gi;
171
- let rabbitMatch: RegExpExecArray | null;
172
- while ((rabbitMatch = rabbitRegex.exec(content)) !== null) {
173
- const host = rabbitMatch[1]!;
174
- if (!isLocalHost(host)) {
175
- sharedInfraWarnings.push({
176
- resource: 'RabbitMQ',
177
- host,
178
- configFile: relPath,
179
- warning: `⚠️ SHARED INFRA: ${relPath} binds RabbitMQ host to non-local host (${host}).`,
180
- });
181
- }
182
- }
183
- } else {
184
- // B. .env parsing
185
- const lines = content.split('\n');
186
- for (const line of lines) {
187
- const cleanLine = line.trim();
188
- if (cleanLine.startsWith('#') || !cleanLine.includes('=')) continue;
189
-
190
- const [key, val] = cleanLine.split('=', 2);
191
- if (!key || !val) continue;
192
-
193
- const cleanKey = key.trim();
194
- const cleanVal = val.trim().replace(/^['"]|['"]$/g, '');
195
-
196
- // DB UrL e.g. DATABASE_URL=postgres://user:pass@host:port/db
197
- if (cleanKey.includes('DATABASE_URL') || cleanKey.includes('MONGODB_URI') || cleanKey.includes('REDIS_URL')) {
198
- let provider = 'unknown';
199
- if (cleanVal.startsWith('postgres')) provider = 'PostgreSQL';
200
- else if (cleanVal.startsWith('mongodb')) provider = 'MongoDB';
201
- else if (cleanVal.startsWith('redis')) provider = 'Redis';
202
-
203
- // Extract Host from URL
204
- const hostMatch = cleanVal.match(/@([^:/]+)/);
205
- const host = hostMatch ? hostMatch[1]! : cleanVal;
206
-
207
- databases.push({
208
- provider,
209
- host,
210
- configFile: relPath,
211
- });
212
-
213
- if (!isLocalHost(host)) {
214
- sharedInfraWarnings.push({
215
- resource: cleanKey,
216
- host,
217
- configFile: relPath,
218
- warning: `⚠️ SHARED INFRA: .env variable "${cleanKey}" points to non-local host (${host}).`,
219
- });
220
- }
221
- }
222
- }
223
- }
224
- } catch {}
225
- }
226
-
227
- } catch {
228
- // Ignore errors
229
- }
230
-
231
- // De-duplicate external dependencies / warnings
232
- const uniqueInfraWarnings: RunConfigSharedInfraWarning[] = [];
233
- const seenInfra = new Set<string>();
234
- for (const w of sharedInfraWarnings) {
235
- const key = `${w.resource}:${w.host}:${w.configFile}`;
236
- if (!seenInfra.has(key)) {
237
- seenInfra.add(key);
238
- uniqueInfraWarnings.push(w);
239
- }
240
- }
241
-
242
- const uniqueDatabases: RunConfigDatabase[] = [];
243
- const seenDb = new Set<string>();
244
- for (const db of databases) {
245
- const key = `${db.provider}:${db.host}:${db.configFile}`;
246
- if (!seenDb.has(key)) {
247
- seenDb.add(key);
248
- uniqueDatabases.push(db);
249
- }
250
- }
251
-
252
- const uniqueSecrets: RunConfigSecret[] = [];
253
- const seenSecret = new Set<string>();
254
- for (const s of committedSecrets) {
255
- const key = `${s.file}:${s.lineHint}`;
256
- if (!seenSecret.has(key)) {
257
- seenSecret.add(key);
258
- uniqueSecrets.push(s);
259
- }
260
- }
261
-
262
- return {
263
- entryPoints,
264
- databases: uniqueDatabases,
265
- sharedInfraWarnings: uniqueInfraWarnings,
266
- committedSecrets: uniqueSecrets,
267
- externalDependencies,
268
- };
269
- }
@@ -1,283 +0,0 @@
1
- /**
2
- * @module analyzers/tech-stack
3
- * Detects the language, framework, build tools, and project type
4
- * of a repository by inspecting manifest files.
5
- */
6
-
7
- import * as fs from 'node:fs/promises';
8
- import * as path from 'node:path';
9
- import { globby } from 'globby';
10
-
11
- import type { TechStack, Language, Framework, ProjectType } from '../types.js';
12
-
13
- /** Safely read and parse a JSON file. Returns null on failure. */
14
- async function readJson(filePath: string): Promise<Record<string, unknown> | null> {
15
- try {
16
- const raw = await fs.readFile(filePath, 'utf-8');
17
- return JSON.parse(raw) as Record<string, unknown>;
18
- } catch {
19
- return null;
20
- }
21
- }
22
-
23
- /**
24
- * Detects the tech stack of a repository by recursively inspecting its
25
- * contents for manifest files, config files, and project structures.
26
- *
27
- * @param repoPath - Absolute path to the repository root.
28
- * @returns A {@link TechStack} object describing the detected stack.
29
- */
30
- export async function detectTechStack(repoPath: string): Promise<TechStack> {
31
- const languages = new Set<Language>();
32
- const frameworks = new Set<Framework>();
33
- const buildTools = new Set<string>();
34
- const projectTypes = new Set<ProjectType>();
35
-
36
- try {
37
- const files = await globby([
38
- '**/package.json',
39
- '**/tsconfig.json',
40
- '**/*.csproj',
41
- '**/*.sln',
42
- '**/requirements.txt',
43
- '**/pyproject.toml',
44
- '**/setup.py',
45
- '**/go.mod',
46
- '**/pom.xml',
47
- '**/build.gradle',
48
- '**/build.gradle.kts',
49
- '**/Cargo.toml',
50
- '**/Gemfile',
51
- '**/composer.json',
52
- '**/Dockerfile',
53
- '**/docker-compose.yml',
54
- '**/docker-compose.yaml',
55
- '**/compose.yaml',
56
- '**/compose.yml',
57
- ], {
58
- cwd: repoPath,
59
- absolute: true,
60
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
61
- });
62
-
63
- const fileMap = new Map<string, string[]>();
64
- for (const file of files) {
65
- const name = path.basename(file);
66
- let list = fileMap.get(name);
67
- if (!list) {
68
- list = [];
69
- fileMap.set(name, list);
70
- }
71
- list.push(file);
72
- }
73
-
74
- // ── Node.js / JavaScript / TypeScript ──────────────────────────────
75
- const packageJsons = fileMap.get('package.json') || [];
76
- if (packageJsons.length > 0) {
77
- const tsconfigs = fileMap.get('tsconfig.json') || [];
78
- if (tsconfigs.length > 0) {
79
- languages.add('typescript');
80
- } else {
81
- languages.add('javascript');
82
- }
83
-
84
- for (const pj of packageJsons) {
85
- const pkg = await readJson(pj);
86
- if (pkg) {
87
- const allDeps = {
88
- ...(pkg.dependencies as Record<string, string> | undefined),
89
- ...(pkg.devDependencies as Record<string, string> | undefined),
90
- };
91
-
92
- // Frameworks
93
- if (allDeps['next']) { frameworks.add('nextjs'); projectTypes.add('fullstack'); }
94
- if (allDeps['react'] && !allDeps['next']) { frameworks.add('react'); projectTypes.add('frontend'); }
95
- if (allDeps['@angular/core']) { frameworks.add('angular'); projectTypes.add('frontend'); }
96
- if (allDeps['vue']) { frameworks.add('vue'); projectTypes.add('frontend'); }
97
- if (allDeps['svelte']) { frameworks.add('svelte'); projectTypes.add('frontend'); }
98
- if (allDeps['express']) { frameworks.add('express'); projectTypes.add('backend'); }
99
- if (allDeps['@nestjs/core']) { frameworks.add('nestjs'); projectTypes.add('backend'); }
100
- if (allDeps['fastify']) { frameworks.add('fastify'); projectTypes.add('backend'); }
101
- if (allDeps['hono']) { frameworks.add('hono'); projectTypes.add('backend'); }
102
-
103
- // Build tools
104
- if (allDeps['vite'] || allDeps['@vitejs/plugin-react']) buildTools.add('vite');
105
- if (allDeps['webpack']) buildTools.add('webpack');
106
- if (allDeps['esbuild']) buildTools.add('esbuild');
107
- if (allDeps['rollup']) buildTools.add('rollup');
108
- if (allDeps['turbo']) buildTools.add('turborepo');
109
- if (allDeps['nx']) buildTools.add('nx');
110
-
111
- // Project type heuristics
112
- if (pkg.bin) projectTypes.add('cli');
113
- if (pkg.main && !pkg.bin && frameworks.size === 0) projectTypes.add('library');
114
- }
115
- }
116
- }
117
-
118
- // ── .NET / C# ─────────────────────────────────────────────────────
119
- const csprojFiles = files.filter((f) => f.endsWith('.csproj'));
120
- const slnFiles = files.filter((f) => f.endsWith('.sln'));
121
- if (csprojFiles.length > 0 || slnFiles.length > 0) {
122
- languages.add('csharp');
123
- buildTools.add('dotnet');
124
-
125
- for (const csproj of csprojFiles) {
126
- try {
127
- const content = await fs.readFile(csproj, 'utf-8');
128
- if (content.includes('Microsoft.NET.Sdk.Web')) {
129
- frameworks.add('aspnet');
130
- projectTypes.add('backend');
131
- }
132
- if (content.includes('Microsoft.NET.Sdk.BlazorWebAssembly') || content.includes('Blazor')) {
133
- frameworks.add('blazor');
134
- projectTypes.add('frontend');
135
- }
136
- } catch {}
137
- }
138
- }
139
-
140
- // ── Python ────────────────────────────────────────────────────────
141
- const pyprojectTomls = fileMap.get('pyproject.toml') || [];
142
- const requirementsTxts = fileMap.get('requirements.txt') || [];
143
- const setupPys = fileMap.get('setup.py') || [];
144
-
145
- if (pyprojectTomls.length > 0 || requirementsTxts.length > 0 || setupPys.length > 0) {
146
- languages.add('python');
147
-
148
- for (const reqFile of [...requirementsTxts, ...pyprojectTomls]) {
149
- try {
150
- const content = await fs.readFile(reqFile, 'utf-8');
151
- const lower = content.toLowerCase();
152
- if (lower.includes('django')) { frameworks.add('django'); projectTypes.add('backend'); }
153
- if (lower.includes('flask')) { frameworks.add('flask'); projectTypes.add('backend'); }
154
- if (lower.includes('fastapi')) { frameworks.add('fastapi'); projectTypes.add('backend'); }
155
- } catch {}
156
- }
157
-
158
- if (pyprojectTomls.length > 0) buildTools.add('pyproject');
159
- if (setupPys.length > 0) buildTools.add('setuptools');
160
- }
161
-
162
- // ── Go ────────────────────────────────────────────────────────────
163
- const goMods = fileMap.get('go.mod') || [];
164
- if (goMods.length > 0) {
165
- languages.add('go');
166
- buildTools.add('go');
167
-
168
- for (const goMod of goMods) {
169
- try {
170
- const content = await fs.readFile(goMod, 'utf-8');
171
- if (content.includes('github.com/gin-gonic/gin')) {
172
- frameworks.add('gin');
173
- projectTypes.add('backend');
174
- }
175
- } catch {}
176
- }
177
- }
178
-
179
- // ── Java ──────────────────────────────────────────────────────────
180
- const poms = fileMap.get('pom.xml') || [];
181
- const gradles = fileMap.get('build.gradle') || [];
182
- const gradleKts = fileMap.get('build.gradle.kts') || [];
183
-
184
- if (poms.length > 0 || gradles.length > 0 || gradleKts.length > 0) {
185
- languages.add('java');
186
- if (poms.length > 0) buildTools.add('maven');
187
- if (gradles.length > 0 || gradleKts.length > 0) buildTools.add('gradle');
188
-
189
- for (const f of [...poms, ...gradles, ...gradleKts]) {
190
- try {
191
- const content = await fs.readFile(f, 'utf-8');
192
- if (content.includes('spring')) {
193
- frameworks.add('spring');
194
- projectTypes.add('backend');
195
- }
196
- } catch {}
197
- }
198
- }
199
-
200
- // ── Rust ──────────────────────────────────────────────────────────
201
- const cargoTomls = fileMap.get('Cargo.toml') || [];
202
- if (cargoTomls.length > 0) {
203
- languages.add('rust');
204
- buildTools.add('cargo');
205
- }
206
-
207
- // ── Ruby ──────────────────────────────────────────────────────────
208
- const gemfiles = fileMap.get('Gemfile') || [];
209
- if (gemfiles.length > 0) {
210
- languages.add('ruby');
211
- buildTools.add('bundler');
212
-
213
- for (const gemfile of gemfiles) {
214
- try {
215
- const content = await fs.readFile(gemfile, 'utf-8');
216
- if (content.includes('rails')) {
217
- frameworks.add('rails');
218
- projectTypes.add('backend');
219
- }
220
- } catch {}
221
- }
222
- }
223
-
224
- // ── PHP ───────────────────────────────────────────────────────────
225
- const composerJsons = fileMap.get('composer.json') || [];
226
- if (composerJsons.length > 0) {
227
- languages.add('php');
228
- buildTools.add('composer');
229
-
230
- for (const comp of composerJsons) {
231
- const composer = await readJson(comp);
232
- if (composer) {
233
- const req = composer.require as Record<string, string> | undefined;
234
- if (req?.['laravel/framework']) {
235
- frameworks.add('laravel');
236
- projectTypes.add('backend');
237
- }
238
- }
239
- }
240
- }
241
-
242
- // ── Docker ────────────────────────────────────────────────────────
243
- const dockerfiles = fileMap.get('Dockerfile') || [];
244
- if (dockerfiles.length > 0) {
245
- buildTools.add('docker');
246
- }
247
- const hasCompose = ['docker-compose.yml', 'docker-compose.yaml', 'compose.yaml', 'compose.yml'].some(
248
- (name) => (fileMap.get(name) || []).length > 0
249
- );
250
- if (hasCompose) {
251
- buildTools.add('docker-compose');
252
- }
253
-
254
- } catch {
255
- // Ignore errors during glob/analysis
256
- }
257
-
258
- // Fallback language
259
- if (languages.size === 0) {
260
- languages.add('other');
261
- }
262
-
263
- // Heuristic for overall projectType
264
- let finalProjectType: ProjectType = 'other';
265
- if (projectTypes.has('fullstack') || (projectTypes.has('frontend') && projectTypes.has('backend'))) {
266
- finalProjectType = 'fullstack';
267
- } else if (projectTypes.has('frontend')) {
268
- finalProjectType = 'frontend';
269
- } else if (projectTypes.has('backend')) {
270
- finalProjectType = 'backend';
271
- } else if (projectTypes.has('library')) {
272
- finalProjectType = 'library';
273
- } else if (projectTypes.has('cli')) {
274
- finalProjectType = 'cli';
275
- }
276
-
277
- return {
278
- languages: Array.from(languages),
279
- frameworks: Array.from(frameworks),
280
- buildTools: Array.from(buildTools),
281
- projectType: finalProjectType,
282
- };
283
- }