create-cogitator-app 0.1.0 → 0.2.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/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/index.js +81 -65
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +52 -0
- package/dist/lib.js +1329 -0
- package/dist/lib.js.map +1 -0
- package/package.json +19 -10
- package/dist/index.d.ts +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cogitator Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# create-cogitator-app
|
|
2
|
+
|
|
3
|
+
Interactive CLI scaffolder for [Cogitator](https://cogitator.dev) — creates production-ready AI agent projects in seconds.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Interactive mode
|
|
9
|
+
npx create-cogitator-app
|
|
10
|
+
|
|
11
|
+
# With arguments
|
|
12
|
+
npx create-cogitator-app my-project --template basic --provider openai
|
|
13
|
+
|
|
14
|
+
# Skip prompts with flags
|
|
15
|
+
npx create-cogitator-app my-project -t swarm -p ollama --pm pnpm --docker --no-git
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Templates
|
|
19
|
+
|
|
20
|
+
| Template | Description |
|
|
21
|
+
| ------------ | ----------------------------------------- |
|
|
22
|
+
| `basic` | Single agent with tools |
|
|
23
|
+
| `memory` | Agent with Redis-backed persistent memory |
|
|
24
|
+
| `swarm` | Multi-agent hierarchical swarm |
|
|
25
|
+
| `workflow` | DAG workflow with sequential agent nodes |
|
|
26
|
+
| `api-server` | Express REST API with Cogitator backend |
|
|
27
|
+
| `nextjs` | Next.js chat app with streaming UI |
|
|
28
|
+
|
|
29
|
+
## CLI Flags
|
|
30
|
+
|
|
31
|
+
| Flag | Shorthand | Description |
|
|
32
|
+
| -------------------------- | --------- | -------------------------------------------------------- |
|
|
33
|
+
| `--template <name>` | `-t` | Template to use |
|
|
34
|
+
| `--provider <name>` | `-p` | LLM provider (`ollama`, `openai`, `anthropic`, `google`) |
|
|
35
|
+
| `--pm <name>` | | Package manager (`pnpm`, `npm`, `yarn`, `bun`) |
|
|
36
|
+
| `--docker` / `--no-docker` | | Include Docker Compose |
|
|
37
|
+
| `--git` / `--no-git` | | Initialize git repository |
|
|
38
|
+
|
|
39
|
+
## Providers
|
|
40
|
+
|
|
41
|
+
| Provider | Default Model | Requires |
|
|
42
|
+
| ----------- | ------------------- | ---------------------------------------------- |
|
|
43
|
+
| `ollama` | `qwen3:8b` | [Ollama](https://ollama.com) installed locally |
|
|
44
|
+
| `openai` | `gpt-6.1-sol` | `OPENAI_API_KEY` |
|
|
45
|
+
| `anthropic` | `claude-sonnet-5-5` | `ANTHROPIC_API_KEY` |
|
|
46
|
+
| `google` | `gemini-3.8-flash` | `GOOGLE_API_KEY` |
|
|
47
|
+
|
|
48
|
+
## Programmatic API
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { scaffold, parseArgs } from 'create-cogitator-app';
|
|
52
|
+
import type { ProjectOptions } from 'create-cogitator-app';
|
|
53
|
+
|
|
54
|
+
const options: ProjectOptions = {
|
|
55
|
+
name: 'my-agent',
|
|
56
|
+
path: '/path/to/my-agent',
|
|
57
|
+
template: 'basic',
|
|
58
|
+
provider: 'ollama',
|
|
59
|
+
packageManager: 'pnpm',
|
|
60
|
+
docker: false,
|
|
61
|
+
git: true,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
await scaffold(options);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Generated Project Structure
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
my-project/
|
|
71
|
+
├── src/
|
|
72
|
+
│ ├── index.ts # Main entry point
|
|
73
|
+
│ └── tools.ts # Tool definitions
|
|
74
|
+
├── package.json
|
|
75
|
+
├── tsconfig.json
|
|
76
|
+
├── cogitator.yml # Cogitator configuration
|
|
77
|
+
├── .env.example
|
|
78
|
+
├── .gitignore
|
|
79
|
+
└── README.md
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -24,10 +24,10 @@ import path from "path";
|
|
|
24
24
|
|
|
25
25
|
// src/utils/providers.ts
|
|
26
26
|
var defaultModels = {
|
|
27
|
-
ollama: "
|
|
28
|
-
openai: "gpt-
|
|
29
|
-
anthropic: "claude-sonnet-
|
|
30
|
-
google: "gemini-
|
|
27
|
+
ollama: "qwen3:8b",
|
|
28
|
+
openai: "gpt-6.1-sol",
|
|
29
|
+
anthropic: "claude-sonnet-5-5",
|
|
30
|
+
google: "gemini-3.8-flash"
|
|
31
31
|
};
|
|
32
32
|
function providerConfig(provider) {
|
|
33
33
|
switch (provider) {
|
|
@@ -351,11 +351,8 @@ var swarmTemplate = {
|
|
|
351
351
|
` supervisor: reviewer,`,
|
|
352
352
|
` workers: [researcher, writer],`,
|
|
353
353
|
` hierarchical: {`,
|
|
354
|
-
`
|
|
355
|
-
`
|
|
356
|
-
` workerCommunication: true,`,
|
|
357
|
-
` maxParallelTasks: 2,`,
|
|
358
|
-
` },`,
|
|
354
|
+
` visibility: 'full',`,
|
|
355
|
+
` workerCommunication: true,`,
|
|
359
356
|
` },`,
|
|
360
357
|
` resources: {`,
|
|
361
358
|
` maxConcurrency: 3,`,
|
|
@@ -447,7 +444,6 @@ var workflowTemplate = {
|
|
|
447
444
|
` WorkflowExecutor,`,
|
|
448
445
|
` agentNode,`,
|
|
449
446
|
` functionNode,`,
|
|
450
|
-
` InMemoryCheckpointStore,`,
|
|
451
447
|
`} from '@cogitator-ai/workflows'`,
|
|
452
448
|
`import { analyzer, processor, formatter } from './agents.js'`,
|
|
453
449
|
``,
|
|
@@ -462,46 +458,37 @@ var workflowTemplate = {
|
|
|
462
458
|
` report?: string`,
|
|
463
459
|
`}`,
|
|
464
460
|
``,
|
|
461
|
+
`const analyzeNode = agentNode<WorkflowState>(analyzer, {`,
|
|
462
|
+
` inputMapper: (state) => \`Analyze the following: \${state.input}\`,`,
|
|
463
|
+
` stateMapper: (result) => ({ analysis: result.output }),`,
|
|
464
|
+
`})`,
|
|
465
|
+
``,
|
|
466
|
+
`const processNode = agentNode<WorkflowState>(processor, {`,
|
|
467
|
+
` inputMapper: (state) => \`Process this analysis: \${state.analysis ?? ''}\`,`,
|
|
468
|
+
` stateMapper: (result) => ({ processed: result.output }),`,
|
|
469
|
+
`})`,
|
|
470
|
+
``,
|
|
471
|
+
`const formatNode = agentNode<WorkflowState>(formatter, {`,
|
|
472
|
+
` inputMapper: (state) => \`Format this into a report: \${state.processed ?? ''}\`,`,
|
|
473
|
+
` stateMapper: (result) => ({ report: result.output }),`,
|
|
474
|
+
`})`,
|
|
475
|
+
``,
|
|
476
|
+
`const outputNode = functionNode<WorkflowState>(`,
|
|
477
|
+
` 'output',`,
|
|
478
|
+
` async (state) => state.report,`,
|
|
479
|
+
`)`,
|
|
480
|
+
``,
|
|
465
481
|
`const workflow = new WorkflowBuilder<WorkflowState>('${options.name}-workflow')`,
|
|
466
482
|
` .initialState({ input: '' })`,
|
|
467
|
-
` .entryPoint(
|
|
468
|
-
` .addNode(`,
|
|
469
|
-
`
|
|
470
|
-
`
|
|
471
|
-
`
|
|
472
|
-
` agent: analyzer,`,
|
|
473
|
-
` prompt: (ctx) => \`Analyze the following: \${ctx.input.input}\`,`,
|
|
474
|
-
` }),`,
|
|
475
|
-
` )`,
|
|
476
|
-
` .addNode(`,
|
|
477
|
-
` 'process',`,
|
|
478
|
-
` agentNode({`,
|
|
479
|
-
` cogitator,`,
|
|
480
|
-
` agent: processor,`,
|
|
481
|
-
` prompt: (ctx) => \`Process this analysis: \${ctx.results.analyze}\`,`,
|
|
482
|
-
` }),`,
|
|
483
|
-
` { after: ['analyze'] },`,
|
|
484
|
-
` )`,
|
|
485
|
-
` .addNode(`,
|
|
486
|
-
` 'format',`,
|
|
487
|
-
` agentNode({`,
|
|
488
|
-
` cogitator,`,
|
|
489
|
-
` agent: formatter,`,
|
|
490
|
-
` prompt: (ctx) => \`Format this into a report: \${ctx.results.process}\`,`,
|
|
491
|
-
` }),`,
|
|
492
|
-
` { after: ['process'] },`,
|
|
493
|
-
` )`,
|
|
494
|
-
` .addNode(`,
|
|
495
|
-
` 'output',`,
|
|
496
|
-
` functionNode(async (ctx) => ({`,
|
|
497
|
-
` report: ctx.results.format as string,`,
|
|
498
|
-
` })),`,
|
|
499
|
-
` { after: ['format'] },`,
|
|
500
|
-
` )`,
|
|
483
|
+
` .entryPoint(analyzeNode.name)`,
|
|
484
|
+
` .addNode(analyzeNode.name, analyzeNode.fn)`,
|
|
485
|
+
` .addNode(processNode.name, processNode.fn, { after: [analyzeNode.name] })`,
|
|
486
|
+
` .addNode(formatNode.name, formatNode.fn, { after: [processNode.name] })`,
|
|
487
|
+
` .addNode(outputNode.name, outputNode.fn, { after: [formatNode.name] })`,
|
|
501
488
|
` .build()`,
|
|
502
489
|
``,
|
|
503
490
|
`async function main() {`,
|
|
504
|
-
` const executor = new WorkflowExecutor(cogitator
|
|
491
|
+
` const executor = new WorkflowExecutor(cogitator)`,
|
|
505
492
|
``,
|
|
506
493
|
` console.log('Starting workflow...')`,
|
|
507
494
|
``,
|
|
@@ -957,14 +944,20 @@ function parseArgs(args) {
|
|
|
957
944
|
for (let i = 0; i < args.length; i++) {
|
|
958
945
|
const arg = args[i];
|
|
959
946
|
if (arg === "--template" || arg === "-t") {
|
|
960
|
-
|
|
961
|
-
|
|
947
|
+
if (i + 1 < args.length) {
|
|
948
|
+
const val = args[++i];
|
|
949
|
+
if (validTemplates.includes(val)) parsed.template = val;
|
|
950
|
+
}
|
|
962
951
|
} else if (arg === "--provider" || arg === "-p") {
|
|
963
|
-
|
|
964
|
-
|
|
952
|
+
if (i + 1 < args.length) {
|
|
953
|
+
const val = args[++i];
|
|
954
|
+
if (validProviders.includes(val)) parsed.provider = val;
|
|
955
|
+
}
|
|
965
956
|
} else if (arg === "--pm") {
|
|
966
|
-
|
|
967
|
-
|
|
957
|
+
if (i + 1 < args.length) {
|
|
958
|
+
const val = args[++i];
|
|
959
|
+
if (validPMs.includes(val)) parsed.packageManager = val;
|
|
960
|
+
}
|
|
968
961
|
} else if (arg === "--docker") {
|
|
969
962
|
parsed.docker = true;
|
|
970
963
|
} else if (arg === "--no-docker") {
|
|
@@ -982,20 +975,21 @@ function parseArgs(args) {
|
|
|
982
975
|
return parsed;
|
|
983
976
|
}
|
|
984
977
|
async function collectOptions(args) {
|
|
985
|
-
const
|
|
978
|
+
const rawName = args.name || await p.text({
|
|
986
979
|
message: "Where should we create your project?",
|
|
987
980
|
placeholder: "./my-agents",
|
|
988
981
|
defaultValue: "my-agents",
|
|
989
982
|
validate: (value) => {
|
|
990
|
-
if (!value.trim()) return "Project name is required";
|
|
983
|
+
if (value && !value.trim()) return "Project name is required";
|
|
991
984
|
return void 0;
|
|
992
985
|
}
|
|
993
986
|
});
|
|
994
|
-
if (p.isCancel(
|
|
987
|
+
if (p.isCancel(rawName)) {
|
|
995
988
|
p.cancel("Operation cancelled.");
|
|
996
989
|
process.exit(0);
|
|
997
990
|
}
|
|
998
|
-
const
|
|
991
|
+
const name = rawName.trim();
|
|
992
|
+
const projectName = path.basename(path.normalize(name).replace(/^\.\//, "").replace(/^\.\\/, ""));
|
|
999
993
|
const projectPath = path.resolve(process.cwd(), name);
|
|
1000
994
|
const template = args.template || await p.select({
|
|
1001
995
|
message: "Which template would you like?",
|
|
@@ -1015,7 +1009,7 @@ async function collectOptions(args) {
|
|
|
1015
1009
|
},
|
|
1016
1010
|
{ value: "openai", label: "OpenAI", hint: "GPT-4o" },
|
|
1017
1011
|
{ value: "anthropic", label: "Anthropic", hint: "Claude Sonnet" },
|
|
1018
|
-
{ value: "google", label: "Google Gemini", hint: "Gemini 2.
|
|
1012
|
+
{ value: "google", label: "Google Gemini", hint: "Gemini 2.5 Flash" }
|
|
1019
1013
|
]
|
|
1020
1014
|
});
|
|
1021
1015
|
if (p.isCancel(provider)) {
|
|
@@ -1114,7 +1108,7 @@ function generateGitignore() {
|
|
|
1114
1108
|
}
|
|
1115
1109
|
|
|
1116
1110
|
// src/templates/base/env-example.ts
|
|
1117
|
-
function generateEnvExample(provider) {
|
|
1111
|
+
function generateEnvExample(provider, template) {
|
|
1118
1112
|
const lines = ["# Cogitator Environment Variables", ""];
|
|
1119
1113
|
switch (provider) {
|
|
1120
1114
|
case "ollama":
|
|
@@ -1134,6 +1128,11 @@ function generateEnvExample(provider) {
|
|
|
1134
1128
|
lines.push("GOOGLE_API_KEY=...");
|
|
1135
1129
|
break;
|
|
1136
1130
|
}
|
|
1131
|
+
if (template === "memory") {
|
|
1132
|
+
lines.push("");
|
|
1133
|
+
lines.push("# Redis");
|
|
1134
|
+
lines.push("REDIS_URL=redis://localhost:6379");
|
|
1135
|
+
}
|
|
1137
1136
|
lines.push("");
|
|
1138
1137
|
return { path: ".env.example", content: lines.join("\n") };
|
|
1139
1138
|
}
|
|
@@ -1168,9 +1167,9 @@ function generateDockerCompose(provider) {
|
|
|
1168
1167
|
" ports:",
|
|
1169
1168
|
' - "5432:5432"',
|
|
1170
1169
|
" environment:",
|
|
1171
|
-
" POSTGRES_USER: cogitator",
|
|
1172
|
-
" POSTGRES_PASSWORD: cogitator",
|
|
1173
|
-
" POSTGRES_DB: cogitator",
|
|
1170
|
+
" POSTGRES_USER: ${POSTGRES_USER:-cogitator}",
|
|
1171
|
+
" POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cogitator}",
|
|
1172
|
+
" POSTGRES_DB: ${POSTGRES_DB:-cogitator}",
|
|
1174
1173
|
" volumes:",
|
|
1175
1174
|
" - postgres_data:/var/lib/postgresql/data"
|
|
1176
1175
|
]
|
|
@@ -1229,6 +1228,17 @@ function generateReadme(options) {
|
|
|
1229
1228
|
return { path: "README.md", content: content.join("\n") };
|
|
1230
1229
|
}
|
|
1231
1230
|
|
|
1231
|
+
// src/templates/base/pnpm-workspace.ts
|
|
1232
|
+
var PNPM_ALLOWED_BUILDS = ["better-sqlite3", "esbuild", "sharp"];
|
|
1233
|
+
function generatePnpmWorkspace() {
|
|
1234
|
+
return {
|
|
1235
|
+
path: "pnpm-workspace.yaml",
|
|
1236
|
+
content: ["allowBuilds:", ...PNPM_ALLOWED_BUILDS.map((name) => ` ${name}: true`), ""].join(
|
|
1237
|
+
"\n"
|
|
1238
|
+
)
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1232
1242
|
// src/utils/git.ts
|
|
1233
1243
|
import { execSync as execSync2 } from "child_process";
|
|
1234
1244
|
function isGitInstalled() {
|
|
@@ -1242,10 +1252,10 @@ function isGitInstalled() {
|
|
|
1242
1252
|
function initGitRepo(cwd) {
|
|
1243
1253
|
execSync2("git init", { cwd, stdio: "ignore" });
|
|
1244
1254
|
execSync2("git add -A", { cwd, stdio: "ignore" });
|
|
1245
|
-
execSync2(
|
|
1246
|
-
|
|
1247
|
-
stdio: "ignore"
|
|
1248
|
-
|
|
1255
|
+
execSync2(
|
|
1256
|
+
'git -c user.name="Cogitator" -c user.email="init@cogitator.dev" commit -m "feat: initial project scaffold"',
|
|
1257
|
+
{ cwd, stdio: "ignore" }
|
|
1258
|
+
);
|
|
1249
1259
|
}
|
|
1250
1260
|
|
|
1251
1261
|
// src/scaffold.ts
|
|
@@ -1274,18 +1284,24 @@ function collectFiles(options) {
|
|
|
1274
1284
|
files.push({ path: "package.json", content: buildPackageJson(options) });
|
|
1275
1285
|
files.push(...template.files(options));
|
|
1276
1286
|
files.push(generateGitignore());
|
|
1277
|
-
files.push(generateEnvExample(options.provider));
|
|
1287
|
+
files.push(generateEnvExample(options.provider, options.template));
|
|
1278
1288
|
files.push(generateCogitatorYml(options.provider));
|
|
1279
1289
|
files.push(generateReadme(options));
|
|
1280
1290
|
if (options.template !== "nextjs") {
|
|
1281
1291
|
files.push(generateTsconfig());
|
|
1282
1292
|
}
|
|
1293
|
+
if (options.packageManager === "pnpm") {
|
|
1294
|
+
files.push(generatePnpmWorkspace());
|
|
1295
|
+
}
|
|
1283
1296
|
if (options.docker) {
|
|
1284
1297
|
files.push(generateDockerCompose(options.provider));
|
|
1285
1298
|
}
|
|
1286
1299
|
return files;
|
|
1287
1300
|
}
|
|
1288
1301
|
async function scaffold(options) {
|
|
1302
|
+
if (fs.existsSync(options.path) && fs.readdirSync(options.path).length > 0) {
|
|
1303
|
+
throw new Error(`Directory "${options.path}" already exists and is not empty`);
|
|
1304
|
+
}
|
|
1289
1305
|
const s = p2.spinner();
|
|
1290
1306
|
s.start("Generating project files");
|
|
1291
1307
|
const files = collectFiles(options);
|