@agents-at-scale/ark 0.1.35 → 0.1.36

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 (167) hide show
  1. package/dist/arkServices.d.ts +42 -0
  2. package/dist/arkServices.js +138 -0
  3. package/dist/arkServices.spec.d.ts +1 -0
  4. package/dist/arkServices.spec.js +24 -0
  5. package/dist/commands/agents/index.d.ts +3 -0
  6. package/dist/commands/agents/index.js +65 -0
  7. package/dist/commands/agents/index.spec.d.ts +1 -0
  8. package/dist/commands/agents/index.spec.js +67 -0
  9. package/dist/commands/chat/index.d.ts +3 -0
  10. package/dist/commands/chat/index.js +29 -0
  11. package/dist/commands/cluster/get.d.ts +2 -0
  12. package/dist/commands/cluster/get.js +39 -0
  13. package/dist/commands/cluster/get.spec.d.ts +1 -0
  14. package/dist/commands/cluster/get.spec.js +92 -0
  15. package/dist/commands/cluster/index.d.ts +2 -1
  16. package/dist/commands/cluster/index.js +3 -5
  17. package/dist/commands/cluster/index.spec.d.ts +1 -0
  18. package/dist/commands/cluster/index.spec.js +24 -0
  19. package/dist/commands/completion/index.d.ts +3 -0
  20. package/dist/commands/completion/index.js +230 -0
  21. package/dist/commands/completion/index.spec.d.ts +1 -0
  22. package/dist/commands/completion/index.spec.js +34 -0
  23. package/dist/commands/config/index.d.ts +3 -0
  24. package/dist/commands/config/index.js +42 -0
  25. package/dist/commands/config/index.spec.d.ts +1 -0
  26. package/dist/commands/config/index.spec.js +78 -0
  27. package/dist/commands/dashboard/index.d.ts +4 -0
  28. package/dist/commands/dashboard/index.js +39 -0
  29. package/dist/commands/docs/index.d.ts +4 -0
  30. package/dist/commands/docs/index.js +18 -0
  31. package/dist/commands/generate/config.js +5 -24
  32. package/dist/commands/generate/generators/mcpserver.d.ts +2 -1
  33. package/dist/commands/generate/generators/mcpserver.js +26 -5
  34. package/dist/commands/generate/generators/project.js +22 -41
  35. package/dist/commands/generate/index.d.ts +2 -1
  36. package/dist/commands/generate/index.js +1 -1
  37. package/dist/commands/install/index.d.ts +8 -0
  38. package/dist/commands/install/index.js +295 -0
  39. package/dist/commands/install/index.spec.d.ts +1 -0
  40. package/dist/commands/install/index.spec.js +143 -0
  41. package/dist/commands/models/create.d.ts +1 -0
  42. package/dist/commands/models/create.js +213 -0
  43. package/dist/commands/models/create.spec.d.ts +1 -0
  44. package/dist/commands/models/create.spec.js +125 -0
  45. package/dist/commands/models/index.d.ts +3 -0
  46. package/dist/commands/models/index.js +75 -0
  47. package/dist/commands/models/index.spec.d.ts +1 -0
  48. package/dist/commands/models/index.spec.js +96 -0
  49. package/dist/commands/query/index.d.ts +3 -0
  50. package/dist/commands/query/index.js +24 -0
  51. package/dist/commands/query/index.spec.d.ts +1 -0
  52. package/dist/commands/query/index.spec.js +53 -0
  53. package/dist/commands/routes/index.d.ts +3 -0
  54. package/dist/commands/routes/index.js +93 -0
  55. package/dist/commands/status/index.d.ts +3 -0
  56. package/dist/commands/status/index.js +281 -0
  57. package/dist/commands/targets/index.d.ts +3 -0
  58. package/dist/commands/targets/index.js +72 -0
  59. package/dist/commands/targets/index.spec.d.ts +1 -0
  60. package/dist/commands/targets/index.spec.js +154 -0
  61. package/dist/commands/teams/index.d.ts +3 -0
  62. package/dist/commands/teams/index.js +64 -0
  63. package/dist/commands/teams/index.spec.d.ts +1 -0
  64. package/dist/commands/teams/index.spec.js +70 -0
  65. package/dist/commands/tools/index.d.ts +3 -0
  66. package/dist/commands/tools/index.js +49 -0
  67. package/dist/commands/tools/index.spec.d.ts +1 -0
  68. package/dist/commands/tools/index.spec.js +70 -0
  69. package/dist/commands/uninstall/index.d.ts +3 -0
  70. package/dist/commands/uninstall/index.js +101 -0
  71. package/dist/commands/uninstall/index.spec.d.ts +1 -0
  72. package/dist/commands/uninstall/index.spec.js +125 -0
  73. package/dist/components/ChatUI.d.ts +16 -0
  74. package/dist/components/ChatUI.js +801 -0
  75. package/dist/components/statusChecker.d.ts +14 -24
  76. package/dist/components/statusChecker.js +295 -129
  77. package/dist/index.d.ts +1 -1
  78. package/dist/index.js +42 -42
  79. package/dist/lib/arkApiClient.d.ts +53 -0
  80. package/dist/lib/arkApiClient.js +102 -0
  81. package/dist/lib/arkApiProxy.d.ts +9 -0
  82. package/dist/lib/arkApiProxy.js +22 -0
  83. package/dist/lib/arkServiceProxy.d.ts +14 -0
  84. package/dist/lib/arkServiceProxy.js +95 -0
  85. package/dist/lib/arkStatus.d.ts +10 -0
  86. package/dist/lib/arkStatus.js +79 -0
  87. package/dist/lib/arkStatus.spec.d.ts +1 -0
  88. package/dist/lib/arkStatus.spec.js +49 -0
  89. package/dist/lib/chatClient.d.ts +33 -0
  90. package/dist/lib/chatClient.js +93 -0
  91. package/dist/lib/cluster.d.ts +2 -1
  92. package/dist/lib/cluster.js +37 -16
  93. package/dist/lib/cluster.spec.d.ts +1 -0
  94. package/dist/lib/cluster.spec.js +338 -0
  95. package/dist/lib/commands.d.ts +16 -0
  96. package/dist/lib/commands.js +29 -0
  97. package/dist/lib/commands.spec.d.ts +1 -0
  98. package/dist/lib/commands.spec.js +146 -0
  99. package/dist/lib/config.d.ts +26 -80
  100. package/dist/lib/config.js +70 -205
  101. package/dist/lib/config.spec.d.ts +1 -0
  102. package/dist/lib/config.spec.js +99 -0
  103. package/dist/lib/errors.js +1 -1
  104. package/dist/lib/errors.spec.d.ts +1 -0
  105. package/dist/lib/errors.spec.js +221 -0
  106. package/dist/lib/executeQuery.d.ts +20 -0
  107. package/dist/lib/executeQuery.js +135 -0
  108. package/dist/lib/executeQuery.spec.d.ts +1 -0
  109. package/dist/lib/executeQuery.spec.js +170 -0
  110. package/dist/lib/nextSteps.d.ts +4 -0
  111. package/dist/lib/nextSteps.js +20 -0
  112. package/dist/lib/nextSteps.spec.d.ts +1 -0
  113. package/dist/lib/nextSteps.spec.js +59 -0
  114. package/dist/lib/output.d.ts +36 -0
  115. package/dist/lib/output.js +89 -0
  116. package/dist/lib/output.spec.d.ts +1 -0
  117. package/dist/lib/output.spec.js +123 -0
  118. package/dist/lib/startup.d.ts +9 -0
  119. package/dist/lib/startup.js +87 -0
  120. package/dist/lib/startup.spec.d.ts +1 -0
  121. package/dist/lib/startup.spec.js +152 -0
  122. package/dist/lib/types.d.ts +87 -3
  123. package/dist/lib/versions.d.ts +23 -0
  124. package/dist/lib/versions.js +51 -0
  125. package/dist/types/types.d.ts +40 -0
  126. package/dist/types/types.js +1 -0
  127. package/dist/ui/AgentSelector.d.ts +8 -0
  128. package/dist/ui/AgentSelector.js +53 -0
  129. package/dist/ui/MainMenu.d.ts +5 -1
  130. package/dist/ui/MainMenu.js +226 -91
  131. package/dist/ui/ModelSelector.d.ts +8 -0
  132. package/dist/ui/ModelSelector.js +53 -0
  133. package/dist/ui/TeamSelector.d.ts +8 -0
  134. package/dist/ui/TeamSelector.js +55 -0
  135. package/dist/ui/ToolSelector.d.ts +8 -0
  136. package/dist/ui/ToolSelector.js +53 -0
  137. package/dist/ui/statusFormatter.d.ts +22 -7
  138. package/dist/ui/statusFormatter.js +39 -39
  139. package/dist/ui/statusFormatter.spec.d.ts +1 -0
  140. package/dist/ui/statusFormatter.spec.js +58 -0
  141. package/package.json +16 -5
  142. package/dist/commands/cluster/get-ip.d.ts +0 -2
  143. package/dist/commands/cluster/get-ip.js +0 -32
  144. package/dist/commands/cluster/get-type.d.ts +0 -2
  145. package/dist/commands/cluster/get-type.js +0 -26
  146. package/dist/commands/completion.d.ts +0 -2
  147. package/dist/commands/completion.js +0 -108
  148. package/dist/commands/config.d.ts +0 -5
  149. package/dist/commands/config.js +0 -327
  150. package/dist/components/DashboardCLI.d.ts +0 -3
  151. package/dist/components/DashboardCLI.js +0 -149
  152. package/dist/config.d.ts +0 -42
  153. package/dist/config.js +0 -243
  154. package/dist/lib/arkClient.d.ts +0 -32
  155. package/dist/lib/arkClient.js +0 -43
  156. package/dist/lib/consts.d.ts +0 -10
  157. package/dist/lib/consts.js +0 -15
  158. package/dist/lib/exec.d.ts +0 -5
  159. package/dist/lib/exec.js +0 -20
  160. package/dist/lib/gatewayManager.d.ts +0 -24
  161. package/dist/lib/gatewayManager.js +0 -85
  162. package/dist/lib/kubernetes.d.ts +0 -28
  163. package/dist/lib/kubernetes.js +0 -122
  164. package/dist/lib/progress.d.ts +0 -128
  165. package/dist/lib/progress.js +0 -273
  166. package/dist/lib/wrappers/git.d.ts +0 -2
  167. package/dist/lib/wrappers/git.js +0 -43
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ import { jest } from '@jest/globals';
2
+ import { Command } from 'commander';
3
+ const mockExeca = jest.fn();
4
+ jest.unstable_mockModule('execa', () => ({
5
+ execa: mockExeca,
6
+ }));
7
+ const mockOutput = {
8
+ info: jest.fn(),
9
+ error: jest.fn(),
10
+ };
11
+ jest.unstable_mockModule('../../lib/output.js', () => ({
12
+ default: mockOutput,
13
+ }));
14
+ const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {
15
+ throw new Error('process.exit called');
16
+ }));
17
+ const mockConsoleLog = jest.spyOn(console, 'log').mockImplementation(() => { });
18
+ const { createTeamsCommand } = await import('./index.js');
19
+ describe('teams command', () => {
20
+ beforeEach(() => {
21
+ jest.clearAllMocks();
22
+ });
23
+ it('creates command with correct structure', () => {
24
+ const command = createTeamsCommand({});
25
+ expect(command).toBeInstanceOf(Command);
26
+ expect(command.name()).toBe('teams');
27
+ });
28
+ it('lists teams in text format', async () => {
29
+ const mockTeams = {
30
+ items: [
31
+ { metadata: { name: 'engineering' } },
32
+ { metadata: { name: 'data-science' } },
33
+ ],
34
+ };
35
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify(mockTeams) });
36
+ const command = createTeamsCommand({});
37
+ await command.parseAsync(['node', 'test']);
38
+ expect(mockExeca).toHaveBeenCalledWith('kubectl', ['get', 'teams', '-o', 'json'], { stdio: 'pipe' });
39
+ expect(mockConsoleLog).toHaveBeenCalledWith('engineering');
40
+ expect(mockConsoleLog).toHaveBeenCalledWith('data-science');
41
+ });
42
+ it('lists teams in json format', async () => {
43
+ const mockTeams = {
44
+ items: [{ metadata: { name: 'engineering' } }],
45
+ };
46
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify(mockTeams) });
47
+ const command = createTeamsCommand({});
48
+ await command.parseAsync(['node', 'test', '-o', 'json']);
49
+ expect(mockConsoleLog).toHaveBeenCalledWith(JSON.stringify(mockTeams.items, null, 2));
50
+ });
51
+ it('shows info when no teams', async () => {
52
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify({ items: [] }) });
53
+ const command = createTeamsCommand({});
54
+ await command.parseAsync(['node', 'test']);
55
+ expect(mockOutput.info).toHaveBeenCalledWith('No teams found');
56
+ });
57
+ it('handles errors', async () => {
58
+ mockExeca.mockRejectedValue(new Error('kubectl failed'));
59
+ const command = createTeamsCommand({});
60
+ await expect(command.parseAsync(['node', 'test'])).rejects.toThrow('process.exit called');
61
+ expect(mockOutput.error).toHaveBeenCalledWith('fetching teams:', 'kubectl failed');
62
+ expect(mockExit).toHaveBeenCalledWith(1);
63
+ });
64
+ it('list subcommand works', async () => {
65
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify({ items: [] }) });
66
+ const command = createTeamsCommand({});
67
+ await command.parseAsync(['node', 'test', 'list']);
68
+ expect(mockExeca).toHaveBeenCalled();
69
+ });
70
+ });
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ import type { ArkConfig } from '../../lib/config.js';
3
+ export declare function createToolsCommand(_: ArkConfig): Command;
@@ -0,0 +1,49 @@
1
+ import { Command } from 'commander';
2
+ import { execa } from 'execa';
3
+ import output from '../../lib/output.js';
4
+ async function listTools(options) {
5
+ try {
6
+ // Use kubectl to get tools (MCPServers)
7
+ const result = await execa('kubectl', ['get', 'mcpservers', '-o', 'json'], {
8
+ stdio: 'pipe',
9
+ });
10
+ const data = JSON.parse(result.stdout);
11
+ const tools = data.items || [];
12
+ if (options.output === 'json') {
13
+ // Output the raw items for JSON format
14
+ console.log(JSON.stringify(tools, null, 2));
15
+ }
16
+ else {
17
+ if (tools.length === 0) {
18
+ output.info('No tools found');
19
+ return;
20
+ }
21
+ tools.forEach((tool) => {
22
+ console.log(tool.metadata.name);
23
+ });
24
+ }
25
+ }
26
+ catch (error) {
27
+ output.error('fetching tools:', error instanceof Error ? error.message : error);
28
+ process.exit(1);
29
+ }
30
+ }
31
+ export function createToolsCommand(_) {
32
+ const toolsCommand = new Command('tools');
33
+ toolsCommand
34
+ .description('List available tools')
35
+ .option('-o, --output <format>', 'Output format (json)', 'text')
36
+ .action(async (options) => {
37
+ await listTools(options);
38
+ });
39
+ const listCommand = new Command('list');
40
+ listCommand
41
+ .alias('ls')
42
+ .description('List available tools')
43
+ .option('-o, --output <format>', 'Output format (json)', 'text')
44
+ .action(async (options) => {
45
+ await listTools(options);
46
+ });
47
+ toolsCommand.addCommand(listCommand);
48
+ return toolsCommand;
49
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ import { jest } from '@jest/globals';
2
+ import { Command } from 'commander';
3
+ const mockExeca = jest.fn();
4
+ jest.unstable_mockModule('execa', () => ({
5
+ execa: mockExeca,
6
+ }));
7
+ const mockOutput = {
8
+ info: jest.fn(),
9
+ error: jest.fn(),
10
+ };
11
+ jest.unstable_mockModule('../../lib/output.js', () => ({
12
+ default: mockOutput,
13
+ }));
14
+ const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {
15
+ throw new Error('process.exit called');
16
+ }));
17
+ const mockConsoleLog = jest.spyOn(console, 'log').mockImplementation(() => { });
18
+ const { createToolsCommand } = await import('./index.js');
19
+ describe('tools command', () => {
20
+ beforeEach(() => {
21
+ jest.clearAllMocks();
22
+ });
23
+ it('creates command with correct structure', () => {
24
+ const command = createToolsCommand({});
25
+ expect(command).toBeInstanceOf(Command);
26
+ expect(command.name()).toBe('tools');
27
+ });
28
+ it('lists tools in text format', async () => {
29
+ const mockTools = {
30
+ items: [
31
+ { metadata: { name: 'github-mcp' } },
32
+ { metadata: { name: 'slack-mcp' } },
33
+ ],
34
+ };
35
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify(mockTools) });
36
+ const command = createToolsCommand({});
37
+ await command.parseAsync(['node', 'test']);
38
+ expect(mockExeca).toHaveBeenCalledWith('kubectl', ['get', 'mcpservers', '-o', 'json'], { stdio: 'pipe' });
39
+ expect(mockConsoleLog).toHaveBeenCalledWith('github-mcp');
40
+ expect(mockConsoleLog).toHaveBeenCalledWith('slack-mcp');
41
+ });
42
+ it('lists tools in json format', async () => {
43
+ const mockTools = {
44
+ items: [{ metadata: { name: 'github-mcp' } }],
45
+ };
46
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify(mockTools) });
47
+ const command = createToolsCommand({});
48
+ await command.parseAsync(['node', 'test', '-o', 'json']);
49
+ expect(mockConsoleLog).toHaveBeenCalledWith(JSON.stringify(mockTools.items, null, 2));
50
+ });
51
+ it('shows info when no tools', async () => {
52
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify({ items: [] }) });
53
+ const command = createToolsCommand({});
54
+ await command.parseAsync(['node', 'test']);
55
+ expect(mockOutput.info).toHaveBeenCalledWith('No tools found');
56
+ });
57
+ it('handles errors', async () => {
58
+ mockExeca.mockRejectedValue(new Error('kubectl failed'));
59
+ const command = createToolsCommand({});
60
+ await expect(command.parseAsync(['node', 'test'])).rejects.toThrow('process.exit called');
61
+ expect(mockOutput.error).toHaveBeenCalledWith('fetching tools:', 'kubectl failed');
62
+ expect(mockExit).toHaveBeenCalledWith(1);
63
+ });
64
+ it('list subcommand works', async () => {
65
+ mockExeca.mockResolvedValue({ stdout: JSON.stringify({ items: [] }) });
66
+ const command = createToolsCommand({});
67
+ await command.parseAsync(['node', 'test', 'list']);
68
+ expect(mockExeca).toHaveBeenCalled();
69
+ });
70
+ });
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ import type { ArkConfig } from '../../lib/config.js';
3
+ export declare function createUninstallCommand(config: ArkConfig): Command;
@@ -0,0 +1,101 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { execute } from '../../lib/commands.js';
4
+ import inquirer from 'inquirer';
5
+ import { showNoClusterError } from '../../lib/startup.js';
6
+ import output from '../../lib/output.js';
7
+ import { getInstallableServices } from '../../arkServices.js';
8
+ async function uninstallService(service, verbose = false) {
9
+ const helmArgs = ['uninstall', service.helmReleaseName, '--ignore-not-found'];
10
+ // Only add namespace flag if service has explicit namespace
11
+ if (service.namespace) {
12
+ helmArgs.push('--namespace', service.namespace);
13
+ }
14
+ await execute('helm', helmArgs, { stdio: 'inherit' }, { verbose });
15
+ }
16
+ async function uninstallArk(config, serviceName, options = {}) {
17
+ // Check cluster connectivity from config
18
+ if (!config.clusterInfo) {
19
+ showNoClusterError();
20
+ process.exit(1);
21
+ }
22
+ const clusterInfo = config.clusterInfo;
23
+ // Show cluster info
24
+ output.success(`connected to cluster: ${chalk.bold(clusterInfo.context)}`);
25
+ console.log(); // Add blank line after cluster info
26
+ // If a specific service is requested, uninstall only that service
27
+ if (serviceName) {
28
+ const services = getInstallableServices();
29
+ const service = Object.values(services).find((s) => s.name === serviceName);
30
+ if (!service) {
31
+ output.error(`service '${serviceName}' not found`);
32
+ output.info('available services:');
33
+ for (const s of Object.values(services)) {
34
+ output.info(` ${s.name}`);
35
+ }
36
+ process.exit(1);
37
+ }
38
+ output.info(`uninstalling ${service.name}...`);
39
+ try {
40
+ await uninstallService(service, options.verbose);
41
+ output.success(`${service.name} uninstalled successfully`);
42
+ }
43
+ catch (error) {
44
+ output.error(`failed to uninstall ${service.name}`);
45
+ console.error(error);
46
+ process.exit(1);
47
+ }
48
+ return;
49
+ }
50
+ // Get installable services and iterate through them in reverse order for clean uninstall
51
+ const services = getInstallableServices();
52
+ const serviceEntries = Object.entries(services).reverse();
53
+ for (const [, service] of serviceEntries) {
54
+ let shouldUninstall = false;
55
+ try {
56
+ // Ask for confirmation
57
+ shouldUninstall =
58
+ options.yes ||
59
+ (await inquirer.prompt([
60
+ {
61
+ type: 'confirm',
62
+ name: 'shouldUninstall',
63
+ message: `uninstall ${chalk.bold(service.name)}? ${service.description ? chalk.gray(`(${service.description.toLowerCase()})`) : ''}`,
64
+ default: true,
65
+ },
66
+ ])).shouldUninstall;
67
+ }
68
+ catch (error) {
69
+ // Handle Ctrl-C gracefully
70
+ if (error && error.name === 'ExitPromptError') {
71
+ console.log('\nUninstallation cancelled');
72
+ process.exit(130); // Standard exit code for SIGINT
73
+ }
74
+ throw error;
75
+ }
76
+ if (!shouldUninstall) {
77
+ output.warning(`skipping ${service.name}`);
78
+ continue;
79
+ }
80
+ try {
81
+ await uninstallService(service, options.verbose);
82
+ console.log(); // Add blank line after command output
83
+ }
84
+ catch {
85
+ // Continue with remaining charts on error
86
+ console.log(); // Add blank line after error output
87
+ }
88
+ }
89
+ }
90
+ export function createUninstallCommand(config) {
91
+ const command = new Command('uninstall');
92
+ command
93
+ .description('Uninstall ARK components using Helm')
94
+ .argument('[service]', 'specific service to uninstall, or all if omitted')
95
+ .option('-y, --yes', 'automatically confirm all uninstallations')
96
+ .option('-v, --verbose', 'show commands being executed')
97
+ .action(async (service, options) => {
98
+ await uninstallArk(config, service, options);
99
+ });
100
+ return command;
101
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,125 @@
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 mockArkServices = {};
13
+ jest.unstable_mockModule('../../arkServices.js', () => ({
14
+ getInstallableServices: mockGetInstallableServices,
15
+ arkServices: mockArkServices,
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 { createUninstallCommand } = await import('./index.js');
32
+ describe('uninstall command', () => {
33
+ const mockConfig = {
34
+ clusterInfo: {
35
+ context: 'test-cluster',
36
+ type: 'minikube',
37
+ namespace: 'default',
38
+ },
39
+ };
40
+ beforeEach(() => {
41
+ jest.clearAllMocks();
42
+ mockGetClusterInfo.mockResolvedValue({
43
+ context: 'test-cluster',
44
+ type: 'minikube',
45
+ namespace: 'default',
46
+ });
47
+ });
48
+ it('creates command with correct structure', () => {
49
+ const command = createUninstallCommand(mockConfig);
50
+ expect(command).toBeInstanceOf(Command);
51
+ expect(command.name()).toBe('uninstall');
52
+ });
53
+ it('uninstalls single service with correct helm parameters', async () => {
54
+ const mockService = {
55
+ name: 'ark-api',
56
+ helmReleaseName: 'ark-api',
57
+ namespace: 'ark-system',
58
+ };
59
+ mockGetInstallableServices.mockReturnValue({
60
+ 'ark-api': mockService,
61
+ });
62
+ const command = createUninstallCommand(mockConfig);
63
+ await command.parseAsync(['node', 'test', 'ark-api']);
64
+ expect(mockExeca).toHaveBeenCalledWith('helm', [
65
+ 'uninstall',
66
+ 'ark-api',
67
+ '--ignore-not-found',
68
+ '--namespace',
69
+ 'ark-system',
70
+ ], {
71
+ stdio: 'inherit',
72
+ });
73
+ expect(mockOutput.success).toHaveBeenCalledWith('ark-api uninstalled successfully');
74
+ });
75
+ it('shows error when service not found', async () => {
76
+ mockGetInstallableServices.mockReturnValue({
77
+ 'ark-api': { name: 'ark-api' },
78
+ 'ark-controller': { name: 'ark-controller' },
79
+ });
80
+ const command = createUninstallCommand(mockConfig);
81
+ await expect(command.parseAsync(['node', 'test', 'invalid-service'])).rejects.toThrow('process.exit called');
82
+ expect(mockOutput.error).toHaveBeenCalledWith("service 'invalid-service' not found");
83
+ expect(mockOutput.info).toHaveBeenCalledWith('available services:');
84
+ expect(mockOutput.info).toHaveBeenCalledWith(' ark-api');
85
+ expect(mockOutput.info).toHaveBeenCalledWith(' ark-controller');
86
+ expect(mockExit).toHaveBeenCalledWith(1);
87
+ });
88
+ it('handles service without namespace (uses current context)', async () => {
89
+ const mockService = {
90
+ name: 'ark-dashboard',
91
+ helmReleaseName: 'ark-dashboard',
92
+ // namespace is undefined - should use current context
93
+ };
94
+ mockGetInstallableServices.mockReturnValue({
95
+ 'ark-dashboard': mockService,
96
+ });
97
+ const command = createUninstallCommand(mockConfig);
98
+ await command.parseAsync(['node', 'test', 'ark-dashboard']);
99
+ // Should NOT include --namespace flag
100
+ expect(mockExeca).toHaveBeenCalledWith('helm', ['uninstall', 'ark-dashboard', '--ignore-not-found'], {
101
+ stdio: 'inherit',
102
+ });
103
+ });
104
+ it('handles helm uninstall error gracefully', async () => {
105
+ const mockService = {
106
+ name: 'ark-api',
107
+ helmReleaseName: 'ark-api',
108
+ namespace: 'ark-system',
109
+ };
110
+ mockGetInstallableServices.mockReturnValue({
111
+ 'ark-api': mockService,
112
+ });
113
+ mockExeca.mockRejectedValue(new Error('helm failed'));
114
+ const command = createUninstallCommand(mockConfig);
115
+ await expect(command.parseAsync(['node', 'test', 'ark-api'])).rejects.toThrow('process.exit called');
116
+ expect(mockOutput.error).toHaveBeenCalledWith('failed to uninstall ark-api');
117
+ expect(mockExit).toHaveBeenCalledWith(1);
118
+ });
119
+ it('exits when cluster not connected', async () => {
120
+ mockGetClusterInfo.mockResolvedValue({ error: true });
121
+ const command = createUninstallCommand({});
122
+ await expect(command.parseAsync(['node', 'test', 'ark-api'])).rejects.toThrow('process.exit called');
123
+ expect(mockExit).toHaveBeenCalledWith(1);
124
+ });
125
+ });
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { ArkApiClient } from '../lib/arkApiClient.js';
3
+ import { ArkApiProxy } from '../lib/arkApiProxy.js';
4
+ interface ChatUIProps {
5
+ initialTargetId?: string;
6
+ arkApiClient: ArkApiClient;
7
+ arkApiProxy: ArkApiProxy;
8
+ config?: {
9
+ chat?: {
10
+ streaming?: boolean;
11
+ outputFormat?: 'text' | 'markdown';
12
+ };
13
+ };
14
+ }
15
+ declare const ChatUI: React.FC<ChatUIProps>;
16
+ export default ChatUI;