claude-skills/agent-launcher/hooks/session_end.py
Claude 22e683b17d
fix(docs): replace 2,308 /cs:<name> references with names Claude Code can run
Claude Code runs a plugin command as /<plugin>:<name> or bare /<name>. A test
plugin on 2.1.306 confirmed /cs-foo and /tp:cs-foo run while /cs:foo matches
nothing, so every /cs:<name> in the docs, descriptions and hook messages sent
users to an unknown command.

- Commands named cs-<name> are now written /cs-<name>.
- c-level-agents and compliance-os skills with generic names (decide, brief,
  freeze, ...) are written fully qualified, e.g. /c-level-agents:decide, so they
  cannot collide with other commands.
- Five names that never existed were mapped to what they described:
  /cs:setup and /cs:update -> /cs-onboard setup|update, /cs:decisions and
  /cs:review -> /decision-logger ..., /cs:board -> /board-meeting,
  /cs:unfreeze -> /c-level-agents:freeze release.
- CHANGELOG.md and audit/ keep the old spelling as history.
- New blocking gate scripts/check_command_refs.py keeps the tree clean.
- Counters: 100 marketplace plugins (loop-library).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HiL4hfMQoQjiFmMUbPnpJJ
2026-10-21 07:48:14 +00:00

57 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""SessionEnd hook for agent-launcher (OPT-IN).
Disabled unless AGENT_LAUNCHER_SESSION=1 (and additionally AGENT_LAUNCHER_SESSIONEND
!= 0). When enabled and an in-progress goal exists that is not yet at phase=done,
prints a one-line reminder to checkpoint/advance the goal so the next session
resumes cleanly. Any error exits 0 — a hook must never break a session.
Stdlib-only.
"""
import json
import os
import sys
from pathlib import Path
def disabled() -> bool:
if os.environ.get("AGENT_LAUNCHER_SESSION", "0") != "1":
return True
if os.environ.get("AGENT_LAUNCHER_SESSIONEND", "1") == "0":
return True
return False
def find_goal() -> Path | None:
for c in [Path.cwd() / "my-agent" / "goal.json", Path.cwd() / ".my-agent" / "goal.json"]:
if c.exists():
return c
try:
for d in sorted(Path.cwd().glob("my-agent-*/goal.json")):
return d
except OSError:
pass
return None
def main() -> int:
if disabled():
return 0
try:
gp = find_goal()
if not gp:
return 0
state = json.loads(gp.read_text())
phase = state.get("phase", "interview")
if phase == "done":
return 0
print(f"[agent-launcher] Launch still at phase '{phase}'. "
f"Checkpoint it: `goal_state.py set --phase {phase} --note '...'` "
f"(or `advance`). Resume next session with /cs-launch.")
except Exception:
return 0
return 0
if __name__ == "__main__":
sys.exit(main())