ai-first-cli 1.1.2 → 1.1.5

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 (264) hide show
  1. package/ANALISIS_MEJORAS.md +327 -0
  2. package/BUGS.md +455 -0
  3. package/CHANGELOG.md +100 -225
  4. package/TEST_RESULTS.md +198 -0
  5. package/TEST_RESULTS_COMPARATIVE.md +159 -0
  6. package/TEST_RESULTS_COMPLETE.md +127 -0
  7. package/TEST_RESULTS_COMPREHENSIVE.md +208 -0
  8. package/ai/ai_context.md +17 -10
  9. package/ai/ai_rules.md +5 -3
  10. package/ai/architecture.md +28 -7
  11. package/ai/cache.json +832 -52
  12. package/ai/context/features/commands.json +18 -0
  13. package/ai/context/features/src.json +61 -0
  14. package/ai/context/features/test-projects.json +56 -0
  15. package/ai/context/flows/account.json +9 -0
  16. package/ai/context/flows/add_.json +9 -0
  17. package/ai/context/flows/ai-first.json +9 -0
  18. package/ai/context/flows/auth..json +10 -0
  19. package/ai/context/flows/auth.json +12 -0
  20. package/ai/context/flows/dashboard.json +9 -0
  21. package/ai/context/flows/doctor.json +9 -0
  22. package/ai/context/flows/explore.json +9 -0
  23. package/ai/context/flows/list_.json +9 -0
  24. package/ai/context/flows/login.json +9 -0
  25. package/ai/context/flows/opportunity.json +9 -0
  26. package/ai/context/flows/remove_.json +9 -0
  27. package/ai/context/flows/user.json +14 -0
  28. package/ai/context/flows/users..json +10 -0
  29. package/ai/context/flows/users.json +9 -0
  30. package/ai/conventions.md +3 -2
  31. package/ai/dependencies.json +429 -251
  32. package/ai/entrypoints.md +10 -0
  33. package/ai/files.json +822 -46
  34. package/ai/git/commit-activity.json +126 -39
  35. package/ai/git/recent-features.json +3 -1
  36. package/ai/git/recent-files.json +6 -6
  37. package/ai/git/recent-flows.json +3 -1
  38. package/ai/graph/knowledge-graph.json +954 -182
  39. package/ai/graph/module-graph.json +270 -0
  40. package/ai/graph/symbol-graph.json +48991 -16523
  41. package/ai/graph/symbol-references.json +953 -56
  42. package/ai/hierarchy.json +3 -24
  43. package/ai/index-state.json +1261 -253
  44. package/ai/index.db +0 -0
  45. package/ai/modules.json +226 -0
  46. package/ai/project.json +29 -0
  47. package/ai/repo-map.json +2284 -250
  48. package/ai/repo_map.json +2731 -231
  49. package/ai/repo_map.md +559 -2
  50. package/ai/schema.json +5 -0
  51. package/ai/summary.md +16 -7
  52. package/ai/tech_stack.md +4 -1
  53. package/ai/tools.json +10 -0
  54. package/dist/analyzers/dependencies.d.ts.map +1 -1
  55. package/dist/analyzers/dependencies.js +8 -16
  56. package/dist/analyzers/dependencies.js.map +1 -1
  57. package/dist/analyzers/symbols.d.ts.map +1 -1
  58. package/dist/analyzers/symbols.js +60 -0
  59. package/dist/analyzers/symbols.js.map +1 -1
  60. package/dist/commands/ai-first.d.ts +1 -0
  61. package/dist/commands/ai-first.d.ts.map +1 -1
  62. package/dist/commands/ai-first.js +29 -6
  63. package/dist/commands/ai-first.js.map +1 -1
  64. package/dist/core/semanticContexts.d.ts.map +1 -1
  65. package/dist/core/semanticContexts.js +48 -26
  66. package/dist/core/semanticContexts.js.map +1 -1
  67. package/dist/core/symbolGraph.d.ts.map +1 -1
  68. package/dist/core/symbolGraph.js +14 -2
  69. package/dist/core/symbolGraph.js.map +1 -1
  70. package/dist/utils/fileUtils.d.ts.map +1 -1
  71. package/dist/utils/fileUtils.js +5 -0
  72. package/dist/utils/fileUtils.js.map +1 -1
  73. package/package.json +2 -2
  74. package/src/analyzers/dependencies.ts +10 -20
  75. package/src/analyzers/symbols.ts +64 -0
  76. package/src/commands/ai-first.ts +32 -8
  77. package/src/core/semanticContexts.ts +54 -29
  78. package/src/core/symbolGraph.ts +16 -2
  79. package/src/utils/fileUtils.ts +5 -0
  80. package/test-projects/express-api/ai/ai_context.md +112 -0
  81. package/test-projects/express-api/ai/ai_rules.md +50 -0
  82. package/test-projects/express-api/ai/architecture.md +62 -0
  83. package/test-projects/express-api/ai/cache.json +125 -0
  84. package/test-projects/express-api/ai/context/features/controllers.json +13 -0
  85. package/test-projects/express-api/ai/context/features/services.json +13 -0
  86. package/test-projects/express-api/ai/context/flows/auth.json +12 -0
  87. package/test-projects/express-api/ai/context/flows/user.json +13 -0
  88. package/test-projects/express-api/ai/conventions.md +51 -0
  89. package/test-projects/express-api/ai/dependencies.json +54 -0
  90. package/test-projects/express-api/ai/entrypoints.md +17 -0
  91. package/test-projects/express-api/ai/files.json +169 -0
  92. package/test-projects/express-api/ai/graph/knowledge-graph.json +98 -0
  93. package/test-projects/express-api/ai/graph/module-graph.json +44 -0
  94. package/test-projects/express-api/ai/graph/symbol-graph.json +882 -0
  95. package/test-projects/express-api/ai/graph/symbol-references.json +51 -0
  96. package/test-projects/express-api/ai/index-state.json +238 -0
  97. package/test-projects/express-api/ai/index.db +0 -0
  98. package/test-projects/express-api/ai/modules.json +30 -0
  99. package/test-projects/express-api/ai/project.json +15 -0
  100. package/test-projects/express-api/ai/repo-map.json +291 -0
  101. package/test-projects/express-api/ai/repo_map.json +100 -0
  102. package/test-projects/express-api/ai/repo_map.md +36 -0
  103. package/test-projects/express-api/ai/schema.json +5 -0
  104. package/test-projects/express-api/ai/summary.md +14 -0
  105. package/test-projects/express-api/ai/symbols.json +1174 -0
  106. package/test-projects/express-api/ai/tech_stack.md +38 -0
  107. package/test-projects/express-api/ai/tools.json +10 -0
  108. package/test-projects/express-api/controllers/authController.js +32 -0
  109. package/test-projects/express-api/controllers/userController.js +51 -0
  110. package/test-projects/express-api/index.js +21 -0
  111. package/test-projects/express-api/middleware/authMiddleware.js +30 -0
  112. package/test-projects/express-api/models/userRepository.js +25 -0
  113. package/test-projects/express-api/package.json +18 -0
  114. package/test-projects/express-api/services/authService.js +17 -0
  115. package/test-projects/express-api/services/userService.js +28 -0
  116. package/test-projects/nestjs-backend/ai/ai_context.md +110 -0
  117. package/test-projects/nestjs-backend/ai/ai_rules.md +52 -0
  118. package/test-projects/nestjs-backend/ai/architecture.md +43 -0
  119. package/test-projects/nestjs-backend/ai/cache.json +137 -0
  120. package/test-projects/nestjs-backend/ai/context/features/src.json +23 -0
  121. package/test-projects/nestjs-backend/ai/context/flows/auth..json +10 -0
  122. package/test-projects/nestjs-backend/ai/context/flows/users..json +10 -0
  123. package/test-projects/nestjs-backend/ai/conventions.md +52 -0
  124. package/test-projects/nestjs-backend/ai/dependencies.json +152 -0
  125. package/test-projects/nestjs-backend/ai/entrypoints.md +18 -0
  126. package/test-projects/nestjs-backend/ai/files.json +184 -0
  127. package/test-projects/nestjs-backend/ai/graph/knowledge-graph.json +74 -0
  128. package/test-projects/nestjs-backend/ai/graph/module-graph.json +29 -0
  129. package/test-projects/nestjs-backend/ai/graph/symbol-graph.json +304 -0
  130. package/test-projects/nestjs-backend/ai/graph/symbol-references.json +5 -0
  131. package/test-projects/nestjs-backend/ai/index-state.json +259 -0
  132. package/test-projects/nestjs-backend/ai/index.db +0 -0
  133. package/test-projects/nestjs-backend/ai/modules.json +19 -0
  134. package/test-projects/nestjs-backend/ai/project.json +14 -0
  135. package/test-projects/nestjs-backend/ai/repo-map.json +323 -0
  136. package/test-projects/nestjs-backend/ai/repo_map.json +141 -0
  137. package/test-projects/nestjs-backend/ai/repo_map.md +39 -0
  138. package/test-projects/nestjs-backend/ai/schema.json +5 -0
  139. package/test-projects/nestjs-backend/ai/summary.md +11 -0
  140. package/test-projects/nestjs-backend/ai/symbols.json +527 -0
  141. package/test-projects/nestjs-backend/ai/tech_stack.md +37 -0
  142. package/test-projects/nestjs-backend/ai/tools.json +10 -0
  143. package/test-projects/nestjs-backend/package.json +22 -0
  144. package/test-projects/nestjs-backend/src/app.module.ts +8 -0
  145. package/test-projects/nestjs-backend/src/auth/auth.controller.ts +22 -0
  146. package/test-projects/nestjs-backend/src/auth/auth.module.ts +11 -0
  147. package/test-projects/nestjs-backend/src/auth/auth.service.ts +28 -0
  148. package/test-projects/nestjs-backend/src/auth/dto/login.dto.ts +4 -0
  149. package/test-projects/nestjs-backend/src/auth/strategies/jwt.strategy.ts +18 -0
  150. package/test-projects/nestjs-backend/src/main.ts +9 -0
  151. package/test-projects/nestjs-backend/src/users/users.controller.ts +32 -0
  152. package/test-projects/nestjs-backend/src/users/users.module.ts +10 -0
  153. package/test-projects/nestjs-backend/src/users/users.service.ts +42 -0
  154. package/test-projects/nestjs-backend/tsconfig.json +21 -0
  155. package/test-projects/python-cli/__init__.py +1 -0
  156. package/test-projects/python-cli/ai/ai_context.md +94 -0
  157. package/test-projects/python-cli/ai/ai_rules.md +47 -0
  158. package/test-projects/python-cli/ai/architecture.md +49 -0
  159. package/test-projects/python-cli/ai/cache.json +129 -0
  160. package/test-projects/python-cli/ai/context/features/cli.json +16 -0
  161. package/test-projects/python-cli/ai/context/flows/add_.json +9 -0
  162. package/test-projects/python-cli/ai/context/flows/list_.json +9 -0
  163. package/test-projects/python-cli/ai/context/flows/remove_.json +9 -0
  164. package/test-projects/python-cli/ai/conventions.md +51 -0
  165. package/test-projects/python-cli/ai/dependencies.json +66 -0
  166. package/test-projects/python-cli/ai/entrypoints.md +4 -0
  167. package/test-projects/python-cli/ai/files.json +174 -0
  168. package/test-projects/python-cli/ai/graph/knowledge-graph.json +83 -0
  169. package/test-projects/python-cli/ai/graph/module-graph.json +31 -0
  170. package/test-projects/python-cli/ai/graph/symbol-graph.json +358 -0
  171. package/test-projects/python-cli/ai/graph/symbol-references.json +11 -0
  172. package/test-projects/python-cli/ai/index-state.json +245 -0
  173. package/test-projects/python-cli/ai/index.db +0 -0
  174. package/test-projects/python-cli/ai/modules.json +21 -0
  175. package/test-projects/python-cli/ai/project.json +15 -0
  176. package/test-projects/python-cli/ai/repo-map.json +290 -0
  177. package/test-projects/python-cli/ai/repo_map.json +99 -0
  178. package/test-projects/python-cli/ai/repo_map.md +32 -0
  179. package/test-projects/python-cli/ai/schema.json +5 -0
  180. package/test-projects/python-cli/ai/summary.md +11 -0
  181. package/test-projects/python-cli/ai/symbols.json +475 -0
  182. package/test-projects/python-cli/ai/tech_stack.md +30 -0
  183. package/test-projects/python-cli/ai/tools.json +10 -0
  184. package/test-projects/python-cli/cli/__init__.py +1 -0
  185. package/test-projects/python-cli/cli/add_command.py +6 -0
  186. package/test-projects/python-cli/cli/list_command.py +7 -0
  187. package/test-projects/python-cli/cli/remove_command.py +6 -0
  188. package/test-projects/python-cli/main.py +34 -0
  189. package/test-projects/python-cli/models/__init__.py +2 -0
  190. package/test-projects/python-cli/models/task.py +19 -0
  191. package/test-projects/python-cli/models/task_repository.py +44 -0
  192. package/test-projects/react-app/ai/ai_context.md +95 -0
  193. package/test-projects/react-app/ai/ai_rules.md +49 -0
  194. package/test-projects/react-app/ai/architecture.md +33 -0
  195. package/test-projects/react-app/ai/cache.json +129 -0
  196. package/test-projects/react-app/ai/context/features/src.json +18 -0
  197. package/test-projects/react-app/ai/context/flows/dashboard.json +9 -0
  198. package/test-projects/react-app/ai/context/flows/login.json +9 -0
  199. package/test-projects/react-app/ai/context/flows/users.json +9 -0
  200. package/test-projects/react-app/ai/conventions.md +52 -0
  201. package/test-projects/react-app/ai/dependencies.json +128 -0
  202. package/test-projects/react-app/ai/entrypoints.md +4 -0
  203. package/test-projects/react-app/ai/files.json +174 -0
  204. package/test-projects/react-app/ai/graph/knowledge-graph.json +83 -0
  205. package/test-projects/react-app/ai/graph/module-graph.json +31 -0
  206. package/test-projects/react-app/ai/graph/symbol-graph.json +868 -0
  207. package/test-projects/react-app/ai/graph/symbol-references.json +31 -0
  208. package/test-projects/react-app/ai/index-state.json +245 -0
  209. package/test-projects/react-app/ai/index.db +0 -0
  210. package/test-projects/react-app/ai/modules.json +17 -0
  211. package/test-projects/react-app/ai/project.json +15 -0
  212. package/test-projects/react-app/ai/repo-map.json +305 -0
  213. package/test-projects/react-app/ai/repo_map.json +114 -0
  214. package/test-projects/react-app/ai/repo_map.md +31 -0
  215. package/test-projects/react-app/ai/schema.json +5 -0
  216. package/test-projects/react-app/ai/summary.md +11 -0
  217. package/test-projects/react-app/ai/symbols.json +985 -0
  218. package/test-projects/react-app/ai/tech_stack.md +38 -0
  219. package/test-projects/react-app/ai/tools.json +10 -0
  220. package/test-projects/react-app/package.json +16 -0
  221. package/test-projects/react-app/src/App.tsx +21 -0
  222. package/test-projects/react-app/src/context/AuthContext.tsx +41 -0
  223. package/test-projects/react-app/src/hooks/useAuth.ts +10 -0
  224. package/test-projects/react-app/src/main.tsx +10 -0
  225. package/test-projects/react-app/src/pages/DashboardPage.tsx +17 -0
  226. package/test-projects/react-app/src/pages/LoginPage.tsx +41 -0
  227. package/test-projects/react-app/src/pages/UsersPage.tsx +36 -0
  228. package/test-projects/react-app/src/services/userService.ts +37 -0
  229. package/test-projects/salesforce-cli/.forceignore +27 -0
  230. package/test-projects/salesforce-cli/ai/ai_context.md +88 -0
  231. package/test-projects/salesforce-cli/ai/ai_rules.md +47 -0
  232. package/test-projects/salesforce-cli/ai/architecture.md +33 -0
  233. package/test-projects/salesforce-cli/ai/cache.json +105 -0
  234. package/test-projects/salesforce-cli/ai/context/features/force-app.json +14 -0
  235. package/test-projects/salesforce-cli/ai/context/flows/account.json +9 -0
  236. package/test-projects/salesforce-cli/ai/context/flows/opportunity.json +9 -0
  237. package/test-projects/salesforce-cli/ai/conventions.md +51 -0
  238. package/test-projects/salesforce-cli/ai/dependencies.json +6 -0
  239. package/test-projects/salesforce-cli/ai/entrypoints.md +4 -0
  240. package/test-projects/salesforce-cli/ai/files.json +144 -0
  241. package/test-projects/salesforce-cli/ai/graph/knowledge-graph.json +64 -0
  242. package/test-projects/salesforce-cli/ai/graph/module-graph.json +13 -0
  243. package/test-projects/salesforce-cli/ai/graph/symbol-graph.json +148 -0
  244. package/test-projects/salesforce-cli/ai/graph/symbol-references.json +1 -0
  245. package/test-projects/salesforce-cli/ai/index-state.json +203 -0
  246. package/test-projects/salesforce-cli/ai/index.db +0 -0
  247. package/test-projects/salesforce-cli/ai/modules.json +12 -0
  248. package/test-projects/salesforce-cli/ai/project.json +14 -0
  249. package/test-projects/salesforce-cli/ai/repo-map.json +251 -0
  250. package/test-projects/salesforce-cli/ai/repo_map.json +69 -0
  251. package/test-projects/salesforce-cli/ai/repo_map.md +21 -0
  252. package/test-projects/salesforce-cli/ai/schema.json +5 -0
  253. package/test-projects/salesforce-cli/ai/summary.md +11 -0
  254. package/test-projects/salesforce-cli/ai/symbols.json +245 -0
  255. package/test-projects/salesforce-cli/ai/tech_stack.md +30 -0
  256. package/test-projects/salesforce-cli/ai/tools.json +10 -0
  257. package/test-projects/salesforce-cli/force-app/main/default/classes/AccountController.cls +24 -0
  258. package/test-projects/salesforce-cli/force-app/main/default/classes/OpportunityController.cls +25 -0
  259. package/test-projects/salesforce-cli/force-app/main/default/objects/Project__c.object.xml +45 -0
  260. package/test-projects/salesforce-cli/force-app/main/default/triggers/AccountTrigger.trigger +33 -0
  261. package/test-projects/salesforce-cli/sfdx-project.json +11 -0
  262. package/tests/e2e/README.md +85 -0
  263. package/tests/e2e/run-e2e.sh +88 -0
  264. package/tests/semanticContexts.test.ts +23 -25
@@ -28,7 +28,11 @@ export interface SemanticContexts {
28
28
  // ============================================================
29
29
 
30
30
  // 1. Candidate roots - scan inside these directories
31
- const CANDIDATE_ROOTS = ["src", "app", "packages", "services", "modules", "features"];
31
+ const CANDIDATE_ROOTS = [
32
+ "src", "app", "packages", "services", "modules", "features",
33
+ // MVC patterns - for projects without src/ prefix
34
+ "controllers", "routes", "handlers", "views", "pages"
35
+ ];
32
36
 
33
37
  // 2. Ignore folders - these are technical, not business features
34
38
  const IGNORED_FOLDERS = new Set([
@@ -39,7 +43,6 @@ const IGNORED_FOLDERS = new Set([
39
43
  "constants",
40
44
  "config",
41
45
  "dto",
42
- "models",
43
46
  "common",
44
47
  "shared"
45
48
  ]);
@@ -54,7 +57,11 @@ const ENTRYPOINT_PATTERNS = [
54
57
  ];
55
58
 
56
59
  // 4. Flow-specific patterns
57
- const FLOW_ENTRY_PATTERNS = ["controller", "route", "handler", "command"];
60
+ const FLOW_ENTRY_PATTERNS = [
61
+ "controller", "route", "handler", "command",
62
+ // Frontend patterns
63
+ "page", "screen", "view", "component"
64
+ ];
58
65
 
59
66
  // 5. Flow exclusion patterns
60
67
  const FLOW_EXCLUDE = new Set([
@@ -83,7 +90,9 @@ const MAX_FLOW_FILES = 30;
83
90
 
84
91
  // Supported source file extensions
85
92
  const SOURCE_EXTENSIONS = new Set([
86
- ".ts", ".tsx", ".js", ".jsx", ".py", ".java", ".kt", ".go", ".rs", ".rb", ".php", ".cs", ".vue", ".svelte"
93
+ ".ts", ".tsx", ".js", ".jsx", ".py", ".java", ".kt", ".go", ".rs", ".rb", ".php", ".cs", ".vue", ".svelte",
94
+ // Salesforce/Apex
95
+ ".cls", ".trigger", ".apex", ".object"
87
96
  ]);
88
97
 
89
98
  // ============================================================
@@ -96,13 +105,20 @@ function isSourceFile(filePath: string): boolean {
96
105
  }
97
106
 
98
107
  function isEntrypoint(filePath: string): boolean {
108
+ const lower = filePath.toLowerCase();
109
+ // Check both filename and directory path
99
110
  const basename = path.basename(filePath).toLowerCase();
100
- return ENTRYPOINT_PATTERNS.some(pattern => basename.includes(pattern));
111
+ return ENTRYPOINT_PATTERNS.some(pattern =>
112
+ basename.includes(pattern) || lower.includes("/" + pattern + "s/")
113
+ );
101
114
  }
102
115
 
103
116
  function isFlowEntrypoint(filePath: string): boolean {
117
+ const lower = filePath.toLowerCase();
104
118
  const basename = path.basename(filePath).toLowerCase();
105
- return FLOW_ENTRY_PATTERNS.some(pattern => basename.includes(pattern));
119
+ return FLOW_ENTRY_PATTERNS.some(pattern =>
120
+ basename.includes(pattern) || lower.includes("/" + pattern + "s/")
121
+ );
106
122
  }
107
123
 
108
124
  function isIgnoredFolder(folderName: string): boolean {
@@ -164,7 +180,20 @@ function findFeatureCandidates(files: string[]): Map<string, string[]> {
164
180
 
165
181
  if (rootIdx === -1) continue;
166
182
 
167
- // Check depth 1: src/auth
183
+ // Check depth 0: controllers/ itself is a feature (when file is directly in root)
184
+ const depth0FeatureIdx = rootIdx;
185
+ if (depth0FeatureIdx < parts.length - 1) {
186
+ const featureName0 = parts[depth0FeatureIdx];
187
+ if (!isIgnoredFolder(featureName0) && !featureName0.includes(".")) {
188
+ const featurePath0 = parts.slice(0, depth0FeatureIdx + 1).join("/");
189
+ if (!candidates.has(featurePath0)) {
190
+ candidates.set(featurePath0, []);
191
+ }
192
+ candidates.get(featurePath0)!.push(file);
193
+ }
194
+ }
195
+
196
+ // Check depth 1 and 2: src/auth, src/modules/auth
168
197
  for (let depth = 1; depth <= 2; depth++) {
169
198
  const featureIdx = rootIdx + depth;
170
199
 
@@ -249,36 +278,29 @@ export function generateFeatures(
249
278
  // Ignore errors, return empty
250
279
  }
251
280
 
252
- // Get all files from modules
253
- const allFiles = Object.values(modules).flatMap(m => m.files || []);
254
-
255
- // Find candidate features
256
- const candidates = findFeatureCandidates(allFiles);
257
-
258
- // Filter and validate candidates
259
- for (const [featurePath, files] of candidates) {
281
+ // Use modules directly from modules.json
282
+ for (const [moduleName, mod] of Object.entries(modules)) {
283
+ const files = mod.files || [];
284
+
260
285
  // Filter to source files only
261
286
  const sourceFiles = files.filter(isSourceFile);
262
287
 
263
- // Must have at least 3 source files
264
- if (sourceFiles.length < 3) continue;
288
+ // Must have at least 2 source files (relaxed from 3 for smaller projects)
289
+ if (sourceFiles.length < 2) continue;
265
290
 
266
291
  // Must have at least one entrypoint
267
292
  const entrypoints = sourceFiles.filter(isEntrypoint);
268
293
  if (entrypoints.length === 0) continue;
269
294
 
270
- // Extract feature name from path
271
- const featureName = featurePath.split("/").pop() || featurePath;
272
-
273
- // Get dependencies
274
- const dependencies = getFeatureDependencies(featurePath, modules);
295
+ // Extract feature name from path - get the last segment
296
+ const featureName = mod.path.split("/").pop() || moduleName;
275
297
 
276
298
  features.push({
277
299
  name: featureName,
278
- path: featurePath,
300
+ path: mod.path,
279
301
  files: sourceFiles.slice(0, 50),
280
302
  entrypoints: entrypoints.slice(0, 10),
281
- dependencies
303
+ dependencies: []
282
304
  });
283
305
  }
284
306
 
@@ -372,9 +394,9 @@ function flowsFromFolders(files: string[]): Flow[] {
372
394
  for (const file of files) {
373
395
  if (!isSourceFile(file)) continue;
374
396
 
375
- const baseName = path.basename(file).replace(/\.(ts|js|tsx|jsx)$/, "");
376
- // Extract feature: authController -> auth, userService -> user
377
- const feature = baseName.replace(/(Controller|Service|Repository|Handler|Route|Model|Entity)$/i, "");
397
+ const baseName = path.basename(file).replace(/\.[^.]+$/, "");
398
+ // Extract feature: authController -> auth, userService -> user, LoginPage -> login, Dashboard -> dashboard
399
+ const feature = baseName.replace(/(Controller|Service|Repository|Handler|Route|Model|Entity|Command|Page|Screen|View|Component)$/i, "");
378
400
  const key = feature.toLowerCase();
379
401
 
380
402
  if (!byFeature.has(key)) {
@@ -384,10 +406,13 @@ function flowsFromFolders(files: string[]): Flow[] {
384
406
  }
385
407
 
386
408
  for (const [feature, featureFiles] of byFeature) {
387
- if (featureFiles.length < 3) continue;
409
+ // Relaxed: allow flows with 2+ files OR files that match entrypoint patterns
410
+ const hasEntrypoint = featureFiles.some(f => isFlowEntrypoint(f));
411
+ if (featureFiles.length < 2 && !hasEntrypoint) continue;
388
412
 
389
413
  const layers = new Set(featureFiles.map(getLayer).filter(l => l !== "unknown"));
390
- if (layers.size < 2) continue;
414
+ // Relaxed: allow single layer if files match entrypoint patterns
415
+ if (layers.size < 2 && !hasEntrypoint) continue;
391
416
 
392
417
  const sorted = [...featureFiles].sort((a, b) =>
393
418
  getLayerPriority(a) - getLayerPriority(b)
@@ -145,7 +145,7 @@ function buildSymbolRelationships(
145
145
  // 1. Process imports relationships
146
146
  for (const dep of depsAnalysis.dependencies) {
147
147
  const sourceSymbols = symbols.filter(s => s.file === dep.source);
148
- let targetSymbol = findTargetSymbol(dep.target, symbolMap);
148
+ let targetSymbol = findTargetSymbol(dep.target, symbolMap, symbols);
149
149
 
150
150
  if (targetSymbol && sourceSymbols.length > 0) {
151
151
  for (const source of sourceSymbols) {
@@ -185,7 +185,7 @@ function buildSymbolRelationships(
185
185
  /**
186
186
  * Find target symbol from import path
187
187
  */
188
- function findTargetSymbol(targetPath: string, symbolMap: Map<string, Symbol>): Symbol | undefined {
188
+ function findTargetSymbol(targetPath: string, symbolMap: Map<string, Symbol>, allSymbols?: Symbol[]): Symbol | undefined {
189
189
  // Try exact match
190
190
  let target = symbolMap.get(targetPath);
191
191
 
@@ -208,6 +208,20 @@ function findTargetSymbol(targetPath: string, symbolMap: Map<string, Symbol>): S
208
208
  }
209
209
  }
210
210
 
211
+ // Try to find any symbol in the target file
212
+ if (!target && allSymbols) {
213
+ const targetFile = targetPath.replace(/\.[^.]+$/, '');
214
+ const fileSymbols = allSymbols.filter(s => {
215
+ const symFile = s.file.replace(/\.[^.]+$/, '');
216
+ return symFile === targetFile || symFile.endsWith('/' + targetFile) || symFile.endsWith('/' + targetPath.replace(/\.[^.]+$/, ''));
217
+ });
218
+
219
+ if (fileSymbols.length > 0) {
220
+ // Return the first exported symbol, or just the first one
221
+ target = fileSymbols.find(s => s.export) || fileSymbols[0];
222
+ }
223
+ }
224
+
211
225
  return target;
212
226
  }
213
227
 
@@ -51,6 +51,11 @@ export const DEFAULT_INCLUDE_EXTENSIONS = [
51
51
  ".yaml",
52
52
  ".yml",
53
53
  ".md",
54
+ // Salesforce
55
+ ".cls",
56
+ ".trigger",
57
+ ".apex",
58
+ ".object",
54
59
  ];
55
60
 
56
61
  /**
@@ -0,0 +1,112 @@
1
+ # AI Context
2
+
3
+ > This file provides a comprehensive overview of the repository for AI coding assistants.
4
+
5
+ ---
6
+
7
+ ## Quick Overview
8
+
9
+ - **Pattern**: MVC (Model-View-Controller)
10
+ - **Languages**: JavaScript, JSON
11
+ - **Frameworks**: Express.js
12
+ - **Total Files**: 8
13
+
14
+ ---
15
+
16
+ ## Table of Contents
17
+
18
+ 1. [Tech Stack](#tech-stack)
19
+ 2. [Architecture](#architecture)
20
+ 3. [Key Entrypoints](#key-entrypoints)
21
+ 4. [Code Conventions](#code-conventions)
22
+ 5. [AI Rules](#ai-rules)
23
+ 6. [Repository Map](#repository-map)
24
+
25
+ ---
26
+
27
+ ## Tech Stack
28
+
29
+ **Languages**: JavaScript, JSON
30
+
31
+ **Frameworks**: Express.js
32
+
33
+ **Libraries**: Bcrypt, JWT
34
+
35
+ **Package Managers**: npm
36
+
37
+ ---
38
+
39
+ ## Architecture
40
+
41
+ ## Architectural Pattern
42
+ **Primary**: MVC (Model-View-Controller)
43
+ **Secondary**: Layered Architecture, Microservices
44
+
45
+ ## Layers Identified
46
+ - Application
47
+ - Domain
48
+
49
+ ## Key Modules
50
+ | Module | Responsibility |
51
+ |--------|----------------|
52
+ | `controllers` | API endpoints and request handling |
53
+ | `index.js` | Contains 0 files |
54
+ | `middleware` | Request/response middleware |
55
+ | `models` | Data models and entities |
56
+ | `package.json` | Contains 0 files |
57
+ | `services` | Business logic and use cases |
58
+
59
+
60
+ ---
61
+
62
+ ## Key Entrypoints
63
+
64
+ ### Library
65
+ - `index.js` - Main entry point
66
+
67
+ ### Server
68
+ - `package.json#scripts.start` - start: node index.js
69
+ - `package.json#scripts.dev` - dev: nodemon index.js
70
+
71
+ ---
72
+
73
+ ## Code Conventions
74
+
75
+ ## Naming Conventions
76
+ - **Files**: camelCase
77
+
78
+ ## Project Structure
79
+
80
+ ## Code Style
81
+ - **Semicolons**: Required
82
+
83
+
84
+ ---
85
+
86
+ ## AI Rules
87
+
88
+ - Language: Use JavaScript, JSON
89
+ - Frameworks: Express.js
90
+ - Architecture: Follow MVC (Model-View-Controller) pattern
91
+ - File naming: camelCase
92
+ - Main entry: package.json#scripts.start
93
+
94
+ ---
95
+
96
+ ## Repository Map
97
+
98
+ See repo_map.md for the full structure.
99
+
100
+ ---
101
+
102
+ ## Notes for AI Assistants
103
+
104
+ 1. Follow the established naming conventions (see conventions.md)
105
+ 2. Use the detected frameworks and libraries
106
+ 3. Target the correct entrypoints for modifications
107
+ 4. Maintain the detected architecture patterns
108
+ 5. Follow AI rules in ai_rules.md
109
+
110
+ ---
111
+
112
+ *Generated by ai-first*
@@ -0,0 +1,50 @@
1
+ # AI Rules
2
+
3
+ > Guidelines for AI assistants working on this project
4
+
5
+ ---
6
+
7
+ ## Guidelines
8
+
9
+ - Language: Use JavaScript, JSON
10
+ - Frameworks: Express.js
11
+ - Architecture: Follow MVC (Model-View-Controller) pattern
12
+ - File naming: camelCase
13
+ - Main entry: package.json#scripts.start
14
+ - Dev command: npm run dev
15
+
16
+ ## Patterns
17
+
18
+ - Layer structure: application → domain
19
+
20
+ ## Constraints
21
+
22
+ - Always use semicolons
23
+
24
+ ---
25
+
26
+ ## Quick Reference
27
+
28
+ | Category | Value |
29
+ |----------|-------|
30
+ | Language | JavaScript, JSON |
31
+ | Framework | Express.js |
32
+ | Architecture | MVC (Model-View-Controller) |
33
+ | Naming | camelCase |
34
+ | Indentation | unknown |
35
+
36
+ ---
37
+
38
+ ## Best Practices
39
+
40
+ 1. Follow the established naming conventions
41
+ 2. Keep functions small and focused
42
+ 3. Write tests for new features
43
+ 4. Use descriptive variable names
44
+ 5. Keep the architecture consistent
45
+ 6. Document complex logic
46
+ 7. Review code before committing
47
+
48
+ ---
49
+
50
+ *Generated by ai-first*
@@ -0,0 +1,62 @@
1
+ # Architecture
2
+
3
+ ## Architectural Pattern
4
+ **Primary**: MVC (Model-View-Controller)
5
+ **Secondary**: Layered Architecture, Microservices
6
+
7
+ ## Layers Identified
8
+ - Application
9
+ - Domain
10
+
11
+ ## Key Modules
12
+ | Module | Responsibility |
13
+ |--------|----------------|
14
+ | `controllers` | API endpoints and request handling |
15
+ | `index.js` | Contains 0 files |
16
+ | `middleware` | Request/response middleware |
17
+ | `models` | Data models and entities |
18
+ | `package.json` | Contains 0 files |
19
+ | `services` | Business logic and use cases |
20
+
21
+
22
+ ## Module Details
23
+
24
+ ### controllers
25
+ - **Path**: `controllers`
26
+ - **Responsibility**: API endpoints and request handling
27
+ - **Depends on**: service, model
28
+
29
+ ### index.js
30
+ - **Path**: `index.js`
31
+ - **Responsibility**: Contains 0 files
32
+
33
+
34
+ ### middleware
35
+ - **Path**: `middleware`
36
+ - **Responsibility**: Request/response middleware
37
+
38
+
39
+ ### models
40
+ - **Path**: `models`
41
+ - **Responsibility**: Data models and entities
42
+
43
+
44
+ ### package.json
45
+ - **Path**: `package.json`
46
+ - **Responsibility**: Contains 0 files
47
+
48
+
49
+ ### services
50
+ - **Path**: `services`
51
+ - **Responsibility**: Business logic and use cases
52
+ - **Depends on**: model, repository
53
+
54
+
55
+ ## Recommendations
56
+
57
+ - Keep the architecture consistent as the project grows
58
+ - Follow the established layer structure
59
+ - Use dependency injection to manage module relationships
60
+
61
+ ---
62
+ *Generated by ai-first*
@@ -0,0 +1,125 @@
1
+ {
2
+ "files": {
3
+ "ai/ai_context.md": {
4
+ "hash": "286f0083010c4a66f3906b020b9cc7b4",
5
+ "mtime": 1773796492348.4023
6
+ },
7
+ "ai/ai_rules.md": {
8
+ "hash": "fa1a632e71f5b7055dee7d1368600ce0",
9
+ "mtime": 1773796492348.4023
10
+ },
11
+ "ai/architecture.md": {
12
+ "hash": "5e9f157447aac07a89cf6fe7bffcdad4",
13
+ "mtime": 1773796492342.4023
14
+ },
15
+ "ai/context/features/controllers.json": {
16
+ "hash": "65a9f94a405e51bd65bd7a5378dbb164",
17
+ "mtime": 1773796492350.4023
18
+ },
19
+ "ai/context/features/services.json": {
20
+ "hash": "113525da53ad952071cca194ba355d48",
21
+ "mtime": 1773796492350.4023
22
+ },
23
+ "ai/context/flows/auth.json": {
24
+ "hash": "a6200259a521a38e08dc6396d870a633",
25
+ "mtime": 1773796492350.4023
26
+ },
27
+ "ai/context/flows/user.json": {
28
+ "hash": "af049ebfc3b8ce808e6091ac96a651ee",
29
+ "mtime": 1773796492350.4023
30
+ },
31
+ "ai/conventions.md": {
32
+ "hash": "fa8f117204dbd53d6b787e6ec1791dbf",
33
+ "mtime": 1773796492344.4023
34
+ },
35
+ "ai/dependencies.json": {
36
+ "hash": "b59a369568a90136bf6d54a022aae411",
37
+ "mtime": 1773796492346.4023
38
+ },
39
+ "ai/entrypoints.md": {
40
+ "hash": "17b75097fff8baf7e8218553431dad64",
41
+ "mtime": 1773796492343.4023
42
+ },
43
+ "ai/files.json": {
44
+ "hash": "4041be286c1f3bef227566eb3131babc",
45
+ "mtime": 1773796517397.7932
46
+ },
47
+ "ai/graph/module-graph.json": {
48
+ "hash": "43383456483e635b66ff8960f3b39f03",
49
+ "mtime": 1773796517391.793
50
+ },
51
+ "ai/modules.json": {
52
+ "hash": "52396bb2eb3346493e373bf55805ef90",
53
+ "mtime": 1773796517382.793
54
+ },
55
+ "ai/project.json": {
56
+ "hash": "08ba7541bf16fe9e746aa0ed3ef4a7b3",
57
+ "mtime": 1773796492350.4023
58
+ },
59
+ "ai/repo-map.json": {
60
+ "hash": "bc79826d46b669d42b546057efb73255",
61
+ "mtime": 1773796517383.793
62
+ },
63
+ "ai/repo_map.json": {
64
+ "hash": "474f2af3cc084780fcdc989f865cb19d",
65
+ "mtime": 1773796492340.4023
66
+ },
67
+ "ai/repo_map.md": {
68
+ "hash": "35963e46f602438bc7b1318c630c9616",
69
+ "mtime": 1773796492340.4023
70
+ },
71
+ "ai/schema.json": {
72
+ "hash": "09deb83ac436baaa3ee8ba47c1b6876e",
73
+ "mtime": 1773796492350.4023
74
+ },
75
+ "ai/summary.md": {
76
+ "hash": "792c7fa8536cdf57b7506a5b4390e1fd",
77
+ "mtime": 1773796492341.4023
78
+ },
79
+ "ai/symbols.json": {
80
+ "hash": "55f09cedb48590dcdc4c0a4506026d52",
81
+ "mtime": 1773796492346.4023
82
+ },
83
+ "ai/tech_stack.md": {
84
+ "hash": "bce98c307ddce9864d341031c914ba8a",
85
+ "mtime": 1773796492343.4023
86
+ },
87
+ "ai/tools.json": {
88
+ "hash": "b1356e52c74e9b3b6a0d397b790a4968",
89
+ "mtime": 1773796492350.4023
90
+ },
91
+ "controllers/authController.js": {
92
+ "hash": "7354721b063c069c013d70e04f4bee0f",
93
+ "mtime": 1773776832721.0393
94
+ },
95
+ "controllers/userController.js": {
96
+ "hash": "e43bb45b1c75b7e4bcd072c60a70d848",
97
+ "mtime": 1773776845003.1538
98
+ },
99
+ "index.js": {
100
+ "hash": "b866780bf160f2bfb2ac6baba6a1f6b1",
101
+ "mtime": 1773776791058.662
102
+ },
103
+ "middleware/authMiddleware.js": {
104
+ "hash": "bd1176bd90f83f93b3f66d07758267e5",
105
+ "mtime": 1773776926397.9497
106
+ },
107
+ "models/userRepository.js": {
108
+ "hash": "fdf8dfbb70b15c82f0d2b13e51a640f6",
109
+ "mtime": 1773776885672.544
110
+ },
111
+ "package.json": {
112
+ "hash": "c64180130f77b5472a2850aafa61c7e9",
113
+ "mtime": 1773776784437.6038
114
+ },
115
+ "services/authService.js": {
116
+ "hash": "cacf5bd493a669c8ef7b95bef67cf7e5",
117
+ "mtime": 1773776853984.2388
118
+ },
119
+ "services/userService.js": {
120
+ "hash": "cb3b6f655977d154edee4038d6105d10",
121
+ "mtime": 1773776865182.3455
122
+ }
123
+ },
124
+ "lastIndexed": "2026-03-18T01:15:17.399Z"
125
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "controllers",
3
+ "path": "controllers",
4
+ "files": [
5
+ "controllers/authController.js",
6
+ "controllers/userController.js"
7
+ ],
8
+ "entrypoints": [
9
+ "controllers/authController.js",
10
+ "controllers/userController.js"
11
+ ],
12
+ "dependencies": []
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "services",
3
+ "path": "services",
4
+ "files": [
5
+ "services/authService.js",
6
+ "services/userService.js"
7
+ ],
8
+ "entrypoints": [
9
+ "services/authService.js",
10
+ "services/userService.js"
11
+ ],
12
+ "dependencies": []
13
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "auth",
3
+ "entrypoint": "controllers/authController.js",
4
+ "files": [
5
+ "controllers/authController.js",
6
+ "services/authService.js"
7
+ ],
8
+ "depth": 1,
9
+ "layers": [
10
+ "service"
11
+ ]
12
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "user",
3
+ "entrypoint": "controllers/userController.js",
4
+ "files": [
5
+ "controllers/userController.js",
6
+ "models/userRepository.js",
7
+ "services/userService.js"
8
+ ],
9
+ "depth": 1,
10
+ "layers": [
11
+ "service"
12
+ ]
13
+ }
@@ -0,0 +1,51 @@
1
+ # Code Conventions
2
+
3
+ ## Naming Conventions
4
+ - **Files**: camelCase
5
+
6
+ ## Project Structure
7
+
8
+ ## Code Style
9
+ - **Semicolons**: Required
10
+
11
+
12
+ ## Naming Conventions
13
+
14
+ | Element | Convention |
15
+ |---------|------------|
16
+ | Files | camelCase |
17
+ | Components | unknown |
18
+ | Test Files | unknown |
19
+ | Directories | unknown |
20
+
21
+ ## Project Structure
22
+
23
+ | Directory | Location |
24
+ |-----------|----------|
25
+ | Source | unknown |
26
+ | Tests | unknown |
27
+ | Config | unknown |
28
+
29
+ ## Code Style
30
+
31
+ | Style Element | Value |
32
+ |---------------|-------|
33
+ | Indentation | unknown |
34
+ | Semicolons | Required |
35
+
36
+ ## Testing
37
+
38
+ | Aspect | Value |
39
+ |--------|-------|
40
+ | Framework | unknown |
41
+ | Test Pattern | unknown |
42
+
43
+ ## Git
44
+
45
+ | Aspect | Value |
46
+ |--------|-------|
47
+ | Branch Strategy | Trunk-based (main/master) |
48
+ | Commit Format | unknown |
49
+
50
+ ---
51
+ *Generated by ai-first*