@majkapp/majk-chat-cli 1.0.3 → 1.0.5

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 (2) hide show
  1. package/README.md +451 -93
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -51,36 +51,50 @@ npm install @majkapp/majk-chat-cli
51
51
  ### Basic Chat
52
52
 
53
53
  ```bash
54
- # Send a simple message
54
+ # Send a simple message (uses default profile)
55
55
  majk-chat chat -M "Hello, how are you?"
56
56
 
57
- # Use a specific provider
58
- majk-chat chat -p anthropic -M "Explain quantum computing"
57
+ # Use a specific provider with work profile
58
+ majk-chat chat -p anthropic --profile work -M "Explain quantum computing"
59
59
 
60
- # Use a specific model
61
- majk-chat chat -m gpt-4 -M "Write a haiku"
60
+ # Use a specific model with personal profile
61
+ majk-chat chat -m gpt-4 --profile personal -M "Write a haiku"
62
+ ```
63
+
64
+ ### Profile Setup (First Time)
65
+
66
+ ```bash
67
+ # Set up your API keys with profiles
68
+ majk-chat set-key --openai sk-your-openai-key --profile default
69
+ majk-chat set-key --anthropic sk-ant-your-anthropic-key --profile work
70
+
71
+ # Test your setup
72
+ majk-chat test-all-profiles
73
+
74
+ # Start chatting
75
+ majk-chat chat --profile work -M "Hello, I'm using my work profile!"
62
76
  ```
63
77
 
64
78
  ### Interactive Mode
65
79
 
66
80
  ```bash
67
- # Start interactive chat
81
+ # Start interactive chat with default profile
68
82
  majk-chat interactive
69
83
 
70
- # With specific provider and model
71
- majk-chat interactive -p openai -m gpt-4
84
+ # With specific profile and provider
85
+ majk-chat interactive --profile work -p anthropic -m claude-3-sonnet
72
86
 
73
- # With tools enabled
74
- majk-chat interactive --tools --auto-execute
87
+ # With tools enabled using production profile
88
+ majk-chat interactive --tools --auto-execute --profile production
75
89
  ```
76
90
 
77
91
  ### Session Management
78
92
 
79
93
  ```bash
80
- # Create a session with title
81
- majk-chat chat --save-session --session-title "Web Development" -M "Help me build a React app"
94
+ # Create a session with title and profile
95
+ majk-chat chat --save-session --session-title "Web Development" --profile work -M "Help me build a React app"
82
96
 
83
- # Continue the most recent session
97
+ # Continue the most recent session (inherits profile)
84
98
  majk-chat chat --continue -M "Add user authentication"
85
99
 
86
100
  # List all sessions in current directory
@@ -117,8 +131,10 @@ majk-chat chat [options]
117
131
  - `--tool-result-limit <limit>` - Truncate tool results over this character limit (default: 8000)
118
132
  - `--max-steps <steps>` - Maximum tool execution steps
119
133
  - `-c, --config <file>` - Configuration file
134
+ - `--profile <name>` - Use specific profile for credentials (default: "default")
120
135
  - `--api-key <key>` - API key (overrides environment)
121
136
  - `--api-key-file <file>` - Read API key from file
137
+ - `--bedrock-api-key <key>` - AWS Bedrock API key (bearer token)
122
138
 
123
139
  #### Session Management Options
124
140
 
@@ -132,28 +148,38 @@ majk-chat chat [options]
132
148
  #### Examples
133
149
 
134
150
  ```bash
135
- # Simple message
151
+ # Simple message with default profile
136
152
  majk-chat chat -M "What is the capital of France?"
137
153
 
138
- # With system message
139
- majk-chat chat -s "You are a helpful assistant" -M "Hello"
154
+ # Use specific profile
155
+ majk-chat chat --profile work -M "Hello from work environment"
156
+
157
+ # With system message and profile
158
+ majk-chat chat -s "You are a helpful assistant" --profile personal -M "Hello"
140
159
 
141
- # Read from file
142
- majk-chat chat -f prompt.txt
160
+ # Read from file with specific profile
161
+ majk-chat chat -f prompt.txt --profile production
143
162
 
