automata-cli 0.11.0-develop.477 → 0.11.0-develop.484

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -458,6 +458,7 @@ function parseOrigin(rawUrl) {
458
458
 
459
459
  // src/config/azdoService.ts
460
460
  import { spawnSync as spawnSync2 } from "child_process";
461
+ var UNRESOLVED_THREAD_STATUSES = /* @__PURE__ */ new Set(["active", "pending"]);
461
462
  function run(cmd, args) {
462
463
  const result = spawnSync2(cmd, args, { encoding: "utf8" });
463
464
  if (result.error) {
@@ -564,6 +565,32 @@ function getPrInfo(branch) {
564
565
  }
565
566
  return toPrInfo(pr, (pr.checks ?? []).map(toPrCheck));
566
567
  }
568
+ function getPrComments(branch) {
569
+ const listed = runJson(
570
+ ["pr", "list", "--branch", branch, "--status", "active"],
571
+ "Failed to list Azure DevOps pull requests. Is `azdo` installed and authenticated?"
572
+ );
573
+ const pr = listed.pullRequests[0];
574
+ if (pr === void 0) return null;
575
+ const output = runJson(
576
+ ["pr", "comments", "--pr-number", String(pr.id), "--exclude-resolved", "--code-related-only", "--exclude-system"],
577
+ "Failed to read the Azure DevOps pull request threads."
578
+ );
579
+ const comments = [];
580
+ for (const thread of output.threads) {
581
+ if (!UNRESOLVED_THREAD_STATUSES.has(thread.status) || thread.threadContext === null) continue;
582
+ const first = thread.comments.find((c) => c.commentType !== "system");
583
+ if (first === void 0) continue;
584
+ comments.push({
585
+ author: first.author ?? "Unknown",
586
+ body: first.content,
587
+ path: thread.threadContext,
588
+ line: thread.line,
589
+ createdAt: first.publishedAt ?? ""
590
+ });
591
+ }
592
+ return comments;
593
+ }
567
594
 
568
595
  // src/remote/backend.ts
569
596
  var AZDO_GAP_DOC = "docs/azdo-gap.md";
@@ -1316,10 +1343,11 @@ function getPrCommentsGh(branch) {
1316
1343
  };
1317
1344
  });
1318
1345
  }
1319
- function getPrComments(branch) {
1346
+ function getPrComments2(branch) {
1320
1347
  const config = readConfig();
1321
1348
  if (selectBackend(config) === "azdo") {
1322
- return "unsupported";
1349
+ assertAzdoRemote();
1350
+ return getPrComments(branch);
1323
1351
  }
1324
1352
  return getPrCommentsGh(branch);
1325
1353
  }
@@ -1332,11 +1360,10 @@ function resolveCurrentBranchComments() {
1332
1360
  }
1333
1361
  let raw;
1334
1362
  try {
1335
- raw = getPrComments(branch);
1363
+ raw = getPrComments2(branch);
1336
1364
  } catch (err) {
1337
1365
  return { ok: false, kind: "error", message: err.message };
1338
1366
  }
1339
- if (raw === "unsupported") return { ok: false, kind: "unsupported" };
1340
1367
  if (raw === null) return { ok: false, kind: "no-pr", branch };
1341
1368
  return { ok: true, branch, comments: raw };
1342
1369
  }
@@ -1782,12 +1809,7 @@ var CONTROL_CHARS_RE = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;
1782
1809
  function sanitizeText(text) {
1783
1810
  return text.replace(ANSI_ESCAPE_RE, "").replace(CONTROL_CHARS_RE, "");
1784
1811
  }
1785
- var getPrCommentsCmd = new Command2("get-pr-comments").description("List open (unresolved) review comments on the pull request for the current branch (GitHub only)").option("--json", "Output as JSON array").addHelpText(
1786
- "after",
1787
- `
1788
- Only GitHub (remoteType: gh) is supported. Azure DevOps is not supported.
1789
- See docs/azdo-gap.md for details.`
1790
- ).action((options) => {
1812
+ var getPrCommentsCmd = new Command2("get-pr-comments").description("List open (unresolved) review comments on the pull request for the current branch").option("--json", "Output as JSON array").action((options) => {
1791
1813
  let branch;
1792
1814
  try {
1793
1815
  branch = getCurrentBranch();
@@ -1798,19 +1820,12 @@ See docs/azdo-gap.md for details.`
1798
1820
  }
1799
1821
  let comments;
1800
1822
  try {
1801
- comments = getPrComments(branch);
1823
+ comments = getPrComments2(branch);
1802
1824
  } catch (err) {
1803
1825
  process.stderr.write(`Error: ${err.message}
1804
1826
  `);
1805
1827
  process.exit(1);
1806
1828
  }
1807
- if (comments === "unsupported") {
1808
- process.stderr.write(
1809
- `Error: ${azdoUnsupportedMessage("get-pr-comments")}
1810
- `
1811
- );
1812
- process.exit(1);
1813
- }
1814
1829
  if (comments === null) {
1815
1830
  process.stderr.write(`Error: No pull request found for branch: ${branch}
1816
1831
  `);
@@ -3452,13 +3467,6 @@ var executeFixCommentsCmd = addAiOptions(
3452
3467
  `);
3453
3468
  process.exit(1);
3454
3469
  }
3455
- if (result.kind === "unsupported") {
3456
- process.stderr.write(
3457
- `Error: ${azdoUnsupportedMessage("fix-comments")}
3458
- `
3459
- );
3460
- process.exit(1);
3461
- }
3462
3470
  process.stderr.write(`Error: No pull request found for branch: ${result.branch}
3463
3471
  `);
3464
3472
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automata-cli",
3
- "version": "0.11.0-develop.477",
3
+ "version": "0.11.0-develop.484",
4
4
  "description": "Automata CLI tool",
5
5
  "type": "module",
6
6
  "engines": {