yaver-cli 1.99.192 → 1.99.194

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/package.json +1 -1
  2. package/src/postinstall.js +58 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaver-cli",
3
- "version": "1.99.192",
3
+ "version": "1.99.194",
4
4
  "mcpName": "io.github.kivanccakmak/yaver",
5
5
  "description": "Unified npm bootstrap for the Yaver agent, SDK injection, and local-first developer runtime",
6
6
  "bin": {
@@ -272,6 +272,63 @@ function ensurePathOnUnix() {
272
272
  }
273
273
  }
274
274
 
275
+ // Belt-and-braces companion to ensurePathOnUnix: write the same PATH
276
+ // rescue into ~/.zshenv. .zshrc patches break when the rc fails to
277
+ // fully load — e.g. one user had a hanging `gcloud completion.zsh.inc`
278
+ // `source` line whose interrupt aborted the rc before the appended
279
+ // yaver PATH block ever ran, so `yaver` was "command not found" in
280
+ // every new terminal even though the install succeeded. .zshenv loads
281
+ // on every zsh shell before .zshrc and is unaffected by .zshrc errors,
282
+ // so it survives that failure mode. Best-effort, never throws.
283
+ function ensureZshenvRescue() {
284
+ try {
285
+ if (process.platform === "win32") return;
286
+ const prefix = (process.env.npm_config_prefix || "").trim();
287
+ if (!prefix) return;
288
+ const binDir = path.join(prefix, "bin");
289
+ if (!fs.existsSync(path.join(binDir, "yaver"))) return;
290
+
291
+ const home = os.homedir();
292
+ if (!home) return;
293
+
294
+ // Only touch .zshenv when the user actually uses zsh; otherwise we'd
295
+ // be creating a dotfile they never asked for.
296
+ const shell = String(process.env.SHELL || "");
297
+ const usesZsh =
298
+ shell.endsWith("/zsh") ||
299
+ fs.existsSync(path.join(home, ".zshrc")) ||
300
+ fs.existsSync(path.join(home, ".zshenv"));
301
+ if (!usesZsh) return;
302
+
303
+ const zshenv = path.join(home, ".zshenv");
304
+ const marker = "# yaver-cli zshenv rescue";
305
+ const yaverNodeBin = path.join(home, ".yaver", "runtimes", "node", "bin");
306
+ const dirs = [yaverNodeBin, binDir];
307
+ const dirsLiteral = dirs.map((d) => `"${d}"`).join(" ");
308
+ const block =
309
+ `\n${marker} (added by yaver-cli postinstall)\n` +
310
+ "# Loads on every zsh shell before .zshrc, so yaver stays on PATH\n" +
311
+ "# even if .zshrc fails to fully load.\n" +
312
+ `for __yaver_d in ${dirsLiteral}; do\n` +
313
+ " case \":$PATH:\" in\n" +
314
+ " *\":$__yaver_d:\"*) ;;\n" +
315
+ " *) export PATH=\"$__yaver_d:$PATH\" ;;\n" +
316
+ " esac\n" +
317
+ "done\n" +
318
+ "unset __yaver_d\n";
319
+
320
+ let existing = "";
321
+ if (fs.existsSync(zshenv)) {
322
+ existing = fs.readFileSync(zshenv, "utf8");
323
+ if (existing.includes(marker)) return;
324
+ }
325
+ fs.appendFileSync(zshenv, block);
326
+ log(`Patched ~/.zshenv with PATH rescue (yaver + bundled node).`);
327
+ } catch (_) {
328
+ // Best-effort only.
329
+ }
330
+ }
331
+
275
332
  // Update ~/.yaver/bin/current → versioned dir for the binary just
276
333
  // installed. Without this, the symlink can lag behind npm — every time
277
334
  // I bumped CLI on the user's Mac mini, `~/.yaver/bin/current` kept
@@ -400,6 +457,7 @@ async function main() {
400
457
  }
401
458
 
402
459
  ensurePathOnUnix();
460
+ ensureZshenvRescue();
403
461
  addNpmGlobalBinToProcessPath();
404
462
  ensureLinuxRunnerSandboxPackages();
405
463
  ensureLinuxRunnerSandboxSupport();