144
- # With specific model and temperature
145
- majk-chat chat -m gpt-4 -t 0.7 -M "Write a creative story"
163
+ # With specific model and temperature using work profile
164
+ majk-chat chat -m claude-3-sonnet -t 0.7 --profile work -M "Write a creative story"
146
165
 
147
- # Enable tools
148
- majk-chat chat --tools -M "Create a file called test.txt with 'Hello World' in it"
166
+ # Enable tools with profile
167
+ majk-chat chat --tools --profile default -M "Create a file called test.txt with 'Hello World' in it"
149
168
 
150
- # JSON output
151
- majk-chat chat -j -M "Hello" > response.json
169
+ # JSON output with profile
170
+ majk-chat chat -j --profile work -M "Hello" > response.json
152
171
 
153
- # Create a session
154
- majk-chat chat --save-session --session-title "Code Review" -M "Review this Python function"
172
+ # Use Bedrock with API key (bearer token)
173
+ majk-chat chat --provider bedrock --bedrock-api-key "bedrock-api-key-..." -M "Hello"
155
174
 
156
- # Continue a session
175
+ # Use Bedrock with environment variable
176
+ export AWS_BEARER_TOKEN_BEDROCK="bedrock-api-key-..."
177
+ majk-chat chat --provider bedrock -M "Explain quantum computing"
178
+
179
+ # Create a session with profile
180
+ majk-chat chat --save-session --session-title "Code Review" --profile work -M "Review this Python function"
181
+
182
+ # Continue a session (inherits profile from saved session)
157
183
  majk-chat chat --continue -M "Fix the performance issues"
158
184
 
159
185
  # List sessions
@@ -180,6 +206,7 @@ majk-chat interactive [options]
180
206
  - `--tool-result-limit <limit>` - Truncate tool results over this character limit (default: 8000)
181
207
  - `--auto-execute` - Auto-execute tools without confirmation
182
208
  - `-c, --config <file>` - Configuration file
209
+ - `--profile <name>` - Use specific profile for credentials (default: "default")
183
210
 
184
211
  #### Interactive Commands
185
212
 
@@ -201,14 +228,14 @@ Once in interactive mode, you can use these commands:
201
228
  #### Examples
202
229
 
203
230
  ```bash
204
- # Start interactive mode
231
+ # Start interactive mode with default profile
205
232
  majk-chat interactive
206
233
 
207
- # With specific configuration
208
- majk-chat interactive -p anthropic -m claude-3-sonnet
234
+ # With specific profile and provider
235
+ majk-chat interactive --profile work -p anthropic -m claude-3-sonnet
209
236
 
210
- # With tools enabled
211
- majk-chat interactive --tools
237
+ # With tools and specific profile
238
+ majk-chat interactive --tools --profile production
212
239
 
213
240
  You> /help
214
241
  [Shows available commands]
@@ -243,15 +270,19 @@ majk-chat models [options]
243
270
 
244
271
  - `-p, --provider <provider>` - Filter by provider
245
272
  - `-c, --config <file>` - Configuration file
273
+ - `--profile <name>` - Use specific profile for credentials
246
274
 
247
275
  #### Examples
248
276
 
249
277
  ```bash
250
- # List all models
278
+ # List all models using default profile
251
279
  majk-chat models
252
280
 
253
- # List models for specific provider
254
- majk-chat models -p openai
281
+ # List models for specific provider using work profile
282
+ majk-chat models -p anthropic --profile work
283
+
284
+ # List models for specific profile
285
+ majk-chat models --profile production
255
286
  ```
256
287
 
257
288
  ### `config` - Configure providers and credentials
@@ -283,6 +314,120 @@ majk-chat config --get providers.openai.apiKey
283
314
  majk-chat config --list
284
315
  ```
285
316
 
