@majkapp/majk-chat-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.
Files changed (38) hide show
  1. package/README.md +746 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +1001 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/interactive/interactive.d.ts +27 -0
  7. package/dist/interactive/interactive.d.ts.map +1 -0
  8. package/dist/interactive/interactive.js +361 -0
  9. package/dist/interactive/interactive.js.map +1 -0
  10. package/dist/tools/bash.tool.d.ts +11 -0
  11. package/dist/tools/bash.tool.d.ts.map +1 -0
  12. package/dist/tools/bash.tool.js +140 -0
  13. package/dist/tools/bash.tool.js.map +1 -0
  14. package/dist/tools/filesystem.tool.d.ts +20 -0
  15. package/dist/tools/filesystem.tool.d.ts.map +1 -0
  16. package/dist/tools/filesystem.tool.js +312 -0
  17. package/dist/tools/filesystem.tool.js.map +1 -0
  18. package/dist/utils/config.d.ts +8 -0
  19. package/dist/utils/config.d.ts.map +1 -0
  20. package/dist/utils/config.js +140 -0
  21. package/dist/utils/config.js.map +1 -0
  22. package/dist/utils/credentials.d.ts +45 -0
  23. package/dist/utils/credentials.d.ts.map +1 -0
  24. package/dist/utils/credentials.js +265 -0
  25. package/dist/utils/credentials.js.map +1 -0
  26. package/dist/utils/models.d.ts +10 -0
  27. package/dist/utils/models.d.ts.map +1 -0
  28. package/dist/utils/models.js +56 -0
  29. package/dist/utils/models.js.map +1 -0
  30. package/dist/utils/output.d.ts +133 -0
  31. package/dist/utils/output.d.ts.map +1 -0
  32. package/dist/utils/output.js +306 -0
  33. package/dist/utils/output.js.map +1 -0
  34. package/dist/utils/tool-filter.d.ts +35 -0
  35. package/dist/utils/tool-filter.d.ts.map +1 -0
  36. package/dist/utils/tool-filter.js +94 -0
  37. package/dist/utils/tool-filter.js.map +1 -0
  38. package/package.json +64 -0
