@cogitator-ai/cli 0.3.16 → 0.4.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.
Files changed (73) hide show
  1. package/README.md +159 -510
  2. package/dist/commands/assistant.d.ts +13 -0
  3. package/dist/commands/assistant.d.ts.map +1 -1
  4. package/dist/commands/assistant.js +64 -58
  5. package/dist/commands/assistant.js.map +1 -1
  6. package/dist/commands/build.d.ts +2 -0
  7. package/dist/commands/build.d.ts.map +1 -1
  8. package/dist/commands/build.js +114 -59
  9. package/dist/commands/build.js.map +1 -1
  10. package/dist/commands/daemon.d.ts.map +1 -1
  11. package/dist/commands/daemon.js +223 -262
  12. package/dist/commands/daemon.js.map +1 -1
  13. package/dist/commands/deploy.d.ts.map +1 -1
  14. package/dist/commands/deploy.js +80 -42
  15. package/dist/commands/deploy.js.map +1 -1
  16. package/dist/commands/init.d.ts +44 -0
  17. package/dist/commands/init.d.ts.map +1 -1
  18. package/dist/commands/init.js +334 -265
  19. package/dist/commands/init.js.map +1 -1
  20. package/dist/commands/logs.d.ts +1 -0
  21. package/dist/commands/logs.d.ts.map +1 -1
  22. package/dist/commands/logs.js +8 -4
  23. package/dist/commands/logs.js.map +1 -1
  24. package/dist/commands/models.d.ts +1 -1
  25. package/dist/commands/models.d.ts.map +1 -1
  26. package/dist/commands/models.js +83 -93
  27. package/dist/commands/models.js.map +1 -1
  28. package/dist/commands/run.d.ts +4 -1
  29. package/dist/commands/run.d.ts.map +1 -1
  30. package/dist/commands/run.js +151 -128
  31. package/dist/commands/run.js.map +1 -1
  32. package/dist/commands/skill.d.ts +17 -0
  33. package/dist/commands/skill.d.ts.map +1 -1
  34. package/dist/commands/skill.js +203 -81
  35. package/dist/commands/skill.js.map +1 -1
  36. package/dist/commands/status.d.ts.map +1 -1
  37. package/dist/commands/status.js +20 -24
  38. package/dist/commands/status.js.map +1 -1
  39. package/dist/commands/up.d.ts +4 -0
  40. package/dist/commands/up.d.ts.map +1 -1
  41. package/dist/commands/up.js +182 -130
  42. package/dist/commands/up.js.map +1 -1
  43. package/dist/commands/wizard.d.ts +6 -0
  44. package/dist/commands/wizard.d.ts.map +1 -1
  45. package/dist/commands/wizard.js +301 -267
  46. package/dist/commands/wizard.js.map +1 -1
  47. package/dist/index.js +8 -1
  48. package/dist/index.js.map +1 -1
  49. package/dist/utils/daemon.d.ts +37 -0
  50. package/dist/utils/daemon.d.ts.map +1 -0
  51. package/dist/utils/daemon.js +194 -0
  52. package/dist/utils/daemon.js.map +1 -0
  53. package/dist/utils/docker.d.ts +9 -0
  54. package/dist/utils/docker.d.ts.map +1 -1
  55. package/dist/utils/docker.js +67 -12
  56. package/dist/utils/docker.js.map +1 -1
  57. package/dist/utils/env.d.ts +7 -0
  58. package/dist/utils/env.d.ts.map +1 -0
  59. package/dist/utils/env.js +41 -0
  60. package/dist/utils/env.js.map +1 -0
  61. package/dist/utils/module-loader.d.ts +5 -0
  62. package/dist/utils/module-loader.d.ts.map +1 -0
  63. package/dist/utils/module-loader.js +52 -0
  64. package/dist/utils/module-loader.js.map +1 -0
  65. package/dist/utils/ollama.d.ts +20 -0
  66. package/dist/utils/ollama.d.ts.map +1 -0
  67. package/dist/utils/ollama.js +111 -0
  68. package/dist/utils/ollama.js.map +1 -0
  69. package/dist/utils/provider-models.d.ts +13 -0
  70. package/dist/utils/provider-models.d.ts.map +1 -0
  71. package/dist/utils/provider-models.js +78 -0
  72. package/dist/utils/provider-models.js.map +1 -0
  73. package/package.json +8 -8
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @cogitator-ai/cli
2
2
 
