create-cogitator-app 0.1.1 → 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/LICENSE +21 -0
- package/README.md +76 -37
- package/dist/index.js +177 -103
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +4 -0
- package/dist/lib.js +153 -94
- package/dist/lib.js.map +1 -1
- package/package.json +16 -13
package/dist/lib.js
CHANGED
|
@@ -5,10 +5,10 @@ import * as p from "@clack/prompts";
|
|
|
5
5
|
|
|
6
6
|
// src/utils/providers.ts
|
|
7
7
|
var defaultModels = {
|
|
8
|
-
ollama: "
|
|
9
|
-
openai: "gpt-
|
|
10
|
-
anthropic: "claude-sonnet-
|
|
11
|
-
google: "gemini-
|
|
8
|
+
ollama: "qwen3:8b",
|
|
9
|
+
openai: "gpt-6.1-sol",
|
|
10
|
+
anthropic: "claude-sonnet-5-5",
|
|
11
|
+
google: "gemini-3.8-flash"
|
|
12
12
|
};
|
|
13
13
|
function providerEnvKey(provider) {
|
|
14
14
|
const map = {
|
|
@@ -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:
|
|
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:
|
|
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:',
|
|
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:
|
|
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
|
-
`
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
1031
|
-
|
|
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(
|
|
1039
|
+
lines.push(
|
|
1040
|
+
" providers:",
|
|
1041
|
+
" ollama:",
|
|
1042
|
+
" baseUrl: ${OLLAMA_BASE_URL:-http://localhost:11434}"
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
if (template === "memory") {
|
|
1046
|
+
lines.push(
|
|
1047
|
+
"",
|
|
1048
|
+
"memory:",
|
|
1049
|
+
" adapter: redis",
|
|
1050
|
+
" redis:",
|
|
1051
|
+
" url: ${REDIS_URL:-redis://localhost:6379}"
|
|
1052
|
+
);
|
|
1034
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](
|
|
1096
|
+
`> Created with [create-cogitator-app](${REPO_URL}) \u2014 ${templateName} template`,
|
|
1073
1097
|
"",
|
|
1074
1098
|
"## Getting Started",
|
|
1075
1099
|
"",
|
|
@@ -1084,30 +1108,57 @@ function generateReadme(options) {
|
|
|
1084
1108
|
...options.docker ? ["## Docker Services", "", "```bash", "docker compose up -d", "```", ""] : [],
|
|
1085
1109
|
"## Learn More",
|
|
1086
1110
|
"",
|
|
1087
|
-
|
|
1088
|
-
|
|
1111
|
+
`- [Cogitator Documentation](${DOCS_URL})`,
|
|
1112
|
+
`- [GitHub Repository](${REPO_URL})`,
|
|
1089
1113
|
""
|
|
1090
1114
|
];
|
|
1091
1115
|
return { path: "README.md", content: content.join("\n") };
|
|
1092
1116
|
}
|
|
1093
1117
|
|
|
1118
|
+
// src/templates/base/pnpm-workspace.ts
|
|
1119
|
+
var PNPM_ALLOWED_BUILDS = ["better-sqlite3", "esbuild", "sharp"];
|
|
1120
|
+
function generatePnpmWorkspace() {
|
|
1121
|
+
return {
|
|
1122
|
+
path: "pnpm-workspace.yaml",
|
|
1123
|
+
content: ["allowBuilds:", ...PNPM_ALLOWED_BUILDS.map((name) => ` ${name}: true`), ""].join(
|
|
1124
|
+
"\n"
|
|
1125
|
+
)
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1094
1129
|
// src/utils/git.ts
|
|
1095
|
-
import {
|
|
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
|
+
];
|
|
1096
1137
|
function isGitInstalled() {
|
|
1097
1138
|
try {
|
|
1098
|
-
|
|
1139
|
+
execFileSync("git", ["--version"], { stdio: "ignore" });
|
|
1099
1140
|
return true;
|
|
1100
1141
|
} catch {
|
|
1101
1142
|
return false;
|
|
1102
1143
|
}
|
|
1103
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
|
+
}
|
|
1104
1154
|
function initGitRepo(cwd) {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
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
|
+
});
|
|
1111
1162
|
}
|
|
1112
1163
|
|
|
1113
1164
|
// src/scaffold.ts
|
|
@@ -1137,11 +1188,14 @@ function collectFiles(options) {
|
|
|
1137
1188
|
files.push(...template.files(options));
|
|
1138
1189
|
files.push(generateGitignore());
|
|
1139
1190
|
files.push(generateEnvExample(options.provider, options.template));
|
|
1140
|
-
files.push(generateCogitatorYml(options.provider));
|
|
1191
|
+
files.push(generateCogitatorYml(options.provider, options.template));
|
|
1141
1192
|
files.push(generateReadme(options));
|
|
1142
1193
|
if (options.template !== "nextjs") {
|
|
1143
1194
|
files.push(generateTsconfig());
|
|
1144
1195
|
}
|
|
1196
|
+
if (options.packageManager === "pnpm") {
|
|
1197
|
+
files.push(generatePnpmWorkspace());
|
|
1198
|
+
}
|
|
1145
1199
|
if (options.docker) {
|
|
1146
1200
|
files.push(generateDockerCompose(options.provider));
|
|
1147
1201
|
}
|
|
@@ -1218,78 +1272,83 @@ function parseArgs(args) {
|
|
|
1218
1272
|
}
|
|
1219
1273
|
return parsed;
|
|
1220
1274
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
});
|
|
1231
|
-
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)) {
|
|
1232
1284
|
p2.cancel("Operation cancelled.");
|
|
1233
1285
|
process.exit(0);
|
|
1234
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);
|
|
1235
1302
|
const name = rawName.trim();
|
|
1236
1303
|
const projectName = path2.basename(path2.normalize(name).replace(/^\.\//, "").replace(/^\.\\/, ""));
|
|
1237
1304
|
const projectPath = path2.resolve(process.cwd(), name);
|
|
1238
|
-
const template = args.template
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
p2.
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
const git = args.git ?? await p2.confirm({
|
|
1286
|
-
message: "Initialize git repository?",
|
|
1287
|
-
initialValue: true
|
|
1288
|
-
});
|
|
1289
|
-
if (p2.isCancel(git)) {
|
|
1290
|
-
p2.cancel("Operation cancelled.");
|
|
1291
|
-
process.exit(0);
|
|
1292
|
-
}
|
|
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);
|
|
1293
1352
|
return {
|
|
1294
1353
|
name: projectName,
|
|
1295
1354
|
path: projectPath,
|