@staff0rd/assist 0.526.0 → 0.528.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.526.0",
9
+ version: "0.528.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -4966,6 +4966,65 @@ Total: ${folders.length} venv folder(s)`);
4966
4966
  }
4967
4967
  }
4968
4968
 
4969
+ // src/commands/sessions/daemon/connectToDaemon.ts
4970
+ import * as net from "net";
4971
+
4972
+ // src/commands/sessions/daemon/daemonPaths.ts
4973
+ import { homedir as homedir2 } from "os";
4974
+ import { join as join10 } from "path";
4975
+ var DAEMON_DIR = join10(homedir2(), ".assist", "daemon");
4976
+ var daemonPaths = {
4977
+ dir: DAEMON_DIR,
4978
+ socket: process.platform === "win32" ? String.raw`\\.\pipe\assist-sessions-daemon` : join10(DAEMON_DIR, "daemon.sock"),
4979
+ log: join10(DAEMON_DIR, "daemon.log"),
4980
+ pid: join10(DAEMON_DIR, "daemon.pid"),
4981
+ spawnLock: join10(DAEMON_DIR, "spawn.lock"),
4982
+ hooksSettings: join10(DAEMON_DIR, "hooks-settings.json")
4983
+ };
4984
+
4985
+ // src/commands/sessions/daemon/connectToDaemon.ts
4986
+ function connectToDaemon() {
4987
+ return new Promise((resolve23, reject) => {
4988
+ const socket = net.connect(daemonPaths.socket);
4989
+ socket.once("connect", () => resolve23(socket));
4990
+ socket.once("error", reject);
4991
+ });
4992
+ }
4993
+ async function isDaemonRunning() {
4994
+ try {
4995
+ (await connectToDaemon()).destroy();
4996
+ return true;
4997
+ } catch {
4998
+ return false;
4999
+ }
5000
+ }
5001
+
5002
+ // src/commands/sessions/signalVerifying.ts
5003
+ function signalVerifying() {
5004
+ const sessionId = process.env.ASSIST_SESSION_ID;
5005
+ if (!sessionId) return () => {
5006
+ };
5007
+ let socket;
5008
+ let released = false;
5009
+ connectToDaemon().then((connected) => {
5010
+ if (released) return connected.destroy();
5011
+ socket = connected;
5012
+ connected.on("error", () => {
5013
+ });
5014
+ connected.unref();
5015
+ connected.write(
5016
+ `${JSON.stringify({ type: "verify-started", sessionId })}
5017
+ `
5018
+ );
5019
+ }, ignoreUnreachableDaemon);
5020
+ return () => {
5021
+ released = true;
5022
+ socket?.destroy();
5023
+ };
5024
+ }
5025
+ function ignoreUnreachableDaemon() {
5026
+ }
5027
+
4969
5028
  // src/commands/verify/run/filterByChangedFiles.ts
4970
5029
  import { minimatch as minimatch4 } from "minimatch";
4971
5030
 