package/README.md ADDED
@@ -0,0 +1,746 @@
1
+ # @majkapp/majk-chat-cli
2
+
3
+ A powerful command-line interface for interacting with multiple LLM providers. Features interactive chat mode, tool execution, credential management, and rich command-line options.
4
+
5
+ ## Features
6
+
7
+ - 💬 **Interactive Chat Mode**: Real-time conversation with LLMs
8
+ - 🛠️ **Tool Execution**: Execute bash commands and file operations with permission controls
9
+ - 🔑 **Smart Credential Management**: Auto-detect credentials from multiple sources
10
+ - 📁 **File I/O**: Read messages from files, save conversations
11
+ - 🎨 **Rich CLI**: Colored output, progress indicators, intuitive commands
12
+ - 🔄 **Multi-Provider**: Switch between providers on the fly
13
+ - 💾 **Session Management**: Persistent conversation storage and continuation
14
+ - 📂 **Directory-based Organization**: Sessions organized by working directory
15
+ - 🎯 **Privacy-First**: Optional session tracking with explicit user control
16
+ - ⚙️ **Configurable**: YAML/JSON configuration files
17
+
18
+ ## Installation
19
+
20
+ ### Global Installation via npm
21
+
22
+ Install globally to use the `majk-chat` command anywhere:
23
+
24
+ ```bash
25
+ npm install -g @majkapp/majk-chat-cli
26
+ ```
27
+
28
+ After installation, you can use `majk-chat` from any directory:
29
+
30
+ ```bash
31
+ majk-chat --help
32
+ majk-chat chat -M "Hello!" --provider openai
33
+ ```
34
+
35
+ ### Local Development Installation
36
+
37
+ ```bash
38
+ npm install -g @majkapp/majk-chat-cli
39
+ ```
40
+
41
+ ### Local Installation
42
+
43
+ ```bash
44
+ npm install @majkapp/majk-chat-cli
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ > **Note**: All examples below use the `majk-chat` command, which is available globally after installing with `npm install -g @majkapp/majk-chat-cli`
50
+
51
+ ### Basic Chat
52
+
53
+ ```bash
54
+ # Send a simple message
55
+ majk-chat chat -M "Hello, how are you?"
56
+
57
+ # Use a specific provider
58
+ majk-chat chat -p anthropic -M "Explain quantum computing"
59
+
60
+ # Use a specific model
61
+ majk-chat chat -m gpt-4 -M "Write a haiku"
62
+ ```
63
+
64
+ ### Interactive Mode
65
+
66
+ ```bash
67
+ # Start interactive chat
68
+ majk-chat interactive
69
+
70
+ # With specific provider and model
71
+ majk-chat interactive -p openai -m gpt-4
72
+
73
+ # With tools enabled
74
+ majk-chat interactive --tools --auto-execute
75
+ ```
76
+
77
+ ### Session Management
78
+
79
+ ```bash
80
+ # Create a session with title
81
+ majk-chat chat --save-session --session-title "Web Development" -M "Help me build a React app"
82
+
83
+ # Continue the most recent session
84
+ majk-chat chat --continue -M "Add user authentication"
85
+
86
+ # List all sessions in current directory
87
+ majk-chat chat --list-sessions
88
+
89
+ # Continue a specific session by UUID
90
+ majk-chat chat --session 550e8400-e29b-41d4-a716-446655440000 -M "Let's add more features"
91
+
92
+ # Delete a session
93
+ majk-chat chat --delete-session 550e8400-e29b-41d4-a716-446655440000
94
+ ```
95
+
96
+ ## Commands
97
+
98
+ ### `chat` - Send a single message
99
+
100
+ ```bash
101
+ majk-chat chat [options]
102
+ ```
103
+
104
+ #### Options
105
+
106
+ - `-p, --provider <provider>` - Provider to use (openai, anthropic, azure-openai, bedrock)
107
+ - `-m, --model <model>` - Model to use
108
+ - `-M, --message <message>` - Message to send
109
+ - `-f, --file <file>` - Read message from file
110
+ - `-s, --system <system>` - System message
111
+ - `-S, --system-file <file>` - Read system message from file
112
+ - `-t, --temperature <temp>` - Temperature (0-2)
113
+ - `--max-tokens <tokens>` - Maximum tokens
114
+ - `-j, --json` - Output JSON response
115
+ - `--tools` - Enable tool execution
116
+ - `--enable-core-tools` - Enable majk-chat-basic-tools (bash, ls, read, etc.)
117
+ - `--tool-result-limit <limit>` - Truncate tool results over this character limit (default: 8000)
118
+ - `--max-steps <steps>` - Maximum tool execution steps
119
+ - `-c, --config <file>` - Configuration file
120
+ - `--api-key <key>` - API key (overrides environment)
121
+ - `--api-key-file <file>` - Read API key from file
122
+
123
+ #### Session Management Options
124
+
125
+ - `--save-session` - Save conversation to a persistent session
126
+ - `--continue` - Continue the most recent session in current directory
127
+ - `--session <uuid>` - Continue a specific session by UUID
128
+ - `--session-title <title>` - Set title for new session
129
+ - `--list-sessions` - List all sessions for current directory
130
+ - `--delete-session <uuid>` - Delete a specific session by UUID
131
+
132
+ #### Examples
133
+
134
+ ```bash
135
+ # Simple message
136
+ majk-chat chat -M "What is the capital of France?"
137
+
138
+ # With system message
139
+ majk-chat chat -s "You are a helpful assistant" -M "Hello"
140
+
141
+ # Read from file
142
+ majk-chat chat -f prompt.txt
143
+
144
+ # With specific model and temperature
145
+ majk-chat chat -m gpt-4 -t 0.7 -M "Write a creative story"
146
+
147
+ # Enable tools
148
+ majk-chat chat --tools -M "Create a file called test.txt with 'Hello World' in it"
149
+
150
+ # JSON output
151
+ majk-chat chat -j -M "Hello" > response.json
152
+
153
+ # Create a session
154
+ majk-chat chat --save-session --session-title "Code Review" -M "Review this Python function"
155
+
156
+ # Continue a session
157
+ majk-chat chat --continue -M "Fix the performance issues"
158
+
159
+ # List sessions
160
+ majk-chat chat --list-sessions
161
+
162
+ # Load specific session
163
+ majk-chat chat --session 550e8400-e29b-41d4-a716-446655440000 -M "Continue our discussion"
164
+ ```
165
+
166
+ ### `interactive` - Interactive chat mode
167
+
168
+ ```bash
169
+ majk-chat interactive [options]
170
+ ```
171
+
172
+ #### Options
173
+
174
+ - `-p, --provider <provider>` - Provider to use
175
+ - `-m, --model <model>` - Model to use
176
+ - `-s, --system <system>` - System message
177
+ - `-S, --system-file <file>` - Read system message from file
178
+ - `--tools` - Enable tool execution
179
+ - `--enable-core-tools` - Enable majk-chat-basic-tools (bash, ls, read, etc.)
180
+ - `--tool-result-limit <limit>` - Truncate tool results over this character limit (default: 8000)
181
+ - `--auto-execute` - Auto-execute tools without confirmation
182
+ - `-c, --config <file>` - Configuration file
183
+
184
+ #### Interactive Commands
185
+
186
+ Once in interactive mode, you can use these commands:
187
+
188
+ - `/help` - Show help message
189
+ - `/exit`, `/quit` - Exit interactive mode
190
+ - `/clear` - Clear conversation history
191
+ - `/history` - Show conversation history
192
+ - `/save <file>` - Save conversation to file
193
+ - `/load <file>` - Load conversation from file
194
+ - `/model <name>` - Set or show current model
195
+ - `/provider <name>` - Set or show current provider
196
+ - `/system <msg>` - Set or show system message
197
+ - `/tools` - Toggle tool execution
198
+ - `/auto` - Toggle auto-execute for tools
199
+ - `/multiline` - Enter multiline input (end with 'END')
200
+
201
+ #### Examples
202
+
203
+ ```bash
204
+ # Start interactive mode
205
+ majk-chat interactive
206
+
207
+ # With specific configuration
208
+ majk-chat interactive -p anthropic -m claude-3-sonnet
209
+
210
+ # With tools enabled
211
+ majk-chat interactive --tools
212
+
213
+ You> /help
214
+ [Shows available commands]
215
+
216
+ You> Hello, how are you?
217
+ Assistant: I'm doing well, thank you! How can I help you today?
218
+
219
+ You> /model gpt-4
220
+ ✓ Model set to: gpt-4
221
+
222
+ You> /save conversation.json
223
+ ✓ Conversation saved to conversation.json
224
+
225
+ You> /multiline
226
+ Enter multiline input. Type END on a new line to finish:
227
+ ... This is a
228
+ ... multiline
229
+ ... message
230
+ ... END
231
+
232
+ You> /exit
233
+ Goodbye! 👋
234
+ ```
235
+
236
+ ### `models` - List available models
237
+
238
+ ```bash
239
+ majk-chat models [options]
240
+ ```
241
+
242
+ #### Options
243
+
244
+ - `-p, --provider <provider>` - Filter by provider
245
+ - `-c, --config <file>` - Configuration file
246
+
247
+ #### Examples
248
+
249
+ ```bash
250
+ # List all models
251
+ majk-chat models
252
+
253
+ # List models for specific provider
254
+ majk-chat models -p openai
255
+ ```
256
+
257
+ ### `config` - Configure providers and credentials
258
+
259
+ ```bash
260
+ majk-chat config [options]
261
+ ```
262
+
263
+ #### Options
264
+
265
+ - `--init` - Initialize configuration
266
+ - `--set <key=value>` - Set configuration value
267
+ - `--get <key>` - Get configuration value
268
+ - `--list` - List configuration
269
+
270
+ #### Examples
271
+
272
+ ```bash
273
+ # Initialize configuration
274
+ majk-chat config --init
275
+
276
+ # Set a value
277
+ majk-chat config --set providers.openai.apiKey=sk-...
278
+
279
+ # Get a value
280
+ majk-chat config --get providers.openai.apiKey
281
+
282
+ # List all configuration
283
+ majk-chat config --list
284
+ ```
285
+
286
+ ## Core Tools Usage
287
+
288
+ The `--enable-core-tools` flag provides access to a comprehensive set of tools for file system operations, process management, and utility functions:
289
+
290
+ ### Available Core Tools
291
+
292
+ - **bash**: Execute bash commands with optional background execution
293
+ - **kill_bash**: Terminate background bash processes
294
+ - **bash_output**: Monitor and retrieve output from background processes
295
+ - **ls**: List files and directories with filtering
296
+ - **read**: Read file contents with configurable limits and offsets
297
+ - **glob**: Fast file pattern matching using glob patterns
298
+ - **grep**: Search for text patterns in files using regular expressions
299
+ - **edit**: Perform exact string replacements in files
300
+ - **multi_edit**: Make multiple edits to a single file atomically
301
+ - **write**: Write content to files with encoding support
302
+ - **web_fetch**: Fetch content from URLs using HTTP/HTTPS
303
+ - **todo_write**: Manage structured task lists for session tracking
304
+ - **read_tool_result**: Read back large tool results that were truncated
305
+
306
+ ### Basic Usage
307
+
308
+ ```bash
309
+ # Enable core tools with basic usage
310
+ majk-chat chat -M "List all JavaScript files in the src directory" --enable-core-tools
311
+
312
+ # Enable with custom result limit (default: 8000 chars)
313
+ majk-chat chat -M "Show me the contents of package.json" --enable-core-tools --tool-result-limit 4000
314
+
315
+ # Filter specific tools (only allow file operations)
316
+ majk-chat chat -M "Read and analyze config files" --enable-core-tools --allowed-tools "ls,read,glob,grep"
317
+
318
+ # Exclude potentially dangerous tools
319
+ majk-chat chat -M "Analyze the codebase" --enable-core-tools --disallowed-tools "bash,kill_bash,web_fetch"
320
+ ```
321
+
322
+ ### Interactive Mode with Core Tools
323
+
324
+ ```bash
325
+ # Start interactive session with core tools
326
+ majk-chat interactive --enable-core-tools
327
+
328
+ # Example conversation:
329
+ User: Find all TypeScript files and show me the first 50 lines of the main entry point
330
+
331
+ # The LLM will use tools like:
332
+ # 1. glob --pattern "**/*.ts"
333
+ # 2. read --file-path "./src/index.ts" --limit 2000
334
+ ```
335
+
336
+ ### Background Process Management
337
+
338
+ ```bash
339
+ # Start a long-running task
340
+ majk-chat chat -M "Start a development server in the background and monitor its output" --enable-core-tools
341
+
342
+ # The LLM can use:
343
+ # 1. bash --command "npm run dev" --run-in-background
344
+ # 2. bash_output --process-id "bg_xxx" --list-all
345
+ # 3. kill_bash --process-id "bg_xxx" (if needed)
346
+ ```
347
+
348
+ ### Tool Result Management
349
+
350
+ When tool results exceed the `--tool-result-limit` (default: 8000 characters):
351
+
352
+ 1. **Automatic Truncation**: Large results are automatically truncated with preview + tail
353
+ 2. **Auto-Registration**: `read_tool_result` tool is automatically registered on first truncation
354
+ 3. **Full Access**: Complete results remain accessible through unique IDs
355
+
356
+ ```bash
357
+ # Example with large output
358
+ majk-chat chat -M "Find all log files and show their contents" --enable-core-tools --tool-result-limit 2000
359
+
360
+ # Output will show:
361
+ # "Result truncated (25000 chars). Use read_tool_result with ID: conv_1234567890_abcdef"
362
+
363
+ # The LLM can then use:
364
+ # read_tool_result --result-id "conv_1234567890_abcdef" --offset 0 --limit 5000
365
+ ```
366
+
367
+ ### Tool Filtering Examples
368
+
369
+ ```bash
370
+ # Only filesystem operations
371
+ --allowed-tools "ls,read,write,glob,grep,edit"
372
+
373
+ # Everything except web access
374
+ --disallowed-tools "web_fetch"
375
+
376
+ # Wildcard patterns (bash tools only)
377
+ --allowed-tools "bash*"
378
+
379
+ # Multiple patterns
380
+ --allowed-tools "ls,read,bash*" --disallowed-tools "*kill*"
381
+ ```
382
+
383
+ ### Configuration File Integration
384
+
385
+ Add core tools to your configuration file:
386
+
387
+ ```yaml
388
+ # ~/.majk-chat/config.yaml
389
+ tools:
390
+ enableCoreTools: true
391
+ toolResultLimit: 10000
392
+ allowedTools: ["ls", "read", "glob", "grep", "edit", "write"]
393
+
394
+ defaultProvider: "anthropic"
395
+ providers:
396
+ anthropic:
397
+ apiKey: "your-key-here"
398
+ ```
399
+
400
+ ### Best Practices
401
+
402
+ 1. **Start Conservative**: Begin with limited tools and expand as needed
403
+ 2. **Use Filtering**: Always consider `--allowed-tools` for security
404
+ 3. **Monitor Resources**: Large results are automatically managed with truncation
405
+ 4. **Background Tasks**: Use background execution for long-running operations
406
+ 5. **Result Management**: Let the system auto-register `read_tool_result` when needed
407
+
408
+ ### Security Considerations
409
+
410
+ - Core tools have full filesystem access when enabled
411
+ - `bash` tool can execute any system command
412
+ - Use `--allowed-tools` to restrict capabilities
413
+ - Consider running in isolated environments for untrusted operations
414
+ - Tool results are stored in memory and cleaned up automatically
415
+
416
+ ## Session Management
417
+
418
+ The CLI includes comprehensive session management for persistent conversations. Sessions allow you to save, continue, and organize your chat conversations across CLI invocations.
419
+
420
+ ### Key Features
421
+
422
+ - **Privacy-First**: Sessions are only saved when explicitly requested with `--save-session`
423
+ - **Directory Organization**: Sessions are automatically organized by working directory
424
+ - **UUID-based**: Each session has a unique identifier for easy reference
425
+ - **Auto-cleanup**: Old sessions are automatically cleaned up based on age and count limits
426
+ - **Smart Titles**: Automatic title generation from first user message
427
+
428
+ ### Session Storage
429
+
430
+ Sessions are stored in `~/.majk/chat-sessions/` organized by working directory:
431
+
432
+ ```
433
+ ~/.majk/chat-sessions/
434
+ ├── users_jules_projects_webapp/
435
+ │ ├── 550e8400-e29b-41d4-a716-446655440000.json
436
+ │ └── 6ba7b810-9dad-11d1-80b4-00c04fd430c8.json
437
+ └── users_jules_documents/
438
+ └── f47ac10b-58cc-4372-a567-0e02b2c3d479.json
439
+ ```
440
+
441
+ ### Session Commands
442
+
443
+ #### Creating Sessions
444
+
445
+ ```bash
446
+ # Create session with auto-generated title
447
+ majk-chat chat --save-session -M "Help me build a React app"
448
+
449
+ # Create session with custom title
450
+ majk-chat chat --save-session --session-title "React Tutorial" -M "Getting started with React"
451
+ ```
452
+
453
+ #### Continuing Sessions
454
+
455
+ ```bash
456
+ # Continue most recent session in current directory
457
+ majk-chat chat --continue -M "Add user authentication"
458
+
459
+ # Continue specific session by UUID
460
+ majk-chat chat --session 550e8400-e29b-41d4-a716-446655440000 -M "Let's add more features"
461
+ ```
462
+
463
+ #### Managing Sessions
464
+
465
+ ```bash
466
+ # List all sessions in current directory
467
+ majk-chat chat --list-sessions
468
+
469
+ # Sample output:
470
+ # Sessions in current directory:
471
+ # 550e8400-e29b-41d4-a716-446655440000
472
+ # Title: React Tutorial
473
+ # Created: 12/1/2023 10:30:00 AM
474
+ # Updated: 12/1/2023 11:45:00 AM
475
+ # Messages: 8
476
+ # Last: Let's add error handling to the authentication
477
+
478
+ # Delete a session
479
+ majk-chat chat --delete-session 550e8400-e29b-41d4-a716-446655440000
480
+ ```
481
+
482
+ ### Session Workflow Examples
483
+
484
+ #### Project Development Session
485
+
486
+ ```bash
487
+ # Start a new project session
488
+ cd ~/projects/my-app
489
+ majk-chat chat --save-session --session-title "My App Development" -M "Help me design a REST API"
490
+
491
+ # Continue working on it later
492
+ cd ~/projects/my-app
493
+ majk-chat chat --continue -M "Add database integration"
494
+
495
+ # Work on it from another day
496
+ cd ~/projects/my-app
497
+ majk-chat chat --continue -M "How do I deploy this API?"
498
+ ```
499
+
500
+ #### Learning Session
501
+
502
+ ```bash
503
+ # Learning session
504
+ majk-chat chat --save-session --session-title "Learning Python" -M "Explain Python decorators"
505
+
506
+ # Continue learning
507
+ majk-chat chat --continue -M "Show me practical examples of decorators"
508
+ ```
509
+
510
+ ### Session Data Format
511
+
512
+ Each session file contains:
513
+
514
+ ```json
515
+ {
516
+ "metadata": {
517
+ "id": "550e8400-e29b-41d4-a716-446655440000",
518
+ "workingDirectory": "/Users/jules/projects/myapp",
519
+ "createdAt": "2024-01-15T10:30:00.000Z",
520
+ "updatedAt": "2024-01-15T11:45:00.000Z",
521
+ "title": "React Tutorial",
522
+ "provider": "anthropic",
523
+ "model": "claude-3-sonnet-20240229",
524
+ "totalMessages": 8
525
+ },
526
+ "messages": [
527
+ {
528
+ "role": "user",
529
+ "content": "Help me build a React app"
530
+ },
531
+ {
532
+ "role": "assistant",
533
+ "content": "I'll help you build a React app...",
534
+ "tool_calls": [...]
535
+ }
536
+ ]
537
+ }
538
+ ```
539
+
540
+ ### Privacy and Control
541
+
542
+ - **No tracking by default**: Conversations are not saved unless `--save-session` is used
543
+ - **User explicit consent**: Sessions are only created when explicitly requested
544
+ - **Local storage only**: All session data stays on your machine
545
+ - **Easy cleanup**: Sessions can be deleted individually or cleaned up automatically
546
+ ## Configuration
547
+
548
+ ### Configuration File
549
+
550
+ Create a configuration file at `~/.majk-chat/config.yaml`:
551
+
552
+ ```yaml
553
+ providers:
554
+ openai:
555
+ apiKey: ${OPENAI_API_KEY}
556
+ organizationId: ${OPENAI_ORG_ID}
557
+ anthropic:
558
+ apiKey: ${ANTHROPIC_API_KEY}
559
+ azure-openai:
560
+ apiKey: ${AZURE_OPENAI_API_KEY}
561
+ endpoint: ${AZURE_OPENAI_ENDPOINT}
562
+ deploymentName: ${AZURE_OPENAI_DEPLOYMENT}
563
+ bedrock:
564
+ region: ${AWS_REGION}
565
+ accessKeyId: ${AWS_ACCESS_KEY_ID}
566
+ secretAccessKey: ${AWS_SECRET_ACCESS_KEY}
567
+
568
+ defaultProvider: openai
569
+
570
+ tools:
571
+ autoExecute: false
572
+ maxSteps: 5
573
+ ```
574
+
575
+ You can also use JSON format:
576
+
577
+ ```json
578
+ {
579
+ "providers": {
580
+ "openai": {
581
+ "apiKey": "${OPENAI_API_KEY}"
582
+ }
583
+ },
584
+ "defaultProvider": "openai"
585
+ }
586
+ ```
587
+
588
+ ### Credential Sources
589
+
590
+ The CLI looks for credentials in the following order:
591
+
592
+ 1. **Command-line options** (`--api-key`, `--api-key-file`)
593
+ 2. **Environment variables**:
594
+ - OpenAI: `OPENAI_API_KEY`, `OPENAI_ORG_ID`
595
+ - Anthropic: `ANTHROPIC_API_KEY`
596
+ - Azure: `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`
597
+ - AWS: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`
598
+ 3. **Standard provider locations**:
599
+ - `~/.openai/api_key`
600
+ - `~/.anthropic/api_key`
601
+ - `~/.config/openai/api_key`
602
+ - `~/.config/anthropic/api_key`
603
+ 4. **Configuration file** (`~/.majk-chat/config.yaml`)
604
+
605
+ ## Tool Support
606
+
607
+ ### Bash Tool
608
+
609
+ Execute bash commands with permission controls:
610
+
611
+ ```bash
612
+ # In interactive mode with tools enabled
613
+ You> Can you list the files in the current directory?
614
+
615
+ ⚠️ Tool execution request:
616
+ Tool: bash
617
+ Command: ls -la
618
+ Do you want to execute this command? (y/n) y
619
+
620
+ Executing: ls -la
621
+ [Output shows files]
622
+ ```
623
+
624
+ ### File System Tool
625
+
626
+ Perform file operations:
627
+
628
+ ```bash
629
+ You> Create a file called hello.txt with "Hello World" in it
630
+
631
+ ⚠️ File system operation request:
632
+ Operation: write
633
+ Path: hello.txt
634
+ Content: Hello World
635
+ Do you want to write this file/directory? (y/n) y
636
+ ```
637
+
638
+ ### Auto-execution
639
+
640
+ Enable auto-execution to skip confirmation prompts:
641
+
642
+ ```bash
643
+ majk-chat interactive --tools --auto-execute
644
+ ```
645
+
646
+ ## Advanced Usage
647
+
648
+ ### Piping and Redirection
649
+
650
+ ```bash
651
+ # Pipe input
652
+ echo "Explain Docker" | majk-chat chat
653
+
654
+ # Read from file, output to file
655
+ majk-chat chat -f prompt.txt > response.txt
656
+
657
+ # Use with other tools
658
+ cat code.js | majk-chat chat -M "Review this code"
659
+ ```
660
+
661
+ ### Scripting
662
+
663
+ ```bash
664
+ #!/bin/bash
665
+
666
+ # Use in scripts
667
+ response=$(majk-chat chat -M "Generate a random number between 1 and 100" -j)
668
+ echo $response | jq '.choices[0].message.content'
669
+ ```
670
+
671
+ ### Multiple Providers
672
+
673
+ ```bash
674
+ # Compare responses from different providers
675
+ for provider in openai anthropic; do
676
+ echo "Provider: $provider"
677
+ majk-chat chat -p $provider -M "What is love?"
678
+ echo "---"
679
+ done
680
+ ```
681
+
682
+ ## Environment Variables
683
+
684
+ - `OPENAI_API_KEY` - OpenAI API key
685
+ - `ANTHROPIC_API_KEY` - Anthropic API key
686
+ - `AZURE_OPENAI_API_KEY` - Azure OpenAI API key
687
+ - `AZURE_OPENAI_ENDPOINT` - Azure OpenAI endpoint
688
+ - `AZURE_OPENAI_DEPLOYMENT` - Azure OpenAI deployment name
689
+ - `AWS_ACCESS_KEY_ID` - AWS access key
690
+ - `AWS_SECRET_ACCESS_KEY` - AWS secret key
691
+ - `AWS_REGION` - AWS region
692
+ - `NO_COLOR` - Disable colored output
693
+
694
+ ## Troubleshooting
695
+
696
+ ### No API Key Found
697
+
698
+ ```bash
699
+ Error: No API key found for provider
700
+
701
+ Solution:
702
+ 1. Set environment variable: export OPENAI_API_KEY=sk-...
703
+ 2. Use --api-key flag: majk-chat chat --api-key sk-...
704
+ 3. Create config file: majk-chat config --init
705
+ ```
706
+
707
+ ### Rate Limiting
708
+
709
+ ```bash
710
+ Error: Rate limit exceeded
711
+
712
+ Solution:
713
+ 1. Wait and retry
714
+ 2. Use a different provider
715
+ 3. Reduce request frequency
716
+ ```
717
+
718
+ ### Tool Execution Denied
719
+
720
+ ```bash
721
+ Error: Permission denied for tool
722
+
723
+ Solution:
724
+ 1. Review the command carefully
725
+ 2. Use --auto-execute with caution
726
+ 3. Ensure you trust the LLM's tool usage
727
+ ```
728
+
729
+ ## Security
730
+
731
+ - **Credentials**: Never commit API keys to version control
732
+ - **Tool Execution**: Always review commands before execution
733
+ - **File Operations**: Be cautious with write/delete operations
734
+ - **Auto-execution**: Only use in trusted environments
735
+
736
+ ## License
737
+
738
+ MIT
739
+
740
+ ## Contributing
741
+
742
+ Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
743
+
744
+ ## Support
745
+
746
+ For issues, questions, or suggestions, please file an issue on our GitHub repository.