317
+ ### Profile Configuration Commands
318
+
319
+ #### `configure-provider` - Interactive provider setup
320
+
321
+ ```bash
322
+ majk-chat configure-provider <provider> [options]
323
+ ```
324
+
325
+ **Arguments:**
326
+ - `<provider>` - Provider to configure (openai, anthropic, azure-openai, bedrock)
327
+
328
+ **Options:**
329
+ - `--profile <name>` - Profile name (default: "default")
330
+ - `--skip-validation` - Skip API key validation
331
+
332
+ **Examples:**
333
+ ```bash
334
+ # Interactive OpenAI setup with validation
335
+ majk-chat configure-provider openai
336
+
337
+ # Set up Anthropic for work profile
338
+ majk-chat configure-provider anthropic --profile work
339
+
340
+ # Set up Azure OpenAI without validation
341
+ majk-chat configure-provider azure-openai --profile production --skip-validation
342
+ ```
343
+
344
+ #### `set-key` - Direct credential configuration
345
+
346
+ ```bash
347
+ majk-chat set-key [options]
348
+ ```
349
+
350
+ **Options:**
351
+ - `--openai <key>` - OpenAI API key
352
+ - `--anthropic <key>` - Anthropic API key
353
+ - `--azure-openai <key> <endpoint> <deployment>` - Azure OpenAI credentials
354
+ - `--bedrock <accessKey> <secretKey> [region]` - AWS Bedrock traditional credentials
355
+ - `--profile <name>` - Profile to store configuration in (default: "default")
356
+ - `--skip-validation` - Skip API key validation
357
+
358
+ **Examples:**
359
+ ```bash
360
+ # Set OpenAI key for default profile
361
+ majk-chat set-key --openai sk-your-key
362
+
363
+ # Set Anthropic key for work profile
364
+ majk-chat set-key --anthropic sk-ant-key --profile work
365
+
366
+ # Set Azure OpenAI (all parameters required)
367
+ majk-chat set-key --azure-openai key https://endpoint.com deployment --profile prod
368
+
369
+ # Set Bedrock with region
370
+ majk-chat set-key --bedrock access-key secret-key us-west-2 --profile aws
371
+ ```
372
+
373
+ #### `list-profiles` - Show configured profiles
374
+
375
+ ```bash
376
+ majk-chat list-profiles
377
+ ```
378
+
379
+ **Example output:**
380
+ ```
381
+ Configured profiles:
382
+ default (openai, anthropic)
383
+ work (anthropic, azure-openai)
384
+ aws-prod (bedrock)
385
+ ```
386
+
387
+ #### `delete-profile` - Remove a profile
388
+
389
+ ```bash
390
+ majk-chat delete-profile <name>
391
+ ```
392
+
393
+ **Examples:**
394
+ ```bash
395
+ majk-chat delete-profile old-work-profile
396
+ ```
397
+
398
+ #### Profile Testing Commands
399
+
400
+ ##### `test-profile` - Test all providers in a profile
401
+ ```bash
402
+ majk-chat test-profile <name>
403
+ ```
404
+
405
+ ##### `test-all-profiles` - Test all profiles
406
+ ```bash
407
+ majk-chat test-all-profiles
408
+ ```
409
+
410
+ ##### `test-provider` - Test specific provider in profile
411
+ ```bash
412
+ majk-chat test-provider <provider> [--profile <name>]
413
+ ```
414
+
415
+ **Examples:**
416
+ ```bash
417
+ # Test work profile
418
+ majk-chat test-profile work
419
+ # Output:
420
+ # Testing profile: work
421
+ # ✓ anthropic (model: claude-3-5-sonnet-20241022)
422
+ # ✗ azure-openai - Invalid endpoint
423
+
424
+ # Test all profiles
425
+ majk-chat test-all-profiles
426
+
427
+ # Test specific provider
428
+ majk-chat test-provider openai --profile default
429
+ ```
430
+
286
431
  ## Core Tools Usage
287
432
 
288
433
  The `--enable-core-tools` flag provides access to a comprehensive set of tools for file system operations, process management, and utility functions:
@@ -306,25 +451,112 @@ The `--enable-core-tools` flag provides access to a comprehensive set of tools f
306
451
  ### Basic Usage
307
452
 
