attnmd 0.4.1 → 0.4.3

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/attn.js +32 -5
  2. package/package.json +1 -1
package/bin/attn.js CHANGED
@@ -102,11 +102,12 @@ async function main() {
102
102
  await maybePromptInstallAlias();
103
103
  }
104
104
 
105
- if (headless) {
106
- const binaryPath = join(appPath, "Contents", "MacOS", "attn");
107
- if (!existsSync(binaryPath)) {
108
- throw new Error(`managed app binary is missing at ${binaryPath}`);
109
- }
105
+ const binaryPath = join(appPath, "Contents", "MacOS", "attn");
106
+ if (!existsSync(binaryPath)) {
107
+ throw new Error(`managed app binary is missing at ${binaryPath}`);
108
+ }
109
+
110
+ if (headless || shouldPreserveAppEnvironment()) {
110
111
  run(binaryPath, args);
111
112
  return;
112
113
  }
@@ -386,6 +387,9 @@ async function maybePromptInstallAlias() {
386
387
  return;
387
388
  }
388
389
  if (existsSync(installLinkPath)) {
390
+ if (isManagedAlias()) {
391
+ installAliasLauncher();
392
+ }
389
393
  return;
390
394
  }
391
395
 
@@ -411,6 +415,14 @@ async function maybePromptInstallAlias() {
411
415
  }
412
416
  }
413
417
 
418
+ function isManagedAlias() {
419
+ try {
420
+ return realpathSync(installLinkPath) === realpathSync(installLauncherPath);
421
+ } catch {
422
+ return false;
423
+ }
424
+ }
425
+
414
426
  function installAliasLauncher() {
415
427
  mkdirSync(dirname(installLauncherPath), { recursive: true });
416
428
  mkdirSync(installLinkDir, { recursive: true });
@@ -438,6 +450,9 @@ done
438
450
  if [ "$HEADLESS" -eq 1 ]; then
439
451
  exec "$BINARY" "$@"
440
452
  fi
453
+ if [ -n "\${ATTN_HOME:-}" ] || [ -n "\${ATTN_RELAY_URL:-}" ]; then
454
+ exec "$BINARY" "$@"
455
+ fi
441
456
  # Resolve the first positional arg to an absolute path since open launches with cwd=/
442
457
  RESOLVED_ARGS=()
443
458
  PATH_RESOLVED=0
@@ -529,6 +544,18 @@ function isHeadlessInvocation(args) {
529
544
  return args[0] === "review" || args.some((arg) => HEADLESS_FLAGS.has(arg));
530
545
  }
531
546
 
547
+ function shouldPreserveAppEnvironment() {
548
+ // Launch Services does not reliably pass shell env to the app. `ATTN_HOME`
549
+ // selects the daemon socket namespace, and `ATTN_RELAY_URL` selects the
550
+ // review relay, so direct binary launch is required for multi-instance
551
+ // review flows driven by `npx attnmd`.
552
+ return hasEnvValue("ATTN_HOME") || hasEnvValue("ATTN_RELAY_URL");
553
+ }
554
+
555
+ function hasEnvValue(name) {
556
+ return Boolean(process.env[name] && process.env[name].trim() !== "");
557
+ }
558
+
532
559
  function run(cmd, args) {
533
560
  const child = spawnSync(cmd, args, {
534
561
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attnmd",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "A beautiful markdown viewer that launches from the CLI",
5
5
  "license": "MIT",
6
6
  "repository": {