@agents-at-scale/ark 0.1.35-rc1 → 0.1.35

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 (207) hide show
  1. package/dist/commands/cluster/index.d.ts +1 -2
  2. package/dist/commands/cluster/index.js +5 -3
  3. package/dist/commands/completion.js +2 -159
  4. package/dist/commands/config.d.ts +3 -0
  5. package/dist/commands/config.js +321 -38
  6. package/dist/commands/generate/config.js +24 -5
  7. package/dist/commands/generate/generators/agent.js +2 -2
  8. package/dist/commands/generate/generators/mcpserver.d.ts +1 -2
  9. package/dist/commands/generate/generators/mcpserver.js +5 -26
  10. package/dist/commands/generate/generators/project.js +41 -22
  11. package/dist/commands/generate/generators/team.js +2 -2
  12. package/dist/commands/generate/index.d.ts +1 -2
  13. package/dist/commands/generate/index.js +1 -1
  14. package/dist/components/statusChecker.d.ts +23 -13
  15. package/dist/components/statusChecker.js +129 -275
  16. package/dist/config.d.ts +22 -3
  17. package/dist/config.js +161 -10
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +42 -40
  20. package/dist/lib/cluster.d.ts +1 -2
  21. package/dist/lib/cluster.js +16 -37
  22. package/dist/lib/config.d.ts +80 -26
  23. package/dist/lib/config.js +205 -70
  24. package/dist/lib/consts.d.ts +1 -0
  25. package/dist/lib/consts.js +2 -0
  26. package/dist/lib/errors.js +1 -1
  27. package/dist/lib/exec.d.ts +4 -0
  28. package/dist/lib/exec.js +11 -0
  29. package/dist/lib/types.d.ts +3 -10
  30. package/dist/ui/MainMenu.d.ts +1 -5
  31. package/dist/ui/MainMenu.js +91 -222
  32. package/dist/ui/statusFormatter.d.ts +7 -22
  33. package/dist/ui/statusFormatter.js +39 -39
  34. package/package.json +5 -17
  35. package/dist/arkServices.d.ts +0 -42
  36. package/dist/arkServices.js +0 -138
  37. package/dist/arkServices.spec.d.ts +0 -1
  38. package/dist/arkServices.spec.js +0 -24
  39. package/dist/charts/charts.d.ts +0 -5
  40. package/dist/charts/charts.js +0 -6
  41. package/dist/charts/dependencies.d.ts +0 -6
  42. package/dist/charts/dependencies.js +0 -50
  43. package/dist/charts/types.d.ts +0 -40
  44. package/dist/charts/types.js +0 -1
  45. package/dist/commands/agents/index.d.ts +0 -3
  46. package/dist/commands/agents/index.js +0 -51
  47. package/dist/commands/agents/index.spec.d.ts +0 -1
  48. package/dist/commands/agents/index.spec.js +0 -67
  49. package/dist/commands/agents/selector.d.ts +0 -8
  50. package/dist/commands/agents/selector.js +0 -53
  51. package/dist/commands/agents.d.ts +0 -2
  52. package/dist/commands/agents.js +0 -53
  53. package/dist/commands/chat/index.d.ts +0 -3
  54. package/dist/commands/chat/index.js +0 -29
  55. package/dist/commands/chat.d.ts +0 -2
  56. package/dist/commands/chat.js +0 -45
  57. package/dist/commands/cluster/get.d.ts +0 -2
  58. package/dist/commands/cluster/get.js +0 -39
  59. package/dist/commands/cluster/get.spec.d.ts +0 -1
  60. package/dist/commands/cluster/get.spec.js +0 -92
  61. package/dist/commands/cluster/index.spec.d.ts +0 -1
  62. package/dist/commands/cluster/index.spec.js +0 -24
  63. package/dist/commands/completion/index.d.ts +0 -3
  64. package/dist/commands/completion/index.js +0 -268
  65. package/dist/commands/completion/index.spec.d.ts +0 -1
  66. package/dist/commands/completion/index.spec.js +0 -34
  67. package/dist/commands/config/index.d.ts +0 -3
  68. package/dist/commands/config/index.js +0 -42
  69. package/dist/commands/config/index.spec.d.ts +0 -1
  70. package/dist/commands/config/index.spec.js +0 -78
  71. package/dist/commands/dashboard/index.d.ts +0 -4
  72. package/dist/commands/dashboard/index.js +0 -39
  73. package/dist/commands/dashboard.d.ts +0 -3
  74. package/dist/commands/dashboard.js +0 -39
  75. package/dist/commands/dev/index.d.ts +0 -3
  76. package/dist/commands/dev/index.js +0 -9
  77. package/dist/commands/dev/tool/check.d.ts +0 -2
  78. package/dist/commands/dev/tool/check.js +0 -142
  79. package/dist/commands/dev/tool/clean.d.ts +0 -2
  80. package/dist/commands/dev/tool/clean.js +0 -153
  81. package/dist/commands/dev/tool/generate.d.ts +0 -2
  82. package/dist/commands/dev/tool/generate.js +0 -28
  83. package/dist/commands/dev/tool/index.d.ts +0 -2
  84. package/dist/commands/dev/tool/index.js +0 -14
  85. package/dist/commands/dev/tool/init.d.ts +0 -2
  86. package/dist/commands/dev/tool/init.js +0 -320
  87. package/dist/commands/dev/tool/shared.d.ts +0 -5
  88. package/dist/commands/dev/tool/shared.js +0 -256
  89. package/dist/commands/dev/tool/status.d.ts +0 -2
  90. package/dist/commands/dev/tool/status.js +0 -136
  91. package/dist/commands/dev/tool-generate.spec.d.ts +0 -1
  92. package/dist/commands/dev/tool-generate.spec.js +0 -163
  93. package/dist/commands/dev/tool.d.ts +0 -2
  94. package/dist/commands/dev/tool.js +0 -559
  95. package/dist/commands/dev/tool.spec.d.ts +0 -1
  96. package/dist/commands/dev/tool.spec.js +0 -48
  97. package/dist/commands/install/index.d.ts +0 -8
  98. package/dist/commands/install/index.js +0 -302
  99. package/dist/commands/install/index.spec.d.ts +0 -1
  100. package/dist/commands/install/index.spec.js +0 -135
  101. package/dist/commands/install.d.ts +0 -3
  102. package/dist/commands/install.js +0 -147
  103. package/dist/commands/models/create.d.ts +0 -1
  104. package/dist/commands/models/create.js +0 -213
  105. package/dist/commands/models/create.spec.d.ts +0 -1
  106. package/dist/commands/models/create.spec.js +0 -125
  107. package/dist/commands/models/index.d.ts +0 -3
  108. package/dist/commands/models/index.js +0 -60
  109. package/dist/commands/models/index.spec.d.ts +0 -1
  110. package/dist/commands/models/index.spec.js +0 -76
  111. package/dist/commands/models/selector.d.ts +0 -8
  112. package/dist/commands/models/selector.js +0 -53
  113. package/dist/commands/routes/index.d.ts +0 -3
  114. package/dist/commands/routes/index.js +0 -93
  115. package/dist/commands/routes.d.ts +0 -2
  116. package/dist/commands/routes.js +0 -101
  117. package/dist/commands/status/index.d.ts +0 -4
  118. package/dist/commands/status/index.js +0 -232
  119. package/dist/commands/status.d.ts +0 -3
  120. package/dist/commands/status.js +0 -33
  121. package/dist/commands/targets/index.d.ts +0 -3
  122. package/dist/commands/targets/index.js +0 -65
  123. package/dist/commands/targets/index.spec.d.ts +0 -1
  124. package/dist/commands/targets/index.spec.js +0 -105
  125. package/dist/commands/targets.d.ts +0 -2
  126. package/dist/commands/targets.js +0 -65
  127. package/dist/commands/teams/index.d.ts +0 -3
  128. package/dist/commands/teams/index.js +0 -49
  129. package/dist/commands/teams/index.spec.d.ts +0 -1
  130. package/dist/commands/teams/index.spec.js +0 -70
  131. package/dist/commands/teams/selector.d.ts +0 -8
  132. package/dist/commands/teams/selector.js +0 -55
  133. package/dist/commands/tools/index.d.ts +0 -3
  134. package/dist/commands/tools/index.js +0 -49
  135. package/dist/commands/tools/index.spec.d.ts +0 -1
  136. package/dist/commands/tools/index.spec.js +0 -70
  137. package/dist/commands/tools/selector.d.ts +0 -8
  138. package/dist/commands/tools/selector.js +0 -53
  139. package/dist/commands/uninstall/index.d.ts +0 -3
  140. package/dist/commands/uninstall/index.js +0 -107
  141. package/dist/commands/uninstall/index.spec.d.ts +0 -1
  142. package/dist/commands/uninstall/index.spec.js +0 -117
  143. package/dist/commands/uninstall.d.ts +0 -2
  144. package/dist/commands/uninstall.js +0 -83
  145. package/dist/components/ChatUI.d.ts +0 -16
  146. package/dist/components/ChatUI.js +0 -801
  147. package/dist/components/StatusView.d.ts +0 -10
  148. package/dist/components/StatusView.js +0 -39
  149. package/dist/lib/arkApiClient.d.ts +0 -53
  150. package/dist/lib/arkApiClient.js +0 -102
  151. package/dist/lib/arkApiProxy.d.ts +0 -9
  152. package/dist/lib/arkApiProxy.js +0 -22
  153. package/dist/lib/arkServiceProxy.d.ts +0 -14
  154. package/dist/lib/arkServiceProxy.js +0 -95
  155. package/dist/lib/arkStatus.d.ts +0 -10
  156. package/dist/lib/arkStatus.js +0 -79
  157. package/dist/lib/arkStatus.spec.d.ts +0 -1
  158. package/dist/lib/arkStatus.spec.js +0 -49
  159. package/dist/lib/chatClient.d.ts +0 -33
  160. package/dist/lib/chatClient.js +0 -99
  161. package/dist/lib/cluster.spec.d.ts +0 -1
  162. package/dist/lib/cluster.spec.js +0 -338
  163. package/dist/lib/commandUtils.d.ts +0 -4
  164. package/dist/lib/commandUtils.js +0 -18
  165. package/dist/lib/commandUtils.test.d.ts +0 -1
  166. package/dist/lib/commandUtils.test.js +0 -44
  167. package/dist/lib/commands.d.ts +0 -16
  168. package/dist/lib/commands.js +0 -29
  169. package/dist/lib/commands.spec.d.ts +0 -1
  170. package/dist/lib/commands.spec.js +0 -146
  171. package/dist/lib/config.spec.d.ts +0 -1
  172. package/dist/lib/config.spec.js +0 -99
  173. package/dist/lib/config.test.d.ts +0 -1
  174. package/dist/lib/config.test.js +0 -93
  175. package/dist/lib/consts.spec.d.ts +0 -1
  176. package/dist/lib/consts.spec.js +0 -15
  177. package/dist/lib/dev/tools/analyzer.d.ts +0 -30
  178. package/dist/lib/dev/tools/analyzer.js +0 -190
  179. package/dist/lib/dev/tools/discover_tools.py +0 -392
  180. package/dist/lib/dev/tools/mcp-types.d.ts +0 -28
  181. package/dist/lib/dev/tools/mcp-types.js +0 -86
  182. package/dist/lib/dev/tools/types.d.ts +0 -50
  183. package/dist/lib/dev/tools/types.js +0 -1
  184. package/dist/lib/errors.spec.d.ts +0 -1
  185. package/dist/lib/errors.spec.js +0 -221
  186. package/dist/lib/output.d.ts +0 -36
  187. package/dist/lib/output.js +0 -89
  188. package/dist/lib/output.spec.d.ts +0 -1
  189. package/dist/lib/output.spec.js +0 -123
  190. package/dist/lib/portUtils.d.ts +0 -8
  191. package/dist/lib/portUtils.js +0 -39
  192. package/dist/lib/startup.d.ts +0 -5
  193. package/dist/lib/startup.js +0 -73
  194. package/dist/lib/startup.spec.d.ts +0 -1
  195. package/dist/lib/startup.spec.js +0 -168
  196. package/dist/types/types.d.ts +0 -40
  197. package/dist/types/types.js +0 -1
  198. package/dist/ui/AgentSelector.d.ts +0 -8
  199. package/dist/ui/AgentSelector.js +0 -53
  200. package/dist/ui/ModelSelector.d.ts +0 -8
  201. package/dist/ui/ModelSelector.js +0 -53
  202. package/dist/ui/TeamSelector.d.ts +0 -8
  203. package/dist/ui/TeamSelector.js +0 -55
  204. package/dist/ui/ToolSelector.d.ts +0 -8
  205. package/dist/ui/ToolSelector.js +0 -53
  206. package/dist/ui/statusFormatter.spec.d.ts +0 -1
  207. package/dist/ui/statusFormatter.spec.js +0 -58