308
453
  ```bash
309
- # Enable core tools with basic usage
454
+ # Enable core tools with basic usage (uses default profile)
310
455
  majk-chat chat -M "List all JavaScript files in the src directory" --enable-core-tools
311
456
 
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
457
+ # Enable with custom result limit using work profile
458
+ majk-chat chat -M "Show me the contents of package.json" --enable-core-tools --tool-result-limit 4000 --profile work
459
+
460
+ # Filter specific tools (only allow file operations) with production profile
461
+ majk-chat chat -M "Read and analyze config files" --enable-core-tools --allowed-tools "ls,read,glob,grep" --profile production
462
+
463
+ # Exclude potentially dangerous tools using personal profile
464
+ majk-chat chat -M "Analyze the codebase" --enable-core-tools --disallowed-tools "bash,kill_bash,web_fetch" --profile personal
465
+ ```
466
+
467
+ ### 🔍 Dry Run Mode
468
+
469
+ Preview and approve tool operations before execution for safe testing and verification:
470
+
471
+ ```bash
472
+ # Preview mode - see what would happen without executing
473
+ majk-chat chat --dry-run --enable-core-tools -M "Refactor this codebase and add tests"
474
+
475
+ # Interactive review mode - approve/reject each operation
476
+ majk-chat chat --dry-run-review --enable-core-tools -M "Set up a new React project"
477
+ ```
478
+
479
+ #### How Dry Run Works
480
+
481
+ 1. **Planning Phase**: All tool operations are captured and analyzed instead of executed
482
+ 2. **Risk Assessment**: Each operation is classified as low/medium/high risk
483
+ 3. **Preview Generation**: Shows file diffs, command effects, and safety warnings
484
+ 4. **User Review**: Interactive approval/rejection of individual operations
485
+ 5. **Selective Execution**: Only approved operations are actually executed
314
486
 
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"
487
+ #### Dry Run Examples
317
488
 
318
- # Exclude potentially dangerous tools
319
- majk-chat chat -M "Analyze the codebase" --enable-core-tools --disallowed-tools "bash,kill_bash,web_fetch"
489
+ ```bash
490
+ # Basic dry run - shows planned operations
491
+ majk-chat chat --dry-run --enable-core-tools -M "Write a hello world script and run it"
492
+
493
+ # Output:
494
+ # 🔍 Dry run mode enabled
495
+ # 📋 Planned 2 operations:
496
+ # 1. [LOW] Write to file: hello.py (67 characters)
497
+ # 2. [MEDIUM] Execute bash command: python hello.py
498
+ #
499
+ # Use --dry-run-review to interactively review and execute operations.
500
+
501
+ # Interactive review mode
502
+ majk-chat chat --dry-run-review --enable-core-tools -M "Update package.json and install dependencies"
503
+
504
+ # Interactive flow:
505
+ # 🔍 Reviewing 2 planned operations
506
+ #
507
+ # 📋 Operation 1/2
508
+ # ──────────────────────────────────────────────────
509
+ # Tool: edit
510
+ # Risk: LOW
511
+ # Category: filesystem
512
+ # Description: Replace first occurrence of "version": "1.0.0" with "version": "1.0.1" in package.json
513
+ #
514
+ # Preview:
515
+ # File: /path/to/package.json
516
+ # - "version": "1.0.0",
517
+ # + "version": "1.0.1",
518
+ #
519
+ # Options:
520
+ # a - Approve this operation
521
+ # r - Reject this operation
522
+ # s - Skip (decide later)
523
+ # p - Show/hide preview
524
+ # d - Show detailed arguments
525
+ # Choice (a/r/s/p/d): a
320
526
  ```
321
527
 
528
+ #### Dry Run Safety Features
529
+
530
+ - **Risk Assessment**: Automatic classification of operations
531
+ - 🟢 **Low Risk**: Simple file reads, basic edits
532
+ - 🟡 **Medium Risk**: Config files, package installs, git operations
533
+ - 🔴 **High Risk**: System files, destructive commands, sudo operations
534
+
535
+ - **Operation Previews**:
536
+ - File operations show diffs and content previews
537
+ - Bash commands show potential effects and warnings
538
+ - Network operations show URLs and request details
539
+
540
+ - **Safety Warnings**: Automatic detection of dangerous patterns
541
+ - `rm -rf` commands
542
+ - `sudo` usage
543
+ - Script downloads (`curl | bash`)
544
+ - Eval/exec operations
545
+
546
+ #### Dry Run Options
547
+
548
+ - `--dry-run` - Plan operations without executing (shows summary)
549
+ - `--dry-run-review` - Plan operations with interactive review and execution
550
+
322
551
  ### Interactive Mode with Core Tools
