create-pmos 0.549.0 → 0.551.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cloud-setup.sh ADDED
@@ -0,0 +1,438 @@
1
+ #!/usr/bin/env bash
2
+ # PMOS in the cloud: run the PMOS workspace on an always-on Linux server (initiative workspace-run-in-cloud).
3
+ # Guide: workspace/guide/cloud.md ("Run PMOS in the cloud").
4
+ #
5
+ # 1. On the Mac that runs PMOS today, one paste moves PMOS to a new server and starts it there:
6
+ #
7
+ # curl -fsSL https://unpkg.com/create-pmos/cloud-setup.sh | bash -s -- move root@<server-ip>
8
+ #
9
+ # It checks that it can reach the server, stops PMOS on the Mac (Online off, the minute check paused, Remote
10
+ # Control left running), packs the PMOS state folder, every registered repository (with its git history), the
11
+ # Cloudflare tunnel files, the Claude profile names and ~/.gitconfig, copies the pack to the server and runs step 2
12
+ # there. Nothing is deleted on the Mac. `cloud-setup.sh mac-on` on the Mac turns the Mac back on.
13
+ #
14
+ # 2. On the server (Ubuntu 22.04 or newer, as root). `move` runs this for you; without a Mac, paste it yourself:
15
+ #
16
+ # curl -fsSL https://unpkg.com/create-pmos/cloud-setup.sh | bash
17
+ #
18
+ # Makes the same user and home folder as on the Mac (so every path, product id and tunnel file stays valid),
19
+ # installs git, tmux, build tools, cloudflared and the GitHub CLI, turns on the firewall (SSH only), unpacks the
20
+ # pack, installs Node, Claude Code and PMOS for that user, and adds a systemd timer that runs the same minute
21
+ # check as the Mac login item: `pmos up --keep`, plus Remote Control in tmux after the sign-in.
22
+ # Running it again is safe: it skips what is there and never overwrites a repository or a state folder.
23
+ #
24
+ # 3. Sign in once, from any computer:
25
+ #
26
+ # ssh -t <user>@<server-ip> pmos-cloud signin
27
+ #
28
+ # Claude Code (your own account; its claude.ai connectors bring Jira and Slack) and GitHub (for record sync).
29
+ #
30
+ # Settings (environment variables, step 2):
31
+ # PMOS_SEED=<file> the pack made by `move` (move sets it)
32
+ # PMOS_USER=<name> the user to make when there is no pack (default: pmos)
33
+ # PMOS_PKG=<spec> the create-pmos release (default: the newest that downloads)
34
+ # PMOS_NO_SYSTEMD=1 write the minute check but do not install the timer (containers, tests)
35
+ # PMOS_NO_FIREWALL=1 leave the firewall alone
36
+ # PMOS_SKIP_CLAUDE=1 do not install Claude Code (tests)
37
+ set -euo pipefail
38
+
39
+ SCRIPT_URL="${PMOS_SCRIPT_URL:-https://unpkg.com/create-pmos/cloud-setup.sh}"
40
+ INSTALL_URL="${PMOS_INSTALL_URL:-https://unpkg.com/create-pmos/install.sh}"
41
+ RC_SESSION=pmos-remote-control
42
+
43
+ say() { printf '\033[1m==>\033[0m %s\n' "$*"; }
44
+ ok() { printf ' \033[32m✓\033[0m %s\n' "$*"; }
45
+ note() { printf ' %s\n' "$*"; }
46
+ fail() { printf '\n\033[31m✗ %s\033[0m\n' "$1" >&2; [ -n "${2:-}" ] && printf ' Try: %s\n' "$2" >&2; exit 1; }
47
+ have() { command -v "$1" >/dev/null 2>&1; }
48
+
49
+ # ── The workspace's own files, wherever npm put them (the same lookup on the Mac and the server) ─────────────────
50
+ ws_dir() {
51
+ local r; r="$(npm root -g 2>/dev/null || true)"
52
+ [ -n "$r" ] && [ -f "$r/pmos-workspace/package.json" ] && { echo "$r/pmos-workspace"; return; }
53
+ local b; b="$(command -v pmos 2>/dev/null || true)"
54
+ [ -n "$b" ] && node -e 'const fs=require("fs"),p=require("path");console.log(p.resolve(p.dirname(fs.realpathSync(process.argv[1])),".."))' "$b" 2>/dev/null
55
+ }
56
+
57
+ state_dir() {
58
+ if [ -n "${PMOS_STATE_DIR:-}" ]; then echo "$PMOS_STATE_DIR"
59
+ elif [ "$(uname -s)" = Darwin ]; then echo "$HOME/Library/Application Support/pmos"
60
+ elif [ -n "${XDG_STATE_HOME:-}" ]; then echo "$XDG_STATE_HOME/pmos"
61
+ else echo "$HOME/.local/state/pmos"; fi
62
+ }
63
+
64
+ # ════════════════════════════════════════════════════════════════════════════════════════════════════════════════
65
+ # move <user@host> — on the Mac: pack PMOS, stop it here, copy the pack to the server and set the server up.
66
+ # ════════════════════════════════════════════════════════════════════════════════════════════════════════════════
67
+ cmd_move() {
68
+ local target="${1:-}"
69
+ [ -n "$target" ] || fail "Name the server." "curl -fsSL $SCRIPT_URL | bash -s -- move root@<server-ip>"
70
+ have pmos || fail "pmos is not installed on this computer." "run this on the Mac that runs PMOS"
71
+ local STATE; STATE="$(state_dir)"
72
+ [ -f "$STATE/workspaces.json" ] || fail "No PMOS state folder at $STATE." "run this on the Mac that runs PMOS"
73
+
74
+ say "Checking that this Mac can reach $target"
75
+ ssh -o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new "$target" true </dev/null \
76
+ || fail "Could not sign in to $target with this Mac's SSH key." "add this Mac's key (cat ~/.ssh/id_ed25519.pub) to the server, then paste the line again"
77
+ ok "reached $target"
78
+
79
+ local WS; WS="$(ws_dir)"
80
+ local tmp; tmp="$(mktemp -d)"
81
+ # The repositories PMOS hosts, as paths under the home folder; the first is the one the minute check names.
82
+ node -e '
83
+ const fs = require("fs"), path = require("path"), home = process.env.HOME;
84
+ const reg = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
85
+ const roots = reg.map((w) => w.root).filter((r) => r && fs.existsSync(r) && r.startsWith(home + "/"));
86
+ // The minute check names one repository; a product with the PMOS kit, so the server-side install adds nothing to it.
87
+ const first = roots.find((r) => fs.existsSync(path.join(r, "pmos", "AGENTS.md"))) || roots[0] || "";
88
+ fs.writeFileSync(process.argv[2], roots.map((r) => path.relative(home, r)).join("\n") + "\n");
89
+ console.log(first);
90
+ ' "$STATE/workspaces.json" "$tmp/repos.txt" >"$tmp/first.txt"
91
+ local FIRST; FIRST="$(cat "$tmp/first.txt")"
92
+ [ -n "$FIRST" ] || fail "No registered repository was found under $HOME."
93
+
94
+ # The Claude profile unattended work runs as (Settings › Claude), and the folder it keeps its sign-in in.
95
+ local PROFILE="" CLAUDE_DIR=""
96
+ PROFILE="$(node -e 'try{const p=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));if(p&&typeof p.claude==="string")console.log(p.claude)}catch{}' "$STATE/prefs.json")"
97
+ if [ -n "$PROFILE" ] && [ -n "$WS" ]; then
98
+ CLAUDE_DIR="$(node -e 'const r=require(process.argv[1]).resolveProfile(process.argv[2],process.env.HOME);if(r&&r.configDir)console.log(r.configDir)' "$WS/lib/launcher-cli.js" "$PROFILE" 2>/dev/null || true)"
99
+ fi
100
+ ok "Claude profile: ${PROFILE:-the default Claude login}${CLAUDE_DIR:+ ($CLAUDE_DIR)}"
101
+
102
+ say "Stopping PMOS on this Mac (nothing is deleted)"
103
+ # Online off first, so the Mac's tunnel does not answer pmos.pm-os.app beside the server's. The server turns it on
104
+ # when it was on here and the tunnel files came along.
105
+ local ONLINE=0
106
+ node -e 'try{process.exit(JSON.parse(require("fs").readFileSync(process.argv[1],"utf8")).on===true?0:1)}catch{process.exit(1)}' "$STATE/online.json" && ONLINE=1
107
+ if [ -f "$STATE/online.json" ]; then
108
+ node -e 'const fs=require("fs"),f=process.argv[1];const o=JSON.parse(fs.readFileSync(f,"utf8"));o.on=false;fs.writeFileSync(f,JSON.stringify(o),{mode:0o600})' "$STATE/online.json" \
109
+ && ok "Online off on this Mac"
110
+ fi
111
+ if [ "$(uname -s)" = Darwin ]; then
112
+ launchctl disable "gui/$(id -u)/com.pmos.workspace" 2>/dev/null || true
113
+ launchctl bootout "gui/$(id -u)/com.pmos.workspace" 2>/dev/null || true
114
+ ok "minute check paused (Remote Control keeps running, so Claude can still reach this Mac)"
115
+ fi
116
+ (cd "$FIRST" && pmos stop </dev/null >/dev/null 2>&1 || true)
117
+ pkill -f 'cloudflared tunnel --no-autoupdate run' 2>/dev/null || true
118
+ ok "workspace stopped"
119
+
120
+ say "Packing PMOS"
121
+ printf 'PM_USER=%q\nPM_HOME=%q\nPM_FIRST=%q\nPM_PROFILE=%q\nPM_CLAUDE_DIR=%q\nPM_ONLINE=%q\nPM_FROM=%q\nPM_AT=%q\n' \
122
+ "$(id -un)" "$HOME" "$FIRST" "$PROFILE" "$CLAUDE_DIR" "$ONLINE" "$(hostname)" "$(date -u +%FT%TZ)" >"$tmp/meta.env"
123
+ # COPYFILE_DISABLE: no macOS ._ files. Sockets and node_modules stay behind; everything else in the state folder goes.
124
+ COPYFILE_DISABLE=1 tar -czf "$tmp/state.tgz" -C "$STATE" --exclude='*.sock' --exclude='node_modules' --exclude='*.partial' .
125
+ # Plain strings, not arrays: the Mac's /bin/bash is 3.2, where an empty array under `set -u` is an error.
126
+ local nrepos extra="" p; nrepos="$(wc -l <"$tmp/repos.txt" | tr -d ' ')"
127
+ for p in .cloudflared .claude/profiles .gitconfig; do [ -e "$HOME/$p" ] && extra="$extra, $p" && echo "$p" >>"$tmp/repos.txt"; done
128
+ COPYFILE_DISABLE=1 tar -czf "$tmp/home.tgz" -C "$HOME" --exclude='node_modules' --exclude='.DS_Store' -T "$tmp/repos.txt"
129
+ tar -cf "$tmp/pmos-seed.tar" -C "$tmp" meta.env state.tgz home.tgz
130
+ ok "$(du -h "$tmp/pmos-seed.tar" | cut -f1) — $nrepos repositories, the state folder$extra"
131
+
132
+ say "Copying the pack to $target"
133
+ scp -q "$tmp/pmos-seed.tar" "$target:pmos-seed.tar" </dev/null || fail "The copy to $target failed." "paste the line again"
134
+ rm -rf "$tmp"
135
+ ok "copied"
136
+
137
+ say "Setting up the server"
138
+ # The variables are on the command line, so sudo keeps them. </dev/tty: under `curl | bash` stdin is the script,
139
+ # and the server setup shows its progress in a real terminal.
140
+ ssh -t "$target" "curl -fsSL '$SCRIPT_URL' -o /tmp/pmos-cloud-setup.sh && sudo PMOS_SEED=\"\$HOME/pmos-seed.tar\" ${PMOS_PKG:+PMOS_PKG='$PMOS_PKG'} bash /tmp/pmos-cloud-setup.sh" </dev/tty \
141
+ || fail "The server setup stopped with an error (shown above)." "fix it, then on this Mac: curl -fsSL $SCRIPT_URL | bash -s -- move $target"
142
+ echo
143
+ ok "PMOS moved. This Mac is the fallback: \`curl -fsSL $SCRIPT_URL | bash -s -- mac-on\` turns it back on."
144
+ }
145
+
146
+ # mac-on — on the Mac: undo the stop that `move` did (turn the minute check on; Online is turned on in Settings).
147
+ cmd_mac_on() {
148
+ [ "$(uname -s)" = Darwin ] || fail "mac-on is for the Mac."
149
+ launchctl enable "gui/$(id -u)/com.pmos.workspace" 2>/dev/null || true
150
+ launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.pmos.workspace.plist" 2>/dev/null || true
151
+ ok "minute check on; PMOS starts within a minute"
152
+ note "Turn Online on in Settings › Online here, and stop the server first (ssh -t <user>@<server-ip> pmos-cloud stop),"
153
+ note "so only one computer answers pmos.pm-os.app."
154
+ }
155
+
156
+ # ════════════════════════════════════════════════════════════════════════════════════════════════════════════════
157
+ # setup — on the server, as root.
158
+ # ════════════════════════════════════════════════════════════════════════════════════════════════════════════════
159
+ cmd_setup() {
160
+ [ "$(uname -s)" = Linux ] || fail "The server setup is for Linux. On the Mac, use: bash -s -- move root@<server-ip>"
161
+ [ "$(id -u)" = 0 ] || fail "Run the server setup as root." "curl -fsSL $SCRIPT_URL | sudo bash"
162
+ have apt-get || fail "This setup needs Ubuntu or Debian (apt-get)."
163
+
164
+ # ── 1. The pack ──────────────────────────────────────────────────────────────────────────────────────────────
165
+ local SEED_DIR="" PM_USER="${PMOS_USER:-pmos}" PM_HOME="" PM_FIRST="" PM_PROFILE="" PM_CLAUDE_DIR="" PM_ONLINE=0 PM_FROM="" PM_AT=""
166
+ if [ -n "${PMOS_SEED:-}" ]; then
167
+ [ -f "$PMOS_SEED" ] || fail "No pack at $PMOS_SEED."
168
+ SEED_DIR="$(mktemp -d)"
169
+ tar -xf "$PMOS_SEED" -C "$SEED_DIR"
170
+ # shellcheck disable=SC1091
171
+ . "$SEED_DIR/meta.env"
172
+ say "Pack from $PM_FROM, made $PM_AT"
173
+ fi
174
+ PM_HOME="${PM_HOME:-/home/$PM_USER}"
175
+ PM_FIRST="${PM_FIRST:-$PM_HOME/PMOS}"
176
+ case "$PM_USER" in root|'') fail "PMOS runs as a normal user, not root.";; esac
177
+
178
+ # ── 2. System packages ───────────────────────────────────────────────────────────────────────────────────────
179
+ say "Installing system packages"
180
+ export DEBIAN_FRONTEND=noninteractive
181
+ apt-get update -qq
182
+ apt-get install -y -qq git tmux build-essential python3 curl ca-certificates gnupg ufw gh >/dev/null 2>&1 \
183
+ || apt-get install -y -qq git tmux build-essential python3 curl ca-certificates gnupg ufw >/dev/null
184
+ ok "git, tmux, build tools$(have gh && echo ', GitHub CLI')"
185
+ if ! have cloudflared; then
186
+ mkdir -p --mode=0755 /usr/share/keyrings
187
+ curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg -o /usr/share/keyrings/cloudflare-main.gpg
188
+ echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' >/etc/apt/sources.list.d/cloudflared.list
189
+ apt-get update -qq && apt-get install -y -qq cloudflared >/dev/null
190
+ fi
191
+ ok "$(cloudflared --version 2>/dev/null | head -1 || echo 'cloudflared')"
192
+ if [ "${PMOS_NO_FIREWALL:-}" != 1 ] && have ufw; then
193
+ ufw allow OpenSSH >/dev/null && ufw --force enable >/dev/null && ok "firewall on: SSH only (PMOS listens on this server only; Cloudflare reaches it from inside)"
194
+ fi
195
+
196
+ # ── 3. The user ──────────────────────────────────────────────────────────────────────────────────────────────
197
+ say "Setting up the user $PM_USER ($PM_HOME)"
198
+ if ! id "$PM_USER" >/dev/null 2>&1; then
199
+ mkdir -p "$(dirname "$PM_HOME")"
200
+ useradd -m -d "$PM_HOME" -s /bin/bash "$PM_USER"
201
+ ok "user made (the same home folder as on the Mac, so every path and product id stays valid)"
202
+ else ok "user exists"; fi
203
+ if [ -f /root/.ssh/authorized_keys ] && [ ! -f "$PM_HOME/.ssh/authorized_keys" ]; then
204
+ install -d -m 700 -o "$PM_USER" -g "$PM_USER" "$PM_HOME/.ssh"
205
+ install -m 600 -o "$PM_USER" -g "$PM_USER" /root/.ssh/authorized_keys "$PM_HOME/.ssh/authorized_keys"
206
+ ok "your SSH key signs in as $PM_USER too"
207
+ fi
208
+ loginctl enable-linger "$PM_USER" >/dev/null 2>&1 || true
209
+
210
+ # ── 4. Unpack ────────────────────────────────────────────────────────────────────────────────────────────────
211
+ local STATE="$PM_HOME/.local/state/pmos"
212
+ if [ -n "$SEED_DIR" ]; then
213
+ say "Unpacking"
214
+ # Repositories and files that are already here are kept: a second run never overwrites cloud work.
215
+ tar -xzf "$SEED_DIR/home.tgz" -C "$PM_HOME" --skip-old-files --warning=no-unknown-keyword --no-same-owner
216
+ ok "repositories and settings files"
217
+ if [ -f "$STATE/workspaces.json" ]; then
218
+ note "the state folder is already here; kept it (the pack's copy is not used)"
219
+ else
220
+ mkdir -p "$STATE"
221
+ tar -xzf "$SEED_DIR/state.tgz" -C "$STATE" --warning=no-unknown-keyword --no-same-owner
222
+ ok "state folder (chats, notes, settings, Online)"
223
+ # Online was on at the Mac and its tunnel files came along: on here too (the same tunnel; only this server runs it now).
224
+ if [ "$PM_ONLINE" = 1 ] && [ -f "$PM_HOME/.cloudflared/config.yml" ] && [ -f "$STATE/online.json" ]; then
225
+ sed -i 's/"on":false/"on":true/' "$STATE/online.json" && ok "Online on (the Mac's tunnel files came along)"
226
+ fi
227
+ fi
228
+ chown -R "$PM_USER:$PM_USER" "$PM_HOME"
229
+ rm -rf "$SEED_DIR"
230
+ fi
231
+
232
+ # ── 5. Node, Claude Code and PMOS, as the user ───────────────────────────────────────────────────────────────
233
+ say "Installing Node, Claude Code and PMOS for $PM_USER"
234
+ local inst; inst="$(mktemp)"
235
+ local here="${BASH_SOURCE[0]:-}"
236
+ if [ -f "$here" ] && [ -f "$(dirname "$here")/install.sh" ]; then cp "$(dirname "$here")/install.sh" "$inst"; else curl -fsSL "$INSTALL_URL" -o "$inst"; fi
237
+ chmod 644 "$inst"
238
+ sudo -u "$PM_USER" -H env PMOS_DIR="$PM_FIRST" PMOS_NO_OPEN=1 ${PMOS_PKG:+PMOS_PKG="$PMOS_PKG"} ${PMOS_SKIP_CLAUDE:+PMOS_SKIP_CLAUDE=1} SHELL=/bin/bash \
239
+ bash -c 'cd ~ && bash "$0"' "$inst" </dev/null || fail "The PMOS install stopped with an error (shown above)." "paste the line again"
240
+ rm -f "$inst"
241
+
242
+ # ── 6. Git on Linux: no macOS keychain; GitHub over HTTPS through the GitHub CLI's sign-in ─────────────────────
243
+ sudo -u "$PM_USER" -H bash -c '
244
+ git config --global --get-all credential.helper 2>/dev/null | grep -q osxkeychain && git config --global --unset-all credential.helper osxkeychain
245
+ git config --global url."https://github.com/".insteadOf "git@github.com:"
246
+ true'
247
+
248
+ # ── 7. The Claude profile (Settings › Claude) ────────────────────────────────────────────────────────────────
249
+ if [ -n "$PM_PROFILE" ] && [ -n "$PM_CLAUDE_DIR" ]; then
250
+ # The same command name as on the Mac, so PMOS finds the profile the way it does there (an alias that sets
251
+ # CLAUDE_CONFIG_DIR). The sign-in itself is `pmos-cloud signin`.
252
+ sudo -u "$PM_USER" -H bash -c 'mkdir -p "$1"; grep -qs "alias $2=" ~/.bashrc || printf "\nalias %s='"'"'CLAUDE_CONFIG_DIR=%s claude'"'"' # added by PMOS cloud setup\n" "$2" "$1" >>~/.bashrc' _ "$PM_CLAUDE_DIR" "$PM_PROFILE"
253
+ ok "Claude profile $PM_PROFILE ($PM_CLAUDE_DIR)"
254
+ fi
255
+
256
+ # ── 8. The minute check ──────────────────────────────────────────────────────────────────────────────────────
257
+ say "Adding the minute check"
258
+ local CLOUD="$PM_HOME/.pmos/cloud"
259
+ install -d -o "$PM_USER" -g "$PM_USER" "$CLOUD"
260
+ # Where install.sh put node (and so pmos) and claude; a systemd job has no shell profile.
261
+ local found; found="$(sudo -u "$PM_USER" -H bash -lc 'printf "%s:%s/bin:" "$(dirname "$(command -v node)")" "$(npm prefix -g)"' 2>/dev/null || true)"
262
+ local UPATH="$found$PM_HOME/.pmos/node/bin:$PM_HOME/.pmos/npm-global/bin:$PM_HOME/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
263
+ printf 'REPO=%q\nPATH=%q\nCLAUDE_DIR=%q\nRC_NAME=%q\n' "$PM_FIRST" "$UPATH" "${PM_CLAUDE_DIR:-}" "PMOS cloud ($(hostname))" >"$CLOUD/env"
264
+ cat >"$CLOUD/keep.sh" <<'KEEP'
265
+ #!/bin/bash
266
+ # Written by cloud-setup.sh. systemd (pmos-keep.timer) runs it every minute, like the Mac's login item.
267
+ # 1. `pmos up --keep`: silent when the workspace answers; starts it when it is down; replaces one stuck for a minute.
268
+ # 2. After `pmos-cloud signin`: keeps `claude remote-control` running in tmux, so Claude can reach this server.
269
+ . "$HOME/.pmos/cloud/env"; export PATH
270
+ LOG="$HOME/.pmos/cloud/keep.log"
271
+ [ -f "$HOME/.pmos/cloud/stopped" ] && exit 0 # `pmos-cloud stop`
272
+ pmos up "$REPO" --no-open --keep >>"$LOG" 2>&1
273
+ if [ -f "$HOME/.pmos/cloud/remote-control.on" ] && ! tmux has-session -t pmos-remote-control 2>/dev/null; then
274
+ echo "$(date -u +%FT%TZ) remote-control: starting" >>"$LOG"
275
+ cd "$REPO" && tmux new-session -d -s pmos-remote-control \
276
+ "${CLAUDE_DIR:+CLAUDE_CONFIG_DIR='$CLAUDE_DIR' }claude remote-control --name '$RC_NAME' --permission-mode auto"
277
+ fi
278
+ # Keep the log small.
279
+ [ "$(wc -c <"$LOG")" -gt 1000000 ] && tail -c 200000 "$LOG" >"$LOG.tmp" && mv "$LOG.tmp" "$LOG"
280
+ exit 0
281
+ KEEP
282
+ chmod 755 "$CLOUD/keep.sh"; chown "$PM_USER:$PM_USER" "$CLOUD/env" "$CLOUD/keep.sh"
283
+
284
+ if [ "${PMOS_NO_SYSTEMD:-}" = 1 ] || ! have systemctl || [ ! -d /run/systemd/system ]; then
285
+ note "no systemd here: run $CLOUD/keep.sh yourself (PMOS_NO_SYSTEMD)"
286
+ else
287
+ cat >/etc/systemd/system/pmos-keep.service <<UNIT
288
+ [Unit]
289
+ Description=PMOS minute check (pmos up --keep, Remote Control keeper)
290
+ After=network-online.target
291
+ Wants=network-online.target
292
+
293
+ [Service]
294
+ Type=oneshot
295
+ User=$PM_USER
296
+ WorkingDirectory=$PM_HOME
297
+ ExecStart=$CLOUD/keep.sh
298
+ # The workspace server and the tmux sessions it starts must outlive this check.
299
+ KillMode=process
300
+ UNIT
301
+ cat >/etc/systemd/system/pmos-keep.timer <<'UNIT'
302
+ [Unit]
303
+ Description=Run the PMOS minute check every minute
304
+
305
+ [Timer]
306
+ OnBootSec=20
307
+ OnUnitActiveSec=60
308
+ AccuracySec=5
309
+
310
+ [Install]
311
+ WantedBy=timers.target
312
+ UNIT
313
+ systemctl daemon-reload
314
+ systemctl enable --now pmos-keep.timer >/dev/null 2>&1
315
+ ok "pmos-keep.timer: every minute, and 20 s after a restart"
316
+ fi
317
+
318
+ # ── 9. The helper command ────────────────────────────────────────────────────────────────────────────────────
319
+ write_helper >/usr/local/bin/pmos-cloud
320
+ chmod 755 /usr/local/bin/pmos-cloud
321
+ ok "pmos-cloud: status, signin, online, add, logs, stop, start"
322
+
323
+ # ── 10. Check ────────────────────────────────────────────────────────────────────────────────────────────────
324
+ say "Checking"
325
+ sudo -u "$PM_USER" -H "$CLOUD/keep.sh"
326
+ sleep 3
327
+ sudo -u "$PM_USER" -H /usr/local/bin/pmos-cloud status || true
328
+
329
+ local IP; IP="$(curl -fsS -4 --max-time 5 https://api.ipify.org 2>/dev/null || hostname -I | awk '{print $1}')"
330
+ echo
331
+ ok "PMOS runs on this server."
332
+ echo
333
+ echo " Your one step left: sign in to Claude and GitHub (about two minutes):"
334
+ echo
335
+ echo " ssh -t $PM_USER@$IP pmos-cloud signin"
336
+ echo
337
+ if [ ! -f "$PM_HOME/.cloudflared/config.yml" ]; then
338
+ echo " Then, for pmos.pm-os.app: ssh -t $PM_USER@$IP pmos-cloud online pmos.pm-os.app"
339
+ echo
340
+ fi
341
+ echo " Open PMOS without Cloudflare: ssh -N -L 7433:127.0.0.1:7433 $PM_USER@$IP then http://localhost:7433"
342
+ }
343
+
344
+ # The `pmos-cloud` helper, installed to /usr/local/bin. It runs as the PMOS user.
345
+ write_helper() {
346
+ cat <<'HELPER'
347
+ #!/bin/bash
348
+ # pmos-cloud — look after PMOS on this server (written by create-pmos cloud-setup.sh; guide: "Run PMOS in the cloud").
349
+ set -uo pipefail
350
+ . "$HOME/.pmos/cloud/env" 2>/dev/null || { echo "PMOS cloud setup is not on this user. Sign in as the PMOS user."; exit 1; }
351
+ export PATH
352
+ CLOUD="$HOME/.pmos/cloud"
353
+ cl() { if [ -n "${CLAUDE_DIR:-}" ]; then CLAUDE_CONFIG_DIR="$CLAUDE_DIR" claude "$@"; else claude "$@"; fi; }
354
+ claude_signed_in() { cl auth status --json 2>/dev/null | grep -q '"loggedIn": *true' || [ -s "${CLAUDE_DIR:-$HOME/.claude}/.credentials.json" ]; }
355
+ case "${1:-status}" in
356
+ status)
357
+ echo "PMOS cloud — $(hostname)"
358
+ v="$(node -p 'require(require("child_process").execSync("npm root -g").toString().trim()+"/pmos-workspace/package.json").version' 2>/dev/null)"
359
+ if (cd "$REPO" && pmos status 2>/dev/null | grep -q '✓ running'); then echo " ✓ workspace: running${v:+ ($v)}"; else echo " ✗ workspace: not answering (the minute check starts it; see: pmos-cloud logs)"; fi
360
+ if claude_signed_in; then echo " ✓ Claude: signed in${CLAUDE_DIR:+ ($CLAUDE_DIR)}"; else echo " ✗ Claude: not signed in — run: pmos-cloud signin"; fi
361
+ if tmux has-session -t pmos-remote-control 2>/dev/null; then echo " ✓ Remote Control: running as \"$RC_NAME\""; elif [ -f "$CLOUD/remote-control.on" ]; then echo " … Remote Control: starts within a minute"; else echo " ○ Remote Control: starts after the sign-in"; fi
362
+ if gh auth status >/dev/null 2>&1; then echo " ✓ GitHub: signed in (records sync)"; else echo " ○ GitHub: not signed in — run: pmos-cloud signin"; fi
363
+ if pgrep -u "$(id -u)" -f 'cloudflared tunnel' >/dev/null; then echo " ✓ Online: the tunnel runs"; elif [ -f "$HOME/.cloudflared/config.yml" ]; then echo " ○ Online: tunnel files are here; turn Online on in Settings › Online"; else echo " ○ Online: not set up — run: pmos-cloud online pmos.pm-os.app"; fi
364
+ ;;
365
+ signin)
366
+ if claude_signed_in; then echo "✓ Claude is signed in."
367
+ else
368
+ echo "Claude: open the link it shows on any device, sign in with your Claude account, and paste the code back here."
369
+ mkdir -p "${CLAUDE_DIR:-$HOME/.claude}"
370
+ (cd "$REPO" && cl auth login --claudeai)
371
+ claude_signed_in && echo "✓ Claude signed in." || echo "✗ Claude is still not signed in. Run: pmos-cloud signin"
372
+ fi
373
+ if gh auth status >/dev/null 2>&1; then echo "✓ GitHub is signed in."
374
+ elif command -v gh >/dev/null; then
375
+ echo "GitHub: open the link it shows, enter the code, and allow access. PMOS uses it to sync records."
376
+ gh auth login --hostname github.com --git-protocol https --web && gh auth setup-git && echo "✓ GitHub signed in."
377
+ fi
378
+ if claude_signed_in; then
379
+ touch "$CLOUD/remote-control.on"; "$CLOUD/keep.sh"; sleep 3
380
+ if tmux has-session -t pmos-remote-control 2>/dev/null; then
381
+ echo "Remote Control runs as \"$RC_NAME\". It opens now: answer any question it asks (such as trusting the folder),"
382
+ echo "then press Ctrl-B and then D. It keeps running after you leave."
383
+ read -r -p "Press Enter to open it. " _
384
+ tmux attach -t pmos-remote-control
385
+ else echo "✗ Remote Control stopped at once. See: tmux new -s rc-test 'claude remote-control'"; fi
386
+ fi
387
+ ;;
388
+ online)
389
+ HOST="${2:-pmos.pm-os.app}"; TUNNEL="${3:-pmos}"
390
+ command -v cloudflared >/dev/null || { echo "cloudflared is missing; run the setup again."; exit 1; }
391
+ [ -f "$HOME/.cloudflared/cert.pem" ] || { echo "Cloudflare: open the link, sign in, and pick the domain of $HOST."; cloudflared tunnel login || exit 1; }
392
+ ID="$(cloudflared tunnel list -o json -n "$TUNNEL" 2>/dev/null | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{const t=JSON.parse(s)[0];if(t)console.log(t.id)}catch{}})')"
393
+ if [ -z "$ID" ]; then
394
+ cloudflared tunnel create "$TUNNEL" >/dev/null || exit 1
395
+ ID="$(cloudflared tunnel list -o json -n "$TUNNEL" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>console.log(JSON.parse(s)[0].id))')"
396
+ cloudflared tunnel route dns "$TUNNEL" "$HOST"
397
+ fi
398
+ # The existing tunnel and its DNS record stay; this server gets its own copy of the tunnel's credentials.
399
+ [ -f "$HOME/.cloudflared/$ID.json" ] || cloudflared tunnel token --cred-file "$HOME/.cloudflared/$ID.json" "$TUNNEL" >/dev/null || exit 1
400
+ DOMAIN="${HOST#*.}"
401
+ cat >"$HOME/.cloudflared/config.yml" <<YML
402
+ tunnel: $TUNNEL
403
+ credentials-file: $HOME/.cloudflared/$ID.json
404
+ ingress:
405
+ - hostname: $HOST
406
+ service: http://127.0.0.1:7433
407
+ - hostname: share.$DOMAIN
408
+ service: http://127.0.0.1:7434
409
+ - service: http_status:404
410
+ YML
411
+ echo "✓ Tunnel $TUNNEL ($ID) is ready for $HOST."
412
+ echo " Now turn Online on in Settings › Online (open PMOS through: ssh -N -L 7433:127.0.0.1:7433 $(id -un)@<server-ip>)."
413
+ echo " Make sure Online is off on the Mac, so only this server answers $HOST."
414
+ ;;
415
+ add)
416
+ shift; [ $# -gt 0 ] || { echo "usage: pmos-cloud add <owner/repo | git URL>..."; exit 1; }
417
+ mkdir -p "$HOME/Project"
418
+ for r in "$@"; do
419
+ case "$r" in http*|git@*) url="$r";; *) url="https://github.com/$r.git";; esac
420
+ dir="$HOME/Project/$(basename "$r" .git)"
421
+ [ -d "$dir/.git" ] || git clone -q "$url" "$dir" || { echo "✗ could not clone $r"; continue; }
422
+ pmos "$dir" --no-open >/dev/null 2>&1 && echo "✓ $dir"
423
+ done
424
+ ;;
425
+ logs) tail -n "${2:-60}" "$CLOUD/keep.log" ;;
426
+ stop) rm -f "$CLOUD/remote-control.on"; touch "$CLOUD/stopped"; (cd "$REPO" && pmos stop); tmux kill-session -t pmos-remote-control 2>/dev/null; pkill -u "$(id -u)" -f 'cloudflared tunnel' 2>/dev/null; echo "✓ stopped. The minute check waits until: pmos-cloud start" ;;
427
+ start) rm -f "$CLOUD/stopped"; claude_signed_in && touch "$CLOUD/remote-control.on"; "$CLOUD/keep.sh"; echo "✓ started" ;;
428
+ *) echo "usage: pmos-cloud status | signin | online [host] [tunnel] | add <owner/repo>... | logs [n] | stop | start"; exit 1 ;;
429
+ esac
430
+ HELPER
431
+ }
432
+
433
+ case "${1:-setup}" in
434
+ move) shift; cmd_move "$@" ;;
435
+ mac-on) cmd_mac_on ;;
436
+ setup) cmd_setup ;;
437
+ *) fail "unknown command: $1" "move root@<server-ip> · mac-on · (no argument: set up this server)" ;;
438
+ esac
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.549.0",
3
+ "version": "0.551.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -11,6 +11,7 @@
11
11
  "payload/",
