assets/setup.sh.tmpl
assets/setup.sh.tmplBrowse 12 files
1,533 tokens
8,286 bytes
Token encoding: o200k_base
Snapshot 24fd22b
← Back to SKILL.md
1#!/usr/bin/env bash2# ═══════════════════════════════════════════════════════════════════════3# Video Pipeline Setup — {{TITLE}}4#5# Generated by kanban-video-orchestrator skill.6#7# Slug: {{SLUG}}8# Workspace: {{WORKSPACE}}9# Tenant: {{TENANT}}10# ═══════════════════════════════════════════════════════════════════════11set -euo pipefail12 13PROJECT_SLUG="{{SLUG}}"14WORKSPACE="$HOME/projects/video-pipeline/${PROJECT_SLUG}"15TENANT="{{TENANT}}"16 17# ─────────────────────────────────────────────────────────────────────18# 1. Verify required API keys19# ─────────────────────────────────────────────────────────────────────20echo "═══ Checking required API keys ═══"21 22check_key() {23 local var="$1"24 local kc_account="${2:-hermes}"25 local kc_service="${3:-$1}"26 local _hermes_env="${HERMES_HOME:-$HOME/.hermes}/.env"27 if grep -q "^${var}=" "$_hermes_env" 2>/dev/null && \28 [ -n "$(grep "^${var}=" "$_hermes_env" | cut -d= -f2-)" ]; then29 echo " ✓ ${var} (env)"30 return 031 fi32 if command -v security >/dev/null 2>&1 && \33 security find-generic-password -a "${kc_account}" -s "${kc_service}" -w >/dev/null 2>&1; then34 echo " ✓ ${var} (Keychain ${kc_account}/${kc_service})"35 return 036 fi37 echo " ✗ ${var} not set in ${_hermes_env} or Keychain (${kc_account}/${kc_service})"38 return 139}40 41# Customize this list per project — only check keys actually used:42{{KEY_CHECKS}}43 44# ─────────────────────────────────────────────────────────────────────45# 2. Create project workspace46# ─────────────────────────────────────────────────────────────────────47echo "═══ Creating project workspace ═══"48mkdir -p "$WORKSPACE"/{taste,audio/{voiceover,sfx},assets,scenes,checkpoints,tools,output}49{{SCENE_DIRS}}50echo " ✓ $WORKSPACE"51 52# ─────────────────────────────────────────────────────────────────────53# 3. Create Hermes profiles54# ─────────────────────────────────────────────────────────────────────55echo "═══ Creating Hermes profiles ═══"56 57{{PROFILE_CREATE_COMMANDS}}58 59# ─────────────────────────────────────────────────────────────────────60# 4. Configure profiles (toolsets, skills, cwd)61# ─────────────────────────────────────────────────────────────────────62echo "═══ Configuring profiles ═══"63 64configure_profile() {65 local profile="$1"66 local toolsets_json="$2" # JSON array string, e.g. '["kanban","terminal","file"]'67 local skills_json="$3" # JSON array string, e.g. '["ascii-video"]'68 python3 - "$profile" "$toolsets_json" "$skills_json" "$WORKSPACE" <<'PY'69"""Patch a Hermes profile config.yaml using PyYAML so we don't depend on the70exact default-config string format. Validates the patch took effect and exits71non-zero if anything's off."""72import json73import os74import sys75 76try:77 import yaml78except ImportError:79 print("ERROR: PyYAML required. pip install pyyaml", file=sys.stderr)80 sys.exit(1)81 82profile, toolsets_json, skills_json, workspace = sys.argv[1:5]83toolsets = json.loads(toolsets_json)84skills = json.loads(skills_json)85 86p = os.path.expanduser(f"~/.hermes/profiles/{profile}/config.yaml")87if not os.path.exists(p):88 print(f" ✗ profile config not found: {p}", file=sys.stderr)89 sys.exit(1)90 91with open(p) as f:92 cfg = yaml.safe_load(f) or {}93 94# Apply our changes — only the keys we actually want to set.95cfg["toolsets"] = toolsets96cfg.setdefault("skills", {})97cfg["skills"]["always_load"] = skills98 99# Note: we do NOT touch cfg["approvals"] — that's a security-sensitive100# setting (manual confirmation of tool calls). Workspace cwd is overridden101# per-task by `--workspace dir:<path>` on `hermes kanban create`, so we102# don't need to mutate cfg["terminal"]["cwd"] either.103 104with open(p, "w") as f:105 yaml.safe_dump(cfg, f, sort_keys=False)106 107# Validate108with open(p) as f:109 after = yaml.safe_load(f)110errors = []111if after.get("toolsets") != toolsets:112 errors.append(f"toolsets mismatch: {after.get('toolsets')!r}")113if after.get("skills", {}).get("always_load") != skills:114 errors.append(f"skills.always_load mismatch: {after.get('skills', {}).get('always_load')!r}")115if errors:116 print(f" ✗ {profile}: " + "; ".join(errors), file=sys.stderr)117 sys.exit(1)118PY119 if [ $? -ne 0 ]; then120 echo " ✗ failed to configure ${profile}" >&2121 exit 1122 fi123 echo " ✓ ${profile}"124}125 126{{PROFILE_CONFIG_COMMANDS}}127 128# ─────────────────────────────────────────────────────────────────────129# 5. Write SOUL.md per profile130# ─────────────────────────────────────────────────────────────────────131echo "═══ Writing profile personalities ═══"132 133{{SOUL_WRITES}}134 135# ─────────────────────────────────────────────────────────────────────136# 6. Copy brief, TEAM.md, and any provided assets137# ─────────────────────────────────────────────────────────────────────138echo "═══ Writing brief + taste ═══"139 140cat > "$WORKSPACE/brief.md" <<'BRIEF_EOF'141{{BRIEF_CONTENTS}}142BRIEF_EOF143 144cat > "$WORKSPACE/TEAM.md" <<'TEAM_EOF'145{{TEAM_CONTENTS}}146TEAM_EOF147 148{{TASTE_WRITES}}149 150{{ASSET_COPIES}}151 152# ─────────────────────────────────────────────────────────────────────153# 7. Fire the initial kanban task154# ─────────────────────────────────────────────────────────────────────155echo "═══ Firing initial kanban task ═══"156 157hermes kanban create "Direct production of {{TITLE}}" \158 --assignee director \159 --workspace dir:"$WORKSPACE" \160 --tenant "$TENANT" \161 --priority 2 \162 --max-runtime 4h \163 --body "$(cat <<EOF164Read brief.md, TEAM.md, and taste/.165 166Decompose into the team graph defined in TEAM.md.167 168All child tasks MUST use:169 workspace_kind="dir"170 workspace_path="$WORKSPACE"171 tenant="$TENANT"172 173Do not execute the work yourself — route every concrete subtask to the174appropriate profile via kanban_create.175EOF176)"177 178echo ""179echo "═══ Setup complete ═══"180echo ""181echo "Monitor with:"182echo " hermes kanban watch --tenant $TENANT"183echo " hermes kanban list --tenant $TENANT"184echo " hermes dashboard"185echo ""186echo "Workspace: $WORKSPACE"187