@staff0rd/assist 0.836.0 → 0.838.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.
|
|
9
|
+
version: "0.838.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -12608,17 +12608,6 @@ async function fileContent(req, res) {
|
|
|
12608
12608
|
}
|
|
12609
12609
|
}
|
|
12610
12610
|
|
|
12611
|
-
// src/commands/sessions/shared/requestClaudeSession.ts
|
|
12612
|
-
function requestClaudeSession(prompt, cwd, options2) {
|
|
12613
|
-
return requestSession({
|
|
12614
|
-
type: "create",
|
|
12615
|
-
prompt,
|
|
12616
|
-
cwd,
|
|
12617
|
-
inPlace: options2?.inPlace === true,
|
|
12618
|
-
launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
|
|
12619
|
-
});
|
|
12620
|
-
}
|
|
12621
|
-
|
|
12622
12611
|
// src/commands/sessions/web/readJsonBody.ts
|
|
12623
12612
|
async function readJsonBody(req) {
|
|
12624
12613
|
const chunks = [];
|
|
@@ -12637,6 +12626,60 @@ function allowExtensionOrigin(req, res) {
|
|
|
12637
12626
|
res.setHeader("Vary", "Origin");
|
|
12638
12627
|
}
|
|
12639
12628
|
|
|
12629
|
+
// src/commands/sessions/web/fromGithub/launchFromGithub.ts
|
|
12630
|
+
async function launchFromGithub(req, res, plan2, launch) {
|
|
12631
|
+
allowExtensionOrigin(req, res);
|
|
12632
|
+
let body;
|
|
12633
|
+
try {
|
|
12634
|
+
body = await readJsonBody(req);
|
|
12635
|
+
} catch {
|
|
12636
|
+
respondJson(res, 400, { error: "Invalid JSON body" });
|
|
12637
|
+
return;
|
|
12638
|
+
}
|
|
12639
|
+
const planned = plan2(body, expandTilde2(loadConfig().clone.baseDir));
|
|
12640
|
+
if (!planned.ok) {
|
|
12641
|
+
respondJson(res, planned.status, { error: planned.error });
|
|
12642
|
+
return;
|
|
12643
|
+
}
|
|
12644
|
+
try {
|
|
12645
|
+
const sessionId = await launch(planned);
|
|
12646
|
+
respondJson(res, 200, { sessionId, cwd: planned.cwd });
|
|
12647
|
+
} catch (error) {
|
|
12648
|
+
respondJson(res, 500, {
|
|
12649
|
+
error: error instanceof Error ? error.message : String(error)
|
|
12650
|
+
});
|
|
12651
|
+
}
|
|
12652
|
+
}
|
|
12653
|
+
|
|
12654
|
+
// src/shared/githubPullNumber.ts
|
|
12655
|
+
var PULL_PATH = /^\/[^/]+\/[^/]+\/pull\/(\d+)(?:\/|$)/;
|
|
12656
|
+
function githubPullNumber(url) {
|
|
12657
|
+
let parsed;
|
|
12658
|
+
try {
|
|
12659
|
+
parsed = new URL(url);
|
|
12660
|
+
} catch {
|
|
12661
|
+
return void 0;
|
|
12662
|
+
}
|
|
12663
|
+
return PULL_PATH.exec(parsed.pathname)?.[1];
|
|
12664
|
+
}
|
|
12665
|
+
|
|
12666
|
+
// src/shared/reviewButtonModes.ts
|
|
12667
|
+
var reviewButtonModes = [
|
|
12668
|
+
{ label: "Review", args: ["review"] },
|
|
12669
|
+
{ label: "Review & refine", args: ["review", "--refine"] },
|
|
12670
|
+
{ label: "Review & apply", args: ["review", "--apply"] },
|
|
12671
|
+
{ label: "Review & post", args: ["review", "--no-prompt", "--submit"] },
|
|
12672
|
+
{ label: "High-level review", args: ["review", "--high-level"] }
|
|
12673
|
+
];
|
|
12674
|
+
|
|
12675
|
+
// src/shared/isReviewModeArgs.ts
|
|
12676
|
+
function isReviewModeArgs(args) {
|
|
12677
|
+
if (!Array.isArray(args)) return false;
|
|
12678
|
+
return reviewButtonModes.some(
|
|
12679
|
+
(mode) => mode.args.length === args.length && mode.args.every((arg, index2) => arg === args[index2])
|
|
12680
|
+
);
|
|
12681
|
+
}
|
|
12682
|
+
|
|
12640
12683
|
// src/commands/sessions/web/fromGithub/parseGithubOrigin.ts
|
|
12641
12684
|
function parseGithubOrigin(url) {
|
|
12642
12685
|
let parsed;
|
|
@@ -12652,12 +12695,12 @@ function parseGithubOrigin(url) {
|
|
|
12652
12695
|
return `github.com/${owner}/${repo.replace(/\.git$/i, "")}`;
|
|
12653
12696
|
}
|
|
12654
12697
|
|
|
12655
|
-
// src/commands/sessions/web/fromGithub/
|
|
12656
|
-
function
|
|
12657
|
-
const { url, instructions } = body ?? {};
|
|
12698
|
+
// src/commands/sessions/web/fromGithub/resolveGithubClone.ts
|
|
12699
|
+
function resolveGithubClone(url, baseDir) {
|
|
12658
12700
|
if (typeof url !== "string" || !url.trim())
|
|
12659
12701
|
return { ok: false, status: 400, error: "Missing url" };
|
|
12660
|
-
const
|
|
12702
|
+
const trimmed = url.trim();
|
|
12703
|
+
const origin = parseGithubOrigin(trimmed);
|
|
12661
12704
|
if (!origin)
|
|
12662
12705
|
return { ok: false, status: 400, error: `Not a GitHub repo URL: ${url}` };
|
|
12663
12706
|
const { cwd } = resolveRepoLocation(origin, void 0, baseDir);
|
|
@@ -12667,36 +12710,63 @@ function planGithubSession(body, baseDir) {
|
|
|
12667
12710
|
status: 404,
|
|
12668
12711
|
error: `${origin.replace("github.com/", "")} is not cloned under ${baseDir}`
|
|
12669
12712
|
};
|
|
12713
|
+
return { ok: true, url: trimmed, cwd };
|
|
12714
|
+
}
|
|
12715
|
+
|
|
12716
|
+
// src/commands/sessions/web/fromGithub/planGithubReview.ts
|
|
12717
|
+
function planGithubReview(body, baseDir) {
|
|
12718
|
+
const { url, args } = body ?? {};
|
|
12719
|
+
if (!isReviewModeArgs(args))
|
|
12720
|
+
return { ok: false, status: 400, error: "Unsupported assist args" };
|
|
12721
|
+
const prNumber = typeof url === "string" ? githubPullNumber(url.trim()) : "";
|
|
12722
|
+
if (!prNumber)
|
|
12723
|
+
return { ok: false, status: 400, error: `Not a GitHub PR URL: ${url}` };
|
|
12724
|
+
const clone = resolveGithubClone(url, baseDir);
|
|
12725
|
+
if (!clone.ok) return clone;
|
|
12726
|
+
return { ok: true, cwd: clone.cwd, assistArgs: [...args, prNumber] };
|
|
12727
|
+
}
|
|
12728
|
+
|
|
12729
|
+
// src/commands/sessions/web/fromGithub/reviewFromGithub.ts
|
|
12730
|
+
function reviewFromGithub(req, res) {
|
|
12731
|
+
return launchFromGithub(
|
|
12732
|
+
req,
|
|
12733
|
+
res,
|
|
12734
|
+
planGithubReview,
|
|
12735
|
+
(plan2) => requestAssistSession(plan2.assistArgs, plan2.cwd)
|
|
12736
|
+
);
|
|
12737
|
+
}
|
|
12738
|
+
|
|
12739
|
+
// src/commands/sessions/shared/requestClaudeSession.ts
|
|
12740
|
+
function requestClaudeSession(prompt, cwd, options2) {
|
|
12741
|
+
return requestSession({
|
|
12742
|
+
type: "create",
|
|
12743
|
+
prompt,
|
|
12744
|
+
cwd,
|
|
12745
|
+
inPlace: options2?.inPlace === true,
|
|
12746
|
+
launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
|
|
12747
|
+
});
|
|
12748
|
+
}
|
|
12749
|
+
|
|
12750
|
+
// src/commands/sessions/web/fromGithub/planGithubSession.ts
|
|
12751
|
+
function planGithubSession(body, baseDir) {
|
|
12752
|
+
const { url, instructions } = body ?? {};
|
|
12753
|
+
const clone = resolveGithubClone(url, baseDir);
|
|
12754
|
+
if (!clone.ok) return clone;
|
|
12670
12755
|
const extra = typeof instructions === "string" ? instructions.trim() : "";
|
|
12671
|
-
const prompt = extra ? `${url
|
|
12756
|
+
const prompt = extra ? `${clone.url}
|
|
12672
12757
|
|
|
12673
|
-
${extra}` : url
|
|
12674
|
-
return { ok: true, cwd, prompt };
|
|
12758
|
+
${extra}` : clone.url;
|
|
12759
|
+
return { ok: true, cwd: clone.cwd, prompt };
|
|
12675
12760
|
}
|
|
12676
12761
|
|
|
12677
12762
|
// src/commands/sessions/web/fromGithub/sessionFromGithub.ts
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
return;
|
|
12686
|
-
}
|
|
12687
|
-
const plan2 = planGithubSession(body, expandTilde2(loadConfig().clone.baseDir));
|
|
12688
|
-
if (!plan2.ok) {
|
|
12689
|
-
respondJson(res, plan2.status, { error: plan2.error });
|
|
12690
|
-
return;
|
|
12691
|
-
}
|
|
12692
|
-
try {
|
|
12693
|
-
const sessionId = await requestClaudeSession(plan2.prompt, plan2.cwd);
|
|
12694
|
-
respondJson(res, 200, { sessionId, cwd: plan2.cwd });
|
|
12695
|
-
} catch (error) {
|
|
12696
|
-
respondJson(res, 500, {
|
|
12697
|
-
error: error instanceof Error ? error.message : String(error)
|
|
12698
|
-
});
|
|
12699
|
-
}
|
|
12763
|
+
function sessionFromGithub(req, res) {
|
|
12764
|
+
return launchFromGithub(
|
|
12765
|
+
req,
|
|
12766
|
+
res,
|
|
12767
|
+
planGithubSession,
|
|
12768
|
+
(plan2) => requestClaudeSession(plan2.prompt, plan2.cwd)
|
|
12769
|
+
);
|
|
12700
12770
|
}
|
|
12701
12771
|
|
|
12702
12772
|
// src/commands/sessions/web/fromGithub/sessionFromGithubPreflight.ts
|
|
@@ -18305,6 +18375,8 @@ var routes2 = {
|
|
|
18305
18375
|
"GET /api/repo-location": getRepoLocation,
|
|
18306
18376
|
"POST /api/sessions/from-github": sessionFromGithub,
|
|
18307
18377
|
"OPTIONS /api/sessions/from-github": sessionFromGithubPreflight,
|
|
18378
|
+
"POST /api/sessions/review-from-github": reviewFromGithub,
|
|
18379
|
+
"OPTIONS /api/sessions/review-from-github": sessionFromGithubPreflight,
|
|
18308
18380
|
"POST /api/open-in-code": openInCode,
|
|
18309
18381
|
"POST /api/pr-preview/upload-image": uploadPrImage,
|
|
18310
18382
|
"GET /api/pr-preview/image": previewImage,
|