3
- Command-line interface for the Cogitator AI agent runtime. Scaffold projects, manage Docker services, and run agents from the terminal.
3
+ Command-line interface for the Cogitator AI agent runtime. Scaffold assistant projects, run them in the foreground or as a background service, chat with agents from the terminal, manage Ollama models and Docker services, and deploy.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,635 +12,284 @@ pnpm add -g @cogitator-ai/cli
12
12
  npx @cogitator-ai/cli <command>
13
13
  ```
14
14
 
15
- ## Features
16
-
17
- - **Project Scaffolding** - Create new Cogitator projects with sensible defaults
18
- - **Docker Services** - Start/stop Redis, PostgreSQL, and Ollama with one command
19
- - **Agent Runner** - Run agents from the command line with streaming output
20
- - **Interactive Mode** - Chat with agents in a REPL environment
21
- - **Model Management** - List and pull Ollama models
22
- - **Service Status** - Monitor running Docker services
23
- - **Log Viewer** - View logs from all services
24
-
25
- ---
15
+ Requires Node.js 20+.
26
16
 
27
17
  ## Quick Start
28
18
 
19
+ There are two ways to build an assistant:
20
+
29
21
  ```bash
30
- # Create a new project
31
- cogitator init my-project
32
- cd my-project
22
+ # A) Config-driven personal assistant (no code)
23
+ cogitator wizard # answers → cogitator.yml + .env
24
+ cogitator up # run it
33
25
 
34
- # Start Docker services (Redis, Postgres, Ollama)
35
- cogitator up
26
+ # B) Code-first project
27
+ cogitator init my-assistant
28
+ cd my-assistant
29
+ pnpm dev # or: cogitator assistant
30
+ ```
36
31
 
37
- # Run the example agent
38
- pnpm dev
32
+ Quick one-off chat with any model:
39
33
 
40
- # Or run a quick chat
41
- cogitator run "What is the capital of France?"
34
+ ```bash
35
+ cogitator run -m ollama/llama3.1:8b "What is the capital of France?"
42
36
  ```
43
37
 
44
38
  ---
45
39
 
46
40
  ## Commands
47
41
 
42
+ | Command | Description |
43
+ | ------------------------ | ---------------------------------------------------------------------- |
44
+ | `cogitator init [name]` | Scaffold a code-first assistant project |
45
+ | `cogitator wizard` | Interactive setup that writes `cogitator.yml` + `.env` |
46
+ | `cogitator up` | Run the assistant from `cogitator.yml`, or start Docker services |
47
+ | `cogitator down` | Stop Docker Compose services |
48
+ | `cogitator assistant` | Run a gateway module (`src/gateway.ts`) with a live dashboard |
49
+ | `cogitator run [msg]` | Chat with an agent (one-shot or interactive REPL) |
50
+ | `cogitator build` | Bundle a gateway into a self-starting `dist/cogitator.mjs` |
51
+ | `cogitator daemon <cmd>` | Run in the background / install as a launchd or systemd service |
52
+ | `cogitator skill <cmd>` | Create, validate, install and remove skills |
53
+ | `cogitator models` | List or pull Ollama models |
54
+ | `cogitator status` | Show Docker Compose and Ollama status (alias: `ps`) |
55
+ | `cogitator logs` | View Docker Compose service logs |
56
+ | `cogitator deploy` | Deploy with Docker or Fly.io (see [`@cogitator-ai/deploy`](../deploy)) |
57
+
58
+ Set `COGITATOR_DEBUG=1` to print stack traces for unexpected errors.
59
+
60
+ ---
61
+
48
62
  ### cogitator init
49
63
 
50
- Create a new Cogitator project with all necessary files.
64
+ Creates a TypeScript project with a [`Gateway`](../channels) wired to your chosen LLM provider, channels and memory adapter.
51
65
 
52
66
  ```bash
53
- cogitator init <name> [options]
67
+ cogitator init my-assistant # prompts for provider, model, channels, memory
68
+ cogitator init my-assistant --no-install
54
69
  ```
55
70
 
56
- | Option | Description |
57
- | -------------- | -------------------------------------- |
58
- | `--no-install` | Skip automatic dependency installation |
59
-
60
- **Generated Project Structure:**
71
+ The project name must be a valid npm package name (lowercase, `-`, `_`, `.`). The package manager used for installation is detected from how you invoked the CLI (`pnpm`, `npm`, `yarn` or `bun`).
61
72
 
62
73
  ```
63
- my-project/
64
- ├── package.json # Dependencies and scripts
65
- ├── tsconfig.json # TypeScript configuration
66
- ├── cogitator.yml # Cogitator configuration
67
- ├── docker-compose.yml # Docker services
68
- ├── .gitignore # Git ignore rules
74
+ my-assistant/
75
+ ├── package.json # @cogitator-ai/* pinned to the versions this CLI ships with
76
+ ├── tsconfig.json
77
+ ├── .env # API keys and channel tokens (mode 0600)
78
+ ├── .gitignore
69
79
  └── src/
70
- └── agent.ts # Example agent with tools
80
+ ├── gateway.ts # exports `gateway` — agent, channels, memory adapter
81
+ └── agent.ts # starts the gateway (pnpm dev / pnpm start)
71
82
  ```
72
83
 
73
- **Example:**
84
+ | Memory choice | Generated adapter | Extra dependency | Notes |
85
+ | ------------- | ----------------- | ---------------- | ----------------------------------- |
86
+ | SQLite | `SQLiteAdapter` | `better-sqlite3` | Stored in `./data/memory.db` |
87
+ | In-memory | `InMemoryAdapter` | — | Lost on restart |
88
+ | PostgreSQL | `PostgresAdapter` | `pg` | Connection string in `DATABASE_URL` |
74
89
 
75
- ```bash
76
- # Create project and install dependencies
77
- cogitator init my-ai-app
78
-
79
- # Create project without installing
80
- cogitator init my-ai-app --no-install
81
- ```
90
+ `src/gateway.ts` loads `.env` itself (`process.loadEnvFile`, Node ≥ 20.12), so it works with `pnpm dev`, `cogitator assistant`, `cogitator build` and the daemon alike.
82
91
 
83
92
  ---
84
93
 
85
- ### cogitator up
94
+ ### cogitator wizard
86
95
 
87
- Start Docker services for local development.
96
+ Interactive setup for the config-driven personal assistant run by `cogitator up`.
88
97
 
89
98
  ```bash
90
- cogitator up [options]
99
+ cogitator wizard # create cogitator.yml (+ .env)
100
+ cogitator wizard --edit # edit an existing cogitator.yml, pre-filling current values
91
101
  ```
92
102
 
93
- | Option | Default | Description |
94
- | -------------- | ------- | ---------------------------------- |
95
- | `-d, --detach` | `true` | Run services in background |
96
- | `--no-detach` | - | Run services in foreground |
97
- | `--pull` | `false` | Pull latest images before starting |
98
-
99
- **Services Started:**
100
-
101
- | Service | Port | Description |
102
- | ---------- | ----- | --------------------------------- |
103
- | Redis | 6379 | In-memory cache and queue backend |
104
- | PostgreSQL | 5432 | Vector database with pgvector |
105
- | Ollama | 11434 | Local LLM inference server |
103
+ The wizard asks for the LLM provider and model (models are fetched live from the provider registry or your Ollama server), channels (Telegram, Discord, Slack with owner IDs), capabilities (web search, file system, GitHub, device tools, browser, scheduler, RAG, self-config, self-tools), MCP servers (quoted arguments are supported) and the SQLite memory path.
106
104
 
107
- **Connection Strings:**
105
+ Secrets are merged into `.env` without touching your other variables or comments. In `--edit` mode, leaving a secret blank keeps the current value, and existing MCP servers and advanced settings (security, rate limits, …) are preserved.
108
106
 
109
- ```
110
- Redis: redis://localhost:6379
111
- Postgres: postgresql://cogitator:cogitator@localhost:5432/cogitator
112
- Ollama: http://localhost:11434
113
- ```
107
+ ---
114
108
 
115
- **Examples:**
109
+ ### cogitator up / down
116
110
 
117
111
  ```bash
118
- # Start in background (default)
119
- cogitator up
120
-
121
- # Pull latest images and start
122
- cogitator up --pull
123
-
124
- # Run in foreground (see all logs)
125
- cogitator up --no-detach
112
+ cogitator up # ./cogitator.yml (or .yaml) → run the assistant
113
+ cogitator up -c path/to/assistant.yml
114
+ cogitator up --no-restart-loop # do not supervise self-config restarts
126
115
  ```
127
116
 
128
- ---
129
-
130
- ### cogitator down
131
-
132
- Stop Docker services.
117
+ When a `cogitator.yml` exists, `up` validates it (errors list the offending fields), loads `.env` from the config's directory (existing environment variables win) and starts the assistant. With the `selfConfig` capability enabled, `up` supervises the assistant and restarts it whenever the agent rewrites its own config; `SIGINT`/`SIGTERM` are forwarded for a graceful shutdown.
133
118
 
134
- ```bash
135
- cogitator down [options]
136
- ```
119
+ Without an assistant config, `up` manages the Docker Compose project found in the current or a parent directory (`docker-compose.yml`, `compose.yml`, …):
137
120
 
138
- | Option | Description |
139
- | --------------- | --------------------------------- |
140
- | `-v, --volumes` | Remove volumes (deletes all data) |
121
+ | Option | Default | Description |
122
+ | -------------- | ------- | ---------------------------------- |
123
+ | `-d, --detach` | `true` | Run services in background |
124
+ | `--no-detach` | - | Run services in foreground |
125
+ | `--pull` | `false` | Pull latest images before starting |
141
126
 
142
- **Examples:**
127
+ After starting, the published ports of every service are printed.
143
128
 
144
129
  ```bash
