@agents-at-scale/ark 0.1.31

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 (76) hide show
  1. package/README.md +95 -0
  2. package/dist/commands/cluster/get-ip.d.ts +2 -0
  3. package/dist/commands/cluster/get-ip.js +32 -0
  4. package/dist/commands/cluster/get-type.d.ts +2 -0
  5. package/dist/commands/cluster/get-type.js +26 -0
  6. package/dist/commands/cluster/index.d.ts +2 -0
  7. package/dist/commands/cluster/index.js +10 -0
  8. package/dist/commands/completion.d.ts +2 -0
  9. package/dist/commands/completion.js +108 -0
  10. package/dist/commands/config.d.ts +5 -0
  11. package/dist/commands/config.js +327 -0
  12. package/dist/commands/generate/config.d.ts +145 -0
  13. package/dist/commands/generate/config.js +253 -0
  14. package/dist/commands/generate/generators/agent.d.ts +2 -0
  15. package/dist/commands/generate/generators/agent.js +156 -0
  16. package/dist/commands/generate/generators/index.d.ts +6 -0
  17. package/dist/commands/generate/generators/index.js +6 -0
  18. package/dist/commands/generate/generators/marketplace.d.ts +2 -0
  19. package/dist/commands/generate/generators/marketplace.js +304 -0
  20. package/dist/commands/generate/generators/mcpserver.d.ts +25 -0
  21. package/dist/commands/generate/generators/mcpserver.js +350 -0
  22. package/dist/commands/generate/generators/project.d.ts +2 -0
  23. package/dist/commands/generate/generators/project.js +784 -0
  24. package/dist/commands/generate/generators/query.d.ts +2 -0
  25. package/dist/commands/generate/generators/query.js +213 -0
  26. package/dist/commands/generate/generators/team.d.ts +2 -0
  27. package/dist/commands/generate/generators/team.js +407 -0
  28. package/dist/commands/generate/index.d.ts +24 -0
  29. package/dist/commands/generate/index.js +357 -0
  30. package/dist/commands/generate/templateDiscovery.d.ts +30 -0
  31. package/dist/commands/generate/templateDiscovery.js +94 -0
  32. package/dist/commands/generate/templateEngine.d.ts +78 -0
  33. package/dist/commands/generate/templateEngine.js +368 -0
  34. package/dist/commands/generate/utils/nameUtils.d.ts +35 -0
  35. package/dist/commands/generate/utils/nameUtils.js +110 -0
  36. package/dist/commands/generate/utils/projectUtils.d.ts +28 -0
  37. package/dist/commands/generate/utils/projectUtils.js +133 -0
  38. package/dist/components/DashboardCLI.d.ts +3 -0
  39. package/dist/components/DashboardCLI.js +149 -0
  40. package/dist/components/GeneratorUI.d.ts +3 -0
  41. package/dist/components/GeneratorUI.js +167 -0
  42. package/dist/components/statusChecker.d.ts +48 -0
  43. package/dist/components/statusChecker.js +251 -0
  44. package/dist/config.d.ts +42 -0
  45. package/dist/config.js +243 -0
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.js +67 -0
  48. package/dist/lib/arkClient.d.ts +32 -0
  49. package/dist/lib/arkClient.js +43 -0
  50. package/dist/lib/cluster.d.ts +8 -0
  51. package/dist/lib/cluster.js +134 -0
  52. package/dist/lib/config.d.ts +82 -0
  53. package/dist/lib/config.js +223 -0
  54. package/dist/lib/consts.d.ts +10 -0
  55. package/dist/lib/consts.js +15 -0
  56. package/dist/lib/errors.d.ts +56 -0
  57. package/dist/lib/errors.js +208 -0
  58. package/dist/lib/exec.d.ts +5 -0
  59. package/dist/lib/exec.js +20 -0
  60. package/dist/lib/gatewayManager.d.ts +24 -0
  61. package/dist/lib/gatewayManager.js +85 -0
  62. package/dist/lib/kubernetes.d.ts +28 -0
  63. package/dist/lib/kubernetes.js +122 -0
  64. package/dist/lib/progress.d.ts +128 -0
  65. package/dist/lib/progress.js +273 -0
  66. package/dist/lib/security.d.ts +37 -0
  67. package/dist/lib/security.js +295 -0
  68. package/dist/lib/types.d.ts +37 -0
  69. package/dist/lib/types.js +1 -0
  70. package/dist/lib/wrappers/git.d.ts +2 -0
  71. package/dist/lib/wrappers/git.js +43 -0
  72. package/dist/ui/MainMenu.d.ts +3 -0
  73. package/dist/ui/MainMenu.js +116 -0
  74. package/dist/ui/statusFormatter.d.ts +9 -0
  75. package/dist/ui/statusFormatter.js +47 -0
  76. package/package.json +62 -0