12
12
  "workspace/",
13
13
  "install.sh",
14
+ "cloud-setup.sh",
14
15
  "install.ps1",
15
16
  "README.md",
16
17
  "LICENSE"
@@ -32,6 +33,32 @@
32
33
  "audit"
33
34
  ],
34
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.551.0",
38
+ "at": "2026-11-10T11:25:58.991Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1279,
43
+ "t": "Intent card on the product page; the Board by goal, and a Next column that says what Claude does next",
44
+ "s": "Intent card on the product page; the Board by goal, and a Next column that says what Claude does next",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.550.0",
51
+ "at": "2026-11-10T08:31:44.572Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1278,
56
+ "t": "Run PMOS on an always-on cloud server — one paste on the Mac moves it, the Mac stays as the fallback",
57
+ "s": "Run PMOS on an always-on cloud server — one paste on the Mac moves it, the Mac stays as the fallback",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
35
62
  {
36
63
  "v": "0.549.0",
37
64
  "at": "2026-11-10T07:06:56.286Z",
@@ -337,32 +364,6 @@
337
364
  "k": "new"
338
365
  }
339
366
  ]
340
- },
341
- {
342
- "v": "0.531.0",
343
- "at": "2026-11-04T18:44:50.726Z",
344
- "f": 4,
345
- "prs": [
346
- {
347
- "n": 1247,
348
- "t": "Report library frame and 23 slide layouts",
349
- "s": "Report library frame and 23 slide layouts",
350
- "k": "new"
351
- }
352
- ]
353
- },
354
- {
355
- "v": "0.530.0",
356
- "at": "2026-11-04T14:38:26.528Z",
357
- "f": 4,
358
- "prs": [
359
- {
360
- "n": 1246,
361
- "t": "Send meeting captures to Jev and keep only the slide (MpJ)",
362
- "s": "Send meeting captures to Jev and keep only the slide (MpJ)",
363
- "k": "new"
364
- }
365
- ]
366
367
  }
367
368
  ]
368
369
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@38a9732b
1
+ kernel-source: pmos@bc3f5f8c
2
2
  assembled: 2026-11-10
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-10T07:06:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-10T11:25:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-10T07:06:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-10T11:25:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-10T07:06:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-10T11:25:55Z"}
6
6
  status: stable
7
7
  ---
8
8