@staff0rd/assist 0.824.4 → 0.825.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
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.824.4",
9
+ version: "0.825.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -1995,7 +1995,8 @@ var daemonPaths = {
1995
1995
  pid: join11(DAEMON_DIR, "daemon.pid"),
1996
1996
  autoUpdatePaused: join11(DAEMON_DIR, "auto-update-paused"),
1997
1997
  spawnLock: join11(DAEMON_DIR, "spawn.lock"),
1998
- hooksSettings: join11(DAEMON_DIR, "hooks-settings.json")
1998
+ hooksSettings: join11(DAEMON_DIR, "hooks-settings.json"),
1999
+ viewerSize: join11(DAEMON_DIR, "viewer-size.json")
1999
2000
  };
2000
2001
 
2001
2002
  // src/commands/sessions/daemon/connectToDaemon.ts
@@ -35422,14 +35423,6 @@ function classifyTestCall(call) {
35422
35423
  return void 0;
35423
35424
  }
35424
35425
 
35425
- // src/commands/review/highLevel/dedentedSource.ts
35426
- function dedentedSource(call) {
35427
- const text18 = call.getSourceFile().getFullText();
35428
- const lineStart = text18.lastIndexOf("\n", call.getStart()) + 1;
35429
- const indent3 = /^\s*/.exec(text18.slice(lineStart, call.getStart()))?.[0] ?? "";
35430
- return call.getText().split("\n").map((line) => line.startsWith(indent3) ? line.slice(indent3.length) : line).join("\n");
35431
- }
35432
-
35433
35426
  // src/commands/review/highLevel/testName.ts
35434
35427
  import { Node as Node3 } from "ts-morph";
35435
35428
  function testName(call) {
@@ -35440,23 +35433,41 @@ function testName(call) {
35440
35433
  return first?.getText() ?? "";
35441
35434
  }
35442
35435
 
35443
- // src/commands/review/highLevel/extractTestHierarchy.ts
35444
- function touchesChange(call, changed) {
35445
- if (!changed) return true;
35446
- for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
35447
- if (changed.has(line)) return true;
35448
- return false;
35436
+ // src/commands/review/highLevel/dedentedSource.ts
35437
+ function dedentedSource(call) {
35438
+ const text18 = call.getSourceFile().getFullText();
35439
+ const lineStart = text18.lastIndexOf("\n", call.getStart()) + 1;
35440
+ const indent3 = /^\s*/.exec(text18.slice(lineStart, call.getStart()))?.[0] ?? "";
35441
+ return call.getText().split("\n").map((line) => line.startsWith(indent3) ? line.slice(indent3.length) : line).join("\n");
35449
35442
  }
35450
- function toCase(call, context) {
35443
+
35444
+ // src/commands/review/highLevel/visitCase.ts
35445
+ function visitCase(call, context) {
35446
+ if (!context.changed) return [toCase(call, context, void 0)];
35447
+ const count8 = changedLines(call, context.changed);
35448
+ if (count8 === 0) return [];
35449
+ const lines2 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
35450
+ return [toCase(call, context, count8 === lines2 ? "added" : "modified")];
35451
+ }
35452
+ function toCase(call, context, change) {
35451
35453
  const line = call.getStartLineNumber();
35452
35454
  return {
35453
35455
  kind: "it",
35454
35456
  id: `${context.path}:${line}`,
35455
35457
  name: testName(call),
35456
35458
  line,
35459
+ ...change ? { change } : {},
35457
35460
  source: dedentedSource(call)
35458
35461
  };
35459
35462
  }
35463
+ function changedLines(call, changed) {
35464
+ let count8 = 0;
35465
+ for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
35466
+ if (changed.has(line)) count8++;
35467
+ return count8;
35468
+ }
35469
+
35470
+ // src/commands/review/highLevel/extractTestHierarchy.ts
35460
35471
  function collect7(node, context) {
35461
35472
  const found = [];
35462
35473
  node.forEachChild((child) => {
@@ -35467,8 +35478,7 @@ function collect7(node, context) {
35467
35478
  function visit(node, context) {
35468
35479
  if (!Node4.isCallExpression(node)) return collect7(node, context);
35469
35480
  const kind = classifyTestCall(node);
35470
- if (kind === "it")
35471
- return touchesChange(node, context.changed) ? [toCase(node, context)] : [];
35481
+ if (kind === "it") return visitCase(node, context);
35472
35482
  if (kind === void 0) return collect7(node, context);
35473
35483
  const children = node.getArguments().slice(1).flatMap((argument) => visit(argument, context));
35474
35484
  if (children.length === 0) return [];
@@ -36082,9 +36092,15 @@ function formatHighLevelStructure(structure) {
36082
36092
 
36083
36093
  // src/commands/review/highLevel/formatHighLevelTests.ts
36084
36094
  import chalk238 from "chalk";
36095
+ function changeMarker(change) {
36096
+ if (change === "added") return "A";
36097
+ if (change === "modified") return "M";
36098
+ return "\xB7";
36099
+ }
36085
36100
  function formatNode2(node, depth) {
36086
36101
  const indent3 = " ".repeat(depth + 2);
36087
- if (node.kind === "it") return [`${indent3}${chalk238.dim("\xB7")} ${node.name}`];
36102
+ if (node.kind === "it")
36103
+ return [`${indent3}${chalk238.dim(changeMarker(node.change))} ${node.name}`];
36088
36104
  return [
36089
36105
  `${indent3}${chalk238.bold(node.name)}`,
36090
36106
  ...node.children.flatMap((child) => formatNode2(child, depth + 1))
@@ -43171,13 +43187,45 @@ function sessionSnapshot(s) {
43171
43187
  return stripReplayQueries(s.screen?.snapshot() ?? s.scrollback);
43172
43188
  }
43173
43189
 
43174
- // src/commands/sessions/daemon/sendTakeoverSnapshot.ts
43175
- function sendTakeoverSnapshot(s, send) {
43190
+ // src/commands/sessions/daemon/sendResizeSnapshot.ts
43191
+ function sendResizeSnapshot(s, send) {
43176
43192
  const data = sessionSnapshot(s);
43177
- daemonLog(`session ${s.id} takeover snapshot ${data.length} chars`);
43193
+ daemonLog(`session ${s.id} resize snapshot ${data.length} chars`);
43178
43194
  send(data);
43179
43195
  }
43180
43196
 
43197
+ // src/commands/sessions/daemon/viewerSize.ts
43198
+ import { readFileSync as readFileSync68, writeFileSync as writeFileSync55 } from "fs";
43199
+ var DEFAULT_SIZE = { cols: 120, rows: 30 };
43200
+ var remembered;
43201
+ function rememberViewerSize(cols, rows) {
43202
+ if (cols <= 0 || rows <= 0) return;
43203
+ if (remembered?.cols === cols && remembered.rows === rows) return;
43204
+ remembered = { cols, rows };
43205
+ try {
43206
+ writeFileSync55(daemonPaths.viewerSize, JSON.stringify(remembered));
43207
+ } catch (error) {
43208
+ daemonLog(
43209
+ `viewer size ${cols}x${rows} not saved: ${error instanceof Error ? error.message : String(error)}`
43210
+ );
43211
+ }
43212
+ }
43213
+ function viewerSize() {
43214
+ remembered ??= readSavedSize();
43215
+ return remembered ?? DEFAULT_SIZE;
43216
+ }
43217
+ function readSavedSize() {
43218
+ try {
43219
+ const { cols, rows } = JSON.parse(
43220
+ readFileSync68(daemonPaths.viewerSize, "utf8")
43221
+ );
43222
+ if (typeof cols === "number" && typeof rows === "number" && cols > 0)
43223
+ return { cols, rows };
43224
+ } catch {
43225
+ }
43226
+ return void 0;
43227
+ }
43228
+
43181
43229
  // src/commands/sessions/daemon/resizeSession.ts
43182
43230
  function resizeSession(sessions, id, cols, rows, viewer = {}) {
43183
43231
  const s = sessions.get(id);
@@ -43191,11 +43239,12 @@ function resizeSession(sessions, id, cols, rows, viewer = {}) {
43191
43239
  );
43192
43240
  s.cols = cols;
43193
43241
  s.rows = rows;
43242
+ rememberViewerSize(cols, rows);
43194
43243
  const resize = (c, r) => resizePty(s, c, r);
43195
43244
  resize(cols, rows);
43196
- if (!viewer.claim) return;
43197
- if (viewer.sendSnapshot) sendTakeoverSnapshot(s, viewer.sendSnapshot);
43198
- else if (unchanged) nudgePty(s, resize);
43245
+ if (viewer.sendSnapshot && (viewer.claim || viewer.refresh))
43246
+ sendResizeSnapshot(s, viewer.sendSnapshot);
43247
+ else if (viewer.claim && unchanged) nudgePty(s, resize);
43199
43248
  }
43200
43249
  function isInactiveViewer(s, { viewerId, claim }) {
43201
43250
  if (claim || !viewerId || !s.activeViewer) return false;
@@ -43517,8 +43566,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
43517
43566
  } = process.env;
43518
43567
  return pty.spawn(command.file, command.args, {
43519
43568
  name: "xterm-256color",
43520
- cols: 120,
43521
- rows: 30,
43569
+ ...viewerSize(),
43522
43570
  cwd: cwd ?? process.cwd(),
43523
43571
  env: {
43524
43572
  ...parentEnv,
@@ -43702,12 +43750,12 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
43702
43750
  }
43703
43751
 
43704
43752
  // src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
43705
- import { existsSync as existsSync88, rmSync as rmSync9, writeFileSync as writeFileSync55 } from "fs";
43753
+ import { existsSync as existsSync88, rmSync as rmSync9, writeFileSync as writeFileSync56 } from "fs";
43706
43754
  var paused;
43707
43755
  var wake;
43708
43756
  function persist2(value) {
43709
43757
  try {
43710
- if (value) writeFileSync55(daemonPaths.autoUpdatePaused, "");
43758
+ if (value) writeFileSync56(daemonPaths.autoUpdatePaused, "");
43711
43759
  else rmSync9(daemonPaths.autoUpdatePaused, { force: true });
43712
43760
  } catch {
43713
43761
  }
@@ -43832,19 +43880,19 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
43832
43880
  }
43833
43881
 
43834
43882
  // src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
43835
- import { readFileSync as readFileSync69, writeFileSync as writeFileSync56 } from "fs";
43883
+ import { readFileSync as readFileSync70, writeFileSync as writeFileSync57 } from "fs";
43836
43884
  var KEEP_TAIL = 256 * 1024;
43837
43885
  var MAX_LOG_SIZE = 4 * 1024 * 1024;
43838
43886
  function trimWatcherLog(cwd) {
43839
43887
  const path108 = watcherLogPath(cwd);
43840
43888
  let log2;
43841
43889
  try {
43842
- log2 = readFileSync69(path108, "utf8");
43890
+ log2 = readFileSync70(path108, "utf8");
43843
43891
  } catch {
43844
43892
  return;
43845
43893
  }
43846
43894
  if (log2.length <= MAX_LOG_SIZE) return;
43847
- writeFileSync56(path108, log2.slice(-KEEP_TAIL));
43895
+ writeFileSync57(path108, log2.slice(-KEEP_TAIL));
43848
43896
  daemonLog(`auto-update: log ${path108} trimmed to its last ${KEEP_TAIL} chars`);
43849
43897
  }
43850
43898
 
@@ -45058,13 +45106,12 @@ function createScreenMirror(cols, rows) {
45058
45106
  }
45059
45107
 
45060
45108
  // src/commands/sessions/daemon/sessionScreen.ts
45061
- var DEFAULT_COLS = 120;
45062
- var DEFAULT_ROWS = 30;
45063
45109
  function sessionScreen(session) {
45064
45110
  if (!session.screen) {
45111
+ const fallback = viewerSize();
45065
45112
  session.screen = createScreenMirror(
45066
- session.cols ?? DEFAULT_COLS,
45067
- session.rows ?? DEFAULT_ROWS
45113
+ session.cols ?? session.pty?.cols ?? fallback.cols,
45114
+ session.rows ?? session.pty?.rows ?? fallback.rows
45068
45115
  );
45069
45116
  if (session.scrollback) session.screen.write(session.scrollback);
45070
45117
  }
@@ -48583,10 +48630,10 @@ function autoUpdateReply() {
48583
48630
  }
48584
48631
 
48585
48632
  // src/commands/sessions/daemon/autoUpdate/applyAutoUpdateAction.ts
48586
- import { rmSync as rmSync11, writeFileSync as writeFileSync57 } from "fs";
48633
+ import { rmSync as rmSync11, writeFileSync as writeFileSync58 } from "fs";
48587
48634
  function signalLap(installDir, marker2) {
48588
48635
  const control = watchControlPaths(installDir);
48589
- if (control) writeFileSync57(control[marker2], "");
48636
+ if (control) writeFileSync58(control[marker2], "");
48590
48637
  }
48591
48638
  function applyAutoUpdateAction(action) {
48592
48639
  const installDir = getInstallDir();
@@ -49080,11 +49127,13 @@ var viewerHandlers = {
49080
49127
  routed((client, m, d) => {
49081
49128
  const sessionId = d.sessionId;
49082
49129
  const claim = d.claim === true;
49130
+ const refresh = d.refresh === true;
49083
49131
  const localViewer = d.viewerNode === m.links.localNode();
49084
49132
  m.io.resize(sessionId, d.cols, d.rows, {
49085
49133
  ...viewerOf(d),
49086
49134
  claim,
49087
- sendSnapshot: claim && localViewer ? (data) => sendTo(client, { type: "snapshot", sessionId, data }) : void 0
49135
+ refresh,
49136
+ sendSnapshot: localViewer ? (data) => sendTo(client, { type: "snapshot", sessionId, data }) : void 0
49088
49137
  });
49089
49138
  })
49090
49139
  ),
@@ -49292,10 +49341,10 @@ function handleConnection(socket, manager) {
49292
49341
  }
49293
49342
 
49294
49343
  // src/commands/sessions/daemon/onListening.ts
49295
- import { unlinkSync as unlinkSync22, writeFileSync as writeFileSync58 } from "fs";
49344
+ import { unlinkSync as unlinkSync22, writeFileSync as writeFileSync59 } from "fs";
49296
49345
 
49297
49346
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
49298
- import { readFileSync as readFileSync70 } from "fs";
49347
+ import { readFileSync as readFileSync71 } from "fs";
49299
49348
  var WATCHDOG_INTERVAL_MS = 5e3;
49300
49349
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
49301
49350
  const timer = setInterval(() => {
@@ -49306,7 +49355,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
49306
49355
  }
49307
49356
  function ownsPidFile() {
49308
49357
  try {
49309
- return readFileSync70(daemonPaths.pid, "utf8").trim() === String(process.pid);
49358
+ return readFileSync71(daemonPaths.pid, "utf8").trim() === String(process.pid);
49310
49359
  } catch {
49311
49360
  return false;
49312
49361
  }
@@ -49314,7 +49363,7 @@ function ownsPidFile() {
49314
49363
 
49315
49364
  // src/commands/sessions/daemon/onListening.ts
49316
49365
  function onListening(manager, checkAutoExit) {
49317
- writeFileSync58(daemonPaths.pid, String(process.pid));
49366
+ writeFileSync59(daemonPaths.pid, String(process.pid));
49318
49367
  startPidFileWatchdog(() => {
49319
49368
  daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
49320
49369
  void manager.flushActiveMs().finally(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.824.4",
3
+ "version": "0.825.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {