@staff0rd/assist 0.257.0 → 0.259.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.257.0",
9
+ version: "0.259.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -4587,17 +4587,95 @@ function getHtml() {
4587
4587
  </html>`;
4588
4588
  }
4589
4589
 
4590
- // src/commands/sessions/web/openInCode.ts
4591
- import { exec as exec2 } from "child_process";
4592
- import { promisify } from "util";
4593
- var execAsync = promisify(exec2);
4594
- async function openInCode(req, res) {
4590
+ // src/commands/prs/getPreferredRemoteRepo.ts
4591
+ import { execSync as execSync19 } from "child_process";
4592
+ var GITHUB_URL_PATTERN = /(?:git@github\.com:|https:\/\/github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?\/?$/;
4593
+ function parseGitHubUrl(url) {
4594
+ const match = url.match(GITHUB_URL_PATTERN);
4595
+ if (!match) return null;
4596
+ return { org: match[1], repo: match[2] };
4597
+ }
4598
+ function tryGetRemoteUrl(remote, cwd) {
4599
+ try {
4600
+ return execSync19(`git remote get-url ${remote}`, {
4601
+ encoding: "utf-8",
4602
+ stdio: ["pipe", "pipe", "pipe"],
4603
+ cwd
4604
+ }).trim();
4605
+ } catch {
4606
+ return null;
4607
+ }
4608
+ }
4609
+ function getCurrentBranchRemote(cwd) {
4610
+ try {
4611
+ const ref = execSync19(
4612
+ "git rev-parse --abbrev-ref --symbolic-full-name @{u}",
4613
+ { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"], cwd }
4614
+ ).trim();
4615
+ const [remote] = ref.split("/", 1);
4616
+ return remote || null;
4617
+ } catch {
4618
+ return null;
4619
+ }
4620
+ }
4621
+ function listRemotes(cwd) {
4622
+ try {
4623
+ return execSync19("git remote", {
4624
+ encoding: "utf-8",
4625
+ stdio: ["pipe", "pipe", "pipe"],
4626
+ cwd
4627
+ }).trim().split("\n").filter(Boolean);
4628
+ } catch {
4629
+ return [];
4630
+ }
4631
+ }
4632
+ function getPreferredRemoteRepo(cwd) {
4633
+ const candidates = [];
4634
+ const tracked = getCurrentBranchRemote(cwd);
4635
+ if (tracked) candidates.push(tracked);
4636
+ if (!candidates.includes("origin")) candidates.push("origin");
4637
+ for (const remote of listRemotes(cwd)) {
4638
+ if (remote !== "upstream" && !candidates.includes(remote)) {
4639
+ candidates.push(remote);
4640
+ }
4641
+ }
4642
+ for (const remote of candidates) {
4643
+ const url = tryGetRemoteUrl(remote, cwd);
4644
+ if (!url) continue;
4645
+ const parsed = parseGitHubUrl(url);
4646
+ if (parsed) return parsed;
4647
+ }
4648
+ return null;
4649
+ }
4650
+
4651
+ // src/commands/sessions/web/getCwdParam.ts
4652
+ function getCwdParam(req, res) {
4595
4653
  const url = new URL(req.url ?? "/", "http://localhost");
4596
4654
  const cwd = url.searchParams.get("cwd");
4597
4655
  if (!cwd) {
4598
4656
  respondJson(res, 400, { error: "Missing cwd" });
4599
- return;
4657
+ return null;
4600
4658
  }
4659
+ return cwd;
4660
+ }
4661
+
4662
+ // src/commands/sessions/web/githubUrl.ts
4663
+ function githubUrl(req, res) {
4664
+ const cwd = getCwdParam(req, res);
4665
+ if (!cwd) return;
4666
+ const repo = getPreferredRemoteRepo(cwd);
4667
+ respondJson(res, 200, {
4668
+ url: repo ? `https://github.com/${repo.org}/${repo.repo}` : null
4669
+ });
4670
+ }
4671
+
4672
+ // src/commands/sessions/web/openInCode.ts
4673
+ import { exec as exec2 } from "child_process";
4674
+ import { promisify } from "util";
4675
+ var execAsync = promisify(exec2);
4676
+ async function openInCode(req, res) {
4677
+ const cwd = getCwdParam(req, res);
4678
+ if (!cwd) return;
4601
4679
  try {
4602
4680
  await execAsync(`code "${cwd}"`);
4603
4681
  respondJson(res, 200, { ok: true });
@@ -4633,7 +4711,8 @@ var routes = {
4633
4711
  "POST /api/items": createItem,
4634
4712
  "GET /api/backlog/exists": getBacklogExists,
4635
4713
  "POST /api/backlog/init": initBacklog,
4636
- "POST /api/open-in-code": openInCode
4714
+ "POST /api/open-in-code": openInCode,
4715
+ "GET /api/github-url": githubUrl
4637
4716
  };
4638
4717
  var handleRequest = createFallbackHandler(
4639
4718
  routes,
@@ -6843,7 +6922,7 @@ import { homedir as homedir6 } from "os";
6843
6922
  import { join as join21 } from "path";
6844
6923
 
6845
6924
  // src/shared/checkCliAvailable.ts
6846
- import { execSync as execSync19 } from "child_process";
6925
+ import { execSync as execSync20 } from "child_process";
6847
6926
  function checkCliAvailable(cli) {
6848
6927
  const binary = cli.split(/\s+/)[0];
6849
6928
  const opts = {
@@ -6851,11 +6930,11 @@ function checkCliAvailable(cli) {
6851
6930
  stdio: ["ignore", "pipe", "pipe"]
6852
6931
  };
6853
6932
  try {
6854
- execSync19(`command -v ${binary}`, opts);
6933
+ execSync20(`command -v ${binary}`, opts);
6855
6934
  return true;
6856
6935
  } catch {
6857
6936
  try {
6858
- execSync19(`where ${binary}`, opts);
6937
+ execSync20(`where ${binary}`, opts);
6859
6938
  return true;
6860
6939
  } catch {
6861
6940
  return false;
@@ -7975,7 +8054,7 @@ function loadBlogSkipDays(repoName) {
7975
8054
  }
7976
8055
 
7977
8056
  // src/commands/devlog/shared.ts
7978
- import { execSync as execSync20 } from "child_process";
8057
+ import { execSync as execSync21 } from "child_process";
7979
8058
  import chalk89 from "chalk";
7980
8059
 
7981
8060
  // src/shared/getRepoName.ts
@@ -8067,7 +8146,7 @@ function loadAllDevlogLatestDates() {
8067
8146
  // src/commands/devlog/shared.ts
8068
8147
  function getCommitFiles(hash) {
8069
8148
  try {
8070
- const output = execSync20(`git show --name-only --format="" ${hash}`, {
8149
+ const output = execSync21(`git show --name-only --format="" ${hash}`, {
8071
8150
  encoding: "utf-8"
8072
8151
  });
8073
8152
  return output.trim().split("\n").filter(Boolean);
@@ -8163,11 +8242,11 @@ function list3(options2) {
8163
8242
  }
8164
8243
 
8165
8244
  // src/commands/devlog/getLastVersionInfo.ts
8166
- import { execFileSync as execFileSync2, execSync as execSync21 } from "child_process";
8245
+ import { execFileSync as execFileSync2, execSync as execSync22 } from "child_process";
8167
8246
  import semver from "semver";
8168
8247
  function getVersionAtCommit(hash) {
8169
8248
  try {
8170
- const content = execSync21(`git show ${hash}:package.json`, {
8249
+ const content = execSync22(`git show ${hash}:package.json`, {
8171
8250
  encoding: "utf-8"
8172
8251
  });
8173
8252
  const pkg = JSON.parse(content);
@@ -8340,7 +8419,7 @@ function next2(options2) {
8340
8419
  }
8341
8420
 
8342
8421
  // src/commands/devlog/repos/index.ts
8343
- import { execSync as execSync22 } from "child_process";
8422
+ import { execSync as execSync23 } from "child_process";
8344
8423
 
8345
8424
  // src/commands/devlog/repos/printReposTable.ts
8346
8425
  import chalk93 from "chalk";
@@ -8375,7 +8454,7 @@ function getStatus(lastPush, lastDevlog) {
8375
8454
  return lastDevlog < lastPush ? "outdated" : "ok";
8376
8455
  }
8377
8456
  function fetchRepos(days, all) {
8378
- const json = execSync22(
8457
+ const json = execSync23(
8379
8458
  "gh repo list staff0rd --json name,pushedAt,isArchived --limit 200",
8380
8459
  { encoding: "utf-8" }
8381
8460
  );
@@ -8735,7 +8814,7 @@ async function deps(csprojPath, options2) {
8735
8814
  }
8736
8815
 
8737
8816
  // src/commands/dotnet/getChangedCsFiles.ts
8738
- import { execSync as execSync23 } from "child_process";
8817
+ import { execSync as execSync24 } from "child_process";
8739
8818
  var SCOPE_ALL = "all";
8740
8819
  var SCOPE_BASE = "base:";
8741
8820
  var SCOPE_COMMIT = "commit:";
@@ -8759,7 +8838,7 @@ function getChangedCsFiles(scope) {
8759
8838
  } else {
8760
8839
  cmd = "git diff --name-only HEAD";
8761
8840
  }
8762
- const output = execSync23(cmd, { encoding: "utf-8" }).trim();
8841
+ const output = execSync24(cmd, { encoding: "utf-8" }).trim();
8763
8842
  if (output === "") return [];
8764
8843
  return output.split("\n").filter((f) => f.toLowerCase().endsWith(".cs"));
8765
8844
  }
@@ -8957,14 +9036,14 @@ function parseInspectReport(json) {
8957
9036
  }
8958
9037
 
8959
9038
  // src/commands/dotnet/runInspectCode.ts
8960
- import { execSync as execSync24 } from "child_process";
9039
+ import { execSync as execSync25 } from "child_process";
8961
9040
  import { existsSync as existsSync29, readFileSync as readFileSync24, unlinkSync as unlinkSync6 } from "fs";
8962
9041
  import { tmpdir as tmpdir3 } from "os";
8963
9042
  import path25 from "path";
8964
9043
  import chalk103 from "chalk";
8965
9044
  function assertJbInstalled() {
8966
9045
  try {
8967
- execSync24("jb inspectcode --version", { stdio: "pipe" });
9046
+ execSync25("jb inspectcode --version", { stdio: "pipe" });
8968
9047
  } catch {
8969
9048
  console.error(chalk103.red("jb is not installed. Install with:"));
8970
9049
  console.error(
@@ -8978,7 +9057,7 @@ function runInspectCode(slnPath, include, swea) {
8978
9057
  const includeFlag = include ? ` --include="${include}"` : "";
8979
9058
  const sweaFlag = swea ? " --swea" : "";
8980
9059
  try {
8981
- execSync24(
9060
+ execSync25(
8982
9061
  `jb inspectcode "${slnPath}" -o="${reportPath}"${includeFlag}${sweaFlag} --verbosity=OFF`,
8983
9062
  { stdio: "pipe" }
8984
9063
  );
@@ -8999,7 +9078,7 @@ function runInspectCode(slnPath, include, swea) {
8999
9078
  }
9000
9079
 
9001
9080
  // src/commands/dotnet/runRoslynInspect.ts
9002
- import { execSync as execSync25 } from "child_process";
9081
+ import { execSync as execSync26 } from "child_process";
9003
9082
  import chalk104 from "chalk";
9004
9083
  function resolveMsbuildPath() {
9005
9084
  const { run: run4 } = loadConfig();
@@ -9010,7 +9089,7 @@ function resolveMsbuildPath() {
9010
9089
  function assertMsbuildInstalled() {
9011
9090
  const msbuild = resolveMsbuildPath();
9012
9091
  try {
9013
- execSync25(`"${msbuild}" -version`, { stdio: "pipe" });
9092
+ execSync26(`"${msbuild}" -version`, { stdio: "pipe" });
9014
9093
  } catch {
9015
9094
  console.error(chalk104.red(`msbuild not found at: ${msbuild}`));
9016
9095
  console.error(
@@ -9036,7 +9115,7 @@ function runRoslynInspect(slnPath) {
9036
9115
  const msbuild = resolveMsbuildPath();
9037
9116
  let output;
9038
9117
  try {
9039
- output = execSync25(
9118
+ output = execSync26(
9040
9119
  `"${msbuild}" "${slnPath}" -t:Build -v:minimal -maxcpucount -p:EnforceCodeStyleInBuild=true -p:RunAnalyzersDuringBuild=true 2>&1`,
9041
9120
  { encoding: "utf-8", stdio: "pipe", maxBuffer: 50 * 1024 * 1024 }
9042
9121
  );
@@ -9598,12 +9677,12 @@ function adfToText(doc) {
9598
9677
  }
9599
9678
 
9600
9679
  // src/commands/jira/fetchIssue.ts
9601
- import { execSync as execSync26 } from "child_process";
9680
+ import { execSync as execSync27 } from "child_process";
9602
9681
  import chalk108 from "chalk";
9603
9682
  function fetchIssue(issueKey, fields) {
9604
9683
  let result;
9605
9684
  try {
9606
- result = execSync26(
9685
+ result = execSync27(
9607
9686
  `acli jira workitem view ${issueKey} -f ${fields} --json`,
9608
9687
  { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
9609
9688
  );
@@ -9649,7 +9728,7 @@ function acceptanceCriteria(issueKey) {
9649
9728
  }
9650
9729
 
9651
9730
  // src/commands/jira/jiraAuth.ts
9652
- import { execSync as execSync27 } from "child_process";
9731
+ import { execSync as execSync28 } from "child_process";
9653
9732
 
9654
9733
  // src/shared/loadJson.ts
9655
9734
  import { existsSync as existsSync32, mkdirSync as mkdirSync9, readFileSync as readFileSync27, writeFileSync as writeFileSync20 } from "fs";
@@ -9713,7 +9792,7 @@ async function jiraAuth() {
9713
9792
  console.error("All fields are required.");
9714
9793
  process.exit(1);
9715
9794
  }
9716
- execSync27(`acli jira auth login --site ${site} --email "${email}" --token`, {
9795
+ execSync28(`acli jira auth login --site ${site} --email "${email}" --token`, {
9717
9796
  encoding: "utf-8",
9718
9797
  input: token,
9719
9798
  stdio: ["pipe", "inherit", "inherit"]
@@ -10196,67 +10275,6 @@ function registerPrompts(program2) {
10196
10275
 
10197
10276
  // src/commands/prs/shared.ts
10198
10277
  import { execSync as execSync29 } from "child_process";
10199
-
10200
- // src/commands/prs/getPreferredRemoteRepo.ts
10201
- import { execSync as execSync28 } from "child_process";
10202
- var GITHUB_URL_PATTERN = /(?:git@github\.com:|https:\/\/github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?\/?$/;
10203
- function parseGitHubUrl(url) {
10204
- const match = url.match(GITHUB_URL_PATTERN);
10205
- if (!match) return null;
10206
- return { org: match[1], repo: match[2] };
10207
- }
10208
- function tryGetRemoteUrl(remote) {
10209
- try {
10210
- return execSync28(`git remote get-url ${remote}`, {
10211
- encoding: "utf-8",
10212
- stdio: ["pipe", "pipe", "pipe"]
10213
- }).trim();
10214
- } catch {
10215
- return null;
10216
- }
10217
- }
10218
- function getCurrentBranchRemote() {
10219
- try {
10220
- const ref = execSync28(
10221
- "git rev-parse --abbrev-ref --symbolic-full-name @{u}",
10222
- { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
10223
- ).trim();
10224
- const [remote] = ref.split("/", 1);
10225
- return remote || null;
10226
- } catch {
10227
- return null;
10228
- }
10229
- }
10230
- function listRemotes() {
10231
- try {
10232
- return execSync28("git remote", {
10233
- encoding: "utf-8",
10234
- stdio: ["pipe", "pipe", "pipe"]
10235
- }).trim().split("\n").filter(Boolean);
10236
- } catch {
10237
- return [];
10238
- }
10239
- }
10240
- function getPreferredRemoteRepo() {
10241
- const candidates = [];
10242
- const tracked = getCurrentBranchRemote();
10243
- if (tracked) candidates.push(tracked);
10244
- if (!candidates.includes("origin")) candidates.push("origin");
10245
- for (const remote of listRemotes()) {
10246
- if (remote !== "upstream" && !candidates.includes(remote)) {
10247
- candidates.push(remote);
10248
- }
10249
- }
10250
- for (const remote of candidates) {
10251
- const url = tryGetRemoteUrl(remote);
10252
- if (!url) continue;
10253
- const parsed = parseGitHubUrl(url);
10254
- if (parsed) return parsed;
10255
- }
10256
- return null;
10257
- }
10258
-
10259
- // src/commands/prs/shared.ts
10260
10278
  function isGhNotInstalled(error) {
10261
10279
  if (error instanceof Error) {
10262
10280
  const msg = error.message.toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.257.0",
3
+ "version": "0.259.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {