@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,539 +0,0 @@
1
- /**
2
- * @module generators/map-generator
3
- * Generates a nexusflow-map-<repo>.md file for each repository in the workspace.
4
- * Provides a localized, token-efficient architectural map for AI assistants.
5
- */
6
-
7
- import * as fs from 'node:fs/promises';
8
- import * as path from 'node:path';
9
- import { globby } from 'globby';
10
- import { writeWorkspaceFile, readWorkspaceFile, workspaceFileExists, writeBaseFile, readBaseFile, baseFileExists } from '../core/storage.js';
11
- import type { ProjectAnalysis, RepoInfo } from '../types.js';
12
-
13
- interface PatternRule {
14
- name: string;
15
- label: string;
16
- regex: RegExp;
17
- description: string;
18
- }
19
-
20
- const LANG_PATTERNS: Record<string, PatternRule[]> = {
21
- csharp: [
22
- {
23
- name: 'FluentValidation',
24
- label: 'FluentValidation Validator subclasses',
25
- regex: /:\s*AbstractValidator\s*</g,
26
- description: 'Used for domain/command validation rules.'
27
- },
28
- {
29
- name: 'MediatR Handlers',
30
- label: 'MediatR Request Handlers',
31
- regex: /:\s*IRequestHandler\s*</g,
32
- description: 'Used for CQRS command/query handler pattern.'
33
- },
34
- {
35
- name: 'MediatR Requests',
36
- label: 'MediatR Requests/Commands',
37
- regex: /:\s*IRequest\b(?!Handler)/g,
38
- description: 'Used for MediatR command/query dispatching.'
39
- },
40
- {
41
- name: 'AutoMapper Profiles',
42
- label: 'AutoMapper Mapping Profiles',
43
- regex: /:\s*Profile\b/g,
44
- description: 'Used for object-to-object mappings.'
45
- },
46
- {
47
- name: 'DataAnnotations',
48
- label: 'DataAnnotations Validation Attributes',
49
- regex: /using\s+System\.ComponentModel\.DataAnnotations;/g,
50
- description: 'Used for property-level attribute validation.'
51
- }
52
- ],
53
- typescript: [
54
- {
55
- name: 'Zod Schemas',
56
- label: 'Zod Object Schemas',
57
- regex: /z\.object\s*\(/g,
58
- description: 'Used for schema parsing/validation.'
59
- },
60
- {
61
- name: 'NestJS Controllers',
62
- label: 'NestJS Routing Controllers',
63
- regex: /@Controller\s*\(/g,
64
- description: 'Used for controller routing endpoints.'
65
- },
66
- {
67
- name: 'NestJS Injectables',
68
- label: 'NestJS Injectable Services',
69
- regex: /@Injectable\s*\(\)/g,
70
- description: 'Used for dependency injection services.'
71
- },
72
- {
73
- name: 'React Components',
74
- label: 'React Functional Components',
75
- regex: /React\.FC/g,
76
- description: 'Used for component UI views.'
77
- }
78
- ],
79
- javascript: [
80
- {
81
- name: 'Zod Schemas',
82
- label: 'Zod Object Schemas',
83
- regex: /z\.object\s*\(/g,
84
- description: 'Used for schema parsing/validation.'
85
- }
86
- ],
87
- python: [
88
- {
89
- name: 'Pydantic Models',
90
- label: 'Pydantic BaseModel subclasses',
91
- regex: /class\s+\w+\s*\(\s*BaseModel\s*\)/g,
92
- description: 'Used for data schemas and validation.'
93
- },
94
- {
95
- name: 'FastAPI Routers',
96
- label: 'FastAPI APIRouter instances',
97
- regex: /=([\s\S]*?)APIRouter\s*\(/g,
98
- description: 'Used for endpoint routing.'
99
- }
100
- ],
101
- go: [
102
- {
103
- name: 'Go JSON tags',
104
- label: 'Go JSON struct tags',
105
- regex: /`json:"[^"]+"`/g,
106
- description: 'Used for struct serialization/deserialization.'
107
- }
108
- ]
109
- };
110
-
111
- /**
112
- * Generates a `nexusflow-map-<repo>.md` file in the workspace root.
113
- *
114
- * @param repo - The repository metadata.
115
- * @param analysis - The repository analysis result.
116
- * @param workspacePath - Absolute path to the workspace root directory.
117
- */
118
- export async function generateRepoMap(
119
- repo: RepoInfo,
120
- analysis: ProjectAnalysis,
121
- workspacePath: string,
122
- allProducedPackages: Set<string> = new Set(),
123
- ): Promise<void> {
124
- const repoName = repo.name;
125
- const worktreePath = path.join(workspacePath, repoName);
126
-
127
- const md: string[] = [];
128
-
129
- md.push(`# Repository Architecture Map — ${repoName}`);
130
- md.push('');
131
- md.push(`> **Repository Path**: \`${worktreePath}\``);
132
- md.push(`> **Generated At**: ${new Date().toISOString()} (UTC)`);
133
- md.push(`> **Regeneration Command**: Run \`nexusflow refresh\` to update this map.`);
134
- md.push(`> **Note**: Maps are advisory snapshots of the codebase. Always verify route parameters, patterns, and filenames before relying on them.`);
135
- md.push('');
136
-
137
-
138
- // 1. Solution/Project Layout
139
- md.push('## 🏗️ Project Layout');
140
- md.push('');
141
-
142
- try {
143
- const slnFiles = await globby('**/*.sln', {
144
- cwd: worktreePath,
145
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
146
- });
147
-
148
- const csprojFiles = await globby('**/*.csproj', {
149
- cwd: worktreePath,
150
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
151
- });
152
-
153
- const packageJsons = await globby('**/package.json', {
154
- cwd: worktreePath,
155
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
156
- });
157
-
158
- if (slnFiles.length > 0) {
159
- md.push('### .NET Solutions');
160
- for (const sln of slnFiles) {
161
- md.push(`- **Solution**: \`${sln}\``);
162
- }
163
- md.push('');
164
- }
165
-
166
- if (csprojFiles.length > 0) {
167
- md.push('### .NET Projects');
168
- for (const csproj of csprojFiles) {
169
- const isTest = csproj.toLowerCase().includes('test') || csproj.toLowerCase().includes('spec');
170
- const role = isTest ? 'Test Suite' : 'App/Library';
171
- md.push(`- \`${csproj}\` (${role})`);
172
- }
173
- md.push('');
174
- }
175
-
176
- if (packageJsons.length > 0) {
177
- md.push('### npm Packages & Modules');
178
- for (const pj of packageJsons) {
179
- md.push(`- \`${pj}\``);
180
- }
181
- md.push('');
182
- }
183
- } catch {
184
- md.push('_No project layout files discovered or error occurred._');
185
- md.push('');
186
- }
187
-
188
- // 1.5. Messaging Topology
189
- md.push('## 📨 Messaging Topology');
190
- md.push('');
191
- if (analysis.messaging && (analysis.messaging.publishers.length > 0 || analysis.messaging.subscribers.length > 0)) {
192
- if (analysis.messaging.publishers.length > 0) {
193
- md.push('### Publishes');
194
- md.push('| Message Contract | Topic/Queue/Channel | Publisher (file) |');
195
- md.push('|---|---|---|');
196
- for (const p of analysis.messaging.publishers) {
197
- const fileLink = p.publisherFile
198
- ? `[${path.basename(p.publisherFile)}](file:///${path.join(worktreePath, p.publisherFile)})`
199
- : '—';
200
- md.push(`| ${p.contractType} | ${p.topicOrQueue} | ${fileLink} |`);
201
- }
202
- md.push('');
203
- }
204
-
205
- if (analysis.messaging.subscribers.length > 0) {
206
- md.push('### Subscribes');
207
- md.push('| Message Contract | Handler (file) | Registered in |');
208
- md.push('|---|---|---|');
209
- for (const s of analysis.messaging.subscribers) {
210
- const handlerLink = s.handlerFile
211
- ? `[${path.basename(s.handlerFile)}](file:///${path.join(worktreePath, s.handlerFile)})`
212
- : '—';
213
- const regLink = s.registrationFile
214
- ? `[${path.basename(s.registrationFile)}](file:///${path.join(worktreePath, s.registrationFile)})`
215
- : '—';
216
- md.push(`| ${s.contractType} | ${handlerLink} | ${regLink} |`);
217
- }
218
- md.push('');
219
- }
220
- } else {
221
- md.push('_No pub/sub messaging patterns detected in this repository._');
222
- md.push('');
223
- }
224
-
225
- // 2. Extensible Usage Pattern Scanning
226
- md.push('## 💡 Detected Architectural Patterns & Usages');
227
- md.push('');
228
-
229
- const detectedLanguages = analysis.techStack.languages;
230
- const patternExamples = new Map<string, { label: string; firstFile?: string; description: string }>();
231
-
232
- // Initialize examples
233
- for (const lang of detectedLanguages) {
234
- const rules = LANG_PATTERNS[lang] || [];
235
- for (const rule of rules) {
236
- patternExamples.set(rule.name, { label: rule.label, description: rule.description });
237
- }
238
- }
239
-
240
- // Scan files for pattern usage
241
- try {
242
- const extensions = detectedLanguages.map(l => {
243
- if (l === 'csharp') return 'cs';
244
- if (l === 'typescript') return 'ts';
245
- if (l === 'javascript') return 'js';
246
- if (l === 'python') return 'py';
247
- if (l === 'go') return 'go';
248
- return '';
249
- }).filter(ext => ext !== '');
250
-
251
- if (extensions.length > 0) {
252
- const globPattern = extensions.length === 1 ? `**/*.${extensions[0]}` : `**/*.{${extensions.join(',')}}`;
253
- const srcFiles = await globby(globPattern, {
254
- cwd: worktreePath,
255
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
256
- });
257
-
258
- for (const file of srcFiles) {
259
- const fullPath = path.join(worktreePath, file);
260
- const content = await fs.readFile(fullPath, 'utf-8');
261
-
262
- for (const lang of detectedLanguages) {
263
- const rules = LANG_PATTERNS[lang] || [];
264
- for (const rule of rules) {
265
- const val = patternExamples.get(rule.name)!;
266
- if (val.firstFile) continue; // Already found an example
267
-
268
- rule.regex.lastIndex = 0;
269
- if (rule.regex.test(content)) {
270
- val.firstFile = file.replace(/\\/g, '/');
271
- }
272
- }
273
- }
274
- }
275
- }
276
- } catch {
277
- // Ignore errors
278
- }
279
-
280
- md.push('### Static Analysis Findings');
281
- let hasFindings = false;
282
- if (patternExamples.size > 0) {
283
- for (const [, v] of patternExamples) {
284
- if (v.firstFile) {
285
- hasFindings = true;
286
- const fileLink = `[${path.basename(v.firstFile)}](file:///${path.join(worktreePath, v.firstFile).replace(/\\/g, '/')})`;
287
- md.push(`- **${v.label}** example: ${fileLink} _(${v.description})_`);
288
- }
289
- }
290
- }
291
- if (!hasFindings) {
292
- md.push('_No architectural usage patterns detected via static analysis._');
293
- }
294
- md.push('');
295
-
296
- md.push('### Packages Present (Dependencies)');
297
- // Filter dependencies: only show internal packages produced by repos in this workspace,
298
- // or those matching a common organization namespace prefix (e.g. if one package is MyOrg.Common, then MyOrg.*).
299
- const internalPrefixes = Array.from(allProducedPackages).map(p => {
300
- const parts = p.split('.');
301
- return parts.length > 1 ? parts[0] + '.' : null;
302
- }).filter((p): p is string => p !== null);
303
-
304
- const filteredDeps = analysis.dependencies.filter(dep => {
305
- const depNameLower = dep.name.toLowerCase();
306
- if (allProducedPackages.has(depNameLower)) return true;
307
- return internalPrefixes.some(prefix => depNameLower.startsWith(prefix));
308
- });
309
-
310
- if (filteredDeps.length > 0) {
311
- for (const dep of filteredDeps) {
312
- md.push(`- \`${dep.name}\` (${dep.version || 'unknown version'})`);
313
- }
314
- } else {
315
- md.push('_No cross-repo or organization-internal package dependencies detected._');
316
- }
317
- md.push('');
318
-
319
- // 3. Endpoint Inventory
320
- md.push('## 🔌 API Endpoints');
321
- md.push('');
322
- if (analysis.endpoints.length > 0) {
323
- md.push('| Endpoint Group (Router/Module/File) | Route Prefix / Pattern | Verbs | Source File |');
324
- md.push('|:---|:---|:---|:---|');
325
-
326
- // Group endpoints by source file
327
- const grouped = new Map<string, typeof analysis.endpoints>();
328
- for (const ep of analysis.endpoints) {
329
- const src = ep.source || 'Unknown';
330
- if (!grouped.has(src)) {
331
- grouped.set(src, []);
332
- }
333
- grouped.get(src)!.push(ep);
334
- }
335
-
336
- const findCommonPrefix = (paths: string[]): string => {
337
- if (paths.length === 0) return '';
338
- if (paths.length === 1) return paths[0]!;
339
- const sorted = [...paths].sort();
340
- const first = sorted[0]!.split('/');
341
- const last = sorted[sorted.length - 1]!.split('/');
342
- const common: string[] = [];
343
- for (let i = 0; i < first.length; i++) {
344
- if (first[i] === last[i]) {
345
- common.push(first[i]!);
346
- } else {
347
- break;
348
- }
349
- }
350
- const prefix = common.join('/');
351
- return prefix || '/';
352
- };
353
-
354
- for (const [src, eps] of grouped) {
355
- const groupName = src !== 'Unknown' ? path.basename(src, path.extname(src)) : 'Inferred';
356
- const paths = eps.map(e => e.path);
357
- const commonPrefix = findCommonPrefix(paths);
358
- const verbs = Array.from(new Set(eps.map(e => e.method.toUpperCase()))).join(', ');
359
- const sourceLink = src !== 'Unknown'
360
- ? `[${path.basename(src)}](file:///${path.join(worktreePath, src).replace(/\\/g, '/')})`
361
- : '—';
362
- md.push(`| ${groupName} | \`${commonPrefix}\` | \`${verbs}\` | ${sourceLink} |`);
363
- }
364
- } else {
365
- md.push('_No endpoints detected._');
366
- }
367
- md.push('');
368
-
369
- // 4. Test Landscape
370
- md.push('## 🧪 Test Landscape & Command');
371
- md.push('');
372
- const testFrameworks: string[] = [];
373
- let testCommand = '';
374
-
375
- for (const dep of analysis.dependencies) {
376
- const name = dep.name.toLowerCase();
377
- if (name.includes('xunit')) testFrameworks.push('xUnit');
378
- if (name.includes('mstest') || name.includes('microsoft.testplatform')) testFrameworks.push('MSTest');
379
- if (name.includes('nunit')) testFrameworks.push('NUnit');
380
- if (name.includes('jest')) testFrameworks.push('Jest');
381
- if (name.includes('vitest')) testFrameworks.push('Vitest');
382
- if (name.includes('cypress')) testFrameworks.push('Cypress');
383
- if (name.includes('playwright')) testFrameworks.push('Playwright');
384
- }
385
-
386
- if (analysis.techStack.languages.includes('csharp')) {
387
- testCommand = 'dotnet test';
388
- try {
389
- const slns = await globby('**/*.sln', {
390
- cwd: worktreePath,
391
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
392
- });
393
- if (slns.length > 0) {
394
- testCommand = `dotnet test ${slns[0]}`;
395
- }
396
- } catch {}
397
- } else if (analysis.techStack.languages.includes('typescript') || analysis.techStack.languages.includes('javascript')) {
398
- testCommand = 'npm test';
399
- }
400
-
401
- if (testFrameworks.length > 0) {
402
- md.push(`- **Frameworks**: ${testFrameworks.join(', ')}`);
403
- } else {
404
- md.push('- **Frameworks**: None explicitly detected');
405
- }
406
- if (testCommand) {
407
- md.push(`- **Run Command**: \`${testCommand}\``);
408
- }
409
- md.push('');
410
-
411
- // 4.5. Running Locally
412
- md.push('## ▶️ Running Locally');
413
- md.push('');
414
- if (analysis.runConfig) {
415
- const { entryPoints, databases, sharedInfraWarnings, committedSecrets } = analysis.runConfig;
416
-
417
- if (entryPoints.length > 0) {
418
- md.push('### Entry Points');
419
- for (const ep of entryPoints) {
420
- md.push(`- **${ep.type.toUpperCase()} App**: \`${ep.command || 'dotnet run'}\` (configured in \`${ep.projectPath}\`)`);
421
- }
422
- md.push('');
423
- }
424
-
425
- if (databases.length > 0) {
426
- md.push('### Databases & Data Stores');
427
- md.push('| Provider | Target Host | Config File |');
428
- md.push('|---|---|---|');
429
- for (const db of databases) {
430
- md.push(`| ${db.provider} | ${db.host} | \`${db.configFile}\` |`);
431
- }
432
- md.push('');
433
- }
434
-
435
- if (sharedInfraWarnings.length > 0) {
436
- md.push('### ⚠️ Shared Infrastructure Warnings');
437
- for (const w of sharedInfraWarnings) {
438
- md.push(`- ${w.warning}`);
439
- }
440
- md.push('');
441
- }
442
-
443
- if (committedSecrets.length > 0) {
444
- md.push('### 🔒 Potential Committed Secrets');
445
- for (const s of committedSecrets) {
446
- md.push(`- **Warning**: Possible plaintext secret/key/password found in \`${s.file}\` (key hint: \`${s.lineHint}\`)`);
447
- }
448
- md.push('');
449
- }
450
- } else {
451
- md.push('_No run configurations detected._');
452
- md.push('');
453
- }
454
-
455
- // 5. Custom Skills
456
- md.push('## 🛠️ Custom Agent Skills');
457
- md.push('');
458
- try {
459
- const skills = await globby('**/SKILL.md', {
460
- cwd: worktreePath,
461
- absolute: true,
462
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**', '**/dist/**', '**/out/**', '**/.git/**'],
463
- });
464
-
465
- if (skills.length > 0) {
466
- md.push('The following custom agent skills are available in this repository:');
467
- for (const skill of skills) {
468
- const relativeSkill = path.relative(worktreePath, skill);
469
- const skillName = path.basename(path.dirname(skill));
470
- md.push(`- **${skillName}**: [${relativeSkill}](file:///${skill})`);
471
- }
472
- } else {
473
- md.push('_No custom agent skills found in this repository._');
474
- }
475
- } catch {
476
- md.push('_No custom agent skills found in this repository._');
477
- }
478
- md.push('');
479
-
480
- // 6. AI Configurations
481
- md.push('## 📄 AI Assistant Configurations');
482
- md.push('');
483
- if (analysis.existingAIConfigs.length > 0) {
484
- md.push('Incorporate instructions from these local configurations:');
485
- for (const config of analysis.existingAIConfigs) {
486
- md.push(`- [${config.relativePath}](file:///${path.join(worktreePath, config.relativePath)}) (${config.assistant})`);
487
- }
488
- } else {
489
- md.push('_No pre-existing AI configurations found in this repository._');
490
- }
491
- md.push('');
492
-
493
- // 7. Project-Specific Conventions (Agent-Defined)
494
- md.push('## 📝 Discovered Conventions');
495
- md.push('');
496
-
497
- const featureId = path.basename(workspacePath);
498
- const conventionsFilename = `nexusflow-conventions-${repoName}.md`;
499
- let customConventions = '';
500
-
501
- const conventionsExist = await workspaceFileExists(workspacePath, featureId, conventionsFilename);
502
-
503
- if (!conventionsExist) {
504
- const starterContent = `# Repository Conventions — ${repoName}
505
-
506
- Use this file to record project-specific coding conventions, patterns, gotchas, and constraints learned during development.
507
- Future AI assistant sessions will read these conventions from the repository map.
508
-
509
- ## Coding Patterns
510
- <!-- E.g., Use ErrorContent structure for errors instead of plain strings -->
511
-
512
- - None recorded yet.
513
-
514
- ## Gotchas & Watch-outs
515
- <!-- E.g., Non-nullable enum required attributes gotchas -->
516
-
517
- - None recorded yet.
518
- `;
519
- try {
520
- await writeBaseFile(workspacePath, repoName, conventionsFilename, starterContent);
521
- customConventions = starterContent.replace(/^#\s+.+\n?/, '').trim();
522
- } catch {}
523
- } else {
524
- try {
525
- customConventions = await readBaseFile(workspacePath, repoName, conventionsFilename);
526
- customConventions = customConventions.replace(/^#\s+.+\n?/, '').trim();
527
- } catch {}
528
- }
529
-
530
- if (customConventions) {
531
- md.push(customConventions);
532
- md.push('');
533
- } else {
534
- md.push('- None recorded yet.');
535
- md.push('');
536
- }
537
-
538
- await writeBaseFile(workspacePath, repoName, `nexusflow-map-${repoName}.md`, md.join('\n'));
539
- }