@symplek/cli 0.0.0-stage ā 0.2.0-beta.0
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/CHANGELOG.md +47 -0
- package/LICENSE +21 -0
- package/README.md +74 -2
- package/bin/symplek.js +5 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +44 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +36 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +467 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/generate.d.ts +26 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +491 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/init.d.ts +46 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +350 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/migrate.d.ts +41 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +518 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/validate.d.ts +252 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +515 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +24 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +39 -0
- package/dist/models.js.map +1 -0
- package/dist/naming.d.ts +20 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +48 -0
- package/dist/naming.js.map +1 -0
- package/dist/templates/agent/agent.ts.template +41 -0
- package/dist/templates/agent/general.yaml.template +34 -0
- package/dist/templates/agent/researcher.yaml.template +42 -0
- package/dist/templates/agent/reviewer.yaml.template +51 -0
- package/dist/templates/project/full/.github/workflows/ci.yml.template +34 -0
- package/dist/templates/project/full/.gitignore.template +6 -0
- package/dist/templates/project/full/Dockerfile.template +43 -0
- package/dist/templates/project/full/README.md.template +77 -0
- package/dist/templates/project/full/agents/example.yaml.template +16 -0
- package/dist/templates/project/full/package.json.template +30 -0
- package/dist/templates/project/full/src/index.ts.template +43 -0
- package/dist/templates/project/full/src/symplek.config.ts.template +20 -0
- package/dist/templates/project/full/src/tools/index.ts.template +73 -0
- package/dist/templates/project/full/tests/example.test.ts.template +49 -0
- package/dist/templates/project/full/tsconfig.json.template +18 -0
- package/dist/templates/project/minimal/.gitignore.template +6 -0
- package/dist/templates/project/minimal/agents/example.yaml.template +16 -0
- package/dist/templates/project/minimal/package.json.template +27 -0
- package/dist/templates/project/minimal/src/index.ts.template +43 -0
- package/dist/templates/project/minimal/src/symplek.config.ts.template +20 -0
- package/dist/templates/project/minimal/tsconfig.json.template +18 -0
- package/dist/templates/project/standard/.gitignore.template +6 -0
- package/dist/templates/project/standard/README.md.template +77 -0
- package/dist/templates/project/standard/agents/example.yaml.template +16 -0
- package/dist/templates/project/standard/package.json.template +30 -0
- package/dist/templates/project/standard/src/index.ts.template +43 -0
- package/dist/templates/project/standard/src/symplek.config.ts.template +20 -0
- package/dist/templates/project/standard/src/tools/index.ts.template +73 -0
- package/dist/templates/project/standard/tests/example.test.ts.template +49 -0
- package/dist/templates/project/standard/tsconfig.json.template +18 -0
- package/dist/utils/templates.d.ts +41 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +133 -0
- package/dist/utils/templates.js.map +1 -0
- package/package.json +60 -3
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `symplek add` command - scaffolds new components
|
|
4
|
+
* Supports: agent (more types coming in future stories)
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.kebabToCamel = void 0;
|
|
11
|
+
exports.validateAgentName = validateAgentName;
|
|
12
|
+
exports.generateAgentYaml = generateAgentYaml;
|
|
13
|
+
exports.generateAgentTypeScript = generateAgentTypeScript;
|
|
14
|
+
exports.generateAgentTest = generateAgentTest;
|
|
15
|
+
exports.createAddCommand = createAddCommand;
|
|
16
|
+
const node_fs_1 = require("node:fs");
|
|
17
|
+
const node_path_1 = require("node:path");
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const commander_1 = require("commander");
|
|
20
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
21
|
+
const ora_1 = __importDefault(require("ora"));
|
|
22
|
+
const models_js_1 = require("../models.js");
|
|
23
|
+
const naming_js_1 = require("../naming.js");
|
|
24
|
+
const generate_js_1 = require("./generate.js");
|
|
25
|
+
const templates_js_1 = require("../utils/templates.js");
|
|
26
|
+
/** Available tools for agent creation */
|
|
27
|
+
const AVAILABLE_TOOLS = [
|
|
28
|
+
{ name: "search", value: "search", description: "Web search capability" },
|
|
29
|
+
{ name: "fetch_url", value: "fetch_url", description: "Fetch URL content" },
|
|
30
|
+
{ name: "read_file", value: "read_file", description: "Read local files" },
|
|
31
|
+
{ name: "search_code", value: "search_code", description: "Search codebase" },
|
|
32
|
+
{ name: "calculator", value: "calculator", description: "Math operations" },
|
|
33
|
+
];
|
|
34
|
+
/** Agent type display names and descriptions */
|
|
35
|
+
const AGENT_TYPES = {
|
|
36
|
+
general: {
|
|
37
|
+
name: "General",
|
|
38
|
+
description: "Generic conversational assistant",
|
|
39
|
+
},
|
|
40
|
+
researcher: {
|
|
41
|
+
name: "Researcher",
|
|
42
|
+
description: "Research and information synthesis",
|
|
43
|
+
},
|
|
44
|
+
reviewer: {
|
|
45
|
+
name: "Reviewer",
|
|
46
|
+
description: "Code review and analysis",
|
|
47
|
+
},
|
|
48
|
+
typescript: {
|
|
49
|
+
name: "TypeScript",
|
|
50
|
+
description: "Full TypeScript implementation",
|
|
51
|
+
},
|
|
52
|
+
custom: {
|
|
53
|
+
name: "Custom",
|
|
54
|
+
description: "Minimal template - customize everything",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
var naming_js_2 = require("../naming.js");
|
|
58
|
+
Object.defineProperty(exports, "kebabToCamel", { enumerable: true, get: function () { return naming_js_2.kebabToCamel; } });
|
|
59
|
+
/**
|
|
60
|
+
* True when `name` can be used as an agent name: kebab-case, and not a word
|
|
61
|
+
* that would make the exported function unparseable.
|
|
62
|
+
*/
|
|
63
|
+
function validateAgentName(name) {
|
|
64
|
+
return (0, naming_js_1.agentNameProblem)(name) === undefined;
|
|
65
|
+
}
|
|
66
|
+
/** True when the project in `dir` lists `name` among its dependencies. */
|
|
67
|
+
function projectHasDependency(dir, name) {
|
|
68
|
+
try {
|
|
69
|
+
const manifest = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(dir, "package.json"), "utf-8"));
|
|
70
|
+
return Boolean(manifest.dependencies?.[name] ?? manifest.devDependencies?.[name]);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// No readable package.json: nothing here can run a test file.
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Generate YAML content for an agent
|
|
79
|
+
*/
|
|
80
|
+
function generateAgentYaml(name, options) {
|
|
81
|
+
const vars = {
|
|
82
|
+
name,
|
|
83
|
+
model: options.model,
|
|
84
|
+
agentName: (0, naming_js_1.kebabToCamel)(name),
|
|
85
|
+
};
|
|
86
|
+
// Custom type uses general template with minimal config
|
|
87
|
+
const templateType = options.type === "custom" ? "general" : options.type;
|
|
88
|
+
// Load base template
|
|
89
|
+
let content = (0, templates_js_1.loadAgentTemplate)(templateType, vars);
|
|
90
|
+
// For custom type, strip most of the template to minimal
|
|
91
|
+
if (options.type === "custom") {
|
|
92
|
+
// The model id goes into the YAML inside double quotes, so it must be
|
|
93
|
+
// well-formed: the shape check rules out the quotes and newlines that
|
|
94
|
+
// would end the string early.
|
|
95
|
+
const safeModel = (0, models_js_1.isModelId)(options.model)
|
|
96
|
+
? options.model
|
|
97
|
+
: models_js_1.DEFAULT_MODEL;
|
|
98
|
+
content = `# Custom agent - minimal template
|
|
99
|
+
# Created with: symplek add agent ${name} --type custom
|
|
100
|
+
|
|
101
|
+
name: ${name}
|
|
102
|
+
version: "1.0.0"
|
|
103
|
+
|
|
104
|
+
model: "${safeModel}"
|
|
105
|
+
|
|
106
|
+
systemPrompt: |
|
|
107
|
+
You are ${name}, a helpful AI assistant.
|
|
108
|
+
Customize this prompt for your specific use case.
|
|
109
|
+
|
|
110
|
+
temperature: 0.7
|
|
111
|
+
maxTokens: 2048
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
114
|
+
// Add custom tools if provided and different from template defaults
|
|
115
|
+
if (options.tools && options.tools.length > 0 && options.type === "custom") {
|
|
116
|
+
content += `
|
|
117
|
+
tools:
|
|
118
|
+
${options.tools.map((tool) => ` - name: ${tool}`).join("\n")}
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
return content;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Generate TypeScript content for an agent
|
|
125
|
+
*/
|
|
126
|
+
function generateAgentTypeScript(name, options) {
|
|
127
|
+
const vars = {
|
|
128
|
+
name,
|
|
129
|
+
model: options.model,
|
|
130
|
+
agentName: (0, naming_js_1.kebabToCamel)(name),
|
|
131
|
+
};
|
|
132
|
+
return (0, templates_js_1.loadAgentTemplate)("typescript", vars);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Generate test file content for an agent
|
|
136
|
+
*/
|
|
137
|
+
function generateAgentTest(name) {
|
|
138
|
+
const agentName = (0, naming_js_1.kebabToCamel)(name);
|
|
139
|
+
return `/**
|
|
140
|
+
* Tests for the ${name} agent
|
|
141
|
+
* Generated by: symplek add agent ${name}
|
|
142
|
+
*/
|
|
143
|
+
import { createContext } from "@symplek/core";
|
|
144
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
145
|
+
|
|
146
|
+
// Only the model call is replaced, so these tests need no API key and make no
|
|
147
|
+
// network request. The agent under test is the real one in ../agents/${name}.
|
|
148
|
+
const { ai } = vi.hoisted(() => ({ ai: vi.fn() }));
|
|
149
|
+
vi.mock("@symplek/core/server", async (importOriginal) => ({
|
|
150
|
+
...(await importOriginal<typeof import("@symplek/core/server")>()),
|
|
151
|
+
ai,
|
|
152
|
+
}));
|
|
153
|
+
|
|
154
|
+
import { ${agentName} } from "../agents/${name}";
|
|
155
|
+
|
|
156
|
+
describe("${name} agent", () => {
|
|
157
|
+
beforeEach(() => {
|
|
158
|
+
ai.mockReset();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("does nothing until it is run", () => {
|
|
162
|
+
${agentName}("Hello");
|
|
163
|
+
expect(ai).not.toHaveBeenCalled();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("sends the prompt to the model and returns the reply", async () => {
|
|
167
|
+
ai.mockResolvedValue("a reply");
|
|
168
|
+
|
|
169
|
+
const result = await ${agentName}("Hello").run(createContext());
|
|
170
|
+
|
|
171
|
+
expect(result.value).toBe("a reply");
|
|
172
|
+
expect(ai).toHaveBeenCalledTimes(1);
|
|
173
|
+
expect(ai.mock.calls[0][0]).toBe("Hello");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("surfaces a model failure instead of swallowing it", async () => {
|
|
177
|
+
ai.mockRejectedValue(new Error("provider unavailable"));
|
|
178
|
+
|
|
179
|
+
await expect(${agentName}("Hello").run(createContext())).rejects.toThrow();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Prompt user for agent configuration
|
|
186
|
+
*/
|
|
187
|
+
async function promptAgentConfig() {
|
|
188
|
+
const answers = await inquirer_1.default.prompt([
|
|
189
|
+
{
|
|
190
|
+
type: "list",
|
|
191
|
+
name: "type",
|
|
192
|
+
message: "Select agent type:",
|
|
193
|
+
choices: Object.entries(AGENT_TYPES).map(([value, { name, description }]) => ({
|
|
194
|
+
name: `${name} - ${description}`,
|
|
195
|
+
value,
|
|
196
|
+
})),
|
|
197
|
+
default: "general",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
type: "list",
|
|
201
|
+
name: "model",
|
|
202
|
+
message: "Select AI model:",
|
|
203
|
+
choices: models_js_1.SUGGESTED_MODELS.map((model) => ({ name: model, value: model })),
|
|
204
|
+
default: models_js_1.DEFAULT_MODEL,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
type: "checkbox",
|
|
208
|
+
name: "tools",
|
|
209
|
+
message: "Select tools (optional):",
|
|
210
|
+
choices: AVAILABLE_TOOLS.map((tool) => ({
|
|
211
|
+
name: `${tool.name} - ${tool.description}`,
|
|
212
|
+
value: tool.value,
|
|
213
|
+
})),
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
type: "confirm",
|
|
217
|
+
name: "createTest",
|
|
218
|
+
message: "Create test file?",
|
|
219
|
+
default: true,
|
|
220
|
+
},
|
|
221
|
+
]);
|
|
222
|
+
return answers;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Prompt for overwrite confirmation
|
|
226
|
+
*/
|
|
227
|
+
async function promptOverwrite(filePath) {
|
|
228
|
+
const { overwrite } = await inquirer_1.default.prompt([
|
|
229
|
+
{
|
|
230
|
+
type: "confirm",
|
|
231
|
+
name: "overwrite",
|
|
232
|
+
message: `File ${filePath} already exists. Overwrite?`,
|
|
233
|
+
default: false,
|
|
234
|
+
},
|
|
235
|
+
]);
|
|
236
|
+
return overwrite;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Write file with directory creation
|
|
240
|
+
*/
|
|
241
|
+
function writeFile(filePath, content) {
|
|
242
|
+
const dir = (0, node_path_1.dirname)(filePath);
|
|
243
|
+
if (!(0, node_fs_1.existsSync)(dir)) {
|
|
244
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
245
|
+
}
|
|
246
|
+
(0, node_fs_1.writeFileSync)(filePath, content, "utf-8");
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Create the add command with subcommands
|
|
250
|
+
*/
|
|
251
|
+
function createAddCommand() {
|
|
252
|
+
const addCommand = new commander_1.Command("add").description("Add new components to your project");
|
|
253
|
+
// symplek add agent <name>
|
|
254
|
+
addCommand
|
|
255
|
+
.command("agent <name>")
|
|
256
|
+
.description("Scaffold a new AI agent")
|
|
257
|
+
.option("--yaml-only", "Only create YAML definition file")
|
|
258
|
+
.option("--ts-only", "Only create TypeScript implementation file")
|
|
259
|
+
.option("-t, --type <type>", "Agent type (general, researcher, reviewer, typescript, custom)")
|
|
260
|
+
.option("-m, --model <model>", "AI model to use")
|
|
261
|
+
.option("--no-test", "Skip test file creation")
|
|
262
|
+
.action(async (name, options) => {
|
|
263
|
+
// Validate the name: kebab-case, and usable as a function name.
|
|
264
|
+
const nameProblem = (0, naming_js_1.agentNameProblem)(name);
|
|
265
|
+
if (nameProblem) {
|
|
266
|
+
console.error(chalk_1.default.red(`Error: ${nameProblem}`));
|
|
267
|
+
console.error(chalk_1.default.gray(` Got: "${name}"`));
|
|
268
|
+
console.error(chalk_1.default.gray(` Valid examples: research-agent, code-reviewer, my-bot`));
|
|
269
|
+
process.exit(1);
|
|
270
|
+
}
|
|
271
|
+
// Determine file paths
|
|
272
|
+
const cwd = process.cwd();
|
|
273
|
+
const yamlPath = (0, node_path_1.join)(cwd, "agents", `${name}.yaml`);
|
|
274
|
+
const tsPath = (0, node_path_1.join)(cwd, "agents", `${name}.ts`);
|
|
275
|
+
const testPath = (0, node_path_1.join)(cwd, "tests", `${name}.test.ts`);
|
|
276
|
+
// Get configuration - either from options or prompts
|
|
277
|
+
let config;
|
|
278
|
+
// An unknown --type would otherwise reach the template loader and
|
|
279
|
+
// fail there with a file-not-found error that names no valid choice.
|
|
280
|
+
if (options.type !== undefined &&
|
|
281
|
+
!Object.keys(AGENT_TYPES).includes(options.type)) {
|
|
282
|
+
console.error(chalk_1.default.red(`Error: unknown agent type "${options.type}"`));
|
|
283
|
+
console.error(chalk_1.default.gray(` Use one of: ${Object.keys(AGENT_TYPES).join(", ")}`));
|
|
284
|
+
process.exit(1);
|
|
285
|
+
}
|
|
286
|
+
if (options.model !== undefined && !(0, models_js_1.isModelId)(options.model)) {
|
|
287
|
+
console.error(chalk_1.default.red(`Error: invalid model id "${options.model}"`));
|
|
288
|
+
console.error(chalk_1.default.gray(` ${models_js_1.MODEL_ID_HINT}`));
|
|
289
|
+
process.exit(1);
|
|
290
|
+
}
|
|
291
|
+
if (options.yamlOnly && options.tsOnly) {
|
|
292
|
+
console.error(chalk_1.default.red("Error: --yaml-only and --ts-only cannot be used together"));
|
|
293
|
+
process.exit(1);
|
|
294
|
+
}
|
|
295
|
+
if (options.type || options.model) {
|
|
296
|
+
// Either flag makes the run non-interactive; the other takes its
|
|
297
|
+
// default. Asking again would throw away what was passed.
|
|
298
|
+
config = {
|
|
299
|
+
type: (options.type ?? "general"),
|
|
300
|
+
model: options.model ?? models_js_1.DEFAULT_MODEL,
|
|
301
|
+
tools: [],
|
|
302
|
+
createTest: options.test !== false,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
else if (!process.stdin.isTTY) {
|
|
306
|
+
console.error(chalk_1.default.red("Error: no terminal to ask questions on."));
|
|
307
|
+
console.error(chalk_1.default.gray(` Pass --type (${Object.keys(AGENT_TYPES).join(", ")}) and optionally --model.`));
|
|
308
|
+
process.exit(1);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
// Interactive mode
|
|
312
|
+
console.log(chalk_1.default.blue(`\nCreating agent: ${chalk_1.default.bold(name)}\n`));
|
|
313
|
+
config = await promptAgentConfig();
|
|
314
|
+
}
|
|
315
|
+
if (config.type === "typescript" && options.yamlOnly) {
|
|
316
|
+
console.error(chalk_1.default.red("Error: the typescript agent type has no YAML file, so --yaml-only leaves nothing to create"));
|
|
317
|
+
process.exit(1);
|
|
318
|
+
}
|
|
319
|
+
const filesToCreate = [];
|
|
320
|
+
// Determine which files to create
|
|
321
|
+
// The "typescript" type is a hand-written agent with no YAML source.
|
|
322
|
+
// Writing a YAML file for it put TypeScript into agents/<name>.yaml,
|
|
323
|
+
// which then failed `symplek validate` and `symplek generate`.
|
|
324
|
+
const createYaml = !options.tsOnly && config.type !== "typescript";
|
|
325
|
+
// For a YAML-defined agent the TypeScript is generated from the YAML,
|
|
326
|
+
// by the same code `symplek generate` runs. Writing a separate
|
|
327
|
+
// hand-editable file here meant the next `symplek generate` silently
|
|
328
|
+
// replaced whatever the user had put in it.
|
|
329
|
+
const generateTs = createYaml && !options.yamlOnly;
|
|
330
|
+
// A hand-written TypeScript agent is created only when there is no
|
|
331
|
+
// YAML to generate from: the typescript type, or --ts-only.
|
|
332
|
+
const createTs = !createYaml && !options.yamlOnly;
|
|
333
|
+
// The test needs the TypeScript agent, and a test runner to run it.
|
|
334
|
+
const canRunTests = projectHasDependency(cwd, "vitest");
|
|
335
|
+
const writesTs = generateTs || createTs;
|
|
336
|
+
const createTest = config.createTest && writesTs && canRunTests;
|
|
337
|
+
// Generation refuses to replace a hand-written agent. Find that out
|
|
338
|
+
// before anything is written, so a refusal leaves no files behind.
|
|
339
|
+
if (generateTs && (0, generate_js_1.isHandWritten)(tsPath)) {
|
|
340
|
+
console.error(chalk_1.default.red(`Error: ${tsPath} already exists and was not generated from YAML. Move or delete it, then run this command again`));
|
|
341
|
+
process.exit(1);
|
|
342
|
+
}
|
|
343
|
+
// Check for existing files and prepare content
|
|
344
|
+
if (createYaml) {
|
|
345
|
+
if ((0, node_fs_1.existsSync)(yamlPath)) {
|
|
346
|
+
const shouldOverwrite = await promptOverwrite(yamlPath);
|
|
347
|
+
if (!shouldOverwrite) {
|
|
348
|
+
console.log(chalk_1.default.yellow(`Skipping ${yamlPath}`));
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
filesToCreate.push({
|
|
352
|
+
path: yamlPath,
|
|
353
|
+
content: generateAgentYaml(name, config),
|
|
354
|
+
type: "YAML definition",
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
filesToCreate.push({
|
|
360
|
+
path: yamlPath,
|
|
361
|
+
content: generateAgentYaml(name, config),
|
|
362
|
+
type: "YAML definition",
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (createTs) {
|
|
367
|
+
if ((0, node_fs_1.existsSync)(tsPath)) {
|
|
368
|
+
const shouldOverwrite = await promptOverwrite(tsPath);
|
|
369
|
+
if (!shouldOverwrite) {
|
|
370
|
+
console.log(chalk_1.default.yellow(`Skipping ${tsPath}`));
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
filesToCreate.push({
|
|
374
|
+
path: tsPath,
|
|
375
|
+
content: generateAgentTypeScript(name, config),
|
|
376
|
+
type: "TypeScript implementation",
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
filesToCreate.push({
|
|
382
|
+
path: tsPath,
|
|
383
|
+
content: generateAgentTypeScript(name, config),
|
|
384
|
+
type: "TypeScript implementation",
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (createTest) {
|
|
389
|
+
if ((0, node_fs_1.existsSync)(testPath)) {
|
|
390
|
+
const shouldOverwrite = await promptOverwrite(testPath);
|
|
391
|
+
if (!shouldOverwrite) {
|
|
392
|
+
console.log(chalk_1.default.yellow(`Skipping ${testPath}`));
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
filesToCreate.push({
|
|
396
|
+
path: testPath,
|
|
397
|
+
content: generateAgentTest(name),
|
|
398
|
+
type: "test file",
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
filesToCreate.push({
|
|
404
|
+
path: testPath,
|
|
405
|
+
content: generateAgentTest(name),
|
|
406
|
+
type: "test file",
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
// Create files
|
|
411
|
+
if (filesToCreate.length === 0) {
|
|
412
|
+
console.log(chalk_1.default.yellow("\nNo files to create."));
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const spinner = (0, ora_1.default)("Creating agent files...").start();
|
|
416
|
+
try {
|
|
417
|
+
const created = filesToCreate.map((file) => ({
|
|
418
|
+
path: file.path,
|
|
419
|
+
type: file.type,
|
|
420
|
+
}));
|
|
421
|
+
for (const file of filesToCreate) {
|
|
422
|
+
writeFile(file.path, file.content);
|
|
423
|
+
}
|
|
424
|
+
if (generateTs) {
|
|
425
|
+
const generated = (0, generate_js_1.generateFile)(yamlPath, undefined, true);
|
|
426
|
+
if (!generated.success) {
|
|
427
|
+
throw new Error(`Could not generate ${tsPath} from ${yamlPath}: ${generated.error}`);
|
|
428
|
+
}
|
|
429
|
+
created.push({ path: tsPath, type: "generated from the YAML" });
|
|
430
|
+
}
|
|
431
|
+
spinner.succeed("Agent files created successfully!");
|
|
432
|
+
// Summary
|
|
433
|
+
console.log(chalk_1.default.green("\nā Created files:"));
|
|
434
|
+
for (const file of created) {
|
|
435
|
+
console.log(chalk_1.default.gray(` - ${file.path} (${file.type})`));
|
|
436
|
+
}
|
|
437
|
+
// Next steps: only the ones that apply to the files just written.
|
|
438
|
+
const nextSteps = [];
|
|
439
|
+
if (createYaml) {
|
|
440
|
+
nextSteps.push(`Edit ${yamlPath} to customize your agent`);
|
|
441
|
+
}
|
|
442
|
+
if (generateTs) {
|
|
443
|
+
nextSteps.push(`Run "symplek generate" after each edit to refresh ${tsPath}. Do not edit that file by hand`);
|
|
444
|
+
}
|
|
445
|
+
if (createTs) {
|
|
446
|
+
nextSteps.push(`Edit ${tsPath} to customize your agent`);
|
|
447
|
+
}
|
|
448
|
+
nextSteps.push(writesTs
|
|
449
|
+
? `Import ${(0, naming_js_1.kebabToCamel)(name)} from ${tsPath} and call .run(createContext())`
|
|
450
|
+
: `Run "symplek generate" to write ${tsPath} from the YAML`);
|
|
451
|
+
console.log(chalk_1.default.blue("\nš Next steps:"));
|
|
452
|
+
nextSteps.forEach((step, index) => {
|
|
453
|
+
console.log(chalk_1.default.gray(` ${index + 1}. ${step}`));
|
|
454
|
+
});
|
|
455
|
+
if (config.createTest && writesTs && !canRunTests) {
|
|
456
|
+
console.log(chalk_1.default.gray("\n No test file was written: this project has no vitest. Add it, then run this command again for a test"));
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
catch (error) {
|
|
460
|
+
spinner.fail("Failed to create agent files");
|
|
461
|
+
console.error(chalk_1.default.red(error instanceof Error ? error.message : String(error)));
|
|
462
|
+
process.exit(1);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
return addCommand;
|
|
466
|
+
}
|
|
467
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAgEH,8CAEC;AAoBD,8CAwDC;AAKD,0DAcC;AAKD,8CA+CC;AAsFD,4CA0RC;AAnkBD,qCAA6E;AAC7E,yCAA0C;AAC1C,kDAA0B;AAC1B,yCAAoC;AACpC,wDAAgC;AAChC,8CAAsB;AACtB,4CAKsB;AACtB,4CAA8D;AAC9D,+CAA4D;AAC5D,wDAI+B;AAE/B,yCAAyC;AACzC,MAAM,eAAe,GAAG;IACtB,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE;IACzE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAE;IAC3E,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE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C,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAClE,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CACF,CAAC;IAEJ,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `symplek generate` command - generates TypeScript from YAML agent definitions
|
|
3
|
+
* @description Converts YAML agent definitions to type-safe TypeScript code
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
/** Result of generating a single file */
|
|
7
|
+
export interface GenerateResult {
|
|
8
|
+
inputFile: string;
|
|
9
|
+
outputFile: string;
|
|
10
|
+
success: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* True when a file is at `filePath` and this command did not write it. Such a
|
|
15
|
+
* file is somebody's work, so nothing here may replace it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isHandWritten(filePath: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Generate TypeScript for a single YAML file
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateFile(inputPath: string, outputDir?: string, quiet?: boolean): GenerateResult;
|
|
22
|
+
/**
|
|
23
|
+
* Create the generate command
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateCommand(): Command;
|
|
26
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuDpC,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAKvD;AAqUD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,KAAK,UAAQ,GACZ,cAAc,CAyDhB;AAuJD;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAwBzC"}
|