janito 2.2.0__py3-none-any.whl → 2.3.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.
Files changed (130) hide show
  1. janito/__init__.py +6 -6
  2. janito/agent/setup_agent.py +14 -5
  3. janito/agent/templates/profiles/system_prompt_template_main.txt.j2 +3 -1
  4. janito/cli/chat_mode/bindings.py +6 -0
  5. janito/cli/chat_mode/session.py +16 -0
  6. janito/cli/chat_mode/shell/autocomplete.py +21 -21
  7. janito/cli/chat_mode/shell/commands/__init__.py +3 -0
  8. janito/cli/chat_mode/shell/commands/clear.py +12 -12
  9. janito/cli/chat_mode/shell/commands/exec.py +27 -0
  10. janito/cli/chat_mode/shell/commands/multi.py +51 -51
  11. janito/cli/chat_mode/shell/commands/tools.py +17 -6
  12. janito/cli/chat_mode/shell/input_history.py +62 -62
  13. janito/cli/chat_mode/shell/session/manager.py +1 -0
  14. janito/cli/chat_mode/toolbar.py +1 -0
  15. janito/cli/cli_commands/list_models.py +35 -35
  16. janito/cli/cli_commands/list_providers.py +9 -9
  17. janito/cli/cli_commands/list_tools.py +53 -53
  18. janito/cli/cli_commands/model_selection.py +50 -50
  19. janito/cli/cli_commands/model_utils.py +13 -2
  20. janito/cli/cli_commands/set_api_key.py +19 -19
  21. janito/cli/cli_commands/show_config.py +51 -51
  22. janito/cli/cli_commands/show_system_prompt.py +62 -62
  23. janito/cli/config.py +2 -1
  24. janito/cli/core/__init__.py +4 -4
  25. janito/cli/core/event_logger.py +59 -59
  26. janito/cli/core/getters.py +3 -1
  27. janito/cli/core/runner.py +165 -148
  28. janito/cli/core/setters.py +5 -1
  29. janito/cli/core/unsetters.py +54 -54
  30. janito/cli/main_cli.py +12 -1
  31. janito/cli/prompt_core.py +5 -2
  32. janito/cli/rich_terminal_reporter.py +22 -3
  33. janito/cli/single_shot_mode/__init__.py +6 -6
  34. janito/cli/single_shot_mode/handler.py +11 -1
  35. janito/cli/verbose_output.py +1 -1
  36. janito/config.py +5 -5
  37. janito/config_manager.py +2 -0
  38. janito/driver_events.py +14 -0
  39. janito/drivers/anthropic/driver.py +113 -113
  40. janito/drivers/azure_openai/driver.py +38 -3
  41. janito/drivers/driver_registry.py +0 -2
  42. janito/drivers/openai/driver.py +196 -36
  43. janito/formatting_token.py +54 -54
  44. janito/i18n/__init__.py +35 -35
  45. janito/i18n/messages.py +23 -23
  46. janito/i18n/pt.py +47 -47
  47. janito/llm/__init__.py +5 -5
  48. janito/llm/agent.py +443 -443
  49. janito/llm/auth.py +1 -0
  50. janito/llm/driver.py +7 -1
  51. janito/llm/driver_config.py +1 -0
  52. janito/llm/driver_config_builder.py +34 -34
  53. janito/llm/driver_input.py +12 -12
  54. janito/llm/message_parts.py +60 -60
  55. janito/llm/model.py +38 -38
  56. janito/llm/provider.py +196 -196
  57. janito/provider_config.py +7 -3
  58. janito/provider_registry.py +176 -158
  59. janito/providers/__init__.py +1 -0
  60. janito/providers/anthropic/model_info.py +22 -22
  61. janito/providers/anthropic/provider.py +2 -2
  62. janito/providers/azure_openai/model_info.py +7 -6
  63. janito/providers/azure_openai/provider.py +30 -2
  64. janito/providers/deepseek/__init__.py +1 -1
  65. janito/providers/deepseek/model_info.py +16 -16
  66. janito/providers/deepseek/provider.py +91 -91
  67. janito/providers/google/model_info.py +21 -29
  68. janito/providers/google/provider.py +49 -38
  69. janito/providers/mistralai/provider.py +2 -2
  70. janito/providers/provider_static_info.py +2 -3
  71. janito/tools/adapters/__init__.py +1 -1
  72. janito/tools/adapters/local/adapter.py +33 -11
  73. janito/tools/adapters/local/ask_user.py +102 -102
  74. janito/tools/adapters/local/copy_file.py +84 -84
  75. janito/tools/adapters/local/create_directory.py +69 -69
  76. janito/tools/adapters/local/create_file.py +82 -82
  77. janito/tools/adapters/local/delete_text_in_file.py +4 -7
  78. janito/tools/adapters/local/fetch_url.py +97 -97
  79. janito/tools/adapters/local/find_files.py +138 -138
  80. janito/tools/adapters/local/get_file_outline/__init__.py +1 -1
  81. janito/tools/adapters/local/get_file_outline/core.py +117 -117
  82. janito/tools/adapters/local/get_file_outline/java_outline.py +40 -40
  83. janito/tools/adapters/local/get_file_outline/markdown_outline.py +14 -14
  84. janito/tools/adapters/local/get_file_outline/python_outline.py +303 -303
  85. janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -156
  86. janito/tools/adapters/local/get_file_outline/search_outline.py +33 -33
  87. janito/tools/adapters/local/move_file.py +3 -13
  88. janito/tools/adapters/local/python_code_run.py +166 -166
  89. janito/tools/adapters/local/python_command_run.py +164 -164
  90. janito/tools/adapters/local/python_file_run.py +163 -163
  91. janito/tools/adapters/local/remove_directory.py +6 -17
  92. janito/tools/adapters/local/remove_file.py +4 -10
  93. janito/tools/adapters/local/replace_text_in_file.py +6 -9
  94. janito/tools/adapters/local/run_bash_command.py +176 -176
  95. janito/tools/adapters/local/run_powershell_command.py +219 -219
  96. janito/tools/adapters/local/search_text/__init__.py +1 -1
  97. janito/tools/adapters/local/search_text/core.py +201 -201
  98. janito/tools/adapters/local/search_text/match_lines.py +1 -1
  99. janito/tools/adapters/local/search_text/pattern_utils.py +73 -73
  100. janito/tools/adapters/local/search_text/traverse_directory.py +145 -145
  101. janito/tools/adapters/local/validate_file_syntax/__init__.py +1 -1
  102. janito/tools/adapters/local/validate_file_syntax/core.py +106 -106
  103. janito/tools/adapters/local/validate_file_syntax/css_validator.py +35 -35
  104. janito/tools/adapters/local/validate_file_syntax/html_validator.py +93 -93
  105. janito/tools/adapters/local/validate_file_syntax/js_validator.py +27 -27
  106. janito/tools/adapters/local/validate_file_syntax/json_validator.py +6 -6
  107. janito/tools/adapters/local/validate_file_syntax/markdown_validator.py +109 -109
  108. janito/tools/adapters/local/validate_file_syntax/ps1_validator.py +32 -32
  109. janito/tools/adapters/local/validate_file_syntax/python_validator.py +5 -5
  110. janito/tools/adapters/local/validate_file_syntax/xml_validator.py +11 -11
  111. janito/tools/adapters/local/validate_file_syntax/yaml_validator.py +6 -6
  112. janito/tools/adapters/local/view_file.py +167 -167
  113. janito/tools/inspect_registry.py +17 -17
  114. janito/tools/tool_base.py +105 -105
  115. janito/tools/tool_events.py +58 -58
  116. janito/tools/tool_run_exception.py +12 -12
  117. janito/tools/tool_use_tracker.py +81 -81
  118. janito/tools/tool_utils.py +45 -45
  119. janito/tools/tools_adapter.py +78 -6
  120. janito/tools/tools_schema.py +104 -104
  121. janito/version.py +4 -4
  122. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/METADATA +388 -251
  123. janito-2.3.0.dist-info/RECORD +181 -0
  124. janito/drivers/google_genai/driver.py +0 -54
  125. janito/drivers/google_genai/schema_generator.py +0 -67
  126. janito-2.2.0.dist-info/RECORD +0 -182
  127. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/WHEEL +0 -0
  128. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/entry_points.txt +0 -0
  129. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/licenses/LICENSE +0 -0
  130. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/top_level.txt +0 -0
