janito 0.15.0__py3-none-any.whl → 1.0.1__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.
Files changed (109) hide show
  1. janito/__init__.py +1 -5
  2. janito/__main__.py +3 -5
  3. janito/agent/__init__.py +1 -0
  4. janito/agent/agent.py +96 -0
  5. janito/agent/config.py +113 -0
  6. janito/agent/config_defaults.py +10 -0
  7. janito/agent/conversation.py +107 -0
  8. janito/agent/queued_tool_handler.py +16 -0
  9. janito/agent/runtime_config.py +30 -0
  10. janito/agent/tool_handler.py +124 -0
  11. janito/agent/tools/__init__.py +11 -0
  12. janito/agent/tools/ask_user.py +63 -0
  13. janito/agent/tools/bash_exec.py +58 -0
  14. janito/agent/tools/create_directory.py +19 -0
  15. janito/agent/tools/create_file.py +43 -0
  16. janito/agent/tools/fetch_url.py +48 -0
  17. janito/agent/tools/file_str_replace.py +48 -0
  18. janito/agent/tools/find_files.py +37 -0
  19. janito/agent/tools/gitignore_utils.py +40 -0
  20. janito/agent/tools/move_file.py +37 -0
  21. janito/agent/tools/remove_file.py +19 -0
  22. janito/agent/tools/rich_live.py +37 -0
  23. janito/agent/tools/rich_utils.py +31 -0
  24. janito/agent/tools/search_text.py +41 -0
  25. janito/agent/tools/view_file.py +34 -0
  26. janito/cli/__init__.py +0 -6
  27. janito/cli/_print_config.py +68 -0
  28. janito/cli/_utils.py +8 -0
  29. janito/cli/arg_parser.py +26 -0
  30. janito/cli/config_commands.py +131 -0
  31. janito/cli/logging_setup.py +27 -0
  32. janito/cli/main.py +39 -0
  33. janito/cli/runner.py +138 -0
  34. janito/cli_chat_shell/__init__.py +1 -0
  35. janito/cli_chat_shell/chat_loop.py +148 -0
  36. janito/cli_chat_shell/commands.py +202 -0
  37. janito/cli_chat_shell/config_shell.py +75 -0
  38. janito/cli_chat_shell/load_prompt.py +15 -0
  39. janito/cli_chat_shell/session_manager.py +60 -0
  40. janito/cli_chat_shell/ui.py +136 -0
  41. janito/render_prompt.py +12 -0
  42. janito/templates/system_instructions.j2 +38 -0
  43. janito/web/__init__.py +0 -0
  44. janito/web/__main__.py +17 -0
  45. janito/web/app.py +132 -0
  46. janito-1.0.1.dist-info/METADATA +144 -0
  47. janito-1.0.1.dist-info/RECORD +51 -0
  48. {janito-0.15.0.dist-info → janito-1.0.1.dist-info}/WHEEL +2 -1
  49. janito-1.0.1.dist-info/entry_points.txt +2 -0
  50. {janito-0.15.0.dist-info → janito-1.0.1.dist-info}/licenses/LICENSE +2 -2
  51. janito-1.0.1.dist-info/top_level.txt +1 -0
  52. janito/callbacks.py +0 -34
  53. janito/cli/agent/__init__.py +0 -7
  54. janito/cli/agent/conversation.py +0 -149
  55. janito/cli/agent/initialization.py +0 -168
  56. janito/cli/agent/query.py +0 -112
  57. janito/cli/agent.py +0 -12
  58. janito/cli/app.py +0 -178
  59. janito/cli/commands/__init__.py +0 -12
  60. janito/cli/commands/config.py +0 -30
  61. janito/cli/commands/history.py +0 -119
  62. janito/cli/commands/profile.py +0 -93
  63. janito/cli/commands/validation.py +0 -24
  64. janito/cli/commands/workspace.py +0 -31
  65. janito/cli/commands.py +0 -12
  66. janito/cli/output.py +0 -29
  67. janito/cli/utils.py +0 -22
  68. janito/config/README.md +0 -104
  69. janito/config/__init__.py +0 -16
  70. janito/config/cli/__init__.py +0 -28
  71. janito/config/cli/commands.py +0 -397
  72. janito/config/cli/validators.py +0 -77
  73. janito/config/core/__init__.py +0 -23
  74. janito/config/core/file_operations.py +0 -90
  75. janito/config/core/properties.py +0 -316
  76. janito/config/core/singleton.py +0 -282
  77. janito/config/profiles/__init__.py +0 -8
  78. janito/config/profiles/definitions.py +0 -38
  79. janito/config/profiles/manager.py +0 -80
  80. janito/data/instructions_template.txt +0 -34
  81. janito/token_report.py +0 -154
  82. janito/tools/__init__.py +0 -44
  83. janito/tools/bash/bash.py +0 -157
  84. janito/tools/bash/unix_persistent_bash.py +0 -215
  85. janito/tools/bash/win_persistent_bash.py +0 -341
  86. janito/tools/decorators.py +0 -90
  87. janito/tools/delete_file.py +0 -65
  88. janito/tools/fetch_webpage/__init__.py +0 -23
  89. janito/tools/fetch_webpage/core.py +0 -182
  90. janito/tools/find_files.py +0 -220
  91. janito/tools/move_file.py +0 -72
  92. janito/tools/prompt_user.py +0 -57
  93. janito/tools/replace_file.py +0 -63
  94. janito/tools/rich_console.py +0 -176
  95. janito/tools/search_text.py +0 -226
  96. janito/tools/str_replace_editor/__init__.py +0 -6
  97. janito/tools/str_replace_editor/editor.py +0 -55
  98. janito/tools/str_replace_editor/handlers/__init__.py +0 -16
  99. janito/tools/str_replace_editor/handlers/create.py +0 -60
  100. janito/tools/str_replace_editor/handlers/insert.py +0 -100
  101. janito/tools/str_replace_editor/handlers/str_replace.py +0 -94
  102. janito/tools/str_replace_editor/handlers/undo.py +0 -64
  103. janito/tools/str_replace_editor/handlers/view.py +0 -165
  104. janito/tools/str_replace_editor/utils.py +0 -33
  105. janito/tools/think.py +0 -37
  106. janito/tools/usage_tracker.py +0 -137
  107. janito-0.15.0.dist-info/METADATA +0 -481
  108. janito-0.15.0.dist-info/RECORD +0 -64
  109. janito-0.15.0.dist-info/entry_points.txt +0 -2
