From 2382399b9237bb885f099192b0a48c4a28be45fb Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Mon, 27 Apr 2026 12:19:49 +0200 Subject: [PATCH] Improve prompt list CLI function --- CHANGELOG.md | 2 +- src/serena/cli.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7bd2bc..8e85a398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ Status of the `main` branch. Changes prior to the next official version change w * CLI: - Support `serena --version` CLI command for displaying the current version #1347 - - Extend `prompts` subcommand with `print-prompt-template` and `print-cc-system-prompt-override`. + - Extend `prompts` subcommand with `print-prompt-template` and `print-cc-system-prompt-override`, improve `list` subcommand * Clients: - Document workaround to make Claude Code use Serena's tools after recent degradations caused by changes in CC harness and Opus 4.7 release. diff --git a/src/serena/cli.py b/src/serena/cli.py index 6d25a35b..e7407545 100644 --- a/src/serena/cli.py +++ b/src/serena/cli.py @@ -1109,16 +1109,26 @@ class PromptCommands(AutoRegisteringGroup): @staticmethod @click.command( - "list", help="Lists yamls that are used for defining prompts.", context_settings={"max_content_width": _MAX_CONTENT_WIDTH} + "list", help="Lists prompt names and YAML files that can be overridden.", context_settings={"max_content_width": _MAX_CONTENT_WIDTH} ) def list() -> None: + # list prompt names + click.echo("Prompts:") + factory = SerenaPromptFactory() + for key in factory.get_prompt_names(): + template = factory.get_prompt_template(key) + is_overridden = not template.path.startswith(PROMPT_TEMPLATES_DIR_INTERNAL) + click.echo(f" * '{key}' ({template.path if is_overridden else 'default'})") + + # list prompts files + click.echo("\nPrompt files (which you can override with the create-override command):") serena_prompt_yaml_names = [os.path.basename(f) for f in glob.glob(PROMPT_TEMPLATES_DIR_INTERNAL + "/*.yml")] for prompt_yaml_name in serena_prompt_yaml_names: user_prompt_yaml_path = PromptCommands._get_user_prompt_yaml_path(prompt_yaml_name) if os.path.exists(user_prompt_yaml_path): - click.echo(f"{user_prompt_yaml_path} merged with default prompts in {prompt_yaml_name}") + click.echo(f" * {user_prompt_yaml_path} merged with default prompts in {prompt_yaml_name}") else: - click.echo(prompt_yaml_name) + click.echo(f" * {prompt_yaml_name}") @staticmethod @click.command( @@ -1209,7 +1219,7 @@ class PromptCommands(AutoRegisteringGroup): context_settings={"max_content_width": _MAX_CONTENT_WIDTH}, ) def print_cc_system_prompt_override() -> None: - click.echo(SerenaPromptFactory().get_cc_system_prompt_override_template_string()) + click.echo(SerenaPromptFactory().create_cc_system_prompt_override()) _mode = ModeCommands()