#!/usr/bin/env bash # Reproducible PM CLI handoff demo from https://preu.at/work/pm-cli # Download: https://preu.at/case-study/pm-handoff.sh # # Two "sessions" share nothing but the repository: session 1 records a goal, a decision, # work with acceptance criteria and evidence; session 2 starts cold and asks PM for context. # Synthetic project, throwaway directory, telemetry off. Requires @unbrained/pm-cli (`pm`). # # bash pm-handoff.sh # prints the transcript # KEEP=1 bash pm-handoff.sh # keeps the demo repo for inspection set -euo pipefail dir="$(mktemp -d "${TMPDIR:-/tmp}/pm-handoff.XXXXXX")" [[ "${KEEP:-}" == 1 ]] || trap 'rm -rf "$dir"' EXIT cd "$dir" git init -q run() { printf '$ %s\n' "$*"; "$@"; printf '\n'; } id_of() { pm list --json 2>/dev/null | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const it=(d.items||d).find(i=>i.title===process.argv[1]);process.stdout.write(it?it.id:"")})' "$1"; } echo "# pm $(pm --version) — demo repo: $dir" pm init rpt --defaults --agent-guidance skip >/dev/null 2>&1 pm config project set telemetry-tracking off >/dev/null 2>&1 echo "# ---- Session 1 ----" export PM_AUTHOR=session-1 pm create epic "CSV export for monthly reports" \ --description "Finance re-types numbers from the reports page into spreadsheets." \ --ac "Finance can download any closed month as CSV" >/dev/null epic="$(id_of 'CSV export for monthly reports')" pm create decision "Stream CSV rows instead of building files in memory" --parent "$epic" \ --description "Large months exceed the 512 MB worker limit when buffered." \ --ac "Export memory stays flat regardless of month size" >/dev/null decision="$(id_of 'Stream CSV rows instead of building files in memory')" pm create task "Streaming CSV endpoint" --parent "$epic" \ --ac "GET /reports/:month.csv streams rows with a header line" \ --ac "Open months return 409 with an explanation" >/dev/null api="$(id_of 'Streaming CSV endpoint')" pm create task "Download button on the reports page" --parent "$epic" --blocked-by "$api" \ --ac "Button appears only for closed months" >/dev/null run pm claim "$api" --start run pm comments "$api" --add "text=Endpoint streams via a cursor (see $decision). Remaining: 409 for open months." run pm files "$api" --add "path=src/reports/csv.ts,scope=project" pm release "$api" >/dev/null echo "# ---- Session 2: a fresh agent, no memory of session 1 ----" export PM_AUTHOR=session-2 run pm context --for orient --limit 5 run pm get "$api"