@@ -1,302 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { execute } from '../../lib/commands.js';
4
- import inquirer from 'inquirer';
5
- import { getClusterInfo } from '../../lib/cluster.js';
6
- import output from '../../lib/output.js';
7
- import { getInstallableServices, arkDependencies } from '../../arkServices.js';
8
- import { isArkReady } from '../../lib/arkStatus.js';
9
- import ora from 'ora';
10
- async function installService(service, verbose = false) {
11
- const helmArgs = [
12
- 'upgrade',
13
- '--install',
14
- service.helmReleaseName,
15
- service.chartPath,
16
- ];
17
- // Only add namespace flag if service has explicit namespace
18
- if (service.namespace) {
19
- helmArgs.push('--namespace', service.namespace);
20
- }
21
- // Add any additional install args
22
- helmArgs.push(...(service.installArgs || []));
23
- await execute('helm', helmArgs, { stdio: 'inherit' }, { verbose });
24
- }
25
- export async function installArk(serviceName, options = {}) {
26
- // Validate that --wait-for-ready requires -y
27
- if (options.waitForReady && !options.yes) {
28
- output.error('--wait-for-ready requires -y flag for non-interactive mode');
29
- process.exit(1);
30
- }
31
- // Check cluster connectivity
32
- const clusterInfo = await getClusterInfo();
33
- if (clusterInfo.error) {
34
- output.error('no kubernetes cluster detected');
35
- output.info('please ensure you have a running cluster and kubectl is configured.');
36
- output.info('');
37
- output.info('for local development, we recommend minikube:');
38
- output.info('• install: https://minikube.sigs.k8s.io/docs/start');
39
- output.info('• start cluster: minikube start');
40
- output.info('');
41
- output.info('alternatively, you can use kind or docker desktop.');
42
- process.exit(1);
43
- }
44
- // Show cluster info
45
- output.success(`connected to cluster: ${chalk.bold(clusterInfo.context)}`);
46
- output.info(`type: ${clusterInfo.type}`);
47
- output.info(`namespace: ${clusterInfo.namespace}`);
48
- if (clusterInfo.ip) {
49
- output.info(`ip: ${clusterInfo.ip}`);
50
- }
51
- console.log(); // Add blank line after cluster info
52
- // If a specific service is requested, install only that service
53
- if (serviceName) {
54
- const services = getInstallableServices();
55
- const service = Object.values(services).find((s) => s.name === serviceName);
56
- if (!service) {
57
- output.error(`service '${serviceName}' not found`);
58
- output.info('available services:');
59
- for (const s of Object.values(services)) {
60
- output.info(` ${s.name}`);
61
- }
62
- process.exit(1);
63
- }
64
- output.info(`installing ${service.name}...`);
65
- try {
66
- await installService(service, options.verbose);
67
- output.success(`${service.name} installed successfully`);
68
- }
69
- catch (error) {
70
- output.error(`failed to install ${service.name}`);
71
- console.error(error);
72
- process.exit(1);
73
- }
74
- return;
75
- }
76
- // If not using -y flag, show checklist interface
77
- if (!options.yes) {
78
- console.log(chalk.cyan.bold('\nSelect components to install:'));
79
- console.log(chalk.gray('Use arrow keys to navigate, space to toggle, enter to confirm\n'));
80
- // Build choices for the checkbox prompt
81
- const allChoices = [
82
- new inquirer.Separator(chalk.bold('──── Dependencies ────')),
83
- {
84
- name: `cert-manager ${chalk.gray('- Certificate management')}`,
85
- value: 'cert-manager',
86
- checked: true,
87
- },
88
- {
89
- name: `gateway-api ${chalk.gray('- Gateway API CRDs')}`,
90
- value: 'gateway-api',
91
- checked: true,
92
- },
93
- new inquirer.Separator(chalk.bold('──── Ark Core ────')),
94
- {
95
- name: `ark-controller ${chalk.gray('- Core Ark controller')}`,
96
- value: 'ark-controller',
97
- checked: true,
98
- },
99
- new inquirer.Separator(chalk.bold('──── Ark Services ────')),
100
- {
101
- name: `ark-api ${chalk.gray('- API service')}`,
102
- value: 'ark-api',
103
- checked: true,
104
- },
105
- {
106
- name: `ark-dashboard ${chalk.gray('- Web dashboard')}`,
107
- value: 'ark-dashboard',
108
- checked: true,
109
- },
110
- {
111
- name: `ark-mcp ${chalk.gray('- MCP services')}`,
112
- value: 'ark-mcp',
113
- checked: true,
114
- },
115
- {
116
- name: `localhost-gateway ${chalk.gray('- Gateway for local access')}`,
117
- value: 'localhost-gateway',
118
- checked: true,
119
- },
120
- ];
121
- let selectedComponents = [];
122
- try {
123
- const answers = await inquirer.prompt([
124
- {
125
- type: 'checkbox',
126
- name: 'components',
127
- message: 'Components to install:',
128
- choices: allChoices,
129
- pageSize: 15,
130
- },
131
- ]);
132
- selectedComponents = answers.components;
133
- if (selectedComponents.length === 0) {
134
- output.warning('No components selected. Exiting.');
135
- process.exit(0);
136
- }
137
- }
138
- catch (error) {
139
- // Handle Ctrl-C gracefully
140
- if (error && error.name === 'ExitPromptError') {
141
- console.log('\nInstallation cancelled');
142
- process.exit(130);
143
- }
144
- throw error;
145
- }
146
- // Install dependencies if selected
147
- const shouldInstallDeps = selectedComponents.includes('cert-manager') ||
148
- selectedComponents.includes('gateway-api');
149
- // Install selected dependencies
150
- if (shouldInstallDeps) {
151
- // Always install cert-manager repo and update if installing any dependency
152
- if (selectedComponents.includes('cert-manager') ||
153
- selectedComponents.includes('gateway-api')) {
154
- for (const depKey of ['cert-manager-repo', 'helm-repo-update']) {
155
- const dep = arkDependencies[depKey];
156
- output.info(`installing ${dep.description || dep.name}...`);
157
- try {
158
- await execute(dep.command, dep.args, {
159
- stdio: 'inherit',
160
- }, { verbose: options.verbose });
161
- output.success(`${dep.name} completed`);
162
- console.log();
163
- }
164
- catch {
165
- console.log();
166
- process.exit(1);
167
- }
168
- }
169
- }
170
- // Install cert-manager if selected
171
- if (selectedComponents.includes('cert-manager')) {
172
- const dep = arkDependencies['cert-manager'];
173
- output.info(`installing ${dep.description || dep.name}...`);
174
- try {
175
- await execute(dep.command, dep.args, {
176
- stdio: 'inherit',
177
- }, { verbose: options.verbose });
178
- output.success(`${dep.name} completed`);
179
- console.log();
180
- }
181
- catch {
182
- console.log();
183
- process.exit(1);
184
- }
185
- }
186
- // Install gateway-api if selected
187
- if (selectedComponents.includes('gateway-api')) {
188
- const dep = arkDependencies['gateway-api-crds'];
189
- output.info(`installing ${dep.description || dep.name}...`);
190
- try {
191
- await execute(dep.command, dep.args, {
192
- stdio: 'inherit',
193
- }, { verbose: options.verbose });
194
- output.success(`${dep.name} completed`);
195
- console.log();
196
- }
197
- catch {
198
- console.log();
199
- process.exit(1);
200
- }
201
- }
202
- }
203
- // Install selected services
204
- const services = getInstallableServices();
205
- for (const service of Object.values(services)) {
206
- // Check if this service was selected
207
- const serviceKey = service.helmReleaseName;
208
- if (!selectedComponents.includes(serviceKey)) {
209
- continue;
210
- }
211
- output.info(`installing ${service.name}...`);
212
- try {
213
- await installService(service, options.verbose);
214
- console.log(); // Add blank line after command output
215
- }
216
- catch {
217
- // Continue with remaining services on error
218
- console.log(); // Add blank line after error output
219
- }
220
- }
221
- }
222
- else {
223
- // -y flag was used, install everything
224
- // Install all dependencies
225
- for (const dep of Object.values(arkDependencies)) {
226
- output.info(`installing ${dep.description || dep.name}...`);
227
- try {
228
- await execute(dep.command, dep.args, {
229
- stdio: 'inherit',
230
- }, { verbose: options.verbose });
231
- output.success(`${dep.name} completed`);
232
- console.log(); // Add blank line after dependency
233
- }
234
- catch {
235
- console.log(); // Add blank line after error
236
- process.exit(1);
237
- }
238
- }
239
- // Install all services
240
- const services = getInstallableServices();
241
- for (const service of Object.values(services)) {
242
- output.info(`installing ${service.name}...`);
243
- try {
244
- await installService(service, options.verbose);
245
- console.log(); // Add blank line after command output
246
- }
247
- catch {
248
- // Continue with remaining services on error
249
- console.log(); // Add blank line after error output
250
- }
251
- }
252
- }
253
- // Wait for Ark to be ready if requested
254
- if (options.waitForReady) {
255
- // Parse timeout value (e.g., '30s', '2m', '60')
256
- const parseTimeout = (value) => {
257
- const match = value.match(/^(\d+)([sm])?$/);
258
- if (!match) {
259
- throw new Error('Invalid timeout format. Use format like 30s or 2m');
260
- }
261
- const num = parseInt(match[1], 10);
262
- const unit = match[2] || 's';
263
- return unit === 'm' ? num * 60 : num;
264
- };
265
- try {
266
- const timeoutSeconds = parseTimeout(options.waitForReady);
267
- const startTime = Date.now();
268
- const endTime = startTime + timeoutSeconds * 1000;
269
- const spinner = ora(`Waiting for Ark to be ready (timeout: ${timeoutSeconds}s)...`).start();
270
- while (Date.now() < endTime) {
271
- if (await isArkReady()) {
272
- spinner.succeed('Ark is ready!');
273
- return;
274
- }
275
- const elapsed = Math.floor((Date.now() - startTime) / 1000);
276
- spinner.text = `Waiting for Ark to be ready (${elapsed}/${timeoutSeconds}s)...`;
277
- // Wait 2 seconds before checking again
278
- await new Promise((resolve) => setTimeout(resolve, 2000));
279
- }
280
- // Timeout reached
281
- spinner.fail(`Ark did not become ready within ${timeoutSeconds} seconds`);
282
- process.exit(1);
283
- }
284
- catch (error) {
285
- output.error(`Failed to wait for ready: ${error instanceof Error ? error.message : 'Unknown error'}`);
286
- process.exit(1);
287
- }
288
- }
289
- }
290
- export function createInstallCommand(_) {
291
- const command = new Command('install');
292
- command
293
- .description('Install ARK components using Helm')
294
- .argument('[service]', 'specific service to install, or all if omitted')
295
- .option('-y, --yes', 'automatically confirm all installations')
296
- .option('--wait-for-ready <timeout>', 'wait for Ark to be ready after installation (e.g., 30s, 2m)')
297
- .option('-v, --verbose', 'show commands being executed')
298
- .action(async (service, options) => {
299
- await installArk(service, options);
300
- });
301
- return command;
302
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,135 +0,0 @@
1
- import { jest } from '@jest/globals';
2
- import { Command } from 'commander';
3
- const mockExeca = jest.fn(() => Promise.resolve());
4
- jest.unstable_mockModule('execa', () => ({
5
- execa: mockExeca,
6
- }));
7
- const mockGetClusterInfo = jest.fn();
8
- jest.unstable_mockModule('../../lib/cluster.js', () => ({
9
- getClusterInfo: mockGetClusterInfo,
10
- }));
11
- const mockGetInstallableServices = jest.fn();
12
- const mockArkDependencies = {};
13
- jest.unstable_mockModule('../../arkServices.js', () => ({
14
- getInstallableServices: mockGetInstallableServices,
15
- arkDependencies: mockArkDependencies,
16
- }));
17
- const mockOutput = {
18
- error: jest.fn(),
19
- info: jest.fn(),
20
- success: jest.fn(),
21
- warning: jest.fn(),
22
- };
23
- jest.unstable_mockModule('../../lib/output.js', () => ({
24
- default: mockOutput,
25
- }));
26
- const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {
27
- throw new Error('process.exit called');
28
- }));
29
- jest.spyOn(console, 'log').mockImplementation(() => { });
30
- jest.spyOn(console, 'error').mockImplementation(() => { });
31
- const { createInstallCommand } = await import('./index.js');
32
- describe('install command', () => {
33
- beforeEach(() => {
34
- jest.clearAllMocks();
35
- mockGetClusterInfo.mockResolvedValue({
36
- context: 'test-cluster',
37
- type: 'minikube',
38
- namespace: 'default',
39
- });
40
- });
41
- it('creates command with correct structure', () => {
42
- const command = createInstallCommand({});
43
- expect(command).toBeInstanceOf(Command);
44
- expect(command.name()).toBe('install');
45
- });
46
- it('installs single service with correct helm parameters', async () => {
47
- const mockService = {
48
- name: 'ark-api',
49
- helmReleaseName: 'ark-api',
50
- chartPath: './charts/ark-api',
51
- namespace: 'ark-system',
52
- installArgs: ['--set', 'image.tag=latest'],
53
- };
54
- mockGetInstallableServices.mockReturnValue({
55
- 'ark-api': mockService,
56
- });
57
- const command = createInstallCommand({});
58
- await command.parseAsync(['node', 'test', 'ark-api']);
59
- expect(mockExeca).toHaveBeenCalledWith('helm', [
60
- 'upgrade',
61
- '--install',
62
- 'ark-api',
63
- './charts/ark-api',
64
- '--namespace',
65
- 'ark-system',
66
- '--set',
67
- 'image.tag=latest',
68
- ], { stdio: 'inherit' });
69
- expect(mockOutput.success).toHaveBeenCalledWith('ark-api installed successfully');
70
- });
71
- it('shows error when service not found', async () => {
72
- mockGetInstallableServices.mockReturnValue({
73
- 'ark-api': { name: 'ark-api' },
74
- 'ark-controller': { name: 'ark-controller' },
75
- });
76
- const command = createInstallCommand({});
77
- await expect(command.parseAsync(['node', 'test', 'invalid-service'])).rejects.toThrow('process.exit called');
78
- expect(mockOutput.error).toHaveBeenCalledWith("service 'invalid-service' not found");
79
- expect(mockOutput.info).toHaveBeenCalledWith('available services:');
80
- expect(mockOutput.info).toHaveBeenCalledWith(' ark-api');
81
- expect(mockOutput.info).toHaveBeenCalledWith(' ark-controller');
82
- expect(mockExit).toHaveBeenCalledWith(1);
83
- });
84
- it('handles service without namespace (uses current context)', async () => {
85
- const mockService = {
86
- name: 'ark-dashboard',
87
- helmReleaseName: 'ark-dashboard',
88
- chartPath: './charts/ark-dashboard',
89
- // namespace is undefined - should use current context
90
- installArgs: ['--set', 'replicas=2'],
91
- };
92
- mockGetInstallableServices.mockReturnValue({
93
- 'ark-dashboard': mockService,
94
- });
95
- const command = createInstallCommand({});
96
- await command.parseAsync(['node', 'test', 'ark-dashboard']);
97
- // Should NOT include --namespace flag
98
- expect(mockExeca).toHaveBeenCalledWith('helm', [
99
- 'upgrade',
100
- '--install',
101
- 'ark-dashboard',
102
- './charts/ark-dashboard',
103
- '--set',
104
- 'replicas=2',
105
- ], { stdio: 'inherit' });
106
- });
107
- it('handles service without installArgs', async () => {
108
- const mockService = {
109
- name: 'simple-service',
110
- helmReleaseName: 'simple-service',
111
- chartPath: './charts/simple',
112
- namespace: 'default',
113
- };
114
- mockGetInstallableServices.mockReturnValue({
115
- 'simple-service': mockService,
116
- });
117
- const command = createInstallCommand({});
118
- await command.parseAsync(['node', 'test', 'simple-service']);
119
- expect(mockExeca).toHaveBeenCalledWith('helm', [
120
- 'upgrade',
121
- '--install',
122
- 'simple-service',
123
- './charts/simple',
124
- '--namespace',
125
- 'default',
126
- ], { stdio: 'inherit' });
127
- });
128
- it('exits when cluster not connected', async () => {
129
- mockGetClusterInfo.mockResolvedValue({ error: true });
130
- const command = createInstallCommand({});
131
- await expect(command.parseAsync(['node', 'test', 'ark-api'])).rejects.toThrow('process.exit called');
132
- expect(mockOutput.error).toHaveBeenCalledWith('no kubernetes cluster detected');
133
- expect(mockExit).toHaveBeenCalledWith(1);
134
- });
135
- });
@@ -1,3 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function installArk(): Promise<void>;
3
- export declare function createInstallCommand(): Command;
@@ -1,147 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { execa } from 'execa';
4
- import inquirer from 'inquirer';
5
- import { isCommandAvailable } from '../lib/commandUtils.js';
6
- import { getClusterInfo } from '../lib/cluster.js';
7
- import output from '../lib/output.js';
8
- import { getInstallableServices, arkDependencies } from '../arkServices.js';
9
- import { createModel } from './models/create.js';
10
- export async function installArk() {
11
- // Check if helm is installed
12
- const helmInstalled = await isCommandAvailable('helm');
13
- if (!helmInstalled) {
14
- output.error('helm is not installed. please install helm first:');
15
- output.info('https://helm.sh/docs/intro/install/');
16
- process.exit(1);
17
- }
18
- // Check if kubectl is installed (needed for some dependencies)
19
- const kubectlInstalled = await isCommandAvailable('kubectl');
20
- if (!kubectlInstalled) {
21
- output.error('kubectl is not installed. please install kubectl first:');
22
- output.info('https://kubernetes.io/docs/tasks/tools/');
23
- process.exit(1);
24
- }
25
- // Check cluster connectivity
26
- const clusterInfo = await getClusterInfo();
27
- if (clusterInfo.error) {
28
- output.error('no kubernetes cluster detected');
29
- output.info('please ensure you have a running cluster and kubectl is configured.');
30
- output.info('');
31
- output.info('for local development, we recommend minikube:');
32
- output.info('• install: https://minikube.sigs.k8s.io/docs/start');
33
- output.info('• start cluster: minikube start');
34
- output.info('');
35
- output.info('alternatively, you can use kind or docker desktop.');
36
- process.exit(1);
37
- }
38
- // Show cluster info
39
- output.success(`connected to cluster: ${chalk.bold(clusterInfo.context)}`);
40
- output.info(`type: ${clusterInfo.type}`);
41
- output.info(`namespace: ${clusterInfo.namespace}`);
42
- if (clusterInfo.ip) {
43
- output.info(`ip: ${clusterInfo.ip}`);
44
- }
45
- console.log(); // Add blank line after cluster info
46
- // Ask about installing dependencies
47
- const { shouldInstallDeps } = await inquirer.prompt([
48
- {
49
- type: 'confirm',
50
- name: 'shouldInstallDeps',
51
- message: 'install required dependencies (cert-manager, gateway api)?',
52
- default: true,
53
- },
54
- ]);
55
- if (shouldInstallDeps) {
56
- for (const dep of Object.values(arkDependencies)) {
57
- output.info(`installing ${dep.description || dep.name}...`);
58
- try {
59
- await execa(dep.command, dep.args, {
60
- stdio: 'inherit',
61
- });
62
- output.success(`${dep.name} completed`);
63
- console.log(); // Add blank line after dependency
64
- }
65
- catch {
66
- console.log(); // Add blank line after error
67
- process.exit(1);
68
- }
69
- }
70
- }
71
- // Get installable services and iterate through them
72
- const services = getInstallableServices();
73
- for (const service of Object.values(services)) {
74
- // Ask for confirmation
75
- const { shouldInstall } = await inquirer.prompt([
76
- {
77
- type: 'confirm',
78
- name: 'shouldInstall',
79
- message: `install ${chalk.bold(service.name)}? ${service.description ? chalk.gray(`(${service.description.toLowerCase()})`) : ''}`,
80
- default: true,
81
- },
82
- ]);
83
- if (!shouldInstall) {
84
- output.warning(`skipping ${service.name}`);
85
- continue;
86
- }
87
- try {
88
- // Build helm arguments
89
- const helmArgs = [
90
- 'upgrade',
91
- '--install',
92
- service.helmReleaseName,
93
- service.chartPath,
94
- '--namespace',
95
- service.namespace,
96
- ];
97
- // Add any additional args from the service definition
98
- if (service.installArgs) {
99
- helmArgs.push(...service.installArgs);
100
- }
101
- // Run helm upgrade --install with streaming output
102
- await execa('helm', helmArgs, {
103
- stdio: 'inherit',
104
- });
105
- console.log(); // Add blank line after command output
106
- }
107
- catch {
108
- // Continue with remaining services on error
109
- console.log(); // Add blank line after error output
110
- }
111
- }
112
- // Check for default model after installing services
113
- output.info('checking for default model...');
114
- let modelExists = false;
115
- try {
116
- await execa('kubectl', ['get', 'model', 'default'], { stdio: 'pipe' });
117
- modelExists = true;
118
- output.success('default model already configured');
119
- }
120
- catch {
121
- output.warning('no default model found');
122
- }
123
- if (!modelExists) {
124
- const { shouldCreateModel } = await inquirer.prompt([
125
- {
126
- type: 'confirm',
127
- name: 'shouldCreateModel',
128
- message: 'would you like to create a default model?',
129
- default: true,
130
- },
131
- ]);
132
- if (shouldCreateModel) {
133
- await createModel('default');
134
- }
135
- else {
136
- output.warning('skipping model creation');
137
- output.info('you can create a model later using ark models create or the dashboard');
138
- }
139
- }
140
- }
141
- export function createInstallCommand() {
142
- const command = new Command('install');
143
- command.description('Install ARK components using Helm').action(async () => {
144
- await installArk();
145
- });
146
- return command;
147
- }
@@ -1 +0,0 @@
1
- export declare function createModel(modelName?: string): Promise<boolean>;