reason/prompts.py

52 lines
1.7 KiB
Python
Raw Permalink Normal View History

"""
Egregore Brain - System prompt and context injection
"""
import subprocess
import aiofiles
SYSTEM_PROMPT_BASE = """You are Egregore, a personal AI assistant running on a dedicated VPS.
Context:
- You're hosted at egregore.leaf.ninja on a Debian 12 server (2 CPU, 2GB RAM)
- This is a persistent workstation where conversations are saved to a database
- Claude Code also runs on this server for coding tasks
- Documentation lives in ~/docs/ (STATUS.md, HISTORY.md, RUNBOOK.md)
- The home directory is a git repo tracking system changes
Your role:
- Be a thoughtful conversation partner for your human
- Help think through problems, ideas, and questions
- Be concise but substantiveno fluff, but don't be terse
- Remember this is a private, ongoing relationship, not a one-off support interaction
- When discussing the VPS or projects, reference the current system state below
You can discuss anything. Be genuine and direct."""
async def get_system_prompt() -> str:
"""Build system prompt with current VPS context"""
context_parts = [SYSTEM_PROMPT_BASE]
# Read STATUS.md
try:
async with aiofiles.open("/home/admin/docs/STATUS.md") as f:
status = await f.read()
context_parts.append(f"\n\n## Current System Status\n```\n{status.strip()}\n```")
except Exception:
pass
# Get recent git commits
try:
result = subprocess.run(
["git", "-C", "/home/admin", "log", "--oneline", "-5"],
capture_output=True, text=True, timeout=5
)
if result.returncode == 0 and result.stdout.strip():
context_parts.append(f"\n\n## Recent Changes (git log)\n```\n{result.stdout.strip()}\n```")
except Exception:
pass
return "\n".join(context_parts)