@codemieai/code 0.0.14 → 0.0.16

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 (370) hide show
  1. package/README.md +32 -15
  2. package/dist/agents/codemie-code/agent.d.ts.map +1 -1
  3. package/dist/agents/codemie-code/agent.js +6 -6
  4. package/dist/agents/codemie-code/agent.js.map +1 -1
  5. package/dist/agents/codemie-code/config.d.ts.map +1 -1
  6. package/dist/agents/codemie-code/config.js +14 -5
  7. package/dist/agents/codemie-code/config.js.map +1 -1
  8. package/dist/agents/codemie-code/filters.js +12 -12
  9. package/dist/agents/codemie-code/filters.js.map +1 -1
  10. package/dist/agents/codemie-code/index.d.ts.map +1 -1
  11. package/dist/agents/codemie-code/index.js +3 -1
  12. package/dist/agents/codemie-code/index.js.map +1 -1
  13. package/dist/agents/codemie-code/storage/todoStorage.js +1 -1
  14. package/dist/agents/codemie-code/storage/todoStorage.js.map +1 -1
  15. package/dist/agents/codemie-code/ui.js +1 -1
  16. package/dist/agents/codemie-code/ui.js.map +1 -1
  17. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  18. package/dist/agents/core/AgentCLI.js +5 -4
  19. package/dist/agents/core/AgentCLI.js.map +1 -1
  20. package/dist/agents/core/BaseAgentAdapter.d.ts +1 -5
  21. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  22. package/dist/agents/core/BaseAgentAdapter.js +5 -26
  23. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  24. package/dist/agents/core/types.d.ts +5 -0
  25. package/dist/agents/core/types.d.ts.map +1 -1
  26. package/dist/agents/plugins/claude.plugin.js +1 -1
  27. package/dist/agents/plugins/claude.plugin.js.map +1 -1
  28. package/dist/agents/plugins/codemie-code.plugin.js +2 -2
  29. package/dist/agents/plugins/codemie-code.plugin.js.map +1 -1
  30. package/dist/agents/plugins/codex.plugin.js +2 -2
  31. package/dist/agents/plugins/codex.plugin.js.map +1 -1
  32. package/dist/agents/plugins/deepagents.plugin.js +1 -1
  33. package/dist/agents/plugins/deepagents.plugin.js.map +1 -1
  34. package/dist/agents/plugins/gemini.plugin.js +1 -1
  35. package/dist/agents/plugins/gemini.plugin.js.map +1 -1
  36. package/dist/analytics/aggregation/adapters/claude.adapter.d.ts.map +1 -1
  37. package/dist/analytics/aggregation/adapters/claude.adapter.js +75 -15
  38. package/dist/analytics/aggregation/adapters/claude.adapter.js.map +1 -1
  39. package/dist/analytics/aggregation/adapters/codex.adapter.d.ts.map +1 -1
  40. package/dist/analytics/aggregation/adapters/codex.adapter.js +20 -0
  41. package/dist/analytics/aggregation/adapters/codex.adapter.js.map +1 -1
  42. package/dist/analytics/aggregation/adapters/gemini.adapter.d.ts +8 -0
  43. package/dist/analytics/aggregation/adapters/gemini.adapter.d.ts.map +1 -1
  44. package/dist/analytics/aggregation/adapters/gemini.adapter.js +46 -1
  45. package/dist/analytics/aggregation/adapters/gemini.adapter.js.map +1 -1
  46. package/dist/analytics/aggregation/core/BaseAnalyticsAdapter.d.ts +36 -0
  47. package/dist/analytics/aggregation/core/BaseAnalyticsAdapter.d.ts.map +1 -1
  48. package/dist/analytics/aggregation/core/BaseAnalyticsAdapter.js +52 -0
  49. package/dist/analytics/aggregation/core/BaseAnalyticsAdapter.js.map +1 -1
  50. package/dist/analytics/aggregation/core/adapter.interface.d.ts +11 -0
  51. package/dist/analytics/aggregation/core/adapter.interface.d.ts.map +1 -1
  52. package/dist/analytics/aggregation/core/aggregation-utils.d.ts +20 -0
  53. package/dist/analytics/aggregation/core/aggregation-utils.d.ts.map +1 -1
  54. package/dist/analytics/aggregation/core/aggregation-utils.js +43 -0
  55. package/dist/analytics/aggregation/core/aggregation-utils.js.map +1 -1
  56. package/dist/analytics/aggregation/core/file-utils.d.ts +2 -1
  57. package/dist/analytics/aggregation/core/file-utils.d.ts.map +1 -1
  58. package/dist/analytics/aggregation/core/file-utils.js +20 -85
  59. package/dist/analytics/aggregation/core/file-utils.js.map +1 -1
  60. package/dist/analytics/aggregation/core/index.d.ts +3 -0
  61. package/dist/analytics/aggregation/core/index.d.ts.map +1 -1
  62. package/dist/analytics/aggregation/core/index.js +3 -0
  63. package/dist/analytics/aggregation/core/index.js.map +1 -1
  64. package/dist/analytics/aggregation/core/user-prompt-source.d.ts +81 -0
  65. package/dist/analytics/aggregation/core/user-prompt-source.d.ts.map +1 -0
  66. package/dist/analytics/aggregation/core/user-prompt-source.js +69 -0
  67. package/dist/analytics/aggregation/core/user-prompt-source.js.map +1 -0
  68. package/dist/analytics/aggregation/core/user-prompt-sources/json.d.ts +49 -0
  69. package/dist/analytics/aggregation/core/user-prompt-sources/json.d.ts.map +1 -0
  70. package/dist/analytics/aggregation/core/user-prompt-sources/json.js +66 -0
  71. package/dist/analytics/aggregation/core/user-prompt-sources/json.js.map +1 -0
  72. package/dist/analytics/aggregation/core/user-prompt-sources/jsonl.d.ts +43 -0
  73. package/dist/analytics/aggregation/core/user-prompt-sources/jsonl.d.ts.map +1 -0
  74. package/dist/analytics/aggregation/core/user-prompt-sources/jsonl.js +56 -0
  75. package/dist/analytics/aggregation/core/user-prompt-sources/jsonl.js.map +1 -0
  76. package/dist/analytics/aggregation/types.d.ts +20 -0
  77. package/dist/analytics/aggregation/types.d.ts.map +1 -1
  78. package/dist/analytics/index.d.ts.map +1 -1
  79. package/dist/analytics/index.js +3 -11
  80. package/dist/analytics/index.js.map +1 -1
  81. package/dist/analytics/remote-submission/cursor-manager.d.ts +71 -0
  82. package/dist/analytics/remote-submission/cursor-manager.d.ts.map +1 -0
  83. package/dist/analytics/remote-submission/cursor-manager.js +204 -0
  84. package/dist/analytics/remote-submission/cursor-manager.js.map +1 -0
  85. package/dist/analytics/remote-submission/index.d.ts +12 -0
  86. package/dist/analytics/remote-submission/index.d.ts.map +1 -0
  87. package/dist/analytics/remote-submission/index.js +11 -0
  88. package/dist/analytics/remote-submission/index.js.map +1 -0
  89. package/dist/analytics/remote-submission/lock-manager.d.ts +71 -0
  90. package/dist/analytics/remote-submission/lock-manager.d.ts.map +1 -0
  91. package/dist/analytics/remote-submission/lock-manager.js +238 -0
  92. package/dist/analytics/remote-submission/lock-manager.js.map +1 -0
  93. package/dist/analytics/remote-submission/metric-transformer.d.ts +21 -0
  94. package/dist/analytics/remote-submission/metric-transformer.d.ts.map +1 -0
  95. package/dist/analytics/remote-submission/metric-transformer.js +82 -0
  96. package/dist/analytics/remote-submission/metric-transformer.js.map +1 -0
  97. package/dist/analytics/remote-submission/submitter.d.ts +79 -0
  98. package/dist/analytics/remote-submission/submitter.d.ts.map +1 -0
  99. package/dist/analytics/remote-submission/submitter.js +362 -0
  100. package/dist/analytics/remote-submission/submitter.js.map +1 -0
  101. package/dist/analytics/remote-submission/types.d.ts +123 -0
  102. package/dist/analytics/remote-submission/types.d.ts.map +1 -0
  103. package/dist/analytics/remote-submission/types.js +13 -0
  104. package/dist/analytics/remote-submission/types.js.map +1 -0
  105. package/dist/cli/commands/analytics.d.ts.map +1 -1
  106. package/dist/cli/commands/analytics.js +181 -12
  107. package/dist/cli/commands/analytics.js.map +1 -1
  108. package/dist/cli/commands/auth.d.ts.map +1 -1
  109. package/dist/cli/commands/auth.js +10 -5
  110. package/dist/cli/commands/auth.js.map +1 -1
  111. package/dist/cli/commands/doctor/checks/AIConfigCheck.d.ts.map +1 -1
  112. package/dist/cli/commands/doctor/checks/AIConfigCheck.js +12 -5
  113. package/dist/cli/commands/doctor/checks/AIConfigCheck.js.map +1 -1
  114. package/dist/cli/commands/doctor/formatter.d.ts +1 -1
  115. package/dist/cli/commands/doctor/formatter.d.ts.map +1 -1
  116. package/dist/cli/commands/doctor/formatter.js +1 -6
  117. package/dist/cli/commands/doctor/formatter.js.map +1 -1
  118. package/dist/cli/commands/doctor/index.d.ts.map +1 -1
  119. package/dist/cli/commands/doctor/index.js +36 -9
  120. package/dist/cli/commands/doctor/index.js.map +1 -1
  121. package/dist/cli/commands/doctor/type-adapters.d.ts +18 -0
  122. package/dist/cli/commands/doctor/type-adapters.d.ts.map +1 -0
  123. package/dist/cli/commands/doctor/type-adapters.js +75 -0
  124. package/dist/cli/commands/doctor/type-adapters.js.map +1 -0
  125. package/dist/cli/commands/install.d.ts.map +1 -1
  126. package/dist/cli/commands/install.js +1 -6
  127. package/dist/cli/commands/install.js.map +1 -1
  128. package/dist/cli/commands/list.d.ts.map +1 -1
  129. package/dist/cli/commands/list.js +0 -5
  130. package/dist/cli/commands/list.js.map +1 -1
  131. package/dist/cli/commands/profile.d.ts.map +1 -1
  132. package/dist/cli/commands/profile.js +109 -63
  133. package/dist/cli/commands/profile.js.map +1 -1
  134. package/dist/cli/commands/setup.d.ts.map +1 -1
  135. package/dist/cli/commands/setup.js +169 -660
  136. package/dist/cli/commands/setup.js.map +1 -1
  137. package/dist/cli/commands/workflow.js +1 -1
  138. package/dist/cli/commands/workflow.js.map +1 -1
  139. package/dist/cli/index.d.ts +1 -1
  140. package/dist/cli/index.d.ts.map +1 -1
  141. package/dist/cli/index.js +4 -5
  142. package/dist/cli/index.js.map +1 -1
  143. package/dist/providers/core/base/BaseHealthCheck.d.ts +57 -0
  144. package/dist/providers/core/base/BaseHealthCheck.d.ts.map +1 -0
  145. package/dist/providers/core/base/BaseHealthCheck.js +121 -0
  146. package/dist/providers/core/base/BaseHealthCheck.js.map +1 -0
  147. package/dist/providers/core/base/BaseModelProxy.d.ts +45 -0
  148. package/dist/providers/core/base/BaseModelProxy.d.ts.map +1 -0
  149. package/dist/providers/core/base/BaseModelProxy.js +43 -0
  150. package/dist/providers/core/base/BaseModelProxy.js.map +1 -0
  151. package/dist/providers/core/base/http-client.d.ts +57 -0
  152. package/dist/providers/core/base/http-client.d.ts.map +1 -0
  153. package/dist/providers/core/base/http-client.js +240 -0
  154. package/dist/providers/core/base/http-client.js.map +1 -0
  155. package/dist/providers/core/decorators.d.ts +13 -0
  156. package/dist/providers/core/decorators.d.ts.map +1 -0
  157. package/dist/providers/core/decorators.js +15 -0
  158. package/dist/providers/core/decorators.js.map +1 -0
  159. package/dist/providers/core/index.d.ts +13 -0
  160. package/dist/providers/core/index.d.ts.map +1 -0
  161. package/dist/providers/core/index.js +14 -0
  162. package/dist/providers/core/index.js.map +1 -0
  163. package/dist/providers/core/registry.d.ts +66 -0
  164. package/dist/providers/core/registry.d.ts.map +1 -0
  165. package/dist/providers/core/registry.js +105 -0
  166. package/dist/providers/core/registry.js.map +1 -0
  167. package/dist/providers/core/types.d.ts +285 -0
  168. package/dist/providers/core/types.d.ts.map +1 -0
  169. package/dist/providers/core/types.js +7 -0
  170. package/dist/providers/core/types.js.map +1 -0
  171. package/dist/providers/index.d.ts +20 -0
  172. package/dist/providers/index.d.ts.map +1 -0
  173. package/dist/providers/index.js +22 -0
  174. package/dist/providers/index.js.map +1 -0
  175. package/dist/providers/integration/setup-ui.d.ts +76 -0
  176. package/dist/providers/integration/setup-ui.d.ts.map +1 -0
  177. package/dist/providers/integration/setup-ui.js +141 -0
  178. package/dist/providers/integration/setup-ui.js.map +1 -0
  179. package/dist/providers/plugins/litellm/index.d.ts +8 -0
  180. package/dist/providers/plugins/litellm/index.d.ts.map +1 -0
  181. package/dist/providers/plugins/litellm/index.js +12 -0
  182. package/dist/providers/plugins/litellm/index.js.map +1 -0
  183. package/dist/providers/plugins/litellm/litellm.models.d.ts +27 -0
  184. package/dist/providers/plugins/litellm/litellm.models.d.ts.map +1 -0
  185. package/dist/providers/plugins/litellm/litellm.models.js +48 -0
  186. package/dist/providers/plugins/litellm/litellm.models.js.map +1 -0
  187. package/dist/providers/plugins/litellm/litellm.setup-steps.d.ts +8 -0
  188. package/dist/providers/plugins/litellm/litellm.setup-steps.d.ts.map +1 -0
  189. package/dist/providers/plugins/litellm/litellm.setup-steps.js +52 -0
  190. package/dist/providers/plugins/litellm/litellm.setup-steps.js.map +1 -0
  191. package/dist/providers/plugins/litellm/litellm.template.d.ts +11 -0
  192. package/dist/providers/plugins/litellm/litellm.template.d.ts.map +1 -0
  193. package/dist/providers/plugins/litellm/litellm.template.js +59 -0
  194. package/dist/providers/plugins/litellm/litellm.template.js.map +1 -0
  195. package/dist/providers/plugins/ollama/index.d.ts +11 -0
  196. package/dist/providers/plugins/ollama/index.d.ts.map +1 -0
  197. package/dist/providers/plugins/ollama/index.js +11 -0
  198. package/dist/providers/plugins/ollama/index.js.map +1 -0
  199. package/dist/providers/plugins/ollama/ollama.health.d.ts +48 -0
  200. package/dist/providers/plugins/ollama/ollama.health.d.ts.map +1 -0
  201. package/dist/providers/plugins/ollama/ollama.health.js +87 -0
  202. package/dist/providers/plugins/ollama/ollama.health.js.map +1 -0
  203. package/dist/providers/plugins/ollama/ollama.models.d.ts +47 -0
  204. package/dist/providers/plugins/ollama/ollama.models.d.ts.map +1 -0
  205. package/dist/providers/plugins/ollama/ollama.models.js +252 -0
  206. package/dist/providers/plugins/ollama/ollama.models.js.map +1 -0
  207. package/dist/providers/plugins/ollama/ollama.setup-steps.d.ts +16 -0
  208. package/dist/providers/plugins/ollama/ollama.setup-steps.d.ts.map +1 -0
  209. package/dist/providers/plugins/ollama/ollama.setup-steps.js +164 -0
  210. package/dist/providers/plugins/ollama/ollama.setup-steps.js.map +1 -0
  211. package/dist/providers/plugins/ollama/ollama.template.d.ts +11 -0
  212. package/dist/providers/plugins/ollama/ollama.template.d.ts.map +1 -0
  213. package/dist/providers/plugins/ollama/ollama.template.js +87 -0
  214. package/dist/providers/plugins/ollama/ollama.template.js.map +1 -0
  215. package/dist/providers/plugins/sso/index.d.ts +12 -0
  216. package/dist/providers/plugins/sso/index.d.ts.map +1 -0
  217. package/dist/providers/plugins/sso/index.js +12 -0
  218. package/dist/providers/plugins/sso/index.js.map +1 -0
  219. package/dist/providers/plugins/sso/sso.auth.d.ts +50 -0
  220. package/dist/providers/plugins/sso/sso.auth.d.ts.map +1 -0
  221. package/dist/{utils/sso-auth.js → providers/plugins/sso/sso.auth.js} +37 -2
  222. package/dist/providers/plugins/sso/sso.auth.js.map +1 -0
  223. package/dist/providers/plugins/sso/sso.health.d.ts +44 -0
  224. package/dist/providers/plugins/sso/sso.health.d.ts.map +1 -0
  225. package/dist/providers/plugins/sso/sso.health.js +178 -0
  226. package/dist/providers/plugins/sso/sso.health.js.map +1 -0
  227. package/dist/{utils/codemie-model-fetcher.d.ts → providers/plugins/sso/sso.http-client.d.ts} +16 -5
  228. package/dist/providers/plugins/sso/sso.http-client.d.ts.map +1 -0
  229. package/dist/providers/plugins/sso/sso.http-client.js +187 -0
  230. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -0
  231. package/dist/providers/plugins/sso/sso.models.d.ts +48 -0
  232. package/dist/providers/plugins/sso/sso.models.d.ts.map +1 -0
  233. package/dist/providers/plugins/sso/sso.models.js +139 -0
  234. package/dist/providers/plugins/sso/sso.models.js.map +1 -0
  235. package/dist/providers/plugins/sso/sso.setup-steps.d.ts +16 -0
  236. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -0
  237. package/dist/providers/plugins/sso/sso.setup-steps.js +145 -0
  238. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -0
  239. package/dist/providers/plugins/sso/sso.template.d.ts +11 -0
  240. package/dist/providers/plugins/sso/sso.template.d.ts.map +1 -0
  241. package/dist/providers/plugins/sso/sso.template.js +35 -0
  242. package/dist/providers/plugins/sso/sso.template.js.map +1 -0
  243. package/dist/proxy/errors.d.ts.map +1 -0
  244. package/dist/proxy/errors.js.map +1 -0
  245. package/dist/proxy/http-client.d.ts.map +1 -0
  246. package/dist/{utils/proxy → proxy}/http-client.js +1 -1
  247. package/dist/proxy/http-client.js.map +1 -0
  248. package/dist/proxy/plugins/header-injection.plugin.d.ts +16 -0
  249. package/dist/proxy/plugins/header-injection.plugin.d.ts.map +1 -0
  250. package/dist/proxy/plugins/header-injection.plugin.js +52 -0
  251. package/dist/proxy/plugins/header-injection.plugin.js.map +1 -0
  252. package/dist/proxy/plugins/index.d.ts +18 -0
  253. package/dist/proxy/plugins/index.d.ts.map +1 -0
  254. package/dist/proxy/plugins/index.js +28 -0
  255. package/dist/proxy/plugins/index.js.map +1 -0
  256. package/dist/proxy/plugins/logging.plugin.d.ts +22 -0
  257. package/dist/proxy/plugins/logging.plugin.d.ts.map +1 -0
  258. package/dist/proxy/plugins/logging.plugin.js +92 -0
  259. package/dist/proxy/plugins/logging.plugin.js.map +1 -0
  260. package/dist/proxy/plugins/registry.d.ts +50 -0
  261. package/dist/proxy/plugins/registry.d.ts.map +1 -0
  262. package/dist/proxy/plugins/registry.js +124 -0
  263. package/dist/proxy/plugins/registry.js.map +1 -0
  264. package/dist/proxy/plugins/sso-auth.plugin.d.ts +16 -0
  265. package/dist/proxy/plugins/sso-auth.plugin.d.ts.map +1 -0
  266. package/dist/proxy/plugins/sso-auth.plugin.js +35 -0
  267. package/dist/proxy/plugins/sso-auth.plugin.js.map +1 -0
  268. package/dist/proxy/plugins/types.d.ts +79 -0
  269. package/dist/proxy/plugins/types.d.ts.map +1 -0
  270. package/dist/proxy/plugins/types.js +8 -0
  271. package/dist/proxy/plugins/types.js.map +1 -0
  272. package/dist/proxy/types.d.ts.map +1 -0
  273. package/dist/proxy/types.js.map +1 -0
  274. package/dist/utils/analytics-reader.js +1 -1
  275. package/dist/utils/analytics-reader.js.map +1 -1
  276. package/dist/utils/codemie-proxy.d.ts +43 -22
  277. package/dist/utils/codemie-proxy.d.ts.map +1 -1
  278. package/dist/utils/codemie-proxy.js +158 -88
  279. package/dist/utils/codemie-proxy.js.map +1 -1
  280. package/dist/utils/config-loader.d.ts +5 -6
  281. package/dist/utils/config-loader.d.ts.map +1 -1
  282. package/dist/utils/config-loader.js +72 -92
  283. package/dist/utils/config-loader.js.map +1 -1
  284. package/dist/utils/credential-store.d.ts +1 -1
  285. package/dist/utils/credential-store.d.ts.map +1 -1
  286. package/dist/utils/first-time.d.ts +0 -4
  287. package/dist/utils/first-time.d.ts.map +1 -1
  288. package/dist/utils/first-time.js +5 -117
  289. package/dist/utils/first-time.js.map +1 -1
  290. package/dist/utils/logger.d.ts +31 -1
  291. package/dist/utils/logger.d.ts.map +1 -1
  292. package/dist/utils/logger.js +111 -3
  293. package/dist/utils/logger.js.map +1 -1
  294. package/dist/utils/sanitize.d.ts +28 -0
  295. package/dist/utils/sanitize.d.ts.map +1 -0
  296. package/dist/utils/sanitize.js +213 -0
  297. package/dist/utils/sanitize.js.map +1 -0
  298. package/dist/workflows/installer.d.ts.map +1 -1
  299. package/dist/workflows/installer.js +3 -4
  300. package/dist/workflows/installer.js.map +1 -1
  301. package/package.json +1 -1
  302. package/dist/cli/commands/config.d.ts +0 -3
  303. package/dist/cli/commands/config.d.ts.map +0 -1
  304. package/dist/cli/commands/config.js +0 -198
  305. package/dist/cli/commands/config.js.map +0 -1
  306. package/dist/cli/commands/doctor/providers/AIRunSSOProviderCheck.d.ts +0 -11
  307. package/dist/cli/commands/doctor/providers/AIRunSSOProviderCheck.d.ts.map +0 -1
  308. package/dist/cli/commands/doctor/providers/AIRunSSOProviderCheck.js +0 -192
  309. package/dist/cli/commands/doctor/providers/AIRunSSOProviderCheck.js.map +0 -1
  310. package/dist/cli/commands/doctor/providers/BaseProviderCheck.d.ts +0 -12
  311. package/dist/cli/commands/doctor/providers/BaseProviderCheck.d.ts.map +0 -1
  312. package/dist/cli/commands/doctor/providers/BaseProviderCheck.js +0 -12
  313. package/dist/cli/commands/doctor/providers/BaseProviderCheck.js.map +0 -1
  314. package/dist/cli/commands/doctor/providers/StandardProviderCheck.d.ts +0 -11
  315. package/dist/cli/commands/doctor/providers/StandardProviderCheck.d.ts.map +0 -1
  316. package/dist/cli/commands/doctor/providers/StandardProviderCheck.js +0 -97
  317. package/dist/cli/commands/doctor/providers/StandardProviderCheck.js.map +0 -1
  318. package/dist/cli/commands/doctor/providers/index.d.ts +0 -30
  319. package/dist/cli/commands/doctor/providers/index.d.ts.map +0 -1
  320. package/dist/cli/commands/doctor/providers/index.js +0 -66
  321. package/dist/cli/commands/doctor/providers/index.js.map +0 -1
  322. package/dist/cli/commands/env.d.ts +0 -3
  323. package/dist/cli/commands/env.d.ts.map +0 -1
  324. package/dist/cli/commands/env.js +0 -19
  325. package/dist/cli/commands/env.js.map +0 -1
  326. package/dist/types/sso.d.ts +0 -42
  327. package/dist/types/sso.d.ts.map +0 -1
  328. package/dist/types/sso.js +0 -2
  329. package/dist/types/sso.js.map +0 -1
  330. package/dist/utils/async-tips.d.ts +0 -64
  331. package/dist/utils/async-tips.d.ts.map +0 -1
  332. package/dist/utils/async-tips.js +0 -203
  333. package/dist/utils/async-tips.js.map +0 -1
  334. package/dist/utils/codemie-integration-validator.d.ts +0 -18
  335. package/dist/utils/codemie-integration-validator.d.ts.map +0 -1
  336. package/dist/utils/codemie-integration-validator.js +0 -119
  337. package/dist/utils/codemie-integration-validator.js.map +0 -1
  338. package/dist/utils/codemie-model-fetcher.d.ts.map +0 -1
  339. package/dist/utils/codemie-model-fetcher.js +0 -242
  340. package/dist/utils/codemie-model-fetcher.js.map +0 -1
  341. package/dist/utils/health-checker.d.ts +0 -20
  342. package/dist/utils/health-checker.d.ts.map +0 -1
  343. package/dist/utils/health-checker.js +0 -172
  344. package/dist/utils/health-checker.js.map +0 -1
  345. package/dist/utils/model-fetcher.d.ts +0 -21
  346. package/dist/utils/model-fetcher.d.ts.map +0 -1
  347. package/dist/utils/model-fetcher.js +0 -148
  348. package/dist/utils/model-fetcher.js.map +0 -1
  349. package/dist/utils/proxy/errors.d.ts.map +0 -1
  350. package/dist/utils/proxy/errors.js.map +0 -1
  351. package/dist/utils/proxy/http-client.d.ts.map +0 -1
  352. package/dist/utils/proxy/http-client.js.map +0 -1
  353. package/dist/utils/proxy/interceptors.d.ts +0 -69
  354. package/dist/utils/proxy/interceptors.d.ts.map +0 -1
  355. package/dist/utils/proxy/interceptors.js +0 -308
  356. package/dist/utils/proxy/interceptors.js.map +0 -1
  357. package/dist/utils/proxy/types.d.ts.map +0 -1
  358. package/dist/utils/proxy/types.js.map +0 -1
  359. package/dist/utils/sso-auth.d.ts +0 -15
  360. package/dist/utils/sso-auth.d.ts.map +0 -1
  361. package/dist/utils/sso-auth.js.map +0 -1
  362. package/dist/utils/tips.d.ts +0 -35
  363. package/dist/utils/tips.d.ts.map +0 -1
  364. package/dist/utils/tips.js +0 -93
  365. package/dist/utils/tips.js.map +0 -1
  366. /package/dist/{utils/proxy → proxy}/errors.d.ts +0 -0
  367. /package/dist/{utils/proxy → proxy}/errors.js +0 -0
  368. /package/dist/{utils/proxy → proxy}/http-client.d.ts +0 -0
  369. /package/dist/{utils/proxy → proxy}/types.d.ts +0 -0
  370. /package/dist/{utils/proxy → proxy}/types.js +0 -0
