recappi 0.1.29 → 0.1.30

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/dist/index.js CHANGED
@@ -20091,8 +20091,19 @@ function readCliVersion() {
20091
20091
  var CLI_VERSION = readCliVersion();
20092
20092
 
20093
20093
  // src/record.tsx
20094
- import { chmodSync, existsSync, statSync } from "fs";
20094
+ import {
20095
+ chmodSync,
20096
+ cpSync,
20097
+ existsSync,
20098
+ mkdirSync as mkdirSync2,
20099
+ readFileSync as readFileSync2,
20100
+ renameSync,
20101
+ rmSync as rmSync2,
20102
+ statSync,
20103
+ writeFileSync
20104
+ } from "fs";
20095
20105
  import { createRequire as createRequire2 } from "module";
20106
+ import { homedir } from "os";
20096
20107
  import { dirname, join as join2 } from "path";
20097
20108
  import { fileURLToPath } from "url";
20098
20109
  import { render, useInput as useInput2 } from "ink";
@@ -20668,7 +20679,7 @@ function resolveSidecarCommand(opts) {
20668
20679
  const command = opts.sidecarCommand?.trim() || opts.env?.[SIDECAR_COMMAND_ENV]?.trim();
20669
20680
  if (command) return command;
20670
20681
  const bundled = bundledSidecarCommand(process.platform, process.arch);
20671
- if (bundled && existsSync(bundled)) return ensureBundledHelperExecutable(bundled);
20682
+ if (bundled && existsSync(bundled)) return ensureBundledHelperExecutable(bundled, opts);
20672
20683
  const platform = `${process.platform}-${process.arch}`;
20673
20684
  if (bundled) {
20674
20685
  throw cliError("record.helper_unavailable", "Recappi recording helper is not available.", {
@@ -20679,16 +20690,17 @@ function resolveSidecarCommand(opts) {
20679
20690
  hint: `No bundled helper is registered for ${platform}. Set ${SIDECAR_COMMAND_ENV} to a compatible helper when one is available.`
20680
20691
  });
20681
20692
  }
20682
- function ensureBundledHelperExecutable(path6) {
20693
+ function ensureBundledHelperExecutable(path6, opts = {}) {
20683
20694
  if (process.platform === "darwin" && path6.endsWith(".app")) {
20684
- const executable = darwinAppExecutablePath(path6);
20695
+ const stableApp = ensureStableDarwinHelperApp(path6, opts);
20696
+ const executable = darwinAppExecutablePath(stableApp);
20685
20697
  if (!existsSync(executable)) {
20686
20698
  throw cliError("record.helper_unavailable", "Recappi recording helper is not available.", {
20687
- hint: `Expected bundled helper executable inside ${path6}. Reinstall recappi, or set ${SIDECAR_COMMAND_ENV} to a compatible helper.`
20699
+ hint: `Expected bundled helper executable inside ${stableApp}. Reinstall recappi, or set ${SIDECAR_COMMAND_ENV} to a compatible helper.`
20688
20700
  });
20689
20701
  }
20690
20702
  ensureExecutableMode(executable);
20691
- return path6;
20703
+ return stableApp;
20692
20704
  }
20693
20705
  if (process.platform === "win32") return path6;
20694
20706
  ensureExecutableMode(path6);
@@ -20706,6 +20718,54 @@ function ensureExecutableMode(path6) {
20706
20718
  });
20707
20719
  }
20708
20720
  }
20721
+ function ensureStableDarwinHelperApp(sourceApp, opts = {}) {
20722
+ const targetApp = stableDarwinHelperAppPath(opts);
20723
+ const markerPath = join2(dirname(targetApp), ".recappi-helper-source");
20724
+ const signature = helperSourceSignature(sourceApp);
20725
+ const currentSignature = readTextIfExists(markerPath);
20726
+ if (existsSync(darwinAppExecutablePath(targetApp)) && currentSignature === signature) {
20727
+ return targetApp;
20728
+ }
20729
+ const tempApp = `${targetApp}.tmp-${process.pid}-${Date.now()}`;
20730
+ try {
20731
+ mkdirSync2(dirname(targetApp), { recursive: true });
20732
+ rmSync2(tempApp, { recursive: true, force: true });
20733
+ cpSync(sourceApp, tempApp, { recursive: true });
20734
+ ensureExecutableMode(darwinAppExecutablePath(tempApp));
20735
+ rmSync2(targetApp, { recursive: true, force: true });
20736
+ renameSync(tempApp, targetApp);
20737
+ writeFileSync(markerPath, signature);
20738
+ return targetApp;
20739
+ } catch (error51) {
20740
+ rmSync2(tempApp, { recursive: true, force: true });
20741
+ const message = error51 instanceof Error ? error51.message : String(error51);
20742
+ throw cliError("record.helper_unavailable", "Recappi recording helper could not be installed.", {
20743
+ hint: `Could not prepare the local recorder at ${targetApp}: ${message}. Reinstall recappi, or set ${SIDECAR_COMMAND_ENV} to a compatible helper.`
20744
+ });
20745
+ }
20746
+ }
20747
+ function stableDarwinHelperAppPath(opts = {}) {
20748
+ const base = opts.env?.RECAPPI_HELPER_HOME?.trim() || join2(opts.homeDir ?? homedir(), "Library", "Application Support", "Recappi", "CLI Helper");
20749
+ return join2(base, `${process.platform}-${process.arch}`, SIDECAR_APP_BUNDLE_NAME);
20750
+ }
20751
+ function helperSourceSignature(sourceApp) {
20752
+ const executable = statSync(darwinAppExecutablePath(sourceApp));
20753
+ const info = statSync(join2(sourceApp, "Contents", "Info.plist"));
20754
+ return JSON.stringify({
20755
+ app: SIDECAR_APP_BUNDLE_NAME,
20756
+ executableSize: executable.size,
20757
+ executableMtimeMs: executable.mtimeMs,
20758
+ infoSize: info.size,
20759
+ infoMtimeMs: info.mtimeMs
20760
+ });
20761
+ }
20762
+ function readTextIfExists(path6) {
20763
+ try {
20764
+ return readFileSync2(path6, "utf8");
20765
+ } catch {
20766
+ return null;
20767
+ }
20768
+ }
20709
20769
  function bundledSidecarCommand(platform, arch) {
20710
20770
  const executable = helperExecutableName(platform);
20711
20771
  if (!executable) return null;