@@ -0,0 +1,122 @@
1
+ import { promises as fs } from 'fs';
2
+ import { homedir } from 'os';
3
+ import { join } from 'path';
4
+ import * as k8s from '@kubernetes/client-node';
5
+ export class KubernetesConfigManager {
6
+ constructor() {
7
+ this.kc = new k8s.KubeConfig();
8
+ }
9
+ /**
10
+ * Get the KubeConfig instance for API client creation
11
+ */
12
+ getKubeConfig() {
13
+ return this.kc;
14
+ }
15
+ /**
16
+ * Initialize Kubernetes configuration similar to fark's approach
17
+ * Priority: in-cluster config > KUBECONFIG env > ~/.kube/config
18
+ */
19
+ async initializeConfig() {
20
+ let kubeconfig;
21
+ let currentContext;
22
+ let namespace;
23
+ let inCluster = false;
24
+ // Check if we're explicitly in a Kubernetes pod environment
25
+ const isInPod = process.env.KUBERNETES_SERVICE_HOST &&
26
+ process.env.KUBERNETES_SERVICE_PORT &&
27
+ process.env.POD_NAMESPACE;
28
+ if (isInPod) {
29
+ try {
30
+ // Try in-cluster config only if we're definitely in a pod
31
+ this.kc.loadFromCluster();
32
+ inCluster = true;
33
+ kubeconfig = '/var/run/secrets/kubernetes.io/serviceaccount';
34
+ namespace = process.env.POD_NAMESPACE || 'default';
35
+ }
36
+ catch (error) {
37
+ throw new Error(`Failed to load in-cluster Kubernetes configuration: ${error}`);
38
+ }
39
+ }
40
+ else {
41
+ // Use kubeconfig file for local development
42
+ try {
43
+ kubeconfig =
44
+ process.env.KUBECONFIG || join(homedir(), '.kube', 'config');
45
+ // Check if kubeconfig file exists
46
+ await fs.access(kubeconfig);
47
+ this.kc.loadFromFile(kubeconfig);
48
+ // Get current context and namespace
49
+ currentContext = this.kc.currentContext;
50
+ // Simplified namespace detection - just use default for now
51
+ // Complex namespace detection can be added later if needed
52
+ namespace = 'default';
53
+ }
54
+ catch (error) {
55
+ throw new Error(`Failed to load Kubernetes configuration: ${error}`);
56
+ }
57
+ }
58
+ return {
59
+ kubeconfig,
60
+ currentContext,
61
+ namespace,
62
+ inCluster,
63
+ };
64
+ }
65
+ /**
66
+ * Get the API server URL for the current cluster
67
+ */
68
+ getClusterApiUrl() {
69
+ const cluster = this.kc.getCurrentCluster();
70
+ if (!cluster) {
71
+ throw new Error('No current cluster found in kubeconfig');
72
+ }
73
+ return cluster.server;
74
+ }
75
+ /**
76
+ * Detect ark-api service URL in the cluster
77
+ * This mimics how fark discovers services
78
+ */
79
+ async getArkApiUrl(namespace = 'default') {
80
+ const k8sApi = this.kc.makeApiClient(k8s.CoreV1Api);
81
+ try {
82
+ // Try to find ark-api service
83
+ const service = await k8sApi.readNamespacedService({
84
+ name: 'ark-api',
85
+ namespace,
86
+ });
87
+ if (service.spec?.type === 'LoadBalancer' &&
88
+ service.status?.loadBalancer?.ingress?.[0]) {
89
+ const ingress = service.status.loadBalancer.ingress[0];
90
+ const host = ingress.ip || ingress.hostname;
91
+ const port = service.spec.ports?.[0]?.port || 8080;
92
+ return `http://${host}:${port}`;
93
+ }
94
+ if (service.spec?.type === 'NodePort' && service.spec.ports?.[0]) {
95
+ const nodePort = service.spec.ports[0].nodePort;
96
+ const clusterUrl = this.getClusterApiUrl();
97
+ const clusterHost = new URL(clusterUrl).hostname;
98
+ return `http://${clusterHost}:${nodePort}`;
99
+ }
100
+ // Default to port-forward style access
101
+ const port = service.spec?.ports?.[0]?.port || 8080;
102
+ return `http://localhost:${port}`;
103
+ }
104
+ catch (error) {
105
+ // Service not found or not accessible
106
+ throw new Error(`ark-api service not found or not accessible in namespace '${namespace}': ${error instanceof Error ? error.message : error}`);
107
+ }
108
+ }
109
+ /**
110
+ * Check if we can access the cluster
111
+ */
112
+ async testClusterAccess() {
113
+ try {
114
+ const k8sApi = this.kc.makeApiClient(k8s.CoreV1Api);
115
+ await k8sApi.listNamespace();
116
+ return true;
117
+ }
118
+ catch {
119
+ return false;
120
+ }
121
+ }
122
+ }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Progress indicators and user experience utilities for ARK CLI
3
+ */
4
+ export interface ProgressStep {
5
+ name: string;
6
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
7
+ message?: string;
8
+ duration?: number;
9
+ }
10
+ export declare class ProgressIndicator {
11
+ private title;
12
+ private steps;
13
+ private startTime;
14
+ constructor(title: string);
15
+ /**
16
+ * Add a step to the progress indicator
17
+ */
18
+ addStep(name: string, message?: string): void;
19
+ /**
20
+ * Start a step
21
+ */
22
+ startStep(name: string, message?: string): void;
23
+ /**
24
+ * Complete a step
25
+ */
26
+ completeStep(name: string, message?: string): void;
27
+ /**
28
+ * Fail a step
29
+ */
30
+ failStep(name: string, message?: string): void;
31
+ /**
32
+ * Skip a step
33
+ */
34
+ skipStep(name: string, message?: string): void;
35
+ /**
36
+ * Render the current progress
37
+ */
38
+ private renderProgress;
39
+ /**
40
+ * Complete the progress indicator
41
+ */
42
+ complete(message?: string): void;
43
+ /**
44
+ * Get status icon for a step
45
+ */
46
+ private getStatusIcon;
47
+ /**
48
+ * Get status color for a step
49
+ */
50
+ private getStatusColor;
51
+ }
52
+ /**
53
+ * Simple spinner for long-running operations
54
+ */
55
+ export declare class Spinner {
56
+ private frames;
57
+ private index;
58
+ private interval;
59
+ private message;
60
+ constructor(message: string);
61
+ start(): void;
62
+ stop(finalMessage?: string): void;
63
+ fail(errorMessage?: string): void;
64
+ }
65
+ /**
66
+ * Enhanced prompts with better validation and user guidance
67
+ */
68
+ export declare class EnhancedPrompts {
69
+ /**
70
+ * Show a helpful tip to the user
71
+ */
72
+ static showTip(message: string): void;
73
+ /**
74
+ * Show a warning to the user
75
+ */
76
+ static showWarning(message: string): void;
77
+ /**
78
+ * Show information to the user
79
+ */
80
+ static showInfo(message: string): void;
81
+ /**
82
+ * Show a success message
83
+ */
84
+ static showSuccess(message: string): void;
85
+ /**
86
+ * Show available options for a choice
87
+ */
88
+ static showChoiceHelp(title: string, choices: Array<{
89
+ name: string;
90
+ description: string;
91
+ }>): void;
92
+ /**
93
+ * Show next steps after completion
94
+ */
95
+ static showNextSteps(title: string, steps: string[]): void;
96
+ /**
97
+ * Show a separator for better visual organization
98
+ */
99
+ static showSeparator(title?: string): void;
100
+ }
101
+ /**
102
+ * Utility for consistent formatting of output
103
+ */
104
+ export declare class OutputFormatter {
105
+ /**
106
+ * Format a list of key-value pairs
107
+ */
108
+ static formatKeyValueList(items: Array<{
109
+ key: string;
110
+ value: string;
111
+ highlight?: boolean;
112
+ }>): void;
113
+ /**
114
+ * Format a file list with icons
115
+ */
116
+ static formatFileList(files: Array<{
117
+ path: string;
118
+ type: 'file' | 'directory';
119
+ description?: string;
120
+ }>): void;
121
+ /**
122
+ * Format command examples
123
+ */
124
+ static formatCommands(title: string, commands: Array<{
125
+ command: string;
126
+ description: string;
127
+ }>): void;
128
+ }
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Progress indicators and user experience utilities for ARK CLI
3
+ */
4
+ import chalk from 'chalk';
5
+ export class ProgressIndicator {
6
+ constructor(title) {
7
+ this.title = title;
8
+ this.steps = [];
9
+ this.startTime = Date.now();
10
+ console.log(chalk.blue(`\nšŸš€ ${this.title}\n`));
11
+ }
12
+ /**
13
+ * Add a step to the progress indicator
14
+ */
15
+ addStep(name, message) {
16
+ this.steps.push({
17
+ name,
18
+ status: 'pending',
19
+ message,
20
+ });
21
+ }
22
+ /**
23
+ * Start a step
24
+ */
25
+ startStep(name, message) {
26
+ const step = this.steps.find((s) => s.name === name);
27
+ if (step) {
28
+ step.status = 'running';
29
+ step.message = message;
30
+ this.renderProgress();
31
+ }
32
+ }
33
+ /**
34
+ * Complete a step
35
+ */
36
+ completeStep(name, message) {
37
+ const step = this.steps.find((s) => s.name === name);
38
+ if (step) {
39
+ step.status = 'completed';
40
+ step.message = message;
41
+ this.renderProgress();
42
+ }
43
+ }
44
+ /**
45
+ * Fail a step
46
+ */
47
+ failStep(name, message) {
48
+ const step = this.steps.find((s) => s.name === name);
49
+ if (step) {
50
+ step.status = 'failed';
51
+ step.message = message;
52
+ this.renderProgress();
53
+ }
54
+ }
55
+ /**
56
+ * Skip a step
57
+ */
58
+ skipStep(name, message) {
59
+ const step = this.steps.find((s) => s.name === name);
60
+ if (step) {
61
+ step.status = 'skipped';
62
+ step.message = message;
63
+ this.renderProgress();
64
+ }
65
+ }
66
+ /**
67
+ * Render the current progress
68
+ */
69
+ renderProgress() {
70
+ // Clear previous output (simple version)
71
+ process.stdout.write('\r\x1b[K');
72
+ for (const step of this.steps) {
73
+ const icon = this.getStatusIcon(step.status);
74
+ const color = this.getStatusColor(step.status);
75
+ const statusText = step.message || step.name;
76
+ console.log(`${icon} ${chalk[color](statusText)}`);
77
+ }
78
+ // Move cursor back up to overwrite on next update
79
+ if (this.steps.length > 1) {
80
+ process.stdout.write(`\x1b[${this.steps.length}A`);
81
+ }
82
+ }
83
+ /**
84
+ * Complete the progress indicator
85
+ */
86
+ complete(message) {
87
+ // Clear any remaining progress rendering
88
+ process.stdout.write('\r\x1b[K');
89
+ // Only print failed or skipped steps - hide successful validation
90
+ const importantSteps = this.steps.filter((step) => step.status === 'failed' || step.status === 'skipped');
91
+ for (const step of importantSteps) {
92
+ const icon = this.getStatusIcon(step.status);
93
+ const color = this.getStatusColor(step.status);
94
+ const statusText = step.message || step.name;
95
+ console.log(`${icon} ${chalk[color](statusText)}`);
96
+ }
97
+ const duration = Date.now() - this.startTime;
98
+ const durationText = duration > 1000 ? `${(duration / 1000).toFixed(1)}s` : `${duration}ms`;
99
+ // Only show completion message if there were issues or if verbose
100
+ if (importantSteps.length > 0) {
101
+ console.log(chalk.green(`\nāœ… ${message || this.title} completed in ${durationText}\n`));
102
+ }
103
+ }
104
+ /**
105
+ * Get status icon for a step
106
+ */
107
+ getStatusIcon(status) {
108
+ switch (status) {
109
+ case 'pending':
110
+ return chalk.gray('ā³');
111
+ case 'running':
112
+ return chalk.blue('šŸ”„');
113
+ case 'completed':
114
+ return chalk.green('āœ…');
115
+ case 'failed':
116
+ return chalk.red('āŒ');
117
+ case 'skipped':
118
+ return chalk.yellow('ā­ļø');
119
+ default:
120
+ return 'ā“';
121
+ }
122
+ }
123
+ /**
124
+ * Get status color for a step
125
+ */
126
+ getStatusColor(status) {
127
+ switch (status) {
128
+ case 'pending':
129
+ return 'gray';
130
+ case 'running':
131
+ return 'blue';
132
+ case 'completed':
133
+ return 'green';
134
+ case 'failed':
135
+ return 'red';
136
+ case 'skipped':
137
+ return 'yellow';
138
+ default:
139
+ return 'gray';
140
+ }
141
+ }
142
+ }
143
+ /**
144
+ * Simple spinner for long-running operations
145
+ */
146
+ export class Spinner {
147
+ constructor(message) {
148
+ this.frames = ['ā ‹', 'ā ™', 'ā ¹', 'ā ø', 'ā ¼', 'ā “', 'ā ¦', 'ā §', 'ā ‡', 'ā '];
149
+ this.index = 0;
150
+ this.interval = null;
151
+ this.message = message;
152
+ }
153
+ start() {
154
+ this.interval = setInterval(() => {
155
+ process.stdout.write(`\r${chalk.blue(this.frames[this.index])} ${this.message}`);
156
+ this.index = (this.index + 1) % this.frames.length;
157
+ }, 100);
158
+ }
159
+ stop(finalMessage) {
160
+ if (this.interval) {
161
+ clearInterval(this.interval);
162
+ this.interval = null;
163
+ }
164
+ process.stdout.write(`\r\x1b[K${finalMessage ? chalk.green(`āœ… ${finalMessage}`) : ''}\n`);
165
+ }
166
+ fail(errorMessage) {
167
+ if (this.interval) {
168
+ clearInterval(this.interval);
169
+ this.interval = null;
170
+ }
171
+ process.stdout.write(`\r\x1b[K${errorMessage ? chalk.red(`āŒ ${errorMessage}`) : ''}\n`);
172
+ }
173
+ }
174
+ /**
175
+ * Enhanced prompts with better validation and user guidance
176
+ */
177
+ export class EnhancedPrompts {
178
+ /**
179
+ * Show a helpful tip to the user
180
+ */
181
+ static showTip(message) {
182
+ console.log(chalk.cyan(`šŸ’” Tip: ${message}`));
183
+ }
184
+ /**
185
+ * Show a warning to the user
186
+ */
187
+ static showWarning(message) {
188
+ console.log(chalk.yellow(`āš ļø Warning: ${message}`));
189
+ }
190
+ /**
191
+ * Show information to the user
192
+ */
193
+ static showInfo(message) {
194
+ console.log(chalk.blue(`ā„¹ļø ${message}`));
195
+ }
196
+ /**
197
+ * Show a success message
198
+ */
199
+ static showSuccess(message) {
200
+ console.log(chalk.green(`āœ… ${message}`));
201
+ }
202
+ /**
203
+ * Show available options for a choice
204
+ */
205
+ static showChoiceHelp(title, choices) {
206
+ console.log(chalk.cyan(`\nšŸ“‹ ${title}:`));
207
+ choices.forEach((choice) => {
208
+ console.log(chalk.gray(` • ${chalk.white(choice.name)}: ${choice.description}`));
209
+ });
210
+ console.log();
211
+ }
212
+ /**
213
+ * Show next steps after completion
214
+ */
215
+ static showNextSteps(title, steps) {
216
+ console.log(chalk.cyan(`\nšŸ“‹ ${title}:`));
217
+ steps.forEach((step, index) => {
218
+ console.log(chalk.gray(` ${index + 1}. ${step}`));
219
+ });
220
+ console.log();
221
+ }
222
+ /**
223
+ * Show a separator for better visual organization
224
+ */
225
+ static showSeparator(title) {
226
+ if (title) {
227
+ console.log(chalk.gray(`\n${'─'.repeat(50)}`));
228
+ console.log(chalk.cyan(`${title}`));
229
+ console.log(chalk.gray(`${'─'.repeat(50)}\n`));
230
+ }
231
+ else {
232
+ console.log(chalk.gray(`${'─'.repeat(50)}`));
233
+ }
234
+ }
235
+ }
236
+ /**
237
+ * Utility for consistent formatting of output
238
+ */
239
+ export class OutputFormatter {
240
+ /**
241
+ * Format a list of key-value pairs
242
+ */
243
+ static formatKeyValueList(items) {
244
+ const maxKeyLength = Math.max(...items.map((item) => item.key.length));
245
+ items.forEach((item) => {
246
+ const paddedKey = item.key.padEnd(maxKeyLength);
247
+ const color = item.highlight ? 'cyan' : 'gray';
248
+ console.log(` ${chalk[color](paddedKey)}: ${chalk.white(item.value)}`);
249
+ });
250
+ }
251
+ /**
252
+ * Format a file list with icons
253
+ */
254
+ static formatFileList(files) {
255
+ files.forEach((file) => {
256
+ const icon = file.type === 'directory' ? 'šŸ“' : 'šŸ“„';
257
+ const description = file.description
258
+ ? chalk.gray(` - ${file.description}`)
259
+ : '';
260
+ console.log(` ${icon} ${chalk.white(file.path)}${description}`);
261
+ });
262
+ }
263
+ /**
264
+ * Format command examples
265
+ */
266
+ static formatCommands(title, commands) {
267
+ console.log(chalk.cyan(`\n${title}:`));
268
+ commands.forEach((cmd) => {
269
+ console.log(` ${chalk.yellow(cmd.command)}`);
270
+ console.log(chalk.gray(` ${cmd.description}\n`));
271
+ });
272
+ }
273
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Security utilities for ARK CLI
3
+ */
4
+ export declare class SecurityUtils {
5
+ /**
6
+ * Validate that a path is safe and doesn't contain directory traversal attempts
7
+ */
8
+ static validatePath(filePath: string, context?: string): void;
9
+ /**
10
+ * Ensure a directory path is safe to create/write to
11
+ */
12
+ static validateOutputPath(outputPath: string, baseDir: string): void;
13
+ /**
14
+ * Sanitize file names to prevent issues
15
+ */
16
+ static sanitizeFileName(fileName: string): string;
17
+ /**
18
+ * Validate template content to prevent code injection
19
+ */
20
+ static validateTemplateContent(content: string, templatePath: string): void;
21
+ /**
22
+ * Safely create directories with proper permissions
23
+ */
24
+ static createDirectorySafe(dirPath: string, baseDir: string): Promise<void>;
25
+ /**
26
+ * Safely write files with proper permissions
27
+ */
28
+ static writeFileSafe(filePath: string, content: string, baseDir: string): Promise<void>;
29
+ /**
30
+ * Validate environment variables for safety
31
+ */
32
+ static sanitizeEnvironmentValue(value: string, varName: string): string;
33
+ /**
34
+ * Validate API keys and secrets
35
+ */
36
+ static validateSecret(secret: string, secretType: string): void;
37
+ }