wake-template.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env python3
  2. # /// script
  3. # requires-python = ">=3.10"
  4. # ///
  5. """
  6. Waking — load the agent's sanctum in one pass, or route to First Breath.
  7. Run on activation. Determines the mode from the filesystem (and the --pulse
  8. flag) and, when the sanctum exists, prints the full identity in a single read
  9. (INDEX, PERSONA, CREED, BOND, MEMORY, CAPABILITIES) so the agent becomes itself
  10. in one shot instead of six. In --pulse mode it also appends PULSE.md. When no
  11. sanctum exists, it prints a directive to run First Breath.
  12. This loads runtime memory only. It never reads or writes config or customize.toml.
  13. Usage:
  14. uv run wake.py <project-root> [--pulse]
  15. project-root: The root of the project (where _bmad/ lives)
  16. """
  17. import sys
  18. from pathlib import Path
  19. SKILL_NAME = "{skillName}"
  20. # Load order — the "become yourself" set.
  21. IDENTITY_FILES = [
  22. "INDEX.md",
  23. "PERSONA.md",
  24. "CREED.md",
  25. "BOND.md",
  26. "MEMORY.md",
  27. "CAPABILITIES.md",
  28. ]
  29. def emit(path: Path) -> None:
  30. print(f"\n===== {path.name} =====")
  31. try:
  32. print(path.read_text(encoding="utf-8").rstrip())
  33. except FileNotFoundError:
  34. print(f"(missing: {path.name})")
  35. def main() -> int:
  36. args = sys.argv[1:]
  37. pulse = "--pulse" in args
  38. positional = [a for a in args if not a.startswith("--")]
  39. if not positional:
  40. print("Usage: wake.py <project-root> [--pulse]", file=sys.stderr)
  41. return 2
  42. project_root = Path(positional[0]).resolve()
  43. sanctum = project_root / "_bmad" / "memory" / SKILL_NAME
  44. core_ok = (
  45. sanctum.is_dir()
  46. and (sanctum / "CREED.md").is_file()
  47. and (sanctum / "MEMORY.md").is_file()
  48. )
  49. if not core_ok:
  50. print("MODE: FIRST_BREATH")
  51. print(f"NO SANCTUM at {sanctum}")
  52. print("This is your one birth. Load references/first-breath.md and follow it.")
  53. return 0
  54. print("MODE: PULSE" if pulse else "MODE: WAKING")
  55. print(f"Sanctum: {sanctum}")
  56. for name in IDENTITY_FILES:
  57. emit(sanctum / name)
  58. if pulse:
  59. emit(sanctum / "PULSE.md")
  60. return 0
  61. if __name__ == "__main__":
  62. raise SystemExit(main())