squad-station 0.8.17 → 0.8.19

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 (2) hide show
  1. package/bin/run.js +84 -14
  2. package/package.json +1 -1
package/bin/run.js CHANGED
@@ -45,7 +45,7 @@ function install() {
45
45
 
46
46
  function installBinary() {
47
47
  // Binary version — may differ from npm package version
48
- var VERSION = '0.8.17';
48
+ var VERSION = '0.8.19';
49
49
  var REPO = 'thientranhung/squad-station';
50
50
 
51
51
  var isWindows = process.platform === 'win32';
@@ -75,6 +75,7 @@ function installBinary() {
75
75
  var result = spawnSync(destPath, ['--version'], { encoding: 'utf8' });
76
76
  if (result.stdout && result.stdout.includes(VERSION)) {
77
77
  console.log(' \x1b[32m✓\x1b[0m squad-station v' + VERSION + ' already installed at ' + destPath);
78
+ checkDuplicateBinary(destPath);
78
79
  return;
79
80
  }
80
81
  } catch (_) {
@@ -118,6 +119,9 @@ function installBinary() {
118
119
 
119
120
  // Verify the binary is actually callable via PATH
120
121
  verifyInPath(destPath, installDir);
122
+
123
+ // Check for duplicate binaries at other locations
124
+ checkDuplicateBinary(destPath);
121
125
  }
122
126
 
123
127
  // Find the best install directory that is already in the user's PATH.
@@ -170,7 +174,7 @@ function findBestInstallDir() {
170
174
  return squadBin;
171
175
  }
172
176
 
173
- // Verify the installed binary is callable. If not, print PATH instructions.
177
+ // Verify the installed binary is callable. If not, auto-add to shell profile.
174
178
  function verifyInPath(destPath, installDir) {
175
179
  var isWindows = process.platform === 'win32';
176
180
  var checkCmd = isWindows ? 'where' : 'which';
@@ -181,28 +185,94 @@ function verifyInPath(destPath, installDir) {
181
185
  return;
182
186
  }
183
187
 
184
- // Not in PATH — print instructions
185
- console.log('');
186
- console.log(' \x1b[33m⚠ squad-station is not in your PATH\x1b[0m');
187
- console.log(' The binary was installed to: \x1b[36m' + installDir + '\x1b[0m');
188
- console.log('');
189
-
190
188
  if (isWindows) {
191
- console.log(' Add to your PATH:');
189
+ // Windows: print manual instructions (modifying registry is too invasive)
192
190
  console.log('');
191
+ console.log(' \x1b[33m⚠ squad-station is not in your PATH\x1b[0m');
193
192
  console.log(' \x1b[2m# Windows (PowerShell) — run as Administrator:\x1b[0m');
194
193
  console.log(' \x1b[36m[Environment]::SetEnvironmentVariable("Path",\x1b[0m');
195
194
  console.log(' \x1b[36m [Environment]::GetEnvironmentVariable("Path", "User") + ";' + installDir + '", "User")\x1b[0m');
196
- console.log('');
197
195
  console.log(' Then restart your terminal.');
198
- } else {
199
- var shellProfile = process.platform === 'darwin' ? '~/.zshrc' : '~/.bashrc';
200
- console.log(' Add to your shell profile: \x1b[36mexport PATH="$HOME/.squad/bin:$PATH"\x1b[0m');
201
- console.log(' Then restart your terminal or run: \x1b[36msource ' + shellProfile + '\x1b[0m');
196
+ console.log('');
197
+ return;
202
198
  }
199
+
200
+ // macOS/Linux: auto-add to shell profile
201
+ var home = process.env.HOME || '';
202
+ var exportLine = 'export PATH="$HOME/.squad/bin:$PATH"';
203
+ var profileCandidates = process.platform === 'darwin'
204
+ ? ['.zshrc', '.bash_profile', '.bashrc']
205
+ : ['.bashrc', '.zshrc', '.profile'];
206
+
207
+ // Find the first existing profile, or default to the platform's primary
208
+ var profileName = profileCandidates[0];
209
+ for (var i = 0; i < profileCandidates.length; i++) {
210
+ if (fs.existsSync(path.join(home, profileCandidates[i]))) {
211
+ profileName = profileCandidates[i];
212
+ break;
213
+ }
214
+ }
215
+ var profilePath = path.join(home, profileName);
216
+
217
+ // Check if already added (idempotent)
218
+ var alreadyAdded = false;
219
+ try {
220
+ var content = fs.readFileSync(profilePath, 'utf8');
221
+ if (content.includes('.squad/bin')) {
222
+ alreadyAdded = true;
223
+ }
224
+ } catch (_) {
225
+ // File doesn't exist yet — we'll create it
226
+ }
227
+
228
+ if (!alreadyAdded) {
229
+ try {
230
+ var marker = '\n# Squad Station\n' + exportLine + '\n';
231
+ fs.appendFileSync(profilePath, marker);
232
+ console.log(' \x1b[32m✓\x1b[0m Added ~/.squad/bin to PATH in ~/' + profileName);
233
+ } catch (e) {
234
+ console.log(' \x1b[33m⚠\x1b[0m Could not update ~/' + profileName + ': ' + e.message);
235
+ console.log(' Add manually: \x1b[36m' + exportLine + '\x1b[0m');
236
+ console.log('');
237
+ return;
238
+ }
239
+ }
240
+
241
+ // Source the profile so it takes effect in the current npx process isn't needed,
242
+ // but we need the user's NEXT terminal to work. Print a note.
243
+ console.log(' \x1b[33m→\x1b[0m Run \x1b[36msource ~/' + profileName + '\x1b[0m or open a new terminal to activate.');
203
244
  console.log('');
204
245
  }
205
246
 
247
+ // Check if another squad-station binary exists at a different path than where we installed.
248
+ function checkDuplicateBinary(installedPath) {
249
+ var isWindows = process.platform === 'win32';
250
+ var checkCmd = isWindows ? 'where' : 'which';
251
+ var result = spawnSync(checkCmd, ['squad-station'], { encoding: 'utf8' });
252
+
253
+ if (result.status !== 0 || !result.stdout || !result.stdout.trim()) {
254
+ return; // not in PATH at all — verifyInPath already warned
255
+ }
256
+
257
+ var whichPath = result.stdout.trim();
258
+
259
+ // Ignore npx cache / node_modules wrappers — these are not real installs
260
+ if (whichPath.includes('.npm/_npx') || whichPath.includes('node_modules/.bin') || whichPath.includes('node_modules\\.bin')) {
261
+ return;
262
+ }
263
+
264
+ var resolvedWhich = fs.realpathSync(whichPath);
265
+ var resolvedInstalled = fs.realpathSync(installedPath);
266
+
267
+ if (resolvedWhich !== resolvedInstalled) {
268
+ console.log('');
269
+ console.log(' \x1b[33m⚠ Another squad-station found at: ' + whichPath + '\x1b[0m');
270
+ console.log(' This version will be used instead of the one just installed.');
271
+ console.log(' Remove it to avoid conflicts: \x1b[36mrm ' + whichPath + '\x1b[0m');
272
+ console.log('');
273
+ }
274
+ }
275
+
206
276
  // ── Uninstall ───────────────────────────────────────────────────────
207
277
  // Find and remove all squad-station binaries from known locations.
208
278
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squad-station",
3
- "version": "0.8.17",
3
+ "version": "0.8.19",
4
4
  "description": "Message routing and orchestration for AI agent squads",
5
5
  "repository": {
6
6
  "type": "git",