@@ -4,53 +4,24 @@ import chalk from 'chalk';
4
4
  import ora from 'ora';
5
5
  import { ConfigLoader } from '../../utils/config-loader.js';
6
6
  import { logger } from '../../utils/logger.js';
7
- import { checkProviderHealth } from '../../utils/health-checker.js';
8
- import { fetchAvailableModels } from '../../utils/model-fetcher.js';
9
- import { CodeMieSSO } from '../../utils/sso-auth.js';
10
- import { fetchCodeMieModels } from '../../utils/codemie-model-fetcher.js';
11
- import { validateCodeMieIntegrations } from '../../utils/codemie-integration-validator.js';
12
- const PROVIDERS = [
13
- {
14
- name: 'CodeMie SSO (Recommended - Enterprise Authentication)',
15
- value: 'ai-run-sso',
16
- baseUrl: '', // Will be resolved from CodeMie URL
17
- models: [] // Will be fetched from CodeMie /v1/llm_models endpoint
18
- },
19
- {
20
- name: 'Google Gemini (Direct API Access)',
21
- value: 'gemini',
22
- baseUrl: 'https://generativelanguage.googleapis.com',
23
- models: ['gemini-2.5-flash', 'gemini-2.5-pro', 'gemini-1.5-pro', 'gemini-1.5-flash']
24
- },
25
- {
26
- name: 'LiteLLM Proxy (OpenAI-compatible Gateway)',
27
- value: 'litellm',
28
- baseUrl: 'https://litellm.example.com',
29
- models: ['claude-4-5-sonnet', 'claude-opus-4', 'gpt-4.1', 'gpt-5']
30
- },
31
- {
32
- name: 'AWS Bedrock (Claude via AWS)',
33
- value: 'bedrock',
34
- baseUrl: '',
35
- models: [
36
- 'us.anthropic.claude-sonnet-4-5-20250929-v1:0',
37
- 'us.anthropic.claude-opus-4-0-20250514-v1:0',
38
- 'anthropic.claude-3-5-sonnet-20241022-v2:0'
39
- ]
40
- },
41
- {
42
- name: 'Azure OpenAI (for GPT models and Codex)',
43
- value: 'azure',
44
- baseUrl: '',
45
- models: []
46
- }
47
- ];
7
+ import { ProviderRegistry } from '../../providers/index.js';
8
+ import { getAllProviderChoices, displaySetupSuccess, displaySetupError, getAllModelChoices, displaySetupInstructions } from '../../providers/integration/setup-ui.js';
48
9
  export function createSetupCommand() {
49
10
  const command = new Command('setup');
50
11
  command
51
12
  .description('Interactive setup wizard for CodeMie Code')
52
13
  .option('--force', 'Force re-setup even if config exists')
14
+ .option('-v, --verbose', 'Enable verbose debug output with detailed API logs')
53
15
  .action(async (options) => {
16
+ // Enable debug mode if verbose flag is set
17
+ if (options.verbose) {
18
+ process.env.CODEMIE_DEBUG = 'true';
19
+ // Show log file location
20
+ const logFilePath = logger.getLogFilePath();
21
+ if (logFilePath) {
22
+ console.log(chalk.dim(`Debug logs: ${logFilePath}\n`));
23
+ }
24
+ }
54
25
  try {
55
26
  await runSetupWizard(options.force);
56
27
  }
@@ -78,558 +49,136 @@ async function runSetupWizard(force) {
78
49
  console.log(`${activeMarker}${chalk.white(name)} (${profile.provider})`);
79
50
  });
80
51
  console.log('');
81
- }
82
- const { action } = await inquirer.prompt([
83
- {
84
- type: 'list',
85
- name: 'action',
86
- message: 'What would you like to do?',
87
- choices: [
88
- { name: 'Add a new profile', value: 'add' },
89
- { name: 'Update an existing profile', value: 'update' },
90
- { name: 'Cancel', value: 'cancel' }
91
- ]
92
- }
93
- ]);
94
- if (action === 'cancel') {
95
- console.log(chalk.yellow('\nSetup cancelled.\n'));
96
- return;
97
- }
98
- if (action === 'update') {
99
- const { selectedProfile } = await inquirer.prompt([
52
+ const { action } = await inquirer.prompt([
100
53
  {
101
54
  type: 'list',
102
- name: 'selectedProfile',
103
- message: 'Select profile to update:',
104
- choices: profiles.map(p => ({ name: p.name, value: p.name }))
55
+ name: 'action',
56
+ message: 'What would you like to do?',
57
+ choices: [
58
+ { name: 'Add a new profile', value: 'add' },
59
+ { name: 'Update an existing profile', value: 'update' },
60
+ { name: 'Cancel', value: 'cancel' }
61
+ ]
105
62
  }
106
63
  ]);
107
- profileName = selectedProfile;
108
- isUpdate = true;
109
- console.log(chalk.white(`\nUpdating profile: ${chalk.cyan(profileName)}\n`));
64
+ if (action === 'cancel') {
65
+ console.log(chalk.yellow('\nSetup cancelled.\n'));
66
+ return;
67
+ }
68
+ if (action === 'update') {
69
+ const { selectedProfile } = await inquirer.prompt([
70
+ {
71
+ type: 'list',
72
+ name: 'selectedProfile',
73
+ message: 'Select profile to update:',
74
+ choices: profiles.map(p => ({ name: p.name, value: p.name }))
75
+ }
76
+ ]);
77
+ profileName = selectedProfile;
78
+ isUpdate = true;
79
+ console.log(chalk.white(`\nUpdating profile: ${chalk.cyan(profileName)}\n`));
80
+ }
81
+ else {
82
+ // Adding new profile - will ask for name at the end
83
+ console.log(chalk.white('\nConfiguring new profile...\n'));
84
+ }
110
85
  }
111
86
  else {
112
- // Adding new profile - will ask for name at the end
113
- console.log(chalk.white('\nConfiguring new profile...\n'));
87
+ // Config file exists but no profiles - treat as fresh setup
88
+ console.log(chalk.white("Let's configure your AI assistant.\n"));
114
89
  }
115
90
  }
116
91
  else {
117
92
  // First time setup - will create default profile or ask for name at the end
118
93
  console.log(chalk.white("Let's configure your AI assistant.\n"));
119
94
  }
120
- // Step 1: Choose provider (ai-run-sso is now first/default)
95
+ // Step 1: Get all registered providers from ProviderRegistry
96
+ const registeredProviders = ProviderRegistry.getAllProviders();
97
+ const allProviderChoices = getAllProviderChoices(registeredProviders);
121
98
  const { provider } = await inquirer.prompt([
122
99
  {
123
100
  type: 'list',
124
101
  name: 'provider',
125
- message: 'Choose your LLM provider:',
126
- choices: PROVIDERS.map(p => ({ name: p.name, value: p.value })),
127
- default: 'ai-run-sso' // Make SSO the default
102
+ message: 'Choose your LLM provider:\n',
103
+ choices: allProviderChoices,
104
+ pageSize: 15,
105
+ // Default to highest priority provider (SSO has priority 0)
106
+ default: allProviderChoices[0]?.value
128
107
  }
129
108
  ]);
130
- if (provider === 'ai-run-sso') {
131
- await handleAiRunSSOSetup(profileName, isUpdate);
132
- return; // Early return for SSO flow
133
- }
134
- const selectedProvider = PROVIDERS.find(p => p.value === provider);
135
- // Step 2: Provider details
136
- let baseUrl = selectedProvider.baseUrl;
137
- let apiKey = '';
138
- let model = selectedProvider.models[0] || '';
139
- // Special handling for AWS Bedrock
140
- if (provider === 'bedrock') {
141
- console.log(chalk.bold.cyan('\n📝 AWS Bedrock Configuration\n'));
142
- console.log(chalk.white('AWS Bedrock requires AWS access credentials and region configuration.'));
143
- console.log(chalk.white('AWS credentials can be configured in multiple ways:\n'));
144
- console.log(chalk.white(' 1. AWS CLI profiles (recommended): ~/.aws/credentials'));
145
- console.log(chalk.white(' 2. Environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY'));
146
- console.log(chalk.white(' 3. IAM roles (for EC2/ECS instances)\n'));
147
- // Check if AWS credentials might be available
148
- const hasAwsCli = await (async () => {
149
- try {
150
- const { exec } = await import('../../utils/exec.js');
151
- await exec('aws', ['--version']);
152
- return true;
153
- }
154
- catch {
155
- return false;
156
- }
157
- })();
158
- const hasAwsEnvVars = !!(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY);
159
- if (!hasAwsCli && !hasAwsEnvVars) {
160
- console.log(chalk.yellow('⚠️ AWS CLI not detected and no AWS environment variables found.\n'));
161
- console.log(chalk.white('Please configure AWS credentials before proceeding:\n'));
162
- console.log(chalk.cyan(' Option 1: Install and configure AWS CLI'));
163
- console.log(chalk.white(' $ ') + chalk.green('aws configure'));
164
- console.log(chalk.white(' Enter your AWS Access Key ID and Secret Access Key\n'));
165
- console.log(chalk.cyan(' Option 2: Set environment variables'));
166
- console.log(chalk.white(' $ ') + chalk.green('export AWS_ACCESS_KEY_ID="your-access-key"'));
167
- console.log(chalk.white(' $ ') + chalk.green('export AWS_SECRET_ACCESS_KEY="your-secret-key"\n'));
168
- const { continueAnyway } = await inquirer.prompt([
169
- {
170
- type: 'confirm',
171
- name: 'continueAnyway',
172
- message: 'Continue with Bedrock setup anyway?',
173
- default: false
174
- }
175
- ]);
176
- if (!continueAnyway) {
177
- console.log(chalk.yellow('\nBedrock setup cancelled. Please configure AWS credentials first.\n'));
178
- process.exit(0);
179
- }
180
- }
181
- else if (hasAwsCli) {
182
- console.log(chalk.green('✓ AWS CLI detected\n'));
183
- }
184
- else if (hasAwsEnvVars) {
185
- console.log(chalk.green('✓ AWS environment variables detected\n'));
186
- }
187
- // Ask for AWS configuration
188
- const { awsRegion, awsProfile, useProfile } = await inquirer.prompt([
189
- {
190
- type: 'confirm',
191
- name: 'useProfile',
192
- message: 'Use AWS CLI profile?',
193
- default: hasAwsCli,
194
- when: hasAwsCli
195
- },
196
- {
197
- type: 'input',
198
- name: 'awsProfile',
199
- message: 'AWS profile name:',
200
- default: 'default',
201
- when: (answers) => answers.useProfile
202
- },
203
- {
204
- type: 'input',
205
- name: 'awsRegion',
206
- message: 'AWS Region:',
207
- default: 'us-west-2',
208
- validate: (input) => input.trim() !== '' || 'AWS region is required'
209
- }
210
- ]);
211
- // Set environment variables for Bedrock
212
- process.env.AWS_REGION = awsRegion ? awsRegion.trim() : awsRegion;
213
- process.env.CLAUDE_CODE_USE_BEDROCK = '1';
214
- if (useProfile && awsProfile) {
215
- process.env.AWS_PROFILE = awsProfile ? awsProfile.trim() : awsProfile;
216
- }
217
- console.log(chalk.green('\n✓ Bedrock configuration set'));
218
- console.log(chalk.white(' AWS_REGION=' + (awsRegion ? awsRegion.trim() : awsRegion)));
219
- if (useProfile && awsProfile) {
220
- console.log(chalk.white(' AWS_PROFILE=' + (awsProfile ? awsProfile.trim() : awsProfile)));
221
- }
222
- console.log(chalk.white(' CLAUDE_CODE_USE_BEDROCK=1\n'));
223
- // For Bedrock, we don't need base URL or API key (uses AWS credentials)
224
- baseUrl = 'bedrock';
225
- apiKey = 'bedrock'; // Placeholder
109
+ // Get setup steps from provider registry
110
+ const setupSteps = ProviderRegistry.getSetupSteps(provider);
111
+ if (!setupSteps) {
112
+ throw new Error(`Provider "${provider}" does not have setup steps configured`);
226
113
  }
227
- else if (!baseUrl) {
228
- // Custom provider - ask for base URL
229
- const answers = await inquirer.prompt([
230
- {
231
- type: 'input',
232
- name: 'baseUrl',
233
- message: 'Enter API base URL:',
234
- validate: (input) => input.trim() !== '' || 'Base URL is required'
235
- }
236
- ]);
237
- baseUrl = answers.baseUrl ? answers.baseUrl.trim() : answers.baseUrl;
238
- }
239
- else {
240
- // Prompt for base URL directly (no default)
241
- const { customUrl } = await inquirer.prompt([
242
- {
243
- type: 'input',
244
- name: 'customUrl',
245
- message: `Enter base URL (default: ${baseUrl}):`,
246
- validate: (input) => {
247
- // Allow empty input to use default
248
- if (input.trim() === '')
249
- return true;
250
- // Otherwise validate it's not just whitespace
251
- return input.trim() !== '' || 'Base URL is required';
252
- }
253
- }
254
- ]);
255
- // Use custom URL if provided, otherwise keep default
256
- if (customUrl && customUrl.trim() !== '') {
257
- baseUrl = customUrl.trim();
114
+ // Use plugin-based setup flow
115
+ await handlePluginSetup(provider, setupSteps, profileName, isUpdate);
116
+ }
117
+ /**
118
+ * Handle plugin-based setup flow
119
+ *
120
+ * Uses ProviderSetupSteps from ProviderRegistry for clean, extensible setup
121
+ */
122
+ async function handlePluginSetup(providerName, setupSteps, profileName, isUpdate) {
123
+ try {
124
+ const providerTemplate = ProviderRegistry.getProvider(providerName);
125
+ // Display setup instructions if available
126
+ if (providerTemplate) {
127
+ displaySetupInstructions(providerTemplate);
258
128
  }
259
- }
260
- // API Key (skip for Bedrock as it uses AWS credentials)
261
- if (provider !== 'bedrock') {
262
- const { apiKeyInput } = await inquirer.prompt([
263
- {
264
- type: 'password',
265
- name: 'apiKeyInput',
266
- message: 'Enter your API key:',
267
- mask: '*',
268
- validate: (input) => input.trim() !== '' || 'API key is required'
269
- }
270
- ]);
271
- apiKey = apiKeyInput ? apiKeyInput.trim() : apiKeyInput;
272
- }
273
- // Step 2.5: Validate credentials and fetch models
274
- let availableModels = [];
275
- if (provider !== 'bedrock') {
276
- const healthSpinner = ora('Validating credentials...').start();
129
+ // Step 1: Get credentials
130
+ const credentials = await setupSteps.getCredentials(isUpdate);
131
+ // Step 2: Fetch models
132
+ const modelsSpinner = ora('Fetching available models...').start();
133
+ let models = [];
277
134
  try {
278
- const healthCheck = await checkProviderHealth(baseUrl, apiKey);
279
- if (!healthCheck.success) {
280
- healthSpinner.fail(chalk.red('Validation failed'));
281
- console.log(chalk.red(` Error: ${healthCheck.message}\n`));
282
- const { continueAnyway } = await inquirer.prompt([
283
- {
284
- type: 'confirm',
285
- name: 'continueAnyway',
286
- message: 'Continue with setup anyway?',
287
- default: false
288
- }
289
- ]);
290
- if (!continueAnyway) {
291
- console.log(chalk.yellow('\nSetup cancelled. Please check your credentials.\n'));
292
- return;
293
- }
294
- }
295
- else {
296
- healthSpinner.succeed(chalk.green('Credentials validated'));
297
- // Fetch available models
298
- const modelsSpinner = ora('Fetching available models...').start();
299
- try {
300
- availableModels = await fetchAvailableModels({
301
- provider,
302
- baseUrl,
303
- apiKey,
304
- model: 'temp', // Temporary, not used for fetching
305
- timeout: 300
306
- });
307
- if (availableModels.length > 0) {
308
- modelsSpinner.succeed(chalk.green(`Found ${availableModels.length} available models`));
309
- }
310
- else {
311
- modelsSpinner.warn(chalk.yellow('No models found - will use manual entry'));
312
- }
313
- }
314
- catch {
315
- modelsSpinner.warn(chalk.yellow('Could not fetch models - will use manual entry'));
316
- availableModels = [];
317
- }
318
- }
319
- }
320
- catch (error) {
321
- healthSpinner.fail(chalk.red('Validation error'));
322
- console.log(chalk.red(` ${error instanceof Error ? error.message : String(error)}\n`));
323
- const { continueAnyway } = await inquirer.prompt([
324
- {
325
- type: 'confirm',
326
- name: 'continueAnyway',
327
- message: 'Continue with setup anyway?',
328
- default: false
329
- }
330
- ]);
331
- if (!continueAnyway) {
332
- console.log(chalk.yellow('\nSetup cancelled.\n'));
333
- return;
334
- }
335
- }
336
- }
337
- // Model selection
338
- // Use fetched models if available, otherwise fall back to provider defaults
339
- const modelChoices = availableModels.length > 0
340
- ? availableModels
341
- : selectedProvider.models;
342
- if (modelChoices.length > 0) {
343
- // Add custom option at the end
344
- const choices = [
345
- ...modelChoices,
346
- { name: chalk.white('Custom model (manual entry)...'), value: 'custom' }
347
- ];
348
- const { selectedModel } = await inquirer.prompt([
349
- {
350
- type: 'list',
351
- name: 'selectedModel',
352
- message: availableModels.length > 0
353
- ? `Choose a model (${availableModels.length} available):`
354
- : 'Choose a model:',
355
- choices,
356
- pageSize: 15
357
- }
358
- ]);
359
- if (selectedModel === 'custom') {
360
- const { customModel } = await inquirer.prompt([
361
- {
362
- type: 'input',
363
- name: 'customModel',
364
- message: 'Enter model name:',
365
- validate: (input) => input.trim() !== '' || 'Model is required'
366
- }
367
- ]);
368
- model = customModel ? customModel.trim() : customModel;
369
- }
370
- else {
371
- model = selectedModel;
135
+ models = await setupSteps.fetchModels(credentials);
136
+ modelsSpinner.succeed(chalk.green(`Found ${models.length} available models`));
372
137
  }
373
- }
374
- else {
375
- const { modelInput } = await inquirer.prompt([
376
- {
377
- type: 'input',
378
- name: 'modelInput',
379
- message: 'Enter model name:',
380
- validate: (input) => input.trim() !== '' || 'Model is required'
381
- }
382
- ]);
383
- model = modelInput ? modelInput.trim() : modelInput;
384
- }
385
- // Step 3: Ask for profile name (if creating new)
386
- if (!isUpdate && profileName === null) {
387
- const profiles = await ConfigLoader.listProfiles();
388
- const existingNames = profiles.map(p => p.name);
389
- // Suggest a default name based on provider
390
- let defaultName = 'default';
391
- if (existingNames.length > 0) {
392
- // If profiles exist, suggest provider-based name
393
- defaultName = provider === 'ai-run-sso' ? 'codemie-sso' : provider;
394
- // Make it unique if needed
395
- let counter = 1;
396
- let suggestedName = defaultName;
397
- while (existingNames.includes(suggestedName)) {
398
- suggestedName = `${defaultName}-${counter}`;
399
- counter++;
400
- }
401
- defaultName = suggestedName;
138
+ catch {
139
+ modelsSpinner.warn(chalk.yellow('Could not fetch models - will use manual entry'));
140
+ models = [];
402
141
  }
403
- const { newProfileName } = await inquirer.prompt([
404
- {
405
- type: 'input',
406
- name: 'newProfileName',
407
- message: 'Enter a name for this profile:',
408
- default: defaultName,
409
- validate: (input) => {
410
- if (!input.trim())
411
- return 'Profile name is required';
412
- if (existingNames.includes(input.trim())) {
413
- return 'A profile with this name already exists';
414
- }
415
- return true;
416
- }
417
- }
418
- ]);
419
- profileName = newProfileName ? newProfileName.trim() : newProfileName;
420
- }
421
- // Step 4: Enable analytics by default (only for first-time setup)
422
- let enableAnalytics = false;
423
- if (!isUpdate) {
424
- const profiles = await ConfigLoader.listProfiles();
425
- const isFirstProfile = profiles.length === 0;
426
- if (isFirstProfile) {
427
- enableAnalytics = true;
142
+ // Step 3: Model selection
143
+ const selectedModel = await promptForModelSelection(models, providerTemplate);
144
+ // Step 3.5: Install model if provider supports it (e.g., Ollama)
145
+ if (providerTemplate?.supportsModelInstallation && setupSteps.installModel) {
146
+ await setupSteps.installModel(credentials, selectedModel, models);
428
147
  }
429
- }
430
- // Step 5: Save configuration as profile
431
- const profile = {
432
- name: profileName,
433
- provider,
434
- baseUrl,
435
- apiKey,
436
- model,
437
- timeout: 300,
438
- debug: false
439
- };
440
- const spinner = ora('Saving profile...').start();
441
- try {
442
- await ConfigLoader.saveProfile(profileName, profile);
443
- // Save analytics config if this is first profile
444
- if (enableAnalytics !== false) {
445
- const config = await ConfigLoader.loadMultiProviderConfig();
446
- if (!config.analytics) {
447
- config.analytics = {
448
- enabled: enableAnalytics,
449
- target: 'local',
450
- localPath: '~/.codemie/analytics',
451
- flushInterval: 5000,
452
- maxBufferSize: 100
453
- };
454
- await ConfigLoader.saveMultiProviderConfig(config);
455
- }
148
+ // Step 4: Build configuration
149
+ const config = setupSteps.buildConfig(credentials, selectedModel);
150
+ // Step 5: Ask for profile name (if creating new)
151
+ let finalProfileName = profileName;
152
+ if (!isUpdate && profileName === null) {
153
+ finalProfileName = await promptForProfileName(providerName);
456
154
  }
457
- spinner.succeed(chalk.green(`Profile "${profileName}" saved to ~/.codemie/config.json`));
458
- // If this is a new profile, ask if user wants to switch to it
155
+ // Step 6: Enable analytics (only for first profile)
156
+ let enableAnalytics = false;
459
157
  if (!isUpdate) {
460
- const activeProfile = await ConfigLoader.getActiveProfileName();
461
- if (activeProfile !== profileName) {
462
- const { switchToNew } = await inquirer.prompt([
463
- {
464
- type: 'confirm',
465
- name: 'switchToNew',
466
- message: `Switch to profile "${profileName}" as active?`,
467
- default: true
468
- }
469
- ]);
470
- if (switchToNew) {
471
- await ConfigLoader.switchProfile(profileName);
472
- console.log(chalk.green(`✓ Switched to profile "${profileName}"`));
473
- }
474
- }
475
- }
476
- }
477
- catch (error) {
478
- spinner.fail(chalk.red('Failed to save profile'));
479
- throw error;
480
- }
481
- // Success message
482
- console.log(chalk.bold.green(`\n✅ Profile "${profileName}" configured successfully!\n`));
483
- console.log(chalk.cyan(`🔗 Provider: ${provider}`));
484
- console.log(chalk.cyan(`🤖 Model: ${model}`));
485
- console.log(chalk.cyan(`📁 Config: ~/.codemie/config.json\n`));
486
- console.log(chalk.bold(`🚀 Ready to use! Try: ${chalk.white('codemie-code "test task"')}\n`));
487
- }
488
- async function handleAiRunSSOSetup(profileName, isUpdate) {
489
- console.log(chalk.bold.cyan('\n🔐 CodeMie SSO Configuration\n'));
490
- // Step 1: Get CodeMie URL
491
- const { codeMieUrl } = await inquirer.prompt([
492
- {
493
- type: 'input',
494
- name: 'codeMieUrl',
495
- message: 'Enter CodeMie URL:',
496
- default: 'https://codemie.lab.epam.com',
497
- validate: (input) => {
498
- const trimmed = input.trim();
499
- if (!trimmed)
500
- return 'CodeMie URL is required';
501
- if (!trimmed.startsWith('http'))
502
- return 'URL must start with http:// or https://';
503
- try {
504
- new URL(trimmed);
505
- return true;
506
- }
507
- catch {
508
- return 'Please enter a valid URL';
509
- }
510
- }
158
+ const profiles = await ConfigLoader.listProfiles();
159
+ enableAnalytics = profiles.length === 0;
511
160
  }
512
- ]);
513
- // Trim the URL to ensure no leading/trailing spaces
514
- const trimmedCodeMieUrl = codeMieUrl ? codeMieUrl.trim() : codeMieUrl;
515
- // Step 2: Proceed directly to SSO authentication (no connectivity check)
516
- // Following the same pattern as codemie-ide-plugin which trusts the SSO endpoint
517
- // Step 3: Launch SSO Authentication
518
- console.log(chalk.white('\nStarting SSO authentication...\n'));
519
- const authSpinner = ora('Launching browser for authentication...').start();
520
- try {
521
- const sso = new CodeMieSSO();
522
- const authResult = await sso.authenticate({ codeMieUrl: trimmedCodeMieUrl, timeout: 120000 });
523
- if (!authResult.success) {
524
- authSpinner.fail(chalk.red('SSO authentication failed'));
525
- console.log(chalk.red(` Error: ${authResult.error}\n`));
526
- return;
527
- }
528
- authSpinner.succeed(chalk.green('SSO authentication successful'));
529
- // Step 4a: Validate CodeMie integrations
530
- const integrationsSpinner = ora('Checking CodeMie integrations...').start();
531
- let selectedIntegration;
161
+ // Step 7: Save profile
162
+ const saveSpinner = ora('Saving profile...').start();
532
163
  try {
533
- selectedIntegration = await validateCodeMieIntegrations(authResult, integrationsSpinner);
534
- if (selectedIntegration) {
535
- integrationsSpinner.succeed(chalk.green('CodeMie integration selected'));
536
- }
537
- else {
538
- integrationsSpinner.info(chalk.white('Continuing without integration'));
539
- }
540
- }
541
- catch {
542
- integrationsSpinner.stop();
543
- // Error details already displayed by validateCodeMieIntegrations
544
- return;
545
- }
546
- // Step 4b: Fetch available models from CodeMie
547
- const modelsSpinner = ora('Fetching available models from CodeMie...').start();
548
- try {
549
- const models = await fetchCodeMieModels(authResult.apiUrl, authResult.cookies);
550
- modelsSpinner.succeed(chalk.green(`Found ${models.length} available models`));
551
- // Step 5: Model selection
552
- const selectedModel = await promptForModelSelection(models);
553
- // Step 6: Ask for profile name (if creating new)
554
- let finalProfileName = profileName;
555
- if (!isUpdate && profileName === null) {
556
- const profiles = await ConfigLoader.listProfiles();
557
- const existingNames = profiles.map(p => p.name);
558
- // Suggest a default name
559
- let defaultName = 'codemie-sso';
560
- if (existingNames.length > 0) {
561
- let counter = 1;
562
- let suggestedName = defaultName;
563
- while (existingNames.includes(suggestedName)) {
564
- suggestedName = `${defaultName}-${counter}`;
565
- counter++;
566
- }
567
- defaultName = suggestedName;
568
- }
569
- else {
570
- defaultName = 'default';
571
- }
572
- const { newProfileName } = await inquirer.prompt([
573
- {
574
- type: 'input',
575
- name: 'newProfileName',
576
- message: 'Enter a name for this profile:',
577
- default: defaultName,
578
- validate: (input) => {
579
- if (!input.trim())
580
- return 'Profile name is required';
581
- if (existingNames.includes(input.trim())) {
582
- return 'A profile with this name already exists';
583
- }
584
- return true;
585
- }
586
- }
587
- ]);
588
- finalProfileName = newProfileName ? newProfileName.trim() : newProfileName;
589
- }
590
- // Step 6.5: Enable analytics by default (only for first-time setup)
591
- let enableAnalytics = false;
592
- if (!isUpdate) {
593
- const profiles = await ConfigLoader.listProfiles();
594
- const isFirstProfile = profiles.length === 0;
595
- if (isFirstProfile) {
596
- enableAnalytics = true;
597
- }
598
- }
599
- // Step 7: Save configuration as profile
600
- const profile = {
601
- name: finalProfileName,
602
- provider: 'ai-run-sso',
603
- authMethod: 'sso',
604
- codeMieUrl: trimmedCodeMieUrl,
605
- baseUrl: authResult.apiUrl,
606
- apiKey: 'sso-authenticated',
607
- model: selectedModel,
608
- timeout: 300,
609
- debug: false
610
- };
611
- // Only add integration if one was selected
612
- if (selectedIntegration) {
613
- profile.codeMieIntegration = selectedIntegration;
614
- }
615
- const saveSpinner = ora('Saving profile...').start();
616
- await ConfigLoader.saveProfile(finalProfileName, profile);
617
- // Save analytics config if this is first profile
618
- if (enableAnalytics !== false) {
619
- const config = await ConfigLoader.loadMultiProviderConfig();
620
- if (!config.analytics) {
621
- config.analytics = {
622
- enabled: enableAnalytics,
164
+ config.name = finalProfileName;
165
+ await ConfigLoader.saveProfile(finalProfileName, config);
166
+ // Save analytics config if first profile
167
+ if (enableAnalytics) {
168
+ const multiConfig = await ConfigLoader.loadMultiProviderConfig();
169
+ if (!multiConfig.analytics) {
170
+ multiConfig.analytics = {
171
+ enabled: true,
623
172
  target: 'local',
624
173
  localPath: '~/.codemie/analytics',
625
174
  flushInterval: 5000,
626
175
  maxBufferSize: 100
627
176
  };
628
- await ConfigLoader.saveMultiProviderConfig(config);
177
+ await ConfigLoader.saveMultiProviderConfig(multiConfig);
629
178
  }
630
179
  }
631
- saveSpinner.succeed(chalk.green(`Profile "${finalProfileName}" saved to ~/.codemie/config.json`));
632
- // If this is a new profile, ask if user wants to switch to it
180
+ saveSpinner.succeed(chalk.green(`Profile "${finalProfileName}" saved`));
181
+ // Switch to new profile if needed
633
182
  if (!isUpdate) {
634
183
  const activeProfile = await ConfigLoader.getActiveProfileName();
635
184
  if (activeProfile !== finalProfileName) {
@@ -647,113 +196,68 @@ async function handleAiRunSSOSetup(profileName, isUpdate) {
647
196
  }
648
197
  }
649
198
  }
650
- // Success message
651
- console.log(chalk.bold.green(`\n✅ Profile "${finalProfileName}" configured successfully!\n`));
652
- console.log(chalk.cyan(`🔗 Connected to: ${trimmedCodeMieUrl}`));
653
- console.log(chalk.cyan(`🔑 Authentication: SSO (session stored securely)`));
654
- console.log(chalk.cyan(`🤖 Selected Model: ${selectedModel}`));
655
- console.log(chalk.cyan(`📁 Config saved to: ~/.codemie/config.json\n`));
656
- console.log(chalk.bold(`🚀 Ready to use! Try: ${chalk.white('codemie-code "test task"')}\n`));
199
+ // Display success
200
+ displaySetupSuccess(finalProfileName, providerName, selectedModel);
657
201
  }
658
202
  catch (error) {
659
- modelsSpinner.fail(chalk.red('Failed to fetch models'));
660
- console.log(chalk.red(` Error: ${error instanceof Error ? error.message : String(error)}\n`));
661
- // Continue with manual model entry
662
- const { manualModel } = await inquirer.prompt([
663
- {
664
- type: 'input',
665
- name: 'manualModel',
666
- message: 'Enter model name manually:',
667
- default: 'claude-4-5-sonnet',
668
- validate: (input) => input.trim() !== '' || 'Model name is required'
669
- }
670
- ]);
671
- // Ask for profile name (if creating new)
672
- let finalProfileName = profileName;
673
- if (!isUpdate && profileName === null) {
674
- const profiles = await ConfigLoader.listProfiles();
675
- const existingNames = profiles.map(p => p.name);
676
- let defaultName = 'codemie-sso';
677
- if (existingNames.length > 0) {
678
- let counter = 1;
679
- let suggestedName = defaultName;
680
- while (existingNames.includes(suggestedName)) {
681
- suggestedName = `${defaultName}-${counter}`;
682
- counter++;
683
- }
684
- defaultName = suggestedName;
685
- }
686
- else {
687
- defaultName = 'default';
688
- }
689
- const { newProfileName } = await inquirer.prompt([
690
- {
691
- type: 'input',
692
- name: 'newProfileName',
693
- message: 'Enter a name for this profile:',
694
- default: defaultName,
695
- validate: (input) => {
696
- if (!input.trim())
697
- return 'Profile name is required';
698
- if (existingNames.includes(input.trim())) {
699
- return 'A profile with this name already exists';
700
- }
701
- return true;
702
- }
703
- }
704
- ]);
705
- finalProfileName = newProfileName ? newProfileName.trim() : newProfileName;
706
- }
707
- // Enable analytics by default (only for first-time setup)
708
- let enableAnalytics = false;
709
- if (!isUpdate) {
710
- const profiles = await ConfigLoader.listProfiles();
711
- const isFirstProfile = profiles.length === 0;
712
- if (isFirstProfile) {
713
- enableAnalytics = true;
714
- }
715
- }
716
- // Save config with manual model as profile
717
- const profile = {
718
- name: finalProfileName,
719
- provider: 'ai-run-sso',
720
- authMethod: 'sso',
721
- codeMieUrl: trimmedCodeMieUrl,
722
- baseUrl: authResult.apiUrl,
723
- apiKey: 'sso-authenticated',
724
- model: manualModel ? manualModel.trim() : manualModel,
725
- timeout: 300,
726
- debug: false
727
- };
728
- // Only add integration if one was selected
729
- if (selectedIntegration) {
730
- profile.codeMieIntegration = selectedIntegration;
731
- }
732
- await ConfigLoader.saveProfile(finalProfileName, profile);
733
- // Save analytics config if this is first profile
734
- if (enableAnalytics !== false) {
735
- const config = await ConfigLoader.loadMultiProviderConfig();
736
- if (!config.analytics) {
737
- config.analytics = {
738
- enabled: enableAnalytics,
739
- target: 'local',
740
- localPath: '~/.codemie/analytics',
741
- flushInterval: 5000,
742
- maxBufferSize: 100
743
- };
744
- await ConfigLoader.saveMultiProviderConfig(config);
745
- }
746
- }
747
- console.log(chalk.green(`\n✅ Profile "${finalProfileName}" saved with manual model selection.\n`));
203
+ saveSpinner.fail(chalk.red('Failed to save profile'));
204
+ throw error;
748
205
  }
749
206
  }
750
207
  catch (error) {
751
- authSpinner.fail(chalk.red('Authentication error'));
752
- console.log(chalk.red(` ${error instanceof Error ? error.message : String(error)}\n`));
753
- return;
208
+ const errorMessage = error instanceof Error ? error.message : String(error);
209
+ const providerTemplate = ProviderRegistry.getProvider(providerName);
210
+ displaySetupError(new Error(errorMessage), providerTemplate?.setupInstructions);
211
+ throw error;
754
212
  }
755
213
  }
756
- async function promptForModelSelection(models) {
214
+ /**
215
+ * Prompt for profile name
216
+ *
217
+ * Generates unique default name and validates input
218
+ */
219
+ async function promptForProfileName(providerName) {
220
+ const profiles = await ConfigLoader.listProfiles();
221
+ const existingNames = profiles.map(p => p.name);
222
+ // Suggest a default name based on provider template
223
+ let defaultName = 'default';
224
+ if (existingNames.length > 0) {
225
+ // If profiles exist, use provider's defaultProfileName or provider name
226
+ const providerTemplate = ProviderRegistry.getProvider(providerName);
227
+ defaultName = providerTemplate?.defaultProfileName || providerName;
228
+ // Make it unique if needed
229
+ let counter = 1;
230
+ let suggestedName = defaultName;
231
+ while (existingNames.includes(suggestedName)) {
232
+ suggestedName = `${defaultName}-${counter}`;
233
+ counter++;
234
+ }
235
+ defaultName = suggestedName;
236
+ }
237
+ const { newProfileName } = await inquirer.prompt([
238
+ {
239
+ type: 'input',
240
+ name: 'newProfileName',
241
+ message: 'Enter a name for this profile:',
242
+ default: defaultName,
243
+ validate: (input) => {
244
+ if (!input.trim())
245
+ return 'Profile name is required';
246
+ if (existingNames.includes(input.trim())) {
247
+ return 'A profile with this name already exists';
248
+ }
249
+ return true;
250
+ }
251
+ }
252
+ ]);
253
+ return newProfileName ? newProfileName.trim() : newProfileName;
254
+ }
255
+ /**
256
+ * Prompt for model selection with metadata
257
+ *
258
+ * Uses getAllModelChoices for enriched display
259
+ */
260
+ async function promptForModelSelection(models, providerTemplate) {
757
261
  if (models.length === 0) {
758
262
  const { manualModel } = await inquirer.prompt([
759
263
  {
@@ -766,9 +270,9 @@ async function promptForModelSelection(models) {
766
270
  ]);
767
271
  return manualModel ? manualModel.trim() : manualModel;
768
272
  }
769
- // Add custom option at the end
273
+ // Use getAllModelChoices for enriched display with metadata
770
274
  const choices = [
771
- ...models,
275
+ ...getAllModelChoices(models, providerTemplate),
772
276
  { name: chalk.white('Custom model (manual entry)...'), value: 'custom' }
773
277
  ];
774
278
  const { selectedModel } = await inquirer.prompt([
@@ -793,4 +297,9 @@ async function promptForModelSelection(models) {
793
297
  }
794
298
  return selectedModel;
795
299
  }
300
+ /*
301
+ * Note: Old SSO setup function (handleAiRunSSOSetup) has been removed.
302
+ * It has been replaced by the plugin-based SSOSetupSteps in src/providers/plugins/sso/
303
+ * All SSO setup logic is now handled through the ProviderRegistry plugin system.
304
+ */
796
305
  //# sourceMappingURL=setup.js.map