janito 0.14.0__tar.gz → 0.15.0__tar.gz

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 (68) hide show
  1. {janito-0.14.0 → janito-0.15.0}/PKG-INFO +107 -22
  2. {janito-0.14.0 → janito-0.15.0}/README.md +106 -21
  3. janito-0.15.0/janito/__init__.py +5 -0
  4. {janito-0.14.0 → janito-0.15.0}/janito/cli/agent/initialization.py +4 -8
  5. {janito-0.14.0 → janito-0.15.0}/janito/cli/agent/query.py +29 -25
  6. {janito-0.14.0 → janito-0.15.0}/janito/cli/app.py +17 -21
  7. janito-0.15.0/janito/cli/commands/config.py +30 -0
  8. janito-0.15.0/janito/cli/commands/profile.py +93 -0
  9. {janito-0.14.0 → janito-0.15.0}/janito/cli/commands/workspace.py +30 -30
  10. janito-0.15.0/janito/config/README.md +104 -0
  11. janito-0.15.0/janito/config/__init__.py +16 -0
  12. janito-0.15.0/janito/config/cli/__init__.py +28 -0
  13. janito-0.15.0/janito/config/cli/commands.py +397 -0
  14. janito-0.15.0/janito/config/cli/validators.py +77 -0
  15. janito-0.15.0/janito/config/core/__init__.py +23 -0
  16. janito-0.15.0/janito/config/core/file_operations.py +90 -0
  17. janito-0.15.0/janito/config/core/properties.py +316 -0
  18. janito-0.15.0/janito/config/core/singleton.py +282 -0
  19. janito-0.15.0/janito/config/profiles/__init__.py +8 -0
  20. janito-0.15.0/janito/config/profiles/definitions.py +38 -0
  21. janito-0.15.0/janito/config/profiles/manager.py +80 -0
  22. {janito-0.14.0 → janito-0.15.0}/janito/data/instructions_template.txt +6 -3
  23. janito-0.15.0/janito/tools/bash/bash.py +157 -0
  24. {janito-0.14.0 → janito-0.15.0}/janito/tools/bash/unix_persistent_bash.py +32 -1
  25. {janito-0.14.0 → janito-0.15.0}/janito/tools/bash/win_persistent_bash.py +34 -1
  26. {janito-0.14.0 → janito-0.15.0}/janito/tools/move_file.py +1 -1
  27. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/handlers/view.py +14 -8
  28. {janito-0.14.0 → janito-0.15.0}/pyproject.toml +1 -1
  29. janito-0.14.0/janito/__init__.py +0 -5
  30. janito-0.14.0/janito/cli/commands/config.py +0 -242
  31. janito-0.14.0/janito/cli/commands/profile.py +0 -72
  32. janito-0.14.0/janito/config.py +0 -375
  33. janito-0.14.0/janito/tools/bash/bash.py +0 -84
  34. {janito-0.14.0 → janito-0.15.0}/.gitignore +0 -0
  35. {janito-0.14.0 → janito-0.15.0}/LICENSE +0 -0
  36. {janito-0.14.0 → janito-0.15.0}/janito/__main__.py +0 -0
  37. {janito-0.14.0 → janito-0.15.0}/janito/callbacks.py +0 -0
  38. {janito-0.14.0 → janito-0.15.0}/janito/cli/__init__.py +0 -0
  39. {janito-0.14.0 → janito-0.15.0}/janito/cli/agent/__init__.py +0 -0
  40. {janito-0.14.0 → janito-0.15.0}/janito/cli/agent/conversation.py +0 -0
  41. {janito-0.14.0 → janito-0.15.0}/janito/cli/agent.py +0 -0
  42. {janito-0.14.0 → janito-0.15.0}/janito/cli/commands/__init__.py +0 -0
  43. {janito-0.14.0 → janito-0.15.0}/janito/cli/commands/history.py +0 -0
  44. {janito-0.14.0 → janito-0.15.0}/janito/cli/commands/validation.py +0 -0
  45. {janito-0.14.0 → janito-0.15.0}/janito/cli/commands.py +0 -0
  46. {janito-0.14.0 → janito-0.15.0}/janito/cli/output.py +0 -0
  47. {janito-0.14.0 → janito-0.15.0}/janito/cli/utils.py +0 -0
  48. {janito-0.14.0 → janito-0.15.0}/janito/token_report.py +0 -0
  49. {janito-0.14.0 → janito-0.15.0}/janito/tools/__init__.py +0 -0
  50. {janito-0.14.0 → janito-0.15.0}/janito/tools/decorators.py +0 -0
  51. {janito-0.14.0 → janito-0.15.0}/janito/tools/delete_file.py +0 -0
  52. {janito-0.14.0 → janito-0.15.0}/janito/tools/fetch_webpage/__init__.py +0 -0
  53. {janito-0.14.0 → janito-0.15.0}/janito/tools/fetch_webpage/core.py +0 -0
  54. {janito-0.14.0 → janito-0.15.0}/janito/tools/find_files.py +0 -0
  55. {janito-0.14.0 → janito-0.15.0}/janito/tools/prompt_user.py +0 -0
  56. {janito-0.14.0 → janito-0.15.0}/janito/tools/replace_file.py +0 -0
  57. {janito-0.14.0 → janito-0.15.0}/janito/tools/rich_console.py +0 -0
  58. {janito-0.14.0 → janito-0.15.0}/janito/tools/search_text.py +0 -0
  59. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/__init__.py +0 -0
  60. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/editor.py +0 -0
  61. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/handlers/__init__.py +0 -0
  62. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/handlers/create.py +0 -0
  63. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/handlers/insert.py +0 -0
  64. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/handlers/str_replace.py +0 -0
  65. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/handlers/undo.py +0 -0
  66. {janito-0.14.0 → janito-0.15.0}/janito/tools/str_replace_editor/utils.py +0 -0
  67. {janito-0.14.0 → janito-0.15.0}/janito/tools/think.py +0 -0
  68. {janito-0.14.0 → janito-0.15.0}/janito/tools/usage_tracker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: janito
3
- Version: 0.14.0
3
+ Version: 0.15.0
4
4
  Summary: Janito CLI tool
5
5
  Project-URL: Homepage, https://github.com/joaompinto/janito
6
6
  Author-email: João Pinto <lamego.pinto@gmail.com>
@@ -130,7 +130,7 @@ janito --continue "Please add one more line"
130
130
 
131
131
  # Continue a specific conversation using its message ID
132
132
  # (Janito displays the message ID after each conversation)
133
- janito --continue 'abc123def' 'Let's refine that code'
133
+ janito --continue "abc123def" "Let's refine that code"
134
134
 
135
135
  # Alternative way to continue a specific conversation
136
136
  janito --continue-id abc123def "Let's refine that code"
@@ -143,6 +143,18 @@ janito -s "You are a poetry expert who speaks in rhymes" "Write about coding"
143
143
  # Show current configuration and available profiles
144
144
  janito --show-config
145
145
 
146
+ # Set a local configuration value (applies to current workspace only)
147
+ janito --set-local-config "temperature=0.7"
148
+
149
+ # Set a global configuration value (applies to all workspaces by default)
150
+ janito --set-global-config "profile=creative"
151
+
152
+ # Reset local configuration
153
+ janito --reset-local-config
154
+
155
+ # Reset global configuration
156
+ janito --reset-global-config
157
+
146
158
  # You can press Ctrl+C at any time to interrupt a query
147
159
  # Interrupted conversations can be continued with --continue
148
160
  ```
@@ -150,13 +162,14 @@ janito --show-config
150
162
  ## 🔧 Available Tools
151
163
 
152
164
  Janito comes with several built-in tools:
153
- - 📄 `str_replace_editor` - View, create, and edit files
165
+ - 📄 `str_replace_editor` - View, create, and edit files with configurable display limits
154
166
  - 🔎 `find_files` - Find files matching patterns
155
167
  - 🗑️ `delete_file` - Delete files
156
168
  - 🔍 `search_text` - Search for text patterns in files
157
169
  - 🌐 `fetch_webpage` - Fetch and extract content from web pages
158
170
  - 📋 `move_file` - Move files from one location to another
159
171
  - 💻 `bash` - Execute bash commands with real-time output display
172
+ - 🧠 `think` - Tool to record thoughts for complex reasoning
160
173
 
161
174
  ## 📊 Usage Tracking
162
175
 
@@ -170,6 +183,24 @@ Janito includes a comprehensive token usage tracking system that helps you monit
170
183
  - Cache performance metrics with savings analysis
171
184
  - Line delta tracking for file modifications
172
185
 
186
+ ## 📄 Enhanced File Viewing
187
+
188
+ The str_replace_editor tool now includes improved file viewing capabilities:
189
+
190
+ - **Configurable Display Limits**: Set the maximum number of lines to display before showing a warning
191
+ - **Warning Instead of Truncation**: When a file exceeds the configured line limit, a warning is shown but the full content is still displayed
192
+ - **Customizable Limits**: Configure the `max_view_lines` setting to adjust the threshold (default: 500 lines)
193
+
194
+ ```bash
195
+ # Set a custom maximum view lines threshold globally
196
+ janito --set-global-config "max_view_lines=1000"
197
+
198
+ # Set a project-specific threshold
199
+ janito --set-local-config "max_view_lines=250"
200
+ ```
201
+
202
+ This improvement ensures you always see the complete file content while still being warned about potentially large files.
203
+
173
204
  ```bash
