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/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
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# create-cogitator-app
|
|
2
2
|
|
|
3
|
-
Interactive
|
|
3
|
+
Interactive scaffolder for [Cogitator](https://cogitator.app) — creates a ready-to-run TypeScript AI agent project from one of six templates.
|
|
4
|
+
|
|
5
|
+
Guide: [cogitator.app/docs/getting-started/scaffolding](https://cogitator.app/docs/getting-started/scaffolding)
|
|
4
6
|
|
|
5
7
|
## Usage
|
|
6
8
|
|
|
@@ -11,44 +13,88 @@ npx create-cogitator-app
|
|
|
11
13
|
# With arguments
|
|
12
14
|
npx create-cogitator-app my-project --template basic --provider openai
|
|
13
15
|
|
|
14
|
-
# Skip
|
|
16
|
+
# Skip every prompt with flags
|
|
15
17
|
npx create-cogitator-app my-project -t swarm -p ollama --pm pnpm --docker --no-git
|
|
18
|
+
|
|
19
|
+
# Accept the defaults for everything not given
|
|
20
|
+
npx create-cogitator-app -y
|
|
21
|
+
npx create-cogitator-app my-project -p openai --yes
|
|
16
22
|
```
|
|
17
23
|
|
|
24
|
+
Prompts are shown only for values not given on the command line: project directory, template, provider, package manager, Docker Compose and git. With `-y` / `--yes` nothing is asked and the defaults fill the gaps: `my-agents`, `basic`, `ollama`, the detected package manager, Docker Compose on, git on. The target directory must be empty or not exist. After writing the files the scaffolder runs `<pm> install` and, unless disabled, creates a git repository with an initial commit.
|
|
25
|
+
|
|
26
|
+
Requires Node.js 22.12+.
|
|
27
|
+
|
|
18
28
|
## Templates
|
|
19
29
|
|
|
20
|
-
| Template
|
|
21
|
-
|
|
22
|
-
| `basic`
|
|
23
|
-
| `memory`
|
|
24
|
-
| `swarm`
|
|
25
|
-
| `workflow`
|
|
26
|
-
| `api-server` | Express REST API with
|
|
27
|
-
| `nextjs`
|
|
30
|
+
| Template | Description |
|
|
31
|
+
| ------------ | ------------------------------------------------------------------------ |
|
|
32
|
+
| `basic` | Single agent with tools |
|
|
33
|
+
| `memory` | Agent with Redis-backed persistent memory (`@cogitator-ai/redis`) |
|
|
34
|
+
| `swarm` | Hierarchical swarm of researcher, writer and reviewer agents |
|
|
35
|
+
| `workflow` | DAG workflow (`@cogitator-ai/workflows`) with sequential agent nodes |
|
|
36
|
+
| `api-server` | Express REST API with `CogitatorServer` from `@cogitator-ai/express` |
|
|
37
|
+
| `nextjs` | Next.js App Router chat app with a streaming `/api/chat` route, Tailwind |
|
|
28
38
|
|
|
29
39
|
## CLI Flags
|
|
30
40
|
|
|
31
|
-
| Flag
|
|
32
|
-
|
|
33
|
-
|
|
|
34
|
-
| `--
|
|
35
|
-
| `--
|
|
36
|
-
| `--
|
|
37
|
-
| `--
|
|
41
|
+
| Flag | Shorthand | Description |
|
|
42
|
+
| -------------------------- | --------- | --------------------------------------------------------- |
|
|
43
|
+
| `[name]` | | Project directory (its basename becomes the package name) |
|
|
44
|
+
| `--template <name>` | `-t` | Template to use |
|
|
45
|
+
| `--provider <name>` | `-p` | LLM provider (`ollama`, `openai`, `anthropic`, `google`) |
|
|
46
|
+
| `--pm <name>` | | Package manager (`pnpm`, `npm`, `yarn`, `bun`) |
|
|
47
|
+
| `--docker` / `--no-docker` | | Include Docker Compose (Redis, Postgres, plus Ollama) |
|
|
48
|
+
| `--git` / `--no-git` | | Initialize git repository |
|
|
49
|
+
| `--yes` | `-y` | Don't prompt; use the defaults for every missing value |
|
|
50
|
+
|
|
51
|
+
Unknown values for `--template`, `--provider` and `--pm` are ignored and asked for interactively (or replaced by the default with `--yes`). The package manager prompt defaults to the one that invoked the scaffolder (`npm_config_user_agent`), falling back to `pnpm`.
|
|
38
52
|
|
|
39
53
|
## Providers
|
|
40
54
|
|
|
41
|
-
| Provider
|
|
42
|
-
|
|
43
|
-
| `ollama`
|
|
44
|
-
| `openai`
|
|
45
|
-
| `anthropic` | `claude-sonnet-
|
|
46
|
-
| `google`
|
|
55
|
+
| Provider | Default Model | Requires |
|
|
56
|
+
| ----------- | ------------------- | ---------------------------------------------------------------------------------- |
|
|
57
|
+
| `ollama` | `qwen3:8b` | [Ollama](https://ollama.com) (`OLLAMA_BASE_URL`, default `http://localhost:11434`) |
|
|
58
|
+
| `openai` | `gpt-6.1-sol` | `OPENAI_API_KEY` |
|
|
59
|
+
| `anthropic` | `claude-sonnet-5-5` | `ANTHROPIC_API_KEY` |
|
|
60
|
+
| `google` | `gemini-3.8-flash` | `GOOGLE_API_KEY` |
|
|
61
|
+
|
|
62
|
+
## Generated Project Structure
|
|
63
|
+
|
|
64
|
+
Every project gets these files (shown for the `basic` template):
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
my-project/
|
|
68
|
+
├── src/
|
|
69
|
+
│ ├── index.ts # Main entry point
|
|
70
|
+
│ └── tools.ts # Tool definitions
|
|
71
|
+
├── package.json # dev / start / build / typecheck scripts
|
|
72
|
+
├── tsconfig.json # not for nextjs, which ships its own
|
|
73
|
+
├── cogitator.yml # provider and default model
|
|
74
|
+
├── .env.example # the provider's key (and REDIS_URL for memory)
|
|
75
|
+
├── .gitignore
|
|
76
|
+
├── README.md
|
|
77
|
+
├── pnpm-workspace.yaml # pnpm only
|
|
78
|
+
└── docker-compose.yml # with --docker
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Template-specific sources:
|
|
82
|
+
|
|
83
|
+
| Template | Files |
|
|
84
|
+
| ------------ | -------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `basic` | `src/index.ts`, `src/tools.ts` |
|
|
86
|
+
| `memory` | `src/index.ts`, `src/tools.ts` |
|
|
87
|
+
| `swarm` | `src/index.ts`, `src/tools.ts`, `src/agents/{researcher,writer,reviewer}.ts` |
|
|
88
|
+
| `workflow` | `src/index.ts`, `src/agents.ts` |
|
|
89
|
+
| `api-server` | `src/index.ts`, `src/agents.ts` |
|
|
90
|
+
| `nextjs` | `src/lib/agent.ts`, `src/app/api/chat/route.ts`, `src/app/{page,layout}.tsx`, Next/Tailwind config |
|
|
91
|
+
|
|
92
|
+
The generated code configures `Cogitator` in `src/` itself, reading the provider key from the environment. Copy `.env.example` to `.env` and fill it in, then run `pnpm dev` (or `npm run dev`, `yarn dev`, `bun dev`).
|
|
47
93
|
|
|
48
94
|
## Programmatic API
|
|
49
95
|
|
|
50
96
|
```ts
|
|
51
|
-
import { scaffold, parseArgs } from 'create-cogitator-app';
|
|
97
|
+
import { scaffold, parseArgs, collectOptions } from 'create-cogitator-app';
|
|
52
98
|
import type { ProjectOptions } from 'create-cogitator-app';
|
|
53
99
|
|
|
54
100
|
const options: ProjectOptions = {
|
|
@@ -62,22 +108,15 @@ const options: ProjectOptions = {
|
|
|
62
108
|
};
|
|
63
109
|
|
|
64
110
|
await scaffold(options);
|
|
111
|
+
|
|
112
|
+
// or: parse CLI arguments and prompt for the rest
|
|
113
|
+
const fromCli = await collectOptions(parseArgs(process.argv.slice(2)));
|
|
114
|
+
await scaffold(fromCli);
|
|
65
115
|
```
|
|
66
116
|
|
|
67
|
-
|
|
117
|
+
`scaffold()` writes the files, installs dependencies with `packageManager` and initializes git when `git` is `true`; it throws when `path` exists and is not empty.
|
|
68
118
|
|
|
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
|
-
```
|
|
119
|
+
Other exports: `getTemplate(name)` and `templateChoices` (template generators and their labels), `detectPackageManager()`, `devCommand(pm)`, `defaultModels`, `providerConfig(provider)` and `providerEnvKey(provider)`, and the types `ProjectOptions`, `Template`, `LLMProvider`, `PackageManager` and `TemplateFile`.
|
|
81
120
|
|
|
82
121
|
## License
|
|
83
122
|
|
package/dist/index.js
CHANGED
|
@@ -2,17 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import * as p3 from "@clack/prompts";
|
|
5
|
+
import { readFileSync } from "fs";
|
|
5
6
|
import pc2 from "picocolors";
|
|
6
7
|
|
|
7
8
|
// src/utils/logger.ts
|
|
8
9
|
import pc from "picocolors";
|
|
9
|
-
|
|
10
|
+
var MIN_INNER_WIDTH = 39;
|
|
11
|
+
function banner(version) {
|
|
12
|
+
const title = "create-cogitator-app";
|
|
13
|
+
const tagline = "Build AI agents in minutes";
|
|
14
|
+
const versionLabel = `v${version}`;
|
|
15
|
+
const lines = [
|
|
16
|
+
{
|
|
17
|
+
text: `${pc.bold(pc.white(title))} ${pc.dim(versionLabel)}`,
|
|
18
|
+
width: title.length + 2 + versionLabel.length
|
|
19
|
+
},
|
|
20
|
+
{ text: pc.dim(tagline), width: tagline.length }
|
|
21
|
+
];
|
|
22
|
+
const inner = Math.max(MIN_INNER_WIDTH, ...lines.map((line) => line.width + 4));
|
|
10
23
|
const art = [
|
|
11
24
|
"",
|
|
12
|
-
` ${pc.cyan("\
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
` ${pc.cyan(`\u2554${"\u2550".repeat(inner)}\u2557`)}`,
|
|
26
|
+
...lines.map(
|
|
27
|
+
(line) => ` ${pc.cyan("\u2551")} ${line.text}${" ".repeat(inner - 2 - line.width)}${pc.cyan("\u2551")}`
|
|
28
|
+
),
|
|
29
|
+
` ${pc.cyan(`\u255A${"\u2550".repeat(inner)}\u255D`)}`,
|
|
16
30
|
""
|
|
17
31
|
];
|
|
18
32
|
console.log(art.join("\n"));
|
|
@@ -24,10 +38,10 @@ import path from "path";
|
|
|
24
38
|
|
|
25
39
|
// src/utils/providers.ts
|
|
26
40
|
var defaultModels = {
|
|
27
|
-
ollama: "
|
|
28
|
-
openai: "gpt-
|
|
29
|
-
anthropic: "claude-sonnet-
|
|
30
|
-
google: "gemini-
|
|
41
|
+
ollama: "qwen3:8b",
|
|
42
|
+
openai: "gpt-6.1-sol",
|
|
43
|
+
anthropic: "claude-sonnet-5-5",
|
|
44
|
+
google: "gemini-3.8-flash"
|
|
31
45
|
};
|
|
32
46
|
function providerConfig(provider) {
|
|
33
47
|
switch (provider) {
|
|
@@ -70,6 +84,9 @@ function providerConfig(provider) {
|
|
|
70
84
|
}
|
|
71
85
|
}
|
|
72
86
|
|
|
87
|
+
// src/templates/versions.ts
|
|
88
|
+
var ZOD_VERSION = "^4.6.5";
|
|
89
|
+
|
|
73
90
|
// src/templates/basic.ts
|
|
74
91
|
var basicTemplate = {
|
|
75
92
|
files(options) {
|
|
@@ -138,7 +155,7 @@ var basicTemplate = {
|
|
|
138
155
|
dependencies() {
|
|
139
156
|
return {
|
|
140
157
|
"@cogitator-ai/core": "latest",
|
|
141
|
-
zod:
|
|
158
|
+
zod: ZOD_VERSION
|
|
142
159
|
};
|
|
143
160
|
},
|
|
144
161
|
devDependencies() {
|
|
@@ -247,7 +264,7 @@ var memoryTemplate = {
|
|
|
247
264
|
"@cogitator-ai/core": "latest",
|
|
248
265
|
"@cogitator-ai/memory": "latest",
|
|
249
266
|
"@cogitator-ai/redis": "latest",
|
|
250
|
-
zod:
|
|
267
|
+
zod: ZOD_VERSION
|
|
251
268
|
};
|
|
252
269
|
},
|
|
253
270
|
devDependencies() {
|
|
@@ -368,7 +385,7 @@ var swarmTemplate = {
|
|
|
368
385
|
` })`,
|
|
369
386
|
``,
|
|
370
387
|
` console.log('Result:', result.output)`,
|
|
371
|
-
` console.log('Strategy:',
|
|
388
|
+
` console.log('Strategy:', team.strategyType)`,
|
|
372
389
|
``,
|
|
373
390
|
` await team.close()`,
|
|
374
391
|
`}`,
|
|
@@ -388,7 +405,7 @@ var swarmTemplate = {
|
|
|
388
405
|
return {
|
|
389
406
|
"@cogitator-ai/core": "latest",
|
|
390
407
|
"@cogitator-ai/swarms": "latest",
|
|
391
|
-
zod:
|
|
408
|
+
zod: ZOD_VERSION
|
|
392
409
|
};
|
|
393
410
|
},
|
|
394
411
|
devDependencies() {
|
|
@@ -451,7 +468,7 @@ var workflowTemplate = {
|
|
|
451
468
|
providerConfig(options.provider),
|
|
452
469
|
`})`,
|
|
453
470
|
``,
|
|
454
|
-
`
|
|
471
|
+
`type WorkflowState = {`,
|
|
455
472
|
` input: string`,
|
|
456
473
|
` analysis?: string`,
|
|
457
474
|
` processed?: string`,
|
|
@@ -512,7 +529,7 @@ var workflowTemplate = {
|
|
|
512
529
|
return {
|
|
513
530
|
"@cogitator-ai/core": "latest",
|
|
514
531
|
"@cogitator-ai/workflows": "latest",
|
|
515
|
-
zod:
|
|
532
|
+
zod: ZOD_VERSION
|
|
516
533
|
};
|
|
517
534
|
},
|
|
518
535
|
devDependencies() {
|
|
@@ -617,7 +634,7 @@ var apiServerTemplate = {
|
|
|
617
634
|
"@cogitator-ai/core": "latest",
|
|
618
635
|
"@cogitator-ai/express": "latest",
|
|
619
636
|
express: "^4.21.0",
|
|
620
|
-
zod:
|
|
637
|
+
zod: ZOD_VERSION
|
|
621
638
|
};
|
|
622
639
|
},
|
|
623
640
|
devDependencies() {
|
|
@@ -859,7 +876,7 @@ var nextjsTemplate = {
|
|
|
859
876
|
next: "^15.0.0",
|
|
860
877
|
react: "^19.0.0",
|
|
861
878
|
"react-dom": "^19.0.0",
|
|
862
|
-
zod:
|
|
879
|
+
zod: ZOD_VERSION
|
|
863
880
|
};
|
|
864
881
|
},
|
|
865
882
|
devDependencies() {
|
|
@@ -974,78 +991,83 @@ function parseArgs(args) {
|
|
|
974
991
|
}
|
|
975
992
|
return parsed;
|
|
976
993
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
});
|
|
987
|
-
if (p.isCancel(rawName)) {
|
|
994
|
+
var defaultAnswers = {
|
|
995
|
+
name: "my-agents",
|
|
996
|
+
template: "basic",
|
|
997
|
+
provider: "ollama",
|
|
998
|
+
docker: true,
|
|
999
|
+
git: true
|
|
1000
|
+
};
|
|
1001
|
+
function unlessCancelled(answer) {
|
|
1002
|
+
if (p.isCancel(answer)) {
|
|
988
1003
|
p.cancel("Operation cancelled.");
|
|
989
1004
|
process.exit(0);
|
|
990
1005
|
}
|
|
1006
|
+
return answer;
|
|
1007
|
+
}
|
|
1008
|
+
async function collectOptions(args) {
|
|
1009
|
+
const interactive = !args.yes;
|
|
1010
|
+
const rawName = args.name || (interactive ? unlessCancelled(
|
|
1011
|
+
await p.text({
|
|
1012
|
+
message: "Where should we create your project?",
|
|
1013
|
+
placeholder: `./${defaultAnswers.name}`,
|
|
1014
|
+
defaultValue: defaultAnswers.name,
|
|
1015
|
+
validate: (value) => {
|
|
1016
|
+
if (value && !value.trim()) return "Project name is required";
|
|
1017
|
+
return void 0;
|
|
1018
|
+
}
|
|
1019
|
+
})
|
|
1020
|
+
) : defaultAnswers.name);
|
|
991
1021
|
const name = rawName.trim();
|
|
992
1022
|
const projectName = path.basename(path.normalize(name).replace(/^\.\//, "").replace(/^\.\\/, ""));
|
|
993
1023
|
const projectPath = path.resolve(process.cwd(), name);
|
|
994
|
-
const template = args.template
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
p.
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
const git = args.git ?? await p.confirm({
|
|
1042
|
-
message: "Initialize git repository?",
|
|
1043
|
-
initialValue: true
|
|
1044
|
-
});
|
|
1045
|
-
if (p.isCancel(git)) {
|
|
1046
|
-
p.cancel("Operation cancelled.");
|
|
1047
|
-
process.exit(0);
|
|
1048
|
-
}
|
|
1024
|
+
const template = args.template ?? (interactive ? unlessCancelled(
|
|
1025
|
+
await p.select({
|
|
1026
|
+
message: "Which template would you like?",
|
|
1027
|
+
options: templateChoices,
|
|
1028
|
+
initialValue: defaultAnswers.template
|
|
1029
|
+
})
|
|
1030
|
+
) : defaultAnswers.template);
|
|
1031
|
+
const provider = args.provider ?? (interactive ? unlessCancelled(
|
|
1032
|
+
await p.select({
|
|
1033
|
+
message: "Which LLM provider?",
|
|
1034
|
+
options: [
|
|
1035
|
+
{
|
|
1036
|
+
value: "ollama",
|
|
1037
|
+
label: "Ollama",
|
|
1038
|
+
hint: `${defaultModels.ollama} \u2014 local, free, requires Ollama installed`
|
|
1039
|
+
},
|
|
1040
|
+
{ value: "openai", label: "OpenAI", hint: defaultModels.openai },
|
|
1041
|
+
{ value: "anthropic", label: "Anthropic", hint: defaultModels.anthropic },
|
|
1042
|
+
{ value: "google", label: "Google Gemini", hint: defaultModels.google }
|
|
1043
|
+
],
|
|
1044
|
+
initialValue: defaultAnswers.provider
|
|
1045
|
+
})
|
|
1046
|
+
) : defaultAnswers.provider);
|
|
1047
|
+
const packageManager = args.packageManager ?? (interactive ? unlessCancelled(
|
|
1048
|
+
await p.select({
|
|
1049
|
+
message: "Package manager?",
|
|
1050
|
+
options: [
|
|
1051
|
+
{ value: "pnpm", label: "pnpm" },
|
|
1052
|
+
{ value: "npm", label: "npm" },
|
|
1053
|
+
{ value: "yarn", label: "yarn" },
|
|
1054
|
+
{ value: "bun", label: "bun" }
|
|
1055
|
+
],
|
|
1056
|
+
initialValue: detectPackageManager()
|
|
1057
|
+
})
|
|
1058
|
+
) : detectPackageManager());
|
|
1059
|
+
const docker = args.docker ?? (interactive ? unlessCancelled(
|
|
1060
|
+
await p.confirm({
|
|
1061
|
+
message: "Include Docker Compose? (Redis + Postgres" + (provider === "ollama" ? " + Ollama)" : ")"),
|
|
1062
|
+
initialValue: defaultAnswers.docker
|
|
1063
|
+
})
|
|
1064
|
+
) : defaultAnswers.docker);
|
|
1065
|
+
const git = args.git ?? (interactive ? unlessCancelled(
|
|
1066
|
+
await p.confirm({
|
|
1067
|
+
message: "Initialize git repository?",
|
|
1068
|
+
initialValue: defaultAnswers.git
|
|
1069
|
+
})
|
|
1070
|
+
) : defaultAnswers.git);
|
|
1049
1071
|
return {
|
|
1050
1072
|
name: projectName,
|
|
1051
1073
|
path: projectPath,
|
|
@@ -1182,15 +1204,36 @@ function generateDockerCompose(provider) {
|
|
|
1182
1204
|
}
|
|
1183
1205
|
|
|
1184
1206
|
// src/templates/base/cogitator-yml.ts
|
|
1185
|
-
function generateCogitatorYml(provider) {
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1207
|
+
function generateCogitatorYml(provider, template) {
|
|
1208
|
+
const lines = [
|
|
1209
|
+
"llm:",
|
|
1210
|
+
` defaultProvider: ${provider}`,
|
|
1211
|
+
` defaultModel: ${defaultModels[provider]}`
|
|
1212
|
+
];
|
|
1188
1213
|
if (provider === "ollama") {
|
|
1189
|
-
lines.push(
|
|
1214
|
+
lines.push(
|
|
1215
|
+
" providers:",
|
|
1216
|
+
" ollama:",
|
|
1217
|
+
" baseUrl: ${OLLAMA_BASE_URL:-http://localhost:11434}"
|
|
1218
|
+
);
|
|
1190
1219
|
}
|
|
1220
|
+
if (template === "memory") {
|
|
1221
|
+
lines.push(
|
|
1222
|
+
"",
|
|
1223
|
+
"memory:",
|
|
1224
|
+
" adapter: redis",
|
|
1225
|
+
" redis:",
|
|
1226
|
+
" url: ${REDIS_URL:-redis://localhost:6379}"
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
lines.push("");
|
|
1191
1230
|
return { path: "cogitator.yml", content: lines.join("\n") };
|
|
1192
1231
|
}
|
|
1193
1232
|
|
|
1233
|
+
// src/utils/links.ts
|
|
1234
|
+
var DOCS_URL = "https://cogitator.app/docs";
|
|
1235
|
+
var REPO_URL = "https://github.com/cogitator-ai/Cogitator-AI";
|
|
1236
|
+
|
|
1194
1237
|
// src/templates/base/readme.ts
|
|
1195
1238
|
var templateNames = {
|
|
1196
1239
|
basic: "Basic Agent",
|
|
@@ -1206,7 +1249,7 @@ function generateReadme(options) {
|
|
|
1206
1249
|
const content = [
|
|
1207
1250
|
`# ${options.name}`,
|
|
1208
1251
|
"",
|
|
1209
|
-
`> Created with [create-cogitator-app](
|
|
1252
|
+
`> Created with [create-cogitator-app](${REPO_URL}) \u2014 ${templateName} template`,
|
|
1210
1253
|
"",
|
|
1211
1254
|
"## Getting Started",
|
|
1212
1255
|
"",
|
|
@@ -1221,30 +1264,57 @@ function generateReadme(options) {
|
|
|
1221
1264
|
...options.docker ? ["## Docker Services", "", "```bash", "docker compose up -d", "```", ""] : [],
|
|
1222
1265
|
"## Learn More",
|
|
1223
1266
|
"",
|
|
1224
|
-
|
|
1225
|
-
|
|
1267
|
+
`- [Cogitator Documentation](${DOCS_URL})`,
|
|
1268
|
+
`- [GitHub Repository](${REPO_URL})`,
|
|
1226
1269
|
""
|
|
1227
1270
|
];
|
|
1228
1271
|
return { path: "README.md", content: content.join("\n") };
|
|
1229
1272
|
}
|
|
1230
1273
|
|
|
1274
|
+
// src/templates/base/pnpm-workspace.ts
|
|
1275
|
+
var PNPM_ALLOWED_BUILDS = ["better-sqlite3", "esbuild", "sharp"];
|
|
1276
|
+
function generatePnpmWorkspace() {
|
|
1277
|
+
return {
|
|
1278
|
+
path: "pnpm-workspace.yaml",
|
|
1279
|
+
content: ["allowBuilds:", ...PNPM_ALLOWED_BUILDS.map((name) => ` ${name}: true`), ""].join(
|
|
1280
|
+
"\n"
|
|
1281
|
+
)
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1231
1285
|
// src/utils/git.ts
|
|
1232
|
-
import {
|
|
1286
|
+
import { execFileSync } from "child_process";
|
|
1287
|
+
var FALLBACK_IDENTITY = [
|
|
1288
|
+
"-c",
|
|
1289
|
+
"user.name=create-cogitator-app",
|
|
1290
|
+
"-c",
|
|
1291
|
+
"user.email=create-cogitator-app@localhost"
|
|
1292
|
+
];
|
|
1233
1293
|
function isGitInstalled() {
|
|
1234
1294
|
try {
|
|
1235
|
-
|
|
1295
|
+
execFileSync("git", ["--version"], { stdio: "ignore" });
|
|
1236
1296
|
return true;
|
|
1237
1297
|
} catch {
|
|
1238
1298
|
return false;
|
|
1239
1299
|
}
|
|
1240
1300
|
}
|
|
1301
|
+
function hasIdentity(cwd) {
|
|
1302
|
+
try {
|
|
1303
|
+
const name = execFileSync("git", ["config", "user.name"], { cwd, encoding: "utf8" }).trim();
|
|
1304
|
+
const email = execFileSync("git", ["config", "user.email"], { cwd, encoding: "utf8" }).trim();
|
|
1305
|
+
return name.length > 0 && email.length > 0;
|
|
1306
|
+
} catch {
|
|
1307
|
+
return false;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1241
1310
|
function initGitRepo(cwd) {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1311
|
+
execFileSync("git", ["init"], { cwd, stdio: "ignore" });
|
|
1312
|
+
execFileSync("git", ["add", "-A"], { cwd, stdio: "ignore" });
|
|
1313
|
+
const identity = hasIdentity(cwd) ? [] : FALLBACK_IDENTITY;
|
|
1314
|
+
execFileSync("git", [...identity, "commit", "-m", "feat: initial project scaffold"], {
|
|
1315
|
+
cwd,
|
|
1316
|
+
stdio: "ignore"
|
|
1317
|
+
});
|
|
1248
1318
|
}
|
|
1249
1319
|
|
|
1250
1320
|
// src/scaffold.ts
|
|
@@ -1256,7 +1326,7 @@ function writeFile(basePath, file) {
|
|
|
1256
1326
|
function buildPackageJson(options) {
|
|
1257
1327
|
const template = getTemplate(options.template);
|
|
1258
1328
|
const isNextjs = options.template === "nextjs";
|
|
1259
|
-
const
|
|
1329
|
+
const pkg2 = {
|
|
1260
1330
|
name: options.name,
|
|
1261
1331
|
version: "0.1.0",
|
|
1262
1332
|
private: true,
|
|
@@ -1265,7 +1335,7 @@ function buildPackageJson(options) {
|
|
|
1265
1335
|
dependencies: template.dependencies(),
|
|
1266
1336
|
devDependencies: template.devDependencies()
|
|
1267
1337
|
};
|
|
1268
|
-
return JSON.stringify(
|
|
1338
|
+
return JSON.stringify(pkg2, null, 2) + "\n";
|
|
1269
1339
|
}
|
|
1270
1340
|
function collectFiles(options) {
|
|
1271
1341
|
const template = getTemplate(options.template);
|
|
@@ -1274,11 +1344,14 @@ function collectFiles(options) {
|
|
|
1274
1344
|
files.push(...template.files(options));
|
|
1275
1345
|
files.push(generateGitignore());
|
|
1276
1346
|
files.push(generateEnvExample(options.provider, options.template));
|
|
1277
|
-
files.push(generateCogitatorYml(options.provider));
|
|
1347
|
+
files.push(generateCogitatorYml(options.provider, options.template));
|
|
1278
1348
|
files.push(generateReadme(options));
|
|
1279
1349
|
if (options.template !== "nextjs") {
|
|
1280
1350
|
files.push(generateTsconfig());
|
|
1281
1351
|
}
|
|
1352
|
+
if (options.packageManager === "pnpm") {
|
|
1353
|
+
files.push(generatePnpmWorkspace());
|
|
1354
|
+
}
|
|
1282
1355
|
if (options.docker) {
|
|
1283
1356
|
files.push(generateDockerCompose(options.provider));
|
|
1284
1357
|
}
|
|
@@ -1315,8 +1388,9 @@ async function scaffold(options) {
|
|
|
1315
1388
|
}
|
|
1316
1389
|
|
|
1317
1390
|
// src/index.ts
|
|
1391
|
+
var pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
1318
1392
|
async function main() {
|
|
1319
|
-
banner();
|
|
1393
|
+
banner(pkg.version);
|
|
1320
1394
|
p3.intro(pc2.cyan("Let's build something with AI agents"));
|
|
1321
1395
|
const args = parseArgs(process.argv.slice(2));
|
|
1322
1396
|
const options = await collectOptions(args);
|
|
@@ -1329,7 +1403,7 @@ async function main() {
|
|
|
1329
1403
|
` ${pc2.cyan("cd")} ${options.name}`,
|
|
1330
1404
|
` ${pc2.cyan(dev)}`,
|
|
1331
1405
|
"",
|
|
1332
|
-
pc2.dim(
|
|
1406
|
+
pc2.dim(`Docs: ${DOCS_URL}`)
|
|
1333
1407
|
].join("\n")
|
|
1334
1408
|
);
|
|
1335
1409
|
}
|