@wrongstack/cli 0.302.2 → 0.303.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.
@@ -263,7 +263,8 @@ function buildAcpServerAgentFactory(deps, options = {}) {
263
263
  iterationTimeoutMs: config.tools?.iterationTimeoutMs ?? 12e4,
264
264
  maxToolTimeoutMs: config.tools?.maxToolTimeoutMs ?? 3e5,
265
265
  perIterationOutputCapBytes: config.tools?.perIterationOutputCapBytes ?? 1e5,
266
- tracer: void 0
266
+ tracer: void 0,
267
+ requireKanbanGovernance: true
267
268
  });
268
269
  return new Agent({
269
270
  container,
@@ -908,4 +909,4 @@ ${renderAcpBenchText(result)}
908
909
  export {
909
910
  acpCmd
910
911
  };
911
- //# sourceMappingURL=acp-XCE4JJF3.js.map
912
+ //# sourceMappingURL=acp-AQMGKW6O.js.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * TUI Theme adapter — extracts the getThemePreset/saveThemePreset pair from
3
+ * the runTui() options literal.
4
+ *
5
+ * Mirrors the `createSettingsAdapter` shape (see `./tui-settings-adapter.ts`)
6
+ * but is much narrower: theme is a single enum-valued key, so there's no
7
+ * section merge, no schema fan-out, and no encrypted-secret dance (the
8
+ * value is a plain preset name, not a credential).
9
+ *
10
+ * The disk write goes to the active profile's config file (same target
11
+ * `createSettingsAdapter` writes) so both layers share the same source of
12
+ * truth: future TUI boots read `themePreset` from the same JSON file the
13
+ * CLI writes via `/theme` and the WebUI flips via Settings.
14
+ */
15
+ import type { ConfigStore, ThemePresetId } from '@wrongstack/core/types';
16
+ import { type WstackPaths } from '@wrongstack/core/utils';
17
+ export interface ThemeAdapterDeps {
18
+ configStore: ConfigStore;
19
+ wpaths: Pick<WstackPaths, 'profileConfig'>;
20
+ }
21
+ export interface ThemeAdapter {
22
+ /** Read the live preset (memory-backed). Returns undefined when unset. */
23
+ getThemePreset: () => ThemePresetId | undefined;
24
+ /**
25
+ * Persist a new preset to BOTH the in-memory configStore (so the running
26
+ * session sees it immediately) and the active profile's config file on
27
+ * disk (so the next boot starts with this preset applied). Unknown ids
28
+ * are rejected without writing.
29
+ */
30
+ saveThemePreset: (preset: ThemePresetId) => Promise<void>;
31
+ }
32
+ export declare function createThemeAdapter({ configStore, wpaths }: ThemeAdapterDeps): ThemeAdapter;
33
+ //# sourceMappingURL=tui-theme-adapter.d.ts.map
@@ -8,6 +8,7 @@ import {
8
8
  // src/subcommands/handlers/update.ts
9
9
  import { spawn } from "node:child_process";
10
10
  import { existsSync, realpathSync } from "node:fs";
11
+ import * as path from "node:path";
11
12
  var MAX_UPDATE_OUTPUT_CHARS = 256 * 1024;
12
13
  async function runUpdateCommand(args, deps) {
13
14
  const cwd = deps.cwd;
@@ -75,9 +76,20 @@ async function runUpdateCommand(args, deps) {
75
76
  return 0;
76
77
  }
77
78
  const packageManager = parsed.packageManager ?? detectUpdatePackageManager();
78
- const updateCommand = buildUpdateCommand(packageManager, packageName, info.latest, {
79
- allowScripts: parsed.allowScripts
80
- });
79
+ let updateCommand;
80
+ try {
81
+ updateCommand = buildUpdateCommand(packageManager, packageName, info.latest, {
82
+ allowScripts: parsed.allowScripts,
83
+ cwd,
84
+ env: deps.environment
85
+ });
86
+ } catch (err) {
87
+ const msg = err instanceof Error ? err.message : String(err);
88
+ deps.renderer.write(`
89
+ Update failed: ${msg}
90
+ `);
91
+ return 1;
92
+ }
81
93
  deps.renderer.write(`Updating wrongstack from v${info.current} to v${info.latest}...
82
94
  `);
83
95
  deps.renderer.write(`Running: ${updateCommand.display}
@@ -122,6 +134,10 @@ Update ${termination}.
122
134
  ${result.stdout}`.trim();
123
135
  if (detail) deps.renderer.write(`
124
136
  ${detail}
137
+ `);
138
+ const lockedFilesGuidance = windowsLockedFilesGuidance(detail);
139
+ if (lockedFilesGuidance) deps.renderer.write(`
140
+ ${lockedFilesGuidance}
125
141
  `);
126
142
  deps.renderer.write(
127
143
  `
@@ -247,36 +263,53 @@ function detectUpdatePackageName(argv = process.argv) {
247
263
  const entry = (argv[1] ?? "").replace(/\\/g, "/").toLowerCase();
248
264
  return entry.includes("/node_modules/@wrongstack/cli/") || entry.includes("/packages/cli/dist/") ? "@wrongstack/cli" : "wrongstack";
249
265
  }
250
- function buildUpdateCommand(packageManager, packageName, version, opts = { allowScripts: false }) {
266
+ function buildUpdateCommand(packageManager, packageName, version, opts = {
267
+ allowScripts: false
268
+ }) {
251
269
  const ignoreScripts = !opts.allowScripts;
252
270
  const target = `${packageName}@${version}`;
253
271
  switch (packageManager) {
254
272
  case "pnpm":
255
273
  return command(
256
274
  packageManager,
257
- ignoreScripts ? ["add", "-g", "--ignore-scripts", target] : ["add", "-g", target]
275
+ ignoreScripts ? ["add", "-g", "--ignore-scripts", target] : ["add", "-g", target],
276
+ opts.cwd,
277
+ opts.env
258
278
  );
259
279
  case "yarn":
260
280
  return command(
261
281
  packageManager,
262
- ignoreScripts ? ["global", "add", "--ignore-scripts", target] : ["global", "add", target]
282
+ ignoreScripts ? ["global", "add", "--ignore-scripts", target] : ["global", "add", target],
283
+ opts.cwd,
284
+ opts.env
263
285
  );
264
286
  case "bun":
265
287
  return command(
266
288
  packageManager,
267
- ignoreScripts ? ["add", "-g", "--ignore-scripts", target] : ["add", "-g", target]
289
+ ignoreScripts ? ["add", "-g", "--ignore-scripts", target] : ["add", "-g", target],
290
+ opts.cwd,
291
+ opts.env
268
292
  );
269
293
  case "npm":
270
294
  return command(
271
295
  packageManager,
272
- ignoreScripts ? ["install", "-g", "--ignore-scripts", target] : ["install", "-g", target]
296
+ ignoreScripts ? ["install", "-g", "--ignore-scripts", target] : ["install", "-g", target],
297
+ opts.cwd,
298
+ opts.env
273
299
  );
274
300
  }
275
301
  }
276
- function command(pm, args) {
302
+ function command(pm, args, cwd, env = process.env) {
277
303
  const display = `${pm} ${args.join(" ")}`;
278
- if (process.platform === "win32" && pm !== "bun") {
279
- const shim = buildWin32CmdShimInvocation(pm, args);
304
+ const resolvedExecutable = cwd ? resolveWin32PackageManagerPath(pm, cwd, env) : void 0;
305
+ if (process.platform === "win32" && cwd && !resolvedExecutable) {
306
+ throw new Error(
307
+ `Could not find ${pm} outside the current project directory. Install ${pm} globally or put its global executable directory on PATH.`
308
+ );
309
+ }
310
+ const executable = resolvedExecutable ?? pm;
311
+ if (process.platform === "win32" && (pm !== "bun" || /\.(?:cmd|bat)$/i.test(executable))) {
312
+ const shim = buildWin32CmdShimInvocation(executable, args);
280
313
  return {
281
314
  executable: shim.command,
282
315
  args: shim.args,
@@ -284,7 +317,39 @@ function command(pm, args) {
284
317
  windowsVerbatimArguments: shim.windowsVerbatimArguments
285
318
  };
286
319
  }
287
- return { executable: pm, args, display };
320
+ return { executable, args, display };
321
+ }
322
+ function resolveWin32PackageManagerPath(packageManager, cwd, env = process.env, pathExists = existsSync) {
323
+ if (process.platform !== "win32") return void 0;
324
+ const pathValue = environmentValue(env, "PATH");
325
+ if (!pathValue) return void 0;
326
+ const cwdPath = path.win32.resolve(cwd).toLowerCase();
327
+ const extensions = packageManager.includes(".") ? [""] : environmentValue(env, "PATHEXT")?.split(";").filter(Boolean) ?? [
328
+ ".COM",
329
+ ".EXE",
330
+ ".BAT",
331
+ ".CMD"
332
+ ];
333
+ for (const rawEntry of pathValue.split(";")) {
334
+ const entry = rawEntry.trim().replace(/^"|"$/g, "");
335
+ if (!entry || !path.win32.isAbsolute(entry)) continue;
336
+ const directory = path.win32.resolve(entry);
337
+ if (isPathInsideWin32(directory, cwdPath)) continue;
338
+ for (const extension of extensions) {
339
+ const candidate = path.win32.join(directory, `${packageManager}${extension}`);
340
+ if (pathExists(candidate)) return candidate;
341
+ }
342
+ }
343
+ return void 0;
344
+ }
345
+ function environmentValue(env, key) {
346
+ const match = Object.entries(env).find(([name]) => name.toUpperCase() === key);
347
+ return typeof match?.[1] === "string" ? match[1] : void 0;
348
+ }
349
+ function isPathInsideWin32(candidate, parent) {
350
+ const normalizedCandidate = path.win32.resolve(candidate).toLowerCase();
351
+ const relative = path.win32.relative(parent, normalizedCandidate);
352
+ return relative === "" || !relative.startsWith("..\\") && relative !== ".." && !path.win32.isAbsolute(relative);
288
353
  }
289
354
  function otherManagerCommands(selected, packageName, version, opts = { allowScripts: false }) {
290
355
  const commands = ["npm", "pnpm", "yarn", "bun"].filter((pm) => pm !== selected).map((pm) => ` ${buildUpdateCommand(pm, packageName, version, opts).display}`);
@@ -301,6 +366,15 @@ function installWarningSummary(output) {
301
366
  if (!/allow-scripts|allowScripts/i.test(output)) return null;
302
367
  return "Install completed, but npm reported blocked lifecycle scripts. If a native optional feature is missing, rerun the update with npm script approval for the named package.";
303
368
  }
369
+ function windowsLockedFilesGuidance(output) {
370
+ if (process.platform !== "win32") return null;
371
+ const hasLockError = /\b(?:EBUSY|EPERM|EACCES|ENOTEMPTY)\b/i.test(output);
372
+ const isWrongStackNativeFile = /(?:\.wrongstack-|wrongstack[\\/]node_modules|electron\.exe|dd_pprof\.node|node-pty)/i.test(
373
+ output
374
+ );
375
+ if (!hasLockError || !isWrongStackNativeFile) return null;
376
+ return "Windows could not replace a native file held by a running WrongStack process. Stop any WrongStack WebUI, Desktop, or background process, then rerun the same update command. Do not remove npm\u2019s .wrongstack-* staging directory until those processes have stopped.";
377
+ }
304
378
 
305
379
  export {
306
380
  runUpdateCommand,
@@ -308,4 +382,4 @@ export {
308
382
  detectUpdatePackageManager,
309
383
  detectUpdatePackageName
310
384
  };
311
- //# sourceMappingURL=chunk-BXQG3H2Y.js.map
385
+ //# sourceMappingURL=chunk-53STH6CX.js.map
@@ -1998,7 +1998,7 @@ async function handleApiAgentMessages(req, res, match, agentMessages) {
1998
1998
  async function handleApiSystemUpdate(res) {
1999
1999
  const [{ checkForUpdate }, { detectUpdatePackageName }] = await Promise.all([
2000
2000
  import("./update-check-WARHSVZA.js"),
2001
- import("./update-LTDJGAFU.js")
2001
+ import("./update-VZSOZGYC.js")
2002
2002
  ]);
2003
2003
  const packageName = detectUpdatePackageName();
2004
2004
  const info = await checkForUpdate({ packageName });
@@ -4773,4 +4773,4 @@ export {
4773
4773
  startHqServer,
4774
4774
  HqInsecureExposureError2 as HqInsecureExposureError
4775
4775
  };
4776
- //# sourceMappingURL=chunk-WOXUE2CN.js.map
4776
+ //# sourceMappingURL=chunk-LUAFQIXT.js.map