Files
NexusOS/synapse/playbook_manager.py
T
jon b0aa0438af Initial commit: NexusOS project + desktop theme baseline
Captures the known-good state after theme consolidation and
consistency reconciliation:
- NexusOS GTK/xfwm4/icon theme assets (assets/themes, management/Mint-Y-Nexus)
- Tightened right-click menus, visible separators, no menu icons
- assets/themes/install-theme.sh: idempotent restore of all wiring
  (symlinks, xfconf xsettings+xfwm4, GTK 3/4 settings.ini)
- .gitignore excludes venv/ollama/models/runtime/db

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 13:39:48 -05:00

42 lines
1.4 KiB
Python

import threading
from typing import List
from .playbooks.store import playbook_store, PlaybookItem
class PlaybookManager:
_lock = threading.Lock()
@classmethod
def _all(cls) -> List[PlaybookItem]:
"""Return all playbooks sorted by order (position 0 is always main)."""
return playbook_store.all_playbooks()
@classmethod
def get_main_playbook(cls) -> PlaybookItem | None:
playbooks = cls._all()
return playbooks[0] if playbooks else None
@classmethod
def get_context_playbooks(cls) -> List[PlaybookItem]:
"""All playbooks after the first — injected as reference context."""
playbooks = cls._all()
return playbooks[1:] if len(playbooks) > 1 else []
@classmethod
def get_system_prompt(cls) -> str:
playbook = cls.get_main_playbook()
return getattr(playbook, "instructions", "") or "" if playbook else ""
@classmethod
def render_prompt(cls, user_message: str, variables: dict | None = None) -> str:
if not variables:
return user_message
result = user_message
for key, value in variables.items():
result = result.replace(f"{{{{{key}}}}}", str(value))
return result
# Keep old name as alias so nothing else breaks
@classmethod
def get_active_playbook(cls) -> PlaybookItem | None:
return cls.get_main_playbook()