#!/usr/bin/env python3
"""Create one isolated reproduction fixture: python3 seed-proof.py <new-output-dir>.

Run from the app checkout under test after vp i:
  T3CODE_DEV_SEED=0 T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD=0 vp run dev --home-dir <output>/home
  node apps/server/src/bin.ts project add <output>/hook-skills-demo --title "Hook skills demo" --base-dir <output>/home

Pair the browser with that server. Use dark mode, 1440 x 1000, hide the thread
 details panel, and open a new thread in Hook skills demo using Claude Haiku 5.5.
1. Type $hook-linked; wait for No skills found (primes the empty inventory).
2. Replace it with Reply with just the word hi. and submit.
3. Wait for the turn to finish (hi and changed files are visible).
4. Confirm .claude/hook.log exists and .claude/skills/hook-linked-proof resolves.
5. In that same thread, without reload or refresh, type $hook-linked again.
6. Record the picker immediately, within the five-minute workspace snapshot TTL.
Expected: hook-linked-proof, its description, and Project Skill appear.
Base observed: No skills found. Head observed: the project skill appears.

Captures use the real Claude provider; replay cannot run its SessionStart hook.
Only the caret was hidden for stable still captures; app behavior was unchanged.
"""
import json
from pathlib import Path
import subprocess
import sys

root = Path(sys.argv[1]).resolve()
root.mkdir(parents=True, exist_ok=False)
repo = root / "hook-skills-demo"
files = {'README.md': '# Hook skills demo\n', 'skill-src/hook-linked-proof/SKILL.md': '---\nname: hook-linked-proof\ndescription: A skill linked into .claude/skills by a SessionStart hook\n---\nReply hi.\n', '.claude/link-skills.sh': '#!/bin/sh\nset -eu\nmkdir -p .claude/skills\nln -sfn ../../skill-src/hook-linked-proof .claude/skills/hook-linked-proof\ndate -u +%Y-%m-%dT%H:%M:%SZ >> .claude/hook.log\n', '.claude/settings.json': '{"hooks": {"SessionStart": [{"hooks": [{"type": "command", "command": "sh .claude/link-skills.sh"}]}]}}'}
for name, content in files.items():
    target = repo / name
    target.parent.mkdir(parents=True, exist_ok=True)
    target.write_text(content)
for command in [
    ["git", "init", "-q", "-b", "main"],
    ["git", "add", "."],
    ["git", "-c", "user.name=Proof", "-c", "user.email=proof@example.invalid", "commit", "-qm", "Seed hook skill"],
]:
    subprocess.run(command, cwd=repo, check=True)
home = root / "home" / "userdata"
home.mkdir(parents=True)
providers = {name: {"driver": name, "enabled": name == "claudeAgent", "config": {}}
             for name in ["codex", "claudeAgent", "cursor", "grok", "muse", "pi", "opencode", "antigravity"]}
(home / "settings.json").write_text(json.dumps({
    "defaultModelSelection": {"instanceId": "claudeAgent", "model": "claude-haiku-5-5"},
    "providerInstances": providers,
}))
print("Fixture ready; .claude/skills is initially absent.")
