janito 0.11.0__tar.gz → 0.12.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 (63) hide show
  1. {janito-0.11.0 → janito-0.12.0}/.gitignore +4 -1
  2. janito-0.12.0/PKG-INFO +203 -0
  3. janito-0.12.0/README.md +183 -0
  4. janito-0.12.0/janito/__init__.py +5 -0
  5. janito-0.12.0/janito/__main__.py +7 -0
  6. janito-0.12.0/janito/callbacks.py +34 -0
  7. janito-0.12.0/janito/cli/__init__.py +6 -0
  8. janito-0.12.0/janito/cli/agent.py +287 -0
  9. janito-0.12.0/janito/cli/app.py +86 -0
  10. janito-0.12.0/janito/cli/commands.py +329 -0
  11. janito-0.12.0/janito/cli/output.py +29 -0
  12. janito-0.12.0/janito/cli/utils.py +22 -0
  13. janito-0.12.0/janito/config.py +338 -0
  14. janito-0.12.0/janito/data/instructions_template.txt +27 -0
  15. janito-0.12.0/janito/token_report.py +154 -0
  16. janito-0.12.0/janito/tools/__init__.py +38 -0
  17. janito-0.12.0/janito/tools/bash/bash.py +82 -0
  18. janito-0.12.0/janito/tools/bash/unix_persistent_bash.py +182 -0
  19. janito-0.12.0/janito/tools/bash/win_persistent_bash.py +306 -0
  20. {janito-0.11.0 → janito-0.12.0}/janito/tools/decorators.py +2 -13
  21. janito-0.12.0/janito/tools/delete_file.py +65 -0
  22. janito-0.12.0/janito/tools/fetch_webpage/__init__.py +34 -0
  23. janito-0.12.0/janito/tools/fetch_webpage/chunking.py +76 -0
  24. janito-0.12.0/janito/tools/fetch_webpage/core.py +155 -0
  25. janito-0.12.0/janito/tools/fetch_webpage/extractors.py +276 -0
  26. janito-0.12.0/janito/tools/fetch_webpage/news.py +137 -0
  27. janito-0.12.0/janito/tools/fetch_webpage/utils.py +108 -0
  28. janito-0.12.0/janito/tools/find_files.py +220 -0
  29. janito-0.12.0/janito/tools/move_file.py +72 -0
  30. janito-0.12.0/janito/tools/prompt_user.py +57 -0
  31. janito-0.12.0/janito/tools/replace_file.py +63 -0
  32. janito-0.12.0/janito/tools/rich_console.py +139 -0
  33. {janito-0.11.0 → janito-0.12.0}/janito/tools/search_text.py +33 -21
  34. {janito-0.11.0 → janito-0.12.0}/janito/tools/str_replace_editor/editor.py +7 -4
  35. janito-0.12.0/janito/tools/str_replace_editor/handlers/__init__.py +16 -0
  36. janito-0.12.0/janito/tools/str_replace_editor/handlers/create.py +60 -0
  37. janito-0.12.0/janito/tools/str_replace_editor/handlers/insert.py +100 -0
  38. janito-0.12.0/janito/tools/str_replace_editor/handlers/str_replace.py +92 -0
  39. janito-0.12.0/janito/tools/str_replace_editor/handlers/undo.py +64 -0
  40. janito-0.12.0/janito/tools/str_replace_editor/handlers/view.py +153 -0
  41. {janito-0.11.0 → janito-0.12.0}/janito/tools/str_replace_editor/utils.py +0 -1
  42. janito-0.12.0/janito/tools/usage_tracker.py +136 -0
  43. janito-0.12.0/pyproject.toml +89 -0
  44. janito-0.11.0/PKG-INFO +0 -86
  45. janito-0.11.0/README.md +0 -73
  46. janito-0.11.0/janito/__init__.py +0 -5
  47. janito-0.11.0/janito/__main__.py +0 -205
  48. janito-0.11.0/janito/callbacks.py +0 -132
  49. janito-0.11.0/janito/chat_history.py +0 -117
  50. janito-0.11.0/janito/config.py +0 -121
  51. janito-0.11.0/janito/data/instructions.txt +0 -4
  52. janito-0.11.0/janito/token_report.py +0 -145
  53. janito-0.11.0/janito/tools/__init__.py +0 -21
  54. janito-0.11.0/janito/tools/bash.py +0 -22
  55. janito-0.11.0/janito/tools/delete_file.py +0 -47
  56. janito-0.11.0/janito/tools/find_files.py +0 -158
  57. janito-0.11.0/janito/tools/prompt_user.py +0 -26
  58. janito-0.11.0/janito/tools/replace_file.py +0 -36
  59. janito-0.11.0/janito/tools/str_replace_editor/handlers.py +0 -335
  60. janito-0.11.0/pyproject.toml +0 -31
  61. {janito-0.11.0 → janito-0.12.0}/LICENSE +0 -0
  62. {janito-0.11.0 → janito-0.12.0}/janito/test_file.py +0 -0
  63. {janito-0.11.0 → janito-0.12.0}/janito/tools/str_replace_editor/__init__.py +0 -0
