create-cogitator-app 0.2.0 → 0.2.1

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/dist/lib.js CHANGED
@@ -60,6 +60,9 @@ function providerConfig(provider) {
60
60
  }
61
61
  }
62
62
 
63
+ // src/templates/versions.ts
64
+ var ZOD_VERSION = "^4.6.5";
65
+
63
66
  // src/templates/basic.ts
64
67
  var basicTemplate = {
65
68
  files(options) {
@@ -128,7 +131,7 @@ var basicTemplate = {
128
131
  dependencies() {
129
132
  return {
130
133
  "@cogitator-ai/core": "latest",
131
- zod: "^3.23.0"
134
+ zod: ZOD_VERSION
132
135
  };
133
136
  },
134
137
  devDependencies() {
@@ -237,7 +240,7 @@ var memoryTemplate = {
237
240
  "@cogitator-ai/core": "latest",
238
241
  "@cogitator-ai/memory": "latest",
239
242
  "@cogitator-ai/redis": "latest",
240
- zod: "^3.23.0"
243
+ zod: ZOD_VERSION
241
244
  };
242
245
  },
243
246
  devDependencies() {
@@ -358,7 +361,7 @@ var swarmTemplate = {
358
361
  ` })`,
359
362
  ``,
360
363
  ` console.log('Result:', result.output)`,
361
- ` console.log('Strategy:', result.strategy)`,
364
+ ` console.log('Strategy:', team.strategyType)`,
362
365
  ``,
363
366
  ` await team.close()`,
364
367
  `}`,
@@ -378,7 +381,7 @@ var swarmTemplate = {
378
381
  return {
379
382
  "@cogitator-ai/core": "latest",
380
383
  "@cogitator-ai/swarms": "latest",
381
- zod: "^3.23.0"
384
+ zod: ZOD_VERSION
382
385
  };
383
386
  },
384
387
  devDependencies() {
@@ -441,7 +444,7 @@ var workflowTemplate = {
441
444
  providerConfig(options.provider),
442
445
  `})`,
443
446
  ``,
444
- `interface WorkflowState {`,
447
+ `type WorkflowState = {`,
445
448
  ` input: string`,
446
449
  ` analysis?: string`,
447
450
  ` processed?: string`,
@@ -502,7 +505,7 @@ var workflowTemplate = {
502
505
  return {
503
506
  "@cogitator-ai/core": "latest",
504
507
  "@cogitator-ai/workflows": "latest",
505
- zod: "^3.23.0"
508
+ zod: ZOD_VERSION
506
509
  };
507
510
  },
508
511
  devDependencies() {
@@ -607,7 +610,7 @@ var apiServerTemplate = {
607
610
  "@cogitator-ai/core": "latest",
608
611
  "@cogitator-ai/express": "latest",
609
612
  express: "^4.21.0",
610
- zod: "^3.23.0"
613
+ zod: ZOD_VERSION
611
614
  };
612
615
  },
613
616
  devDependencies() {
@@ -849,7 +852,7 @@ var nextjsTemplate = {
849
852
  next: "^15.0.0",
850
853
  react: "^19.0.0",
851
854
  "react-dom": "^19.0.0",
852
- zod: "^3.23.0"
855
+ zod: ZOD_VERSION
853
856
  };
854
857
  },
855
858
  devDependencies() {
@@ -1026,12 +1029,29 @@ function generateDockerCompose(provider) {
1026
1029
  }
1027
1030
 
1028
1031
  // src/templates/base/cogitator-yml.ts
1029
- function generateCogitatorYml(provider) {
1030
- const model = defaultModels[provider];
1031
- const lines = [`provider: ${provider}`, `model: ${model}`, ""];
1032
+ function generateCogitatorYml(provider, template) {
1033
+ const lines = [
1034
+ "llm:",
1035
+ ` defaultProvider: ${provider}`,
1036
+ ` defaultModel: ${defaultModels[provider]}`
1037
+ ];
1032
1038
  if (provider === "ollama") {
1033
- lines.push("ollama:", " baseUrl: http://localhost:11434", "");
1039
+ lines.push(
1040
+ " providers:",
1041
+ " ollama:",
1042
+ " baseUrl: ${OLLAMA_BASE_URL:-http://localhost:11434}"
1043
+ );
1034
1044
  }
1045
+ if (template === "memory") {
1046
+ lines.push(
1047
+ "",
1048
+ "memory:",
1049
+ " adapter: redis",
1050
+ " redis:",
1051
+ " url: ${REDIS_URL:-redis://localhost:6379}"
1052
+ );
1053
+ }
1054
+ lines.push("");
1035
1055
  return { path: "cogitator.yml", content: lines.join("\n") };
1036
1056
  }
1037
1057
 
@@ -1054,6 +1074,10 @@ function devCommand(pm) {
1054
1074
  return `${pm} dev`;
1055
1075
  }
1056
1076
 
1077
+ // src/utils/links.ts
1078
+ var DOCS_URL = "https://cogitator.app/docs";
1079
+ var REPO_URL = "https://github.com/cogitator-ai/Cogitator-AI";
1080
+
1057
1081
  // src/templates/base/readme.ts
1058
1082
  var templateNames = {
1059
1083
  basic: "Basic Agent",
@@ -1069,7 +1093,7 @@ function generateReadme(options) {
1069
1093
  const content = [
1070
1094
  `# ${options.name}`,
1071
1095
  "",
1072
- `> Created with [create-cogitator-app](https://github.com/cogitator-ai/cogitator) \u2014 ${templateName} template`,
1096
+ `> Created with [create-cogitator-app](${REPO_URL}) \u2014 ${templateName} template`,
1073
1097
  "",
1074
1098
  "## Getting Started",
1075
1099
  "",
@@ -1084,8 +1108,8 @@ function generateReadme(options) {
1084
1108
  ...options.docker ? ["## Docker Services", "", "```bash", "docker compose up -d", "```", ""] : [],
1085
1109
  "## Learn More",
1086
1110
  "",
1087
- "- [Cogitator Documentation](https://cogitator.dev/docs)",
1088
- "- [GitHub Repository](https://github.com/cogitator-ai/cogitator)",
1111
+ `- [Cogitator Documentation](${DOCS_URL})`,
1112
+ `- [GitHub Repository](${REPO_URL})`,
1089
1113
  ""
1090
1114
  ];
1091
1115
  return { path: "README.md", content: content.join("\n") };
@@ -1103,22 +1127,38 @@ function generatePnpmWorkspace() {
1103
1127
  }
1104
1128
 
1105
1129
  // src/utils/git.ts
1106
- import { execSync as execSync2 } from "child_process";
1130
+ import { execFileSync } from "child_process";
1131
+ var FALLBACK_IDENTITY = [
1132
+ "-c",
1133
+ "user.name=create-cogitator-app",
1134
+ "-c",
1135
+ "user.email=create-cogitator-app@localhost"
1136
+ ];
1107
1137
  function isGitInstalled() {
1108
1138
  try {
1109
- execSync2("git --version", { stdio: "ignore" });
1139
+ execFileSync("git", ["--version"], { stdio: "ignore" });
1110
1140
  return true;
1111
1141
  } catch {
1112
1142
  return false;
1113
1143
  }
1114
1144
  }
1145
+ function hasIdentity(cwd) {
1146
+ try {
1147
+ const name = execFileSync("git", ["config", "user.name"], { cwd, encoding: "utf8" }).trim();
1148
+ const email = execFileSync("git", ["config", "user.email"], { cwd, encoding: "utf8" }).trim();
1149
+ return name.length > 0 && email.length > 0;
1150
+ } catch {
1151
+ return false;
1152
+ }
1153
+ }
1115
1154
  function initGitRepo(cwd) {
1116
- execSync2("git init", { cwd, stdio: "ignore" });
1117
- execSync2("git add -A", { cwd, stdio: "ignore" });
1118
- execSync2(
1119
- 'git -c user.name="Cogitator" -c user.email="init@cogitator.dev" commit -m "feat: initial project scaffold"',
1120
- { cwd, stdio: "ignore" }
1121
- );
1155
+ execFileSync("git", ["init"], { cwd, stdio: "ignore" });
1156
+ execFileSync("git", ["add", "-A"], { cwd, stdio: "ignore" });
1157
+ const identity = hasIdentity(cwd) ? [] : FALLBACK_IDENTITY;
1158
+ execFileSync("git", [...identity, "commit", "-m", "feat: initial project scaffold"], {
1159
+ cwd,
1160
+ stdio: "ignore"
1161
+ });
1122
1162
  }
1123
1163
 
1124
1164
  // src/scaffold.ts
@@ -1148,7 +1188,7 @@ function collectFiles(options) {
1148
1188
  files.push(...template.files(options));
1149
1189
  files.push(generateGitignore());
1150
1190
  files.push(generateEnvExample(options.provider, options.template));
1151
- files.push(generateCogitatorYml(options.provider));
1191
+ files.push(generateCogitatorYml(options.provider, options.template));
1152
1192
  files.push(generateReadme(options));
1153
1193
  if (options.template !== "nextjs") {
1154
1194
  files.push(generateTsconfig());
@@ -1232,78 +1272,83 @@ function parseArgs(args) {
1232
1272
  }
1233
1273
  return parsed;
1234
1274
  }
1235
- async function collectOptions(args) {
1236
- const rawName = args.name || await p2.text({
1237
- message: "Where should we create your project?",
1238
- placeholder: "./my-agents",
1239
- defaultValue: "my-agents",
1240
- validate: (value) => {
1241
- if (value && !value.trim()) return "Project name is required";
1242
- return void 0;
1243
- }
1244
- });
1245
- if (p2.isCancel(rawName)) {
1275
+ var defaultAnswers = {
1276
+ name: "my-agents",
1277
+ template: "basic",
1278
+ provider: "ollama",
1279
+ docker: true,
1280
+ git: true
1281
+ };
1282
+ function unlessCancelled(answer) {
1283
+ if (p2.isCancel(answer)) {
1246
1284
  p2.cancel("Operation cancelled.");
1247
1285
  process.exit(0);
1248
1286
  }
1287
+ return answer;
1288
+ }
1289
+ async function collectOptions(args) {
1290
+ const interactive = !args.yes;
1291
+ const rawName = args.name || (interactive ? unlessCancelled(
1292
+ await p2.text({
1293
+ message: "Where should we create your project?",
1294
+ placeholder: `./${defaultAnswers.name}`,
1295
+ defaultValue: defaultAnswers.name,
1296
+ validate: (value) => {
1297
+ if (value && !value.trim()) return "Project name is required";
1298
+ return void 0;
1299
+ }
1300
+ })
1301
+ ) : defaultAnswers.name);
1249
1302
  const name = rawName.trim();
1250
1303
  const projectName = path2.basename(path2.normalize(name).replace(/^\.\//, "").replace(/^\.\\/, ""));
1251
1304
  const projectPath = path2.resolve(process.cwd(), name);
1252
- const template = args.template || await p2.select({
1253
- message: "Which template would you like?",
1254
- options: templateChoices
1255
- });
1256
- if (p2.isCancel(template)) {
1257
- p2.cancel("Operation cancelled.");
1258
- process.exit(0);
1259
- }
1260
- const provider = args.provider || await p2.select({
1261
- message: "Which LLM provider?",
1262
- options: [
1263
- {
1264
- value: "ollama",
1265
- label: "Ollama",
1266
- hint: "local, free \u2014 requires Ollama installed"
1267
- },
1268
- { value: "openai", label: "OpenAI", hint: "GPT-4o" },
1269
- { value: "anthropic", label: "Anthropic", hint: "Claude Sonnet" },
1270
- { value: "google", label: "Google Gemini", hint: "Gemini 2.5 Flash" }
1271
- ]
1272
- });
1273
- if (p2.isCancel(provider)) {
1274
- p2.cancel("Operation cancelled.");
1275
- process.exit(0);
1276
- }
1277
- const packageManager = args.packageManager || await p2.select({
1278
- message: "Package manager?",
1279
- options: [
1280
- { value: "pnpm", label: "pnpm" },
1281
- { value: "npm", label: "npm" },
1282
- { value: "yarn", label: "yarn" },
1283
- { value: "bun", label: "bun" }
1284
- ],
1285
- initialValue: detectPackageManager()
1286
- });
1287
- if (p2.isCancel(packageManager)) {
1288
- p2.cancel("Operation cancelled.");
1289
- process.exit(0);
1290
- }
1291
- const docker = args.docker ?? await p2.confirm({
1292
- message: "Include Docker Compose? (Redis + Postgres" + (provider === "ollama" ? " + Ollama)" : ")"),
1293
- initialValue: true
1294
- });
1295
- if (p2.isCancel(docker)) {
1296
- p2.cancel("Operation cancelled.");
1297
- process.exit(0);
1298
- }
1299
- const git = args.git ?? await p2.confirm({
1300
- message: "Initialize git repository?",
1301
- initialValue: true
1302
- });
1303
- if (p2.isCancel(git)) {
1304
- p2.cancel("Operation cancelled.");
1305
- process.exit(0);
1306
- }
1305
+ const template = args.template ?? (interactive ? unlessCancelled(
1306
+ await p2.select({
1307
+ message: "Which template would you like?",
1308
+ options: templateChoices,
1309
+ initialValue: defaultAnswers.template
1310
+ })
1311
+ ) : defaultAnswers.template);
1312
+ const provider = args.provider ?? (interactive ? unlessCancelled(
1313
+ await p2.select({
1314
+ message: "Which LLM provider?",
1315
+ options: [
1316
+ {
1317
+ value: "ollama",
1318
+ label: "Ollama",
1319
+ hint: `${defaultModels.ollama} \u2014 local, free, requires Ollama installed`
1320
+ },
1321
+ { value: "openai", label: "OpenAI", hint: defaultModels.openai },
1322
+ { value: "anthropic", label: "Anthropic", hint: defaultModels.anthropic },
1323
+ { value: "google", label: "Google Gemini", hint: defaultModels.google }
1324
+ ],
1325
+ initialValue: defaultAnswers.provider
1326
+ })
1327
+ ) : defaultAnswers.provider);
1328
+ const packageManager = args.packageManager ?? (interactive ? unlessCancelled(
1329
+ await p2.select({
1330
+ message: "Package manager?",
1331
+ options: [
1332
+ { value: "pnpm", label: "pnpm" },
1333
+ { value: "npm", label: "npm" },
1334
+ { value: "yarn", label: "yarn" },
1335
+ { value: "bun", label: "bun" }
1336
+ ],
1337
+ initialValue: detectPackageManager()
1338
+ })
1339
+ ) : detectPackageManager());
1340
+ const docker = args.docker ?? (interactive ? unlessCancelled(
1341
+ await p2.confirm({
1342
+ message: "Include Docker Compose? (Redis + Postgres" + (provider === "ollama" ? " + Ollama)" : ")"),
1343
+ initialValue: defaultAnswers.docker
1344
+ })
1345
+ ) : defaultAnswers.docker);
1346
+ const git = args.git ?? (interactive ? unlessCancelled(
1347
+ await p2.confirm({
1348
+ message: "Initialize git repository?",
1349
+ initialValue: defaultAnswers.git
1350
+ })
1351
+ ) : defaultAnswers.git);
1307
1352
  return {
1308
1353
  name: projectName,
1309
1354
  path: projectPath,