@staff0rd/assist 0.828.1 → 0.829.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.828.1",
9
+ version: "0.829.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -12607,6 +12607,85 @@ async function fileContent(req, res) {
12607
12607
  }
12608
12608
  }
12609
12609
 
12610
+ // src/commands/sessions/shared/requestClaudeSession.ts
12611
+ function requestClaudeSession(prompt, cwd, options2) {
12612
+ return requestSession({
12613
+ type: "create",
12614
+ prompt,
12615
+ cwd,
12616
+ inPlace: options2?.inPlace === true,
12617
+ launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
12618
+ });
12619
+ }
12620
+
12621
+ // src/commands/sessions/web/readJsonBody.ts
12622
+ async function readJsonBody(req) {
12623
+ const chunks = [];
12624
+ for await (const chunk of req) chunks.push(chunk);
12625
+ return JSON.parse(Buffer.concat(chunks).toString("utf8"));
12626
+ }
12627
+
12628
+ // src/commands/sessions/web/fromGithub/parseGithubOrigin.ts
12629
+ function parseGithubOrigin(url) {
12630
+ let parsed;
12631
+ try {
12632
+ parsed = new URL(url);
12633
+ } catch {
12634
+ return null;
12635
+ }
12636
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
12637
+ if (parsed.hostname.toLowerCase() !== "github.com") return null;
12638
+ const [owner, repo] = parsed.pathname.split("/").filter(Boolean);
12639
+ if (!owner || !repo) return null;
12640
+ return `github.com/${owner}/${repo.replace(/\.git$/i, "")}`;
12641
+ }
12642
+
12643
+ // src/commands/sessions/web/fromGithub/planGithubSession.ts
12644
+ function planGithubSession(body, baseDir) {
12645
+ const { url, instructions } = body ?? {};
12646
+ if (typeof url !== "string" || !url.trim())
12647
+ return { ok: false, status: 400, error: "Missing url" };
12648
+ const origin = parseGithubOrigin(url.trim());
12649
+ if (!origin)
12650
+ return { ok: false, status: 400, error: `Not a GitHub repo URL: ${url}` };
12651
+ const { cwd } = resolveRepoLocation(origin, void 0, baseDir);
12652
+ if (!cwd)
12653
+ return {
12654
+ ok: false,
12655
+ status: 404,
12656
+ error: `${origin.replace("github.com/", "")} is not cloned under ${baseDir}`
12657
+ };
12658
+ const extra = typeof instructions === "string" ? instructions.trim() : "";
12659
+ const prompt = extra ? `${url.trim()}
12660
+
12661
+ ${extra}` : url.trim();
12662
+ return { ok: true, cwd, prompt };
12663
+ }
12664
+
12665
+ // src/commands/sessions/web/fromGithub/sessionFromGithub.ts
12666
+ async function sessionFromGithub(req, res) {
12667
+ let body;
12668
+ try {
12669
+ body = await readJsonBody(req);
12670
+ } catch {
12671
+ respondJson(res, 400, { error: "Invalid JSON body" });
12672
+ return;
12673
+ }
12674
+ const plan2 = planGithubSession(body, expandTilde2(loadConfig().clone.baseDir));
12675
+ if (!plan2.ok) {
12676
+ respondJson(res, plan2.status, { error: plan2.error });
12677
+ return;
12678
+ }
12679
+ try {
12680
+ const sessionId = await requestClaudeSession(plan2.prompt, plan2.cwd);
12681
+ respondJson(res, 200, { sessionId, cwd: plan2.cwd });
12682
+ } catch (error) {
12683
+ respondJson(res, 500, {
12684
+ error: error instanceof Error ? error.message : String(error)
12685
+ });
12686
+ }
12687
+ }
12688
+
12610
12689
  // src/shared/db/listBackups.ts
12611
12690
  import { desc as desc2 } from "drizzle-orm";
12612
12691
  async function listBackups(db) {
@@ -14986,13 +15065,6 @@ async function nextItems(req, res) {
14986
15065
  respondJson(res, 200, body);
14987
15066
  }
14988
15067
 
14989
- // src/commands/sessions/web/readJsonBody.ts
14990
- async function readJsonBody(req) {
14991
- const chunks = [];
14992
- for await (const chunk of req) chunks.push(chunk);
14993
- return JSON.parse(Buffer.concat(chunks).toString("utf8"));
14994
- }
14995
-
14996
15068
  // src/commands/github/issue/readGhTokenScopes.ts
14997
15069
  import { spawnSync as spawnSync3 } from "child_process";
14998
15070
  var SCOPES_LINE = /Token scopes:\s*(.*)/;
@@ -18199,6 +18271,7 @@ var routes2 = {
18199
18271
  "GET /api/items": listItems,
18200
18272
  "GET /api/backlog/summary": getBacklogSummary,
18201
18273
  "GET /api/repo-location": getRepoLocation,
18274
+ "POST /api/sessions/from-github": sessionFromGithub,
18202
18275
  "POST /api/open-in-code": openInCode,
18203
18276
  "POST /api/pr-preview/upload-image": uploadPrImage,
18204
18277
  "GET /api/pr-preview/image": previewImage,
@@ -30496,17 +30569,6 @@ async function placePr(prNumber, title, body, options2, attachments = []) {
30496
30569
  // src/commands/prs/previewAndPlace.ts
30497
30570
  import { randomUUID as randomUUID17 } from "crypto";
30498
30571
 
30499
- // src/commands/sessions/shared/requestClaudeSession.ts
30500
- function requestClaudeSession(prompt, cwd, options2) {
30501
- return requestSession({
30502
- type: "create",
30503
- prompt,
30504
- cwd,
30505
- inPlace: options2?.inPlace === true,
30506
- launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
30507
- });
30508
- }
30509
-
30510
30572
  // src/commands/review/announcePr.ts
30511
30573
  function announcePr(prNumber) {
30512
30574
  return startChainedSession(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.828.1",
3
+ "version": "0.829.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {