@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,290 +0,0 @@
1
- /**
2
- * @module analyzers/detect-apis
3
- * Detects API endpoints in a repository by scanning for OpenAPI/Swagger files,
4
- * route patterns in common frameworks, and gRPC proto 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 { ApiEndpoint } from '../types.js';
12
-
13
- /**
14
- * Detects API endpoints in a repository.
15
- *
16
- * Strategies (in order):
17
- * 1. Look for OpenAPI/Swagger spec files (JSON/YAML)
18
- * 2. Scan source files for Express/Fastify/ASP.NET route patterns
19
- * 3. Look for gRPC .proto files
20
- *
21
- * @param repoPath - Absolute path to the repository root.
22
- * @returns Array of detected {@link ApiEndpoint} objects.
23
- */
24
- export async function detectApis(repoPath: string): Promise<ApiEndpoint[]> {
25
- const endpoints: ApiEndpoint[] = [];
26
-
27
- // 1. OpenAPI/Swagger files
28
- const openApiEndpoints = await scanOpenApiFiles(repoPath);
29
- endpoints.push(...openApiEndpoints);
30
-
31
- // 2. Route patterns in source files (only if no OpenAPI found)
32
- if (endpoints.length === 0) {
33
- const routeEndpoints = await scanRoutePatterns(repoPath);
34
- endpoints.push(...routeEndpoints);
35
- }
36
-
37
- return endpoints;
38
- }
39
-
40
- /** Looks for OpenAPI/Swagger spec files and extracts paths. */
41
- async function scanOpenApiFiles(repoPath: string): Promise<ApiEndpoint[]> {
42
- const candidates = [
43
- 'swagger.json', 'swagger.yaml', 'swagger.yml',
44
- 'openapi.json', 'openapi.yaml', 'openapi.yml',
45
- 'api-spec.json', 'api-spec.yaml', 'api-spec.yml',
46
- ];
47
-
48
- const endpoints: ApiEndpoint[] = [];
49
-
50
- for (const filename of candidates) {
51
- const filePath = path.join(repoPath, filename);
52
- try {
53
- const content = await fs.readFile(filePath, 'utf-8');
54
-
55
- if (filename.endsWith('.json')) {
56
- const spec = JSON.parse(content) as Record<string, unknown>;
57
- const paths = spec.paths as Record<string, Record<string, unknown>> | undefined;
58
-
59
- if (paths) {
60
- for (const [routePath, methods] of Object.entries(paths)) {
61
- for (const method of Object.keys(methods)) {
62
- if (['get', 'post', 'put', 'patch', 'delete', 'head', 'options'].includes(method)) {
63
- endpoints.push({
64
- method: method.toUpperCase(),
65
- path: routePath,
66
- source: filename,
67
- });
68
- }
69
- }
70
- }
71
- }
72
- }
73
- } catch {
74
- // File doesn't exist or can't be parsed — skip
75
- }
76
- }
77
-
78
- return endpoints;
79
- }
80
-
81
- /** Scans C# files for controllers and Minimal APIs. */
82
- function extractCsEndpoints(content: string, relPath: string): ApiEndpoint[] {
83
- const endpoints: ApiEndpoint[] = [];
84
-
85
- // 1. Controller style routing
86
- const classRegex = /class\s+(\w+Controller)/gi;
87
- const classes: { name: string; index: number }[] = [];
88
- let classMatch: RegExpExecArray | null;
89
- while ((classMatch = classRegex.exec(content)) !== null) {
90
- classes.push({
91
- name: classMatch[1],
92
- index: classMatch.index,
93
- });
94
- }
95
-
96
- const routeAttrRegex = /\[Route\s*\(\s*"([^"]*)"\s*\)\]/gi;
97
- const classRoutes: { route: string; index: number }[] = [];
98
- let routeMatch: RegExpExecArray | null;
99
- while ((routeMatch = routeAttrRegex.exec(content)) !== null) {
100
- classRoutes.push({
101
- route: routeMatch[1],
102
- index: routeMatch.index,
103
- });
104
- }
105
-
106
- const versionAttrRegex = /\[ApiVersion\s*\(\s*["']?([^"'\s\)]+)["']?\s*\)\]/gi;
107
- const apiVersions: { version: string; index: number }[] = [];
108
- let versionMatch: RegExpExecArray | null;
109
- while ((versionMatch = versionAttrRegex.exec(content)) !== null) {
110
- apiVersions.push({
111
- version: versionMatch[1],
112
- index: versionMatch.index,
113
- });
114
- }
115
-
116
- const controllerRoutes: {
117
- route: string;
118
- controllerName: string;
119
- version?: string;
120
- classIndex: number;
121
- }[] = [];
122
-
123
- for (const cr of classRoutes) {
124
- const targetClass = classes.find(c => c.index > cr.index);
125
- if (targetClass) {
126
- const targetVersion = apiVersions.find(v => v.index > cr.index - 100 && v.index < targetClass.index);
127
- controllerRoutes.push({
128
- route: cr.route,
129
- controllerName: targetClass.name,
130
- version: targetVersion?.version,
131
- classIndex: targetClass.index,
132
- });
133
- }
134
- }
135
-
136
- const httpAttrRegex = /\[Http(Get|Post|Put|Patch|Delete)(?:\s*\(\s*"([^"]*)"\s*\))?\]/gi;
137
- let httpMatch: RegExpExecArray | null;
138
- while ((httpMatch = httpAttrRegex.exec(content)) !== null) {
139
- const method = httpMatch[1].toUpperCase();
140
- const actionRoute = httpMatch[2] || '';
141
- const index = httpMatch.index;
142
-
143
- let matchedController = controllerRoutes[0];
144
- for (const cr of controllerRoutes) {
145
- if (cr.classIndex < index) {
146
- matchedController = cr;
147
- } else {
148
- break;
149
- }
150
- }
151
-
152
- let resolvedRoute = '';
153
- if (matchedController) {
154
- let baseRoute = matchedController.route;
155
- const controllerBaseName = matchedController.controllerName.replace(/Controller$/i, '');
156
- baseRoute = baseRoute.replace(/\[controller\]/gi, controllerBaseName);
157
-
158
- const ver = matchedController.version;
159
- const verReplacement = ver ? 'v' + ver.split('.')[0] : 'v1';
160
- baseRoute = baseRoute.replace(/\{version(:apiVersion)?\}/gi, verReplacement);
161
-
162
- if (actionRoute) {
163
- resolvedRoute = baseRoute.endsWith('/') || actionRoute.startsWith('/')
164
- ? `${baseRoute}${actionRoute}`
165
- : `${baseRoute}/${actionRoute}`;
166
- } else {
167
- resolvedRoute = baseRoute;
168
- }
169
- } else {
170
- resolvedRoute = actionRoute;
171
- }
172
-
173
- resolvedRoute = resolvedRoute
174
- .replace(/\/+/g, '/')
175
- .replace(/:[a-zA-Z0-9\?]+/g, '');
176
-
177
- if (resolvedRoute && !resolvedRoute.startsWith('/')) {
178
- resolvedRoute = '/' + resolvedRoute;
179
- }
180
-
181
- if (resolvedRoute) {
182
- endpoints.push({
183
- method,
184
- path: resolvedRoute,
185
- source: relPath,
186
- });
187
- }
188
- }
189
-
190
- // 2. Minimal API style routing
191
- const groupRegex = /(?:const|var|let)?\s*(\w+)\s*=\s*(?:\w+)\.MapGroup\s*\(\s*"([^"]+)"/gi;
192
- const groups = new Map<string, string>();
193
- let groupMatch: RegExpExecArray | null;
194
- while ((groupMatch = groupRegex.exec(content)) !== null) {
195
- groups.set(groupMatch[1], groupMatch[2]);
196
- }
197
-
198
- const minimalApiRegex = /\b(\w+)?\.?Map(Get|Post|Put|Patch|Delete)\s*\(\s*"([^"]+)"/gi;
199
- let minMatch: RegExpExecArray | null;
200
- while ((minMatch = minimalApiRegex.exec(content)) !== null) {
201
- const varName = minMatch[1];
202
- const method = minMatch[2].toUpperCase();
203
- const actionRoute = minMatch[3];
204
-
205
- let fullPath = actionRoute;
206
- if (varName && groups.has(varName)) {
207
- const groupPath = groups.get(varName)!;
208
- fullPath = groupPath.endsWith('/') || actionRoute.startsWith('/')
209
- ? `${groupPath}${actionRoute}`
210
- : `${groupPath}/${actionRoute}`;
211
- }
212
-
213
- fullPath = fullPath
214
- .replace(/\/+/g, '/')
215
- .replace(/:[a-zA-Z0-9\?]+/g, '');
216
-
217
- if (fullPath && !fullPath.startsWith('/')) {
218
- fullPath = '/' + fullPath;
219
- }
220
-
221
- if (fullPath) {
222
- endpoints.push({
223
- method,
224
- path: fullPath,
225
- source: relPath,
226
- });
227
- }
228
- }
229
-
230
- return endpoints;
231
- }
232
-
233
- /** Scans source files for common route patterns recursively using globby. */
234
- async function scanRoutePatterns(repoPath: string): Promise<ApiEndpoint[]> {
235
- const endpoints: ApiEndpoint[] = [];
236
- const routeRegex = /\.(get|post|put|patch|delete)\s*\(\s*['"`]([^'"`]+)['"`]/gi;
237
-
238
- try {
239
- const files = await globby(
240
- ['**/*.ts', '**/*.js', '**/*.cs', '**/*.py'],
241
- {
242
- cwd: repoPath,
243
- absolute: true,
244
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
245
- }
246
- );
247
-
248
- for (const file of files) {
249
- try {
250
- const stat = await fs.stat(file);
251
- if (!stat.isFile() || stat.size > 100_000) continue; // Skip large files
252
-
253
- const content = await fs.readFile(file, 'utf-8');
254
- const relPath = path.relative(repoPath, file);
255
-
256
- if (file.endsWith('.cs')) {
257
- endpoints.push(...extractCsEndpoints(content, relPath));
258
- } else {
259
- // Express/Fastify/Hono/etc style routes
260
- let match: RegExpExecArray | null;
261
- routeRegex.lastIndex = 0;
262
- while ((match = routeRegex.exec(content)) !== null) {
263
- endpoints.push({
264
- method: match[1]!.toUpperCase(),
265
- path: match[2]!,
266
- source: relPath,
267
- });
268
- }
269
- }
270
- } catch {
271
- continue;
272
- }
273
- }
274
- } catch {
275
- // Ignore errors
276
- }
277
-
278
- // De-duplicate endpoints
279
- const seen = new Set<string>();
280
- const uniqueEndpoints: ApiEndpoint[] = [];
281
- for (const ep of endpoints) {
282
- const key = `${ep.method}:${ep.path}`;
283
- if (!seen.has(key)) {
284
- seen.add(key);
285
- uniqueEndpoints.push(ep);
286
- }
287
- }
288
-
289
- return uniqueEndpoints;
290
- }
@@ -1,315 +0,0 @@
1
- /**
2
- * @module analyzers/detect-deps
3
- * Detects dependencies declared in a repository by reading manifest files.
4
- * This is used to find potential inter-repo connections (e.g., one repo
5
- * consumes an npm package published by another).
6
- */
7
-
8
- import * as fs from 'node:fs/promises';
9
- import * as path from 'node:path';
10
- import { globby } from 'globby';
11
-
12
- import type { RepoDependency, ProjectAnalysis } from '../types.js';
13
-
14
- /**
15
- * Extracts declared dependencies from a repository's manifest files recursively.
16
- *
17
- * Supports:
18
- * - npm (package.json)
19
- * - NuGet (*.csproj)
20
- * - pip (requirements.txt)
21
- * - Go (go.mod)
22
- *
23
- * @param repoPath - Absolute path to the repository root.
24
- * @returns Array of detected {@link RepoDependency} objects.
25
- */
26
- export async function detectDependencies(repoPath: string): Promise<RepoDependency[]> {
27
- const deps: RepoDependency[] = [];
28
-
29
- try {
30
- const files = await globby(
31
- ['**/package.json', '**/*.csproj', '**/requirements.txt', '**/go.mod'],
32
- {
33
- cwd: repoPath,
34
- absolute: true,
35
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
36
- }
37
- );
38
-
39
- for (const file of files) {
40
- const filename = path.basename(file);
41
-
42
- // ── npm ───────────────────────────────────────────────────────────
43
- if (filename === 'package.json') {
44
- try {
45
- const raw = await fs.readFile(file, 'utf-8');
46
- const pkg = JSON.parse(raw) as Record<string, unknown>;
47
-
48
- const allDeps: Record<string, string> = {
49
- ...(pkg.dependencies as Record<string, string> | undefined),
50
- ...(pkg.devDependencies as Record<string, string> | undefined),
51
- };
52
-
53
- for (const [name, version] of Object.entries(allDeps)) {
54
- deps.push({ name, type: 'npm', version });
55
- }
56
- } catch {
57
- // Parse error or skip
58
- }
59
- }
60
-
61
- // ── NuGet (.csproj) ───────────────────────────────────────────────
62
- else if (filename.endsWith('.csproj')) {
63
- try {
64
- const content = await fs.readFile(file, 'utf-8');
65
- const packageRefRegex = /<PackageReference\s+Include="([^"]+)"\s+Version="([^"]*)"/gi;
66
- let match: RegExpExecArray | null;
67
- while ((match = packageRefRegex.exec(content)) !== null) {
68
- deps.push({ name: match[1]!, type: 'nuget', version: match[2] });
69
- }
70
- } catch {
71
- // Skip
72
- }
73
- }
74
-
75
- // ── pip (requirements.txt) ────────────────────────────────────────
76
- else if (filename === 'requirements.txt') {
77
- try {
78
- const content = await fs.readFile(file, 'utf-8');
79
- const lines = content.split('\n').filter((l) => l.trim() && !l.startsWith('#'));
80
-
81
- for (const line of lines) {
82
- const match = line.match(/^([a-zA-Z0-9_-]+)\s*([>=<~!]*\s*[\d.*]+)?/);
83
- if (match) {
84
- deps.push({
85
- name: match[1]!,
86
- type: 'pip',
87
- version: match[2]?.trim() || undefined,
88
- });
89
- }
90
- }
91
- } catch {
92
- // Skip
93
- }
94
- }
95
-
96
- // ── Go (go.mod) ──────────────────────────────────────────────────
97
- else if (filename === 'go.mod') {
98
- try {
99
- const content = await fs.readFile(file, 'utf-8');
100
- const requireRegex = /require\s*\(([\s\S]*?)\)/g;
101
- const modRegex = /^\s*([\S]+)\s+(v[\S]+)/gm;
102
-
103
- let match: RegExpExecArray | null;
104
- while ((match = requireRegex.exec(content)) !== null) {
105
- const block = match[1]!;
106
- let modMatch: RegExpExecArray | null;
107
- modRegex.lastIndex = 0;
108
- while ((modMatch = modRegex.exec(block)) !== null) {
109
- deps.push({ name: modMatch[1]!, type: 'go', version: modMatch[2] });
110
- }
111
- }
112
- } catch {
113
- // Skip
114
- }
115
- }
116
- }
117
- } catch {
118
- // Ignore errors
119
- }
120
-
121
- // De-duplicate dependencies to keep context clean
122
- const seen = new Set<string>();
123
- const uniqueDeps: RepoDependency[] = [];
124
- for (const dep of deps) {
125
- const key = `${dep.type}:${dep.name}`;
126
- if (!seen.has(key)) {
127
- seen.add(key);
128
- uniqueDeps.push(dep);
129
- }
130
- }
131
-
132
- return uniqueDeps;
133
- }
134
-
135
- /**
136
- * Scans recursively for packages produced or published by the repository.
137
- *
138
- * @param repoPath - Absolute path to the repository root.
139
- * @returns Array of produced package metadata.
140
- */
141
- export async function detectProducedPackages(
142
- repoPath: string,
143
- ): Promise<{ name: string; type: 'npm' | 'nuget' | 'other'; version?: string; contributing?: string[] }[]> {
144
- const products: { name: string; type: 'npm' | 'nuget' | 'other'; version?: string; contributing?: string[] }[] = [];
145
-
146
- try {
147
- const files = await globby(
148
- ['**/package.json', '**/*.csproj'],
149
- {
150
- cwd: repoPath,
151
- absolute: true,
152
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
153
- }
154
- );
155
-
156
- for (const file of files) {
157
- const filename = path.basename(file);
158
-
159
- if (filename === 'package.json') {
160
- try {
161
- const raw = await fs.readFile(file, 'utf-8');
162
- const pkg = JSON.parse(raw) as Record<string, unknown>;
163
- if (pkg.name && pkg.name !== 'workspace' && !pkg.private) {
164
- products.push({
165
- name: pkg.name as string,
166
- type: 'npm',
167
- version: (pkg.version as string) || undefined,
168
- });
169
- }
170
- } catch {
171
- // Skip
172
- }
173
- } else if (filename.endsWith('.csproj')) {
174
- try {
175
- const content = await fs.readFile(file, 'utf-8');
176
- const packageIdMatch = /<PackageId>([^<]+)<\/PackageId>/i.exec(content);
177
- const assemblyNameMatch = /<AssemblyName>([^<]+)<\/AssemblyName>/i.exec(content);
178
- const versionMatch = /<Version>([^<]+)<\/Version>/i.exec(content);
179
-
180
- const name =
181
- packageIdMatch?.[1]?.trim() ||
182
- assemblyNameMatch?.[1]?.trim() ||
183
- path.basename(file, '.csproj');
184
-
185
- // Extract project references to find contributing sub-projects
186
- const projRefRegex = /<ProjectReference\s+Include="([^"]+)"/gi;
187
- const contributing: string[] = [];
188
- let projMatch: RegExpExecArray | null;
189
- while ((projMatch = projRefRegex.exec(content)) !== null) {
190
- const refPath = projMatch[1];
191
- const refName = path.basename(refPath, '.csproj');
192
- contributing.push(refName);
193
- }
194
-
195
- products.push({
196
- name,
197
- type: 'nuget',
198
- version: versionMatch?.[1]?.trim() || undefined,
199
- contributing: contributing.length > 0 ? contributing : undefined,
200
- });
201
- } catch {
202
- // Skip
203
- }
204
- }
205
- }
206
- } catch {
207
- // Ignore errors
208
- }
209
-
210
- return products;
211
- }
212
-
213
- /**
214
- * Given analysis of multiple repos, find which repos depend on each other.
215
- * Returns a map of repo name → list of repo names it depends on.
216
- *
217
- * @param repoAnalyses - Map of repo path to its full analysis result.
218
- * @param repoNames - Map of repo path to its name.
219
- * @returns Map of repo name → list of repo names it depends on.
220
- */
221
- export function findInterRepoDependencies(
222
- repoAnalyses: Map<string, ProjectAnalysis>,
223
- repoNames: Map<string, string>,
224
- ): Map<string, string[]> {
225
- const connections = new Map<string, string[]>();
226
-
227
- // Map each produced package name to the repo name that produces it
228
- const packageToRepo = new Map<string, string>();
229
- for (const [repoPath, a] of repoAnalyses) {
230
- const thisName = repoNames.get(repoPath) ?? a.name;
231
- // Map the repo name itself as a produced product (for direct matching)
232
- packageToRepo.set(thisName.toLowerCase(), thisName);
233
-
234
- if (a.produces) {
235
- for (const product of a.produces) {
236
- packageToRepo.set(product.name.toLowerCase(), thisName);
237
- // Also map basename (e.g. Hogia.EmploymentService.Client -> Client)
238
- const base = product.name.split('.').pop() ?? product.name;
239
- if (base && base.length > 3) {
240
- packageToRepo.set(base.toLowerCase(), thisName);
241
- }
242
- }
243
- }
244
- }
245
-
246
- for (const [repoPath, a] of repoAnalyses) {
247
- const thisName = repoNames.get(repoPath) ?? a.name;
248
- const dependsOn: string[] = [];
249
-
250
- for (const dep of a.dependencies) {
251
- const depNameLower = dep.name.toLowerCase();
252
-
253
- // 1. Direct match with a produced package
254
- if (packageToRepo.has(depNameLower)) {
255
- const targetRepo = packageToRepo.get(depNameLower)!;
256
- if (targetRepo !== thisName && !dependsOn.includes(targetRepo)) {
257
- dependsOn.push(targetRepo);
258
- }
259
- } else {
260
- // 2. Check if the dependency contains or is contained by a produced package name
261
- for (const [prodPkg, targetRepo] of packageToRepo) {
262
- if (targetRepo === thisName) continue;
263
- if (depNameLower.includes(prodPkg) || prodPkg.includes(depNameLower)) {
264
- if (!dependsOn.includes(targetRepo)) {
265
- dependsOn.push(targetRepo);
266
- }
267
- }
268
- }
269
- }
270
- }
271
-
272
- if (dependsOn.length > 0) {
273
- connections.set(thisName, dependsOn);
274
- }
275
- }
276
-
277
- return connections;
278
- }
279
-
280
- /**
281
- * Scans for NuGet.config files recursively in the repository and extracts configured package source feeds.
282
- *
283
- * @param repoPath - Absolute path to the repository root.
284
- * @returns Array of package sources (key, value).
285
- */
286
- export async function detectNuGetFeeds(repoPath: string): Promise<{ name: string; url: string }[]> {
287
- const feeds: { name: string; url: string }[] = [];
288
- try {
289
- const configFiles = await globby('**/NuGet.config', {
290
- cwd: repoPath,
291
- absolute: true,
292
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
293
- });
294
-
295
- for (const file of configFiles) {
296
- try {
297
- const content = await fs.readFile(file, 'utf-8');
298
- // Scan for <add key="..." value="..." /> elements under <packageSources>
299
- const addRegex = /<add\s+key="([^"]+)"\s+value="([^"]+)"/gi;
300
- let match: RegExpExecArray | null;
301
- while ((match = addRegex.exec(content)) !== null) {
302
- const key = match[1];
303
- const value = match[2];
304
- // Exclude default public nuget feed to keep output focused on private feeds
305
- if (!key.toLowerCase().includes('nuget.org') && !value.toLowerCase().includes('api.nuget.org')) {
306
- feeds.push({ name: key, url: value });
307
- }
308
- }
309
- } catch {}
310
- }
311
- } catch {
312
- // Ignore errors
313
- }
314
- return feeds;
315
- }
@@ -1,74 +0,0 @@
1
- /**
2
- * @module analyzers/detect-existing
3
- * Detects existing AI assistant configuration files in a repository.
4
- * These are merged into the generated workspace context to preserve
5
- * repo-specific instructions.
6
- */
7
-
8
- import * as fs from 'node:fs/promises';
9
- import * as path from 'node:path';
10
-
11
- import type { ExistingAIConfig } from '../types.js';
12
-
13
- /** Maximum chars to include as a content preview. */
14
- const PREVIEW_LENGTH = 500;
15
-
16
- /** Known AI config file locations. */
17
- const AI_CONFIG_FILES = [
18
- { assistant: 'claude' as const, relativePath: 'CLAUDE.md' },
19
- { assistant: 'claude' as const, relativePath: 'CLAUDE.local.md' },
20
- { assistant: 'agents' as const, relativePath: 'AGENTS.md' },
21
- { assistant: 'copilot' as const, relativePath: '.github/copilot-instructions.md' },
22
- { assistant: 'cursor' as const, relativePath: '.cursorrules' },
23
- ];
24
-
25
- /**
26
- * Scans a repository for existing AI assistant configuration files.
27
- *
28
- * @param repoPath - Absolute path to the repository root.
29
- * @returns Array of detected {@link ExistingAIConfig} objects.
30
- */
31
- export async function detectExistingAIConfigs(
32
- repoPath: string,
33
- ): Promise<ExistingAIConfig[]> {
34
- const results: ExistingAIConfig[] = [];
35
-
36
- for (const config of AI_CONFIG_FILES) {
37
- const filePath = path.join(repoPath, config.relativePath);
38
-
39
- try {
40
- const content = await fs.readFile(filePath, 'utf-8');
41
- results.push({
42
- assistant: config.assistant,
43
- relativePath: config.relativePath,
44
- contentPreview: content.slice(0, PREVIEW_LENGTH),
45
- });
46
- } catch {
47
- // File doesn't exist — skip
48
- }
49
- }
50
-
51
- // Also check for Cursor rules directory
52
- const cursorRulesDir = path.join(repoPath, '.cursor', 'rules');
53
- try {
54
- const entries = await fs.readdir(cursorRulesDir);
55
- const mdcFiles = entries.filter((e) => e.endsWith('.mdc'));
56
-
57
- for (const mdc of mdcFiles) {
58
- try {
59
- const content = await fs.readFile(path.join(cursorRulesDir, mdc), 'utf-8');
60
- results.push({
61
- assistant: 'cursor',
62
- relativePath: `.cursor/rules/${mdc}`,
63
- contentPreview: content.slice(0, PREVIEW_LENGTH),
64
- });
65
- } catch {
66
- // Skip unreadable files
67
- }
68
- }
69
- } catch {
70
- // No .cursor/rules directory
71
- }
72
-
73
- return results;
74
- }