@@ -100,6 +100,9 @@ venv.bak/
100
100
  # mypy
101
101
  .mypy_cache/
102
102
 
103
+ # Ruff
104
+ .ruff_cache/
105
+
103
106
  # IDE specific files
104
107
  .idea/
105
108
  .vscode/
@@ -107,5 +110,5 @@ venv.bak/
107
110
  *.swo
108
111
 
109
112
  # Janito
110
- .janito/
111
113
  janito-env/
114
+ .janito/
janito-0.12.0/PKG-INFO ADDED
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: janito
3
+ Version: 0.12.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
+ [![GitHub Repository](https://img.shields.io/badge/GitHub-Repository-blue?logo=github)](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
+
39
+ ## 🛠️ System Requirements
40
+
41
+ - **Python 3.8+** - Janito requires Python 3.8 or higher
42
+ - **Operating Systems**:
43
+ - Linux/macOS: Native support
44
+ - Windows: Requires Git Bash for proper operation of CLI tools
45
+ - **Anthropic API Key** - Required for Claude AI integration
46
+
47
+ ## 🛠️ Installation
48
+
49
+ ```bash
50
+ # Install directly from PyPI
51
+ pip install janito
52
+ ```
53
+
54
+ ### Setting up your API Key
55
+
56
+ Janito requires an Anthropic API key to function. You can:
57
+ 1. Set the API key: `janito --set-api-key your_api_key`
58
+
59
+ For development or installation from source, please see [README_DEV.md](README_DEV.md).
60
+
61
+ ## 🚀 Usage Tutorial
62
+
63
+ After installation, you can start using Janito right away. Let's walk through a simple tutorial:
64
+
65
+ ### Getting Started
66
+
67
+ First, let's check that everything is working:
68
+
69
+ ```bash
70
+ # Get help and see available commands
71
+ janito --help
72
+ ```
73
+
74
+ ### Tutorial: Creating a Simple Project
75
+
76
+ Let's create a simple HTML project with Janito's help:
77
+
78
+ After installing Janito, using your prefered editor and/or terminal, go to a new empty folder.
79
+
80
+ Use the janito command to create a new project.
81
+
82
+ ```bash
83
+ # Step 1: Create a new project structure
84
+ janito "Create a simple HTML page with a calculator and 3 columns with text for the 3 main activities of the Kazakh culture"
85
+ ```
86
+ Browse the resulting html page.
87
+
88
+ ### Tutorial: Adding Features
89
+
90
+ Now, let's enhance our example
91
+
92
+ ```bash
93
+ # Step 2: Add multiplication and division features
94
+ janito "Add some svg icons and remove the calculator"
95
+
96
+ ```
97
+
98
+ Refresh the page
99
+
100
+ ### Exploring More Features
101
+
102
+ Janito offers many more capabilities:
103
+
104
+ ```bash
105
+ # Show detailed token usage and cost information
106
+ janito --show-tokens "Explain what is in the project"
107
+
108
+ # Use a specific parameter profile for creative tasks
109
+ janito --profile creative "Write a fun description for our project"
110
+
111
+ # Continue previous conversation
112
+ janito --continue "Plese add one more line"
113
+
114
+ # Show current configuration and available profiles
115
+ janito --show-config
116
+
117
+ # You can press Ctrl+C at any time to interrupt a query
118
+ # Janito will still display token and tool usage information
119
+ ```
120
+
121
+ ## 🔧 Available Tools
122
+
123
+ Janito comes with several built-in tools:
124
+ - 📄 `str_replace_editor` - View, create, and edit files
125
+ - 🔎 `find_files` - Find files matching patterns
126
+ - 🗑️ `delete_file` - Delete files
127
+ - 🔍 `search_text` - Search for text patterns in files
128
+ - 🌐 `fetch_webpage` - Fetch and extract content from web pages
129
+ - 📋 `move_file` - Move files from one location to another
130
+ - 💻 `bash` - Execute bash commands with real-time output display
131
+
132
+ ## 📊 Usage Tracking
133
+
134
+ Janito includes a comprehensive token usage tracking system that helps you monitor API costs:
135
+
136
+ - **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:
138
+ - Input and output token counts
139
+ - Per-tool token usage statistics
140
+ - Precise cost calculations
141
+ - Cache performance metrics with savings analysis
142
+ - Line delta tracking for file modifications
143
+
144
+ ```bash
145
+ # Show detailed token usage and cost information
146
+ janito --show-tokens "Write a Python function to sort a list"
147
+
148
+ # Basic usage (shows simplified token usage summary)
149
+ janito "Explain Docker containers"
150
+ ```
151
+
152
+ The usage tracker automatically calculates cache savings, showing you how much you're saving by reusing previous responses.
153
+
154
+ ## 📋 Parameter Profiles
155
+
156
+ Janito offers predefined parameter profiles to optimize Claude's behavior for different tasks:
157
+
158
+ - **precise**: Factual answers, documentation, structured data (temperature: 0.2)
159
+ - **balanced**: Professional writing, summarization, everyday tasks (temperature: 0.5)
160
+ - **conversational**: Natural dialogue, educational content (temperature: 0.7)
161
+ - **creative**: Storytelling, brainstorming, marketing copy (temperature: 0.9)
162
+ - **technical**: Code generation, debugging, technical problem-solving (temperature: 0.3)
163
+
164
+ ```bash
165
+ # Use a specific profile
166
+ janito --profile creative "Write a poem about coding"
167
+
168
+ # View available profiles
169
+ janito --show-config
170
+ ```
171
+
172
+ ## ⚙️ Dependencies
173
+
174
+ Janito automatically installs the following dependencies:
175
+ - typer (>=0.9.0) - For CLI interface
176
+ - rich (>=13.0.0) - For rich text formatting
177
+ - claudine - For Claude AI integration
178
+ - Additional packages for file handling and web content extraction
179
+
180
+ ## 🔑 API Key Configuration
181
+
182
+ You can configure your Anthropic API key in several ways:
183
+
184
+ ```bash
185
+ # Option 1: Set as environment variable
186
+ export ANTHROPIC_API_KEY=your_api_key
187
+
188
+ # Option 2: Configure globally within Janito
189
+ janito --set-api-key your_api_key
190
+
191
+ # Option 3: Let Janito prompt you on first use
192
+ janito "Hello, I'm new to Janito!"
193
+ ```
194
+
195
+ Your API key is securely stored and used for all future sessions.
196
+
197
+ ## 💻 Development
198
+
199
+ For development instructions, please refer to [README_DEV.md](README_DEV.md).
200
+
201
+ ## 📜 License
202
+
203
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,183 @@
1
+ # 🤖 Janito
2
+
3
+ Janito is a powerful AI-assisted command-line interface (CLI) tool built with Python, leveraging Anthropic's Claude for intelligent code and file management.
4
+
5
+ [![GitHub Repository](https://img.shields.io/badge/GitHub-Repository-blue?logo=github)](https://github.com/joaompinto/janito)
6
+
7
+ ## ✨ Features
8
+
9
+ - 🧠 Intelligent AI assistant powered by Claude
10
+ - 📁 File management capabilities with real-time output
11
+ - 🔍 Smart code search and editing
12
+ - 💻 Interactive terminal interface with rich formatting
13
+ - 📊 Detailed token usage tracking and cost reporting with cache savings analysis
14
+ - 🛑 Token and tool usage reporting even when interrupted with Ctrl+C
15
+ - 🌐 Web page fetching with content extraction capabilities
16
+ - 🔄 Parameter profiles for optimizing Claude's behavior for different tasks
17
+ - 📋 Line delta tracking to monitor net changes in files
18
+
19
+ ## 🛠️ System Requirements
20
+
21
+ - **Python 3.8+** - Janito requires Python 3.8 or higher
22
+ - **Operating Systems**:
23
+ - Linux/macOS: Native support
24
+ - Windows: Requires Git Bash for proper operation of CLI tools
25
+ - **Anthropic API Key** - Required for Claude AI integration
26
+
27
+ ## 🛠️ Installation
28
+
29
+ ```bash
30
+ # Install directly from PyPI
31
+ pip install janito
32
+ ```
33
+
34
+ ### Setting up your API Key
35
+
36
+ Janito requires an Anthropic API key to function. You can:
37
+ 1. Set the API key: `janito --set-api-key your_api_key`
38
+
39
+ For development or installation from source, please see [README_DEV.md](README_DEV.md).
40
+
41
+ ## 🚀 Usage Tutorial
42
+
43
+ After installation, you can start using Janito right away. Let's walk through a simple tutorial:
44
+
45
+ ### Getting Started
46
+
47
+ First, let's check that everything is working:
48
+
49
+ ```bash
50
+ # Get help and see available commands
51
+ janito --help
52
+ ```
53
+
54
+ ### Tutorial: Creating a Simple Project
55
+
56
+ Let's create a simple HTML project with Janito's help:
57
+
58
+ After installing Janito, using your prefered editor and/or terminal, go to a new empty folder.
59
+
60
+ Use the janito command to create a new project.
61
+
62
+ ```bash
63
+ # Step 1: Create a new project structure
64
+ janito "Create a simple HTML page with a calculator and 3 columns with text for the 3 main activities of the Kazakh culture"
65
+ ```
66
+ Browse the resulting html page.
67
+
68
+ ### Tutorial: Adding Features
69
+
70
+ Now, let's enhance our example
71
+
72
+ ```bash
73
+ # Step 2: Add multiplication and division features
74
+ janito "Add some svg icons and remove the calculator"
75
+
76
+ ```
77
+
78
+ Refresh the page
79
+
80
+ ### Exploring More Features
81
+
82
+ Janito offers many more capabilities:
83
+
84
+ ```bash
85
+ # Show detailed token usage and cost information
86
+ janito --show-tokens "Explain what is in the project"
87
+
88
+ # Use a specific parameter profile for creative tasks
89
+ janito --profile creative "Write a fun description for our project"
90
+
91
+ # Continue previous conversation
92
+ janito --continue "Plese add one more line"
93
+
94
+ # Show current configuration and available profiles
95
+ janito --show-config
96
+
97
+ # You can press Ctrl+C at any time to interrupt a query
98
+ # Janito will still display token and tool usage information
99
+ ```
100
+
101
+ ## 🔧 Available Tools
102
+
103
+ Janito comes with several built-in tools:
104
+ - 📄 `str_replace_editor` - View, create, and edit files
105
+ - 🔎 `find_files` - Find files matching patterns
106
+ - 🗑️ `delete_file` - Delete files
107
+ - 🔍 `search_text` - Search for text patterns in files
108
+ - 🌐 `fetch_webpage` - Fetch and extract content from web pages
109
+ - 📋 `move_file` - Move files from one location to another
110
+ - 💻 `bash` - Execute bash commands with real-time output display
111
+
112
+ ## 📊 Usage Tracking
113
+
114
+ Janito includes a comprehensive token usage tracking system that helps you monitor API costs:
115
+
116
+ - **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:
118
+ - Input and output token counts
119
+ - Per-tool token usage statistics
120
+ - Precise cost calculations
121
+ - Cache performance metrics with savings analysis
122
+ - Line delta tracking for file modifications
123
+
124
+ ```bash
125
+ # Show detailed token usage and cost information
126
+ janito --show-tokens "Write a Python function to sort a list"
127
+
128
+ # Basic usage (shows simplified token usage summary)
129
+ janito "Explain Docker containers"
130
+ ```
131
+
132
+ The usage tracker automatically calculates cache savings, showing you how much you're saving by reusing previous responses.
133
+
134
+ ## 📋 Parameter Profiles
135
+
136
+ Janito offers predefined parameter profiles to optimize Claude's behavior for different tasks:
137
+
138
+ - **precise**: Factual answers, documentation, structured data (temperature: 0.2)
139
+ - **balanced**: Professional writing, summarization, everyday tasks (temperature: 0.5)
140
+ - **conversational**: Natural dialogue, educational content (temperature: 0.7)
141
+ - **creative**: Storytelling, brainstorming, marketing copy (temperature: 0.9)
142
+ - **technical**: Code generation, debugging, technical problem-solving (temperature: 0.3)
143
+
144
+ ```bash
145
+ # Use a specific profile
146
+ janito --profile creative "Write a poem about coding"
147
+
148
+ # View available profiles
149
+ janito --show-config
150
+ ```
151
+
152
+ ## ⚙️ Dependencies
153
+
154
+ Janito automatically installs the following dependencies:
155
+ - typer (>=0.9.0) - For CLI interface
156
+ - rich (>=13.0.0) - For rich text formatting
157
+ - claudine - For Claude AI integration
158
+ - Additional packages for file handling and web content extraction
159
+
160
+ ## 🔑 API Key Configuration
161
+
162
+ You can configure your Anthropic API key in several ways:
163
+
164
+ ```bash
165
+ # Option 1: Set as environment variable
166
+ export ANTHROPIC_API_KEY=your_api_key
167
+
168
+ # Option 2: Configure globally within Janito
169
+ janito --set-api-key your_api_key
170
+
171
+ # Option 3: Let Janito prompt you on first use
172
+ janito "Hello, I'm new to Janito!"
173
+ ```
174
+
175
+ Your API key is securely stored and used for all future sessions.
176
+
177
+ ## 💻 Development
178
+
179
+ For development instructions, please refer to [README_DEV.md](README_DEV.md).
180
+
181
+ ## 📜 License
182
+
183
+ 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.12.0"
@@ -0,0 +1,7 @@
1
+ """
2
+ Main entry point for Janito.
3
+ """
4
+ from janito.cli import app
5
+
6
+ if __name__ == "__main__":
7
+ app()
@@ -0,0 +1,34 @@
1
+ """
2
+ Callback functions for tool execution in janito.
3
+ """
4
+
5
+ from rich.console import Console
6
+ from rich.markdown import Markdown
7
+
8
+ from janito.config import get_config
9
+
10
+ # Counter for pre-tool callbacks
11
+ pre_tool_callbacks = 0
12
+
13
+ def text_callback(text: str) -> None:
14
+ """
15
+ Callback function that handles text output from the agent.
16
+
17
+ Args:
18
+ text: Text output from the agent
19
+
20
+ Returns:
21
+ None
22
+ """
23
+ console = Console()
24
+
25
+ # Add debug counter only when debug mode is enabled
26
+ if get_config().debug_mode:
27
+ if not hasattr(text_callback, "counter"):
28
+ text_callback.counter = 1
29
+ console.print(f"[bold blue]DEBUG: Text callback #{text_callback.counter}[/bold blue]")
30
+ text_callback.counter += 1
31
+
32
+ # Print the text with markdown formatting
33
+ console.print(Markdown(text, code_theme="monokai"), end="")
34
+
@@ -0,0 +1,6 @@
1
+ """
2
+ CLI module for Janito.
3
+ """
4
+ from janito.cli.app import app
5
+
6
+ __all__ = ["app"]