@staff0rd/assist 0.665.0 → 0.665.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/commands/sessions/web/bundle.js +284 -284
- package/dist/index.js +72 -17
- 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.665.
|
|
9
|
+
version: "0.665.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -12563,10 +12563,64 @@ async function prList(req, res) {
|
|
|
12563
12563
|
respondJson(res, 200, { prs: await getOpenPrs(cwd) });
|
|
12564
12564
|
}
|
|
12565
12565
|
|
|
12566
|
-
// src/commands/sessions/web/
|
|
12566
|
+
// src/commands/sessions/web/ghAuthToken.ts
|
|
12567
12567
|
import { execFile as execFile6 } from "child_process";
|
|
12568
12568
|
import { promisify as promisify6 } from "util";
|
|
12569
12569
|
var execFileAsync5 = promisify6(execFile6);
|
|
12570
|
+
async function ghAuthToken(cwd) {
|
|
12571
|
+
const { stdout } = await execFileAsync5("gh", ["auth", "token"], {
|
|
12572
|
+
cwd,
|
|
12573
|
+
windowsHide: true
|
|
12574
|
+
});
|
|
12575
|
+
const token = stdout.trim();
|
|
12576
|
+
if (!token) throw new Error("gh auth token produced no token");
|
|
12577
|
+
return token;
|
|
12578
|
+
}
|
|
12579
|
+
|
|
12580
|
+
// src/commands/sessions/web/isUserAttachmentUrl.ts
|
|
12581
|
+
var USER_ATTACHMENT = /^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/;
|
|
12582
|
+
function isUserAttachmentUrl(url) {
|
|
12583
|
+
return USER_ATTACHMENT.test(url);
|
|
12584
|
+
}
|
|
12585
|
+
|
|
12586
|
+
// src/commands/sessions/web/previewImage.ts
|
|
12587
|
+
async function previewImage(req, res) {
|
|
12588
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
12589
|
+
const target = url.searchParams.get("url") ?? "";
|
|
12590
|
+
if (!isUserAttachmentUrl(target)) {
|
|
12591
|
+
respondJson(res, 400, { error: "Not a GitHub attachment url." });
|
|
12592
|
+
return;
|
|
12593
|
+
}
|
|
12594
|
+
let token;
|
|
12595
|
+
try {
|
|
12596
|
+
token = await ghAuthToken(url.searchParams.get("cwd") ?? void 0);
|
|
12597
|
+
} catch {
|
|
12598
|
+
respondJson(res, 502, { error: "Could not read a GitHub token." });
|
|
12599
|
+
return;
|
|
12600
|
+
}
|
|
12601
|
+
let location;
|
|
12602
|
+
try {
|
|
12603
|
+
const upstream = await fetch(target, {
|
|
12604
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
12605
|
+
redirect: "manual"
|
|
12606
|
+
});
|
|
12607
|
+
location = upstream.headers.get("location");
|
|
12608
|
+
} catch {
|
|
12609
|
+
respondJson(res, 502, { error: "Could not reach GitHub." });
|
|
12610
|
+
return;
|
|
12611
|
+
}
|
|
12612
|
+
if (!location) {
|
|
12613
|
+
respondJson(res, 404, { error: "Attachment is no longer available." });
|
|
12614
|
+
return;
|
|
12615
|
+
}
|
|
12616
|
+
res.writeHead(302, { Location: location, "Cache-Control": "no-store" });
|
|
12617
|
+
res.end();
|
|
12618
|
+
}
|
|
12619
|
+
|
|
12620
|
+
// src/commands/sessions/web/prStatus.ts
|
|
12621
|
+
import { execFile as execFile7 } from "child_process";
|
|
12622
|
+
import { promisify as promisify7 } from "util";
|
|
12623
|
+
var execFileAsync6 = promisify7(execFile7);
|
|
12570
12624
|
function toPrSummary(parsed) {
|
|
12571
12625
|
if (typeof parsed.number !== "number") return null;
|
|
12572
12626
|
return {
|
|
@@ -12596,7 +12650,7 @@ var getOpenPrForBranch = createCachedGhJson(
|
|
|
12596
12650
|
);
|
|
12597
12651
|
async function getCurrentBranch(cwd) {
|
|
12598
12652
|
try {
|
|
12599
|
-
const { stdout } = await
|
|
12653
|
+
const { stdout } = await execFileAsync6(
|
|
12600
12654
|
"git",
|
|
12601
12655
|
["rev-parse", "--abbrev-ref", "HEAD"],
|
|
12602
12656
|
{ encoding: "utf8", windowsHide: true, cwd: toGitCwd(cwd) }
|
|
@@ -13440,9 +13494,9 @@ function unsetConfig(req, res) {
|
|
|
13440
13494
|
import { rm } from "fs/promises";
|
|
13441
13495
|
|
|
13442
13496
|
// src/commands/sessions/web/runGhImage.ts
|
|
13443
|
-
import { execFile as
|
|
13444
|
-
import { promisify as
|
|
13445
|
-
var
|
|
13497
|
+
import { execFile as execFile8 } from "child_process";
|
|
13498
|
+
import { promisify as promisify8 } from "util";
|
|
13499
|
+
var execFileAsync7 = promisify8(execFile8);
|
|
13446
13500
|
var GhImageUnavailableError = class extends Error {
|
|
13447
13501
|
name = "GhImageUnavailableError";
|
|
13448
13502
|
};
|
|
@@ -13451,7 +13505,7 @@ var INSTALL_HINT = `Install the gh-image extension: ${GH_IMAGE_INSTALL_COMMAND}`
|
|
|
13451
13505
|
async function runGhImage(filePath, cwd) {
|
|
13452
13506
|
let stdout;
|
|
13453
13507
|
try {
|
|
13454
|
-
({ stdout } = await
|
|
13508
|
+
({ stdout } = await execFileAsync7("gh", ["image", filePath], {
|
|
13455
13509
|
cwd,
|
|
13456
13510
|
windowsHide: true,
|
|
13457
13511
|
maxBuffer: 10 * 1024 * 1024
|
|
@@ -13595,11 +13649,11 @@ async function uploadPrImage(req, res) {
|
|
|
13595
13649
|
import { readFile as readFile2, stat as stat3, writeFile as writeFile3 } from "fs/promises";
|
|
13596
13650
|
|
|
13597
13651
|
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
13598
|
-
import { execFile as
|
|
13652
|
+
import { execFile as execFile9 } from "child_process";
|
|
13599
13653
|
import { existsSync as existsSync37 } from "fs";
|
|
13600
13654
|
import { dirname as dirname23, join as join35 } from "path";
|
|
13601
|
-
import { promisify as
|
|
13602
|
-
var
|
|
13655
|
+
import { promisify as promisify9 } from "util";
|
|
13656
|
+
var execFileAsync8 = promisify9(execFile9);
|
|
13603
13657
|
var TIMEOUT_MS = 15e3;
|
|
13604
13658
|
function findOxfmtScript(root) {
|
|
13605
13659
|
let dir = root;
|
|
@@ -13614,7 +13668,7 @@ function findOxfmtScript(root) {
|
|
|
13614
13668
|
async function formatWithOxfmt(target, root) {
|
|
13615
13669
|
const script = findOxfmtScript(root);
|
|
13616
13670
|
if (!script) return;
|
|
13617
|
-
await
|
|
13671
|
+
await execFileAsync8(process.execPath, [script, target], {
|
|
13618
13672
|
cwd: root,
|
|
13619
13673
|
windowsHide: true,
|
|
13620
13674
|
timeout: TIMEOUT_MS
|
|
@@ -13730,6 +13784,7 @@ var routes2 = {
|
|
|
13730
13784
|
"GET /api/backlog/summary": getBacklogSummary,
|
|
13731
13785
|
"POST /api/open-in-code": openInCode,
|
|
13732
13786
|
"POST /api/pr-preview/upload-image": uploadPrImage,
|
|
13787
|
+
"GET /api/pr-preview/image": previewImage,
|
|
13733
13788
|
"POST /api/restart": restartWeb,
|
|
13734
13789
|
"GET /api/github-url": githubUrl,
|
|
13735
13790
|
"GET /api/git-status": gitStatus,
|
|
@@ -24451,7 +24506,7 @@ function resolveInstallCommand(repoRoot2, install) {
|
|
|
24451
24506
|
}
|
|
24452
24507
|
|
|
24453
24508
|
// src/commands/sessions/daemon/worktree/stopInstall.ts
|
|
24454
|
-
import { execFile as
|
|
24509
|
+
import { execFile as execFile10 } from "child_process";
|
|
24455
24510
|
var running2 = /* @__PURE__ */ new Map();
|
|
24456
24511
|
function trackInstall(worktreePath, child) {
|
|
24457
24512
|
running2.set(worktreePath, child);
|
|
@@ -24470,7 +24525,7 @@ function stopInstall(worktreePath) {
|
|
|
24470
24525
|
}
|
|
24471
24526
|
function killTree(pid) {
|
|
24472
24527
|
if (process.platform === "win32") {
|
|
24473
|
-
|
|
24528
|
+
execFile10(
|
|
24474
24529
|
"taskkill",
|
|
24475
24530
|
["/T", "/F", "/PID", String(pid)],
|
|
24476
24531
|
{ windowsHide: true },
|
|
@@ -37943,13 +37998,13 @@ function isBacklogItemId(text18) {
|
|
|
37943
37998
|
}
|
|
37944
37999
|
|
|
37945
38000
|
// src/commands/sessions/daemon/generateSessionTitle.ts
|
|
37946
|
-
import { execFile as
|
|
37947
|
-
import { promisify as
|
|
37948
|
-
var
|
|
38001
|
+
import { execFile as execFile11 } from "child_process";
|
|
38002
|
+
import { promisify as promisify10 } from "util";
|
|
38003
|
+
var execFileAsync9 = promisify10(execFile11);
|
|
37949
38004
|
var SESSION_TITLE_MAX_LENGTH = 48;
|
|
37950
38005
|
async function generateSessionTitle(prompt) {
|
|
37951
38006
|
try {
|
|
37952
|
-
const { stdout } = await
|
|
38007
|
+
const { stdout } = await execFileAsync9(
|
|
37953
38008
|
"claude",
|
|
37954
38009
|
["-p", "--model", "haiku", buildPrompt5(prompt)],
|
|
37955
38010
|
{ encoding: "utf8", windowsHide: true, timeout: 3e4 }
|