145
- # Stop services (keep data)
146
- cogitator down
147
-
148
- # Stop services and delete all data
149
- cogitator down --volumes
130
+ cogitator down # stop services (keep data)
131
+ cogitator down --volumes # stop and delete volumes
150
132
  ```
151
133
 
152
134
  ---
153
135
 
154
- ### cogitator run
136
+ ### cogitator assistant
155
137
 
156
- Run an agent with a message or start interactive mode.
138
+ Runs a module that exports a `gateway` (as generated by `init`) with a live dashboard.
157
139
 
158
140
  ```bash
159
- cogitator run [message] [options]
141
+ cogitator assistant # src/gateway.ts
142
+ cogitator assistant -c src/my-gw.ts
143
+ cogitator assistant --quiet # no banner, status line or hotkeys (used by the daemon)
160
144
  ```
161
145
 
162
- | Option | Default | Description |
163
- | --------------------- | --------------- | --------------------------------------- |
164
- | `-c, --config <path>` | `cogitator.yml` | Config file path |
165
- | `-m, --model <model>` | auto-detect | Model to use (e.g., `ollama/gemma3:4b`) |
166
- | `-i, --interactive` | `false` | Force interactive mode |
167
- | `-s, --stream` | `true` | Stream response tokens |
168
- | `--no-stream` | - | Disable streaming |
169
-
170
- **Model Auto-Detection:**
146
+ TypeScript modules are loaded through [`tsx`](https://tsx.is), resolved from your project first. `.env` in the working directory is loaded before the module. Hotkeys (interactive terminals only): `s` sessions, `c` channels, `h` help, `q` quit.
171
147
 
172
- If no model is specified, the CLI will:
148
+ ---
173
149
 
174
- 1. Check `COGITATOR_MODEL` environment variable
175
- 2. Query Ollama for available models
176
- 3. Select from preferred models: llama3.1:8b, llama3:8b, gemma3:4b, gemma2:9b, mistral:7b
177
- 4. Fall back to first available model
150
+ ### cogitator run
178
151
 
179
- **Examples:**
152
+ Run an agent with a message, or start an interactive REPL when no message is given.
180
153
 
181
154
  ```bash
182
- # Single message with auto-detected model
183
155
  cogitator run "Explain quantum computing in simple terms"
184
-
185
- # Specify a model
186
- cogitator run -m ollama/gemma3:4b "Write a haiku about AI"
187
-
188
- # Use OpenAI
189
156
  cogitator run -m openai/gpt-4o "Analyze this code..."
190
-
191
- # Disable streaming
192
157
  cogitator run --no-stream "Hello"
193
-
194
- # Interactive mode (starts automatically if no message)
195
- cogitator run
196
- cogitator run -i
197
- ```
198
-
199
- ---
200
-
201
- ### Interactive Mode
202
-
203
- When running without a message or with `-i`, you enter interactive mode:
204
-
158
+ cogitator run # interactive
205
159
  ```