@@ -1,53 +1,53 @@
1
- """
2
- CLI Command: List available tools
3
- """
4
-
5
-
6
- def handle_list_tools(args=None):
7
- from janito.tools.adapters.local.adapter import LocalToolsAdapter
8
- import janito.tools # Ensure all tools are registered
9
-
10
- registry = janito.tools.get_local_tools_adapter()
11
- tools = registry.list_tools()
12
- if tools:
13
- from rich.table import Table
14
- from rich.console import Console
15
- console = Console()
16
- # Get tool instances to check provides_execution and get info
17
- tool_instances = {t.tool_name: t for t in registry.get_tools()}
18
- normal_tools = []
19
- exec_tools = []
20
- for tool in tools:
21
- inst = tool_instances.get(tool, None)
22
- # Extract parameter names from run signature
23
- param_names = []
24
- if inst and hasattr(inst, "run"):
25
- import inspect
26
- sig = inspect.signature(inst.run)
27
- param_names = [p for p in sig.parameters if p != "self"]
28
- info = {
29
- "name": tool,
30
- "params": ", ".join(param_names),
31
- }
32
- if getattr(inst, "provides_execution", False):
33
- exec_tools.append(info)
34
- else:
35
- normal_tools.append(info)
36
- table = Table(title="Registered tools", show_header=True, header_style="bold", show_lines=False, box=None)
37
- table.add_column("Name", style="cyan", no_wrap=True)
38
- table.add_column("Parameters", style="yellow")
39
- for info in normal_tools:
40
- table.add_row(info["name"], info["params"] or "-")
41
- console.print(table)
42
- if exec_tools:
43
- exec_table = Table(title="Execution tools (only available with -x)", show_header=True, header_style="bold", show_lines=False, box=None)
44
- exec_table.add_column("Name", style="cyan", no_wrap=True)
45
- exec_table.add_column("Parameters", style="yellow")
46
- for info in exec_tools:
47
- exec_table.add_row(info["name"], info["params"] or "-")
48
- console.print(exec_table)
49
- else:
50
- print("No tools registered.")
51
- import sys
52
-
53
- sys.exit(0)
1
+ """
2
+ CLI Command: List available tools
3
+ """
4
+
5
+
6
+ def handle_list_tools(args=None):
7
+ from janito.tools.adapters.local.adapter import LocalToolsAdapter
8
+ import janito.tools # Ensure all tools are registered
9
+
10
+ registry = janito.tools.get_local_tools_adapter()
11
+ tools = registry.list_tools()
12
+ if tools:
13
+ from rich.table import Table
14
+ from rich.console import Console
15
+ console = Console()
16
+ # Get tool instances to check provides_execution and get info
17
+ tool_instances = {t.tool_name: t for t in registry.get_tools()}
18
+ normal_tools = []
19
+ exec_tools = []
20
+ for tool in tools:
21
+ inst = tool_instances.get(tool, None)
22
+ # Extract parameter names from run signature
23
+ param_names = []
24
+ if inst and hasattr(inst, "run"):
25
+ import inspect
26
+ sig = inspect.signature(inst.run)
27
+ param_names = [p for p in sig.parameters if p != "self"]
28
+ info = {
29
+ "name": tool,
30
+ "params": ", ".join(param_names),
31
+ }
32
+ if getattr(inst, "provides_execution", False):
33
+ exec_tools.append(info)
34
+ else:
35
+ normal_tools.append(info)
36
+ table = Table(title="Registered tools", show_header=True, header_style="bold", show_lines=False, box=None)
37
+ table.add_column("Name", style="cyan", no_wrap=True)
38
+ table.add_column("Parameters", style="yellow")
39
+ for info in normal_tools:
40
+ table.add_row(info["name"], info["params"] or "-")
41
+ console.print(table)
42
+ if exec_tools:
43
+ exec_table = Table(title="Execution tools (only available with -x)", show_header=True, header_style="bold", show_lines=False, box=None)
44
+ exec_table.add_column("Name", style="cyan", no_wrap=True)
45
+ exec_table.add_column("Parameters", style="yellow")
46
+ for info in exec_tools:
47
+ exec_table.add_row(info["name"], info["params"] or "-")
48
+ console.print(exec_table)
49
+ else:
50
+ print("No tools registered.")
51
+ import sys
52
+
53
+ sys.exit(0)
@@ -1,50 +1,50 @@
1
- """
2
- CLI Command: Validate and set the model provider selection
3
- """
4
-
5
- from janito.cli.config import config
6
-
7
- _provider_instance = None
8
-
9
-
10
- def get_provider_instance():
11
- global _provider_instance
12
- if _provider_instance is None:
13
- _provider_instance = setup_provider()
14
- return _provider_instance
15
-
16
-
17
- def handle_model_selection(args):
18
- if getattr(args, "model", None):
19
- provider_instance = get_provider_instance()
20
- provider_name = getattr(provider_instance, "name", None)
21
- if not provider_name:
22
- print(
23
- "Error: Provider must be specified with --provider or set as default before selecting a model."
24
- )
25
- import sys
26
-
27
- sys.exit(1)
28
- if not validate_model_for_provider(provider_name, args.model):
29
- sys.exit(1)
30
- config.runtime_set("model", args.model)
31
-
32
-
33
- def validate_model_for_provider(provider_name, model_name):
34
- try:
35
- provider_instance = get_provider_instance()
36
- info_dict = provider_instance.get_model_info()
37
- available_names = [
38
- m["name"] for m in info_dict.values() if isinstance(m, dict) and "name" in m
39
- ]
40
- if model_name in available_names:
41
- return True
42
- else:
43
- print(
44
- f"Error: Model '{model_name}' is not available for provider '{provider_name}'."
45
- )
46
- print(f"Available models: {', '.join(available_names)}")
47
- return False
48
- except Exception as e:
49
- print(f"Error validating model for provider '{provider_name}': {e}")
50
- return False
1
+ """
2
+ CLI Command: Validate and set the model provider selection
3
+ """
4
+
5
+ from janito.cli.config import config
6
+
7
+ _provider_instance = None
8
+
9
+
10
+ def get_provider_instance():
11
+ global _provider_instance
12
+ if _provider_instance is None:
13
+ _provider_instance = setup_provider()
14
+ return _provider_instance
15
+
16
+
17
+ def handle_model_selection(args):
18
+ if getattr(args, "model", None):
19
+ provider_instance = get_provider_instance()
20
+ provider_name = getattr(provider_instance, "name", None)
21
+ if not provider_name:
22
+ print(
23
+ "Error: Provider must be specified with --provider or set as default before selecting a model."
24
+ )
25
+ import sys
26
+
27
+ sys.exit(1)
28
+ if not validate_model_for_provider(provider_name, args.model):
29
+ sys.exit(1)
30
+ config.runtime_set("model", args.model)
31
+
32
+
33
+ def validate_model_for_provider(provider_name, model_name):
34
+ try:
35
+ provider_instance = get_provider_instance()
36
+ info_dict = provider_instance.get_model_info()
37
+ available_names = [
38
+ m["name"] for m in info_dict.values() if isinstance(m, dict) and "name" in m
39
+ ]
40
+ if model_name in available_names:
41
+ return True
42
+ else:
43
+ print(
44
+ f"Error: Model '{model_name}' is not available for provider '{provider_name}'."
45
+ )
46
+ print(f"Available models: {', '.join(available_names)}")
47
+ return False
48
+ except Exception as e:
49
+ print(f"Error validating model for provider '{provider_name}': {e}")
50
+ return False
@@ -34,8 +34,19 @@ def _print_models_table(models, provider_name):
34
34
  row = [str(m.get("name", ""))]
