@staff0rd/assist 0.414.0 → 0.415.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/commands/sessions/web/bundle.js +359 -359
- package/dist/index.js +58 -44
- package/package.json +1 -1
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.
|
|
9
|
+
version: "0.415.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -3597,9 +3597,9 @@ function forbiddenStrings() {
|
|
|
3597
3597
|
console.log("No forbidden-strings rules configured.");
|
|
3598
3598
|
process.exit(0);
|
|
3599
3599
|
}
|
|
3600
|
-
const
|
|
3600
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
3601
3601
|
const readJson = (file) => {
|
|
3602
|
-
if (
|
|
3602
|
+
if (cache2.has(file)) return cache2.get(file);
|
|
3603
3603
|
if (!existsSync12(file)) {
|
|
3604
3604
|
console.log(`Forbidden-strings file not found: ${file}`);
|
|
3605
3605
|
process.exit(1);
|
|
@@ -3611,7 +3611,7 @@ function forbiddenStrings() {
|
|
|
3611
3611
|
console.log(`Could not parse ${file}: ${error.message}`);
|
|
3612
3612
|
process.exit(1);
|
|
3613
3613
|
}
|
|
3614
|
-
|
|
3614
|
+
cache2.set(file, parsed);
|
|
3615
3615
|
return parsed;
|
|
3616
3616
|
};
|
|
3617
3617
|
const violations = findForbiddenStrings(rules, readJson);
|
|
@@ -8003,18 +8003,18 @@ import { dirname as dirname19, join as join22 } from "path";
|
|
|
8003
8003
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
8004
8004
|
function createBundleHandler(importMetaUrl, bundlePath) {
|
|
8005
8005
|
const dir = dirname19(fileURLToPath4(importMetaUrl));
|
|
8006
|
-
let
|
|
8006
|
+
let cache2;
|
|
8007
8007
|
return (req, res) => {
|
|
8008
|
-
if (!
|
|
8008
|
+
if (!cache2) {
|
|
8009
8009
|
const body = readFileSync18(join22(dir, bundlePath), "utf8");
|
|
8010
8010
|
const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
8011
|
-
|
|
8011
|
+
cache2 = { body, etag };
|
|
8012
8012
|
}
|
|
8013
8013
|
const headers = {
|
|
8014
|
-
ETag:
|
|
8014
|
+
ETag: cache2.etag,
|
|
8015
8015
|
"Cache-Control": "no-cache"
|
|
8016
8016
|
};
|
|
8017
|
-
if (req.headers["if-none-match"] ===
|
|
8017
|
+
if (req.headers["if-none-match"] === cache2.etag) {
|
|
8018
8018
|
res.writeHead(304, headers);
|
|
8019
8019
|
res.end();
|
|
8020
8020
|
return;
|
|
@@ -8023,7 +8023,7 @@ function createBundleHandler(importMetaUrl, bundlePath) {
|
|
|
8023
8023
|
"Content-Type": "application/javascript",
|
|
8024
8024
|
...headers
|
|
8025
8025
|
});
|
|
8026
|
-
res.end(
|
|
8026
|
+
res.end(cache2.body);
|
|
8027
8027
|
};
|
|
8028
8028
|
}
|
|
8029
8029
|
|
|
@@ -8531,9 +8531,24 @@ function getCwdParam(req, res) {
|
|
|
8531
8531
|
return cwd;
|
|
8532
8532
|
}
|
|
8533
8533
|
|
|
8534
|
+
// src/commands/sessions/web/windowsCwdToWslPath.ts
|
|
8535
|
+
function windowsCwdToWslPath(cwd) {
|
|
8536
|
+
const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
|
|
8537
|
+
if (!match) return cwd;
|
|
8538
|
+
const drive = match[1].toLowerCase();
|
|
8539
|
+
const rest = match[2].replace(/\\/g, "/");
|
|
8540
|
+
return `/mnt/${drive}/${rest}`;
|
|
8541
|
+
}
|
|
8542
|
+
|
|
8543
|
+
// src/commands/sessions/web/toGitCwd.ts
|
|
8544
|
+
function toGitCwd(cwd) {
|
|
8545
|
+
return detectPlatform() === "wsl" ? windowsCwdToWslPath(cwd) : cwd;
|
|
8546
|
+
}
|
|
8547
|
+
|
|
8534
8548
|
// src/commands/sessions/web/handleServerRuns.ts
|
|
8535
|
-
function getServerRuns(
|
|
8549
|
+
function getServerRuns(rawCwd) {
|
|
8536
8550
|
try {
|
|
8551
|
+
const cwd = toGitCwd(rawCwd);
|
|
8537
8552
|
const { run: run4 } = loadConfigFrom(cwd);
|
|
8538
8553
|
return resolveRunConfigs(run4, getConfigDirFrom(cwd)).filter((r) => r.server).map((r) => ({ name: r.name, port: r.port }));
|
|
8539
8554
|
} catch {
|
|
@@ -8565,20 +8580,6 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
|
8565
8580
|
return synthesisFiles[0]?.path ?? null;
|
|
8566
8581
|
}
|
|
8567
8582
|
|
|
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
8583
|
// src/commands/sessions/web/getReviewSynthesis.ts
|
|
8583
8584
|
var execFileAsync2 = promisify2(execFile2);
|
|
8584
8585
|
function runGit(cwd, args) {
|
|
@@ -8979,11 +8980,11 @@ var execFileAsync4 = promisify5(execFile4);
|
|
|
8979
8980
|
var CACHE_TTL_MS = 3e4;
|
|
8980
8981
|
function createCachedGhJson(args, parse3, fallback, options2 = {}) {
|
|
8981
8982
|
const { cacheFallback = true } = options2;
|
|
8982
|
-
const
|
|
8983
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
8983
8984
|
return async (cwd, extraArgs = []) => {
|
|
8984
8985
|
const key = extraArgs.length ? `${cwd}\0${extraArgs.join("\0")}` : cwd;
|
|
8985
8986
|
const now = Date.now();
|
|
8986
|
-
const cached =
|
|
8987
|
+
const cached = cache2.get(key);
|
|
8987
8988
|
if (cached && cached.expires > now) return cached.value;
|
|
8988
8989
|
let value = fallback;
|
|
8989
8990
|
try {
|
|
@@ -8996,7 +8997,7 @@ function createCachedGhJson(args, parse3, fallback, options2 = {}) {
|
|
|
8996
8997
|
value = fallback;
|
|
8997
8998
|
}
|
|
8998
8999
|
if (cacheFallback || value !== fallback)
|
|
8999
|
-
|
|
9000
|
+
cache2.set(key, { value, expires: now + CACHE_TTL_MS });
|
|
9000
9001
|
return value;
|
|
9001
9002
|
};
|
|
9002
9003
|
}
|
|
@@ -9196,22 +9197,22 @@ import { readFileSync as readFileSync21 } from "fs";
|
|
|
9196
9197
|
import { createRequire as createRequire2 } from "module";
|
|
9197
9198
|
var require3 = createRequire2(import.meta.url);
|
|
9198
9199
|
function createCssHandler(packageEntry) {
|
|
9199
|
-
let
|
|
9200
|
+
let cache2;
|
|
9200
9201
|
return (req, res) => {
|
|
9201
|
-
if (!
|
|
9202
|
+
if (!cache2) {
|
|
9202
9203
|
const resolved = require3.resolve(packageEntry);
|
|
9203
9204
|
const body = readFileSync21(resolved, "utf8");
|
|
9204
9205
|
const etag = `"${createHash2("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
9205
|
-
|
|
9206
|
+
cache2 = { body, etag };
|
|
9206
9207
|
}
|
|
9207
|
-
const headers = { ETag:
|
|
9208
|
-
if (req.headers["if-none-match"] ===
|
|
9208
|
+
const headers = { ETag: cache2.etag, "Cache-Control": "no-cache" };
|
|
9209
|
+
if (req.headers["if-none-match"] === cache2.etag) {
|
|
9209
9210
|
res.writeHead(304, headers);
|
|
9210
9211
|
res.end();
|
|
9211
9212
|
return;
|
|
9212
9213
|
}
|
|
9213
9214
|
res.writeHead(200, { "Content-Type": "text/css", ...headers });
|
|
9214
|
-
res.end(
|
|
9215
|
+
res.end(cache2.body);
|
|
9215
9216
|
};
|
|
9216
9217
|
}
|
|
9217
9218
|
|
|
@@ -17723,20 +17724,20 @@ function resolveThread(threadId) {
|
|
|
17723
17724
|
}
|
|
17724
17725
|
}
|
|
17725
17726
|
function requireCache(prNumber) {
|
|
17726
|
-
const
|
|
17727
|
-
if (!
|
|
17727
|
+
const cache2 = loadCommentsCache(prNumber);
|
|
17728
|
+
if (!cache2) {
|
|
17728
17729
|
console.error(
|
|
17729
17730
|
`Error: No cached comments found for PR #${prNumber}. Run "assist prs list-comments" first.`
|
|
17730
17731
|
);
|
|
17731
17732
|
process.exit(1);
|
|
17732
17733
|
}
|
|
17733
|
-
return
|
|
17734
|
+
return cache2;
|
|
17734
17735
|
}
|
|
17735
17736
|
function findLineComment(comments3, commentId) {
|
|
17736
17737
|
return comments3.find((c) => c.type === "line" && c.id === commentId);
|
|
17737
17738
|
}
|
|
17738
|
-
function requireLineComment(
|
|
17739
|
-
const comment3 = findLineComment(
|
|
17739
|
+
function requireLineComment(cache2, commentId) {
|
|
17740
|
+
const comment3 = findLineComment(cache2.comments, commentId);
|
|
17740
17741
|
if (!comment3 || comment3.type !== "line" || !comment3.threadId) {
|
|
17741
17742
|
console.error(
|
|
17742
17743
|
`Error: Comment #${commentId} not found or has no thread ID.`
|
|
@@ -17745,8 +17746,8 @@ function requireLineComment(cache, commentId) {
|
|
|
17745
17746
|
}
|
|
17746
17747
|
return comment3;
|
|
17747
17748
|
}
|
|
17748
|
-
function cleanupCacheIfDone(
|
|
17749
|
-
const hasRemaining =
|
|
17749
|
+
function cleanupCacheIfDone(cache2, prNumber, commentId) {
|
|
17750
|
+
const hasRemaining = cache2.comments.some(
|
|
17750
17751
|
(c) => c.type === "line" && c.id !== commentId
|
|
17751
17752
|
);
|
|
17752
17753
|
if (!hasRemaining) deleteCommentsCache(prNumber);
|
|
@@ -17754,13 +17755,13 @@ function cleanupCacheIfDone(cache, prNumber, commentId) {
|
|
|
17754
17755
|
function resolveCommentWithReply(commentId, message) {
|
|
17755
17756
|
const prNumber = getCurrentPrNumber();
|
|
17756
17757
|
const { org, repo } = getRepoInfo();
|
|
17757
|
-
const
|
|
17758
|
-
const comment3 = requireLineComment(
|
|
17758
|
+
const cache2 = requireCache(prNumber);
|
|
17759
|
+
const comment3 = requireLineComment(cache2, commentId);
|
|
17759
17760
|
replyToComment(org, repo, prNumber, commentId, message);
|
|
17760
17761
|
console.log("Reply posted successfully.");
|
|
17761
17762
|
resolveThread(comment3.threadId);
|
|
17762
17763
|
console.log("Thread resolved successfully.");
|
|
17763
|
-
cleanupCacheIfDone(
|
|
17764
|
+
cleanupCacheIfDone(cache2, prNumber, commentId);
|
|
17764
17765
|
}
|
|
17765
17766
|
|
|
17766
17767
|
// src/commands/prs/fixed.ts
|
|
@@ -24777,6 +24778,17 @@ function broadcast(clients, msg) {
|
|
|
24777
24778
|
}
|
|
24778
24779
|
}
|
|
24779
24780
|
|
|
24781
|
+
// src/commands/sessions/daemon/originForCwd.ts
|
|
24782
|
+
var cache = /* @__PURE__ */ new Map();
|
|
24783
|
+
function originForCwd(cwd) {
|
|
24784
|
+
if (!cwd) return void 0;
|
|
24785
|
+
const cached = cache.get(cwd);
|
|
24786
|
+
if (cached !== void 0) return cached;
|
|
24787
|
+
const origin = getCurrentOrigin(cwd);
|
|
24788
|
+
cache.set(cwd, origin);
|
|
24789
|
+
return origin;
|
|
24790
|
+
}
|
|
24791
|
+
|
|
24780
24792
|
// src/commands/sessions/daemon/toSessionInfo.ts
|
|
24781
24793
|
function toSessionInfo({
|
|
24782
24794
|
id,
|
|
@@ -24793,6 +24805,7 @@ function toSessionInfo({
|
|
|
24793
24805
|
runArgs,
|
|
24794
24806
|
server,
|
|
24795
24807
|
serverPort,
|
|
24808
|
+
serverOrigin,
|
|
24796
24809
|
assistArgs,
|
|
24797
24810
|
cwd,
|
|
24798
24811
|
restored,
|
|
@@ -24820,6 +24833,7 @@ function toSessionInfo({
|
|
|
24820
24833
|
runArgs,
|
|
24821
24834
|
server,
|
|
24822
24835
|
port: serverPort,
|
|
24836
|
+
remoteOrigin: serverOrigin ?? originForCwd(cwd),
|
|
24823
24837
|
assistArgs,
|
|
24824
24838
|
cwd,
|
|
24825
24839
|
restored,
|