zelari-code 1.7.0 → 1.7.1

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.
@@ -16576,6 +16576,28 @@ var init_filesystem = __esm({
16576
16576
  // packages/core/dist/core/tools/builtin/shellResolver.js
16577
16577
  import { existsSync as existsSync4 } from "node:fs";
16578
16578
  import { spawnSync } from "node:child_process";
16579
+ function isWslBashPath(p3) {
16580
+ if (!p3 || typeof p3 !== "string")
16581
+ return false;
16582
+ const n = p3.replace(/\//g, "\\").toLowerCase();
16583
+ if (n.includes("\\windows\\system32\\bash.exe"))
16584
+ return true;
16585
+ if (n.includes("\\windows\\syswow64\\bash.exe"))
16586
+ return true;
16587
+ if (n.includes("\\windowsapps\\bash.exe"))
16588
+ return true;
16589
+ return false;
16590
+ }
16591
+ function acceptBashPath(p3) {
16592
+ if (!p3 || p3.trim().length === 0)
16593
+ return null;
16594
+ const trimmed = p3.trim();
16595
+ if (isWslBashPath(trimmed))
16596
+ return null;
16597
+ if (!existsSyncSafe(trimmed))
16598
+ return null;
16599
+ return trimmed;
16600
+ }
16579
16601
  function resolveShell(forceReResolve = false) {
16580
16602
  if (memoized && !forceReResolve)
16581
16603
  return memoized;
@@ -16596,24 +16618,25 @@ function resolveShell(forceReResolve = false) {
16596
16618
  return memoized;
16597
16619
  }
16598
16620
  function resolveBashWindows() {
16599
- const envShell = process.env.ZELARI_SHELL;
16600
- if (envShell && envShell.trim().length > 0 && existsSyncSafe(envShell)) {
16601
- return envShell;
16602
- }
16603
- const sessionShell = process.env.SHELL;
16604
- if (sessionShell && sessionShell.trim().length > 0 && existsSyncSafe(sessionShell)) {
16605
- return sessionShell;
16606
- }
16621
+ const fromEnv = acceptBashPath(process.env.ZELARI_SHELL);
16622
+ if (fromEnv)
16623
+ return fromEnv;
16624
+ const fromSession = acceptBashPath(process.env.SHELL);
16625
+ if (fromSession)
16626
+ return fromSession;
16607
16627
  for (const p3 of STANDARD_BASH_PATHS) {
16608
- if (existsSyncSafe(p3))
16609
- return p3;
16628
+ const accepted = acceptBashPath(p3);
16629
+ if (accepted)
16630
+ return accepted;
16610
16631
  }
16611
16632
  try {
16612
16633
  const result = spawnSync("where", ["bash"], { encoding: "utf-8", windowsHide: true });
16613
16634
  if (result.status === 0 && result.stdout) {
16614
- const first = result.stdout.split(/\r?\n/).find((l) => l.trim().length > 0);
16615
- if (first && existsSyncSafe(first))
16616
- return first.trim();
16635
+ for (const line of result.stdout.split(/\r?\n/)) {
16636
+ const accepted = acceptBashPath(line);
16637
+ if (accepted)
16638
+ return accepted;
16639
+ }
16617
16640
  }
16618
16641
  } catch {
16619
16642
  }
@@ -16643,6 +16666,24 @@ var init_shellResolver = __esm({
16643
16666
 
16644
16667
  // packages/core/dist/core/tools/builtin/shell.js
16645
16668
  import { spawn } from "node:child_process";
16669
+ import { dirname } from "node:path";
16670
+ function withNodeDirOnPath(base) {
16671
+ const env = { ...base };
16672
+ try {
16673
+ const nodeDir = dirname(process.execPath);
16674
+ if (!nodeDir)
16675
+ return env;
16676
+ const sep = process.platform === "win32" ? ";" : ":";
16677
+ const current = env.PATH ?? env.Path ?? "";
16678
+ const parts = current.split(sep).filter((p3) => p3.length > 0);
16679
+ const has = parts.some((p3) => p3.toLowerCase() === nodeDir.toLowerCase());
16680
+ if (!has) {
16681
+ env.PATH = `${nodeDir}${sep}${current}`;
16682
+ }
16683
+ } catch {
16684
+ }
16685
+ return env;
16686
+ }
16646
16687
  var BashArgsSchema, INTERACTIVE_CANCEL_RE, INTERACTIVE_HINT, bashTool;
16647
16688
  var init_shell = __esm({
16648
16689
  "packages/core/dist/core/tools/builtin/shell.js"() {
@@ -16669,7 +16710,10 @@ var init_shell = __esm({
16669
16710
  const cwd = args.cwd ?? ctx.cwd;
16670
16711
  const resolved = resolveShell();
16671
16712
  let child;
16672
- const baseEnv = { ...process.env, CI: process.env.CI ?? "1" };
16713
+ const baseEnv = withNodeDirOnPath({
16714
+ ...process.env,
16715
+ CI: process.env.CI ?? "1"
16716
+ });
16673
16717
  const env = resolved.isBash ? { ...baseEnv, MSYSTEM: process.env.MSYSTEM ?? "MINGW64" } : baseEnv;
16674
16718
  if (resolved.isBash) {
16675
16719
  child = spawn(resolved.shell, ["-c", args.command], {
@@ -26210,7 +26254,7 @@ import {
26210
26254
  readdirSync as readdirSync2,
26211
26255
  renameSync as renameSync2
26212
26256
  } from "node:fs";
26213
- import { dirname, join as join13 } from "node:path";
26257
+ import { dirname as dirname2, join as join13 } from "node:path";
26214
26258
  function parseFrontmatter(md) {
26215
26259
  const m = FRONTMATTER_RE.exec(md);
26216
26260
  if (!m) return { meta: {}, body: md };
@@ -26481,7 +26525,7 @@ var init_storage = __esm({
26481
26525
  * The meta object is serialized as YAML frontmatter; body as Markdown.
26482
26526
  */
26483
26527
  write(path34, meta3, body) {
26484
- mkdirSync7(dirname(path34), { recursive: true });
26528
+ mkdirSync7(dirname2(path34), { recursive: true });
26485
26529
  const tmp = path34 + ".tmp-" + process.pid;
26486
26530
  const md = serializeFrontmatter(meta3, body);
26487
26531
  writeFileSync11(tmp, md, "utf8");
@@ -26536,7 +26580,7 @@ import {
26536
26580
  mkdirSync as mkdirSync8,
26537
26581
  renameSync as renameSync3
26538
26582
  } from "node:fs";
26539
- import { join as join14, basename as basename2, dirname as dirname2, relative as relative2 } from "node:path";
26583
+ import { join as join14, basename as basename2, dirname as dirname3, relative as relative2 } from "node:path";
26540
26584
  function createWorkspaceContext(projectRoot = process.cwd()) {
26541
26585
  const rootDir = resolveWorkspaceRoot(projectRoot);
26542
26586
  return {
@@ -26575,7 +26619,7 @@ function readPlan(ctx) {
26575
26619
  }
26576
26620
  function writePlan(ctx, summary) {
26577
26621
  const jsonPath = planJsonPath(ctx);
26578
- mkdirSync8(dirname2(jsonPath), { recursive: true });
26622
+ mkdirSync8(dirname3(jsonPath), { recursive: true });
26579
26623
  const tmp = jsonPath + ".tmp-" + process.pid;
26580
26624
  writeFileSync12(tmp, JSON.stringify(summary, null, 2), "utf8");
26581
26625
  renameSync3(tmp, jsonPath);
@@ -29154,29 +29198,47 @@ __export(prereqChecks_exports, {
29154
29198
  checkAgentGit: () => checkAgentGit,
29155
29199
  checkAgentNode: () => checkAgentNode,
29156
29200
  checkMainNode: () => checkMainNode,
29201
+ isWslBashPath: () => isWslBashPath2,
29157
29202
  runPrereqChecks: () => runPrereqChecks
29158
29203
  });
29159
29204
  import { execSync, spawnSync as spawnSync2 } from "node:child_process";
29160
29205
  import { existsSync as existsSync25 } from "node:fs";
29206
+ import { dirname as dirname4 } from "node:path";
29207
+ function isWslBashPath2(p3) {
29208
+ if (!p3 || typeof p3 !== "string") return false;
29209
+ const n = p3.replace(/\//g, "\\").toLowerCase();
29210
+ if (n.includes("\\windows\\system32\\bash.exe")) return true;
29211
+ if (n.includes("\\windows\\syswow64\\bash.exe")) return true;
29212
+ if (n.includes("\\windowsapps\\bash.exe")) return true;
29213
+ return false;
29214
+ }
29215
+ function acceptBashPath2(p3) {
29216
+ if (!p3 || p3.trim().length === 0) return null;
29217
+ const trimmed = p3.trim();
29218
+ if (isWslBashPath2(trimmed)) return null;
29219
+ if (!existsSyncSafe2(trimmed)) return null;
29220
+ return trimmed;
29221
+ }
29161
29222
  function resolveAgentShellSync() {
29162
29223
  if (process.platform !== "win32") {
29163
29224
  return { bashPath: null, isBash: true, via: "/bin/sh" };
29164
29225
  }
29165
- const envShell = process.env.ZELARI_SHELL;
29166
- if (envShell && envShell.trim().length > 0 && existsSyncSafe2(envShell)) {
29167
- return { bashPath: envShell, isBash: true, via: `bash (${envShell})` };
29226
+ const fromEnv = acceptBashPath2(process.env.ZELARI_SHELL);
29227
+ if (fromEnv) {
29228
+ return { bashPath: fromEnv, isBash: true, via: `bash (${fromEnv})` };
29168
29229
  }
29169
- const sessionShell = process.env.SHELL;
29170
- if (sessionShell && sessionShell.trim().length > 0 && existsSyncSafe2(sessionShell)) {
29230
+ const fromSession = acceptBashPath2(process.env.SHELL);
29231
+ if (fromSession) {
29171
29232
  return {
29172
- bashPath: sessionShell,
29233
+ bashPath: fromSession,
29173
29234
  isBash: true,
29174
- via: `bash (${sessionShell})`
29235
+ via: `bash (${fromSession})`
29175
29236
  };
29176
29237
  }
29177
29238
  for (const p3 of STANDARD_BASH_PATHS2) {
29178
- if (existsSyncSafe2(p3)) {
29179
- return { bashPath: p3, isBash: true, via: `bash (${p3})` };
29239
+ const accepted = acceptBashPath2(p3);
29240
+ if (accepted) {
29241
+ return { bashPath: accepted, isBash: true, via: `bash (${accepted})` };
29180
29242
  }
29181
29243
  }
29182
29244
  try {
@@ -29185,16 +29247,39 @@ function resolveAgentShellSync() {
29185
29247
  windowsHide: true
29186
29248
  });
29187
29249
  if (result.status === 0 && result.stdout) {
29188
- const first = result.stdout.split(/\r?\n/).find((l) => l.trim().length > 0);
29189
- if (first && existsSyncSafe2(first)) {
29190
- const trimmed = first.trim();
29191
- return { bashPath: trimmed, isBash: true, via: `bash (${trimmed})` };
29250
+ for (const line of result.stdout.split(/\r?\n/)) {
29251
+ const accepted = acceptBashPath2(line);
29252
+ if (accepted) {
29253
+ return {
29254
+ bashPath: accepted,
29255
+ isBash: true,
29256
+ via: `bash (${accepted})`
29257
+ };
29258
+ }
29192
29259
  }
29193
29260
  }
29194
29261
  } catch {
29195
29262
  }
29196
29263
  return { bashPath: null, isBash: false, via: "cmd.exe" };
29197
29264
  }
29265
+ function agentProbeEnv() {
29266
+ const env = { ...process.env };
29267
+ try {
29268
+ const nodeDir = dirname4(process.execPath);
29269
+ if (!nodeDir) return env;
29270
+ const sep = process.platform === "win32" ? ";" : ":";
29271
+ const current = env.PATH ?? env.Path ?? "";
29272
+ const parts = current.split(sep).filter((p3) => p3.length > 0);
29273
+ const has = parts.some(
29274
+ (p3) => p3.toLowerCase() === nodeDir.toLowerCase()
29275
+ );
29276
+ if (!has) {
29277
+ env.PATH = `${nodeDir}${sep}${current}`;
29278
+ }
29279
+ } catch {
29280
+ }
29281
+ return env;
29282
+ }
29198
29283
  function existsSyncSafe2(p3) {
29199
29284
  try {
29200
29285
  return existsSync25(p3);
@@ -29205,12 +29290,14 @@ function existsSyncSafe2(p3) {
29205
29290
  function probeTool(tool) {
29206
29291
  const shell = resolveAgentShellSync();
29207
29292
  let stdout = "";
29293
+ const env = agentProbeEnv();
29208
29294
  if (shell.bashPath) {
29209
29295
  try {
29210
29296
  const r = spawnSync2(shell.bashPath, ["-c", `${tool} --version`], {
29211
29297
  encoding: "utf8",
29212
29298
  stdio: ["ignore", "pipe", "ignore"],
29213
- windowsHide: true
29299
+ windowsHide: true,
29300
+ env
29214
29301
  });
29215
29302
  if (r.status === 0) stdout = (r.stdout || "").trim();
29216
29303
  } catch {
@@ -29219,7 +29306,8 @@ function probeTool(tool) {
29219
29306
  try {
29220
29307
  stdout = execSync(`${tool} --version`, {
29221
29308
  encoding: "utf8",
29222
- stdio: ["ignore", "pipe", "ignore"]
29309
+ stdio: ["ignore", "pipe", "ignore"],
29310
+ env
29223
29311
  }).trim();
29224
29312
  } catch {
29225
29313
  }
@@ -29227,7 +29315,8 @@ function probeTool(tool) {
29227
29315
  try {
29228
29316
  stdout = execSync(`${tool} --version`, {
29229
29317
  encoding: "utf8",
29230
- stdio: ["ignore", "pipe", "ignore"]
29318
+ stdio: ["ignore", "pipe", "ignore"],
29319
+ env
29231
29320
  }).trim();
29232
29321
  } catch {
29233
29322
  }
@@ -29242,14 +29331,21 @@ function probeTool(tool) {
29242
29331
  function nodeMissingHint() {
29243
29332
  const shell = resolveAgentShellSync();
29244
29333
  if (process.platform === "win32") {
29334
+ if (!shell.isBash) {
29335
+ return `node is not reachable from the agent's shell (${shell.via}).
29336
+ Install Node >= ${MIN_NODE_MAJOR} (https://nodejs.org) and ensure it is
29337
+ on PATH, then open a NEW terminal. Optional: install Git for
29338
+ Windows so the agent can use real bash (https://git-scm.com/download/win).`;
29339
+ }
29245
29340
  return `node is not reachable from the agent's shell (${shell.via}).
29246
29341
  This usually means Node was installed for "current user" only,
29247
- while Git Bash inherits the SYSTEM Path. Fix (pick one):
29342
+ while Git Bash sees a different Path. Fix (pick one):
29248
29343
  - Reinstall Node (https://nodejs.org) and choose
29249
29344
  "Add to PATH for all users", OR
29250
- - Add C:\\Program Files\\nodejs\\ to the SYSTEM Path
29251
- (System Properties \u2192 Environment Variables \u2192 Path), OR
29252
- - Set ZELARI_SHELL to a bash that already sees node.`;
29345
+ - Add your nodejs folder to the User or System Path, OR
29346
+ - Set ZELARI_SHELL to a bash that already sees node.
29347
+ Note: WSL's C:\\Windows\\System32\\bash.exe is NOT a valid agent
29348
+ shell \u2014 install Git for Windows instead.`;
29253
29349
  }
29254
29350
  return `node is not on the agent's shell PATH.
29255
29351
  Install Node >= ${MIN_NODE_MAJOR} (https://nodejs.org) or, if you use