@staff0rd/assist 0.1039.0 → 0.1040.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.1039.0",
9
+ version: "0.1040.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -12765,6 +12765,7 @@ function extensionUpdateStatus(connected, latest2) {
12765
12765
  connected,
12766
12766
  latest: latest2?.version,
12767
12767
  updateLink: behind ? latest2?.update_link : void 0,
12768
+ installLink: latest2?.update_link,
12768
12769
  behind
12769
12770
  };
12770
12771
  }
@@ -22610,6 +22611,26 @@ function isSchemaPath(filePath, incomingContents2 = [], root2 = getProjectRoot()
22610
22611
  );
22611
22612
  }
22612
22613
 
22614
+ // src/commands/cliHook/isSedPrint.ts
22615
+ var QUIET_LONG = /* @__PURE__ */ new Set(["--quiet", "--silent"]);
22616
+ function isShortFlagWith(token, letter) {
22617
+ return /^-[a-zA-Z]+$/.test(token) && token.includes(letter);
22618
+ }
22619
+ function hasWriteCommand(args) {
22620
+ return args.some((arg) => /[wW]$/.test(arg));
22621
+ }
22622
+ function isSedPrint(command) {
22623
+ const [name, ...args] = command.split(/\s+/);
22624
+ if (name !== "sed") return false;
22625
+ const quiet = args.some(
22626
+ (arg) => QUIET_LONG.has(arg) || isShortFlagWith(arg, "n")
22627
+ );
22628
+ const inPlace = args.some(
22629
+ (arg) => arg.startsWith("--in-place") || isShortFlagWith(arg, "i")
22630
+ );
22631
+ return quiet && !inPlace && !hasWriteCommand(args);
22632
+ }
22633
+
22613
22634
  // src/commands/cliHook/findSchemaPathDeny.ts
