@wrongstack/cli 0.257.2 → 0.260.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.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import * as fsp5 from 'fs/promises';
3
- import * as path38 from 'path';
3
+ import * as path39 from 'path';
4
4
  import { join } from 'path';
5
- import { color, writeErr, loadPlugins, renderProgress, SpecStore, TaskGraphStore, analyzeCriticalPath, getTemplate, listTemplates, templateToMarkdown, SpecParser, renderSpecAnalysis, AISpecBuilder, expectDefined, DefaultTaskStore, TaskTracker, renderTaskGraph, withFileLock, DefaultSecretScrubber, resolveProjectDir, GlobalMailbox, TOKENS, ToolRegistry, resolveSessionLoggingConfig, createSessionEventBridge, HookRegistry, HookRunner, SlashCommandRegistry, attachDepWatcherBridge, SessionMemoryConsolidator, BrainDecisionQueue, ObservableBrainArbiter, HumanEscalatingBrainArbiter, createTieredBrainArbiter, DefaultBrainArbiter, BrainMonitor, mailboxSessionTag, createDelegateTool, FLEET_ROSTER, createMcpControlTool, startTechStackConsumer, startPackageOutdatedWatcher, recordFileAction, createAutonomyBrain, DefaultPluginAPI, SpecVersioning, wstackGlobalRoot, DEFAULT_CONTEXT_WINDOW_MODE_ID, recentTextTurns, enhanceUserPrompt, projectSlug, DefaultSystemPromptBuilder, mutateTasks, loadTasks, resolveContextWindowPolicy, repairToolUseAdjacency, mutatePlan, setPlanItemStatus, getPlanTemplate, loadPlan, emptyPlan, addPlanItem, savePlan, DefaultLogger, DefaultModelsRegistry, isStdinTTY, DefaultPathResolver, EventBus, runProviderWithRetry, ReplayLogStore, ReplayProviderRunner, mergeCustomModelDefs, makeAutonomyPromptContributor, createContextManagerTool, makeMailboxTool, makeMailSendTool, makeMailInboxTool, InMemoryMetricsSink, wireMetricsToEvents, DefaultHealthRegistry, startMetricsServer, DEFAULT_SESSION_PRUNE_DAYS, RecoveryLock, DefaultAttachmentStore, QueueStore, Context, loadTodosCheckpoint, attachTodosCheckpoint, loadDirectorState, createDefaultPipelines, resolveAuditLevel, AutoCompactionMiddleware, estimateRequestTokensCalibrated, Agent, FleetManager, makeDirectorSessionFactory, Director, makeFleetEmitTool, makeFleetStatusTool, resolveModelMatrix, DEFAULT_SUBAGENT_BASELINE, AutoApprovePermissionPolicy, PhaseStore, AutoPhasePlanner, PhaseGraphBuilder, WorktreeManager, PhaseOrchestrator, makeLLMClassifier, writeOut, ParallelEternalEngine, EternalAutonomyEngine, allServers as allServers$1, CHIMERA_REVIEW_PROMPT, noOpVault, decryptConfigSecrets, encryptConfigSecrets, atomicWrite, setQueuedMessagesSnapshot, DefaultSessionRewinder, bootConfig as bootConfig$1, setOutputLineGuard, setRawMode, DefaultSessionReader, resolveWstackPaths, ToolAuditLog, DefaultSessionStore as DefaultSessionStore$1, ProviderRegistry, StreamHangError, ProviderError, makeAgentSubagentRunner, NULL_FLEET_BUS, buildChildEnv, formatContextWindowModeList, getContextWindowMode, AGENT_CATALOG, dispatchAgent, formatTodosList, formatTaskList, formatTaskProgress, formatPlan, SessionRecovery, loadGoal, goalFilePath, summarizeUsage, saveGoal, formatGoal, emptyGoal, buildGoalPreamble, pendingBtwCount, setBtwNote, MATRIX_PHASE_KEYS, matrixKeyKind, phaseForRole, onResize, ERROR_CODES, FsError, ConfigError, InputBuilder, truncate, estimateMessageTokens, AGENTS_BY_PHASE, validateAgainstSchema, resolveMailboxIdentity, isSecretField as isSecretField$1 } from '@wrongstack/core';
5
+ import { color, writeErr, loadPlugins, renderProgress, SpecStore, TaskGraphStore, analyzeCriticalPath, getTemplate, listTemplates, templateToMarkdown, SpecParser, renderSpecAnalysis, AISpecBuilder, expectDefined, DefaultTaskStore, TaskTracker, renderTaskGraph, withFileLock, DefaultSecretScrubber, resolveProjectDir, GlobalMailbox, TOKENS, ToolRegistry, resolveSessionLoggingConfig, createSessionEventBridge, HookRegistry, HookRunner, SlashCommandRegistry, attachDepWatcherBridge, SessionMemoryConsolidator, BrainDecisionQueue, ObservableBrainArbiter, HumanEscalatingBrainArbiter, createTieredBrainArbiter, DefaultBrainArbiter, BrainMonitor, mailboxSessionTag, createDelegateTool, FLEET_ROSTER, createMcpControlTool, startTechStackConsumer, startPackageOutdatedWatcher, recordFileAction, createAutonomyBrain, DefaultPluginAPI, SpecVersioning, wstackGlobalRoot, DEFAULT_CONTEXT_WINDOW_MODE_ID, recentTextTurns, enhanceUserPrompt, projectSlug, DefaultSystemPromptBuilder, mutateTasks, loadTasks, resolveContextWindowPolicy, repairToolUseAdjacency, mutatePlan, setPlanItemStatus, getPlanTemplate, loadPlan, emptyPlan, addPlanItem, savePlan, DefaultLogger, DefaultModelsRegistry, isStdinTTY, DefaultPathResolver, EventBus, runProviderWithRetry, ReplayLogStore, ReplayProviderRunner, mergeCustomModelDefs, makeAutonomyPromptContributor, createContextManagerTool, makeMailboxTool, makeMailSendTool, makeMailInboxTool, InMemoryMetricsSink, wireMetricsToEvents, DefaultHealthRegistry, startMetricsServer, DEFAULT_SESSION_PRUNE_DAYS, RecoveryLock, DefaultAttachmentStore, Context, QueueStore, loadTodosCheckpoint, attachTodosCheckpoint, loadDirectorState, createDefaultPipelines, resolveAuditLevel, AutoCompactionMiddleware, estimateRequestTokensCalibrated, Agent, FleetManager, makeDirectorSessionFactory, Director, makeFleetEmitTool, makeFleetStatusTool, resolveModelMatrix, DEFAULT_SUBAGENT_BASELINE, AutoApprovePermissionPolicy, PhaseStore, AutoPhasePlanner, PhaseGraphBuilder, WorktreeManager, PhaseOrchestrator, makeLLMClassifier, writeOut, ParallelEternalEngine, EternalAutonomyEngine, allServers as allServers$1, CHIMERA_REVIEW_PROMPT, noOpVault, decryptConfigSecrets, encryptConfigSecrets, atomicWrite, setQueuedMessagesSnapshot, DefaultSessionRewinder, bootConfig as bootConfig$1, setOutputLineGuard, setRawMode, DefaultSessionReader, resolveWstackPaths, ToolAuditLog, DefaultSessionStore as DefaultSessionStore$1, ProviderRegistry, StreamHangError, ProviderError, makeAgentSubagentRunner, NULL_FLEET_BUS, buildChildEnv, formatContextWindowModeList, getContextWindowMode, AGENT_CATALOG, dispatchAgent, formatTodosList, formatTaskList, formatTaskProgress, formatPlan, SessionRecovery, loadGoal, goalFilePath, summarizeUsage, saveGoal, formatGoal, emptyGoal, buildGoalPreamble, pendingBtwCount, setBtwNote, MATRIX_PHASE_KEYS, matrixKeyKind, phaseForRole, onResize, ERROR_CODES, FsError, ConfigError, InputBuilder, truncate, estimateMessageTokens, AGENTS_BY_PHASE, validateAgainstSchema, resolveMailboxIdentity, isSecretField as isSecretField$1 } from '@wrongstack/core';
6
6
  import { DefaultSecretVault, encryptConfigSecrets as encryptConfigSecrets$1, decryptConfigSecrets as decryptConfigSecrets$1, isSecretField } from '@wrongstack/core/security';
7
7
  import * as crypto3 from 'crypto';
8
- import { createHash, randomUUID } from 'crypto';
8
+ import { createHash, randomBytes, randomUUID } from 'crypto';
9
9
  import { createRequire } from 'module';
10
10
  import * as os from 'os';
11
11
  import os__default from 'os';
@@ -25,6 +25,7 @@ import { parseNextSteps } from '@wrongstack/tui';
25
25
  import { ACP_AGENT_COMMANDS, makeACPSubagentRunner, makeACPSubagentRunnerWithStop } from '@wrongstack/acp';
26
26
  import { WrongStackACPServer } from '@wrongstack/acp/agent';
27
27
  import { ACP_AGENTS, SubagentBudget } from '@wrongstack/core/coordination';
28
+ import { loadBenchConfig, reportHeaderLine, readSummary, renderMarkdownReport, createPolyglotSuite, createSwebenchSuite, runBenchmark, writeJsonArtifacts, collectCellPredictions, writePredictionsJsonl, gradePolyglot, gradeSwebench } from '@wrongstack/bench';
28
29
  import { allServers } from '@wrongstack/core/infrastructure';
29
30
  import { ToolExecutor } from '@wrongstack/core/execution';
30
31
  import { createToolVisionAdapters } from '@wrongstack/runtime/vision';
@@ -70,10 +71,10 @@ async function detectPackageManager2(root, declared) {
70
71
  const name = declared.split("@")[0];
71
72
  if (name) return name;
72
73
  }
73
- if (await pathExists(path38.join(root, "pnpm-lock.yaml"))) return "pnpm";
74
- if (await pathExists(path38.join(root, "bun.lockb"))) return "bun";
75
- if (await pathExists(path38.join(root, "bun.lock"))) return "bun";
76
- if (await pathExists(path38.join(root, "yarn.lock"))) return "yarn";
74
+ if (await pathExists(path39.join(root, "pnpm-lock.yaml"))) return "pnpm";
75
+ if (await pathExists(path39.join(root, "bun.lockb"))) return "bun";
76
+ if (await pathExists(path39.join(root, "bun.lock"))) return "bun";
77
+ if (await pathExists(path39.join(root, "yarn.lock"))) return "yarn";
77
78
  return "npm";
78
79
  }
79
80
  function hasUsableScript(scripts, name) {
@@ -94,7 +95,7 @@ function parseMakeTargets(makefile) {
94
95
  async function detectProjectFacts(root) {
95
96
  const facts = { hints: [] };
96
97
  try {
97
- const pkg = JSON.parse(await fsp5.readFile(path38.join(root, "package.json"), "utf8"));
98
+ const pkg = JSON.parse(await fsp5.readFile(path39.join(root, "package.json"), "utf8"));
98
99
  const scripts = pkg.scripts ?? {};
99
100
  const pm = await detectPackageManager2(root, pkg.packageManager);
100
101
  if (hasUsableScript(scripts, "build")) facts.build = `${pm} run build`;
@@ -108,14 +109,14 @@ async function detectProjectFacts(root) {
108
109
  } catch {
109
110
  }
110
111
  try {
111
- if (!await pathExists(path38.join(root, "pyproject.toml"))) throw new Error("not python");
112
+ if (!await pathExists(path39.join(root, "pyproject.toml"))) throw new Error("not python");
112
113
  facts.test ??= "pytest";
113
114
  facts.lint ??= "ruff check .";
114
115
  facts.hints.push("pyproject.toml");
115
116
  } catch {
116
117
  }
117
118
  try {
118
- if (!await pathExists(path38.join(root, "go.mod"))) throw new Error("not go");
119
+ if (!await pathExists(path39.join(root, "go.mod"))) throw new Error("not go");
119
120
  facts.build ??= "go build ./...";
120
121
  facts.test ??= "go test ./...";
121
122
  facts.run ??= "go run .";
@@ -123,7 +124,7 @@ async function detectProjectFacts(root) {
123
124
  } catch {
124
125
  }
125
126
  try {
126
- if (!await pathExists(path38.join(root, "Cargo.toml"))) throw new Error("not rust");
127
+ if (!await pathExists(path39.join(root, "Cargo.toml"))) throw new Error("not rust");
127
128
  facts.build ??= "cargo build";
128
129
  facts.test ??= "cargo test";
129
130
  facts.lint ??= "cargo clippy";
@@ -132,7 +133,7 @@ async function detectProjectFacts(root) {
132
133
  } catch {
133
134
  }
134
135
  try {
135
- const makefile = await fsp5.readFile(path38.join(root, "Makefile"), "utf8");
136
+ const makefile = await fsp5.readFile(path39.join(root, "Makefile"), "utf8");
136
137
  const targets = parseMakeTargets(makefile);
137
138
  facts.build ??= targets.has("build") ? "make build" : "make";
138
139
  if (targets.has("test")) facts.test ??= "make test";
@@ -371,26 +372,26 @@ function fmtDuration(ms) {
371
372
  const remMin = m - h * 60;
372
373
  return `${h}h${remMin}m`;
373
374
  }
374
- function fmtTaskResultLine(r, color71) {
375
+ function fmtTaskResultLine(r, color72) {
375
376
  const stats = `${r.iterations}it ${r.toolCalls}tc ${fmtDuration(r.durationMs)}`;
376
377
  const errMsg = typeof r.error === "string" ? r.error : r.error?.message;
377
378
  const errKind = typeof r.error === "object" ? r.error?.kind : void 0;
378
379
  const errTail = errMsg ? ` \u2014 ${errMsg.replace(/\s+/g, " ").slice(0, 80)}${errMsg.length > 80 ? "\u2026" : ""}` : "";
379
- const errKindChip = errKind ? color71.dim(` [${errKind}]`) : "";
380
- const errSnip = errMsg || errKind ? `${errKindChip}${color71.dim(errTail)}` : "";
380
+ const errKindChip = errKind ? color72.dim(` [${errKind}]`) : "";
381
+ const errSnip = errMsg || errKind ? `${errKindChip}${color72.dim(errTail)}` : "";
381
382
  switch (r.status) {
382
383
  case "success":
383
- return { mark: color71.green("\u2713"), stats, tail: "" };
384
+ return { mark: color72.green("\u2713"), stats, tail: "" };
384
385
  case "timeout":
385
386
  return {
386
- mark: color71.yellow("\u23F1"),
387
- stats: `${color71.yellow("timeout")} ${stats}`,
387
+ mark: color72.yellow("\u23F1"),
388
+ stats: `${color72.yellow("timeout")} ${stats}`,
388
389
  tail: errSnip
389
390
  };
390
391
  case "stopped":
391
- return { mark: color71.dim("\u2298"), stats: `${color71.dim("stopped")} ${stats}`, tail: errSnip };
392
+ return { mark: color72.dim("\u2298"), stats: `${color72.dim("stopped")} ${stats}`, tail: errSnip };
392
393
  case "failed":
393
- return { mark: color71.red("\u2717"), stats: `${color71.red("failed")} ${stats}`, tail: errSnip };
394
+ return { mark: color72.red("\u2717"), stats: `${color72.red("failed")} ${stats}`, tail: errSnip };
394
395
  }
395
396
  }
396
397
  var init_utils = __esm({
@@ -675,7 +676,7 @@ async function findSpec(store, idOrTitle) {
675
676
  async function gatherProjectContext2(projectRoot) {
676
677
  const parts = [];
677
678
  try {
678
- const pkgPath = path38.join(projectRoot, "package.json");
679
+ const pkgPath = path39.join(projectRoot, "package.json");
679
680
  const pkgRaw = await fsp5.readFile(pkgPath, "utf8");
680
681
  const pkg = JSON.parse(pkgRaw);
681
682
  parts.push(`Project: ${String(pkg.name ?? "unknown")}`);
@@ -693,13 +694,13 @@ async function gatherProjectContext2(projectRoot) {
693
694
  } catch {
694
695
  }
695
696
  try {
696
- const tsconfigPath = path38.join(projectRoot, "tsconfig.json");
697
+ const tsconfigPath = path39.join(projectRoot, "tsconfig.json");
697
698
  await fsp5.access(tsconfigPath);
698
699
  parts.push("Language: TypeScript");
699
700
  } catch {
700
701
  }
701
702
  try {
702
- const srcDir = path38.join(projectRoot, "src");
703
+ const srcDir = path39.join(projectRoot, "src");
703
704
  const entries = await fsp5.readdir(srcDir, { withFileTypes: true });
704
705
  const dirs = entries.filter((e) => e.isDirectory()).map((e) => e.name);
705
706
  if (dirs.length > 0) parts.push(`Source structure: src/${dirs.join(", src/")}`);
@@ -2124,12 +2125,12 @@ __export(project_utils_exports, {
2124
2125
  touchProjectInManifest: () => touchProjectInManifest
2125
2126
  });
2126
2127
  function projectsJsonPath(globalConfigPath) {
2127
- const base = globalConfigPath ? path38.dirname(globalConfigPath) : wstackGlobalRoot();
2128
- return path38.join(base, "projects.json");
2128
+ const base = globalConfigPath ? path39.dirname(globalConfigPath) : wstackGlobalRoot();
2129
+ return path39.join(base, "projects.json");
2129
2130
  }
2130
2131
  function projectsDataDir(globalConfigPath) {
2131
- const base = globalConfigPath ? path38.dirname(globalConfigPath) : wstackGlobalRoot();
2132
- return path38.join(base, "projects");
2132
+ const base = globalConfigPath ? path39.dirname(globalConfigPath) : wstackGlobalRoot();
2133
+ return path39.join(base, "projects");
2133
2134
  }
2134
2135
  async function loadManifest(globalConfigPath) {
2135
2136
  const file = projectsJsonPath(globalConfigPath);
@@ -2143,12 +2144,12 @@ async function loadManifest(globalConfigPath) {
2143
2144
  }
2144
2145
  async function saveManifest(manifest, globalConfigPath) {
2145
2146
  const file = projectsJsonPath(globalConfigPath);
2146
- await fsp5.mkdir(path38.dirname(file), { recursive: true });
2147
+ await fsp5.mkdir(path39.dirname(file), { recursive: true });
2147
2148
  await fsp5.writeFile(file, JSON.stringify(manifest, null, 2), "utf8");
2148
2149
  }
2149
2150
  function generateSlug(root) {
2150
- const base = path38.basename(root).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
2151
- const hash = createHash("sha256").update(path38.resolve(root)).digest("hex").slice(0, 6);
2151
+ const base = path39.basename(root).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
2152
+ const hash = createHash("sha256").update(path39.resolve(root)).digest("hex").slice(0, 6);
2152
2153
  return `${base}-${hash}`;
2153
2154
  }
2154
2155
  function findProject(manifest, query) {
@@ -2163,29 +2164,29 @@ function findProject(manifest, query) {
2163
2164
  return found;
2164
2165
  }
2165
2166
  async function ensureProjectDataDir(slug, globalConfigPath) {
2166
- const dir = path38.join(projectsDataDir(globalConfigPath), slug);
2167
+ const dir = path39.join(projectsDataDir(globalConfigPath), slug);
2167
2168
  await fsp5.mkdir(dir, { recursive: true });
2168
2169
  return dir;
2169
2170
  }
2170
2171
  async function touchProjectInManifest(opts) {
2171
- const root = path38.resolve(opts.projectRoot);
2172
+ const root = path39.resolve(opts.projectRoot);
2172
2173
  const file = projectsJsonPath(opts.globalConfigPath);
2173
2174
  let entry;
2174
2175
  await withFileLock(file, async () => {
2175
2176
  const manifest = await loadManifest(opts.globalConfigPath);
2176
2177
  const now = (/* @__PURE__ */ new Date()).toISOString();
2177
- entry = manifest.projects.find((p) => path38.resolve(p.root) === root);
2178
+ entry = manifest.projects.find((p) => path39.resolve(p.root) === root);
2178
2179
  if (entry) {
2179
2180
  entry.lastSeen = now;
2180
- if (opts.workingDir) entry.lastWorkingDir = path38.resolve(opts.workingDir);
2181
+ if (opts.workingDir) entry.lastWorkingDir = path39.resolve(opts.workingDir);
2181
2182
  } else {
2182
2183
  entry = {
2183
- name: opts.name ?? path38.basename(root),
2184
+ name: opts.name ?? path39.basename(root),
2184
2185
  root,
2185
2186
  slug: generateSlug(root),
2186
2187
  createdAt: now,
2187
2188
  lastSeen: now,
2188
- lastWorkingDir: opts.workingDir ? path38.resolve(opts.workingDir) : void 0
2189
+ lastWorkingDir: opts.workingDir ? path39.resolve(opts.workingDir) : void 0
2189
2190
  };
2190
2191
  manifest.projects.push(entry);
2191
2192
  }
@@ -2379,7 +2380,7 @@ async function runProjectPicker(opts) {
2379
2380
  const reservedBottom = 3;
2380
2381
  const headerHeight = reservedTop + reservedBottom;
2381
2382
  const baseVisibleHeight = Math.max(5, terminalHeight() - headerHeight);
2382
- return new Promise((resolve10) => {
2383
+ return new Promise((resolve11) => {
2383
2384
  const wasRaw = stdin.isRaw;
2384
2385
  const wasPaused = stdin.isPaused();
2385
2386
  let filter = "";
@@ -2503,7 +2504,7 @@ async function runProjectPicker(opts) {
2503
2504
  cleanup();
2504
2505
  out.write(CURSOR_SHOW);
2505
2506
  out.write("\n");
2506
- resolve10(void 0);
2507
+ resolve11(void 0);
2507
2508
  return;
2508
2509
  }
2509
2510
  if (ch === ESC) {
@@ -2516,7 +2517,7 @@ async function runProjectPicker(opts) {
2516
2517
  cleanup();
2517
2518
  out.write(CURSOR_SHOW);
2518
2519
  out.write("\n");
2519
- resolve10(void 0);
2520
+ resolve11(void 0);
2520
2521
  return;
2521
2522
  }
2522
2523
  if (ch === BS || ch === "\b") {
@@ -2533,22 +2534,22 @@ async function runProjectPicker(opts) {
2533
2534
  out.write(CURSOR_SHOW);
2534
2535
  out.write("\n");
2535
2536
  if (!item || item.key === "__divider__") {
2536
- resolve10(void 0);
2537
+ resolve11(void 0);
2537
2538
  return;
2538
2539
  }
2539
2540
  if (item.key === "quit") {
2540
- resolve10(void 0);
2541
+ resolve11(void 0);
2541
2542
  return;
2542
2543
  }
2543
2544
  if (item.key === "new-session") {
2544
- resolve10({ kind: "action", key: "new-session", action: "new-session" });
2545
+ resolve11({ kind: "action", key: "new-session", action: "new-session" });
2545
2546
  return;
2546
2547
  }
2547
2548
  if (item.key === "prev-sessions") {
2548
- resolve10({ kind: "action", key: "prev-sessions", action: "prev-sessions" });
2549
+ resolve11({ kind: "action", key: "prev-sessions", action: "prev-sessions" });
2549
2550
  return;
2550
2551
  }
2551
- resolve10({ kind: "project", key: item.key });
2552
+ resolve11({ kind: "project", key: item.key });
2552
2553
  return;
2553
2554
  }
2554
2555
  if (filter.length === 0) {
@@ -2556,7 +2557,7 @@ async function runProjectPicker(opts) {
2556
2557
  cleanup();
2557
2558
  out.write(CURSOR_SHOW);
2558
2559
  out.write("\n");
2559
- resolve10(void 0);
2560
+ resolve11(void 0);
2560
2561
  return;
2561
2562
  }
2562
2563
  if (ch === "j") {
@@ -2585,7 +2586,7 @@ async function runProjectPicker(opts) {
2585
2586
  try {
2586
2587
  stdin.setRawMode(true);
2587
2588
  } catch {
2588
- resolve10(void 0);
2589
+ resolve11(void 0);
2589
2590
  return;
2590
2591
  }
2591
2592
  stdin.resume();
@@ -2596,7 +2597,7 @@ async function runProjectPicker(opts) {
2596
2597
  stdin.once("close", () => {
2597
2598
  cleanup();
2598
2599
  out.write(CURSOR_SHOW);
2599
- resolve10(void 0);
2600
+ resolve11(void 0);
2600
2601
  });
2601
2602
  });
2602
2603
  }
@@ -2631,7 +2632,7 @@ __export(update_check_exports, {
2631
2632
  getUpdateNotification: () => getUpdateNotification
2632
2633
  });
2633
2634
  function cachePath(homeFn = defaultHomeDir2) {
2634
- return path38.join(homeFn(), ".wrongstack", "update-cache.json");
2635
+ return path39.join(homeFn(), ".wrongstack", "update-cache.json");
2635
2636
  }
2636
2637
  function currentVersion() {
2637
2638
  const req2 = createRequire(import.meta.url);
@@ -2668,7 +2669,7 @@ async function readCache(homeFn = defaultHomeDir2) {
2668
2669
  }
2669
2670
  async function writeCache(entry, homeFn = defaultHomeDir2) {
2670
2671
  try {
2671
- const dir = path38.dirname(cachePath(homeFn));
2672
+ const dir = path39.dirname(cachePath(homeFn));
2672
2673
  await fsp5.mkdir(dir, { recursive: true });
2673
2674
  await fsp5.writeFile(cachePath(homeFn), JSON.stringify(entry, null, 2), "utf8");
2674
2675
  } catch {
@@ -2754,7 +2755,7 @@ function registerWebuiInstance(p, deps = {}) {
2754
2755
  wsPort: p.wsPort,
2755
2756
  host: p.host,
2756
2757
  projectRoot: p.projectRoot,
2757
- projectName: path38.basename(p.projectRoot) || p.projectRoot,
2758
+ projectName: path39.basename(p.projectRoot) || p.projectRoot,
2758
2759
  startedAt: p.startedAt,
2759
2760
  url: `http://${p.host}:${p.httpPort}`
2760
2761
  },
@@ -2818,7 +2819,7 @@ var init_lifecycle = __esm({
2818
2819
  }
2819
2820
  });
2820
2821
  function getVault(globalConfigPath) {
2821
- const keyFile = path38.join(path38.dirname(globalConfigPath ?? ""), ".key");
2822
+ const keyFile = path39.join(path39.dirname(globalConfigPath ?? ""), ".key");
2822
2823
  return new DefaultSecretVault({ keyFile });
2823
2824
  }
2824
2825
  async function loadSavedProviders(globalConfigPath) {
@@ -2852,7 +2853,7 @@ function resolveDistDir() {
2852
2853
  try {
2853
2854
  const requireFromHere = createRequire(import.meta.url);
2854
2855
  const serverEntry = requireFromHere.resolve("@wrongstack/webui/server");
2855
- return path38.resolve(path38.dirname(serverEntry), "..");
2856
+ return path39.resolve(path39.dirname(serverEntry), "..");
2856
2857
  } catch {
2857
2858
  return null;
2858
2859
  }
@@ -3124,10 +3125,10 @@ function handlePing(ctx, ws) {
3124
3125
  ctx.send(ws, { type: "pong", payload: {} });
3125
3126
  }
3126
3127
  function handleToolConfirmResult(ctx, id, decision) {
3127
- const resolve10 = ctx.pendingConfirms.get(id);
3128
- if (resolve10) {
3128
+ const resolve11 = ctx.pendingConfirms.get(id);
3129
+ if (resolve11) {
3129
3130
  ctx.pendingConfirms.delete(id);
3130
- resolve10(decision);
3131
+ resolve11(decision);
3131
3132
  }
3132
3133
  }
3133
3134
  var init_connection = __esm({
@@ -3543,8 +3544,8 @@ function sendResult6(ctx, ws, success, message) {
3543
3544
  ctx.send(ws, { type: "key.operation_result", payload: { success, message } });
3544
3545
  }
3545
3546
  async function handleProjectsList(ctx, ws) {
3546
- const projectsBase = ctx.opts.globalConfigPath ? path38.resolve(path38.dirname(ctx.opts.globalConfigPath)) : wstackGlobalRoot();
3547
- const manifestPath = path38.join(projectsBase, "projects.json");
3547
+ const projectsBase = ctx.opts.globalConfigPath ? path39.resolve(path39.dirname(ctx.opts.globalConfigPath)) : wstackGlobalRoot();
3548
+ const manifestPath = path39.join(projectsBase, "projects.json");
3548
3549
  try {
3549
3550
  const raw = await fsp5.readFile(manifestPath, "utf8");
3550
3551
  const manifest = JSON.parse(raw);
@@ -3557,22 +3558,22 @@ async function handleProjectsSelect(ctx, ws, payload) {
3557
3558
  const { opts } = ctx;
3558
3559
  const { root, name: projectName } = payload;
3559
3560
  try {
3560
- const resolved = path38.resolve(root);
3561
+ const resolved = path39.resolve(root);
3561
3562
  const stat7 = await fsp5.stat(resolved).catch(() => null);
3562
3563
  if (!stat7?.isDirectory()) {
3563
3564
  ctx.send(ws, {
3564
3565
  type: "projects.selected",
3565
3566
  payload: {
3566
3567
  root,
3567
- name: projectName ?? path38.basename(root),
3568
+ name: projectName ?? path39.basename(root),
3568
3569
  message: `Cannot switch: not a directory: ${resolved}`
3569
3570
  }
3570
3571
  });
3571
3572
  return;
3572
3573
  }
3573
3574
  const manifest = await loadManifest(opts.globalConfigPath);
3574
- const entry = manifest.projects.find((p) => path38.resolve(p.root) === resolved);
3575
- const displayName = projectName?.trim() || entry?.name || path38.basename(resolved);
3575
+ const entry = manifest.projects.find((p) => path39.resolve(p.root) === resolved);
3576
+ const displayName = projectName?.trim() || entry?.name || path39.basename(resolved);
3576
3577
  if (entry) {
3577
3578
  entry.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
3578
3579
  } else {
@@ -3618,8 +3619,8 @@ async function handleProjectsSelect(ctx, ws, payload) {
3618
3619
  });
3619
3620
  } catch {
3620
3621
  }
3621
- const globalRoot = opts.globalConfigPath ? path38.dirname(opts.globalConfigPath) : wstackGlobalRoot();
3622
- const newSessionsDir = path38.join(resolveProjectDir(resolved, globalRoot), "sessions");
3622
+ const globalRoot = opts.globalConfigPath ? path39.dirname(opts.globalConfigPath) : wstackGlobalRoot();
3623
+ const newSessionsDir = path39.join(resolveProjectDir(resolved, globalRoot), "sessions");
3623
3624
  await fsp5.mkdir(newSessionsDir, { recursive: true });
3624
3625
  const newStore = new DefaultSessionStore({ dir: newSessionsDir });
3625
3626
  opts.sessionStore = newStore;
@@ -3649,11 +3650,11 @@ async function handleProjectsSelect(ctx, ws, payload) {
3649
3650
  async function handleProjectsAdd(ctx, ws, payload) {
3650
3651
  const { root: addRoot, name: addName } = payload;
3651
3652
  try {
3652
- const resolved = path38.resolve(addRoot);
3653
+ const resolved = path39.resolve(addRoot);
3653
3654
  const stat7 = await fsp5.stat(resolved).catch(() => null);
3654
3655
  if (!stat7?.isDirectory()) throw new Error(`Not a directory: ${resolved}`);
3655
3656
  const manifest = await loadManifest(ctx.opts.globalConfigPath);
3656
- const existing = manifest.projects.find((p) => path38.resolve(p.root) === resolved);
3657
+ const existing = manifest.projects.find((p) => path39.resolve(p.root) === resolved);
3657
3658
  if (existing) {
3658
3659
  ctx.send(ws, {
3659
3660
  type: "projects.added",
@@ -3666,7 +3667,7 @@ async function handleProjectsAdd(ctx, ws, payload) {
3666
3667
  });
3667
3668
  return;
3668
3669
  }
3669
- const name = addName?.trim() || path38.basename(resolved);
3670
+ const name = addName?.trim() || path39.basename(resolved);
3670
3671
  const slug = projectSlug(resolved);
3671
3672
  await ensureProjectDataDir(slug, ctx.opts.globalConfigPath);
3672
3673
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -3680,7 +3681,7 @@ async function handleProjectsAdd(ctx, ws, payload) {
3680
3681
  ctx.send(ws, {
3681
3682
  type: "projects.added",
3682
3683
  payload: {
3683
- name: path38.basename(addRoot),
3684
+ name: path39.basename(addRoot),
3684
3685
  root: addRoot,
3685
3686
  slug: "",
3686
3687
  message: err instanceof Error ? err.message : String(err)
@@ -3691,8 +3692,8 @@ async function handleProjectsAdd(ctx, ws, payload) {
3691
3692
  async function handleWorkingDirSet(ctx, ws, newPath) {
3692
3693
  try {
3693
3694
  const wdRoot = ctx.opts.projectRoot ?? ctx.opts.agent.ctx.projectRoot;
3694
- const resolved = path38.resolve(wdRoot, newPath);
3695
- if (!resolved.startsWith(wdRoot + path38.sep) && resolved !== wdRoot) {
3695
+ const resolved = path39.resolve(wdRoot, newPath);
3696
+ if (!resolved.startsWith(wdRoot + path39.sep) && resolved !== wdRoot) {
3696
3697
  sendResult6(ctx, ws, false, `Path must stay inside the project root: ${wdRoot}`);
3697
3698
  return;
3698
3699
  }
@@ -3933,13 +3934,13 @@ function sendResult8(ctx, ws, success, message) {
3933
3934
  }
3934
3935
  function storeFor(opts) {
3935
3936
  return opts.sessionStore ?? new DefaultSessionStore({
3936
- dir: path38.join(opts.projectRoot ?? opts.agent.ctx.projectRoot, ".wrongstack", "sessions")
3937
+ dir: path39.join(opts.projectRoot ?? opts.agent.ctx.projectRoot, ".wrongstack", "sessions")
3937
3938
  });
3938
3939
  }
3939
3940
  async function handleGoalGet(ctx, _ws) {
3940
3941
  const projectRoot = ctx.opts.projectRoot ?? ctx.opts.agent.ctx.projectRoot;
3941
3942
  try {
3942
- const goalPath = path38.join(projectRoot, ".wrongstack", "goal.json");
3943
+ const goalPath = path39.join(projectRoot, ".wrongstack", "goal.json");
3943
3944
  const raw = await fsp5.readFile(goalPath, "utf8");
3944
3945
  ctx.broadcast({ type: "goal.updated", payload: JSON.parse(raw) });
3945
3946
  } catch {
@@ -4015,7 +4016,7 @@ async function handleSessionNew(ctx, _ws) {
4015
4016
  function rewinderFor(opts) {
4016
4017
  const projectRoot = opts.projectRoot ?? opts.agent.ctx.projectRoot;
4017
4018
  return new DefaultSessionRewinder(
4018
- opts.sessionsDir ?? path38.join(projectRoot, ".wrongstack", "sessions"),
4019
+ opts.sessionsDir ?? path39.join(projectRoot, ".wrongstack", "sessions"),
4019
4020
  projectRoot
4020
4021
  );
4021
4022
  }
@@ -4349,14 +4350,14 @@ async function runWebUI(opts) {
4349
4350
  let customModeStoreP = null;
4350
4351
  const getCustomModeStore = () => {
4351
4352
  customModeStoreP ??= (async () => {
4352
- const dir = opts.globalConfigPath ? path38.dirname(opts.globalConfigPath) : wstackGlobalRoot();
4353
+ const dir = opts.globalConfigPath ? path39.dirname(opts.globalConfigPath) : wstackGlobalRoot();
4353
4354
  const store = createCustomModeStore(dir);
4354
4355
  await store.load();
4355
4356
  return store;
4356
4357
  })();
4357
4358
  return customModeStoreP;
4358
4359
  };
4359
- const autoPhaseStoreDir = opts.projectRoot ? path38.join(opts.projectRoot, ".wrongstack", "autophase") : path38.join(os.tmpdir(), ".wrongstack", "autophase");
4360
+ const autoPhaseStoreDir = opts.projectRoot ? path39.join(opts.projectRoot, ".wrongstack", "autophase") : path39.join(os.tmpdir(), ".wrongstack", "autophase");
4360
4361
  const autoPhaseHandler = new AutoPhaseWebSocketHandler(
4361
4362
  opts.agent,
4362
4363
  opts.agent.ctx,
@@ -4447,7 +4448,7 @@ async function runWebUI(opts) {
4447
4448
  return;
4448
4449
  }
4449
4450
  const vault = new DefaultSecretVault({
4450
- keyFile: path38.join(path38.dirname(configPath2), ".key")
4451
+ keyFile: path39.join(path39.dirname(configPath2), ".key")
4451
4452
  });
4452
4453
  const decrypted = decryptConfigSecrets$1(parsed, vault);
4453
4454
  const autonomyCfg = decrypted.autonomy ?? {};
@@ -4570,7 +4571,7 @@ async function runWebUI(opts) {
4570
4571
  model: opts.agent.ctx.model,
4571
4572
  provider: opts.agent.ctx.provider.id,
4572
4573
  mode: opts.modeId ?? "default",
4573
- projectName: opts.projectRoot ? path38.basename(opts.projectRoot) : void 0,
4574
+ projectName: opts.projectRoot ? path39.basename(opts.projectRoot) : void 0,
4574
4575
  // Frontend reads `projectRoot` from session.start (ws-handlers setEnv) —
4575
4576
  // omitting it left the store's projectRoot empty after a project switch.
4576
4577
  projectRoot: opts.projectRoot ?? opts.agent.ctx.projectRoot ?? "",
@@ -4596,7 +4597,7 @@ async function runWebUI(opts) {
4596
4597
  const projectDir = resolveProjectDir(opts.projectRoot, wstackGlobalRoot());
4597
4598
  const mailbox = new GlobalMailbox(projectDir, opts.events);
4598
4599
  webuiClientId = `webui@${crypto3.randomUUID().slice(0, 8)}`;
4599
- const projectName = opts.projectRoot ? path38.basename(opts.projectRoot) : "unknown";
4600
+ const projectName = opts.projectRoot ? path39.basename(opts.projectRoot) : "unknown";
4600
4601
  await mailbox.registerClient({
4601
4602
  clientId: webuiClientId,
4602
4603
  sessionId: opts.projectRoot,
@@ -4627,7 +4628,7 @@ async function runWebUI(opts) {
4627
4628
  host,
4628
4629
  httpPort,
4629
4630
  wsPort,
4630
- globalRoot: path38.dirname(opts.globalConfigPath ?? "")
4631
+ globalRoot: path39.dirname(opts.globalConfigPath ?? "")
4631
4632
  });
4632
4633
  if (httpServer) {
4633
4634
  announceWebuiReady({
@@ -4642,7 +4643,7 @@ async function runWebUI(opts) {
4642
4643
  `[WebUI] Frontend not served (run \`pnpm --filter @wrongstack/webui build\`). WS bridge still active on ws://${host}:${wsPort}.`
4643
4644
  );
4644
4645
  }
4645
- const registryBaseDir = opts.globalConfigPath ? path38.dirname(opts.globalConfigPath) : void 0;
4646
+ const registryBaseDir = opts.globalConfigPath ? path39.dirname(opts.globalConfigPath) : void 0;
4646
4647
  if (opts.projectRoot) {
4647
4648
  registerWebuiInstance({
4648
4649
  pid: process.pid,
@@ -4999,12 +5000,12 @@ async function runWebUI(opts) {
4999
5000
  broadcast,
5000
5001
  log: (m) => console.log(m)
5001
5002
  };
5002
- return new Promise((resolve10) => {
5003
+ return new Promise((resolve11) => {
5003
5004
  wss.on("listening", () => {
5004
5005
  console.log(`[WebUI] WebSocket server running on ws://${host}:${port}`);
5005
5006
  setupEvents();
5006
5007
  opts.onListening?.({ httpPort, wsPort, host });
5007
- const globalRoot = opts.globalConfigPath ? path38.dirname(opts.globalConfigPath) : void 0;
5008
+ const globalRoot = opts.globalConfigPath ? path39.dirname(opts.globalConfigPath) : void 0;
5008
5009
  if (globalRoot) {
5009
5010
  const statusInterval = setInterval(async () => {
5010
5011
  try {
@@ -5123,8 +5124,8 @@ async function runWebUI(opts) {
5123
5124
  clients.delete(ws);
5124
5125
  abortControllers.delete(ws);
5125
5126
  if (clients.size === 0 && pendingConfirms.size > 0) {
5126
- for (const [id, resolve11] of pendingConfirms) {
5127
- resolve11("no");
5127
+ for (const [id, resolve12] of pendingConfirms) {
5128
+ resolve12("no");
5128
5129
  pendingConfirms.delete(id);
5129
5130
  }
5130
5131
  }
@@ -5163,7 +5164,7 @@ async function runWebUI(opts) {
5163
5164
  wss,
5164
5165
  pid: process.pid,
5165
5166
  registryBaseDir,
5166
- onStopped: resolve10
5167
+ onStopped: resolve11
5167
5168
  });
5168
5169
  registerWebuiSignalHandlers(signalShutdown);
5169
5170
  });
@@ -5553,7 +5554,7 @@ async function runWebUI(opts) {
5553
5554
  // ── Mailbox operations — project-level inter-agent messaging ────
5554
5555
  case "mailbox.messages": {
5555
5556
  const projectRoot = opts.projectRoot ?? opts.agent.ctx.projectRoot ?? "";
5556
- const globalRoot = opts.globalConfigPath ? path38.dirname(opts.globalConfigPath) : "";
5557
+ const globalRoot = opts.globalConfigPath ? path39.dirname(opts.globalConfigPath) : "";
5557
5558
  if (!projectRoot || !globalRoot) {
5558
5559
  send(ws, {
5559
5560
  type: "mailbox.messages",
@@ -5602,7 +5603,7 @@ async function runWebUI(opts) {
5602
5603
  }
5603
5604
  case "mailbox.agents": {
5604
5605
  const projectRoot = opts.projectRoot ?? opts.agent.ctx.projectRoot ?? "";
5605
- const globalRoot = opts.globalConfigPath ? path38.dirname(opts.globalConfigPath) : "";
5606
+ const globalRoot = opts.globalConfigPath ? path39.dirname(opts.globalConfigPath) : "";
5606
5607
  if (!projectRoot || !globalRoot) {
5607
5608
  send(ws, {
5608
5609
  type: "mailbox.agents",
@@ -5645,7 +5646,7 @@ async function runWebUI(opts) {
5645
5646
  }
5646
5647
  case "mailbox.clear": {
5647
5648
  const projectRoot = opts.projectRoot ?? opts.agent.ctx.projectRoot ?? "";
5648
- const globalRoot = opts.globalConfigPath ? path38.dirname(opts.globalConfigPath) : "";
5649
+ const globalRoot = opts.globalConfigPath ? path39.dirname(opts.globalConfigPath) : "";
5649
5650
  if (!projectRoot || !globalRoot) {
5650
5651
  send(ws, { type: "mailbox.cleared", payload: { error: "No project root available" } });
5651
5652
  break;
@@ -5715,7 +5716,7 @@ var init_webui_server = __esm({
5715
5716
  var WORKTREE_PHASE_CONCURRENCY = 4;
5716
5717
  var MAX_CMD_OUTPUT = 2e5;
5717
5718
  function gitText(args, cwd) {
5718
- return new Promise((resolve10, reject) => {
5719
+ return new Promise((resolve11, reject) => {
5719
5720
  let child;
5720
5721
  try {
5721
5722
  child = spawn("git", args, {
@@ -5735,8 +5736,8 @@ function gitText(args, cwd) {
5735
5736
  };
5736
5737
  child.stdout?.on("data", emit);
5737
5738
  child.stderr?.on("data", emit);
5738
- child.on("error", () => resolve10({ code: 1, out: chunks.join("") }));
5739
- child.on("close", (code) => resolve10({ code: code ?? 1, out: chunks.join("").trim() }));
5739
+ child.on("error", () => resolve11({ code: 1, out: chunks.join("") }));
5740
+ child.on("close", (code) => resolve11({ code: code ?? 1, out: chunks.join("").trim() }));
5740
5741
  });
5741
5742
  }
5742
5743
  async function isGitRepo(cwd) {
@@ -5772,7 +5773,7 @@ function runCmd(cmd, args, cwd, shell = false) {
5772
5773
  });
5773
5774
  }
5774
5775
  }
5775
- return new Promise((resolve10, reject) => {
5776
+ return new Promise((resolve11, reject) => {
5776
5777
  const chunks = [];
5777
5778
  let child;
5778
5779
  try {
@@ -5795,11 +5796,11 @@ function runCmd(cmd, args, cwd, shell = false) {
5795
5796
  };
5796
5797
  child.stdout?.on("data", append);
5797
5798
  child.stderr?.on("data", append);
5798
- child.on("error", (e) => resolve10({ code: 1, out: `${chunks.join("")}${String(e)}` }));
5799
+ child.on("error", (e) => resolve11({ code: 1, out: `${chunks.join("")}${String(e)}` }));
5799
5800
  child.on("close", (code) => {
5800
5801
  let out = chunks.join("");
5801
5802
  if (out.length > MAX_CMD_OUTPUT) out = out.slice(-MAX_CMD_OUTPUT);
5802
- resolve10({ code: code ?? 1, out: out.trim() });
5803
+ resolve11({ code: code ?? 1, out: out.trim() });
5803
5804
  });
5804
5805
  });
5805
5806
  }
@@ -6275,7 +6276,7 @@ var ReadlineInputReader = class {
6275
6276
  history = [];
6276
6277
  pending = false;
6277
6278
  constructor(opts = {}) {
6278
- this.historyFile = opts.historyFile ?? path38.join(wstackGlobalRoot(), "history");
6279
+ this.historyFile = opts.historyFile ?? path39.join(wstackGlobalRoot(), "history");
6279
6280
  }
6280
6281
  async loadHistory() {
6281
6282
  try {
@@ -6287,7 +6288,7 @@ var ReadlineInputReader = class {
6287
6288
  }
6288
6289
  async saveHistory() {
6289
6290
  try {
6290
- await fsp5.mkdir(path38.dirname(this.historyFile), { recursive: true });
6291
+ await fsp5.mkdir(path39.dirname(this.historyFile), { recursive: true });
6291
6292
  await fsp5.writeFile(this.historyFile, this.history.slice(-1e3).join("\n"));
6292
6293
  } catch {
6293
6294
  }
@@ -6306,31 +6307,31 @@ var ReadlineInputReader = class {
6306
6307
  async readLine(prompt) {
6307
6308
  if (this.history.length === 0) await this.loadHistory();
6308
6309
  while (this.pending) {
6309
- await new Promise((resolve10) => setTimeout(resolve10, 50));
6310
+ await new Promise((resolve11) => setTimeout(resolve11, 50));
6310
6311
  }
6311
6312
  this.pending = true;
6312
6313
  try {
6313
6314
  if (this.rl) {
6314
6315
  const old = this.rl;
6315
6316
  this.rl = void 0;
6316
- await new Promise((resolve10) => {
6317
+ await new Promise((resolve11) => {
6317
6318
  if (old.closed) {
6318
- resolve10();
6319
+ resolve11();
6319
6320
  } else {
6320
- old.once("close", resolve10);
6321
+ old.once("close", resolve11);
6321
6322
  old.close();
6322
6323
  }
6323
6324
  });
6324
6325
  }
6325
6326
  const fresh = this.ensure();
6326
6327
  this.installPromptGuard(fresh);
6327
- return new Promise((resolve10) => {
6328
+ return new Promise((resolve11) => {
6328
6329
  let settled = false;
6329
6330
  const settle = (line) => {
6330
6331
  if (settled) return;
6331
6332
  settled = true;
6332
6333
  setOutputLineGuard(null);
6333
- resolve10(line);
6334
+ resolve11(line);
6334
6335
  };
6335
6336
  fresh.question(prompt ?? "> ", (line) => {
6336
6337
  if (line.trim()) {
@@ -6383,7 +6384,7 @@ var ReadlineInputReader = class {
6383
6384
  async readKey(prompt, options) {
6384
6385
  setOutputLineGuard(null);
6385
6386
  writeOut(prompt);
6386
- return new Promise((resolve10) => {
6387
+ return new Promise((resolve11) => {
6387
6388
  const stdin = process.stdin;
6388
6389
  const wasRaw = stdin.isRaw;
6389
6390
  const wasPaused = stdin.isPaused();
@@ -6394,7 +6395,7 @@ var ReadlineInputReader = class {
6394
6395
  if (key === "") {
6395
6396
  cleanup();
6396
6397
  writeOut("\n");
6397
- resolve10("");
6398
+ resolve11("");
6398
6399
  return;
6399
6400
  }
6400
6401
  const opt = options.find(
@@ -6404,12 +6405,12 @@ var ReadlineInputReader = class {
6404
6405
  cleanup();
6405
6406
  writeOut(`${opt.key}
6406
6407
  `);
6407
- resolve10(opt.value);
6408
+ resolve11(opt.value);
6408
6409
  }
6409
6410
  };
6410
6411
  const onClose = () => {
6411
6412
  cleanup();
6412
- resolve10("");
6413
+ resolve11("");
6413
6414
  };
6414
6415
  const cleanup = () => {
6415
6416
  stdin.off("data", onData);
@@ -6438,7 +6439,7 @@ var ReadlineInputReader = class {
6438
6439
  this.rl?.close();
6439
6440
  this.rl = void 0;
6440
6441
  writeOut(prompt);
6441
- return new Promise((resolve10) => {
6442
+ return new Promise((resolve11) => {
6442
6443
  let buf = "";
6443
6444
  const wasRaw = stdin.isRaw;
6444
6445
  setRawMode(stdin, true);
@@ -6456,7 +6457,7 @@ var ReadlineInputReader = class {
6456
6457
  cleanup();
6457
6458
  writeOut(` ${dim(`[${buf.length} chars]`)}
6458
6459
  `);
6459
- resolve10(buf);
6460
+ resolve11(buf);
6460
6461
  return;
6461
6462
  }
6462
6463
  if (ch === "") {
@@ -6619,7 +6620,7 @@ function pickGroupIndex(opts) {
6619
6620
  if (Number.isFinite(parsed)) current = wrap(parsed);
6620
6621
  } catch {
6621
6622
  }
6622
- fs2.mkdirSync(path38.dirname(opts.cursorFile), { recursive: true });
6623
+ fs2.mkdirSync(path39.dirname(opts.cursorFile), { recursive: true });
6623
6624
  fs2.writeFileSync(opts.cursorFile, String(wrap(current + 1)));
6624
6625
  return current;
6625
6626
  } catch {
@@ -6672,11 +6673,11 @@ function assertSafeToDelete(filename, parentDir) {
6672
6673
  throw new FsError({
6673
6674
  message: `Refusing to delete protected file: ${filename}`,
6674
6675
  code: ERROR_CODES.FS_DELETE_FAILED,
6675
- path: path38.join(parentDir, filename),
6676
+ path: path39.join(parentDir, filename),
6676
6677
  context: { reason: "protected_basename" }
6677
6678
  });
6678
6679
  }
6679
- if (filename !== path38.basename(filename)) {
6680
+ if (filename !== path39.basename(filename)) {
6680
6681
  throw new FsError({
6681
6682
  message: `Refusing to delete path with traversal: ${filename}`,
6682
6683
  code: ERROR_CODES.FS_DELETE_FAILED,
@@ -6688,11 +6689,11 @@ function assertSafeToDelete(filename, parentDir) {
6688
6689
  throw new FsError({
6689
6690
  message: `Refusing to delete unknown file: ${filename}`,
6690
6691
  code: ERROR_CODES.FS_DELETE_FAILED,
6691
- path: path38.join(parentDir, filename),
6692
+ path: path39.join(parentDir, filename),
6692
6693
  context: { reason: "unknown_file_pattern" }
6693
6694
  });
6694
6695
  }
6695
- const resolvedParent = path38.resolve(parentDir);
6696
+ const resolvedParent = path39.resolve(parentDir);
6696
6697
  if (!resolvedParent.endsWith(".wrongstack")) {
6697
6698
  throw new FsError({
6698
6699
  message: `Unexpected parent directory for bak prune: ${resolvedParent}`,
@@ -6703,8 +6704,8 @@ function assertSafeToDelete(filename, parentDir) {
6703
6704
  }
6704
6705
  }
6705
6706
  async function safeDelete(filePath) {
6706
- const dir = path38.dirname(filePath);
6707
- const filename = path38.basename(filePath);
6707
+ const dir = path39.dirname(filePath);
6708
+ const filename = path39.basename(filePath);
6708
6709
  try {
6709
6710
  assertSafeToDelete(filename, dir);
6710
6711
  await fsp5.unlink(filePath);
@@ -6749,16 +6750,16 @@ function diffSummary(oldCfg, newCfg) {
6749
6750
  }
6750
6751
  var defaultHomeDir = () => os__default.homedir();
6751
6752
  function historyDir(homeFn = defaultHomeDir) {
6752
- return path38.join(homeFn(), ".wrongstack", "config.history", "entries");
6753
+ return path39.join(homeFn(), ".wrongstack", "config.history", "entries");
6753
6754
  }
6754
6755
  function historyIndexPath(homeFn = defaultHomeDir) {
6755
- return path38.join(homeFn(), ".wrongstack", "config.history", "index.json");
6756
+ return path39.join(homeFn(), ".wrongstack", "config.history", "index.json");
6756
6757
  }
6757
6758
  function configPath(homeFn = defaultHomeDir) {
6758
- return path38.join(homeFn(), ".wrongstack", "config.json");
6759
+ return path39.join(homeFn(), ".wrongstack", "config.json");
6759
6760
  }
6760
6761
  function backupLastPath(homeFn = defaultHomeDir) {
6761
- return path38.join(homeFn(), ".wrongstack", "config.json.last");
6762
+ return path39.join(homeFn(), ".wrongstack", "config.json.last");
6762
6763
  }
6763
6764
  function entryId(ts) {
6764
6765
  return ts.replace(/[:.]/g, "-").slice(0, 19);
@@ -6816,7 +6817,7 @@ async function backupCurrent(homeFn = defaultHomeDir) {
6816
6817
  }
6817
6818
  if (content !== void 0) {
6818
6819
  try {
6819
- const bakPath = path38.join(homeFn(), ".wrongstack", `config.json.${ts}.bak`);
6820
+ const bakPath = path39.join(homeFn(), ".wrongstack", `config.json.${ts}.bak`);
6820
6821
  await atomicWrite(bakPath, content);
6821
6822
  } catch (err) {
6822
6823
  writeErr(
@@ -6825,11 +6826,11 @@ async function backupCurrent(homeFn = defaultHomeDir) {
6825
6826
  }
6826
6827
  }
6827
6828
  try {
6828
- const dir = path38.join(homeFn(), ".wrongstack");
6829
+ const dir = path39.join(homeFn(), ".wrongstack");
6829
6830
  const files = await fsp5.readdir(dir);
6830
6831
  const baks = files.filter((f) => f.startsWith("config.json.") && f.endsWith(".bak")).sort().reverse();
6831
6832
  for (const f of baks.slice(10)) {
6832
- await safeDelete(path38.join(dir, f));
6833
+ await safeDelete(path39.join(dir, f));
6833
6834
  }
6834
6835
  } catch (err) {
6835
6836
  writeErr(
@@ -6850,7 +6851,7 @@ async function appendHistory(oldCfg, newCfg, description, homeFn = defaultHomeDi
6850
6851
  };
6851
6852
  try {
6852
6853
  await fsp5.writeFile(
6853
- path38.join(historyDir(homeFn), `${id}.json`),
6854
+ path39.join(historyDir(homeFn), `${id}.json`),
6854
6855
  JSON.stringify(entry, null, 2),
6855
6856
  "utf8"
6856
6857
  );
@@ -6858,7 +6859,7 @@ async function appendHistory(oldCfg, newCfg, description, homeFn = defaultHomeDi
6858
6859
  throw new FsError({
6859
6860
  message: err instanceof Error ? err.message : String(err),
6860
6861
  code: ERROR_CODES.FS_WRITE_FAILED,
6861
- path: path38.join(historyDir(homeFn), `${id}.json`),
6862
+ path: path39.join(historyDir(homeFn), `${id}.json`),
6862
6863
  cause: err
6863
6864
  });
6864
6865
  }
@@ -6873,7 +6874,7 @@ async function listHistory(homeFn = defaultHomeDir) {
6873
6874
  }
6874
6875
  async function getHistoryEntry(id, homeFn = defaultHomeDir) {
6875
6876
  try {
6876
- const raw = await fsp5.readFile(path38.join(historyDir(homeFn), `${id}.json`), "utf8");
6877
+ const raw = await fsp5.readFile(path39.join(historyDir(homeFn), `${id}.json`), "utf8");
6877
6878
  return JSON.parse(raw);
6878
6879
  } catch {
6879
6880
  return null;
@@ -6990,10 +6991,10 @@ var theme = { primary: color.amber };
6990
6991
  async function saveToGlobalConfig(configPath2, provider, model, homeFn = () => process.env.HOME ?? os__default.homedir()) {
6991
6992
  try {
6992
6993
  const { atomicWrite: atomicWrite17 } = await import('@wrongstack/core');
6993
- const fs38 = await import('fs/promises');
6994
+ const fs39 = await import('fs/promises');
6994
6995
  let existing = {};
6995
6996
  try {
6996
- const raw = await fs38.readFile(configPath2, "utf8");
6997
+ const raw = await fs39.readFile(configPath2, "utf8");
6997
6998
  existing = JSON.parse(raw);
6998
6999
  } catch {
6999
7000
  }
@@ -7486,7 +7487,7 @@ function buildAutonomyCommand(opts) {
7486
7487
  const current = opts.onAutonomy();
7487
7488
  const lines = [`Autonomy mode: ${MODE_LABELS[current] ?? current}`];
7488
7489
  try {
7489
- const goal = await loadGoal(goalFilePath(opts.projectRoot));
7490
+ const goal = await loadGoal(goalFilePath(opts.projectRoot), opts.events);
7490
7491
  if (goal) {
7491
7492
  const u = summarizeUsage(goal);
7492
7493
  lines.push(
@@ -7532,7 +7533,7 @@ function buildAutonomyCommand(opts) {
7532
7533
  opts.onAutonomy("off");
7533
7534
  let summaryLine = "";
7534
7535
  try {
7535
- const goal = await loadGoal(goalFilePath(opts.projectRoot));
7536
+ const goal = await loadGoal(goalFilePath(opts.projectRoot), opts.events);
7536
7537
  if (goal) {
7537
7538
  const u = summarizeUsage(goal);
7538
7539
  if (u.iterationsWithUsage > 0) {
@@ -7572,7 +7573,7 @@ function buildAutonomyCommand(opts) {
7572
7573
  if (newMode === "eternal" || newMode === "eternal-parallel") {
7573
7574
  const wantKeep = modifiers.includes("--keep") || modifiers.includes("keep");
7574
7575
  const wantNew = modifiers.includes("--new") || modifiers.includes("new");
7575
- const goal = await loadGoal(goalFilePath(opts.projectRoot));
7576
+ const goal = await loadGoal(goalFilePath(opts.projectRoot), opts.events);
7576
7577
  if (!goal) {
7577
7578
  const msg3 = `${color.red("Eternal/parallel mode requires a goal.")} Run \`/goal set <mission>\` first.`;
7578
7579
  opts.renderer.writeWarning(msg3);
@@ -7675,7 +7676,7 @@ function formatPhaseList(graph) {
7675
7676
  }
7676
7677
  async function gatherProjectContext(projectRoot) {
7677
7678
  try {
7678
- const raw = await fsp5.readFile(path38.join(projectRoot, "package.json"), "utf8");
7679
+ const raw = await fsp5.readFile(path39.join(projectRoot, "package.json"), "utf8");
7679
7680
  const pkg = JSON.parse(raw);
7680
7681
  const parts = [
7681
7682
  `Project: ${String(pkg.name ?? "unknown")}`,
@@ -8146,7 +8147,9 @@ async function annotationsCommand(opts, sessionId) {
8146
8147
  )
8147
8148
  };
8148
8149
  }
8149
- const annotations = new AnnotationsStore({ dir: storeDir });
8150
+ const annotationsOpts = { dir: storeDir, events: opts.events };
8151
+ if (opts.context?.traceId !== void 0) annotationsOpts.traceId = opts.context.traceId;
8152
+ const annotations = new AnnotationsStore(annotationsOpts);
8150
8153
  const open = await annotations.listOpen(sessionId);
8151
8154
  if (open.length === 0) {
8152
8155
  return {
@@ -8664,7 +8667,7 @@ The following characters are not allowed: ; & | < > ^ $ , ( ) { } [ ] ! # % ' "
8664
8667
  }
8665
8668
  }
8666
8669
  function runCommand(cmd, cwd, timeout) {
8667
- return new Promise((resolve10) => {
8670
+ return new Promise((resolve11) => {
8668
8671
  validateCommand(cmd);
8669
8672
  const opts = {
8670
8673
  cwd,
@@ -8677,7 +8680,7 @@ function runCommand(cmd, cwd, timeout) {
8677
8680
  shell: process.platform === "win32" ? true : false
8678
8681
  };
8679
8682
  execFile(cmd, [], opts, (error, stdout, stderr) => {
8680
- resolve10({
8683
+ resolve11({
8681
8684
  stdout,
8682
8685
  stderr,
8683
8686
  exitCode: typeof error?.code === "number" ? error.code : 0,
@@ -9099,17 +9102,17 @@ function diagnoseConfig(cfg, plugins = []) {
9099
9102
  function scanPlaintextSecrets(node, prefix, findings) {
9100
9103
  if (!isPlainObject(node)) return;
9101
9104
  for (const [key, value] of Object.entries(node)) {
9102
- const path39 = prefix ? `${prefix}.${key}` : key;
9105
+ const path40 = prefix ? `${prefix}.${key}` : key;
9103
9106
  if (typeof value === "string") {
9104
9107
  if (value.length > 0 && isSecretField$1(key) && !value.startsWith(ENC_PREFIX)) {
9105
9108
  findings.push({
9106
- path: path39,
9109
+ path: path40,
9107
9110
  problem: "looks like a plaintext secret (not vault-encrypted) \u2014 it will be encrypted on next boot",
9108
9111
  severity: "warning"
9109
9112
  });
9110
9113
  }
9111
9114
  } else if (isPlainObject(value)) {
9112
- scanPlaintextSecrets(value, path39, findings);
9115
+ scanPlaintextSecrets(value, path40, findings);
9113
9116
  }
9114
9117
  }
9115
9118
  }
@@ -9130,7 +9133,7 @@ function resolvePersistPath(deps) {
9130
9133
  return deps.globalConfigPath;
9131
9134
  }
9132
9135
  async function ensureProjectDir(filePath) {
9133
- const dir = path38.dirname(filePath);
9136
+ const dir = path39.dirname(filePath);
9134
9137
  try {
9135
9138
  await fsp5.mkdir(dir, { recursive: true });
9136
9139
  } catch {
@@ -9334,8 +9337,8 @@ function buildDoctorCommand(opts) {
9334
9337
  return ` ${icon} ${color.cyan(f.path)} \u2014 ${f.problem}${fix}`;
9335
9338
  }
9336
9339
  async function findParsableBackup(file) {
9337
- const dir = path38.dirname(file);
9338
- const base = path38.basename(file);
9340
+ const dir = path39.dirname(file);
9341
+ const base = path39.basename(file);
9339
9342
  const candidates = [`${base}.last`];
9340
9343
  try {
9341
9344
  const siblings = await fsp5.readdir(dir);
@@ -9346,7 +9349,7 @@ function buildDoctorCommand(opts) {
9346
9349
  }
9347
9350
  for (const name of candidates) {
9348
9351
  try {
9349
- const raw = await fsp5.readFile(path38.join(dir, name), "utf8");
9352
+ const raw = await fsp5.readFile(path39.join(dir, name), "utf8");
9350
9353
  JSON.parse(raw);
9351
9354
  return { name, raw };
9352
9355
  } catch {
@@ -9463,7 +9466,7 @@ function buildDoctorCommand(opts) {
9463
9466
  await atomicWrite(target.file, JSON.stringify(report.fixed, null, 2));
9464
9467
  if (!target.isProject) {
9465
9468
  try {
9466
- const homeFn = () => path38.dirname(path38.dirname(target.file));
9469
+ const homeFn = () => path39.dirname(path39.dirname(target.file));
9467
9470
  await appendHistory(parsed, report.fixed, "config doctor auto-fix", homeFn);
9468
9471
  } catch {
9469
9472
  }
@@ -11324,7 +11327,7 @@ function buildGoalCommand(opts) {
11324
11327
  case "":
11325
11328
  case "show":
11326
11329
  case "status": {
11327
- const current = await loadGoal(goalPath);
11330
+ const current = await loadGoal(goalPath, opts.events);
11328
11331
  if (!current) {
11329
11332
  const msg2 = "No goal set. Use `/goal set <mission text>` to create one.";
11330
11333
  opts.renderer.write(msg2);
@@ -11349,7 +11352,7 @@ function buildGoalCommand(opts) {
11349
11352
  if (!refined) {
11350
11353
  refined = refineGoalHeuristic(setText);
11351
11354
  }
11352
- const existing = await loadGoal(goalPath);
11355
+ const existing = await loadGoal(goalPath, opts.events);
11353
11356
  const now = (/* @__PURE__ */ new Date()).toISOString();
11354
11357
  const next = existing ? {
11355
11358
  ...existing,
@@ -11366,7 +11369,7 @@ function buildGoalCommand(opts) {
11366
11369
  refinedGoal: refined.refinedGoal,
11367
11370
  deliverables: refined.deliverables
11368
11371
  };
11369
- await saveGoal(goalPath, next);
11372
+ await saveGoal(goalPath, next, opts.events);
11370
11373
  const lines = [];
11371
11374
  lines.push(`\u{1F3AF} ${color.green("Goal locked:")} ${color.bold(refined.refinedGoal)}`);
11372
11375
  if (refined.refinedGoal !== setText) {
@@ -11393,7 +11396,7 @@ function buildGoalCommand(opts) {
11393
11396
  };
11394
11397
  }
11395
11398
  case "refine": {
11396
- const current = await loadGoal(goalPath);
11399
+ const current = await loadGoal(goalPath, opts.events);
11397
11400
  if (!current) {
11398
11401
  const msg2 = "No goal set to refine. Use /goal set <text> first.";
11399
11402
  opts.renderer.writeWarning(msg2);
@@ -11412,7 +11415,7 @@ function buildGoalCommand(opts) {
11412
11415
  refinedGoal: refined.refinedGoal,
11413
11416
  deliverables: refined.deliverables
11414
11417
  };
11415
- await saveGoal(goalPath, updated);
11418
+ await saveGoal(goalPath, updated, opts.events);
11416
11419
  const msg = `${color.green("\u2713")} Goal re-refined with ${refined.deliverables.length} deliverables.`;
11417
11420
  opts.renderer.write(msg);
11418
11421
  return { message: `${msg}
@@ -11421,14 +11424,14 @@ ${formatGoal(updated)}` };
11421
11424
  }
11422
11425
  case "clear":
11423
11426
  case "reset": {
11424
- const current = await loadGoal(goalPath);
11427
+ const current = await loadGoal(goalPath, opts.events);
11425
11428
  if (!current) {
11426
11429
  const msg2 = "No goal to clear.";
11427
11430
  opts.renderer.write(msg2);
11428
11431
  return { message: msg2 };
11429
11432
  }
11430
11433
  const abandoned = { ...current, goalState: "abandoned" };
11431
- await saveGoal(goalPath, abandoned);
11434
+ await saveGoal(goalPath, abandoned, opts.events);
11432
11435
  const { unlink: unlink4 } = await import('fs/promises');
11433
11436
  try {
11434
11437
  await unlink4(goalPath);
@@ -11442,7 +11445,7 @@ ${formatGoal(updated)}` };
11442
11445
  }
11443
11446
  case "journal":
11444
11447
  case "log": {
11445
- const current = await loadGoal(goalPath);
11448
+ const current = await loadGoal(goalPath, opts.events);
11446
11449
  if (!current) {
11447
11450
  const msg2 = "No goal set.";
11448
11451
  opts.renderer.write(msg2);
@@ -11467,7 +11470,7 @@ ${lines.join("\n")}`;
11467
11470
  return { message: msg };
11468
11471
  }
11469
11472
  case "pause": {
11470
- const current = await loadGoal(goalPath);
11473
+ const current = await loadGoal(goalPath, opts.events);
11471
11474
  if (!current) {
11472
11475
  const msg2 = "No goal set \u2014 nothing to pause.";
11473
11476
  opts.renderer.writeWarning(msg2);
@@ -11479,13 +11482,13 @@ ${lines.join("\n")}`;
11479
11482
  return { message: msg2 };
11480
11483
  }
11481
11484
  const paused = { ...current, goalState: "paused" };
11482
- await saveGoal(goalPath, paused);
11485
+ await saveGoal(goalPath, paused, opts.events);
11483
11486
  const msg = `${color.cyan("Goal paused.")} Current iteration will finish, then the loop stops. Use /goal resume to continue.`;
11484
11487
  opts.renderer.write(msg);
11485
11488
  return { message: msg };
11486
11489
  }
11487
11490
  case "resume": {
11488
- const current = await loadGoal(goalPath);
11491
+ const current = await loadGoal(goalPath, opts.events);
11489
11492
  if (!current) {
11490
11493
  const msg2 = "No goal set \u2014 cannot resume.";
11491
11494
  opts.renderer.writeWarning(msg2);
@@ -11497,7 +11500,7 @@ ${lines.join("\n")}`;
11497
11500
  return { message: msg2 };
11498
11501
  }
11499
11502
  const resumed = { ...current, goalState: "active" };
11500
- await saveGoal(goalPath, resumed);
11503
+ await saveGoal(goalPath, resumed, opts.events);
11501
11504
  const msg = `${color.green("Goal resumed.")} Loop will continue from the next iteration.`;
11502
11505
  opts.renderer.write(msg);
11503
11506
  return { message: msg };
@@ -11584,8 +11587,8 @@ function buildInitCommand(opts) {
11584
11587
  description: "Create or update .wrongstack/AGENTS.md project context for the system prompt.",
11585
11588
  async run(_args, ctx) {
11586
11589
  const root = ctx?.projectRoot ?? opts.projectRoot ?? process.cwd();
11587
- const dir = path38.join(root, ".wrongstack");
11588
- const file = path38.join(dir, "AGENTS.md");
11590
+ const dir = path39.join(root, ".wrongstack");
11591
+ const file = path39.join(dir, "AGENTS.md");
11589
11592
  const isFirstInit = !await fileExists(file);
11590
11593
  const detected = await detectProjectFacts(root);
11591
11594
  const body = renderAgentsTemplate(detected);
@@ -11593,7 +11596,7 @@ function buildInitCommand(opts) {
11593
11596
  await fsp5.writeFile(file, body, "utf8");
11594
11597
  let nodePkg = false;
11595
11598
  try {
11596
- await fsp5.access(path38.join(root, "package.json"));
11599
+ await fsp5.access(path39.join(root, "package.json"));
11597
11600
  nodePkg = true;
11598
11601
  } catch {
11599
11602
  }
@@ -12277,9 +12280,9 @@ function stateBadge(state) {
12277
12280
  return color.dim(state);
12278
12281
  }
12279
12282
  }
12280
- async function readConfig(path39) {
12283
+ async function readConfig(path40) {
12281
12284
  try {
12282
- return JSON.parse(await fsp5.readFile(path39, "utf8"));
12285
+ return JSON.parse(await fsp5.readFile(path40, "utf8"));
12283
12286
  } catch {
12284
12287
  return {};
12285
12288
  }
@@ -12287,11 +12290,11 @@ async function readConfig(path39) {
12287
12290
  function isMcpServerRecord(value) {
12288
12291
  return !!value && typeof value === "object" && !Array.isArray(value);
12289
12292
  }
12290
- async function writeConfig(path39, cfg) {
12293
+ async function writeConfig(path40, cfg) {
12291
12294
  const raw = JSON.stringify(cfg, null, 2);
12292
- const tmp = path39 + ".tmp";
12295
+ const tmp = path40 + ".tmp";
12293
12296
  await fsp5.writeFile(tmp, raw, "utf8");
12294
- await fsp5.rename(tmp, path39);
12297
+ await fsp5.rename(tmp, path40);
12295
12298
  }
12296
12299
 
12297
12300
  // src/slash-commands/mcp.ts
@@ -14590,7 +14593,7 @@ async function listProjectsCommand(opts, ctx) {
14590
14593
  return { message: lines.join("\n") };
14591
14594
  }
14592
14595
  async function addProjectCommand(opts, ctx, targetPath, displayName) {
14593
- const resolved = path38.resolve(ctx?.projectRoot ?? ctx?.cwd ?? process.cwd(), targetPath);
14596
+ const resolved = path39.resolve(ctx?.projectRoot ?? ctx?.cwd ?? process.cwd(), targetPath);
14594
14597
  try {
14595
14598
  await fsp5.access(resolved);
14596
14599
  } catch {
@@ -14607,7 +14610,7 @@ async function addProjectCommand(opts, ctx, targetPath, displayName) {
14607
14610
  message: color.yellow(`Project already registered: "${existing.name}" (${existing.slug})`)
14608
14611
  };
14609
14612
  }
14610
- const name = displayName?.trim() || path38.basename(resolved);
14613
+ const name = displayName?.trim() || path39.basename(resolved);
14611
14614
  const slug = generateSlug(resolved);
14612
14615
  const now = (/* @__PURE__ */ new Date()).toISOString();
14613
14616
  await ensureProjectDataDir(slug, opts.paths?.globalConfig);
@@ -14660,7 +14663,7 @@ async function removeProjectCommand(opts, _ctx, slugOrName) {
14660
14663
  };
14661
14664
  }
14662
14665
  async function switchProjectCommand(opts, ctx, target, displayName) {
14663
- const resolved = path38.resolve(ctx?.projectRoot ?? ctx?.cwd ?? process.cwd(), target);
14666
+ const resolved = path39.resolve(ctx?.projectRoot ?? ctx?.cwd ?? process.cwd(), target);
14664
14667
  try {
14665
14668
  await fsp5.access(resolved);
14666
14669
  } catch {
@@ -14674,8 +14677,8 @@ async function switchProjectCommand(opts, ctx, target, displayName) {
14674
14677
  try {
14675
14678
  const req2 = createRequire(import.meta.url);
14676
14679
  const pkgPath = req2.resolve("@wrongstack/cli/package.json");
14677
- const pkgDir = path38.dirname(pkgPath);
14678
- cliPath = path38.join(pkgDir, "dist", "index.js");
14680
+ const pkgDir = path39.dirname(pkgPath);
14681
+ cliPath = path39.join(pkgDir, "dist", "index.js");
14679
14682
  await fsp5.access(cliPath);
14680
14683
  } catch {
14681
14684
  cliPath = process.argv[1] ?? "";
@@ -14692,13 +14695,13 @@ async function switchProjectCommand(opts, ctx, target, displayName) {
14692
14695
  if (existing) {
14693
14696
  existing.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
14694
14697
  } else {
14695
- const name = displayName?.trim() || path38.basename(resolved);
14698
+ const name = displayName?.trim() || path39.basename(resolved);
14696
14699
  const slug = generateSlug(resolved);
14697
14700
  manifest.projects.push({ name, root: resolved, slug, lastSeen: (/* @__PURE__ */ new Date()).toISOString() });
14698
14701
  await ensureProjectDataDir(slug, opts.paths?.globalConfig);
14699
14702
  }
14700
14703
  await saveManifest(manifest, opts.paths?.globalConfig);
14701
- const targetName = displayName?.trim() || path38.basename(resolved);
14704
+ const targetName = displayName?.trim() || path39.basename(resolved);
14702
14705
  const canSwitch = await confirmProjectSwitch(opts, targetName);
14703
14706
  if (!canSwitch) return { message: "" };
14704
14707
  const nodeExe = process.execPath;
@@ -14814,8 +14817,8 @@ async function spawnInProject(opts, _ctx, root, projectName) {
14814
14817
  try {
14815
14818
  const req2 = createRequire(import.meta.url);
14816
14819
  const pkgPath = req2.resolve("@wrongstack/cli/package.json");
14817
- const pkgDir = path38.dirname(pkgPath);
14818
- cliPath = path38.join(pkgDir, "dist", "index.js");
14820
+ const pkgDir = path39.dirname(pkgPath);
14821
+ cliPath = path39.join(pkgDir, "dist", "index.js");
14819
14822
  await fsp5.access(cliPath);
14820
14823
  } catch {
14821
14824
  cliPath = process.argv[1] ?? "";
@@ -14832,7 +14835,7 @@ async function spawnInProject(opts, _ctx, root, projectName) {
14832
14835
  if (existing) {
14833
14836
  existing.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
14834
14837
  } else {
14835
- const name = projectName || path38.basename(root);
14838
+ const name = projectName || path39.basename(root);
14836
14839
  const slug = generateSlug(root);
14837
14840
  manifest.projects.push({ name, root, slug, lastSeen: (/* @__PURE__ */ new Date()).toISOString() });
14838
14841
  await ensureProjectDataDir(slug, opts.paths?.globalConfig);
@@ -14864,8 +14867,8 @@ async function handleNewSession(_opts, _ctx) {
14864
14867
  try {
14865
14868
  const req2 = createRequire(import.meta.url);
14866
14869
  const pkgPath = req2.resolve("@wrongstack/cli/package.json");
14867
- const pkgDir = path38.dirname(pkgPath);
14868
- cliPath = path38.join(pkgDir, "dist", "index.js");
14870
+ const pkgDir = path39.dirname(pkgPath);
14871
+ cliPath = path39.join(pkgDir, "dist", "index.js");
14869
14872
  await fsp5.access(cliPath);
14870
14873
  } catch {
14871
14874
  cliPath = process.argv[1] ?? "";
@@ -14923,7 +14926,7 @@ async function handlePrevSessions(opts, _ctx) {
14923
14926
  return { message: lines.join("\n") };
14924
14927
  }
14925
14928
  async function runGit(args, cwd) {
14926
- return new Promise((resolve10) => {
14929
+ return new Promise((resolve11) => {
14927
14930
  const child = spawn("git", args, {
14928
14931
  cwd,
14929
14932
  stdio: ["ignore", "pipe", "pipe"],
@@ -14934,8 +14937,8 @@ async function runGit(args, cwd) {
14934
14937
  child.stdout?.on("data", (d) => {
14935
14938
  stdout += d;
14936
14939
  });
14937
- child.on("error", () => resolve10({ stdout, code: 1 }));
14938
- child.on("close", (code) => resolve10({ stdout, code: code ?? 0 }));
14940
+ child.on("error", () => resolve11({ stdout, code: 1 }));
14941
+ child.on("close", (code) => resolve11({ stdout, code: code ?? 0 }));
14939
14942
  });
14940
14943
  }
14941
14944
  async function getChangedFiles(cwd) {
@@ -14976,7 +14979,7 @@ function buildReviewCommand(opts) {
14976
14979
  for (const f of allChanged) {
14977
14980
  if (f.path.startsWith(".wrongstack/")) continue;
14978
14981
  try {
14979
- await fsp5.access(path38.join(cwd, f.path));
14982
+ await fsp5.access(path39.join(cwd, f.path));
14980
14983
  existing.push(f);
14981
14984
  } catch {
14982
14985
  }
@@ -14987,7 +14990,7 @@ function buildReviewCommand(opts) {
14987
14990
  const filesWithContent = [];
14988
14991
  for (const f of existing.slice(0, 30)) {
14989
14992
  try {
14990
- const content = await fsp5.readFile(path38.join(cwd, f.path), "utf8");
14993
+ const content = await fsp5.readFile(path39.join(cwd, f.path), "utf8");
14991
14994
  filesWithContent.push({ ...f, content });
14992
14995
  } catch {
14993
14996
  }
@@ -15360,7 +15363,7 @@ var DEFAULTS = {
15360
15363
  working_dir: true
15361
15364
  };
15362
15365
  function resolveConfigPath() {
15363
- return process.env[CONFIG_ENV] ?? path38.join(process.env.HOME ?? "", ".wrongstack", "statusline.json");
15366
+ return process.env[CONFIG_ENV] ?? path39.join(process.env.HOME ?? "", ".wrongstack", "statusline.json");
15364
15367
  }
15365
15368
  async function loadStatuslineConfig() {
15366
15369
  const p = resolveConfigPath();
@@ -15374,7 +15377,7 @@ async function loadStatuslineConfig() {
15374
15377
  async function saveStatuslineConfig(cfg) {
15375
15378
  const p = resolveConfigPath();
15376
15379
  try {
15377
- await fsp5.mkdir(path38.dirname(p), { recursive: true });
15380
+ await fsp5.mkdir(path39.dirname(p), { recursive: true });
15378
15381
  await atomicWrite(p, JSON.stringify(cfg, null, 2));
15379
15382
  } catch (err) {
15380
15383
  throw new FsError({
@@ -15786,13 +15789,13 @@ ${formatTaskProgress(file.tasks)}`;
15786
15789
  }
15787
15790
  async function discoverPackageFiles(projectRoot) {
15788
15791
  const files = [];
15789
- const rootPkg = path38.join(projectRoot, "package.json");
15792
+ const rootPkg = path39.join(projectRoot, "package.json");
15790
15793
  try {
15791
15794
  await fsp5.access(rootPkg);
15792
15795
  files.push(rootPkg);
15793
15796
  } catch {
15794
15797
  }
15795
- const workspaceFile = path38.join(projectRoot, "pnpm-workspace.yaml");
15798
+ const workspaceFile = path39.join(projectRoot, "pnpm-workspace.yaml");
15796
15799
  try {
15797
15800
  await fsp5.access(workspaceFile);
15798
15801
  const content = await fsp5.readFile(workspaceFile, "utf8");
@@ -15802,12 +15805,12 @@ async function discoverPackageFiles(projectRoot) {
15802
15805
  const globs = rawGlobs.split(/[\s,]+/).filter(Boolean).map((g) => g.replace(/['"]/g, ""));
15803
15806
  for (const g of globs) {
15804
15807
  const dirPrefix = g.replace(/\/?\*$/, "").replace(/\/\*$/, "");
15805
- const dir = path38.join(projectRoot, dirPrefix);
15808
+ const dir = path39.join(projectRoot, dirPrefix);
15806
15809
  try {
15807
15810
  const entries = await fsp5.readdir(dir, { withFileTypes: true });
15808
15811
  for (const e of entries) {
15809
15812
  if (!e.isDirectory()) continue;
15810
- const subPkg = path38.join(dir, e.name, "package.json");
15813
+ const subPkg = path39.join(dir, e.name, "package.json");
15811
15814
  try {
15812
15815
  await fsp5.access(subPkg);
15813
15816
  files.push(subPkg);
@@ -15822,7 +15825,7 @@ async function discoverPackageFiles(projectRoot) {
15822
15825
  return files;
15823
15826
  }
15824
15827
  function buildTechStackTask(opts) {
15825
- const pkgList = opts.packageFiles.map((f) => ` - ${path38.relative(opts.projectRoot, f)}`).join("\n");
15828
+ const pkgList = opts.packageFiles.map((f) => ` - ${path39.relative(opts.projectRoot, f)}`).join("\n");
15826
15829
  const header = opts.isInit ? [
15827
15830
  "## Tech Stack Audit \u2014 First-Time Project Init",
15828
15831
  "",
@@ -16250,7 +16253,7 @@ function buildWorkingDirCommand(_opts) {
16250
16253
  }
16251
16254
  const trimmed = args.trim();
16252
16255
  if (!trimmed) {
16253
- const rel2 = path38.relative(ctx.projectRoot, ctx.workingDir) || ".";
16256
+ const rel2 = path39.relative(ctx.projectRoot, ctx.workingDir) || ".";
16254
16257
  return {
16255
16258
  message: [
16256
16259
  `Working directory: ${color.bold(ctx.workingDir)}`,
@@ -16259,10 +16262,10 @@ function buildWorkingDirCommand(_opts) {
16259
16262
  ].join("\n")
16260
16263
  };
16261
16264
  }
16262
- const resolved = path38.isAbsolute(trimmed) ? path38.resolve(trimmed) : path38.resolve(ctx.projectRoot, trimmed);
16263
- const root = path38.resolve(ctx.projectRoot);
16264
- const rel = path38.relative(root, resolved);
16265
- if (rel.startsWith("..") || path38.isAbsolute(rel)) {
16265
+ const resolved = path39.isAbsolute(trimmed) ? path39.resolve(trimmed) : path39.resolve(ctx.projectRoot, trimmed);
16266
+ const root = path39.resolve(ctx.projectRoot);
16267
+ const rel = path39.relative(root, resolved);
16268
+ if (rel.startsWith("..") || path39.isAbsolute(rel)) {
16266
16269
  return {
16267
16270
  message: color.red(
16268
16271
  `Directory "${trimmed}" is outside the project root.
@@ -16287,8 +16290,8 @@ function buildWorkingDirCommand(_opts) {
16287
16290
  message: color.red(err instanceof Error ? err.message : String(err))
16288
16291
  };
16289
16292
  }
16290
- const prevRel = path38.relative(ctx.projectRoot, previous) || ".";
16291
- const newRel = path38.relative(ctx.projectRoot, resolved) || ".";
16293
+ const prevRel = path39.relative(ctx.projectRoot, previous) || ".";
16294
+ const newRel = path39.relative(ctx.projectRoot, resolved) || ".";
16292
16295
  return {
16293
16296
  message: [
16294
16297
  color.green(` \u2713 ${prevRel} \u2192 ${color.bold(newRel)}`),
@@ -16488,13 +16491,13 @@ var MANIFESTS = [
16488
16491
  ];
16489
16492
  async function detectProjectKind(projectRoot) {
16490
16493
  try {
16491
- await fsp5.access(path38.join(projectRoot, ".wrongstack", "AGENTS.md"));
16494
+ await fsp5.access(path39.join(projectRoot, ".wrongstack", "AGENTS.md"));
16492
16495
  return "initialized";
16493
16496
  } catch {
16494
16497
  }
16495
16498
  for (const m of MANIFESTS) {
16496
16499
  try {
16497
- await fsp5.access(path38.join(projectRoot, m));
16500
+ await fsp5.access(path39.join(projectRoot, m));
16498
16501
  return "project";
16499
16502
  } catch {
16500
16503
  }
@@ -16502,8 +16505,8 @@ async function detectProjectKind(projectRoot) {
16502
16505
  return "empty";
16503
16506
  }
16504
16507
  async function scaffoldAgentsMd(projectRoot) {
16505
- const dir = path38.join(projectRoot, ".wrongstack");
16506
- const file = path38.join(dir, "AGENTS.md");
16508
+ const dir = path39.join(projectRoot, ".wrongstack");
16509
+ const file = path39.join(dir, "AGENTS.md");
16507
16510
  const facts = await detectProjectFacts(projectRoot);
16508
16511
  const body = renderAgentsTemplate(facts);
16509
16512
  await fsp5.mkdir(dir, { recursive: true });
@@ -16516,7 +16519,7 @@ async function runProjectCheck(opts) {
16516
16519
  if (kind === "initialized") {
16517
16520
  renderer.write(
16518
16521
  `
16519
- ${color.green("\u2713")} Project initialized ${color.dim(`(${path38.join(projectRoot, ".wrongstack", "AGENTS.md")})`)}
16522
+ ${color.green("\u2713")} Project initialized ${color.dim(`(${path39.join(projectRoot, ".wrongstack", "AGENTS.md")})`)}
16520
16523
  `
16521
16524
  );
16522
16525
  return true;
@@ -16547,7 +16550,7 @@ async function runProjectCheck(opts) {
16547
16550
  }
16548
16551
  return true;
16549
16552
  }
16550
- const gitDir = path38.join(projectRoot, ".git");
16553
+ const gitDir = path39.join(projectRoot, ".git");
16551
16554
  let hasGit = false;
16552
16555
  try {
16553
16556
  await fsp5.access(gitDir);
@@ -16570,7 +16573,7 @@ async function runProjectCheck(opts) {
16570
16573
  if (answer2 === "y" || answer2 === "yes") {
16571
16574
  try {
16572
16575
  const { spawn: spawn6 } = await import('child_process');
16573
- await new Promise((resolve10, reject) => {
16576
+ await new Promise((resolve11, reject) => {
16574
16577
  const child = spawn6("git", ["init"], {
16575
16578
  cwd,
16576
16579
  signal: AbortSignal.timeout(1e4),
@@ -16579,7 +16582,7 @@ async function runProjectCheck(opts) {
16579
16582
  child.on("error", reject);
16580
16583
  child.on(
16581
16584
  "close",
16582
- (code) => code === 0 ? resolve10() : reject(new Error(`git init failed with ${code}`))
16585
+ (code) => code === 0 ? resolve11() : reject(new Error(`git init failed with ${code}`))
16583
16586
  );
16584
16587
  });
16585
16588
  renderer.write(` ${color.green("\u2713")} Git repository initialized
@@ -16782,11 +16785,11 @@ async function countProjectFiles(projectRoot, threshold) {
16782
16785
  for (const e of entries) {
16783
16786
  if (SKIP_DIRS.has(e.name)) continue;
16784
16787
  if (count >= threshold) return;
16785
- const full = path38.join(dir, e.name);
16788
+ const full = path39.join(dir, e.name);
16786
16789
  if (e.isDirectory()) {
16787
16790
  await walk(full);
16788
16791
  } else if (e.isFile()) {
16789
- if (INDEXABLE_EXTS.has(path38.extname(e.name))) {
16792
+ if (INDEXABLE_EXTS.has(path39.extname(e.name))) {
16790
16793
  count++;
16791
16794
  }
16792
16795
  }
@@ -17127,14 +17130,14 @@ function summarize(value, name) {
17127
17130
  if (typeof v === "object" && v !== null) {
17128
17131
  const o = v;
17129
17132
  if (name === "edit") {
17130
- const path39 = typeof o["path"] === "string" ? o["path"] : "";
17133
+ const path40 = typeof o["path"] === "string" ? o["path"] : "";
17131
17134
  const reps = typeof o["replacements"] === "number" ? o["replacements"] : 0;
17132
- return `${path39} ${reps} replacement${reps === 1 ? "" : "s"}`.trim();
17135
+ return `${path40} ${reps} replacement${reps === 1 ? "" : "s"}`.trim();
17133
17136
  }
17134
17137
  if (name === "write") {
17135
- const path39 = typeof o["path"] === "string" ? o["path"] : "";
17138
+ const path40 = typeof o["path"] === "string" ? o["path"] : "";
17136
17139
  const bytes = typeof o["bytes"] === "number" ? o["bytes"] : void 0;
17137
- return bytes !== void 0 ? `${path39} ${bytes}B` : path39;
17140
+ return bytes !== void 0 ? `${path40} ${bytes}B` : path40;
17138
17141
  }
17139
17142
  if (typeof o["count"] === "number") {
17140
17143
  return `${o["count"]} match${o["count"] === 1 ? "" : "es"}`;
@@ -17351,14 +17354,14 @@ var auditCmd = async (args, deps) => {
17351
17354
  return verify.ok ? 0 : 1;
17352
17355
  };
17353
17356
  async function listAudits(log, dir, deps) {
17354
- const fs38 = await import('fs/promises');
17355
- const path39 = await import('path');
17357
+ const fs39 = await import('fs/promises');
17358
+ const path40 = await import('path');
17356
17359
  const out = [];
17357
17360
  let foundRoot = true;
17358
17361
  const scan = async (scanDir, prefix, depth) => {
17359
17362
  let entries;
17360
17363
  try {
17361
- entries = await fs38.readdir(scanDir, { withFileTypes: true });
17364
+ entries = await fs39.readdir(scanDir, { withFileTypes: true });
17362
17365
  } catch {
17363
17366
  if (depth === 0) foundRoot = false;
17364
17367
  return;
@@ -17366,7 +17369,7 @@ async function listAudits(log, dir, deps) {
17366
17369
  for (const entry of entries) {
17367
17370
  if (entry.name.startsWith(".")) continue;
17368
17371
  if (entry.isDirectory()) {
17369
- if (depth === 0) await scan(path39.join(scanDir, entry.name), entry.name, depth + 1);
17372
+ if (depth === 0) await scan(path40.join(scanDir, entry.name), entry.name, depth + 1);
17370
17373
  continue;
17371
17374
  }
17372
17375
  if (!entry.isFile() || !entry.name.endsWith(".audit.jsonl")) continue;
@@ -18285,7 +18288,200 @@ try {
18285
18288
  } catch {
18286
18289
  }
18287
18290
 
18288
- // src/subcommands/handlers/diag-doctor.ts
18291
+ // src/subcommands/handlers/bench.ts
18292
+ var benchCmd = async (args, deps) => {
18293
+ const sub = args[0];
18294
+ const rest = args.slice(1);
18295
+ switch (sub) {
18296
+ case "run":
18297
+ return benchRun(rest, deps);
18298
+ case "report":
18299
+ return benchReport(rest, deps);
18300
+ case "list":
18301
+ return benchList(rest, deps);
18302
+ default:
18303
+ printUsage(deps);
18304
+ return sub === void 0 ? 0 : 1;
18305
+ }
18306
+ };
18307
+ function printUsage(deps) {
18308
+ deps.renderer.write(
18309
+ [
18310
+ color.bold("wstack bench") + " \u2014 model-independent agentic benchmarks",
18311
+ "",
18312
+ " run Run a suite across a model matrix and write a report",
18313
+ " report Re-render report.md from a finished run directory",
18314
+ " list Show available suites and configured model cells",
18315
+ "",
18316
+ color.dim("Examples:"),
18317
+ color.dim(
18318
+ " wstack bench run --suite polyglot --polyglot-dir ./polyglot --models bench.config.json --limit 5"
18319
+ ),
18320
+ color.dim(" wstack bench report ./bench-results/2026-06-14T10-00-00"),
18321
+ ""
18322
+ ].join("\n") + "\n"
18323
+ );
18324
+ }
18325
+ function flagStr(deps, name) {
18326
+ const v = deps.flags?.[name];
18327
+ return typeof v === "string" ? v : void 0;
18328
+ }
18329
+ function flagBool(deps, name) {
18330
+ const v = deps.flags?.[name];
18331
+ return v === true || v === "true";
18332
+ }
18333
+ async function resolveWstackEntry() {
18334
+ try {
18335
+ const req2 = createRequire(import.meta.url);
18336
+ const pkgPath = req2.resolve("@wrongstack/cli/package.json");
18337
+ const entry = path39.join(path39.dirname(pkgPath), "dist", "index.js");
18338
+ await fsp5.access(entry);
18339
+ return entry;
18340
+ } catch {
18341
+ return process.argv[1] ?? "";
18342
+ }
18343
+ }
18344
+ async function benchRun(_args, deps) {
18345
+ const suiteId = flagStr(deps, "suite") ?? "polyglot";
18346
+ const modelsPath = flagStr(deps, "models") ?? "bench.config.json";
18347
+ const limitRaw = flagStr(deps, "limit");
18348
+ const limit = limitRaw ? Math.max(1, Number.parseInt(limitRaw, 10)) : void 0;
18349
+ const outBase = flagStr(deps, "out") ?? "bench-results";
18350
+ let config;
18351
+ try {
18352
+ config = await loadBenchConfig(path39.resolve(deps.cwd, modelsPath));
18353
+ } catch (err) {
18354
+ deps.renderer.writeError(err instanceof Error ? err.message : String(err));
18355
+ return 1;
18356
+ }
18357
+ const concurrencyRaw = flagStr(deps, "concurrency");
18358
+ if (concurrencyRaw) {
18359
+ const c = Number.parseInt(concurrencyRaw, 10);
18360
+ if (c > 0) config.concurrency = c;
18361
+ }
18362
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
18363
+ const outDir = path39.resolve(deps.cwd, outBase, stamp);
18364
+ const predictionsDir = path39.join(outDir, "predictions");
18365
+ let suite;
18366
+ let grade;
18367
+ let isSwebench = false;
18368
+ if (suiteId === "polyglot") {
18369
+ const polyglotDir = flagStr(deps, "polyglot-dir");
18370
+ if (!polyglotDir) {
18371
+ deps.renderer.writeError("--polyglot-dir <path> is required for the polyglot suite.");
18372
+ return 1;
18373
+ }
18374
+ const languagesRaw = flagStr(deps, "languages");
18375
+ const languages = languagesRaw ? languagesRaw.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
18376
+ suite = createPolyglotSuite({ polyglotDir: path39.resolve(deps.cwd, polyglotDir), languages });
18377
+ grade = (a) => gradePolyglot(a);
18378
+ } else if (suiteId === "swebench") {
18379
+ isSwebench = true;
18380
+ const datasetDir = flagStr(deps, "dataset-dir");
18381
+ const docker = flagBool(deps, "docker");
18382
+ suite = createSwebenchSuite({
18383
+ datasetDir: datasetDir ? path39.resolve(deps.cwd, datasetDir) : void 0,
18384
+ docker
18385
+ });
18386
+ grade = (a) => gradeSwebench({ ...a, predictionsDir });
18387
+ } else {
18388
+ deps.renderer.writeError(`unknown suite "${suiteId}" (expected: polyglot | swebench)`);
18389
+ return 1;
18390
+ }
18391
+ const toolNames = deps.toolRegistry?.list().map((t) => t.name) ?? [];
18392
+ const wstackEntry = await resolveWstackEntry();
18393
+ deps.renderer.writeInfo(`Running ${suiteId} across ${config.cells.length} model(s)\u2026`);
18394
+ let report;
18395
+ try {
18396
+ report = await runBenchmark({
18397
+ suite,
18398
+ grade,
18399
+ config,
18400
+ cliVersion: CLI_VERSION,
18401
+ toolNames,
18402
+ nodeBin: process.execPath,
18403
+ wstackEntry,
18404
+ limit,
18405
+ onProgress: (msg) => deps.renderer.write(color.dim(msg) + "\n")
18406
+ });
18407
+ } catch (err) {
18408
+ deps.renderer.writeError(err instanceof Error ? err.message : String(err));
18409
+ return 1;
18410
+ }
18411
+ await writeJsonArtifacts(outDir, report);
18412
+ const md = renderMarkdownReport(report);
18413
+ await fsp5.writeFile(path39.join(outDir, "report.md"), md, "utf8");
18414
+ deps.renderer.write("\n" + md + "\n");
18415
+ if (isSwebench) {
18416
+ for (const cell of config.cells) {
18417
+ const preds = await collectCellPredictions(predictionsDir, cell.label);
18418
+ if (preds.length === 0) continue;
18419
+ const file = await writePredictionsJsonl(outDir, cell.label, preds);
18420
+ deps.renderer.writeInfo(`Predictions for "${cell.label}" \u2192 ${file}`);
18421
+ }
18422
+ deps.renderer.writeInfo(
18423
+ "Grade with the official SWE-bench harness: python -m swebench.harness.run_evaluation --predictions_path <file> --run_id <id>"
18424
+ );
18425
+ }
18426
+ deps.renderer.writeInfo(`Report written to ${path39.join(outDir, "report.md")}`);
18427
+ return 0;
18428
+ }
18429
+ async function benchReport(args, deps) {
18430
+ const dir = args.find((a) => !a.startsWith("-"));
18431
+ if (!dir) {
18432
+ deps.renderer.writeError("Usage: wstack bench report <run-directory>");
18433
+ return 1;
18434
+ }
18435
+ const outDir = path39.resolve(deps.cwd, dir);
18436
+ let summary;
18437
+ try {
18438
+ summary = await readSummary(outDir);
18439
+ } catch (err) {
18440
+ deps.renderer.writeError(
18441
+ `cannot read summary.json in ${outDir}: ${err instanceof Error ? err.message : String(err)}`
18442
+ );
18443
+ return 1;
18444
+ }
18445
+ const md = renderMarkdownReport(summary);
18446
+ await fsp5.writeFile(path39.join(outDir, "report.md"), md, "utf8");
18447
+ deps.renderer.write("\n" + md + "\n");
18448
+ return 0;
18449
+ }
18450
+ async function benchList(_args, deps) {
18451
+ deps.renderer.write(color.bold("Suites\n"));
18452
+ deps.renderer.write(
18453
+ " polyglot " + color.dim("Aider polyglot (edit accuracy) \u2014 Phase 1, Docker-free\n")
18454
+ );
18455
+ deps.renderer.write(
18456
+ " swebench " + color.dim("SWE-bench Verified (end-to-end) \u2014 Phase 2, Docker-gated\n")
18457
+ );
18458
+ const modelsPath = flagStr(deps, "models");
18459
+ if (modelsPath) {
18460
+ try {
18461
+ const config = await loadBenchConfig(path39.resolve(deps.cwd, modelsPath));
18462
+ deps.renderer.write("\n" + color.bold("Model cells\n"));
18463
+ for (const cell of config.cells) {
18464
+ deps.renderer.write(
18465
+ ` ${cell.label.padEnd(16)} ${color.dim(`${cell.provider}/${cell.model}`)}
18466
+ `
18467
+ );
18468
+ }
18469
+ const fp = reportHeaderLine({
18470
+ cliVersion: CLI_VERSION,
18471
+ toolNames: deps.toolRegistry?.list().map((t) => t.name) ?? [],
18472
+ maxIterations: config.maxIterations,
18473
+ yolo: true,
18474
+ subsetId: "(computed at run time)",
18475
+ hash: "(computed at run time)"
18476
+ });
18477
+ deps.renderer.write("\n" + color.dim(`Harness: ${fp}`) + "\n");
18478
+ } catch (err) {
18479
+ deps.renderer.writeError(err instanceof Error ? err.message : String(err));
18480
+ return 1;
18481
+ }
18482
+ }
18483
+ return 0;
18484
+ }
18289
18485
  var diagCmd = async (_args, deps) => {
18290
18486
  const cfg = deps.config;
18291
18487
  const age = await deps.modelsRegistry.ageSeconds();
@@ -18379,7 +18575,7 @@ var doctorCmd = async (_args, deps) => {
18379
18575
  }
18380
18576
  try {
18381
18577
  await fsp5.mkdir(deps.paths.projectSessions, { recursive: true });
18382
- const probe = path38.join(deps.paths.projectSessions, `.probe-${Date.now()}`);
18578
+ const probe = path39.join(deps.paths.projectSessions, `.probe-${Date.now()}`);
18383
18579
  await fsp5.writeFile(probe, "");
18384
18580
  await fsp5.unlink(probe);
18385
18581
  checks.push({ name: "sessions writable", status: "ok", detail: deps.paths.projectSessions });
@@ -18482,8 +18678,8 @@ var exportCmd = async (args, deps) => {
18482
18678
  return 1;
18483
18679
  }
18484
18680
  if (output) {
18485
- await fsp5.mkdir(path38.dirname(path38.resolve(deps.cwd, output)), { recursive: true });
18486
- await fsp5.writeFile(path38.resolve(deps.cwd, output), rendered, "utf8");
18681
+ await fsp5.mkdir(path39.dirname(path39.resolve(deps.cwd, output)), { recursive: true });
18682
+ await fsp5.writeFile(path39.resolve(deps.cwd, output), rendered, "utf8");
18487
18683
  deps.renderer.write(`Wrote ${rendered.length} bytes to ${output}
18488
18684
  `);
18489
18685
  } else {
@@ -18559,8 +18755,8 @@ var initCmd = async (_args, deps) => {
18559
18755
  const vault = new DefaultSecretVault({ keyFile: deps.paths.secretsKey });
18560
18756
  const encrypted = encryptConfigSecrets$1(config, vault);
18561
18757
  await atomicWrite(deps.paths.globalConfig, JSON.stringify(encrypted, null, 2), { mode: 384 });
18562
- await fsp5.mkdir(path38.join(deps.projectRoot, ".wrongstack"), { recursive: true });
18563
- const agentsFile = path38.join(deps.projectRoot, ".wrongstack", "AGENTS.md");
18758
+ await fsp5.mkdir(path39.join(deps.projectRoot, ".wrongstack"), { recursive: true });
18759
+ const agentsFile = path39.join(deps.projectRoot, ".wrongstack", "AGENTS.md");
18564
18760
  const projectFacts = await detectProjectFacts(deps.projectRoot);
18565
18761
  await atomicWrite(agentsFile, renderAgentsTemplate(projectFacts));
18566
18762
  deps.renderer.writeInfo(`Wrote ${deps.paths.globalConfig}`);
@@ -18699,8 +18895,8 @@ async function serveMcpStdio(deps) {
18699
18895
  log(
18700
18896
  `wrongstack MCP server ready at ${handle2.url} \u2014 exposing ${allowed.length} tool(s) (${mode})${token ? " [token auth]" : ""}.`
18701
18897
  );
18702
- await new Promise((resolve10) => {
18703
- const stop = () => resolve10();
18898
+ await new Promise((resolve11) => {
18899
+ const stop = () => resolve11();
18704
18900
  process.once("SIGINT", stop);
18705
18901
  process.once("SIGTERM", stop);
18706
18902
  });
@@ -19923,7 +20119,7 @@ var usageCmd = async (_args, deps) => {
19923
20119
  return 0;
19924
20120
  };
19925
20121
  var projectsCmd = async (_args, deps) => {
19926
- const projectsRoot = path38.join(deps.paths.globalRoot, "projects");
20122
+ const projectsRoot = path39.join(deps.paths.globalRoot, "projects");
19927
20123
  try {
19928
20124
  const entries = await fsp5.readdir(projectsRoot);
19929
20125
  if (entries.length === 0) {
@@ -19933,7 +20129,7 @@ var projectsCmd = async (_args, deps) => {
19933
20129
  for (const hash of entries) {
19934
20130
  try {
19935
20131
  const meta = JSON.parse(
19936
- await fsp5.readFile(path38.join(projectsRoot, hash, "meta.json"), "utf8")
20132
+ await fsp5.readFile(path39.join(projectsRoot, hash, "meta.json"), "utf8")
19937
20133
  );
19938
20134
  deps.renderer.write(
19939
20135
  ` ${color.dim(hash)} ${color.dim(meta.lastSeen ?? "")} ${meta.root ?? "?"}
@@ -20382,7 +20578,7 @@ function findSessionId(args) {
20382
20578
  var rewindCmd = async (args, deps) => {
20383
20579
  const flags = parseRewindFlags(args);
20384
20580
  const wpaths = resolveWstackPaths({ projectRoot: deps.projectRoot });
20385
- const sessionsDir = path38.join(wpaths.globalRoot, "sessions");
20581
+ const sessionsDir = path39.join(wpaths.globalRoot, "sessions");
20386
20582
  const rewind = new DefaultSessionRewinder(sessionsDir, deps.projectRoot);
20387
20583
  let sessionId = findSessionId(args);
20388
20584
  if (!sessionId) {
@@ -20527,7 +20723,7 @@ async function listFleetRuns(deps) {
20527
20723
  }
20528
20724
  const runs = [];
20529
20725
  for (const id of entries) {
20530
- const runDir = path38.join(deps.paths.projectSessions, id);
20726
+ const runDir = path39.join(deps.paths.projectSessions, id);
20531
20727
  let stat7;
20532
20728
  try {
20533
20729
  stat7 = await fsp5.stat(runDir);
@@ -20540,17 +20736,17 @@ async function listFleetRuns(deps) {
20540
20736
  let subagentCount = 0;
20541
20737
  let subagentsDir;
20542
20738
  try {
20543
- await fsp5.access(path38.join(runDir, "fleet.json"));
20739
+ await fsp5.access(path39.join(runDir, "fleet.json"));
20544
20740
  manifest = true;
20545
20741
  } catch {
20546
20742
  }
20547
20743
  try {
20548
- await fsp5.access(path38.join(runDir, "checkpoint.json"));
20744
+ await fsp5.access(path39.join(runDir, "checkpoint.json"));
20549
20745
  checkpoint = true;
20550
20746
  } catch {
20551
20747
  }
20552
20748
  try {
20553
- subagentsDir = path38.join(runDir, "subagents");
20749
+ subagentsDir = path39.join(runDir, "subagents");
20554
20750
  const files = await fsp5.readdir(subagentsDir);
20555
20751
  subagentCount = files.filter((f) => f.endsWith(".jsonl")).length;
20556
20752
  } catch {
@@ -20577,7 +20773,7 @@ async function listFleetRuns(deps) {
20577
20773
  return 0;
20578
20774
  }
20579
20775
  async function showFleetRun(runId, deps) {
20580
- const runDir = path38.join(deps.paths.projectSessions, runId);
20776
+ const runDir = path39.join(deps.paths.projectSessions, runId);
20581
20777
  let stat7;
20582
20778
  try {
20583
20779
  stat7 = await fsp5.stat(runDir);
@@ -20594,7 +20790,7 @@ async function showFleetRun(runId, deps) {
20594
20790
  deps.renderer.write(color.bold(`
20595
20791
  Fleet Run: ${runId}
20596
20792
  `) + "\n");
20597
- const manifestPath = path38.join(runDir, "fleet.json");
20793
+ const manifestPath = path39.join(runDir, "fleet.json");
20598
20794
  let manifestData = null;
20599
20795
  try {
20600
20796
  manifestData = await fsp5.readFile(manifestPath, "utf8");
@@ -20612,7 +20808,7 @@ Fleet Run: ${runId}
20612
20808
  deps.renderer.write(` ${color.dim("\u25CB")} fleet.json \u2014 not found
20613
20809
  `);
20614
20810
  }
20615
- const checkpointPath = path38.join(runDir, "checkpoint.json");
20811
+ const checkpointPath = path39.join(runDir, "checkpoint.json");
20616
20812
  let checkpointData = null;
20617
20813
  try {
20618
20814
  checkpointData = await fsp5.readFile(checkpointPath, "utf8");
@@ -20659,7 +20855,7 @@ Fleet Run: ${runId}
20659
20855
  } catch {
20660
20856
  }
20661
20857
  }
20662
- const subagentsDir = path38.join(runDir, "subagents");
20858
+ const subagentsDir = path39.join(runDir, "subagents");
20663
20859
  let subagentFiles = [];
20664
20860
  try {
20665
20861
  subagentFiles = await fsp5.readdir(subagentsDir);
@@ -20671,7 +20867,7 @@ Fleet Run: ${runId}
20671
20867
  Subagent transcripts (${subagentFiles.length}):
20672
20868
  `);
20673
20869
  for (const f of subagentFiles.sort()) {
20674
- const filePath = path38.join(subagentsDir, f);
20870
+ const filePath = path39.join(subagentsDir, f);
20675
20871
  let size;
20676
20872
  try {
20677
20873
  const s = await fsp5.stat(filePath);
@@ -20688,7 +20884,7 @@ Fleet Run: ${runId}
20688
20884
  ${color.dim("\u25CB")} No subagent transcripts
20689
20885
  `);
20690
20886
  }
20691
- const sharedDir = path38.join(runDir, "shared");
20887
+ const sharedDir = path39.join(runDir, "shared");
20692
20888
  try {
20693
20889
  const files = await fsp5.readdir(sharedDir);
20694
20890
  deps.renderer.write(`
@@ -20872,7 +21068,7 @@ var updateCmd = async (args, deps) => {
20872
21068
  deps.renderer.write(`Updating wrongstack from v${info.current} to v${info.latest}...
20873
21069
  `);
20874
21070
  try {
20875
- const result = await new Promise((resolve10, reject) => {
21071
+ const result = await new Promise((resolve11, reject) => {
20876
21072
  const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
20877
21073
  const child = spawn(npmCommand, ["install", "-g", "wrongstack@latest"], {
20878
21074
  cwd,
@@ -20885,7 +21081,7 @@ var updateCmd = async (args, deps) => {
20885
21081
  _stderr += d;
20886
21082
  });
20887
21083
  child.on("error", reject);
20888
- child.on("close", (code) => resolve10({ code: code ?? 0 }));
21084
+ child.on("close", (code) => resolve11({ code: code ?? 0 }));
20889
21085
  });
20890
21086
  if (result.code === 0) {
20891
21087
  deps.renderer.write(
@@ -20996,7 +21192,8 @@ var subcommands = {
20996
21192
  help: helpCmd,
20997
21193
  projects: projectsCmd,
20998
21194
  modeldiag: modeldiagCmd,
20999
- quick: quickCmd
21195
+ quick: quickCmd,
21196
+ bench: benchCmd
21000
21197
  };
21001
21198
 
21002
21199
  // src/boot.ts
@@ -21014,7 +21211,7 @@ function resolveBundledSkillsDir() {
21014
21211
  try {
21015
21212
  const req2 = createRequire(import.meta.url);
21016
21213
  const corePkg = req2.resolve("@wrongstack/core/package.json");
21017
- return path38.join(path38.dirname(corePkg), "skills");
21214
+ return path39.join(path39.dirname(corePkg), "skills");
21018
21215
  } catch {
21019
21216
  return void 0;
21020
21217
  }
@@ -21235,7 +21432,7 @@ async function boot(argv) {
21235
21432
  const created = await registerProjectAtBoot({ projectRoot, cwd, wpaths });
21236
21433
  if (created && isInteractiveTTY) {
21237
21434
  renderer.write(
21238
- color.dim(` \u2713 Registered "${path38.basename(projectRoot)}" in projects.json.
21435
+ color.dim(` \u2713 Registered "${path39.basename(projectRoot)}" in projects.json.
21239
21436
  `)
21240
21437
  );
21241
21438
  }
@@ -21315,7 +21512,7 @@ async function boot(argv) {
21315
21512
  } catch {
21316
21513
  }
21317
21514
  printLaunchHints(renderer, flags, {
21318
- cursorFile: path38.join(wpaths.cacheDir, "hint-cursor")
21515
+ cursorFile: path39.join(wpaths.cacheDir, "hint-cursor")
21319
21516
  });
21320
21517
  } else {
21321
21518
  const effectiveChoices = config.launch ? {
@@ -21353,7 +21550,7 @@ async function boot(argv) {
21353
21550
  }
21354
21551
  async function checkGitInCwd(opts) {
21355
21552
  const { cwd, renderer, reader } = opts;
21356
- const cwdGit = path38.join(cwd, ".git");
21553
+ const cwdGit = path39.join(cwd, ".git");
21357
21554
  let hasCwdGit = false;
21358
21555
  try {
21359
21556
  await fsp5.access(cwdGit);
@@ -21370,7 +21567,7 @@ async function checkGitInCwd(opts) {
21370
21567
  if (answer === "y" || answer === "yes") {
21371
21568
  try {
21372
21569
  const { spawn: spawn6 } = await import('child_process');
21373
- await new Promise((resolve10, reject) => {
21570
+ await new Promise((resolve11, reject) => {
21374
21571
  const child = spawn6("git", ["init"], {
21375
21572
  cwd,
21376
21573
  signal: AbortSignal.timeout(1e4),
@@ -21379,7 +21576,7 @@ async function checkGitInCwd(opts) {
21379
21576
  child.on("error", reject);
21380
21577
  child.on(
21381
21578
  "close",
21382
- (code) => code === 0 ? resolve10() : reject(new Error(`git init failed with ${code}`))
21579
+ (code) => code === 0 ? resolve11() : reject(new Error(`git init failed with ${code}`))
21383
21580
  );
21384
21581
  });
21385
21582
  renderer.write(` ${color.green("\u2713")} Git repository initialized
@@ -21393,10 +21590,10 @@ async function checkGitInCwd(opts) {
21393
21590
  }
21394
21591
  }
21395
21592
  }
21396
- const parentDir = path38.dirname(cwd);
21593
+ const parentDir = path39.dirname(cwd);
21397
21594
  if (parentDir !== cwd) {
21398
21595
  try {
21399
- await fsp5.access(path38.join(parentDir, ".git"));
21596
+ await fsp5.access(path39.join(parentDir, ".git"));
21400
21597
  renderer.write(
21401
21598
  ` ${color.dim("\u2139")} A ${color.bold(".git")} repo exists in the parent directory: ${color.dim(parentDir)}
21402
21599
  `
@@ -21408,7 +21605,7 @@ async function checkGitInCwd(opts) {
21408
21605
  async function registerProjectAtBoot(opts) {
21409
21606
  const { projectRoot, cwd, wpaths } = opts;
21410
21607
  const manifest = await loadManifest(wpaths.globalConfig);
21411
- const existed = manifest.projects.some((p) => path38.resolve(p.root) === path38.resolve(projectRoot));
21608
+ const existed = manifest.projects.some((p) => path39.resolve(p.root) === path39.resolve(projectRoot));
21412
21609
  await touchProjectInManifest({
21413
21610
  projectRoot,
21414
21611
  globalConfigPath: wpaths.globalConfig,
@@ -21609,7 +21806,7 @@ function resolveBundledSkillsDir2() {
21609
21806
  try {
21610
21807
  const req2 = createRequire(import.meta.url);
21611
21808
  const corePkg = req2.resolve("@wrongstack/core/package.json");
21612
- return path38.join(path38.dirname(corePkg), "skills");
21809
+ return path39.join(path39.dirname(corePkg), "skills");
21613
21810
  } catch {
21614
21811
  return void 0;
21615
21812
  }
@@ -22097,7 +22294,7 @@ async function runRepl(opts) {
22097
22294
  clientMailbox.registerClient({
22098
22295
  clientId,
22099
22296
  sessionId: replProjectRoot,
22100
- name: `REPL [${path38.basename(replProjectRoot)}]`,
22297
+ name: `REPL [${path39.basename(replProjectRoot)}]`,
22101
22298
  source: "repl",
22102
22299
  pid: process.pid
22103
22300
  }).then(() => {
@@ -22165,7 +22362,7 @@ async function runRepl(opts) {
22165
22362
  `[eternal] ${err instanceof Error ? err.message : String(err)}`
22166
22363
  );
22167
22364
  }
22168
- await new Promise((resolve10) => setTimeout(resolve10, 250));
22365
+ await new Promise((resolve11) => setTimeout(resolve11, 250));
22169
22366
  continue;
22170
22367
  }
22171
22368
  } else if (opts.getAutonomy?.() === "eternal-parallel") {
@@ -22241,7 +22438,7 @@ async function runRepl(opts) {
22241
22438
  `[parallel] ${err instanceof Error ? err.message : String(err)}`
22242
22439
  );
22243
22440
  }
22244
- await new Promise((resolve10) => setTimeout(resolve10, 250));
22441
+ await new Promise((resolve11) => setTimeout(resolve11, 250));
22245
22442
  continue;
22246
22443
  }
22247
22444
  }
@@ -22808,12 +23005,12 @@ ${color.cyan("\u23F3 Auto")} ${color.dim("(Ctrl+C to cancel)")}
22808
23005
  let interval;
22809
23006
  let lastTickedSecond = sec + 1;
22810
23007
  let onAbort;
22811
- return new Promise((resolve10) => {
22812
- onAbort = () => resolve10(false);
23008
+ return new Promise((resolve11) => {
23009
+ onAbort = () => resolve11(false);
22813
23010
  signal.addEventListener("abort", onAbort, { once: true });
22814
23011
  interval = setInterval(() => {
22815
23012
  if (signal.aborted) {
22816
- resolve10(false);
23013
+ resolve11(false);
22817
23014
  return;
22818
23015
  }
22819
23016
  const elapsed = Date.now() - start;
@@ -22821,7 +23018,7 @@ ${color.cyan("\u23F3 Auto")} ${color.dim("(Ctrl+C to cancel)")}
22821
23018
  if (remaining <= 0) {
22822
23019
  opts.renderer.write(color.dim(` \u21B3 ${truncated}
22823
23020
  `));
22824
- resolve10(true);
23021
+ resolve11(true);
22825
23022
  return;
22826
23023
  }
22827
23024
  if (opts.onCountdownTick && remaining !== lastTickedSecond) {
@@ -22832,7 +23029,7 @@ ${color.cyan("\u23F3 Auto")} ${color.dim("(Ctrl+C to cancel)")}
22832
23029
  opts.renderer.write(
22833
23030
  color.yellow(" \u21B3 Countdown cancelled \u2014 switching to manual mode\n")
22834
23031
  );
22835
- resolve10(false);
23032
+ resolve11(false);
22836
23033
  return;
22837
23034
  }
22838
23035
  } catch {
@@ -22978,6 +23175,23 @@ async function execute(deps) {
22978
23175
  restoredToolCalls,
22979
23176
  needsSetup
22980
23177
  } = deps;
23178
+ const rootTraceId = context.traceId;
23179
+ const storageLog = (event, payload) => {
23180
+ const traceId = payload.traceId ?? rootTraceId;
23181
+ console.warn(JSON.stringify({
23182
+ level: "info",
23183
+ event,
23184
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23185
+ traceId,
23186
+ ...payload
23187
+ }));
23188
+ };
23189
+ const onStorageRead = (...args) => storageLog("storage.read", args[0]);
23190
+ const onStorageWrite = (...args) => storageLog("storage.write", args[0]);
23191
+ const onStorageError = (...args) => storageLog("storage.error", args[0]);
23192
+ events.on("storage.read", onStorageRead);
23193
+ events.on("storage.write", onStorageWrite);
23194
+ events.on("storage.error", onStorageError);
22981
23195
  let pendingChimeraWork;
22982
23196
  events.onPattern("chimera.review_needed", (_event, payload) => {
22983
23197
  const p = payload;
@@ -23423,7 +23637,7 @@ async function execute(deps) {
23423
23637
  const toWrite = targetPath === wpaths.globalConfig ? decrypted : filterSafeForProject(decrypted);
23424
23638
  const encrypted = encryptConfigSecrets(toWrite, noOpVault);
23425
23639
  if (targetPath !== wpaths.globalConfig) {
23426
- await fsp5.mkdir(path38.dirname(targetPath), { recursive: true });
23640
+ await fsp5.mkdir(path39.dirname(targetPath), { recursive: true });
23427
23641
  }
23428
23642
  await atomicWrite(targetPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
23429
23643
  configStore.update({
@@ -23500,7 +23714,7 @@ async function execute(deps) {
23500
23714
  agentsMonitorController,
23501
23715
  getLiveSessions: async () => {
23502
23716
  const { SessionRegistry } = await import('@wrongstack/core');
23503
- const globalRoot = path38.dirname(wpaths.globalConfig);
23717
+ const globalRoot = path39.dirname(wpaths.globalConfig);
23504
23718
  const registry = new SessionRegistry(globalRoot);
23505
23719
  const sessions = await registry.list();
23506
23720
  return sessions.filter((s) => s.status !== "stale").map((s) => ({
@@ -23629,7 +23843,7 @@ async function execute(deps) {
23629
23843
  if (!sessionStore) return null;
23630
23844
  try {
23631
23845
  const { SessionRegistry } = await import('@wrongstack/core');
23632
- const registry = new SessionRegistry(path38.dirname(wpaths.globalConfig));
23846
+ const registry = new SessionRegistry(path39.dirname(wpaths.globalConfig));
23633
23847
  const live = (await registry.list()).find(
23634
23848
  (s) => s.sessionId === sessionId && s.status !== "stale" && s.pid !== process.pid
23635
23849
  );
@@ -23767,7 +23981,7 @@ async function execute(deps) {
23767
23981
  if (slug === "new-session") {
23768
23982
  pendingProjectSwitch = {
23769
23983
  root: projectRoot,
23770
- name: path38.basename(projectRoot) || projectRoot
23984
+ name: path39.basename(projectRoot) || projectRoot
23771
23985
  };
23772
23986
  }
23773
23987
  return;
@@ -23828,13 +24042,13 @@ ${parts.join("\n")}
23828
24042
  const { root, name, resumeSessionId } = pendingProjectSwitch;
23829
24043
  process.stdout.write("\x1B[2J\x1B[H");
23830
24044
  const { spawn: spawn6 } = await import('child_process');
23831
- const { createRequire: createRequire7 } = await import('module');
24045
+ const { createRequire: createRequire8 } = await import('module');
23832
24046
  let cliPath;
23833
24047
  try {
23834
- const req2 = createRequire7(import.meta.url);
24048
+ const req2 = createRequire8(import.meta.url);
23835
24049
  const pkgPath = req2.resolve("@wrongstack/cli/package.json");
23836
- const pkgDir = path38.dirname(pkgPath);
23837
- cliPath = path38.join(pkgDir, "dist", "index.js");
24050
+ const pkgDir = path39.dirname(pkgPath);
24051
+ cliPath = path39.join(pkgDir, "dist", "index.js");
23838
24052
  await fsp5.access(cliPath);
23839
24053
  } catch {
23840
24054
  cliPath = process.argv[1] ?? "";
@@ -23908,12 +24122,12 @@ ${parts.join("\n")}
23908
24122
  )
23909
24123
  );
23910
24124
  renderer.writeInfo(color.dim(" Press Ctrl+C in this terminal to stop the WebUI server.\n"));
23911
- const webuiExit = new Promise((resolve10) => {
24125
+ const webuiExit = new Promise((resolve11) => {
23912
24126
  const onSigint = () => {
23913
24127
  renderer.setSilent(false);
23914
24128
  renderer.write("\n");
23915
24129
  renderer.writeInfo(color.yellow(" Shutting down WebUI server\u2026"));
23916
- resolve10(0);
24130
+ resolve11(0);
23917
24131
  };
23918
24132
  process.on("SIGINT", onSigint);
23919
24133
  process.on("SIGTERM", onSigint);
@@ -23921,13 +24135,13 @@ ${parts.join("\n")}
23921
24135
  renderer.setSilent(false);
23922
24136
  process.off("SIGINT", onSigint);
23923
24137
  process.off("SIGTERM", onSigint);
23924
- resolve10(0);
24138
+ resolve11(0);
23925
24139
  }).catch((err) => {
23926
24140
  renderer.setSilent(false);
23927
24141
  process.off("SIGINT", onSigint);
23928
24142
  process.off("SIGTERM", onSigint);
23929
24143
  console.debug(`[execution] webui error: ${err}`);
23930
- resolve10(1);
24144
+ resolve11(1);
23931
24145
  });
23932
24146
  });
23933
24147
  code = await webuiExit;
@@ -23942,7 +24156,7 @@ ${parts.join("\n")}
23942
24156
  supportsVision,
23943
24157
  attachments,
23944
24158
  effectiveMaxContext,
23945
- projectName: path38.basename(projectRoot) || void 0,
24159
+ projectName: path39.basename(projectRoot) || void 0,
23946
24160
  getAutonomy,
23947
24161
  onAutonomy,
23948
24162
  getNextPredict,
@@ -24155,7 +24369,8 @@ var MultiAgentHost = class _MultiAgentHost {
24155
24369
  if (this.opts.sessionsRoot && !this.sessionFactory) {
24156
24370
  this.sessionFactory = makeDirectorSessionFactory({
24157
24371
  sessionsRoot: this.opts.sessionsRoot,
24158
- directorRunId: this.opts.directorRunId
24372
+ directorRunId: this.opts.directorRunId,
24373
+ traceId: this.opts.traceId
24159
24374
  });
24160
24375
  }
24161
24376
  const coordinatorConfig = {
@@ -24163,7 +24378,7 @@ var MultiAgentHost = class _MultiAgentHost {
24163
24378
  doneCondition: { type: "all_tasks_done" },
24164
24379
  maxConcurrent: this.opts.maxConcurrent ?? 4
24165
24380
  };
24166
- const defaultScratchpad = this.opts.sharedScratchpadPath || (this.opts.sessionsRoot && this.opts.directorRunId ? path38.join(this.opts.sessionsRoot, this.opts.directorRunId, "shared") : void 0);
24381
+ const defaultScratchpad = this.opts.sharedScratchpadPath || (this.opts.sessionsRoot && this.opts.directorRunId ? path39.join(this.opts.sessionsRoot, this.opts.directorRunId, "shared") : void 0);
24167
24382
  this.director = new Director({
24168
24383
  config: coordinatorConfig,
24169
24384
  manifestPath: this.opts.manifestPath,
@@ -24720,16 +24935,16 @@ var MultiAgentHost = class _MultiAgentHost {
24720
24935
  if (this.director) return this.director;
24721
24936
  this.opts.directorMode = true;
24722
24937
  if (this.opts.fleetRoot && !this.opts.manifestPath) {
24723
- this.opts.manifestPath = path38.join(this.opts.fleetRoot, "fleet.json");
24938
+ this.opts.manifestPath = path39.join(this.opts.fleetRoot, "fleet.json");
24724
24939
  }
24725
24940
  if (this.opts.fleetRoot && !this.opts.sharedScratchpadPath) {
24726
- this.opts.sharedScratchpadPath = path38.join(this.opts.fleetRoot, "shared");
24941
+ this.opts.sharedScratchpadPath = path39.join(this.opts.fleetRoot, "shared");
24727
24942
  }
24728
24943
  if (this.opts.fleetRoot && !this.opts.sessionsRoot) {
24729
- this.opts.sessionsRoot = path38.join(this.opts.fleetRoot, "subagents");
24944
+ this.opts.sessionsRoot = path39.join(this.opts.fleetRoot, "subagents");
24730
24945
  }
24731
24946
  if (this.opts.fleetRoot && !this.opts.stateCheckpointPath) {
24732
- this.opts.stateCheckpointPath = path38.join(this.opts.fleetRoot, "director-state.json");
24947
+ this.opts.stateCheckpointPath = path39.join(this.opts.fleetRoot, "director-state.json");
24733
24948
  }
24734
24949
  await this.ensureDirector();
24735
24950
  return this.director ?? null;
@@ -24858,11 +25073,11 @@ var SessionStats = class {
24858
25073
  if (tool.name === "bash") this.bashCommands++;
24859
25074
  else if (tool.name === "fetch") this.fetches++;
24860
25075
  if (!tool.ok) return;
24861
- const path39 = typeof input?.path === "string" ? input.path : void 0;
24862
- if (tool.name === "read" && path39) this.readPaths.add(path39);
24863
- else if (tool.name === "edit" && path39) this.editedPaths.add(path39);
24864
- else if (tool.name === "write" && path39) {
24865
- this.writtenPaths.add(path39);
25076
+ const path40 = typeof input?.path === "string" ? input.path : void 0;
25077
+ if (tool.name === "read" && path40) this.readPaths.add(path40);
25078
+ else if (tool.name === "edit" && path40) this.editedPaths.add(path40);
25079
+ else if (tool.name === "write" && path40) {
25080
+ this.writtenPaths.add(path40);
24866
25081
  const content = typeof input?.content === "string" ? input.content : "";
24867
25082
  this.bytesWritten += Buffer.byteLength(content, "utf8");
24868
25083
  }
@@ -25174,7 +25389,7 @@ async function setupCodebaseIndexing(deps) {
25174
25389
  if (tool?.mutating && FILE_EDIT_TOOLS.has(tool.name)) {
25175
25390
  const fp = payload.toolUse.input?.file_path;
25176
25391
  if (typeof fp === "string" && fp.length > 0) {
25177
- const abs = path38.resolve(payload.ctx.cwd, fp);
25392
+ const abs = path39.resolve(payload.ctx.cwd, fp);
25178
25393
  if (isIndexableFile(abs)) {
25179
25394
  enqueueReindex({ projectRoot, files: [abs], debounceMs, onError });
25180
25395
  }
@@ -25193,7 +25408,7 @@ async function setupCodebaseIndexing(deps) {
25193
25408
  if (!filename) return;
25194
25409
  const rel = filename.toString();
25195
25410
  if (isIgnored(rel)) return;
25196
- const abs = path38.resolve(projectRoot, rel);
25411
+ const abs = path39.resolve(projectRoot, rel);
25197
25412
  if (!isIndexableFile(abs)) return;
25198
25413
  enqueueReindex({ projectRoot, files: [abs], debounceMs, onError });
25199
25414
  });
@@ -25247,7 +25462,7 @@ function setupMetrics(params) {
25247
25462
  const dumpMetrics = () => {
25248
25463
  if (!metricsSink) return;
25249
25464
  try {
25250
- const out = path38.join(wpaths.projectSessions, "metrics.json");
25465
+ const out = path39.join(wpaths.projectSessions, "metrics.json");
25251
25466
  const snap = metricsSink.snapshot();
25252
25467
  writeFileSync(out, JSON.stringify(snap, null, 2));
25253
25468
  } catch {
@@ -25425,7 +25640,9 @@ async function setupSession(params) {
25425
25640
  tokenCounter,
25426
25641
  renderer,
25427
25642
  flags,
25428
- onRecovery
25643
+ onRecovery,
25644
+ // Optional EventBus for storage observability
25645
+ events: eventsBus
25429
25646
  } = params;
25430
25647
  sessionStore.prune(DEFAULT_SESSION_PRUNE_DAYS).then((count) => {
25431
25648
  if (count > 0) renderer.writeInfo(`Pruned ${count} old session${count === 1 ? "" : "s"}.`);
@@ -25482,10 +25699,10 @@ async function setupSession(params) {
25482
25699
  );
25483
25700
  });
25484
25701
  const attachments = new DefaultAttachmentStore({
25485
- spoolDir: path38.join(wpaths.projectSessions, session?.id, "attachments")
25702
+ spoolDir: path39.join(wpaths.projectSessions, session?.id, "attachments")
25486
25703
  });
25487
- const queueStore = new QueueStore({ dir: path38.join(wpaths.projectSessions, session?.id) });
25488
25704
  const ctxSignal = new AbortController().signal;
25705
+ const traceId = randomBytes(16).toString("hex");
25489
25706
  const context = new Context({
25490
25707
  systemPrompt,
25491
25708
  provider,
@@ -25496,17 +25713,27 @@ async function setupSession(params) {
25496
25713
  projectRoot,
25497
25714
  model: config.model,
25498
25715
  agentId: "leader",
25499
- agentName: "Leader Agent"
25716
+ agentName: "Leader Agent",
25717
+ traceId
25500
25718
  });
25501
25719
  context.meta["packageTrackerOpts"] = {
25502
25720
  storageDir: wpaths.projectDir,
25503
25721
  projectRoot
25504
25722
  };
25505
25723
  if (restoredMessages.length > 0) context.state.replaceMessages(restoredMessages);
25506
- const todosCheckpointPath = path38.join(wpaths.projectSessions, `${session?.id}.todos.json`);
25724
+ const queueStore = new QueueStore({
25725
+ dir: path39.join(wpaths.projectSessions, session?.id),
25726
+ ...eventsBus ? { events: eventsBus } : {},
25727
+ ...traceId ? { traceId } : {}
25728
+ });
25729
+ const todosCheckpointPath = path39.join(wpaths.projectSessions, `${session?.id}.todos.json`);
25507
25730
  if (resumeId) {
25508
25731
  try {
25509
- const restoredTodos = await loadTodosCheckpoint(todosCheckpointPath);
25732
+ const restoredTodos = await loadTodosCheckpoint(
25733
+ todosCheckpointPath,
25734
+ eventsBus,
25735
+ traceId
25736
+ );
25510
25737
  if (restoredTodos && restoredTodos.length > 0) {
25511
25738
  context.state.replaceTodos(restoredTodos);
25512
25739
  renderer.writeInfo(
@@ -25519,17 +25746,19 @@ async function setupSession(params) {
25519
25746
  const detachTodosCheckpoint = attachTodosCheckpoint(
25520
25747
  context.state,
25521
25748
  todosCheckpointPath,
25522
- session?.id
25749
+ session?.id,
25750
+ eventsBus,
25751
+ traceId
25523
25752
  );
25524
- const planPath = path38.join(wpaths.projectSessions, `${session?.id}.plan.json`);
25753
+ const planPath = path39.join(wpaths.projectSessions, `${session?.id}.plan.json`);
25525
25754
  context.state.setMeta("plan.path", planPath);
25526
- const taskPath = path38.join(wpaths.projectSessions, `${session?.id}.tasks.json`);
25755
+ const taskPath = path39.join(wpaths.projectSessions, `${session?.id}.tasks.json`);
25527
25756
  context.state.setMeta("task.path", taskPath);
25528
25757
  let dirState;
25529
25758
  if (resumeId) {
25530
25759
  try {
25531
- const fleetRoot = path38.join(wpaths.projectSessions, session?.id);
25532
- dirState = await loadDirectorState(path38.join(fleetRoot, "director-state.json"));
25760
+ const fleetRoot = path39.join(wpaths.projectSessions, session?.id);
25761
+ dirState = await loadDirectorState(path39.join(fleetRoot, "director-state.json"));
25533
25762
  if (dirState) {
25534
25763
  const tCounts = {};
25535
25764
  for (const t of dirState.tasks) tCounts[t.status] = (tCounts[t.status] ?? 0) + 1;
@@ -25555,6 +25784,7 @@ async function setupSession(params) {
25555
25784
  return {
25556
25785
  session: expectDefined(session),
25557
25786
  sessionRef,
25787
+ traceId,
25558
25788
  context,
25559
25789
  restoredMessages,
25560
25790
  attachments,
@@ -25775,7 +26005,7 @@ async function main(argv) {
25775
26005
  projectGoal: wpaths.projectGoal,
25776
26006
  projectSessions: wpaths.projectSessions
25777
26007
  },
25778
- pathJoiner: { join: (a, b) => path38.join(a, b) },
26008
+ pathJoiner: { join: (a, b) => path39.join(a, b) },
25779
26009
  systemPromptBuilderToken: TOKENS.SystemPromptBuilder
25780
26010
  });
25781
26011
  const toolRegistry = new ToolRegistry();
@@ -25895,6 +26125,7 @@ async function main(argv) {
25895
26125
  tokenCounter,
25896
26126
  renderer,
25897
26127
  flags,
26128
+ events,
25898
26129
  onRecovery: (abandoned, autoRecover) => promptRecovery(reader, renderer, abandoned, autoRecover)
25899
26130
  });
25900
26131
  const session = sessResult.session;
@@ -25906,12 +26137,13 @@ async function main(argv) {
25906
26137
  const planPath = sessResult.planPath;
25907
26138
  const detachTodosCheckpoint = sessResult.detachTodosCheckpoint;
25908
26139
  const priorFleetState = sessResult.priorFleetState;
26140
+ memoryStore.withTraceId(sessResult.traceId);
25909
26141
  let tracker;
25910
26142
  try {
25911
26143
  const { getSessionRegistry, AgentStatusTracker } = await import('@wrongstack/core');
25912
26144
  const registry = getSessionRegistry(wpaths.globalRoot);
25913
- const projectSlug2 = path38.basename(wpaths.projectDir);
25914
- const projectName = path38.basename(projectRoot);
26145
+ const projectSlug2 = path39.basename(wpaths.projectDir);
26146
+ const projectName = path39.basename(projectRoot);
25915
26147
  let gitBranch;
25916
26148
  try {
25917
26149
  const { execSync } = await import('child_process');
@@ -26010,7 +26242,7 @@ async function main(argv) {
26010
26242
  if (e.ok && (e.name === "write" || e.name === "edit" || e.name === "replace" || e.name === "patch")) {
26011
26243
  const filePath = e.input?.path;
26012
26244
  if (filePath) {
26013
- const projectDir = path38.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26245
+ const projectDir = path39.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26014
26246
  void recordFileAction(
26015
26247
  { storageDir: projectDir, projectRoot },
26016
26248
  {
@@ -26176,7 +26408,7 @@ async function main(argv) {
26176
26408
  let depWatcherDispose;
26177
26409
  if (dwCfg?.["enabled"] === true) {
26178
26410
  try {
26179
- const projectDir = path38.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26411
+ const projectDir = path39.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26180
26412
  const dwMailbox = new GlobalMailbox(projectDir, events);
26181
26413
  depWatcherDispose = attachDepWatcherBridge({
26182
26414
  events,
@@ -26275,12 +26507,12 @@ async function main(argv) {
26275
26507
  }
26276
26508
  }
26277
26509
  };
26278
- const fleetRoot = directorMode ? path38.join(wpaths.projectSessions, session.id) : void 0;
26279
- const manifestPath = directorMode ? typeof process.env["WRONGSTACK_FLEET_MANIFEST"] === "string" ? process.env["WRONGSTACK_FLEET_MANIFEST"] : path38.join(expectDefined(fleetRoot), "fleet.json") : void 0;
26280
- const sharedScratchpadPath = directorMode ? path38.join(expectDefined(fleetRoot), "shared") : void 0;
26281
- const subagentSessionsRoot = directorMode ? path38.join(expectDefined(fleetRoot), "subagents") : void 0;
26282
- const stateCheckpointPath = directorMode ? path38.join(expectDefined(fleetRoot), "director-state.json") : void 0;
26283
- const fleetRootForPromotion = path38.join(wpaths.projectSessions, session.id);
26510
+ const fleetRoot = directorMode ? path39.join(wpaths.projectSessions, session.id) : void 0;
26511
+ const manifestPath = directorMode ? typeof process.env["WRONGSTACK_FLEET_MANIFEST"] === "string" ? process.env["WRONGSTACK_FLEET_MANIFEST"] : path39.join(expectDefined(fleetRoot), "fleet.json") : void 0;
26512
+ const sharedScratchpadPath = directorMode ? path39.join(expectDefined(fleetRoot), "shared") : void 0;
26513
+ const subagentSessionsRoot = directorMode ? path39.join(expectDefined(fleetRoot), "subagents") : void 0;
26514
+ const stateCheckpointPath = directorMode ? path39.join(expectDefined(fleetRoot), "director-state.json") : void 0;
26515
+ const fleetRootForPromotion = path39.join(wpaths.projectSessions, session.id);
26284
26516
  const brainSettings = {
26285
26517
  maxAutoRisk: "medium"
26286
26518
  };
@@ -26385,7 +26617,8 @@ async function main(argv) {
26385
26617
  sessionWriter: session,
26386
26618
  maxConcurrent,
26387
26619
  getLeaderMaxContext: () => effectiveMaxContext,
26388
- brain
26620
+ brain,
26621
+ traceId: sessResult.traceId
26389
26622
  }
26390
26623
  );
26391
26624
  toolRegistry.register(
@@ -26422,7 +26655,7 @@ async function main(argv) {
26422
26655
  let techStackConsumerDispose;
26423
26656
  if (dwCfg?.["enabled"] === true) {
26424
26657
  try {
26425
- const projectDir = path38.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26658
+ const projectDir = path39.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26426
26659
  const tsMailbox = new GlobalMailbox(projectDir, events);
26427
26660
  const fileAuthorOpts = {
26428
26661
  storageDir: projectDir,
@@ -26455,7 +26688,7 @@ async function main(argv) {
26455
26688
  let pkgOutdatedDispose;
26456
26689
  if (dwCfg?.["enabled"] === true) {
26457
26690
  try {
26458
- const projectDir = path38.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26691
+ const projectDir = path39.join(wpaths.globalRoot, "projects", wpaths.projectSlug);
26459
26692
  const pkgMailbox = new GlobalMailbox(projectDir, events);
26460
26693
  const pkgTrackerOpts = {
26461
26694
  storageDir: projectDir,
@@ -26829,7 +27062,7 @@ ${color.dim("\u2500".repeat(40))}` : "";
26829
27062
  return director.spawn(cfg);
26830
27063
  },
26831
27064
  onFleetLog: async (subagentId, mode) => {
26832
- const subagentsRoot = path38.join(fleetRootForPromotion, "subagents");
27065
+ const subagentsRoot = path39.join(fleetRootForPromotion, "subagents");
26833
27066
  let runDirs;
26834
27067
  try {
26835
27068
  runDirs = await fsp5.readdir(subagentsRoot);
@@ -26838,7 +27071,7 @@ ${color.dim("\u2500".repeat(40))}` : "";
26838
27071
  }
26839
27072
  const found = [];
26840
27073
  for (const runId of runDirs) {
26841
- const runDir = path38.join(subagentsRoot, runId);
27074
+ const runDir = path39.join(subagentsRoot, runId);
26842
27075
  let files;
26843
27076
  try {
26844
27077
  files = await fsp5.readdir(runDir);
@@ -26847,7 +27080,7 @@ ${color.dim("\u2500".repeat(40))}` : "";
26847
27080
  }
26848
27081
  for (const f of files) {
26849
27082
  if (!f.endsWith(".jsonl")) continue;
26850
- const full = path38.join(runDir, f);
27083
+ const full = path39.join(runDir, f);
26851
27084
  try {
26852
27085
  const stat7 = await fsp5.stat(full);
26853
27086
  found.push({
@@ -26948,7 +27181,7 @@ ${color.dim("\u2500".repeat(40))}` : "";
26948
27181
  }
26949
27182
  const dir = await multiAgentHost.ensureDirector();
26950
27183
  if (!dir) return "Director is not available.";
26951
- const dirStatePath = path38.join(fleetRootForPromotion, "director-state.json");
27184
+ const dirStatePath = path39.join(fleetRootForPromotion, "director-state.json");
26952
27185
  const prior = await loadDirectorState(dirStatePath);
26953
27186
  if (!prior) {
26954
27187
  return "No prior director-state.json found \u2014 nothing to retry.";
@@ -27017,9 +27250,9 @@ ${color.dim("\u2500".repeat(40))}` : "";
27017
27250
  for (const tool of director2.tools(FLEET_ROSTER)) {
27018
27251
  toolRegistry.register(tool);
27019
27252
  }
27020
- const mp = path38.join(fleetRootForPromotion, "fleet.json");
27021
- const sp = path38.join(fleetRootForPromotion, "shared");
27022
- const ss = path38.join(fleetRootForPromotion, "subagents");
27253
+ const mp = path39.join(fleetRootForPromotion, "fleet.json");
27254
+ const sp = path39.join(fleetRootForPromotion, "shared");
27255
+ const ss = path39.join(fleetRootForPromotion, "subagents");
27023
27256
  const lines = [
27024
27257
  `${color.green("\u2713")} Promoted to director mode.`,
27025
27258
  ` Roster: ${Object.keys(FLEET_ROSTER).join(", ")}`,
@@ -27123,7 +27356,8 @@ Restart WrongStack to load or unload plugin code in this session.`;
27123
27356
  // Real per-role factory: each dispatched slot runs as a fresh,
27124
27357
  // isolated agent with the role's filtered tools + persona prompt
27125
27358
  // (instead of sharing the leader agent's Context).
27126
- subagentFactory: multiAgentHost.makeSubagentFactory(config)
27359
+ subagentFactory: multiAgentHost.makeSubagentFactory(config),
27360
+ events
27127
27361
  };
27128
27362
  parallelEngine = new ParallelEternalEngine(parallelOptions);
27129
27363
  }
@@ -27137,7 +27371,8 @@ Restart WrongStack to load or unload plugin code in this session.`;
27137
27371
  maxContextTokens: effectiveMaxContext > 0 ? effectiveMaxContext : void 0,
27138
27372
  onIteration: broadcastEternalIteration,
27139
27373
  onStage: broadcastAutonomyStage,
27140
- brain
27374
+ brain,
27375
+ events
27141
27376
  });
27142
27377
  }
27143
27378
  void eternalEngine.prime();
@@ -27160,7 +27395,7 @@ Restart WrongStack to load or unload plugin code in this session.`;
27160
27395
  onBeforeExit: async () => {
27161
27396
  const cwd2 = projectRoot;
27162
27397
  const statusResult = await new Promise(
27163
- (resolve10, reject) => {
27398
+ (resolve11, reject) => {
27164
27399
  const child = spawn("git", ["status", "--porcelain"], {
27165
27400
  cwd: cwd2,
27166
27401
  stdio: ["ignore", "pipe", "pipe"],
@@ -27172,7 +27407,7 @@ Restart WrongStack to load or unload plugin code in this session.`;
27172
27407
  stdout += d;
27173
27408
  });
27174
27409
  child.on("error", reject);
27175
- child.on("close", (code) => resolve10({ stdout, code: code ?? 0 }));
27410
+ child.on("close", (code) => resolve11({ stdout, code: code ?? 0 }));
27176
27411
  }
27177
27412
  );
27178
27413
  if (statusResult.stdout.trim().length > 0) {