janito/cli/app.py DELETED
@@ -1,178 +0,0 @@
1
- """
2
- Main CLI application for Janito.
3
- """
4
- import sys
5
- from typing import Optional
6
- import typer
7
- from rich.console import Console
8
- import importlib.metadata
9
-
10
- from janito import __version__
11
- from janito.config import Config
12
- from janito.cli.commands import handle_config_commands, validate_parameters
13
- from janito.cli.agent import handle_query
14
- from janito.cli.utils import get_stdin_termination_hint
15
-
16
- app = typer.Typer()
17
- console = Console()
18
-
19
- @app.callback(invoke_without_command=True)
20
- def main(ctx: typer.Context,
21
- query: Optional[str] = typer.Argument(None, help="Query to send to the claudine agent"),
22
- verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose mode with detailed output"),
23
- show_tokens: bool = typer.Option(False, "--show-tokens", "--tokens", help="Show detailed token usage and pricing information"),
24
- workspace: Optional[str] = typer.Option(None, "--workspace", "-w", help="Set the workspace directory"),
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)"),
27
- show_config: bool = typer.Option(False, "--show-config", help="Show current configuration"),
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"),
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"),
31
- ask: bool = typer.Option(False, "--ask", help="Enable ask mode which disables tools that perform changes"),
32
- trust: bool = typer.Option(False, "--trust", "-t", help="Enable trust mode which suppresses tool outputs for a more concise execution"),
33
- no_tools: bool = typer.Option(False, "--no-tools", help="Disable all tools for this session (per-session setting, not saved to config)"),
34
- temperature: float = typer.Option(0.0, "--temperature", help="Set the temperature for model generation (0.0 to 1.0)"),
35
- profile: Optional[str] = typer.Option(None, "--profile", help="Use a predefined parameter profile (precise, balanced, conversational, creative, technical)"),
36
- role: Optional[str] = typer.Option(None, "--role", help="Set the assistant's role (default: 'software engineer')"),
37
- system: Optional[str] = typer.Option(None, "--system", "-s", help="Provide custom system instructions, bypassing the default file load method"),
38
- version: bool = typer.Option(False, "--version", help="Show the version and exit"),
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)"),
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")):
41
- """
42
- Janito CLI tool. If a query is provided without a command, it will be sent to the claudine agent.
43
- """
44
- # Set verbose mode in config
45
- Config().verbose = verbose
46
-
47
- # Set ask mode in config
48
- Config().ask_mode = ask
49
-
50
- # Set trust mode in config
51
- Config().trust_mode = trust
52
-
53
- # Set no-tools mode in config
54
- Config().no_tools = no_tools
55
-
56
- # Show a message if ask mode is enabled
57
- if ask:
58
- console.print("[bold yellow]⚠️ Ask Mode enabled:[/bold yellow] 🔒 Tools that perform changes are disabled")
59
-
60
- # Show a message if trust mode is enabled
61
- if trust:
62
- console.print("[bold blue]⚡ Trust Mode enabled:[/bold blue] Tool outputs are suppressed for concise execution")
63
-
64
- # Show a message if no-tools mode is enabled
65
- if no_tools:
66
- console.print("[bold magenta]🚫 No-Tools Mode enabled:[/bold magenta] All tools are disabled for this session")
67
-
68
- # Show version and exit if requested
69
- if version:
70
- console.print(f"🚀 Janito version: {__version__}")
71
- sys.exit(0)
72
-
73
- # Validate temperature
74
- validate_parameters(temperature)
75
-
76
- # Process continue flags before handling other options
77
- continue_conversation = None
78
-
79
- # First, parse continue_flag and continue_id from original sys.argv to avoid typer issues
80
- # This is necessary because typer has trouble with quotes in some edge cases
81
- try:
82
- # Check if --continue or -c is in sys.argv
83
- args = sys.argv
84
-
85
- # Handle the --history flag with optional count parameter
86
- history_count_override = None
87
- if "--history" in args:
88
- history_idx = args.index("--history")
89
- history_flag = True
90
-
91
- # Check if there's a number after --history and it's not another flag
92
- if history_idx + 1 < len(args) and not args[history_idx + 1].startswith("-"):
93
- try:
94
- # Try to convert to int - if successful, it's a count
95
- history_count_override = int(args[history_idx + 1])
96
- except ValueError:
97
- # Not a number, ignore it
98
- pass
99
-
100
- if "--continue" in args or "-c" in args:
101
- continue_idx = args.index("--continue") if "--continue" in args else args.index("-c")
102
-
103
- # Check if there's at least one argument after --continue
104
- if continue_idx + 1 < len(args) and not args[continue_idx + 1].startswith("-"):
105
- # If next arg doesn't start with "-", it's our continue value
106
- continue_value = args[continue_idx + 1]
107
-
108
- # Check if continue_value is a numeric ID or a query
109
- if continue_value.isdigit():
110
- # It's an ID
111
- continue_conversation = continue_value
112
-
113
- # Check if there's a query after the ID
114
- if continue_idx + 2 < len(args) and not args[continue_idx + 2].startswith("-"):
115
- query = args[continue_idx + 2]
116
- else:
117
- # It's a query string for the most recent conversation
118
- continue_conversation = "" # Empty string means continue most recent
119
- query = continue_value
120
-
121
- if verbose:
122
- console.print(f"[bold blue]🔄 Continuing most recent conversation[/bold blue]")
123
- console.print(f"[dim]📝 Query: {query}[/dim]")
124
- else:
125
- # --continue with no args means continue most recent conversation
126
- continue_conversation = ""
127
-
128
- # --continue-id has been removed in favor of --continue
129
- except Exception as e:
130
- if verbose:
131
- console.print(f"[bold yellow]⚠️ Error parsing continue arguments: {str(e)}[/bold yellow]")
132
-
133
- # Fall back to typer-processed args if our parsing failed
134
- if continue_conversation is None:
135
- # Handle the --continue flag option (processed by typer)
136
- if continue_flag is not None:
137
- if continue_flag == "":
138
- continue_conversation = "" # Empty string means continue most recent
139
- elif continue_flag.isdigit():
140
- continue_conversation = continue_flag
141
- else:
142
- continue_conversation = "" # Empty string means continue most recent
143
- query = continue_flag # Use the continue_flag as the query
144
-
145
- # Handle configuration-related commands
146
- exit_after_config = handle_config_commands(
147
- ctx,
148
- False, # reset_config is removed, passing False for backward compatibility
149
- reset_local_config,
150
- reset_global_config,
151
- workspace,
152
- show_config,
153
- profile,
154
- role,
155
- set_api_key,
156
- set_local_config,
157
- set_global_config,
158
- query,
159
- continue_flag,
160
- history_flag,
161
- history_count_override
162
- )
163
-
164
- if exit_after_config:
165
- sys.exit(0)
166
-
167
- # Handle query if no subcommand was invoked
168
- if ctx.invoked_subcommand is None:
169
- # If no query provided in command line, read from stdin
170
- # Only prompt for stdin if query is still None after processing --continue flag
171
- if not query:
172
- console.print("[bold blue]📝 No query provided in command line. Reading from stdin...[/bold blue]")
173
- console.print(get_stdin_termination_hint())
174
- query = sys.stdin.read().strip()
175
-
176
- # Only proceed if we have a query (either from command line or stdin)
177
- if query:
178
- handle_query(query, temperature, verbose, show_tokens, continue_conversation, system)
@@ -1,12 +0,0 @@
1
- """
2
- Command handling logic for Janito CLI.
3
- """
4
- from janito.cli.commands.config import handle_config_commands
5
- from janito.cli.commands.validation import validate_parameters
6
- from janito.cli.commands.history import handle_history
7
-
8
- __all__ = [
9
- "handle_config_commands",
10
- "validate_parameters",
11
- "handle_history",
12
- ]
@@ -1,30 +0,0 @@
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
- ]
@@ -1,119 +0,0 @@
1
- """
2
- History management functions for Janito CLI.
3
- """
4
- import sys
5
- import json
6
- import datetime
7
- from pathlib import Path
8
- from typing import Optional, List, Dict, Any
9
- import typer
10
- from rich.console import Console
11
- from rich.table import Table
12
-
13
- from janito.config import get_config
14
-
15
- console = Console()
16
-
17
- def handle_history(history_flag: bool, history_count: Optional[int], ctx: typer.Context, query: Optional[str]) -> bool:
18
- """
19
- Handle the --history parameter to display conversation history.
20
-
21
- Args:
22
- history_flag: Whether to show history (--history flag)
23
- history_count: Number of history entries to display (value after --history)
24
- ctx: Typer context
25
- query: Query string
26
-
27
- Returns:
28
- bool: True if the program should exit after this operation
29
- """
30
- # Check if --history was used
31
- if history_flag:
32
- try:
33
- # If --history is used with a count value passed from app.py, use that
34
- # If no count is specified, default to 20
35
- count = 20 if history_count is None else history_count
36
-
37
- # Get the workspace directory
38
- workspace_dir = Path(get_config().workspace_dir)
39
- janito_dir = workspace_dir / ".janito"
40
- messages_dir = janito_dir / "last_messages"
41
-
42
- if not messages_dir.exists() or not any(messages_dir.iterdir()):
43
- console.print("[bold yellow]⚠️ No conversation history found[/bold yellow]")
44
- return True # Always exit after displaying history
45
-
46
- # Find all message files and sort by timestamp (newest first)
47
- message_files = [f for f in messages_dir.iterdir() if f.is_file() and f.suffix == '.json']
48
- message_files.sort(key=lambda x: x.stem, reverse=True)
49
-
50
- # Limit to the requested number of entries
51
- message_files = message_files[:count]
52
-
53
- # Create a table for the history
54
- table = Table(title=f"Conversation History (Last {min(count, len(message_files))} Entries)")
55
- table.add_column("ID", style="cyan")
56
- table.add_column("Date", style="green")
57
- table.add_column("Time", style="green")
58
- table.add_column("First Query", style="yellow")
59
-
60
- # Add rows to the table
61
- for file in message_files:
62
- try:
63
- with open(file, "r", encoding="utf-8") as f:
64
- message_object = json.load(f)
65
-
66
- # Extract message ID and timestamp
67
- message_id = message_object.get("id", file.stem)
68
-
69
- # Parse timestamp
70
- timestamp_str = message_object.get("timestamp")
71
- if timestamp_str:
72
- timestamp = datetime.datetime.fromisoformat(timestamp_str)
73
- date_str = timestamp.strftime("%Y-%m-%d")
74
- time_str = timestamp.strftime("%H:%M:%S")
75
- else:
76
- # Fallback to file name which is a timestamp
77
- timestamp_str = file.stem
78
- date_str = timestamp_str[:8] # YYYYMMDD
79
- time_str = timestamp_str[8:] # HHMMSS
80
-
81
- # Format the date and time
82
- if len(date_str) == 8:
83
- date_str = f"{date_str[:4]}-{date_str[4:6]}-{date_str[6:8]}"
84
- if len(time_str) == 6:
85
- time_str = f"{time_str[:2]}:{time_str[2:4]}:{time_str[4:6]}"
86
-
87
- # Extract the first user message
88
- messages = message_object.get("messages", [])
89
- first_query = "N/A"
90
- for msg in messages:
91
- if msg.get("role") == "user":
92
- first_query = msg.get("content", "N/A")
93
- # Truncate long queries
94
- if len(first_query) > 60:
95
- first_query = first_query[:57] + "..."
96
- break
97
-
98
- table.add_row(message_id, date_str, time_str, first_query)
99
- except Exception as e:
100
- table.add_row(file.stem, "Error", "Error", f"Failed to parse: {str(e)}")
101
-
102
- console.print(table)
103
-
104
- # Display information about how to continue conversations
105
- console.print("\n[bold blue]💡 To continue a conversation:[/bold blue]")
106
- script_name = "janito"
107
- if sys.argv[0].endswith(('janito', 'janito.exe')):
108
- console.print(f" {script_name} --continue <ID> <request>")
109
- else:
110
- console.print(f" python -m janito --continue <ID> <request>")
111
-
112
- # If --history flag is used, always exit regardless of whether a query is provided
113
- return True
114
-
115
- except Exception as e:
116
- console.print(f"[bold red]Error displaying history:[/bold red] {str(e)}")
117
- return True # Exit on error
118
-
119
- return False
@@ -1,93 +0,0 @@
1
- """
2
- Profile and role management functions for Janito CLI.
3
- """
4
- import sys
5
- from typing import Optional
6
- import typer
7
- from rich.console import Console
8
-
9
- from janito.config import Config
10
-
11
- console = Console()
12
-
13
- def handle_profile(profile: Optional[str], ctx: typer.Context, query: Optional[str], config_type: str = "session") -> bool:
14
- """
15
- Handle the --profile parameter.
16
-
17
- Args:
18
- profile: Profile name
19
- ctx: Typer context
20
- query: Query string
21
- config_type: Type of configuration to update ("session", "local", or "global")
22
-
23
- Returns:
24
- bool: True if the program should exit after this operation
25
- """
26
- if profile is not None:
27
- try:
28
- # Apply profile
29
- config = Config()
30
- profile_data = config.get_available_profiles()[profile.lower()]
31
-
32
- if config_type == "session":
33
- # Set values directly without saving
34
- config._temperature = profile_data["temperature"]
35
- config._profile = profile.lower()
36
- console.print(f"[bold green]✅ Profile '{profile.lower()}' applied for this session only[/bold green]")
37
- elif config_type in ["local", "global"]:
38
- # Set profile in the specified configuration
39
- config.set_profile(profile.lower(), config_type)
40
- console.print(f"[bold green]✅ Profile '{profile.lower()}' set in {config_type} configuration[/bold green]")
41
- else:
42
- console.print(f"[bold red]Error:[/bold red] Invalid config_type: {config_type}")
43
- return ctx.invoked_subcommand is None and not query
44
-
45
- console.print(f"[dim]📝 Description: {profile_data['description']}[/dim]")
46
-
47
- # Exit after applying profile if no other operation is requested
48
- return ctx.invoked_subcommand is None and not query
49
- except ValueError as e:
50
- console.print(f"[bold red]Error:[/bold red] {str(e)}")
51
- sys.exit(1)
52
-
53
- return False
54
-
55
- def handle_role(role: Optional[str], ctx: typer.Context, query: Optional[str], config_type: str = "session") -> bool:
56
- """
57
- Handle the --role parameter.
58
-
59
- Args:
60
- role: Role name
61
- ctx: Typer context
62
- query: Query string
63
- config_type: Type of configuration to update ("session", "local", or "global")
64
-
65
- Returns:
66
- bool: True if the program should exit after this operation
67
- """
68
- if role is not None:
69
- try:
70
- config = Config()
71
-
72
- if config_type == "session":
73
- # Set role directly without saving
74
- config._role = role
75
- console.print(f"[bold green]✅ Role '{role}' applied for this session only[/bold green]")
76
- elif config_type in ["local", "global"]:
77
- # Set role in the specified configuration
78
- if config_type == "local":
79
- config.role = role, "local"
80
- else:
81
- config.role = role, "global"
82
- console.print(f"[bold green]✅ Role '{role}' set in {config_type} configuration[/bold green]")
83
- else:
84
- console.print(f"[bold red]Error:[/bold red] Invalid config_type: {config_type}")
85
- return ctx.invoked_subcommand is None and not query
86
-
87
- # Exit after applying role if no other operation is requested
88
- return ctx.invoked_subcommand is None and not query
89
- except Exception as e:
90
- console.print(f"[bold red]Error:[/bold red] {str(e)}")
91
- sys.exit(1)
92
-
93
- return False
@@ -1,24 +0,0 @@
1
- """
2
- Parameter validation functions for Janito CLI.
3
- """
4
- import sys
5
- from rich.console import Console
6
-
7
- console = Console()
8
-
9
- def validate_parameters(temperature: float) -> None:
10
- """
11
- Validate temperature parameter.
12
-
13
- Args:
14
- temperature: Temperature value for model generation
15
- """
16
- try:
17
- if temperature < 0.0 or temperature > 1.0:
18
- raise ValueError("Temperature must be between 0.0 and 1.0")
19
-
20
- # We'll use this value directly in the agent initialization but we don't save it to config
21
- # Temperature display is hidden
22
- except ValueError as e:
23
- console.print(f"[bold red]Error:[/bold red] {str(e)}")
24
- sys.exit(1)
@@ -1,31 +0,0 @@
1
- """
2
- Workspace management functions for Janito CLI.
3
- """
4
- import sys
5
- from typing import Optional
6
- from rich.console import Console
7
-
8
- from janito.config import Config
9
-
10
- console = Console()
11
-
12
- def handle_workspace(workspace: Optional[str]) -> bool:
13
- """
14
- Handle the --workspace parameter.
15
-
16
- Args:
17
- workspace: Workspace directory path
18
-
19
- Returns:
20
- bool: True if the program should exit after this operation
21
- """
22
- if workspace:
23
- try:
24
- console.print(f"[bold]📂 Setting workspace directory to: {workspace}[/bold]")
25
- Config().workspace_dir = workspace
26
- console.print(f"[bold green]✅ Workspace directory set to: {Config().workspace_dir}[/bold green]")
27
- except ValueError as e:
28
- console.print(f"[bold red]Error:[/bold red] {str(e)}")
29
- sys.exit(1)
30
-
31
- return False
janito/cli/commands.py DELETED
@@ -1,12 +0,0 @@
1
- """
2
- Command handling logic for Janito CLI.
3
- This module serves as a compatibility layer for the reorganized commands module.
4
- """
5
- # Re-export the functions from the new module structure
6
- from janito.cli.commands import handle_config_commands, validate_parameters, handle_history
7
-
8
- __all__ = [
9
- "handle_config_commands",
10
- "validate_parameters",
11
- "handle_history",
12
- ]
janito/cli/output.py DELETED
@@ -1,29 +0,0 @@
1
- """
2
- Output formatting and display for Janito CLI.
3
- """
4
- from rich.console import Console
5
- from janito.config import get_config
6
-
7
- console = Console()
8
-
9
- def display_generation_params(
10
- temp_to_use: float,
11
- profile_data: dict = None,
12
- temperature: float = 0.0
13
- ) -> None:
14
- """
15
- Display generation parameters in verbose mode.
16
-
17
- Args:
18
- temp_to_use: The temperature value being used
19
- profile_data: The profile data if a profile is being used
20
- temperature: The temperature value from command line
21
- """
22
- # Show profile information if one is active
23
- config = get_config()
24
- if config.profile:
25
- if not profile_data:
26
- profile_data = config.get_available_profiles()[config.profile]
27
- console.print(f"[dim]👤 Using profile: {config.profile} - {profile_data['description']}[/dim]")
28
-
29
- # Temperature, top_k, and top_p information is hidden
janito/cli/utils.py DELETED
@@ -1,22 +0,0 @@
1
- """
2
- Utility functions for the CLI module.
3
- """
4
- import platform
5
- from rich.console import Console
6
-
7
- console = Console()
8
-
9
- def get_stdin_termination_hint():
10
- """
11
- Returns a user-friendly message about how to terminate stdin input
12
- based on the current platform.
13
-
14
- Returns:
15
- str: A message with the key sequence to terminate stdin input
16
- """
17
- system = platform.system()
18
-
19
- if system == "Windows":
20
- return "[bold yellow]Press Ctrl+Z followed by Enter to terminate input[/bold yellow]"
21
- else: # Unix-like systems (Linux, macOS)
22
- return "[bold yellow]Press Ctrl+D to terminate input[/bold yellow]"
janito/config/README.md DELETED
@@ -1,104 +0,0 @@
1
- # Janito Configuration System
2
-
3
- This directory contains the configuration system for Janito. The configuration system is designed to be modular, extensible, and easy to use.
4
-
5
- ## Directory Structure
6
-
7
- ```
8
- janito/config/
9
- ├── __init__.py # Re-exports and backward compatibility
10
- ├── README.md # This file
11
- ├── core/ # Core configuration functionality
12
- │ ├── __init__.py # Re-exports core components
13
- │ ├── singleton.py # Singleton implementation
14
- │ ├── properties.py # Property getters and setters
15
- │ └── file_operations.py # File I/O operations
16
- ├── profiles/ # Profile management
17
- │ ├── __init__.py # Re-exports profile components
18
- │ ├── definitions.py # Profile definitions
19
- │ └── manager.py # Profile management functions
20
- └── cli/ # CLI integration
21
- ├── __init__.py # Re-exports CLI components
22
- ├── commands.py # Command handling functions
23
- └── validators.py # Input validation functions
24
- ```
25
-
26
- ## Core Components
27
-
28
- The core configuration functionality is implemented in the `core` directory:
29
-
30
- - `singleton.py`: Implements the `Config` class as a singleton to ensure only one instance exists
31
- - `properties.py`: Contains property getters and setters for the `Config` class
32
- - `file_operations.py`: Handles file I/O operations for loading and saving configuration files
33
-
34
- ## Profiles
35
-
36
- The `profiles` directory contains functionality related to parameter profiles:
37
-
38
- - `definitions.py`: Defines predefined parameter profiles (precise, balanced, conversational, creative, technical)
39
- - `manager.py`: Provides functions for managing profiles, including getting available profiles and creating custom profiles
40
-
41
- ## CLI Integration
42
-
43
- The `cli` directory contains functionality related to CLI integration:
44
-
45
- - `commands.py`: Implements command handling functions for configuration-related CLI commands
46
- - `validators.py`: Provides validation functions for configuration inputs
47
-
48
- ## Usage
49
-
50
- ### Basic Usage
51
-
52
- ```python
53
- from janito.config import Config
54
-
55
- # Get the singleton instance
56
- config = Config()
57
-
58
- # Access configuration properties
59
- workspace_dir = config.workspace_dir
60
- temperature = config.temperature
61
- role = config.role
62
-
63
- # Set configuration properties
64
- config.temperature = 0.7 # Set runtime value only
65
- config.temperature = (0.7, "local") # Set in local config
66
- config.temperature = (0.7, "global") # Set in global config
67
- ```
68
-
69
- ### Working with Profiles
70
-
71
- ```python
72
- from janito.config import Config, get_available_profiles, get_profile
73
-
74
- # Get available profiles
75
- profiles = get_available_profiles()
76
- for name, data in profiles.items():
77
- print(f"{name}: {data['description']}")
78
-
79
- # Get a specific profile
80
- technical_profile = get_profile("technical")
81
- print(f"Temperature: {technical_profile['temperature']}")
82
-
83
- # Set a profile
84
- config = Config()
85
- config.set_profile("creative", "local")
86
- ```
87
-
88
- ### Configuration Files
89
-
90
- The configuration system uses two configuration files:
91
-
92
- - Global configuration file: `~/.janito/config.json`
93
- - Local configuration file: `.janito/config.json` (in the current workspace directory)
94
-
95
- Local configuration overrides global configuration when both are present.
96
-
97
- ## Extending the Configuration System
98
-
99
- To add a new configuration property:
100
-
101
- 1. Add a property getter and setter in `core/properties.py`
102
- 2. Update the `_apply_config` method in `core/singleton.py` to handle the new property
103
- 3. Add validation in `cli/validators.py` if needed
104
- 4. Update the command handling in `cli/commands.py` to support the new property