@@ -5031,9 +5090,9 @@ function printMeasureTable(records, totalMs) {
5031
5090
  import { spawn } from "child_process";
5032
5091
 
5033
5092
  // src/shared/expandEnv.ts
5034
- import { homedir as homedir2 } from "os";
5093
+ import { homedir as homedir3 } from "os";
5035
5094
  function expandTilde(value) {
5036
- return value.startsWith("~/") ? homedir2() + value.slice(1) : value;
5095
+ return value.startsWith("~/") ? homedir3() + value.slice(1) : value;
5037
5096
  }
5038
5097
  function expandEnv(env) {
5039
5098
  return Object.fromEntries(
@@ -5136,11 +5195,16 @@ async function run(options2 = {}) {
5136
5195
  return;
5137
5196
  }
5138
5197
  printEntryList(entries);
5139
- const { results, totalMs } = await runAllEntries(entries);
5140
- if (options2.measure) {
5141
- printMeasureTable(results, totalMs);
5198
+ const releaseVerifying = signalVerifying();
5199
+ try {
5200
+ const { results, totalMs } = await runAllEntries(entries);
5201
+ if (options2.measure) {
5202
+ printMeasureTable(results, totalMs);
5203
+ }
5204
+ handleResults(results, entries.length);
5205
+ } finally {
5206
+ releaseVerifying();
5142
5207
  }
5143
- handleResults(results, entries.length);
5144
5208
  }
5145
5209
 
5146
5210
  // src/commands/new/registerNew/initGit.ts
@@ -5247,7 +5311,7 @@ import enquirer3 from "enquirer";
5247
5311
 
5248
5312
  // src/commands/deploy/init/updateWorkflow.ts
5249
5313
  import { existsSync as existsSync16, mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync12 } from "fs";
5250
- import { dirname as dirname12, join as join10 } from "path";
5314
+ import { dirname as dirname12, join as join11 } from "path";
5251
5315
  import { fileURLToPath as fileURLToPath2 } from "url";
5252
5316
  import chalk28 from "chalk";
5253
5317
  var WORKFLOW_PATH = ".github/workflows/build.yml";
@@ -5261,7 +5325,7 @@ function getExistingSiteId() {
5261
5325
  return match ? match[1] : null;
5262
5326
  }
5263
5327
  function getTemplateContent(siteId) {
5264
- const templatePath = join10(__dirname2, "commands/deploy/build.yml");
5328
+ const templatePath = join11(__dirname2, "commands/deploy/build.yml");
5265
5329
  const template = readFileSync12(templatePath, "utf8");
5266
5330
  return template.replace("{{NETLIFY_SITE_ID}}", siteId);
5267
5331
  }
@@ -5612,7 +5676,7 @@ function registerActivity(program2) {
5612
5676
 
5613
5677
  // src/commands/registerBackup.ts
5614
5678
  import { mkdir as mkdir2, stat } from "fs/promises";
5615
- import { join as join12, resolve as resolve7 } from "path";
5679
+ import { join as join13, resolve as resolve7 } from "path";
5616
5680
  import chalk32 from "chalk";
5617
5681
 
5618
5682
  // src/shared/db/recordBackup.ts
@@ -5625,14 +5689,14 @@ async function recordBackup(db, {
5625
5689
  }
5626
5690
 
5627
5691
  // src/shared/expandTilde.ts
5628
- import { homedir as homedir3 } from "os";
5692
+ import { homedir as homedir4 } from "os";
5629
5693
  function expandTilde2(value) {
5630
- return value.startsWith("~/") ? homedir3() + value.slice(1) : value;
5694
+ return value.startsWith("~/") ? homedir4() + value.slice(1) : value;
5631
5695
  }
5632
5696
 
5633
5697
  // src/commands/backup/scheduleBackup.ts
5634
5698
  import { mkdir } from "fs/promises";
5635
- import { join as join11 } from "path";
5699
+ import { join as join12 } from "path";
5636
5700
  import chalk30 from "chalk";
5637
5701
 
5638
5702
  // src/commands/backup/readCrontab.ts
@@ -5774,7 +5838,7 @@ async function scheduleBackup({
5774
5838
  const cronExpr = durationToCron(every);
5775
5839
  const dir = expandTilde2(loadConfig().backup.dir);
5776
5840
  await mkdir(dir, { recursive: true });
5777
- const logPath2 = join11(dir, "cron.log");
5841
+ const logPath2 = join12(dir, "cron.log");
5778
5842
  const cronLine = `${cronExpr} ${resolveAssistCommand()} backup >> ${logPath2} 2>&1`;
5779
5843
  writeCrontab(upsertScheduleBlock(readCrontab(), every, cronLine));
5780
5844
  console.error(
@@ -5953,7 +6017,7 @@ async function backup({ out }) {
5953
6017
  await mkdir2(dir, { recursive: true });
5954
6018
  const start3 = Date.now();
5955
6019
  const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
5956
- const filePath = resolve7(join12(dir, `backup-${timestamp6}.dump`));
6020
+ const filePath = resolve7(join13(dir, `backup-${timestamp6}.dump`));
5957
6021
  await exportBacklog(filePath);
5958
6022
  const { size } = await stat(filePath);
5959
6023
  const durationMs = Date.now() - start3;
@@ -6060,13 +6124,13 @@ import {
6060
6124
  unlinkSync as unlinkSync2,
6061
6125
  writeFileSync as writeFileSync14
6062
6126
  } from "fs";
6063
- import { homedir as homedir4 } from "os";
6064
- import { join as join13 } from "path";
6127
+ import { homedir as homedir5 } from "os";
6128
+ import { join as join14 } from "path";
6065
6129
  function getLocksDir() {
6066
- return join13(homedir4(), ".assist", "locks");
6130
+ return join14(homedir5(), ".assist", "locks");
6067
6131
  }
6068
6132
  function getLockPath(itemId2) {
6069
- return join13(getLocksDir(), `lock-${itemId2}.json`);
6133
+ return join14(getLocksDir(), `lock-${itemId2}.json`);
6070
6134
  }
6071
6135
  function isProcessAlive(pid) {
6072
6136
  try {
@@ -6192,21 +6256,6 @@ import chalk46 from "chalk";
6192
6256
  // src/commands/sessions/daemon/ensureHooksSettings.ts
6193
6257
  import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync15 } from "fs";
6194
6258
  import { dirname as dirname13 } from "path";
6195
-
6196
- // src/commands/sessions/daemon/daemonPaths.ts
6197
- import { homedir as homedir5 } from "os";
6198
- import { join as join14 } from "path";
6199
- var DAEMON_DIR = join14(homedir5(), ".assist", "daemon");
6200
- var daemonPaths = {
6201
- dir: DAEMON_DIR,
6202
- socket: process.platform === "win32" ? String.raw`\\.\pipe\assist-sessions-daemon` : join14(DAEMON_DIR, "daemon.sock"),
6203
- log: join14(DAEMON_DIR, "daemon.log"),
6204
- pid: join14(DAEMON_DIR, "daemon.pid"),
6205
- spawnLock: join14(DAEMON_DIR, "spawn.lock"),
6206
- hooksSettings: join14(DAEMON_DIR, "hooks-settings.json")
6207
- };
6208
-
6209
- // src/commands/sessions/daemon/ensureHooksSettings.ts
6210
6259
  var SET_STATUS = "assist sessions set-status";
6211
6260
  function running(source) {
6212
6261
  return `${SET_STATUS} running --source ${source}`;
@@ -7400,24 +7449,6 @@ Failed to launch Claude for ${context}: ${message3}`)
7400
7449
  }
7401
7450
  }
7402
7451
 
7403
- // src/commands/sessions/daemon/connectToDaemon.ts
7404
- import * as net from "net";
7405
- function connectToDaemon() {
7406
- return new Promise((resolve23, reject) => {
7407
- const socket = net.connect(daemonPaths.socket);
7408
- socket.once("connect", () => resolve23(socket));
7409
- socket.once("error", reject);
7410
- });
7411
- }
7412
- async function isDaemonRunning() {
7413
- try {
7414
- (await connectToDaemon()).destroy();
7415
- return true;
7416
- } catch {
7417
- return false;
7418
- }
7419
- }
7420
-
7421
7452
  // src/commands/sessions/daemon/sendToDaemon.ts
7422
7453
  var WRITE_TIMEOUT_MS = 500;
7423
7454
  function sendToDaemon(message3) {
@@ -22488,7 +22519,8 @@ function requestAssistSession(assistArgs, cwd, options2) {
22488
22519
  type: "create-assist",
22489
22520
  assistArgs,
22490
22521
  cwd,
22491
- inPlace: options2?.inPlace === true
22522
+ inPlace: options2?.inPlace === true,
22523
+ launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
22492
22524
  });
22493
22525
  }
22494
22526
 
@@ -29729,6 +29761,7 @@ function toSessionInfo(session) {
29729
29761
  starred,
29730
29762
  watcher,
29731
29763
  design,
29764
+ verifying,
29732
29765
  pendingPrPreview,
29733
29766
  undurable
29734
29767
  } = session;
@@ -29751,6 +29784,7 @@ function toSessionInfo(session) {
29751
29784
  starred,
29752
29785
  watcher,
29753
29786
  design,
29787
+ verifying,
29754
29788
  pendingPrPreview,
29755
29789
  undurable
29756
29790
  };
@@ -31921,6 +31955,14 @@ function restartManagedSession(sessions, id, clients, onStatusChange) {
31921
31955
  return { ok: true };
31922
31956
  }
31923
31957
 
31958
+ // src/commands/sessions/daemon/releaseClient.ts
31959
+ function releaseClient(client, clients, prPreview, verify) {
31960
+ clients.delete(client);
31961
+ clients.unsubscribeLogs(client);
31962
+ prPreview.clearWaiter(client);
31963
+ verify.clear(client);
31964
+ }
31965
+
31924
31966
  // src/commands/sessions/daemon/restoredAutoAdvance.ts
31925
31967
  function restoredAutoAdvance(id, persisted) {
31926
31968
  const itemId2 = persisted.activity?.itemId;
@@ -32819,6 +32861,41 @@ function treeSpawnContext(sessions, spawnWith, notify2, clients, onStatusChange)
32819
32861
  };
32820
32862
  }
32821
32863
 
32864
+ // src/commands/sessions/daemon/VerifyTracker.ts
32865
+ var VerifyTracker = class {
32866
+ constructor(sessions, notify2) {
32867
+ this.sessions = sessions;
32868
+ this.notify = notify2;
32869
+ }
32870
+ sessionByClient = /* @__PURE__ */ new Map();
32871
+ start(client, sessionId) {
32872
+ const session = this.sessions.get(sessionId);
32873
+ if (!session) {
32874
+ daemonLog(
32875
+ `verify-started for unknown session id=${sessionId} (ignoring)`
32876
+ );
32877
+ return;
32878
+ }
32879
+ daemonLog(`verify-started received: id=${sessionId}`);
32880
+ this.sessionByClient.set(client, sessionId);
32881
+ session.verifying = true;
32882
+ this.notify();
32883
+ }
32884
+ clear(client) {
32885
+ const sessionId = this.sessionByClient.get(client);
32886
+ if (!sessionId) return;
32887
+ this.sessionByClient.delete(client);
32888
+ if (this.stillVerifying(sessionId)) return;
32889
+ daemonLog(`verify connection closed: id=${sessionId}`);
32890
+ const session = this.sessions.get(sessionId);
32891
+ if (session) session.verifying = false;
32892
+ this.notify();
32893
+ }
32894
+ stillVerifying(sessionId) {
32895
+ return [...this.sessionByClient.values()].includes(sessionId);
32896
+ }
32897
+ };
32898
+
32822
32899
  // src/commands/sessions/daemon/connectToWindowsDaemon.ts
32823
32900
  import * as net2 from "net";
32824
32901
 
@@ -33541,7 +33618,8 @@ function createAssistSession(id, assistArgs, cwd, meta, holdPty) {
33541
33618
  ),
33542
33619
  scrollback: "",
33543
33620
  assistArgs,
33544
- cwd
33621
+ cwd,
33622
+ launchedFrom: meta?.launchedFrom
33545
33623
  };
33546
33624
  }
33547
33625
 
@@ -33806,6 +33884,7 @@ var SessionManager = class {
33806
33884
  );
33807
33885
  // why: dispatch calls active.set() on card click; broadcasts include active.toJSON()
33808
33886
  active = new ActiveSelection(() => this.notify());
33887
+ verify = new VerifyTracker(this.sessions, () => this.notify());
33809
33888
  clients = new ClientHub(persistUsagePeak);
33810
33889
  idCounter = { next: 1 };
33811
33890
  shuttingDown = false;
@@ -33817,9 +33896,7 @@ var SessionManager = class {
33817
33896
  greetClient(client, this.sessions, this.windowsProxy);
33818
33897
  }
33819
33898
  removeClient(client) {
33820
- this.clients.delete(client);
33821
- this.clients.unsubscribeLogs(client);
33822
- this.prPreview.clearWaiter(client);
33899
+ releaseClient(client, this.clients, this.prPreview, this.verify);
33823
33900
  this.onIdleChange?.(this.isIdle());
33824
33901
  }
33825
33902
  isIdle = () => this.sessions.size === 0 && this.clients.size === 0;
@@ -34146,7 +34223,8 @@ var messageHandlers = {
34146
34223
  {
34147
34224
  title: d.title,
34148
34225
  subtitle: d.subtitle,
34149
- inPlace: d.inPlace === true
34226
+ inPlace: d.inPlace === true,
34227
+ launchedFrom: d.launchedFrom
34150
34228
  }
34151
34229
  )
34152
34230
  ),
@@ -34200,6 +34278,7 @@ var messageHandlers = {
34200
34278
  ),
34201
34279
  "set-active": (_client, m, d) => m.active.set(d.cwd, d.sessionId),
34202
34280
  "set-status": handleSetStatus,
34281
+ "verify-started": (client, m, d) => m.verify.start(client, d.sessionId),
34203
34282
  "pr-preview": (client, m, d) => m.prPreview.set(client, d),
34204
34283
  "pr-decision": (_client, m, d) => m.prPreview.decide(d),
34205
34284
  "ui-status": (_client, _m, d) => daemonLog(`ui rendered: id=${d.sessionId} status=${d.status}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.526.0",
3
+ "version": "0.528.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {