openclawid 0.0.2 → 0.0.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/openclawid.js +13 -10
  2. package/package.json +1 -1
package/bin/openclawid.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { spawnSync } = require('node:child_process');
4
- const path = require('node:path');
5
4
 
6
5
  const DEFAULT_SITE = 'https://moltbook-replica.vercel.app';
7
6
 
@@ -13,10 +12,14 @@ function hasSiteFlag(argv) {
13
12
  return false;
14
13
  }
15
14
 
16
- function resolveMolthubBin() {
17
- // Prefer local dependency's binary.
18
- // When installed globally / via npx, this should exist.
19
- return path.join(__dirname, '..', 'node_modules', '.bin', process.platform === 'win32' ? 'molthub.cmd' : 'molthub');
15
+ function resolveMolthubEntry() {
16
+ // IMPORTANT: npm/pnpm do NOT guarantee creating nested node_modules/.bin shims
17
+ // for dependencies of a package (only for the root project). When openclawid
18
+ // is executed via `npx openclawid`, the molthub binary shim may not exist at:
19
+ // node_modules/.bin/molthub
20
+ // So we resolve molthub's actual JS entry file and invoke it via Node.
21
+ // This works for npm, pnpm, yarn, and npx temp installs.
22
+ return require.resolve('molthub/bin/clawdhub.js');
20
23
  }
21
24
 
22
25
  function main() {
@@ -27,17 +30,17 @@ function main() {
27
30
  finalArgs.push('--site', DEFAULT_SITE);
28
31
  }
29
32
 
30
- const binPath = resolveMolthubBin();
33
+ const entryPath = resolveMolthubEntry();
31
34
 
32
- const result = spawnSync(binPath, finalArgs, {
35
+ // Use the same node executable that is running this script.
36
+ const result = spawnSync(process.execPath, [entryPath, ...finalArgs], {
33
37
  stdio: 'inherit',
34
38
  env: process.env
35
39
  });
36
40
 
37
41
  if (result.error) {
38
- // Friendly hint if molthub wasn't installed properly.
39
- console.error('\n[openclawid] Failed to run molthub:', result.error.message);
40
- console.error('[openclawid] Try: npm i -g molthub (or ensure it is installed as a dependency)');
42
+ console.error('\n[openclawid] Failed to run molthub entry:', result.error.message);
43
+ console.error('[openclawid] Ensure molthub is installed as a dependency of openclawid (it should be).');
41
44
  process.exit(1);
42
45
  }
43
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawid",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "OpenClaw ID helper CLI (wrapper around molthub)",
5
5
  "license": "MIT",
6
6
  "author": "FerryF19999",