22614
22635
  var DB_PATH = /(?:^|[\s'"=(<>|;&:])(?:\.\/)?(src\/shared\/db\/[\w./-]*\.ts)(?![\w.-])/g;
22615
22636
  function mentionedDbPaths(command, root2) {
@@ -22617,15 +22638,18 @@ function mentionedDbPaths(command, root2) {
22617
22638
  const relativized = command.replace(/\\/g, "/").split(normalizedRoot).join("");
22618
22639
  return [...relativized.matchAll(DB_PATH)].map((match) => match[1]);
22619
22640
  }
22620
- function findSchemaPathDeny(toolName, rawCommand, root2 = getProjectRoot()) {
22641
+ function writesSchema(toolName, rawCommand, root2) {
22642
+ const touchesSchema = (part) => mentionedDbPaths(part, root2).some(
22643
+ (rel) => isSchemaRelativePath(rel, root2, [rawCommand])
22644
+ );
22621
22645
  const result = splitCompound(rawCommand);
22622
- const parts = result.ok ? result.parts : [rawCommand];
22623
- const writes = parts.some(
22624
- (part) => mentionedDbPaths(part, root2).some(
22625
- (rel) => isSchemaRelativePath(rel, root2, [rawCommand])
22626
- ) && !isApprovedRead(part, toolName)
22646
+ if (!result.ok) return touchesSchema(rawCommand);
22647
+ return result.parts.some(
22648
+ (part) => touchesSchema(part) && !isApprovedRead(part, toolName) && !isSedPrint(part)
22627
22649
  );
22628
- if (!writes) return void 0;
22650
+ }
22651
+ function findSchemaPathDeny(toolName, rawCommand, root2 = getProjectRoot()) {
22652
+ if (!writesSchema(toolName, rawCommand, root2)) return void 0;
22629
22653
  return {
22630
22654
  permissionDecision: "deny",
22631
22655
  permissionDecisionReason: SCHEMA_LOCK_REASON
@@ -50665,12 +50689,78 @@ function awaitTreeVacated(session, treePath) {
50665
50689
  });
50666
50690
  }
50667
50691
 
50692
+ // src/commands/sessions/daemon/worktree/describeOccupants.ts
50693
+ function describeOccupants(occupants) {
50694
+ if (occupants.length === 0) return void 0;
50695
+ const vscode = occupants.filter((o) => o.vscode).map((o) => o.pid);
50696
+ const others = /* @__PURE__ */ new Map();
50697
+ for (const o of occupants) {
50698
+ if (o.vscode) continue;
50699
+ others.set(o.name, [...others.get(o.name) ?? [], o.pid]);
50700
+ }
50701
+ const parts = [];
50702
+ if (vscode.length > 0)
50703
+ parts.push(`VS Code has this worktree open (${pidList(vscode)})`);
50704
+ if (others.size > 0) {
50705
+ const programs = [...others].map(
50706
+ ([name, pids]) => `${name} (${pidList(pids)})`
50707
+ );
50708
+ parts.push(`a live process is still running in it: ${programs.join(", ")}`);
50709
+ }
50710
+ return parts.join("; ");
50711
+ }
50712
+ function pidList(pids) {
50713
+ return `pid ${[...pids].sort((a, b) => a - b).join(", ")}`;
50714
+ }
50715
+
50716
+ // src/commands/sessions/daemon/worktree/readOccupant.ts
50717
+ import { readFileSync as readFileSync75 } from "fs";
50718
+ var VSCODE_PATHS = [
50719
+ "/.vscode-server/",
50720
+ "/.vscode-server-insiders/",
50721
+ "/.vscode-remote-containers/",
50722
+ "/usr/share/code/",
50723
+ "/usr/share/code-insiders/",
50724
+ "/Microsoft VS Code/"
50725
+ ];
50726
+ var MAX_ANCESTORS = 64;
50727
+ function readOccupant(pid, procRoot = "/proc") {
50728
+ return {
50729
+ pid,
50730
+ name: readProc(procRoot, pid, "comm")?.trim() || `pid ${pid}`,
50731
+ vscode: underVsCode(pid, procRoot)
50732
+ };
50733
+ }
50734
+ function underVsCode(pid, procRoot) {
50735
+ let current = pid;
50736
+ for (let depth = 0; current && current > 1 && depth < MAX_ANCESTORS; depth++) {
50737
+ const cmdline = readProc(procRoot, current, "cmdline");
50738
+ if (cmdline && VSCODE_PATHS.some((path109) => cmdline.includes(path109)))
50739
+ return true;
50740
+ current = parentPid(readProc(procRoot, current, "stat"));
50741
+ }
50742
+ return false;
50743
+ }
50744
+ function parentPid(stat5) {
50745
+ if (!stat5) return void 0;
50746
+ const fields = stat5.slice(stat5.lastIndexOf(")") + 2).split(" ");
50747
+ const ppid = Number(fields[1]);
50748
+ return Number.isInteger(ppid) ? ppid : void 0;
50749
+ }
50750
+ function readProc(procRoot, pid, file) {
50751
+ try {
50752
+ return readFileSync75(`${procRoot}/${pid}/${file}`, "utf8");
50753
+ } catch {
50754
+ return void 0;
50755
+ }
50756
+ }
50757
+
50668
50758
  // src/commands/sessions/daemon/worktree/liveOccupantReason.ts
50669
50759
  function liveOccupantReason(treePath) {
50670
50760
  stopInstall(treePath);
50671
- const pids = liveProcessesInTree(treePath);
50672
- if (pids.length === 0) return void 0;
50673
- return `a live process is still running in it (pid ${pids.join(", ")})`;
50761
+ return describeOccupants(
50762
+ liveProcessesInTree(treePath).map((pid) => readOccupant(pid))
50763
+ );
50674
50764
  }
50675
50765
 
50676
50766
  // src/commands/sessions/daemon/worktree/closeBlockReason.ts
@@ -56769,7 +56859,7 @@ function handleConnection(socket, manager) {
56769
56859
  import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync62 } from "fs";
56770
56860
 
56771
56861
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
56772
- import { readFileSync as readFileSync75 } from "fs";
56862
+ import { readFileSync as readFileSync76 } from "fs";
56773
56863
  var WATCHDOG_INTERVAL_MS = 5e3;
56774
56864
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
56775
56865
  const timer = setInterval(() => {
@@ -56780,7 +56870,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
56780
56870
  }
56781
56871
  function ownsPidFile() {
56782
56872
  try {
56783
- return readFileSync75(daemonPaths.pid, "utf8").trim() === String(process.pid);
56873
+ return readFileSync76(daemonPaths.pid, "utf8").trim() === String(process.pid);
56784
56874
  } catch {
56785
56875
  return false;
56786
56876
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1039.0",
3
+ "version": "0.1040.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {