@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.
- package/README.md +27 -3
- package/dist/analyzers/index.d.ts +23 -0
- package/dist/analyzers/index.d.ts.map +1 -1
- package/dist/analyzers/index.js +62 -0
- package/dist/analyzers/index.js.map +1 -1
- package/dist/commands/commands.test.js +20 -6
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/commit.d.ts.map +1 -1
- package/dist/commands/commit.js +27 -5
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/diff.d.ts +9 -2
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +36 -12
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/handoff.js +2 -2
- package/dist/commands/handoff.js.map +1 -1
- package/dist/commands/refresh.d.ts +4 -2
- package/dist/commands/refresh.d.ts.map +1 -1
- package/dist/commands/refresh.js +20 -36
- package/dist/commands/refresh.js.map +1 -1
- package/dist/commands/schedule.d.ts +35 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +151 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +58 -50
- package/dist/commands/sync.js.map +1 -1
- package/dist/core/analysis-cache.d.ts +58 -0
- package/dist/core/analysis-cache.d.ts.map +1 -0
- package/dist/core/analysis-cache.js +116 -0
- package/dist/core/analysis-cache.js.map +1 -0
- package/dist/core/analysis-cache.test.d.ts +2 -0
- package/dist/core/analysis-cache.test.d.ts.map +1 -0
- package/dist/core/analysis-cache.test.js +108 -0
- package/dist/core/analysis-cache.test.js.map +1 -0
- package/dist/core/refresh.d.ts +41 -0
- package/dist/core/refresh.d.ts.map +1 -0
- package/dist/core/refresh.js +60 -0
- package/dist/core/refresh.js.map +1 -0
- package/dist/core/scheduler.d.ts +117 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +247 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/scheduler.test.d.ts +2 -0
- package/dist/core/scheduler.test.d.ts.map +1 -0
- package/dist/core/scheduler.test.js +111 -0
- package/dist/core/scheduler.test.js.map +1 -0
- package/dist/core/sync.d.ts +50 -0
- package/dist/core/sync.d.ts.map +1 -0
- package/dist/core/sync.js +92 -0
- package/dist/core/sync.js.map +1 -0
- package/dist/core/workspace-state.d.ts +51 -0
- package/dist/core/workspace-state.d.ts.map +1 -0
- package/dist/core/workspace-state.js +108 -0
- package/dist/core/workspace-state.js.map +1 -0
- package/dist/core/workspace-state.test.d.ts +2 -0
- package/dist/core/workspace-state.test.d.ts.map +1 -0
- package/dist/core/workspace-state.test.js +84 -0
- package/dist/core/workspace-state.test.js.map +1 -0
- package/dist/generators/index.d.ts +7 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +14 -1
- package/dist/generators/index.js.map +1 -1
- package/dist/gui/assets/index-Bdbld6yY.css +1 -0
- package/dist/gui/assets/index-D8iJPvnk.js +26 -0
- package/dist/gui/index.html +2 -2
- package/dist/index.js +107 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +42 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +175 -13
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +66 -0
- package/dist/server.test.js.map +1 -1
- package/dist/types.d.ts +31 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/multi-git.d.ts +54 -8
- package/dist/utils/multi-git.d.ts.map +1 -1
- package/dist/utils/multi-git.js +129 -21
- package/dist/utils/multi-git.js.map +1 -1
- package/dist/utils/multi-git.test.d.ts +2 -0
- package/dist/utils/multi-git.test.d.ts.map +1 -0
- package/dist/utils/multi-git.test.js +125 -0
- package/dist/utils/multi-git.test.js.map +1 -0
- package/package.json +13 -1
- package/.agents/skills/ccc/SKILL.md +0 -71
- package/.agents/skills/ccc/references/management.md +0 -110
- package/.agents/skills/ccc/references/settings.md +0 -126
- package/.github/dependabot.yml +0 -52
- package/.github/workflows/ci.yml +0 -44
- package/.github/workflows/dependabot-merge.yml +0 -53
- package/.github/workflows/release-desktop.yml +0 -67
- package/.github/workflows/release-npm.yml +0 -65
- package/.github/workflows/release-vscode.yml +0 -61
- package/.vscode/launch.json +0 -17
- package/.vscode/tasks.json +0 -17
- package/GETTING_STARTED.md +0 -114
- package/desktop/build-installer.js +0 -228
- package/desktop/build.js +0 -118
- package/desktop/installer/nexusflow.iss +0 -35
- package/desktop/neutralino.config.json +0 -39
- package/desktop/package-lock.json +0 -1060
- package/desktop/package.json +0 -14
- package/dist/gui/assets/index-CB-jWded.css +0 -1
- package/dist/gui/assets/index-DDXpZZu3.js +0 -25
- package/extension/media/icon.svg +0 -1
- package/extension/package-lock.json +0 -6044
- package/extension/package.json +0 -117
- package/extension/src/extension.ts +0 -653
- package/extension/tsconfig.json +0 -21
- package/gui/README.md +0 -73
- package/gui/e2e/wizard.spec.ts +0 -346
- package/gui/eslint.config.js +0 -26
- package/gui/index.html +0 -17
- package/gui/package-lock.json +0 -3079
- package/gui/package.json +0 -36
- package/gui/playwright.config.ts +0 -41
- package/gui/public/app_logo.png +0 -0
- package/gui/public/favicon.svg +0 -1
- package/gui/public/icons.svg +0 -24
- package/gui/src/App.css +0 -1
- package/gui/src/App.tsx +0 -3632
- package/gui/src/assets/hero.png +0 -0
- package/gui/src/assets/react.svg +0 -1
- package/gui/src/assets/vite.svg +0 -1
- package/gui/src/features/changes/ChangesViewer.tsx +0 -388
- package/gui/src/features/knowledge/KnowledgeBase.tsx +0 -84
- package/gui/src/features/onboarding/OnboardingWizard.tsx +0 -230
- package/gui/src/features/plan/ImplementationPlan.tsx +0 -32
- package/gui/src/features/services/ServiceConsole.tsx +0 -250
- package/gui/src/features/sessions/SessionHistory.tsx +0 -195
- package/gui/src/features/workspace/WorkspaceList.tsx +0 -666
- package/gui/src/index.css +0 -152
- package/gui/src/main.tsx +0 -94
- package/gui/src/types.ts +0 -62
- package/gui/tsconfig.app.json +0 -25
- package/gui/tsconfig.json +0 -7
- package/gui/tsconfig.node.json +0 -24
- package/gui/vite.config.ts +0 -12
- package/resources/workflows/plan-implement-review.md +0 -8
- package/resources/workflows/research-verify.md +0 -6
- package/resources/workflows/solo-developer.md +0 -3
- package/scripts/simulate-workspaces.ts +0 -55
- package/skills-lock.json +0 -11
- package/src/analyzers/detect-apis.ts +0 -290
- package/src/analyzers/detect-deps.ts +0 -315
- package/src/analyzers/detect-existing.ts +0 -74
- package/src/analyzers/detect-ports.ts +0 -110
- package/src/analyzers/index.ts +0 -97
- package/src/analyzers/messaging-analyzer.ts +0 -254
- package/src/analyzers/readme-summarizer.ts +0 -102
- package/src/analyzers/run-analyzer.ts +0 -269
- package/src/analyzers/tech-stack.ts +0 -283
- package/src/commands/adapter.ts +0 -348
- package/src/commands/add-repo.ts +0 -156
- package/src/commands/commands.test.ts +0 -156
- package/src/commands/commit.ts +0 -131
- package/src/commands/config.ts +0 -52
- package/src/commands/create.ts +0 -204
- package/src/commands/desktop.ts +0 -128
- package/src/commands/diff.ts +0 -125
- package/src/commands/doctor.ts +0 -370
- package/src/commands/handoff.ts +0 -266
- package/src/commands/init.ts +0 -134
- package/src/commands/list.ts +0 -46
- package/src/commands/logs.ts +0 -63
- package/src/commands/mcp.ts +0 -94
- package/src/commands/open.ts +0 -129
- package/src/commands/refresh.ts +0 -137
- package/src/commands/remove.ts +0 -98
- package/src/commands/start.ts +0 -117
- package/src/commands/status.ts +0 -54
- package/src/commands/stop.ts +0 -55
- package/src/commands/sync.ts +0 -147
- package/src/commands/tui.ts +0 -484
- package/src/commands/ui.ts +0 -111
- package/src/core/adapters/local-storage.ts +0 -66
- package/src/core/adapters/obsidian-storage.ts +0 -151
- package/src/core/adapters/registry.ts +0 -44
- package/src/core/adapters/storage.test.ts +0 -174
- package/src/core/adapters/vault-storage.ts +0 -86
- package/src/core/config.test.ts +0 -96
- package/src/core/config.ts +0 -140
- package/src/core/graph.ts +0 -344
- package/src/core/plugins/index.ts +0 -17
- package/src/core/plugins/loader.ts +0 -36
- package/src/core/ports/storage.ts +0 -71
- package/src/core/scanner.test.ts +0 -61
- package/src/core/scanner.ts +0 -91
- package/src/core/storage.ts +0 -37
- package/src/core/workspace.ts +0 -487
- package/src/core/worktree.ts +0 -120
- package/src/generators/antigravity.ts +0 -32
- package/src/generators/base.ts +0 -243
- package/src/generators/claude.ts +0 -34
- package/src/generators/codex.ts +0 -48
- package/src/generators/copilot.ts +0 -56
- package/src/generators/cursor.ts +0 -44
- package/src/generators/diff-context.ts +0 -75
- package/src/generators/index.ts +0 -322
- package/src/generators/map-generator.test.ts +0 -159
- package/src/generators/map-generator.ts +0 -539
- package/src/generators/plan-generator.ts +0 -483
- package/src/generators/skills-generator.ts +0 -259
- package/src/index.ts +0 -539
- package/src/mcp/server.ts +0 -294
- package/src/orchestration/detect.ts +0 -313
- package/src/orchestration/index.ts +0 -7
- package/src/orchestration/runner.ts +0 -283
- package/src/server.test.ts +0 -618
- package/src/server.ts +0 -1314
- package/src/types.ts +0 -415
- package/src/utils/detect-ai.test.ts +0 -44
- package/src/utils/detect-ai.ts +0 -84
- package/src/utils/detect-editors.test.ts +0 -48
- package/src/utils/detect-editors.ts +0 -57
- package/src/utils/git.test.ts +0 -74
- package/src/utils/git.ts +0 -117
- package/src/utils/local-ai.test.ts +0 -130
- package/src/utils/local-ai.ts +0 -116
- package/src/utils/multi-git.ts +0 -313
- package/src/utils/prompts.ts +0 -209
- package/src/utils/session-finder.ts +0 -483
- package/src/utils/system-scanner.test.ts +0 -89
- package/src/utils/system-scanner.ts +0 -96
- package/src/utils/update-check.ts +0 -286
- package/src/utils/workflow-advisor.ts +0 -118
- package/src/utils/workflows.test.ts +0 -114
- package/src/utils/workflows.ts +0 -178
- package/tsconfig.json +0 -19
- 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
|
-
}
|