-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo-setup.sh
More file actions
executable file
·244 lines (216 loc) · 7.32 KB
/
demo-setup.sh
File metadata and controls
executable file
·244 lines (216 loc) · 7.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
# Creates a temporary demo environment for the VHS tape.
# Called from Makefile: `make demo` runs this, then `vhs demo.tape`.
set -e
export FLOW_HOME="/tmp/flow-demo/.flow"
FLOW="$(pwd)/flow"
rm -rf /tmp/flow-demo /tmp/demo
mkdir -p /tmp/demo "$FLOW_HOME/workspaces" "$FLOW_HOME/repos"
# --- Configure flow agent ---
# A launcher script writes .claude/settings.json to pre-approve tools before
# launching claude. This avoids permission dialogs during the demo.
cat > /tmp/flow-demo/launch-claude.sh <<'LAUNCHER'
#!/bin/bash
echo '{"permissions":{"allow":["Bash","Edit","Write","Read","Glob","Grep","Skill"]}}' > .claude/settings.json
exec claude --model haiku
LAUNCHER
chmod +x /tmp/flow-demo/launch-claude.sh
cat > "$FLOW_HOME/config.yaml" <<YAML
apiVersion: flow/v1
kind: Config
spec:
agents:
- name: claude
exec: /tmp/flow-demo/launch-claude.sh
default: true
YAML
# --- Pre-trust the demo directory so Claude skips the workspace trust dialog ---
CLAUDE_JSON="$HOME/.claude.json"
if [ -f "$CLAUDE_JSON" ]; then
python3 -c "
import json, sys
with open('$CLAUDE_JSON') as f:
config = json.load(f)
config.setdefault('projects', {})
config['projects']['/tmp/flow-demo'] = {'hasTrustDialogAccepted': True}
with open('$CLAUDE_JSON', 'w') as f:
json.dump(config, f, indent=2)
"
fi
# --- Create local git repos with feature branches ---
create_repo() {
local name="$1" branch="$2" file="$3" msg="$4"
local dir="/tmp/demo/$name"
mkdir -p "$dir"
git -C "$dir" init -q
echo "# $name" > "$dir/README.md"
echo "package main" > "$dir/main.go"
git -C "$dir" add .
git -C "$dir" commit -q -m "initial commit"
git -C "$dir" checkout -q -b "$branch" 2>/dev/null || true
echo "// $msg" >> "$dir/$file"
git -C "$dir" add .
git -C "$dir" commit -q -m "$msg"
}
create_repo "app" "feature/ipv6" "main.go" "add ipv6 support"
create_repo "api" "feat/auth" "main.go" "add auth endpoints"
create_repo "docs" "update/guides" "README.md" "update setup guide"
create_repo "web" "feat/dashboard" "main.go" "add dashboard page"
create_repo "billing" "feat/billing-v2" "main.go" "billing v2 migration"
create_repo "gateway" "feat/rate-limits" "main.go" "add rate limiting"
create_repo "config" "feat/env-vars" "main.go" "add env var support"
create_repo "apps" "main" "main.go" "initial app setup"
create_repo "infrastructure" "main" "main.go" "initial infra setup"
# --- Pre-populate bare clone cache for realistic URLs ---
for name in app api docs web billing gateway config apps infrastructure; do
bare="$FLOW_HOME/repos/github.com/acme/${name}.git"
mkdir -p "$(dirname "$bare")"
git clone --bare "/tmp/demo/$name" "$bare" -q
# Add fetch refspec so worktrees can resolve origin/* refs
git -C "$bare" config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git -C "$bare" fetch -q origin
# Also create under SSH URL path (in case Claude uses git@ format)
ssh_bare="$FLOW_HOME/repos/git@github.com:acme/${name}.git"
mkdir -p "$(dirname "$ssh_bare")"
cp -a "$bare" "$ssh_bare"
done
# --- Create and render pre-existing workspaces ---
create_workspace() {
local id="$1" yaml="$2"
mkdir -p "$FLOW_HOME/workspaces/$id"
echo "$yaml" > "$FLOW_HOME/workspaces/$id/state.yaml"
}
# Workspace: api-refactor — will be "in-progress" (has local diffs)
create_workspace "bold-creek" "$(cat <<'YAML'
apiVersion: flow/v1
kind: State
metadata:
name: api-refactor
description: Refactor authentication API
created: "2026-02-21T14:30:00Z"
spec:
repos:
- url: github.com/acme/api
branch: feat/auth
path: api
- url: github.com/acme/docs
branch: update/guides
path: docs
YAML
)"
# Workspace: infra-update — will be "in-review" (marker file)
create_workspace "swift-pine" "$(cat <<'YAML'
apiVersion: flow/v1
kind: State
metadata:
name: infra-update
description: Update infrastructure across services
created: "2026-02-19T09:00:00Z"
spec:
repos:
- url: github.com/acme/app
branch: feature/ipv6
path: app
YAML
)"
# Workspace: billing-v2 — will be "closed" (marker file)
create_workspace "calm-ridge" "$(cat <<'YAML'
apiVersion: flow/v1
kind: State
metadata:
name: billing-v2
description: Migrate billing system to v2
created: "2026-02-15T10:00:00Z"
spec:
repos:
- url: github.com/acme/billing
branch: feat/billing-v2
path: billing
YAML
)"
# Workspace: rate-limits — will be "in-progress" (has local diffs)
create_workspace "dry-fog" "$(cat <<'YAML'
apiVersion: flow/v1
kind: State
metadata:
name: rate-limits
description: Add rate limiting to API gateway
created: "2026-02-23T16:00:00Z"
spec:
repos:
- url: github.com/acme/gateway
branch: feat/rate-limits
path: gateway
YAML
)"
# Workspace: env-config — will be "open" (no changes)
create_workspace "iron-vale" "$(cat <<'YAML'
apiVersion: flow/v1
kind: State
metadata:
name: env-config
description: Add environment variable support
created: "2026-02-26T08:00:00Z"
spec:
repos:
- url: github.com/acme/config
branch: feat/env-vars
path: config
YAML
)"
# Render all workspaces
# Use --reset=false to use existing branches as-is instead of creating fresh from base
$FLOW render bold-creek --reset=false
$FLOW render swift-pine --reset=false
$FLOW render calm-ridge --reset=false
$FLOW render dry-fog --reset=false
$FLOW render iron-vale --reset=false
# --- Set up different statuses via local changes and marker files ---
# api-refactor: "in-progress" — add local commits so git diff detects changes
add_local_change() {
local ws_dir="$FLOW_HOME/workspaces/$1/$2"
git -C "$ws_dir" fetch -q origin 2>/dev/null || true
echo "# local change" >> "$ws_dir/README.md"
git -C "$ws_dir" add .
git -C "$ws_dir" commit -q -m "wip: local changes"
}
add_local_change "bold-creek" "api"
add_local_change "bold-creek" "docs"
# rate-limits: "in-progress" — local commits
add_local_change "dry-fog" "gateway"
# infra-update: "in-review" — marker file
touch "$FLOW_HOME/workspaces/swift-pine/app/.flow-review"
# billing-v2: "closed" — marker file
touch "$FLOW_HOME/workspaces/calm-ridge/billing/.flow-closed"
# --- Create status specs ---
# The default spec (written by EnsureDirs on first flow command) uses gh + jq.
# For the demo, we keep the default for the edit-status tape (so it shows the
# real commands), then the status tape swaps in a local-only spec before running.
# Write a local-only spec that the status tape will swap in (no gh needed).
# Checks are evaluated in order — first match wins per repo.
cat > "$FLOW_HOME/status-local.yaml" <<YAML
apiVersion: flow/v1
kind: Status
spec:
statuses:
- name: closed
description: All PRs merged or closed
color: "131"
check: test -f "\$FLOW_REPO_PATH/.flow-closed"
- name: stale
description: Workspace inactive
color: magenta
check: 'false'
- name: in-review
description: Non-draft PR open
color: purple
check: test -f "\$FLOW_REPO_PATH/.flow-review"
- name: in-progress
description: Local diffs or draft PR
color: yellow
check: git -C "\$FLOW_REPO_PATH" diff --name-only "origin/\$FLOW_REPO_BRANCH" 2>/dev/null | grep -q .
- name: open
description: Workspace created, no changes yet
color: green
default: true
YAML