@staff0rd/assist 0.414.0 → 0.415.1

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.414.0",
9
+ version: "0.415.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -220,15 +220,38 @@ function mergeDenyRules(globalDeny, projectDeny) {
220
220
  const globalOnly = globalDeny.filter((r) => !projectPatterns.has(r.pattern));
221
221
  return [...globalOnly, ...projectDeny];
222
222
  }
223
+ function runKey(r) {
224
+ return typeof r.name === "string" ? r.name : void 0;
225
+ }
226
+ function mergeRunConfigs(globalRun, projectRun) {
227
+ if (!globalRun && !projectRun) return void 0;
228
+ if (!globalRun) return projectRun;
229
+ if (!projectRun) return globalRun;
230
+ const projectNames = new Set(
231
+ projectRun.map(runKey).filter((n) => n !== void 0)
232
+ );
233
+ const globalOnly = globalRun.filter((r) => {
234
+ const key = runKey(r);
235
+ return key === void 0 || !projectNames.has(key);
236
+ });
237
+ return [...globalOnly, ...projectRun];
238
+ }
223
239
  function mergeRawConfigs(globalRaw, projectRaw) {
224
240
  const deny = mergeDenyRules(
225
241
  globalRaw.deny,
226
242
  projectRaw.deny
227
243
  );
244
+ const run4 = mergeRunConfigs(
245
+ globalRaw.run,
246
+ projectRaw.run
247
+ );
228
248
  const merged = { ...globalRaw, ...projectRaw };
229
249
  if (deny !== void 0) {
230
250
  merged.deny = deny;
231
251
  }
252
+ if (run4 !== void 0) {
253
+ merged.run = run4;
254
+ }
232
255
  const globalSubtasks = globalRaw.subtasks;
233
256
  const projectSubtasks = projectRaw.subtasks;
234
257
  if (globalSubtasks || projectSubtasks) {
@@ -3597,9 +3620,9 @@ function forbiddenStrings() {
3597
3620
  console.log("No forbidden-strings rules configured.");
3598
3621
  process.exit(0);
3599
3622
  }
3600
- const cache = /* @__PURE__ */ new Map();
3623
+ const cache2 = /* @__PURE__ */ new Map();
3601
3624
  const readJson = (file) => {
3602
- if (cache.has(file)) return cache.get(file);
3625
+ if (cache2.has(file)) return cache2.get(file);
3603
3626
  if (!existsSync12(file)) {
3604
3627
  console.log(`Forbidden-strings file not found: ${file}`);
3605
3628
  process.exit(1);
@@ -3611,7 +3634,7 @@ function forbiddenStrings() {
3611
3634
  console.log(`Could not parse ${file}: ${error.message}`);
3612
3635
  process.exit(1);
3613
3636
  }
3614
- cache.set(file, parsed);
3637
+ cache2.set(file, parsed);
3615
3638
  return parsed;
3616
3639
  };
3617
3640
  const violations = findForbiddenStrings(rules, readJson);
@@ -8003,18 +8026,18 @@ import { dirname as dirname19, join as join22 } from "path";
8003
8026
  import { fileURLToPath as fileURLToPath4 } from "url";
8004
8027
  function createBundleHandler(importMetaUrl, bundlePath) {
8005
8028
  const dir = dirname19(fileURLToPath4(importMetaUrl));
8006
- let cache;
8029
+ let cache2;
8007
8030
  return (req, res) => {
8008
- if (!cache) {
8031
+ if (!cache2) {
8009
8032
  const body = readFileSync18(join22(dir, bundlePath), "utf8");
8010
8033
  const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
8011
- cache = { body, etag };
8034
+ cache2 = { body, etag };
8012
8035
  }
8013
8036
  const headers = {
8014
- ETag: cache.etag,
8037
+ ETag: cache2.etag,
8015
8038
  "Cache-Control": "no-cache"
8016
8039
  };
8017
- if (req.headers["if-none-match"] === cache.etag) {
8040
+ if (req.headers["if-none-match"] === cache2.etag) {
8018
8041
  res.writeHead(304, headers);
8019
8042
  res.end();
8020
8043
  return;
@@ -8023,7 +8046,7 @@ function createBundleHandler(importMetaUrl, bundlePath) {
8023
8046
  "Content-Type": "application/javascript",
8024
8047
  ...headers
8025
8048
  });
8026
- res.end(cache.body);
8049
+ res.end(cache2.body);
8027
8050
  };
8028
8051
  }
8029
8052
 
@@ -8531,9 +8554,24 @@ function getCwdParam(req, res) {
8531
8554
  return cwd;
8532
8555
  }
8533
8556
 
8557
+ // src/commands/sessions/web/windowsCwdToWslPath.ts
8558
+ function windowsCwdToWslPath(cwd) {
8559
+ const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
8560
+ if (!match) return cwd;
8561
+ const drive = match[1].toLowerCase();
8562
+ const rest = match[2].replace(/\\/g, "/");
8563
+ return `/mnt/${drive}/${rest}`;
8564
+ }
8565
+
8566
+ // src/commands/sessions/web/toGitCwd.ts
8567
+ function toGitCwd(cwd) {
8568
+ return detectPlatform() === "wsl" ? windowsCwdToWslPath(cwd) : cwd;
8569
+ }
8570
+
8534
8571
  // src/commands/sessions/web/handleServerRuns.ts
8535
- function getServerRuns(cwd) {
8572
+ function getServerRuns(rawCwd) {
8536
8573
  try {
8574
+ const cwd = toGitCwd(rawCwd);
8537
8575
  const { run: run4 } = loadConfigFrom(cwd);
8538
8576
  return resolveRunConfigs(run4, getConfigDirFrom(cwd)).filter((r) => r.server).map((r) => ({ name: r.name, port: r.port }));
8539
8577
  } catch {
@@ -8565,20 +8603,6 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
8565
8603
  return synthesisFiles[0]?.path ?? null;
8566
8604
  }
8567
8605
 
8568
- // src/commands/sessions/web/windowsCwdToWslPath.ts
8569
- function windowsCwdToWslPath(cwd) {
8570
- const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
8571
- if (!match) return cwd;
8572
- const drive = match[1].toLowerCase();
8573
- const rest = match[2].replace(/\\/g, "/");
8574
- return `/mnt/${drive}/${rest}`;
8575
- }
8576
-
8577
- // src/commands/sessions/web/toGitCwd.ts
8578
- function toGitCwd(cwd) {
8579
- return detectPlatform() === "wsl" ? windowsCwdToWslPath(cwd) : cwd;
8580
- }
8581
-
8582
8606
  // src/commands/sessions/web/getReviewSynthesis.ts
8583
8607
  var execFileAsync2 = promisify2(execFile2);
8584
8608
  function runGit(cwd, args) {
@@ -8979,11 +9003,11 @@ var execFileAsync4 = promisify5(execFile4);
8979
9003
  var CACHE_TTL_MS = 3e4;
8980
9004
  function createCachedGhJson(args, parse3, fallback, options2 = {}) {
8981
9005
  const { cacheFallback = true } = options2;
8982
- const cache = /* @__PURE__ */ new Map();
9006
+ const cache2 = /* @__PURE__ */ new Map();
8983
9007
  return async (cwd, extraArgs = []) => {
8984
9008
  const key = extraArgs.length ? `${cwd}\0${extraArgs.join("\0")}` : cwd;
8985
9009
  const now = Date.now();
8986
- const cached = cache.get(key);
9010
+ const cached = cache2.get(key);
8987
9011
  if (cached && cached.expires > now) return cached.value;
8988
9012
  let value = fallback;
8989
9013
  try {
@@ -8996,7 +9020,7 @@ function createCachedGhJson(args, parse3, fallback, options2 = {}) {
8996
9020
  value = fallback;
8997
9021
  }
8998
9022
  if (cacheFallback || value !== fallback)
8999
- cache.set(key, { value, expires: now + CACHE_TTL_MS });
9023
+ cache2.set(key, { value, expires: now + CACHE_TTL_MS });
9000
9024
  return value;
9001
9025
  };
9002
9026
  }
@@ -9196,22 +9220,22 @@ import { readFileSync as readFileSync21 } from "fs";
9196
9220
  import { createRequire as createRequire2 } from "module";
9197
9221
  var require3 = createRequire2(import.meta.url);
9198
9222
  function createCssHandler(packageEntry) {
9199
- let cache;
9223
+ let cache2;
9200
9224
  return (req, res) => {
9201
- if (!cache) {
9225
+ if (!cache2) {
9202
9226
  const resolved = require3.resolve(packageEntry);
9203
9227
  const body = readFileSync21(resolved, "utf8");
9204
9228
  const etag = `"${createHash2("sha256").update(body).digest("hex").slice(0, 16)}"`;
9205
- cache = { body, etag };
9229
+ cache2 = { body, etag };
9206
9230
  }
9207
- const headers = { ETag: cache.etag, "Cache-Control": "no-cache" };
9208
- if (req.headers["if-none-match"] === cache.etag) {
9231
+ const headers = { ETag: cache2.etag, "Cache-Control": "no-cache" };
9232
+ if (req.headers["if-none-match"] === cache2.etag) {
9209
9233
  res.writeHead(304, headers);
9210
9234
  res.end();
9211
9235
  return;
9212
9236
  }
9213
9237
  res.writeHead(200, { "Content-Type": "text/css", ...headers });
9214
- res.end(cache.body);
9238
+ res.end(cache2.body);
9215
9239
  };
9216
9240
  }
9217
9241
 
@@ -17723,20 +17747,20 @@ function resolveThread(threadId) {
17723
17747
  }
17724
17748
  }
17725
17749
  function requireCache(prNumber) {
17726
- const cache = loadCommentsCache(prNumber);
17727
- if (!cache) {
17750
+ const cache2 = loadCommentsCache(prNumber);
17751
+ if (!cache2) {
17728
17752
  console.error(
17729
17753
  `Error: No cached comments found for PR #${prNumber}. Run "assist prs list-comments" first.`
17730
17754
  );
17731
17755
  process.exit(1);
17732
17756
  }
17733
- return cache;
17757
+ return cache2;
17734
17758
  }
17735
17759
  function findLineComment(comments3, commentId) {
17736
17760
  return comments3.find((c) => c.type === "line" && c.id === commentId);
17737
17761
  }
17738
- function requireLineComment(cache, commentId) {
17739
- const comment3 = findLineComment(cache.comments, commentId);
17762
+ function requireLineComment(cache2, commentId) {
17763
+ const comment3 = findLineComment(cache2.comments, commentId);
17740
17764
  if (!comment3 || comment3.type !== "line" || !comment3.threadId) {
17741
17765
  console.error(
17742
17766
  `Error: Comment #${commentId} not found or has no thread ID.`
@@ -17745,8 +17769,8 @@ function requireLineComment(cache, commentId) {
17745
17769
  }
17746
17770
  return comment3;
17747
17771
  }
17748
- function cleanupCacheIfDone(cache, prNumber, commentId) {
17749
- const hasRemaining = cache.comments.some(
17772
+ function cleanupCacheIfDone(cache2, prNumber, commentId) {
17773
+ const hasRemaining = cache2.comments.some(
17750
17774
  (c) => c.type === "line" && c.id !== commentId
17751
17775
  );
17752
17776
  if (!hasRemaining) deleteCommentsCache(prNumber);
@@ -17754,13 +17778,13 @@ function cleanupCacheIfDone(cache, prNumber, commentId) {
17754
17778
  function resolveCommentWithReply(commentId, message) {
17755
17779
  const prNumber = getCurrentPrNumber();
17756
17780
  const { org, repo } = getRepoInfo();
17757
- const cache = requireCache(prNumber);
17758
- const comment3 = requireLineComment(cache, commentId);
17781
+ const cache2 = requireCache(prNumber);
17782
+ const comment3 = requireLineComment(cache2, commentId);
17759
17783
  replyToComment(org, repo, prNumber, commentId, message);
17760
17784
  console.log("Reply posted successfully.");
17761
17785
  resolveThread(comment3.threadId);
17762
17786
  console.log("Thread resolved successfully.");
17763
- cleanupCacheIfDone(cache, prNumber, commentId);
17787
+ cleanupCacheIfDone(cache2, prNumber, commentId);
17764
17788
  }
17765
17789
 
17766
17790
  // src/commands/prs/fixed.ts
@@ -24777,6 +24801,17 @@ function broadcast(clients, msg) {
24777
24801
  }
24778
24802
  }
24779
24803
 
24804
+ // src/commands/sessions/daemon/originForCwd.ts
24805
+ var cache = /* @__PURE__ */ new Map();
24806
+ function originForCwd(cwd) {
24807
+ if (!cwd) return void 0;
24808
+ const cached = cache.get(cwd);
24809
+ if (cached !== void 0) return cached;
24810
+ const origin = getCurrentOrigin(cwd);
24811
+ cache.set(cwd, origin);
24812
+ return origin;
24813
+ }
24814
+
24780
24815
  // src/commands/sessions/daemon/toSessionInfo.ts
24781
24816
  function toSessionInfo({
24782
24817
  id,
@@ -24793,6 +24828,7 @@ function toSessionInfo({
24793
24828
  runArgs,
24794
24829
  server,
24795
24830
  serverPort,
24831
+ serverOrigin,
24796
24832
  assistArgs,
24797
24833
  cwd,
24798
24834
  restored,
@@ -24820,6 +24856,7 @@ function toSessionInfo({
24820
24856
  runArgs,
24821
24857
  server,
24822
24858
  port: serverPort,
24859
+ remoteOrigin: serverOrigin ?? originForCwd(cwd),
24823
24860
  assistArgs,
24824
24861
  cwd,
24825
24862
  restored,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.414.0",
3
+ "version": "0.415.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {