@ai-coders/context 0.3.1 → 0.4.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 (210) hide show
  1. package/README.md +25 -23
  2. package/dist/generators/agents/agentConfig.d.ts.map +1 -1
  3. package/dist/generators/agents/agentConfig.js +42 -0
  4. package/dist/generators/agents/agentConfig.js.map +1 -1
  5. package/dist/generators/agents/agentGenerator.d.ts +0 -1
  6. package/dist/generators/agents/agentGenerator.d.ts.map +1 -1
  7. package/dist/generators/agents/agentGenerator.js +7 -47
  8. package/dist/generators/agents/agentGenerator.js.map +1 -1
  9. package/dist/generators/agents/agentTypes.d.ts +1 -1
  10. package/dist/generators/agents/agentTypes.d.ts.map +1 -1
  11. package/dist/generators/agents/agentTypes.js +4 -1
  12. package/dist/generators/agents/agentTypes.js.map +1 -1
  13. package/dist/generators/agents/templates/indexTemplate.d.ts.map +1 -1
  14. package/dist/generators/agents/templates/indexTemplate.js +2 -1
  15. package/dist/generators/agents/templates/indexTemplate.js.map +1 -1
  16. package/dist/generators/agents/templates/playbookTemplate.d.ts.map +1 -1
  17. package/dist/generators/agents/templates/playbookTemplate.js +39 -3
  18. package/dist/generators/agents/templates/playbookTemplate.js.map +1 -1
  19. package/dist/generators/documentation/documentationGenerator.d.ts +3 -1
  20. package/dist/generators/documentation/documentationGenerator.d.ts.map +1 -1
  21. package/dist/generators/documentation/documentationGenerator.js +88 -15
  22. package/dist/generators/documentation/documentationGenerator.js.map +1 -1
  23. package/dist/generators/documentation/guideRegistry.js +8 -8
  24. package/dist/generators/documentation/guideRegistry.js.map +1 -1
  25. package/dist/generators/documentation/templates/apiReferenceTemplate.d.ts +2 -0
  26. package/dist/generators/documentation/templates/apiReferenceTemplate.d.ts.map +1 -0
  27. package/dist/generators/documentation/templates/apiReferenceTemplate.js +490 -0
  28. package/dist/generators/documentation/templates/apiReferenceTemplate.js.map +1 -0
  29. package/dist/generators/documentation/templates/architectureTemplate.d.ts.map +1 -1
  30. package/dist/generators/documentation/templates/architectureTemplate.js +27 -27
  31. package/dist/generators/documentation/templates/architectureTemplate.js.map +1 -1
  32. package/dist/generators/documentation/templates/common.js +2 -2
  33. package/dist/generators/documentation/templates/common.js.map +1 -1
  34. package/dist/generators/documentation/templates/dataFlowTemplate.d.ts.map +1 -1
  35. package/dist/generators/documentation/templates/dataFlowTemplate.js +5 -20
  36. package/dist/generators/documentation/templates/dataFlowTemplate.js.map +1 -1
  37. package/dist/generators/documentation/templates/developmentWorkflowTemplate.d.ts.map +1 -1
  38. package/dist/generators/documentation/templates/developmentWorkflowTemplate.js +5 -20
  39. package/dist/generators/documentation/templates/developmentWorkflowTemplate.js.map +1 -1
  40. package/dist/generators/documentation/templates/glossaryTemplate.d.ts.map +1 -1
  41. package/dist/generators/documentation/templates/glossaryTemplate.js +9 -23
  42. package/dist/generators/documentation/templates/glossaryTemplate.js.map +1 -1
  43. package/dist/generators/documentation/templates/index.d.ts +4 -0
  44. package/dist/generators/documentation/templates/index.d.ts.map +1 -1
  45. package/dist/generators/documentation/templates/index.js +9 -1
  46. package/dist/generators/documentation/templates/index.js.map +1 -1
  47. package/dist/generators/documentation/templates/indexTemplate.d.ts.map +1 -1
  48. package/dist/generators/documentation/templates/indexTemplate.js +5 -19
  49. package/dist/generators/documentation/templates/indexTemplate.js.map +1 -1
  50. package/dist/generators/documentation/templates/migrationTemplate.d.ts +2 -0
  51. package/dist/generators/documentation/templates/migrationTemplate.d.ts.map +1 -0
  52. package/dist/generators/documentation/templates/migrationTemplate.js +422 -0
  53. package/dist/generators/documentation/templates/migrationTemplate.js.map +1 -0
  54. package/dist/generators/documentation/templates/onboardingTemplate.d.ts +2 -0
  55. package/dist/generators/documentation/templates/onboardingTemplate.d.ts.map +1 -0
  56. package/dist/generators/documentation/templates/onboardingTemplate.js +431 -0
  57. package/dist/generators/documentation/templates/onboardingTemplate.js.map +1 -0
  58. package/dist/generators/documentation/templates/projectOverviewTemplate.d.ts.map +1 -1
  59. package/dist/generators/documentation/templates/projectOverviewTemplate.js +22 -25
  60. package/dist/generators/documentation/templates/projectOverviewTemplate.js.map +1 -1
  61. package/dist/generators/documentation/templates/securityTemplate.d.ts.map +1 -1
  62. package/dist/generators/documentation/templates/securityTemplate.js +5 -19
  63. package/dist/generators/documentation/templates/securityTemplate.js.map +1 -1
  64. package/dist/generators/documentation/templates/testingTemplate.d.ts.map +1 -1
  65. package/dist/generators/documentation/templates/testingTemplate.js +5 -19
  66. package/dist/generators/documentation/templates/testingTemplate.js.map +1 -1
  67. package/dist/generators/documentation/templates/toolingTemplate.d.ts.map +1 -1
  68. package/dist/generators/documentation/templates/toolingTemplate.js +6 -20
  69. package/dist/generators/documentation/templates/toolingTemplate.js.map +1 -1
  70. package/dist/generators/documentation/templates/troubleshootingTemplate.d.ts +2 -0
  71. package/dist/generators/documentation/templates/troubleshootingTemplate.d.ts.map +1 -0
  72. package/dist/generators/documentation/templates/troubleshootingTemplate.js +292 -0
  73. package/dist/generators/documentation/templates/troubleshootingTemplate.js.map +1 -0
  74. package/dist/generators/plans/templates/indexTemplate.d.ts.map +1 -1
  75. package/dist/generators/plans/templates/indexTemplate.js +3 -2
  76. package/dist/generators/plans/templates/indexTemplate.js.map +1 -1
  77. package/dist/generators/plans/templates/planTemplate.d.ts.map +1 -1
  78. package/dist/generators/plans/templates/planTemplate.js +74 -3
  79. package/dist/generators/plans/templates/planTemplate.js.map +1 -1
  80. package/dist/generators/shared/generatorUtils.d.ts +1 -1
  81. package/dist/generators/shared/generatorUtils.d.ts.map +1 -1
  82. package/dist/generators/shared/generatorUtils.js +1 -1
  83. package/dist/generators/shared/generatorUtils.js.map +1 -1
  84. package/dist/index.d.ts +2 -2
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +46 -1000
  87. package/dist/index.js.map +1 -1
  88. package/dist/prompts/defaults.d.ts +2 -2
  89. package/dist/prompts/defaults.d.ts.map +1 -1
  90. package/dist/prompts/defaults.js +11 -11
  91. package/dist/services/baseLLMClient.d.ts +3 -3
  92. package/dist/services/baseLLMClient.d.ts.map +1 -1
  93. package/dist/services/baseLLMClient.js +44 -5
  94. package/dist/services/baseLLMClient.js.map +1 -1
  95. package/dist/services/fill/fillService.d.ts +0 -4
  96. package/dist/services/fill/fillService.d.ts.map +1 -1
  97. package/dist/services/fill/fillService.js +6 -54
  98. package/dist/services/fill/fillService.js.map +1 -1
  99. package/dist/services/init/initService.d.ts +2 -2
  100. package/dist/services/init/initService.d.ts.map +1 -1
  101. package/dist/services/init/initService.js +45 -15
  102. package/dist/services/init/initService.js.map +1 -1
  103. package/dist/services/llmClientFactory.d.ts +2 -8
  104. package/dist/services/llmClientFactory.d.ts.map +1 -1
  105. package/dist/services/llmClientFactory.js +10 -96
  106. package/dist/services/llmClientFactory.js.map +1 -1
  107. package/dist/services/openRouterClient.d.ts +0 -3
  108. package/dist/services/openRouterClient.d.ts.map +1 -1
  109. package/dist/services/openRouterClient.js +2 -49
  110. package/dist/services/openRouterClient.js.map +1 -1
  111. package/dist/services/plan/planService.d.ts +2 -4
  112. package/dist/services/plan/planService.d.ts.map +1 -1
  113. package/dist/services/plan/planService.js +3 -12
  114. package/dist/services/plan/planService.js.map +1 -1
  115. package/dist/services/shared/llmConfig.d.ts.map +1 -1
  116. package/dist/services/shared/llmConfig.js +11 -53
  117. package/dist/services/shared/llmConfig.js.map +1 -1
  118. package/dist/types.d.ts +7 -2
  119. package/dist/types.d.ts.map +1 -1
  120. package/dist/utils/fileMapper.d.ts +1 -1
  121. package/dist/utils/fileMapper.d.ts.map +1 -1
  122. package/dist/utils/fileMapper.js +40 -19
  123. package/dist/utils/fileMapper.js.map +1 -1
  124. package/dist/utils/i18n.d.ts +11 -32
  125. package/dist/utils/i18n.d.ts.map +1 -1
  126. package/dist/utils/i18n.js +22 -64
  127. package/dist/utils/i18n.js.map +1 -1
  128. package/package.json +9 -12
  129. package/prompts/update_plan_prompt.md +4 -5
  130. package/prompts/update_scaffold_prompt.md +7 -8
  131. package/dist/generators/agents/contextUtils.d.ts +0 -8
  132. package/dist/generators/agents/contextUtils.d.ts.map +0 -1
  133. package/dist/generators/agents/contextUtils.js +0 -15
  134. package/dist/generators/agents/contextUtils.js.map +0 -1
  135. package/dist/generators/agents/promptFormatter.d.ts +0 -9
  136. package/dist/generators/agents/promptFormatter.d.ts.map +0 -1
  137. package/dist/generators/agents/promptFormatter.js +0 -84
  138. package/dist/generators/agents/promptFormatter.js.map +0 -1
  139. package/dist/generators/analyzers/codebaseAnalyzer.d.ts +0 -45
  140. package/dist/generators/analyzers/codebaseAnalyzer.d.ts.map +0 -1
  141. package/dist/generators/analyzers/codebaseAnalyzer.js +0 -293
  142. package/dist/generators/analyzers/codebaseAnalyzer.js.map +0 -1
  143. package/dist/generators/analyzers/index.d.ts +0 -3
  144. package/dist/generators/analyzers/index.d.ts.map +0 -1
  145. package/dist/generators/analyzers/index.js +0 -6
  146. package/dist/generators/analyzers/index.js.map +0 -1
  147. package/dist/generators/documentation/documentationTemplates.d.ts +0 -21
  148. package/dist/generators/documentation/documentationTemplates.d.ts.map +0 -1
  149. package/dist/generators/documentation/documentationTemplates.js +0 -359
  150. package/dist/generators/documentation/documentationTemplates.js.map +0 -1
  151. package/dist/generators/documentation/documentationTypes.d.ts +0 -11
  152. package/dist/generators/documentation/documentationTypes.d.ts.map +0 -1
  153. package/dist/generators/documentation/documentationTypes.js +0 -22
  154. package/dist/generators/documentation/documentationTypes.js.map +0 -1
  155. package/dist/generators/documentation/documentationUtils.d.ts +0 -7
  156. package/dist/generators/documentation/documentationUtils.d.ts.map +0 -1
  157. package/dist/generators/documentation/documentationUtils.js +0 -28
  158. package/dist/generators/documentation/documentationUtils.js.map +0 -1
  159. package/dist/generators/documentation/incrementalDocumentationGenerator.d.ts +0 -33
  160. package/dist/generators/documentation/incrementalDocumentationGenerator.d.ts.map +0 -1
  161. package/dist/generators/documentation/incrementalDocumentationGenerator.js +0 -400
  162. package/dist/generators/documentation/incrementalDocumentationGenerator.js.map +0 -1
  163. package/dist/generators/documentation/templates.d.ts +0 -31
  164. package/dist/generators/documentation/templates.d.ts.map +0 -1
  165. package/dist/generators/documentation/templates.js +0 -566
  166. package/dist/generators/documentation/templates.js.map +0 -1
  167. package/dist/generators/guidelines/agentIntegration.d.ts +0 -43
  168. package/dist/generators/guidelines/agentIntegration.d.ts.map +0 -1
  169. package/dist/generators/guidelines/agentIntegration.js +0 -157
  170. package/dist/generators/guidelines/agentIntegration.js.map +0 -1
  171. package/dist/generators/guidelines/guidelineTypes.d.ts +0 -40
  172. package/dist/generators/guidelines/guidelineTypes.d.ts.map +0 -1
  173. package/dist/generators/guidelines/guidelineTypes.js +0 -144
  174. package/dist/generators/guidelines/guidelineTypes.js.map +0 -1
  175. package/dist/generators/guidelines/guidelinesAnalyzer.d.ts +0 -30
  176. package/dist/generators/guidelines/guidelinesAnalyzer.d.ts.map +0 -1
  177. package/dist/generators/guidelines/guidelinesAnalyzer.js +0 -263
  178. package/dist/generators/guidelines/guidelinesAnalyzer.js.map +0 -1
  179. package/dist/generators/guidelines/guidelinesGenerator.d.ts +0 -30
  180. package/dist/generators/guidelines/guidelinesGenerator.d.ts.map +0 -1
  181. package/dist/generators/guidelines/guidelinesGenerator.js +0 -249
  182. package/dist/generators/guidelines/guidelinesGenerator.js.map +0 -1
  183. package/dist/generators/guidelines/guidelinesTemplates.d.ts +0 -23
  184. package/dist/generators/guidelines/guidelinesTemplates.d.ts.map +0 -1
  185. package/dist/generators/guidelines/guidelinesTemplates.js +0 -304
  186. package/dist/generators/guidelines/guidelinesTemplates.js.map +0 -1
  187. package/dist/generators/guidelines/index.d.ts +0 -6
  188. package/dist/generators/guidelines/index.d.ts.map +0 -1
  189. package/dist/generators/guidelines/index.js +0 -16
  190. package/dist/generators/guidelines/index.js.map +0 -1
  191. package/dist/generators/moduleGrouper.d.ts +0 -14
  192. package/dist/generators/moduleGrouper.d.ts.map +0 -1
  193. package/dist/generators/moduleGrouper.js +0 -82
  194. package/dist/generators/moduleGrouper.js.map +0 -1
  195. package/dist/generators/projectAnalyzer.d.ts +0 -14
  196. package/dist/generators/projectAnalyzer.d.ts.map +0 -1
  197. package/dist/generators/projectAnalyzer.js +0 -217
  198. package/dist/generators/projectAnalyzer.js.map +0 -1
  199. package/dist/services/changeAnalyzer.d.ts +0 -44
  200. package/dist/services/changeAnalyzer.d.ts.map +0 -1
  201. package/dist/services/changeAnalyzer.js +0 -344
  202. package/dist/services/changeAnalyzer.js.map +0 -1
  203. package/dist/utils/interactiveMode.d.ts +0 -21
  204. package/dist/utils/interactiveMode.d.ts.map +0 -1
  205. package/dist/utils/interactiveMode.js +0 -737
  206. package/dist/utils/interactiveMode.js.map +0 -1
  207. package/dist/utils/tokenEstimator.d.ts +0 -28
  208. package/dist/utils/tokenEstimator.d.ts.map +0 -1
  209. package/dist/utils/tokenEstimator.js +0 -134
  210. package/dist/utils/tokenEstimator.js.map +0 -1
@@ -1,737 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.InteractiveMode = void 0;
40
- const inquirer_1 = __importDefault(require("inquirer"));
41
- const path = __importStar(require("path"));
42
- const fs = __importStar(require("fs-extra"));
43
- const chalk_1 = __importDefault(require("chalk"));
44
- const cliUI_1 = require("./cliUI");
45
- const llmClientFactory_1 = require("../services/llmClientFactory");
46
- class InteractiveMode {
47
- constructor() {
48
- this.ui = new cliUI_1.CLIInterface();
49
- }
50
- async start() {
51
- this.ui.displayWelcome('0.1.0');
52
- console.log(chalk_1.default.cyan('\nšŸŽÆ Interactive Mode\n'));
53
- console.log(chalk_1.default.gray('Let me help you get started with AI Context Generator!\n'));
54
- const answers = await this.promptMainCommand();
55
- if (answers.command === 'exit') {
56
- console.log(chalk_1.default.yellow('\nšŸ‘‹ Goodbye!\n'));
57
- process.exit(0);
58
- }
59
- // Execute the selected command
60
- await this.executeCommand(answers);
61
- }
62
- async promptMainCommand() {
63
- const { command } = await inquirer_1.default.prompt({
64
- type: 'list',
65
- name: 'command',
66
- message: 'What would you like to generate?',
67
- choices: [
68
- {
69
- name: 'šŸš€ Generate everything (docs + agents + guidelines)',
70
- value: 'generate-all',
71
- short: 'Generate All'
72
- },
73
- {
74
- name: 'šŸ“š Generate documentation only',
75
- value: 'generate-docs',
76
- short: 'Generate Docs'
77
- },
78
- {
79
- name: 'šŸ¤– Generate AI agent prompts only',
80
- value: 'generate-agents',
81
- short: 'Generate Agents'
82
- },
83
- {
84
- name: 'šŸ“‹ Generate development guidelines only',
85
- value: 'generate-guidelines',
86
- short: 'Generate Guidelines'
87
- },
88
- new inquirer_1.default.Separator(),
89
- {
90
- name: 'šŸ” Analyze repository structure and estimate costs',
91
- value: 'analyze',
92
- short: 'Analyze'
93
- },
94
- {
95
- name: 'šŸ”„ Update existing documentation with recent changes',
96
- value: 'update',
97
- short: 'Update'
98
- },
99
- {
100
- name: 'šŸ‘ļø Preview what changes would be made',
101
- value: 'preview',
102
- short: 'Preview'
103
- },
104
- new inquirer_1.default.Separator(),
105
- {
106
- name: 'āŒ Exit',
107
- value: 'exit',
108
- short: 'Exit'
109
- }
110
- ]
111
- });
112
- if (command === 'exit') {
113
- return { command };
114
- }
115
- // Get common parameters
116
- const commonAnswers = await this.promptCommonParameters();
117
- // Get command-specific parameters
118
- let specificAnswers = {};
119
- switch (command) {
120
- case 'generate-all':
121
- specificAnswers = await this.promptGenerateParameters(true);
122
- break;
123
- case 'generate-docs':
124
- specificAnswers = await this.promptGenerateParameters(false);
125
- break;
126
- case 'generate-agents':
127
- specificAnswers = await this.promptGenerateParameters(false);
128
- break;
129
- case 'generate-guidelines':
130
- specificAnswers = await this.promptGuidelinesParameters();
131
- break;
132
- case 'analyze':
133
- specificAnswers = await this.promptAnalyzeParameters();
134
- break;
135
- case 'update':
136
- case 'preview':
137
- specificAnswers = await this.promptPreviewParameters();
138
- break;
139
- }
140
- return {
141
- command,
142
- ...commonAnswers,
143
- ...specificAnswers
144
- };
145
- }
146
- async promptCommonParameters() {
147
- const answers = await inquirer_1.default.prompt([
148
- {
149
- type: 'input',
150
- name: 'repoPath',
151
- message: 'Enter the path to your repository:',
152
- default: '.',
153
- validate: async (input) => {
154
- const resolvedPath = path.resolve(input);
155
- if (await fs.pathExists(resolvedPath)) {
156
- return true;
157
- }
158
- return 'Path does not exist. Please enter a valid path.';
159
- }
160
- },
161
- {
162
- type: 'input',
163
- name: 'outputDir',
164
- message: 'Where should the output be saved?',
165
- default: './.context'
166
- }
167
- ]);
168
- return answers;
169
- }
170
- async promptGuidelinesParameters() {
171
- // Ask for LLM configuration first
172
- const llmAnswers = await this.promptLLMConfiguration();
173
- // Ask for patterns
174
- const patternAnswers = await this.promptPatterns();
175
- // Ask for guidelines configuration
176
- const guidelineAnswers = await this.promptGuidelinesConfiguration();
177
- return {
178
- ...llmAnswers,
179
- ...patternAnswers,
180
- ...guidelineAnswers
181
- };
182
- }
183
- async promptAnalyzeParameters() {
184
- // Ask for custom pricing
185
- const pricingAnswers = await this.promptCustomPricing();
186
- // Ask for patterns
187
- const patternAnswers = await this.promptPatterns();
188
- return {
189
- ...pricingAnswers,
190
- ...patternAnswers
191
- };
192
- }
193
- async promptPreviewParameters() {
194
- // Ask for custom pricing
195
- const pricingAnswers = await this.promptCustomPricing();
196
- // Ask for patterns
197
- const patternAnswers = await this.promptPatterns();
198
- return {
199
- ...pricingAnswers,
200
- ...patternAnswers
201
- };
202
- }
203
- async promptCustomPricing() {
204
- const { usePricing } = await inquirer_1.default.prompt([
205
- {
206
- type: 'confirm',
207
- name: 'usePricing',
208
- message: 'Do you want to provide pricing for cost estimation?',
209
- default: false
210
- }
211
- ]);
212
- if (!usePricing) {
213
- return { usePricing: false };
214
- }
215
- console.log(chalk_1.default.gray('\nšŸ’° Pricing Configuration'));
216
- console.log(chalk_1.default.gray('Enter your token pricing (per 1M tokens):\n'));
217
- const pricingAnswers = await inquirer_1.default.prompt([
218
- {
219
- type: 'input',
220
- name: 'inputPrice',
221
- message: 'Input token price per 1M tokens (e.g., 2.50 for $2.50):',
222
- validate: (input) => {
223
- const num = parseFloat(input);
224
- return !isNaN(num) && num >= 0 || 'Please enter a valid positive number';
225
- },
226
- filter: (input) => parseFloat(input)
227
- },
228
- {
229
- type: 'input',
230
- name: 'outputPrice',
231
- message: 'Output token price per 1M tokens (e.g., 10.00 for $10.00):',
232
- validate: (input) => {
233
- const num = parseFloat(input);
234
- return !isNaN(num) && num >= 0 || 'Please enter a valid positive number';
235
- },
236
- filter: (input) => parseFloat(input)
237
- }
238
- ]);
239
- return {
240
- usePricing: true,
241
- ...pricingAnswers
242
- };
243
- }
244
- async promptGenerateParameters(includeGuidelines) {
245
- // Ask for LLM configuration
246
- const llmAnswers = await this.promptLLMConfiguration();
247
- // Ask for patterns
248
- const patternAnswers = await this.promptPatterns();
249
- let guidelineAnswers = {};
250
- if (includeGuidelines) {
251
- // For generate-all, ask if they want to include guidelines configuration
252
- const { configureGuidelines } = await inquirer_1.default.prompt([
253
- {
254
- type: 'confirm',
255
- name: 'configureGuidelines',
256
- message: 'Do you want to configure guidelines generation options?',
257
- default: false
258
- }
259
- ]);
260
- if (configureGuidelines) {
261
- guidelineAnswers = await this.promptGuidelinesConfiguration();
262
- }
263
- }
264
- return {
265
- ...llmAnswers,
266
- ...patternAnswers,
267
- ...guidelineAnswers
268
- };
269
- }
270
- async promptGuidelinesConfiguration() {
271
- // Ask for specific categories or comprehensive guidelines
272
- const { guidelineScope } = await inquirer_1.default.prompt([
273
- {
274
- type: 'list',
275
- name: 'guidelineScope',
276
- message: 'What type of guidelines would you like to generate?',
277
- choices: [
278
- {
279
- name: 'šŸŽÆ Comprehensive guidelines (all categories)',
280
- value: 'comprehensive',
281
- short: 'Comprehensive'
282
- },
283
- {
284
- name: 'šŸ”§ Specific categories only',
285
- value: 'specific',
286
- short: 'Specific'
287
- }
288
- ],
289
- default: 'comprehensive'
290
- }
291
- ]);
292
- let guidelineCategories = [];
293
- if (guidelineScope === 'specific') {
294
- const { selectedCategories } = await inquirer_1.default.prompt({
295
- type: 'checkbox',
296
- name: 'selectedCategories',
297
- message: 'Select the guideline categories to generate:',
298
- choices: [
299
- { name: '🧪 Testing guidelines', value: 'testing' },
300
- { name: 'šŸŽØ Frontend guidelines', value: 'frontend' },
301
- { name: 'āš™ļø Backend guidelines', value: 'backend' },
302
- { name: 'šŸ—„ļø Database guidelines', value: 'database' },
303
- { name: 'šŸ”’ Security guidelines', value: 'security' },
304
- { name: '⚔ Performance guidelines', value: 'performance' },
305
- { name: '✨ Code style guidelines', value: 'code-style' },
306
- { name: '🌲 Git workflow guidelines', value: 'git-workflow' },
307
- { name: 'šŸš€ Deployment guidelines', value: 'deployment' },
308
- { name: 'šŸ“Š Monitoring guidelines', value: 'monitoring' },
309
- { name: 'šŸ“š Documentation guidelines', value: 'documentation' },
310
- { name: 'šŸ—ļø Architecture guidelines', value: 'architecture' }
311
- ],
312
- validate: (answer) => {
313
- if (!answer || answer.length === 0) {
314
- return 'Please select at least one category.';
315
- }
316
- return true;
317
- }
318
- });
319
- guidelineCategories = selectedCategories;
320
- }
321
- // Ask for project configuration
322
- const projectConfig = await inquirer_1.default.prompt([
323
- {
324
- type: 'list',
325
- name: 'projectType',
326
- message: 'What type of project is this?',
327
- choices: [
328
- { name: 'šŸ¤– Auto-detect based on codebase', value: 'auto' },
329
- { name: 'šŸŽØ Frontend application', value: 'frontend' },
330
- { name: 'āš™ļø Backend service', value: 'backend' },
331
- { name: '🌐 Full-stack application', value: 'fullstack' },
332
- { name: 'šŸ“± Mobile application', value: 'mobile' },
333
- { name: 'šŸ–„ļø Desktop application', value: 'desktop' },
334
- { name: 'šŸ“¦ Library/package', value: 'library' }
335
- ],
336
- default: 'auto'
337
- },
338
- {
339
- type: 'list',
340
- name: 'complexity',
341
- message: 'How complex is your project?',
342
- choices: [
343
- { name: 'šŸ¤– Auto-detect based on codebase', value: 'auto' },
344
- { name: '🟢 Simple (few components, straightforward logic)', value: 'simple' },
345
- { name: '🟔 Moderate (multiple modules, some complexity)', value: 'moderate' },
346
- { name: 'šŸ”“ Complex (many modules, intricate architecture)', value: 'complex' }
347
- ],
348
- default: 'auto'
349
- },
350
- {
351
- type: 'list',
352
- name: 'teamSize',
353
- message: 'What is your team size?',
354
- choices: [
355
- { name: 'šŸ¤– Auto-detect/assume medium team', value: 'auto' },
356
- { name: 'šŸ‘¤ Small team (1-3 people)', value: 'small' },
357
- { name: 'šŸ‘„ Medium team (4-10 people)', value: 'medium' },
358
- { name: 'šŸ‘Øā€šŸ‘©ā€šŸ‘§ā€šŸ‘¦ Large team (10+ people)', value: 'large' }
359
- ],
360
- default: 'auto'
361
- }
362
- ]);
363
- // Ask for additional features
364
- const features = await inquirer_1.default.prompt([
365
- {
366
- type: 'confirm',
367
- name: 'includeExamples',
368
- message: 'Include code examples in guidelines?',
369
- default: true
370
- },
371
- {
372
- type: 'confirm',
373
- name: 'includeTools',
374
- message: 'Include tool recommendations in guidelines?',
375
- default: true
376
- }
377
- ]);
378
- return {
379
- guidelineCategories,
380
- ...projectConfig,
381
- ...features
382
- };
383
- }
384
- async promptLLMConfiguration() {
385
- // First check if any API keys are already set in environment
386
- const availableProviders = this.getAvailableProviders();
387
- let provider;
388
- let model;
389
- let apiKey;
390
- if (availableProviders.length > 0) {
391
- const { useExisting } = await inquirer_1.default.prompt([
392
- {
393
- type: 'confirm',
394
- name: 'useExisting',
395
- message: `Found API keys for: ${availableProviders.join(', ')}. Use existing configuration?`,
396
- default: true
397
- }
398
- ]);
399
- if (useExisting) {
400
- provider = availableProviders[0];
401
- model = this.getDefaultModelForProvider(provider);
402
- return { provider, model };
403
- }
404
- }
405
- // Ask for provider
406
- const { selectedProvider } = await inquirer_1.default.prompt([
407
- {
408
- type: 'list',
409
- name: 'selectedProvider',
410
- message: 'Choose your LLM provider:',
411
- choices: [
412
- { name: '🌐 OpenRouter (access to multiple models)', value: 'openrouter' },
413
- { name: 'šŸ¤– OpenAI (GPT models)', value: 'openai' },
414
- { name: '🧠 Anthropic (Claude models)', value: 'anthropic' },
415
- { name: 'šŸ”· Google Gemini', value: 'gemini' },
416
- { name: 'šŸš€ Grok (xAI)', value: 'grok' }
417
- ]
418
- }
419
- ]);
420
- provider = selectedProvider;
421
- // Ask for model based on provider
422
- const modelChoices = this.getModelsForProvider(provider);
423
- const { selectedModel } = await inquirer_1.default.prompt([
424
- {
425
- type: 'list',
426
- name: 'selectedModel',
427
- message: 'Choose a model:',
428
- choices: modelChoices,
429
- default: this.getDefaultModelForProvider(provider)
430
- }
431
- ]);
432
- model = selectedModel;
433
- // Check if API key is needed
434
- const envVars = llmClientFactory_1.LLMClientFactory.getEnvironmentVariables()[provider];
435
- let hasApiKey = false;
436
- for (const envVar of envVars) {
437
- if (process.env[envVar]) {
438
- hasApiKey = true;
439
- break;
440
- }
441
- }
442
- if (!hasApiKey) {
443
- const { enteredApiKey } = await inquirer_1.default.prompt([
444
- {
445
- type: 'password',
446
- name: 'enteredApiKey',
447
- message: `Enter your ${provider.toUpperCase()} API key:`,
448
- mask: '*',
449
- validate: (input) => {
450
- if (input.length > 0) {
451
- return true;
452
- }
453
- return `API key is required. Get one from ${this.getProviderUrl(provider)}`;
454
- }
455
- }
456
- ]);
457
- apiKey = enteredApiKey;
458
- }
459
- return { provider, model, apiKey };
460
- }
461
- async promptPatterns() {
462
- const { hasPatterns } = await inquirer_1.default.prompt([
463
- {
464
- type: 'confirm',
465
- name: 'hasPatterns',
466
- message: 'Do you want to customize file include/exclude patterns?',
467
- default: false
468
- }
469
- ]);
470
- if (!hasPatterns) {
471
- return {};
472
- }
473
- const patterns = await inquirer_1.default.prompt([
474
- {
475
- type: 'input',
476
- name: 'includePatterns',
477
- message: 'Enter patterns to include (comma-separated, e.g., "src/**/*.ts,lib/**/*.js"):',
478
- default: ''
479
- },
480
- {
481
- type: 'input',
482
- name: 'excludePatterns',
483
- message: 'Enter additional patterns to exclude (comma-separated, e.g., "tests/**,*.test.ts"):',
484
- default: ''
485
- }
486
- ]);
487
- return patterns;
488
- }
489
- getAvailableProviders() {
490
- const providers = [];
491
- const providerMap = llmClientFactory_1.LLMClientFactory.getEnvironmentVariables();
492
- for (const [provider, envVars] of Object.entries(providerMap)) {
493
- for (const envVar of envVars) {
494
- if (process.env[envVar]) {
495
- providers.push(provider);
496
- break;
497
- }
498
- }
499
- }
500
- return providers;
501
- }
502
- getDefaultModelForProvider(provider) {
503
- const defaults = {
504
- openrouter: 'google/gemini-2.5-flash-preview-05-20',
505
- openai: 'gpt-4o-mini',
506
- anthropic: 'claude-3-haiku-20240307',
507
- gemini: 'gemini-2.5-flash-preview-05-20',
508
- grok: 'grok-beta'
509
- };
510
- return defaults[provider] || 'default';
511
- }
512
- getModelsForProvider(provider) {
513
- const models = {
514
- openrouter: [
515
- { name: 'šŸ’° Google Gemini 2.5 Flash (recommended, fast & cheap)', value: 'google/gemini-2.5-flash-preview-05-20' },
516
- { name: 'šŸš€ GPT-4o Mini (fast & capable)', value: 'openai/gpt-4o-mini' },
517
- { name: '⚔ Claude 3 Haiku (very fast)', value: 'anthropic/claude-3-haiku' },
518
- { name: '🧠 Claude 3.5 Sonnet (powerful)', value: 'anthropic/claude-3.5-sonnet' },
519
- { name: 'šŸ’Ž GPT-4o (most capable)', value: 'openai/gpt-4o' }
520
- ],
521
- openai: [
522
- { name: 'šŸ’° GPT-4o Mini (recommended, fast & cheap)', value: 'gpt-4o-mini' },
523
- { name: 'šŸš€ GPT-4o (most capable)', value: 'gpt-4o' },
524
- { name: 'šŸ“š GPT-4 Turbo', value: 'gpt-4-turbo' }
525
- ],
526
- anthropic: [
527
- { name: '⚔ Claude 3 Haiku (recommended, fast & cheap)', value: 'claude-3-haiku-20240307' },
528
- { name: '🧠 Claude 3.5 Sonnet (powerful)', value: 'claude-3-5-sonnet-20241022' },
529
- { name: 'šŸ’Ž Claude 3 Opus (most capable)', value: 'claude-3-opus-20240229' }
530
- ],
531
- gemini: [
532
- { name: '⚔ Gemini 2.5 Flash (recommended)', value: 'gemini-2.5-flash-preview-05-20' },
533
- { name: '🧠 Gemini 1.5 Pro', value: 'gemini-1.5-pro' }
534
- ],
535
- grok: [
536
- { name: 'šŸš€ Grok Beta', value: 'grok-beta' }
537
- ]
538
- };
539
- return models[provider] || [];
540
- }
541
- getProviderUrl(provider) {
542
- const urls = {
543
- openrouter: 'https://openrouter.ai/keys',
544
- openai: 'https://platform.openai.com/api-keys',
545
- anthropic: 'https://console.anthropic.com/account/keys',
546
- gemini: 'https://makersuite.google.com/app/apikey',
547
- grok: 'https://console.x.ai/'
548
- };
549
- return urls[provider] || 'your provider\'s website';
550
- }
551
- async executeCommand(answers) {
552
- const args = [];
553
- // Build command arguments - map interactive commands to CLI commands
554
- let cliCommand;
555
- switch (answers.command) {
556
- case 'generate-all':
557
- cliCommand = 'init';
558
- break;
559
- case 'generate-docs':
560
- cliCommand = 'init';
561
- break;
562
- case 'generate-agents':
563
- cliCommand = 'init';
564
- break;
565
- case 'generate-guidelines':
566
- cliCommand = 'guidelines';
567
- break;
568
- default:
569
- cliCommand = answers.command;
570
- }
571
- args.push(cliCommand);
572
- if (answers.repoPath) {
573
- args.push(answers.repoPath);
574
- }
575
- // Add init type for generate commands
576
- if (answers.command === 'generate-docs') {
577
- args.push('docs');
578
- }
579
- else if (answers.command === 'generate-agents') {
580
- args.push('agents');
581
- }
582
- else if (answers.command === 'generate-all') {
583
- args.push('both');
584
- }
585
- // Add command-specific arguments
586
- if (answers.command === 'generate-guidelines' && answers.guidelineCategories && answers.guidelineCategories.length > 0) {
587
- args.push(...answers.guidelineCategories);
588
- }
589
- // Add options
590
- if (answers.outputDir) {
591
- args.push('--output', answers.outputDir);
592
- }
593
- if (answers.provider) {
594
- args.push('--provider', answers.provider);
595
- }
596
- if (answers.model) {
597
- args.push('--model', answers.model);
598
- }
599
- if (answers.apiKey) {
600
- args.push('--api-key', answers.apiKey);
601
- }
602
- if (answers.includePatterns) {
603
- const patterns = answers.includePatterns.split(',').map(p => p.trim()).filter(p => p);
604
- if (patterns.length > 0) {
605
- args.push('--include', ...patterns);
606
- }
607
- }
608
- if (answers.excludePatterns) {
609
- const patterns = answers.excludePatterns.split(',').map(p => p.trim()).filter(p => p);
610
- if (patterns.length > 0) {
611
- args.push('--exclude', ...patterns);
612
- }
613
- }
614
- // Add guidelines-specific options
615
- if (answers.command === 'generate-guidelines') {
616
- if (answers.projectType && answers.projectType !== 'auto') {
617
- args.push('--project-type', answers.projectType);
618
- }
619
- if (answers.complexity && answers.complexity !== 'auto') {
620
- args.push('--complexity', answers.complexity);
621
- }
622
- if (answers.teamSize && answers.teamSize !== 'auto') {
623
- args.push('--team-size', answers.teamSize);
624
- }
625
- if (answers.includeExamples) {
626
- args.push('--include-examples');
627
- }
628
- if (answers.includeTools) {
629
- args.push('--include-tools');
630
- }
631
- }
632
- // Add pricing options for analyze and preview commands
633
- if ((answers.command === 'analyze' || answers.command === 'preview') && answers.usePricing) {
634
- if (answers.inputPrice !== undefined) {
635
- args.push('--input-price', answers.inputPrice.toString());
636
- }
637
- if (answers.outputPrice !== undefined) {
638
- args.push('--output-price', answers.outputPrice.toString());
639
- }
640
- }
641
- // Show the command that will be executed
642
- console.log(chalk_1.default.gray('\nšŸ“‹ Executing command:'));
643
- console.log(chalk_1.default.cyan(`ai-context ${args.join(' ')}\n`));
644
- // Import and execute the command
645
- const { runGenerate, runAnalyze, runUpdate, runPreview, runGuidelines } = await Promise.resolve().then(() => __importStar(require('../index')));
646
- try {
647
- switch (answers.command) {
648
- case 'generate-all':
649
- await runGenerate(answers.repoPath, {
650
- output: answers.outputDir,
651
- provider: answers.provider,
652
- model: answers.model,
653
- apiKey: answers.apiKey,
654
- include: answers.includePatterns?.split(',').map(p => p.trim()).filter(p => p),
655
- exclude: answers.excludePatterns?.split(',').map(p => p.trim()).filter(p => p),
656
- verbose: true // Enable verbose for interactive mode
657
- });
658
- break;
659
- case 'generate-docs':
660
- await runGenerate(answers.repoPath, {
661
- output: answers.outputDir,
662
- provider: answers.provider,
663
- model: answers.model,
664
- apiKey: answers.apiKey,
665
- include: answers.includePatterns?.split(',').map(p => p.trim()).filter(p => p),
666
- exclude: answers.excludePatterns?.split(',').map(p => p.trim()).filter(p => p),
667
- docsOnly: true,
668
- verbose: true // Enable verbose for interactive mode
669
- });
670
- break;
671
- case 'generate-agents':
672
- await runGenerate(answers.repoPath, {
673
- output: answers.outputDir,
674
- provider: answers.provider,
675
- model: answers.model,
676
- apiKey: answers.apiKey,
677
- include: answers.includePatterns?.split(',').map(p => p.trim()).filter(p => p),
678
- exclude: answers.excludePatterns?.split(',').map(p => p.trim()).filter(p => p),
679
- agentsOnly: true,
680
- verbose: true // Enable verbose for interactive mode
681
- });
682
- break;
683
- case 'generate-guidelines':
684
- await runGuidelines(answers.repoPath, answers.guidelineCategories || [], {
685
- output: answers.outputDir,
686
- provider: answers.provider,
687
- model: answers.model,
688
- apiKey: answers.apiKey,
689
- projectType: answers.projectType !== 'auto' ? answers.projectType : undefined,
690
- complexity: answers.complexity !== 'auto' ? answers.complexity : undefined,
691
- teamSize: answers.teamSize !== 'auto' ? answers.teamSize : undefined,
692
- includeExamples: answers.includeExamples,
693
- includeTools: answers.includeTools,
694
- include: answers.includePatterns?.split(',').map(p => p.trim()).filter(p => p),
695
- exclude: answers.excludePatterns?.split(',').map(p => p.trim()).filter(p => p),
696
- verbose: true // Enable verbose for interactive mode
697
- });
698
- break;
699
- case 'analyze':
700
- await runAnalyze(answers.repoPath, {
701
- include: answers.includePatterns?.split(',').map(p => p.trim()).filter(p => p),
702
- exclude: answers.excludePatterns?.split(',').map(p => p.trim()).filter(p => p),
703
- inputPrice: answers.inputPrice,
704
- outputPrice: answers.outputPrice,
705
- verbose: true // Enable verbose for interactive mode
706
- });
707
- break;
708
- case 'update':
709
- await runUpdate(answers.repoPath, {
710
- output: answers.outputDir,
711
- provider: answers.provider,
712
- model: answers.model,
713
- apiKey: answers.apiKey,
714
- include: answers.includePatterns?.split(',').map(p => p.trim()).filter(p => p),
715
- exclude: answers.excludePatterns?.split(',').map(p => p.trim()).filter(p => p)
716
- });
717
- break;
718
- case 'preview':
719
- await runPreview(answers.repoPath, {
720
- output: answers.outputDir,
721
- include: answers.includePatterns?.split(',').map(p => p.trim()).filter(p => p),
722
- exclude: answers.excludePatterns?.split(',').map(p => p.trim()).filter(p => p),
723
- inputPrice: answers.inputPrice,
724
- outputPrice: answers.outputPrice,
725
- verbose: true // Enable verbose for interactive mode
726
- });
727
- break;
728
- }
729
- }
730
- catch (error) {
731
- this.ui.displayError(`Failed to execute ${answers.command}`, error);
732
- process.exit(1);
733
- }
734
- }
735
- }
736
- exports.InteractiveMode = InteractiveMode;
737
- //# sourceMappingURL=interactiveMode.js.map