174
205
  # Show detailed token usage and cost information
175
206
  janito --show-tokens "Write a Python function to sort a list"
@@ -347,29 +378,73 @@ Janito automatically installs the following dependencies:
347
378
  Janito offers a variety of command-line options to customize its behavior:
348
379
 
349
380
  ```
350
- --verbose, -v Enable verbose mode with detailed output
351
- --show-tokens Show detailed token usage and pricing information
352
- --workspace, -w TEXT Set the workspace directory
353
- --set-config TEXT Configuration string in format 'key=value', e.g., 'temperature=0.7'
354
- --show-config Show current configuration
355
- --reset-config Reset configuration by removing the config file
356
- --set-api-key TEXT Set the Anthropic API key globally in the user's home directory
357
- --ask Enable ask mode which disables tools that perform changes
358
- --trust, -t Enable trust mode which suppresses tool outputs for concise execution
359
- --no-tools Disable all tools for this session (pure AI interaction)
360
- --temperature FLOAT Set the temperature for model generation (0.0 to 1.0)
361
- --profile TEXT Use a predefined parameter profile (precise, balanced, conversational, creative, technical)
362
- --role TEXT Set the assistant's role (default: 'software engineer')
363
- --system, -s TEXT Provide custom system instructions, bypassing the default file load method
364
- --version Show the version and exit
365
- --continue, -c TEXT Continue a conversation. Can be used as: 1) --continue (to continue most recent),
381
+ Arguments:
382
+ [QUERY] Query to send to the claudine agent
383
+
384
+ Options:
385
+ --verbose, -v Enable verbose mode with detailed output
386
+ --show-tokens, --tokens Show detailed token usage and pricing information
387
+ --workspace, -w TEXT Set the workspace directory
388
+ --set-local-config TEXT Set a local configuration value in format 'key=value' (overrides global config)
389
+ --set-global-config TEXT Set a global configuration value in format 'key=value' (used as default)
390
+ --show-config Show current configuration
391
+ --reset-local-config Reset local configuration by removing the local config file
392
+ --reset-global-config Reset global configuration by removing the global config file
393
+ --set-api-key TEXT Set the Anthropic API key globally in the user's home directory
394
+ --ask Enable ask mode which disables tools that perform changes
395
+ --trust, -t Enable trust mode which suppresses tool outputs for concise execution
396
+ --no-tools Disable all tools for this session (pure AI interaction)
397
+ --temperature FLOAT Set the temperature for model generation (0.0 to 1.0)
398
+ --profile TEXT Use a predefined parameter profile (precise, balanced, conversational, creative, technical)
399
+ --role TEXT Set the assistant's role (default: 'software engineer')
400
+ --system, -s TEXT Provide custom system instructions, bypassing the default file load method
401
+ --version Show the version and exit
402
+ --continue, -c [TEXT] Continue a conversation. Can be used as: 1) --continue (to continue most recent),
366
403
  2) --continue 123 (to continue conversation with ID 123), or
367
404
  3) --continue "query" (to continue most recent with new query)
368
- --continue-id TEXT Continue a specific conversation with the given ID
369
- --history Show a summary of conversations. Use --history for default (20) or --history n to specify count
370
- --help Show the help message and exit
405
+ --history [N] Show a summary of conversations. Use --history for default (20) or --history n to specify count
406
+ --help Show the help message and exit
407
+ ```
408
+
409
+ ## ⚙️ Configuration System
410
+
411
+ Janito uses a two-level configuration system with local and global settings:
412
+
413
+ ### Local vs Global Configuration
414
+
415
+ - **Local Configuration**: Stored in `.janito/config.json` in your current workspace directory
416
+ - **Global Configuration**: Stored in `~/.janito/config.json` in your home directory
417
+ - Local settings override global settings when both are present
418
+ - Use `--set-local-config` for project-specific settings and `--set-global-config` for user-wide defaults
419
+
420
+ ### Setting Configuration Values
421
+
422
+ ```bash
423
+ # Set a local configuration value (applies to current workspace only)
424
+ janito --set-local-config "temperature=0.7"
425
+
426
+ # Set a global configuration value (applies to all workspaces by default)
427
+ janito --set-global-config "profile=creative"
428
+
429
+ # Reset local configuration
430
+ janito --reset-local-config
431
+
432
+ # Reset global configuration
433
+ janito --reset-global-config
434
+
435
+ # View current configuration (shows both local and global settings)
436
+ janito --show-config
371
437
  ```