323
552
 
324
553
  ```bash
325
- # Start interactive session with core tools
554
+ # Start interactive session with core tools using default profile
326
555
  majk-chat interactive --enable-core-tools
327
556
 
557
+ # Start with specific profile for development work
558
+ majk-chat interactive --enable-core-tools --profile development
559
+
328
560
  # Example conversation:
329
561
  User: Find all TypeScript files and show me the first 50 lines of the main entry point
330
562
 
@@ -336,8 +568,8 @@ User: Find all TypeScript files and show me the first 50 lines of the main entry
336
568
  ### Background Process Management
337
569
 
338
570
  ```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
571
+ # Start a long-running task with development profile
572
+ majk-chat chat -M "Start a development server in the background and monitor its output" --enable-core-tools --profile development
341
573
 
342
574
  # The LLM can use:
343
575
  # 1. bash --command "npm run dev" --run-in-background
@@ -543,64 +775,163 @@ Each session file contains:
543
775
  - **User explicit consent**: Sessions are only created when explicitly requested
544
776
  - **Local storage only**: All session data stays on your machine
545
777
  - **Easy cleanup**: Sessions can be deleted individually or cleaned up automatically
546
- ## Configuration
778
+ - **Profile inheritance**: Sessions remember the profile used when created and continue using it automatically
547
779
 
548
- ### Configuration File
780
+ ## Profile Configuration (AWS-Style)
549
781
 
550
- Create a configuration file at `~/.majk-chat/config.yaml`:
782
+ The CLI now supports AWS-style profiles for managing multiple sets of credentials. This is the recommended way to manage API keys.
551
783
 
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
784
+ ### Quick Setup
569
785
 
570
- tools:
571
- autoExecute: false
572
- maxSteps: 5
786
+ ```bash
787
+ # Direct configuration (recommended for simple setups)
788
+ majk-chat set-key --openai sk-your-openai-key --profile default
789
+ majk-chat set-key --anthropic sk-ant-your-anthropic-key --profile work
790
+
791
+ # Interactive configuration (recommended for complex setups)
792
+ majk-chat configure-provider openai --profile personal
793
+ majk-chat configure-provider azure-openai --profile production
794
+ ```
795
+
796
+ ### Profile Management
797
+
798
+ ```bash
799
+ # List all configured profiles
800
+ majk-chat list-profiles
801
+ # Output:
802
+ # Configured profiles:
803
+ # default (openai)
804
+ # work (anthropic)
805
+ # production (azure-openai)
806
+
807
+ # Test profile configurations
808
+ majk-chat test-profile work
809
+ majk-chat test-all-profiles
810
+ majk-chat test-provider openai --profile default
811
+
812
+ # Delete a profile
813
+ majk-chat delete-profile old-profile
814
+ ```
815
+
816
+ ### Using Profiles
817
+
818
+ ```bash
819
+ # Use specific profile for chat
820
+ majk-chat chat --profile work -M "Hello from work environment"
821
+
822
+ # Interactive mode with profile
823
+ majk-chat interactive --profile production
824
+
825
+ # Models command with profile
826
+ majk-chat models --profile work
573
827
  ```
574
828
 