35
35
  row.extend(_build_model_row(m, headers, num_fields))
36
36
  table.add_row(*row)
37
- console = Console()
38
- console.print(table)
37
+ import sys
38
+ if sys.stdout.isatty():
39
+ from rich.console import Console
40
+ Console().print(table)
41
+ else:
42
+ # ASCII-friendly fallback table when output is redirected
43
+ print(f"Supported models for provider '{provider_name}'")
44
+ headers_fallback = [h for h in display_headers]
45
+ print(' | '.join(headers_fallback))
46
+ for m in models:
47
+ row = [str(m.get('name', ''))]
48
+ row.extend(_build_model_row(m, headers, num_fields))
49
+ print(' | '.join(row))
39
50
 
40
51
 
41
52
  def _add_table_columns(table, display_headers):
@@ -1,19 +1,19 @@
1
- """
2
- CLI Command: Set API key for the current or selected provider
3
- """
4
-
5
- from janito.provider_config import set_api_key
6
- from janito.llm.auth import LLMAuthManager
7
-
8
-
9
- def handle_set_api_key(args):
10
- api_key = getattr(args, "set_api_key", None)
11
- provider = getattr(args, "provider", None)
12
- if not provider:
13
- print("Error: --set-api-key requires -p/--provider to be specified.")
14
- return
15
- set_api_key(provider, api_key)
16
- auth_manager = LLMAuthManager()
17
- print(
18
- f"API key set for provider '{provider}'. Auth file updated: {auth_manager._auth_file}"
19
- )
1
+ """
2
+ CLI Command: Set API key for the current or selected provider
3
+ """
4
+
5
+ from janito.provider_config import set_api_key
6
+ from janito.llm.auth import LLMAuthManager
7
+
8
+
9
+ def handle_set_api_key(args):
10
+ api_key = getattr(args, "set_api_key", None)
11
+ provider = getattr(args, "provider", None)
12
+ if not provider:
13
+ print("Error: --set-api-key requires -p/--provider to be specified.")
14
+ return
15
+ set_api_key(provider, api_key)
16
+ auth_manager = LLMAuthManager()
17
+ print(
18
+ f"API key set for provider '{provider}'. Auth file updated: {auth_manager._auth_file}"
19
+ )
@@ -1,51 +1,51 @@
1
- from rich.console import Console
2
- from rich.pretty import Pretty
3
-
4
- from janito.config import config
5
- from janito.cli.config import CONFIG_OPTIONS
6
-
7
-
8
- def resolve_effective_model(provider_name):
9
- # Try provider-specific model, then global model, then provider default
10
- provider_cfg = config.get_provider_config(provider_name)
11
- model = provider_cfg.get("model") if provider_cfg else None
12
- if not model:
13
- model = config.get("model")
14
- if not model:
15
- try:
16
- from janito.provider_registry import ProviderRegistry
17
-
18
- provider_class = ProviderRegistry().get_provider(provider_name)
19
- model = getattr(provider_class, "DEFAULT_MODEL", None)
20
- except Exception:
21
- model = None
22
- return model
23
-
24
-
25
- def handle_show_config(args):
26
- console = Console()
27
- provider = config.get("provider")
28
- model = config.get("model")
29
- # Show all providers with their effective model
30
- from janito.provider_registry import ProviderRegistry
31
-
32
- provider_names = []
33
- try:
34
- provider_names = ProviderRegistry()._get_provider_names()
35
- except Exception:
36
- pass
37
- console.print("[bold green]Current configuration:[/bold green]")
38
- console.print(f"[bold yellow]Current provider:[/bold yellow] {provider!r}\n")
39
- if model is not None:
40
- console.print(f"[bold yellow]Global model:[/bold yellow] {model!r}\n")
41
- if provider_names:
42
- console.print("[bold cyan]Provider specific default models:[/bold cyan]")
43
- for pname in provider_names:
44
- eff_model = resolve_effective_model(pname)
45
- prov_cfg = config.get_provider_config(pname)
46
- prov_model = prov_cfg.get("model") if prov_cfg else None
47
- extra = f" (override)" if prov_model else ""
48
- sel = "[default]" if pname == provider else ""
49
- console.print(
50
- f" [bold]{pname}[/bold]{' '+sel if sel else ''}: model = [magenta]{eff_model}[/magenta]{extra}"
51
- )
1
+ from rich.console import Console
2
+ from rich.pretty import Pretty
3
+
4
+ from janito.config import config
5
+ from janito.cli.config import CONFIG_OPTIONS
6
+
7
+
8
+ def resolve_effective_model(provider_name):
9
+ # Try provider-specific model, then global model, then provider default
10
+ provider_cfg = config.get_provider_config(provider_name)
11
+ model = provider_cfg.get("model") if provider_cfg else None
12
+ if not model:
13
+ model = config.get("model")
14
+ if not model:
15
+ try:
16
+ from janito.provider_registry import ProviderRegistry
17
+
18
+ provider_class = ProviderRegistry().get_provider(provider_name)
19
+ model = getattr(provider_class, "DEFAULT_MODEL", None)
20
+ except Exception:
21
+ model = None
22
+ return model
23
+
24
+
25
+ def handle_show_config(args):
26
+ console = Console()
27
+ provider = config.get("provider")
28
+ model = config.get("model")
29
+ # Show all providers with their effective model
30
+ from janito.provider_registry import ProviderRegistry
31
+
32
+ provider_names = []
33
+ try:
34
+ provider_names = ProviderRegistry()._get_provider_names()
35
+ except Exception:
36
+ pass
37
+ console.print("[bold green]Current configuration:[/bold green]")
38
+ console.print(f"[bold yellow]Current provider:[/bold yellow] {provider!r}\n")
39
+ if model is not None:
40
+ console.print(f"[bold yellow]Global model:[/bold yellow] {model!r}\n")
41
+ if provider_names:
42
+ console.print("[bold cyan]Provider specific default models:[/bold cyan]")
43
+ for pname in provider_names:
44
+ eff_model = resolve_effective_model(pname)
45
+ prov_cfg = config.get_provider_config(pname)
46
+ prov_model = prov_cfg.get("model") if prov_cfg else None
47
+ extra = f" (override)" if prov_model else ""
48
+ sel = "[default]" if pname == provider else ""
49
+ console.print(
50
+ f" [bold]{pname}[/bold]{' '+sel if sel else ''}: model = [magenta]{eff_model}[/magenta]{extra}"
51
+ )
@@ -1,62 +1,62 @@
1
- """
2
- CLI Command: Show the resolved system prompt for the main agent (single-shot mode)
3
- """
4
-
5
- from janito.cli.core.runner import prepare_llm_driver_config
6
- from janito.platform_discovery import PlatformDiscovery
7
- from pathlib import Path
8
- from jinja2 import Template
9
- import importlib.resources
10
-
11
-
12
- def handle_show_system_prompt(args):
13
- # Collect modifiers as in JanitoCLI
14
- from janito.cli.main_cli import MODIFIER_KEYS
15
-
16
- modifiers = {
17
- k: getattr(args, k) for k in MODIFIER_KEYS if getattr(args, k, None) is not None
18
- }
19
- provider, llm_driver_config, agent_role = prepare_llm_driver_config(args, modifiers)
20
- if provider is None or llm_driver_config is None:
21
- print("Error: Could not resolve provider or LLM driver config.")
22
- return
23
-
24
- # Prepare context for Jinja2 rendering
25
- context = {}
26
- context["role"] = agent_role or "software developer"
27
- pd = PlatformDiscovery()
28
- context["platform"] = pd.get_platform_name()
29
- context["python_version"] = pd.get_python_version()
30
- context["shell_info"] = pd.detect_shell()
31
-
32
- # Locate and load the system prompt template
33
- templates_dir = (
34
- Path(__file__).parent.parent.parent / "agent" / "templates" / "profiles"
35
- )
36
- template_path = templates_dir / "system_prompt_template_main.txt.j2"
37
- template_content = None
38
- if template_path.exists():
39
- with open(template_path, "r", encoding="utf-8") as file:
40
- template_content = file.read()
41
- else:
42
- # Try package import fallback
43
- try:
44
- with importlib.resources.files("janito.agent.templates.profiles").joinpath(
45
- "system_prompt_template_main.txt.j2"
46
- ).open("r", encoding="utf-8") as file:
47
- template_content = file.read()
48
- except (FileNotFoundError, ModuleNotFoundError, AttributeError):
49
- print(
50
- f"[janito] Could not find system_prompt_template_main.txt.j2 in {template_path} nor in janito.agent.templates.profiles package."
51
- )
52
- print("No system prompt is set or resolved for this configuration.")
53
- return
54
-
55
- template = Template(template_content)
56
- system_prompt = template.render(**context)
57
-
58
- print("\n--- System Prompt (resolved) ---\n")
59
- print(system_prompt)
60
- print("\n-------------------------------\n")
61
- if agent_role:
62
- print(f"[Role: {agent_role}]")
1
+ """
2
+ CLI Command: Show the resolved system prompt for the main agent (single-shot mode)
3
+ """
4
+
5
+ from janito.cli.core.runner import prepare_llm_driver_config
6
+ from janito.platform_discovery import PlatformDiscovery
7
+ from pathlib import Path
8
+ from jinja2 import Template
9
+ import importlib.resources
10
+
11
+
12
+ def handle_show_system_prompt(args):
13
+ # Collect modifiers as in JanitoCLI
14
+ from janito.cli.main_cli import MODIFIER_KEYS
15
+
16
+ modifiers = {
17
+ k: getattr(args, k) for k in MODIFIER_KEYS if getattr(args, k, None) is not None
18
+ }
19
+ provider, llm_driver_config, agent_role = prepare_llm_driver_config(args, modifiers)
20
+ if provider is None or llm_driver_config is None:
21
+ print("Error: Could not resolve provider or LLM driver config.")
22
+ return
23
+
24
+ # Prepare context for Jinja2 rendering
25
+ context = {}
26
+ context["role"] = agent_role or "software developer"
27
+ pd = PlatformDiscovery()
28
+ context["platform"] = pd.get_platform_name()
29
+ context["python_version"] = pd.get_python_version()
30
+ context["shell_info"] = pd.detect_shell()
31
+
32
+ # Locate and load the system prompt template
33
+ templates_dir = (
34
+ Path(__file__).parent.parent.parent / "agent" / "templates" / "profiles"
35
+ )
36
+ template_path = templates_dir / "system_prompt_template_main.txt.j2"
37
+ template_content = None
38
+ if template_path.exists():
39
+ with open(template_path, "r", encoding="utf-8") as file:
40
+ template_content = file.read()
41
+ else:
42
+ # Try package import fallback
43
+ try:
44
+ with importlib.resources.files("janito.agent.templates.profiles").joinpath(
45
+ "system_prompt_template_main.txt.j2"
46
+ ).open("r", encoding="utf-8") as file:
47
+ template_content = file.read()
48
+ except (FileNotFoundError, ModuleNotFoundError, AttributeError):
49
+ print(
50
+ f"[janito] Could not find system_prompt_template_main.txt.j2 in {template_path} nor in janito.agent.templates.profiles package."
51
+ )
52
+ print("No system prompt is set or resolved for this configuration.")
53
+ return
54
+
55
+ template = Template(template_content)
56
+ system_prompt = template.render(**context)
57
+
58
+ print("\n--- System Prompt (resolved) ---\n")
59
+ print(system_prompt)
60
+ print("\n-------------------------------\n")
61
+ if agent_role:
62
+ print(f"[Role: {agent_role}]")
janito/cli/config.py CHANGED
@@ -3,8 +3,9 @@ from janito.config import config
3
3
  CONFIG_OPTIONS = {
4
4
  "api_key": "API key for OpenAI-compatible service (required)", # pragma: allowlist secret
5
5
  "trust": "Trust mode: suppress all console output (bool, default: False)",
6
- "model": "Model name to use (e.g., 'gpt-4.1', 'gpt-4o', 'gpt-4-turbo', 'o3-mini', 'o4-mini')",
6
+ "model": "Model name to use (e.g., 'gpt-4.1', 'gpt-4o', 'gpt-4-turbo', 'o3-mini', 'o4-mini', 'gemini-2.5-flash')",
7
7
  "base_url": "API base URL (OpenAI-compatible endpoint)",
8
+ "azure_deployment_name": "Azure OpenAI deployment name (for Azure endpoints)",
8
9
  "role": "Role description for the Agent Profile (e.g., 'software engineer')",
9
10
  "temperature": "Sampling temperature (float, e.g., 0.0 - 2.0)",
10
11
  "max_tokens": "Maximum tokens for model response (int)",
@@ -1,4 +1,4 @@
1
- """
2
- Core logic, handler classes, and utilities for the main Janito CLI orchestration and sub-command processing.
3
- Contains modules for setters, getters, event logger, and runner pipelines.
4
- """
1
+ """
2
+ Core logic, handler classes, and utilities for the main Janito CLI orchestration and sub-command processing.
3
+ Contains modules for setters, getters, event logger, and runner pipelines.
4
+ """
@@ -1,59 +1,59 @@
1
- """Stub implementation of EventLogger for the CLI event logging system."""
2
-
3
-
4
- class EventLogger:
5
- def __init__(self, debug=False):
6
- self.debug = debug
7
-
8
- def subscribe(self, event_name, callback):
9
- if self.debug:
10
- pass # Add debug subscribe output if needed
11
- # No real subscription logic
12
-
13
- def submit(self, event_name, payload=None):
14
- if self.debug:
15
- pass # Add debug submit output if needed
16
- # No real submission logic
17
-
18
-
19
- def setup_event_logger(args):
20
- debug = getattr(args, "event_debug", False)
21
- event_logger = EventLogger(debug=debug)
22
- print("[EventLog] Event logger is now active (stub implementation)")
23
- return event_logger
24
-
25
-
26
- def setup_event_logger_if_needed(args):
27
- if getattr(args, "event_log", False):
28
- print("[EventLog] Setting up event logger with system bus...")
29
- event_logger = setup_event_logger(args)
30
- from janito.event_bus import event_bus
31
-
32
- def event_logger_handler(event):
33
- from janito.cli.console import shared_console
34
- from rich.pretty import Pretty
35
- from datetime import datetime
36
-
37
- timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
38
- shared_console.print(
39
- f"[EventLog] [dim]{timestamp}[/] [bold green]{event.__class__.__name__}[/] | [cyan]{getattr(event, 'category', '')}[/]"
40
- )
41
- shared_console.print(Pretty(event, expand_all=True))
42
- shared_console.file.flush()
43
-
44
- from janito.event_bus.event import Event
45
-
46
- event_bus.subscribe(Event, event_logger_handler)
47
-
48
-
49
- def inject_debug_event_bus_if_needed(args):
50
- if getattr(args, "event_debug", False):
51
- from janito.event_bus import event_bus
52
-
53
- orig_publish = event_bus.publish
54
-
55
- def debug_publish(event):
56
- # You can enrich here if needed
57
- return orig_publish(event)
58
-
59
- event_bus.publish = debug_publish
1
+ """Stub implementation of EventLogger for the CLI event logging system."""
2
+
3
+
4
+ class EventLogger:
5
+ def __init__(self, debug=False):
6
+ self.debug = debug
7
+
8
+ def subscribe(self, event_name, callback):
9
+ if self.debug:
10
+ pass # Add debug subscribe output if needed
11
+ # No real subscription logic
12
+
13
+ def submit(self, event_name, payload=None):
14
+ if self.debug:
15
+ pass # Add debug submit output if needed
16
+ # No real submission logic
17
+
18
+
19
+ def setup_event_logger(args):
20
+ debug = getattr(args, "event_debug", False)
21
+ event_logger = EventLogger(debug=debug)
22
+ print("[EventLog] Event logger is now active (stub implementation)")
23
+ return event_logger
24
+
25
+
26
+ def setup_event_logger_if_needed(args):
27
+ if getattr(args, "event_log", False):
28
+ print("[EventLog] Setting up event logger with system bus...")
29
+ event_logger = setup_event_logger(args)
30
+ from janito.event_bus import event_bus
31
+
32
+ def event_logger_handler(event):
33
+ from janito.cli.console import shared_console
34
+ from rich.pretty import Pretty
35
+ from datetime import datetime
36
+
37
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
38
+ shared_console.print(
39
+ f"[EventLog] [dim]{timestamp}[/] [bold green]{event.__class__.__name__}[/] | [cyan]{getattr(event, 'category', '')}[/]"
40
+ )
41
+ shared_console.print(Pretty(event, expand_all=True))
42
+ shared_console.file.flush()
43
+
44
+ from janito.event_bus.event import Event
45
+
46
+ event_bus.subscribe(Event, event_logger_handler)
47
+
48
+
49
+ def inject_debug_event_bus_if_needed(args):
50
+ if getattr(args, "event_debug", False):
51
+ from janito.event_bus import event_bus
52
+
53
+ orig_publish = event_bus.publish
54
+
55
+ def debug_publish(event):
56
+ # You can enrich here if needed
57
+ return orig_publish(event)
58
+
59
+ event_bus.publish = debug_publish