206
- ___ _ _ _
207
- / __\___ __ _(_) |_ __ _| |_ ___ _ __
208
- / / / _ \ / _` | | __/ _` | __/ _ \| '__|
209
- / /__| (_) | (_| | | || (_| | || (_) | |
210
- \____/\___/ \__, |_|\__\__,_|\__\___/|_|
211
- |___/
212
160
 
213
- AI Agent Runtime v0.1.0
161
+ | Option | Default | Description |
162
+ | --------------------- | ----------- | ----------------------------------- |
163
+ | `-c, --config <path>` | auto | Config file (must exist when given) |
164
+ | `-m, --model <model>` | auto-detect | Model, e.g. `ollama/gemma3:4b` |
165
+ | `-i, --interactive` | `false` | Force interactive mode |
166
+ | `-s, --stream` | `true` | Stream response tokens |
167
+ | `--no-stream` | - | Disable streaming |
214
168
 
215
- Model: llama3.1:8b
216
- Commands: /model <name>, /clear, /help, exit
169
+ **Config resolution:** `-c` → `COGITATOR_CONFIG` → `cogitator.yml`, `cogitator.yaml`, `cogitator.json`, `.cogitator.yml`, `.cogitator.yaml`. The file is loaded with [`@cogitator-ai/config`](../config), so `${ENV}` references and `COGITATOR_*` / provider environment variables apply even without a file.
217
170
 
218
- > Hello!
219
- → Hi there! How can I help you today?
171
+ **Model resolution:** `-m` → `COGITATOR_MODEL` → `llm.defaultModel` from the config → first installed Ollama model (preferring llama3.1:8b, llama3:8b, gemma3:4b, gemma2:9b, mistral:7b). Ollama is reached at `llm.providers.ollama.baseUrl`, `OLLAMA_URL` or `OLLAMA_HOST`.
220
172
 
221
- [1] > What's 2 + 2?
222
- → 2 + 2 equals 4.
173
+ Interactive commands: `/model [name]`, `/clear`, `/help`, `exit` / `quit` (Ctrl+D also exits).
223
174
 
224
- [2] >
225
- ```
226
-
227
- **Interactive Commands:**
175
+ ---
228
176
 
229
- | Command | Description |
230
- | ---------------- | ----------------------------------------- |
231
- | `/model [name]` | Show current model or switch to a new one |
232
- | `/clear` | Clear conversation history (start fresh) |
233
- | `/help` | Show available commands |
234
- | `exit` or `quit` | Exit interactive mode |
177
+ ### cogitator build
235
178
 
236
- **Examples:**
179
+ Bundles a gateway module with [esbuild](https://esbuild.github.io) into a single self-starting ES module. The bundle starts the exported `gateway` and stops it gracefully on `SIGINT`/`SIGTERM`.
237
180
 
181
+ ```bash
182
+ pnpm add -D esbuild
183
+ cogitator build # src/gateway.ts → dist/cogitator.mjs
184
+ cogitator build -c src/gw.ts -o out/bot.mjs --minify --no-sourcemap
185
+ node dist/cogitator.mjs
238
186
  ```
239
- > /model
240
- Current model: ollama/llama3.1:8b
241
-
242
- > /model gemma3:4b
243
- ✓ Switched to model: ollama/gemma3:4b
244
187
 
245
- > /clear
246
- Conversation cleared
188
+ | Option | Default |
189
+ | ---------------------- | -------------------- |
190
+ | `-c, --config <path>` | `src/gateway.ts` |
191
+ | `-o, --outfile <path>` | `dist/cogitator.mjs` |
192
+ | `--target <version>` | `node20` |
193
+ | `--sourcemap` | `true` |
194
+ | `--minify` | `false` |
247
195
 
248
- > exit
249
- Goodbye!
250
- ```
196
+ Native and optional channel dependencies (`better-sqlite3`, `pg`, `grammy`, `discord.js`, `@slack/bolt`, `playwright`, …) stay external.
251
197
 
252
198
  ---
253
199
 
254
- ### cogitator status
200
+ ### cogitator daemon
255
201
 
256
- Show status of all Cogitator services.
202
+ Runs your assistant in the background. The entry is auto-detected in this order: `dist/cogitator.mjs` (from `cogitator build`), `cogitator.yml` / `cogitator.yaml` (via `cogitator up`), `src/gateway.ts` (via `cogitator assistant --quiet`). Use `-c` to choose explicitly.
257
203
 
258
204
  ```bash
259
- cogitator status
260
- # or
261
- cogitator ps
262
- ```
263
-
264
- **Output Example:**
205
+ cogitator daemon start [-c <entry>]
206
+ cogitator daemon status # PID, uptime, memory
207
+ cogitator daemon logs -f -n 100 # .cogitator/daemon.log
208
+ cogitator daemon restart
209
+ cogitator daemon stop # SIGTERM, then SIGKILL after 10s
265
210
 
211
+ cogitator daemon install [-c <entry>] # launchd (macOS) or systemd --user (Linux)
212
+ cogitator daemon uninstall
266
213
  ```
267
- ℹ Cogitator Services Status
268
-
269
- Docker Compose Services:
270
-
271
- ● my-project-redis-1 running Up 2 minutes
272
- ● my-project-postgres-1 running Up 2 minutes
273
- ● my-project-ollama-1 running Up 2 minutes
274
214
 
275
- External Services:
276
-
277
- ● Ollama running localhost:11434
278
- ```
215
+ The PID file (`.cogitator/daemon.pid`) records the launched script, so `stop` never signals an unrelated process that reused the PID. Service definitions use absolute paths, the current `PATH`, and start on login (`loginctl enable-linger` keeps a systemd user service running after logout).
279
216
 
280
217
  ---
281
218
 
282
- ### cogitator logs
283
-
284
- View logs from Docker services.
219
+ ### cogitator skill
285
220
 
286
221
  ```bash
287
- cogitator logs [service] [options]
222
+ cogitator skill create weather-api --template api # basic | device | api
223
+ cogitator skill validate skills/weather-api
224
+ cogitator skill list
225
+ cogitator skill add ./path/to/skill [--global]
226
+ cogitator skill remove weather-api [--global]
288
227
  ```
289
228
 
290
- | Option | Default | Description |
291
- | -------------------- | ------- | ---------------------------------- |
292
- | `-f, --follow` | `false` | Follow log output (like `tail -f`) |
293
- | `-n, --tail <lines>` | `100` | Number of lines to show |
294
- | `-t, --timestamps` | `false` | Show timestamps |
295
-
296
- **Available Services:**
297
-
298
- - `redis` - Redis cache/queue logs
299
- - `postgres` - PostgreSQL database logs
300
- - `ollama` - Ollama LLM server logs
301
-
302
- **Examples:**
303
-
304
- ```bash
305
- # View last 100 lines from all services
306
- cogitator logs
307
-
308
- # Follow logs in real-time
309
- cogitator logs -f
310
-
311
- # View only Ollama logs
312
- cogitator logs ollama
313
-
314
- # Follow Ollama logs with timestamps
315
- cogitator logs ollama -f -t
316
-
317
- # Show last 50 lines
318
- cogitator logs -n 50
319
- ```
229
+ Local skills live in `./skills`, global ones in `~/.cogitator/skills`. Skill names must be kebab-case. `validate` loads `skill.ts`/`skill.js`/`skill.mjs`, checks the `defineSkill` shape and every tool, required environment variables (`env`) and that `dependencies` resolve from the skill's location; it exits non-zero on problems.
320
230
 
321
231
  ---
322
232
 
323
233
  ### cogitator models
324
234
 
325
- List and manage Ollama models.
326
-
327
235
  ```bash
328
- cogitator models [options]
329
- ```
330
-
331
- | Option | Description |
332
- | ---------------- | --------------------------------- |
333
- | `--pull <model>` | Pull a model from Ollama registry |
334
-
335
- **Output Example:**
336
-
337
- ```
338
- ✓ Found 3 model(s)
339
-
340
- llama3.1:8b 4.7 GB 2 days ago
341
- gemma3:4b 2.8 GB 1 week ago
342
- mistral:7b 4.1 GB 3 weeks ago
343
-
344
- Use with: cogitator run -m ollama/<model> "message"
236
+ cogitator models # list installed models
237
+ cogitator models --pull qwen2.5:0.5b # pull with progress
238
+ cogitator models --url http://gpu-box:11434
345
239
  ```
346
240
 
347
- **Examples:**
348
-
349
- ```bash
350
- # List installed models
351
- cogitator models
352
-
353
- # Pull a new model
354
- cogitator models --pull llama3.1:8b
355
- cogitator models --pull gemma3:4b
356
- cogitator models --pull mistral:7b
357
- ```
241
+ The Ollama URL defaults to `OLLAMA_URL`, then `OLLAMA_HOST`, then `http://localhost:11434`; `OLLAMA_API_KEY` is sent as a bearer token. Pull errors reported by Ollama (e.g. unknown model) fail the command.
358
242
 
359
243
  ---
360
244
 
361
- ### cogitator deploy
362
-
363
- Deploy your Cogitator project to various targets.
245
+ ### cogitator status / logs
364
246
 
365
247
  ```bash
366
- cogitator deploy [action] [options]
248
+ cogitator status # compose services (state, health) + Ollama reachability
249
+ cogitator logs ollama -f -t -n 50
250
+ cogitator logs -n all
367
251
  ```
368
252
 
369
- **Actions:**
370
-
371
- | Action | Description |
372
- | --------- | ----------------------------------- |
373
- | _(none)_ | Deploy to target (shows plan first) |
374
- | `status` | Check deployment status |
375
- | `destroy` | Tear down deployment |
253
+ `status` still reports Ollama when Docker is not running.
376
254
 
377
- **Options:**
378
-
379
- | Option | Description |
380
- | ----------------------- | ------------------------------------------------------- |
381
- | `-t, --target <target>` | Deploy target: `docker`, `fly`, `railway`, `k8s`, `ssh` |
382
- | `-c, --config <path>` | Config file path |
383
- | `--registry <url>` | Container registry URL |
384
- | `--no-push` | Skip pushing image to registry |
385
- | `--dry-run` | Show deploy plan without executing |
386
- | `--region <region>` | Deploy region |
255
+ ---
387
256
 
388
- **Examples:**
257
+ ### cogitator deploy
389
258
 
390
259
  ```bash
391
- # Deploy with dry-run preview
392
- cogitator deploy --dry-run
393
-
394
- # Deploy to Fly.io
260
+ cogitator deploy --dry-run # analyze + preflight only
261
+ cogitator deploy # docker: build image, start compose stack
395
262
  cogitator deploy --target fly --region ord
396
-
397
- # Check deployment status
263
+ cogitator deploy --registry ghcr.io/acme # build + push (use --no-push to skip)
398
264
  cogitator deploy status
399
-
400
- # Tear down deployment
401
265
  cogitator deploy destroy
402
266
  ```
403
267
 
404
- ---
405
-
406
- ## Configuration
407
-
408
- ### cogitator.yml
409
-
410
- The main configuration file for your Cogitator project:
411
-
412
- ```yaml
413
- # cogitator.yml
414
-
415
- llm:
416
- defaultProvider: ollama
417
- providers:
418
- ollama:
419
- baseUrl: http://localhost:11434
420
- openai:
421
- apiKey: ${OPENAI_API_KEY}
422
-
423
- memory:
424
- adapter: memory
425
- # Or use Redis:
426
- # adapter: redis
427
- # redis:
428
- # url: redis://localhost:6379
429
- ```
430
-
431
- ### Environment Variables
432
-
433
- | Variable | Description |
434
- | ------------------- | ---------------------------------------------- |
435
- | `COGITATOR_CONFIG` | Path to config file (overrides auto-detection) |
436
- | `COGITATOR_MODEL` | Default model to use |
437
- | `OPENAI_API_KEY` | OpenAI API key |
438
- | `ANTHROPIC_API_KEY` | Anthropic API key |
439
-
440
- **Example .env:**
441
-
442
- ```bash
443
- COGITATOR_MODEL=ollama/llama3.1:8b
444
- OPENAI_API_KEY=sk-...
445
- ```
446
-
447
- ---
448
-
449
- ## Project Templates
450
-
451
- ### Basic Agent (Generated by `init`)
452
-
453
- ```typescript
454
- // src/agent.ts
455
- import { Cogitator, Agent, tool } from '@cogitator-ai/core';
456
- import { z } from 'zod';
457
-
458
- const greet = tool({
459
- name: 'greet',
460
- description: 'Greet someone by name',
461
- parameters: z.object({
462
- name: z.string().describe('Name to greet'),
463
- }),
464
- execute: async ({ name }) => `Hello, ${name}! 👋`,
465
- });
466
-
467
- const agent = new Agent({
468
- id: 'my-agent',
469
- name: 'My Agent',
470
- model: 'ollama/llama3.1:8b',
471
- instructions: 'You are a helpful assistant. Use the greet tool when asked to greet someone.',
472
- tools: [greet],
473
- });
474
-
475
- const cog = new Cogitator();
476
-
477
- const result = await cog.run(agent, {
478
- input: 'Hello! Can you greet Alex?',
479
- });
480
-
481
- console.log('Agent:', result.output);
482
-
483
- await cog.close();
484
- ```
485
-
486
- ### Agent with Multiple Tools
487
-
488
- ```typescript
489
- import { Cogitator, Agent, tool } from '@cogitator-ai/core';
490
- import { z } from 'zod';
491
-
492
- const calculator = tool({
493
- name: 'calculator',
494
- description: 'Perform mathematical calculations',
495
- parameters: z.object({
496
- expression: z.string().describe('Math expression to evaluate'),
497
- }),
498
- execute: async ({ expression }) => {
499
- const result = Function(`return ${expression}`)();
500
- return String(result);
501
- },
502
- });
503
-
504
- const datetime = tool({
505
- name: 'datetime',
506
- description: 'Get current date and time',
507
- parameters: z.object({}),
508
- execute: async () => new Date().toISOString(),
509
- });
510
-
511
- const agent = new Agent({
512
- name: 'Assistant',
513
- model: 'ollama/llama3.1:8b',
514
- instructions: 'You are a helpful assistant with calculator and datetime tools.',
515
- tools: [calculator, datetime],
516
- });
517
-
518
- const cog = new Cogitator();
519
- const result = await cog.run(agent, {
520
- input: 'What is 15 * 23 + 42? Also, what time is it?',
521
- });
522
-
523
- console.log(result.output);
524
- await cog.close();
525
- ```
526
-
527
- ---
528
-
529
- ## Docker Compose
530
-
531
- The generated `docker-compose.yml`:
532
-
533
- ```yaml
534
- name: my-project
535
-
536
- services:
537
- redis:
538
- image: redis:7-alpine
539
- ports:
540
- - '6379:6379'
541
- volumes:
542
- - redis-data:/data
543
-
544
- postgres:
545
- image: pgvector/pgvector:pg16
546
- ports:
547
- - '5432:5432'
548
- environment:
549
- POSTGRES_USER: cogitator
550
- POSTGRES_PASSWORD: cogitator
551
- POSTGRES_DB: cogitator
552
- volumes:
553
- - postgres-data:/var/lib/postgresql/data
554
-
555
- ollama:
556
- image: ollama/ollama:latest
557
- ports:
558
- - '11434:11434'
559
- volumes:
560
- - ollama-data:/root/.ollama
561
-
562
- volumes:
563
- redis-data:
564
- postgres-data:
565
- ollama-data:
566
- ```
567
-
568
- ---
569
-
570
- ## Troubleshooting
571
-
572
- ### Ollama Not Running
573
-
574
- ```
575
- ✗ Cannot connect to Ollama
576
- Start Ollama with: ollama serve
577
- ```
578
-
579
- **Solutions:**
580
-
581
- 1. Start Ollama: `ollama serve`
582
- 2. Or use Docker: `cogitator up`
583
- 3. Install Ollama: https://ollama.ai
584
-
585
- ### No Models Found
586
-
587
- ```
588
- ⚠ No models installed
589
- Pull a model with: cogitator models --pull llama3.1:8b
590
- ```
591
-
592
- **Solution:**
268
+ | Option | Description |
269
+ | ----------------------- | ---------------------------------------- |
270
+ | `-t, --target <target>` | `docker` (default) or `fly` |
271
+ | `-c, --config <path>` | Config file with a `deploy:` section |
272
+ | `--registry <url>` | Container registry to push to |
273
+ | `--no-push` | Skip pushing even when a registry is set |
274
+ | `--dry-run` | Show the plan without executing |
275
+ | `--region <region>` | Deploy region (Fly.io) |
593
276
 
594
- ```bash
595
- cogitator models --pull llama3.1:8b
596
- # or
597
- ollama pull llama3.1:8b
598
- ```
599
-
600
- ### Docker Not Running
601
-
602
- ```
603
- ✗ Docker is not installed or not running
604
- Install Docker: https://docs.docker.com/get-docker/
605
- ```
606
-
607
- **Solutions:**
608
-
609
- 1. Start Docker Desktop
610
- 2. Or: `sudo systemctl start docker`
611
-
612
- ### Config File Not Found
613
-
614
- ```
615
- No config file found
616
- ```
617
-
618
- The CLI searches for config in this order:
619
-
620
- 1. `COGITATOR_CONFIG` environment variable
621
- 2. `-c` option value
622
- 3. `cogitator.yml` in current directory
623
- 4. `cogitator.yaml` in current directory
624
- 5. `cogitator.json` in current directory
277
+ The plan lists detected services, required secrets (read from the environment or the project's `.env`), warnings and preflight checks. See [`@cogitator-ai/deploy`](../deploy) for details.
625
278
 
626
279
  ---
627
280
 
628
- ## NPM Scripts
629
-
630
- After `cogitator init`, these scripts are available:
281
+ ## Environment Variables
631
282
 
632
- ```bash
633
- # Run agent in watch mode (auto-reload on changes)
634
- pnpm dev
635
-
636
- # Run agent once
637
- pnpm start
283
+ | Variable | Used by | Description |
284
+ | ------------------------------------------------------- | ------------------------- | ----------------------------------- |
285
+ | `COGITATOR_CONFIG` | `run` | Config file path |
286
+ | `COGITATOR_MODEL` | `run` | Default model |
287
+ | `OLLAMA_URL` / `OLLAMA_HOST` | `run`, `models`, `status` | Ollama endpoint |
288
+ | `OLLAMA_API_KEY` | `run`, `models`, `wizard` | Ollama Cloud / authenticated Ollama |
289
+ | `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_API_KEY` | `run`, `init`, `wizard` | Provider keys |
290
+ | `COGITATOR_DEBUG` | all | Print stack traces |
638
291
 
639
- # Build TypeScript
640
- pnpm build
641
- ```
642
-
643
- ---
292
+ See [`@cogitator-ai/config`](../config) for every `COGITATOR_*` variable.
644
293
 
645
294
  ## License
646
295