kob-cli 1.0.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/AGENTS.md +351 -0
- package/INSTALL.md +84 -0
- package/LICENSE +34 -0
- package/MANUAL.md +526 -0
- package/QUICKSTART.md +147 -0
- package/README.md +359 -0
- package/SPECTS.md +581 -0
- package/bin/cli.js +21 -0
- package/package.json +76 -0
- package/src/commands/ask.ts +55 -0
- package/src/commands/auth.ts +72 -0
- package/src/commands/chat.ts +146 -0
- package/src/commands/code.ts +78 -0
- package/src/commands/models.ts +66 -0
- package/src/commands/skills.ts +36 -0
- package/src/commands/stream.ts +53 -0
- package/src/index.ts +84 -0
- package/src/types/index.ts +95 -0
- package/src/ui/code-tui.tsx +440 -0
- package/src/utils/api.ts +208 -0
- package/src/utils/config.ts +45 -0
- package/src/utils/errors.ts +43 -0
- package/src/utils/format.ts +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
# ๐ค KOB AI CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for interacting with KOB AI API. Built with Bun and TypeScript.
|
|
4
|
+
|
|
5
|
+
Developed by **Kob AI** โ [www.kob-ai.dev](https://www.kob-ai.dev) | Developer in Thailand ๐น๐ญ
|
|
6
|
+
|
|
7
|
+
## โจ Features
|
|
8
|
+
|
|
9
|
+
- ๐ **Authentication** - Verify credentials and check balance
|
|
10
|
+
- ๐ฌ **AI Chat** - Send messages and get AI responses
|
|
11
|
+
- ๐ **Streaming** - Real-time streaming AI responses
|
|
12
|
+
- ๐ค **Models** - Browse available AI models and pricing
|
|
13
|
+
- ๐ **Projects** - Create, update, list, and delete projects
|
|
14
|
+
- ๐ **Rules** - Manage project rules (forbidden, required, custom)
|
|
15
|
+
- ๐ฐ **Credits** - View credit history and transactions
|
|
16
|
+
- ๐จ **Rich Output** - Beautiful terminal output with colors and formatting
|
|
17
|
+
|
|
18
|
+
## ๐ Quick Start
|
|
19
|
+
|
|
20
|
+
### Prerequisites
|
|
21
|
+
|
|
22
|
+
- **Bun** runtime installed ([Install Bun](https://bun.sh/docs/installation))
|
|
23
|
+
- KOB AI API credentials (API Key)
|
|
24
|
+
|
|
25
|
+
### Installation via npm (recommended)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g kob-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Installation from source
|
|
32
|
+
|
|
33
|
+
1. Clone or navigate to the kob-cli directory:
|
|
34
|
+
```bash
|
|
35
|
+
cd kob-cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Install dependencies:
|
|
39
|
+
```bash
|
|
40
|
+
bun install
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
3. Set up environment variables:
|
|
44
|
+
```bash
|
|
45
|
+
# Copy the example env file
|
|
46
|
+
cp .env.example .env
|
|
47
|
+
|
|
48
|
+
# Edit .env and add your credentials
|
|
49
|
+
# KOB_API_BASE_URL=https://www.kob-ai.dev
|
|
50
|
+
# KOB_API_KEY=kob_your_api_key
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or export them directly:
|
|
54
|
+
```bash
|
|
55
|
+
export KOB_API_KEY=kob_your_api_key
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Usage
|
|
59
|
+
|
|
60
|
+
Run the CLI directly with Bun:
|
|
61
|
+
```bash
|
|
62
|
+
bun run src/index.ts <command>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Or use the npm script:
|
|
66
|
+
```bash
|
|
67
|
+
bun dev <command>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## ๐ Commands
|
|
71
|
+
|
|
72
|
+
### Authentication
|
|
73
|
+
|
|
74
|
+
**Verify credentials:**
|
|
75
|
+
```bash
|
|
76
|
+
bun dev auth:verify
|
|
77
|
+
```
|
|
78
|
+
Shows user information, package details, and credit balance.
|
|
79
|
+
|
|
80
|
+
**Check balance:**
|
|
81
|
+
```bash
|
|
82
|
+
bun dev balance
|
|
83
|
+
```
|
|
84
|
+
Quick check of your current credit balance.
|
|
85
|
+
|
|
86
|
+
### AI Chat
|
|
87
|
+
|
|
88
|
+
**Send a message:**
|
|
89
|
+
```bash
|
|
90
|
+
bun dev chat "Explain quantum computing" \
|
|
91
|
+
--provider DeepSeek \
|
|
92
|
+
--model deepseek-chat \
|
|
93
|
+
--temperature 0.7
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Interactive chat mode:**
|
|
97
|
+
```bash
|
|
98
|
+
bun dev chat:interactive \
|
|
99
|
+
--provider OpenRouter \
|
|
100
|
+
--model openai/gpt-4o
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Interactive commands:
|
|
104
|
+
- `/clear` - Clear conversation history
|
|
105
|
+
- `/stats` - Show conversation statistics
|
|
106
|
+
- `/help` - Show available commands
|
|
107
|
+
- `/exit` - Exit chat mode
|
|
108
|
+
|
|
109
|
+
### Streaming
|
|
110
|
+
|
|
111
|
+
**Stream AI response:**
|
|
112
|
+
```bash
|
|
113
|
+
bun dev stream "Write a poem about coding" \
|
|
114
|
+
--provider OpenRouter \
|
|
115
|
+
--model google/gemini-flash-1.5
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Real-time token-by-token display as AI generates response.
|
|
119
|
+
|
|
120
|
+
### Models
|
|
121
|
+
|
|
122
|
+
**List all models:**
|
|
123
|
+
```bash
|
|
124
|
+
bun dev models
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Filter by provider:**
|
|
128
|
+
```bash
|
|
129
|
+
bun dev models --provider DeepSeek
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**JSON output:**
|
|
133
|
+
```bash
|
|
134
|
+
bun dev models --format json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Projects
|
|
138
|
+
|
|
139
|
+
**List projects:**
|
|
140
|
+
```bash
|
|
141
|
+
bun dev projects:list
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Create project:**
|
|
145
|
+
```bash
|
|
146
|
+
bun dev projects:create "My Chatbot" \
|
|
147
|
+
--description "AI chatbot for customer support"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Update project:**
|
|
151
|
+
```bash
|
|
152
|
+
bun dev projects:update <project-id> \
|
|
153
|
+
--name "Updated Name" \
|
|
154
|
+
--description "New description"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Delete project:**
|
|
158
|
+
```bash
|
|
159
|
+
bun dev projects:delete <project-id>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Rules
|
|
163
|
+
|
|
164
|
+
**List rules:**
|
|
165
|
+
```bash
|
|
166
|
+
bun dev rules:list --project-id <project-id>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Create rule:**
|
|
170
|
+
```bash
|
|
171
|
+
bun dev rules:create \
|
|
172
|
+
--project-id <project-id> \
|
|
173
|
+
--text "Must respond in Thai only" \
|
|
174
|
+
--type required
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Rule types:
|
|
178
|
+
- `forbidden` - ๐ซ Things AI must not do
|
|
179
|
+
- `required` - โ
Things AI must do
|
|
180
|
+
- `custom` - ๐ Custom rules
|
|
181
|
+
|
|
182
|
+
**Update rule:**
|
|
183
|
+
```bash
|
|
184
|
+
bun dev rules:update <rule-id> \
|
|
185
|
+
--project-id <project-id> \
|
|
186
|
+
--text "Updated rule text" \
|
|
187
|
+
--active false
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Delete rule:**
|
|
191
|
+
```bash
|
|
192
|
+
bun dev rules:delete <rule-id> --project-id <project-id>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Credits
|
|
196
|
+
|
|
197
|
+
**View credit history:**
|
|
198
|
+
```bash
|
|
199
|
+
bun dev credits:history
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**With pagination:**
|
|
203
|
+
```bash
|
|
204
|
+
bun dev credits:history --limit 50 --offset 0
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## ๐ง Options
|
|
208
|
+
|
|
209
|
+
### Chat & Stream Options
|
|
210
|
+
|
|
211
|
+
| Option | Description | Default |
|
|
212
|
+
|--------|-------------|---------|
|
|
213
|
+
| `-p, --provider` | AI provider (DeepSeek, OpenRouter, DeepInfra) | DeepSeek |
|
|
214
|
+
| `-m, --model` | Model ID | deepseek-chat |
|
|
215
|
+
| `-t, --temperature` | Temperature (0.0-2.0) | 0.7 |
|
|
216
|
+
| `--max-tokens` | Maximum tokens | 4096 |
|
|
217
|
+
| `--project-id` | Project ID for rules | - |
|
|
218
|
+
| `--system-prompt` | System prompt | - |
|
|
219
|
+
|
|
220
|
+
### Common Providers and Models
|
|
221
|
+
|
|
222
|
+
**DeepSeek:**
|
|
223
|
+
- `deepseek-chat` (DeepSeek V3)
|
|
224
|
+
- `deepseek-reasoner` (DeepSeek R1)
|
|
225
|
+
- `deepseek-v4-pro`
|
|
226
|
+
- `deepseek-v4-flash`
|
|
227
|
+
|
|
228
|
+
**OpenRouter:**
|
|
229
|
+
- `openai/gpt-4o`
|
|
230
|
+
- `openai/gpt-4o-mini`
|
|
231
|
+
- `anthropic/claude-3.5-sonnet`
|
|
232
|
+
- `google/gemini-1.5-pro`
|
|
233
|
+
|
|
234
|
+
**DeepInfra:**
|
|
235
|
+
- `meta-llama/Meta-Llama-3.1-8B-Instruct`
|
|
236
|
+
- `meta-llama/Meta-Llama-3.1-70B-Instruct`
|
|
237
|
+
- `Qwen/Qwen2.5-72B-Instruct`
|
|
238
|
+
|
|
239
|
+
## ๐ก Examples
|
|
240
|
+
|
|
241
|
+
### Complete Workflow
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# 1. Verify connection
|
|
245
|
+
bun dev auth:verify
|
|
246
|
+
|
|
247
|
+
# 2. Check available models
|
|
248
|
+
bun dev models --provider DeepSeek
|
|
249
|
+
|
|
250
|
+
# 3. Create a project
|
|
251
|
+
bun dev projects:create "Customer Support Bot"
|
|
252
|
+
|
|
253
|
+
# 4. Add rules to project
|
|
254
|
+
bun dev rules:create \
|
|
255
|
+
--project-id <id> \
|
|
256
|
+
--text "Always respond in Thai" \
|
|
257
|
+
--type required
|
|
258
|
+
|
|
259
|
+
# 5. Chat with AI using project rules
|
|
260
|
+
bun dev chat "เธชเธงเธฑเธชเธเธต เธเนเธงเธขเนเธเธฐเธเธณเธชเธดเธเธเนเธฒเธซเธเนเธญเธข" \
|
|
261
|
+
--project-id <id>
|
|
262
|
+
|
|
263
|
+
# 6. Stream response for longer content
|
|
264
|
+
bun dev stream "Write a detailed guide about AI" \
|
|
265
|
+
--model openai/gpt-4o
|
|
266
|
+
|
|
267
|
+
# 7. Check credit usage
|
|
268
|
+
bun dev balance
|
|
269
|
+
bun dev credits:history
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## ๐ Development
|
|
273
|
+
|
|
274
|
+
### Project Structure
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
kob-cli/
|
|
278
|
+
โโโ src/
|
|
279
|
+
โ โโโ index.ts # CLI entry point
|
|
280
|
+
โ โโโ commands/ # Command implementations
|
|
281
|
+
โ โ โโโ auth.ts # Authentication commands
|
|
282
|
+
โ โ โโโ chat.ts # Chat commands
|
|
283
|
+
โ โ โโโ stream.ts # Streaming command
|
|
284
|
+
โ โ โโโ models.ts # Models command
|
|
285
|
+
โ โ โโโ projects.ts # Project CRUD
|
|
286
|
+
โ โ โโโ rules.ts # Rules CRUD
|
|
287
|
+
โ โ โโโ credits.ts # Credit history
|
|
288
|
+
โ โโโ utils/ # Utility modules
|
|
289
|
+
โ โ โโโ api.ts # API client
|
|
290
|
+
โ โ โโโ config.ts # Configuration
|
|
291
|
+
โ โ โโโ format.ts # Output formatting
|
|
292
|
+
โ โ โโโ errors.ts # Error handling
|
|
293
|
+
โ โโโ types/ # TypeScript types
|
|
294
|
+
โ โโโ index.ts
|
|
295
|
+
โโโ .env.example # Environment variables template
|
|
296
|
+
โโโ package.json
|
|
297
|
+
โโโ README.md
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Adding New Commands
|
|
301
|
+
|
|
302
|
+
1. Create command file in `src/commands/`
|
|
303
|
+
2. Export the command
|
|
304
|
+
3. Import and add to `src/index.ts`
|
|
305
|
+
|
|
306
|
+
### Build for Distribution
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
bun run build
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
This creates a compiled binary `kob-cli.exe`.
|
|
313
|
+
|
|
314
|
+
## โ Troubleshooting
|
|
315
|
+
|
|
316
|
+
**Error: KOB_API_KEY environment variable is required**
|
|
317
|
+
- Make sure you've set your environment variables
|
|
318
|
+
- Check that they're exported correctly or in .env file
|
|
319
|
+
|
|
320
|
+
**Authentication failed**
|
|
321
|
+
- Verify your API key is correct
|
|
322
|
+
- Check that your key is active on the Kob AI dashboard
|
|
323
|
+
|
|
324
|
+
**Insufficient credits**
|
|
325
|
+
- Check your balance with `bun dev balance`
|
|
326
|
+
- Top up your account at https://www.kob-ai.dev
|
|
327
|
+
|
|
328
|
+
**Model not available**
|
|
329
|
+
- List available models with `bun dev models`
|
|
330
|
+
- Verify the model ID is correct
|
|
331
|
+
|
|
332
|
+
## ๐ API Documentation
|
|
333
|
+
|
|
334
|
+
For detailed API documentation, see the official KOB AI API docs in the parent directory:
|
|
335
|
+
- `/my-app/docs/api-token-verify.md`
|
|
336
|
+
- `/my-app/docs/api-ai-chat.md`
|
|
337
|
+
- `/my-app/docs/api-ai-stream.md`
|
|
338
|
+
- `/my-app/docs/api-models.md`
|
|
339
|
+
- `/my-app/docs/api-projects.md`
|
|
340
|
+
- `/my-app/docs/api-project-rules.md`
|
|
341
|
+
- `/my-app/docs/api-credit-history.md`
|
|
342
|
+
|
|
343
|
+
## ๐ License
|
|
344
|
+
|
|
345
|
+
KOB AI CLI - Non-Commercial Open Source License
|
|
346
|
+
|
|
347
|
+
Copyright (c) 2025 KOB AI Project Owner
|
|
348
|
+
|
|
349
|
+
This software is open source and free to use, modify, and distribute for **non-commercial purposes only**.
|
|
350
|
+
|
|
351
|
+
**Commercial use is strictly prohibited without prior written permission from the owner.**
|
|
352
|
+
|
|
353
|
+
For commercial licensing inquiries, please contact the project owner.
|
|
354
|
+
|
|
355
|
+
See the [LICENSE](LICENSE) file for full terms.
|
|
356
|
+
|
|
357
|
+
## ๐ค Support
|
|
358
|
+
|
|
359
|
+
For issues or questions, please visit https://www.kob-ai.dev or contact the Kob AI development team.
|