trooper-cli 0.1.2 → 0.1.4

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.
Files changed (3) hide show
  1. package/README.md +88 -0
  2. package/bin/trooper.js +25 -16
  3. package/package.json +23 -3
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # trooper-cli
2
+
3
+ Official command-line installer for Trooper's local desktop runtime.
4
+
5
+ Trooper can run on your own Mac without a hosted cloud computer. This CLI installs the local bridge, starts the local AI gateway, and lets the Trooper desktop app pair the machine to your workspace.
6
+
7
+ ## Quick Start
8
+
9
+ Install Trooper locally on this Mac:
10
+
11
+ ```bash
12
+ npx -y trooper-cli onboard --yes
13
+ ```
14
+
15
+ Then open the Trooper desktop app to connect this computer to your workspace.
16
+
17
+ ## What It Sets Up
18
+
19
+ On macOS, `trooper-cli onboard --yes` prepares:
20
+
21
+ - A local Trooper bridge on `http://127.0.0.1:3002`
22
+ - A local AI gateway on `http://127.0.0.1:18789`
23
+ - LaunchAgents so the local host can keep running
24
+ - A Docker-compatible runtime using existing Docker or Colima when needed
25
+ - Local runtime files under `~/Library/Application Support/Trooper/runtime`
26
+
27
+ The local desktop plan does not require a Trooper cloud computer or Stripe checkout.
28
+
29
+ ## Commands
30
+
31
+ ### Install local runtime
32
+
33
+ ```bash
34
+ npx -y trooper-cli onboard --yes
35
+ ```
36
+
37
+ ### Install with a Trooper setup token
38
+
39
+ The Trooper app may generate a short-lived setup token for workspace pairing:
40
+
41
+ ```bash
42
+ npx -y trooper-cli onboard --yes \
43
+ --token lst_example \
44
+ --api https://trooper-production.up.railway.app \
45
+ --platform macos
46
+ ```
47
+
48
+ ### Preview the installer command
49
+
50
+ ```bash
51
+ npx -y trooper-cli onboard --yes --dry-run
52
+ ```
53
+
54
+ ### Uninstall local runtime
55
+
56
+ ```bash
57
+ npx -y --prefer-online trooper-cli@latest uninstall --yes
58
+ ```
59
+
60
+ This removes Trooper's local runtime, LaunchAgents, installer command file, and Trooper local Docker container. It leaves Docker, Colima, Homebrew, Node, and npm installed because those may be used by other projects.
61
+
62
+ Keep local workspace/config data:
63
+
64
+ ```bash
65
+ npx -y --prefer-online trooper-cli@latest uninstall --yes --keep-data
66
+ ```
67
+
68
+ Also try to remove the desktop app:
69
+
70
+ ```bash
71
+ npx -y --prefer-online trooper-cli@latest uninstall --yes --remove-app
72
+ ```
73
+
74
+ ## Requirements
75
+
76
+ - Node.js 18 or newer
77
+ - macOS for tokenless local desktop install
78
+ - Administrator access may be requested if ownership repair or local runtime dependencies need it
79
+
80
+ ## Desktop App
81
+
82
+ Local desktop install is meant to be started from the Trooper Mac or Windows app. The web onboarding page shows the plan, but only the desktop app can safely launch the local helper installer.
83
+
84
+ ## Links
85
+
86
+ - Website: https://trooper.so
87
+ - App: https://app.trooper.so
88
+ - Package: https://www.npmjs.com/package/trooper-cli
package/bin/trooper.js CHANGED
@@ -111,10 +111,12 @@ function buildLocalMacUninstallCommand({ keepData = false, removeApp = false } =
111
111
  return `set -euo pipefail
112
112
  export PATH="/opt/homebrew/bin:/usr/local/bin:/Applications/Docker.app/Contents/Resources/bin:$HOME/Applications/Docker.app/Contents/Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin"
113
113
  TROOPER_HOME="\${TROOPER_HOME:-$HOME/Library/Application Support/Trooper/runtime}"
114
- TROOPER_PARENT_DIR="\$(dirname "$TROOPER_HOME")"
114
+ TROOPER_PARENT_DIR="\$(/usr/bin/dirname "$TROOPER_HOME")"
115
115
  PLIST_DIR="$HOME/Library/LaunchAgents"
116
116
  OPENCLAW_GATEWAY_CONTAINER="\${OPENCLAW_GATEWAY_CONTAINER:-openclaw-openclaw-gateway-1}"
117
117
  LABELS=(${labels})
118
+ USER_ID="\$(/usr/bin/id -u)"
119
+ GROUP_ID="\$(/usr/bin/id -g)"
118
120
 
119
121
  echo "Uninstalling Trooper local host from this Mac..."
120
122
 
@@ -126,33 +128,40 @@ for path in "$TROOPER_HOME" "$TROOPER_PARENT_DIR/install-local-host.command" "$P
126
128
  done
127
129
  if (( \${#ROOT_OWNED_PATHS[@]} > 0 )); then
128
130
  echo "Repairing ownership from an earlier Trooper local-host installation..."
129
- sudo chown -R "\$(id -u):\$(id -g)" "\${ROOT_OWNED_PATHS[@]}"
131
+ /usr/bin/sudo /usr/sbin/chown -R "$USER_ID:$GROUP_ID" "\${ROOT_OWNED_PATHS[@]}"
130
132
  fi
131
133
 
132
134
  for label in "\${LABELS[@]}"; do
133
- launchctl bootout "gui/\$(id -u)/$label" >/dev/null 2>&1 || true
134
- launchctl bootout "gui/\$(id -u)" "$PLIST_DIR/$label.plist" >/dev/null 2>&1 || true
135
- rm -f "$PLIST_DIR/$label.plist"
135
+ /bin/launchctl bootout "gui/$USER_ID/$label" >/dev/null 2>&1 || true
136
+ /bin/launchctl bootout "gui/$USER_ID" "$PLIST_DIR/$label.plist" >/dev/null 2>&1 || true
137
+ /bin/rm -f "$PLIST_DIR/$label.plist"
136
138
  done
137
139
 
138
- if command -v docker >/dev/null 2>&1; then
139
- docker rm -f "$OPENCLAW_GATEWAY_CONTAINER" trooper-local-gateway >/dev/null 2>&1 || true
140
+ DOCKER_BIN=""
141
+ for candidate in /opt/homebrew/bin/docker /usr/local/bin/docker /Applications/Docker.app/Contents/Resources/bin/docker "$HOME/Applications/Docker.app/Contents/Resources/bin/docker"; do
142
+ if [[ -x "$candidate" ]]; then
143
+ DOCKER_BIN="$candidate"
144
+ break
145
+ fi
146
+ done
147
+ if [[ -n "$DOCKER_BIN" ]]; then
148
+ "$DOCKER_BIN" rm -f "$OPENCLAW_GATEWAY_CONTAINER" trooper-local-gateway >/dev/null 2>&1 || true
140
149
  fi
141
150
 
142
- rm -f "$TROOPER_PARENT_DIR/install-local-host.command" /tmp/trooper-local-mac-host.sh
151
+ /bin/rm -f "$TROOPER_PARENT_DIR/install-local-host.command" /tmp/trooper-local-mac-host.sh
143
152
 
144
153
  if [[ ${keepData ? '1' : '0'} == "1" ]]; then
145
- rm -rf "$TROOPER_HOME/bridge" "$TROOPER_HOME/bin" "$TROOPER_HOME/logs"
146
- rm -f "$TROOPER_HOME/trooper-local-host.env"
154
+ /bin/rm -rf "$TROOPER_HOME/bridge" "$TROOPER_HOME/bin" "$TROOPER_HOME/logs"
155
+ /bin/rm -f "$TROOPER_HOME/trooper-local-host.env"
147
156
  echo "Preserved local Trooper data at: $TROOPER_HOME/openclaw-data"
148
157
  else
149
- rm -rf "$TROOPER_HOME"
158
+ /bin/rm -rf "$TROOPER_HOME"
150
159
  fi
151
160
 
152
161
  if [[ ${removeApp ? '1' : '0'} == "1" ]]; then
153
- rm -rf "$HOME/Applications/Trooper.app" 2>/dev/null || true
162
+ /bin/rm -rf "$HOME/Applications/Trooper.app" 2>/dev/null || true
154
163
  if [[ -d "/Applications/Trooper.app" ]]; then
155
- rm -rf "/Applications/Trooper.app" 2>/dev/null || echo "Trooper.app in /Applications still exists; remove it from Finder or rerun with permission."
164
+ /bin/rm -rf "/Applications/Trooper.app" 2>/dev/null || echo "Trooper.app in /Applications still exists; remove it from Finder or rerun with permission."
156
165
  fi
157
166
  fi
158
167
 
@@ -185,11 +194,11 @@ async function fetchSetupGuide({ apiUrl, token, platform }) {
185
194
  return data;
186
195
  }
187
196
 
188
- function runShellCommand(command, platform, { failureLabel = 'Command', successMessage = '' } = {}) {
197
+ function runShellCommand(command, platform, { failureLabel = 'Command', successMessage = '', shell } = {}) {
189
198
  const isWindows = platform === 'windows' || process.platform === 'win32';
190
199
  const child = isWindows
191
200
  ? spawn('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', command], { stdio: 'inherit' })
192
- : spawn(process.platform === 'darwin' ? '/bin/zsh' : '/bin/bash', ['-lc', command], { stdio: 'inherit' });
201
+ : spawn(shell || (process.platform === 'darwin' ? '/bin/zsh' : '/bin/bash'), ['-lc', command], { stdio: 'inherit' });
193
202
 
194
203
  child.on('error', (error) => {
195
204
  console.error(`Could not start ${failureLabel.toLowerCase()}: ${error.message}`);
@@ -241,7 +250,7 @@ async function main() {
241
250
  console.log(uninstallCommand);
242
251
  return;
243
252
  }
244
- runShellCommand(uninstallCommand, platform, { failureLabel: 'Uninstall' });
253
+ runShellCommand(uninstallCommand, platform, { failureLabel: 'Uninstall', shell: '/bin/bash' });
245
254
  return;
246
255
  }
247
256
 
package/package.json CHANGED
@@ -1,14 +1,34 @@
1
1
  {
2
2
  "name": "trooper-cli",
3
- "version": "0.1.2",
4
- "description": "Trooper local host setup CLI",
3
+ "version": "0.1.4",
4
+ "description": "Official Trooper CLI for installing and managing the local desktop AI runtime.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "trooper": "bin/trooper.js"
8
8
  },
9
9
  "files": [
10
- "bin"
10
+ "bin",
11
+ "README.md"
11
12
  ],
13
+ "keywords": [
14
+ "trooper",
15
+ "ai",
16
+ "local-ai",
17
+ "desktop-ai",
18
+ "agent",
19
+ "automation",
20
+ "macos",
21
+ "self-hosted"
22
+ ],
23
+ "homepage": "https://trooper.so",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/absurdfounder/Trooper.git",
27
+ "directory": "packages/cli"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/absurdfounder/Trooper/issues"
31
+ },
12
32
  "engines": {
13
33
  "node": ">=18"
14
34
  },