@staff0rd/assist 0.424.0 → 0.425.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.424.0",
9
+ version: "0.425.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -68,6 +68,8 @@ var package_default = {
68
68
  "node-pty": "^1.1.0",
69
69
  pg: "^8.21.0",
70
70
  "pg-copy-streams": "^7.0.0",
71
+ "react-diff-view": "^3.3.3",
72
+ refractor: "^3.6.0",
71
73
  semver: "^7.7.3",
72
74
  "shell-quote": "^1.8.3",
73
75
  "ts-morph": "^27.0.2",
@@ -3394,11 +3396,11 @@ function collectFileComments(file, lines, project) {
3394
3396
  // src/commands/verify/blockCodeComments/parseDiffAddedLines.ts
3395
3397
  var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
3396
3398
  var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
3397
- function parseDiffAddedLines(diff2) {
3399
+ function parseDiffAddedLines(diff3) {
3398
3400
  const added = /* @__PURE__ */ new Map();
3399
3401
  let currentFile = null;
3400
3402
  let newLine = 0;
3401
- for (const line of diff2.split("\n")) {
3403
+ for (const line of diff3.split("\n")) {
3402
3404
  const fileMatch = line.match(FILE_HEADER);
3403
3405
  if (fileMatch) {
3404
3406
  const file = fileMatch[1];
@@ -3446,11 +3448,11 @@ function shouldScan(file, ignoreGlobs) {
3446
3448
  return fs15.existsSync(file);
3447
3449
  }
3448
3450
  function findComments(options2) {
3449
- const diff2 = execSync10("git diff HEAD", {
3451
+ const diff3 = execSync10("git diff HEAD", {
3450
3452
  encoding: "utf8",
3451
3453
  maxBuffer: 64 * 1024 * 1024
3452
3454
  });
3453
- const addedLines = parseDiffAddedLines(diff2);
3455
+ const addedLines = parseDiffAddedLines(diff3);
3454
3456
  const project = new Project2({
3455
3457
  skipAddingFilesFromTsConfig: true,
3456
3458
  compilerOptions: { allowJs: true }
@@ -8043,7 +8045,7 @@ import { createHash } from "crypto";
8043
8045
  import { readFileSync as readFileSync18 } from "fs";
8044
8046
  import { dirname as dirname19, join as join22 } from "path";
8045
8047
  import { fileURLToPath as fileURLToPath4 } from "url";
8046
- function createBundleHandler(importMetaUrl, bundlePath) {
8048
+ function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
8047
8049
  const dir = dirname19(fileURLToPath4(importMetaUrl));
8048
8050
  let cache2;
8049
8051
  return (req, res) => {
@@ -8062,7 +8064,7 @@ function createBundleHandler(importMetaUrl, bundlePath) {
8062
8064
  return;
8063
8065
  }
8064
8066
  res.writeHead(200, {
8065
- "Content-Type": "application/javascript",
8067
+ "Content-Type": contentType,
8066
8068
  ...headers
8067
8069
  });
8068
8070
  res.end(cache2.body);
@@ -8520,6 +8522,75 @@ async function handleItemRoute(req, res, pathname) {
8520
8522
  return false;
8521
8523
  }
8522
8524
 
8525
+ // src/commands/sessions/web/execGit.ts
8526
+ import { execFile as execFile2 } from "child_process";
8527
+ import { promisify as promisify2 } from "util";
8528
+ var execFileAsync2 = promisify2(execFile2);
8529
+ async function execGit(cwd, args, opts = {}) {
8530
+ const { maxBuffer, allowFailure } = opts;
8531
+ const { file, argv } = /^[A-Za-z]:[\\/]/.test(cwd) ? { file: "git.exe", argv: ["-C", cwd, ...args] } : { file: "git", argv: args };
8532
+ try {
8533
+ const { stdout } = await execFileAsync2(file, argv, {
8534
+ encoding: "utf8",
8535
+ ...maxBuffer ? { maxBuffer } : {},
8536
+ ...file === "git" ? { cwd } : {}
8537
+ });
8538
+ return stdout;
8539
+ } catch (error) {
8540
+ if (allowFailure && error && typeof error === "object" && "stdout" in error) {
8541
+ return String(error.stdout);
8542
+ }
8543
+ throw error;
8544
+ }
8545
+ }
8546
+
8547
+ // src/commands/sessions/web/getCwdParam.ts
8548
+ function getCwdParam(req, res) {
8549
+ const url = new URL(req.url ?? "/", "http://localhost");
8550
+ const cwd = url.searchParams.get("cwd");
8551
+ if (!cwd) {
8552
+ respondJson(res, 400, { error: "Missing cwd" });
8553
+ return null;
8554
+ }
8555
+ return cwd;
8556
+ }
8557
+
8558
+ // src/commands/sessions/web/diff.ts
8559
+ var MAX_DIFF_BYTES = 50 * 1024 * 1024;
8560
+ async function untrackedFileDiff(cwd, path71) {
8561
+ return execGit(cwd, ["diff", "--no-index", "--", "/dev/null", path71], {
8562
+ maxBuffer: MAX_DIFF_BYTES,
8563
+ allowFailure: true
8564
+ });
8565
+ }
8566
+ async function untrackedDiff(cwd) {
8567
+ const list5 = await execGit(cwd, [
8568
+ "ls-files",
8569
+ "--others",
8570
+ "--exclude-standard"
8571
+ ]);
8572
+ const paths = list5.split("\n").filter(Boolean);
8573
+ const diffs = await Promise.all(
8574
+ paths.map((path71) => untrackedFileDiff(cwd, path71))
8575
+ );
8576
+ return diffs.join("");
8577
+ }
8578
+ async function diff2(req, res) {
8579
+ const cwd = getCwdParam(req, res);
8580
+ if (!cwd) return;
8581
+ try {
8582
+ const tracked = await execGit(cwd, ["diff", "HEAD"], {
8583
+ maxBuffer: MAX_DIFF_BYTES
8584
+ });
8585
+ const untracked = await untrackedDiff(cwd);
8586
+ res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
8587
+ res.end(tracked + untracked);
8588
+ } catch {
8589
+ res.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
8590
+ res.end("");
8591
+ }
8592
+ }
8593
+
8523
8594
  // src/shared/db/listBackups.ts
8524
8595
  import { desc } from "drizzle-orm";
8525
8596
  async function listBackups(db) {
@@ -8540,6 +8611,7 @@ function getHtml() {
8540
8611
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
8541
8612
  <title>Assist</title>
8542
8613
  <link rel="stylesheet" href="/xterm.css">
8614
+ <link rel="stylesheet" href="/bundle.css">
8543
8615
  <style>
8544
8616
  * { margin: 0; padding: 0; box-sizing: border-box; }
8545
8617
  html, body, #app { width: 100%; height: 100%; }
@@ -8562,17 +8634,6 @@ function getHtml() {
8562
8634
  </html>`;
8563
8635
  }
8564
8636
 
8565
- // src/commands/sessions/web/getCwdParam.ts
8566
- function getCwdParam(req, res) {
8567
- const url = new URL(req.url ?? "/", "http://localhost");
8568
- const cwd = url.searchParams.get("cwd");
8569
- if (!cwd) {
8570
- respondJson(res, 400, { error: "Missing cwd" });
8571
- return null;
8572
- }
8573
- return cwd;
8574
- }
8575
-
8576
8637
  // src/commands/sessions/web/windowsCwdToWslPath.ts
8577
8638
  function windowsCwdToWslPath(cwd) {
8578
8639
  const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
@@ -8604,11 +8665,11 @@ function handleServerRuns(req, res) {
8604
8665
  }
8605
8666
 
8606
8667
  // src/commands/sessions/web/getReviewSynthesis.ts
8607
- import { execFile as execFile2 } from "child_process";
8668
+ import { execFile as execFile3 } from "child_process";
8608
8669
  import { readFileSync as readFileSync19 } from "fs";
8609
8670
  import { homedir as homedir11 } from "os";
8610
8671
  import { basename as basename6, join as join25 } from "path";
8611
- import { promisify as promisify2 } from "util";
8672
+ import { promisify as promisify3 } from "util";
8612
8673
 
8613
8674
  // src/commands/sessions/web/findSynthesisForBranch.ts
8614
8675
  import { existsSync as existsSync26, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
@@ -8623,9 +8684,9 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
8623
8684
  }
8624
8685
 
8625
8686
  // src/commands/sessions/web/getReviewSynthesis.ts
8626
- var execFileAsync2 = promisify2(execFile2);
8687
+ var execFileAsync3 = promisify3(execFile3);
8627
8688
  function runGit(cwd, args) {
8628
- return execFileAsync2("git", args, {
8689
+ return execFileAsync3("git", args, {
8629
8690
  encoding: "utf8",
8630
8691
  cwd: toGitCwd(cwd)
8631
8692
  }).then((r) => r.stdout.trim());
@@ -8668,10 +8729,6 @@ function githubUrl(req, res) {
8668
8729
  });
8669
8730
  }
8670
8731
 
8671
- // src/commands/sessions/web/gitStatus.ts
8672
- import { execFile as execFile3 } from "child_process";
8673
- import { promisify as promisify3 } from "util";
8674
-
8675
8732
  // src/commands/sessions/web/parseGitStatus.ts
8676
8733
  function extractPath(rest) {
8677
8734
  const arrow = rest.indexOf(" -> ");
@@ -8700,24 +8757,20 @@ function parseGitStatus(output) {
8700
8757
  }
8701
8758
 
8702
8759
  // src/commands/sessions/web/gitStatus.ts
8703
- var execFileAsync3 = promisify3(execFile3);
8704
8760
  async function gitStatus(req, res) {
8705
8761
  const cwd = getCwdParam(req, res);
8706
8762
  if (!cwd) return;
8707
8763
  try {
8708
- respondJson(res, 200, parseGitStatus(await runGitStatus(cwd)));
8764
+ const output = await execGit(cwd, [
8765
+ "status",
8766
+ "--porcelain",
8767
+ "--untracked-files=all"
8768
+ ]);
8769
+ respondJson(res, 200, parseGitStatus(output));
8709
8770
  } catch {
8710
8771
  respondJson(res, 200, { new: [], modified: [], deleted: [] });
8711
8772
  }
8712
8773
  }
8713
- function runGitStatus(cwd) {
8714
- const args = ["status", "--porcelain", "--untracked-files=all"];
8715
- const { file, argv } = /^[A-Za-z]:[\\/]/.test(cwd) ? { file: "git.exe", argv: ["-C", cwd, ...args] } : { file: "git", argv: args };
8716
- return execFileAsync3(file, argv, {
8717
- encoding: "utf8",
8718
- ...file === "git" ? { cwd } : {}
8719
- }).then((r) => r.stdout);
8720
- }
8721
8774
 
8722
8775
  // src/shared/harnesses.ts
8723
8776
  import * as os3 from "os";
@@ -9267,12 +9320,18 @@ var routes2 = {
9267
9320
  "commands/sessions/web/bundle.js"
9268
9321
  ),
9269
9322
  "GET /xterm.css": createCssHandler("@xterm/xterm/css/xterm.css"),
9323
+ "GET /bundle.css": createBundleHandler(
9324
+ import.meta.url,
9325
+ "commands/sessions/web/bundle.css",
9326
+ "text/css"
9327
+ ),
9270
9328
  "GET /api/items": listItems,
9271
9329
  "GET /api/backlog/summary": getBacklogSummary,
9272
9330
  "POST /api/open-in-code": openInCode,
9273
9331
  "POST /api/restart": restartWeb,
9274
9332
  "GET /api/github-url": githubUrl,
9275
9333
  "GET /api/git-status": gitStatus,
9334
+ "GET /api/diff": diff2,
9276
9335
  "GET /api/jira-site": jiraSite,
9277
9336
  "GET /api/harness": harnessCapabilities,
9278
9337
  "GET /api/pr-status": prStatus,
@@ -20834,10 +20893,10 @@ function gutter(lineNumber) {
20834
20893
  const label2 = lineNumber === null ? "" : String(lineNumber);
20835
20894
  return `${label2.padStart(GUTTER_WIDTH, " ")} `;
20836
20895
  }
20837
- function annotateDiffWithLineNumbers(diff2) {
20896
+ function annotateDiffWithLineNumbers(diff3) {
20838
20897
  let inFile = false;
20839
20898
  let newLine = 0;
20840
- return diff2.split("\n").map((line) => {
20899
+ return diff3.split("\n").map((line) => {
20841
20900
  if (FILE_HEADER2.test(line)) {
20842
20901
  inFile = true;
20843
20902
  return gutter(null) + line;
@@ -21080,7 +21139,7 @@ function gatherContext() {
21080
21139
  }).trim();
21081
21140
  const prInfo = fetchPrDiffInfo();
21082
21141
  const changedFiles = fetchPrChangedFiles(prInfo.prNumber);
21083
- const diff2 = fetchPrDiff(prInfo.prNumber, prInfo.baseSha, prInfo.headSha);
21142
+ const diff3 = fetchPrDiff(prInfo.prNumber, prInfo.baseSha, prInfo.headSha);
21084
21143
  return {
21085
21144
  branch: branch2,
21086
21145
  sha,
@@ -21091,7 +21150,7 @@ function gatherContext() {
21091
21150
  headRef: prInfo.headRef,
21092
21151
  headSha: prInfo.headSha,
21093
21152
  changedFiles,
21094
- diff: diff2
21153
+ diff: diff3
21095
21154
  };
21096
21155
  }
21097
21156
 
@@ -21306,11 +21365,11 @@ async function postAndMaybeSubmit(lineBound, markdown, options2) {
21306
21365
  // src/commands/review/buildDiffLineIndex.ts
21307
21366
  var FILE_HEADER3 = /^\+\+\+ (?:b\/)?(.+)$/;
21308
21367
  var HUNK_HEADER3 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
21309
- function buildDiffLineIndex(diff2) {
21368
+ function buildDiffLineIndex(diff3) {
21310
21369
  const index3 = /* @__PURE__ */ new Map();
21311
21370
  let currentFile = null;
21312
21371
  let newLine = 0;
21313
- for (const line of diff2.split("\n")) {
21372
+ for (const line of diff3.split("\n")) {
21314
21373
  const fileMatch = line.match(FILE_HEADER3);
21315
21374
  if (fileMatch) {
21316
21375
  currentFile = fileMatch[1] === "/dev/null" ? null : fileMatch[1];
@@ -21377,10 +21436,10 @@ function warnOutOfDiff(outOfDiff) {
21377
21436
 
21378
21437
  // src/commands/review/selectInDiffFindings.ts
21379
21438
  function selectInDiffFindings(lineBound, prDiff) {
21380
- const diff2 = fetchPrDiff(prDiff.prNumber, prDiff.baseSha, prDiff.headSha);
21439
+ const diff3 = fetchPrDiff(prDiff.prNumber, prDiff.baseSha, prDiff.headSha);
21381
21440
  const { inDiff, outOfDiff } = partitionFindingsByDiff(
21382
21441
  lineBound,
21383
- buildDiffLineIndex(diff2)
21442
+ buildDiffLineIndex(diff3)
21384
21443
  );
21385
21444
  warnOutOfDiff(outOfDiff);
21386
21445
  return inDiff;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.424.0",
3
+ "version": "0.425.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -62,6 +62,8 @@
62
62
  "node-pty": "^1.1.0",
63
63
  "pg": "^8.21.0",
64
64
  "pg-copy-streams": "^7.0.0",
65
+ "react-diff-view": "^3.3.3",
66
+ "refractor": "^3.6.0",
65
67
  "semver": "^7.7.3",
66
68
  "shell-quote": "^1.8.3",
67
69
  "ts-morph": "^27.0.2",