@xyrlan/mnemo 0.13.3 → 0.14.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/lib/bootstrap.js CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  const { execSync, spawnSync } = require("node:child_process");
4
4
  const { probeOnPath } = require("./detect");
5
+ const { resolveMnemoBinary } = require("./runMnemo");
5
6
 
6
7
 
7
- const PIN_SPEC = "mnemo-claude>=0.13,<0.14";
8
+ const PIN_SPEC = "mnemo-claude>=0.14,<0.15";
8
9
 
9
10
 
10
11
  function buildInstallCmd(installer, spec = PIN_SPEC) {
@@ -27,8 +28,13 @@ function buildUpgradeCmd(installer) {
27
28
  }
28
29
 
29
30
 
30
- function isAlreadyInstalled(probeFn = probeOnPath) {
31
- return probeFn("mnemo");
31
+ // Detect a real mnemo install. We can NOT trust `command -v mnemo` here:
32
+ // when running under `npx @xyrlan/mnemo`, npm injects the wrapper itself
33
+ // onto PATH, so `command -v mnemo` resolves to us. resolveMnemoBinary
34
+ // filters npx temp dirs so it only matches a real Python install.
35
+ function isAlreadyInstalled(resolverFn = resolveMnemoBinary) {
36
+ const selfBinDir = process.argv[1] ? require("node:path").dirname(process.argv[1]) : null;
37
+ return Boolean(resolverFn({ selfBinDir }));
32
38
  }
33
39
 
34
40
 
package/lib/runMnemo.js CHANGED
@@ -26,8 +26,6 @@ function buildUninstallArgs({ scope, quiet, yes = true }) {
26
26
 
27
27
  // Resolve the real Python `mnemo` entry point, skipping the npx-injected
28
28
  // wrapper bin so spawnSync doesn't recurse into us.
29
- // `selfBinDir` defaults to the directory of the currently executing
30
- // wrapper (process.argv[1]); override for testing.
31
29
  function resolveMnemoBinary({ env = process.env, platform = process.platform, selfBinDir } = {}) {
32
30
  const exeName = platform === "win32" ? "mnemo.exe" : "mnemo";
33
31
  const sep = platform === "win32" ? ";" : ":";
@@ -44,12 +42,21 @@ function resolveMnemoBinary({ env = process.env, platform = process.platform, se
44
42
  }
45
43
 
46
44
 
45
+ // Decide what to spawn. If we have a resolved real binary, run it directly.
46
+ // Otherwise fall back to `python3 -m mnemo` so we never recurse into the
47
+ // npx-injected wrapper that may still be on PATH.
48
+ function buildSpawnPlan(bin, args) {
49
+ if (bin) return { cmd: bin, args };
50
+ return { cmd: "python3", args: ["-m", "mnemo", ...args] };
51
+ }
52
+
53
+
47
54
  function runMnemo(args, { quiet = false, selfBinDir } = {}) {
48
55
  const bin = resolveMnemoBinary({ selfBinDir: selfBinDir || (process.argv[1] && path.dirname(process.argv[1])) });
49
- const target = bin || "mnemo";
50
- const result = spawnSync(target, args, { stdio: quiet ? "ignore" : "inherit" });
56
+ const plan = buildSpawnPlan(bin, args);
57
+ const result = spawnSync(plan.cmd, plan.args, { stdio: quiet ? "ignore" : "inherit" });
51
58
  return result.status === null ? 1 : result.status;
52
59
  }
53
60
 
54
61
 
55
- module.exports = { buildInitArgs, buildUninstallArgs, runMnemo, resolveMnemoBinary };
62
+ module.exports = { buildInitArgs, buildUninstallArgs, runMnemo, resolveMnemoBinary, buildSpawnPlan };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyrlan/mnemo",
3
- "version": "0.13.3",
3
+ "version": "0.14.0",
4
4
  "description": "One-command installer for mnemo (the Obsidian that populates itself).",
5
5
  "bin": {
6
6
  "mnemo": "bin/mnemo.js"