@staff0rd/assist 0.866.0 → 0.868.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.866.0",
9
+ version: "0.868.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -14108,6 +14108,48 @@ async function getReviewSynthesis(req, res) {
14108
14108
  }
14109
14109
  }
14110
14110
 
14111
+ // src/commands/sessions/web/githubFileContent.ts
14112
+ import { execFile as execFile7 } from "child_process";
14113
+ import { promisify as promisify6 } from "util";
14114
+ var execFileAsync6 = promisify6(execFile7);
14115
+ var MAX_FILE_BYTES2 = 2 * 1024 * 1024;
14116
+ var REPO = /^[\w.-]+\/[\w.-]+$/;
14117
+ var SHA = /^[0-9a-f]{7,40}$/i;
14118
+ function validPath(path109) {
14119
+ return path109.length > 0 && !path109.startsWith("/") && path109.split("/").every((part) => part !== "" && part !== "..");
14120
+ }
14121
+ function ghFailure(error) {
14122
+ const stderr = error.stderr;
14123
+ if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
14124
+ return error instanceof Error ? error.message : "gh api failed";
14125
+ }
14126
+ async function githubFileContent(req, res) {
14127
+ const params = new URL(req.url ?? "/", "http://localhost").searchParams;
14128
+ const repo = params.get("repo") ?? "";
14129
+ const sha = params.get("sha") ?? "";
14130
+ const path109 = params.get("path") ?? "";
14131
+ if (!REPO.test(repo) || !SHA.test(sha) || !validPath(path109)) {
14132
+ respondJson(res, 400, { error: "Invalid repo, sha or path" });
14133
+ return;
14134
+ }
14135
+ const encodedPath = path109.split("/").map(encodeURIComponent).join("/");
14136
+ try {
14137
+ const { stdout } = await execFileAsync6(
14138
+ "gh",
14139
+ [
14140
+ "api",
14141
+ "-H",
14142
+ "Accept: application/vnd.github.raw",
14143
+ `repos/${repo}/contents/${encodedPath}?ref=${sha}`
14144
+ ],
14145
+ { encoding: "utf8", windowsHide: true, maxBuffer: MAX_FILE_BYTES2 }
14146
+ );
14147
+ respondJson(res, 200, { content: stdout });
14148
+ } catch (error) {
14149
+ respondJson(res, 502, { error: ghFailure(error) });
14150
+ }
14151
+ }
14152
+
14111
14153
  // src/commands/sessions/web/githubUrl.ts
