@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.
- package/README.md +95 -0
- package/dist/commands/cluster/get-ip.d.ts +2 -0
- package/dist/commands/cluster/get-ip.js +32 -0
- package/dist/commands/cluster/get-type.d.ts +2 -0
- package/dist/commands/cluster/get-type.js +26 -0
- package/dist/commands/cluster/index.d.ts +2 -0
- package/dist/commands/cluster/index.js +10 -0
- package/dist/commands/completion.d.ts +2 -0
- package/dist/commands/completion.js +108 -0
- package/dist/commands/config.d.ts +5 -0
- package/dist/commands/config.js +327 -0
- package/dist/commands/generate/config.d.ts +145 -0
- package/dist/commands/generate/config.js +253 -0
- package/dist/commands/generate/generators/agent.d.ts +2 -0
- package/dist/commands/generate/generators/agent.js +156 -0
- package/dist/commands/generate/generators/index.d.ts +6 -0
- package/dist/commands/generate/generators/index.js +6 -0
- package/dist/commands/generate/generators/marketplace.d.ts +2 -0
- package/dist/commands/generate/generators/marketplace.js +304 -0
- package/dist/commands/generate/generators/mcpserver.d.ts +25 -0
- package/dist/commands/generate/generators/mcpserver.js +350 -0
- package/dist/commands/generate/generators/project.d.ts +2 -0
- package/dist/commands/generate/generators/project.js +784 -0
- package/dist/commands/generate/generators/query.d.ts +2 -0
- package/dist/commands/generate/generators/query.js +213 -0
- package/dist/commands/generate/generators/team.d.ts +2 -0
- package/dist/commands/generate/generators/team.js +407 -0
- package/dist/commands/generate/index.d.ts +24 -0
- package/dist/commands/generate/index.js +357 -0
- package/dist/commands/generate/templateDiscovery.d.ts +30 -0
- package/dist/commands/generate/templateDiscovery.js +94 -0
- package/dist/commands/generate/templateEngine.d.ts +78 -0
- package/dist/commands/generate/templateEngine.js +368 -0
- package/dist/commands/generate/utils/nameUtils.d.ts +35 -0
- package/dist/commands/generate/utils/nameUtils.js +110 -0
- package/dist/commands/generate/utils/projectUtils.d.ts +28 -0
- package/dist/commands/generate/utils/projectUtils.js +133 -0
- package/dist/components/DashboardCLI.d.ts +3 -0
- package/dist/components/DashboardCLI.js +149 -0
- package/dist/components/GeneratorUI.d.ts +3 -0
- package/dist/components/GeneratorUI.js +167 -0
- package/dist/components/statusChecker.d.ts +48 -0
- package/dist/components/statusChecker.js +251 -0
- package/dist/config.d.ts +42 -0
- package/dist/config.js +243 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +67 -0
- package/dist/lib/arkClient.d.ts +32 -0
- package/dist/lib/arkClient.js +43 -0
- package/dist/lib/cluster.d.ts +8 -0
- package/dist/lib/cluster.js +134 -0
- package/dist/lib/config.d.ts +82 -0
- package/dist/lib/config.js +223 -0
- package/dist/lib/consts.d.ts +10 -0
- package/dist/lib/consts.js +15 -0
- package/dist/lib/errors.d.ts +56 -0
- package/dist/lib/errors.js +208 -0
- package/dist/lib/exec.d.ts +5 -0
- package/dist/lib/exec.js +20 -0
- package/dist/lib/gatewayManager.d.ts +24 -0
- package/dist/lib/gatewayManager.js +85 -0
- package/dist/lib/kubernetes.d.ts +28 -0
- package/dist/lib/kubernetes.js +122 -0
- package/dist/lib/progress.d.ts +128 -0
- package/dist/lib/progress.js +273 -0
- package/dist/lib/security.d.ts +37 -0
- package/dist/lib/security.js +295 -0
- package/dist/lib/types.d.ts +37 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/wrappers/git.d.ts +2 -0
- package/dist/lib/wrappers/git.js +43 -0
- package/dist/ui/MainMenu.d.ts +3 -0
- package/dist/ui/MainMenu.js +116 -0
- package/dist/ui/statusFormatter.d.ts +9 -0
- package/dist/ui/statusFormatter.js +47 -0
- package/package.json +62 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared configuration for generators across CLI and UI
|
|
3
|
+
*/
|
|
4
|
+
export interface ProjectTypeChoice {
|
|
5
|
+
value: 'empty' | 'with-samples';
|
|
6
|
+
label: string;
|
|
7
|
+
shortLabel?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
recommended?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface GeneratorChoice {
|
|
13
|
+
value: string;
|
|
14
|
+
label: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
icon?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GeneratorDefaults {
|
|
19
|
+
projectType: 'empty' | 'with-samples';
|
|
20
|
+
skipModels: boolean;
|
|
21
|
+
skipGit: boolean;
|
|
22
|
+
getDefaultDestination: () => string;
|
|
23
|
+
getDefaultNamespace: (projectName: string) => string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Project type choices - shared between CLI and UI
|
|
27
|
+
*/
|
|
28
|
+
export declare const PROJECT_TYPE_CHOICES: ProjectTypeChoice[];
|
|
29
|
+
/**
|
|
30
|
+
* Available generator types - shared between CLI and UI
|
|
31
|
+
*/
|
|
32
|
+
export declare const GENERATOR_CHOICES: GeneratorChoice[];
|
|
33
|
+
/**
|
|
34
|
+
* Default configuration values with config manager integration
|
|
35
|
+
*/
|
|
36
|
+
export declare const GENERATOR_DEFAULTS: GeneratorDefaults;
|
|
37
|
+
/**
|
|
38
|
+
* Validation constants
|
|
39
|
+
*/
|
|
40
|
+
export declare const VALIDATION_CONSTANTS: {
|
|
41
|
+
readonly MAX_NAME_LENGTH: 63;
|
|
42
|
+
readonly MIN_NAME_LENGTH: 1;
|
|
43
|
+
readonly NAME_PATTERN: RegExp;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* UI-specific configurations
|
|
47
|
+
*/
|
|
48
|
+
export declare const UI_CONFIG: {
|
|
49
|
+
readonly messages: {
|
|
50
|
+
readonly projectNamePrompt: "Enter a name for your new agent project:";
|
|
51
|
+
readonly projectTypePrompt: "Choose project type:";
|
|
52
|
+
readonly generatorTypePrompt: "Choose what you'd like to generate:";
|
|
53
|
+
readonly nameTooLong: (max: number) => string;
|
|
54
|
+
readonly nameEmpty: "Name cannot be empty";
|
|
55
|
+
readonly nameInvalid: (suggested: string) => string;
|
|
56
|
+
readonly generationComplete: "Project Generated Successfully!";
|
|
57
|
+
readonly generationFailed: "Generation Failed";
|
|
58
|
+
};
|
|
59
|
+
readonly steps: {
|
|
60
|
+
readonly generatorType: "generator-type";
|
|
61
|
+
readonly projectName: "project-name";
|
|
62
|
+
readonly projectConfig: "project-config";
|
|
63
|
+
readonly generating: "generating";
|
|
64
|
+
readonly complete: "complete";
|
|
65
|
+
readonly error: "error";
|
|
66
|
+
};
|
|
67
|
+
readonly colors: {
|
|
68
|
+
readonly primary: "cyan";
|
|
69
|
+
readonly success: "green";
|
|
70
|
+
readonly error: "red";
|
|
71
|
+
readonly warning: "yellow";
|
|
72
|
+
readonly secondary: "gray";
|
|
73
|
+
};
|
|
74
|
+
readonly icons: {
|
|
75
|
+
readonly generator: "šÆ";
|
|
76
|
+
readonly project: "š¦";
|
|
77
|
+
readonly success: "ā
";
|
|
78
|
+
readonly error: "ā";
|
|
79
|
+
readonly warning: "ā ļø";
|
|
80
|
+
readonly info: "ā¹ļø";
|
|
81
|
+
readonly folder: "š";
|
|
82
|
+
readonly rocket: "š";
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* CLI-specific configurations
|
|
87
|
+
*/
|
|
88
|
+
export declare const CLI_CONFIG: {
|
|
89
|
+
readonly prompts: {
|
|
90
|
+
readonly projectType: {
|
|
91
|
+
readonly type: "list";
|
|
92
|
+
readonly name: "projectType";
|
|
93
|
+
readonly message: "Project type:";
|
|
94
|
+
readonly default: "empty" | "with-samples";
|
|
95
|
+
};
|
|
96
|
+
readonly parentDir: {
|
|
97
|
+
readonly type: "input";
|
|
98
|
+
readonly name: "parentDir";
|
|
99
|
+
readonly message: "Parent directory for project:";
|
|
100
|
+
readonly filter: (input: string) => string;
|
|
101
|
+
};
|
|
102
|
+
readonly namespace: {
|
|
103
|
+
readonly type: "input";
|
|
104
|
+
readonly name: "namespace";
|
|
105
|
+
readonly message: "Kubernetes namespace:";
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
readonly messages: {
|
|
109
|
+
readonly banner: "š ARK Agent Project Generator";
|
|
110
|
+
readonly checkingPrerequisites: "š Checking prerequisites...";
|
|
111
|
+
readonly projectConfiguration: "š Project Configuration";
|
|
112
|
+
readonly generatingProject: "š Generating project...";
|
|
113
|
+
readonly projectGenerated: "ā
Project generated successfully";
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Get project type choices formatted for inquirer (CLI)
|
|
118
|
+
*/
|
|
119
|
+
export declare function getInquirerProjectTypeChoices(): {
|
|
120
|
+
name: string;
|
|
121
|
+
value: "empty" | "with-samples";
|
|
122
|
+
short: string;
|
|
123
|
+
}[];
|
|
124
|
+
/**
|
|
125
|
+
* Get project type choices formatted for ink-select-input (UI)
|
|
126
|
+
*/
|
|
127
|
+
export declare function getUIProjectTypeChoices(): {
|
|
128
|
+
label: string;
|
|
129
|
+
value: "empty" | "with-samples";
|
|
130
|
+
}[];
|
|
131
|
+
/**
|
|
132
|
+
* Get generator choices formatted for ink-select-input (UI)
|
|
133
|
+
*/
|
|
134
|
+
export declare function getUIGeneratorChoices(): {
|
|
135
|
+
label: string;
|
|
136
|
+
value: string;
|
|
137
|
+
}[];
|
|
138
|
+
/**
|
|
139
|
+
* Get the recommended project type
|
|
140
|
+
*/
|
|
141
|
+
export declare function getRecommendedProjectType(): 'empty' | 'with-samples';
|
|
142
|
+
/**
|
|
143
|
+
* Get project type by value
|
|
144
|
+
*/
|
|
145
|
+
export declare function getProjectTypeChoice(value: 'empty' | 'with-samples'): ProjectTypeChoice | undefined;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared configuration for generators across CLI and UI
|
|
3
|
+
*/
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { ConfigManager } from '../../lib/config.js';
|
|
6
|
+
/**
|
|
7
|
+
* Project type choices - shared between CLI and UI
|
|
8
|
+
*/
|
|
9
|
+
export const PROJECT_TYPE_CHOICES = [
|
|
10
|
+
{
|
|
11
|
+
value: 'with-samples',
|
|
12
|
+
label: 'Project with samples (recommended for getting started)',
|
|
13
|
+
shortLabel: 'with-samples',
|
|
14
|
+
description: 'Includes sample agents, teams, models, and queries to get you started',
|
|
15
|
+
icon: 'šÆ',
|
|
16
|
+
recommended: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: 'empty',
|
|
20
|
+
label: 'Empty project (just the structure)',
|
|
21
|
+
shortLabel: 'empty',
|
|
22
|
+
description: 'Just the directory structure and configuration files',
|
|
23
|
+
icon: 'š',
|
|
24
|
+
recommended: false,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Available generator types - shared between CLI and UI
|
|
29
|
+
*/
|
|
30
|
+
export const GENERATOR_CHOICES = [
|
|
31
|
+
{
|
|
32
|
+
value: 'project',
|
|
33
|
+
label: 'Project - Generate a new agent project',
|
|
34
|
+
description: 'Create a complete ARK agent project with all necessary files and structure',
|
|
35
|
+
icon: 'š¦',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
value: 'agent',
|
|
39
|
+
label: 'Agent - Generate a single agent',
|
|
40
|
+
description: 'Create a new agent definition in the current project',
|
|
41
|
+
icon: 'š¤',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: 'team',
|
|
45
|
+
label: 'Team - Generate a team with multiple agents',
|
|
46
|
+
description: 'Create a team configuration with selected agents and strategy',
|
|
47
|
+
icon: 'š„',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
value: 'query',
|
|
51
|
+
label: 'Query - Generate a query to test agents or teams',
|
|
52
|
+
description: 'Create a query definition to test and interact with agents',
|
|
53
|
+
icon: 'ā',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: 'mcp-server',
|
|
57
|
+
label: 'MCP Server - Generate an MCP server with Kubernetes deployment',
|
|
58
|
+
description: 'Create an MCP server with Docker image and Kubernetes deployment configuration',
|
|
59
|
+
icon: 'š',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 'marketplace',
|
|
63
|
+
label: 'Marketplace - Generate a marketplace repository',
|
|
64
|
+
description: 'Create a central repository for sharing reusable ARK components',
|
|
65
|
+
icon: 'šŖ',
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
/**
|
|
69
|
+
* Default configuration values with config manager integration
|
|
70
|
+
*/
|
|
71
|
+
export const GENERATOR_DEFAULTS = {
|
|
72
|
+
get projectType() {
|
|
73
|
+
try {
|
|
74
|
+
const configManager = new ConfigManager();
|
|
75
|
+
return configManager.get('defaultProjectType');
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return 'with-samples';
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
get skipModels() {
|
|
82
|
+
try {
|
|
83
|
+
const configManager = new ConfigManager();
|
|
84
|
+
return configManager.get('skipModelsbyDefault');
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
get skipGit() {
|
|
91
|
+
try {
|
|
92
|
+
const configManager = new ConfigManager();
|
|
93
|
+
return configManager.get('skipGitByDefault');
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
getDefaultDestination: () => {
|
|
100
|
+
try {
|
|
101
|
+
const configManager = new ConfigManager();
|
|
102
|
+
const configured = configManager.get('defaultDestination');
|
|
103
|
+
if (configured && configured !== process.cwd()) {
|
|
104
|
+
return configured;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Fall through to default logic
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
// Get the path relative to this config file
|
|
112
|
+
// This file is at: tools/ark-cli/src/commands/generate/config.ts
|
|
113
|
+
// We want to go up to agents-at-scale and then to its parent
|
|
114
|
+
const configFileDir = new URL('.', import.meta.url).pathname;
|
|
115
|
+
const arkRoot = path.resolve(configFileDir, '../../../../../');
|
|
116
|
+
const parentDir = path.dirname(arkRoot);
|
|
117
|
+
return parentDir;
|
|
118
|
+
}
|
|
119
|
+
catch (_error) {
|
|
120
|
+
// Fallback to current working directory if we can't determine ark location
|
|
121
|
+
return process.cwd();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
getDefaultNamespace: (projectName) => projectName,
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Validation constants
|
|
128
|
+
*/
|
|
129
|
+
export const VALIDATION_CONSTANTS = {
|
|
130
|
+
MAX_NAME_LENGTH: 63,
|
|
131
|
+
MIN_NAME_LENGTH: 1,
|
|
132
|
+
NAME_PATTERN: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* UI-specific configurations
|
|
136
|
+
*/
|
|
137
|
+
export const UI_CONFIG = {
|
|
138
|
+
// Text and messages
|
|
139
|
+
messages: {
|
|
140
|
+
projectNamePrompt: 'Enter a name for your new agent project:',
|
|
141
|
+
projectTypePrompt: 'Choose project type:',
|
|
142
|
+
generatorTypePrompt: "Choose what you'd like to generate:",
|
|
143
|
+
nameTooLong: (max) => `Name must be ${max} characters or less`,
|
|
144
|
+
nameEmpty: 'Name cannot be empty',
|
|
145
|
+
nameInvalid: (suggested) => `Name must be lowercase kebab-case (suggested: "${suggested}")`,
|
|
146
|
+
generationComplete: 'Project Generated Successfully!',
|
|
147
|
+
generationFailed: 'Generation Failed',
|
|
148
|
+
},
|
|
149
|
+
// Step navigation
|
|
150
|
+
steps: {
|
|
151
|
+
generatorType: 'generator-type',
|
|
152
|
+
projectName: 'project-name',
|
|
153
|
+
projectConfig: 'project-config',
|
|
154
|
+
generating: 'generating',
|
|
155
|
+
complete: 'complete',
|
|
156
|
+
error: 'error',
|
|
157
|
+
},
|
|
158
|
+
// Icons and colors
|
|
159
|
+
colors: {
|
|
160
|
+
primary: 'cyan',
|
|
161
|
+
success: 'green',
|
|
162
|
+
error: 'red',
|
|
163
|
+
warning: 'yellow',
|
|
164
|
+
secondary: 'gray',
|
|
165
|
+
},
|
|
166
|
+
icons: {
|
|
167
|
+
generator: 'šÆ',
|
|
168
|
+
project: 'š¦',
|
|
169
|
+
success: 'ā
',
|
|
170
|
+
error: 'ā',
|
|
171
|
+
warning: 'ā ļø',
|
|
172
|
+
info: 'ā¹ļø',
|
|
173
|
+
folder: 'š',
|
|
174
|
+
rocket: 'š',
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* CLI-specific configurations
|
|
179
|
+
*/
|
|
180
|
+
export const CLI_CONFIG = {
|
|
181
|
+
// Inquirer prompt configurations
|
|
182
|
+
prompts: {
|
|
183
|
+
projectType: {
|
|
184
|
+
type: 'list',
|
|
185
|
+
name: 'projectType',
|
|
186
|
+
message: 'Project type:',
|
|
187
|
+
default: GENERATOR_DEFAULTS.projectType,
|
|
188
|
+
},
|
|
189
|
+
parentDir: {
|
|
190
|
+
type: 'input',
|
|
191
|
+
name: 'parentDir',
|
|
192
|
+
message: 'Parent directory for project:',
|
|
193
|
+
filter: (input) => input.replace(/^~/, process.env.HOME || '~'),
|
|
194
|
+
},
|
|
195
|
+
namespace: {
|
|
196
|
+
type: 'input',
|
|
197
|
+
name: 'namespace',
|
|
198
|
+
message: 'Kubernetes namespace:',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
// Console messages
|
|
202
|
+
messages: {
|
|
203
|
+
banner: 'š ARK Agent Project Generator',
|
|
204
|
+
checkingPrerequisites: 'š Checking prerequisites...',
|
|
205
|
+
projectConfiguration: 'š Project Configuration',
|
|
206
|
+
generatingProject: 'š Generating project...',
|
|
207
|
+
projectGenerated: 'ā
Project generated successfully',
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Get project type choices formatted for inquirer (CLI)
|
|
212
|
+
*/
|
|
213
|
+
export function getInquirerProjectTypeChoices() {
|
|
214
|
+
return PROJECT_TYPE_CHOICES.map((choice) => ({
|
|
215
|
+
name: choice.label,
|
|
216
|
+
value: choice.value,
|
|
217
|
+
short: choice.shortLabel || choice.value,
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get project type choices formatted for ink-select-input (UI)
|
|
222
|
+
*/
|
|
223
|
+
export function getUIProjectTypeChoices() {
|
|
224
|
+
return PROJECT_TYPE_CHOICES.map((choice) => ({
|
|
225
|
+
label: `${choice.icon || ''} ${choice.label}`,
|
|
226
|
+
value: choice.value,
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get generator choices formatted for ink-select-input (UI)
|
|
231
|
+
*/
|
|
232
|
+
export function getUIGeneratorChoices() {
|
|
233
|
+
return [
|
|
234
|
+
...GENERATOR_CHOICES.map((choice) => ({
|
|
235
|
+
label: `${choice.icon || ''} ${choice.label}`,
|
|
236
|
+
value: choice.value,
|
|
237
|
+
})),
|
|
238
|
+
{ label: 'š Back to main menu', value: 'back' },
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get the recommended project type
|
|
243
|
+
*/
|
|
244
|
+
export function getRecommendedProjectType() {
|
|
245
|
+
return (PROJECT_TYPE_CHOICES.find((choice) => choice.recommended)?.value ||
|
|
246
|
+
'with-samples');
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Get project type by value
|
|
250
|
+
*/
|
|
251
|
+
export function getProjectTypeChoice(value) {
|
|
252
|
+
return PROJECT_TYPE_CHOICES.find((choice) => choice.value === value);
|
|
253
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { TemplateEngine } from '../templateEngine.js';
|
|
6
|
+
import { TemplateDiscovery } from '../templateDiscovery.js';
|
|
7
|
+
import { toKebabCase, validateNameStrict } from '../utils/nameUtils.js';
|
|
8
|
+
import { getCurrentProjectInfo } from '../utils/projectUtils.js';
|
|
9
|
+
import { ErrorHandler, TemplateError, ValidationError, } from '../../../lib/errors.js';
|
|
10
|
+
export function createAgentGenerator() {
|
|
11
|
+
return {
|
|
12
|
+
name: 'agent',
|
|
13
|
+
description: 'Generate a new agent in the current project',
|
|
14
|
+
templatePath: 'templates/agent',
|
|
15
|
+
generate: async (name, destination, options) => {
|
|
16
|
+
const generator = new AgentGenerator();
|
|
17
|
+
await generator.generate(name, destination, options);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
class AgentGenerator {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.templateDiscovery = new TemplateDiscovery();
|
|
24
|
+
this.templateEngine = new TemplateEngine();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get agent configuration from user input and validation
|
|
28
|
+
*/
|
|
29
|
+
async getAgentConfig(name, _destination, _options) {
|
|
30
|
+
// Validate that we're in a project directory and get project info
|
|
31
|
+
const { projectName, projectDir } = getCurrentProjectInfo();
|
|
32
|
+
// Validate and normalize agent name
|
|
33
|
+
const agentName = toKebabCase(name);
|
|
34
|
+
validateNameStrict(agentName, 'agent name');
|
|
35
|
+
// Check if agent already exists
|
|
36
|
+
const agentsDir = path.join(projectDir, 'agents');
|
|
37
|
+
const agentFilePath = path.join(agentsDir, `${agentName}-agent.yaml`);
|
|
38
|
+
if (fs.existsSync(agentFilePath)) {
|
|
39
|
+
console.log(chalk.yellow(`ā ļø Agent file already exists: ${agentFilePath}`));
|
|
40
|
+
const { overwrite } = await inquirer.prompt([
|
|
41
|
+
{
|
|
42
|
+
type: 'confirm',
|
|
43
|
+
name: 'overwrite',
|
|
44
|
+
message: 'Do you want to overwrite the existing agent?',
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
if (!overwrite) {
|
|
49
|
+
throw new ValidationError('Agent generation cancelled by user', 'overwrite', [
|
|
50
|
+
`Use a different agent name`,
|
|
51
|
+
`Use --force flag to overwrite without prompting`,
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Ask if user wants to create a query for the agent
|
|
56
|
+
const { createQuery } = await inquirer.prompt([
|
|
57
|
+
{
|
|
58
|
+
type: 'confirm',
|
|
59
|
+
name: 'createQuery',
|
|
60
|
+
message: `Would you like to create a sample query for the ${agentName} agent?`,
|
|
61
|
+
default: true,
|
|
62
|
+
},
|
|
63
|
+
]);
|
|
64
|
+
return {
|
|
65
|
+
name,
|
|
66
|
+
agentName,
|
|
67
|
+
projectName,
|
|
68
|
+
projectDirectory: projectDir,
|
|
69
|
+
createQuery,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Generate the query file for the agent
|
|
74
|
+
*/
|
|
75
|
+
async generateQueryFile(config) {
|
|
76
|
+
const templatePath = this.templateDiscovery.getTemplatePath('query');
|
|
77
|
+
if (!this.templateDiscovery.templateExists('query')) {
|
|
78
|
+
throw new Error(`Query template not found at: ${templatePath}`);
|
|
79
|
+
}
|
|
80
|
+
// Set up template variables
|
|
81
|
+
const variables = {
|
|
82
|
+
queryName: config.agentName,
|
|
83
|
+
targetType: 'agent',
|
|
84
|
+
targetName: config.agentName,
|
|
85
|
+
projectName: config.projectName,
|
|
86
|
+
inputMessage: `Hello! Can you help me understand what you can do for the ${config.projectName} project?`,
|
|
87
|
+
};
|
|
88
|
+
this.templateEngine.setVariables(variables);
|
|
89
|
+
// Process the query template file
|
|
90
|
+
const templateFilePath = path.join(templatePath, 'query.template.yaml');
|
|
91
|
+
const destinationFilePath = path.join(config.projectDirectory, 'queries', `${config.agentName}-query.yaml`);
|
|
92
|
+
await this.templateEngine.processFile(templateFilePath, destinationFilePath);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Generate the agent file
|
|
96
|
+
*/
|
|
97
|
+
async generateAgentFile(config) {
|
|
98
|
+
const templatePath = this.templateDiscovery.getTemplatePath('agent');
|
|
99
|
+
if (!this.templateDiscovery.templateExists('agent')) {
|
|
100
|
+
throw new TemplateError(`Agent template not found at: ${templatePath}`, templatePath, [
|
|
101
|
+
'Ensure the templates directory exists',
|
|
102
|
+
'Check that the agent template is properly installed',
|
|
103
|
+
'Verify file permissions',
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
// Set up template variables
|
|
107
|
+
const variables = {
|
|
108
|
+
agentName: config.agentName,
|
|
109
|
+
projectName: config.projectName,
|
|
110
|
+
};
|
|
111
|
+
this.templateEngine.setVariables(variables);
|
|
112
|
+
// Process the agent template file
|
|
113
|
+
const templateFilePath = path.join(templatePath, 'agent.template.yaml');
|
|
114
|
+
const destinationFilePath = path.join(config.projectDirectory, 'agents', `${config.agentName}-agent.yaml`);
|
|
115
|
+
await this.templateEngine.processFile(templateFilePath, destinationFilePath);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Main generate method
|
|
119
|
+
*/
|
|
120
|
+
async generate(name, destination, options) {
|
|
121
|
+
return ErrorHandler.catchAndHandle(async () => {
|
|
122
|
+
console.log(chalk.blue(`š¤ ARK Agent Generator\n`));
|
|
123
|
+
// Get agent configuration
|
|
124
|
+
const config = await this.getAgentConfig(name, destination, options);
|
|
125
|
+
console.log(chalk.cyan(`š Agent Configuration:`));
|
|
126
|
+
console.log(chalk.gray(` Name: ${config.agentName}`));
|
|
127
|
+
console.log(chalk.gray(` Project: ${config.projectName}`));
|
|
128
|
+
console.log(chalk.gray(` Directory: ${config.projectDirectory}\n`));
|
|
129
|
+
// Generate the agent
|
|
130
|
+
console.log(chalk.blue(`š§ Generating agent: ${config.agentName}`));
|
|
131
|
+
await this.generateAgentFile(config);
|
|
132
|
+
// Generate query if requested
|
|
133
|
+
if (config.createQuery) {
|
|
134
|
+
console.log(chalk.blue(`š§ Generating query for agent: ${config.agentName}`));
|
|
135
|
+
await this.generateQueryFile(config);
|
|
136
|
+
}
|
|
137
|
+
console.log(chalk.green(`\nā
Successfully generated agent: ${config.agentName}`));
|
|
138
|
+
console.log(chalk.gray(`š Created: agents/${config.agentName}-agent.yaml`));
|
|
139
|
+
if (config.createQuery) {
|
|
140
|
+
console.log(chalk.gray(`š Created: queries/${config.agentName}-query.yaml`));
|
|
141
|
+
}
|
|
142
|
+
// Show next steps
|
|
143
|
+
console.log(chalk.cyan(`\nš Next Steps:`));
|
|
144
|
+
console.log(chalk.gray(` 1. Review and customise the agent configuration`));
|
|
145
|
+
if (config.createQuery) {
|
|
146
|
+
console.log(chalk.gray(` 2. Review and customise the query configuration`));
|
|
147
|
+
console.log(chalk.gray(` 3. Deploy with: helm upgrade --install ${config.projectName} .`));
|
|
148
|
+
console.log(chalk.gray(` 4. Test with: kubectl get agents,queries`));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
console.log(chalk.gray(` 2. Deploy with: helm upgrade --install ${config.projectName} .`));
|
|
152
|
+
console.log(chalk.gray(` 3. Test with: kubectl get agents`));
|
|
153
|
+
}
|
|
154
|
+
}, 'Generating agent');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createProjectGenerator } from './project.js';
|
|
2
|
+
export { createAgentGenerator } from './agent.js';
|
|
3
|
+
export { createTeamGenerator } from './team.js';
|
|
4
|
+
export { createQueryGenerator } from './query.js';
|
|
5
|
+
export { createMcpServerGenerator } from './mcpserver.js';
|
|
6
|
+
export { createMarketplaceGenerator } from './marketplace.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createProjectGenerator } from './project.js';
|
|
2
|
+
export { createAgentGenerator } from './agent.js';
|
|
3
|
+
export { createTeamGenerator } from './team.js';
|
|
4
|
+
export { createQueryGenerator } from './query.js';
|
|
5
|
+
export { createMcpServerGenerator } from './mcpserver.js';
|
|
6
|
+
export { createMarketplaceGenerator } from './marketplace.js';
|