372
438
 
439
+ ### Configurable Settings
440
+
441
+ You can configure various settings including:
442
+ - `profile`: Parameter profile (precise, balanced, conversational, creative, technical)
443
+ - `temperature`: Model temperature (0.0 to 1.0)
444
+ - `role`: Assistant's role (default: 'software engineer')
445
+ - `ask_mode`: Enable/disable ask mode (true/false)
446
+ - `max_view_lines`: Maximum number of lines to display before showing a warning (default: 500)
447
+
373
448
  ## 🔑 API Key Configuration
374
449
 
375
450
  You can configure your Anthropic API key in several ways:
@@ -391,6 +466,16 @@ Your API key is securely stored and used for all future sessions.
391
466
 
392
467
  For development instructions, please refer to [README_DEV.md](README_DEV.md).
393
468
 
469
+ ## 💡 Use Cases
470
+
471
+ ### Debugging Code
472
+
473
+ Below is an example of using Janito to help fix a bug in your code:
474
+
475
+ ![Using Janito to fix a bug](docs/images/use_cases/fix_bug_example.png)
476
+
477
+ Simply describe the bug to Janito, and it will help you identify and fix the issue in your code.
478
+
394
479
  ## 📜 License
395
480
 
396
481
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -110,7 +110,7 @@ janito --continue "Please add one more line"
110
110
 
111
111
  # Continue a specific conversation using its message ID
112
112
  # (Janito displays the message ID after each conversation)
113
- janito --continue 'abc123def' 'Let's refine that code'
113
+ janito --continue "abc123def" "Let's refine that code"
114
114
 
115
115
  # Alternative way to continue a specific conversation
116
116
  janito --continue-id abc123def "Let's refine that code"
@@ -123,6 +123,18 @@ janito -s "You are a poetry expert who speaks in rhymes" "Write about coding"
123
123
  # Show current configuration and available profiles
124
124
  janito --show-config
125
125
 
126
+ # Set a local configuration value (applies to current workspace only)
127
+ janito --set-local-config "temperature=0.7"
128
+
129
+ # Set a global configuration value (applies to all workspaces by default)
130
+ janito --set-global-config "profile=creative"
131
+
132
+ # Reset local configuration
133
+ janito --reset-local-config
134
+
135
+ # Reset global configuration
136
+ janito --reset-global-config
137
+
126
138
  # You can press Ctrl+C at any time to interrupt a query
127
139
  # Interrupted conversations can be continued with --continue
128
140
  ```
@@ -130,13 +142,14 @@ janito --show-config
130
142
  ## 🔧 Available Tools
131
143
 
132
144
  Janito comes with several built-in tools:
133
- - 📄 `str_replace_editor` - View, create, and edit files
145
+ - 📄 `str_replace_editor` - View, create, and edit files with configurable display limits
134
146
  - 🔎 `find_files` - Find files matching patterns
135
147
  - 🗑️ `delete_file` - Delete files
136
148
  - 🔍 `search_text` - Search for text patterns in files
137
149
  - 🌐 `fetch_webpage` - Fetch and extract content from web pages
138
150
  - 📋 `move_file` - Move files from one location to another
139
151
  - 💻 `bash` - Execute bash commands with real-time output display
152
+ - 🧠 `think` - Tool to record thoughts for complex reasoning
140
153
 
141
154
  ## 📊 Usage Tracking
142
155
 
@@ -150,6 +163,24 @@ Janito includes a comprehensive token usage tracking system that helps you monit
150
163
  - Cache performance metrics with savings analysis
151
164
  - Line delta tracking for file modifications
152
165
 
166
+ ## 📄 Enhanced File Viewing
167
+
168
+ The str_replace_editor tool now includes improved file viewing capabilities:
169
+
170
+ - **Configurable Display Limits**: Set the maximum number of lines to display before showing a warning
171
+ - **Warning Instead of Truncation**: When a file exceeds the configured line limit, a warning is shown but the full content is still displayed
172
+ - **Customizable Limits**: Configure the `max_view_lines` setting to adjust the threshold (default: 500 lines)
173
+
174
+ ```bash
175
+ # Set a custom maximum view lines threshold globally
176
+ janito --set-global-config "max_view_lines=1000"
177
+
178
+ # Set a project-specific threshold
179
+ janito --set-local-config "max_view_lines=250"
180
+ ```
181
+
182
+ This improvement ensures you always see the complete file content while still being warned about potentially large files.
183
+
153
184
  ```bash
154
185
  # Show detailed token usage and cost information
155
186
  janito --show-tokens "Write a Python function to sort a list"
@@ -327,29 +358,73 @@ Janito automatically installs the following dependencies:
327
358
  Janito offers a variety of command-line options to customize its behavior:
328
359
 
329
360
  ```
330
- --verbose, -v Enable verbose mode with detailed output
331
- --show-tokens Show detailed token usage and pricing information
332
- --workspace, -w TEXT Set the workspace directory
333
- --set-config TEXT Configuration string in format 'key=value', e.g., 'temperature=0.7'
334
- --show-config Show current configuration
335
- --reset-config Reset configuration by removing the config file
336
- --set-api-key TEXT Set the Anthropic API key globally in the user's home directory
337
- --ask Enable ask mode which disables tools that perform changes
338
- --trust, -t Enable trust mode which suppresses tool outputs for concise execution
339
- --no-tools Disable all tools for this session (pure AI interaction)
340
- --temperature FLOAT Set the temperature for model generation (0.0 to 1.0)
341
- --profile TEXT Use a predefined parameter profile (precise, balanced, conversational, creative, technical)
342
- --role TEXT Set the assistant's role (default: 'software engineer')
343
- --system, -s TEXT Provide custom system instructions, bypassing the default file load method
344
- --version Show the version and exit
345
- --continue, -c TEXT Continue a conversation. Can be used as: 1) --continue (to continue most recent),
361
+ Arguments:
362
+ [QUERY] Query to send to the claudine agent
363
+
364
+ Options:
365
+ --verbose, -v Enable verbose mode with detailed output
366
+ --show-tokens, --tokens Show detailed token usage and pricing information
367
+ --workspace, -w TEXT Set the workspace directory
368
+ --set-local-config TEXT Set a local configuration value in format 'key=value' (overrides global config)
369
+ --set-global-config TEXT Set a global configuration value in format 'key=value' (used as default)
370
+ --show-config Show current configuration
371
+ --reset-local-config Reset local configuration by removing the local config file
372
+ --reset-global-config Reset global configuration by removing the global config file
373
+ --set-api-key TEXT Set the Anthropic API key globally in the user's home directory
374
+ --ask Enable ask mode which disables tools that perform changes
375
+ --trust, -t Enable trust mode which suppresses tool outputs for concise execution
376
+ --no-tools Disable all tools for this session (pure AI interaction)
377
+ --temperature FLOAT Set the temperature for model generation (0.0 to 1.0)
378
+ --profile TEXT Use a predefined parameter profile (precise, balanced, conversational, creative, technical)
379
+ --role TEXT Set the assistant's role (default: 'software engineer')
380
+ --system, -s TEXT Provide custom system instructions, bypassing the default file load method
381
+ --version Show the version and exit
382
+ --continue, -c [TEXT] Continue a conversation. Can be used as: 1) --continue (to continue most recent),
346
383
  2) --continue 123 (to continue conversation with ID 123), or
347
384
  3) --continue "query" (to continue most recent with new query)
348
- --continue-id TEXT Continue a specific conversation with the given ID
349
- --history Show a summary of conversations. Use --history for default (20) or --history n to specify count
350
- --help Show the help message and exit
385
+ --history [N] Show a summary of conversations. Use --history for default (20) or --history n to specify count
386
+ --help Show the help message and exit
387
+ ```
388
+
389
+ ## ⚙️ Configuration System
390
+
391
+ Janito uses a two-level configuration system with local and global settings:
392
+
393
+ ### Local vs Global Configuration
394
+
395
+ - **Local Configuration**: Stored in `.janito/config.json` in your current workspace directory
396
+ - **Global Configuration**: Stored in `~/.janito/config.json` in your home directory
397
+ - Local settings override global settings when both are present
398
+ - Use `--set-local-config` for project-specific settings and `--set-global-config` for user-wide defaults
399
+
400
+ ### Setting Configuration Values
401
+
402
+ ```bash
403
+ # Set a local configuration value (applies to current workspace only)
404
+ janito --set-local-config "temperature=0.7"
405
+
406
+ # Set a global configuration value (applies to all workspaces by default)
407
+ janito --set-global-config "profile=creative"
408
+
409
+ # Reset local configuration
410
+ janito --reset-local-config
411
+
412
+ # Reset global configuration
413
+ janito --reset-global-config
414
+
415
+ # View current configuration (shows both local and global settings)
416
+ janito --show-config
351
417
  ```
352
418
 
419
+ ### Configurable Settings
420
+
421
+ You can configure various settings including:
422
+ - `profile`: Parameter profile (precise, balanced, conversational, creative, technical)
423
+ - `temperature`: Model temperature (0.0 to 1.0)
424
+ - `role`: Assistant's role (default: 'software engineer')
425
+ - `ask_mode`: Enable/disable ask mode (true/false)
426
+ - `max_view_lines`: Maximum number of lines to display before showing a warning (default: 500)
427
+
353
428
  ## 🔑 API Key Configuration
354
429
 
355
430
  You can configure your Anthropic API key in several ways:
@@ -371,6 +446,16 @@ Your API key is securely stored and used for all future sessions.
371
446
 
372
447
  For development instructions, please refer to [README_DEV.md](README_DEV.md).
373
448
 
449
+ ## 💡 Use Cases
450
+
451
+ ### Debugging Code
452
+
453
+ Below is an example of using Janito to help fix a bug in your code:
454
+
455
+ ![Using Janito to fix a bug](docs/images/use_cases/fix_bug_example.png)
456
+
457
+ Simply describe the bug to Janito, and it will help you identify and fix the issue in your code.
458
+
374
459
  ## 📜 License
375
460
 
376
461
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,5 @@
1
+ """
2
+ Janito package.
3
+ """
4
+
5
+ __version__ = "0.15.0"
@@ -20,21 +20,17 @@ console = Console()
20
20
 
21
21
  def get_api_key() -> str:
22
22
  """
23
- Get the API key from global config, environment variable, or user input.
23
+ Get the API key from global config or user input.
24
24
 
25
25
  Returns:
26
26
  str: The API key
27
27
  """
28
- # Get API key from global config, environment variable, or ask the user
28
+ # Get API key from global config or ask the user
29
29
  api_key = Config.get_api_key()
30
-
31
- # If not found in global config, try environment variable
32
- if not api_key:
33
- api_key = os.environ.get("ANTHROPIC_API_KEY")
34
30
 
35
- # If still not found, prompt the user
31
+ # If not found, prompt the user
36
32
  if not api_key:
37
- console.print("[bold yellow]⚠️ Warning:[/bold yellow] API key not found in global config or ANTHROPIC_API_KEY environment variable.")
33
+ console.print("[bold yellow]⚠️ Warning:[/bold yellow] API key not found in global config.")
38
34
  console.print("🔑 Please set it using --set-api-key or provide your API key now:")
39
35
  api_key = typer.prompt("Anthropic API Key", hide_input=True)
40
36
 
@@ -11,6 +11,7 @@ from janito.token_report import generate_token_report
11
11
  from janito.tools import print_usage_stats
12
12
  from janito.cli.agent.initialization import initialize_agent
13
13
  from janito.cli.agent.conversation import load_messages, save_messages
14
+ from janito.config import Config
14
15
 
15
16
  console = Console()
16
17
 
