@wrongstack/cli 1.1.1 → 1.1.2

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.
@@ -2427,12 +2427,14 @@ async function dispatchBootSubcommand(input) {
2427
2427
  import * as fs7 from "node:fs/promises";
2428
2428
  import * as path8 from "node:path";
2429
2429
  import * as readline from "node:readline";
2430
+ import { DefaultSecretScrubber } from "@wrongstack/core/security";
2430
2431
  import {
2431
2432
  resolveWstackPaths,
2432
2433
  setOutputLineGuard,
2433
2434
  setRawMode as setRawMode2,
2434
2435
  writeOut
2435
2436
  } from "@wrongstack/core/utils";
2437
+ var historyScrubber = new DefaultSecretScrubber();
2436
2438
  var ReadlineInputReader = class {
2437
2439
  rl;
2438
2440
  historyFile;
@@ -2453,7 +2455,8 @@ var ReadlineInputReader = class {
2453
2455
  async saveHistory() {
2454
2456
  try {
2455
2457
  await fs7.mkdir(path8.dirname(this.historyFile), { recursive: true });
2456
- await fs7.writeFile(this.historyFile, this.history.slice(-1e3).join("\n"));
2458
+ const persisted = this.history.slice(-1e3).filter((line) => historyScrubber.scrub(line) === line);
2459
+ await fs7.writeFile(this.historyFile, persisted.join("\n"));
2457
2460
  } catch {
2458
2461
  }
2459
2462
  }
@@ -3619,4 +3622,4 @@ async function initializeCli(argv, options = {}) {
3619
3622
  export {
3620
3623
  initializeCli
3621
3624
  };
3622
- //# sourceMappingURL=cli-context-A6XDEXN5.js.map
3625
+ //# sourceMappingURL=cli-context-YIT4FEDM.js.map
@@ -21391,12 +21391,22 @@ ${formatGoal(next, 0)}`,
21391
21391
  refinerModel: refinerTarget?.model,
21392
21392
  onUsage: (usage2, source) => journalGoalRefineUsage(opts, usage2, source)
21393
21393
  });
21394
- const updated = {
21395
- ...current,
21396
- refinedGoal: refined.refinedGoal,
21397
- deliverables: refined.deliverables
21398
- };
21399
- await saveGoal(goalPath, updated, opts.events);
21394
+ let updated;
21395
+ await updateGoal(
21396
+ goalPath,
21397
+ (latest) => {
21398
+ if (!latest || latest.goal !== current.goal) return latest;
21399
+ updated = {
21400
+ ...latest,
21401
+ refinedGoal: refined.refinedGoal,
21402
+ deliverables: refined.deliverables
21403
+ };
21404
+ return updated;
21405
+ },
21406
+ opts.events
21407
+ );
21408
+ if (!updated)
21409
+ return { message: "The mission changed while it was being refined; nothing was applied." };
21400
21410
  return { message: `\u2713 Mission refined.
21401
21411
 
21402
21412
  ${formatGoal(updated)}` };
@@ -21839,6 +21849,7 @@ function buildHelpCommand(opts) {
21839
21849
  }
21840
21850
 
21841
21851
  // src/slash-commands/init.ts
21852
+ import { constants as fsConstants2 } from "node:fs";
21842
21853
  import * as fs10 from "node:fs/promises";
21843
21854
  import * as path23 from "node:path";
21844
21855
  import { color as color36 } from "@wrongstack/core/utils";
@@ -21855,12 +21866,15 @@ function buildInitCommand(opts) {
21855
21866
  const detected = await detectProjectFacts(root);
21856
21867
  const body = renderAgentsTemplate(detected);
21857
21868
  await fs10.mkdir(dir, { recursive: true });
21858
- let backedUp = false;
21869
+ let backedUp;
21859
21870
  if (!isFirstInit) {
21860
21871
  try {
21861
- await fs10.copyFile(file, `${file}.bak`);
21862
- backedUp = true;
21863
- } catch {
21872
+ const current = await fs10.readFile(file, "utf8");
21873
+ backedUp = current === body ? void 0 : await backupWithoutClobbering(file, current);
21874
+ } catch (err) {
21875
+ const msg = `Did not rewrite ${file}: could not back it up first (${err instanceof Error ? err.message : String(err)}).`;
21876
+ opts.renderer.writeWarning(msg);
21877
+ return { message: msg };
21864
21878
  }
21865
21879
  }
21866
21880
  await fs10.writeFile(file, body, "utf8");
@@ -21875,7 +21889,7 @@ function buildInitCommand(opts) {
21875
21889
  lines.push(wroteMsg);
21876
21890
  opts.renderer.writeInfo(wroteMsg);
21877
21891
  if (backedUp) {
21878
- const backupLine = `Backed up the previous AGENTS.md to ${file}.bak`;
21892
+ const backupLine = `Backed up the previous AGENTS.md to ${backedUp}`;
21879
21893
  opts.renderer.writeInfo(backupLine);
21880
21894
  lines.push(backupLine);
21881
21895
  }
@@ -21902,6 +21916,19 @@ function buildInitCommand(opts) {
21902
21916
  }
21903
21917
  };
21904
21918
  }
21919
+ async function backupWithoutClobbering(file, current) {
21920
+ const primary = `${file}.bak`;
21921
+ try {
21922
+ await fs10.copyFile(file, primary, fsConstants2.COPYFILE_EXCL);
21923
+ return primary;
21924
+ } catch (err) {
21925
+ if (err.code !== "EEXIST") throw err;
21926
+ }
21927
+ if (await fs10.readFile(primary, "utf8") === current) return primary;
21928
+ const stamped = `${file}.${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.bak`;
21929
+ await fs10.copyFile(file, stamped, fsConstants2.COPYFILE_EXCL);
21930
+ return stamped;
21931
+ }
21905
21932
  async function fileExists(filePath) {
21906
21933
  try {
21907
21934
  await fs10.access(filePath);
@@ -43318,4 +43345,4 @@ export {
43318
43345
  CLI_VERSION,
43319
43346
  runInteractive
43320
43347
  };
43321
- //# sourceMappingURL=cli-main-5UGSW4TO.js.map
43348
+ //# sourceMappingURL=cli-main-JIADJ5OL.js.map
package/dist/index.js CHANGED
@@ -131,7 +131,7 @@ async function main(argv) {
131
131
  shouldCaptureTuiStartup(parsed.flags, parsed.positional)
132
132
  );
133
133
  try {
134
- const { initializeCli } = await import("./cli-context-A6XDEXN5.js");
134
+ const { initializeCli } = await import("./cli-context-YIT4FEDM.js");
135
135
  const cliCtx = await initializeCli(argv, {
136
136
  onNonTuiLaunch: () => startupOutput.stop()
137
137
  });
@@ -141,7 +141,7 @@ async function main(argv) {
141
141
  } else {
142
142
  startupOutput.stop();
143
143
  }
144
- const { runInteractive } = await import("./cli-main-5UGSW4TO.js");
144
+ const { runInteractive } = await import("./cli-main-JIADJ5OL.js");
145
145
  return await runInteractive(cliCtx);
146
146
  } finally {
147
147
  startupOutput.stop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack CLI — terminal AI coding agent with provider catalog from models.dev. Provides `wrongstack` and `wstack` binaries.",
6
6
  "keywords": [