cc-os/plugins/os-orchestration/hooks/inject.py

32 lines
758 B
Python
Executable File

#!/usr/bin/env python3
"""SessionStart hook: inject ORCHESTRATION.md as additionalContext.
Fires on startup/resume/clear, and on 'compact' (matcher includes it) so the
rules survive a context-compaction pass, not just the first turn.
"""
import json
import os
import sys
PLUGIN_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ORCHESTRATION_FILE = os.path.join(PLUGIN_ROOT, "ORCHESTRATION.md")
def main():
try:
with open(ORCHESTRATION_FILE) as f:
context = f.read()
except OSError:
return
print(json.dumps({
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": context,
}
}))
if __name__ == "__main__":
sys.exit(main())