@@ -60,15 +61,17 @@ def handle_query(query: str, temperature: float, verbose: bool, show_tokens: boo
60
61
  # Save messages after successful query and get the message ID
61
62
  message_id = save_messages(agent)
62
63
 
63
- # Print token usage report
64
- if show_tokens:
65
- generate_token_report(agent, verbose=True, interrupted=False)
66
- else:
67
- # Show basic token usage
68
- generate_token_report(agent, verbose=False, interrupted=False)
69
-
70
- # Print tool usage statistics
71
- print_usage_stats()
64
+ # Check if usage reports should be shown
65
+ if Config().show_usage_report:
66
+ # Print token usage report
67
+ if show_tokens:
68
+ generate_token_report(agent, verbose=True, interrupted=False)
69
+ else:
70
+ # Show basic token usage
71
+ generate_token_report(agent, verbose=False, interrupted=False)
72
+
73
+ # Print tool usage statistics
74
+ print_usage_stats()
72
75
 
73
76
 
74
77
 
@@ -79,22 +82,23 @@ def handle_query(query: str, temperature: float, verbose: bool, show_tokens: boo
79
82
  # Save messages even if interrupted
80
83
  message_id = save_messages(agent)
81
84
 
82
- # Print token usage report (even if interrupted)
83
- try:
84
- if show_tokens:
85
- generate_token_report(agent, verbose=True, interrupted=True)
86
- else:
87
- # Show basic token usage
88
- generate_token_report(agent, verbose=False, interrupted=True)
89
-
90
- # Print tool usage statistics
91
- print_usage_stats()
92
-
93
-
94
- except Exception as e:
95
- console.print(f"[bold red]❌ Error generating usage report:[/bold red] {str(e)}")
96
- if verbose:
97
- console.print(traceback.format_exc())
85
+ # Check if usage reports should be shown
86
+ if Config().show_usage_report:
87
+ # Print token usage report (even if interrupted)
88
+ try:
89
+ if show_tokens:
90
+ generate_token_report(agent, verbose=True, interrupted=True)
91
+ else:
92
+ # Show basic token usage
93
+ generate_token_report(agent, verbose=False, interrupted=True)
94
+
95
+ # Print tool usage statistics
96
+ print_usage_stats()
97
+
98
+ except Exception as e:
99
+ console.print(f"[bold red]❌ Error generating usage report:[/bold red] {str(e)}")
100
+ if verbose:
101
+ console.print(traceback.format_exc())
98
102
 
99
103
  # Exit with non-zero status to indicate interruption
100
104
  sys.exit(130) # 130 is the standard exit code for SIGINT
@@ -8,7 +8,7 @@ from rich.console import Console
8
8
  import importlib.metadata
9
9
 
10
10
  from janito import __version__
11
- from janito.config import get_config
11
+ from janito.config import Config
12
12
  from janito.cli.commands import handle_config_commands, validate_parameters
13
13
  from janito.cli.agent import handle_query
14
14
  from janito.cli.utils import get_stdin_termination_hint
@@ -22,9 +22,11 @@ def main(ctx: typer.Context,
22
22
  verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose mode with detailed output"),
23
23
  show_tokens: bool = typer.Option(False, "--show-tokens", "--tokens", help="Show detailed token usage and pricing information"),
24
24
  workspace: Optional[str] = typer.Option(None, "--workspace", "-w", help="Set the workspace directory"),
25
- config_str: Optional[str] = typer.Option(None, "--set-config", help="Configuration string in format 'key=value', e.g., 'temperature=0.7' or 'profile=technical'"),
25
+ set_local_config: Optional[str] = typer.Option(None, "--set-local-config", help="Set a local configuration value in format 'key=value' (overrides global config)"),
26
+ set_global_config: Optional[str] = typer.Option(None, "--set-global-config", help="Set a global configuration value in format 'key=value' (used as default)"),
26
27
  show_config: bool = typer.Option(False, "--show-config", help="Show current configuration"),
27
- reset_config: bool = typer.Option(False, "--reset-config", help="Reset configuration by removing the config file"),
28
+ reset_local_config: bool = typer.Option(False, "--reset-local-config", help="Reset local configuration by removing the local config file"),
29
+ reset_global_config: bool = typer.Option(False, "--reset-global-config", help="Reset global configuration by removing the global config file"),
28
30
  set_api_key: Optional[str] = typer.Option(None, "--set-api-key", help="Set the Anthropic API key globally in the user's home directory"),
29
31
  ask: bool = typer.Option(False, "--ask", help="Enable ask mode which disables tools that perform changes"),
30
32
  trust: bool = typer.Option(False, "--trust", "-t", help="Enable trust mode which suppresses tool outputs for a more concise execution"),
@@ -34,23 +36,22 @@ def main(ctx: typer.Context,
34
36
  role: Optional[str] = typer.Option(None, "--role", help="Set the assistant's role (default: 'software engineer')"),
35
37
  system: Optional[str] = typer.Option(None, "--system", "-s", help="Provide custom system instructions, bypassing the default file load method"),
36
38
  version: bool = typer.Option(False, "--version", help="Show the version and exit"),
37
- continue_id: Optional[str] = typer.Option(None, "--continue-id", help="Continue a specific conversation with the given ID"),
38
39
  continue_flag: Optional[str] = typer.Option(None, "--continue", "-c", help="Continue a conversation. Can be used as: 1) --continue (to continue most recent), 2) --continue 123 (to continue conversation with ID 123), or 3) --continue \"query\" (to continue most recent with new query)"),
39
40
  history_flag: bool = typer.Option(False, "--history", help="Show a summary of conversations. Use --history for default (20) or --history n to specify count")):
40
41
  """
41
42
  Janito CLI tool. If a query is provided without a command, it will be sent to the claudine agent.
42
43
  """
43
44
  # Set verbose mode in config
44
- get_config().verbose = verbose
45
+ Config().verbose = verbose
45
46
 
46
47
  # Set ask mode in config
47
- get_config().ask_mode = ask
48
+ Config().ask_mode = ask
48
49
 
49
50
  # Set trust mode in config
50
- get_config().trust_mode = trust
51
+ Config().trust_mode = trust
51
52
 
52
53
  # Set no-tools mode in config
53
- get_config().no_tools = no_tools
54
+ Config().no_tools = no_tools
54
55
 
55
56
  # Show a message if ask mode is enabled
56
57
  if ask:
@@ -124,22 +125,15 @@ def main(ctx: typer.Context,
124
125
  # --continue with no args means continue most recent conversation
125
126
  continue_conversation = ""
126
127
 
127
- # Handle explicit --continue-id if specified (this takes precedence)
128
- if "--continue-id" in args:
129
- continue_id_idx = args.index("--continue-id")
130
- if continue_id_idx + 1 < len(args) and not args[continue_id_idx + 1].startswith("-"):
131
- continue_conversation = args[continue_id_idx + 1]
128
+ # --continue-id has been removed in favor of --continue
132
129
  except Exception as e:
133
130
  if verbose:
134
131
  console.print(f"[bold yellow]⚠️ Error parsing continue arguments: {str(e)}[/bold yellow]")
135
132
 
136
133
  # Fall back to typer-processed args if our parsing failed
137
134
  if continue_conversation is None:
138
- # Handle the --continue-id option
139
- if continue_id is not None:
140
- continue_conversation = continue_id
141
135
  # Handle the --continue flag option (processed by typer)
142
- elif continue_flag is not None:
136
+ if continue_flag is not None:
143
137
  if continue_flag == "":
144
138
  continue_conversation = "" # Empty string means continue most recent
145
139
  elif continue_flag.isdigit():
@@ -151,15 +145,17 @@ def main(ctx: typer.Context,
151
145
  # Handle configuration-related commands
152
146
  exit_after_config = handle_config_commands(
153
147
  ctx,
154
- reset_config,
148
+ False, # reset_config is removed, passing False for backward compatibility
149
+ reset_local_config,
150
+ reset_global_config,
155
151
  workspace,
156
152
  show_config,
157
153
  profile,
158
154
  role,
159
- set_api_key,
160
- config_str,
155
+ set_api_key,
156
+ set_local_config,
157
+ set_global_config,
161
158
  query,
162
- continue_id,
163
159
  continue_flag,
164
160
  history_flag,
165
161
  history_count_override
@@ -0,0 +1,30 @@
1
+ """
2
+ Configuration management functions for Janito CLI.
3
+ This file is a thin wrapper around the actual implementation in janito.config.cli.commands
4
+ to maintain backward compatibility.
5
+ """
6
+ import typer
7
+ from typing import Optional
8
+
9
+ from janito.config.cli.commands import (
10
+ handle_reset_config,
11
+ handle_reset_local_config,
12
+ handle_reset_global_config,
13
+ handle_show_config,
14
+ handle_set_api_key,
15
+ handle_set_local_config,
16
+ handle_set_global_config,
17
+ handle_config_commands
18
+ )
19
+
20
+ # Re-export all functions for backward compatibility
21
+ __all__ = [
22
+ "handle_reset_config",
23
+ "handle_reset_local_config",
24
+ "handle_reset_global_config",
25
+ "handle_show_config",
26
+ "handle_set_api_key",
27
+ "handle_set_local_config",
28
+ "handle_set_global_config",
29
+ "handle_config_commands"
30
+ ]