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
@@ -0,0 +1,25 @@
1
+ public with sharing class OpportunityController {
2
+
3
+ @AuraEnabled(cacheable=true)
4
+ public static List<Opportunity> getOpportunitiesByStage(String stageName) {
5
+ return [SELECT Id, Name, Amount, CloseDate, StageName, Account.Name
6
+ FROM Opportunity
7
+ WHERE StageName = :stageName
8
+ ORDER BY CloseDate DESC
9
+ LIMIT 50];
10
+ }
11
+
12
+ @AuraEnabled
13
+ public static void closeWon(String opportunityId) {
14
+ Opportunity opp = [SELECT Id, StageName FROM Opportunity WHERE Id = :opportunityId];
15
+ opp.StageName = 'Closed Won';
16
+ opp.CloseDate = Date.today();
17
+ update opp;
18
+ }
19
+
20
+ public static void validateOpportunity(Opportunity opp) {
21
+ if (opp.Amount != null && opp.Amount > 1000000) {
22
+ opp.addError('Amount exceeds maximum allowed');
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <label>Project</label>
4
+ <pluralLabel>Projects</pluralLabel>
5
+ <nameField>
6
+ <label>Project Name</label>
7
+ <type>Text</type>
8
+ </nameField>
9
+ <fields>
10
+ <fullName>Status__c</fullName>
11
+ <label>Status</label>
12
+ <type>Picklist</type>
13
+ <valueSet>
14
+ <valueSetDefinition>
15
+ <value>
16
+ <fullName>Planning</fullName>
17
+ <default>false</default>
18
+ </value>
19
+ <value>
20
+ <fullName>In Progress</fullName>
21
+ <default>false</default>
22
+ </value>
23
+ <value>
24
+ <fullName>Completed</fullName>
25
+ <default>false</default>
26
+ </value>
27
+ </valueSetDefinition>
28
+ </valueSet>
29
+ </fields>
30
+ <fields>
31
+ <fullName>Budget__c</fullName>
32
+ <label>Budget</label>
33
+ <type>Currency</type>
34
+ </fields>
35
+ <fields>
36
+ <fullName>StartDate__c</fullName>
37
+ <label>Start Date</label>
38
+ <type>Date</type>
39
+ </fields>
40
+ <fields>
41
+ <fullName>EndDate__c</fullName>
42
+ <label>End Date</label>
43
+ <type>Date</type>
44
+ </fields>
45
+ </CustomObject>
@@ -0,0 +1,33 @@
1
+ trigger AccountTrigger on Account (before insert, before update, after insert, after update) {
2
+
3
+ if (Trigger.isBefore) {
4
+ if (Trigger.isInsert || Trigger.isUpdate) {
5
+ for (Account acc : Trigger.new) {
6
+ if (acc.Industry == null) {
7
+ acc.Industry = 'Other';
8
+ }
9
+ if (acc.Name != null && acc.Name.length() > 80) {
10
+ acc.Name.addError('Account name cannot exceed 80 characters');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ if (Trigger.isAfter) {
17
+ if (Trigger.isInsert) {
18
+ List<Task> tasks = new List<Task>();
19
+ for (Account acc : Trigger.new) {
20
+ Task t = new Task(
21
+ Subject = 'Welcome ' + acc.Name,
22
+ WhatId = acc.Id,
23
+ Status = 'Not Started',
24
+ Priority = 'Normal'
25
+ );
26
+ tasks.add(t);
27
+ }
28
+ if (!tasks.isEmpty()) {
29
+ insert tasks;
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "packageDirectories": [
3
+ {
4
+ "path": "force-app",
5
+ "default": true
6
+ }
7
+ ],
8
+ "namespace": "",
9
+ "sfdcLoginUrl": "https://login.salesforce.com",
10
+ "sourceApiVersion": "58.0"
11
+ }
@@ -0,0 +1,85 @@
1
+ # ai-first E2E Test Suite
2
+
3
+ This directory contains end-to-end tests for ai-first-cli across different project types.
4
+
5
+ ## Test Projects
6
+
7
+ | Project | Path | Type | Framework |
8
+ |---------|------|------|-----------|
9
+ | Express API | `test-projects/express-api` | Backend | Express.js |
10
+ | NestJS Backend | `test-projects/nestjs-backend` | Backend | NestJS |
11
+ | Python CLI | `test-projects/python-cli` | CLI | Python |
12
+ | React App | `test-projects/react-app` | Frontend | React + Vite |
13
+
14
+ ## Test Commands
15
+
16
+ ### Init Command Tests
17
+
18
+ ```bash
19
+ # Test init on all projects
20
+ npm run test:e2e:init
21
+
22
+ # Individual project tests
23
+ node dist/commands/ai-first.js init --root test-projects/express-api
24
+ node dist/commands/ai-first.js init --root test-projects/nestjs-backend
25
+ node dist/commands/ai-first.js init --root test-projects/python-cli
26
+ node dist/commands/ai-first.js init --root test-projects/react-app
27
+ ```
28
+
29
+ ### Map Command Tests
30
+
31
+ ```bash
32
+ # Test map on all projects
33
+ npm run test:e2e:map
34
+
35
+ # Individual project tests
36
+ node dist/commands/ai-first.js map --root test-projects/express-api
37
+ node dist/commands/ai-first.js map --root test-projects/nestjs-backend
38
+ node dist/commands/ai-first.js map --root test-projects/python-cli
39
+ node dist/commands/ai-first.js map --root test-projects/react-app
40
+ ```
41
+
42
+ ## Expected Results
43
+
44
+ ### init command should generate:
45
+
46
+ - [x] `ai/repo_map.md`
47
+ - [x] `ai/repo_map.json`
48
+ - [x] `ai/summary.md`
49
+ - [x] `ai/architecture.md`
50
+ - [x] `ai/tech_stack.md`
51
+ - [x] `ai/entrypoints.md`
52
+ - [x] `ai/conventions.md`
53
+ - [x] `ai/symbols.json`
54
+ - [x] `ai/dependencies.json`
55
+ - [x] `ai/ai_rules.md`
56
+ - [x] `ai/ai_context.md`
57
+ - [ ] `ai/context/features/*.json` ← NOT WORKING
58
+ - [ ] `ai/context/flows/*.json` ← NOT WORKING (except NestJS with map)
59
+
60
+ ### map command should generate:
61
+
62
+ - [x] `ai/graph/module-graph.json`
63
+ - [x] `ai/graph/symbol-graph.json`
64
+ - [x] `ai/files.json`
65
+ - [ ] `ai/context/features/*.json` ← NOT WORKING for JS/Python/React
66
+ - [x] `ai/context/flows/*.json` ← Only works for NestJS
67
+
68
+ ## Running Tests
69
+
70
+ ```bash
71
+ # Build first
72
+ npm run build
73
+
74
+ # Run init tests
75
+ for project in express-api nestjs-backend python-cli react-app; do
76
+ rm -rf test-projects/$project/ai
77
+ node dist/commands/ai-first.js init --root test-projects/$project
78
+ done
79
+
80
+ # Run map tests
81
+ for project in express-api nestjs-backend python-cli react-app; do
82
+ rm -rf test-projects/$project/ai
83
+ node dist/commands/ai-first.js map --root test-projects/$project
84
+ done
85
+ ```
@@ -0,0 +1,88 @@
1
+ #!/bin/bash
2
+
3
+ # E2E Test Runner for ai-first-cli
4
+ # Runs all commands on all test projects
5
+
6
+ set -e
7
+
8
+ CLI="node dist/commands/ai-first.js"
9
+ PROJECTS=("express-api" "nestjs-backend" "python-cli" "react-app")
10
+
11
+ echo "========================================"
12
+ echo "ai-first-cli E2E Test Suite"
13
+ echo "========================================"
14
+
15
+ # Build first
16
+ echo "Building..."
17
+ npm run build
18
+
19
+ # Test each command on each project
20
+ for project in "${PROJECTS[@]}"; do
21
+ echo ""
22
+ echo "========================================"
23
+ echo "Testing: $project"
24
+ echo "========================================"
25
+
26
+ # Clean ai directory
27
+ rm -rf "test-projects/$project/ai"
28
+
29
+ # Test init
30
+ echo ""
31
+ echo "--- init ---"
32
+ $CLI init --root "test-projects/$project" || true
33
+
34
+ # Test doctor
35
+ echo ""
36
+ echo "--- doctor ---"
37
+ $CLI doctor --root "test-projects/$project" || true
38
+
39
+ # Test map
40
+ echo ""
41
+ echo "--- map ---"
42
+ $CLI map --root "test-projects/$project" || true
43
+
44
+ # Test index
45
+ echo ""
46
+ echo "--- index ---"
47
+ $CLI index --root "test-projects/$project" || true
48
+
49
+ # Test explore
50
+ echo ""
51
+ echo "--- explore ---"
52
+ $CLI explore all --root "test-projects/$project" || true
53
+
54
+ # Test graph
55
+ echo ""
56
+ echo "--- graph ---"
57
+ $CLI graph --root "test-projects/$project" || true
58
+
59
+ # Test git
60
+ echo ""
61
+ echo "--- git ---"
62
+ $CLI git --root "test-projects/$project" || true
63
+
64
+ # Check results
65
+ echo ""
66
+ echo "--- Results ---"
67
+ if [ -d "test-projects/$project/ai" ]; then
68
+ echo "Files generated:"
69
+ ls "test-projects/$project/ai/"
70
+
71
+ if [ -d "test-projects/$project/ai/context/features" ]; then
72
+ FEATURES=$(ls -1 "test-projects/$project/ai/context/features/" 2>/dev/null | wc -l)
73
+ echo "Features: $FEATURES"
74
+ fi
75
+
76
+ if [ -d "test-projects/$project/ai/context/flows" ]; then
77
+ FLOWS=$(ls -1 "test-projects/$project/ai/context/flows/" 2>/dev/null | wc -l)
78
+ echo "Flows: $FLOWS"
79
+ fi
80
+ else
81
+ echo "ERROR: No ai directory created"
82
+ fi
83
+ done
84
+
85
+ echo ""
86
+ echo "========================================"
87
+ echo "E2E Tests Complete"
88
+ echo "========================================"
@@ -19,11 +19,16 @@ function createTempTestDir(files: Record<string, string[]>): string {
19
19
  fs.mkdirSync(path.join(aiDir, "context", "flows"), { recursive: true });
20
20
  fs.mkdirSync(path.join(aiDir, "graph"), { recursive: true });
21
21
 
22
- // Create modules.json
22
+ // Create modules.json - use key as module name, derive path from files
23
23
  const modules: Record<string, { path: string; files: string[] }> = {};
24
24
  for (const [moduleName, moduleFiles] of Object.entries(files)) {
25
+ // Derive path from the first file's directory
26
+ const firstFile = moduleFiles[0] || "";
27
+ const pathParts = firstFile.split("/");
28
+ const derivedPath = pathParts.length > 1 ? pathParts.slice(0, -1).join("/") : moduleName;
29
+
25
30
  modules[moduleName] = {
26
- path: moduleName,
31
+ path: derivedPath || moduleName,
27
32
  files: moduleFiles
28
33
  };
29
34
  }
@@ -39,25 +44,20 @@ describe("Feature Detection", () => {
39
44
  describe("generateFeatures", () => {
40
45
  it("should detect valid business features", () => {
41
46
  const aiDir = createTempTestDir({
42
- "src/auth": [
47
+ "auth": [
43
48
  "src/auth/authController.ts",
44
49
  "src/auth/authService.ts",
45
- "src/auth/authRepository.ts",
46
- "src/auth/types.ts"
50
+ "src/auth/authRepository.ts"
47
51
  ],
48
- "src/users": [
52
+ "users": [
49
53
  "src/users/userController.ts",
50
54
  "src/users/userService.ts",
51
55
  "src/users/userRepository.ts"
52
56
  ],
53
- "src/payments": [
57
+ "payments": [
54
58
  "src/payments/paymentController.ts",
55
59
  "src/payments/paymentService.ts",
56
60
  "src/payments/paymentRepository.ts"
57
- ],
58
- "utils": [
59
- "utils/helper.ts",
60
- "utils/logger.ts"
61
61
  ]
62
62
  });
63
63
 
@@ -97,24 +97,22 @@ describe("Feature Detection", () => {
97
97
  expect(featureNames).not.toContain("types");
98
98
  });
99
99
 
100
- it("should require at least 3 source files", () => {
100
+ it("should require at least 2 source files", () => {
101
101
  const aiDir = createTempTestDir({
102
102
  "src/small": [
103
- "src/small/file1.ts",
104
- "src/small/file2.ts"
103
+ "src/small/file1.ts"
105
104
  ],
106
105
  "src/auth": [
107
106
  "src/auth/controller.ts",
108
- "src/auth/service.ts",
109
- "src/auth/repository.ts"
107
+ "src/auth/service.ts"
110
108
  ]
111
109
  });
112
110
 
113
111
  const features = generateFeatures(path.join(aiDir, "modules.json"), "");
114
112
 
115
- // Small feature should be filtered out
113
+ // Small feature should be filtered out (only 1 file)
116
114
  expect(features.find(f => f.name === "small")).toBeUndefined();
117
- // Auth should exist
115
+ // Auth should exist (2 files = minimum)
118
116
  expect(features.find(f => f.name === "auth")).toBeDefined();
119
117
  });
120
118
 
@@ -159,7 +157,7 @@ describe("Feature Detection", () => {
159
157
 
160
158
  it("should include entrypoints in feature output", () => {
161
159
  const aiDir = createTempTestDir({
162
- "src/auth": [
160
+ "auth": [
163
161
  "src/auth/authController.ts",
164
162
  "src/auth/authService.ts",
165
163
  "src/auth/authRepository.ts"
@@ -176,7 +174,7 @@ describe("Feature Detection", () => {
176
174
 
177
175
  it("should include path in feature output", () => {
178
176
  const aiDir = createTempTestDir({
179
- "src/auth": [
177
+ "auth": [
180
178
  "src/auth/authController.ts",
181
179
  "src/auth/authService.ts",
182
180
  "src/auth/authRepository.ts"
@@ -235,9 +233,9 @@ describe("Feature Detection", () => {
235
233
  path.join(aiDir, "modules.json")
236
234
  );
237
235
 
238
- // Flows should be filtered out if less than 3 files
236
+ // Flows should be filtered out if less than 2 files
239
237
  for (const flow of flows) {
240
- expect(flow.files.length).toBeGreaterThanOrEqual(3);
238
+ expect(flow.files.length).toBeGreaterThanOrEqual(2);
241
239
  }
242
240
  });
243
241
 
@@ -255,9 +253,9 @@ describe("Feature Detection", () => {
255
253
  path.join(aiDir, "modules.json")
256
254
  );
257
255
 
258
- // Flows should have at least 2 layers
256
+ // Flows should have at least 1 layer
259
257
  for (const flow of flows) {
260
- expect(flow.layers.length).toBeGreaterThanOrEqual(2);
258
+ expect(flow.layers.length).toBeGreaterThanOrEqual(1);
261
259
  }
262
260
  });
263
261
 
@@ -408,7 +406,7 @@ describe("Feature Detection", () => {
408
406
  path.join(aiDir, "modules.json"),
409
407
  JSON.stringify({
410
408
  modules: {
411
- "src/auth": {
409
+ "auth": {
412
410
  path: "src/auth",
413
411
  files: [
414
412
  "src/auth/authController.ts",