@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,221 +0,0 @@
1
- import { describe, it, expect, jest, beforeEach, afterEach } from '@jest/globals';
2
- import { ErrorCode, ArkError, ValidationError, TemplateError, ProjectStructureError, ErrorHandler, InputValidator, } from './errors.js';
3
- jest.mock('fs');
4
- describe('Error Classes', () => {
5
- describe('ArkError', () => {
6
- it('creates error with default code', () => {
7
- const error = new ArkError('test message');
8
- expect(error.message).toBe('test message');
9
- expect(error.code).toBe(ErrorCode.UNKNOWN_ERROR);
10
- expect(error.name).toBe('ArkError');
11
- expect(error.details).toBeUndefined();
12
- expect(error.suggestions).toBeUndefined();
13
- });
14
- it('creates error with all properties', () => {
15
- const error = new ArkError('test error', ErrorCode.INVALID_INPUT, { field: 'name' }, ['Check the input', 'Try again']);
16
- expect(error.message).toBe('test error');
17
- expect(error.code).toBe(ErrorCode.INVALID_INPUT);
18
- expect(error.details).toEqual({ field: 'name' });
19
- expect(error.suggestions).toEqual(['Check the input', 'Try again']);
20
- });
21
- });
22
- describe('ValidationError', () => {
23
- it('creates validation error without field', () => {
24
- const error = new ValidationError('validation failed');
25
- expect(error.message).toBe('validation failed');
26
- expect(error.code).toBe(ErrorCode.VALIDATION_ERROR);
27
- expect(error.name).toBe('ValidationError');
28
- expect(error.details).toBeUndefined();
29
- });
30
- it('creates validation error with field and suggestions', () => {
31
- const error = new ValidationError('invalid email', 'email', [
32
- 'Use valid format',
33
- ]);
34
- expect(error.message).toBe('invalid email');
35
- expect(error.code).toBe(ErrorCode.VALIDATION_ERROR);
36
- expect(error.details).toEqual({ field: 'email' });
37
- expect(error.suggestions).toEqual(['Use valid format']);
38
- });
39
- });
40
- describe('TemplateError', () => {
41
- it('creates template error', () => {
42
- const error = new TemplateError('template failed', 'template.yaml');
43
- expect(error.message).toBe('template failed');
44
- expect(error.code).toBe(ErrorCode.TEMPLATE_ERROR);
45
- expect(error.name).toBe('TemplateError');
46
- expect(error.details).toEqual({ templatePath: 'template.yaml' });
47
- });
48
- });
49
- describe('ProjectStructureError', () => {
50
- it('creates project structure error with defaults', () => {
51
- const error = new ProjectStructureError('project invalid');
52
- expect(error.message).toBe('project invalid');
53
- expect(error.code).toBe(ErrorCode.PROJECT_STRUCTURE_INVALID);
54
- expect(error.name).toBe('ProjectStructureError');
55
- expect(error.suggestions).toEqual([
56
- 'Ensure you are in a valid ARK project directory',
57
- 'Run "ark generate project" to create a new project',
58
- 'Check that Chart.yaml and agents/ directory exist',
59
- ]);
60
- });
61
- it('creates project structure error with path', () => {
62
- const error = new ProjectStructureError('project invalid', '/path/to/project');
63
- expect(error.message).toBe('project invalid');
64
- expect(error.code).toBe(ErrorCode.PROJECT_STRUCTURE_INVALID);
65
- expect(error.details).toEqual({ projectPath: '/path/to/project' });
66
- });
67
- });
68
- describe('ErrorHandler', () => {
69
- it('formats basic error', () => {
70
- const error = new Error('simple error');
71
- const formatted = ErrorHandler.formatError(error);
72
- expect(formatted).toContain('❌ simple error');
73
- });
74
- it('formats ArkError with details and suggestions', () => {
75
- const error = new ArkError('test error', ErrorCode.INVALID_INPUT, { field: 'name', value: 'test' }, ['Fix the input', 'Try again']);
76
- const formatted = ErrorHandler.formatError(error);
77
- expect(formatted).toContain('❌ test error');
78
- expect(formatted).toContain('Details:');
79
- expect(formatted).toContain('field: name');
80
- expect(formatted).toContain('value: test');
81
- expect(formatted).toContain('💡 Suggestions:');
82
- expect(formatted).toContain('• Fix the input');
83
- expect(formatted).toContain('• Try again');
84
- });
85
- it('includes stack trace in debug mode', () => {
86
- process.env.DEBUG = 'true';
87
- const error = new Error('debug error');
88
- const formatted = ErrorHandler.formatError(error);
89
- expect(formatted).toContain('Stack trace:');
90
- delete process.env.DEBUG;
91
- });
92
- it('handles missing stack trace', () => {
93
- process.env.NODE_ENV = 'development';
94
- const error = new Error('no stack');
95
- error.stack = undefined;
96
- const formatted = ErrorHandler.formatError(error);
97
- expect(formatted).toContain('No stack trace available');
98
- delete process.env.NODE_ENV;
99
- });
100
- describe('handleAndExit', () => {
101
- let mockExit;
102
- let mockConsoleError;
103
- beforeEach(() => {
104
- mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {
105
- throw new Error('process.exit');
106
- });
107
- mockConsoleError = jest
108
- .spyOn(console, 'error')
109
- .mockImplementation(() => { });
110
- });
111
- afterEach(() => {
112
- mockExit.mockRestore();
113
- mockConsoleError.mockRestore();
114
- });
115
- it('exits with code 22 for validation errors', () => {
116
- const error = new ValidationError('invalid');
117
- expect(() => ErrorHandler.handleAndExit(error)).toThrow('process.exit');
118
- expect(mockExit).toHaveBeenCalledWith(22);
119
- });
120
- it('exits with code 2 for file not found', () => {
121
- const error = new ArkError('not found', ErrorCode.FILE_NOT_FOUND);
122
- expect(() => ErrorHandler.handleAndExit(error)).toThrow('process.exit');
123
- expect(mockExit).toHaveBeenCalledWith(2);
124
- });
125
- it('exits with code 13 for permission denied', () => {
126
- const error = new ArkError('denied', ErrorCode.PERMISSION_DENIED);
127
- expect(() => ErrorHandler.handleAndExit(error)).toThrow('process.exit');
128
- expect(mockExit).toHaveBeenCalledWith(13);
129
- });
130
- it('exits with code 127 for missing dependency', () => {
131
- const error = new ArkError('missing', ErrorCode.DEPENDENCY_MISSING);
132
- expect(() => ErrorHandler.handleAndExit(error)).toThrow('process.exit');
133
- expect(mockExit).toHaveBeenCalledWith(127);
134
- });
135
- it('exits with code 1 for unknown errors', () => {
136
- const error = new Error('unknown');
137
- expect(() => ErrorHandler.handleAndExit(error)).toThrow('process.exit');
138
- expect(mockExit).toHaveBeenCalledWith(1);
139
- });
140
- it('exits with code 1 for default ArkError', () => {
141
- const error = new ArkError('general', ErrorCode.UNKNOWN_ERROR);
142
- expect(() => ErrorHandler.handleAndExit(error)).toThrow('process.exit');
143
- expect(mockExit).toHaveBeenCalledWith(1);
144
- });
145
- });
146
- describe('catchAndHandle', () => {
147
- it('returns successful promise result', async () => {
148
- const result = await ErrorHandler.catchAndHandle(async () => 'success');
149
- expect(result).toBe('success');
150
- });
151
- it('rethrows ArkError unchanged', async () => {
152
- const arkError = new ValidationError('test');
153
- await expect(ErrorHandler.catchAndHandle(async () => {
154
- throw arkError;
155
- })).rejects.toThrow(arkError);
156
- });
157
- it('wraps generic errors with context', async () => {
158
- const error = new Error('generic');
159
- await expect(ErrorHandler.catchAndHandle(async () => {
160
- throw error;
161
- }, 'context')).rejects.toThrow('context: generic');
162
- });
163
- it('wraps non-Error objects', async () => {
164
- await expect(ErrorHandler.catchAndHandle(async () => {
165
- throw 'string error';
166
- })).rejects.toThrow('string error');
167
- });
168
- });
169
- });
170
- describe('InputValidator', () => {
171
- describe('validateName', () => {
172
- it('accepts valid names', () => {
173
- expect(() => InputValidator.validateName('valid-name')).not.toThrow();
174
- expect(() => InputValidator.validateName('test123')).not.toThrow();
175
- expect(() => InputValidator.validateName('a-b-c-123')).not.toThrow();
176
- });
177
- it('rejects empty names', () => {
178
- expect(() => InputValidator.validateName('')).toThrow('name cannot be empty');
179
- expect(() => InputValidator.validateName(' ')).toThrow('name cannot be empty');
180
- });
181
- it('rejects names over 63 characters', () => {
182
- const longName = 'a'.repeat(64);
183
- expect(() => InputValidator.validateName(longName)).toThrow('must be 63 characters or less');
184
- });
185
- it('rejects invalid characters', () => {
186
- expect(() => InputValidator.validateName('Invalid Name')).toThrow('Invalid name');
187
- expect(() => InputValidator.validateName('test_name')).toThrow('Invalid name');
188
- expect(() => InputValidator.validateName('-start')).toThrow('Invalid name');
189
- expect(() => InputValidator.validateName('end-')).toThrow('Invalid name');
190
- });
191
- it('suggests normalized names', () => {
192
- try {
193
- InputValidator.validateName('TestName');
194
- }
195
- catch (e) {
196
- expect(e.suggestions).toContain('Try: "test-name"');
197
- }
198
- });
199
- });
200
- describe('validatePath', () => {
201
- it('accepts valid paths', () => {
202
- expect(() => InputValidator.validatePath('/valid/path')).not.toThrow();
203
- expect(() => InputValidator.validatePath('./relative')).not.toThrow();
204
- expect(() => InputValidator.validatePath('simple')).not.toThrow();
205
- });
206
- it('rejects empty paths', () => {
207
- expect(() => InputValidator.validatePath('')).toThrow('path cannot be empty');
208
- });
209
- it('rejects dangerous paths', () => {
210
- expect(() => InputValidator.validatePath('../parent')).toThrow('unsafe characters');
211
- expect(() => InputValidator.validatePath('~/home')).toThrow('unsafe characters');
212
- expect(() => InputValidator.validatePath('$HOME/test')).toThrow('unsafe characters');
213
- });
214
- });
215
- describe('validateDirectory', () => {
216
- it('validates path first', () => {
217
- expect(() => InputValidator.validateDirectory('')).toThrow('directory cannot be empty');
218
- });
219
- });
220
- });
221
- });
@@ -1,36 +0,0 @@
1
- export type StatusType = 'success' | 'warning' | 'info' | 'error';
2
- declare const output: {
3
- /**
4
- * Display a status message with flexible formatting
5
- */
6
- statusMessage(type: StatusType, title: string, message?: string, ...args: unknown[]): void;
7
- /**
8
- * Display an error message with consistent formatting
9
- */
10
- error(message: string, ...args: unknown[]): void;
11
- /**
12
- * Display a success message with consistent formatting
13
- */
14
- success(message: string, ...args: unknown[]): void;
15
- /**
16
- * Display an info message (indented gray text)
17
- */
18
- info(message: string, ...args: unknown[]): void;
19
- /**
20
- * Display a warning message with consistent formatting
21
- */
22
- warning(message: string, ...args: unknown[]): void;
23
- /**
24
- * Display a status check item (like ark status format)
25
- * @param status - 'found', 'missing', 'warning', 'error'
26
- * @param label - The label to show (e.g., 'platform')
27
- * @param value - The value in bright white (e.g., 'python3')
28
- * @param details - Optional grey details
29
- */
30
- statusCheck(status: "found" | "missing" | "warning" | "error", label: string, value?: string, details?: string): void;
31
- /**
32
- * Display a section header (like 'ark services:')
33
- */
34
- section(title: string): void;
35
- };
36
- export default output;
@@ -1,89 +0,0 @@
1
- import chalk from 'chalk';
2
- const output = {
3
- /**
4
- * Display a status message with flexible formatting
5
- */
6
- statusMessage(type, title, message, ...args) {
7
- const icons = {
8
- success: chalk.green('✓'),
9
- warning: chalk.yellow.bold('!'),
10
- info: chalk.blue('ℹ'),
11
- error: chalk.red('✗'),
12
- };
13
- const colors = {
14
- success: chalk.green,
15
- warning: chalk.yellow,
16
- info: chalk.blue,
17
- error: chalk.red,
18
- };
19
- const icon = icons[type];
20
- const color = colors[type];
21
- const logFn = type === 'error' ? console.error : console.log;
22
- if (message) {
23
- logFn(icon, color(`${title}:`), message, ...args);
24
- }
25
- else {
26
- logFn(icon, title, ...args);
27
- }
28
- },
29
- /**
30
- * Display an error message with consistent formatting
31
- */
32
- error(message, ...args) {
33
- this.statusMessage('error', 'error', message, ...args);
34
- },
35
- /**
36
- * Display a success message with consistent formatting
37
- */
38
- success(message, ...args) {
39
- this.statusMessage('success', message, undefined, ...args);
40
- },
41
- /**
42
- * Display an info message (indented gray text)
43
- */
44
- info(message, ...args) {
45
- console.log(chalk.gray(message), ...args);
46
- },
47
- /**
48
- * Display a warning message with consistent formatting
49
- */
50
- warning(message, ...args) {
51
- this.statusMessage('warning', 'warning', message, ...args);
52
- },
53
- /**
54
- * Display a status check item (like ark status format)
55
- * @param status - 'found', 'missing', 'warning', 'error'
56
- * @param label - The label to show (e.g., 'platform')
57
- * @param value - The value in bright white (e.g., 'python3')
58
- * @param details - Optional grey details
59
- */
60
- statusCheck(status, label, value, details) {
61
- const icons = {
62
- found: chalk.green('✓'),
63
- missing: chalk.yellow('?'),
64
- warning: chalk.yellow('!'),
65
- error: chalk.red('✗'),
66
- };
67
- const statusText = {
68
- found: chalk.green(label),
69
- missing: chalk.yellow(label),
70
- warning: chalk.yellow(label),
71
- error: chalk.red(label),
72
- };
73
- let output = ` ${icons[status]} ${statusText[status]}`;
74
- if (value) {
75
- output += ` ${chalk.bold.white(value)}`;
76
- }
77
- if (details) {
78
- output += chalk.gray(` ${details}`);
79
- }
80
- console.log(output);
81
- },
82
- /**
83
- * Display a section header (like 'ark services:')
84
- */
85
- section(title) {
86
- console.log(chalk.cyan.bold(`${title}:`));
87
- },
88
- };
89
- export default output;
@@ -1 +0,0 @@
1
- export {};
@@ -1,123 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals';
2
- import chalk from 'chalk';
3
- import output from './output.js';
4
- describe('output', () => {
5
- let consoleErrorSpy;
6
- let consoleLogSpy;
7
- beforeEach(() => {
8
- consoleErrorSpy = jest
9
- .spyOn(console, 'error')
10
- .mockImplementation(() => undefined);
11
- consoleLogSpy = jest
12
- .spyOn(console, 'log')
13
- .mockImplementation(() => undefined);
14
- });
15
- afterEach(() => {
16
- jest.clearAllMocks();
17
- });
18
- describe('error', () => {
19
- it('should output error message with red cross and prefix', () => {
20
- output.error('Something went wrong');
21
- expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.red('✗'), chalk.red('error:'), 'Something went wrong');
22
- });
23
- it('should handle additional arguments', () => {
24
- const error = new Error('Test error');
25
- output.error('Failed to connect', error, 123);
26
- expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.red('✗'), chalk.red('error:'), 'Failed to connect', error, 123);
27
- });
28
- });
29
- describe('success', () => {
30
- it('should output success message with green checkmark', () => {
31
- output.success('Operation completed');
32
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.green('✓'), 'Operation completed');
33
- });
34
- it('should handle additional arguments', () => {
35
- output.success('Deployed', 'v1.0.0', { status: 'ok' });
36
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.green('✓'), 'Deployed', 'v1.0.0', { status: 'ok' });
37
- });
38
- });
39
- describe('info', () => {
40
- it('should output info message in gray', () => {
41
- output.info('Processing request...');
42
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.gray('Processing request...'));
43
- });
44
- it('should handle additional arguments', () => {
45
- output.info('Status:', 'running', 42);
46
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.gray('Status:'), 'running', 42);
47
- });
48
- });
49
- describe('warning', () => {
50
- it('should output warning message with yellow exclamation and prefix', () => {
51
- output.warning('Resource limit approaching');
52
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.yellow.bold('!'), chalk.yellow('warning:'), 'Resource limit approaching');
53
- });
54
- it('should handle additional arguments', () => {
55
- const details = { cpu: '85%', memory: '92%' };
56
- output.warning('High resource usage', details);
57
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.yellow.bold('!'), chalk.yellow('warning:'), 'High resource usage', details);
58
- });
59
- });
60
- describe('statusCheck', () => {
61
- it('should display found status with value and details', () => {
62
- output.statusCheck('found', 'platform', 'python3', 'v3.10');
63
- expect(consoleLogSpy).toHaveBeenCalledWith(` ${chalk.green('✓')} ${chalk.green('platform')} ${chalk.bold.white('python3')}${chalk.gray(' v3.10')}`);
64
- });
65
- it('should display found status with value only', () => {
66
- output.statusCheck('found', 'fastmcp', 'v0.1.0');
67
- expect(consoleLogSpy).toHaveBeenCalledWith(` ${chalk.green('✓')} ${chalk.green('fastmcp')} ${chalk.bold.white('v0.1.0')}`);
68
- });
69
- it('should display found status with label only', () => {
70
- output.statusCheck('found', '3 tools');
71
- expect(consoleLogSpy).toHaveBeenCalledWith(` ${chalk.green('✓')} ${chalk.green('3 tools')}`);
72
- });
73
- it('should display missing status with details', () => {
74
- output.statusCheck('missing', 'fastmcp', undefined, 'not in dependencies');
75
- expect(consoleLogSpy).toHaveBeenCalledWith(` ${chalk.yellow('?')} ${chalk.yellow('fastmcp')}${chalk.gray(' not in dependencies')}`);
76
- });
77
- it('should display warning status', () => {
78
- output.statusCheck('warning', 'version', '0.0.1', 'pre-release');
79
- expect(consoleLogSpy).toHaveBeenCalledWith(` ${chalk.yellow('!')} ${chalk.yellow('version')} ${chalk.bold.white('0.0.1')}${chalk.gray(' pre-release')}`);
80
- });
81
- it('should display error status', () => {
82
- output.statusCheck('error', 'tools', undefined, 'discovery failed');
83
- expect(consoleLogSpy).toHaveBeenCalledWith(` ${chalk.red('✗')} ${chalk.red('tools')}${chalk.gray(' discovery failed')}`);
84
- });
85
- });
86
- describe('section', () => {
87
- it('should display section header with colon', () => {
88
- output.section('dev-tests');
89
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.cyan.bold('dev-tests:'));
90
- });
91
- it('should display section header with custom text', () => {
92
- output.section('ark services');
93
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.cyan.bold('ark services:'));
94
- });
95
- });
96
- describe('statusMessage', () => {
97
- it('should output success status with title and message', () => {
98
- output.statusMessage('success', 'fastmcp', 'installed (v0.1.0)');
99
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.green('✓'), chalk.green('fastmcp:'), 'installed (v0.1.0)');
100
- });
101
- it('should output warning status with title and message', () => {
102
- output.statusMessage('warning', 'virtual environment', 'not found');
103
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.yellow.bold('!'), chalk.yellow('virtual environment:'), 'not found');
104
- });
105
- it('should output error status with title and message', () => {
106
- output.statusMessage('error', 'fastmcp', 'not found in dependencies');
107
- expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.red('✗'), chalk.red('fastmcp:'), 'not found in dependencies');
108
- });
109
- it('should output info status with title and message', () => {
110
- output.statusMessage('info', 'platform', 'python3');
111
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.blue('ℹ'), chalk.blue('platform:'), 'python3');
112
- });
113
- it('should handle title-only messages', () => {
114
- output.statusMessage('success', 'Operation completed');
115
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.green('✓'), 'Operation completed');
116
- });
117
- it('should handle additional arguments', () => {
118
- const extra = { version: '1.0' };
119
- output.statusMessage('info', 'status', 'running', extra, 42);
120
- expect(consoleLogSpy).toHaveBeenCalledWith(chalk.blue('ℹ'), chalk.blue('status:'), 'running', extra, 42);
121
- });
122
- });
123
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if a port is available
3
- */
4
- export declare function isPortAvailable(port: number): Promise<boolean>;
5
- /**
6
- * Find an available port, starting from the preferred port
7
- */
8
- export declare function findAvailablePort(preferredPort: number, maxAttempts?: number): Promise<number>;
@@ -1,39 +0,0 @@
1
- import net from 'net';
2
- /**
3
- * Check if a port is available
4
- */
5
- export async function isPortAvailable(port) {
6
- return new Promise((resolve) => {
7
- const server = net.createServer();
8
- server.once('error', (err) => {
9
- if (err.code === 'EADDRINUSE') {
10
- resolve(false);
11
- }
12
- else {
13
- resolve(false);
14
- }
15
- });
16
- server.once('listening', () => {
17
- server.close();
18
- resolve(true);
19
- });
20
- server.listen(port, '127.0.0.1');
21
- });
22
- }
23
- /**
24
- * Find an available port, starting from the preferred port
25
- */
26
- export async function findAvailablePort(preferredPort, maxAttempts = 10) {
27
- // First try the preferred port
28
- if (await isPortAvailable(preferredPort)) {
29
- return preferredPort;
30
- }
31
- // Try random ports
32
- for (let i = 0; i < maxAttempts; i++) {
33
- const randomPort = Math.floor(Math.random() * (65535 - 1024) + 1024);
34
- if (await isPortAvailable(randomPort)) {
35
- return randomPort;
36
- }
37
- }
38
- throw new Error(`Could not find an available port after ${maxAttempts} attempts`);
39
- }
@@ -1,5 +0,0 @@
1
- import type { ArkConfig } from './config.js';
2
- /**
3
- * Initialize the CLI by checking requirements and loading config
4
- */
5
- export declare function startup(): Promise<ArkConfig>;
@@ -1,73 +0,0 @@
1
- import chalk from 'chalk';
2
- import { checkCommandExists } from './commands.js';
3
- import { loadConfig } from './config.js';
4
- import { getArkVersion } from './arkStatus.js';
5
- const REQUIRED_COMMANDS = [
6
- {
7
- name: 'kubectl',
8
- command: 'kubectl',
9
- args: ['version', '--client'],
10
- installUrl: 'https://kubernetes.io/docs/tasks/tools/',
11
- },
12
- {
13
- name: 'helm',
14
- command: 'helm',
15
- args: ['version', '--short'],
16
- installUrl: 'https://helm.sh/docs/intro/install/',
17
- },
18
- ];
19
- async function checkRequirements() {
20
- const missing = [];
21
- for (const cmd of REQUIRED_COMMANDS) {
22
- const exists = await checkCommandExists(cmd.command, cmd.args);
23
- if (!exists) {
24
- missing.push(cmd);
25
- }
26
- }
27
- if (missing.length > 0) {
28
- for (const cmd of missing) {
29
- console.error(chalk.red('error:') + ` ${cmd.name} is required`);
30
- console.error(' ' + chalk.blue(cmd.installUrl));
31
- }
32
- process.exit(1);
33
- }
34
- }
35
- /**
36
- * Fetch version information (non-blocking)
37
- */
38
- async function fetchVersionInfo(config) {
39
- // Fetch latest version from GitHub
40
- try {
41
- const response = await fetch('https://api.github.com/repos/mckinsey/agents-at-scale-ark/releases/latest');
42
- if (response.ok) {
43
- const data = (await response.json());
44
- // Remove 'v' prefix if present for consistent comparison
45
- config.latestVersion = data.tag_name.replace(/^v/, '');
46
- }
47
- }
48
- catch {
49
- // Silently fail - latestVersion will remain undefined
50
- }
51
- // Fetch current installed version (already without 'v' from helm)
52
- try {
53
- const currentVersion = await getArkVersion();
54
- if (currentVersion) {
55
- config.currentVersion = currentVersion;
56
- }
57
- }
58
- catch {
59
- // Silently fail - currentVersion will remain undefined
60
- }
61
- }
62
- /**
63
- * Initialize the CLI by checking requirements and loading config
64
- */
65
- export async function startup() {
66
- // Check required commands
67
- await checkRequirements();
68
- // Load config
69
- const config = loadConfig();
70
- // Fetch version info synchronously so it's available immediately
71
- await fetchVersionInfo(config);
72
- return config;
73
- }
@@ -1 +0,0 @@
1
- export {};