Skip to content

Commit 5daecb2

Browse files
zhujian0805claude
andcommitted
feat: Show which prompts are linked to live files in CLI commands
- Enhanced 'cam prompt list' to show which prompts are linked to live instruction files - Enhanced 'cam prompt status' to display linked prompt for each app/level combination - Enhanced 'cam prompt show-live' to indicate which stored prompt corresponds to each live file - Added persistent tracking of active prompts per app/level in PromptManager - Updated sync operations to record which prompts are active when synced to apps 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5ffa7d5 commit 5daecb2

2 files changed

Lines changed: 213 additions & 34 deletions

File tree

code_assistant_manager/cli/prompts_commands.py

Lines changed: 99 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,36 @@ def list_prompts():
7272

7373
typer.echo(f"\n{Colors.BOLD}Prompts:{Colors.RESET}\n")
7474
for prompt_id, prompt in sorted(prompts.items()):
75+
# Check if this prompt is active for any apps by comparing content
76+
active_apps = []
77+
for app_type in VALID_APP_TYPES:
78+
try:
79+
if app_type == "copilot":
80+
# Copilot uses project level
81+
live_content = manager.get_copilot_instructions()
82+
else:
83+
# Other apps use user level
84+
live_content = manager.get_live_content(app_type, level="user")
85+
86+
if live_content and live_content.strip() == prompt.content.strip():
87+
active_apps.append(app_type.capitalize())
88+
except Exception:
89+
# Ignore errors when checking live content
90+
pass
91+
92+
status_parts = []
7593
if prompt.is_default:
76-
status = f"{Colors.GREEN}★ default{Colors.RESET}"
94+
status_parts.append(f"{Colors.GREEN}★ default{Colors.RESET}")
95+
if active_apps:
96+
status_parts.append(
97+
f"{Colors.BLUE}linked: {', '.join(active_apps)}{Colors.RESET}"
98+
)
99+
100+
if status_parts:
101+
status = " | ".join(status_parts)
77102
else:
78103
status = f"{Colors.CYAN}{Colors.RESET}"
104+
79105
typer.echo(f"{status} {Colors.BOLD}{prompt.name}{Colors.RESET}")
80106
typer.echo(f" {Colors.CYAN}ID:{Colors.RESET} {prompt_id}")
81107
if prompt.description:
@@ -591,6 +617,21 @@ def show_live_prompt(
591617
typer.echo(f"\n{Colors.BOLD}Live prompt for {app}:{Colors.RESET}")
592618
typer.echo(f"{Colors.CYAN}Level:{Colors.RESET} {lvl}")
593619
typer.echo(f"{Colors.CYAN}File:{Colors.RESET} {file_path}")
620+
621+
# Check which prompt is linked to this file
622+
linked_prompt = None
623+
if content:
624+
# Find which stored prompt matches this content
625+
for prompt_id, prompt in manager.get_all().items():
626+
if prompt.content.strip() == content.strip():
627+
linked_prompt = prompt
628+
break
629+
630+
if linked_prompt:
631+
typer.echo(
632+
f"{Colors.BLUE}Linked Prompt:{Colors.RESET} {linked_prompt.name} ({linked_prompt.id})"
633+
)
634+
594635
typer.echo()
595636

596637
if content:
@@ -613,6 +654,21 @@ def _show_copilot(manager: PromptManager, project_dir: Optional[Path]):
613654
typer.echo(f"\n{Colors.BOLD}Live prompt for copilot:{Colors.RESET}")
614655
typer.echo(f"{Colors.CYAN}Level:{Colors.RESET} project")
615656
typer.echo(f"{Colors.CYAN}File:{Colors.RESET} {file_path}")
657+
658+
# Check which prompt is linked to this file
659+
linked_prompt = None
660+
if content:
661+
# Find which stored prompt matches this content
662+
for prompt_id, prompt in manager.get_all().items():
663+
if prompt.content.strip() == content.strip():
664+
linked_prompt = prompt
665+
break
666+
667+
if linked_prompt:
668+
typer.echo(
669+
f"{Colors.BLUE}Linked Prompt:{Colors.RESET} {linked_prompt.name} ({linked_prompt.id})"
670+
)
671+
616672
typer.echo()
617673

618674
if content:
@@ -780,7 +836,7 @@ def show_prompt_status(
780836
for app_type in apps_for_level:
781837
# Handle Copilot specially
782838
if app_type == "copilot":
783-
_show_copilot_status(project_dir)
839+
_show_copilot_status(manager, project_dir)
784840
continue
785841

786842
file_path = get_prompt_file_path(
@@ -790,6 +846,28 @@ def show_prompt_status(
790846
typer.echo(f"{Colors.BOLD}{app_type.capitalize()}:{Colors.RESET}")
791847
typer.echo(f" {Colors.CYAN}File:{Colors.RESET} {file_path}")
792848

849+
# Check which prompt is linked to this file
850+
linked_prompt = None
851+
try:
852+
live_content = manager.get_live_content(
853+
app_type,
854+
level=lvl,
855+
project_dir=project_dir if lvl == "project" else None,
856+
)
857+
if live_content:
858+
# Find which stored prompt matches this content
859+
for prompt_id, prompt in manager.get_all().items():
860+
if prompt.content.strip() == live_content.strip():
861+
linked_prompt = prompt
862+
break
863+
except Exception:
864+
pass
865+
866+
if linked_prompt:
867+
typer.echo(
868+
f" {Colors.BLUE}Linked Prompt:{Colors.RESET} {linked_prompt.name} ({linked_prompt.id})"
869+
)
870+
793871
if file_path and file_path.exists():
794872
content = file_path.read_text(encoding="utf-8")
795873
if content.strip():
@@ -805,14 +883,32 @@ def show_prompt_status(
805883
typer.echo()
806884

807885

808-
def _show_copilot_status(project_dir: Optional[Path]):
886+
def _show_copilot_status(manager: PromptManager, project_dir: Optional[Path]):
809887
"""Helper to show Copilot status."""
810888
base_dir = project_dir or Path.cwd()
811889
file_path = base_dir / ".github" / "copilot-instructions.md"
812890

813891
typer.echo(f"{Colors.BOLD}Copilot:{Colors.RESET}")
814892
typer.echo(f" {Colors.CYAN}File:{Colors.RESET} {file_path}")
815893

894+
# Check which prompt is linked to this file
895+
linked_prompt = None
896+
try:
897+
live_content = manager.get_copilot_instructions(project_dir=project_dir)
898+
if live_content:
899+
# Find which stored prompt matches this content
900+
for prompt_id, prompt in manager.get_all().items():
901+
if prompt.content.strip() == live_content.strip():
902+
linked_prompt = prompt
903+
break
904+
except Exception:
905+
pass
906+
907+
if linked_prompt:
908+
typer.echo(
909+
f" {Colors.BLUE}Linked Prompt:{Colors.RESET} {linked_prompt.name} ({linked_prompt.id})"
910+
)
911+
816912
if file_path.exists():
817913
content = file_path.read_text(encoding="utf-8")
818914
if content.strip():

0 commit comments

Comments
 (0)