14112
14154
  function githubUrl(req, res) {
14113
14155
  const cwd = getCwdParam(req, res);
@@ -14637,9 +14679,9 @@ function newsNavConfig(_req, res) {
14637
14679
  }
14638
14680
 
14639
14681
  // src/commands/sessions/web/releases/ghJson.ts
14640
- import { execFile as execFile7 } from "child_process";
14641
- import { promisify as promisify6 } from "util";
14642
- var execFileAsync6 = promisify6(execFile7);
14682
+ import { execFile as execFile8 } from "child_process";
14683
+ import { promisify as promisify7 } from "util";
14684
+ var execFileAsync7 = promisify7(execFile8);
14643
14685
  var CACHE_TTL_MS4 = 3e4;
14644
14686
  var cache3 = /* @__PURE__ */ new Map();
14645
14687
  function partialGraphqlData(error) {
@@ -14654,7 +14696,7 @@ function partialGraphqlData(error) {
14654
14696
  }
14655
14697
  async function runGh(cwd, args) {
14656
14698
  try {
14657
- const { stdout } = await execFileAsync6("gh", args, {
14699
+ const { stdout } = await execFileAsync7("gh", args, {
14658
14700
  encoding: "utf8",
14659
14701
  windowsHide: true,
14660
14702
  cwd,
@@ -15769,8 +15811,8 @@ function listUsageItems(req, res) {
15769
15811
 
15770
15812
  // src/commands/sessions/web/openInCode.ts
15771
15813
  import { exec } from "child_process";
15772
- import { promisify as promisify7 } from "util";
15773
- var execAsync = promisify7(exec);
15814
+ import { promisify as promisify8 } from "util";
15815
+ var execAsync = promisify8(exec);
15774
15816
  async function openInCode(req, res) {
15775
15817
  const cwd = getCwdParam(req, res);
15776
15818
  if (!cwd) return;
@@ -15786,9 +15828,9 @@ async function openInCode(req, res) {
15786
15828
  }
15787
15829
 
15788
15830
  // src/commands/sessions/web/createCachedGhJson.ts
15789
- import { execFile as execFile8 } from "child_process";
15790
- import { promisify as promisify8 } from "util";
15791
- var execFileAsync7 = promisify8(execFile8);
15831
+ import { execFile as execFile9 } from "child_process";
15832
+ import { promisify as promisify9 } from "util";
15833
+ var execFileAsync8 = promisify9(execFile9);
15792
15834
  var CACHE_TTL_MS5 = 3e4;
15793
15835
  function createCachedGhJson(args, parse5, fallback, options2 = {}) {
15794
15836
  const { cacheFallback = true } = options2;
@@ -15800,7 +15842,7 @@ function createCachedGhJson(args, parse5, fallback, options2 = {}) {
15800
15842
  if (cached && cached.expires > now) return cached.value;
15801
15843
  let value = fallback;
15802
15844
  try {
15803
- const { stdout } = await execFileAsync7("gh", [...args, ...extraArgs], {
15845
+ const { stdout } = await execFileAsync8("gh", [...args, ...extraArgs], {
15804
15846
  encoding: "utf8",
15805
15847
  windowsHide: true,
15806
15848
  cwd
@@ -16040,12 +16082,12 @@ async function previewImage(req, res) {
16040
16082
  }
16041
16083
 
16042
16084
  // src/commands/sessions/web/getCurrentBranch.ts
16043
- import { execFile as execFile9 } from "child_process";
16044
- import { promisify as promisify9 } from "util";
16045
- var execFileAsync8 = promisify9(execFile9);
16085
+ import { execFile as execFile10 } from "child_process";
16086
+ import { promisify as promisify10 } from "util";
16087
+ var execFileAsync9 = promisify10(execFile10);
16046
16088
  async function getCurrentBranch(cwd) {
16047
16089
  try {
16048
- const { stdout } = await execFileAsync8(
16090
+ const { stdout } = await execFileAsync9(
16049
16091
  "git",
16050
16092
  ["rev-parse", "--abbrev-ref", "HEAD"],
16051
16093
  { encoding: "utf8", windowsHide: true, cwd }
@@ -18273,11 +18315,11 @@ async function uploadPrImage(req, res) {
18273
18315
  import { readFile as readFile3, stat as stat4, writeFile as writeFile3 } from "fs/promises";
18274
18316
 
18275
18317
  // src/commands/sessions/web/formatWithOxfmt.ts
18276
- import { execFile as execFile10 } from "child_process";
18318
+ import { execFile as execFile11 } from "child_process";
18277
18319
  import { existsSync as existsSync40 } from "fs";
18278
18320
  import { dirname as dirname24, join as join46 } from "path";
18279
- import { promisify as promisify10 } from "util";
18280
- var execFileAsync9 = promisify10(execFile10);
18321
+ import { promisify as promisify11 } from "util";
18322
+ var execFileAsync10 = promisify11(execFile11);
18281
18323
  var TIMEOUT_MS = 15e3;
18282
18324
  function findOxfmtScript(root2) {
18283
18325
  let dir = root2;
@@ -18292,7 +18334,7 @@ function findOxfmtScript(root2) {
18292
18334
  async function formatWithOxfmt(target, root2) {
18293
18335
  const script = findOxfmtScript(root2);
18294
18336
  if (!script) return;
18295
- await execFileAsync9(process.execPath, [script, target], {
18337
+ await execFileAsync10(process.execPath, [script, target], {
18296
18338
  cwd: root2,
18297
18339
  windowsHide: true,
18298
18340
  timeout: TIMEOUT_MS
@@ -18465,6 +18507,7 @@ var routes2 = {
18465
18507
  "GET /api/node-doctor": nodeDoctor,
18466
18508
  "POST /api/self-update": selfUpdate,
18467
18509
  "GET /api/github-url": githubUrl,
18510
+ "GET /api/github-file": githubFileContent,
18468
18511
  "GET /api/git-status": gitStatus,
18469
18512
  "GET /api/diff": diff2,
18470
18513
  "GET /api/diff-scopes": diffScopes,
@@ -27616,7 +27659,7 @@ function quoteForPosixShell(value) {
27616
27659
  }
27617
27660
 
27618
27661
  // src/commands/sessions/daemon/worktree/stopInstall.ts
27619
- import { execFile as execFile11 } from "child_process";
27662
+ import { execFile as execFile12 } from "child_process";
27620
27663
  var running2 = /* @__PURE__ */ new Map();
27621
27664
  function trackInstall(worktreePath, child) {
27622
27665
  running2.set(worktreePath, child);
@@ -27637,7 +27680,7 @@ function stopInstall(worktreePath) {
27637
27680
  }
27638
27681
  function killTree(pid) {
27639
27682
  if (process.platform === "win32") {
27640
- execFile11(
27683
+ execFile12(
27641
27684
  "taskkill",
27642
27685
  ["/T", "/F", "/PID", String(pid)],
27643
27686
  { windowsHide: true },
@@ -36359,6 +36402,7 @@ function highLevelPreviewPayload(subject) {
36359
36402
  const {
36360
36403
  repo,
36361
36404
  prNumber,
36405
+ headSha,
36362
36406
  checks: checks2,
36363
36407
  structure,
36364
36408
  criticalDiffs,
@@ -36371,6 +36415,7 @@ function highLevelPreviewPayload(subject) {
36371
36415
  return {
36372
36416
  repo,
36373
36417
  prNumber,
36418
+ headSha,
36374
36419
  checks: checks2,
36375
36420
  structure,
36376
36421
  criticalDiffs,
@@ -45895,13 +45940,13 @@ function isBacklogItemId(text18) {
45895
45940
  }
45896
45941
 
45897
45942
  // src/commands/sessions/daemon/generateSessionTitle.ts
45898
- import { execFile as execFile12 } from "child_process";
45899
- import { promisify as promisify11 } from "util";
45900
- var execFileAsync10 = promisify11(execFile12);
45943
+ import { execFile as execFile13 } from "child_process";
45944
+ import { promisify as promisify12 } from "util";
45945
+ var execFileAsync11 = promisify12(execFile13);
45901
45946
  var SESSION_TITLE_MAX_LENGTH = 48;
45902
45947
  async function generateSessionTitle(prompt) {
45903
45948
  try {
45904
- const { stdout } = await execFileAsync10(
45949
+ const { stdout } = await execFileAsync11(
45905
45950
  "claude",
45906
45951
  ["-p", "--model", "haiku", buildPrompt5(prompt)],
45907
45952
  { encoding: "utf8", windowsHide: true, timeout: 3e4 }
@@ -50499,11 +50544,11 @@ var sessionSettingHandlers = {
50499
50544
  };
50500
50545
 
50501
50546
  // src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
50502
- import { execFile as execFile13 } from "child_process";
50547
+ import { execFile as execFile14 } from "child_process";
50503
50548
  import { existsSync as existsSync100 } from "fs";
50504
50549
  function prHeadBranch2(number, cwd) {
50505
50550
  return new Promise((resolve30) => {
50506
- execFile13(
50551
+ execFile14(
50507
50552
  "gh",
50508
50553
  ["pr", "view", number, "--json", "headRefName", "-q", ".headRefName"],
50509
50554
  { cwd, encoding: "utf8", windowsHide: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.866.0",
3
+ "version": "0.868.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {