janito 0.11.0__py3-none-any.whl → 0.13.0__py3-none-any.whl
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.
- janito/__init__.py +1 -1
- janito/__main__.py +6 -204
- janito/callbacks.py +34 -132
- janito/cli/__init__.py +6 -0
- janito/cli/agent.py +400 -0
- janito/cli/app.py +94 -0
- janito/cli/commands.py +329 -0
- janito/cli/output.py +29 -0
- janito/cli/utils.py +22 -0
- janito/config.py +358 -121
- janito/data/instructions_template.txt +28 -0
- janito/token_report.py +154 -145
- janito/tools/__init__.py +38 -21
- janito/tools/bash/bash.py +84 -0
- janito/tools/bash/unix_persistent_bash.py +184 -0
- janito/tools/bash/win_persistent_bash.py +308 -0
- janito/tools/decorators.py +2 -13
- janito/tools/delete_file.py +27 -9
- janito/tools/fetch_webpage/__init__.py +34 -0
- janito/tools/fetch_webpage/chunking.py +76 -0
- janito/tools/fetch_webpage/core.py +155 -0
- janito/tools/fetch_webpage/extractors.py +276 -0
- janito/tools/fetch_webpage/news.py +137 -0
- janito/tools/fetch_webpage/utils.py +108 -0
- janito/tools/find_files.py +106 -44
- janito/tools/move_file.py +72 -0
- janito/tools/prompt_user.py +37 -6
- janito/tools/replace_file.py +31 -4
- janito/tools/rich_console.py +176 -0
- janito/tools/search_text.py +35 -22
- janito/tools/str_replace_editor/editor.py +7 -4
- janito/tools/str_replace_editor/handlers/__init__.py +16 -0
- janito/tools/str_replace_editor/handlers/create.py +60 -0
- janito/tools/str_replace_editor/handlers/insert.py +100 -0
- janito/tools/str_replace_editor/handlers/str_replace.py +94 -0
- janito/tools/str_replace_editor/handlers/undo.py +64 -0
- janito/tools/str_replace_editor/handlers/view.py +159 -0
- janito/tools/str_replace_editor/utils.py +0 -1
- janito/tools/usage_tracker.py +136 -0
- janito-0.13.0.dist-info/METADATA +300 -0
- janito-0.13.0.dist-info/RECORD +47 -0
- janito/chat_history.py +0 -117
- janito/data/instructions.txt +0 -4
- janito/tools/bash.py +0 -22
- janito/tools/str_replace_editor/handlers.py +0 -335
- janito-0.11.0.dist-info/METADATA +0 -86
- janito-0.11.0.dist-info/RECORD +0 -26
- {janito-0.11.0.dist-info → janito-0.13.0.dist-info}/WHEEL +0 -0
- {janito-0.11.0.dist-info → janito-0.13.0.dist-info}/entry_points.txt +0 -0
- {janito-0.11.0.dist-info → janito-0.13.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
"""
|
2
|
+
Tool usage tracking module for Janito.
|
3
|
+
|
4
|
+
This module provides functionality to track tool usage statistics
|
5
|
+
such as files modified, created, deleted, and lines replaced.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from functools import wraps
|
9
|
+
from typing import Dict, Any, Callable
|
10
|
+
import threading
|
11
|
+
|
12
|
+
# Global tracker instance
|
13
|
+
_tracker = None
|
14
|
+
_tracker_lock = threading.Lock()
|
15
|
+
|
16
|
+
class ToolUsageTracker:
|
17
|
+
"""Tracks usage statistics for Janito tools."""
|
18
|
+
|
19
|
+
def __init__(self):
|
20
|
+
self.reset()
|
21
|
+
|
22
|
+
def reset(self):
|
23
|
+
"""Reset all counters to zero."""
|
24
|
+
self.files_modified = 0
|
25
|
+
self.files_created = 0
|
26
|
+
self.files_deleted = 0
|
27
|
+
self.files_moved = 0
|
28
|
+
self.lines_replaced = 0
|
29
|
+
self.lines_delta = 0 # Track the net change in number of lines
|
30
|
+
self.web_requests = 0
|
31
|
+
self.bash_commands = 0
|
32
|
+
self.user_prompts = 0
|
33
|
+
self.search_operations = 0
|
34
|
+
self.file_views = 0
|
35
|
+
self.partial_file_views = 0
|
36
|
+
|
37
|
+
def increment(self, counter_name: str, value: int = 1):
|
38
|
+
"""Increment a specific counter by the given value."""
|
39
|
+
if hasattr(self, counter_name):
|
40
|
+
setattr(self, counter_name, getattr(self, counter_name) + value)
|
41
|
+
|
42
|
+
def get_stats(self) -> Dict[str, int]:
|
43
|
+
"""Get all non-zero statistics as a dictionary."""
|
44
|
+
stats = {}
|
45
|
+
for attr_name in dir(self):
|
46
|
+
if not attr_name.startswith('_') and not callable(getattr(self, attr_name)):
|
47
|
+
value = getattr(self, attr_name)
|
48
|
+
if value > 0:
|
49
|
+
# Convert attribute_name to "Attribute Name" format
|
50
|
+
display_name = ' '.join(word.capitalize() for word in attr_name.split('_'))
|
51
|
+
stats[display_name] = value
|
52
|
+
return stats
|
53
|
+
|
54
|
+
|
55
|
+
def get_tracker() -> ToolUsageTracker:
|
56
|
+
"""Get the global tracker instance."""
|
57
|
+
global _tracker
|
58
|
+
with _tracker_lock:
|
59
|
+
if _tracker is None:
|
60
|
+
_tracker = ToolUsageTracker()
|
61
|
+
return _tracker
|
62
|
+
|
63
|
+
|
64
|
+
def reset_tracker():
|
65
|
+
"""Reset the global tracker."""
|
66
|
+
get_tracker().reset()
|
67
|
+
|
68
|
+
|
69
|
+
def track_usage(counter_name: str, increment_value: int = 1):
|
70
|
+
"""
|
71
|
+
Decorator to track tool usage.
|
72
|
+
|
73
|
+
Args:
|
74
|
+
counter_name: The name of the counter to increment
|
75
|
+
increment_value: Value to increment the counter by (default: 1)
|
76
|
+
"""
|
77
|
+
def decorator(func):
|
78
|
+
@wraps(func)
|
79
|
+
def wrapper(*args, **kwargs):
|
80
|
+
result = func(*args, **kwargs)
|
81
|
+
# Only track successful operations
|
82
|
+
if isinstance(result, tuple) and len(result) >= 2:
|
83
|
+
message, is_error = result[0], result[1]
|
84
|
+
if not is_error:
|
85
|
+
get_tracker().increment(counter_name, increment_value)
|
86
|
+
return result
|
87
|
+
return wrapper
|
88
|
+
return decorator
|
89
|
+
|
90
|
+
|
91
|
+
def count_lines_in_string(old_str: str, new_str: str) -> tuple[int, int]:
|
92
|
+
"""
|
93
|
+
Count the number of lines that differ between old_str and new_str.
|
94
|
+
|
95
|
+
Args:
|
96
|
+
old_str: Original string
|
97
|
+
new_str: New string
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
Tuple of (number of lines that differ, line delta)
|
101
|
+
"""
|
102
|
+
old_lines = old_str.splitlines()
|
103
|
+
new_lines = new_str.splitlines()
|
104
|
+
|
105
|
+
# Calculate the line delta (positive for added lines, negative for removed lines)
|
106
|
+
line_delta = len(new_lines) - len(old_lines)
|
107
|
+
|
108
|
+
# Simple approach: count the total number of lines changed
|
109
|
+
# For tracking purposes, we'll use the max to ensure we don't undercount
|
110
|
+
return max(len(old_lines), len(new_lines)), line_delta
|
111
|
+
|
112
|
+
|
113
|
+
def print_usage_stats():
|
114
|
+
"""Print the current usage statistics if any values are non-zero."""
|
115
|
+
stats = get_tracker().get_stats()
|
116
|
+
if stats:
|
117
|
+
from rich.console import Console
|
118
|
+
|
119
|
+
console = Console()
|
120
|
+
|
121
|
+
# Create a single-line summary of tool usage
|
122
|
+
summary_parts = []
|
123
|
+
for name, value in stats.items():
|
124
|
+
# Format lines delta with a sign
|
125
|
+
if name == "Lines Delta":
|
126
|
+
sign = "+" if value > 0 else "" if value == 0 else "-"
|
127
|
+
formatted_value = f"{sign}{abs(value)}"
|
128
|
+
summary_parts.append(f"{name}: {formatted_value}")
|
129
|
+
else:
|
130
|
+
summary_parts.append(f"{name}: {value}")
|
131
|
+
|
132
|
+
summary = " | ".join(summary_parts)
|
133
|
+
|
134
|
+
# Display with a rule similar to token usage
|
135
|
+
console.rule("[blue]Tool Usage[/blue]")
|
136
|
+
console.print(f"[blue]{summary}[/blue]", justify="center")
|
@@ -0,0 +1,300 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: janito
|
3
|
+
Version: 0.13.0
|
4
|
+
Summary: Janito CLI tool
|
5
|
+
Project-URL: Homepage, https://github.com/joaompinto/janito
|
6
|
+
Author-email: João Pinto <lamego.pinto@gmail.com>
|
7
|
+
License-File: LICENSE
|
8
|
+
Requires-Python: >=3.8
|
9
|
+
Requires-Dist: anthropic>=0.5.0
|
10
|
+
Requires-Dist: beautifulsoup4>=4.13.0
|
11
|
+
Requires-Dist: claudine>=0.1.0
|
12
|
+
Requires-Dist: jinja2>=3.0.0
|
13
|
+
Requires-Dist: lxml-html-clean>=0.4.1
|
14
|
+
Requires-Dist: newspaper3k>=0.2.8
|
15
|
+
Requires-Dist: requests>=2.32.0
|
16
|
+
Requires-Dist: rich>=13.0.0
|
17
|
+
Requires-Dist: trafilatura>=1.6.0
|
18
|
+
Requires-Dist: typer>=0.9.0
|
19
|
+
Description-Content-Type: text/markdown
|
20
|
+
|
21
|
+
# 🤖 Janito
|
22
|
+
|
23
|
+
Janito is a powerful AI-assisted command-line interface (CLI) tool built with Python, leveraging Anthropic's Claude for intelligent code and file management.
|
24
|
+
|
25
|
+
[](https://github.com/joaompinto/janito)
|
26
|
+
|
27
|
+
## ✨ Features
|
28
|
+
|
29
|
+
- 🧠 Intelligent AI assistant powered by Claude
|
30
|
+
- 📁 File management capabilities with real-time output
|
31
|
+
- 🔍 Smart code search and editing
|
32
|
+
- 💻 Interactive terminal interface with rich formatting
|
33
|
+
- 📊 Detailed token usage tracking and cost reporting with cache savings analysis
|
34
|
+
- 🛑 Token and tool usage reporting even when interrupted with Ctrl+C
|
35
|
+
- 🌐 Web page fetching with content extraction capabilities
|
36
|
+
- 🔄 Parameter profiles for optimizing Claude's behavior for different tasks
|
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
|
40
|
+
|
41
|
+
## 🛠️ System Requirements
|
42
|
+
|
43
|
+
- **Python 3.8+** - Janito requires Python 3.8 or higher
|
44
|
+
- **Operating Systems**:
|
45
|
+
- Linux/macOS: Native support
|
46
|
+
- Windows: Requires Git Bash for proper operation of CLI tools
|
47
|
+
- **Anthropic API Key** - Required for Claude AI integration
|
48
|
+
|
49
|
+
## 🛠️ Installation
|
50
|
+
|
51
|
+
```bash
|
52
|
+
# Install directly from PyPI
|
53
|
+
pip install janito
|
54
|
+
```
|
55
|
+
|
56
|
+
### Setting up your API Key
|
57
|
+
|
58
|
+
Janito requires an Anthropic API key to function. You can:
|
59
|
+
1. Set the API key: `janito --set-api-key your_api_key`
|
60
|
+
|
61
|
+
For development or installation from source, please see [README_DEV.md](README_DEV.md).
|
62
|
+
|
63
|
+
## 🚀 Usage Tutorial
|
64
|
+
|
65
|
+
After installation, you can start using Janito right away. Let's walk through a simple tutorial:
|
66
|
+
|
67
|
+
### Getting Started
|
68
|
+
|
69
|
+
First, let's check that everything is working:
|
70
|
+
|
71
|
+
```bash
|
72
|
+
# Get help and see available commands
|
73
|
+
janito --help
|
74
|
+
```
|
75
|
+
|
76
|
+
### Tutorial: Creating a Simple Project
|
77
|
+
|
78
|
+
Let's create a simple HTML project with Janito's help:
|
79
|
+
|
80
|
+
After installing Janito, using your prefered editor and/or terminal, go to a new empty folder.
|
81
|
+
|
82
|
+
Use the janito command to create a new project.
|
83
|
+
|
84
|
+
```bash
|
85
|
+
# Step 1: Create a new project structure
|
86
|
+
janito "Create a simple HTML page with a calculator and 3 columns with text for the 3 main activities of the Kazakh culture"
|
87
|
+
```
|
88
|
+
Browse the resulting html page.
|
89
|
+
|
90
|
+
### Tutorial: Adding Features
|
91
|
+
|
92
|
+
Now, let's enhance our example
|
93
|
+
|
94
|
+
```bash
|
95
|
+
# Step 2: Add multiplication and division features
|
96
|
+
janito "Add some svg icons and remove the calculator"
|
97
|
+
|
98
|
+
```
|
99
|
+
|
100
|
+
Refresh the page
|
101
|
+
|
102
|
+
### Exploring More Features
|
103
|
+
|
104
|
+
Janito offers many more capabilities:
|
105
|
+
|
106
|
+
```bash
|
107
|
+
# Show detailed token usage and cost information
|
108
|
+
janito --show-tokens "Explain what is in the project"
|
109
|
+
|
110
|
+
# Use a specific parameter profile for creative tasks
|
111
|
+
janito --profile creative "Write a fun description for our project"
|
112
|
+
|
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"
|
124
|
+
|
125
|
+
# Show current configuration and available profiles
|
126
|
+
janito --show-config
|
127
|
+
|
128
|
+
# You can press Ctrl+C at any time to interrupt a query
|
129
|
+
# Janito will still display token and tool usage information
|
130
|
+
# Even interrupted conversations can be continued with --continue
|
131
|
+
```
|
132
|
+
|
133
|
+
## 🔧 Available Tools
|
134
|
+
|
135
|
+
Janito comes with several built-in tools:
|
136
|
+
- 📄 `str_replace_editor` - View, create, and edit files
|
137
|
+
- 🔎 `find_files` - Find files matching patterns
|
138
|
+
- 🗑️ `delete_file` - Delete files
|
139
|
+
- 🔍 `search_text` - Search for text patterns in files
|
140
|
+
- 🌐 `fetch_webpage` - Fetch and extract content from web pages
|
141
|
+
- 📋 `move_file` - Move files from one location to another
|
142
|
+
- 💻 `bash` - Execute bash commands with real-time output display
|
143
|
+
|
144
|
+
## 📊 Usage Tracking
|
145
|
+
|
146
|
+
Janito includes a comprehensive token usage tracking system that helps you monitor API costs:
|
147
|
+
|
148
|
+
- **Basic tracking**: By default, Janito displays a summary of token usage and cost after each query
|
149
|
+
- **Detailed reporting**: Use the `--show-tokens` flag to see detailed breakdowns including:
|
150
|
+
- Input and output token counts
|
151
|
+
- Per-tool token usage statistics
|
152
|
+
- Precise cost calculations
|
153
|
+
- Cache performance metrics with savings analysis
|
154
|
+
- Line delta tracking for file modifications
|
155
|
+
|
156
|
+
```bash
|
157
|
+
# Show detailed token usage and cost information
|
158
|
+
janito --show-tokens "Write a Python function to sort a list"
|
159
|
+
|
160
|
+
# Basic usage (shows simplified token usage summary)
|
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"
|
167
|
+
```
|
168
|
+
|
169
|
+
The usage tracker automatically calculates cache savings, showing you how much you're saving by reusing previous responses.
|
170
|
+
|
171
|
+
## 📋 Parameter Profiles
|
172
|
+
|
173
|
+
Janito offers predefined parameter profiles to optimize Claude's behavior for different tasks:
|
174
|
+
|
175
|
+
- **precise**: Factual answers, documentation, structured data (temperature: 0.2)
|
176
|
+
- **balanced**: Professional writing, summarization, everyday tasks (temperature: 0.5)
|
177
|
+
- **conversational**: Natural dialogue, educational content (temperature: 0.7)
|
178
|
+
- **creative**: Storytelling, brainstorming, marketing copy (temperature: 0.9)
|
179
|
+
- **technical**: Code generation, debugging, technical problem-solving (temperature: 0.3)
|
180
|
+
|
181
|
+
```bash
|
182
|
+
# Use a specific profile
|
183
|
+
janito --profile creative "Write a poem about coding"
|
184
|
+
|
185
|
+
# View available profiles
|
186
|
+
janito --show-config
|
187
|
+
```
|
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
|
+
|
247
|
+
## ⚙️ Dependencies
|
248
|
+
|
249
|
+
Janito automatically installs the following dependencies:
|
250
|
+
- typer (>=0.9.0) - For CLI interface
|
251
|
+
- rich (>=13.0.0) - For rich text formatting
|
252
|
+
- claudine - For Claude AI integration
|
253
|
+
- Additional packages for file handling and web content extraction
|
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
|
+
|
277
|
+
## 🔑 API Key Configuration
|
278
|
+
|
279
|
+
You can configure your Anthropic API key in several ways:
|
280
|
+
|
281
|
+
```bash
|
282
|
+
# Option 1: Set as environment variable
|
283
|
+
export ANTHROPIC_API_KEY=your_api_key
|
284
|
+
|
285
|
+
# Option 2: Configure globally within Janito
|
286
|
+
janito --set-api-key your_api_key
|
287
|
+
|
288
|
+
# Option 3: Let Janito prompt you on first use
|
289
|
+
janito "Hello, I'm new to Janito!"
|
290
|
+
```
|
291
|
+
|
292
|
+
Your API key is securely stored and used for all future sessions.
|
293
|
+
|
294
|
+
## 💻 Development
|
295
|
+
|
296
|
+
For development instructions, please refer to [README_DEV.md](README_DEV.md).
|
297
|
+
|
298
|
+
## 📜 License
|
299
|
+
|
300
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
janito/__init__.py,sha256=5Cnu7sPJURDSY1cnxtGvzs0MpwHUsh5zYZRNQ2LkM8k,53
|
2
|
+
janito/__main__.py,sha256=Oy-Nc1tZkpyvTKuq1R8oHSuJTkvptN6H93kIHBu7DKY,107
|
3
|
+
janito/callbacks.py,sha256=E1FPXYHZUgiEGMabYuf999PSf_Su4ByHOWlc1-hMqWE,915
|
4
|
+
janito/config.py,sha256=MHfloii_OnOVcV4pbunfdnAv8uJzxu_ytDK34Rj8yZ8,13221
|
5
|
+
janito/test_file.py,sha256=c6GWGdTYG3z-Y5XBao9Tmhmq3G-v0L37OfwLgBo8zIU,126
|
6
|
+
janito/token_report.py,sha256=Mks7o2yTxPChgQyBJNoQ5eMmrhSgEM4LKCKi2tHJbVo,9580
|
7
|
+
janito/cli/__init__.py,sha256=dVi9l3E86YyukjxQ-XSUnMZkghnNasXex-X5XAOBiwk,85
|
8
|
+
janito/cli/agent.py,sha256=iFwzbZupkpXQVO0YrQmCGKKQGcqCRdAY3JLg6tZaJiQ,15940
|
9
|
+
janito/cli/app.py,sha256=czgOEWCsWlKeLWMHxPv6fxOStoL2wcC8_QZs6mMtTp8,4643
|
10
|
+
janito/cli/commands.py,sha256=pgassnKENr0DGcZT3tFXtz8MCVuEZwHgxiBktgAik6g,12682
|
11
|
+
janito/cli/output.py,sha256=mo3hUokhrD4SWexUjCbLGGQeCDUf0369DA_i9BW7HjU,933
|
12
|
+
janito/cli/utils.py,sha256=gO4NtCNwtEzYDsQesrFlqB5FtYuw87yGwo4iG3nINgw,661
|
13
|
+
janito/data/instructions_template.txt,sha256=FlyGpNjl2LRBjPWLTK40oKOSH6sveHp5ud35nf_lfs8,1716
|
14
|
+
janito/tools/__init__.py,sha256=hio75FRkxLSQB13We-SCCM7Qa9lMqWCfWhEonHlTr8M,1405
|
15
|
+
janito/tools/decorators.py,sha256=Tp48n5y4LKsjyV3HeOA9wk2dV413RrEG-23kRyQVlKs,2522
|
16
|
+
janito/tools/delete_file.py,sha256=UrZ5q59SIxWfuJcqgol6yPBqL-RhO9lFCF4MqAc6o00,2252
|
17
|
+
janito/tools/find_files.py,sha256=c_N9ETcRPprQeuZYanwFnl-9E05ZqUYhNVoCRS5uqQg,8300
|
18
|
+
janito/tools/move_file.py,sha256=FCs1ghalfHlXmcbAA_IlLcUll9hTOU1MMFGrTWopXvM,2741
|
19
|
+
janito/tools/prompt_user.py,sha256=OnTiWVBCbL_2MYu7oThlKr8X_pnYdG-dzxXSOgJF41c,1942
|
20
|
+
janito/tools/replace_file.py,sha256=i4GoLtS14eKSU5lYI18mJ96S0_ekeHMwlQfazg-fxrM,2296
|
21
|
+
janito/tools/rich_console.py,sha256=0zWYRF8qk4N-upuwswUSEfYFAfkEYDYeCgxst-czWtY,6044
|
22
|
+
janito/tools/search_text.py,sha256=RxbnNeZ3ErCvevwbl60fQAe55QYtU-D9n13iixeDcqQ,9822
|
23
|
+
janito/tools/usage_tracker.py,sha256=IE7GVBDYsX2EDLjsVaVqTeAnT2SAYfcOJvBaH__wHdU,4613
|
24
|
+
janito/tools/bash/bash.py,sha256=AFm0w_z-yyYRWxuR744OFpm5iCZaZpE-pWbnKbgajp4,3665
|
25
|
+
janito/tools/bash/unix_persistent_bash.py,sha256=I59PPQiXHscPJ6Y7ev_83dLFNFWq1hKwAK9kFXdnbBY,7185
|
26
|
+
janito/tools/bash/win_persistent_bash.py,sha256=96xm_yijjc6hBYfNluLahbvR2oUuHug_JkoMah7Hy38,12894
|
27
|
+
janito/tools/fetch_webpage/__init__.py,sha256=0RG0ev-yrfo8gPzt-36WMpVdY2qtMhk2Z-mVpq-7m1o,1076
|
28
|
+
janito/tools/fetch_webpage/chunking.py,sha256=mMtrZeirZ_GnKOOzeG8BijLVpSUI0-TA5Ioqi2HKb1A,2971
|
29
|
+
janito/tools/fetch_webpage/core.py,sha256=3XDvYnC_UbQUNumwWw32hfJhjJUEaPzzoF2yhxhwxos,7764
|
30
|
+
janito/tools/fetch_webpage/extractors.py,sha256=-jrLDRWfWyF2SNOATdRWrqETqnnDLbe2JUWtuyHKFOU,12043
|
31
|
+
janito/tools/fetch_webpage/news.py,sha256=Hp0uNTnRzTa-4hyegQbHSmLeSbkiSpx4cP2oP_hKLEQ,5378
|
32
|
+
janito/tools/fetch_webpage/utils.py,sha256=mkfwefD7U9HOktIwo1eP63v7dpVY-q06COUjaqnTT5M,3412
|
33
|
+
janito/tools/str_replace_editor/__init__.py,sha256=kYmscmQgft3Jzt3oCNz7k2FiRbJvku6OFDDC3Q_zoAA,144
|
34
|
+
janito/tools/str_replace_editor/editor.py,sha256=BckYfiMRUYDfDrbu871qMt2AfZexth_02QhwYYOd53g,2489
|
35
|
+
janito/tools/str_replace_editor/utils.py,sha256=akiPqCHjky_RwL9OitHJJ7uQ-3fNaA8wt_K_YO1EP6I,954
|
36
|
+
janito/tools/str_replace_editor/handlers/__init__.py,sha256=RP6JCeDRIL4R-lTpGowIoOAi64gg6VxZvJGp8Q2UOVU,373
|
37
|
+
janito/tools/str_replace_editor/handlers/create.py,sha256=s8RQE04kDAL7OLZA8WxJkDqTmJlGmCNiit4tIHnmNMo,2470
|
38
|
+
janito/tools/str_replace_editor/handlers/insert.py,sha256=eKHodm2ozKUlRMxWMLAsu9ca6unUo1jfXWwHSld-pSU,4061
|
39
|
+
janito/tools/str_replace_editor/handlers/str_replace.py,sha256=RciLTlA7R2PGljeeyluLcBHUAje9c1OCxm-bFE7j6iY,4473
|
40
|
+
janito/tools/str_replace_editor/handlers/undo.py,sha256=3OIdAWkpXC2iDe94_sfx_WxEFh3a1cRzoP0NtPXq1Ks,2491
|
41
|
+
janito/tools/str_replace_editor/handlers/view.py,sha256=k8F-n64bomHmDjavr5OJKC4cHhfm4_1-aMIFZdMICQo,6809
|
42
|
+
janito/data/instructions_template.txt,sha256=FlyGpNjl2LRBjPWLTK40oKOSH6sveHp5ud35nf_lfs8,1716
|
43
|
+
janito-0.13.0.dist-info/METADATA,sha256=06Vh36jWdwTcsUOpIyRkHybxssdksSoWNvPVE41y1jM,10584
|
44
|
+
janito-0.13.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
45
|
+
janito-0.13.0.dist-info/entry_points.txt,sha256=JMbF_1jg-xQddidpAYkzjOKdw70fy_ymJfcmerY2wIY,47
|
46
|
+
janito-0.13.0.dist-info/licenses/LICENSE,sha256=6-H8LXExbBIAuT4cyiE-Qy8Bad1K4pagQRVTWr6wkhk,1096
|
47
|
+
janito-0.13.0.dist-info/RECORD,,
|
janito/chat_history.py
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Chat history module for Janito.
|
3
|
-
Handles storing and loading chat history.
|
4
|
-
"""
|
5
|
-
import os
|
6
|
-
import json
|
7
|
-
import datetime
|
8
|
-
from pathlib import Path
|
9
|
-
from typing import List, Dict, Any, Optional
|
10
|
-
from janito.config import get_config
|
11
|
-
|
12
|
-
def ensure_chat_history_dir() -> Path:
|
13
|
-
"""
|
14
|
-
Ensure the chat history directory exists.
|
15
|
-
|
16
|
-
Returns:
|
17
|
-
Path: Path to the chat history directory
|
18
|
-
"""
|
19
|
-
workspace_dir = get_config().workspace_dir
|
20
|
-
chat_history_dir = Path(workspace_dir) / ".janito" / "chat_history"
|
21
|
-
chat_history_dir.mkdir(parents=True, exist_ok=True)
|
22
|
-
return chat_history_dir
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def store_conversation(query: str, response: str, agent=None) -> None:
|
27
|
-
"""
|
28
|
-
Store a conversation in the chat history.
|
29
|
-
|
30
|
-
Args:
|
31
|
-
query: The user's query
|
32
|
-
response: The agent's response
|
33
|
-
agent: Optional agent instance for using get_messages method
|
34
|
-
"""
|
35
|
-
chat_history_dir = ensure_chat_history_dir()
|
36
|
-
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
37
|
-
filename = f"{timestamp}.json"
|
38
|
-
|
39
|
-
# Create the conversation data
|
40
|
-
conversation = {
|
41
|
-
"timestamp": timestamp,
|
42
|
-
"query": query,
|
43
|
-
"response": response
|
44
|
-
}
|
45
|
-
|
46
|
-
# Write to file
|
47
|
-
with open(chat_history_dir / filename, "w", encoding="utf-8") as f:
|
48
|
-
json.dump(conversation, f, ensure_ascii=False, indent=2)
|
49
|
-
|
50
|
-
def load_recent_conversations(count: int = 5) -> List[Dict[str, str]]:
|
51
|
-
"""
|
52
|
-
Load the most recent conversations from the chat history.
|
53
|
-
|
54
|
-
Args:
|
55
|
-
count: Number of conversations to load
|
56
|
-
|
57
|
-
Returns:
|
58
|
-
List[Dict[str, str]]: List of conversations
|
59
|
-
"""
|
60
|
-
chat_history_dir = ensure_chat_history_dir()
|
61
|
-
|
62
|
-
# Get all JSON files in the chat history directory
|
63
|
-
history_files = list(chat_history_dir.glob("*.json"))
|
64
|
-
|
65
|
-
# Sort by filename (which includes timestamp)
|
66
|
-
history_files.sort(reverse=True)
|
67
|
-
|
68
|
-
# Load the most recent conversations
|
69
|
-
conversations = []
|
70
|
-
for file_path in history_files[:count]:
|
71
|
-
try:
|
72
|
-
with open(file_path, "r", encoding="utf-8") as f:
|
73
|
-
conversation = json.load(f)
|
74
|
-
conversations.append(conversation)
|
75
|
-
except Exception as e:
|
76
|
-
print(f"Error loading chat history file {file_path}: {e}")
|
77
|
-
|
78
|
-
return conversations
|
79
|
-
|
80
|
-
def format_conversation_for_context(conversation: Dict[str, str]) -> str:
|
81
|
-
"""
|
82
|
-
Format a conversation for inclusion in the context.
|
83
|
-
|
84
|
-
Args:
|
85
|
-
conversation: The conversation to format
|
86
|
-
|
87
|
-
Returns:
|
88
|
-
str: The formatted conversation
|
89
|
-
"""
|
90
|
-
timestamp = conversation.get("timestamp", "Unknown time")
|
91
|
-
query = conversation.get("query", "")
|
92
|
-
response = conversation.get("response", "")
|
93
|
-
|
94
|
-
formatted_time = datetime.datetime.strptime(timestamp, "%Y%m%d_%H%M%S").strftime("%Y-%m-%d %H:%M:%S")
|
95
|
-
|
96
|
-
return f"--- Conversation from {formatted_time} ---\nUser: {query}\n\nAssistant: {response}\n\n"
|
97
|
-
|
98
|
-
def get_chat_history_context(count: int = 5) -> str:
|
99
|
-
"""
|
100
|
-
Get the chat history formatted for inclusion in the agent's context.
|
101
|
-
|
102
|
-
Args:
|
103
|
-
count: Number of conversations to include
|
104
|
-
|
105
|
-
Returns:
|
106
|
-
str: The formatted chat history
|
107
|
-
"""
|
108
|
-
conversations = load_recent_conversations(count)
|
109
|
-
|
110
|
-
if not conversations:
|
111
|
-
return ""
|
112
|
-
|
113
|
-
context = "# Previous conversations:\n\n"
|
114
|
-
for conversation in conversations:
|
115
|
-
context += format_conversation_for_context(conversation)
|
116
|
-
|
117
|
-
return context
|
janito/data/instructions.txt
DELETED
janito/tools/bash.py
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
from typing import Tuple
|
3
|
-
|
4
|
-
|
5
|
-
def bash_tool(command: str, restart: Optional[bool] = False) -> Tuple[str, bool]:
|
6
|
-
"""
|
7
|
-
A simple bash tool implementation that just prints the command and restart flag.
|
8
|
-
|
9
|
-
Args:
|
10
|
-
command: The bash command to execute
|
11
|
-
restart: Whether to restart the process
|
12
|
-
|
13
|
-
Returns:
|
14
|
-
A tuple containing (output message, is_error flag)
|
15
|
-
"""
|
16
|
-
# In a real implementation, this would execute the command
|
17
|
-
# Here we just print what would be executed
|
18
|
-
output = f"Would execute bash command: '{command}'\n"
|
19
|
-
output += f"Restart flag is set to: {restart}"
|
20
|
-
|
21
|
-
# Return the output with is_error=False
|
22
|
-
return output, False
|