janito 0.12.0__tar.gz → 0.13.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 (47) hide show
  1. {janito-0.12.0 → janito-0.13.0}/PKG-INFO +101 -4
  2. {janito-0.12.0 → janito-0.13.0}/README.md +100 -3
  3. janito-0.13.0/janito/__init__.py +5 -0
  4. {janito-0.12.0 → janito-0.13.0}/janito/cli/agent.py +135 -22
  5. {janito-0.12.0 → janito-0.13.0}/janito/cli/app.py +10 -2
  6. {janito-0.12.0 → janito-0.13.0}/janito/cli/commands.py +2 -2
  7. {janito-0.12.0 → janito-0.13.0}/janito/config.py +20 -0
  8. {janito-0.12.0 → janito-0.13.0}/janito/data/instructions_template.txt +5 -4
  9. {janito-0.12.0 → janito-0.13.0}/janito/tools/bash/bash.py +3 -1
  10. {janito-0.12.0 → janito-0.13.0}/janito/tools/bash/unix_persistent_bash.py +183 -181
  11. {janito-0.12.0 → janito-0.13.0}/janito/tools/bash/win_persistent_bash.py +4 -2
  12. {janito-0.12.0 → janito-0.13.0}/janito/tools/rich_console.py +46 -9
  13. {janito-0.12.0 → janito-0.13.0}/janito/tools/search_text.py +4 -3
  14. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/handlers/str_replace.py +3 -1
  15. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/handlers/view.py +14 -8
  16. {janito-0.12.0 → janito-0.13.0}/pyproject.toml +1 -1
  17. janito-0.12.0/janito/__init__.py +0 -5
  18. {janito-0.12.0 → janito-0.13.0}/.gitignore +0 -0
  19. {janito-0.12.0 → janito-0.13.0}/LICENSE +0 -0
  20. {janito-0.12.0 → janito-0.13.0}/janito/__main__.py +0 -0
  21. {janito-0.12.0 → janito-0.13.0}/janito/callbacks.py +0 -0
  22. {janito-0.12.0 → janito-0.13.0}/janito/cli/__init__.py +0 -0
  23. {janito-0.12.0 → janito-0.13.0}/janito/cli/output.py +0 -0
  24. {janito-0.12.0 → janito-0.13.0}/janito/cli/utils.py +0 -0
  25. {janito-0.12.0 → janito-0.13.0}/janito/test_file.py +0 -0
  26. {janito-0.12.0 → janito-0.13.0}/janito/token_report.py +0 -0
  27. {janito-0.12.0 → janito-0.13.0}/janito/tools/__init__.py +0 -0
  28. {janito-0.12.0 → janito-0.13.0}/janito/tools/decorators.py +0 -0
  29. {janito-0.12.0 → janito-0.13.0}/janito/tools/delete_file.py +0 -0
  30. {janito-0.12.0 → janito-0.13.0}/janito/tools/fetch_webpage/__init__.py +0 -0
  31. {janito-0.12.0 → janito-0.13.0}/janito/tools/fetch_webpage/chunking.py +0 -0
  32. {janito-0.12.0 → janito-0.13.0}/janito/tools/fetch_webpage/core.py +0 -0
  33. {janito-0.12.0 → janito-0.13.0}/janito/tools/fetch_webpage/extractors.py +0 -0
  34. {janito-0.12.0 → janito-0.13.0}/janito/tools/fetch_webpage/news.py +0 -0
  35. {janito-0.12.0 → janito-0.13.0}/janito/tools/fetch_webpage/utils.py +0 -0
  36. {janito-0.12.0 → janito-0.13.0}/janito/tools/find_files.py +0 -0
  37. {janito-0.12.0 → janito-0.13.0}/janito/tools/move_file.py +0 -0
  38. {janito-0.12.0 → janito-0.13.0}/janito/tools/prompt_user.py +0 -0
  39. {janito-0.12.0 → janito-0.13.0}/janito/tools/replace_file.py +0 -0
  40. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/__init__.py +0 -0
  41. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/editor.py +0 -0
  42. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/handlers/__init__.py +0 -0
  43. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/handlers/create.py +0 -0
  44. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/handlers/insert.py +0 -0
  45. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/handlers/undo.py +0 -0
  46. {janito-0.12.0 → janito-0.13.0}/janito/tools/str_replace_editor/utils.py +0 -0
  47. {janito-0.12.0 → janito-0.13.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.12.0
3
+ Version: 0.13.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>
@@ -35,6 +35,8 @@ Janito is a powerful AI-assisted command-line interface (CLI) tool built with Py
35
35
  - 🌐 Web page fetching with content extraction capabilities
36
36
  - 🔄 Parameter profiles for optimizing Claude's behavior for different tasks
37
37
  - 📋 Line delta tracking to monitor net changes in files
38
+ - 💬 Conversation history with ability to resume previous conversations
39
+ - 🔇 Trust mode for concise output without tool details
38
40
 
39
41
  ## 🛠️ System Requirements
40
42
 
@@ -108,14 +110,24 @@ janito --show-tokens "Explain what is in the project"
108
110
  # Use a specific parameter profile for creative tasks
109
111
  janito --profile creative "Write a fun description for our project"
110
112
 
111
- # Continue previous conversation
112
- janito --continue "Plese add one more line"
113
+ # Use trust mode for concise output without tool details
114
+ janito --trust "Optimize the HTML code"
115
+ # Or use the short alias
116
+ janito -t "Optimize the HTML code"
117
+
118
+ # Continue the most recent conversation
119
+ janito --continue "Please add one more line"
120
+
121
+ # Continue a specific conversation using its message ID
122
+ # (Janito displays the message ID after each conversation)
123
+ janito --continue abc123def "Let's refine that code"
113
124
 
114
125
  # Show current configuration and available profiles
115
126
  janito --show-config
116
127
 
117
128
  # You can press Ctrl+C at any time to interrupt a query
118
129
  # Janito will still display token and tool usage information
130
+ # Even interrupted conversations can be continued with --continue
119
131
  ```
120
132
 
121
133
  ## 🔧 Available Tools
@@ -134,7 +146,7 @@ Janito comes with several built-in tools:
134
146
  Janito includes a comprehensive token usage tracking system that helps you monitor API costs:
135
147
 
136
148
  - **Basic tracking**: By default, Janito displays a summary of token usage and cost after each query
137
- - **Detailed reporting**: Use the `--show-tokens` or `-t` flag to see detailed breakdowns including:
149
+ - **Detailed reporting**: Use the `--show-tokens` flag to see detailed breakdowns including:
138
150
  - Input and output token counts
139
151
  - Per-tool token usage statistics
140
152
  - Precise cost calculations
@@ -147,6 +159,11 @@ janito --show-tokens "Write a Python function to sort a list"
147
159
 
148
160
  # Basic usage (shows simplified token usage summary)
149
161
  janito "Explain Docker containers"
162
+
163
+ # Use trust mode for concise output without tool details
164
+ janito --trust "Create a simple Python script"
165
+ # Or use the short alias
166
+ janito -t "Create a simple Python script"
150
167
  ```
151
168
 
152
169
  The usage tracker automatically calculates cache savings, showing you how much you're saving by reusing previous responses.
@@ -169,6 +186,64 @@ janito --profile creative "Write a poem about coding"
169
186
  janito --show-config
170
187
  ```
171
188
 
189
+ ## 🔇 Trust Mode
190
+
191
+ Janito offers a trust mode that suppresses tool outputs for a more concise execution experience:
192
+
193
+ ### How It Works
194
+
195
+ - When enabled with `--trust` or `-t`, Janito suppresses informational and success messages from tools
196
+ - Only essential output and error messages are displayed
197
+ - The final result from Claude is still shown in full
198
+ - Trust mode is a per-session setting and not saved to your configuration
199
+
200
+ ### Using Trust Mode
201
+
202
+ ```bash
203
+ # Enable trust mode with the full flag
204
+ janito --trust "Create a Python script that reads a CSV file"
205
+
206
+ # Or use the short alias
207
+ janito -t "Create a Python script that reads a CSV file"
208
+ ```
209
+
210
+ This feature is particularly useful for:
211
+ - Experienced users who don't need to see every step of the process
212
+ - Batch processing or scripting where concise output is preferred
213
+ - Focusing on results rather than the process
214
+ - Creating cleaner output for documentation or sharing
215
+
216
+ ## 💬 Conversation History
217
+
218
+ Janito automatically saves your conversation history, allowing you to continue previous discussions:
219
+
220
+ ### How It Works
221
+
222
+ - Each conversation is saved with a unique message ID in `.janito/last_messages/`
223
+ - The most recent conversation is also saved as `.janito/last_message.json` for backward compatibility
224
+ - After each conversation, Janito displays the command to continue that specific conversation
225
+
226
+ ### Using the Continue Feature
227
+
228
+ ```bash
229
+ # Continue the most recent conversation
230
+ janito --continue "Add more details to your previous response"
231
+
232
+ # Continue a specific conversation using its ID
233
+ janito --continue abc123def "Let's modify that code you suggested"
234
+ ```
235
+
236
+ The `--continue` flag (or `-c` for short) allows you to:
237
+ - Resume the most recent conversation when used without an ID
238
+ - Resume a specific conversation when provided with a message ID
239
+ - Maintain context across multiple interactions for complex tasks
240
+
241
+ This feature is particularly useful for:
242
+ - Multi-step development tasks
243
+ - Iterative code improvements
244
+ - Continuing discussions after system interruptions
245
+ - Maintaining context when working on complex problems
246
+
172
247
  ## ⚙️ Dependencies
173
248
 
174
249
  Janito automatically installs the following dependencies:
@@ -177,6 +252,28 @@ Janito automatically installs the following dependencies:
177
252
  - claudine - For Claude AI integration
178
253
  - Additional packages for file handling and web content extraction
179
254
 
255
+ ## 🛠️ Command-Line Options
256
+
257
+ Janito offers a variety of command-line options to customize its behavior:
258
+
259
+ ```
260
+ --verbose, -v Enable verbose mode with detailed output
261
+ --show-tokens Show detailed token usage and pricing information
262
+ --workspace, -w TEXT Set the workspace directory
263
+ --set-config TEXT Configuration string in format 'key=value', e.g., 'temperature=0.7'
264
+ --show-config Show current configuration
265
+ --reset-config Reset configuration by removing the config file
266
+ --set-api-key TEXT Set the Anthropic API key globally in the user's home directory
267
+ --ask Enable ask mode which disables tools that perform changes
268
+ --trust, -t Enable trust mode which suppresses tool outputs for concise execution
269
+ --temperature FLOAT Set the temperature for model generation (0.0 to 1.0)
270
+ --profile TEXT Use a predefined parameter profile (precise, balanced, conversational, creative, technical)
271
+ --role TEXT Set the assistant's role (default: 'software engineer')
272
+ --version Show the version and exit
273
+ --continue, -c TEXT Continue a previous conversation, optionally with a specific message ID
274
+ --help Show the help message and exit
275
+ ```
276
+
180
277
  ## 🔑 API Key Configuration
181
278
 
182
279
  You can configure your Anthropic API key in several ways:
@@ -15,6 +15,8 @@ Janito is a powerful AI-assisted command-line interface (CLI) tool built with Py
15
15
  - 🌐 Web page fetching with content extraction capabilities
16
16
  - 🔄 Parameter profiles for optimizing Claude's behavior for different tasks
17
17
  - 📋 Line delta tracking to monitor net changes in files
18
+ - 💬 Conversation history with ability to resume previous conversations
19
+ - 🔇 Trust mode for concise output without tool details
18
20
 
19
21
  ## 🛠️ System Requirements
20
22
 
@@ -88,14 +90,24 @@ janito --show-tokens "Explain what is in the project"
88
90
  # Use a specific parameter profile for creative tasks
89
91
  janito --profile creative "Write a fun description for our project"
90
92
 
91
- # Continue previous conversation
92
- janito --continue "Plese add one more line"
93
+ # Use trust mode for concise output without tool details
94
+ janito --trust "Optimize the HTML code"
95
+ # Or use the short alias
96
+ janito -t "Optimize the HTML code"
97
+
98
+ # Continue the most recent conversation
99
+ janito --continue "Please add one more line"
100
+
101
+ # Continue a specific conversation using its message ID
102
+ # (Janito displays the message ID after each conversation)
103
+ janito --continue abc123def "Let's refine that code"
93
104
 
94
105
  # Show current configuration and available profiles
95
106
  janito --show-config
96
107
 
97
108
  # You can press Ctrl+C at any time to interrupt a query
98
109
  # Janito will still display token and tool usage information
110
+ # Even interrupted conversations can be continued with --continue
99
111
  ```
100
112
 
101
113
  ## 🔧 Available Tools
@@ -114,7 +126,7 @@ Janito comes with several built-in tools:
114
126
  Janito includes a comprehensive token usage tracking system that helps you monitor API costs:
115
127
 
116
128
  - **Basic tracking**: By default, Janito displays a summary of token usage and cost after each query
117
- - **Detailed reporting**: Use the `--show-tokens` or `-t` flag to see detailed breakdowns including:
129
+ - **Detailed reporting**: Use the `--show-tokens` flag to see detailed breakdowns including:
118
130
  - Input and output token counts
119
131
  - Per-tool token usage statistics
120
132
  - Precise cost calculations
@@ -127,6 +139,11 @@ janito --show-tokens "Write a Python function to sort a list"
127
139
 
128
140
  # Basic usage (shows simplified token usage summary)
129
141
  janito "Explain Docker containers"
142
+
143
+ # Use trust mode for concise output without tool details
144
+ janito --trust "Create a simple Python script"
145
+ # Or use the short alias
146
+ janito -t "Create a simple Python script"
130
147
  ```
131
148
 
132
149
  The usage tracker automatically calculates cache savings, showing you how much you're saving by reusing previous responses.
@@ -149,6 +166,64 @@ janito --profile creative "Write a poem about coding"
149
166
  janito --show-config
150
167
  ```
151
168
 
169
+ ## 🔇 Trust Mode
170
+
171
+ Janito offers a trust mode that suppresses tool outputs for a more concise execution experience:
172
+
173
+ ### How It Works
174
+
175
+ - When enabled with `--trust` or `-t`, Janito suppresses informational and success messages from tools
176
+ - Only essential output and error messages are displayed
177
+ - The final result from Claude is still shown in full
178
+ - Trust mode is a per-session setting and not saved to your configuration
179
+
180
+ ### Using Trust Mode
181
+
182
+ ```bash
183
+ # Enable trust mode with the full flag
184
+ janito --trust "Create a Python script that reads a CSV file"
185
+
186
+ # Or use the short alias
187
+ janito -t "Create a Python script that reads a CSV file"
188
+ ```
189
+
190
+ This feature is particularly useful for:
191
+ - Experienced users who don't need to see every step of the process
192
+ - Batch processing or scripting where concise output is preferred
193
+ - Focusing on results rather than the process
194
+ - Creating cleaner output for documentation or sharing
195
+
196
+ ## 💬 Conversation History
197
+
198
+ Janito automatically saves your conversation history, allowing you to continue previous discussions:
199
+
200
+ ### How It Works
201
+
202
+ - Each conversation is saved with a unique message ID in `.janito/last_messages/`
203
+ - The most recent conversation is also saved as `.janito/last_message.json` for backward compatibility
204
+ - After each conversation, Janito displays the command to continue that specific conversation
205
+
206
+ ### Using the Continue Feature
207
+
208
+ ```bash
209
+ # Continue the most recent conversation
210
+ janito --continue "Add more details to your previous response"
211
+
212
+ # Continue a specific conversation using its ID
213
+ janito --continue abc123def "Let's modify that code you suggested"
214
+ ```
215
+
216
+ The `--continue` flag (or `-c` for short) allows you to:
217
+ - Resume the most recent conversation when used without an ID
218
+ - Resume a specific conversation when provided with a message ID
219
+ - Maintain context across multiple interactions for complex tasks
220
+
221
+ This feature is particularly useful for:
222
+ - Multi-step development tasks
223
+ - Iterative code improvements
224
+ - Continuing discussions after system interruptions
225
+ - Maintaining context when working on complex problems
226
+
152
227
  ## ⚙️ Dependencies
153
228
 
154
229
  Janito automatically installs the following dependencies:
@@ -157,6 +232,28 @@ Janito automatically installs the following dependencies:
157
232
  - claudine - For Claude AI integration
158
233
  - Additional packages for file handling and web content extraction
159
234
 
235
+ ## 🛠️ Command-Line Options
236
+
237
+ Janito offers a variety of command-line options to customize its behavior:
238
+
239
+ ```
240
+ --verbose, -v Enable verbose mode with detailed output
241
+ --show-tokens Show detailed token usage and pricing information
242
+ --workspace, -w TEXT Set the workspace directory
243
+ --set-config TEXT Configuration string in format 'key=value', e.g., 'temperature=0.7'
244
+ --show-config Show current configuration
245
+ --reset-config Reset configuration by removing the config file
246
+ --set-api-key TEXT Set the Anthropic API key globally in the user's home directory
247
+ --ask Enable ask mode which disables tools that perform changes
248
+ --trust, -t Enable trust mode which suppresses tool outputs for concise execution
249
+ --temperature FLOAT Set the temperature for model generation (0.0 to 1.0)
250
+ --profile TEXT Use a predefined parameter profile (precise, balanced, conversational, creative, technical)
251
+ --role TEXT Set the assistant's role (default: 'software engineer')
252
+ --version Show the version and exit
253
+ --continue, -c TEXT Continue a previous conversation, optionally with a specific message ID
254
+ --help Show the help message and exit
255
+ ```
256
+
160
257
  ## 🔑 API Key Configuration
161
258
 
162
259
  You can configure your Anthropic API key in several ways:
@@ -0,0 +1,5 @@
1
+ """
2
+ Janito package.
3
+ """
4
+
5
+ __version__ = "0.13.0"
@@ -7,6 +7,8 @@ import json
7
7
  import anthropic
8
8
  import claudine
9
9
  import typer
10
+ import datetime
11
+ from typing import Optional
10
12
  from rich.console import Console
11
13
  from pathlib import Path
12
14
  from jinja2 import Template
@@ -19,6 +21,7 @@ from janito.tools import str_replace_editor
19
21
  from janito.tools.bash.bash import bash_tool
20
22
  from janito.cli.output import display_generation_params
21
23
 
24
+
22
25
  console = Console()
23
26
 
24
27
  def get_api_key() -> str:
@@ -154,12 +157,25 @@ def initialize_agent(temperature: float, verbose: bool) -> claudine.Agent:
154
157
 
155
158
  return agent
156
159
 
160
+ def generate_message_id():
161
+ """
162
+ Generate a message ID based on timestamp with seconds granularity
163
+
164
+ Returns:
165
+ str: A timestamp-based message ID
166
+ """
167
+ timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
168
+ return timestamp
169
+
157
170
  def save_messages(agent):
158
171
  """
159
- Save agent messages to .janito/last_message.json
172
+ Save agent messages to .janito/last_messages/{message_id}.json
160
173
 
161
174
  Args:
162
175
  agent: The claudine agent instance
176
+
177
+ Returns:
178
+ str: The message ID used for saving
163
179
  """
164
180
  try:
165
181
  # Get the workspace directory
@@ -169,49 +185,115 @@ def save_messages(agent):
169
185
  janito_dir = workspace_dir / ".janito"
170
186
  janito_dir.mkdir(exist_ok=True)
171
187
 
188
+ # Create last_messages directory if it doesn't exist
189
+ messages_dir = janito_dir / "last_messages"
190
+ messages_dir.mkdir(exist_ok=True)
191
+
192
+ # Generate a unique message ID
193
+ message_id = generate_message_id()
194
+
172
195
  # Get messages from the agent
173
196
  messages = agent.get_messages()
174
197
 
198
+ # Create a message object with metadata
199
+ message_object = {
200
+ "id": message_id,
201
+ "timestamp": datetime.datetime.now().isoformat(),
202
+ "messages": messages
203
+ }
204
+
175
205
  # Save messages to file
176
- with open(janito_dir / "last_message.json", "w", encoding="utf-8") as f:
177
- json.dump(messages, f, ensure_ascii=False, indent=2)
206
+ message_file = messages_dir / f"{message_id}.json"
207
+ with open(message_file, "w", encoding="utf-8") as f:
208
+ json.dump(message_object, f, ensure_ascii=False, indent=2)
209
+
210
+ # No longer saving to last_message.json for backward compatibility
178
211
 
179
212
  if get_config().verbose:
180
- console.print(f"[bold green]✅ Conversation saved to {janito_dir / 'last_message.json'}[/bold green]")
213
+ console.print(f"[bold green]✅ Conversation saved to {message_file}[/bold green]")
214
+
215
+ return message_id
181
216
  except Exception as e:
182
217
  console.print(f"[bold red]❌ Error saving conversation:[/bold red] {str(e)}")
218
+ return None
183
219
 
184
- def load_messages():
220
+ def load_messages(message_id=None):
185
221
  """
186
- Load messages from .janito/last_message.json
222
+ Load messages from .janito/last_messages/{message_id}.json or the latest message file
187
223
 
224
+ Args:
225
+ message_id: Optional message ID to load specific conversation
226
+
188
227
  Returns:
189
228
  List of message dictionaries or None if file doesn't exist
190
229
  """
191
230
  try:
192
231
  # Get the workspace directory
193
232
  workspace_dir = Path(get_config().workspace_dir)
233
+ janito_dir = workspace_dir / ".janito"
234
+ messages_dir = janito_dir / "last_messages"
235
+
236
+ # If message_id is provided, try to load that specific conversation
237
+ if message_id:
238
+ # Check if the message ID is a file name or just the ID
239
+ if message_id.endswith('.json'):
240
+ message_file = messages_dir / message_id
241
+ else:
242
+ message_file = messages_dir / f"{message_id}.json"
243
+
244
+ if not message_file.exists():
245
+ console.print(f"[bold yellow]⚠️ No conversation found with ID {message_id}[/bold yellow]")
246
+ return None
247
+
248
+ # Load messages from file
249
+ with open(message_file, "r", encoding="utf-8") as f:
250
+ message_object = json.load(f)
251
+
252
+ # Extract messages from the message object
253
+ if isinstance(message_object, dict) and "messages" in message_object:
254
+ messages = message_object["messages"]
255
+ else:
256
+ # Handle legacy format
257
+ messages = message_object
258
+
259
+ if get_config().verbose:
260
+ console.print(f"[bold green]✅ Loaded conversation from {message_file}[/bold green]")
261
+ console.print(f"[dim]📝 Conversation has {len(messages)} messages[/dim]")
262
+
263
+ return messages
194
264
 
195
- # Check if file exists
196
- messages_file = workspace_dir / ".janito" / "last_message.json"
197
- if not messages_file.exists():
265
+ # If no message_id is provided, try to load the latest message from last_messages directory
266
+ if not messages_dir.exists() or not any(messages_dir.iterdir()):
198
267
  console.print("[bold yellow]⚠️ No previous conversation found[/bold yellow]")
199
268
  return None
200
269
 
201
- # Load messages from file
202
- with open(messages_file, "r", encoding="utf-8") as f:
203
- messages = json.load(f)
270
+ # Find the latest message file (based on filename which is a timestamp)
271
+ latest_file = max(
272
+ [f for f in messages_dir.iterdir() if f.is_file() and f.suffix == '.json'],
273
+ key=lambda x: x.stem
274
+ )
275
+
276
+ # Load messages from the latest file
277
+ with open(latest_file, "r", encoding="utf-8") as f:
278
+ message_object = json.load(f)
279
+
280
+ # Extract messages from the message object
281
+ if isinstance(message_object, dict) and "messages" in message_object:
282
+ messages = message_object["messages"]
283
+ else:
284
+ # Handle legacy format
285
+ messages = message_object
204
286
 
205
287
  if get_config().verbose:
206
- console.print(f"[bold green]✅ Loaded previous conversation from {messages_file}[/bold green]")
288
+ console.print(f"[bold green]✅ Loaded latest conversation from {latest_file}[/bold green]")
207
289
  console.print(f"[dim]📝 Conversation has {len(messages)} messages[/dim]")
208
290
 
209
291
  return messages
210
292
  except Exception as e:
211
- console.print(f"[bold red]❌ Error loading previous conversation:[/bold red] {str(e)}")
293
+ console.print(f"[bold red]❌ Error loading conversation:[/bold red] {str(e)}")
212
294
  return None
213
295
 
214
- def handle_query(query: str, temperature: float, verbose: bool, show_tokens: bool, continue_conversation: bool = False) -> None:
296
+ def handle_query(query: str, temperature: float, verbose: bool, show_tokens: bool, continue_conversation: Optional[str] = None) -> None:
215
297
  """
216
298
  Handle a query by initializing the agent and sending the query.
217
299
 
@@ -220,24 +302,29 @@ def handle_query(query: str, temperature: float, verbose: bool, show_tokens: boo
220
302
  temperature: Temperature value for model generation
221
303
  verbose: Whether to enable verbose mode
222
304
  show_tokens: Whether to show detailed token usage
223
- continue_conversation: Whether to continue the previous conversation
305
+ continue_conversation: Optional message ID to continue a specific conversation
224
306
  """
225
307
  # Initialize the agent
226
308
  agent = initialize_agent(temperature, verbose)
227
309
 
228
310
  # Load previous messages if continuing conversation
229
- if continue_conversation:
230
- messages = load_messages()
311
+ if continue_conversation is not None:
312
+ # If continue_conversation is an empty string (from flag with no value), use default behavior
313
+ message_id = None if continue_conversation == "" else continue_conversation
314
+ messages = load_messages(message_id)
231
315
  if messages:
232
316
  agent.set_messages(messages)
233
- console.print("[bold blue]🔄 Continuing previous conversation[/bold blue]")
317
+ if message_id:
318
+ console.print(f"[bold blue]🔄 Continuing conversation with ID: {message_id}[/bold blue]")
319
+ else:
320
+ console.print("[bold blue]🔄 Continuing previous conversation[/bold blue]")
234
321
 
235
322
  # Send the query to the agent
236
323
  try:
237
324
  agent.query(query)
238
325
 
239
- # Save messages after successful query
240
- save_messages(agent)
326
+ # Save messages after successful query and get the message ID
327
+ message_id = save_messages(agent)
241
328
 
242
329
  # Print token usage report
243
330
  if show_tokens:
@@ -249,13 +336,26 @@ def handle_query(query: str, temperature: float, verbose: bool, show_tokens: boo
249
336
  # Print tool usage statistics
250
337
  from janito.tools import print_usage_stats
251
338
  print_usage_stats()
339
+
340
+ # Show message about continuing this conversation
341
+ if message_id:
342
+ script_name = "janito"
343
+ try:
344
+ # Check if we're running from the entry point script or as a module
345
+ if sys.argv[0].endswith(('janito', 'janito.exe')):
346
+ console.print(f"[bold green]💬 This conversation can be continued with:[/bold green] {script_name} --continue {message_id} <request>")
347
+ else:
348
+ console.print(f"[bold green]💬 This conversation can be continued with:[/bold green] python -m janito --continue {message_id} <request>")
349
+ except:
350
+ # Fallback message
351
+ console.print(f"[bold green]💬 This conversation can be continued with:[/bold green] --continue {message_id} <request>")
252
352
 
253
353
  except KeyboardInterrupt:
254
354
  # Handle Ctrl+C by printing token and tool usage information
255
355
  console.print("\n[bold yellow]⚠️ Query interrupted by user (Ctrl+C)[/bold yellow]")
256
356
 
257
357
  # Save messages even if interrupted
258
- save_messages(agent)
358
+ message_id = save_messages(agent)
259
359
 
260
360
  # Print token usage report (even if interrupted)
261
361
  try:
@@ -268,6 +368,19 @@ def handle_query(query: str, temperature: float, verbose: bool, show_tokens: boo
268
368
  # Print tool usage statistics
269
369
  from janito.tools import print_usage_stats
270
370
  print_usage_stats()
371
+
372
+ # Show message about continuing this conversation
373
+ if message_id:
374
+ script_name = "janito"
375
+ try:
376
+ # Check if we're running from the entry point script or as a module
377
+ if sys.argv[0].endswith(('janito', 'janito.exe')):
378
+ console.print(f"[bold green]💬 This conversation can be continued with:[/bold green] {script_name} --continue {message_id} <request>")
379
+ else:
380
+ console.print(f"[bold green]💬 This conversation can be continued with:[/bold green] python -m janito --continue {message_id} <request>")
381
+ except:
382
+ # Fallback message
383
+ console.print(f"[bold green]💬 This conversation can be continued with:[/bold green] --continue {message_id} <request>")
271
384
  except Exception as e:
272
385
  console.print(f"[bold red]❌ Error generating usage report:[/bold red] {str(e)}")
273
386
  if verbose:
@@ -19,18 +19,19 @@ console = Console()
19
19
  def main(ctx: typer.Context,
20
20
  query: Optional[str] = typer.Argument(None, help="Query to send to the claudine agent"),
21
21
  verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose mode with detailed output"),
22
- show_tokens: bool = typer.Option(False, "--show-tokens", "-t", help="Show detailed token usage and pricing information"),
22
+ show_tokens: bool = typer.Option(False, "--show-tokens", "--tokens", help="Show detailed token usage and pricing information"),
23
23
  workspace: Optional[str] = typer.Option(None, "--workspace", "-w", help="Set the workspace directory"),
24
24
  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
25
  show_config: bool = typer.Option(False, "--show-config", help="Show current configuration"),
26
26
  reset_config: bool = typer.Option(False, "--reset-config", help="Reset configuration by removing the config file"),
27
27
  set_api_key: Optional[str] = typer.Option(None, "--set-api-key", help="Set the Anthropic API key globally in the user's home directory"),
28
28
  ask: bool = typer.Option(False, "--ask", help="Enable ask mode which disables tools that perform changes"),
29
+ trust: bool = typer.Option(False, "--trust", "-t", help="Enable trust mode which suppresses tool outputs for a more concise execution (per-session setting)"),
29
30
  temperature: float = typer.Option(0.0, "--temperature", help="Set the temperature for model generation (0.0 to 1.0)"),
30
31
  profile: Optional[str] = typer.Option(None, "--profile", help="Use a predefined parameter profile (precise, balanced, conversational, creative, technical)"),
31
32
  role: Optional[str] = typer.Option(None, "--role", help="Set the assistant's role (default: 'software engineer')"),
32
33
  version: bool = typer.Option(False, "--version", help="Show the version and exit"),
33
- continue_conversation: bool = typer.Option(False, "--continue", "-c", help="Continue the previous conversation")):
34
+ continue_conversation: Optional[str] = typer.Option(None, "--continue", "-c", help="Continue a previous conversation, optionally with a specific message ID")):
34
35
  """
35
36
  Janito CLI tool. If a query is provided without a command, it will be sent to the claudine agent.
36
37
  """
@@ -40,9 +41,16 @@ def main(ctx: typer.Context,
40
41
  # Set ask mode in config
41
42
  get_config().ask_mode = ask
42
43
 
44
+ # Set trust mode in config
45
+ get_config().trust_mode = trust
46
+
43
47
  # Show a message if ask mode is enabled
44
48
  if ask:
45
49
  console.print("[bold yellow]⚠️ Ask Mode enabled:[/bold yellow] 🔒 Tools that perform changes are disabled")
50
+
51
+ # Show a message if trust mode is enabled
52
+ if trust:
53
+ console.print("[bold blue]⚡ Trust Mode enabled:[/bold blue] Tool outputs are suppressed for concise execution (per-session setting)")
46
54
 
47
55
  # Show version and exit if requested
48
56
  if version:
@@ -285,7 +285,7 @@ def handle_config_commands(
285
285
  set_api_key: Optional[str],
286
286
  config_str: Optional[str],
287
287
  query: Optional[str],
288
- continue_conversation: bool = False
288
+ continue_conversation: Optional[str] = None
289
289
  ) -> bool:
290
290
  """
291
291
  Handle all configuration-related commands.
@@ -300,7 +300,7 @@ def handle_config_commands(
300
300
  set_api_key: API key
301
301
  config_str: Configuration string in format 'key=value'
302
302
  query: Query string
303
- continue_conversation: Whether to continue the previous conversation
303
+ continue_conversation: Optional message ID to continue a specific conversation
304
304
 
305
305
  Returns:
306
306
  bool: True if the program should exit after these operations