@silicaclaw/cli 1.0.0-beta.13 → 1.0.0-beta.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silicaclaw/cli",
3
- "version": "1.0.0-beta.13",
3
+ "version": "1.0.0-beta.14",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawnSync } from "node:child_process";
4
- import { existsSync, readFileSync } from "node:fs";
4
+ import { accessSync, constants, existsSync, readFileSync } from "node:fs";
5
5
  import { dirname, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
 
@@ -58,6 +58,20 @@ function isNpxRun() {
58
58
  return ROOT_DIR.includes("/.npm/_npx/");
59
59
  }
60
60
 
61
+ function canWriteGlobalPrefix() {
62
+ try {
63
+ const prefixResult = runCapture("npm", ["prefix", "-g"]);
64
+ if ((prefixResult.status ?? 1) !== 0) return false;
65
+ const prefix = String(prefixResult.stdout || "").trim();
66
+ if (!prefix) return false;
67
+ const targetDir = resolve(prefix, "lib", "node_modules");
68
+ accessSync(targetDir, constants.W_OK);
69
+ return true;
70
+ } catch {
71
+ return false;
72
+ }
73
+ }
74
+
61
75
  function showUpdateGuide(current, latest, beta) {
62
76
  console.log("SilicaClaw update check");
63
77
  console.log(`current: ${current}`);
@@ -82,10 +96,17 @@ function showUpdateGuide(current, latest, beta) {
82
96
  console.log(" alias silicaclaw='npx -y @silicaclaw/cli@beta'");
83
97
  console.log(" silicaclaw version");
84
98
  console.log("");
85
- console.log("3) global install mode (optional)");
86
- console.log(" npm i -g @silicaclaw/cli@beta");
87
- console.log(" silicaclaw version");
88
- console.log("");
99
+ const writableGlobal = canWriteGlobalPrefix();
100
+ if (writableGlobal) {
101
+ console.log("3) global install mode (optional)");
102
+ console.log(" npm i -g @silicaclaw/cli@beta");
103
+ console.log(" silicaclaw version");
104
+ console.log("");
105
+ } else {
106
+ console.log("Global install skipped: current npm global directory is not writable (likely EACCES).");
107
+ console.log("Use npx or alias mode above.");
108
+ console.log("");
109
+ }
89
110
  if (isNpxRun()) {
90
111
  console.log("Detected npx runtime: use npx commands above for immediate update.");
91
112
  }