575
- You can also use JSON format:
829
+ ### Provider Configuration Commands
830
+
831
+ #### Interactive Configuration
832
+ ```bash
833
+ # OpenAI
834
+ majk-chat configure-provider openai [--profile name] [--skip-validation]
835
+
836
+ # Anthropic
837
+ majk-chat configure-provider anthropic [--profile name] [--skip-validation]
838
+
839
+ # Azure OpenAI (prompts for key, endpoint, deployment)
840
+ majk-chat configure-provider azure-openai [--profile name] [--skip-validation]
841
+
842
+ # AWS Bedrock (prompts for API key or access key, secret key, region)
843
+ majk-chat configure-provider bedrock [--profile name] [--skip-validation]
844
+ ```
845
+
846
+ #### Direct Configuration
847
+ ```bash
848
+ # OpenAI
849
+ majk-chat set-key --openai sk-your-key [--profile name] [--skip-validation]
850
+
851
+ # Anthropic
852
+ majk-chat set-key --anthropic sk-ant-your-key [--profile name] [--skip-validation]
853
+
854
+ # Azure OpenAI (requires all three parameters)
855
+ majk-chat set-key --azure-openai your-key https://your-endpoint.com deployment-name [--profile name]
856
+
857
+ # AWS Bedrock (requires access key and secret key, region optional)
858
+ majk-chat set-key --bedrock access-key secret-key us-east-1 [--profile name]
859
+ ```
860
+
861
+ ### Profile Configuration File
862
+
863
+ Profiles are stored in `~/.magic/chat/config.json`:
576
864
 
577
865
  ```json
578
866
  {
579
- "providers": {
580
- "openai": {
581
- "apiKey": "${OPENAI_API_KEY}"
867
+ "profiles": {
868
+ "default": {
869
+ "providers": {
870
+ "openai": {
871
+ "apiKey": "sk-...",
872
+ "organizationId": "org-..."
873
+ }
874
+ }
875
+ },
876
+ "work": {
877
+ "providers": {
878
+ "anthropic": {
879
+ "apiKey": "sk-ant-..."
880
+ },
881
+ "azure-openai": {
882
+ "apiKey": "...",
883
+ "endpoint": "https://work.openai.azure.com",
884
+ "deploymentName": "gpt-4-work"
885
+ }
886
+ }
887
+ },
888
+ "aws-prod": {
889
+ "providers": {
890
+ "bedrock": {
891
+ "bearerToken": "bedrock-api-key-...",
892
+ "region": "us-west-2"
893
+ }
894
+ }
582
895
  }
583
- },
584
- "defaultProvider": "openai"
896
+ }
585
897
  }
586
898
  ```
587
899
 
588
- ### Credential Sources
900
+ ### Credential Sources (Resolution Chain)
589
901
 
590
- The CLI looks for credentials in the following order:
902
+ The CLI looks for credentials in the following order (highest to lowest precedence):
591
903
 
592
- 1. **Command-line options** (`--api-key`, `--api-key-file`)
593
- 2. **Environment variables**:
904
+ 1. **Command-line options** (`--openai-api-key`, `--api-key`, etc.)
905
+ 2. **API key files** (`--api-key-file`)
906
+ 3. **Environment variables**:
594
907
  - OpenAI: `OPENAI_API_KEY`, `OPENAI_ORG_ID`
595
908
  - 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**:
909
+ - Azure: `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_DEPLOYMENT`
910
+ - AWS Bedrock: `AWS_BEARER_TOKEN_BEDROCK` (API keys) or `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION` (traditional)
911
+ 4. **Standard provider locations**:
599
912
  - `~/.openai/api_key`
600
913
  - `~/.anthropic/api_key`
601
914
  - `~/.config/openai/api_key`
602
915
  - `~/.config/anthropic/api_key`
603
- 4. **Configuration file** (`~/.majk-chat/config.yaml`)
916
+ 5. **Legacy configuration files** (`~/.majk-chat/config.yaml`)
917
+ 6. **Profile-based configuration** (`~/.magic/chat/config.json`) ⭐ **NEW**
918
+
919
+ ### Validation and Testing
920
+
921
+ ```bash
922
+ # Test specific profile
923
+ majk-chat test-profile work
924
+ # Output:
925
+ # Testing profile: work
926
+ # ✓ anthropic (model: claude-3-5-sonnet-20241022)
927
+ # ✗ openai - 401 Incorrect API key
928
+
929
+ # Test all profiles
930
+ majk-chat test-all-profiles
931
+
932
+ # Test specific provider in profile
933
+ majk-chat test-provider openai --profile default
934
+ ```
604
935
 
605
936
  ## Tool Support
606
937
 
@@ -668,15 +999,18 @@ response=$(majk-chat chat -M "Generate a random number between 1 and 100" -j)
668
999
  echo $response | jq '.choices[0].message.content'
669
1000
  ```
670
1001
 
671
- ### Multiple Providers
1002
+ ### Multiple Providers with Profiles
672
1003
 
673
1004
  ```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
1005
+ # Compare responses from different providers using different profiles
1006
+ majk-chat chat -p openai --profile personal -M "What is love?"
1007
+ echo "---"
1008
+ majk-chat chat -p anthropic --profile work -M "What is love?"
1009
+ echo "---"
1010
+
1011
+ # Use different profiles for different environments
1012
+ majk-chat chat --profile development -M "Test message"
1013
+ majk-chat chat --profile production -M "Production query"
680
1014
  ```
681
1015
 
682
1016
  ## Environment Variables
@@ -686,8 +1020,9 @@ done
686
1020
  - `AZURE_OPENAI_API_KEY` - Azure OpenAI API key
687
1021
  - `AZURE_OPENAI_ENDPOINT` - Azure OpenAI endpoint
688
1022
  - `AZURE_OPENAI_DEPLOYMENT` - Azure OpenAI deployment name
689
- - `AWS_ACCESS_KEY_ID` - AWS access key
690
- - `AWS_SECRET_ACCESS_KEY` - AWS secret key
1023
+ - `AWS_BEARER_TOKEN_BEDROCK` - AWS Bedrock API key (bearer token)
1024
+ - `AWS_ACCESS_KEY_ID` - AWS access key (traditional credentials)
1025
+ - `AWS_SECRET_ACCESS_KEY` - AWS secret key (traditional credentials)
691
1026
  - `AWS_REGION` - AWS region
692
1027
  - `NO_COLOR` - Disable colored output
693
1028
 
@@ -696,14 +1031,37 @@ done
696
1031
  ### No API Key Found
697
1032
 
698
1033
  ```bash
699
- Error: No API key found for provider
1034
+ Error: No valid API credentials found
700
1035
 
701
- Solution:
1036
+ Solution (recommended - profiles):
1037
+ 1. Set up profile: majk-chat set-key --openai sk-... --profile default
1038
+ 2. Use specific profile: majk-chat chat --profile work -M "Hello"
1039
+ 3. Test your setup: majk-chat test-all-profiles
1040
+
1041
+ Traditional solutions:
702
1042
  1. Set environment variable: export OPENAI_API_KEY=sk-...
703
1043
  2. Use --api-key flag: majk-chat chat --api-key sk-...
704
1044
  3. Create config file: majk-chat config --init
705
1045
  ```
706
1046
 
1047
+ ### Profile Issues
1048
+
1049
+ ```bash
1050
+ Error: Profile 'work' not found
1051
+
1052
+ Solution:
1053
+ 1. List profiles: majk-chat list-profiles
1054
+ 2. Create profile: majk-chat set-key --anthropic sk-... --profile work
1055
+ 3. Use existing profile: majk-chat chat --profile default
1056
+
1057
+ Error: Provider validation failed
1058
+
1059
+ Solution:
1060
+ 1. Test configuration: majk-chat test-profile work
1061
+ 2. Reconfigure: majk-chat configure-provider anthropic --profile work
1062
+ 3. Skip validation: majk-chat set-key --anthropic sk-... --skip-validation
1063
+ ```
1064
+
707
1065
  ### Rate Limiting
708
1066
 
709
1067
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@majkapp/majk-chat-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "CLI for multi-provider LLM chat interactions",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {
@@ -30,8 +30,8 @@
30
30
  "author": "Jules White",
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@majkapp/majk-chat-basic-tools": "^1.0.3",
34
- "@majkapp/majk-chat-core": "^1.0.2",
33
+ "@majkapp/majk-chat-basic-tools": "^1.0.4",
34
+ "@majkapp/majk-chat-core": "^1.0.4",
35
35
  "@majkapp/majk-chat-mcp": "^1.0.2",
36
36
  "@majkapp/majk-chat-sessions": "^1.0.2",
37
37
  "chalk": "^4.1.2",